blob: e57ab1937c5b92e2b6c4774048c8dc4cb752b47f [file] [log] [blame]
Sebastian Redl3b3c8742010-08-18 23:57:11 +00001//===--- ASTReaderStmt.cpp - Stmt/Expr Deserialization ----------*- C++ -*-===//
Chris Lattner92ba5ff2009-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 Redl2c499f62010-08-18 23:56:43 +000011// ASTReader::ReadStmt method.
Chris Lattner92ba5ff2009-04-27 05:14:47 +000012//
13//===----------------------------------------------------------------------===//
14
Sebastian Redlf5b13462010-08-18 23:57:17 +000015#include "clang/Serialization/ASTReader.h"
Douglas Gregor5d3507d2009-09-09 23:08:42 +000016#include "clang/AST/DeclCXX.h"
Douglas Gregorcdbc5392011-01-15 01:15:58 +000017#include "clang/AST/DeclTemplate.h"
Chris Lattner92ba5ff2009-04-27 05:14:47 +000018#include "clang/AST/StmtVisitor.h"
19using namespace clang;
Sebastian Redl539c5062010-08-18 23:57:32 +000020using namespace clang::serialization;
Chris Lattner92ba5ff2009-04-27 05:14:47 +000021
Argyrios Kyrtzidisf9f47c82010-06-30 08:49:18 +000022namespace clang {
Argyrios Kyrtzidisddf5f212010-06-28 09:31:42 +000023
Sebastian Redl70c751d2010-08-18 23:56:52 +000024 class ASTStmtReader : public StmtVisitor<ASTStmtReader> {
Douglas Gregor7fb09192011-07-21 22:35:25 +000025 typedef ASTReader::RecordData RecordData;
26
Sebastian Redl2c499f62010-08-18 23:56:43 +000027 ASTReader &Reader;
Douglas Gregora6895d82011-07-22 16:00:58 +000028 Module &F;
Sebastian Redlc67764e2010-07-22 22:43:28 +000029 llvm::BitstreamCursor &DeclsCursor;
Sebastian Redl2c499f62010-08-18 23:56:43 +000030 const ASTReader::RecordData &Record;
Chris Lattner92ba5ff2009-04-27 05:14:47 +000031 unsigned &Idx;
Chris Lattner92ba5ff2009-04-27 05:14:47 +000032
Douglas Gregor7fb09192011-07-21 22:35:25 +000033 SourceLocation ReadSourceLocation(const RecordData &R, unsigned &I) {
Sebastian Redl2c373b92010-10-05 15:59:54 +000034 return Reader.ReadSourceLocation(F, R, I);
35 }
Douglas Gregor7fb09192011-07-21 22:35:25 +000036
37 SourceRange ReadSourceRange(const RecordData &R, unsigned &I) {
Sebastian Redl2c373b92010-10-05 15:59:54 +000038 return Reader.ReadSourceRange(F, R, I);
39 }
Douglas Gregor7fb09192011-07-21 22:35:25 +000040
41 TypeSourceInfo *GetTypeSourceInfo(const RecordData &R, unsigned &I) {
Sebastian Redl2c373b92010-10-05 15:59:54 +000042 return Reader.GetTypeSourceInfo(F, R, I);
43 }
Douglas Gregor7fb09192011-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 Kyrtzidis434383d2010-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 Gregor7fb09192011-07-21 22:35:25 +000062
Argyrios Kyrtzidis434383d2010-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 Redl2c373b92010-10-05 15:59:54 +000067
Chris Lattner92ba5ff2009-04-27 05:14:47 +000068 public:
Douglas Gregora6895d82011-07-22 16:00:58 +000069 ASTStmtReader(ASTReader &Reader, Module &F,
Sebastian Redl2c373b92010-10-05 15:59:54 +000070 llvm::BitstreamCursor &Cursor,
Sebastian Redl2c499f62010-08-18 23:56:43 +000071 const ASTReader::RecordData &Record, unsigned &Idx)
Sebastian Redl2c373b92010-10-05 15:59:54 +000072 : Reader(Reader), F(F), DeclsCursor(Cursor), Record(Record), Idx(Idx) { }
Chris Lattner92ba5ff2009-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 Gregor678d76c2011-07-01 01:22:09 +000080 static const unsigned NumExprFields = NumStmtFields + 7;
Argyrios Kyrtzidisb5288de2010-06-28 09:31:48 +000081
82 /// \brief Read and initialize a ExplicitTemplateArgumentList structure.
Argyrios Kyrtzidisde6aa082011-09-22 20:07:03 +000083 void ReadExplicitTemplateArgumentList(ASTTemplateArgumentListInfo &ArgList,
Argyrios Kyrtzidisd0795b22010-06-28 22:28:35 +000084 unsigned NumTemplateArgs);
Chris Lattner92ba5ff2009-04-27 05:14:47 +000085
Argyrios Kyrtzidisd0795b22010-06-28 22:28:35 +000086 void VisitStmt(Stmt *S);
John McCallfa194042011-07-15 07:00:14 +000087#define STMT(Type, Base) \
88 void Visit##Type(Type *);
89#include "clang/AST/StmtNodes.inc"
Chris Lattner92ba5ff2009-04-27 05:14:47 +000090 };
91}
92
Sebastian Redl70c751d2010-08-18 23:56:52 +000093void ASTStmtReader::
Argyrios Kyrtzidisde6aa082011-09-22 20:07:03 +000094ReadExplicitTemplateArgumentList(ASTTemplateArgumentListInfo &ArgList,
Argyrios Kyrtzidisd0795b22010-06-28 22:28:35 +000095 unsigned NumTemplateArgs) {
Argyrios Kyrtzidisb5288de2010-06-28 09:31:48 +000096 TemplateArgumentListInfo ArgInfo;
Sebastian Redl2c373b92010-10-05 15:59:54 +000097 ArgInfo.setLAngleLoc(ReadSourceLocation(Record, Idx));
98 ArgInfo.setRAngleLoc(ReadSourceLocation(Record, Idx));
Argyrios Kyrtzidisb5288de2010-06-28 09:31:48 +000099 for (unsigned i = 0; i != NumTemplateArgs; ++i)
Sebastian Redlc67764e2010-07-22 22:43:28 +0000100 ArgInfo.addArgument(
Sebastian Redl2c373b92010-10-05 15:59:54 +0000101 Reader.ReadTemplateArgumentLoc(F, Record, Idx));
Argyrios Kyrtzidisb5288de2010-06-28 09:31:48 +0000102 ArgList.initializeFrom(ArgInfo);
Argyrios Kyrtzidisb5288de2010-06-28 09:31:48 +0000103}
104
Sebastian Redl70c751d2010-08-18 23:56:52 +0000105void ASTStmtReader::VisitStmt(Stmt *S) {
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000106 assert(Idx == NumStmtFields && "Incorrect statement field count");
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000107}
108
Sebastian Redl70c751d2010-08-18 23:56:52 +0000109void ASTStmtReader::VisitNullStmt(NullStmt *S) {
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000110 VisitStmt(S);
Sebastian Redl2c373b92010-10-05 15:59:54 +0000111 S->setSemiLoc(ReadSourceLocation(Record, Idx));
Argyrios Kyrtzidis43ea78b2011-09-01 21:53:45 +0000112 S->HasLeadingEmptyMacro = Record[Idx++];
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000113}
114
Sebastian Redl70c751d2010-08-18 23:56:52 +0000115void ASTStmtReader::VisitCompoundStmt(CompoundStmt *S) {
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000116 VisitStmt(S);
Chris Lattner0e62c1c2011-07-23 10:55:15 +0000117 SmallVector<Stmt *, 16> Stmts;
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000118 unsigned NumStmts = Record[Idx++];
Argyrios Kyrtzidisd0795b22010-06-28 22:28:35 +0000119 while (NumStmts--)
Argyrios Kyrtzidis26d72012010-06-29 22:46:25 +0000120 Stmts.push_back(Reader.ReadSubStmt());
Douglas Gregor4163aca2011-09-09 21:34:22 +0000121 S->setStmts(Reader.getContext(), Stmts.data(), Stmts.size());
Sebastian Redl2c373b92010-10-05 15:59:54 +0000122 S->setLBracLoc(ReadSourceLocation(Record, Idx));
123 S->setRBracLoc(ReadSourceLocation(Record, Idx));
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000124}
125
Sebastian Redl70c751d2010-08-18 23:56:52 +0000126void ASTStmtReader::VisitSwitchCase(SwitchCase *S) {
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000127 VisitStmt(S);
128 Reader.RecordSwitchCaseID(S, Record[Idx++]);
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000129}
130
Sebastian Redl70c751d2010-08-18 23:56:52 +0000131void ASTStmtReader::VisitCaseStmt(CaseStmt *S) {
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000132 VisitSwitchCase(S);
Argyrios Kyrtzidis26d72012010-06-29 22:46:25 +0000133 S->setLHS(Reader.ReadSubExpr());
134 S->setRHS(Reader.ReadSubExpr());
135 S->setSubStmt(Reader.ReadSubStmt());
Sebastian Redl2c373b92010-10-05 15:59:54 +0000136 S->setCaseLoc(ReadSourceLocation(Record, Idx));
137 S->setEllipsisLoc(ReadSourceLocation(Record, Idx));
138 S->setColonLoc(ReadSourceLocation(Record, Idx));
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000139}
140
Sebastian Redl70c751d2010-08-18 23:56:52 +0000141void ASTStmtReader::VisitDefaultStmt(DefaultStmt *S) {
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000142 VisitSwitchCase(S);
Argyrios Kyrtzidis26d72012010-06-29 22:46:25 +0000143 S->setSubStmt(Reader.ReadSubStmt());
Sebastian Redl2c373b92010-10-05 15:59:54 +0000144 S->setDefaultLoc(ReadSourceLocation(Record, Idx));
145 S->setColonLoc(ReadSourceLocation(Record, Idx));
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000146}
147
Sebastian Redl70c751d2010-08-18 23:56:52 +0000148void ASTStmtReader::VisitLabelStmt(LabelStmt *S) {
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000149 VisitStmt(S);
Douglas Gregor7fb09192011-07-21 22:35:25 +0000150 LabelDecl *LD = ReadDeclAs<LabelDecl>(Record, Idx);
Chris Lattnerc8e630e2011-02-17 07:39:24 +0000151 LD->setStmt(S);
152 S->setDecl(LD);
Argyrios Kyrtzidis26d72012010-06-29 22:46:25 +0000153 S->setSubStmt(Reader.ReadSubStmt());
Sebastian Redl2c373b92010-10-05 15:59:54 +0000154 S->setIdentLoc(ReadSourceLocation(Record, Idx));
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000155}
156
Sebastian Redl70c751d2010-08-18 23:56:52 +0000157void ASTStmtReader::VisitIfStmt(IfStmt *S) {
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000158 VisitStmt(S);
Douglas Gregor4163aca2011-09-09 21:34:22 +0000159 S->setConditionVariable(Reader.getContext(),
Douglas Gregor7fb09192011-07-21 22:35:25 +0000160 ReadDeclAs<VarDecl>(Record, Idx));
Argyrios Kyrtzidis26d72012010-06-29 22:46:25 +0000161 S->setCond(Reader.ReadSubExpr());
162 S->setThen(Reader.ReadSubStmt());
163 S->setElse(Reader.ReadSubStmt());
Sebastian Redl2c373b92010-10-05 15:59:54 +0000164 S->setIfLoc(ReadSourceLocation(Record, Idx));
165 S->setElseLoc(ReadSourceLocation(Record, Idx));
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000166}
167
Sebastian Redl70c751d2010-08-18 23:56:52 +0000168void ASTStmtReader::VisitSwitchStmt(SwitchStmt *S) {
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000169 VisitStmt(S);
Douglas Gregor4163aca2011-09-09 21:34:22 +0000170 S->setConditionVariable(Reader.getContext(),
Douglas Gregor7fb09192011-07-21 22:35:25 +0000171 ReadDeclAs<VarDecl>(Record, Idx));
Argyrios Kyrtzidis26d72012010-06-29 22:46:25 +0000172 S->setCond(Reader.ReadSubExpr());
173 S->setBody(Reader.ReadSubStmt());
Sebastian Redl2c373b92010-10-05 15:59:54 +0000174 S->setSwitchLoc(ReadSourceLocation(Record, Idx));
Ted Kremenekc42f3452010-09-09 00:05:53 +0000175 if (Record[Idx++])
176 S->setAllEnumCasesCovered();
177
Chris Lattner92ba5ff2009-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 Stump11289f42009-09-09 15:08:12 +0000185
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000186 PrevSC = SC;
187 }
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000188}
189
Sebastian Redl70c751d2010-08-18 23:56:52 +0000190void ASTStmtReader::VisitWhileStmt(WhileStmt *S) {
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000191 VisitStmt(S);
Douglas Gregor4163aca2011-09-09 21:34:22 +0000192 S->setConditionVariable(Reader.getContext(),
Douglas Gregor7fb09192011-07-21 22:35:25 +0000193 ReadDeclAs<VarDecl>(Record, Idx));
194
Argyrios Kyrtzidis26d72012010-06-29 22:46:25 +0000195 S->setCond(Reader.ReadSubExpr());
196 S->setBody(Reader.ReadSubStmt());
Sebastian Redl2c373b92010-10-05 15:59:54 +0000197 S->setWhileLoc(ReadSourceLocation(Record, Idx));
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000198}
199
Sebastian Redl70c751d2010-08-18 23:56:52 +0000200void ASTStmtReader::VisitDoStmt(DoStmt *S) {
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000201 VisitStmt(S);
Argyrios Kyrtzidis26d72012010-06-29 22:46:25 +0000202 S->setCond(Reader.ReadSubExpr());
203 S->setBody(Reader.ReadSubStmt());
Sebastian Redl2c373b92010-10-05 15:59:54 +0000204 S->setDoLoc(ReadSourceLocation(Record, Idx));
205 S->setWhileLoc(ReadSourceLocation(Record, Idx));
206 S->setRParenLoc(ReadSourceLocation(Record, Idx));
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000207}
208
Sebastian Redl70c751d2010-08-18 23:56:52 +0000209void ASTStmtReader::VisitForStmt(ForStmt *S) {
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000210 VisitStmt(S);
Argyrios Kyrtzidis26d72012010-06-29 22:46:25 +0000211 S->setInit(Reader.ReadSubStmt());
212 S->setCond(Reader.ReadSubExpr());
Douglas Gregor4163aca2011-09-09 21:34:22 +0000213 S->setConditionVariable(Reader.getContext(),
Douglas Gregor7fb09192011-07-21 22:35:25 +0000214 ReadDeclAs<VarDecl>(Record, Idx));
Argyrios Kyrtzidis26d72012010-06-29 22:46:25 +0000215 S->setInc(Reader.ReadSubExpr());
216 S->setBody(Reader.ReadSubStmt());
Sebastian Redl2c373b92010-10-05 15:59:54 +0000217 S->setForLoc(ReadSourceLocation(Record, Idx));
218 S->setLParenLoc(ReadSourceLocation(Record, Idx));
219 S->setRParenLoc(ReadSourceLocation(Record, Idx));
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000220}
221
Sebastian Redl70c751d2010-08-18 23:56:52 +0000222void ASTStmtReader::VisitGotoStmt(GotoStmt *S) {
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000223 VisitStmt(S);
Douglas Gregor7fb09192011-07-21 22:35:25 +0000224 S->setLabel(ReadDeclAs<LabelDecl>(Record, Idx));
Sebastian Redl2c373b92010-10-05 15:59:54 +0000225 S->setGotoLoc(ReadSourceLocation(Record, Idx));
226 S->setLabelLoc(ReadSourceLocation(Record, Idx));
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000227}
228
Sebastian Redl70c751d2010-08-18 23:56:52 +0000229void ASTStmtReader::VisitIndirectGotoStmt(IndirectGotoStmt *S) {
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000230 VisitStmt(S);
Sebastian Redl2c373b92010-10-05 15:59:54 +0000231 S->setGotoLoc(ReadSourceLocation(Record, Idx));
232 S->setStarLoc(ReadSourceLocation(Record, Idx));
Argyrios Kyrtzidis26d72012010-06-29 22:46:25 +0000233 S->setTarget(Reader.ReadSubExpr());
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000234}
235
Sebastian Redl70c751d2010-08-18 23:56:52 +0000236void ASTStmtReader::VisitContinueStmt(ContinueStmt *S) {
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000237 VisitStmt(S);
Sebastian Redl2c373b92010-10-05 15:59:54 +0000238 S->setContinueLoc(ReadSourceLocation(Record, Idx));
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000239}
240
Sebastian Redl70c751d2010-08-18 23:56:52 +0000241void ASTStmtReader::VisitBreakStmt(BreakStmt *S) {
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000242 VisitStmt(S);
Sebastian Redl2c373b92010-10-05 15:59:54 +0000243 S->setBreakLoc(ReadSourceLocation(Record, Idx));
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000244}
245
Sebastian Redl70c751d2010-08-18 23:56:52 +0000246void ASTStmtReader::VisitReturnStmt(ReturnStmt *S) {
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000247 VisitStmt(S);
Argyrios Kyrtzidis26d72012010-06-29 22:46:25 +0000248 S->setRetValue(Reader.ReadSubExpr());
Sebastian Redl2c373b92010-10-05 15:59:54 +0000249 S->setReturnLoc(ReadSourceLocation(Record, Idx));
Douglas Gregor7fb09192011-07-21 22:35:25 +0000250 S->setNRVOCandidate(ReadDeclAs<VarDecl>(Record, Idx));
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000251}
252
Sebastian Redl70c751d2010-08-18 23:56:52 +0000253void ASTStmtReader::VisitDeclStmt(DeclStmt *S) {
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000254 VisitStmt(S);
Sebastian Redl2c373b92010-10-05 15:59:54 +0000255 S->setStartLoc(ReadSourceLocation(Record, Idx));
256 S->setEndLoc(ReadSourceLocation(Record, Idx));
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000257
258 if (Idx + 1 == Record.size()) {
259 // Single declaration
Douglas Gregor7fb09192011-07-21 22:35:25 +0000260 S->setDeclGroup(DeclGroupRef(ReadDecl(Record, Idx)));
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000261 } else {
Chris Lattner0e62c1c2011-07-23 10:55:15 +0000262 SmallVector<Decl *, 16> Decls;
Douglas Gregor7fb09192011-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 Gregor4163aca2011-09-09 21:34:22 +0000266 S->setDeclGroup(DeclGroupRef(DeclGroup::Create(Reader.getContext(),
Douglas Gregor038c3382009-05-22 22:45:36 +0000267 Decls.data(),
268 Decls.size())));
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000269 }
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000270}
271
Sebastian Redl70c751d2010-08-18 23:56:52 +0000272void ASTStmtReader::VisitAsmStmt(AsmStmt *S) {
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000273 VisitStmt(S);
274 unsigned NumOutputs = Record[Idx++];
275 unsigned NumInputs = Record[Idx++];
276 unsigned NumClobbers = Record[Idx++];
Sebastian Redl2c373b92010-10-05 15:59:54 +0000277 S->setAsmLoc(ReadSourceLocation(Record, Idx));
278 S->setRParenLoc(ReadSourceLocation(Record, Idx));
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000279 S->setVolatile(Record[Idx++]);
280 S->setSimple(Record[Idx++]);
Mike Stump90be58a2010-01-04 22:37:17 +0000281 S->setMSAsm(Record[Idx++]);
Mike Stump11289f42009-09-09 15:08:12 +0000282
Argyrios Kyrtzidis26d72012010-06-29 22:46:25 +0000283 S->setAsmString(cast_or_null<StringLiteral>(Reader.ReadSubStmt()));
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000284
285 // Outputs and inputs
Chris Lattner0e62c1c2011-07-23 10:55:15 +0000286 SmallVector<IdentifierInfo *, 16> Names;
287 SmallVector<StringLiteral*, 16> Constraints;
288 SmallVector<Stmt*, 16> Exprs;
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000289 for (unsigned I = 0, N = NumOutputs + NumInputs; I != N; ++I) {
Douglas Gregora3e41532011-07-28 20:55:49 +0000290 Names.push_back(Reader.GetIdentifierInfo(F, Record, Idx));
Argyrios Kyrtzidis26d72012010-06-29 22:46:25 +0000291 Constraints.push_back(cast_or_null<StringLiteral>(Reader.ReadSubStmt()));
292 Exprs.push_back(Reader.ReadSubStmt());
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000293 }
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000294
295 // Constraints
Chris Lattner0e62c1c2011-07-23 10:55:15 +0000296 SmallVector<StringLiteral*, 16> Clobbers;
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000297 for (unsigned I = 0; I != NumClobbers; ++I)
Argyrios Kyrtzidis26d72012010-06-29 22:46:25 +0000298 Clobbers.push_back(cast_or_null<StringLiteral>(Reader.ReadSubStmt()));
Anders Carlsson96fe0b52010-01-30 19:34:25 +0000299
Douglas Gregor4163aca2011-09-09 21:34:22 +0000300 S->setOutputsAndInputsAndClobbers(Reader.getContext(),
Anders Carlsson66de0812010-01-30 20:38:10 +0000301 Names.data(), Constraints.data(),
Anders Carlsson96fe0b52010-01-30 19:34:25 +0000302 Exprs.data(), NumOutputs, NumInputs,
303 Clobbers.data(), NumClobbers);
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000304}
305
Sebastian Redl70c751d2010-08-18 23:56:52 +0000306void ASTStmtReader::VisitExpr(Expr *E) {
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000307 VisitStmt(E);
Douglas Gregor903b7e92011-07-22 00:38:23 +0000308 E->setType(Reader.readType(F, Record, Idx));
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000309 E->setTypeDependent(Record[Idx++]);
310 E->setValueDependent(Record[Idx++]);
Douglas Gregor678d76c2011-07-01 01:22:09 +0000311 E->setInstantiationDependent(Record[Idx++]);
Douglas Gregor506bd562010-12-13 22:49:22 +0000312 E->ExprBits.ContainsUnexpandedParameterPack = Record[Idx++];
John McCall7decc9e2010-11-18 06:31:45 +0000313 E->setValueKind(static_cast<ExprValueKind>(Record[Idx++]));
314 E->setObjectKind(static_cast<ExprObjectKind>(Record[Idx++]));
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000315 assert(Idx == NumExprFields && "Incorrect expression field count");
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000316}
317
Sebastian Redl70c751d2010-08-18 23:56:52 +0000318void ASTStmtReader::VisitPredefinedExpr(PredefinedExpr *E) {
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000319 VisitExpr(E);
Sebastian Redl2c373b92010-10-05 15:59:54 +0000320 E->setLocation(ReadSourceLocation(Record, Idx));
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000321 E->setIdentType((PredefinedExpr::IdentType)Record[Idx++]);
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000322}
323
Sebastian Redl70c751d2010-08-18 23:56:52 +0000324void ASTStmtReader::VisitDeclRefExpr(DeclRefExpr *E) {
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000325 VisitExpr(E);
Argyrios Kyrtzidis1985bb32010-07-08 13:09:47 +0000326
Chandler Carruth0e439962011-05-01 21:29:53 +0000327 E->DeclRefExprBits.HasQualifier = Record[Idx++];
Chandler Carruth8d26bb02011-05-01 23:48:14 +0000328 E->DeclRefExprBits.HasFoundDecl = Record[Idx++];
Chandler Carruth0e439962011-05-01 21:29:53 +0000329 E->DeclRefExprBits.HasExplicitTemplateArgs = Record[Idx++];
Abramo Bagnara635ed24e2011-10-05 07:56:41 +0000330 E->DeclRefExprBits.HadMultipleCandidates = Record[Idx++];
Anders Carlsson80756f62011-03-06 18:19:42 +0000331 unsigned NumTemplateArgs = 0;
Chandler Carruth0e439962011-05-01 21:29:53 +0000332 if (E->hasExplicitTemplateArgs())
Anders Carlsson80756f62011-03-06 18:19:42 +0000333 NumTemplateArgs = Record[Idx++];
334
Chandler Carruth0e439962011-05-01 21:29:53 +0000335 if (E->hasQualifier())
Chandler Carruthbbf65b02011-05-01 22:14:37 +0000336 E->getInternalQualifierLoc()
Douglas Gregorea972d32011-02-28 21:54:11 +0000337 = Reader.ReadNestedNameSpecifierLoc(F, Record, Idx);
Argyrios Kyrtzidis1985bb32010-07-08 13:09:47 +0000338
Chandler Carruth8d26bb02011-05-01 23:48:14 +0000339 if (E->hasFoundDecl())
Douglas Gregor7fb09192011-07-21 22:35:25 +0000340 E->getInternalFoundDecl() = ReadDeclAs<NamedDecl>(Record, Idx);
Chandler Carruth8d26bb02011-05-01 23:48:14 +0000341
Chandler Carruth0e439962011-05-01 21:29:53 +0000342 if (E->hasExplicitTemplateArgs())
John McCallb3774b52010-08-19 23:49:38 +0000343 ReadExplicitTemplateArgumentList(E->getExplicitTemplateArgs(),
Argyrios Kyrtzidis1985bb32010-07-08 13:09:47 +0000344 NumTemplateArgs);
345
Douglas Gregor7fb09192011-07-21 22:35:25 +0000346 E->setDecl(ReadDeclAs<ValueDecl>(Record, Idx));
Sebastian Redl2c373b92010-10-05 15:59:54 +0000347 E->setLocation(ReadSourceLocation(Record, Idx));
Argyrios Kyrtzidis434383d2010-10-15 18:21:24 +0000348 ReadDeclarationNameLoc(E->DNLoc, E->getDecl()->getDeclName(), Record, Idx);
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000349}
350
Sebastian Redl70c751d2010-08-18 23:56:52 +0000351void ASTStmtReader::VisitIntegerLiteral(IntegerLiteral *E) {
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000352 VisitExpr(E);
Sebastian Redl2c373b92010-10-05 15:59:54 +0000353 E->setLocation(ReadSourceLocation(Record, Idx));
Douglas Gregor4163aca2011-09-09 21:34:22 +0000354 E->setValue(Reader.getContext(), Reader.ReadAPInt(Record, Idx));
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000355}
356
Sebastian Redl70c751d2010-08-18 23:56:52 +0000357void ASTStmtReader::VisitFloatingLiteral(FloatingLiteral *E) {
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000358 VisitExpr(E);
Douglas Gregor4163aca2011-09-09 21:34:22 +0000359 E->setValue(Reader.getContext(), Reader.ReadAPFloat(Record, Idx));
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000360 E->setExact(Record[Idx++]);
Sebastian Redl2c373b92010-10-05 15:59:54 +0000361 E->setLocation(ReadSourceLocation(Record, Idx));
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000362}
363
Sebastian Redl70c751d2010-08-18 23:56:52 +0000364void ASTStmtReader::VisitImaginaryLiteral(ImaginaryLiteral *E) {
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000365 VisitExpr(E);
Argyrios Kyrtzidis26d72012010-06-29 22:46:25 +0000366 E->setSubExpr(Reader.ReadSubExpr());
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000367}
368
Sebastian Redl70c751d2010-08-18 23:56:52 +0000369void ASTStmtReader::VisitStringLiteral(StringLiteral *E) {
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000370 VisitExpr(E);
371 unsigned Len = Record[Idx++];
Mike Stump11289f42009-09-09 15:08:12 +0000372 assert(Record[Idx] == E->getNumConcatenated() &&
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000373 "Wrong number of concatenated tokens!");
374 ++Idx;
Eli Friedmanfcec6302011-11-01 02:23:42 +0000375 StringLiteral::StringKind kind =
376 static_cast<StringLiteral::StringKind>(Record[Idx++]);
377 bool isPascal = Record[Idx++];
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000378
Mike Stump11289f42009-09-09 15:08:12 +0000379 // Read string data
Daniel Dunbar36217882009-09-22 03:27:33 +0000380 llvm::SmallString<16> Str(&Record[Idx], &Record[Idx] + Len);
Eli Friedmanfcec6302011-11-01 02:23:42 +0000381 E->setString(Reader.getContext(), Str.str(), kind, isPascal);
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000382 Idx += Len;
383
384 // Read source locations
385 for (unsigned I = 0, N = E->getNumConcatenated(); I != N; ++I)
Sebastian Redl2c373b92010-10-05 15:59:54 +0000386 E->setStrTokenLoc(I, ReadSourceLocation(Record, Idx));
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000387}
388
Sebastian Redl70c751d2010-08-18 23:56:52 +0000389void ASTStmtReader::VisitCharacterLiteral(CharacterLiteral *E) {
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000390 VisitExpr(E);
391 E->setValue(Record[Idx++]);
Sebastian Redl2c373b92010-10-05 15:59:54 +0000392 E->setLocation(ReadSourceLocation(Record, Idx));
Douglas Gregorfb65e592011-07-27 05:40:30 +0000393 E->setKind(static_cast<CharacterLiteral::CharacterKind>(Record[Idx++]));
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000394}
395
Sebastian Redl70c751d2010-08-18 23:56:52 +0000396void ASTStmtReader::VisitParenExpr(ParenExpr *E) {
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000397 VisitExpr(E);
Sebastian Redl2c373b92010-10-05 15:59:54 +0000398 E->setLParen(ReadSourceLocation(Record, Idx));
399 E->setRParen(ReadSourceLocation(Record, Idx));
Argyrios Kyrtzidis26d72012010-06-29 22:46:25 +0000400 E->setSubExpr(Reader.ReadSubExpr());
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000401}
402
Sebastian Redl70c751d2010-08-18 23:56:52 +0000403void ASTStmtReader::VisitParenListExpr(ParenListExpr *E) {
Argyrios Kyrtzidisf9f47c82010-06-30 08:49:18 +0000404 VisitExpr(E);
405 unsigned NumExprs = Record[Idx++];
Douglas Gregor4163aca2011-09-09 21:34:22 +0000406 E->Exprs = new (Reader.getContext()) Stmt*[NumExprs];
Argyrios Kyrtzidisf9f47c82010-06-30 08:49:18 +0000407 for (unsigned i = 0; i != NumExprs; ++i)
408 E->Exprs[i] = Reader.ReadSubStmt();
409 E->NumExprs = NumExprs;
Sebastian Redl2c373b92010-10-05 15:59:54 +0000410 E->LParenLoc = ReadSourceLocation(Record, Idx);
411 E->RParenLoc = ReadSourceLocation(Record, Idx);
Argyrios Kyrtzidisf9f47c82010-06-30 08:49:18 +0000412}
413
Sebastian Redl70c751d2010-08-18 23:56:52 +0000414void ASTStmtReader::VisitUnaryOperator(UnaryOperator *E) {
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000415 VisitExpr(E);
Argyrios Kyrtzidis26d72012010-06-29 22:46:25 +0000416 E->setSubExpr(Reader.ReadSubExpr());
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000417 E->setOpcode((UnaryOperator::Opcode)Record[Idx++]);
Sebastian Redl2c373b92010-10-05 15:59:54 +0000418 E->setOperatorLoc(ReadSourceLocation(Record, Idx));
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000419}
420
Sebastian Redl70c751d2010-08-18 23:56:52 +0000421void ASTStmtReader::VisitOffsetOfExpr(OffsetOfExpr *E) {
Douglas Gregor882211c2010-04-28 22:16:22 +0000422 typedef OffsetOfExpr::OffsetOfNode Node;
423 VisitExpr(E);
424 assert(E->getNumComponents() == Record[Idx]);
425 ++Idx;
426 assert(E->getNumExpressions() == Record[Idx]);
427 ++Idx;
Sebastian Redl2c373b92010-10-05 15:59:54 +0000428 E->setOperatorLoc(ReadSourceLocation(Record, Idx));
429 E->setRParenLoc(ReadSourceLocation(Record, Idx));
430 E->setTypeSourceInfo(GetTypeSourceInfo(Record, Idx));
Douglas Gregor882211c2010-04-28 22:16:22 +0000431 for (unsigned I = 0, N = E->getNumComponents(); I != N; ++I) {
432 Node::Kind Kind = static_cast<Node::Kind>(Record[Idx++]);
Sebastian Redl2c373b92010-10-05 15:59:54 +0000433 SourceLocation Start = ReadSourceLocation(Record, Idx);
434 SourceLocation End = ReadSourceLocation(Record, Idx);
Douglas Gregor882211c2010-04-28 22:16:22 +0000435 switch (Kind) {
436 case Node::Array:
437 E->setComponent(I, Node(Start, Record[Idx++], End));
438 break;
439
440 case Node::Field:
Douglas Gregor7fb09192011-07-21 22:35:25 +0000441 E->setComponent(I, Node(Start, ReadDeclAs<FieldDecl>(Record, Idx), End));
Douglas Gregor882211c2010-04-28 22:16:22 +0000442 break;
443
444 case Node::Identifier:
Douglas Gregora3e41532011-07-28 20:55:49 +0000445 E->setComponent(I,
446 Node(Start,
447 Reader.GetIdentifierInfo(F, Record, Idx),
448 End));
Douglas Gregor882211c2010-04-28 22:16:22 +0000449 break;
Douglas Gregord1702062010-04-29 00:18:15 +0000450
Argyrios Kyrtzidisd67d4cc2010-07-29 18:16:10 +0000451 case Node::Base: {
Douglas Gregor4163aca2011-09-09 21:34:22 +0000452 CXXBaseSpecifier *Base = new (Reader.getContext()) CXXBaseSpecifier();
Sebastian Redl2c373b92010-10-05 15:59:54 +0000453 *Base = Reader.ReadCXXBaseSpecifier(F, Record, Idx);
Argyrios Kyrtzidisd67d4cc2010-07-29 18:16:10 +0000454 E->setComponent(I, Node(Base));
Douglas Gregord1702062010-04-29 00:18:15 +0000455 break;
Douglas Gregor882211c2010-04-28 22:16:22 +0000456 }
Argyrios Kyrtzidisd67d4cc2010-07-29 18:16:10 +0000457 }
Douglas Gregor882211c2010-04-28 22:16:22 +0000458 }
459
460 for (unsigned I = 0, N = E->getNumExpressions(); I != N; ++I)
Argyrios Kyrtzidis26d72012010-06-29 22:46:25 +0000461 E->setIndexExpr(I, Reader.ReadSubExpr());
Douglas Gregor882211c2010-04-28 22:16:22 +0000462}
463
Peter Collingbournee190dee2011-03-11 19:24:49 +0000464void ASTStmtReader::VisitUnaryExprOrTypeTraitExpr(UnaryExprOrTypeTraitExpr *E) {
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000465 VisitExpr(E);
Peter Collingbournee190dee2011-03-11 19:24:49 +0000466 E->setKind(static_cast<UnaryExprOrTypeTrait>(Record[Idx++]));
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000467 if (Record[Idx] == 0) {
Argyrios Kyrtzidis26d72012010-06-29 22:46:25 +0000468 E->setArgument(Reader.ReadSubExpr());
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000469 ++Idx;
470 } else {
Sebastian Redl2c373b92010-10-05 15:59:54 +0000471 E->setArgument(GetTypeSourceInfo(Record, Idx));
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000472 }
Sebastian Redl2c373b92010-10-05 15:59:54 +0000473 E->setOperatorLoc(ReadSourceLocation(Record, Idx));
474 E->setRParenLoc(ReadSourceLocation(Record, Idx));
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000475}
476
Sebastian Redl70c751d2010-08-18 23:56:52 +0000477void ASTStmtReader::VisitArraySubscriptExpr(ArraySubscriptExpr *E) {
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000478 VisitExpr(E);
Argyrios Kyrtzidis26d72012010-06-29 22:46:25 +0000479 E->setLHS(Reader.ReadSubExpr());
480 E->setRHS(Reader.ReadSubExpr());
Sebastian Redl2c373b92010-10-05 15:59:54 +0000481 E->setRBracketLoc(ReadSourceLocation(Record, Idx));
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000482}
483
Sebastian Redl70c751d2010-08-18 23:56:52 +0000484void ASTStmtReader::VisitCallExpr(CallExpr *E) {
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000485 VisitExpr(E);
Douglas Gregor4163aca2011-09-09 21:34:22 +0000486 E->setNumArgs(Reader.getContext(), Record[Idx++]);
Sebastian Redl2c373b92010-10-05 15:59:54 +0000487 E->setRParenLoc(ReadSourceLocation(Record, Idx));
Argyrios Kyrtzidis26d72012010-06-29 22:46:25 +0000488 E->setCallee(Reader.ReadSubExpr());
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000489 for (unsigned I = 0, N = E->getNumArgs(); I != N; ++I)
Argyrios Kyrtzidis26d72012010-06-29 22:46:25 +0000490 E->setArg(I, Reader.ReadSubExpr());
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000491}
492
John McCallfa194042011-07-15 07:00:14 +0000493void ASTStmtReader::VisitCXXMemberCallExpr(CXXMemberCallExpr *E) {
494 VisitCallExpr(E);
495}
496
Sebastian Redl70c751d2010-08-18 23:56:52 +0000497void ASTStmtReader::VisitMemberExpr(MemberExpr *E) {
Argyrios Kyrtzidis1985bb32010-07-08 13:09:47 +0000498 // Don't call VisitExpr, this is fully initialized at creation.
499 assert(E->getStmtClass() == Stmt::MemberExprClass &&
500 "It's a subclass, we must advance Idx!");
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000501}
502
Sebastian Redl70c751d2010-08-18 23:56:52 +0000503void ASTStmtReader::VisitObjCIsaExpr(ObjCIsaExpr *E) {
Steve Naroffe87026a2009-07-24 17:54:45 +0000504 VisitExpr(E);
Argyrios Kyrtzidis26d72012010-06-29 22:46:25 +0000505 E->setBase(Reader.ReadSubExpr());
Sebastian Redl2c373b92010-10-05 15:59:54 +0000506 E->setIsaMemberLoc(ReadSourceLocation(Record, Idx));
Steve Naroffe87026a2009-07-24 17:54:45 +0000507 E->setArrow(Record[Idx++]);
Steve Naroffe87026a2009-07-24 17:54:45 +0000508}
509
John McCall31168b02011-06-15 23:02:42 +0000510void ASTStmtReader::
511VisitObjCIndirectCopyRestoreExpr(ObjCIndirectCopyRestoreExpr *E) {
512 VisitExpr(E);
513 E->Operand = Reader.ReadSubExpr();
514 E->setShouldCopy(Record[Idx++]);
515}
516
517void ASTStmtReader::VisitObjCBridgedCastExpr(ObjCBridgedCastExpr *E) {
518 VisitExplicitCastExpr(E);
519 E->LParenLoc = ReadSourceLocation(Record, Idx);
520 E->BridgeKeywordLoc = ReadSourceLocation(Record, Idx);
521 E->Kind = Record[Idx++];
522}
523
Sebastian Redl70c751d2010-08-18 23:56:52 +0000524void ASTStmtReader::VisitCastExpr(CastExpr *E) {
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000525 VisitExpr(E);
John McCallcf142162010-08-07 06:22:56 +0000526 unsigned NumBaseSpecs = Record[Idx++];
527 assert(NumBaseSpecs == E->path_size());
Argyrios Kyrtzidis26d72012010-06-29 22:46:25 +0000528 E->setSubExpr(Reader.ReadSubExpr());
Anders Carlssona2615922009-07-31 00:48:10 +0000529 E->setCastKind((CastExpr::CastKind)Record[Idx++]);
John McCallcf142162010-08-07 06:22:56 +0000530 CastExpr::path_iterator BaseI = E->path_begin();
Argyrios Kyrtzidis3701fcd2010-07-02 23:30:27 +0000531 while (NumBaseSpecs--) {
Douglas Gregor4163aca2011-09-09 21:34:22 +0000532 CXXBaseSpecifier *BaseSpec = new (Reader.getContext()) CXXBaseSpecifier;
Sebastian Redl2c373b92010-10-05 15:59:54 +0000533 *BaseSpec = Reader.ReadCXXBaseSpecifier(F, Record, Idx);
John McCallcf142162010-08-07 06:22:56 +0000534 *BaseI++ = BaseSpec;
Argyrios Kyrtzidis3701fcd2010-07-02 23:30:27 +0000535 }
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000536}
537
Sebastian Redl70c751d2010-08-18 23:56:52 +0000538void ASTStmtReader::VisitBinaryOperator(BinaryOperator *E) {
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000539 VisitExpr(E);
Argyrios Kyrtzidis26d72012010-06-29 22:46:25 +0000540 E->setLHS(Reader.ReadSubExpr());
541 E->setRHS(Reader.ReadSubExpr());
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000542 E->setOpcode((BinaryOperator::Opcode)Record[Idx++]);
Sebastian Redl2c373b92010-10-05 15:59:54 +0000543 E->setOperatorLoc(ReadSourceLocation(Record, Idx));
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000544}
545
Sebastian Redl70c751d2010-08-18 23:56:52 +0000546void ASTStmtReader::VisitCompoundAssignOperator(CompoundAssignOperator *E) {
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000547 VisitBinaryOperator(E);
Douglas Gregor903b7e92011-07-22 00:38:23 +0000548 E->setComputationLHSType(Reader.readType(F, Record, Idx));
549 E->setComputationResultType(Reader.readType(F, Record, Idx));
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000550}
551
Sebastian Redl70c751d2010-08-18 23:56:52 +0000552void ASTStmtReader::VisitConditionalOperator(ConditionalOperator *E) {
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000553 VisitExpr(E);
John McCallc07a0c72011-02-17 10:25:35 +0000554 E->SubExprs[ConditionalOperator::COND] = Reader.ReadSubExpr();
555 E->SubExprs[ConditionalOperator::LHS] = Reader.ReadSubExpr();
556 E->SubExprs[ConditionalOperator::RHS] = Reader.ReadSubExpr();
557 E->QuestionLoc = ReadSourceLocation(Record, Idx);
558 E->ColonLoc = ReadSourceLocation(Record, Idx);
559}
560
561void
562ASTStmtReader::VisitBinaryConditionalOperator(BinaryConditionalOperator *E) {
563 VisitExpr(E);
564 E->OpaqueValue = cast<OpaqueValueExpr>(Reader.ReadSubExpr());
565 E->SubExprs[BinaryConditionalOperator::COMMON] = Reader.ReadSubExpr();
566 E->SubExprs[BinaryConditionalOperator::COND] = Reader.ReadSubExpr();
567 E->SubExprs[BinaryConditionalOperator::LHS] = Reader.ReadSubExpr();
568 E->SubExprs[BinaryConditionalOperator::RHS] = Reader.ReadSubExpr();
569 E->QuestionLoc = ReadSourceLocation(Record, Idx);
570 E->ColonLoc = ReadSourceLocation(Record, Idx);
571
572 E->getOpaqueValue()->setSourceExpr(E->getCommon());
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000573}
574
Sebastian Redl70c751d2010-08-18 23:56:52 +0000575void ASTStmtReader::VisitImplicitCastExpr(ImplicitCastExpr *E) {
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000576 VisitCastExpr(E);
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000577}
578
Sebastian Redl70c751d2010-08-18 23:56:52 +0000579void ASTStmtReader::VisitExplicitCastExpr(ExplicitCastExpr *E) {
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000580 VisitCastExpr(E);
Sebastian Redl2c373b92010-10-05 15:59:54 +0000581 E->setTypeInfoAsWritten(GetTypeSourceInfo(Record, Idx));
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000582}
583
Sebastian Redl70c751d2010-08-18 23:56:52 +0000584void ASTStmtReader::VisitCStyleCastExpr(CStyleCastExpr *E) {
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000585 VisitExplicitCastExpr(E);
Sebastian Redl2c373b92010-10-05 15:59:54 +0000586 E->setLParenLoc(ReadSourceLocation(Record, Idx));
587 E->setRParenLoc(ReadSourceLocation(Record, Idx));
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000588}
589
Sebastian Redl70c751d2010-08-18 23:56:52 +0000590void ASTStmtReader::VisitCompoundLiteralExpr(CompoundLiteralExpr *E) {
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000591 VisitExpr(E);
Sebastian Redl2c373b92010-10-05 15:59:54 +0000592 E->setLParenLoc(ReadSourceLocation(Record, Idx));
593 E->setTypeSourceInfo(GetTypeSourceInfo(Record, Idx));
Argyrios Kyrtzidis26d72012010-06-29 22:46:25 +0000594 E->setInitializer(Reader.ReadSubExpr());
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000595 E->setFileScope(Record[Idx++]);
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000596}
597
Sebastian Redl70c751d2010-08-18 23:56:52 +0000598void ASTStmtReader::VisitExtVectorElementExpr(ExtVectorElementExpr *E) {
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000599 VisitExpr(E);
Argyrios Kyrtzidis26d72012010-06-29 22:46:25 +0000600 E->setBase(Reader.ReadSubExpr());
Douglas Gregora3e41532011-07-28 20:55:49 +0000601 E->setAccessor(Reader.GetIdentifierInfo(F, Record, Idx));
Sebastian Redl2c373b92010-10-05 15:59:54 +0000602 E->setAccessorLoc(ReadSourceLocation(Record, Idx));
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000603}
604
Sebastian Redl70c751d2010-08-18 23:56:52 +0000605void ASTStmtReader::VisitInitListExpr(InitListExpr *E) {
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000606 VisitExpr(E);
Argyrios Kyrtzidis26d72012010-06-29 22:46:25 +0000607 E->setSyntacticForm(cast_or_null<InitListExpr>(Reader.ReadSubStmt()));
Sebastian Redl2c373b92010-10-05 15:59:54 +0000608 E->setLBraceLoc(ReadSourceLocation(Record, Idx));
609 E->setRBraceLoc(ReadSourceLocation(Record, Idx));
Argyrios Kyrtzidisbbcefa72011-04-22 05:29:30 +0000610 bool isArrayFiller = Record[Idx++];
611 Expr *filler = 0;
612 if (isArrayFiller) {
613 filler = Reader.ReadSubExpr();
614 E->ArrayFillerOrUnionFieldInit = filler;
615 } else
Douglas Gregor7fb09192011-07-21 22:35:25 +0000616 E->ArrayFillerOrUnionFieldInit = ReadDeclAs<FieldDecl>(Record, Idx);
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000617 E->sawArrayRangeDesignator(Record[Idx++]);
Argyrios Kyrtzidisbbcefa72011-04-22 05:29:30 +0000618 unsigned NumInits = Record[Idx++];
Douglas Gregor4163aca2011-09-09 21:34:22 +0000619 E->reserveInits(Reader.getContext(), NumInits);
Argyrios Kyrtzidisbbcefa72011-04-22 05:29:30 +0000620 if (isArrayFiller) {
621 for (unsigned I = 0; I != NumInits; ++I) {
622 Expr *init = Reader.ReadSubExpr();
Douglas Gregor4163aca2011-09-09 21:34:22 +0000623 E->updateInit(Reader.getContext(), I, init ? init : filler);
Argyrios Kyrtzidisbbcefa72011-04-22 05:29:30 +0000624 }
625 } else {
626 for (unsigned I = 0; I != NumInits; ++I)
Douglas Gregor4163aca2011-09-09 21:34:22 +0000627 E->updateInit(Reader.getContext(), I, Reader.ReadSubExpr());
Argyrios Kyrtzidisbbcefa72011-04-22 05:29:30 +0000628 }
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000629}
630
Sebastian Redl70c751d2010-08-18 23:56:52 +0000631void ASTStmtReader::VisitDesignatedInitExpr(DesignatedInitExpr *E) {
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000632 typedef DesignatedInitExpr::Designator Designator;
633
634 VisitExpr(E);
635 unsigned NumSubExprs = Record[Idx++];
636 assert(NumSubExprs == E->getNumSubExprs() && "Wrong number of subexprs");
637 for (unsigned I = 0; I != NumSubExprs; ++I)
Argyrios Kyrtzidis26d72012010-06-29 22:46:25 +0000638 E->setSubExpr(I, Reader.ReadSubExpr());
Sebastian Redl2c373b92010-10-05 15:59:54 +0000639 E->setEqualOrColonLoc(ReadSourceLocation(Record, Idx));
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000640 E->setGNUSyntax(Record[Idx++]);
641
Chris Lattner0e62c1c2011-07-23 10:55:15 +0000642 SmallVector<Designator, 4> Designators;
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000643 while (Idx < Record.size()) {
Sebastian Redl539c5062010-08-18 23:57:32 +0000644 switch ((DesignatorTypes)Record[Idx++]) {
645 case DESIG_FIELD_DECL: {
Douglas Gregor7fb09192011-07-21 22:35:25 +0000646 FieldDecl *Field = ReadDeclAs<FieldDecl>(Record, Idx);
Mike Stump11289f42009-09-09 15:08:12 +0000647 SourceLocation DotLoc
Sebastian Redl2c373b92010-10-05 15:59:54 +0000648 = ReadSourceLocation(Record, Idx);
Mike Stump11289f42009-09-09 15:08:12 +0000649 SourceLocation FieldLoc
Sebastian Redl2c373b92010-10-05 15:59:54 +0000650 = ReadSourceLocation(Record, Idx);
Mike Stump11289f42009-09-09 15:08:12 +0000651 Designators.push_back(Designator(Field->getIdentifier(), DotLoc,
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000652 FieldLoc));
653 Designators.back().setField(Field);
654 break;
655 }
656
Sebastian Redl539c5062010-08-18 23:57:32 +0000657 case DESIG_FIELD_NAME: {
Douglas Gregora3e41532011-07-28 20:55:49 +0000658 const IdentifierInfo *Name = Reader.GetIdentifierInfo(F, Record, Idx);
Mike Stump11289f42009-09-09 15:08:12 +0000659 SourceLocation DotLoc
Sebastian Redl2c373b92010-10-05 15:59:54 +0000660 = ReadSourceLocation(Record, Idx);
Mike Stump11289f42009-09-09 15:08:12 +0000661 SourceLocation FieldLoc
Sebastian Redl2c373b92010-10-05 15:59:54 +0000662 = ReadSourceLocation(Record, Idx);
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000663 Designators.push_back(Designator(Name, DotLoc, FieldLoc));
664 break;
665 }
Mike Stump11289f42009-09-09 15:08:12 +0000666
Sebastian Redl539c5062010-08-18 23:57:32 +0000667 case DESIG_ARRAY: {
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000668 unsigned Index = Record[Idx++];
669 SourceLocation LBracketLoc
Sebastian Redl2c373b92010-10-05 15:59:54 +0000670 = ReadSourceLocation(Record, Idx);
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000671 SourceLocation RBracketLoc
Sebastian Redl2c373b92010-10-05 15:59:54 +0000672 = ReadSourceLocation(Record, Idx);
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000673 Designators.push_back(Designator(Index, LBracketLoc, RBracketLoc));
674 break;
675 }
676
Sebastian Redl539c5062010-08-18 23:57:32 +0000677 case DESIG_ARRAY_RANGE: {
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000678 unsigned Index = Record[Idx++];
679 SourceLocation LBracketLoc
Sebastian Redl2c373b92010-10-05 15:59:54 +0000680 = ReadSourceLocation(Record, Idx);
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000681 SourceLocation EllipsisLoc
Sebastian Redl2c373b92010-10-05 15:59:54 +0000682 = ReadSourceLocation(Record, Idx);
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000683 SourceLocation RBracketLoc
Sebastian Redl2c373b92010-10-05 15:59:54 +0000684 = ReadSourceLocation(Record, Idx);
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000685 Designators.push_back(Designator(Index, LBracketLoc, EllipsisLoc,
686 RBracketLoc));
687 break;
688 }
689 }
690 }
Douglas Gregor4163aca2011-09-09 21:34:22 +0000691 E->setDesignators(Reader.getContext(),
Douglas Gregor03e8bdc2010-01-06 23:17:19 +0000692 Designators.data(), Designators.size());
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000693}
694
Sebastian Redl70c751d2010-08-18 23:56:52 +0000695void ASTStmtReader::VisitImplicitValueInitExpr(ImplicitValueInitExpr *E) {
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000696 VisitExpr(E);
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000697}
698
Sebastian Redl70c751d2010-08-18 23:56:52 +0000699void ASTStmtReader::VisitVAArgExpr(VAArgExpr *E) {
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000700 VisitExpr(E);
Argyrios Kyrtzidis26d72012010-06-29 22:46:25 +0000701 E->setSubExpr(Reader.ReadSubExpr());
Sebastian Redl2c373b92010-10-05 15:59:54 +0000702 E->setWrittenTypeInfo(GetTypeSourceInfo(Record, Idx));
703 E->setBuiltinLoc(ReadSourceLocation(Record, Idx));
704 E->setRParenLoc(ReadSourceLocation(Record, Idx));
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000705}
706
Sebastian Redl70c751d2010-08-18 23:56:52 +0000707void ASTStmtReader::VisitAddrLabelExpr(AddrLabelExpr *E) {
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000708 VisitExpr(E);
Sebastian Redl2c373b92010-10-05 15:59:54 +0000709 E->setAmpAmpLoc(ReadSourceLocation(Record, Idx));
710 E->setLabelLoc(ReadSourceLocation(Record, Idx));
Douglas Gregor7fb09192011-07-21 22:35:25 +0000711 E->setLabel(ReadDeclAs<LabelDecl>(Record, Idx));
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000712}
713
Sebastian Redl70c751d2010-08-18 23:56:52 +0000714void ASTStmtReader::VisitStmtExpr(StmtExpr *E) {
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000715 VisitExpr(E);
Sebastian Redl2c373b92010-10-05 15:59:54 +0000716 E->setLParenLoc(ReadSourceLocation(Record, Idx));
717 E->setRParenLoc(ReadSourceLocation(Record, Idx));
Argyrios Kyrtzidis26d72012010-06-29 22:46:25 +0000718 E->setSubStmt(cast_or_null<CompoundStmt>(Reader.ReadSubStmt()));
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000719}
720
Sebastian Redl70c751d2010-08-18 23:56:52 +0000721void ASTStmtReader::VisitChooseExpr(ChooseExpr *E) {
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000722 VisitExpr(E);
Argyrios Kyrtzidis26d72012010-06-29 22:46:25 +0000723 E->setCond(Reader.ReadSubExpr());
724 E->setLHS(Reader.ReadSubExpr());
725 E->setRHS(Reader.ReadSubExpr());
Sebastian Redl2c373b92010-10-05 15:59:54 +0000726 E->setBuiltinLoc(ReadSourceLocation(Record, Idx));
727 E->setRParenLoc(ReadSourceLocation(Record, Idx));
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000728}
729
Sebastian Redl70c751d2010-08-18 23:56:52 +0000730void ASTStmtReader::VisitGNUNullExpr(GNUNullExpr *E) {
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000731 VisitExpr(E);
Sebastian Redl2c373b92010-10-05 15:59:54 +0000732 E->setTokenLocation(ReadSourceLocation(Record, Idx));
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000733}
734
Sebastian Redl70c751d2010-08-18 23:56:52 +0000735void ASTStmtReader::VisitShuffleVectorExpr(ShuffleVectorExpr *E) {
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000736 VisitExpr(E);
Chris Lattner0e62c1c2011-07-23 10:55:15 +0000737 SmallVector<Expr *, 16> Exprs;
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000738 unsigned NumExprs = Record[Idx++];
Argyrios Kyrtzidisd0795b22010-06-28 22:28:35 +0000739 while (NumExprs--)
Argyrios Kyrtzidis26d72012010-06-29 22:46:25 +0000740 Exprs.push_back(Reader.ReadSubExpr());
Douglas Gregor4163aca2011-09-09 21:34:22 +0000741 E->setExprs(Reader.getContext(), Exprs.data(), Exprs.size());
Sebastian Redl2c373b92010-10-05 15:59:54 +0000742 E->setBuiltinLoc(ReadSourceLocation(Record, Idx));
743 E->setRParenLoc(ReadSourceLocation(Record, Idx));
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000744}
745
Sebastian Redl70c751d2010-08-18 23:56:52 +0000746void ASTStmtReader::VisitBlockExpr(BlockExpr *E) {
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000747 VisitExpr(E);
Douglas Gregor7fb09192011-07-21 22:35:25 +0000748 E->setBlockDecl(ReadDeclAs<BlockDecl>(Record, Idx));
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000749}
750
Sebastian Redl70c751d2010-08-18 23:56:52 +0000751void ASTStmtReader::VisitBlockDeclRefExpr(BlockDeclRefExpr *E) {
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000752 VisitExpr(E);
Douglas Gregor7fb09192011-07-21 22:35:25 +0000753 E->setDecl(ReadDeclAs<VarDecl>(Record, Idx));
Sebastian Redl2c373b92010-10-05 15:59:54 +0000754 E->setLocation(ReadSourceLocation(Record, Idx));
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000755 E->setByRef(Record[Idx++]);
Fariborz Jahaniane8918d52009-06-20 00:02:26 +0000756 E->setConstQualAdded(Record[Idx++]);
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000757}
758
Peter Collingbourne91147592011-04-15 00:35:48 +0000759void ASTStmtReader::VisitGenericSelectionExpr(GenericSelectionExpr *E) {
760 VisitExpr(E);
761 E->NumAssocs = Record[Idx++];
Douglas Gregor4163aca2011-09-09 21:34:22 +0000762 E->AssocTypes = new (Reader.getContext()) TypeSourceInfo*[E->NumAssocs];
Peter Collingbourne91147592011-04-15 00:35:48 +0000763 E->SubExprs =
Douglas Gregor4163aca2011-09-09 21:34:22 +0000764 new(Reader.getContext()) Stmt*[GenericSelectionExpr::END_EXPR+E->NumAssocs];
Peter Collingbourne91147592011-04-15 00:35:48 +0000765
766 E->SubExprs[GenericSelectionExpr::CONTROLLING] = Reader.ReadSubExpr();
767 for (unsigned I = 0, N = E->getNumAssocs(); I != N; ++I) {
768 E->AssocTypes[I] = GetTypeSourceInfo(Record, Idx);
769 E->SubExprs[GenericSelectionExpr::END_EXPR+I] = Reader.ReadSubExpr();
770 }
771 E->ResultIndex = Record[Idx++];
772
773 E->GenericLoc = ReadSourceLocation(Record, Idx);
774 E->DefaultLoc = ReadSourceLocation(Record, Idx);
775 E->RParenLoc = ReadSourceLocation(Record, Idx);
776}
777
Eli Friedmandf14b3a2011-10-11 02:20:01 +0000778void ASTStmtReader::VisitAtomicExpr(AtomicExpr *E) {
779 VisitExpr(E);
780 E->setOp(AtomicExpr::AtomicOp(Record[Idx++]));
781 E->setPtr(Reader.ReadSubExpr());
782 E->setOrder(Reader.ReadSubExpr());
783 E->setNumSubExprs(2);
784 if (E->getOp() != AtomicExpr::Load) {
785 E->setVal1(Reader.ReadSubExpr());
786 E->setNumSubExprs(3);
787 }
788 if (E->isCmpXChg()) {
789 E->setOrderFail(Reader.ReadSubExpr());
790 E->setVal2(Reader.ReadSubExpr());
791 E->setNumSubExprs(5);
792 }
793 E->setBuiltinLoc(ReadSourceLocation(Record, Idx));
794 E->setRParenLoc(ReadSourceLocation(Record, Idx));
795}
796
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000797//===----------------------------------------------------------------------===//
798// Objective-C Expressions and Statements
799
Sebastian Redl70c751d2010-08-18 23:56:52 +0000800void ASTStmtReader::VisitObjCStringLiteral(ObjCStringLiteral *E) {
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000801 VisitExpr(E);
Argyrios Kyrtzidis26d72012010-06-29 22:46:25 +0000802 E->setString(cast<StringLiteral>(Reader.ReadSubStmt()));
Sebastian Redl2c373b92010-10-05 15:59:54 +0000803 E->setAtLoc(ReadSourceLocation(Record, Idx));
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000804}
805
Sebastian Redl70c751d2010-08-18 23:56:52 +0000806void ASTStmtReader::VisitObjCEncodeExpr(ObjCEncodeExpr *E) {
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000807 VisitExpr(E);
Sebastian Redl2c373b92010-10-05 15:59:54 +0000808 E->setEncodedTypeSourceInfo(GetTypeSourceInfo(Record, Idx));
809 E->setAtLoc(ReadSourceLocation(Record, Idx));
810 E->setRParenLoc(ReadSourceLocation(Record, Idx));
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000811}
812
Sebastian Redl70c751d2010-08-18 23:56:52 +0000813void ASTStmtReader::VisitObjCSelectorExpr(ObjCSelectorExpr *E) {
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000814 VisitExpr(E);
Douglas Gregor074fdc52011-07-28 21:16:51 +0000815 E->setSelector(Reader.ReadSelector(F, Record, Idx));
Sebastian Redl2c373b92010-10-05 15:59:54 +0000816 E->setAtLoc(ReadSourceLocation(Record, Idx));
817 E->setRParenLoc(ReadSourceLocation(Record, Idx));
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000818}
819
Sebastian Redl70c751d2010-08-18 23:56:52 +0000820void ASTStmtReader::VisitObjCProtocolExpr(ObjCProtocolExpr *E) {
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000821 VisitExpr(E);
Douglas Gregor7fb09192011-07-21 22:35:25 +0000822 E->setProtocol(ReadDeclAs<ObjCProtocolDecl>(Record, Idx));
Sebastian Redl2c373b92010-10-05 15:59:54 +0000823 E->setAtLoc(ReadSourceLocation(Record, Idx));
824 E->setRParenLoc(ReadSourceLocation(Record, Idx));
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000825}
826
Sebastian Redl70c751d2010-08-18 23:56:52 +0000827void ASTStmtReader::VisitObjCIvarRefExpr(ObjCIvarRefExpr *E) {
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000828 VisitExpr(E);
Douglas Gregor7fb09192011-07-21 22:35:25 +0000829 E->setDecl(ReadDeclAs<ObjCIvarDecl>(Record, Idx));
Sebastian Redl2c373b92010-10-05 15:59:54 +0000830 E->setLocation(ReadSourceLocation(Record, Idx));
Argyrios Kyrtzidis26d72012010-06-29 22:46:25 +0000831 E->setBase(Reader.ReadSubExpr());
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000832 E->setIsArrow(Record[Idx++]);
833 E->setIsFreeIvar(Record[Idx++]);
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000834}
835
Sebastian Redl70c751d2010-08-18 23:56:52 +0000836void ASTStmtReader::VisitObjCPropertyRefExpr(ObjCPropertyRefExpr *E) {
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000837 VisitExpr(E);
John McCallb7bd14f2010-12-02 01:19:52 +0000838 bool Implicit = Record[Idx++] != 0;
839 if (Implicit) {
Douglas Gregor7fb09192011-07-21 22:35:25 +0000840 ObjCMethodDecl *Getter = ReadDeclAs<ObjCMethodDecl>(Record, Idx);
841 ObjCMethodDecl *Setter = ReadDeclAs<ObjCMethodDecl>(Record, Idx);
John McCallb7bd14f2010-12-02 01:19:52 +0000842 E->setImplicitProperty(Getter, Setter);
843 } else {
Douglas Gregor7fb09192011-07-21 22:35:25 +0000844 E->setExplicitProperty(ReadDeclAs<ObjCPropertyDecl>(Record, Idx));
Fariborz Jahanian681c0752010-10-14 16:04:05 +0000845 }
Sebastian Redl2c373b92010-10-05 15:59:54 +0000846 E->setLocation(ReadSourceLocation(Record, Idx));
John McCallb7bd14f2010-12-02 01:19:52 +0000847 E->setReceiverLocation(ReadSourceLocation(Record, Idx));
848 switch (Record[Idx++]) {
849 case 0:
850 E->setBase(Reader.ReadSubExpr());
851 break;
852 case 1:
Douglas Gregor903b7e92011-07-22 00:38:23 +0000853 E->setSuperReceiver(Reader.readType(F, Record, Idx));
John McCallb7bd14f2010-12-02 01:19:52 +0000854 break;
855 case 2:
Douglas Gregor7fb09192011-07-21 22:35:25 +0000856 E->setClassReceiver(ReadDeclAs<ObjCInterfaceDecl>(Record, Idx));
John McCallb7bd14f2010-12-02 01:19:52 +0000857 break;
858 }
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000859}
860
Sebastian Redl70c751d2010-08-18 23:56:52 +0000861void ASTStmtReader::VisitObjCMessageExpr(ObjCMessageExpr *E) {
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000862 VisitExpr(E);
Douglas Gregor9a129192010-04-21 00:45:42 +0000863 assert(Record[Idx] == E->getNumArgs());
864 ++Idx;
Argyrios Kyrtzidisa6011e22011-10-03 06:36:51 +0000865 unsigned NumStoredSelLocs = Record[Idx++];
866 E->SelLocsKind = Record[Idx++];
John McCall31168b02011-06-15 23:02:42 +0000867 E->setDelegateInitCall(Record[Idx++]);
Douglas Gregor9a129192010-04-21 00:45:42 +0000868 ObjCMessageExpr::ReceiverKind Kind
869 = static_cast<ObjCMessageExpr::ReceiverKind>(Record[Idx++]);
870 switch (Kind) {
871 case ObjCMessageExpr::Instance:
Argyrios Kyrtzidis26d72012010-06-29 22:46:25 +0000872 E->setInstanceReceiver(Reader.ReadSubExpr());
Douglas Gregor9a129192010-04-21 00:45:42 +0000873 break;
874
875 case ObjCMessageExpr::Class:
Sebastian Redl2c373b92010-10-05 15:59:54 +0000876 E->setClassReceiver(GetTypeSourceInfo(Record, Idx));
Douglas Gregor9a129192010-04-21 00:45:42 +0000877 break;
878
879 case ObjCMessageExpr::SuperClass:
880 case ObjCMessageExpr::SuperInstance: {
Douglas Gregor903b7e92011-07-22 00:38:23 +0000881 QualType T = Reader.readType(F, Record, Idx);
Sebastian Redl2c373b92010-10-05 15:59:54 +0000882 SourceLocation SuperLoc = ReadSourceLocation(Record, Idx);
Douglas Gregor9a129192010-04-21 00:45:42 +0000883 E->setSuper(SuperLoc, T, Kind == ObjCMessageExpr::SuperInstance);
884 break;
885 }
886 }
887
888 assert(Kind == E->getReceiverKind());
889
890 if (Record[Idx++])
Douglas Gregor7fb09192011-07-21 22:35:25 +0000891 E->setMethodDecl(ReadDeclAs<ObjCMethodDecl>(Record, Idx));
Douglas Gregor9a129192010-04-21 00:45:42 +0000892 else
Douglas Gregor074fdc52011-07-28 21:16:51 +0000893 E->setSelector(Reader.ReadSelector(F, Record, Idx));
Douglas Gregor9a129192010-04-21 00:45:42 +0000894
Argyrios Kyrtzidisd0039e52010-12-10 20:08:27 +0000895 E->LBracLoc = ReadSourceLocation(Record, Idx);
896 E->RBracLoc = ReadSourceLocation(Record, Idx);
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000897
898 for (unsigned I = 0, N = E->getNumArgs(); I != N; ++I)
Argyrios Kyrtzidis26d72012010-06-29 22:46:25 +0000899 E->setArg(I, Reader.ReadSubExpr());
Argyrios Kyrtzidisa6011e22011-10-03 06:36:51 +0000900
901 SourceLocation *Locs = E->getStoredSelLocs();
902 for (unsigned I = 0; I != NumStoredSelLocs; ++I)
903 Locs[I] = ReadSourceLocation(Record, Idx);
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000904}
905
Sebastian Redl70c751d2010-08-18 23:56:52 +0000906void ASTStmtReader::VisitObjCForCollectionStmt(ObjCForCollectionStmt *S) {
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000907 VisitStmt(S);
Argyrios Kyrtzidis26d72012010-06-29 22:46:25 +0000908 S->setElement(Reader.ReadSubStmt());
909 S->setCollection(Reader.ReadSubExpr());
910 S->setBody(Reader.ReadSubStmt());
Sebastian Redl2c373b92010-10-05 15:59:54 +0000911 S->setForLoc(ReadSourceLocation(Record, Idx));
912 S->setRParenLoc(ReadSourceLocation(Record, Idx));
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000913}
914
Sebastian Redl70c751d2010-08-18 23:56:52 +0000915void ASTStmtReader::VisitObjCAtCatchStmt(ObjCAtCatchStmt *S) {
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000916 VisitStmt(S);
Argyrios Kyrtzidis26d72012010-06-29 22:46:25 +0000917 S->setCatchBody(Reader.ReadSubStmt());
Douglas Gregor7fb09192011-07-21 22:35:25 +0000918 S->setCatchParamDecl(ReadDeclAs<VarDecl>(Record, Idx));
Sebastian Redl2c373b92010-10-05 15:59:54 +0000919 S->setAtCatchLoc(ReadSourceLocation(Record, Idx));
920 S->setRParenLoc(ReadSourceLocation(Record, Idx));
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000921}
922
Sebastian Redl70c751d2010-08-18 23:56:52 +0000923void ASTStmtReader::VisitObjCAtFinallyStmt(ObjCAtFinallyStmt *S) {
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000924 VisitStmt(S);
Argyrios Kyrtzidis26d72012010-06-29 22:46:25 +0000925 S->setFinallyBody(Reader.ReadSubStmt());
Sebastian Redl2c373b92010-10-05 15:59:54 +0000926 S->setAtFinallyLoc(ReadSourceLocation(Record, Idx));
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000927}
928
John McCall31168b02011-06-15 23:02:42 +0000929void ASTStmtReader::VisitObjCAutoreleasePoolStmt(ObjCAutoreleasePoolStmt *S) {
930 VisitStmt(S);
931 S->setSubStmt(Reader.ReadSubStmt());
932 S->setAtLoc(ReadSourceLocation(Record, Idx));
933}
934
Sebastian Redl70c751d2010-08-18 23:56:52 +0000935void ASTStmtReader::VisitObjCAtTryStmt(ObjCAtTryStmt *S) {
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000936 VisitStmt(S);
Douglas Gregor96c79492010-04-23 22:50:49 +0000937 assert(Record[Idx] == S->getNumCatchStmts());
938 ++Idx;
939 bool HasFinally = Record[Idx++];
Argyrios Kyrtzidis26d72012010-06-29 22:46:25 +0000940 S->setTryBody(Reader.ReadSubStmt());
Argyrios Kyrtzidisd0795b22010-06-28 22:28:35 +0000941 for (unsigned I = 0, N = S->getNumCatchStmts(); I != N; ++I)
Argyrios Kyrtzidis26d72012010-06-29 22:46:25 +0000942 S->setCatchStmt(I, cast_or_null<ObjCAtCatchStmt>(Reader.ReadSubStmt()));
Douglas Gregor96c79492010-04-23 22:50:49 +0000943
Douglas Gregor96c79492010-04-23 22:50:49 +0000944 if (HasFinally)
Argyrios Kyrtzidis26d72012010-06-29 22:46:25 +0000945 S->setFinallyStmt(Reader.ReadSubStmt());
Sebastian Redl2c373b92010-10-05 15:59:54 +0000946 S->setAtTryLoc(ReadSourceLocation(Record, Idx));
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000947}
948
Sebastian Redl70c751d2010-08-18 23:56:52 +0000949void ASTStmtReader::VisitObjCAtSynchronizedStmt(ObjCAtSynchronizedStmt *S) {
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000950 VisitStmt(S);
Argyrios Kyrtzidis26d72012010-06-29 22:46:25 +0000951 S->setSynchExpr(Reader.ReadSubStmt());
952 S->setSynchBody(Reader.ReadSubStmt());
Sebastian Redl2c373b92010-10-05 15:59:54 +0000953 S->setAtSynchronizedLoc(ReadSourceLocation(Record, Idx));
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000954}
955
Sebastian Redl70c751d2010-08-18 23:56:52 +0000956void ASTStmtReader::VisitObjCAtThrowStmt(ObjCAtThrowStmt *S) {
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000957 VisitStmt(S);
Argyrios Kyrtzidis26d72012010-06-29 22:46:25 +0000958 S->setThrowExpr(Reader.ReadSubStmt());
Sebastian Redl2c373b92010-10-05 15:59:54 +0000959 S->setThrowLoc(ReadSourceLocation(Record, Idx));
Chris Lattner92ba5ff2009-04-27 05:14:47 +0000960}
961
Argyrios Kyrtzidiseeaaead2009-07-14 03:19:21 +0000962//===----------------------------------------------------------------------===//
963// C++ Expressions and Statements
Argyrios Kyrtzidis47cd7a92010-07-22 16:03:56 +0000964//===----------------------------------------------------------------------===//
965
Sebastian Redl70c751d2010-08-18 23:56:52 +0000966void ASTStmtReader::VisitCXXCatchStmt(CXXCatchStmt *S) {
Argyrios Kyrtzidis47cd7a92010-07-22 16:03:56 +0000967 VisitStmt(S);
Sebastian Redl2c373b92010-10-05 15:59:54 +0000968 S->CatchLoc = ReadSourceLocation(Record, Idx);
Douglas Gregor7fb09192011-07-21 22:35:25 +0000969 S->ExceptionDecl = ReadDeclAs<VarDecl>(Record, Idx);
Argyrios Kyrtzidis47cd7a92010-07-22 16:03:56 +0000970 S->HandlerBlock = Reader.ReadSubStmt();
971}
972
Sebastian Redl70c751d2010-08-18 23:56:52 +0000973void ASTStmtReader::VisitCXXTryStmt(CXXTryStmt *S) {
Argyrios Kyrtzidis47cd7a92010-07-22 16:03:56 +0000974 VisitStmt(S);
975 assert(Record[Idx] == S->getNumHandlers() && "NumStmtFields is wrong ?");
976 ++Idx;
Sebastian Redl2c373b92010-10-05 15:59:54 +0000977 S->TryLoc = ReadSourceLocation(Record, Idx);
Argyrios Kyrtzidis47cd7a92010-07-22 16:03:56 +0000978 S->getStmts()[0] = Reader.ReadSubStmt();
979 for (unsigned i = 0, e = S->getNumHandlers(); i != e; ++i)
980 S->getStmts()[i + 1] = Reader.ReadSubStmt();
981}
Argyrios Kyrtzidiseeaaead2009-07-14 03:19:21 +0000982
Richard Smith02e85f32011-04-14 22:09:26 +0000983void ASTStmtReader::VisitCXXForRangeStmt(CXXForRangeStmt *S) {
984 VisitStmt(S);
985 S->setForLoc(ReadSourceLocation(Record, Idx));
986 S->setColonLoc(ReadSourceLocation(Record, Idx));
987 S->setRParenLoc(ReadSourceLocation(Record, Idx));
988 S->setRangeStmt(Reader.ReadSubStmt());
989 S->setBeginEndStmt(Reader.ReadSubStmt());
990 S->setCond(Reader.ReadSubExpr());
991 S->setInc(Reader.ReadSubExpr());
992 S->setLoopVarStmt(Reader.ReadSubStmt());
993 S->setBody(Reader.ReadSubStmt());
994}
995
Douglas Gregordeb4a2be2011-10-25 01:33:02 +0000996void ASTStmtReader::VisitMSDependentExistsStmt(MSDependentExistsStmt *S) {
997 VisitStmt(S);
998 S->KeywordLoc = ReadSourceLocation(Record, Idx);
999 S->IsIfExists = Record[Idx++];
1000 S->QualifierLoc = Reader.ReadNestedNameSpecifierLoc(F, Record, Idx);
1001 ReadDeclarationNameInfo(S->NameInfo, Record, Idx);
1002 S->SubStmt = Reader.ReadSubStmt();
1003}
1004
Sebastian Redl70c751d2010-08-18 23:56:52 +00001005void ASTStmtReader::VisitCXXOperatorCallExpr(CXXOperatorCallExpr *E) {
Argyrios Kyrtzidisd0795b22010-06-28 22:28:35 +00001006 VisitCallExpr(E);
Argyrios Kyrtzidiseeaaead2009-07-14 03:19:21 +00001007 E->setOperator((OverloadedOperatorKind)Record[Idx++]);
Argyrios Kyrtzidiseeaaead2009-07-14 03:19:21 +00001008}
1009
Sebastian Redl70c751d2010-08-18 23:56:52 +00001010void ASTStmtReader::VisitCXXConstructExpr(CXXConstructExpr *E) {
Douglas Gregor5d3507d2009-09-09 23:08:42 +00001011 VisitExpr(E);
Argyrios Kyrtzidisb8d77eb2010-07-10 11:46:15 +00001012 E->NumArgs = Record[Idx++];
1013 if (E->NumArgs)
Douglas Gregor4163aca2011-09-09 21:34:22 +00001014 E->Args = new (Reader.getContext()) Stmt*[E->NumArgs];
Argyrios Kyrtzidis30d98f32010-06-24 08:57:09 +00001015 for (unsigned I = 0, N = E->getNumArgs(); I != N; ++I)
Argyrios Kyrtzidis26d72012010-06-29 22:46:25 +00001016 E->setArg(I, Reader.ReadSubExpr());
Douglas Gregor7fb09192011-07-21 22:35:25 +00001017 E->setConstructor(ReadDeclAs<CXXConstructorDecl>(Record, Idx));
Sebastian Redl2c373b92010-10-05 15:59:54 +00001018 E->setLocation(ReadSourceLocation(Record, Idx));
Abramo Bagnara635ed24e2011-10-05 07:56:41 +00001019 E->setElidable(Record[Idx++]);
1020 E->setHadMultipleCandidates(Record[Idx++]);
Douglas Gregor4f4b1862009-12-16 18:50:27 +00001021 E->setRequiresZeroInitialization(Record[Idx++]);
Douglas Gregor222cf0e2010-05-15 00:13:29 +00001022 E->setConstructionKind((CXXConstructExpr::ConstructionKind)Record[Idx++]);
Chandler Carruth01718152010-10-25 08:47:36 +00001023 E->ParenRange = ReadSourceRange(Record, Idx);
Douglas Gregor5d3507d2009-09-09 23:08:42 +00001024}
Chris Lattner92ba5ff2009-04-27 05:14:47 +00001025
Sebastian Redl70c751d2010-08-18 23:56:52 +00001026void ASTStmtReader::VisitCXXTemporaryObjectExpr(CXXTemporaryObjectExpr *E) {
Argyrios Kyrtzidisb8d77eb2010-07-10 11:46:15 +00001027 VisitCXXConstructExpr(E);
Sebastian Redl2c373b92010-10-05 15:59:54 +00001028 E->Type = GetTypeSourceInfo(Record, Idx);
Argyrios Kyrtzidisb8d77eb2010-07-10 11:46:15 +00001029}
1030
Sebastian Redl70c751d2010-08-18 23:56:52 +00001031void ASTStmtReader::VisitCXXNamedCastExpr(CXXNamedCastExpr *E) {
Argyrios Kyrtzidisd0795b22010-06-28 22:28:35 +00001032 VisitExplicitCastExpr(E);
Douglas Gregor4478f852011-01-12 22:41:29 +00001033 SourceRange R = ReadSourceRange(Record, Idx);
1034 E->Loc = R.getBegin();
1035 E->RParenLoc = R.getEnd();
Sam Weinigd01101e2010-01-16 21:21:01 +00001036}
1037
Sebastian Redl70c751d2010-08-18 23:56:52 +00001038void ASTStmtReader::VisitCXXStaticCastExpr(CXXStaticCastExpr *E) {
Sam Weinigd01101e2010-01-16 21:21:01 +00001039 return VisitCXXNamedCastExpr(E);
1040}
1041
Sebastian Redl70c751d2010-08-18 23:56:52 +00001042void ASTStmtReader::VisitCXXDynamicCastExpr(CXXDynamicCastExpr *E) {
Sam Weinigd01101e2010-01-16 21:21:01 +00001043 return VisitCXXNamedCastExpr(E);
1044}
1045
Sebastian Redl70c751d2010-08-18 23:56:52 +00001046void ASTStmtReader::VisitCXXReinterpretCastExpr(CXXReinterpretCastExpr *E) {
Sam Weinigd01101e2010-01-16 21:21:01 +00001047 return VisitCXXNamedCastExpr(E);
1048}
1049
Sebastian Redl70c751d2010-08-18 23:56:52 +00001050void ASTStmtReader::VisitCXXConstCastExpr(CXXConstCastExpr *E) {
Sam Weinigd01101e2010-01-16 21:21:01 +00001051 return VisitCXXNamedCastExpr(E);
1052}
1053
Sebastian Redl70c751d2010-08-18 23:56:52 +00001054void ASTStmtReader::VisitCXXFunctionalCastExpr(CXXFunctionalCastExpr *E) {
Argyrios Kyrtzidisd0795b22010-06-28 22:28:35 +00001055 VisitExplicitCastExpr(E);
Sebastian Redl2c373b92010-10-05 15:59:54 +00001056 E->setTypeBeginLoc(ReadSourceLocation(Record, Idx));
1057 E->setRParenLoc(ReadSourceLocation(Record, Idx));
Sam Weinigd01101e2010-01-16 21:21:01 +00001058}
1059
Sebastian Redl70c751d2010-08-18 23:56:52 +00001060void ASTStmtReader::VisitCXXBoolLiteralExpr(CXXBoolLiteralExpr *E) {
Sam Weinige83b3ac2010-02-07 06:32:43 +00001061 VisitExpr(E);
1062 E->setValue(Record[Idx++]);
Sebastian Redl2c373b92010-10-05 15:59:54 +00001063 E->setLocation(ReadSourceLocation(Record, Idx));
Sam Weinige83b3ac2010-02-07 06:32:43 +00001064}
1065
Sebastian Redl70c751d2010-08-18 23:56:52 +00001066void ASTStmtReader::VisitCXXNullPtrLiteralExpr(CXXNullPtrLiteralExpr *E) {
Sam Weinige83b3ac2010-02-07 06:32:43 +00001067 VisitExpr(E);
Sebastian Redl2c373b92010-10-05 15:59:54 +00001068 E->setLocation(ReadSourceLocation(Record, Idx));
Sam Weinige83b3ac2010-02-07 06:32:43 +00001069}
1070
Sebastian Redl70c751d2010-08-18 23:56:52 +00001071void ASTStmtReader::VisitCXXTypeidExpr(CXXTypeidExpr *E) {
Chris Lattner13a5ecc2010-05-09 06:03:39 +00001072 VisitExpr(E);
Sebastian Redl2c373b92010-10-05 15:59:54 +00001073 E->setSourceRange(ReadSourceRange(Record, Idx));
Chris Lattner13a5ecc2010-05-09 06:03:39 +00001074 if (E->isTypeOperand()) { // typeid(int)
Sebastian Redlc67764e2010-07-22 22:43:28 +00001075 E->setTypeOperandSourceInfo(
Sebastian Redl2c373b92010-10-05 15:59:54 +00001076 GetTypeSourceInfo(Record, Idx));
Argyrios Kyrtzidisd0795b22010-06-28 22:28:35 +00001077 return;
Chris Lattner13a5ecc2010-05-09 06:03:39 +00001078 }
1079
1080 // typeid(42+2)
Argyrios Kyrtzidis26d72012010-06-29 22:46:25 +00001081 E->setExprOperand(Reader.ReadSubExpr());
Chris Lattner13a5ecc2010-05-09 06:03:39 +00001082}
1083
Sebastian Redl70c751d2010-08-18 23:56:52 +00001084void ASTStmtReader::VisitCXXThisExpr(CXXThisExpr *E) {
Chris Lattner98267332010-05-09 06:15:05 +00001085 VisitExpr(E);
Sebastian Redl2c373b92010-10-05 15:59:54 +00001086 E->setLocation(ReadSourceLocation(Record, Idx));
Chris Lattner98267332010-05-09 06:15:05 +00001087 E->setImplicit(Record[Idx++]);
Chris Lattner98267332010-05-09 06:15:05 +00001088}
1089
Sebastian Redl70c751d2010-08-18 23:56:52 +00001090void ASTStmtReader::VisitCXXThrowExpr(CXXThrowExpr *E) {
Chris Lattner98267332010-05-09 06:15:05 +00001091 VisitExpr(E);
Douglas Gregor53e191ed2011-07-06 22:04:06 +00001092 E->ThrowLoc = ReadSourceLocation(Record, Idx);
1093 E->Op = Reader.ReadSubExpr();
1094 E->IsThrownVariableInScope = Record[Idx++];
Chris Lattner98267332010-05-09 06:15:05 +00001095}
Chris Lattner13a5ecc2010-05-09 06:03:39 +00001096
Sebastian Redl70c751d2010-08-18 23:56:52 +00001097void ASTStmtReader::VisitCXXDefaultArgExpr(CXXDefaultArgExpr *E) {
Chris Lattnere2437f42010-05-09 06:40:08 +00001098 VisitExpr(E);
Argyrios Kyrtzidis4259ebc2010-07-02 23:30:15 +00001099
Douglas Gregor27f58c22011-09-23 22:07:41 +00001100 assert((bool)Record[Idx] == E->Param.getInt() && "We messed up at creation ?");
Argyrios Kyrtzidis4259ebc2010-07-02 23:30:15 +00001101 ++Idx; // HasOtherExprStored and SubExpr was handled during creation.
Douglas Gregor7fb09192011-07-21 22:35:25 +00001102 E->Param.setPointer(ReadDeclAs<ParmVarDecl>(Record, Idx));
Sebastian Redl2c373b92010-10-05 15:59:54 +00001103 E->Loc = ReadSourceLocation(Record, Idx);
Chris Lattnercba86142010-05-10 00:25:06 +00001104}
1105
Sebastian Redl70c751d2010-08-18 23:56:52 +00001106void ASTStmtReader::VisitCXXBindTemporaryExpr(CXXBindTemporaryExpr *E) {
Chris Lattnercba86142010-05-10 00:25:06 +00001107 VisitExpr(E);
Douglas Gregor7fb09192011-07-21 22:35:25 +00001108 E->setTemporary(Reader.ReadCXXTemporary(F, Record, Idx));
Argyrios Kyrtzidis26d72012010-06-29 22:46:25 +00001109 E->setSubExpr(Reader.ReadSubExpr());
Chris Lattnercba86142010-05-10 00:25:06 +00001110}
1111
Sebastian Redl70c751d2010-08-18 23:56:52 +00001112void ASTStmtReader::VisitCXXScalarValueInitExpr(CXXScalarValueInitExpr *E) {
Chris Lattnerabfb58d2010-05-10 01:22:27 +00001113 VisitExpr(E);
Sebastian Redl2c373b92010-10-05 15:59:54 +00001114 E->TypeInfo = GetTypeSourceInfo(Record, Idx);
1115 E->RParenLoc = ReadSourceLocation(Record, Idx);
Chris Lattnerabfb58d2010-05-10 01:22:27 +00001116}
1117
Sebastian Redl70c751d2010-08-18 23:56:52 +00001118void ASTStmtReader::VisitCXXNewExpr(CXXNewExpr *E) {
Chris Lattnerabfb58d2010-05-10 01:22:27 +00001119 VisitExpr(E);
John McCall284c48f2011-01-27 09:37:56 +00001120 E->GlobalNew = Record[Idx++];
1121 E->Initializer = Record[Idx++];
1122 E->UsualArrayDeleteWantsSize = Record[Idx++];
Chris Lattnerabfb58d2010-05-10 01:22:27 +00001123 bool isArray = Record[Idx++];
Abramo Bagnara635ed24e2011-10-05 07:56:41 +00001124 E->setHadMultipleCandidates(Record[Idx++]);
Chris Lattnerabfb58d2010-05-10 01:22:27 +00001125 unsigned NumPlacementArgs = Record[Idx++];
1126 unsigned NumCtorArgs = Record[Idx++];
Douglas Gregor7fb09192011-07-21 22:35:25 +00001127 E->setOperatorNew(ReadDeclAs<FunctionDecl>(Record, Idx));
1128 E->setOperatorDelete(ReadDeclAs<FunctionDecl>(Record, Idx));
1129 E->setConstructor(ReadDeclAs<CXXConstructorDecl>(Record, Idx));
Sebastian Redl2c373b92010-10-05 15:59:54 +00001130 E->AllocatedTypeInfo = GetTypeSourceInfo(Record, Idx);
Douglas Gregorf2753b32010-07-13 15:54:32 +00001131 SourceRange TypeIdParens;
Sebastian Redl2c373b92010-10-05 15:59:54 +00001132 TypeIdParens.setBegin(ReadSourceLocation(Record, Idx));
1133 TypeIdParens.setEnd(ReadSourceLocation(Record, Idx));
Douglas Gregorf2753b32010-07-13 15:54:32 +00001134 E->TypeIdParens = TypeIdParens;
Chandler Carruth01718152010-10-25 08:47:36 +00001135 E->StartLoc = ReadSourceLocation(Record, Idx);
1136 E->EndLoc = ReadSourceLocation(Record, Idx);
1137 E->ConstructorLParen = ReadSourceLocation(Record, Idx);
1138 E->ConstructorRParen = ReadSourceLocation(Record, Idx);
1139
Douglas Gregor4163aca2011-09-09 21:34:22 +00001140 E->AllocateArgsArray(Reader.getContext(), isArray, NumPlacementArgs,
Chris Lattnerabfb58d2010-05-10 01:22:27 +00001141 NumCtorArgs);
1142
1143 // Install all the subexpressions.
Chris Lattnerabfb58d2010-05-10 01:22:27 +00001144 for (CXXNewExpr::raw_arg_iterator I = E->raw_arg_begin(),e = E->raw_arg_end();
1145 I != e; ++I)
Argyrios Kyrtzidis26d72012010-06-29 22:46:25 +00001146 *I = Reader.ReadSubStmt();
Chris Lattnerabfb58d2010-05-10 01:22:27 +00001147}
1148
Sebastian Redl70c751d2010-08-18 23:56:52 +00001149void ASTStmtReader::VisitCXXDeleteExpr(CXXDeleteExpr *E) {
Argyrios Kyrtzidis6e57c352010-06-22 17:07:59 +00001150 VisitExpr(E);
Argyrios Kyrtzidis9b0d1cf2010-09-13 20:15:40 +00001151 E->GlobalDelete = Record[Idx++];
1152 E->ArrayForm = Record[Idx++];
Argyrios Kyrtzidis14ec9f62010-09-13 20:15:54 +00001153 E->ArrayFormAsWritten = Record[Idx++];
John McCall284c48f2011-01-27 09:37:56 +00001154 E->UsualArrayDeleteWantsSize = Record[Idx++];
Douglas Gregor7fb09192011-07-21 22:35:25 +00001155 E->OperatorDelete = ReadDeclAs<FunctionDecl>(Record, Idx);
Argyrios Kyrtzidis9b0d1cf2010-09-13 20:15:40 +00001156 E->Argument = Reader.ReadSubExpr();
Sebastian Redl2c373b92010-10-05 15:59:54 +00001157 E->Loc = ReadSourceLocation(Record, Idx);
Argyrios Kyrtzidis6e57c352010-06-22 17:07:59 +00001158}
Chris Lattnercba86142010-05-10 00:25:06 +00001159
Sebastian Redl70c751d2010-08-18 23:56:52 +00001160void ASTStmtReader::VisitCXXPseudoDestructorExpr(CXXPseudoDestructorExpr *E) {
Argyrios Kyrtzidis99a226d2010-06-28 09:32:03 +00001161 VisitExpr(E);
1162
Douglas Gregora6ce6082011-02-25 18:19:59 +00001163 E->Base = Reader.ReadSubExpr();
1164 E->IsArrow = Record[Idx++];
1165 E->OperatorLoc = ReadSourceLocation(Record, Idx);
1166 E->QualifierLoc = Reader.ReadNestedNameSpecifierLoc(F, Record, Idx);
1167 E->ScopeType = GetTypeSourceInfo(Record, Idx);
1168 E->ColonColonLoc = ReadSourceLocation(Record, Idx);
1169 E->TildeLoc = ReadSourceLocation(Record, Idx);
Argyrios Kyrtzidis99a226d2010-06-28 09:32:03 +00001170
Douglas Gregora3e41532011-07-28 20:55:49 +00001171 IdentifierInfo *II = Reader.GetIdentifierInfo(F, Record, Idx);
Argyrios Kyrtzidis99a226d2010-06-28 09:32:03 +00001172 if (II)
Sebastian Redl2c373b92010-10-05 15:59:54 +00001173 E->setDestroyedType(II, ReadSourceLocation(Record, Idx));
Argyrios Kyrtzidis99a226d2010-06-28 09:32:03 +00001174 else
Sebastian Redl2c373b92010-10-05 15:59:54 +00001175 E->setDestroyedType(GetTypeSourceInfo(Record, Idx));
Argyrios Kyrtzidis99a226d2010-06-28 09:32:03 +00001176}
1177
John McCall5d413782010-12-06 08:20:24 +00001178void ASTStmtReader::VisitExprWithCleanups(ExprWithCleanups *E) {
Chris Lattnercba86142010-05-10 00:25:06 +00001179 VisitExpr(E);
1180 unsigned NumTemps = Record[Idx++];
1181 if (NumTemps) {
Douglas Gregor4163aca2011-09-09 21:34:22 +00001182 E->setNumTemporaries(Reader.getContext(), NumTemps);
Chris Lattnercba86142010-05-10 00:25:06 +00001183 for (unsigned i = 0; i != NumTemps; ++i)
Douglas Gregor7fb09192011-07-21 22:35:25 +00001184 E->setTemporary(i, Reader.ReadCXXTemporary(F, Record, Idx));
Chris Lattnercba86142010-05-10 00:25:06 +00001185 }
Argyrios Kyrtzidis26d72012010-06-29 22:46:25 +00001186 E->setSubExpr(Reader.ReadSubExpr());
Chris Lattnere2437f42010-05-09 06:40:08 +00001187}
1188
Argyrios Kyrtzidisd0795b22010-06-28 22:28:35 +00001189void
Sebastian Redl70c751d2010-08-18 23:56:52 +00001190ASTStmtReader::VisitCXXDependentScopeMemberExpr(CXXDependentScopeMemberExpr *E){
Argyrios Kyrtzidisbfcacee2010-06-24 08:57:31 +00001191 VisitExpr(E);
1192
Douglas Gregor87866ce2011-02-04 12:01:24 +00001193 if (Record[Idx++])
John McCallb3774b52010-08-19 23:49:38 +00001194 ReadExplicitTemplateArgumentList(E->getExplicitTemplateArgs(),
Douglas Gregor87866ce2011-02-04 12:01:24 +00001195 Record[Idx++]);
Argyrios Kyrtzidisbfcacee2010-06-24 08:57:31 +00001196
Douglas Gregore16af532011-02-28 18:50:33 +00001197 E->Base = Reader.ReadSubExpr();
Douglas Gregor903b7e92011-07-22 00:38:23 +00001198 E->BaseType = Reader.readType(F, Record, Idx);
Douglas Gregore16af532011-02-28 18:50:33 +00001199 E->IsArrow = Record[Idx++];
1200 E->OperatorLoc = ReadSourceLocation(Record, Idx);
1201 E->QualifierLoc = Reader.ReadNestedNameSpecifierLoc(F, Record, Idx);
Douglas Gregor7fb09192011-07-21 22:35:25 +00001202 E->FirstQualifierFoundInScope = ReadDeclAs<NamedDecl>(Record, Idx);
Argyrios Kyrtzidis434383d2010-10-15 18:21:24 +00001203 ReadDeclarationNameInfo(E->MemberNameInfo, Record, Idx);
Argyrios Kyrtzidisbfcacee2010-06-24 08:57:31 +00001204}
1205
Argyrios Kyrtzidisd0795b22010-06-28 22:28:35 +00001206void
Sebastian Redl70c751d2010-08-18 23:56:52 +00001207ASTStmtReader::VisitDependentScopeDeclRefExpr(DependentScopeDeclRefExpr *E) {
Argyrios Kyrtzidiscd444d1a2010-06-28 09:31:56 +00001208 VisitExpr(E);
Argyrios Kyrtzidiscd444d1a2010-06-28 09:31:56 +00001209
Douglas Gregor87866ce2011-02-04 12:01:24 +00001210 if (Record[Idx++])
1211 ReadExplicitTemplateArgumentList(E->getExplicitTemplateArgs(),
1212 Record[Idx++]);
Douglas Gregor3a43fd62011-02-25 20:49:16 +00001213
1214 E->QualifierLoc = Reader.ReadNestedNameSpecifierLoc(F, Record, Idx);
Argyrios Kyrtzidis434383d2010-10-15 18:21:24 +00001215 ReadDeclarationNameInfo(E->NameInfo, Record, Idx);
Argyrios Kyrtzidiscd444d1a2010-06-28 09:31:56 +00001216}
1217
Argyrios Kyrtzidisd0795b22010-06-28 22:28:35 +00001218void
Sebastian Redl70c751d2010-08-18 23:56:52 +00001219ASTStmtReader::VisitCXXUnresolvedConstructExpr(CXXUnresolvedConstructExpr *E) {
Argyrios Kyrtzidisbfcacee2010-06-24 08:57:31 +00001220 VisitExpr(E);
1221 assert(Record[Idx] == E->arg_size() && "Read wrong record during creation ?");
1222 ++Idx; // NumArgs;
1223 for (unsigned I = 0, N = E->arg_size(); I != N; ++I)
Argyrios Kyrtzidis26d72012010-06-29 22:46:25 +00001224 E->setArg(I, Reader.ReadSubExpr());
Sebastian Redl2c373b92010-10-05 15:59:54 +00001225 E->Type = GetTypeSourceInfo(Record, Idx);
1226 E->setLParenLoc(ReadSourceLocation(Record, Idx));
1227 E->setRParenLoc(ReadSourceLocation(Record, Idx));
Argyrios Kyrtzidisbfcacee2010-06-24 08:57:31 +00001228}
1229
Sebastian Redl70c751d2010-08-18 23:56:52 +00001230void ASTStmtReader::VisitOverloadExpr(OverloadExpr *E) {
Argyrios Kyrtzidisb8d3c632010-06-25 09:03:26 +00001231 VisitExpr(E);
1232
Douglas Gregor87866ce2011-02-04 12:01:24 +00001233 // Read the explicit template argument list, if available.
1234 if (Record[Idx++])
Argyrios Kyrtzidisd0795b22010-06-28 22:28:35 +00001235 ReadExplicitTemplateArgumentList(E->getExplicitTemplateArgs(),
Douglas Gregor87866ce2011-02-04 12:01:24 +00001236 Record[Idx++]);
Argyrios Kyrtzidisb8d3c632010-06-25 09:03:26 +00001237
1238 unsigned NumDecls = Record[Idx++];
1239 UnresolvedSet<8> Decls;
1240 for (unsigned i = 0; i != NumDecls; ++i) {
Douglas Gregor7fb09192011-07-21 22:35:25 +00001241 NamedDecl *D = ReadDeclAs<NamedDecl>(Record, Idx);
Argyrios Kyrtzidisb8d3c632010-06-25 09:03:26 +00001242 AccessSpecifier AS = (AccessSpecifier)Record[Idx++];
1243 Decls.addDecl(D, AS);
1244 }
Douglas Gregor4163aca2011-09-09 21:34:22 +00001245 E->initializeResults(Reader.getContext(), Decls.begin(), Decls.end());
Argyrios Kyrtzidisb8d3c632010-06-25 09:03:26 +00001246
Argyrios Kyrtzidis434383d2010-10-15 18:21:24 +00001247 ReadDeclarationNameInfo(E->NameInfo, Record, Idx);
Douglas Gregor0da1d432011-02-28 20:01:57 +00001248 E->QualifierLoc = Reader.ReadNestedNameSpecifierLoc(F, Record, Idx);
Argyrios Kyrtzidisb8d3c632010-06-25 09:03:26 +00001249}
1250
Sebastian Redl70c751d2010-08-18 23:56:52 +00001251void ASTStmtReader::VisitUnresolvedMemberExpr(UnresolvedMemberExpr *E) {
Argyrios Kyrtzidisd0795b22010-06-28 22:28:35 +00001252 VisitOverloadExpr(E);
Douglas Gregor0da1d432011-02-28 20:01:57 +00001253 E->IsArrow = Record[Idx++];
1254 E->HasUnresolvedUsing = Record[Idx++];
1255 E->Base = Reader.ReadSubExpr();
Douglas Gregor903b7e92011-07-22 00:38:23 +00001256 E->BaseType = Reader.readType(F, Record, Idx);
Douglas Gregor0da1d432011-02-28 20:01:57 +00001257 E->OperatorLoc = ReadSourceLocation(Record, Idx);
Argyrios Kyrtzidisb8d3c632010-06-25 09:03:26 +00001258}
1259
Sebastian Redl70c751d2010-08-18 23:56:52 +00001260void ASTStmtReader::VisitUnresolvedLookupExpr(UnresolvedLookupExpr *E) {
Argyrios Kyrtzidisd0795b22010-06-28 22:28:35 +00001261 VisitOverloadExpr(E);
Douglas Gregor0da1d432011-02-28 20:01:57 +00001262 E->RequiresADL = Record[Idx++];
Richard Smith02e85f32011-04-14 22:09:26 +00001263 if (E->RequiresADL)
1264 E->StdIsAssociatedNamespace = Record[Idx++];
Douglas Gregor0da1d432011-02-28 20:01:57 +00001265 E->Overloaded = Record[Idx++];
Douglas Gregor7fb09192011-07-21 22:35:25 +00001266 E->NamingClass = ReadDeclAs<CXXRecordDecl>(Record, Idx);
Argyrios Kyrtzidis58e01ad2010-06-25 09:03:34 +00001267}
1268
Sebastian Redl70c751d2010-08-18 23:56:52 +00001269void ASTStmtReader::VisitUnaryTypeTraitExpr(UnaryTypeTraitExpr *E) {
Argyrios Kyrtzidisb8d77eb2010-07-10 11:46:15 +00001270 VisitExpr(E);
1271 E->UTT = (UnaryTypeTrait)Record[Idx++];
Sebastian Redl8eb06f12010-09-13 20:56:31 +00001272 E->Value = (bool)Record[Idx++];
Sebastian Redl2c373b92010-10-05 15:59:54 +00001273 SourceRange Range = ReadSourceRange(Record, Idx);
Argyrios Kyrtzidisb8d77eb2010-07-10 11:46:15 +00001274 E->Loc = Range.getBegin();
1275 E->RParen = Range.getEnd();
Sebastian Redl2c373b92010-10-05 15:59:54 +00001276 E->QueriedType = GetTypeSourceInfo(Record, Idx);
Argyrios Kyrtzidisb8d77eb2010-07-10 11:46:15 +00001277}
1278
Francois Pichet9dfa3ce2010-12-07 00:08:36 +00001279void ASTStmtReader::VisitBinaryTypeTraitExpr(BinaryTypeTraitExpr *E) {
1280 VisitExpr(E);
1281 E->BTT = (BinaryTypeTrait)Record[Idx++];
1282 E->Value = (bool)Record[Idx++];
1283 SourceRange Range = ReadSourceRange(Record, Idx);
1284 E->Loc = Range.getBegin();
1285 E->RParen = Range.getEnd();
1286 E->LhsType = GetTypeSourceInfo(Record, Idx);
1287 E->RhsType = GetTypeSourceInfo(Record, Idx);
1288}
1289
John Wiegley6242b6a2011-04-28 00:16:57 +00001290void ASTStmtReader::VisitArrayTypeTraitExpr(ArrayTypeTraitExpr *E) {
1291 VisitExpr(E);
1292 E->ATT = (ArrayTypeTrait)Record[Idx++];
1293 E->Value = (unsigned int)Record[Idx++];
1294 SourceRange Range = ReadSourceRange(Record, Idx);
1295 E->Loc = Range.getBegin();
1296 E->RParen = Range.getEnd();
1297 E->QueriedType = GetTypeSourceInfo(Record, Idx);
1298}
1299
John Wiegleyf9f65842011-04-25 06:54:41 +00001300void ASTStmtReader::VisitExpressionTraitExpr(ExpressionTraitExpr *E) {
1301 VisitExpr(E);
1302 E->ET = (ExpressionTrait)Record[Idx++];
1303 E->Value = (bool)Record[Idx++];
1304 SourceRange Range = ReadSourceRange(Record, Idx);
1305 E->QueriedExpression = Reader.ReadSubExpr();
1306 E->Loc = Range.getBegin();
1307 E->RParen = Range.getEnd();
1308}
1309
Sebastian Redl9ac55dd2010-09-10 20:55:54 +00001310void ASTStmtReader::VisitCXXNoexceptExpr(CXXNoexceptExpr *E) {
1311 VisitExpr(E);
Sebastian Redlb8a76c42010-09-10 22:34:40 +00001312 E->Value = (bool)Record[Idx++];
Sebastian Redl2c373b92010-10-05 15:59:54 +00001313 E->Range = ReadSourceRange(Record, Idx);
Sebastian Redlb8a76c42010-09-10 22:34:40 +00001314 E->Operand = Reader.ReadSubExpr();
Sebastian Redl9ac55dd2010-09-10 20:55:54 +00001315}
1316
Douglas Gregore8e9dd62011-01-03 17:17:50 +00001317void ASTStmtReader::VisitPackExpansionExpr(PackExpansionExpr *E) {
1318 VisitExpr(E);
1319 E->EllipsisLoc = ReadSourceLocation(Record, Idx);
Douglas Gregorb8840002011-01-14 21:20:45 +00001320 E->NumExpansions = Record[Idx++];
Douglas Gregore8e9dd62011-01-03 17:17:50 +00001321 E->Pattern = Reader.ReadSubExpr();
1322}
1323
Douglas Gregor820ba7b2011-01-04 17:33:58 +00001324void ASTStmtReader::VisitSizeOfPackExpr(SizeOfPackExpr *E) {
1325 VisitExpr(E);
1326 E->OperatorLoc = ReadSourceLocation(Record, Idx);
1327 E->PackLoc = ReadSourceLocation(Record, Idx);
1328 E->RParenLoc = ReadSourceLocation(Record, Idx);
1329 E->Length = Record[Idx++];
Douglas Gregor7fb09192011-07-21 22:35:25 +00001330 E->Pack = ReadDeclAs<NamedDecl>(Record, Idx);
Douglas Gregor820ba7b2011-01-04 17:33:58 +00001331}
1332
John McCallfa194042011-07-15 07:00:14 +00001333void ASTStmtReader::VisitSubstNonTypeTemplateParmExpr(
1334 SubstNonTypeTemplateParmExpr *E) {
1335 VisitExpr(E);
Douglas Gregor7fb09192011-07-21 22:35:25 +00001336 E->Param = ReadDeclAs<NonTypeTemplateParmDecl>(Record, Idx);
John McCallfa194042011-07-15 07:00:14 +00001337 E->NameLoc = ReadSourceLocation(Record, Idx);
1338 E->Replacement = Reader.ReadSubExpr();
1339}
1340
Douglas Gregorcdbc5392011-01-15 01:15:58 +00001341void ASTStmtReader::VisitSubstNonTypeTemplateParmPackExpr(
1342 SubstNonTypeTemplateParmPackExpr *E) {
1343 VisitExpr(E);
Douglas Gregor7fb09192011-07-21 22:35:25 +00001344 E->Param = ReadDeclAs<NonTypeTemplateParmDecl>(Record, Idx);
Douglas Gregorcdbc5392011-01-15 01:15:58 +00001345 TemplateArgument ArgPack = Reader.ReadTemplateArgument(F, Record, Idx);
1346 if (ArgPack.getKind() != TemplateArgument::Pack)
1347 return;
1348
1349 E->Arguments = ArgPack.pack_begin();
1350 E->NumArguments = ArgPack.pack_size();
1351 E->NameLoc = ReadSourceLocation(Record, Idx);
1352}
1353
Douglas Gregorfe314812011-06-21 17:03:29 +00001354void ASTStmtReader::VisitMaterializeTemporaryExpr(MaterializeTemporaryExpr *E) {
1355 VisitExpr(E);
1356 E->Temporary = Reader.ReadSubExpr();
1357}
1358
John McCall8d69a212010-11-15 23:31:06 +00001359void ASTStmtReader::VisitOpaqueValueExpr(OpaqueValueExpr *E) {
1360 VisitExpr(E);
John McCallc07a0c72011-02-17 10:25:35 +00001361 Idx++; // skip ID
Douglas Gregorc03a1082011-01-28 02:26:04 +00001362 E->Loc = ReadSourceLocation(Record, Idx);
John McCall8d69a212010-11-15 23:31:06 +00001363}
1364
Peter Collingbourne41f85462011-02-09 21:07:24 +00001365//===----------------------------------------------------------------------===//
John McCallfa194042011-07-15 07:00:14 +00001366// Microsoft Expressions and Statements
1367//===----------------------------------------------------------------------===//
1368void ASTStmtReader::VisitCXXUuidofExpr(CXXUuidofExpr *E) {
1369 VisitExpr(E);
1370 E->setSourceRange(ReadSourceRange(Record, Idx));
1371 if (E->isTypeOperand()) { // __uuidof(ComType)
1372 E->setTypeOperandSourceInfo(
1373 GetTypeSourceInfo(Record, Idx));
1374 return;
1375 }
1376
1377 // __uuidof(expr)
1378 E->setExprOperand(Reader.ReadSubExpr());
1379}
1380
1381void ASTStmtReader::VisitSEHExceptStmt(SEHExceptStmt *S) {
1382 VisitStmt(S);
1383 S->Loc = ReadSourceLocation(Record, Idx);
1384 S->Children[SEHExceptStmt::FILTER_EXPR] = Reader.ReadSubStmt();
1385 S->Children[SEHExceptStmt::BLOCK] = Reader.ReadSubStmt();
1386}
1387
1388void ASTStmtReader::VisitSEHFinallyStmt(SEHFinallyStmt *S) {
1389 VisitStmt(S);
1390 S->Loc = ReadSourceLocation(Record, Idx);
1391 S->Block = Reader.ReadSubStmt();
1392}
1393
1394void ASTStmtReader::VisitSEHTryStmt(SEHTryStmt *S) {
1395 VisitStmt(S);
1396 S->IsCXXTry = Record[Idx++];
1397 S->TryLoc = ReadSourceLocation(Record, Idx);
1398 S->Children[SEHTryStmt::TRY] = Reader.ReadSubStmt();
1399 S->Children[SEHTryStmt::HANDLER] = Reader.ReadSubStmt();
1400}
1401
1402//===----------------------------------------------------------------------===//
Peter Collingbourne41f85462011-02-09 21:07:24 +00001403// CUDA Expressions and Statements
1404//===----------------------------------------------------------------------===//
1405
1406void ASTStmtReader::VisitCUDAKernelCallExpr(CUDAKernelCallExpr *E) {
1407 VisitCallExpr(E);
1408 E->setConfig(cast<CallExpr>(Reader.ReadSubExpr()));
1409}
1410
John McCallfa194042011-07-15 07:00:14 +00001411//===----------------------------------------------------------------------===//
1412// OpenCL Expressions and Statements.
1413//===----------------------------------------------------------------------===//
1414void ASTStmtReader::VisitAsTypeExpr(AsTypeExpr *E) {
1415 VisitExpr(E);
1416 E->BuiltinLoc = ReadSourceLocation(Record, Idx);
1417 E->RParenLoc = ReadSourceLocation(Record, Idx);
1418 E->SrcExpr = Reader.ReadSubExpr();
1419}
1420
1421//===----------------------------------------------------------------------===//
1422// ASTReader Implementation
1423//===----------------------------------------------------------------------===//
1424
Douglas Gregora6895d82011-07-22 16:00:58 +00001425Stmt *ASTReader::ReadStmt(Module &F) {
Argyrios Kyrtzidisd0795b22010-06-28 22:28:35 +00001426 switch (ReadingKind) {
1427 case Read_Decl:
1428 case Read_Type:
Sebastian Redl2c373b92010-10-05 15:59:54 +00001429 return ReadStmtFromStream(F);
Argyrios Kyrtzidisd0795b22010-06-28 22:28:35 +00001430 case Read_Stmt:
Argyrios Kyrtzidis26d72012010-06-29 22:46:25 +00001431 return ReadSubStmt();
Argyrios Kyrtzidisd0795b22010-06-28 22:28:35 +00001432 }
1433
1434 llvm_unreachable("ReadingKind not set ?");
1435 return 0;
1436}
1437
Douglas Gregora6895d82011-07-22 16:00:58 +00001438Expr *ASTReader::ReadExpr(Module &F) {
Sebastian Redl2c373b92010-10-05 15:59:54 +00001439 return cast_or_null<Expr>(ReadStmt(F));
Argyrios Kyrtzidisd0795b22010-06-28 22:28:35 +00001440}
Chris Lattnere2437f42010-05-09 06:40:08 +00001441
Sebastian Redl2c499f62010-08-18 23:56:43 +00001442Expr *ASTReader::ReadSubExpr() {
Argyrios Kyrtzidis26d72012010-06-29 22:46:25 +00001443 return cast_or_null<Expr>(ReadSubStmt());
1444}
1445
Chris Lattnerf4262532009-04-27 05:41:06 +00001446// Within the bitstream, expressions are stored in Reverse Polish
1447// Notation, with each of the subexpressions preceding the
Argyrios Kyrtzidisd0795b22010-06-28 22:28:35 +00001448// expression they are stored in. Subexpressions are stored from last to first.
1449// To evaluate expressions, we continue reading expressions and placing them on
1450// the stack, with expressions having operands removing those operands from the
Chris Lattnerf4262532009-04-27 05:41:06 +00001451// stack. Evaluation terminates when we see a STMT_STOP record, and
1452// the single remaining expression on the stack is our result.
Douglas Gregora6895d82011-07-22 16:00:58 +00001453Stmt *ASTReader::ReadStmtFromStream(Module &F) {
Argyrios Kyrtzidisd0795b22010-06-28 22:28:35 +00001454
1455 ReadingKindTracker ReadingKind(Read_Stmt, *this);
Sebastian Redl2c373b92010-10-05 15:59:54 +00001456 llvm::BitstreamCursor &Cursor = F.DeclsCursor;
Argyrios Kyrtzidis6a598972011-10-21 23:02:28 +00001457
1458 // Map of offset to previously deserialized stmt. The offset points
1459 /// just after the stmt record.
1460 llvm::DenseMap<uint64_t, Stmt *> StmtEntries;
Sebastian Redl2c373b92010-10-05 15:59:54 +00001461
Argyrios Kyrtzidisd0795b22010-06-28 22:28:35 +00001462#ifndef NDEBUG
1463 unsigned PrevNumStmts = StmtStack.size();
1464#endif
1465
Chris Lattner92ba5ff2009-04-27 05:14:47 +00001466 RecordData Record;
1467 unsigned Idx;
Sebastian Redl2c373b92010-10-05 15:59:54 +00001468 ASTStmtReader Reader(*this, F, Cursor, Record, Idx);
Chris Lattner92ba5ff2009-04-27 05:14:47 +00001469 Stmt::EmptyShell Empty;
1470
1471 while (true) {
Chris Lattnerf4262532009-04-27 05:41:06 +00001472 unsigned Code = Cursor.ReadCode();
Chris Lattner92ba5ff2009-04-27 05:14:47 +00001473 if (Code == llvm::bitc::END_BLOCK) {
Chris Lattnerf4262532009-04-27 05:41:06 +00001474 if (Cursor.ReadBlockEnd()) {
Sebastian Redld44cd6a2010-08-18 23:57:06 +00001475 Error("error at end of block in AST file");
Chris Lattner92ba5ff2009-04-27 05:14:47 +00001476 return 0;
1477 }
1478 break;
1479 }
1480
1481 if (Code == llvm::bitc::ENTER_SUBBLOCK) {
1482 // No known subblocks, always skip them.
Chris Lattnerf4262532009-04-27 05:41:06 +00001483 Cursor.ReadSubBlockID();
1484 if (Cursor.SkipBlock()) {
Sebastian Redld44cd6a2010-08-18 23:57:06 +00001485 Error("malformed block record in AST file");
Chris Lattner92ba5ff2009-04-27 05:14:47 +00001486 return 0;
1487 }
1488 continue;
1489 }
1490
1491 if (Code == llvm::bitc::DEFINE_ABBREV) {
Chris Lattnerf4262532009-04-27 05:41:06 +00001492 Cursor.ReadAbbrevRecord();
Chris Lattner92ba5ff2009-04-27 05:14:47 +00001493 continue;
1494 }
1495
1496 Stmt *S = 0;
1497 Idx = 0;
1498 Record.clear();
1499 bool Finished = false;
Argyrios Kyrtzidis6a598972011-10-21 23:02:28 +00001500 bool IsStmtReference = false;
Sebastian Redl539c5062010-08-18 23:57:32 +00001501 switch ((StmtCode)Cursor.ReadRecord(Code, Record)) {
1502 case STMT_STOP:
Chris Lattner92ba5ff2009-04-27 05:14:47 +00001503 Finished = true;
1504 break;
1505
Argyrios Kyrtzidis6a598972011-10-21 23:02:28 +00001506 case STMT_REF_PTR:
1507 IsStmtReference = true;
1508 assert(StmtEntries.find(Record[0]) != StmtEntries.end() &&
1509 "No stmt was recorded for this offset reference!");
1510 S = StmtEntries[Record[Idx++]];
1511 break;
1512
Sebastian Redl539c5062010-08-18 23:57:32 +00001513 case STMT_NULL_PTR:
Mike Stump11289f42009-09-09 15:08:12 +00001514 S = 0;
Chris Lattner92ba5ff2009-04-27 05:14:47 +00001515 break;
1516
Sebastian Redl539c5062010-08-18 23:57:32 +00001517 case STMT_NULL:
Chris Lattner92ba5ff2009-04-27 05:14:47 +00001518 S = new (Context) NullStmt(Empty);
1519 break;
1520
Sebastian Redl539c5062010-08-18 23:57:32 +00001521 case STMT_COMPOUND:
Chris Lattner92ba5ff2009-04-27 05:14:47 +00001522 S = new (Context) CompoundStmt(Empty);
1523 break;
1524
Sebastian Redl539c5062010-08-18 23:57:32 +00001525 case STMT_CASE:
Chris Lattner92ba5ff2009-04-27 05:14:47 +00001526 S = new (Context) CaseStmt(Empty);
1527 break;
1528
Sebastian Redl539c5062010-08-18 23:57:32 +00001529 case STMT_DEFAULT:
Chris Lattner92ba5ff2009-04-27 05:14:47 +00001530 S = new (Context) DefaultStmt(Empty);
1531 break;
1532
Sebastian Redl539c5062010-08-18 23:57:32 +00001533 case STMT_LABEL:
Chris Lattner92ba5ff2009-04-27 05:14:47 +00001534 S = new (Context) LabelStmt(Empty);
1535 break;
1536
Sebastian Redl539c5062010-08-18 23:57:32 +00001537 case STMT_IF:
Chris Lattner92ba5ff2009-04-27 05:14:47 +00001538 S = new (Context) IfStmt(Empty);
1539 break;
1540
Sebastian Redl539c5062010-08-18 23:57:32 +00001541 case STMT_SWITCH:
Chris Lattner92ba5ff2009-04-27 05:14:47 +00001542 S = new (Context) SwitchStmt(Empty);
1543 break;
1544
Sebastian Redl539c5062010-08-18 23:57:32 +00001545 case STMT_WHILE:
Chris Lattner92ba5ff2009-04-27 05:14:47 +00001546 S = new (Context) WhileStmt(Empty);
1547 break;
1548
Sebastian Redl539c5062010-08-18 23:57:32 +00001549 case STMT_DO:
Chris Lattner92ba5ff2009-04-27 05:14:47 +00001550 S = new (Context) DoStmt(Empty);
1551 break;
Mike Stump11289f42009-09-09 15:08:12 +00001552
Sebastian Redl539c5062010-08-18 23:57:32 +00001553 case STMT_FOR:
Chris Lattner92ba5ff2009-04-27 05:14:47 +00001554 S = new (Context) ForStmt(Empty);
1555 break;
1556
Sebastian Redl539c5062010-08-18 23:57:32 +00001557 case STMT_GOTO:
Chris Lattner92ba5ff2009-04-27 05:14:47 +00001558 S = new (Context) GotoStmt(Empty);
1559 break;
Mike Stump11289f42009-09-09 15:08:12 +00001560
Sebastian Redl539c5062010-08-18 23:57:32 +00001561 case STMT_INDIRECT_GOTO:
Chris Lattner92ba5ff2009-04-27 05:14:47 +00001562 S = new (Context) IndirectGotoStmt(Empty);
1563 break;
1564
Sebastian Redl539c5062010-08-18 23:57:32 +00001565 case STMT_CONTINUE:
Chris Lattner92ba5ff2009-04-27 05:14:47 +00001566 S = new (Context) ContinueStmt(Empty);
1567 break;
1568
Sebastian Redl539c5062010-08-18 23:57:32 +00001569 case STMT_BREAK:
Chris Lattner92ba5ff2009-04-27 05:14:47 +00001570 S = new (Context) BreakStmt(Empty);
1571 break;
1572
Sebastian Redl539c5062010-08-18 23:57:32 +00001573 case STMT_RETURN:
Chris Lattner92ba5ff2009-04-27 05:14:47 +00001574 S = new (Context) ReturnStmt(Empty);
1575 break;
1576
Sebastian Redl539c5062010-08-18 23:57:32 +00001577 case STMT_DECL:
Chris Lattner92ba5ff2009-04-27 05:14:47 +00001578 S = new (Context) DeclStmt(Empty);
1579 break;
1580
Sebastian Redl539c5062010-08-18 23:57:32 +00001581 case STMT_ASM:
Chris Lattner92ba5ff2009-04-27 05:14:47 +00001582 S = new (Context) AsmStmt(Empty);
1583 break;
1584
Sebastian Redl539c5062010-08-18 23:57:32 +00001585 case EXPR_PREDEFINED:
Chris Lattner92ba5ff2009-04-27 05:14:47 +00001586 S = new (Context) PredefinedExpr(Empty);
1587 break;
Mike Stump11289f42009-09-09 15:08:12 +00001588
Sebastian Redl539c5062010-08-18 23:57:32 +00001589 case EXPR_DECL_REF:
Chandler Carruth8d26bb02011-05-01 23:48:14 +00001590 S = DeclRefExpr::CreateEmpty(
Douglas Gregor4163aca2011-09-09 21:34:22 +00001591 Context,
Chandler Carruth8d26bb02011-05-01 23:48:14 +00001592 /*HasQualifier=*/Record[ASTStmtReader::NumExprFields],
1593 /*HasFoundDecl=*/Record[ASTStmtReader::NumExprFields + 1],
1594 /*HasExplicitTemplateArgs=*/Record[ASTStmtReader::NumExprFields + 2],
1595 /*NumTemplateArgs=*/Record[ASTStmtReader::NumExprFields + 2] ?
Abramo Bagnara635ed24e2011-10-05 07:56:41 +00001596 Record[ASTStmtReader::NumExprFields + 4] : 0);
Chris Lattner92ba5ff2009-04-27 05:14:47 +00001597 break;
Mike Stump11289f42009-09-09 15:08:12 +00001598
Sebastian Redl539c5062010-08-18 23:57:32 +00001599 case EXPR_INTEGER_LITERAL:
Douglas Gregor4163aca2011-09-09 21:34:22 +00001600 S = IntegerLiteral::Create(Context, Empty);
Chris Lattner92ba5ff2009-04-27 05:14:47 +00001601 break;
Mike Stump11289f42009-09-09 15:08:12 +00001602
Sebastian Redl539c5062010-08-18 23:57:32 +00001603 case EXPR_FLOATING_LITERAL:
Douglas Gregor4163aca2011-09-09 21:34:22 +00001604 S = FloatingLiteral::Create(Context, Empty);
Chris Lattner92ba5ff2009-04-27 05:14:47 +00001605 break;
Mike Stump11289f42009-09-09 15:08:12 +00001606
Sebastian Redl539c5062010-08-18 23:57:32 +00001607 case EXPR_IMAGINARY_LITERAL:
Chris Lattner92ba5ff2009-04-27 05:14:47 +00001608 S = new (Context) ImaginaryLiteral(Empty);
1609 break;
1610
Sebastian Redl539c5062010-08-18 23:57:32 +00001611 case EXPR_STRING_LITERAL:
Douglas Gregor4163aca2011-09-09 21:34:22 +00001612 S = StringLiteral::CreateEmpty(Context,
Sebastian Redl70c751d2010-08-18 23:56:52 +00001613 Record[ASTStmtReader::NumExprFields + 1]);
Chris Lattner92ba5ff2009-04-27 05:14:47 +00001614 break;
1615
Sebastian Redl539c5062010-08-18 23:57:32 +00001616 case EXPR_CHARACTER_LITERAL:
Chris Lattner92ba5ff2009-04-27 05:14:47 +00001617 S = new (Context) CharacterLiteral(Empty);
1618 break;
1619
Sebastian Redl539c5062010-08-18 23:57:32 +00001620 case EXPR_PAREN:
Chris Lattner92ba5ff2009-04-27 05:14:47 +00001621 S = new (Context) ParenExpr(Empty);
1622 break;
1623
Sebastian Redl539c5062010-08-18 23:57:32 +00001624 case EXPR_PAREN_LIST:
Argyrios Kyrtzidisf9f47c82010-06-30 08:49:18 +00001625 S = new (Context) ParenListExpr(Empty);
1626 break;
1627
Sebastian Redl539c5062010-08-18 23:57:32 +00001628 case EXPR_UNARY_OPERATOR:
Chris Lattner92ba5ff2009-04-27 05:14:47 +00001629 S = new (Context) UnaryOperator(Empty);
1630 break;
1631
Sebastian Redl539c5062010-08-18 23:57:32 +00001632 case EXPR_OFFSETOF:
Douglas Gregor4163aca2011-09-09 21:34:22 +00001633 S = OffsetOfExpr::CreateEmpty(Context,
Sebastian Redl70c751d2010-08-18 23:56:52 +00001634 Record[ASTStmtReader::NumExprFields],
1635 Record[ASTStmtReader::NumExprFields + 1]);
Douglas Gregor882211c2010-04-28 22:16:22 +00001636 break;
1637
Sebastian Redl539c5062010-08-18 23:57:32 +00001638 case EXPR_SIZEOF_ALIGN_OF:
Peter Collingbournee190dee2011-03-11 19:24:49 +00001639 S = new (Context) UnaryExprOrTypeTraitExpr(Empty);
Chris Lattner92ba5ff2009-04-27 05:14:47 +00001640 break;
1641
Sebastian Redl539c5062010-08-18 23:57:32 +00001642 case EXPR_ARRAY_SUBSCRIPT:
Chris Lattner92ba5ff2009-04-27 05:14:47 +00001643 S = new (Context) ArraySubscriptExpr(Empty);
1644 break;
1645
Sebastian Redl539c5062010-08-18 23:57:32 +00001646 case EXPR_CALL:
Douglas Gregor4163aca2011-09-09 21:34:22 +00001647 S = new (Context) CallExpr(Context, Stmt::CallExprClass, Empty);
Chris Lattner92ba5ff2009-04-27 05:14:47 +00001648 break;
1649
Sebastian Redl539c5062010-08-18 23:57:32 +00001650 case EXPR_MEMBER: {
Argyrios Kyrtzidis1985bb32010-07-08 13:09:47 +00001651 // We load everything here and fully initialize it at creation.
1652 // That way we can use MemberExpr::Create and don't have to duplicate its
1653 // logic with a MemberExpr::CreateEmpty.
1654
1655 assert(Idx == 0);
Douglas Gregorea972d32011-02-28 21:54:11 +00001656 NestedNameSpecifierLoc QualifierLoc;
Argyrios Kyrtzidis1985bb32010-07-08 13:09:47 +00001657 if (Record[Idx++]) { // HasQualifier.
Douglas Gregorea972d32011-02-28 21:54:11 +00001658 QualifierLoc = ReadNestedNameSpecifierLoc(F, Record, Idx);
Argyrios Kyrtzidis1985bb32010-07-08 13:09:47 +00001659 }
1660
1661 TemplateArgumentListInfo ArgInfo;
Douglas Gregor87866ce2011-02-04 12:01:24 +00001662 bool HasExplicitTemplateArgs = Record[Idx++];
1663 if (HasExplicitTemplateArgs) {
1664 unsigned NumTemplateArgs = Record[Idx++];
Sebastian Redl2c373b92010-10-05 15:59:54 +00001665 ArgInfo.setLAngleLoc(ReadSourceLocation(F, Record, Idx));
1666 ArgInfo.setRAngleLoc(ReadSourceLocation(F, Record, Idx));
Argyrios Kyrtzidis1985bb32010-07-08 13:09:47 +00001667 for (unsigned i = 0; i != NumTemplateArgs; ++i)
Sebastian Redl2c373b92010-10-05 15:59:54 +00001668 ArgInfo.addArgument(ReadTemplateArgumentLoc(F, Record, Idx));
Argyrios Kyrtzidis1985bb32010-07-08 13:09:47 +00001669 }
Abramo Bagnara635ed24e2011-10-05 07:56:41 +00001670
1671 bool HadMultipleCandidates = Record[Idx++];
1672
Douglas Gregor7fb09192011-07-21 22:35:25 +00001673 NamedDecl *FoundD = ReadDeclAs<NamedDecl>(F, Record, Idx);
Argyrios Kyrtzidis1985bb32010-07-08 13:09:47 +00001674 AccessSpecifier AS = (AccessSpecifier)Record[Idx++];
1675 DeclAccessPair FoundDecl = DeclAccessPair::make(FoundD, AS);
1676
Douglas Gregor903b7e92011-07-22 00:38:23 +00001677 QualType T = readType(F, Record, Idx);
John McCall7decc9e2010-11-18 06:31:45 +00001678 ExprValueKind VK = static_cast<ExprValueKind>(Record[Idx++]);
1679 ExprObjectKind OK = static_cast<ExprObjectKind>(Record[Idx++]);
Argyrios Kyrtzidis1985bb32010-07-08 13:09:47 +00001680 Expr *Base = ReadSubExpr();
Douglas Gregor7fb09192011-07-21 22:35:25 +00001681 ValueDecl *MemberD = ReadDeclAs<ValueDecl>(F, Record, Idx);
Sebastian Redl2c373b92010-10-05 15:59:54 +00001682 SourceLocation MemberLoc = ReadSourceLocation(F, Record, Idx);
Abramo Bagnarad6d2f182010-08-11 22:01:17 +00001683 DeclarationNameInfo MemberNameInfo(MemberD->getDeclName(), MemberLoc);
Argyrios Kyrtzidis1985bb32010-07-08 13:09:47 +00001684 bool IsArrow = Record[Idx++];
1685
Douglas Gregor4163aca2011-09-09 21:34:22 +00001686 S = MemberExpr::Create(Context, Base, IsArrow, QualifierLoc,
Abramo Bagnarad6d2f182010-08-11 22:01:17 +00001687 MemberD, FoundDecl, MemberNameInfo,
Douglas Gregor87866ce2011-02-04 12:01:24 +00001688 HasExplicitTemplateArgs ? &ArgInfo : 0, T, VK, OK);
Argyrios Kyrtzidis434383d2010-10-15 18:21:24 +00001689 ReadDeclarationNameLoc(F, cast<MemberExpr>(S)->MemberDNLoc,
1690 MemberD->getDeclName(), Record, Idx);
Abramo Bagnara635ed24e2011-10-05 07:56:41 +00001691 if (HadMultipleCandidates)
1692 cast<MemberExpr>(S)->setHadMultipleCandidates(true);
Chris Lattner92ba5ff2009-04-27 05:14:47 +00001693 break;
Argyrios Kyrtzidis1985bb32010-07-08 13:09:47 +00001694 }
Chris Lattner92ba5ff2009-04-27 05:14:47 +00001695
Sebastian Redl539c5062010-08-18 23:57:32 +00001696 case EXPR_BINARY_OPERATOR:
Chris Lattner92ba5ff2009-04-27 05:14:47 +00001697 S = new (Context) BinaryOperator(Empty);
1698 break;
1699
Sebastian Redl539c5062010-08-18 23:57:32 +00001700 case EXPR_COMPOUND_ASSIGN_OPERATOR:
Chris Lattner92ba5ff2009-04-27 05:14:47 +00001701 S = new (Context) CompoundAssignOperator(Empty);
1702 break;
1703
Sebastian Redl539c5062010-08-18 23:57:32 +00001704 case EXPR_CONDITIONAL_OPERATOR:
Chris Lattner92ba5ff2009-04-27 05:14:47 +00001705 S = new (Context) ConditionalOperator(Empty);
1706 break;
1707
John McCallc07a0c72011-02-17 10:25:35 +00001708 case EXPR_BINARY_CONDITIONAL_OPERATOR:
1709 S = new (Context) BinaryConditionalOperator(Empty);
1710 break;
1711
Sebastian Redl539c5062010-08-18 23:57:32 +00001712 case EXPR_IMPLICIT_CAST:
Douglas Gregor4163aca2011-09-09 21:34:22 +00001713 S = ImplicitCastExpr::CreateEmpty(Context,
Sebastian Redl70c751d2010-08-18 23:56:52 +00001714 /*PathSize*/ Record[ASTStmtReader::NumExprFields]);
Chris Lattner92ba5ff2009-04-27 05:14:47 +00001715 break;
1716
Sebastian Redl539c5062010-08-18 23:57:32 +00001717 case EXPR_CSTYLE_CAST:
Douglas Gregor4163aca2011-09-09 21:34:22 +00001718 S = CStyleCastExpr::CreateEmpty(Context,
Sebastian Redl70c751d2010-08-18 23:56:52 +00001719 /*PathSize*/ Record[ASTStmtReader::NumExprFields]);
Chris Lattner92ba5ff2009-04-27 05:14:47 +00001720 break;
1721
Sebastian Redl539c5062010-08-18 23:57:32 +00001722 case EXPR_COMPOUND_LITERAL:
Chris Lattner92ba5ff2009-04-27 05:14:47 +00001723 S = new (Context) CompoundLiteralExpr(Empty);
1724 break;
1725
Sebastian Redl539c5062010-08-18 23:57:32 +00001726 case EXPR_EXT_VECTOR_ELEMENT:
Chris Lattner92ba5ff2009-04-27 05:14:47 +00001727 S = new (Context) ExtVectorElementExpr(Empty);
1728 break;
1729
Sebastian Redl539c5062010-08-18 23:57:32 +00001730 case EXPR_INIT_LIST:
Douglas Gregor4163aca2011-09-09 21:34:22 +00001731 S = new (Context) InitListExpr(getContext(), Empty);
Chris Lattner92ba5ff2009-04-27 05:14:47 +00001732 break;
1733
Sebastian Redl539c5062010-08-18 23:57:32 +00001734 case EXPR_DESIGNATED_INIT:
Douglas Gregor4163aca2011-09-09 21:34:22 +00001735 S = DesignatedInitExpr::CreateEmpty(Context,
Sebastian Redl70c751d2010-08-18 23:56:52 +00001736 Record[ASTStmtReader::NumExprFields] - 1);
Mike Stump11289f42009-09-09 15:08:12 +00001737
Chris Lattner92ba5ff2009-04-27 05:14:47 +00001738 break;
1739
Sebastian Redl539c5062010-08-18 23:57:32 +00001740 case EXPR_IMPLICIT_VALUE_INIT:
Chris Lattner92ba5ff2009-04-27 05:14:47 +00001741 S = new (Context) ImplicitValueInitExpr(Empty);
1742 break;
1743
Sebastian Redl539c5062010-08-18 23:57:32 +00001744 case EXPR_VA_ARG:
Chris Lattner92ba5ff2009-04-27 05:14:47 +00001745 S = new (Context) VAArgExpr(Empty);
1746 break;
1747
Sebastian Redl539c5062010-08-18 23:57:32 +00001748 case EXPR_ADDR_LABEL:
Chris Lattner92ba5ff2009-04-27 05:14:47 +00001749 S = new (Context) AddrLabelExpr(Empty);
1750 break;
1751
Sebastian Redl539c5062010-08-18 23:57:32 +00001752 case EXPR_STMT:
Chris Lattner92ba5ff2009-04-27 05:14:47 +00001753 S = new (Context) StmtExpr(Empty);
1754 break;
1755
Sebastian Redl539c5062010-08-18 23:57:32 +00001756 case EXPR_CHOOSE:
Chris Lattner92ba5ff2009-04-27 05:14:47 +00001757 S = new (Context) ChooseExpr(Empty);
1758 break;
1759
Sebastian Redl539c5062010-08-18 23:57:32 +00001760 case EXPR_GNU_NULL:
Chris Lattner92ba5ff2009-04-27 05:14:47 +00001761 S = new (Context) GNUNullExpr(Empty);
1762 break;
1763
Sebastian Redl539c5062010-08-18 23:57:32 +00001764 case EXPR_SHUFFLE_VECTOR:
Chris Lattner92ba5ff2009-04-27 05:14:47 +00001765 S = new (Context) ShuffleVectorExpr(Empty);
1766 break;
Mike Stump11289f42009-09-09 15:08:12 +00001767
Sebastian Redl539c5062010-08-18 23:57:32 +00001768 case EXPR_BLOCK:
Chris Lattner92ba5ff2009-04-27 05:14:47 +00001769 S = new (Context) BlockExpr(Empty);
1770 break;
1771
Sebastian Redl539c5062010-08-18 23:57:32 +00001772 case EXPR_BLOCK_DECL_REF:
Chris Lattner92ba5ff2009-04-27 05:14:47 +00001773 S = new (Context) BlockDeclRefExpr(Empty);
1774 break;
Mike Stump11289f42009-09-09 15:08:12 +00001775
Peter Collingbourne91147592011-04-15 00:35:48 +00001776 case EXPR_GENERIC_SELECTION:
1777 S = new (Context) GenericSelectionExpr(Empty);
1778 break;
1779
Sebastian Redl539c5062010-08-18 23:57:32 +00001780 case EXPR_OBJC_STRING_LITERAL:
Chris Lattner92ba5ff2009-04-27 05:14:47 +00001781 S = new (Context) ObjCStringLiteral(Empty);
1782 break;
Sebastian Redl539c5062010-08-18 23:57:32 +00001783 case EXPR_OBJC_ENCODE:
Chris Lattner92ba5ff2009-04-27 05:14:47 +00001784 S = new (Context) ObjCEncodeExpr(Empty);
1785 break;
Sebastian Redl539c5062010-08-18 23:57:32 +00001786 case EXPR_OBJC_SELECTOR_EXPR:
Chris Lattner92ba5ff2009-04-27 05:14:47 +00001787 S = new (Context) ObjCSelectorExpr(Empty);
1788 break;
Sebastian Redl539c5062010-08-18 23:57:32 +00001789 case EXPR_OBJC_PROTOCOL_EXPR:
Chris Lattner92ba5ff2009-04-27 05:14:47 +00001790 S = new (Context) ObjCProtocolExpr(Empty);
1791 break;
Sebastian Redl539c5062010-08-18 23:57:32 +00001792 case EXPR_OBJC_IVAR_REF_EXPR:
Chris Lattner92ba5ff2009-04-27 05:14:47 +00001793 S = new (Context) ObjCIvarRefExpr(Empty);
1794 break;
Sebastian Redl539c5062010-08-18 23:57:32 +00001795 case EXPR_OBJC_PROPERTY_REF_EXPR:
Chris Lattner92ba5ff2009-04-27 05:14:47 +00001796 S = new (Context) ObjCPropertyRefExpr(Empty);
1797 break;
Sebastian Redl539c5062010-08-18 23:57:32 +00001798 case EXPR_OBJC_KVC_REF_EXPR:
John McCallb7bd14f2010-12-02 01:19:52 +00001799 llvm_unreachable("mismatching AST file");
Chris Lattner92ba5ff2009-04-27 05:14:47 +00001800 break;
Sebastian Redl539c5062010-08-18 23:57:32 +00001801 case EXPR_OBJC_MESSAGE_EXPR:
Douglas Gregor4163aca2011-09-09 21:34:22 +00001802 S = ObjCMessageExpr::CreateEmpty(Context,
Argyrios Kyrtzidisa6011e22011-10-03 06:36:51 +00001803 Record[ASTStmtReader::NumExprFields],
1804 Record[ASTStmtReader::NumExprFields + 1]);
Chris Lattner92ba5ff2009-04-27 05:14:47 +00001805 break;
Sebastian Redl539c5062010-08-18 23:57:32 +00001806 case EXPR_OBJC_ISA:
Steve Naroffe87026a2009-07-24 17:54:45 +00001807 S = new (Context) ObjCIsaExpr(Empty);
1808 break;
John McCall31168b02011-06-15 23:02:42 +00001809 case EXPR_OBJC_INDIRECT_COPY_RESTORE:
1810 S = new (Context) ObjCIndirectCopyRestoreExpr(Empty);
1811 break;
1812 case EXPR_OBJC_BRIDGED_CAST:
1813 S = new (Context) ObjCBridgedCastExpr(Empty);
1814 break;
Sebastian Redl539c5062010-08-18 23:57:32 +00001815 case STMT_OBJC_FOR_COLLECTION:
Chris Lattner92ba5ff2009-04-27 05:14:47 +00001816 S = new (Context) ObjCForCollectionStmt(Empty);
1817 break;
Sebastian Redl539c5062010-08-18 23:57:32 +00001818 case STMT_OBJC_CATCH:
Chris Lattner92ba5ff2009-04-27 05:14:47 +00001819 S = new (Context) ObjCAtCatchStmt(Empty);
1820 break;
Sebastian Redl539c5062010-08-18 23:57:32 +00001821 case STMT_OBJC_FINALLY:
Chris Lattner92ba5ff2009-04-27 05:14:47 +00001822 S = new (Context) ObjCAtFinallyStmt(Empty);
1823 break;
Sebastian Redl539c5062010-08-18 23:57:32 +00001824 case STMT_OBJC_AT_TRY:
Douglas Gregor4163aca2011-09-09 21:34:22 +00001825 S = ObjCAtTryStmt::CreateEmpty(Context,
Sebastian Redl70c751d2010-08-18 23:56:52 +00001826 Record[ASTStmtReader::NumStmtFields],
1827 Record[ASTStmtReader::NumStmtFields + 1]);
Chris Lattner92ba5ff2009-04-27 05:14:47 +00001828 break;
Sebastian Redl539c5062010-08-18 23:57:32 +00001829 case STMT_OBJC_AT_SYNCHRONIZED:
Chris Lattner92ba5ff2009-04-27 05:14:47 +00001830 S = new (Context) ObjCAtSynchronizedStmt(Empty);
1831 break;
Sebastian Redl539c5062010-08-18 23:57:32 +00001832 case STMT_OBJC_AT_THROW:
Chris Lattner92ba5ff2009-04-27 05:14:47 +00001833 S = new (Context) ObjCAtThrowStmt(Empty);
1834 break;
John McCall31168b02011-06-15 23:02:42 +00001835 case STMT_OBJC_AUTORELEASE_POOL:
1836 S = new (Context) ObjCAutoreleasePoolStmt(Empty);
1837 break;
John McCallfa194042011-07-15 07:00:14 +00001838 case STMT_SEH_EXCEPT:
1839 S = new (Context) SEHExceptStmt(Empty);
1840 break;
1841 case STMT_SEH_FINALLY:
1842 S = new (Context) SEHFinallyStmt(Empty);
1843 break;
1844 case STMT_SEH_TRY:
1845 S = new (Context) SEHTryStmt(Empty);
1846 break;
Sebastian Redl539c5062010-08-18 23:57:32 +00001847 case STMT_CXX_CATCH:
Argyrios Kyrtzidis47cd7a92010-07-22 16:03:56 +00001848 S = new (Context) CXXCatchStmt(Empty);
1849 break;
1850
Sebastian Redl539c5062010-08-18 23:57:32 +00001851 case STMT_CXX_TRY:
Douglas Gregor4163aca2011-09-09 21:34:22 +00001852 S = CXXTryStmt::Create(Context, Empty,
Sebastian Redl70c751d2010-08-18 23:56:52 +00001853 /*NumHandlers=*/Record[ASTStmtReader::NumStmtFields]);
Argyrios Kyrtzidis47cd7a92010-07-22 16:03:56 +00001854 break;
1855
Richard Smith02e85f32011-04-14 22:09:26 +00001856 case STMT_CXX_FOR_RANGE:
1857 S = new (Context) CXXForRangeStmt(Empty);
1858 break;
1859
Douglas Gregordeb4a2be2011-10-25 01:33:02 +00001860 case STMT_MS_DEPENDENT_EXISTS:
1861 S = new (Context) MSDependentExistsStmt(SourceLocation(), true,
1862 NestedNameSpecifierLoc(),
1863 DeclarationNameInfo(),
1864 0);
1865 break;
1866
Sebastian Redl539c5062010-08-18 23:57:32 +00001867 case EXPR_CXX_OPERATOR_CALL:
Douglas Gregor4163aca2011-09-09 21:34:22 +00001868 S = new (Context) CXXOperatorCallExpr(Context, Empty);
Argyrios Kyrtzidiseeaaead2009-07-14 03:19:21 +00001869 break;
Chris Lattnerb7e7f722010-05-09 05:36:05 +00001870
Sebastian Redl539c5062010-08-18 23:57:32 +00001871 case EXPR_CXX_MEMBER_CALL:
Douglas Gregor4163aca2011-09-09 21:34:22 +00001872 S = new (Context) CXXMemberCallExpr(Context, Empty);
Chris Lattnerb7e7f722010-05-09 05:36:05 +00001873 break;
Douglas Gregor5d3507d2009-09-09 23:08:42 +00001874
Sebastian Redl539c5062010-08-18 23:57:32 +00001875 case EXPR_CXX_CONSTRUCT:
Argyrios Kyrtzidisb8d77eb2010-07-10 11:46:15 +00001876 S = new (Context) CXXConstructExpr(Empty);
1877 break;
1878
Sebastian Redl539c5062010-08-18 23:57:32 +00001879 case EXPR_CXX_TEMPORARY_OBJECT:
Argyrios Kyrtzidisb8d77eb2010-07-10 11:46:15 +00001880 S = new (Context) CXXTemporaryObjectExpr(Empty);
Douglas Gregor5d3507d2009-09-09 23:08:42 +00001881 break;
Sam Weinigd01101e2010-01-16 21:21:01 +00001882
Sebastian Redl539c5062010-08-18 23:57:32 +00001883 case EXPR_CXX_STATIC_CAST:
Douglas Gregor4163aca2011-09-09 21:34:22 +00001884 S = CXXStaticCastExpr::CreateEmpty(Context,
Sebastian Redl70c751d2010-08-18 23:56:52 +00001885 /*PathSize*/ Record[ASTStmtReader::NumExprFields]);
Sam Weinigd01101e2010-01-16 21:21:01 +00001886 break;
1887
Sebastian Redl539c5062010-08-18 23:57:32 +00001888 case EXPR_CXX_DYNAMIC_CAST:
Douglas Gregor4163aca2011-09-09 21:34:22 +00001889 S = CXXDynamicCastExpr::CreateEmpty(Context,
Sebastian Redl70c751d2010-08-18 23:56:52 +00001890 /*PathSize*/ Record[ASTStmtReader::NumExprFields]);
Sam Weinigd01101e2010-01-16 21:21:01 +00001891 break;
1892
Sebastian Redl539c5062010-08-18 23:57:32 +00001893 case EXPR_CXX_REINTERPRET_CAST:
Douglas Gregor4163aca2011-09-09 21:34:22 +00001894 S = CXXReinterpretCastExpr::CreateEmpty(Context,
Sebastian Redl70c751d2010-08-18 23:56:52 +00001895 /*PathSize*/ Record[ASTStmtReader::NumExprFields]);
Sam Weinigd01101e2010-01-16 21:21:01 +00001896 break;
1897
Sebastian Redl539c5062010-08-18 23:57:32 +00001898 case EXPR_CXX_CONST_CAST:
Douglas Gregor4163aca2011-09-09 21:34:22 +00001899 S = CXXConstCastExpr::CreateEmpty(Context);
Sam Weinigd01101e2010-01-16 21:21:01 +00001900 break;
1901
Sebastian Redl539c5062010-08-18 23:57:32 +00001902 case EXPR_CXX_FUNCTIONAL_CAST:
Douglas Gregor4163aca2011-09-09 21:34:22 +00001903 S = CXXFunctionalCastExpr::CreateEmpty(Context,
Sebastian Redl70c751d2010-08-18 23:56:52 +00001904 /*PathSize*/ Record[ASTStmtReader::NumExprFields]);
Sam Weinigd01101e2010-01-16 21:21:01 +00001905 break;
1906
Sebastian Redl539c5062010-08-18 23:57:32 +00001907 case EXPR_CXX_BOOL_LITERAL:
Sam Weinige83b3ac2010-02-07 06:32:43 +00001908 S = new (Context) CXXBoolLiteralExpr(Empty);
1909 break;
Sam Weinigd01101e2010-01-16 21:21:01 +00001910
Sebastian Redl539c5062010-08-18 23:57:32 +00001911 case EXPR_CXX_NULL_PTR_LITERAL:
Sam Weinige83b3ac2010-02-07 06:32:43 +00001912 S = new (Context) CXXNullPtrLiteralExpr(Empty);
1913 break;
Sebastian Redl539c5062010-08-18 23:57:32 +00001914 case EXPR_CXX_TYPEID_EXPR:
Chris Lattner13a5ecc2010-05-09 06:03:39 +00001915 S = new (Context) CXXTypeidExpr(Empty, true);
1916 break;
Sebastian Redl539c5062010-08-18 23:57:32 +00001917 case EXPR_CXX_TYPEID_TYPE:
Chris Lattner13a5ecc2010-05-09 06:03:39 +00001918 S = new (Context) CXXTypeidExpr(Empty, false);
1919 break;
Francois Pichet9f4f2072010-09-08 12:20:18 +00001920 case EXPR_CXX_UUIDOF_EXPR:
1921 S = new (Context) CXXUuidofExpr(Empty, true);
1922 break;
1923 case EXPR_CXX_UUIDOF_TYPE:
1924 S = new (Context) CXXUuidofExpr(Empty, false);
1925 break;
Sebastian Redl539c5062010-08-18 23:57:32 +00001926 case EXPR_CXX_THIS:
Chris Lattner98267332010-05-09 06:15:05 +00001927 S = new (Context) CXXThisExpr(Empty);
1928 break;
Sebastian Redl539c5062010-08-18 23:57:32 +00001929 case EXPR_CXX_THROW:
Chris Lattner98267332010-05-09 06:15:05 +00001930 S = new (Context) CXXThrowExpr(Empty);
1931 break;
Sebastian Redl539c5062010-08-18 23:57:32 +00001932 case EXPR_CXX_DEFAULT_ARG: {
Sebastian Redl70c751d2010-08-18 23:56:52 +00001933 bool HasOtherExprStored = Record[ASTStmtReader::NumExprFields];
Argyrios Kyrtzidis4259ebc2010-07-02 23:30:15 +00001934 if (HasOtherExprStored) {
1935 Expr *SubExpr = ReadSubExpr();
Douglas Gregor4163aca2011-09-09 21:34:22 +00001936 S = CXXDefaultArgExpr::Create(Context, SourceLocation(), 0, SubExpr);
Argyrios Kyrtzidis4259ebc2010-07-02 23:30:15 +00001937 } else
1938 S = new (Context) CXXDefaultArgExpr(Empty);
Chris Lattnere2437f42010-05-09 06:40:08 +00001939 break;
Argyrios Kyrtzidis4259ebc2010-07-02 23:30:15 +00001940 }
Sebastian Redl539c5062010-08-18 23:57:32 +00001941 case EXPR_CXX_BIND_TEMPORARY:
Chris Lattnercba86142010-05-10 00:25:06 +00001942 S = new (Context) CXXBindTemporaryExpr(Empty);
1943 break;
Douglas Gregor6429f5c2010-09-02 21:50:02 +00001944
Sebastian Redl539c5062010-08-18 23:57:32 +00001945 case EXPR_CXX_SCALAR_VALUE_INIT:
Douglas Gregor747eb782010-07-08 06:14:04 +00001946 S = new (Context) CXXScalarValueInitExpr(Empty);
Chris Lattnerabfb58d2010-05-10 01:22:27 +00001947 break;
Sebastian Redl539c5062010-08-18 23:57:32 +00001948 case EXPR_CXX_NEW:
Chris Lattnerabfb58d2010-05-10 01:22:27 +00001949 S = new (Context) CXXNewExpr(Empty);
1950 break;
Sebastian Redl539c5062010-08-18 23:57:32 +00001951 case EXPR_CXX_DELETE:
Argyrios Kyrtzidis6e57c352010-06-22 17:07:59 +00001952 S = new (Context) CXXDeleteExpr(Empty);
1953 break;
Sebastian Redl539c5062010-08-18 23:57:32 +00001954 case EXPR_CXX_PSEUDO_DESTRUCTOR:
Argyrios Kyrtzidis99a226d2010-06-28 09:32:03 +00001955 S = new (Context) CXXPseudoDestructorExpr(Empty);
1956 break;
Chris Lattnerabfb58d2010-05-10 01:22:27 +00001957
John McCall5d413782010-12-06 08:20:24 +00001958 case EXPR_EXPR_WITH_CLEANUPS:
1959 S = new (Context) ExprWithCleanups(Empty);
Chris Lattnercba86142010-05-10 00:25:06 +00001960 break;
Argyrios Kyrtzidisbfcacee2010-06-24 08:57:31 +00001961
Sebastian Redl539c5062010-08-18 23:57:32 +00001962 case EXPR_CXX_DEPENDENT_SCOPE_MEMBER:
Douglas Gregor4163aca2011-09-09 21:34:22 +00001963 S = CXXDependentScopeMemberExpr::CreateEmpty(Context,
Douglas Gregor87866ce2011-02-04 12:01:24 +00001964 /*HasExplicitTemplateArgs=*/Record[ASTStmtReader::NumExprFields],
1965 /*NumTemplateArgs=*/Record[ASTStmtReader::NumExprFields]
1966 ? Record[ASTStmtReader::NumExprFields + 1]
1967 : 0);
Argyrios Kyrtzidisbfcacee2010-06-24 08:57:31 +00001968 break;
1969
Sebastian Redl539c5062010-08-18 23:57:32 +00001970 case EXPR_CXX_DEPENDENT_SCOPE_DECL_REF:
Douglas Gregor4163aca2011-09-09 21:34:22 +00001971 S = DependentScopeDeclRefExpr::CreateEmpty(Context,
Douglas Gregor87866ce2011-02-04 12:01:24 +00001972 /*HasExplicitTemplateArgs=*/Record[ASTStmtReader::NumExprFields],
1973 /*NumTemplateArgs=*/Record[ASTStmtReader::NumExprFields]
1974 ? Record[ASTStmtReader::NumExprFields + 1]
1975 : 0);
Argyrios Kyrtzidiscd444d1a2010-06-28 09:31:56 +00001976 break;
1977
Sebastian Redl539c5062010-08-18 23:57:32 +00001978 case EXPR_CXX_UNRESOLVED_CONSTRUCT:
Douglas Gregor4163aca2011-09-09 21:34:22 +00001979 S = CXXUnresolvedConstructExpr::CreateEmpty(Context,
Sebastian Redl70c751d2010-08-18 23:56:52 +00001980 /*NumArgs=*/Record[ASTStmtReader::NumExprFields]);
Argyrios Kyrtzidisb8d3c632010-06-25 09:03:26 +00001981 break;
1982
Sebastian Redl539c5062010-08-18 23:57:32 +00001983 case EXPR_CXX_UNRESOLVED_MEMBER:
Douglas Gregor4163aca2011-09-09 21:34:22 +00001984 S = UnresolvedMemberExpr::CreateEmpty(Context,
Douglas Gregor87866ce2011-02-04 12:01:24 +00001985 /*HasExplicitTemplateArgs=*/Record[ASTStmtReader::NumExprFields],
1986 /*NumTemplateArgs=*/Record[ASTStmtReader::NumExprFields]
1987 ? Record[ASTStmtReader::NumExprFields + 1]
1988 : 0);
Argyrios Kyrtzidisbfcacee2010-06-24 08:57:31 +00001989 break;
Argyrios Kyrtzidis58e01ad2010-06-25 09:03:34 +00001990
Sebastian Redl539c5062010-08-18 23:57:32 +00001991 case EXPR_CXX_UNRESOLVED_LOOKUP:
Douglas Gregor4163aca2011-09-09 21:34:22 +00001992 S = UnresolvedLookupExpr::CreateEmpty(Context,
Douglas Gregor87866ce2011-02-04 12:01:24 +00001993 /*HasExplicitTemplateArgs=*/Record[ASTStmtReader::NumExprFields],
1994 /*NumTemplateArgs=*/Record[ASTStmtReader::NumExprFields]
1995 ? Record[ASTStmtReader::NumExprFields + 1]
1996 : 0);
Argyrios Kyrtzidis58e01ad2010-06-25 09:03:34 +00001997 break;
Argyrios Kyrtzidisb8d77eb2010-07-10 11:46:15 +00001998
Sebastian Redl539c5062010-08-18 23:57:32 +00001999 case EXPR_CXX_UNARY_TYPE_TRAIT:
Argyrios Kyrtzidisb8d77eb2010-07-10 11:46:15 +00002000 S = new (Context) UnaryTypeTraitExpr(Empty);
2001 break;
Sebastian Redl9ac55dd2010-09-10 20:55:54 +00002002
Francois Pichet34b21132010-12-08 22:35:30 +00002003 case EXPR_BINARY_TYPE_TRAIT:
Francois Pichet9dfa3ce2010-12-07 00:08:36 +00002004 S = new (Context) BinaryTypeTraitExpr(Empty);
2005 break;
2006
John Wiegley6242b6a2011-04-28 00:16:57 +00002007 case EXPR_ARRAY_TYPE_TRAIT:
2008 S = new (Context) ArrayTypeTraitExpr(Empty);
2009 break;
2010
John Wiegleyf9f65842011-04-25 06:54:41 +00002011 case EXPR_CXX_EXPRESSION_TRAIT:
2012 S = new (Context) ExpressionTraitExpr(Empty);
2013 break;
2014
Sebastian Redl9ac55dd2010-09-10 20:55:54 +00002015 case EXPR_CXX_NOEXCEPT:
2016 S = new (Context) CXXNoexceptExpr(Empty);
2017 break;
John McCall8d69a212010-11-15 23:31:06 +00002018
Douglas Gregore8e9dd62011-01-03 17:17:50 +00002019 case EXPR_PACK_EXPANSION:
2020 S = new (Context) PackExpansionExpr(Empty);
2021 break;
2022
Douglas Gregor820ba7b2011-01-04 17:33:58 +00002023 case EXPR_SIZEOF_PACK:
2024 S = new (Context) SizeOfPackExpr(Empty);
2025 break;
2026
John McCallfa194042011-07-15 07:00:14 +00002027 case EXPR_SUBST_NON_TYPE_TEMPLATE_PARM:
2028 S = new (Context) SubstNonTypeTemplateParmExpr(Empty);
2029 break;
2030
Douglas Gregorcdbc5392011-01-15 01:15:58 +00002031 case EXPR_SUBST_NON_TYPE_TEMPLATE_PARM_PACK:
2032 S = new (Context) SubstNonTypeTemplateParmPackExpr(Empty);
2033 break;
2034
Douglas Gregorfe314812011-06-21 17:03:29 +00002035 case EXPR_MATERIALIZE_TEMPORARY:
2036 S = new (Context) MaterializeTemporaryExpr(Empty);
2037 break;
2038
John McCallc07a0c72011-02-17 10:25:35 +00002039 case EXPR_OPAQUE_VALUE: {
2040 unsigned key = Record[ASTStmtReader::NumExprFields];
2041 OpaqueValueExpr *&expr = OpaqueValueExprs[key];
2042
2043 // If we already have an entry for this opaque value expression,
2044 // don't bother reading it again.
2045 if (expr) {
2046 StmtStack.push_back(expr);
2047 continue;
2048 }
2049
2050 S = expr = new (Context) OpaqueValueExpr(Empty);
John McCall8d69a212010-11-15 23:31:06 +00002051 break;
John McCallc07a0c72011-02-17 10:25:35 +00002052 }
Peter Collingbourne41f85462011-02-09 21:07:24 +00002053
2054 case EXPR_CUDA_KERNEL_CALL:
Douglas Gregor4163aca2011-09-09 21:34:22 +00002055 S = new (Context) CUDAKernelCallExpr(Context, Empty);
Peter Collingbourne41f85462011-02-09 21:07:24 +00002056 break;
Tanya Lattner55808c12011-06-04 00:47:47 +00002057
2058 case EXPR_ASTYPE:
2059 S = new (Context) AsTypeExpr(Empty);
2060 break;
Eli Friedmandf14b3a2011-10-11 02:20:01 +00002061
2062 case EXPR_ATOMIC:
2063 S = new (Context) AtomicExpr(Empty);
2064 break;
Chris Lattner92ba5ff2009-04-27 05:14:47 +00002065 }
Argyrios Kyrtzidisb8d77eb2010-07-10 11:46:15 +00002066
Chris Lattner92ba5ff2009-04-27 05:14:47 +00002067 // We hit a STMT_STOP, so we're done with this expression.
2068 if (Finished)
2069 break;
2070
2071 ++NumStatementsRead;
2072
Argyrios Kyrtzidis6a598972011-10-21 23:02:28 +00002073 if (S && !IsStmtReference) {
Argyrios Kyrtzidisd0795b22010-06-28 22:28:35 +00002074 Reader.Visit(S);
Argyrios Kyrtzidis6a598972011-10-21 23:02:28 +00002075 StmtEntries[Cursor.GetCurrentBitNo()] = S;
2076 }
2077
Chris Lattner92ba5ff2009-04-27 05:14:47 +00002078
2079 assert(Idx == Record.size() && "Invalid deserialization of statement");
2080 StmtStack.push_back(S);
2081 }
Argyrios Kyrtzidisd0795b22010-06-28 22:28:35 +00002082
2083#ifndef NDEBUG
2084 assert(StmtStack.size() > PrevNumStmts && "Read too many sub stmts!");
2085 assert(StmtStack.size() == PrevNumStmts + 1 && "Extra expressions on stack!");
2086#endif
2087
2088 return StmtStack.pop_back_val();
Chris Lattner92ba5ff2009-04-27 05:14:47 +00002089}