[cfe-commits] r106726 - in /cfe/trunk: lib/Frontend/PCHReaderStmt.cpp lib/Frontend/PCHWriterStmt.cpp test/PCH/cxx_exprs.cpp
Argyrios Kyrtzidis
akyrtzi at gmail.com
Thu Jun 24 01:57:09 PDT 2010
Author: akirtzidis
Date: Thu Jun 24 03:57:09 2010
New Revision: 106726
URL: http://llvm.org/viewvc/llvm-project?rev=106726&view=rev
Log:
Fix broken de/serialization for a couple of C++ Exprs.
Modified:
cfe/trunk/lib/Frontend/PCHReaderStmt.cpp
cfe/trunk/lib/Frontend/PCHWriterStmt.cpp
cfe/trunk/test/PCH/cxx_exprs.cpp
Modified: cfe/trunk/lib/Frontend/PCHReaderStmt.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/PCHReaderStmt.cpp?rev=106726&r1=106725&r2=106726&view=diff
==============================================================================
--- cfe/trunk/lib/Frontend/PCHReaderStmt.cpp (original)
+++ cfe/trunk/lib/Frontend/PCHReaderStmt.cpp Thu Jun 24 03:57:09 2010
@@ -957,12 +957,15 @@
unsigned PCHStmtReader::VisitCXXConstructExpr(CXXConstructExpr *E) {
VisitExpr(E);
+ assert(Record[Idx] == E->getNumArgs() &&
+ "Read wrong record during creation ?");
+ ++Idx; // NumArgs;
+ for (unsigned I = 0, N = E->getNumArgs(); I != N; ++I)
+ E->setArg(I, cast<Expr>(StmtStack[StmtStack.size() - N + I]));
E->setConstructor(cast<CXXConstructorDecl>(Reader.GetDecl(Record[Idx++])));
E->setLocation(SourceLocation::getFromRawEncoding(Record[Idx++]));
E->setElidable(Record[Idx++]);
E->setRequiresZeroInitialization(Record[Idx++]);
- for (unsigned I = 0, N = E->getNumArgs(); I != N; ++I)
- E->setArg(I, cast<Expr>(StmtStack[StmtStack.size() - N + I]));
E->setConstructionKind((CXXConstructExpr::ConstructionKind)Record[Idx++]);
return E->getNumArgs();
}
@@ -1032,7 +1035,7 @@
unsigned PCHStmtReader::VisitCXXThrowExpr(CXXThrowExpr *E) {
VisitExpr(E);
E->setThrowLoc(SourceLocation::getFromRawEncoding(Record[Idx++]));
- E->setSubExpr(cast<Expr>(StmtStack.back()));
+ E->setSubExpr(cast_or_null<Expr>(StmtStack.back()));
return 1;
}
@@ -1431,7 +1434,7 @@
case pch::EXPR_CXX_CONSTRUCT:
S = new (Context) CXXConstructExpr(Empty, *Context,
- Record[PCHStmtReader::NumExprFields + 2]);
+ Record[PCHStmtReader::NumExprFields]);
break;
case pch::EXPR_CXX_STATIC_CAST:
Modified: cfe/trunk/lib/Frontend/PCHWriterStmt.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/PCHWriterStmt.cpp?rev=106726&r1=106725&r2=106726&view=diff
==============================================================================
--- cfe/trunk/lib/Frontend/PCHWriterStmt.cpp (original)
+++ cfe/trunk/lib/Frontend/PCHWriterStmt.cpp Thu Jun 24 03:57:09 2010
@@ -869,13 +869,13 @@
void PCHStmtWriter::VisitCXXConstructExpr(CXXConstructExpr *E) {
VisitExpr(E);
+ Record.push_back(E->getNumArgs());
+ for (unsigned I = 0, N = E->getNumArgs(); I != N; ++I)
+ Writer.WriteSubStmt(E->getArg(I));
Writer.AddDeclRef(E->getConstructor(), Record);
Writer.AddSourceLocation(E->getLocation(), Record);
Record.push_back(E->isElidable());
Record.push_back(E->requiresZeroInitialization());
- Record.push_back(E->getNumArgs());
- for (unsigned I = 0, N = E->getNumArgs(); I != N; ++I)
- Writer.WriteSubStmt(E->getArg(I));
Record.push_back(E->getConstructionKind()); // FIXME: stable encoding
Code = pch::EXPR_CXX_CONSTRUCT;
}
Modified: cfe/trunk/test/PCH/cxx_exprs.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/PCH/cxx_exprs.cpp?rev=106726&r1=106725&r2=106726&view=diff
==============================================================================
--- cfe/trunk/test/PCH/cxx_exprs.cpp (original)
+++ cfe/trunk/test/PCH/cxx_exprs.cpp Thu Jun 24 03:57:09 2010
@@ -1,9 +1,9 @@
// Test this without pch.
-// RUN: %clang_cc1 -include %S/cxx_exprs.h -std=c++0x -fsyntax-only -verify %s
+// RUN: %clang_cc1 -include %S/cxx_exprs.h -std=c++0x -fsyntax-only -verify %s -ast-dump
-// Test with pch.
+// Test with pch. Use '-ast-dump' to force deserialization of function bodies.
// RUN: %clang_cc1 -x c++-header -std=c++0x -emit-pch -o %t %S/cxx_exprs.h
-// RUN: %clang_cc1 -std=c++0x -include-pch %t -fsyntax-only -verify %s
+// RUN: %clang_cc1 -std=c++0x -include-pch %t -fsyntax-only -verify %s -ast-dump
int integer;
double floating;
@@ -36,4 +36,4 @@
// CXXTypeidExpr
typeid_result1 typeid_1 = 0;
-typeid_result2 typeid_2 = 0;
\ No newline at end of file
+typeid_result2 typeid_2 = 0;
More information about the cfe-commits
mailing list