blob: 7d56f10eb5382b20f5251f0107276f235bf8fffe [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"
Benjamin Kramer471c8b42012-07-04 20:19:54 +000016#include "clang/AST/ASTContext.h"
Douglas Gregor39da0b82009-09-09 23:08:42 +000017#include "clang/AST/DeclCXX.h"
Douglas Gregorc7793c72011-01-15 01:15:58 +000018#include "clang/AST/DeclTemplate.h"
Chris Lattner4c6f9522009-04-27 05:14:47 +000019#include "clang/AST/StmtVisitor.h"
Benjamin Kramer8fe83e12012-02-04 13:45:25 +000020#include "llvm/ADT/SmallString.h"
Chris Lattner4c6f9522009-04-27 05:14:47 +000021using namespace clang;
Sebastian Redl8538e8d2010-08-18 23:57:32 +000022using namespace clang::serialization;
Chris Lattner4c6f9522009-04-27 05:14:47 +000023
Argyrios Kyrtzidis37bdfe22010-06-30 08:49:18 +000024namespace clang {
Argyrios Kyrtzidis17cfded2010-06-28 09:31:42 +000025
Sebastian Redl60adf4a2010-08-18 23:56:52 +000026 class ASTStmtReader : public StmtVisitor<ASTStmtReader> {
Douglas Gregor409448c2011-07-21 22:35:25 +000027 typedef ASTReader::RecordData RecordData;
28
Sebastian Redlc43b54c2010-08-18 23:56:43 +000029 ASTReader &Reader;
Douglas Gregor1a4761e2011-11-30 23:21:26 +000030 ModuleFile &F;
Sebastian Redl577d4792010-07-22 22:43:28 +000031 llvm::BitstreamCursor &DeclsCursor;
Sebastian Redlc43b54c2010-08-18 23:56:43 +000032 const ASTReader::RecordData &Record;
Chris Lattner4c6f9522009-04-27 05:14:47 +000033 unsigned &Idx;
Chris Lattner4c6f9522009-04-27 05:14:47 +000034
Douglas Gregor409448c2011-07-21 22:35:25 +000035 SourceLocation ReadSourceLocation(const RecordData &R, unsigned &I) {
Sebastian Redlc3632732010-10-05 15:59:54 +000036 return Reader.ReadSourceLocation(F, R, I);
37 }
Douglas Gregor409448c2011-07-21 22:35:25 +000038
39 SourceRange ReadSourceRange(const RecordData &R, unsigned &I) {
Sebastian Redlc3632732010-10-05 15:59:54 +000040 return Reader.ReadSourceRange(F, R, I);
41 }
Douglas Gregor409448c2011-07-21 22:35:25 +000042
43 TypeSourceInfo *GetTypeSourceInfo(const RecordData &R, unsigned &I) {
Sebastian Redlc3632732010-10-05 15:59:54 +000044 return Reader.GetTypeSourceInfo(F, R, I);
45 }
Douglas Gregor409448c2011-07-21 22:35:25 +000046
47 serialization::DeclID ReadDeclID(const RecordData &R, unsigned &I) {
48 return Reader.ReadDeclID(F, R, I);
49 }
50
51 Decl *ReadDecl(const RecordData &R, unsigned &I) {
52 return Reader.ReadDecl(F, R, I);
53 }
54
55 template<typename T>
56 T *ReadDeclAs(const RecordData &R, unsigned &I) {
57 return Reader.ReadDeclAs<T>(F, R, I);
58 }
59
Argyrios Kyrtzidis40451072010-10-15 18:21:24 +000060 void ReadDeclarationNameLoc(DeclarationNameLoc &DNLoc, DeclarationName Name,
61 const ASTReader::RecordData &R, unsigned &I) {
62 Reader.ReadDeclarationNameLoc(F, DNLoc, Name, R, I);
63 }
Douglas Gregor409448c2011-07-21 22:35:25 +000064
Argyrios Kyrtzidis40451072010-10-15 18:21:24 +000065 void ReadDeclarationNameInfo(DeclarationNameInfo &NameInfo,
66 const ASTReader::RecordData &R, unsigned &I) {
67 Reader.ReadDeclarationNameInfo(F, NameInfo, R, I);
68 }
Sebastian Redlc3632732010-10-05 15:59:54 +000069
Chris Lattner4c6f9522009-04-27 05:14:47 +000070 public:
Douglas Gregor1a4761e2011-11-30 23:21:26 +000071 ASTStmtReader(ASTReader &Reader, ModuleFile &F,
Sebastian Redlc3632732010-10-05 15:59:54 +000072 llvm::BitstreamCursor &Cursor,
Sebastian Redlc43b54c2010-08-18 23:56:43 +000073 const ASTReader::RecordData &Record, unsigned &Idx)
Sebastian Redlc3632732010-10-05 15:59:54 +000074 : Reader(Reader), F(F), DeclsCursor(Cursor), Record(Record), Idx(Idx) { }
Chris Lattner4c6f9522009-04-27 05:14:47 +000075
76 /// \brief The number of record fields required for the Stmt class
77 /// itself.
78 static const unsigned NumStmtFields = 0;
79
80 /// \brief The number of record fields required for the Expr class
81 /// itself.
Douglas Gregor561f8122011-07-01 01:22:09 +000082 static const unsigned NumExprFields = NumStmtFields + 7;
Abramo Bagnarae4b92762012-01-27 09:46:47 +000083
84 /// \brief Read and initialize a ExplicitTemplateArgumentList structure.
85 void ReadTemplateKWAndArgsInfo(ASTTemplateKWAndArgsInfo &Args,
86 unsigned NumTemplateArgs);
Argyrios Kyrtzidis36c76f02010-06-28 09:31:48 +000087 /// \brief Read and initialize a ExplicitTemplateArgumentList structure.
Argyrios Kyrtzidisb0c3e092011-09-22 20:07:03 +000088 void ReadExplicitTemplateArgumentList(ASTTemplateArgumentListInfo &ArgList,
Argyrios Kyrtzidis919e6932010-06-28 22:28:35 +000089 unsigned NumTemplateArgs);
Chris Lattner4c6f9522009-04-27 05:14:47 +000090
Argyrios Kyrtzidis919e6932010-06-28 22:28:35 +000091 void VisitStmt(Stmt *S);
John McCall7110fd62011-07-15 07:00:14 +000092#define STMT(Type, Base) \
93 void Visit##Type(Type *);
94#include "clang/AST/StmtNodes.inc"
Chris Lattner4c6f9522009-04-27 05:14:47 +000095 };
96}
97
Sebastian Redl60adf4a2010-08-18 23:56:52 +000098void ASTStmtReader::
Abramo Bagnarae4b92762012-01-27 09:46:47 +000099ReadTemplateKWAndArgsInfo(ASTTemplateKWAndArgsInfo &Args,
100 unsigned NumTemplateArgs) {
101 SourceLocation TemplateKWLoc = ReadSourceLocation(Record, Idx);
Argyrios Kyrtzidis36c76f02010-06-28 09:31:48 +0000102 TemplateArgumentListInfo ArgInfo;
Sebastian Redlc3632732010-10-05 15:59:54 +0000103 ArgInfo.setLAngleLoc(ReadSourceLocation(Record, Idx));
104 ArgInfo.setRAngleLoc(ReadSourceLocation(Record, Idx));
Argyrios Kyrtzidis36c76f02010-06-28 09:31:48 +0000105 for (unsigned i = 0; i != NumTemplateArgs; ++i)
Sebastian Redl577d4792010-07-22 22:43:28 +0000106 ArgInfo.addArgument(
Sebastian Redlc3632732010-10-05 15:59:54 +0000107 Reader.ReadTemplateArgumentLoc(F, Record, Idx));
Abramo Bagnarae4b92762012-01-27 09:46:47 +0000108 Args.initializeFrom(TemplateKWLoc, ArgInfo);
Argyrios Kyrtzidis36c76f02010-06-28 09:31:48 +0000109}
110
Sebastian Redl60adf4a2010-08-18 23:56:52 +0000111void ASTStmtReader::VisitStmt(Stmt *S) {
Chris Lattner4c6f9522009-04-27 05:14:47 +0000112 assert(Idx == NumStmtFields && "Incorrect statement field count");
Chris Lattner4c6f9522009-04-27 05:14:47 +0000113}
114
Sebastian Redl60adf4a2010-08-18 23:56:52 +0000115void ASTStmtReader::VisitNullStmt(NullStmt *S) {
Chris Lattner4c6f9522009-04-27 05:14:47 +0000116 VisitStmt(S);
Sebastian Redlc3632732010-10-05 15:59:54 +0000117 S->setSemiLoc(ReadSourceLocation(Record, Idx));
Argyrios Kyrtzidise2ca8282011-09-01 21:53:45 +0000118 S->HasLeadingEmptyMacro = Record[Idx++];
Chris Lattner4c6f9522009-04-27 05:14:47 +0000119}
120
Sebastian Redl60adf4a2010-08-18 23:56:52 +0000121void ASTStmtReader::VisitCompoundStmt(CompoundStmt *S) {
Chris Lattner4c6f9522009-04-27 05:14:47 +0000122 VisitStmt(S);
Chris Lattner5f9e2722011-07-23 10:55:15 +0000123 SmallVector<Stmt *, 16> Stmts;
Chris Lattner4c6f9522009-04-27 05:14:47 +0000124 unsigned NumStmts = Record[Idx++];
Argyrios Kyrtzidis919e6932010-06-28 22:28:35 +0000125 while (NumStmts--)
Argyrios Kyrtzidisd98a2ab2010-06-29 22:46:25 +0000126 Stmts.push_back(Reader.ReadSubStmt());
Douglas Gregor35942772011-09-09 21:34:22 +0000127 S->setStmts(Reader.getContext(), Stmts.data(), Stmts.size());
Sebastian Redlc3632732010-10-05 15:59:54 +0000128 S->setLBracLoc(ReadSourceLocation(Record, Idx));
129 S->setRBracLoc(ReadSourceLocation(Record, Idx));
Chris Lattner4c6f9522009-04-27 05:14:47 +0000130}
131
Sebastian Redl60adf4a2010-08-18 23:56:52 +0000132void ASTStmtReader::VisitSwitchCase(SwitchCase *S) {
Chris Lattner4c6f9522009-04-27 05:14:47 +0000133 VisitStmt(S);
134 Reader.RecordSwitchCaseID(S, Record[Idx++]);
Chris Lattner4c6f9522009-04-27 05:14:47 +0000135}
136
Sebastian Redl60adf4a2010-08-18 23:56:52 +0000137void ASTStmtReader::VisitCaseStmt(CaseStmt *S) {
Chris Lattner4c6f9522009-04-27 05:14:47 +0000138 VisitSwitchCase(S);
Argyrios Kyrtzidisd98a2ab2010-06-29 22:46:25 +0000139 S->setLHS(Reader.ReadSubExpr());
140 S->setRHS(Reader.ReadSubExpr());
141 S->setSubStmt(Reader.ReadSubStmt());
Sebastian Redlc3632732010-10-05 15:59:54 +0000142 S->setCaseLoc(ReadSourceLocation(Record, Idx));
143 S->setEllipsisLoc(ReadSourceLocation(Record, Idx));
144 S->setColonLoc(ReadSourceLocation(Record, Idx));
Chris Lattner4c6f9522009-04-27 05:14:47 +0000145}
146
Sebastian Redl60adf4a2010-08-18 23:56:52 +0000147void ASTStmtReader::VisitDefaultStmt(DefaultStmt *S) {
Chris Lattner4c6f9522009-04-27 05:14:47 +0000148 VisitSwitchCase(S);
Argyrios Kyrtzidisd98a2ab2010-06-29 22:46:25 +0000149 S->setSubStmt(Reader.ReadSubStmt());
Sebastian Redlc3632732010-10-05 15:59:54 +0000150 S->setDefaultLoc(ReadSourceLocation(Record, Idx));
151 S->setColonLoc(ReadSourceLocation(Record, Idx));
Chris Lattner4c6f9522009-04-27 05:14:47 +0000152}
153
Sebastian Redl60adf4a2010-08-18 23:56:52 +0000154void ASTStmtReader::VisitLabelStmt(LabelStmt *S) {
Chris Lattner4c6f9522009-04-27 05:14:47 +0000155 VisitStmt(S);
Douglas Gregor409448c2011-07-21 22:35:25 +0000156 LabelDecl *LD = ReadDeclAs<LabelDecl>(Record, Idx);
Chris Lattnerad8dcf42011-02-17 07:39:24 +0000157 LD->setStmt(S);
158 S->setDecl(LD);
Argyrios Kyrtzidisd98a2ab2010-06-29 22:46:25 +0000159 S->setSubStmt(Reader.ReadSubStmt());
Sebastian Redlc3632732010-10-05 15:59:54 +0000160 S->setIdentLoc(ReadSourceLocation(Record, Idx));
Chris Lattner4c6f9522009-04-27 05:14:47 +0000161}
162
Richard Smith534986f2012-04-14 00:33:13 +0000163void ASTStmtReader::VisitAttributedStmt(AttributedStmt *S) {
164 VisitStmt(S);
Alexander Kornienko49908902012-07-09 10:04:07 +0000165 uint64_t NumAttrs = Record[Idx++];
Richard Smith534986f2012-04-14 00:33:13 +0000166 AttrVec Attrs;
167 Reader.ReadAttributes(F, Attrs, Record, Idx);
Alexander Kornienko49908902012-07-09 10:04:07 +0000168 assert(NumAttrs == S->NumAttrs);
169 assert(NumAttrs == Attrs.size());
170 std::copy(Attrs.begin(), Attrs.end(), S->Attrs);
Richard Smith534986f2012-04-14 00:33:13 +0000171 S->SubStmt = Reader.ReadSubStmt();
172 S->AttrLoc = ReadSourceLocation(Record, Idx);
173}
174
Sebastian Redl60adf4a2010-08-18 23:56:52 +0000175void ASTStmtReader::VisitIfStmt(IfStmt *S) {
Chris Lattner4c6f9522009-04-27 05:14:47 +0000176 VisitStmt(S);
Richard Smith534986f2012-04-14 00:33:13 +0000177 S->setConditionVariable(Reader.getContext(),
Douglas Gregor409448c2011-07-21 22:35:25 +0000178 ReadDeclAs<VarDecl>(Record, Idx));
Argyrios Kyrtzidisd98a2ab2010-06-29 22:46:25 +0000179 S->setCond(Reader.ReadSubExpr());
180 S->setThen(Reader.ReadSubStmt());
181 S->setElse(Reader.ReadSubStmt());
Sebastian Redlc3632732010-10-05 15:59:54 +0000182 S->setIfLoc(ReadSourceLocation(Record, Idx));
183 S->setElseLoc(ReadSourceLocation(Record, Idx));
Chris Lattner4c6f9522009-04-27 05:14:47 +0000184}
185
Sebastian Redl60adf4a2010-08-18 23:56:52 +0000186void ASTStmtReader::VisitSwitchStmt(SwitchStmt *S) {
Chris Lattner4c6f9522009-04-27 05:14:47 +0000187 VisitStmt(S);
Douglas Gregor35942772011-09-09 21:34:22 +0000188 S->setConditionVariable(Reader.getContext(),
Douglas Gregor409448c2011-07-21 22:35:25 +0000189 ReadDeclAs<VarDecl>(Record, Idx));
Argyrios Kyrtzidisd98a2ab2010-06-29 22:46:25 +0000190 S->setCond(Reader.ReadSubExpr());
191 S->setBody(Reader.ReadSubStmt());
Sebastian Redlc3632732010-10-05 15:59:54 +0000192 S->setSwitchLoc(ReadSourceLocation(Record, Idx));
Ted Kremenek559fb552010-09-09 00:05:53 +0000193 if (Record[Idx++])
194 S->setAllEnumCasesCovered();
195
Chris Lattner4c6f9522009-04-27 05:14:47 +0000196 SwitchCase *PrevSC = 0;
197 for (unsigned N = Record.size(); Idx != N; ++Idx) {
198 SwitchCase *SC = Reader.getSwitchCaseWithID(Record[Idx]);
199 if (PrevSC)
200 PrevSC->setNextSwitchCase(SC);
201 else
202 S->setSwitchCaseList(SC);
Mike Stump1eb44332009-09-09 15:08:12 +0000203
Chris Lattner4c6f9522009-04-27 05:14:47 +0000204 PrevSC = SC;
205 }
Chris Lattner4c6f9522009-04-27 05:14:47 +0000206}
207
Sebastian Redl60adf4a2010-08-18 23:56:52 +0000208void ASTStmtReader::VisitWhileStmt(WhileStmt *S) {
Chris Lattner4c6f9522009-04-27 05:14:47 +0000209 VisitStmt(S);
Douglas Gregor35942772011-09-09 21:34:22 +0000210 S->setConditionVariable(Reader.getContext(),
Douglas Gregor409448c2011-07-21 22:35:25 +0000211 ReadDeclAs<VarDecl>(Record, Idx));
212
Argyrios Kyrtzidisd98a2ab2010-06-29 22:46:25 +0000213 S->setCond(Reader.ReadSubExpr());
214 S->setBody(Reader.ReadSubStmt());
Sebastian Redlc3632732010-10-05 15:59:54 +0000215 S->setWhileLoc(ReadSourceLocation(Record, Idx));
Chris Lattner4c6f9522009-04-27 05:14:47 +0000216}
217
Sebastian Redl60adf4a2010-08-18 23:56:52 +0000218void ASTStmtReader::VisitDoStmt(DoStmt *S) {
Chris Lattner4c6f9522009-04-27 05:14:47 +0000219 VisitStmt(S);
Argyrios Kyrtzidisd98a2ab2010-06-29 22:46:25 +0000220 S->setCond(Reader.ReadSubExpr());
221 S->setBody(Reader.ReadSubStmt());
Sebastian Redlc3632732010-10-05 15:59:54 +0000222 S->setDoLoc(ReadSourceLocation(Record, Idx));
223 S->setWhileLoc(ReadSourceLocation(Record, Idx));
224 S->setRParenLoc(ReadSourceLocation(Record, Idx));
Chris Lattner4c6f9522009-04-27 05:14:47 +0000225}
226
Sebastian Redl60adf4a2010-08-18 23:56:52 +0000227void ASTStmtReader::VisitForStmt(ForStmt *S) {
Chris Lattner4c6f9522009-04-27 05:14:47 +0000228 VisitStmt(S);
Argyrios Kyrtzidisd98a2ab2010-06-29 22:46:25 +0000229 S->setInit(Reader.ReadSubStmt());
230 S->setCond(Reader.ReadSubExpr());
Douglas Gregor35942772011-09-09 21:34:22 +0000231 S->setConditionVariable(Reader.getContext(),
Douglas Gregor409448c2011-07-21 22:35:25 +0000232 ReadDeclAs<VarDecl>(Record, Idx));
Argyrios Kyrtzidisd98a2ab2010-06-29 22:46:25 +0000233 S->setInc(Reader.ReadSubExpr());
234 S->setBody(Reader.ReadSubStmt());
Sebastian Redlc3632732010-10-05 15:59:54 +0000235 S->setForLoc(ReadSourceLocation(Record, Idx));
236 S->setLParenLoc(ReadSourceLocation(Record, Idx));
237 S->setRParenLoc(ReadSourceLocation(Record, Idx));
Chris Lattner4c6f9522009-04-27 05:14:47 +0000238}
239
Sebastian Redl60adf4a2010-08-18 23:56:52 +0000240void ASTStmtReader::VisitGotoStmt(GotoStmt *S) {
Chris Lattner4c6f9522009-04-27 05:14:47 +0000241 VisitStmt(S);
Douglas Gregor409448c2011-07-21 22:35:25 +0000242 S->setLabel(ReadDeclAs<LabelDecl>(Record, Idx));
Sebastian Redlc3632732010-10-05 15:59:54 +0000243 S->setGotoLoc(ReadSourceLocation(Record, Idx));
244 S->setLabelLoc(ReadSourceLocation(Record, Idx));
Chris Lattner4c6f9522009-04-27 05:14:47 +0000245}
246
Sebastian Redl60adf4a2010-08-18 23:56:52 +0000247void ASTStmtReader::VisitIndirectGotoStmt(IndirectGotoStmt *S) {
Chris Lattner4c6f9522009-04-27 05:14:47 +0000248 VisitStmt(S);
Sebastian Redlc3632732010-10-05 15:59:54 +0000249 S->setGotoLoc(ReadSourceLocation(Record, Idx));
250 S->setStarLoc(ReadSourceLocation(Record, Idx));
Argyrios Kyrtzidisd98a2ab2010-06-29 22:46:25 +0000251 S->setTarget(Reader.ReadSubExpr());
Chris Lattner4c6f9522009-04-27 05:14:47 +0000252}
253
Sebastian Redl60adf4a2010-08-18 23:56:52 +0000254void ASTStmtReader::VisitContinueStmt(ContinueStmt *S) {
Chris Lattner4c6f9522009-04-27 05:14:47 +0000255 VisitStmt(S);
Sebastian Redlc3632732010-10-05 15:59:54 +0000256 S->setContinueLoc(ReadSourceLocation(Record, Idx));
Chris Lattner4c6f9522009-04-27 05:14:47 +0000257}
258
Sebastian Redl60adf4a2010-08-18 23:56:52 +0000259void ASTStmtReader::VisitBreakStmt(BreakStmt *S) {
Chris Lattner4c6f9522009-04-27 05:14:47 +0000260 VisitStmt(S);
Sebastian Redlc3632732010-10-05 15:59:54 +0000261 S->setBreakLoc(ReadSourceLocation(Record, Idx));
Chris Lattner4c6f9522009-04-27 05:14:47 +0000262}
263
Sebastian Redl60adf4a2010-08-18 23:56:52 +0000264void ASTStmtReader::VisitReturnStmt(ReturnStmt *S) {
Chris Lattner4c6f9522009-04-27 05:14:47 +0000265 VisitStmt(S);
Argyrios Kyrtzidisd98a2ab2010-06-29 22:46:25 +0000266 S->setRetValue(Reader.ReadSubExpr());
Sebastian Redlc3632732010-10-05 15:59:54 +0000267 S->setReturnLoc(ReadSourceLocation(Record, Idx));
Douglas Gregor409448c2011-07-21 22:35:25 +0000268 S->setNRVOCandidate(ReadDeclAs<VarDecl>(Record, Idx));
Chris Lattner4c6f9522009-04-27 05:14:47 +0000269}
270
Sebastian Redl60adf4a2010-08-18 23:56:52 +0000271void ASTStmtReader::VisitDeclStmt(DeclStmt *S) {
Chris Lattner4c6f9522009-04-27 05:14:47 +0000272 VisitStmt(S);
Sebastian Redlc3632732010-10-05 15:59:54 +0000273 S->setStartLoc(ReadSourceLocation(Record, Idx));
274 S->setEndLoc(ReadSourceLocation(Record, Idx));
Chris Lattner4c6f9522009-04-27 05:14:47 +0000275
276 if (Idx + 1 == Record.size()) {
277 // Single declaration
Douglas Gregor409448c2011-07-21 22:35:25 +0000278 S->setDeclGroup(DeclGroupRef(ReadDecl(Record, Idx)));
Chris Lattner4c6f9522009-04-27 05:14:47 +0000279 } else {
Chris Lattner5f9e2722011-07-23 10:55:15 +0000280 SmallVector<Decl *, 16> Decls;
Douglas Gregor409448c2011-07-21 22:35:25 +0000281 Decls.reserve(Record.size() - Idx);
282 for (unsigned N = Record.size(); Idx != N; )
283 Decls.push_back(ReadDecl(Record, Idx));
Douglas Gregor35942772011-09-09 21:34:22 +0000284 S->setDeclGroup(DeclGroupRef(DeclGroup::Create(Reader.getContext(),
Douglas Gregor75fdb232009-05-22 22:45:36 +0000285 Decls.data(),
286 Decls.size())));
Chris Lattner4c6f9522009-04-27 05:14:47 +0000287 }
Chris Lattner4c6f9522009-04-27 05:14:47 +0000288}
289
Sebastian Redl60adf4a2010-08-18 23:56:52 +0000290void ASTStmtReader::VisitAsmStmt(AsmStmt *S) {
Chris Lattner4c6f9522009-04-27 05:14:47 +0000291 VisitStmt(S);
292 unsigned NumOutputs = Record[Idx++];
293 unsigned NumInputs = Record[Idx++];
294 unsigned NumClobbers = Record[Idx++];
Sebastian Redlc3632732010-10-05 15:59:54 +0000295 S->setAsmLoc(ReadSourceLocation(Record, Idx));
296 S->setRParenLoc(ReadSourceLocation(Record, Idx));
Chris Lattner4c6f9522009-04-27 05:14:47 +0000297 S->setVolatile(Record[Idx++]);
298 S->setSimple(Record[Idx++]);
Mike Stump3b11fd32010-01-04 22:37:17 +0000299 S->setMSAsm(Record[Idx++]);
Mike Stump1eb44332009-09-09 15:08:12 +0000300
Argyrios Kyrtzidisd98a2ab2010-06-29 22:46:25 +0000301 S->setAsmString(cast_or_null<StringLiteral>(Reader.ReadSubStmt()));
Chris Lattner4c6f9522009-04-27 05:14:47 +0000302
303 // Outputs and inputs
Chris Lattner5f9e2722011-07-23 10:55:15 +0000304 SmallVector<IdentifierInfo *, 16> Names;
305 SmallVector<StringLiteral*, 16> Constraints;
306 SmallVector<Stmt*, 16> Exprs;
Chris Lattner4c6f9522009-04-27 05:14:47 +0000307 for (unsigned I = 0, N = NumOutputs + NumInputs; I != N; ++I) {
Douglas Gregor95eab172011-07-28 20:55:49 +0000308 Names.push_back(Reader.GetIdentifierInfo(F, Record, Idx));
Argyrios Kyrtzidisd98a2ab2010-06-29 22:46:25 +0000309 Constraints.push_back(cast_or_null<StringLiteral>(Reader.ReadSubStmt()));
310 Exprs.push_back(Reader.ReadSubStmt());
Chris Lattner4c6f9522009-04-27 05:14:47 +0000311 }
Chris Lattner4c6f9522009-04-27 05:14:47 +0000312
313 // Constraints
Chris Lattner5f9e2722011-07-23 10:55:15 +0000314 SmallVector<StringLiteral*, 16> Clobbers;
Chris Lattner4c6f9522009-04-27 05:14:47 +0000315 for (unsigned I = 0; I != NumClobbers; ++I)
Argyrios Kyrtzidisd98a2ab2010-06-29 22:46:25 +0000316 Clobbers.push_back(cast_or_null<StringLiteral>(Reader.ReadSubStmt()));
Anders Carlssonfdba9c02010-01-30 19:34:25 +0000317
Douglas Gregor35942772011-09-09 21:34:22 +0000318 S->setOutputsAndInputsAndClobbers(Reader.getContext(),
Anders Carlssonacb6bcb2010-01-30 20:38:10 +0000319 Names.data(), Constraints.data(),
Anders Carlssonfdba9c02010-01-30 19:34:25 +0000320 Exprs.data(), NumOutputs, NumInputs,
321 Clobbers.data(), NumClobbers);
Chris Lattner4c6f9522009-04-27 05:14:47 +0000322}
323
Chad Rosier8cd64b42012-06-11 20:47:18 +0000324void ASTStmtReader::VisitMSAsmStmt(MSAsmStmt *S) {
325 // FIXME: Statement reader not yet implemented for MS style inline asm.
326 VisitStmt(S);
327}
328
Sebastian Redl60adf4a2010-08-18 23:56:52 +0000329void ASTStmtReader::VisitExpr(Expr *E) {
Chris Lattner4c6f9522009-04-27 05:14:47 +0000330 VisitStmt(E);
Douglas Gregor393f2492011-07-22 00:38:23 +0000331 E->setType(Reader.readType(F, Record, Idx));
Chris Lattner4c6f9522009-04-27 05:14:47 +0000332 E->setTypeDependent(Record[Idx++]);
333 E->setValueDependent(Record[Idx++]);
Douglas Gregor561f8122011-07-01 01:22:09 +0000334 E->setInstantiationDependent(Record[Idx++]);
Douglas Gregord0937222010-12-13 22:49:22 +0000335 E->ExprBits.ContainsUnexpandedParameterPack = Record[Idx++];
John McCallf89e55a2010-11-18 06:31:45 +0000336 E->setValueKind(static_cast<ExprValueKind>(Record[Idx++]));
337 E->setObjectKind(static_cast<ExprObjectKind>(Record[Idx++]));
Chris Lattner4c6f9522009-04-27 05:14:47 +0000338 assert(Idx == NumExprFields && "Incorrect expression field count");
Chris Lattner4c6f9522009-04-27 05:14:47 +0000339}
340
Sebastian Redl60adf4a2010-08-18 23:56:52 +0000341void ASTStmtReader::VisitPredefinedExpr(PredefinedExpr *E) {
Chris Lattner4c6f9522009-04-27 05:14:47 +0000342 VisitExpr(E);
Sebastian Redlc3632732010-10-05 15:59:54 +0000343 E->setLocation(ReadSourceLocation(Record, Idx));
Chris Lattner4c6f9522009-04-27 05:14:47 +0000344 E->setIdentType((PredefinedExpr::IdentType)Record[Idx++]);
Chris Lattner4c6f9522009-04-27 05:14:47 +0000345}
346
Sebastian Redl60adf4a2010-08-18 23:56:52 +0000347void ASTStmtReader::VisitDeclRefExpr(DeclRefExpr *E) {
Chris Lattner4c6f9522009-04-27 05:14:47 +0000348 VisitExpr(E);
Argyrios Kyrtzidis663e3802010-07-08 13:09:47 +0000349
Chandler Carruthcb66cff2011-05-01 21:29:53 +0000350 E->DeclRefExprBits.HasQualifier = Record[Idx++];
Chandler Carruth3aa81402011-05-01 23:48:14 +0000351 E->DeclRefExprBits.HasFoundDecl = Record[Idx++];
Abramo Bagnarae4b92762012-01-27 09:46:47 +0000352 E->DeclRefExprBits.HasTemplateKWAndArgsInfo = Record[Idx++];
Abramo Bagnara7cc58b42011-10-05 07:56:41 +0000353 E->DeclRefExprBits.HadMultipleCandidates = Record[Idx++];
John McCallf4b88a42012-03-10 09:33:50 +0000354 E->DeclRefExprBits.RefersToEnclosingLocal = Record[Idx++];
Anders Carlssonb0ca1372011-03-06 18:19:42 +0000355 unsigned NumTemplateArgs = 0;
Abramo Bagnarae4b92762012-01-27 09:46:47 +0000356 if (E->hasTemplateKWAndArgsInfo())
Anders Carlssonb0ca1372011-03-06 18:19:42 +0000357 NumTemplateArgs = Record[Idx++];
358
Chandler Carruthcb66cff2011-05-01 21:29:53 +0000359 if (E->hasQualifier())
Chandler Carruth6857c3e2011-05-01 22:14:37 +0000360 E->getInternalQualifierLoc()
Douglas Gregor40d96a62011-02-28 21:54:11 +0000361 = Reader.ReadNestedNameSpecifierLoc(F, Record, Idx);
Argyrios Kyrtzidis663e3802010-07-08 13:09:47 +0000362
Chandler Carruth3aa81402011-05-01 23:48:14 +0000363 if (E->hasFoundDecl())
Douglas Gregor409448c2011-07-21 22:35:25 +0000364 E->getInternalFoundDecl() = ReadDeclAs<NamedDecl>(Record, Idx);
Chandler Carruth3aa81402011-05-01 23:48:14 +0000365
Abramo Bagnarae4b92762012-01-27 09:46:47 +0000366 if (E->hasTemplateKWAndArgsInfo())
367 ReadTemplateKWAndArgsInfo(*E->getTemplateKWAndArgsInfo(),
368 NumTemplateArgs);
Argyrios Kyrtzidis663e3802010-07-08 13:09:47 +0000369
Douglas Gregor409448c2011-07-21 22:35:25 +0000370 E->setDecl(ReadDeclAs<ValueDecl>(Record, Idx));
Sebastian Redlc3632732010-10-05 15:59:54 +0000371 E->setLocation(ReadSourceLocation(Record, Idx));
Argyrios Kyrtzidis40451072010-10-15 18:21:24 +0000372 ReadDeclarationNameLoc(E->DNLoc, E->getDecl()->getDeclName(), Record, Idx);
Chris Lattner4c6f9522009-04-27 05:14:47 +0000373}
374
Sebastian Redl60adf4a2010-08-18 23:56:52 +0000375void ASTStmtReader::VisitIntegerLiteral(IntegerLiteral *E) {
Chris Lattner4c6f9522009-04-27 05:14:47 +0000376 VisitExpr(E);
Sebastian Redlc3632732010-10-05 15:59:54 +0000377 E->setLocation(ReadSourceLocation(Record, Idx));
Douglas Gregor35942772011-09-09 21:34:22 +0000378 E->setValue(Reader.getContext(), Reader.ReadAPInt(Record, Idx));
Chris Lattner4c6f9522009-04-27 05:14:47 +0000379}
380
Sebastian Redl60adf4a2010-08-18 23:56:52 +0000381void ASTStmtReader::VisitFloatingLiteral(FloatingLiteral *E) {
Chris Lattner4c6f9522009-04-27 05:14:47 +0000382 VisitExpr(E);
Douglas Gregor35942772011-09-09 21:34:22 +0000383 E->setValue(Reader.getContext(), Reader.ReadAPFloat(Record, Idx));
Chris Lattner4c6f9522009-04-27 05:14:47 +0000384 E->setExact(Record[Idx++]);
Sebastian Redlc3632732010-10-05 15:59:54 +0000385 E->setLocation(ReadSourceLocation(Record, Idx));
Chris Lattner4c6f9522009-04-27 05:14:47 +0000386}
387
Sebastian Redl60adf4a2010-08-18 23:56:52 +0000388void ASTStmtReader::VisitImaginaryLiteral(ImaginaryLiteral *E) {
Chris Lattner4c6f9522009-04-27 05:14:47 +0000389 VisitExpr(E);
Argyrios Kyrtzidisd98a2ab2010-06-29 22:46:25 +0000390 E->setSubExpr(Reader.ReadSubExpr());
Chris Lattner4c6f9522009-04-27 05:14:47 +0000391}
392
Sebastian Redl60adf4a2010-08-18 23:56:52 +0000393void ASTStmtReader::VisitStringLiteral(StringLiteral *E) {
Chris Lattner4c6f9522009-04-27 05:14:47 +0000394 VisitExpr(E);
395 unsigned Len = Record[Idx++];
Mike Stump1eb44332009-09-09 15:08:12 +0000396 assert(Record[Idx] == E->getNumConcatenated() &&
Chris Lattner4c6f9522009-04-27 05:14:47 +0000397 "Wrong number of concatenated tokens!");
398 ++Idx;
Eli Friedman64f45a22011-11-01 02:23:42 +0000399 StringLiteral::StringKind kind =
400 static_cast<StringLiteral::StringKind>(Record[Idx++]);
401 bool isPascal = Record[Idx++];
Chris Lattner4c6f9522009-04-27 05:14:47 +0000402
Mike Stump1eb44332009-09-09 15:08:12 +0000403 // Read string data
Dylan Noblesmithf7ccbad2012-02-05 02:13:05 +0000404 SmallString<16> Str(&Record[Idx], &Record[Idx] + Len);
Eli Friedman64f45a22011-11-01 02:23:42 +0000405 E->setString(Reader.getContext(), Str.str(), kind, isPascal);
Chris Lattner4c6f9522009-04-27 05:14:47 +0000406 Idx += Len;
407
408 // Read source locations
409 for (unsigned I = 0, N = E->getNumConcatenated(); I != N; ++I)
Sebastian Redlc3632732010-10-05 15:59:54 +0000410 E->setStrTokenLoc(I, ReadSourceLocation(Record, Idx));
Chris Lattner4c6f9522009-04-27 05:14:47 +0000411}
412
Sebastian Redl60adf4a2010-08-18 23:56:52 +0000413void ASTStmtReader::VisitCharacterLiteral(CharacterLiteral *E) {
Chris Lattner4c6f9522009-04-27 05:14:47 +0000414 VisitExpr(E);
415 E->setValue(Record[Idx++]);
Sebastian Redlc3632732010-10-05 15:59:54 +0000416 E->setLocation(ReadSourceLocation(Record, Idx));
Douglas Gregor5cee1192011-07-27 05:40:30 +0000417 E->setKind(static_cast<CharacterLiteral::CharacterKind>(Record[Idx++]));
Chris Lattner4c6f9522009-04-27 05:14:47 +0000418}
419
Sebastian Redl60adf4a2010-08-18 23:56:52 +0000420void ASTStmtReader::VisitParenExpr(ParenExpr *E) {
Chris Lattner4c6f9522009-04-27 05:14:47 +0000421 VisitExpr(E);
Sebastian Redlc3632732010-10-05 15:59:54 +0000422 E->setLParen(ReadSourceLocation(Record, Idx));
423 E->setRParen(ReadSourceLocation(Record, Idx));
Argyrios Kyrtzidisd98a2ab2010-06-29 22:46:25 +0000424 E->setSubExpr(Reader.ReadSubExpr());
Chris Lattner4c6f9522009-04-27 05:14:47 +0000425}
426
Sebastian Redl60adf4a2010-08-18 23:56:52 +0000427void ASTStmtReader::VisitParenListExpr(ParenListExpr *E) {
Argyrios Kyrtzidis37bdfe22010-06-30 08:49:18 +0000428 VisitExpr(E);
429 unsigned NumExprs = Record[Idx++];
Douglas Gregor35942772011-09-09 21:34:22 +0000430 E->Exprs = new (Reader.getContext()) Stmt*[NumExprs];
Argyrios Kyrtzidis37bdfe22010-06-30 08:49:18 +0000431 for (unsigned i = 0; i != NumExprs; ++i)
432 E->Exprs[i] = Reader.ReadSubStmt();
433 E->NumExprs = NumExprs;
Sebastian Redlc3632732010-10-05 15:59:54 +0000434 E->LParenLoc = ReadSourceLocation(Record, Idx);
435 E->RParenLoc = ReadSourceLocation(Record, Idx);
Argyrios Kyrtzidis37bdfe22010-06-30 08:49:18 +0000436}
437
Sebastian Redl60adf4a2010-08-18 23:56:52 +0000438void ASTStmtReader::VisitUnaryOperator(UnaryOperator *E) {
Chris Lattner4c6f9522009-04-27 05:14:47 +0000439 VisitExpr(E);
Argyrios Kyrtzidisd98a2ab2010-06-29 22:46:25 +0000440 E->setSubExpr(Reader.ReadSubExpr());
Chris Lattner4c6f9522009-04-27 05:14:47 +0000441 E->setOpcode((UnaryOperator::Opcode)Record[Idx++]);
Sebastian Redlc3632732010-10-05 15:59:54 +0000442 E->setOperatorLoc(ReadSourceLocation(Record, Idx));
Chris Lattner4c6f9522009-04-27 05:14:47 +0000443}
444
Sebastian Redl60adf4a2010-08-18 23:56:52 +0000445void ASTStmtReader::VisitOffsetOfExpr(OffsetOfExpr *E) {
Douglas Gregor8ecdb652010-04-28 22:16:22 +0000446 typedef OffsetOfExpr::OffsetOfNode Node;
447 VisitExpr(E);
448 assert(E->getNumComponents() == Record[Idx]);
449 ++Idx;
450 assert(E->getNumExpressions() == Record[Idx]);
451 ++Idx;
Sebastian Redlc3632732010-10-05 15:59:54 +0000452 E->setOperatorLoc(ReadSourceLocation(Record, Idx));
453 E->setRParenLoc(ReadSourceLocation(Record, Idx));
454 E->setTypeSourceInfo(GetTypeSourceInfo(Record, Idx));
Douglas Gregor8ecdb652010-04-28 22:16:22 +0000455 for (unsigned I = 0, N = E->getNumComponents(); I != N; ++I) {
456 Node::Kind Kind = static_cast<Node::Kind>(Record[Idx++]);
Sebastian Redlc3632732010-10-05 15:59:54 +0000457 SourceLocation Start = ReadSourceLocation(Record, Idx);
458 SourceLocation End = ReadSourceLocation(Record, Idx);
Douglas Gregor8ecdb652010-04-28 22:16:22 +0000459 switch (Kind) {
460 case Node::Array:
461 E->setComponent(I, Node(Start, Record[Idx++], End));
462 break;
463
464 case Node::Field:
Douglas Gregor409448c2011-07-21 22:35:25 +0000465 E->setComponent(I, Node(Start, ReadDeclAs<FieldDecl>(Record, Idx), End));
Douglas Gregor8ecdb652010-04-28 22:16:22 +0000466 break;
467
468 case Node::Identifier:
Douglas Gregor95eab172011-07-28 20:55:49 +0000469 E->setComponent(I,
470 Node(Start,
471 Reader.GetIdentifierInfo(F, Record, Idx),
472 End));
Douglas Gregor8ecdb652010-04-28 22:16:22 +0000473 break;
Douglas Gregorcc8a5d52010-04-29 00:18:15 +0000474
Argyrios Kyrtzidisafbf3122010-07-29 18:16:10 +0000475 case Node::Base: {
Douglas Gregor35942772011-09-09 21:34:22 +0000476 CXXBaseSpecifier *Base = new (Reader.getContext()) CXXBaseSpecifier();
Sebastian Redlc3632732010-10-05 15:59:54 +0000477 *Base = Reader.ReadCXXBaseSpecifier(F, Record, Idx);
Argyrios Kyrtzidisafbf3122010-07-29 18:16:10 +0000478 E->setComponent(I, Node(Base));
Douglas Gregorcc8a5d52010-04-29 00:18:15 +0000479 break;
Douglas Gregor8ecdb652010-04-28 22:16:22 +0000480 }
Argyrios Kyrtzidisafbf3122010-07-29 18:16:10 +0000481 }
Douglas Gregor8ecdb652010-04-28 22:16:22 +0000482 }
483
484 for (unsigned I = 0, N = E->getNumExpressions(); I != N; ++I)
Argyrios Kyrtzidisd98a2ab2010-06-29 22:46:25 +0000485 E->setIndexExpr(I, Reader.ReadSubExpr());
Douglas Gregor8ecdb652010-04-28 22:16:22 +0000486}
487
Peter Collingbournef4e3cfb2011-03-11 19:24:49 +0000488void ASTStmtReader::VisitUnaryExprOrTypeTraitExpr(UnaryExprOrTypeTraitExpr *E) {
Chris Lattner4c6f9522009-04-27 05:14:47 +0000489 VisitExpr(E);
Peter Collingbournef4e3cfb2011-03-11 19:24:49 +0000490 E->setKind(static_cast<UnaryExprOrTypeTrait>(Record[Idx++]));
Chris Lattner4c6f9522009-04-27 05:14:47 +0000491 if (Record[Idx] == 0) {
Argyrios Kyrtzidisd98a2ab2010-06-29 22:46:25 +0000492 E->setArgument(Reader.ReadSubExpr());
Chris Lattner4c6f9522009-04-27 05:14:47 +0000493 ++Idx;
494 } else {
Sebastian Redlc3632732010-10-05 15:59:54 +0000495 E->setArgument(GetTypeSourceInfo(Record, Idx));
Chris Lattner4c6f9522009-04-27 05:14:47 +0000496 }
Sebastian Redlc3632732010-10-05 15:59:54 +0000497 E->setOperatorLoc(ReadSourceLocation(Record, Idx));
498 E->setRParenLoc(ReadSourceLocation(Record, Idx));
Chris Lattner4c6f9522009-04-27 05:14:47 +0000499}
500
Sebastian Redl60adf4a2010-08-18 23:56:52 +0000501void ASTStmtReader::VisitArraySubscriptExpr(ArraySubscriptExpr *E) {
Chris Lattner4c6f9522009-04-27 05:14:47 +0000502 VisitExpr(E);
Argyrios Kyrtzidisd98a2ab2010-06-29 22:46:25 +0000503 E->setLHS(Reader.ReadSubExpr());
504 E->setRHS(Reader.ReadSubExpr());
Sebastian Redlc3632732010-10-05 15:59:54 +0000505 E->setRBracketLoc(ReadSourceLocation(Record, Idx));
Chris Lattner4c6f9522009-04-27 05:14:47 +0000506}
507
Sebastian Redl60adf4a2010-08-18 23:56:52 +0000508void ASTStmtReader::VisitCallExpr(CallExpr *E) {
Chris Lattner4c6f9522009-04-27 05:14:47 +0000509 VisitExpr(E);
Douglas Gregor35942772011-09-09 21:34:22 +0000510 E->setNumArgs(Reader.getContext(), Record[Idx++]);
Sebastian Redlc3632732010-10-05 15:59:54 +0000511 E->setRParenLoc(ReadSourceLocation(Record, Idx));
Argyrios Kyrtzidisd98a2ab2010-06-29 22:46:25 +0000512 E->setCallee(Reader.ReadSubExpr());
Chris Lattner4c6f9522009-04-27 05:14:47 +0000513 for (unsigned I = 0, N = E->getNumArgs(); I != N; ++I)
Argyrios Kyrtzidisd98a2ab2010-06-29 22:46:25 +0000514 E->setArg(I, Reader.ReadSubExpr());
Chris Lattner4c6f9522009-04-27 05:14:47 +0000515}
516
John McCall7110fd62011-07-15 07:00:14 +0000517void ASTStmtReader::VisitCXXMemberCallExpr(CXXMemberCallExpr *E) {
518 VisitCallExpr(E);
519}
520
Sebastian Redl60adf4a2010-08-18 23:56:52 +0000521void ASTStmtReader::VisitMemberExpr(MemberExpr *E) {
Argyrios Kyrtzidis663e3802010-07-08 13:09:47 +0000522 // Don't call VisitExpr, this is fully initialized at creation.
523 assert(E->getStmtClass() == Stmt::MemberExprClass &&
524 "It's a subclass, we must advance Idx!");
Chris Lattner4c6f9522009-04-27 05:14:47 +0000525}
526
Sebastian Redl60adf4a2010-08-18 23:56:52 +0000527void ASTStmtReader::VisitObjCIsaExpr(ObjCIsaExpr *E) {
Steve Narofff242b1b2009-07-24 17:54:45 +0000528 VisitExpr(E);
Argyrios Kyrtzidisd98a2ab2010-06-29 22:46:25 +0000529 E->setBase(Reader.ReadSubExpr());
Sebastian Redlc3632732010-10-05 15:59:54 +0000530 E->setIsaMemberLoc(ReadSourceLocation(Record, Idx));
Steve Narofff242b1b2009-07-24 17:54:45 +0000531 E->setArrow(Record[Idx++]);
Steve Narofff242b1b2009-07-24 17:54:45 +0000532}
533
John McCallf85e1932011-06-15 23:02:42 +0000534void ASTStmtReader::
535VisitObjCIndirectCopyRestoreExpr(ObjCIndirectCopyRestoreExpr *E) {
536 VisitExpr(E);
537 E->Operand = Reader.ReadSubExpr();
538 E->setShouldCopy(Record[Idx++]);
539}
540
541void ASTStmtReader::VisitObjCBridgedCastExpr(ObjCBridgedCastExpr *E) {
542 VisitExplicitCastExpr(E);
543 E->LParenLoc = ReadSourceLocation(Record, Idx);
544 E->BridgeKeywordLoc = ReadSourceLocation(Record, Idx);
545 E->Kind = Record[Idx++];
546}
547
Sebastian Redl60adf4a2010-08-18 23:56:52 +0000548void ASTStmtReader::VisitCastExpr(CastExpr *E) {
Chris Lattner4c6f9522009-04-27 05:14:47 +0000549 VisitExpr(E);
John McCallf871d0c2010-08-07 06:22:56 +0000550 unsigned NumBaseSpecs = Record[Idx++];
551 assert(NumBaseSpecs == E->path_size());
Argyrios Kyrtzidisd98a2ab2010-06-29 22:46:25 +0000552 E->setSubExpr(Reader.ReadSubExpr());
Anders Carlssoncdef2b72009-07-31 00:48:10 +0000553 E->setCastKind((CastExpr::CastKind)Record[Idx++]);
John McCallf871d0c2010-08-07 06:22:56 +0000554 CastExpr::path_iterator BaseI = E->path_begin();
Argyrios Kyrtzidis0745d0a2010-07-02 23:30:27 +0000555 while (NumBaseSpecs--) {
Douglas Gregor35942772011-09-09 21:34:22 +0000556 CXXBaseSpecifier *BaseSpec = new (Reader.getContext()) CXXBaseSpecifier;
Sebastian Redlc3632732010-10-05 15:59:54 +0000557 *BaseSpec = Reader.ReadCXXBaseSpecifier(F, Record, Idx);
John McCallf871d0c2010-08-07 06:22:56 +0000558 *BaseI++ = BaseSpec;
Argyrios Kyrtzidis0745d0a2010-07-02 23:30:27 +0000559 }
Chris Lattner4c6f9522009-04-27 05:14:47 +0000560}
561
Sebastian Redl60adf4a2010-08-18 23:56:52 +0000562void ASTStmtReader::VisitBinaryOperator(BinaryOperator *E) {
Chris Lattner4c6f9522009-04-27 05:14:47 +0000563 VisitExpr(E);
Argyrios Kyrtzidisd98a2ab2010-06-29 22:46:25 +0000564 E->setLHS(Reader.ReadSubExpr());
565 E->setRHS(Reader.ReadSubExpr());
Chris Lattner4c6f9522009-04-27 05:14:47 +0000566 E->setOpcode((BinaryOperator::Opcode)Record[Idx++]);
Sebastian Redlc3632732010-10-05 15:59:54 +0000567 E->setOperatorLoc(ReadSourceLocation(Record, Idx));
Chris Lattner4c6f9522009-04-27 05:14:47 +0000568}
569
Sebastian Redl60adf4a2010-08-18 23:56:52 +0000570void ASTStmtReader::VisitCompoundAssignOperator(CompoundAssignOperator *E) {
Chris Lattner4c6f9522009-04-27 05:14:47 +0000571 VisitBinaryOperator(E);
Douglas Gregor393f2492011-07-22 00:38:23 +0000572 E->setComputationLHSType(Reader.readType(F, Record, Idx));
573 E->setComputationResultType(Reader.readType(F, Record, Idx));
Chris Lattner4c6f9522009-04-27 05:14:47 +0000574}
575
Sebastian Redl60adf4a2010-08-18 23:56:52 +0000576void ASTStmtReader::VisitConditionalOperator(ConditionalOperator *E) {
Chris Lattner4c6f9522009-04-27 05:14:47 +0000577 VisitExpr(E);
John McCall56ca35d2011-02-17 10:25:35 +0000578 E->SubExprs[ConditionalOperator::COND] = Reader.ReadSubExpr();
579 E->SubExprs[ConditionalOperator::LHS] = Reader.ReadSubExpr();
580 E->SubExprs[ConditionalOperator::RHS] = Reader.ReadSubExpr();
581 E->QuestionLoc = ReadSourceLocation(Record, Idx);
582 E->ColonLoc = ReadSourceLocation(Record, Idx);
583}
584
585void
586ASTStmtReader::VisitBinaryConditionalOperator(BinaryConditionalOperator *E) {
587 VisitExpr(E);
588 E->OpaqueValue = cast<OpaqueValueExpr>(Reader.ReadSubExpr());
589 E->SubExprs[BinaryConditionalOperator::COMMON] = Reader.ReadSubExpr();
590 E->SubExprs[BinaryConditionalOperator::COND] = Reader.ReadSubExpr();
591 E->SubExprs[BinaryConditionalOperator::LHS] = Reader.ReadSubExpr();
592 E->SubExprs[BinaryConditionalOperator::RHS] = Reader.ReadSubExpr();
593 E->QuestionLoc = ReadSourceLocation(Record, Idx);
594 E->ColonLoc = ReadSourceLocation(Record, Idx);
Chris Lattner4c6f9522009-04-27 05:14:47 +0000595}
596
Sebastian Redl60adf4a2010-08-18 23:56:52 +0000597void ASTStmtReader::VisitImplicitCastExpr(ImplicitCastExpr *E) {
Chris Lattner4c6f9522009-04-27 05:14:47 +0000598 VisitCastExpr(E);
Chris Lattner4c6f9522009-04-27 05:14:47 +0000599}
600
Sebastian Redl60adf4a2010-08-18 23:56:52 +0000601void ASTStmtReader::VisitExplicitCastExpr(ExplicitCastExpr *E) {
Chris Lattner4c6f9522009-04-27 05:14:47 +0000602 VisitCastExpr(E);
Sebastian Redlc3632732010-10-05 15:59:54 +0000603 E->setTypeInfoAsWritten(GetTypeSourceInfo(Record, Idx));
Chris Lattner4c6f9522009-04-27 05:14:47 +0000604}
605
Sebastian Redl60adf4a2010-08-18 23:56:52 +0000606void ASTStmtReader::VisitCStyleCastExpr(CStyleCastExpr *E) {
Chris Lattner4c6f9522009-04-27 05:14:47 +0000607 VisitExplicitCastExpr(E);
Sebastian Redlc3632732010-10-05 15:59:54 +0000608 E->setLParenLoc(ReadSourceLocation(Record, Idx));
609 E->setRParenLoc(ReadSourceLocation(Record, Idx));
Chris Lattner4c6f9522009-04-27 05:14:47 +0000610}
611
Sebastian Redl60adf4a2010-08-18 23:56:52 +0000612void ASTStmtReader::VisitCompoundLiteralExpr(CompoundLiteralExpr *E) {
Chris Lattner4c6f9522009-04-27 05:14:47 +0000613 VisitExpr(E);
Sebastian Redlc3632732010-10-05 15:59:54 +0000614 E->setLParenLoc(ReadSourceLocation(Record, Idx));
615 E->setTypeSourceInfo(GetTypeSourceInfo(Record, Idx));
Argyrios Kyrtzidisd98a2ab2010-06-29 22:46:25 +0000616 E->setInitializer(Reader.ReadSubExpr());
Chris Lattner4c6f9522009-04-27 05:14:47 +0000617 E->setFileScope(Record[Idx++]);
Chris Lattner4c6f9522009-04-27 05:14:47 +0000618}
619
Sebastian Redl60adf4a2010-08-18 23:56:52 +0000620void ASTStmtReader::VisitExtVectorElementExpr(ExtVectorElementExpr *E) {
Chris Lattner4c6f9522009-04-27 05:14:47 +0000621 VisitExpr(E);
Argyrios Kyrtzidisd98a2ab2010-06-29 22:46:25 +0000622 E->setBase(Reader.ReadSubExpr());
Douglas Gregor95eab172011-07-28 20:55:49 +0000623 E->setAccessor(Reader.GetIdentifierInfo(F, Record, Idx));
Sebastian Redlc3632732010-10-05 15:59:54 +0000624 E->setAccessorLoc(ReadSourceLocation(Record, Idx));
Chris Lattner4c6f9522009-04-27 05:14:47 +0000625}
626
Sebastian Redl60adf4a2010-08-18 23:56:52 +0000627void ASTStmtReader::VisitInitListExpr(InitListExpr *E) {
Chris Lattner4c6f9522009-04-27 05:14:47 +0000628 VisitExpr(E);
Argyrios Kyrtzidisd98a2ab2010-06-29 22:46:25 +0000629 E->setSyntacticForm(cast_or_null<InitListExpr>(Reader.ReadSubStmt()));
Sebastian Redlc3632732010-10-05 15:59:54 +0000630 E->setLBraceLoc(ReadSourceLocation(Record, Idx));
631 E->setRBraceLoc(ReadSourceLocation(Record, Idx));
Argyrios Kyrtzidis2ac0b7a2011-04-22 05:29:30 +0000632 bool isArrayFiller = Record[Idx++];
633 Expr *filler = 0;
634 if (isArrayFiller) {
635 filler = Reader.ReadSubExpr();
636 E->ArrayFillerOrUnionFieldInit = filler;
637 } else
Douglas Gregor409448c2011-07-21 22:35:25 +0000638 E->ArrayFillerOrUnionFieldInit = ReadDeclAs<FieldDecl>(Record, Idx);
Chris Lattner4c6f9522009-04-27 05:14:47 +0000639 E->sawArrayRangeDesignator(Record[Idx++]);
Benjamin Kramer1b1a5072012-02-27 13:20:39 +0000640 E->setInitializesStdInitializerList(Record[Idx++]);
Argyrios Kyrtzidis2ac0b7a2011-04-22 05:29:30 +0000641 unsigned NumInits = Record[Idx++];
Douglas Gregor35942772011-09-09 21:34:22 +0000642 E->reserveInits(Reader.getContext(), NumInits);
Argyrios Kyrtzidis2ac0b7a2011-04-22 05:29:30 +0000643 if (isArrayFiller) {
644 for (unsigned I = 0; I != NumInits; ++I) {
645 Expr *init = Reader.ReadSubExpr();
Douglas Gregor35942772011-09-09 21:34:22 +0000646 E->updateInit(Reader.getContext(), I, init ? init : filler);
Argyrios Kyrtzidis2ac0b7a2011-04-22 05:29:30 +0000647 }
648 } else {
649 for (unsigned I = 0; I != NumInits; ++I)
Douglas Gregor35942772011-09-09 21:34:22 +0000650 E->updateInit(Reader.getContext(), I, Reader.ReadSubExpr());
Argyrios Kyrtzidis2ac0b7a2011-04-22 05:29:30 +0000651 }
Chris Lattner4c6f9522009-04-27 05:14:47 +0000652}
653
Sebastian Redl60adf4a2010-08-18 23:56:52 +0000654void ASTStmtReader::VisitDesignatedInitExpr(DesignatedInitExpr *E) {
Chris Lattner4c6f9522009-04-27 05:14:47 +0000655 typedef DesignatedInitExpr::Designator Designator;
656
657 VisitExpr(E);
658 unsigned NumSubExprs = Record[Idx++];
659 assert(NumSubExprs == E->getNumSubExprs() && "Wrong number of subexprs");
660 for (unsigned I = 0; I != NumSubExprs; ++I)
Argyrios Kyrtzidisd98a2ab2010-06-29 22:46:25 +0000661 E->setSubExpr(I, Reader.ReadSubExpr());
Sebastian Redlc3632732010-10-05 15:59:54 +0000662 E->setEqualOrColonLoc(ReadSourceLocation(Record, Idx));
Chris Lattner4c6f9522009-04-27 05:14:47 +0000663 E->setGNUSyntax(Record[Idx++]);
664
Chris Lattner5f9e2722011-07-23 10:55:15 +0000665 SmallVector<Designator, 4> Designators;
Chris Lattner4c6f9522009-04-27 05:14:47 +0000666 while (Idx < Record.size()) {
Sebastian Redl8538e8d2010-08-18 23:57:32 +0000667 switch ((DesignatorTypes)Record[Idx++]) {
668 case DESIG_FIELD_DECL: {
Douglas Gregor409448c2011-07-21 22:35:25 +0000669 FieldDecl *Field = ReadDeclAs<FieldDecl>(Record, Idx);
Mike Stump1eb44332009-09-09 15:08:12 +0000670 SourceLocation DotLoc
Sebastian Redlc3632732010-10-05 15:59:54 +0000671 = ReadSourceLocation(Record, Idx);
Mike Stump1eb44332009-09-09 15:08:12 +0000672 SourceLocation FieldLoc
Sebastian Redlc3632732010-10-05 15:59:54 +0000673 = ReadSourceLocation(Record, Idx);
Mike Stump1eb44332009-09-09 15:08:12 +0000674 Designators.push_back(Designator(Field->getIdentifier(), DotLoc,
Chris Lattner4c6f9522009-04-27 05:14:47 +0000675 FieldLoc));
676 Designators.back().setField(Field);
677 break;
678 }
679
Sebastian Redl8538e8d2010-08-18 23:57:32 +0000680 case DESIG_FIELD_NAME: {
Douglas Gregor95eab172011-07-28 20:55:49 +0000681 const IdentifierInfo *Name = Reader.GetIdentifierInfo(F, Record, Idx);
Mike Stump1eb44332009-09-09 15:08:12 +0000682 SourceLocation DotLoc
Sebastian Redlc3632732010-10-05 15:59:54 +0000683 = ReadSourceLocation(Record, Idx);
Mike Stump1eb44332009-09-09 15:08:12 +0000684 SourceLocation FieldLoc
Sebastian Redlc3632732010-10-05 15:59:54 +0000685 = ReadSourceLocation(Record, Idx);
Chris Lattner4c6f9522009-04-27 05:14:47 +0000686 Designators.push_back(Designator(Name, DotLoc, FieldLoc));
687 break;
688 }
Mike Stump1eb44332009-09-09 15:08:12 +0000689
Sebastian Redl8538e8d2010-08-18 23:57:32 +0000690 case DESIG_ARRAY: {
Chris Lattner4c6f9522009-04-27 05:14:47 +0000691 unsigned Index = Record[Idx++];
692 SourceLocation LBracketLoc
Sebastian Redlc3632732010-10-05 15:59:54 +0000693 = ReadSourceLocation(Record, Idx);
Chris Lattner4c6f9522009-04-27 05:14:47 +0000694 SourceLocation RBracketLoc
Sebastian Redlc3632732010-10-05 15:59:54 +0000695 = ReadSourceLocation(Record, Idx);
Chris Lattner4c6f9522009-04-27 05:14:47 +0000696 Designators.push_back(Designator(Index, LBracketLoc, RBracketLoc));
697 break;
698 }
699
Sebastian Redl8538e8d2010-08-18 23:57:32 +0000700 case DESIG_ARRAY_RANGE: {
Chris Lattner4c6f9522009-04-27 05:14:47 +0000701 unsigned Index = Record[Idx++];
702 SourceLocation LBracketLoc
Sebastian Redlc3632732010-10-05 15:59:54 +0000703 = ReadSourceLocation(Record, Idx);
Chris Lattner4c6f9522009-04-27 05:14:47 +0000704 SourceLocation EllipsisLoc
Sebastian Redlc3632732010-10-05 15:59:54 +0000705 = ReadSourceLocation(Record, Idx);
Chris Lattner4c6f9522009-04-27 05:14:47 +0000706 SourceLocation RBracketLoc
Sebastian Redlc3632732010-10-05 15:59:54 +0000707 = ReadSourceLocation(Record, Idx);
Chris Lattner4c6f9522009-04-27 05:14:47 +0000708 Designators.push_back(Designator(Index, LBracketLoc, EllipsisLoc,
709 RBracketLoc));
710 break;
711 }
712 }
713 }
Douglas Gregor35942772011-09-09 21:34:22 +0000714 E->setDesignators(Reader.getContext(),
Douglas Gregor319d57f2010-01-06 23:17:19 +0000715 Designators.data(), Designators.size());
Chris Lattner4c6f9522009-04-27 05:14:47 +0000716}
717
Sebastian Redl60adf4a2010-08-18 23:56:52 +0000718void ASTStmtReader::VisitImplicitValueInitExpr(ImplicitValueInitExpr *E) {
Chris Lattner4c6f9522009-04-27 05:14:47 +0000719 VisitExpr(E);
Chris Lattner4c6f9522009-04-27 05:14:47 +0000720}
721
Sebastian Redl60adf4a2010-08-18 23:56:52 +0000722void ASTStmtReader::VisitVAArgExpr(VAArgExpr *E) {
Chris Lattner4c6f9522009-04-27 05:14:47 +0000723 VisitExpr(E);
Argyrios Kyrtzidisd98a2ab2010-06-29 22:46:25 +0000724 E->setSubExpr(Reader.ReadSubExpr());
Sebastian Redlc3632732010-10-05 15:59:54 +0000725 E->setWrittenTypeInfo(GetTypeSourceInfo(Record, Idx));
726 E->setBuiltinLoc(ReadSourceLocation(Record, Idx));
727 E->setRParenLoc(ReadSourceLocation(Record, Idx));
Chris Lattner4c6f9522009-04-27 05:14:47 +0000728}
729
Sebastian Redl60adf4a2010-08-18 23:56:52 +0000730void ASTStmtReader::VisitAddrLabelExpr(AddrLabelExpr *E) {
Chris Lattner4c6f9522009-04-27 05:14:47 +0000731 VisitExpr(E);
Sebastian Redlc3632732010-10-05 15:59:54 +0000732 E->setAmpAmpLoc(ReadSourceLocation(Record, Idx));
733 E->setLabelLoc(ReadSourceLocation(Record, Idx));
Douglas Gregor409448c2011-07-21 22:35:25 +0000734 E->setLabel(ReadDeclAs<LabelDecl>(Record, Idx));
Chris Lattner4c6f9522009-04-27 05:14:47 +0000735}
736
Sebastian Redl60adf4a2010-08-18 23:56:52 +0000737void ASTStmtReader::VisitStmtExpr(StmtExpr *E) {
Chris Lattner4c6f9522009-04-27 05:14:47 +0000738 VisitExpr(E);
Sebastian Redlc3632732010-10-05 15:59:54 +0000739 E->setLParenLoc(ReadSourceLocation(Record, Idx));
740 E->setRParenLoc(ReadSourceLocation(Record, Idx));
Argyrios Kyrtzidisd98a2ab2010-06-29 22:46:25 +0000741 E->setSubStmt(cast_or_null<CompoundStmt>(Reader.ReadSubStmt()));
Chris Lattner4c6f9522009-04-27 05:14:47 +0000742}
743
Sebastian Redl60adf4a2010-08-18 23:56:52 +0000744void ASTStmtReader::VisitChooseExpr(ChooseExpr *E) {
Chris Lattner4c6f9522009-04-27 05:14:47 +0000745 VisitExpr(E);
Argyrios Kyrtzidisd98a2ab2010-06-29 22:46:25 +0000746 E->setCond(Reader.ReadSubExpr());
747 E->setLHS(Reader.ReadSubExpr());
748 E->setRHS(Reader.ReadSubExpr());
Sebastian Redlc3632732010-10-05 15:59:54 +0000749 E->setBuiltinLoc(ReadSourceLocation(Record, Idx));
750 E->setRParenLoc(ReadSourceLocation(Record, Idx));
Chris Lattner4c6f9522009-04-27 05:14:47 +0000751}
752
Sebastian Redl60adf4a2010-08-18 23:56:52 +0000753void ASTStmtReader::VisitGNUNullExpr(GNUNullExpr *E) {
Chris Lattner4c6f9522009-04-27 05:14:47 +0000754 VisitExpr(E);
Sebastian Redlc3632732010-10-05 15:59:54 +0000755 E->setTokenLocation(ReadSourceLocation(Record, Idx));
Chris Lattner4c6f9522009-04-27 05:14:47 +0000756}
757
Sebastian Redl60adf4a2010-08-18 23:56:52 +0000758void ASTStmtReader::VisitShuffleVectorExpr(ShuffleVectorExpr *E) {
Chris Lattner4c6f9522009-04-27 05:14:47 +0000759 VisitExpr(E);
Chris Lattner5f9e2722011-07-23 10:55:15 +0000760 SmallVector<Expr *, 16> Exprs;
Chris Lattner4c6f9522009-04-27 05:14:47 +0000761 unsigned NumExprs = Record[Idx++];
Argyrios Kyrtzidis919e6932010-06-28 22:28:35 +0000762 while (NumExprs--)
Argyrios Kyrtzidisd98a2ab2010-06-29 22:46:25 +0000763 Exprs.push_back(Reader.ReadSubExpr());
Douglas Gregor35942772011-09-09 21:34:22 +0000764 E->setExprs(Reader.getContext(), Exprs.data(), Exprs.size());
Sebastian Redlc3632732010-10-05 15:59:54 +0000765 E->setBuiltinLoc(ReadSourceLocation(Record, Idx));
766 E->setRParenLoc(ReadSourceLocation(Record, Idx));
Chris Lattner4c6f9522009-04-27 05:14:47 +0000767}
768
Sebastian Redl60adf4a2010-08-18 23:56:52 +0000769void ASTStmtReader::VisitBlockExpr(BlockExpr *E) {
Chris Lattner4c6f9522009-04-27 05:14:47 +0000770 VisitExpr(E);
Douglas Gregor409448c2011-07-21 22:35:25 +0000771 E->setBlockDecl(ReadDeclAs<BlockDecl>(Record, Idx));
Chris Lattner4c6f9522009-04-27 05:14:47 +0000772}
773
Peter Collingbournef111d932011-04-15 00:35:48 +0000774void ASTStmtReader::VisitGenericSelectionExpr(GenericSelectionExpr *E) {
775 VisitExpr(E);
776 E->NumAssocs = Record[Idx++];
Douglas Gregor35942772011-09-09 21:34:22 +0000777 E->AssocTypes = new (Reader.getContext()) TypeSourceInfo*[E->NumAssocs];
Peter Collingbournef111d932011-04-15 00:35:48 +0000778 E->SubExprs =
Douglas Gregor35942772011-09-09 21:34:22 +0000779 new(Reader.getContext()) Stmt*[GenericSelectionExpr::END_EXPR+E->NumAssocs];
Peter Collingbournef111d932011-04-15 00:35:48 +0000780
781 E->SubExprs[GenericSelectionExpr::CONTROLLING] = Reader.ReadSubExpr();
782 for (unsigned I = 0, N = E->getNumAssocs(); I != N; ++I) {
783 E->AssocTypes[I] = GetTypeSourceInfo(Record, Idx);
784 E->SubExprs[GenericSelectionExpr::END_EXPR+I] = Reader.ReadSubExpr();
785 }
786 E->ResultIndex = Record[Idx++];
787
788 E->GenericLoc = ReadSourceLocation(Record, Idx);
789 E->DefaultLoc = ReadSourceLocation(Record, Idx);
790 E->RParenLoc = ReadSourceLocation(Record, Idx);
791}
792
John McCall4b9c2d22011-11-06 09:01:30 +0000793void ASTStmtReader::VisitPseudoObjectExpr(PseudoObjectExpr *E) {
794 VisitExpr(E);
795 unsigned numSemanticExprs = Record[Idx++];
796 assert(numSemanticExprs + 1 == E->PseudoObjectExprBits.NumSubExprs);
797 E->PseudoObjectExprBits.ResultIndex = Record[Idx++];
798
799 // Read the syntactic expression.
800 E->getSubExprsBuffer()[0] = Reader.ReadSubExpr();
801
802 // Read all the semantic expressions.
803 for (unsigned i = 0; i != numSemanticExprs; ++i) {
804 Expr *subExpr = Reader.ReadSubExpr();
John McCall4b9c2d22011-11-06 09:01:30 +0000805 E->getSubExprsBuffer()[i+1] = subExpr;
806 }
807}
808
Eli Friedman276b0612011-10-11 02:20:01 +0000809void ASTStmtReader::VisitAtomicExpr(AtomicExpr *E) {
810 VisitExpr(E);
Richard Smithe1b2abc2012-04-10 22:49:28 +0000811 E->Op = AtomicExpr::AtomicOp(Record[Idx++]);
812 E->NumSubExprs = AtomicExpr::getNumSubExprs(E->Op);
813 for (unsigned I = 0; I != E->NumSubExprs; ++I)
814 E->SubExprs[I] = Reader.ReadSubExpr();
815 E->BuiltinLoc = ReadSourceLocation(Record, Idx);
816 E->RParenLoc = ReadSourceLocation(Record, Idx);
Eli Friedman276b0612011-10-11 02:20:01 +0000817}
818
Chris Lattner4c6f9522009-04-27 05:14:47 +0000819//===----------------------------------------------------------------------===//
820// Objective-C Expressions and Statements
821
Sebastian Redl60adf4a2010-08-18 23:56:52 +0000822void ASTStmtReader::VisitObjCStringLiteral(ObjCStringLiteral *E) {
Chris Lattner4c6f9522009-04-27 05:14:47 +0000823 VisitExpr(E);
Argyrios Kyrtzidisd98a2ab2010-06-29 22:46:25 +0000824 E->setString(cast<StringLiteral>(Reader.ReadSubStmt()));
Sebastian Redlc3632732010-10-05 15:59:54 +0000825 E->setAtLoc(ReadSourceLocation(Record, Idx));
Chris Lattner4c6f9522009-04-27 05:14:47 +0000826}
827
Patrick Beardeb382ec2012-04-19 00:25:12 +0000828void ASTStmtReader::VisitObjCBoxedExpr(ObjCBoxedExpr *E) {
Ted Kremenekebcb57a2012-03-06 20:05:56 +0000829 VisitExpr(E);
830 // could be one of several IntegerLiteral, FloatLiteral, etc.
Patrick Beardeb382ec2012-04-19 00:25:12 +0000831 E->SubExpr = Reader.ReadSubStmt();
832 E->BoxingMethod = ReadDeclAs<ObjCMethodDecl>(Record, Idx);
833 E->Range = ReadSourceRange(Record, Idx);
Ted Kremenekebcb57a2012-03-06 20:05:56 +0000834}
835
836void ASTStmtReader::VisitObjCArrayLiteral(ObjCArrayLiteral *E) {
837 VisitExpr(E);
838 unsigned NumElements = Record[Idx++];
839 assert(NumElements == E->getNumElements() && "Wrong number of elements");
840 Expr **Elements = E->getElements();
841 for (unsigned I = 0, N = NumElements; I != N; ++I)
842 Elements[I] = Reader.ReadSubExpr();
843 E->ArrayWithObjectsMethod = ReadDeclAs<ObjCMethodDecl>(Record, Idx);
844 E->Range = ReadSourceRange(Record, Idx);
845}
846
847void ASTStmtReader::VisitObjCDictionaryLiteral(ObjCDictionaryLiteral *E) {
848 VisitExpr(E);
849 unsigned NumElements = Record[Idx++];
850 assert(NumElements == E->getNumElements() && "Wrong number of elements");
851 bool HasPackExpansions = Record[Idx++];
852 assert(HasPackExpansions == E->HasPackExpansions &&"Pack expansion mismatch");
853 ObjCDictionaryLiteral::KeyValuePair *KeyValues = E->getKeyValues();
854 ObjCDictionaryLiteral::ExpansionData *Expansions = E->getExpansionData();
855 for (unsigned I = 0; I != NumElements; ++I) {
856 KeyValues[I].Key = Reader.ReadSubExpr();
857 KeyValues[I].Value = Reader.ReadSubExpr();
858 if (HasPackExpansions) {
859 Expansions[I].EllipsisLoc = ReadSourceLocation(Record, Idx);
860 Expansions[I].NumExpansionsPlusOne = Record[Idx++];
861 }
862 }
863 E->DictWithObjectsMethod = ReadDeclAs<ObjCMethodDecl>(Record, Idx);
864 E->Range = ReadSourceRange(Record, Idx);
865}
866
Sebastian Redl60adf4a2010-08-18 23:56:52 +0000867void ASTStmtReader::VisitObjCEncodeExpr(ObjCEncodeExpr *E) {
Chris Lattner4c6f9522009-04-27 05:14:47 +0000868 VisitExpr(E);
Sebastian Redlc3632732010-10-05 15:59:54 +0000869 E->setEncodedTypeSourceInfo(GetTypeSourceInfo(Record, Idx));
870 E->setAtLoc(ReadSourceLocation(Record, Idx));
871 E->setRParenLoc(ReadSourceLocation(Record, Idx));
Chris Lattner4c6f9522009-04-27 05:14:47 +0000872}
873
Sebastian Redl60adf4a2010-08-18 23:56:52 +0000874void ASTStmtReader::VisitObjCSelectorExpr(ObjCSelectorExpr *E) {
Chris Lattner4c6f9522009-04-27 05:14:47 +0000875 VisitExpr(E);
Douglas Gregor2d2689a2011-07-28 21:16:51 +0000876 E->setSelector(Reader.ReadSelector(F, Record, Idx));
Sebastian Redlc3632732010-10-05 15:59:54 +0000877 E->setAtLoc(ReadSourceLocation(Record, Idx));
878 E->setRParenLoc(ReadSourceLocation(Record, Idx));
Chris Lattner4c6f9522009-04-27 05:14:47 +0000879}
880
Sebastian Redl60adf4a2010-08-18 23:56:52 +0000881void ASTStmtReader::VisitObjCProtocolExpr(ObjCProtocolExpr *E) {
Chris Lattner4c6f9522009-04-27 05:14:47 +0000882 VisitExpr(E);
Douglas Gregor409448c2011-07-21 22:35:25 +0000883 E->setProtocol(ReadDeclAs<ObjCProtocolDecl>(Record, Idx));
Sebastian Redlc3632732010-10-05 15:59:54 +0000884 E->setAtLoc(ReadSourceLocation(Record, Idx));
Argyrios Kyrtzidis7d24e282012-05-16 00:50:02 +0000885 E->ProtoLoc = ReadSourceLocation(Record, Idx);
Sebastian Redlc3632732010-10-05 15:59:54 +0000886 E->setRParenLoc(ReadSourceLocation(Record, Idx));
Chris Lattner4c6f9522009-04-27 05:14:47 +0000887}
888
Sebastian Redl60adf4a2010-08-18 23:56:52 +0000889void ASTStmtReader::VisitObjCIvarRefExpr(ObjCIvarRefExpr *E) {
Chris Lattner4c6f9522009-04-27 05:14:47 +0000890 VisitExpr(E);
Douglas Gregor409448c2011-07-21 22:35:25 +0000891 E->setDecl(ReadDeclAs<ObjCIvarDecl>(Record, Idx));
Sebastian Redlc3632732010-10-05 15:59:54 +0000892 E->setLocation(ReadSourceLocation(Record, Idx));
Argyrios Kyrtzidisd98a2ab2010-06-29 22:46:25 +0000893 E->setBase(Reader.ReadSubExpr());
Chris Lattner4c6f9522009-04-27 05:14:47 +0000894 E->setIsArrow(Record[Idx++]);
895 E->setIsFreeIvar(Record[Idx++]);
Chris Lattner4c6f9522009-04-27 05:14:47 +0000896}
897
Sebastian Redl60adf4a2010-08-18 23:56:52 +0000898void ASTStmtReader::VisitObjCPropertyRefExpr(ObjCPropertyRefExpr *E) {
Chris Lattner4c6f9522009-04-27 05:14:47 +0000899 VisitExpr(E);
Argyrios Kyrtzidisb085d892012-03-30 00:19:18 +0000900 unsigned MethodRefFlags = Record[Idx++];
John McCall12f78a62010-12-02 01:19:52 +0000901 bool Implicit = Record[Idx++] != 0;
902 if (Implicit) {
Douglas Gregor409448c2011-07-21 22:35:25 +0000903 ObjCMethodDecl *Getter = ReadDeclAs<ObjCMethodDecl>(Record, Idx);
904 ObjCMethodDecl *Setter = ReadDeclAs<ObjCMethodDecl>(Record, Idx);
Argyrios Kyrtzidisb085d892012-03-30 00:19:18 +0000905 E->setImplicitProperty(Getter, Setter, MethodRefFlags);
John McCall12f78a62010-12-02 01:19:52 +0000906 } else {
Argyrios Kyrtzidisb085d892012-03-30 00:19:18 +0000907 E->setExplicitProperty(ReadDeclAs<ObjCPropertyDecl>(Record, Idx),
908 MethodRefFlags);
Fariborz Jahanian8ac2d442010-10-14 16:04:05 +0000909 }
Sebastian Redlc3632732010-10-05 15:59:54 +0000910 E->setLocation(ReadSourceLocation(Record, Idx));
John McCall12f78a62010-12-02 01:19:52 +0000911 E->setReceiverLocation(ReadSourceLocation(Record, Idx));
912 switch (Record[Idx++]) {
913 case 0:
914 E->setBase(Reader.ReadSubExpr());
915 break;
916 case 1:
Douglas Gregor393f2492011-07-22 00:38:23 +0000917 E->setSuperReceiver(Reader.readType(F, Record, Idx));
John McCall12f78a62010-12-02 01:19:52 +0000918 break;
919 case 2:
Douglas Gregor409448c2011-07-21 22:35:25 +0000920 E->setClassReceiver(ReadDeclAs<ObjCInterfaceDecl>(Record, Idx));
John McCall12f78a62010-12-02 01:19:52 +0000921 break;
922 }
Chris Lattner4c6f9522009-04-27 05:14:47 +0000923}
924
Ted Kremenekebcb57a2012-03-06 20:05:56 +0000925void ASTStmtReader::VisitObjCSubscriptRefExpr(ObjCSubscriptRefExpr *E) {
926 VisitExpr(E);
927 E->setRBracket(ReadSourceLocation(Record, Idx));
928 E->setBaseExpr(Reader.ReadSubExpr());
929 E->setKeyExpr(Reader.ReadSubExpr());
930 E->GetAtIndexMethodDecl = ReadDeclAs<ObjCMethodDecl>(Record, Idx);
931 E->SetAtIndexMethodDecl = ReadDeclAs<ObjCMethodDecl>(Record, Idx);
932}
933
Sebastian Redl60adf4a2010-08-18 23:56:52 +0000934void ASTStmtReader::VisitObjCMessageExpr(ObjCMessageExpr *E) {
Chris Lattner4c6f9522009-04-27 05:14:47 +0000935 VisitExpr(E);
Douglas Gregor04badcf2010-04-21 00:45:42 +0000936 assert(Record[Idx] == E->getNumArgs());
937 ++Idx;
Argyrios Kyrtzidis20718082011-10-03 06:36:51 +0000938 unsigned NumStoredSelLocs = Record[Idx++];
939 E->SelLocsKind = Record[Idx++];
John McCallf85e1932011-06-15 23:02:42 +0000940 E->setDelegateInitCall(Record[Idx++]);
Argyrios Kyrtzidis746f5bc2012-01-12 02:34:39 +0000941 E->IsImplicit = Record[Idx++];
Douglas Gregor04badcf2010-04-21 00:45:42 +0000942 ObjCMessageExpr::ReceiverKind Kind
943 = static_cast<ObjCMessageExpr::ReceiverKind>(Record[Idx++]);
944 switch (Kind) {
945 case ObjCMessageExpr::Instance:
Argyrios Kyrtzidisd98a2ab2010-06-29 22:46:25 +0000946 E->setInstanceReceiver(Reader.ReadSubExpr());
Douglas Gregor04badcf2010-04-21 00:45:42 +0000947 break;
948
949 case ObjCMessageExpr::Class:
Sebastian Redlc3632732010-10-05 15:59:54 +0000950 E->setClassReceiver(GetTypeSourceInfo(Record, Idx));
Douglas Gregor04badcf2010-04-21 00:45:42 +0000951 break;
952
953 case ObjCMessageExpr::SuperClass:
954 case ObjCMessageExpr::SuperInstance: {
Douglas Gregor393f2492011-07-22 00:38:23 +0000955 QualType T = Reader.readType(F, Record, Idx);
Sebastian Redlc3632732010-10-05 15:59:54 +0000956 SourceLocation SuperLoc = ReadSourceLocation(Record, Idx);
Douglas Gregor04badcf2010-04-21 00:45:42 +0000957 E->setSuper(SuperLoc, T, Kind == ObjCMessageExpr::SuperInstance);
958 break;
959 }
960 }
961
962 assert(Kind == E->getReceiverKind());
963
964 if (Record[Idx++])
Douglas Gregor409448c2011-07-21 22:35:25 +0000965 E->setMethodDecl(ReadDeclAs<ObjCMethodDecl>(Record, Idx));
Douglas Gregor04badcf2010-04-21 00:45:42 +0000966 else
Douglas Gregor2d2689a2011-07-28 21:16:51 +0000967 E->setSelector(Reader.ReadSelector(F, Record, Idx));
Douglas Gregor04badcf2010-04-21 00:45:42 +0000968
Argyrios Kyrtzidisf40f0d52010-12-10 20:08:27 +0000969 E->LBracLoc = ReadSourceLocation(Record, Idx);
970 E->RBracLoc = ReadSourceLocation(Record, Idx);
Chris Lattner4c6f9522009-04-27 05:14:47 +0000971
972 for (unsigned I = 0, N = E->getNumArgs(); I != N; ++I)
Argyrios Kyrtzidisd98a2ab2010-06-29 22:46:25 +0000973 E->setArg(I, Reader.ReadSubExpr());
Argyrios Kyrtzidis20718082011-10-03 06:36:51 +0000974
975 SourceLocation *Locs = E->getStoredSelLocs();
976 for (unsigned I = 0; I != NumStoredSelLocs; ++I)
977 Locs[I] = ReadSourceLocation(Record, Idx);
Chris Lattner4c6f9522009-04-27 05:14:47 +0000978}
979
Sebastian Redl60adf4a2010-08-18 23:56:52 +0000980void ASTStmtReader::VisitObjCForCollectionStmt(ObjCForCollectionStmt *S) {
Chris Lattner4c6f9522009-04-27 05:14:47 +0000981 VisitStmt(S);
Argyrios Kyrtzidisd98a2ab2010-06-29 22:46:25 +0000982 S->setElement(Reader.ReadSubStmt());
983 S->setCollection(Reader.ReadSubExpr());
984 S->setBody(Reader.ReadSubStmt());
Sebastian Redlc3632732010-10-05 15:59:54 +0000985 S->setForLoc(ReadSourceLocation(Record, Idx));
986 S->setRParenLoc(ReadSourceLocation(Record, Idx));
Chris Lattner4c6f9522009-04-27 05:14:47 +0000987}
988
Sebastian Redl60adf4a2010-08-18 23:56:52 +0000989void ASTStmtReader::VisitObjCAtCatchStmt(ObjCAtCatchStmt *S) {
Chris Lattner4c6f9522009-04-27 05:14:47 +0000990 VisitStmt(S);
Argyrios Kyrtzidisd98a2ab2010-06-29 22:46:25 +0000991 S->setCatchBody(Reader.ReadSubStmt());
Douglas Gregor409448c2011-07-21 22:35:25 +0000992 S->setCatchParamDecl(ReadDeclAs<VarDecl>(Record, Idx));
Sebastian Redlc3632732010-10-05 15:59:54 +0000993 S->setAtCatchLoc(ReadSourceLocation(Record, Idx));
994 S->setRParenLoc(ReadSourceLocation(Record, Idx));
Chris Lattner4c6f9522009-04-27 05:14:47 +0000995}
996
Sebastian Redl60adf4a2010-08-18 23:56:52 +0000997void ASTStmtReader::VisitObjCAtFinallyStmt(ObjCAtFinallyStmt *S) {
Chris Lattner4c6f9522009-04-27 05:14:47 +0000998 VisitStmt(S);
Argyrios Kyrtzidisd98a2ab2010-06-29 22:46:25 +0000999 S->setFinallyBody(Reader.ReadSubStmt());
Sebastian Redlc3632732010-10-05 15:59:54 +00001000 S->setAtFinallyLoc(ReadSourceLocation(Record, Idx));
Chris Lattner4c6f9522009-04-27 05:14:47 +00001001}
1002
John McCallf85e1932011-06-15 23:02:42 +00001003void ASTStmtReader::VisitObjCAutoreleasePoolStmt(ObjCAutoreleasePoolStmt *S) {
1004 VisitStmt(S);
1005 S->setSubStmt(Reader.ReadSubStmt());
1006 S->setAtLoc(ReadSourceLocation(Record, Idx));
1007}
1008
Sebastian Redl60adf4a2010-08-18 23:56:52 +00001009void ASTStmtReader::VisitObjCAtTryStmt(ObjCAtTryStmt *S) {
Chris Lattner4c6f9522009-04-27 05:14:47 +00001010 VisitStmt(S);
Douglas Gregor8f5e3dd2010-04-23 22:50:49 +00001011 assert(Record[Idx] == S->getNumCatchStmts());
1012 ++Idx;
1013 bool HasFinally = Record[Idx++];
Argyrios Kyrtzidisd98a2ab2010-06-29 22:46:25 +00001014 S->setTryBody(Reader.ReadSubStmt());
Argyrios Kyrtzidis919e6932010-06-28 22:28:35 +00001015 for (unsigned I = 0, N = S->getNumCatchStmts(); I != N; ++I)
Argyrios Kyrtzidisd98a2ab2010-06-29 22:46:25 +00001016 S->setCatchStmt(I, cast_or_null<ObjCAtCatchStmt>(Reader.ReadSubStmt()));
Douglas Gregor8f5e3dd2010-04-23 22:50:49 +00001017
Douglas Gregor8f5e3dd2010-04-23 22:50:49 +00001018 if (HasFinally)
Argyrios Kyrtzidisd98a2ab2010-06-29 22:46:25 +00001019 S->setFinallyStmt(Reader.ReadSubStmt());
Sebastian Redlc3632732010-10-05 15:59:54 +00001020 S->setAtTryLoc(ReadSourceLocation(Record, Idx));
Chris Lattner4c6f9522009-04-27 05:14:47 +00001021}
1022
Sebastian Redl60adf4a2010-08-18 23:56:52 +00001023void ASTStmtReader::VisitObjCAtSynchronizedStmt(ObjCAtSynchronizedStmt *S) {
Chris Lattner4c6f9522009-04-27 05:14:47 +00001024 VisitStmt(S);
Argyrios Kyrtzidisd98a2ab2010-06-29 22:46:25 +00001025 S->setSynchExpr(Reader.ReadSubStmt());
1026 S->setSynchBody(Reader.ReadSubStmt());
Sebastian Redlc3632732010-10-05 15:59:54 +00001027 S->setAtSynchronizedLoc(ReadSourceLocation(Record, Idx));
Chris Lattner4c6f9522009-04-27 05:14:47 +00001028}
1029
Sebastian Redl60adf4a2010-08-18 23:56:52 +00001030void ASTStmtReader::VisitObjCAtThrowStmt(ObjCAtThrowStmt *S) {
Chris Lattner4c6f9522009-04-27 05:14:47 +00001031 VisitStmt(S);
Argyrios Kyrtzidisd98a2ab2010-06-29 22:46:25 +00001032 S->setThrowExpr(Reader.ReadSubStmt());
Sebastian Redlc3632732010-10-05 15:59:54 +00001033 S->setThrowLoc(ReadSourceLocation(Record, Idx));
Chris Lattner4c6f9522009-04-27 05:14:47 +00001034}
1035
Ted Kremenekebcb57a2012-03-06 20:05:56 +00001036void ASTStmtReader::VisitObjCBoolLiteralExpr(ObjCBoolLiteralExpr *E) {
1037 VisitExpr(E);
1038 E->setValue(Record[Idx++]);
1039 E->setLocation(ReadSourceLocation(Record, Idx));
1040}
1041
Argyrios Kyrtzidisba0a9002009-07-14 03:19:21 +00001042//===----------------------------------------------------------------------===//
1043// C++ Expressions and Statements
Argyrios Kyrtzidis7cb45e32010-07-22 16:03:56 +00001044//===----------------------------------------------------------------------===//
1045
Sebastian Redl60adf4a2010-08-18 23:56:52 +00001046void ASTStmtReader::VisitCXXCatchStmt(CXXCatchStmt *S) {
Argyrios Kyrtzidis7cb45e32010-07-22 16:03:56 +00001047 VisitStmt(S);
Sebastian Redlc3632732010-10-05 15:59:54 +00001048 S->CatchLoc = ReadSourceLocation(Record, Idx);
Douglas Gregor409448c2011-07-21 22:35:25 +00001049 S->ExceptionDecl = ReadDeclAs<VarDecl>(Record, Idx);
Argyrios Kyrtzidis7cb45e32010-07-22 16:03:56 +00001050 S->HandlerBlock = Reader.ReadSubStmt();
1051}
1052
Sebastian Redl60adf4a2010-08-18 23:56:52 +00001053void ASTStmtReader::VisitCXXTryStmt(CXXTryStmt *S) {
Argyrios Kyrtzidis7cb45e32010-07-22 16:03:56 +00001054 VisitStmt(S);
1055 assert(Record[Idx] == S->getNumHandlers() && "NumStmtFields is wrong ?");
1056 ++Idx;
Sebastian Redlc3632732010-10-05 15:59:54 +00001057 S->TryLoc = ReadSourceLocation(Record, Idx);
Argyrios Kyrtzidis7cb45e32010-07-22 16:03:56 +00001058 S->getStmts()[0] = Reader.ReadSubStmt();
1059 for (unsigned i = 0, e = S->getNumHandlers(); i != e; ++i)
1060 S->getStmts()[i + 1] = Reader.ReadSubStmt();
1061}
Argyrios Kyrtzidisba0a9002009-07-14 03:19:21 +00001062
Richard Smithad762fc2011-04-14 22:09:26 +00001063void ASTStmtReader::VisitCXXForRangeStmt(CXXForRangeStmt *S) {
1064 VisitStmt(S);
1065 S->setForLoc(ReadSourceLocation(Record, Idx));
1066 S->setColonLoc(ReadSourceLocation(Record, Idx));
1067 S->setRParenLoc(ReadSourceLocation(Record, Idx));
1068 S->setRangeStmt(Reader.ReadSubStmt());
1069 S->setBeginEndStmt(Reader.ReadSubStmt());
1070 S->setCond(Reader.ReadSubExpr());
1071 S->setInc(Reader.ReadSubExpr());
1072 S->setLoopVarStmt(Reader.ReadSubStmt());
1073 S->setBody(Reader.ReadSubStmt());
1074}
1075
Douglas Gregorba0513d2011-10-25 01:33:02 +00001076void ASTStmtReader::VisitMSDependentExistsStmt(MSDependentExistsStmt *S) {
1077 VisitStmt(S);
1078 S->KeywordLoc = ReadSourceLocation(Record, Idx);
1079 S->IsIfExists = Record[Idx++];
1080 S->QualifierLoc = Reader.ReadNestedNameSpecifierLoc(F, Record, Idx);
1081 ReadDeclarationNameInfo(S->NameInfo, Record, Idx);
1082 S->SubStmt = Reader.ReadSubStmt();
1083}
1084
Sebastian Redl60adf4a2010-08-18 23:56:52 +00001085void ASTStmtReader::VisitCXXOperatorCallExpr(CXXOperatorCallExpr *E) {
Argyrios Kyrtzidis919e6932010-06-28 22:28:35 +00001086 VisitCallExpr(E);
Argyrios Kyrtzidis4548ca22012-04-30 22:12:22 +00001087 E->Operator = (OverloadedOperatorKind)Record[Idx++];
1088 E->Range = Reader.ReadSourceRange(F, Record, Idx);
Argyrios Kyrtzidisba0a9002009-07-14 03:19:21 +00001089}
1090
Sebastian Redl60adf4a2010-08-18 23:56:52 +00001091void ASTStmtReader::VisitCXXConstructExpr(CXXConstructExpr *E) {
Douglas Gregor39da0b82009-09-09 23:08:42 +00001092 VisitExpr(E);
Argyrios Kyrtzidis6d00c132010-07-10 11:46:15 +00001093 E->NumArgs = Record[Idx++];
1094 if (E->NumArgs)
Douglas Gregor35942772011-09-09 21:34:22 +00001095 E->Args = new (Reader.getContext()) Stmt*[E->NumArgs];
Argyrios Kyrtzidis5e1b7c22010-06-24 08:57:09 +00001096 for (unsigned I = 0, N = E->getNumArgs(); I != N; ++I)
Argyrios Kyrtzidisd98a2ab2010-06-29 22:46:25 +00001097 E->setArg(I, Reader.ReadSubExpr());
Douglas Gregor409448c2011-07-21 22:35:25 +00001098 E->setConstructor(ReadDeclAs<CXXConstructorDecl>(Record, Idx));
Sebastian Redlc3632732010-10-05 15:59:54 +00001099 E->setLocation(ReadSourceLocation(Record, Idx));
Abramo Bagnara7cc58b42011-10-05 07:56:41 +00001100 E->setElidable(Record[Idx++]);
1101 E->setHadMultipleCandidates(Record[Idx++]);
Douglas Gregor16006c92009-12-16 18:50:27 +00001102 E->setRequiresZeroInitialization(Record[Idx++]);
Douglas Gregor3c9034c2010-05-15 00:13:29 +00001103 E->setConstructionKind((CXXConstructExpr::ConstructionKind)Record[Idx++]);
Chandler Carruth428edaf2010-10-25 08:47:36 +00001104 E->ParenRange = ReadSourceRange(Record, Idx);
Douglas Gregor39da0b82009-09-09 23:08:42 +00001105}
Chris Lattner4c6f9522009-04-27 05:14:47 +00001106
Sebastian Redl60adf4a2010-08-18 23:56:52 +00001107void ASTStmtReader::VisitCXXTemporaryObjectExpr(CXXTemporaryObjectExpr *E) {
Argyrios Kyrtzidis6d00c132010-07-10 11:46:15 +00001108 VisitCXXConstructExpr(E);
Sebastian Redlc3632732010-10-05 15:59:54 +00001109 E->Type = GetTypeSourceInfo(Record, Idx);
Argyrios Kyrtzidis6d00c132010-07-10 11:46:15 +00001110}
1111
Douglas Gregor01d08012012-02-07 10:09:13 +00001112void ASTStmtReader::VisitLambdaExpr(LambdaExpr *E) {
1113 VisitExpr(E);
Douglas Gregor9d36f5d2012-02-14 17:54:36 +00001114 unsigned NumCaptures = Record[Idx++];
1115 assert(NumCaptures == E->NumCaptures);(void)NumCaptures;
1116 unsigned NumArrayIndexVars = Record[Idx++];
1117 E->IntroducerRange = ReadSourceRange(Record, Idx);
1118 E->CaptureDefault = static_cast<LambdaCaptureDefault>(Record[Idx++]);
1119 E->ExplicitParams = Record[Idx++];
1120 E->ExplicitResultType = Record[Idx++];
1121 E->ClosingBrace = ReadSourceLocation(Record, Idx);
1122
1123 // Read capture initializers.
1124 for (LambdaExpr::capture_init_iterator C = E->capture_init_begin(),
1125 CEnd = E->capture_init_end();
1126 C != CEnd; ++C)
1127 *C = Reader.ReadSubExpr();
1128
1129 // Read array capture index variables.
1130 if (NumArrayIndexVars > 0) {
1131 unsigned *ArrayIndexStarts = E->getArrayIndexStarts();
1132 for (unsigned I = 0; I != NumCaptures + 1; ++I)
1133 ArrayIndexStarts[I] = Record[Idx++];
1134
1135 VarDecl **ArrayIndexVars = E->getArrayIndexVars();
1136 for (unsigned I = 0; I != NumArrayIndexVars; ++I)
1137 ArrayIndexVars[I] = ReadDeclAs<VarDecl>(Record, Idx);
1138 }
Douglas Gregor01d08012012-02-07 10:09:13 +00001139}
1140
Sebastian Redl60adf4a2010-08-18 23:56:52 +00001141void ASTStmtReader::VisitCXXNamedCastExpr(CXXNamedCastExpr *E) {
Argyrios Kyrtzidis919e6932010-06-28 22:28:35 +00001142 VisitExplicitCastExpr(E);
Douglas Gregor1d5d0b92011-01-12 22:41:29 +00001143 SourceRange R = ReadSourceRange(Record, Idx);
1144 E->Loc = R.getBegin();
1145 E->RParenLoc = R.getEnd();
Sam Weinigce757a72010-01-16 21:21:01 +00001146}
1147
Sebastian Redl60adf4a2010-08-18 23:56:52 +00001148void ASTStmtReader::VisitCXXStaticCastExpr(CXXStaticCastExpr *E) {
Sam Weinigce757a72010-01-16 21:21:01 +00001149 return VisitCXXNamedCastExpr(E);
1150}
1151
Sebastian Redl60adf4a2010-08-18 23:56:52 +00001152void ASTStmtReader::VisitCXXDynamicCastExpr(CXXDynamicCastExpr *E) {
Sam Weinigce757a72010-01-16 21:21:01 +00001153 return VisitCXXNamedCastExpr(E);
1154}
1155
Sebastian Redl60adf4a2010-08-18 23:56:52 +00001156void ASTStmtReader::VisitCXXReinterpretCastExpr(CXXReinterpretCastExpr *E) {
Sam Weinigce757a72010-01-16 21:21:01 +00001157 return VisitCXXNamedCastExpr(E);
1158}
1159
Sebastian Redl60adf4a2010-08-18 23:56:52 +00001160void ASTStmtReader::VisitCXXConstCastExpr(CXXConstCastExpr *E) {
Sam Weinigce757a72010-01-16 21:21:01 +00001161 return VisitCXXNamedCastExpr(E);
1162}
1163
Sebastian Redl60adf4a2010-08-18 23:56:52 +00001164void ASTStmtReader::VisitCXXFunctionalCastExpr(CXXFunctionalCastExpr *E) {
Argyrios Kyrtzidis919e6932010-06-28 22:28:35 +00001165 VisitExplicitCastExpr(E);
Sebastian Redlc3632732010-10-05 15:59:54 +00001166 E->setTypeBeginLoc(ReadSourceLocation(Record, Idx));
1167 E->setRParenLoc(ReadSourceLocation(Record, Idx));
Sam Weinigce757a72010-01-16 21:21:01 +00001168}
1169
Richard Smith9fcce652012-03-07 08:35:16 +00001170void ASTStmtReader::VisitUserDefinedLiteral(UserDefinedLiteral *E) {
1171 VisitCallExpr(E);
1172 E->UDSuffixLoc = ReadSourceLocation(Record, Idx);
1173}
1174
Sebastian Redl60adf4a2010-08-18 23:56:52 +00001175void ASTStmtReader::VisitCXXBoolLiteralExpr(CXXBoolLiteralExpr *E) {
Sam Weinigeb7f9612010-02-07 06:32:43 +00001176 VisitExpr(E);
1177 E->setValue(Record[Idx++]);
Sebastian Redlc3632732010-10-05 15:59:54 +00001178 E->setLocation(ReadSourceLocation(Record, Idx));
Sam Weinigeb7f9612010-02-07 06:32:43 +00001179}
1180
Sebastian Redl60adf4a2010-08-18 23:56:52 +00001181void ASTStmtReader::VisitCXXNullPtrLiteralExpr(CXXNullPtrLiteralExpr *E) {
Sam Weinigeb7f9612010-02-07 06:32:43 +00001182 VisitExpr(E);
Sebastian Redlc3632732010-10-05 15:59:54 +00001183 E->setLocation(ReadSourceLocation(Record, Idx));
Sam Weinigeb7f9612010-02-07 06:32:43 +00001184}
1185
Sebastian Redl60adf4a2010-08-18 23:56:52 +00001186void ASTStmtReader::VisitCXXTypeidExpr(CXXTypeidExpr *E) {
Chris Lattner14ab24f2010-05-09 06:03:39 +00001187 VisitExpr(E);
Sebastian Redlc3632732010-10-05 15:59:54 +00001188 E->setSourceRange(ReadSourceRange(Record, Idx));
Chris Lattner14ab24f2010-05-09 06:03:39 +00001189 if (E->isTypeOperand()) { // typeid(int)
Sebastian Redl577d4792010-07-22 22:43:28 +00001190 E->setTypeOperandSourceInfo(
Sebastian Redlc3632732010-10-05 15:59:54 +00001191 GetTypeSourceInfo(Record, Idx));
Argyrios Kyrtzidis919e6932010-06-28 22:28:35 +00001192 return;
Chris Lattner14ab24f2010-05-09 06:03:39 +00001193 }
1194
1195 // typeid(42+2)
Argyrios Kyrtzidisd98a2ab2010-06-29 22:46:25 +00001196 E->setExprOperand(Reader.ReadSubExpr());
Chris Lattner14ab24f2010-05-09 06:03:39 +00001197}
1198
Sebastian Redl60adf4a2010-08-18 23:56:52 +00001199void ASTStmtReader::VisitCXXThisExpr(CXXThisExpr *E) {
Chris Lattner2fbdfcd2010-05-09 06:15:05 +00001200 VisitExpr(E);
Sebastian Redlc3632732010-10-05 15:59:54 +00001201 E->setLocation(ReadSourceLocation(Record, Idx));
Chris Lattner2fbdfcd2010-05-09 06:15:05 +00001202 E->setImplicit(Record[Idx++]);
Chris Lattner2fbdfcd2010-05-09 06:15:05 +00001203}
1204
Sebastian Redl60adf4a2010-08-18 23:56:52 +00001205void ASTStmtReader::VisitCXXThrowExpr(CXXThrowExpr *E) {
Chris Lattner2fbdfcd2010-05-09 06:15:05 +00001206 VisitExpr(E);
Douglas Gregorbca01b42011-07-06 22:04:06 +00001207 E->ThrowLoc = ReadSourceLocation(Record, Idx);
1208 E->Op = Reader.ReadSubExpr();
1209 E->IsThrownVariableInScope = Record[Idx++];
Chris Lattner2fbdfcd2010-05-09 06:15:05 +00001210}
Chris Lattner14ab24f2010-05-09 06:03:39 +00001211
Sebastian Redl60adf4a2010-08-18 23:56:52 +00001212void ASTStmtReader::VisitCXXDefaultArgExpr(CXXDefaultArgExpr *E) {
Chris Lattner030854b2010-05-09 06:40:08 +00001213 VisitExpr(E);
Argyrios Kyrtzidis8a507332010-07-02 23:30:15 +00001214
Douglas Gregordf226552011-09-23 22:07:41 +00001215 assert((bool)Record[Idx] == E->Param.getInt() && "We messed up at creation ?");
Argyrios Kyrtzidis8a507332010-07-02 23:30:15 +00001216 ++Idx; // HasOtherExprStored and SubExpr was handled during creation.
Douglas Gregor409448c2011-07-21 22:35:25 +00001217 E->Param.setPointer(ReadDeclAs<ParmVarDecl>(Record, Idx));
Sebastian Redlc3632732010-10-05 15:59:54 +00001218 E->Loc = ReadSourceLocation(Record, Idx);
Chris Lattnerd2598362010-05-10 00:25:06 +00001219}
1220
Sebastian Redl60adf4a2010-08-18 23:56:52 +00001221void ASTStmtReader::VisitCXXBindTemporaryExpr(CXXBindTemporaryExpr *E) {
Chris Lattnerd2598362010-05-10 00:25:06 +00001222 VisitExpr(E);
Douglas Gregor409448c2011-07-21 22:35:25 +00001223 E->setTemporary(Reader.ReadCXXTemporary(F, Record, Idx));
Argyrios Kyrtzidisd98a2ab2010-06-29 22:46:25 +00001224 E->setSubExpr(Reader.ReadSubExpr());
Chris Lattnerd2598362010-05-10 00:25:06 +00001225}
1226
Sebastian Redl60adf4a2010-08-18 23:56:52 +00001227void ASTStmtReader::VisitCXXScalarValueInitExpr(CXXScalarValueInitExpr *E) {
Chris Lattner59218632010-05-10 01:22:27 +00001228 VisitExpr(E);
Sebastian Redlc3632732010-10-05 15:59:54 +00001229 E->TypeInfo = GetTypeSourceInfo(Record, Idx);
1230 E->RParenLoc = ReadSourceLocation(Record, Idx);
Chris Lattner59218632010-05-10 01:22:27 +00001231}
1232
Sebastian Redl60adf4a2010-08-18 23:56:52 +00001233void ASTStmtReader::VisitCXXNewExpr(CXXNewExpr *E) {
Chris Lattner59218632010-05-10 01:22:27 +00001234 VisitExpr(E);
John McCall6ec278d2011-01-27 09:37:56 +00001235 E->GlobalNew = Record[Idx++];
Sebastian Redl1548d142012-02-16 11:35:52 +00001236 bool isArray = Record[Idx++];
Sebastian Redl2aed8b82012-02-16 12:22:20 +00001237 E->UsualArrayDeleteWantsSize = Record[Idx++];
Chris Lattner59218632010-05-10 01:22:27 +00001238 unsigned NumPlacementArgs = Record[Idx++];
Sebastian Redl2aed8b82012-02-16 12:22:20 +00001239 E->StoredInitializationStyle = Record[Idx++];
Douglas Gregor409448c2011-07-21 22:35:25 +00001240 E->setOperatorNew(ReadDeclAs<FunctionDecl>(Record, Idx));
1241 E->setOperatorDelete(ReadDeclAs<FunctionDecl>(Record, Idx));
Sebastian Redlc3632732010-10-05 15:59:54 +00001242 E->AllocatedTypeInfo = GetTypeSourceInfo(Record, Idx);
Douglas Gregor83bc2762012-02-20 16:12:14 +00001243 E->TypeIdParens = ReadSourceRange(Record, Idx);
Chandler Carruth428edaf2010-10-25 08:47:36 +00001244 E->StartLoc = ReadSourceLocation(Record, Idx);
Douglas Gregor83bc2762012-02-20 16:12:14 +00001245 E->DirectInitRange = ReadSourceRange(Record, Idx);
Chandler Carruth428edaf2010-10-25 08:47:36 +00001246
Douglas Gregor35942772011-09-09 21:34:22 +00001247 E->AllocateArgsArray(Reader.getContext(), isArray, NumPlacementArgs,
Sebastian Redl2aed8b82012-02-16 12:22:20 +00001248 E->StoredInitializationStyle != 0);
Chris Lattner59218632010-05-10 01:22:27 +00001249
1250 // Install all the subexpressions.
Chris Lattner59218632010-05-10 01:22:27 +00001251 for (CXXNewExpr::raw_arg_iterator I = E->raw_arg_begin(),e = E->raw_arg_end();
1252 I != e; ++I)
Argyrios Kyrtzidisd98a2ab2010-06-29 22:46:25 +00001253 *I = Reader.ReadSubStmt();
Chris Lattner59218632010-05-10 01:22:27 +00001254}
1255
Sebastian Redl60adf4a2010-08-18 23:56:52 +00001256void ASTStmtReader::VisitCXXDeleteExpr(CXXDeleteExpr *E) {
Argyrios Kyrtzidis95fc98c2010-06-22 17:07:59 +00001257 VisitExpr(E);
Argyrios Kyrtzidisf1b89112010-09-13 20:15:40 +00001258 E->GlobalDelete = Record[Idx++];
1259 E->ArrayForm = Record[Idx++];
Argyrios Kyrtzidis4076dac2010-09-13 20:15:54 +00001260 E->ArrayFormAsWritten = Record[Idx++];
John McCall6ec278d2011-01-27 09:37:56 +00001261 E->UsualArrayDeleteWantsSize = Record[Idx++];
Douglas Gregor409448c2011-07-21 22:35:25 +00001262 E->OperatorDelete = ReadDeclAs<FunctionDecl>(Record, Idx);
Argyrios Kyrtzidisf1b89112010-09-13 20:15:40 +00001263 E->Argument = Reader.ReadSubExpr();
Sebastian Redlc3632732010-10-05 15:59:54 +00001264 E->Loc = ReadSourceLocation(Record, Idx);
Argyrios Kyrtzidis95fc98c2010-06-22 17:07:59 +00001265}
Chris Lattnerd2598362010-05-10 00:25:06 +00001266
Sebastian Redl60adf4a2010-08-18 23:56:52 +00001267void ASTStmtReader::VisitCXXPseudoDestructorExpr(CXXPseudoDestructorExpr *E) {
Argyrios Kyrtzidisde4bd182010-06-28 09:32:03 +00001268 VisitExpr(E);
1269
Douglas Gregorf3db29f2011-02-25 18:19:59 +00001270 E->Base = Reader.ReadSubExpr();
1271 E->IsArrow = Record[Idx++];
1272 E->OperatorLoc = ReadSourceLocation(Record, Idx);
1273 E->QualifierLoc = Reader.ReadNestedNameSpecifierLoc(F, Record, Idx);
1274 E->ScopeType = GetTypeSourceInfo(Record, Idx);
1275 E->ColonColonLoc = ReadSourceLocation(Record, Idx);
1276 E->TildeLoc = ReadSourceLocation(Record, Idx);
Argyrios Kyrtzidisde4bd182010-06-28 09:32:03 +00001277
Douglas Gregor95eab172011-07-28 20:55:49 +00001278 IdentifierInfo *II = Reader.GetIdentifierInfo(F, Record, Idx);
Argyrios Kyrtzidisde4bd182010-06-28 09:32:03 +00001279 if (II)
Sebastian Redlc3632732010-10-05 15:59:54 +00001280 E->setDestroyedType(II, ReadSourceLocation(Record, Idx));
Argyrios Kyrtzidisde4bd182010-06-28 09:32:03 +00001281 else
Sebastian Redlc3632732010-10-05 15:59:54 +00001282 E->setDestroyedType(GetTypeSourceInfo(Record, Idx));
Argyrios Kyrtzidisde4bd182010-06-28 09:32:03 +00001283}
1284
John McCall4765fa02010-12-06 08:20:24 +00001285void ASTStmtReader::VisitExprWithCleanups(ExprWithCleanups *E) {
Chris Lattnerd2598362010-05-10 00:25:06 +00001286 VisitExpr(E);
John McCall80ee6e82011-11-10 05:35:25 +00001287
1288 unsigned NumObjects = Record[Idx++];
1289 assert(NumObjects == E->getNumObjects());
1290 for (unsigned i = 0; i != NumObjects; ++i)
1291 E->getObjectsBuffer()[i] = ReadDeclAs<BlockDecl>(Record, Idx);
1292
1293 E->SubExpr = Reader.ReadSubExpr();
Chris Lattner030854b2010-05-09 06:40:08 +00001294}
1295
Argyrios Kyrtzidis919e6932010-06-28 22:28:35 +00001296void
Sebastian Redl60adf4a2010-08-18 23:56:52 +00001297ASTStmtReader::VisitCXXDependentScopeMemberExpr(CXXDependentScopeMemberExpr *E){
Argyrios Kyrtzidis8dfbd8b2010-06-24 08:57:31 +00001298 VisitExpr(E);
Abramo Bagnarae4b92762012-01-27 09:46:47 +00001299
1300 if (Record[Idx++]) // HasTemplateKWAndArgsInfo
1301 ReadTemplateKWAndArgsInfo(*E->getTemplateKWAndArgsInfo(),
1302 /*NumTemplateArgs=*/Record[Idx++]);
Argyrios Kyrtzidis8dfbd8b2010-06-24 08:57:31 +00001303
Douglas Gregor7c3179c2011-02-28 18:50:33 +00001304 E->Base = Reader.ReadSubExpr();
Douglas Gregor393f2492011-07-22 00:38:23 +00001305 E->BaseType = Reader.readType(F, Record, Idx);
Douglas Gregor7c3179c2011-02-28 18:50:33 +00001306 E->IsArrow = Record[Idx++];
1307 E->OperatorLoc = ReadSourceLocation(Record, Idx);
1308 E->QualifierLoc = Reader.ReadNestedNameSpecifierLoc(F, Record, Idx);
Douglas Gregor409448c2011-07-21 22:35:25 +00001309 E->FirstQualifierFoundInScope = ReadDeclAs<NamedDecl>(Record, Idx);
Argyrios Kyrtzidis40451072010-10-15 18:21:24 +00001310 ReadDeclarationNameInfo(E->MemberNameInfo, Record, Idx);
Argyrios Kyrtzidis8dfbd8b2010-06-24 08:57:31 +00001311}
1312
Argyrios Kyrtzidis919e6932010-06-28 22:28:35 +00001313void
Sebastian Redl60adf4a2010-08-18 23:56:52 +00001314ASTStmtReader::VisitDependentScopeDeclRefExpr(DependentScopeDeclRefExpr *E) {
Argyrios Kyrtzidis12dffcd2010-06-28 09:31:56 +00001315 VisitExpr(E);
Abramo Bagnarae4b92762012-01-27 09:46:47 +00001316
1317 if (Record[Idx++]) // HasTemplateKWAndArgsInfo
1318 ReadTemplateKWAndArgsInfo(*E->getTemplateKWAndArgsInfo(),
1319 /*NumTemplateArgs=*/Record[Idx++]);
Douglas Gregor00cf3cc2011-02-25 20:49:16 +00001320
1321 E->QualifierLoc = Reader.ReadNestedNameSpecifierLoc(F, Record, Idx);
Argyrios Kyrtzidis40451072010-10-15 18:21:24 +00001322 ReadDeclarationNameInfo(E->NameInfo, Record, Idx);
Argyrios Kyrtzidis12dffcd2010-06-28 09:31:56 +00001323}
1324
Argyrios Kyrtzidis919e6932010-06-28 22:28:35 +00001325void
Sebastian Redl60adf4a2010-08-18 23:56:52 +00001326ASTStmtReader::VisitCXXUnresolvedConstructExpr(CXXUnresolvedConstructExpr *E) {
Argyrios Kyrtzidis8dfbd8b2010-06-24 08:57:31 +00001327 VisitExpr(E);
1328 assert(Record[Idx] == E->arg_size() && "Read wrong record during creation ?");
1329 ++Idx; // NumArgs;
1330 for (unsigned I = 0, N = E->arg_size(); I != N; ++I)
Argyrios Kyrtzidisd98a2ab2010-06-29 22:46:25 +00001331 E->setArg(I, Reader.ReadSubExpr());
Sebastian Redlc3632732010-10-05 15:59:54 +00001332 E->Type = GetTypeSourceInfo(Record, Idx);
1333 E->setLParenLoc(ReadSourceLocation(Record, Idx));
1334 E->setRParenLoc(ReadSourceLocation(Record, Idx));
Argyrios Kyrtzidis8dfbd8b2010-06-24 08:57:31 +00001335}
1336
Sebastian Redl60adf4a2010-08-18 23:56:52 +00001337void ASTStmtReader::VisitOverloadExpr(OverloadExpr *E) {
Argyrios Kyrtzidisa77eb082010-06-25 09:03:26 +00001338 VisitExpr(E);
Abramo Bagnarae4b92762012-01-27 09:46:47 +00001339
1340 if (Record[Idx++]) // HasTemplateKWAndArgsInfo
1341 ReadTemplateKWAndArgsInfo(*E->getTemplateKWAndArgsInfo(),
1342 /*NumTemplateArgs=*/Record[Idx++]);
Argyrios Kyrtzidisa77eb082010-06-25 09:03:26 +00001343
1344 unsigned NumDecls = Record[Idx++];
1345 UnresolvedSet<8> Decls;
1346 for (unsigned i = 0; i != NumDecls; ++i) {
Douglas Gregor409448c2011-07-21 22:35:25 +00001347 NamedDecl *D = ReadDeclAs<NamedDecl>(Record, Idx);
Argyrios Kyrtzidisa77eb082010-06-25 09:03:26 +00001348 AccessSpecifier AS = (AccessSpecifier)Record[Idx++];
1349 Decls.addDecl(D, AS);
1350 }
Douglas Gregor35942772011-09-09 21:34:22 +00001351 E->initializeResults(Reader.getContext(), Decls.begin(), Decls.end());
Argyrios Kyrtzidisa77eb082010-06-25 09:03:26 +00001352
Argyrios Kyrtzidis40451072010-10-15 18:21:24 +00001353 ReadDeclarationNameInfo(E->NameInfo, Record, Idx);
Douglas Gregor4c9be892011-02-28 20:01:57 +00001354 E->QualifierLoc = Reader.ReadNestedNameSpecifierLoc(F, Record, Idx);
Argyrios Kyrtzidisa77eb082010-06-25 09:03:26 +00001355}
1356
Sebastian Redl60adf4a2010-08-18 23:56:52 +00001357void ASTStmtReader::VisitUnresolvedMemberExpr(UnresolvedMemberExpr *E) {
Argyrios Kyrtzidis919e6932010-06-28 22:28:35 +00001358 VisitOverloadExpr(E);
Douglas Gregor4c9be892011-02-28 20:01:57 +00001359 E->IsArrow = Record[Idx++];
1360 E->HasUnresolvedUsing = Record[Idx++];
1361 E->Base = Reader.ReadSubExpr();
Douglas Gregor393f2492011-07-22 00:38:23 +00001362 E->BaseType = Reader.readType(F, Record, Idx);
Douglas Gregor4c9be892011-02-28 20:01:57 +00001363 E->OperatorLoc = ReadSourceLocation(Record, Idx);
Argyrios Kyrtzidisa77eb082010-06-25 09:03:26 +00001364}
1365
Sebastian Redl60adf4a2010-08-18 23:56:52 +00001366void ASTStmtReader::VisitUnresolvedLookupExpr(UnresolvedLookupExpr *E) {
Argyrios Kyrtzidis919e6932010-06-28 22:28:35 +00001367 VisitOverloadExpr(E);
Douglas Gregor4c9be892011-02-28 20:01:57 +00001368 E->RequiresADL = Record[Idx++];
Richard Smithad762fc2011-04-14 22:09:26 +00001369 if (E->RequiresADL)
1370 E->StdIsAssociatedNamespace = Record[Idx++];
Douglas Gregor4c9be892011-02-28 20:01:57 +00001371 E->Overloaded = Record[Idx++];
Douglas Gregor409448c2011-07-21 22:35:25 +00001372 E->NamingClass = ReadDeclAs<CXXRecordDecl>(Record, Idx);
Argyrios Kyrtzidisbd65bb52010-06-25 09:03:34 +00001373}
1374
Sebastian Redl60adf4a2010-08-18 23:56:52 +00001375void ASTStmtReader::VisitUnaryTypeTraitExpr(UnaryTypeTraitExpr *E) {
Argyrios Kyrtzidis6d00c132010-07-10 11:46:15 +00001376 VisitExpr(E);
1377 E->UTT = (UnaryTypeTrait)Record[Idx++];
Sebastian Redl0dfd8482010-09-13 20:56:31 +00001378 E->Value = (bool)Record[Idx++];
Sebastian Redlc3632732010-10-05 15:59:54 +00001379 SourceRange Range = ReadSourceRange(Record, Idx);
Argyrios Kyrtzidis6d00c132010-07-10 11:46:15 +00001380 E->Loc = Range.getBegin();
1381 E->RParen = Range.getEnd();
Sebastian Redlc3632732010-10-05 15:59:54 +00001382 E->QueriedType = GetTypeSourceInfo(Record, Idx);
Argyrios Kyrtzidis6d00c132010-07-10 11:46:15 +00001383}
1384
Francois Pichet6ad6f282010-12-07 00:08:36 +00001385void ASTStmtReader::VisitBinaryTypeTraitExpr(BinaryTypeTraitExpr *E) {
1386 VisitExpr(E);
1387 E->BTT = (BinaryTypeTrait)Record[Idx++];
1388 E->Value = (bool)Record[Idx++];
1389 SourceRange Range = ReadSourceRange(Record, Idx);
1390 E->Loc = Range.getBegin();
1391 E->RParen = Range.getEnd();
1392 E->LhsType = GetTypeSourceInfo(Record, Idx);
1393 E->RhsType = GetTypeSourceInfo(Record, Idx);
1394}
1395
Douglas Gregor4ca8ac22012-02-24 07:38:34 +00001396void ASTStmtReader::VisitTypeTraitExpr(TypeTraitExpr *E) {
1397 VisitExpr(E);
1398 E->TypeTraitExprBits.NumArgs = Record[Idx++];
1399 E->TypeTraitExprBits.Kind = Record[Idx++];
1400 E->TypeTraitExprBits.Value = Record[Idx++];
1401
1402 TypeSourceInfo **Args = E->getTypeSourceInfos();
1403 for (unsigned I = 0, N = E->getNumArgs(); I != N; ++I)
1404 Args[I] = GetTypeSourceInfo(Record, Idx);
1405}
1406
John Wiegley21ff2e52011-04-28 00:16:57 +00001407void ASTStmtReader::VisitArrayTypeTraitExpr(ArrayTypeTraitExpr *E) {
1408 VisitExpr(E);
1409 E->ATT = (ArrayTypeTrait)Record[Idx++];
1410 E->Value = (unsigned int)Record[Idx++];
1411 SourceRange Range = ReadSourceRange(Record, Idx);
1412 E->Loc = Range.getBegin();
1413 E->RParen = Range.getEnd();
1414 E->QueriedType = GetTypeSourceInfo(Record, Idx);
1415}
1416
John Wiegley55262202011-04-25 06:54:41 +00001417void ASTStmtReader::VisitExpressionTraitExpr(ExpressionTraitExpr *E) {
1418 VisitExpr(E);
1419 E->ET = (ExpressionTrait)Record[Idx++];
1420 E->Value = (bool)Record[Idx++];
1421 SourceRange Range = ReadSourceRange(Record, Idx);
1422 E->QueriedExpression = Reader.ReadSubExpr();
1423 E->Loc = Range.getBegin();
1424 E->RParen = Range.getEnd();
1425}
1426
Sebastian Redl6b219d02010-09-10 20:55:54 +00001427void ASTStmtReader::VisitCXXNoexceptExpr(CXXNoexceptExpr *E) {
1428 VisitExpr(E);
Sebastian Redl5221d8f2010-09-10 22:34:40 +00001429 E->Value = (bool)Record[Idx++];
Sebastian Redlc3632732010-10-05 15:59:54 +00001430 E->Range = ReadSourceRange(Record, Idx);
Sebastian Redl5221d8f2010-09-10 22:34:40 +00001431 E->Operand = Reader.ReadSubExpr();
Sebastian Redl6b219d02010-09-10 20:55:54 +00001432}
1433
Douglas Gregorbe230c32011-01-03 17:17:50 +00001434void ASTStmtReader::VisitPackExpansionExpr(PackExpansionExpr *E) {
1435 VisitExpr(E);
1436 E->EllipsisLoc = ReadSourceLocation(Record, Idx);
Douglas Gregor67fd1252011-01-14 21:20:45 +00001437 E->NumExpansions = Record[Idx++];
Douglas Gregorbe230c32011-01-03 17:17:50 +00001438 E->Pattern = Reader.ReadSubExpr();
1439}
1440
Douglas Gregoree8aff02011-01-04 17:33:58 +00001441void ASTStmtReader::VisitSizeOfPackExpr(SizeOfPackExpr *E) {
1442 VisitExpr(E);
1443 E->OperatorLoc = ReadSourceLocation(Record, Idx);
1444 E->PackLoc = ReadSourceLocation(Record, Idx);
1445 E->RParenLoc = ReadSourceLocation(Record, Idx);
1446 E->Length = Record[Idx++];
Douglas Gregor409448c2011-07-21 22:35:25 +00001447 E->Pack = ReadDeclAs<NamedDecl>(Record, Idx);
Douglas Gregoree8aff02011-01-04 17:33:58 +00001448}
1449
John McCall7110fd62011-07-15 07:00:14 +00001450void ASTStmtReader::VisitSubstNonTypeTemplateParmExpr(
1451 SubstNonTypeTemplateParmExpr *E) {
1452 VisitExpr(E);
Douglas Gregor409448c2011-07-21 22:35:25 +00001453 E->Param = ReadDeclAs<NonTypeTemplateParmDecl>(Record, Idx);
John McCall7110fd62011-07-15 07:00:14 +00001454 E->NameLoc = ReadSourceLocation(Record, Idx);
1455 E->Replacement = Reader.ReadSubExpr();
1456}
1457
Douglas Gregorc7793c72011-01-15 01:15:58 +00001458void ASTStmtReader::VisitSubstNonTypeTemplateParmPackExpr(
1459 SubstNonTypeTemplateParmPackExpr *E) {
1460 VisitExpr(E);
Douglas Gregor409448c2011-07-21 22:35:25 +00001461 E->Param = ReadDeclAs<NonTypeTemplateParmDecl>(Record, Idx);
Douglas Gregorc7793c72011-01-15 01:15:58 +00001462 TemplateArgument ArgPack = Reader.ReadTemplateArgument(F, Record, Idx);
1463 if (ArgPack.getKind() != TemplateArgument::Pack)
1464 return;
1465
1466 E->Arguments = ArgPack.pack_begin();
1467 E->NumArguments = ArgPack.pack_size();
1468 E->NameLoc = ReadSourceLocation(Record, Idx);
1469}
1470
Douglas Gregor03e80032011-06-21 17:03:29 +00001471void ASTStmtReader::VisitMaterializeTemporaryExpr(MaterializeTemporaryExpr *E) {
1472 VisitExpr(E);
1473 E->Temporary = Reader.ReadSubExpr();
1474}
1475
John McCall7cd7d1a2010-11-15 23:31:06 +00001476void ASTStmtReader::VisitOpaqueValueExpr(OpaqueValueExpr *E) {
1477 VisitExpr(E);
Argyrios Kyrtzidis8bc27822011-12-03 03:49:52 +00001478 E->SourceExpr = Reader.ReadSubExpr();
Douglas Gregorb608b982011-01-28 02:26:04 +00001479 E->Loc = ReadSourceLocation(Record, Idx);
John McCall7cd7d1a2010-11-15 23:31:06 +00001480}
1481
Peter Collingbournee08ce652011-02-09 21:07:24 +00001482//===----------------------------------------------------------------------===//
John McCall7110fd62011-07-15 07:00:14 +00001483// Microsoft Expressions and Statements
1484//===----------------------------------------------------------------------===//
1485void ASTStmtReader::VisitCXXUuidofExpr(CXXUuidofExpr *E) {
1486 VisitExpr(E);
1487 E->setSourceRange(ReadSourceRange(Record, Idx));
1488 if (E->isTypeOperand()) { // __uuidof(ComType)
1489 E->setTypeOperandSourceInfo(
1490 GetTypeSourceInfo(Record, Idx));
1491 return;
1492 }
1493
1494 // __uuidof(expr)
1495 E->setExprOperand(Reader.ReadSubExpr());
1496}
1497
1498void ASTStmtReader::VisitSEHExceptStmt(SEHExceptStmt *S) {
1499 VisitStmt(S);
1500 S->Loc = ReadSourceLocation(Record, Idx);
1501 S->Children[SEHExceptStmt::FILTER_EXPR] = Reader.ReadSubStmt();
1502 S->Children[SEHExceptStmt::BLOCK] = Reader.ReadSubStmt();
1503}
1504
1505void ASTStmtReader::VisitSEHFinallyStmt(SEHFinallyStmt *S) {
1506 VisitStmt(S);
1507 S->Loc = ReadSourceLocation(Record, Idx);
1508 S->Block = Reader.ReadSubStmt();
1509}
1510
1511void ASTStmtReader::VisitSEHTryStmt(SEHTryStmt *S) {
1512 VisitStmt(S);
1513 S->IsCXXTry = Record[Idx++];
1514 S->TryLoc = ReadSourceLocation(Record, Idx);
1515 S->Children[SEHTryStmt::TRY] = Reader.ReadSubStmt();
1516 S->Children[SEHTryStmt::HANDLER] = Reader.ReadSubStmt();
1517}
1518
1519//===----------------------------------------------------------------------===//
Peter Collingbournee08ce652011-02-09 21:07:24 +00001520// CUDA Expressions and Statements
1521//===----------------------------------------------------------------------===//
1522
1523void ASTStmtReader::VisitCUDAKernelCallExpr(CUDAKernelCallExpr *E) {
1524 VisitCallExpr(E);
1525 E->setConfig(cast<CallExpr>(Reader.ReadSubExpr()));
1526}
1527
John McCall7110fd62011-07-15 07:00:14 +00001528//===----------------------------------------------------------------------===//
1529// OpenCL Expressions and Statements.
1530//===----------------------------------------------------------------------===//
1531void ASTStmtReader::VisitAsTypeExpr(AsTypeExpr *E) {
1532 VisitExpr(E);
1533 E->BuiltinLoc = ReadSourceLocation(Record, Idx);
1534 E->RParenLoc = ReadSourceLocation(Record, Idx);
1535 E->SrcExpr = Reader.ReadSubExpr();
1536}
1537
1538//===----------------------------------------------------------------------===//
1539// ASTReader Implementation
1540//===----------------------------------------------------------------------===//
1541
Douglas Gregor1a4761e2011-11-30 23:21:26 +00001542Stmt *ASTReader::ReadStmt(ModuleFile &F) {
Argyrios Kyrtzidis919e6932010-06-28 22:28:35 +00001543 switch (ReadingKind) {
1544 case Read_Decl:
1545 case Read_Type:
Sebastian Redlc3632732010-10-05 15:59:54 +00001546 return ReadStmtFromStream(F);
Argyrios Kyrtzidis919e6932010-06-28 22:28:35 +00001547 case Read_Stmt:
Argyrios Kyrtzidisd98a2ab2010-06-29 22:46:25 +00001548 return ReadSubStmt();
Argyrios Kyrtzidis919e6932010-06-28 22:28:35 +00001549 }
1550
1551 llvm_unreachable("ReadingKind not set ?");
Argyrios Kyrtzidis919e6932010-06-28 22:28:35 +00001552}
1553
Douglas Gregor1a4761e2011-11-30 23:21:26 +00001554Expr *ASTReader::ReadExpr(ModuleFile &F) {
Sebastian Redlc3632732010-10-05 15:59:54 +00001555 return cast_or_null<Expr>(ReadStmt(F));
Argyrios Kyrtzidis919e6932010-06-28 22:28:35 +00001556}
Chris Lattner030854b2010-05-09 06:40:08 +00001557
Sebastian Redlc43b54c2010-08-18 23:56:43 +00001558Expr *ASTReader::ReadSubExpr() {
Argyrios Kyrtzidisd98a2ab2010-06-29 22:46:25 +00001559 return cast_or_null<Expr>(ReadSubStmt());
1560}
1561
Chris Lattner52e97d12009-04-27 05:41:06 +00001562// Within the bitstream, expressions are stored in Reverse Polish
1563// Notation, with each of the subexpressions preceding the
Argyrios Kyrtzidis919e6932010-06-28 22:28:35 +00001564// expression they are stored in. Subexpressions are stored from last to first.
1565// To evaluate expressions, we continue reading expressions and placing them on
1566// the stack, with expressions having operands removing those operands from the
Chris Lattner52e97d12009-04-27 05:41:06 +00001567// stack. Evaluation terminates when we see a STMT_STOP record, and
1568// the single remaining expression on the stack is our result.
Douglas Gregor1a4761e2011-11-30 23:21:26 +00001569Stmt *ASTReader::ReadStmtFromStream(ModuleFile &F) {
Argyrios Kyrtzidis919e6932010-06-28 22:28:35 +00001570
1571 ReadingKindTracker ReadingKind(Read_Stmt, *this);
Sebastian Redlc3632732010-10-05 15:59:54 +00001572 llvm::BitstreamCursor &Cursor = F.DeclsCursor;
Argyrios Kyrtzidise6f08682011-10-21 23:02:28 +00001573
1574 // Map of offset to previously deserialized stmt. The offset points
1575 /// just after the stmt record.
1576 llvm::DenseMap<uint64_t, Stmt *> StmtEntries;
Sebastian Redlc3632732010-10-05 15:59:54 +00001577
Argyrios Kyrtzidis919e6932010-06-28 22:28:35 +00001578#ifndef NDEBUG
1579 unsigned PrevNumStmts = StmtStack.size();
1580#endif
1581
Chris Lattner4c6f9522009-04-27 05:14:47 +00001582 RecordData Record;
1583 unsigned Idx;
Sebastian Redlc3632732010-10-05 15:59:54 +00001584 ASTStmtReader Reader(*this, F, Cursor, Record, Idx);
Chris Lattner4c6f9522009-04-27 05:14:47 +00001585 Stmt::EmptyShell Empty;
1586
1587 while (true) {
Chris Lattner52e97d12009-04-27 05:41:06 +00001588 unsigned Code = Cursor.ReadCode();
Chris Lattner4c6f9522009-04-27 05:14:47 +00001589 if (Code == llvm::bitc::END_BLOCK) {
Chris Lattner52e97d12009-04-27 05:41:06 +00001590 if (Cursor.ReadBlockEnd()) {
Sebastian Redl3c7f4132010-08-18 23:57:06 +00001591 Error("error at end of block in AST file");
Chris Lattner4c6f9522009-04-27 05:14:47 +00001592 return 0;
1593 }
1594 break;
1595 }
1596
1597 if (Code == llvm::bitc::ENTER_SUBBLOCK) {
1598 // No known subblocks, always skip them.
Chris Lattner52e97d12009-04-27 05:41:06 +00001599 Cursor.ReadSubBlockID();
1600 if (Cursor.SkipBlock()) {
Sebastian Redl3c7f4132010-08-18 23:57:06 +00001601 Error("malformed block record in AST file");
Chris Lattner4c6f9522009-04-27 05:14:47 +00001602 return 0;
1603 }
1604 continue;
1605 }
1606
1607 if (Code == llvm::bitc::DEFINE_ABBREV) {
Chris Lattner52e97d12009-04-27 05:41:06 +00001608 Cursor.ReadAbbrevRecord();
Chris Lattner4c6f9522009-04-27 05:14:47 +00001609 continue;
1610 }
1611
1612 Stmt *S = 0;
1613 Idx = 0;
1614 Record.clear();
1615 bool Finished = false;
Argyrios Kyrtzidise6f08682011-10-21 23:02:28 +00001616 bool IsStmtReference = false;
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001617 switch ((StmtCode)Cursor.ReadRecord(Code, Record)) {
1618 case STMT_STOP:
Chris Lattner4c6f9522009-04-27 05:14:47 +00001619 Finished = true;
1620 break;
1621
Argyrios Kyrtzidise6f08682011-10-21 23:02:28 +00001622 case STMT_REF_PTR:
1623 IsStmtReference = true;
1624 assert(StmtEntries.find(Record[0]) != StmtEntries.end() &&
1625 "No stmt was recorded for this offset reference!");
1626 S = StmtEntries[Record[Idx++]];
1627 break;
1628
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001629 case STMT_NULL_PTR:
Mike Stump1eb44332009-09-09 15:08:12 +00001630 S = 0;
Chris Lattner4c6f9522009-04-27 05:14:47 +00001631 break;
1632
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001633 case STMT_NULL:
Chris Lattner4c6f9522009-04-27 05:14:47 +00001634 S = new (Context) NullStmt(Empty);
1635 break;
1636
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001637 case STMT_COMPOUND:
Chris Lattner4c6f9522009-04-27 05:14:47 +00001638 S = new (Context) CompoundStmt(Empty);
1639 break;
1640
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001641 case STMT_CASE:
Chris Lattner4c6f9522009-04-27 05:14:47 +00001642 S = new (Context) CaseStmt(Empty);
1643 break;
1644
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001645 case STMT_DEFAULT:
Chris Lattner4c6f9522009-04-27 05:14:47 +00001646 S = new (Context) DefaultStmt(Empty);
1647 break;
1648
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001649 case STMT_LABEL:
Chris Lattner4c6f9522009-04-27 05:14:47 +00001650 S = new (Context) LabelStmt(Empty);
1651 break;
1652
Richard Smith534986f2012-04-14 00:33:13 +00001653 case STMT_ATTRIBUTED:
Alexander Kornienko49908902012-07-09 10:04:07 +00001654 S = AttributedStmt::CreateEmpty(
1655 Context,
1656 /*NumAttrs*/Record[ASTStmtReader::NumStmtFields]);
Richard Smith534986f2012-04-14 00:33:13 +00001657 break;
1658
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001659 case STMT_IF:
Chris Lattner4c6f9522009-04-27 05:14:47 +00001660 S = new (Context) IfStmt(Empty);
1661 break;
1662
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001663 case STMT_SWITCH:
Chris Lattner4c6f9522009-04-27 05:14:47 +00001664 S = new (Context) SwitchStmt(Empty);
1665 break;
1666
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001667 case STMT_WHILE:
Chris Lattner4c6f9522009-04-27 05:14:47 +00001668 S = new (Context) WhileStmt(Empty);
1669 break;
1670
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001671 case STMT_DO:
Chris Lattner4c6f9522009-04-27 05:14:47 +00001672 S = new (Context) DoStmt(Empty);
1673 break;
Mike Stump1eb44332009-09-09 15:08:12 +00001674
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001675 case STMT_FOR:
Chris Lattner4c6f9522009-04-27 05:14:47 +00001676 S = new (Context) ForStmt(Empty);
1677 break;
1678
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001679 case STMT_GOTO:
Chris Lattner4c6f9522009-04-27 05:14:47 +00001680 S = new (Context) GotoStmt(Empty);
1681 break;
Mike Stump1eb44332009-09-09 15:08:12 +00001682
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001683 case STMT_INDIRECT_GOTO:
Chris Lattner4c6f9522009-04-27 05:14:47 +00001684 S = new (Context) IndirectGotoStmt(Empty);
1685 break;
1686
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001687 case STMT_CONTINUE:
Chris Lattner4c6f9522009-04-27 05:14:47 +00001688 S = new (Context) ContinueStmt(Empty);
1689 break;
1690
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001691 case STMT_BREAK:
Chris Lattner4c6f9522009-04-27 05:14:47 +00001692 S = new (Context) BreakStmt(Empty);
1693 break;
1694
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001695 case STMT_RETURN:
Chris Lattner4c6f9522009-04-27 05:14:47 +00001696 S = new (Context) ReturnStmt(Empty);
1697 break;
1698
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001699 case STMT_DECL:
Chris Lattner4c6f9522009-04-27 05:14:47 +00001700 S = new (Context) DeclStmt(Empty);
1701 break;
1702
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001703 case STMT_ASM:
Chris Lattner4c6f9522009-04-27 05:14:47 +00001704 S = new (Context) AsmStmt(Empty);
1705 break;
1706
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001707 case EXPR_PREDEFINED:
Chris Lattner4c6f9522009-04-27 05:14:47 +00001708 S = new (Context) PredefinedExpr(Empty);
1709 break;
Mike Stump1eb44332009-09-09 15:08:12 +00001710
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001711 case EXPR_DECL_REF:
Chandler Carruth3aa81402011-05-01 23:48:14 +00001712 S = DeclRefExpr::CreateEmpty(
Douglas Gregor35942772011-09-09 21:34:22 +00001713 Context,
Chandler Carruth3aa81402011-05-01 23:48:14 +00001714 /*HasQualifier=*/Record[ASTStmtReader::NumExprFields],
1715 /*HasFoundDecl=*/Record[ASTStmtReader::NumExprFields + 1],
Abramo Bagnarae4b92762012-01-27 09:46:47 +00001716 /*HasTemplateKWAndArgsInfo=*/Record[ASTStmtReader::NumExprFields + 2],
Chandler Carruth3aa81402011-05-01 23:48:14 +00001717 /*NumTemplateArgs=*/Record[ASTStmtReader::NumExprFields + 2] ?
John McCallf4b88a42012-03-10 09:33:50 +00001718 Record[ASTStmtReader::NumExprFields + 5] : 0);
Chris Lattner4c6f9522009-04-27 05:14:47 +00001719 break;
Mike Stump1eb44332009-09-09 15:08:12 +00001720
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001721 case EXPR_INTEGER_LITERAL:
Douglas Gregor35942772011-09-09 21:34:22 +00001722 S = IntegerLiteral::Create(Context, Empty);
Chris Lattner4c6f9522009-04-27 05:14:47 +00001723 break;
Mike Stump1eb44332009-09-09 15:08:12 +00001724
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001725 case EXPR_FLOATING_LITERAL:
Douglas Gregor35942772011-09-09 21:34:22 +00001726 S = FloatingLiteral::Create(Context, Empty);
Chris Lattner4c6f9522009-04-27 05:14:47 +00001727 break;
Mike Stump1eb44332009-09-09 15:08:12 +00001728
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001729 case EXPR_IMAGINARY_LITERAL:
Chris Lattner4c6f9522009-04-27 05:14:47 +00001730 S = new (Context) ImaginaryLiteral(Empty);
1731 break;
1732
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001733 case EXPR_STRING_LITERAL:
Douglas Gregor35942772011-09-09 21:34:22 +00001734 S = StringLiteral::CreateEmpty(Context,
Sebastian Redl60adf4a2010-08-18 23:56:52 +00001735 Record[ASTStmtReader::NumExprFields + 1]);
Chris Lattner4c6f9522009-04-27 05:14:47 +00001736 break;
1737
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001738 case EXPR_CHARACTER_LITERAL:
Chris Lattner4c6f9522009-04-27 05:14:47 +00001739 S = new (Context) CharacterLiteral(Empty);
1740 break;
1741
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001742 case EXPR_PAREN:
Chris Lattner4c6f9522009-04-27 05:14:47 +00001743 S = new (Context) ParenExpr(Empty);
1744 break;
1745
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001746 case EXPR_PAREN_LIST:
Argyrios Kyrtzidis37bdfe22010-06-30 08:49:18 +00001747 S = new (Context) ParenListExpr(Empty);
1748 break;
1749
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001750 case EXPR_UNARY_OPERATOR:
Chris Lattner4c6f9522009-04-27 05:14:47 +00001751 S = new (Context) UnaryOperator(Empty);
1752 break;
1753
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001754 case EXPR_OFFSETOF:
Douglas Gregor35942772011-09-09 21:34:22 +00001755 S = OffsetOfExpr::CreateEmpty(Context,
Sebastian Redl60adf4a2010-08-18 23:56:52 +00001756 Record[ASTStmtReader::NumExprFields],
1757 Record[ASTStmtReader::NumExprFields + 1]);
Douglas Gregor8ecdb652010-04-28 22:16:22 +00001758 break;
1759
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001760 case EXPR_SIZEOF_ALIGN_OF:
Peter Collingbournef4e3cfb2011-03-11 19:24:49 +00001761 S = new (Context) UnaryExprOrTypeTraitExpr(Empty);
Chris Lattner4c6f9522009-04-27 05:14:47 +00001762 break;
1763
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001764 case EXPR_ARRAY_SUBSCRIPT:
Chris Lattner4c6f9522009-04-27 05:14:47 +00001765 S = new (Context) ArraySubscriptExpr(Empty);
1766 break;
1767
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001768 case EXPR_CALL:
Douglas Gregor35942772011-09-09 21:34:22 +00001769 S = new (Context) CallExpr(Context, Stmt::CallExprClass, Empty);
Chris Lattner4c6f9522009-04-27 05:14:47 +00001770 break;
1771
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001772 case EXPR_MEMBER: {
Argyrios Kyrtzidis663e3802010-07-08 13:09:47 +00001773 // We load everything here and fully initialize it at creation.
1774 // That way we can use MemberExpr::Create and don't have to duplicate its
1775 // logic with a MemberExpr::CreateEmpty.
1776
1777 assert(Idx == 0);
Douglas Gregor40d96a62011-02-28 21:54:11 +00001778 NestedNameSpecifierLoc QualifierLoc;
Argyrios Kyrtzidis663e3802010-07-08 13:09:47 +00001779 if (Record[Idx++]) { // HasQualifier.
Douglas Gregor40d96a62011-02-28 21:54:11 +00001780 QualifierLoc = ReadNestedNameSpecifierLoc(F, Record, Idx);
Argyrios Kyrtzidis663e3802010-07-08 13:09:47 +00001781 }
1782
Abramo Bagnarae4b92762012-01-27 09:46:47 +00001783 SourceLocation TemplateKWLoc;
Argyrios Kyrtzidis663e3802010-07-08 13:09:47 +00001784 TemplateArgumentListInfo ArgInfo;
Abramo Bagnarae4b92762012-01-27 09:46:47 +00001785 bool HasTemplateKWAndArgsInfo = Record[Idx++];
1786 if (HasTemplateKWAndArgsInfo) {
1787 TemplateKWLoc = ReadSourceLocation(F, Record, Idx);
Douglas Gregordef03542011-02-04 12:01:24 +00001788 unsigned NumTemplateArgs = Record[Idx++];
Sebastian Redlc3632732010-10-05 15:59:54 +00001789 ArgInfo.setLAngleLoc(ReadSourceLocation(F, Record, Idx));
1790 ArgInfo.setRAngleLoc(ReadSourceLocation(F, Record, Idx));
Argyrios Kyrtzidis663e3802010-07-08 13:09:47 +00001791 for (unsigned i = 0; i != NumTemplateArgs; ++i)
Sebastian Redlc3632732010-10-05 15:59:54 +00001792 ArgInfo.addArgument(ReadTemplateArgumentLoc(F, Record, Idx));
Argyrios Kyrtzidis663e3802010-07-08 13:09:47 +00001793 }
Abramo Bagnara7cc58b42011-10-05 07:56:41 +00001794
1795 bool HadMultipleCandidates = Record[Idx++];
1796
Douglas Gregor409448c2011-07-21 22:35:25 +00001797 NamedDecl *FoundD = ReadDeclAs<NamedDecl>(F, Record, Idx);
Argyrios Kyrtzidis663e3802010-07-08 13:09:47 +00001798 AccessSpecifier AS = (AccessSpecifier)Record[Idx++];
1799 DeclAccessPair FoundDecl = DeclAccessPair::make(FoundD, AS);
1800
Douglas Gregor393f2492011-07-22 00:38:23 +00001801 QualType T = readType(F, Record, Idx);
John McCallf89e55a2010-11-18 06:31:45 +00001802 ExprValueKind VK = static_cast<ExprValueKind>(Record[Idx++]);
1803 ExprObjectKind OK = static_cast<ExprObjectKind>(Record[Idx++]);
Argyrios Kyrtzidis663e3802010-07-08 13:09:47 +00001804 Expr *Base = ReadSubExpr();
Douglas Gregor409448c2011-07-21 22:35:25 +00001805 ValueDecl *MemberD = ReadDeclAs<ValueDecl>(F, Record, Idx);
Sebastian Redlc3632732010-10-05 15:59:54 +00001806 SourceLocation MemberLoc = ReadSourceLocation(F, Record, Idx);
Abramo Bagnara25777432010-08-11 22:01:17 +00001807 DeclarationNameInfo MemberNameInfo(MemberD->getDeclName(), MemberLoc);
Argyrios Kyrtzidis663e3802010-07-08 13:09:47 +00001808 bool IsArrow = Record[Idx++];
1809
Douglas Gregor35942772011-09-09 21:34:22 +00001810 S = MemberExpr::Create(Context, Base, IsArrow, QualifierLoc,
Abramo Bagnarae4b92762012-01-27 09:46:47 +00001811 TemplateKWLoc, MemberD, FoundDecl, MemberNameInfo,
1812 HasTemplateKWAndArgsInfo ? &ArgInfo : 0,
1813 T, VK, OK);
Argyrios Kyrtzidis40451072010-10-15 18:21:24 +00001814 ReadDeclarationNameLoc(F, cast<MemberExpr>(S)->MemberDNLoc,
1815 MemberD->getDeclName(), Record, Idx);
Abramo Bagnara7cc58b42011-10-05 07:56:41 +00001816 if (HadMultipleCandidates)
1817 cast<MemberExpr>(S)->setHadMultipleCandidates(true);
Chris Lattner4c6f9522009-04-27 05:14:47 +00001818 break;
Argyrios Kyrtzidis663e3802010-07-08 13:09:47 +00001819 }
Chris Lattner4c6f9522009-04-27 05:14:47 +00001820
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001821 case EXPR_BINARY_OPERATOR:
Chris Lattner4c6f9522009-04-27 05:14:47 +00001822 S = new (Context) BinaryOperator(Empty);
1823 break;
1824
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001825 case EXPR_COMPOUND_ASSIGN_OPERATOR:
Chris Lattner4c6f9522009-04-27 05:14:47 +00001826 S = new (Context) CompoundAssignOperator(Empty);
1827 break;
1828
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001829 case EXPR_CONDITIONAL_OPERATOR:
Chris Lattner4c6f9522009-04-27 05:14:47 +00001830 S = new (Context) ConditionalOperator(Empty);
1831 break;
1832
John McCall56ca35d2011-02-17 10:25:35 +00001833 case EXPR_BINARY_CONDITIONAL_OPERATOR:
1834 S = new (Context) BinaryConditionalOperator(Empty);
1835 break;
1836
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001837 case EXPR_IMPLICIT_CAST:
Douglas Gregor35942772011-09-09 21:34:22 +00001838 S = ImplicitCastExpr::CreateEmpty(Context,
Sebastian Redl60adf4a2010-08-18 23:56:52 +00001839 /*PathSize*/ Record[ASTStmtReader::NumExprFields]);
Chris Lattner4c6f9522009-04-27 05:14:47 +00001840 break;
1841
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001842 case EXPR_CSTYLE_CAST:
Douglas Gregor35942772011-09-09 21:34:22 +00001843 S = CStyleCastExpr::CreateEmpty(Context,
Sebastian Redl60adf4a2010-08-18 23:56:52 +00001844 /*PathSize*/ Record[ASTStmtReader::NumExprFields]);
Chris Lattner4c6f9522009-04-27 05:14:47 +00001845 break;
1846
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001847 case EXPR_COMPOUND_LITERAL:
Chris Lattner4c6f9522009-04-27 05:14:47 +00001848 S = new (Context) CompoundLiteralExpr(Empty);
1849 break;
1850
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001851 case EXPR_EXT_VECTOR_ELEMENT:
Chris Lattner4c6f9522009-04-27 05:14:47 +00001852 S = new (Context) ExtVectorElementExpr(Empty);
1853 break;
1854
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001855 case EXPR_INIT_LIST:
Douglas Gregor35942772011-09-09 21:34:22 +00001856 S = new (Context) InitListExpr(getContext(), Empty);
Chris Lattner4c6f9522009-04-27 05:14:47 +00001857 break;
1858
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001859 case EXPR_DESIGNATED_INIT:
Douglas Gregor35942772011-09-09 21:34:22 +00001860 S = DesignatedInitExpr::CreateEmpty(Context,
Sebastian Redl60adf4a2010-08-18 23:56:52 +00001861 Record[ASTStmtReader::NumExprFields] - 1);
Mike Stump1eb44332009-09-09 15:08:12 +00001862
Chris Lattner4c6f9522009-04-27 05:14:47 +00001863 break;
1864
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001865 case EXPR_IMPLICIT_VALUE_INIT:
Chris Lattner4c6f9522009-04-27 05:14:47 +00001866 S = new (Context) ImplicitValueInitExpr(Empty);
1867 break;
1868
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001869 case EXPR_VA_ARG:
Chris Lattner4c6f9522009-04-27 05:14:47 +00001870 S = new (Context) VAArgExpr(Empty);
1871 break;
1872
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001873 case EXPR_ADDR_LABEL:
Chris Lattner4c6f9522009-04-27 05:14:47 +00001874 S = new (Context) AddrLabelExpr(Empty);
1875 break;
1876
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001877 case EXPR_STMT:
Chris Lattner4c6f9522009-04-27 05:14:47 +00001878 S = new (Context) StmtExpr(Empty);
1879 break;
1880
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001881 case EXPR_CHOOSE:
Chris Lattner4c6f9522009-04-27 05:14:47 +00001882 S = new (Context) ChooseExpr(Empty);
1883 break;
1884
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001885 case EXPR_GNU_NULL:
Chris Lattner4c6f9522009-04-27 05:14:47 +00001886 S = new (Context) GNUNullExpr(Empty);
1887 break;
1888
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001889 case EXPR_SHUFFLE_VECTOR:
Chris Lattner4c6f9522009-04-27 05:14:47 +00001890 S = new (Context) ShuffleVectorExpr(Empty);
1891 break;
Mike Stump1eb44332009-09-09 15:08:12 +00001892
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001893 case EXPR_BLOCK:
Chris Lattner4c6f9522009-04-27 05:14:47 +00001894 S = new (Context) BlockExpr(Empty);
1895 break;
1896
Peter Collingbournef111d932011-04-15 00:35:48 +00001897 case EXPR_GENERIC_SELECTION:
1898 S = new (Context) GenericSelectionExpr(Empty);
1899 break;
1900
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001901 case EXPR_OBJC_STRING_LITERAL:
Chris Lattner4c6f9522009-04-27 05:14:47 +00001902 S = new (Context) ObjCStringLiteral(Empty);
1903 break;
Patrick Beardeb382ec2012-04-19 00:25:12 +00001904 case EXPR_OBJC_BOXED_EXPRESSION:
1905 S = new (Context) ObjCBoxedExpr(Empty);
Ted Kremenekebcb57a2012-03-06 20:05:56 +00001906 break;
1907 case EXPR_OBJC_ARRAY_LITERAL:
1908 S = ObjCArrayLiteral::CreateEmpty(Context,
1909 Record[ASTStmtReader::NumExprFields]);
1910 break;
1911 case EXPR_OBJC_DICTIONARY_LITERAL:
1912 S = ObjCDictionaryLiteral::CreateEmpty(Context,
1913 Record[ASTStmtReader::NumExprFields],
1914 Record[ASTStmtReader::NumExprFields + 1]);
1915 break;
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001916 case EXPR_OBJC_ENCODE:
Chris Lattner4c6f9522009-04-27 05:14:47 +00001917 S = new (Context) ObjCEncodeExpr(Empty);
1918 break;
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001919 case EXPR_OBJC_SELECTOR_EXPR:
Chris Lattner4c6f9522009-04-27 05:14:47 +00001920 S = new (Context) ObjCSelectorExpr(Empty);
1921 break;
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001922 case EXPR_OBJC_PROTOCOL_EXPR:
Chris Lattner4c6f9522009-04-27 05:14:47 +00001923 S = new (Context) ObjCProtocolExpr(Empty);
1924 break;
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001925 case EXPR_OBJC_IVAR_REF_EXPR:
Chris Lattner4c6f9522009-04-27 05:14:47 +00001926 S = new (Context) ObjCIvarRefExpr(Empty);
1927 break;
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001928 case EXPR_OBJC_PROPERTY_REF_EXPR:
Chris Lattner4c6f9522009-04-27 05:14:47 +00001929 S = new (Context) ObjCPropertyRefExpr(Empty);
1930 break;
Ted Kremenekebcb57a2012-03-06 20:05:56 +00001931 case EXPR_OBJC_SUBSCRIPT_REF_EXPR:
1932 S = new (Context) ObjCSubscriptRefExpr(Empty);
1933 break;
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001934 case EXPR_OBJC_KVC_REF_EXPR:
John McCall12f78a62010-12-02 01:19:52 +00001935 llvm_unreachable("mismatching AST file");
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001936 case EXPR_OBJC_MESSAGE_EXPR:
Douglas Gregor35942772011-09-09 21:34:22 +00001937 S = ObjCMessageExpr::CreateEmpty(Context,
Argyrios Kyrtzidis20718082011-10-03 06:36:51 +00001938 Record[ASTStmtReader::NumExprFields],
1939 Record[ASTStmtReader::NumExprFields + 1]);
Chris Lattner4c6f9522009-04-27 05:14:47 +00001940 break;
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001941 case EXPR_OBJC_ISA:
Steve Narofff242b1b2009-07-24 17:54:45 +00001942 S = new (Context) ObjCIsaExpr(Empty);
1943 break;
John McCallf85e1932011-06-15 23:02:42 +00001944 case EXPR_OBJC_INDIRECT_COPY_RESTORE:
1945 S = new (Context) ObjCIndirectCopyRestoreExpr(Empty);
1946 break;
1947 case EXPR_OBJC_BRIDGED_CAST:
1948 S = new (Context) ObjCBridgedCastExpr(Empty);
1949 break;
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001950 case STMT_OBJC_FOR_COLLECTION:
Chris Lattner4c6f9522009-04-27 05:14:47 +00001951 S = new (Context) ObjCForCollectionStmt(Empty);
1952 break;
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001953 case STMT_OBJC_CATCH:
Chris Lattner4c6f9522009-04-27 05:14:47 +00001954 S = new (Context) ObjCAtCatchStmt(Empty);
1955 break;
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001956 case STMT_OBJC_FINALLY:
Chris Lattner4c6f9522009-04-27 05:14:47 +00001957 S = new (Context) ObjCAtFinallyStmt(Empty);
1958 break;
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001959 case STMT_OBJC_AT_TRY:
Douglas Gregor35942772011-09-09 21:34:22 +00001960 S = ObjCAtTryStmt::CreateEmpty(Context,
Sebastian Redl60adf4a2010-08-18 23:56:52 +00001961 Record[ASTStmtReader::NumStmtFields],
1962 Record[ASTStmtReader::NumStmtFields + 1]);
Chris Lattner4c6f9522009-04-27 05:14:47 +00001963 break;
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001964 case STMT_OBJC_AT_SYNCHRONIZED:
Chris Lattner4c6f9522009-04-27 05:14:47 +00001965 S = new (Context) ObjCAtSynchronizedStmt(Empty);
1966 break;
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001967 case STMT_OBJC_AT_THROW:
Chris Lattner4c6f9522009-04-27 05:14:47 +00001968 S = new (Context) ObjCAtThrowStmt(Empty);
1969 break;
John McCallf85e1932011-06-15 23:02:42 +00001970 case STMT_OBJC_AUTORELEASE_POOL:
1971 S = new (Context) ObjCAutoreleasePoolStmt(Empty);
1972 break;
Ted Kremenekebcb57a2012-03-06 20:05:56 +00001973 case EXPR_OBJC_BOOL_LITERAL:
1974 S = new (Context) ObjCBoolLiteralExpr(Empty);
1975 break;
John McCall7110fd62011-07-15 07:00:14 +00001976 case STMT_SEH_EXCEPT:
1977 S = new (Context) SEHExceptStmt(Empty);
1978 break;
1979 case STMT_SEH_FINALLY:
1980 S = new (Context) SEHFinallyStmt(Empty);
1981 break;
1982 case STMT_SEH_TRY:
1983 S = new (Context) SEHTryStmt(Empty);
1984 break;
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001985 case STMT_CXX_CATCH:
Argyrios Kyrtzidis7cb45e32010-07-22 16:03:56 +00001986 S = new (Context) CXXCatchStmt(Empty);
1987 break;
1988
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001989 case STMT_CXX_TRY:
Douglas Gregor35942772011-09-09 21:34:22 +00001990 S = CXXTryStmt::Create(Context, Empty,
Sebastian Redl60adf4a2010-08-18 23:56:52 +00001991 /*NumHandlers=*/Record[ASTStmtReader::NumStmtFields]);
Argyrios Kyrtzidis7cb45e32010-07-22 16:03:56 +00001992 break;
1993
Richard Smithad762fc2011-04-14 22:09:26 +00001994 case STMT_CXX_FOR_RANGE:
1995 S = new (Context) CXXForRangeStmt(Empty);
1996 break;
1997
Douglas Gregorba0513d2011-10-25 01:33:02 +00001998 case STMT_MS_DEPENDENT_EXISTS:
1999 S = new (Context) MSDependentExistsStmt(SourceLocation(), true,
2000 NestedNameSpecifierLoc(),
2001 DeclarationNameInfo(),
2002 0);
2003 break;
2004
Sebastian Redl8538e8d2010-08-18 23:57:32 +00002005 case EXPR_CXX_OPERATOR_CALL:
Douglas Gregor35942772011-09-09 21:34:22 +00002006 S = new (Context) CXXOperatorCallExpr(Context, Empty);
Argyrios Kyrtzidisba0a9002009-07-14 03:19:21 +00002007 break;
Chris Lattner1817bd42010-05-09 05:36:05 +00002008
Sebastian Redl8538e8d2010-08-18 23:57:32 +00002009 case EXPR_CXX_MEMBER_CALL:
Douglas Gregor35942772011-09-09 21:34:22 +00002010 S = new (Context) CXXMemberCallExpr(Context, Empty);
Chris Lattner1817bd42010-05-09 05:36:05 +00002011 break;
Douglas Gregor39da0b82009-09-09 23:08:42 +00002012
Sebastian Redl8538e8d2010-08-18 23:57:32 +00002013 case EXPR_CXX_CONSTRUCT:
Argyrios Kyrtzidis6d00c132010-07-10 11:46:15 +00002014 S = new (Context) CXXConstructExpr(Empty);
2015 break;
2016
Sebastian Redl8538e8d2010-08-18 23:57:32 +00002017 case EXPR_CXX_TEMPORARY_OBJECT:
Argyrios Kyrtzidis6d00c132010-07-10 11:46:15 +00002018 S = new (Context) CXXTemporaryObjectExpr(Empty);
Douglas Gregor39da0b82009-09-09 23:08:42 +00002019 break;
Sam Weinigce757a72010-01-16 21:21:01 +00002020
Sebastian Redl8538e8d2010-08-18 23:57:32 +00002021 case EXPR_CXX_STATIC_CAST:
Douglas Gregor35942772011-09-09 21:34:22 +00002022 S = CXXStaticCastExpr::CreateEmpty(Context,
Sebastian Redl60adf4a2010-08-18 23:56:52 +00002023 /*PathSize*/ Record[ASTStmtReader::NumExprFields]);
Sam Weinigce757a72010-01-16 21:21:01 +00002024 break;
2025
Sebastian Redl8538e8d2010-08-18 23:57:32 +00002026 case EXPR_CXX_DYNAMIC_CAST:
Douglas Gregor35942772011-09-09 21:34:22 +00002027 S = CXXDynamicCastExpr::CreateEmpty(Context,
Sebastian Redl60adf4a2010-08-18 23:56:52 +00002028 /*PathSize*/ Record[ASTStmtReader::NumExprFields]);
Sam Weinigce757a72010-01-16 21:21:01 +00002029 break;
2030
Sebastian Redl8538e8d2010-08-18 23:57:32 +00002031 case EXPR_CXX_REINTERPRET_CAST:
Douglas Gregor35942772011-09-09 21:34:22 +00002032 S = CXXReinterpretCastExpr::CreateEmpty(Context,
Sebastian Redl60adf4a2010-08-18 23:56:52 +00002033 /*PathSize*/ Record[ASTStmtReader::NumExprFields]);
Sam Weinigce757a72010-01-16 21:21:01 +00002034 break;
2035
Sebastian Redl8538e8d2010-08-18 23:57:32 +00002036 case EXPR_CXX_CONST_CAST:
Douglas Gregor35942772011-09-09 21:34:22 +00002037 S = CXXConstCastExpr::CreateEmpty(Context);
Sam Weinigce757a72010-01-16 21:21:01 +00002038 break;
2039
Sebastian Redl8538e8d2010-08-18 23:57:32 +00002040 case EXPR_CXX_FUNCTIONAL_CAST:
Douglas Gregor35942772011-09-09 21:34:22 +00002041 S = CXXFunctionalCastExpr::CreateEmpty(Context,
Sebastian Redl60adf4a2010-08-18 23:56:52 +00002042 /*PathSize*/ Record[ASTStmtReader::NumExprFields]);
Sam Weinigce757a72010-01-16 21:21:01 +00002043 break;
2044
Richard Smith9fcce652012-03-07 08:35:16 +00002045 case EXPR_USER_DEFINED_LITERAL:
2046 S = new (Context) UserDefinedLiteral(Context, Empty);
2047 break;
2048
Sebastian Redl8538e8d2010-08-18 23:57:32 +00002049 case EXPR_CXX_BOOL_LITERAL:
Sam Weinigeb7f9612010-02-07 06:32:43 +00002050 S = new (Context) CXXBoolLiteralExpr(Empty);
2051 break;
Sam Weinigce757a72010-01-16 21:21:01 +00002052
Sebastian Redl8538e8d2010-08-18 23:57:32 +00002053 case EXPR_CXX_NULL_PTR_LITERAL:
Sam Weinigeb7f9612010-02-07 06:32:43 +00002054 S = new (Context) CXXNullPtrLiteralExpr(Empty);
2055 break;
Sebastian Redl8538e8d2010-08-18 23:57:32 +00002056 case EXPR_CXX_TYPEID_EXPR:
Chris Lattner14ab24f2010-05-09 06:03:39 +00002057 S = new (Context) CXXTypeidExpr(Empty, true);
2058 break;
Sebastian Redl8538e8d2010-08-18 23:57:32 +00002059 case EXPR_CXX_TYPEID_TYPE:
Chris Lattner14ab24f2010-05-09 06:03:39 +00002060 S = new (Context) CXXTypeidExpr(Empty, false);
2061 break;
Francois Pichet01b7c302010-09-08 12:20:18 +00002062 case EXPR_CXX_UUIDOF_EXPR:
2063 S = new (Context) CXXUuidofExpr(Empty, true);
2064 break;
2065 case EXPR_CXX_UUIDOF_TYPE:
2066 S = new (Context) CXXUuidofExpr(Empty, false);
2067 break;
Sebastian Redl8538e8d2010-08-18 23:57:32 +00002068 case EXPR_CXX_THIS:
Chris Lattner2fbdfcd2010-05-09 06:15:05 +00002069 S = new (Context) CXXThisExpr(Empty);
2070 break;
Sebastian Redl8538e8d2010-08-18 23:57:32 +00002071 case EXPR_CXX_THROW:
Chris Lattner2fbdfcd2010-05-09 06:15:05 +00002072 S = new (Context) CXXThrowExpr(Empty);
2073 break;
Sebastian Redl8538e8d2010-08-18 23:57:32 +00002074 case EXPR_CXX_DEFAULT_ARG: {
Sebastian Redl60adf4a2010-08-18 23:56:52 +00002075 bool HasOtherExprStored = Record[ASTStmtReader::NumExprFields];
Argyrios Kyrtzidis8a507332010-07-02 23:30:15 +00002076 if (HasOtherExprStored) {
2077 Expr *SubExpr = ReadSubExpr();
Douglas Gregor35942772011-09-09 21:34:22 +00002078 S = CXXDefaultArgExpr::Create(Context, SourceLocation(), 0, SubExpr);
Argyrios Kyrtzidis8a507332010-07-02 23:30:15 +00002079 } else
2080 S = new (Context) CXXDefaultArgExpr(Empty);
Chris Lattner030854b2010-05-09 06:40:08 +00002081 break;
Argyrios Kyrtzidis8a507332010-07-02 23:30:15 +00002082 }
Sebastian Redl8538e8d2010-08-18 23:57:32 +00002083 case EXPR_CXX_BIND_TEMPORARY:
Chris Lattnerd2598362010-05-10 00:25:06 +00002084 S = new (Context) CXXBindTemporaryExpr(Empty);
2085 break;
Douglas Gregore2ca6d42010-09-02 21:50:02 +00002086
Sebastian Redl8538e8d2010-08-18 23:57:32 +00002087 case EXPR_CXX_SCALAR_VALUE_INIT:
Douglas Gregored8abf12010-07-08 06:14:04 +00002088 S = new (Context) CXXScalarValueInitExpr(Empty);
Chris Lattner59218632010-05-10 01:22:27 +00002089 break;
Sebastian Redl8538e8d2010-08-18 23:57:32 +00002090 case EXPR_CXX_NEW:
Chris Lattner59218632010-05-10 01:22:27 +00002091 S = new (Context) CXXNewExpr(Empty);
2092 break;
Sebastian Redl8538e8d2010-08-18 23:57:32 +00002093 case EXPR_CXX_DELETE:
Argyrios Kyrtzidis95fc98c2010-06-22 17:07:59 +00002094 S = new (Context) CXXDeleteExpr(Empty);
2095 break;
Sebastian Redl8538e8d2010-08-18 23:57:32 +00002096 case EXPR_CXX_PSEUDO_DESTRUCTOR:
Argyrios Kyrtzidisde4bd182010-06-28 09:32:03 +00002097 S = new (Context) CXXPseudoDestructorExpr(Empty);
2098 break;
Chris Lattner59218632010-05-10 01:22:27 +00002099
John McCall4765fa02010-12-06 08:20:24 +00002100 case EXPR_EXPR_WITH_CLEANUPS:
John McCall80ee6e82011-11-10 05:35:25 +00002101 S = ExprWithCleanups::Create(Context, Empty,
2102 Record[ASTStmtReader::NumExprFields]);
Chris Lattnerd2598362010-05-10 00:25:06 +00002103 break;
Argyrios Kyrtzidis8dfbd8b2010-06-24 08:57:31 +00002104
Sebastian Redl8538e8d2010-08-18 23:57:32 +00002105 case EXPR_CXX_DEPENDENT_SCOPE_MEMBER:
Douglas Gregor35942772011-09-09 21:34:22 +00002106 S = CXXDependentScopeMemberExpr::CreateEmpty(Context,
Abramo Bagnarae4b92762012-01-27 09:46:47 +00002107 /*HasTemplateKWAndArgsInfo=*/Record[ASTStmtReader::NumExprFields],
Douglas Gregordef03542011-02-04 12:01:24 +00002108 /*NumTemplateArgs=*/Record[ASTStmtReader::NumExprFields]
2109 ? Record[ASTStmtReader::NumExprFields + 1]
2110 : 0);
Argyrios Kyrtzidis8dfbd8b2010-06-24 08:57:31 +00002111 break;
2112
Sebastian Redl8538e8d2010-08-18 23:57:32 +00002113 case EXPR_CXX_DEPENDENT_SCOPE_DECL_REF:
Douglas Gregor35942772011-09-09 21:34:22 +00002114 S = DependentScopeDeclRefExpr::CreateEmpty(Context,
Abramo Bagnarae4b92762012-01-27 09:46:47 +00002115 /*HasTemplateKWAndArgsInfo=*/Record[ASTStmtReader::NumExprFields],
Douglas Gregordef03542011-02-04 12:01:24 +00002116 /*NumTemplateArgs=*/Record[ASTStmtReader::NumExprFields]
2117 ? Record[ASTStmtReader::NumExprFields + 1]
2118 : 0);
Argyrios Kyrtzidis12dffcd2010-06-28 09:31:56 +00002119 break;
2120
Sebastian Redl8538e8d2010-08-18 23:57:32 +00002121 case EXPR_CXX_UNRESOLVED_CONSTRUCT:
Douglas Gregor35942772011-09-09 21:34:22 +00002122 S = CXXUnresolvedConstructExpr::CreateEmpty(Context,
Sebastian Redl60adf4a2010-08-18 23:56:52 +00002123 /*NumArgs=*/Record[ASTStmtReader::NumExprFields]);
Argyrios Kyrtzidisa77eb082010-06-25 09:03:26 +00002124 break;
2125
Sebastian Redl8538e8d2010-08-18 23:57:32 +00002126 case EXPR_CXX_UNRESOLVED_MEMBER:
Douglas Gregor35942772011-09-09 21:34:22 +00002127 S = UnresolvedMemberExpr::CreateEmpty(Context,
Abramo Bagnarae4b92762012-01-27 09:46:47 +00002128 /*HasTemplateKWAndArgsInfo=*/Record[ASTStmtReader::NumExprFields],
Douglas Gregordef03542011-02-04 12:01:24 +00002129 /*NumTemplateArgs=*/Record[ASTStmtReader::NumExprFields]
2130 ? Record[ASTStmtReader::NumExprFields + 1]
2131 : 0);
Argyrios Kyrtzidis8dfbd8b2010-06-24 08:57:31 +00002132 break;
Argyrios Kyrtzidisbd65bb52010-06-25 09:03:34 +00002133
Sebastian Redl8538e8d2010-08-18 23:57:32 +00002134 case EXPR_CXX_UNRESOLVED_LOOKUP:
Douglas Gregor35942772011-09-09 21:34:22 +00002135 S = UnresolvedLookupExpr::CreateEmpty(Context,
Abramo Bagnarae4b92762012-01-27 09:46:47 +00002136 /*HasTemplateKWAndArgsInfo=*/Record[ASTStmtReader::NumExprFields],
Douglas Gregordef03542011-02-04 12:01:24 +00002137 /*NumTemplateArgs=*/Record[ASTStmtReader::NumExprFields]
2138 ? Record[ASTStmtReader::NumExprFields + 1]
2139 : 0);
Argyrios Kyrtzidisbd65bb52010-06-25 09:03:34 +00002140 break;
Argyrios Kyrtzidis6d00c132010-07-10 11:46:15 +00002141
Sebastian Redl8538e8d2010-08-18 23:57:32 +00002142 case EXPR_CXX_UNARY_TYPE_TRAIT:
Argyrios Kyrtzidis6d00c132010-07-10 11:46:15 +00002143 S = new (Context) UnaryTypeTraitExpr(Empty);
2144 break;
Sebastian Redl6b219d02010-09-10 20:55:54 +00002145
Francois Pichetf1872372010-12-08 22:35:30 +00002146 case EXPR_BINARY_TYPE_TRAIT:
Francois Pichet6ad6f282010-12-07 00:08:36 +00002147 S = new (Context) BinaryTypeTraitExpr(Empty);
2148 break;
2149
Douglas Gregor4ca8ac22012-02-24 07:38:34 +00002150 case EXPR_TYPE_TRAIT:
2151 S = TypeTraitExpr::CreateDeserialized(Context,
2152 Record[ASTStmtReader::NumExprFields]);
2153 break;
2154
John Wiegley21ff2e52011-04-28 00:16:57 +00002155 case EXPR_ARRAY_TYPE_TRAIT:
2156 S = new (Context) ArrayTypeTraitExpr(Empty);
2157 break;
2158
John Wiegley55262202011-04-25 06:54:41 +00002159 case EXPR_CXX_EXPRESSION_TRAIT:
2160 S = new (Context) ExpressionTraitExpr(Empty);
2161 break;
2162
Sebastian Redl6b219d02010-09-10 20:55:54 +00002163 case EXPR_CXX_NOEXCEPT:
2164 S = new (Context) CXXNoexceptExpr(Empty);
2165 break;
John McCall7cd7d1a2010-11-15 23:31:06 +00002166
Douglas Gregorbe230c32011-01-03 17:17:50 +00002167 case EXPR_PACK_EXPANSION:
2168 S = new (Context) PackExpansionExpr(Empty);
2169 break;
2170
Douglas Gregoree8aff02011-01-04 17:33:58 +00002171 case EXPR_SIZEOF_PACK:
2172 S = new (Context) SizeOfPackExpr(Empty);
2173 break;
2174
John McCall7110fd62011-07-15 07:00:14 +00002175 case EXPR_SUBST_NON_TYPE_TEMPLATE_PARM:
2176 S = new (Context) SubstNonTypeTemplateParmExpr(Empty);
2177 break;
2178
Douglas Gregorc7793c72011-01-15 01:15:58 +00002179 case EXPR_SUBST_NON_TYPE_TEMPLATE_PARM_PACK:
2180 S = new (Context) SubstNonTypeTemplateParmPackExpr(Empty);
2181 break;
2182
Douglas Gregor03e80032011-06-21 17:03:29 +00002183 case EXPR_MATERIALIZE_TEMPORARY:
2184 S = new (Context) MaterializeTemporaryExpr(Empty);
2185 break;
2186
Argyrios Kyrtzidis8bc27822011-12-03 03:49:52 +00002187 case EXPR_OPAQUE_VALUE:
2188 S = new (Context) OpaqueValueExpr(Empty);
John McCall7cd7d1a2010-11-15 23:31:06 +00002189 break;
Peter Collingbournee08ce652011-02-09 21:07:24 +00002190
2191 case EXPR_CUDA_KERNEL_CALL:
Douglas Gregor35942772011-09-09 21:34:22 +00002192 S = new (Context) CUDAKernelCallExpr(Context, Empty);
Peter Collingbournee08ce652011-02-09 21:07:24 +00002193 break;
Tanya Lattner61eee0c2011-06-04 00:47:47 +00002194
2195 case EXPR_ASTYPE:
2196 S = new (Context) AsTypeExpr(Empty);
2197 break;
Eli Friedman276b0612011-10-11 02:20:01 +00002198
John McCall4b9c2d22011-11-06 09:01:30 +00002199 case EXPR_PSEUDO_OBJECT: {
2200 unsigned numSemanticExprs = Record[ASTStmtReader::NumExprFields];
2201 S = PseudoObjectExpr::Create(Context, Empty, numSemanticExprs);
2202 break;
2203 }
2204
Eli Friedman276b0612011-10-11 02:20:01 +00002205 case EXPR_ATOMIC:
2206 S = new (Context) AtomicExpr(Empty);
2207 break;
Douglas Gregor9d36f5d2012-02-14 17:54:36 +00002208
2209 case EXPR_LAMBDA: {
2210 unsigned NumCaptures = Record[ASTStmtReader::NumExprFields];
2211 unsigned NumArrayIndexVars = Record[ASTStmtReader::NumExprFields + 1];
2212 S = LambdaExpr::CreateDeserialized(Context, NumCaptures,
2213 NumArrayIndexVars);
2214 break;
2215 }
Chris Lattner4c6f9522009-04-27 05:14:47 +00002216 }
Argyrios Kyrtzidis6d00c132010-07-10 11:46:15 +00002217
Chris Lattner4c6f9522009-04-27 05:14:47 +00002218 // We hit a STMT_STOP, so we're done with this expression.
2219 if (Finished)
2220 break;
2221
2222 ++NumStatementsRead;
2223
Argyrios Kyrtzidise6f08682011-10-21 23:02:28 +00002224 if (S && !IsStmtReference) {
Argyrios Kyrtzidis919e6932010-06-28 22:28:35 +00002225 Reader.Visit(S);
Argyrios Kyrtzidise6f08682011-10-21 23:02:28 +00002226 StmtEntries[Cursor.GetCurrentBitNo()] = S;
2227 }
2228
Chris Lattner4c6f9522009-04-27 05:14:47 +00002229
2230 assert(Idx == Record.size() && "Invalid deserialization of statement");
2231 StmtStack.push_back(S);
2232 }
Argyrios Kyrtzidis919e6932010-06-28 22:28:35 +00002233
2234#ifndef NDEBUG
2235 assert(StmtStack.size() > PrevNumStmts && "Read too many sub stmts!");
2236 assert(StmtStack.size() == PrevNumStmts + 1 && "Extra expressions on stack!");
2237#endif
2238
2239 return StmtStack.pop_back_val();
Chris Lattner4c6f9522009-04-27 05:14:47 +00002240}