PCH support for MemberExpr and CallExpr.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@69186 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/AST/Expr.cpp b/lib/AST/Expr.cpp
index 5363397..99e07c4 100644
--- a/lib/AST/Expr.cpp
+++ b/lib/AST/Expr.cpp
@@ -186,6 +186,11 @@
RParenLoc = rparenloc;
}
+CallExpr::CallExpr(ASTContext &C, EmptyShell Empty)
+ : Expr(CallExprClass, Empty), SubExprs(0), NumArgs(0) {
+ SubExprs = new (C) Stmt*[1];
+}
+
void CallExpr::Destroy(ASTContext& C) {
DestroyChildren(C);
if (SubExprs) C.Deallocate(SubExprs);
diff --git a/lib/Frontend/PCHReader.cpp b/lib/Frontend/PCHReader.cpp
index 2da2102..083d0d6 100644
--- a/lib/Frontend/PCHReader.cpp
+++ b/lib/Frontend/PCHReader.cpp
@@ -245,6 +245,8 @@
unsigned VisitParenExpr(ParenExpr *E);
unsigned VisitUnaryOperator(UnaryOperator *E);
unsigned VisitSizeOfAlignOfExpr(SizeOfAlignOfExpr *E);
+ unsigned VisitCallExpr(CallExpr *E);
+ unsigned VisitMemberExpr(MemberExpr *E);
unsigned VisitCastExpr(CastExpr *E);
unsigned VisitBinaryOperator(BinaryOperator *E);
unsigned VisitImplicitCastExpr(ImplicitCastExpr *E);
@@ -348,6 +350,25 @@
return E->isArgumentType()? 0 : 1;
}
+unsigned PCHStmtReader::VisitCallExpr(CallExpr *E) {
+ VisitExpr(E);
+ E->setNumArgs(Reader.getContext(), Record[Idx++]);
+ E->setRParenLoc(SourceLocation::getFromRawEncoding(Record[Idx++]));
+ E->setCallee(ExprStack[ExprStack.size() - E->getNumArgs() - 1]);
+ for (unsigned I = 0, N = E->getNumArgs(); I != N; ++I)
+ E->setArg(I, ExprStack[ExprStack.size() - N + I]);
+ return E->getNumArgs() + 1;
+}
+
+unsigned PCHStmtReader::VisitMemberExpr(MemberExpr *E) {
+ VisitExpr(E);
+ E->setBase(ExprStack.back());
+ E->setMemberDecl(cast<NamedDecl>(Reader.GetDecl(Record[Idx++])));
+ E->setMemberLoc(SourceLocation::getFromRawEncoding(Record[Idx++]));
+ E->setArrow(Record[Idx++]);
+ return 1;
+}
+
unsigned PCHStmtReader::VisitCastExpr(CastExpr *E) {
VisitExpr(E);
E->setSubExpr(ExprStack.back());
@@ -1703,6 +1724,14 @@
E = new (Context) SizeOfAlignOfExpr(Empty);
break;
+ case pch::EXPR_CALL:
+ E = new (Context) CallExpr(Context, Empty);
+ break;
+
+ case pch::EXPR_MEMBER:
+ E = new (Context) MemberExpr(Empty);
+ break;
+
case pch::EXPR_BINARY_OPERATOR:
E = new (Context) BinaryOperator(Empty);
break;
diff --git a/lib/Frontend/PCHWriter.cpp b/lib/Frontend/PCHWriter.cpp
index 69b070f..6c3056a 100644
--- a/lib/Frontend/PCHWriter.cpp
+++ b/lib/Frontend/PCHWriter.cpp
@@ -453,6 +453,8 @@
void VisitParenExpr(ParenExpr *E);
void VisitUnaryOperator(UnaryOperator *E);
void VisitSizeOfAlignOfExpr(SizeOfAlignOfExpr *E);
+ void VisitCallExpr(CallExpr *E);
+ void VisitMemberExpr(MemberExpr *E);
void VisitCastExpr(CastExpr *E);
void VisitBinaryOperator(BinaryOperator *E);
void VisitImplicitCastExpr(ImplicitCastExpr *E);
@@ -550,6 +552,26 @@
Code = pch::EXPR_SIZEOF_ALIGN_OF;
}
+void PCHStmtWriter::VisitCallExpr(CallExpr *E) {
+ VisitExpr(E);
+ Record.push_back(E->getNumArgs());
+ Writer.AddSourceLocation(E->getRParenLoc(), Record);
+ Writer.WriteSubExpr(E->getCallee());
+ for (CallExpr::arg_iterator Arg = E->arg_begin(), ArgEnd = E->arg_end();
+ Arg != ArgEnd; ++Arg)
+ Writer.WriteSubExpr(*Arg);
+ Code = pch::EXPR_CALL;
+}
+
+void PCHStmtWriter::VisitMemberExpr(MemberExpr *E) {
+ VisitExpr(E);
+ Writer.WriteSubExpr(E->getBase());
+ Writer.AddDeclRef(E->getMemberDecl(), Record);
+ Writer.AddSourceLocation(E->getMemberLoc(), Record);
+ Record.push_back(E->isArrow());
+ Code = pch::EXPR_MEMBER;
+}
+
void PCHStmtWriter::VisitCastExpr(CastExpr *E) {
VisitExpr(E);
Writer.WriteSubExpr(E->getSubExpr());