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