blob: 9823be19427be88d039a5b884ce23e363c3179e7 [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"
Benjamin Kramer8fe83e12012-02-04 13:45:25 +000019#include "llvm/ADT/SmallString.h"
Chris Lattner4c6f9522009-04-27 05:14:47 +000020using namespace clang;
Sebastian Redl8538e8d2010-08-18 23:57:32 +000021using namespace clang::serialization;
Chris Lattner4c6f9522009-04-27 05:14:47 +000022
Argyrios Kyrtzidis37bdfe22010-06-30 08:49:18 +000023namespace clang {
Argyrios Kyrtzidis17cfded2010-06-28 09:31:42 +000024
Sebastian Redl60adf4a2010-08-18 23:56:52 +000025 class ASTStmtReader : public StmtVisitor<ASTStmtReader> {
Douglas Gregor409448c2011-07-21 22:35:25 +000026 typedef ASTReader::RecordData RecordData;
27
Sebastian Redlc43b54c2010-08-18 23:56:43 +000028 ASTReader &Reader;
Douglas Gregor1a4761e2011-11-30 23:21:26 +000029 ModuleFile &F;
Sebastian Redl577d4792010-07-22 22:43:28 +000030 llvm::BitstreamCursor &DeclsCursor;
Sebastian Redlc43b54c2010-08-18 23:56:43 +000031 const ASTReader::RecordData &Record;
Chris Lattner4c6f9522009-04-27 05:14:47 +000032 unsigned &Idx;
Chris Lattner4c6f9522009-04-27 05:14:47 +000033
Douglas Gregor409448c2011-07-21 22:35:25 +000034 SourceLocation ReadSourceLocation(const RecordData &R, unsigned &I) {
Sebastian Redlc3632732010-10-05 15:59:54 +000035 return Reader.ReadSourceLocation(F, R, I);
36 }
Douglas Gregor409448c2011-07-21 22:35:25 +000037
38 SourceRange ReadSourceRange(const RecordData &R, unsigned &I) {
Sebastian Redlc3632732010-10-05 15:59:54 +000039 return Reader.ReadSourceRange(F, R, I);
40 }
Douglas Gregor409448c2011-07-21 22:35:25 +000041
42 TypeSourceInfo *GetTypeSourceInfo(const RecordData &R, unsigned &I) {
Sebastian Redlc3632732010-10-05 15:59:54 +000043 return Reader.GetTypeSourceInfo(F, R, I);
44 }
Douglas Gregor409448c2011-07-21 22:35:25 +000045
46 serialization::DeclID ReadDeclID(const RecordData &R, unsigned &I) {
47 return Reader.ReadDeclID(F, R, I);
48 }
49
50 Decl *ReadDecl(const RecordData &R, unsigned &I) {
51 return Reader.ReadDecl(F, R, I);
52 }
53
54 template<typename T>
55 T *ReadDeclAs(const RecordData &R, unsigned &I) {
56 return Reader.ReadDeclAs<T>(F, R, I);
57 }
58
Argyrios Kyrtzidis40451072010-10-15 18:21:24 +000059 void ReadDeclarationNameLoc(DeclarationNameLoc &DNLoc, DeclarationName Name,
60 const ASTReader::RecordData &R, unsigned &I) {
61 Reader.ReadDeclarationNameLoc(F, DNLoc, Name, R, I);
62 }
Douglas Gregor409448c2011-07-21 22:35:25 +000063
Argyrios Kyrtzidis40451072010-10-15 18:21:24 +000064 void ReadDeclarationNameInfo(DeclarationNameInfo &NameInfo,
65 const ASTReader::RecordData &R, unsigned &I) {
66 Reader.ReadDeclarationNameInfo(F, NameInfo, R, I);
67 }
Sebastian Redlc3632732010-10-05 15:59:54 +000068
Chris Lattner4c6f9522009-04-27 05:14:47 +000069 public:
Douglas Gregor1a4761e2011-11-30 23:21:26 +000070 ASTStmtReader(ASTReader &Reader, ModuleFile &F,
Sebastian Redlc3632732010-10-05 15:59:54 +000071 llvm::BitstreamCursor &Cursor,
Sebastian Redlc43b54c2010-08-18 23:56:43 +000072 const ASTReader::RecordData &Record, unsigned &Idx)
Sebastian Redlc3632732010-10-05 15:59:54 +000073 : Reader(Reader), F(F), DeclsCursor(Cursor), Record(Record), Idx(Idx) { }
Chris Lattner4c6f9522009-04-27 05:14:47 +000074
75 /// \brief The number of record fields required for the Stmt class
76 /// itself.
77 static const unsigned NumStmtFields = 0;
78
79 /// \brief The number of record fields required for the Expr class
80 /// itself.
Douglas Gregor561f8122011-07-01 01:22:09 +000081 static const unsigned NumExprFields = NumStmtFields + 7;
Abramo Bagnarae4b92762012-01-27 09:46:47 +000082
83 /// \brief Read and initialize a ExplicitTemplateArgumentList structure.
84 void ReadTemplateKWAndArgsInfo(ASTTemplateKWAndArgsInfo &Args,
85 unsigned NumTemplateArgs);
Argyrios Kyrtzidis36c76f02010-06-28 09:31:48 +000086 /// \brief Read and initialize a ExplicitTemplateArgumentList structure.
Argyrios Kyrtzidisb0c3e092011-09-22 20:07:03 +000087 void ReadExplicitTemplateArgumentList(ASTTemplateArgumentListInfo &ArgList,
Argyrios Kyrtzidis919e6932010-06-28 22:28:35 +000088 unsigned NumTemplateArgs);
Chris Lattner4c6f9522009-04-27 05:14:47 +000089
Argyrios Kyrtzidis919e6932010-06-28 22:28:35 +000090 void VisitStmt(Stmt *S);
John McCall7110fd62011-07-15 07:00:14 +000091#define STMT(Type, Base) \
92 void Visit##Type(Type *);
93#include "clang/AST/StmtNodes.inc"
Chris Lattner4c6f9522009-04-27 05:14:47 +000094 };
95}
96
Sebastian Redl60adf4a2010-08-18 23:56:52 +000097void ASTStmtReader::
Abramo Bagnarae4b92762012-01-27 09:46:47 +000098ReadTemplateKWAndArgsInfo(ASTTemplateKWAndArgsInfo &Args,
99 unsigned NumTemplateArgs) {
100 SourceLocation TemplateKWLoc = ReadSourceLocation(Record, Idx);
Argyrios Kyrtzidis36c76f02010-06-28 09:31:48 +0000101 TemplateArgumentListInfo ArgInfo;
Sebastian Redlc3632732010-10-05 15:59:54 +0000102 ArgInfo.setLAngleLoc(ReadSourceLocation(Record, Idx));
103 ArgInfo.setRAngleLoc(ReadSourceLocation(Record, Idx));
Argyrios Kyrtzidis36c76f02010-06-28 09:31:48 +0000104 for (unsigned i = 0; i != NumTemplateArgs; ++i)
Sebastian Redl577d4792010-07-22 22:43:28 +0000105 ArgInfo.addArgument(
Sebastian Redlc3632732010-10-05 15:59:54 +0000106 Reader.ReadTemplateArgumentLoc(F, Record, Idx));
Abramo Bagnarae4b92762012-01-27 09:46:47 +0000107 Args.initializeFrom(TemplateKWLoc, ArgInfo);
Argyrios Kyrtzidis36c76f02010-06-28 09:31:48 +0000108}
109
Sebastian Redl60adf4a2010-08-18 23:56:52 +0000110void ASTStmtReader::VisitStmt(Stmt *S) {
Chris Lattner4c6f9522009-04-27 05:14:47 +0000111 assert(Idx == NumStmtFields && "Incorrect statement field count");
Chris Lattner4c6f9522009-04-27 05:14:47 +0000112}
113
Sebastian Redl60adf4a2010-08-18 23:56:52 +0000114void ASTStmtReader::VisitNullStmt(NullStmt *S) {
Chris Lattner4c6f9522009-04-27 05:14:47 +0000115 VisitStmt(S);
Sebastian Redlc3632732010-10-05 15:59:54 +0000116 S->setSemiLoc(ReadSourceLocation(Record, Idx));
Argyrios Kyrtzidise2ca8282011-09-01 21:53:45 +0000117 S->HasLeadingEmptyMacro = Record[Idx++];
Chris Lattner4c6f9522009-04-27 05:14:47 +0000118}
119
Sebastian Redl60adf4a2010-08-18 23:56:52 +0000120void ASTStmtReader::VisitCompoundStmt(CompoundStmt *S) {
Chris Lattner4c6f9522009-04-27 05:14:47 +0000121 VisitStmt(S);
Chris Lattner5f9e2722011-07-23 10:55:15 +0000122 SmallVector<Stmt *, 16> Stmts;
Chris Lattner4c6f9522009-04-27 05:14:47 +0000123 unsigned NumStmts = Record[Idx++];
Argyrios Kyrtzidis919e6932010-06-28 22:28:35 +0000124 while (NumStmts--)
Argyrios Kyrtzidisd98a2ab2010-06-29 22:46:25 +0000125 Stmts.push_back(Reader.ReadSubStmt());
Douglas Gregor35942772011-09-09 21:34:22 +0000126 S->setStmts(Reader.getContext(), Stmts.data(), Stmts.size());
Sebastian Redlc3632732010-10-05 15:59:54 +0000127 S->setLBracLoc(ReadSourceLocation(Record, Idx));
128 S->setRBracLoc(ReadSourceLocation(Record, Idx));
Chris Lattner4c6f9522009-04-27 05:14:47 +0000129}
130
Sebastian Redl60adf4a2010-08-18 23:56:52 +0000131void ASTStmtReader::VisitSwitchCase(SwitchCase *S) {
Chris Lattner4c6f9522009-04-27 05:14:47 +0000132 VisitStmt(S);
133 Reader.RecordSwitchCaseID(S, Record[Idx++]);
Chris Lattner4c6f9522009-04-27 05:14:47 +0000134}
135
Sebastian Redl60adf4a2010-08-18 23:56:52 +0000136void ASTStmtReader::VisitCaseStmt(CaseStmt *S) {
Chris Lattner4c6f9522009-04-27 05:14:47 +0000137 VisitSwitchCase(S);
Argyrios Kyrtzidisd98a2ab2010-06-29 22:46:25 +0000138 S->setLHS(Reader.ReadSubExpr());
139 S->setRHS(Reader.ReadSubExpr());
140 S->setSubStmt(Reader.ReadSubStmt());
Sebastian Redlc3632732010-10-05 15:59:54 +0000141 S->setCaseLoc(ReadSourceLocation(Record, Idx));
142 S->setEllipsisLoc(ReadSourceLocation(Record, Idx));
143 S->setColonLoc(ReadSourceLocation(Record, Idx));
Chris Lattner4c6f9522009-04-27 05:14:47 +0000144}
145
Sebastian Redl60adf4a2010-08-18 23:56:52 +0000146void ASTStmtReader::VisitDefaultStmt(DefaultStmt *S) {
Chris Lattner4c6f9522009-04-27 05:14:47 +0000147 VisitSwitchCase(S);
Argyrios Kyrtzidisd98a2ab2010-06-29 22:46:25 +0000148 S->setSubStmt(Reader.ReadSubStmt());
Sebastian Redlc3632732010-10-05 15:59:54 +0000149 S->setDefaultLoc(ReadSourceLocation(Record, Idx));
150 S->setColonLoc(ReadSourceLocation(Record, Idx));
Chris Lattner4c6f9522009-04-27 05:14:47 +0000151}
152
Sebastian Redl60adf4a2010-08-18 23:56:52 +0000153void ASTStmtReader::VisitLabelStmt(LabelStmt *S) {
Chris Lattner4c6f9522009-04-27 05:14:47 +0000154 VisitStmt(S);
Douglas Gregor409448c2011-07-21 22:35:25 +0000155 LabelDecl *LD = ReadDeclAs<LabelDecl>(Record, Idx);
Chris Lattnerad8dcf42011-02-17 07:39:24 +0000156 LD->setStmt(S);
157 S->setDecl(LD);
Argyrios Kyrtzidisd98a2ab2010-06-29 22:46:25 +0000158 S->setSubStmt(Reader.ReadSubStmt());
Sebastian Redlc3632732010-10-05 15:59:54 +0000159 S->setIdentLoc(ReadSourceLocation(Record, Idx));
Chris Lattner4c6f9522009-04-27 05:14:47 +0000160}
161
Richard Smith534986f2012-04-14 00:33:13 +0000162void ASTStmtReader::VisitAttributedStmt(AttributedStmt *S) {
163 VisitStmt(S);
164 AttrVec Attrs;
165 Reader.ReadAttributes(F, Attrs, Record, Idx);
166 S->Attrs = Attrs;
167 S->SubStmt = Reader.ReadSubStmt();
168 S->AttrLoc = ReadSourceLocation(Record, Idx);
169}
170
Sebastian Redl60adf4a2010-08-18 23:56:52 +0000171void ASTStmtReader::VisitIfStmt(IfStmt *S) {
Chris Lattner4c6f9522009-04-27 05:14:47 +0000172 VisitStmt(S);
Richard Smith534986f2012-04-14 00:33:13 +0000173 S->setConditionVariable(Reader.getContext(),
Douglas Gregor409448c2011-07-21 22:35:25 +0000174 ReadDeclAs<VarDecl>(Record, Idx));
Argyrios Kyrtzidisd98a2ab2010-06-29 22:46:25 +0000175 S->setCond(Reader.ReadSubExpr());
176 S->setThen(Reader.ReadSubStmt());
177 S->setElse(Reader.ReadSubStmt());
Sebastian Redlc3632732010-10-05 15:59:54 +0000178 S->setIfLoc(ReadSourceLocation(Record, Idx));
179 S->setElseLoc(ReadSourceLocation(Record, Idx));
Chris Lattner4c6f9522009-04-27 05:14:47 +0000180}
181
Sebastian Redl60adf4a2010-08-18 23:56:52 +0000182void ASTStmtReader::VisitSwitchStmt(SwitchStmt *S) {
Chris Lattner4c6f9522009-04-27 05:14:47 +0000183 VisitStmt(S);
Douglas Gregor35942772011-09-09 21:34:22 +0000184 S->setConditionVariable(Reader.getContext(),
Douglas Gregor409448c2011-07-21 22:35:25 +0000185 ReadDeclAs<VarDecl>(Record, Idx));
Argyrios Kyrtzidisd98a2ab2010-06-29 22:46:25 +0000186 S->setCond(Reader.ReadSubExpr());
187 S->setBody(Reader.ReadSubStmt());
Sebastian Redlc3632732010-10-05 15:59:54 +0000188 S->setSwitchLoc(ReadSourceLocation(Record, Idx));
Ted Kremenek559fb552010-09-09 00:05:53 +0000189 if (Record[Idx++])
190 S->setAllEnumCasesCovered();
191
Chris Lattner4c6f9522009-04-27 05:14:47 +0000192 SwitchCase *PrevSC = 0;
193 for (unsigned N = Record.size(); Idx != N; ++Idx) {
194 SwitchCase *SC = Reader.getSwitchCaseWithID(Record[Idx]);
195 if (PrevSC)
196 PrevSC->setNextSwitchCase(SC);
197 else
198 S->setSwitchCaseList(SC);
Mike Stump1eb44332009-09-09 15:08:12 +0000199
Chris Lattner4c6f9522009-04-27 05:14:47 +0000200 PrevSC = SC;
201 }
Chris Lattner4c6f9522009-04-27 05:14:47 +0000202}
203
Sebastian Redl60adf4a2010-08-18 23:56:52 +0000204void ASTStmtReader::VisitWhileStmt(WhileStmt *S) {
Chris Lattner4c6f9522009-04-27 05:14:47 +0000205 VisitStmt(S);
Douglas Gregor35942772011-09-09 21:34:22 +0000206 S->setConditionVariable(Reader.getContext(),
Douglas Gregor409448c2011-07-21 22:35:25 +0000207 ReadDeclAs<VarDecl>(Record, Idx));
208
Argyrios Kyrtzidisd98a2ab2010-06-29 22:46:25 +0000209 S->setCond(Reader.ReadSubExpr());
210 S->setBody(Reader.ReadSubStmt());
Sebastian Redlc3632732010-10-05 15:59:54 +0000211 S->setWhileLoc(ReadSourceLocation(Record, Idx));
Chris Lattner4c6f9522009-04-27 05:14:47 +0000212}
213
Sebastian Redl60adf4a2010-08-18 23:56:52 +0000214void ASTStmtReader::VisitDoStmt(DoStmt *S) {
Chris Lattner4c6f9522009-04-27 05:14:47 +0000215 VisitStmt(S);
Argyrios Kyrtzidisd98a2ab2010-06-29 22:46:25 +0000216 S->setCond(Reader.ReadSubExpr());
217 S->setBody(Reader.ReadSubStmt());
Sebastian Redlc3632732010-10-05 15:59:54 +0000218 S->setDoLoc(ReadSourceLocation(Record, Idx));
219 S->setWhileLoc(ReadSourceLocation(Record, Idx));
220 S->setRParenLoc(ReadSourceLocation(Record, Idx));
Chris Lattner4c6f9522009-04-27 05:14:47 +0000221}
222
Sebastian Redl60adf4a2010-08-18 23:56:52 +0000223void ASTStmtReader::VisitForStmt(ForStmt *S) {
Chris Lattner4c6f9522009-04-27 05:14:47 +0000224 VisitStmt(S);
Argyrios Kyrtzidisd98a2ab2010-06-29 22:46:25 +0000225 S->setInit(Reader.ReadSubStmt());
226 S->setCond(Reader.ReadSubExpr());
Douglas Gregor35942772011-09-09 21:34:22 +0000227 S->setConditionVariable(Reader.getContext(),
Douglas Gregor409448c2011-07-21 22:35:25 +0000228 ReadDeclAs<VarDecl>(Record, Idx));
Argyrios Kyrtzidisd98a2ab2010-06-29 22:46:25 +0000229 S->setInc(Reader.ReadSubExpr());
230 S->setBody(Reader.ReadSubStmt());
Sebastian Redlc3632732010-10-05 15:59:54 +0000231 S->setForLoc(ReadSourceLocation(Record, Idx));
232 S->setLParenLoc(ReadSourceLocation(Record, Idx));
233 S->setRParenLoc(ReadSourceLocation(Record, Idx));
Chris Lattner4c6f9522009-04-27 05:14:47 +0000234}
235
Sebastian Redl60adf4a2010-08-18 23:56:52 +0000236void ASTStmtReader::VisitGotoStmt(GotoStmt *S) {
Chris Lattner4c6f9522009-04-27 05:14:47 +0000237 VisitStmt(S);
Douglas Gregor409448c2011-07-21 22:35:25 +0000238 S->setLabel(ReadDeclAs<LabelDecl>(Record, Idx));
Sebastian Redlc3632732010-10-05 15:59:54 +0000239 S->setGotoLoc(ReadSourceLocation(Record, Idx));
240 S->setLabelLoc(ReadSourceLocation(Record, Idx));
Chris Lattner4c6f9522009-04-27 05:14:47 +0000241}
242
Sebastian Redl60adf4a2010-08-18 23:56:52 +0000243void ASTStmtReader::VisitIndirectGotoStmt(IndirectGotoStmt *S) {
Chris Lattner4c6f9522009-04-27 05:14:47 +0000244 VisitStmt(S);
Sebastian Redlc3632732010-10-05 15:59:54 +0000245 S->setGotoLoc(ReadSourceLocation(Record, Idx));
246 S->setStarLoc(ReadSourceLocation(Record, Idx));
Argyrios Kyrtzidisd98a2ab2010-06-29 22:46:25 +0000247 S->setTarget(Reader.ReadSubExpr());
Chris Lattner4c6f9522009-04-27 05:14:47 +0000248}
249
Sebastian Redl60adf4a2010-08-18 23:56:52 +0000250void ASTStmtReader::VisitContinueStmt(ContinueStmt *S) {
Chris Lattner4c6f9522009-04-27 05:14:47 +0000251 VisitStmt(S);
Sebastian Redlc3632732010-10-05 15:59:54 +0000252 S->setContinueLoc(ReadSourceLocation(Record, Idx));
Chris Lattner4c6f9522009-04-27 05:14:47 +0000253}
254
Sebastian Redl60adf4a2010-08-18 23:56:52 +0000255void ASTStmtReader::VisitBreakStmt(BreakStmt *S) {
Chris Lattner4c6f9522009-04-27 05:14:47 +0000256 VisitStmt(S);
Sebastian Redlc3632732010-10-05 15:59:54 +0000257 S->setBreakLoc(ReadSourceLocation(Record, Idx));
Chris Lattner4c6f9522009-04-27 05:14:47 +0000258}
259
Sebastian Redl60adf4a2010-08-18 23:56:52 +0000260void ASTStmtReader::VisitReturnStmt(ReturnStmt *S) {
Chris Lattner4c6f9522009-04-27 05:14:47 +0000261 VisitStmt(S);
Argyrios Kyrtzidisd98a2ab2010-06-29 22:46:25 +0000262 S->setRetValue(Reader.ReadSubExpr());
Sebastian Redlc3632732010-10-05 15:59:54 +0000263 S->setReturnLoc(ReadSourceLocation(Record, Idx));
Douglas Gregor409448c2011-07-21 22:35:25 +0000264 S->setNRVOCandidate(ReadDeclAs<VarDecl>(Record, Idx));
Chris Lattner4c6f9522009-04-27 05:14:47 +0000265}
266
Sebastian Redl60adf4a2010-08-18 23:56:52 +0000267void ASTStmtReader::VisitDeclStmt(DeclStmt *S) {
Chris Lattner4c6f9522009-04-27 05:14:47 +0000268 VisitStmt(S);
Sebastian Redlc3632732010-10-05 15:59:54 +0000269 S->setStartLoc(ReadSourceLocation(Record, Idx));
270 S->setEndLoc(ReadSourceLocation(Record, Idx));
Chris Lattner4c6f9522009-04-27 05:14:47 +0000271
272 if (Idx + 1 == Record.size()) {
273 // Single declaration
Douglas Gregor409448c2011-07-21 22:35:25 +0000274 S->setDeclGroup(DeclGroupRef(ReadDecl(Record, Idx)));
Chris Lattner4c6f9522009-04-27 05:14:47 +0000275 } else {
Chris Lattner5f9e2722011-07-23 10:55:15 +0000276 SmallVector<Decl *, 16> Decls;
Douglas Gregor409448c2011-07-21 22:35:25 +0000277 Decls.reserve(Record.size() - Idx);
278 for (unsigned N = Record.size(); Idx != N; )
279 Decls.push_back(ReadDecl(Record, Idx));
Douglas Gregor35942772011-09-09 21:34:22 +0000280 S->setDeclGroup(DeclGroupRef(DeclGroup::Create(Reader.getContext(),
Douglas Gregor75fdb232009-05-22 22:45:36 +0000281 Decls.data(),
282 Decls.size())));
Chris Lattner4c6f9522009-04-27 05:14:47 +0000283 }
Chris Lattner4c6f9522009-04-27 05:14:47 +0000284}
285
Sebastian Redl60adf4a2010-08-18 23:56:52 +0000286void ASTStmtReader::VisitAsmStmt(AsmStmt *S) {
Chris Lattner4c6f9522009-04-27 05:14:47 +0000287 VisitStmt(S);
288 unsigned NumOutputs = Record[Idx++];
289 unsigned NumInputs = Record[Idx++];
290 unsigned NumClobbers = Record[Idx++];
Sebastian Redlc3632732010-10-05 15:59:54 +0000291 S->setAsmLoc(ReadSourceLocation(Record, Idx));
292 S->setRParenLoc(ReadSourceLocation(Record, Idx));
Chris Lattner4c6f9522009-04-27 05:14:47 +0000293 S->setVolatile(Record[Idx++]);
294 S->setSimple(Record[Idx++]);
Mike Stump3b11fd32010-01-04 22:37:17 +0000295 S->setMSAsm(Record[Idx++]);
Mike Stump1eb44332009-09-09 15:08:12 +0000296
Argyrios Kyrtzidisd98a2ab2010-06-29 22:46:25 +0000297 S->setAsmString(cast_or_null<StringLiteral>(Reader.ReadSubStmt()));
Chris Lattner4c6f9522009-04-27 05:14:47 +0000298
299 // Outputs and inputs
Chris Lattner5f9e2722011-07-23 10:55:15 +0000300 SmallVector<IdentifierInfo *, 16> Names;
301 SmallVector<StringLiteral*, 16> Constraints;
302 SmallVector<Stmt*, 16> Exprs;
Chris Lattner4c6f9522009-04-27 05:14:47 +0000303 for (unsigned I = 0, N = NumOutputs + NumInputs; I != N; ++I) {
Douglas Gregor95eab172011-07-28 20:55:49 +0000304 Names.push_back(Reader.GetIdentifierInfo(F, Record, Idx));
Argyrios Kyrtzidisd98a2ab2010-06-29 22:46:25 +0000305 Constraints.push_back(cast_or_null<StringLiteral>(Reader.ReadSubStmt()));
306 Exprs.push_back(Reader.ReadSubStmt());
Chris Lattner4c6f9522009-04-27 05:14:47 +0000307 }
Chris Lattner4c6f9522009-04-27 05:14:47 +0000308
309 // Constraints
Chris Lattner5f9e2722011-07-23 10:55:15 +0000310 SmallVector<StringLiteral*, 16> Clobbers;
Chris Lattner4c6f9522009-04-27 05:14:47 +0000311 for (unsigned I = 0; I != NumClobbers; ++I)
Argyrios Kyrtzidisd98a2ab2010-06-29 22:46:25 +0000312 Clobbers.push_back(cast_or_null<StringLiteral>(Reader.ReadSubStmt()));
Anders Carlssonfdba9c02010-01-30 19:34:25 +0000313
Douglas Gregor35942772011-09-09 21:34:22 +0000314 S->setOutputsAndInputsAndClobbers(Reader.getContext(),
Anders Carlssonacb6bcb2010-01-30 20:38:10 +0000315 Names.data(), Constraints.data(),
Anders Carlssonfdba9c02010-01-30 19:34:25 +0000316 Exprs.data(), NumOutputs, NumInputs,
317 Clobbers.data(), NumClobbers);
Chris Lattner4c6f9522009-04-27 05:14:47 +0000318}
319
Chad Rosier8cd64b42012-06-11 20:47:18 +0000320void ASTStmtReader::VisitMSAsmStmt(MSAsmStmt *S) {
321 // FIXME: Statement reader not yet implemented for MS style inline asm.
322 VisitStmt(S);
323}
324
Sebastian Redl60adf4a2010-08-18 23:56:52 +0000325void ASTStmtReader::VisitExpr(Expr *E) {
Chris Lattner4c6f9522009-04-27 05:14:47 +0000326 VisitStmt(E);
Douglas Gregor393f2492011-07-22 00:38:23 +0000327 E->setType(Reader.readType(F, Record, Idx));
Chris Lattner4c6f9522009-04-27 05:14:47 +0000328 E->setTypeDependent(Record[Idx++]);
329 E->setValueDependent(Record[Idx++]);
Douglas Gregor561f8122011-07-01 01:22:09 +0000330 E->setInstantiationDependent(Record[Idx++]);
Douglas Gregord0937222010-12-13 22:49:22 +0000331 E->ExprBits.ContainsUnexpandedParameterPack = Record[Idx++];
John McCallf89e55a2010-11-18 06:31:45 +0000332 E->setValueKind(static_cast<ExprValueKind>(Record[Idx++]));
333 E->setObjectKind(static_cast<ExprObjectKind>(Record[Idx++]));
Chris Lattner4c6f9522009-04-27 05:14:47 +0000334 assert(Idx == NumExprFields && "Incorrect expression field count");
Chris Lattner4c6f9522009-04-27 05:14:47 +0000335}
336
Sebastian Redl60adf4a2010-08-18 23:56:52 +0000337void ASTStmtReader::VisitPredefinedExpr(PredefinedExpr *E) {
Chris Lattner4c6f9522009-04-27 05:14:47 +0000338 VisitExpr(E);
Sebastian Redlc3632732010-10-05 15:59:54 +0000339 E->setLocation(ReadSourceLocation(Record, Idx));
Chris Lattner4c6f9522009-04-27 05:14:47 +0000340 E->setIdentType((PredefinedExpr::IdentType)Record[Idx++]);
Chris Lattner4c6f9522009-04-27 05:14:47 +0000341}
342
Sebastian Redl60adf4a2010-08-18 23:56:52 +0000343void ASTStmtReader::VisitDeclRefExpr(DeclRefExpr *E) {
Chris Lattner4c6f9522009-04-27 05:14:47 +0000344 VisitExpr(E);
Argyrios Kyrtzidis663e3802010-07-08 13:09:47 +0000345
Chandler Carruthcb66cff2011-05-01 21:29:53 +0000346 E->DeclRefExprBits.HasQualifier = Record[Idx++];
Chandler Carruth3aa81402011-05-01 23:48:14 +0000347 E->DeclRefExprBits.HasFoundDecl = Record[Idx++];
Abramo Bagnarae4b92762012-01-27 09:46:47 +0000348 E->DeclRefExprBits.HasTemplateKWAndArgsInfo = Record[Idx++];
Abramo Bagnara7cc58b42011-10-05 07:56:41 +0000349 E->DeclRefExprBits.HadMultipleCandidates = Record[Idx++];
John McCallf4b88a42012-03-10 09:33:50 +0000350 E->DeclRefExprBits.RefersToEnclosingLocal = Record[Idx++];
Anders Carlssonb0ca1372011-03-06 18:19:42 +0000351 unsigned NumTemplateArgs = 0;
Abramo Bagnarae4b92762012-01-27 09:46:47 +0000352 if (E->hasTemplateKWAndArgsInfo())
Anders Carlssonb0ca1372011-03-06 18:19:42 +0000353 NumTemplateArgs = Record[Idx++];
354
Chandler Carruthcb66cff2011-05-01 21:29:53 +0000355 if (E->hasQualifier())
Chandler Carruth6857c3e2011-05-01 22:14:37 +0000356 E->getInternalQualifierLoc()
Douglas Gregor40d96a62011-02-28 21:54:11 +0000357 = Reader.ReadNestedNameSpecifierLoc(F, Record, Idx);
Argyrios Kyrtzidis663e3802010-07-08 13:09:47 +0000358
Chandler Carruth3aa81402011-05-01 23:48:14 +0000359 if (E->hasFoundDecl())
Douglas Gregor409448c2011-07-21 22:35:25 +0000360 E->getInternalFoundDecl() = ReadDeclAs<NamedDecl>(Record, Idx);
Chandler Carruth3aa81402011-05-01 23:48:14 +0000361
Abramo Bagnarae4b92762012-01-27 09:46:47 +0000362 if (E->hasTemplateKWAndArgsInfo())
363 ReadTemplateKWAndArgsInfo(*E->getTemplateKWAndArgsInfo(),
364 NumTemplateArgs);
Argyrios Kyrtzidis663e3802010-07-08 13:09:47 +0000365
Douglas Gregor409448c2011-07-21 22:35:25 +0000366 E->setDecl(ReadDeclAs<ValueDecl>(Record, Idx));
Sebastian Redlc3632732010-10-05 15:59:54 +0000367 E->setLocation(ReadSourceLocation(Record, Idx));
Argyrios Kyrtzidis40451072010-10-15 18:21:24 +0000368 ReadDeclarationNameLoc(E->DNLoc, E->getDecl()->getDeclName(), Record, Idx);
Chris Lattner4c6f9522009-04-27 05:14:47 +0000369}
370
Sebastian Redl60adf4a2010-08-18 23:56:52 +0000371void ASTStmtReader::VisitIntegerLiteral(IntegerLiteral *E) {
Chris Lattner4c6f9522009-04-27 05:14:47 +0000372 VisitExpr(E);
Sebastian Redlc3632732010-10-05 15:59:54 +0000373 E->setLocation(ReadSourceLocation(Record, Idx));
Douglas Gregor35942772011-09-09 21:34:22 +0000374 E->setValue(Reader.getContext(), Reader.ReadAPInt(Record, Idx));
Chris Lattner4c6f9522009-04-27 05:14:47 +0000375}
376
Sebastian Redl60adf4a2010-08-18 23:56:52 +0000377void ASTStmtReader::VisitFloatingLiteral(FloatingLiteral *E) {
Chris Lattner4c6f9522009-04-27 05:14:47 +0000378 VisitExpr(E);
Douglas Gregor35942772011-09-09 21:34:22 +0000379 E->setValue(Reader.getContext(), Reader.ReadAPFloat(Record, Idx));
Chris Lattner4c6f9522009-04-27 05:14:47 +0000380 E->setExact(Record[Idx++]);
Sebastian Redlc3632732010-10-05 15:59:54 +0000381 E->setLocation(ReadSourceLocation(Record, Idx));
Chris Lattner4c6f9522009-04-27 05:14:47 +0000382}
383
Sebastian Redl60adf4a2010-08-18 23:56:52 +0000384void ASTStmtReader::VisitImaginaryLiteral(ImaginaryLiteral *E) {
Chris Lattner4c6f9522009-04-27 05:14:47 +0000385 VisitExpr(E);
Argyrios Kyrtzidisd98a2ab2010-06-29 22:46:25 +0000386 E->setSubExpr(Reader.ReadSubExpr());
Chris Lattner4c6f9522009-04-27 05:14:47 +0000387}
388
Sebastian Redl60adf4a2010-08-18 23:56:52 +0000389void ASTStmtReader::VisitStringLiteral(StringLiteral *E) {
Chris Lattner4c6f9522009-04-27 05:14:47 +0000390 VisitExpr(E);
391 unsigned Len = Record[Idx++];
Mike Stump1eb44332009-09-09 15:08:12 +0000392 assert(Record[Idx] == E->getNumConcatenated() &&
Chris Lattner4c6f9522009-04-27 05:14:47 +0000393 "Wrong number of concatenated tokens!");
394 ++Idx;
Eli Friedman64f45a22011-11-01 02:23:42 +0000395 StringLiteral::StringKind kind =
396 static_cast<StringLiteral::StringKind>(Record[Idx++]);
397 bool isPascal = Record[Idx++];
Chris Lattner4c6f9522009-04-27 05:14:47 +0000398
Mike Stump1eb44332009-09-09 15:08:12 +0000399 // Read string data
Dylan Noblesmithf7ccbad2012-02-05 02:13:05 +0000400 SmallString<16> Str(&Record[Idx], &Record[Idx] + Len);
Eli Friedman64f45a22011-11-01 02:23:42 +0000401 E->setString(Reader.getContext(), Str.str(), kind, isPascal);
Chris Lattner4c6f9522009-04-27 05:14:47 +0000402 Idx += Len;
403
404 // Read source locations
405 for (unsigned I = 0, N = E->getNumConcatenated(); I != N; ++I)
Sebastian Redlc3632732010-10-05 15:59:54 +0000406 E->setStrTokenLoc(I, ReadSourceLocation(Record, Idx));
Chris Lattner4c6f9522009-04-27 05:14:47 +0000407}
408
Sebastian Redl60adf4a2010-08-18 23:56:52 +0000409void ASTStmtReader::VisitCharacterLiteral(CharacterLiteral *E) {
Chris Lattner4c6f9522009-04-27 05:14:47 +0000410 VisitExpr(E);
411 E->setValue(Record[Idx++]);
Sebastian Redlc3632732010-10-05 15:59:54 +0000412 E->setLocation(ReadSourceLocation(Record, Idx));
Douglas Gregor5cee1192011-07-27 05:40:30 +0000413 E->setKind(static_cast<CharacterLiteral::CharacterKind>(Record[Idx++]));
Chris Lattner4c6f9522009-04-27 05:14:47 +0000414}
415
Sebastian Redl60adf4a2010-08-18 23:56:52 +0000416void ASTStmtReader::VisitParenExpr(ParenExpr *E) {
Chris Lattner4c6f9522009-04-27 05:14:47 +0000417 VisitExpr(E);
Sebastian Redlc3632732010-10-05 15:59:54 +0000418 E->setLParen(ReadSourceLocation(Record, Idx));
419 E->setRParen(ReadSourceLocation(Record, Idx));
Argyrios Kyrtzidisd98a2ab2010-06-29 22:46:25 +0000420 E->setSubExpr(Reader.ReadSubExpr());
Chris Lattner4c6f9522009-04-27 05:14:47 +0000421}
422
Sebastian Redl60adf4a2010-08-18 23:56:52 +0000423void ASTStmtReader::VisitParenListExpr(ParenListExpr *E) {
Argyrios Kyrtzidis37bdfe22010-06-30 08:49:18 +0000424 VisitExpr(E);
425 unsigned NumExprs = Record[Idx++];
Douglas Gregor35942772011-09-09 21:34:22 +0000426 E->Exprs = new (Reader.getContext()) Stmt*[NumExprs];
Argyrios Kyrtzidis37bdfe22010-06-30 08:49:18 +0000427 for (unsigned i = 0; i != NumExprs; ++i)
428 E->Exprs[i] = Reader.ReadSubStmt();
429 E->NumExprs = NumExprs;
Sebastian Redlc3632732010-10-05 15:59:54 +0000430 E->LParenLoc = ReadSourceLocation(Record, Idx);
431 E->RParenLoc = ReadSourceLocation(Record, Idx);
Argyrios Kyrtzidis37bdfe22010-06-30 08:49:18 +0000432}
433
Sebastian Redl60adf4a2010-08-18 23:56:52 +0000434void ASTStmtReader::VisitUnaryOperator(UnaryOperator *E) {
Chris Lattner4c6f9522009-04-27 05:14:47 +0000435 VisitExpr(E);
Argyrios Kyrtzidisd98a2ab2010-06-29 22:46:25 +0000436 E->setSubExpr(Reader.ReadSubExpr());
Chris Lattner4c6f9522009-04-27 05:14:47 +0000437 E->setOpcode((UnaryOperator::Opcode)Record[Idx++]);
Sebastian Redlc3632732010-10-05 15:59:54 +0000438 E->setOperatorLoc(ReadSourceLocation(Record, Idx));
Chris Lattner4c6f9522009-04-27 05:14:47 +0000439}
440
Sebastian Redl60adf4a2010-08-18 23:56:52 +0000441void ASTStmtReader::VisitOffsetOfExpr(OffsetOfExpr *E) {
Douglas Gregor8ecdb652010-04-28 22:16:22 +0000442 typedef OffsetOfExpr::OffsetOfNode Node;
443 VisitExpr(E);
444 assert(E->getNumComponents() == Record[Idx]);
445 ++Idx;
446 assert(E->getNumExpressions() == Record[Idx]);
447 ++Idx;
Sebastian Redlc3632732010-10-05 15:59:54 +0000448 E->setOperatorLoc(ReadSourceLocation(Record, Idx));
449 E->setRParenLoc(ReadSourceLocation(Record, Idx));
450 E->setTypeSourceInfo(GetTypeSourceInfo(Record, Idx));
Douglas Gregor8ecdb652010-04-28 22:16:22 +0000451 for (unsigned I = 0, N = E->getNumComponents(); I != N; ++I) {
452 Node::Kind Kind = static_cast<Node::Kind>(Record[Idx++]);
Sebastian Redlc3632732010-10-05 15:59:54 +0000453 SourceLocation Start = ReadSourceLocation(Record, Idx);
454 SourceLocation End = ReadSourceLocation(Record, Idx);
Douglas Gregor8ecdb652010-04-28 22:16:22 +0000455 switch (Kind) {
456 case Node::Array:
457 E->setComponent(I, Node(Start, Record[Idx++], End));
458 break;
459
460 case Node::Field:
Douglas Gregor409448c2011-07-21 22:35:25 +0000461 E->setComponent(I, Node(Start, ReadDeclAs<FieldDecl>(Record, Idx), End));
Douglas Gregor8ecdb652010-04-28 22:16:22 +0000462 break;
463
464 case Node::Identifier:
Douglas Gregor95eab172011-07-28 20:55:49 +0000465 E->setComponent(I,
466 Node(Start,
467 Reader.GetIdentifierInfo(F, Record, Idx),
468 End));
Douglas Gregor8ecdb652010-04-28 22:16:22 +0000469 break;
Douglas Gregorcc8a5d52010-04-29 00:18:15 +0000470
Argyrios Kyrtzidisafbf3122010-07-29 18:16:10 +0000471 case Node::Base: {
Douglas Gregor35942772011-09-09 21:34:22 +0000472 CXXBaseSpecifier *Base = new (Reader.getContext()) CXXBaseSpecifier();
Sebastian Redlc3632732010-10-05 15:59:54 +0000473 *Base = Reader.ReadCXXBaseSpecifier(F, Record, Idx);
Argyrios Kyrtzidisafbf3122010-07-29 18:16:10 +0000474 E->setComponent(I, Node(Base));
Douglas Gregorcc8a5d52010-04-29 00:18:15 +0000475 break;
Douglas Gregor8ecdb652010-04-28 22:16:22 +0000476 }
Argyrios Kyrtzidisafbf3122010-07-29 18:16:10 +0000477 }
Douglas Gregor8ecdb652010-04-28 22:16:22 +0000478 }
479
480 for (unsigned I = 0, N = E->getNumExpressions(); I != N; ++I)
Argyrios Kyrtzidisd98a2ab2010-06-29 22:46:25 +0000481 E->setIndexExpr(I, Reader.ReadSubExpr());
Douglas Gregor8ecdb652010-04-28 22:16:22 +0000482}
483
Peter Collingbournef4e3cfb2011-03-11 19:24:49 +0000484void ASTStmtReader::VisitUnaryExprOrTypeTraitExpr(UnaryExprOrTypeTraitExpr *E) {
Chris Lattner4c6f9522009-04-27 05:14:47 +0000485 VisitExpr(E);
Peter Collingbournef4e3cfb2011-03-11 19:24:49 +0000486 E->setKind(static_cast<UnaryExprOrTypeTrait>(Record[Idx++]));
Chris Lattner4c6f9522009-04-27 05:14:47 +0000487 if (Record[Idx] == 0) {
Argyrios Kyrtzidisd98a2ab2010-06-29 22:46:25 +0000488 E->setArgument(Reader.ReadSubExpr());
Chris Lattner4c6f9522009-04-27 05:14:47 +0000489 ++Idx;
490 } else {
Sebastian Redlc3632732010-10-05 15:59:54 +0000491 E->setArgument(GetTypeSourceInfo(Record, Idx));
Chris Lattner4c6f9522009-04-27 05:14:47 +0000492 }
Sebastian Redlc3632732010-10-05 15:59:54 +0000493 E->setOperatorLoc(ReadSourceLocation(Record, Idx));
494 E->setRParenLoc(ReadSourceLocation(Record, Idx));
Chris Lattner4c6f9522009-04-27 05:14:47 +0000495}
496
Sebastian Redl60adf4a2010-08-18 23:56:52 +0000497void ASTStmtReader::VisitArraySubscriptExpr(ArraySubscriptExpr *E) {
Chris Lattner4c6f9522009-04-27 05:14:47 +0000498 VisitExpr(E);
Argyrios Kyrtzidisd98a2ab2010-06-29 22:46:25 +0000499 E->setLHS(Reader.ReadSubExpr());
500 E->setRHS(Reader.ReadSubExpr());
Sebastian Redlc3632732010-10-05 15:59:54 +0000501 E->setRBracketLoc(ReadSourceLocation(Record, Idx));
Chris Lattner4c6f9522009-04-27 05:14:47 +0000502}
503
Sebastian Redl60adf4a2010-08-18 23:56:52 +0000504void ASTStmtReader::VisitCallExpr(CallExpr *E) {
Chris Lattner4c6f9522009-04-27 05:14:47 +0000505 VisitExpr(E);
Douglas Gregor35942772011-09-09 21:34:22 +0000506 E->setNumArgs(Reader.getContext(), Record[Idx++]);
Sebastian Redlc3632732010-10-05 15:59:54 +0000507 E->setRParenLoc(ReadSourceLocation(Record, Idx));
Argyrios Kyrtzidisd98a2ab2010-06-29 22:46:25 +0000508 E->setCallee(Reader.ReadSubExpr());
Chris Lattner4c6f9522009-04-27 05:14:47 +0000509 for (unsigned I = 0, N = E->getNumArgs(); I != N; ++I)
Argyrios Kyrtzidisd98a2ab2010-06-29 22:46:25 +0000510 E->setArg(I, Reader.ReadSubExpr());
Chris Lattner4c6f9522009-04-27 05:14:47 +0000511}
512
John McCall7110fd62011-07-15 07:00:14 +0000513void ASTStmtReader::VisitCXXMemberCallExpr(CXXMemberCallExpr *E) {
514 VisitCallExpr(E);
515}
516
Sebastian Redl60adf4a2010-08-18 23:56:52 +0000517void ASTStmtReader::VisitMemberExpr(MemberExpr *E) {
Argyrios Kyrtzidis663e3802010-07-08 13:09:47 +0000518 // Don't call VisitExpr, this is fully initialized at creation.
519 assert(E->getStmtClass() == Stmt::MemberExprClass &&
520 "It's a subclass, we must advance Idx!");
Chris Lattner4c6f9522009-04-27 05:14:47 +0000521}
522
Sebastian Redl60adf4a2010-08-18 23:56:52 +0000523void ASTStmtReader::VisitObjCIsaExpr(ObjCIsaExpr *E) {
Steve Narofff242b1b2009-07-24 17:54:45 +0000524 VisitExpr(E);
Argyrios Kyrtzidisd98a2ab2010-06-29 22:46:25 +0000525 E->setBase(Reader.ReadSubExpr());
Sebastian Redlc3632732010-10-05 15:59:54 +0000526 E->setIsaMemberLoc(ReadSourceLocation(Record, Idx));
Steve Narofff242b1b2009-07-24 17:54:45 +0000527 E->setArrow(Record[Idx++]);
Steve Narofff242b1b2009-07-24 17:54:45 +0000528}
529
John McCallf85e1932011-06-15 23:02:42 +0000530void ASTStmtReader::
531VisitObjCIndirectCopyRestoreExpr(ObjCIndirectCopyRestoreExpr *E) {
532 VisitExpr(E);
533 E->Operand = Reader.ReadSubExpr();
534 E->setShouldCopy(Record[Idx++]);
535}
536
537void ASTStmtReader::VisitObjCBridgedCastExpr(ObjCBridgedCastExpr *E) {
538 VisitExplicitCastExpr(E);
539 E->LParenLoc = ReadSourceLocation(Record, Idx);
540 E->BridgeKeywordLoc = ReadSourceLocation(Record, Idx);
541 E->Kind = Record[Idx++];
542}
543
Sebastian Redl60adf4a2010-08-18 23:56:52 +0000544void ASTStmtReader::VisitCastExpr(CastExpr *E) {
Chris Lattner4c6f9522009-04-27 05:14:47 +0000545 VisitExpr(E);
John McCallf871d0c2010-08-07 06:22:56 +0000546 unsigned NumBaseSpecs = Record[Idx++];
547 assert(NumBaseSpecs == E->path_size());
Argyrios Kyrtzidisd98a2ab2010-06-29 22:46:25 +0000548 E->setSubExpr(Reader.ReadSubExpr());
Anders Carlssoncdef2b72009-07-31 00:48:10 +0000549 E->setCastKind((CastExpr::CastKind)Record[Idx++]);
John McCallf871d0c2010-08-07 06:22:56 +0000550 CastExpr::path_iterator BaseI = E->path_begin();
Argyrios Kyrtzidis0745d0a2010-07-02 23:30:27 +0000551 while (NumBaseSpecs--) {
Douglas Gregor35942772011-09-09 21:34:22 +0000552 CXXBaseSpecifier *BaseSpec = new (Reader.getContext()) CXXBaseSpecifier;
Sebastian Redlc3632732010-10-05 15:59:54 +0000553 *BaseSpec = Reader.ReadCXXBaseSpecifier(F, Record, Idx);
John McCallf871d0c2010-08-07 06:22:56 +0000554 *BaseI++ = BaseSpec;
Argyrios Kyrtzidis0745d0a2010-07-02 23:30:27 +0000555 }
Chris Lattner4c6f9522009-04-27 05:14:47 +0000556}
557
Sebastian Redl60adf4a2010-08-18 23:56:52 +0000558void ASTStmtReader::VisitBinaryOperator(BinaryOperator *E) {
Chris Lattner4c6f9522009-04-27 05:14:47 +0000559 VisitExpr(E);
Argyrios Kyrtzidisd98a2ab2010-06-29 22:46:25 +0000560 E->setLHS(Reader.ReadSubExpr());
561 E->setRHS(Reader.ReadSubExpr());
Chris Lattner4c6f9522009-04-27 05:14:47 +0000562 E->setOpcode((BinaryOperator::Opcode)Record[Idx++]);
Sebastian Redlc3632732010-10-05 15:59:54 +0000563 E->setOperatorLoc(ReadSourceLocation(Record, Idx));
Chris Lattner4c6f9522009-04-27 05:14:47 +0000564}
565
Sebastian Redl60adf4a2010-08-18 23:56:52 +0000566void ASTStmtReader::VisitCompoundAssignOperator(CompoundAssignOperator *E) {
Chris Lattner4c6f9522009-04-27 05:14:47 +0000567 VisitBinaryOperator(E);
Douglas Gregor393f2492011-07-22 00:38:23 +0000568 E->setComputationLHSType(Reader.readType(F, Record, Idx));
569 E->setComputationResultType(Reader.readType(F, Record, Idx));
Chris Lattner4c6f9522009-04-27 05:14:47 +0000570}
571
Sebastian Redl60adf4a2010-08-18 23:56:52 +0000572void ASTStmtReader::VisitConditionalOperator(ConditionalOperator *E) {
Chris Lattner4c6f9522009-04-27 05:14:47 +0000573 VisitExpr(E);
John McCall56ca35d2011-02-17 10:25:35 +0000574 E->SubExprs[ConditionalOperator::COND] = Reader.ReadSubExpr();
575 E->SubExprs[ConditionalOperator::LHS] = Reader.ReadSubExpr();
576 E->SubExprs[ConditionalOperator::RHS] = Reader.ReadSubExpr();
577 E->QuestionLoc = ReadSourceLocation(Record, Idx);
578 E->ColonLoc = ReadSourceLocation(Record, Idx);
579}
580
581void
582ASTStmtReader::VisitBinaryConditionalOperator(BinaryConditionalOperator *E) {
583 VisitExpr(E);
584 E->OpaqueValue = cast<OpaqueValueExpr>(Reader.ReadSubExpr());
585 E->SubExprs[BinaryConditionalOperator::COMMON] = Reader.ReadSubExpr();
586 E->SubExprs[BinaryConditionalOperator::COND] = Reader.ReadSubExpr();
587 E->SubExprs[BinaryConditionalOperator::LHS] = Reader.ReadSubExpr();
588 E->SubExprs[BinaryConditionalOperator::RHS] = Reader.ReadSubExpr();
589 E->QuestionLoc = ReadSourceLocation(Record, Idx);
590 E->ColonLoc = ReadSourceLocation(Record, Idx);
Chris Lattner4c6f9522009-04-27 05:14:47 +0000591}
592
Sebastian Redl60adf4a2010-08-18 23:56:52 +0000593void ASTStmtReader::VisitImplicitCastExpr(ImplicitCastExpr *E) {
Chris Lattner4c6f9522009-04-27 05:14:47 +0000594 VisitCastExpr(E);
Chris Lattner4c6f9522009-04-27 05:14:47 +0000595}
596
Sebastian Redl60adf4a2010-08-18 23:56:52 +0000597void ASTStmtReader::VisitExplicitCastExpr(ExplicitCastExpr *E) {
Chris Lattner4c6f9522009-04-27 05:14:47 +0000598 VisitCastExpr(E);
Sebastian Redlc3632732010-10-05 15:59:54 +0000599 E->setTypeInfoAsWritten(GetTypeSourceInfo(Record, Idx));
Chris Lattner4c6f9522009-04-27 05:14:47 +0000600}
601
Sebastian Redl60adf4a2010-08-18 23:56:52 +0000602void ASTStmtReader::VisitCStyleCastExpr(CStyleCastExpr *E) {
Chris Lattner4c6f9522009-04-27 05:14:47 +0000603 VisitExplicitCastExpr(E);
Sebastian Redlc3632732010-10-05 15:59:54 +0000604 E->setLParenLoc(ReadSourceLocation(Record, Idx));
605 E->setRParenLoc(ReadSourceLocation(Record, Idx));
Chris Lattner4c6f9522009-04-27 05:14:47 +0000606}
607
Sebastian Redl60adf4a2010-08-18 23:56:52 +0000608void ASTStmtReader::VisitCompoundLiteralExpr(CompoundLiteralExpr *E) {
Chris Lattner4c6f9522009-04-27 05:14:47 +0000609 VisitExpr(E);
Sebastian Redlc3632732010-10-05 15:59:54 +0000610 E->setLParenLoc(ReadSourceLocation(Record, Idx));
611 E->setTypeSourceInfo(GetTypeSourceInfo(Record, Idx));
Argyrios Kyrtzidisd98a2ab2010-06-29 22:46:25 +0000612 E->setInitializer(Reader.ReadSubExpr());
Chris Lattner4c6f9522009-04-27 05:14:47 +0000613 E->setFileScope(Record[Idx++]);
Chris Lattner4c6f9522009-04-27 05:14:47 +0000614}
615
Sebastian Redl60adf4a2010-08-18 23:56:52 +0000616void ASTStmtReader::VisitExtVectorElementExpr(ExtVectorElementExpr *E) {
Chris Lattner4c6f9522009-04-27 05:14:47 +0000617 VisitExpr(E);
Argyrios Kyrtzidisd98a2ab2010-06-29 22:46:25 +0000618 E->setBase(Reader.ReadSubExpr());
Douglas Gregor95eab172011-07-28 20:55:49 +0000619 E->setAccessor(Reader.GetIdentifierInfo(F, Record, Idx));
Sebastian Redlc3632732010-10-05 15:59:54 +0000620 E->setAccessorLoc(ReadSourceLocation(Record, Idx));
Chris Lattner4c6f9522009-04-27 05:14:47 +0000621}
622
Sebastian Redl60adf4a2010-08-18 23:56:52 +0000623void ASTStmtReader::VisitInitListExpr(InitListExpr *E) {
Chris Lattner4c6f9522009-04-27 05:14:47 +0000624 VisitExpr(E);
Argyrios Kyrtzidisd98a2ab2010-06-29 22:46:25 +0000625 E->setSyntacticForm(cast_or_null<InitListExpr>(Reader.ReadSubStmt()));
Sebastian Redlc3632732010-10-05 15:59:54 +0000626 E->setLBraceLoc(ReadSourceLocation(Record, Idx));
627 E->setRBraceLoc(ReadSourceLocation(Record, Idx));
Argyrios Kyrtzidis2ac0b7a2011-04-22 05:29:30 +0000628 bool isArrayFiller = Record[Idx++];
629 Expr *filler = 0;
630 if (isArrayFiller) {
631 filler = Reader.ReadSubExpr();
632 E->ArrayFillerOrUnionFieldInit = filler;
633 } else
Douglas Gregor409448c2011-07-21 22:35:25 +0000634 E->ArrayFillerOrUnionFieldInit = ReadDeclAs<FieldDecl>(Record, Idx);
Chris Lattner4c6f9522009-04-27 05:14:47 +0000635 E->sawArrayRangeDesignator(Record[Idx++]);
Benjamin Kramer1b1a5072012-02-27 13:20:39 +0000636 E->setInitializesStdInitializerList(Record[Idx++]);
Argyrios Kyrtzidis2ac0b7a2011-04-22 05:29:30 +0000637 unsigned NumInits = Record[Idx++];
Douglas Gregor35942772011-09-09 21:34:22 +0000638 E->reserveInits(Reader.getContext(), NumInits);
Argyrios Kyrtzidis2ac0b7a2011-04-22 05:29:30 +0000639 if (isArrayFiller) {
640 for (unsigned I = 0; I != NumInits; ++I) {
641 Expr *init = Reader.ReadSubExpr();
Douglas Gregor35942772011-09-09 21:34:22 +0000642 E->updateInit(Reader.getContext(), I, init ? init : filler);
Argyrios Kyrtzidis2ac0b7a2011-04-22 05:29:30 +0000643 }
644 } else {
645 for (unsigned I = 0; I != NumInits; ++I)
Douglas Gregor35942772011-09-09 21:34:22 +0000646 E->updateInit(Reader.getContext(), I, Reader.ReadSubExpr());
Argyrios Kyrtzidis2ac0b7a2011-04-22 05:29:30 +0000647 }
Chris Lattner4c6f9522009-04-27 05:14:47 +0000648}
649
Sebastian Redl60adf4a2010-08-18 23:56:52 +0000650void ASTStmtReader::VisitDesignatedInitExpr(DesignatedInitExpr *E) {
Chris Lattner4c6f9522009-04-27 05:14:47 +0000651 typedef DesignatedInitExpr::Designator Designator;
652
653 VisitExpr(E);
654 unsigned NumSubExprs = Record[Idx++];
655 assert(NumSubExprs == E->getNumSubExprs() && "Wrong number of subexprs");
656 for (unsigned I = 0; I != NumSubExprs; ++I)
Argyrios Kyrtzidisd98a2ab2010-06-29 22:46:25 +0000657 E->setSubExpr(I, Reader.ReadSubExpr());
Sebastian Redlc3632732010-10-05 15:59:54 +0000658 E->setEqualOrColonLoc(ReadSourceLocation(Record, Idx));
Chris Lattner4c6f9522009-04-27 05:14:47 +0000659 E->setGNUSyntax(Record[Idx++]);
660
Chris Lattner5f9e2722011-07-23 10:55:15 +0000661 SmallVector<Designator, 4> Designators;
Chris Lattner4c6f9522009-04-27 05:14:47 +0000662 while (Idx < Record.size()) {
Sebastian Redl8538e8d2010-08-18 23:57:32 +0000663 switch ((DesignatorTypes)Record[Idx++]) {
664 case DESIG_FIELD_DECL: {
Douglas Gregor409448c2011-07-21 22:35:25 +0000665 FieldDecl *Field = ReadDeclAs<FieldDecl>(Record, Idx);
Mike Stump1eb44332009-09-09 15:08:12 +0000666 SourceLocation DotLoc
Sebastian Redlc3632732010-10-05 15:59:54 +0000667 = ReadSourceLocation(Record, Idx);
Mike Stump1eb44332009-09-09 15:08:12 +0000668 SourceLocation FieldLoc
Sebastian Redlc3632732010-10-05 15:59:54 +0000669 = ReadSourceLocation(Record, Idx);
Mike Stump1eb44332009-09-09 15:08:12 +0000670 Designators.push_back(Designator(Field->getIdentifier(), DotLoc,
Chris Lattner4c6f9522009-04-27 05:14:47 +0000671 FieldLoc));
672 Designators.back().setField(Field);
673 break;
674 }
675
Sebastian Redl8538e8d2010-08-18 23:57:32 +0000676 case DESIG_FIELD_NAME: {
Douglas Gregor95eab172011-07-28 20:55:49 +0000677 const IdentifierInfo *Name = Reader.GetIdentifierInfo(F, Record, Idx);
Mike Stump1eb44332009-09-09 15:08:12 +0000678 SourceLocation DotLoc
Sebastian Redlc3632732010-10-05 15:59:54 +0000679 = ReadSourceLocation(Record, Idx);
Mike Stump1eb44332009-09-09 15:08:12 +0000680 SourceLocation FieldLoc
Sebastian Redlc3632732010-10-05 15:59:54 +0000681 = ReadSourceLocation(Record, Idx);
Chris Lattner4c6f9522009-04-27 05:14:47 +0000682 Designators.push_back(Designator(Name, DotLoc, FieldLoc));
683 break;
684 }
Mike Stump1eb44332009-09-09 15:08:12 +0000685
Sebastian Redl8538e8d2010-08-18 23:57:32 +0000686 case DESIG_ARRAY: {
Chris Lattner4c6f9522009-04-27 05:14:47 +0000687 unsigned Index = Record[Idx++];
688 SourceLocation LBracketLoc
Sebastian Redlc3632732010-10-05 15:59:54 +0000689 = ReadSourceLocation(Record, Idx);
Chris Lattner4c6f9522009-04-27 05:14:47 +0000690 SourceLocation RBracketLoc
Sebastian Redlc3632732010-10-05 15:59:54 +0000691 = ReadSourceLocation(Record, Idx);
Chris Lattner4c6f9522009-04-27 05:14:47 +0000692 Designators.push_back(Designator(Index, LBracketLoc, RBracketLoc));
693 break;
694 }
695
Sebastian Redl8538e8d2010-08-18 23:57:32 +0000696 case DESIG_ARRAY_RANGE: {
Chris Lattner4c6f9522009-04-27 05:14:47 +0000697 unsigned Index = Record[Idx++];
698 SourceLocation LBracketLoc
Sebastian Redlc3632732010-10-05 15:59:54 +0000699 = ReadSourceLocation(Record, Idx);
Chris Lattner4c6f9522009-04-27 05:14:47 +0000700 SourceLocation EllipsisLoc
Sebastian Redlc3632732010-10-05 15:59:54 +0000701 = ReadSourceLocation(Record, Idx);
Chris Lattner4c6f9522009-04-27 05:14:47 +0000702 SourceLocation RBracketLoc
Sebastian Redlc3632732010-10-05 15:59:54 +0000703 = ReadSourceLocation(Record, Idx);
Chris Lattner4c6f9522009-04-27 05:14:47 +0000704 Designators.push_back(Designator(Index, LBracketLoc, EllipsisLoc,
705 RBracketLoc));
706 break;
707 }
708 }
709 }
Douglas Gregor35942772011-09-09 21:34:22 +0000710 E->setDesignators(Reader.getContext(),
Douglas Gregor319d57f2010-01-06 23:17:19 +0000711 Designators.data(), Designators.size());
Chris Lattner4c6f9522009-04-27 05:14:47 +0000712}
713
Sebastian Redl60adf4a2010-08-18 23:56:52 +0000714void ASTStmtReader::VisitImplicitValueInitExpr(ImplicitValueInitExpr *E) {
Chris Lattner4c6f9522009-04-27 05:14:47 +0000715 VisitExpr(E);
Chris Lattner4c6f9522009-04-27 05:14:47 +0000716}
717
Sebastian Redl60adf4a2010-08-18 23:56:52 +0000718void ASTStmtReader::VisitVAArgExpr(VAArgExpr *E) {
Chris Lattner4c6f9522009-04-27 05:14:47 +0000719 VisitExpr(E);
Argyrios Kyrtzidisd98a2ab2010-06-29 22:46:25 +0000720 E->setSubExpr(Reader.ReadSubExpr());
Sebastian Redlc3632732010-10-05 15:59:54 +0000721 E->setWrittenTypeInfo(GetTypeSourceInfo(Record, Idx));
722 E->setBuiltinLoc(ReadSourceLocation(Record, Idx));
723 E->setRParenLoc(ReadSourceLocation(Record, Idx));
Chris Lattner4c6f9522009-04-27 05:14:47 +0000724}
725
Sebastian Redl60adf4a2010-08-18 23:56:52 +0000726void ASTStmtReader::VisitAddrLabelExpr(AddrLabelExpr *E) {
Chris Lattner4c6f9522009-04-27 05:14:47 +0000727 VisitExpr(E);
Sebastian Redlc3632732010-10-05 15:59:54 +0000728 E->setAmpAmpLoc(ReadSourceLocation(Record, Idx));
729 E->setLabelLoc(ReadSourceLocation(Record, Idx));
Douglas Gregor409448c2011-07-21 22:35:25 +0000730 E->setLabel(ReadDeclAs<LabelDecl>(Record, Idx));
Chris Lattner4c6f9522009-04-27 05:14:47 +0000731}
732
Sebastian Redl60adf4a2010-08-18 23:56:52 +0000733void ASTStmtReader::VisitStmtExpr(StmtExpr *E) {
Chris Lattner4c6f9522009-04-27 05:14:47 +0000734 VisitExpr(E);
Sebastian Redlc3632732010-10-05 15:59:54 +0000735 E->setLParenLoc(ReadSourceLocation(Record, Idx));
736 E->setRParenLoc(ReadSourceLocation(Record, Idx));
Argyrios Kyrtzidisd98a2ab2010-06-29 22:46:25 +0000737 E->setSubStmt(cast_or_null<CompoundStmt>(Reader.ReadSubStmt()));
Chris Lattner4c6f9522009-04-27 05:14:47 +0000738}
739
Sebastian Redl60adf4a2010-08-18 23:56:52 +0000740void ASTStmtReader::VisitChooseExpr(ChooseExpr *E) {
Chris Lattner4c6f9522009-04-27 05:14:47 +0000741 VisitExpr(E);
Argyrios Kyrtzidisd98a2ab2010-06-29 22:46:25 +0000742 E->setCond(Reader.ReadSubExpr());
743 E->setLHS(Reader.ReadSubExpr());
744 E->setRHS(Reader.ReadSubExpr());
Sebastian Redlc3632732010-10-05 15:59:54 +0000745 E->setBuiltinLoc(ReadSourceLocation(Record, Idx));
746 E->setRParenLoc(ReadSourceLocation(Record, Idx));
Chris Lattner4c6f9522009-04-27 05:14:47 +0000747}
748
Sebastian Redl60adf4a2010-08-18 23:56:52 +0000749void ASTStmtReader::VisitGNUNullExpr(GNUNullExpr *E) {
Chris Lattner4c6f9522009-04-27 05:14:47 +0000750 VisitExpr(E);
Sebastian Redlc3632732010-10-05 15:59:54 +0000751 E->setTokenLocation(ReadSourceLocation(Record, Idx));
Chris Lattner4c6f9522009-04-27 05:14:47 +0000752}
753
Sebastian Redl60adf4a2010-08-18 23:56:52 +0000754void ASTStmtReader::VisitShuffleVectorExpr(ShuffleVectorExpr *E) {
Chris Lattner4c6f9522009-04-27 05:14:47 +0000755 VisitExpr(E);
Chris Lattner5f9e2722011-07-23 10:55:15 +0000756 SmallVector<Expr *, 16> Exprs;
Chris Lattner4c6f9522009-04-27 05:14:47 +0000757 unsigned NumExprs = Record[Idx++];
Argyrios Kyrtzidis919e6932010-06-28 22:28:35 +0000758 while (NumExprs--)
Argyrios Kyrtzidisd98a2ab2010-06-29 22:46:25 +0000759 Exprs.push_back(Reader.ReadSubExpr());
Douglas Gregor35942772011-09-09 21:34:22 +0000760 E->setExprs(Reader.getContext(), Exprs.data(), Exprs.size());
Sebastian Redlc3632732010-10-05 15:59:54 +0000761 E->setBuiltinLoc(ReadSourceLocation(Record, Idx));
762 E->setRParenLoc(ReadSourceLocation(Record, Idx));
Chris Lattner4c6f9522009-04-27 05:14:47 +0000763}
764
Sebastian Redl60adf4a2010-08-18 23:56:52 +0000765void ASTStmtReader::VisitBlockExpr(BlockExpr *E) {
Chris Lattner4c6f9522009-04-27 05:14:47 +0000766 VisitExpr(E);
Douglas Gregor409448c2011-07-21 22:35:25 +0000767 E->setBlockDecl(ReadDeclAs<BlockDecl>(Record, Idx));
Chris Lattner4c6f9522009-04-27 05:14:47 +0000768}
769
Peter Collingbournef111d932011-04-15 00:35:48 +0000770void ASTStmtReader::VisitGenericSelectionExpr(GenericSelectionExpr *E) {
771 VisitExpr(E);
772 E->NumAssocs = Record[Idx++];
Douglas Gregor35942772011-09-09 21:34:22 +0000773 E->AssocTypes = new (Reader.getContext()) TypeSourceInfo*[E->NumAssocs];
Peter Collingbournef111d932011-04-15 00:35:48 +0000774 E->SubExprs =
Douglas Gregor35942772011-09-09 21:34:22 +0000775 new(Reader.getContext()) Stmt*[GenericSelectionExpr::END_EXPR+E->NumAssocs];
Peter Collingbournef111d932011-04-15 00:35:48 +0000776
777 E->SubExprs[GenericSelectionExpr::CONTROLLING] = Reader.ReadSubExpr();
778 for (unsigned I = 0, N = E->getNumAssocs(); I != N; ++I) {
779 E->AssocTypes[I] = GetTypeSourceInfo(Record, Idx);
780 E->SubExprs[GenericSelectionExpr::END_EXPR+I] = Reader.ReadSubExpr();
781 }
782 E->ResultIndex = Record[Idx++];
783
784 E->GenericLoc = ReadSourceLocation(Record, Idx);
785 E->DefaultLoc = ReadSourceLocation(Record, Idx);
786 E->RParenLoc = ReadSourceLocation(Record, Idx);
787}
788
John McCall4b9c2d22011-11-06 09:01:30 +0000789void ASTStmtReader::VisitPseudoObjectExpr(PseudoObjectExpr *E) {
790 VisitExpr(E);
791 unsigned numSemanticExprs = Record[Idx++];
792 assert(numSemanticExprs + 1 == E->PseudoObjectExprBits.NumSubExprs);
793 E->PseudoObjectExprBits.ResultIndex = Record[Idx++];
794
795 // Read the syntactic expression.
796 E->getSubExprsBuffer()[0] = Reader.ReadSubExpr();
797
798 // Read all the semantic expressions.
799 for (unsigned i = 0; i != numSemanticExprs; ++i) {
800 Expr *subExpr = Reader.ReadSubExpr();
John McCall4b9c2d22011-11-06 09:01:30 +0000801 E->getSubExprsBuffer()[i+1] = subExpr;
802 }
803}
804
Eli Friedman276b0612011-10-11 02:20:01 +0000805void ASTStmtReader::VisitAtomicExpr(AtomicExpr *E) {
806 VisitExpr(E);
Richard Smithe1b2abc2012-04-10 22:49:28 +0000807 E->Op = AtomicExpr::AtomicOp(Record[Idx++]);
808 E->NumSubExprs = AtomicExpr::getNumSubExprs(E->Op);
809 for (unsigned I = 0; I != E->NumSubExprs; ++I)
810 E->SubExprs[I] = Reader.ReadSubExpr();
811 E->BuiltinLoc = ReadSourceLocation(Record, Idx);
812 E->RParenLoc = ReadSourceLocation(Record, Idx);
Eli Friedman276b0612011-10-11 02:20:01 +0000813}
814
Chris Lattner4c6f9522009-04-27 05:14:47 +0000815//===----------------------------------------------------------------------===//
816// Objective-C Expressions and Statements
817
Sebastian Redl60adf4a2010-08-18 23:56:52 +0000818void ASTStmtReader::VisitObjCStringLiteral(ObjCStringLiteral *E) {
Chris Lattner4c6f9522009-04-27 05:14:47 +0000819 VisitExpr(E);
Argyrios Kyrtzidisd98a2ab2010-06-29 22:46:25 +0000820 E->setString(cast<StringLiteral>(Reader.ReadSubStmt()));
Sebastian Redlc3632732010-10-05 15:59:54 +0000821 E->setAtLoc(ReadSourceLocation(Record, Idx));
Chris Lattner4c6f9522009-04-27 05:14:47 +0000822}
823
Patrick Beardeb382ec2012-04-19 00:25:12 +0000824void ASTStmtReader::VisitObjCBoxedExpr(ObjCBoxedExpr *E) {
Ted Kremenekebcb57a2012-03-06 20:05:56 +0000825 VisitExpr(E);
826 // could be one of several IntegerLiteral, FloatLiteral, etc.
Patrick Beardeb382ec2012-04-19 00:25:12 +0000827 E->SubExpr = Reader.ReadSubStmt();
828 E->BoxingMethod = ReadDeclAs<ObjCMethodDecl>(Record, Idx);
829 E->Range = ReadSourceRange(Record, Idx);
Ted Kremenekebcb57a2012-03-06 20:05:56 +0000830}
831
832void ASTStmtReader::VisitObjCArrayLiteral(ObjCArrayLiteral *E) {
833 VisitExpr(E);
834 unsigned NumElements = Record[Idx++];
835 assert(NumElements == E->getNumElements() && "Wrong number of elements");
836 Expr **Elements = E->getElements();
837 for (unsigned I = 0, N = NumElements; I != N; ++I)
838 Elements[I] = Reader.ReadSubExpr();
839 E->ArrayWithObjectsMethod = ReadDeclAs<ObjCMethodDecl>(Record, Idx);
840 E->Range = ReadSourceRange(Record, Idx);
841}
842
843void ASTStmtReader::VisitObjCDictionaryLiteral(ObjCDictionaryLiteral *E) {
844 VisitExpr(E);
845 unsigned NumElements = Record[Idx++];
846 assert(NumElements == E->getNumElements() && "Wrong number of elements");
847 bool HasPackExpansions = Record[Idx++];
848 assert(HasPackExpansions == E->HasPackExpansions &&"Pack expansion mismatch");
849 ObjCDictionaryLiteral::KeyValuePair *KeyValues = E->getKeyValues();
850 ObjCDictionaryLiteral::ExpansionData *Expansions = E->getExpansionData();
851 for (unsigned I = 0; I != NumElements; ++I) {
852 KeyValues[I].Key = Reader.ReadSubExpr();
853 KeyValues[I].Value = Reader.ReadSubExpr();
854 if (HasPackExpansions) {
855 Expansions[I].EllipsisLoc = ReadSourceLocation(Record, Idx);
856 Expansions[I].NumExpansionsPlusOne = Record[Idx++];
857 }
858 }
859 E->DictWithObjectsMethod = ReadDeclAs<ObjCMethodDecl>(Record, Idx);
860 E->Range = ReadSourceRange(Record, Idx);
861}
862
Sebastian Redl60adf4a2010-08-18 23:56:52 +0000863void ASTStmtReader::VisitObjCEncodeExpr(ObjCEncodeExpr *E) {
Chris Lattner4c6f9522009-04-27 05:14:47 +0000864 VisitExpr(E);
Sebastian Redlc3632732010-10-05 15:59:54 +0000865 E->setEncodedTypeSourceInfo(GetTypeSourceInfo(Record, Idx));
866 E->setAtLoc(ReadSourceLocation(Record, Idx));
867 E->setRParenLoc(ReadSourceLocation(Record, Idx));
Chris Lattner4c6f9522009-04-27 05:14:47 +0000868}
869
Sebastian Redl60adf4a2010-08-18 23:56:52 +0000870void ASTStmtReader::VisitObjCSelectorExpr(ObjCSelectorExpr *E) {
Chris Lattner4c6f9522009-04-27 05:14:47 +0000871 VisitExpr(E);
Douglas Gregor2d2689a2011-07-28 21:16:51 +0000872 E->setSelector(Reader.ReadSelector(F, Record, Idx));
Sebastian Redlc3632732010-10-05 15:59:54 +0000873 E->setAtLoc(ReadSourceLocation(Record, Idx));
874 E->setRParenLoc(ReadSourceLocation(Record, Idx));
Chris Lattner4c6f9522009-04-27 05:14:47 +0000875}
876
Sebastian Redl60adf4a2010-08-18 23:56:52 +0000877void ASTStmtReader::VisitObjCProtocolExpr(ObjCProtocolExpr *E) {
Chris Lattner4c6f9522009-04-27 05:14:47 +0000878 VisitExpr(E);
Douglas Gregor409448c2011-07-21 22:35:25 +0000879 E->setProtocol(ReadDeclAs<ObjCProtocolDecl>(Record, Idx));
Sebastian Redlc3632732010-10-05 15:59:54 +0000880 E->setAtLoc(ReadSourceLocation(Record, Idx));
Argyrios Kyrtzidis7d24e282012-05-16 00:50:02 +0000881 E->ProtoLoc = ReadSourceLocation(Record, Idx);
Sebastian Redlc3632732010-10-05 15:59:54 +0000882 E->setRParenLoc(ReadSourceLocation(Record, Idx));
Chris Lattner4c6f9522009-04-27 05:14:47 +0000883}
884
Sebastian Redl60adf4a2010-08-18 23:56:52 +0000885void ASTStmtReader::VisitObjCIvarRefExpr(ObjCIvarRefExpr *E) {
Chris Lattner4c6f9522009-04-27 05:14:47 +0000886 VisitExpr(E);
Douglas Gregor409448c2011-07-21 22:35:25 +0000887 E->setDecl(ReadDeclAs<ObjCIvarDecl>(Record, Idx));
Sebastian Redlc3632732010-10-05 15:59:54 +0000888 E->setLocation(ReadSourceLocation(Record, Idx));
Argyrios Kyrtzidisd98a2ab2010-06-29 22:46:25 +0000889 E->setBase(Reader.ReadSubExpr());
Chris Lattner4c6f9522009-04-27 05:14:47 +0000890 E->setIsArrow(Record[Idx++]);
891 E->setIsFreeIvar(Record[Idx++]);
Chris Lattner4c6f9522009-04-27 05:14:47 +0000892}
893
Sebastian Redl60adf4a2010-08-18 23:56:52 +0000894void ASTStmtReader::VisitObjCPropertyRefExpr(ObjCPropertyRefExpr *E) {
Chris Lattner4c6f9522009-04-27 05:14:47 +0000895 VisitExpr(E);
Argyrios Kyrtzidisb085d892012-03-30 00:19:18 +0000896 unsigned MethodRefFlags = Record[Idx++];
John McCall12f78a62010-12-02 01:19:52 +0000897 bool Implicit = Record[Idx++] != 0;
898 if (Implicit) {
Douglas Gregor409448c2011-07-21 22:35:25 +0000899 ObjCMethodDecl *Getter = ReadDeclAs<ObjCMethodDecl>(Record, Idx);
900 ObjCMethodDecl *Setter = ReadDeclAs<ObjCMethodDecl>(Record, Idx);
Argyrios Kyrtzidisb085d892012-03-30 00:19:18 +0000901 E->setImplicitProperty(Getter, Setter, MethodRefFlags);
John McCall12f78a62010-12-02 01:19:52 +0000902 } else {
Argyrios Kyrtzidisb085d892012-03-30 00:19:18 +0000903 E->setExplicitProperty(ReadDeclAs<ObjCPropertyDecl>(Record, Idx),
904 MethodRefFlags);
Fariborz Jahanian8ac2d442010-10-14 16:04:05 +0000905 }
Sebastian Redlc3632732010-10-05 15:59:54 +0000906 E->setLocation(ReadSourceLocation(Record, Idx));
John McCall12f78a62010-12-02 01:19:52 +0000907 E->setReceiverLocation(ReadSourceLocation(Record, Idx));
908 switch (Record[Idx++]) {
909 case 0:
910 E->setBase(Reader.ReadSubExpr());
911 break;
912 case 1:
Douglas Gregor393f2492011-07-22 00:38:23 +0000913 E->setSuperReceiver(Reader.readType(F, Record, Idx));
John McCall12f78a62010-12-02 01:19:52 +0000914 break;
915 case 2:
Douglas Gregor409448c2011-07-21 22:35:25 +0000916 E->setClassReceiver(ReadDeclAs<ObjCInterfaceDecl>(Record, Idx));
John McCall12f78a62010-12-02 01:19:52 +0000917 break;
918 }
Chris Lattner4c6f9522009-04-27 05:14:47 +0000919}
920
Ted Kremenekebcb57a2012-03-06 20:05:56 +0000921void ASTStmtReader::VisitObjCSubscriptRefExpr(ObjCSubscriptRefExpr *E) {
922 VisitExpr(E);
923 E->setRBracket(ReadSourceLocation(Record, Idx));
924 E->setBaseExpr(Reader.ReadSubExpr());
925 E->setKeyExpr(Reader.ReadSubExpr());
926 E->GetAtIndexMethodDecl = ReadDeclAs<ObjCMethodDecl>(Record, Idx);
927 E->SetAtIndexMethodDecl = ReadDeclAs<ObjCMethodDecl>(Record, Idx);
928}
929
Sebastian Redl60adf4a2010-08-18 23:56:52 +0000930void ASTStmtReader::VisitObjCMessageExpr(ObjCMessageExpr *E) {
Chris Lattner4c6f9522009-04-27 05:14:47 +0000931 VisitExpr(E);
Douglas Gregor04badcf2010-04-21 00:45:42 +0000932 assert(Record[Idx] == E->getNumArgs());
933 ++Idx;
Argyrios Kyrtzidis20718082011-10-03 06:36:51 +0000934 unsigned NumStoredSelLocs = Record[Idx++];
935 E->SelLocsKind = Record[Idx++];
John McCallf85e1932011-06-15 23:02:42 +0000936 E->setDelegateInitCall(Record[Idx++]);
Argyrios Kyrtzidis746f5bc2012-01-12 02:34:39 +0000937 E->IsImplicit = Record[Idx++];
Douglas Gregor04badcf2010-04-21 00:45:42 +0000938 ObjCMessageExpr::ReceiverKind Kind
939 = static_cast<ObjCMessageExpr::ReceiverKind>(Record[Idx++]);
940 switch (Kind) {
941 case ObjCMessageExpr::Instance:
Argyrios Kyrtzidisd98a2ab2010-06-29 22:46:25 +0000942 E->setInstanceReceiver(Reader.ReadSubExpr());
Douglas Gregor04badcf2010-04-21 00:45:42 +0000943 break;
944
945 case ObjCMessageExpr::Class:
Sebastian Redlc3632732010-10-05 15:59:54 +0000946 E->setClassReceiver(GetTypeSourceInfo(Record, Idx));
Douglas Gregor04badcf2010-04-21 00:45:42 +0000947 break;
948
949 case ObjCMessageExpr::SuperClass:
950 case ObjCMessageExpr::SuperInstance: {
Douglas Gregor393f2492011-07-22 00:38:23 +0000951 QualType T = Reader.readType(F, Record, Idx);
Sebastian Redlc3632732010-10-05 15:59:54 +0000952 SourceLocation SuperLoc = ReadSourceLocation(Record, Idx);
Douglas Gregor04badcf2010-04-21 00:45:42 +0000953 E->setSuper(SuperLoc, T, Kind == ObjCMessageExpr::SuperInstance);
954 break;
955 }
956 }
957
958 assert(Kind == E->getReceiverKind());
959
960 if (Record[Idx++])
Douglas Gregor409448c2011-07-21 22:35:25 +0000961 E->setMethodDecl(ReadDeclAs<ObjCMethodDecl>(Record, Idx));
Douglas Gregor04badcf2010-04-21 00:45:42 +0000962 else
Douglas Gregor2d2689a2011-07-28 21:16:51 +0000963 E->setSelector(Reader.ReadSelector(F, Record, Idx));
Douglas Gregor04badcf2010-04-21 00:45:42 +0000964
Argyrios Kyrtzidisf40f0d52010-12-10 20:08:27 +0000965 E->LBracLoc = ReadSourceLocation(Record, Idx);
966 E->RBracLoc = ReadSourceLocation(Record, Idx);
Chris Lattner4c6f9522009-04-27 05:14:47 +0000967
968 for (unsigned I = 0, N = E->getNumArgs(); I != N; ++I)
Argyrios Kyrtzidisd98a2ab2010-06-29 22:46:25 +0000969 E->setArg(I, Reader.ReadSubExpr());
Argyrios Kyrtzidis20718082011-10-03 06:36:51 +0000970
971 SourceLocation *Locs = E->getStoredSelLocs();
972 for (unsigned I = 0; I != NumStoredSelLocs; ++I)
973 Locs[I] = ReadSourceLocation(Record, Idx);
Chris Lattner4c6f9522009-04-27 05:14:47 +0000974}
975
Sebastian Redl60adf4a2010-08-18 23:56:52 +0000976void ASTStmtReader::VisitObjCForCollectionStmt(ObjCForCollectionStmt *S) {
Chris Lattner4c6f9522009-04-27 05:14:47 +0000977 VisitStmt(S);
Argyrios Kyrtzidisd98a2ab2010-06-29 22:46:25 +0000978 S->setElement(Reader.ReadSubStmt());
979 S->setCollection(Reader.ReadSubExpr());
980 S->setBody(Reader.ReadSubStmt());
Sebastian Redlc3632732010-10-05 15:59:54 +0000981 S->setForLoc(ReadSourceLocation(Record, Idx));
982 S->setRParenLoc(ReadSourceLocation(Record, Idx));
Chris Lattner4c6f9522009-04-27 05:14:47 +0000983}
984
Sebastian Redl60adf4a2010-08-18 23:56:52 +0000985void ASTStmtReader::VisitObjCAtCatchStmt(ObjCAtCatchStmt *S) {
Chris Lattner4c6f9522009-04-27 05:14:47 +0000986 VisitStmt(S);
Argyrios Kyrtzidisd98a2ab2010-06-29 22:46:25 +0000987 S->setCatchBody(Reader.ReadSubStmt());
Douglas Gregor409448c2011-07-21 22:35:25 +0000988 S->setCatchParamDecl(ReadDeclAs<VarDecl>(Record, Idx));
Sebastian Redlc3632732010-10-05 15:59:54 +0000989 S->setAtCatchLoc(ReadSourceLocation(Record, Idx));
990 S->setRParenLoc(ReadSourceLocation(Record, Idx));
Chris Lattner4c6f9522009-04-27 05:14:47 +0000991}
992
Sebastian Redl60adf4a2010-08-18 23:56:52 +0000993void ASTStmtReader::VisitObjCAtFinallyStmt(ObjCAtFinallyStmt *S) {
Chris Lattner4c6f9522009-04-27 05:14:47 +0000994 VisitStmt(S);
Argyrios Kyrtzidisd98a2ab2010-06-29 22:46:25 +0000995 S->setFinallyBody(Reader.ReadSubStmt());
Sebastian Redlc3632732010-10-05 15:59:54 +0000996 S->setAtFinallyLoc(ReadSourceLocation(Record, Idx));
Chris Lattner4c6f9522009-04-27 05:14:47 +0000997}
998
John McCallf85e1932011-06-15 23:02:42 +0000999void ASTStmtReader::VisitObjCAutoreleasePoolStmt(ObjCAutoreleasePoolStmt *S) {
1000 VisitStmt(S);
1001 S->setSubStmt(Reader.ReadSubStmt());
1002 S->setAtLoc(ReadSourceLocation(Record, Idx));
1003}
1004
Sebastian Redl60adf4a2010-08-18 23:56:52 +00001005void ASTStmtReader::VisitObjCAtTryStmt(ObjCAtTryStmt *S) {
Chris Lattner4c6f9522009-04-27 05:14:47 +00001006 VisitStmt(S);
Douglas Gregor8f5e3dd2010-04-23 22:50:49 +00001007 assert(Record[Idx] == S->getNumCatchStmts());
1008 ++Idx;
1009 bool HasFinally = Record[Idx++];
Argyrios Kyrtzidisd98a2ab2010-06-29 22:46:25 +00001010 S->setTryBody(Reader.ReadSubStmt());
Argyrios Kyrtzidis919e6932010-06-28 22:28:35 +00001011 for (unsigned I = 0, N = S->getNumCatchStmts(); I != N; ++I)
Argyrios Kyrtzidisd98a2ab2010-06-29 22:46:25 +00001012 S->setCatchStmt(I, cast_or_null<ObjCAtCatchStmt>(Reader.ReadSubStmt()));
Douglas Gregor8f5e3dd2010-04-23 22:50:49 +00001013
Douglas Gregor8f5e3dd2010-04-23 22:50:49 +00001014 if (HasFinally)
Argyrios Kyrtzidisd98a2ab2010-06-29 22:46:25 +00001015 S->setFinallyStmt(Reader.ReadSubStmt());
Sebastian Redlc3632732010-10-05 15:59:54 +00001016 S->setAtTryLoc(ReadSourceLocation(Record, Idx));
Chris Lattner4c6f9522009-04-27 05:14:47 +00001017}
1018
Sebastian Redl60adf4a2010-08-18 23:56:52 +00001019void ASTStmtReader::VisitObjCAtSynchronizedStmt(ObjCAtSynchronizedStmt *S) {
Chris Lattner4c6f9522009-04-27 05:14:47 +00001020 VisitStmt(S);
Argyrios Kyrtzidisd98a2ab2010-06-29 22:46:25 +00001021 S->setSynchExpr(Reader.ReadSubStmt());
1022 S->setSynchBody(Reader.ReadSubStmt());
Sebastian Redlc3632732010-10-05 15:59:54 +00001023 S->setAtSynchronizedLoc(ReadSourceLocation(Record, Idx));
Chris Lattner4c6f9522009-04-27 05:14:47 +00001024}
1025
Sebastian Redl60adf4a2010-08-18 23:56:52 +00001026void ASTStmtReader::VisitObjCAtThrowStmt(ObjCAtThrowStmt *S) {
Chris Lattner4c6f9522009-04-27 05:14:47 +00001027 VisitStmt(S);
Argyrios Kyrtzidisd98a2ab2010-06-29 22:46:25 +00001028 S->setThrowExpr(Reader.ReadSubStmt());
Sebastian Redlc3632732010-10-05 15:59:54 +00001029 S->setThrowLoc(ReadSourceLocation(Record, Idx));
Chris Lattner4c6f9522009-04-27 05:14:47 +00001030}
1031
Ted Kremenekebcb57a2012-03-06 20:05:56 +00001032void ASTStmtReader::VisitObjCBoolLiteralExpr(ObjCBoolLiteralExpr *E) {
1033 VisitExpr(E);
1034 E->setValue(Record[Idx++]);
1035 E->setLocation(ReadSourceLocation(Record, Idx));
1036}
1037
Argyrios Kyrtzidisba0a9002009-07-14 03:19:21 +00001038//===----------------------------------------------------------------------===//
1039// C++ Expressions and Statements
Argyrios Kyrtzidis7cb45e32010-07-22 16:03:56 +00001040//===----------------------------------------------------------------------===//
1041
Sebastian Redl60adf4a2010-08-18 23:56:52 +00001042void ASTStmtReader::VisitCXXCatchStmt(CXXCatchStmt *S) {
Argyrios Kyrtzidis7cb45e32010-07-22 16:03:56 +00001043 VisitStmt(S);
Sebastian Redlc3632732010-10-05 15:59:54 +00001044 S->CatchLoc = ReadSourceLocation(Record, Idx);
Douglas Gregor409448c2011-07-21 22:35:25 +00001045 S->ExceptionDecl = ReadDeclAs<VarDecl>(Record, Idx);
Argyrios Kyrtzidis7cb45e32010-07-22 16:03:56 +00001046 S->HandlerBlock = Reader.ReadSubStmt();
1047}
1048
Sebastian Redl60adf4a2010-08-18 23:56:52 +00001049void ASTStmtReader::VisitCXXTryStmt(CXXTryStmt *S) {
Argyrios Kyrtzidis7cb45e32010-07-22 16:03:56 +00001050 VisitStmt(S);
1051 assert(Record[Idx] == S->getNumHandlers() && "NumStmtFields is wrong ?");
1052 ++Idx;
Sebastian Redlc3632732010-10-05 15:59:54 +00001053 S->TryLoc = ReadSourceLocation(Record, Idx);
Argyrios Kyrtzidis7cb45e32010-07-22 16:03:56 +00001054 S->getStmts()[0] = Reader.ReadSubStmt();
1055 for (unsigned i = 0, e = S->getNumHandlers(); i != e; ++i)
1056 S->getStmts()[i + 1] = Reader.ReadSubStmt();
1057}
Argyrios Kyrtzidisba0a9002009-07-14 03:19:21 +00001058
Richard Smithad762fc2011-04-14 22:09:26 +00001059void ASTStmtReader::VisitCXXForRangeStmt(CXXForRangeStmt *S) {
1060 VisitStmt(S);
1061 S->setForLoc(ReadSourceLocation(Record, Idx));
1062 S->setColonLoc(ReadSourceLocation(Record, Idx));
1063 S->setRParenLoc(ReadSourceLocation(Record, Idx));
1064 S->setRangeStmt(Reader.ReadSubStmt());
1065 S->setBeginEndStmt(Reader.ReadSubStmt());
1066 S->setCond(Reader.ReadSubExpr());
1067 S->setInc(Reader.ReadSubExpr());
1068 S->setLoopVarStmt(Reader.ReadSubStmt());
1069 S->setBody(Reader.ReadSubStmt());
1070}
1071
Douglas Gregorba0513d2011-10-25 01:33:02 +00001072void ASTStmtReader::VisitMSDependentExistsStmt(MSDependentExistsStmt *S) {
1073 VisitStmt(S);
1074 S->KeywordLoc = ReadSourceLocation(Record, Idx);
1075 S->IsIfExists = Record[Idx++];
1076 S->QualifierLoc = Reader.ReadNestedNameSpecifierLoc(F, Record, Idx);
1077 ReadDeclarationNameInfo(S->NameInfo, Record, Idx);
1078 S->SubStmt = Reader.ReadSubStmt();
1079}
1080
Sebastian Redl60adf4a2010-08-18 23:56:52 +00001081void ASTStmtReader::VisitCXXOperatorCallExpr(CXXOperatorCallExpr *E) {
Argyrios Kyrtzidis919e6932010-06-28 22:28:35 +00001082 VisitCallExpr(E);
Argyrios Kyrtzidis4548ca22012-04-30 22:12:22 +00001083 E->Operator = (OverloadedOperatorKind)Record[Idx++];
1084 E->Range = Reader.ReadSourceRange(F, Record, Idx);
Argyrios Kyrtzidisba0a9002009-07-14 03:19:21 +00001085}
1086
Sebastian Redl60adf4a2010-08-18 23:56:52 +00001087void ASTStmtReader::VisitCXXConstructExpr(CXXConstructExpr *E) {
Douglas Gregor39da0b82009-09-09 23:08:42 +00001088 VisitExpr(E);
Argyrios Kyrtzidis6d00c132010-07-10 11:46:15 +00001089 E->NumArgs = Record[Idx++];
1090 if (E->NumArgs)
Douglas Gregor35942772011-09-09 21:34:22 +00001091 E->Args = new (Reader.getContext()) Stmt*[E->NumArgs];
Argyrios Kyrtzidis5e1b7c22010-06-24 08:57:09 +00001092 for (unsigned I = 0, N = E->getNumArgs(); I != N; ++I)
Argyrios Kyrtzidisd98a2ab2010-06-29 22:46:25 +00001093 E->setArg(I, Reader.ReadSubExpr());
Douglas Gregor409448c2011-07-21 22:35:25 +00001094 E->setConstructor(ReadDeclAs<CXXConstructorDecl>(Record, Idx));
Sebastian Redlc3632732010-10-05 15:59:54 +00001095 E->setLocation(ReadSourceLocation(Record, Idx));
Abramo Bagnara7cc58b42011-10-05 07:56:41 +00001096 E->setElidable(Record[Idx++]);
1097 E->setHadMultipleCandidates(Record[Idx++]);
Douglas Gregor16006c92009-12-16 18:50:27 +00001098 E->setRequiresZeroInitialization(Record[Idx++]);
Douglas Gregor3c9034c2010-05-15 00:13:29 +00001099 E->setConstructionKind((CXXConstructExpr::ConstructionKind)Record[Idx++]);
Chandler Carruth428edaf2010-10-25 08:47:36 +00001100 E->ParenRange = ReadSourceRange(Record, Idx);
Douglas Gregor39da0b82009-09-09 23:08:42 +00001101}
Chris Lattner4c6f9522009-04-27 05:14:47 +00001102
Sebastian Redl60adf4a2010-08-18 23:56:52 +00001103void ASTStmtReader::VisitCXXTemporaryObjectExpr(CXXTemporaryObjectExpr *E) {
Argyrios Kyrtzidis6d00c132010-07-10 11:46:15 +00001104 VisitCXXConstructExpr(E);
Sebastian Redlc3632732010-10-05 15:59:54 +00001105 E->Type = GetTypeSourceInfo(Record, Idx);
Argyrios Kyrtzidis6d00c132010-07-10 11:46:15 +00001106}
1107
Douglas Gregor01d08012012-02-07 10:09:13 +00001108void ASTStmtReader::VisitLambdaExpr(LambdaExpr *E) {
1109 VisitExpr(E);
Douglas Gregor9d36f5d2012-02-14 17:54:36 +00001110 unsigned NumCaptures = Record[Idx++];
1111 assert(NumCaptures == E->NumCaptures);(void)NumCaptures;
1112 unsigned NumArrayIndexVars = Record[Idx++];
1113 E->IntroducerRange = ReadSourceRange(Record, Idx);
1114 E->CaptureDefault = static_cast<LambdaCaptureDefault>(Record[Idx++]);
1115 E->ExplicitParams = Record[Idx++];
1116 E->ExplicitResultType = Record[Idx++];
1117 E->ClosingBrace = ReadSourceLocation(Record, Idx);
1118
1119 // Read capture initializers.
1120 for (LambdaExpr::capture_init_iterator C = E->capture_init_begin(),
1121 CEnd = E->capture_init_end();
1122 C != CEnd; ++C)
1123 *C = Reader.ReadSubExpr();
1124
1125 // Read array capture index variables.
1126 if (NumArrayIndexVars > 0) {
1127 unsigned *ArrayIndexStarts = E->getArrayIndexStarts();
1128 for (unsigned I = 0; I != NumCaptures + 1; ++I)
1129 ArrayIndexStarts[I] = Record[Idx++];
1130
1131 VarDecl **ArrayIndexVars = E->getArrayIndexVars();
1132 for (unsigned I = 0; I != NumArrayIndexVars; ++I)
1133 ArrayIndexVars[I] = ReadDeclAs<VarDecl>(Record, Idx);
1134 }
Douglas Gregor01d08012012-02-07 10:09:13 +00001135}
1136
Sebastian Redl60adf4a2010-08-18 23:56:52 +00001137void ASTStmtReader::VisitCXXNamedCastExpr(CXXNamedCastExpr *E) {
Argyrios Kyrtzidis919e6932010-06-28 22:28:35 +00001138 VisitExplicitCastExpr(E);
Douglas Gregor1d5d0b92011-01-12 22:41:29 +00001139 SourceRange R = ReadSourceRange(Record, Idx);
1140 E->Loc = R.getBegin();
1141 E->RParenLoc = R.getEnd();
Sam Weinigce757a72010-01-16 21:21:01 +00001142}
1143
Sebastian Redl60adf4a2010-08-18 23:56:52 +00001144void ASTStmtReader::VisitCXXStaticCastExpr(CXXStaticCastExpr *E) {
Sam Weinigce757a72010-01-16 21:21:01 +00001145 return VisitCXXNamedCastExpr(E);
1146}
1147
Sebastian Redl60adf4a2010-08-18 23:56:52 +00001148void ASTStmtReader::VisitCXXDynamicCastExpr(CXXDynamicCastExpr *E) {
Sam Weinigce757a72010-01-16 21:21:01 +00001149 return VisitCXXNamedCastExpr(E);
1150}
1151
Sebastian Redl60adf4a2010-08-18 23:56:52 +00001152void ASTStmtReader::VisitCXXReinterpretCastExpr(CXXReinterpretCastExpr *E) {
Sam Weinigce757a72010-01-16 21:21:01 +00001153 return VisitCXXNamedCastExpr(E);
1154}
1155
Sebastian Redl60adf4a2010-08-18 23:56:52 +00001156void ASTStmtReader::VisitCXXConstCastExpr(CXXConstCastExpr *E) {
Sam Weinigce757a72010-01-16 21:21:01 +00001157 return VisitCXXNamedCastExpr(E);
1158}
1159
Sebastian Redl60adf4a2010-08-18 23:56:52 +00001160void ASTStmtReader::VisitCXXFunctionalCastExpr(CXXFunctionalCastExpr *E) {
Argyrios Kyrtzidis919e6932010-06-28 22:28:35 +00001161 VisitExplicitCastExpr(E);
Sebastian Redlc3632732010-10-05 15:59:54 +00001162 E->setTypeBeginLoc(ReadSourceLocation(Record, Idx));
1163 E->setRParenLoc(ReadSourceLocation(Record, Idx));
Sam Weinigce757a72010-01-16 21:21:01 +00001164}
1165
Richard Smith9fcce652012-03-07 08:35:16 +00001166void ASTStmtReader::VisitUserDefinedLiteral(UserDefinedLiteral *E) {
1167 VisitCallExpr(E);
1168 E->UDSuffixLoc = ReadSourceLocation(Record, Idx);
1169}
1170
Sebastian Redl60adf4a2010-08-18 23:56:52 +00001171void ASTStmtReader::VisitCXXBoolLiteralExpr(CXXBoolLiteralExpr *E) {
Sam Weinigeb7f9612010-02-07 06:32:43 +00001172 VisitExpr(E);
1173 E->setValue(Record[Idx++]);
Sebastian Redlc3632732010-10-05 15:59:54 +00001174 E->setLocation(ReadSourceLocation(Record, Idx));
Sam Weinigeb7f9612010-02-07 06:32:43 +00001175}
1176
Sebastian Redl60adf4a2010-08-18 23:56:52 +00001177void ASTStmtReader::VisitCXXNullPtrLiteralExpr(CXXNullPtrLiteralExpr *E) {
Sam Weinigeb7f9612010-02-07 06:32:43 +00001178 VisitExpr(E);
Sebastian Redlc3632732010-10-05 15:59:54 +00001179 E->setLocation(ReadSourceLocation(Record, Idx));
Sam Weinigeb7f9612010-02-07 06:32:43 +00001180}
1181
Sebastian Redl60adf4a2010-08-18 23:56:52 +00001182void ASTStmtReader::VisitCXXTypeidExpr(CXXTypeidExpr *E) {
Chris Lattner14ab24f2010-05-09 06:03:39 +00001183 VisitExpr(E);
Sebastian Redlc3632732010-10-05 15:59:54 +00001184 E->setSourceRange(ReadSourceRange(Record, Idx));
Chris Lattner14ab24f2010-05-09 06:03:39 +00001185 if (E->isTypeOperand()) { // typeid(int)
Sebastian Redl577d4792010-07-22 22:43:28 +00001186 E->setTypeOperandSourceInfo(
Sebastian Redlc3632732010-10-05 15:59:54 +00001187 GetTypeSourceInfo(Record, Idx));
Argyrios Kyrtzidis919e6932010-06-28 22:28:35 +00001188 return;
Chris Lattner14ab24f2010-05-09 06:03:39 +00001189 }
1190
1191 // typeid(42+2)
Argyrios Kyrtzidisd98a2ab2010-06-29 22:46:25 +00001192 E->setExprOperand(Reader.ReadSubExpr());
Chris Lattner14ab24f2010-05-09 06:03:39 +00001193}
1194
Sebastian Redl60adf4a2010-08-18 23:56:52 +00001195void ASTStmtReader::VisitCXXThisExpr(CXXThisExpr *E) {
Chris Lattner2fbdfcd2010-05-09 06:15:05 +00001196 VisitExpr(E);
Sebastian Redlc3632732010-10-05 15:59:54 +00001197 E->setLocation(ReadSourceLocation(Record, Idx));
Chris Lattner2fbdfcd2010-05-09 06:15:05 +00001198 E->setImplicit(Record[Idx++]);
Chris Lattner2fbdfcd2010-05-09 06:15:05 +00001199}
1200
Sebastian Redl60adf4a2010-08-18 23:56:52 +00001201void ASTStmtReader::VisitCXXThrowExpr(CXXThrowExpr *E) {
Chris Lattner2fbdfcd2010-05-09 06:15:05 +00001202 VisitExpr(E);
Douglas Gregorbca01b42011-07-06 22:04:06 +00001203 E->ThrowLoc = ReadSourceLocation(Record, Idx);
1204 E->Op = Reader.ReadSubExpr();
1205 E->IsThrownVariableInScope = Record[Idx++];
Chris Lattner2fbdfcd2010-05-09 06:15:05 +00001206}
Chris Lattner14ab24f2010-05-09 06:03:39 +00001207
Sebastian Redl60adf4a2010-08-18 23:56:52 +00001208void ASTStmtReader::VisitCXXDefaultArgExpr(CXXDefaultArgExpr *E) {
Chris Lattner030854b2010-05-09 06:40:08 +00001209 VisitExpr(E);
Argyrios Kyrtzidis8a507332010-07-02 23:30:15 +00001210
Douglas Gregordf226552011-09-23 22:07:41 +00001211 assert((bool)Record[Idx] == E->Param.getInt() && "We messed up at creation ?");
Argyrios Kyrtzidis8a507332010-07-02 23:30:15 +00001212 ++Idx; // HasOtherExprStored and SubExpr was handled during creation.
Douglas Gregor409448c2011-07-21 22:35:25 +00001213 E->Param.setPointer(ReadDeclAs<ParmVarDecl>(Record, Idx));
Sebastian Redlc3632732010-10-05 15:59:54 +00001214 E->Loc = ReadSourceLocation(Record, Idx);
Chris Lattnerd2598362010-05-10 00:25:06 +00001215}
1216
Sebastian Redl60adf4a2010-08-18 23:56:52 +00001217void ASTStmtReader::VisitCXXBindTemporaryExpr(CXXBindTemporaryExpr *E) {
Chris Lattnerd2598362010-05-10 00:25:06 +00001218 VisitExpr(E);
Douglas Gregor409448c2011-07-21 22:35:25 +00001219 E->setTemporary(Reader.ReadCXXTemporary(F, Record, Idx));
Argyrios Kyrtzidisd98a2ab2010-06-29 22:46:25 +00001220 E->setSubExpr(Reader.ReadSubExpr());
Chris Lattnerd2598362010-05-10 00:25:06 +00001221}
1222
Sebastian Redl60adf4a2010-08-18 23:56:52 +00001223void ASTStmtReader::VisitCXXScalarValueInitExpr(CXXScalarValueInitExpr *E) {
Chris Lattner59218632010-05-10 01:22:27 +00001224 VisitExpr(E);
Sebastian Redlc3632732010-10-05 15:59:54 +00001225 E->TypeInfo = GetTypeSourceInfo(Record, Idx);
1226 E->RParenLoc = ReadSourceLocation(Record, Idx);
Chris Lattner59218632010-05-10 01:22:27 +00001227}
1228
Sebastian Redl60adf4a2010-08-18 23:56:52 +00001229void ASTStmtReader::VisitCXXNewExpr(CXXNewExpr *E) {
Chris Lattner59218632010-05-10 01:22:27 +00001230 VisitExpr(E);
John McCall6ec278d2011-01-27 09:37:56 +00001231 E->GlobalNew = Record[Idx++];
Sebastian Redl1548d142012-02-16 11:35:52 +00001232 bool isArray = Record[Idx++];
Sebastian Redl2aed8b82012-02-16 12:22:20 +00001233 E->UsualArrayDeleteWantsSize = Record[Idx++];
Chris Lattner59218632010-05-10 01:22:27 +00001234 unsigned NumPlacementArgs = Record[Idx++];
Sebastian Redl2aed8b82012-02-16 12:22:20 +00001235 E->StoredInitializationStyle = Record[Idx++];
Douglas Gregor409448c2011-07-21 22:35:25 +00001236 E->setOperatorNew(ReadDeclAs<FunctionDecl>(Record, Idx));
1237 E->setOperatorDelete(ReadDeclAs<FunctionDecl>(Record, Idx));
Sebastian Redlc3632732010-10-05 15:59:54 +00001238 E->AllocatedTypeInfo = GetTypeSourceInfo(Record, Idx);
Douglas Gregor83bc2762012-02-20 16:12:14 +00001239 E->TypeIdParens = ReadSourceRange(Record, Idx);
Chandler Carruth428edaf2010-10-25 08:47:36 +00001240 E->StartLoc = ReadSourceLocation(Record, Idx);
Douglas Gregor83bc2762012-02-20 16:12:14 +00001241 E->DirectInitRange = ReadSourceRange(Record, Idx);
Chandler Carruth428edaf2010-10-25 08:47:36 +00001242
Douglas Gregor35942772011-09-09 21:34:22 +00001243 E->AllocateArgsArray(Reader.getContext(), isArray, NumPlacementArgs,
Sebastian Redl2aed8b82012-02-16 12:22:20 +00001244 E->StoredInitializationStyle != 0);
Chris Lattner59218632010-05-10 01:22:27 +00001245
1246 // Install all the subexpressions.
Chris Lattner59218632010-05-10 01:22:27 +00001247 for (CXXNewExpr::raw_arg_iterator I = E->raw_arg_begin(),e = E->raw_arg_end();
1248 I != e; ++I)
Argyrios Kyrtzidisd98a2ab2010-06-29 22:46:25 +00001249 *I = Reader.ReadSubStmt();
Chris Lattner59218632010-05-10 01:22:27 +00001250}
1251
Sebastian Redl60adf4a2010-08-18 23:56:52 +00001252void ASTStmtReader::VisitCXXDeleteExpr(CXXDeleteExpr *E) {
Argyrios Kyrtzidis95fc98c2010-06-22 17:07:59 +00001253 VisitExpr(E);
Argyrios Kyrtzidisf1b89112010-09-13 20:15:40 +00001254 E->GlobalDelete = Record[Idx++];
1255 E->ArrayForm = Record[Idx++];
Argyrios Kyrtzidis4076dac2010-09-13 20:15:54 +00001256 E->ArrayFormAsWritten = Record[Idx++];
John McCall6ec278d2011-01-27 09:37:56 +00001257 E->UsualArrayDeleteWantsSize = Record[Idx++];
Douglas Gregor409448c2011-07-21 22:35:25 +00001258 E->OperatorDelete = ReadDeclAs<FunctionDecl>(Record, Idx);
Argyrios Kyrtzidisf1b89112010-09-13 20:15:40 +00001259 E->Argument = Reader.ReadSubExpr();
Sebastian Redlc3632732010-10-05 15:59:54 +00001260 E->Loc = ReadSourceLocation(Record, Idx);
Argyrios Kyrtzidis95fc98c2010-06-22 17:07:59 +00001261}
Chris Lattnerd2598362010-05-10 00:25:06 +00001262
Sebastian Redl60adf4a2010-08-18 23:56:52 +00001263void ASTStmtReader::VisitCXXPseudoDestructorExpr(CXXPseudoDestructorExpr *E) {
Argyrios Kyrtzidisde4bd182010-06-28 09:32:03 +00001264 VisitExpr(E);
1265
Douglas Gregorf3db29f2011-02-25 18:19:59 +00001266 E->Base = Reader.ReadSubExpr();
1267 E->IsArrow = Record[Idx++];
1268 E->OperatorLoc = ReadSourceLocation(Record, Idx);
1269 E->QualifierLoc = Reader.ReadNestedNameSpecifierLoc(F, Record, Idx);
1270 E->ScopeType = GetTypeSourceInfo(Record, Idx);
1271 E->ColonColonLoc = ReadSourceLocation(Record, Idx);
1272 E->TildeLoc = ReadSourceLocation(Record, Idx);
Argyrios Kyrtzidisde4bd182010-06-28 09:32:03 +00001273
Douglas Gregor95eab172011-07-28 20:55:49 +00001274 IdentifierInfo *II = Reader.GetIdentifierInfo(F, Record, Idx);
Argyrios Kyrtzidisde4bd182010-06-28 09:32:03 +00001275 if (II)
Sebastian Redlc3632732010-10-05 15:59:54 +00001276 E->setDestroyedType(II, ReadSourceLocation(Record, Idx));
Argyrios Kyrtzidisde4bd182010-06-28 09:32:03 +00001277 else
Sebastian Redlc3632732010-10-05 15:59:54 +00001278 E->setDestroyedType(GetTypeSourceInfo(Record, Idx));
Argyrios Kyrtzidisde4bd182010-06-28 09:32:03 +00001279}
1280
John McCall4765fa02010-12-06 08:20:24 +00001281void ASTStmtReader::VisitExprWithCleanups(ExprWithCleanups *E) {
Chris Lattnerd2598362010-05-10 00:25:06 +00001282 VisitExpr(E);
John McCall80ee6e82011-11-10 05:35:25 +00001283
1284 unsigned NumObjects = Record[Idx++];
1285 assert(NumObjects == E->getNumObjects());
1286 for (unsigned i = 0; i != NumObjects; ++i)
1287 E->getObjectsBuffer()[i] = ReadDeclAs<BlockDecl>(Record, Idx);
1288
1289 E->SubExpr = Reader.ReadSubExpr();
Chris Lattner030854b2010-05-09 06:40:08 +00001290}
1291
Argyrios Kyrtzidis919e6932010-06-28 22:28:35 +00001292void
Sebastian Redl60adf4a2010-08-18 23:56:52 +00001293ASTStmtReader::VisitCXXDependentScopeMemberExpr(CXXDependentScopeMemberExpr *E){
Argyrios Kyrtzidis8dfbd8b2010-06-24 08:57:31 +00001294 VisitExpr(E);
Abramo Bagnarae4b92762012-01-27 09:46:47 +00001295
1296 if (Record[Idx++]) // HasTemplateKWAndArgsInfo
1297 ReadTemplateKWAndArgsInfo(*E->getTemplateKWAndArgsInfo(),
1298 /*NumTemplateArgs=*/Record[Idx++]);
Argyrios Kyrtzidis8dfbd8b2010-06-24 08:57:31 +00001299
Douglas Gregor7c3179c2011-02-28 18:50:33 +00001300 E->Base = Reader.ReadSubExpr();
Douglas Gregor393f2492011-07-22 00:38:23 +00001301 E->BaseType = Reader.readType(F, Record, Idx);
Douglas Gregor7c3179c2011-02-28 18:50:33 +00001302 E->IsArrow = Record[Idx++];
1303 E->OperatorLoc = ReadSourceLocation(Record, Idx);
1304 E->QualifierLoc = Reader.ReadNestedNameSpecifierLoc(F, Record, Idx);
Douglas Gregor409448c2011-07-21 22:35:25 +00001305 E->FirstQualifierFoundInScope = ReadDeclAs<NamedDecl>(Record, Idx);
Argyrios Kyrtzidis40451072010-10-15 18:21:24 +00001306 ReadDeclarationNameInfo(E->MemberNameInfo, Record, Idx);
Argyrios Kyrtzidis8dfbd8b2010-06-24 08:57:31 +00001307}
1308
Argyrios Kyrtzidis919e6932010-06-28 22:28:35 +00001309void
Sebastian Redl60adf4a2010-08-18 23:56:52 +00001310ASTStmtReader::VisitDependentScopeDeclRefExpr(DependentScopeDeclRefExpr *E) {
Argyrios Kyrtzidis12dffcd2010-06-28 09:31:56 +00001311 VisitExpr(E);
Abramo Bagnarae4b92762012-01-27 09:46:47 +00001312
1313 if (Record[Idx++]) // HasTemplateKWAndArgsInfo
1314 ReadTemplateKWAndArgsInfo(*E->getTemplateKWAndArgsInfo(),
1315 /*NumTemplateArgs=*/Record[Idx++]);
Douglas Gregor00cf3cc2011-02-25 20:49:16 +00001316
1317 E->QualifierLoc = Reader.ReadNestedNameSpecifierLoc(F, Record, Idx);
Argyrios Kyrtzidis40451072010-10-15 18:21:24 +00001318 ReadDeclarationNameInfo(E->NameInfo, Record, Idx);
Argyrios Kyrtzidis12dffcd2010-06-28 09:31:56 +00001319}
1320
Argyrios Kyrtzidis919e6932010-06-28 22:28:35 +00001321void
Sebastian Redl60adf4a2010-08-18 23:56:52 +00001322ASTStmtReader::VisitCXXUnresolvedConstructExpr(CXXUnresolvedConstructExpr *E) {
Argyrios Kyrtzidis8dfbd8b2010-06-24 08:57:31 +00001323 VisitExpr(E);
1324 assert(Record[Idx] == E->arg_size() && "Read wrong record during creation ?");
1325 ++Idx; // NumArgs;
1326 for (unsigned I = 0, N = E->arg_size(); I != N; ++I)
Argyrios Kyrtzidisd98a2ab2010-06-29 22:46:25 +00001327 E->setArg(I, Reader.ReadSubExpr());
Sebastian Redlc3632732010-10-05 15:59:54 +00001328 E->Type = GetTypeSourceInfo(Record, Idx);
1329 E->setLParenLoc(ReadSourceLocation(Record, Idx));
1330 E->setRParenLoc(ReadSourceLocation(Record, Idx));
Argyrios Kyrtzidis8dfbd8b2010-06-24 08:57:31 +00001331}
1332
Sebastian Redl60adf4a2010-08-18 23:56:52 +00001333void ASTStmtReader::VisitOverloadExpr(OverloadExpr *E) {
Argyrios Kyrtzidisa77eb082010-06-25 09:03:26 +00001334 VisitExpr(E);
Abramo Bagnarae4b92762012-01-27 09:46:47 +00001335
1336 if (Record[Idx++]) // HasTemplateKWAndArgsInfo
1337 ReadTemplateKWAndArgsInfo(*E->getTemplateKWAndArgsInfo(),
1338 /*NumTemplateArgs=*/Record[Idx++]);
Argyrios Kyrtzidisa77eb082010-06-25 09:03:26 +00001339
1340 unsigned NumDecls = Record[Idx++];
1341 UnresolvedSet<8> Decls;
1342 for (unsigned i = 0; i != NumDecls; ++i) {
Douglas Gregor409448c2011-07-21 22:35:25 +00001343 NamedDecl *D = ReadDeclAs<NamedDecl>(Record, Idx);
Argyrios Kyrtzidisa77eb082010-06-25 09:03:26 +00001344 AccessSpecifier AS = (AccessSpecifier)Record[Idx++];
1345 Decls.addDecl(D, AS);
1346 }
Douglas Gregor35942772011-09-09 21:34:22 +00001347 E->initializeResults(Reader.getContext(), Decls.begin(), Decls.end());
Argyrios Kyrtzidisa77eb082010-06-25 09:03:26 +00001348
Argyrios Kyrtzidis40451072010-10-15 18:21:24 +00001349 ReadDeclarationNameInfo(E->NameInfo, Record, Idx);
Douglas Gregor4c9be892011-02-28 20:01:57 +00001350 E->QualifierLoc = Reader.ReadNestedNameSpecifierLoc(F, Record, Idx);
Argyrios Kyrtzidisa77eb082010-06-25 09:03:26 +00001351}
1352
Sebastian Redl60adf4a2010-08-18 23:56:52 +00001353void ASTStmtReader::VisitUnresolvedMemberExpr(UnresolvedMemberExpr *E) {
Argyrios Kyrtzidis919e6932010-06-28 22:28:35 +00001354 VisitOverloadExpr(E);
Douglas Gregor4c9be892011-02-28 20:01:57 +00001355 E->IsArrow = Record[Idx++];
1356 E->HasUnresolvedUsing = Record[Idx++];
1357 E->Base = Reader.ReadSubExpr();
Douglas Gregor393f2492011-07-22 00:38:23 +00001358 E->BaseType = Reader.readType(F, Record, Idx);
Douglas Gregor4c9be892011-02-28 20:01:57 +00001359 E->OperatorLoc = ReadSourceLocation(Record, Idx);
Argyrios Kyrtzidisa77eb082010-06-25 09:03:26 +00001360}
1361
Sebastian Redl60adf4a2010-08-18 23:56:52 +00001362void ASTStmtReader::VisitUnresolvedLookupExpr(UnresolvedLookupExpr *E) {
Argyrios Kyrtzidis919e6932010-06-28 22:28:35 +00001363 VisitOverloadExpr(E);
Douglas Gregor4c9be892011-02-28 20:01:57 +00001364 E->RequiresADL = Record[Idx++];
Richard Smithad762fc2011-04-14 22:09:26 +00001365 if (E->RequiresADL)
1366 E->StdIsAssociatedNamespace = Record[Idx++];
Douglas Gregor4c9be892011-02-28 20:01:57 +00001367 E->Overloaded = Record[Idx++];
Douglas Gregor409448c2011-07-21 22:35:25 +00001368 E->NamingClass = ReadDeclAs<CXXRecordDecl>(Record, Idx);
Argyrios Kyrtzidisbd65bb52010-06-25 09:03:34 +00001369}
1370
Sebastian Redl60adf4a2010-08-18 23:56:52 +00001371void ASTStmtReader::VisitUnaryTypeTraitExpr(UnaryTypeTraitExpr *E) {
Argyrios Kyrtzidis6d00c132010-07-10 11:46:15 +00001372 VisitExpr(E);
1373 E->UTT = (UnaryTypeTrait)Record[Idx++];
Sebastian Redl0dfd8482010-09-13 20:56:31 +00001374 E->Value = (bool)Record[Idx++];
Sebastian Redlc3632732010-10-05 15:59:54 +00001375 SourceRange Range = ReadSourceRange(Record, Idx);
Argyrios Kyrtzidis6d00c132010-07-10 11:46:15 +00001376 E->Loc = Range.getBegin();
1377 E->RParen = Range.getEnd();
Sebastian Redlc3632732010-10-05 15:59:54 +00001378 E->QueriedType = GetTypeSourceInfo(Record, Idx);
Argyrios Kyrtzidis6d00c132010-07-10 11:46:15 +00001379}
1380
Francois Pichet6ad6f282010-12-07 00:08:36 +00001381void ASTStmtReader::VisitBinaryTypeTraitExpr(BinaryTypeTraitExpr *E) {
1382 VisitExpr(E);
1383 E->BTT = (BinaryTypeTrait)Record[Idx++];
1384 E->Value = (bool)Record[Idx++];
1385 SourceRange Range = ReadSourceRange(Record, Idx);
1386 E->Loc = Range.getBegin();
1387 E->RParen = Range.getEnd();
1388 E->LhsType = GetTypeSourceInfo(Record, Idx);
1389 E->RhsType = GetTypeSourceInfo(Record, Idx);
1390}
1391
Douglas Gregor4ca8ac22012-02-24 07:38:34 +00001392void ASTStmtReader::VisitTypeTraitExpr(TypeTraitExpr *E) {
1393 VisitExpr(E);
1394 E->TypeTraitExprBits.NumArgs = Record[Idx++];
1395 E->TypeTraitExprBits.Kind = Record[Idx++];
1396 E->TypeTraitExprBits.Value = Record[Idx++];
1397
1398 TypeSourceInfo **Args = E->getTypeSourceInfos();
1399 for (unsigned I = 0, N = E->getNumArgs(); I != N; ++I)
1400 Args[I] = GetTypeSourceInfo(Record, Idx);
1401}
1402
John Wiegley21ff2e52011-04-28 00:16:57 +00001403void ASTStmtReader::VisitArrayTypeTraitExpr(ArrayTypeTraitExpr *E) {
1404 VisitExpr(E);
1405 E->ATT = (ArrayTypeTrait)Record[Idx++];
1406 E->Value = (unsigned int)Record[Idx++];
1407 SourceRange Range = ReadSourceRange(Record, Idx);
1408 E->Loc = Range.getBegin();
1409 E->RParen = Range.getEnd();
1410 E->QueriedType = GetTypeSourceInfo(Record, Idx);
1411}
1412
John Wiegley55262202011-04-25 06:54:41 +00001413void ASTStmtReader::VisitExpressionTraitExpr(ExpressionTraitExpr *E) {
1414 VisitExpr(E);
1415 E->ET = (ExpressionTrait)Record[Idx++];
1416 E->Value = (bool)Record[Idx++];
1417 SourceRange Range = ReadSourceRange(Record, Idx);
1418 E->QueriedExpression = Reader.ReadSubExpr();
1419 E->Loc = Range.getBegin();
1420 E->RParen = Range.getEnd();
1421}
1422
Sebastian Redl6b219d02010-09-10 20:55:54 +00001423void ASTStmtReader::VisitCXXNoexceptExpr(CXXNoexceptExpr *E) {
1424 VisitExpr(E);
Sebastian Redl5221d8f2010-09-10 22:34:40 +00001425 E->Value = (bool)Record[Idx++];
Sebastian Redlc3632732010-10-05 15:59:54 +00001426 E->Range = ReadSourceRange(Record, Idx);
Sebastian Redl5221d8f2010-09-10 22:34:40 +00001427 E->Operand = Reader.ReadSubExpr();
Sebastian Redl6b219d02010-09-10 20:55:54 +00001428}
1429
Douglas Gregorbe230c32011-01-03 17:17:50 +00001430void ASTStmtReader::VisitPackExpansionExpr(PackExpansionExpr *E) {
1431 VisitExpr(E);
1432 E->EllipsisLoc = ReadSourceLocation(Record, Idx);
Douglas Gregor67fd1252011-01-14 21:20:45 +00001433 E->NumExpansions = Record[Idx++];
Douglas Gregorbe230c32011-01-03 17:17:50 +00001434 E->Pattern = Reader.ReadSubExpr();
1435}
1436
Douglas Gregoree8aff02011-01-04 17:33:58 +00001437void ASTStmtReader::VisitSizeOfPackExpr(SizeOfPackExpr *E) {
1438 VisitExpr(E);
1439 E->OperatorLoc = ReadSourceLocation(Record, Idx);
1440 E->PackLoc = ReadSourceLocation(Record, Idx);
1441 E->RParenLoc = ReadSourceLocation(Record, Idx);
1442 E->Length = Record[Idx++];
Douglas Gregor409448c2011-07-21 22:35:25 +00001443 E->Pack = ReadDeclAs<NamedDecl>(Record, Idx);
Douglas Gregoree8aff02011-01-04 17:33:58 +00001444}
1445
John McCall7110fd62011-07-15 07:00:14 +00001446void ASTStmtReader::VisitSubstNonTypeTemplateParmExpr(
1447 SubstNonTypeTemplateParmExpr *E) {
1448 VisitExpr(E);
Douglas Gregor409448c2011-07-21 22:35:25 +00001449 E->Param = ReadDeclAs<NonTypeTemplateParmDecl>(Record, Idx);
John McCall7110fd62011-07-15 07:00:14 +00001450 E->NameLoc = ReadSourceLocation(Record, Idx);
1451 E->Replacement = Reader.ReadSubExpr();
1452}
1453
Douglas Gregorc7793c72011-01-15 01:15:58 +00001454void ASTStmtReader::VisitSubstNonTypeTemplateParmPackExpr(
1455 SubstNonTypeTemplateParmPackExpr *E) {
1456 VisitExpr(E);
Douglas Gregor409448c2011-07-21 22:35:25 +00001457 E->Param = ReadDeclAs<NonTypeTemplateParmDecl>(Record, Idx);
Douglas Gregorc7793c72011-01-15 01:15:58 +00001458 TemplateArgument ArgPack = Reader.ReadTemplateArgument(F, Record, Idx);
1459 if (ArgPack.getKind() != TemplateArgument::Pack)
1460 return;
1461
1462 E->Arguments = ArgPack.pack_begin();
1463 E->NumArguments = ArgPack.pack_size();
1464 E->NameLoc = ReadSourceLocation(Record, Idx);
1465}
1466
Douglas Gregor03e80032011-06-21 17:03:29 +00001467void ASTStmtReader::VisitMaterializeTemporaryExpr(MaterializeTemporaryExpr *E) {
1468 VisitExpr(E);
1469 E->Temporary = Reader.ReadSubExpr();
1470}
1471
John McCall7cd7d1a2010-11-15 23:31:06 +00001472void ASTStmtReader::VisitOpaqueValueExpr(OpaqueValueExpr *E) {
1473 VisitExpr(E);
Argyrios Kyrtzidis8bc27822011-12-03 03:49:52 +00001474 E->SourceExpr = Reader.ReadSubExpr();
Douglas Gregorb608b982011-01-28 02:26:04 +00001475 E->Loc = ReadSourceLocation(Record, Idx);
John McCall7cd7d1a2010-11-15 23:31:06 +00001476}
1477
Peter Collingbournee08ce652011-02-09 21:07:24 +00001478//===----------------------------------------------------------------------===//
John McCall7110fd62011-07-15 07:00:14 +00001479// Microsoft Expressions and Statements
1480//===----------------------------------------------------------------------===//
1481void ASTStmtReader::VisitCXXUuidofExpr(CXXUuidofExpr *E) {
1482 VisitExpr(E);
1483 E->setSourceRange(ReadSourceRange(Record, Idx));
1484 if (E->isTypeOperand()) { // __uuidof(ComType)
1485 E->setTypeOperandSourceInfo(
1486 GetTypeSourceInfo(Record, Idx));
1487 return;
1488 }
1489
1490 // __uuidof(expr)
1491 E->setExprOperand(Reader.ReadSubExpr());
1492}
1493
1494void ASTStmtReader::VisitSEHExceptStmt(SEHExceptStmt *S) {
1495 VisitStmt(S);
1496 S->Loc = ReadSourceLocation(Record, Idx);
1497 S->Children[SEHExceptStmt::FILTER_EXPR] = Reader.ReadSubStmt();
1498 S->Children[SEHExceptStmt::BLOCK] = Reader.ReadSubStmt();
1499}
1500
1501void ASTStmtReader::VisitSEHFinallyStmt(SEHFinallyStmt *S) {
1502 VisitStmt(S);
1503 S->Loc = ReadSourceLocation(Record, Idx);
1504 S->Block = Reader.ReadSubStmt();
1505}
1506
1507void ASTStmtReader::VisitSEHTryStmt(SEHTryStmt *S) {
1508 VisitStmt(S);
1509 S->IsCXXTry = Record[Idx++];
1510 S->TryLoc = ReadSourceLocation(Record, Idx);
1511 S->Children[SEHTryStmt::TRY] = Reader.ReadSubStmt();
1512 S->Children[SEHTryStmt::HANDLER] = Reader.ReadSubStmt();
1513}
1514
1515//===----------------------------------------------------------------------===//
Peter Collingbournee08ce652011-02-09 21:07:24 +00001516// CUDA Expressions and Statements
1517//===----------------------------------------------------------------------===//
1518
1519void ASTStmtReader::VisitCUDAKernelCallExpr(CUDAKernelCallExpr *E) {
1520 VisitCallExpr(E);
1521 E->setConfig(cast<CallExpr>(Reader.ReadSubExpr()));
1522}
1523
John McCall7110fd62011-07-15 07:00:14 +00001524//===----------------------------------------------------------------------===//
1525// OpenCL Expressions and Statements.
1526//===----------------------------------------------------------------------===//
1527void ASTStmtReader::VisitAsTypeExpr(AsTypeExpr *E) {
1528 VisitExpr(E);
1529 E->BuiltinLoc = ReadSourceLocation(Record, Idx);
1530 E->RParenLoc = ReadSourceLocation(Record, Idx);
1531 E->SrcExpr = Reader.ReadSubExpr();
1532}
1533
1534//===----------------------------------------------------------------------===//
1535// ASTReader Implementation
1536//===----------------------------------------------------------------------===//
1537
Douglas Gregor1a4761e2011-11-30 23:21:26 +00001538Stmt *ASTReader::ReadStmt(ModuleFile &F) {
Argyrios Kyrtzidis919e6932010-06-28 22:28:35 +00001539 switch (ReadingKind) {
1540 case Read_Decl:
1541 case Read_Type:
Sebastian Redlc3632732010-10-05 15:59:54 +00001542 return ReadStmtFromStream(F);
Argyrios Kyrtzidis919e6932010-06-28 22:28:35 +00001543 case Read_Stmt:
Argyrios Kyrtzidisd98a2ab2010-06-29 22:46:25 +00001544 return ReadSubStmt();
Argyrios Kyrtzidis919e6932010-06-28 22:28:35 +00001545 }
1546
1547 llvm_unreachable("ReadingKind not set ?");
Argyrios Kyrtzidis919e6932010-06-28 22:28:35 +00001548}
1549
Douglas Gregor1a4761e2011-11-30 23:21:26 +00001550Expr *ASTReader::ReadExpr(ModuleFile &F) {
Sebastian Redlc3632732010-10-05 15:59:54 +00001551 return cast_or_null<Expr>(ReadStmt(F));
Argyrios Kyrtzidis919e6932010-06-28 22:28:35 +00001552}
Chris Lattner030854b2010-05-09 06:40:08 +00001553
Sebastian Redlc43b54c2010-08-18 23:56:43 +00001554Expr *ASTReader::ReadSubExpr() {
Argyrios Kyrtzidisd98a2ab2010-06-29 22:46:25 +00001555 return cast_or_null<Expr>(ReadSubStmt());
1556}
1557
Chris Lattner52e97d12009-04-27 05:41:06 +00001558// Within the bitstream, expressions are stored in Reverse Polish
1559// Notation, with each of the subexpressions preceding the
Argyrios Kyrtzidis919e6932010-06-28 22:28:35 +00001560// expression they are stored in. Subexpressions are stored from last to first.
1561// To evaluate expressions, we continue reading expressions and placing them on
1562// the stack, with expressions having operands removing those operands from the
Chris Lattner52e97d12009-04-27 05:41:06 +00001563// stack. Evaluation terminates when we see a STMT_STOP record, and
1564// the single remaining expression on the stack is our result.
Douglas Gregor1a4761e2011-11-30 23:21:26 +00001565Stmt *ASTReader::ReadStmtFromStream(ModuleFile &F) {
Argyrios Kyrtzidis919e6932010-06-28 22:28:35 +00001566
1567 ReadingKindTracker ReadingKind(Read_Stmt, *this);
Sebastian Redlc3632732010-10-05 15:59:54 +00001568 llvm::BitstreamCursor &Cursor = F.DeclsCursor;
Argyrios Kyrtzidise6f08682011-10-21 23:02:28 +00001569
1570 // Map of offset to previously deserialized stmt. The offset points
1571 /// just after the stmt record.
1572 llvm::DenseMap<uint64_t, Stmt *> StmtEntries;
Sebastian Redlc3632732010-10-05 15:59:54 +00001573
Argyrios Kyrtzidis919e6932010-06-28 22:28:35 +00001574#ifndef NDEBUG
1575 unsigned PrevNumStmts = StmtStack.size();
1576#endif
1577
Chris Lattner4c6f9522009-04-27 05:14:47 +00001578 RecordData Record;
1579 unsigned Idx;
Sebastian Redlc3632732010-10-05 15:59:54 +00001580 ASTStmtReader Reader(*this, F, Cursor, Record, Idx);
Chris Lattner4c6f9522009-04-27 05:14:47 +00001581 Stmt::EmptyShell Empty;
1582
1583 while (true) {
Chris Lattner52e97d12009-04-27 05:41:06 +00001584 unsigned Code = Cursor.ReadCode();
Chris Lattner4c6f9522009-04-27 05:14:47 +00001585 if (Code == llvm::bitc::END_BLOCK) {
Chris Lattner52e97d12009-04-27 05:41:06 +00001586 if (Cursor.ReadBlockEnd()) {
Sebastian Redl3c7f4132010-08-18 23:57:06 +00001587 Error("error at end of block in AST file");
Chris Lattner4c6f9522009-04-27 05:14:47 +00001588 return 0;
1589 }
1590 break;
1591 }
1592
1593 if (Code == llvm::bitc::ENTER_SUBBLOCK) {
1594 // No known subblocks, always skip them.
Chris Lattner52e97d12009-04-27 05:41:06 +00001595 Cursor.ReadSubBlockID();
1596 if (Cursor.SkipBlock()) {
Sebastian Redl3c7f4132010-08-18 23:57:06 +00001597 Error("malformed block record in AST file");
Chris Lattner4c6f9522009-04-27 05:14:47 +00001598 return 0;
1599 }
1600 continue;
1601 }
1602
1603 if (Code == llvm::bitc::DEFINE_ABBREV) {
Chris Lattner52e97d12009-04-27 05:41:06 +00001604 Cursor.ReadAbbrevRecord();
Chris Lattner4c6f9522009-04-27 05:14:47 +00001605 continue;
1606 }
1607
1608 Stmt *S = 0;
1609 Idx = 0;
1610 Record.clear();
1611 bool Finished = false;
Argyrios Kyrtzidise6f08682011-10-21 23:02:28 +00001612 bool IsStmtReference = false;
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001613 switch ((StmtCode)Cursor.ReadRecord(Code, Record)) {
1614 case STMT_STOP:
Chris Lattner4c6f9522009-04-27 05:14:47 +00001615 Finished = true;
1616 break;
1617
Argyrios Kyrtzidise6f08682011-10-21 23:02:28 +00001618 case STMT_REF_PTR:
1619 IsStmtReference = true;
1620 assert(StmtEntries.find(Record[0]) != StmtEntries.end() &&
1621 "No stmt was recorded for this offset reference!");
1622 S = StmtEntries[Record[Idx++]];
1623 break;
1624
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001625 case STMT_NULL_PTR:
Mike Stump1eb44332009-09-09 15:08:12 +00001626 S = 0;
Chris Lattner4c6f9522009-04-27 05:14:47 +00001627 break;
1628
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001629 case STMT_NULL:
Chris Lattner4c6f9522009-04-27 05:14:47 +00001630 S = new (Context) NullStmt(Empty);
1631 break;
1632
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001633 case STMT_COMPOUND:
Chris Lattner4c6f9522009-04-27 05:14:47 +00001634 S = new (Context) CompoundStmt(Empty);
1635 break;
1636
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001637 case STMT_CASE:
Chris Lattner4c6f9522009-04-27 05:14:47 +00001638 S = new (Context) CaseStmt(Empty);
1639 break;
1640
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001641 case STMT_DEFAULT:
Chris Lattner4c6f9522009-04-27 05:14:47 +00001642 S = new (Context) DefaultStmt(Empty);
1643 break;
1644
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001645 case STMT_LABEL:
Chris Lattner4c6f9522009-04-27 05:14:47 +00001646 S = new (Context) LabelStmt(Empty);
1647 break;
1648
Richard Smith534986f2012-04-14 00:33:13 +00001649 case STMT_ATTRIBUTED:
1650 S = new (Context) AttributedStmt(Empty);
1651 break;
1652
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001653 case STMT_IF:
Chris Lattner4c6f9522009-04-27 05:14:47 +00001654 S = new (Context) IfStmt(Empty);
1655 break;
1656
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001657 case STMT_SWITCH:
Chris Lattner4c6f9522009-04-27 05:14:47 +00001658 S = new (Context) SwitchStmt(Empty);
1659 break;
1660
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001661 case STMT_WHILE:
Chris Lattner4c6f9522009-04-27 05:14:47 +00001662 S = new (Context) WhileStmt(Empty);
1663 break;
1664
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001665 case STMT_DO:
Chris Lattner4c6f9522009-04-27 05:14:47 +00001666 S = new (Context) DoStmt(Empty);
1667 break;
Mike Stump1eb44332009-09-09 15:08:12 +00001668
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001669 case STMT_FOR:
Chris Lattner4c6f9522009-04-27 05:14:47 +00001670 S = new (Context) ForStmt(Empty);
1671 break;
1672
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001673 case STMT_GOTO:
Chris Lattner4c6f9522009-04-27 05:14:47 +00001674 S = new (Context) GotoStmt(Empty);
1675 break;
Mike Stump1eb44332009-09-09 15:08:12 +00001676
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001677 case STMT_INDIRECT_GOTO:
Chris Lattner4c6f9522009-04-27 05:14:47 +00001678 S = new (Context) IndirectGotoStmt(Empty);
1679 break;
1680
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001681 case STMT_CONTINUE:
Chris Lattner4c6f9522009-04-27 05:14:47 +00001682 S = new (Context) ContinueStmt(Empty);
1683 break;
1684
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001685 case STMT_BREAK:
Chris Lattner4c6f9522009-04-27 05:14:47 +00001686 S = new (Context) BreakStmt(Empty);
1687 break;
1688
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001689 case STMT_RETURN:
Chris Lattner4c6f9522009-04-27 05:14:47 +00001690 S = new (Context) ReturnStmt(Empty);
1691 break;
1692
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001693 case STMT_DECL:
Chris Lattner4c6f9522009-04-27 05:14:47 +00001694 S = new (Context) DeclStmt(Empty);
1695 break;
1696
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001697 case STMT_ASM:
Chris Lattner4c6f9522009-04-27 05:14:47 +00001698 S = new (Context) AsmStmt(Empty);
1699 break;
1700
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001701 case EXPR_PREDEFINED:
Chris Lattner4c6f9522009-04-27 05:14:47 +00001702 S = new (Context) PredefinedExpr(Empty);
1703 break;
Mike Stump1eb44332009-09-09 15:08:12 +00001704
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001705 case EXPR_DECL_REF:
Chandler Carruth3aa81402011-05-01 23:48:14 +00001706 S = DeclRefExpr::CreateEmpty(
Douglas Gregor35942772011-09-09 21:34:22 +00001707 Context,
Chandler Carruth3aa81402011-05-01 23:48:14 +00001708 /*HasQualifier=*/Record[ASTStmtReader::NumExprFields],
1709 /*HasFoundDecl=*/Record[ASTStmtReader::NumExprFields + 1],
Abramo Bagnarae4b92762012-01-27 09:46:47 +00001710 /*HasTemplateKWAndArgsInfo=*/Record[ASTStmtReader::NumExprFields + 2],
Chandler Carruth3aa81402011-05-01 23:48:14 +00001711 /*NumTemplateArgs=*/Record[ASTStmtReader::NumExprFields + 2] ?
John McCallf4b88a42012-03-10 09:33:50 +00001712 Record[ASTStmtReader::NumExprFields + 5] : 0);
Chris Lattner4c6f9522009-04-27 05:14:47 +00001713 break;
Mike Stump1eb44332009-09-09 15:08:12 +00001714
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001715 case EXPR_INTEGER_LITERAL:
Douglas Gregor35942772011-09-09 21:34:22 +00001716 S = IntegerLiteral::Create(Context, Empty);
Chris Lattner4c6f9522009-04-27 05:14:47 +00001717 break;
Mike Stump1eb44332009-09-09 15:08:12 +00001718
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001719 case EXPR_FLOATING_LITERAL:
Douglas Gregor35942772011-09-09 21:34:22 +00001720 S = FloatingLiteral::Create(Context, Empty);
Chris Lattner4c6f9522009-04-27 05:14:47 +00001721 break;
Mike Stump1eb44332009-09-09 15:08:12 +00001722
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001723 case EXPR_IMAGINARY_LITERAL:
Chris Lattner4c6f9522009-04-27 05:14:47 +00001724 S = new (Context) ImaginaryLiteral(Empty);
1725 break;
1726
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001727 case EXPR_STRING_LITERAL:
Douglas Gregor35942772011-09-09 21:34:22 +00001728 S = StringLiteral::CreateEmpty(Context,
Sebastian Redl60adf4a2010-08-18 23:56:52 +00001729 Record[ASTStmtReader::NumExprFields + 1]);
Chris Lattner4c6f9522009-04-27 05:14:47 +00001730 break;
1731
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001732 case EXPR_CHARACTER_LITERAL:
Chris Lattner4c6f9522009-04-27 05:14:47 +00001733 S = new (Context) CharacterLiteral(Empty);
1734 break;
1735
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001736 case EXPR_PAREN:
Chris Lattner4c6f9522009-04-27 05:14:47 +00001737 S = new (Context) ParenExpr(Empty);
1738 break;
1739
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001740 case EXPR_PAREN_LIST:
Argyrios Kyrtzidis37bdfe22010-06-30 08:49:18 +00001741 S = new (Context) ParenListExpr(Empty);
1742 break;
1743
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001744 case EXPR_UNARY_OPERATOR:
Chris Lattner4c6f9522009-04-27 05:14:47 +00001745 S = new (Context) UnaryOperator(Empty);
1746 break;
1747
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001748 case EXPR_OFFSETOF:
Douglas Gregor35942772011-09-09 21:34:22 +00001749 S = OffsetOfExpr::CreateEmpty(Context,
Sebastian Redl60adf4a2010-08-18 23:56:52 +00001750 Record[ASTStmtReader::NumExprFields],
1751 Record[ASTStmtReader::NumExprFields + 1]);
Douglas Gregor8ecdb652010-04-28 22:16:22 +00001752 break;
1753
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001754 case EXPR_SIZEOF_ALIGN_OF:
Peter Collingbournef4e3cfb2011-03-11 19:24:49 +00001755 S = new (Context) UnaryExprOrTypeTraitExpr(Empty);
Chris Lattner4c6f9522009-04-27 05:14:47 +00001756 break;
1757
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001758 case EXPR_ARRAY_SUBSCRIPT:
Chris Lattner4c6f9522009-04-27 05:14:47 +00001759 S = new (Context) ArraySubscriptExpr(Empty);
1760 break;
1761
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001762 case EXPR_CALL:
Douglas Gregor35942772011-09-09 21:34:22 +00001763 S = new (Context) CallExpr(Context, Stmt::CallExprClass, Empty);
Chris Lattner4c6f9522009-04-27 05:14:47 +00001764 break;
1765
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001766 case EXPR_MEMBER: {
Argyrios Kyrtzidis663e3802010-07-08 13:09:47 +00001767 // We load everything here and fully initialize it at creation.
1768 // That way we can use MemberExpr::Create and don't have to duplicate its
1769 // logic with a MemberExpr::CreateEmpty.
1770
1771 assert(Idx == 0);
Douglas Gregor40d96a62011-02-28 21:54:11 +00001772 NestedNameSpecifierLoc QualifierLoc;
Argyrios Kyrtzidis663e3802010-07-08 13:09:47 +00001773 if (Record[Idx++]) { // HasQualifier.
Douglas Gregor40d96a62011-02-28 21:54:11 +00001774 QualifierLoc = ReadNestedNameSpecifierLoc(F, Record, Idx);
Argyrios Kyrtzidis663e3802010-07-08 13:09:47 +00001775 }
1776
Abramo Bagnarae4b92762012-01-27 09:46:47 +00001777 SourceLocation TemplateKWLoc;
Argyrios Kyrtzidis663e3802010-07-08 13:09:47 +00001778 TemplateArgumentListInfo ArgInfo;
Abramo Bagnarae4b92762012-01-27 09:46:47 +00001779 bool HasTemplateKWAndArgsInfo = Record[Idx++];
1780 if (HasTemplateKWAndArgsInfo) {
1781 TemplateKWLoc = ReadSourceLocation(F, Record, Idx);
Douglas Gregordef03542011-02-04 12:01:24 +00001782 unsigned NumTemplateArgs = Record[Idx++];
Sebastian Redlc3632732010-10-05 15:59:54 +00001783 ArgInfo.setLAngleLoc(ReadSourceLocation(F, Record, Idx));
1784 ArgInfo.setRAngleLoc(ReadSourceLocation(F, Record, Idx));
Argyrios Kyrtzidis663e3802010-07-08 13:09:47 +00001785 for (unsigned i = 0; i != NumTemplateArgs; ++i)
Sebastian Redlc3632732010-10-05 15:59:54 +00001786 ArgInfo.addArgument(ReadTemplateArgumentLoc(F, Record, Idx));
Argyrios Kyrtzidis663e3802010-07-08 13:09:47 +00001787 }
Abramo Bagnara7cc58b42011-10-05 07:56:41 +00001788
1789 bool HadMultipleCandidates = Record[Idx++];
1790
Douglas Gregor409448c2011-07-21 22:35:25 +00001791 NamedDecl *FoundD = ReadDeclAs<NamedDecl>(F, Record, Idx);
Argyrios Kyrtzidis663e3802010-07-08 13:09:47 +00001792 AccessSpecifier AS = (AccessSpecifier)Record[Idx++];
1793 DeclAccessPair FoundDecl = DeclAccessPair::make(FoundD, AS);
1794
Douglas Gregor393f2492011-07-22 00:38:23 +00001795 QualType T = readType(F, Record, Idx);
John McCallf89e55a2010-11-18 06:31:45 +00001796 ExprValueKind VK = static_cast<ExprValueKind>(Record[Idx++]);
1797 ExprObjectKind OK = static_cast<ExprObjectKind>(Record[Idx++]);
Argyrios Kyrtzidis663e3802010-07-08 13:09:47 +00001798 Expr *Base = ReadSubExpr();
Douglas Gregor409448c2011-07-21 22:35:25 +00001799 ValueDecl *MemberD = ReadDeclAs<ValueDecl>(F, Record, Idx);
Sebastian Redlc3632732010-10-05 15:59:54 +00001800 SourceLocation MemberLoc = ReadSourceLocation(F, Record, Idx);
Abramo Bagnara25777432010-08-11 22:01:17 +00001801 DeclarationNameInfo MemberNameInfo(MemberD->getDeclName(), MemberLoc);
Argyrios Kyrtzidis663e3802010-07-08 13:09:47 +00001802 bool IsArrow = Record[Idx++];
1803
Douglas Gregor35942772011-09-09 21:34:22 +00001804 S = MemberExpr::Create(Context, Base, IsArrow, QualifierLoc,
Abramo Bagnarae4b92762012-01-27 09:46:47 +00001805 TemplateKWLoc, MemberD, FoundDecl, MemberNameInfo,
1806 HasTemplateKWAndArgsInfo ? &ArgInfo : 0,
1807 T, VK, OK);
Argyrios Kyrtzidis40451072010-10-15 18:21:24 +00001808 ReadDeclarationNameLoc(F, cast<MemberExpr>(S)->MemberDNLoc,
1809 MemberD->getDeclName(), Record, Idx);
Abramo Bagnara7cc58b42011-10-05 07:56:41 +00001810 if (HadMultipleCandidates)
1811 cast<MemberExpr>(S)->setHadMultipleCandidates(true);
Chris Lattner4c6f9522009-04-27 05:14:47 +00001812 break;
Argyrios Kyrtzidis663e3802010-07-08 13:09:47 +00001813 }
Chris Lattner4c6f9522009-04-27 05:14:47 +00001814
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001815 case EXPR_BINARY_OPERATOR:
Chris Lattner4c6f9522009-04-27 05:14:47 +00001816 S = new (Context) BinaryOperator(Empty);
1817 break;
1818
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001819 case EXPR_COMPOUND_ASSIGN_OPERATOR:
Chris Lattner4c6f9522009-04-27 05:14:47 +00001820 S = new (Context) CompoundAssignOperator(Empty);
1821 break;
1822
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001823 case EXPR_CONDITIONAL_OPERATOR:
Chris Lattner4c6f9522009-04-27 05:14:47 +00001824 S = new (Context) ConditionalOperator(Empty);
1825 break;
1826
John McCall56ca35d2011-02-17 10:25:35 +00001827 case EXPR_BINARY_CONDITIONAL_OPERATOR:
1828 S = new (Context) BinaryConditionalOperator(Empty);
1829 break;
1830
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001831 case EXPR_IMPLICIT_CAST:
Douglas Gregor35942772011-09-09 21:34:22 +00001832 S = ImplicitCastExpr::CreateEmpty(Context,
Sebastian Redl60adf4a2010-08-18 23:56:52 +00001833 /*PathSize*/ Record[ASTStmtReader::NumExprFields]);
Chris Lattner4c6f9522009-04-27 05:14:47 +00001834 break;
1835
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001836 case EXPR_CSTYLE_CAST:
Douglas Gregor35942772011-09-09 21:34:22 +00001837 S = CStyleCastExpr::CreateEmpty(Context,
Sebastian Redl60adf4a2010-08-18 23:56:52 +00001838 /*PathSize*/ Record[ASTStmtReader::NumExprFields]);
Chris Lattner4c6f9522009-04-27 05:14:47 +00001839 break;
1840
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001841 case EXPR_COMPOUND_LITERAL:
Chris Lattner4c6f9522009-04-27 05:14:47 +00001842 S = new (Context) CompoundLiteralExpr(Empty);
1843 break;
1844
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001845 case EXPR_EXT_VECTOR_ELEMENT:
Chris Lattner4c6f9522009-04-27 05:14:47 +00001846 S = new (Context) ExtVectorElementExpr(Empty);
1847 break;
1848
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001849 case EXPR_INIT_LIST:
Douglas Gregor35942772011-09-09 21:34:22 +00001850 S = new (Context) InitListExpr(getContext(), Empty);
Chris Lattner4c6f9522009-04-27 05:14:47 +00001851 break;
1852
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001853 case EXPR_DESIGNATED_INIT:
Douglas Gregor35942772011-09-09 21:34:22 +00001854 S = DesignatedInitExpr::CreateEmpty(Context,
Sebastian Redl60adf4a2010-08-18 23:56:52 +00001855 Record[ASTStmtReader::NumExprFields] - 1);
Mike Stump1eb44332009-09-09 15:08:12 +00001856
Chris Lattner4c6f9522009-04-27 05:14:47 +00001857 break;
1858
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001859 case EXPR_IMPLICIT_VALUE_INIT:
Chris Lattner4c6f9522009-04-27 05:14:47 +00001860 S = new (Context) ImplicitValueInitExpr(Empty);
1861 break;
1862
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001863 case EXPR_VA_ARG:
Chris Lattner4c6f9522009-04-27 05:14:47 +00001864 S = new (Context) VAArgExpr(Empty);
1865 break;
1866
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001867 case EXPR_ADDR_LABEL:
Chris Lattner4c6f9522009-04-27 05:14:47 +00001868 S = new (Context) AddrLabelExpr(Empty);
1869 break;
1870
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001871 case EXPR_STMT:
Chris Lattner4c6f9522009-04-27 05:14:47 +00001872 S = new (Context) StmtExpr(Empty);
1873 break;
1874
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001875 case EXPR_CHOOSE:
Chris Lattner4c6f9522009-04-27 05:14:47 +00001876 S = new (Context) ChooseExpr(Empty);
1877 break;
1878
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001879 case EXPR_GNU_NULL:
Chris Lattner4c6f9522009-04-27 05:14:47 +00001880 S = new (Context) GNUNullExpr(Empty);
1881 break;
1882
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001883 case EXPR_SHUFFLE_VECTOR:
Chris Lattner4c6f9522009-04-27 05:14:47 +00001884 S = new (Context) ShuffleVectorExpr(Empty);
1885 break;
Mike Stump1eb44332009-09-09 15:08:12 +00001886
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001887 case EXPR_BLOCK:
Chris Lattner4c6f9522009-04-27 05:14:47 +00001888 S = new (Context) BlockExpr(Empty);
1889 break;
1890
Peter Collingbournef111d932011-04-15 00:35:48 +00001891 case EXPR_GENERIC_SELECTION:
1892 S = new (Context) GenericSelectionExpr(Empty);
1893 break;
1894
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001895 case EXPR_OBJC_STRING_LITERAL:
Chris Lattner4c6f9522009-04-27 05:14:47 +00001896 S = new (Context) ObjCStringLiteral(Empty);
1897 break;
Patrick Beardeb382ec2012-04-19 00:25:12 +00001898 case EXPR_OBJC_BOXED_EXPRESSION:
1899 S = new (Context) ObjCBoxedExpr(Empty);
Ted Kremenekebcb57a2012-03-06 20:05:56 +00001900 break;
1901 case EXPR_OBJC_ARRAY_LITERAL:
1902 S = ObjCArrayLiteral::CreateEmpty(Context,
1903 Record[ASTStmtReader::NumExprFields]);
1904 break;
1905 case EXPR_OBJC_DICTIONARY_LITERAL:
1906 S = ObjCDictionaryLiteral::CreateEmpty(Context,
1907 Record[ASTStmtReader::NumExprFields],
1908 Record[ASTStmtReader::NumExprFields + 1]);
1909 break;
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001910 case EXPR_OBJC_ENCODE:
Chris Lattner4c6f9522009-04-27 05:14:47 +00001911 S = new (Context) ObjCEncodeExpr(Empty);
1912 break;
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001913 case EXPR_OBJC_SELECTOR_EXPR:
Chris Lattner4c6f9522009-04-27 05:14:47 +00001914 S = new (Context) ObjCSelectorExpr(Empty);
1915 break;
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001916 case EXPR_OBJC_PROTOCOL_EXPR:
Chris Lattner4c6f9522009-04-27 05:14:47 +00001917 S = new (Context) ObjCProtocolExpr(Empty);
1918 break;
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001919 case EXPR_OBJC_IVAR_REF_EXPR:
Chris Lattner4c6f9522009-04-27 05:14:47 +00001920 S = new (Context) ObjCIvarRefExpr(Empty);
1921 break;
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001922 case EXPR_OBJC_PROPERTY_REF_EXPR:
Chris Lattner4c6f9522009-04-27 05:14:47 +00001923 S = new (Context) ObjCPropertyRefExpr(Empty);
1924 break;
Ted Kremenekebcb57a2012-03-06 20:05:56 +00001925 case EXPR_OBJC_SUBSCRIPT_REF_EXPR:
1926 S = new (Context) ObjCSubscriptRefExpr(Empty);
1927 break;
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001928 case EXPR_OBJC_KVC_REF_EXPR:
John McCall12f78a62010-12-02 01:19:52 +00001929 llvm_unreachable("mismatching AST file");
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001930 case EXPR_OBJC_MESSAGE_EXPR:
Douglas Gregor35942772011-09-09 21:34:22 +00001931 S = ObjCMessageExpr::CreateEmpty(Context,
Argyrios Kyrtzidis20718082011-10-03 06:36:51 +00001932 Record[ASTStmtReader::NumExprFields],
1933 Record[ASTStmtReader::NumExprFields + 1]);
Chris Lattner4c6f9522009-04-27 05:14:47 +00001934 break;
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001935 case EXPR_OBJC_ISA:
Steve Narofff242b1b2009-07-24 17:54:45 +00001936 S = new (Context) ObjCIsaExpr(Empty);
1937 break;
John McCallf85e1932011-06-15 23:02:42 +00001938 case EXPR_OBJC_INDIRECT_COPY_RESTORE:
1939 S = new (Context) ObjCIndirectCopyRestoreExpr(Empty);
1940 break;
1941 case EXPR_OBJC_BRIDGED_CAST:
1942 S = new (Context) ObjCBridgedCastExpr(Empty);
1943 break;
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001944 case STMT_OBJC_FOR_COLLECTION:
Chris Lattner4c6f9522009-04-27 05:14:47 +00001945 S = new (Context) ObjCForCollectionStmt(Empty);
1946 break;
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001947 case STMT_OBJC_CATCH:
Chris Lattner4c6f9522009-04-27 05:14:47 +00001948 S = new (Context) ObjCAtCatchStmt(Empty);
1949 break;
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001950 case STMT_OBJC_FINALLY:
Chris Lattner4c6f9522009-04-27 05:14:47 +00001951 S = new (Context) ObjCAtFinallyStmt(Empty);
1952 break;
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001953 case STMT_OBJC_AT_TRY:
Douglas Gregor35942772011-09-09 21:34:22 +00001954 S = ObjCAtTryStmt::CreateEmpty(Context,
Sebastian Redl60adf4a2010-08-18 23:56:52 +00001955 Record[ASTStmtReader::NumStmtFields],
1956 Record[ASTStmtReader::NumStmtFields + 1]);
Chris Lattner4c6f9522009-04-27 05:14:47 +00001957 break;
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001958 case STMT_OBJC_AT_SYNCHRONIZED:
Chris Lattner4c6f9522009-04-27 05:14:47 +00001959 S = new (Context) ObjCAtSynchronizedStmt(Empty);
1960 break;
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001961 case STMT_OBJC_AT_THROW:
Chris Lattner4c6f9522009-04-27 05:14:47 +00001962 S = new (Context) ObjCAtThrowStmt(Empty);
1963 break;
John McCallf85e1932011-06-15 23:02:42 +00001964 case STMT_OBJC_AUTORELEASE_POOL:
1965 S = new (Context) ObjCAutoreleasePoolStmt(Empty);
1966 break;
Ted Kremenekebcb57a2012-03-06 20:05:56 +00001967 case EXPR_OBJC_BOOL_LITERAL:
1968 S = new (Context) ObjCBoolLiteralExpr(Empty);
1969 break;
John McCall7110fd62011-07-15 07:00:14 +00001970 case STMT_SEH_EXCEPT:
1971 S = new (Context) SEHExceptStmt(Empty);
1972 break;
1973 case STMT_SEH_FINALLY:
1974 S = new (Context) SEHFinallyStmt(Empty);
1975 break;
1976 case STMT_SEH_TRY:
1977 S = new (Context) SEHTryStmt(Empty);
1978 break;
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001979 case STMT_CXX_CATCH:
Argyrios Kyrtzidis7cb45e32010-07-22 16:03:56 +00001980 S = new (Context) CXXCatchStmt(Empty);
1981 break;
1982
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001983 case STMT_CXX_TRY:
Douglas Gregor35942772011-09-09 21:34:22 +00001984 S = CXXTryStmt::Create(Context, Empty,
Sebastian Redl60adf4a2010-08-18 23:56:52 +00001985 /*NumHandlers=*/Record[ASTStmtReader::NumStmtFields]);
Argyrios Kyrtzidis7cb45e32010-07-22 16:03:56 +00001986 break;
1987
Richard Smithad762fc2011-04-14 22:09:26 +00001988 case STMT_CXX_FOR_RANGE:
1989 S = new (Context) CXXForRangeStmt(Empty);
1990 break;
1991
Douglas Gregorba0513d2011-10-25 01:33:02 +00001992 case STMT_MS_DEPENDENT_EXISTS:
1993 S = new (Context) MSDependentExistsStmt(SourceLocation(), true,
1994 NestedNameSpecifierLoc(),
1995 DeclarationNameInfo(),
1996 0);
1997 break;
1998
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001999 case EXPR_CXX_OPERATOR_CALL:
Douglas Gregor35942772011-09-09 21:34:22 +00002000 S = new (Context) CXXOperatorCallExpr(Context, Empty);
Argyrios Kyrtzidisba0a9002009-07-14 03:19:21 +00002001 break;
Chris Lattner1817bd42010-05-09 05:36:05 +00002002
Sebastian Redl8538e8d2010-08-18 23:57:32 +00002003 case EXPR_CXX_MEMBER_CALL:
Douglas Gregor35942772011-09-09 21:34:22 +00002004 S = new (Context) CXXMemberCallExpr(Context, Empty);
Chris Lattner1817bd42010-05-09 05:36:05 +00002005 break;
Douglas Gregor39da0b82009-09-09 23:08:42 +00002006
Sebastian Redl8538e8d2010-08-18 23:57:32 +00002007 case EXPR_CXX_CONSTRUCT:
Argyrios Kyrtzidis6d00c132010-07-10 11:46:15 +00002008 S = new (Context) CXXConstructExpr(Empty);
2009 break;
2010
Sebastian Redl8538e8d2010-08-18 23:57:32 +00002011 case EXPR_CXX_TEMPORARY_OBJECT:
Argyrios Kyrtzidis6d00c132010-07-10 11:46:15 +00002012 S = new (Context) CXXTemporaryObjectExpr(Empty);
Douglas Gregor39da0b82009-09-09 23:08:42 +00002013 break;
Sam Weinigce757a72010-01-16 21:21:01 +00002014
Sebastian Redl8538e8d2010-08-18 23:57:32 +00002015 case EXPR_CXX_STATIC_CAST:
Douglas Gregor35942772011-09-09 21:34:22 +00002016 S = CXXStaticCastExpr::CreateEmpty(Context,
Sebastian Redl60adf4a2010-08-18 23:56:52 +00002017 /*PathSize*/ Record[ASTStmtReader::NumExprFields]);
Sam Weinigce757a72010-01-16 21:21:01 +00002018 break;
2019
Sebastian Redl8538e8d2010-08-18 23:57:32 +00002020 case EXPR_CXX_DYNAMIC_CAST:
Douglas Gregor35942772011-09-09 21:34:22 +00002021 S = CXXDynamicCastExpr::CreateEmpty(Context,
Sebastian Redl60adf4a2010-08-18 23:56:52 +00002022 /*PathSize*/ Record[ASTStmtReader::NumExprFields]);
Sam Weinigce757a72010-01-16 21:21:01 +00002023 break;
2024
Sebastian Redl8538e8d2010-08-18 23:57:32 +00002025 case EXPR_CXX_REINTERPRET_CAST:
Douglas Gregor35942772011-09-09 21:34:22 +00002026 S = CXXReinterpretCastExpr::CreateEmpty(Context,
Sebastian Redl60adf4a2010-08-18 23:56:52 +00002027 /*PathSize*/ Record[ASTStmtReader::NumExprFields]);
Sam Weinigce757a72010-01-16 21:21:01 +00002028 break;
2029
Sebastian Redl8538e8d2010-08-18 23:57:32 +00002030 case EXPR_CXX_CONST_CAST:
Douglas Gregor35942772011-09-09 21:34:22 +00002031 S = CXXConstCastExpr::CreateEmpty(Context);
Sam Weinigce757a72010-01-16 21:21:01 +00002032 break;
2033
Sebastian Redl8538e8d2010-08-18 23:57:32 +00002034 case EXPR_CXX_FUNCTIONAL_CAST:
Douglas Gregor35942772011-09-09 21:34:22 +00002035 S = CXXFunctionalCastExpr::CreateEmpty(Context,
Sebastian Redl60adf4a2010-08-18 23:56:52 +00002036 /*PathSize*/ Record[ASTStmtReader::NumExprFields]);
Sam Weinigce757a72010-01-16 21:21:01 +00002037 break;
2038
Richard Smith9fcce652012-03-07 08:35:16 +00002039 case EXPR_USER_DEFINED_LITERAL:
2040 S = new (Context) UserDefinedLiteral(Context, Empty);
2041 break;
2042
Sebastian Redl8538e8d2010-08-18 23:57:32 +00002043 case EXPR_CXX_BOOL_LITERAL:
Sam Weinigeb7f9612010-02-07 06:32:43 +00002044 S = new (Context) CXXBoolLiteralExpr(Empty);
2045 break;
Sam Weinigce757a72010-01-16 21:21:01 +00002046
Sebastian Redl8538e8d2010-08-18 23:57:32 +00002047 case EXPR_CXX_NULL_PTR_LITERAL:
Sam Weinigeb7f9612010-02-07 06:32:43 +00002048 S = new (Context) CXXNullPtrLiteralExpr(Empty);
2049 break;
Sebastian Redl8538e8d2010-08-18 23:57:32 +00002050 case EXPR_CXX_TYPEID_EXPR:
Chris Lattner14ab24f2010-05-09 06:03:39 +00002051 S = new (Context) CXXTypeidExpr(Empty, true);
2052 break;
Sebastian Redl8538e8d2010-08-18 23:57:32 +00002053 case EXPR_CXX_TYPEID_TYPE:
Chris Lattner14ab24f2010-05-09 06:03:39 +00002054 S = new (Context) CXXTypeidExpr(Empty, false);
2055 break;
Francois Pichet01b7c302010-09-08 12:20:18 +00002056 case EXPR_CXX_UUIDOF_EXPR:
2057 S = new (Context) CXXUuidofExpr(Empty, true);
2058 break;
2059 case EXPR_CXX_UUIDOF_TYPE:
2060 S = new (Context) CXXUuidofExpr(Empty, false);
2061 break;
Sebastian Redl8538e8d2010-08-18 23:57:32 +00002062 case EXPR_CXX_THIS:
Chris Lattner2fbdfcd2010-05-09 06:15:05 +00002063 S = new (Context) CXXThisExpr(Empty);
2064 break;
Sebastian Redl8538e8d2010-08-18 23:57:32 +00002065 case EXPR_CXX_THROW:
Chris Lattner2fbdfcd2010-05-09 06:15:05 +00002066 S = new (Context) CXXThrowExpr(Empty);
2067 break;
Sebastian Redl8538e8d2010-08-18 23:57:32 +00002068 case EXPR_CXX_DEFAULT_ARG: {
Sebastian Redl60adf4a2010-08-18 23:56:52 +00002069 bool HasOtherExprStored = Record[ASTStmtReader::NumExprFields];
Argyrios Kyrtzidis8a507332010-07-02 23:30:15 +00002070 if (HasOtherExprStored) {
2071 Expr *SubExpr = ReadSubExpr();
Douglas Gregor35942772011-09-09 21:34:22 +00002072 S = CXXDefaultArgExpr::Create(Context, SourceLocation(), 0, SubExpr);
Argyrios Kyrtzidis8a507332010-07-02 23:30:15 +00002073 } else
2074 S = new (Context) CXXDefaultArgExpr(Empty);
Chris Lattner030854b2010-05-09 06:40:08 +00002075 break;
Argyrios Kyrtzidis8a507332010-07-02 23:30:15 +00002076 }
Sebastian Redl8538e8d2010-08-18 23:57:32 +00002077 case EXPR_CXX_BIND_TEMPORARY:
Chris Lattnerd2598362010-05-10 00:25:06 +00002078 S = new (Context) CXXBindTemporaryExpr(Empty);
2079 break;
Douglas Gregore2ca6d42010-09-02 21:50:02 +00002080
Sebastian Redl8538e8d2010-08-18 23:57:32 +00002081 case EXPR_CXX_SCALAR_VALUE_INIT:
Douglas Gregored8abf12010-07-08 06:14:04 +00002082 S = new (Context) CXXScalarValueInitExpr(Empty);
Chris Lattner59218632010-05-10 01:22:27 +00002083 break;
Sebastian Redl8538e8d2010-08-18 23:57:32 +00002084 case EXPR_CXX_NEW:
Chris Lattner59218632010-05-10 01:22:27 +00002085 S = new (Context) CXXNewExpr(Empty);
2086 break;
Sebastian Redl8538e8d2010-08-18 23:57:32 +00002087 case EXPR_CXX_DELETE:
Argyrios Kyrtzidis95fc98c2010-06-22 17:07:59 +00002088 S = new (Context) CXXDeleteExpr(Empty);
2089 break;
Sebastian Redl8538e8d2010-08-18 23:57:32 +00002090 case EXPR_CXX_PSEUDO_DESTRUCTOR:
Argyrios Kyrtzidisde4bd182010-06-28 09:32:03 +00002091 S = new (Context) CXXPseudoDestructorExpr(Empty);
2092 break;
Chris Lattner59218632010-05-10 01:22:27 +00002093
John McCall4765fa02010-12-06 08:20:24 +00002094 case EXPR_EXPR_WITH_CLEANUPS:
John McCall80ee6e82011-11-10 05:35:25 +00002095 S = ExprWithCleanups::Create(Context, Empty,
2096 Record[ASTStmtReader::NumExprFields]);
Chris Lattnerd2598362010-05-10 00:25:06 +00002097 break;
Argyrios Kyrtzidis8dfbd8b2010-06-24 08:57:31 +00002098
Sebastian Redl8538e8d2010-08-18 23:57:32 +00002099 case EXPR_CXX_DEPENDENT_SCOPE_MEMBER:
Douglas Gregor35942772011-09-09 21:34:22 +00002100 S = CXXDependentScopeMemberExpr::CreateEmpty(Context,
Abramo Bagnarae4b92762012-01-27 09:46:47 +00002101 /*HasTemplateKWAndArgsInfo=*/Record[ASTStmtReader::NumExprFields],
Douglas Gregordef03542011-02-04 12:01:24 +00002102 /*NumTemplateArgs=*/Record[ASTStmtReader::NumExprFields]
2103 ? Record[ASTStmtReader::NumExprFields + 1]
2104 : 0);
Argyrios Kyrtzidis8dfbd8b2010-06-24 08:57:31 +00002105 break;
2106
Sebastian Redl8538e8d2010-08-18 23:57:32 +00002107 case EXPR_CXX_DEPENDENT_SCOPE_DECL_REF:
Douglas Gregor35942772011-09-09 21:34:22 +00002108 S = DependentScopeDeclRefExpr::CreateEmpty(Context,
Abramo Bagnarae4b92762012-01-27 09:46:47 +00002109 /*HasTemplateKWAndArgsInfo=*/Record[ASTStmtReader::NumExprFields],
Douglas Gregordef03542011-02-04 12:01:24 +00002110 /*NumTemplateArgs=*/Record[ASTStmtReader::NumExprFields]
2111 ? Record[ASTStmtReader::NumExprFields + 1]
2112 : 0);
Argyrios Kyrtzidis12dffcd2010-06-28 09:31:56 +00002113 break;
2114
Sebastian Redl8538e8d2010-08-18 23:57:32 +00002115 case EXPR_CXX_UNRESOLVED_CONSTRUCT:
Douglas Gregor35942772011-09-09 21:34:22 +00002116 S = CXXUnresolvedConstructExpr::CreateEmpty(Context,
Sebastian Redl60adf4a2010-08-18 23:56:52 +00002117 /*NumArgs=*/Record[ASTStmtReader::NumExprFields]);
Argyrios Kyrtzidisa77eb082010-06-25 09:03:26 +00002118 break;
2119
Sebastian Redl8538e8d2010-08-18 23:57:32 +00002120 case EXPR_CXX_UNRESOLVED_MEMBER:
Douglas Gregor35942772011-09-09 21:34:22 +00002121 S = UnresolvedMemberExpr::CreateEmpty(Context,
Abramo Bagnarae4b92762012-01-27 09:46:47 +00002122 /*HasTemplateKWAndArgsInfo=*/Record[ASTStmtReader::NumExprFields],
Douglas Gregordef03542011-02-04 12:01:24 +00002123 /*NumTemplateArgs=*/Record[ASTStmtReader::NumExprFields]
2124 ? Record[ASTStmtReader::NumExprFields + 1]
2125 : 0);
Argyrios Kyrtzidis8dfbd8b2010-06-24 08:57:31 +00002126 break;
Argyrios Kyrtzidisbd65bb52010-06-25 09:03:34 +00002127
Sebastian Redl8538e8d2010-08-18 23:57:32 +00002128 case EXPR_CXX_UNRESOLVED_LOOKUP:
Douglas Gregor35942772011-09-09 21:34:22 +00002129 S = UnresolvedLookupExpr::CreateEmpty(Context,
Abramo Bagnarae4b92762012-01-27 09:46:47 +00002130 /*HasTemplateKWAndArgsInfo=*/Record[ASTStmtReader::NumExprFields],
Douglas Gregordef03542011-02-04 12:01:24 +00002131 /*NumTemplateArgs=*/Record[ASTStmtReader::NumExprFields]
2132 ? Record[ASTStmtReader::NumExprFields + 1]
2133 : 0);
Argyrios Kyrtzidisbd65bb52010-06-25 09:03:34 +00002134 break;
Argyrios Kyrtzidis6d00c132010-07-10 11:46:15 +00002135
Sebastian Redl8538e8d2010-08-18 23:57:32 +00002136 case EXPR_CXX_UNARY_TYPE_TRAIT:
Argyrios Kyrtzidis6d00c132010-07-10 11:46:15 +00002137 S = new (Context) UnaryTypeTraitExpr(Empty);
2138 break;
Sebastian Redl6b219d02010-09-10 20:55:54 +00002139
Francois Pichetf1872372010-12-08 22:35:30 +00002140 case EXPR_BINARY_TYPE_TRAIT:
Francois Pichet6ad6f282010-12-07 00:08:36 +00002141 S = new (Context) BinaryTypeTraitExpr(Empty);
2142 break;
2143
Douglas Gregor4ca8ac22012-02-24 07:38:34 +00002144 case EXPR_TYPE_TRAIT:
2145 S = TypeTraitExpr::CreateDeserialized(Context,
2146 Record[ASTStmtReader::NumExprFields]);
2147 break;
2148
John Wiegley21ff2e52011-04-28 00:16:57 +00002149 case EXPR_ARRAY_TYPE_TRAIT:
2150 S = new (Context) ArrayTypeTraitExpr(Empty);
2151 break;
2152
John Wiegley55262202011-04-25 06:54:41 +00002153 case EXPR_CXX_EXPRESSION_TRAIT:
2154 S = new (Context) ExpressionTraitExpr(Empty);
2155 break;
2156
Sebastian Redl6b219d02010-09-10 20:55:54 +00002157 case EXPR_CXX_NOEXCEPT:
2158 S = new (Context) CXXNoexceptExpr(Empty);
2159 break;
John McCall7cd7d1a2010-11-15 23:31:06 +00002160
Douglas Gregorbe230c32011-01-03 17:17:50 +00002161 case EXPR_PACK_EXPANSION:
2162 S = new (Context) PackExpansionExpr(Empty);
2163 break;
2164
Douglas Gregoree8aff02011-01-04 17:33:58 +00002165 case EXPR_SIZEOF_PACK:
2166 S = new (Context) SizeOfPackExpr(Empty);
2167 break;
2168
John McCall7110fd62011-07-15 07:00:14 +00002169 case EXPR_SUBST_NON_TYPE_TEMPLATE_PARM:
2170 S = new (Context) SubstNonTypeTemplateParmExpr(Empty);
2171 break;
2172
Douglas Gregorc7793c72011-01-15 01:15:58 +00002173 case EXPR_SUBST_NON_TYPE_TEMPLATE_PARM_PACK:
2174 S = new (Context) SubstNonTypeTemplateParmPackExpr(Empty);
2175 break;
2176
Douglas Gregor03e80032011-06-21 17:03:29 +00002177 case EXPR_MATERIALIZE_TEMPORARY:
2178 S = new (Context) MaterializeTemporaryExpr(Empty);
2179 break;
2180
Argyrios Kyrtzidis8bc27822011-12-03 03:49:52 +00002181 case EXPR_OPAQUE_VALUE:
2182 S = new (Context) OpaqueValueExpr(Empty);
John McCall7cd7d1a2010-11-15 23:31:06 +00002183 break;
Peter Collingbournee08ce652011-02-09 21:07:24 +00002184
2185 case EXPR_CUDA_KERNEL_CALL:
Douglas Gregor35942772011-09-09 21:34:22 +00002186 S = new (Context) CUDAKernelCallExpr(Context, Empty);
Peter Collingbournee08ce652011-02-09 21:07:24 +00002187 break;
Tanya Lattner61eee0c2011-06-04 00:47:47 +00002188
2189 case EXPR_ASTYPE:
2190 S = new (Context) AsTypeExpr(Empty);
2191 break;
Eli Friedman276b0612011-10-11 02:20:01 +00002192
John McCall4b9c2d22011-11-06 09:01:30 +00002193 case EXPR_PSEUDO_OBJECT: {
2194 unsigned numSemanticExprs = Record[ASTStmtReader::NumExprFields];
2195 S = PseudoObjectExpr::Create(Context, Empty, numSemanticExprs);
2196 break;
2197 }
2198
Eli Friedman276b0612011-10-11 02:20:01 +00002199 case EXPR_ATOMIC:
2200 S = new (Context) AtomicExpr(Empty);
2201 break;
Douglas Gregor9d36f5d2012-02-14 17:54:36 +00002202
2203 case EXPR_LAMBDA: {
2204 unsigned NumCaptures = Record[ASTStmtReader::NumExprFields];
2205 unsigned NumArrayIndexVars = Record[ASTStmtReader::NumExprFields + 1];
2206 S = LambdaExpr::CreateDeserialized(Context, NumCaptures,
2207 NumArrayIndexVars);
2208 break;
2209 }
Chris Lattner4c6f9522009-04-27 05:14:47 +00002210 }
Argyrios Kyrtzidis6d00c132010-07-10 11:46:15 +00002211
Chris Lattner4c6f9522009-04-27 05:14:47 +00002212 // We hit a STMT_STOP, so we're done with this expression.
2213 if (Finished)
2214 break;
2215
2216 ++NumStatementsRead;
2217
Argyrios Kyrtzidise6f08682011-10-21 23:02:28 +00002218 if (S && !IsStmtReference) {
Argyrios Kyrtzidis919e6932010-06-28 22:28:35 +00002219 Reader.Visit(S);
Argyrios Kyrtzidise6f08682011-10-21 23:02:28 +00002220 StmtEntries[Cursor.GetCurrentBitNo()] = S;
2221 }
2222
Chris Lattner4c6f9522009-04-27 05:14:47 +00002223
2224 assert(Idx == Record.size() && "Invalid deserialization of statement");
2225 StmtStack.push_back(S);
2226 }
Argyrios Kyrtzidis919e6932010-06-28 22:28:35 +00002227
2228#ifndef NDEBUG
2229 assert(StmtStack.size() > PrevNumStmts && "Read too many sub stmts!");
2230 assert(StmtStack.size() == PrevNumStmts + 1 && "Extra expressions on stack!");
2231#endif
2232
2233 return StmtStack.pop_back_val();
Chris Lattner4c6f9522009-04-27 05:14:47 +00002234}