diff options
| author | Douglas Gregor <dgregor@apple.com> | 2012-09-20 23:43:29 +0000 |
|---|---|---|
| committer | Douglas Gregor <dgregor@apple.com> | 2012-09-20 23:43:29 +0000 |
| commit | 12cda633be4045e4c6c86e17e74a02adc96ede9d (patch) | |
| tree | e1a93aff8d0062f597768bc542141c4a71153d24 /clang | |
| parent | eacb4911a02806b55657e6249cf81ff258e10e65 (diff) | |
| download | bcm5719-llvm-12cda633be4045e4c6c86e17e74a02adc96ede9d.tar.gz bcm5719-llvm-12cda633be4045e4c6c86e17e74a02adc96ede9d.zip | |
Serialize the 'IsConstexpr' bit of VarDecls. Fixes <rdar://problem/12328814>.
llvm-svn: 164335
Diffstat (limited to 'clang')
| -rw-r--r-- | clang/lib/Serialization/ASTReaderDecl.cpp | 3 | ||||
| -rw-r--r-- | clang/lib/Serialization/ASTWriterDecl.cpp | 5 | ||||
| -rw-r--r-- | clang/test/PCH/cxx11-constexpr.cpp | 9 |
3 files changed, 16 insertions, 1 deletions
diff --git a/clang/lib/Serialization/ASTReaderDecl.cpp b/clang/lib/Serialization/ASTReaderDecl.cpp index 109d378105d..754ff36db79 100644 --- a/clang/lib/Serialization/ASTReaderDecl.cpp +++ b/clang/lib/Serialization/ASTReaderDecl.cpp @@ -898,7 +898,8 @@ void ASTDeclReader::VisitVarDecl(VarDecl *VD) { VD->VarDeclBits.NRVOVariable = Record[Idx++]; VD->VarDeclBits.CXXForRangeDecl = Record[Idx++]; VD->VarDeclBits.ARCPseudoStrong = Record[Idx++]; - + VD->VarDeclBits.IsConstexpr = Record[Idx++]; + // Only true variables (not parameters or implicit parameters) can be merged. if (VD->getKind() == Decl::Var) mergeRedeclarable(VD, Redecl); diff --git a/clang/lib/Serialization/ASTWriterDecl.cpp b/clang/lib/Serialization/ASTWriterDecl.cpp index 76a23321432..7122bca9699 100644 --- a/clang/lib/Serialization/ASTWriterDecl.cpp +++ b/clang/lib/Serialization/ASTWriterDecl.cpp @@ -675,6 +675,8 @@ void ASTDeclWriter::VisitVarDecl(VarDecl *D) { Record.push_back(D->isNRVOVariable()); Record.push_back(D->isCXXForRangeDecl()); Record.push_back(D->isARCPseudoStrong()); + Record.push_back(D->isConstexpr()); + if (D->getInit()) { Record.push_back(!D->isInitKnownICE() ? 1 : (D->isInitICE() ? 3 : 2)); Writer.AddStmt(D->getInit()); @@ -705,6 +707,7 @@ void ASTDeclWriter::VisitVarDecl(VarDecl *D) { D->getInitStyle() == VarDecl::CInit && D->getInit() == 0 && !isa<ParmVarDecl>(D) && + !D->isConstexpr() && !SpecInfo) AbbrevToUse = Writer.getDeclVarAbbrev(); @@ -1478,6 +1481,7 @@ void ASTWriter::WriteDeclsBlockAbbrevs() { Abv->Add(BitCodeAbbrevOp(0)); // isNRVOVariable Abv->Add(BitCodeAbbrevOp(0)); // isCXXForRangeDecl Abv->Add(BitCodeAbbrevOp(0)); // isARCPseudoStrong + Abv->Add(BitCodeAbbrevOp(0)); // isConstexpr Abv->Add(BitCodeAbbrevOp(0)); // HasInit Abv->Add(BitCodeAbbrevOp(0)); // HasMemberSpecializationInfo // ParmVarDecl @@ -1556,6 +1560,7 @@ void ASTWriter::WriteDeclsBlockAbbrevs() { Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); // isNRVOVariable Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); // isCXXForRangeDecl Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); // isARCPseudoStrong + Abv->Add(BitCodeAbbrevOp(0)); // isConstexpr Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); // HasInit Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); // HasMemberSpecInfo // Type Source Info diff --git a/clang/test/PCH/cxx11-constexpr.cpp b/clang/test/PCH/cxx11-constexpr.cpp index ce43206d396..8b722ce9809 100644 --- a/clang/test/PCH/cxx11-constexpr.cpp +++ b/clang/test/PCH/cxx11-constexpr.cpp @@ -20,6 +20,13 @@ struct D : B { int k; }; +constexpr int value = 7; + +template<typename T> +constexpr T plus_seven(T other) { + return value + other; +} + #else static_assert(D(4).k == 9, ""); @@ -28,4 +35,6 @@ constexpr int f(C c) { return 0; } // expected-error {{not a literal type}} constexpr B b; // expected-error {{constant expression}} expected-note {{non-constexpr}} // expected-note@9 {{here}} +static_assert(plus_seven(3) == 10, ""); + #endif |

