blob: ff306b06c9ea49d456d269ced10572711dfe3ecf [file] [log] [blame]
Sebastian Redl904c9c82010-08-18 23:57:11 +00001//===--- ASTReaderStmt.cpp - Stmt/Expr Deserialization ----------*- C++ -*-===//
Chris Lattner4c6f9522009-04-27 05:14:47 +00002//
3// The LLVM Compiler Infrastructure
4//
5// This file is distributed under the University of Illinois Open Source
6// License. See LICENSE.TXT for details.
7//
8//===----------------------------------------------------------------------===//
9//
10// Statement/expression deserialization. This implements the
Sebastian Redlc43b54c2010-08-18 23:56:43 +000011// ASTReader::ReadStmt method.
Chris Lattner4c6f9522009-04-27 05:14:47 +000012//
13//===----------------------------------------------------------------------===//
14
Sebastian Redl6ab7cd82010-08-18 23:57:17 +000015#include "clang/Serialization/ASTReader.h"
Douglas Gregor39da0b82009-09-09 23:08:42 +000016#include "clang/AST/DeclCXX.h"
Douglas Gregorc7793c72011-01-15 01:15:58 +000017#include "clang/AST/DeclTemplate.h"
Chris Lattner4c6f9522009-04-27 05:14:47 +000018#include "clang/AST/StmtVisitor.h"
19using namespace clang;
Sebastian Redl8538e8d2010-08-18 23:57:32 +000020using namespace clang::serialization;
Chris Lattner4c6f9522009-04-27 05:14:47 +000021
Argyrios Kyrtzidis37bdfe22010-06-30 08:49:18 +000022namespace clang {
Argyrios Kyrtzidis17cfded2010-06-28 09:31:42 +000023
Sebastian Redl60adf4a2010-08-18 23:56:52 +000024 class ASTStmtReader : public StmtVisitor<ASTStmtReader> {
Douglas Gregor409448c2011-07-21 22:35:25 +000025 typedef ASTReader::RecordData RecordData;
26
Sebastian Redlc43b54c2010-08-18 23:56:43 +000027 ASTReader &Reader;
Douglas Gregor72a9ae12011-07-22 16:00:58 +000028 Module &F;
Sebastian Redl577d4792010-07-22 22:43:28 +000029 llvm::BitstreamCursor &DeclsCursor;
Sebastian Redlc43b54c2010-08-18 23:56:43 +000030 const ASTReader::RecordData &Record;
Chris Lattner4c6f9522009-04-27 05:14:47 +000031 unsigned &Idx;
Chris Lattner4c6f9522009-04-27 05:14:47 +000032
Douglas Gregor409448c2011-07-21 22:35:25 +000033 SourceLocation ReadSourceLocation(const RecordData &R, unsigned &I) {
Sebastian Redlc3632732010-10-05 15:59:54 +000034 return Reader.ReadSourceLocation(F, R, I);
35 }
Douglas Gregor409448c2011-07-21 22:35:25 +000036
37 SourceRange ReadSourceRange(const RecordData &R, unsigned &I) {
Sebastian Redlc3632732010-10-05 15:59:54 +000038 return Reader.ReadSourceRange(F, R, I);
39 }
Douglas Gregor409448c2011-07-21 22:35:25 +000040
41 TypeSourceInfo *GetTypeSourceInfo(const RecordData &R, unsigned &I) {
Sebastian Redlc3632732010-10-05 15:59:54 +000042 return Reader.GetTypeSourceInfo(F, R, I);
43 }
Douglas Gregor409448c2011-07-21 22:35:25 +000044
45 serialization::DeclID ReadDeclID(const RecordData &R, unsigned &I) {
46 return Reader.ReadDeclID(F, R, I);
47 }
48
49 Decl *ReadDecl(const RecordData &R, unsigned &I) {
50 return Reader.ReadDecl(F, R, I);
51 }
52
53 template<typename T>
54 T *ReadDeclAs(const RecordData &R, unsigned &I) {
55 return Reader.ReadDeclAs<T>(F, R, I);
56 }
57
Argyrios Kyrtzidis40451072010-10-15 18:21:24 +000058 void ReadDeclarationNameLoc(DeclarationNameLoc &DNLoc, DeclarationName Name,
59 const ASTReader::RecordData &R, unsigned &I) {
60 Reader.ReadDeclarationNameLoc(F, DNLoc, Name, R, I);
61 }
Douglas Gregor409448c2011-07-21 22:35:25 +000062
Argyrios Kyrtzidis40451072010-10-15 18:21:24 +000063 void ReadDeclarationNameInfo(DeclarationNameInfo &NameInfo,
64 const ASTReader::RecordData &R, unsigned &I) {
65 Reader.ReadDeclarationNameInfo(F, NameInfo, R, I);
66 }
Sebastian Redlc3632732010-10-05 15:59:54 +000067
Chris Lattner4c6f9522009-04-27 05:14:47 +000068 public:
Douglas Gregor72a9ae12011-07-22 16:00:58 +000069 ASTStmtReader(ASTReader &Reader, Module &F,
Sebastian Redlc3632732010-10-05 15:59:54 +000070 llvm::BitstreamCursor &Cursor,
Sebastian Redlc43b54c2010-08-18 23:56:43 +000071 const ASTReader::RecordData &Record, unsigned &Idx)
Sebastian Redlc3632732010-10-05 15:59:54 +000072 : Reader(Reader), F(F), DeclsCursor(Cursor), Record(Record), Idx(Idx) { }
Chris Lattner4c6f9522009-04-27 05:14:47 +000073
74 /// \brief The number of record fields required for the Stmt class
75 /// itself.
76 static const unsigned NumStmtFields = 0;
77
78 /// \brief The number of record fields required for the Expr class
79 /// itself.
Douglas Gregor561f8122011-07-01 01:22:09 +000080 static const unsigned NumExprFields = NumStmtFields + 7;
Argyrios Kyrtzidis36c76f02010-06-28 09:31:48 +000081
82 /// \brief Read and initialize a ExplicitTemplateArgumentList structure.
Argyrios Kyrtzidisb0c3e092011-09-22 20:07:03 +000083 void ReadExplicitTemplateArgumentList(ASTTemplateArgumentListInfo &ArgList,
Argyrios Kyrtzidis919e6932010-06-28 22:28:35 +000084 unsigned NumTemplateArgs);
Chris Lattner4c6f9522009-04-27 05:14:47 +000085
Argyrios Kyrtzidis919e6932010-06-28 22:28:35 +000086 void VisitStmt(Stmt *S);
John McCall7110fd62011-07-15 07:00:14 +000087#define STMT(Type, Base) \
88 void Visit##Type(Type *);
89#include "clang/AST/StmtNodes.inc"
Chris Lattner4c6f9522009-04-27 05:14:47 +000090 };
91}
92
Sebastian Redl60adf4a2010-08-18 23:56:52 +000093void ASTStmtReader::
Argyrios Kyrtzidisb0c3e092011-09-22 20:07:03 +000094ReadExplicitTemplateArgumentList(ASTTemplateArgumentListInfo &ArgList,
Argyrios Kyrtzidis919e6932010-06-28 22:28:35 +000095 unsigned NumTemplateArgs) {
Argyrios Kyrtzidis36c76f02010-06-28 09:31:48 +000096 TemplateArgumentListInfo ArgInfo;
Sebastian Redlc3632732010-10-05 15:59:54 +000097 ArgInfo.setLAngleLoc(ReadSourceLocation(Record, Idx));
98 ArgInfo.setRAngleLoc(ReadSourceLocation(Record, Idx));
Argyrios Kyrtzidis36c76f02010-06-28 09:31:48 +000099 for (unsigned i = 0; i != NumTemplateArgs; ++i)
Sebastian Redl577d4792010-07-22 22:43:28 +0000100 ArgInfo.addArgument(
Sebastian Redlc3632732010-10-05 15:59:54 +0000101 Reader.ReadTemplateArgumentLoc(F, Record, Idx));
Argyrios Kyrtzidis36c76f02010-06-28 09:31:48 +0000102 ArgList.initializeFrom(ArgInfo);
Argyrios Kyrtzidis36c76f02010-06-28 09:31:48 +0000103}
104
Sebastian Redl60adf4a2010-08-18 23:56:52 +0000105void ASTStmtReader::VisitStmt(Stmt *S) {
Chris Lattner4c6f9522009-04-27 05:14:47 +0000106 assert(Idx == NumStmtFields && "Incorrect statement field count");
Chris Lattner4c6f9522009-04-27 05:14:47 +0000107}
108
Sebastian Redl60adf4a2010-08-18 23:56:52 +0000109void ASTStmtReader::VisitNullStmt(NullStmt *S) {
Chris Lattner4c6f9522009-04-27 05:14:47 +0000110 VisitStmt(S);
Sebastian Redlc3632732010-10-05 15:59:54 +0000111 S->setSemiLoc(ReadSourceLocation(Record, Idx));
Argyrios Kyrtzidise2ca8282011-09-01 21:53:45 +0000112 S->HasLeadingEmptyMacro = Record[Idx++];
Chris Lattner4c6f9522009-04-27 05:14:47 +0000113}
114
Sebastian Redl60adf4a2010-08-18 23:56:52 +0000115void ASTStmtReader::VisitCompoundStmt(CompoundStmt *S) {
Chris Lattner4c6f9522009-04-27 05:14:47 +0000116 VisitStmt(S);
Chris Lattner5f9e2722011-07-23 10:55:15 +0000117 SmallVector<Stmt *, 16> Stmts;
Chris Lattner4c6f9522009-04-27 05:14:47 +0000118 unsigned NumStmts = Record[Idx++];
Argyrios Kyrtzidis919e6932010-06-28 22:28:35 +0000119 while (NumStmts--)
Argyrios Kyrtzidisd98a2ab2010-06-29 22:46:25 +0000120 Stmts.push_back(Reader.ReadSubStmt());
Douglas Gregor35942772011-09-09 21:34:22 +0000121 S->setStmts(Reader.getContext(), Stmts.data(), Stmts.size());
Sebastian Redlc3632732010-10-05 15:59:54 +0000122 S->setLBracLoc(ReadSourceLocation(Record, Idx));
123 S->setRBracLoc(ReadSourceLocation(Record, Idx));
Chris Lattner4c6f9522009-04-27 05:14:47 +0000124}
125
Sebastian Redl60adf4a2010-08-18 23:56:52 +0000126void ASTStmtReader::VisitSwitchCase(SwitchCase *S) {
Chris Lattner4c6f9522009-04-27 05:14:47 +0000127 VisitStmt(S);
128 Reader.RecordSwitchCaseID(S, Record[Idx++]);
Chris Lattner4c6f9522009-04-27 05:14:47 +0000129}
130
Sebastian Redl60adf4a2010-08-18 23:56:52 +0000131void ASTStmtReader::VisitCaseStmt(CaseStmt *S) {
Chris Lattner4c6f9522009-04-27 05:14:47 +0000132 VisitSwitchCase(S);
Argyrios Kyrtzidisd98a2ab2010-06-29 22:46:25 +0000133 S->setLHS(Reader.ReadSubExpr());
134 S->setRHS(Reader.ReadSubExpr());
135 S->setSubStmt(Reader.ReadSubStmt());
Sebastian Redlc3632732010-10-05 15:59:54 +0000136 S->setCaseLoc(ReadSourceLocation(Record, Idx));
137 S->setEllipsisLoc(ReadSourceLocation(Record, Idx));
138 S->setColonLoc(ReadSourceLocation(Record, Idx));
Chris Lattner4c6f9522009-04-27 05:14:47 +0000139}
140
Sebastian Redl60adf4a2010-08-18 23:56:52 +0000141void ASTStmtReader::VisitDefaultStmt(DefaultStmt *S) {
Chris Lattner4c6f9522009-04-27 05:14:47 +0000142 VisitSwitchCase(S);
Argyrios Kyrtzidisd98a2ab2010-06-29 22:46:25 +0000143 S->setSubStmt(Reader.ReadSubStmt());
Sebastian Redlc3632732010-10-05 15:59:54 +0000144 S->setDefaultLoc(ReadSourceLocation(Record, Idx));
145 S->setColonLoc(ReadSourceLocation(Record, Idx));
Chris Lattner4c6f9522009-04-27 05:14:47 +0000146}
147
Sebastian Redl60adf4a2010-08-18 23:56:52 +0000148void ASTStmtReader::VisitLabelStmt(LabelStmt *S) {
Chris Lattner4c6f9522009-04-27 05:14:47 +0000149 VisitStmt(S);
Douglas Gregor409448c2011-07-21 22:35:25 +0000150 LabelDecl *LD = ReadDeclAs<LabelDecl>(Record, Idx);
Chris Lattnerad8dcf42011-02-17 07:39:24 +0000151 LD->setStmt(S);
152 S->setDecl(LD);
Argyrios Kyrtzidisd98a2ab2010-06-29 22:46:25 +0000153 S->setSubStmt(Reader.ReadSubStmt());
Sebastian Redlc3632732010-10-05 15:59:54 +0000154 S->setIdentLoc(ReadSourceLocation(Record, Idx));
Chris Lattner4c6f9522009-04-27 05:14:47 +0000155}
156
Sebastian Redl60adf4a2010-08-18 23:56:52 +0000157void ASTStmtReader::VisitIfStmt(IfStmt *S) {
Chris Lattner4c6f9522009-04-27 05:14:47 +0000158 VisitStmt(S);
Douglas Gregor35942772011-09-09 21:34:22 +0000159 S->setConditionVariable(Reader.getContext(),
Douglas Gregor409448c2011-07-21 22:35:25 +0000160 ReadDeclAs<VarDecl>(Record, Idx));
Argyrios Kyrtzidisd98a2ab2010-06-29 22:46:25 +0000161 S->setCond(Reader.ReadSubExpr());
162 S->setThen(Reader.ReadSubStmt());
163 S->setElse(Reader.ReadSubStmt());
Sebastian Redlc3632732010-10-05 15:59:54 +0000164 S->setIfLoc(ReadSourceLocation(Record, Idx));
165 S->setElseLoc(ReadSourceLocation(Record, Idx));
Chris Lattner4c6f9522009-04-27 05:14:47 +0000166}
167
Sebastian Redl60adf4a2010-08-18 23:56:52 +0000168void ASTStmtReader::VisitSwitchStmt(SwitchStmt *S) {
Chris Lattner4c6f9522009-04-27 05:14:47 +0000169 VisitStmt(S);
Douglas Gregor35942772011-09-09 21:34:22 +0000170 S->setConditionVariable(Reader.getContext(),
Douglas Gregor409448c2011-07-21 22:35:25 +0000171 ReadDeclAs<VarDecl>(Record, Idx));
Argyrios Kyrtzidisd98a2ab2010-06-29 22:46:25 +0000172 S->setCond(Reader.ReadSubExpr());
173 S->setBody(Reader.ReadSubStmt());
Sebastian Redlc3632732010-10-05 15:59:54 +0000174 S->setSwitchLoc(ReadSourceLocation(Record, Idx));
Ted Kremenek559fb552010-09-09 00:05:53 +0000175 if (Record[Idx++])
176 S->setAllEnumCasesCovered();
177
Chris Lattner4c6f9522009-04-27 05:14:47 +0000178 SwitchCase *PrevSC = 0;
179 for (unsigned N = Record.size(); Idx != N; ++Idx) {
180 SwitchCase *SC = Reader.getSwitchCaseWithID(Record[Idx]);
181 if (PrevSC)
182 PrevSC->setNextSwitchCase(SC);
183 else
184 S->setSwitchCaseList(SC);
Mike Stump1eb44332009-09-09 15:08:12 +0000185
Chris Lattner4c6f9522009-04-27 05:14:47 +0000186 PrevSC = SC;
187 }
Chris Lattner4c6f9522009-04-27 05:14:47 +0000188}
189
Sebastian Redl60adf4a2010-08-18 23:56:52 +0000190void ASTStmtReader::VisitWhileStmt(WhileStmt *S) {
Chris Lattner4c6f9522009-04-27 05:14:47 +0000191 VisitStmt(S);
Douglas Gregor35942772011-09-09 21:34:22 +0000192 S->setConditionVariable(Reader.getContext(),
Douglas Gregor409448c2011-07-21 22:35:25 +0000193 ReadDeclAs<VarDecl>(Record, Idx));
194
Argyrios Kyrtzidisd98a2ab2010-06-29 22:46:25 +0000195 S->setCond(Reader.ReadSubExpr());
196 S->setBody(Reader.ReadSubStmt());
Sebastian Redlc3632732010-10-05 15:59:54 +0000197 S->setWhileLoc(ReadSourceLocation(Record, Idx));
Chris Lattner4c6f9522009-04-27 05:14:47 +0000198}
199
Sebastian Redl60adf4a2010-08-18 23:56:52 +0000200void ASTStmtReader::VisitDoStmt(DoStmt *S) {
Chris Lattner4c6f9522009-04-27 05:14:47 +0000201 VisitStmt(S);
Argyrios Kyrtzidisd98a2ab2010-06-29 22:46:25 +0000202 S->setCond(Reader.ReadSubExpr());
203 S->setBody(Reader.ReadSubStmt());
Sebastian Redlc3632732010-10-05 15:59:54 +0000204 S->setDoLoc(ReadSourceLocation(Record, Idx));
205 S->setWhileLoc(ReadSourceLocation(Record, Idx));
206 S->setRParenLoc(ReadSourceLocation(Record, Idx));
Chris Lattner4c6f9522009-04-27 05:14:47 +0000207}
208
Sebastian Redl60adf4a2010-08-18 23:56:52 +0000209void ASTStmtReader::VisitForStmt(ForStmt *S) {
Chris Lattner4c6f9522009-04-27 05:14:47 +0000210 VisitStmt(S);
Argyrios Kyrtzidisd98a2ab2010-06-29 22:46:25 +0000211 S->setInit(Reader.ReadSubStmt());
212 S->setCond(Reader.ReadSubExpr());
Douglas Gregor35942772011-09-09 21:34:22 +0000213 S->setConditionVariable(Reader.getContext(),
Douglas Gregor409448c2011-07-21 22:35:25 +0000214 ReadDeclAs<VarDecl>(Record, Idx));
Argyrios Kyrtzidisd98a2ab2010-06-29 22:46:25 +0000215 S->setInc(Reader.ReadSubExpr());
216 S->setBody(Reader.ReadSubStmt());
Sebastian Redlc3632732010-10-05 15:59:54 +0000217 S->setForLoc(ReadSourceLocation(Record, Idx));
218 S->setLParenLoc(ReadSourceLocation(Record, Idx));
219 S->setRParenLoc(ReadSourceLocation(Record, Idx));
Chris Lattner4c6f9522009-04-27 05:14:47 +0000220}
221
Sebastian Redl60adf4a2010-08-18 23:56:52 +0000222void ASTStmtReader::VisitGotoStmt(GotoStmt *S) {
Chris Lattner4c6f9522009-04-27 05:14:47 +0000223 VisitStmt(S);
Douglas Gregor409448c2011-07-21 22:35:25 +0000224 S->setLabel(ReadDeclAs<LabelDecl>(Record, Idx));
Sebastian Redlc3632732010-10-05 15:59:54 +0000225 S->setGotoLoc(ReadSourceLocation(Record, Idx));
226 S->setLabelLoc(ReadSourceLocation(Record, Idx));
Chris Lattner4c6f9522009-04-27 05:14:47 +0000227}
228
Sebastian Redl60adf4a2010-08-18 23:56:52 +0000229void ASTStmtReader::VisitIndirectGotoStmt(IndirectGotoStmt *S) {
Chris Lattner4c6f9522009-04-27 05:14:47 +0000230 VisitStmt(S);
Sebastian Redlc3632732010-10-05 15:59:54 +0000231 S->setGotoLoc(ReadSourceLocation(Record, Idx));
232 S->setStarLoc(ReadSourceLocation(Record, Idx));
Argyrios Kyrtzidisd98a2ab2010-06-29 22:46:25 +0000233 S->setTarget(Reader.ReadSubExpr());
Chris Lattner4c6f9522009-04-27 05:14:47 +0000234}
235
Sebastian Redl60adf4a2010-08-18 23:56:52 +0000236void ASTStmtReader::VisitContinueStmt(ContinueStmt *S) {
Chris Lattner4c6f9522009-04-27 05:14:47 +0000237 VisitStmt(S);
Sebastian Redlc3632732010-10-05 15:59:54 +0000238 S->setContinueLoc(ReadSourceLocation(Record, Idx));
Chris Lattner4c6f9522009-04-27 05:14:47 +0000239}
240
Sebastian Redl60adf4a2010-08-18 23:56:52 +0000241void ASTStmtReader::VisitBreakStmt(BreakStmt *S) {
Chris Lattner4c6f9522009-04-27 05:14:47 +0000242 VisitStmt(S);
Sebastian Redlc3632732010-10-05 15:59:54 +0000243 S->setBreakLoc(ReadSourceLocation(Record, Idx));
Chris Lattner4c6f9522009-04-27 05:14:47 +0000244}
245
Sebastian Redl60adf4a2010-08-18 23:56:52 +0000246void ASTStmtReader::VisitReturnStmt(ReturnStmt *S) {
Chris Lattner4c6f9522009-04-27 05:14:47 +0000247 VisitStmt(S);
Argyrios Kyrtzidisd98a2ab2010-06-29 22:46:25 +0000248 S->setRetValue(Reader.ReadSubExpr());
Sebastian Redlc3632732010-10-05 15:59:54 +0000249 S->setReturnLoc(ReadSourceLocation(Record, Idx));
Douglas Gregor409448c2011-07-21 22:35:25 +0000250 S->setNRVOCandidate(ReadDeclAs<VarDecl>(Record, Idx));
Chris Lattner4c6f9522009-04-27 05:14:47 +0000251}
252
Sebastian Redl60adf4a2010-08-18 23:56:52 +0000253void ASTStmtReader::VisitDeclStmt(DeclStmt *S) {
Chris Lattner4c6f9522009-04-27 05:14:47 +0000254 VisitStmt(S);
Sebastian Redlc3632732010-10-05 15:59:54 +0000255 S->setStartLoc(ReadSourceLocation(Record, Idx));
256 S->setEndLoc(ReadSourceLocation(Record, Idx));
Chris Lattner4c6f9522009-04-27 05:14:47 +0000257
258 if (Idx + 1 == Record.size()) {
259 // Single declaration
Douglas Gregor409448c2011-07-21 22:35:25 +0000260 S->setDeclGroup(DeclGroupRef(ReadDecl(Record, Idx)));
Chris Lattner4c6f9522009-04-27 05:14:47 +0000261 } else {
Chris Lattner5f9e2722011-07-23 10:55:15 +0000262 SmallVector<Decl *, 16> Decls;
Douglas Gregor409448c2011-07-21 22:35:25 +0000263 Decls.reserve(Record.size() - Idx);
264 for (unsigned N = Record.size(); Idx != N; )
265 Decls.push_back(ReadDecl(Record, Idx));
Douglas Gregor35942772011-09-09 21:34:22 +0000266 S->setDeclGroup(DeclGroupRef(DeclGroup::Create(Reader.getContext(),
Douglas Gregor75fdb232009-05-22 22:45:36 +0000267 Decls.data(),
268 Decls.size())));
Chris Lattner4c6f9522009-04-27 05:14:47 +0000269 }
Chris Lattner4c6f9522009-04-27 05:14:47 +0000270}
271
Sebastian Redl60adf4a2010-08-18 23:56:52 +0000272void ASTStmtReader::VisitAsmStmt(AsmStmt *S) {
Chris Lattner4c6f9522009-04-27 05:14:47 +0000273 VisitStmt(S);
274 unsigned NumOutputs = Record[Idx++];
275 unsigned NumInputs = Record[Idx++];
276 unsigned NumClobbers = Record[Idx++];
Sebastian Redlc3632732010-10-05 15:59:54 +0000277 S->setAsmLoc(ReadSourceLocation(Record, Idx));
278 S->setRParenLoc(ReadSourceLocation(Record, Idx));
Chris Lattner4c6f9522009-04-27 05:14:47 +0000279 S->setVolatile(Record[Idx++]);
280 S->setSimple(Record[Idx++]);
Mike Stump3b11fd32010-01-04 22:37:17 +0000281 S->setMSAsm(Record[Idx++]);
Mike Stump1eb44332009-09-09 15:08:12 +0000282
Argyrios Kyrtzidisd98a2ab2010-06-29 22:46:25 +0000283 S->setAsmString(cast_or_null<StringLiteral>(Reader.ReadSubStmt()));
Chris Lattner4c6f9522009-04-27 05:14:47 +0000284
285 // Outputs and inputs
Chris Lattner5f9e2722011-07-23 10:55:15 +0000286 SmallVector<IdentifierInfo *, 16> Names;
287 SmallVector<StringLiteral*, 16> Constraints;
288 SmallVector<Stmt*, 16> Exprs;
Chris Lattner4c6f9522009-04-27 05:14:47 +0000289 for (unsigned I = 0, N = NumOutputs + NumInputs; I != N; ++I) {
Douglas Gregor95eab172011-07-28 20:55:49 +0000290 Names.push_back(Reader.GetIdentifierInfo(F, Record, Idx));
Argyrios Kyrtzidisd98a2ab2010-06-29 22:46:25 +0000291 Constraints.push_back(cast_or_null<StringLiteral>(Reader.ReadSubStmt()));
292 Exprs.push_back(Reader.ReadSubStmt());
Chris Lattner4c6f9522009-04-27 05:14:47 +0000293 }
Chris Lattner4c6f9522009-04-27 05:14:47 +0000294
295 // Constraints
Chris Lattner5f9e2722011-07-23 10:55:15 +0000296 SmallVector<StringLiteral*, 16> Clobbers;
Chris Lattner4c6f9522009-04-27 05:14:47 +0000297 for (unsigned I = 0; I != NumClobbers; ++I)
Argyrios Kyrtzidisd98a2ab2010-06-29 22:46:25 +0000298 Clobbers.push_back(cast_or_null<StringLiteral>(Reader.ReadSubStmt()));
Anders Carlssonfdba9c02010-01-30 19:34:25 +0000299
Douglas Gregor35942772011-09-09 21:34:22 +0000300 S->setOutputsAndInputsAndClobbers(Reader.getContext(),
Anders Carlssonacb6bcb2010-01-30 20:38:10 +0000301 Names.data(), Constraints.data(),
Anders Carlssonfdba9c02010-01-30 19:34:25 +0000302 Exprs.data(), NumOutputs, NumInputs,
303 Clobbers.data(), NumClobbers);
Chris Lattner4c6f9522009-04-27 05:14:47 +0000304}
305
Sebastian Redl60adf4a2010-08-18 23:56:52 +0000306void ASTStmtReader::VisitExpr(Expr *E) {
Chris Lattner4c6f9522009-04-27 05:14:47 +0000307 VisitStmt(E);
Douglas Gregor393f2492011-07-22 00:38:23 +0000308 E->setType(Reader.readType(F, Record, Idx));
Chris Lattner4c6f9522009-04-27 05:14:47 +0000309 E->setTypeDependent(Record[Idx++]);
310 E->setValueDependent(Record[Idx++]);
Douglas Gregor561f8122011-07-01 01:22:09 +0000311 E->setInstantiationDependent(Record[Idx++]);
Douglas Gregord0937222010-12-13 22:49:22 +0000312 E->ExprBits.ContainsUnexpandedParameterPack = Record[Idx++];
John McCallf89e55a2010-11-18 06:31:45 +0000313 E->setValueKind(static_cast<ExprValueKind>(Record[Idx++]));
314 E->setObjectKind(static_cast<ExprObjectKind>(Record[Idx++]));
Chris Lattner4c6f9522009-04-27 05:14:47 +0000315 assert(Idx == NumExprFields && "Incorrect expression field count");
Chris Lattner4c6f9522009-04-27 05:14:47 +0000316}
317
Sebastian Redl60adf4a2010-08-18 23:56:52 +0000318void ASTStmtReader::VisitPredefinedExpr(PredefinedExpr *E) {
Chris Lattner4c6f9522009-04-27 05:14:47 +0000319 VisitExpr(E);
Sebastian Redlc3632732010-10-05 15:59:54 +0000320 E->setLocation(ReadSourceLocation(Record, Idx));
Chris Lattner4c6f9522009-04-27 05:14:47 +0000321 E->setIdentType((PredefinedExpr::IdentType)Record[Idx++]);
Chris Lattner4c6f9522009-04-27 05:14:47 +0000322}
323
Sebastian Redl60adf4a2010-08-18 23:56:52 +0000324void ASTStmtReader::VisitDeclRefExpr(DeclRefExpr *E) {
Chris Lattner4c6f9522009-04-27 05:14:47 +0000325 VisitExpr(E);
Argyrios Kyrtzidis663e3802010-07-08 13:09:47 +0000326
Chandler Carruthcb66cff2011-05-01 21:29:53 +0000327 E->DeclRefExprBits.HasQualifier = Record[Idx++];
Chandler Carruth3aa81402011-05-01 23:48:14 +0000328 E->DeclRefExprBits.HasFoundDecl = Record[Idx++];
Chandler Carruthcb66cff2011-05-01 21:29:53 +0000329 E->DeclRefExprBits.HasExplicitTemplateArgs = Record[Idx++];
Abramo Bagnara7cc58b42011-10-05 07:56:41 +0000330 E->DeclRefExprBits.HadMultipleCandidates = Record[Idx++];
Anders Carlssonb0ca1372011-03-06 18:19:42 +0000331 unsigned NumTemplateArgs = 0;
Chandler Carruthcb66cff2011-05-01 21:29:53 +0000332 if (E->hasExplicitTemplateArgs())
Anders Carlssonb0ca1372011-03-06 18:19:42 +0000333 NumTemplateArgs = Record[Idx++];
334
Chandler Carruthcb66cff2011-05-01 21:29:53 +0000335 if (E->hasQualifier())
Chandler Carruth6857c3e2011-05-01 22:14:37 +0000336 E->getInternalQualifierLoc()
Douglas Gregor40d96a62011-02-28 21:54:11 +0000337 = Reader.ReadNestedNameSpecifierLoc(F, Record, Idx);
Argyrios Kyrtzidis663e3802010-07-08 13:09:47 +0000338
Chandler Carruth3aa81402011-05-01 23:48:14 +0000339 if (E->hasFoundDecl())
Douglas Gregor409448c2011-07-21 22:35:25 +0000340 E->getInternalFoundDecl() = ReadDeclAs<NamedDecl>(Record, Idx);
Chandler Carruth3aa81402011-05-01 23:48:14 +0000341
Chandler Carruthcb66cff2011-05-01 21:29:53 +0000342 if (E->hasExplicitTemplateArgs())
John McCall096832c2010-08-19 23:49:38 +0000343 ReadExplicitTemplateArgumentList(E->getExplicitTemplateArgs(),
Argyrios Kyrtzidis663e3802010-07-08 13:09:47 +0000344 NumTemplateArgs);
345
Douglas Gregor409448c2011-07-21 22:35:25 +0000346 E->setDecl(ReadDeclAs<ValueDecl>(Record, Idx));
Sebastian Redlc3632732010-10-05 15:59:54 +0000347 E->setLocation(ReadSourceLocation(Record, Idx));
Argyrios Kyrtzidis40451072010-10-15 18:21:24 +0000348 ReadDeclarationNameLoc(E->DNLoc, E->getDecl()->getDeclName(), Record, Idx);
Chris Lattner4c6f9522009-04-27 05:14:47 +0000349}
350
Sebastian Redl60adf4a2010-08-18 23:56:52 +0000351void ASTStmtReader::VisitIntegerLiteral(IntegerLiteral *E) {
Chris Lattner4c6f9522009-04-27 05:14:47 +0000352 VisitExpr(E);
Sebastian Redlc3632732010-10-05 15:59:54 +0000353 E->setLocation(ReadSourceLocation(Record, Idx));
Douglas Gregor35942772011-09-09 21:34:22 +0000354 E->setValue(Reader.getContext(), Reader.ReadAPInt(Record, Idx));
Chris Lattner4c6f9522009-04-27 05:14:47 +0000355}
356
Sebastian Redl60adf4a2010-08-18 23:56:52 +0000357void ASTStmtReader::VisitFloatingLiteral(FloatingLiteral *E) {
Chris Lattner4c6f9522009-04-27 05:14:47 +0000358 VisitExpr(E);
Douglas Gregor35942772011-09-09 21:34:22 +0000359 E->setValue(Reader.getContext(), Reader.ReadAPFloat(Record, Idx));
Chris Lattner4c6f9522009-04-27 05:14:47 +0000360 E->setExact(Record[Idx++]);
Sebastian Redlc3632732010-10-05 15:59:54 +0000361 E->setLocation(ReadSourceLocation(Record, Idx));
Chris Lattner4c6f9522009-04-27 05:14:47 +0000362}
363
Sebastian Redl60adf4a2010-08-18 23:56:52 +0000364void ASTStmtReader::VisitImaginaryLiteral(ImaginaryLiteral *E) {
Chris Lattner4c6f9522009-04-27 05:14:47 +0000365 VisitExpr(E);
Argyrios Kyrtzidisd98a2ab2010-06-29 22:46:25 +0000366 E->setSubExpr(Reader.ReadSubExpr());
Chris Lattner4c6f9522009-04-27 05:14:47 +0000367}
368
Sebastian Redl60adf4a2010-08-18 23:56:52 +0000369void ASTStmtReader::VisitStringLiteral(StringLiteral *E) {
Chris Lattner4c6f9522009-04-27 05:14:47 +0000370 VisitExpr(E);
371 unsigned Len = Record[Idx++];
Mike Stump1eb44332009-09-09 15:08:12 +0000372 assert(Record[Idx] == E->getNumConcatenated() &&
Chris Lattner4c6f9522009-04-27 05:14:47 +0000373 "Wrong number of concatenated tokens!");
374 ++Idx;
Eli Friedman64f45a22011-11-01 02:23:42 +0000375 StringLiteral::StringKind kind =
376 static_cast<StringLiteral::StringKind>(Record[Idx++]);
377 bool isPascal = Record[Idx++];
Chris Lattner4c6f9522009-04-27 05:14:47 +0000378
Mike Stump1eb44332009-09-09 15:08:12 +0000379 // Read string data
Daniel Dunbarb6480232009-09-22 03:27:33 +0000380 llvm::SmallString<16> Str(&Record[Idx], &Record[Idx] + Len);
Eli Friedman64f45a22011-11-01 02:23:42 +0000381 E->setString(Reader.getContext(), Str.str(), kind, isPascal);
Chris Lattner4c6f9522009-04-27 05:14:47 +0000382 Idx += Len;
383
384 // Read source locations
385 for (unsigned I = 0, N = E->getNumConcatenated(); I != N; ++I)
Sebastian Redlc3632732010-10-05 15:59:54 +0000386 E->setStrTokenLoc(I, ReadSourceLocation(Record, Idx));
Chris Lattner4c6f9522009-04-27 05:14:47 +0000387}
388
Sebastian Redl60adf4a2010-08-18 23:56:52 +0000389void ASTStmtReader::VisitCharacterLiteral(CharacterLiteral *E) {
Chris Lattner4c6f9522009-04-27 05:14:47 +0000390 VisitExpr(E);
391 E->setValue(Record[Idx++]);
Sebastian Redlc3632732010-10-05 15:59:54 +0000392 E->setLocation(ReadSourceLocation(Record, Idx));
Douglas Gregor5cee1192011-07-27 05:40:30 +0000393 E->setKind(static_cast<CharacterLiteral::CharacterKind>(Record[Idx++]));
Chris Lattner4c6f9522009-04-27 05:14:47 +0000394}
395
Sebastian Redl60adf4a2010-08-18 23:56:52 +0000396void ASTStmtReader::VisitParenExpr(ParenExpr *E) {
Chris Lattner4c6f9522009-04-27 05:14:47 +0000397 VisitExpr(E);
Sebastian Redlc3632732010-10-05 15:59:54 +0000398 E->setLParen(ReadSourceLocation(Record, Idx));
399 E->setRParen(ReadSourceLocation(Record, Idx));
Argyrios Kyrtzidisd98a2ab2010-06-29 22:46:25 +0000400 E->setSubExpr(Reader.ReadSubExpr());
Chris Lattner4c6f9522009-04-27 05:14:47 +0000401}
402
Sebastian Redl60adf4a2010-08-18 23:56:52 +0000403void ASTStmtReader::VisitParenListExpr(ParenListExpr *E) {
Argyrios Kyrtzidis37bdfe22010-06-30 08:49:18 +0000404 VisitExpr(E);
405 unsigned NumExprs = Record[Idx++];
Douglas Gregor35942772011-09-09 21:34:22 +0000406 E->Exprs = new (Reader.getContext()) Stmt*[NumExprs];
Argyrios Kyrtzidis37bdfe22010-06-30 08:49:18 +0000407 for (unsigned i = 0; i != NumExprs; ++i)
408 E->Exprs[i] = Reader.ReadSubStmt();
409 E->NumExprs = NumExprs;
Sebastian Redlc3632732010-10-05 15:59:54 +0000410 E->LParenLoc = ReadSourceLocation(Record, Idx);
411 E->RParenLoc = ReadSourceLocation(Record, Idx);
Argyrios Kyrtzidis37bdfe22010-06-30 08:49:18 +0000412}
413
Sebastian Redl60adf4a2010-08-18 23:56:52 +0000414void ASTStmtReader::VisitUnaryOperator(UnaryOperator *E) {
Chris Lattner4c6f9522009-04-27 05:14:47 +0000415 VisitExpr(E);
Argyrios Kyrtzidisd98a2ab2010-06-29 22:46:25 +0000416 E->setSubExpr(Reader.ReadSubExpr());
Chris Lattner4c6f9522009-04-27 05:14:47 +0000417 E->setOpcode((UnaryOperator::Opcode)Record[Idx++]);
Sebastian Redlc3632732010-10-05 15:59:54 +0000418 E->setOperatorLoc(ReadSourceLocation(Record, Idx));
Chris Lattner4c6f9522009-04-27 05:14:47 +0000419}
420
Sebastian Redl60adf4a2010-08-18 23:56:52 +0000421void ASTStmtReader::VisitOffsetOfExpr(OffsetOfExpr *E) {
Douglas Gregor8ecdb652010-04-28 22:16:22 +0000422 typedef OffsetOfExpr::OffsetOfNode Node;
423 VisitExpr(E);
424 assert(E->getNumComponents() == Record[Idx]);
425 ++Idx;
426 assert(E->getNumExpressions() == Record[Idx]);
427 ++Idx;
Sebastian Redlc3632732010-10-05 15:59:54 +0000428 E->setOperatorLoc(ReadSourceLocation(Record, Idx));
429 E->setRParenLoc(ReadSourceLocation(Record, Idx));
430 E->setTypeSourceInfo(GetTypeSourceInfo(Record, Idx));
Douglas Gregor8ecdb652010-04-28 22:16:22 +0000431 for (unsigned I = 0, N = E->getNumComponents(); I != N; ++I) {
432 Node::Kind Kind = static_cast<Node::Kind>(Record[Idx++]);
Sebastian Redlc3632732010-10-05 15:59:54 +0000433 SourceLocation Start = ReadSourceLocation(Record, Idx);
434 SourceLocation End = ReadSourceLocation(Record, Idx);
Douglas Gregor8ecdb652010-04-28 22:16:22 +0000435 switch (Kind) {
436 case Node::Array:
437 E->setComponent(I, Node(Start, Record[Idx++], End));
438 break;
439
440 case Node::Field:
Douglas Gregor409448c2011-07-21 22:35:25 +0000441 E->setComponent(I, Node(Start, ReadDeclAs<FieldDecl>(Record, Idx), End));
Douglas Gregor8ecdb652010-04-28 22:16:22 +0000442 break;
443
444 case Node::Identifier:
Douglas Gregor95eab172011-07-28 20:55:49 +0000445 E->setComponent(I,
446 Node(Start,
447 Reader.GetIdentifierInfo(F, Record, Idx),
448 End));
Douglas Gregor8ecdb652010-04-28 22:16:22 +0000449 break;
Douglas Gregorcc8a5d52010-04-29 00:18:15 +0000450
Argyrios Kyrtzidisafbf3122010-07-29 18:16:10 +0000451 case Node::Base: {
Douglas Gregor35942772011-09-09 21:34:22 +0000452 CXXBaseSpecifier *Base = new (Reader.getContext()) CXXBaseSpecifier();
Sebastian Redlc3632732010-10-05 15:59:54 +0000453 *Base = Reader.ReadCXXBaseSpecifier(F, Record, Idx);
Argyrios Kyrtzidisafbf3122010-07-29 18:16:10 +0000454 E->setComponent(I, Node(Base));
Douglas Gregorcc8a5d52010-04-29 00:18:15 +0000455 break;
Douglas Gregor8ecdb652010-04-28 22:16:22 +0000456 }
Argyrios Kyrtzidisafbf3122010-07-29 18:16:10 +0000457 }
Douglas Gregor8ecdb652010-04-28 22:16:22 +0000458 }
459
460 for (unsigned I = 0, N = E->getNumExpressions(); I != N; ++I)
Argyrios Kyrtzidisd98a2ab2010-06-29 22:46:25 +0000461 E->setIndexExpr(I, Reader.ReadSubExpr());
Douglas Gregor8ecdb652010-04-28 22:16:22 +0000462}
463
Peter Collingbournef4e3cfb2011-03-11 19:24:49 +0000464void ASTStmtReader::VisitUnaryExprOrTypeTraitExpr(UnaryExprOrTypeTraitExpr *E) {
Chris Lattner4c6f9522009-04-27 05:14:47 +0000465 VisitExpr(E);
Peter Collingbournef4e3cfb2011-03-11 19:24:49 +0000466 E->setKind(static_cast<UnaryExprOrTypeTrait>(Record[Idx++]));
Chris Lattner4c6f9522009-04-27 05:14:47 +0000467 if (Record[Idx] == 0) {
Argyrios Kyrtzidisd98a2ab2010-06-29 22:46:25 +0000468 E->setArgument(Reader.ReadSubExpr());
Chris Lattner4c6f9522009-04-27 05:14:47 +0000469 ++Idx;
470 } else {
Sebastian Redlc3632732010-10-05 15:59:54 +0000471 E->setArgument(GetTypeSourceInfo(Record, Idx));
Chris Lattner4c6f9522009-04-27 05:14:47 +0000472 }
Sebastian Redlc3632732010-10-05 15:59:54 +0000473 E->setOperatorLoc(ReadSourceLocation(Record, Idx));
474 E->setRParenLoc(ReadSourceLocation(Record, Idx));
Chris Lattner4c6f9522009-04-27 05:14:47 +0000475}
476
Sebastian Redl60adf4a2010-08-18 23:56:52 +0000477void ASTStmtReader::VisitArraySubscriptExpr(ArraySubscriptExpr *E) {
Chris Lattner4c6f9522009-04-27 05:14:47 +0000478 VisitExpr(E);
Argyrios Kyrtzidisd98a2ab2010-06-29 22:46:25 +0000479 E->setLHS(Reader.ReadSubExpr());
480 E->setRHS(Reader.ReadSubExpr());
Sebastian Redlc3632732010-10-05 15:59:54 +0000481 E->setRBracketLoc(ReadSourceLocation(Record, Idx));
Chris Lattner4c6f9522009-04-27 05:14:47 +0000482}
483
Sebastian Redl60adf4a2010-08-18 23:56:52 +0000484void ASTStmtReader::VisitCallExpr(CallExpr *E) {
Chris Lattner4c6f9522009-04-27 05:14:47 +0000485 VisitExpr(E);
Douglas Gregor35942772011-09-09 21:34:22 +0000486 E->setNumArgs(Reader.getContext(), Record[Idx++]);
Sebastian Redlc3632732010-10-05 15:59:54 +0000487 E->setRParenLoc(ReadSourceLocation(Record, Idx));
Argyrios Kyrtzidisd98a2ab2010-06-29 22:46:25 +0000488 E->setCallee(Reader.ReadSubExpr());
Chris Lattner4c6f9522009-04-27 05:14:47 +0000489 for (unsigned I = 0, N = E->getNumArgs(); I != N; ++I)
Argyrios Kyrtzidisd98a2ab2010-06-29 22:46:25 +0000490 E->setArg(I, Reader.ReadSubExpr());
Chris Lattner4c6f9522009-04-27 05:14:47 +0000491}
492
John McCall7110fd62011-07-15 07:00:14 +0000493void ASTStmtReader::VisitCXXMemberCallExpr(CXXMemberCallExpr *E) {
494 VisitCallExpr(E);
495}
496
Sebastian Redl60adf4a2010-08-18 23:56:52 +0000497void ASTStmtReader::VisitMemberExpr(MemberExpr *E) {
Argyrios Kyrtzidis663e3802010-07-08 13:09:47 +0000498 // Don't call VisitExpr, this is fully initialized at creation.
499 assert(E->getStmtClass() == Stmt::MemberExprClass &&
500 "It's a subclass, we must advance Idx!");
Chris Lattner4c6f9522009-04-27 05:14:47 +0000501}
502
Sebastian Redl60adf4a2010-08-18 23:56:52 +0000503void ASTStmtReader::VisitObjCIsaExpr(ObjCIsaExpr *E) {
Steve Narofff242b1b2009-07-24 17:54:45 +0000504 VisitExpr(E);
Argyrios Kyrtzidisd98a2ab2010-06-29 22:46:25 +0000505 E->setBase(Reader.ReadSubExpr());
Sebastian Redlc3632732010-10-05 15:59:54 +0000506 E->setIsaMemberLoc(ReadSourceLocation(Record, Idx));
Steve Narofff242b1b2009-07-24 17:54:45 +0000507 E->setArrow(Record[Idx++]);
Steve Narofff242b1b2009-07-24 17:54:45 +0000508}
509
John McCallf85e1932011-06-15 23:02:42 +0000510void ASTStmtReader::
511VisitObjCIndirectCopyRestoreExpr(ObjCIndirectCopyRestoreExpr *E) {
512 VisitExpr(E);
513 E->Operand = Reader.ReadSubExpr();
514 E->setShouldCopy(Record[Idx++]);
515}
516
517void ASTStmtReader::VisitObjCBridgedCastExpr(ObjCBridgedCastExpr *E) {
518 VisitExplicitCastExpr(E);
519 E->LParenLoc = ReadSourceLocation(Record, Idx);
520 E->BridgeKeywordLoc = ReadSourceLocation(Record, Idx);
521 E->Kind = Record[Idx++];
522}
523
Sebastian Redl60adf4a2010-08-18 23:56:52 +0000524void ASTStmtReader::VisitCastExpr(CastExpr *E) {
Chris Lattner4c6f9522009-04-27 05:14:47 +0000525 VisitExpr(E);
John McCallf871d0c2010-08-07 06:22:56 +0000526 unsigned NumBaseSpecs = Record[Idx++];
527 assert(NumBaseSpecs == E->path_size());
Argyrios Kyrtzidisd98a2ab2010-06-29 22:46:25 +0000528 E->setSubExpr(Reader.ReadSubExpr());
Anders Carlssoncdef2b72009-07-31 00:48:10 +0000529 E->setCastKind((CastExpr::CastKind)Record[Idx++]);
John McCallf871d0c2010-08-07 06:22:56 +0000530 CastExpr::path_iterator BaseI = E->path_begin();
Argyrios Kyrtzidis0745d0a2010-07-02 23:30:27 +0000531 while (NumBaseSpecs--) {
Douglas Gregor35942772011-09-09 21:34:22 +0000532 CXXBaseSpecifier *BaseSpec = new (Reader.getContext()) CXXBaseSpecifier;
Sebastian Redlc3632732010-10-05 15:59:54 +0000533 *BaseSpec = Reader.ReadCXXBaseSpecifier(F, Record, Idx);
John McCallf871d0c2010-08-07 06:22:56 +0000534 *BaseI++ = BaseSpec;
Argyrios Kyrtzidis0745d0a2010-07-02 23:30:27 +0000535 }
Chris Lattner4c6f9522009-04-27 05:14:47 +0000536}
537
Sebastian Redl60adf4a2010-08-18 23:56:52 +0000538void ASTStmtReader::VisitBinaryOperator(BinaryOperator *E) {
Chris Lattner4c6f9522009-04-27 05:14:47 +0000539 VisitExpr(E);
Argyrios Kyrtzidisd98a2ab2010-06-29 22:46:25 +0000540 E->setLHS(Reader.ReadSubExpr());
541 E->setRHS(Reader.ReadSubExpr());
Chris Lattner4c6f9522009-04-27 05:14:47 +0000542 E->setOpcode((BinaryOperator::Opcode)Record[Idx++]);
Sebastian Redlc3632732010-10-05 15:59:54 +0000543 E->setOperatorLoc(ReadSourceLocation(Record, Idx));
Chris Lattner4c6f9522009-04-27 05:14:47 +0000544}
545
Sebastian Redl60adf4a2010-08-18 23:56:52 +0000546void ASTStmtReader::VisitCompoundAssignOperator(CompoundAssignOperator *E) {
Chris Lattner4c6f9522009-04-27 05:14:47 +0000547 VisitBinaryOperator(E);
Douglas Gregor393f2492011-07-22 00:38:23 +0000548 E->setComputationLHSType(Reader.readType(F, Record, Idx));
549 E->setComputationResultType(Reader.readType(F, Record, Idx));
Chris Lattner4c6f9522009-04-27 05:14:47 +0000550}
551
Sebastian Redl60adf4a2010-08-18 23:56:52 +0000552void ASTStmtReader::VisitConditionalOperator(ConditionalOperator *E) {
Chris Lattner4c6f9522009-04-27 05:14:47 +0000553 VisitExpr(E);
John McCall56ca35d2011-02-17 10:25:35 +0000554 E->SubExprs[ConditionalOperator::COND] = Reader.ReadSubExpr();
555 E->SubExprs[ConditionalOperator::LHS] = Reader.ReadSubExpr();
556 E->SubExprs[ConditionalOperator::RHS] = Reader.ReadSubExpr();
557 E->QuestionLoc = ReadSourceLocation(Record, Idx);
558 E->ColonLoc = ReadSourceLocation(Record, Idx);
559}
560
561void
562ASTStmtReader::VisitBinaryConditionalOperator(BinaryConditionalOperator *E) {
563 VisitExpr(E);
564 E->OpaqueValue = cast<OpaqueValueExpr>(Reader.ReadSubExpr());
565 E->SubExprs[BinaryConditionalOperator::COMMON] = Reader.ReadSubExpr();
566 E->SubExprs[BinaryConditionalOperator::COND] = Reader.ReadSubExpr();
567 E->SubExprs[BinaryConditionalOperator::LHS] = Reader.ReadSubExpr();
568 E->SubExprs[BinaryConditionalOperator::RHS] = Reader.ReadSubExpr();
569 E->QuestionLoc = ReadSourceLocation(Record, Idx);
570 E->ColonLoc = ReadSourceLocation(Record, Idx);
571
572 E->getOpaqueValue()->setSourceExpr(E->getCommon());
Chris Lattner4c6f9522009-04-27 05:14:47 +0000573}
574
Sebastian Redl60adf4a2010-08-18 23:56:52 +0000575void ASTStmtReader::VisitImplicitCastExpr(ImplicitCastExpr *E) {
Chris Lattner4c6f9522009-04-27 05:14:47 +0000576 VisitCastExpr(E);
Chris Lattner4c6f9522009-04-27 05:14:47 +0000577}
578
Sebastian Redl60adf4a2010-08-18 23:56:52 +0000579void ASTStmtReader::VisitExplicitCastExpr(ExplicitCastExpr *E) {
Chris Lattner4c6f9522009-04-27 05:14:47 +0000580 VisitCastExpr(E);
Sebastian Redlc3632732010-10-05 15:59:54 +0000581 E->setTypeInfoAsWritten(GetTypeSourceInfo(Record, Idx));
Chris Lattner4c6f9522009-04-27 05:14:47 +0000582}
583
Sebastian Redl60adf4a2010-08-18 23:56:52 +0000584void ASTStmtReader::VisitCStyleCastExpr(CStyleCastExpr *E) {
Chris Lattner4c6f9522009-04-27 05:14:47 +0000585 VisitExplicitCastExpr(E);
Sebastian Redlc3632732010-10-05 15:59:54 +0000586 E->setLParenLoc(ReadSourceLocation(Record, Idx));
587 E->setRParenLoc(ReadSourceLocation(Record, Idx));
Chris Lattner4c6f9522009-04-27 05:14:47 +0000588}
589
Sebastian Redl60adf4a2010-08-18 23:56:52 +0000590void ASTStmtReader::VisitCompoundLiteralExpr(CompoundLiteralExpr *E) {
Chris Lattner4c6f9522009-04-27 05:14:47 +0000591 VisitExpr(E);
Sebastian Redlc3632732010-10-05 15:59:54 +0000592 E->setLParenLoc(ReadSourceLocation(Record, Idx));
593 E->setTypeSourceInfo(GetTypeSourceInfo(Record, Idx));
Argyrios Kyrtzidisd98a2ab2010-06-29 22:46:25 +0000594 E->setInitializer(Reader.ReadSubExpr());
Chris Lattner4c6f9522009-04-27 05:14:47 +0000595 E->setFileScope(Record[Idx++]);
Chris Lattner4c6f9522009-04-27 05:14:47 +0000596}
597
Sebastian Redl60adf4a2010-08-18 23:56:52 +0000598void ASTStmtReader::VisitExtVectorElementExpr(ExtVectorElementExpr *E) {
Chris Lattner4c6f9522009-04-27 05:14:47 +0000599 VisitExpr(E);
Argyrios Kyrtzidisd98a2ab2010-06-29 22:46:25 +0000600 E->setBase(Reader.ReadSubExpr());
Douglas Gregor95eab172011-07-28 20:55:49 +0000601 E->setAccessor(Reader.GetIdentifierInfo(F, Record, Idx));
Sebastian Redlc3632732010-10-05 15:59:54 +0000602 E->setAccessorLoc(ReadSourceLocation(Record, Idx));
Chris Lattner4c6f9522009-04-27 05:14:47 +0000603}
604
Sebastian Redl60adf4a2010-08-18 23:56:52 +0000605void ASTStmtReader::VisitInitListExpr(InitListExpr *E) {
Chris Lattner4c6f9522009-04-27 05:14:47 +0000606 VisitExpr(E);
Argyrios Kyrtzidisd98a2ab2010-06-29 22:46:25 +0000607 E->setSyntacticForm(cast_or_null<InitListExpr>(Reader.ReadSubStmt()));
Sebastian Redlc3632732010-10-05 15:59:54 +0000608 E->setLBraceLoc(ReadSourceLocation(Record, Idx));
609 E->setRBraceLoc(ReadSourceLocation(Record, Idx));
Argyrios Kyrtzidis2ac0b7a2011-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 Gregor409448c2011-07-21 22:35:25 +0000616 E->ArrayFillerOrUnionFieldInit = ReadDeclAs<FieldDecl>(Record, Idx);
Chris Lattner4c6f9522009-04-27 05:14:47 +0000617 E->sawArrayRangeDesignator(Record[Idx++]);
Argyrios Kyrtzidis2ac0b7a2011-04-22 05:29:30 +0000618 unsigned NumInits = Record[Idx++];
Douglas Gregor35942772011-09-09 21:34:22 +0000619 E->reserveInits(Reader.getContext(), NumInits);
Argyrios Kyrtzidis2ac0b7a2011-04-22 05:29:30 +0000620 if (isArrayFiller) {
621 for (unsigned I = 0; I != NumInits; ++I) {
622 Expr *init = Reader.ReadSubExpr();
Douglas Gregor35942772011-09-09 21:34:22 +0000623 E->updateInit(Reader.getContext(), I, init ? init : filler);
Argyrios Kyrtzidis2ac0b7a2011-04-22 05:29:30 +0000624 }
625 } else {
626 for (unsigned I = 0; I != NumInits; ++I)
Douglas Gregor35942772011-09-09 21:34:22 +0000627 E->updateInit(Reader.getContext(), I, Reader.ReadSubExpr());
Argyrios Kyrtzidis2ac0b7a2011-04-22 05:29:30 +0000628 }
Chris Lattner4c6f9522009-04-27 05:14:47 +0000629}
630
Sebastian Redl60adf4a2010-08-18 23:56:52 +0000631void ASTStmtReader::VisitDesignatedInitExpr(DesignatedInitExpr *E) {
Chris Lattner4c6f9522009-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 Kyrtzidisd98a2ab2010-06-29 22:46:25 +0000638 E->setSubExpr(I, Reader.ReadSubExpr());
Sebastian Redlc3632732010-10-05 15:59:54 +0000639 E->setEqualOrColonLoc(ReadSourceLocation(Record, Idx));
Chris Lattner4c6f9522009-04-27 05:14:47 +0000640 E->setGNUSyntax(Record[Idx++]);
641
Chris Lattner5f9e2722011-07-23 10:55:15 +0000642 SmallVector<Designator, 4> Designators;
Chris Lattner4c6f9522009-04-27 05:14:47 +0000643 while (Idx < Record.size()) {
Sebastian Redl8538e8d2010-08-18 23:57:32 +0000644 switch ((DesignatorTypes)Record[Idx++]) {
645 case DESIG_FIELD_DECL: {
Douglas Gregor409448c2011-07-21 22:35:25 +0000646 FieldDecl *Field = ReadDeclAs<FieldDecl>(Record, Idx);
Mike Stump1eb44332009-09-09 15:08:12 +0000647 SourceLocation DotLoc
Sebastian Redlc3632732010-10-05 15:59:54 +0000648 = ReadSourceLocation(Record, Idx);
Mike Stump1eb44332009-09-09 15:08:12 +0000649 SourceLocation FieldLoc
Sebastian Redlc3632732010-10-05 15:59:54 +0000650 = ReadSourceLocation(Record, Idx);
Mike Stump1eb44332009-09-09 15:08:12 +0000651 Designators.push_back(Designator(Field->getIdentifier(), DotLoc,
Chris Lattner4c6f9522009-04-27 05:14:47 +0000652 FieldLoc));
653 Designators.back().setField(Field);
654 break;
655 }
656
Sebastian Redl8538e8d2010-08-18 23:57:32 +0000657 case DESIG_FIELD_NAME: {
Douglas Gregor95eab172011-07-28 20:55:49 +0000658 const IdentifierInfo *Name = Reader.GetIdentifierInfo(F, Record, Idx);
Mike Stump1eb44332009-09-09 15:08:12 +0000659 SourceLocation DotLoc
Sebastian Redlc3632732010-10-05 15:59:54 +0000660 = ReadSourceLocation(Record, Idx);
Mike Stump1eb44332009-09-09 15:08:12 +0000661 SourceLocation FieldLoc
Sebastian Redlc3632732010-10-05 15:59:54 +0000662 = ReadSourceLocation(Record, Idx);
Chris Lattner4c6f9522009-04-27 05:14:47 +0000663 Designators.push_back(Designator(Name, DotLoc, FieldLoc));
664 break;
665 }
Mike Stump1eb44332009-09-09 15:08:12 +0000666
Sebastian Redl8538e8d2010-08-18 23:57:32 +0000667 case DESIG_ARRAY: {
Chris Lattner4c6f9522009-04-27 05:14:47 +0000668 unsigned Index = Record[Idx++];
669 SourceLocation LBracketLoc
Sebastian Redlc3632732010-10-05 15:59:54 +0000670 = ReadSourceLocation(Record, Idx);
Chris Lattner4c6f9522009-04-27 05:14:47 +0000671 SourceLocation RBracketLoc
Sebastian Redlc3632732010-10-05 15:59:54 +0000672 = ReadSourceLocation(Record, Idx);
Chris Lattner4c6f9522009-04-27 05:14:47 +0000673 Designators.push_back(Designator(Index, LBracketLoc, RBracketLoc));
674 break;
675 }
676
Sebastian Redl8538e8d2010-08-18 23:57:32 +0000677 case DESIG_ARRAY_RANGE: {
Chris Lattner4c6f9522009-04-27 05:14:47 +0000678 unsigned Index = Record[Idx++];
679 SourceLocation LBracketLoc
Sebastian Redlc3632732010-10-05 15:59:54 +0000680 = ReadSourceLocation(Record, Idx);
Chris Lattner4c6f9522009-04-27 05:14:47 +0000681 SourceLocation EllipsisLoc
Sebastian Redlc3632732010-10-05 15:59:54 +0000682 = ReadSourceLocation(Record, Idx);
Chris Lattner4c6f9522009-04-27 05:14:47 +0000683 SourceLocation RBracketLoc
Sebastian Redlc3632732010-10-05 15:59:54 +0000684 = ReadSourceLocation(Record, Idx);
Chris Lattner4c6f9522009-04-27 05:14:47 +0000685 Designators.push_back(Designator(Index, LBracketLoc, EllipsisLoc,
686 RBracketLoc));
687 break;
688 }
689 }
690 }
Douglas Gregor35942772011-09-09 21:34:22 +0000691 E->setDesignators(Reader.getContext(),
Douglas Gregor319d57f2010-01-06 23:17:19 +0000692 Designators.data(), Designators.size());
Chris Lattner4c6f9522009-04-27 05:14:47 +0000693}
694
Sebastian Redl60adf4a2010-08-18 23:56:52 +0000695void ASTStmtReader::VisitImplicitValueInitExpr(ImplicitValueInitExpr *E) {
Chris Lattner4c6f9522009-04-27 05:14:47 +0000696 VisitExpr(E);
Chris Lattner4c6f9522009-04-27 05:14:47 +0000697}
698
Sebastian Redl60adf4a2010-08-18 23:56:52 +0000699void ASTStmtReader::VisitVAArgExpr(VAArgExpr *E) {
Chris Lattner4c6f9522009-04-27 05:14:47 +0000700 VisitExpr(E);
Argyrios Kyrtzidisd98a2ab2010-06-29 22:46:25 +0000701 E->setSubExpr(Reader.ReadSubExpr());
Sebastian Redlc3632732010-10-05 15:59:54 +0000702 E->setWrittenTypeInfo(GetTypeSourceInfo(Record, Idx));
703 E->setBuiltinLoc(ReadSourceLocation(Record, Idx));
704 E->setRParenLoc(ReadSourceLocation(Record, Idx));
Chris Lattner4c6f9522009-04-27 05:14:47 +0000705}
706
Sebastian Redl60adf4a2010-08-18 23:56:52 +0000707void ASTStmtReader::VisitAddrLabelExpr(AddrLabelExpr *E) {
Chris Lattner4c6f9522009-04-27 05:14:47 +0000708 VisitExpr(E);
Sebastian Redlc3632732010-10-05 15:59:54 +0000709 E->setAmpAmpLoc(ReadSourceLocation(Record, Idx));
710 E->setLabelLoc(ReadSourceLocation(Record, Idx));
Douglas Gregor409448c2011-07-21 22:35:25 +0000711 E->setLabel(ReadDeclAs<LabelDecl>(Record, Idx));
Chris Lattner4c6f9522009-04-27 05:14:47 +0000712}
713
Sebastian Redl60adf4a2010-08-18 23:56:52 +0000714void ASTStmtReader::VisitStmtExpr(StmtExpr *E) {
Chris Lattner4c6f9522009-04-27 05:14:47 +0000715 VisitExpr(E);
Sebastian Redlc3632732010-10-05 15:59:54 +0000716 E->setLParenLoc(ReadSourceLocation(Record, Idx));
717 E->setRParenLoc(ReadSourceLocation(Record, Idx));
Argyrios Kyrtzidisd98a2ab2010-06-29 22:46:25 +0000718 E->setSubStmt(cast_or_null<CompoundStmt>(Reader.ReadSubStmt()));
Chris Lattner4c6f9522009-04-27 05:14:47 +0000719}
720
Sebastian Redl60adf4a2010-08-18 23:56:52 +0000721void ASTStmtReader::VisitChooseExpr(ChooseExpr *E) {
Chris Lattner4c6f9522009-04-27 05:14:47 +0000722 VisitExpr(E);
Argyrios Kyrtzidisd98a2ab2010-06-29 22:46:25 +0000723 E->setCond(Reader.ReadSubExpr());
724 E->setLHS(Reader.ReadSubExpr());
725 E->setRHS(Reader.ReadSubExpr());
Sebastian Redlc3632732010-10-05 15:59:54 +0000726 E->setBuiltinLoc(ReadSourceLocation(Record, Idx));
727 E->setRParenLoc(ReadSourceLocation(Record, Idx));
Chris Lattner4c6f9522009-04-27 05:14:47 +0000728}
729
Sebastian Redl60adf4a2010-08-18 23:56:52 +0000730void ASTStmtReader::VisitGNUNullExpr(GNUNullExpr *E) {
Chris Lattner4c6f9522009-04-27 05:14:47 +0000731 VisitExpr(E);
Sebastian Redlc3632732010-10-05 15:59:54 +0000732 E->setTokenLocation(ReadSourceLocation(Record, Idx));
Chris Lattner4c6f9522009-04-27 05:14:47 +0000733}
734
Sebastian Redl60adf4a2010-08-18 23:56:52 +0000735void ASTStmtReader::VisitShuffleVectorExpr(ShuffleVectorExpr *E) {
Chris Lattner4c6f9522009-04-27 05:14:47 +0000736 VisitExpr(E);
Chris Lattner5f9e2722011-07-23 10:55:15 +0000737 SmallVector<Expr *, 16> Exprs;
Chris Lattner4c6f9522009-04-27 05:14:47 +0000738 unsigned NumExprs = Record[Idx++];
Argyrios Kyrtzidis919e6932010-06-28 22:28:35 +0000739 while (NumExprs--)
Argyrios Kyrtzidisd98a2ab2010-06-29 22:46:25 +0000740 Exprs.push_back(Reader.ReadSubExpr());
Douglas Gregor35942772011-09-09 21:34:22 +0000741 E->setExprs(Reader.getContext(), Exprs.data(), Exprs.size());
Sebastian Redlc3632732010-10-05 15:59:54 +0000742 E->setBuiltinLoc(ReadSourceLocation(Record, Idx));
743 E->setRParenLoc(ReadSourceLocation(Record, Idx));
Chris Lattner4c6f9522009-04-27 05:14:47 +0000744}
745
Sebastian Redl60adf4a2010-08-18 23:56:52 +0000746void ASTStmtReader::VisitBlockExpr(BlockExpr *E) {
Chris Lattner4c6f9522009-04-27 05:14:47 +0000747 VisitExpr(E);
Douglas Gregor409448c2011-07-21 22:35:25 +0000748 E->setBlockDecl(ReadDeclAs<BlockDecl>(Record, Idx));
Chris Lattner4c6f9522009-04-27 05:14:47 +0000749}
750
Sebastian Redl60adf4a2010-08-18 23:56:52 +0000751void ASTStmtReader::VisitBlockDeclRefExpr(BlockDeclRefExpr *E) {
Chris Lattner4c6f9522009-04-27 05:14:47 +0000752 VisitExpr(E);
Douglas Gregor409448c2011-07-21 22:35:25 +0000753 E->setDecl(ReadDeclAs<VarDecl>(Record, Idx));
Sebastian Redlc3632732010-10-05 15:59:54 +0000754 E->setLocation(ReadSourceLocation(Record, Idx));
Chris Lattner4c6f9522009-04-27 05:14:47 +0000755 E->setByRef(Record[Idx++]);
Fariborz Jahanian9b0b57c2009-06-20 00:02:26 +0000756 E->setConstQualAdded(Record[Idx++]);
Chris Lattner4c6f9522009-04-27 05:14:47 +0000757}
758
Peter Collingbournef111d932011-04-15 00:35:48 +0000759void ASTStmtReader::VisitGenericSelectionExpr(GenericSelectionExpr *E) {
760 VisitExpr(E);
761 E->NumAssocs = Record[Idx++];
Douglas Gregor35942772011-09-09 21:34:22 +0000762 E->AssocTypes = new (Reader.getContext()) TypeSourceInfo*[E->NumAssocs];
Peter Collingbournef111d932011-04-15 00:35:48 +0000763 E->SubExprs =
Douglas Gregor35942772011-09-09 21:34:22 +0000764 new(Reader.getContext()) Stmt*[GenericSelectionExpr::END_EXPR+E->NumAssocs];
Peter Collingbournef111d932011-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
John McCall4b9c2d22011-11-06 09:01:30 +0000778void ASTStmtReader::VisitPseudoObjectExpr(PseudoObjectExpr *E) {
779 VisitExpr(E);
780 unsigned numSemanticExprs = Record[Idx++];
781 assert(numSemanticExprs + 1 == E->PseudoObjectExprBits.NumSubExprs);
782 E->PseudoObjectExprBits.ResultIndex = Record[Idx++];
783
784 // Read the syntactic expression.
785 E->getSubExprsBuffer()[0] = Reader.ReadSubExpr();
786
787 // Read all the semantic expressions.
788 for (unsigned i = 0; i != numSemanticExprs; ++i) {
789 Expr *subExpr = Reader.ReadSubExpr();
790 if (isa<OpaqueValueExpr>(subExpr))
791 cast<OpaqueValueExpr>(subExpr)->setSourceExpr(Reader.ReadSubExpr());
792 E->getSubExprsBuffer()[i+1] = subExpr;
793 }
794}
795
Eli Friedman276b0612011-10-11 02:20:01 +0000796void ASTStmtReader::VisitAtomicExpr(AtomicExpr *E) {
797 VisitExpr(E);
798 E->setOp(AtomicExpr::AtomicOp(Record[Idx++]));
799 E->setPtr(Reader.ReadSubExpr());
800 E->setOrder(Reader.ReadSubExpr());
801 E->setNumSubExprs(2);
802 if (E->getOp() != AtomicExpr::Load) {
803 E->setVal1(Reader.ReadSubExpr());
804 E->setNumSubExprs(3);
805 }
806 if (E->isCmpXChg()) {
807 E->setOrderFail(Reader.ReadSubExpr());
808 E->setVal2(Reader.ReadSubExpr());
809 E->setNumSubExprs(5);
810 }
811 E->setBuiltinLoc(ReadSourceLocation(Record, Idx));
812 E->setRParenLoc(ReadSourceLocation(Record, Idx));
813}
814
Chris Lattner4c6f9522009-04-27 05:14:47 +0000815//===----------------------------------------------------------------------===//
816// Objective-C Expressions and Statements
817
Sebastian Redl60adf4a2010-08-18 23:56:52 +0000818void ASTStmtReader::VisitObjCStringLiteral(ObjCStringLiteral *E) {
Chris Lattner4c6f9522009-04-27 05:14:47 +0000819 VisitExpr(E);
Argyrios Kyrtzidisd98a2ab2010-06-29 22:46:25 +0000820 E->setString(cast<StringLiteral>(Reader.ReadSubStmt()));
Sebastian Redlc3632732010-10-05 15:59:54 +0000821 E->setAtLoc(ReadSourceLocation(Record, Idx));
Chris Lattner4c6f9522009-04-27 05:14:47 +0000822}
823
Sebastian Redl60adf4a2010-08-18 23:56:52 +0000824void ASTStmtReader::VisitObjCEncodeExpr(ObjCEncodeExpr *E) {
Chris Lattner4c6f9522009-04-27 05:14:47 +0000825 VisitExpr(E);
Sebastian Redlc3632732010-10-05 15:59:54 +0000826 E->setEncodedTypeSourceInfo(GetTypeSourceInfo(Record, Idx));
827 E->setAtLoc(ReadSourceLocation(Record, Idx));
828 E->setRParenLoc(ReadSourceLocation(Record, Idx));
Chris Lattner4c6f9522009-04-27 05:14:47 +0000829}
830
Sebastian Redl60adf4a2010-08-18 23:56:52 +0000831void ASTStmtReader::VisitObjCSelectorExpr(ObjCSelectorExpr *E) {
Chris Lattner4c6f9522009-04-27 05:14:47 +0000832 VisitExpr(E);
Douglas Gregor2d2689a2011-07-28 21:16:51 +0000833 E->setSelector(Reader.ReadSelector(F, Record, Idx));
Sebastian Redlc3632732010-10-05 15:59:54 +0000834 E->setAtLoc(ReadSourceLocation(Record, Idx));
835 E->setRParenLoc(ReadSourceLocation(Record, Idx));
Chris Lattner4c6f9522009-04-27 05:14:47 +0000836}
837
Sebastian Redl60adf4a2010-08-18 23:56:52 +0000838void ASTStmtReader::VisitObjCProtocolExpr(ObjCProtocolExpr *E) {
Chris Lattner4c6f9522009-04-27 05:14:47 +0000839 VisitExpr(E);
Douglas Gregor409448c2011-07-21 22:35:25 +0000840 E->setProtocol(ReadDeclAs<ObjCProtocolDecl>(Record, Idx));
Sebastian Redlc3632732010-10-05 15:59:54 +0000841 E->setAtLoc(ReadSourceLocation(Record, Idx));
842 E->setRParenLoc(ReadSourceLocation(Record, Idx));
Chris Lattner4c6f9522009-04-27 05:14:47 +0000843}
844
Sebastian Redl60adf4a2010-08-18 23:56:52 +0000845void ASTStmtReader::VisitObjCIvarRefExpr(ObjCIvarRefExpr *E) {
Chris Lattner4c6f9522009-04-27 05:14:47 +0000846 VisitExpr(E);
Douglas Gregor409448c2011-07-21 22:35:25 +0000847 E->setDecl(ReadDeclAs<ObjCIvarDecl>(Record, Idx));
Sebastian Redlc3632732010-10-05 15:59:54 +0000848 E->setLocation(ReadSourceLocation(Record, Idx));
Argyrios Kyrtzidisd98a2ab2010-06-29 22:46:25 +0000849 E->setBase(Reader.ReadSubExpr());
Chris Lattner4c6f9522009-04-27 05:14:47 +0000850 E->setIsArrow(Record[Idx++]);
851 E->setIsFreeIvar(Record[Idx++]);
Chris Lattner4c6f9522009-04-27 05:14:47 +0000852}
853
Sebastian Redl60adf4a2010-08-18 23:56:52 +0000854void ASTStmtReader::VisitObjCPropertyRefExpr(ObjCPropertyRefExpr *E) {
Chris Lattner4c6f9522009-04-27 05:14:47 +0000855 VisitExpr(E);
John McCall12f78a62010-12-02 01:19:52 +0000856 bool Implicit = Record[Idx++] != 0;
857 if (Implicit) {
Douglas Gregor409448c2011-07-21 22:35:25 +0000858 ObjCMethodDecl *Getter = ReadDeclAs<ObjCMethodDecl>(Record, Idx);
859 ObjCMethodDecl *Setter = ReadDeclAs<ObjCMethodDecl>(Record, Idx);
John McCall12f78a62010-12-02 01:19:52 +0000860 E->setImplicitProperty(Getter, Setter);
861 } else {
Douglas Gregor409448c2011-07-21 22:35:25 +0000862 E->setExplicitProperty(ReadDeclAs<ObjCPropertyDecl>(Record, Idx));
Fariborz Jahanian8ac2d442010-10-14 16:04:05 +0000863 }
Sebastian Redlc3632732010-10-05 15:59:54 +0000864 E->setLocation(ReadSourceLocation(Record, Idx));
John McCall12f78a62010-12-02 01:19:52 +0000865 E->setReceiverLocation(ReadSourceLocation(Record, Idx));
866 switch (Record[Idx++]) {
867 case 0:
868 E->setBase(Reader.ReadSubExpr());
869 break;
870 case 1:
Douglas Gregor393f2492011-07-22 00:38:23 +0000871 E->setSuperReceiver(Reader.readType(F, Record, Idx));
John McCall12f78a62010-12-02 01:19:52 +0000872 break;
873 case 2:
Douglas Gregor409448c2011-07-21 22:35:25 +0000874 E->setClassReceiver(ReadDeclAs<ObjCInterfaceDecl>(Record, Idx));
John McCall12f78a62010-12-02 01:19:52 +0000875 break;
876 }
Chris Lattner4c6f9522009-04-27 05:14:47 +0000877}
878
Sebastian Redl60adf4a2010-08-18 23:56:52 +0000879void ASTStmtReader::VisitObjCMessageExpr(ObjCMessageExpr *E) {
Chris Lattner4c6f9522009-04-27 05:14:47 +0000880 VisitExpr(E);
Douglas Gregor04badcf2010-04-21 00:45:42 +0000881 assert(Record[Idx] == E->getNumArgs());
882 ++Idx;
Argyrios Kyrtzidis20718082011-10-03 06:36:51 +0000883 unsigned NumStoredSelLocs = Record[Idx++];
884 E->SelLocsKind = Record[Idx++];
John McCallf85e1932011-06-15 23:02:42 +0000885 E->setDelegateInitCall(Record[Idx++]);
Douglas Gregor04badcf2010-04-21 00:45:42 +0000886 ObjCMessageExpr::ReceiverKind Kind
887 = static_cast<ObjCMessageExpr::ReceiverKind>(Record[Idx++]);
888 switch (Kind) {
889 case ObjCMessageExpr::Instance:
Argyrios Kyrtzidisd98a2ab2010-06-29 22:46:25 +0000890 E->setInstanceReceiver(Reader.ReadSubExpr());
Douglas Gregor04badcf2010-04-21 00:45:42 +0000891 break;
892
893 case ObjCMessageExpr::Class:
Sebastian Redlc3632732010-10-05 15:59:54 +0000894 E->setClassReceiver(GetTypeSourceInfo(Record, Idx));
Douglas Gregor04badcf2010-04-21 00:45:42 +0000895 break;
896
897 case ObjCMessageExpr::SuperClass:
898 case ObjCMessageExpr::SuperInstance: {
Douglas Gregor393f2492011-07-22 00:38:23 +0000899 QualType T = Reader.readType(F, Record, Idx);
Sebastian Redlc3632732010-10-05 15:59:54 +0000900 SourceLocation SuperLoc = ReadSourceLocation(Record, Idx);
Douglas Gregor04badcf2010-04-21 00:45:42 +0000901 E->setSuper(SuperLoc, T, Kind == ObjCMessageExpr::SuperInstance);
902 break;
903 }
904 }
905
906 assert(Kind == E->getReceiverKind());
907
908 if (Record[Idx++])
Douglas Gregor409448c2011-07-21 22:35:25 +0000909 E->setMethodDecl(ReadDeclAs<ObjCMethodDecl>(Record, Idx));
Douglas Gregor04badcf2010-04-21 00:45:42 +0000910 else
Douglas Gregor2d2689a2011-07-28 21:16:51 +0000911 E->setSelector(Reader.ReadSelector(F, Record, Idx));
Douglas Gregor04badcf2010-04-21 00:45:42 +0000912
Argyrios Kyrtzidisf40f0d52010-12-10 20:08:27 +0000913 E->LBracLoc = ReadSourceLocation(Record, Idx);
914 E->RBracLoc = ReadSourceLocation(Record, Idx);
Chris Lattner4c6f9522009-04-27 05:14:47 +0000915
916 for (unsigned I = 0, N = E->getNumArgs(); I != N; ++I)
Argyrios Kyrtzidisd98a2ab2010-06-29 22:46:25 +0000917 E->setArg(I, Reader.ReadSubExpr());
Argyrios Kyrtzidis20718082011-10-03 06:36:51 +0000918
919 SourceLocation *Locs = E->getStoredSelLocs();
920 for (unsigned I = 0; I != NumStoredSelLocs; ++I)
921 Locs[I] = ReadSourceLocation(Record, Idx);
Chris Lattner4c6f9522009-04-27 05:14:47 +0000922}
923
Sebastian Redl60adf4a2010-08-18 23:56:52 +0000924void ASTStmtReader::VisitObjCForCollectionStmt(ObjCForCollectionStmt *S) {
Chris Lattner4c6f9522009-04-27 05:14:47 +0000925 VisitStmt(S);
Argyrios Kyrtzidisd98a2ab2010-06-29 22:46:25 +0000926 S->setElement(Reader.ReadSubStmt());
927 S->setCollection(Reader.ReadSubExpr());
928 S->setBody(Reader.ReadSubStmt());
Sebastian Redlc3632732010-10-05 15:59:54 +0000929 S->setForLoc(ReadSourceLocation(Record, Idx));
930 S->setRParenLoc(ReadSourceLocation(Record, Idx));
Chris Lattner4c6f9522009-04-27 05:14:47 +0000931}
932
Sebastian Redl60adf4a2010-08-18 23:56:52 +0000933void ASTStmtReader::VisitObjCAtCatchStmt(ObjCAtCatchStmt *S) {
Chris Lattner4c6f9522009-04-27 05:14:47 +0000934 VisitStmt(S);
Argyrios Kyrtzidisd98a2ab2010-06-29 22:46:25 +0000935 S->setCatchBody(Reader.ReadSubStmt());
Douglas Gregor409448c2011-07-21 22:35:25 +0000936 S->setCatchParamDecl(ReadDeclAs<VarDecl>(Record, Idx));
Sebastian Redlc3632732010-10-05 15:59:54 +0000937 S->setAtCatchLoc(ReadSourceLocation(Record, Idx));
938 S->setRParenLoc(ReadSourceLocation(Record, Idx));
Chris Lattner4c6f9522009-04-27 05:14:47 +0000939}
940
Sebastian Redl60adf4a2010-08-18 23:56:52 +0000941void ASTStmtReader::VisitObjCAtFinallyStmt(ObjCAtFinallyStmt *S) {
Chris Lattner4c6f9522009-04-27 05:14:47 +0000942 VisitStmt(S);
Argyrios Kyrtzidisd98a2ab2010-06-29 22:46:25 +0000943 S->setFinallyBody(Reader.ReadSubStmt());
Sebastian Redlc3632732010-10-05 15:59:54 +0000944 S->setAtFinallyLoc(ReadSourceLocation(Record, Idx));
Chris Lattner4c6f9522009-04-27 05:14:47 +0000945}
946
John McCallf85e1932011-06-15 23:02:42 +0000947void ASTStmtReader::VisitObjCAutoreleasePoolStmt(ObjCAutoreleasePoolStmt *S) {
948 VisitStmt(S);
949 S->setSubStmt(Reader.ReadSubStmt());
950 S->setAtLoc(ReadSourceLocation(Record, Idx));
951}
952
Sebastian Redl60adf4a2010-08-18 23:56:52 +0000953void ASTStmtReader::VisitObjCAtTryStmt(ObjCAtTryStmt *S) {
Chris Lattner4c6f9522009-04-27 05:14:47 +0000954 VisitStmt(S);
Douglas Gregor8f5e3dd2010-04-23 22:50:49 +0000955 assert(Record[Idx] == S->getNumCatchStmts());
956 ++Idx;
957 bool HasFinally = Record[Idx++];
Argyrios Kyrtzidisd98a2ab2010-06-29 22:46:25 +0000958 S->setTryBody(Reader.ReadSubStmt());
Argyrios Kyrtzidis919e6932010-06-28 22:28:35 +0000959 for (unsigned I = 0, N = S->getNumCatchStmts(); I != N; ++I)
Argyrios Kyrtzidisd98a2ab2010-06-29 22:46:25 +0000960 S->setCatchStmt(I, cast_or_null<ObjCAtCatchStmt>(Reader.ReadSubStmt()));
Douglas Gregor8f5e3dd2010-04-23 22:50:49 +0000961
Douglas Gregor8f5e3dd2010-04-23 22:50:49 +0000962 if (HasFinally)
Argyrios Kyrtzidisd98a2ab2010-06-29 22:46:25 +0000963 S->setFinallyStmt(Reader.ReadSubStmt());
Sebastian Redlc3632732010-10-05 15:59:54 +0000964 S->setAtTryLoc(ReadSourceLocation(Record, Idx));
Chris Lattner4c6f9522009-04-27 05:14:47 +0000965}
966
Sebastian Redl60adf4a2010-08-18 23:56:52 +0000967void ASTStmtReader::VisitObjCAtSynchronizedStmt(ObjCAtSynchronizedStmt *S) {
Chris Lattner4c6f9522009-04-27 05:14:47 +0000968 VisitStmt(S);
Argyrios Kyrtzidisd98a2ab2010-06-29 22:46:25 +0000969 S->setSynchExpr(Reader.ReadSubStmt());
970 S->setSynchBody(Reader.ReadSubStmt());
Sebastian Redlc3632732010-10-05 15:59:54 +0000971 S->setAtSynchronizedLoc(ReadSourceLocation(Record, Idx));
Chris Lattner4c6f9522009-04-27 05:14:47 +0000972}
973
Sebastian Redl60adf4a2010-08-18 23:56:52 +0000974void ASTStmtReader::VisitObjCAtThrowStmt(ObjCAtThrowStmt *S) {
Chris Lattner4c6f9522009-04-27 05:14:47 +0000975 VisitStmt(S);
Argyrios Kyrtzidisd98a2ab2010-06-29 22:46:25 +0000976 S->setThrowExpr(Reader.ReadSubStmt());
Sebastian Redlc3632732010-10-05 15:59:54 +0000977 S->setThrowLoc(ReadSourceLocation(Record, Idx));
Chris Lattner4c6f9522009-04-27 05:14:47 +0000978}
979
Argyrios Kyrtzidisba0a9002009-07-14 03:19:21 +0000980//===----------------------------------------------------------------------===//
981// C++ Expressions and Statements
Argyrios Kyrtzidis7cb45e32010-07-22 16:03:56 +0000982//===----------------------------------------------------------------------===//
983
Sebastian Redl60adf4a2010-08-18 23:56:52 +0000984void ASTStmtReader::VisitCXXCatchStmt(CXXCatchStmt *S) {
Argyrios Kyrtzidis7cb45e32010-07-22 16:03:56 +0000985 VisitStmt(S);
Sebastian Redlc3632732010-10-05 15:59:54 +0000986 S->CatchLoc = ReadSourceLocation(Record, Idx);
Douglas Gregor409448c2011-07-21 22:35:25 +0000987 S->ExceptionDecl = ReadDeclAs<VarDecl>(Record, Idx);
Argyrios Kyrtzidis7cb45e32010-07-22 16:03:56 +0000988 S->HandlerBlock = Reader.ReadSubStmt();
989}
990
Sebastian Redl60adf4a2010-08-18 23:56:52 +0000991void ASTStmtReader::VisitCXXTryStmt(CXXTryStmt *S) {
Argyrios Kyrtzidis7cb45e32010-07-22 16:03:56 +0000992 VisitStmt(S);
993 assert(Record[Idx] == S->getNumHandlers() && "NumStmtFields is wrong ?");
994 ++Idx;
Sebastian Redlc3632732010-10-05 15:59:54 +0000995 S->TryLoc = ReadSourceLocation(Record, Idx);
Argyrios Kyrtzidis7cb45e32010-07-22 16:03:56 +0000996 S->getStmts()[0] = Reader.ReadSubStmt();
997 for (unsigned i = 0, e = S->getNumHandlers(); i != e; ++i)
998 S->getStmts()[i + 1] = Reader.ReadSubStmt();
999}
Argyrios Kyrtzidisba0a9002009-07-14 03:19:21 +00001000
Richard Smithad762fc2011-04-14 22:09:26 +00001001void ASTStmtReader::VisitCXXForRangeStmt(CXXForRangeStmt *S) {
1002 VisitStmt(S);
1003 S->setForLoc(ReadSourceLocation(Record, Idx));
1004 S->setColonLoc(ReadSourceLocation(Record, Idx));
1005 S->setRParenLoc(ReadSourceLocation(Record, Idx));
1006 S->setRangeStmt(Reader.ReadSubStmt());
1007 S->setBeginEndStmt(Reader.ReadSubStmt());
1008 S->setCond(Reader.ReadSubExpr());
1009 S->setInc(Reader.ReadSubExpr());
1010 S->setLoopVarStmt(Reader.ReadSubStmt());
1011 S->setBody(Reader.ReadSubStmt());
1012}
1013
Douglas Gregorba0513d2011-10-25 01:33:02 +00001014void ASTStmtReader::VisitMSDependentExistsStmt(MSDependentExistsStmt *S) {
1015 VisitStmt(S);
1016 S->KeywordLoc = ReadSourceLocation(Record, Idx);
1017 S->IsIfExists = Record[Idx++];
1018 S->QualifierLoc = Reader.ReadNestedNameSpecifierLoc(F, Record, Idx);
1019 ReadDeclarationNameInfo(S->NameInfo, Record, Idx);
1020 S->SubStmt = Reader.ReadSubStmt();
1021}
1022
Sebastian Redl60adf4a2010-08-18 23:56:52 +00001023void ASTStmtReader::VisitCXXOperatorCallExpr(CXXOperatorCallExpr *E) {
Argyrios Kyrtzidis919e6932010-06-28 22:28:35 +00001024 VisitCallExpr(E);
Argyrios Kyrtzidisba0a9002009-07-14 03:19:21 +00001025 E->setOperator((OverloadedOperatorKind)Record[Idx++]);
Argyrios Kyrtzidisba0a9002009-07-14 03:19:21 +00001026}
1027
Sebastian Redl60adf4a2010-08-18 23:56:52 +00001028void ASTStmtReader::VisitCXXConstructExpr(CXXConstructExpr *E) {
Douglas Gregor39da0b82009-09-09 23:08:42 +00001029 VisitExpr(E);
Argyrios Kyrtzidis6d00c132010-07-10 11:46:15 +00001030 E->NumArgs = Record[Idx++];
1031 if (E->NumArgs)
Douglas Gregor35942772011-09-09 21:34:22 +00001032 E->Args = new (Reader.getContext()) Stmt*[E->NumArgs];
Argyrios Kyrtzidis5e1b7c22010-06-24 08:57:09 +00001033 for (unsigned I = 0, N = E->getNumArgs(); I != N; ++I)
Argyrios Kyrtzidisd98a2ab2010-06-29 22:46:25 +00001034 E->setArg(I, Reader.ReadSubExpr());
Douglas Gregor409448c2011-07-21 22:35:25 +00001035 E->setConstructor(ReadDeclAs<CXXConstructorDecl>(Record, Idx));
Sebastian Redlc3632732010-10-05 15:59:54 +00001036 E->setLocation(ReadSourceLocation(Record, Idx));
Abramo Bagnara7cc58b42011-10-05 07:56:41 +00001037 E->setElidable(Record[Idx++]);
1038 E->setHadMultipleCandidates(Record[Idx++]);
Douglas Gregor16006c92009-12-16 18:50:27 +00001039 E->setRequiresZeroInitialization(Record[Idx++]);
Douglas Gregor3c9034c2010-05-15 00:13:29 +00001040 E->setConstructionKind((CXXConstructExpr::ConstructionKind)Record[Idx++]);
Chandler Carruth428edaf2010-10-25 08:47:36 +00001041 E->ParenRange = ReadSourceRange(Record, Idx);
Douglas Gregor39da0b82009-09-09 23:08:42 +00001042}
Chris Lattner4c6f9522009-04-27 05:14:47 +00001043
Sebastian Redl60adf4a2010-08-18 23:56:52 +00001044void ASTStmtReader::VisitCXXTemporaryObjectExpr(CXXTemporaryObjectExpr *E) {
Argyrios Kyrtzidis6d00c132010-07-10 11:46:15 +00001045 VisitCXXConstructExpr(E);
Sebastian Redlc3632732010-10-05 15:59:54 +00001046 E->Type = GetTypeSourceInfo(Record, Idx);
Argyrios Kyrtzidis6d00c132010-07-10 11:46:15 +00001047}
1048
Sebastian Redl60adf4a2010-08-18 23:56:52 +00001049void ASTStmtReader::VisitCXXNamedCastExpr(CXXNamedCastExpr *E) {
Argyrios Kyrtzidis919e6932010-06-28 22:28:35 +00001050 VisitExplicitCastExpr(E);
Douglas Gregor1d5d0b92011-01-12 22:41:29 +00001051 SourceRange R = ReadSourceRange(Record, Idx);
1052 E->Loc = R.getBegin();
1053 E->RParenLoc = R.getEnd();
Sam Weinigce757a72010-01-16 21:21:01 +00001054}
1055
Sebastian Redl60adf4a2010-08-18 23:56:52 +00001056void ASTStmtReader::VisitCXXStaticCastExpr(CXXStaticCastExpr *E) {
Sam Weinigce757a72010-01-16 21:21:01 +00001057 return VisitCXXNamedCastExpr(E);
1058}
1059
Sebastian Redl60adf4a2010-08-18 23:56:52 +00001060void ASTStmtReader::VisitCXXDynamicCastExpr(CXXDynamicCastExpr *E) {
Sam Weinigce757a72010-01-16 21:21:01 +00001061 return VisitCXXNamedCastExpr(E);
1062}
1063
Sebastian Redl60adf4a2010-08-18 23:56:52 +00001064void ASTStmtReader::VisitCXXReinterpretCastExpr(CXXReinterpretCastExpr *E) {
Sam Weinigce757a72010-01-16 21:21:01 +00001065 return VisitCXXNamedCastExpr(E);
1066}
1067
Sebastian Redl60adf4a2010-08-18 23:56:52 +00001068void ASTStmtReader::VisitCXXConstCastExpr(CXXConstCastExpr *E) {
Sam Weinigce757a72010-01-16 21:21:01 +00001069 return VisitCXXNamedCastExpr(E);
1070}
1071
Sebastian Redl60adf4a2010-08-18 23:56:52 +00001072void ASTStmtReader::VisitCXXFunctionalCastExpr(CXXFunctionalCastExpr *E) {
Argyrios Kyrtzidis919e6932010-06-28 22:28:35 +00001073 VisitExplicitCastExpr(E);
Sebastian Redlc3632732010-10-05 15:59:54 +00001074 E->setTypeBeginLoc(ReadSourceLocation(Record, Idx));
1075 E->setRParenLoc(ReadSourceLocation(Record, Idx));
Sam Weinigce757a72010-01-16 21:21:01 +00001076}
1077
Sebastian Redl60adf4a2010-08-18 23:56:52 +00001078void ASTStmtReader::VisitCXXBoolLiteralExpr(CXXBoolLiteralExpr *E) {
Sam Weinigeb7f9612010-02-07 06:32:43 +00001079 VisitExpr(E);
1080 E->setValue(Record[Idx++]);
Sebastian Redlc3632732010-10-05 15:59:54 +00001081 E->setLocation(ReadSourceLocation(Record, Idx));
Sam Weinigeb7f9612010-02-07 06:32:43 +00001082}
1083
Sebastian Redl60adf4a2010-08-18 23:56:52 +00001084void ASTStmtReader::VisitCXXNullPtrLiteralExpr(CXXNullPtrLiteralExpr *E) {
Sam Weinigeb7f9612010-02-07 06:32:43 +00001085 VisitExpr(E);
Sebastian Redlc3632732010-10-05 15:59:54 +00001086 E->setLocation(ReadSourceLocation(Record, Idx));
Sam Weinigeb7f9612010-02-07 06:32:43 +00001087}
1088
Sebastian Redl60adf4a2010-08-18 23:56:52 +00001089void ASTStmtReader::VisitCXXTypeidExpr(CXXTypeidExpr *E) {
Chris Lattner14ab24f2010-05-09 06:03:39 +00001090 VisitExpr(E);
Sebastian Redlc3632732010-10-05 15:59:54 +00001091 E->setSourceRange(ReadSourceRange(Record, Idx));
Chris Lattner14ab24f2010-05-09 06:03:39 +00001092 if (E->isTypeOperand()) { // typeid(int)
Sebastian Redl577d4792010-07-22 22:43:28 +00001093 E->setTypeOperandSourceInfo(
Sebastian Redlc3632732010-10-05 15:59:54 +00001094 GetTypeSourceInfo(Record, Idx));
Argyrios Kyrtzidis919e6932010-06-28 22:28:35 +00001095 return;
Chris Lattner14ab24f2010-05-09 06:03:39 +00001096 }
1097
1098 // typeid(42+2)
Argyrios Kyrtzidisd98a2ab2010-06-29 22:46:25 +00001099 E->setExprOperand(Reader.ReadSubExpr());
Chris Lattner14ab24f2010-05-09 06:03:39 +00001100}
1101
Sebastian Redl60adf4a2010-08-18 23:56:52 +00001102void ASTStmtReader::VisitCXXThisExpr(CXXThisExpr *E) {
Chris Lattner2fbdfcd2010-05-09 06:15:05 +00001103 VisitExpr(E);
Sebastian Redlc3632732010-10-05 15:59:54 +00001104 E->setLocation(ReadSourceLocation(Record, Idx));
Chris Lattner2fbdfcd2010-05-09 06:15:05 +00001105 E->setImplicit(Record[Idx++]);
Chris Lattner2fbdfcd2010-05-09 06:15:05 +00001106}
1107
Sebastian Redl60adf4a2010-08-18 23:56:52 +00001108void ASTStmtReader::VisitCXXThrowExpr(CXXThrowExpr *E) {
Chris Lattner2fbdfcd2010-05-09 06:15:05 +00001109 VisitExpr(E);
Douglas Gregorbca01b42011-07-06 22:04:06 +00001110 E->ThrowLoc = ReadSourceLocation(Record, Idx);
1111 E->Op = Reader.ReadSubExpr();
1112 E->IsThrownVariableInScope = Record[Idx++];
Chris Lattner2fbdfcd2010-05-09 06:15:05 +00001113}
Chris Lattner14ab24f2010-05-09 06:03:39 +00001114
Sebastian Redl60adf4a2010-08-18 23:56:52 +00001115void ASTStmtReader::VisitCXXDefaultArgExpr(CXXDefaultArgExpr *E) {
Chris Lattner030854b2010-05-09 06:40:08 +00001116 VisitExpr(E);
Argyrios Kyrtzidis8a507332010-07-02 23:30:15 +00001117
Douglas Gregordf226552011-09-23 22:07:41 +00001118 assert((bool)Record[Idx] == E->Param.getInt() && "We messed up at creation ?");
Argyrios Kyrtzidis8a507332010-07-02 23:30:15 +00001119 ++Idx; // HasOtherExprStored and SubExpr was handled during creation.
Douglas Gregor409448c2011-07-21 22:35:25 +00001120 E->Param.setPointer(ReadDeclAs<ParmVarDecl>(Record, Idx));
Sebastian Redlc3632732010-10-05 15:59:54 +00001121 E->Loc = ReadSourceLocation(Record, Idx);
Chris Lattnerd2598362010-05-10 00:25:06 +00001122}
1123
Sebastian Redl60adf4a2010-08-18 23:56:52 +00001124void ASTStmtReader::VisitCXXBindTemporaryExpr(CXXBindTemporaryExpr *E) {
Chris Lattnerd2598362010-05-10 00:25:06 +00001125 VisitExpr(E);
Douglas Gregor409448c2011-07-21 22:35:25 +00001126 E->setTemporary(Reader.ReadCXXTemporary(F, Record, Idx));
Argyrios Kyrtzidisd98a2ab2010-06-29 22:46:25 +00001127 E->setSubExpr(Reader.ReadSubExpr());
Chris Lattnerd2598362010-05-10 00:25:06 +00001128}
1129
Sebastian Redl60adf4a2010-08-18 23:56:52 +00001130void ASTStmtReader::VisitCXXScalarValueInitExpr(CXXScalarValueInitExpr *E) {
Chris Lattner59218632010-05-10 01:22:27 +00001131 VisitExpr(E);
Sebastian Redlc3632732010-10-05 15:59:54 +00001132 E->TypeInfo = GetTypeSourceInfo(Record, Idx);
1133 E->RParenLoc = ReadSourceLocation(Record, Idx);
Chris Lattner59218632010-05-10 01:22:27 +00001134}
1135
Sebastian Redl60adf4a2010-08-18 23:56:52 +00001136void ASTStmtReader::VisitCXXNewExpr(CXXNewExpr *E) {
Chris Lattner59218632010-05-10 01:22:27 +00001137 VisitExpr(E);
John McCall6ec278d2011-01-27 09:37:56 +00001138 E->GlobalNew = Record[Idx++];
1139 E->Initializer = Record[Idx++];
1140 E->UsualArrayDeleteWantsSize = Record[Idx++];
Chris Lattner59218632010-05-10 01:22:27 +00001141 bool isArray = Record[Idx++];
Abramo Bagnara7cc58b42011-10-05 07:56:41 +00001142 E->setHadMultipleCandidates(Record[Idx++]);
Chris Lattner59218632010-05-10 01:22:27 +00001143 unsigned NumPlacementArgs = Record[Idx++];
1144 unsigned NumCtorArgs = Record[Idx++];
Douglas Gregor409448c2011-07-21 22:35:25 +00001145 E->setOperatorNew(ReadDeclAs<FunctionDecl>(Record, Idx));
1146 E->setOperatorDelete(ReadDeclAs<FunctionDecl>(Record, Idx));
1147 E->setConstructor(ReadDeclAs<CXXConstructorDecl>(Record, Idx));
Sebastian Redlc3632732010-10-05 15:59:54 +00001148 E->AllocatedTypeInfo = GetTypeSourceInfo(Record, Idx);
Douglas Gregor4bd40312010-07-13 15:54:32 +00001149 SourceRange TypeIdParens;
Sebastian Redlc3632732010-10-05 15:59:54 +00001150 TypeIdParens.setBegin(ReadSourceLocation(Record, Idx));
1151 TypeIdParens.setEnd(ReadSourceLocation(Record, Idx));
Douglas Gregor4bd40312010-07-13 15:54:32 +00001152 E->TypeIdParens = TypeIdParens;
Chandler Carruth428edaf2010-10-25 08:47:36 +00001153 E->StartLoc = ReadSourceLocation(Record, Idx);
1154 E->EndLoc = ReadSourceLocation(Record, Idx);
1155 E->ConstructorLParen = ReadSourceLocation(Record, Idx);
1156 E->ConstructorRParen = ReadSourceLocation(Record, Idx);
1157
Douglas Gregor35942772011-09-09 21:34:22 +00001158 E->AllocateArgsArray(Reader.getContext(), isArray, NumPlacementArgs,
Chris Lattner59218632010-05-10 01:22:27 +00001159 NumCtorArgs);
1160
1161 // Install all the subexpressions.
Chris Lattner59218632010-05-10 01:22:27 +00001162 for (CXXNewExpr::raw_arg_iterator I = E->raw_arg_begin(),e = E->raw_arg_end();
1163 I != e; ++I)
Argyrios Kyrtzidisd98a2ab2010-06-29 22:46:25 +00001164 *I = Reader.ReadSubStmt();
Chris Lattner59218632010-05-10 01:22:27 +00001165}
1166
Sebastian Redl60adf4a2010-08-18 23:56:52 +00001167void ASTStmtReader::VisitCXXDeleteExpr(CXXDeleteExpr *E) {
Argyrios Kyrtzidis95fc98c2010-06-22 17:07:59 +00001168 VisitExpr(E);
Argyrios Kyrtzidisf1b89112010-09-13 20:15:40 +00001169 E->GlobalDelete = Record[Idx++];
1170 E->ArrayForm = Record[Idx++];
Argyrios Kyrtzidis4076dac2010-09-13 20:15:54 +00001171 E->ArrayFormAsWritten = Record[Idx++];
John McCall6ec278d2011-01-27 09:37:56 +00001172 E->UsualArrayDeleteWantsSize = Record[Idx++];
Douglas Gregor409448c2011-07-21 22:35:25 +00001173 E->OperatorDelete = ReadDeclAs<FunctionDecl>(Record, Idx);
Argyrios Kyrtzidisf1b89112010-09-13 20:15:40 +00001174 E->Argument = Reader.ReadSubExpr();
Sebastian Redlc3632732010-10-05 15:59:54 +00001175 E->Loc = ReadSourceLocation(Record, Idx);
Argyrios Kyrtzidis95fc98c2010-06-22 17:07:59 +00001176}
Chris Lattnerd2598362010-05-10 00:25:06 +00001177
Sebastian Redl60adf4a2010-08-18 23:56:52 +00001178void ASTStmtReader::VisitCXXPseudoDestructorExpr(CXXPseudoDestructorExpr *E) {
Argyrios Kyrtzidisde4bd182010-06-28 09:32:03 +00001179 VisitExpr(E);
1180
Douglas Gregorf3db29f2011-02-25 18:19:59 +00001181 E->Base = Reader.ReadSubExpr();
1182 E->IsArrow = Record[Idx++];
1183 E->OperatorLoc = ReadSourceLocation(Record, Idx);
1184 E->QualifierLoc = Reader.ReadNestedNameSpecifierLoc(F, Record, Idx);
1185 E->ScopeType = GetTypeSourceInfo(Record, Idx);
1186 E->ColonColonLoc = ReadSourceLocation(Record, Idx);
1187 E->TildeLoc = ReadSourceLocation(Record, Idx);
Argyrios Kyrtzidisde4bd182010-06-28 09:32:03 +00001188
Douglas Gregor95eab172011-07-28 20:55:49 +00001189 IdentifierInfo *II = Reader.GetIdentifierInfo(F, Record, Idx);
Argyrios Kyrtzidisde4bd182010-06-28 09:32:03 +00001190 if (II)
Sebastian Redlc3632732010-10-05 15:59:54 +00001191 E->setDestroyedType(II, ReadSourceLocation(Record, Idx));
Argyrios Kyrtzidisde4bd182010-06-28 09:32:03 +00001192 else
Sebastian Redlc3632732010-10-05 15:59:54 +00001193 E->setDestroyedType(GetTypeSourceInfo(Record, Idx));
Argyrios Kyrtzidisde4bd182010-06-28 09:32:03 +00001194}
1195
John McCall4765fa02010-12-06 08:20:24 +00001196void ASTStmtReader::VisitExprWithCleanups(ExprWithCleanups *E) {
Chris Lattnerd2598362010-05-10 00:25:06 +00001197 VisitExpr(E);
1198 unsigned NumTemps = Record[Idx++];
1199 if (NumTemps) {
Douglas Gregor35942772011-09-09 21:34:22 +00001200 E->setNumTemporaries(Reader.getContext(), NumTemps);
Chris Lattnerd2598362010-05-10 00:25:06 +00001201 for (unsigned i = 0; i != NumTemps; ++i)
Douglas Gregor409448c2011-07-21 22:35:25 +00001202 E->setTemporary(i, Reader.ReadCXXTemporary(F, Record, Idx));
Chris Lattnerd2598362010-05-10 00:25:06 +00001203 }
Argyrios Kyrtzidisd98a2ab2010-06-29 22:46:25 +00001204 E->setSubExpr(Reader.ReadSubExpr());
Chris Lattner030854b2010-05-09 06:40:08 +00001205}
1206
Argyrios Kyrtzidis919e6932010-06-28 22:28:35 +00001207void
Sebastian Redl60adf4a2010-08-18 23:56:52 +00001208ASTStmtReader::VisitCXXDependentScopeMemberExpr(CXXDependentScopeMemberExpr *E){
Argyrios Kyrtzidis8dfbd8b2010-06-24 08:57:31 +00001209 VisitExpr(E);
1210
Douglas Gregordef03542011-02-04 12:01:24 +00001211 if (Record[Idx++])
John McCall096832c2010-08-19 23:49:38 +00001212 ReadExplicitTemplateArgumentList(E->getExplicitTemplateArgs(),
Douglas Gregordef03542011-02-04 12:01:24 +00001213 Record[Idx++]);
Argyrios Kyrtzidis8dfbd8b2010-06-24 08:57:31 +00001214
Douglas Gregor7c3179c2011-02-28 18:50:33 +00001215 E->Base = Reader.ReadSubExpr();
Douglas Gregor393f2492011-07-22 00:38:23 +00001216 E->BaseType = Reader.readType(F, Record, Idx);
Douglas Gregor7c3179c2011-02-28 18:50:33 +00001217 E->IsArrow = Record[Idx++];
1218 E->OperatorLoc = ReadSourceLocation(Record, Idx);
1219 E->QualifierLoc = Reader.ReadNestedNameSpecifierLoc(F, Record, Idx);
Douglas Gregor409448c2011-07-21 22:35:25 +00001220 E->FirstQualifierFoundInScope = ReadDeclAs<NamedDecl>(Record, Idx);
Argyrios Kyrtzidis40451072010-10-15 18:21:24 +00001221 ReadDeclarationNameInfo(E->MemberNameInfo, Record, Idx);
Argyrios Kyrtzidis8dfbd8b2010-06-24 08:57:31 +00001222}
1223
Argyrios Kyrtzidis919e6932010-06-28 22:28:35 +00001224void
Sebastian Redl60adf4a2010-08-18 23:56:52 +00001225ASTStmtReader::VisitDependentScopeDeclRefExpr(DependentScopeDeclRefExpr *E) {
Argyrios Kyrtzidis12dffcd2010-06-28 09:31:56 +00001226 VisitExpr(E);
Argyrios Kyrtzidis12dffcd2010-06-28 09:31:56 +00001227
Douglas Gregordef03542011-02-04 12:01:24 +00001228 if (Record[Idx++])
1229 ReadExplicitTemplateArgumentList(E->getExplicitTemplateArgs(),
1230 Record[Idx++]);
Douglas Gregor00cf3cc2011-02-25 20:49:16 +00001231
1232 E->QualifierLoc = Reader.ReadNestedNameSpecifierLoc(F, Record, Idx);
Argyrios Kyrtzidis40451072010-10-15 18:21:24 +00001233 ReadDeclarationNameInfo(E->NameInfo, Record, Idx);
Argyrios Kyrtzidis12dffcd2010-06-28 09:31:56 +00001234}
1235
Argyrios Kyrtzidis919e6932010-06-28 22:28:35 +00001236void
Sebastian Redl60adf4a2010-08-18 23:56:52 +00001237ASTStmtReader::VisitCXXUnresolvedConstructExpr(CXXUnresolvedConstructExpr *E) {
Argyrios Kyrtzidis8dfbd8b2010-06-24 08:57:31 +00001238 VisitExpr(E);
1239 assert(Record[Idx] == E->arg_size() && "Read wrong record during creation ?");
1240 ++Idx; // NumArgs;
1241 for (unsigned I = 0, N = E->arg_size(); I != N; ++I)
Argyrios Kyrtzidisd98a2ab2010-06-29 22:46:25 +00001242 E->setArg(I, Reader.ReadSubExpr());
Sebastian Redlc3632732010-10-05 15:59:54 +00001243 E->Type = GetTypeSourceInfo(Record, Idx);
1244 E->setLParenLoc(ReadSourceLocation(Record, Idx));
1245 E->setRParenLoc(ReadSourceLocation(Record, Idx));
Argyrios Kyrtzidis8dfbd8b2010-06-24 08:57:31 +00001246}
1247
Sebastian Redl60adf4a2010-08-18 23:56:52 +00001248void ASTStmtReader::VisitOverloadExpr(OverloadExpr *E) {
Argyrios Kyrtzidisa77eb082010-06-25 09:03:26 +00001249 VisitExpr(E);
1250
Douglas Gregordef03542011-02-04 12:01:24 +00001251 // Read the explicit template argument list, if available.
1252 if (Record[Idx++])
Argyrios Kyrtzidis919e6932010-06-28 22:28:35 +00001253 ReadExplicitTemplateArgumentList(E->getExplicitTemplateArgs(),
Douglas Gregordef03542011-02-04 12:01:24 +00001254 Record[Idx++]);
Argyrios Kyrtzidisa77eb082010-06-25 09:03:26 +00001255
1256 unsigned NumDecls = Record[Idx++];
1257 UnresolvedSet<8> Decls;
1258 for (unsigned i = 0; i != NumDecls; ++i) {
Douglas Gregor409448c2011-07-21 22:35:25 +00001259 NamedDecl *D = ReadDeclAs<NamedDecl>(Record, Idx);
Argyrios Kyrtzidisa77eb082010-06-25 09:03:26 +00001260 AccessSpecifier AS = (AccessSpecifier)Record[Idx++];
1261 Decls.addDecl(D, AS);
1262 }
Douglas Gregor35942772011-09-09 21:34:22 +00001263 E->initializeResults(Reader.getContext(), Decls.begin(), Decls.end());
Argyrios Kyrtzidisa77eb082010-06-25 09:03:26 +00001264
Argyrios Kyrtzidis40451072010-10-15 18:21:24 +00001265 ReadDeclarationNameInfo(E->NameInfo, Record, Idx);
Douglas Gregor4c9be892011-02-28 20:01:57 +00001266 E->QualifierLoc = Reader.ReadNestedNameSpecifierLoc(F, Record, Idx);
Argyrios Kyrtzidisa77eb082010-06-25 09:03:26 +00001267}
1268
Sebastian Redl60adf4a2010-08-18 23:56:52 +00001269void ASTStmtReader::VisitUnresolvedMemberExpr(UnresolvedMemberExpr *E) {
Argyrios Kyrtzidis919e6932010-06-28 22:28:35 +00001270 VisitOverloadExpr(E);
Douglas Gregor4c9be892011-02-28 20:01:57 +00001271 E->IsArrow = Record[Idx++];
1272 E->HasUnresolvedUsing = Record[Idx++];
1273 E->Base = Reader.ReadSubExpr();
Douglas Gregor393f2492011-07-22 00:38:23 +00001274 E->BaseType = Reader.readType(F, Record, Idx);
Douglas Gregor4c9be892011-02-28 20:01:57 +00001275 E->OperatorLoc = ReadSourceLocation(Record, Idx);
Argyrios Kyrtzidisa77eb082010-06-25 09:03:26 +00001276}
1277
Sebastian Redl60adf4a2010-08-18 23:56:52 +00001278void ASTStmtReader::VisitUnresolvedLookupExpr(UnresolvedLookupExpr *E) {
Argyrios Kyrtzidis919e6932010-06-28 22:28:35 +00001279 VisitOverloadExpr(E);
Douglas Gregor4c9be892011-02-28 20:01:57 +00001280 E->RequiresADL = Record[Idx++];
Richard Smithad762fc2011-04-14 22:09:26 +00001281 if (E->RequiresADL)
1282 E->StdIsAssociatedNamespace = Record[Idx++];
Douglas Gregor4c9be892011-02-28 20:01:57 +00001283 E->Overloaded = Record[Idx++];
Douglas Gregor409448c2011-07-21 22:35:25 +00001284 E->NamingClass = ReadDeclAs<CXXRecordDecl>(Record, Idx);
Argyrios Kyrtzidisbd65bb52010-06-25 09:03:34 +00001285}
1286
Sebastian Redl60adf4a2010-08-18 23:56:52 +00001287void ASTStmtReader::VisitUnaryTypeTraitExpr(UnaryTypeTraitExpr *E) {
Argyrios Kyrtzidis6d00c132010-07-10 11:46:15 +00001288 VisitExpr(E);
1289 E->UTT = (UnaryTypeTrait)Record[Idx++];
Sebastian Redl0dfd8482010-09-13 20:56:31 +00001290 E->Value = (bool)Record[Idx++];
Sebastian Redlc3632732010-10-05 15:59:54 +00001291 SourceRange Range = ReadSourceRange(Record, Idx);
Argyrios Kyrtzidis6d00c132010-07-10 11:46:15 +00001292 E->Loc = Range.getBegin();
1293 E->RParen = Range.getEnd();
Sebastian Redlc3632732010-10-05 15:59:54 +00001294 E->QueriedType = GetTypeSourceInfo(Record, Idx);
Argyrios Kyrtzidis6d00c132010-07-10 11:46:15 +00001295}
1296
Francois Pichet6ad6f282010-12-07 00:08:36 +00001297void ASTStmtReader::VisitBinaryTypeTraitExpr(BinaryTypeTraitExpr *E) {
1298 VisitExpr(E);
1299 E->BTT = (BinaryTypeTrait)Record[Idx++];
1300 E->Value = (bool)Record[Idx++];
1301 SourceRange Range = ReadSourceRange(Record, Idx);
1302 E->Loc = Range.getBegin();
1303 E->RParen = Range.getEnd();
1304 E->LhsType = GetTypeSourceInfo(Record, Idx);
1305 E->RhsType = GetTypeSourceInfo(Record, Idx);
1306}
1307
John Wiegley21ff2e52011-04-28 00:16:57 +00001308void ASTStmtReader::VisitArrayTypeTraitExpr(ArrayTypeTraitExpr *E) {
1309 VisitExpr(E);
1310 E->ATT = (ArrayTypeTrait)Record[Idx++];
1311 E->Value = (unsigned int)Record[Idx++];
1312 SourceRange Range = ReadSourceRange(Record, Idx);
1313 E->Loc = Range.getBegin();
1314 E->RParen = Range.getEnd();
1315 E->QueriedType = GetTypeSourceInfo(Record, Idx);
1316}
1317
John Wiegley55262202011-04-25 06:54:41 +00001318void ASTStmtReader::VisitExpressionTraitExpr(ExpressionTraitExpr *E) {
1319 VisitExpr(E);
1320 E->ET = (ExpressionTrait)Record[Idx++];
1321 E->Value = (bool)Record[Idx++];
1322 SourceRange Range = ReadSourceRange(Record, Idx);
1323 E->QueriedExpression = Reader.ReadSubExpr();
1324 E->Loc = Range.getBegin();
1325 E->RParen = Range.getEnd();
1326}
1327
Sebastian Redl6b219d02010-09-10 20:55:54 +00001328void ASTStmtReader::VisitCXXNoexceptExpr(CXXNoexceptExpr *E) {
1329 VisitExpr(E);
Sebastian Redl5221d8f2010-09-10 22:34:40 +00001330 E->Value = (bool)Record[Idx++];
Sebastian Redlc3632732010-10-05 15:59:54 +00001331 E->Range = ReadSourceRange(Record, Idx);
Sebastian Redl5221d8f2010-09-10 22:34:40 +00001332 E->Operand = Reader.ReadSubExpr();
Sebastian Redl6b219d02010-09-10 20:55:54 +00001333}
1334
Douglas Gregorbe230c32011-01-03 17:17:50 +00001335void ASTStmtReader::VisitPackExpansionExpr(PackExpansionExpr *E) {
1336 VisitExpr(E);
1337 E->EllipsisLoc = ReadSourceLocation(Record, Idx);
Douglas Gregor67fd1252011-01-14 21:20:45 +00001338 E->NumExpansions = Record[Idx++];
Douglas Gregorbe230c32011-01-03 17:17:50 +00001339 E->Pattern = Reader.ReadSubExpr();
1340}
1341
Douglas Gregoree8aff02011-01-04 17:33:58 +00001342void ASTStmtReader::VisitSizeOfPackExpr(SizeOfPackExpr *E) {
1343 VisitExpr(E);
1344 E->OperatorLoc = ReadSourceLocation(Record, Idx);
1345 E->PackLoc = ReadSourceLocation(Record, Idx);
1346 E->RParenLoc = ReadSourceLocation(Record, Idx);
1347 E->Length = Record[Idx++];
Douglas Gregor409448c2011-07-21 22:35:25 +00001348 E->Pack = ReadDeclAs<NamedDecl>(Record, Idx);
Douglas Gregoree8aff02011-01-04 17:33:58 +00001349}
1350
John McCall7110fd62011-07-15 07:00:14 +00001351void ASTStmtReader::VisitSubstNonTypeTemplateParmExpr(
1352 SubstNonTypeTemplateParmExpr *E) {
1353 VisitExpr(E);
Douglas Gregor409448c2011-07-21 22:35:25 +00001354 E->Param = ReadDeclAs<NonTypeTemplateParmDecl>(Record, Idx);
John McCall7110fd62011-07-15 07:00:14 +00001355 E->NameLoc = ReadSourceLocation(Record, Idx);
1356 E->Replacement = Reader.ReadSubExpr();
1357}
1358
Douglas Gregorc7793c72011-01-15 01:15:58 +00001359void ASTStmtReader::VisitSubstNonTypeTemplateParmPackExpr(
1360 SubstNonTypeTemplateParmPackExpr *E) {
1361 VisitExpr(E);
Douglas Gregor409448c2011-07-21 22:35:25 +00001362 E->Param = ReadDeclAs<NonTypeTemplateParmDecl>(Record, Idx);
Douglas Gregorc7793c72011-01-15 01:15:58 +00001363 TemplateArgument ArgPack = Reader.ReadTemplateArgument(F, Record, Idx);
1364 if (ArgPack.getKind() != TemplateArgument::Pack)
1365 return;
1366
1367 E->Arguments = ArgPack.pack_begin();
1368 E->NumArguments = ArgPack.pack_size();
1369 E->NameLoc = ReadSourceLocation(Record, Idx);
1370}
1371
Douglas Gregor03e80032011-06-21 17:03:29 +00001372void ASTStmtReader::VisitMaterializeTemporaryExpr(MaterializeTemporaryExpr *E) {
1373 VisitExpr(E);
1374 E->Temporary = Reader.ReadSubExpr();
1375}
1376
John McCall7cd7d1a2010-11-15 23:31:06 +00001377void ASTStmtReader::VisitOpaqueValueExpr(OpaqueValueExpr *E) {
1378 VisitExpr(E);
John McCall56ca35d2011-02-17 10:25:35 +00001379 Idx++; // skip ID
Douglas Gregorb608b982011-01-28 02:26:04 +00001380 E->Loc = ReadSourceLocation(Record, Idx);
John McCall7cd7d1a2010-11-15 23:31:06 +00001381}
1382
Peter Collingbournee08ce652011-02-09 21:07:24 +00001383//===----------------------------------------------------------------------===//
John McCall7110fd62011-07-15 07:00:14 +00001384// Microsoft Expressions and Statements
1385//===----------------------------------------------------------------------===//
1386void ASTStmtReader::VisitCXXUuidofExpr(CXXUuidofExpr *E) {
1387 VisitExpr(E);
1388 E->setSourceRange(ReadSourceRange(Record, Idx));
1389 if (E->isTypeOperand()) { // __uuidof(ComType)
1390 E->setTypeOperandSourceInfo(
1391 GetTypeSourceInfo(Record, Idx));
1392 return;
1393 }
1394
1395 // __uuidof(expr)
1396 E->setExprOperand(Reader.ReadSubExpr());
1397}
1398
1399void ASTStmtReader::VisitSEHExceptStmt(SEHExceptStmt *S) {
1400 VisitStmt(S);
1401 S->Loc = ReadSourceLocation(Record, Idx);
1402 S->Children[SEHExceptStmt::FILTER_EXPR] = Reader.ReadSubStmt();
1403 S->Children[SEHExceptStmt::BLOCK] = Reader.ReadSubStmt();
1404}
1405
1406void ASTStmtReader::VisitSEHFinallyStmt(SEHFinallyStmt *S) {
1407 VisitStmt(S);
1408 S->Loc = ReadSourceLocation(Record, Idx);
1409 S->Block = Reader.ReadSubStmt();
1410}
1411
1412void ASTStmtReader::VisitSEHTryStmt(SEHTryStmt *S) {
1413 VisitStmt(S);
1414 S->IsCXXTry = Record[Idx++];
1415 S->TryLoc = ReadSourceLocation(Record, Idx);
1416 S->Children[SEHTryStmt::TRY] = Reader.ReadSubStmt();
1417 S->Children[SEHTryStmt::HANDLER] = Reader.ReadSubStmt();
1418}
1419
1420//===----------------------------------------------------------------------===//
Peter Collingbournee08ce652011-02-09 21:07:24 +00001421// CUDA Expressions and Statements
1422//===----------------------------------------------------------------------===//
1423
1424void ASTStmtReader::VisitCUDAKernelCallExpr(CUDAKernelCallExpr *E) {
1425 VisitCallExpr(E);
1426 E->setConfig(cast<CallExpr>(Reader.ReadSubExpr()));
1427}
1428
John McCall7110fd62011-07-15 07:00:14 +00001429//===----------------------------------------------------------------------===//
1430// OpenCL Expressions and Statements.
1431//===----------------------------------------------------------------------===//
1432void ASTStmtReader::VisitAsTypeExpr(AsTypeExpr *E) {
1433 VisitExpr(E);
1434 E->BuiltinLoc = ReadSourceLocation(Record, Idx);
1435 E->RParenLoc = ReadSourceLocation(Record, Idx);
1436 E->SrcExpr = Reader.ReadSubExpr();
1437}
1438
1439//===----------------------------------------------------------------------===//
1440// ASTReader Implementation
1441//===----------------------------------------------------------------------===//
1442
Douglas Gregor72a9ae12011-07-22 16:00:58 +00001443Stmt *ASTReader::ReadStmt(Module &F) {
Argyrios Kyrtzidis919e6932010-06-28 22:28:35 +00001444 switch (ReadingKind) {
1445 case Read_Decl:
1446 case Read_Type:
Sebastian Redlc3632732010-10-05 15:59:54 +00001447 return ReadStmtFromStream(F);
Argyrios Kyrtzidis919e6932010-06-28 22:28:35 +00001448 case Read_Stmt:
Argyrios Kyrtzidisd98a2ab2010-06-29 22:46:25 +00001449 return ReadSubStmt();
Argyrios Kyrtzidis919e6932010-06-28 22:28:35 +00001450 }
1451
1452 llvm_unreachable("ReadingKind not set ?");
1453 return 0;
1454}
1455
Douglas Gregor72a9ae12011-07-22 16:00:58 +00001456Expr *ASTReader::ReadExpr(Module &F) {
Sebastian Redlc3632732010-10-05 15:59:54 +00001457 return cast_or_null<Expr>(ReadStmt(F));
Argyrios Kyrtzidis919e6932010-06-28 22:28:35 +00001458}
Chris Lattner030854b2010-05-09 06:40:08 +00001459
Sebastian Redlc43b54c2010-08-18 23:56:43 +00001460Expr *ASTReader::ReadSubExpr() {
Argyrios Kyrtzidisd98a2ab2010-06-29 22:46:25 +00001461 return cast_or_null<Expr>(ReadSubStmt());
1462}
1463
Chris Lattner52e97d12009-04-27 05:41:06 +00001464// Within the bitstream, expressions are stored in Reverse Polish
1465// Notation, with each of the subexpressions preceding the
Argyrios Kyrtzidis919e6932010-06-28 22:28:35 +00001466// expression they are stored in. Subexpressions are stored from last to first.
1467// To evaluate expressions, we continue reading expressions and placing them on
1468// the stack, with expressions having operands removing those operands from the
Chris Lattner52e97d12009-04-27 05:41:06 +00001469// stack. Evaluation terminates when we see a STMT_STOP record, and
1470// the single remaining expression on the stack is our result.
Douglas Gregor72a9ae12011-07-22 16:00:58 +00001471Stmt *ASTReader::ReadStmtFromStream(Module &F) {
Argyrios Kyrtzidis919e6932010-06-28 22:28:35 +00001472
1473 ReadingKindTracker ReadingKind(Read_Stmt, *this);
Sebastian Redlc3632732010-10-05 15:59:54 +00001474 llvm::BitstreamCursor &Cursor = F.DeclsCursor;
Argyrios Kyrtzidise6f08682011-10-21 23:02:28 +00001475
1476 // Map of offset to previously deserialized stmt. The offset points
1477 /// just after the stmt record.
1478 llvm::DenseMap<uint64_t, Stmt *> StmtEntries;
Sebastian Redlc3632732010-10-05 15:59:54 +00001479
Argyrios Kyrtzidis919e6932010-06-28 22:28:35 +00001480#ifndef NDEBUG
1481 unsigned PrevNumStmts = StmtStack.size();
1482#endif
1483
Chris Lattner4c6f9522009-04-27 05:14:47 +00001484 RecordData Record;
1485 unsigned Idx;
Sebastian Redlc3632732010-10-05 15:59:54 +00001486 ASTStmtReader Reader(*this, F, Cursor, Record, Idx);
Chris Lattner4c6f9522009-04-27 05:14:47 +00001487 Stmt::EmptyShell Empty;
1488
1489 while (true) {
Chris Lattner52e97d12009-04-27 05:41:06 +00001490 unsigned Code = Cursor.ReadCode();
Chris Lattner4c6f9522009-04-27 05:14:47 +00001491 if (Code == llvm::bitc::END_BLOCK) {
Chris Lattner52e97d12009-04-27 05:41:06 +00001492 if (Cursor.ReadBlockEnd()) {
Sebastian Redl3c7f4132010-08-18 23:57:06 +00001493 Error("error at end of block in AST file");
Chris Lattner4c6f9522009-04-27 05:14:47 +00001494 return 0;
1495 }
1496 break;
1497 }
1498
1499 if (Code == llvm::bitc::ENTER_SUBBLOCK) {
1500 // No known subblocks, always skip them.
Chris Lattner52e97d12009-04-27 05:41:06 +00001501 Cursor.ReadSubBlockID();
1502 if (Cursor.SkipBlock()) {
Sebastian Redl3c7f4132010-08-18 23:57:06 +00001503 Error("malformed block record in AST file");
Chris Lattner4c6f9522009-04-27 05:14:47 +00001504 return 0;
1505 }
1506 continue;
1507 }
1508
1509 if (Code == llvm::bitc::DEFINE_ABBREV) {
Chris Lattner52e97d12009-04-27 05:41:06 +00001510 Cursor.ReadAbbrevRecord();
Chris Lattner4c6f9522009-04-27 05:14:47 +00001511 continue;
1512 }
1513
1514 Stmt *S = 0;
1515 Idx = 0;
1516 Record.clear();
1517 bool Finished = false;
Argyrios Kyrtzidise6f08682011-10-21 23:02:28 +00001518 bool IsStmtReference = false;
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001519 switch ((StmtCode)Cursor.ReadRecord(Code, Record)) {
1520 case STMT_STOP:
Chris Lattner4c6f9522009-04-27 05:14:47 +00001521 Finished = true;
1522 break;
1523
Argyrios Kyrtzidise6f08682011-10-21 23:02:28 +00001524 case STMT_REF_PTR:
1525 IsStmtReference = true;
1526 assert(StmtEntries.find(Record[0]) != StmtEntries.end() &&
1527 "No stmt was recorded for this offset reference!");
1528 S = StmtEntries[Record[Idx++]];
1529 break;
1530
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001531 case STMT_NULL_PTR:
Mike Stump1eb44332009-09-09 15:08:12 +00001532 S = 0;
Chris Lattner4c6f9522009-04-27 05:14:47 +00001533 break;
1534
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001535 case STMT_NULL:
Chris Lattner4c6f9522009-04-27 05:14:47 +00001536 S = new (Context) NullStmt(Empty);
1537 break;
1538
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001539 case STMT_COMPOUND:
Chris Lattner4c6f9522009-04-27 05:14:47 +00001540 S = new (Context) CompoundStmt(Empty);
1541 break;
1542
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001543 case STMT_CASE:
Chris Lattner4c6f9522009-04-27 05:14:47 +00001544 S = new (Context) CaseStmt(Empty);
1545 break;
1546
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001547 case STMT_DEFAULT:
Chris Lattner4c6f9522009-04-27 05:14:47 +00001548 S = new (Context) DefaultStmt(Empty);
1549 break;
1550
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001551 case STMT_LABEL:
Chris Lattner4c6f9522009-04-27 05:14:47 +00001552 S = new (Context) LabelStmt(Empty);
1553 break;
1554
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001555 case STMT_IF:
Chris Lattner4c6f9522009-04-27 05:14:47 +00001556 S = new (Context) IfStmt(Empty);
1557 break;
1558
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001559 case STMT_SWITCH:
Chris Lattner4c6f9522009-04-27 05:14:47 +00001560 S = new (Context) SwitchStmt(Empty);
1561 break;
1562
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001563 case STMT_WHILE:
Chris Lattner4c6f9522009-04-27 05:14:47 +00001564 S = new (Context) WhileStmt(Empty);
1565 break;
1566
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001567 case STMT_DO:
Chris Lattner4c6f9522009-04-27 05:14:47 +00001568 S = new (Context) DoStmt(Empty);
1569 break;
Mike Stump1eb44332009-09-09 15:08:12 +00001570
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001571 case STMT_FOR:
Chris Lattner4c6f9522009-04-27 05:14:47 +00001572 S = new (Context) ForStmt(Empty);
1573 break;
1574
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001575 case STMT_GOTO:
Chris Lattner4c6f9522009-04-27 05:14:47 +00001576 S = new (Context) GotoStmt(Empty);
1577 break;
Mike Stump1eb44332009-09-09 15:08:12 +00001578
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001579 case STMT_INDIRECT_GOTO:
Chris Lattner4c6f9522009-04-27 05:14:47 +00001580 S = new (Context) IndirectGotoStmt(Empty);
1581 break;
1582
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001583 case STMT_CONTINUE:
Chris Lattner4c6f9522009-04-27 05:14:47 +00001584 S = new (Context) ContinueStmt(Empty);
1585 break;
1586
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001587 case STMT_BREAK:
Chris Lattner4c6f9522009-04-27 05:14:47 +00001588 S = new (Context) BreakStmt(Empty);
1589 break;
1590
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001591 case STMT_RETURN:
Chris Lattner4c6f9522009-04-27 05:14:47 +00001592 S = new (Context) ReturnStmt(Empty);
1593 break;
1594
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001595 case STMT_DECL:
Chris Lattner4c6f9522009-04-27 05:14:47 +00001596 S = new (Context) DeclStmt(Empty);
1597 break;
1598
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001599 case STMT_ASM:
Chris Lattner4c6f9522009-04-27 05:14:47 +00001600 S = new (Context) AsmStmt(Empty);
1601 break;
1602
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001603 case EXPR_PREDEFINED:
Chris Lattner4c6f9522009-04-27 05:14:47 +00001604 S = new (Context) PredefinedExpr(Empty);
1605 break;
Mike Stump1eb44332009-09-09 15:08:12 +00001606
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001607 case EXPR_DECL_REF:
Chandler Carruth3aa81402011-05-01 23:48:14 +00001608 S = DeclRefExpr::CreateEmpty(
Douglas Gregor35942772011-09-09 21:34:22 +00001609 Context,
Chandler Carruth3aa81402011-05-01 23:48:14 +00001610 /*HasQualifier=*/Record[ASTStmtReader::NumExprFields],
1611 /*HasFoundDecl=*/Record[ASTStmtReader::NumExprFields + 1],
1612 /*HasExplicitTemplateArgs=*/Record[ASTStmtReader::NumExprFields + 2],
1613 /*NumTemplateArgs=*/Record[ASTStmtReader::NumExprFields + 2] ?
Abramo Bagnara7cc58b42011-10-05 07:56:41 +00001614 Record[ASTStmtReader::NumExprFields + 4] : 0);
Chris Lattner4c6f9522009-04-27 05:14:47 +00001615 break;
Mike Stump1eb44332009-09-09 15:08:12 +00001616
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001617 case EXPR_INTEGER_LITERAL:
Douglas Gregor35942772011-09-09 21:34:22 +00001618 S = IntegerLiteral::Create(Context, Empty);
Chris Lattner4c6f9522009-04-27 05:14:47 +00001619 break;
Mike Stump1eb44332009-09-09 15:08:12 +00001620
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001621 case EXPR_FLOATING_LITERAL:
Douglas Gregor35942772011-09-09 21:34:22 +00001622 S = FloatingLiteral::Create(Context, Empty);
Chris Lattner4c6f9522009-04-27 05:14:47 +00001623 break;
Mike Stump1eb44332009-09-09 15:08:12 +00001624
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001625 case EXPR_IMAGINARY_LITERAL:
Chris Lattner4c6f9522009-04-27 05:14:47 +00001626 S = new (Context) ImaginaryLiteral(Empty);
1627 break;
1628
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001629 case EXPR_STRING_LITERAL:
Douglas Gregor35942772011-09-09 21:34:22 +00001630 S = StringLiteral::CreateEmpty(Context,
Sebastian Redl60adf4a2010-08-18 23:56:52 +00001631 Record[ASTStmtReader::NumExprFields + 1]);
Chris Lattner4c6f9522009-04-27 05:14:47 +00001632 break;
1633
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001634 case EXPR_CHARACTER_LITERAL:
Chris Lattner4c6f9522009-04-27 05:14:47 +00001635 S = new (Context) CharacterLiteral(Empty);
1636 break;
1637
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001638 case EXPR_PAREN:
Chris Lattner4c6f9522009-04-27 05:14:47 +00001639 S = new (Context) ParenExpr(Empty);
1640 break;
1641
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001642 case EXPR_PAREN_LIST:
Argyrios Kyrtzidis37bdfe22010-06-30 08:49:18 +00001643 S = new (Context) ParenListExpr(Empty);
1644 break;
1645
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001646 case EXPR_UNARY_OPERATOR:
Chris Lattner4c6f9522009-04-27 05:14:47 +00001647 S = new (Context) UnaryOperator(Empty);
1648 break;
1649
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001650 case EXPR_OFFSETOF:
Douglas Gregor35942772011-09-09 21:34:22 +00001651 S = OffsetOfExpr::CreateEmpty(Context,
Sebastian Redl60adf4a2010-08-18 23:56:52 +00001652 Record[ASTStmtReader::NumExprFields],
1653 Record[ASTStmtReader::NumExprFields + 1]);
Douglas Gregor8ecdb652010-04-28 22:16:22 +00001654 break;
1655
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001656 case EXPR_SIZEOF_ALIGN_OF:
Peter Collingbournef4e3cfb2011-03-11 19:24:49 +00001657 S = new (Context) UnaryExprOrTypeTraitExpr(Empty);
Chris Lattner4c6f9522009-04-27 05:14:47 +00001658 break;
1659
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001660 case EXPR_ARRAY_SUBSCRIPT:
Chris Lattner4c6f9522009-04-27 05:14:47 +00001661 S = new (Context) ArraySubscriptExpr(Empty);
1662 break;
1663
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001664 case EXPR_CALL:
Douglas Gregor35942772011-09-09 21:34:22 +00001665 S = new (Context) CallExpr(Context, Stmt::CallExprClass, Empty);
Chris Lattner4c6f9522009-04-27 05:14:47 +00001666 break;
1667
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001668 case EXPR_MEMBER: {
Argyrios Kyrtzidis663e3802010-07-08 13:09:47 +00001669 // We load everything here and fully initialize it at creation.
1670 // That way we can use MemberExpr::Create and don't have to duplicate its
1671 // logic with a MemberExpr::CreateEmpty.
1672
1673 assert(Idx == 0);
Douglas Gregor40d96a62011-02-28 21:54:11 +00001674 NestedNameSpecifierLoc QualifierLoc;
Argyrios Kyrtzidis663e3802010-07-08 13:09:47 +00001675 if (Record[Idx++]) { // HasQualifier.
Douglas Gregor40d96a62011-02-28 21:54:11 +00001676 QualifierLoc = ReadNestedNameSpecifierLoc(F, Record, Idx);
Argyrios Kyrtzidis663e3802010-07-08 13:09:47 +00001677 }
1678
1679 TemplateArgumentListInfo ArgInfo;
Douglas Gregordef03542011-02-04 12:01:24 +00001680 bool HasExplicitTemplateArgs = Record[Idx++];
1681 if (HasExplicitTemplateArgs) {
1682 unsigned NumTemplateArgs = Record[Idx++];
Sebastian Redlc3632732010-10-05 15:59:54 +00001683 ArgInfo.setLAngleLoc(ReadSourceLocation(F, Record, Idx));
1684 ArgInfo.setRAngleLoc(ReadSourceLocation(F, Record, Idx));
Argyrios Kyrtzidis663e3802010-07-08 13:09:47 +00001685 for (unsigned i = 0; i != NumTemplateArgs; ++i)
Sebastian Redlc3632732010-10-05 15:59:54 +00001686 ArgInfo.addArgument(ReadTemplateArgumentLoc(F, Record, Idx));
Argyrios Kyrtzidis663e3802010-07-08 13:09:47 +00001687 }
Abramo Bagnara7cc58b42011-10-05 07:56:41 +00001688
1689 bool HadMultipleCandidates = Record[Idx++];
1690
Douglas Gregor409448c2011-07-21 22:35:25 +00001691 NamedDecl *FoundD = ReadDeclAs<NamedDecl>(F, Record, Idx);
Argyrios Kyrtzidis663e3802010-07-08 13:09:47 +00001692 AccessSpecifier AS = (AccessSpecifier)Record[Idx++];
1693 DeclAccessPair FoundDecl = DeclAccessPair::make(FoundD, AS);
1694
Douglas Gregor393f2492011-07-22 00:38:23 +00001695 QualType T = readType(F, Record, Idx);
John McCallf89e55a2010-11-18 06:31:45 +00001696 ExprValueKind VK = static_cast<ExprValueKind>(Record[Idx++]);
1697 ExprObjectKind OK = static_cast<ExprObjectKind>(Record[Idx++]);
Argyrios Kyrtzidis663e3802010-07-08 13:09:47 +00001698 Expr *Base = ReadSubExpr();
Douglas Gregor409448c2011-07-21 22:35:25 +00001699 ValueDecl *MemberD = ReadDeclAs<ValueDecl>(F, Record, Idx);
Sebastian Redlc3632732010-10-05 15:59:54 +00001700 SourceLocation MemberLoc = ReadSourceLocation(F, Record, Idx);
Abramo Bagnara25777432010-08-11 22:01:17 +00001701 DeclarationNameInfo MemberNameInfo(MemberD->getDeclName(), MemberLoc);
Argyrios Kyrtzidis663e3802010-07-08 13:09:47 +00001702 bool IsArrow = Record[Idx++];
1703
Douglas Gregor35942772011-09-09 21:34:22 +00001704 S = MemberExpr::Create(Context, Base, IsArrow, QualifierLoc,
Abramo Bagnara25777432010-08-11 22:01:17 +00001705 MemberD, FoundDecl, MemberNameInfo,
Douglas Gregordef03542011-02-04 12:01:24 +00001706 HasExplicitTemplateArgs ? &ArgInfo : 0, T, VK, OK);
Argyrios Kyrtzidis40451072010-10-15 18:21:24 +00001707 ReadDeclarationNameLoc(F, cast<MemberExpr>(S)->MemberDNLoc,
1708 MemberD->getDeclName(), Record, Idx);
Abramo Bagnara7cc58b42011-10-05 07:56:41 +00001709 if (HadMultipleCandidates)
1710 cast<MemberExpr>(S)->setHadMultipleCandidates(true);
Chris Lattner4c6f9522009-04-27 05:14:47 +00001711 break;
Argyrios Kyrtzidis663e3802010-07-08 13:09:47 +00001712 }
Chris Lattner4c6f9522009-04-27 05:14:47 +00001713
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001714 case EXPR_BINARY_OPERATOR:
Chris Lattner4c6f9522009-04-27 05:14:47 +00001715 S = new (Context) BinaryOperator(Empty);
1716 break;
1717
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001718 case EXPR_COMPOUND_ASSIGN_OPERATOR:
Chris Lattner4c6f9522009-04-27 05:14:47 +00001719 S = new (Context) CompoundAssignOperator(Empty);
1720 break;
1721
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001722 case EXPR_CONDITIONAL_OPERATOR:
Chris Lattner4c6f9522009-04-27 05:14:47 +00001723 S = new (Context) ConditionalOperator(Empty);
1724 break;
1725
John McCall56ca35d2011-02-17 10:25:35 +00001726 case EXPR_BINARY_CONDITIONAL_OPERATOR:
1727 S = new (Context) BinaryConditionalOperator(Empty);
1728 break;
1729
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001730 case EXPR_IMPLICIT_CAST:
Douglas Gregor35942772011-09-09 21:34:22 +00001731 S = ImplicitCastExpr::CreateEmpty(Context,
Sebastian Redl60adf4a2010-08-18 23:56:52 +00001732 /*PathSize*/ Record[ASTStmtReader::NumExprFields]);
Chris Lattner4c6f9522009-04-27 05:14:47 +00001733 break;
1734
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001735 case EXPR_CSTYLE_CAST:
Douglas Gregor35942772011-09-09 21:34:22 +00001736 S = CStyleCastExpr::CreateEmpty(Context,
Sebastian Redl60adf4a2010-08-18 23:56:52 +00001737 /*PathSize*/ Record[ASTStmtReader::NumExprFields]);
Chris Lattner4c6f9522009-04-27 05:14:47 +00001738 break;
1739
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001740 case EXPR_COMPOUND_LITERAL:
Chris Lattner4c6f9522009-04-27 05:14:47 +00001741 S = new (Context) CompoundLiteralExpr(Empty);
1742 break;
1743
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001744 case EXPR_EXT_VECTOR_ELEMENT:
Chris Lattner4c6f9522009-04-27 05:14:47 +00001745 S = new (Context) ExtVectorElementExpr(Empty);
1746 break;
1747
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001748 case EXPR_INIT_LIST:
Douglas Gregor35942772011-09-09 21:34:22 +00001749 S = new (Context) InitListExpr(getContext(), Empty);
Chris Lattner4c6f9522009-04-27 05:14:47 +00001750 break;
1751
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001752 case EXPR_DESIGNATED_INIT:
Douglas Gregor35942772011-09-09 21:34:22 +00001753 S = DesignatedInitExpr::CreateEmpty(Context,
Sebastian Redl60adf4a2010-08-18 23:56:52 +00001754 Record[ASTStmtReader::NumExprFields] - 1);
Mike Stump1eb44332009-09-09 15:08:12 +00001755
Chris Lattner4c6f9522009-04-27 05:14:47 +00001756 break;
1757
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001758 case EXPR_IMPLICIT_VALUE_INIT:
Chris Lattner4c6f9522009-04-27 05:14:47 +00001759 S = new (Context) ImplicitValueInitExpr(Empty);
1760 break;
1761
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001762 case EXPR_VA_ARG:
Chris Lattner4c6f9522009-04-27 05:14:47 +00001763 S = new (Context) VAArgExpr(Empty);
1764 break;
1765
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001766 case EXPR_ADDR_LABEL:
Chris Lattner4c6f9522009-04-27 05:14:47 +00001767 S = new (Context) AddrLabelExpr(Empty);
1768 break;
1769
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001770 case EXPR_STMT:
Chris Lattner4c6f9522009-04-27 05:14:47 +00001771 S = new (Context) StmtExpr(Empty);
1772 break;
1773
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001774 case EXPR_CHOOSE:
Chris Lattner4c6f9522009-04-27 05:14:47 +00001775 S = new (Context) ChooseExpr(Empty);
1776 break;
1777
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001778 case EXPR_GNU_NULL:
Chris Lattner4c6f9522009-04-27 05:14:47 +00001779 S = new (Context) GNUNullExpr(Empty);
1780 break;
1781
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001782 case EXPR_SHUFFLE_VECTOR:
Chris Lattner4c6f9522009-04-27 05:14:47 +00001783 S = new (Context) ShuffleVectorExpr(Empty);
1784 break;
Mike Stump1eb44332009-09-09 15:08:12 +00001785
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001786 case EXPR_BLOCK:
Chris Lattner4c6f9522009-04-27 05:14:47 +00001787 S = new (Context) BlockExpr(Empty);
1788 break;
1789
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001790 case EXPR_BLOCK_DECL_REF:
Chris Lattner4c6f9522009-04-27 05:14:47 +00001791 S = new (Context) BlockDeclRefExpr(Empty);
1792 break;
Mike Stump1eb44332009-09-09 15:08:12 +00001793
Peter Collingbournef111d932011-04-15 00:35:48 +00001794 case EXPR_GENERIC_SELECTION:
1795 S = new (Context) GenericSelectionExpr(Empty);
1796 break;
1797
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001798 case EXPR_OBJC_STRING_LITERAL:
Chris Lattner4c6f9522009-04-27 05:14:47 +00001799 S = new (Context) ObjCStringLiteral(Empty);
1800 break;
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001801 case EXPR_OBJC_ENCODE:
Chris Lattner4c6f9522009-04-27 05:14:47 +00001802 S = new (Context) ObjCEncodeExpr(Empty);
1803 break;
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001804 case EXPR_OBJC_SELECTOR_EXPR:
Chris Lattner4c6f9522009-04-27 05:14:47 +00001805 S = new (Context) ObjCSelectorExpr(Empty);
1806 break;
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001807 case EXPR_OBJC_PROTOCOL_EXPR:
Chris Lattner4c6f9522009-04-27 05:14:47 +00001808 S = new (Context) ObjCProtocolExpr(Empty);
1809 break;
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001810 case EXPR_OBJC_IVAR_REF_EXPR:
Chris Lattner4c6f9522009-04-27 05:14:47 +00001811 S = new (Context) ObjCIvarRefExpr(Empty);
1812 break;
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001813 case EXPR_OBJC_PROPERTY_REF_EXPR:
Chris Lattner4c6f9522009-04-27 05:14:47 +00001814 S = new (Context) ObjCPropertyRefExpr(Empty);
1815 break;
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001816 case EXPR_OBJC_KVC_REF_EXPR:
John McCall12f78a62010-12-02 01:19:52 +00001817 llvm_unreachable("mismatching AST file");
Chris Lattner4c6f9522009-04-27 05:14:47 +00001818 break;
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001819 case EXPR_OBJC_MESSAGE_EXPR:
Douglas Gregor35942772011-09-09 21:34:22 +00001820 S = ObjCMessageExpr::CreateEmpty(Context,
Argyrios Kyrtzidis20718082011-10-03 06:36:51 +00001821 Record[ASTStmtReader::NumExprFields],
1822 Record[ASTStmtReader::NumExprFields + 1]);
Chris Lattner4c6f9522009-04-27 05:14:47 +00001823 break;
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001824 case EXPR_OBJC_ISA:
Steve Narofff242b1b2009-07-24 17:54:45 +00001825 S = new (Context) ObjCIsaExpr(Empty);
1826 break;
John McCallf85e1932011-06-15 23:02:42 +00001827 case EXPR_OBJC_INDIRECT_COPY_RESTORE:
1828 S = new (Context) ObjCIndirectCopyRestoreExpr(Empty);
1829 break;
1830 case EXPR_OBJC_BRIDGED_CAST:
1831 S = new (Context) ObjCBridgedCastExpr(Empty);
1832 break;
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001833 case STMT_OBJC_FOR_COLLECTION:
Chris Lattner4c6f9522009-04-27 05:14:47 +00001834 S = new (Context) ObjCForCollectionStmt(Empty);
1835 break;
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001836 case STMT_OBJC_CATCH:
Chris Lattner4c6f9522009-04-27 05:14:47 +00001837 S = new (Context) ObjCAtCatchStmt(Empty);
1838 break;
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001839 case STMT_OBJC_FINALLY:
Chris Lattner4c6f9522009-04-27 05:14:47 +00001840 S = new (Context) ObjCAtFinallyStmt(Empty);
1841 break;
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001842 case STMT_OBJC_AT_TRY:
Douglas Gregor35942772011-09-09 21:34:22 +00001843 S = ObjCAtTryStmt::CreateEmpty(Context,
Sebastian Redl60adf4a2010-08-18 23:56:52 +00001844 Record[ASTStmtReader::NumStmtFields],
1845 Record[ASTStmtReader::NumStmtFields + 1]);
Chris Lattner4c6f9522009-04-27 05:14:47 +00001846 break;
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001847 case STMT_OBJC_AT_SYNCHRONIZED:
Chris Lattner4c6f9522009-04-27 05:14:47 +00001848 S = new (Context) ObjCAtSynchronizedStmt(Empty);
1849 break;
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001850 case STMT_OBJC_AT_THROW:
Chris Lattner4c6f9522009-04-27 05:14:47 +00001851 S = new (Context) ObjCAtThrowStmt(Empty);
1852 break;
John McCallf85e1932011-06-15 23:02:42 +00001853 case STMT_OBJC_AUTORELEASE_POOL:
1854 S = new (Context) ObjCAutoreleasePoolStmt(Empty);
1855 break;
John McCall7110fd62011-07-15 07:00:14 +00001856 case STMT_SEH_EXCEPT:
1857 S = new (Context) SEHExceptStmt(Empty);
1858 break;
1859 case STMT_SEH_FINALLY:
1860 S = new (Context) SEHFinallyStmt(Empty);
1861 break;
1862 case STMT_SEH_TRY:
1863 S = new (Context) SEHTryStmt(Empty);
1864 break;
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001865 case STMT_CXX_CATCH:
Argyrios Kyrtzidis7cb45e32010-07-22 16:03:56 +00001866 S = new (Context) CXXCatchStmt(Empty);
1867 break;
1868
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001869 case STMT_CXX_TRY:
Douglas Gregor35942772011-09-09 21:34:22 +00001870 S = CXXTryStmt::Create(Context, Empty,
Sebastian Redl60adf4a2010-08-18 23:56:52 +00001871 /*NumHandlers=*/Record[ASTStmtReader::NumStmtFields]);
Argyrios Kyrtzidis7cb45e32010-07-22 16:03:56 +00001872 break;
1873
Richard Smithad762fc2011-04-14 22:09:26 +00001874 case STMT_CXX_FOR_RANGE:
1875 S = new (Context) CXXForRangeStmt(Empty);
1876 break;
1877
Douglas Gregorba0513d2011-10-25 01:33:02 +00001878 case STMT_MS_DEPENDENT_EXISTS:
1879 S = new (Context) MSDependentExistsStmt(SourceLocation(), true,
1880 NestedNameSpecifierLoc(),
1881 DeclarationNameInfo(),
1882 0);
1883 break;
1884
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001885 case EXPR_CXX_OPERATOR_CALL:
Douglas Gregor35942772011-09-09 21:34:22 +00001886 S = new (Context) CXXOperatorCallExpr(Context, Empty);
Argyrios Kyrtzidisba0a9002009-07-14 03:19:21 +00001887 break;
Chris Lattner1817bd42010-05-09 05:36:05 +00001888
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001889 case EXPR_CXX_MEMBER_CALL:
Douglas Gregor35942772011-09-09 21:34:22 +00001890 S = new (Context) CXXMemberCallExpr(Context, Empty);
Chris Lattner1817bd42010-05-09 05:36:05 +00001891 break;
Douglas Gregor39da0b82009-09-09 23:08:42 +00001892
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001893 case EXPR_CXX_CONSTRUCT:
Argyrios Kyrtzidis6d00c132010-07-10 11:46:15 +00001894 S = new (Context) CXXConstructExpr(Empty);
1895 break;
1896
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001897 case EXPR_CXX_TEMPORARY_OBJECT:
Argyrios Kyrtzidis6d00c132010-07-10 11:46:15 +00001898 S = new (Context) CXXTemporaryObjectExpr(Empty);
Douglas Gregor39da0b82009-09-09 23:08:42 +00001899 break;
Sam Weinigce757a72010-01-16 21:21:01 +00001900
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001901 case EXPR_CXX_STATIC_CAST:
Douglas Gregor35942772011-09-09 21:34:22 +00001902 S = CXXStaticCastExpr::CreateEmpty(Context,
Sebastian Redl60adf4a2010-08-18 23:56:52 +00001903 /*PathSize*/ Record[ASTStmtReader::NumExprFields]);
Sam Weinigce757a72010-01-16 21:21:01 +00001904 break;
1905
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001906 case EXPR_CXX_DYNAMIC_CAST:
Douglas Gregor35942772011-09-09 21:34:22 +00001907 S = CXXDynamicCastExpr::CreateEmpty(Context,
Sebastian Redl60adf4a2010-08-18 23:56:52 +00001908 /*PathSize*/ Record[ASTStmtReader::NumExprFields]);
Sam Weinigce757a72010-01-16 21:21:01 +00001909 break;
1910
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001911 case EXPR_CXX_REINTERPRET_CAST:
Douglas Gregor35942772011-09-09 21:34:22 +00001912 S = CXXReinterpretCastExpr::CreateEmpty(Context,
Sebastian Redl60adf4a2010-08-18 23:56:52 +00001913 /*PathSize*/ Record[ASTStmtReader::NumExprFields]);
Sam Weinigce757a72010-01-16 21:21:01 +00001914 break;
1915
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001916 case EXPR_CXX_CONST_CAST:
Douglas Gregor35942772011-09-09 21:34:22 +00001917 S = CXXConstCastExpr::CreateEmpty(Context);
Sam Weinigce757a72010-01-16 21:21:01 +00001918 break;
1919
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001920 case EXPR_CXX_FUNCTIONAL_CAST:
Douglas Gregor35942772011-09-09 21:34:22 +00001921 S = CXXFunctionalCastExpr::CreateEmpty(Context,
Sebastian Redl60adf4a2010-08-18 23:56:52 +00001922 /*PathSize*/ Record[ASTStmtReader::NumExprFields]);
Sam Weinigce757a72010-01-16 21:21:01 +00001923 break;
1924
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001925 case EXPR_CXX_BOOL_LITERAL:
Sam Weinigeb7f9612010-02-07 06:32:43 +00001926 S = new (Context) CXXBoolLiteralExpr(Empty);
1927 break;
Sam Weinigce757a72010-01-16 21:21:01 +00001928
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001929 case EXPR_CXX_NULL_PTR_LITERAL:
Sam Weinigeb7f9612010-02-07 06:32:43 +00001930 S = new (Context) CXXNullPtrLiteralExpr(Empty);
1931 break;
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001932 case EXPR_CXX_TYPEID_EXPR:
Chris Lattner14ab24f2010-05-09 06:03:39 +00001933 S = new (Context) CXXTypeidExpr(Empty, true);
1934 break;
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001935 case EXPR_CXX_TYPEID_TYPE:
Chris Lattner14ab24f2010-05-09 06:03:39 +00001936 S = new (Context) CXXTypeidExpr(Empty, false);
1937 break;
Francois Pichet01b7c302010-09-08 12:20:18 +00001938 case EXPR_CXX_UUIDOF_EXPR:
1939 S = new (Context) CXXUuidofExpr(Empty, true);
1940 break;
1941 case EXPR_CXX_UUIDOF_TYPE:
1942 S = new (Context) CXXUuidofExpr(Empty, false);
1943 break;
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001944 case EXPR_CXX_THIS:
Chris Lattner2fbdfcd2010-05-09 06:15:05 +00001945 S = new (Context) CXXThisExpr(Empty);
1946 break;
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001947 case EXPR_CXX_THROW:
Chris Lattner2fbdfcd2010-05-09 06:15:05 +00001948 S = new (Context) CXXThrowExpr(Empty);
1949 break;
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001950 case EXPR_CXX_DEFAULT_ARG: {
Sebastian Redl60adf4a2010-08-18 23:56:52 +00001951 bool HasOtherExprStored = Record[ASTStmtReader::NumExprFields];
Argyrios Kyrtzidis8a507332010-07-02 23:30:15 +00001952 if (HasOtherExprStored) {
1953 Expr *SubExpr = ReadSubExpr();
Douglas Gregor35942772011-09-09 21:34:22 +00001954 S = CXXDefaultArgExpr::Create(Context, SourceLocation(), 0, SubExpr);
Argyrios Kyrtzidis8a507332010-07-02 23:30:15 +00001955 } else
1956 S = new (Context) CXXDefaultArgExpr(Empty);
Chris Lattner030854b2010-05-09 06:40:08 +00001957 break;
Argyrios Kyrtzidis8a507332010-07-02 23:30:15 +00001958 }
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001959 case EXPR_CXX_BIND_TEMPORARY:
Chris Lattnerd2598362010-05-10 00:25:06 +00001960 S = new (Context) CXXBindTemporaryExpr(Empty);
1961 break;
Douglas Gregore2ca6d42010-09-02 21:50:02 +00001962
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001963 case EXPR_CXX_SCALAR_VALUE_INIT:
Douglas Gregored8abf12010-07-08 06:14:04 +00001964 S = new (Context) CXXScalarValueInitExpr(Empty);
Chris Lattner59218632010-05-10 01:22:27 +00001965 break;
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001966 case EXPR_CXX_NEW:
Chris Lattner59218632010-05-10 01:22:27 +00001967 S = new (Context) CXXNewExpr(Empty);
1968 break;
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001969 case EXPR_CXX_DELETE:
Argyrios Kyrtzidis95fc98c2010-06-22 17:07:59 +00001970 S = new (Context) CXXDeleteExpr(Empty);
1971 break;
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001972 case EXPR_CXX_PSEUDO_DESTRUCTOR:
Argyrios Kyrtzidisde4bd182010-06-28 09:32:03 +00001973 S = new (Context) CXXPseudoDestructorExpr(Empty);
1974 break;
Chris Lattner59218632010-05-10 01:22:27 +00001975
John McCall4765fa02010-12-06 08:20:24 +00001976 case EXPR_EXPR_WITH_CLEANUPS:
1977 S = new (Context) ExprWithCleanups(Empty);
Chris Lattnerd2598362010-05-10 00:25:06 +00001978 break;
Argyrios Kyrtzidis8dfbd8b2010-06-24 08:57:31 +00001979
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001980 case EXPR_CXX_DEPENDENT_SCOPE_MEMBER:
Douglas Gregor35942772011-09-09 21:34:22 +00001981 S = CXXDependentScopeMemberExpr::CreateEmpty(Context,
Douglas Gregordef03542011-02-04 12:01:24 +00001982 /*HasExplicitTemplateArgs=*/Record[ASTStmtReader::NumExprFields],
1983 /*NumTemplateArgs=*/Record[ASTStmtReader::NumExprFields]
1984 ? Record[ASTStmtReader::NumExprFields + 1]
1985 : 0);
Argyrios Kyrtzidis8dfbd8b2010-06-24 08:57:31 +00001986 break;
1987
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001988 case EXPR_CXX_DEPENDENT_SCOPE_DECL_REF:
Douglas Gregor35942772011-09-09 21:34:22 +00001989 S = DependentScopeDeclRefExpr::CreateEmpty(Context,
Douglas Gregordef03542011-02-04 12:01:24 +00001990 /*HasExplicitTemplateArgs=*/Record[ASTStmtReader::NumExprFields],
1991 /*NumTemplateArgs=*/Record[ASTStmtReader::NumExprFields]
1992 ? Record[ASTStmtReader::NumExprFields + 1]
1993 : 0);
Argyrios Kyrtzidis12dffcd2010-06-28 09:31:56 +00001994 break;
1995
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001996 case EXPR_CXX_UNRESOLVED_CONSTRUCT:
Douglas Gregor35942772011-09-09 21:34:22 +00001997 S = CXXUnresolvedConstructExpr::CreateEmpty(Context,
Sebastian Redl60adf4a2010-08-18 23:56:52 +00001998 /*NumArgs=*/Record[ASTStmtReader::NumExprFields]);
Argyrios Kyrtzidisa77eb082010-06-25 09:03:26 +00001999 break;
2000
Sebastian Redl8538e8d2010-08-18 23:57:32 +00002001 case EXPR_CXX_UNRESOLVED_MEMBER:
Douglas Gregor35942772011-09-09 21:34:22 +00002002 S = UnresolvedMemberExpr::CreateEmpty(Context,
Douglas Gregordef03542011-02-04 12:01:24 +00002003 /*HasExplicitTemplateArgs=*/Record[ASTStmtReader::NumExprFields],
2004 /*NumTemplateArgs=*/Record[ASTStmtReader::NumExprFields]
2005 ? Record[ASTStmtReader::NumExprFields + 1]
2006 : 0);
Argyrios Kyrtzidis8dfbd8b2010-06-24 08:57:31 +00002007 break;
Argyrios Kyrtzidisbd65bb52010-06-25 09:03:34 +00002008
Sebastian Redl8538e8d2010-08-18 23:57:32 +00002009 case EXPR_CXX_UNRESOLVED_LOOKUP:
Douglas Gregor35942772011-09-09 21:34:22 +00002010 S = UnresolvedLookupExpr::CreateEmpty(Context,
Douglas Gregordef03542011-02-04 12:01:24 +00002011 /*HasExplicitTemplateArgs=*/Record[ASTStmtReader::NumExprFields],
2012 /*NumTemplateArgs=*/Record[ASTStmtReader::NumExprFields]
2013 ? Record[ASTStmtReader::NumExprFields + 1]
2014 : 0);
Argyrios Kyrtzidisbd65bb52010-06-25 09:03:34 +00002015 break;
Argyrios Kyrtzidis6d00c132010-07-10 11:46:15 +00002016
Sebastian Redl8538e8d2010-08-18 23:57:32 +00002017 case EXPR_CXX_UNARY_TYPE_TRAIT:
Argyrios Kyrtzidis6d00c132010-07-10 11:46:15 +00002018 S = new (Context) UnaryTypeTraitExpr(Empty);
2019 break;
Sebastian Redl6b219d02010-09-10 20:55:54 +00002020
Francois Pichetf1872372010-12-08 22:35:30 +00002021 case EXPR_BINARY_TYPE_TRAIT:
Francois Pichet6ad6f282010-12-07 00:08:36 +00002022 S = new (Context) BinaryTypeTraitExpr(Empty);
2023 break;
2024
John Wiegley21ff2e52011-04-28 00:16:57 +00002025 case EXPR_ARRAY_TYPE_TRAIT:
2026 S = new (Context) ArrayTypeTraitExpr(Empty);
2027 break;
2028
John Wiegley55262202011-04-25 06:54:41 +00002029 case EXPR_CXX_EXPRESSION_TRAIT:
2030 S = new (Context) ExpressionTraitExpr(Empty);
2031 break;
2032
Sebastian Redl6b219d02010-09-10 20:55:54 +00002033 case EXPR_CXX_NOEXCEPT:
2034 S = new (Context) CXXNoexceptExpr(Empty);
2035 break;
John McCall7cd7d1a2010-11-15 23:31:06 +00002036
Douglas Gregorbe230c32011-01-03 17:17:50 +00002037 case EXPR_PACK_EXPANSION:
2038 S = new (Context) PackExpansionExpr(Empty);
2039 break;
2040
Douglas Gregoree8aff02011-01-04 17:33:58 +00002041 case EXPR_SIZEOF_PACK:
2042 S = new (Context) SizeOfPackExpr(Empty);
2043 break;
2044
John McCall7110fd62011-07-15 07:00:14 +00002045 case EXPR_SUBST_NON_TYPE_TEMPLATE_PARM:
2046 S = new (Context) SubstNonTypeTemplateParmExpr(Empty);
2047 break;
2048
Douglas Gregorc7793c72011-01-15 01:15:58 +00002049 case EXPR_SUBST_NON_TYPE_TEMPLATE_PARM_PACK:
2050 S = new (Context) SubstNonTypeTemplateParmPackExpr(Empty);
2051 break;
2052
Douglas Gregor03e80032011-06-21 17:03:29 +00002053 case EXPR_MATERIALIZE_TEMPORARY:
2054 S = new (Context) MaterializeTemporaryExpr(Empty);
2055 break;
2056
John McCall56ca35d2011-02-17 10:25:35 +00002057 case EXPR_OPAQUE_VALUE: {
2058 unsigned key = Record[ASTStmtReader::NumExprFields];
2059 OpaqueValueExpr *&expr = OpaqueValueExprs[key];
2060
2061 // If we already have an entry for this opaque value expression,
2062 // don't bother reading it again.
2063 if (expr) {
2064 StmtStack.push_back(expr);
2065 continue;
2066 }
2067
2068 S = expr = new (Context) OpaqueValueExpr(Empty);
John McCall7cd7d1a2010-11-15 23:31:06 +00002069 break;
John McCall56ca35d2011-02-17 10:25:35 +00002070 }
Peter Collingbournee08ce652011-02-09 21:07:24 +00002071
2072 case EXPR_CUDA_KERNEL_CALL:
Douglas Gregor35942772011-09-09 21:34:22 +00002073 S = new (Context) CUDAKernelCallExpr(Context, Empty);
Peter Collingbournee08ce652011-02-09 21:07:24 +00002074 break;
Tanya Lattner61eee0c2011-06-04 00:47:47 +00002075
2076 case EXPR_ASTYPE:
2077 S = new (Context) AsTypeExpr(Empty);
2078 break;
Eli Friedman276b0612011-10-11 02:20:01 +00002079
John McCall4b9c2d22011-11-06 09:01:30 +00002080 case EXPR_PSEUDO_OBJECT: {
2081 unsigned numSemanticExprs = Record[ASTStmtReader::NumExprFields];
2082 S = PseudoObjectExpr::Create(Context, Empty, numSemanticExprs);
2083 break;
2084 }
2085
Eli Friedman276b0612011-10-11 02:20:01 +00002086 case EXPR_ATOMIC:
2087 S = new (Context) AtomicExpr(Empty);
2088 break;
Chris Lattner4c6f9522009-04-27 05:14:47 +00002089 }
Argyrios Kyrtzidis6d00c132010-07-10 11:46:15 +00002090
Chris Lattner4c6f9522009-04-27 05:14:47 +00002091 // We hit a STMT_STOP, so we're done with this expression.
2092 if (Finished)
2093 break;
2094
2095 ++NumStatementsRead;
2096
Argyrios Kyrtzidise6f08682011-10-21 23:02:28 +00002097 if (S && !IsStmtReference) {
Argyrios Kyrtzidis919e6932010-06-28 22:28:35 +00002098 Reader.Visit(S);
Argyrios Kyrtzidise6f08682011-10-21 23:02:28 +00002099 StmtEntries[Cursor.GetCurrentBitNo()] = S;
2100 }
2101
Chris Lattner4c6f9522009-04-27 05:14:47 +00002102
2103 assert(Idx == Record.size() && "Invalid deserialization of statement");
2104 StmtStack.push_back(S);
2105 }
Argyrios Kyrtzidis919e6932010-06-28 22:28:35 +00002106
2107#ifndef NDEBUG
2108 assert(StmtStack.size() > PrevNumStmts && "Read too many sub stmts!");
2109 assert(StmtStack.size() == PrevNumStmts + 1 && "Extra expressions on stack!");
2110#endif
2111
2112 return StmtStack.pop_back_val();
Chris Lattner4c6f9522009-04-27 05:14:47 +00002113}