blob: 87912af461073120668635bccaf0567e6506ba58 [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 Gregor72a9ae12011-07-22 16:00:58 +000028 Module &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 Gregor72a9ae12011-07-22 16:00:58 +000069 ASTStmtReader(ASTReader &Reader, Module &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;
Douglas Gregor5cee1192011-07-27 05:40:30 +0000375 E->Kind = static_cast<StringLiteral::StringKind>(Record[Idx++]);
Anders Carlsson3e2193c2011-04-14 00:40:03 +0000376 E->IsPascal = Record[Idx++];
Chris Lattner4c6f9522009-04-27 05:14:47 +0000377
Mike Stump1eb44332009-09-09 15:08:12 +0000378 // Read string data
Daniel Dunbarb6480232009-09-22 03:27:33 +0000379 llvm::SmallString<16> Str(&Record[Idx], &Record[Idx] + Len);
Douglas Gregor35942772011-09-09 21:34:22 +0000380 E->setString(Reader.getContext(), Str.str());
Chris Lattner4c6f9522009-04-27 05:14:47 +0000381 Idx += Len;
382
383 // Read source locations
384 for (unsigned I = 0, N = E->getNumConcatenated(); I != N; ++I)
Sebastian Redlc3632732010-10-05 15:59:54 +0000385 E->setStrTokenLoc(I, ReadSourceLocation(Record, Idx));
Chris Lattner4c6f9522009-04-27 05:14:47 +0000386}
387
Sebastian Redl60adf4a2010-08-18 23:56:52 +0000388void ASTStmtReader::VisitCharacterLiteral(CharacterLiteral *E) {
Chris Lattner4c6f9522009-04-27 05:14:47 +0000389 VisitExpr(E);
390 E->setValue(Record[Idx++]);
Sebastian Redlc3632732010-10-05 15:59:54 +0000391 E->setLocation(ReadSourceLocation(Record, Idx));
Douglas Gregor5cee1192011-07-27 05:40:30 +0000392 E->setKind(static_cast<CharacterLiteral::CharacterKind>(Record[Idx++]));
Chris Lattner4c6f9522009-04-27 05:14:47 +0000393}
394
Sebastian Redl60adf4a2010-08-18 23:56:52 +0000395void ASTStmtReader::VisitParenExpr(ParenExpr *E) {
Chris Lattner4c6f9522009-04-27 05:14:47 +0000396 VisitExpr(E);
Sebastian Redlc3632732010-10-05 15:59:54 +0000397 E->setLParen(ReadSourceLocation(Record, Idx));
398 E->setRParen(ReadSourceLocation(Record, Idx));
Argyrios Kyrtzidisd98a2ab2010-06-29 22:46:25 +0000399 E->setSubExpr(Reader.ReadSubExpr());
Chris Lattner4c6f9522009-04-27 05:14:47 +0000400}
401
Sebastian Redl60adf4a2010-08-18 23:56:52 +0000402void ASTStmtReader::VisitParenListExpr(ParenListExpr *E) {
Argyrios Kyrtzidis37bdfe22010-06-30 08:49:18 +0000403 VisitExpr(E);
404 unsigned NumExprs = Record[Idx++];
Douglas Gregor35942772011-09-09 21:34:22 +0000405 E->Exprs = new (Reader.getContext()) Stmt*[NumExprs];
Argyrios Kyrtzidis37bdfe22010-06-30 08:49:18 +0000406 for (unsigned i = 0; i != NumExprs; ++i)
407 E->Exprs[i] = Reader.ReadSubStmt();
408 E->NumExprs = NumExprs;
Sebastian Redlc3632732010-10-05 15:59:54 +0000409 E->LParenLoc = ReadSourceLocation(Record, Idx);
410 E->RParenLoc = ReadSourceLocation(Record, Idx);
Argyrios Kyrtzidis37bdfe22010-06-30 08:49:18 +0000411}
412
Sebastian Redl60adf4a2010-08-18 23:56:52 +0000413void ASTStmtReader::VisitUnaryOperator(UnaryOperator *E) {
Chris Lattner4c6f9522009-04-27 05:14:47 +0000414 VisitExpr(E);
Argyrios Kyrtzidisd98a2ab2010-06-29 22:46:25 +0000415 E->setSubExpr(Reader.ReadSubExpr());
Chris Lattner4c6f9522009-04-27 05:14:47 +0000416 E->setOpcode((UnaryOperator::Opcode)Record[Idx++]);
Sebastian Redlc3632732010-10-05 15:59:54 +0000417 E->setOperatorLoc(ReadSourceLocation(Record, Idx));
Chris Lattner4c6f9522009-04-27 05:14:47 +0000418}
419
Sebastian Redl60adf4a2010-08-18 23:56:52 +0000420void ASTStmtReader::VisitOffsetOfExpr(OffsetOfExpr *E) {
Douglas Gregor8ecdb652010-04-28 22:16:22 +0000421 typedef OffsetOfExpr::OffsetOfNode Node;
422 VisitExpr(E);
423 assert(E->getNumComponents() == Record[Idx]);
424 ++Idx;
425 assert(E->getNumExpressions() == Record[Idx]);
426 ++Idx;
Sebastian Redlc3632732010-10-05 15:59:54 +0000427 E->setOperatorLoc(ReadSourceLocation(Record, Idx));
428 E->setRParenLoc(ReadSourceLocation(Record, Idx));
429 E->setTypeSourceInfo(GetTypeSourceInfo(Record, Idx));
Douglas Gregor8ecdb652010-04-28 22:16:22 +0000430 for (unsigned I = 0, N = E->getNumComponents(); I != N; ++I) {
431 Node::Kind Kind = static_cast<Node::Kind>(Record[Idx++]);
Sebastian Redlc3632732010-10-05 15:59:54 +0000432 SourceLocation Start = ReadSourceLocation(Record, Idx);
433 SourceLocation End = ReadSourceLocation(Record, Idx);
Douglas Gregor8ecdb652010-04-28 22:16:22 +0000434 switch (Kind) {
435 case Node::Array:
436 E->setComponent(I, Node(Start, Record[Idx++], End));
437 break;
438
439 case Node::Field:
Douglas Gregor409448c2011-07-21 22:35:25 +0000440 E->setComponent(I, Node(Start, ReadDeclAs<FieldDecl>(Record, Idx), End));
Douglas Gregor8ecdb652010-04-28 22:16:22 +0000441 break;
442
443 case Node::Identifier:
Douglas Gregor95eab172011-07-28 20:55:49 +0000444 E->setComponent(I,
445 Node(Start,
446 Reader.GetIdentifierInfo(F, Record, Idx),
447 End));
Douglas Gregor8ecdb652010-04-28 22:16:22 +0000448 break;
Douglas Gregorcc8a5d52010-04-29 00:18:15 +0000449
Argyrios Kyrtzidisafbf3122010-07-29 18:16:10 +0000450 case Node::Base: {
Douglas Gregor35942772011-09-09 21:34:22 +0000451 CXXBaseSpecifier *Base = new (Reader.getContext()) CXXBaseSpecifier();
Sebastian Redlc3632732010-10-05 15:59:54 +0000452 *Base = Reader.ReadCXXBaseSpecifier(F, Record, Idx);
Argyrios Kyrtzidisafbf3122010-07-29 18:16:10 +0000453 E->setComponent(I, Node(Base));
Douglas Gregorcc8a5d52010-04-29 00:18:15 +0000454 break;
Douglas Gregor8ecdb652010-04-28 22:16:22 +0000455 }
Argyrios Kyrtzidisafbf3122010-07-29 18:16:10 +0000456 }
Douglas Gregor8ecdb652010-04-28 22:16:22 +0000457 }
458
459 for (unsigned I = 0, N = E->getNumExpressions(); I != N; ++I)
Argyrios Kyrtzidisd98a2ab2010-06-29 22:46:25 +0000460 E->setIndexExpr(I, Reader.ReadSubExpr());
Douglas Gregor8ecdb652010-04-28 22:16:22 +0000461}
462
Peter Collingbournef4e3cfb2011-03-11 19:24:49 +0000463void ASTStmtReader::VisitUnaryExprOrTypeTraitExpr(UnaryExprOrTypeTraitExpr *E) {
Chris Lattner4c6f9522009-04-27 05:14:47 +0000464 VisitExpr(E);
Peter Collingbournef4e3cfb2011-03-11 19:24:49 +0000465 E->setKind(static_cast<UnaryExprOrTypeTrait>(Record[Idx++]));
Chris Lattner4c6f9522009-04-27 05:14:47 +0000466 if (Record[Idx] == 0) {
Argyrios Kyrtzidisd98a2ab2010-06-29 22:46:25 +0000467 E->setArgument(Reader.ReadSubExpr());
Chris Lattner4c6f9522009-04-27 05:14:47 +0000468 ++Idx;
469 } else {
Sebastian Redlc3632732010-10-05 15:59:54 +0000470 E->setArgument(GetTypeSourceInfo(Record, Idx));
Chris Lattner4c6f9522009-04-27 05:14:47 +0000471 }
Sebastian Redlc3632732010-10-05 15:59:54 +0000472 E->setOperatorLoc(ReadSourceLocation(Record, Idx));
473 E->setRParenLoc(ReadSourceLocation(Record, Idx));
Chris Lattner4c6f9522009-04-27 05:14:47 +0000474}
475
Sebastian Redl60adf4a2010-08-18 23:56:52 +0000476void ASTStmtReader::VisitArraySubscriptExpr(ArraySubscriptExpr *E) {
Chris Lattner4c6f9522009-04-27 05:14:47 +0000477 VisitExpr(E);
Argyrios Kyrtzidisd98a2ab2010-06-29 22:46:25 +0000478 E->setLHS(Reader.ReadSubExpr());
479 E->setRHS(Reader.ReadSubExpr());
Sebastian Redlc3632732010-10-05 15:59:54 +0000480 E->setRBracketLoc(ReadSourceLocation(Record, Idx));
Chris Lattner4c6f9522009-04-27 05:14:47 +0000481}
482
Sebastian Redl60adf4a2010-08-18 23:56:52 +0000483void ASTStmtReader::VisitCallExpr(CallExpr *E) {
Chris Lattner4c6f9522009-04-27 05:14:47 +0000484 VisitExpr(E);
Douglas Gregor35942772011-09-09 21:34:22 +0000485 E->setNumArgs(Reader.getContext(), Record[Idx++]);
Sebastian Redlc3632732010-10-05 15:59:54 +0000486 E->setRParenLoc(ReadSourceLocation(Record, Idx));
Argyrios Kyrtzidisd98a2ab2010-06-29 22:46:25 +0000487 E->setCallee(Reader.ReadSubExpr());
Chris Lattner4c6f9522009-04-27 05:14:47 +0000488 for (unsigned I = 0, N = E->getNumArgs(); I != N; ++I)
Argyrios Kyrtzidisd98a2ab2010-06-29 22:46:25 +0000489 E->setArg(I, Reader.ReadSubExpr());
Chris Lattner4c6f9522009-04-27 05:14:47 +0000490}
491
John McCall7110fd62011-07-15 07:00:14 +0000492void ASTStmtReader::VisitCXXMemberCallExpr(CXXMemberCallExpr *E) {
493 VisitCallExpr(E);
494}
495
Sebastian Redl60adf4a2010-08-18 23:56:52 +0000496void ASTStmtReader::VisitMemberExpr(MemberExpr *E) {
Argyrios Kyrtzidis663e3802010-07-08 13:09:47 +0000497 // Don't call VisitExpr, this is fully initialized at creation.
498 assert(E->getStmtClass() == Stmt::MemberExprClass &&
499 "It's a subclass, we must advance Idx!");
Chris Lattner4c6f9522009-04-27 05:14:47 +0000500}
501
Sebastian Redl60adf4a2010-08-18 23:56:52 +0000502void ASTStmtReader::VisitObjCIsaExpr(ObjCIsaExpr *E) {
Steve Narofff242b1b2009-07-24 17:54:45 +0000503 VisitExpr(E);
Argyrios Kyrtzidisd98a2ab2010-06-29 22:46:25 +0000504 E->setBase(Reader.ReadSubExpr());
Sebastian Redlc3632732010-10-05 15:59:54 +0000505 E->setIsaMemberLoc(ReadSourceLocation(Record, Idx));
Steve Narofff242b1b2009-07-24 17:54:45 +0000506 E->setArrow(Record[Idx++]);
Steve Narofff242b1b2009-07-24 17:54:45 +0000507}
508
John McCallf85e1932011-06-15 23:02:42 +0000509void ASTStmtReader::
510VisitObjCIndirectCopyRestoreExpr(ObjCIndirectCopyRestoreExpr *E) {
511 VisitExpr(E);
512 E->Operand = Reader.ReadSubExpr();
513 E->setShouldCopy(Record[Idx++]);
514}
515
516void ASTStmtReader::VisitObjCBridgedCastExpr(ObjCBridgedCastExpr *E) {
517 VisitExplicitCastExpr(E);
518 E->LParenLoc = ReadSourceLocation(Record, Idx);
519 E->BridgeKeywordLoc = ReadSourceLocation(Record, Idx);
520 E->Kind = Record[Idx++];
521}
522
Sebastian Redl60adf4a2010-08-18 23:56:52 +0000523void ASTStmtReader::VisitCastExpr(CastExpr *E) {
Chris Lattner4c6f9522009-04-27 05:14:47 +0000524 VisitExpr(E);
John McCallf871d0c2010-08-07 06:22:56 +0000525 unsigned NumBaseSpecs = Record[Idx++];
526 assert(NumBaseSpecs == E->path_size());
Argyrios Kyrtzidisd98a2ab2010-06-29 22:46:25 +0000527 E->setSubExpr(Reader.ReadSubExpr());
Anders Carlssoncdef2b72009-07-31 00:48:10 +0000528 E->setCastKind((CastExpr::CastKind)Record[Idx++]);
John McCallf871d0c2010-08-07 06:22:56 +0000529 CastExpr::path_iterator BaseI = E->path_begin();
Argyrios Kyrtzidis0745d0a2010-07-02 23:30:27 +0000530 while (NumBaseSpecs--) {
Douglas Gregor35942772011-09-09 21:34:22 +0000531 CXXBaseSpecifier *BaseSpec = new (Reader.getContext()) CXXBaseSpecifier;
Sebastian Redlc3632732010-10-05 15:59:54 +0000532 *BaseSpec = Reader.ReadCXXBaseSpecifier(F, Record, Idx);
John McCallf871d0c2010-08-07 06:22:56 +0000533 *BaseI++ = BaseSpec;
Argyrios Kyrtzidis0745d0a2010-07-02 23:30:27 +0000534 }
Chris Lattner4c6f9522009-04-27 05:14:47 +0000535}
536
Sebastian Redl60adf4a2010-08-18 23:56:52 +0000537void ASTStmtReader::VisitBinaryOperator(BinaryOperator *E) {
Chris Lattner4c6f9522009-04-27 05:14:47 +0000538 VisitExpr(E);
Argyrios Kyrtzidisd98a2ab2010-06-29 22:46:25 +0000539 E->setLHS(Reader.ReadSubExpr());
540 E->setRHS(Reader.ReadSubExpr());
Chris Lattner4c6f9522009-04-27 05:14:47 +0000541 E->setOpcode((BinaryOperator::Opcode)Record[Idx++]);
Sebastian Redlc3632732010-10-05 15:59:54 +0000542 E->setOperatorLoc(ReadSourceLocation(Record, Idx));
Chris Lattner4c6f9522009-04-27 05:14:47 +0000543}
544
Sebastian Redl60adf4a2010-08-18 23:56:52 +0000545void ASTStmtReader::VisitCompoundAssignOperator(CompoundAssignOperator *E) {
Chris Lattner4c6f9522009-04-27 05:14:47 +0000546 VisitBinaryOperator(E);
Douglas Gregor393f2492011-07-22 00:38:23 +0000547 E->setComputationLHSType(Reader.readType(F, Record, Idx));
548 E->setComputationResultType(Reader.readType(F, Record, Idx));
Chris Lattner4c6f9522009-04-27 05:14:47 +0000549}
550
Sebastian Redl60adf4a2010-08-18 23:56:52 +0000551void ASTStmtReader::VisitConditionalOperator(ConditionalOperator *E) {
Chris Lattner4c6f9522009-04-27 05:14:47 +0000552 VisitExpr(E);
John McCall56ca35d2011-02-17 10:25:35 +0000553 E->SubExprs[ConditionalOperator::COND] = Reader.ReadSubExpr();
554 E->SubExprs[ConditionalOperator::LHS] = Reader.ReadSubExpr();
555 E->SubExprs[ConditionalOperator::RHS] = Reader.ReadSubExpr();
556 E->QuestionLoc = ReadSourceLocation(Record, Idx);
557 E->ColonLoc = ReadSourceLocation(Record, Idx);
558}
559
560void
561ASTStmtReader::VisitBinaryConditionalOperator(BinaryConditionalOperator *E) {
562 VisitExpr(E);
563 E->OpaqueValue = cast<OpaqueValueExpr>(Reader.ReadSubExpr());
564 E->SubExprs[BinaryConditionalOperator::COMMON] = Reader.ReadSubExpr();
565 E->SubExprs[BinaryConditionalOperator::COND] = Reader.ReadSubExpr();
566 E->SubExprs[BinaryConditionalOperator::LHS] = Reader.ReadSubExpr();
567 E->SubExprs[BinaryConditionalOperator::RHS] = Reader.ReadSubExpr();
568 E->QuestionLoc = ReadSourceLocation(Record, Idx);
569 E->ColonLoc = ReadSourceLocation(Record, Idx);
570
571 E->getOpaqueValue()->setSourceExpr(E->getCommon());
Chris Lattner4c6f9522009-04-27 05:14:47 +0000572}
573
Sebastian Redl60adf4a2010-08-18 23:56:52 +0000574void ASTStmtReader::VisitImplicitCastExpr(ImplicitCastExpr *E) {
Chris Lattner4c6f9522009-04-27 05:14:47 +0000575 VisitCastExpr(E);
Chris Lattner4c6f9522009-04-27 05:14:47 +0000576}
577
Sebastian Redl60adf4a2010-08-18 23:56:52 +0000578void ASTStmtReader::VisitExplicitCastExpr(ExplicitCastExpr *E) {
Chris Lattner4c6f9522009-04-27 05:14:47 +0000579 VisitCastExpr(E);
Sebastian Redlc3632732010-10-05 15:59:54 +0000580 E->setTypeInfoAsWritten(GetTypeSourceInfo(Record, Idx));
Chris Lattner4c6f9522009-04-27 05:14:47 +0000581}
582
Sebastian Redl60adf4a2010-08-18 23:56:52 +0000583void ASTStmtReader::VisitCStyleCastExpr(CStyleCastExpr *E) {
Chris Lattner4c6f9522009-04-27 05:14:47 +0000584 VisitExplicitCastExpr(E);
Sebastian Redlc3632732010-10-05 15:59:54 +0000585 E->setLParenLoc(ReadSourceLocation(Record, Idx));
586 E->setRParenLoc(ReadSourceLocation(Record, Idx));
Chris Lattner4c6f9522009-04-27 05:14:47 +0000587}
588
Sebastian Redl60adf4a2010-08-18 23:56:52 +0000589void ASTStmtReader::VisitCompoundLiteralExpr(CompoundLiteralExpr *E) {
Chris Lattner4c6f9522009-04-27 05:14:47 +0000590 VisitExpr(E);
Sebastian Redlc3632732010-10-05 15:59:54 +0000591 E->setLParenLoc(ReadSourceLocation(Record, Idx));
592 E->setTypeSourceInfo(GetTypeSourceInfo(Record, Idx));
Argyrios Kyrtzidisd98a2ab2010-06-29 22:46:25 +0000593 E->setInitializer(Reader.ReadSubExpr());
Chris Lattner4c6f9522009-04-27 05:14:47 +0000594 E->setFileScope(Record[Idx++]);
Chris Lattner4c6f9522009-04-27 05:14:47 +0000595}
596
Sebastian Redl60adf4a2010-08-18 23:56:52 +0000597void ASTStmtReader::VisitExtVectorElementExpr(ExtVectorElementExpr *E) {
Chris Lattner4c6f9522009-04-27 05:14:47 +0000598 VisitExpr(E);
Argyrios Kyrtzidisd98a2ab2010-06-29 22:46:25 +0000599 E->setBase(Reader.ReadSubExpr());
Douglas Gregor95eab172011-07-28 20:55:49 +0000600 E->setAccessor(Reader.GetIdentifierInfo(F, Record, Idx));
Sebastian Redlc3632732010-10-05 15:59:54 +0000601 E->setAccessorLoc(ReadSourceLocation(Record, Idx));
Chris Lattner4c6f9522009-04-27 05:14:47 +0000602}
603
Sebastian Redl60adf4a2010-08-18 23:56:52 +0000604void ASTStmtReader::VisitInitListExpr(InitListExpr *E) {
Chris Lattner4c6f9522009-04-27 05:14:47 +0000605 VisitExpr(E);
Argyrios Kyrtzidisd98a2ab2010-06-29 22:46:25 +0000606 E->setSyntacticForm(cast_or_null<InitListExpr>(Reader.ReadSubStmt()));
Sebastian Redlc3632732010-10-05 15:59:54 +0000607 E->setLBraceLoc(ReadSourceLocation(Record, Idx));
608 E->setRBraceLoc(ReadSourceLocation(Record, Idx));
Argyrios Kyrtzidis2ac0b7a2011-04-22 05:29:30 +0000609 bool isArrayFiller = Record[Idx++];
610 Expr *filler = 0;
611 if (isArrayFiller) {
612 filler = Reader.ReadSubExpr();
613 E->ArrayFillerOrUnionFieldInit = filler;
614 } else
Douglas Gregor409448c2011-07-21 22:35:25 +0000615 E->ArrayFillerOrUnionFieldInit = ReadDeclAs<FieldDecl>(Record, Idx);
Chris Lattner4c6f9522009-04-27 05:14:47 +0000616 E->sawArrayRangeDesignator(Record[Idx++]);
Argyrios Kyrtzidis2ac0b7a2011-04-22 05:29:30 +0000617 unsigned NumInits = Record[Idx++];
Douglas Gregor35942772011-09-09 21:34:22 +0000618 E->reserveInits(Reader.getContext(), NumInits);
Argyrios Kyrtzidis2ac0b7a2011-04-22 05:29:30 +0000619 if (isArrayFiller) {
620 for (unsigned I = 0; I != NumInits; ++I) {
621 Expr *init = Reader.ReadSubExpr();
Douglas Gregor35942772011-09-09 21:34:22 +0000622 E->updateInit(Reader.getContext(), I, init ? init : filler);
Argyrios Kyrtzidis2ac0b7a2011-04-22 05:29:30 +0000623 }
624 } else {
625 for (unsigned I = 0; I != NumInits; ++I)
Douglas Gregor35942772011-09-09 21:34:22 +0000626 E->updateInit(Reader.getContext(), I, Reader.ReadSubExpr());
Argyrios Kyrtzidis2ac0b7a2011-04-22 05:29:30 +0000627 }
Chris Lattner4c6f9522009-04-27 05:14:47 +0000628}
629
Sebastian Redl60adf4a2010-08-18 23:56:52 +0000630void ASTStmtReader::VisitDesignatedInitExpr(DesignatedInitExpr *E) {
Chris Lattner4c6f9522009-04-27 05:14:47 +0000631 typedef DesignatedInitExpr::Designator Designator;
632
633 VisitExpr(E);
634 unsigned NumSubExprs = Record[Idx++];
635 assert(NumSubExprs == E->getNumSubExprs() && "Wrong number of subexprs");
636 for (unsigned I = 0; I != NumSubExprs; ++I)
Argyrios Kyrtzidisd98a2ab2010-06-29 22:46:25 +0000637 E->setSubExpr(I, Reader.ReadSubExpr());
Sebastian Redlc3632732010-10-05 15:59:54 +0000638 E->setEqualOrColonLoc(ReadSourceLocation(Record, Idx));
Chris Lattner4c6f9522009-04-27 05:14:47 +0000639 E->setGNUSyntax(Record[Idx++]);
640
Chris Lattner5f9e2722011-07-23 10:55:15 +0000641 SmallVector<Designator, 4> Designators;
Chris Lattner4c6f9522009-04-27 05:14:47 +0000642 while (Idx < Record.size()) {
Sebastian Redl8538e8d2010-08-18 23:57:32 +0000643 switch ((DesignatorTypes)Record[Idx++]) {
644 case DESIG_FIELD_DECL: {
Douglas Gregor409448c2011-07-21 22:35:25 +0000645 FieldDecl *Field = ReadDeclAs<FieldDecl>(Record, Idx);
Mike Stump1eb44332009-09-09 15:08:12 +0000646 SourceLocation DotLoc
Sebastian Redlc3632732010-10-05 15:59:54 +0000647 = ReadSourceLocation(Record, Idx);
Mike Stump1eb44332009-09-09 15:08:12 +0000648 SourceLocation FieldLoc
Sebastian Redlc3632732010-10-05 15:59:54 +0000649 = ReadSourceLocation(Record, Idx);
Mike Stump1eb44332009-09-09 15:08:12 +0000650 Designators.push_back(Designator(Field->getIdentifier(), DotLoc,
Chris Lattner4c6f9522009-04-27 05:14:47 +0000651 FieldLoc));
652 Designators.back().setField(Field);
653 break;
654 }
655
Sebastian Redl8538e8d2010-08-18 23:57:32 +0000656 case DESIG_FIELD_NAME: {
Douglas Gregor95eab172011-07-28 20:55:49 +0000657 const IdentifierInfo *Name = Reader.GetIdentifierInfo(F, Record, Idx);
Mike Stump1eb44332009-09-09 15:08:12 +0000658 SourceLocation DotLoc
Sebastian Redlc3632732010-10-05 15:59:54 +0000659 = ReadSourceLocation(Record, Idx);
Mike Stump1eb44332009-09-09 15:08:12 +0000660 SourceLocation FieldLoc
Sebastian Redlc3632732010-10-05 15:59:54 +0000661 = ReadSourceLocation(Record, Idx);
Chris Lattner4c6f9522009-04-27 05:14:47 +0000662 Designators.push_back(Designator(Name, DotLoc, FieldLoc));
663 break;
664 }
Mike Stump1eb44332009-09-09 15:08:12 +0000665
Sebastian Redl8538e8d2010-08-18 23:57:32 +0000666 case DESIG_ARRAY: {
Chris Lattner4c6f9522009-04-27 05:14:47 +0000667 unsigned Index = Record[Idx++];
668 SourceLocation LBracketLoc
Sebastian Redlc3632732010-10-05 15:59:54 +0000669 = ReadSourceLocation(Record, Idx);
Chris Lattner4c6f9522009-04-27 05:14:47 +0000670 SourceLocation RBracketLoc
Sebastian Redlc3632732010-10-05 15:59:54 +0000671 = ReadSourceLocation(Record, Idx);
Chris Lattner4c6f9522009-04-27 05:14:47 +0000672 Designators.push_back(Designator(Index, LBracketLoc, RBracketLoc));
673 break;
674 }
675
Sebastian Redl8538e8d2010-08-18 23:57:32 +0000676 case DESIG_ARRAY_RANGE: {
Chris Lattner4c6f9522009-04-27 05:14:47 +0000677 unsigned Index = Record[Idx++];
678 SourceLocation LBracketLoc
Sebastian Redlc3632732010-10-05 15:59:54 +0000679 = ReadSourceLocation(Record, Idx);
Chris Lattner4c6f9522009-04-27 05:14:47 +0000680 SourceLocation EllipsisLoc
Sebastian Redlc3632732010-10-05 15:59:54 +0000681 = ReadSourceLocation(Record, Idx);
Chris Lattner4c6f9522009-04-27 05:14:47 +0000682 SourceLocation RBracketLoc
Sebastian Redlc3632732010-10-05 15:59:54 +0000683 = ReadSourceLocation(Record, Idx);
Chris Lattner4c6f9522009-04-27 05:14:47 +0000684 Designators.push_back(Designator(Index, LBracketLoc, EllipsisLoc,
685 RBracketLoc));
686 break;
687 }
688 }
689 }
Douglas Gregor35942772011-09-09 21:34:22 +0000690 E->setDesignators(Reader.getContext(),
Douglas Gregor319d57f2010-01-06 23:17:19 +0000691 Designators.data(), Designators.size());
Chris Lattner4c6f9522009-04-27 05:14:47 +0000692}
693
Sebastian Redl60adf4a2010-08-18 23:56:52 +0000694void ASTStmtReader::VisitImplicitValueInitExpr(ImplicitValueInitExpr *E) {
Chris Lattner4c6f9522009-04-27 05:14:47 +0000695 VisitExpr(E);
Chris Lattner4c6f9522009-04-27 05:14:47 +0000696}
697
Sebastian Redl60adf4a2010-08-18 23:56:52 +0000698void ASTStmtReader::VisitVAArgExpr(VAArgExpr *E) {
Chris Lattner4c6f9522009-04-27 05:14:47 +0000699 VisitExpr(E);
Argyrios Kyrtzidisd98a2ab2010-06-29 22:46:25 +0000700 E->setSubExpr(Reader.ReadSubExpr());
Sebastian Redlc3632732010-10-05 15:59:54 +0000701 E->setWrittenTypeInfo(GetTypeSourceInfo(Record, Idx));
702 E->setBuiltinLoc(ReadSourceLocation(Record, Idx));
703 E->setRParenLoc(ReadSourceLocation(Record, Idx));
Chris Lattner4c6f9522009-04-27 05:14:47 +0000704}
705
Sebastian Redl60adf4a2010-08-18 23:56:52 +0000706void ASTStmtReader::VisitAddrLabelExpr(AddrLabelExpr *E) {
Chris Lattner4c6f9522009-04-27 05:14:47 +0000707 VisitExpr(E);
Sebastian Redlc3632732010-10-05 15:59:54 +0000708 E->setAmpAmpLoc(ReadSourceLocation(Record, Idx));
709 E->setLabelLoc(ReadSourceLocation(Record, Idx));
Douglas Gregor409448c2011-07-21 22:35:25 +0000710 E->setLabel(ReadDeclAs<LabelDecl>(Record, Idx));
Chris Lattner4c6f9522009-04-27 05:14:47 +0000711}
712
Sebastian Redl60adf4a2010-08-18 23:56:52 +0000713void ASTStmtReader::VisitStmtExpr(StmtExpr *E) {
Chris Lattner4c6f9522009-04-27 05:14:47 +0000714 VisitExpr(E);
Sebastian Redlc3632732010-10-05 15:59:54 +0000715 E->setLParenLoc(ReadSourceLocation(Record, Idx));
716 E->setRParenLoc(ReadSourceLocation(Record, Idx));
Argyrios Kyrtzidisd98a2ab2010-06-29 22:46:25 +0000717 E->setSubStmt(cast_or_null<CompoundStmt>(Reader.ReadSubStmt()));
Chris Lattner4c6f9522009-04-27 05:14:47 +0000718}
719
Sebastian Redl60adf4a2010-08-18 23:56:52 +0000720void ASTStmtReader::VisitChooseExpr(ChooseExpr *E) {
Chris Lattner4c6f9522009-04-27 05:14:47 +0000721 VisitExpr(E);
Argyrios Kyrtzidisd98a2ab2010-06-29 22:46:25 +0000722 E->setCond(Reader.ReadSubExpr());
723 E->setLHS(Reader.ReadSubExpr());
724 E->setRHS(Reader.ReadSubExpr());
Sebastian Redlc3632732010-10-05 15:59:54 +0000725 E->setBuiltinLoc(ReadSourceLocation(Record, Idx));
726 E->setRParenLoc(ReadSourceLocation(Record, Idx));
Chris Lattner4c6f9522009-04-27 05:14:47 +0000727}
728
Sebastian Redl60adf4a2010-08-18 23:56:52 +0000729void ASTStmtReader::VisitGNUNullExpr(GNUNullExpr *E) {
Chris Lattner4c6f9522009-04-27 05:14:47 +0000730 VisitExpr(E);
Sebastian Redlc3632732010-10-05 15:59:54 +0000731 E->setTokenLocation(ReadSourceLocation(Record, Idx));
Chris Lattner4c6f9522009-04-27 05:14:47 +0000732}
733
Sebastian Redl60adf4a2010-08-18 23:56:52 +0000734void ASTStmtReader::VisitShuffleVectorExpr(ShuffleVectorExpr *E) {
Chris Lattner4c6f9522009-04-27 05:14:47 +0000735 VisitExpr(E);
Chris Lattner5f9e2722011-07-23 10:55:15 +0000736 SmallVector<Expr *, 16> Exprs;
Chris Lattner4c6f9522009-04-27 05:14:47 +0000737 unsigned NumExprs = Record[Idx++];
Argyrios Kyrtzidis919e6932010-06-28 22:28:35 +0000738 while (NumExprs--)
Argyrios Kyrtzidisd98a2ab2010-06-29 22:46:25 +0000739 Exprs.push_back(Reader.ReadSubExpr());
Douglas Gregor35942772011-09-09 21:34:22 +0000740 E->setExprs(Reader.getContext(), Exprs.data(), Exprs.size());
Sebastian Redlc3632732010-10-05 15:59:54 +0000741 E->setBuiltinLoc(ReadSourceLocation(Record, Idx));
742 E->setRParenLoc(ReadSourceLocation(Record, Idx));
Chris Lattner4c6f9522009-04-27 05:14:47 +0000743}
744
Sebastian Redl60adf4a2010-08-18 23:56:52 +0000745void ASTStmtReader::VisitBlockExpr(BlockExpr *E) {
Chris Lattner4c6f9522009-04-27 05:14:47 +0000746 VisitExpr(E);
Douglas Gregor409448c2011-07-21 22:35:25 +0000747 E->setBlockDecl(ReadDeclAs<BlockDecl>(Record, Idx));
Chris Lattner4c6f9522009-04-27 05:14:47 +0000748}
749
Sebastian Redl60adf4a2010-08-18 23:56:52 +0000750void ASTStmtReader::VisitBlockDeclRefExpr(BlockDeclRefExpr *E) {
Chris Lattner4c6f9522009-04-27 05:14:47 +0000751 VisitExpr(E);
Douglas Gregor409448c2011-07-21 22:35:25 +0000752 E->setDecl(ReadDeclAs<VarDecl>(Record, Idx));
Sebastian Redlc3632732010-10-05 15:59:54 +0000753 E->setLocation(ReadSourceLocation(Record, Idx));
Chris Lattner4c6f9522009-04-27 05:14:47 +0000754 E->setByRef(Record[Idx++]);
Fariborz Jahanian9b0b57c2009-06-20 00:02:26 +0000755 E->setConstQualAdded(Record[Idx++]);
Chris Lattner4c6f9522009-04-27 05:14:47 +0000756}
757
Peter Collingbournef111d932011-04-15 00:35:48 +0000758void ASTStmtReader::VisitGenericSelectionExpr(GenericSelectionExpr *E) {
759 VisitExpr(E);
760 E->NumAssocs = Record[Idx++];
Douglas Gregor35942772011-09-09 21:34:22 +0000761 E->AssocTypes = new (Reader.getContext()) TypeSourceInfo*[E->NumAssocs];
Peter Collingbournef111d932011-04-15 00:35:48 +0000762 E->SubExprs =
Douglas Gregor35942772011-09-09 21:34:22 +0000763 new(Reader.getContext()) Stmt*[GenericSelectionExpr::END_EXPR+E->NumAssocs];
Peter Collingbournef111d932011-04-15 00:35:48 +0000764
765 E->SubExprs[GenericSelectionExpr::CONTROLLING] = Reader.ReadSubExpr();
766 for (unsigned I = 0, N = E->getNumAssocs(); I != N; ++I) {
767 E->AssocTypes[I] = GetTypeSourceInfo(Record, Idx);
768 E->SubExprs[GenericSelectionExpr::END_EXPR+I] = Reader.ReadSubExpr();
769 }
770 E->ResultIndex = Record[Idx++];
771
772 E->GenericLoc = ReadSourceLocation(Record, Idx);
773 E->DefaultLoc = ReadSourceLocation(Record, Idx);
774 E->RParenLoc = ReadSourceLocation(Record, Idx);
775}
776
Eli Friedman276b0612011-10-11 02:20:01 +0000777void ASTStmtReader::VisitAtomicExpr(AtomicExpr *E) {
778 VisitExpr(E);
779 E->setOp(AtomicExpr::AtomicOp(Record[Idx++]));
780 E->setPtr(Reader.ReadSubExpr());
781 E->setOrder(Reader.ReadSubExpr());
782 E->setNumSubExprs(2);
783 if (E->getOp() != AtomicExpr::Load) {
784 E->setVal1(Reader.ReadSubExpr());
785 E->setNumSubExprs(3);
786 }
787 if (E->isCmpXChg()) {
788 E->setOrderFail(Reader.ReadSubExpr());
789 E->setVal2(Reader.ReadSubExpr());
790 E->setNumSubExprs(5);
791 }
792 E->setBuiltinLoc(ReadSourceLocation(Record, Idx));
793 E->setRParenLoc(ReadSourceLocation(Record, Idx));
794}
795
Chris Lattner4c6f9522009-04-27 05:14:47 +0000796//===----------------------------------------------------------------------===//
797// Objective-C Expressions and Statements
798
Sebastian Redl60adf4a2010-08-18 23:56:52 +0000799void ASTStmtReader::VisitObjCStringLiteral(ObjCStringLiteral *E) {
Chris Lattner4c6f9522009-04-27 05:14:47 +0000800 VisitExpr(E);
Argyrios Kyrtzidisd98a2ab2010-06-29 22:46:25 +0000801 E->setString(cast<StringLiteral>(Reader.ReadSubStmt()));
Sebastian Redlc3632732010-10-05 15:59:54 +0000802 E->setAtLoc(ReadSourceLocation(Record, Idx));
Chris Lattner4c6f9522009-04-27 05:14:47 +0000803}
804
Sebastian Redl60adf4a2010-08-18 23:56:52 +0000805void ASTStmtReader::VisitObjCEncodeExpr(ObjCEncodeExpr *E) {
Chris Lattner4c6f9522009-04-27 05:14:47 +0000806 VisitExpr(E);
Sebastian Redlc3632732010-10-05 15:59:54 +0000807 E->setEncodedTypeSourceInfo(GetTypeSourceInfo(Record, Idx));
808 E->setAtLoc(ReadSourceLocation(Record, Idx));
809 E->setRParenLoc(ReadSourceLocation(Record, Idx));
Chris Lattner4c6f9522009-04-27 05:14:47 +0000810}
811
Sebastian Redl60adf4a2010-08-18 23:56:52 +0000812void ASTStmtReader::VisitObjCSelectorExpr(ObjCSelectorExpr *E) {
Chris Lattner4c6f9522009-04-27 05:14:47 +0000813 VisitExpr(E);
Douglas Gregor2d2689a2011-07-28 21:16:51 +0000814 E->setSelector(Reader.ReadSelector(F, Record, Idx));
Sebastian Redlc3632732010-10-05 15:59:54 +0000815 E->setAtLoc(ReadSourceLocation(Record, Idx));
816 E->setRParenLoc(ReadSourceLocation(Record, Idx));
Chris Lattner4c6f9522009-04-27 05:14:47 +0000817}
818
Sebastian Redl60adf4a2010-08-18 23:56:52 +0000819void ASTStmtReader::VisitObjCProtocolExpr(ObjCProtocolExpr *E) {
Chris Lattner4c6f9522009-04-27 05:14:47 +0000820 VisitExpr(E);
Douglas Gregor409448c2011-07-21 22:35:25 +0000821 E->setProtocol(ReadDeclAs<ObjCProtocolDecl>(Record, Idx));
Sebastian Redlc3632732010-10-05 15:59:54 +0000822 E->setAtLoc(ReadSourceLocation(Record, Idx));
823 E->setRParenLoc(ReadSourceLocation(Record, Idx));
Chris Lattner4c6f9522009-04-27 05:14:47 +0000824}
825
Sebastian Redl60adf4a2010-08-18 23:56:52 +0000826void ASTStmtReader::VisitObjCIvarRefExpr(ObjCIvarRefExpr *E) {
Chris Lattner4c6f9522009-04-27 05:14:47 +0000827 VisitExpr(E);
Douglas Gregor409448c2011-07-21 22:35:25 +0000828 E->setDecl(ReadDeclAs<ObjCIvarDecl>(Record, Idx));
Sebastian Redlc3632732010-10-05 15:59:54 +0000829 E->setLocation(ReadSourceLocation(Record, Idx));
Argyrios Kyrtzidisd98a2ab2010-06-29 22:46:25 +0000830 E->setBase(Reader.ReadSubExpr());
Chris Lattner4c6f9522009-04-27 05:14:47 +0000831 E->setIsArrow(Record[Idx++]);
832 E->setIsFreeIvar(Record[Idx++]);
Chris Lattner4c6f9522009-04-27 05:14:47 +0000833}
834
Sebastian Redl60adf4a2010-08-18 23:56:52 +0000835void ASTStmtReader::VisitObjCPropertyRefExpr(ObjCPropertyRefExpr *E) {
Chris Lattner4c6f9522009-04-27 05:14:47 +0000836 VisitExpr(E);
John McCall12f78a62010-12-02 01:19:52 +0000837 bool Implicit = Record[Idx++] != 0;
838 if (Implicit) {
Douglas Gregor409448c2011-07-21 22:35:25 +0000839 ObjCMethodDecl *Getter = ReadDeclAs<ObjCMethodDecl>(Record, Idx);
840 ObjCMethodDecl *Setter = ReadDeclAs<ObjCMethodDecl>(Record, Idx);
John McCall12f78a62010-12-02 01:19:52 +0000841 E->setImplicitProperty(Getter, Setter);
842 } else {
Douglas Gregor409448c2011-07-21 22:35:25 +0000843 E->setExplicitProperty(ReadDeclAs<ObjCPropertyDecl>(Record, Idx));
Fariborz Jahanian8ac2d442010-10-14 16:04:05 +0000844 }
Sebastian Redlc3632732010-10-05 15:59:54 +0000845 E->setLocation(ReadSourceLocation(Record, Idx));
John McCall12f78a62010-12-02 01:19:52 +0000846 E->setReceiverLocation(ReadSourceLocation(Record, Idx));
847 switch (Record[Idx++]) {
848 case 0:
849 E->setBase(Reader.ReadSubExpr());
850 break;
851 case 1:
Douglas Gregor393f2492011-07-22 00:38:23 +0000852 E->setSuperReceiver(Reader.readType(F, Record, Idx));
John McCall12f78a62010-12-02 01:19:52 +0000853 break;
854 case 2:
Douglas Gregor409448c2011-07-21 22:35:25 +0000855 E->setClassReceiver(ReadDeclAs<ObjCInterfaceDecl>(Record, Idx));
John McCall12f78a62010-12-02 01:19:52 +0000856 break;
857 }
Chris Lattner4c6f9522009-04-27 05:14:47 +0000858}
859
Sebastian Redl60adf4a2010-08-18 23:56:52 +0000860void ASTStmtReader::VisitObjCMessageExpr(ObjCMessageExpr *E) {
Chris Lattner4c6f9522009-04-27 05:14:47 +0000861 VisitExpr(E);
Douglas Gregor04badcf2010-04-21 00:45:42 +0000862 assert(Record[Idx] == E->getNumArgs());
863 ++Idx;
Argyrios Kyrtzidis20718082011-10-03 06:36:51 +0000864 unsigned NumStoredSelLocs = Record[Idx++];
865 E->SelLocsKind = Record[Idx++];
John McCallf85e1932011-06-15 23:02:42 +0000866 E->setDelegateInitCall(Record[Idx++]);
Douglas Gregor04badcf2010-04-21 00:45:42 +0000867 ObjCMessageExpr::ReceiverKind Kind
868 = static_cast<ObjCMessageExpr::ReceiverKind>(Record[Idx++]);
869 switch (Kind) {
870 case ObjCMessageExpr::Instance:
Argyrios Kyrtzidisd98a2ab2010-06-29 22:46:25 +0000871 E->setInstanceReceiver(Reader.ReadSubExpr());
Douglas Gregor04badcf2010-04-21 00:45:42 +0000872 break;
873
874 case ObjCMessageExpr::Class:
Sebastian Redlc3632732010-10-05 15:59:54 +0000875 E->setClassReceiver(GetTypeSourceInfo(Record, Idx));
Douglas Gregor04badcf2010-04-21 00:45:42 +0000876 break;
877
878 case ObjCMessageExpr::SuperClass:
879 case ObjCMessageExpr::SuperInstance: {
Douglas Gregor393f2492011-07-22 00:38:23 +0000880 QualType T = Reader.readType(F, Record, Idx);
Sebastian Redlc3632732010-10-05 15:59:54 +0000881 SourceLocation SuperLoc = ReadSourceLocation(Record, Idx);
Douglas Gregor04badcf2010-04-21 00:45:42 +0000882 E->setSuper(SuperLoc, T, Kind == ObjCMessageExpr::SuperInstance);
883 break;
884 }
885 }
886
887 assert(Kind == E->getReceiverKind());
888
889 if (Record[Idx++])
Douglas Gregor409448c2011-07-21 22:35:25 +0000890 E->setMethodDecl(ReadDeclAs<ObjCMethodDecl>(Record, Idx));
Douglas Gregor04badcf2010-04-21 00:45:42 +0000891 else
Douglas Gregor2d2689a2011-07-28 21:16:51 +0000892 E->setSelector(Reader.ReadSelector(F, Record, Idx));
Douglas Gregor04badcf2010-04-21 00:45:42 +0000893
Argyrios Kyrtzidisf40f0d52010-12-10 20:08:27 +0000894 E->LBracLoc = ReadSourceLocation(Record, Idx);
895 E->RBracLoc = ReadSourceLocation(Record, Idx);
Chris Lattner4c6f9522009-04-27 05:14:47 +0000896
897 for (unsigned I = 0, N = E->getNumArgs(); I != N; ++I)
Argyrios Kyrtzidisd98a2ab2010-06-29 22:46:25 +0000898 E->setArg(I, Reader.ReadSubExpr());
Argyrios Kyrtzidis20718082011-10-03 06:36:51 +0000899
900 SourceLocation *Locs = E->getStoredSelLocs();
901 for (unsigned I = 0; I != NumStoredSelLocs; ++I)
902 Locs[I] = ReadSourceLocation(Record, Idx);
Chris Lattner4c6f9522009-04-27 05:14:47 +0000903}
904
Sebastian Redl60adf4a2010-08-18 23:56:52 +0000905void ASTStmtReader::VisitObjCForCollectionStmt(ObjCForCollectionStmt *S) {
Chris Lattner4c6f9522009-04-27 05:14:47 +0000906 VisitStmt(S);
Argyrios Kyrtzidisd98a2ab2010-06-29 22:46:25 +0000907 S->setElement(Reader.ReadSubStmt());
908 S->setCollection(Reader.ReadSubExpr());
909 S->setBody(Reader.ReadSubStmt());
Sebastian Redlc3632732010-10-05 15:59:54 +0000910 S->setForLoc(ReadSourceLocation(Record, Idx));
911 S->setRParenLoc(ReadSourceLocation(Record, Idx));
Chris Lattner4c6f9522009-04-27 05:14:47 +0000912}
913
Sebastian Redl60adf4a2010-08-18 23:56:52 +0000914void ASTStmtReader::VisitObjCAtCatchStmt(ObjCAtCatchStmt *S) {
Chris Lattner4c6f9522009-04-27 05:14:47 +0000915 VisitStmt(S);
Argyrios Kyrtzidisd98a2ab2010-06-29 22:46:25 +0000916 S->setCatchBody(Reader.ReadSubStmt());
Douglas Gregor409448c2011-07-21 22:35:25 +0000917 S->setCatchParamDecl(ReadDeclAs<VarDecl>(Record, Idx));
Sebastian Redlc3632732010-10-05 15:59:54 +0000918 S->setAtCatchLoc(ReadSourceLocation(Record, Idx));
919 S->setRParenLoc(ReadSourceLocation(Record, Idx));
Chris Lattner4c6f9522009-04-27 05:14:47 +0000920}
921
Sebastian Redl60adf4a2010-08-18 23:56:52 +0000922void ASTStmtReader::VisitObjCAtFinallyStmt(ObjCAtFinallyStmt *S) {
Chris Lattner4c6f9522009-04-27 05:14:47 +0000923 VisitStmt(S);
Argyrios Kyrtzidisd98a2ab2010-06-29 22:46:25 +0000924 S->setFinallyBody(Reader.ReadSubStmt());
Sebastian Redlc3632732010-10-05 15:59:54 +0000925 S->setAtFinallyLoc(ReadSourceLocation(Record, Idx));
Chris Lattner4c6f9522009-04-27 05:14:47 +0000926}
927
John McCallf85e1932011-06-15 23:02:42 +0000928void ASTStmtReader::VisitObjCAutoreleasePoolStmt(ObjCAutoreleasePoolStmt *S) {
929 VisitStmt(S);
930 S->setSubStmt(Reader.ReadSubStmt());
931 S->setAtLoc(ReadSourceLocation(Record, Idx));
932}
933
Sebastian Redl60adf4a2010-08-18 23:56:52 +0000934void ASTStmtReader::VisitObjCAtTryStmt(ObjCAtTryStmt *S) {
Chris Lattner4c6f9522009-04-27 05:14:47 +0000935 VisitStmt(S);
Douglas Gregor8f5e3dd2010-04-23 22:50:49 +0000936 assert(Record[Idx] == S->getNumCatchStmts());
937 ++Idx;
938 bool HasFinally = Record[Idx++];
Argyrios Kyrtzidisd98a2ab2010-06-29 22:46:25 +0000939 S->setTryBody(Reader.ReadSubStmt());
Argyrios Kyrtzidis919e6932010-06-28 22:28:35 +0000940 for (unsigned I = 0, N = S->getNumCatchStmts(); I != N; ++I)
Argyrios Kyrtzidisd98a2ab2010-06-29 22:46:25 +0000941 S->setCatchStmt(I, cast_or_null<ObjCAtCatchStmt>(Reader.ReadSubStmt()));
Douglas Gregor8f5e3dd2010-04-23 22:50:49 +0000942
Douglas Gregor8f5e3dd2010-04-23 22:50:49 +0000943 if (HasFinally)
Argyrios Kyrtzidisd98a2ab2010-06-29 22:46:25 +0000944 S->setFinallyStmt(Reader.ReadSubStmt());
Sebastian Redlc3632732010-10-05 15:59:54 +0000945 S->setAtTryLoc(ReadSourceLocation(Record, Idx));
Chris Lattner4c6f9522009-04-27 05:14:47 +0000946}
947
Sebastian Redl60adf4a2010-08-18 23:56:52 +0000948void ASTStmtReader::VisitObjCAtSynchronizedStmt(ObjCAtSynchronizedStmt *S) {
Chris Lattner4c6f9522009-04-27 05:14:47 +0000949 VisitStmt(S);
Argyrios Kyrtzidisd98a2ab2010-06-29 22:46:25 +0000950 S->setSynchExpr(Reader.ReadSubStmt());
951 S->setSynchBody(Reader.ReadSubStmt());
Sebastian Redlc3632732010-10-05 15:59:54 +0000952 S->setAtSynchronizedLoc(ReadSourceLocation(Record, Idx));
Chris Lattner4c6f9522009-04-27 05:14:47 +0000953}
954
Sebastian Redl60adf4a2010-08-18 23:56:52 +0000955void ASTStmtReader::VisitObjCAtThrowStmt(ObjCAtThrowStmt *S) {
Chris Lattner4c6f9522009-04-27 05:14:47 +0000956 VisitStmt(S);
Argyrios Kyrtzidisd98a2ab2010-06-29 22:46:25 +0000957 S->setThrowExpr(Reader.ReadSubStmt());
Sebastian Redlc3632732010-10-05 15:59:54 +0000958 S->setThrowLoc(ReadSourceLocation(Record, Idx));
Chris Lattner4c6f9522009-04-27 05:14:47 +0000959}
960
Argyrios Kyrtzidisba0a9002009-07-14 03:19:21 +0000961//===----------------------------------------------------------------------===//
962// C++ Expressions and Statements
Argyrios Kyrtzidis7cb45e32010-07-22 16:03:56 +0000963//===----------------------------------------------------------------------===//
964
Sebastian Redl60adf4a2010-08-18 23:56:52 +0000965void ASTStmtReader::VisitCXXCatchStmt(CXXCatchStmt *S) {
Argyrios Kyrtzidis7cb45e32010-07-22 16:03:56 +0000966 VisitStmt(S);
Sebastian Redlc3632732010-10-05 15:59:54 +0000967 S->CatchLoc = ReadSourceLocation(Record, Idx);
Douglas Gregor409448c2011-07-21 22:35:25 +0000968 S->ExceptionDecl = ReadDeclAs<VarDecl>(Record, Idx);
Argyrios Kyrtzidis7cb45e32010-07-22 16:03:56 +0000969 S->HandlerBlock = Reader.ReadSubStmt();
970}
971
Sebastian Redl60adf4a2010-08-18 23:56:52 +0000972void ASTStmtReader::VisitCXXTryStmt(CXXTryStmt *S) {
Argyrios Kyrtzidis7cb45e32010-07-22 16:03:56 +0000973 VisitStmt(S);
974 assert(Record[Idx] == S->getNumHandlers() && "NumStmtFields is wrong ?");
975 ++Idx;
Sebastian Redlc3632732010-10-05 15:59:54 +0000976 S->TryLoc = ReadSourceLocation(Record, Idx);
Argyrios Kyrtzidis7cb45e32010-07-22 16:03:56 +0000977 S->getStmts()[0] = Reader.ReadSubStmt();
978 for (unsigned i = 0, e = S->getNumHandlers(); i != e; ++i)
979 S->getStmts()[i + 1] = Reader.ReadSubStmt();
980}
Argyrios Kyrtzidisba0a9002009-07-14 03:19:21 +0000981
Richard Smithad762fc2011-04-14 22:09:26 +0000982void ASTStmtReader::VisitCXXForRangeStmt(CXXForRangeStmt *S) {
983 VisitStmt(S);
984 S->setForLoc(ReadSourceLocation(Record, Idx));
985 S->setColonLoc(ReadSourceLocation(Record, Idx));
986 S->setRParenLoc(ReadSourceLocation(Record, Idx));
987 S->setRangeStmt(Reader.ReadSubStmt());
988 S->setBeginEndStmt(Reader.ReadSubStmt());
989 S->setCond(Reader.ReadSubExpr());
990 S->setInc(Reader.ReadSubExpr());
991 S->setLoopVarStmt(Reader.ReadSubStmt());
992 S->setBody(Reader.ReadSubStmt());
993}
994
Douglas Gregorba0513d2011-10-25 01:33:02 +0000995void ASTStmtReader::VisitMSDependentExistsStmt(MSDependentExistsStmt *S) {
996 VisitStmt(S);
997 S->KeywordLoc = ReadSourceLocation(Record, Idx);
998 S->IsIfExists = Record[Idx++];
999 S->QualifierLoc = Reader.ReadNestedNameSpecifierLoc(F, Record, Idx);
1000 ReadDeclarationNameInfo(S->NameInfo, Record, Idx);
1001 S->SubStmt = Reader.ReadSubStmt();
1002}
1003
Sebastian Redl60adf4a2010-08-18 23:56:52 +00001004void ASTStmtReader::VisitCXXOperatorCallExpr(CXXOperatorCallExpr *E) {
Argyrios Kyrtzidis919e6932010-06-28 22:28:35 +00001005 VisitCallExpr(E);
Argyrios Kyrtzidisba0a9002009-07-14 03:19:21 +00001006 E->setOperator((OverloadedOperatorKind)Record[Idx++]);
Argyrios Kyrtzidisba0a9002009-07-14 03:19:21 +00001007}
1008
Sebastian Redl60adf4a2010-08-18 23:56:52 +00001009void ASTStmtReader::VisitCXXConstructExpr(CXXConstructExpr *E) {
Douglas Gregor39da0b82009-09-09 23:08:42 +00001010 VisitExpr(E);
Argyrios Kyrtzidis6d00c132010-07-10 11:46:15 +00001011 E->NumArgs = Record[Idx++];
1012 if (E->NumArgs)
Douglas Gregor35942772011-09-09 21:34:22 +00001013 E->Args = new (Reader.getContext()) Stmt*[E->NumArgs];
Argyrios Kyrtzidis5e1b7c22010-06-24 08:57:09 +00001014 for (unsigned I = 0, N = E->getNumArgs(); I != N; ++I)
Argyrios Kyrtzidisd98a2ab2010-06-29 22:46:25 +00001015 E->setArg(I, Reader.ReadSubExpr());
Douglas Gregor409448c2011-07-21 22:35:25 +00001016 E->setConstructor(ReadDeclAs<CXXConstructorDecl>(Record, Idx));
Sebastian Redlc3632732010-10-05 15:59:54 +00001017 E->setLocation(ReadSourceLocation(Record, Idx));
Abramo Bagnara7cc58b42011-10-05 07:56:41 +00001018 E->setElidable(Record[Idx++]);
1019 E->setHadMultipleCandidates(Record[Idx++]);
Douglas Gregor16006c92009-12-16 18:50:27 +00001020 E->setRequiresZeroInitialization(Record[Idx++]);
Douglas Gregor3c9034c2010-05-15 00:13:29 +00001021 E->setConstructionKind((CXXConstructExpr::ConstructionKind)Record[Idx++]);
Chandler Carruth428edaf2010-10-25 08:47:36 +00001022 E->ParenRange = ReadSourceRange(Record, Idx);
Douglas Gregor39da0b82009-09-09 23:08:42 +00001023}
Chris Lattner4c6f9522009-04-27 05:14:47 +00001024
Sebastian Redl60adf4a2010-08-18 23:56:52 +00001025void ASTStmtReader::VisitCXXTemporaryObjectExpr(CXXTemporaryObjectExpr *E) {
Argyrios Kyrtzidis6d00c132010-07-10 11:46:15 +00001026 VisitCXXConstructExpr(E);
Sebastian Redlc3632732010-10-05 15:59:54 +00001027 E->Type = GetTypeSourceInfo(Record, Idx);
Argyrios Kyrtzidis6d00c132010-07-10 11:46:15 +00001028}
1029
Sebastian Redl60adf4a2010-08-18 23:56:52 +00001030void ASTStmtReader::VisitCXXNamedCastExpr(CXXNamedCastExpr *E) {
Argyrios Kyrtzidis919e6932010-06-28 22:28:35 +00001031 VisitExplicitCastExpr(E);
Douglas Gregor1d5d0b92011-01-12 22:41:29 +00001032 SourceRange R = ReadSourceRange(Record, Idx);
1033 E->Loc = R.getBegin();
1034 E->RParenLoc = R.getEnd();
Sam Weinigce757a72010-01-16 21:21:01 +00001035}
1036
Sebastian Redl60adf4a2010-08-18 23:56:52 +00001037void ASTStmtReader::VisitCXXStaticCastExpr(CXXStaticCastExpr *E) {
Sam Weinigce757a72010-01-16 21:21:01 +00001038 return VisitCXXNamedCastExpr(E);
1039}
1040
Sebastian Redl60adf4a2010-08-18 23:56:52 +00001041void ASTStmtReader::VisitCXXDynamicCastExpr(CXXDynamicCastExpr *E) {
Sam Weinigce757a72010-01-16 21:21:01 +00001042 return VisitCXXNamedCastExpr(E);
1043}
1044
Sebastian Redl60adf4a2010-08-18 23:56:52 +00001045void ASTStmtReader::VisitCXXReinterpretCastExpr(CXXReinterpretCastExpr *E) {
Sam Weinigce757a72010-01-16 21:21:01 +00001046 return VisitCXXNamedCastExpr(E);
1047}
1048
Sebastian Redl60adf4a2010-08-18 23:56:52 +00001049void ASTStmtReader::VisitCXXConstCastExpr(CXXConstCastExpr *E) {
Sam Weinigce757a72010-01-16 21:21:01 +00001050 return VisitCXXNamedCastExpr(E);
1051}
1052
Sebastian Redl60adf4a2010-08-18 23:56:52 +00001053void ASTStmtReader::VisitCXXFunctionalCastExpr(CXXFunctionalCastExpr *E) {
Argyrios Kyrtzidis919e6932010-06-28 22:28:35 +00001054 VisitExplicitCastExpr(E);
Sebastian Redlc3632732010-10-05 15:59:54 +00001055 E->setTypeBeginLoc(ReadSourceLocation(Record, Idx));
1056 E->setRParenLoc(ReadSourceLocation(Record, Idx));
Sam Weinigce757a72010-01-16 21:21:01 +00001057}
1058
Sebastian Redl60adf4a2010-08-18 23:56:52 +00001059void ASTStmtReader::VisitCXXBoolLiteralExpr(CXXBoolLiteralExpr *E) {
Sam Weinigeb7f9612010-02-07 06:32:43 +00001060 VisitExpr(E);
1061 E->setValue(Record[Idx++]);
Sebastian Redlc3632732010-10-05 15:59:54 +00001062 E->setLocation(ReadSourceLocation(Record, Idx));
Sam Weinigeb7f9612010-02-07 06:32:43 +00001063}
1064
Sebastian Redl60adf4a2010-08-18 23:56:52 +00001065void ASTStmtReader::VisitCXXNullPtrLiteralExpr(CXXNullPtrLiteralExpr *E) {
Sam Weinigeb7f9612010-02-07 06:32:43 +00001066 VisitExpr(E);
Sebastian Redlc3632732010-10-05 15:59:54 +00001067 E->setLocation(ReadSourceLocation(Record, Idx));
Sam Weinigeb7f9612010-02-07 06:32:43 +00001068}
1069
Sebastian Redl60adf4a2010-08-18 23:56:52 +00001070void ASTStmtReader::VisitCXXTypeidExpr(CXXTypeidExpr *E) {
Chris Lattner14ab24f2010-05-09 06:03:39 +00001071 VisitExpr(E);
Sebastian Redlc3632732010-10-05 15:59:54 +00001072 E->setSourceRange(ReadSourceRange(Record, Idx));
Chris Lattner14ab24f2010-05-09 06:03:39 +00001073 if (E->isTypeOperand()) { // typeid(int)
Sebastian Redl577d4792010-07-22 22:43:28 +00001074 E->setTypeOperandSourceInfo(
Sebastian Redlc3632732010-10-05 15:59:54 +00001075 GetTypeSourceInfo(Record, Idx));
Argyrios Kyrtzidis919e6932010-06-28 22:28:35 +00001076 return;
Chris Lattner14ab24f2010-05-09 06:03:39 +00001077 }
1078
1079 // typeid(42+2)
Argyrios Kyrtzidisd98a2ab2010-06-29 22:46:25 +00001080 E->setExprOperand(Reader.ReadSubExpr());
Chris Lattner14ab24f2010-05-09 06:03:39 +00001081}
1082
Sebastian Redl60adf4a2010-08-18 23:56:52 +00001083void ASTStmtReader::VisitCXXThisExpr(CXXThisExpr *E) {
Chris Lattner2fbdfcd2010-05-09 06:15:05 +00001084 VisitExpr(E);
Sebastian Redlc3632732010-10-05 15:59:54 +00001085 E->setLocation(ReadSourceLocation(Record, Idx));
Chris Lattner2fbdfcd2010-05-09 06:15:05 +00001086 E->setImplicit(Record[Idx++]);
Chris Lattner2fbdfcd2010-05-09 06:15:05 +00001087}
1088
Sebastian Redl60adf4a2010-08-18 23:56:52 +00001089void ASTStmtReader::VisitCXXThrowExpr(CXXThrowExpr *E) {
Chris Lattner2fbdfcd2010-05-09 06:15:05 +00001090 VisitExpr(E);
Douglas Gregorbca01b42011-07-06 22:04:06 +00001091 E->ThrowLoc = ReadSourceLocation(Record, Idx);
1092 E->Op = Reader.ReadSubExpr();
1093 E->IsThrownVariableInScope = Record[Idx++];
Chris Lattner2fbdfcd2010-05-09 06:15:05 +00001094}
Chris Lattner14ab24f2010-05-09 06:03:39 +00001095
Sebastian Redl60adf4a2010-08-18 23:56:52 +00001096void ASTStmtReader::VisitCXXDefaultArgExpr(CXXDefaultArgExpr *E) {
Chris Lattner030854b2010-05-09 06:40:08 +00001097 VisitExpr(E);
Argyrios Kyrtzidis8a507332010-07-02 23:30:15 +00001098
Douglas Gregordf226552011-09-23 22:07:41 +00001099 assert((bool)Record[Idx] == E->Param.getInt() && "We messed up at creation ?");
Argyrios Kyrtzidis8a507332010-07-02 23:30:15 +00001100 ++Idx; // HasOtherExprStored and SubExpr was handled during creation.
Douglas Gregor409448c2011-07-21 22:35:25 +00001101 E->Param.setPointer(ReadDeclAs<ParmVarDecl>(Record, Idx));
Sebastian Redlc3632732010-10-05 15:59:54 +00001102 E->Loc = ReadSourceLocation(Record, Idx);
Chris Lattnerd2598362010-05-10 00:25:06 +00001103}
1104
Sebastian Redl60adf4a2010-08-18 23:56:52 +00001105void ASTStmtReader::VisitCXXBindTemporaryExpr(CXXBindTemporaryExpr *E) {
Chris Lattnerd2598362010-05-10 00:25:06 +00001106 VisitExpr(E);
Douglas Gregor409448c2011-07-21 22:35:25 +00001107 E->setTemporary(Reader.ReadCXXTemporary(F, Record, Idx));
Argyrios Kyrtzidisd98a2ab2010-06-29 22:46:25 +00001108 E->setSubExpr(Reader.ReadSubExpr());
Chris Lattnerd2598362010-05-10 00:25:06 +00001109}
1110
Sebastian Redl60adf4a2010-08-18 23:56:52 +00001111void ASTStmtReader::VisitCXXScalarValueInitExpr(CXXScalarValueInitExpr *E) {
Chris Lattner59218632010-05-10 01:22:27 +00001112 VisitExpr(E);
Sebastian Redlc3632732010-10-05 15:59:54 +00001113 E->TypeInfo = GetTypeSourceInfo(Record, Idx);
1114 E->RParenLoc = ReadSourceLocation(Record, Idx);
Chris Lattner59218632010-05-10 01:22:27 +00001115}
1116
Sebastian Redl60adf4a2010-08-18 23:56:52 +00001117void ASTStmtReader::VisitCXXNewExpr(CXXNewExpr *E) {
Chris Lattner59218632010-05-10 01:22:27 +00001118 VisitExpr(E);
John McCall6ec278d2011-01-27 09:37:56 +00001119 E->GlobalNew = Record[Idx++];
1120 E->Initializer = Record[Idx++];
1121 E->UsualArrayDeleteWantsSize = Record[Idx++];
Chris Lattner59218632010-05-10 01:22:27 +00001122 bool isArray = Record[Idx++];
Abramo Bagnara7cc58b42011-10-05 07:56:41 +00001123 E->setHadMultipleCandidates(Record[Idx++]);
Chris Lattner59218632010-05-10 01:22:27 +00001124 unsigned NumPlacementArgs = Record[Idx++];
1125 unsigned NumCtorArgs = Record[Idx++];
Douglas Gregor409448c2011-07-21 22:35:25 +00001126 E->setOperatorNew(ReadDeclAs<FunctionDecl>(Record, Idx));
1127 E->setOperatorDelete(ReadDeclAs<FunctionDecl>(Record, Idx));
1128 E->setConstructor(ReadDeclAs<CXXConstructorDecl>(Record, Idx));
Sebastian Redlc3632732010-10-05 15:59:54 +00001129 E->AllocatedTypeInfo = GetTypeSourceInfo(Record, Idx);
Douglas Gregor4bd40312010-07-13 15:54:32 +00001130 SourceRange TypeIdParens;
Sebastian Redlc3632732010-10-05 15:59:54 +00001131 TypeIdParens.setBegin(ReadSourceLocation(Record, Idx));
1132 TypeIdParens.setEnd(ReadSourceLocation(Record, Idx));
Douglas Gregor4bd40312010-07-13 15:54:32 +00001133 E->TypeIdParens = TypeIdParens;
Chandler Carruth428edaf2010-10-25 08:47:36 +00001134 E->StartLoc = ReadSourceLocation(Record, Idx);
1135 E->EndLoc = ReadSourceLocation(Record, Idx);
1136 E->ConstructorLParen = ReadSourceLocation(Record, Idx);
1137 E->ConstructorRParen = ReadSourceLocation(Record, Idx);
1138
Douglas Gregor35942772011-09-09 21:34:22 +00001139 E->AllocateArgsArray(Reader.getContext(), isArray, NumPlacementArgs,
Chris Lattner59218632010-05-10 01:22:27 +00001140 NumCtorArgs);
1141
1142 // Install all the subexpressions.
Chris Lattner59218632010-05-10 01:22:27 +00001143 for (CXXNewExpr::raw_arg_iterator I = E->raw_arg_begin(),e = E->raw_arg_end();
1144 I != e; ++I)
Argyrios Kyrtzidisd98a2ab2010-06-29 22:46:25 +00001145 *I = Reader.ReadSubStmt();
Chris Lattner59218632010-05-10 01:22:27 +00001146}
1147
Sebastian Redl60adf4a2010-08-18 23:56:52 +00001148void ASTStmtReader::VisitCXXDeleteExpr(CXXDeleteExpr *E) {
Argyrios Kyrtzidis95fc98c2010-06-22 17:07:59 +00001149 VisitExpr(E);
Argyrios Kyrtzidisf1b89112010-09-13 20:15:40 +00001150 E->GlobalDelete = Record[Idx++];
1151 E->ArrayForm = Record[Idx++];
Argyrios Kyrtzidis4076dac2010-09-13 20:15:54 +00001152 E->ArrayFormAsWritten = Record[Idx++];
John McCall6ec278d2011-01-27 09:37:56 +00001153 E->UsualArrayDeleteWantsSize = Record[Idx++];
Douglas Gregor409448c2011-07-21 22:35:25 +00001154 E->OperatorDelete = ReadDeclAs<FunctionDecl>(Record, Idx);
Argyrios Kyrtzidisf1b89112010-09-13 20:15:40 +00001155 E->Argument = Reader.ReadSubExpr();
Sebastian Redlc3632732010-10-05 15:59:54 +00001156 E->Loc = ReadSourceLocation(Record, Idx);
Argyrios Kyrtzidis95fc98c2010-06-22 17:07:59 +00001157}
Chris Lattnerd2598362010-05-10 00:25:06 +00001158
Sebastian Redl60adf4a2010-08-18 23:56:52 +00001159void ASTStmtReader::VisitCXXPseudoDestructorExpr(CXXPseudoDestructorExpr *E) {
Argyrios Kyrtzidisde4bd182010-06-28 09:32:03 +00001160 VisitExpr(E);
1161
Douglas Gregorf3db29f2011-02-25 18:19:59 +00001162 E->Base = Reader.ReadSubExpr();
1163 E->IsArrow = Record[Idx++];
1164 E->OperatorLoc = ReadSourceLocation(Record, Idx);
1165 E->QualifierLoc = Reader.ReadNestedNameSpecifierLoc(F, Record, Idx);
1166 E->ScopeType = GetTypeSourceInfo(Record, Idx);
1167 E->ColonColonLoc = ReadSourceLocation(Record, Idx);
1168 E->TildeLoc = ReadSourceLocation(Record, Idx);
Argyrios Kyrtzidisde4bd182010-06-28 09:32:03 +00001169
Douglas Gregor95eab172011-07-28 20:55:49 +00001170 IdentifierInfo *II = Reader.GetIdentifierInfo(F, Record, Idx);
Argyrios Kyrtzidisde4bd182010-06-28 09:32:03 +00001171 if (II)
Sebastian Redlc3632732010-10-05 15:59:54 +00001172 E->setDestroyedType(II, ReadSourceLocation(Record, Idx));
Argyrios Kyrtzidisde4bd182010-06-28 09:32:03 +00001173 else
Sebastian Redlc3632732010-10-05 15:59:54 +00001174 E->setDestroyedType(GetTypeSourceInfo(Record, Idx));
Argyrios Kyrtzidisde4bd182010-06-28 09:32:03 +00001175}
1176
John McCall4765fa02010-12-06 08:20:24 +00001177void ASTStmtReader::VisitExprWithCleanups(ExprWithCleanups *E) {
Chris Lattnerd2598362010-05-10 00:25:06 +00001178 VisitExpr(E);
1179 unsigned NumTemps = Record[Idx++];
1180 if (NumTemps) {
Douglas Gregor35942772011-09-09 21:34:22 +00001181 E->setNumTemporaries(Reader.getContext(), NumTemps);
Chris Lattnerd2598362010-05-10 00:25:06 +00001182 for (unsigned i = 0; i != NumTemps; ++i)
Douglas Gregor409448c2011-07-21 22:35:25 +00001183 E->setTemporary(i, Reader.ReadCXXTemporary(F, Record, Idx));
Chris Lattnerd2598362010-05-10 00:25:06 +00001184 }
Argyrios Kyrtzidisd98a2ab2010-06-29 22:46:25 +00001185 E->setSubExpr(Reader.ReadSubExpr());
Chris Lattner030854b2010-05-09 06:40:08 +00001186}
1187
Argyrios Kyrtzidis919e6932010-06-28 22:28:35 +00001188void
Sebastian Redl60adf4a2010-08-18 23:56:52 +00001189ASTStmtReader::VisitCXXDependentScopeMemberExpr(CXXDependentScopeMemberExpr *E){
Argyrios Kyrtzidis8dfbd8b2010-06-24 08:57:31 +00001190 VisitExpr(E);
1191
Douglas Gregordef03542011-02-04 12:01:24 +00001192 if (Record[Idx++])
John McCall096832c2010-08-19 23:49:38 +00001193 ReadExplicitTemplateArgumentList(E->getExplicitTemplateArgs(),
Douglas Gregordef03542011-02-04 12:01:24 +00001194 Record[Idx++]);
Argyrios Kyrtzidis8dfbd8b2010-06-24 08:57:31 +00001195
Douglas Gregor7c3179c2011-02-28 18:50:33 +00001196 E->Base = Reader.ReadSubExpr();
Douglas Gregor393f2492011-07-22 00:38:23 +00001197 E->BaseType = Reader.readType(F, Record, Idx);
Douglas Gregor7c3179c2011-02-28 18:50:33 +00001198 E->IsArrow = Record[Idx++];
1199 E->OperatorLoc = ReadSourceLocation(Record, Idx);
1200 E->QualifierLoc = Reader.ReadNestedNameSpecifierLoc(F, Record, Idx);
Douglas Gregor409448c2011-07-21 22:35:25 +00001201 E->FirstQualifierFoundInScope = ReadDeclAs<NamedDecl>(Record, Idx);
Argyrios Kyrtzidis40451072010-10-15 18:21:24 +00001202 ReadDeclarationNameInfo(E->MemberNameInfo, Record, Idx);
Argyrios Kyrtzidis8dfbd8b2010-06-24 08:57:31 +00001203}
1204
Argyrios Kyrtzidis919e6932010-06-28 22:28:35 +00001205void
Sebastian Redl60adf4a2010-08-18 23:56:52 +00001206ASTStmtReader::VisitDependentScopeDeclRefExpr(DependentScopeDeclRefExpr *E) {
Argyrios Kyrtzidis12dffcd2010-06-28 09:31:56 +00001207 VisitExpr(E);
Argyrios Kyrtzidis12dffcd2010-06-28 09:31:56 +00001208
Douglas Gregordef03542011-02-04 12:01:24 +00001209 if (Record[Idx++])
1210 ReadExplicitTemplateArgumentList(E->getExplicitTemplateArgs(),
1211 Record[Idx++]);
Douglas Gregor00cf3cc2011-02-25 20:49:16 +00001212
1213 E->QualifierLoc = Reader.ReadNestedNameSpecifierLoc(F, Record, Idx);
Argyrios Kyrtzidis40451072010-10-15 18:21:24 +00001214 ReadDeclarationNameInfo(E->NameInfo, Record, Idx);
Argyrios Kyrtzidis12dffcd2010-06-28 09:31:56 +00001215}
1216
Argyrios Kyrtzidis919e6932010-06-28 22:28:35 +00001217void
Sebastian Redl60adf4a2010-08-18 23:56:52 +00001218ASTStmtReader::VisitCXXUnresolvedConstructExpr(CXXUnresolvedConstructExpr *E) {
Argyrios Kyrtzidis8dfbd8b2010-06-24 08:57:31 +00001219 VisitExpr(E);
1220 assert(Record[Idx] == E->arg_size() && "Read wrong record during creation ?");
1221 ++Idx; // NumArgs;
1222 for (unsigned I = 0, N = E->arg_size(); I != N; ++I)
Argyrios Kyrtzidisd98a2ab2010-06-29 22:46:25 +00001223 E->setArg(I, Reader.ReadSubExpr());
Sebastian Redlc3632732010-10-05 15:59:54 +00001224 E->Type = GetTypeSourceInfo(Record, Idx);
1225 E->setLParenLoc(ReadSourceLocation(Record, Idx));
1226 E->setRParenLoc(ReadSourceLocation(Record, Idx));
Argyrios Kyrtzidis8dfbd8b2010-06-24 08:57:31 +00001227}
1228
Sebastian Redl60adf4a2010-08-18 23:56:52 +00001229void ASTStmtReader::VisitOverloadExpr(OverloadExpr *E) {
Argyrios Kyrtzidisa77eb082010-06-25 09:03:26 +00001230 VisitExpr(E);
1231
Douglas Gregordef03542011-02-04 12:01:24 +00001232 // Read the explicit template argument list, if available.
1233 if (Record[Idx++])
Argyrios Kyrtzidis919e6932010-06-28 22:28:35 +00001234 ReadExplicitTemplateArgumentList(E->getExplicitTemplateArgs(),
Douglas Gregordef03542011-02-04 12:01:24 +00001235 Record[Idx++]);
Argyrios Kyrtzidisa77eb082010-06-25 09:03:26 +00001236
1237 unsigned NumDecls = Record[Idx++];
1238 UnresolvedSet<8> Decls;
1239 for (unsigned i = 0; i != NumDecls; ++i) {
Douglas Gregor409448c2011-07-21 22:35:25 +00001240 NamedDecl *D = ReadDeclAs<NamedDecl>(Record, Idx);
Argyrios Kyrtzidisa77eb082010-06-25 09:03:26 +00001241 AccessSpecifier AS = (AccessSpecifier)Record[Idx++];
1242 Decls.addDecl(D, AS);
1243 }
Douglas Gregor35942772011-09-09 21:34:22 +00001244 E->initializeResults(Reader.getContext(), Decls.begin(), Decls.end());
Argyrios Kyrtzidisa77eb082010-06-25 09:03:26 +00001245
Argyrios Kyrtzidis40451072010-10-15 18:21:24 +00001246 ReadDeclarationNameInfo(E->NameInfo, Record, Idx);
Douglas Gregor4c9be892011-02-28 20:01:57 +00001247 E->QualifierLoc = Reader.ReadNestedNameSpecifierLoc(F, Record, Idx);
Argyrios Kyrtzidisa77eb082010-06-25 09:03:26 +00001248}
1249
Sebastian Redl60adf4a2010-08-18 23:56:52 +00001250void ASTStmtReader::VisitUnresolvedMemberExpr(UnresolvedMemberExpr *E) {
Argyrios Kyrtzidis919e6932010-06-28 22:28:35 +00001251 VisitOverloadExpr(E);
Douglas Gregor4c9be892011-02-28 20:01:57 +00001252 E->IsArrow = Record[Idx++];
1253 E->HasUnresolvedUsing = Record[Idx++];
1254 E->Base = Reader.ReadSubExpr();
Douglas Gregor393f2492011-07-22 00:38:23 +00001255 E->BaseType = Reader.readType(F, Record, Idx);
Douglas Gregor4c9be892011-02-28 20:01:57 +00001256 E->OperatorLoc = ReadSourceLocation(Record, Idx);
Argyrios Kyrtzidisa77eb082010-06-25 09:03:26 +00001257}
1258
Sebastian Redl60adf4a2010-08-18 23:56:52 +00001259void ASTStmtReader::VisitUnresolvedLookupExpr(UnresolvedLookupExpr *E) {
Argyrios Kyrtzidis919e6932010-06-28 22:28:35 +00001260 VisitOverloadExpr(E);
Douglas Gregor4c9be892011-02-28 20:01:57 +00001261 E->RequiresADL = Record[Idx++];
Richard Smithad762fc2011-04-14 22:09:26 +00001262 if (E->RequiresADL)
1263 E->StdIsAssociatedNamespace = Record[Idx++];
Douglas Gregor4c9be892011-02-28 20:01:57 +00001264 E->Overloaded = Record[Idx++];
Douglas Gregor409448c2011-07-21 22:35:25 +00001265 E->NamingClass = ReadDeclAs<CXXRecordDecl>(Record, Idx);
Argyrios Kyrtzidisbd65bb52010-06-25 09:03:34 +00001266}
1267
Sebastian Redl60adf4a2010-08-18 23:56:52 +00001268void ASTStmtReader::VisitUnaryTypeTraitExpr(UnaryTypeTraitExpr *E) {
Argyrios Kyrtzidis6d00c132010-07-10 11:46:15 +00001269 VisitExpr(E);
1270 E->UTT = (UnaryTypeTrait)Record[Idx++];
Sebastian Redl0dfd8482010-09-13 20:56:31 +00001271 E->Value = (bool)Record[Idx++];
Sebastian Redlc3632732010-10-05 15:59:54 +00001272 SourceRange Range = ReadSourceRange(Record, Idx);
Argyrios Kyrtzidis6d00c132010-07-10 11:46:15 +00001273 E->Loc = Range.getBegin();
1274 E->RParen = Range.getEnd();
Sebastian Redlc3632732010-10-05 15:59:54 +00001275 E->QueriedType = GetTypeSourceInfo(Record, Idx);
Argyrios Kyrtzidis6d00c132010-07-10 11:46:15 +00001276}
1277
Francois Pichet6ad6f282010-12-07 00:08:36 +00001278void ASTStmtReader::VisitBinaryTypeTraitExpr(BinaryTypeTraitExpr *E) {
1279 VisitExpr(E);
1280 E->BTT = (BinaryTypeTrait)Record[Idx++];
1281 E->Value = (bool)Record[Idx++];
1282 SourceRange Range = ReadSourceRange(Record, Idx);
1283 E->Loc = Range.getBegin();
1284 E->RParen = Range.getEnd();
1285 E->LhsType = GetTypeSourceInfo(Record, Idx);
1286 E->RhsType = GetTypeSourceInfo(Record, Idx);
1287}
1288
John Wiegley21ff2e52011-04-28 00:16:57 +00001289void ASTStmtReader::VisitArrayTypeTraitExpr(ArrayTypeTraitExpr *E) {
1290 VisitExpr(E);
1291 E->ATT = (ArrayTypeTrait)Record[Idx++];
1292 E->Value = (unsigned int)Record[Idx++];
1293 SourceRange Range = ReadSourceRange(Record, Idx);
1294 E->Loc = Range.getBegin();
1295 E->RParen = Range.getEnd();
1296 E->QueriedType = GetTypeSourceInfo(Record, Idx);
1297}
1298
John Wiegley55262202011-04-25 06:54:41 +00001299void ASTStmtReader::VisitExpressionTraitExpr(ExpressionTraitExpr *E) {
1300 VisitExpr(E);
1301 E->ET = (ExpressionTrait)Record[Idx++];
1302 E->Value = (bool)Record[Idx++];
1303 SourceRange Range = ReadSourceRange(Record, Idx);
1304 E->QueriedExpression = Reader.ReadSubExpr();
1305 E->Loc = Range.getBegin();
1306 E->RParen = Range.getEnd();
1307}
1308
Sebastian Redl6b219d02010-09-10 20:55:54 +00001309void ASTStmtReader::VisitCXXNoexceptExpr(CXXNoexceptExpr *E) {
1310 VisitExpr(E);
Sebastian Redl5221d8f2010-09-10 22:34:40 +00001311 E->Value = (bool)Record[Idx++];
Sebastian Redlc3632732010-10-05 15:59:54 +00001312 E->Range = ReadSourceRange(Record, Idx);
Sebastian Redl5221d8f2010-09-10 22:34:40 +00001313 E->Operand = Reader.ReadSubExpr();
Sebastian Redl6b219d02010-09-10 20:55:54 +00001314}
1315
Douglas Gregorbe230c32011-01-03 17:17:50 +00001316void ASTStmtReader::VisitPackExpansionExpr(PackExpansionExpr *E) {
1317 VisitExpr(E);
1318 E->EllipsisLoc = ReadSourceLocation(Record, Idx);
Douglas Gregor67fd1252011-01-14 21:20:45 +00001319 E->NumExpansions = Record[Idx++];
Douglas Gregorbe230c32011-01-03 17:17:50 +00001320 E->Pattern = Reader.ReadSubExpr();
1321}
1322
Douglas Gregoree8aff02011-01-04 17:33:58 +00001323void ASTStmtReader::VisitSizeOfPackExpr(SizeOfPackExpr *E) {
1324 VisitExpr(E);
1325 E->OperatorLoc = ReadSourceLocation(Record, Idx);
1326 E->PackLoc = ReadSourceLocation(Record, Idx);
1327 E->RParenLoc = ReadSourceLocation(Record, Idx);
1328 E->Length = Record[Idx++];
Douglas Gregor409448c2011-07-21 22:35:25 +00001329 E->Pack = ReadDeclAs<NamedDecl>(Record, Idx);
Douglas Gregoree8aff02011-01-04 17:33:58 +00001330}
1331
John McCall7110fd62011-07-15 07:00:14 +00001332void ASTStmtReader::VisitSubstNonTypeTemplateParmExpr(
1333 SubstNonTypeTemplateParmExpr *E) {
1334 VisitExpr(E);
Douglas Gregor409448c2011-07-21 22:35:25 +00001335 E->Param = ReadDeclAs<NonTypeTemplateParmDecl>(Record, Idx);
John McCall7110fd62011-07-15 07:00:14 +00001336 E->NameLoc = ReadSourceLocation(Record, Idx);
1337 E->Replacement = Reader.ReadSubExpr();
1338}
1339
Douglas Gregorc7793c72011-01-15 01:15:58 +00001340void ASTStmtReader::VisitSubstNonTypeTemplateParmPackExpr(
1341 SubstNonTypeTemplateParmPackExpr *E) {
1342 VisitExpr(E);
Douglas Gregor409448c2011-07-21 22:35:25 +00001343 E->Param = ReadDeclAs<NonTypeTemplateParmDecl>(Record, Idx);
Douglas Gregorc7793c72011-01-15 01:15:58 +00001344 TemplateArgument ArgPack = Reader.ReadTemplateArgument(F, Record, Idx);
1345 if (ArgPack.getKind() != TemplateArgument::Pack)
1346 return;
1347
1348 E->Arguments = ArgPack.pack_begin();
1349 E->NumArguments = ArgPack.pack_size();
1350 E->NameLoc = ReadSourceLocation(Record, Idx);
1351}
1352
Douglas Gregor03e80032011-06-21 17:03:29 +00001353void ASTStmtReader::VisitMaterializeTemporaryExpr(MaterializeTemporaryExpr *E) {
1354 VisitExpr(E);
1355 E->Temporary = Reader.ReadSubExpr();
1356}
1357
John McCall7cd7d1a2010-11-15 23:31:06 +00001358void ASTStmtReader::VisitOpaqueValueExpr(OpaqueValueExpr *E) {
1359 VisitExpr(E);
John McCall56ca35d2011-02-17 10:25:35 +00001360 Idx++; // skip ID
Douglas Gregorb608b982011-01-28 02:26:04 +00001361 E->Loc = ReadSourceLocation(Record, Idx);
John McCall7cd7d1a2010-11-15 23:31:06 +00001362}
1363
Peter Collingbournee08ce652011-02-09 21:07:24 +00001364//===----------------------------------------------------------------------===//
John McCall7110fd62011-07-15 07:00:14 +00001365// Microsoft Expressions and Statements
1366//===----------------------------------------------------------------------===//
1367void ASTStmtReader::VisitCXXUuidofExpr(CXXUuidofExpr *E) {
1368 VisitExpr(E);
1369 E->setSourceRange(ReadSourceRange(Record, Idx));
1370 if (E->isTypeOperand()) { // __uuidof(ComType)
1371 E->setTypeOperandSourceInfo(
1372 GetTypeSourceInfo(Record, Idx));
1373 return;
1374 }
1375
1376 // __uuidof(expr)
1377 E->setExprOperand(Reader.ReadSubExpr());
1378}
1379
1380void ASTStmtReader::VisitSEHExceptStmt(SEHExceptStmt *S) {
1381 VisitStmt(S);
1382 S->Loc = ReadSourceLocation(Record, Idx);
1383 S->Children[SEHExceptStmt::FILTER_EXPR] = Reader.ReadSubStmt();
1384 S->Children[SEHExceptStmt::BLOCK] = Reader.ReadSubStmt();
1385}
1386
1387void ASTStmtReader::VisitSEHFinallyStmt(SEHFinallyStmt *S) {
1388 VisitStmt(S);
1389 S->Loc = ReadSourceLocation(Record, Idx);
1390 S->Block = Reader.ReadSubStmt();
1391}
1392
1393void ASTStmtReader::VisitSEHTryStmt(SEHTryStmt *S) {
1394 VisitStmt(S);
1395 S->IsCXXTry = Record[Idx++];
1396 S->TryLoc = ReadSourceLocation(Record, Idx);
1397 S->Children[SEHTryStmt::TRY] = Reader.ReadSubStmt();
1398 S->Children[SEHTryStmt::HANDLER] = Reader.ReadSubStmt();
1399}
1400
1401//===----------------------------------------------------------------------===//
Peter Collingbournee08ce652011-02-09 21:07:24 +00001402// CUDA Expressions and Statements
1403//===----------------------------------------------------------------------===//
1404
1405void ASTStmtReader::VisitCUDAKernelCallExpr(CUDAKernelCallExpr *E) {
1406 VisitCallExpr(E);
1407 E->setConfig(cast<CallExpr>(Reader.ReadSubExpr()));
1408}
1409
John McCall7110fd62011-07-15 07:00:14 +00001410//===----------------------------------------------------------------------===//
1411// OpenCL Expressions and Statements.
1412//===----------------------------------------------------------------------===//
1413void ASTStmtReader::VisitAsTypeExpr(AsTypeExpr *E) {
1414 VisitExpr(E);
1415 E->BuiltinLoc = ReadSourceLocation(Record, Idx);
1416 E->RParenLoc = ReadSourceLocation(Record, Idx);
1417 E->SrcExpr = Reader.ReadSubExpr();
1418}
1419
1420//===----------------------------------------------------------------------===//
1421// ASTReader Implementation
1422//===----------------------------------------------------------------------===//
1423
Douglas Gregor72a9ae12011-07-22 16:00:58 +00001424Stmt *ASTReader::ReadStmt(Module &F) {
Argyrios Kyrtzidis919e6932010-06-28 22:28:35 +00001425 switch (ReadingKind) {
1426 case Read_Decl:
1427 case Read_Type:
Sebastian Redlc3632732010-10-05 15:59:54 +00001428 return ReadStmtFromStream(F);
Argyrios Kyrtzidis919e6932010-06-28 22:28:35 +00001429 case Read_Stmt:
Argyrios Kyrtzidisd98a2ab2010-06-29 22:46:25 +00001430 return ReadSubStmt();
Argyrios Kyrtzidis919e6932010-06-28 22:28:35 +00001431 }
1432
1433 llvm_unreachable("ReadingKind not set ?");
1434 return 0;
1435}
1436
Douglas Gregor72a9ae12011-07-22 16:00:58 +00001437Expr *ASTReader::ReadExpr(Module &F) {
Sebastian Redlc3632732010-10-05 15:59:54 +00001438 return cast_or_null<Expr>(ReadStmt(F));
Argyrios Kyrtzidis919e6932010-06-28 22:28:35 +00001439}
Chris Lattner030854b2010-05-09 06:40:08 +00001440
Sebastian Redlc43b54c2010-08-18 23:56:43 +00001441Expr *ASTReader::ReadSubExpr() {
Argyrios Kyrtzidisd98a2ab2010-06-29 22:46:25 +00001442 return cast_or_null<Expr>(ReadSubStmt());
1443}
1444
Chris Lattner52e97d12009-04-27 05:41:06 +00001445// Within the bitstream, expressions are stored in Reverse Polish
1446// Notation, with each of the subexpressions preceding the
Argyrios Kyrtzidis919e6932010-06-28 22:28:35 +00001447// expression they are stored in. Subexpressions are stored from last to first.
1448// To evaluate expressions, we continue reading expressions and placing them on
1449// the stack, with expressions having operands removing those operands from the
Chris Lattner52e97d12009-04-27 05:41:06 +00001450// stack. Evaluation terminates when we see a STMT_STOP record, and
1451// the single remaining expression on the stack is our result.
Douglas Gregor72a9ae12011-07-22 16:00:58 +00001452Stmt *ASTReader::ReadStmtFromStream(Module &F) {
Argyrios Kyrtzidis919e6932010-06-28 22:28:35 +00001453
1454 ReadingKindTracker ReadingKind(Read_Stmt, *this);
Sebastian Redlc3632732010-10-05 15:59:54 +00001455 llvm::BitstreamCursor &Cursor = F.DeclsCursor;
Argyrios Kyrtzidise6f08682011-10-21 23:02:28 +00001456
1457 // Map of offset to previously deserialized stmt. The offset points
1458 /// just after the stmt record.
1459 llvm::DenseMap<uint64_t, Stmt *> StmtEntries;
Sebastian Redlc3632732010-10-05 15:59:54 +00001460
Argyrios Kyrtzidis919e6932010-06-28 22:28:35 +00001461#ifndef NDEBUG
1462 unsigned PrevNumStmts = StmtStack.size();
1463#endif
1464
Chris Lattner4c6f9522009-04-27 05:14:47 +00001465 RecordData Record;
1466 unsigned Idx;
Sebastian Redlc3632732010-10-05 15:59:54 +00001467 ASTStmtReader Reader(*this, F, Cursor, Record, Idx);
Chris Lattner4c6f9522009-04-27 05:14:47 +00001468 Stmt::EmptyShell Empty;
1469
1470 while (true) {
Chris Lattner52e97d12009-04-27 05:41:06 +00001471 unsigned Code = Cursor.ReadCode();
Chris Lattner4c6f9522009-04-27 05:14:47 +00001472 if (Code == llvm::bitc::END_BLOCK) {
Chris Lattner52e97d12009-04-27 05:41:06 +00001473 if (Cursor.ReadBlockEnd()) {
Sebastian Redl3c7f4132010-08-18 23:57:06 +00001474 Error("error at end of block in AST file");
Chris Lattner4c6f9522009-04-27 05:14:47 +00001475 return 0;
1476 }
1477 break;
1478 }
1479
1480 if (Code == llvm::bitc::ENTER_SUBBLOCK) {
1481 // No known subblocks, always skip them.
Chris Lattner52e97d12009-04-27 05:41:06 +00001482 Cursor.ReadSubBlockID();
1483 if (Cursor.SkipBlock()) {
Sebastian Redl3c7f4132010-08-18 23:57:06 +00001484 Error("malformed block record in AST file");
Chris Lattner4c6f9522009-04-27 05:14:47 +00001485 return 0;
1486 }
1487 continue;
1488 }
1489
1490 if (Code == llvm::bitc::DEFINE_ABBREV) {
Chris Lattner52e97d12009-04-27 05:41:06 +00001491 Cursor.ReadAbbrevRecord();
Chris Lattner4c6f9522009-04-27 05:14:47 +00001492 continue;
1493 }
1494
1495 Stmt *S = 0;
1496 Idx = 0;
1497 Record.clear();
1498 bool Finished = false;
Argyrios Kyrtzidise6f08682011-10-21 23:02:28 +00001499 bool IsStmtReference = false;
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001500 switch ((StmtCode)Cursor.ReadRecord(Code, Record)) {
1501 case STMT_STOP:
Chris Lattner4c6f9522009-04-27 05:14:47 +00001502 Finished = true;
1503 break;
1504
Argyrios Kyrtzidise6f08682011-10-21 23:02:28 +00001505 case STMT_REF_PTR:
1506 IsStmtReference = true;
1507 assert(StmtEntries.find(Record[0]) != StmtEntries.end() &&
1508 "No stmt was recorded for this offset reference!");
1509 S = StmtEntries[Record[Idx++]];
1510 break;
1511
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001512 case STMT_NULL_PTR:
Mike Stump1eb44332009-09-09 15:08:12 +00001513 S = 0;
Chris Lattner4c6f9522009-04-27 05:14:47 +00001514 break;
1515
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001516 case STMT_NULL:
Chris Lattner4c6f9522009-04-27 05:14:47 +00001517 S = new (Context) NullStmt(Empty);
1518 break;
1519
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001520 case STMT_COMPOUND:
Chris Lattner4c6f9522009-04-27 05:14:47 +00001521 S = new (Context) CompoundStmt(Empty);
1522 break;
1523
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001524 case STMT_CASE:
Chris Lattner4c6f9522009-04-27 05:14:47 +00001525 S = new (Context) CaseStmt(Empty);
1526 break;
1527
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001528 case STMT_DEFAULT:
Chris Lattner4c6f9522009-04-27 05:14:47 +00001529 S = new (Context) DefaultStmt(Empty);
1530 break;
1531
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001532 case STMT_LABEL:
Chris Lattner4c6f9522009-04-27 05:14:47 +00001533 S = new (Context) LabelStmt(Empty);
1534 break;
1535
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001536 case STMT_IF:
Chris Lattner4c6f9522009-04-27 05:14:47 +00001537 S = new (Context) IfStmt(Empty);
1538 break;
1539
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001540 case STMT_SWITCH:
Chris Lattner4c6f9522009-04-27 05:14:47 +00001541 S = new (Context) SwitchStmt(Empty);
1542 break;
1543
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001544 case STMT_WHILE:
Chris Lattner4c6f9522009-04-27 05:14:47 +00001545 S = new (Context) WhileStmt(Empty);
1546 break;
1547
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001548 case STMT_DO:
Chris Lattner4c6f9522009-04-27 05:14:47 +00001549 S = new (Context) DoStmt(Empty);
1550 break;
Mike Stump1eb44332009-09-09 15:08:12 +00001551
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001552 case STMT_FOR:
Chris Lattner4c6f9522009-04-27 05:14:47 +00001553 S = new (Context) ForStmt(Empty);
1554 break;
1555
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001556 case STMT_GOTO:
Chris Lattner4c6f9522009-04-27 05:14:47 +00001557 S = new (Context) GotoStmt(Empty);
1558 break;
Mike Stump1eb44332009-09-09 15:08:12 +00001559
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001560 case STMT_INDIRECT_GOTO:
Chris Lattner4c6f9522009-04-27 05:14:47 +00001561 S = new (Context) IndirectGotoStmt(Empty);
1562 break;
1563
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001564 case STMT_CONTINUE:
Chris Lattner4c6f9522009-04-27 05:14:47 +00001565 S = new (Context) ContinueStmt(Empty);
1566 break;
1567
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001568 case STMT_BREAK:
Chris Lattner4c6f9522009-04-27 05:14:47 +00001569 S = new (Context) BreakStmt(Empty);
1570 break;
1571
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001572 case STMT_RETURN:
Chris Lattner4c6f9522009-04-27 05:14:47 +00001573 S = new (Context) ReturnStmt(Empty);
1574 break;
1575
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001576 case STMT_DECL:
Chris Lattner4c6f9522009-04-27 05:14:47 +00001577 S = new (Context) DeclStmt(Empty);
1578 break;
1579
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001580 case STMT_ASM:
Chris Lattner4c6f9522009-04-27 05:14:47 +00001581 S = new (Context) AsmStmt(Empty);
1582 break;
1583
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001584 case EXPR_PREDEFINED:
Chris Lattner4c6f9522009-04-27 05:14:47 +00001585 S = new (Context) PredefinedExpr(Empty);
1586 break;
Mike Stump1eb44332009-09-09 15:08:12 +00001587
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001588 case EXPR_DECL_REF:
Chandler Carruth3aa81402011-05-01 23:48:14 +00001589 S = DeclRefExpr::CreateEmpty(
Douglas Gregor35942772011-09-09 21:34:22 +00001590 Context,
Chandler Carruth3aa81402011-05-01 23:48:14 +00001591 /*HasQualifier=*/Record[ASTStmtReader::NumExprFields],
1592 /*HasFoundDecl=*/Record[ASTStmtReader::NumExprFields + 1],
1593 /*HasExplicitTemplateArgs=*/Record[ASTStmtReader::NumExprFields + 2],
1594 /*NumTemplateArgs=*/Record[ASTStmtReader::NumExprFields + 2] ?
Abramo Bagnara7cc58b42011-10-05 07:56:41 +00001595 Record[ASTStmtReader::NumExprFields + 4] : 0);
Chris Lattner4c6f9522009-04-27 05:14:47 +00001596 break;
Mike Stump1eb44332009-09-09 15:08:12 +00001597
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001598 case EXPR_INTEGER_LITERAL:
Douglas Gregor35942772011-09-09 21:34:22 +00001599 S = IntegerLiteral::Create(Context, Empty);
Chris Lattner4c6f9522009-04-27 05:14:47 +00001600 break;
Mike Stump1eb44332009-09-09 15:08:12 +00001601
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001602 case EXPR_FLOATING_LITERAL:
Douglas Gregor35942772011-09-09 21:34:22 +00001603 S = FloatingLiteral::Create(Context, Empty);
Chris Lattner4c6f9522009-04-27 05:14:47 +00001604 break;
Mike Stump1eb44332009-09-09 15:08:12 +00001605
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001606 case EXPR_IMAGINARY_LITERAL:
Chris Lattner4c6f9522009-04-27 05:14:47 +00001607 S = new (Context) ImaginaryLiteral(Empty);
1608 break;
1609
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001610 case EXPR_STRING_LITERAL:
Douglas Gregor35942772011-09-09 21:34:22 +00001611 S = StringLiteral::CreateEmpty(Context,
Sebastian Redl60adf4a2010-08-18 23:56:52 +00001612 Record[ASTStmtReader::NumExprFields + 1]);
Chris Lattner4c6f9522009-04-27 05:14:47 +00001613 break;
1614
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001615 case EXPR_CHARACTER_LITERAL:
Chris Lattner4c6f9522009-04-27 05:14:47 +00001616 S = new (Context) CharacterLiteral(Empty);
1617 break;
1618
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001619 case EXPR_PAREN:
Chris Lattner4c6f9522009-04-27 05:14:47 +00001620 S = new (Context) ParenExpr(Empty);
1621 break;
1622
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001623 case EXPR_PAREN_LIST:
Argyrios Kyrtzidis37bdfe22010-06-30 08:49:18 +00001624 S = new (Context) ParenListExpr(Empty);
1625 break;
1626
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001627 case EXPR_UNARY_OPERATOR:
Chris Lattner4c6f9522009-04-27 05:14:47 +00001628 S = new (Context) UnaryOperator(Empty);
1629 break;
1630
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001631 case EXPR_OFFSETOF:
Douglas Gregor35942772011-09-09 21:34:22 +00001632 S = OffsetOfExpr::CreateEmpty(Context,
Sebastian Redl60adf4a2010-08-18 23:56:52 +00001633 Record[ASTStmtReader::NumExprFields],
1634 Record[ASTStmtReader::NumExprFields + 1]);
Douglas Gregor8ecdb652010-04-28 22:16:22 +00001635 break;
1636
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001637 case EXPR_SIZEOF_ALIGN_OF:
Peter Collingbournef4e3cfb2011-03-11 19:24:49 +00001638 S = new (Context) UnaryExprOrTypeTraitExpr(Empty);
Chris Lattner4c6f9522009-04-27 05:14:47 +00001639 break;
1640
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001641 case EXPR_ARRAY_SUBSCRIPT:
Chris Lattner4c6f9522009-04-27 05:14:47 +00001642 S = new (Context) ArraySubscriptExpr(Empty);
1643 break;
1644
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001645 case EXPR_CALL:
Douglas Gregor35942772011-09-09 21:34:22 +00001646 S = new (Context) CallExpr(Context, Stmt::CallExprClass, Empty);
Chris Lattner4c6f9522009-04-27 05:14:47 +00001647 break;
1648
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001649 case EXPR_MEMBER: {
Argyrios Kyrtzidis663e3802010-07-08 13:09:47 +00001650 // We load everything here and fully initialize it at creation.
1651 // That way we can use MemberExpr::Create and don't have to duplicate its
1652 // logic with a MemberExpr::CreateEmpty.
1653
1654 assert(Idx == 0);
Douglas Gregor40d96a62011-02-28 21:54:11 +00001655 NestedNameSpecifierLoc QualifierLoc;
Argyrios Kyrtzidis663e3802010-07-08 13:09:47 +00001656 if (Record[Idx++]) { // HasQualifier.
Douglas Gregor40d96a62011-02-28 21:54:11 +00001657 QualifierLoc = ReadNestedNameSpecifierLoc(F, Record, Idx);
Argyrios Kyrtzidis663e3802010-07-08 13:09:47 +00001658 }
1659
1660 TemplateArgumentListInfo ArgInfo;
Douglas Gregordef03542011-02-04 12:01:24 +00001661 bool HasExplicitTemplateArgs = Record[Idx++];
1662 if (HasExplicitTemplateArgs) {
1663 unsigned NumTemplateArgs = Record[Idx++];
Sebastian Redlc3632732010-10-05 15:59:54 +00001664 ArgInfo.setLAngleLoc(ReadSourceLocation(F, Record, Idx));
1665 ArgInfo.setRAngleLoc(ReadSourceLocation(F, Record, Idx));
Argyrios Kyrtzidis663e3802010-07-08 13:09:47 +00001666 for (unsigned i = 0; i != NumTemplateArgs; ++i)
Sebastian Redlc3632732010-10-05 15:59:54 +00001667 ArgInfo.addArgument(ReadTemplateArgumentLoc(F, Record, Idx));
Argyrios Kyrtzidis663e3802010-07-08 13:09:47 +00001668 }
Abramo Bagnara7cc58b42011-10-05 07:56:41 +00001669
1670 bool HadMultipleCandidates = Record[Idx++];
1671
Douglas Gregor409448c2011-07-21 22:35:25 +00001672 NamedDecl *FoundD = ReadDeclAs<NamedDecl>(F, Record, Idx);
Argyrios Kyrtzidis663e3802010-07-08 13:09:47 +00001673 AccessSpecifier AS = (AccessSpecifier)Record[Idx++];
1674 DeclAccessPair FoundDecl = DeclAccessPair::make(FoundD, AS);
1675
Douglas Gregor393f2492011-07-22 00:38:23 +00001676 QualType T = readType(F, Record, Idx);
John McCallf89e55a2010-11-18 06:31:45 +00001677 ExprValueKind VK = static_cast<ExprValueKind>(Record[Idx++]);
1678 ExprObjectKind OK = static_cast<ExprObjectKind>(Record[Idx++]);
Argyrios Kyrtzidis663e3802010-07-08 13:09:47 +00001679 Expr *Base = ReadSubExpr();
Douglas Gregor409448c2011-07-21 22:35:25 +00001680 ValueDecl *MemberD = ReadDeclAs<ValueDecl>(F, Record, Idx);
Sebastian Redlc3632732010-10-05 15:59:54 +00001681 SourceLocation MemberLoc = ReadSourceLocation(F, Record, Idx);
Abramo Bagnara25777432010-08-11 22:01:17 +00001682 DeclarationNameInfo MemberNameInfo(MemberD->getDeclName(), MemberLoc);
Argyrios Kyrtzidis663e3802010-07-08 13:09:47 +00001683 bool IsArrow = Record[Idx++];
1684
Douglas Gregor35942772011-09-09 21:34:22 +00001685 S = MemberExpr::Create(Context, Base, IsArrow, QualifierLoc,
Abramo Bagnara25777432010-08-11 22:01:17 +00001686 MemberD, FoundDecl, MemberNameInfo,
Douglas Gregordef03542011-02-04 12:01:24 +00001687 HasExplicitTemplateArgs ? &ArgInfo : 0, T, VK, OK);
Argyrios Kyrtzidis40451072010-10-15 18:21:24 +00001688 ReadDeclarationNameLoc(F, cast<MemberExpr>(S)->MemberDNLoc,
1689 MemberD->getDeclName(), Record, Idx);
Abramo Bagnara7cc58b42011-10-05 07:56:41 +00001690 if (HadMultipleCandidates)
1691 cast<MemberExpr>(S)->setHadMultipleCandidates(true);
Chris Lattner4c6f9522009-04-27 05:14:47 +00001692 break;
Argyrios Kyrtzidis663e3802010-07-08 13:09:47 +00001693 }
Chris Lattner4c6f9522009-04-27 05:14:47 +00001694
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001695 case EXPR_BINARY_OPERATOR:
Chris Lattner4c6f9522009-04-27 05:14:47 +00001696 S = new (Context) BinaryOperator(Empty);
1697 break;
1698
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001699 case EXPR_COMPOUND_ASSIGN_OPERATOR:
Chris Lattner4c6f9522009-04-27 05:14:47 +00001700 S = new (Context) CompoundAssignOperator(Empty);
1701 break;
1702
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001703 case EXPR_CONDITIONAL_OPERATOR:
Chris Lattner4c6f9522009-04-27 05:14:47 +00001704 S = new (Context) ConditionalOperator(Empty);
1705 break;
1706
John McCall56ca35d2011-02-17 10:25:35 +00001707 case EXPR_BINARY_CONDITIONAL_OPERATOR:
1708 S = new (Context) BinaryConditionalOperator(Empty);
1709 break;
1710
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001711 case EXPR_IMPLICIT_CAST:
Douglas Gregor35942772011-09-09 21:34:22 +00001712 S = ImplicitCastExpr::CreateEmpty(Context,
Sebastian Redl60adf4a2010-08-18 23:56:52 +00001713 /*PathSize*/ Record[ASTStmtReader::NumExprFields]);
Chris Lattner4c6f9522009-04-27 05:14:47 +00001714 break;
1715
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001716 case EXPR_CSTYLE_CAST:
Douglas Gregor35942772011-09-09 21:34:22 +00001717 S = CStyleCastExpr::CreateEmpty(Context,
Sebastian Redl60adf4a2010-08-18 23:56:52 +00001718 /*PathSize*/ Record[ASTStmtReader::NumExprFields]);
Chris Lattner4c6f9522009-04-27 05:14:47 +00001719 break;
1720
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001721 case EXPR_COMPOUND_LITERAL:
Chris Lattner4c6f9522009-04-27 05:14:47 +00001722 S = new (Context) CompoundLiteralExpr(Empty);
1723 break;
1724
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001725 case EXPR_EXT_VECTOR_ELEMENT:
Chris Lattner4c6f9522009-04-27 05:14:47 +00001726 S = new (Context) ExtVectorElementExpr(Empty);
1727 break;
1728
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001729 case EXPR_INIT_LIST:
Douglas Gregor35942772011-09-09 21:34:22 +00001730 S = new (Context) InitListExpr(getContext(), Empty);
Chris Lattner4c6f9522009-04-27 05:14:47 +00001731 break;
1732
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001733 case EXPR_DESIGNATED_INIT:
Douglas Gregor35942772011-09-09 21:34:22 +00001734 S = DesignatedInitExpr::CreateEmpty(Context,
Sebastian Redl60adf4a2010-08-18 23:56:52 +00001735 Record[ASTStmtReader::NumExprFields] - 1);
Mike Stump1eb44332009-09-09 15:08:12 +00001736
Chris Lattner4c6f9522009-04-27 05:14:47 +00001737 break;
1738
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001739 case EXPR_IMPLICIT_VALUE_INIT:
Chris Lattner4c6f9522009-04-27 05:14:47 +00001740 S = new (Context) ImplicitValueInitExpr(Empty);
1741 break;
1742
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001743 case EXPR_VA_ARG:
Chris Lattner4c6f9522009-04-27 05:14:47 +00001744 S = new (Context) VAArgExpr(Empty);
1745 break;
1746
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001747 case EXPR_ADDR_LABEL:
Chris Lattner4c6f9522009-04-27 05:14:47 +00001748 S = new (Context) AddrLabelExpr(Empty);
1749 break;
1750
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001751 case EXPR_STMT:
Chris Lattner4c6f9522009-04-27 05:14:47 +00001752 S = new (Context) StmtExpr(Empty);
1753 break;
1754
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001755 case EXPR_CHOOSE:
Chris Lattner4c6f9522009-04-27 05:14:47 +00001756 S = new (Context) ChooseExpr(Empty);
1757 break;
1758
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001759 case EXPR_GNU_NULL:
Chris Lattner4c6f9522009-04-27 05:14:47 +00001760 S = new (Context) GNUNullExpr(Empty);
1761 break;
1762
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001763 case EXPR_SHUFFLE_VECTOR:
Chris Lattner4c6f9522009-04-27 05:14:47 +00001764 S = new (Context) ShuffleVectorExpr(Empty);
1765 break;
Mike Stump1eb44332009-09-09 15:08:12 +00001766
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001767 case EXPR_BLOCK:
Chris Lattner4c6f9522009-04-27 05:14:47 +00001768 S = new (Context) BlockExpr(Empty);
1769 break;
1770
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001771 case EXPR_BLOCK_DECL_REF:
Chris Lattner4c6f9522009-04-27 05:14:47 +00001772 S = new (Context) BlockDeclRefExpr(Empty);
1773 break;
Mike Stump1eb44332009-09-09 15:08:12 +00001774
Peter Collingbournef111d932011-04-15 00:35:48 +00001775 case EXPR_GENERIC_SELECTION:
1776 S = new (Context) GenericSelectionExpr(Empty);
1777 break;
1778
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001779 case EXPR_OBJC_STRING_LITERAL:
Chris Lattner4c6f9522009-04-27 05:14:47 +00001780 S = new (Context) ObjCStringLiteral(Empty);
1781 break;
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001782 case EXPR_OBJC_ENCODE:
Chris Lattner4c6f9522009-04-27 05:14:47 +00001783 S = new (Context) ObjCEncodeExpr(Empty);
1784 break;
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001785 case EXPR_OBJC_SELECTOR_EXPR:
Chris Lattner4c6f9522009-04-27 05:14:47 +00001786 S = new (Context) ObjCSelectorExpr(Empty);
1787 break;
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001788 case EXPR_OBJC_PROTOCOL_EXPR:
Chris Lattner4c6f9522009-04-27 05:14:47 +00001789 S = new (Context) ObjCProtocolExpr(Empty);
1790 break;
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001791 case EXPR_OBJC_IVAR_REF_EXPR:
Chris Lattner4c6f9522009-04-27 05:14:47 +00001792 S = new (Context) ObjCIvarRefExpr(Empty);
1793 break;
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001794 case EXPR_OBJC_PROPERTY_REF_EXPR:
Chris Lattner4c6f9522009-04-27 05:14:47 +00001795 S = new (Context) ObjCPropertyRefExpr(Empty);
1796 break;
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001797 case EXPR_OBJC_KVC_REF_EXPR:
John McCall12f78a62010-12-02 01:19:52 +00001798 llvm_unreachable("mismatching AST file");
Chris Lattner4c6f9522009-04-27 05:14:47 +00001799 break;
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001800 case EXPR_OBJC_MESSAGE_EXPR:
Douglas Gregor35942772011-09-09 21:34:22 +00001801 S = ObjCMessageExpr::CreateEmpty(Context,
Argyrios Kyrtzidis20718082011-10-03 06:36:51 +00001802 Record[ASTStmtReader::NumExprFields],
1803 Record[ASTStmtReader::NumExprFields + 1]);
Chris Lattner4c6f9522009-04-27 05:14:47 +00001804 break;
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001805 case EXPR_OBJC_ISA:
Steve Narofff242b1b2009-07-24 17:54:45 +00001806 S = new (Context) ObjCIsaExpr(Empty);
1807 break;
John McCallf85e1932011-06-15 23:02:42 +00001808 case EXPR_OBJC_INDIRECT_COPY_RESTORE:
1809 S = new (Context) ObjCIndirectCopyRestoreExpr(Empty);
1810 break;
1811 case EXPR_OBJC_BRIDGED_CAST:
1812 S = new (Context) ObjCBridgedCastExpr(Empty);
1813 break;
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001814 case STMT_OBJC_FOR_COLLECTION:
Chris Lattner4c6f9522009-04-27 05:14:47 +00001815 S = new (Context) ObjCForCollectionStmt(Empty);
1816 break;
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001817 case STMT_OBJC_CATCH:
Chris Lattner4c6f9522009-04-27 05:14:47 +00001818 S = new (Context) ObjCAtCatchStmt(Empty);
1819 break;
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001820 case STMT_OBJC_FINALLY:
Chris Lattner4c6f9522009-04-27 05:14:47 +00001821 S = new (Context) ObjCAtFinallyStmt(Empty);
1822 break;
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001823 case STMT_OBJC_AT_TRY:
Douglas Gregor35942772011-09-09 21:34:22 +00001824 S = ObjCAtTryStmt::CreateEmpty(Context,
Sebastian Redl60adf4a2010-08-18 23:56:52 +00001825 Record[ASTStmtReader::NumStmtFields],
1826 Record[ASTStmtReader::NumStmtFields + 1]);
Chris Lattner4c6f9522009-04-27 05:14:47 +00001827 break;
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001828 case STMT_OBJC_AT_SYNCHRONIZED:
Chris Lattner4c6f9522009-04-27 05:14:47 +00001829 S = new (Context) ObjCAtSynchronizedStmt(Empty);
1830 break;
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001831 case STMT_OBJC_AT_THROW:
Chris Lattner4c6f9522009-04-27 05:14:47 +00001832 S = new (Context) ObjCAtThrowStmt(Empty);
1833 break;
John McCallf85e1932011-06-15 23:02:42 +00001834 case STMT_OBJC_AUTORELEASE_POOL:
1835 S = new (Context) ObjCAutoreleasePoolStmt(Empty);
1836 break;
John McCall7110fd62011-07-15 07:00:14 +00001837 case STMT_SEH_EXCEPT:
1838 S = new (Context) SEHExceptStmt(Empty);
1839 break;
1840 case STMT_SEH_FINALLY:
1841 S = new (Context) SEHFinallyStmt(Empty);
1842 break;
1843 case STMT_SEH_TRY:
1844 S = new (Context) SEHTryStmt(Empty);
1845 break;
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001846 case STMT_CXX_CATCH:
Argyrios Kyrtzidis7cb45e32010-07-22 16:03:56 +00001847 S = new (Context) CXXCatchStmt(Empty);
1848 break;
1849
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001850 case STMT_CXX_TRY:
Douglas Gregor35942772011-09-09 21:34:22 +00001851 S = CXXTryStmt::Create(Context, Empty,
Sebastian Redl60adf4a2010-08-18 23:56:52 +00001852 /*NumHandlers=*/Record[ASTStmtReader::NumStmtFields]);
Argyrios Kyrtzidis7cb45e32010-07-22 16:03:56 +00001853 break;
1854
Richard Smithad762fc2011-04-14 22:09:26 +00001855 case STMT_CXX_FOR_RANGE:
1856 S = new (Context) CXXForRangeStmt(Empty);
1857 break;
1858
Douglas Gregorba0513d2011-10-25 01:33:02 +00001859 case STMT_MS_DEPENDENT_EXISTS:
1860 S = new (Context) MSDependentExistsStmt(SourceLocation(), true,
1861 NestedNameSpecifierLoc(),
1862 DeclarationNameInfo(),
1863 0);
1864 break;
1865
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001866 case EXPR_CXX_OPERATOR_CALL:
Douglas Gregor35942772011-09-09 21:34:22 +00001867 S = new (Context) CXXOperatorCallExpr(Context, Empty);
Argyrios Kyrtzidisba0a9002009-07-14 03:19:21 +00001868 break;
Chris Lattner1817bd42010-05-09 05:36:05 +00001869
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001870 case EXPR_CXX_MEMBER_CALL:
Douglas Gregor35942772011-09-09 21:34:22 +00001871 S = new (Context) CXXMemberCallExpr(Context, Empty);
Chris Lattner1817bd42010-05-09 05:36:05 +00001872 break;
Douglas Gregor39da0b82009-09-09 23:08:42 +00001873
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001874 case EXPR_CXX_CONSTRUCT:
Argyrios Kyrtzidis6d00c132010-07-10 11:46:15 +00001875 S = new (Context) CXXConstructExpr(Empty);
1876 break;
1877
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001878 case EXPR_CXX_TEMPORARY_OBJECT:
Argyrios Kyrtzidis6d00c132010-07-10 11:46:15 +00001879 S = new (Context) CXXTemporaryObjectExpr(Empty);
Douglas Gregor39da0b82009-09-09 23:08:42 +00001880 break;
Sam Weinigce757a72010-01-16 21:21:01 +00001881
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001882 case EXPR_CXX_STATIC_CAST:
Douglas Gregor35942772011-09-09 21:34:22 +00001883 S = CXXStaticCastExpr::CreateEmpty(Context,
Sebastian Redl60adf4a2010-08-18 23:56:52 +00001884 /*PathSize*/ Record[ASTStmtReader::NumExprFields]);
Sam Weinigce757a72010-01-16 21:21:01 +00001885 break;
1886
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001887 case EXPR_CXX_DYNAMIC_CAST:
Douglas Gregor35942772011-09-09 21:34:22 +00001888 S = CXXDynamicCastExpr::CreateEmpty(Context,
Sebastian Redl60adf4a2010-08-18 23:56:52 +00001889 /*PathSize*/ Record[ASTStmtReader::NumExprFields]);
Sam Weinigce757a72010-01-16 21:21:01 +00001890 break;
1891
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001892 case EXPR_CXX_REINTERPRET_CAST:
Douglas Gregor35942772011-09-09 21:34:22 +00001893 S = CXXReinterpretCastExpr::CreateEmpty(Context,
Sebastian Redl60adf4a2010-08-18 23:56:52 +00001894 /*PathSize*/ Record[ASTStmtReader::NumExprFields]);
Sam Weinigce757a72010-01-16 21:21:01 +00001895 break;
1896
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001897 case EXPR_CXX_CONST_CAST:
Douglas Gregor35942772011-09-09 21:34:22 +00001898 S = CXXConstCastExpr::CreateEmpty(Context);
Sam Weinigce757a72010-01-16 21:21:01 +00001899 break;
1900
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001901 case EXPR_CXX_FUNCTIONAL_CAST:
Douglas Gregor35942772011-09-09 21:34:22 +00001902 S = CXXFunctionalCastExpr::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_BOOL_LITERAL:
Sam Weinigeb7f9612010-02-07 06:32:43 +00001907 S = new (Context) CXXBoolLiteralExpr(Empty);
1908 break;
Sam Weinigce757a72010-01-16 21:21:01 +00001909
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001910 case EXPR_CXX_NULL_PTR_LITERAL:
Sam Weinigeb7f9612010-02-07 06:32:43 +00001911 S = new (Context) CXXNullPtrLiteralExpr(Empty);
1912 break;
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001913 case EXPR_CXX_TYPEID_EXPR:
Chris Lattner14ab24f2010-05-09 06:03:39 +00001914 S = new (Context) CXXTypeidExpr(Empty, true);
1915 break;
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001916 case EXPR_CXX_TYPEID_TYPE:
Chris Lattner14ab24f2010-05-09 06:03:39 +00001917 S = new (Context) CXXTypeidExpr(Empty, false);
1918 break;
Francois Pichet01b7c302010-09-08 12:20:18 +00001919 case EXPR_CXX_UUIDOF_EXPR:
1920 S = new (Context) CXXUuidofExpr(Empty, true);
1921 break;
1922 case EXPR_CXX_UUIDOF_TYPE:
1923 S = new (Context) CXXUuidofExpr(Empty, false);
1924 break;
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001925 case EXPR_CXX_THIS:
Chris Lattner2fbdfcd2010-05-09 06:15:05 +00001926 S = new (Context) CXXThisExpr(Empty);
1927 break;
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001928 case EXPR_CXX_THROW:
Chris Lattner2fbdfcd2010-05-09 06:15:05 +00001929 S = new (Context) CXXThrowExpr(Empty);
1930 break;
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001931 case EXPR_CXX_DEFAULT_ARG: {
Sebastian Redl60adf4a2010-08-18 23:56:52 +00001932 bool HasOtherExprStored = Record[ASTStmtReader::NumExprFields];
Argyrios Kyrtzidis8a507332010-07-02 23:30:15 +00001933 if (HasOtherExprStored) {
1934 Expr *SubExpr = ReadSubExpr();
Douglas Gregor35942772011-09-09 21:34:22 +00001935 S = CXXDefaultArgExpr::Create(Context, SourceLocation(), 0, SubExpr);
Argyrios Kyrtzidis8a507332010-07-02 23:30:15 +00001936 } else
1937 S = new (Context) CXXDefaultArgExpr(Empty);
Chris Lattner030854b2010-05-09 06:40:08 +00001938 break;
Argyrios Kyrtzidis8a507332010-07-02 23:30:15 +00001939 }
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001940 case EXPR_CXX_BIND_TEMPORARY:
Chris Lattnerd2598362010-05-10 00:25:06 +00001941 S = new (Context) CXXBindTemporaryExpr(Empty);
1942 break;
Douglas Gregore2ca6d42010-09-02 21:50:02 +00001943
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001944 case EXPR_CXX_SCALAR_VALUE_INIT:
Douglas Gregored8abf12010-07-08 06:14:04 +00001945 S = new (Context) CXXScalarValueInitExpr(Empty);
Chris Lattner59218632010-05-10 01:22:27 +00001946 break;
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001947 case EXPR_CXX_NEW:
Chris Lattner59218632010-05-10 01:22:27 +00001948 S = new (Context) CXXNewExpr(Empty);
1949 break;
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001950 case EXPR_CXX_DELETE:
Argyrios Kyrtzidis95fc98c2010-06-22 17:07:59 +00001951 S = new (Context) CXXDeleteExpr(Empty);
1952 break;
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001953 case EXPR_CXX_PSEUDO_DESTRUCTOR:
Argyrios Kyrtzidisde4bd182010-06-28 09:32:03 +00001954 S = new (Context) CXXPseudoDestructorExpr(Empty);
1955 break;
Chris Lattner59218632010-05-10 01:22:27 +00001956
John McCall4765fa02010-12-06 08:20:24 +00001957 case EXPR_EXPR_WITH_CLEANUPS:
1958 S = new (Context) ExprWithCleanups(Empty);
Chris Lattnerd2598362010-05-10 00:25:06 +00001959 break;
Argyrios Kyrtzidis8dfbd8b2010-06-24 08:57:31 +00001960
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001961 case EXPR_CXX_DEPENDENT_SCOPE_MEMBER:
Douglas Gregor35942772011-09-09 21:34:22 +00001962 S = CXXDependentScopeMemberExpr::CreateEmpty(Context,
Douglas Gregordef03542011-02-04 12:01:24 +00001963 /*HasExplicitTemplateArgs=*/Record[ASTStmtReader::NumExprFields],
1964 /*NumTemplateArgs=*/Record[ASTStmtReader::NumExprFields]
1965 ? Record[ASTStmtReader::NumExprFields + 1]
1966 : 0);
Argyrios Kyrtzidis8dfbd8b2010-06-24 08:57:31 +00001967 break;
1968
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001969 case EXPR_CXX_DEPENDENT_SCOPE_DECL_REF:
Douglas Gregor35942772011-09-09 21:34:22 +00001970 S = DependentScopeDeclRefExpr::CreateEmpty(Context,
Douglas Gregordef03542011-02-04 12:01:24 +00001971 /*HasExplicitTemplateArgs=*/Record[ASTStmtReader::NumExprFields],
1972 /*NumTemplateArgs=*/Record[ASTStmtReader::NumExprFields]
1973 ? Record[ASTStmtReader::NumExprFields + 1]
1974 : 0);
Argyrios Kyrtzidis12dffcd2010-06-28 09:31:56 +00001975 break;
1976
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001977 case EXPR_CXX_UNRESOLVED_CONSTRUCT:
Douglas Gregor35942772011-09-09 21:34:22 +00001978 S = CXXUnresolvedConstructExpr::CreateEmpty(Context,
Sebastian Redl60adf4a2010-08-18 23:56:52 +00001979 /*NumArgs=*/Record[ASTStmtReader::NumExprFields]);
Argyrios Kyrtzidisa77eb082010-06-25 09:03:26 +00001980 break;
1981
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001982 case EXPR_CXX_UNRESOLVED_MEMBER:
Douglas Gregor35942772011-09-09 21:34:22 +00001983 S = UnresolvedMemberExpr::CreateEmpty(Context,
Douglas Gregordef03542011-02-04 12:01:24 +00001984 /*HasExplicitTemplateArgs=*/Record[ASTStmtReader::NumExprFields],
1985 /*NumTemplateArgs=*/Record[ASTStmtReader::NumExprFields]
1986 ? Record[ASTStmtReader::NumExprFields + 1]
1987 : 0);
Argyrios Kyrtzidis8dfbd8b2010-06-24 08:57:31 +00001988 break;
Argyrios Kyrtzidisbd65bb52010-06-25 09:03:34 +00001989
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001990 case EXPR_CXX_UNRESOLVED_LOOKUP:
Douglas Gregor35942772011-09-09 21:34:22 +00001991 S = UnresolvedLookupExpr::CreateEmpty(Context,
Douglas Gregordef03542011-02-04 12:01:24 +00001992 /*HasExplicitTemplateArgs=*/Record[ASTStmtReader::NumExprFields],
1993 /*NumTemplateArgs=*/Record[ASTStmtReader::NumExprFields]
1994 ? Record[ASTStmtReader::NumExprFields + 1]
1995 : 0);
Argyrios Kyrtzidisbd65bb52010-06-25 09:03:34 +00001996 break;
Argyrios Kyrtzidis6d00c132010-07-10 11:46:15 +00001997
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001998 case EXPR_CXX_UNARY_TYPE_TRAIT:
Argyrios Kyrtzidis6d00c132010-07-10 11:46:15 +00001999 S = new (Context) UnaryTypeTraitExpr(Empty);
2000 break;
Sebastian Redl6b219d02010-09-10 20:55:54 +00002001
Francois Pichetf1872372010-12-08 22:35:30 +00002002 case EXPR_BINARY_TYPE_TRAIT:
Francois Pichet6ad6f282010-12-07 00:08:36 +00002003 S = new (Context) BinaryTypeTraitExpr(Empty);
2004 break;
2005
John Wiegley21ff2e52011-04-28 00:16:57 +00002006 case EXPR_ARRAY_TYPE_TRAIT:
2007 S = new (Context) ArrayTypeTraitExpr(Empty);
2008 break;
2009
John Wiegley55262202011-04-25 06:54:41 +00002010 case EXPR_CXX_EXPRESSION_TRAIT:
2011 S = new (Context) ExpressionTraitExpr(Empty);
2012 break;
2013
Sebastian Redl6b219d02010-09-10 20:55:54 +00002014 case EXPR_CXX_NOEXCEPT:
2015 S = new (Context) CXXNoexceptExpr(Empty);
2016 break;
John McCall7cd7d1a2010-11-15 23:31:06 +00002017
Douglas Gregorbe230c32011-01-03 17:17:50 +00002018 case EXPR_PACK_EXPANSION:
2019 S = new (Context) PackExpansionExpr(Empty);
2020 break;
2021
Douglas Gregoree8aff02011-01-04 17:33:58 +00002022 case EXPR_SIZEOF_PACK:
2023 S = new (Context) SizeOfPackExpr(Empty);
2024 break;
2025
John McCall7110fd62011-07-15 07:00:14 +00002026 case EXPR_SUBST_NON_TYPE_TEMPLATE_PARM:
2027 S = new (Context) SubstNonTypeTemplateParmExpr(Empty);
2028 break;
2029
Douglas Gregorc7793c72011-01-15 01:15:58 +00002030 case EXPR_SUBST_NON_TYPE_TEMPLATE_PARM_PACK:
2031 S = new (Context) SubstNonTypeTemplateParmPackExpr(Empty);
2032 break;
2033
Douglas Gregor03e80032011-06-21 17:03:29 +00002034 case EXPR_MATERIALIZE_TEMPORARY:
2035 S = new (Context) MaterializeTemporaryExpr(Empty);
2036 break;
2037
John McCall56ca35d2011-02-17 10:25:35 +00002038 case EXPR_OPAQUE_VALUE: {
2039 unsigned key = Record[ASTStmtReader::NumExprFields];
2040 OpaqueValueExpr *&expr = OpaqueValueExprs[key];
2041
2042 // If we already have an entry for this opaque value expression,
2043 // don't bother reading it again.
2044 if (expr) {
2045 StmtStack.push_back(expr);
2046 continue;
2047 }
2048
2049 S = expr = new (Context) OpaqueValueExpr(Empty);
John McCall7cd7d1a2010-11-15 23:31:06 +00002050 break;
John McCall56ca35d2011-02-17 10:25:35 +00002051 }
Peter Collingbournee08ce652011-02-09 21:07:24 +00002052
2053 case EXPR_CUDA_KERNEL_CALL:
Douglas Gregor35942772011-09-09 21:34:22 +00002054 S = new (Context) CUDAKernelCallExpr(Context, Empty);
Peter Collingbournee08ce652011-02-09 21:07:24 +00002055 break;
Tanya Lattner61eee0c2011-06-04 00:47:47 +00002056
2057 case EXPR_ASTYPE:
2058 S = new (Context) AsTypeExpr(Empty);
2059 break;
Eli Friedman276b0612011-10-11 02:20:01 +00002060
2061 case EXPR_ATOMIC:
2062 S = new (Context) AtomicExpr(Empty);
2063 break;
Chris Lattner4c6f9522009-04-27 05:14:47 +00002064 }
Argyrios Kyrtzidis6d00c132010-07-10 11:46:15 +00002065
Chris Lattner4c6f9522009-04-27 05:14:47 +00002066 // We hit a STMT_STOP, so we're done with this expression.
2067 if (Finished)
2068 break;
2069
2070 ++NumStatementsRead;
2071
Argyrios Kyrtzidise6f08682011-10-21 23:02:28 +00002072 if (S && !IsStmtReference) {
Argyrios Kyrtzidis919e6932010-06-28 22:28:35 +00002073 Reader.Visit(S);
Argyrios Kyrtzidise6f08682011-10-21 23:02:28 +00002074 StmtEntries[Cursor.GetCurrentBitNo()] = S;
2075 }
2076
Chris Lattner4c6f9522009-04-27 05:14:47 +00002077
2078 assert(Idx == Record.size() && "Invalid deserialization of statement");
2079 StmtStack.push_back(S);
2080 }
Argyrios Kyrtzidis919e6932010-06-28 22:28:35 +00002081
2082#ifndef NDEBUG
2083 assert(StmtStack.size() > PrevNumStmts && "Read too many sub stmts!");
2084 assert(StmtStack.size() == PrevNumStmts + 1 && "Extra expressions on stack!");
2085#endif
2086
2087 return StmtStack.pop_back_val();
Chris Lattner4c6f9522009-04-27 05:14:47 +00002088}