Fix broken de/serialization for a couple of C++ Exprs.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@106726 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/Frontend/PCHReaderStmt.cpp b/lib/Frontend/PCHReaderStmt.cpp
index 4a38a36..652fdb1 100644
--- a/lib/Frontend/PCHReaderStmt.cpp
+++ b/lib/Frontend/PCHReaderStmt.cpp
@@ -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: