[cfe-commits] r164335 - in /cfe/trunk: lib/Serialization/ASTReaderDecl.cpp lib/Serialization/ASTWriterDecl.cpp test/PCH/cxx11-constexpr.cpp
Douglas Gregor
dgregor at apple.com
Thu Sep 20 16:43:29 PDT 2012
Author: dgregor
Date: Thu Sep 20 18:43:29 2012
New Revision: 164335
URL: http://llvm.org/viewvc/llvm-project?rev=164335&view=rev
Log:
Serialize the 'IsConstexpr' bit of VarDecls. Fixes <rdar://problem/12328814>.
Modified:
cfe/trunk/lib/Serialization/ASTReaderDecl.cpp
cfe/trunk/lib/Serialization/ASTWriterDecl.cpp
cfe/trunk/test/PCH/cxx11-constexpr.cpp
Modified: cfe/trunk/lib/Serialization/ASTReaderDecl.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Serialization/ASTReaderDecl.cpp?rev=164335&r1=164334&r2=164335&view=diff
==============================================================================
--- cfe/trunk/lib/Serialization/ASTReaderDecl.cpp (original)
+++ cfe/trunk/lib/Serialization/ASTReaderDecl.cpp Thu Sep 20 18:43:29 2012
@@ -898,7 +898,8 @@
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);
Modified: cfe/trunk/lib/Serialization/ASTWriterDecl.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Serialization/ASTWriterDecl.cpp?rev=164335&r1=164334&r2=164335&view=diff
==============================================================================
--- cfe/trunk/lib/Serialization/ASTWriterDecl.cpp (original)
+++ cfe/trunk/lib/Serialization/ASTWriterDecl.cpp Thu Sep 20 18:43:29 2012
@@ -675,6 +675,8 @@
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 @@
D->getInitStyle() == VarDecl::CInit &&
D->getInit() == 0 &&
!isa<ParmVarDecl>(D) &&
+ !D->isConstexpr() &&
!SpecInfo)
AbbrevToUse = Writer.getDeclVarAbbrev();
@@ -1478,6 +1481,7 @@
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 @@
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
Modified: cfe/trunk/test/PCH/cxx11-constexpr.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/PCH/cxx11-constexpr.cpp?rev=164335&r1=164334&r2=164335&view=diff
==============================================================================
--- cfe/trunk/test/PCH/cxx11-constexpr.cpp (original)
+++ cfe/trunk/test/PCH/cxx11-constexpr.cpp Thu Sep 20 18:43:29 2012
@@ -20,6 +20,13 @@
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 B b; // expected-error {{constant expression}} expected-note {{non-constexpr}}
// expected-note at 9 {{here}}
+static_assert(plus_seven(3) == 10, "");
+
#endif
More information about the cfe-commits
mailing list