blob: 623ee1ffc0fa7071908ee2dcd27002f97701e60e [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;
Abramo Bagnarae4b92762012-01-27 09:46:47 +000081
82 /// \brief Read and initialize a ExplicitTemplateArgumentList structure.
83 void ReadTemplateKWAndArgsInfo(ASTTemplateKWAndArgsInfo &Args,
84 unsigned NumTemplateArgs);
Argyrios Kyrtzidis36c76f02010-06-28 09:31:48 +000085 /// \brief Read and initialize a ExplicitTemplateArgumentList structure.
Argyrios Kyrtzidisb0c3e092011-09-22 20:07:03 +000086 void ReadExplicitTemplateArgumentList(ASTTemplateArgumentListInfo &ArgList,
Argyrios Kyrtzidis919e6932010-06-28 22:28:35 +000087 unsigned NumTemplateArgs);
Chris Lattner4c6f9522009-04-27 05:14:47 +000088
Argyrios Kyrtzidis919e6932010-06-28 22:28:35 +000089 void VisitStmt(Stmt *S);
John McCall7110fd62011-07-15 07:00:14 +000090#define STMT(Type, Base) \
91 void Visit##Type(Type *);
92#include "clang/AST/StmtNodes.inc"
Chris Lattner4c6f9522009-04-27 05:14:47 +000093 };
94}
95
Sebastian Redl60adf4a2010-08-18 23:56:52 +000096void ASTStmtReader::
Abramo Bagnarae4b92762012-01-27 09:46:47 +000097ReadTemplateKWAndArgsInfo(ASTTemplateKWAndArgsInfo &Args,
98 unsigned NumTemplateArgs) {
99 SourceLocation TemplateKWLoc = ReadSourceLocation(Record, Idx);
Argyrios Kyrtzidis36c76f02010-06-28 09:31:48 +0000100 TemplateArgumentListInfo ArgInfo;
Sebastian Redlc3632732010-10-05 15:59:54 +0000101 ArgInfo.setLAngleLoc(ReadSourceLocation(Record, Idx));
102 ArgInfo.setRAngleLoc(ReadSourceLocation(Record, Idx));
Argyrios Kyrtzidis36c76f02010-06-28 09:31:48 +0000103 for (unsigned i = 0; i != NumTemplateArgs; ++i)
Sebastian Redl577d4792010-07-22 22:43:28 +0000104 ArgInfo.addArgument(
Sebastian Redlc3632732010-10-05 15:59:54 +0000105 Reader.ReadTemplateArgumentLoc(F, Record, Idx));
Abramo Bagnarae4b92762012-01-27 09:46:47 +0000106 Args.initializeFrom(TemplateKWLoc, ArgInfo);
Argyrios Kyrtzidis36c76f02010-06-28 09:31:48 +0000107}
108
Sebastian Redl60adf4a2010-08-18 23:56:52 +0000109void ASTStmtReader::VisitStmt(Stmt *S) {
Chris Lattner4c6f9522009-04-27 05:14:47 +0000110 assert(Idx == NumStmtFields && "Incorrect statement field count");
Chris Lattner4c6f9522009-04-27 05:14:47 +0000111}
112
Sebastian Redl60adf4a2010-08-18 23:56:52 +0000113void ASTStmtReader::VisitNullStmt(NullStmt *S) {
Chris Lattner4c6f9522009-04-27 05:14:47 +0000114 VisitStmt(S);
Sebastian Redlc3632732010-10-05 15:59:54 +0000115 S->setSemiLoc(ReadSourceLocation(Record, Idx));
Argyrios Kyrtzidise2ca8282011-09-01 21:53:45 +0000116 S->HasLeadingEmptyMacro = Record[Idx++];
Chris Lattner4c6f9522009-04-27 05:14:47 +0000117}
118
Sebastian Redl60adf4a2010-08-18 23:56:52 +0000119void ASTStmtReader::VisitCompoundStmt(CompoundStmt *S) {
Chris Lattner4c6f9522009-04-27 05:14:47 +0000120 VisitStmt(S);
Chris Lattner5f9e2722011-07-23 10:55:15 +0000121 SmallVector<Stmt *, 16> Stmts;
Chris Lattner4c6f9522009-04-27 05:14:47 +0000122 unsigned NumStmts = Record[Idx++];
Argyrios Kyrtzidis919e6932010-06-28 22:28:35 +0000123 while (NumStmts--)
Argyrios Kyrtzidisd98a2ab2010-06-29 22:46:25 +0000124 Stmts.push_back(Reader.ReadSubStmt());
Douglas Gregor35942772011-09-09 21:34:22 +0000125 S->setStmts(Reader.getContext(), Stmts.data(), Stmts.size());
Sebastian Redlc3632732010-10-05 15:59:54 +0000126 S->setLBracLoc(ReadSourceLocation(Record, Idx));
127 S->setRBracLoc(ReadSourceLocation(Record, Idx));
Chris Lattner4c6f9522009-04-27 05:14:47 +0000128}
129
Sebastian Redl60adf4a2010-08-18 23:56:52 +0000130void ASTStmtReader::VisitSwitchCase(SwitchCase *S) {
Chris Lattner4c6f9522009-04-27 05:14:47 +0000131 VisitStmt(S);
132 Reader.RecordSwitchCaseID(S, Record[Idx++]);
Chris Lattner4c6f9522009-04-27 05:14:47 +0000133}
134
Sebastian Redl60adf4a2010-08-18 23:56:52 +0000135void ASTStmtReader::VisitCaseStmt(CaseStmt *S) {
Chris Lattner4c6f9522009-04-27 05:14:47 +0000136 VisitSwitchCase(S);
Argyrios Kyrtzidisd98a2ab2010-06-29 22:46:25 +0000137 S->setLHS(Reader.ReadSubExpr());
138 S->setRHS(Reader.ReadSubExpr());
139 S->setSubStmt(Reader.ReadSubStmt());
Sebastian Redlc3632732010-10-05 15:59:54 +0000140 S->setCaseLoc(ReadSourceLocation(Record, Idx));
141 S->setEllipsisLoc(ReadSourceLocation(Record, Idx));
142 S->setColonLoc(ReadSourceLocation(Record, Idx));
Chris Lattner4c6f9522009-04-27 05:14:47 +0000143}
144
Sebastian Redl60adf4a2010-08-18 23:56:52 +0000145void ASTStmtReader::VisitDefaultStmt(DefaultStmt *S) {
Chris Lattner4c6f9522009-04-27 05:14:47 +0000146 VisitSwitchCase(S);
Argyrios Kyrtzidisd98a2ab2010-06-29 22:46:25 +0000147 S->setSubStmt(Reader.ReadSubStmt());
Sebastian Redlc3632732010-10-05 15:59:54 +0000148 S->setDefaultLoc(ReadSourceLocation(Record, Idx));
149 S->setColonLoc(ReadSourceLocation(Record, Idx));
Chris Lattner4c6f9522009-04-27 05:14:47 +0000150}
151
Sebastian Redl60adf4a2010-08-18 23:56:52 +0000152void ASTStmtReader::VisitLabelStmt(LabelStmt *S) {
Chris Lattner4c6f9522009-04-27 05:14:47 +0000153 VisitStmt(S);
Douglas Gregor409448c2011-07-21 22:35:25 +0000154 LabelDecl *LD = ReadDeclAs<LabelDecl>(Record, Idx);
Chris Lattnerad8dcf42011-02-17 07:39:24 +0000155 LD->setStmt(S);
156 S->setDecl(LD);
Argyrios Kyrtzidisd98a2ab2010-06-29 22:46:25 +0000157 S->setSubStmt(Reader.ReadSubStmt());
Sebastian Redlc3632732010-10-05 15:59:54 +0000158 S->setIdentLoc(ReadSourceLocation(Record, Idx));
Chris Lattner4c6f9522009-04-27 05:14:47 +0000159}
160
Sebastian Redl60adf4a2010-08-18 23:56:52 +0000161void ASTStmtReader::VisitIfStmt(IfStmt *S) {
Chris Lattner4c6f9522009-04-27 05:14:47 +0000162 VisitStmt(S);
Douglas Gregor35942772011-09-09 21:34:22 +0000163 S->setConditionVariable(Reader.getContext(),
Douglas Gregor409448c2011-07-21 22:35:25 +0000164 ReadDeclAs<VarDecl>(Record, Idx));
Argyrios Kyrtzidisd98a2ab2010-06-29 22:46:25 +0000165 S->setCond(Reader.ReadSubExpr());
166 S->setThen(Reader.ReadSubStmt());
167 S->setElse(Reader.ReadSubStmt());
Sebastian Redlc3632732010-10-05 15:59:54 +0000168 S->setIfLoc(ReadSourceLocation(Record, Idx));
169 S->setElseLoc(ReadSourceLocation(Record, Idx));
Chris Lattner4c6f9522009-04-27 05:14:47 +0000170}
171
Sebastian Redl60adf4a2010-08-18 23:56:52 +0000172void ASTStmtReader::VisitSwitchStmt(SwitchStmt *S) {
Chris Lattner4c6f9522009-04-27 05:14:47 +0000173 VisitStmt(S);
Douglas Gregor35942772011-09-09 21:34:22 +0000174 S->setConditionVariable(Reader.getContext(),
Douglas Gregor409448c2011-07-21 22:35:25 +0000175 ReadDeclAs<VarDecl>(Record, Idx));
Argyrios Kyrtzidisd98a2ab2010-06-29 22:46:25 +0000176 S->setCond(Reader.ReadSubExpr());
177 S->setBody(Reader.ReadSubStmt());
Sebastian Redlc3632732010-10-05 15:59:54 +0000178 S->setSwitchLoc(ReadSourceLocation(Record, Idx));
Ted Kremenek559fb552010-09-09 00:05:53 +0000179 if (Record[Idx++])
180 S->setAllEnumCasesCovered();
181
Chris Lattner4c6f9522009-04-27 05:14:47 +0000182 SwitchCase *PrevSC = 0;
183 for (unsigned N = Record.size(); Idx != N; ++Idx) {
184 SwitchCase *SC = Reader.getSwitchCaseWithID(Record[Idx]);
185 if (PrevSC)
186 PrevSC->setNextSwitchCase(SC);
187 else
188 S->setSwitchCaseList(SC);
Mike Stump1eb44332009-09-09 15:08:12 +0000189
Chris Lattner4c6f9522009-04-27 05:14:47 +0000190 PrevSC = SC;
191 }
Chris Lattner4c6f9522009-04-27 05:14:47 +0000192}
193
Sebastian Redl60adf4a2010-08-18 23:56:52 +0000194void ASTStmtReader::VisitWhileStmt(WhileStmt *S) {
Chris Lattner4c6f9522009-04-27 05:14:47 +0000195 VisitStmt(S);
Douglas Gregor35942772011-09-09 21:34:22 +0000196 S->setConditionVariable(Reader.getContext(),
Douglas Gregor409448c2011-07-21 22:35:25 +0000197 ReadDeclAs<VarDecl>(Record, Idx));
198
Argyrios Kyrtzidisd98a2ab2010-06-29 22:46:25 +0000199 S->setCond(Reader.ReadSubExpr());
200 S->setBody(Reader.ReadSubStmt());
Sebastian Redlc3632732010-10-05 15:59:54 +0000201 S->setWhileLoc(ReadSourceLocation(Record, Idx));
Chris Lattner4c6f9522009-04-27 05:14:47 +0000202}
203
Sebastian Redl60adf4a2010-08-18 23:56:52 +0000204void ASTStmtReader::VisitDoStmt(DoStmt *S) {
Chris Lattner4c6f9522009-04-27 05:14:47 +0000205 VisitStmt(S);
Argyrios Kyrtzidisd98a2ab2010-06-29 22:46:25 +0000206 S->setCond(Reader.ReadSubExpr());
207 S->setBody(Reader.ReadSubStmt());
Sebastian Redlc3632732010-10-05 15:59:54 +0000208 S->setDoLoc(ReadSourceLocation(Record, Idx));
209 S->setWhileLoc(ReadSourceLocation(Record, Idx));
210 S->setRParenLoc(ReadSourceLocation(Record, Idx));
Chris Lattner4c6f9522009-04-27 05:14:47 +0000211}
212
Sebastian Redl60adf4a2010-08-18 23:56:52 +0000213void ASTStmtReader::VisitForStmt(ForStmt *S) {
Chris Lattner4c6f9522009-04-27 05:14:47 +0000214 VisitStmt(S);
Argyrios Kyrtzidisd98a2ab2010-06-29 22:46:25 +0000215 S->setInit(Reader.ReadSubStmt());
216 S->setCond(Reader.ReadSubExpr());
Douglas Gregor35942772011-09-09 21:34:22 +0000217 S->setConditionVariable(Reader.getContext(),
Douglas Gregor409448c2011-07-21 22:35:25 +0000218 ReadDeclAs<VarDecl>(Record, Idx));
Argyrios Kyrtzidisd98a2ab2010-06-29 22:46:25 +0000219 S->setInc(Reader.ReadSubExpr());
220 S->setBody(Reader.ReadSubStmt());
Sebastian Redlc3632732010-10-05 15:59:54 +0000221 S->setForLoc(ReadSourceLocation(Record, Idx));
222 S->setLParenLoc(ReadSourceLocation(Record, Idx));
223 S->setRParenLoc(ReadSourceLocation(Record, Idx));
Chris Lattner4c6f9522009-04-27 05:14:47 +0000224}
225
Sebastian Redl60adf4a2010-08-18 23:56:52 +0000226void ASTStmtReader::VisitGotoStmt(GotoStmt *S) {
Chris Lattner4c6f9522009-04-27 05:14:47 +0000227 VisitStmt(S);
Douglas Gregor409448c2011-07-21 22:35:25 +0000228 S->setLabel(ReadDeclAs<LabelDecl>(Record, Idx));
Sebastian Redlc3632732010-10-05 15:59:54 +0000229 S->setGotoLoc(ReadSourceLocation(Record, Idx));
230 S->setLabelLoc(ReadSourceLocation(Record, Idx));
Chris Lattner4c6f9522009-04-27 05:14:47 +0000231}
232
Sebastian Redl60adf4a2010-08-18 23:56:52 +0000233void ASTStmtReader::VisitIndirectGotoStmt(IndirectGotoStmt *S) {
Chris Lattner4c6f9522009-04-27 05:14:47 +0000234 VisitStmt(S);
Sebastian Redlc3632732010-10-05 15:59:54 +0000235 S->setGotoLoc(ReadSourceLocation(Record, Idx));
236 S->setStarLoc(ReadSourceLocation(Record, Idx));
Argyrios Kyrtzidisd98a2ab2010-06-29 22:46:25 +0000237 S->setTarget(Reader.ReadSubExpr());
Chris Lattner4c6f9522009-04-27 05:14:47 +0000238}
239
Sebastian Redl60adf4a2010-08-18 23:56:52 +0000240void ASTStmtReader::VisitContinueStmt(ContinueStmt *S) {
Chris Lattner4c6f9522009-04-27 05:14:47 +0000241 VisitStmt(S);
Sebastian Redlc3632732010-10-05 15:59:54 +0000242 S->setContinueLoc(ReadSourceLocation(Record, Idx));
Chris Lattner4c6f9522009-04-27 05:14:47 +0000243}
244
Sebastian Redl60adf4a2010-08-18 23:56:52 +0000245void ASTStmtReader::VisitBreakStmt(BreakStmt *S) {
Chris Lattner4c6f9522009-04-27 05:14:47 +0000246 VisitStmt(S);
Sebastian Redlc3632732010-10-05 15:59:54 +0000247 S->setBreakLoc(ReadSourceLocation(Record, Idx));
Chris Lattner4c6f9522009-04-27 05:14:47 +0000248}
249
Sebastian Redl60adf4a2010-08-18 23:56:52 +0000250void ASTStmtReader::VisitReturnStmt(ReturnStmt *S) {
Chris Lattner4c6f9522009-04-27 05:14:47 +0000251 VisitStmt(S);
Argyrios Kyrtzidisd98a2ab2010-06-29 22:46:25 +0000252 S->setRetValue(Reader.ReadSubExpr());
Sebastian Redlc3632732010-10-05 15:59:54 +0000253 S->setReturnLoc(ReadSourceLocation(Record, Idx));
Douglas Gregor409448c2011-07-21 22:35:25 +0000254 S->setNRVOCandidate(ReadDeclAs<VarDecl>(Record, Idx));
Chris Lattner4c6f9522009-04-27 05:14:47 +0000255}
256
Sebastian Redl60adf4a2010-08-18 23:56:52 +0000257void ASTStmtReader::VisitDeclStmt(DeclStmt *S) {
Chris Lattner4c6f9522009-04-27 05:14:47 +0000258 VisitStmt(S);
Sebastian Redlc3632732010-10-05 15:59:54 +0000259 S->setStartLoc(ReadSourceLocation(Record, Idx));
260 S->setEndLoc(ReadSourceLocation(Record, Idx));
Chris Lattner4c6f9522009-04-27 05:14:47 +0000261
262 if (Idx + 1 == Record.size()) {
263 // Single declaration
Douglas Gregor409448c2011-07-21 22:35:25 +0000264 S->setDeclGroup(DeclGroupRef(ReadDecl(Record, Idx)));
Chris Lattner4c6f9522009-04-27 05:14:47 +0000265 } else {
Chris Lattner5f9e2722011-07-23 10:55:15 +0000266 SmallVector<Decl *, 16> Decls;
Douglas Gregor409448c2011-07-21 22:35:25 +0000267 Decls.reserve(Record.size() - Idx);
268 for (unsigned N = Record.size(); Idx != N; )
269 Decls.push_back(ReadDecl(Record, Idx));
Douglas Gregor35942772011-09-09 21:34:22 +0000270 S->setDeclGroup(DeclGroupRef(DeclGroup::Create(Reader.getContext(),
Douglas Gregor75fdb232009-05-22 22:45:36 +0000271 Decls.data(),
272 Decls.size())));
Chris Lattner4c6f9522009-04-27 05:14:47 +0000273 }
Chris Lattner4c6f9522009-04-27 05:14:47 +0000274}
275
Sebastian Redl60adf4a2010-08-18 23:56:52 +0000276void ASTStmtReader::VisitAsmStmt(AsmStmt *S) {
Chris Lattner4c6f9522009-04-27 05:14:47 +0000277 VisitStmt(S);
278 unsigned NumOutputs = Record[Idx++];
279 unsigned NumInputs = Record[Idx++];
280 unsigned NumClobbers = Record[Idx++];
Sebastian Redlc3632732010-10-05 15:59:54 +0000281 S->setAsmLoc(ReadSourceLocation(Record, Idx));
282 S->setRParenLoc(ReadSourceLocation(Record, Idx));
Chris Lattner4c6f9522009-04-27 05:14:47 +0000283 S->setVolatile(Record[Idx++]);
284 S->setSimple(Record[Idx++]);
Mike Stump3b11fd32010-01-04 22:37:17 +0000285 S->setMSAsm(Record[Idx++]);
Mike Stump1eb44332009-09-09 15:08:12 +0000286
Argyrios Kyrtzidisd98a2ab2010-06-29 22:46:25 +0000287 S->setAsmString(cast_or_null<StringLiteral>(Reader.ReadSubStmt()));
Chris Lattner4c6f9522009-04-27 05:14:47 +0000288
289 // Outputs and inputs
Chris Lattner5f9e2722011-07-23 10:55:15 +0000290 SmallVector<IdentifierInfo *, 16> Names;
291 SmallVector<StringLiteral*, 16> Constraints;
292 SmallVector<Stmt*, 16> Exprs;
Chris Lattner4c6f9522009-04-27 05:14:47 +0000293 for (unsigned I = 0, N = NumOutputs + NumInputs; I != N; ++I) {
Douglas Gregor95eab172011-07-28 20:55:49 +0000294 Names.push_back(Reader.GetIdentifierInfo(F, Record, Idx));
Argyrios Kyrtzidisd98a2ab2010-06-29 22:46:25 +0000295 Constraints.push_back(cast_or_null<StringLiteral>(Reader.ReadSubStmt()));
296 Exprs.push_back(Reader.ReadSubStmt());
Chris Lattner4c6f9522009-04-27 05:14:47 +0000297 }
Chris Lattner4c6f9522009-04-27 05:14:47 +0000298
299 // Constraints
Chris Lattner5f9e2722011-07-23 10:55:15 +0000300 SmallVector<StringLiteral*, 16> Clobbers;
Chris Lattner4c6f9522009-04-27 05:14:47 +0000301 for (unsigned I = 0; I != NumClobbers; ++I)
Argyrios Kyrtzidisd98a2ab2010-06-29 22:46:25 +0000302 Clobbers.push_back(cast_or_null<StringLiteral>(Reader.ReadSubStmt()));
Anders Carlssonfdba9c02010-01-30 19:34:25 +0000303
Douglas Gregor35942772011-09-09 21:34:22 +0000304 S->setOutputsAndInputsAndClobbers(Reader.getContext(),
Anders Carlssonacb6bcb2010-01-30 20:38:10 +0000305 Names.data(), Constraints.data(),
Anders Carlssonfdba9c02010-01-30 19:34:25 +0000306 Exprs.data(), NumOutputs, NumInputs,
307 Clobbers.data(), NumClobbers);
Chris Lattner4c6f9522009-04-27 05:14:47 +0000308}
309
Sebastian Redl60adf4a2010-08-18 23:56:52 +0000310void ASTStmtReader::VisitExpr(Expr *E) {
Chris Lattner4c6f9522009-04-27 05:14:47 +0000311 VisitStmt(E);
Douglas Gregor393f2492011-07-22 00:38:23 +0000312 E->setType(Reader.readType(F, Record, Idx));
Chris Lattner4c6f9522009-04-27 05:14:47 +0000313 E->setTypeDependent(Record[Idx++]);
314 E->setValueDependent(Record[Idx++]);
Douglas Gregor561f8122011-07-01 01:22:09 +0000315 E->setInstantiationDependent(Record[Idx++]);
Douglas Gregord0937222010-12-13 22:49:22 +0000316 E->ExprBits.ContainsUnexpandedParameterPack = Record[Idx++];
John McCallf89e55a2010-11-18 06:31:45 +0000317 E->setValueKind(static_cast<ExprValueKind>(Record[Idx++]));
318 E->setObjectKind(static_cast<ExprObjectKind>(Record[Idx++]));
Chris Lattner4c6f9522009-04-27 05:14:47 +0000319 assert(Idx == NumExprFields && "Incorrect expression field count");
Chris Lattner4c6f9522009-04-27 05:14:47 +0000320}
321
Sebastian Redl60adf4a2010-08-18 23:56:52 +0000322void ASTStmtReader::VisitPredefinedExpr(PredefinedExpr *E) {
Chris Lattner4c6f9522009-04-27 05:14:47 +0000323 VisitExpr(E);
Sebastian Redlc3632732010-10-05 15:59:54 +0000324 E->setLocation(ReadSourceLocation(Record, Idx));
Chris Lattner4c6f9522009-04-27 05:14:47 +0000325 E->setIdentType((PredefinedExpr::IdentType)Record[Idx++]);
Chris Lattner4c6f9522009-04-27 05:14:47 +0000326}
327
Sebastian Redl60adf4a2010-08-18 23:56:52 +0000328void ASTStmtReader::VisitDeclRefExpr(DeclRefExpr *E) {
Chris Lattner4c6f9522009-04-27 05:14:47 +0000329 VisitExpr(E);
Argyrios Kyrtzidis663e3802010-07-08 13:09:47 +0000330
Chandler Carruthcb66cff2011-05-01 21:29:53 +0000331 E->DeclRefExprBits.HasQualifier = Record[Idx++];
Chandler Carruth3aa81402011-05-01 23:48:14 +0000332 E->DeclRefExprBits.HasFoundDecl = Record[Idx++];
Abramo Bagnarae4b92762012-01-27 09:46:47 +0000333 E->DeclRefExprBits.HasTemplateKWAndArgsInfo = Record[Idx++];
Abramo Bagnara7cc58b42011-10-05 07:56:41 +0000334 E->DeclRefExprBits.HadMultipleCandidates = Record[Idx++];
Anders Carlssonb0ca1372011-03-06 18:19:42 +0000335 unsigned NumTemplateArgs = 0;
Abramo Bagnarae4b92762012-01-27 09:46:47 +0000336 if (E->hasTemplateKWAndArgsInfo())
Anders Carlssonb0ca1372011-03-06 18:19:42 +0000337 NumTemplateArgs = Record[Idx++];
338
Chandler Carruthcb66cff2011-05-01 21:29:53 +0000339 if (E->hasQualifier())
Chandler Carruth6857c3e2011-05-01 22:14:37 +0000340 E->getInternalQualifierLoc()
Douglas Gregor40d96a62011-02-28 21:54:11 +0000341 = Reader.ReadNestedNameSpecifierLoc(F, Record, Idx);
Argyrios Kyrtzidis663e3802010-07-08 13:09:47 +0000342
Chandler Carruth3aa81402011-05-01 23:48:14 +0000343 if (E->hasFoundDecl())
Douglas Gregor409448c2011-07-21 22:35:25 +0000344 E->getInternalFoundDecl() = ReadDeclAs<NamedDecl>(Record, Idx);
Chandler Carruth3aa81402011-05-01 23:48:14 +0000345
Abramo Bagnarae4b92762012-01-27 09:46:47 +0000346 if (E->hasTemplateKWAndArgsInfo())
347 ReadTemplateKWAndArgsInfo(*E->getTemplateKWAndArgsInfo(),
348 NumTemplateArgs);
Argyrios Kyrtzidis663e3802010-07-08 13:09:47 +0000349
Douglas Gregor409448c2011-07-21 22:35:25 +0000350 E->setDecl(ReadDeclAs<ValueDecl>(Record, Idx));
Sebastian Redlc3632732010-10-05 15:59:54 +0000351 E->setLocation(ReadSourceLocation(Record, Idx));
Argyrios Kyrtzidis40451072010-10-15 18:21:24 +0000352 ReadDeclarationNameLoc(E->DNLoc, E->getDecl()->getDeclName(), Record, Idx);
Chris Lattner4c6f9522009-04-27 05:14:47 +0000353}
354
Sebastian Redl60adf4a2010-08-18 23:56:52 +0000355void ASTStmtReader::VisitIntegerLiteral(IntegerLiteral *E) {
Chris Lattner4c6f9522009-04-27 05:14:47 +0000356 VisitExpr(E);
Sebastian Redlc3632732010-10-05 15:59:54 +0000357 E->setLocation(ReadSourceLocation(Record, Idx));
Douglas Gregor35942772011-09-09 21:34:22 +0000358 E->setValue(Reader.getContext(), Reader.ReadAPInt(Record, Idx));
Chris Lattner4c6f9522009-04-27 05:14:47 +0000359}
360
Sebastian Redl60adf4a2010-08-18 23:56:52 +0000361void ASTStmtReader::VisitFloatingLiteral(FloatingLiteral *E) {
Chris Lattner4c6f9522009-04-27 05:14:47 +0000362 VisitExpr(E);
Douglas Gregor35942772011-09-09 21:34:22 +0000363 E->setValue(Reader.getContext(), Reader.ReadAPFloat(Record, Idx));
Chris Lattner4c6f9522009-04-27 05:14:47 +0000364 E->setExact(Record[Idx++]);
Sebastian Redlc3632732010-10-05 15:59:54 +0000365 E->setLocation(ReadSourceLocation(Record, Idx));
Chris Lattner4c6f9522009-04-27 05:14:47 +0000366}
367
Sebastian Redl60adf4a2010-08-18 23:56:52 +0000368void ASTStmtReader::VisitImaginaryLiteral(ImaginaryLiteral *E) {
Chris Lattner4c6f9522009-04-27 05:14:47 +0000369 VisitExpr(E);
Argyrios Kyrtzidisd98a2ab2010-06-29 22:46:25 +0000370 E->setSubExpr(Reader.ReadSubExpr());
Chris Lattner4c6f9522009-04-27 05:14:47 +0000371}
372
Sebastian Redl60adf4a2010-08-18 23:56:52 +0000373void ASTStmtReader::VisitStringLiteral(StringLiteral *E) {
Chris Lattner4c6f9522009-04-27 05:14:47 +0000374 VisitExpr(E);
375 unsigned Len = Record[Idx++];
Mike Stump1eb44332009-09-09 15:08:12 +0000376 assert(Record[Idx] == E->getNumConcatenated() &&
Chris Lattner4c6f9522009-04-27 05:14:47 +0000377 "Wrong number of concatenated tokens!");
378 ++Idx;
Eli Friedman64f45a22011-11-01 02:23:42 +0000379 StringLiteral::StringKind kind =
380 static_cast<StringLiteral::StringKind>(Record[Idx++]);
381 bool isPascal = Record[Idx++];
Chris Lattner4c6f9522009-04-27 05:14:47 +0000382
Mike Stump1eb44332009-09-09 15:08:12 +0000383 // Read string data
Daniel Dunbarb6480232009-09-22 03:27:33 +0000384 llvm::SmallString<16> Str(&Record[Idx], &Record[Idx] + Len);
Eli Friedman64f45a22011-11-01 02:23:42 +0000385 E->setString(Reader.getContext(), Str.str(), kind, isPascal);
Chris Lattner4c6f9522009-04-27 05:14:47 +0000386 Idx += Len;
387
388 // Read source locations
389 for (unsigned I = 0, N = E->getNumConcatenated(); I != N; ++I)
Sebastian Redlc3632732010-10-05 15:59:54 +0000390 E->setStrTokenLoc(I, ReadSourceLocation(Record, Idx));
Chris Lattner4c6f9522009-04-27 05:14:47 +0000391}
392
Sebastian Redl60adf4a2010-08-18 23:56:52 +0000393void ASTStmtReader::VisitCharacterLiteral(CharacterLiteral *E) {
Chris Lattner4c6f9522009-04-27 05:14:47 +0000394 VisitExpr(E);
395 E->setValue(Record[Idx++]);
Sebastian Redlc3632732010-10-05 15:59:54 +0000396 E->setLocation(ReadSourceLocation(Record, Idx));
Douglas Gregor5cee1192011-07-27 05:40:30 +0000397 E->setKind(static_cast<CharacterLiteral::CharacterKind>(Record[Idx++]));
Chris Lattner4c6f9522009-04-27 05:14:47 +0000398}
399
Sebastian Redl60adf4a2010-08-18 23:56:52 +0000400void ASTStmtReader::VisitParenExpr(ParenExpr *E) {
Chris Lattner4c6f9522009-04-27 05:14:47 +0000401 VisitExpr(E);
Sebastian Redlc3632732010-10-05 15:59:54 +0000402 E->setLParen(ReadSourceLocation(Record, Idx));
403 E->setRParen(ReadSourceLocation(Record, Idx));
Argyrios Kyrtzidisd98a2ab2010-06-29 22:46:25 +0000404 E->setSubExpr(Reader.ReadSubExpr());
Chris Lattner4c6f9522009-04-27 05:14:47 +0000405}
406
Sebastian Redl60adf4a2010-08-18 23:56:52 +0000407void ASTStmtReader::VisitParenListExpr(ParenListExpr *E) {
Argyrios Kyrtzidis37bdfe22010-06-30 08:49:18 +0000408 VisitExpr(E);
409 unsigned NumExprs = Record[Idx++];
Douglas Gregor35942772011-09-09 21:34:22 +0000410 E->Exprs = new (Reader.getContext()) Stmt*[NumExprs];
Argyrios Kyrtzidis37bdfe22010-06-30 08:49:18 +0000411 for (unsigned i = 0; i != NumExprs; ++i)
412 E->Exprs[i] = Reader.ReadSubStmt();
413 E->NumExprs = NumExprs;
Sebastian Redlc3632732010-10-05 15:59:54 +0000414 E->LParenLoc = ReadSourceLocation(Record, Idx);
415 E->RParenLoc = ReadSourceLocation(Record, Idx);
Argyrios Kyrtzidis37bdfe22010-06-30 08:49:18 +0000416}
417
Sebastian Redl60adf4a2010-08-18 23:56:52 +0000418void ASTStmtReader::VisitUnaryOperator(UnaryOperator *E) {
Chris Lattner4c6f9522009-04-27 05:14:47 +0000419 VisitExpr(E);
Argyrios Kyrtzidisd98a2ab2010-06-29 22:46:25 +0000420 E->setSubExpr(Reader.ReadSubExpr());
Chris Lattner4c6f9522009-04-27 05:14:47 +0000421 E->setOpcode((UnaryOperator::Opcode)Record[Idx++]);
Sebastian Redlc3632732010-10-05 15:59:54 +0000422 E->setOperatorLoc(ReadSourceLocation(Record, Idx));
Chris Lattner4c6f9522009-04-27 05:14:47 +0000423}
424
Sebastian Redl60adf4a2010-08-18 23:56:52 +0000425void ASTStmtReader::VisitOffsetOfExpr(OffsetOfExpr *E) {
Douglas Gregor8ecdb652010-04-28 22:16:22 +0000426 typedef OffsetOfExpr::OffsetOfNode Node;
427 VisitExpr(E);
428 assert(E->getNumComponents() == Record[Idx]);
429 ++Idx;
430 assert(E->getNumExpressions() == Record[Idx]);
431 ++Idx;
Sebastian Redlc3632732010-10-05 15:59:54 +0000432 E->setOperatorLoc(ReadSourceLocation(Record, Idx));
433 E->setRParenLoc(ReadSourceLocation(Record, Idx));
434 E->setTypeSourceInfo(GetTypeSourceInfo(Record, Idx));
Douglas Gregor8ecdb652010-04-28 22:16:22 +0000435 for (unsigned I = 0, N = E->getNumComponents(); I != N; ++I) {
436 Node::Kind Kind = static_cast<Node::Kind>(Record[Idx++]);
Sebastian Redlc3632732010-10-05 15:59:54 +0000437 SourceLocation Start = ReadSourceLocation(Record, Idx);
438 SourceLocation End = ReadSourceLocation(Record, Idx);
Douglas Gregor8ecdb652010-04-28 22:16:22 +0000439 switch (Kind) {
440 case Node::Array:
441 E->setComponent(I, Node(Start, Record[Idx++], End));
442 break;
443
444 case Node::Field:
Douglas Gregor409448c2011-07-21 22:35:25 +0000445 E->setComponent(I, Node(Start, ReadDeclAs<FieldDecl>(Record, Idx), End));
Douglas Gregor8ecdb652010-04-28 22:16:22 +0000446 break;
447
448 case Node::Identifier:
Douglas Gregor95eab172011-07-28 20:55:49 +0000449 E->setComponent(I,
450 Node(Start,
451 Reader.GetIdentifierInfo(F, Record, Idx),
452 End));
Douglas Gregor8ecdb652010-04-28 22:16:22 +0000453 break;
Douglas Gregorcc8a5d52010-04-29 00:18:15 +0000454
Argyrios Kyrtzidisafbf3122010-07-29 18:16:10 +0000455 case Node::Base: {
Douglas Gregor35942772011-09-09 21:34:22 +0000456 CXXBaseSpecifier *Base = new (Reader.getContext()) CXXBaseSpecifier();
Sebastian Redlc3632732010-10-05 15:59:54 +0000457 *Base = Reader.ReadCXXBaseSpecifier(F, Record, Idx);
Argyrios Kyrtzidisafbf3122010-07-29 18:16:10 +0000458 E->setComponent(I, Node(Base));
Douglas Gregorcc8a5d52010-04-29 00:18:15 +0000459 break;
Douglas Gregor8ecdb652010-04-28 22:16:22 +0000460 }
Argyrios Kyrtzidisafbf3122010-07-29 18:16:10 +0000461 }
Douglas Gregor8ecdb652010-04-28 22:16:22 +0000462 }
463
464 for (unsigned I = 0, N = E->getNumExpressions(); I != N; ++I)
Argyrios Kyrtzidisd98a2ab2010-06-29 22:46:25 +0000465 E->setIndexExpr(I, Reader.ReadSubExpr());
Douglas Gregor8ecdb652010-04-28 22:16:22 +0000466}
467
Peter Collingbournef4e3cfb2011-03-11 19:24:49 +0000468void ASTStmtReader::VisitUnaryExprOrTypeTraitExpr(UnaryExprOrTypeTraitExpr *E) {
Chris Lattner4c6f9522009-04-27 05:14:47 +0000469 VisitExpr(E);
Peter Collingbournef4e3cfb2011-03-11 19:24:49 +0000470 E->setKind(static_cast<UnaryExprOrTypeTrait>(Record[Idx++]));
Chris Lattner4c6f9522009-04-27 05:14:47 +0000471 if (Record[Idx] == 0) {
Argyrios Kyrtzidisd98a2ab2010-06-29 22:46:25 +0000472 E->setArgument(Reader.ReadSubExpr());
Chris Lattner4c6f9522009-04-27 05:14:47 +0000473 ++Idx;
474 } else {
Sebastian Redlc3632732010-10-05 15:59:54 +0000475 E->setArgument(GetTypeSourceInfo(Record, Idx));
Chris Lattner4c6f9522009-04-27 05:14:47 +0000476 }
Sebastian Redlc3632732010-10-05 15:59:54 +0000477 E->setOperatorLoc(ReadSourceLocation(Record, Idx));
478 E->setRParenLoc(ReadSourceLocation(Record, Idx));
Chris Lattner4c6f9522009-04-27 05:14:47 +0000479}
480
Sebastian Redl60adf4a2010-08-18 23:56:52 +0000481void ASTStmtReader::VisitArraySubscriptExpr(ArraySubscriptExpr *E) {
Chris Lattner4c6f9522009-04-27 05:14:47 +0000482 VisitExpr(E);
Argyrios Kyrtzidisd98a2ab2010-06-29 22:46:25 +0000483 E->setLHS(Reader.ReadSubExpr());
484 E->setRHS(Reader.ReadSubExpr());
Sebastian Redlc3632732010-10-05 15:59:54 +0000485 E->setRBracketLoc(ReadSourceLocation(Record, Idx));
Chris Lattner4c6f9522009-04-27 05:14:47 +0000486}
487
Sebastian Redl60adf4a2010-08-18 23:56:52 +0000488void ASTStmtReader::VisitCallExpr(CallExpr *E) {
Chris Lattner4c6f9522009-04-27 05:14:47 +0000489 VisitExpr(E);
Douglas Gregor35942772011-09-09 21:34:22 +0000490 E->setNumArgs(Reader.getContext(), Record[Idx++]);
Sebastian Redlc3632732010-10-05 15:59:54 +0000491 E->setRParenLoc(ReadSourceLocation(Record, Idx));
Argyrios Kyrtzidisd98a2ab2010-06-29 22:46:25 +0000492 E->setCallee(Reader.ReadSubExpr());
Chris Lattner4c6f9522009-04-27 05:14:47 +0000493 for (unsigned I = 0, N = E->getNumArgs(); I != N; ++I)
Argyrios Kyrtzidisd98a2ab2010-06-29 22:46:25 +0000494 E->setArg(I, Reader.ReadSubExpr());
Chris Lattner4c6f9522009-04-27 05:14:47 +0000495}
496
John McCall7110fd62011-07-15 07:00:14 +0000497void ASTStmtReader::VisitCXXMemberCallExpr(CXXMemberCallExpr *E) {
498 VisitCallExpr(E);
499}
500
Sebastian Redl60adf4a2010-08-18 23:56:52 +0000501void ASTStmtReader::VisitMemberExpr(MemberExpr *E) {
Argyrios Kyrtzidis663e3802010-07-08 13:09:47 +0000502 // Don't call VisitExpr, this is fully initialized at creation.
503 assert(E->getStmtClass() == Stmt::MemberExprClass &&
504 "It's a subclass, we must advance Idx!");
Chris Lattner4c6f9522009-04-27 05:14:47 +0000505}
506
Sebastian Redl60adf4a2010-08-18 23:56:52 +0000507void ASTStmtReader::VisitObjCIsaExpr(ObjCIsaExpr *E) {
Steve Narofff242b1b2009-07-24 17:54:45 +0000508 VisitExpr(E);
Argyrios Kyrtzidisd98a2ab2010-06-29 22:46:25 +0000509 E->setBase(Reader.ReadSubExpr());
Sebastian Redlc3632732010-10-05 15:59:54 +0000510 E->setIsaMemberLoc(ReadSourceLocation(Record, Idx));
Steve Narofff242b1b2009-07-24 17:54:45 +0000511 E->setArrow(Record[Idx++]);
Steve Narofff242b1b2009-07-24 17:54:45 +0000512}
513
John McCallf85e1932011-06-15 23:02:42 +0000514void ASTStmtReader::
515VisitObjCIndirectCopyRestoreExpr(ObjCIndirectCopyRestoreExpr *E) {
516 VisitExpr(E);
517 E->Operand = Reader.ReadSubExpr();
518 E->setShouldCopy(Record[Idx++]);
519}
520
521void ASTStmtReader::VisitObjCBridgedCastExpr(ObjCBridgedCastExpr *E) {
522 VisitExplicitCastExpr(E);
523 E->LParenLoc = ReadSourceLocation(Record, Idx);
524 E->BridgeKeywordLoc = ReadSourceLocation(Record, Idx);
525 E->Kind = Record[Idx++];
526}
527
Sebastian Redl60adf4a2010-08-18 23:56:52 +0000528void ASTStmtReader::VisitCastExpr(CastExpr *E) {
Chris Lattner4c6f9522009-04-27 05:14:47 +0000529 VisitExpr(E);
John McCallf871d0c2010-08-07 06:22:56 +0000530 unsigned NumBaseSpecs = Record[Idx++];
531 assert(NumBaseSpecs == E->path_size());
Argyrios Kyrtzidisd98a2ab2010-06-29 22:46:25 +0000532 E->setSubExpr(Reader.ReadSubExpr());
Anders Carlssoncdef2b72009-07-31 00:48:10 +0000533 E->setCastKind((CastExpr::CastKind)Record[Idx++]);
John McCallf871d0c2010-08-07 06:22:56 +0000534 CastExpr::path_iterator BaseI = E->path_begin();
Argyrios Kyrtzidis0745d0a2010-07-02 23:30:27 +0000535 while (NumBaseSpecs--) {
Douglas Gregor35942772011-09-09 21:34:22 +0000536 CXXBaseSpecifier *BaseSpec = new (Reader.getContext()) CXXBaseSpecifier;
Sebastian Redlc3632732010-10-05 15:59:54 +0000537 *BaseSpec = Reader.ReadCXXBaseSpecifier(F, Record, Idx);
John McCallf871d0c2010-08-07 06:22:56 +0000538 *BaseI++ = BaseSpec;
Argyrios Kyrtzidis0745d0a2010-07-02 23:30:27 +0000539 }
Chris Lattner4c6f9522009-04-27 05:14:47 +0000540}
541
Sebastian Redl60adf4a2010-08-18 23:56:52 +0000542void ASTStmtReader::VisitBinaryOperator(BinaryOperator *E) {
Chris Lattner4c6f9522009-04-27 05:14:47 +0000543 VisitExpr(E);
Argyrios Kyrtzidisd98a2ab2010-06-29 22:46:25 +0000544 E->setLHS(Reader.ReadSubExpr());
545 E->setRHS(Reader.ReadSubExpr());
Chris Lattner4c6f9522009-04-27 05:14:47 +0000546 E->setOpcode((BinaryOperator::Opcode)Record[Idx++]);
Sebastian Redlc3632732010-10-05 15:59:54 +0000547 E->setOperatorLoc(ReadSourceLocation(Record, Idx));
Chris Lattner4c6f9522009-04-27 05:14:47 +0000548}
549
Sebastian Redl60adf4a2010-08-18 23:56:52 +0000550void ASTStmtReader::VisitCompoundAssignOperator(CompoundAssignOperator *E) {
Chris Lattner4c6f9522009-04-27 05:14:47 +0000551 VisitBinaryOperator(E);
Douglas Gregor393f2492011-07-22 00:38:23 +0000552 E->setComputationLHSType(Reader.readType(F, Record, Idx));
553 E->setComputationResultType(Reader.readType(F, Record, Idx));
Chris Lattner4c6f9522009-04-27 05:14:47 +0000554}
555
Sebastian Redl60adf4a2010-08-18 23:56:52 +0000556void ASTStmtReader::VisitConditionalOperator(ConditionalOperator *E) {
Chris Lattner4c6f9522009-04-27 05:14:47 +0000557 VisitExpr(E);
John McCall56ca35d2011-02-17 10:25:35 +0000558 E->SubExprs[ConditionalOperator::COND] = Reader.ReadSubExpr();
559 E->SubExprs[ConditionalOperator::LHS] = Reader.ReadSubExpr();
560 E->SubExprs[ConditionalOperator::RHS] = Reader.ReadSubExpr();
561 E->QuestionLoc = ReadSourceLocation(Record, Idx);
562 E->ColonLoc = ReadSourceLocation(Record, Idx);
563}
564
565void
566ASTStmtReader::VisitBinaryConditionalOperator(BinaryConditionalOperator *E) {
567 VisitExpr(E);
568 E->OpaqueValue = cast<OpaqueValueExpr>(Reader.ReadSubExpr());
569 E->SubExprs[BinaryConditionalOperator::COMMON] = Reader.ReadSubExpr();
570 E->SubExprs[BinaryConditionalOperator::COND] = Reader.ReadSubExpr();
571 E->SubExprs[BinaryConditionalOperator::LHS] = Reader.ReadSubExpr();
572 E->SubExprs[BinaryConditionalOperator::RHS] = Reader.ReadSubExpr();
573 E->QuestionLoc = ReadSourceLocation(Record, Idx);
574 E->ColonLoc = ReadSourceLocation(Record, Idx);
Chris Lattner4c6f9522009-04-27 05:14:47 +0000575}
576
Sebastian Redl60adf4a2010-08-18 23:56:52 +0000577void ASTStmtReader::VisitImplicitCastExpr(ImplicitCastExpr *E) {
Chris Lattner4c6f9522009-04-27 05:14:47 +0000578 VisitCastExpr(E);
Chris Lattner4c6f9522009-04-27 05:14:47 +0000579}
580
Sebastian Redl60adf4a2010-08-18 23:56:52 +0000581void ASTStmtReader::VisitExplicitCastExpr(ExplicitCastExpr *E) {
Chris Lattner4c6f9522009-04-27 05:14:47 +0000582 VisitCastExpr(E);
Sebastian Redlc3632732010-10-05 15:59:54 +0000583 E->setTypeInfoAsWritten(GetTypeSourceInfo(Record, Idx));
Chris Lattner4c6f9522009-04-27 05:14:47 +0000584}
585
Sebastian Redl60adf4a2010-08-18 23:56:52 +0000586void ASTStmtReader::VisitCStyleCastExpr(CStyleCastExpr *E) {
Chris Lattner4c6f9522009-04-27 05:14:47 +0000587 VisitExplicitCastExpr(E);
Sebastian Redlc3632732010-10-05 15:59:54 +0000588 E->setLParenLoc(ReadSourceLocation(Record, Idx));
589 E->setRParenLoc(ReadSourceLocation(Record, Idx));
Chris Lattner4c6f9522009-04-27 05:14:47 +0000590}
591
Sebastian Redl60adf4a2010-08-18 23:56:52 +0000592void ASTStmtReader::VisitCompoundLiteralExpr(CompoundLiteralExpr *E) {
Chris Lattner4c6f9522009-04-27 05:14:47 +0000593 VisitExpr(E);
Sebastian Redlc3632732010-10-05 15:59:54 +0000594 E->setLParenLoc(ReadSourceLocation(Record, Idx));
595 E->setTypeSourceInfo(GetTypeSourceInfo(Record, Idx));
Argyrios Kyrtzidisd98a2ab2010-06-29 22:46:25 +0000596 E->setInitializer(Reader.ReadSubExpr());
Chris Lattner4c6f9522009-04-27 05:14:47 +0000597 E->setFileScope(Record[Idx++]);
Chris Lattner4c6f9522009-04-27 05:14:47 +0000598}
599
Sebastian Redl60adf4a2010-08-18 23:56:52 +0000600void ASTStmtReader::VisitExtVectorElementExpr(ExtVectorElementExpr *E) {
Chris Lattner4c6f9522009-04-27 05:14:47 +0000601 VisitExpr(E);
Argyrios Kyrtzidisd98a2ab2010-06-29 22:46:25 +0000602 E->setBase(Reader.ReadSubExpr());
Douglas Gregor95eab172011-07-28 20:55:49 +0000603 E->setAccessor(Reader.GetIdentifierInfo(F, Record, Idx));
Sebastian Redlc3632732010-10-05 15:59:54 +0000604 E->setAccessorLoc(ReadSourceLocation(Record, Idx));
Chris Lattner4c6f9522009-04-27 05:14:47 +0000605}
606
Sebastian Redl60adf4a2010-08-18 23:56:52 +0000607void ASTStmtReader::VisitInitListExpr(InitListExpr *E) {
Chris Lattner4c6f9522009-04-27 05:14:47 +0000608 VisitExpr(E);
Argyrios Kyrtzidisd98a2ab2010-06-29 22:46:25 +0000609 E->setSyntacticForm(cast_or_null<InitListExpr>(Reader.ReadSubStmt()));
Sebastian Redlc3632732010-10-05 15:59:54 +0000610 E->setLBraceLoc(ReadSourceLocation(Record, Idx));
611 E->setRBraceLoc(ReadSourceLocation(Record, Idx));
Argyrios Kyrtzidis2ac0b7a2011-04-22 05:29:30 +0000612 bool isArrayFiller = Record[Idx++];
613 Expr *filler = 0;
614 if (isArrayFiller) {
615 filler = Reader.ReadSubExpr();
616 E->ArrayFillerOrUnionFieldInit = filler;
617 } else
Douglas Gregor409448c2011-07-21 22:35:25 +0000618 E->ArrayFillerOrUnionFieldInit = ReadDeclAs<FieldDecl>(Record, Idx);
Chris Lattner4c6f9522009-04-27 05:14:47 +0000619 E->sawArrayRangeDesignator(Record[Idx++]);
Argyrios Kyrtzidis2ac0b7a2011-04-22 05:29:30 +0000620 unsigned NumInits = Record[Idx++];
Douglas Gregor35942772011-09-09 21:34:22 +0000621 E->reserveInits(Reader.getContext(), NumInits);
Argyrios Kyrtzidis2ac0b7a2011-04-22 05:29:30 +0000622 if (isArrayFiller) {
623 for (unsigned I = 0; I != NumInits; ++I) {
624 Expr *init = Reader.ReadSubExpr();
Douglas Gregor35942772011-09-09 21:34:22 +0000625 E->updateInit(Reader.getContext(), I, init ? init : filler);
Argyrios Kyrtzidis2ac0b7a2011-04-22 05:29:30 +0000626 }
627 } else {
628 for (unsigned I = 0; I != NumInits; ++I)
Douglas Gregor35942772011-09-09 21:34:22 +0000629 E->updateInit(Reader.getContext(), I, Reader.ReadSubExpr());
Argyrios Kyrtzidis2ac0b7a2011-04-22 05:29:30 +0000630 }
Chris Lattner4c6f9522009-04-27 05:14:47 +0000631}
632
Sebastian Redl60adf4a2010-08-18 23:56:52 +0000633void ASTStmtReader::VisitDesignatedInitExpr(DesignatedInitExpr *E) {
Chris Lattner4c6f9522009-04-27 05:14:47 +0000634 typedef DesignatedInitExpr::Designator Designator;
635
636 VisitExpr(E);
637 unsigned NumSubExprs = Record[Idx++];
638 assert(NumSubExprs == E->getNumSubExprs() && "Wrong number of subexprs");
639 for (unsigned I = 0; I != NumSubExprs; ++I)
Argyrios Kyrtzidisd98a2ab2010-06-29 22:46:25 +0000640 E->setSubExpr(I, Reader.ReadSubExpr());
Sebastian Redlc3632732010-10-05 15:59:54 +0000641 E->setEqualOrColonLoc(ReadSourceLocation(Record, Idx));
Chris Lattner4c6f9522009-04-27 05:14:47 +0000642 E->setGNUSyntax(Record[Idx++]);
643
Chris Lattner5f9e2722011-07-23 10:55:15 +0000644 SmallVector<Designator, 4> Designators;
Chris Lattner4c6f9522009-04-27 05:14:47 +0000645 while (Idx < Record.size()) {
Sebastian Redl8538e8d2010-08-18 23:57:32 +0000646 switch ((DesignatorTypes)Record[Idx++]) {
647 case DESIG_FIELD_DECL: {
Douglas Gregor409448c2011-07-21 22:35:25 +0000648 FieldDecl *Field = ReadDeclAs<FieldDecl>(Record, Idx);
Mike Stump1eb44332009-09-09 15:08:12 +0000649 SourceLocation DotLoc
Sebastian Redlc3632732010-10-05 15:59:54 +0000650 = ReadSourceLocation(Record, Idx);
Mike Stump1eb44332009-09-09 15:08:12 +0000651 SourceLocation FieldLoc
Sebastian Redlc3632732010-10-05 15:59:54 +0000652 = ReadSourceLocation(Record, Idx);
Mike Stump1eb44332009-09-09 15:08:12 +0000653 Designators.push_back(Designator(Field->getIdentifier(), DotLoc,
Chris Lattner4c6f9522009-04-27 05:14:47 +0000654 FieldLoc));
655 Designators.back().setField(Field);
656 break;
657 }
658
Sebastian Redl8538e8d2010-08-18 23:57:32 +0000659 case DESIG_FIELD_NAME: {
Douglas Gregor95eab172011-07-28 20:55:49 +0000660 const IdentifierInfo *Name = Reader.GetIdentifierInfo(F, Record, Idx);
Mike Stump1eb44332009-09-09 15:08:12 +0000661 SourceLocation DotLoc
Sebastian Redlc3632732010-10-05 15:59:54 +0000662 = ReadSourceLocation(Record, Idx);
Mike Stump1eb44332009-09-09 15:08:12 +0000663 SourceLocation FieldLoc
Sebastian Redlc3632732010-10-05 15:59:54 +0000664 = ReadSourceLocation(Record, Idx);
Chris Lattner4c6f9522009-04-27 05:14:47 +0000665 Designators.push_back(Designator(Name, DotLoc, FieldLoc));
666 break;
667 }
Mike Stump1eb44332009-09-09 15:08:12 +0000668
Sebastian Redl8538e8d2010-08-18 23:57:32 +0000669 case DESIG_ARRAY: {
Chris Lattner4c6f9522009-04-27 05:14:47 +0000670 unsigned Index = Record[Idx++];
671 SourceLocation LBracketLoc
Sebastian Redlc3632732010-10-05 15:59:54 +0000672 = ReadSourceLocation(Record, Idx);
Chris Lattner4c6f9522009-04-27 05:14:47 +0000673 SourceLocation RBracketLoc
Sebastian Redlc3632732010-10-05 15:59:54 +0000674 = ReadSourceLocation(Record, Idx);
Chris Lattner4c6f9522009-04-27 05:14:47 +0000675 Designators.push_back(Designator(Index, LBracketLoc, RBracketLoc));
676 break;
677 }
678
Sebastian Redl8538e8d2010-08-18 23:57:32 +0000679 case DESIG_ARRAY_RANGE: {
Chris Lattner4c6f9522009-04-27 05:14:47 +0000680 unsigned Index = Record[Idx++];
681 SourceLocation LBracketLoc
Sebastian Redlc3632732010-10-05 15:59:54 +0000682 = ReadSourceLocation(Record, Idx);
Chris Lattner4c6f9522009-04-27 05:14:47 +0000683 SourceLocation EllipsisLoc
Sebastian Redlc3632732010-10-05 15:59:54 +0000684 = ReadSourceLocation(Record, Idx);
Chris Lattner4c6f9522009-04-27 05:14:47 +0000685 SourceLocation RBracketLoc
Sebastian Redlc3632732010-10-05 15:59:54 +0000686 = ReadSourceLocation(Record, Idx);
Chris Lattner4c6f9522009-04-27 05:14:47 +0000687 Designators.push_back(Designator(Index, LBracketLoc, EllipsisLoc,
688 RBracketLoc));
689 break;
690 }
691 }
692 }
Douglas Gregor35942772011-09-09 21:34:22 +0000693 E->setDesignators(Reader.getContext(),
Douglas Gregor319d57f2010-01-06 23:17:19 +0000694 Designators.data(), Designators.size());
Chris Lattner4c6f9522009-04-27 05:14:47 +0000695}
696
Sebastian Redl60adf4a2010-08-18 23:56:52 +0000697void ASTStmtReader::VisitImplicitValueInitExpr(ImplicitValueInitExpr *E) {
Chris Lattner4c6f9522009-04-27 05:14:47 +0000698 VisitExpr(E);
Chris Lattner4c6f9522009-04-27 05:14:47 +0000699}
700
Sebastian Redl60adf4a2010-08-18 23:56:52 +0000701void ASTStmtReader::VisitVAArgExpr(VAArgExpr *E) {
Chris Lattner4c6f9522009-04-27 05:14:47 +0000702 VisitExpr(E);
Argyrios Kyrtzidisd98a2ab2010-06-29 22:46:25 +0000703 E->setSubExpr(Reader.ReadSubExpr());
Sebastian Redlc3632732010-10-05 15:59:54 +0000704 E->setWrittenTypeInfo(GetTypeSourceInfo(Record, Idx));
705 E->setBuiltinLoc(ReadSourceLocation(Record, Idx));
706 E->setRParenLoc(ReadSourceLocation(Record, Idx));
Chris Lattner4c6f9522009-04-27 05:14:47 +0000707}
708
Sebastian Redl60adf4a2010-08-18 23:56:52 +0000709void ASTStmtReader::VisitAddrLabelExpr(AddrLabelExpr *E) {
Chris Lattner4c6f9522009-04-27 05:14:47 +0000710 VisitExpr(E);
Sebastian Redlc3632732010-10-05 15:59:54 +0000711 E->setAmpAmpLoc(ReadSourceLocation(Record, Idx));
712 E->setLabelLoc(ReadSourceLocation(Record, Idx));
Douglas Gregor409448c2011-07-21 22:35:25 +0000713 E->setLabel(ReadDeclAs<LabelDecl>(Record, Idx));
Chris Lattner4c6f9522009-04-27 05:14:47 +0000714}
715
Sebastian Redl60adf4a2010-08-18 23:56:52 +0000716void ASTStmtReader::VisitStmtExpr(StmtExpr *E) {
Chris Lattner4c6f9522009-04-27 05:14:47 +0000717 VisitExpr(E);
Sebastian Redlc3632732010-10-05 15:59:54 +0000718 E->setLParenLoc(ReadSourceLocation(Record, Idx));
719 E->setRParenLoc(ReadSourceLocation(Record, Idx));
Argyrios Kyrtzidisd98a2ab2010-06-29 22:46:25 +0000720 E->setSubStmt(cast_or_null<CompoundStmt>(Reader.ReadSubStmt()));
Chris Lattner4c6f9522009-04-27 05:14:47 +0000721}
722
Sebastian Redl60adf4a2010-08-18 23:56:52 +0000723void ASTStmtReader::VisitChooseExpr(ChooseExpr *E) {
Chris Lattner4c6f9522009-04-27 05:14:47 +0000724 VisitExpr(E);
Argyrios Kyrtzidisd98a2ab2010-06-29 22:46:25 +0000725 E->setCond(Reader.ReadSubExpr());
726 E->setLHS(Reader.ReadSubExpr());
727 E->setRHS(Reader.ReadSubExpr());
Sebastian Redlc3632732010-10-05 15:59:54 +0000728 E->setBuiltinLoc(ReadSourceLocation(Record, Idx));
729 E->setRParenLoc(ReadSourceLocation(Record, Idx));
Chris Lattner4c6f9522009-04-27 05:14:47 +0000730}
731
Sebastian Redl60adf4a2010-08-18 23:56:52 +0000732void ASTStmtReader::VisitGNUNullExpr(GNUNullExpr *E) {
Chris Lattner4c6f9522009-04-27 05:14:47 +0000733 VisitExpr(E);
Sebastian Redlc3632732010-10-05 15:59:54 +0000734 E->setTokenLocation(ReadSourceLocation(Record, Idx));
Chris Lattner4c6f9522009-04-27 05:14:47 +0000735}
736
Sebastian Redl60adf4a2010-08-18 23:56:52 +0000737void ASTStmtReader::VisitShuffleVectorExpr(ShuffleVectorExpr *E) {
Chris Lattner4c6f9522009-04-27 05:14:47 +0000738 VisitExpr(E);
Chris Lattner5f9e2722011-07-23 10:55:15 +0000739 SmallVector<Expr *, 16> Exprs;
Chris Lattner4c6f9522009-04-27 05:14:47 +0000740 unsigned NumExprs = Record[Idx++];
Argyrios Kyrtzidis919e6932010-06-28 22:28:35 +0000741 while (NumExprs--)
Argyrios Kyrtzidisd98a2ab2010-06-29 22:46:25 +0000742 Exprs.push_back(Reader.ReadSubExpr());
Douglas Gregor35942772011-09-09 21:34:22 +0000743 E->setExprs(Reader.getContext(), Exprs.data(), Exprs.size());
Sebastian Redlc3632732010-10-05 15:59:54 +0000744 E->setBuiltinLoc(ReadSourceLocation(Record, Idx));
745 E->setRParenLoc(ReadSourceLocation(Record, Idx));
Chris Lattner4c6f9522009-04-27 05:14:47 +0000746}
747
Sebastian Redl60adf4a2010-08-18 23:56:52 +0000748void ASTStmtReader::VisitBlockExpr(BlockExpr *E) {
Chris Lattner4c6f9522009-04-27 05:14:47 +0000749 VisitExpr(E);
Douglas Gregor409448c2011-07-21 22:35:25 +0000750 E->setBlockDecl(ReadDeclAs<BlockDecl>(Record, Idx));
Chris Lattner4c6f9522009-04-27 05:14:47 +0000751}
752
Sebastian Redl60adf4a2010-08-18 23:56:52 +0000753void ASTStmtReader::VisitBlockDeclRefExpr(BlockDeclRefExpr *E) {
Chris Lattner4c6f9522009-04-27 05:14:47 +0000754 VisitExpr(E);
Douglas Gregor409448c2011-07-21 22:35:25 +0000755 E->setDecl(ReadDeclAs<VarDecl>(Record, Idx));
Sebastian Redlc3632732010-10-05 15:59:54 +0000756 E->setLocation(ReadSourceLocation(Record, Idx));
Chris Lattner4c6f9522009-04-27 05:14:47 +0000757 E->setByRef(Record[Idx++]);
Fariborz Jahanian9b0b57c2009-06-20 00:02:26 +0000758 E->setConstQualAdded(Record[Idx++]);
Chris Lattner4c6f9522009-04-27 05:14:47 +0000759}
760
Peter Collingbournef111d932011-04-15 00:35:48 +0000761void ASTStmtReader::VisitGenericSelectionExpr(GenericSelectionExpr *E) {
762 VisitExpr(E);
763 E->NumAssocs = Record[Idx++];
Douglas Gregor35942772011-09-09 21:34:22 +0000764 E->AssocTypes = new (Reader.getContext()) TypeSourceInfo*[E->NumAssocs];
Peter Collingbournef111d932011-04-15 00:35:48 +0000765 E->SubExprs =
Douglas Gregor35942772011-09-09 21:34:22 +0000766 new(Reader.getContext()) Stmt*[GenericSelectionExpr::END_EXPR+E->NumAssocs];
Peter Collingbournef111d932011-04-15 00:35:48 +0000767
768 E->SubExprs[GenericSelectionExpr::CONTROLLING] = Reader.ReadSubExpr();
769 for (unsigned I = 0, N = E->getNumAssocs(); I != N; ++I) {
770 E->AssocTypes[I] = GetTypeSourceInfo(Record, Idx);
771 E->SubExprs[GenericSelectionExpr::END_EXPR+I] = Reader.ReadSubExpr();
772 }
773 E->ResultIndex = Record[Idx++];
774
775 E->GenericLoc = ReadSourceLocation(Record, Idx);
776 E->DefaultLoc = ReadSourceLocation(Record, Idx);
777 E->RParenLoc = ReadSourceLocation(Record, Idx);
778}
779
John McCall4b9c2d22011-11-06 09:01:30 +0000780void ASTStmtReader::VisitPseudoObjectExpr(PseudoObjectExpr *E) {
781 VisitExpr(E);
782 unsigned numSemanticExprs = Record[Idx++];
783 assert(numSemanticExprs + 1 == E->PseudoObjectExprBits.NumSubExprs);
784 E->PseudoObjectExprBits.ResultIndex = Record[Idx++];
785
786 // Read the syntactic expression.
787 E->getSubExprsBuffer()[0] = Reader.ReadSubExpr();
788
789 // Read all the semantic expressions.
790 for (unsigned i = 0; i != numSemanticExprs; ++i) {
791 Expr *subExpr = Reader.ReadSubExpr();
John McCall4b9c2d22011-11-06 09:01:30 +0000792 E->getSubExprsBuffer()[i+1] = subExpr;
793 }
794}
795
Eli Friedman276b0612011-10-11 02:20:01 +0000796void ASTStmtReader::VisitAtomicExpr(AtomicExpr *E) {
797 VisitExpr(E);
798 E->setOp(AtomicExpr::AtomicOp(Record[Idx++]));
799 E->setPtr(Reader.ReadSubExpr());
800 E->setOrder(Reader.ReadSubExpr());
801 E->setNumSubExprs(2);
802 if (E->getOp() != AtomicExpr::Load) {
803 E->setVal1(Reader.ReadSubExpr());
804 E->setNumSubExprs(3);
805 }
806 if (E->isCmpXChg()) {
807 E->setOrderFail(Reader.ReadSubExpr());
808 E->setVal2(Reader.ReadSubExpr());
809 E->setNumSubExprs(5);
810 }
811 E->setBuiltinLoc(ReadSourceLocation(Record, Idx));
812 E->setRParenLoc(ReadSourceLocation(Record, Idx));
813}
814
Chris Lattner4c6f9522009-04-27 05:14:47 +0000815//===----------------------------------------------------------------------===//
816// Objective-C Expressions and Statements
817
Sebastian Redl60adf4a2010-08-18 23:56:52 +0000818void ASTStmtReader::VisitObjCStringLiteral(ObjCStringLiteral *E) {
Chris Lattner4c6f9522009-04-27 05:14:47 +0000819 VisitExpr(E);
Argyrios Kyrtzidisd98a2ab2010-06-29 22:46:25 +0000820 E->setString(cast<StringLiteral>(Reader.ReadSubStmt()));
Sebastian Redlc3632732010-10-05 15:59:54 +0000821 E->setAtLoc(ReadSourceLocation(Record, Idx));
Chris Lattner4c6f9522009-04-27 05:14:47 +0000822}
823
Sebastian Redl60adf4a2010-08-18 23:56:52 +0000824void ASTStmtReader::VisitObjCEncodeExpr(ObjCEncodeExpr *E) {
Chris Lattner4c6f9522009-04-27 05:14:47 +0000825 VisitExpr(E);
Sebastian Redlc3632732010-10-05 15:59:54 +0000826 E->setEncodedTypeSourceInfo(GetTypeSourceInfo(Record, Idx));
827 E->setAtLoc(ReadSourceLocation(Record, Idx));
828 E->setRParenLoc(ReadSourceLocation(Record, Idx));
Chris Lattner4c6f9522009-04-27 05:14:47 +0000829}
830
Sebastian Redl60adf4a2010-08-18 23:56:52 +0000831void ASTStmtReader::VisitObjCSelectorExpr(ObjCSelectorExpr *E) {
Chris Lattner4c6f9522009-04-27 05:14:47 +0000832 VisitExpr(E);
Douglas Gregor2d2689a2011-07-28 21:16:51 +0000833 E->setSelector(Reader.ReadSelector(F, Record, Idx));
Sebastian Redlc3632732010-10-05 15:59:54 +0000834 E->setAtLoc(ReadSourceLocation(Record, Idx));
835 E->setRParenLoc(ReadSourceLocation(Record, Idx));
Chris Lattner4c6f9522009-04-27 05:14:47 +0000836}
837
Sebastian Redl60adf4a2010-08-18 23:56:52 +0000838void ASTStmtReader::VisitObjCProtocolExpr(ObjCProtocolExpr *E) {
Chris Lattner4c6f9522009-04-27 05:14:47 +0000839 VisitExpr(E);
Douglas Gregor409448c2011-07-21 22:35:25 +0000840 E->setProtocol(ReadDeclAs<ObjCProtocolDecl>(Record, Idx));
Sebastian Redlc3632732010-10-05 15:59:54 +0000841 E->setAtLoc(ReadSourceLocation(Record, Idx));
842 E->setRParenLoc(ReadSourceLocation(Record, Idx));
Chris Lattner4c6f9522009-04-27 05:14:47 +0000843}
844
Sebastian Redl60adf4a2010-08-18 23:56:52 +0000845void ASTStmtReader::VisitObjCIvarRefExpr(ObjCIvarRefExpr *E) {
Chris Lattner4c6f9522009-04-27 05:14:47 +0000846 VisitExpr(E);
Douglas Gregor409448c2011-07-21 22:35:25 +0000847 E->setDecl(ReadDeclAs<ObjCIvarDecl>(Record, Idx));
Sebastian Redlc3632732010-10-05 15:59:54 +0000848 E->setLocation(ReadSourceLocation(Record, Idx));
Argyrios Kyrtzidisd98a2ab2010-06-29 22:46:25 +0000849 E->setBase(Reader.ReadSubExpr());
Chris Lattner4c6f9522009-04-27 05:14:47 +0000850 E->setIsArrow(Record[Idx++]);
851 E->setIsFreeIvar(Record[Idx++]);
Chris Lattner4c6f9522009-04-27 05:14:47 +0000852}
853
Sebastian Redl60adf4a2010-08-18 23:56:52 +0000854void ASTStmtReader::VisitObjCPropertyRefExpr(ObjCPropertyRefExpr *E) {
Chris Lattner4c6f9522009-04-27 05:14:47 +0000855 VisitExpr(E);
John McCall12f78a62010-12-02 01:19:52 +0000856 bool Implicit = Record[Idx++] != 0;
857 if (Implicit) {
Douglas Gregor409448c2011-07-21 22:35:25 +0000858 ObjCMethodDecl *Getter = ReadDeclAs<ObjCMethodDecl>(Record, Idx);
859 ObjCMethodDecl *Setter = ReadDeclAs<ObjCMethodDecl>(Record, Idx);
John McCall12f78a62010-12-02 01:19:52 +0000860 E->setImplicitProperty(Getter, Setter);
861 } else {
Douglas Gregor409448c2011-07-21 22:35:25 +0000862 E->setExplicitProperty(ReadDeclAs<ObjCPropertyDecl>(Record, Idx));
Fariborz Jahanian8ac2d442010-10-14 16:04:05 +0000863 }
Sebastian Redlc3632732010-10-05 15:59:54 +0000864 E->setLocation(ReadSourceLocation(Record, Idx));
John McCall12f78a62010-12-02 01:19:52 +0000865 E->setReceiverLocation(ReadSourceLocation(Record, Idx));
866 switch (Record[Idx++]) {
867 case 0:
868 E->setBase(Reader.ReadSubExpr());
869 break;
870 case 1:
Douglas Gregor393f2492011-07-22 00:38:23 +0000871 E->setSuperReceiver(Reader.readType(F, Record, Idx));
John McCall12f78a62010-12-02 01:19:52 +0000872 break;
873 case 2:
Douglas Gregor409448c2011-07-21 22:35:25 +0000874 E->setClassReceiver(ReadDeclAs<ObjCInterfaceDecl>(Record, Idx));
John McCall12f78a62010-12-02 01:19:52 +0000875 break;
876 }
Chris Lattner4c6f9522009-04-27 05:14:47 +0000877}
878
Sebastian Redl60adf4a2010-08-18 23:56:52 +0000879void ASTStmtReader::VisitObjCMessageExpr(ObjCMessageExpr *E) {
Chris Lattner4c6f9522009-04-27 05:14:47 +0000880 VisitExpr(E);
Douglas Gregor04badcf2010-04-21 00:45:42 +0000881 assert(Record[Idx] == E->getNumArgs());
882 ++Idx;
Argyrios Kyrtzidis20718082011-10-03 06:36:51 +0000883 unsigned NumStoredSelLocs = Record[Idx++];
884 E->SelLocsKind = Record[Idx++];
John McCallf85e1932011-06-15 23:02:42 +0000885 E->setDelegateInitCall(Record[Idx++]);
Argyrios Kyrtzidis746f5bc2012-01-12 02:34:39 +0000886 E->IsImplicit = Record[Idx++];
Douglas Gregor04badcf2010-04-21 00:45:42 +0000887 ObjCMessageExpr::ReceiverKind Kind
888 = static_cast<ObjCMessageExpr::ReceiverKind>(Record[Idx++]);
889 switch (Kind) {
890 case ObjCMessageExpr::Instance:
Argyrios Kyrtzidisd98a2ab2010-06-29 22:46:25 +0000891 E->setInstanceReceiver(Reader.ReadSubExpr());
Douglas Gregor04badcf2010-04-21 00:45:42 +0000892 break;
893
894 case ObjCMessageExpr::Class:
Sebastian Redlc3632732010-10-05 15:59:54 +0000895 E->setClassReceiver(GetTypeSourceInfo(Record, Idx));
Douglas Gregor04badcf2010-04-21 00:45:42 +0000896 break;
897
898 case ObjCMessageExpr::SuperClass:
899 case ObjCMessageExpr::SuperInstance: {
Douglas Gregor393f2492011-07-22 00:38:23 +0000900 QualType T = Reader.readType(F, Record, Idx);
Sebastian Redlc3632732010-10-05 15:59:54 +0000901 SourceLocation SuperLoc = ReadSourceLocation(Record, Idx);
Douglas Gregor04badcf2010-04-21 00:45:42 +0000902 E->setSuper(SuperLoc, T, Kind == ObjCMessageExpr::SuperInstance);
903 break;
904 }
905 }
906
907 assert(Kind == E->getReceiverKind());
908
909 if (Record[Idx++])
Douglas Gregor409448c2011-07-21 22:35:25 +0000910 E->setMethodDecl(ReadDeclAs<ObjCMethodDecl>(Record, Idx));
Douglas Gregor04badcf2010-04-21 00:45:42 +0000911 else
Douglas Gregor2d2689a2011-07-28 21:16:51 +0000912 E->setSelector(Reader.ReadSelector(F, Record, Idx));
Douglas Gregor04badcf2010-04-21 00:45:42 +0000913
Argyrios Kyrtzidisf40f0d52010-12-10 20:08:27 +0000914 E->LBracLoc = ReadSourceLocation(Record, Idx);
915 E->RBracLoc = ReadSourceLocation(Record, Idx);
Chris Lattner4c6f9522009-04-27 05:14:47 +0000916
917 for (unsigned I = 0, N = E->getNumArgs(); I != N; ++I)
Argyrios Kyrtzidisd98a2ab2010-06-29 22:46:25 +0000918 E->setArg(I, Reader.ReadSubExpr());
Argyrios Kyrtzidis20718082011-10-03 06:36:51 +0000919
920 SourceLocation *Locs = E->getStoredSelLocs();
921 for (unsigned I = 0; I != NumStoredSelLocs; ++I)
922 Locs[I] = ReadSourceLocation(Record, Idx);
Chris Lattner4c6f9522009-04-27 05:14:47 +0000923}
924
Sebastian Redl60adf4a2010-08-18 23:56:52 +0000925void ASTStmtReader::VisitObjCForCollectionStmt(ObjCForCollectionStmt *S) {
Chris Lattner4c6f9522009-04-27 05:14:47 +0000926 VisitStmt(S);
Argyrios Kyrtzidisd98a2ab2010-06-29 22:46:25 +0000927 S->setElement(Reader.ReadSubStmt());
928 S->setCollection(Reader.ReadSubExpr());
929 S->setBody(Reader.ReadSubStmt());
Sebastian Redlc3632732010-10-05 15:59:54 +0000930 S->setForLoc(ReadSourceLocation(Record, Idx));
931 S->setRParenLoc(ReadSourceLocation(Record, Idx));
Chris Lattner4c6f9522009-04-27 05:14:47 +0000932}
933
Sebastian Redl60adf4a2010-08-18 23:56:52 +0000934void ASTStmtReader::VisitObjCAtCatchStmt(ObjCAtCatchStmt *S) {
Chris Lattner4c6f9522009-04-27 05:14:47 +0000935 VisitStmt(S);
Argyrios Kyrtzidisd98a2ab2010-06-29 22:46:25 +0000936 S->setCatchBody(Reader.ReadSubStmt());
Douglas Gregor409448c2011-07-21 22:35:25 +0000937 S->setCatchParamDecl(ReadDeclAs<VarDecl>(Record, Idx));
Sebastian Redlc3632732010-10-05 15:59:54 +0000938 S->setAtCatchLoc(ReadSourceLocation(Record, Idx));
939 S->setRParenLoc(ReadSourceLocation(Record, Idx));
Chris Lattner4c6f9522009-04-27 05:14:47 +0000940}
941
Sebastian Redl60adf4a2010-08-18 23:56:52 +0000942void ASTStmtReader::VisitObjCAtFinallyStmt(ObjCAtFinallyStmt *S) {
Chris Lattner4c6f9522009-04-27 05:14:47 +0000943 VisitStmt(S);
Argyrios Kyrtzidisd98a2ab2010-06-29 22:46:25 +0000944 S->setFinallyBody(Reader.ReadSubStmt());
Sebastian Redlc3632732010-10-05 15:59:54 +0000945 S->setAtFinallyLoc(ReadSourceLocation(Record, Idx));
Chris Lattner4c6f9522009-04-27 05:14:47 +0000946}
947
John McCallf85e1932011-06-15 23:02:42 +0000948void ASTStmtReader::VisitObjCAutoreleasePoolStmt(ObjCAutoreleasePoolStmt *S) {
949 VisitStmt(S);
950 S->setSubStmt(Reader.ReadSubStmt());
951 S->setAtLoc(ReadSourceLocation(Record, Idx));
952}
953
Sebastian Redl60adf4a2010-08-18 23:56:52 +0000954void ASTStmtReader::VisitObjCAtTryStmt(ObjCAtTryStmt *S) {
Chris Lattner4c6f9522009-04-27 05:14:47 +0000955 VisitStmt(S);
Douglas Gregor8f5e3dd2010-04-23 22:50:49 +0000956 assert(Record[Idx] == S->getNumCatchStmts());
957 ++Idx;
958 bool HasFinally = Record[Idx++];
Argyrios Kyrtzidisd98a2ab2010-06-29 22:46:25 +0000959 S->setTryBody(Reader.ReadSubStmt());
Argyrios Kyrtzidis919e6932010-06-28 22:28:35 +0000960 for (unsigned I = 0, N = S->getNumCatchStmts(); I != N; ++I)
Argyrios Kyrtzidisd98a2ab2010-06-29 22:46:25 +0000961 S->setCatchStmt(I, cast_or_null<ObjCAtCatchStmt>(Reader.ReadSubStmt()));
Douglas Gregor8f5e3dd2010-04-23 22:50:49 +0000962
Douglas Gregor8f5e3dd2010-04-23 22:50:49 +0000963 if (HasFinally)
Argyrios Kyrtzidisd98a2ab2010-06-29 22:46:25 +0000964 S->setFinallyStmt(Reader.ReadSubStmt());
Sebastian Redlc3632732010-10-05 15:59:54 +0000965 S->setAtTryLoc(ReadSourceLocation(Record, Idx));
Chris Lattner4c6f9522009-04-27 05:14:47 +0000966}
967
Sebastian Redl60adf4a2010-08-18 23:56:52 +0000968void ASTStmtReader::VisitObjCAtSynchronizedStmt(ObjCAtSynchronizedStmt *S) {
Chris Lattner4c6f9522009-04-27 05:14:47 +0000969 VisitStmt(S);
Argyrios Kyrtzidisd98a2ab2010-06-29 22:46:25 +0000970 S->setSynchExpr(Reader.ReadSubStmt());
971 S->setSynchBody(Reader.ReadSubStmt());
Sebastian Redlc3632732010-10-05 15:59:54 +0000972 S->setAtSynchronizedLoc(ReadSourceLocation(Record, Idx));
Chris Lattner4c6f9522009-04-27 05:14:47 +0000973}
974
Sebastian Redl60adf4a2010-08-18 23:56:52 +0000975void ASTStmtReader::VisitObjCAtThrowStmt(ObjCAtThrowStmt *S) {
Chris Lattner4c6f9522009-04-27 05:14:47 +0000976 VisitStmt(S);
Argyrios Kyrtzidisd98a2ab2010-06-29 22:46:25 +0000977 S->setThrowExpr(Reader.ReadSubStmt());
Sebastian Redlc3632732010-10-05 15:59:54 +0000978 S->setThrowLoc(ReadSourceLocation(Record, Idx));
Chris Lattner4c6f9522009-04-27 05:14:47 +0000979}
980
Argyrios Kyrtzidisba0a9002009-07-14 03:19:21 +0000981//===----------------------------------------------------------------------===//
982// C++ Expressions and Statements
Argyrios Kyrtzidis7cb45e32010-07-22 16:03:56 +0000983//===----------------------------------------------------------------------===//
984
Sebastian Redl60adf4a2010-08-18 23:56:52 +0000985void ASTStmtReader::VisitCXXCatchStmt(CXXCatchStmt *S) {
Argyrios Kyrtzidis7cb45e32010-07-22 16:03:56 +0000986 VisitStmt(S);
Sebastian Redlc3632732010-10-05 15:59:54 +0000987 S->CatchLoc = ReadSourceLocation(Record, Idx);
Douglas Gregor409448c2011-07-21 22:35:25 +0000988 S->ExceptionDecl = ReadDeclAs<VarDecl>(Record, Idx);
Argyrios Kyrtzidis7cb45e32010-07-22 16:03:56 +0000989 S->HandlerBlock = Reader.ReadSubStmt();
990}
991
Sebastian Redl60adf4a2010-08-18 23:56:52 +0000992void ASTStmtReader::VisitCXXTryStmt(CXXTryStmt *S) {
Argyrios Kyrtzidis7cb45e32010-07-22 16:03:56 +0000993 VisitStmt(S);
994 assert(Record[Idx] == S->getNumHandlers() && "NumStmtFields is wrong ?");
995 ++Idx;
Sebastian Redlc3632732010-10-05 15:59:54 +0000996 S->TryLoc = ReadSourceLocation(Record, Idx);
Argyrios Kyrtzidis7cb45e32010-07-22 16:03:56 +0000997 S->getStmts()[0] = Reader.ReadSubStmt();
998 for (unsigned i = 0, e = S->getNumHandlers(); i != e; ++i)
999 S->getStmts()[i + 1] = Reader.ReadSubStmt();
1000}
Argyrios Kyrtzidisba0a9002009-07-14 03:19:21 +00001001
Richard Smithad762fc2011-04-14 22:09:26 +00001002void ASTStmtReader::VisitCXXForRangeStmt(CXXForRangeStmt *S) {
1003 VisitStmt(S);
1004 S->setForLoc(ReadSourceLocation(Record, Idx));
1005 S->setColonLoc(ReadSourceLocation(Record, Idx));
1006 S->setRParenLoc(ReadSourceLocation(Record, Idx));
1007 S->setRangeStmt(Reader.ReadSubStmt());
1008 S->setBeginEndStmt(Reader.ReadSubStmt());
1009 S->setCond(Reader.ReadSubExpr());
1010 S->setInc(Reader.ReadSubExpr());
1011 S->setLoopVarStmt(Reader.ReadSubStmt());
1012 S->setBody(Reader.ReadSubStmt());
1013}
1014
Douglas Gregorba0513d2011-10-25 01:33:02 +00001015void ASTStmtReader::VisitMSDependentExistsStmt(MSDependentExistsStmt *S) {
1016 VisitStmt(S);
1017 S->KeywordLoc = ReadSourceLocation(Record, Idx);
1018 S->IsIfExists = Record[Idx++];
1019 S->QualifierLoc = Reader.ReadNestedNameSpecifierLoc(F, Record, Idx);
1020 ReadDeclarationNameInfo(S->NameInfo, Record, Idx);
1021 S->SubStmt = Reader.ReadSubStmt();
1022}
1023
Sebastian Redl60adf4a2010-08-18 23:56:52 +00001024void ASTStmtReader::VisitCXXOperatorCallExpr(CXXOperatorCallExpr *E) {
Argyrios Kyrtzidis919e6932010-06-28 22:28:35 +00001025 VisitCallExpr(E);
Argyrios Kyrtzidisba0a9002009-07-14 03:19:21 +00001026 E->setOperator((OverloadedOperatorKind)Record[Idx++]);
Argyrios Kyrtzidisba0a9002009-07-14 03:19:21 +00001027}
1028
Sebastian Redl60adf4a2010-08-18 23:56:52 +00001029void ASTStmtReader::VisitCXXConstructExpr(CXXConstructExpr *E) {
Douglas Gregor39da0b82009-09-09 23:08:42 +00001030 VisitExpr(E);
Argyrios Kyrtzidis6d00c132010-07-10 11:46:15 +00001031 E->NumArgs = Record[Idx++];
1032 if (E->NumArgs)
Douglas Gregor35942772011-09-09 21:34:22 +00001033 E->Args = new (Reader.getContext()) Stmt*[E->NumArgs];
Argyrios Kyrtzidis5e1b7c22010-06-24 08:57:09 +00001034 for (unsigned I = 0, N = E->getNumArgs(); I != N; ++I)
Argyrios Kyrtzidisd98a2ab2010-06-29 22:46:25 +00001035 E->setArg(I, Reader.ReadSubExpr());
Douglas Gregor409448c2011-07-21 22:35:25 +00001036 E->setConstructor(ReadDeclAs<CXXConstructorDecl>(Record, Idx));
Sebastian Redlc3632732010-10-05 15:59:54 +00001037 E->setLocation(ReadSourceLocation(Record, Idx));
Abramo Bagnara7cc58b42011-10-05 07:56:41 +00001038 E->setElidable(Record[Idx++]);
1039 E->setHadMultipleCandidates(Record[Idx++]);
Douglas Gregor16006c92009-12-16 18:50:27 +00001040 E->setRequiresZeroInitialization(Record[Idx++]);
Douglas Gregor3c9034c2010-05-15 00:13:29 +00001041 E->setConstructionKind((CXXConstructExpr::ConstructionKind)Record[Idx++]);
Chandler Carruth428edaf2010-10-25 08:47:36 +00001042 E->ParenRange = ReadSourceRange(Record, Idx);
Douglas Gregor39da0b82009-09-09 23:08:42 +00001043}
Chris Lattner4c6f9522009-04-27 05:14:47 +00001044
Sebastian Redl60adf4a2010-08-18 23:56:52 +00001045void ASTStmtReader::VisitCXXTemporaryObjectExpr(CXXTemporaryObjectExpr *E) {
Argyrios Kyrtzidis6d00c132010-07-10 11:46:15 +00001046 VisitCXXConstructExpr(E);
Sebastian Redlc3632732010-10-05 15:59:54 +00001047 E->Type = GetTypeSourceInfo(Record, Idx);
Argyrios Kyrtzidis6d00c132010-07-10 11:46:15 +00001048}
1049
Sebastian Redl60adf4a2010-08-18 23:56:52 +00001050void ASTStmtReader::VisitCXXNamedCastExpr(CXXNamedCastExpr *E) {
Argyrios Kyrtzidis919e6932010-06-28 22:28:35 +00001051 VisitExplicitCastExpr(E);
Douglas Gregor1d5d0b92011-01-12 22:41:29 +00001052 SourceRange R = ReadSourceRange(Record, Idx);
1053 E->Loc = R.getBegin();
1054 E->RParenLoc = R.getEnd();
Sam Weinigce757a72010-01-16 21:21:01 +00001055}
1056
Sebastian Redl60adf4a2010-08-18 23:56:52 +00001057void ASTStmtReader::VisitCXXStaticCastExpr(CXXStaticCastExpr *E) {
Sam Weinigce757a72010-01-16 21:21:01 +00001058 return VisitCXXNamedCastExpr(E);
1059}
1060
Sebastian Redl60adf4a2010-08-18 23:56:52 +00001061void ASTStmtReader::VisitCXXDynamicCastExpr(CXXDynamicCastExpr *E) {
Sam Weinigce757a72010-01-16 21:21:01 +00001062 return VisitCXXNamedCastExpr(E);
1063}
1064
Sebastian Redl60adf4a2010-08-18 23:56:52 +00001065void ASTStmtReader::VisitCXXReinterpretCastExpr(CXXReinterpretCastExpr *E) {
Sam Weinigce757a72010-01-16 21:21:01 +00001066 return VisitCXXNamedCastExpr(E);
1067}
1068
Sebastian Redl60adf4a2010-08-18 23:56:52 +00001069void ASTStmtReader::VisitCXXConstCastExpr(CXXConstCastExpr *E) {
Sam Weinigce757a72010-01-16 21:21:01 +00001070 return VisitCXXNamedCastExpr(E);
1071}
1072
Sebastian Redl60adf4a2010-08-18 23:56:52 +00001073void ASTStmtReader::VisitCXXFunctionalCastExpr(CXXFunctionalCastExpr *E) {
Argyrios Kyrtzidis919e6932010-06-28 22:28:35 +00001074 VisitExplicitCastExpr(E);
Sebastian Redlc3632732010-10-05 15:59:54 +00001075 E->setTypeBeginLoc(ReadSourceLocation(Record, Idx));
1076 E->setRParenLoc(ReadSourceLocation(Record, Idx));
Sam Weinigce757a72010-01-16 21:21:01 +00001077}
1078
Sebastian Redl60adf4a2010-08-18 23:56:52 +00001079void ASTStmtReader::VisitCXXBoolLiteralExpr(CXXBoolLiteralExpr *E) {
Sam Weinigeb7f9612010-02-07 06:32:43 +00001080 VisitExpr(E);
1081 E->setValue(Record[Idx++]);
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::VisitCXXNullPtrLiteralExpr(CXXNullPtrLiteralExpr *E) {
Sam Weinigeb7f9612010-02-07 06:32:43 +00001086 VisitExpr(E);
Sebastian Redlc3632732010-10-05 15:59:54 +00001087 E->setLocation(ReadSourceLocation(Record, Idx));
Sam Weinigeb7f9612010-02-07 06:32:43 +00001088}
1089
Sebastian Redl60adf4a2010-08-18 23:56:52 +00001090void ASTStmtReader::VisitCXXTypeidExpr(CXXTypeidExpr *E) {
Chris Lattner14ab24f2010-05-09 06:03:39 +00001091 VisitExpr(E);
Sebastian Redlc3632732010-10-05 15:59:54 +00001092 E->setSourceRange(ReadSourceRange(Record, Idx));
Chris Lattner14ab24f2010-05-09 06:03:39 +00001093 if (E->isTypeOperand()) { // typeid(int)
Sebastian Redl577d4792010-07-22 22:43:28 +00001094 E->setTypeOperandSourceInfo(
Sebastian Redlc3632732010-10-05 15:59:54 +00001095 GetTypeSourceInfo(Record, Idx));
Argyrios Kyrtzidis919e6932010-06-28 22:28:35 +00001096 return;
Chris Lattner14ab24f2010-05-09 06:03:39 +00001097 }
1098
1099 // typeid(42+2)
Argyrios Kyrtzidisd98a2ab2010-06-29 22:46:25 +00001100 E->setExprOperand(Reader.ReadSubExpr());
Chris Lattner14ab24f2010-05-09 06:03:39 +00001101}
1102
Sebastian Redl60adf4a2010-08-18 23:56:52 +00001103void ASTStmtReader::VisitCXXThisExpr(CXXThisExpr *E) {
Chris Lattner2fbdfcd2010-05-09 06:15:05 +00001104 VisitExpr(E);
Sebastian Redlc3632732010-10-05 15:59:54 +00001105 E->setLocation(ReadSourceLocation(Record, Idx));
Chris Lattner2fbdfcd2010-05-09 06:15:05 +00001106 E->setImplicit(Record[Idx++]);
Chris Lattner2fbdfcd2010-05-09 06:15:05 +00001107}
1108
Sebastian Redl60adf4a2010-08-18 23:56:52 +00001109void ASTStmtReader::VisitCXXThrowExpr(CXXThrowExpr *E) {
Chris Lattner2fbdfcd2010-05-09 06:15:05 +00001110 VisitExpr(E);
Douglas Gregorbca01b42011-07-06 22:04:06 +00001111 E->ThrowLoc = ReadSourceLocation(Record, Idx);
1112 E->Op = Reader.ReadSubExpr();
1113 E->IsThrownVariableInScope = Record[Idx++];
Chris Lattner2fbdfcd2010-05-09 06:15:05 +00001114}
Chris Lattner14ab24f2010-05-09 06:03:39 +00001115
Sebastian Redl60adf4a2010-08-18 23:56:52 +00001116void ASTStmtReader::VisitCXXDefaultArgExpr(CXXDefaultArgExpr *E) {
Chris Lattner030854b2010-05-09 06:40:08 +00001117 VisitExpr(E);
Argyrios Kyrtzidis8a507332010-07-02 23:30:15 +00001118
Douglas Gregordf226552011-09-23 22:07:41 +00001119 assert((bool)Record[Idx] == E->Param.getInt() && "We messed up at creation ?");
Argyrios Kyrtzidis8a507332010-07-02 23:30:15 +00001120 ++Idx; // HasOtherExprStored and SubExpr was handled during creation.
Douglas Gregor409448c2011-07-21 22:35:25 +00001121 E->Param.setPointer(ReadDeclAs<ParmVarDecl>(Record, Idx));
Sebastian Redlc3632732010-10-05 15:59:54 +00001122 E->Loc = ReadSourceLocation(Record, Idx);
Chris Lattnerd2598362010-05-10 00:25:06 +00001123}
1124
Sebastian Redl60adf4a2010-08-18 23:56:52 +00001125void ASTStmtReader::VisitCXXBindTemporaryExpr(CXXBindTemporaryExpr *E) {
Chris Lattnerd2598362010-05-10 00:25:06 +00001126 VisitExpr(E);
Douglas Gregor409448c2011-07-21 22:35:25 +00001127 E->setTemporary(Reader.ReadCXXTemporary(F, Record, Idx));
Argyrios Kyrtzidisd98a2ab2010-06-29 22:46:25 +00001128 E->setSubExpr(Reader.ReadSubExpr());
Chris Lattnerd2598362010-05-10 00:25:06 +00001129}
1130
Sebastian Redl60adf4a2010-08-18 23:56:52 +00001131void ASTStmtReader::VisitCXXScalarValueInitExpr(CXXScalarValueInitExpr *E) {
Chris Lattner59218632010-05-10 01:22:27 +00001132 VisitExpr(E);
Sebastian Redlc3632732010-10-05 15:59:54 +00001133 E->TypeInfo = GetTypeSourceInfo(Record, Idx);
1134 E->RParenLoc = ReadSourceLocation(Record, Idx);
Chris Lattner59218632010-05-10 01:22:27 +00001135}
1136
Sebastian Redl60adf4a2010-08-18 23:56:52 +00001137void ASTStmtReader::VisitCXXNewExpr(CXXNewExpr *E) {
Chris Lattner59218632010-05-10 01:22:27 +00001138 VisitExpr(E);
John McCall6ec278d2011-01-27 09:37:56 +00001139 E->GlobalNew = Record[Idx++];
1140 E->Initializer = Record[Idx++];
1141 E->UsualArrayDeleteWantsSize = Record[Idx++];
Chris Lattner59218632010-05-10 01:22:27 +00001142 bool isArray = Record[Idx++];
Abramo Bagnara7cc58b42011-10-05 07:56:41 +00001143 E->setHadMultipleCandidates(Record[Idx++]);
Chris Lattner59218632010-05-10 01:22:27 +00001144 unsigned NumPlacementArgs = Record[Idx++];
1145 unsigned NumCtorArgs = Record[Idx++];
Douglas Gregor409448c2011-07-21 22:35:25 +00001146 E->setOperatorNew(ReadDeclAs<FunctionDecl>(Record, Idx));
1147 E->setOperatorDelete(ReadDeclAs<FunctionDecl>(Record, Idx));
1148 E->setConstructor(ReadDeclAs<CXXConstructorDecl>(Record, Idx));
Sebastian Redlc3632732010-10-05 15:59:54 +00001149 E->AllocatedTypeInfo = GetTypeSourceInfo(Record, Idx);
Douglas Gregor4bd40312010-07-13 15:54:32 +00001150 SourceRange TypeIdParens;
Sebastian Redlc3632732010-10-05 15:59:54 +00001151 TypeIdParens.setBegin(ReadSourceLocation(Record, Idx));
1152 TypeIdParens.setEnd(ReadSourceLocation(Record, Idx));
Douglas Gregor4bd40312010-07-13 15:54:32 +00001153 E->TypeIdParens = TypeIdParens;
Chandler Carruth428edaf2010-10-25 08:47:36 +00001154 E->StartLoc = ReadSourceLocation(Record, Idx);
1155 E->EndLoc = ReadSourceLocation(Record, Idx);
1156 E->ConstructorLParen = ReadSourceLocation(Record, Idx);
1157 E->ConstructorRParen = ReadSourceLocation(Record, Idx);
1158
Douglas Gregor35942772011-09-09 21:34:22 +00001159 E->AllocateArgsArray(Reader.getContext(), isArray, NumPlacementArgs,
Chris Lattner59218632010-05-10 01:22:27 +00001160 NumCtorArgs);
1161
1162 // Install all the subexpressions.
Chris Lattner59218632010-05-10 01:22:27 +00001163 for (CXXNewExpr::raw_arg_iterator I = E->raw_arg_begin(),e = E->raw_arg_end();
1164 I != e; ++I)
Argyrios Kyrtzidisd98a2ab2010-06-29 22:46:25 +00001165 *I = Reader.ReadSubStmt();
Chris Lattner59218632010-05-10 01:22:27 +00001166}
1167
Sebastian Redl60adf4a2010-08-18 23:56:52 +00001168void ASTStmtReader::VisitCXXDeleteExpr(CXXDeleteExpr *E) {
Argyrios Kyrtzidis95fc98c2010-06-22 17:07:59 +00001169 VisitExpr(E);
Argyrios Kyrtzidisf1b89112010-09-13 20:15:40 +00001170 E->GlobalDelete = Record[Idx++];
1171 E->ArrayForm = Record[Idx++];
Argyrios Kyrtzidis4076dac2010-09-13 20:15:54 +00001172 E->ArrayFormAsWritten = Record[Idx++];
John McCall6ec278d2011-01-27 09:37:56 +00001173 E->UsualArrayDeleteWantsSize = Record[Idx++];
Douglas Gregor409448c2011-07-21 22:35:25 +00001174 E->OperatorDelete = ReadDeclAs<FunctionDecl>(Record, Idx);
Argyrios Kyrtzidisf1b89112010-09-13 20:15:40 +00001175 E->Argument = Reader.ReadSubExpr();
Sebastian Redlc3632732010-10-05 15:59:54 +00001176 E->Loc = ReadSourceLocation(Record, Idx);
Argyrios Kyrtzidis95fc98c2010-06-22 17:07:59 +00001177}
Chris Lattnerd2598362010-05-10 00:25:06 +00001178
Sebastian Redl60adf4a2010-08-18 23:56:52 +00001179void ASTStmtReader::VisitCXXPseudoDestructorExpr(CXXPseudoDestructorExpr *E) {
Argyrios Kyrtzidisde4bd182010-06-28 09:32:03 +00001180 VisitExpr(E);
1181
Douglas Gregorf3db29f2011-02-25 18:19:59 +00001182 E->Base = Reader.ReadSubExpr();
1183 E->IsArrow = Record[Idx++];
1184 E->OperatorLoc = ReadSourceLocation(Record, Idx);
1185 E->QualifierLoc = Reader.ReadNestedNameSpecifierLoc(F, Record, Idx);
1186 E->ScopeType = GetTypeSourceInfo(Record, Idx);
1187 E->ColonColonLoc = ReadSourceLocation(Record, Idx);
1188 E->TildeLoc = ReadSourceLocation(Record, Idx);
Argyrios Kyrtzidisde4bd182010-06-28 09:32:03 +00001189
Douglas Gregor95eab172011-07-28 20:55:49 +00001190 IdentifierInfo *II = Reader.GetIdentifierInfo(F, Record, Idx);
Argyrios Kyrtzidisde4bd182010-06-28 09:32:03 +00001191 if (II)
Sebastian Redlc3632732010-10-05 15:59:54 +00001192 E->setDestroyedType(II, ReadSourceLocation(Record, Idx));
Argyrios Kyrtzidisde4bd182010-06-28 09:32:03 +00001193 else
Sebastian Redlc3632732010-10-05 15:59:54 +00001194 E->setDestroyedType(GetTypeSourceInfo(Record, Idx));
Argyrios Kyrtzidisde4bd182010-06-28 09:32:03 +00001195}
1196
John McCall4765fa02010-12-06 08:20:24 +00001197void ASTStmtReader::VisitExprWithCleanups(ExprWithCleanups *E) {
Chris Lattnerd2598362010-05-10 00:25:06 +00001198 VisitExpr(E);
John McCall80ee6e82011-11-10 05:35:25 +00001199
1200 unsigned NumObjects = Record[Idx++];
1201 assert(NumObjects == E->getNumObjects());
1202 for (unsigned i = 0; i != NumObjects; ++i)
1203 E->getObjectsBuffer()[i] = ReadDeclAs<BlockDecl>(Record, Idx);
1204
1205 E->SubExpr = Reader.ReadSubExpr();
Chris Lattner030854b2010-05-09 06:40:08 +00001206}
1207
Argyrios Kyrtzidis919e6932010-06-28 22:28:35 +00001208void
Sebastian Redl60adf4a2010-08-18 23:56:52 +00001209ASTStmtReader::VisitCXXDependentScopeMemberExpr(CXXDependentScopeMemberExpr *E){
Argyrios Kyrtzidis8dfbd8b2010-06-24 08:57:31 +00001210 VisitExpr(E);
Abramo Bagnarae4b92762012-01-27 09:46:47 +00001211
1212 if (Record[Idx++]) // HasTemplateKWAndArgsInfo
1213 ReadTemplateKWAndArgsInfo(*E->getTemplateKWAndArgsInfo(),
1214 /*NumTemplateArgs=*/Record[Idx++]);
Argyrios Kyrtzidis8dfbd8b2010-06-24 08:57:31 +00001215
Douglas Gregor7c3179c2011-02-28 18:50:33 +00001216 E->Base = Reader.ReadSubExpr();
Douglas Gregor393f2492011-07-22 00:38:23 +00001217 E->BaseType = Reader.readType(F, Record, Idx);
Douglas Gregor7c3179c2011-02-28 18:50:33 +00001218 E->IsArrow = Record[Idx++];
1219 E->OperatorLoc = ReadSourceLocation(Record, Idx);
1220 E->QualifierLoc = Reader.ReadNestedNameSpecifierLoc(F, Record, Idx);
Douglas Gregor409448c2011-07-21 22:35:25 +00001221 E->FirstQualifierFoundInScope = ReadDeclAs<NamedDecl>(Record, Idx);
Argyrios Kyrtzidis40451072010-10-15 18:21:24 +00001222 ReadDeclarationNameInfo(E->MemberNameInfo, Record, Idx);
Argyrios Kyrtzidis8dfbd8b2010-06-24 08:57:31 +00001223}
1224
Argyrios Kyrtzidis919e6932010-06-28 22:28:35 +00001225void
Sebastian Redl60adf4a2010-08-18 23:56:52 +00001226ASTStmtReader::VisitDependentScopeDeclRefExpr(DependentScopeDeclRefExpr *E) {
Argyrios Kyrtzidis12dffcd2010-06-28 09:31:56 +00001227 VisitExpr(E);
Abramo Bagnarae4b92762012-01-27 09:46:47 +00001228
1229 if (Record[Idx++]) // HasTemplateKWAndArgsInfo
1230 ReadTemplateKWAndArgsInfo(*E->getTemplateKWAndArgsInfo(),
1231 /*NumTemplateArgs=*/Record[Idx++]);
Douglas Gregor00cf3cc2011-02-25 20:49:16 +00001232
1233 E->QualifierLoc = Reader.ReadNestedNameSpecifierLoc(F, Record, Idx);
Argyrios Kyrtzidis40451072010-10-15 18:21:24 +00001234 ReadDeclarationNameInfo(E->NameInfo, Record, Idx);
Argyrios Kyrtzidis12dffcd2010-06-28 09:31:56 +00001235}
1236
Argyrios Kyrtzidis919e6932010-06-28 22:28:35 +00001237void
Sebastian Redl60adf4a2010-08-18 23:56:52 +00001238ASTStmtReader::VisitCXXUnresolvedConstructExpr(CXXUnresolvedConstructExpr *E) {
Argyrios Kyrtzidis8dfbd8b2010-06-24 08:57:31 +00001239 VisitExpr(E);
1240 assert(Record[Idx] == E->arg_size() && "Read wrong record during creation ?");
1241 ++Idx; // NumArgs;
1242 for (unsigned I = 0, N = E->arg_size(); I != N; ++I)
Argyrios Kyrtzidisd98a2ab2010-06-29 22:46:25 +00001243 E->setArg(I, Reader.ReadSubExpr());
Sebastian Redlc3632732010-10-05 15:59:54 +00001244 E->Type = GetTypeSourceInfo(Record, Idx);
1245 E->setLParenLoc(ReadSourceLocation(Record, Idx));
1246 E->setRParenLoc(ReadSourceLocation(Record, Idx));
Argyrios Kyrtzidis8dfbd8b2010-06-24 08:57:31 +00001247}
1248
Sebastian Redl60adf4a2010-08-18 23:56:52 +00001249void ASTStmtReader::VisitOverloadExpr(OverloadExpr *E) {
Argyrios Kyrtzidisa77eb082010-06-25 09:03:26 +00001250 VisitExpr(E);
Abramo Bagnarae4b92762012-01-27 09:46:47 +00001251
1252 if (Record[Idx++]) // HasTemplateKWAndArgsInfo
1253 ReadTemplateKWAndArgsInfo(*E->getTemplateKWAndArgsInfo(),
1254 /*NumTemplateArgs=*/Record[Idx++]);
Argyrios Kyrtzidisa77eb082010-06-25 09:03:26 +00001255
1256 unsigned NumDecls = Record[Idx++];
1257 UnresolvedSet<8> Decls;
1258 for (unsigned i = 0; i != NumDecls; ++i) {
Douglas Gregor409448c2011-07-21 22:35:25 +00001259 NamedDecl *D = ReadDeclAs<NamedDecl>(Record, Idx);
Argyrios Kyrtzidisa77eb082010-06-25 09:03:26 +00001260 AccessSpecifier AS = (AccessSpecifier)Record[Idx++];
1261 Decls.addDecl(D, AS);
1262 }
Douglas Gregor35942772011-09-09 21:34:22 +00001263 E->initializeResults(Reader.getContext(), Decls.begin(), Decls.end());
Argyrios Kyrtzidisa77eb082010-06-25 09:03:26 +00001264
Argyrios Kyrtzidis40451072010-10-15 18:21:24 +00001265 ReadDeclarationNameInfo(E->NameInfo, Record, Idx);
Douglas Gregor4c9be892011-02-28 20:01:57 +00001266 E->QualifierLoc = Reader.ReadNestedNameSpecifierLoc(F, Record, Idx);
Argyrios Kyrtzidisa77eb082010-06-25 09:03:26 +00001267}
1268
Sebastian Redl60adf4a2010-08-18 23:56:52 +00001269void ASTStmtReader::VisitUnresolvedMemberExpr(UnresolvedMemberExpr *E) {
Argyrios Kyrtzidis919e6932010-06-28 22:28:35 +00001270 VisitOverloadExpr(E);
Douglas Gregor4c9be892011-02-28 20:01:57 +00001271 E->IsArrow = Record[Idx++];
1272 E->HasUnresolvedUsing = Record[Idx++];
1273 E->Base = Reader.ReadSubExpr();
Douglas Gregor393f2492011-07-22 00:38:23 +00001274 E->BaseType = Reader.readType(F, Record, Idx);
Douglas Gregor4c9be892011-02-28 20:01:57 +00001275 E->OperatorLoc = ReadSourceLocation(Record, Idx);
Argyrios Kyrtzidisa77eb082010-06-25 09:03:26 +00001276}
1277
Sebastian Redl60adf4a2010-08-18 23:56:52 +00001278void ASTStmtReader::VisitUnresolvedLookupExpr(UnresolvedLookupExpr *E) {
Argyrios Kyrtzidis919e6932010-06-28 22:28:35 +00001279 VisitOverloadExpr(E);
Douglas Gregor4c9be892011-02-28 20:01:57 +00001280 E->RequiresADL = Record[Idx++];
Richard Smithad762fc2011-04-14 22:09:26 +00001281 if (E->RequiresADL)
1282 E->StdIsAssociatedNamespace = Record[Idx++];
Douglas Gregor4c9be892011-02-28 20:01:57 +00001283 E->Overloaded = Record[Idx++];
Douglas Gregor409448c2011-07-21 22:35:25 +00001284 E->NamingClass = ReadDeclAs<CXXRecordDecl>(Record, Idx);
Argyrios Kyrtzidisbd65bb52010-06-25 09:03:34 +00001285}
1286
Sebastian Redl60adf4a2010-08-18 23:56:52 +00001287void ASTStmtReader::VisitUnaryTypeTraitExpr(UnaryTypeTraitExpr *E) {
Argyrios Kyrtzidis6d00c132010-07-10 11:46:15 +00001288 VisitExpr(E);
1289 E->UTT = (UnaryTypeTrait)Record[Idx++];
Sebastian Redl0dfd8482010-09-13 20:56:31 +00001290 E->Value = (bool)Record[Idx++];
Sebastian Redlc3632732010-10-05 15:59:54 +00001291 SourceRange Range = ReadSourceRange(Record, Idx);
Argyrios Kyrtzidis6d00c132010-07-10 11:46:15 +00001292 E->Loc = Range.getBegin();
1293 E->RParen = Range.getEnd();
Sebastian Redlc3632732010-10-05 15:59:54 +00001294 E->QueriedType = GetTypeSourceInfo(Record, Idx);
Argyrios Kyrtzidis6d00c132010-07-10 11:46:15 +00001295}
1296
Francois Pichet6ad6f282010-12-07 00:08:36 +00001297void ASTStmtReader::VisitBinaryTypeTraitExpr(BinaryTypeTraitExpr *E) {
1298 VisitExpr(E);
1299 E->BTT = (BinaryTypeTrait)Record[Idx++];
1300 E->Value = (bool)Record[Idx++];
1301 SourceRange Range = ReadSourceRange(Record, Idx);
1302 E->Loc = Range.getBegin();
1303 E->RParen = Range.getEnd();
1304 E->LhsType = GetTypeSourceInfo(Record, Idx);
1305 E->RhsType = GetTypeSourceInfo(Record, Idx);
1306}
1307
John Wiegley21ff2e52011-04-28 00:16:57 +00001308void ASTStmtReader::VisitArrayTypeTraitExpr(ArrayTypeTraitExpr *E) {
1309 VisitExpr(E);
1310 E->ATT = (ArrayTypeTrait)Record[Idx++];
1311 E->Value = (unsigned int)Record[Idx++];
1312 SourceRange Range = ReadSourceRange(Record, Idx);
1313 E->Loc = Range.getBegin();
1314 E->RParen = Range.getEnd();
1315 E->QueriedType = GetTypeSourceInfo(Record, Idx);
1316}
1317
John Wiegley55262202011-04-25 06:54:41 +00001318void ASTStmtReader::VisitExpressionTraitExpr(ExpressionTraitExpr *E) {
1319 VisitExpr(E);
1320 E->ET = (ExpressionTrait)Record[Idx++];
1321 E->Value = (bool)Record[Idx++];
1322 SourceRange Range = ReadSourceRange(Record, Idx);
1323 E->QueriedExpression = Reader.ReadSubExpr();
1324 E->Loc = Range.getBegin();
1325 E->RParen = Range.getEnd();
1326}
1327
Sebastian Redl6b219d02010-09-10 20:55:54 +00001328void ASTStmtReader::VisitCXXNoexceptExpr(CXXNoexceptExpr *E) {
1329 VisitExpr(E);
Sebastian Redl5221d8f2010-09-10 22:34:40 +00001330 E->Value = (bool)Record[Idx++];
Sebastian Redlc3632732010-10-05 15:59:54 +00001331 E->Range = ReadSourceRange(Record, Idx);
Sebastian Redl5221d8f2010-09-10 22:34:40 +00001332 E->Operand = Reader.ReadSubExpr();
Sebastian Redl6b219d02010-09-10 20:55:54 +00001333}
1334
Douglas Gregorbe230c32011-01-03 17:17:50 +00001335void ASTStmtReader::VisitPackExpansionExpr(PackExpansionExpr *E) {
1336 VisitExpr(E);
1337 E->EllipsisLoc = ReadSourceLocation(Record, Idx);
Douglas Gregor67fd1252011-01-14 21:20:45 +00001338 E->NumExpansions = Record[Idx++];
Douglas Gregorbe230c32011-01-03 17:17:50 +00001339 E->Pattern = Reader.ReadSubExpr();
1340}
1341
Douglas Gregoree8aff02011-01-04 17:33:58 +00001342void ASTStmtReader::VisitSizeOfPackExpr(SizeOfPackExpr *E) {
1343 VisitExpr(E);
1344 E->OperatorLoc = ReadSourceLocation(Record, Idx);
1345 E->PackLoc = ReadSourceLocation(Record, Idx);
1346 E->RParenLoc = ReadSourceLocation(Record, Idx);
1347 E->Length = Record[Idx++];
Douglas Gregor409448c2011-07-21 22:35:25 +00001348 E->Pack = ReadDeclAs<NamedDecl>(Record, Idx);
Douglas Gregoree8aff02011-01-04 17:33:58 +00001349}
1350
John McCall7110fd62011-07-15 07:00:14 +00001351void ASTStmtReader::VisitSubstNonTypeTemplateParmExpr(
1352 SubstNonTypeTemplateParmExpr *E) {
1353 VisitExpr(E);
Douglas Gregor409448c2011-07-21 22:35:25 +00001354 E->Param = ReadDeclAs<NonTypeTemplateParmDecl>(Record, Idx);
John McCall7110fd62011-07-15 07:00:14 +00001355 E->NameLoc = ReadSourceLocation(Record, Idx);
1356 E->Replacement = Reader.ReadSubExpr();
1357}
1358
Douglas Gregorc7793c72011-01-15 01:15:58 +00001359void ASTStmtReader::VisitSubstNonTypeTemplateParmPackExpr(
1360 SubstNonTypeTemplateParmPackExpr *E) {
1361 VisitExpr(E);
Douglas Gregor409448c2011-07-21 22:35:25 +00001362 E->Param = ReadDeclAs<NonTypeTemplateParmDecl>(Record, Idx);
Douglas Gregorc7793c72011-01-15 01:15:58 +00001363 TemplateArgument ArgPack = Reader.ReadTemplateArgument(F, Record, Idx);
1364 if (ArgPack.getKind() != TemplateArgument::Pack)
1365 return;
1366
1367 E->Arguments = ArgPack.pack_begin();
1368 E->NumArguments = ArgPack.pack_size();
1369 E->NameLoc = ReadSourceLocation(Record, Idx);
1370}
1371
Douglas Gregor03e80032011-06-21 17:03:29 +00001372void ASTStmtReader::VisitMaterializeTemporaryExpr(MaterializeTemporaryExpr *E) {
1373 VisitExpr(E);
1374 E->Temporary = Reader.ReadSubExpr();
1375}
1376
John McCall7cd7d1a2010-11-15 23:31:06 +00001377void ASTStmtReader::VisitOpaqueValueExpr(OpaqueValueExpr *E) {
1378 VisitExpr(E);
Argyrios Kyrtzidis8bc27822011-12-03 03:49:52 +00001379 E->SourceExpr = Reader.ReadSubExpr();
Douglas Gregorb608b982011-01-28 02:26:04 +00001380 E->Loc = ReadSourceLocation(Record, Idx);
John McCall7cd7d1a2010-11-15 23:31:06 +00001381}
1382
Peter Collingbournee08ce652011-02-09 21:07:24 +00001383//===----------------------------------------------------------------------===//
John McCall7110fd62011-07-15 07:00:14 +00001384// Microsoft Expressions and Statements
1385//===----------------------------------------------------------------------===//
1386void ASTStmtReader::VisitCXXUuidofExpr(CXXUuidofExpr *E) {
1387 VisitExpr(E);
1388 E->setSourceRange(ReadSourceRange(Record, Idx));
1389 if (E->isTypeOperand()) { // __uuidof(ComType)
1390 E->setTypeOperandSourceInfo(
1391 GetTypeSourceInfo(Record, Idx));
1392 return;
1393 }
1394
1395 // __uuidof(expr)
1396 E->setExprOperand(Reader.ReadSubExpr());
1397}
1398
1399void ASTStmtReader::VisitSEHExceptStmt(SEHExceptStmt *S) {
1400 VisitStmt(S);
1401 S->Loc = ReadSourceLocation(Record, Idx);
1402 S->Children[SEHExceptStmt::FILTER_EXPR] = Reader.ReadSubStmt();
1403 S->Children[SEHExceptStmt::BLOCK] = Reader.ReadSubStmt();
1404}
1405
1406void ASTStmtReader::VisitSEHFinallyStmt(SEHFinallyStmt *S) {
1407 VisitStmt(S);
1408 S->Loc = ReadSourceLocation(Record, Idx);
1409 S->Block = Reader.ReadSubStmt();
1410}
1411
1412void ASTStmtReader::VisitSEHTryStmt(SEHTryStmt *S) {
1413 VisitStmt(S);
1414 S->IsCXXTry = Record[Idx++];
1415 S->TryLoc = ReadSourceLocation(Record, Idx);
1416 S->Children[SEHTryStmt::TRY] = Reader.ReadSubStmt();
1417 S->Children[SEHTryStmt::HANDLER] = Reader.ReadSubStmt();
1418}
1419
1420//===----------------------------------------------------------------------===//
Peter Collingbournee08ce652011-02-09 21:07:24 +00001421// CUDA Expressions and Statements
1422//===----------------------------------------------------------------------===//
1423
1424void ASTStmtReader::VisitCUDAKernelCallExpr(CUDAKernelCallExpr *E) {
1425 VisitCallExpr(E);
1426 E->setConfig(cast<CallExpr>(Reader.ReadSubExpr()));
1427}
1428
John McCall7110fd62011-07-15 07:00:14 +00001429//===----------------------------------------------------------------------===//
1430// OpenCL Expressions and Statements.
1431//===----------------------------------------------------------------------===//
1432void ASTStmtReader::VisitAsTypeExpr(AsTypeExpr *E) {
1433 VisitExpr(E);
1434 E->BuiltinLoc = ReadSourceLocation(Record, Idx);
1435 E->RParenLoc = ReadSourceLocation(Record, Idx);
1436 E->SrcExpr = Reader.ReadSubExpr();
1437}
1438
1439//===----------------------------------------------------------------------===//
1440// ASTReader Implementation
1441//===----------------------------------------------------------------------===//
1442
Douglas Gregor1a4761e2011-11-30 23:21:26 +00001443Stmt *ASTReader::ReadStmt(ModuleFile &F) {
Argyrios Kyrtzidis919e6932010-06-28 22:28:35 +00001444 switch (ReadingKind) {
1445 case Read_Decl:
1446 case Read_Type:
Sebastian Redlc3632732010-10-05 15:59:54 +00001447 return ReadStmtFromStream(F);
Argyrios Kyrtzidis919e6932010-06-28 22:28:35 +00001448 case Read_Stmt:
Argyrios Kyrtzidisd98a2ab2010-06-29 22:46:25 +00001449 return ReadSubStmt();
Argyrios Kyrtzidis919e6932010-06-28 22:28:35 +00001450 }
1451
1452 llvm_unreachable("ReadingKind not set ?");
Argyrios Kyrtzidis919e6932010-06-28 22:28:35 +00001453}
1454
Douglas Gregor1a4761e2011-11-30 23:21:26 +00001455Expr *ASTReader::ReadExpr(ModuleFile &F) {
Sebastian Redlc3632732010-10-05 15:59:54 +00001456 return cast_or_null<Expr>(ReadStmt(F));
Argyrios Kyrtzidis919e6932010-06-28 22:28:35 +00001457}
Chris Lattner030854b2010-05-09 06:40:08 +00001458
Sebastian Redlc43b54c2010-08-18 23:56:43 +00001459Expr *ASTReader::ReadSubExpr() {
Argyrios Kyrtzidisd98a2ab2010-06-29 22:46:25 +00001460 return cast_or_null<Expr>(ReadSubStmt());
1461}
1462
Chris Lattner52e97d12009-04-27 05:41:06 +00001463// Within the bitstream, expressions are stored in Reverse Polish
1464// Notation, with each of the subexpressions preceding the
Argyrios Kyrtzidis919e6932010-06-28 22:28:35 +00001465// expression they are stored in. Subexpressions are stored from last to first.
1466// To evaluate expressions, we continue reading expressions and placing them on
1467// the stack, with expressions having operands removing those operands from the
Chris Lattner52e97d12009-04-27 05:41:06 +00001468// stack. Evaluation terminates when we see a STMT_STOP record, and
1469// the single remaining expression on the stack is our result.
Douglas Gregor1a4761e2011-11-30 23:21:26 +00001470Stmt *ASTReader::ReadStmtFromStream(ModuleFile &F) {
Argyrios Kyrtzidis919e6932010-06-28 22:28:35 +00001471
1472 ReadingKindTracker ReadingKind(Read_Stmt, *this);
Sebastian Redlc3632732010-10-05 15:59:54 +00001473 llvm::BitstreamCursor &Cursor = F.DeclsCursor;
Argyrios Kyrtzidise6f08682011-10-21 23:02:28 +00001474
1475 // Map of offset to previously deserialized stmt. The offset points
1476 /// just after the stmt record.
1477 llvm::DenseMap<uint64_t, Stmt *> StmtEntries;
Sebastian Redlc3632732010-10-05 15:59:54 +00001478
Argyrios Kyrtzidis919e6932010-06-28 22:28:35 +00001479#ifndef NDEBUG
1480 unsigned PrevNumStmts = StmtStack.size();
1481#endif
1482
Chris Lattner4c6f9522009-04-27 05:14:47 +00001483 RecordData Record;
1484 unsigned Idx;
Sebastian Redlc3632732010-10-05 15:59:54 +00001485 ASTStmtReader Reader(*this, F, Cursor, Record, Idx);
Chris Lattner4c6f9522009-04-27 05:14:47 +00001486 Stmt::EmptyShell Empty;
1487
1488 while (true) {
Chris Lattner52e97d12009-04-27 05:41:06 +00001489 unsigned Code = Cursor.ReadCode();
Chris Lattner4c6f9522009-04-27 05:14:47 +00001490 if (Code == llvm::bitc::END_BLOCK) {
Chris Lattner52e97d12009-04-27 05:41:06 +00001491 if (Cursor.ReadBlockEnd()) {
Sebastian Redl3c7f4132010-08-18 23:57:06 +00001492 Error("error at end of block in AST file");
Chris Lattner4c6f9522009-04-27 05:14:47 +00001493 return 0;
1494 }
1495 break;
1496 }
1497
1498 if (Code == llvm::bitc::ENTER_SUBBLOCK) {
1499 // No known subblocks, always skip them.
Chris Lattner52e97d12009-04-27 05:41:06 +00001500 Cursor.ReadSubBlockID();
1501 if (Cursor.SkipBlock()) {
Sebastian Redl3c7f4132010-08-18 23:57:06 +00001502 Error("malformed block record in AST file");
Chris Lattner4c6f9522009-04-27 05:14:47 +00001503 return 0;
1504 }
1505 continue;
1506 }
1507
1508 if (Code == llvm::bitc::DEFINE_ABBREV) {
Chris Lattner52e97d12009-04-27 05:41:06 +00001509 Cursor.ReadAbbrevRecord();
Chris Lattner4c6f9522009-04-27 05:14:47 +00001510 continue;
1511 }
1512
1513 Stmt *S = 0;
1514 Idx = 0;
1515 Record.clear();
1516 bool Finished = false;
Argyrios Kyrtzidise6f08682011-10-21 23:02:28 +00001517 bool IsStmtReference = false;
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001518 switch ((StmtCode)Cursor.ReadRecord(Code, Record)) {
1519 case STMT_STOP:
Chris Lattner4c6f9522009-04-27 05:14:47 +00001520 Finished = true;
1521 break;
1522
Argyrios Kyrtzidise6f08682011-10-21 23:02:28 +00001523 case STMT_REF_PTR:
1524 IsStmtReference = true;
1525 assert(StmtEntries.find(Record[0]) != StmtEntries.end() &&
1526 "No stmt was recorded for this offset reference!");
1527 S = StmtEntries[Record[Idx++]];
1528 break;
1529
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001530 case STMT_NULL_PTR:
Mike Stump1eb44332009-09-09 15:08:12 +00001531 S = 0;
Chris Lattner4c6f9522009-04-27 05:14:47 +00001532 break;
1533
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001534 case STMT_NULL:
Chris Lattner4c6f9522009-04-27 05:14:47 +00001535 S = new (Context) NullStmt(Empty);
1536 break;
1537
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001538 case STMT_COMPOUND:
Chris Lattner4c6f9522009-04-27 05:14:47 +00001539 S = new (Context) CompoundStmt(Empty);
1540 break;
1541
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001542 case STMT_CASE:
Chris Lattner4c6f9522009-04-27 05:14:47 +00001543 S = new (Context) CaseStmt(Empty);
1544 break;
1545
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001546 case STMT_DEFAULT:
Chris Lattner4c6f9522009-04-27 05:14:47 +00001547 S = new (Context) DefaultStmt(Empty);
1548 break;
1549
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001550 case STMT_LABEL:
Chris Lattner4c6f9522009-04-27 05:14:47 +00001551 S = new (Context) LabelStmt(Empty);
1552 break;
1553
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001554 case STMT_IF:
Chris Lattner4c6f9522009-04-27 05:14:47 +00001555 S = new (Context) IfStmt(Empty);
1556 break;
1557
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001558 case STMT_SWITCH:
Chris Lattner4c6f9522009-04-27 05:14:47 +00001559 S = new (Context) SwitchStmt(Empty);
1560 break;
1561
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001562 case STMT_WHILE:
Chris Lattner4c6f9522009-04-27 05:14:47 +00001563 S = new (Context) WhileStmt(Empty);
1564 break;
1565
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001566 case STMT_DO:
Chris Lattner4c6f9522009-04-27 05:14:47 +00001567 S = new (Context) DoStmt(Empty);
1568 break;
Mike Stump1eb44332009-09-09 15:08:12 +00001569
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001570 case STMT_FOR:
Chris Lattner4c6f9522009-04-27 05:14:47 +00001571 S = new (Context) ForStmt(Empty);
1572 break;
1573
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001574 case STMT_GOTO:
Chris Lattner4c6f9522009-04-27 05:14:47 +00001575 S = new (Context) GotoStmt(Empty);
1576 break;
Mike Stump1eb44332009-09-09 15:08:12 +00001577
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001578 case STMT_INDIRECT_GOTO:
Chris Lattner4c6f9522009-04-27 05:14:47 +00001579 S = new (Context) IndirectGotoStmt(Empty);
1580 break;
1581
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001582 case STMT_CONTINUE:
Chris Lattner4c6f9522009-04-27 05:14:47 +00001583 S = new (Context) ContinueStmt(Empty);
1584 break;
1585
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001586 case STMT_BREAK:
Chris Lattner4c6f9522009-04-27 05:14:47 +00001587 S = new (Context) BreakStmt(Empty);
1588 break;
1589
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001590 case STMT_RETURN:
Chris Lattner4c6f9522009-04-27 05:14:47 +00001591 S = new (Context) ReturnStmt(Empty);
1592 break;
1593
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001594 case STMT_DECL:
Chris Lattner4c6f9522009-04-27 05:14:47 +00001595 S = new (Context) DeclStmt(Empty);
1596 break;
1597
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001598 case STMT_ASM:
Chris Lattner4c6f9522009-04-27 05:14:47 +00001599 S = new (Context) AsmStmt(Empty);
1600 break;
1601
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001602 case EXPR_PREDEFINED:
Chris Lattner4c6f9522009-04-27 05:14:47 +00001603 S = new (Context) PredefinedExpr(Empty);
1604 break;
Mike Stump1eb44332009-09-09 15:08:12 +00001605
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001606 case EXPR_DECL_REF:
Chandler Carruth3aa81402011-05-01 23:48:14 +00001607 S = DeclRefExpr::CreateEmpty(
Douglas Gregor35942772011-09-09 21:34:22 +00001608 Context,
Chandler Carruth3aa81402011-05-01 23:48:14 +00001609 /*HasQualifier=*/Record[ASTStmtReader::NumExprFields],
1610 /*HasFoundDecl=*/Record[ASTStmtReader::NumExprFields + 1],
Abramo Bagnarae4b92762012-01-27 09:46:47 +00001611 /*HasTemplateKWAndArgsInfo=*/Record[ASTStmtReader::NumExprFields + 2],
Chandler Carruth3aa81402011-05-01 23:48:14 +00001612 /*NumTemplateArgs=*/Record[ASTStmtReader::NumExprFields + 2] ?
Abramo Bagnara7cc58b42011-10-05 07:56:41 +00001613 Record[ASTStmtReader::NumExprFields + 4] : 0);
Chris Lattner4c6f9522009-04-27 05:14:47 +00001614 break;
Mike Stump1eb44332009-09-09 15:08:12 +00001615
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001616 case EXPR_INTEGER_LITERAL:
Douglas Gregor35942772011-09-09 21:34:22 +00001617 S = IntegerLiteral::Create(Context, Empty);
Chris Lattner4c6f9522009-04-27 05:14:47 +00001618 break;
Mike Stump1eb44332009-09-09 15:08:12 +00001619
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001620 case EXPR_FLOATING_LITERAL:
Douglas Gregor35942772011-09-09 21:34:22 +00001621 S = FloatingLiteral::Create(Context, Empty);
Chris Lattner4c6f9522009-04-27 05:14:47 +00001622 break;
Mike Stump1eb44332009-09-09 15:08:12 +00001623
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001624 case EXPR_IMAGINARY_LITERAL:
Chris Lattner4c6f9522009-04-27 05:14:47 +00001625 S = new (Context) ImaginaryLiteral(Empty);
1626 break;
1627
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001628 case EXPR_STRING_LITERAL:
Douglas Gregor35942772011-09-09 21:34:22 +00001629 S = StringLiteral::CreateEmpty(Context,
Sebastian Redl60adf4a2010-08-18 23:56:52 +00001630 Record[ASTStmtReader::NumExprFields + 1]);
Chris Lattner4c6f9522009-04-27 05:14:47 +00001631 break;
1632
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001633 case EXPR_CHARACTER_LITERAL:
Chris Lattner4c6f9522009-04-27 05:14:47 +00001634 S = new (Context) CharacterLiteral(Empty);
1635 break;
1636
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001637 case EXPR_PAREN:
Chris Lattner4c6f9522009-04-27 05:14:47 +00001638 S = new (Context) ParenExpr(Empty);
1639 break;
1640
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001641 case EXPR_PAREN_LIST:
Argyrios Kyrtzidis37bdfe22010-06-30 08:49:18 +00001642 S = new (Context) ParenListExpr(Empty);
1643 break;
1644
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001645 case EXPR_UNARY_OPERATOR:
Chris Lattner4c6f9522009-04-27 05:14:47 +00001646 S = new (Context) UnaryOperator(Empty);
1647 break;
1648
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001649 case EXPR_OFFSETOF:
Douglas Gregor35942772011-09-09 21:34:22 +00001650 S = OffsetOfExpr::CreateEmpty(Context,
Sebastian Redl60adf4a2010-08-18 23:56:52 +00001651 Record[ASTStmtReader::NumExprFields],
1652 Record[ASTStmtReader::NumExprFields + 1]);
Douglas Gregor8ecdb652010-04-28 22:16:22 +00001653 break;
1654
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001655 case EXPR_SIZEOF_ALIGN_OF:
Peter Collingbournef4e3cfb2011-03-11 19:24:49 +00001656 S = new (Context) UnaryExprOrTypeTraitExpr(Empty);
Chris Lattner4c6f9522009-04-27 05:14:47 +00001657 break;
1658
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001659 case EXPR_ARRAY_SUBSCRIPT:
Chris Lattner4c6f9522009-04-27 05:14:47 +00001660 S = new (Context) ArraySubscriptExpr(Empty);
1661 break;
1662
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001663 case EXPR_CALL:
Douglas Gregor35942772011-09-09 21:34:22 +00001664 S = new (Context) CallExpr(Context, Stmt::CallExprClass, Empty);
Chris Lattner4c6f9522009-04-27 05:14:47 +00001665 break;
1666
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001667 case EXPR_MEMBER: {
Argyrios Kyrtzidis663e3802010-07-08 13:09:47 +00001668 // We load everything here and fully initialize it at creation.
1669 // That way we can use MemberExpr::Create and don't have to duplicate its
1670 // logic with a MemberExpr::CreateEmpty.
1671
1672 assert(Idx == 0);
Douglas Gregor40d96a62011-02-28 21:54:11 +00001673 NestedNameSpecifierLoc QualifierLoc;
Argyrios Kyrtzidis663e3802010-07-08 13:09:47 +00001674 if (Record[Idx++]) { // HasQualifier.
Douglas Gregor40d96a62011-02-28 21:54:11 +00001675 QualifierLoc = ReadNestedNameSpecifierLoc(F, Record, Idx);
Argyrios Kyrtzidis663e3802010-07-08 13:09:47 +00001676 }
1677
Abramo Bagnarae4b92762012-01-27 09:46:47 +00001678 SourceLocation TemplateKWLoc;
Argyrios Kyrtzidis663e3802010-07-08 13:09:47 +00001679 TemplateArgumentListInfo ArgInfo;
Abramo Bagnarae4b92762012-01-27 09:46:47 +00001680 bool HasTemplateKWAndArgsInfo = Record[Idx++];
1681 if (HasTemplateKWAndArgsInfo) {
1682 TemplateKWLoc = ReadSourceLocation(F, Record, Idx);
Douglas Gregordef03542011-02-04 12:01:24 +00001683 unsigned NumTemplateArgs = Record[Idx++];
Sebastian Redlc3632732010-10-05 15:59:54 +00001684 ArgInfo.setLAngleLoc(ReadSourceLocation(F, Record, Idx));
1685 ArgInfo.setRAngleLoc(ReadSourceLocation(F, Record, Idx));
Argyrios Kyrtzidis663e3802010-07-08 13:09:47 +00001686 for (unsigned i = 0; i != NumTemplateArgs; ++i)
Sebastian Redlc3632732010-10-05 15:59:54 +00001687 ArgInfo.addArgument(ReadTemplateArgumentLoc(F, Record, Idx));
Argyrios Kyrtzidis663e3802010-07-08 13:09:47 +00001688 }
Abramo Bagnara7cc58b42011-10-05 07:56:41 +00001689
1690 bool HadMultipleCandidates = Record[Idx++];
1691
Douglas Gregor409448c2011-07-21 22:35:25 +00001692 NamedDecl *FoundD = ReadDeclAs<NamedDecl>(F, Record, Idx);
Argyrios Kyrtzidis663e3802010-07-08 13:09:47 +00001693 AccessSpecifier AS = (AccessSpecifier)Record[Idx++];
1694 DeclAccessPair FoundDecl = DeclAccessPair::make(FoundD, AS);
1695
Douglas Gregor393f2492011-07-22 00:38:23 +00001696 QualType T = readType(F, Record, Idx);
John McCallf89e55a2010-11-18 06:31:45 +00001697 ExprValueKind VK = static_cast<ExprValueKind>(Record[Idx++]);
1698 ExprObjectKind OK = static_cast<ExprObjectKind>(Record[Idx++]);
Argyrios Kyrtzidis663e3802010-07-08 13:09:47 +00001699 Expr *Base = ReadSubExpr();
Douglas Gregor409448c2011-07-21 22:35:25 +00001700 ValueDecl *MemberD = ReadDeclAs<ValueDecl>(F, Record, Idx);
Sebastian Redlc3632732010-10-05 15:59:54 +00001701 SourceLocation MemberLoc = ReadSourceLocation(F, Record, Idx);
Abramo Bagnara25777432010-08-11 22:01:17 +00001702 DeclarationNameInfo MemberNameInfo(MemberD->getDeclName(), MemberLoc);
Argyrios Kyrtzidis663e3802010-07-08 13:09:47 +00001703 bool IsArrow = Record[Idx++];
1704
Douglas Gregor35942772011-09-09 21:34:22 +00001705 S = MemberExpr::Create(Context, Base, IsArrow, QualifierLoc,
Abramo Bagnarae4b92762012-01-27 09:46:47 +00001706 TemplateKWLoc, MemberD, FoundDecl, MemberNameInfo,
1707 HasTemplateKWAndArgsInfo ? &ArgInfo : 0,
1708 T, VK, OK);
Argyrios Kyrtzidis40451072010-10-15 18:21:24 +00001709 ReadDeclarationNameLoc(F, cast<MemberExpr>(S)->MemberDNLoc,
1710 MemberD->getDeclName(), Record, Idx);
Abramo Bagnara7cc58b42011-10-05 07:56:41 +00001711 if (HadMultipleCandidates)
1712 cast<MemberExpr>(S)->setHadMultipleCandidates(true);
Chris Lattner4c6f9522009-04-27 05:14:47 +00001713 break;
Argyrios Kyrtzidis663e3802010-07-08 13:09:47 +00001714 }
Chris Lattner4c6f9522009-04-27 05:14:47 +00001715
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001716 case EXPR_BINARY_OPERATOR:
Chris Lattner4c6f9522009-04-27 05:14:47 +00001717 S = new (Context) BinaryOperator(Empty);
1718 break;
1719
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001720 case EXPR_COMPOUND_ASSIGN_OPERATOR:
Chris Lattner4c6f9522009-04-27 05:14:47 +00001721 S = new (Context) CompoundAssignOperator(Empty);
1722 break;
1723
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001724 case EXPR_CONDITIONAL_OPERATOR:
Chris Lattner4c6f9522009-04-27 05:14:47 +00001725 S = new (Context) ConditionalOperator(Empty);
1726 break;
1727
John McCall56ca35d2011-02-17 10:25:35 +00001728 case EXPR_BINARY_CONDITIONAL_OPERATOR:
1729 S = new (Context) BinaryConditionalOperator(Empty);
1730 break;
1731
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001732 case EXPR_IMPLICIT_CAST:
Douglas Gregor35942772011-09-09 21:34:22 +00001733 S = ImplicitCastExpr::CreateEmpty(Context,
Sebastian Redl60adf4a2010-08-18 23:56:52 +00001734 /*PathSize*/ Record[ASTStmtReader::NumExprFields]);
Chris Lattner4c6f9522009-04-27 05:14:47 +00001735 break;
1736
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001737 case EXPR_CSTYLE_CAST:
Douglas Gregor35942772011-09-09 21:34:22 +00001738 S = CStyleCastExpr::CreateEmpty(Context,
Sebastian Redl60adf4a2010-08-18 23:56:52 +00001739 /*PathSize*/ Record[ASTStmtReader::NumExprFields]);
Chris Lattner4c6f9522009-04-27 05:14:47 +00001740 break;
1741
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001742 case EXPR_COMPOUND_LITERAL:
Chris Lattner4c6f9522009-04-27 05:14:47 +00001743 S = new (Context) CompoundLiteralExpr(Empty);
1744 break;
1745
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001746 case EXPR_EXT_VECTOR_ELEMENT:
Chris Lattner4c6f9522009-04-27 05:14:47 +00001747 S = new (Context) ExtVectorElementExpr(Empty);
1748 break;
1749
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001750 case EXPR_INIT_LIST:
Douglas Gregor35942772011-09-09 21:34:22 +00001751 S = new (Context) InitListExpr(getContext(), Empty);
Chris Lattner4c6f9522009-04-27 05:14:47 +00001752 break;
1753
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001754 case EXPR_DESIGNATED_INIT:
Douglas Gregor35942772011-09-09 21:34:22 +00001755 S = DesignatedInitExpr::CreateEmpty(Context,
Sebastian Redl60adf4a2010-08-18 23:56:52 +00001756 Record[ASTStmtReader::NumExprFields] - 1);
Mike Stump1eb44332009-09-09 15:08:12 +00001757
Chris Lattner4c6f9522009-04-27 05:14:47 +00001758 break;
1759
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001760 case EXPR_IMPLICIT_VALUE_INIT:
Chris Lattner4c6f9522009-04-27 05:14:47 +00001761 S = new (Context) ImplicitValueInitExpr(Empty);
1762 break;
1763
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001764 case EXPR_VA_ARG:
Chris Lattner4c6f9522009-04-27 05:14:47 +00001765 S = new (Context) VAArgExpr(Empty);
1766 break;
1767
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001768 case EXPR_ADDR_LABEL:
Chris Lattner4c6f9522009-04-27 05:14:47 +00001769 S = new (Context) AddrLabelExpr(Empty);
1770 break;
1771
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001772 case EXPR_STMT:
Chris Lattner4c6f9522009-04-27 05:14:47 +00001773 S = new (Context) StmtExpr(Empty);
1774 break;
1775
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001776 case EXPR_CHOOSE:
Chris Lattner4c6f9522009-04-27 05:14:47 +00001777 S = new (Context) ChooseExpr(Empty);
1778 break;
1779
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001780 case EXPR_GNU_NULL:
Chris Lattner4c6f9522009-04-27 05:14:47 +00001781 S = new (Context) GNUNullExpr(Empty);
1782 break;
1783
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001784 case EXPR_SHUFFLE_VECTOR:
Chris Lattner4c6f9522009-04-27 05:14:47 +00001785 S = new (Context) ShuffleVectorExpr(Empty);
1786 break;
Mike Stump1eb44332009-09-09 15:08:12 +00001787
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001788 case EXPR_BLOCK:
Chris Lattner4c6f9522009-04-27 05:14:47 +00001789 S = new (Context) BlockExpr(Empty);
1790 break;
1791
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001792 case EXPR_BLOCK_DECL_REF:
Chris Lattner4c6f9522009-04-27 05:14:47 +00001793 S = new (Context) BlockDeclRefExpr(Empty);
1794 break;
Mike Stump1eb44332009-09-09 15:08:12 +00001795
Peter Collingbournef111d932011-04-15 00:35:48 +00001796 case EXPR_GENERIC_SELECTION:
1797 S = new (Context) GenericSelectionExpr(Empty);
1798 break;
1799
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001800 case EXPR_OBJC_STRING_LITERAL:
Chris Lattner4c6f9522009-04-27 05:14:47 +00001801 S = new (Context) ObjCStringLiteral(Empty);
1802 break;
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001803 case EXPR_OBJC_ENCODE:
Chris Lattner4c6f9522009-04-27 05:14:47 +00001804 S = new (Context) ObjCEncodeExpr(Empty);
1805 break;
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001806 case EXPR_OBJC_SELECTOR_EXPR:
Chris Lattner4c6f9522009-04-27 05:14:47 +00001807 S = new (Context) ObjCSelectorExpr(Empty);
1808 break;
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001809 case EXPR_OBJC_PROTOCOL_EXPR:
Chris Lattner4c6f9522009-04-27 05:14:47 +00001810 S = new (Context) ObjCProtocolExpr(Empty);
1811 break;
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001812 case EXPR_OBJC_IVAR_REF_EXPR:
Chris Lattner4c6f9522009-04-27 05:14:47 +00001813 S = new (Context) ObjCIvarRefExpr(Empty);
1814 break;
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001815 case EXPR_OBJC_PROPERTY_REF_EXPR:
Chris Lattner4c6f9522009-04-27 05:14:47 +00001816 S = new (Context) ObjCPropertyRefExpr(Empty);
1817 break;
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001818 case EXPR_OBJC_KVC_REF_EXPR:
John McCall12f78a62010-12-02 01:19:52 +00001819 llvm_unreachable("mismatching AST file");
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001820 case EXPR_OBJC_MESSAGE_EXPR:
Douglas Gregor35942772011-09-09 21:34:22 +00001821 S = ObjCMessageExpr::CreateEmpty(Context,
Argyrios Kyrtzidis20718082011-10-03 06:36:51 +00001822 Record[ASTStmtReader::NumExprFields],
1823 Record[ASTStmtReader::NumExprFields + 1]);
Chris Lattner4c6f9522009-04-27 05:14:47 +00001824 break;
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001825 case EXPR_OBJC_ISA:
Steve Narofff242b1b2009-07-24 17:54:45 +00001826 S = new (Context) ObjCIsaExpr(Empty);
1827 break;
John McCallf85e1932011-06-15 23:02:42 +00001828 case EXPR_OBJC_INDIRECT_COPY_RESTORE:
1829 S = new (Context) ObjCIndirectCopyRestoreExpr(Empty);
1830 break;
1831 case EXPR_OBJC_BRIDGED_CAST:
1832 S = new (Context) ObjCBridgedCastExpr(Empty);
1833 break;
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001834 case STMT_OBJC_FOR_COLLECTION:
Chris Lattner4c6f9522009-04-27 05:14:47 +00001835 S = new (Context) ObjCForCollectionStmt(Empty);
1836 break;
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001837 case STMT_OBJC_CATCH:
Chris Lattner4c6f9522009-04-27 05:14:47 +00001838 S = new (Context) ObjCAtCatchStmt(Empty);
1839 break;
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001840 case STMT_OBJC_FINALLY:
Chris Lattner4c6f9522009-04-27 05:14:47 +00001841 S = new (Context) ObjCAtFinallyStmt(Empty);
1842 break;
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001843 case STMT_OBJC_AT_TRY:
Douglas Gregor35942772011-09-09 21:34:22 +00001844 S = ObjCAtTryStmt::CreateEmpty(Context,
Sebastian Redl60adf4a2010-08-18 23:56:52 +00001845 Record[ASTStmtReader::NumStmtFields],
1846 Record[ASTStmtReader::NumStmtFields + 1]);
Chris Lattner4c6f9522009-04-27 05:14:47 +00001847 break;
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001848 case STMT_OBJC_AT_SYNCHRONIZED:
Chris Lattner4c6f9522009-04-27 05:14:47 +00001849 S = new (Context) ObjCAtSynchronizedStmt(Empty);
1850 break;
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001851 case STMT_OBJC_AT_THROW:
Chris Lattner4c6f9522009-04-27 05:14:47 +00001852 S = new (Context) ObjCAtThrowStmt(Empty);
1853 break;
John McCallf85e1932011-06-15 23:02:42 +00001854 case STMT_OBJC_AUTORELEASE_POOL:
1855 S = new (Context) ObjCAutoreleasePoolStmt(Empty);
1856 break;
John McCall7110fd62011-07-15 07:00:14 +00001857 case STMT_SEH_EXCEPT:
1858 S = new (Context) SEHExceptStmt(Empty);
1859 break;
1860 case STMT_SEH_FINALLY:
1861 S = new (Context) SEHFinallyStmt(Empty);
1862 break;
1863 case STMT_SEH_TRY:
1864 S = new (Context) SEHTryStmt(Empty);
1865 break;
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001866 case STMT_CXX_CATCH:
Argyrios Kyrtzidis7cb45e32010-07-22 16:03:56 +00001867 S = new (Context) CXXCatchStmt(Empty);
1868 break;
1869
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001870 case STMT_CXX_TRY:
Douglas Gregor35942772011-09-09 21:34:22 +00001871 S = CXXTryStmt::Create(Context, Empty,
Sebastian Redl60adf4a2010-08-18 23:56:52 +00001872 /*NumHandlers=*/Record[ASTStmtReader::NumStmtFields]);
Argyrios Kyrtzidis7cb45e32010-07-22 16:03:56 +00001873 break;
1874
Richard Smithad762fc2011-04-14 22:09:26 +00001875 case STMT_CXX_FOR_RANGE:
1876 S = new (Context) CXXForRangeStmt(Empty);
1877 break;
1878
Douglas Gregorba0513d2011-10-25 01:33:02 +00001879 case STMT_MS_DEPENDENT_EXISTS:
1880 S = new (Context) MSDependentExistsStmt(SourceLocation(), true,
1881 NestedNameSpecifierLoc(),
1882 DeclarationNameInfo(),
1883 0);
1884 break;
1885
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001886 case EXPR_CXX_OPERATOR_CALL:
Douglas Gregor35942772011-09-09 21:34:22 +00001887 S = new (Context) CXXOperatorCallExpr(Context, Empty);
Argyrios Kyrtzidisba0a9002009-07-14 03:19:21 +00001888 break;
Chris Lattner1817bd42010-05-09 05:36:05 +00001889
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001890 case EXPR_CXX_MEMBER_CALL:
Douglas Gregor35942772011-09-09 21:34:22 +00001891 S = new (Context) CXXMemberCallExpr(Context, Empty);
Chris Lattner1817bd42010-05-09 05:36:05 +00001892 break;
Douglas Gregor39da0b82009-09-09 23:08:42 +00001893
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001894 case EXPR_CXX_CONSTRUCT:
Argyrios Kyrtzidis6d00c132010-07-10 11:46:15 +00001895 S = new (Context) CXXConstructExpr(Empty);
1896 break;
1897
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001898 case EXPR_CXX_TEMPORARY_OBJECT:
Argyrios Kyrtzidis6d00c132010-07-10 11:46:15 +00001899 S = new (Context) CXXTemporaryObjectExpr(Empty);
Douglas Gregor39da0b82009-09-09 23:08:42 +00001900 break;
Sam Weinigce757a72010-01-16 21:21:01 +00001901
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001902 case EXPR_CXX_STATIC_CAST:
Douglas Gregor35942772011-09-09 21:34:22 +00001903 S = CXXStaticCastExpr::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_DYNAMIC_CAST:
Douglas Gregor35942772011-09-09 21:34:22 +00001908 S = CXXDynamicCastExpr::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_REINTERPRET_CAST:
Douglas Gregor35942772011-09-09 21:34:22 +00001913 S = CXXReinterpretCastExpr::CreateEmpty(Context,
Sebastian Redl60adf4a2010-08-18 23:56:52 +00001914 /*PathSize*/ Record[ASTStmtReader::NumExprFields]);
Sam Weinigce757a72010-01-16 21:21:01 +00001915 break;
1916
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001917 case EXPR_CXX_CONST_CAST:
Douglas Gregor35942772011-09-09 21:34:22 +00001918 S = CXXConstCastExpr::CreateEmpty(Context);
Sam Weinigce757a72010-01-16 21:21:01 +00001919 break;
1920
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001921 case EXPR_CXX_FUNCTIONAL_CAST:
Douglas Gregor35942772011-09-09 21:34:22 +00001922 S = CXXFunctionalCastExpr::CreateEmpty(Context,
Sebastian Redl60adf4a2010-08-18 23:56:52 +00001923 /*PathSize*/ Record[ASTStmtReader::NumExprFields]);
Sam Weinigce757a72010-01-16 21:21:01 +00001924 break;
1925
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001926 case EXPR_CXX_BOOL_LITERAL:
Sam Weinigeb7f9612010-02-07 06:32:43 +00001927 S = new (Context) CXXBoolLiteralExpr(Empty);
1928 break;
Sam Weinigce757a72010-01-16 21:21:01 +00001929
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001930 case EXPR_CXX_NULL_PTR_LITERAL:
Sam Weinigeb7f9612010-02-07 06:32:43 +00001931 S = new (Context) CXXNullPtrLiteralExpr(Empty);
1932 break;
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001933 case EXPR_CXX_TYPEID_EXPR:
Chris Lattner14ab24f2010-05-09 06:03:39 +00001934 S = new (Context) CXXTypeidExpr(Empty, true);
1935 break;
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001936 case EXPR_CXX_TYPEID_TYPE:
Chris Lattner14ab24f2010-05-09 06:03:39 +00001937 S = new (Context) CXXTypeidExpr(Empty, false);
1938 break;
Francois Pichet01b7c302010-09-08 12:20:18 +00001939 case EXPR_CXX_UUIDOF_EXPR:
1940 S = new (Context) CXXUuidofExpr(Empty, true);
1941 break;
1942 case EXPR_CXX_UUIDOF_TYPE:
1943 S = new (Context) CXXUuidofExpr(Empty, false);
1944 break;
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001945 case EXPR_CXX_THIS:
Chris Lattner2fbdfcd2010-05-09 06:15:05 +00001946 S = new (Context) CXXThisExpr(Empty);
1947 break;
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001948 case EXPR_CXX_THROW:
Chris Lattner2fbdfcd2010-05-09 06:15:05 +00001949 S = new (Context) CXXThrowExpr(Empty);
1950 break;
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001951 case EXPR_CXX_DEFAULT_ARG: {
Sebastian Redl60adf4a2010-08-18 23:56:52 +00001952 bool HasOtherExprStored = Record[ASTStmtReader::NumExprFields];
Argyrios Kyrtzidis8a507332010-07-02 23:30:15 +00001953 if (HasOtherExprStored) {
1954 Expr *SubExpr = ReadSubExpr();
Douglas Gregor35942772011-09-09 21:34:22 +00001955 S = CXXDefaultArgExpr::Create(Context, SourceLocation(), 0, SubExpr);
Argyrios Kyrtzidis8a507332010-07-02 23:30:15 +00001956 } else
1957 S = new (Context) CXXDefaultArgExpr(Empty);
Chris Lattner030854b2010-05-09 06:40:08 +00001958 break;
Argyrios Kyrtzidis8a507332010-07-02 23:30:15 +00001959 }
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001960 case EXPR_CXX_BIND_TEMPORARY:
Chris Lattnerd2598362010-05-10 00:25:06 +00001961 S = new (Context) CXXBindTemporaryExpr(Empty);
1962 break;
Douglas Gregore2ca6d42010-09-02 21:50:02 +00001963
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001964 case EXPR_CXX_SCALAR_VALUE_INIT:
Douglas Gregored8abf12010-07-08 06:14:04 +00001965 S = new (Context) CXXScalarValueInitExpr(Empty);
Chris Lattner59218632010-05-10 01:22:27 +00001966 break;
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001967 case EXPR_CXX_NEW:
Chris Lattner59218632010-05-10 01:22:27 +00001968 S = new (Context) CXXNewExpr(Empty);
1969 break;
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001970 case EXPR_CXX_DELETE:
Argyrios Kyrtzidis95fc98c2010-06-22 17:07:59 +00001971 S = new (Context) CXXDeleteExpr(Empty);
1972 break;
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001973 case EXPR_CXX_PSEUDO_DESTRUCTOR:
Argyrios Kyrtzidisde4bd182010-06-28 09:32:03 +00001974 S = new (Context) CXXPseudoDestructorExpr(Empty);
1975 break;
Chris Lattner59218632010-05-10 01:22:27 +00001976
John McCall4765fa02010-12-06 08:20:24 +00001977 case EXPR_EXPR_WITH_CLEANUPS:
John McCall80ee6e82011-11-10 05:35:25 +00001978 S = ExprWithCleanups::Create(Context, Empty,
1979 Record[ASTStmtReader::NumExprFields]);
Chris Lattnerd2598362010-05-10 00:25:06 +00001980 break;
Argyrios Kyrtzidis8dfbd8b2010-06-24 08:57:31 +00001981
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001982 case EXPR_CXX_DEPENDENT_SCOPE_MEMBER:
Douglas Gregor35942772011-09-09 21:34:22 +00001983 S = CXXDependentScopeMemberExpr::CreateEmpty(Context,
Abramo Bagnarae4b92762012-01-27 09:46:47 +00001984 /*HasTemplateKWAndArgsInfo=*/Record[ASTStmtReader::NumExprFields],
Douglas Gregordef03542011-02-04 12:01:24 +00001985 /*NumTemplateArgs=*/Record[ASTStmtReader::NumExprFields]
1986 ? Record[ASTStmtReader::NumExprFields + 1]
1987 : 0);
Argyrios Kyrtzidis8dfbd8b2010-06-24 08:57:31 +00001988 break;
1989
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001990 case EXPR_CXX_DEPENDENT_SCOPE_DECL_REF:
Douglas Gregor35942772011-09-09 21:34:22 +00001991 S = DependentScopeDeclRefExpr::CreateEmpty(Context,
Abramo Bagnarae4b92762012-01-27 09:46:47 +00001992 /*HasTemplateKWAndArgsInfo=*/Record[ASTStmtReader::NumExprFields],
Douglas Gregordef03542011-02-04 12:01:24 +00001993 /*NumTemplateArgs=*/Record[ASTStmtReader::NumExprFields]
1994 ? Record[ASTStmtReader::NumExprFields + 1]
1995 : 0);
Argyrios Kyrtzidis12dffcd2010-06-28 09:31:56 +00001996 break;
1997
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001998 case EXPR_CXX_UNRESOLVED_CONSTRUCT:
Douglas Gregor35942772011-09-09 21:34:22 +00001999 S = CXXUnresolvedConstructExpr::CreateEmpty(Context,
Sebastian Redl60adf4a2010-08-18 23:56:52 +00002000 /*NumArgs=*/Record[ASTStmtReader::NumExprFields]);
Argyrios Kyrtzidisa77eb082010-06-25 09:03:26 +00002001 break;
2002
Sebastian Redl8538e8d2010-08-18 23:57:32 +00002003 case EXPR_CXX_UNRESOLVED_MEMBER:
Douglas Gregor35942772011-09-09 21:34:22 +00002004 S = UnresolvedMemberExpr::CreateEmpty(Context,
Abramo Bagnarae4b92762012-01-27 09:46:47 +00002005 /*HasTemplateKWAndArgsInfo=*/Record[ASTStmtReader::NumExprFields],
Douglas Gregordef03542011-02-04 12:01:24 +00002006 /*NumTemplateArgs=*/Record[ASTStmtReader::NumExprFields]
2007 ? Record[ASTStmtReader::NumExprFields + 1]
2008 : 0);
Argyrios Kyrtzidis8dfbd8b2010-06-24 08:57:31 +00002009 break;
Argyrios Kyrtzidisbd65bb52010-06-25 09:03:34 +00002010
Sebastian Redl8538e8d2010-08-18 23:57:32 +00002011 case EXPR_CXX_UNRESOLVED_LOOKUP:
Douglas Gregor35942772011-09-09 21:34:22 +00002012 S = UnresolvedLookupExpr::CreateEmpty(Context,
Abramo Bagnarae4b92762012-01-27 09:46:47 +00002013 /*HasTemplateKWAndArgsInfo=*/Record[ASTStmtReader::NumExprFields],
Douglas Gregordef03542011-02-04 12:01:24 +00002014 /*NumTemplateArgs=*/Record[ASTStmtReader::NumExprFields]
2015 ? Record[ASTStmtReader::NumExprFields + 1]
2016 : 0);
Argyrios Kyrtzidisbd65bb52010-06-25 09:03:34 +00002017 break;
Argyrios Kyrtzidis6d00c132010-07-10 11:46:15 +00002018
Sebastian Redl8538e8d2010-08-18 23:57:32 +00002019 case EXPR_CXX_UNARY_TYPE_TRAIT:
Argyrios Kyrtzidis6d00c132010-07-10 11:46:15 +00002020 S = new (Context) UnaryTypeTraitExpr(Empty);
2021 break;
Sebastian Redl6b219d02010-09-10 20:55:54 +00002022
Francois Pichetf1872372010-12-08 22:35:30 +00002023 case EXPR_BINARY_TYPE_TRAIT:
Francois Pichet6ad6f282010-12-07 00:08:36 +00002024 S = new (Context) BinaryTypeTraitExpr(Empty);
2025 break;
2026
John Wiegley21ff2e52011-04-28 00:16:57 +00002027 case EXPR_ARRAY_TYPE_TRAIT:
2028 S = new (Context) ArrayTypeTraitExpr(Empty);
2029 break;
2030
John Wiegley55262202011-04-25 06:54:41 +00002031 case EXPR_CXX_EXPRESSION_TRAIT:
2032 S = new (Context) ExpressionTraitExpr(Empty);
2033 break;
2034
Sebastian Redl6b219d02010-09-10 20:55:54 +00002035 case EXPR_CXX_NOEXCEPT:
2036 S = new (Context) CXXNoexceptExpr(Empty);
2037 break;
John McCall7cd7d1a2010-11-15 23:31:06 +00002038
Douglas Gregorbe230c32011-01-03 17:17:50 +00002039 case EXPR_PACK_EXPANSION:
2040 S = new (Context) PackExpansionExpr(Empty);
2041 break;
2042
Douglas Gregoree8aff02011-01-04 17:33:58 +00002043 case EXPR_SIZEOF_PACK:
2044 S = new (Context) SizeOfPackExpr(Empty);
2045 break;
2046
John McCall7110fd62011-07-15 07:00:14 +00002047 case EXPR_SUBST_NON_TYPE_TEMPLATE_PARM:
2048 S = new (Context) SubstNonTypeTemplateParmExpr(Empty);
2049 break;
2050
Douglas Gregorc7793c72011-01-15 01:15:58 +00002051 case EXPR_SUBST_NON_TYPE_TEMPLATE_PARM_PACK:
2052 S = new (Context) SubstNonTypeTemplateParmPackExpr(Empty);
2053 break;
2054
Douglas Gregor03e80032011-06-21 17:03:29 +00002055 case EXPR_MATERIALIZE_TEMPORARY:
2056 S = new (Context) MaterializeTemporaryExpr(Empty);
2057 break;
2058
Argyrios Kyrtzidis8bc27822011-12-03 03:49:52 +00002059 case EXPR_OPAQUE_VALUE:
2060 S = new (Context) OpaqueValueExpr(Empty);
John McCall7cd7d1a2010-11-15 23:31:06 +00002061 break;
Peter Collingbournee08ce652011-02-09 21:07:24 +00002062
2063 case EXPR_CUDA_KERNEL_CALL:
Douglas Gregor35942772011-09-09 21:34:22 +00002064 S = new (Context) CUDAKernelCallExpr(Context, Empty);
Peter Collingbournee08ce652011-02-09 21:07:24 +00002065 break;
Tanya Lattner61eee0c2011-06-04 00:47:47 +00002066
2067 case EXPR_ASTYPE:
2068 S = new (Context) AsTypeExpr(Empty);
2069 break;
Eli Friedman276b0612011-10-11 02:20:01 +00002070
John McCall4b9c2d22011-11-06 09:01:30 +00002071 case EXPR_PSEUDO_OBJECT: {
2072 unsigned numSemanticExprs = Record[ASTStmtReader::NumExprFields];
2073 S = PseudoObjectExpr::Create(Context, Empty, numSemanticExprs);
2074 break;
2075 }
2076
Eli Friedman276b0612011-10-11 02:20:01 +00002077 case EXPR_ATOMIC:
2078 S = new (Context) AtomicExpr(Empty);
2079 break;
Chris Lattner4c6f9522009-04-27 05:14:47 +00002080 }
Argyrios Kyrtzidis6d00c132010-07-10 11:46:15 +00002081
Chris Lattner4c6f9522009-04-27 05:14:47 +00002082 // We hit a STMT_STOP, so we're done with this expression.
2083 if (Finished)
2084 break;
2085
2086 ++NumStatementsRead;
2087
Argyrios Kyrtzidise6f08682011-10-21 23:02:28 +00002088 if (S && !IsStmtReference) {
Argyrios Kyrtzidis919e6932010-06-28 22:28:35 +00002089 Reader.Visit(S);
Argyrios Kyrtzidise6f08682011-10-21 23:02:28 +00002090 StmtEntries[Cursor.GetCurrentBitNo()] = S;
2091 }
2092
Chris Lattner4c6f9522009-04-27 05:14:47 +00002093
2094 assert(Idx == Record.size() && "Invalid deserialization of statement");
2095 StmtStack.push_back(S);
2096 }
Argyrios Kyrtzidis919e6932010-06-28 22:28:35 +00002097
2098#ifndef NDEBUG
2099 assert(StmtStack.size() > PrevNumStmts && "Read too many sub stmts!");
2100 assert(StmtStack.size() == PrevNumStmts + 1 && "Extra expressions on stack!");
2101#endif
2102
2103 return StmtStack.pop_back_val();
Chris Lattner4c6f9522009-04-27 05:14:47 +00002104}