diff options
| author | Richard Smith <richard-llvm@metafoo.co.uk> | 2012-07-11 22:37:56 +0000 |
|---|---|---|
| committer | Richard Smith <richard-llvm@metafoo.co.uk> | 2012-07-11 22:37:56 +0000 |
| commit | e3f470a718ec00eb8b546e405fa59bc2df2d7c46 (patch) | |
| tree | da7223195380885f10c3fb658c4320a8667787e3 /include | |
| parent | 18b7f95bdbfbd90c1f8e027225fb2cb8fca7134a (diff) | |
| download | clang-e3f470a718ec00eb8b546e405fa59bc2df2d7c46.tar.gz clang-e3f470a718ec00eb8b546e405fa59bc2df2d7c46.tar.bz2 clang-e3f470a718ec00eb8b546e405fa59bc2df2d7c46.tar.xz | |
Stop instantiating a class if we hit a static_assert failure. Also, if the
static_assert fails when parsing the template, don't diagnose it again on every
instantiation.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@160088 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'include')
| -rw-r--r-- | include/clang/AST/DeclCXX.h | 20 | ||||
| -rw-r--r-- | include/clang/Sema/Sema.h | 5 |
2 files changed, 16 insertions, 9 deletions
diff --git a/include/clang/AST/DeclCXX.h b/include/clang/AST/DeclCXX.h index 9130e28a47..0d498fe4e5 100644 --- a/include/clang/AST/DeclCXX.h +++ b/include/clang/AST/DeclCXX.h @@ -2892,31 +2892,33 @@ public: /// \brief Represents a C++11 static_assert declaration. class StaticAssertDecl : public Decl { virtual void anchor(); - Expr *AssertExpr; + llvm::PointerIntPair<Expr *, 1, bool> AssertExprAndFailed; StringLiteral *Message; SourceLocation RParenLoc; StaticAssertDecl(DeclContext *DC, SourceLocation StaticAssertLoc, - Expr *assertexpr, StringLiteral *message, - SourceLocation RParenLoc) - : Decl(StaticAssert, DC, StaticAssertLoc), AssertExpr(assertexpr), - Message(message), RParenLoc(RParenLoc) { } + Expr *AssertExpr, StringLiteral *Message, + SourceLocation RParenLoc, bool Failed) + : Decl(StaticAssert, DC, StaticAssertLoc), + AssertExprAndFailed(AssertExpr, Failed), Message(Message), + RParenLoc(RParenLoc) { } public: static StaticAssertDecl *Create(ASTContext &C, DeclContext *DC, SourceLocation StaticAssertLoc, Expr *AssertExpr, StringLiteral *Message, - SourceLocation RParenLoc); + SourceLocation RParenLoc, bool Failed); static StaticAssertDecl *CreateDeserialized(ASTContext &C, unsigned ID); - Expr *getAssertExpr() { return AssertExpr; } - const Expr *getAssertExpr() const { return AssertExpr; } + Expr *getAssertExpr() { return AssertExprAndFailed.getPointer(); } + const Expr *getAssertExpr() const { return AssertExprAndFailed.getPointer(); } StringLiteral *getMessage() { return Message; } const StringLiteral *getMessage() const { return Message; } + bool isFailed() const { return AssertExprAndFailed.getInt(); } + SourceLocation getRParenLoc() const { return RParenLoc; } - void setRParenLoc(SourceLocation L) { RParenLoc = L; } SourceRange getSourceRange() const LLVM_READONLY { return SourceRange(getLocation(), getRParenLoc()); diff --git a/include/clang/Sema/Sema.h b/include/clang/Sema/Sema.h index 6096466f08..35bbc0104f 100644 --- a/include/clang/Sema/Sema.h +++ b/include/clang/Sema/Sema.h @@ -4306,6 +4306,11 @@ public: Expr *AssertExpr, Expr *AssertMessageExpr, SourceLocation RParenLoc); + Decl *BuildStaticAssertDeclaration(SourceLocation StaticAssertLoc, + Expr *AssertExpr, + StringLiteral *AssertMessageExpr, + SourceLocation RParenLoc, + bool Failed); FriendDecl *CheckFriendTypeDecl(SourceLocation Loc, SourceLocation FriendLoc, |
