blob: ab07b85bf4c37bbf750b69ee1abc91756456b454 [file] [log] [blame]
Sebastian Redl904c9c82010-08-18 23:57:11 +00001//===--- ASTReaderStmt.cpp - Stmt/Expr Deserialization ----------*- C++ -*-===//
Chris Lattner4c6f9522009-04-27 05:14:47 +00002//
3// The LLVM Compiler Infrastructure
4//
5// This file is distributed under the University of Illinois Open Source
6// License. See LICENSE.TXT for details.
7//
8//===----------------------------------------------------------------------===//
9//
10// Statement/expression deserialization. This implements the
Sebastian Redlc43b54c2010-08-18 23:56:43 +000011// ASTReader::ReadStmt method.
Chris Lattner4c6f9522009-04-27 05:14:47 +000012//
13//===----------------------------------------------------------------------===//
14
Sebastian Redl6ab7cd82010-08-18 23:57:17 +000015#include "clang/Serialization/ASTReader.h"
Douglas Gregor39da0b82009-09-09 23:08:42 +000016#include "clang/AST/DeclCXX.h"
Douglas Gregorc7793c72011-01-15 01:15:58 +000017#include "clang/AST/DeclTemplate.h"
Chris Lattner4c6f9522009-04-27 05:14:47 +000018#include "clang/AST/StmtVisitor.h"
19using namespace clang;
Sebastian Redl8538e8d2010-08-18 23:57:32 +000020using namespace clang::serialization;
Chris Lattner4c6f9522009-04-27 05:14:47 +000021
Argyrios Kyrtzidis37bdfe22010-06-30 08:49:18 +000022namespace clang {
Argyrios Kyrtzidis17cfded2010-06-28 09:31:42 +000023
Sebastian Redl60adf4a2010-08-18 23:56:52 +000024 class ASTStmtReader : public StmtVisitor<ASTStmtReader> {
Douglas Gregor409448c2011-07-21 22:35:25 +000025 typedef ASTReader::RecordData RecordData;
26
Sebastian Redlc43b54c2010-08-18 23:56:43 +000027 ASTReader &Reader;
Douglas Gregor72a9ae12011-07-22 16:00:58 +000028 Module &F;
Sebastian Redl577d4792010-07-22 22:43:28 +000029 llvm::BitstreamCursor &DeclsCursor;
Sebastian Redlc43b54c2010-08-18 23:56:43 +000030 const ASTReader::RecordData &Record;
Chris Lattner4c6f9522009-04-27 05:14:47 +000031 unsigned &Idx;
Chris Lattner4c6f9522009-04-27 05:14:47 +000032
Douglas Gregor409448c2011-07-21 22:35:25 +000033 SourceLocation ReadSourceLocation(const RecordData &R, unsigned &I) {
Sebastian Redlc3632732010-10-05 15:59:54 +000034 return Reader.ReadSourceLocation(F, R, I);
35 }
Douglas Gregor409448c2011-07-21 22:35:25 +000036
37 SourceRange ReadSourceRange(const RecordData &R, unsigned &I) {
Sebastian Redlc3632732010-10-05 15:59:54 +000038 return Reader.ReadSourceRange(F, R, I);
39 }
Douglas Gregor409448c2011-07-21 22:35:25 +000040
41 TypeSourceInfo *GetTypeSourceInfo(const RecordData &R, unsigned &I) {
Sebastian Redlc3632732010-10-05 15:59:54 +000042 return Reader.GetTypeSourceInfo(F, R, I);
43 }
Douglas Gregor409448c2011-07-21 22:35:25 +000044
45 serialization::DeclID ReadDeclID(const RecordData &R, unsigned &I) {
46 return Reader.ReadDeclID(F, R, I);
47 }
48
49 Decl *ReadDecl(const RecordData &R, unsigned &I) {
50 return Reader.ReadDecl(F, R, I);
51 }
52
53 template<typename T>
54 T *ReadDeclAs(const RecordData &R, unsigned &I) {
55 return Reader.ReadDeclAs<T>(F, R, I);
56 }
57
Argyrios Kyrtzidis40451072010-10-15 18:21:24 +000058 void ReadDeclarationNameLoc(DeclarationNameLoc &DNLoc, DeclarationName Name,
59 const ASTReader::RecordData &R, unsigned &I) {
60 Reader.ReadDeclarationNameLoc(F, DNLoc, Name, R, I);
61 }
Douglas Gregor409448c2011-07-21 22:35:25 +000062
Argyrios Kyrtzidis40451072010-10-15 18:21:24 +000063 void ReadDeclarationNameInfo(DeclarationNameInfo &NameInfo,
64 const ASTReader::RecordData &R, unsigned &I) {
65 Reader.ReadDeclarationNameInfo(F, NameInfo, R, I);
66 }
Sebastian Redlc3632732010-10-05 15:59:54 +000067
Chris Lattner4c6f9522009-04-27 05:14:47 +000068 public:
Douglas Gregor72a9ae12011-07-22 16:00:58 +000069 ASTStmtReader(ASTReader &Reader, Module &F,
Sebastian Redlc3632732010-10-05 15:59:54 +000070 llvm::BitstreamCursor &Cursor,
Sebastian Redlc43b54c2010-08-18 23:56:43 +000071 const ASTReader::RecordData &Record, unsigned &Idx)
Sebastian Redlc3632732010-10-05 15:59:54 +000072 : Reader(Reader), F(F), DeclsCursor(Cursor), Record(Record), Idx(Idx) { }
Chris Lattner4c6f9522009-04-27 05:14:47 +000073
74 /// \brief The number of record fields required for the Stmt class
75 /// itself.
76 static const unsigned NumStmtFields = 0;
77
78 /// \brief The number of record fields required for the Expr class
79 /// itself.
Douglas Gregor561f8122011-07-01 01:22:09 +000080 static const unsigned NumExprFields = NumStmtFields + 7;
Argyrios Kyrtzidis36c76f02010-06-28 09:31:48 +000081
82 /// \brief Read and initialize a ExplicitTemplateArgumentList structure.
Argyrios Kyrtzidisb0c3e092011-09-22 20:07:03 +000083 void ReadExplicitTemplateArgumentList(ASTTemplateArgumentListInfo &ArgList,
Argyrios Kyrtzidis919e6932010-06-28 22:28:35 +000084 unsigned NumTemplateArgs);
Chris Lattner4c6f9522009-04-27 05:14:47 +000085
Argyrios Kyrtzidis919e6932010-06-28 22:28:35 +000086 void VisitStmt(Stmt *S);
John McCall7110fd62011-07-15 07:00:14 +000087#define STMT(Type, Base) \
88 void Visit##Type(Type *);
89#include "clang/AST/StmtNodes.inc"
Chris Lattner4c6f9522009-04-27 05:14:47 +000090 };
91}
92
Sebastian Redl60adf4a2010-08-18 23:56:52 +000093void ASTStmtReader::
Argyrios Kyrtzidisb0c3e092011-09-22 20:07:03 +000094ReadExplicitTemplateArgumentList(ASTTemplateArgumentListInfo &ArgList,
Argyrios Kyrtzidis919e6932010-06-28 22:28:35 +000095 unsigned NumTemplateArgs) {
Argyrios Kyrtzidis36c76f02010-06-28 09:31:48 +000096 TemplateArgumentListInfo ArgInfo;
Sebastian Redlc3632732010-10-05 15:59:54 +000097 ArgInfo.setLAngleLoc(ReadSourceLocation(Record, Idx));
98 ArgInfo.setRAngleLoc(ReadSourceLocation(Record, Idx));
Argyrios Kyrtzidis36c76f02010-06-28 09:31:48 +000099 for (unsigned i = 0; i != NumTemplateArgs; ++i)
Sebastian Redl577d4792010-07-22 22:43:28 +0000100 ArgInfo.addArgument(
Sebastian Redlc3632732010-10-05 15:59:54 +0000101 Reader.ReadTemplateArgumentLoc(F, Record, Idx));
Argyrios Kyrtzidis36c76f02010-06-28 09:31:48 +0000102 ArgList.initializeFrom(ArgInfo);
Argyrios Kyrtzidis36c76f02010-06-28 09:31:48 +0000103}
104
Sebastian Redl60adf4a2010-08-18 23:56:52 +0000105void ASTStmtReader::VisitStmt(Stmt *S) {
Chris Lattner4c6f9522009-04-27 05:14:47 +0000106 assert(Idx == NumStmtFields && "Incorrect statement field count");
Chris Lattner4c6f9522009-04-27 05:14:47 +0000107}
108
Sebastian Redl60adf4a2010-08-18 23:56:52 +0000109void ASTStmtReader::VisitNullStmt(NullStmt *S) {
Chris Lattner4c6f9522009-04-27 05:14:47 +0000110 VisitStmt(S);
Sebastian Redlc3632732010-10-05 15:59:54 +0000111 S->setSemiLoc(ReadSourceLocation(Record, Idx));
Argyrios Kyrtzidise2ca8282011-09-01 21:53:45 +0000112 S->HasLeadingEmptyMacro = Record[Idx++];
Chris Lattner4c6f9522009-04-27 05:14:47 +0000113}
114
Sebastian Redl60adf4a2010-08-18 23:56:52 +0000115void ASTStmtReader::VisitCompoundStmt(CompoundStmt *S) {
Chris Lattner4c6f9522009-04-27 05:14:47 +0000116 VisitStmt(S);
Chris Lattner5f9e2722011-07-23 10:55:15 +0000117 SmallVector<Stmt *, 16> Stmts;
Chris Lattner4c6f9522009-04-27 05:14:47 +0000118 unsigned NumStmts = Record[Idx++];
Argyrios Kyrtzidis919e6932010-06-28 22:28:35 +0000119 while (NumStmts--)
Argyrios Kyrtzidisd98a2ab2010-06-29 22:46:25 +0000120 Stmts.push_back(Reader.ReadSubStmt());
Douglas Gregor35942772011-09-09 21:34:22 +0000121 S->setStmts(Reader.getContext(), Stmts.data(), Stmts.size());
Sebastian Redlc3632732010-10-05 15:59:54 +0000122 S->setLBracLoc(ReadSourceLocation(Record, Idx));
123 S->setRBracLoc(ReadSourceLocation(Record, Idx));
Chris Lattner4c6f9522009-04-27 05:14:47 +0000124}
125
Sebastian Redl60adf4a2010-08-18 23:56:52 +0000126void ASTStmtReader::VisitSwitchCase(SwitchCase *S) {
Chris Lattner4c6f9522009-04-27 05:14:47 +0000127 VisitStmt(S);
128 Reader.RecordSwitchCaseID(S, Record[Idx++]);
Chris Lattner4c6f9522009-04-27 05:14:47 +0000129}
130
Sebastian Redl60adf4a2010-08-18 23:56:52 +0000131void ASTStmtReader::VisitCaseStmt(CaseStmt *S) {
Chris Lattner4c6f9522009-04-27 05:14:47 +0000132 VisitSwitchCase(S);
Argyrios Kyrtzidisd98a2ab2010-06-29 22:46:25 +0000133 S->setLHS(Reader.ReadSubExpr());
134 S->setRHS(Reader.ReadSubExpr());
135 S->setSubStmt(Reader.ReadSubStmt());
Sebastian Redlc3632732010-10-05 15:59:54 +0000136 S->setCaseLoc(ReadSourceLocation(Record, Idx));
137 S->setEllipsisLoc(ReadSourceLocation(Record, Idx));
138 S->setColonLoc(ReadSourceLocation(Record, Idx));
Chris Lattner4c6f9522009-04-27 05:14:47 +0000139}
140
Sebastian Redl60adf4a2010-08-18 23:56:52 +0000141void ASTStmtReader::VisitDefaultStmt(DefaultStmt *S) {
Chris Lattner4c6f9522009-04-27 05:14:47 +0000142 VisitSwitchCase(S);
Argyrios Kyrtzidisd98a2ab2010-06-29 22:46:25 +0000143 S->setSubStmt(Reader.ReadSubStmt());
Sebastian Redlc3632732010-10-05 15:59:54 +0000144 S->setDefaultLoc(ReadSourceLocation(Record, Idx));
145 S->setColonLoc(ReadSourceLocation(Record, Idx));
Chris Lattner4c6f9522009-04-27 05:14:47 +0000146}
147
Sebastian Redl60adf4a2010-08-18 23:56:52 +0000148void ASTStmtReader::VisitLabelStmt(LabelStmt *S) {
Chris Lattner4c6f9522009-04-27 05:14:47 +0000149 VisitStmt(S);
Douglas Gregor409448c2011-07-21 22:35:25 +0000150 LabelDecl *LD = ReadDeclAs<LabelDecl>(Record, Idx);
Chris Lattnerad8dcf42011-02-17 07:39:24 +0000151 LD->setStmt(S);
152 S->setDecl(LD);
Argyrios Kyrtzidisd98a2ab2010-06-29 22:46:25 +0000153 S->setSubStmt(Reader.ReadSubStmt());
Sebastian Redlc3632732010-10-05 15:59:54 +0000154 S->setIdentLoc(ReadSourceLocation(Record, Idx));
Chris Lattner4c6f9522009-04-27 05:14:47 +0000155}
156
Sebastian Redl60adf4a2010-08-18 23:56:52 +0000157void ASTStmtReader::VisitIfStmt(IfStmt *S) {
Chris Lattner4c6f9522009-04-27 05:14:47 +0000158 VisitStmt(S);
Douglas Gregor35942772011-09-09 21:34:22 +0000159 S->setConditionVariable(Reader.getContext(),
Douglas Gregor409448c2011-07-21 22:35:25 +0000160 ReadDeclAs<VarDecl>(Record, Idx));
Argyrios Kyrtzidisd98a2ab2010-06-29 22:46:25 +0000161 S->setCond(Reader.ReadSubExpr());
162 S->setThen(Reader.ReadSubStmt());
163 S->setElse(Reader.ReadSubStmt());
Sebastian Redlc3632732010-10-05 15:59:54 +0000164 S->setIfLoc(ReadSourceLocation(Record, Idx));
165 S->setElseLoc(ReadSourceLocation(Record, Idx));
Chris Lattner4c6f9522009-04-27 05:14:47 +0000166}
167
Sebastian Redl60adf4a2010-08-18 23:56:52 +0000168void ASTStmtReader::VisitSwitchStmt(SwitchStmt *S) {
Chris Lattner4c6f9522009-04-27 05:14:47 +0000169 VisitStmt(S);
Douglas Gregor35942772011-09-09 21:34:22 +0000170 S->setConditionVariable(Reader.getContext(),
Douglas Gregor409448c2011-07-21 22:35:25 +0000171 ReadDeclAs<VarDecl>(Record, Idx));
Argyrios Kyrtzidisd98a2ab2010-06-29 22:46:25 +0000172 S->setCond(Reader.ReadSubExpr());
173 S->setBody(Reader.ReadSubStmt());
Sebastian Redlc3632732010-10-05 15:59:54 +0000174 S->setSwitchLoc(ReadSourceLocation(Record, Idx));
Ted Kremenek559fb552010-09-09 00:05:53 +0000175 if (Record[Idx++])
176 S->setAllEnumCasesCovered();
177
Chris Lattner4c6f9522009-04-27 05:14:47 +0000178 SwitchCase *PrevSC = 0;
179 for (unsigned N = Record.size(); Idx != N; ++Idx) {
180 SwitchCase *SC = Reader.getSwitchCaseWithID(Record[Idx]);
181 if (PrevSC)
182 PrevSC->setNextSwitchCase(SC);
183 else
184 S->setSwitchCaseList(SC);
Mike Stump1eb44332009-09-09 15:08:12 +0000185
Chris Lattner4c6f9522009-04-27 05:14:47 +0000186 PrevSC = SC;
187 }
Chris Lattner4c6f9522009-04-27 05:14:47 +0000188}
189
Sebastian Redl60adf4a2010-08-18 23:56:52 +0000190void ASTStmtReader::VisitWhileStmt(WhileStmt *S) {
Chris Lattner4c6f9522009-04-27 05:14:47 +0000191 VisitStmt(S);
Douglas Gregor35942772011-09-09 21:34:22 +0000192 S->setConditionVariable(Reader.getContext(),
Douglas Gregor409448c2011-07-21 22:35:25 +0000193 ReadDeclAs<VarDecl>(Record, Idx));
194
Argyrios Kyrtzidisd98a2ab2010-06-29 22:46:25 +0000195 S->setCond(Reader.ReadSubExpr());
196 S->setBody(Reader.ReadSubStmt());
Sebastian Redlc3632732010-10-05 15:59:54 +0000197 S->setWhileLoc(ReadSourceLocation(Record, Idx));
Chris Lattner4c6f9522009-04-27 05:14:47 +0000198}
199
Sebastian Redl60adf4a2010-08-18 23:56:52 +0000200void ASTStmtReader::VisitDoStmt(DoStmt *S) {
Chris Lattner4c6f9522009-04-27 05:14:47 +0000201 VisitStmt(S);
Argyrios Kyrtzidisd98a2ab2010-06-29 22:46:25 +0000202 S->setCond(Reader.ReadSubExpr());
203 S->setBody(Reader.ReadSubStmt());
Sebastian Redlc3632732010-10-05 15:59:54 +0000204 S->setDoLoc(ReadSourceLocation(Record, Idx));
205 S->setWhileLoc(ReadSourceLocation(Record, Idx));
206 S->setRParenLoc(ReadSourceLocation(Record, Idx));
Chris Lattner4c6f9522009-04-27 05:14:47 +0000207}
208
Sebastian Redl60adf4a2010-08-18 23:56:52 +0000209void ASTStmtReader::VisitForStmt(ForStmt *S) {
Chris Lattner4c6f9522009-04-27 05:14:47 +0000210 VisitStmt(S);
Argyrios Kyrtzidisd98a2ab2010-06-29 22:46:25 +0000211 S->setInit(Reader.ReadSubStmt());
212 S->setCond(Reader.ReadSubExpr());
Douglas Gregor35942772011-09-09 21:34:22 +0000213 S->setConditionVariable(Reader.getContext(),
Douglas Gregor409448c2011-07-21 22:35:25 +0000214 ReadDeclAs<VarDecl>(Record, Idx));
Argyrios Kyrtzidisd98a2ab2010-06-29 22:46:25 +0000215 S->setInc(Reader.ReadSubExpr());
216 S->setBody(Reader.ReadSubStmt());
Sebastian Redlc3632732010-10-05 15:59:54 +0000217 S->setForLoc(ReadSourceLocation(Record, Idx));
218 S->setLParenLoc(ReadSourceLocation(Record, Idx));
219 S->setRParenLoc(ReadSourceLocation(Record, Idx));
Chris Lattner4c6f9522009-04-27 05:14:47 +0000220}
221
Sebastian Redl60adf4a2010-08-18 23:56:52 +0000222void ASTStmtReader::VisitGotoStmt(GotoStmt *S) {
Chris Lattner4c6f9522009-04-27 05:14:47 +0000223 VisitStmt(S);
Douglas Gregor409448c2011-07-21 22:35:25 +0000224 S->setLabel(ReadDeclAs<LabelDecl>(Record, Idx));
Sebastian Redlc3632732010-10-05 15:59:54 +0000225 S->setGotoLoc(ReadSourceLocation(Record, Idx));
226 S->setLabelLoc(ReadSourceLocation(Record, Idx));
Chris Lattner4c6f9522009-04-27 05:14:47 +0000227}
228
Sebastian Redl60adf4a2010-08-18 23:56:52 +0000229void ASTStmtReader::VisitIndirectGotoStmt(IndirectGotoStmt *S) {
Chris Lattner4c6f9522009-04-27 05:14:47 +0000230 VisitStmt(S);
Sebastian Redlc3632732010-10-05 15:59:54 +0000231 S->setGotoLoc(ReadSourceLocation(Record, Idx));
232 S->setStarLoc(ReadSourceLocation(Record, Idx));
Argyrios Kyrtzidisd98a2ab2010-06-29 22:46:25 +0000233 S->setTarget(Reader.ReadSubExpr());
Chris Lattner4c6f9522009-04-27 05:14:47 +0000234}
235
Sebastian Redl60adf4a2010-08-18 23:56:52 +0000236void ASTStmtReader::VisitContinueStmt(ContinueStmt *S) {
Chris Lattner4c6f9522009-04-27 05:14:47 +0000237 VisitStmt(S);
Sebastian Redlc3632732010-10-05 15:59:54 +0000238 S->setContinueLoc(ReadSourceLocation(Record, Idx));
Chris Lattner4c6f9522009-04-27 05:14:47 +0000239}
240
Sebastian Redl60adf4a2010-08-18 23:56:52 +0000241void ASTStmtReader::VisitBreakStmt(BreakStmt *S) {
Chris Lattner4c6f9522009-04-27 05:14:47 +0000242 VisitStmt(S);
Sebastian Redlc3632732010-10-05 15:59:54 +0000243 S->setBreakLoc(ReadSourceLocation(Record, Idx));
Chris Lattner4c6f9522009-04-27 05:14:47 +0000244}
245
Sebastian Redl60adf4a2010-08-18 23:56:52 +0000246void ASTStmtReader::VisitReturnStmt(ReturnStmt *S) {
Chris Lattner4c6f9522009-04-27 05:14:47 +0000247 VisitStmt(S);
Argyrios Kyrtzidisd98a2ab2010-06-29 22:46:25 +0000248 S->setRetValue(Reader.ReadSubExpr());
Sebastian Redlc3632732010-10-05 15:59:54 +0000249 S->setReturnLoc(ReadSourceLocation(Record, Idx));
Douglas Gregor409448c2011-07-21 22:35:25 +0000250 S->setNRVOCandidate(ReadDeclAs<VarDecl>(Record, Idx));
Chris Lattner4c6f9522009-04-27 05:14:47 +0000251}
252
Sebastian Redl60adf4a2010-08-18 23:56:52 +0000253void ASTStmtReader::VisitDeclStmt(DeclStmt *S) {
Chris Lattner4c6f9522009-04-27 05:14:47 +0000254 VisitStmt(S);
Sebastian Redlc3632732010-10-05 15:59:54 +0000255 S->setStartLoc(ReadSourceLocation(Record, Idx));
256 S->setEndLoc(ReadSourceLocation(Record, Idx));
Chris Lattner4c6f9522009-04-27 05:14:47 +0000257
258 if (Idx + 1 == Record.size()) {
259 // Single declaration
Douglas Gregor409448c2011-07-21 22:35:25 +0000260 S->setDeclGroup(DeclGroupRef(ReadDecl(Record, Idx)));
Chris Lattner4c6f9522009-04-27 05:14:47 +0000261 } else {
Chris Lattner5f9e2722011-07-23 10:55:15 +0000262 SmallVector<Decl *, 16> Decls;
Douglas Gregor409448c2011-07-21 22:35:25 +0000263 Decls.reserve(Record.size() - Idx);
264 for (unsigned N = Record.size(); Idx != N; )
265 Decls.push_back(ReadDecl(Record, Idx));
Douglas Gregor35942772011-09-09 21:34:22 +0000266 S->setDeclGroup(DeclGroupRef(DeclGroup::Create(Reader.getContext(),
Douglas Gregor75fdb232009-05-22 22:45:36 +0000267 Decls.data(),
268 Decls.size())));
Chris Lattner4c6f9522009-04-27 05:14:47 +0000269 }
Chris Lattner4c6f9522009-04-27 05:14:47 +0000270}
271
Sebastian Redl60adf4a2010-08-18 23:56:52 +0000272void ASTStmtReader::VisitAsmStmt(AsmStmt *S) {
Chris Lattner4c6f9522009-04-27 05:14:47 +0000273 VisitStmt(S);
274 unsigned NumOutputs = Record[Idx++];
275 unsigned NumInputs = Record[Idx++];
276 unsigned NumClobbers = Record[Idx++];
Sebastian Redlc3632732010-10-05 15:59:54 +0000277 S->setAsmLoc(ReadSourceLocation(Record, Idx));
278 S->setRParenLoc(ReadSourceLocation(Record, Idx));
Chris Lattner4c6f9522009-04-27 05:14:47 +0000279 S->setVolatile(Record[Idx++]);
280 S->setSimple(Record[Idx++]);
Mike Stump3b11fd32010-01-04 22:37:17 +0000281 S->setMSAsm(Record[Idx++]);
Mike Stump1eb44332009-09-09 15:08:12 +0000282
Argyrios Kyrtzidisd98a2ab2010-06-29 22:46:25 +0000283 S->setAsmString(cast_or_null<StringLiteral>(Reader.ReadSubStmt()));
Chris Lattner4c6f9522009-04-27 05:14:47 +0000284
285 // Outputs and inputs
Chris Lattner5f9e2722011-07-23 10:55:15 +0000286 SmallVector<IdentifierInfo *, 16> Names;
287 SmallVector<StringLiteral*, 16> Constraints;
288 SmallVector<Stmt*, 16> Exprs;
Chris Lattner4c6f9522009-04-27 05:14:47 +0000289 for (unsigned I = 0, N = NumOutputs + NumInputs; I != N; ++I) {
Douglas Gregor95eab172011-07-28 20:55:49 +0000290 Names.push_back(Reader.GetIdentifierInfo(F, Record, Idx));
Argyrios Kyrtzidisd98a2ab2010-06-29 22:46:25 +0000291 Constraints.push_back(cast_or_null<StringLiteral>(Reader.ReadSubStmt()));
292 Exprs.push_back(Reader.ReadSubStmt());
Chris Lattner4c6f9522009-04-27 05:14:47 +0000293 }
Chris Lattner4c6f9522009-04-27 05:14:47 +0000294
295 // Constraints
Chris Lattner5f9e2722011-07-23 10:55:15 +0000296 SmallVector<StringLiteral*, 16> Clobbers;
Chris Lattner4c6f9522009-04-27 05:14:47 +0000297 for (unsigned I = 0; I != NumClobbers; ++I)
Argyrios Kyrtzidisd98a2ab2010-06-29 22:46:25 +0000298 Clobbers.push_back(cast_or_null<StringLiteral>(Reader.ReadSubStmt()));
Anders Carlssonfdba9c02010-01-30 19:34:25 +0000299
Douglas Gregor35942772011-09-09 21:34:22 +0000300 S->setOutputsAndInputsAndClobbers(Reader.getContext(),
Anders Carlssonacb6bcb2010-01-30 20:38:10 +0000301 Names.data(), Constraints.data(),
Anders Carlssonfdba9c02010-01-30 19:34:25 +0000302 Exprs.data(), NumOutputs, NumInputs,
303 Clobbers.data(), NumClobbers);
Chris Lattner4c6f9522009-04-27 05:14:47 +0000304}
305
Sebastian Redl60adf4a2010-08-18 23:56:52 +0000306void ASTStmtReader::VisitExpr(Expr *E) {
Chris Lattner4c6f9522009-04-27 05:14:47 +0000307 VisitStmt(E);
Douglas Gregor393f2492011-07-22 00:38:23 +0000308 E->setType(Reader.readType(F, Record, Idx));
Chris Lattner4c6f9522009-04-27 05:14:47 +0000309 E->setTypeDependent(Record[Idx++]);
310 E->setValueDependent(Record[Idx++]);
Douglas Gregor561f8122011-07-01 01:22:09 +0000311 E->setInstantiationDependent(Record[Idx++]);
Douglas Gregord0937222010-12-13 22:49:22 +0000312 E->ExprBits.ContainsUnexpandedParameterPack = Record[Idx++];
John McCallf89e55a2010-11-18 06:31:45 +0000313 E->setValueKind(static_cast<ExprValueKind>(Record[Idx++]));
314 E->setObjectKind(static_cast<ExprObjectKind>(Record[Idx++]));
Chris Lattner4c6f9522009-04-27 05:14:47 +0000315 assert(Idx == NumExprFields && "Incorrect expression field count");
Chris Lattner4c6f9522009-04-27 05:14:47 +0000316}
317
Sebastian Redl60adf4a2010-08-18 23:56:52 +0000318void ASTStmtReader::VisitPredefinedExpr(PredefinedExpr *E) {
Chris Lattner4c6f9522009-04-27 05:14:47 +0000319 VisitExpr(E);
Sebastian Redlc3632732010-10-05 15:59:54 +0000320 E->setLocation(ReadSourceLocation(Record, Idx));
Chris Lattner4c6f9522009-04-27 05:14:47 +0000321 E->setIdentType((PredefinedExpr::IdentType)Record[Idx++]);
Chris Lattner4c6f9522009-04-27 05:14:47 +0000322}
323
Sebastian Redl60adf4a2010-08-18 23:56:52 +0000324void ASTStmtReader::VisitDeclRefExpr(DeclRefExpr *E) {
Chris Lattner4c6f9522009-04-27 05:14:47 +0000325 VisitExpr(E);
Argyrios Kyrtzidis663e3802010-07-08 13:09:47 +0000326
Chandler Carruthcb66cff2011-05-01 21:29:53 +0000327 E->DeclRefExprBits.HasQualifier = Record[Idx++];
Chandler Carruth3aa81402011-05-01 23:48:14 +0000328 E->DeclRefExprBits.HasFoundDecl = Record[Idx++];
Chandler Carruthcb66cff2011-05-01 21:29:53 +0000329 E->DeclRefExprBits.HasExplicitTemplateArgs = Record[Idx++];
Abramo Bagnara7cc58b42011-10-05 07:56:41 +0000330 E->DeclRefExprBits.HadMultipleCandidates = Record[Idx++];
Anders Carlssonb0ca1372011-03-06 18:19:42 +0000331 unsigned NumTemplateArgs = 0;
Chandler Carruthcb66cff2011-05-01 21:29:53 +0000332 if (E->hasExplicitTemplateArgs())
Anders Carlssonb0ca1372011-03-06 18:19:42 +0000333 NumTemplateArgs = Record[Idx++];
334
Chandler Carruthcb66cff2011-05-01 21:29:53 +0000335 if (E->hasQualifier())
Chandler Carruth6857c3e2011-05-01 22:14:37 +0000336 E->getInternalQualifierLoc()
Douglas Gregor40d96a62011-02-28 21:54:11 +0000337 = Reader.ReadNestedNameSpecifierLoc(F, Record, Idx);
Argyrios Kyrtzidis663e3802010-07-08 13:09:47 +0000338
Chandler Carruth3aa81402011-05-01 23:48:14 +0000339 if (E->hasFoundDecl())
Douglas Gregor409448c2011-07-21 22:35:25 +0000340 E->getInternalFoundDecl() = ReadDeclAs<NamedDecl>(Record, Idx);
Chandler Carruth3aa81402011-05-01 23:48:14 +0000341
Chandler Carruthcb66cff2011-05-01 21:29:53 +0000342 if (E->hasExplicitTemplateArgs())
John McCall096832c2010-08-19 23:49:38 +0000343 ReadExplicitTemplateArgumentList(E->getExplicitTemplateArgs(),
Argyrios Kyrtzidis663e3802010-07-08 13:09:47 +0000344 NumTemplateArgs);
345
Douglas Gregor409448c2011-07-21 22:35:25 +0000346 E->setDecl(ReadDeclAs<ValueDecl>(Record, Idx));
Sebastian Redlc3632732010-10-05 15:59:54 +0000347 E->setLocation(ReadSourceLocation(Record, Idx));
Argyrios Kyrtzidis40451072010-10-15 18:21:24 +0000348 ReadDeclarationNameLoc(E->DNLoc, E->getDecl()->getDeclName(), Record, Idx);
Chris Lattner4c6f9522009-04-27 05:14:47 +0000349}
350
Sebastian Redl60adf4a2010-08-18 23:56:52 +0000351void ASTStmtReader::VisitIntegerLiteral(IntegerLiteral *E) {
Chris Lattner4c6f9522009-04-27 05:14:47 +0000352 VisitExpr(E);
Sebastian Redlc3632732010-10-05 15:59:54 +0000353 E->setLocation(ReadSourceLocation(Record, Idx));
Douglas Gregor35942772011-09-09 21:34:22 +0000354 E->setValue(Reader.getContext(), Reader.ReadAPInt(Record, Idx));
Chris Lattner4c6f9522009-04-27 05:14:47 +0000355}
356
Sebastian Redl60adf4a2010-08-18 23:56:52 +0000357void ASTStmtReader::VisitFloatingLiteral(FloatingLiteral *E) {
Chris Lattner4c6f9522009-04-27 05:14:47 +0000358 VisitExpr(E);
Douglas Gregor35942772011-09-09 21:34:22 +0000359 E->setValue(Reader.getContext(), Reader.ReadAPFloat(Record, Idx));
Chris Lattner4c6f9522009-04-27 05:14:47 +0000360 E->setExact(Record[Idx++]);
Sebastian Redlc3632732010-10-05 15:59:54 +0000361 E->setLocation(ReadSourceLocation(Record, Idx));
Chris Lattner4c6f9522009-04-27 05:14:47 +0000362}
363
Sebastian Redl60adf4a2010-08-18 23:56:52 +0000364void ASTStmtReader::VisitImaginaryLiteral(ImaginaryLiteral *E) {
Chris Lattner4c6f9522009-04-27 05:14:47 +0000365 VisitExpr(E);
Argyrios Kyrtzidisd98a2ab2010-06-29 22:46:25 +0000366 E->setSubExpr(Reader.ReadSubExpr());
Chris Lattner4c6f9522009-04-27 05:14:47 +0000367}
368
Sebastian Redl60adf4a2010-08-18 23:56:52 +0000369void ASTStmtReader::VisitStringLiteral(StringLiteral *E) {
Chris Lattner4c6f9522009-04-27 05:14:47 +0000370 VisitExpr(E);
371 unsigned Len = Record[Idx++];
Mike Stump1eb44332009-09-09 15:08:12 +0000372 assert(Record[Idx] == E->getNumConcatenated() &&
Chris Lattner4c6f9522009-04-27 05:14:47 +0000373 "Wrong number of concatenated tokens!");
374 ++Idx;
Douglas Gregor5cee1192011-07-27 05:40:30 +0000375 E->Kind = static_cast<StringLiteral::StringKind>(Record[Idx++]);
Anders Carlsson3e2193c2011-04-14 00:40:03 +0000376 E->IsPascal = Record[Idx++];
Chris Lattner4c6f9522009-04-27 05:14:47 +0000377
Mike Stump1eb44332009-09-09 15:08:12 +0000378 // Read string data
Daniel Dunbarb6480232009-09-22 03:27:33 +0000379 llvm::SmallString<16> Str(&Record[Idx], &Record[Idx] + Len);
Douglas Gregor35942772011-09-09 21:34:22 +0000380 E->setString(Reader.getContext(), Str.str());
Chris Lattner4c6f9522009-04-27 05:14:47 +0000381 Idx += Len;
382
383 // Read source locations
384 for (unsigned I = 0, N = E->getNumConcatenated(); I != N; ++I)
Sebastian Redlc3632732010-10-05 15:59:54 +0000385 E->setStrTokenLoc(I, ReadSourceLocation(Record, Idx));
Chris Lattner4c6f9522009-04-27 05:14:47 +0000386}
387
Sebastian Redl60adf4a2010-08-18 23:56:52 +0000388void ASTStmtReader::VisitCharacterLiteral(CharacterLiteral *E) {
Chris Lattner4c6f9522009-04-27 05:14:47 +0000389 VisitExpr(E);
390 E->setValue(Record[Idx++]);
Sebastian Redlc3632732010-10-05 15:59:54 +0000391 E->setLocation(ReadSourceLocation(Record, Idx));
Douglas Gregor5cee1192011-07-27 05:40:30 +0000392 E->setKind(static_cast<CharacterLiteral::CharacterKind>(Record[Idx++]));
Chris Lattner4c6f9522009-04-27 05:14:47 +0000393}
394
Sebastian Redl60adf4a2010-08-18 23:56:52 +0000395void ASTStmtReader::VisitParenExpr(ParenExpr *E) {
Chris Lattner4c6f9522009-04-27 05:14:47 +0000396 VisitExpr(E);
Sebastian Redlc3632732010-10-05 15:59:54 +0000397 E->setLParen(ReadSourceLocation(Record, Idx));
398 E->setRParen(ReadSourceLocation(Record, Idx));
Argyrios Kyrtzidisd98a2ab2010-06-29 22:46:25 +0000399 E->setSubExpr(Reader.ReadSubExpr());
Chris Lattner4c6f9522009-04-27 05:14:47 +0000400}
401
Sebastian Redl60adf4a2010-08-18 23:56:52 +0000402void ASTStmtReader::VisitParenListExpr(ParenListExpr *E) {
Argyrios Kyrtzidis37bdfe22010-06-30 08:49:18 +0000403 VisitExpr(E);
404 unsigned NumExprs = Record[Idx++];
Douglas Gregor35942772011-09-09 21:34:22 +0000405 E->Exprs = new (Reader.getContext()) Stmt*[NumExprs];
Argyrios Kyrtzidis37bdfe22010-06-30 08:49:18 +0000406 for (unsigned i = 0; i != NumExprs; ++i)
407 E->Exprs[i] = Reader.ReadSubStmt();
408 E->NumExprs = NumExprs;
Sebastian Redlc3632732010-10-05 15:59:54 +0000409 E->LParenLoc = ReadSourceLocation(Record, Idx);
410 E->RParenLoc = ReadSourceLocation(Record, Idx);
Argyrios Kyrtzidis37bdfe22010-06-30 08:49:18 +0000411}
412
Sebastian Redl60adf4a2010-08-18 23:56:52 +0000413void ASTStmtReader::VisitUnaryOperator(UnaryOperator *E) {
Chris Lattner4c6f9522009-04-27 05:14:47 +0000414 VisitExpr(E);
Argyrios Kyrtzidisd98a2ab2010-06-29 22:46:25 +0000415 E->setSubExpr(Reader.ReadSubExpr());
Chris Lattner4c6f9522009-04-27 05:14:47 +0000416 E->setOpcode((UnaryOperator::Opcode)Record[Idx++]);
Sebastian Redlc3632732010-10-05 15:59:54 +0000417 E->setOperatorLoc(ReadSourceLocation(Record, Idx));
Chris Lattner4c6f9522009-04-27 05:14:47 +0000418}
419
Sebastian Redl60adf4a2010-08-18 23:56:52 +0000420void ASTStmtReader::VisitOffsetOfExpr(OffsetOfExpr *E) {
Douglas Gregor8ecdb652010-04-28 22:16:22 +0000421 typedef OffsetOfExpr::OffsetOfNode Node;
422 VisitExpr(E);
423 assert(E->getNumComponents() == Record[Idx]);
424 ++Idx;
425 assert(E->getNumExpressions() == Record[Idx]);
426 ++Idx;
Sebastian Redlc3632732010-10-05 15:59:54 +0000427 E->setOperatorLoc(ReadSourceLocation(Record, Idx));
428 E->setRParenLoc(ReadSourceLocation(Record, Idx));
429 E->setTypeSourceInfo(GetTypeSourceInfo(Record, Idx));
Douglas Gregor8ecdb652010-04-28 22:16:22 +0000430 for (unsigned I = 0, N = E->getNumComponents(); I != N; ++I) {
431 Node::Kind Kind = static_cast<Node::Kind>(Record[Idx++]);
Sebastian Redlc3632732010-10-05 15:59:54 +0000432 SourceLocation Start = ReadSourceLocation(Record, Idx);
433 SourceLocation End = ReadSourceLocation(Record, Idx);
Douglas Gregor8ecdb652010-04-28 22:16:22 +0000434 switch (Kind) {
435 case Node::Array:
436 E->setComponent(I, Node(Start, Record[Idx++], End));
437 break;
438
439 case Node::Field:
Douglas Gregor409448c2011-07-21 22:35:25 +0000440 E->setComponent(I, Node(Start, ReadDeclAs<FieldDecl>(Record, Idx), End));
Douglas Gregor8ecdb652010-04-28 22:16:22 +0000441 break;
442
443 case Node::Identifier:
Douglas Gregor95eab172011-07-28 20:55:49 +0000444 E->setComponent(I,
445 Node(Start,
446 Reader.GetIdentifierInfo(F, Record, Idx),
447 End));
Douglas Gregor8ecdb652010-04-28 22:16:22 +0000448 break;
Douglas Gregorcc8a5d52010-04-29 00:18:15 +0000449
Argyrios Kyrtzidisafbf3122010-07-29 18:16:10 +0000450 case Node::Base: {
Douglas Gregor35942772011-09-09 21:34:22 +0000451 CXXBaseSpecifier *Base = new (Reader.getContext()) CXXBaseSpecifier();
Sebastian Redlc3632732010-10-05 15:59:54 +0000452 *Base = Reader.ReadCXXBaseSpecifier(F, Record, Idx);
Argyrios Kyrtzidisafbf3122010-07-29 18:16:10 +0000453 E->setComponent(I, Node(Base));
Douglas Gregorcc8a5d52010-04-29 00:18:15 +0000454 break;
Douglas Gregor8ecdb652010-04-28 22:16:22 +0000455 }
Argyrios Kyrtzidisafbf3122010-07-29 18:16:10 +0000456 }
Douglas Gregor8ecdb652010-04-28 22:16:22 +0000457 }
458
459 for (unsigned I = 0, N = E->getNumExpressions(); I != N; ++I)
Argyrios Kyrtzidisd98a2ab2010-06-29 22:46:25 +0000460 E->setIndexExpr(I, Reader.ReadSubExpr());
Douglas Gregor8ecdb652010-04-28 22:16:22 +0000461}
462
Peter Collingbournef4e3cfb2011-03-11 19:24:49 +0000463void ASTStmtReader::VisitUnaryExprOrTypeTraitExpr(UnaryExprOrTypeTraitExpr *E) {
Chris Lattner4c6f9522009-04-27 05:14:47 +0000464 VisitExpr(E);
Peter Collingbournef4e3cfb2011-03-11 19:24:49 +0000465 E->setKind(static_cast<UnaryExprOrTypeTrait>(Record[Idx++]));
Chris Lattner4c6f9522009-04-27 05:14:47 +0000466 if (Record[Idx] == 0) {
Argyrios Kyrtzidisd98a2ab2010-06-29 22:46:25 +0000467 E->setArgument(Reader.ReadSubExpr());
Chris Lattner4c6f9522009-04-27 05:14:47 +0000468 ++Idx;
469 } else {
Sebastian Redlc3632732010-10-05 15:59:54 +0000470 E->setArgument(GetTypeSourceInfo(Record, Idx));
Chris Lattner4c6f9522009-04-27 05:14:47 +0000471 }
Sebastian Redlc3632732010-10-05 15:59:54 +0000472 E->setOperatorLoc(ReadSourceLocation(Record, Idx));
473 E->setRParenLoc(ReadSourceLocation(Record, Idx));
Chris Lattner4c6f9522009-04-27 05:14:47 +0000474}
475
Sebastian Redl60adf4a2010-08-18 23:56:52 +0000476void ASTStmtReader::VisitArraySubscriptExpr(ArraySubscriptExpr *E) {
Chris Lattner4c6f9522009-04-27 05:14:47 +0000477 VisitExpr(E);
Argyrios Kyrtzidisd98a2ab2010-06-29 22:46:25 +0000478 E->setLHS(Reader.ReadSubExpr());
479 E->setRHS(Reader.ReadSubExpr());
Sebastian Redlc3632732010-10-05 15:59:54 +0000480 E->setRBracketLoc(ReadSourceLocation(Record, Idx));
Chris Lattner4c6f9522009-04-27 05:14:47 +0000481}
482
Sebastian Redl60adf4a2010-08-18 23:56:52 +0000483void ASTStmtReader::VisitCallExpr(CallExpr *E) {
Chris Lattner4c6f9522009-04-27 05:14:47 +0000484 VisitExpr(E);
Douglas Gregor35942772011-09-09 21:34:22 +0000485 E->setNumArgs(Reader.getContext(), Record[Idx++]);
Sebastian Redlc3632732010-10-05 15:59:54 +0000486 E->setRParenLoc(ReadSourceLocation(Record, Idx));
Argyrios Kyrtzidisd98a2ab2010-06-29 22:46:25 +0000487 E->setCallee(Reader.ReadSubExpr());
Chris Lattner4c6f9522009-04-27 05:14:47 +0000488 for (unsigned I = 0, N = E->getNumArgs(); I != N; ++I)
Argyrios Kyrtzidisd98a2ab2010-06-29 22:46:25 +0000489 E->setArg(I, Reader.ReadSubExpr());
Chris Lattner4c6f9522009-04-27 05:14:47 +0000490}
491
John McCall7110fd62011-07-15 07:00:14 +0000492void ASTStmtReader::VisitCXXMemberCallExpr(CXXMemberCallExpr *E) {
493 VisitCallExpr(E);
494}
495
Sebastian Redl60adf4a2010-08-18 23:56:52 +0000496void ASTStmtReader::VisitMemberExpr(MemberExpr *E) {
Argyrios Kyrtzidis663e3802010-07-08 13:09:47 +0000497 // Don't call VisitExpr, this is fully initialized at creation.
498 assert(E->getStmtClass() == Stmt::MemberExprClass &&
499 "It's a subclass, we must advance Idx!");
Chris Lattner4c6f9522009-04-27 05:14:47 +0000500}
501
Sebastian Redl60adf4a2010-08-18 23:56:52 +0000502void ASTStmtReader::VisitObjCIsaExpr(ObjCIsaExpr *E) {
Steve Narofff242b1b2009-07-24 17:54:45 +0000503 VisitExpr(E);
Argyrios Kyrtzidisd98a2ab2010-06-29 22:46:25 +0000504 E->setBase(Reader.ReadSubExpr());
Sebastian Redlc3632732010-10-05 15:59:54 +0000505 E->setIsaMemberLoc(ReadSourceLocation(Record, Idx));
Steve Narofff242b1b2009-07-24 17:54:45 +0000506 E->setArrow(Record[Idx++]);
Steve Narofff242b1b2009-07-24 17:54:45 +0000507}
508
John McCallf85e1932011-06-15 23:02:42 +0000509void ASTStmtReader::
510VisitObjCIndirectCopyRestoreExpr(ObjCIndirectCopyRestoreExpr *E) {
511 VisitExpr(E);
512 E->Operand = Reader.ReadSubExpr();
513 E->setShouldCopy(Record[Idx++]);
514}
515
516void ASTStmtReader::VisitObjCBridgedCastExpr(ObjCBridgedCastExpr *E) {
517 VisitExplicitCastExpr(E);
518 E->LParenLoc = ReadSourceLocation(Record, Idx);
519 E->BridgeKeywordLoc = ReadSourceLocation(Record, Idx);
520 E->Kind = Record[Idx++];
521}
522
Sebastian Redl60adf4a2010-08-18 23:56:52 +0000523void ASTStmtReader::VisitCastExpr(CastExpr *E) {
Chris Lattner4c6f9522009-04-27 05:14:47 +0000524 VisitExpr(E);
John McCallf871d0c2010-08-07 06:22:56 +0000525 unsigned NumBaseSpecs = Record[Idx++];
526 assert(NumBaseSpecs == E->path_size());
Argyrios Kyrtzidisd98a2ab2010-06-29 22:46:25 +0000527 E->setSubExpr(Reader.ReadSubExpr());
Anders Carlssoncdef2b72009-07-31 00:48:10 +0000528 E->setCastKind((CastExpr::CastKind)Record[Idx++]);
John McCallf871d0c2010-08-07 06:22:56 +0000529 CastExpr::path_iterator BaseI = E->path_begin();
Argyrios Kyrtzidis0745d0a2010-07-02 23:30:27 +0000530 while (NumBaseSpecs--) {
Douglas Gregor35942772011-09-09 21:34:22 +0000531 CXXBaseSpecifier *BaseSpec = new (Reader.getContext()) CXXBaseSpecifier;
Sebastian Redlc3632732010-10-05 15:59:54 +0000532 *BaseSpec = Reader.ReadCXXBaseSpecifier(F, Record, Idx);
John McCallf871d0c2010-08-07 06:22:56 +0000533 *BaseI++ = BaseSpec;
Argyrios Kyrtzidis0745d0a2010-07-02 23:30:27 +0000534 }
Chris Lattner4c6f9522009-04-27 05:14:47 +0000535}
536
Sebastian Redl60adf4a2010-08-18 23:56:52 +0000537void ASTStmtReader::VisitBinaryOperator(BinaryOperator *E) {
Chris Lattner4c6f9522009-04-27 05:14:47 +0000538 VisitExpr(E);
Argyrios Kyrtzidisd98a2ab2010-06-29 22:46:25 +0000539 E->setLHS(Reader.ReadSubExpr());
540 E->setRHS(Reader.ReadSubExpr());
Chris Lattner4c6f9522009-04-27 05:14:47 +0000541 E->setOpcode((BinaryOperator::Opcode)Record[Idx++]);
Sebastian Redlc3632732010-10-05 15:59:54 +0000542 E->setOperatorLoc(ReadSourceLocation(Record, Idx));
Chris Lattner4c6f9522009-04-27 05:14:47 +0000543}
544
Sebastian Redl60adf4a2010-08-18 23:56:52 +0000545void ASTStmtReader::VisitCompoundAssignOperator(CompoundAssignOperator *E) {
Chris Lattner4c6f9522009-04-27 05:14:47 +0000546 VisitBinaryOperator(E);
Douglas Gregor393f2492011-07-22 00:38:23 +0000547 E->setComputationLHSType(Reader.readType(F, Record, Idx));
548 E->setComputationResultType(Reader.readType(F, Record, Idx));
Chris Lattner4c6f9522009-04-27 05:14:47 +0000549}
550
Sebastian Redl60adf4a2010-08-18 23:56:52 +0000551void ASTStmtReader::VisitConditionalOperator(ConditionalOperator *E) {
Chris Lattner4c6f9522009-04-27 05:14:47 +0000552 VisitExpr(E);
John McCall56ca35d2011-02-17 10:25:35 +0000553 E->SubExprs[ConditionalOperator::COND] = Reader.ReadSubExpr();
554 E->SubExprs[ConditionalOperator::LHS] = Reader.ReadSubExpr();
555 E->SubExprs[ConditionalOperator::RHS] = Reader.ReadSubExpr();
556 E->QuestionLoc = ReadSourceLocation(Record, Idx);
557 E->ColonLoc = ReadSourceLocation(Record, Idx);
558}
559
560void
561ASTStmtReader::VisitBinaryConditionalOperator(BinaryConditionalOperator *E) {
562 VisitExpr(E);
563 E->OpaqueValue = cast<OpaqueValueExpr>(Reader.ReadSubExpr());
564 E->SubExprs[BinaryConditionalOperator::COMMON] = Reader.ReadSubExpr();
565 E->SubExprs[BinaryConditionalOperator::COND] = Reader.ReadSubExpr();
566 E->SubExprs[BinaryConditionalOperator::LHS] = Reader.ReadSubExpr();
567 E->SubExprs[BinaryConditionalOperator::RHS] = Reader.ReadSubExpr();
568 E->QuestionLoc = ReadSourceLocation(Record, Idx);
569 E->ColonLoc = ReadSourceLocation(Record, Idx);
570
571 E->getOpaqueValue()->setSourceExpr(E->getCommon());
Chris Lattner4c6f9522009-04-27 05:14:47 +0000572}
573
Sebastian Redl60adf4a2010-08-18 23:56:52 +0000574void ASTStmtReader::VisitImplicitCastExpr(ImplicitCastExpr *E) {
Chris Lattner4c6f9522009-04-27 05:14:47 +0000575 VisitCastExpr(E);
Chris Lattner4c6f9522009-04-27 05:14:47 +0000576}
577
Sebastian Redl60adf4a2010-08-18 23:56:52 +0000578void ASTStmtReader::VisitExplicitCastExpr(ExplicitCastExpr *E) {
Chris Lattner4c6f9522009-04-27 05:14:47 +0000579 VisitCastExpr(E);
Sebastian Redlc3632732010-10-05 15:59:54 +0000580 E->setTypeInfoAsWritten(GetTypeSourceInfo(Record, Idx));
Chris Lattner4c6f9522009-04-27 05:14:47 +0000581}
582
Sebastian Redl60adf4a2010-08-18 23:56:52 +0000583void ASTStmtReader::VisitCStyleCastExpr(CStyleCastExpr *E) {
Chris Lattner4c6f9522009-04-27 05:14:47 +0000584 VisitExplicitCastExpr(E);
Sebastian Redlc3632732010-10-05 15:59:54 +0000585 E->setLParenLoc(ReadSourceLocation(Record, Idx));
586 E->setRParenLoc(ReadSourceLocation(Record, Idx));
Chris Lattner4c6f9522009-04-27 05:14:47 +0000587}
588
Sebastian Redl60adf4a2010-08-18 23:56:52 +0000589void ASTStmtReader::VisitCompoundLiteralExpr(CompoundLiteralExpr *E) {
Chris Lattner4c6f9522009-04-27 05:14:47 +0000590 VisitExpr(E);
Sebastian Redlc3632732010-10-05 15:59:54 +0000591 E->setLParenLoc(ReadSourceLocation(Record, Idx));
592 E->setTypeSourceInfo(GetTypeSourceInfo(Record, Idx));
Argyrios Kyrtzidisd98a2ab2010-06-29 22:46:25 +0000593 E->setInitializer(Reader.ReadSubExpr());
Chris Lattner4c6f9522009-04-27 05:14:47 +0000594 E->setFileScope(Record[Idx++]);
Chris Lattner4c6f9522009-04-27 05:14:47 +0000595}
596
Sebastian Redl60adf4a2010-08-18 23:56:52 +0000597void ASTStmtReader::VisitExtVectorElementExpr(ExtVectorElementExpr *E) {
Chris Lattner4c6f9522009-04-27 05:14:47 +0000598 VisitExpr(E);
Argyrios Kyrtzidisd98a2ab2010-06-29 22:46:25 +0000599 E->setBase(Reader.ReadSubExpr());
Douglas Gregor95eab172011-07-28 20:55:49 +0000600 E->setAccessor(Reader.GetIdentifierInfo(F, Record, Idx));
Sebastian Redlc3632732010-10-05 15:59:54 +0000601 E->setAccessorLoc(ReadSourceLocation(Record, Idx));
Chris Lattner4c6f9522009-04-27 05:14:47 +0000602}
603
Sebastian Redl60adf4a2010-08-18 23:56:52 +0000604void ASTStmtReader::VisitInitListExpr(InitListExpr *E) {
Chris Lattner4c6f9522009-04-27 05:14:47 +0000605 VisitExpr(E);
Argyrios Kyrtzidisd98a2ab2010-06-29 22:46:25 +0000606 E->setSyntacticForm(cast_or_null<InitListExpr>(Reader.ReadSubStmt()));
Sebastian Redlc3632732010-10-05 15:59:54 +0000607 E->setLBraceLoc(ReadSourceLocation(Record, Idx));
608 E->setRBraceLoc(ReadSourceLocation(Record, Idx));
Argyrios Kyrtzidis2ac0b7a2011-04-22 05:29:30 +0000609 bool isArrayFiller = Record[Idx++];
610 Expr *filler = 0;
611 if (isArrayFiller) {
612 filler = Reader.ReadSubExpr();
613 E->ArrayFillerOrUnionFieldInit = filler;
614 } else
Douglas Gregor409448c2011-07-21 22:35:25 +0000615 E->ArrayFillerOrUnionFieldInit = ReadDeclAs<FieldDecl>(Record, Idx);
Chris Lattner4c6f9522009-04-27 05:14:47 +0000616 E->sawArrayRangeDesignator(Record[Idx++]);
Argyrios Kyrtzidis2ac0b7a2011-04-22 05:29:30 +0000617 unsigned NumInits = Record[Idx++];
Douglas Gregor35942772011-09-09 21:34:22 +0000618 E->reserveInits(Reader.getContext(), NumInits);
Argyrios Kyrtzidis2ac0b7a2011-04-22 05:29:30 +0000619 if (isArrayFiller) {
620 for (unsigned I = 0; I != NumInits; ++I) {
621 Expr *init = Reader.ReadSubExpr();
Douglas Gregor35942772011-09-09 21:34:22 +0000622 E->updateInit(Reader.getContext(), I, init ? init : filler);
Argyrios Kyrtzidis2ac0b7a2011-04-22 05:29:30 +0000623 }
624 } else {
625 for (unsigned I = 0; I != NumInits; ++I)
Douglas Gregor35942772011-09-09 21:34:22 +0000626 E->updateInit(Reader.getContext(), I, Reader.ReadSubExpr());
Argyrios Kyrtzidis2ac0b7a2011-04-22 05:29:30 +0000627 }
Chris Lattner4c6f9522009-04-27 05:14:47 +0000628}
629
Sebastian Redl60adf4a2010-08-18 23:56:52 +0000630void ASTStmtReader::VisitDesignatedInitExpr(DesignatedInitExpr *E) {
Chris Lattner4c6f9522009-04-27 05:14:47 +0000631 typedef DesignatedInitExpr::Designator Designator;
632
633 VisitExpr(E);
634 unsigned NumSubExprs = Record[Idx++];
635 assert(NumSubExprs == E->getNumSubExprs() && "Wrong number of subexprs");
636 for (unsigned I = 0; I != NumSubExprs; ++I)
Argyrios Kyrtzidisd98a2ab2010-06-29 22:46:25 +0000637 E->setSubExpr(I, Reader.ReadSubExpr());
Sebastian Redlc3632732010-10-05 15:59:54 +0000638 E->setEqualOrColonLoc(ReadSourceLocation(Record, Idx));
Chris Lattner4c6f9522009-04-27 05:14:47 +0000639 E->setGNUSyntax(Record[Idx++]);
640
Chris Lattner5f9e2722011-07-23 10:55:15 +0000641 SmallVector<Designator, 4> Designators;
Chris Lattner4c6f9522009-04-27 05:14:47 +0000642 while (Idx < Record.size()) {
Sebastian Redl8538e8d2010-08-18 23:57:32 +0000643 switch ((DesignatorTypes)Record[Idx++]) {
644 case DESIG_FIELD_DECL: {
Douglas Gregor409448c2011-07-21 22:35:25 +0000645 FieldDecl *Field = ReadDeclAs<FieldDecl>(Record, Idx);
Mike Stump1eb44332009-09-09 15:08:12 +0000646 SourceLocation DotLoc
Sebastian Redlc3632732010-10-05 15:59:54 +0000647 = ReadSourceLocation(Record, Idx);
Mike Stump1eb44332009-09-09 15:08:12 +0000648 SourceLocation FieldLoc
Sebastian Redlc3632732010-10-05 15:59:54 +0000649 = ReadSourceLocation(Record, Idx);
Mike Stump1eb44332009-09-09 15:08:12 +0000650 Designators.push_back(Designator(Field->getIdentifier(), DotLoc,
Chris Lattner4c6f9522009-04-27 05:14:47 +0000651 FieldLoc));
652 Designators.back().setField(Field);
653 break;
654 }
655
Sebastian Redl8538e8d2010-08-18 23:57:32 +0000656 case DESIG_FIELD_NAME: {
Douglas Gregor95eab172011-07-28 20:55:49 +0000657 const IdentifierInfo *Name = Reader.GetIdentifierInfo(F, Record, Idx);
Mike Stump1eb44332009-09-09 15:08:12 +0000658 SourceLocation DotLoc
Sebastian Redlc3632732010-10-05 15:59:54 +0000659 = ReadSourceLocation(Record, Idx);
Mike Stump1eb44332009-09-09 15:08:12 +0000660 SourceLocation FieldLoc
Sebastian Redlc3632732010-10-05 15:59:54 +0000661 = ReadSourceLocation(Record, Idx);
Chris Lattner4c6f9522009-04-27 05:14:47 +0000662 Designators.push_back(Designator(Name, DotLoc, FieldLoc));
663 break;
664 }
Mike Stump1eb44332009-09-09 15:08:12 +0000665
Sebastian Redl8538e8d2010-08-18 23:57:32 +0000666 case DESIG_ARRAY: {
Chris Lattner4c6f9522009-04-27 05:14:47 +0000667 unsigned Index = Record[Idx++];
668 SourceLocation LBracketLoc
Sebastian Redlc3632732010-10-05 15:59:54 +0000669 = ReadSourceLocation(Record, Idx);
Chris Lattner4c6f9522009-04-27 05:14:47 +0000670 SourceLocation RBracketLoc
Sebastian Redlc3632732010-10-05 15:59:54 +0000671 = ReadSourceLocation(Record, Idx);
Chris Lattner4c6f9522009-04-27 05:14:47 +0000672 Designators.push_back(Designator(Index, LBracketLoc, RBracketLoc));
673 break;
674 }
675
Sebastian Redl8538e8d2010-08-18 23:57:32 +0000676 case DESIG_ARRAY_RANGE: {
Chris Lattner4c6f9522009-04-27 05:14:47 +0000677 unsigned Index = Record[Idx++];
678 SourceLocation LBracketLoc
Sebastian Redlc3632732010-10-05 15:59:54 +0000679 = ReadSourceLocation(Record, Idx);
Chris Lattner4c6f9522009-04-27 05:14:47 +0000680 SourceLocation EllipsisLoc
Sebastian Redlc3632732010-10-05 15:59:54 +0000681 = ReadSourceLocation(Record, Idx);
Chris Lattner4c6f9522009-04-27 05:14:47 +0000682 SourceLocation RBracketLoc
Sebastian Redlc3632732010-10-05 15:59:54 +0000683 = ReadSourceLocation(Record, Idx);
Chris Lattner4c6f9522009-04-27 05:14:47 +0000684 Designators.push_back(Designator(Index, LBracketLoc, EllipsisLoc,
685 RBracketLoc));
686 break;
687 }
688 }
689 }
Douglas Gregor35942772011-09-09 21:34:22 +0000690 E->setDesignators(Reader.getContext(),
Douglas Gregor319d57f2010-01-06 23:17:19 +0000691 Designators.data(), Designators.size());
Chris Lattner4c6f9522009-04-27 05:14:47 +0000692}
693
Sebastian Redl60adf4a2010-08-18 23:56:52 +0000694void ASTStmtReader::VisitImplicitValueInitExpr(ImplicitValueInitExpr *E) {
Chris Lattner4c6f9522009-04-27 05:14:47 +0000695 VisitExpr(E);
Chris Lattner4c6f9522009-04-27 05:14:47 +0000696}
697
Sebastian Redl60adf4a2010-08-18 23:56:52 +0000698void ASTStmtReader::VisitVAArgExpr(VAArgExpr *E) {
Chris Lattner4c6f9522009-04-27 05:14:47 +0000699 VisitExpr(E);
Argyrios Kyrtzidisd98a2ab2010-06-29 22:46:25 +0000700 E->setSubExpr(Reader.ReadSubExpr());
Sebastian Redlc3632732010-10-05 15:59:54 +0000701 E->setWrittenTypeInfo(GetTypeSourceInfo(Record, Idx));
702 E->setBuiltinLoc(ReadSourceLocation(Record, Idx));
703 E->setRParenLoc(ReadSourceLocation(Record, Idx));
Chris Lattner4c6f9522009-04-27 05:14:47 +0000704}
705
Sebastian Redl60adf4a2010-08-18 23:56:52 +0000706void ASTStmtReader::VisitAddrLabelExpr(AddrLabelExpr *E) {
Chris Lattner4c6f9522009-04-27 05:14:47 +0000707 VisitExpr(E);
Sebastian Redlc3632732010-10-05 15:59:54 +0000708 E->setAmpAmpLoc(ReadSourceLocation(Record, Idx));
709 E->setLabelLoc(ReadSourceLocation(Record, Idx));
Douglas Gregor409448c2011-07-21 22:35:25 +0000710 E->setLabel(ReadDeclAs<LabelDecl>(Record, Idx));
Chris Lattner4c6f9522009-04-27 05:14:47 +0000711}
712
Sebastian Redl60adf4a2010-08-18 23:56:52 +0000713void ASTStmtReader::VisitStmtExpr(StmtExpr *E) {
Chris Lattner4c6f9522009-04-27 05:14:47 +0000714 VisitExpr(E);
Sebastian Redlc3632732010-10-05 15:59:54 +0000715 E->setLParenLoc(ReadSourceLocation(Record, Idx));
716 E->setRParenLoc(ReadSourceLocation(Record, Idx));
Argyrios Kyrtzidisd98a2ab2010-06-29 22:46:25 +0000717 E->setSubStmt(cast_or_null<CompoundStmt>(Reader.ReadSubStmt()));
Chris Lattner4c6f9522009-04-27 05:14:47 +0000718}
719
Sebastian Redl60adf4a2010-08-18 23:56:52 +0000720void ASTStmtReader::VisitChooseExpr(ChooseExpr *E) {
Chris Lattner4c6f9522009-04-27 05:14:47 +0000721 VisitExpr(E);
Argyrios Kyrtzidisd98a2ab2010-06-29 22:46:25 +0000722 E->setCond(Reader.ReadSubExpr());
723 E->setLHS(Reader.ReadSubExpr());
724 E->setRHS(Reader.ReadSubExpr());
Sebastian Redlc3632732010-10-05 15:59:54 +0000725 E->setBuiltinLoc(ReadSourceLocation(Record, Idx));
726 E->setRParenLoc(ReadSourceLocation(Record, Idx));
Chris Lattner4c6f9522009-04-27 05:14:47 +0000727}
728
Sebastian Redl60adf4a2010-08-18 23:56:52 +0000729void ASTStmtReader::VisitGNUNullExpr(GNUNullExpr *E) {
Chris Lattner4c6f9522009-04-27 05:14:47 +0000730 VisitExpr(E);
Sebastian Redlc3632732010-10-05 15:59:54 +0000731 E->setTokenLocation(ReadSourceLocation(Record, Idx));
Chris Lattner4c6f9522009-04-27 05:14:47 +0000732}
733
Sebastian Redl60adf4a2010-08-18 23:56:52 +0000734void ASTStmtReader::VisitShuffleVectorExpr(ShuffleVectorExpr *E) {
Chris Lattner4c6f9522009-04-27 05:14:47 +0000735 VisitExpr(E);
Chris Lattner5f9e2722011-07-23 10:55:15 +0000736 SmallVector<Expr *, 16> Exprs;
Chris Lattner4c6f9522009-04-27 05:14:47 +0000737 unsigned NumExprs = Record[Idx++];
Argyrios Kyrtzidis919e6932010-06-28 22:28:35 +0000738 while (NumExprs--)
Argyrios Kyrtzidisd98a2ab2010-06-29 22:46:25 +0000739 Exprs.push_back(Reader.ReadSubExpr());
Douglas Gregor35942772011-09-09 21:34:22 +0000740 E->setExprs(Reader.getContext(), Exprs.data(), Exprs.size());
Sebastian Redlc3632732010-10-05 15:59:54 +0000741 E->setBuiltinLoc(ReadSourceLocation(Record, Idx));
742 E->setRParenLoc(ReadSourceLocation(Record, Idx));
Chris Lattner4c6f9522009-04-27 05:14:47 +0000743}
744
Sebastian Redl60adf4a2010-08-18 23:56:52 +0000745void ASTStmtReader::VisitBlockExpr(BlockExpr *E) {
Chris Lattner4c6f9522009-04-27 05:14:47 +0000746 VisitExpr(E);
Douglas Gregor409448c2011-07-21 22:35:25 +0000747 E->setBlockDecl(ReadDeclAs<BlockDecl>(Record, Idx));
Chris Lattner4c6f9522009-04-27 05:14:47 +0000748}
749
Sebastian Redl60adf4a2010-08-18 23:56:52 +0000750void ASTStmtReader::VisitBlockDeclRefExpr(BlockDeclRefExpr *E) {
Chris Lattner4c6f9522009-04-27 05:14:47 +0000751 VisitExpr(E);
Douglas Gregor409448c2011-07-21 22:35:25 +0000752 E->setDecl(ReadDeclAs<VarDecl>(Record, Idx));
Sebastian Redlc3632732010-10-05 15:59:54 +0000753 E->setLocation(ReadSourceLocation(Record, Idx));
Chris Lattner4c6f9522009-04-27 05:14:47 +0000754 E->setByRef(Record[Idx++]);
Fariborz Jahanian9b0b57c2009-06-20 00:02:26 +0000755 E->setConstQualAdded(Record[Idx++]);
Chris Lattner4c6f9522009-04-27 05:14:47 +0000756}
757
Peter Collingbournef111d932011-04-15 00:35:48 +0000758void ASTStmtReader::VisitGenericSelectionExpr(GenericSelectionExpr *E) {
759 VisitExpr(E);
760 E->NumAssocs = Record[Idx++];
Douglas Gregor35942772011-09-09 21:34:22 +0000761 E->AssocTypes = new (Reader.getContext()) TypeSourceInfo*[E->NumAssocs];
Peter Collingbournef111d932011-04-15 00:35:48 +0000762 E->SubExprs =
Douglas Gregor35942772011-09-09 21:34:22 +0000763 new(Reader.getContext()) Stmt*[GenericSelectionExpr::END_EXPR+E->NumAssocs];
Peter Collingbournef111d932011-04-15 00:35:48 +0000764
765 E->SubExprs[GenericSelectionExpr::CONTROLLING] = Reader.ReadSubExpr();
766 for (unsigned I = 0, N = E->getNumAssocs(); I != N; ++I) {
767 E->AssocTypes[I] = GetTypeSourceInfo(Record, Idx);
768 E->SubExprs[GenericSelectionExpr::END_EXPR+I] = Reader.ReadSubExpr();
769 }
770 E->ResultIndex = Record[Idx++];
771
772 E->GenericLoc = ReadSourceLocation(Record, Idx);
773 E->DefaultLoc = ReadSourceLocation(Record, Idx);
774 E->RParenLoc = ReadSourceLocation(Record, Idx);
775}
776
Eli Friedman276b0612011-10-11 02:20:01 +0000777void ASTStmtReader::VisitAtomicExpr(AtomicExpr *E) {
778 VisitExpr(E);
779 E->setOp(AtomicExpr::AtomicOp(Record[Idx++]));
780 E->setPtr(Reader.ReadSubExpr());
781 E->setOrder(Reader.ReadSubExpr());
782 E->setNumSubExprs(2);
783 if (E->getOp() != AtomicExpr::Load) {
784 E->setVal1(Reader.ReadSubExpr());
785 E->setNumSubExprs(3);
786 }
787 if (E->isCmpXChg()) {
788 E->setOrderFail(Reader.ReadSubExpr());
789 E->setVal2(Reader.ReadSubExpr());
790 E->setNumSubExprs(5);
791 }
792 E->setBuiltinLoc(ReadSourceLocation(Record, Idx));
793 E->setRParenLoc(ReadSourceLocation(Record, Idx));
794}
795
Chris Lattner4c6f9522009-04-27 05:14:47 +0000796//===----------------------------------------------------------------------===//
797// Objective-C Expressions and Statements
798
Sebastian Redl60adf4a2010-08-18 23:56:52 +0000799void ASTStmtReader::VisitObjCStringLiteral(ObjCStringLiteral *E) {
Chris Lattner4c6f9522009-04-27 05:14:47 +0000800 VisitExpr(E);
Argyrios Kyrtzidisd98a2ab2010-06-29 22:46:25 +0000801 E->setString(cast<StringLiteral>(Reader.ReadSubStmt()));
Sebastian Redlc3632732010-10-05 15:59:54 +0000802 E->setAtLoc(ReadSourceLocation(Record, Idx));
Chris Lattner4c6f9522009-04-27 05:14:47 +0000803}
804
Sebastian Redl60adf4a2010-08-18 23:56:52 +0000805void ASTStmtReader::VisitObjCEncodeExpr(ObjCEncodeExpr *E) {
Chris Lattner4c6f9522009-04-27 05:14:47 +0000806 VisitExpr(E);
Sebastian Redlc3632732010-10-05 15:59:54 +0000807 E->setEncodedTypeSourceInfo(GetTypeSourceInfo(Record, Idx));
808 E->setAtLoc(ReadSourceLocation(Record, Idx));
809 E->setRParenLoc(ReadSourceLocation(Record, Idx));
Chris Lattner4c6f9522009-04-27 05:14:47 +0000810}
811
Sebastian Redl60adf4a2010-08-18 23:56:52 +0000812void ASTStmtReader::VisitObjCSelectorExpr(ObjCSelectorExpr *E) {
Chris Lattner4c6f9522009-04-27 05:14:47 +0000813 VisitExpr(E);
Douglas Gregor2d2689a2011-07-28 21:16:51 +0000814 E->setSelector(Reader.ReadSelector(F, Record, Idx));
Sebastian Redlc3632732010-10-05 15:59:54 +0000815 E->setAtLoc(ReadSourceLocation(Record, Idx));
816 E->setRParenLoc(ReadSourceLocation(Record, Idx));
Chris Lattner4c6f9522009-04-27 05:14:47 +0000817}
818
Sebastian Redl60adf4a2010-08-18 23:56:52 +0000819void ASTStmtReader::VisitObjCProtocolExpr(ObjCProtocolExpr *E) {
Chris Lattner4c6f9522009-04-27 05:14:47 +0000820 VisitExpr(E);
Douglas Gregor409448c2011-07-21 22:35:25 +0000821 E->setProtocol(ReadDeclAs<ObjCProtocolDecl>(Record, Idx));
Sebastian Redlc3632732010-10-05 15:59:54 +0000822 E->setAtLoc(ReadSourceLocation(Record, Idx));
823 E->setRParenLoc(ReadSourceLocation(Record, Idx));
Chris Lattner4c6f9522009-04-27 05:14:47 +0000824}
825
Sebastian Redl60adf4a2010-08-18 23:56:52 +0000826void ASTStmtReader::VisitObjCIvarRefExpr(ObjCIvarRefExpr *E) {
Chris Lattner4c6f9522009-04-27 05:14:47 +0000827 VisitExpr(E);
Douglas Gregor409448c2011-07-21 22:35:25 +0000828 E->setDecl(ReadDeclAs<ObjCIvarDecl>(Record, Idx));
Sebastian Redlc3632732010-10-05 15:59:54 +0000829 E->setLocation(ReadSourceLocation(Record, Idx));
Argyrios Kyrtzidisd98a2ab2010-06-29 22:46:25 +0000830 E->setBase(Reader.ReadSubExpr());
Chris Lattner4c6f9522009-04-27 05:14:47 +0000831 E->setIsArrow(Record[Idx++]);
832 E->setIsFreeIvar(Record[Idx++]);
Chris Lattner4c6f9522009-04-27 05:14:47 +0000833}
834
Sebastian Redl60adf4a2010-08-18 23:56:52 +0000835void ASTStmtReader::VisitObjCPropertyRefExpr(ObjCPropertyRefExpr *E) {
Chris Lattner4c6f9522009-04-27 05:14:47 +0000836 VisitExpr(E);
John McCall12f78a62010-12-02 01:19:52 +0000837 bool Implicit = Record[Idx++] != 0;
838 if (Implicit) {
Douglas Gregor409448c2011-07-21 22:35:25 +0000839 ObjCMethodDecl *Getter = ReadDeclAs<ObjCMethodDecl>(Record, Idx);
840 ObjCMethodDecl *Setter = ReadDeclAs<ObjCMethodDecl>(Record, Idx);
John McCall12f78a62010-12-02 01:19:52 +0000841 E->setImplicitProperty(Getter, Setter);
842 } else {
Douglas Gregor409448c2011-07-21 22:35:25 +0000843 E->setExplicitProperty(ReadDeclAs<ObjCPropertyDecl>(Record, Idx));
Fariborz Jahanian8ac2d442010-10-14 16:04:05 +0000844 }
Sebastian Redlc3632732010-10-05 15:59:54 +0000845 E->setLocation(ReadSourceLocation(Record, Idx));
John McCall12f78a62010-12-02 01:19:52 +0000846 E->setReceiverLocation(ReadSourceLocation(Record, Idx));
847 switch (Record[Idx++]) {
848 case 0:
849 E->setBase(Reader.ReadSubExpr());
850 break;
851 case 1:
Douglas Gregor393f2492011-07-22 00:38:23 +0000852 E->setSuperReceiver(Reader.readType(F, Record, Idx));
John McCall12f78a62010-12-02 01:19:52 +0000853 break;
854 case 2:
Douglas Gregor409448c2011-07-21 22:35:25 +0000855 E->setClassReceiver(ReadDeclAs<ObjCInterfaceDecl>(Record, Idx));
John McCall12f78a62010-12-02 01:19:52 +0000856 break;
857 }
Chris Lattner4c6f9522009-04-27 05:14:47 +0000858}
859
Sebastian Redl60adf4a2010-08-18 23:56:52 +0000860void ASTStmtReader::VisitObjCMessageExpr(ObjCMessageExpr *E) {
Chris Lattner4c6f9522009-04-27 05:14:47 +0000861 VisitExpr(E);
Douglas Gregor04badcf2010-04-21 00:45:42 +0000862 assert(Record[Idx] == E->getNumArgs());
863 ++Idx;
Argyrios Kyrtzidis20718082011-10-03 06:36:51 +0000864 unsigned NumStoredSelLocs = Record[Idx++];
865 E->SelLocsKind = Record[Idx++];
John McCallf85e1932011-06-15 23:02:42 +0000866 E->setDelegateInitCall(Record[Idx++]);
Douglas Gregor04badcf2010-04-21 00:45:42 +0000867 ObjCMessageExpr::ReceiverKind Kind
868 = static_cast<ObjCMessageExpr::ReceiverKind>(Record[Idx++]);
869 switch (Kind) {
870 case ObjCMessageExpr::Instance:
Argyrios Kyrtzidisd98a2ab2010-06-29 22:46:25 +0000871 E->setInstanceReceiver(Reader.ReadSubExpr());
Douglas Gregor04badcf2010-04-21 00:45:42 +0000872 break;
873
874 case ObjCMessageExpr::Class:
Sebastian Redlc3632732010-10-05 15:59:54 +0000875 E->setClassReceiver(GetTypeSourceInfo(Record, Idx));
Douglas Gregor04badcf2010-04-21 00:45:42 +0000876 break;
877
878 case ObjCMessageExpr::SuperClass:
879 case ObjCMessageExpr::SuperInstance: {
Douglas Gregor393f2492011-07-22 00:38:23 +0000880 QualType T = Reader.readType(F, Record, Idx);
Sebastian Redlc3632732010-10-05 15:59:54 +0000881 SourceLocation SuperLoc = ReadSourceLocation(Record, Idx);
Douglas Gregor04badcf2010-04-21 00:45:42 +0000882 E->setSuper(SuperLoc, T, Kind == ObjCMessageExpr::SuperInstance);
883 break;
884 }
885 }
886
887 assert(Kind == E->getReceiverKind());
888
889 if (Record[Idx++])
Douglas Gregor409448c2011-07-21 22:35:25 +0000890 E->setMethodDecl(ReadDeclAs<ObjCMethodDecl>(Record, Idx));
Douglas Gregor04badcf2010-04-21 00:45:42 +0000891 else
Douglas Gregor2d2689a2011-07-28 21:16:51 +0000892 E->setSelector(Reader.ReadSelector(F, Record, Idx));
Douglas Gregor04badcf2010-04-21 00:45:42 +0000893
Argyrios Kyrtzidisf40f0d52010-12-10 20:08:27 +0000894 E->LBracLoc = ReadSourceLocation(Record, Idx);
895 E->RBracLoc = ReadSourceLocation(Record, Idx);
Chris Lattner4c6f9522009-04-27 05:14:47 +0000896
897 for (unsigned I = 0, N = E->getNumArgs(); I != N; ++I)
Argyrios Kyrtzidisd98a2ab2010-06-29 22:46:25 +0000898 E->setArg(I, Reader.ReadSubExpr());
Argyrios Kyrtzidis20718082011-10-03 06:36:51 +0000899
900 SourceLocation *Locs = E->getStoredSelLocs();
901 for (unsigned I = 0; I != NumStoredSelLocs; ++I)
902 Locs[I] = ReadSourceLocation(Record, Idx);
Chris Lattner4c6f9522009-04-27 05:14:47 +0000903}
904
Sebastian Redl60adf4a2010-08-18 23:56:52 +0000905void ASTStmtReader::VisitObjCForCollectionStmt(ObjCForCollectionStmt *S) {
Chris Lattner4c6f9522009-04-27 05:14:47 +0000906 VisitStmt(S);
Argyrios Kyrtzidisd98a2ab2010-06-29 22:46:25 +0000907 S->setElement(Reader.ReadSubStmt());
908 S->setCollection(Reader.ReadSubExpr());
909 S->setBody(Reader.ReadSubStmt());
Sebastian Redlc3632732010-10-05 15:59:54 +0000910 S->setForLoc(ReadSourceLocation(Record, Idx));
911 S->setRParenLoc(ReadSourceLocation(Record, Idx));
Chris Lattner4c6f9522009-04-27 05:14:47 +0000912}
913
Sebastian Redl60adf4a2010-08-18 23:56:52 +0000914void ASTStmtReader::VisitObjCAtCatchStmt(ObjCAtCatchStmt *S) {
Chris Lattner4c6f9522009-04-27 05:14:47 +0000915 VisitStmt(S);
Argyrios Kyrtzidisd98a2ab2010-06-29 22:46:25 +0000916 S->setCatchBody(Reader.ReadSubStmt());
Douglas Gregor409448c2011-07-21 22:35:25 +0000917 S->setCatchParamDecl(ReadDeclAs<VarDecl>(Record, Idx));
Sebastian Redlc3632732010-10-05 15:59:54 +0000918 S->setAtCatchLoc(ReadSourceLocation(Record, Idx));
919 S->setRParenLoc(ReadSourceLocation(Record, Idx));
Chris Lattner4c6f9522009-04-27 05:14:47 +0000920}
921
Sebastian Redl60adf4a2010-08-18 23:56:52 +0000922void ASTStmtReader::VisitObjCAtFinallyStmt(ObjCAtFinallyStmt *S) {
Chris Lattner4c6f9522009-04-27 05:14:47 +0000923 VisitStmt(S);
Argyrios Kyrtzidisd98a2ab2010-06-29 22:46:25 +0000924 S->setFinallyBody(Reader.ReadSubStmt());
Sebastian Redlc3632732010-10-05 15:59:54 +0000925 S->setAtFinallyLoc(ReadSourceLocation(Record, Idx));
Chris Lattner4c6f9522009-04-27 05:14:47 +0000926}
927
John McCallf85e1932011-06-15 23:02:42 +0000928void ASTStmtReader::VisitObjCAutoreleasePoolStmt(ObjCAutoreleasePoolStmt *S) {
929 VisitStmt(S);
930 S->setSubStmt(Reader.ReadSubStmt());
931 S->setAtLoc(ReadSourceLocation(Record, Idx));
932}
933
Sebastian Redl60adf4a2010-08-18 23:56:52 +0000934void ASTStmtReader::VisitObjCAtTryStmt(ObjCAtTryStmt *S) {
Chris Lattner4c6f9522009-04-27 05:14:47 +0000935 VisitStmt(S);
Douglas Gregor8f5e3dd2010-04-23 22:50:49 +0000936 assert(Record[Idx] == S->getNumCatchStmts());
937 ++Idx;
938 bool HasFinally = Record[Idx++];
Argyrios Kyrtzidisd98a2ab2010-06-29 22:46:25 +0000939 S->setTryBody(Reader.ReadSubStmt());
Argyrios Kyrtzidis919e6932010-06-28 22:28:35 +0000940 for (unsigned I = 0, N = S->getNumCatchStmts(); I != N; ++I)
Argyrios Kyrtzidisd98a2ab2010-06-29 22:46:25 +0000941 S->setCatchStmt(I, cast_or_null<ObjCAtCatchStmt>(Reader.ReadSubStmt()));
Douglas Gregor8f5e3dd2010-04-23 22:50:49 +0000942
Douglas Gregor8f5e3dd2010-04-23 22:50:49 +0000943 if (HasFinally)
Argyrios Kyrtzidisd98a2ab2010-06-29 22:46:25 +0000944 S->setFinallyStmt(Reader.ReadSubStmt());
Sebastian Redlc3632732010-10-05 15:59:54 +0000945 S->setAtTryLoc(ReadSourceLocation(Record, Idx));
Chris Lattner4c6f9522009-04-27 05:14:47 +0000946}
947
Sebastian Redl60adf4a2010-08-18 23:56:52 +0000948void ASTStmtReader::VisitObjCAtSynchronizedStmt(ObjCAtSynchronizedStmt *S) {
Chris Lattner4c6f9522009-04-27 05:14:47 +0000949 VisitStmt(S);
Argyrios Kyrtzidisd98a2ab2010-06-29 22:46:25 +0000950 S->setSynchExpr(Reader.ReadSubStmt());
951 S->setSynchBody(Reader.ReadSubStmt());
Sebastian Redlc3632732010-10-05 15:59:54 +0000952 S->setAtSynchronizedLoc(ReadSourceLocation(Record, Idx));
Chris Lattner4c6f9522009-04-27 05:14:47 +0000953}
954
Sebastian Redl60adf4a2010-08-18 23:56:52 +0000955void ASTStmtReader::VisitObjCAtThrowStmt(ObjCAtThrowStmt *S) {
Chris Lattner4c6f9522009-04-27 05:14:47 +0000956 VisitStmt(S);
Argyrios Kyrtzidisd98a2ab2010-06-29 22:46:25 +0000957 S->setThrowExpr(Reader.ReadSubStmt());
Sebastian Redlc3632732010-10-05 15:59:54 +0000958 S->setThrowLoc(ReadSourceLocation(Record, Idx));
Chris Lattner4c6f9522009-04-27 05:14:47 +0000959}
960
Argyrios Kyrtzidisba0a9002009-07-14 03:19:21 +0000961//===----------------------------------------------------------------------===//
962// C++ Expressions and Statements
Argyrios Kyrtzidis7cb45e32010-07-22 16:03:56 +0000963//===----------------------------------------------------------------------===//
964
Sebastian Redl60adf4a2010-08-18 23:56:52 +0000965void ASTStmtReader::VisitCXXCatchStmt(CXXCatchStmt *S) {
Argyrios Kyrtzidis7cb45e32010-07-22 16:03:56 +0000966 VisitStmt(S);
Sebastian Redlc3632732010-10-05 15:59:54 +0000967 S->CatchLoc = ReadSourceLocation(Record, Idx);
Douglas Gregor409448c2011-07-21 22:35:25 +0000968 S->ExceptionDecl = ReadDeclAs<VarDecl>(Record, Idx);
Argyrios Kyrtzidis7cb45e32010-07-22 16:03:56 +0000969 S->HandlerBlock = Reader.ReadSubStmt();
970}
971
Sebastian Redl60adf4a2010-08-18 23:56:52 +0000972void ASTStmtReader::VisitCXXTryStmt(CXXTryStmt *S) {
Argyrios Kyrtzidis7cb45e32010-07-22 16:03:56 +0000973 VisitStmt(S);
974 assert(Record[Idx] == S->getNumHandlers() && "NumStmtFields is wrong ?");
975 ++Idx;
Sebastian Redlc3632732010-10-05 15:59:54 +0000976 S->TryLoc = ReadSourceLocation(Record, Idx);
Argyrios Kyrtzidis7cb45e32010-07-22 16:03:56 +0000977 S->getStmts()[0] = Reader.ReadSubStmt();
978 for (unsigned i = 0, e = S->getNumHandlers(); i != e; ++i)
979 S->getStmts()[i + 1] = Reader.ReadSubStmt();
980}
Argyrios Kyrtzidisba0a9002009-07-14 03:19:21 +0000981
Richard Smithad762fc2011-04-14 22:09:26 +0000982void ASTStmtReader::VisitCXXForRangeStmt(CXXForRangeStmt *S) {
983 VisitStmt(S);
984 S->setForLoc(ReadSourceLocation(Record, Idx));
985 S->setColonLoc(ReadSourceLocation(Record, Idx));
986 S->setRParenLoc(ReadSourceLocation(Record, Idx));
987 S->setRangeStmt(Reader.ReadSubStmt());
988 S->setBeginEndStmt(Reader.ReadSubStmt());
989 S->setCond(Reader.ReadSubExpr());
990 S->setInc(Reader.ReadSubExpr());
991 S->setLoopVarStmt(Reader.ReadSubStmt());
992 S->setBody(Reader.ReadSubStmt());
993}
994
Sebastian Redl60adf4a2010-08-18 23:56:52 +0000995void ASTStmtReader::VisitCXXOperatorCallExpr(CXXOperatorCallExpr *E) {
Argyrios Kyrtzidis919e6932010-06-28 22:28:35 +0000996 VisitCallExpr(E);
Argyrios Kyrtzidisba0a9002009-07-14 03:19:21 +0000997 E->setOperator((OverloadedOperatorKind)Record[Idx++]);
Argyrios Kyrtzidisba0a9002009-07-14 03:19:21 +0000998}
999
Sebastian Redl60adf4a2010-08-18 23:56:52 +00001000void ASTStmtReader::VisitCXXConstructExpr(CXXConstructExpr *E) {
Douglas Gregor39da0b82009-09-09 23:08:42 +00001001 VisitExpr(E);
Argyrios Kyrtzidis6d00c132010-07-10 11:46:15 +00001002 E->NumArgs = Record[Idx++];
1003 if (E->NumArgs)
Douglas Gregor35942772011-09-09 21:34:22 +00001004 E->Args = new (Reader.getContext()) Stmt*[E->NumArgs];
Argyrios Kyrtzidis5e1b7c22010-06-24 08:57:09 +00001005 for (unsigned I = 0, N = E->getNumArgs(); I != N; ++I)
Argyrios Kyrtzidisd98a2ab2010-06-29 22:46:25 +00001006 E->setArg(I, Reader.ReadSubExpr());
Douglas Gregor409448c2011-07-21 22:35:25 +00001007 E->setConstructor(ReadDeclAs<CXXConstructorDecl>(Record, Idx));
Sebastian Redlc3632732010-10-05 15:59:54 +00001008 E->setLocation(ReadSourceLocation(Record, Idx));
Abramo Bagnara7cc58b42011-10-05 07:56:41 +00001009 E->setElidable(Record[Idx++]);
1010 E->setHadMultipleCandidates(Record[Idx++]);
Douglas Gregor16006c92009-12-16 18:50:27 +00001011 E->setRequiresZeroInitialization(Record[Idx++]);
Douglas Gregor3c9034c2010-05-15 00:13:29 +00001012 E->setConstructionKind((CXXConstructExpr::ConstructionKind)Record[Idx++]);
Chandler Carruth428edaf2010-10-25 08:47:36 +00001013 E->ParenRange = ReadSourceRange(Record, Idx);
Douglas Gregor39da0b82009-09-09 23:08:42 +00001014}
Chris Lattner4c6f9522009-04-27 05:14:47 +00001015
Sebastian Redl60adf4a2010-08-18 23:56:52 +00001016void ASTStmtReader::VisitCXXTemporaryObjectExpr(CXXTemporaryObjectExpr *E) {
Argyrios Kyrtzidis6d00c132010-07-10 11:46:15 +00001017 VisitCXXConstructExpr(E);
Sebastian Redlc3632732010-10-05 15:59:54 +00001018 E->Type = GetTypeSourceInfo(Record, Idx);
Argyrios Kyrtzidis6d00c132010-07-10 11:46:15 +00001019}
1020
Sebastian Redl60adf4a2010-08-18 23:56:52 +00001021void ASTStmtReader::VisitCXXNamedCastExpr(CXXNamedCastExpr *E) {
Argyrios Kyrtzidis919e6932010-06-28 22:28:35 +00001022 VisitExplicitCastExpr(E);
Douglas Gregor1d5d0b92011-01-12 22:41:29 +00001023 SourceRange R = ReadSourceRange(Record, Idx);
1024 E->Loc = R.getBegin();
1025 E->RParenLoc = R.getEnd();
Sam Weinigce757a72010-01-16 21:21:01 +00001026}
1027
Sebastian Redl60adf4a2010-08-18 23:56:52 +00001028void ASTStmtReader::VisitCXXStaticCastExpr(CXXStaticCastExpr *E) {
Sam Weinigce757a72010-01-16 21:21:01 +00001029 return VisitCXXNamedCastExpr(E);
1030}
1031
Sebastian Redl60adf4a2010-08-18 23:56:52 +00001032void ASTStmtReader::VisitCXXDynamicCastExpr(CXXDynamicCastExpr *E) {
Sam Weinigce757a72010-01-16 21:21:01 +00001033 return VisitCXXNamedCastExpr(E);
1034}
1035
Sebastian Redl60adf4a2010-08-18 23:56:52 +00001036void ASTStmtReader::VisitCXXReinterpretCastExpr(CXXReinterpretCastExpr *E) {
Sam Weinigce757a72010-01-16 21:21:01 +00001037 return VisitCXXNamedCastExpr(E);
1038}
1039
Sebastian Redl60adf4a2010-08-18 23:56:52 +00001040void ASTStmtReader::VisitCXXConstCastExpr(CXXConstCastExpr *E) {
Sam Weinigce757a72010-01-16 21:21:01 +00001041 return VisitCXXNamedCastExpr(E);
1042}
1043
Sebastian Redl60adf4a2010-08-18 23:56:52 +00001044void ASTStmtReader::VisitCXXFunctionalCastExpr(CXXFunctionalCastExpr *E) {
Argyrios Kyrtzidis919e6932010-06-28 22:28:35 +00001045 VisitExplicitCastExpr(E);
Sebastian Redlc3632732010-10-05 15:59:54 +00001046 E->setTypeBeginLoc(ReadSourceLocation(Record, Idx));
1047 E->setRParenLoc(ReadSourceLocation(Record, Idx));
Sam Weinigce757a72010-01-16 21:21:01 +00001048}
1049
Sebastian Redl60adf4a2010-08-18 23:56:52 +00001050void ASTStmtReader::VisitCXXBoolLiteralExpr(CXXBoolLiteralExpr *E) {
Sam Weinigeb7f9612010-02-07 06:32:43 +00001051 VisitExpr(E);
1052 E->setValue(Record[Idx++]);
Sebastian Redlc3632732010-10-05 15:59:54 +00001053 E->setLocation(ReadSourceLocation(Record, Idx));
Sam Weinigeb7f9612010-02-07 06:32:43 +00001054}
1055
Sebastian Redl60adf4a2010-08-18 23:56:52 +00001056void ASTStmtReader::VisitCXXNullPtrLiteralExpr(CXXNullPtrLiteralExpr *E) {
Sam Weinigeb7f9612010-02-07 06:32:43 +00001057 VisitExpr(E);
Sebastian Redlc3632732010-10-05 15:59:54 +00001058 E->setLocation(ReadSourceLocation(Record, Idx));
Sam Weinigeb7f9612010-02-07 06:32:43 +00001059}
1060
Sebastian Redl60adf4a2010-08-18 23:56:52 +00001061void ASTStmtReader::VisitCXXTypeidExpr(CXXTypeidExpr *E) {
Chris Lattner14ab24f2010-05-09 06:03:39 +00001062 VisitExpr(E);
Sebastian Redlc3632732010-10-05 15:59:54 +00001063 E->setSourceRange(ReadSourceRange(Record, Idx));
Chris Lattner14ab24f2010-05-09 06:03:39 +00001064 if (E->isTypeOperand()) { // typeid(int)
Sebastian Redl577d4792010-07-22 22:43:28 +00001065 E->setTypeOperandSourceInfo(
Sebastian Redlc3632732010-10-05 15:59:54 +00001066 GetTypeSourceInfo(Record, Idx));
Argyrios Kyrtzidis919e6932010-06-28 22:28:35 +00001067 return;
Chris Lattner14ab24f2010-05-09 06:03:39 +00001068 }
1069
1070 // typeid(42+2)
Argyrios Kyrtzidisd98a2ab2010-06-29 22:46:25 +00001071 E->setExprOperand(Reader.ReadSubExpr());
Chris Lattner14ab24f2010-05-09 06:03:39 +00001072}
1073
Sebastian Redl60adf4a2010-08-18 23:56:52 +00001074void ASTStmtReader::VisitCXXThisExpr(CXXThisExpr *E) {
Chris Lattner2fbdfcd2010-05-09 06:15:05 +00001075 VisitExpr(E);
Sebastian Redlc3632732010-10-05 15:59:54 +00001076 E->setLocation(ReadSourceLocation(Record, Idx));
Chris Lattner2fbdfcd2010-05-09 06:15:05 +00001077 E->setImplicit(Record[Idx++]);
Chris Lattner2fbdfcd2010-05-09 06:15:05 +00001078}
1079
Sebastian Redl60adf4a2010-08-18 23:56:52 +00001080void ASTStmtReader::VisitCXXThrowExpr(CXXThrowExpr *E) {
Chris Lattner2fbdfcd2010-05-09 06:15:05 +00001081 VisitExpr(E);
Douglas Gregorbca01b42011-07-06 22:04:06 +00001082 E->ThrowLoc = ReadSourceLocation(Record, Idx);
1083 E->Op = Reader.ReadSubExpr();
1084 E->IsThrownVariableInScope = Record[Idx++];
Chris Lattner2fbdfcd2010-05-09 06:15:05 +00001085}
Chris Lattner14ab24f2010-05-09 06:03:39 +00001086
Sebastian Redl60adf4a2010-08-18 23:56:52 +00001087void ASTStmtReader::VisitCXXDefaultArgExpr(CXXDefaultArgExpr *E) {
Chris Lattner030854b2010-05-09 06:40:08 +00001088 VisitExpr(E);
Argyrios Kyrtzidis8a507332010-07-02 23:30:15 +00001089
Douglas Gregordf226552011-09-23 22:07:41 +00001090 assert((bool)Record[Idx] == E->Param.getInt() && "We messed up at creation ?");
Argyrios Kyrtzidis8a507332010-07-02 23:30:15 +00001091 ++Idx; // HasOtherExprStored and SubExpr was handled during creation.
Douglas Gregor409448c2011-07-21 22:35:25 +00001092 E->Param.setPointer(ReadDeclAs<ParmVarDecl>(Record, Idx));
Sebastian Redlc3632732010-10-05 15:59:54 +00001093 E->Loc = ReadSourceLocation(Record, Idx);
Chris Lattnerd2598362010-05-10 00:25:06 +00001094}
1095
Sebastian Redl60adf4a2010-08-18 23:56:52 +00001096void ASTStmtReader::VisitCXXBindTemporaryExpr(CXXBindTemporaryExpr *E) {
Chris Lattnerd2598362010-05-10 00:25:06 +00001097 VisitExpr(E);
Douglas Gregor409448c2011-07-21 22:35:25 +00001098 E->setTemporary(Reader.ReadCXXTemporary(F, Record, Idx));
Argyrios Kyrtzidisd98a2ab2010-06-29 22:46:25 +00001099 E->setSubExpr(Reader.ReadSubExpr());
Chris Lattnerd2598362010-05-10 00:25:06 +00001100}
1101
Sebastian Redl60adf4a2010-08-18 23:56:52 +00001102void ASTStmtReader::VisitCXXScalarValueInitExpr(CXXScalarValueInitExpr *E) {
Chris Lattner59218632010-05-10 01:22:27 +00001103 VisitExpr(E);
Sebastian Redlc3632732010-10-05 15:59:54 +00001104 E->TypeInfo = GetTypeSourceInfo(Record, Idx);
1105 E->RParenLoc = ReadSourceLocation(Record, Idx);
Chris Lattner59218632010-05-10 01:22:27 +00001106}
1107
Sebastian Redl60adf4a2010-08-18 23:56:52 +00001108void ASTStmtReader::VisitCXXNewExpr(CXXNewExpr *E) {
Chris Lattner59218632010-05-10 01:22:27 +00001109 VisitExpr(E);
John McCall6ec278d2011-01-27 09:37:56 +00001110 E->GlobalNew = Record[Idx++];
1111 E->Initializer = Record[Idx++];
1112 E->UsualArrayDeleteWantsSize = Record[Idx++];
Chris Lattner59218632010-05-10 01:22:27 +00001113 bool isArray = Record[Idx++];
Abramo Bagnara7cc58b42011-10-05 07:56:41 +00001114 E->setHadMultipleCandidates(Record[Idx++]);
Chris Lattner59218632010-05-10 01:22:27 +00001115 unsigned NumPlacementArgs = Record[Idx++];
1116 unsigned NumCtorArgs = Record[Idx++];
Douglas Gregor409448c2011-07-21 22:35:25 +00001117 E->setOperatorNew(ReadDeclAs<FunctionDecl>(Record, Idx));
1118 E->setOperatorDelete(ReadDeclAs<FunctionDecl>(Record, Idx));
1119 E->setConstructor(ReadDeclAs<CXXConstructorDecl>(Record, Idx));
Sebastian Redlc3632732010-10-05 15:59:54 +00001120 E->AllocatedTypeInfo = GetTypeSourceInfo(Record, Idx);
Douglas Gregor4bd40312010-07-13 15:54:32 +00001121 SourceRange TypeIdParens;
Sebastian Redlc3632732010-10-05 15:59:54 +00001122 TypeIdParens.setBegin(ReadSourceLocation(Record, Idx));
1123 TypeIdParens.setEnd(ReadSourceLocation(Record, Idx));
Douglas Gregor4bd40312010-07-13 15:54:32 +00001124 E->TypeIdParens = TypeIdParens;
Chandler Carruth428edaf2010-10-25 08:47:36 +00001125 E->StartLoc = ReadSourceLocation(Record, Idx);
1126 E->EndLoc = ReadSourceLocation(Record, Idx);
1127 E->ConstructorLParen = ReadSourceLocation(Record, Idx);
1128 E->ConstructorRParen = ReadSourceLocation(Record, Idx);
1129
Douglas Gregor35942772011-09-09 21:34:22 +00001130 E->AllocateArgsArray(Reader.getContext(), isArray, NumPlacementArgs,
Chris Lattner59218632010-05-10 01:22:27 +00001131 NumCtorArgs);
1132
1133 // Install all the subexpressions.
Chris Lattner59218632010-05-10 01:22:27 +00001134 for (CXXNewExpr::raw_arg_iterator I = E->raw_arg_begin(),e = E->raw_arg_end();
1135 I != e; ++I)
Argyrios Kyrtzidisd98a2ab2010-06-29 22:46:25 +00001136 *I = Reader.ReadSubStmt();
Chris Lattner59218632010-05-10 01:22:27 +00001137}
1138
Sebastian Redl60adf4a2010-08-18 23:56:52 +00001139void ASTStmtReader::VisitCXXDeleteExpr(CXXDeleteExpr *E) {
Argyrios Kyrtzidis95fc98c2010-06-22 17:07:59 +00001140 VisitExpr(E);
Argyrios Kyrtzidisf1b89112010-09-13 20:15:40 +00001141 E->GlobalDelete = Record[Idx++];
1142 E->ArrayForm = Record[Idx++];
Argyrios Kyrtzidis4076dac2010-09-13 20:15:54 +00001143 E->ArrayFormAsWritten = Record[Idx++];
John McCall6ec278d2011-01-27 09:37:56 +00001144 E->UsualArrayDeleteWantsSize = Record[Idx++];
Douglas Gregor409448c2011-07-21 22:35:25 +00001145 E->OperatorDelete = ReadDeclAs<FunctionDecl>(Record, Idx);
Argyrios Kyrtzidisf1b89112010-09-13 20:15:40 +00001146 E->Argument = Reader.ReadSubExpr();
Sebastian Redlc3632732010-10-05 15:59:54 +00001147 E->Loc = ReadSourceLocation(Record, Idx);
Argyrios Kyrtzidis95fc98c2010-06-22 17:07:59 +00001148}
Chris Lattnerd2598362010-05-10 00:25:06 +00001149
Sebastian Redl60adf4a2010-08-18 23:56:52 +00001150void ASTStmtReader::VisitCXXPseudoDestructorExpr(CXXPseudoDestructorExpr *E) {
Argyrios Kyrtzidisde4bd182010-06-28 09:32:03 +00001151 VisitExpr(E);
1152
Douglas Gregorf3db29f2011-02-25 18:19:59 +00001153 E->Base = Reader.ReadSubExpr();
1154 E->IsArrow = Record[Idx++];
1155 E->OperatorLoc = ReadSourceLocation(Record, Idx);
1156 E->QualifierLoc = Reader.ReadNestedNameSpecifierLoc(F, Record, Idx);
1157 E->ScopeType = GetTypeSourceInfo(Record, Idx);
1158 E->ColonColonLoc = ReadSourceLocation(Record, Idx);
1159 E->TildeLoc = ReadSourceLocation(Record, Idx);
Argyrios Kyrtzidisde4bd182010-06-28 09:32:03 +00001160
Douglas Gregor95eab172011-07-28 20:55:49 +00001161 IdentifierInfo *II = Reader.GetIdentifierInfo(F, Record, Idx);
Argyrios Kyrtzidisde4bd182010-06-28 09:32:03 +00001162 if (II)
Sebastian Redlc3632732010-10-05 15:59:54 +00001163 E->setDestroyedType(II, ReadSourceLocation(Record, Idx));
Argyrios Kyrtzidisde4bd182010-06-28 09:32:03 +00001164 else
Sebastian Redlc3632732010-10-05 15:59:54 +00001165 E->setDestroyedType(GetTypeSourceInfo(Record, Idx));
Argyrios Kyrtzidisde4bd182010-06-28 09:32:03 +00001166}
1167
John McCall4765fa02010-12-06 08:20:24 +00001168void ASTStmtReader::VisitExprWithCleanups(ExprWithCleanups *E) {
Chris Lattnerd2598362010-05-10 00:25:06 +00001169 VisitExpr(E);
1170 unsigned NumTemps = Record[Idx++];
1171 if (NumTemps) {
Douglas Gregor35942772011-09-09 21:34:22 +00001172 E->setNumTemporaries(Reader.getContext(), NumTemps);
Chris Lattnerd2598362010-05-10 00:25:06 +00001173 for (unsigned i = 0; i != NumTemps; ++i)
Douglas Gregor409448c2011-07-21 22:35:25 +00001174 E->setTemporary(i, Reader.ReadCXXTemporary(F, Record, Idx));
Chris Lattnerd2598362010-05-10 00:25:06 +00001175 }
Argyrios Kyrtzidisd98a2ab2010-06-29 22:46:25 +00001176 E->setSubExpr(Reader.ReadSubExpr());
Chris Lattner030854b2010-05-09 06:40:08 +00001177}
1178
Argyrios Kyrtzidis919e6932010-06-28 22:28:35 +00001179void
Sebastian Redl60adf4a2010-08-18 23:56:52 +00001180ASTStmtReader::VisitCXXDependentScopeMemberExpr(CXXDependentScopeMemberExpr *E){
Argyrios Kyrtzidis8dfbd8b2010-06-24 08:57:31 +00001181 VisitExpr(E);
1182
Douglas Gregordef03542011-02-04 12:01:24 +00001183 if (Record[Idx++])
John McCall096832c2010-08-19 23:49:38 +00001184 ReadExplicitTemplateArgumentList(E->getExplicitTemplateArgs(),
Douglas Gregordef03542011-02-04 12:01:24 +00001185 Record[Idx++]);
Argyrios Kyrtzidis8dfbd8b2010-06-24 08:57:31 +00001186
Douglas Gregor7c3179c2011-02-28 18:50:33 +00001187 E->Base = Reader.ReadSubExpr();
Douglas Gregor393f2492011-07-22 00:38:23 +00001188 E->BaseType = Reader.readType(F, Record, Idx);
Douglas Gregor7c3179c2011-02-28 18:50:33 +00001189 E->IsArrow = Record[Idx++];
1190 E->OperatorLoc = ReadSourceLocation(Record, Idx);
1191 E->QualifierLoc = Reader.ReadNestedNameSpecifierLoc(F, Record, Idx);
Douglas Gregor409448c2011-07-21 22:35:25 +00001192 E->FirstQualifierFoundInScope = ReadDeclAs<NamedDecl>(Record, Idx);
Argyrios Kyrtzidis40451072010-10-15 18:21:24 +00001193 ReadDeclarationNameInfo(E->MemberNameInfo, Record, Idx);
Argyrios Kyrtzidis8dfbd8b2010-06-24 08:57:31 +00001194}
1195
Argyrios Kyrtzidis919e6932010-06-28 22:28:35 +00001196void
Sebastian Redl60adf4a2010-08-18 23:56:52 +00001197ASTStmtReader::VisitDependentScopeDeclRefExpr(DependentScopeDeclRefExpr *E) {
Argyrios Kyrtzidis12dffcd2010-06-28 09:31:56 +00001198 VisitExpr(E);
Argyrios Kyrtzidis12dffcd2010-06-28 09:31:56 +00001199
Douglas Gregordef03542011-02-04 12:01:24 +00001200 if (Record[Idx++])
1201 ReadExplicitTemplateArgumentList(E->getExplicitTemplateArgs(),
1202 Record[Idx++]);
Douglas Gregor00cf3cc2011-02-25 20:49:16 +00001203
1204 E->QualifierLoc = Reader.ReadNestedNameSpecifierLoc(F, Record, Idx);
Argyrios Kyrtzidis40451072010-10-15 18:21:24 +00001205 ReadDeclarationNameInfo(E->NameInfo, Record, Idx);
Argyrios Kyrtzidis12dffcd2010-06-28 09:31:56 +00001206}
1207
Argyrios Kyrtzidis919e6932010-06-28 22:28:35 +00001208void
Sebastian Redl60adf4a2010-08-18 23:56:52 +00001209ASTStmtReader::VisitCXXUnresolvedConstructExpr(CXXUnresolvedConstructExpr *E) {
Argyrios Kyrtzidis8dfbd8b2010-06-24 08:57:31 +00001210 VisitExpr(E);
1211 assert(Record[Idx] == E->arg_size() && "Read wrong record during creation ?");
1212 ++Idx; // NumArgs;
1213 for (unsigned I = 0, N = E->arg_size(); I != N; ++I)
Argyrios Kyrtzidisd98a2ab2010-06-29 22:46:25 +00001214 E->setArg(I, Reader.ReadSubExpr());
Sebastian Redlc3632732010-10-05 15:59:54 +00001215 E->Type = GetTypeSourceInfo(Record, Idx);
1216 E->setLParenLoc(ReadSourceLocation(Record, Idx));
1217 E->setRParenLoc(ReadSourceLocation(Record, Idx));
Argyrios Kyrtzidis8dfbd8b2010-06-24 08:57:31 +00001218}
1219
Sebastian Redl60adf4a2010-08-18 23:56:52 +00001220void ASTStmtReader::VisitOverloadExpr(OverloadExpr *E) {
Argyrios Kyrtzidisa77eb082010-06-25 09:03:26 +00001221 VisitExpr(E);
1222
Douglas Gregordef03542011-02-04 12:01:24 +00001223 // Read the explicit template argument list, if available.
1224 if (Record[Idx++])
Argyrios Kyrtzidis919e6932010-06-28 22:28:35 +00001225 ReadExplicitTemplateArgumentList(E->getExplicitTemplateArgs(),
Douglas Gregordef03542011-02-04 12:01:24 +00001226 Record[Idx++]);
Argyrios Kyrtzidisa77eb082010-06-25 09:03:26 +00001227
1228 unsigned NumDecls = Record[Idx++];
1229 UnresolvedSet<8> Decls;
1230 for (unsigned i = 0; i != NumDecls; ++i) {
Douglas Gregor409448c2011-07-21 22:35:25 +00001231 NamedDecl *D = ReadDeclAs<NamedDecl>(Record, Idx);
Argyrios Kyrtzidisa77eb082010-06-25 09:03:26 +00001232 AccessSpecifier AS = (AccessSpecifier)Record[Idx++];
1233 Decls.addDecl(D, AS);
1234 }
Douglas Gregor35942772011-09-09 21:34:22 +00001235 E->initializeResults(Reader.getContext(), Decls.begin(), Decls.end());
Argyrios Kyrtzidisa77eb082010-06-25 09:03:26 +00001236
Argyrios Kyrtzidis40451072010-10-15 18:21:24 +00001237 ReadDeclarationNameInfo(E->NameInfo, Record, Idx);
Douglas Gregor4c9be892011-02-28 20:01:57 +00001238 E->QualifierLoc = Reader.ReadNestedNameSpecifierLoc(F, Record, Idx);
Argyrios Kyrtzidisa77eb082010-06-25 09:03:26 +00001239}
1240
Sebastian Redl60adf4a2010-08-18 23:56:52 +00001241void ASTStmtReader::VisitUnresolvedMemberExpr(UnresolvedMemberExpr *E) {
Argyrios Kyrtzidis919e6932010-06-28 22:28:35 +00001242 VisitOverloadExpr(E);
Douglas Gregor4c9be892011-02-28 20:01:57 +00001243 E->IsArrow = Record[Idx++];
1244 E->HasUnresolvedUsing = Record[Idx++];
1245 E->Base = Reader.ReadSubExpr();
Douglas Gregor393f2492011-07-22 00:38:23 +00001246 E->BaseType = Reader.readType(F, Record, Idx);
Douglas Gregor4c9be892011-02-28 20:01:57 +00001247 E->OperatorLoc = ReadSourceLocation(Record, Idx);
Argyrios Kyrtzidisa77eb082010-06-25 09:03:26 +00001248}
1249
Sebastian Redl60adf4a2010-08-18 23:56:52 +00001250void ASTStmtReader::VisitUnresolvedLookupExpr(UnresolvedLookupExpr *E) {
Argyrios Kyrtzidis919e6932010-06-28 22:28:35 +00001251 VisitOverloadExpr(E);
Douglas Gregor4c9be892011-02-28 20:01:57 +00001252 E->RequiresADL = Record[Idx++];
Richard Smithad762fc2011-04-14 22:09:26 +00001253 if (E->RequiresADL)
1254 E->StdIsAssociatedNamespace = Record[Idx++];
Douglas Gregor4c9be892011-02-28 20:01:57 +00001255 E->Overloaded = Record[Idx++];
Douglas Gregor409448c2011-07-21 22:35:25 +00001256 E->NamingClass = ReadDeclAs<CXXRecordDecl>(Record, Idx);
Argyrios Kyrtzidisbd65bb52010-06-25 09:03:34 +00001257}
1258
Sebastian Redl60adf4a2010-08-18 23:56:52 +00001259void ASTStmtReader::VisitUnaryTypeTraitExpr(UnaryTypeTraitExpr *E) {
Argyrios Kyrtzidis6d00c132010-07-10 11:46:15 +00001260 VisitExpr(E);
1261 E->UTT = (UnaryTypeTrait)Record[Idx++];
Sebastian Redl0dfd8482010-09-13 20:56:31 +00001262 E->Value = (bool)Record[Idx++];
Sebastian Redlc3632732010-10-05 15:59:54 +00001263 SourceRange Range = ReadSourceRange(Record, Idx);
Argyrios Kyrtzidis6d00c132010-07-10 11:46:15 +00001264 E->Loc = Range.getBegin();
1265 E->RParen = Range.getEnd();
Sebastian Redlc3632732010-10-05 15:59:54 +00001266 E->QueriedType = GetTypeSourceInfo(Record, Idx);
Argyrios Kyrtzidis6d00c132010-07-10 11:46:15 +00001267}
1268
Francois Pichet6ad6f282010-12-07 00:08:36 +00001269void ASTStmtReader::VisitBinaryTypeTraitExpr(BinaryTypeTraitExpr *E) {
1270 VisitExpr(E);
1271 E->BTT = (BinaryTypeTrait)Record[Idx++];
1272 E->Value = (bool)Record[Idx++];
1273 SourceRange Range = ReadSourceRange(Record, Idx);
1274 E->Loc = Range.getBegin();
1275 E->RParen = Range.getEnd();
1276 E->LhsType = GetTypeSourceInfo(Record, Idx);
1277 E->RhsType = GetTypeSourceInfo(Record, Idx);
1278}
1279
John Wiegley21ff2e52011-04-28 00:16:57 +00001280void ASTStmtReader::VisitArrayTypeTraitExpr(ArrayTypeTraitExpr *E) {
1281 VisitExpr(E);
1282 E->ATT = (ArrayTypeTrait)Record[Idx++];
1283 E->Value = (unsigned int)Record[Idx++];
1284 SourceRange Range = ReadSourceRange(Record, Idx);
1285 E->Loc = Range.getBegin();
1286 E->RParen = Range.getEnd();
1287 E->QueriedType = GetTypeSourceInfo(Record, Idx);
1288}
1289
John Wiegley55262202011-04-25 06:54:41 +00001290void ASTStmtReader::VisitExpressionTraitExpr(ExpressionTraitExpr *E) {
1291 VisitExpr(E);
1292 E->ET = (ExpressionTrait)Record[Idx++];
1293 E->Value = (bool)Record[Idx++];
1294 SourceRange Range = ReadSourceRange(Record, Idx);
1295 E->QueriedExpression = Reader.ReadSubExpr();
1296 E->Loc = Range.getBegin();
1297 E->RParen = Range.getEnd();
1298}
1299
Sebastian Redl6b219d02010-09-10 20:55:54 +00001300void ASTStmtReader::VisitCXXNoexceptExpr(CXXNoexceptExpr *E) {
1301 VisitExpr(E);
Sebastian Redl5221d8f2010-09-10 22:34:40 +00001302 E->Value = (bool)Record[Idx++];
Sebastian Redlc3632732010-10-05 15:59:54 +00001303 E->Range = ReadSourceRange(Record, Idx);
Sebastian Redl5221d8f2010-09-10 22:34:40 +00001304 E->Operand = Reader.ReadSubExpr();
Sebastian Redl6b219d02010-09-10 20:55:54 +00001305}
1306
Douglas Gregorbe230c32011-01-03 17:17:50 +00001307void ASTStmtReader::VisitPackExpansionExpr(PackExpansionExpr *E) {
1308 VisitExpr(E);
1309 E->EllipsisLoc = ReadSourceLocation(Record, Idx);
Douglas Gregor67fd1252011-01-14 21:20:45 +00001310 E->NumExpansions = Record[Idx++];
Douglas Gregorbe230c32011-01-03 17:17:50 +00001311 E->Pattern = Reader.ReadSubExpr();
1312}
1313
Douglas Gregoree8aff02011-01-04 17:33:58 +00001314void ASTStmtReader::VisitSizeOfPackExpr(SizeOfPackExpr *E) {
1315 VisitExpr(E);
1316 E->OperatorLoc = ReadSourceLocation(Record, Idx);
1317 E->PackLoc = ReadSourceLocation(Record, Idx);
1318 E->RParenLoc = ReadSourceLocation(Record, Idx);
1319 E->Length = Record[Idx++];
Douglas Gregor409448c2011-07-21 22:35:25 +00001320 E->Pack = ReadDeclAs<NamedDecl>(Record, Idx);
Douglas Gregoree8aff02011-01-04 17:33:58 +00001321}
1322
John McCall7110fd62011-07-15 07:00:14 +00001323void ASTStmtReader::VisitSubstNonTypeTemplateParmExpr(
1324 SubstNonTypeTemplateParmExpr *E) {
1325 VisitExpr(E);
Douglas Gregor409448c2011-07-21 22:35:25 +00001326 E->Param = ReadDeclAs<NonTypeTemplateParmDecl>(Record, Idx);
John McCall7110fd62011-07-15 07:00:14 +00001327 E->NameLoc = ReadSourceLocation(Record, Idx);
1328 E->Replacement = Reader.ReadSubExpr();
1329}
1330
Douglas Gregorc7793c72011-01-15 01:15:58 +00001331void ASTStmtReader::VisitSubstNonTypeTemplateParmPackExpr(
1332 SubstNonTypeTemplateParmPackExpr *E) {
1333 VisitExpr(E);
Douglas Gregor409448c2011-07-21 22:35:25 +00001334 E->Param = ReadDeclAs<NonTypeTemplateParmDecl>(Record, Idx);
Douglas Gregorc7793c72011-01-15 01:15:58 +00001335 TemplateArgument ArgPack = Reader.ReadTemplateArgument(F, Record, Idx);
1336 if (ArgPack.getKind() != TemplateArgument::Pack)
1337 return;
1338
1339 E->Arguments = ArgPack.pack_begin();
1340 E->NumArguments = ArgPack.pack_size();
1341 E->NameLoc = ReadSourceLocation(Record, Idx);
1342}
1343
Douglas Gregor03e80032011-06-21 17:03:29 +00001344void ASTStmtReader::VisitMaterializeTemporaryExpr(MaterializeTemporaryExpr *E) {
1345 VisitExpr(E);
1346 E->Temporary = Reader.ReadSubExpr();
1347}
1348
John McCall7cd7d1a2010-11-15 23:31:06 +00001349void ASTStmtReader::VisitOpaqueValueExpr(OpaqueValueExpr *E) {
1350 VisitExpr(E);
John McCall56ca35d2011-02-17 10:25:35 +00001351 Idx++; // skip ID
Douglas Gregorb608b982011-01-28 02:26:04 +00001352 E->Loc = ReadSourceLocation(Record, Idx);
John McCall7cd7d1a2010-11-15 23:31:06 +00001353}
1354
Peter Collingbournee08ce652011-02-09 21:07:24 +00001355//===----------------------------------------------------------------------===//
John McCall7110fd62011-07-15 07:00:14 +00001356// Microsoft Expressions and Statements
1357//===----------------------------------------------------------------------===//
1358void ASTStmtReader::VisitCXXUuidofExpr(CXXUuidofExpr *E) {
1359 VisitExpr(E);
1360 E->setSourceRange(ReadSourceRange(Record, Idx));
1361 if (E->isTypeOperand()) { // __uuidof(ComType)
1362 E->setTypeOperandSourceInfo(
1363 GetTypeSourceInfo(Record, Idx));
1364 return;
1365 }
1366
1367 // __uuidof(expr)
1368 E->setExprOperand(Reader.ReadSubExpr());
1369}
1370
1371void ASTStmtReader::VisitSEHExceptStmt(SEHExceptStmt *S) {
1372 VisitStmt(S);
1373 S->Loc = ReadSourceLocation(Record, Idx);
1374 S->Children[SEHExceptStmt::FILTER_EXPR] = Reader.ReadSubStmt();
1375 S->Children[SEHExceptStmt::BLOCK] = Reader.ReadSubStmt();
1376}
1377
1378void ASTStmtReader::VisitSEHFinallyStmt(SEHFinallyStmt *S) {
1379 VisitStmt(S);
1380 S->Loc = ReadSourceLocation(Record, Idx);
1381 S->Block = Reader.ReadSubStmt();
1382}
1383
1384void ASTStmtReader::VisitSEHTryStmt(SEHTryStmt *S) {
1385 VisitStmt(S);
1386 S->IsCXXTry = Record[Idx++];
1387 S->TryLoc = ReadSourceLocation(Record, Idx);
1388 S->Children[SEHTryStmt::TRY] = Reader.ReadSubStmt();
1389 S->Children[SEHTryStmt::HANDLER] = Reader.ReadSubStmt();
1390}
1391
1392//===----------------------------------------------------------------------===//
Peter Collingbournee08ce652011-02-09 21:07:24 +00001393// CUDA Expressions and Statements
1394//===----------------------------------------------------------------------===//
1395
1396void ASTStmtReader::VisitCUDAKernelCallExpr(CUDAKernelCallExpr *E) {
1397 VisitCallExpr(E);
1398 E->setConfig(cast<CallExpr>(Reader.ReadSubExpr()));
1399}
1400
John McCall7110fd62011-07-15 07:00:14 +00001401//===----------------------------------------------------------------------===//
1402// OpenCL Expressions and Statements.
1403//===----------------------------------------------------------------------===//
1404void ASTStmtReader::VisitAsTypeExpr(AsTypeExpr *E) {
1405 VisitExpr(E);
1406 E->BuiltinLoc = ReadSourceLocation(Record, Idx);
1407 E->RParenLoc = ReadSourceLocation(Record, Idx);
1408 E->SrcExpr = Reader.ReadSubExpr();
1409}
1410
1411//===----------------------------------------------------------------------===//
1412// ASTReader Implementation
1413//===----------------------------------------------------------------------===//
1414
Douglas Gregor72a9ae12011-07-22 16:00:58 +00001415Stmt *ASTReader::ReadStmt(Module &F) {
Argyrios Kyrtzidis919e6932010-06-28 22:28:35 +00001416 switch (ReadingKind) {
1417 case Read_Decl:
1418 case Read_Type:
Sebastian Redlc3632732010-10-05 15:59:54 +00001419 return ReadStmtFromStream(F);
Argyrios Kyrtzidis919e6932010-06-28 22:28:35 +00001420 case Read_Stmt:
Argyrios Kyrtzidisd98a2ab2010-06-29 22:46:25 +00001421 return ReadSubStmt();
Argyrios Kyrtzidis919e6932010-06-28 22:28:35 +00001422 }
1423
1424 llvm_unreachable("ReadingKind not set ?");
1425 return 0;
1426}
1427
Douglas Gregor72a9ae12011-07-22 16:00:58 +00001428Expr *ASTReader::ReadExpr(Module &F) {
Sebastian Redlc3632732010-10-05 15:59:54 +00001429 return cast_or_null<Expr>(ReadStmt(F));
Argyrios Kyrtzidis919e6932010-06-28 22:28:35 +00001430}
Chris Lattner030854b2010-05-09 06:40:08 +00001431
Sebastian Redlc43b54c2010-08-18 23:56:43 +00001432Expr *ASTReader::ReadSubExpr() {
Argyrios Kyrtzidisd98a2ab2010-06-29 22:46:25 +00001433 return cast_or_null<Expr>(ReadSubStmt());
1434}
1435
Chris Lattner52e97d12009-04-27 05:41:06 +00001436// Within the bitstream, expressions are stored in Reverse Polish
1437// Notation, with each of the subexpressions preceding the
Argyrios Kyrtzidis919e6932010-06-28 22:28:35 +00001438// expression they are stored in. Subexpressions are stored from last to first.
1439// To evaluate expressions, we continue reading expressions and placing them on
1440// the stack, with expressions having operands removing those operands from the
Chris Lattner52e97d12009-04-27 05:41:06 +00001441// stack. Evaluation terminates when we see a STMT_STOP record, and
1442// the single remaining expression on the stack is our result.
Douglas Gregor72a9ae12011-07-22 16:00:58 +00001443Stmt *ASTReader::ReadStmtFromStream(Module &F) {
Argyrios Kyrtzidis919e6932010-06-28 22:28:35 +00001444
1445 ReadingKindTracker ReadingKind(Read_Stmt, *this);
Sebastian Redlc3632732010-10-05 15:59:54 +00001446 llvm::BitstreamCursor &Cursor = F.DeclsCursor;
1447
Argyrios Kyrtzidis919e6932010-06-28 22:28:35 +00001448#ifndef NDEBUG
1449 unsigned PrevNumStmts = StmtStack.size();
1450#endif
1451
Chris Lattner4c6f9522009-04-27 05:14:47 +00001452 RecordData Record;
1453 unsigned Idx;
Sebastian Redlc3632732010-10-05 15:59:54 +00001454 ASTStmtReader Reader(*this, F, Cursor, Record, Idx);
Chris Lattner4c6f9522009-04-27 05:14:47 +00001455 Stmt::EmptyShell Empty;
1456
1457 while (true) {
Chris Lattner52e97d12009-04-27 05:41:06 +00001458 unsigned Code = Cursor.ReadCode();
Chris Lattner4c6f9522009-04-27 05:14:47 +00001459 if (Code == llvm::bitc::END_BLOCK) {
Chris Lattner52e97d12009-04-27 05:41:06 +00001460 if (Cursor.ReadBlockEnd()) {
Sebastian Redl3c7f4132010-08-18 23:57:06 +00001461 Error("error at end of block in AST file");
Chris Lattner4c6f9522009-04-27 05:14:47 +00001462 return 0;
1463 }
1464 break;
1465 }
1466
1467 if (Code == llvm::bitc::ENTER_SUBBLOCK) {
1468 // No known subblocks, always skip them.
Chris Lattner52e97d12009-04-27 05:41:06 +00001469 Cursor.ReadSubBlockID();
1470 if (Cursor.SkipBlock()) {
Sebastian Redl3c7f4132010-08-18 23:57:06 +00001471 Error("malformed block record in AST file");
Chris Lattner4c6f9522009-04-27 05:14:47 +00001472 return 0;
1473 }
1474 continue;
1475 }
1476
1477 if (Code == llvm::bitc::DEFINE_ABBREV) {
Chris Lattner52e97d12009-04-27 05:41:06 +00001478 Cursor.ReadAbbrevRecord();
Chris Lattner4c6f9522009-04-27 05:14:47 +00001479 continue;
1480 }
1481
1482 Stmt *S = 0;
1483 Idx = 0;
1484 Record.clear();
1485 bool Finished = false;
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001486 switch ((StmtCode)Cursor.ReadRecord(Code, Record)) {
1487 case STMT_STOP:
Chris Lattner4c6f9522009-04-27 05:14:47 +00001488 Finished = true;
1489 break;
1490
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001491 case STMT_NULL_PTR:
Mike Stump1eb44332009-09-09 15:08:12 +00001492 S = 0;
Chris Lattner4c6f9522009-04-27 05:14:47 +00001493 break;
1494
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001495 case STMT_NULL:
Chris Lattner4c6f9522009-04-27 05:14:47 +00001496 S = new (Context) NullStmt(Empty);
1497 break;
1498
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001499 case STMT_COMPOUND:
Chris Lattner4c6f9522009-04-27 05:14:47 +00001500 S = new (Context) CompoundStmt(Empty);
1501 break;
1502
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001503 case STMT_CASE:
Chris Lattner4c6f9522009-04-27 05:14:47 +00001504 S = new (Context) CaseStmt(Empty);
1505 break;
1506
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001507 case STMT_DEFAULT:
Chris Lattner4c6f9522009-04-27 05:14:47 +00001508 S = new (Context) DefaultStmt(Empty);
1509 break;
1510
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001511 case STMT_LABEL:
Chris Lattner4c6f9522009-04-27 05:14:47 +00001512 S = new (Context) LabelStmt(Empty);
1513 break;
1514
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001515 case STMT_IF:
Chris Lattner4c6f9522009-04-27 05:14:47 +00001516 S = new (Context) IfStmt(Empty);
1517 break;
1518
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001519 case STMT_SWITCH:
Chris Lattner4c6f9522009-04-27 05:14:47 +00001520 S = new (Context) SwitchStmt(Empty);
1521 break;
1522
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001523 case STMT_WHILE:
Chris Lattner4c6f9522009-04-27 05:14:47 +00001524 S = new (Context) WhileStmt(Empty);
1525 break;
1526
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001527 case STMT_DO:
Chris Lattner4c6f9522009-04-27 05:14:47 +00001528 S = new (Context) DoStmt(Empty);
1529 break;
Mike Stump1eb44332009-09-09 15:08:12 +00001530
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001531 case STMT_FOR:
Chris Lattner4c6f9522009-04-27 05:14:47 +00001532 S = new (Context) ForStmt(Empty);
1533 break;
1534
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001535 case STMT_GOTO:
Chris Lattner4c6f9522009-04-27 05:14:47 +00001536 S = new (Context) GotoStmt(Empty);
1537 break;
Mike Stump1eb44332009-09-09 15:08:12 +00001538
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001539 case STMT_INDIRECT_GOTO:
Chris Lattner4c6f9522009-04-27 05:14:47 +00001540 S = new (Context) IndirectGotoStmt(Empty);
1541 break;
1542
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001543 case STMT_CONTINUE:
Chris Lattner4c6f9522009-04-27 05:14:47 +00001544 S = new (Context) ContinueStmt(Empty);
1545 break;
1546
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001547 case STMT_BREAK:
Chris Lattner4c6f9522009-04-27 05:14:47 +00001548 S = new (Context) BreakStmt(Empty);
1549 break;
1550
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001551 case STMT_RETURN:
Chris Lattner4c6f9522009-04-27 05:14:47 +00001552 S = new (Context) ReturnStmt(Empty);
1553 break;
1554
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001555 case STMT_DECL:
Chris Lattner4c6f9522009-04-27 05:14:47 +00001556 S = new (Context) DeclStmt(Empty);
1557 break;
1558
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001559 case STMT_ASM:
Chris Lattner4c6f9522009-04-27 05:14:47 +00001560 S = new (Context) AsmStmt(Empty);
1561 break;
1562
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001563 case EXPR_PREDEFINED:
Chris Lattner4c6f9522009-04-27 05:14:47 +00001564 S = new (Context) PredefinedExpr(Empty);
1565 break;
Mike Stump1eb44332009-09-09 15:08:12 +00001566
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001567 case EXPR_DECL_REF:
Chandler Carruth3aa81402011-05-01 23:48:14 +00001568 S = DeclRefExpr::CreateEmpty(
Douglas Gregor35942772011-09-09 21:34:22 +00001569 Context,
Chandler Carruth3aa81402011-05-01 23:48:14 +00001570 /*HasQualifier=*/Record[ASTStmtReader::NumExprFields],
1571 /*HasFoundDecl=*/Record[ASTStmtReader::NumExprFields + 1],
1572 /*HasExplicitTemplateArgs=*/Record[ASTStmtReader::NumExprFields + 2],
1573 /*NumTemplateArgs=*/Record[ASTStmtReader::NumExprFields + 2] ?
Abramo Bagnara7cc58b42011-10-05 07:56:41 +00001574 Record[ASTStmtReader::NumExprFields + 4] : 0);
Chris Lattner4c6f9522009-04-27 05:14:47 +00001575 break;
Mike Stump1eb44332009-09-09 15:08:12 +00001576
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001577 case EXPR_INTEGER_LITERAL:
Douglas Gregor35942772011-09-09 21:34:22 +00001578 S = IntegerLiteral::Create(Context, Empty);
Chris Lattner4c6f9522009-04-27 05:14:47 +00001579 break;
Mike Stump1eb44332009-09-09 15:08:12 +00001580
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001581 case EXPR_FLOATING_LITERAL:
Douglas Gregor35942772011-09-09 21:34:22 +00001582 S = FloatingLiteral::Create(Context, Empty);
Chris Lattner4c6f9522009-04-27 05:14:47 +00001583 break;
Mike Stump1eb44332009-09-09 15:08:12 +00001584
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001585 case EXPR_IMAGINARY_LITERAL:
Chris Lattner4c6f9522009-04-27 05:14:47 +00001586 S = new (Context) ImaginaryLiteral(Empty);
1587 break;
1588
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001589 case EXPR_STRING_LITERAL:
Douglas Gregor35942772011-09-09 21:34:22 +00001590 S = StringLiteral::CreateEmpty(Context,
Sebastian Redl60adf4a2010-08-18 23:56:52 +00001591 Record[ASTStmtReader::NumExprFields + 1]);
Chris Lattner4c6f9522009-04-27 05:14:47 +00001592 break;
1593
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001594 case EXPR_CHARACTER_LITERAL:
Chris Lattner4c6f9522009-04-27 05:14:47 +00001595 S = new (Context) CharacterLiteral(Empty);
1596 break;
1597
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001598 case EXPR_PAREN:
Chris Lattner4c6f9522009-04-27 05:14:47 +00001599 S = new (Context) ParenExpr(Empty);
1600 break;
1601
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001602 case EXPR_PAREN_LIST:
Argyrios Kyrtzidis37bdfe22010-06-30 08:49:18 +00001603 S = new (Context) ParenListExpr(Empty);
1604 break;
1605
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001606 case EXPR_UNARY_OPERATOR:
Chris Lattner4c6f9522009-04-27 05:14:47 +00001607 S = new (Context) UnaryOperator(Empty);
1608 break;
1609
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001610 case EXPR_OFFSETOF:
Douglas Gregor35942772011-09-09 21:34:22 +00001611 S = OffsetOfExpr::CreateEmpty(Context,
Sebastian Redl60adf4a2010-08-18 23:56:52 +00001612 Record[ASTStmtReader::NumExprFields],
1613 Record[ASTStmtReader::NumExprFields + 1]);
Douglas Gregor8ecdb652010-04-28 22:16:22 +00001614 break;
1615
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001616 case EXPR_SIZEOF_ALIGN_OF:
Peter Collingbournef4e3cfb2011-03-11 19:24:49 +00001617 S = new (Context) UnaryExprOrTypeTraitExpr(Empty);
Chris Lattner4c6f9522009-04-27 05:14:47 +00001618 break;
1619
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001620 case EXPR_ARRAY_SUBSCRIPT:
Chris Lattner4c6f9522009-04-27 05:14:47 +00001621 S = new (Context) ArraySubscriptExpr(Empty);
1622 break;
1623
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001624 case EXPR_CALL:
Douglas Gregor35942772011-09-09 21:34:22 +00001625 S = new (Context) CallExpr(Context, Stmt::CallExprClass, Empty);
Chris Lattner4c6f9522009-04-27 05:14:47 +00001626 break;
1627
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001628 case EXPR_MEMBER: {
Argyrios Kyrtzidis663e3802010-07-08 13:09:47 +00001629 // We load everything here and fully initialize it at creation.
1630 // That way we can use MemberExpr::Create and don't have to duplicate its
1631 // logic with a MemberExpr::CreateEmpty.
1632
1633 assert(Idx == 0);
Douglas Gregor40d96a62011-02-28 21:54:11 +00001634 NestedNameSpecifierLoc QualifierLoc;
Argyrios Kyrtzidis663e3802010-07-08 13:09:47 +00001635 if (Record[Idx++]) { // HasQualifier.
Douglas Gregor40d96a62011-02-28 21:54:11 +00001636 QualifierLoc = ReadNestedNameSpecifierLoc(F, Record, Idx);
Argyrios Kyrtzidis663e3802010-07-08 13:09:47 +00001637 }
1638
1639 TemplateArgumentListInfo ArgInfo;
Douglas Gregordef03542011-02-04 12:01:24 +00001640 bool HasExplicitTemplateArgs = Record[Idx++];
1641 if (HasExplicitTemplateArgs) {
1642 unsigned NumTemplateArgs = Record[Idx++];
Sebastian Redlc3632732010-10-05 15:59:54 +00001643 ArgInfo.setLAngleLoc(ReadSourceLocation(F, Record, Idx));
1644 ArgInfo.setRAngleLoc(ReadSourceLocation(F, Record, Idx));
Argyrios Kyrtzidis663e3802010-07-08 13:09:47 +00001645 for (unsigned i = 0; i != NumTemplateArgs; ++i)
Sebastian Redlc3632732010-10-05 15:59:54 +00001646 ArgInfo.addArgument(ReadTemplateArgumentLoc(F, Record, Idx));
Argyrios Kyrtzidis663e3802010-07-08 13:09:47 +00001647 }
Abramo Bagnara7cc58b42011-10-05 07:56:41 +00001648
1649 bool HadMultipleCandidates = Record[Idx++];
1650
Douglas Gregor409448c2011-07-21 22:35:25 +00001651 NamedDecl *FoundD = ReadDeclAs<NamedDecl>(F, Record, Idx);
Argyrios Kyrtzidis663e3802010-07-08 13:09:47 +00001652 AccessSpecifier AS = (AccessSpecifier)Record[Idx++];
1653 DeclAccessPair FoundDecl = DeclAccessPair::make(FoundD, AS);
1654
Douglas Gregor393f2492011-07-22 00:38:23 +00001655 QualType T = readType(F, Record, Idx);
John McCallf89e55a2010-11-18 06:31:45 +00001656 ExprValueKind VK = static_cast<ExprValueKind>(Record[Idx++]);
1657 ExprObjectKind OK = static_cast<ExprObjectKind>(Record[Idx++]);
Argyrios Kyrtzidis663e3802010-07-08 13:09:47 +00001658 Expr *Base = ReadSubExpr();
Douglas Gregor409448c2011-07-21 22:35:25 +00001659 ValueDecl *MemberD = ReadDeclAs<ValueDecl>(F, Record, Idx);
Sebastian Redlc3632732010-10-05 15:59:54 +00001660 SourceLocation MemberLoc = ReadSourceLocation(F, Record, Idx);
Abramo Bagnara25777432010-08-11 22:01:17 +00001661 DeclarationNameInfo MemberNameInfo(MemberD->getDeclName(), MemberLoc);
Argyrios Kyrtzidis663e3802010-07-08 13:09:47 +00001662 bool IsArrow = Record[Idx++];
1663
Douglas Gregor35942772011-09-09 21:34:22 +00001664 S = MemberExpr::Create(Context, Base, IsArrow, QualifierLoc,
Abramo Bagnara25777432010-08-11 22:01:17 +00001665 MemberD, FoundDecl, MemberNameInfo,
Douglas Gregordef03542011-02-04 12:01:24 +00001666 HasExplicitTemplateArgs ? &ArgInfo : 0, T, VK, OK);
Argyrios Kyrtzidis40451072010-10-15 18:21:24 +00001667 ReadDeclarationNameLoc(F, cast<MemberExpr>(S)->MemberDNLoc,
1668 MemberD->getDeclName(), Record, Idx);
Abramo Bagnara7cc58b42011-10-05 07:56:41 +00001669 if (HadMultipleCandidates)
1670 cast<MemberExpr>(S)->setHadMultipleCandidates(true);
Chris Lattner4c6f9522009-04-27 05:14:47 +00001671 break;
Argyrios Kyrtzidis663e3802010-07-08 13:09:47 +00001672 }
Chris Lattner4c6f9522009-04-27 05:14:47 +00001673
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001674 case EXPR_BINARY_OPERATOR:
Chris Lattner4c6f9522009-04-27 05:14:47 +00001675 S = new (Context) BinaryOperator(Empty);
1676 break;
1677
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001678 case EXPR_COMPOUND_ASSIGN_OPERATOR:
Chris Lattner4c6f9522009-04-27 05:14:47 +00001679 S = new (Context) CompoundAssignOperator(Empty);
1680 break;
1681
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001682 case EXPR_CONDITIONAL_OPERATOR:
Chris Lattner4c6f9522009-04-27 05:14:47 +00001683 S = new (Context) ConditionalOperator(Empty);
1684 break;
1685
John McCall56ca35d2011-02-17 10:25:35 +00001686 case EXPR_BINARY_CONDITIONAL_OPERATOR:
1687 S = new (Context) BinaryConditionalOperator(Empty);
1688 break;
1689
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001690 case EXPR_IMPLICIT_CAST:
Douglas Gregor35942772011-09-09 21:34:22 +00001691 S = ImplicitCastExpr::CreateEmpty(Context,
Sebastian Redl60adf4a2010-08-18 23:56:52 +00001692 /*PathSize*/ Record[ASTStmtReader::NumExprFields]);
Chris Lattner4c6f9522009-04-27 05:14:47 +00001693 break;
1694
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001695 case EXPR_CSTYLE_CAST:
Douglas Gregor35942772011-09-09 21:34:22 +00001696 S = CStyleCastExpr::CreateEmpty(Context,
Sebastian Redl60adf4a2010-08-18 23:56:52 +00001697 /*PathSize*/ Record[ASTStmtReader::NumExprFields]);
Chris Lattner4c6f9522009-04-27 05:14:47 +00001698 break;
1699
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001700 case EXPR_COMPOUND_LITERAL:
Chris Lattner4c6f9522009-04-27 05:14:47 +00001701 S = new (Context) CompoundLiteralExpr(Empty);
1702 break;
1703
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001704 case EXPR_EXT_VECTOR_ELEMENT:
Chris Lattner4c6f9522009-04-27 05:14:47 +00001705 S = new (Context) ExtVectorElementExpr(Empty);
1706 break;
1707
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001708 case EXPR_INIT_LIST:
Douglas Gregor35942772011-09-09 21:34:22 +00001709 S = new (Context) InitListExpr(getContext(), Empty);
Chris Lattner4c6f9522009-04-27 05:14:47 +00001710 break;
1711
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001712 case EXPR_DESIGNATED_INIT:
Douglas Gregor35942772011-09-09 21:34:22 +00001713 S = DesignatedInitExpr::CreateEmpty(Context,
Sebastian Redl60adf4a2010-08-18 23:56:52 +00001714 Record[ASTStmtReader::NumExprFields] - 1);
Mike Stump1eb44332009-09-09 15:08:12 +00001715
Chris Lattner4c6f9522009-04-27 05:14:47 +00001716 break;
1717
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001718 case EXPR_IMPLICIT_VALUE_INIT:
Chris Lattner4c6f9522009-04-27 05:14:47 +00001719 S = new (Context) ImplicitValueInitExpr(Empty);
1720 break;
1721
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001722 case EXPR_VA_ARG:
Chris Lattner4c6f9522009-04-27 05:14:47 +00001723 S = new (Context) VAArgExpr(Empty);
1724 break;
1725
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001726 case EXPR_ADDR_LABEL:
Chris Lattner4c6f9522009-04-27 05:14:47 +00001727 S = new (Context) AddrLabelExpr(Empty);
1728 break;
1729
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001730 case EXPR_STMT:
Chris Lattner4c6f9522009-04-27 05:14:47 +00001731 S = new (Context) StmtExpr(Empty);
1732 break;
1733
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001734 case EXPR_CHOOSE:
Chris Lattner4c6f9522009-04-27 05:14:47 +00001735 S = new (Context) ChooseExpr(Empty);
1736 break;
1737
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001738 case EXPR_GNU_NULL:
Chris Lattner4c6f9522009-04-27 05:14:47 +00001739 S = new (Context) GNUNullExpr(Empty);
1740 break;
1741
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001742 case EXPR_SHUFFLE_VECTOR:
Chris Lattner4c6f9522009-04-27 05:14:47 +00001743 S = new (Context) ShuffleVectorExpr(Empty);
1744 break;
Mike Stump1eb44332009-09-09 15:08:12 +00001745
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001746 case EXPR_BLOCK:
Chris Lattner4c6f9522009-04-27 05:14:47 +00001747 S = new (Context) BlockExpr(Empty);
1748 break;
1749
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001750 case EXPR_BLOCK_DECL_REF:
Chris Lattner4c6f9522009-04-27 05:14:47 +00001751 S = new (Context) BlockDeclRefExpr(Empty);
1752 break;
Mike Stump1eb44332009-09-09 15:08:12 +00001753
Peter Collingbournef111d932011-04-15 00:35:48 +00001754 case EXPR_GENERIC_SELECTION:
1755 S = new (Context) GenericSelectionExpr(Empty);
1756 break;
1757
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001758 case EXPR_OBJC_STRING_LITERAL:
Chris Lattner4c6f9522009-04-27 05:14:47 +00001759 S = new (Context) ObjCStringLiteral(Empty);
1760 break;
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001761 case EXPR_OBJC_ENCODE:
Chris Lattner4c6f9522009-04-27 05:14:47 +00001762 S = new (Context) ObjCEncodeExpr(Empty);
1763 break;
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001764 case EXPR_OBJC_SELECTOR_EXPR:
Chris Lattner4c6f9522009-04-27 05:14:47 +00001765 S = new (Context) ObjCSelectorExpr(Empty);
1766 break;
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001767 case EXPR_OBJC_PROTOCOL_EXPR:
Chris Lattner4c6f9522009-04-27 05:14:47 +00001768 S = new (Context) ObjCProtocolExpr(Empty);
1769 break;
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001770 case EXPR_OBJC_IVAR_REF_EXPR:
Chris Lattner4c6f9522009-04-27 05:14:47 +00001771 S = new (Context) ObjCIvarRefExpr(Empty);
1772 break;
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001773 case EXPR_OBJC_PROPERTY_REF_EXPR:
Chris Lattner4c6f9522009-04-27 05:14:47 +00001774 S = new (Context) ObjCPropertyRefExpr(Empty);
1775 break;
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001776 case EXPR_OBJC_KVC_REF_EXPR:
John McCall12f78a62010-12-02 01:19:52 +00001777 llvm_unreachable("mismatching AST file");
Chris Lattner4c6f9522009-04-27 05:14:47 +00001778 break;
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001779 case EXPR_OBJC_MESSAGE_EXPR:
Douglas Gregor35942772011-09-09 21:34:22 +00001780 S = ObjCMessageExpr::CreateEmpty(Context,
Argyrios Kyrtzidis20718082011-10-03 06:36:51 +00001781 Record[ASTStmtReader::NumExprFields],
1782 Record[ASTStmtReader::NumExprFields + 1]);
Chris Lattner4c6f9522009-04-27 05:14:47 +00001783 break;
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001784 case EXPR_OBJC_ISA:
Steve Narofff242b1b2009-07-24 17:54:45 +00001785 S = new (Context) ObjCIsaExpr(Empty);
1786 break;
John McCallf85e1932011-06-15 23:02:42 +00001787 case EXPR_OBJC_INDIRECT_COPY_RESTORE:
1788 S = new (Context) ObjCIndirectCopyRestoreExpr(Empty);
1789 break;
1790 case EXPR_OBJC_BRIDGED_CAST:
1791 S = new (Context) ObjCBridgedCastExpr(Empty);
1792 break;
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001793 case STMT_OBJC_FOR_COLLECTION:
Chris Lattner4c6f9522009-04-27 05:14:47 +00001794 S = new (Context) ObjCForCollectionStmt(Empty);
1795 break;
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001796 case STMT_OBJC_CATCH:
Chris Lattner4c6f9522009-04-27 05:14:47 +00001797 S = new (Context) ObjCAtCatchStmt(Empty);
1798 break;
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001799 case STMT_OBJC_FINALLY:
Chris Lattner4c6f9522009-04-27 05:14:47 +00001800 S = new (Context) ObjCAtFinallyStmt(Empty);
1801 break;
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001802 case STMT_OBJC_AT_TRY:
Douglas Gregor35942772011-09-09 21:34:22 +00001803 S = ObjCAtTryStmt::CreateEmpty(Context,
Sebastian Redl60adf4a2010-08-18 23:56:52 +00001804 Record[ASTStmtReader::NumStmtFields],
1805 Record[ASTStmtReader::NumStmtFields + 1]);
Chris Lattner4c6f9522009-04-27 05:14:47 +00001806 break;
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001807 case STMT_OBJC_AT_SYNCHRONIZED:
Chris Lattner4c6f9522009-04-27 05:14:47 +00001808 S = new (Context) ObjCAtSynchronizedStmt(Empty);
1809 break;
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001810 case STMT_OBJC_AT_THROW:
Chris Lattner4c6f9522009-04-27 05:14:47 +00001811 S = new (Context) ObjCAtThrowStmt(Empty);
1812 break;
John McCallf85e1932011-06-15 23:02:42 +00001813 case STMT_OBJC_AUTORELEASE_POOL:
1814 S = new (Context) ObjCAutoreleasePoolStmt(Empty);
1815 break;
John McCall7110fd62011-07-15 07:00:14 +00001816 case STMT_SEH_EXCEPT:
1817 S = new (Context) SEHExceptStmt(Empty);
1818 break;
1819 case STMT_SEH_FINALLY:
1820 S = new (Context) SEHFinallyStmt(Empty);
1821 break;
1822 case STMT_SEH_TRY:
1823 S = new (Context) SEHTryStmt(Empty);
1824 break;
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001825 case STMT_CXX_CATCH:
Argyrios Kyrtzidis7cb45e32010-07-22 16:03:56 +00001826 S = new (Context) CXXCatchStmt(Empty);
1827 break;
1828
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001829 case STMT_CXX_TRY:
Douglas Gregor35942772011-09-09 21:34:22 +00001830 S = CXXTryStmt::Create(Context, Empty,
Sebastian Redl60adf4a2010-08-18 23:56:52 +00001831 /*NumHandlers=*/Record[ASTStmtReader::NumStmtFields]);
Argyrios Kyrtzidis7cb45e32010-07-22 16:03:56 +00001832 break;
1833
Richard Smithad762fc2011-04-14 22:09:26 +00001834 case STMT_CXX_FOR_RANGE:
1835 S = new (Context) CXXForRangeStmt(Empty);
1836 break;
1837
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001838 case EXPR_CXX_OPERATOR_CALL:
Douglas Gregor35942772011-09-09 21:34:22 +00001839 S = new (Context) CXXOperatorCallExpr(Context, Empty);
Argyrios Kyrtzidisba0a9002009-07-14 03:19:21 +00001840 break;
Chris Lattner1817bd42010-05-09 05:36:05 +00001841
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001842 case EXPR_CXX_MEMBER_CALL:
Douglas Gregor35942772011-09-09 21:34:22 +00001843 S = new (Context) CXXMemberCallExpr(Context, Empty);
Chris Lattner1817bd42010-05-09 05:36:05 +00001844 break;
Douglas Gregor39da0b82009-09-09 23:08:42 +00001845
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001846 case EXPR_CXX_CONSTRUCT:
Argyrios Kyrtzidis6d00c132010-07-10 11:46:15 +00001847 S = new (Context) CXXConstructExpr(Empty);
1848 break;
1849
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001850 case EXPR_CXX_TEMPORARY_OBJECT:
Argyrios Kyrtzidis6d00c132010-07-10 11:46:15 +00001851 S = new (Context) CXXTemporaryObjectExpr(Empty);
Douglas Gregor39da0b82009-09-09 23:08:42 +00001852 break;
Sam Weinigce757a72010-01-16 21:21:01 +00001853
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001854 case EXPR_CXX_STATIC_CAST:
Douglas Gregor35942772011-09-09 21:34:22 +00001855 S = CXXStaticCastExpr::CreateEmpty(Context,
Sebastian Redl60adf4a2010-08-18 23:56:52 +00001856 /*PathSize*/ Record[ASTStmtReader::NumExprFields]);
Sam Weinigce757a72010-01-16 21:21:01 +00001857 break;
1858
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001859 case EXPR_CXX_DYNAMIC_CAST:
Douglas Gregor35942772011-09-09 21:34:22 +00001860 S = CXXDynamicCastExpr::CreateEmpty(Context,
Sebastian Redl60adf4a2010-08-18 23:56:52 +00001861 /*PathSize*/ Record[ASTStmtReader::NumExprFields]);
Sam Weinigce757a72010-01-16 21:21:01 +00001862 break;
1863
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001864 case EXPR_CXX_REINTERPRET_CAST:
Douglas Gregor35942772011-09-09 21:34:22 +00001865 S = CXXReinterpretCastExpr::CreateEmpty(Context,
Sebastian Redl60adf4a2010-08-18 23:56:52 +00001866 /*PathSize*/ Record[ASTStmtReader::NumExprFields]);
Sam Weinigce757a72010-01-16 21:21:01 +00001867 break;
1868
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001869 case EXPR_CXX_CONST_CAST:
Douglas Gregor35942772011-09-09 21:34:22 +00001870 S = CXXConstCastExpr::CreateEmpty(Context);
Sam Weinigce757a72010-01-16 21:21:01 +00001871 break;
1872
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001873 case EXPR_CXX_FUNCTIONAL_CAST:
Douglas Gregor35942772011-09-09 21:34:22 +00001874 S = CXXFunctionalCastExpr::CreateEmpty(Context,
Sebastian Redl60adf4a2010-08-18 23:56:52 +00001875 /*PathSize*/ Record[ASTStmtReader::NumExprFields]);
Sam Weinigce757a72010-01-16 21:21:01 +00001876 break;
1877
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001878 case EXPR_CXX_BOOL_LITERAL:
Sam Weinigeb7f9612010-02-07 06:32:43 +00001879 S = new (Context) CXXBoolLiteralExpr(Empty);
1880 break;
Sam Weinigce757a72010-01-16 21:21:01 +00001881
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001882 case EXPR_CXX_NULL_PTR_LITERAL:
Sam Weinigeb7f9612010-02-07 06:32:43 +00001883 S = new (Context) CXXNullPtrLiteralExpr(Empty);
1884 break;
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001885 case EXPR_CXX_TYPEID_EXPR:
Chris Lattner14ab24f2010-05-09 06:03:39 +00001886 S = new (Context) CXXTypeidExpr(Empty, true);
1887 break;
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001888 case EXPR_CXX_TYPEID_TYPE:
Chris Lattner14ab24f2010-05-09 06:03:39 +00001889 S = new (Context) CXXTypeidExpr(Empty, false);
1890 break;
Francois Pichet01b7c302010-09-08 12:20:18 +00001891 case EXPR_CXX_UUIDOF_EXPR:
1892 S = new (Context) CXXUuidofExpr(Empty, true);
1893 break;
1894 case EXPR_CXX_UUIDOF_TYPE:
1895 S = new (Context) CXXUuidofExpr(Empty, false);
1896 break;
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001897 case EXPR_CXX_THIS:
Chris Lattner2fbdfcd2010-05-09 06:15:05 +00001898 S = new (Context) CXXThisExpr(Empty);
1899 break;
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001900 case EXPR_CXX_THROW:
Chris Lattner2fbdfcd2010-05-09 06:15:05 +00001901 S = new (Context) CXXThrowExpr(Empty);
1902 break;
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001903 case EXPR_CXX_DEFAULT_ARG: {
Sebastian Redl60adf4a2010-08-18 23:56:52 +00001904 bool HasOtherExprStored = Record[ASTStmtReader::NumExprFields];
Argyrios Kyrtzidis8a507332010-07-02 23:30:15 +00001905 if (HasOtherExprStored) {
1906 Expr *SubExpr = ReadSubExpr();
Douglas Gregor35942772011-09-09 21:34:22 +00001907 S = CXXDefaultArgExpr::Create(Context, SourceLocation(), 0, SubExpr);
Argyrios Kyrtzidis8a507332010-07-02 23:30:15 +00001908 } else
1909 S = new (Context) CXXDefaultArgExpr(Empty);
Chris Lattner030854b2010-05-09 06:40:08 +00001910 break;
Argyrios Kyrtzidis8a507332010-07-02 23:30:15 +00001911 }
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001912 case EXPR_CXX_BIND_TEMPORARY:
Chris Lattnerd2598362010-05-10 00:25:06 +00001913 S = new (Context) CXXBindTemporaryExpr(Empty);
1914 break;
Douglas Gregore2ca6d42010-09-02 21:50:02 +00001915
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001916 case EXPR_CXX_SCALAR_VALUE_INIT:
Douglas Gregored8abf12010-07-08 06:14:04 +00001917 S = new (Context) CXXScalarValueInitExpr(Empty);
Chris Lattner59218632010-05-10 01:22:27 +00001918 break;
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001919 case EXPR_CXX_NEW:
Chris Lattner59218632010-05-10 01:22:27 +00001920 S = new (Context) CXXNewExpr(Empty);
1921 break;
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001922 case EXPR_CXX_DELETE:
Argyrios Kyrtzidis95fc98c2010-06-22 17:07:59 +00001923 S = new (Context) CXXDeleteExpr(Empty);
1924 break;
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001925 case EXPR_CXX_PSEUDO_DESTRUCTOR:
Argyrios Kyrtzidisde4bd182010-06-28 09:32:03 +00001926 S = new (Context) CXXPseudoDestructorExpr(Empty);
1927 break;
Chris Lattner59218632010-05-10 01:22:27 +00001928
John McCall4765fa02010-12-06 08:20:24 +00001929 case EXPR_EXPR_WITH_CLEANUPS:
1930 S = new (Context) ExprWithCleanups(Empty);
Chris Lattnerd2598362010-05-10 00:25:06 +00001931 break;
Argyrios Kyrtzidis8dfbd8b2010-06-24 08:57:31 +00001932
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001933 case EXPR_CXX_DEPENDENT_SCOPE_MEMBER:
Douglas Gregor35942772011-09-09 21:34:22 +00001934 S = CXXDependentScopeMemberExpr::CreateEmpty(Context,
Douglas Gregordef03542011-02-04 12:01:24 +00001935 /*HasExplicitTemplateArgs=*/Record[ASTStmtReader::NumExprFields],
1936 /*NumTemplateArgs=*/Record[ASTStmtReader::NumExprFields]
1937 ? Record[ASTStmtReader::NumExprFields + 1]
1938 : 0);
Argyrios Kyrtzidis8dfbd8b2010-06-24 08:57:31 +00001939 break;
1940
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001941 case EXPR_CXX_DEPENDENT_SCOPE_DECL_REF:
Douglas Gregor35942772011-09-09 21:34:22 +00001942 S = DependentScopeDeclRefExpr::CreateEmpty(Context,
Douglas Gregordef03542011-02-04 12:01:24 +00001943 /*HasExplicitTemplateArgs=*/Record[ASTStmtReader::NumExprFields],
1944 /*NumTemplateArgs=*/Record[ASTStmtReader::NumExprFields]
1945 ? Record[ASTStmtReader::NumExprFields + 1]
1946 : 0);
Argyrios Kyrtzidis12dffcd2010-06-28 09:31:56 +00001947 break;
1948
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001949 case EXPR_CXX_UNRESOLVED_CONSTRUCT:
Douglas Gregor35942772011-09-09 21:34:22 +00001950 S = CXXUnresolvedConstructExpr::CreateEmpty(Context,
Sebastian Redl60adf4a2010-08-18 23:56:52 +00001951 /*NumArgs=*/Record[ASTStmtReader::NumExprFields]);
Argyrios Kyrtzidisa77eb082010-06-25 09:03:26 +00001952 break;
1953
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001954 case EXPR_CXX_UNRESOLVED_MEMBER:
Douglas Gregor35942772011-09-09 21:34:22 +00001955 S = UnresolvedMemberExpr::CreateEmpty(Context,
Douglas Gregordef03542011-02-04 12:01:24 +00001956 /*HasExplicitTemplateArgs=*/Record[ASTStmtReader::NumExprFields],
1957 /*NumTemplateArgs=*/Record[ASTStmtReader::NumExprFields]
1958 ? Record[ASTStmtReader::NumExprFields + 1]
1959 : 0);
Argyrios Kyrtzidis8dfbd8b2010-06-24 08:57:31 +00001960 break;
Argyrios Kyrtzidisbd65bb52010-06-25 09:03:34 +00001961
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001962 case EXPR_CXX_UNRESOLVED_LOOKUP:
Douglas Gregor35942772011-09-09 21:34:22 +00001963 S = UnresolvedLookupExpr::CreateEmpty(Context,
Douglas Gregordef03542011-02-04 12:01:24 +00001964 /*HasExplicitTemplateArgs=*/Record[ASTStmtReader::NumExprFields],
1965 /*NumTemplateArgs=*/Record[ASTStmtReader::NumExprFields]
1966 ? Record[ASTStmtReader::NumExprFields + 1]
1967 : 0);
Argyrios Kyrtzidisbd65bb52010-06-25 09:03:34 +00001968 break;
Argyrios Kyrtzidis6d00c132010-07-10 11:46:15 +00001969
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001970 case EXPR_CXX_UNARY_TYPE_TRAIT:
Argyrios Kyrtzidis6d00c132010-07-10 11:46:15 +00001971 S = new (Context) UnaryTypeTraitExpr(Empty);
1972 break;
Sebastian Redl6b219d02010-09-10 20:55:54 +00001973
Francois Pichetf1872372010-12-08 22:35:30 +00001974 case EXPR_BINARY_TYPE_TRAIT:
Francois Pichet6ad6f282010-12-07 00:08:36 +00001975 S = new (Context) BinaryTypeTraitExpr(Empty);
1976 break;
1977
John Wiegley21ff2e52011-04-28 00:16:57 +00001978 case EXPR_ARRAY_TYPE_TRAIT:
1979 S = new (Context) ArrayTypeTraitExpr(Empty);
1980 break;
1981
John Wiegley55262202011-04-25 06:54:41 +00001982 case EXPR_CXX_EXPRESSION_TRAIT:
1983 S = new (Context) ExpressionTraitExpr(Empty);
1984 break;
1985
Sebastian Redl6b219d02010-09-10 20:55:54 +00001986 case EXPR_CXX_NOEXCEPT:
1987 S = new (Context) CXXNoexceptExpr(Empty);
1988 break;
John McCall7cd7d1a2010-11-15 23:31:06 +00001989
Douglas Gregorbe230c32011-01-03 17:17:50 +00001990 case EXPR_PACK_EXPANSION:
1991 S = new (Context) PackExpansionExpr(Empty);
1992 break;
1993
Douglas Gregoree8aff02011-01-04 17:33:58 +00001994 case EXPR_SIZEOF_PACK:
1995 S = new (Context) SizeOfPackExpr(Empty);
1996 break;
1997
John McCall7110fd62011-07-15 07:00:14 +00001998 case EXPR_SUBST_NON_TYPE_TEMPLATE_PARM:
1999 S = new (Context) SubstNonTypeTemplateParmExpr(Empty);
2000 break;
2001
Douglas Gregorc7793c72011-01-15 01:15:58 +00002002 case EXPR_SUBST_NON_TYPE_TEMPLATE_PARM_PACK:
2003 S = new (Context) SubstNonTypeTemplateParmPackExpr(Empty);
2004 break;
2005
Douglas Gregor03e80032011-06-21 17:03:29 +00002006 case EXPR_MATERIALIZE_TEMPORARY:
2007 S = new (Context) MaterializeTemporaryExpr(Empty);
2008 break;
2009
John McCall56ca35d2011-02-17 10:25:35 +00002010 case EXPR_OPAQUE_VALUE: {
2011 unsigned key = Record[ASTStmtReader::NumExprFields];
2012 OpaqueValueExpr *&expr = OpaqueValueExprs[key];
2013
2014 // If we already have an entry for this opaque value expression,
2015 // don't bother reading it again.
2016 if (expr) {
2017 StmtStack.push_back(expr);
2018 continue;
2019 }
2020
2021 S = expr = new (Context) OpaqueValueExpr(Empty);
John McCall7cd7d1a2010-11-15 23:31:06 +00002022 break;
John McCall56ca35d2011-02-17 10:25:35 +00002023 }
Peter Collingbournee08ce652011-02-09 21:07:24 +00002024
2025 case EXPR_CUDA_KERNEL_CALL:
Douglas Gregor35942772011-09-09 21:34:22 +00002026 S = new (Context) CUDAKernelCallExpr(Context, Empty);
Peter Collingbournee08ce652011-02-09 21:07:24 +00002027 break;
Tanya Lattner61eee0c2011-06-04 00:47:47 +00002028
2029 case EXPR_ASTYPE:
2030 S = new (Context) AsTypeExpr(Empty);
2031 break;
Eli Friedman276b0612011-10-11 02:20:01 +00002032
2033 case EXPR_ATOMIC:
2034 S = new (Context) AtomicExpr(Empty);
2035 break;
Chris Lattner4c6f9522009-04-27 05:14:47 +00002036 }
Argyrios Kyrtzidis6d00c132010-07-10 11:46:15 +00002037
Chris Lattner4c6f9522009-04-27 05:14:47 +00002038 // We hit a STMT_STOP, so we're done with this expression.
2039 if (Finished)
2040 break;
2041
2042 ++NumStatementsRead;
2043
Argyrios Kyrtzidis919e6932010-06-28 22:28:35 +00002044 if (S)
2045 Reader.Visit(S);
Chris Lattner4c6f9522009-04-27 05:14:47 +00002046
2047 assert(Idx == Record.size() && "Invalid deserialization of statement");
2048 StmtStack.push_back(S);
2049 }
Argyrios Kyrtzidis919e6932010-06-28 22:28:35 +00002050
2051#ifndef NDEBUG
2052 assert(StmtStack.size() > PrevNumStmts && "Read too many sub stmts!");
2053 assert(StmtStack.size() == PrevNumStmts + 1 && "Extra expressions on stack!");
2054#endif
2055
2056 return StmtStack.pop_back_val();
Chris Lattner4c6f9522009-04-27 05:14:47 +00002057}