blob: f1137c0e3386844258d8736b3002ea601453bf15 [file] [log] [blame]
Sebastian Redl904c9c82010-08-18 23:57:11 +00001//===--- ASTReaderStmt.cpp - Stmt/Expr Deserialization ----------*- C++ -*-===//
Chris Lattner4c6f9522009-04-27 05:14:47 +00002//
3// The LLVM Compiler Infrastructure
4//
5// This file is distributed under the University of Illinois Open Source
6// License. See LICENSE.TXT for details.
7//
8//===----------------------------------------------------------------------===//
9//
10// Statement/expression deserialization. This implements the
Sebastian Redlc43b54c2010-08-18 23:56:43 +000011// ASTReader::ReadStmt method.
Chris Lattner4c6f9522009-04-27 05:14:47 +000012//
13//===----------------------------------------------------------------------===//
14
Sebastian Redl6ab7cd82010-08-18 23:57:17 +000015#include "clang/Serialization/ASTReader.h"
Douglas Gregor39da0b82009-09-09 23:08:42 +000016#include "clang/AST/DeclCXX.h"
Chris Lattner4c6f9522009-04-27 05:14:47 +000017#include "clang/AST/StmtVisitor.h"
18using namespace clang;
Sebastian Redl8538e8d2010-08-18 23:57:32 +000019using namespace clang::serialization;
Chris Lattner4c6f9522009-04-27 05:14:47 +000020
Argyrios Kyrtzidis37bdfe22010-06-30 08:49:18 +000021namespace clang {
Argyrios Kyrtzidis17cfded2010-06-28 09:31:42 +000022
Sebastian Redl60adf4a2010-08-18 23:56:52 +000023 class ASTStmtReader : public StmtVisitor<ASTStmtReader> {
Sebastian Redlc43b54c2010-08-18 23:56:43 +000024 ASTReader &Reader;
Sebastian Redlc3632732010-10-05 15:59:54 +000025 ASTReader::PerFileData &F;
Sebastian Redl577d4792010-07-22 22:43:28 +000026 llvm::BitstreamCursor &DeclsCursor;
Sebastian Redlc43b54c2010-08-18 23:56:43 +000027 const ASTReader::RecordData &Record;
Chris Lattner4c6f9522009-04-27 05:14:47 +000028 unsigned &Idx;
Chris Lattner4c6f9522009-04-27 05:14:47 +000029
Sebastian Redlc3632732010-10-05 15:59:54 +000030 SourceLocation ReadSourceLocation(const ASTReader::RecordData &R,
31 unsigned &I) {
32 return Reader.ReadSourceLocation(F, R, I);
33 }
34 SourceRange ReadSourceRange(const ASTReader::RecordData &R, unsigned &I) {
35 return Reader.ReadSourceRange(F, R, I);
36 }
37 TypeSourceInfo *GetTypeSourceInfo(const ASTReader::RecordData &R,
38 unsigned &I) {
39 return Reader.GetTypeSourceInfo(F, R, I);
40 }
Argyrios Kyrtzidis40451072010-10-15 18:21:24 +000041 void ReadDeclarationNameLoc(DeclarationNameLoc &DNLoc, DeclarationName Name,
42 const ASTReader::RecordData &R, unsigned &I) {
43 Reader.ReadDeclarationNameLoc(F, DNLoc, Name, R, I);
44 }
45 void ReadDeclarationNameInfo(DeclarationNameInfo &NameInfo,
46 const ASTReader::RecordData &R, unsigned &I) {
47 Reader.ReadDeclarationNameInfo(F, NameInfo, R, I);
48 }
Sebastian Redlc3632732010-10-05 15:59:54 +000049
Chris Lattner4c6f9522009-04-27 05:14:47 +000050 public:
Sebastian Redlc3632732010-10-05 15:59:54 +000051 ASTStmtReader(ASTReader &Reader, ASTReader::PerFileData &F,
52 llvm::BitstreamCursor &Cursor,
Sebastian Redlc43b54c2010-08-18 23:56:43 +000053 const ASTReader::RecordData &Record, unsigned &Idx)
Sebastian Redlc3632732010-10-05 15:59:54 +000054 : Reader(Reader), F(F), DeclsCursor(Cursor), Record(Record), Idx(Idx) { }
Chris Lattner4c6f9522009-04-27 05:14:47 +000055
56 /// \brief The number of record fields required for the Stmt class
57 /// itself.
58 static const unsigned NumStmtFields = 0;
59
60 /// \brief The number of record fields required for the Expr class
61 /// itself.
62 static const unsigned NumExprFields = NumStmtFields + 3;
Argyrios Kyrtzidis36c76f02010-06-28 09:31:48 +000063
64 /// \brief Read and initialize a ExplicitTemplateArgumentList structure.
Argyrios Kyrtzidis919e6932010-06-28 22:28:35 +000065 void ReadExplicitTemplateArgumentList(ExplicitTemplateArgumentList &ArgList,
66 unsigned NumTemplateArgs);
Chris Lattner4c6f9522009-04-27 05:14:47 +000067
Argyrios Kyrtzidis919e6932010-06-28 22:28:35 +000068 void VisitStmt(Stmt *S);
69 void VisitNullStmt(NullStmt *S);
70 void VisitCompoundStmt(CompoundStmt *S);
71 void VisitSwitchCase(SwitchCase *S);
72 void VisitCaseStmt(CaseStmt *S);
73 void VisitDefaultStmt(DefaultStmt *S);
74 void VisitLabelStmt(LabelStmt *S);
75 void VisitIfStmt(IfStmt *S);
76 void VisitSwitchStmt(SwitchStmt *S);
77 void VisitWhileStmt(WhileStmt *S);
78 void VisitDoStmt(DoStmt *S);
79 void VisitForStmt(ForStmt *S);
80 void VisitGotoStmt(GotoStmt *S);
81 void VisitIndirectGotoStmt(IndirectGotoStmt *S);
82 void VisitContinueStmt(ContinueStmt *S);
83 void VisitBreakStmt(BreakStmt *S);
84 void VisitReturnStmt(ReturnStmt *S);
85 void VisitDeclStmt(DeclStmt *S);
86 void VisitAsmStmt(AsmStmt *S);
87 void VisitExpr(Expr *E);
88 void VisitPredefinedExpr(PredefinedExpr *E);
89 void VisitDeclRefExpr(DeclRefExpr *E);
90 void VisitIntegerLiteral(IntegerLiteral *E);
91 void VisitFloatingLiteral(FloatingLiteral *E);
92 void VisitImaginaryLiteral(ImaginaryLiteral *E);
93 void VisitStringLiteral(StringLiteral *E);
94 void VisitCharacterLiteral(CharacterLiteral *E);
95 void VisitParenExpr(ParenExpr *E);
Argyrios Kyrtzidis37bdfe22010-06-30 08:49:18 +000096 void VisitParenListExpr(ParenListExpr *E);
Argyrios Kyrtzidis919e6932010-06-28 22:28:35 +000097 void VisitUnaryOperator(UnaryOperator *E);
98 void VisitOffsetOfExpr(OffsetOfExpr *E);
99 void VisitSizeOfAlignOfExpr(SizeOfAlignOfExpr *E);
100 void VisitArraySubscriptExpr(ArraySubscriptExpr *E);
101 void VisitCallExpr(CallExpr *E);
102 void VisitMemberExpr(MemberExpr *E);
103 void VisitCastExpr(CastExpr *E);
104 void VisitBinaryOperator(BinaryOperator *E);
105 void VisitCompoundAssignOperator(CompoundAssignOperator *E);
106 void VisitConditionalOperator(ConditionalOperator *E);
107 void VisitImplicitCastExpr(ImplicitCastExpr *E);
108 void VisitExplicitCastExpr(ExplicitCastExpr *E);
109 void VisitCStyleCastExpr(CStyleCastExpr *E);
110 void VisitCompoundLiteralExpr(CompoundLiteralExpr *E);
111 void VisitExtVectorElementExpr(ExtVectorElementExpr *E);
112 void VisitInitListExpr(InitListExpr *E);
113 void VisitDesignatedInitExpr(DesignatedInitExpr *E);
114 void VisitImplicitValueInitExpr(ImplicitValueInitExpr *E);
115 void VisitVAArgExpr(VAArgExpr *E);
116 void VisitAddrLabelExpr(AddrLabelExpr *E);
117 void VisitStmtExpr(StmtExpr *E);
118 void VisitTypesCompatibleExpr(TypesCompatibleExpr *E);
119 void VisitChooseExpr(ChooseExpr *E);
120 void VisitGNUNullExpr(GNUNullExpr *E);
121 void VisitShuffleVectorExpr(ShuffleVectorExpr *E);
122 void VisitBlockExpr(BlockExpr *E);
123 void VisitBlockDeclRefExpr(BlockDeclRefExpr *E);
124 void VisitObjCStringLiteral(ObjCStringLiteral *E);
125 void VisitObjCEncodeExpr(ObjCEncodeExpr *E);
126 void VisitObjCSelectorExpr(ObjCSelectorExpr *E);
127 void VisitObjCProtocolExpr(ObjCProtocolExpr *E);
128 void VisitObjCIvarRefExpr(ObjCIvarRefExpr *E);
129 void VisitObjCPropertyRefExpr(ObjCPropertyRefExpr *E);
130 void VisitObjCImplicitSetterGetterRefExpr(
Fariborz Jahanian09105f52009-08-20 17:02:02 +0000131 ObjCImplicitSetterGetterRefExpr *E);
Argyrios Kyrtzidis919e6932010-06-28 22:28:35 +0000132 void VisitObjCMessageExpr(ObjCMessageExpr *E);
Argyrios Kyrtzidis919e6932010-06-28 22:28:35 +0000133 void VisitObjCIsaExpr(ObjCIsaExpr *E);
Mike Stump1eb44332009-09-09 15:08:12 +0000134
Argyrios Kyrtzidis919e6932010-06-28 22:28:35 +0000135 void VisitObjCForCollectionStmt(ObjCForCollectionStmt *);
136 void VisitObjCAtCatchStmt(ObjCAtCatchStmt *);
137 void VisitObjCAtFinallyStmt(ObjCAtFinallyStmt *);
138 void VisitObjCAtTryStmt(ObjCAtTryStmt *);
139 void VisitObjCAtSynchronizedStmt(ObjCAtSynchronizedStmt *);
140 void VisitObjCAtThrowStmt(ObjCAtThrowStmt *);
Argyrios Kyrtzidisba0a9002009-07-14 03:19:21 +0000141
Argyrios Kyrtzidis7cb45e32010-07-22 16:03:56 +0000142 // C++ Statements
143 void VisitCXXCatchStmt(CXXCatchStmt *S);
144 void VisitCXXTryStmt(CXXTryStmt *S);
145
Argyrios Kyrtzidis919e6932010-06-28 22:28:35 +0000146 void VisitCXXOperatorCallExpr(CXXOperatorCallExpr *E);
147 void VisitCXXConstructExpr(CXXConstructExpr *E);
Argyrios Kyrtzidis6d00c132010-07-10 11:46:15 +0000148 void VisitCXXTemporaryObjectExpr(CXXTemporaryObjectExpr *E);
Argyrios Kyrtzidis919e6932010-06-28 22:28:35 +0000149 void VisitCXXNamedCastExpr(CXXNamedCastExpr *E);
150 void VisitCXXStaticCastExpr(CXXStaticCastExpr *E);
151 void VisitCXXDynamicCastExpr(CXXDynamicCastExpr *E);
152 void VisitCXXReinterpretCastExpr(CXXReinterpretCastExpr *E);
153 void VisitCXXConstCastExpr(CXXConstCastExpr *E);
154 void VisitCXXFunctionalCastExpr(CXXFunctionalCastExpr *E);
155 void VisitCXXBoolLiteralExpr(CXXBoolLiteralExpr *E);
156 void VisitCXXNullPtrLiteralExpr(CXXNullPtrLiteralExpr *E);
157 void VisitCXXTypeidExpr(CXXTypeidExpr *E);
Francois Pichet01b7c302010-09-08 12:20:18 +0000158 void VisitCXXUuidofExpr(CXXUuidofExpr *E);
Argyrios Kyrtzidis919e6932010-06-28 22:28:35 +0000159 void VisitCXXThisExpr(CXXThisExpr *E);
160 void VisitCXXThrowExpr(CXXThrowExpr *E);
161 void VisitCXXDefaultArgExpr(CXXDefaultArgExpr *E);
162 void VisitCXXBindTemporaryExpr(CXXBindTemporaryExpr *E);
Chris Lattnerd2598362010-05-10 00:25:06 +0000163
Douglas Gregored8abf12010-07-08 06:14:04 +0000164 void VisitCXXScalarValueInitExpr(CXXScalarValueInitExpr *E);
Argyrios Kyrtzidis919e6932010-06-28 22:28:35 +0000165 void VisitCXXNewExpr(CXXNewExpr *E);
166 void VisitCXXDeleteExpr(CXXDeleteExpr *E);
167 void VisitCXXPseudoDestructorExpr(CXXPseudoDestructorExpr *E);
Chris Lattner59218632010-05-10 01:22:27 +0000168
Argyrios Kyrtzidis919e6932010-06-28 22:28:35 +0000169 void VisitCXXExprWithTemporaries(CXXExprWithTemporaries *E);
Argyrios Kyrtzidis8dfbd8b2010-06-24 08:57:31 +0000170
Argyrios Kyrtzidis919e6932010-06-28 22:28:35 +0000171 void VisitCXXDependentScopeMemberExpr(CXXDependentScopeMemberExpr *E);
172 void VisitDependentScopeDeclRefExpr(DependentScopeDeclRefExpr *E);
173 void VisitCXXUnresolvedConstructExpr(CXXUnresolvedConstructExpr *E);
Argyrios Kyrtzidisa77eb082010-06-25 09:03:26 +0000174
Argyrios Kyrtzidis919e6932010-06-28 22:28:35 +0000175 void VisitOverloadExpr(OverloadExpr *E);
176 void VisitUnresolvedMemberExpr(UnresolvedMemberExpr *E);
177 void VisitUnresolvedLookupExpr(UnresolvedLookupExpr *E);
Argyrios Kyrtzidis6d00c132010-07-10 11:46:15 +0000178
179 void VisitUnaryTypeTraitExpr(UnaryTypeTraitExpr *E);
Sebastian Redl6b219d02010-09-10 20:55:54 +0000180 void VisitCXXNoexceptExpr(CXXNoexceptExpr *E);
Chris Lattner4c6f9522009-04-27 05:14:47 +0000181 };
182}
183
Sebastian Redl60adf4a2010-08-18 23:56:52 +0000184void ASTStmtReader::
Argyrios Kyrtzidis36c76f02010-06-28 09:31:48 +0000185ReadExplicitTemplateArgumentList(ExplicitTemplateArgumentList &ArgList,
Argyrios Kyrtzidis919e6932010-06-28 22:28:35 +0000186 unsigned NumTemplateArgs) {
Argyrios Kyrtzidis36c76f02010-06-28 09:31:48 +0000187 TemplateArgumentListInfo ArgInfo;
Sebastian Redlc3632732010-10-05 15:59:54 +0000188 ArgInfo.setLAngleLoc(ReadSourceLocation(Record, Idx));
189 ArgInfo.setRAngleLoc(ReadSourceLocation(Record, Idx));
Argyrios Kyrtzidis36c76f02010-06-28 09:31:48 +0000190 for (unsigned i = 0; i != NumTemplateArgs; ++i)
Sebastian Redl577d4792010-07-22 22:43:28 +0000191 ArgInfo.addArgument(
Sebastian Redlc3632732010-10-05 15:59:54 +0000192 Reader.ReadTemplateArgumentLoc(F, Record, Idx));
Argyrios Kyrtzidis36c76f02010-06-28 09:31:48 +0000193 ArgList.initializeFrom(ArgInfo);
Argyrios Kyrtzidis36c76f02010-06-28 09:31:48 +0000194}
195
Sebastian Redl60adf4a2010-08-18 23:56:52 +0000196void ASTStmtReader::VisitStmt(Stmt *S) {
Chris Lattner4c6f9522009-04-27 05:14:47 +0000197 assert(Idx == NumStmtFields && "Incorrect statement field count");
Chris Lattner4c6f9522009-04-27 05:14:47 +0000198}
199
Sebastian Redl60adf4a2010-08-18 23:56:52 +0000200void ASTStmtReader::VisitNullStmt(NullStmt *S) {
Chris Lattner4c6f9522009-04-27 05:14:47 +0000201 VisitStmt(S);
Sebastian Redlc3632732010-10-05 15:59:54 +0000202 S->setSemiLoc(ReadSourceLocation(Record, Idx));
Chris Lattner4c6f9522009-04-27 05:14:47 +0000203}
204
Sebastian Redl60adf4a2010-08-18 23:56:52 +0000205void ASTStmtReader::VisitCompoundStmt(CompoundStmt *S) {
Chris Lattner4c6f9522009-04-27 05:14:47 +0000206 VisitStmt(S);
Argyrios Kyrtzidis919e6932010-06-28 22:28:35 +0000207 llvm::SmallVector<Stmt *, 16> Stmts;
Chris Lattner4c6f9522009-04-27 05:14:47 +0000208 unsigned NumStmts = Record[Idx++];
Argyrios Kyrtzidis919e6932010-06-28 22:28:35 +0000209 while (NumStmts--)
Argyrios Kyrtzidisd98a2ab2010-06-29 22:46:25 +0000210 Stmts.push_back(Reader.ReadSubStmt());
Argyrios Kyrtzidis919e6932010-06-28 22:28:35 +0000211 S->setStmts(*Reader.getContext(), Stmts.data(), Stmts.size());
Sebastian Redlc3632732010-10-05 15:59:54 +0000212 S->setLBracLoc(ReadSourceLocation(Record, Idx));
213 S->setRBracLoc(ReadSourceLocation(Record, Idx));
Chris Lattner4c6f9522009-04-27 05:14:47 +0000214}
215
Sebastian Redl60adf4a2010-08-18 23:56:52 +0000216void ASTStmtReader::VisitSwitchCase(SwitchCase *S) {
Chris Lattner4c6f9522009-04-27 05:14:47 +0000217 VisitStmt(S);
218 Reader.RecordSwitchCaseID(S, Record[Idx++]);
Chris Lattner4c6f9522009-04-27 05:14:47 +0000219}
220
Sebastian Redl60adf4a2010-08-18 23:56:52 +0000221void ASTStmtReader::VisitCaseStmt(CaseStmt *S) {
Chris Lattner4c6f9522009-04-27 05:14:47 +0000222 VisitSwitchCase(S);
Argyrios Kyrtzidisd98a2ab2010-06-29 22:46:25 +0000223 S->setLHS(Reader.ReadSubExpr());
224 S->setRHS(Reader.ReadSubExpr());
225 S->setSubStmt(Reader.ReadSubStmt());
Sebastian Redlc3632732010-10-05 15:59:54 +0000226 S->setCaseLoc(ReadSourceLocation(Record, Idx));
227 S->setEllipsisLoc(ReadSourceLocation(Record, Idx));
228 S->setColonLoc(ReadSourceLocation(Record, Idx));
Chris Lattner4c6f9522009-04-27 05:14:47 +0000229}
230
Sebastian Redl60adf4a2010-08-18 23:56:52 +0000231void ASTStmtReader::VisitDefaultStmt(DefaultStmt *S) {
Chris Lattner4c6f9522009-04-27 05:14:47 +0000232 VisitSwitchCase(S);
Argyrios Kyrtzidisd98a2ab2010-06-29 22:46:25 +0000233 S->setSubStmt(Reader.ReadSubStmt());
Sebastian Redlc3632732010-10-05 15:59:54 +0000234 S->setDefaultLoc(ReadSourceLocation(Record, Idx));
235 S->setColonLoc(ReadSourceLocation(Record, Idx));
Chris Lattner4c6f9522009-04-27 05:14:47 +0000236}
237
Sebastian Redl60adf4a2010-08-18 23:56:52 +0000238void ASTStmtReader::VisitLabelStmt(LabelStmt *S) {
Chris Lattner4c6f9522009-04-27 05:14:47 +0000239 VisitStmt(S);
240 S->setID(Reader.GetIdentifierInfo(Record, Idx));
Argyrios Kyrtzidisd98a2ab2010-06-29 22:46:25 +0000241 S->setSubStmt(Reader.ReadSubStmt());
Sebastian Redlc3632732010-10-05 15:59:54 +0000242 S->setIdentLoc(ReadSourceLocation(Record, Idx));
Argyrios Kyrtzidis355a9fe2010-09-19 21:21:25 +0000243 S->setUsed(Record[Idx++]);
Argyrios Kyrtzidis1a186002010-09-28 14:54:07 +0000244 S->setUnusedAttribute(Record[Idx++]);
Chris Lattner4c6f9522009-04-27 05:14:47 +0000245 Reader.RecordLabelStmt(S, Record[Idx++]);
Chris Lattner4c6f9522009-04-27 05:14:47 +0000246}
247
Sebastian Redl60adf4a2010-08-18 23:56:52 +0000248void ASTStmtReader::VisitIfStmt(IfStmt *S) {
Chris Lattner4c6f9522009-04-27 05:14:47 +0000249 VisitStmt(S);
Douglas Gregor43dec6b2010-06-21 23:44:13 +0000250 S->setConditionVariable(*Reader.getContext(),
251 cast_or_null<VarDecl>(Reader.GetDecl(Record[Idx++])));
Argyrios Kyrtzidisd98a2ab2010-06-29 22:46:25 +0000252 S->setCond(Reader.ReadSubExpr());
253 S->setThen(Reader.ReadSubStmt());
254 S->setElse(Reader.ReadSubStmt());
Sebastian Redlc3632732010-10-05 15:59:54 +0000255 S->setIfLoc(ReadSourceLocation(Record, Idx));
256 S->setElseLoc(ReadSourceLocation(Record, Idx));
Chris Lattner4c6f9522009-04-27 05:14:47 +0000257}
258
Sebastian Redl60adf4a2010-08-18 23:56:52 +0000259void ASTStmtReader::VisitSwitchStmt(SwitchStmt *S) {
Chris Lattner4c6f9522009-04-27 05:14:47 +0000260 VisitStmt(S);
Douglas Gregor43dec6b2010-06-21 23:44:13 +0000261 S->setConditionVariable(*Reader.getContext(),
262 cast_or_null<VarDecl>(Reader.GetDecl(Record[Idx++])));
Argyrios Kyrtzidisd98a2ab2010-06-29 22:46:25 +0000263 S->setCond(Reader.ReadSubExpr());
264 S->setBody(Reader.ReadSubStmt());
Sebastian Redlc3632732010-10-05 15:59:54 +0000265 S->setSwitchLoc(ReadSourceLocation(Record, Idx));
Ted Kremenek559fb552010-09-09 00:05:53 +0000266 if (Record[Idx++])
267 S->setAllEnumCasesCovered();
268
Chris Lattner4c6f9522009-04-27 05:14:47 +0000269 SwitchCase *PrevSC = 0;
270 for (unsigned N = Record.size(); Idx != N; ++Idx) {
271 SwitchCase *SC = Reader.getSwitchCaseWithID(Record[Idx]);
272 if (PrevSC)
273 PrevSC->setNextSwitchCase(SC);
274 else
275 S->setSwitchCaseList(SC);
Mike Stump1eb44332009-09-09 15:08:12 +0000276
Douglas Gregor43d9d922009-08-08 01:41:12 +0000277 // Retain this SwitchCase, since SwitchStmt::addSwitchCase() would
278 // normally retain it (but we aren't calling addSwitchCase).
279 SC->Retain();
Chris Lattner4c6f9522009-04-27 05:14:47 +0000280 PrevSC = SC;
281 }
Chris Lattner4c6f9522009-04-27 05:14:47 +0000282}
283
Sebastian Redl60adf4a2010-08-18 23:56:52 +0000284void ASTStmtReader::VisitWhileStmt(WhileStmt *S) {
Chris Lattner4c6f9522009-04-27 05:14:47 +0000285 VisitStmt(S);
Douglas Gregor43dec6b2010-06-21 23:44:13 +0000286 S->setConditionVariable(*Reader.getContext(),
287 cast_or_null<VarDecl>(Reader.GetDecl(Record[Idx++])));
Argyrios Kyrtzidisd98a2ab2010-06-29 22:46:25 +0000288 S->setCond(Reader.ReadSubExpr());
289 S->setBody(Reader.ReadSubStmt());
Sebastian Redlc3632732010-10-05 15:59:54 +0000290 S->setWhileLoc(ReadSourceLocation(Record, Idx));
Chris Lattner4c6f9522009-04-27 05:14:47 +0000291}
292
Sebastian Redl60adf4a2010-08-18 23:56:52 +0000293void ASTStmtReader::VisitDoStmt(DoStmt *S) {
Chris Lattner4c6f9522009-04-27 05:14:47 +0000294 VisitStmt(S);
Argyrios Kyrtzidisd98a2ab2010-06-29 22:46:25 +0000295 S->setCond(Reader.ReadSubExpr());
296 S->setBody(Reader.ReadSubStmt());
Sebastian Redlc3632732010-10-05 15:59:54 +0000297 S->setDoLoc(ReadSourceLocation(Record, Idx));
298 S->setWhileLoc(ReadSourceLocation(Record, Idx));
299 S->setRParenLoc(ReadSourceLocation(Record, Idx));
Chris Lattner4c6f9522009-04-27 05:14:47 +0000300}
301
Sebastian Redl60adf4a2010-08-18 23:56:52 +0000302void ASTStmtReader::VisitForStmt(ForStmt *S) {
Chris Lattner4c6f9522009-04-27 05:14:47 +0000303 VisitStmt(S);
Argyrios Kyrtzidisd98a2ab2010-06-29 22:46:25 +0000304 S->setInit(Reader.ReadSubStmt());
305 S->setCond(Reader.ReadSubExpr());
Douglas Gregor43dec6b2010-06-21 23:44:13 +0000306 S->setConditionVariable(*Reader.getContext(),
307 cast_or_null<VarDecl>(Reader.GetDecl(Record[Idx++])));
Argyrios Kyrtzidisd98a2ab2010-06-29 22:46:25 +0000308 S->setInc(Reader.ReadSubExpr());
309 S->setBody(Reader.ReadSubStmt());
Sebastian Redlc3632732010-10-05 15:59:54 +0000310 S->setForLoc(ReadSourceLocation(Record, Idx));
311 S->setLParenLoc(ReadSourceLocation(Record, Idx));
312 S->setRParenLoc(ReadSourceLocation(Record, Idx));
Chris Lattner4c6f9522009-04-27 05:14:47 +0000313}
314
Sebastian Redl60adf4a2010-08-18 23:56:52 +0000315void ASTStmtReader::VisitGotoStmt(GotoStmt *S) {
Chris Lattner4c6f9522009-04-27 05:14:47 +0000316 VisitStmt(S);
317 Reader.SetLabelOf(S, Record[Idx++]);
Sebastian Redlc3632732010-10-05 15:59:54 +0000318 S->setGotoLoc(ReadSourceLocation(Record, Idx));
319 S->setLabelLoc(ReadSourceLocation(Record, Idx));
Chris Lattner4c6f9522009-04-27 05:14:47 +0000320}
321
Sebastian Redl60adf4a2010-08-18 23:56:52 +0000322void ASTStmtReader::VisitIndirectGotoStmt(IndirectGotoStmt *S) {
Chris Lattner4c6f9522009-04-27 05:14:47 +0000323 VisitStmt(S);
Sebastian Redlc3632732010-10-05 15:59:54 +0000324 S->setGotoLoc(ReadSourceLocation(Record, Idx));
325 S->setStarLoc(ReadSourceLocation(Record, Idx));
Argyrios Kyrtzidisd98a2ab2010-06-29 22:46:25 +0000326 S->setTarget(Reader.ReadSubExpr());
Chris Lattner4c6f9522009-04-27 05:14:47 +0000327}
328
Sebastian Redl60adf4a2010-08-18 23:56:52 +0000329void ASTStmtReader::VisitContinueStmt(ContinueStmt *S) {
Chris Lattner4c6f9522009-04-27 05:14:47 +0000330 VisitStmt(S);
Sebastian Redlc3632732010-10-05 15:59:54 +0000331 S->setContinueLoc(ReadSourceLocation(Record, Idx));
Chris Lattner4c6f9522009-04-27 05:14:47 +0000332}
333
Sebastian Redl60adf4a2010-08-18 23:56:52 +0000334void ASTStmtReader::VisitBreakStmt(BreakStmt *S) {
Chris Lattner4c6f9522009-04-27 05:14:47 +0000335 VisitStmt(S);
Sebastian Redlc3632732010-10-05 15:59:54 +0000336 S->setBreakLoc(ReadSourceLocation(Record, Idx));
Chris Lattner4c6f9522009-04-27 05:14:47 +0000337}
338
Sebastian Redl60adf4a2010-08-18 23:56:52 +0000339void ASTStmtReader::VisitReturnStmt(ReturnStmt *S) {
Chris Lattner4c6f9522009-04-27 05:14:47 +0000340 VisitStmt(S);
Argyrios Kyrtzidisd98a2ab2010-06-29 22:46:25 +0000341 S->setRetValue(Reader.ReadSubExpr());
Sebastian Redlc3632732010-10-05 15:59:54 +0000342 S->setReturnLoc(ReadSourceLocation(Record, Idx));
Douglas Gregor5077c382010-05-15 06:01:05 +0000343 S->setNRVOCandidate(cast_or_null<VarDecl>(Reader.GetDecl(Record[Idx++])));
Chris Lattner4c6f9522009-04-27 05:14:47 +0000344}
345
Sebastian Redl60adf4a2010-08-18 23:56:52 +0000346void ASTStmtReader::VisitDeclStmt(DeclStmt *S) {
Chris Lattner4c6f9522009-04-27 05:14:47 +0000347 VisitStmt(S);
Sebastian Redlc3632732010-10-05 15:59:54 +0000348 S->setStartLoc(ReadSourceLocation(Record, Idx));
349 S->setEndLoc(ReadSourceLocation(Record, Idx));
Chris Lattner4c6f9522009-04-27 05:14:47 +0000350
351 if (Idx + 1 == Record.size()) {
352 // Single declaration
353 S->setDeclGroup(DeclGroupRef(Reader.GetDecl(Record[Idx++])));
354 } else {
355 llvm::SmallVector<Decl *, 16> Decls;
356 Decls.reserve(Record.size() - Idx);
357 for (unsigned N = Record.size(); Idx != N; ++Idx)
358 Decls.push_back(Reader.GetDecl(Record[Idx]));
Chris Lattnerd1d64a02009-04-27 21:45:14 +0000359 S->setDeclGroup(DeclGroupRef(DeclGroup::Create(*Reader.getContext(),
Douglas Gregor75fdb232009-05-22 22:45:36 +0000360 Decls.data(),
361 Decls.size())));
Chris Lattner4c6f9522009-04-27 05:14:47 +0000362 }
Chris Lattner4c6f9522009-04-27 05:14:47 +0000363}
364
Sebastian Redl60adf4a2010-08-18 23:56:52 +0000365void ASTStmtReader::VisitAsmStmt(AsmStmt *S) {
Chris Lattner4c6f9522009-04-27 05:14:47 +0000366 VisitStmt(S);
367 unsigned NumOutputs = Record[Idx++];
368 unsigned NumInputs = Record[Idx++];
369 unsigned NumClobbers = Record[Idx++];
Sebastian Redlc3632732010-10-05 15:59:54 +0000370 S->setAsmLoc(ReadSourceLocation(Record, Idx));
371 S->setRParenLoc(ReadSourceLocation(Record, Idx));
Chris Lattner4c6f9522009-04-27 05:14:47 +0000372 S->setVolatile(Record[Idx++]);
373 S->setSimple(Record[Idx++]);
Mike Stump3b11fd32010-01-04 22:37:17 +0000374 S->setMSAsm(Record[Idx++]);
Mike Stump1eb44332009-09-09 15:08:12 +0000375
Argyrios Kyrtzidisd98a2ab2010-06-29 22:46:25 +0000376 S->setAsmString(cast_or_null<StringLiteral>(Reader.ReadSubStmt()));
Chris Lattner4c6f9522009-04-27 05:14:47 +0000377
378 // Outputs and inputs
Anders Carlssonff93dbd2010-01-30 22:25:16 +0000379 llvm::SmallVector<IdentifierInfo *, 16> Names;
Chris Lattner4c6f9522009-04-27 05:14:47 +0000380 llvm::SmallVector<StringLiteral*, 16> Constraints;
381 llvm::SmallVector<Stmt*, 16> Exprs;
382 for (unsigned I = 0, N = NumOutputs + NumInputs; I != N; ++I) {
Anders Carlssonff93dbd2010-01-30 22:25:16 +0000383 Names.push_back(Reader.GetIdentifierInfo(Record, Idx));
Argyrios Kyrtzidisd98a2ab2010-06-29 22:46:25 +0000384 Constraints.push_back(cast_or_null<StringLiteral>(Reader.ReadSubStmt()));
385 Exprs.push_back(Reader.ReadSubStmt());
Chris Lattner4c6f9522009-04-27 05:14:47 +0000386 }
Chris Lattner4c6f9522009-04-27 05:14:47 +0000387
388 // Constraints
389 llvm::SmallVector<StringLiteral*, 16> Clobbers;
390 for (unsigned I = 0; I != NumClobbers; ++I)
Argyrios Kyrtzidisd98a2ab2010-06-29 22:46:25 +0000391 Clobbers.push_back(cast_or_null<StringLiteral>(Reader.ReadSubStmt()));
Anders Carlssonfdba9c02010-01-30 19:34:25 +0000392
Anders Carlssonacb6bcb2010-01-30 20:38:10 +0000393 S->setOutputsAndInputsAndClobbers(*Reader.getContext(),
394 Names.data(), Constraints.data(),
Anders Carlssonfdba9c02010-01-30 19:34:25 +0000395 Exprs.data(), NumOutputs, NumInputs,
396 Clobbers.data(), NumClobbers);
Chris Lattner4c6f9522009-04-27 05:14:47 +0000397}
398
Sebastian Redl60adf4a2010-08-18 23:56:52 +0000399void ASTStmtReader::VisitExpr(Expr *E) {
Chris Lattner4c6f9522009-04-27 05:14:47 +0000400 VisitStmt(E);
401 E->setType(Reader.GetType(Record[Idx++]));
402 E->setTypeDependent(Record[Idx++]);
403 E->setValueDependent(Record[Idx++]);
404 assert(Idx == NumExprFields && "Incorrect expression field count");
Chris Lattner4c6f9522009-04-27 05:14:47 +0000405}
406
Sebastian Redl60adf4a2010-08-18 23:56:52 +0000407void ASTStmtReader::VisitPredefinedExpr(PredefinedExpr *E) {
Chris Lattner4c6f9522009-04-27 05:14:47 +0000408 VisitExpr(E);
Sebastian Redlc3632732010-10-05 15:59:54 +0000409 E->setLocation(ReadSourceLocation(Record, Idx));
Chris Lattner4c6f9522009-04-27 05:14:47 +0000410 E->setIdentType((PredefinedExpr::IdentType)Record[Idx++]);
Chris Lattner4c6f9522009-04-27 05:14:47 +0000411}
412
Sebastian Redl60adf4a2010-08-18 23:56:52 +0000413void ASTStmtReader::VisitDeclRefExpr(DeclRefExpr *E) {
Chris Lattner4c6f9522009-04-27 05:14:47 +0000414 VisitExpr(E);
Argyrios Kyrtzidis663e3802010-07-08 13:09:47 +0000415
416 bool HasQualifier = Record[Idx++];
417 unsigned NumTemplateArgs = Record[Idx++];
418
419 E->DecoratedD.setInt((HasQualifier? DeclRefExpr::HasQualifierFlag : 0) |
420 (NumTemplateArgs ? DeclRefExpr::HasExplicitTemplateArgumentListFlag : 0));
421
422 if (HasQualifier) {
423 E->getNameQualifier()->NNS = Reader.ReadNestedNameSpecifier(Record, Idx);
Sebastian Redlc3632732010-10-05 15:59:54 +0000424 E->getNameQualifier()->Range = ReadSourceRange(Record, Idx);
Argyrios Kyrtzidis663e3802010-07-08 13:09:47 +0000425 }
426
427 if (NumTemplateArgs)
John McCall096832c2010-08-19 23:49:38 +0000428 ReadExplicitTemplateArgumentList(E->getExplicitTemplateArgs(),
Argyrios Kyrtzidis663e3802010-07-08 13:09:47 +0000429 NumTemplateArgs);
430
John McCalldbd872f2009-12-08 09:08:17 +0000431 E->setDecl(cast<ValueDecl>(Reader.GetDecl(Record[Idx++])));
Sebastian Redlc3632732010-10-05 15:59:54 +0000432 E->setLocation(ReadSourceLocation(Record, Idx));
Argyrios Kyrtzidis40451072010-10-15 18:21:24 +0000433 ReadDeclarationNameLoc(E->DNLoc, E->getDecl()->getDeclName(), Record, Idx);
Chris Lattner4c6f9522009-04-27 05:14:47 +0000434}
435
Sebastian Redl60adf4a2010-08-18 23:56:52 +0000436void ASTStmtReader::VisitIntegerLiteral(IntegerLiteral *E) {
Chris Lattner4c6f9522009-04-27 05:14:47 +0000437 VisitExpr(E);
Sebastian Redlc3632732010-10-05 15:59:54 +0000438 E->setLocation(ReadSourceLocation(Record, Idx));
Argyrios Kyrtzidis9996a7f2010-08-28 09:06:06 +0000439 E->setValue(*Reader.getContext(), Reader.ReadAPInt(Record, Idx));
Chris Lattner4c6f9522009-04-27 05:14:47 +0000440}
441
Sebastian Redl60adf4a2010-08-18 23:56:52 +0000442void ASTStmtReader::VisitFloatingLiteral(FloatingLiteral *E) {
Chris Lattner4c6f9522009-04-27 05:14:47 +0000443 VisitExpr(E);
Argyrios Kyrtzidis9996a7f2010-08-28 09:06:06 +0000444 E->setValue(*Reader.getContext(), Reader.ReadAPFloat(Record, Idx));
Chris Lattner4c6f9522009-04-27 05:14:47 +0000445 E->setExact(Record[Idx++]);
Sebastian Redlc3632732010-10-05 15:59:54 +0000446 E->setLocation(ReadSourceLocation(Record, Idx));
Chris Lattner4c6f9522009-04-27 05:14:47 +0000447}
448
Sebastian Redl60adf4a2010-08-18 23:56:52 +0000449void ASTStmtReader::VisitImaginaryLiteral(ImaginaryLiteral *E) {
Chris Lattner4c6f9522009-04-27 05:14:47 +0000450 VisitExpr(E);
Argyrios Kyrtzidisd98a2ab2010-06-29 22:46:25 +0000451 E->setSubExpr(Reader.ReadSubExpr());
Chris Lattner4c6f9522009-04-27 05:14:47 +0000452}
453
Sebastian Redl60adf4a2010-08-18 23:56:52 +0000454void ASTStmtReader::VisitStringLiteral(StringLiteral *E) {
Chris Lattner4c6f9522009-04-27 05:14:47 +0000455 VisitExpr(E);
456 unsigned Len = Record[Idx++];
Mike Stump1eb44332009-09-09 15:08:12 +0000457 assert(Record[Idx] == E->getNumConcatenated() &&
Chris Lattner4c6f9522009-04-27 05:14:47 +0000458 "Wrong number of concatenated tokens!");
459 ++Idx;
460 E->setWide(Record[Idx++]);
461
Mike Stump1eb44332009-09-09 15:08:12 +0000462 // Read string data
Daniel Dunbarb6480232009-09-22 03:27:33 +0000463 llvm::SmallString<16> Str(&Record[Idx], &Record[Idx] + Len);
464 E->setString(*Reader.getContext(), Str.str());
Chris Lattner4c6f9522009-04-27 05:14:47 +0000465 Idx += Len;
466
467 // Read source locations
468 for (unsigned I = 0, N = E->getNumConcatenated(); I != N; ++I)
Sebastian Redlc3632732010-10-05 15:59:54 +0000469 E->setStrTokenLoc(I, ReadSourceLocation(Record, Idx));
Chris Lattner4c6f9522009-04-27 05:14:47 +0000470}
471
Sebastian Redl60adf4a2010-08-18 23:56:52 +0000472void ASTStmtReader::VisitCharacterLiteral(CharacterLiteral *E) {
Chris Lattner4c6f9522009-04-27 05:14:47 +0000473 VisitExpr(E);
474 E->setValue(Record[Idx++]);
Sebastian Redlc3632732010-10-05 15:59:54 +0000475 E->setLocation(ReadSourceLocation(Record, Idx));
Chris Lattner4c6f9522009-04-27 05:14:47 +0000476 E->setWide(Record[Idx++]);
Chris Lattner4c6f9522009-04-27 05:14:47 +0000477}
478
Sebastian Redl60adf4a2010-08-18 23:56:52 +0000479void ASTStmtReader::VisitParenExpr(ParenExpr *E) {
Chris Lattner4c6f9522009-04-27 05:14:47 +0000480 VisitExpr(E);
Sebastian Redlc3632732010-10-05 15:59:54 +0000481 E->setLParen(ReadSourceLocation(Record, Idx));
482 E->setRParen(ReadSourceLocation(Record, Idx));
Argyrios Kyrtzidisd98a2ab2010-06-29 22:46:25 +0000483 E->setSubExpr(Reader.ReadSubExpr());
Chris Lattner4c6f9522009-04-27 05:14:47 +0000484}
485
Sebastian Redl60adf4a2010-08-18 23:56:52 +0000486void ASTStmtReader::VisitParenListExpr(ParenListExpr *E) {
Argyrios Kyrtzidis37bdfe22010-06-30 08:49:18 +0000487 VisitExpr(E);
488 unsigned NumExprs = Record[Idx++];
489 E->Exprs = new (*Reader.getContext()) Stmt*[NumExprs];
490 for (unsigned i = 0; i != NumExprs; ++i)
491 E->Exprs[i] = Reader.ReadSubStmt();
492 E->NumExprs = NumExprs;
Sebastian Redlc3632732010-10-05 15:59:54 +0000493 E->LParenLoc = ReadSourceLocation(Record, Idx);
494 E->RParenLoc = ReadSourceLocation(Record, Idx);
Argyrios Kyrtzidis37bdfe22010-06-30 08:49:18 +0000495}
496
Sebastian Redl60adf4a2010-08-18 23:56:52 +0000497void ASTStmtReader::VisitUnaryOperator(UnaryOperator *E) {
Chris Lattner4c6f9522009-04-27 05:14:47 +0000498 VisitExpr(E);
Argyrios Kyrtzidisd98a2ab2010-06-29 22:46:25 +0000499 E->setSubExpr(Reader.ReadSubExpr());
Chris Lattner4c6f9522009-04-27 05:14:47 +0000500 E->setOpcode((UnaryOperator::Opcode)Record[Idx++]);
Sebastian Redlc3632732010-10-05 15:59:54 +0000501 E->setOperatorLoc(ReadSourceLocation(Record, Idx));
Chris Lattner4c6f9522009-04-27 05:14:47 +0000502}
503
Sebastian Redl60adf4a2010-08-18 23:56:52 +0000504void ASTStmtReader::VisitOffsetOfExpr(OffsetOfExpr *E) {
Douglas Gregor8ecdb652010-04-28 22:16:22 +0000505 typedef OffsetOfExpr::OffsetOfNode Node;
506 VisitExpr(E);
507 assert(E->getNumComponents() == Record[Idx]);
508 ++Idx;
509 assert(E->getNumExpressions() == Record[Idx]);
510 ++Idx;
Sebastian Redlc3632732010-10-05 15:59:54 +0000511 E->setOperatorLoc(ReadSourceLocation(Record, Idx));
512 E->setRParenLoc(ReadSourceLocation(Record, Idx));
513 E->setTypeSourceInfo(GetTypeSourceInfo(Record, Idx));
Douglas Gregor8ecdb652010-04-28 22:16:22 +0000514 for (unsigned I = 0, N = E->getNumComponents(); I != N; ++I) {
515 Node::Kind Kind = static_cast<Node::Kind>(Record[Idx++]);
Sebastian Redlc3632732010-10-05 15:59:54 +0000516 SourceLocation Start = ReadSourceLocation(Record, Idx);
517 SourceLocation End = ReadSourceLocation(Record, Idx);
Douglas Gregor8ecdb652010-04-28 22:16:22 +0000518 switch (Kind) {
519 case Node::Array:
520 E->setComponent(I, Node(Start, Record[Idx++], End));
521 break;
522
523 case Node::Field:
524 E->setComponent(I,
525 Node(Start,
526 dyn_cast_or_null<FieldDecl>(Reader.GetDecl(Record[Idx++])),
527 End));
528 break;
529
530 case Node::Identifier:
531 E->setComponent(I, Node(Start, Reader.GetIdentifier(Record[Idx++]), End));
532 break;
Douglas Gregorcc8a5d52010-04-29 00:18:15 +0000533
Argyrios Kyrtzidisafbf3122010-07-29 18:16:10 +0000534 case Node::Base: {
535 CXXBaseSpecifier *Base = new (*Reader.getContext()) CXXBaseSpecifier();
Sebastian Redlc3632732010-10-05 15:59:54 +0000536 *Base = Reader.ReadCXXBaseSpecifier(F, Record, Idx);
Argyrios Kyrtzidisafbf3122010-07-29 18:16:10 +0000537 E->setComponent(I, Node(Base));
Douglas Gregorcc8a5d52010-04-29 00:18:15 +0000538 break;
Douglas Gregor8ecdb652010-04-28 22:16:22 +0000539 }
Argyrios Kyrtzidisafbf3122010-07-29 18:16:10 +0000540 }
Douglas Gregor8ecdb652010-04-28 22:16:22 +0000541 }
542
543 for (unsigned I = 0, N = E->getNumExpressions(); I != N; ++I)
Argyrios Kyrtzidisd98a2ab2010-06-29 22:46:25 +0000544 E->setIndexExpr(I, Reader.ReadSubExpr());
Douglas Gregor8ecdb652010-04-28 22:16:22 +0000545}
546
Sebastian Redl60adf4a2010-08-18 23:56:52 +0000547void ASTStmtReader::VisitSizeOfAlignOfExpr(SizeOfAlignOfExpr *E) {
Chris Lattner4c6f9522009-04-27 05:14:47 +0000548 VisitExpr(E);
549 E->setSizeof(Record[Idx++]);
550 if (Record[Idx] == 0) {
Argyrios Kyrtzidisd98a2ab2010-06-29 22:46:25 +0000551 E->setArgument(Reader.ReadSubExpr());
Chris Lattner4c6f9522009-04-27 05:14:47 +0000552 ++Idx;
553 } else {
Sebastian Redlc3632732010-10-05 15:59:54 +0000554 E->setArgument(GetTypeSourceInfo(Record, Idx));
Chris Lattner4c6f9522009-04-27 05:14:47 +0000555 }
Sebastian Redlc3632732010-10-05 15:59:54 +0000556 E->setOperatorLoc(ReadSourceLocation(Record, Idx));
557 E->setRParenLoc(ReadSourceLocation(Record, Idx));
Chris Lattner4c6f9522009-04-27 05:14:47 +0000558}
559
Sebastian Redl60adf4a2010-08-18 23:56:52 +0000560void ASTStmtReader::VisitArraySubscriptExpr(ArraySubscriptExpr *E) {
Chris Lattner4c6f9522009-04-27 05:14:47 +0000561 VisitExpr(E);
Argyrios Kyrtzidisd98a2ab2010-06-29 22:46:25 +0000562 E->setLHS(Reader.ReadSubExpr());
563 E->setRHS(Reader.ReadSubExpr());
Sebastian Redlc3632732010-10-05 15:59:54 +0000564 E->setRBracketLoc(ReadSourceLocation(Record, Idx));
Chris Lattner4c6f9522009-04-27 05:14:47 +0000565}
566
Sebastian Redl60adf4a2010-08-18 23:56:52 +0000567void ASTStmtReader::VisitCallExpr(CallExpr *E) {
Chris Lattner4c6f9522009-04-27 05:14:47 +0000568 VisitExpr(E);
Chris Lattnerd1d64a02009-04-27 21:45:14 +0000569 E->setNumArgs(*Reader.getContext(), Record[Idx++]);
Sebastian Redlc3632732010-10-05 15:59:54 +0000570 E->setRParenLoc(ReadSourceLocation(Record, Idx));
Argyrios Kyrtzidisd98a2ab2010-06-29 22:46:25 +0000571 E->setCallee(Reader.ReadSubExpr());
Chris Lattner4c6f9522009-04-27 05:14:47 +0000572 for (unsigned I = 0, N = E->getNumArgs(); I != N; ++I)
Argyrios Kyrtzidisd98a2ab2010-06-29 22:46:25 +0000573 E->setArg(I, Reader.ReadSubExpr());
Chris Lattner4c6f9522009-04-27 05:14:47 +0000574}
575
Sebastian Redl60adf4a2010-08-18 23:56:52 +0000576void ASTStmtReader::VisitMemberExpr(MemberExpr *E) {
Argyrios Kyrtzidis663e3802010-07-08 13:09:47 +0000577 // Don't call VisitExpr, this is fully initialized at creation.
578 assert(E->getStmtClass() == Stmt::MemberExprClass &&
579 "It's a subclass, we must advance Idx!");
Chris Lattner4c6f9522009-04-27 05:14:47 +0000580}
581
Sebastian Redl60adf4a2010-08-18 23:56:52 +0000582void ASTStmtReader::VisitObjCIsaExpr(ObjCIsaExpr *E) {
Steve Narofff242b1b2009-07-24 17:54:45 +0000583 VisitExpr(E);
Argyrios Kyrtzidisd98a2ab2010-06-29 22:46:25 +0000584 E->setBase(Reader.ReadSubExpr());
Sebastian Redlc3632732010-10-05 15:59:54 +0000585 E->setIsaMemberLoc(ReadSourceLocation(Record, Idx));
Steve Narofff242b1b2009-07-24 17:54:45 +0000586 E->setArrow(Record[Idx++]);
Steve Narofff242b1b2009-07-24 17:54:45 +0000587}
588
Sebastian Redl60adf4a2010-08-18 23:56:52 +0000589void ASTStmtReader::VisitCastExpr(CastExpr *E) {
Chris Lattner4c6f9522009-04-27 05:14:47 +0000590 VisitExpr(E);
John McCallf871d0c2010-08-07 06:22:56 +0000591 unsigned NumBaseSpecs = Record[Idx++];
592 assert(NumBaseSpecs == E->path_size());
Argyrios Kyrtzidisd98a2ab2010-06-29 22:46:25 +0000593 E->setSubExpr(Reader.ReadSubExpr());
Anders Carlssoncdef2b72009-07-31 00:48:10 +0000594 E->setCastKind((CastExpr::CastKind)Record[Idx++]);
John McCallf871d0c2010-08-07 06:22:56 +0000595 CastExpr::path_iterator BaseI = E->path_begin();
Argyrios Kyrtzidis0745d0a2010-07-02 23:30:27 +0000596 while (NumBaseSpecs--) {
Argyrios Kyrtzidis0745d0a2010-07-02 23:30:27 +0000597 CXXBaseSpecifier *BaseSpec = new (*Reader.getContext()) CXXBaseSpecifier;
Sebastian Redlc3632732010-10-05 15:59:54 +0000598 *BaseSpec = Reader.ReadCXXBaseSpecifier(F, Record, Idx);
John McCallf871d0c2010-08-07 06:22:56 +0000599 *BaseI++ = BaseSpec;
Argyrios Kyrtzidis0745d0a2010-07-02 23:30:27 +0000600 }
Chris Lattner4c6f9522009-04-27 05:14:47 +0000601}
602
Sebastian Redl60adf4a2010-08-18 23:56:52 +0000603void ASTStmtReader::VisitBinaryOperator(BinaryOperator *E) {
Chris Lattner4c6f9522009-04-27 05:14:47 +0000604 VisitExpr(E);
Argyrios Kyrtzidisd98a2ab2010-06-29 22:46:25 +0000605 E->setLHS(Reader.ReadSubExpr());
606 E->setRHS(Reader.ReadSubExpr());
Chris Lattner4c6f9522009-04-27 05:14:47 +0000607 E->setOpcode((BinaryOperator::Opcode)Record[Idx++]);
Sebastian Redlc3632732010-10-05 15:59:54 +0000608 E->setOperatorLoc(ReadSourceLocation(Record, Idx));
Chris Lattner4c6f9522009-04-27 05:14:47 +0000609}
610
Sebastian Redl60adf4a2010-08-18 23:56:52 +0000611void ASTStmtReader::VisitCompoundAssignOperator(CompoundAssignOperator *E) {
Chris Lattner4c6f9522009-04-27 05:14:47 +0000612 VisitBinaryOperator(E);
613 E->setComputationLHSType(Reader.GetType(Record[Idx++]));
614 E->setComputationResultType(Reader.GetType(Record[Idx++]));
Chris Lattner4c6f9522009-04-27 05:14:47 +0000615}
616
Sebastian Redl60adf4a2010-08-18 23:56:52 +0000617void ASTStmtReader::VisitConditionalOperator(ConditionalOperator *E) {
Chris Lattner4c6f9522009-04-27 05:14:47 +0000618 VisitExpr(E);
Argyrios Kyrtzidisd98a2ab2010-06-29 22:46:25 +0000619 E->setCond(Reader.ReadSubExpr());
620 E->setLHS(Reader.ReadSubExpr());
621 E->setRHS(Reader.ReadSubExpr());
Fariborz Jahanianf9b949f2010-08-31 18:02:20 +0000622 E->setSAVE(Reader.ReadSubExpr());
Sebastian Redlc3632732010-10-05 15:59:54 +0000623 E->setQuestionLoc(ReadSourceLocation(Record, Idx));
624 E->setColonLoc(ReadSourceLocation(Record, Idx));
Chris Lattner4c6f9522009-04-27 05:14:47 +0000625}
626
Sebastian Redl60adf4a2010-08-18 23:56:52 +0000627void ASTStmtReader::VisitImplicitCastExpr(ImplicitCastExpr *E) {
Chris Lattner4c6f9522009-04-27 05:14:47 +0000628 VisitCastExpr(E);
John McCall5baba9d2010-08-25 10:28:54 +0000629 E->setValueKind(static_cast<ExprValueKind>(Record[Idx++]));
Chris Lattner4c6f9522009-04-27 05:14:47 +0000630}
631
Sebastian Redl60adf4a2010-08-18 23:56:52 +0000632void ASTStmtReader::VisitExplicitCastExpr(ExplicitCastExpr *E) {
Chris Lattner4c6f9522009-04-27 05:14:47 +0000633 VisitCastExpr(E);
Sebastian Redlc3632732010-10-05 15:59:54 +0000634 E->setTypeInfoAsWritten(GetTypeSourceInfo(Record, Idx));
Chris Lattner4c6f9522009-04-27 05:14:47 +0000635}
636
Sebastian Redl60adf4a2010-08-18 23:56:52 +0000637void ASTStmtReader::VisitCStyleCastExpr(CStyleCastExpr *E) {
Chris Lattner4c6f9522009-04-27 05:14:47 +0000638 VisitExplicitCastExpr(E);
Sebastian Redlc3632732010-10-05 15:59:54 +0000639 E->setLParenLoc(ReadSourceLocation(Record, Idx));
640 E->setRParenLoc(ReadSourceLocation(Record, Idx));
Chris Lattner4c6f9522009-04-27 05:14:47 +0000641}
642
Sebastian Redl60adf4a2010-08-18 23:56:52 +0000643void ASTStmtReader::VisitCompoundLiteralExpr(CompoundLiteralExpr *E) {
Chris Lattner4c6f9522009-04-27 05:14:47 +0000644 VisitExpr(E);
Sebastian Redlc3632732010-10-05 15:59:54 +0000645 E->setLParenLoc(ReadSourceLocation(Record, Idx));
646 E->setTypeSourceInfo(GetTypeSourceInfo(Record, Idx));
Argyrios Kyrtzidisd98a2ab2010-06-29 22:46:25 +0000647 E->setInitializer(Reader.ReadSubExpr());
Chris Lattner4c6f9522009-04-27 05:14:47 +0000648 E->setFileScope(Record[Idx++]);
Chris Lattner4c6f9522009-04-27 05:14:47 +0000649}
650
Sebastian Redl60adf4a2010-08-18 23:56:52 +0000651void ASTStmtReader::VisitExtVectorElementExpr(ExtVectorElementExpr *E) {
Chris Lattner4c6f9522009-04-27 05:14:47 +0000652 VisitExpr(E);
Argyrios Kyrtzidisd98a2ab2010-06-29 22:46:25 +0000653 E->setBase(Reader.ReadSubExpr());
Chris Lattner4c6f9522009-04-27 05:14:47 +0000654 E->setAccessor(Reader.GetIdentifierInfo(Record, Idx));
Sebastian Redlc3632732010-10-05 15:59:54 +0000655 E->setAccessorLoc(ReadSourceLocation(Record, Idx));
Chris Lattner4c6f9522009-04-27 05:14:47 +0000656}
657
Sebastian Redl60adf4a2010-08-18 23:56:52 +0000658void ASTStmtReader::VisitInitListExpr(InitListExpr *E) {
Chris Lattner4c6f9522009-04-27 05:14:47 +0000659 VisitExpr(E);
660 unsigned NumInits = Record[Idx++];
Ted Kremenek709210f2010-04-13 23:39:13 +0000661 E->reserveInits(*Reader.getContext(), NumInits);
Chris Lattner4c6f9522009-04-27 05:14:47 +0000662 for (unsigned I = 0; I != NumInits; ++I)
Argyrios Kyrtzidisd98a2ab2010-06-29 22:46:25 +0000663 E->updateInit(*Reader.getContext(), I, Reader.ReadSubExpr());
664 E->setSyntacticForm(cast_or_null<InitListExpr>(Reader.ReadSubStmt()));
Sebastian Redlc3632732010-10-05 15:59:54 +0000665 E->setLBraceLoc(ReadSourceLocation(Record, Idx));
666 E->setRBraceLoc(ReadSourceLocation(Record, Idx));
Chris Lattner4c6f9522009-04-27 05:14:47 +0000667 E->setInitializedFieldInUnion(
668 cast_or_null<FieldDecl>(Reader.GetDecl(Record[Idx++])));
669 E->sawArrayRangeDesignator(Record[Idx++]);
Chris Lattner4c6f9522009-04-27 05:14:47 +0000670}
671
Sebastian Redl60adf4a2010-08-18 23:56:52 +0000672void ASTStmtReader::VisitDesignatedInitExpr(DesignatedInitExpr *E) {
Chris Lattner4c6f9522009-04-27 05:14:47 +0000673 typedef DesignatedInitExpr::Designator Designator;
674
675 VisitExpr(E);
676 unsigned NumSubExprs = Record[Idx++];
677 assert(NumSubExprs == E->getNumSubExprs() && "Wrong number of subexprs");
678 for (unsigned I = 0; I != NumSubExprs; ++I)
Argyrios Kyrtzidisd98a2ab2010-06-29 22:46:25 +0000679 E->setSubExpr(I, Reader.ReadSubExpr());
Sebastian Redlc3632732010-10-05 15:59:54 +0000680 E->setEqualOrColonLoc(ReadSourceLocation(Record, Idx));
Chris Lattner4c6f9522009-04-27 05:14:47 +0000681 E->setGNUSyntax(Record[Idx++]);
682
683 llvm::SmallVector<Designator, 4> Designators;
684 while (Idx < Record.size()) {
Sebastian Redl8538e8d2010-08-18 23:57:32 +0000685 switch ((DesignatorTypes)Record[Idx++]) {
686 case DESIG_FIELD_DECL: {
Chris Lattner4c6f9522009-04-27 05:14:47 +0000687 FieldDecl *Field = cast<FieldDecl>(Reader.GetDecl(Record[Idx++]));
Mike Stump1eb44332009-09-09 15:08:12 +0000688 SourceLocation DotLoc
Sebastian Redlc3632732010-10-05 15:59:54 +0000689 = ReadSourceLocation(Record, Idx);
Mike Stump1eb44332009-09-09 15:08:12 +0000690 SourceLocation FieldLoc
Sebastian Redlc3632732010-10-05 15:59:54 +0000691 = ReadSourceLocation(Record, Idx);
Mike Stump1eb44332009-09-09 15:08:12 +0000692 Designators.push_back(Designator(Field->getIdentifier(), DotLoc,
Chris Lattner4c6f9522009-04-27 05:14:47 +0000693 FieldLoc));
694 Designators.back().setField(Field);
695 break;
696 }
697
Sebastian Redl8538e8d2010-08-18 23:57:32 +0000698 case DESIG_FIELD_NAME: {
Chris Lattner4c6f9522009-04-27 05:14:47 +0000699 const IdentifierInfo *Name = Reader.GetIdentifierInfo(Record, Idx);
Mike Stump1eb44332009-09-09 15:08:12 +0000700 SourceLocation DotLoc
Sebastian Redlc3632732010-10-05 15:59:54 +0000701 = ReadSourceLocation(Record, Idx);
Mike Stump1eb44332009-09-09 15:08:12 +0000702 SourceLocation FieldLoc
Sebastian Redlc3632732010-10-05 15:59:54 +0000703 = ReadSourceLocation(Record, Idx);
Chris Lattner4c6f9522009-04-27 05:14:47 +0000704 Designators.push_back(Designator(Name, DotLoc, FieldLoc));
705 break;
706 }
Mike Stump1eb44332009-09-09 15:08:12 +0000707
Sebastian Redl8538e8d2010-08-18 23:57:32 +0000708 case DESIG_ARRAY: {
Chris Lattner4c6f9522009-04-27 05:14:47 +0000709 unsigned Index = Record[Idx++];
710 SourceLocation LBracketLoc
Sebastian Redlc3632732010-10-05 15:59:54 +0000711 = ReadSourceLocation(Record, Idx);
Chris Lattner4c6f9522009-04-27 05:14:47 +0000712 SourceLocation RBracketLoc
Sebastian Redlc3632732010-10-05 15:59:54 +0000713 = ReadSourceLocation(Record, Idx);
Chris Lattner4c6f9522009-04-27 05:14:47 +0000714 Designators.push_back(Designator(Index, LBracketLoc, RBracketLoc));
715 break;
716 }
717
Sebastian Redl8538e8d2010-08-18 23:57:32 +0000718 case DESIG_ARRAY_RANGE: {
Chris Lattner4c6f9522009-04-27 05:14:47 +0000719 unsigned Index = Record[Idx++];
720 SourceLocation LBracketLoc
Sebastian Redlc3632732010-10-05 15:59:54 +0000721 = ReadSourceLocation(Record, Idx);
Chris Lattner4c6f9522009-04-27 05:14:47 +0000722 SourceLocation EllipsisLoc
Sebastian Redlc3632732010-10-05 15:59:54 +0000723 = ReadSourceLocation(Record, Idx);
Chris Lattner4c6f9522009-04-27 05:14:47 +0000724 SourceLocation RBracketLoc
Sebastian Redlc3632732010-10-05 15:59:54 +0000725 = ReadSourceLocation(Record, Idx);
Chris Lattner4c6f9522009-04-27 05:14:47 +0000726 Designators.push_back(Designator(Index, LBracketLoc, EllipsisLoc,
727 RBracketLoc));
728 break;
729 }
730 }
731 }
Douglas Gregor319d57f2010-01-06 23:17:19 +0000732 E->setDesignators(*Reader.getContext(),
733 Designators.data(), Designators.size());
Chris Lattner4c6f9522009-04-27 05:14:47 +0000734}
735
Sebastian Redl60adf4a2010-08-18 23:56:52 +0000736void ASTStmtReader::VisitImplicitValueInitExpr(ImplicitValueInitExpr *E) {
Chris Lattner4c6f9522009-04-27 05:14:47 +0000737 VisitExpr(E);
Chris Lattner4c6f9522009-04-27 05:14:47 +0000738}
739
Sebastian Redl60adf4a2010-08-18 23:56:52 +0000740void ASTStmtReader::VisitVAArgExpr(VAArgExpr *E) {
Chris Lattner4c6f9522009-04-27 05:14:47 +0000741 VisitExpr(E);
Argyrios Kyrtzidisd98a2ab2010-06-29 22:46:25 +0000742 E->setSubExpr(Reader.ReadSubExpr());
Sebastian Redlc3632732010-10-05 15:59:54 +0000743 E->setWrittenTypeInfo(GetTypeSourceInfo(Record, Idx));
744 E->setBuiltinLoc(ReadSourceLocation(Record, Idx));
745 E->setRParenLoc(ReadSourceLocation(Record, Idx));
Chris Lattner4c6f9522009-04-27 05:14:47 +0000746}
747
Sebastian Redl60adf4a2010-08-18 23:56:52 +0000748void ASTStmtReader::VisitAddrLabelExpr(AddrLabelExpr *E) {
Chris Lattner4c6f9522009-04-27 05:14:47 +0000749 VisitExpr(E);
Sebastian Redlc3632732010-10-05 15:59:54 +0000750 E->setAmpAmpLoc(ReadSourceLocation(Record, Idx));
751 E->setLabelLoc(ReadSourceLocation(Record, Idx));
Chris Lattner4c6f9522009-04-27 05:14:47 +0000752 Reader.SetLabelOf(E, Record[Idx++]);
Chris Lattner4c6f9522009-04-27 05:14:47 +0000753}
754
Sebastian Redl60adf4a2010-08-18 23:56:52 +0000755void ASTStmtReader::VisitStmtExpr(StmtExpr *E) {
Chris Lattner4c6f9522009-04-27 05:14:47 +0000756 VisitExpr(E);
Sebastian Redlc3632732010-10-05 15:59:54 +0000757 E->setLParenLoc(ReadSourceLocation(Record, Idx));
758 E->setRParenLoc(ReadSourceLocation(Record, Idx));
Argyrios Kyrtzidisd98a2ab2010-06-29 22:46:25 +0000759 E->setSubStmt(cast_or_null<CompoundStmt>(Reader.ReadSubStmt()));
Chris Lattner4c6f9522009-04-27 05:14:47 +0000760}
761
Sebastian Redl60adf4a2010-08-18 23:56:52 +0000762void ASTStmtReader::VisitTypesCompatibleExpr(TypesCompatibleExpr *E) {
Chris Lattner4c6f9522009-04-27 05:14:47 +0000763 VisitExpr(E);
Sebastian Redlc3632732010-10-05 15:59:54 +0000764 E->setArgTInfo1(GetTypeSourceInfo(Record, Idx));
765 E->setArgTInfo2(GetTypeSourceInfo(Record, Idx));
766 E->setBuiltinLoc(ReadSourceLocation(Record, Idx));
767 E->setRParenLoc(ReadSourceLocation(Record, Idx));
Chris Lattner4c6f9522009-04-27 05:14:47 +0000768}
769
Sebastian Redl60adf4a2010-08-18 23:56:52 +0000770void ASTStmtReader::VisitChooseExpr(ChooseExpr *E) {
Chris Lattner4c6f9522009-04-27 05:14:47 +0000771 VisitExpr(E);
Argyrios Kyrtzidisd98a2ab2010-06-29 22:46:25 +0000772 E->setCond(Reader.ReadSubExpr());
773 E->setLHS(Reader.ReadSubExpr());
774 E->setRHS(Reader.ReadSubExpr());
Sebastian Redlc3632732010-10-05 15:59:54 +0000775 E->setBuiltinLoc(ReadSourceLocation(Record, Idx));
776 E->setRParenLoc(ReadSourceLocation(Record, Idx));
Chris Lattner4c6f9522009-04-27 05:14:47 +0000777}
778
Sebastian Redl60adf4a2010-08-18 23:56:52 +0000779void ASTStmtReader::VisitGNUNullExpr(GNUNullExpr *E) {
Chris Lattner4c6f9522009-04-27 05:14:47 +0000780 VisitExpr(E);
Sebastian Redlc3632732010-10-05 15:59:54 +0000781 E->setTokenLocation(ReadSourceLocation(Record, Idx));
Chris Lattner4c6f9522009-04-27 05:14:47 +0000782}
783
Sebastian Redl60adf4a2010-08-18 23:56:52 +0000784void ASTStmtReader::VisitShuffleVectorExpr(ShuffleVectorExpr *E) {
Chris Lattner4c6f9522009-04-27 05:14:47 +0000785 VisitExpr(E);
Argyrios Kyrtzidis919e6932010-06-28 22:28:35 +0000786 llvm::SmallVector<Expr *, 16> Exprs;
Chris Lattner4c6f9522009-04-27 05:14:47 +0000787 unsigned NumExprs = Record[Idx++];
Argyrios Kyrtzidis919e6932010-06-28 22:28:35 +0000788 while (NumExprs--)
Argyrios Kyrtzidisd98a2ab2010-06-29 22:46:25 +0000789 Exprs.push_back(Reader.ReadSubExpr());
Argyrios Kyrtzidis919e6932010-06-28 22:28:35 +0000790 E->setExprs(*Reader.getContext(), Exprs.data(), Exprs.size());
Sebastian Redlc3632732010-10-05 15:59:54 +0000791 E->setBuiltinLoc(ReadSourceLocation(Record, Idx));
792 E->setRParenLoc(ReadSourceLocation(Record, Idx));
Chris Lattner4c6f9522009-04-27 05:14:47 +0000793}
794
Sebastian Redl60adf4a2010-08-18 23:56:52 +0000795void ASTStmtReader::VisitBlockExpr(BlockExpr *E) {
Chris Lattner4c6f9522009-04-27 05:14:47 +0000796 VisitExpr(E);
797 E->setBlockDecl(cast_or_null<BlockDecl>(Reader.GetDecl(Record[Idx++])));
798 E->setHasBlockDeclRefExprs(Record[Idx++]);
Chris Lattner4c6f9522009-04-27 05:14:47 +0000799}
800
Sebastian Redl60adf4a2010-08-18 23:56:52 +0000801void ASTStmtReader::VisitBlockDeclRefExpr(BlockDeclRefExpr *E) {
Chris Lattner4c6f9522009-04-27 05:14:47 +0000802 VisitExpr(E);
803 E->setDecl(cast<ValueDecl>(Reader.GetDecl(Record[Idx++])));
Sebastian Redlc3632732010-10-05 15:59:54 +0000804 E->setLocation(ReadSourceLocation(Record, Idx));
Chris Lattner4c6f9522009-04-27 05:14:47 +0000805 E->setByRef(Record[Idx++]);
Fariborz Jahanian9b0b57c2009-06-20 00:02:26 +0000806 E->setConstQualAdded(Record[Idx++]);
Argyrios Kyrtzidisd98a2ab2010-06-29 22:46:25 +0000807 E->setCopyConstructorExpr(Reader.ReadSubExpr());
Chris Lattner4c6f9522009-04-27 05:14:47 +0000808}
809
810//===----------------------------------------------------------------------===//
811// Objective-C Expressions and Statements
812
Sebastian Redl60adf4a2010-08-18 23:56:52 +0000813void ASTStmtReader::VisitObjCStringLiteral(ObjCStringLiteral *E) {
Chris Lattner4c6f9522009-04-27 05:14:47 +0000814 VisitExpr(E);
Argyrios Kyrtzidisd98a2ab2010-06-29 22:46:25 +0000815 E->setString(cast<StringLiteral>(Reader.ReadSubStmt()));
Sebastian Redlc3632732010-10-05 15:59:54 +0000816 E->setAtLoc(ReadSourceLocation(Record, Idx));
Chris Lattner4c6f9522009-04-27 05:14:47 +0000817}
818
Sebastian Redl60adf4a2010-08-18 23:56:52 +0000819void ASTStmtReader::VisitObjCEncodeExpr(ObjCEncodeExpr *E) {
Chris Lattner4c6f9522009-04-27 05:14:47 +0000820 VisitExpr(E);
Sebastian Redlc3632732010-10-05 15:59:54 +0000821 E->setEncodedTypeSourceInfo(GetTypeSourceInfo(Record, Idx));
822 E->setAtLoc(ReadSourceLocation(Record, Idx));
823 E->setRParenLoc(ReadSourceLocation(Record, Idx));
Chris Lattner4c6f9522009-04-27 05:14:47 +0000824}
825
Sebastian Redl60adf4a2010-08-18 23:56:52 +0000826void ASTStmtReader::VisitObjCSelectorExpr(ObjCSelectorExpr *E) {
Chris Lattner4c6f9522009-04-27 05:14:47 +0000827 VisitExpr(E);
828 E->setSelector(Reader.GetSelector(Record, Idx));
Sebastian Redlc3632732010-10-05 15:59:54 +0000829 E->setAtLoc(ReadSourceLocation(Record, Idx));
830 E->setRParenLoc(ReadSourceLocation(Record, Idx));
Chris Lattner4c6f9522009-04-27 05:14:47 +0000831}
832
Sebastian Redl60adf4a2010-08-18 23:56:52 +0000833void ASTStmtReader::VisitObjCProtocolExpr(ObjCProtocolExpr *E) {
Chris Lattner4c6f9522009-04-27 05:14:47 +0000834 VisitExpr(E);
835 E->setProtocol(cast<ObjCProtocolDecl>(Reader.GetDecl(Record[Idx++])));
Sebastian Redlc3632732010-10-05 15:59:54 +0000836 E->setAtLoc(ReadSourceLocation(Record, Idx));
837 E->setRParenLoc(ReadSourceLocation(Record, Idx));
Chris Lattner4c6f9522009-04-27 05:14:47 +0000838}
839
Sebastian Redl60adf4a2010-08-18 23:56:52 +0000840void ASTStmtReader::VisitObjCIvarRefExpr(ObjCIvarRefExpr *E) {
Chris Lattner4c6f9522009-04-27 05:14:47 +0000841 VisitExpr(E);
842 E->setDecl(cast<ObjCIvarDecl>(Reader.GetDecl(Record[Idx++])));
Sebastian Redlc3632732010-10-05 15:59:54 +0000843 E->setLocation(ReadSourceLocation(Record, Idx));
Argyrios Kyrtzidisd98a2ab2010-06-29 22:46:25 +0000844 E->setBase(Reader.ReadSubExpr());
Chris Lattner4c6f9522009-04-27 05:14:47 +0000845 E->setIsArrow(Record[Idx++]);
846 E->setIsFreeIvar(Record[Idx++]);
Chris Lattner4c6f9522009-04-27 05:14:47 +0000847}
848
Sebastian Redl60adf4a2010-08-18 23:56:52 +0000849void ASTStmtReader::VisitObjCPropertyRefExpr(ObjCPropertyRefExpr *E) {
Chris Lattner4c6f9522009-04-27 05:14:47 +0000850 VisitExpr(E);
851 E->setProperty(cast<ObjCPropertyDecl>(Reader.GetDecl(Record[Idx++])));
Sebastian Redlc3632732010-10-05 15:59:54 +0000852 E->setLocation(ReadSourceLocation(Record, Idx));
Fariborz Jahanian8ac2d442010-10-14 16:04:05 +0000853 E->SuperLoc = ReadSourceLocation(Record, Idx);
854 if (E->isSuperReceiver()) {
855 QualType T = Reader.GetType(Record[Idx++]);
856 E->BaseExprOrSuperType = T.getTypePtr();
857 }
858 else
859 E->setBase(Reader.ReadSubExpr());
Chris Lattner4c6f9522009-04-27 05:14:47 +0000860}
861
Sebastian Redl60adf4a2010-08-18 23:56:52 +0000862void ASTStmtReader::VisitObjCImplicitSetterGetterRefExpr(
Fariborz Jahanian09105f52009-08-20 17:02:02 +0000863 ObjCImplicitSetterGetterRefExpr *E) {
Chris Lattner4c6f9522009-04-27 05:14:47 +0000864 VisitExpr(E);
865 E->setGetterMethod(
866 cast_or_null<ObjCMethodDecl>(Reader.GetDecl(Record[Idx++])));
867 E->setSetterMethod(
868 cast_or_null<ObjCMethodDecl>(Reader.GetDecl(Record[Idx++])));
Fariborz Jahaniand2ae5aa2009-08-18 21:37:33 +0000869 E->setInterfaceDecl(
Chris Lattner4c6f9522009-04-27 05:14:47 +0000870 cast_or_null<ObjCInterfaceDecl>(Reader.GetDecl(Record[Idx++])));
Argyrios Kyrtzidisd98a2ab2010-06-29 22:46:25 +0000871 E->setBase(Reader.ReadSubExpr());
Sebastian Redlc3632732010-10-05 15:59:54 +0000872 E->setLocation(ReadSourceLocation(Record, Idx));
873 E->setClassLoc(ReadSourceLocation(Record, Idx));
Fariborz Jahanian8ac2d442010-10-14 16:04:05 +0000874 E->SuperLoc = ReadSourceLocation(Record, Idx);
875 E->SuperTy = Reader.GetType(Record[Idx++]);
Chris Lattner4c6f9522009-04-27 05:14:47 +0000876}
877
Sebastian Redl60adf4a2010-08-18 23:56:52 +0000878void ASTStmtReader::VisitObjCMessageExpr(ObjCMessageExpr *E) {
Chris Lattner4c6f9522009-04-27 05:14:47 +0000879 VisitExpr(E);
Douglas Gregor04badcf2010-04-21 00:45:42 +0000880 assert(Record[Idx] == E->getNumArgs());
881 ++Idx;
882 ObjCMessageExpr::ReceiverKind Kind
883 = static_cast<ObjCMessageExpr::ReceiverKind>(Record[Idx++]);
884 switch (Kind) {
885 case ObjCMessageExpr::Instance:
Argyrios Kyrtzidisd98a2ab2010-06-29 22:46:25 +0000886 E->setInstanceReceiver(Reader.ReadSubExpr());
Douglas Gregor04badcf2010-04-21 00:45:42 +0000887 break;
888
889 case ObjCMessageExpr::Class:
Sebastian Redlc3632732010-10-05 15:59:54 +0000890 E->setClassReceiver(GetTypeSourceInfo(Record, Idx));
Douglas Gregor04badcf2010-04-21 00:45:42 +0000891 break;
892
893 case ObjCMessageExpr::SuperClass:
894 case ObjCMessageExpr::SuperInstance: {
895 QualType T = Reader.GetType(Record[Idx++]);
Sebastian Redlc3632732010-10-05 15:59:54 +0000896 SourceLocation SuperLoc = ReadSourceLocation(Record, Idx);
Douglas Gregor04badcf2010-04-21 00:45:42 +0000897 E->setSuper(SuperLoc, T, Kind == ObjCMessageExpr::SuperInstance);
898 break;
899 }
900 }
901
902 assert(Kind == E->getReceiverKind());
903
904 if (Record[Idx++])
905 E->setMethodDecl(cast_or_null<ObjCMethodDecl>(Reader.GetDecl(Record[Idx++])));
906 else
907 E->setSelector(Reader.GetSelector(Record, Idx));
908
Sebastian Redlc3632732010-10-05 15:59:54 +0000909 E->setLeftLoc(ReadSourceLocation(Record, Idx));
910 E->setRightLoc(ReadSourceLocation(Record, Idx));
Chris Lattner4c6f9522009-04-27 05:14:47 +0000911
912 for (unsigned I = 0, N = E->getNumArgs(); I != N; ++I)
Argyrios Kyrtzidisd98a2ab2010-06-29 22:46:25 +0000913 E->setArg(I, Reader.ReadSubExpr());
Chris Lattner4c6f9522009-04-27 05:14:47 +0000914}
915
Sebastian Redl60adf4a2010-08-18 23:56:52 +0000916void ASTStmtReader::VisitObjCForCollectionStmt(ObjCForCollectionStmt *S) {
Chris Lattner4c6f9522009-04-27 05:14:47 +0000917 VisitStmt(S);
Argyrios Kyrtzidisd98a2ab2010-06-29 22:46:25 +0000918 S->setElement(Reader.ReadSubStmt());
919 S->setCollection(Reader.ReadSubExpr());
920 S->setBody(Reader.ReadSubStmt());
Sebastian Redlc3632732010-10-05 15:59:54 +0000921 S->setForLoc(ReadSourceLocation(Record, Idx));
922 S->setRParenLoc(ReadSourceLocation(Record, Idx));
Chris Lattner4c6f9522009-04-27 05:14:47 +0000923}
924
Sebastian Redl60adf4a2010-08-18 23:56:52 +0000925void ASTStmtReader::VisitObjCAtCatchStmt(ObjCAtCatchStmt *S) {
Chris Lattner4c6f9522009-04-27 05:14:47 +0000926 VisitStmt(S);
Argyrios Kyrtzidisd98a2ab2010-06-29 22:46:25 +0000927 S->setCatchBody(Reader.ReadSubStmt());
Douglas Gregorc00d8e12010-04-26 16:46:50 +0000928 S->setCatchParamDecl(cast_or_null<VarDecl>(Reader.GetDecl(Record[Idx++])));
Sebastian Redlc3632732010-10-05 15:59:54 +0000929 S->setAtCatchLoc(ReadSourceLocation(Record, Idx));
930 S->setRParenLoc(ReadSourceLocation(Record, Idx));
Chris Lattner4c6f9522009-04-27 05:14:47 +0000931}
932
Sebastian Redl60adf4a2010-08-18 23:56:52 +0000933void ASTStmtReader::VisitObjCAtFinallyStmt(ObjCAtFinallyStmt *S) {
Chris Lattner4c6f9522009-04-27 05:14:47 +0000934 VisitStmt(S);
Argyrios Kyrtzidisd98a2ab2010-06-29 22:46:25 +0000935 S->setFinallyBody(Reader.ReadSubStmt());
Sebastian Redlc3632732010-10-05 15:59:54 +0000936 S->setAtFinallyLoc(ReadSourceLocation(Record, Idx));
Chris Lattner4c6f9522009-04-27 05:14:47 +0000937}
938
Sebastian Redl60adf4a2010-08-18 23:56:52 +0000939void ASTStmtReader::VisitObjCAtTryStmt(ObjCAtTryStmt *S) {
Chris Lattner4c6f9522009-04-27 05:14:47 +0000940 VisitStmt(S);
Douglas Gregor8f5e3dd2010-04-23 22:50:49 +0000941 assert(Record[Idx] == S->getNumCatchStmts());
942 ++Idx;
943 bool HasFinally = Record[Idx++];
Argyrios Kyrtzidisd98a2ab2010-06-29 22:46:25 +0000944 S->setTryBody(Reader.ReadSubStmt());
Argyrios Kyrtzidis919e6932010-06-28 22:28:35 +0000945 for (unsigned I = 0, N = S->getNumCatchStmts(); I != N; ++I)
Argyrios Kyrtzidisd98a2ab2010-06-29 22:46:25 +0000946 S->setCatchStmt(I, cast_or_null<ObjCAtCatchStmt>(Reader.ReadSubStmt()));
Douglas Gregor8f5e3dd2010-04-23 22:50:49 +0000947
Douglas Gregor8f5e3dd2010-04-23 22:50:49 +0000948 if (HasFinally)
Argyrios Kyrtzidisd98a2ab2010-06-29 22:46:25 +0000949 S->setFinallyStmt(Reader.ReadSubStmt());
Sebastian Redlc3632732010-10-05 15:59:54 +0000950 S->setAtTryLoc(ReadSourceLocation(Record, Idx));
Chris Lattner4c6f9522009-04-27 05:14:47 +0000951}
952
Sebastian Redl60adf4a2010-08-18 23:56:52 +0000953void ASTStmtReader::VisitObjCAtSynchronizedStmt(ObjCAtSynchronizedStmt *S) {
Chris Lattner4c6f9522009-04-27 05:14:47 +0000954 VisitStmt(S);
Argyrios Kyrtzidisd98a2ab2010-06-29 22:46:25 +0000955 S->setSynchExpr(Reader.ReadSubStmt());
956 S->setSynchBody(Reader.ReadSubStmt());
Sebastian Redlc3632732010-10-05 15:59:54 +0000957 S->setAtSynchronizedLoc(ReadSourceLocation(Record, Idx));
Chris Lattner4c6f9522009-04-27 05:14:47 +0000958}
959
Sebastian Redl60adf4a2010-08-18 23:56:52 +0000960void ASTStmtReader::VisitObjCAtThrowStmt(ObjCAtThrowStmt *S) {
Chris Lattner4c6f9522009-04-27 05:14:47 +0000961 VisitStmt(S);
Argyrios Kyrtzidisd98a2ab2010-06-29 22:46:25 +0000962 S->setThrowExpr(Reader.ReadSubStmt());
Sebastian Redlc3632732010-10-05 15:59:54 +0000963 S->setThrowLoc(ReadSourceLocation(Record, Idx));
Chris Lattner4c6f9522009-04-27 05:14:47 +0000964}
965
Argyrios Kyrtzidisba0a9002009-07-14 03:19:21 +0000966//===----------------------------------------------------------------------===//
967// C++ Expressions and Statements
Argyrios Kyrtzidis7cb45e32010-07-22 16:03:56 +0000968//===----------------------------------------------------------------------===//
969
Sebastian Redl60adf4a2010-08-18 23:56:52 +0000970void ASTStmtReader::VisitCXXCatchStmt(CXXCatchStmt *S) {
Argyrios Kyrtzidis7cb45e32010-07-22 16:03:56 +0000971 VisitStmt(S);
Sebastian Redlc3632732010-10-05 15:59:54 +0000972 S->CatchLoc = ReadSourceLocation(Record, Idx);
Argyrios Kyrtzidis7cb45e32010-07-22 16:03:56 +0000973 S->ExceptionDecl = cast_or_null<VarDecl>(Reader.GetDecl(Record[Idx++]));
974 S->HandlerBlock = Reader.ReadSubStmt();
975}
976
Sebastian Redl60adf4a2010-08-18 23:56:52 +0000977void ASTStmtReader::VisitCXXTryStmt(CXXTryStmt *S) {
Argyrios Kyrtzidis7cb45e32010-07-22 16:03:56 +0000978 VisitStmt(S);
979 assert(Record[Idx] == S->getNumHandlers() && "NumStmtFields is wrong ?");
980 ++Idx;
Sebastian Redlc3632732010-10-05 15:59:54 +0000981 S->TryLoc = ReadSourceLocation(Record, Idx);
Argyrios Kyrtzidis7cb45e32010-07-22 16:03:56 +0000982 S->getStmts()[0] = Reader.ReadSubStmt();
983 for (unsigned i = 0, e = S->getNumHandlers(); i != e; ++i)
984 S->getStmts()[i + 1] = Reader.ReadSubStmt();
985}
Argyrios Kyrtzidisba0a9002009-07-14 03:19:21 +0000986
Sebastian Redl60adf4a2010-08-18 23:56:52 +0000987void ASTStmtReader::VisitCXXOperatorCallExpr(CXXOperatorCallExpr *E) {
Argyrios Kyrtzidis919e6932010-06-28 22:28:35 +0000988 VisitCallExpr(E);
Argyrios Kyrtzidisba0a9002009-07-14 03:19:21 +0000989 E->setOperator((OverloadedOperatorKind)Record[Idx++]);
Argyrios Kyrtzidisba0a9002009-07-14 03:19:21 +0000990}
991
Sebastian Redl60adf4a2010-08-18 23:56:52 +0000992void ASTStmtReader::VisitCXXConstructExpr(CXXConstructExpr *E) {
Douglas Gregor39da0b82009-09-09 23:08:42 +0000993 VisitExpr(E);
Argyrios Kyrtzidis6d00c132010-07-10 11:46:15 +0000994 E->NumArgs = Record[Idx++];
995 if (E->NumArgs)
996 E->Args = new (*Reader.getContext()) Stmt*[E->NumArgs];
Argyrios Kyrtzidis5e1b7c22010-06-24 08:57:09 +0000997 for (unsigned I = 0, N = E->getNumArgs(); I != N; ++I)
Argyrios Kyrtzidisd98a2ab2010-06-29 22:46:25 +0000998 E->setArg(I, Reader.ReadSubExpr());
Douglas Gregor39da0b82009-09-09 23:08:42 +0000999 E->setConstructor(cast<CXXConstructorDecl>(Reader.GetDecl(Record[Idx++])));
Sebastian Redlc3632732010-10-05 15:59:54 +00001000 E->setLocation(ReadSourceLocation(Record, Idx));
Douglas Gregor39da0b82009-09-09 23:08:42 +00001001 E->setElidable(Record[Idx++]);
Douglas Gregor16006c92009-12-16 18:50:27 +00001002 E->setRequiresZeroInitialization(Record[Idx++]);
Douglas Gregor3c9034c2010-05-15 00:13:29 +00001003 E->setConstructionKind((CXXConstructExpr::ConstructionKind)Record[Idx++]);
Douglas Gregor39da0b82009-09-09 23:08:42 +00001004}
Chris Lattner4c6f9522009-04-27 05:14:47 +00001005
Sebastian Redl60adf4a2010-08-18 23:56:52 +00001006void ASTStmtReader::VisitCXXTemporaryObjectExpr(CXXTemporaryObjectExpr *E) {
Argyrios Kyrtzidis6d00c132010-07-10 11:46:15 +00001007 VisitCXXConstructExpr(E);
Sebastian Redlc3632732010-10-05 15:59:54 +00001008 E->Type = GetTypeSourceInfo(Record, Idx);
1009 E->RParenLoc = ReadSourceLocation(Record, Idx);
Argyrios Kyrtzidis6d00c132010-07-10 11:46:15 +00001010}
1011
Sebastian Redl60adf4a2010-08-18 23:56:52 +00001012void ASTStmtReader::VisitCXXNamedCastExpr(CXXNamedCastExpr *E) {
Argyrios Kyrtzidis919e6932010-06-28 22:28:35 +00001013 VisitExplicitCastExpr(E);
Sebastian Redlc3632732010-10-05 15:59:54 +00001014 E->setOperatorLoc(ReadSourceLocation(Record, Idx));
Sam Weinigce757a72010-01-16 21:21:01 +00001015}
1016
Sebastian Redl60adf4a2010-08-18 23:56:52 +00001017void ASTStmtReader::VisitCXXStaticCastExpr(CXXStaticCastExpr *E) {
Sam Weinigce757a72010-01-16 21:21:01 +00001018 return VisitCXXNamedCastExpr(E);
1019}
1020
Sebastian Redl60adf4a2010-08-18 23:56:52 +00001021void ASTStmtReader::VisitCXXDynamicCastExpr(CXXDynamicCastExpr *E) {
Sam Weinigce757a72010-01-16 21:21:01 +00001022 return VisitCXXNamedCastExpr(E);
1023}
1024
Sebastian Redl60adf4a2010-08-18 23:56:52 +00001025void ASTStmtReader::VisitCXXReinterpretCastExpr(CXXReinterpretCastExpr *E) {
Sam Weinigce757a72010-01-16 21:21:01 +00001026 return VisitCXXNamedCastExpr(E);
1027}
1028
Sebastian Redl60adf4a2010-08-18 23:56:52 +00001029void ASTStmtReader::VisitCXXConstCastExpr(CXXConstCastExpr *E) {
Sam Weinigce757a72010-01-16 21:21:01 +00001030 return VisitCXXNamedCastExpr(E);
1031}
1032
Sebastian Redl60adf4a2010-08-18 23:56:52 +00001033void ASTStmtReader::VisitCXXFunctionalCastExpr(CXXFunctionalCastExpr *E) {
Argyrios Kyrtzidis919e6932010-06-28 22:28:35 +00001034 VisitExplicitCastExpr(E);
Sebastian Redlc3632732010-10-05 15:59:54 +00001035 E->setTypeBeginLoc(ReadSourceLocation(Record, Idx));
1036 E->setRParenLoc(ReadSourceLocation(Record, Idx));
Sam Weinigce757a72010-01-16 21:21:01 +00001037}
1038
Sebastian Redl60adf4a2010-08-18 23:56:52 +00001039void ASTStmtReader::VisitCXXBoolLiteralExpr(CXXBoolLiteralExpr *E) {
Sam Weinigeb7f9612010-02-07 06:32:43 +00001040 VisitExpr(E);
1041 E->setValue(Record[Idx++]);
Sebastian Redlc3632732010-10-05 15:59:54 +00001042 E->setLocation(ReadSourceLocation(Record, Idx));
Sam Weinigeb7f9612010-02-07 06:32:43 +00001043}
1044
Sebastian Redl60adf4a2010-08-18 23:56:52 +00001045void ASTStmtReader::VisitCXXNullPtrLiteralExpr(CXXNullPtrLiteralExpr *E) {
Sam Weinigeb7f9612010-02-07 06:32:43 +00001046 VisitExpr(E);
Sebastian Redlc3632732010-10-05 15:59:54 +00001047 E->setLocation(ReadSourceLocation(Record, Idx));
Sam Weinigeb7f9612010-02-07 06:32:43 +00001048}
1049
Sebastian Redl60adf4a2010-08-18 23:56:52 +00001050void ASTStmtReader::VisitCXXTypeidExpr(CXXTypeidExpr *E) {
Chris Lattner14ab24f2010-05-09 06:03:39 +00001051 VisitExpr(E);
Sebastian Redlc3632732010-10-05 15:59:54 +00001052 E->setSourceRange(ReadSourceRange(Record, Idx));
Chris Lattner14ab24f2010-05-09 06:03:39 +00001053 if (E->isTypeOperand()) { // typeid(int)
Sebastian Redl577d4792010-07-22 22:43:28 +00001054 E->setTypeOperandSourceInfo(
Sebastian Redlc3632732010-10-05 15:59:54 +00001055 GetTypeSourceInfo(Record, Idx));
Argyrios Kyrtzidis919e6932010-06-28 22:28:35 +00001056 return;
Chris Lattner14ab24f2010-05-09 06:03:39 +00001057 }
1058
1059 // typeid(42+2)
Argyrios Kyrtzidisd98a2ab2010-06-29 22:46:25 +00001060 E->setExprOperand(Reader.ReadSubExpr());
Chris Lattner14ab24f2010-05-09 06:03:39 +00001061}
Francois Pichet01b7c302010-09-08 12:20:18 +00001062void ASTStmtReader::VisitCXXUuidofExpr(CXXUuidofExpr *E) {
1063 VisitExpr(E);
Sebastian Redlc3632732010-10-05 15:59:54 +00001064 E->setSourceRange(ReadSourceRange(Record, Idx));
Francois Pichet01b7c302010-09-08 12:20:18 +00001065 if (E->isTypeOperand()) { // __uuidof(ComType)
1066 E->setTypeOperandSourceInfo(
Sebastian Redlc3632732010-10-05 15:59:54 +00001067 GetTypeSourceInfo(Record, Idx));
Francois Pichet01b7c302010-09-08 12:20:18 +00001068 return;
1069 }
1070
1071 // __uuidof(expr)
1072 E->setExprOperand(Reader.ReadSubExpr());
1073}
Chris Lattner14ab24f2010-05-09 06:03:39 +00001074
Sebastian Redl60adf4a2010-08-18 23:56:52 +00001075void ASTStmtReader::VisitCXXThisExpr(CXXThisExpr *E) {
Chris Lattner2fbdfcd2010-05-09 06:15:05 +00001076 VisitExpr(E);
Sebastian Redlc3632732010-10-05 15:59:54 +00001077 E->setLocation(ReadSourceLocation(Record, Idx));
Chris Lattner2fbdfcd2010-05-09 06:15:05 +00001078 E->setImplicit(Record[Idx++]);
Chris Lattner2fbdfcd2010-05-09 06:15:05 +00001079}
1080
Sebastian Redl60adf4a2010-08-18 23:56:52 +00001081void ASTStmtReader::VisitCXXThrowExpr(CXXThrowExpr *E) {
Chris Lattner2fbdfcd2010-05-09 06:15:05 +00001082 VisitExpr(E);
Sebastian Redlc3632732010-10-05 15:59:54 +00001083 E->setThrowLoc(ReadSourceLocation(Record, Idx));
Argyrios Kyrtzidisd98a2ab2010-06-29 22:46:25 +00001084 E->setSubExpr(Reader.ReadSubExpr());
Chris Lattner2fbdfcd2010-05-09 06:15:05 +00001085}
Chris Lattner14ab24f2010-05-09 06:03:39 +00001086
Sebastian Redl60adf4a2010-08-18 23:56:52 +00001087void ASTStmtReader::VisitCXXDefaultArgExpr(CXXDefaultArgExpr *E) {
Chris Lattner030854b2010-05-09 06:40:08 +00001088 VisitExpr(E);
Argyrios Kyrtzidis8a507332010-07-02 23:30:15 +00001089
1090 assert(Record[Idx] == E->Param.getInt() && "We messed up at creation ?");
1091 ++Idx; // HasOtherExprStored and SubExpr was handled during creation.
1092 E->Param.setPointer(cast<ParmVarDecl>(Reader.GetDecl(Record[Idx++])));
Sebastian Redlc3632732010-10-05 15:59:54 +00001093 E->Loc = ReadSourceLocation(Record, Idx);
Chris Lattnerd2598362010-05-10 00:25:06 +00001094}
1095
Sebastian Redl60adf4a2010-08-18 23:56:52 +00001096void ASTStmtReader::VisitCXXBindTemporaryExpr(CXXBindTemporaryExpr *E) {
Chris Lattnerd2598362010-05-10 00:25:06 +00001097 VisitExpr(E);
1098 E->setTemporary(Reader.ReadCXXTemporary(Record, Idx));
Argyrios Kyrtzidisd98a2ab2010-06-29 22:46:25 +00001099 E->setSubExpr(Reader.ReadSubExpr());
Chris Lattnerd2598362010-05-10 00:25:06 +00001100}
1101
Sebastian Redl60adf4a2010-08-18 23:56:52 +00001102void ASTStmtReader::VisitCXXScalarValueInitExpr(CXXScalarValueInitExpr *E) {
Chris Lattner59218632010-05-10 01:22:27 +00001103 VisitExpr(E);
Sebastian Redlc3632732010-10-05 15:59:54 +00001104 E->TypeInfo = GetTypeSourceInfo(Record, Idx);
1105 E->RParenLoc = ReadSourceLocation(Record, Idx);
Chris Lattner59218632010-05-10 01:22:27 +00001106}
1107
Sebastian Redl60adf4a2010-08-18 23:56:52 +00001108void ASTStmtReader::VisitCXXNewExpr(CXXNewExpr *E) {
Chris Lattner59218632010-05-10 01:22:27 +00001109 VisitExpr(E);
1110 E->setGlobalNew(Record[Idx++]);
Chris Lattner59218632010-05-10 01:22:27 +00001111 E->setHasInitializer(Record[Idx++]);
1112 bool isArray = Record[Idx++];
1113 unsigned NumPlacementArgs = Record[Idx++];
1114 unsigned NumCtorArgs = Record[Idx++];
1115 E->setOperatorNew(cast_or_null<FunctionDecl>(Reader.GetDecl(Record[Idx++])));
1116 E->setOperatorDelete(
1117 cast_or_null<FunctionDecl>(Reader.GetDecl(Record[Idx++])));
1118 E->setConstructor(
1119 cast_or_null<CXXConstructorDecl>(Reader.GetDecl(Record[Idx++])));
Sebastian Redlc3632732010-10-05 15:59:54 +00001120 E->AllocatedTypeInfo = GetTypeSourceInfo(Record, Idx);
Douglas Gregor4bd40312010-07-13 15:54:32 +00001121 SourceRange TypeIdParens;
Sebastian Redlc3632732010-10-05 15:59:54 +00001122 TypeIdParens.setBegin(ReadSourceLocation(Record, Idx));
1123 TypeIdParens.setEnd(ReadSourceLocation(Record, Idx));
Douglas Gregor4bd40312010-07-13 15:54:32 +00001124 E->TypeIdParens = TypeIdParens;
Sebastian Redlc3632732010-10-05 15:59:54 +00001125 E->setStartLoc(ReadSourceLocation(Record, Idx));
1126 E->setEndLoc(ReadSourceLocation(Record, Idx));
Chris Lattner59218632010-05-10 01:22:27 +00001127
1128 E->AllocateArgsArray(*Reader.getContext(), isArray, NumPlacementArgs,
1129 NumCtorArgs);
1130
1131 // Install all the subexpressions.
Chris Lattner59218632010-05-10 01:22:27 +00001132 for (CXXNewExpr::raw_arg_iterator I = E->raw_arg_begin(),e = E->raw_arg_end();
1133 I != e; ++I)
Argyrios Kyrtzidisd98a2ab2010-06-29 22:46:25 +00001134 *I = Reader.ReadSubStmt();
Chris Lattner59218632010-05-10 01:22:27 +00001135}
1136
Sebastian Redl60adf4a2010-08-18 23:56:52 +00001137void ASTStmtReader::VisitCXXDeleteExpr(CXXDeleteExpr *E) {
Argyrios Kyrtzidis95fc98c2010-06-22 17:07:59 +00001138 VisitExpr(E);
Argyrios Kyrtzidisf1b89112010-09-13 20:15:40 +00001139 E->GlobalDelete = Record[Idx++];
1140 E->ArrayForm = Record[Idx++];
Argyrios Kyrtzidis4076dac2010-09-13 20:15:54 +00001141 E->ArrayFormAsWritten = Record[Idx++];
Argyrios Kyrtzidisf1b89112010-09-13 20:15:40 +00001142 E->OperatorDelete = cast_or_null<FunctionDecl>(Reader.GetDecl(Record[Idx++]));
1143 E->Argument = Reader.ReadSubExpr();
Sebastian Redlc3632732010-10-05 15:59:54 +00001144 E->Loc = ReadSourceLocation(Record, Idx);
Argyrios Kyrtzidis95fc98c2010-06-22 17:07:59 +00001145}
Chris Lattnerd2598362010-05-10 00:25:06 +00001146
Sebastian Redl60adf4a2010-08-18 23:56:52 +00001147void ASTStmtReader::VisitCXXPseudoDestructorExpr(CXXPseudoDestructorExpr *E) {
Argyrios Kyrtzidisde4bd182010-06-28 09:32:03 +00001148 VisitExpr(E);
1149
Argyrios Kyrtzidisd98a2ab2010-06-29 22:46:25 +00001150 E->setBase(Reader.ReadSubExpr());
Argyrios Kyrtzidisde4bd182010-06-28 09:32:03 +00001151 E->setArrow(Record[Idx++]);
Sebastian Redlc3632732010-10-05 15:59:54 +00001152 E->setOperatorLoc(ReadSourceLocation(Record, Idx));
Argyrios Kyrtzidisde4bd182010-06-28 09:32:03 +00001153 E->setQualifier(Reader.ReadNestedNameSpecifier(Record, Idx));
Sebastian Redlc3632732010-10-05 15:59:54 +00001154 E->setQualifierRange(ReadSourceRange(Record, Idx));
1155 E->setScopeTypeInfo(GetTypeSourceInfo(Record, Idx));
1156 E->setColonColonLoc(ReadSourceLocation(Record, Idx));
1157 E->setTildeLoc(ReadSourceLocation(Record, Idx));
Argyrios Kyrtzidisde4bd182010-06-28 09:32:03 +00001158
1159 IdentifierInfo *II = Reader.GetIdentifierInfo(Record, Idx);
1160 if (II)
Sebastian Redlc3632732010-10-05 15:59:54 +00001161 E->setDestroyedType(II, ReadSourceLocation(Record, Idx));
Argyrios Kyrtzidisde4bd182010-06-28 09:32:03 +00001162 else
Sebastian Redlc3632732010-10-05 15:59:54 +00001163 E->setDestroyedType(GetTypeSourceInfo(Record, Idx));
Argyrios Kyrtzidisde4bd182010-06-28 09:32:03 +00001164}
1165
Sebastian Redl60adf4a2010-08-18 23:56:52 +00001166void ASTStmtReader::VisitCXXExprWithTemporaries(CXXExprWithTemporaries *E) {
Chris Lattnerd2598362010-05-10 00:25:06 +00001167 VisitExpr(E);
1168 unsigned NumTemps = Record[Idx++];
1169 if (NumTemps) {
Ted Kremenekd04ed412010-05-10 20:06:30 +00001170 E->setNumTemporaries(*Reader.getContext(), NumTemps);
Chris Lattnerd2598362010-05-10 00:25:06 +00001171 for (unsigned i = 0; i != NumTemps; ++i)
1172 E->setTemporary(i, Reader.ReadCXXTemporary(Record, Idx));
1173 }
Argyrios Kyrtzidisd98a2ab2010-06-29 22:46:25 +00001174 E->setSubExpr(Reader.ReadSubExpr());
Chris Lattner030854b2010-05-09 06:40:08 +00001175}
1176
Argyrios Kyrtzidis919e6932010-06-28 22:28:35 +00001177void
Sebastian Redl60adf4a2010-08-18 23:56:52 +00001178ASTStmtReader::VisitCXXDependentScopeMemberExpr(CXXDependentScopeMemberExpr *E){
Argyrios Kyrtzidis8dfbd8b2010-06-24 08:57:31 +00001179 VisitExpr(E);
1180
1181 unsigned NumTemplateArgs = Record[Idx++];
1182 assert((NumTemplateArgs != 0) == E->hasExplicitTemplateArgs() &&
1183 "Read wrong record during creation ?");
Argyrios Kyrtzidis36c76f02010-06-28 09:31:48 +00001184 if (E->hasExplicitTemplateArgs())
John McCall096832c2010-08-19 23:49:38 +00001185 ReadExplicitTemplateArgumentList(E->getExplicitTemplateArgs(),
Argyrios Kyrtzidis919e6932010-06-28 22:28:35 +00001186 NumTemplateArgs);
Argyrios Kyrtzidis8dfbd8b2010-06-24 08:57:31 +00001187
Argyrios Kyrtzidisd98a2ab2010-06-29 22:46:25 +00001188 E->setBase(Reader.ReadSubExpr());
Argyrios Kyrtzidis8dfbd8b2010-06-24 08:57:31 +00001189 E->setBaseType(Reader.GetType(Record[Idx++]));
1190 E->setArrow(Record[Idx++]);
Sebastian Redlc3632732010-10-05 15:59:54 +00001191 E->setOperatorLoc(ReadSourceLocation(Record, Idx));
Argyrios Kyrtzidis8dfbd8b2010-06-24 08:57:31 +00001192 E->setQualifier(Reader.ReadNestedNameSpecifier(Record, Idx));
Sebastian Redlc3632732010-10-05 15:59:54 +00001193 E->setQualifierRange(ReadSourceRange(Record, Idx));
Argyrios Kyrtzidis8dfbd8b2010-06-24 08:57:31 +00001194 E->setFirstQualifierFoundInScope(
1195 cast_or_null<NamedDecl>(Reader.GetDecl(Record[Idx++])));
Argyrios Kyrtzidis40451072010-10-15 18:21:24 +00001196 ReadDeclarationNameInfo(E->MemberNameInfo, Record, Idx);
Argyrios Kyrtzidis8dfbd8b2010-06-24 08:57:31 +00001197}
1198
Argyrios Kyrtzidis919e6932010-06-28 22:28:35 +00001199void
Sebastian Redl60adf4a2010-08-18 23:56:52 +00001200ASTStmtReader::VisitDependentScopeDeclRefExpr(DependentScopeDeclRefExpr *E) {
Argyrios Kyrtzidis12dffcd2010-06-28 09:31:56 +00001201 VisitExpr(E);
Argyrios Kyrtzidis12dffcd2010-06-28 09:31:56 +00001202
1203 unsigned NumTemplateArgs = Record[Idx++];
1204 assert((NumTemplateArgs != 0) == E->hasExplicitTemplateArgs() &&
1205 "Read wrong record during creation ?");
1206 if (E->hasExplicitTemplateArgs())
Argyrios Kyrtzidis919e6932010-06-28 22:28:35 +00001207 ReadExplicitTemplateArgumentList(E->getExplicitTemplateArgs(),
1208 NumTemplateArgs);
Argyrios Kyrtzidis12dffcd2010-06-28 09:31:56 +00001209
Argyrios Kyrtzidis40451072010-10-15 18:21:24 +00001210 ReadDeclarationNameInfo(E->NameInfo, Record, Idx);
Sebastian Redlc3632732010-10-05 15:59:54 +00001211 E->setQualifierRange(ReadSourceRange(Record, Idx));
Argyrios Kyrtzidis12dffcd2010-06-28 09:31:56 +00001212 E->setQualifier(Reader.ReadNestedNameSpecifier(Record, Idx));
Argyrios Kyrtzidis12dffcd2010-06-28 09:31:56 +00001213}
1214
Argyrios Kyrtzidis919e6932010-06-28 22:28:35 +00001215void
Sebastian Redl60adf4a2010-08-18 23:56:52 +00001216ASTStmtReader::VisitCXXUnresolvedConstructExpr(CXXUnresolvedConstructExpr *E) {
Argyrios Kyrtzidis8dfbd8b2010-06-24 08:57:31 +00001217 VisitExpr(E);
1218 assert(Record[Idx] == E->arg_size() && "Read wrong record during creation ?");
1219 ++Idx; // NumArgs;
1220 for (unsigned I = 0, N = E->arg_size(); I != N; ++I)
Argyrios Kyrtzidisd98a2ab2010-06-29 22:46:25 +00001221 E->setArg(I, Reader.ReadSubExpr());
Sebastian Redlc3632732010-10-05 15:59:54 +00001222 E->Type = GetTypeSourceInfo(Record, Idx);
1223 E->setLParenLoc(ReadSourceLocation(Record, Idx));
1224 E->setRParenLoc(ReadSourceLocation(Record, Idx));
Argyrios Kyrtzidis8dfbd8b2010-06-24 08:57:31 +00001225}
1226
Sebastian Redl60adf4a2010-08-18 23:56:52 +00001227void ASTStmtReader::VisitOverloadExpr(OverloadExpr *E) {
Argyrios Kyrtzidisa77eb082010-06-25 09:03:26 +00001228 VisitExpr(E);
1229
1230 unsigned NumTemplateArgs = Record[Idx++];
1231 assert((NumTemplateArgs != 0) == E->hasExplicitTemplateArgs() &&
1232 "Read wrong record during creation ?");
Argyrios Kyrtzidis919e6932010-06-28 22:28:35 +00001233 if (E->hasExplicitTemplateArgs())
1234 ReadExplicitTemplateArgumentList(E->getExplicitTemplateArgs(),
1235 NumTemplateArgs);
Argyrios Kyrtzidisa77eb082010-06-25 09:03:26 +00001236
1237 unsigned NumDecls = Record[Idx++];
1238 UnresolvedSet<8> Decls;
1239 for (unsigned i = 0; i != NumDecls; ++i) {
1240 NamedDecl *D = cast<NamedDecl>(Reader.GetDecl(Record[Idx++]));
1241 AccessSpecifier AS = (AccessSpecifier)Record[Idx++];
1242 Decls.addDecl(D, AS);
1243 }
1244 E->initializeResults(*Reader.getContext(), Decls.begin(), Decls.end());
1245
Argyrios Kyrtzidis40451072010-10-15 18:21:24 +00001246 ReadDeclarationNameInfo(E->NameInfo, Record, Idx);
Argyrios Kyrtzidisa77eb082010-06-25 09:03:26 +00001247 E->setQualifier(Reader.ReadNestedNameSpecifier(Record, Idx));
Sebastian Redlc3632732010-10-05 15:59:54 +00001248 E->setQualifierRange(ReadSourceRange(Record, Idx));
Argyrios Kyrtzidisa77eb082010-06-25 09:03:26 +00001249}
1250
Sebastian Redl60adf4a2010-08-18 23:56:52 +00001251void ASTStmtReader::VisitUnresolvedMemberExpr(UnresolvedMemberExpr *E) {
Argyrios Kyrtzidis919e6932010-06-28 22:28:35 +00001252 VisitOverloadExpr(E);
Argyrios Kyrtzidisa77eb082010-06-25 09:03:26 +00001253 E->setArrow(Record[Idx++]);
1254 E->setHasUnresolvedUsing(Record[Idx++]);
Argyrios Kyrtzidisd98a2ab2010-06-29 22:46:25 +00001255 E->setBase(Reader.ReadSubExpr());
Argyrios Kyrtzidisa77eb082010-06-25 09:03:26 +00001256 E->setBaseType(Reader.GetType(Record[Idx++]));
Sebastian Redlc3632732010-10-05 15:59:54 +00001257 E->setOperatorLoc(ReadSourceLocation(Record, Idx));
Argyrios Kyrtzidisa77eb082010-06-25 09:03:26 +00001258}
1259
Sebastian Redl60adf4a2010-08-18 23:56:52 +00001260void ASTStmtReader::VisitUnresolvedLookupExpr(UnresolvedLookupExpr *E) {
Argyrios Kyrtzidis919e6932010-06-28 22:28:35 +00001261 VisitOverloadExpr(E);
Argyrios Kyrtzidisbd65bb52010-06-25 09:03:34 +00001262 E->setRequiresADL(Record[Idx++]);
1263 E->setOverloaded(Record[Idx++]);
1264 E->setNamingClass(cast_or_null<CXXRecordDecl>(Reader.GetDecl(Record[Idx++])));
Argyrios Kyrtzidisbd65bb52010-06-25 09:03:34 +00001265}
1266
Sebastian Redl60adf4a2010-08-18 23:56:52 +00001267void ASTStmtReader::VisitUnaryTypeTraitExpr(UnaryTypeTraitExpr *E) {
Argyrios Kyrtzidis6d00c132010-07-10 11:46:15 +00001268 VisitExpr(E);
1269 E->UTT = (UnaryTypeTrait)Record[Idx++];
Sebastian Redl0dfd8482010-09-13 20:56:31 +00001270 E->Value = (bool)Record[Idx++];
Sebastian Redlc3632732010-10-05 15:59:54 +00001271 SourceRange Range = ReadSourceRange(Record, Idx);
Argyrios Kyrtzidis6d00c132010-07-10 11:46:15 +00001272 E->Loc = Range.getBegin();
1273 E->RParen = Range.getEnd();
Sebastian Redlc3632732010-10-05 15:59:54 +00001274 E->QueriedType = GetTypeSourceInfo(Record, Idx);
Argyrios Kyrtzidis6d00c132010-07-10 11:46:15 +00001275}
1276
Sebastian Redl6b219d02010-09-10 20:55:54 +00001277void ASTStmtReader::VisitCXXNoexceptExpr(CXXNoexceptExpr *E) {
1278 VisitExpr(E);
Sebastian Redl5221d8f2010-09-10 22:34:40 +00001279 E->Value = (bool)Record[Idx++];
Sebastian Redlc3632732010-10-05 15:59:54 +00001280 E->Range = ReadSourceRange(Record, Idx);
Sebastian Redl5221d8f2010-09-10 22:34:40 +00001281 E->Operand = Reader.ReadSubExpr();
Sebastian Redl6b219d02010-09-10 20:55:54 +00001282}
1283
Sebastian Redlc3632732010-10-05 15:59:54 +00001284Stmt *ASTReader::ReadStmt(PerFileData &F) {
Argyrios Kyrtzidis919e6932010-06-28 22:28:35 +00001285 switch (ReadingKind) {
1286 case Read_Decl:
1287 case Read_Type:
Sebastian Redlc3632732010-10-05 15:59:54 +00001288 return ReadStmtFromStream(F);
Argyrios Kyrtzidis919e6932010-06-28 22:28:35 +00001289 case Read_Stmt:
Argyrios Kyrtzidisd98a2ab2010-06-29 22:46:25 +00001290 return ReadSubStmt();
Argyrios Kyrtzidis919e6932010-06-28 22:28:35 +00001291 }
1292
1293 llvm_unreachable("ReadingKind not set ?");
1294 return 0;
1295}
1296
Sebastian Redlc3632732010-10-05 15:59:54 +00001297Expr *ASTReader::ReadExpr(PerFileData &F) {
1298 return cast_or_null<Expr>(ReadStmt(F));
Argyrios Kyrtzidis919e6932010-06-28 22:28:35 +00001299}
Chris Lattner030854b2010-05-09 06:40:08 +00001300
Sebastian Redlc43b54c2010-08-18 23:56:43 +00001301Expr *ASTReader::ReadSubExpr() {
Argyrios Kyrtzidisd98a2ab2010-06-29 22:46:25 +00001302 return cast_or_null<Expr>(ReadSubStmt());
1303}
1304
Chris Lattner52e97d12009-04-27 05:41:06 +00001305// Within the bitstream, expressions are stored in Reverse Polish
1306// Notation, with each of the subexpressions preceding the
Argyrios Kyrtzidis919e6932010-06-28 22:28:35 +00001307// expression they are stored in. Subexpressions are stored from last to first.
1308// To evaluate expressions, we continue reading expressions and placing them on
1309// the stack, with expressions having operands removing those operands from the
Chris Lattner52e97d12009-04-27 05:41:06 +00001310// stack. Evaluation terminates when we see a STMT_STOP record, and
1311// the single remaining expression on the stack is our result.
Sebastian Redlc3632732010-10-05 15:59:54 +00001312Stmt *ASTReader::ReadStmtFromStream(PerFileData &F) {
Argyrios Kyrtzidis919e6932010-06-28 22:28:35 +00001313
1314 ReadingKindTracker ReadingKind(Read_Stmt, *this);
Sebastian Redlc3632732010-10-05 15:59:54 +00001315 llvm::BitstreamCursor &Cursor = F.DeclsCursor;
1316
Argyrios Kyrtzidis919e6932010-06-28 22:28:35 +00001317#ifndef NDEBUG
1318 unsigned PrevNumStmts = StmtStack.size();
1319#endif
1320
Chris Lattner4c6f9522009-04-27 05:14:47 +00001321 RecordData Record;
1322 unsigned Idx;
Sebastian Redlc3632732010-10-05 15:59:54 +00001323 ASTStmtReader Reader(*this, F, Cursor, Record, Idx);
Chris Lattner4c6f9522009-04-27 05:14:47 +00001324 Stmt::EmptyShell Empty;
1325
1326 while (true) {
Chris Lattner52e97d12009-04-27 05:41:06 +00001327 unsigned Code = Cursor.ReadCode();
Chris Lattner4c6f9522009-04-27 05:14:47 +00001328 if (Code == llvm::bitc::END_BLOCK) {
Chris Lattner52e97d12009-04-27 05:41:06 +00001329 if (Cursor.ReadBlockEnd()) {
Sebastian Redl3c7f4132010-08-18 23:57:06 +00001330 Error("error at end of block in AST file");
Chris Lattner4c6f9522009-04-27 05:14:47 +00001331 return 0;
1332 }
1333 break;
1334 }
1335
1336 if (Code == llvm::bitc::ENTER_SUBBLOCK) {
1337 // No known subblocks, always skip them.
Chris Lattner52e97d12009-04-27 05:41:06 +00001338 Cursor.ReadSubBlockID();
1339 if (Cursor.SkipBlock()) {
Sebastian Redl3c7f4132010-08-18 23:57:06 +00001340 Error("malformed block record in AST file");
Chris Lattner4c6f9522009-04-27 05:14:47 +00001341 return 0;
1342 }
1343 continue;
1344 }
1345
1346 if (Code == llvm::bitc::DEFINE_ABBREV) {
Chris Lattner52e97d12009-04-27 05:41:06 +00001347 Cursor.ReadAbbrevRecord();
Chris Lattner4c6f9522009-04-27 05:14:47 +00001348 continue;
1349 }
1350
1351 Stmt *S = 0;
1352 Idx = 0;
1353 Record.clear();
1354 bool Finished = false;
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001355 switch ((StmtCode)Cursor.ReadRecord(Code, Record)) {
1356 case STMT_STOP:
Chris Lattner4c6f9522009-04-27 05:14:47 +00001357 Finished = true;
1358 break;
1359
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001360 case STMT_NULL_PTR:
Mike Stump1eb44332009-09-09 15:08:12 +00001361 S = 0;
Chris Lattner4c6f9522009-04-27 05:14:47 +00001362 break;
1363
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001364 case STMT_NULL:
Chris Lattner4c6f9522009-04-27 05:14:47 +00001365 S = new (Context) NullStmt(Empty);
1366 break;
1367
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001368 case STMT_COMPOUND:
Chris Lattner4c6f9522009-04-27 05:14:47 +00001369 S = new (Context) CompoundStmt(Empty);
1370 break;
1371
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001372 case STMT_CASE:
Chris Lattner4c6f9522009-04-27 05:14:47 +00001373 S = new (Context) CaseStmt(Empty);
1374 break;
1375
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001376 case STMT_DEFAULT:
Chris Lattner4c6f9522009-04-27 05:14:47 +00001377 S = new (Context) DefaultStmt(Empty);
1378 break;
1379
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001380 case STMT_LABEL:
Chris Lattner4c6f9522009-04-27 05:14:47 +00001381 S = new (Context) LabelStmt(Empty);
1382 break;
1383
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001384 case STMT_IF:
Chris Lattner4c6f9522009-04-27 05:14:47 +00001385 S = new (Context) IfStmt(Empty);
1386 break;
1387
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001388 case STMT_SWITCH:
Chris Lattner4c6f9522009-04-27 05:14:47 +00001389 S = new (Context) SwitchStmt(Empty);
1390 break;
1391
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001392 case STMT_WHILE:
Chris Lattner4c6f9522009-04-27 05:14:47 +00001393 S = new (Context) WhileStmt(Empty);
1394 break;
1395
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001396 case STMT_DO:
Chris Lattner4c6f9522009-04-27 05:14:47 +00001397 S = new (Context) DoStmt(Empty);
1398 break;
Mike Stump1eb44332009-09-09 15:08:12 +00001399
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001400 case STMT_FOR:
Chris Lattner4c6f9522009-04-27 05:14:47 +00001401 S = new (Context) ForStmt(Empty);
1402 break;
1403
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001404 case STMT_GOTO:
Chris Lattner4c6f9522009-04-27 05:14:47 +00001405 S = new (Context) GotoStmt(Empty);
1406 break;
Mike Stump1eb44332009-09-09 15:08:12 +00001407
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001408 case STMT_INDIRECT_GOTO:
Chris Lattner4c6f9522009-04-27 05:14:47 +00001409 S = new (Context) IndirectGotoStmt(Empty);
1410 break;
1411
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001412 case STMT_CONTINUE:
Chris Lattner4c6f9522009-04-27 05:14:47 +00001413 S = new (Context) ContinueStmt(Empty);
1414 break;
1415
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001416 case STMT_BREAK:
Chris Lattner4c6f9522009-04-27 05:14:47 +00001417 S = new (Context) BreakStmt(Empty);
1418 break;
1419
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001420 case STMT_RETURN:
Chris Lattner4c6f9522009-04-27 05:14:47 +00001421 S = new (Context) ReturnStmt(Empty);
1422 break;
1423
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001424 case STMT_DECL:
Chris Lattner4c6f9522009-04-27 05:14:47 +00001425 S = new (Context) DeclStmt(Empty);
1426 break;
1427
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001428 case STMT_ASM:
Chris Lattner4c6f9522009-04-27 05:14:47 +00001429 S = new (Context) AsmStmt(Empty);
1430 break;
1431
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001432 case EXPR_PREDEFINED:
Chris Lattner4c6f9522009-04-27 05:14:47 +00001433 S = new (Context) PredefinedExpr(Empty);
1434 break;
Mike Stump1eb44332009-09-09 15:08:12 +00001435
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001436 case EXPR_DECL_REF:
Argyrios Kyrtzidis663e3802010-07-08 13:09:47 +00001437 S = DeclRefExpr::CreateEmpty(*Context,
Sebastian Redl60adf4a2010-08-18 23:56:52 +00001438 /*HasQualifier=*/Record[ASTStmtReader::NumExprFields],
1439 /*NumTemplateArgs=*/Record[ASTStmtReader::NumExprFields + 1]);
Chris Lattner4c6f9522009-04-27 05:14:47 +00001440 break;
Mike Stump1eb44332009-09-09 15:08:12 +00001441
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001442 case EXPR_INTEGER_LITERAL:
Argyrios Kyrtzidis9996a7f2010-08-28 09:06:06 +00001443 S = IntegerLiteral::Create(*Context, Empty);
Chris Lattner4c6f9522009-04-27 05:14:47 +00001444 break;
Mike Stump1eb44332009-09-09 15:08:12 +00001445
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001446 case EXPR_FLOATING_LITERAL:
Argyrios Kyrtzidis9996a7f2010-08-28 09:06:06 +00001447 S = FloatingLiteral::Create(*Context, Empty);
Chris Lattner4c6f9522009-04-27 05:14:47 +00001448 break;
Mike Stump1eb44332009-09-09 15:08:12 +00001449
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001450 case EXPR_IMAGINARY_LITERAL:
Chris Lattner4c6f9522009-04-27 05:14:47 +00001451 S = new (Context) ImaginaryLiteral(Empty);
1452 break;
1453
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001454 case EXPR_STRING_LITERAL:
Mike Stump1eb44332009-09-09 15:08:12 +00001455 S = StringLiteral::CreateEmpty(*Context,
Sebastian Redl60adf4a2010-08-18 23:56:52 +00001456 Record[ASTStmtReader::NumExprFields + 1]);
Chris Lattner4c6f9522009-04-27 05:14:47 +00001457 break;
1458
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001459 case EXPR_CHARACTER_LITERAL:
Chris Lattner4c6f9522009-04-27 05:14:47 +00001460 S = new (Context) CharacterLiteral(Empty);
1461 break;
1462
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001463 case EXPR_PAREN:
Chris Lattner4c6f9522009-04-27 05:14:47 +00001464 S = new (Context) ParenExpr(Empty);
1465 break;
1466
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001467 case EXPR_PAREN_LIST:
Argyrios Kyrtzidis37bdfe22010-06-30 08:49:18 +00001468 S = new (Context) ParenListExpr(Empty);
1469 break;
1470
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001471 case EXPR_UNARY_OPERATOR:
Chris Lattner4c6f9522009-04-27 05:14:47 +00001472 S = new (Context) UnaryOperator(Empty);
1473 break;
1474
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001475 case EXPR_OFFSETOF:
Douglas Gregor8ecdb652010-04-28 22:16:22 +00001476 S = OffsetOfExpr::CreateEmpty(*Context,
Sebastian Redl60adf4a2010-08-18 23:56:52 +00001477 Record[ASTStmtReader::NumExprFields],
1478 Record[ASTStmtReader::NumExprFields + 1]);
Douglas Gregor8ecdb652010-04-28 22:16:22 +00001479 break;
1480
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001481 case EXPR_SIZEOF_ALIGN_OF:
Chris Lattner4c6f9522009-04-27 05:14:47 +00001482 S = new (Context) SizeOfAlignOfExpr(Empty);
1483 break;
1484
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001485 case EXPR_ARRAY_SUBSCRIPT:
Chris Lattner4c6f9522009-04-27 05:14:47 +00001486 S = new (Context) ArraySubscriptExpr(Empty);
1487 break;
1488
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001489 case EXPR_CALL:
Argyrios Kyrtzidisba0a9002009-07-14 03:19:21 +00001490 S = new (Context) CallExpr(*Context, Stmt::CallExprClass, Empty);
Chris Lattner4c6f9522009-04-27 05:14:47 +00001491 break;
1492
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001493 case EXPR_MEMBER: {
Argyrios Kyrtzidis663e3802010-07-08 13:09:47 +00001494 // We load everything here and fully initialize it at creation.
1495 // That way we can use MemberExpr::Create and don't have to duplicate its
1496 // logic with a MemberExpr::CreateEmpty.
1497
1498 assert(Idx == 0);
1499 NestedNameSpecifier *NNS = 0;
1500 SourceRange QualifierRange;
1501 if (Record[Idx++]) { // HasQualifier.
1502 NNS = ReadNestedNameSpecifier(Record, Idx);
Sebastian Redlc3632732010-10-05 15:59:54 +00001503 QualifierRange = ReadSourceRange(F, Record, Idx);
Argyrios Kyrtzidis663e3802010-07-08 13:09:47 +00001504 }
1505
1506 TemplateArgumentListInfo ArgInfo;
1507 unsigned NumTemplateArgs = Record[Idx++];
1508 if (NumTemplateArgs) {
Sebastian Redlc3632732010-10-05 15:59:54 +00001509 ArgInfo.setLAngleLoc(ReadSourceLocation(F, Record, Idx));
1510 ArgInfo.setRAngleLoc(ReadSourceLocation(F, Record, Idx));
Argyrios Kyrtzidis663e3802010-07-08 13:09:47 +00001511 for (unsigned i = 0; i != NumTemplateArgs; ++i)
Sebastian Redlc3632732010-10-05 15:59:54 +00001512 ArgInfo.addArgument(ReadTemplateArgumentLoc(F, Record, Idx));
Argyrios Kyrtzidis663e3802010-07-08 13:09:47 +00001513 }
1514
1515 NamedDecl *FoundD = cast_or_null<NamedDecl>(GetDecl(Record[Idx++]));
1516 AccessSpecifier AS = (AccessSpecifier)Record[Idx++];
1517 DeclAccessPair FoundDecl = DeclAccessPair::make(FoundD, AS);
1518
1519 QualType T = GetType(Record[Idx++]);
1520 Expr *Base = ReadSubExpr();
1521 ValueDecl *MemberD = cast<ValueDecl>(GetDecl(Record[Idx++]));
Sebastian Redlc3632732010-10-05 15:59:54 +00001522 SourceLocation MemberLoc = ReadSourceLocation(F, Record, Idx);
Abramo Bagnara25777432010-08-11 22:01:17 +00001523 DeclarationNameInfo MemberNameInfo(MemberD->getDeclName(), MemberLoc);
Argyrios Kyrtzidis663e3802010-07-08 13:09:47 +00001524 bool IsArrow = Record[Idx++];
1525
1526 S = MemberExpr::Create(*Context, Base, IsArrow, NNS, QualifierRange,
Abramo Bagnara25777432010-08-11 22:01:17 +00001527 MemberD, FoundDecl, MemberNameInfo,
Argyrios Kyrtzidis663e3802010-07-08 13:09:47 +00001528 NumTemplateArgs ? &ArgInfo : 0, T);
Argyrios Kyrtzidis40451072010-10-15 18:21:24 +00001529 ReadDeclarationNameLoc(F, cast<MemberExpr>(S)->MemberDNLoc,
1530 MemberD->getDeclName(), Record, Idx);
Chris Lattner4c6f9522009-04-27 05:14:47 +00001531 break;
Argyrios Kyrtzidis663e3802010-07-08 13:09:47 +00001532 }
Chris Lattner4c6f9522009-04-27 05:14:47 +00001533
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001534 case EXPR_BINARY_OPERATOR:
Chris Lattner4c6f9522009-04-27 05:14:47 +00001535 S = new (Context) BinaryOperator(Empty);
1536 break;
1537
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001538 case EXPR_COMPOUND_ASSIGN_OPERATOR:
Chris Lattner4c6f9522009-04-27 05:14:47 +00001539 S = new (Context) CompoundAssignOperator(Empty);
1540 break;
1541
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001542 case EXPR_CONDITIONAL_OPERATOR:
Chris Lattner4c6f9522009-04-27 05:14:47 +00001543 S = new (Context) ConditionalOperator(Empty);
1544 break;
1545
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001546 case EXPR_IMPLICIT_CAST:
John McCallf871d0c2010-08-07 06:22:56 +00001547 S = ImplicitCastExpr::CreateEmpty(*Context,
Sebastian Redl60adf4a2010-08-18 23:56:52 +00001548 /*PathSize*/ Record[ASTStmtReader::NumExprFields]);
Chris Lattner4c6f9522009-04-27 05:14:47 +00001549 break;
1550
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001551 case EXPR_CSTYLE_CAST:
John McCallf871d0c2010-08-07 06:22:56 +00001552 S = CStyleCastExpr::CreateEmpty(*Context,
Sebastian Redl60adf4a2010-08-18 23:56:52 +00001553 /*PathSize*/ Record[ASTStmtReader::NumExprFields]);
Chris Lattner4c6f9522009-04-27 05:14:47 +00001554 break;
1555
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001556 case EXPR_COMPOUND_LITERAL:
Chris Lattner4c6f9522009-04-27 05:14:47 +00001557 S = new (Context) CompoundLiteralExpr(Empty);
1558 break;
1559
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001560 case EXPR_EXT_VECTOR_ELEMENT:
Chris Lattner4c6f9522009-04-27 05:14:47 +00001561 S = new (Context) ExtVectorElementExpr(Empty);
1562 break;
1563
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001564 case EXPR_INIT_LIST:
Ted Kremenek709210f2010-04-13 23:39:13 +00001565 S = new (Context) InitListExpr(*getContext(), Empty);
Chris Lattner4c6f9522009-04-27 05:14:47 +00001566 break;
1567
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001568 case EXPR_DESIGNATED_INIT:
Chris Lattnerd1d64a02009-04-27 21:45:14 +00001569 S = DesignatedInitExpr::CreateEmpty(*Context,
Sebastian Redl60adf4a2010-08-18 23:56:52 +00001570 Record[ASTStmtReader::NumExprFields] - 1);
Mike Stump1eb44332009-09-09 15:08:12 +00001571
Chris Lattner4c6f9522009-04-27 05:14:47 +00001572 break;
1573
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001574 case EXPR_IMPLICIT_VALUE_INIT:
Chris Lattner4c6f9522009-04-27 05:14:47 +00001575 S = new (Context) ImplicitValueInitExpr(Empty);
1576 break;
1577
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001578 case EXPR_VA_ARG:
Chris Lattner4c6f9522009-04-27 05:14:47 +00001579 S = new (Context) VAArgExpr(Empty);
1580 break;
1581
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001582 case EXPR_ADDR_LABEL:
Chris Lattner4c6f9522009-04-27 05:14:47 +00001583 S = new (Context) AddrLabelExpr(Empty);
1584 break;
1585
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001586 case EXPR_STMT:
Chris Lattner4c6f9522009-04-27 05:14:47 +00001587 S = new (Context) StmtExpr(Empty);
1588 break;
1589
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001590 case EXPR_TYPES_COMPATIBLE:
Chris Lattner4c6f9522009-04-27 05:14:47 +00001591 S = new (Context) TypesCompatibleExpr(Empty);
1592 break;
1593
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001594 case EXPR_CHOOSE:
Chris Lattner4c6f9522009-04-27 05:14:47 +00001595 S = new (Context) ChooseExpr(Empty);
1596 break;
1597
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001598 case EXPR_GNU_NULL:
Chris Lattner4c6f9522009-04-27 05:14:47 +00001599 S = new (Context) GNUNullExpr(Empty);
1600 break;
1601
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001602 case EXPR_SHUFFLE_VECTOR:
Chris Lattner4c6f9522009-04-27 05:14:47 +00001603 S = new (Context) ShuffleVectorExpr(Empty);
1604 break;
Mike Stump1eb44332009-09-09 15:08:12 +00001605
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001606 case EXPR_BLOCK:
Chris Lattner4c6f9522009-04-27 05:14:47 +00001607 S = new (Context) BlockExpr(Empty);
1608 break;
1609
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001610 case EXPR_BLOCK_DECL_REF:
Chris Lattner4c6f9522009-04-27 05:14:47 +00001611 S = new (Context) BlockDeclRefExpr(Empty);
1612 break;
Mike Stump1eb44332009-09-09 15:08:12 +00001613
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001614 case EXPR_OBJC_STRING_LITERAL:
Chris Lattner4c6f9522009-04-27 05:14:47 +00001615 S = new (Context) ObjCStringLiteral(Empty);
1616 break;
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001617 case EXPR_OBJC_ENCODE:
Chris Lattner4c6f9522009-04-27 05:14:47 +00001618 S = new (Context) ObjCEncodeExpr(Empty);
1619 break;
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001620 case EXPR_OBJC_SELECTOR_EXPR:
Chris Lattner4c6f9522009-04-27 05:14:47 +00001621 S = new (Context) ObjCSelectorExpr(Empty);
1622 break;
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001623 case EXPR_OBJC_PROTOCOL_EXPR:
Chris Lattner4c6f9522009-04-27 05:14:47 +00001624 S = new (Context) ObjCProtocolExpr(Empty);
1625 break;
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001626 case EXPR_OBJC_IVAR_REF_EXPR:
Chris Lattner4c6f9522009-04-27 05:14:47 +00001627 S = new (Context) ObjCIvarRefExpr(Empty);
1628 break;
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001629 case EXPR_OBJC_PROPERTY_REF_EXPR:
Chris Lattner4c6f9522009-04-27 05:14:47 +00001630 S = new (Context) ObjCPropertyRefExpr(Empty);
1631 break;
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001632 case EXPR_OBJC_KVC_REF_EXPR:
Fariborz Jahanian09105f52009-08-20 17:02:02 +00001633 S = new (Context) ObjCImplicitSetterGetterRefExpr(Empty);
Chris Lattner4c6f9522009-04-27 05:14:47 +00001634 break;
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001635 case EXPR_OBJC_MESSAGE_EXPR:
Douglas Gregor04badcf2010-04-21 00:45:42 +00001636 S = ObjCMessageExpr::CreateEmpty(*Context,
Sebastian Redl60adf4a2010-08-18 23:56:52 +00001637 Record[ASTStmtReader::NumExprFields]);
Chris Lattner4c6f9522009-04-27 05:14:47 +00001638 break;
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001639 case EXPR_OBJC_ISA:
Steve Narofff242b1b2009-07-24 17:54:45 +00001640 S = new (Context) ObjCIsaExpr(Empty);
1641 break;
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001642 case STMT_OBJC_FOR_COLLECTION:
Chris Lattner4c6f9522009-04-27 05:14:47 +00001643 S = new (Context) ObjCForCollectionStmt(Empty);
1644 break;
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001645 case STMT_OBJC_CATCH:
Chris Lattner4c6f9522009-04-27 05:14:47 +00001646 S = new (Context) ObjCAtCatchStmt(Empty);
1647 break;
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001648 case STMT_OBJC_FINALLY:
Chris Lattner4c6f9522009-04-27 05:14:47 +00001649 S = new (Context) ObjCAtFinallyStmt(Empty);
1650 break;
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001651 case STMT_OBJC_AT_TRY:
Douglas Gregor8f5e3dd2010-04-23 22:50:49 +00001652 S = ObjCAtTryStmt::CreateEmpty(*Context,
Sebastian Redl60adf4a2010-08-18 23:56:52 +00001653 Record[ASTStmtReader::NumStmtFields],
1654 Record[ASTStmtReader::NumStmtFields + 1]);
Chris Lattner4c6f9522009-04-27 05:14:47 +00001655 break;
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001656 case STMT_OBJC_AT_SYNCHRONIZED:
Chris Lattner4c6f9522009-04-27 05:14:47 +00001657 S = new (Context) ObjCAtSynchronizedStmt(Empty);
1658 break;
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001659 case STMT_OBJC_AT_THROW:
Chris Lattner4c6f9522009-04-27 05:14:47 +00001660 S = new (Context) ObjCAtThrowStmt(Empty);
1661 break;
Mike Stump1eb44332009-09-09 15:08:12 +00001662
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001663 case STMT_CXX_CATCH:
Argyrios Kyrtzidis7cb45e32010-07-22 16:03:56 +00001664 S = new (Context) CXXCatchStmt(Empty);
1665 break;
1666
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001667 case STMT_CXX_TRY:
Argyrios Kyrtzidis7cb45e32010-07-22 16:03:56 +00001668 S = CXXTryStmt::Create(*Context, Empty,
Sebastian Redl60adf4a2010-08-18 23:56:52 +00001669 /*NumHandlers=*/Record[ASTStmtReader::NumStmtFields]);
Argyrios Kyrtzidis7cb45e32010-07-22 16:03:56 +00001670 break;
1671
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001672 case EXPR_CXX_OPERATOR_CALL:
Argyrios Kyrtzidisba0a9002009-07-14 03:19:21 +00001673 S = new (Context) CXXOperatorCallExpr(*Context, Empty);
1674 break;
Chris Lattner1817bd42010-05-09 05:36:05 +00001675
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001676 case EXPR_CXX_MEMBER_CALL:
Chris Lattner1817bd42010-05-09 05:36:05 +00001677 S = new (Context) CXXMemberCallExpr(*Context, Empty);
1678 break;
Douglas Gregor39da0b82009-09-09 23:08:42 +00001679
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001680 case EXPR_CXX_CONSTRUCT:
Argyrios Kyrtzidis6d00c132010-07-10 11:46:15 +00001681 S = new (Context) CXXConstructExpr(Empty);
1682 break;
1683
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001684 case EXPR_CXX_TEMPORARY_OBJECT:
Argyrios Kyrtzidis6d00c132010-07-10 11:46:15 +00001685 S = new (Context) CXXTemporaryObjectExpr(Empty);
Douglas Gregor39da0b82009-09-09 23:08:42 +00001686 break;
Sam Weinigce757a72010-01-16 21:21:01 +00001687
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001688 case EXPR_CXX_STATIC_CAST:
John McCallf871d0c2010-08-07 06:22:56 +00001689 S = CXXStaticCastExpr::CreateEmpty(*Context,
Sebastian Redl60adf4a2010-08-18 23:56:52 +00001690 /*PathSize*/ Record[ASTStmtReader::NumExprFields]);
Sam Weinigce757a72010-01-16 21:21:01 +00001691 break;
1692
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001693 case EXPR_CXX_DYNAMIC_CAST:
John McCallf871d0c2010-08-07 06:22:56 +00001694 S = CXXDynamicCastExpr::CreateEmpty(*Context,
Sebastian Redl60adf4a2010-08-18 23:56:52 +00001695 /*PathSize*/ Record[ASTStmtReader::NumExprFields]);
Sam Weinigce757a72010-01-16 21:21:01 +00001696 break;
1697
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001698 case EXPR_CXX_REINTERPRET_CAST:
John McCallf871d0c2010-08-07 06:22:56 +00001699 S = CXXReinterpretCastExpr::CreateEmpty(*Context,
Sebastian Redl60adf4a2010-08-18 23:56:52 +00001700 /*PathSize*/ Record[ASTStmtReader::NumExprFields]);
Sam Weinigce757a72010-01-16 21:21:01 +00001701 break;
1702
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001703 case EXPR_CXX_CONST_CAST:
John McCallf871d0c2010-08-07 06:22:56 +00001704 S = CXXConstCastExpr::CreateEmpty(*Context);
Sam Weinigce757a72010-01-16 21:21:01 +00001705 break;
1706
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001707 case EXPR_CXX_FUNCTIONAL_CAST:
John McCallf871d0c2010-08-07 06:22:56 +00001708 S = CXXFunctionalCastExpr::CreateEmpty(*Context,
Sebastian Redl60adf4a2010-08-18 23:56:52 +00001709 /*PathSize*/ Record[ASTStmtReader::NumExprFields]);
Sam Weinigce757a72010-01-16 21:21:01 +00001710 break;
1711
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001712 case EXPR_CXX_BOOL_LITERAL:
Sam Weinigeb7f9612010-02-07 06:32:43 +00001713 S = new (Context) CXXBoolLiteralExpr(Empty);
1714 break;
Sam Weinigce757a72010-01-16 21:21:01 +00001715
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001716 case EXPR_CXX_NULL_PTR_LITERAL:
Sam Weinigeb7f9612010-02-07 06:32:43 +00001717 S = new (Context) CXXNullPtrLiteralExpr(Empty);
1718 break;
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001719 case EXPR_CXX_TYPEID_EXPR:
Chris Lattner14ab24f2010-05-09 06:03:39 +00001720 S = new (Context) CXXTypeidExpr(Empty, true);
1721 break;
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001722 case EXPR_CXX_TYPEID_TYPE:
Chris Lattner14ab24f2010-05-09 06:03:39 +00001723 S = new (Context) CXXTypeidExpr(Empty, false);
1724 break;
Francois Pichet01b7c302010-09-08 12:20:18 +00001725 case EXPR_CXX_UUIDOF_EXPR:
1726 S = new (Context) CXXUuidofExpr(Empty, true);
1727 break;
1728 case EXPR_CXX_UUIDOF_TYPE:
1729 S = new (Context) CXXUuidofExpr(Empty, false);
1730 break;
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001731 case EXPR_CXX_THIS:
Chris Lattner2fbdfcd2010-05-09 06:15:05 +00001732 S = new (Context) CXXThisExpr(Empty);
1733 break;
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001734 case EXPR_CXX_THROW:
Chris Lattner2fbdfcd2010-05-09 06:15:05 +00001735 S = new (Context) CXXThrowExpr(Empty);
1736 break;
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001737 case EXPR_CXX_DEFAULT_ARG: {
Sebastian Redl60adf4a2010-08-18 23:56:52 +00001738 bool HasOtherExprStored = Record[ASTStmtReader::NumExprFields];
Argyrios Kyrtzidis8a507332010-07-02 23:30:15 +00001739 if (HasOtherExprStored) {
1740 Expr *SubExpr = ReadSubExpr();
1741 S = CXXDefaultArgExpr::Create(*Context, SourceLocation(), 0, SubExpr);
1742 } else
1743 S = new (Context) CXXDefaultArgExpr(Empty);
Chris Lattner030854b2010-05-09 06:40:08 +00001744 break;
Argyrios Kyrtzidis8a507332010-07-02 23:30:15 +00001745 }
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001746 case EXPR_CXX_BIND_TEMPORARY:
Chris Lattnerd2598362010-05-10 00:25:06 +00001747 S = new (Context) CXXBindTemporaryExpr(Empty);
1748 break;
Douglas Gregore2ca6d42010-09-02 21:50:02 +00001749
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001750 case EXPR_CXX_SCALAR_VALUE_INIT:
Douglas Gregored8abf12010-07-08 06:14:04 +00001751 S = new (Context) CXXScalarValueInitExpr(Empty);
Chris Lattner59218632010-05-10 01:22:27 +00001752 break;
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001753 case EXPR_CXX_NEW:
Chris Lattner59218632010-05-10 01:22:27 +00001754 S = new (Context) CXXNewExpr(Empty);
1755 break;
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001756 case EXPR_CXX_DELETE:
Argyrios Kyrtzidis95fc98c2010-06-22 17:07:59 +00001757 S = new (Context) CXXDeleteExpr(Empty);
1758 break;
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001759 case EXPR_CXX_PSEUDO_DESTRUCTOR:
Argyrios Kyrtzidisde4bd182010-06-28 09:32:03 +00001760 S = new (Context) CXXPseudoDestructorExpr(Empty);
1761 break;
Chris Lattner59218632010-05-10 01:22:27 +00001762
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001763 case EXPR_CXX_EXPR_WITH_TEMPORARIES:
Chris Lattnerd2598362010-05-10 00:25:06 +00001764 S = new (Context) CXXExprWithTemporaries(Empty);
1765 break;
Argyrios Kyrtzidis8dfbd8b2010-06-24 08:57:31 +00001766
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001767 case EXPR_CXX_DEPENDENT_SCOPE_MEMBER:
Argyrios Kyrtzidis8dfbd8b2010-06-24 08:57:31 +00001768 S = CXXDependentScopeMemberExpr::CreateEmpty(*Context,
Sebastian Redl60adf4a2010-08-18 23:56:52 +00001769 /*NumTemplateArgs=*/Record[ASTStmtReader::NumExprFields]);
Argyrios Kyrtzidis8dfbd8b2010-06-24 08:57:31 +00001770 break;
1771
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001772 case EXPR_CXX_DEPENDENT_SCOPE_DECL_REF:
Argyrios Kyrtzidis12dffcd2010-06-28 09:31:56 +00001773 S = DependentScopeDeclRefExpr::CreateEmpty(*Context,
Sebastian Redl60adf4a2010-08-18 23:56:52 +00001774 /*NumTemplateArgs=*/Record[ASTStmtReader::NumExprFields]);
Argyrios Kyrtzidis12dffcd2010-06-28 09:31:56 +00001775 break;
1776
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001777 case EXPR_CXX_UNRESOLVED_CONSTRUCT:
Argyrios Kyrtzidis8dfbd8b2010-06-24 08:57:31 +00001778 S = CXXUnresolvedConstructExpr::CreateEmpty(*Context,
Sebastian Redl60adf4a2010-08-18 23:56:52 +00001779 /*NumArgs=*/Record[ASTStmtReader::NumExprFields]);
Argyrios Kyrtzidisa77eb082010-06-25 09:03:26 +00001780 break;
1781
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001782 case EXPR_CXX_UNRESOLVED_MEMBER:
Argyrios Kyrtzidisa77eb082010-06-25 09:03:26 +00001783 S = UnresolvedMemberExpr::CreateEmpty(*Context,
Sebastian Redl60adf4a2010-08-18 23:56:52 +00001784 /*NumTemplateArgs=*/Record[ASTStmtReader::NumExprFields]);
Argyrios Kyrtzidis8dfbd8b2010-06-24 08:57:31 +00001785 break;
Argyrios Kyrtzidisbd65bb52010-06-25 09:03:34 +00001786
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001787 case EXPR_CXX_UNRESOLVED_LOOKUP:
Argyrios Kyrtzidisbd65bb52010-06-25 09:03:34 +00001788 S = UnresolvedLookupExpr::CreateEmpty(*Context,
Sebastian Redl60adf4a2010-08-18 23:56:52 +00001789 /*NumTemplateArgs=*/Record[ASTStmtReader::NumExprFields]);
Argyrios Kyrtzidisbd65bb52010-06-25 09:03:34 +00001790 break;
Argyrios Kyrtzidis6d00c132010-07-10 11:46:15 +00001791
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001792 case EXPR_CXX_UNARY_TYPE_TRAIT:
Argyrios Kyrtzidis6d00c132010-07-10 11:46:15 +00001793 S = new (Context) UnaryTypeTraitExpr(Empty);
1794 break;
Sebastian Redl6b219d02010-09-10 20:55:54 +00001795
1796 case EXPR_CXX_NOEXCEPT:
1797 S = new (Context) CXXNoexceptExpr(Empty);
1798 break;
Chris Lattner4c6f9522009-04-27 05:14:47 +00001799 }
Argyrios Kyrtzidis6d00c132010-07-10 11:46:15 +00001800
Chris Lattner4c6f9522009-04-27 05:14:47 +00001801 // We hit a STMT_STOP, so we're done with this expression.
1802 if (Finished)
1803 break;
1804
1805 ++NumStatementsRead;
1806
Argyrios Kyrtzidis919e6932010-06-28 22:28:35 +00001807 if (S)
1808 Reader.Visit(S);
Chris Lattner4c6f9522009-04-27 05:14:47 +00001809
1810 assert(Idx == Record.size() && "Invalid deserialization of statement");
1811 StmtStack.push_back(S);
1812 }
Argyrios Kyrtzidis919e6932010-06-28 22:28:35 +00001813
1814#ifndef NDEBUG
1815 assert(StmtStack.size() > PrevNumStmts && "Read too many sub stmts!");
1816 assert(StmtStack.size() == PrevNumStmts + 1 && "Extra expressions on stack!");
1817#endif
1818
1819 return StmtStack.pop_back_val();
Chris Lattner4c6f9522009-04-27 05:14:47 +00001820}