blob: a7dfa1b19fea3d885ab712f151c9624a7166940e [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"
Douglas Gregorc7793c72011-01-15 01:15:58 +000017#include "clang/AST/DeclTemplate.h"
Chris Lattner4c6f9522009-04-27 05:14:47 +000018#include "clang/AST/StmtVisitor.h"
19using namespace clang;
Sebastian Redl8538e8d2010-08-18 23:57:32 +000020using namespace clang::serialization;
Chris Lattner4c6f9522009-04-27 05:14:47 +000021
Argyrios Kyrtzidis37bdfe22010-06-30 08:49:18 +000022namespace clang {
Argyrios Kyrtzidis17cfded2010-06-28 09:31:42 +000023
Sebastian Redl60adf4a2010-08-18 23:56:52 +000024 class ASTStmtReader : public StmtVisitor<ASTStmtReader> {
Douglas Gregor409448c2011-07-21 22:35:25 +000025 typedef ASTReader::RecordData RecordData;
26
Sebastian Redlc43b54c2010-08-18 23:56:43 +000027 ASTReader &Reader;
Douglas Gregor1a4761e2011-11-30 23:21:26 +000028 ModuleFile &F;
Sebastian Redl577d4792010-07-22 22:43:28 +000029 llvm::BitstreamCursor &DeclsCursor;
Sebastian Redlc43b54c2010-08-18 23:56:43 +000030 const ASTReader::RecordData &Record;
Chris Lattner4c6f9522009-04-27 05:14:47 +000031 unsigned &Idx;
Chris Lattner4c6f9522009-04-27 05:14:47 +000032
Douglas Gregor409448c2011-07-21 22:35:25 +000033 SourceLocation ReadSourceLocation(const RecordData &R, unsigned &I) {
Sebastian Redlc3632732010-10-05 15:59:54 +000034 return Reader.ReadSourceLocation(F, R, I);
35 }
Douglas Gregor409448c2011-07-21 22:35:25 +000036
37 SourceRange ReadSourceRange(const RecordData &R, unsigned &I) {
Sebastian Redlc3632732010-10-05 15:59:54 +000038 return Reader.ReadSourceRange(F, R, I);
39 }
Douglas Gregor409448c2011-07-21 22:35:25 +000040
41 TypeSourceInfo *GetTypeSourceInfo(const RecordData &R, unsigned &I) {
Sebastian Redlc3632732010-10-05 15:59:54 +000042 return Reader.GetTypeSourceInfo(F, R, I);
43 }
Douglas Gregor409448c2011-07-21 22:35:25 +000044
45 serialization::DeclID ReadDeclID(const RecordData &R, unsigned &I) {
46 return Reader.ReadDeclID(F, R, I);
47 }
48
49 Decl *ReadDecl(const RecordData &R, unsigned &I) {
50 return Reader.ReadDecl(F, R, I);
51 }
52
53 template<typename T>
54 T *ReadDeclAs(const RecordData &R, unsigned &I) {
55 return Reader.ReadDeclAs<T>(F, R, I);
56 }
57
Argyrios Kyrtzidis40451072010-10-15 18:21:24 +000058 void ReadDeclarationNameLoc(DeclarationNameLoc &DNLoc, DeclarationName Name,
59 const ASTReader::RecordData &R, unsigned &I) {
60 Reader.ReadDeclarationNameLoc(F, DNLoc, Name, R, I);
61 }
Douglas Gregor409448c2011-07-21 22:35:25 +000062
Argyrios Kyrtzidis40451072010-10-15 18:21:24 +000063 void ReadDeclarationNameInfo(DeclarationNameInfo &NameInfo,
64 const ASTReader::RecordData &R, unsigned &I) {
65 Reader.ReadDeclarationNameInfo(F, NameInfo, R, I);
66 }
Sebastian Redlc3632732010-10-05 15:59:54 +000067
Chris Lattner4c6f9522009-04-27 05:14:47 +000068 public:
Douglas Gregor1a4761e2011-11-30 23:21:26 +000069 ASTStmtReader(ASTReader &Reader, ModuleFile &F,
Sebastian Redlc3632732010-10-05 15:59:54 +000070 llvm::BitstreamCursor &Cursor,
Sebastian Redlc43b54c2010-08-18 23:56:43 +000071 const ASTReader::RecordData &Record, unsigned &Idx)
Sebastian Redlc3632732010-10-05 15:59:54 +000072 : Reader(Reader), F(F), DeclsCursor(Cursor), Record(Record), Idx(Idx) { }
Chris Lattner4c6f9522009-04-27 05:14:47 +000073
74 /// \brief The number of record fields required for the Stmt class
75 /// itself.
76 static const unsigned NumStmtFields = 0;
77
78 /// \brief The number of record fields required for the Expr class
79 /// itself.
Douglas Gregor561f8122011-07-01 01:22:09 +000080 static const unsigned NumExprFields = NumStmtFields + 7;
Argyrios Kyrtzidis36c76f02010-06-28 09:31:48 +000081
82 /// \brief Read and initialize a ExplicitTemplateArgumentList structure.
Argyrios Kyrtzidisb0c3e092011-09-22 20:07:03 +000083 void ReadExplicitTemplateArgumentList(ASTTemplateArgumentListInfo &ArgList,
Argyrios Kyrtzidis919e6932010-06-28 22:28:35 +000084 unsigned NumTemplateArgs);
Chris Lattner4c6f9522009-04-27 05:14:47 +000085
Argyrios Kyrtzidis919e6932010-06-28 22:28:35 +000086 void VisitStmt(Stmt *S);
John McCall7110fd62011-07-15 07:00:14 +000087#define STMT(Type, Base) \
88 void Visit##Type(Type *);
89#include "clang/AST/StmtNodes.inc"
Chris Lattner4c6f9522009-04-27 05:14:47 +000090 };
91}
92
Sebastian Redl60adf4a2010-08-18 23:56:52 +000093void ASTStmtReader::
Argyrios Kyrtzidisb0c3e092011-09-22 20:07:03 +000094ReadExplicitTemplateArgumentList(ASTTemplateArgumentListInfo &ArgList,
Argyrios Kyrtzidis919e6932010-06-28 22:28:35 +000095 unsigned NumTemplateArgs) {
Argyrios Kyrtzidis36c76f02010-06-28 09:31:48 +000096 TemplateArgumentListInfo ArgInfo;
Sebastian Redlc3632732010-10-05 15:59:54 +000097 ArgInfo.setLAngleLoc(ReadSourceLocation(Record, Idx));
98 ArgInfo.setRAngleLoc(ReadSourceLocation(Record, Idx));
Argyrios Kyrtzidis36c76f02010-06-28 09:31:48 +000099 for (unsigned i = 0; i != NumTemplateArgs; ++i)
Sebastian Redl577d4792010-07-22 22:43:28 +0000100 ArgInfo.addArgument(
Sebastian Redlc3632732010-10-05 15:59:54 +0000101 Reader.ReadTemplateArgumentLoc(F, Record, Idx));
Argyrios Kyrtzidis36c76f02010-06-28 09:31:48 +0000102 ArgList.initializeFrom(ArgInfo);
Argyrios Kyrtzidis36c76f02010-06-28 09:31:48 +0000103}
104
Sebastian Redl60adf4a2010-08-18 23:56:52 +0000105void ASTStmtReader::VisitStmt(Stmt *S) {
Chris Lattner4c6f9522009-04-27 05:14:47 +0000106 assert(Idx == NumStmtFields && "Incorrect statement field count");
Chris Lattner4c6f9522009-04-27 05:14:47 +0000107}
108
Sebastian Redl60adf4a2010-08-18 23:56:52 +0000109void ASTStmtReader::VisitNullStmt(NullStmt *S) {
Chris Lattner4c6f9522009-04-27 05:14:47 +0000110 VisitStmt(S);
Sebastian Redlc3632732010-10-05 15:59:54 +0000111 S->setSemiLoc(ReadSourceLocation(Record, Idx));
Argyrios Kyrtzidise2ca8282011-09-01 21:53:45 +0000112 S->HasLeadingEmptyMacro = Record[Idx++];
Chris Lattner4c6f9522009-04-27 05:14:47 +0000113}
114
Sebastian Redl60adf4a2010-08-18 23:56:52 +0000115void ASTStmtReader::VisitCompoundStmt(CompoundStmt *S) {
Chris Lattner4c6f9522009-04-27 05:14:47 +0000116 VisitStmt(S);
Chris Lattner5f9e2722011-07-23 10:55:15 +0000117 SmallVector<Stmt *, 16> Stmts;
Chris Lattner4c6f9522009-04-27 05:14:47 +0000118 unsigned NumStmts = Record[Idx++];
Argyrios Kyrtzidis919e6932010-06-28 22:28:35 +0000119 while (NumStmts--)
Argyrios Kyrtzidisd98a2ab2010-06-29 22:46:25 +0000120 Stmts.push_back(Reader.ReadSubStmt());
Douglas Gregor35942772011-09-09 21:34:22 +0000121 S->setStmts(Reader.getContext(), Stmts.data(), Stmts.size());
Sebastian Redlc3632732010-10-05 15:59:54 +0000122 S->setLBracLoc(ReadSourceLocation(Record, Idx));
123 S->setRBracLoc(ReadSourceLocation(Record, Idx));
Chris Lattner4c6f9522009-04-27 05:14:47 +0000124}
125
Sebastian Redl60adf4a2010-08-18 23:56:52 +0000126void ASTStmtReader::VisitSwitchCase(SwitchCase *S) {
Chris Lattner4c6f9522009-04-27 05:14:47 +0000127 VisitStmt(S);
128 Reader.RecordSwitchCaseID(S, Record[Idx++]);
Chris Lattner4c6f9522009-04-27 05:14:47 +0000129}
130
Sebastian Redl60adf4a2010-08-18 23:56:52 +0000131void ASTStmtReader::VisitCaseStmt(CaseStmt *S) {
Chris Lattner4c6f9522009-04-27 05:14:47 +0000132 VisitSwitchCase(S);
Argyrios Kyrtzidisd98a2ab2010-06-29 22:46:25 +0000133 S->setLHS(Reader.ReadSubExpr());
134 S->setRHS(Reader.ReadSubExpr());
135 S->setSubStmt(Reader.ReadSubStmt());
Sebastian Redlc3632732010-10-05 15:59:54 +0000136 S->setCaseLoc(ReadSourceLocation(Record, Idx));
137 S->setEllipsisLoc(ReadSourceLocation(Record, Idx));
138 S->setColonLoc(ReadSourceLocation(Record, Idx));
Chris Lattner4c6f9522009-04-27 05:14:47 +0000139}
140
Sebastian Redl60adf4a2010-08-18 23:56:52 +0000141void ASTStmtReader::VisitDefaultStmt(DefaultStmt *S) {
Chris Lattner4c6f9522009-04-27 05:14:47 +0000142 VisitSwitchCase(S);
Argyrios Kyrtzidisd98a2ab2010-06-29 22:46:25 +0000143 S->setSubStmt(Reader.ReadSubStmt());
Sebastian Redlc3632732010-10-05 15:59:54 +0000144 S->setDefaultLoc(ReadSourceLocation(Record, Idx));
145 S->setColonLoc(ReadSourceLocation(Record, Idx));
Chris Lattner4c6f9522009-04-27 05:14:47 +0000146}
147
Sebastian Redl60adf4a2010-08-18 23:56:52 +0000148void ASTStmtReader::VisitLabelStmt(LabelStmt *S) {
Chris Lattner4c6f9522009-04-27 05:14:47 +0000149 VisitStmt(S);
Douglas Gregor409448c2011-07-21 22:35:25 +0000150 LabelDecl *LD = ReadDeclAs<LabelDecl>(Record, Idx);
Chris Lattnerad8dcf42011-02-17 07:39:24 +0000151 LD->setStmt(S);
152 S->setDecl(LD);
Argyrios Kyrtzidisd98a2ab2010-06-29 22:46:25 +0000153 S->setSubStmt(Reader.ReadSubStmt());
Sebastian Redlc3632732010-10-05 15:59:54 +0000154 S->setIdentLoc(ReadSourceLocation(Record, Idx));
Chris Lattner4c6f9522009-04-27 05:14:47 +0000155}
156
Sebastian Redl60adf4a2010-08-18 23:56:52 +0000157void ASTStmtReader::VisitIfStmt(IfStmt *S) {
Chris Lattner4c6f9522009-04-27 05:14:47 +0000158 VisitStmt(S);
Douglas Gregor35942772011-09-09 21:34:22 +0000159 S->setConditionVariable(Reader.getContext(),
Douglas Gregor409448c2011-07-21 22:35:25 +0000160 ReadDeclAs<VarDecl>(Record, Idx));
Argyrios Kyrtzidisd98a2ab2010-06-29 22:46:25 +0000161 S->setCond(Reader.ReadSubExpr());
162 S->setThen(Reader.ReadSubStmt());
163 S->setElse(Reader.ReadSubStmt());
Sebastian Redlc3632732010-10-05 15:59:54 +0000164 S->setIfLoc(ReadSourceLocation(Record, Idx));
165 S->setElseLoc(ReadSourceLocation(Record, Idx));
Chris Lattner4c6f9522009-04-27 05:14:47 +0000166}
167
Sebastian Redl60adf4a2010-08-18 23:56:52 +0000168void ASTStmtReader::VisitSwitchStmt(SwitchStmt *S) {
Chris Lattner4c6f9522009-04-27 05:14:47 +0000169 VisitStmt(S);
Douglas Gregor35942772011-09-09 21:34:22 +0000170 S->setConditionVariable(Reader.getContext(),
Douglas Gregor409448c2011-07-21 22:35:25 +0000171 ReadDeclAs<VarDecl>(Record, Idx));
Argyrios Kyrtzidisd98a2ab2010-06-29 22:46:25 +0000172 S->setCond(Reader.ReadSubExpr());
173 S->setBody(Reader.ReadSubStmt());
Sebastian Redlc3632732010-10-05 15:59:54 +0000174 S->setSwitchLoc(ReadSourceLocation(Record, Idx));
Ted Kremenek559fb552010-09-09 00:05:53 +0000175 if (Record[Idx++])
176 S->setAllEnumCasesCovered();
177
Chris Lattner4c6f9522009-04-27 05:14:47 +0000178 SwitchCase *PrevSC = 0;
179 for (unsigned N = Record.size(); Idx != N; ++Idx) {
180 SwitchCase *SC = Reader.getSwitchCaseWithID(Record[Idx]);
181 if (PrevSC)
182 PrevSC->setNextSwitchCase(SC);
183 else
184 S->setSwitchCaseList(SC);
Mike Stump1eb44332009-09-09 15:08:12 +0000185
Chris Lattner4c6f9522009-04-27 05:14:47 +0000186 PrevSC = SC;
187 }
Chris Lattner4c6f9522009-04-27 05:14:47 +0000188}
189
Sebastian Redl60adf4a2010-08-18 23:56:52 +0000190void ASTStmtReader::VisitWhileStmt(WhileStmt *S) {
Chris Lattner4c6f9522009-04-27 05:14:47 +0000191 VisitStmt(S);
Douglas Gregor35942772011-09-09 21:34:22 +0000192 S->setConditionVariable(Reader.getContext(),
Douglas Gregor409448c2011-07-21 22:35:25 +0000193 ReadDeclAs<VarDecl>(Record, Idx));
194
Argyrios Kyrtzidisd98a2ab2010-06-29 22:46:25 +0000195 S->setCond(Reader.ReadSubExpr());
196 S->setBody(Reader.ReadSubStmt());
Sebastian Redlc3632732010-10-05 15:59:54 +0000197 S->setWhileLoc(ReadSourceLocation(Record, Idx));
Chris Lattner4c6f9522009-04-27 05:14:47 +0000198}
199
Sebastian Redl60adf4a2010-08-18 23:56:52 +0000200void ASTStmtReader::VisitDoStmt(DoStmt *S) {
Chris Lattner4c6f9522009-04-27 05:14:47 +0000201 VisitStmt(S);
Argyrios Kyrtzidisd98a2ab2010-06-29 22:46:25 +0000202 S->setCond(Reader.ReadSubExpr());
203 S->setBody(Reader.ReadSubStmt());
Sebastian Redlc3632732010-10-05 15:59:54 +0000204 S->setDoLoc(ReadSourceLocation(Record, Idx));
205 S->setWhileLoc(ReadSourceLocation(Record, Idx));
206 S->setRParenLoc(ReadSourceLocation(Record, Idx));
Chris Lattner4c6f9522009-04-27 05:14:47 +0000207}
208
Sebastian Redl60adf4a2010-08-18 23:56:52 +0000209void ASTStmtReader::VisitForStmt(ForStmt *S) {
Chris Lattner4c6f9522009-04-27 05:14:47 +0000210 VisitStmt(S);
Argyrios Kyrtzidisd98a2ab2010-06-29 22:46:25 +0000211 S->setInit(Reader.ReadSubStmt());
212 S->setCond(Reader.ReadSubExpr());
Douglas Gregor35942772011-09-09 21:34:22 +0000213 S->setConditionVariable(Reader.getContext(),
Douglas Gregor409448c2011-07-21 22:35:25 +0000214 ReadDeclAs<VarDecl>(Record, Idx));
Argyrios Kyrtzidisd98a2ab2010-06-29 22:46:25 +0000215 S->setInc(Reader.ReadSubExpr());
216 S->setBody(Reader.ReadSubStmt());
Sebastian Redlc3632732010-10-05 15:59:54 +0000217 S->setForLoc(ReadSourceLocation(Record, Idx));
218 S->setLParenLoc(ReadSourceLocation(Record, Idx));
219 S->setRParenLoc(ReadSourceLocation(Record, Idx));
Chris Lattner4c6f9522009-04-27 05:14:47 +0000220}
221
Sebastian Redl60adf4a2010-08-18 23:56:52 +0000222void ASTStmtReader::VisitGotoStmt(GotoStmt *S) {
Chris Lattner4c6f9522009-04-27 05:14:47 +0000223 VisitStmt(S);
Douglas Gregor409448c2011-07-21 22:35:25 +0000224 S->setLabel(ReadDeclAs<LabelDecl>(Record, Idx));
Sebastian Redlc3632732010-10-05 15:59:54 +0000225 S->setGotoLoc(ReadSourceLocation(Record, Idx));
226 S->setLabelLoc(ReadSourceLocation(Record, Idx));
Chris Lattner4c6f9522009-04-27 05:14:47 +0000227}
228
Sebastian Redl60adf4a2010-08-18 23:56:52 +0000229void ASTStmtReader::VisitIndirectGotoStmt(IndirectGotoStmt *S) {
Chris Lattner4c6f9522009-04-27 05:14:47 +0000230 VisitStmt(S);
Sebastian Redlc3632732010-10-05 15:59:54 +0000231 S->setGotoLoc(ReadSourceLocation(Record, Idx));
232 S->setStarLoc(ReadSourceLocation(Record, Idx));
Argyrios Kyrtzidisd98a2ab2010-06-29 22:46:25 +0000233 S->setTarget(Reader.ReadSubExpr());
Chris Lattner4c6f9522009-04-27 05:14:47 +0000234}
235
Sebastian Redl60adf4a2010-08-18 23:56:52 +0000236void ASTStmtReader::VisitContinueStmt(ContinueStmt *S) {
Chris Lattner4c6f9522009-04-27 05:14:47 +0000237 VisitStmt(S);
Sebastian Redlc3632732010-10-05 15:59:54 +0000238 S->setContinueLoc(ReadSourceLocation(Record, Idx));
Chris Lattner4c6f9522009-04-27 05:14:47 +0000239}
240
Sebastian Redl60adf4a2010-08-18 23:56:52 +0000241void ASTStmtReader::VisitBreakStmt(BreakStmt *S) {
Chris Lattner4c6f9522009-04-27 05:14:47 +0000242 VisitStmt(S);
Sebastian Redlc3632732010-10-05 15:59:54 +0000243 S->setBreakLoc(ReadSourceLocation(Record, Idx));
Chris Lattner4c6f9522009-04-27 05:14:47 +0000244}
245
Sebastian Redl60adf4a2010-08-18 23:56:52 +0000246void ASTStmtReader::VisitReturnStmt(ReturnStmt *S) {
Chris Lattner4c6f9522009-04-27 05:14:47 +0000247 VisitStmt(S);
Argyrios Kyrtzidisd98a2ab2010-06-29 22:46:25 +0000248 S->setRetValue(Reader.ReadSubExpr());
Sebastian Redlc3632732010-10-05 15:59:54 +0000249 S->setReturnLoc(ReadSourceLocation(Record, Idx));
Douglas Gregor409448c2011-07-21 22:35:25 +0000250 S->setNRVOCandidate(ReadDeclAs<VarDecl>(Record, Idx));
Chris Lattner4c6f9522009-04-27 05:14:47 +0000251}
252
Sebastian Redl60adf4a2010-08-18 23:56:52 +0000253void ASTStmtReader::VisitDeclStmt(DeclStmt *S) {
Chris Lattner4c6f9522009-04-27 05:14:47 +0000254 VisitStmt(S);
Sebastian Redlc3632732010-10-05 15:59:54 +0000255 S->setStartLoc(ReadSourceLocation(Record, Idx));
256 S->setEndLoc(ReadSourceLocation(Record, Idx));
Chris Lattner4c6f9522009-04-27 05:14:47 +0000257
258 if (Idx + 1 == Record.size()) {
259 // Single declaration
Douglas Gregor409448c2011-07-21 22:35:25 +0000260 S->setDeclGroup(DeclGroupRef(ReadDecl(Record, Idx)));
Chris Lattner4c6f9522009-04-27 05:14:47 +0000261 } else {
Chris Lattner5f9e2722011-07-23 10:55:15 +0000262 SmallVector<Decl *, 16> Decls;
Douglas Gregor409448c2011-07-21 22:35:25 +0000263 Decls.reserve(Record.size() - Idx);
264 for (unsigned N = Record.size(); Idx != N; )
265 Decls.push_back(ReadDecl(Record, Idx));
Douglas Gregor35942772011-09-09 21:34:22 +0000266 S->setDeclGroup(DeclGroupRef(DeclGroup::Create(Reader.getContext(),
Douglas Gregor75fdb232009-05-22 22:45:36 +0000267 Decls.data(),
268 Decls.size())));
Chris Lattner4c6f9522009-04-27 05:14:47 +0000269 }
Chris Lattner4c6f9522009-04-27 05:14:47 +0000270}
271
Sebastian Redl60adf4a2010-08-18 23:56:52 +0000272void ASTStmtReader::VisitAsmStmt(AsmStmt *S) {
Chris Lattner4c6f9522009-04-27 05:14:47 +0000273 VisitStmt(S);
274 unsigned NumOutputs = Record[Idx++];
275 unsigned NumInputs = Record[Idx++];
276 unsigned NumClobbers = Record[Idx++];
Sebastian Redlc3632732010-10-05 15:59:54 +0000277 S->setAsmLoc(ReadSourceLocation(Record, Idx));
278 S->setRParenLoc(ReadSourceLocation(Record, Idx));
Chris Lattner4c6f9522009-04-27 05:14:47 +0000279 S->setVolatile(Record[Idx++]);
280 S->setSimple(Record[Idx++]);
Mike Stump3b11fd32010-01-04 22:37:17 +0000281 S->setMSAsm(Record[Idx++]);
Mike Stump1eb44332009-09-09 15:08:12 +0000282
Argyrios Kyrtzidisd98a2ab2010-06-29 22:46:25 +0000283 S->setAsmString(cast_or_null<StringLiteral>(Reader.ReadSubStmt()));
Chris Lattner4c6f9522009-04-27 05:14:47 +0000284
285 // Outputs and inputs
Chris Lattner5f9e2722011-07-23 10:55:15 +0000286 SmallVector<IdentifierInfo *, 16> Names;
287 SmallVector<StringLiteral*, 16> Constraints;
288 SmallVector<Stmt*, 16> Exprs;
Chris Lattner4c6f9522009-04-27 05:14:47 +0000289 for (unsigned I = 0, N = NumOutputs + NumInputs; I != N; ++I) {
Douglas Gregor95eab172011-07-28 20:55:49 +0000290 Names.push_back(Reader.GetIdentifierInfo(F, Record, Idx));
Argyrios Kyrtzidisd98a2ab2010-06-29 22:46:25 +0000291 Constraints.push_back(cast_or_null<StringLiteral>(Reader.ReadSubStmt()));
292 Exprs.push_back(Reader.ReadSubStmt());
Chris Lattner4c6f9522009-04-27 05:14:47 +0000293 }
Chris Lattner4c6f9522009-04-27 05:14:47 +0000294
295 // Constraints
Chris Lattner5f9e2722011-07-23 10:55:15 +0000296 SmallVector<StringLiteral*, 16> Clobbers;
Chris Lattner4c6f9522009-04-27 05:14:47 +0000297 for (unsigned I = 0; I != NumClobbers; ++I)
Argyrios Kyrtzidisd98a2ab2010-06-29 22:46:25 +0000298 Clobbers.push_back(cast_or_null<StringLiteral>(Reader.ReadSubStmt()));
Anders Carlssonfdba9c02010-01-30 19:34:25 +0000299
Douglas Gregor35942772011-09-09 21:34:22 +0000300 S->setOutputsAndInputsAndClobbers(Reader.getContext(),
Anders Carlssonacb6bcb2010-01-30 20:38:10 +0000301 Names.data(), Constraints.data(),
Anders Carlssonfdba9c02010-01-30 19:34:25 +0000302 Exprs.data(), NumOutputs, NumInputs,
303 Clobbers.data(), NumClobbers);
Chris Lattner4c6f9522009-04-27 05:14:47 +0000304}
305
Sebastian Redl60adf4a2010-08-18 23:56:52 +0000306void ASTStmtReader::VisitExpr(Expr *E) {
Chris Lattner4c6f9522009-04-27 05:14:47 +0000307 VisitStmt(E);
Douglas Gregor393f2492011-07-22 00:38:23 +0000308 E->setType(Reader.readType(F, Record, Idx));
Chris Lattner4c6f9522009-04-27 05:14:47 +0000309 E->setTypeDependent(Record[Idx++]);
310 E->setValueDependent(Record[Idx++]);
Douglas Gregor561f8122011-07-01 01:22:09 +0000311 E->setInstantiationDependent(Record[Idx++]);
Douglas Gregord0937222010-12-13 22:49:22 +0000312 E->ExprBits.ContainsUnexpandedParameterPack = Record[Idx++];
John McCallf89e55a2010-11-18 06:31:45 +0000313 E->setValueKind(static_cast<ExprValueKind>(Record[Idx++]));
314 E->setObjectKind(static_cast<ExprObjectKind>(Record[Idx++]));
Chris Lattner4c6f9522009-04-27 05:14:47 +0000315 assert(Idx == NumExprFields && "Incorrect expression field count");
Chris Lattner4c6f9522009-04-27 05:14:47 +0000316}
317
Sebastian Redl60adf4a2010-08-18 23:56:52 +0000318void ASTStmtReader::VisitPredefinedExpr(PredefinedExpr *E) {
Chris Lattner4c6f9522009-04-27 05:14:47 +0000319 VisitExpr(E);
Sebastian Redlc3632732010-10-05 15:59:54 +0000320 E->setLocation(ReadSourceLocation(Record, Idx));
Chris Lattner4c6f9522009-04-27 05:14:47 +0000321 E->setIdentType((PredefinedExpr::IdentType)Record[Idx++]);
Chris Lattner4c6f9522009-04-27 05:14:47 +0000322}
323
Sebastian Redl60adf4a2010-08-18 23:56:52 +0000324void ASTStmtReader::VisitDeclRefExpr(DeclRefExpr *E) {
Chris Lattner4c6f9522009-04-27 05:14:47 +0000325 VisitExpr(E);
Argyrios Kyrtzidis663e3802010-07-08 13:09:47 +0000326
Chandler Carruthcb66cff2011-05-01 21:29:53 +0000327 E->DeclRefExprBits.HasQualifier = Record[Idx++];
Chandler Carruth3aa81402011-05-01 23:48:14 +0000328 E->DeclRefExprBits.HasFoundDecl = Record[Idx++];
Chandler Carruthcb66cff2011-05-01 21:29:53 +0000329 E->DeclRefExprBits.HasExplicitTemplateArgs = Record[Idx++];
Abramo Bagnara7cc58b42011-10-05 07:56:41 +0000330 E->DeclRefExprBits.HadMultipleCandidates = Record[Idx++];
Anders Carlssonb0ca1372011-03-06 18:19:42 +0000331 unsigned NumTemplateArgs = 0;
Chandler Carruthcb66cff2011-05-01 21:29:53 +0000332 if (E->hasExplicitTemplateArgs())
Anders Carlssonb0ca1372011-03-06 18:19:42 +0000333 NumTemplateArgs = Record[Idx++];
334
Chandler Carruthcb66cff2011-05-01 21:29:53 +0000335 if (E->hasQualifier())
Chandler Carruth6857c3e2011-05-01 22:14:37 +0000336 E->getInternalQualifierLoc()
Douglas Gregor40d96a62011-02-28 21:54:11 +0000337 = Reader.ReadNestedNameSpecifierLoc(F, Record, Idx);
Argyrios Kyrtzidis663e3802010-07-08 13:09:47 +0000338
Chandler Carruth3aa81402011-05-01 23:48:14 +0000339 if (E->hasFoundDecl())
Douglas Gregor409448c2011-07-21 22:35:25 +0000340 E->getInternalFoundDecl() = ReadDeclAs<NamedDecl>(Record, Idx);
Chandler Carruth3aa81402011-05-01 23:48:14 +0000341
Chandler Carruthcb66cff2011-05-01 21:29:53 +0000342 if (E->hasExplicitTemplateArgs())
John McCall096832c2010-08-19 23:49:38 +0000343 ReadExplicitTemplateArgumentList(E->getExplicitTemplateArgs(),
Argyrios Kyrtzidis663e3802010-07-08 13:09:47 +0000344 NumTemplateArgs);
345
Douglas Gregor409448c2011-07-21 22:35:25 +0000346 E->setDecl(ReadDeclAs<ValueDecl>(Record, Idx));
Sebastian Redlc3632732010-10-05 15:59:54 +0000347 E->setLocation(ReadSourceLocation(Record, Idx));
Argyrios Kyrtzidis40451072010-10-15 18:21:24 +0000348 ReadDeclarationNameLoc(E->DNLoc, E->getDecl()->getDeclName(), Record, Idx);
Chris Lattner4c6f9522009-04-27 05:14:47 +0000349}
350
Sebastian Redl60adf4a2010-08-18 23:56:52 +0000351void ASTStmtReader::VisitIntegerLiteral(IntegerLiteral *E) {
Chris Lattner4c6f9522009-04-27 05:14:47 +0000352 VisitExpr(E);
Sebastian Redlc3632732010-10-05 15:59:54 +0000353 E->setLocation(ReadSourceLocation(Record, Idx));
Douglas Gregor35942772011-09-09 21:34:22 +0000354 E->setValue(Reader.getContext(), Reader.ReadAPInt(Record, Idx));
Chris Lattner4c6f9522009-04-27 05:14:47 +0000355}
356
Sebastian Redl60adf4a2010-08-18 23:56:52 +0000357void ASTStmtReader::VisitFloatingLiteral(FloatingLiteral *E) {
Chris Lattner4c6f9522009-04-27 05:14:47 +0000358 VisitExpr(E);
Douglas Gregor35942772011-09-09 21:34:22 +0000359 E->setValue(Reader.getContext(), Reader.ReadAPFloat(Record, Idx));
Chris Lattner4c6f9522009-04-27 05:14:47 +0000360 E->setExact(Record[Idx++]);
Sebastian Redlc3632732010-10-05 15:59:54 +0000361 E->setLocation(ReadSourceLocation(Record, Idx));
Chris Lattner4c6f9522009-04-27 05:14:47 +0000362}
363
Sebastian Redl60adf4a2010-08-18 23:56:52 +0000364void ASTStmtReader::VisitImaginaryLiteral(ImaginaryLiteral *E) {
Chris Lattner4c6f9522009-04-27 05:14:47 +0000365 VisitExpr(E);
Argyrios Kyrtzidisd98a2ab2010-06-29 22:46:25 +0000366 E->setSubExpr(Reader.ReadSubExpr());
Chris Lattner4c6f9522009-04-27 05:14:47 +0000367}
368
Sebastian Redl60adf4a2010-08-18 23:56:52 +0000369void ASTStmtReader::VisitStringLiteral(StringLiteral *E) {
Chris Lattner4c6f9522009-04-27 05:14:47 +0000370 VisitExpr(E);
371 unsigned Len = Record[Idx++];
Mike Stump1eb44332009-09-09 15:08:12 +0000372 assert(Record[Idx] == E->getNumConcatenated() &&
Chris Lattner4c6f9522009-04-27 05:14:47 +0000373 "Wrong number of concatenated tokens!");
374 ++Idx;
Eli Friedman64f45a22011-11-01 02:23:42 +0000375 StringLiteral::StringKind kind =
376 static_cast<StringLiteral::StringKind>(Record[Idx++]);
377 bool isPascal = Record[Idx++];
Chris Lattner4c6f9522009-04-27 05:14:47 +0000378
Mike Stump1eb44332009-09-09 15:08:12 +0000379 // Read string data
Daniel Dunbarb6480232009-09-22 03:27:33 +0000380 llvm::SmallString<16> Str(&Record[Idx], &Record[Idx] + Len);
Eli Friedman64f45a22011-11-01 02:23:42 +0000381 E->setString(Reader.getContext(), Str.str(), kind, isPascal);
Chris Lattner4c6f9522009-04-27 05:14:47 +0000382 Idx += Len;
383
384 // Read source locations
385 for (unsigned I = 0, N = E->getNumConcatenated(); I != N; ++I)
Sebastian Redlc3632732010-10-05 15:59:54 +0000386 E->setStrTokenLoc(I, ReadSourceLocation(Record, Idx));
Chris Lattner4c6f9522009-04-27 05:14:47 +0000387}
388
Sebastian Redl60adf4a2010-08-18 23:56:52 +0000389void ASTStmtReader::VisitCharacterLiteral(CharacterLiteral *E) {
Chris Lattner4c6f9522009-04-27 05:14:47 +0000390 VisitExpr(E);
391 E->setValue(Record[Idx++]);
Sebastian Redlc3632732010-10-05 15:59:54 +0000392 E->setLocation(ReadSourceLocation(Record, Idx));
Douglas Gregor5cee1192011-07-27 05:40:30 +0000393 E->setKind(static_cast<CharacterLiteral::CharacterKind>(Record[Idx++]));
Chris Lattner4c6f9522009-04-27 05:14:47 +0000394}
395
Sebastian Redl60adf4a2010-08-18 23:56:52 +0000396void ASTStmtReader::VisitParenExpr(ParenExpr *E) {
Chris Lattner4c6f9522009-04-27 05:14:47 +0000397 VisitExpr(E);
Sebastian Redlc3632732010-10-05 15:59:54 +0000398 E->setLParen(ReadSourceLocation(Record, Idx));
399 E->setRParen(ReadSourceLocation(Record, Idx));
Argyrios Kyrtzidisd98a2ab2010-06-29 22:46:25 +0000400 E->setSubExpr(Reader.ReadSubExpr());
Chris Lattner4c6f9522009-04-27 05:14:47 +0000401}
402
Sebastian Redl60adf4a2010-08-18 23:56:52 +0000403void ASTStmtReader::VisitParenListExpr(ParenListExpr *E) {
Argyrios Kyrtzidis37bdfe22010-06-30 08:49:18 +0000404 VisitExpr(E);
405 unsigned NumExprs = Record[Idx++];
Douglas Gregor35942772011-09-09 21:34:22 +0000406 E->Exprs = new (Reader.getContext()) Stmt*[NumExprs];
Argyrios Kyrtzidis37bdfe22010-06-30 08:49:18 +0000407 for (unsigned i = 0; i != NumExprs; ++i)
408 E->Exprs[i] = Reader.ReadSubStmt();
409 E->NumExprs = NumExprs;
Sebastian Redlc3632732010-10-05 15:59:54 +0000410 E->LParenLoc = ReadSourceLocation(Record, Idx);
411 E->RParenLoc = ReadSourceLocation(Record, Idx);
Argyrios Kyrtzidis37bdfe22010-06-30 08:49:18 +0000412}
413
Sebastian Redl60adf4a2010-08-18 23:56:52 +0000414void ASTStmtReader::VisitUnaryOperator(UnaryOperator *E) {
Chris Lattner4c6f9522009-04-27 05:14:47 +0000415 VisitExpr(E);
Argyrios Kyrtzidisd98a2ab2010-06-29 22:46:25 +0000416 E->setSubExpr(Reader.ReadSubExpr());
Chris Lattner4c6f9522009-04-27 05:14:47 +0000417 E->setOpcode((UnaryOperator::Opcode)Record[Idx++]);
Sebastian Redlc3632732010-10-05 15:59:54 +0000418 E->setOperatorLoc(ReadSourceLocation(Record, Idx));
Chris Lattner4c6f9522009-04-27 05:14:47 +0000419}
420
Sebastian Redl60adf4a2010-08-18 23:56:52 +0000421void ASTStmtReader::VisitOffsetOfExpr(OffsetOfExpr *E) {
Douglas Gregor8ecdb652010-04-28 22:16:22 +0000422 typedef OffsetOfExpr::OffsetOfNode Node;
423 VisitExpr(E);
424 assert(E->getNumComponents() == Record[Idx]);
425 ++Idx;
426 assert(E->getNumExpressions() == Record[Idx]);
427 ++Idx;
Sebastian Redlc3632732010-10-05 15:59:54 +0000428 E->setOperatorLoc(ReadSourceLocation(Record, Idx));
429 E->setRParenLoc(ReadSourceLocation(Record, Idx));
430 E->setTypeSourceInfo(GetTypeSourceInfo(Record, Idx));
Douglas Gregor8ecdb652010-04-28 22:16:22 +0000431 for (unsigned I = 0, N = E->getNumComponents(); I != N; ++I) {
432 Node::Kind Kind = static_cast<Node::Kind>(Record[Idx++]);
Sebastian Redlc3632732010-10-05 15:59:54 +0000433 SourceLocation Start = ReadSourceLocation(Record, Idx);
434 SourceLocation End = ReadSourceLocation(Record, Idx);
Douglas Gregor8ecdb652010-04-28 22:16:22 +0000435 switch (Kind) {
436 case Node::Array:
437 E->setComponent(I, Node(Start, Record[Idx++], End));
438 break;
439
440 case Node::Field:
Douglas Gregor409448c2011-07-21 22:35:25 +0000441 E->setComponent(I, Node(Start, ReadDeclAs<FieldDecl>(Record, Idx), End));
Douglas Gregor8ecdb652010-04-28 22:16:22 +0000442 break;
443
444 case Node::Identifier:
Douglas Gregor95eab172011-07-28 20:55:49 +0000445 E->setComponent(I,
446 Node(Start,
447 Reader.GetIdentifierInfo(F, Record, Idx),
448 End));
Douglas Gregor8ecdb652010-04-28 22:16:22 +0000449 break;
Douglas Gregorcc8a5d52010-04-29 00:18:15 +0000450
Argyrios Kyrtzidisafbf3122010-07-29 18:16:10 +0000451 case Node::Base: {
Douglas Gregor35942772011-09-09 21:34:22 +0000452 CXXBaseSpecifier *Base = new (Reader.getContext()) CXXBaseSpecifier();
Sebastian Redlc3632732010-10-05 15:59:54 +0000453 *Base = Reader.ReadCXXBaseSpecifier(F, Record, Idx);
Argyrios Kyrtzidisafbf3122010-07-29 18:16:10 +0000454 E->setComponent(I, Node(Base));
Douglas Gregorcc8a5d52010-04-29 00:18:15 +0000455 break;
Douglas Gregor8ecdb652010-04-28 22:16:22 +0000456 }
Argyrios Kyrtzidisafbf3122010-07-29 18:16:10 +0000457 }
Douglas Gregor8ecdb652010-04-28 22:16:22 +0000458 }
459
460 for (unsigned I = 0, N = E->getNumExpressions(); I != N; ++I)
Argyrios Kyrtzidisd98a2ab2010-06-29 22:46:25 +0000461 E->setIndexExpr(I, Reader.ReadSubExpr());
Douglas Gregor8ecdb652010-04-28 22:16:22 +0000462}
463
Peter Collingbournef4e3cfb2011-03-11 19:24:49 +0000464void ASTStmtReader::VisitUnaryExprOrTypeTraitExpr(UnaryExprOrTypeTraitExpr *E) {
Chris Lattner4c6f9522009-04-27 05:14:47 +0000465 VisitExpr(E);
Peter Collingbournef4e3cfb2011-03-11 19:24:49 +0000466 E->setKind(static_cast<UnaryExprOrTypeTrait>(Record[Idx++]));
Chris Lattner4c6f9522009-04-27 05:14:47 +0000467 if (Record[Idx] == 0) {
Argyrios Kyrtzidisd98a2ab2010-06-29 22:46:25 +0000468 E->setArgument(Reader.ReadSubExpr());
Chris Lattner4c6f9522009-04-27 05:14:47 +0000469 ++Idx;
470 } else {
Sebastian Redlc3632732010-10-05 15:59:54 +0000471 E->setArgument(GetTypeSourceInfo(Record, Idx));
Chris Lattner4c6f9522009-04-27 05:14:47 +0000472 }
Sebastian Redlc3632732010-10-05 15:59:54 +0000473 E->setOperatorLoc(ReadSourceLocation(Record, Idx));
474 E->setRParenLoc(ReadSourceLocation(Record, Idx));
Chris Lattner4c6f9522009-04-27 05:14:47 +0000475}
476
Sebastian Redl60adf4a2010-08-18 23:56:52 +0000477void ASTStmtReader::VisitArraySubscriptExpr(ArraySubscriptExpr *E) {
Chris Lattner4c6f9522009-04-27 05:14:47 +0000478 VisitExpr(E);
Argyrios Kyrtzidisd98a2ab2010-06-29 22:46:25 +0000479 E->setLHS(Reader.ReadSubExpr());
480 E->setRHS(Reader.ReadSubExpr());
Sebastian Redlc3632732010-10-05 15:59:54 +0000481 E->setRBracketLoc(ReadSourceLocation(Record, Idx));
Chris Lattner4c6f9522009-04-27 05:14:47 +0000482}
483
Sebastian Redl60adf4a2010-08-18 23:56:52 +0000484void ASTStmtReader::VisitCallExpr(CallExpr *E) {
Chris Lattner4c6f9522009-04-27 05:14:47 +0000485 VisitExpr(E);
Douglas Gregor35942772011-09-09 21:34:22 +0000486 E->setNumArgs(Reader.getContext(), Record[Idx++]);
Sebastian Redlc3632732010-10-05 15:59:54 +0000487 E->setRParenLoc(ReadSourceLocation(Record, Idx));
Argyrios Kyrtzidisd98a2ab2010-06-29 22:46:25 +0000488 E->setCallee(Reader.ReadSubExpr());
Chris Lattner4c6f9522009-04-27 05:14:47 +0000489 for (unsigned I = 0, N = E->getNumArgs(); I != N; ++I)
Argyrios Kyrtzidisd98a2ab2010-06-29 22:46:25 +0000490 E->setArg(I, Reader.ReadSubExpr());
Chris Lattner4c6f9522009-04-27 05:14:47 +0000491}
492
John McCall7110fd62011-07-15 07:00:14 +0000493void ASTStmtReader::VisitCXXMemberCallExpr(CXXMemberCallExpr *E) {
494 VisitCallExpr(E);
495}
496
Sebastian Redl60adf4a2010-08-18 23:56:52 +0000497void ASTStmtReader::VisitMemberExpr(MemberExpr *E) {
Argyrios Kyrtzidis663e3802010-07-08 13:09:47 +0000498 // Don't call VisitExpr, this is fully initialized at creation.
499 assert(E->getStmtClass() == Stmt::MemberExprClass &&
500 "It's a subclass, we must advance Idx!");
Chris Lattner4c6f9522009-04-27 05:14:47 +0000501}
502
Sebastian Redl60adf4a2010-08-18 23:56:52 +0000503void ASTStmtReader::VisitObjCIsaExpr(ObjCIsaExpr *E) {
Steve Narofff242b1b2009-07-24 17:54:45 +0000504 VisitExpr(E);
Argyrios Kyrtzidisd98a2ab2010-06-29 22:46:25 +0000505 E->setBase(Reader.ReadSubExpr());
Sebastian Redlc3632732010-10-05 15:59:54 +0000506 E->setIsaMemberLoc(ReadSourceLocation(Record, Idx));
Steve Narofff242b1b2009-07-24 17:54:45 +0000507 E->setArrow(Record[Idx++]);
Steve Narofff242b1b2009-07-24 17:54:45 +0000508}
509
John McCallf85e1932011-06-15 23:02:42 +0000510void ASTStmtReader::
511VisitObjCIndirectCopyRestoreExpr(ObjCIndirectCopyRestoreExpr *E) {
512 VisitExpr(E);
513 E->Operand = Reader.ReadSubExpr();
514 E->setShouldCopy(Record[Idx++]);
515}
516
517void ASTStmtReader::VisitObjCBridgedCastExpr(ObjCBridgedCastExpr *E) {
518 VisitExplicitCastExpr(E);
519 E->LParenLoc = ReadSourceLocation(Record, Idx);
520 E->BridgeKeywordLoc = ReadSourceLocation(Record, Idx);
521 E->Kind = Record[Idx++];
522}
523
Sebastian Redl60adf4a2010-08-18 23:56:52 +0000524void ASTStmtReader::VisitCastExpr(CastExpr *E) {
Chris Lattner4c6f9522009-04-27 05:14:47 +0000525 VisitExpr(E);
John McCallf871d0c2010-08-07 06:22:56 +0000526 unsigned NumBaseSpecs = Record[Idx++];
527 assert(NumBaseSpecs == E->path_size());
Argyrios Kyrtzidisd98a2ab2010-06-29 22:46:25 +0000528 E->setSubExpr(Reader.ReadSubExpr());
Anders Carlssoncdef2b72009-07-31 00:48:10 +0000529 E->setCastKind((CastExpr::CastKind)Record[Idx++]);
John McCallf871d0c2010-08-07 06:22:56 +0000530 CastExpr::path_iterator BaseI = E->path_begin();
Argyrios Kyrtzidis0745d0a2010-07-02 23:30:27 +0000531 while (NumBaseSpecs--) {
Douglas Gregor35942772011-09-09 21:34:22 +0000532 CXXBaseSpecifier *BaseSpec = new (Reader.getContext()) CXXBaseSpecifier;
Sebastian Redlc3632732010-10-05 15:59:54 +0000533 *BaseSpec = Reader.ReadCXXBaseSpecifier(F, Record, Idx);
John McCallf871d0c2010-08-07 06:22:56 +0000534 *BaseI++ = BaseSpec;
Argyrios Kyrtzidis0745d0a2010-07-02 23:30:27 +0000535 }
Chris Lattner4c6f9522009-04-27 05:14:47 +0000536}
537
Sebastian Redl60adf4a2010-08-18 23:56:52 +0000538void ASTStmtReader::VisitBinaryOperator(BinaryOperator *E) {
Chris Lattner4c6f9522009-04-27 05:14:47 +0000539 VisitExpr(E);
Argyrios Kyrtzidisd98a2ab2010-06-29 22:46:25 +0000540 E->setLHS(Reader.ReadSubExpr());
541 E->setRHS(Reader.ReadSubExpr());
Chris Lattner4c6f9522009-04-27 05:14:47 +0000542 E->setOpcode((BinaryOperator::Opcode)Record[Idx++]);
Sebastian Redlc3632732010-10-05 15:59:54 +0000543 E->setOperatorLoc(ReadSourceLocation(Record, Idx));
Chris Lattner4c6f9522009-04-27 05:14:47 +0000544}
545
Sebastian Redl60adf4a2010-08-18 23:56:52 +0000546void ASTStmtReader::VisitCompoundAssignOperator(CompoundAssignOperator *E) {
Chris Lattner4c6f9522009-04-27 05:14:47 +0000547 VisitBinaryOperator(E);
Douglas Gregor393f2492011-07-22 00:38:23 +0000548 E->setComputationLHSType(Reader.readType(F, Record, Idx));
549 E->setComputationResultType(Reader.readType(F, Record, Idx));
Chris Lattner4c6f9522009-04-27 05:14:47 +0000550}
551
Sebastian Redl60adf4a2010-08-18 23:56:52 +0000552void ASTStmtReader::VisitConditionalOperator(ConditionalOperator *E) {
Chris Lattner4c6f9522009-04-27 05:14:47 +0000553 VisitExpr(E);
John McCall56ca35d2011-02-17 10:25:35 +0000554 E->SubExprs[ConditionalOperator::COND] = Reader.ReadSubExpr();
555 E->SubExprs[ConditionalOperator::LHS] = Reader.ReadSubExpr();
556 E->SubExprs[ConditionalOperator::RHS] = Reader.ReadSubExpr();
557 E->QuestionLoc = ReadSourceLocation(Record, Idx);
558 E->ColonLoc = ReadSourceLocation(Record, Idx);
559}
560
561void
562ASTStmtReader::VisitBinaryConditionalOperator(BinaryConditionalOperator *E) {
563 VisitExpr(E);
564 E->OpaqueValue = cast<OpaqueValueExpr>(Reader.ReadSubExpr());
565 E->SubExprs[BinaryConditionalOperator::COMMON] = Reader.ReadSubExpr();
566 E->SubExprs[BinaryConditionalOperator::COND] = Reader.ReadSubExpr();
567 E->SubExprs[BinaryConditionalOperator::LHS] = Reader.ReadSubExpr();
568 E->SubExprs[BinaryConditionalOperator::RHS] = Reader.ReadSubExpr();
569 E->QuestionLoc = ReadSourceLocation(Record, Idx);
570 E->ColonLoc = ReadSourceLocation(Record, Idx);
Chris Lattner4c6f9522009-04-27 05:14:47 +0000571}
572
Sebastian Redl60adf4a2010-08-18 23:56:52 +0000573void ASTStmtReader::VisitImplicitCastExpr(ImplicitCastExpr *E) {
Chris Lattner4c6f9522009-04-27 05:14:47 +0000574 VisitCastExpr(E);
Chris Lattner4c6f9522009-04-27 05:14:47 +0000575}
576
Sebastian Redl60adf4a2010-08-18 23:56:52 +0000577void ASTStmtReader::VisitExplicitCastExpr(ExplicitCastExpr *E) {
Chris Lattner4c6f9522009-04-27 05:14:47 +0000578 VisitCastExpr(E);
Sebastian Redlc3632732010-10-05 15:59:54 +0000579 E->setTypeInfoAsWritten(GetTypeSourceInfo(Record, Idx));
Chris Lattner4c6f9522009-04-27 05:14:47 +0000580}
581
Sebastian Redl60adf4a2010-08-18 23:56:52 +0000582void ASTStmtReader::VisitCStyleCastExpr(CStyleCastExpr *E) {
Chris Lattner4c6f9522009-04-27 05:14:47 +0000583 VisitExplicitCastExpr(E);
Sebastian Redlc3632732010-10-05 15:59:54 +0000584 E->setLParenLoc(ReadSourceLocation(Record, Idx));
585 E->setRParenLoc(ReadSourceLocation(Record, Idx));
Chris Lattner4c6f9522009-04-27 05:14:47 +0000586}
587
Sebastian Redl60adf4a2010-08-18 23:56:52 +0000588void ASTStmtReader::VisitCompoundLiteralExpr(CompoundLiteralExpr *E) {
Chris Lattner4c6f9522009-04-27 05:14:47 +0000589 VisitExpr(E);
Sebastian Redlc3632732010-10-05 15:59:54 +0000590 E->setLParenLoc(ReadSourceLocation(Record, Idx));
591 E->setTypeSourceInfo(GetTypeSourceInfo(Record, Idx));
Argyrios Kyrtzidisd98a2ab2010-06-29 22:46:25 +0000592 E->setInitializer(Reader.ReadSubExpr());
Chris Lattner4c6f9522009-04-27 05:14:47 +0000593 E->setFileScope(Record[Idx++]);
Chris Lattner4c6f9522009-04-27 05:14:47 +0000594}
595
Sebastian Redl60adf4a2010-08-18 23:56:52 +0000596void ASTStmtReader::VisitExtVectorElementExpr(ExtVectorElementExpr *E) {
Chris Lattner4c6f9522009-04-27 05:14:47 +0000597 VisitExpr(E);
Argyrios Kyrtzidisd98a2ab2010-06-29 22:46:25 +0000598 E->setBase(Reader.ReadSubExpr());
Douglas Gregor95eab172011-07-28 20:55:49 +0000599 E->setAccessor(Reader.GetIdentifierInfo(F, Record, Idx));
Sebastian Redlc3632732010-10-05 15:59:54 +0000600 E->setAccessorLoc(ReadSourceLocation(Record, Idx));
Chris Lattner4c6f9522009-04-27 05:14:47 +0000601}
602
Sebastian Redl60adf4a2010-08-18 23:56:52 +0000603void ASTStmtReader::VisitInitListExpr(InitListExpr *E) {
Chris Lattner4c6f9522009-04-27 05:14:47 +0000604 VisitExpr(E);
Argyrios Kyrtzidisd98a2ab2010-06-29 22:46:25 +0000605 E->setSyntacticForm(cast_or_null<InitListExpr>(Reader.ReadSubStmt()));
Sebastian Redlc3632732010-10-05 15:59:54 +0000606 E->setLBraceLoc(ReadSourceLocation(Record, Idx));
607 E->setRBraceLoc(ReadSourceLocation(Record, Idx));
Argyrios Kyrtzidis2ac0b7a2011-04-22 05:29:30 +0000608 bool isArrayFiller = Record[Idx++];
609 Expr *filler = 0;
610 if (isArrayFiller) {
611 filler = Reader.ReadSubExpr();
612 E->ArrayFillerOrUnionFieldInit = filler;
613 } else
Douglas Gregor409448c2011-07-21 22:35:25 +0000614 E->ArrayFillerOrUnionFieldInit = ReadDeclAs<FieldDecl>(Record, Idx);
Chris Lattner4c6f9522009-04-27 05:14:47 +0000615 E->sawArrayRangeDesignator(Record[Idx++]);
Argyrios Kyrtzidis2ac0b7a2011-04-22 05:29:30 +0000616 unsigned NumInits = Record[Idx++];
Douglas Gregor35942772011-09-09 21:34:22 +0000617 E->reserveInits(Reader.getContext(), NumInits);
Argyrios Kyrtzidis2ac0b7a2011-04-22 05:29:30 +0000618 if (isArrayFiller) {
619 for (unsigned I = 0; I != NumInits; ++I) {
620 Expr *init = Reader.ReadSubExpr();
Douglas Gregor35942772011-09-09 21:34:22 +0000621 E->updateInit(Reader.getContext(), I, init ? init : filler);
Argyrios Kyrtzidis2ac0b7a2011-04-22 05:29:30 +0000622 }
623 } else {
624 for (unsigned I = 0; I != NumInits; ++I)
Douglas Gregor35942772011-09-09 21:34:22 +0000625 E->updateInit(Reader.getContext(), I, Reader.ReadSubExpr());
Argyrios Kyrtzidis2ac0b7a2011-04-22 05:29:30 +0000626 }
Chris Lattner4c6f9522009-04-27 05:14:47 +0000627}
628
Sebastian Redl60adf4a2010-08-18 23:56:52 +0000629void ASTStmtReader::VisitDesignatedInitExpr(DesignatedInitExpr *E) {
Chris Lattner4c6f9522009-04-27 05:14:47 +0000630 typedef DesignatedInitExpr::Designator Designator;
631
632 VisitExpr(E);
633 unsigned NumSubExprs = Record[Idx++];
634 assert(NumSubExprs == E->getNumSubExprs() && "Wrong number of subexprs");
635 for (unsigned I = 0; I != NumSubExprs; ++I)
Argyrios Kyrtzidisd98a2ab2010-06-29 22:46:25 +0000636 E->setSubExpr(I, Reader.ReadSubExpr());
Sebastian Redlc3632732010-10-05 15:59:54 +0000637 E->setEqualOrColonLoc(ReadSourceLocation(Record, Idx));
Chris Lattner4c6f9522009-04-27 05:14:47 +0000638 E->setGNUSyntax(Record[Idx++]);
639
Chris Lattner5f9e2722011-07-23 10:55:15 +0000640 SmallVector<Designator, 4> Designators;
Chris Lattner4c6f9522009-04-27 05:14:47 +0000641 while (Idx < Record.size()) {
Sebastian Redl8538e8d2010-08-18 23:57:32 +0000642 switch ((DesignatorTypes)Record[Idx++]) {
643 case DESIG_FIELD_DECL: {
Douglas Gregor409448c2011-07-21 22:35:25 +0000644 FieldDecl *Field = ReadDeclAs<FieldDecl>(Record, Idx);
Mike Stump1eb44332009-09-09 15:08:12 +0000645 SourceLocation DotLoc
Sebastian Redlc3632732010-10-05 15:59:54 +0000646 = ReadSourceLocation(Record, Idx);
Mike Stump1eb44332009-09-09 15:08:12 +0000647 SourceLocation FieldLoc
Sebastian Redlc3632732010-10-05 15:59:54 +0000648 = ReadSourceLocation(Record, Idx);
Mike Stump1eb44332009-09-09 15:08:12 +0000649 Designators.push_back(Designator(Field->getIdentifier(), DotLoc,
Chris Lattner4c6f9522009-04-27 05:14:47 +0000650 FieldLoc));
651 Designators.back().setField(Field);
652 break;
653 }
654
Sebastian Redl8538e8d2010-08-18 23:57:32 +0000655 case DESIG_FIELD_NAME: {
Douglas Gregor95eab172011-07-28 20:55:49 +0000656 const IdentifierInfo *Name = Reader.GetIdentifierInfo(F, Record, Idx);
Mike Stump1eb44332009-09-09 15:08:12 +0000657 SourceLocation DotLoc
Sebastian Redlc3632732010-10-05 15:59:54 +0000658 = ReadSourceLocation(Record, Idx);
Mike Stump1eb44332009-09-09 15:08:12 +0000659 SourceLocation FieldLoc
Sebastian Redlc3632732010-10-05 15:59:54 +0000660 = ReadSourceLocation(Record, Idx);
Chris Lattner4c6f9522009-04-27 05:14:47 +0000661 Designators.push_back(Designator(Name, DotLoc, FieldLoc));
662 break;
663 }
Mike Stump1eb44332009-09-09 15:08:12 +0000664
Sebastian Redl8538e8d2010-08-18 23:57:32 +0000665 case DESIG_ARRAY: {
Chris Lattner4c6f9522009-04-27 05:14:47 +0000666 unsigned Index = Record[Idx++];
667 SourceLocation LBracketLoc
Sebastian Redlc3632732010-10-05 15:59:54 +0000668 = ReadSourceLocation(Record, Idx);
Chris Lattner4c6f9522009-04-27 05:14:47 +0000669 SourceLocation RBracketLoc
Sebastian Redlc3632732010-10-05 15:59:54 +0000670 = ReadSourceLocation(Record, Idx);
Chris Lattner4c6f9522009-04-27 05:14:47 +0000671 Designators.push_back(Designator(Index, LBracketLoc, RBracketLoc));
672 break;
673 }
674
Sebastian Redl8538e8d2010-08-18 23:57:32 +0000675 case DESIG_ARRAY_RANGE: {
Chris Lattner4c6f9522009-04-27 05:14:47 +0000676 unsigned Index = Record[Idx++];
677 SourceLocation LBracketLoc
Sebastian Redlc3632732010-10-05 15:59:54 +0000678 = ReadSourceLocation(Record, Idx);
Chris Lattner4c6f9522009-04-27 05:14:47 +0000679 SourceLocation EllipsisLoc
Sebastian Redlc3632732010-10-05 15:59:54 +0000680 = ReadSourceLocation(Record, Idx);
Chris Lattner4c6f9522009-04-27 05:14:47 +0000681 SourceLocation RBracketLoc
Sebastian Redlc3632732010-10-05 15:59:54 +0000682 = ReadSourceLocation(Record, Idx);
Chris Lattner4c6f9522009-04-27 05:14:47 +0000683 Designators.push_back(Designator(Index, LBracketLoc, EllipsisLoc,
684 RBracketLoc));
685 break;
686 }
687 }
688 }
Douglas Gregor35942772011-09-09 21:34:22 +0000689 E->setDesignators(Reader.getContext(),
Douglas Gregor319d57f2010-01-06 23:17:19 +0000690 Designators.data(), Designators.size());
Chris Lattner4c6f9522009-04-27 05:14:47 +0000691}
692
Sebastian Redl60adf4a2010-08-18 23:56:52 +0000693void ASTStmtReader::VisitImplicitValueInitExpr(ImplicitValueInitExpr *E) {
Chris Lattner4c6f9522009-04-27 05:14:47 +0000694 VisitExpr(E);
Chris Lattner4c6f9522009-04-27 05:14:47 +0000695}
696
Sebastian Redl60adf4a2010-08-18 23:56:52 +0000697void ASTStmtReader::VisitVAArgExpr(VAArgExpr *E) {
Chris Lattner4c6f9522009-04-27 05:14:47 +0000698 VisitExpr(E);
Argyrios Kyrtzidisd98a2ab2010-06-29 22:46:25 +0000699 E->setSubExpr(Reader.ReadSubExpr());
Sebastian Redlc3632732010-10-05 15:59:54 +0000700 E->setWrittenTypeInfo(GetTypeSourceInfo(Record, Idx));
701 E->setBuiltinLoc(ReadSourceLocation(Record, Idx));
702 E->setRParenLoc(ReadSourceLocation(Record, Idx));
Chris Lattner4c6f9522009-04-27 05:14:47 +0000703}
704
Sebastian Redl60adf4a2010-08-18 23:56:52 +0000705void ASTStmtReader::VisitAddrLabelExpr(AddrLabelExpr *E) {
Chris Lattner4c6f9522009-04-27 05:14:47 +0000706 VisitExpr(E);
Sebastian Redlc3632732010-10-05 15:59:54 +0000707 E->setAmpAmpLoc(ReadSourceLocation(Record, Idx));
708 E->setLabelLoc(ReadSourceLocation(Record, Idx));
Douglas Gregor409448c2011-07-21 22:35:25 +0000709 E->setLabel(ReadDeclAs<LabelDecl>(Record, Idx));
Chris Lattner4c6f9522009-04-27 05:14:47 +0000710}
711
Sebastian Redl60adf4a2010-08-18 23:56:52 +0000712void ASTStmtReader::VisitStmtExpr(StmtExpr *E) {
Chris Lattner4c6f9522009-04-27 05:14:47 +0000713 VisitExpr(E);
Sebastian Redlc3632732010-10-05 15:59:54 +0000714 E->setLParenLoc(ReadSourceLocation(Record, Idx));
715 E->setRParenLoc(ReadSourceLocation(Record, Idx));
Argyrios Kyrtzidisd98a2ab2010-06-29 22:46:25 +0000716 E->setSubStmt(cast_or_null<CompoundStmt>(Reader.ReadSubStmt()));
Chris Lattner4c6f9522009-04-27 05:14:47 +0000717}
718
Sebastian Redl60adf4a2010-08-18 23:56:52 +0000719void ASTStmtReader::VisitChooseExpr(ChooseExpr *E) {
Chris Lattner4c6f9522009-04-27 05:14:47 +0000720 VisitExpr(E);
Argyrios Kyrtzidisd98a2ab2010-06-29 22:46:25 +0000721 E->setCond(Reader.ReadSubExpr());
722 E->setLHS(Reader.ReadSubExpr());
723 E->setRHS(Reader.ReadSubExpr());
Sebastian Redlc3632732010-10-05 15:59:54 +0000724 E->setBuiltinLoc(ReadSourceLocation(Record, Idx));
725 E->setRParenLoc(ReadSourceLocation(Record, Idx));
Chris Lattner4c6f9522009-04-27 05:14:47 +0000726}
727
Sebastian Redl60adf4a2010-08-18 23:56:52 +0000728void ASTStmtReader::VisitGNUNullExpr(GNUNullExpr *E) {
Chris Lattner4c6f9522009-04-27 05:14:47 +0000729 VisitExpr(E);
Sebastian Redlc3632732010-10-05 15:59:54 +0000730 E->setTokenLocation(ReadSourceLocation(Record, Idx));
Chris Lattner4c6f9522009-04-27 05:14:47 +0000731}
732
Sebastian Redl60adf4a2010-08-18 23:56:52 +0000733void ASTStmtReader::VisitShuffleVectorExpr(ShuffleVectorExpr *E) {
Chris Lattner4c6f9522009-04-27 05:14:47 +0000734 VisitExpr(E);
Chris Lattner5f9e2722011-07-23 10:55:15 +0000735 SmallVector<Expr *, 16> Exprs;
Chris Lattner4c6f9522009-04-27 05:14:47 +0000736 unsigned NumExprs = Record[Idx++];
Argyrios Kyrtzidis919e6932010-06-28 22:28:35 +0000737 while (NumExprs--)
Argyrios Kyrtzidisd98a2ab2010-06-29 22:46:25 +0000738 Exprs.push_back(Reader.ReadSubExpr());
Douglas Gregor35942772011-09-09 21:34:22 +0000739 E->setExprs(Reader.getContext(), Exprs.data(), Exprs.size());
Sebastian Redlc3632732010-10-05 15:59:54 +0000740 E->setBuiltinLoc(ReadSourceLocation(Record, Idx));
741 E->setRParenLoc(ReadSourceLocation(Record, Idx));
Chris Lattner4c6f9522009-04-27 05:14:47 +0000742}
743
Sebastian Redl60adf4a2010-08-18 23:56:52 +0000744void ASTStmtReader::VisitBlockExpr(BlockExpr *E) {
Chris Lattner4c6f9522009-04-27 05:14:47 +0000745 VisitExpr(E);
Douglas Gregor409448c2011-07-21 22:35:25 +0000746 E->setBlockDecl(ReadDeclAs<BlockDecl>(Record, Idx));
Chris Lattner4c6f9522009-04-27 05:14:47 +0000747}
748
Sebastian Redl60adf4a2010-08-18 23:56:52 +0000749void ASTStmtReader::VisitBlockDeclRefExpr(BlockDeclRefExpr *E) {
Chris Lattner4c6f9522009-04-27 05:14:47 +0000750 VisitExpr(E);
Douglas Gregor409448c2011-07-21 22:35:25 +0000751 E->setDecl(ReadDeclAs<VarDecl>(Record, Idx));
Sebastian Redlc3632732010-10-05 15:59:54 +0000752 E->setLocation(ReadSourceLocation(Record, Idx));
Chris Lattner4c6f9522009-04-27 05:14:47 +0000753 E->setByRef(Record[Idx++]);
Fariborz Jahanian9b0b57c2009-06-20 00:02:26 +0000754 E->setConstQualAdded(Record[Idx++]);
Chris Lattner4c6f9522009-04-27 05:14:47 +0000755}
756
Peter Collingbournef111d932011-04-15 00:35:48 +0000757void ASTStmtReader::VisitGenericSelectionExpr(GenericSelectionExpr *E) {
758 VisitExpr(E);
759 E->NumAssocs = Record[Idx++];
Douglas Gregor35942772011-09-09 21:34:22 +0000760 E->AssocTypes = new (Reader.getContext()) TypeSourceInfo*[E->NumAssocs];
Peter Collingbournef111d932011-04-15 00:35:48 +0000761 E->SubExprs =
Douglas Gregor35942772011-09-09 21:34:22 +0000762 new(Reader.getContext()) Stmt*[GenericSelectionExpr::END_EXPR+E->NumAssocs];
Peter Collingbournef111d932011-04-15 00:35:48 +0000763
764 E->SubExprs[GenericSelectionExpr::CONTROLLING] = Reader.ReadSubExpr();
765 for (unsigned I = 0, N = E->getNumAssocs(); I != N; ++I) {
766 E->AssocTypes[I] = GetTypeSourceInfo(Record, Idx);
767 E->SubExprs[GenericSelectionExpr::END_EXPR+I] = Reader.ReadSubExpr();
768 }
769 E->ResultIndex = Record[Idx++];
770
771 E->GenericLoc = ReadSourceLocation(Record, Idx);
772 E->DefaultLoc = ReadSourceLocation(Record, Idx);
773 E->RParenLoc = ReadSourceLocation(Record, Idx);
774}
775
John McCall4b9c2d22011-11-06 09:01:30 +0000776void ASTStmtReader::VisitPseudoObjectExpr(PseudoObjectExpr *E) {
777 VisitExpr(E);
778 unsigned numSemanticExprs = Record[Idx++];
779 assert(numSemanticExprs + 1 == E->PseudoObjectExprBits.NumSubExprs);
780 E->PseudoObjectExprBits.ResultIndex = Record[Idx++];
781
782 // Read the syntactic expression.
783 E->getSubExprsBuffer()[0] = Reader.ReadSubExpr();
784
785 // Read all the semantic expressions.
786 for (unsigned i = 0; i != numSemanticExprs; ++i) {
787 Expr *subExpr = Reader.ReadSubExpr();
John McCall4b9c2d22011-11-06 09:01:30 +0000788 E->getSubExprsBuffer()[i+1] = subExpr;
789 }
790}
791
Eli Friedman276b0612011-10-11 02:20:01 +0000792void ASTStmtReader::VisitAtomicExpr(AtomicExpr *E) {
793 VisitExpr(E);
794 E->setOp(AtomicExpr::AtomicOp(Record[Idx++]));
795 E->setPtr(Reader.ReadSubExpr());
796 E->setOrder(Reader.ReadSubExpr());
797 E->setNumSubExprs(2);
798 if (E->getOp() != AtomicExpr::Load) {
799 E->setVal1(Reader.ReadSubExpr());
800 E->setNumSubExprs(3);
801 }
802 if (E->isCmpXChg()) {
803 E->setOrderFail(Reader.ReadSubExpr());
804 E->setVal2(Reader.ReadSubExpr());
805 E->setNumSubExprs(5);
806 }
807 E->setBuiltinLoc(ReadSourceLocation(Record, Idx));
808 E->setRParenLoc(ReadSourceLocation(Record, Idx));
809}
810
Chris Lattner4c6f9522009-04-27 05:14:47 +0000811//===----------------------------------------------------------------------===//
812// Objective-C Expressions and Statements
813
Sebastian Redl60adf4a2010-08-18 23:56:52 +0000814void ASTStmtReader::VisitObjCStringLiteral(ObjCStringLiteral *E) {
Chris Lattner4c6f9522009-04-27 05:14:47 +0000815 VisitExpr(E);
Argyrios Kyrtzidisd98a2ab2010-06-29 22:46:25 +0000816 E->setString(cast<StringLiteral>(Reader.ReadSubStmt()));
Sebastian Redlc3632732010-10-05 15:59:54 +0000817 E->setAtLoc(ReadSourceLocation(Record, Idx));
Chris Lattner4c6f9522009-04-27 05:14:47 +0000818}
819
Sebastian Redl60adf4a2010-08-18 23:56:52 +0000820void ASTStmtReader::VisitObjCEncodeExpr(ObjCEncodeExpr *E) {
Chris Lattner4c6f9522009-04-27 05:14:47 +0000821 VisitExpr(E);
Sebastian Redlc3632732010-10-05 15:59:54 +0000822 E->setEncodedTypeSourceInfo(GetTypeSourceInfo(Record, Idx));
823 E->setAtLoc(ReadSourceLocation(Record, Idx));
824 E->setRParenLoc(ReadSourceLocation(Record, Idx));
Chris Lattner4c6f9522009-04-27 05:14:47 +0000825}
826
Sebastian Redl60adf4a2010-08-18 23:56:52 +0000827void ASTStmtReader::VisitObjCSelectorExpr(ObjCSelectorExpr *E) {
Chris Lattner4c6f9522009-04-27 05:14:47 +0000828 VisitExpr(E);
Douglas Gregor2d2689a2011-07-28 21:16:51 +0000829 E->setSelector(Reader.ReadSelector(F, Record, Idx));
Sebastian Redlc3632732010-10-05 15:59:54 +0000830 E->setAtLoc(ReadSourceLocation(Record, Idx));
831 E->setRParenLoc(ReadSourceLocation(Record, Idx));
Chris Lattner4c6f9522009-04-27 05:14:47 +0000832}
833
Sebastian Redl60adf4a2010-08-18 23:56:52 +0000834void ASTStmtReader::VisitObjCProtocolExpr(ObjCProtocolExpr *E) {
Chris Lattner4c6f9522009-04-27 05:14:47 +0000835 VisitExpr(E);
Douglas Gregor409448c2011-07-21 22:35:25 +0000836 E->setProtocol(ReadDeclAs<ObjCProtocolDecl>(Record, Idx));
Sebastian Redlc3632732010-10-05 15:59:54 +0000837 E->setAtLoc(ReadSourceLocation(Record, Idx));
838 E->setRParenLoc(ReadSourceLocation(Record, Idx));
Chris Lattner4c6f9522009-04-27 05:14:47 +0000839}
840
Sebastian Redl60adf4a2010-08-18 23:56:52 +0000841void ASTStmtReader::VisitObjCIvarRefExpr(ObjCIvarRefExpr *E) {
Chris Lattner4c6f9522009-04-27 05:14:47 +0000842 VisitExpr(E);
Douglas Gregor409448c2011-07-21 22:35:25 +0000843 E->setDecl(ReadDeclAs<ObjCIvarDecl>(Record, Idx));
Sebastian Redlc3632732010-10-05 15:59:54 +0000844 E->setLocation(ReadSourceLocation(Record, Idx));
Argyrios Kyrtzidisd98a2ab2010-06-29 22:46:25 +0000845 E->setBase(Reader.ReadSubExpr());
Chris Lattner4c6f9522009-04-27 05:14:47 +0000846 E->setIsArrow(Record[Idx++]);
847 E->setIsFreeIvar(Record[Idx++]);
Chris Lattner4c6f9522009-04-27 05:14:47 +0000848}
849
Sebastian Redl60adf4a2010-08-18 23:56:52 +0000850void ASTStmtReader::VisitObjCPropertyRefExpr(ObjCPropertyRefExpr *E) {
Chris Lattner4c6f9522009-04-27 05:14:47 +0000851 VisitExpr(E);
John McCall12f78a62010-12-02 01:19:52 +0000852 bool Implicit = Record[Idx++] != 0;
853 if (Implicit) {
Douglas Gregor409448c2011-07-21 22:35:25 +0000854 ObjCMethodDecl *Getter = ReadDeclAs<ObjCMethodDecl>(Record, Idx);
855 ObjCMethodDecl *Setter = ReadDeclAs<ObjCMethodDecl>(Record, Idx);
John McCall12f78a62010-12-02 01:19:52 +0000856 E->setImplicitProperty(Getter, Setter);
857 } else {
Douglas Gregor409448c2011-07-21 22:35:25 +0000858 E->setExplicitProperty(ReadDeclAs<ObjCPropertyDecl>(Record, Idx));
Fariborz Jahanian8ac2d442010-10-14 16:04:05 +0000859 }
Sebastian Redlc3632732010-10-05 15:59:54 +0000860 E->setLocation(ReadSourceLocation(Record, Idx));
John McCall12f78a62010-12-02 01:19:52 +0000861 E->setReceiverLocation(ReadSourceLocation(Record, Idx));
862 switch (Record[Idx++]) {
863 case 0:
864 E->setBase(Reader.ReadSubExpr());
865 break;
866 case 1:
Douglas Gregor393f2492011-07-22 00:38:23 +0000867 E->setSuperReceiver(Reader.readType(F, Record, Idx));
John McCall12f78a62010-12-02 01:19:52 +0000868 break;
869 case 2:
Douglas Gregor409448c2011-07-21 22:35:25 +0000870 E->setClassReceiver(ReadDeclAs<ObjCInterfaceDecl>(Record, Idx));
John McCall12f78a62010-12-02 01:19:52 +0000871 break;
872 }
Chris Lattner4c6f9522009-04-27 05:14:47 +0000873}
874
Sebastian Redl60adf4a2010-08-18 23:56:52 +0000875void ASTStmtReader::VisitObjCMessageExpr(ObjCMessageExpr *E) {
Chris Lattner4c6f9522009-04-27 05:14:47 +0000876 VisitExpr(E);
Douglas Gregor04badcf2010-04-21 00:45:42 +0000877 assert(Record[Idx] == E->getNumArgs());
878 ++Idx;
Argyrios Kyrtzidis20718082011-10-03 06:36:51 +0000879 unsigned NumStoredSelLocs = Record[Idx++];
880 E->SelLocsKind = Record[Idx++];
John McCallf85e1932011-06-15 23:02:42 +0000881 E->setDelegateInitCall(Record[Idx++]);
Argyrios Kyrtzidis746f5bc2012-01-12 02:34:39 +0000882 E->IsImplicit = Record[Idx++];
Douglas Gregor04badcf2010-04-21 00:45:42 +0000883 ObjCMessageExpr::ReceiverKind Kind
884 = static_cast<ObjCMessageExpr::ReceiverKind>(Record[Idx++]);
885 switch (Kind) {
886 case ObjCMessageExpr::Instance:
Argyrios Kyrtzidisd98a2ab2010-06-29 22:46:25 +0000887 E->setInstanceReceiver(Reader.ReadSubExpr());
Douglas Gregor04badcf2010-04-21 00:45:42 +0000888 break;
889
890 case ObjCMessageExpr::Class:
Sebastian Redlc3632732010-10-05 15:59:54 +0000891 E->setClassReceiver(GetTypeSourceInfo(Record, Idx));
Douglas Gregor04badcf2010-04-21 00:45:42 +0000892 break;
893
894 case ObjCMessageExpr::SuperClass:
895 case ObjCMessageExpr::SuperInstance: {
Douglas Gregor393f2492011-07-22 00:38:23 +0000896 QualType T = Reader.readType(F, Record, Idx);
Sebastian Redlc3632732010-10-05 15:59:54 +0000897 SourceLocation SuperLoc = ReadSourceLocation(Record, Idx);
Douglas Gregor04badcf2010-04-21 00:45:42 +0000898 E->setSuper(SuperLoc, T, Kind == ObjCMessageExpr::SuperInstance);
899 break;
900 }
901 }
902
903 assert(Kind == E->getReceiverKind());
904
905 if (Record[Idx++])
Douglas Gregor409448c2011-07-21 22:35:25 +0000906 E->setMethodDecl(ReadDeclAs<ObjCMethodDecl>(Record, Idx));
Douglas Gregor04badcf2010-04-21 00:45:42 +0000907 else
Douglas Gregor2d2689a2011-07-28 21:16:51 +0000908 E->setSelector(Reader.ReadSelector(F, Record, Idx));
Douglas Gregor04badcf2010-04-21 00:45:42 +0000909
Argyrios Kyrtzidisf40f0d52010-12-10 20:08:27 +0000910 E->LBracLoc = ReadSourceLocation(Record, Idx);
911 E->RBracLoc = ReadSourceLocation(Record, Idx);
Chris Lattner4c6f9522009-04-27 05:14:47 +0000912
913 for (unsigned I = 0, N = E->getNumArgs(); I != N; ++I)
Argyrios Kyrtzidisd98a2ab2010-06-29 22:46:25 +0000914 E->setArg(I, Reader.ReadSubExpr());
Argyrios Kyrtzidis20718082011-10-03 06:36:51 +0000915
916 SourceLocation *Locs = E->getStoredSelLocs();
917 for (unsigned I = 0; I != NumStoredSelLocs; ++I)
918 Locs[I] = ReadSourceLocation(Record, Idx);
Chris Lattner4c6f9522009-04-27 05:14:47 +0000919}
920
Sebastian Redl60adf4a2010-08-18 23:56:52 +0000921void ASTStmtReader::VisitObjCForCollectionStmt(ObjCForCollectionStmt *S) {
Chris Lattner4c6f9522009-04-27 05:14:47 +0000922 VisitStmt(S);
Argyrios Kyrtzidisd98a2ab2010-06-29 22:46:25 +0000923 S->setElement(Reader.ReadSubStmt());
924 S->setCollection(Reader.ReadSubExpr());
925 S->setBody(Reader.ReadSubStmt());
Sebastian Redlc3632732010-10-05 15:59:54 +0000926 S->setForLoc(ReadSourceLocation(Record, Idx));
927 S->setRParenLoc(ReadSourceLocation(Record, Idx));
Chris Lattner4c6f9522009-04-27 05:14:47 +0000928}
929
Sebastian Redl60adf4a2010-08-18 23:56:52 +0000930void ASTStmtReader::VisitObjCAtCatchStmt(ObjCAtCatchStmt *S) {
Chris Lattner4c6f9522009-04-27 05:14:47 +0000931 VisitStmt(S);
Argyrios Kyrtzidisd98a2ab2010-06-29 22:46:25 +0000932 S->setCatchBody(Reader.ReadSubStmt());
Douglas Gregor409448c2011-07-21 22:35:25 +0000933 S->setCatchParamDecl(ReadDeclAs<VarDecl>(Record, Idx));
Sebastian Redlc3632732010-10-05 15:59:54 +0000934 S->setAtCatchLoc(ReadSourceLocation(Record, Idx));
935 S->setRParenLoc(ReadSourceLocation(Record, Idx));
Chris Lattner4c6f9522009-04-27 05:14:47 +0000936}
937
Sebastian Redl60adf4a2010-08-18 23:56:52 +0000938void ASTStmtReader::VisitObjCAtFinallyStmt(ObjCAtFinallyStmt *S) {
Chris Lattner4c6f9522009-04-27 05:14:47 +0000939 VisitStmt(S);
Argyrios Kyrtzidisd98a2ab2010-06-29 22:46:25 +0000940 S->setFinallyBody(Reader.ReadSubStmt());
Sebastian Redlc3632732010-10-05 15:59:54 +0000941 S->setAtFinallyLoc(ReadSourceLocation(Record, Idx));
Chris Lattner4c6f9522009-04-27 05:14:47 +0000942}
943
John McCallf85e1932011-06-15 23:02:42 +0000944void ASTStmtReader::VisitObjCAutoreleasePoolStmt(ObjCAutoreleasePoolStmt *S) {
945 VisitStmt(S);
946 S->setSubStmt(Reader.ReadSubStmt());
947 S->setAtLoc(ReadSourceLocation(Record, Idx));
948}
949
Sebastian Redl60adf4a2010-08-18 23:56:52 +0000950void ASTStmtReader::VisitObjCAtTryStmt(ObjCAtTryStmt *S) {
Chris Lattner4c6f9522009-04-27 05:14:47 +0000951 VisitStmt(S);
Douglas Gregor8f5e3dd2010-04-23 22:50:49 +0000952 assert(Record[Idx] == S->getNumCatchStmts());
953 ++Idx;
954 bool HasFinally = Record[Idx++];
Argyrios Kyrtzidisd98a2ab2010-06-29 22:46:25 +0000955 S->setTryBody(Reader.ReadSubStmt());
Argyrios Kyrtzidis919e6932010-06-28 22:28:35 +0000956 for (unsigned I = 0, N = S->getNumCatchStmts(); I != N; ++I)
Argyrios Kyrtzidisd98a2ab2010-06-29 22:46:25 +0000957 S->setCatchStmt(I, cast_or_null<ObjCAtCatchStmt>(Reader.ReadSubStmt()));
Douglas Gregor8f5e3dd2010-04-23 22:50:49 +0000958
Douglas Gregor8f5e3dd2010-04-23 22:50:49 +0000959 if (HasFinally)
Argyrios Kyrtzidisd98a2ab2010-06-29 22:46:25 +0000960 S->setFinallyStmt(Reader.ReadSubStmt());
Sebastian Redlc3632732010-10-05 15:59:54 +0000961 S->setAtTryLoc(ReadSourceLocation(Record, Idx));
Chris Lattner4c6f9522009-04-27 05:14:47 +0000962}
963
Sebastian Redl60adf4a2010-08-18 23:56:52 +0000964void ASTStmtReader::VisitObjCAtSynchronizedStmt(ObjCAtSynchronizedStmt *S) {
Chris Lattner4c6f9522009-04-27 05:14:47 +0000965 VisitStmt(S);
Argyrios Kyrtzidisd98a2ab2010-06-29 22:46:25 +0000966 S->setSynchExpr(Reader.ReadSubStmt());
967 S->setSynchBody(Reader.ReadSubStmt());
Sebastian Redlc3632732010-10-05 15:59:54 +0000968 S->setAtSynchronizedLoc(ReadSourceLocation(Record, Idx));
Chris Lattner4c6f9522009-04-27 05:14:47 +0000969}
970
Sebastian Redl60adf4a2010-08-18 23:56:52 +0000971void ASTStmtReader::VisitObjCAtThrowStmt(ObjCAtThrowStmt *S) {
Chris Lattner4c6f9522009-04-27 05:14:47 +0000972 VisitStmt(S);
Argyrios Kyrtzidisd98a2ab2010-06-29 22:46:25 +0000973 S->setThrowExpr(Reader.ReadSubStmt());
Sebastian Redlc3632732010-10-05 15:59:54 +0000974 S->setThrowLoc(ReadSourceLocation(Record, Idx));
Chris Lattner4c6f9522009-04-27 05:14:47 +0000975}
976
Argyrios Kyrtzidisba0a9002009-07-14 03:19:21 +0000977//===----------------------------------------------------------------------===//
978// C++ Expressions and Statements
Argyrios Kyrtzidis7cb45e32010-07-22 16:03:56 +0000979//===----------------------------------------------------------------------===//
980
Sebastian Redl60adf4a2010-08-18 23:56:52 +0000981void ASTStmtReader::VisitCXXCatchStmt(CXXCatchStmt *S) {
Argyrios Kyrtzidis7cb45e32010-07-22 16:03:56 +0000982 VisitStmt(S);
Sebastian Redlc3632732010-10-05 15:59:54 +0000983 S->CatchLoc = ReadSourceLocation(Record, Idx);
Douglas Gregor409448c2011-07-21 22:35:25 +0000984 S->ExceptionDecl = ReadDeclAs<VarDecl>(Record, Idx);
Argyrios Kyrtzidis7cb45e32010-07-22 16:03:56 +0000985 S->HandlerBlock = Reader.ReadSubStmt();
986}
987
Sebastian Redl60adf4a2010-08-18 23:56:52 +0000988void ASTStmtReader::VisitCXXTryStmt(CXXTryStmt *S) {
Argyrios Kyrtzidis7cb45e32010-07-22 16:03:56 +0000989 VisitStmt(S);
990 assert(Record[Idx] == S->getNumHandlers() && "NumStmtFields is wrong ?");
991 ++Idx;
Sebastian Redlc3632732010-10-05 15:59:54 +0000992 S->TryLoc = ReadSourceLocation(Record, Idx);
Argyrios Kyrtzidis7cb45e32010-07-22 16:03:56 +0000993 S->getStmts()[0] = Reader.ReadSubStmt();
994 for (unsigned i = 0, e = S->getNumHandlers(); i != e; ++i)
995 S->getStmts()[i + 1] = Reader.ReadSubStmt();
996}
Argyrios Kyrtzidisba0a9002009-07-14 03:19:21 +0000997
Richard Smithad762fc2011-04-14 22:09:26 +0000998void ASTStmtReader::VisitCXXForRangeStmt(CXXForRangeStmt *S) {
999 VisitStmt(S);
1000 S->setForLoc(ReadSourceLocation(Record, Idx));
1001 S->setColonLoc(ReadSourceLocation(Record, Idx));
1002 S->setRParenLoc(ReadSourceLocation(Record, Idx));
1003 S->setRangeStmt(Reader.ReadSubStmt());
1004 S->setBeginEndStmt(Reader.ReadSubStmt());
1005 S->setCond(Reader.ReadSubExpr());
1006 S->setInc(Reader.ReadSubExpr());
1007 S->setLoopVarStmt(Reader.ReadSubStmt());
1008 S->setBody(Reader.ReadSubStmt());
1009}
1010
Douglas Gregorba0513d2011-10-25 01:33:02 +00001011void ASTStmtReader::VisitMSDependentExistsStmt(MSDependentExistsStmt *S) {
1012 VisitStmt(S);
1013 S->KeywordLoc = ReadSourceLocation(Record, Idx);
1014 S->IsIfExists = Record[Idx++];
1015 S->QualifierLoc = Reader.ReadNestedNameSpecifierLoc(F, Record, Idx);
1016 ReadDeclarationNameInfo(S->NameInfo, Record, Idx);
1017 S->SubStmt = Reader.ReadSubStmt();
1018}
1019
Sebastian Redl60adf4a2010-08-18 23:56:52 +00001020void ASTStmtReader::VisitCXXOperatorCallExpr(CXXOperatorCallExpr *E) {
Argyrios Kyrtzidis919e6932010-06-28 22:28:35 +00001021 VisitCallExpr(E);
Argyrios Kyrtzidisba0a9002009-07-14 03:19:21 +00001022 E->setOperator((OverloadedOperatorKind)Record[Idx++]);
Argyrios Kyrtzidisba0a9002009-07-14 03:19:21 +00001023}
1024
Sebastian Redl60adf4a2010-08-18 23:56:52 +00001025void ASTStmtReader::VisitCXXConstructExpr(CXXConstructExpr *E) {
Douglas Gregor39da0b82009-09-09 23:08:42 +00001026 VisitExpr(E);
Argyrios Kyrtzidis6d00c132010-07-10 11:46:15 +00001027 E->NumArgs = Record[Idx++];
1028 if (E->NumArgs)
Douglas Gregor35942772011-09-09 21:34:22 +00001029 E->Args = new (Reader.getContext()) Stmt*[E->NumArgs];
Argyrios Kyrtzidis5e1b7c22010-06-24 08:57:09 +00001030 for (unsigned I = 0, N = E->getNumArgs(); I != N; ++I)
Argyrios Kyrtzidisd98a2ab2010-06-29 22:46:25 +00001031 E->setArg(I, Reader.ReadSubExpr());
Douglas Gregor409448c2011-07-21 22:35:25 +00001032 E->setConstructor(ReadDeclAs<CXXConstructorDecl>(Record, Idx));
Sebastian Redlc3632732010-10-05 15:59:54 +00001033 E->setLocation(ReadSourceLocation(Record, Idx));
Abramo Bagnara7cc58b42011-10-05 07:56:41 +00001034 E->setElidable(Record[Idx++]);
1035 E->setHadMultipleCandidates(Record[Idx++]);
Douglas Gregor16006c92009-12-16 18:50:27 +00001036 E->setRequiresZeroInitialization(Record[Idx++]);
Douglas Gregor3c9034c2010-05-15 00:13:29 +00001037 E->setConstructionKind((CXXConstructExpr::ConstructionKind)Record[Idx++]);
Chandler Carruth428edaf2010-10-25 08:47:36 +00001038 E->ParenRange = ReadSourceRange(Record, Idx);
Douglas Gregor39da0b82009-09-09 23:08:42 +00001039}
Chris Lattner4c6f9522009-04-27 05:14:47 +00001040
Sebastian Redl60adf4a2010-08-18 23:56:52 +00001041void ASTStmtReader::VisitCXXTemporaryObjectExpr(CXXTemporaryObjectExpr *E) {
Argyrios Kyrtzidis6d00c132010-07-10 11:46:15 +00001042 VisitCXXConstructExpr(E);
Sebastian Redlc3632732010-10-05 15:59:54 +00001043 E->Type = GetTypeSourceInfo(Record, Idx);
Argyrios Kyrtzidis6d00c132010-07-10 11:46:15 +00001044}
1045
Sebastian Redl60adf4a2010-08-18 23:56:52 +00001046void ASTStmtReader::VisitCXXNamedCastExpr(CXXNamedCastExpr *E) {
Argyrios Kyrtzidis919e6932010-06-28 22:28:35 +00001047 VisitExplicitCastExpr(E);
Douglas Gregor1d5d0b92011-01-12 22:41:29 +00001048 SourceRange R = ReadSourceRange(Record, Idx);
1049 E->Loc = R.getBegin();
1050 E->RParenLoc = R.getEnd();
Sam Weinigce757a72010-01-16 21:21:01 +00001051}
1052
Sebastian Redl60adf4a2010-08-18 23:56:52 +00001053void ASTStmtReader::VisitCXXStaticCastExpr(CXXStaticCastExpr *E) {
Sam Weinigce757a72010-01-16 21:21:01 +00001054 return VisitCXXNamedCastExpr(E);
1055}
1056
Sebastian Redl60adf4a2010-08-18 23:56:52 +00001057void ASTStmtReader::VisitCXXDynamicCastExpr(CXXDynamicCastExpr *E) {
Sam Weinigce757a72010-01-16 21:21:01 +00001058 return VisitCXXNamedCastExpr(E);
1059}
1060
Sebastian Redl60adf4a2010-08-18 23:56:52 +00001061void ASTStmtReader::VisitCXXReinterpretCastExpr(CXXReinterpretCastExpr *E) {
Sam Weinigce757a72010-01-16 21:21:01 +00001062 return VisitCXXNamedCastExpr(E);
1063}
1064
Sebastian Redl60adf4a2010-08-18 23:56:52 +00001065void ASTStmtReader::VisitCXXConstCastExpr(CXXConstCastExpr *E) {
Sam Weinigce757a72010-01-16 21:21:01 +00001066 return VisitCXXNamedCastExpr(E);
1067}
1068
Sebastian Redl60adf4a2010-08-18 23:56:52 +00001069void ASTStmtReader::VisitCXXFunctionalCastExpr(CXXFunctionalCastExpr *E) {
Argyrios Kyrtzidis919e6932010-06-28 22:28:35 +00001070 VisitExplicitCastExpr(E);
Sebastian Redlc3632732010-10-05 15:59:54 +00001071 E->setTypeBeginLoc(ReadSourceLocation(Record, Idx));
1072 E->setRParenLoc(ReadSourceLocation(Record, Idx));
Sam Weinigce757a72010-01-16 21:21:01 +00001073}
1074
Sebastian Redl60adf4a2010-08-18 23:56:52 +00001075void ASTStmtReader::VisitCXXBoolLiteralExpr(CXXBoolLiteralExpr *E) {
Sam Weinigeb7f9612010-02-07 06:32:43 +00001076 VisitExpr(E);
1077 E->setValue(Record[Idx++]);
Sebastian Redlc3632732010-10-05 15:59:54 +00001078 E->setLocation(ReadSourceLocation(Record, Idx));
Sam Weinigeb7f9612010-02-07 06:32:43 +00001079}
1080
Sebastian Redl60adf4a2010-08-18 23:56:52 +00001081void ASTStmtReader::VisitCXXNullPtrLiteralExpr(CXXNullPtrLiteralExpr *E) {
Sam Weinigeb7f9612010-02-07 06:32:43 +00001082 VisitExpr(E);
Sebastian Redlc3632732010-10-05 15:59:54 +00001083 E->setLocation(ReadSourceLocation(Record, Idx));
Sam Weinigeb7f9612010-02-07 06:32:43 +00001084}
1085
Sebastian Redl60adf4a2010-08-18 23:56:52 +00001086void ASTStmtReader::VisitCXXTypeidExpr(CXXTypeidExpr *E) {
Chris Lattner14ab24f2010-05-09 06:03:39 +00001087 VisitExpr(E);
Sebastian Redlc3632732010-10-05 15:59:54 +00001088 E->setSourceRange(ReadSourceRange(Record, Idx));
Chris Lattner14ab24f2010-05-09 06:03:39 +00001089 if (E->isTypeOperand()) { // typeid(int)
Sebastian Redl577d4792010-07-22 22:43:28 +00001090 E->setTypeOperandSourceInfo(
Sebastian Redlc3632732010-10-05 15:59:54 +00001091 GetTypeSourceInfo(Record, Idx));
Argyrios Kyrtzidis919e6932010-06-28 22:28:35 +00001092 return;
Chris Lattner14ab24f2010-05-09 06:03:39 +00001093 }
1094
1095 // typeid(42+2)
Argyrios Kyrtzidisd98a2ab2010-06-29 22:46:25 +00001096 E->setExprOperand(Reader.ReadSubExpr());
Chris Lattner14ab24f2010-05-09 06:03:39 +00001097}
1098
Sebastian Redl60adf4a2010-08-18 23:56:52 +00001099void ASTStmtReader::VisitCXXThisExpr(CXXThisExpr *E) {
Chris Lattner2fbdfcd2010-05-09 06:15:05 +00001100 VisitExpr(E);
Sebastian Redlc3632732010-10-05 15:59:54 +00001101 E->setLocation(ReadSourceLocation(Record, Idx));
Chris Lattner2fbdfcd2010-05-09 06:15:05 +00001102 E->setImplicit(Record[Idx++]);
Chris Lattner2fbdfcd2010-05-09 06:15:05 +00001103}
1104
Sebastian Redl60adf4a2010-08-18 23:56:52 +00001105void ASTStmtReader::VisitCXXThrowExpr(CXXThrowExpr *E) {
Chris Lattner2fbdfcd2010-05-09 06:15:05 +00001106 VisitExpr(E);
Douglas Gregorbca01b42011-07-06 22:04:06 +00001107 E->ThrowLoc = ReadSourceLocation(Record, Idx);
1108 E->Op = Reader.ReadSubExpr();
1109 E->IsThrownVariableInScope = Record[Idx++];
Chris Lattner2fbdfcd2010-05-09 06:15:05 +00001110}
Chris Lattner14ab24f2010-05-09 06:03:39 +00001111
Sebastian Redl60adf4a2010-08-18 23:56:52 +00001112void ASTStmtReader::VisitCXXDefaultArgExpr(CXXDefaultArgExpr *E) {
Chris Lattner030854b2010-05-09 06:40:08 +00001113 VisitExpr(E);
Argyrios Kyrtzidis8a507332010-07-02 23:30:15 +00001114
Douglas Gregordf226552011-09-23 22:07:41 +00001115 assert((bool)Record[Idx] == E->Param.getInt() && "We messed up at creation ?");
Argyrios Kyrtzidis8a507332010-07-02 23:30:15 +00001116 ++Idx; // HasOtherExprStored and SubExpr was handled during creation.
Douglas Gregor409448c2011-07-21 22:35:25 +00001117 E->Param.setPointer(ReadDeclAs<ParmVarDecl>(Record, Idx));
Sebastian Redlc3632732010-10-05 15:59:54 +00001118 E->Loc = ReadSourceLocation(Record, Idx);
Chris Lattnerd2598362010-05-10 00:25:06 +00001119}
1120
Sebastian Redl60adf4a2010-08-18 23:56:52 +00001121void ASTStmtReader::VisitCXXBindTemporaryExpr(CXXBindTemporaryExpr *E) {
Chris Lattnerd2598362010-05-10 00:25:06 +00001122 VisitExpr(E);
Douglas Gregor409448c2011-07-21 22:35:25 +00001123 E->setTemporary(Reader.ReadCXXTemporary(F, Record, Idx));
Argyrios Kyrtzidisd98a2ab2010-06-29 22:46:25 +00001124 E->setSubExpr(Reader.ReadSubExpr());
Chris Lattnerd2598362010-05-10 00:25:06 +00001125}
1126
Sebastian Redl60adf4a2010-08-18 23:56:52 +00001127void ASTStmtReader::VisitCXXScalarValueInitExpr(CXXScalarValueInitExpr *E) {
Chris Lattner59218632010-05-10 01:22:27 +00001128 VisitExpr(E);
Sebastian Redlc3632732010-10-05 15:59:54 +00001129 E->TypeInfo = GetTypeSourceInfo(Record, Idx);
1130 E->RParenLoc = ReadSourceLocation(Record, Idx);
Chris Lattner59218632010-05-10 01:22:27 +00001131}
1132
Sebastian Redl60adf4a2010-08-18 23:56:52 +00001133void ASTStmtReader::VisitCXXNewExpr(CXXNewExpr *E) {
Chris Lattner59218632010-05-10 01:22:27 +00001134 VisitExpr(E);
John McCall6ec278d2011-01-27 09:37:56 +00001135 E->GlobalNew = Record[Idx++];
1136 E->Initializer = Record[Idx++];
1137 E->UsualArrayDeleteWantsSize = Record[Idx++];
Chris Lattner59218632010-05-10 01:22:27 +00001138 bool isArray = Record[Idx++];
Abramo Bagnara7cc58b42011-10-05 07:56:41 +00001139 E->setHadMultipleCandidates(Record[Idx++]);
Chris Lattner59218632010-05-10 01:22:27 +00001140 unsigned NumPlacementArgs = Record[Idx++];
1141 unsigned NumCtorArgs = Record[Idx++];
Douglas Gregor409448c2011-07-21 22:35:25 +00001142 E->setOperatorNew(ReadDeclAs<FunctionDecl>(Record, Idx));
1143 E->setOperatorDelete(ReadDeclAs<FunctionDecl>(Record, Idx));
1144 E->setConstructor(ReadDeclAs<CXXConstructorDecl>(Record, Idx));
Sebastian Redlc3632732010-10-05 15:59:54 +00001145 E->AllocatedTypeInfo = GetTypeSourceInfo(Record, Idx);
Douglas Gregor4bd40312010-07-13 15:54:32 +00001146 SourceRange TypeIdParens;
Sebastian Redlc3632732010-10-05 15:59:54 +00001147 TypeIdParens.setBegin(ReadSourceLocation(Record, Idx));
1148 TypeIdParens.setEnd(ReadSourceLocation(Record, Idx));
Douglas Gregor4bd40312010-07-13 15:54:32 +00001149 E->TypeIdParens = TypeIdParens;
Chandler Carruth428edaf2010-10-25 08:47:36 +00001150 E->StartLoc = ReadSourceLocation(Record, Idx);
1151 E->EndLoc = ReadSourceLocation(Record, Idx);
1152 E->ConstructorLParen = ReadSourceLocation(Record, Idx);
1153 E->ConstructorRParen = ReadSourceLocation(Record, Idx);
1154
Douglas Gregor35942772011-09-09 21:34:22 +00001155 E->AllocateArgsArray(Reader.getContext(), isArray, NumPlacementArgs,
Chris Lattner59218632010-05-10 01:22:27 +00001156 NumCtorArgs);
1157
1158 // Install all the subexpressions.
Chris Lattner59218632010-05-10 01:22:27 +00001159 for (CXXNewExpr::raw_arg_iterator I = E->raw_arg_begin(),e = E->raw_arg_end();
1160 I != e; ++I)
Argyrios Kyrtzidisd98a2ab2010-06-29 22:46:25 +00001161 *I = Reader.ReadSubStmt();
Chris Lattner59218632010-05-10 01:22:27 +00001162}
1163
Sebastian Redl60adf4a2010-08-18 23:56:52 +00001164void ASTStmtReader::VisitCXXDeleteExpr(CXXDeleteExpr *E) {
Argyrios Kyrtzidis95fc98c2010-06-22 17:07:59 +00001165 VisitExpr(E);
Argyrios Kyrtzidisf1b89112010-09-13 20:15:40 +00001166 E->GlobalDelete = Record[Idx++];
1167 E->ArrayForm = Record[Idx++];
Argyrios Kyrtzidis4076dac2010-09-13 20:15:54 +00001168 E->ArrayFormAsWritten = Record[Idx++];
John McCall6ec278d2011-01-27 09:37:56 +00001169 E->UsualArrayDeleteWantsSize = Record[Idx++];
Douglas Gregor409448c2011-07-21 22:35:25 +00001170 E->OperatorDelete = ReadDeclAs<FunctionDecl>(Record, Idx);
Argyrios Kyrtzidisf1b89112010-09-13 20:15:40 +00001171 E->Argument = Reader.ReadSubExpr();
Sebastian Redlc3632732010-10-05 15:59:54 +00001172 E->Loc = ReadSourceLocation(Record, Idx);
Argyrios Kyrtzidis95fc98c2010-06-22 17:07:59 +00001173}
Chris Lattnerd2598362010-05-10 00:25:06 +00001174
Sebastian Redl60adf4a2010-08-18 23:56:52 +00001175void ASTStmtReader::VisitCXXPseudoDestructorExpr(CXXPseudoDestructorExpr *E) {
Argyrios Kyrtzidisde4bd182010-06-28 09:32:03 +00001176 VisitExpr(E);
1177
Douglas Gregorf3db29f2011-02-25 18:19:59 +00001178 E->Base = Reader.ReadSubExpr();
1179 E->IsArrow = Record[Idx++];
1180 E->OperatorLoc = ReadSourceLocation(Record, Idx);
1181 E->QualifierLoc = Reader.ReadNestedNameSpecifierLoc(F, Record, Idx);
1182 E->ScopeType = GetTypeSourceInfo(Record, Idx);
1183 E->ColonColonLoc = ReadSourceLocation(Record, Idx);
1184 E->TildeLoc = ReadSourceLocation(Record, Idx);
Argyrios Kyrtzidisde4bd182010-06-28 09:32:03 +00001185
Douglas Gregor95eab172011-07-28 20:55:49 +00001186 IdentifierInfo *II = Reader.GetIdentifierInfo(F, Record, Idx);
Argyrios Kyrtzidisde4bd182010-06-28 09:32:03 +00001187 if (II)
Sebastian Redlc3632732010-10-05 15:59:54 +00001188 E->setDestroyedType(II, ReadSourceLocation(Record, Idx));
Argyrios Kyrtzidisde4bd182010-06-28 09:32:03 +00001189 else
Sebastian Redlc3632732010-10-05 15:59:54 +00001190 E->setDestroyedType(GetTypeSourceInfo(Record, Idx));
Argyrios Kyrtzidisde4bd182010-06-28 09:32:03 +00001191}
1192
John McCall4765fa02010-12-06 08:20:24 +00001193void ASTStmtReader::VisitExprWithCleanups(ExprWithCleanups *E) {
Chris Lattnerd2598362010-05-10 00:25:06 +00001194 VisitExpr(E);
John McCall80ee6e82011-11-10 05:35:25 +00001195
1196 unsigned NumObjects = Record[Idx++];
1197 assert(NumObjects == E->getNumObjects());
1198 for (unsigned i = 0; i != NumObjects; ++i)
1199 E->getObjectsBuffer()[i] = ReadDeclAs<BlockDecl>(Record, Idx);
1200
1201 E->SubExpr = Reader.ReadSubExpr();
Chris Lattner030854b2010-05-09 06:40:08 +00001202}
1203
Argyrios Kyrtzidis919e6932010-06-28 22:28:35 +00001204void
Sebastian Redl60adf4a2010-08-18 23:56:52 +00001205ASTStmtReader::VisitCXXDependentScopeMemberExpr(CXXDependentScopeMemberExpr *E){
Argyrios Kyrtzidis8dfbd8b2010-06-24 08:57:31 +00001206 VisitExpr(E);
1207
Douglas Gregordef03542011-02-04 12:01:24 +00001208 if (Record[Idx++])
John McCall096832c2010-08-19 23:49:38 +00001209 ReadExplicitTemplateArgumentList(E->getExplicitTemplateArgs(),
Douglas Gregordef03542011-02-04 12:01:24 +00001210 Record[Idx++]);
Argyrios Kyrtzidis8dfbd8b2010-06-24 08:57:31 +00001211
Douglas Gregor7c3179c2011-02-28 18:50:33 +00001212 E->Base = Reader.ReadSubExpr();
Douglas Gregor393f2492011-07-22 00:38:23 +00001213 E->BaseType = Reader.readType(F, Record, Idx);
Douglas Gregor7c3179c2011-02-28 18:50:33 +00001214 E->IsArrow = Record[Idx++];
1215 E->OperatorLoc = ReadSourceLocation(Record, Idx);
1216 E->QualifierLoc = Reader.ReadNestedNameSpecifierLoc(F, Record, Idx);
Douglas Gregor409448c2011-07-21 22:35:25 +00001217 E->FirstQualifierFoundInScope = ReadDeclAs<NamedDecl>(Record, Idx);
Argyrios Kyrtzidis40451072010-10-15 18:21:24 +00001218 ReadDeclarationNameInfo(E->MemberNameInfo, Record, Idx);
Argyrios Kyrtzidis8dfbd8b2010-06-24 08:57:31 +00001219}
1220
Argyrios Kyrtzidis919e6932010-06-28 22:28:35 +00001221void
Sebastian Redl60adf4a2010-08-18 23:56:52 +00001222ASTStmtReader::VisitDependentScopeDeclRefExpr(DependentScopeDeclRefExpr *E) {
Argyrios Kyrtzidis12dffcd2010-06-28 09:31:56 +00001223 VisitExpr(E);
Argyrios Kyrtzidis12dffcd2010-06-28 09:31:56 +00001224
Douglas Gregordef03542011-02-04 12:01:24 +00001225 if (Record[Idx++])
1226 ReadExplicitTemplateArgumentList(E->getExplicitTemplateArgs(),
1227 Record[Idx++]);
Douglas Gregor00cf3cc2011-02-25 20:49:16 +00001228
1229 E->QualifierLoc = Reader.ReadNestedNameSpecifierLoc(F, Record, Idx);
Argyrios Kyrtzidis40451072010-10-15 18:21:24 +00001230 ReadDeclarationNameInfo(E->NameInfo, Record, Idx);
Argyrios Kyrtzidis12dffcd2010-06-28 09:31:56 +00001231}
1232
Argyrios Kyrtzidis919e6932010-06-28 22:28:35 +00001233void
Sebastian Redl60adf4a2010-08-18 23:56:52 +00001234ASTStmtReader::VisitCXXUnresolvedConstructExpr(CXXUnresolvedConstructExpr *E) {
Argyrios Kyrtzidis8dfbd8b2010-06-24 08:57:31 +00001235 VisitExpr(E);
1236 assert(Record[Idx] == E->arg_size() && "Read wrong record during creation ?");
1237 ++Idx; // NumArgs;
1238 for (unsigned I = 0, N = E->arg_size(); I != N; ++I)
Argyrios Kyrtzidisd98a2ab2010-06-29 22:46:25 +00001239 E->setArg(I, Reader.ReadSubExpr());
Sebastian Redlc3632732010-10-05 15:59:54 +00001240 E->Type = GetTypeSourceInfo(Record, Idx);
1241 E->setLParenLoc(ReadSourceLocation(Record, Idx));
1242 E->setRParenLoc(ReadSourceLocation(Record, Idx));
Argyrios Kyrtzidis8dfbd8b2010-06-24 08:57:31 +00001243}
1244
Sebastian Redl60adf4a2010-08-18 23:56:52 +00001245void ASTStmtReader::VisitOverloadExpr(OverloadExpr *E) {
Argyrios Kyrtzidisa77eb082010-06-25 09:03:26 +00001246 VisitExpr(E);
1247
Douglas Gregordef03542011-02-04 12:01:24 +00001248 // Read the explicit template argument list, if available.
1249 if (Record[Idx++])
Argyrios Kyrtzidis919e6932010-06-28 22:28:35 +00001250 ReadExplicitTemplateArgumentList(E->getExplicitTemplateArgs(),
Douglas Gregordef03542011-02-04 12:01:24 +00001251 Record[Idx++]);
Argyrios Kyrtzidisa77eb082010-06-25 09:03:26 +00001252
1253 unsigned NumDecls = Record[Idx++];
1254 UnresolvedSet<8> Decls;
1255 for (unsigned i = 0; i != NumDecls; ++i) {
Douglas Gregor409448c2011-07-21 22:35:25 +00001256 NamedDecl *D = ReadDeclAs<NamedDecl>(Record, Idx);
Argyrios Kyrtzidisa77eb082010-06-25 09:03:26 +00001257 AccessSpecifier AS = (AccessSpecifier)Record[Idx++];
1258 Decls.addDecl(D, AS);
1259 }
Douglas Gregor35942772011-09-09 21:34:22 +00001260 E->initializeResults(Reader.getContext(), Decls.begin(), Decls.end());
Argyrios Kyrtzidisa77eb082010-06-25 09:03:26 +00001261
Argyrios Kyrtzidis40451072010-10-15 18:21:24 +00001262 ReadDeclarationNameInfo(E->NameInfo, Record, Idx);
Douglas Gregor4c9be892011-02-28 20:01:57 +00001263 E->QualifierLoc = Reader.ReadNestedNameSpecifierLoc(F, Record, Idx);
Argyrios Kyrtzidisa77eb082010-06-25 09:03:26 +00001264}
1265
Sebastian Redl60adf4a2010-08-18 23:56:52 +00001266void ASTStmtReader::VisitUnresolvedMemberExpr(UnresolvedMemberExpr *E) {
Argyrios Kyrtzidis919e6932010-06-28 22:28:35 +00001267 VisitOverloadExpr(E);
Douglas Gregor4c9be892011-02-28 20:01:57 +00001268 E->IsArrow = Record[Idx++];
1269 E->HasUnresolvedUsing = Record[Idx++];
1270 E->Base = Reader.ReadSubExpr();
Douglas Gregor393f2492011-07-22 00:38:23 +00001271 E->BaseType = Reader.readType(F, Record, Idx);
Douglas Gregor4c9be892011-02-28 20:01:57 +00001272 E->OperatorLoc = ReadSourceLocation(Record, Idx);
Argyrios Kyrtzidisa77eb082010-06-25 09:03:26 +00001273}
1274
Sebastian Redl60adf4a2010-08-18 23:56:52 +00001275void ASTStmtReader::VisitUnresolvedLookupExpr(UnresolvedLookupExpr *E) {
Argyrios Kyrtzidis919e6932010-06-28 22:28:35 +00001276 VisitOverloadExpr(E);
Douglas Gregor4c9be892011-02-28 20:01:57 +00001277 E->RequiresADL = Record[Idx++];
Richard Smithad762fc2011-04-14 22:09:26 +00001278 if (E->RequiresADL)
1279 E->StdIsAssociatedNamespace = Record[Idx++];
Douglas Gregor4c9be892011-02-28 20:01:57 +00001280 E->Overloaded = Record[Idx++];
Douglas Gregor409448c2011-07-21 22:35:25 +00001281 E->NamingClass = ReadDeclAs<CXXRecordDecl>(Record, Idx);
Argyrios Kyrtzidisbd65bb52010-06-25 09:03:34 +00001282}
1283
Sebastian Redl60adf4a2010-08-18 23:56:52 +00001284void ASTStmtReader::VisitUnaryTypeTraitExpr(UnaryTypeTraitExpr *E) {
Argyrios Kyrtzidis6d00c132010-07-10 11:46:15 +00001285 VisitExpr(E);
1286 E->UTT = (UnaryTypeTrait)Record[Idx++];
Sebastian Redl0dfd8482010-09-13 20:56:31 +00001287 E->Value = (bool)Record[Idx++];
Sebastian Redlc3632732010-10-05 15:59:54 +00001288 SourceRange Range = ReadSourceRange(Record, Idx);
Argyrios Kyrtzidis6d00c132010-07-10 11:46:15 +00001289 E->Loc = Range.getBegin();
1290 E->RParen = Range.getEnd();
Sebastian Redlc3632732010-10-05 15:59:54 +00001291 E->QueriedType = GetTypeSourceInfo(Record, Idx);
Argyrios Kyrtzidis6d00c132010-07-10 11:46:15 +00001292}
1293
Francois Pichet6ad6f282010-12-07 00:08:36 +00001294void ASTStmtReader::VisitBinaryTypeTraitExpr(BinaryTypeTraitExpr *E) {
1295 VisitExpr(E);
1296 E->BTT = (BinaryTypeTrait)Record[Idx++];
1297 E->Value = (bool)Record[Idx++];
1298 SourceRange Range = ReadSourceRange(Record, Idx);
1299 E->Loc = Range.getBegin();
1300 E->RParen = Range.getEnd();
1301 E->LhsType = GetTypeSourceInfo(Record, Idx);
1302 E->RhsType = GetTypeSourceInfo(Record, Idx);
1303}
1304
John Wiegley21ff2e52011-04-28 00:16:57 +00001305void ASTStmtReader::VisitArrayTypeTraitExpr(ArrayTypeTraitExpr *E) {
1306 VisitExpr(E);
1307 E->ATT = (ArrayTypeTrait)Record[Idx++];
1308 E->Value = (unsigned int)Record[Idx++];
1309 SourceRange Range = ReadSourceRange(Record, Idx);
1310 E->Loc = Range.getBegin();
1311 E->RParen = Range.getEnd();
1312 E->QueriedType = GetTypeSourceInfo(Record, Idx);
1313}
1314
John Wiegley55262202011-04-25 06:54:41 +00001315void ASTStmtReader::VisitExpressionTraitExpr(ExpressionTraitExpr *E) {
1316 VisitExpr(E);
1317 E->ET = (ExpressionTrait)Record[Idx++];
1318 E->Value = (bool)Record[Idx++];
1319 SourceRange Range = ReadSourceRange(Record, Idx);
1320 E->QueriedExpression = Reader.ReadSubExpr();
1321 E->Loc = Range.getBegin();
1322 E->RParen = Range.getEnd();
1323}
1324
Sebastian Redl6b219d02010-09-10 20:55:54 +00001325void ASTStmtReader::VisitCXXNoexceptExpr(CXXNoexceptExpr *E) {
1326 VisitExpr(E);
Sebastian Redl5221d8f2010-09-10 22:34:40 +00001327 E->Value = (bool)Record[Idx++];
Sebastian Redlc3632732010-10-05 15:59:54 +00001328 E->Range = ReadSourceRange(Record, Idx);
Sebastian Redl5221d8f2010-09-10 22:34:40 +00001329 E->Operand = Reader.ReadSubExpr();
Sebastian Redl6b219d02010-09-10 20:55:54 +00001330}
1331
Douglas Gregorbe230c32011-01-03 17:17:50 +00001332void ASTStmtReader::VisitPackExpansionExpr(PackExpansionExpr *E) {
1333 VisitExpr(E);
1334 E->EllipsisLoc = ReadSourceLocation(Record, Idx);
Douglas Gregor67fd1252011-01-14 21:20:45 +00001335 E->NumExpansions = Record[Idx++];
Douglas Gregorbe230c32011-01-03 17:17:50 +00001336 E->Pattern = Reader.ReadSubExpr();
1337}
1338
Douglas Gregoree8aff02011-01-04 17:33:58 +00001339void ASTStmtReader::VisitSizeOfPackExpr(SizeOfPackExpr *E) {
1340 VisitExpr(E);
1341 E->OperatorLoc = ReadSourceLocation(Record, Idx);
1342 E->PackLoc = ReadSourceLocation(Record, Idx);
1343 E->RParenLoc = ReadSourceLocation(Record, Idx);
1344 E->Length = Record[Idx++];
Douglas Gregor409448c2011-07-21 22:35:25 +00001345 E->Pack = ReadDeclAs<NamedDecl>(Record, Idx);
Douglas Gregoree8aff02011-01-04 17:33:58 +00001346}
1347
John McCall7110fd62011-07-15 07:00:14 +00001348void ASTStmtReader::VisitSubstNonTypeTemplateParmExpr(
1349 SubstNonTypeTemplateParmExpr *E) {
1350 VisitExpr(E);
Douglas Gregor409448c2011-07-21 22:35:25 +00001351 E->Param = ReadDeclAs<NonTypeTemplateParmDecl>(Record, Idx);
John McCall7110fd62011-07-15 07:00:14 +00001352 E->NameLoc = ReadSourceLocation(Record, Idx);
1353 E->Replacement = Reader.ReadSubExpr();
1354}
1355
Douglas Gregorc7793c72011-01-15 01:15:58 +00001356void ASTStmtReader::VisitSubstNonTypeTemplateParmPackExpr(
1357 SubstNonTypeTemplateParmPackExpr *E) {
1358 VisitExpr(E);
Douglas Gregor409448c2011-07-21 22:35:25 +00001359 E->Param = ReadDeclAs<NonTypeTemplateParmDecl>(Record, Idx);
Douglas Gregorc7793c72011-01-15 01:15:58 +00001360 TemplateArgument ArgPack = Reader.ReadTemplateArgument(F, Record, Idx);
1361 if (ArgPack.getKind() != TemplateArgument::Pack)
1362 return;
1363
1364 E->Arguments = ArgPack.pack_begin();
1365 E->NumArguments = ArgPack.pack_size();
1366 E->NameLoc = ReadSourceLocation(Record, Idx);
1367}
1368
Douglas Gregor03e80032011-06-21 17:03:29 +00001369void ASTStmtReader::VisitMaterializeTemporaryExpr(MaterializeTemporaryExpr *E) {
1370 VisitExpr(E);
1371 E->Temporary = Reader.ReadSubExpr();
1372}
1373
John McCall7cd7d1a2010-11-15 23:31:06 +00001374void ASTStmtReader::VisitOpaqueValueExpr(OpaqueValueExpr *E) {
1375 VisitExpr(E);
Argyrios Kyrtzidis8bc27822011-12-03 03:49:52 +00001376 E->SourceExpr = Reader.ReadSubExpr();
Douglas Gregorb608b982011-01-28 02:26:04 +00001377 E->Loc = ReadSourceLocation(Record, Idx);
John McCall7cd7d1a2010-11-15 23:31:06 +00001378}
1379
Peter Collingbournee08ce652011-02-09 21:07:24 +00001380//===----------------------------------------------------------------------===//
John McCall7110fd62011-07-15 07:00:14 +00001381// Microsoft Expressions and Statements
1382//===----------------------------------------------------------------------===//
1383void ASTStmtReader::VisitCXXUuidofExpr(CXXUuidofExpr *E) {
1384 VisitExpr(E);
1385 E->setSourceRange(ReadSourceRange(Record, Idx));
1386 if (E->isTypeOperand()) { // __uuidof(ComType)
1387 E->setTypeOperandSourceInfo(
1388 GetTypeSourceInfo(Record, Idx));
1389 return;
1390 }
1391
1392 // __uuidof(expr)
1393 E->setExprOperand(Reader.ReadSubExpr());
1394}
1395
1396void ASTStmtReader::VisitSEHExceptStmt(SEHExceptStmt *S) {
1397 VisitStmt(S);
1398 S->Loc = ReadSourceLocation(Record, Idx);
1399 S->Children[SEHExceptStmt::FILTER_EXPR] = Reader.ReadSubStmt();
1400 S->Children[SEHExceptStmt::BLOCK] = Reader.ReadSubStmt();
1401}
1402
1403void ASTStmtReader::VisitSEHFinallyStmt(SEHFinallyStmt *S) {
1404 VisitStmt(S);
1405 S->Loc = ReadSourceLocation(Record, Idx);
1406 S->Block = Reader.ReadSubStmt();
1407}
1408
1409void ASTStmtReader::VisitSEHTryStmt(SEHTryStmt *S) {
1410 VisitStmt(S);
1411 S->IsCXXTry = Record[Idx++];
1412 S->TryLoc = ReadSourceLocation(Record, Idx);
1413 S->Children[SEHTryStmt::TRY] = Reader.ReadSubStmt();
1414 S->Children[SEHTryStmt::HANDLER] = Reader.ReadSubStmt();
1415}
1416
1417//===----------------------------------------------------------------------===//
Peter Collingbournee08ce652011-02-09 21:07:24 +00001418// CUDA Expressions and Statements
1419//===----------------------------------------------------------------------===//
1420
1421void ASTStmtReader::VisitCUDAKernelCallExpr(CUDAKernelCallExpr *E) {
1422 VisitCallExpr(E);
1423 E->setConfig(cast<CallExpr>(Reader.ReadSubExpr()));
1424}
1425
John McCall7110fd62011-07-15 07:00:14 +00001426//===----------------------------------------------------------------------===//
1427// OpenCL Expressions and Statements.
1428//===----------------------------------------------------------------------===//
1429void ASTStmtReader::VisitAsTypeExpr(AsTypeExpr *E) {
1430 VisitExpr(E);
1431 E->BuiltinLoc = ReadSourceLocation(Record, Idx);
1432 E->RParenLoc = ReadSourceLocation(Record, Idx);
1433 E->SrcExpr = Reader.ReadSubExpr();
1434}
1435
1436//===----------------------------------------------------------------------===//
1437// ASTReader Implementation
1438//===----------------------------------------------------------------------===//
1439
Douglas Gregor1a4761e2011-11-30 23:21:26 +00001440Stmt *ASTReader::ReadStmt(ModuleFile &F) {
Argyrios Kyrtzidis919e6932010-06-28 22:28:35 +00001441 switch (ReadingKind) {
1442 case Read_Decl:
1443 case Read_Type:
Sebastian Redlc3632732010-10-05 15:59:54 +00001444 return ReadStmtFromStream(F);
Argyrios Kyrtzidis919e6932010-06-28 22:28:35 +00001445 case Read_Stmt:
Argyrios Kyrtzidisd98a2ab2010-06-29 22:46:25 +00001446 return ReadSubStmt();
Argyrios Kyrtzidis919e6932010-06-28 22:28:35 +00001447 }
1448
1449 llvm_unreachable("ReadingKind not set ?");
Argyrios Kyrtzidis919e6932010-06-28 22:28:35 +00001450}
1451
Douglas Gregor1a4761e2011-11-30 23:21:26 +00001452Expr *ASTReader::ReadExpr(ModuleFile &F) {
Sebastian Redlc3632732010-10-05 15:59:54 +00001453 return cast_or_null<Expr>(ReadStmt(F));
Argyrios Kyrtzidis919e6932010-06-28 22:28:35 +00001454}
Chris Lattner030854b2010-05-09 06:40:08 +00001455
Sebastian Redlc43b54c2010-08-18 23:56:43 +00001456Expr *ASTReader::ReadSubExpr() {
Argyrios Kyrtzidisd98a2ab2010-06-29 22:46:25 +00001457 return cast_or_null<Expr>(ReadSubStmt());
1458}
1459
Chris Lattner52e97d12009-04-27 05:41:06 +00001460// Within the bitstream, expressions are stored in Reverse Polish
1461// Notation, with each of the subexpressions preceding the
Argyrios Kyrtzidis919e6932010-06-28 22:28:35 +00001462// expression they are stored in. Subexpressions are stored from last to first.
1463// To evaluate expressions, we continue reading expressions and placing them on
1464// the stack, with expressions having operands removing those operands from the
Chris Lattner52e97d12009-04-27 05:41:06 +00001465// stack. Evaluation terminates when we see a STMT_STOP record, and
1466// the single remaining expression on the stack is our result.
Douglas Gregor1a4761e2011-11-30 23:21:26 +00001467Stmt *ASTReader::ReadStmtFromStream(ModuleFile &F) {
Argyrios Kyrtzidis919e6932010-06-28 22:28:35 +00001468
1469 ReadingKindTracker ReadingKind(Read_Stmt, *this);
Sebastian Redlc3632732010-10-05 15:59:54 +00001470 llvm::BitstreamCursor &Cursor = F.DeclsCursor;
Argyrios Kyrtzidise6f08682011-10-21 23:02:28 +00001471
1472 // Map of offset to previously deserialized stmt. The offset points
1473 /// just after the stmt record.
1474 llvm::DenseMap<uint64_t, Stmt *> StmtEntries;
Sebastian Redlc3632732010-10-05 15:59:54 +00001475
Argyrios Kyrtzidis919e6932010-06-28 22:28:35 +00001476#ifndef NDEBUG
1477 unsigned PrevNumStmts = StmtStack.size();
1478#endif
1479
Chris Lattner4c6f9522009-04-27 05:14:47 +00001480 RecordData Record;
1481 unsigned Idx;
Sebastian Redlc3632732010-10-05 15:59:54 +00001482 ASTStmtReader Reader(*this, F, Cursor, Record, Idx);
Chris Lattner4c6f9522009-04-27 05:14:47 +00001483 Stmt::EmptyShell Empty;
1484
1485 while (true) {
Chris Lattner52e97d12009-04-27 05:41:06 +00001486 unsigned Code = Cursor.ReadCode();
Chris Lattner4c6f9522009-04-27 05:14:47 +00001487 if (Code == llvm::bitc::END_BLOCK) {
Chris Lattner52e97d12009-04-27 05:41:06 +00001488 if (Cursor.ReadBlockEnd()) {
Sebastian Redl3c7f4132010-08-18 23:57:06 +00001489 Error("error at end of block in AST file");
Chris Lattner4c6f9522009-04-27 05:14:47 +00001490 return 0;
1491 }
1492 break;
1493 }
1494
1495 if (Code == llvm::bitc::ENTER_SUBBLOCK) {
1496 // No known subblocks, always skip them.
Chris Lattner52e97d12009-04-27 05:41:06 +00001497 Cursor.ReadSubBlockID();
1498 if (Cursor.SkipBlock()) {
Sebastian Redl3c7f4132010-08-18 23:57:06 +00001499 Error("malformed block record in AST file");
Chris Lattner4c6f9522009-04-27 05:14:47 +00001500 return 0;
1501 }
1502 continue;
1503 }
1504
1505 if (Code == llvm::bitc::DEFINE_ABBREV) {
Chris Lattner52e97d12009-04-27 05:41:06 +00001506 Cursor.ReadAbbrevRecord();
Chris Lattner4c6f9522009-04-27 05:14:47 +00001507 continue;
1508 }
1509
1510 Stmt *S = 0;
1511 Idx = 0;
1512 Record.clear();
1513 bool Finished = false;
Argyrios Kyrtzidise6f08682011-10-21 23:02:28 +00001514 bool IsStmtReference = false;
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001515 switch ((StmtCode)Cursor.ReadRecord(Code, Record)) {
1516 case STMT_STOP:
Chris Lattner4c6f9522009-04-27 05:14:47 +00001517 Finished = true;
1518 break;
1519
Argyrios Kyrtzidise6f08682011-10-21 23:02:28 +00001520 case STMT_REF_PTR:
1521 IsStmtReference = true;
1522 assert(StmtEntries.find(Record[0]) != StmtEntries.end() &&
1523 "No stmt was recorded for this offset reference!");
1524 S = StmtEntries[Record[Idx++]];
1525 break;
1526
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001527 case STMT_NULL_PTR:
Mike Stump1eb44332009-09-09 15:08:12 +00001528 S = 0;
Chris Lattner4c6f9522009-04-27 05:14:47 +00001529 break;
1530
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001531 case STMT_NULL:
Chris Lattner4c6f9522009-04-27 05:14:47 +00001532 S = new (Context) NullStmt(Empty);
1533 break;
1534
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001535 case STMT_COMPOUND:
Chris Lattner4c6f9522009-04-27 05:14:47 +00001536 S = new (Context) CompoundStmt(Empty);
1537 break;
1538
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001539 case STMT_CASE:
Chris Lattner4c6f9522009-04-27 05:14:47 +00001540 S = new (Context) CaseStmt(Empty);
1541 break;
1542
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001543 case STMT_DEFAULT:
Chris Lattner4c6f9522009-04-27 05:14:47 +00001544 S = new (Context) DefaultStmt(Empty);
1545 break;
1546
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001547 case STMT_LABEL:
Chris Lattner4c6f9522009-04-27 05:14:47 +00001548 S = new (Context) LabelStmt(Empty);
1549 break;
1550
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001551 case STMT_IF:
Chris Lattner4c6f9522009-04-27 05:14:47 +00001552 S = new (Context) IfStmt(Empty);
1553 break;
1554
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001555 case STMT_SWITCH:
Chris Lattner4c6f9522009-04-27 05:14:47 +00001556 S = new (Context) SwitchStmt(Empty);
1557 break;
1558
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001559 case STMT_WHILE:
Chris Lattner4c6f9522009-04-27 05:14:47 +00001560 S = new (Context) WhileStmt(Empty);
1561 break;
1562
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001563 case STMT_DO:
Chris Lattner4c6f9522009-04-27 05:14:47 +00001564 S = new (Context) DoStmt(Empty);
1565 break;
Mike Stump1eb44332009-09-09 15:08:12 +00001566
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001567 case STMT_FOR:
Chris Lattner4c6f9522009-04-27 05:14:47 +00001568 S = new (Context) ForStmt(Empty);
1569 break;
1570
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001571 case STMT_GOTO:
Chris Lattner4c6f9522009-04-27 05:14:47 +00001572 S = new (Context) GotoStmt(Empty);
1573 break;
Mike Stump1eb44332009-09-09 15:08:12 +00001574
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001575 case STMT_INDIRECT_GOTO:
Chris Lattner4c6f9522009-04-27 05:14:47 +00001576 S = new (Context) IndirectGotoStmt(Empty);
1577 break;
1578
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001579 case STMT_CONTINUE:
Chris Lattner4c6f9522009-04-27 05:14:47 +00001580 S = new (Context) ContinueStmt(Empty);
1581 break;
1582
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001583 case STMT_BREAK:
Chris Lattner4c6f9522009-04-27 05:14:47 +00001584 S = new (Context) BreakStmt(Empty);
1585 break;
1586
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001587 case STMT_RETURN:
Chris Lattner4c6f9522009-04-27 05:14:47 +00001588 S = new (Context) ReturnStmt(Empty);
1589 break;
1590
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001591 case STMT_DECL:
Chris Lattner4c6f9522009-04-27 05:14:47 +00001592 S = new (Context) DeclStmt(Empty);
1593 break;
1594
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001595 case STMT_ASM:
Chris Lattner4c6f9522009-04-27 05:14:47 +00001596 S = new (Context) AsmStmt(Empty);
1597 break;
1598
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001599 case EXPR_PREDEFINED:
Chris Lattner4c6f9522009-04-27 05:14:47 +00001600 S = new (Context) PredefinedExpr(Empty);
1601 break;
Mike Stump1eb44332009-09-09 15:08:12 +00001602
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001603 case EXPR_DECL_REF:
Chandler Carruth3aa81402011-05-01 23:48:14 +00001604 S = DeclRefExpr::CreateEmpty(
Douglas Gregor35942772011-09-09 21:34:22 +00001605 Context,
Chandler Carruth3aa81402011-05-01 23:48:14 +00001606 /*HasQualifier=*/Record[ASTStmtReader::NumExprFields],
1607 /*HasFoundDecl=*/Record[ASTStmtReader::NumExprFields + 1],
1608 /*HasExplicitTemplateArgs=*/Record[ASTStmtReader::NumExprFields + 2],
1609 /*NumTemplateArgs=*/Record[ASTStmtReader::NumExprFields + 2] ?
Abramo Bagnara7cc58b42011-10-05 07:56:41 +00001610 Record[ASTStmtReader::NumExprFields + 4] : 0);
Chris Lattner4c6f9522009-04-27 05:14:47 +00001611 break;
Mike Stump1eb44332009-09-09 15:08:12 +00001612
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001613 case EXPR_INTEGER_LITERAL:
Douglas Gregor35942772011-09-09 21:34:22 +00001614 S = IntegerLiteral::Create(Context, Empty);
Chris Lattner4c6f9522009-04-27 05:14:47 +00001615 break;
Mike Stump1eb44332009-09-09 15:08:12 +00001616
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001617 case EXPR_FLOATING_LITERAL:
Douglas Gregor35942772011-09-09 21:34:22 +00001618 S = FloatingLiteral::Create(Context, Empty);
Chris Lattner4c6f9522009-04-27 05:14:47 +00001619 break;
Mike Stump1eb44332009-09-09 15:08:12 +00001620
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001621 case EXPR_IMAGINARY_LITERAL:
Chris Lattner4c6f9522009-04-27 05:14:47 +00001622 S = new (Context) ImaginaryLiteral(Empty);
1623 break;
1624
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001625 case EXPR_STRING_LITERAL:
Douglas Gregor35942772011-09-09 21:34:22 +00001626 S = StringLiteral::CreateEmpty(Context,
Sebastian Redl60adf4a2010-08-18 23:56:52 +00001627 Record[ASTStmtReader::NumExprFields + 1]);
Chris Lattner4c6f9522009-04-27 05:14:47 +00001628 break;
1629
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001630 case EXPR_CHARACTER_LITERAL:
Chris Lattner4c6f9522009-04-27 05:14:47 +00001631 S = new (Context) CharacterLiteral(Empty);
1632 break;
1633
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001634 case EXPR_PAREN:
Chris Lattner4c6f9522009-04-27 05:14:47 +00001635 S = new (Context) ParenExpr(Empty);
1636 break;
1637
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001638 case EXPR_PAREN_LIST:
Argyrios Kyrtzidis37bdfe22010-06-30 08:49:18 +00001639 S = new (Context) ParenListExpr(Empty);
1640 break;
1641
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001642 case EXPR_UNARY_OPERATOR:
Chris Lattner4c6f9522009-04-27 05:14:47 +00001643 S = new (Context) UnaryOperator(Empty);
1644 break;
1645
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001646 case EXPR_OFFSETOF:
Douglas Gregor35942772011-09-09 21:34:22 +00001647 S = OffsetOfExpr::CreateEmpty(Context,
Sebastian Redl60adf4a2010-08-18 23:56:52 +00001648 Record[ASTStmtReader::NumExprFields],
1649 Record[ASTStmtReader::NumExprFields + 1]);
Douglas Gregor8ecdb652010-04-28 22:16:22 +00001650 break;
1651
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001652 case EXPR_SIZEOF_ALIGN_OF:
Peter Collingbournef4e3cfb2011-03-11 19:24:49 +00001653 S = new (Context) UnaryExprOrTypeTraitExpr(Empty);
Chris Lattner4c6f9522009-04-27 05:14:47 +00001654 break;
1655
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001656 case EXPR_ARRAY_SUBSCRIPT:
Chris Lattner4c6f9522009-04-27 05:14:47 +00001657 S = new (Context) ArraySubscriptExpr(Empty);
1658 break;
1659
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001660 case EXPR_CALL:
Douglas Gregor35942772011-09-09 21:34:22 +00001661 S = new (Context) CallExpr(Context, Stmt::CallExprClass, Empty);
Chris Lattner4c6f9522009-04-27 05:14:47 +00001662 break;
1663
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001664 case EXPR_MEMBER: {
Argyrios Kyrtzidis663e3802010-07-08 13:09:47 +00001665 // We load everything here and fully initialize it at creation.
1666 // That way we can use MemberExpr::Create and don't have to duplicate its
1667 // logic with a MemberExpr::CreateEmpty.
1668
1669 assert(Idx == 0);
Douglas Gregor40d96a62011-02-28 21:54:11 +00001670 NestedNameSpecifierLoc QualifierLoc;
Argyrios Kyrtzidis663e3802010-07-08 13:09:47 +00001671 if (Record[Idx++]) { // HasQualifier.
Douglas Gregor40d96a62011-02-28 21:54:11 +00001672 QualifierLoc = ReadNestedNameSpecifierLoc(F, Record, Idx);
Argyrios Kyrtzidis663e3802010-07-08 13:09:47 +00001673 }
1674
1675 TemplateArgumentListInfo ArgInfo;
Douglas Gregordef03542011-02-04 12:01:24 +00001676 bool HasExplicitTemplateArgs = Record[Idx++];
1677 if (HasExplicitTemplateArgs) {
1678 unsigned NumTemplateArgs = Record[Idx++];
Sebastian Redlc3632732010-10-05 15:59:54 +00001679 ArgInfo.setLAngleLoc(ReadSourceLocation(F, Record, Idx));
1680 ArgInfo.setRAngleLoc(ReadSourceLocation(F, Record, Idx));
Argyrios Kyrtzidis663e3802010-07-08 13:09:47 +00001681 for (unsigned i = 0; i != NumTemplateArgs; ++i)
Sebastian Redlc3632732010-10-05 15:59:54 +00001682 ArgInfo.addArgument(ReadTemplateArgumentLoc(F, Record, Idx));
Argyrios Kyrtzidis663e3802010-07-08 13:09:47 +00001683 }
Abramo Bagnara7cc58b42011-10-05 07:56:41 +00001684
1685 bool HadMultipleCandidates = Record[Idx++];
1686
Douglas Gregor409448c2011-07-21 22:35:25 +00001687 NamedDecl *FoundD = ReadDeclAs<NamedDecl>(F, Record, Idx);
Argyrios Kyrtzidis663e3802010-07-08 13:09:47 +00001688 AccessSpecifier AS = (AccessSpecifier)Record[Idx++];
1689 DeclAccessPair FoundDecl = DeclAccessPair::make(FoundD, AS);
1690
Douglas Gregor393f2492011-07-22 00:38:23 +00001691 QualType T = readType(F, Record, Idx);
John McCallf89e55a2010-11-18 06:31:45 +00001692 ExprValueKind VK = static_cast<ExprValueKind>(Record[Idx++]);
1693 ExprObjectKind OK = static_cast<ExprObjectKind>(Record[Idx++]);
Argyrios Kyrtzidis663e3802010-07-08 13:09:47 +00001694 Expr *Base = ReadSubExpr();
Douglas Gregor409448c2011-07-21 22:35:25 +00001695 ValueDecl *MemberD = ReadDeclAs<ValueDecl>(F, Record, Idx);
Sebastian Redlc3632732010-10-05 15:59:54 +00001696 SourceLocation MemberLoc = ReadSourceLocation(F, Record, Idx);
Abramo Bagnara25777432010-08-11 22:01:17 +00001697 DeclarationNameInfo MemberNameInfo(MemberD->getDeclName(), MemberLoc);
Argyrios Kyrtzidis663e3802010-07-08 13:09:47 +00001698 bool IsArrow = Record[Idx++];
1699
Douglas Gregor35942772011-09-09 21:34:22 +00001700 S = MemberExpr::Create(Context, Base, IsArrow, QualifierLoc,
Abramo Bagnara25777432010-08-11 22:01:17 +00001701 MemberD, FoundDecl, MemberNameInfo,
Douglas Gregordef03542011-02-04 12:01:24 +00001702 HasExplicitTemplateArgs ? &ArgInfo : 0, T, VK, OK);
Argyrios Kyrtzidis40451072010-10-15 18:21:24 +00001703 ReadDeclarationNameLoc(F, cast<MemberExpr>(S)->MemberDNLoc,
1704 MemberD->getDeclName(), Record, Idx);
Abramo Bagnara7cc58b42011-10-05 07:56:41 +00001705 if (HadMultipleCandidates)
1706 cast<MemberExpr>(S)->setHadMultipleCandidates(true);
Chris Lattner4c6f9522009-04-27 05:14:47 +00001707 break;
Argyrios Kyrtzidis663e3802010-07-08 13:09:47 +00001708 }
Chris Lattner4c6f9522009-04-27 05:14:47 +00001709
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001710 case EXPR_BINARY_OPERATOR:
Chris Lattner4c6f9522009-04-27 05:14:47 +00001711 S = new (Context) BinaryOperator(Empty);
1712 break;
1713
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001714 case EXPR_COMPOUND_ASSIGN_OPERATOR:
Chris Lattner4c6f9522009-04-27 05:14:47 +00001715 S = new (Context) CompoundAssignOperator(Empty);
1716 break;
1717
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001718 case EXPR_CONDITIONAL_OPERATOR:
Chris Lattner4c6f9522009-04-27 05:14:47 +00001719 S = new (Context) ConditionalOperator(Empty);
1720 break;
1721
John McCall56ca35d2011-02-17 10:25:35 +00001722 case EXPR_BINARY_CONDITIONAL_OPERATOR:
1723 S = new (Context) BinaryConditionalOperator(Empty);
1724 break;
1725
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001726 case EXPR_IMPLICIT_CAST:
Douglas Gregor35942772011-09-09 21:34:22 +00001727 S = ImplicitCastExpr::CreateEmpty(Context,
Sebastian Redl60adf4a2010-08-18 23:56:52 +00001728 /*PathSize*/ Record[ASTStmtReader::NumExprFields]);
Chris Lattner4c6f9522009-04-27 05:14:47 +00001729 break;
1730
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001731 case EXPR_CSTYLE_CAST:
Douglas Gregor35942772011-09-09 21:34:22 +00001732 S = CStyleCastExpr::CreateEmpty(Context,
Sebastian Redl60adf4a2010-08-18 23:56:52 +00001733 /*PathSize*/ Record[ASTStmtReader::NumExprFields]);
Chris Lattner4c6f9522009-04-27 05:14:47 +00001734 break;
1735
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001736 case EXPR_COMPOUND_LITERAL:
Chris Lattner4c6f9522009-04-27 05:14:47 +00001737 S = new (Context) CompoundLiteralExpr(Empty);
1738 break;
1739
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001740 case EXPR_EXT_VECTOR_ELEMENT:
Chris Lattner4c6f9522009-04-27 05:14:47 +00001741 S = new (Context) ExtVectorElementExpr(Empty);
1742 break;
1743
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001744 case EXPR_INIT_LIST:
Douglas Gregor35942772011-09-09 21:34:22 +00001745 S = new (Context) InitListExpr(getContext(), Empty);
Chris Lattner4c6f9522009-04-27 05:14:47 +00001746 break;
1747
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001748 case EXPR_DESIGNATED_INIT:
Douglas Gregor35942772011-09-09 21:34:22 +00001749 S = DesignatedInitExpr::CreateEmpty(Context,
Sebastian Redl60adf4a2010-08-18 23:56:52 +00001750 Record[ASTStmtReader::NumExprFields] - 1);
Mike Stump1eb44332009-09-09 15:08:12 +00001751
Chris Lattner4c6f9522009-04-27 05:14:47 +00001752 break;
1753
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001754 case EXPR_IMPLICIT_VALUE_INIT:
Chris Lattner4c6f9522009-04-27 05:14:47 +00001755 S = new (Context) ImplicitValueInitExpr(Empty);
1756 break;
1757
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001758 case EXPR_VA_ARG:
Chris Lattner4c6f9522009-04-27 05:14:47 +00001759 S = new (Context) VAArgExpr(Empty);
1760 break;
1761
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001762 case EXPR_ADDR_LABEL:
Chris Lattner4c6f9522009-04-27 05:14:47 +00001763 S = new (Context) AddrLabelExpr(Empty);
1764 break;
1765
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001766 case EXPR_STMT:
Chris Lattner4c6f9522009-04-27 05:14:47 +00001767 S = new (Context) StmtExpr(Empty);
1768 break;
1769
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001770 case EXPR_CHOOSE:
Chris Lattner4c6f9522009-04-27 05:14:47 +00001771 S = new (Context) ChooseExpr(Empty);
1772 break;
1773
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001774 case EXPR_GNU_NULL:
Chris Lattner4c6f9522009-04-27 05:14:47 +00001775 S = new (Context) GNUNullExpr(Empty);
1776 break;
1777
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001778 case EXPR_SHUFFLE_VECTOR:
Chris Lattner4c6f9522009-04-27 05:14:47 +00001779 S = new (Context) ShuffleVectorExpr(Empty);
1780 break;
Mike Stump1eb44332009-09-09 15:08:12 +00001781
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001782 case EXPR_BLOCK:
Chris Lattner4c6f9522009-04-27 05:14:47 +00001783 S = new (Context) BlockExpr(Empty);
1784 break;
1785
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001786 case EXPR_BLOCK_DECL_REF:
Chris Lattner4c6f9522009-04-27 05:14:47 +00001787 S = new (Context) BlockDeclRefExpr(Empty);
1788 break;
Mike Stump1eb44332009-09-09 15:08:12 +00001789
Peter Collingbournef111d932011-04-15 00:35:48 +00001790 case EXPR_GENERIC_SELECTION:
1791 S = new (Context) GenericSelectionExpr(Empty);
1792 break;
1793
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001794 case EXPR_OBJC_STRING_LITERAL:
Chris Lattner4c6f9522009-04-27 05:14:47 +00001795 S = new (Context) ObjCStringLiteral(Empty);
1796 break;
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001797 case EXPR_OBJC_ENCODE:
Chris Lattner4c6f9522009-04-27 05:14:47 +00001798 S = new (Context) ObjCEncodeExpr(Empty);
1799 break;
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001800 case EXPR_OBJC_SELECTOR_EXPR:
Chris Lattner4c6f9522009-04-27 05:14:47 +00001801 S = new (Context) ObjCSelectorExpr(Empty);
1802 break;
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001803 case EXPR_OBJC_PROTOCOL_EXPR:
Chris Lattner4c6f9522009-04-27 05:14:47 +00001804 S = new (Context) ObjCProtocolExpr(Empty);
1805 break;
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001806 case EXPR_OBJC_IVAR_REF_EXPR:
Chris Lattner4c6f9522009-04-27 05:14:47 +00001807 S = new (Context) ObjCIvarRefExpr(Empty);
1808 break;
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001809 case EXPR_OBJC_PROPERTY_REF_EXPR:
Chris Lattner4c6f9522009-04-27 05:14:47 +00001810 S = new (Context) ObjCPropertyRefExpr(Empty);
1811 break;
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001812 case EXPR_OBJC_KVC_REF_EXPR:
John McCall12f78a62010-12-02 01:19:52 +00001813 llvm_unreachable("mismatching AST file");
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001814 case EXPR_OBJC_MESSAGE_EXPR:
Douglas Gregor35942772011-09-09 21:34:22 +00001815 S = ObjCMessageExpr::CreateEmpty(Context,
Argyrios Kyrtzidis20718082011-10-03 06:36:51 +00001816 Record[ASTStmtReader::NumExprFields],
1817 Record[ASTStmtReader::NumExprFields + 1]);
Chris Lattner4c6f9522009-04-27 05:14:47 +00001818 break;
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001819 case EXPR_OBJC_ISA:
Steve Narofff242b1b2009-07-24 17:54:45 +00001820 S = new (Context) ObjCIsaExpr(Empty);
1821 break;
John McCallf85e1932011-06-15 23:02:42 +00001822 case EXPR_OBJC_INDIRECT_COPY_RESTORE:
1823 S = new (Context) ObjCIndirectCopyRestoreExpr(Empty);
1824 break;
1825 case EXPR_OBJC_BRIDGED_CAST:
1826 S = new (Context) ObjCBridgedCastExpr(Empty);
1827 break;
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001828 case STMT_OBJC_FOR_COLLECTION:
Chris Lattner4c6f9522009-04-27 05:14:47 +00001829 S = new (Context) ObjCForCollectionStmt(Empty);
1830 break;
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001831 case STMT_OBJC_CATCH:
Chris Lattner4c6f9522009-04-27 05:14:47 +00001832 S = new (Context) ObjCAtCatchStmt(Empty);
1833 break;
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001834 case STMT_OBJC_FINALLY:
Chris Lattner4c6f9522009-04-27 05:14:47 +00001835 S = new (Context) ObjCAtFinallyStmt(Empty);
1836 break;
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001837 case STMT_OBJC_AT_TRY:
Douglas Gregor35942772011-09-09 21:34:22 +00001838 S = ObjCAtTryStmt::CreateEmpty(Context,
Sebastian Redl60adf4a2010-08-18 23:56:52 +00001839 Record[ASTStmtReader::NumStmtFields],
1840 Record[ASTStmtReader::NumStmtFields + 1]);
Chris Lattner4c6f9522009-04-27 05:14:47 +00001841 break;
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001842 case STMT_OBJC_AT_SYNCHRONIZED:
Chris Lattner4c6f9522009-04-27 05:14:47 +00001843 S = new (Context) ObjCAtSynchronizedStmt(Empty);
1844 break;
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001845 case STMT_OBJC_AT_THROW:
Chris Lattner4c6f9522009-04-27 05:14:47 +00001846 S = new (Context) ObjCAtThrowStmt(Empty);
1847 break;
John McCallf85e1932011-06-15 23:02:42 +00001848 case STMT_OBJC_AUTORELEASE_POOL:
1849 S = new (Context) ObjCAutoreleasePoolStmt(Empty);
1850 break;
John McCall7110fd62011-07-15 07:00:14 +00001851 case STMT_SEH_EXCEPT:
1852 S = new (Context) SEHExceptStmt(Empty);
1853 break;
1854 case STMT_SEH_FINALLY:
1855 S = new (Context) SEHFinallyStmt(Empty);
1856 break;
1857 case STMT_SEH_TRY:
1858 S = new (Context) SEHTryStmt(Empty);
1859 break;
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001860 case STMT_CXX_CATCH:
Argyrios Kyrtzidis7cb45e32010-07-22 16:03:56 +00001861 S = new (Context) CXXCatchStmt(Empty);
1862 break;
1863
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001864 case STMT_CXX_TRY:
Douglas Gregor35942772011-09-09 21:34:22 +00001865 S = CXXTryStmt::Create(Context, Empty,
Sebastian Redl60adf4a2010-08-18 23:56:52 +00001866 /*NumHandlers=*/Record[ASTStmtReader::NumStmtFields]);
Argyrios Kyrtzidis7cb45e32010-07-22 16:03:56 +00001867 break;
1868
Richard Smithad762fc2011-04-14 22:09:26 +00001869 case STMT_CXX_FOR_RANGE:
1870 S = new (Context) CXXForRangeStmt(Empty);
1871 break;
1872
Douglas Gregorba0513d2011-10-25 01:33:02 +00001873 case STMT_MS_DEPENDENT_EXISTS:
1874 S = new (Context) MSDependentExistsStmt(SourceLocation(), true,
1875 NestedNameSpecifierLoc(),
1876 DeclarationNameInfo(),
1877 0);
1878 break;
1879
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001880 case EXPR_CXX_OPERATOR_CALL:
Douglas Gregor35942772011-09-09 21:34:22 +00001881 S = new (Context) CXXOperatorCallExpr(Context, Empty);
Argyrios Kyrtzidisba0a9002009-07-14 03:19:21 +00001882 break;
Chris Lattner1817bd42010-05-09 05:36:05 +00001883
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001884 case EXPR_CXX_MEMBER_CALL:
Douglas Gregor35942772011-09-09 21:34:22 +00001885 S = new (Context) CXXMemberCallExpr(Context, Empty);
Chris Lattner1817bd42010-05-09 05:36:05 +00001886 break;
Douglas Gregor39da0b82009-09-09 23:08:42 +00001887
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001888 case EXPR_CXX_CONSTRUCT:
Argyrios Kyrtzidis6d00c132010-07-10 11:46:15 +00001889 S = new (Context) CXXConstructExpr(Empty);
1890 break;
1891
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001892 case EXPR_CXX_TEMPORARY_OBJECT:
Argyrios Kyrtzidis6d00c132010-07-10 11:46:15 +00001893 S = new (Context) CXXTemporaryObjectExpr(Empty);
Douglas Gregor39da0b82009-09-09 23:08:42 +00001894 break;
Sam Weinigce757a72010-01-16 21:21:01 +00001895
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001896 case EXPR_CXX_STATIC_CAST:
Douglas Gregor35942772011-09-09 21:34:22 +00001897 S = CXXStaticCastExpr::CreateEmpty(Context,
Sebastian Redl60adf4a2010-08-18 23:56:52 +00001898 /*PathSize*/ Record[ASTStmtReader::NumExprFields]);
Sam Weinigce757a72010-01-16 21:21:01 +00001899 break;
1900
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001901 case EXPR_CXX_DYNAMIC_CAST:
Douglas Gregor35942772011-09-09 21:34:22 +00001902 S = CXXDynamicCastExpr::CreateEmpty(Context,
Sebastian Redl60adf4a2010-08-18 23:56:52 +00001903 /*PathSize*/ Record[ASTStmtReader::NumExprFields]);
Sam Weinigce757a72010-01-16 21:21:01 +00001904 break;
1905
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001906 case EXPR_CXX_REINTERPRET_CAST:
Douglas Gregor35942772011-09-09 21:34:22 +00001907 S = CXXReinterpretCastExpr::CreateEmpty(Context,
Sebastian Redl60adf4a2010-08-18 23:56:52 +00001908 /*PathSize*/ Record[ASTStmtReader::NumExprFields]);
Sam Weinigce757a72010-01-16 21:21:01 +00001909 break;
1910
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001911 case EXPR_CXX_CONST_CAST:
Douglas Gregor35942772011-09-09 21:34:22 +00001912 S = CXXConstCastExpr::CreateEmpty(Context);
Sam Weinigce757a72010-01-16 21:21:01 +00001913 break;
1914
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001915 case EXPR_CXX_FUNCTIONAL_CAST:
Douglas Gregor35942772011-09-09 21:34:22 +00001916 S = CXXFunctionalCastExpr::CreateEmpty(Context,
Sebastian Redl60adf4a2010-08-18 23:56:52 +00001917 /*PathSize*/ Record[ASTStmtReader::NumExprFields]);
Sam Weinigce757a72010-01-16 21:21:01 +00001918 break;
1919
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001920 case EXPR_CXX_BOOL_LITERAL:
Sam Weinigeb7f9612010-02-07 06:32:43 +00001921 S = new (Context) CXXBoolLiteralExpr(Empty);
1922 break;
Sam Weinigce757a72010-01-16 21:21:01 +00001923
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001924 case EXPR_CXX_NULL_PTR_LITERAL:
Sam Weinigeb7f9612010-02-07 06:32:43 +00001925 S = new (Context) CXXNullPtrLiteralExpr(Empty);
1926 break;
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001927 case EXPR_CXX_TYPEID_EXPR:
Chris Lattner14ab24f2010-05-09 06:03:39 +00001928 S = new (Context) CXXTypeidExpr(Empty, true);
1929 break;
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001930 case EXPR_CXX_TYPEID_TYPE:
Chris Lattner14ab24f2010-05-09 06:03:39 +00001931 S = new (Context) CXXTypeidExpr(Empty, false);
1932 break;
Francois Pichet01b7c302010-09-08 12:20:18 +00001933 case EXPR_CXX_UUIDOF_EXPR:
1934 S = new (Context) CXXUuidofExpr(Empty, true);
1935 break;
1936 case EXPR_CXX_UUIDOF_TYPE:
1937 S = new (Context) CXXUuidofExpr(Empty, false);
1938 break;
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001939 case EXPR_CXX_THIS:
Chris Lattner2fbdfcd2010-05-09 06:15:05 +00001940 S = new (Context) CXXThisExpr(Empty);
1941 break;
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001942 case EXPR_CXX_THROW:
Chris Lattner2fbdfcd2010-05-09 06:15:05 +00001943 S = new (Context) CXXThrowExpr(Empty);
1944 break;
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001945 case EXPR_CXX_DEFAULT_ARG: {
Sebastian Redl60adf4a2010-08-18 23:56:52 +00001946 bool HasOtherExprStored = Record[ASTStmtReader::NumExprFields];
Argyrios Kyrtzidis8a507332010-07-02 23:30:15 +00001947 if (HasOtherExprStored) {
1948 Expr *SubExpr = ReadSubExpr();
Douglas Gregor35942772011-09-09 21:34:22 +00001949 S = CXXDefaultArgExpr::Create(Context, SourceLocation(), 0, SubExpr);
Argyrios Kyrtzidis8a507332010-07-02 23:30:15 +00001950 } else
1951 S = new (Context) CXXDefaultArgExpr(Empty);
Chris Lattner030854b2010-05-09 06:40:08 +00001952 break;
Argyrios Kyrtzidis8a507332010-07-02 23:30:15 +00001953 }
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001954 case EXPR_CXX_BIND_TEMPORARY:
Chris Lattnerd2598362010-05-10 00:25:06 +00001955 S = new (Context) CXXBindTemporaryExpr(Empty);
1956 break;
Douglas Gregore2ca6d42010-09-02 21:50:02 +00001957
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001958 case EXPR_CXX_SCALAR_VALUE_INIT:
Douglas Gregored8abf12010-07-08 06:14:04 +00001959 S = new (Context) CXXScalarValueInitExpr(Empty);
Chris Lattner59218632010-05-10 01:22:27 +00001960 break;
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001961 case EXPR_CXX_NEW:
Chris Lattner59218632010-05-10 01:22:27 +00001962 S = new (Context) CXXNewExpr(Empty);
1963 break;
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001964 case EXPR_CXX_DELETE:
Argyrios Kyrtzidis95fc98c2010-06-22 17:07:59 +00001965 S = new (Context) CXXDeleteExpr(Empty);
1966 break;
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001967 case EXPR_CXX_PSEUDO_DESTRUCTOR:
Argyrios Kyrtzidisde4bd182010-06-28 09:32:03 +00001968 S = new (Context) CXXPseudoDestructorExpr(Empty);
1969 break;
Chris Lattner59218632010-05-10 01:22:27 +00001970
John McCall4765fa02010-12-06 08:20:24 +00001971 case EXPR_EXPR_WITH_CLEANUPS:
John McCall80ee6e82011-11-10 05:35:25 +00001972 S = ExprWithCleanups::Create(Context, Empty,
1973 Record[ASTStmtReader::NumExprFields]);
Chris Lattnerd2598362010-05-10 00:25:06 +00001974 break;
Argyrios Kyrtzidis8dfbd8b2010-06-24 08:57:31 +00001975
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001976 case EXPR_CXX_DEPENDENT_SCOPE_MEMBER:
Douglas Gregor35942772011-09-09 21:34:22 +00001977 S = CXXDependentScopeMemberExpr::CreateEmpty(Context,
Douglas Gregordef03542011-02-04 12:01:24 +00001978 /*HasExplicitTemplateArgs=*/Record[ASTStmtReader::NumExprFields],
1979 /*NumTemplateArgs=*/Record[ASTStmtReader::NumExprFields]
1980 ? Record[ASTStmtReader::NumExprFields + 1]
1981 : 0);
Argyrios Kyrtzidis8dfbd8b2010-06-24 08:57:31 +00001982 break;
1983
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001984 case EXPR_CXX_DEPENDENT_SCOPE_DECL_REF:
Douglas Gregor35942772011-09-09 21:34:22 +00001985 S = DependentScopeDeclRefExpr::CreateEmpty(Context,
Douglas Gregordef03542011-02-04 12:01:24 +00001986 /*HasExplicitTemplateArgs=*/Record[ASTStmtReader::NumExprFields],
1987 /*NumTemplateArgs=*/Record[ASTStmtReader::NumExprFields]
1988 ? Record[ASTStmtReader::NumExprFields + 1]
1989 : 0);
Argyrios Kyrtzidis12dffcd2010-06-28 09:31:56 +00001990 break;
1991
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001992 case EXPR_CXX_UNRESOLVED_CONSTRUCT:
Douglas Gregor35942772011-09-09 21:34:22 +00001993 S = CXXUnresolvedConstructExpr::CreateEmpty(Context,
Sebastian Redl60adf4a2010-08-18 23:56:52 +00001994 /*NumArgs=*/Record[ASTStmtReader::NumExprFields]);
Argyrios Kyrtzidisa77eb082010-06-25 09:03:26 +00001995 break;
1996
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001997 case EXPR_CXX_UNRESOLVED_MEMBER:
Douglas Gregor35942772011-09-09 21:34:22 +00001998 S = UnresolvedMemberExpr::CreateEmpty(Context,
Douglas Gregordef03542011-02-04 12:01:24 +00001999 /*HasExplicitTemplateArgs=*/Record[ASTStmtReader::NumExprFields],
2000 /*NumTemplateArgs=*/Record[ASTStmtReader::NumExprFields]
2001 ? Record[ASTStmtReader::NumExprFields + 1]
2002 : 0);
Argyrios Kyrtzidis8dfbd8b2010-06-24 08:57:31 +00002003 break;
Argyrios Kyrtzidisbd65bb52010-06-25 09:03:34 +00002004
Sebastian Redl8538e8d2010-08-18 23:57:32 +00002005 case EXPR_CXX_UNRESOLVED_LOOKUP:
Douglas Gregor35942772011-09-09 21:34:22 +00002006 S = UnresolvedLookupExpr::CreateEmpty(Context,
Douglas Gregordef03542011-02-04 12:01:24 +00002007 /*HasExplicitTemplateArgs=*/Record[ASTStmtReader::NumExprFields],
2008 /*NumTemplateArgs=*/Record[ASTStmtReader::NumExprFields]
2009 ? Record[ASTStmtReader::NumExprFields + 1]
2010 : 0);
Argyrios Kyrtzidisbd65bb52010-06-25 09:03:34 +00002011 break;
Argyrios Kyrtzidis6d00c132010-07-10 11:46:15 +00002012
Sebastian Redl8538e8d2010-08-18 23:57:32 +00002013 case EXPR_CXX_UNARY_TYPE_TRAIT:
Argyrios Kyrtzidis6d00c132010-07-10 11:46:15 +00002014 S = new (Context) UnaryTypeTraitExpr(Empty);
2015 break;
Sebastian Redl6b219d02010-09-10 20:55:54 +00002016
Francois Pichetf1872372010-12-08 22:35:30 +00002017 case EXPR_BINARY_TYPE_TRAIT:
Francois Pichet6ad6f282010-12-07 00:08:36 +00002018 S = new (Context) BinaryTypeTraitExpr(Empty);
2019 break;
2020
John Wiegley21ff2e52011-04-28 00:16:57 +00002021 case EXPR_ARRAY_TYPE_TRAIT:
2022 S = new (Context) ArrayTypeTraitExpr(Empty);
2023 break;
2024
John Wiegley55262202011-04-25 06:54:41 +00002025 case EXPR_CXX_EXPRESSION_TRAIT:
2026 S = new (Context) ExpressionTraitExpr(Empty);
2027 break;
2028
Sebastian Redl6b219d02010-09-10 20:55:54 +00002029 case EXPR_CXX_NOEXCEPT:
2030 S = new (Context) CXXNoexceptExpr(Empty);
2031 break;
John McCall7cd7d1a2010-11-15 23:31:06 +00002032
Douglas Gregorbe230c32011-01-03 17:17:50 +00002033 case EXPR_PACK_EXPANSION:
2034 S = new (Context) PackExpansionExpr(Empty);
2035 break;
2036
Douglas Gregoree8aff02011-01-04 17:33:58 +00002037 case EXPR_SIZEOF_PACK:
2038 S = new (Context) SizeOfPackExpr(Empty);
2039 break;
2040
John McCall7110fd62011-07-15 07:00:14 +00002041 case EXPR_SUBST_NON_TYPE_TEMPLATE_PARM:
2042 S = new (Context) SubstNonTypeTemplateParmExpr(Empty);
2043 break;
2044
Douglas Gregorc7793c72011-01-15 01:15:58 +00002045 case EXPR_SUBST_NON_TYPE_TEMPLATE_PARM_PACK:
2046 S = new (Context) SubstNonTypeTemplateParmPackExpr(Empty);
2047 break;
2048
Douglas Gregor03e80032011-06-21 17:03:29 +00002049 case EXPR_MATERIALIZE_TEMPORARY:
2050 S = new (Context) MaterializeTemporaryExpr(Empty);
2051 break;
2052
Argyrios Kyrtzidis8bc27822011-12-03 03:49:52 +00002053 case EXPR_OPAQUE_VALUE:
2054 S = new (Context) OpaqueValueExpr(Empty);
John McCall7cd7d1a2010-11-15 23:31:06 +00002055 break;
Peter Collingbournee08ce652011-02-09 21:07:24 +00002056
2057 case EXPR_CUDA_KERNEL_CALL:
Douglas Gregor35942772011-09-09 21:34:22 +00002058 S = new (Context) CUDAKernelCallExpr(Context, Empty);
Peter Collingbournee08ce652011-02-09 21:07:24 +00002059 break;
Tanya Lattner61eee0c2011-06-04 00:47:47 +00002060
2061 case EXPR_ASTYPE:
2062 S = new (Context) AsTypeExpr(Empty);
2063 break;
Eli Friedman276b0612011-10-11 02:20:01 +00002064
John McCall4b9c2d22011-11-06 09:01:30 +00002065 case EXPR_PSEUDO_OBJECT: {
2066 unsigned numSemanticExprs = Record[ASTStmtReader::NumExprFields];
2067 S = PseudoObjectExpr::Create(Context, Empty, numSemanticExprs);
2068 break;
2069 }
2070
Eli Friedman276b0612011-10-11 02:20:01 +00002071 case EXPR_ATOMIC:
2072 S = new (Context) AtomicExpr(Empty);
2073 break;
Chris Lattner4c6f9522009-04-27 05:14:47 +00002074 }
Argyrios Kyrtzidis6d00c132010-07-10 11:46:15 +00002075
Chris Lattner4c6f9522009-04-27 05:14:47 +00002076 // We hit a STMT_STOP, so we're done with this expression.
2077 if (Finished)
2078 break;
2079
2080 ++NumStatementsRead;
2081
Argyrios Kyrtzidise6f08682011-10-21 23:02:28 +00002082 if (S && !IsStmtReference) {
Argyrios Kyrtzidis919e6932010-06-28 22:28:35 +00002083 Reader.Visit(S);
Argyrios Kyrtzidise6f08682011-10-21 23:02:28 +00002084 StmtEntries[Cursor.GetCurrentBitNo()] = S;
2085 }
2086
Chris Lattner4c6f9522009-04-27 05:14:47 +00002087
2088 assert(Idx == Record.size() && "Invalid deserialization of statement");
2089 StmtStack.push_back(S);
2090 }
Argyrios Kyrtzidis919e6932010-06-28 22:28:35 +00002091
2092#ifndef NDEBUG
2093 assert(StmtStack.size() > PrevNumStmts && "Read too many sub stmts!");
2094 assert(StmtStack.size() == PrevNumStmts + 1 && "Extra expressions on stack!");
2095#endif
2096
2097 return StmtStack.pop_back_val();
Chris Lattner4c6f9522009-04-27 05:14:47 +00002098}