blob: c5325b5f7837036009b911b743719b5a07120cee [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);
Matt Beaumont-Gay50470242012-07-09 18:55:31 +0000168 (void)NumAttrs;
Alexander Kornienko49908902012-07-09 10:04:07 +0000169 assert(NumAttrs == S->NumAttrs);
170 assert(NumAttrs == Attrs.size());
171 std::copy(Attrs.begin(), Attrs.end(), S->Attrs);
Richard Smith534986f2012-04-14 00:33:13 +0000172 S->SubStmt = Reader.ReadSubStmt();
173 S->AttrLoc = ReadSourceLocation(Record, Idx);
174}
175
Sebastian Redl60adf4a2010-08-18 23:56:52 +0000176void ASTStmtReader::VisitIfStmt(IfStmt *S) {
Chris Lattner4c6f9522009-04-27 05:14:47 +0000177 VisitStmt(S);
Richard Smith534986f2012-04-14 00:33:13 +0000178 S->setConditionVariable(Reader.getContext(),
Douglas Gregor409448c2011-07-21 22:35:25 +0000179 ReadDeclAs<VarDecl>(Record, Idx));
Argyrios Kyrtzidisd98a2ab2010-06-29 22:46:25 +0000180 S->setCond(Reader.ReadSubExpr());
181 S->setThen(Reader.ReadSubStmt());
182 S->setElse(Reader.ReadSubStmt());
Sebastian Redlc3632732010-10-05 15:59:54 +0000183 S->setIfLoc(ReadSourceLocation(Record, Idx));
184 S->setElseLoc(ReadSourceLocation(Record, Idx));
Chris Lattner4c6f9522009-04-27 05:14:47 +0000185}
186
Sebastian Redl60adf4a2010-08-18 23:56:52 +0000187void ASTStmtReader::VisitSwitchStmt(SwitchStmt *S) {
Chris Lattner4c6f9522009-04-27 05:14:47 +0000188 VisitStmt(S);
Douglas Gregor35942772011-09-09 21:34:22 +0000189 S->setConditionVariable(Reader.getContext(),
Douglas Gregor409448c2011-07-21 22:35:25 +0000190 ReadDeclAs<VarDecl>(Record, Idx));
Argyrios Kyrtzidisd98a2ab2010-06-29 22:46:25 +0000191 S->setCond(Reader.ReadSubExpr());
192 S->setBody(Reader.ReadSubStmt());
Sebastian Redlc3632732010-10-05 15:59:54 +0000193 S->setSwitchLoc(ReadSourceLocation(Record, Idx));
Ted Kremenek559fb552010-09-09 00:05:53 +0000194 if (Record[Idx++])
195 S->setAllEnumCasesCovered();
196
Chris Lattner4c6f9522009-04-27 05:14:47 +0000197 SwitchCase *PrevSC = 0;
198 for (unsigned N = Record.size(); Idx != N; ++Idx) {
199 SwitchCase *SC = Reader.getSwitchCaseWithID(Record[Idx]);
200 if (PrevSC)
201 PrevSC->setNextSwitchCase(SC);
202 else
203 S->setSwitchCaseList(SC);
Mike Stump1eb44332009-09-09 15:08:12 +0000204
Chris Lattner4c6f9522009-04-27 05:14:47 +0000205 PrevSC = SC;
206 }
Chris Lattner4c6f9522009-04-27 05:14:47 +0000207}
208
Sebastian Redl60adf4a2010-08-18 23:56:52 +0000209void ASTStmtReader::VisitWhileStmt(WhileStmt *S) {
Chris Lattner4c6f9522009-04-27 05:14:47 +0000210 VisitStmt(S);
Douglas Gregor35942772011-09-09 21:34:22 +0000211 S->setConditionVariable(Reader.getContext(),
Douglas Gregor409448c2011-07-21 22:35:25 +0000212 ReadDeclAs<VarDecl>(Record, Idx));
213
Argyrios Kyrtzidisd98a2ab2010-06-29 22:46:25 +0000214 S->setCond(Reader.ReadSubExpr());
215 S->setBody(Reader.ReadSubStmt());
Sebastian Redlc3632732010-10-05 15:59:54 +0000216 S->setWhileLoc(ReadSourceLocation(Record, Idx));
Chris Lattner4c6f9522009-04-27 05:14:47 +0000217}
218
Sebastian Redl60adf4a2010-08-18 23:56:52 +0000219void ASTStmtReader::VisitDoStmt(DoStmt *S) {
Chris Lattner4c6f9522009-04-27 05:14:47 +0000220 VisitStmt(S);
Argyrios Kyrtzidisd98a2ab2010-06-29 22:46:25 +0000221 S->setCond(Reader.ReadSubExpr());
222 S->setBody(Reader.ReadSubStmt());
Sebastian Redlc3632732010-10-05 15:59:54 +0000223 S->setDoLoc(ReadSourceLocation(Record, Idx));
224 S->setWhileLoc(ReadSourceLocation(Record, Idx));
225 S->setRParenLoc(ReadSourceLocation(Record, Idx));
Chris Lattner4c6f9522009-04-27 05:14:47 +0000226}
227
Sebastian Redl60adf4a2010-08-18 23:56:52 +0000228void ASTStmtReader::VisitForStmt(ForStmt *S) {
Chris Lattner4c6f9522009-04-27 05:14:47 +0000229 VisitStmt(S);
Argyrios Kyrtzidisd98a2ab2010-06-29 22:46:25 +0000230 S->setInit(Reader.ReadSubStmt());
231 S->setCond(Reader.ReadSubExpr());
Douglas Gregor35942772011-09-09 21:34:22 +0000232 S->setConditionVariable(Reader.getContext(),
Douglas Gregor409448c2011-07-21 22:35:25 +0000233 ReadDeclAs<VarDecl>(Record, Idx));
Argyrios Kyrtzidisd98a2ab2010-06-29 22:46:25 +0000234 S->setInc(Reader.ReadSubExpr());
235 S->setBody(Reader.ReadSubStmt());
Sebastian Redlc3632732010-10-05 15:59:54 +0000236 S->setForLoc(ReadSourceLocation(Record, Idx));
237 S->setLParenLoc(ReadSourceLocation(Record, Idx));
238 S->setRParenLoc(ReadSourceLocation(Record, Idx));
Chris Lattner4c6f9522009-04-27 05:14:47 +0000239}
240
Sebastian Redl60adf4a2010-08-18 23:56:52 +0000241void ASTStmtReader::VisitGotoStmt(GotoStmt *S) {
Chris Lattner4c6f9522009-04-27 05:14:47 +0000242 VisitStmt(S);
Douglas Gregor409448c2011-07-21 22:35:25 +0000243 S->setLabel(ReadDeclAs<LabelDecl>(Record, Idx));
Sebastian Redlc3632732010-10-05 15:59:54 +0000244 S->setGotoLoc(ReadSourceLocation(Record, Idx));
245 S->setLabelLoc(ReadSourceLocation(Record, Idx));
Chris Lattner4c6f9522009-04-27 05:14:47 +0000246}
247
Sebastian Redl60adf4a2010-08-18 23:56:52 +0000248void ASTStmtReader::VisitIndirectGotoStmt(IndirectGotoStmt *S) {
Chris Lattner4c6f9522009-04-27 05:14:47 +0000249 VisitStmt(S);
Sebastian Redlc3632732010-10-05 15:59:54 +0000250 S->setGotoLoc(ReadSourceLocation(Record, Idx));
251 S->setStarLoc(ReadSourceLocation(Record, Idx));
Argyrios Kyrtzidisd98a2ab2010-06-29 22:46:25 +0000252 S->setTarget(Reader.ReadSubExpr());
Chris Lattner4c6f9522009-04-27 05:14:47 +0000253}
254
Sebastian Redl60adf4a2010-08-18 23:56:52 +0000255void ASTStmtReader::VisitContinueStmt(ContinueStmt *S) {
Chris Lattner4c6f9522009-04-27 05:14:47 +0000256 VisitStmt(S);
Sebastian Redlc3632732010-10-05 15:59:54 +0000257 S->setContinueLoc(ReadSourceLocation(Record, Idx));
Chris Lattner4c6f9522009-04-27 05:14:47 +0000258}
259
Sebastian Redl60adf4a2010-08-18 23:56:52 +0000260void ASTStmtReader::VisitBreakStmt(BreakStmt *S) {
Chris Lattner4c6f9522009-04-27 05:14:47 +0000261 VisitStmt(S);
Sebastian Redlc3632732010-10-05 15:59:54 +0000262 S->setBreakLoc(ReadSourceLocation(Record, Idx));
Chris Lattner4c6f9522009-04-27 05:14:47 +0000263}
264
Sebastian Redl60adf4a2010-08-18 23:56:52 +0000265void ASTStmtReader::VisitReturnStmt(ReturnStmt *S) {
Chris Lattner4c6f9522009-04-27 05:14:47 +0000266 VisitStmt(S);
Argyrios Kyrtzidisd98a2ab2010-06-29 22:46:25 +0000267 S->setRetValue(Reader.ReadSubExpr());
Sebastian Redlc3632732010-10-05 15:59:54 +0000268 S->setReturnLoc(ReadSourceLocation(Record, Idx));
Douglas Gregor409448c2011-07-21 22:35:25 +0000269 S->setNRVOCandidate(ReadDeclAs<VarDecl>(Record, Idx));
Chris Lattner4c6f9522009-04-27 05:14:47 +0000270}
271
Sebastian Redl60adf4a2010-08-18 23:56:52 +0000272void ASTStmtReader::VisitDeclStmt(DeclStmt *S) {
Chris Lattner4c6f9522009-04-27 05:14:47 +0000273 VisitStmt(S);
Sebastian Redlc3632732010-10-05 15:59:54 +0000274 S->setStartLoc(ReadSourceLocation(Record, Idx));
275 S->setEndLoc(ReadSourceLocation(Record, Idx));
Chris Lattner4c6f9522009-04-27 05:14:47 +0000276
277 if (Idx + 1 == Record.size()) {
278 // Single declaration
Douglas Gregor409448c2011-07-21 22:35:25 +0000279 S->setDeclGroup(DeclGroupRef(ReadDecl(Record, Idx)));
Chris Lattner4c6f9522009-04-27 05:14:47 +0000280 } else {
Chris Lattner5f9e2722011-07-23 10:55:15 +0000281 SmallVector<Decl *, 16> Decls;
Douglas Gregor409448c2011-07-21 22:35:25 +0000282 Decls.reserve(Record.size() - Idx);
283 for (unsigned N = Record.size(); Idx != N; )
284 Decls.push_back(ReadDecl(Record, Idx));
Douglas Gregor35942772011-09-09 21:34:22 +0000285 S->setDeclGroup(DeclGroupRef(DeclGroup::Create(Reader.getContext(),
Douglas Gregor75fdb232009-05-22 22:45:36 +0000286 Decls.data(),
287 Decls.size())));
Chris Lattner4c6f9522009-04-27 05:14:47 +0000288 }
Chris Lattner4c6f9522009-04-27 05:14:47 +0000289}
290
Sebastian Redl60adf4a2010-08-18 23:56:52 +0000291void ASTStmtReader::VisitAsmStmt(AsmStmt *S) {
Chris Lattner4c6f9522009-04-27 05:14:47 +0000292 VisitStmt(S);
293 unsigned NumOutputs = Record[Idx++];
294 unsigned NumInputs = Record[Idx++];
295 unsigned NumClobbers = Record[Idx++];
Sebastian Redlc3632732010-10-05 15:59:54 +0000296 S->setAsmLoc(ReadSourceLocation(Record, Idx));
297 S->setRParenLoc(ReadSourceLocation(Record, Idx));
Chris Lattner4c6f9522009-04-27 05:14:47 +0000298 S->setVolatile(Record[Idx++]);
299 S->setSimple(Record[Idx++]);
Mike Stump3b11fd32010-01-04 22:37:17 +0000300 S->setMSAsm(Record[Idx++]);
Mike Stump1eb44332009-09-09 15:08:12 +0000301
Argyrios Kyrtzidisd98a2ab2010-06-29 22:46:25 +0000302 S->setAsmString(cast_or_null<StringLiteral>(Reader.ReadSubStmt()));
Chris Lattner4c6f9522009-04-27 05:14:47 +0000303
304 // Outputs and inputs
Chris Lattner5f9e2722011-07-23 10:55:15 +0000305 SmallVector<IdentifierInfo *, 16> Names;
306 SmallVector<StringLiteral*, 16> Constraints;
307 SmallVector<Stmt*, 16> Exprs;
Chris Lattner4c6f9522009-04-27 05:14:47 +0000308 for (unsigned I = 0, N = NumOutputs + NumInputs; I != N; ++I) {
Douglas Gregor95eab172011-07-28 20:55:49 +0000309 Names.push_back(Reader.GetIdentifierInfo(F, Record, Idx));
Argyrios Kyrtzidisd98a2ab2010-06-29 22:46:25 +0000310 Constraints.push_back(cast_or_null<StringLiteral>(Reader.ReadSubStmt()));
311 Exprs.push_back(Reader.ReadSubStmt());
Chris Lattner4c6f9522009-04-27 05:14:47 +0000312 }
Chris Lattner4c6f9522009-04-27 05:14:47 +0000313
314 // Constraints
Chris Lattner5f9e2722011-07-23 10:55:15 +0000315 SmallVector<StringLiteral*, 16> Clobbers;
Chris Lattner4c6f9522009-04-27 05:14:47 +0000316 for (unsigned I = 0; I != NumClobbers; ++I)
Argyrios Kyrtzidisd98a2ab2010-06-29 22:46:25 +0000317 Clobbers.push_back(cast_or_null<StringLiteral>(Reader.ReadSubStmt()));
Anders Carlssonfdba9c02010-01-30 19:34:25 +0000318
Douglas Gregor35942772011-09-09 21:34:22 +0000319 S->setOutputsAndInputsAndClobbers(Reader.getContext(),
Anders Carlssonacb6bcb2010-01-30 20:38:10 +0000320 Names.data(), Constraints.data(),
Anders Carlssonfdba9c02010-01-30 19:34:25 +0000321 Exprs.data(), NumOutputs, NumInputs,
322 Clobbers.data(), NumClobbers);
Chris Lattner4c6f9522009-04-27 05:14:47 +0000323}
324
Chad Rosier8cd64b42012-06-11 20:47:18 +0000325void ASTStmtReader::VisitMSAsmStmt(MSAsmStmt *S) {
326 // FIXME: Statement reader not yet implemented for MS style inline asm.
327 VisitStmt(S);
328}
329
Sebastian Redl60adf4a2010-08-18 23:56:52 +0000330void ASTStmtReader::VisitExpr(Expr *E) {
Chris Lattner4c6f9522009-04-27 05:14:47 +0000331 VisitStmt(E);
Douglas Gregor393f2492011-07-22 00:38:23 +0000332 E->setType(Reader.readType(F, Record, Idx));
Chris Lattner4c6f9522009-04-27 05:14:47 +0000333 E->setTypeDependent(Record[Idx++]);
334 E->setValueDependent(Record[Idx++]);
Douglas Gregor561f8122011-07-01 01:22:09 +0000335 E->setInstantiationDependent(Record[Idx++]);
Douglas Gregord0937222010-12-13 22:49:22 +0000336 E->ExprBits.ContainsUnexpandedParameterPack = Record[Idx++];
John McCallf89e55a2010-11-18 06:31:45 +0000337 E->setValueKind(static_cast<ExprValueKind>(Record[Idx++]));
338 E->setObjectKind(static_cast<ExprObjectKind>(Record[Idx++]));
Chris Lattner4c6f9522009-04-27 05:14:47 +0000339 assert(Idx == NumExprFields && "Incorrect expression field count");
Chris Lattner4c6f9522009-04-27 05:14:47 +0000340}
341
Sebastian Redl60adf4a2010-08-18 23:56:52 +0000342void ASTStmtReader::VisitPredefinedExpr(PredefinedExpr *E) {
Chris Lattner4c6f9522009-04-27 05:14:47 +0000343 VisitExpr(E);
Sebastian Redlc3632732010-10-05 15:59:54 +0000344 E->setLocation(ReadSourceLocation(Record, Idx));
Chris Lattner4c6f9522009-04-27 05:14:47 +0000345 E->setIdentType((PredefinedExpr::IdentType)Record[Idx++]);
Chris Lattner4c6f9522009-04-27 05:14:47 +0000346}
347
Sebastian Redl60adf4a2010-08-18 23:56:52 +0000348void ASTStmtReader::VisitDeclRefExpr(DeclRefExpr *E) {
Chris Lattner4c6f9522009-04-27 05:14:47 +0000349 VisitExpr(E);
Argyrios Kyrtzidis663e3802010-07-08 13:09:47 +0000350
Chandler Carruthcb66cff2011-05-01 21:29:53 +0000351 E->DeclRefExprBits.HasQualifier = Record[Idx++];
Chandler Carruth3aa81402011-05-01 23:48:14 +0000352 E->DeclRefExprBits.HasFoundDecl = Record[Idx++];
Abramo Bagnarae4b92762012-01-27 09:46:47 +0000353 E->DeclRefExprBits.HasTemplateKWAndArgsInfo = Record[Idx++];
Abramo Bagnara7cc58b42011-10-05 07:56:41 +0000354 E->DeclRefExprBits.HadMultipleCandidates = Record[Idx++];
John McCallf4b88a42012-03-10 09:33:50 +0000355 E->DeclRefExprBits.RefersToEnclosingLocal = Record[Idx++];
Anders Carlssonb0ca1372011-03-06 18:19:42 +0000356 unsigned NumTemplateArgs = 0;
Abramo Bagnarae4b92762012-01-27 09:46:47 +0000357 if (E->hasTemplateKWAndArgsInfo())
Anders Carlssonb0ca1372011-03-06 18:19:42 +0000358 NumTemplateArgs = Record[Idx++];
359
Chandler Carruthcb66cff2011-05-01 21:29:53 +0000360 if (E->hasQualifier())
Chandler Carruth6857c3e2011-05-01 22:14:37 +0000361 E->getInternalQualifierLoc()
Douglas Gregor40d96a62011-02-28 21:54:11 +0000362 = Reader.ReadNestedNameSpecifierLoc(F, Record, Idx);
Argyrios Kyrtzidis663e3802010-07-08 13:09:47 +0000363
Chandler Carruth3aa81402011-05-01 23:48:14 +0000364 if (E->hasFoundDecl())
Douglas Gregor409448c2011-07-21 22:35:25 +0000365 E->getInternalFoundDecl() = ReadDeclAs<NamedDecl>(Record, Idx);
Chandler Carruth3aa81402011-05-01 23:48:14 +0000366
Abramo Bagnarae4b92762012-01-27 09:46:47 +0000367 if (E->hasTemplateKWAndArgsInfo())
368 ReadTemplateKWAndArgsInfo(*E->getTemplateKWAndArgsInfo(),
369 NumTemplateArgs);
Argyrios Kyrtzidis663e3802010-07-08 13:09:47 +0000370
Douglas Gregor409448c2011-07-21 22:35:25 +0000371 E->setDecl(ReadDeclAs<ValueDecl>(Record, Idx));
Sebastian Redlc3632732010-10-05 15:59:54 +0000372 E->setLocation(ReadSourceLocation(Record, Idx));
Argyrios Kyrtzidis40451072010-10-15 18:21:24 +0000373 ReadDeclarationNameLoc(E->DNLoc, E->getDecl()->getDeclName(), Record, Idx);
Chris Lattner4c6f9522009-04-27 05:14:47 +0000374}
375
Sebastian Redl60adf4a2010-08-18 23:56:52 +0000376void ASTStmtReader::VisitIntegerLiteral(IntegerLiteral *E) {
Chris Lattner4c6f9522009-04-27 05:14:47 +0000377 VisitExpr(E);
Sebastian Redlc3632732010-10-05 15:59:54 +0000378 E->setLocation(ReadSourceLocation(Record, Idx));
Douglas Gregor35942772011-09-09 21:34:22 +0000379 E->setValue(Reader.getContext(), Reader.ReadAPInt(Record, Idx));
Chris Lattner4c6f9522009-04-27 05:14:47 +0000380}
381
Sebastian Redl60adf4a2010-08-18 23:56:52 +0000382void ASTStmtReader::VisitFloatingLiteral(FloatingLiteral *E) {
Chris Lattner4c6f9522009-04-27 05:14:47 +0000383 VisitExpr(E);
Douglas Gregor35942772011-09-09 21:34:22 +0000384 E->setValue(Reader.getContext(), Reader.ReadAPFloat(Record, Idx));
Chris Lattner4c6f9522009-04-27 05:14:47 +0000385 E->setExact(Record[Idx++]);
Sebastian Redlc3632732010-10-05 15:59:54 +0000386 E->setLocation(ReadSourceLocation(Record, Idx));
Chris Lattner4c6f9522009-04-27 05:14:47 +0000387}
388
Sebastian Redl60adf4a2010-08-18 23:56:52 +0000389void ASTStmtReader::VisitImaginaryLiteral(ImaginaryLiteral *E) {
Chris Lattner4c6f9522009-04-27 05:14:47 +0000390 VisitExpr(E);
Argyrios Kyrtzidisd98a2ab2010-06-29 22:46:25 +0000391 E->setSubExpr(Reader.ReadSubExpr());
Chris Lattner4c6f9522009-04-27 05:14:47 +0000392}
393
Sebastian Redl60adf4a2010-08-18 23:56:52 +0000394void ASTStmtReader::VisitStringLiteral(StringLiteral *E) {
Chris Lattner4c6f9522009-04-27 05:14:47 +0000395 VisitExpr(E);
396 unsigned Len = Record[Idx++];
Mike Stump1eb44332009-09-09 15:08:12 +0000397 assert(Record[Idx] == E->getNumConcatenated() &&
Chris Lattner4c6f9522009-04-27 05:14:47 +0000398 "Wrong number of concatenated tokens!");
399 ++Idx;
Eli Friedman64f45a22011-11-01 02:23:42 +0000400 StringLiteral::StringKind kind =
401 static_cast<StringLiteral::StringKind>(Record[Idx++]);
402 bool isPascal = Record[Idx++];
Chris Lattner4c6f9522009-04-27 05:14:47 +0000403
Mike Stump1eb44332009-09-09 15:08:12 +0000404 // Read string data
Dylan Noblesmithf7ccbad2012-02-05 02:13:05 +0000405 SmallString<16> Str(&Record[Idx], &Record[Idx] + Len);
Eli Friedman64f45a22011-11-01 02:23:42 +0000406 E->setString(Reader.getContext(), Str.str(), kind, isPascal);
Chris Lattner4c6f9522009-04-27 05:14:47 +0000407 Idx += Len;
408
409 // Read source locations
410 for (unsigned I = 0, N = E->getNumConcatenated(); I != N; ++I)
Sebastian Redlc3632732010-10-05 15:59:54 +0000411 E->setStrTokenLoc(I, ReadSourceLocation(Record, Idx));
Chris Lattner4c6f9522009-04-27 05:14:47 +0000412}
413
Sebastian Redl60adf4a2010-08-18 23:56:52 +0000414void ASTStmtReader::VisitCharacterLiteral(CharacterLiteral *E) {
Chris Lattner4c6f9522009-04-27 05:14:47 +0000415 VisitExpr(E);
416 E->setValue(Record[Idx++]);
Sebastian Redlc3632732010-10-05 15:59:54 +0000417 E->setLocation(ReadSourceLocation(Record, Idx));
Douglas Gregor5cee1192011-07-27 05:40:30 +0000418 E->setKind(static_cast<CharacterLiteral::CharacterKind>(Record[Idx++]));
Chris Lattner4c6f9522009-04-27 05:14:47 +0000419}
420
Sebastian Redl60adf4a2010-08-18 23:56:52 +0000421void ASTStmtReader::VisitParenExpr(ParenExpr *E) {
Chris Lattner4c6f9522009-04-27 05:14:47 +0000422 VisitExpr(E);
Sebastian Redlc3632732010-10-05 15:59:54 +0000423 E->setLParen(ReadSourceLocation(Record, Idx));
424 E->setRParen(ReadSourceLocation(Record, Idx));
Argyrios Kyrtzidisd98a2ab2010-06-29 22:46:25 +0000425 E->setSubExpr(Reader.ReadSubExpr());
Chris Lattner4c6f9522009-04-27 05:14:47 +0000426}
427
Sebastian Redl60adf4a2010-08-18 23:56:52 +0000428void ASTStmtReader::VisitParenListExpr(ParenListExpr *E) {
Argyrios Kyrtzidis37bdfe22010-06-30 08:49:18 +0000429 VisitExpr(E);
430 unsigned NumExprs = Record[Idx++];
Douglas Gregor35942772011-09-09 21:34:22 +0000431 E->Exprs = new (Reader.getContext()) Stmt*[NumExprs];
Argyrios Kyrtzidis37bdfe22010-06-30 08:49:18 +0000432 for (unsigned i = 0; i != NumExprs; ++i)
433 E->Exprs[i] = Reader.ReadSubStmt();
434 E->NumExprs = NumExprs;
Sebastian Redlc3632732010-10-05 15:59:54 +0000435 E->LParenLoc = ReadSourceLocation(Record, Idx);
436 E->RParenLoc = ReadSourceLocation(Record, Idx);
Argyrios Kyrtzidis37bdfe22010-06-30 08:49:18 +0000437}
438
Sebastian Redl60adf4a2010-08-18 23:56:52 +0000439void ASTStmtReader::VisitUnaryOperator(UnaryOperator *E) {
Chris Lattner4c6f9522009-04-27 05:14:47 +0000440 VisitExpr(E);
Argyrios Kyrtzidisd98a2ab2010-06-29 22:46:25 +0000441 E->setSubExpr(Reader.ReadSubExpr());
Chris Lattner4c6f9522009-04-27 05:14:47 +0000442 E->setOpcode((UnaryOperator::Opcode)Record[Idx++]);
Sebastian Redlc3632732010-10-05 15:59:54 +0000443 E->setOperatorLoc(ReadSourceLocation(Record, Idx));
Chris Lattner4c6f9522009-04-27 05:14:47 +0000444}
445
Sebastian Redl60adf4a2010-08-18 23:56:52 +0000446void ASTStmtReader::VisitOffsetOfExpr(OffsetOfExpr *E) {
Douglas Gregor8ecdb652010-04-28 22:16:22 +0000447 typedef OffsetOfExpr::OffsetOfNode Node;
448 VisitExpr(E);
449 assert(E->getNumComponents() == Record[Idx]);
450 ++Idx;
451 assert(E->getNumExpressions() == Record[Idx]);
452 ++Idx;
Sebastian Redlc3632732010-10-05 15:59:54 +0000453 E->setOperatorLoc(ReadSourceLocation(Record, Idx));
454 E->setRParenLoc(ReadSourceLocation(Record, Idx));
455 E->setTypeSourceInfo(GetTypeSourceInfo(Record, Idx));
Douglas Gregor8ecdb652010-04-28 22:16:22 +0000456 for (unsigned I = 0, N = E->getNumComponents(); I != N; ++I) {
457 Node::Kind Kind = static_cast<Node::Kind>(Record[Idx++]);
Sebastian Redlc3632732010-10-05 15:59:54 +0000458 SourceLocation Start = ReadSourceLocation(Record, Idx);
459 SourceLocation End = ReadSourceLocation(Record, Idx);
Douglas Gregor8ecdb652010-04-28 22:16:22 +0000460 switch (Kind) {
461 case Node::Array:
462 E->setComponent(I, Node(Start, Record[Idx++], End));
463 break;
464
465 case Node::Field:
Douglas Gregor409448c2011-07-21 22:35:25 +0000466 E->setComponent(I, Node(Start, ReadDeclAs<FieldDecl>(Record, Idx), End));
Douglas Gregor8ecdb652010-04-28 22:16:22 +0000467 break;
468
469 case Node::Identifier:
Douglas Gregor95eab172011-07-28 20:55:49 +0000470 E->setComponent(I,
471 Node(Start,
472 Reader.GetIdentifierInfo(F, Record, Idx),
473 End));
Douglas Gregor8ecdb652010-04-28 22:16:22 +0000474 break;
Douglas Gregorcc8a5d52010-04-29 00:18:15 +0000475
Argyrios Kyrtzidisafbf3122010-07-29 18:16:10 +0000476 case Node::Base: {
Douglas Gregor35942772011-09-09 21:34:22 +0000477 CXXBaseSpecifier *Base = new (Reader.getContext()) CXXBaseSpecifier();
Sebastian Redlc3632732010-10-05 15:59:54 +0000478 *Base = Reader.ReadCXXBaseSpecifier(F, Record, Idx);
Argyrios Kyrtzidisafbf3122010-07-29 18:16:10 +0000479 E->setComponent(I, Node(Base));
Douglas Gregorcc8a5d52010-04-29 00:18:15 +0000480 break;
Douglas Gregor8ecdb652010-04-28 22:16:22 +0000481 }
Argyrios Kyrtzidisafbf3122010-07-29 18:16:10 +0000482 }
Douglas Gregor8ecdb652010-04-28 22:16:22 +0000483 }
484
485 for (unsigned I = 0, N = E->getNumExpressions(); I != N; ++I)
Argyrios Kyrtzidisd98a2ab2010-06-29 22:46:25 +0000486 E->setIndexExpr(I, Reader.ReadSubExpr());
Douglas Gregor8ecdb652010-04-28 22:16:22 +0000487}
488
Peter Collingbournef4e3cfb2011-03-11 19:24:49 +0000489void ASTStmtReader::VisitUnaryExprOrTypeTraitExpr(UnaryExprOrTypeTraitExpr *E) {
Chris Lattner4c6f9522009-04-27 05:14:47 +0000490 VisitExpr(E);
Peter Collingbournef4e3cfb2011-03-11 19:24:49 +0000491 E->setKind(static_cast<UnaryExprOrTypeTrait>(Record[Idx++]));
Chris Lattner4c6f9522009-04-27 05:14:47 +0000492 if (Record[Idx] == 0) {
Argyrios Kyrtzidisd98a2ab2010-06-29 22:46:25 +0000493 E->setArgument(Reader.ReadSubExpr());
Chris Lattner4c6f9522009-04-27 05:14:47 +0000494 ++Idx;
495 } else {
Sebastian Redlc3632732010-10-05 15:59:54 +0000496 E->setArgument(GetTypeSourceInfo(Record, Idx));
Chris Lattner4c6f9522009-04-27 05:14:47 +0000497 }
Sebastian Redlc3632732010-10-05 15:59:54 +0000498 E->setOperatorLoc(ReadSourceLocation(Record, Idx));
499 E->setRParenLoc(ReadSourceLocation(Record, Idx));
Chris Lattner4c6f9522009-04-27 05:14:47 +0000500}
501
Sebastian Redl60adf4a2010-08-18 23:56:52 +0000502void ASTStmtReader::VisitArraySubscriptExpr(ArraySubscriptExpr *E) {
Chris Lattner4c6f9522009-04-27 05:14:47 +0000503 VisitExpr(E);
Argyrios Kyrtzidisd98a2ab2010-06-29 22:46:25 +0000504 E->setLHS(Reader.ReadSubExpr());
505 E->setRHS(Reader.ReadSubExpr());
Sebastian Redlc3632732010-10-05 15:59:54 +0000506 E->setRBracketLoc(ReadSourceLocation(Record, Idx));
Chris Lattner4c6f9522009-04-27 05:14:47 +0000507}
508
Sebastian Redl60adf4a2010-08-18 23:56:52 +0000509void ASTStmtReader::VisitCallExpr(CallExpr *E) {
Chris Lattner4c6f9522009-04-27 05:14:47 +0000510 VisitExpr(E);
Douglas Gregor35942772011-09-09 21:34:22 +0000511 E->setNumArgs(Reader.getContext(), Record[Idx++]);
Sebastian Redlc3632732010-10-05 15:59:54 +0000512 E->setRParenLoc(ReadSourceLocation(Record, Idx));
Argyrios Kyrtzidisd98a2ab2010-06-29 22:46:25 +0000513 E->setCallee(Reader.ReadSubExpr());
Chris Lattner4c6f9522009-04-27 05:14:47 +0000514 for (unsigned I = 0, N = E->getNumArgs(); I != N; ++I)
Argyrios Kyrtzidisd98a2ab2010-06-29 22:46:25 +0000515 E->setArg(I, Reader.ReadSubExpr());
Chris Lattner4c6f9522009-04-27 05:14:47 +0000516}
517
John McCall7110fd62011-07-15 07:00:14 +0000518void ASTStmtReader::VisitCXXMemberCallExpr(CXXMemberCallExpr *E) {
519 VisitCallExpr(E);
520}
521
Sebastian Redl60adf4a2010-08-18 23:56:52 +0000522void ASTStmtReader::VisitMemberExpr(MemberExpr *E) {
Argyrios Kyrtzidis663e3802010-07-08 13:09:47 +0000523 // Don't call VisitExpr, this is fully initialized at creation.
524 assert(E->getStmtClass() == Stmt::MemberExprClass &&
525 "It's a subclass, we must advance Idx!");
Chris Lattner4c6f9522009-04-27 05:14:47 +0000526}
527
Sebastian Redl60adf4a2010-08-18 23:56:52 +0000528void ASTStmtReader::VisitObjCIsaExpr(ObjCIsaExpr *E) {
Steve Narofff242b1b2009-07-24 17:54:45 +0000529 VisitExpr(E);
Argyrios Kyrtzidisd98a2ab2010-06-29 22:46:25 +0000530 E->setBase(Reader.ReadSubExpr());
Sebastian Redlc3632732010-10-05 15:59:54 +0000531 E->setIsaMemberLoc(ReadSourceLocation(Record, Idx));
Steve Narofff242b1b2009-07-24 17:54:45 +0000532 E->setArrow(Record[Idx++]);
Steve Narofff242b1b2009-07-24 17:54:45 +0000533}
534
John McCallf85e1932011-06-15 23:02:42 +0000535void ASTStmtReader::
536VisitObjCIndirectCopyRestoreExpr(ObjCIndirectCopyRestoreExpr *E) {
537 VisitExpr(E);
538 E->Operand = Reader.ReadSubExpr();
539 E->setShouldCopy(Record[Idx++]);
540}
541
542void ASTStmtReader::VisitObjCBridgedCastExpr(ObjCBridgedCastExpr *E) {
543 VisitExplicitCastExpr(E);
544 E->LParenLoc = ReadSourceLocation(Record, Idx);
545 E->BridgeKeywordLoc = ReadSourceLocation(Record, Idx);
546 E->Kind = Record[Idx++];
547}
548
Sebastian Redl60adf4a2010-08-18 23:56:52 +0000549void ASTStmtReader::VisitCastExpr(CastExpr *E) {
Chris Lattner4c6f9522009-04-27 05:14:47 +0000550 VisitExpr(E);
John McCallf871d0c2010-08-07 06:22:56 +0000551 unsigned NumBaseSpecs = Record[Idx++];
552 assert(NumBaseSpecs == E->path_size());
Argyrios Kyrtzidisd98a2ab2010-06-29 22:46:25 +0000553 E->setSubExpr(Reader.ReadSubExpr());
Anders Carlssoncdef2b72009-07-31 00:48:10 +0000554 E->setCastKind((CastExpr::CastKind)Record[Idx++]);
John McCallf871d0c2010-08-07 06:22:56 +0000555 CastExpr::path_iterator BaseI = E->path_begin();
Argyrios Kyrtzidis0745d0a2010-07-02 23:30:27 +0000556 while (NumBaseSpecs--) {
Douglas Gregor35942772011-09-09 21:34:22 +0000557 CXXBaseSpecifier *BaseSpec = new (Reader.getContext()) CXXBaseSpecifier;
Sebastian Redlc3632732010-10-05 15:59:54 +0000558 *BaseSpec = Reader.ReadCXXBaseSpecifier(F, Record, Idx);
John McCallf871d0c2010-08-07 06:22:56 +0000559 *BaseI++ = BaseSpec;
Argyrios Kyrtzidis0745d0a2010-07-02 23:30:27 +0000560 }
Chris Lattner4c6f9522009-04-27 05:14:47 +0000561}
562
Sebastian Redl60adf4a2010-08-18 23:56:52 +0000563void ASTStmtReader::VisitBinaryOperator(BinaryOperator *E) {
Chris Lattner4c6f9522009-04-27 05:14:47 +0000564 VisitExpr(E);
Argyrios Kyrtzidisd98a2ab2010-06-29 22:46:25 +0000565 E->setLHS(Reader.ReadSubExpr());
566 E->setRHS(Reader.ReadSubExpr());
Chris Lattner4c6f9522009-04-27 05:14:47 +0000567 E->setOpcode((BinaryOperator::Opcode)Record[Idx++]);
Sebastian Redlc3632732010-10-05 15:59:54 +0000568 E->setOperatorLoc(ReadSourceLocation(Record, Idx));
Chris Lattner4c6f9522009-04-27 05:14:47 +0000569}
570
Sebastian Redl60adf4a2010-08-18 23:56:52 +0000571void ASTStmtReader::VisitCompoundAssignOperator(CompoundAssignOperator *E) {
Chris Lattner4c6f9522009-04-27 05:14:47 +0000572 VisitBinaryOperator(E);
Douglas Gregor393f2492011-07-22 00:38:23 +0000573 E->setComputationLHSType(Reader.readType(F, Record, Idx));
574 E->setComputationResultType(Reader.readType(F, Record, Idx));
Chris Lattner4c6f9522009-04-27 05:14:47 +0000575}
576
Sebastian Redl60adf4a2010-08-18 23:56:52 +0000577void ASTStmtReader::VisitConditionalOperator(ConditionalOperator *E) {
Chris Lattner4c6f9522009-04-27 05:14:47 +0000578 VisitExpr(E);
John McCall56ca35d2011-02-17 10:25:35 +0000579 E->SubExprs[ConditionalOperator::COND] = Reader.ReadSubExpr();
580 E->SubExprs[ConditionalOperator::LHS] = Reader.ReadSubExpr();
581 E->SubExprs[ConditionalOperator::RHS] = Reader.ReadSubExpr();
582 E->QuestionLoc = ReadSourceLocation(Record, Idx);
583 E->ColonLoc = ReadSourceLocation(Record, Idx);
584}
585
586void
587ASTStmtReader::VisitBinaryConditionalOperator(BinaryConditionalOperator *E) {
588 VisitExpr(E);
589 E->OpaqueValue = cast<OpaqueValueExpr>(Reader.ReadSubExpr());
590 E->SubExprs[BinaryConditionalOperator::COMMON] = Reader.ReadSubExpr();
591 E->SubExprs[BinaryConditionalOperator::COND] = Reader.ReadSubExpr();
592 E->SubExprs[BinaryConditionalOperator::LHS] = Reader.ReadSubExpr();
593 E->SubExprs[BinaryConditionalOperator::RHS] = Reader.ReadSubExpr();
594 E->QuestionLoc = ReadSourceLocation(Record, Idx);
595 E->ColonLoc = ReadSourceLocation(Record, Idx);
Chris Lattner4c6f9522009-04-27 05:14:47 +0000596}
597
Sebastian Redl60adf4a2010-08-18 23:56:52 +0000598void ASTStmtReader::VisitImplicitCastExpr(ImplicitCastExpr *E) {
Chris Lattner4c6f9522009-04-27 05:14:47 +0000599 VisitCastExpr(E);
Chris Lattner4c6f9522009-04-27 05:14:47 +0000600}
601
Sebastian Redl60adf4a2010-08-18 23:56:52 +0000602void ASTStmtReader::VisitExplicitCastExpr(ExplicitCastExpr *E) {
Chris Lattner4c6f9522009-04-27 05:14:47 +0000603 VisitCastExpr(E);
Sebastian Redlc3632732010-10-05 15:59:54 +0000604 E->setTypeInfoAsWritten(GetTypeSourceInfo(Record, Idx));
Chris Lattner4c6f9522009-04-27 05:14:47 +0000605}
606
Sebastian Redl60adf4a2010-08-18 23:56:52 +0000607void ASTStmtReader::VisitCStyleCastExpr(CStyleCastExpr *E) {
Chris Lattner4c6f9522009-04-27 05:14:47 +0000608 VisitExplicitCastExpr(E);
Sebastian Redlc3632732010-10-05 15:59:54 +0000609 E->setLParenLoc(ReadSourceLocation(Record, Idx));
610 E->setRParenLoc(ReadSourceLocation(Record, Idx));
Chris Lattner4c6f9522009-04-27 05:14:47 +0000611}
612
Sebastian Redl60adf4a2010-08-18 23:56:52 +0000613void ASTStmtReader::VisitCompoundLiteralExpr(CompoundLiteralExpr *E) {
Chris Lattner4c6f9522009-04-27 05:14:47 +0000614 VisitExpr(E);
Sebastian Redlc3632732010-10-05 15:59:54 +0000615 E->setLParenLoc(ReadSourceLocation(Record, Idx));
616 E->setTypeSourceInfo(GetTypeSourceInfo(Record, Idx));
Argyrios Kyrtzidisd98a2ab2010-06-29 22:46:25 +0000617 E->setInitializer(Reader.ReadSubExpr());
Chris Lattner4c6f9522009-04-27 05:14:47 +0000618 E->setFileScope(Record[Idx++]);
Chris Lattner4c6f9522009-04-27 05:14:47 +0000619}
620
Sebastian Redl60adf4a2010-08-18 23:56:52 +0000621void ASTStmtReader::VisitExtVectorElementExpr(ExtVectorElementExpr *E) {
Chris Lattner4c6f9522009-04-27 05:14:47 +0000622 VisitExpr(E);
Argyrios Kyrtzidisd98a2ab2010-06-29 22:46:25 +0000623 E->setBase(Reader.ReadSubExpr());
Douglas Gregor95eab172011-07-28 20:55:49 +0000624 E->setAccessor(Reader.GetIdentifierInfo(F, Record, Idx));
Sebastian Redlc3632732010-10-05 15:59:54 +0000625 E->setAccessorLoc(ReadSourceLocation(Record, Idx));
Chris Lattner4c6f9522009-04-27 05:14:47 +0000626}
627
Sebastian Redl60adf4a2010-08-18 23:56:52 +0000628void ASTStmtReader::VisitInitListExpr(InitListExpr *E) {
Chris Lattner4c6f9522009-04-27 05:14:47 +0000629 VisitExpr(E);
Argyrios Kyrtzidisd98a2ab2010-06-29 22:46:25 +0000630 E->setSyntacticForm(cast_or_null<InitListExpr>(Reader.ReadSubStmt()));
Sebastian Redlc3632732010-10-05 15:59:54 +0000631 E->setLBraceLoc(ReadSourceLocation(Record, Idx));
632 E->setRBraceLoc(ReadSourceLocation(Record, Idx));
Argyrios Kyrtzidis2ac0b7a2011-04-22 05:29:30 +0000633 bool isArrayFiller = Record[Idx++];
634 Expr *filler = 0;
635 if (isArrayFiller) {
636 filler = Reader.ReadSubExpr();
637 E->ArrayFillerOrUnionFieldInit = filler;
638 } else
Douglas Gregor409448c2011-07-21 22:35:25 +0000639 E->ArrayFillerOrUnionFieldInit = ReadDeclAs<FieldDecl>(Record, Idx);
Chris Lattner4c6f9522009-04-27 05:14:47 +0000640 E->sawArrayRangeDesignator(Record[Idx++]);
Benjamin Kramer1b1a5072012-02-27 13:20:39 +0000641 E->setInitializesStdInitializerList(Record[Idx++]);
Argyrios Kyrtzidis2ac0b7a2011-04-22 05:29:30 +0000642 unsigned NumInits = Record[Idx++];
Douglas Gregor35942772011-09-09 21:34:22 +0000643 E->reserveInits(Reader.getContext(), NumInits);
Argyrios Kyrtzidis2ac0b7a2011-04-22 05:29:30 +0000644 if (isArrayFiller) {
645 for (unsigned I = 0; I != NumInits; ++I) {
646 Expr *init = Reader.ReadSubExpr();
Douglas Gregor35942772011-09-09 21:34:22 +0000647 E->updateInit(Reader.getContext(), I, init ? init : filler);
Argyrios Kyrtzidis2ac0b7a2011-04-22 05:29:30 +0000648 }
649 } else {
650 for (unsigned I = 0; I != NumInits; ++I)
Douglas Gregor35942772011-09-09 21:34:22 +0000651 E->updateInit(Reader.getContext(), I, Reader.ReadSubExpr());
Argyrios Kyrtzidis2ac0b7a2011-04-22 05:29:30 +0000652 }
Chris Lattner4c6f9522009-04-27 05:14:47 +0000653}
654
Sebastian Redl60adf4a2010-08-18 23:56:52 +0000655void ASTStmtReader::VisitDesignatedInitExpr(DesignatedInitExpr *E) {
Chris Lattner4c6f9522009-04-27 05:14:47 +0000656 typedef DesignatedInitExpr::Designator Designator;
657
658 VisitExpr(E);
659 unsigned NumSubExprs = Record[Idx++];
660 assert(NumSubExprs == E->getNumSubExprs() && "Wrong number of subexprs");
661 for (unsigned I = 0; I != NumSubExprs; ++I)
Argyrios Kyrtzidisd98a2ab2010-06-29 22:46:25 +0000662 E->setSubExpr(I, Reader.ReadSubExpr());
Sebastian Redlc3632732010-10-05 15:59:54 +0000663 E->setEqualOrColonLoc(ReadSourceLocation(Record, Idx));
Chris Lattner4c6f9522009-04-27 05:14:47 +0000664 E->setGNUSyntax(Record[Idx++]);
665
Chris Lattner5f9e2722011-07-23 10:55:15 +0000666 SmallVector<Designator, 4> Designators;
Chris Lattner4c6f9522009-04-27 05:14:47 +0000667 while (Idx < Record.size()) {
Sebastian Redl8538e8d2010-08-18 23:57:32 +0000668 switch ((DesignatorTypes)Record[Idx++]) {
669 case DESIG_FIELD_DECL: {
Douglas Gregor409448c2011-07-21 22:35:25 +0000670 FieldDecl *Field = ReadDeclAs<FieldDecl>(Record, Idx);
Mike Stump1eb44332009-09-09 15:08:12 +0000671 SourceLocation DotLoc
Sebastian Redlc3632732010-10-05 15:59:54 +0000672 = ReadSourceLocation(Record, Idx);
Mike Stump1eb44332009-09-09 15:08:12 +0000673 SourceLocation FieldLoc
Sebastian Redlc3632732010-10-05 15:59:54 +0000674 = ReadSourceLocation(Record, Idx);
Mike Stump1eb44332009-09-09 15:08:12 +0000675 Designators.push_back(Designator(Field->getIdentifier(), DotLoc,
Chris Lattner4c6f9522009-04-27 05:14:47 +0000676 FieldLoc));
677 Designators.back().setField(Field);
678 break;
679 }
680
Sebastian Redl8538e8d2010-08-18 23:57:32 +0000681 case DESIG_FIELD_NAME: {
Douglas Gregor95eab172011-07-28 20:55:49 +0000682 const IdentifierInfo *Name = Reader.GetIdentifierInfo(F, Record, Idx);
Mike Stump1eb44332009-09-09 15:08:12 +0000683 SourceLocation DotLoc
Sebastian Redlc3632732010-10-05 15:59:54 +0000684 = ReadSourceLocation(Record, Idx);
Mike Stump1eb44332009-09-09 15:08:12 +0000685 SourceLocation FieldLoc
Sebastian Redlc3632732010-10-05 15:59:54 +0000686 = ReadSourceLocation(Record, Idx);
Chris Lattner4c6f9522009-04-27 05:14:47 +0000687 Designators.push_back(Designator(Name, DotLoc, FieldLoc));
688 break;
689 }
Mike Stump1eb44332009-09-09 15:08:12 +0000690
Sebastian Redl8538e8d2010-08-18 23:57:32 +0000691 case DESIG_ARRAY: {
Chris Lattner4c6f9522009-04-27 05:14:47 +0000692 unsigned Index = Record[Idx++];
693 SourceLocation LBracketLoc
Sebastian Redlc3632732010-10-05 15:59:54 +0000694 = ReadSourceLocation(Record, Idx);
Chris Lattner4c6f9522009-04-27 05:14:47 +0000695 SourceLocation RBracketLoc
Sebastian Redlc3632732010-10-05 15:59:54 +0000696 = ReadSourceLocation(Record, Idx);
Chris Lattner4c6f9522009-04-27 05:14:47 +0000697 Designators.push_back(Designator(Index, LBracketLoc, RBracketLoc));
698 break;
699 }
700
Sebastian Redl8538e8d2010-08-18 23:57:32 +0000701 case DESIG_ARRAY_RANGE: {
Chris Lattner4c6f9522009-04-27 05:14:47 +0000702 unsigned Index = Record[Idx++];
703 SourceLocation LBracketLoc
Sebastian Redlc3632732010-10-05 15:59:54 +0000704 = ReadSourceLocation(Record, Idx);
Chris Lattner4c6f9522009-04-27 05:14:47 +0000705 SourceLocation EllipsisLoc
Sebastian Redlc3632732010-10-05 15:59:54 +0000706 = ReadSourceLocation(Record, Idx);
Chris Lattner4c6f9522009-04-27 05:14:47 +0000707 SourceLocation RBracketLoc
Sebastian Redlc3632732010-10-05 15:59:54 +0000708 = ReadSourceLocation(Record, Idx);
Chris Lattner4c6f9522009-04-27 05:14:47 +0000709 Designators.push_back(Designator(Index, LBracketLoc, EllipsisLoc,
710 RBracketLoc));
711 break;
712 }
713 }
714 }
Douglas Gregor35942772011-09-09 21:34:22 +0000715 E->setDesignators(Reader.getContext(),
Douglas Gregor319d57f2010-01-06 23:17:19 +0000716 Designators.data(), Designators.size());
Chris Lattner4c6f9522009-04-27 05:14:47 +0000717}
718
Sebastian Redl60adf4a2010-08-18 23:56:52 +0000719void ASTStmtReader::VisitImplicitValueInitExpr(ImplicitValueInitExpr *E) {
Chris Lattner4c6f9522009-04-27 05:14:47 +0000720 VisitExpr(E);
Chris Lattner4c6f9522009-04-27 05:14:47 +0000721}
722
Sebastian Redl60adf4a2010-08-18 23:56:52 +0000723void ASTStmtReader::VisitVAArgExpr(VAArgExpr *E) {
Chris Lattner4c6f9522009-04-27 05:14:47 +0000724 VisitExpr(E);
Argyrios Kyrtzidisd98a2ab2010-06-29 22:46:25 +0000725 E->setSubExpr(Reader.ReadSubExpr());
Sebastian Redlc3632732010-10-05 15:59:54 +0000726 E->setWrittenTypeInfo(GetTypeSourceInfo(Record, Idx));
727 E->setBuiltinLoc(ReadSourceLocation(Record, Idx));
728 E->setRParenLoc(ReadSourceLocation(Record, Idx));
Chris Lattner4c6f9522009-04-27 05:14:47 +0000729}
730
Sebastian Redl60adf4a2010-08-18 23:56:52 +0000731void ASTStmtReader::VisitAddrLabelExpr(AddrLabelExpr *E) {
Chris Lattner4c6f9522009-04-27 05:14:47 +0000732 VisitExpr(E);
Sebastian Redlc3632732010-10-05 15:59:54 +0000733 E->setAmpAmpLoc(ReadSourceLocation(Record, Idx));
734 E->setLabelLoc(ReadSourceLocation(Record, Idx));
Douglas Gregor409448c2011-07-21 22:35:25 +0000735 E->setLabel(ReadDeclAs<LabelDecl>(Record, Idx));
Chris Lattner4c6f9522009-04-27 05:14:47 +0000736}
737
Sebastian Redl60adf4a2010-08-18 23:56:52 +0000738void ASTStmtReader::VisitStmtExpr(StmtExpr *E) {
Chris Lattner4c6f9522009-04-27 05:14:47 +0000739 VisitExpr(E);
Sebastian Redlc3632732010-10-05 15:59:54 +0000740 E->setLParenLoc(ReadSourceLocation(Record, Idx));
741 E->setRParenLoc(ReadSourceLocation(Record, Idx));
Argyrios Kyrtzidisd98a2ab2010-06-29 22:46:25 +0000742 E->setSubStmt(cast_or_null<CompoundStmt>(Reader.ReadSubStmt()));
Chris Lattner4c6f9522009-04-27 05:14:47 +0000743}
744
Sebastian Redl60adf4a2010-08-18 23:56:52 +0000745void ASTStmtReader::VisitChooseExpr(ChooseExpr *E) {
Chris Lattner4c6f9522009-04-27 05:14:47 +0000746 VisitExpr(E);
Argyrios Kyrtzidisd98a2ab2010-06-29 22:46:25 +0000747 E->setCond(Reader.ReadSubExpr());
748 E->setLHS(Reader.ReadSubExpr());
749 E->setRHS(Reader.ReadSubExpr());
Sebastian Redlc3632732010-10-05 15:59:54 +0000750 E->setBuiltinLoc(ReadSourceLocation(Record, Idx));
751 E->setRParenLoc(ReadSourceLocation(Record, Idx));
Chris Lattner4c6f9522009-04-27 05:14:47 +0000752}
753
Sebastian Redl60adf4a2010-08-18 23:56:52 +0000754void ASTStmtReader::VisitGNUNullExpr(GNUNullExpr *E) {
Chris Lattner4c6f9522009-04-27 05:14:47 +0000755 VisitExpr(E);
Sebastian Redlc3632732010-10-05 15:59:54 +0000756 E->setTokenLocation(ReadSourceLocation(Record, Idx));
Chris Lattner4c6f9522009-04-27 05:14:47 +0000757}
758
Sebastian Redl60adf4a2010-08-18 23:56:52 +0000759void ASTStmtReader::VisitShuffleVectorExpr(ShuffleVectorExpr *E) {
Chris Lattner4c6f9522009-04-27 05:14:47 +0000760 VisitExpr(E);
Chris Lattner5f9e2722011-07-23 10:55:15 +0000761 SmallVector<Expr *, 16> Exprs;
Chris Lattner4c6f9522009-04-27 05:14:47 +0000762 unsigned NumExprs = Record[Idx++];
Argyrios Kyrtzidis919e6932010-06-28 22:28:35 +0000763 while (NumExprs--)
Argyrios Kyrtzidisd98a2ab2010-06-29 22:46:25 +0000764 Exprs.push_back(Reader.ReadSubExpr());
Douglas Gregor35942772011-09-09 21:34:22 +0000765 E->setExprs(Reader.getContext(), Exprs.data(), Exprs.size());
Sebastian Redlc3632732010-10-05 15:59:54 +0000766 E->setBuiltinLoc(ReadSourceLocation(Record, Idx));
767 E->setRParenLoc(ReadSourceLocation(Record, Idx));
Chris Lattner4c6f9522009-04-27 05:14:47 +0000768}
769
Sebastian Redl60adf4a2010-08-18 23:56:52 +0000770void ASTStmtReader::VisitBlockExpr(BlockExpr *E) {
Chris Lattner4c6f9522009-04-27 05:14:47 +0000771 VisitExpr(E);
Douglas Gregor409448c2011-07-21 22:35:25 +0000772 E->setBlockDecl(ReadDeclAs<BlockDecl>(Record, Idx));
Chris Lattner4c6f9522009-04-27 05:14:47 +0000773}
774
Peter Collingbournef111d932011-04-15 00:35:48 +0000775void ASTStmtReader::VisitGenericSelectionExpr(GenericSelectionExpr *E) {
776 VisitExpr(E);
777 E->NumAssocs = Record[Idx++];
Douglas Gregor35942772011-09-09 21:34:22 +0000778 E->AssocTypes = new (Reader.getContext()) TypeSourceInfo*[E->NumAssocs];
Peter Collingbournef111d932011-04-15 00:35:48 +0000779 E->SubExprs =
Douglas Gregor35942772011-09-09 21:34:22 +0000780 new(Reader.getContext()) Stmt*[GenericSelectionExpr::END_EXPR+E->NumAssocs];
Peter Collingbournef111d932011-04-15 00:35:48 +0000781
782 E->SubExprs[GenericSelectionExpr::CONTROLLING] = Reader.ReadSubExpr();
783 for (unsigned I = 0, N = E->getNumAssocs(); I != N; ++I) {
784 E->AssocTypes[I] = GetTypeSourceInfo(Record, Idx);
785 E->SubExprs[GenericSelectionExpr::END_EXPR+I] = Reader.ReadSubExpr();
786 }
787 E->ResultIndex = Record[Idx++];
788
789 E->GenericLoc = ReadSourceLocation(Record, Idx);
790 E->DefaultLoc = ReadSourceLocation(Record, Idx);
791 E->RParenLoc = ReadSourceLocation(Record, Idx);
792}
793
John McCall4b9c2d22011-11-06 09:01:30 +0000794void ASTStmtReader::VisitPseudoObjectExpr(PseudoObjectExpr *E) {
795 VisitExpr(E);
796 unsigned numSemanticExprs = Record[Idx++];
797 assert(numSemanticExprs + 1 == E->PseudoObjectExprBits.NumSubExprs);
798 E->PseudoObjectExprBits.ResultIndex = Record[Idx++];
799
800 // Read the syntactic expression.
801 E->getSubExprsBuffer()[0] = Reader.ReadSubExpr();
802
803 // Read all the semantic expressions.
804 for (unsigned i = 0; i != numSemanticExprs; ++i) {
805 Expr *subExpr = Reader.ReadSubExpr();
John McCall4b9c2d22011-11-06 09:01:30 +0000806 E->getSubExprsBuffer()[i+1] = subExpr;
807 }
808}
809
Eli Friedman276b0612011-10-11 02:20:01 +0000810void ASTStmtReader::VisitAtomicExpr(AtomicExpr *E) {
811 VisitExpr(E);
Richard Smithe1b2abc2012-04-10 22:49:28 +0000812 E->Op = AtomicExpr::AtomicOp(Record[Idx++]);
813 E->NumSubExprs = AtomicExpr::getNumSubExprs(E->Op);
814 for (unsigned I = 0; I != E->NumSubExprs; ++I)
815 E->SubExprs[I] = Reader.ReadSubExpr();
816 E->BuiltinLoc = ReadSourceLocation(Record, Idx);
817 E->RParenLoc = ReadSourceLocation(Record, Idx);
Eli Friedman276b0612011-10-11 02:20:01 +0000818}
819
Chris Lattner4c6f9522009-04-27 05:14:47 +0000820//===----------------------------------------------------------------------===//
821// Objective-C Expressions and Statements
822
Sebastian Redl60adf4a2010-08-18 23:56:52 +0000823void ASTStmtReader::VisitObjCStringLiteral(ObjCStringLiteral *E) {
Chris Lattner4c6f9522009-04-27 05:14:47 +0000824 VisitExpr(E);
Argyrios Kyrtzidisd98a2ab2010-06-29 22:46:25 +0000825 E->setString(cast<StringLiteral>(Reader.ReadSubStmt()));
Sebastian Redlc3632732010-10-05 15:59:54 +0000826 E->setAtLoc(ReadSourceLocation(Record, Idx));
Chris Lattner4c6f9522009-04-27 05:14:47 +0000827}
828
Patrick Beardeb382ec2012-04-19 00:25:12 +0000829void ASTStmtReader::VisitObjCBoxedExpr(ObjCBoxedExpr *E) {
Ted Kremenekebcb57a2012-03-06 20:05:56 +0000830 VisitExpr(E);
831 // could be one of several IntegerLiteral, FloatLiteral, etc.
Patrick Beardeb382ec2012-04-19 00:25:12 +0000832 E->SubExpr = Reader.ReadSubStmt();
833 E->BoxingMethod = ReadDeclAs<ObjCMethodDecl>(Record, Idx);
834 E->Range = ReadSourceRange(Record, Idx);
Ted Kremenekebcb57a2012-03-06 20:05:56 +0000835}
836
837void ASTStmtReader::VisitObjCArrayLiteral(ObjCArrayLiteral *E) {
838 VisitExpr(E);
839 unsigned NumElements = Record[Idx++];
840 assert(NumElements == E->getNumElements() && "Wrong number of elements");
841 Expr **Elements = E->getElements();
842 for (unsigned I = 0, N = NumElements; I != N; ++I)
843 Elements[I] = Reader.ReadSubExpr();
844 E->ArrayWithObjectsMethod = ReadDeclAs<ObjCMethodDecl>(Record, Idx);
845 E->Range = ReadSourceRange(Record, Idx);
846}
847
848void ASTStmtReader::VisitObjCDictionaryLiteral(ObjCDictionaryLiteral *E) {
849 VisitExpr(E);
850 unsigned NumElements = Record[Idx++];
851 assert(NumElements == E->getNumElements() && "Wrong number of elements");
852 bool HasPackExpansions = Record[Idx++];
853 assert(HasPackExpansions == E->HasPackExpansions &&"Pack expansion mismatch");
854 ObjCDictionaryLiteral::KeyValuePair *KeyValues = E->getKeyValues();
855 ObjCDictionaryLiteral::ExpansionData *Expansions = E->getExpansionData();
856 for (unsigned I = 0; I != NumElements; ++I) {
857 KeyValues[I].Key = Reader.ReadSubExpr();
858 KeyValues[I].Value = Reader.ReadSubExpr();
859 if (HasPackExpansions) {
860 Expansions[I].EllipsisLoc = ReadSourceLocation(Record, Idx);
861 Expansions[I].NumExpansionsPlusOne = Record[Idx++];
862 }
863 }
864 E->DictWithObjectsMethod = ReadDeclAs<ObjCMethodDecl>(Record, Idx);
865 E->Range = ReadSourceRange(Record, Idx);
866}
867
Sebastian Redl60adf4a2010-08-18 23:56:52 +0000868void ASTStmtReader::VisitObjCEncodeExpr(ObjCEncodeExpr *E) {
Chris Lattner4c6f9522009-04-27 05:14:47 +0000869 VisitExpr(E);
Sebastian Redlc3632732010-10-05 15:59:54 +0000870 E->setEncodedTypeSourceInfo(GetTypeSourceInfo(Record, Idx));
871 E->setAtLoc(ReadSourceLocation(Record, Idx));
872 E->setRParenLoc(ReadSourceLocation(Record, Idx));
Chris Lattner4c6f9522009-04-27 05:14:47 +0000873}
874
Sebastian Redl60adf4a2010-08-18 23:56:52 +0000875void ASTStmtReader::VisitObjCSelectorExpr(ObjCSelectorExpr *E) {
Chris Lattner4c6f9522009-04-27 05:14:47 +0000876 VisitExpr(E);
Douglas Gregor2d2689a2011-07-28 21:16:51 +0000877 E->setSelector(Reader.ReadSelector(F, Record, Idx));
Sebastian Redlc3632732010-10-05 15:59:54 +0000878 E->setAtLoc(ReadSourceLocation(Record, Idx));
879 E->setRParenLoc(ReadSourceLocation(Record, Idx));
Chris Lattner4c6f9522009-04-27 05:14:47 +0000880}
881
Sebastian Redl60adf4a2010-08-18 23:56:52 +0000882void ASTStmtReader::VisitObjCProtocolExpr(ObjCProtocolExpr *E) {
Chris Lattner4c6f9522009-04-27 05:14:47 +0000883 VisitExpr(E);
Douglas Gregor409448c2011-07-21 22:35:25 +0000884 E->setProtocol(ReadDeclAs<ObjCProtocolDecl>(Record, Idx));
Sebastian Redlc3632732010-10-05 15:59:54 +0000885 E->setAtLoc(ReadSourceLocation(Record, Idx));
Argyrios Kyrtzidis7d24e282012-05-16 00:50:02 +0000886 E->ProtoLoc = ReadSourceLocation(Record, Idx);
Sebastian Redlc3632732010-10-05 15:59:54 +0000887 E->setRParenLoc(ReadSourceLocation(Record, Idx));
Chris Lattner4c6f9522009-04-27 05:14:47 +0000888}
889
Sebastian Redl60adf4a2010-08-18 23:56:52 +0000890void ASTStmtReader::VisitObjCIvarRefExpr(ObjCIvarRefExpr *E) {
Chris Lattner4c6f9522009-04-27 05:14:47 +0000891 VisitExpr(E);
Douglas Gregor409448c2011-07-21 22:35:25 +0000892 E->setDecl(ReadDeclAs<ObjCIvarDecl>(Record, Idx));
Sebastian Redlc3632732010-10-05 15:59:54 +0000893 E->setLocation(ReadSourceLocation(Record, Idx));
Argyrios Kyrtzidisd98a2ab2010-06-29 22:46:25 +0000894 E->setBase(Reader.ReadSubExpr());
Chris Lattner4c6f9522009-04-27 05:14:47 +0000895 E->setIsArrow(Record[Idx++]);
896 E->setIsFreeIvar(Record[Idx++]);
Chris Lattner4c6f9522009-04-27 05:14:47 +0000897}
898
Sebastian Redl60adf4a2010-08-18 23:56:52 +0000899void ASTStmtReader::VisitObjCPropertyRefExpr(ObjCPropertyRefExpr *E) {
Chris Lattner4c6f9522009-04-27 05:14:47 +0000900 VisitExpr(E);
Argyrios Kyrtzidisb085d892012-03-30 00:19:18 +0000901 unsigned MethodRefFlags = Record[Idx++];
John McCall12f78a62010-12-02 01:19:52 +0000902 bool Implicit = Record[Idx++] != 0;
903 if (Implicit) {
Douglas Gregor409448c2011-07-21 22:35:25 +0000904 ObjCMethodDecl *Getter = ReadDeclAs<ObjCMethodDecl>(Record, Idx);
905 ObjCMethodDecl *Setter = ReadDeclAs<ObjCMethodDecl>(Record, Idx);
Argyrios Kyrtzidisb085d892012-03-30 00:19:18 +0000906 E->setImplicitProperty(Getter, Setter, MethodRefFlags);
John McCall12f78a62010-12-02 01:19:52 +0000907 } else {
Argyrios Kyrtzidisb085d892012-03-30 00:19:18 +0000908 E->setExplicitProperty(ReadDeclAs<ObjCPropertyDecl>(Record, Idx),
909 MethodRefFlags);
Fariborz Jahanian8ac2d442010-10-14 16:04:05 +0000910 }
Sebastian Redlc3632732010-10-05 15:59:54 +0000911 E->setLocation(ReadSourceLocation(Record, Idx));
John McCall12f78a62010-12-02 01:19:52 +0000912 E->setReceiverLocation(ReadSourceLocation(Record, Idx));
913 switch (Record[Idx++]) {
914 case 0:
915 E->setBase(Reader.ReadSubExpr());
916 break;
917 case 1:
Douglas Gregor393f2492011-07-22 00:38:23 +0000918 E->setSuperReceiver(Reader.readType(F, Record, Idx));
John McCall12f78a62010-12-02 01:19:52 +0000919 break;
920 case 2:
Douglas Gregor409448c2011-07-21 22:35:25 +0000921 E->setClassReceiver(ReadDeclAs<ObjCInterfaceDecl>(Record, Idx));
John McCall12f78a62010-12-02 01:19:52 +0000922 break;
923 }
Chris Lattner4c6f9522009-04-27 05:14:47 +0000924}
925
Ted Kremenekebcb57a2012-03-06 20:05:56 +0000926void ASTStmtReader::VisitObjCSubscriptRefExpr(ObjCSubscriptRefExpr *E) {
927 VisitExpr(E);
928 E->setRBracket(ReadSourceLocation(Record, Idx));
929 E->setBaseExpr(Reader.ReadSubExpr());
930 E->setKeyExpr(Reader.ReadSubExpr());
931 E->GetAtIndexMethodDecl = ReadDeclAs<ObjCMethodDecl>(Record, Idx);
932 E->SetAtIndexMethodDecl = ReadDeclAs<ObjCMethodDecl>(Record, Idx);
933}
934
Sebastian Redl60adf4a2010-08-18 23:56:52 +0000935void ASTStmtReader::VisitObjCMessageExpr(ObjCMessageExpr *E) {
Chris Lattner4c6f9522009-04-27 05:14:47 +0000936 VisitExpr(E);
Douglas Gregor04badcf2010-04-21 00:45:42 +0000937 assert(Record[Idx] == E->getNumArgs());
938 ++Idx;
Argyrios Kyrtzidis20718082011-10-03 06:36:51 +0000939 unsigned NumStoredSelLocs = Record[Idx++];
940 E->SelLocsKind = Record[Idx++];
John McCallf85e1932011-06-15 23:02:42 +0000941 E->setDelegateInitCall(Record[Idx++]);
Argyrios Kyrtzidis746f5bc2012-01-12 02:34:39 +0000942 E->IsImplicit = Record[Idx++];
Douglas Gregor04badcf2010-04-21 00:45:42 +0000943 ObjCMessageExpr::ReceiverKind Kind
944 = static_cast<ObjCMessageExpr::ReceiverKind>(Record[Idx++]);
945 switch (Kind) {
946 case ObjCMessageExpr::Instance:
Argyrios Kyrtzidisd98a2ab2010-06-29 22:46:25 +0000947 E->setInstanceReceiver(Reader.ReadSubExpr());
Douglas Gregor04badcf2010-04-21 00:45:42 +0000948 break;
949
950 case ObjCMessageExpr::Class:
Sebastian Redlc3632732010-10-05 15:59:54 +0000951 E->setClassReceiver(GetTypeSourceInfo(Record, Idx));
Douglas Gregor04badcf2010-04-21 00:45:42 +0000952 break;
953
954 case ObjCMessageExpr::SuperClass:
955 case ObjCMessageExpr::SuperInstance: {
Douglas Gregor393f2492011-07-22 00:38:23 +0000956 QualType T = Reader.readType(F, Record, Idx);
Sebastian Redlc3632732010-10-05 15:59:54 +0000957 SourceLocation SuperLoc = ReadSourceLocation(Record, Idx);
Douglas Gregor04badcf2010-04-21 00:45:42 +0000958 E->setSuper(SuperLoc, T, Kind == ObjCMessageExpr::SuperInstance);
959 break;
960 }
961 }
962
963 assert(Kind == E->getReceiverKind());
964
965 if (Record[Idx++])
Douglas Gregor409448c2011-07-21 22:35:25 +0000966 E->setMethodDecl(ReadDeclAs<ObjCMethodDecl>(Record, Idx));
Douglas Gregor04badcf2010-04-21 00:45:42 +0000967 else
Douglas Gregor2d2689a2011-07-28 21:16:51 +0000968 E->setSelector(Reader.ReadSelector(F, Record, Idx));
Douglas Gregor04badcf2010-04-21 00:45:42 +0000969
Argyrios Kyrtzidisf40f0d52010-12-10 20:08:27 +0000970 E->LBracLoc = ReadSourceLocation(Record, Idx);
971 E->RBracLoc = ReadSourceLocation(Record, Idx);
Chris Lattner4c6f9522009-04-27 05:14:47 +0000972
973 for (unsigned I = 0, N = E->getNumArgs(); I != N; ++I)
Argyrios Kyrtzidisd98a2ab2010-06-29 22:46:25 +0000974 E->setArg(I, Reader.ReadSubExpr());
Argyrios Kyrtzidis20718082011-10-03 06:36:51 +0000975
976 SourceLocation *Locs = E->getStoredSelLocs();
977 for (unsigned I = 0; I != NumStoredSelLocs; ++I)
978 Locs[I] = ReadSourceLocation(Record, Idx);
Chris Lattner4c6f9522009-04-27 05:14:47 +0000979}
980
Sebastian Redl60adf4a2010-08-18 23:56:52 +0000981void ASTStmtReader::VisitObjCForCollectionStmt(ObjCForCollectionStmt *S) {
Chris Lattner4c6f9522009-04-27 05:14:47 +0000982 VisitStmt(S);
Argyrios Kyrtzidisd98a2ab2010-06-29 22:46:25 +0000983 S->setElement(Reader.ReadSubStmt());
984 S->setCollection(Reader.ReadSubExpr());
985 S->setBody(Reader.ReadSubStmt());
Sebastian Redlc3632732010-10-05 15:59:54 +0000986 S->setForLoc(ReadSourceLocation(Record, Idx));
987 S->setRParenLoc(ReadSourceLocation(Record, Idx));
Chris Lattner4c6f9522009-04-27 05:14:47 +0000988}
989
Sebastian Redl60adf4a2010-08-18 23:56:52 +0000990void ASTStmtReader::VisitObjCAtCatchStmt(ObjCAtCatchStmt *S) {
Chris Lattner4c6f9522009-04-27 05:14:47 +0000991 VisitStmt(S);
Argyrios Kyrtzidisd98a2ab2010-06-29 22:46:25 +0000992 S->setCatchBody(Reader.ReadSubStmt());
Douglas Gregor409448c2011-07-21 22:35:25 +0000993 S->setCatchParamDecl(ReadDeclAs<VarDecl>(Record, Idx));
Sebastian Redlc3632732010-10-05 15:59:54 +0000994 S->setAtCatchLoc(ReadSourceLocation(Record, Idx));
995 S->setRParenLoc(ReadSourceLocation(Record, Idx));
Chris Lattner4c6f9522009-04-27 05:14:47 +0000996}
997
Sebastian Redl60adf4a2010-08-18 23:56:52 +0000998void ASTStmtReader::VisitObjCAtFinallyStmt(ObjCAtFinallyStmt *S) {
Chris Lattner4c6f9522009-04-27 05:14:47 +0000999 VisitStmt(S);
Argyrios Kyrtzidisd98a2ab2010-06-29 22:46:25 +00001000 S->setFinallyBody(Reader.ReadSubStmt());
Sebastian Redlc3632732010-10-05 15:59:54 +00001001 S->setAtFinallyLoc(ReadSourceLocation(Record, Idx));
Chris Lattner4c6f9522009-04-27 05:14:47 +00001002}
1003
John McCallf85e1932011-06-15 23:02:42 +00001004void ASTStmtReader::VisitObjCAutoreleasePoolStmt(ObjCAutoreleasePoolStmt *S) {
1005 VisitStmt(S);
1006 S->setSubStmt(Reader.ReadSubStmt());
1007 S->setAtLoc(ReadSourceLocation(Record, Idx));
1008}
1009
Sebastian Redl60adf4a2010-08-18 23:56:52 +00001010void ASTStmtReader::VisitObjCAtTryStmt(ObjCAtTryStmt *S) {
Chris Lattner4c6f9522009-04-27 05:14:47 +00001011 VisitStmt(S);
Douglas Gregor8f5e3dd2010-04-23 22:50:49 +00001012 assert(Record[Idx] == S->getNumCatchStmts());
1013 ++Idx;
1014 bool HasFinally = Record[Idx++];
Argyrios Kyrtzidisd98a2ab2010-06-29 22:46:25 +00001015 S->setTryBody(Reader.ReadSubStmt());
Argyrios Kyrtzidis919e6932010-06-28 22:28:35 +00001016 for (unsigned I = 0, N = S->getNumCatchStmts(); I != N; ++I)
Argyrios Kyrtzidisd98a2ab2010-06-29 22:46:25 +00001017 S->setCatchStmt(I, cast_or_null<ObjCAtCatchStmt>(Reader.ReadSubStmt()));
Douglas Gregor8f5e3dd2010-04-23 22:50:49 +00001018
Douglas Gregor8f5e3dd2010-04-23 22:50:49 +00001019 if (HasFinally)
Argyrios Kyrtzidisd98a2ab2010-06-29 22:46:25 +00001020 S->setFinallyStmt(Reader.ReadSubStmt());
Sebastian Redlc3632732010-10-05 15:59:54 +00001021 S->setAtTryLoc(ReadSourceLocation(Record, Idx));
Chris Lattner4c6f9522009-04-27 05:14:47 +00001022}
1023
Sebastian Redl60adf4a2010-08-18 23:56:52 +00001024void ASTStmtReader::VisitObjCAtSynchronizedStmt(ObjCAtSynchronizedStmt *S) {
Chris Lattner4c6f9522009-04-27 05:14:47 +00001025 VisitStmt(S);
Argyrios Kyrtzidisd98a2ab2010-06-29 22:46:25 +00001026 S->setSynchExpr(Reader.ReadSubStmt());
1027 S->setSynchBody(Reader.ReadSubStmt());
Sebastian Redlc3632732010-10-05 15:59:54 +00001028 S->setAtSynchronizedLoc(ReadSourceLocation(Record, Idx));
Chris Lattner4c6f9522009-04-27 05:14:47 +00001029}
1030
Sebastian Redl60adf4a2010-08-18 23:56:52 +00001031void ASTStmtReader::VisitObjCAtThrowStmt(ObjCAtThrowStmt *S) {
Chris Lattner4c6f9522009-04-27 05:14:47 +00001032 VisitStmt(S);
Argyrios Kyrtzidisd98a2ab2010-06-29 22:46:25 +00001033 S->setThrowExpr(Reader.ReadSubStmt());
Sebastian Redlc3632732010-10-05 15:59:54 +00001034 S->setThrowLoc(ReadSourceLocation(Record, Idx));
Chris Lattner4c6f9522009-04-27 05:14:47 +00001035}
1036
Ted Kremenekebcb57a2012-03-06 20:05:56 +00001037void ASTStmtReader::VisitObjCBoolLiteralExpr(ObjCBoolLiteralExpr *E) {
1038 VisitExpr(E);
1039 E->setValue(Record[Idx++]);
1040 E->setLocation(ReadSourceLocation(Record, Idx));
1041}
1042
Argyrios Kyrtzidisba0a9002009-07-14 03:19:21 +00001043//===----------------------------------------------------------------------===//
1044// C++ Expressions and Statements
Argyrios Kyrtzidis7cb45e32010-07-22 16:03:56 +00001045//===----------------------------------------------------------------------===//
1046
Sebastian Redl60adf4a2010-08-18 23:56:52 +00001047void ASTStmtReader::VisitCXXCatchStmt(CXXCatchStmt *S) {
Argyrios Kyrtzidis7cb45e32010-07-22 16:03:56 +00001048 VisitStmt(S);
Sebastian Redlc3632732010-10-05 15:59:54 +00001049 S->CatchLoc = ReadSourceLocation(Record, Idx);
Douglas Gregor409448c2011-07-21 22:35:25 +00001050 S->ExceptionDecl = ReadDeclAs<VarDecl>(Record, Idx);
Argyrios Kyrtzidis7cb45e32010-07-22 16:03:56 +00001051 S->HandlerBlock = Reader.ReadSubStmt();
1052}
1053
Sebastian Redl60adf4a2010-08-18 23:56:52 +00001054void ASTStmtReader::VisitCXXTryStmt(CXXTryStmt *S) {
Argyrios Kyrtzidis7cb45e32010-07-22 16:03:56 +00001055 VisitStmt(S);
1056 assert(Record[Idx] == S->getNumHandlers() && "NumStmtFields is wrong ?");
1057 ++Idx;
Sebastian Redlc3632732010-10-05 15:59:54 +00001058 S->TryLoc = ReadSourceLocation(Record, Idx);
Argyrios Kyrtzidis7cb45e32010-07-22 16:03:56 +00001059 S->getStmts()[0] = Reader.ReadSubStmt();
1060 for (unsigned i = 0, e = S->getNumHandlers(); i != e; ++i)
1061 S->getStmts()[i + 1] = Reader.ReadSubStmt();
1062}
Argyrios Kyrtzidisba0a9002009-07-14 03:19:21 +00001063
Richard Smithad762fc2011-04-14 22:09:26 +00001064void ASTStmtReader::VisitCXXForRangeStmt(CXXForRangeStmt *S) {
1065 VisitStmt(S);
1066 S->setForLoc(ReadSourceLocation(Record, Idx));
1067 S->setColonLoc(ReadSourceLocation(Record, Idx));
1068 S->setRParenLoc(ReadSourceLocation(Record, Idx));
1069 S->setRangeStmt(Reader.ReadSubStmt());
1070 S->setBeginEndStmt(Reader.ReadSubStmt());
1071 S->setCond(Reader.ReadSubExpr());
1072 S->setInc(Reader.ReadSubExpr());
1073 S->setLoopVarStmt(Reader.ReadSubStmt());
1074 S->setBody(Reader.ReadSubStmt());
1075}
1076
Douglas Gregorba0513d2011-10-25 01:33:02 +00001077void ASTStmtReader::VisitMSDependentExistsStmt(MSDependentExistsStmt *S) {
1078 VisitStmt(S);
1079 S->KeywordLoc = ReadSourceLocation(Record, Idx);
1080 S->IsIfExists = Record[Idx++];
1081 S->QualifierLoc = Reader.ReadNestedNameSpecifierLoc(F, Record, Idx);
1082 ReadDeclarationNameInfo(S->NameInfo, Record, Idx);
1083 S->SubStmt = Reader.ReadSubStmt();
1084}
1085
Sebastian Redl60adf4a2010-08-18 23:56:52 +00001086void ASTStmtReader::VisitCXXOperatorCallExpr(CXXOperatorCallExpr *E) {
Argyrios Kyrtzidis919e6932010-06-28 22:28:35 +00001087 VisitCallExpr(E);
Argyrios Kyrtzidis4548ca22012-04-30 22:12:22 +00001088 E->Operator = (OverloadedOperatorKind)Record[Idx++];
1089 E->Range = Reader.ReadSourceRange(F, Record, Idx);
Argyrios Kyrtzidisba0a9002009-07-14 03:19:21 +00001090}
1091
Sebastian Redl60adf4a2010-08-18 23:56:52 +00001092void ASTStmtReader::VisitCXXConstructExpr(CXXConstructExpr *E) {
Douglas Gregor39da0b82009-09-09 23:08:42 +00001093 VisitExpr(E);
Argyrios Kyrtzidis6d00c132010-07-10 11:46:15 +00001094 E->NumArgs = Record[Idx++];
1095 if (E->NumArgs)
Douglas Gregor35942772011-09-09 21:34:22 +00001096 E->Args = new (Reader.getContext()) Stmt*[E->NumArgs];
Argyrios Kyrtzidis5e1b7c22010-06-24 08:57:09 +00001097 for (unsigned I = 0, N = E->getNumArgs(); I != N; ++I)
Argyrios Kyrtzidisd98a2ab2010-06-29 22:46:25 +00001098 E->setArg(I, Reader.ReadSubExpr());
Douglas Gregor409448c2011-07-21 22:35:25 +00001099 E->setConstructor(ReadDeclAs<CXXConstructorDecl>(Record, Idx));
Sebastian Redlc3632732010-10-05 15:59:54 +00001100 E->setLocation(ReadSourceLocation(Record, Idx));
Abramo Bagnara7cc58b42011-10-05 07:56:41 +00001101 E->setElidable(Record[Idx++]);
1102 E->setHadMultipleCandidates(Record[Idx++]);
Douglas Gregor16006c92009-12-16 18:50:27 +00001103 E->setRequiresZeroInitialization(Record[Idx++]);
Douglas Gregor3c9034c2010-05-15 00:13:29 +00001104 E->setConstructionKind((CXXConstructExpr::ConstructionKind)Record[Idx++]);
Chandler Carruth428edaf2010-10-25 08:47:36 +00001105 E->ParenRange = ReadSourceRange(Record, Idx);
Douglas Gregor39da0b82009-09-09 23:08:42 +00001106}
Chris Lattner4c6f9522009-04-27 05:14:47 +00001107
Sebastian Redl60adf4a2010-08-18 23:56:52 +00001108void ASTStmtReader::VisitCXXTemporaryObjectExpr(CXXTemporaryObjectExpr *E) {
Argyrios Kyrtzidis6d00c132010-07-10 11:46:15 +00001109 VisitCXXConstructExpr(E);
Sebastian Redlc3632732010-10-05 15:59:54 +00001110 E->Type = GetTypeSourceInfo(Record, Idx);
Argyrios Kyrtzidis6d00c132010-07-10 11:46:15 +00001111}
1112
Douglas Gregor01d08012012-02-07 10:09:13 +00001113void ASTStmtReader::VisitLambdaExpr(LambdaExpr *E) {
1114 VisitExpr(E);
Douglas Gregor9d36f5d2012-02-14 17:54:36 +00001115 unsigned NumCaptures = Record[Idx++];
1116 assert(NumCaptures == E->NumCaptures);(void)NumCaptures;
1117 unsigned NumArrayIndexVars = Record[Idx++];
1118 E->IntroducerRange = ReadSourceRange(Record, Idx);
1119 E->CaptureDefault = static_cast<LambdaCaptureDefault>(Record[Idx++]);
1120 E->ExplicitParams = Record[Idx++];
1121 E->ExplicitResultType = Record[Idx++];
1122 E->ClosingBrace = ReadSourceLocation(Record, Idx);
1123
1124 // Read capture initializers.
1125 for (LambdaExpr::capture_init_iterator C = E->capture_init_begin(),
1126 CEnd = E->capture_init_end();
1127 C != CEnd; ++C)
1128 *C = Reader.ReadSubExpr();
1129
1130 // Read array capture index variables.
1131 if (NumArrayIndexVars > 0) {
1132 unsigned *ArrayIndexStarts = E->getArrayIndexStarts();
1133 for (unsigned I = 0; I != NumCaptures + 1; ++I)
1134 ArrayIndexStarts[I] = Record[Idx++];
1135
1136 VarDecl **ArrayIndexVars = E->getArrayIndexVars();
1137 for (unsigned I = 0; I != NumArrayIndexVars; ++I)
1138 ArrayIndexVars[I] = ReadDeclAs<VarDecl>(Record, Idx);
1139 }
Douglas Gregor01d08012012-02-07 10:09:13 +00001140}
1141
Sebastian Redl60adf4a2010-08-18 23:56:52 +00001142void ASTStmtReader::VisitCXXNamedCastExpr(CXXNamedCastExpr *E) {
Argyrios Kyrtzidis919e6932010-06-28 22:28:35 +00001143 VisitExplicitCastExpr(E);
Douglas Gregor1d5d0b92011-01-12 22:41:29 +00001144 SourceRange R = ReadSourceRange(Record, Idx);
1145 E->Loc = R.getBegin();
1146 E->RParenLoc = R.getEnd();
Sam Weinigce757a72010-01-16 21:21:01 +00001147}
1148
Sebastian Redl60adf4a2010-08-18 23:56:52 +00001149void ASTStmtReader::VisitCXXStaticCastExpr(CXXStaticCastExpr *E) {
Sam Weinigce757a72010-01-16 21:21:01 +00001150 return VisitCXXNamedCastExpr(E);
1151}
1152
Sebastian Redl60adf4a2010-08-18 23:56:52 +00001153void ASTStmtReader::VisitCXXDynamicCastExpr(CXXDynamicCastExpr *E) {
Sam Weinigce757a72010-01-16 21:21:01 +00001154 return VisitCXXNamedCastExpr(E);
1155}
1156
Sebastian Redl60adf4a2010-08-18 23:56:52 +00001157void ASTStmtReader::VisitCXXReinterpretCastExpr(CXXReinterpretCastExpr *E) {
Sam Weinigce757a72010-01-16 21:21:01 +00001158 return VisitCXXNamedCastExpr(E);
1159}
1160
Sebastian Redl60adf4a2010-08-18 23:56:52 +00001161void ASTStmtReader::VisitCXXConstCastExpr(CXXConstCastExpr *E) {
Sam Weinigce757a72010-01-16 21:21:01 +00001162 return VisitCXXNamedCastExpr(E);
1163}
1164
Sebastian Redl60adf4a2010-08-18 23:56:52 +00001165void ASTStmtReader::VisitCXXFunctionalCastExpr(CXXFunctionalCastExpr *E) {
Argyrios Kyrtzidis919e6932010-06-28 22:28:35 +00001166 VisitExplicitCastExpr(E);
Sebastian Redlc3632732010-10-05 15:59:54 +00001167 E->setTypeBeginLoc(ReadSourceLocation(Record, Idx));
1168 E->setRParenLoc(ReadSourceLocation(Record, Idx));
Sam Weinigce757a72010-01-16 21:21:01 +00001169}
1170
Richard Smith9fcce652012-03-07 08:35:16 +00001171void ASTStmtReader::VisitUserDefinedLiteral(UserDefinedLiteral *E) {
1172 VisitCallExpr(E);
1173 E->UDSuffixLoc = ReadSourceLocation(Record, Idx);
1174}
1175
Sebastian Redl60adf4a2010-08-18 23:56:52 +00001176void ASTStmtReader::VisitCXXBoolLiteralExpr(CXXBoolLiteralExpr *E) {
Sam Weinigeb7f9612010-02-07 06:32:43 +00001177 VisitExpr(E);
1178 E->setValue(Record[Idx++]);
Sebastian Redlc3632732010-10-05 15:59:54 +00001179 E->setLocation(ReadSourceLocation(Record, Idx));
Sam Weinigeb7f9612010-02-07 06:32:43 +00001180}
1181
Sebastian Redl60adf4a2010-08-18 23:56:52 +00001182void ASTStmtReader::VisitCXXNullPtrLiteralExpr(CXXNullPtrLiteralExpr *E) {
Sam Weinigeb7f9612010-02-07 06:32:43 +00001183 VisitExpr(E);
Sebastian Redlc3632732010-10-05 15:59:54 +00001184 E->setLocation(ReadSourceLocation(Record, Idx));
Sam Weinigeb7f9612010-02-07 06:32:43 +00001185}
1186
Sebastian Redl60adf4a2010-08-18 23:56:52 +00001187void ASTStmtReader::VisitCXXTypeidExpr(CXXTypeidExpr *E) {
Chris Lattner14ab24f2010-05-09 06:03:39 +00001188 VisitExpr(E);
Sebastian Redlc3632732010-10-05 15:59:54 +00001189 E->setSourceRange(ReadSourceRange(Record, Idx));
Chris Lattner14ab24f2010-05-09 06:03:39 +00001190 if (E->isTypeOperand()) { // typeid(int)
Sebastian Redl577d4792010-07-22 22:43:28 +00001191 E->setTypeOperandSourceInfo(
Sebastian Redlc3632732010-10-05 15:59:54 +00001192 GetTypeSourceInfo(Record, Idx));
Argyrios Kyrtzidis919e6932010-06-28 22:28:35 +00001193 return;
Chris Lattner14ab24f2010-05-09 06:03:39 +00001194 }
1195
1196 // typeid(42+2)
Argyrios Kyrtzidisd98a2ab2010-06-29 22:46:25 +00001197 E->setExprOperand(Reader.ReadSubExpr());
Chris Lattner14ab24f2010-05-09 06:03:39 +00001198}
1199
Sebastian Redl60adf4a2010-08-18 23:56:52 +00001200void ASTStmtReader::VisitCXXThisExpr(CXXThisExpr *E) {
Chris Lattner2fbdfcd2010-05-09 06:15:05 +00001201 VisitExpr(E);
Sebastian Redlc3632732010-10-05 15:59:54 +00001202 E->setLocation(ReadSourceLocation(Record, Idx));
Chris Lattner2fbdfcd2010-05-09 06:15:05 +00001203 E->setImplicit(Record[Idx++]);
Chris Lattner2fbdfcd2010-05-09 06:15:05 +00001204}
1205
Sebastian Redl60adf4a2010-08-18 23:56:52 +00001206void ASTStmtReader::VisitCXXThrowExpr(CXXThrowExpr *E) {
Chris Lattner2fbdfcd2010-05-09 06:15:05 +00001207 VisitExpr(E);
Douglas Gregorbca01b42011-07-06 22:04:06 +00001208 E->ThrowLoc = ReadSourceLocation(Record, Idx);
1209 E->Op = Reader.ReadSubExpr();
1210 E->IsThrownVariableInScope = Record[Idx++];
Chris Lattner2fbdfcd2010-05-09 06:15:05 +00001211}
Chris Lattner14ab24f2010-05-09 06:03:39 +00001212
Sebastian Redl60adf4a2010-08-18 23:56:52 +00001213void ASTStmtReader::VisitCXXDefaultArgExpr(CXXDefaultArgExpr *E) {
Chris Lattner030854b2010-05-09 06:40:08 +00001214 VisitExpr(E);
Argyrios Kyrtzidis8a507332010-07-02 23:30:15 +00001215
Douglas Gregordf226552011-09-23 22:07:41 +00001216 assert((bool)Record[Idx] == E->Param.getInt() && "We messed up at creation ?");
Argyrios Kyrtzidis8a507332010-07-02 23:30:15 +00001217 ++Idx; // HasOtherExprStored and SubExpr was handled during creation.
Douglas Gregor409448c2011-07-21 22:35:25 +00001218 E->Param.setPointer(ReadDeclAs<ParmVarDecl>(Record, Idx));
Sebastian Redlc3632732010-10-05 15:59:54 +00001219 E->Loc = ReadSourceLocation(Record, Idx);
Chris Lattnerd2598362010-05-10 00:25:06 +00001220}
1221
Sebastian Redl60adf4a2010-08-18 23:56:52 +00001222void ASTStmtReader::VisitCXXBindTemporaryExpr(CXXBindTemporaryExpr *E) {
Chris Lattnerd2598362010-05-10 00:25:06 +00001223 VisitExpr(E);
Douglas Gregor409448c2011-07-21 22:35:25 +00001224 E->setTemporary(Reader.ReadCXXTemporary(F, Record, Idx));
Argyrios Kyrtzidisd98a2ab2010-06-29 22:46:25 +00001225 E->setSubExpr(Reader.ReadSubExpr());
Chris Lattnerd2598362010-05-10 00:25:06 +00001226}
1227
Sebastian Redl60adf4a2010-08-18 23:56:52 +00001228void ASTStmtReader::VisitCXXScalarValueInitExpr(CXXScalarValueInitExpr *E) {
Chris Lattner59218632010-05-10 01:22:27 +00001229 VisitExpr(E);
Sebastian Redlc3632732010-10-05 15:59:54 +00001230 E->TypeInfo = GetTypeSourceInfo(Record, Idx);
1231 E->RParenLoc = ReadSourceLocation(Record, Idx);
Chris Lattner59218632010-05-10 01:22:27 +00001232}
1233
Sebastian Redl60adf4a2010-08-18 23:56:52 +00001234void ASTStmtReader::VisitCXXNewExpr(CXXNewExpr *E) {
Chris Lattner59218632010-05-10 01:22:27 +00001235 VisitExpr(E);
John McCall6ec278d2011-01-27 09:37:56 +00001236 E->GlobalNew = Record[Idx++];
Sebastian Redl1548d142012-02-16 11:35:52 +00001237 bool isArray = Record[Idx++];
Sebastian Redl2aed8b82012-02-16 12:22:20 +00001238 E->UsualArrayDeleteWantsSize = Record[Idx++];
Chris Lattner59218632010-05-10 01:22:27 +00001239 unsigned NumPlacementArgs = Record[Idx++];
Sebastian Redl2aed8b82012-02-16 12:22:20 +00001240 E->StoredInitializationStyle = Record[Idx++];
Douglas Gregor409448c2011-07-21 22:35:25 +00001241 E->setOperatorNew(ReadDeclAs<FunctionDecl>(Record, Idx));
1242 E->setOperatorDelete(ReadDeclAs<FunctionDecl>(Record, Idx));
Sebastian Redlc3632732010-10-05 15:59:54 +00001243 E->AllocatedTypeInfo = GetTypeSourceInfo(Record, Idx);
Douglas Gregor83bc2762012-02-20 16:12:14 +00001244 E->TypeIdParens = ReadSourceRange(Record, Idx);
Chandler Carruth428edaf2010-10-25 08:47:36 +00001245 E->StartLoc = ReadSourceLocation(Record, Idx);
Douglas Gregor83bc2762012-02-20 16:12:14 +00001246 E->DirectInitRange = ReadSourceRange(Record, Idx);
Chandler Carruth428edaf2010-10-25 08:47:36 +00001247
Douglas Gregor35942772011-09-09 21:34:22 +00001248 E->AllocateArgsArray(Reader.getContext(), isArray, NumPlacementArgs,
Sebastian Redl2aed8b82012-02-16 12:22:20 +00001249 E->StoredInitializationStyle != 0);
Chris Lattner59218632010-05-10 01:22:27 +00001250
1251 // Install all the subexpressions.
Chris Lattner59218632010-05-10 01:22:27 +00001252 for (CXXNewExpr::raw_arg_iterator I = E->raw_arg_begin(),e = E->raw_arg_end();
1253 I != e; ++I)
Argyrios Kyrtzidisd98a2ab2010-06-29 22:46:25 +00001254 *I = Reader.ReadSubStmt();
Chris Lattner59218632010-05-10 01:22:27 +00001255}
1256
Sebastian Redl60adf4a2010-08-18 23:56:52 +00001257void ASTStmtReader::VisitCXXDeleteExpr(CXXDeleteExpr *E) {
Argyrios Kyrtzidis95fc98c2010-06-22 17:07:59 +00001258 VisitExpr(E);
Argyrios Kyrtzidisf1b89112010-09-13 20:15:40 +00001259 E->GlobalDelete = Record[Idx++];
1260 E->ArrayForm = Record[Idx++];
Argyrios Kyrtzidis4076dac2010-09-13 20:15:54 +00001261 E->ArrayFormAsWritten = Record[Idx++];
John McCall6ec278d2011-01-27 09:37:56 +00001262 E->UsualArrayDeleteWantsSize = Record[Idx++];
Douglas Gregor409448c2011-07-21 22:35:25 +00001263 E->OperatorDelete = ReadDeclAs<FunctionDecl>(Record, Idx);
Argyrios Kyrtzidisf1b89112010-09-13 20:15:40 +00001264 E->Argument = Reader.ReadSubExpr();
Sebastian Redlc3632732010-10-05 15:59:54 +00001265 E->Loc = ReadSourceLocation(Record, Idx);
Argyrios Kyrtzidis95fc98c2010-06-22 17:07:59 +00001266}
Chris Lattnerd2598362010-05-10 00:25:06 +00001267
Sebastian Redl60adf4a2010-08-18 23:56:52 +00001268void ASTStmtReader::VisitCXXPseudoDestructorExpr(CXXPseudoDestructorExpr *E) {
Argyrios Kyrtzidisde4bd182010-06-28 09:32:03 +00001269 VisitExpr(E);
1270
Douglas Gregorf3db29f2011-02-25 18:19:59 +00001271 E->Base = Reader.ReadSubExpr();
1272 E->IsArrow = Record[Idx++];
1273 E->OperatorLoc = ReadSourceLocation(Record, Idx);
1274 E->QualifierLoc = Reader.ReadNestedNameSpecifierLoc(F, Record, Idx);
1275 E->ScopeType = GetTypeSourceInfo(Record, Idx);
1276 E->ColonColonLoc = ReadSourceLocation(Record, Idx);
1277 E->TildeLoc = ReadSourceLocation(Record, Idx);
Argyrios Kyrtzidisde4bd182010-06-28 09:32:03 +00001278
Douglas Gregor95eab172011-07-28 20:55:49 +00001279 IdentifierInfo *II = Reader.GetIdentifierInfo(F, Record, Idx);
Argyrios Kyrtzidisde4bd182010-06-28 09:32:03 +00001280 if (II)
Sebastian Redlc3632732010-10-05 15:59:54 +00001281 E->setDestroyedType(II, ReadSourceLocation(Record, Idx));
Argyrios Kyrtzidisde4bd182010-06-28 09:32:03 +00001282 else
Sebastian Redlc3632732010-10-05 15:59:54 +00001283 E->setDestroyedType(GetTypeSourceInfo(Record, Idx));
Argyrios Kyrtzidisde4bd182010-06-28 09:32:03 +00001284}
1285
John McCall4765fa02010-12-06 08:20:24 +00001286void ASTStmtReader::VisitExprWithCleanups(ExprWithCleanups *E) {
Chris Lattnerd2598362010-05-10 00:25:06 +00001287 VisitExpr(E);
John McCall80ee6e82011-11-10 05:35:25 +00001288
1289 unsigned NumObjects = Record[Idx++];
1290 assert(NumObjects == E->getNumObjects());
1291 for (unsigned i = 0; i != NumObjects; ++i)
1292 E->getObjectsBuffer()[i] = ReadDeclAs<BlockDecl>(Record, Idx);
1293
1294 E->SubExpr = Reader.ReadSubExpr();
Chris Lattner030854b2010-05-09 06:40:08 +00001295}
1296
Argyrios Kyrtzidis919e6932010-06-28 22:28:35 +00001297void
Sebastian Redl60adf4a2010-08-18 23:56:52 +00001298ASTStmtReader::VisitCXXDependentScopeMemberExpr(CXXDependentScopeMemberExpr *E){
Argyrios Kyrtzidis8dfbd8b2010-06-24 08:57:31 +00001299 VisitExpr(E);
Abramo Bagnarae4b92762012-01-27 09:46:47 +00001300
1301 if (Record[Idx++]) // HasTemplateKWAndArgsInfo
1302 ReadTemplateKWAndArgsInfo(*E->getTemplateKWAndArgsInfo(),
1303 /*NumTemplateArgs=*/Record[Idx++]);
Argyrios Kyrtzidis8dfbd8b2010-06-24 08:57:31 +00001304
Douglas Gregor7c3179c2011-02-28 18:50:33 +00001305 E->Base = Reader.ReadSubExpr();
Douglas Gregor393f2492011-07-22 00:38:23 +00001306 E->BaseType = Reader.readType(F, Record, Idx);
Douglas Gregor7c3179c2011-02-28 18:50:33 +00001307 E->IsArrow = Record[Idx++];
1308 E->OperatorLoc = ReadSourceLocation(Record, Idx);
1309 E->QualifierLoc = Reader.ReadNestedNameSpecifierLoc(F, Record, Idx);
Douglas Gregor409448c2011-07-21 22:35:25 +00001310 E->FirstQualifierFoundInScope = ReadDeclAs<NamedDecl>(Record, Idx);
Argyrios Kyrtzidis40451072010-10-15 18:21:24 +00001311 ReadDeclarationNameInfo(E->MemberNameInfo, Record, Idx);
Argyrios Kyrtzidis8dfbd8b2010-06-24 08:57:31 +00001312}
1313
Argyrios Kyrtzidis919e6932010-06-28 22:28:35 +00001314void
Sebastian Redl60adf4a2010-08-18 23:56:52 +00001315ASTStmtReader::VisitDependentScopeDeclRefExpr(DependentScopeDeclRefExpr *E) {
Argyrios Kyrtzidis12dffcd2010-06-28 09:31:56 +00001316 VisitExpr(E);
Abramo Bagnarae4b92762012-01-27 09:46:47 +00001317
1318 if (Record[Idx++]) // HasTemplateKWAndArgsInfo
1319 ReadTemplateKWAndArgsInfo(*E->getTemplateKWAndArgsInfo(),
1320 /*NumTemplateArgs=*/Record[Idx++]);
Douglas Gregor00cf3cc2011-02-25 20:49:16 +00001321
1322 E->QualifierLoc = Reader.ReadNestedNameSpecifierLoc(F, Record, Idx);
Argyrios Kyrtzidis40451072010-10-15 18:21:24 +00001323 ReadDeclarationNameInfo(E->NameInfo, Record, Idx);
Argyrios Kyrtzidis12dffcd2010-06-28 09:31:56 +00001324}
1325
Argyrios Kyrtzidis919e6932010-06-28 22:28:35 +00001326void
Sebastian Redl60adf4a2010-08-18 23:56:52 +00001327ASTStmtReader::VisitCXXUnresolvedConstructExpr(CXXUnresolvedConstructExpr *E) {
Argyrios Kyrtzidis8dfbd8b2010-06-24 08:57:31 +00001328 VisitExpr(E);
1329 assert(Record[Idx] == E->arg_size() && "Read wrong record during creation ?");
1330 ++Idx; // NumArgs;
1331 for (unsigned I = 0, N = E->arg_size(); I != N; ++I)
Argyrios Kyrtzidisd98a2ab2010-06-29 22:46:25 +00001332 E->setArg(I, Reader.ReadSubExpr());
Sebastian Redlc3632732010-10-05 15:59:54 +00001333 E->Type = GetTypeSourceInfo(Record, Idx);
1334 E->setLParenLoc(ReadSourceLocation(Record, Idx));
1335 E->setRParenLoc(ReadSourceLocation(Record, Idx));
Argyrios Kyrtzidis8dfbd8b2010-06-24 08:57:31 +00001336}
1337
Sebastian Redl60adf4a2010-08-18 23:56:52 +00001338void ASTStmtReader::VisitOverloadExpr(OverloadExpr *E) {
Argyrios Kyrtzidisa77eb082010-06-25 09:03:26 +00001339 VisitExpr(E);
Abramo Bagnarae4b92762012-01-27 09:46:47 +00001340
1341 if (Record[Idx++]) // HasTemplateKWAndArgsInfo
1342 ReadTemplateKWAndArgsInfo(*E->getTemplateKWAndArgsInfo(),
1343 /*NumTemplateArgs=*/Record[Idx++]);
Argyrios Kyrtzidisa77eb082010-06-25 09:03:26 +00001344
1345 unsigned NumDecls = Record[Idx++];
1346 UnresolvedSet<8> Decls;
1347 for (unsigned i = 0; i != NumDecls; ++i) {
Douglas Gregor409448c2011-07-21 22:35:25 +00001348 NamedDecl *D = ReadDeclAs<NamedDecl>(Record, Idx);
Argyrios Kyrtzidisa77eb082010-06-25 09:03:26 +00001349 AccessSpecifier AS = (AccessSpecifier)Record[Idx++];
1350 Decls.addDecl(D, AS);
1351 }
Douglas Gregor35942772011-09-09 21:34:22 +00001352 E->initializeResults(Reader.getContext(), Decls.begin(), Decls.end());
Argyrios Kyrtzidisa77eb082010-06-25 09:03:26 +00001353
Argyrios Kyrtzidis40451072010-10-15 18:21:24 +00001354 ReadDeclarationNameInfo(E->NameInfo, Record, Idx);
Douglas Gregor4c9be892011-02-28 20:01:57 +00001355 E->QualifierLoc = Reader.ReadNestedNameSpecifierLoc(F, Record, Idx);
Argyrios Kyrtzidisa77eb082010-06-25 09:03:26 +00001356}
1357
Sebastian Redl60adf4a2010-08-18 23:56:52 +00001358void ASTStmtReader::VisitUnresolvedMemberExpr(UnresolvedMemberExpr *E) {
Argyrios Kyrtzidis919e6932010-06-28 22:28:35 +00001359 VisitOverloadExpr(E);
Douglas Gregor4c9be892011-02-28 20:01:57 +00001360 E->IsArrow = Record[Idx++];
1361 E->HasUnresolvedUsing = Record[Idx++];
1362 E->Base = Reader.ReadSubExpr();
Douglas Gregor393f2492011-07-22 00:38:23 +00001363 E->BaseType = Reader.readType(F, Record, Idx);
Douglas Gregor4c9be892011-02-28 20:01:57 +00001364 E->OperatorLoc = ReadSourceLocation(Record, Idx);
Argyrios Kyrtzidisa77eb082010-06-25 09:03:26 +00001365}
1366
Sebastian Redl60adf4a2010-08-18 23:56:52 +00001367void ASTStmtReader::VisitUnresolvedLookupExpr(UnresolvedLookupExpr *E) {
Argyrios Kyrtzidis919e6932010-06-28 22:28:35 +00001368 VisitOverloadExpr(E);
Douglas Gregor4c9be892011-02-28 20:01:57 +00001369 E->RequiresADL = Record[Idx++];
Richard Smithad762fc2011-04-14 22:09:26 +00001370 if (E->RequiresADL)
1371 E->StdIsAssociatedNamespace = Record[Idx++];
Douglas Gregor4c9be892011-02-28 20:01:57 +00001372 E->Overloaded = Record[Idx++];
Douglas Gregor409448c2011-07-21 22:35:25 +00001373 E->NamingClass = ReadDeclAs<CXXRecordDecl>(Record, Idx);
Argyrios Kyrtzidisbd65bb52010-06-25 09:03:34 +00001374}
1375
Sebastian Redl60adf4a2010-08-18 23:56:52 +00001376void ASTStmtReader::VisitUnaryTypeTraitExpr(UnaryTypeTraitExpr *E) {
Argyrios Kyrtzidis6d00c132010-07-10 11:46:15 +00001377 VisitExpr(E);
1378 E->UTT = (UnaryTypeTrait)Record[Idx++];
Sebastian Redl0dfd8482010-09-13 20:56:31 +00001379 E->Value = (bool)Record[Idx++];
Sebastian Redlc3632732010-10-05 15:59:54 +00001380 SourceRange Range = ReadSourceRange(Record, Idx);
Argyrios Kyrtzidis6d00c132010-07-10 11:46:15 +00001381 E->Loc = Range.getBegin();
1382 E->RParen = Range.getEnd();
Sebastian Redlc3632732010-10-05 15:59:54 +00001383 E->QueriedType = GetTypeSourceInfo(Record, Idx);
Argyrios Kyrtzidis6d00c132010-07-10 11:46:15 +00001384}
1385
Francois Pichet6ad6f282010-12-07 00:08:36 +00001386void ASTStmtReader::VisitBinaryTypeTraitExpr(BinaryTypeTraitExpr *E) {
1387 VisitExpr(E);
1388 E->BTT = (BinaryTypeTrait)Record[Idx++];
1389 E->Value = (bool)Record[Idx++];
1390 SourceRange Range = ReadSourceRange(Record, Idx);
1391 E->Loc = Range.getBegin();
1392 E->RParen = Range.getEnd();
1393 E->LhsType = GetTypeSourceInfo(Record, Idx);
1394 E->RhsType = GetTypeSourceInfo(Record, Idx);
1395}
1396
Douglas Gregor4ca8ac22012-02-24 07:38:34 +00001397void ASTStmtReader::VisitTypeTraitExpr(TypeTraitExpr *E) {
1398 VisitExpr(E);
1399 E->TypeTraitExprBits.NumArgs = Record[Idx++];
1400 E->TypeTraitExprBits.Kind = Record[Idx++];
1401 E->TypeTraitExprBits.Value = Record[Idx++];
1402
1403 TypeSourceInfo **Args = E->getTypeSourceInfos();
1404 for (unsigned I = 0, N = E->getNumArgs(); I != N; ++I)
1405 Args[I] = GetTypeSourceInfo(Record, Idx);
1406}
1407
John Wiegley21ff2e52011-04-28 00:16:57 +00001408void ASTStmtReader::VisitArrayTypeTraitExpr(ArrayTypeTraitExpr *E) {
1409 VisitExpr(E);
1410 E->ATT = (ArrayTypeTrait)Record[Idx++];
1411 E->Value = (unsigned int)Record[Idx++];
1412 SourceRange Range = ReadSourceRange(Record, Idx);
1413 E->Loc = Range.getBegin();
1414 E->RParen = Range.getEnd();
1415 E->QueriedType = GetTypeSourceInfo(Record, Idx);
1416}
1417
John Wiegley55262202011-04-25 06:54:41 +00001418void ASTStmtReader::VisitExpressionTraitExpr(ExpressionTraitExpr *E) {
1419 VisitExpr(E);
1420 E->ET = (ExpressionTrait)Record[Idx++];
1421 E->Value = (bool)Record[Idx++];
1422 SourceRange Range = ReadSourceRange(Record, Idx);
1423 E->QueriedExpression = Reader.ReadSubExpr();
1424 E->Loc = Range.getBegin();
1425 E->RParen = Range.getEnd();
1426}
1427
Sebastian Redl6b219d02010-09-10 20:55:54 +00001428void ASTStmtReader::VisitCXXNoexceptExpr(CXXNoexceptExpr *E) {
1429 VisitExpr(E);
Sebastian Redl5221d8f2010-09-10 22:34:40 +00001430 E->Value = (bool)Record[Idx++];
Sebastian Redlc3632732010-10-05 15:59:54 +00001431 E->Range = ReadSourceRange(Record, Idx);
Sebastian Redl5221d8f2010-09-10 22:34:40 +00001432 E->Operand = Reader.ReadSubExpr();
Sebastian Redl6b219d02010-09-10 20:55:54 +00001433}
1434
Douglas Gregorbe230c32011-01-03 17:17:50 +00001435void ASTStmtReader::VisitPackExpansionExpr(PackExpansionExpr *E) {
1436 VisitExpr(E);
1437 E->EllipsisLoc = ReadSourceLocation(Record, Idx);
Douglas Gregor67fd1252011-01-14 21:20:45 +00001438 E->NumExpansions = Record[Idx++];
Douglas Gregorbe230c32011-01-03 17:17:50 +00001439 E->Pattern = Reader.ReadSubExpr();
1440}
1441
Douglas Gregoree8aff02011-01-04 17:33:58 +00001442void ASTStmtReader::VisitSizeOfPackExpr(SizeOfPackExpr *E) {
1443 VisitExpr(E);
1444 E->OperatorLoc = ReadSourceLocation(Record, Idx);
1445 E->PackLoc = ReadSourceLocation(Record, Idx);
1446 E->RParenLoc = ReadSourceLocation(Record, Idx);
1447 E->Length = Record[Idx++];
Douglas Gregor409448c2011-07-21 22:35:25 +00001448 E->Pack = ReadDeclAs<NamedDecl>(Record, Idx);
Douglas Gregoree8aff02011-01-04 17:33:58 +00001449}
1450
John McCall7110fd62011-07-15 07:00:14 +00001451void ASTStmtReader::VisitSubstNonTypeTemplateParmExpr(
1452 SubstNonTypeTemplateParmExpr *E) {
1453 VisitExpr(E);
Douglas Gregor409448c2011-07-21 22:35:25 +00001454 E->Param = ReadDeclAs<NonTypeTemplateParmDecl>(Record, Idx);
John McCall7110fd62011-07-15 07:00:14 +00001455 E->NameLoc = ReadSourceLocation(Record, Idx);
1456 E->Replacement = Reader.ReadSubExpr();
1457}
1458
Douglas Gregorc7793c72011-01-15 01:15:58 +00001459void ASTStmtReader::VisitSubstNonTypeTemplateParmPackExpr(
1460 SubstNonTypeTemplateParmPackExpr *E) {
1461 VisitExpr(E);
Douglas Gregor409448c2011-07-21 22:35:25 +00001462 E->Param = ReadDeclAs<NonTypeTemplateParmDecl>(Record, Idx);
Douglas Gregorc7793c72011-01-15 01:15:58 +00001463 TemplateArgument ArgPack = Reader.ReadTemplateArgument(F, Record, Idx);
1464 if (ArgPack.getKind() != TemplateArgument::Pack)
1465 return;
1466
1467 E->Arguments = ArgPack.pack_begin();
1468 E->NumArguments = ArgPack.pack_size();
1469 E->NameLoc = ReadSourceLocation(Record, Idx);
1470}
1471
Douglas Gregor03e80032011-06-21 17:03:29 +00001472void ASTStmtReader::VisitMaterializeTemporaryExpr(MaterializeTemporaryExpr *E) {
1473 VisitExpr(E);
1474 E->Temporary = Reader.ReadSubExpr();
1475}
1476
John McCall7cd7d1a2010-11-15 23:31:06 +00001477void ASTStmtReader::VisitOpaqueValueExpr(OpaqueValueExpr *E) {
1478 VisitExpr(E);
Argyrios Kyrtzidis8bc27822011-12-03 03:49:52 +00001479 E->SourceExpr = Reader.ReadSubExpr();
Douglas Gregorb608b982011-01-28 02:26:04 +00001480 E->Loc = ReadSourceLocation(Record, Idx);
John McCall7cd7d1a2010-11-15 23:31:06 +00001481}
1482
Peter Collingbournee08ce652011-02-09 21:07:24 +00001483//===----------------------------------------------------------------------===//
John McCall7110fd62011-07-15 07:00:14 +00001484// Microsoft Expressions and Statements
1485//===----------------------------------------------------------------------===//
1486void ASTStmtReader::VisitCXXUuidofExpr(CXXUuidofExpr *E) {
1487 VisitExpr(E);
1488 E->setSourceRange(ReadSourceRange(Record, Idx));
1489 if (E->isTypeOperand()) { // __uuidof(ComType)
1490 E->setTypeOperandSourceInfo(
1491 GetTypeSourceInfo(Record, Idx));
1492 return;
1493 }
1494
1495 // __uuidof(expr)
1496 E->setExprOperand(Reader.ReadSubExpr());
1497}
1498
1499void ASTStmtReader::VisitSEHExceptStmt(SEHExceptStmt *S) {
1500 VisitStmt(S);
1501 S->Loc = ReadSourceLocation(Record, Idx);
1502 S->Children[SEHExceptStmt::FILTER_EXPR] = Reader.ReadSubStmt();
1503 S->Children[SEHExceptStmt::BLOCK] = Reader.ReadSubStmt();
1504}
1505
1506void ASTStmtReader::VisitSEHFinallyStmt(SEHFinallyStmt *S) {
1507 VisitStmt(S);
1508 S->Loc = ReadSourceLocation(Record, Idx);
1509 S->Block = Reader.ReadSubStmt();
1510}
1511
1512void ASTStmtReader::VisitSEHTryStmt(SEHTryStmt *S) {
1513 VisitStmt(S);
1514 S->IsCXXTry = Record[Idx++];
1515 S->TryLoc = ReadSourceLocation(Record, Idx);
1516 S->Children[SEHTryStmt::TRY] = Reader.ReadSubStmt();
1517 S->Children[SEHTryStmt::HANDLER] = Reader.ReadSubStmt();
1518}
1519
1520//===----------------------------------------------------------------------===//
Peter Collingbournee08ce652011-02-09 21:07:24 +00001521// CUDA Expressions and Statements
1522//===----------------------------------------------------------------------===//
1523
1524void ASTStmtReader::VisitCUDAKernelCallExpr(CUDAKernelCallExpr *E) {
1525 VisitCallExpr(E);
1526 E->setConfig(cast<CallExpr>(Reader.ReadSubExpr()));
1527}
1528
John McCall7110fd62011-07-15 07:00:14 +00001529//===----------------------------------------------------------------------===//
1530// OpenCL Expressions and Statements.
1531//===----------------------------------------------------------------------===//
1532void ASTStmtReader::VisitAsTypeExpr(AsTypeExpr *E) {
1533 VisitExpr(E);
1534 E->BuiltinLoc = ReadSourceLocation(Record, Idx);
1535 E->RParenLoc = ReadSourceLocation(Record, Idx);
1536 E->SrcExpr = Reader.ReadSubExpr();
1537}
1538
1539//===----------------------------------------------------------------------===//
1540// ASTReader Implementation
1541//===----------------------------------------------------------------------===//
1542
Douglas Gregor1a4761e2011-11-30 23:21:26 +00001543Stmt *ASTReader::ReadStmt(ModuleFile &F) {
Argyrios Kyrtzidis919e6932010-06-28 22:28:35 +00001544 switch (ReadingKind) {
1545 case Read_Decl:
1546 case Read_Type:
Sebastian Redlc3632732010-10-05 15:59:54 +00001547 return ReadStmtFromStream(F);
Argyrios Kyrtzidis919e6932010-06-28 22:28:35 +00001548 case Read_Stmt:
Argyrios Kyrtzidisd98a2ab2010-06-29 22:46:25 +00001549 return ReadSubStmt();
Argyrios Kyrtzidis919e6932010-06-28 22:28:35 +00001550 }
1551
1552 llvm_unreachable("ReadingKind not set ?");
Argyrios Kyrtzidis919e6932010-06-28 22:28:35 +00001553}
1554
Douglas Gregor1a4761e2011-11-30 23:21:26 +00001555Expr *ASTReader::ReadExpr(ModuleFile &F) {
Sebastian Redlc3632732010-10-05 15:59:54 +00001556 return cast_or_null<Expr>(ReadStmt(F));
Argyrios Kyrtzidis919e6932010-06-28 22:28:35 +00001557}
Chris Lattner030854b2010-05-09 06:40:08 +00001558
Sebastian Redlc43b54c2010-08-18 23:56:43 +00001559Expr *ASTReader::ReadSubExpr() {
Argyrios Kyrtzidisd98a2ab2010-06-29 22:46:25 +00001560 return cast_or_null<Expr>(ReadSubStmt());
1561}
1562
Chris Lattner52e97d12009-04-27 05:41:06 +00001563// Within the bitstream, expressions are stored in Reverse Polish
1564// Notation, with each of the subexpressions preceding the
Argyrios Kyrtzidis919e6932010-06-28 22:28:35 +00001565// expression they are stored in. Subexpressions are stored from last to first.
1566// To evaluate expressions, we continue reading expressions and placing them on
1567// the stack, with expressions having operands removing those operands from the
Chris Lattner52e97d12009-04-27 05:41:06 +00001568// stack. Evaluation terminates when we see a STMT_STOP record, and
1569// the single remaining expression on the stack is our result.
Douglas Gregor1a4761e2011-11-30 23:21:26 +00001570Stmt *ASTReader::ReadStmtFromStream(ModuleFile &F) {
Argyrios Kyrtzidis919e6932010-06-28 22:28:35 +00001571
1572 ReadingKindTracker ReadingKind(Read_Stmt, *this);
Sebastian Redlc3632732010-10-05 15:59:54 +00001573 llvm::BitstreamCursor &Cursor = F.DeclsCursor;
Argyrios Kyrtzidise6f08682011-10-21 23:02:28 +00001574
1575 // Map of offset to previously deserialized stmt. The offset points
1576 /// just after the stmt record.
1577 llvm::DenseMap<uint64_t, Stmt *> StmtEntries;
Sebastian Redlc3632732010-10-05 15:59:54 +00001578
Argyrios Kyrtzidis919e6932010-06-28 22:28:35 +00001579#ifndef NDEBUG
1580 unsigned PrevNumStmts = StmtStack.size();
1581#endif
1582
Chris Lattner4c6f9522009-04-27 05:14:47 +00001583 RecordData Record;
1584 unsigned Idx;
Sebastian Redlc3632732010-10-05 15:59:54 +00001585 ASTStmtReader Reader(*this, F, Cursor, Record, Idx);
Chris Lattner4c6f9522009-04-27 05:14:47 +00001586 Stmt::EmptyShell Empty;
1587
1588 while (true) {
Chris Lattner52e97d12009-04-27 05:41:06 +00001589 unsigned Code = Cursor.ReadCode();
Chris Lattner4c6f9522009-04-27 05:14:47 +00001590 if (Code == llvm::bitc::END_BLOCK) {
Chris Lattner52e97d12009-04-27 05:41:06 +00001591 if (Cursor.ReadBlockEnd()) {
Sebastian Redl3c7f4132010-08-18 23:57:06 +00001592 Error("error at end of block in AST file");
Chris Lattner4c6f9522009-04-27 05:14:47 +00001593 return 0;
1594 }
1595 break;
1596 }
1597
1598 if (Code == llvm::bitc::ENTER_SUBBLOCK) {
1599 // No known subblocks, always skip them.
Chris Lattner52e97d12009-04-27 05:41:06 +00001600 Cursor.ReadSubBlockID();
1601 if (Cursor.SkipBlock()) {
Sebastian Redl3c7f4132010-08-18 23:57:06 +00001602 Error("malformed block record in AST file");
Chris Lattner4c6f9522009-04-27 05:14:47 +00001603 return 0;
1604 }
1605 continue;
1606 }
1607
1608 if (Code == llvm::bitc::DEFINE_ABBREV) {
Chris Lattner52e97d12009-04-27 05:41:06 +00001609 Cursor.ReadAbbrevRecord();
Chris Lattner4c6f9522009-04-27 05:14:47 +00001610 continue;
1611 }
1612
1613 Stmt *S = 0;
1614 Idx = 0;
1615 Record.clear();
1616 bool Finished = false;
Argyrios Kyrtzidise6f08682011-10-21 23:02:28 +00001617 bool IsStmtReference = false;
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001618 switch ((StmtCode)Cursor.ReadRecord(Code, Record)) {
1619 case STMT_STOP:
Chris Lattner4c6f9522009-04-27 05:14:47 +00001620 Finished = true;
1621 break;
1622
Argyrios Kyrtzidise6f08682011-10-21 23:02:28 +00001623 case STMT_REF_PTR:
1624 IsStmtReference = true;
1625 assert(StmtEntries.find(Record[0]) != StmtEntries.end() &&
1626 "No stmt was recorded for this offset reference!");
1627 S = StmtEntries[Record[Idx++]];
1628 break;
1629
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001630 case STMT_NULL_PTR:
Mike Stump1eb44332009-09-09 15:08:12 +00001631 S = 0;
Chris Lattner4c6f9522009-04-27 05:14:47 +00001632 break;
1633
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001634 case STMT_NULL:
Chris Lattner4c6f9522009-04-27 05:14:47 +00001635 S = new (Context) NullStmt(Empty);
1636 break;
1637
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001638 case STMT_COMPOUND:
Chris Lattner4c6f9522009-04-27 05:14:47 +00001639 S = new (Context) CompoundStmt(Empty);
1640 break;
1641
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001642 case STMT_CASE:
Chris Lattner4c6f9522009-04-27 05:14:47 +00001643 S = new (Context) CaseStmt(Empty);
1644 break;
1645
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001646 case STMT_DEFAULT:
Chris Lattner4c6f9522009-04-27 05:14:47 +00001647 S = new (Context) DefaultStmt(Empty);
1648 break;
1649
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001650 case STMT_LABEL:
Chris Lattner4c6f9522009-04-27 05:14:47 +00001651 S = new (Context) LabelStmt(Empty);
1652 break;
1653
Richard Smith534986f2012-04-14 00:33:13 +00001654 case STMT_ATTRIBUTED:
Alexander Kornienko49908902012-07-09 10:04:07 +00001655 S = AttributedStmt::CreateEmpty(
1656 Context,
1657 /*NumAttrs*/Record[ASTStmtReader::NumStmtFields]);
Richard Smith534986f2012-04-14 00:33:13 +00001658 break;
1659
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001660 case STMT_IF:
Chris Lattner4c6f9522009-04-27 05:14:47 +00001661 S = new (Context) IfStmt(Empty);
1662 break;
1663
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001664 case STMT_SWITCH:
Chris Lattner4c6f9522009-04-27 05:14:47 +00001665 S = new (Context) SwitchStmt(Empty);
1666 break;
1667
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001668 case STMT_WHILE:
Chris Lattner4c6f9522009-04-27 05:14:47 +00001669 S = new (Context) WhileStmt(Empty);
1670 break;
1671
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001672 case STMT_DO:
Chris Lattner4c6f9522009-04-27 05:14:47 +00001673 S = new (Context) DoStmt(Empty);
1674 break;
Mike Stump1eb44332009-09-09 15:08:12 +00001675
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001676 case STMT_FOR:
Chris Lattner4c6f9522009-04-27 05:14:47 +00001677 S = new (Context) ForStmt(Empty);
1678 break;
1679
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001680 case STMT_GOTO:
Chris Lattner4c6f9522009-04-27 05:14:47 +00001681 S = new (Context) GotoStmt(Empty);
1682 break;
Mike Stump1eb44332009-09-09 15:08:12 +00001683
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001684 case STMT_INDIRECT_GOTO:
Chris Lattner4c6f9522009-04-27 05:14:47 +00001685 S = new (Context) IndirectGotoStmt(Empty);
1686 break;
1687
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001688 case STMT_CONTINUE:
Chris Lattner4c6f9522009-04-27 05:14:47 +00001689 S = new (Context) ContinueStmt(Empty);
1690 break;
1691
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001692 case STMT_BREAK:
Chris Lattner4c6f9522009-04-27 05:14:47 +00001693 S = new (Context) BreakStmt(Empty);
1694 break;
1695
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001696 case STMT_RETURN:
Chris Lattner4c6f9522009-04-27 05:14:47 +00001697 S = new (Context) ReturnStmt(Empty);
1698 break;
1699
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001700 case STMT_DECL:
Chris Lattner4c6f9522009-04-27 05:14:47 +00001701 S = new (Context) DeclStmt(Empty);
1702 break;
1703
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001704 case STMT_ASM:
Chris Lattner4c6f9522009-04-27 05:14:47 +00001705 S = new (Context) AsmStmt(Empty);
1706 break;
1707
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001708 case EXPR_PREDEFINED:
Chris Lattner4c6f9522009-04-27 05:14:47 +00001709 S = new (Context) PredefinedExpr(Empty);
1710 break;
Mike Stump1eb44332009-09-09 15:08:12 +00001711
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001712 case EXPR_DECL_REF:
Chandler Carruth3aa81402011-05-01 23:48:14 +00001713 S = DeclRefExpr::CreateEmpty(
Douglas Gregor35942772011-09-09 21:34:22 +00001714 Context,
Chandler Carruth3aa81402011-05-01 23:48:14 +00001715 /*HasQualifier=*/Record[ASTStmtReader::NumExprFields],
1716 /*HasFoundDecl=*/Record[ASTStmtReader::NumExprFields + 1],
Abramo Bagnarae4b92762012-01-27 09:46:47 +00001717 /*HasTemplateKWAndArgsInfo=*/Record[ASTStmtReader::NumExprFields + 2],
Chandler Carruth3aa81402011-05-01 23:48:14 +00001718 /*NumTemplateArgs=*/Record[ASTStmtReader::NumExprFields + 2] ?
John McCallf4b88a42012-03-10 09:33:50 +00001719 Record[ASTStmtReader::NumExprFields + 5] : 0);
Chris Lattner4c6f9522009-04-27 05:14:47 +00001720 break;
Mike Stump1eb44332009-09-09 15:08:12 +00001721
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001722 case EXPR_INTEGER_LITERAL:
Douglas Gregor35942772011-09-09 21:34:22 +00001723 S = IntegerLiteral::Create(Context, Empty);
Chris Lattner4c6f9522009-04-27 05:14:47 +00001724 break;
Mike Stump1eb44332009-09-09 15:08:12 +00001725
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001726 case EXPR_FLOATING_LITERAL:
Douglas Gregor35942772011-09-09 21:34:22 +00001727 S = FloatingLiteral::Create(Context, Empty);
Chris Lattner4c6f9522009-04-27 05:14:47 +00001728 break;
Mike Stump1eb44332009-09-09 15:08:12 +00001729
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001730 case EXPR_IMAGINARY_LITERAL:
Chris Lattner4c6f9522009-04-27 05:14:47 +00001731 S = new (Context) ImaginaryLiteral(Empty);
1732 break;
1733
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001734 case EXPR_STRING_LITERAL:
Douglas Gregor35942772011-09-09 21:34:22 +00001735 S = StringLiteral::CreateEmpty(Context,
Sebastian Redl60adf4a2010-08-18 23:56:52 +00001736 Record[ASTStmtReader::NumExprFields + 1]);
Chris Lattner4c6f9522009-04-27 05:14:47 +00001737 break;
1738
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001739 case EXPR_CHARACTER_LITERAL:
Chris Lattner4c6f9522009-04-27 05:14:47 +00001740 S = new (Context) CharacterLiteral(Empty);
1741 break;
1742
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001743 case EXPR_PAREN:
Chris Lattner4c6f9522009-04-27 05:14:47 +00001744 S = new (Context) ParenExpr(Empty);
1745 break;
1746
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001747 case EXPR_PAREN_LIST:
Argyrios Kyrtzidis37bdfe22010-06-30 08:49:18 +00001748 S = new (Context) ParenListExpr(Empty);
1749 break;
1750
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001751 case EXPR_UNARY_OPERATOR:
Chris Lattner4c6f9522009-04-27 05:14:47 +00001752 S = new (Context) UnaryOperator(Empty);
1753 break;
1754
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001755 case EXPR_OFFSETOF:
Douglas Gregor35942772011-09-09 21:34:22 +00001756 S = OffsetOfExpr::CreateEmpty(Context,
Sebastian Redl60adf4a2010-08-18 23:56:52 +00001757 Record[ASTStmtReader::NumExprFields],
1758 Record[ASTStmtReader::NumExprFields + 1]);
Douglas Gregor8ecdb652010-04-28 22:16:22 +00001759 break;
1760
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001761 case EXPR_SIZEOF_ALIGN_OF:
Peter Collingbournef4e3cfb2011-03-11 19:24:49 +00001762 S = new (Context) UnaryExprOrTypeTraitExpr(Empty);
Chris Lattner4c6f9522009-04-27 05:14:47 +00001763 break;
1764
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001765 case EXPR_ARRAY_SUBSCRIPT:
Chris Lattner4c6f9522009-04-27 05:14:47 +00001766 S = new (Context) ArraySubscriptExpr(Empty);
1767 break;
1768
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001769 case EXPR_CALL:
Douglas Gregor35942772011-09-09 21:34:22 +00001770 S = new (Context) CallExpr(Context, Stmt::CallExprClass, Empty);
Chris Lattner4c6f9522009-04-27 05:14:47 +00001771 break;
1772
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001773 case EXPR_MEMBER: {
Argyrios Kyrtzidis663e3802010-07-08 13:09:47 +00001774 // We load everything here and fully initialize it at creation.
1775 // That way we can use MemberExpr::Create and don't have to duplicate its
1776 // logic with a MemberExpr::CreateEmpty.
1777
1778 assert(Idx == 0);
Douglas Gregor40d96a62011-02-28 21:54:11 +00001779 NestedNameSpecifierLoc QualifierLoc;
Argyrios Kyrtzidis663e3802010-07-08 13:09:47 +00001780 if (Record[Idx++]) { // HasQualifier.
Douglas Gregor40d96a62011-02-28 21:54:11 +00001781 QualifierLoc = ReadNestedNameSpecifierLoc(F, Record, Idx);
Argyrios Kyrtzidis663e3802010-07-08 13:09:47 +00001782 }
1783
Abramo Bagnarae4b92762012-01-27 09:46:47 +00001784 SourceLocation TemplateKWLoc;
Argyrios Kyrtzidis663e3802010-07-08 13:09:47 +00001785 TemplateArgumentListInfo ArgInfo;
Abramo Bagnarae4b92762012-01-27 09:46:47 +00001786 bool HasTemplateKWAndArgsInfo = Record[Idx++];
1787 if (HasTemplateKWAndArgsInfo) {
1788 TemplateKWLoc = ReadSourceLocation(F, Record, Idx);
Douglas Gregordef03542011-02-04 12:01:24 +00001789 unsigned NumTemplateArgs = Record[Idx++];
Sebastian Redlc3632732010-10-05 15:59:54 +00001790 ArgInfo.setLAngleLoc(ReadSourceLocation(F, Record, Idx));
1791 ArgInfo.setRAngleLoc(ReadSourceLocation(F, Record, Idx));
Argyrios Kyrtzidis663e3802010-07-08 13:09:47 +00001792 for (unsigned i = 0; i != NumTemplateArgs; ++i)
Sebastian Redlc3632732010-10-05 15:59:54 +00001793 ArgInfo.addArgument(ReadTemplateArgumentLoc(F, Record, Idx));
Argyrios Kyrtzidis663e3802010-07-08 13:09:47 +00001794 }
Abramo Bagnara7cc58b42011-10-05 07:56:41 +00001795
1796 bool HadMultipleCandidates = Record[Idx++];
1797
Douglas Gregor409448c2011-07-21 22:35:25 +00001798 NamedDecl *FoundD = ReadDeclAs<NamedDecl>(F, Record, Idx);
Argyrios Kyrtzidis663e3802010-07-08 13:09:47 +00001799 AccessSpecifier AS = (AccessSpecifier)Record[Idx++];
1800 DeclAccessPair FoundDecl = DeclAccessPair::make(FoundD, AS);
1801
Douglas Gregor393f2492011-07-22 00:38:23 +00001802 QualType T = readType(F, Record, Idx);
John McCallf89e55a2010-11-18 06:31:45 +00001803 ExprValueKind VK = static_cast<ExprValueKind>(Record[Idx++]);
1804 ExprObjectKind OK = static_cast<ExprObjectKind>(Record[Idx++]);
Argyrios Kyrtzidis663e3802010-07-08 13:09:47 +00001805 Expr *Base = ReadSubExpr();
Douglas Gregor409448c2011-07-21 22:35:25 +00001806 ValueDecl *MemberD = ReadDeclAs<ValueDecl>(F, Record, Idx);
Sebastian Redlc3632732010-10-05 15:59:54 +00001807 SourceLocation MemberLoc = ReadSourceLocation(F, Record, Idx);
Abramo Bagnara25777432010-08-11 22:01:17 +00001808 DeclarationNameInfo MemberNameInfo(MemberD->getDeclName(), MemberLoc);
Argyrios Kyrtzidis663e3802010-07-08 13:09:47 +00001809 bool IsArrow = Record[Idx++];
1810
Douglas Gregor35942772011-09-09 21:34:22 +00001811 S = MemberExpr::Create(Context, Base, IsArrow, QualifierLoc,
Abramo Bagnarae4b92762012-01-27 09:46:47 +00001812 TemplateKWLoc, MemberD, FoundDecl, MemberNameInfo,
1813 HasTemplateKWAndArgsInfo ? &ArgInfo : 0,
1814 T, VK, OK);
Argyrios Kyrtzidis40451072010-10-15 18:21:24 +00001815 ReadDeclarationNameLoc(F, cast<MemberExpr>(S)->MemberDNLoc,
1816 MemberD->getDeclName(), Record, Idx);
Abramo Bagnara7cc58b42011-10-05 07:56:41 +00001817 if (HadMultipleCandidates)
1818 cast<MemberExpr>(S)->setHadMultipleCandidates(true);
Chris Lattner4c6f9522009-04-27 05:14:47 +00001819 break;
Argyrios Kyrtzidis663e3802010-07-08 13:09:47 +00001820 }
Chris Lattner4c6f9522009-04-27 05:14:47 +00001821
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001822 case EXPR_BINARY_OPERATOR:
Chris Lattner4c6f9522009-04-27 05:14:47 +00001823 S = new (Context) BinaryOperator(Empty);
1824 break;
1825
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001826 case EXPR_COMPOUND_ASSIGN_OPERATOR:
Chris Lattner4c6f9522009-04-27 05:14:47 +00001827 S = new (Context) CompoundAssignOperator(Empty);
1828 break;
1829
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001830 case EXPR_CONDITIONAL_OPERATOR:
Chris Lattner4c6f9522009-04-27 05:14:47 +00001831 S = new (Context) ConditionalOperator(Empty);
1832 break;
1833
John McCall56ca35d2011-02-17 10:25:35 +00001834 case EXPR_BINARY_CONDITIONAL_OPERATOR:
1835 S = new (Context) BinaryConditionalOperator(Empty);
1836 break;
1837
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001838 case EXPR_IMPLICIT_CAST:
Douglas Gregor35942772011-09-09 21:34:22 +00001839 S = ImplicitCastExpr::CreateEmpty(Context,
Sebastian Redl60adf4a2010-08-18 23:56:52 +00001840 /*PathSize*/ Record[ASTStmtReader::NumExprFields]);
Chris Lattner4c6f9522009-04-27 05:14:47 +00001841 break;
1842
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001843 case EXPR_CSTYLE_CAST:
Douglas Gregor35942772011-09-09 21:34:22 +00001844 S = CStyleCastExpr::CreateEmpty(Context,
Sebastian Redl60adf4a2010-08-18 23:56:52 +00001845 /*PathSize*/ Record[ASTStmtReader::NumExprFields]);
Chris Lattner4c6f9522009-04-27 05:14:47 +00001846 break;
1847
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001848 case EXPR_COMPOUND_LITERAL:
Chris Lattner4c6f9522009-04-27 05:14:47 +00001849 S = new (Context) CompoundLiteralExpr(Empty);
1850 break;
1851
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001852 case EXPR_EXT_VECTOR_ELEMENT:
Chris Lattner4c6f9522009-04-27 05:14:47 +00001853 S = new (Context) ExtVectorElementExpr(Empty);
1854 break;
1855
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001856 case EXPR_INIT_LIST:
Douglas Gregor35942772011-09-09 21:34:22 +00001857 S = new (Context) InitListExpr(getContext(), Empty);
Chris Lattner4c6f9522009-04-27 05:14:47 +00001858 break;
1859
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001860 case EXPR_DESIGNATED_INIT:
Douglas Gregor35942772011-09-09 21:34:22 +00001861 S = DesignatedInitExpr::CreateEmpty(Context,
Sebastian Redl60adf4a2010-08-18 23:56:52 +00001862 Record[ASTStmtReader::NumExprFields] - 1);
Mike Stump1eb44332009-09-09 15:08:12 +00001863
Chris Lattner4c6f9522009-04-27 05:14:47 +00001864 break;
1865
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001866 case EXPR_IMPLICIT_VALUE_INIT:
Chris Lattner4c6f9522009-04-27 05:14:47 +00001867 S = new (Context) ImplicitValueInitExpr(Empty);
1868 break;
1869
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001870 case EXPR_VA_ARG:
Chris Lattner4c6f9522009-04-27 05:14:47 +00001871 S = new (Context) VAArgExpr(Empty);
1872 break;
1873
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001874 case EXPR_ADDR_LABEL:
Chris Lattner4c6f9522009-04-27 05:14:47 +00001875 S = new (Context) AddrLabelExpr(Empty);
1876 break;
1877
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001878 case EXPR_STMT:
Chris Lattner4c6f9522009-04-27 05:14:47 +00001879 S = new (Context) StmtExpr(Empty);
1880 break;
1881
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001882 case EXPR_CHOOSE:
Chris Lattner4c6f9522009-04-27 05:14:47 +00001883 S = new (Context) ChooseExpr(Empty);
1884 break;
1885
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001886 case EXPR_GNU_NULL:
Chris Lattner4c6f9522009-04-27 05:14:47 +00001887 S = new (Context) GNUNullExpr(Empty);
1888 break;
1889
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001890 case EXPR_SHUFFLE_VECTOR:
Chris Lattner4c6f9522009-04-27 05:14:47 +00001891 S = new (Context) ShuffleVectorExpr(Empty);
1892 break;
Mike Stump1eb44332009-09-09 15:08:12 +00001893
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001894 case EXPR_BLOCK:
Chris Lattner4c6f9522009-04-27 05:14:47 +00001895 S = new (Context) BlockExpr(Empty);
1896 break;
1897
Peter Collingbournef111d932011-04-15 00:35:48 +00001898 case EXPR_GENERIC_SELECTION:
1899 S = new (Context) GenericSelectionExpr(Empty);
1900 break;
1901
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001902 case EXPR_OBJC_STRING_LITERAL:
Chris Lattner4c6f9522009-04-27 05:14:47 +00001903 S = new (Context) ObjCStringLiteral(Empty);
1904 break;
Patrick Beardeb382ec2012-04-19 00:25:12 +00001905 case EXPR_OBJC_BOXED_EXPRESSION:
1906 S = new (Context) ObjCBoxedExpr(Empty);
Ted Kremenekebcb57a2012-03-06 20:05:56 +00001907 break;
1908 case EXPR_OBJC_ARRAY_LITERAL:
1909 S = ObjCArrayLiteral::CreateEmpty(Context,
1910 Record[ASTStmtReader::NumExprFields]);
1911 break;
1912 case EXPR_OBJC_DICTIONARY_LITERAL:
1913 S = ObjCDictionaryLiteral::CreateEmpty(Context,
1914 Record[ASTStmtReader::NumExprFields],
1915 Record[ASTStmtReader::NumExprFields + 1]);
1916 break;
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001917 case EXPR_OBJC_ENCODE:
Chris Lattner4c6f9522009-04-27 05:14:47 +00001918 S = new (Context) ObjCEncodeExpr(Empty);
1919 break;
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001920 case EXPR_OBJC_SELECTOR_EXPR:
Chris Lattner4c6f9522009-04-27 05:14:47 +00001921 S = new (Context) ObjCSelectorExpr(Empty);
1922 break;
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001923 case EXPR_OBJC_PROTOCOL_EXPR:
Chris Lattner4c6f9522009-04-27 05:14:47 +00001924 S = new (Context) ObjCProtocolExpr(Empty);
1925 break;
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001926 case EXPR_OBJC_IVAR_REF_EXPR:
Chris Lattner4c6f9522009-04-27 05:14:47 +00001927 S = new (Context) ObjCIvarRefExpr(Empty);
1928 break;
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001929 case EXPR_OBJC_PROPERTY_REF_EXPR:
Chris Lattner4c6f9522009-04-27 05:14:47 +00001930 S = new (Context) ObjCPropertyRefExpr(Empty);
1931 break;
Ted Kremenekebcb57a2012-03-06 20:05:56 +00001932 case EXPR_OBJC_SUBSCRIPT_REF_EXPR:
1933 S = new (Context) ObjCSubscriptRefExpr(Empty);
1934 break;
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001935 case EXPR_OBJC_KVC_REF_EXPR:
John McCall12f78a62010-12-02 01:19:52 +00001936 llvm_unreachable("mismatching AST file");
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001937 case EXPR_OBJC_MESSAGE_EXPR:
Douglas Gregor35942772011-09-09 21:34:22 +00001938 S = ObjCMessageExpr::CreateEmpty(Context,
Argyrios Kyrtzidis20718082011-10-03 06:36:51 +00001939 Record[ASTStmtReader::NumExprFields],
1940 Record[ASTStmtReader::NumExprFields + 1]);
Chris Lattner4c6f9522009-04-27 05:14:47 +00001941 break;
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001942 case EXPR_OBJC_ISA:
Steve Narofff242b1b2009-07-24 17:54:45 +00001943 S = new (Context) ObjCIsaExpr(Empty);
1944 break;
John McCallf85e1932011-06-15 23:02:42 +00001945 case EXPR_OBJC_INDIRECT_COPY_RESTORE:
1946 S = new (Context) ObjCIndirectCopyRestoreExpr(Empty);
1947 break;
1948 case EXPR_OBJC_BRIDGED_CAST:
1949 S = new (Context) ObjCBridgedCastExpr(Empty);
1950 break;
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001951 case STMT_OBJC_FOR_COLLECTION:
Chris Lattner4c6f9522009-04-27 05:14:47 +00001952 S = new (Context) ObjCForCollectionStmt(Empty);
1953 break;
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001954 case STMT_OBJC_CATCH:
Chris Lattner4c6f9522009-04-27 05:14:47 +00001955 S = new (Context) ObjCAtCatchStmt(Empty);
1956 break;
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001957 case STMT_OBJC_FINALLY:
Chris Lattner4c6f9522009-04-27 05:14:47 +00001958 S = new (Context) ObjCAtFinallyStmt(Empty);
1959 break;
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001960 case STMT_OBJC_AT_TRY:
Douglas Gregor35942772011-09-09 21:34:22 +00001961 S = ObjCAtTryStmt::CreateEmpty(Context,
Sebastian Redl60adf4a2010-08-18 23:56:52 +00001962 Record[ASTStmtReader::NumStmtFields],
1963 Record[ASTStmtReader::NumStmtFields + 1]);
Chris Lattner4c6f9522009-04-27 05:14:47 +00001964 break;
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001965 case STMT_OBJC_AT_SYNCHRONIZED:
Chris Lattner4c6f9522009-04-27 05:14:47 +00001966 S = new (Context) ObjCAtSynchronizedStmt(Empty);
1967 break;
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001968 case STMT_OBJC_AT_THROW:
Chris Lattner4c6f9522009-04-27 05:14:47 +00001969 S = new (Context) ObjCAtThrowStmt(Empty);
1970 break;
John McCallf85e1932011-06-15 23:02:42 +00001971 case STMT_OBJC_AUTORELEASE_POOL:
1972 S = new (Context) ObjCAutoreleasePoolStmt(Empty);
1973 break;
Ted Kremenekebcb57a2012-03-06 20:05:56 +00001974 case EXPR_OBJC_BOOL_LITERAL:
1975 S = new (Context) ObjCBoolLiteralExpr(Empty);
1976 break;
John McCall7110fd62011-07-15 07:00:14 +00001977 case STMT_SEH_EXCEPT:
1978 S = new (Context) SEHExceptStmt(Empty);
1979 break;
1980 case STMT_SEH_FINALLY:
1981 S = new (Context) SEHFinallyStmt(Empty);
1982 break;
1983 case STMT_SEH_TRY:
1984 S = new (Context) SEHTryStmt(Empty);
1985 break;
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001986 case STMT_CXX_CATCH:
Argyrios Kyrtzidis7cb45e32010-07-22 16:03:56 +00001987 S = new (Context) CXXCatchStmt(Empty);
1988 break;
1989
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001990 case STMT_CXX_TRY:
Douglas Gregor35942772011-09-09 21:34:22 +00001991 S = CXXTryStmt::Create(Context, Empty,
Sebastian Redl60adf4a2010-08-18 23:56:52 +00001992 /*NumHandlers=*/Record[ASTStmtReader::NumStmtFields]);
Argyrios Kyrtzidis7cb45e32010-07-22 16:03:56 +00001993 break;
1994
Richard Smithad762fc2011-04-14 22:09:26 +00001995 case STMT_CXX_FOR_RANGE:
1996 S = new (Context) CXXForRangeStmt(Empty);
1997 break;
1998
Douglas Gregorba0513d2011-10-25 01:33:02 +00001999 case STMT_MS_DEPENDENT_EXISTS:
2000 S = new (Context) MSDependentExistsStmt(SourceLocation(), true,
2001 NestedNameSpecifierLoc(),
2002 DeclarationNameInfo(),
2003 0);
2004 break;
2005
Sebastian Redl8538e8d2010-08-18 23:57:32 +00002006 case EXPR_CXX_OPERATOR_CALL:
Douglas Gregor35942772011-09-09 21:34:22 +00002007 S = new (Context) CXXOperatorCallExpr(Context, Empty);
Argyrios Kyrtzidisba0a9002009-07-14 03:19:21 +00002008 break;
Chris Lattner1817bd42010-05-09 05:36:05 +00002009
Sebastian Redl8538e8d2010-08-18 23:57:32 +00002010 case EXPR_CXX_MEMBER_CALL:
Douglas Gregor35942772011-09-09 21:34:22 +00002011 S = new (Context) CXXMemberCallExpr(Context, Empty);
Chris Lattner1817bd42010-05-09 05:36:05 +00002012 break;
Douglas Gregor39da0b82009-09-09 23:08:42 +00002013
Sebastian Redl8538e8d2010-08-18 23:57:32 +00002014 case EXPR_CXX_CONSTRUCT:
Argyrios Kyrtzidis6d00c132010-07-10 11:46:15 +00002015 S = new (Context) CXXConstructExpr(Empty);
2016 break;
2017
Sebastian Redl8538e8d2010-08-18 23:57:32 +00002018 case EXPR_CXX_TEMPORARY_OBJECT:
Argyrios Kyrtzidis6d00c132010-07-10 11:46:15 +00002019 S = new (Context) CXXTemporaryObjectExpr(Empty);
Douglas Gregor39da0b82009-09-09 23:08:42 +00002020 break;
Sam Weinigce757a72010-01-16 21:21:01 +00002021
Sebastian Redl8538e8d2010-08-18 23:57:32 +00002022 case EXPR_CXX_STATIC_CAST:
Douglas Gregor35942772011-09-09 21:34:22 +00002023 S = CXXStaticCastExpr::CreateEmpty(Context,
Sebastian Redl60adf4a2010-08-18 23:56:52 +00002024 /*PathSize*/ Record[ASTStmtReader::NumExprFields]);
Sam Weinigce757a72010-01-16 21:21:01 +00002025 break;
2026
Sebastian Redl8538e8d2010-08-18 23:57:32 +00002027 case EXPR_CXX_DYNAMIC_CAST:
Douglas Gregor35942772011-09-09 21:34:22 +00002028 S = CXXDynamicCastExpr::CreateEmpty(Context,
Sebastian Redl60adf4a2010-08-18 23:56:52 +00002029 /*PathSize*/ Record[ASTStmtReader::NumExprFields]);
Sam Weinigce757a72010-01-16 21:21:01 +00002030 break;
2031
Sebastian Redl8538e8d2010-08-18 23:57:32 +00002032 case EXPR_CXX_REINTERPRET_CAST:
Douglas Gregor35942772011-09-09 21:34:22 +00002033 S = CXXReinterpretCastExpr::CreateEmpty(Context,
Sebastian Redl60adf4a2010-08-18 23:56:52 +00002034 /*PathSize*/ Record[ASTStmtReader::NumExprFields]);
Sam Weinigce757a72010-01-16 21:21:01 +00002035 break;
2036
Sebastian Redl8538e8d2010-08-18 23:57:32 +00002037 case EXPR_CXX_CONST_CAST:
Douglas Gregor35942772011-09-09 21:34:22 +00002038 S = CXXConstCastExpr::CreateEmpty(Context);
Sam Weinigce757a72010-01-16 21:21:01 +00002039 break;
2040
Sebastian Redl8538e8d2010-08-18 23:57:32 +00002041 case EXPR_CXX_FUNCTIONAL_CAST:
Douglas Gregor35942772011-09-09 21:34:22 +00002042 S = CXXFunctionalCastExpr::CreateEmpty(Context,
Sebastian Redl60adf4a2010-08-18 23:56:52 +00002043 /*PathSize*/ Record[ASTStmtReader::NumExprFields]);
Sam Weinigce757a72010-01-16 21:21:01 +00002044 break;
2045
Richard Smith9fcce652012-03-07 08:35:16 +00002046 case EXPR_USER_DEFINED_LITERAL:
2047 S = new (Context) UserDefinedLiteral(Context, Empty);
2048 break;
2049
Sebastian Redl8538e8d2010-08-18 23:57:32 +00002050 case EXPR_CXX_BOOL_LITERAL:
Sam Weinigeb7f9612010-02-07 06:32:43 +00002051 S = new (Context) CXXBoolLiteralExpr(Empty);
2052 break;
Sam Weinigce757a72010-01-16 21:21:01 +00002053
Sebastian Redl8538e8d2010-08-18 23:57:32 +00002054 case EXPR_CXX_NULL_PTR_LITERAL:
Sam Weinigeb7f9612010-02-07 06:32:43 +00002055 S = new (Context) CXXNullPtrLiteralExpr(Empty);
2056 break;
Sebastian Redl8538e8d2010-08-18 23:57:32 +00002057 case EXPR_CXX_TYPEID_EXPR:
Chris Lattner14ab24f2010-05-09 06:03:39 +00002058 S = new (Context) CXXTypeidExpr(Empty, true);
2059 break;
Sebastian Redl8538e8d2010-08-18 23:57:32 +00002060 case EXPR_CXX_TYPEID_TYPE:
Chris Lattner14ab24f2010-05-09 06:03:39 +00002061 S = new (Context) CXXTypeidExpr(Empty, false);
2062 break;
Francois Pichet01b7c302010-09-08 12:20:18 +00002063 case EXPR_CXX_UUIDOF_EXPR:
2064 S = new (Context) CXXUuidofExpr(Empty, true);
2065 break;
2066 case EXPR_CXX_UUIDOF_TYPE:
2067 S = new (Context) CXXUuidofExpr(Empty, false);
2068 break;
Sebastian Redl8538e8d2010-08-18 23:57:32 +00002069 case EXPR_CXX_THIS:
Chris Lattner2fbdfcd2010-05-09 06:15:05 +00002070 S = new (Context) CXXThisExpr(Empty);
2071 break;
Sebastian Redl8538e8d2010-08-18 23:57:32 +00002072 case EXPR_CXX_THROW:
Chris Lattner2fbdfcd2010-05-09 06:15:05 +00002073 S = new (Context) CXXThrowExpr(Empty);
2074 break;
Sebastian Redl8538e8d2010-08-18 23:57:32 +00002075 case EXPR_CXX_DEFAULT_ARG: {
Sebastian Redl60adf4a2010-08-18 23:56:52 +00002076 bool HasOtherExprStored = Record[ASTStmtReader::NumExprFields];
Argyrios Kyrtzidis8a507332010-07-02 23:30:15 +00002077 if (HasOtherExprStored) {
2078 Expr *SubExpr = ReadSubExpr();
Douglas Gregor35942772011-09-09 21:34:22 +00002079 S = CXXDefaultArgExpr::Create(Context, SourceLocation(), 0, SubExpr);
Argyrios Kyrtzidis8a507332010-07-02 23:30:15 +00002080 } else
2081 S = new (Context) CXXDefaultArgExpr(Empty);
Chris Lattner030854b2010-05-09 06:40:08 +00002082 break;
Argyrios Kyrtzidis8a507332010-07-02 23:30:15 +00002083 }
Sebastian Redl8538e8d2010-08-18 23:57:32 +00002084 case EXPR_CXX_BIND_TEMPORARY:
Chris Lattnerd2598362010-05-10 00:25:06 +00002085 S = new (Context) CXXBindTemporaryExpr(Empty);
2086 break;
Douglas Gregore2ca6d42010-09-02 21:50:02 +00002087
Sebastian Redl8538e8d2010-08-18 23:57:32 +00002088 case EXPR_CXX_SCALAR_VALUE_INIT:
Douglas Gregored8abf12010-07-08 06:14:04 +00002089 S = new (Context) CXXScalarValueInitExpr(Empty);
Chris Lattner59218632010-05-10 01:22:27 +00002090 break;
Sebastian Redl8538e8d2010-08-18 23:57:32 +00002091 case EXPR_CXX_NEW:
Chris Lattner59218632010-05-10 01:22:27 +00002092 S = new (Context) CXXNewExpr(Empty);
2093 break;
Sebastian Redl8538e8d2010-08-18 23:57:32 +00002094 case EXPR_CXX_DELETE:
Argyrios Kyrtzidis95fc98c2010-06-22 17:07:59 +00002095 S = new (Context) CXXDeleteExpr(Empty);
2096 break;
Sebastian Redl8538e8d2010-08-18 23:57:32 +00002097 case EXPR_CXX_PSEUDO_DESTRUCTOR:
Argyrios Kyrtzidisde4bd182010-06-28 09:32:03 +00002098 S = new (Context) CXXPseudoDestructorExpr(Empty);
2099 break;
Chris Lattner59218632010-05-10 01:22:27 +00002100
John McCall4765fa02010-12-06 08:20:24 +00002101 case EXPR_EXPR_WITH_CLEANUPS:
John McCall80ee6e82011-11-10 05:35:25 +00002102 S = ExprWithCleanups::Create(Context, Empty,
2103 Record[ASTStmtReader::NumExprFields]);
Chris Lattnerd2598362010-05-10 00:25:06 +00002104 break;
Argyrios Kyrtzidis8dfbd8b2010-06-24 08:57:31 +00002105
Sebastian Redl8538e8d2010-08-18 23:57:32 +00002106 case EXPR_CXX_DEPENDENT_SCOPE_MEMBER:
Douglas Gregor35942772011-09-09 21:34:22 +00002107 S = CXXDependentScopeMemberExpr::CreateEmpty(Context,
Abramo Bagnarae4b92762012-01-27 09:46:47 +00002108 /*HasTemplateKWAndArgsInfo=*/Record[ASTStmtReader::NumExprFields],
Douglas Gregordef03542011-02-04 12:01:24 +00002109 /*NumTemplateArgs=*/Record[ASTStmtReader::NumExprFields]
2110 ? Record[ASTStmtReader::NumExprFields + 1]
2111 : 0);
Argyrios Kyrtzidis8dfbd8b2010-06-24 08:57:31 +00002112 break;
2113
Sebastian Redl8538e8d2010-08-18 23:57:32 +00002114 case EXPR_CXX_DEPENDENT_SCOPE_DECL_REF:
Douglas Gregor35942772011-09-09 21:34:22 +00002115 S = DependentScopeDeclRefExpr::CreateEmpty(Context,
Abramo Bagnarae4b92762012-01-27 09:46:47 +00002116 /*HasTemplateKWAndArgsInfo=*/Record[ASTStmtReader::NumExprFields],
Douglas Gregordef03542011-02-04 12:01:24 +00002117 /*NumTemplateArgs=*/Record[ASTStmtReader::NumExprFields]
2118 ? Record[ASTStmtReader::NumExprFields + 1]
2119 : 0);
Argyrios Kyrtzidis12dffcd2010-06-28 09:31:56 +00002120 break;
2121
Sebastian Redl8538e8d2010-08-18 23:57:32 +00002122 case EXPR_CXX_UNRESOLVED_CONSTRUCT:
Douglas Gregor35942772011-09-09 21:34:22 +00002123 S = CXXUnresolvedConstructExpr::CreateEmpty(Context,
Sebastian Redl60adf4a2010-08-18 23:56:52 +00002124 /*NumArgs=*/Record[ASTStmtReader::NumExprFields]);
Argyrios Kyrtzidisa77eb082010-06-25 09:03:26 +00002125 break;
2126
Sebastian Redl8538e8d2010-08-18 23:57:32 +00002127 case EXPR_CXX_UNRESOLVED_MEMBER:
Douglas Gregor35942772011-09-09 21:34:22 +00002128 S = UnresolvedMemberExpr::CreateEmpty(Context,
Abramo Bagnarae4b92762012-01-27 09:46:47 +00002129 /*HasTemplateKWAndArgsInfo=*/Record[ASTStmtReader::NumExprFields],
Douglas Gregordef03542011-02-04 12:01:24 +00002130 /*NumTemplateArgs=*/Record[ASTStmtReader::NumExprFields]
2131 ? Record[ASTStmtReader::NumExprFields + 1]
2132 : 0);
Argyrios Kyrtzidis8dfbd8b2010-06-24 08:57:31 +00002133 break;
Argyrios Kyrtzidisbd65bb52010-06-25 09:03:34 +00002134
Sebastian Redl8538e8d2010-08-18 23:57:32 +00002135 case EXPR_CXX_UNRESOLVED_LOOKUP:
Douglas Gregor35942772011-09-09 21:34:22 +00002136 S = UnresolvedLookupExpr::CreateEmpty(Context,
Abramo Bagnarae4b92762012-01-27 09:46:47 +00002137 /*HasTemplateKWAndArgsInfo=*/Record[ASTStmtReader::NumExprFields],
Douglas Gregordef03542011-02-04 12:01:24 +00002138 /*NumTemplateArgs=*/Record[ASTStmtReader::NumExprFields]
2139 ? Record[ASTStmtReader::NumExprFields + 1]
2140 : 0);
Argyrios Kyrtzidisbd65bb52010-06-25 09:03:34 +00002141 break;
Argyrios Kyrtzidis6d00c132010-07-10 11:46:15 +00002142
Sebastian Redl8538e8d2010-08-18 23:57:32 +00002143 case EXPR_CXX_UNARY_TYPE_TRAIT:
Argyrios Kyrtzidis6d00c132010-07-10 11:46:15 +00002144 S = new (Context) UnaryTypeTraitExpr(Empty);
2145 break;
Sebastian Redl6b219d02010-09-10 20:55:54 +00002146
Francois Pichetf1872372010-12-08 22:35:30 +00002147 case EXPR_BINARY_TYPE_TRAIT:
Francois Pichet6ad6f282010-12-07 00:08:36 +00002148 S = new (Context) BinaryTypeTraitExpr(Empty);
2149 break;
2150
Douglas Gregor4ca8ac22012-02-24 07:38:34 +00002151 case EXPR_TYPE_TRAIT:
2152 S = TypeTraitExpr::CreateDeserialized(Context,
2153 Record[ASTStmtReader::NumExprFields]);
2154 break;
2155
John Wiegley21ff2e52011-04-28 00:16:57 +00002156 case EXPR_ARRAY_TYPE_TRAIT:
2157 S = new (Context) ArrayTypeTraitExpr(Empty);
2158 break;
2159
John Wiegley55262202011-04-25 06:54:41 +00002160 case EXPR_CXX_EXPRESSION_TRAIT:
2161 S = new (Context) ExpressionTraitExpr(Empty);
2162 break;
2163
Sebastian Redl6b219d02010-09-10 20:55:54 +00002164 case EXPR_CXX_NOEXCEPT:
2165 S = new (Context) CXXNoexceptExpr(Empty);
2166 break;
John McCall7cd7d1a2010-11-15 23:31:06 +00002167
Douglas Gregorbe230c32011-01-03 17:17:50 +00002168 case EXPR_PACK_EXPANSION:
2169 S = new (Context) PackExpansionExpr(Empty);
2170 break;
2171
Douglas Gregoree8aff02011-01-04 17:33:58 +00002172 case EXPR_SIZEOF_PACK:
2173 S = new (Context) SizeOfPackExpr(Empty);
2174 break;
2175
John McCall7110fd62011-07-15 07:00:14 +00002176 case EXPR_SUBST_NON_TYPE_TEMPLATE_PARM:
2177 S = new (Context) SubstNonTypeTemplateParmExpr(Empty);
2178 break;
2179
Douglas Gregorc7793c72011-01-15 01:15:58 +00002180 case EXPR_SUBST_NON_TYPE_TEMPLATE_PARM_PACK:
2181 S = new (Context) SubstNonTypeTemplateParmPackExpr(Empty);
2182 break;
2183
Douglas Gregor03e80032011-06-21 17:03:29 +00002184 case EXPR_MATERIALIZE_TEMPORARY:
2185 S = new (Context) MaterializeTemporaryExpr(Empty);
2186 break;
2187
Argyrios Kyrtzidis8bc27822011-12-03 03:49:52 +00002188 case EXPR_OPAQUE_VALUE:
2189 S = new (Context) OpaqueValueExpr(Empty);
John McCall7cd7d1a2010-11-15 23:31:06 +00002190 break;
Peter Collingbournee08ce652011-02-09 21:07:24 +00002191
2192 case EXPR_CUDA_KERNEL_CALL:
Douglas Gregor35942772011-09-09 21:34:22 +00002193 S = new (Context) CUDAKernelCallExpr(Context, Empty);
Peter Collingbournee08ce652011-02-09 21:07:24 +00002194 break;
Tanya Lattner61eee0c2011-06-04 00:47:47 +00002195
2196 case EXPR_ASTYPE:
2197 S = new (Context) AsTypeExpr(Empty);
2198 break;
Eli Friedman276b0612011-10-11 02:20:01 +00002199
John McCall4b9c2d22011-11-06 09:01:30 +00002200 case EXPR_PSEUDO_OBJECT: {
2201 unsigned numSemanticExprs = Record[ASTStmtReader::NumExprFields];
2202 S = PseudoObjectExpr::Create(Context, Empty, numSemanticExprs);
2203 break;
2204 }
2205
Eli Friedman276b0612011-10-11 02:20:01 +00002206 case EXPR_ATOMIC:
2207 S = new (Context) AtomicExpr(Empty);
2208 break;
Douglas Gregor9d36f5d2012-02-14 17:54:36 +00002209
2210 case EXPR_LAMBDA: {
2211 unsigned NumCaptures = Record[ASTStmtReader::NumExprFields];
2212 unsigned NumArrayIndexVars = Record[ASTStmtReader::NumExprFields + 1];
2213 S = LambdaExpr::CreateDeserialized(Context, NumCaptures,
2214 NumArrayIndexVars);
2215 break;
2216 }
Chris Lattner4c6f9522009-04-27 05:14:47 +00002217 }
Argyrios Kyrtzidis6d00c132010-07-10 11:46:15 +00002218
Chris Lattner4c6f9522009-04-27 05:14:47 +00002219 // We hit a STMT_STOP, so we're done with this expression.
2220 if (Finished)
2221 break;
2222
2223 ++NumStatementsRead;
2224
Argyrios Kyrtzidise6f08682011-10-21 23:02:28 +00002225 if (S && !IsStmtReference) {
Argyrios Kyrtzidis919e6932010-06-28 22:28:35 +00002226 Reader.Visit(S);
Argyrios Kyrtzidise6f08682011-10-21 23:02:28 +00002227 StmtEntries[Cursor.GetCurrentBitNo()] = S;
2228 }
2229
Chris Lattner4c6f9522009-04-27 05:14:47 +00002230
2231 assert(Idx == Record.size() && "Invalid deserialization of statement");
2232 StmtStack.push_back(S);
2233 }
Argyrios Kyrtzidis919e6932010-06-28 22:28:35 +00002234
2235#ifndef NDEBUG
2236 assert(StmtStack.size() > PrevNumStmts && "Read too many sub stmts!");
2237 assert(StmtStack.size() == PrevNumStmts + 1 && "Extra expressions on stack!");
2238#endif
2239
2240 return StmtStack.pop_back_val();
Chris Lattner4c6f9522009-04-27 05:14:47 +00002241}