blob: 62459d897423db7963dc4adfbeecbe4cdded7a96 [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"
John McCallaeeacf72013-05-03 00:10:13 +000020#include "clang/Lex/Token.h"
Benjamin Kramer8fe83e12012-02-04 13:45:25 +000021#include "llvm/ADT/SmallString.h"
Chris Lattner4c6f9522009-04-27 05:14:47 +000022using namespace clang;
Sebastian Redl8538e8d2010-08-18 23:57:32 +000023using namespace clang::serialization;
Chris Lattner4c6f9522009-04-27 05:14:47 +000024
Argyrios Kyrtzidis37bdfe22010-06-30 08:49:18 +000025namespace clang {
Argyrios Kyrtzidis17cfded2010-06-28 09:31:42 +000026
Sebastian Redl60adf4a2010-08-18 23:56:52 +000027 class ASTStmtReader : public StmtVisitor<ASTStmtReader> {
Alexey Bataev4fa7eab2013-07-19 03:13:43 +000028 friend class OMPClauseReader;
Douglas Gregor409448c2011-07-21 22:35:25 +000029 typedef ASTReader::RecordData RecordData;
30
Sebastian Redlc43b54c2010-08-18 23:56:43 +000031 ASTReader &Reader;
Douglas Gregor1a4761e2011-11-30 23:21:26 +000032 ModuleFile &F;
Sebastian Redl577d4792010-07-22 22:43:28 +000033 llvm::BitstreamCursor &DeclsCursor;
Sebastian Redlc43b54c2010-08-18 23:56:43 +000034 const ASTReader::RecordData &Record;
Chris Lattner4c6f9522009-04-27 05:14:47 +000035 unsigned &Idx;
Chris Lattner4c6f9522009-04-27 05:14:47 +000036
John McCallaeeacf72013-05-03 00:10:13 +000037 Token ReadToken(const RecordData &R, unsigned &I) {
38 return Reader.ReadToken(F, R, I);
39 }
40
Douglas Gregor409448c2011-07-21 22:35:25 +000041 SourceLocation ReadSourceLocation(const RecordData &R, unsigned &I) {
Sebastian Redlc3632732010-10-05 15:59:54 +000042 return Reader.ReadSourceLocation(F, R, I);
43 }
John McCallaeeacf72013-05-03 00:10:13 +000044
Douglas Gregor409448c2011-07-21 22:35:25 +000045 SourceRange ReadSourceRange(const RecordData &R, unsigned &I) {
Sebastian Redlc3632732010-10-05 15:59:54 +000046 return Reader.ReadSourceRange(F, R, I);
47 }
John McCallaeeacf72013-05-03 00:10:13 +000048
49 std::string ReadString(const RecordData &R, unsigned &I) {
50 return Reader.ReadString(R, I);
51 }
52
Douglas Gregor409448c2011-07-21 22:35:25 +000053 TypeSourceInfo *GetTypeSourceInfo(const RecordData &R, unsigned &I) {
Sebastian Redlc3632732010-10-05 15:59:54 +000054 return Reader.GetTypeSourceInfo(F, R, I);
55 }
Douglas Gregor409448c2011-07-21 22:35:25 +000056
57 serialization::DeclID ReadDeclID(const RecordData &R, unsigned &I) {
58 return Reader.ReadDeclID(F, R, I);
59 }
60
61 Decl *ReadDecl(const RecordData &R, unsigned &I) {
62 return Reader.ReadDecl(F, R, I);
63 }
64
65 template<typename T>
66 T *ReadDeclAs(const RecordData &R, unsigned &I) {
67 return Reader.ReadDeclAs<T>(F, R, I);
68 }
69
Argyrios Kyrtzidis40451072010-10-15 18:21:24 +000070 void ReadDeclarationNameLoc(DeclarationNameLoc &DNLoc, DeclarationName Name,
71 const ASTReader::RecordData &R, unsigned &I) {
72 Reader.ReadDeclarationNameLoc(F, DNLoc, Name, R, I);
73 }
Douglas Gregor409448c2011-07-21 22:35:25 +000074
Argyrios Kyrtzidis40451072010-10-15 18:21:24 +000075 void ReadDeclarationNameInfo(DeclarationNameInfo &NameInfo,
76 const ASTReader::RecordData &R, unsigned &I) {
77 Reader.ReadDeclarationNameInfo(F, NameInfo, R, I);
78 }
Sebastian Redlc3632732010-10-05 15:59:54 +000079
Chris Lattner4c6f9522009-04-27 05:14:47 +000080 public:
Douglas Gregor1a4761e2011-11-30 23:21:26 +000081 ASTStmtReader(ASTReader &Reader, ModuleFile &F,
Sebastian Redlc3632732010-10-05 15:59:54 +000082 llvm::BitstreamCursor &Cursor,
Sebastian Redlc43b54c2010-08-18 23:56:43 +000083 const ASTReader::RecordData &Record, unsigned &Idx)
Sebastian Redlc3632732010-10-05 15:59:54 +000084 : Reader(Reader), F(F), DeclsCursor(Cursor), Record(Record), Idx(Idx) { }
Chris Lattner4c6f9522009-04-27 05:14:47 +000085
86 /// \brief The number of record fields required for the Stmt class
87 /// itself.
88 static const unsigned NumStmtFields = 0;
89
90 /// \brief The number of record fields required for the Expr class
91 /// itself.
Douglas Gregor561f8122011-07-01 01:22:09 +000092 static const unsigned NumExprFields = NumStmtFields + 7;
Abramo Bagnarae4b92762012-01-27 09:46:47 +000093
94 /// \brief Read and initialize a ExplicitTemplateArgumentList structure.
95 void ReadTemplateKWAndArgsInfo(ASTTemplateKWAndArgsInfo &Args,
96 unsigned NumTemplateArgs);
Argyrios Kyrtzidis36c76f02010-06-28 09:31:48 +000097 /// \brief Read and initialize a ExplicitTemplateArgumentList structure.
Argyrios Kyrtzidisb0c3e092011-09-22 20:07:03 +000098 void ReadExplicitTemplateArgumentList(ASTTemplateArgumentListInfo &ArgList,
Argyrios Kyrtzidis919e6932010-06-28 22:28:35 +000099 unsigned NumTemplateArgs);
Chris Lattner4c6f9522009-04-27 05:14:47 +0000100
Argyrios Kyrtzidis919e6932010-06-28 22:28:35 +0000101 void VisitStmt(Stmt *S);
John McCall7110fd62011-07-15 07:00:14 +0000102#define STMT(Type, Base) \
103 void Visit##Type(Type *);
104#include "clang/AST/StmtNodes.inc"
Chris Lattner4c6f9522009-04-27 05:14:47 +0000105 };
106}
107
Sebastian Redl60adf4a2010-08-18 23:56:52 +0000108void ASTStmtReader::
Abramo Bagnarae4b92762012-01-27 09:46:47 +0000109ReadTemplateKWAndArgsInfo(ASTTemplateKWAndArgsInfo &Args,
110 unsigned NumTemplateArgs) {
111 SourceLocation TemplateKWLoc = ReadSourceLocation(Record, Idx);
Argyrios Kyrtzidis36c76f02010-06-28 09:31:48 +0000112 TemplateArgumentListInfo ArgInfo;
Sebastian Redlc3632732010-10-05 15:59:54 +0000113 ArgInfo.setLAngleLoc(ReadSourceLocation(Record, Idx));
114 ArgInfo.setRAngleLoc(ReadSourceLocation(Record, Idx));
Argyrios Kyrtzidis36c76f02010-06-28 09:31:48 +0000115 for (unsigned i = 0; i != NumTemplateArgs; ++i)
Sebastian Redl577d4792010-07-22 22:43:28 +0000116 ArgInfo.addArgument(
Sebastian Redlc3632732010-10-05 15:59:54 +0000117 Reader.ReadTemplateArgumentLoc(F, Record, Idx));
Abramo Bagnarae4b92762012-01-27 09:46:47 +0000118 Args.initializeFrom(TemplateKWLoc, ArgInfo);
Argyrios Kyrtzidis36c76f02010-06-28 09:31:48 +0000119}
120
Sebastian Redl60adf4a2010-08-18 23:56:52 +0000121void ASTStmtReader::VisitStmt(Stmt *S) {
Chris Lattner4c6f9522009-04-27 05:14:47 +0000122 assert(Idx == NumStmtFields && "Incorrect statement field count");
Chris Lattner4c6f9522009-04-27 05:14:47 +0000123}
124
Sebastian Redl60adf4a2010-08-18 23:56:52 +0000125void ASTStmtReader::VisitNullStmt(NullStmt *S) {
Chris Lattner4c6f9522009-04-27 05:14:47 +0000126 VisitStmt(S);
Sebastian Redlc3632732010-10-05 15:59:54 +0000127 S->setSemiLoc(ReadSourceLocation(Record, Idx));
Argyrios Kyrtzidise2ca8282011-09-01 21:53:45 +0000128 S->HasLeadingEmptyMacro = Record[Idx++];
Chris Lattner4c6f9522009-04-27 05:14:47 +0000129}
130
Sebastian Redl60adf4a2010-08-18 23:56:52 +0000131void ASTStmtReader::VisitCompoundStmt(CompoundStmt *S) {
Chris Lattner4c6f9522009-04-27 05:14:47 +0000132 VisitStmt(S);
Chris Lattner5f9e2722011-07-23 10:55:15 +0000133 SmallVector<Stmt *, 16> Stmts;
Chris Lattner4c6f9522009-04-27 05:14:47 +0000134 unsigned NumStmts = Record[Idx++];
Argyrios Kyrtzidis919e6932010-06-28 22:28:35 +0000135 while (NumStmts--)
Argyrios Kyrtzidisd98a2ab2010-06-29 22:46:25 +0000136 Stmts.push_back(Reader.ReadSubStmt());
Douglas Gregor35942772011-09-09 21:34:22 +0000137 S->setStmts(Reader.getContext(), Stmts.data(), Stmts.size());
Sebastian Redlc3632732010-10-05 15:59:54 +0000138 S->setLBracLoc(ReadSourceLocation(Record, Idx));
139 S->setRBracLoc(ReadSourceLocation(Record, Idx));
Chris Lattner4c6f9522009-04-27 05:14:47 +0000140}
141
Sebastian Redl60adf4a2010-08-18 23:56:52 +0000142void ASTStmtReader::VisitSwitchCase(SwitchCase *S) {
Chris Lattner4c6f9522009-04-27 05:14:47 +0000143 VisitStmt(S);
144 Reader.RecordSwitchCaseID(S, Record[Idx++]);
Argyrios Kyrtzidis81cc2f12013-01-04 18:30:04 +0000145 S->setKeywordLoc(ReadSourceLocation(Record, Idx));
146 S->setColonLoc(ReadSourceLocation(Record, Idx));
Chris Lattner4c6f9522009-04-27 05:14:47 +0000147}
148
Sebastian Redl60adf4a2010-08-18 23:56:52 +0000149void ASTStmtReader::VisitCaseStmt(CaseStmt *S) {
Chris Lattner4c6f9522009-04-27 05:14:47 +0000150 VisitSwitchCase(S);
Argyrios Kyrtzidisd98a2ab2010-06-29 22:46:25 +0000151 S->setLHS(Reader.ReadSubExpr());
152 S->setRHS(Reader.ReadSubExpr());
153 S->setSubStmt(Reader.ReadSubStmt());
Sebastian Redlc3632732010-10-05 15:59:54 +0000154 S->setEllipsisLoc(ReadSourceLocation(Record, Idx));
Chris Lattner4c6f9522009-04-27 05:14:47 +0000155}
156
Sebastian Redl60adf4a2010-08-18 23:56:52 +0000157void ASTStmtReader::VisitDefaultStmt(DefaultStmt *S) {
Chris Lattner4c6f9522009-04-27 05:14:47 +0000158 VisitSwitchCase(S);
Argyrios Kyrtzidisd98a2ab2010-06-29 22:46:25 +0000159 S->setSubStmt(Reader.ReadSubStmt());
Chris Lattner4c6f9522009-04-27 05:14:47 +0000160}
161
Sebastian Redl60adf4a2010-08-18 23:56:52 +0000162void ASTStmtReader::VisitLabelStmt(LabelStmt *S) {
Chris Lattner4c6f9522009-04-27 05:14:47 +0000163 VisitStmt(S);
Douglas Gregor409448c2011-07-21 22:35:25 +0000164 LabelDecl *LD = ReadDeclAs<LabelDecl>(Record, Idx);
Chris Lattnerad8dcf42011-02-17 07:39:24 +0000165 LD->setStmt(S);
166 S->setDecl(LD);
Argyrios Kyrtzidisd98a2ab2010-06-29 22:46:25 +0000167 S->setSubStmt(Reader.ReadSubStmt());
Sebastian Redlc3632732010-10-05 15:59:54 +0000168 S->setIdentLoc(ReadSourceLocation(Record, Idx));
Chris Lattner4c6f9522009-04-27 05:14:47 +0000169}
170
Richard Smith534986f2012-04-14 00:33:13 +0000171void ASTStmtReader::VisitAttributedStmt(AttributedStmt *S) {
172 VisitStmt(S);
Alexander Kornienko49908902012-07-09 10:04:07 +0000173 uint64_t NumAttrs = Record[Idx++];
Richard Smith534986f2012-04-14 00:33:13 +0000174 AttrVec Attrs;
175 Reader.ReadAttributes(F, Attrs, Record, Idx);
Matt Beaumont-Gay50470242012-07-09 18:55:31 +0000176 (void)NumAttrs;
Alexander Kornienko49908902012-07-09 10:04:07 +0000177 assert(NumAttrs == S->NumAttrs);
178 assert(NumAttrs == Attrs.size());
179 std::copy(Attrs.begin(), Attrs.end(), S->Attrs);
Richard Smith534986f2012-04-14 00:33:13 +0000180 S->SubStmt = Reader.ReadSubStmt();
181 S->AttrLoc = ReadSourceLocation(Record, Idx);
182}
183
Sebastian Redl60adf4a2010-08-18 23:56:52 +0000184void ASTStmtReader::VisitIfStmt(IfStmt *S) {
Chris Lattner4c6f9522009-04-27 05:14:47 +0000185 VisitStmt(S);
Richard Smith534986f2012-04-14 00:33:13 +0000186 S->setConditionVariable(Reader.getContext(),
Douglas Gregor409448c2011-07-21 22:35:25 +0000187 ReadDeclAs<VarDecl>(Record, Idx));
Argyrios Kyrtzidisd98a2ab2010-06-29 22:46:25 +0000188 S->setCond(Reader.ReadSubExpr());
189 S->setThen(Reader.ReadSubStmt());
190 S->setElse(Reader.ReadSubStmt());
Sebastian Redlc3632732010-10-05 15:59:54 +0000191 S->setIfLoc(ReadSourceLocation(Record, Idx));
192 S->setElseLoc(ReadSourceLocation(Record, Idx));
Chris Lattner4c6f9522009-04-27 05:14:47 +0000193}
194
Sebastian Redl60adf4a2010-08-18 23:56:52 +0000195void ASTStmtReader::VisitSwitchStmt(SwitchStmt *S) {
Chris Lattner4c6f9522009-04-27 05:14:47 +0000196 VisitStmt(S);
Douglas Gregor35942772011-09-09 21:34:22 +0000197 S->setConditionVariable(Reader.getContext(),
Douglas Gregor409448c2011-07-21 22:35:25 +0000198 ReadDeclAs<VarDecl>(Record, Idx));
Argyrios Kyrtzidisd98a2ab2010-06-29 22:46:25 +0000199 S->setCond(Reader.ReadSubExpr());
200 S->setBody(Reader.ReadSubStmt());
Sebastian Redlc3632732010-10-05 15:59:54 +0000201 S->setSwitchLoc(ReadSourceLocation(Record, Idx));
Ted Kremenek559fb552010-09-09 00:05:53 +0000202 if (Record[Idx++])
203 S->setAllEnumCasesCovered();
204
Chris Lattner4c6f9522009-04-27 05:14:47 +0000205 SwitchCase *PrevSC = 0;
206 for (unsigned N = Record.size(); Idx != N; ++Idx) {
207 SwitchCase *SC = Reader.getSwitchCaseWithID(Record[Idx]);
208 if (PrevSC)
209 PrevSC->setNextSwitchCase(SC);
210 else
211 S->setSwitchCaseList(SC);
Mike Stump1eb44332009-09-09 15:08:12 +0000212
Chris Lattner4c6f9522009-04-27 05:14:47 +0000213 PrevSC = SC;
214 }
Chris Lattner4c6f9522009-04-27 05:14:47 +0000215}
216
Sebastian Redl60adf4a2010-08-18 23:56:52 +0000217void ASTStmtReader::VisitWhileStmt(WhileStmt *S) {
Chris Lattner4c6f9522009-04-27 05:14:47 +0000218 VisitStmt(S);
Douglas Gregor35942772011-09-09 21:34:22 +0000219 S->setConditionVariable(Reader.getContext(),
Douglas Gregor409448c2011-07-21 22:35:25 +0000220 ReadDeclAs<VarDecl>(Record, Idx));
221
Argyrios Kyrtzidisd98a2ab2010-06-29 22:46:25 +0000222 S->setCond(Reader.ReadSubExpr());
223 S->setBody(Reader.ReadSubStmt());
Sebastian Redlc3632732010-10-05 15:59:54 +0000224 S->setWhileLoc(ReadSourceLocation(Record, Idx));
Chris Lattner4c6f9522009-04-27 05:14:47 +0000225}
226
Sebastian Redl60adf4a2010-08-18 23:56:52 +0000227void ASTStmtReader::VisitDoStmt(DoStmt *S) {
Chris Lattner4c6f9522009-04-27 05:14:47 +0000228 VisitStmt(S);
Argyrios Kyrtzidisd98a2ab2010-06-29 22:46:25 +0000229 S->setCond(Reader.ReadSubExpr());
230 S->setBody(Reader.ReadSubStmt());
Sebastian Redlc3632732010-10-05 15:59:54 +0000231 S->setDoLoc(ReadSourceLocation(Record, Idx));
232 S->setWhileLoc(ReadSourceLocation(Record, Idx));
233 S->setRParenLoc(ReadSourceLocation(Record, Idx));
Chris Lattner4c6f9522009-04-27 05:14:47 +0000234}
235
Sebastian Redl60adf4a2010-08-18 23:56:52 +0000236void ASTStmtReader::VisitForStmt(ForStmt *S) {
Chris Lattner4c6f9522009-04-27 05:14:47 +0000237 VisitStmt(S);
Argyrios Kyrtzidisd98a2ab2010-06-29 22:46:25 +0000238 S->setInit(Reader.ReadSubStmt());
239 S->setCond(Reader.ReadSubExpr());
Douglas Gregor35942772011-09-09 21:34:22 +0000240 S->setConditionVariable(Reader.getContext(),
Douglas Gregor409448c2011-07-21 22:35:25 +0000241 ReadDeclAs<VarDecl>(Record, Idx));
Argyrios Kyrtzidisd98a2ab2010-06-29 22:46:25 +0000242 S->setInc(Reader.ReadSubExpr());
243 S->setBody(Reader.ReadSubStmt());
Sebastian Redlc3632732010-10-05 15:59:54 +0000244 S->setForLoc(ReadSourceLocation(Record, Idx));
245 S->setLParenLoc(ReadSourceLocation(Record, Idx));
246 S->setRParenLoc(ReadSourceLocation(Record, Idx));
Chris Lattner4c6f9522009-04-27 05:14:47 +0000247}
248
Sebastian Redl60adf4a2010-08-18 23:56:52 +0000249void ASTStmtReader::VisitGotoStmt(GotoStmt *S) {
Chris Lattner4c6f9522009-04-27 05:14:47 +0000250 VisitStmt(S);
Douglas Gregor409448c2011-07-21 22:35:25 +0000251 S->setLabel(ReadDeclAs<LabelDecl>(Record, Idx));
Sebastian Redlc3632732010-10-05 15:59:54 +0000252 S->setGotoLoc(ReadSourceLocation(Record, Idx));
253 S->setLabelLoc(ReadSourceLocation(Record, Idx));
Chris Lattner4c6f9522009-04-27 05:14:47 +0000254}
255
Sebastian Redl60adf4a2010-08-18 23:56:52 +0000256void ASTStmtReader::VisitIndirectGotoStmt(IndirectGotoStmt *S) {
Chris Lattner4c6f9522009-04-27 05:14:47 +0000257 VisitStmt(S);
Sebastian Redlc3632732010-10-05 15:59:54 +0000258 S->setGotoLoc(ReadSourceLocation(Record, Idx));
259 S->setStarLoc(ReadSourceLocation(Record, Idx));
Argyrios Kyrtzidisd98a2ab2010-06-29 22:46:25 +0000260 S->setTarget(Reader.ReadSubExpr());
Chris Lattner4c6f9522009-04-27 05:14:47 +0000261}
262
Sebastian Redl60adf4a2010-08-18 23:56:52 +0000263void ASTStmtReader::VisitContinueStmt(ContinueStmt *S) {
Chris Lattner4c6f9522009-04-27 05:14:47 +0000264 VisitStmt(S);
Sebastian Redlc3632732010-10-05 15:59:54 +0000265 S->setContinueLoc(ReadSourceLocation(Record, Idx));
Chris Lattner4c6f9522009-04-27 05:14:47 +0000266}
267
Sebastian Redl60adf4a2010-08-18 23:56:52 +0000268void ASTStmtReader::VisitBreakStmt(BreakStmt *S) {
Chris Lattner4c6f9522009-04-27 05:14:47 +0000269 VisitStmt(S);
Sebastian Redlc3632732010-10-05 15:59:54 +0000270 S->setBreakLoc(ReadSourceLocation(Record, Idx));
Chris Lattner4c6f9522009-04-27 05:14:47 +0000271}
272
Sebastian Redl60adf4a2010-08-18 23:56:52 +0000273void ASTStmtReader::VisitReturnStmt(ReturnStmt *S) {
Chris Lattner4c6f9522009-04-27 05:14:47 +0000274 VisitStmt(S);
Argyrios Kyrtzidisd98a2ab2010-06-29 22:46:25 +0000275 S->setRetValue(Reader.ReadSubExpr());
Sebastian Redlc3632732010-10-05 15:59:54 +0000276 S->setReturnLoc(ReadSourceLocation(Record, Idx));
Douglas Gregor409448c2011-07-21 22:35:25 +0000277 S->setNRVOCandidate(ReadDeclAs<VarDecl>(Record, Idx));
Chris Lattner4c6f9522009-04-27 05:14:47 +0000278}
279
Sebastian Redl60adf4a2010-08-18 23:56:52 +0000280void ASTStmtReader::VisitDeclStmt(DeclStmt *S) {
Chris Lattner4c6f9522009-04-27 05:14:47 +0000281 VisitStmt(S);
Sebastian Redlc3632732010-10-05 15:59:54 +0000282 S->setStartLoc(ReadSourceLocation(Record, Idx));
283 S->setEndLoc(ReadSourceLocation(Record, Idx));
Chris Lattner4c6f9522009-04-27 05:14:47 +0000284
285 if (Idx + 1 == Record.size()) {
286 // Single declaration
Douglas Gregor409448c2011-07-21 22:35:25 +0000287 S->setDeclGroup(DeclGroupRef(ReadDecl(Record, Idx)));
Chris Lattner4c6f9522009-04-27 05:14:47 +0000288 } else {
Chris Lattner5f9e2722011-07-23 10:55:15 +0000289 SmallVector<Decl *, 16> Decls;
Douglas Gregor409448c2011-07-21 22:35:25 +0000290 Decls.reserve(Record.size() - Idx);
291 for (unsigned N = Record.size(); Idx != N; )
292 Decls.push_back(ReadDecl(Record, Idx));
Douglas Gregor35942772011-09-09 21:34:22 +0000293 S->setDeclGroup(DeclGroupRef(DeclGroup::Create(Reader.getContext(),
Douglas Gregor75fdb232009-05-22 22:45:36 +0000294 Decls.data(),
295 Decls.size())));
Chris Lattner4c6f9522009-04-27 05:14:47 +0000296 }
Chris Lattner4c6f9522009-04-27 05:14:47 +0000297}
298
John McCallaeeacf72013-05-03 00:10:13 +0000299void ASTStmtReader::VisitAsmStmt(AsmStmt *S) {
Chris Lattner4c6f9522009-04-27 05:14:47 +0000300 VisitStmt(S);
John McCallaeeacf72013-05-03 00:10:13 +0000301 S->NumOutputs = Record[Idx++];
302 S->NumInputs = Record[Idx++];
303 S->NumClobbers = Record[Idx++];
Sebastian Redlc3632732010-10-05 15:59:54 +0000304 S->setAsmLoc(ReadSourceLocation(Record, Idx));
Chris Lattner4c6f9522009-04-27 05:14:47 +0000305 S->setVolatile(Record[Idx++]);
306 S->setSimple(Record[Idx++]);
John McCallaeeacf72013-05-03 00:10:13 +0000307}
Mike Stump1eb44332009-09-09 15:08:12 +0000308
John McCallaeeacf72013-05-03 00:10:13 +0000309void ASTStmtReader::VisitGCCAsmStmt(GCCAsmStmt *S) {
310 VisitAsmStmt(S);
311 S->setRParenLoc(ReadSourceLocation(Record, Idx));
Argyrios Kyrtzidisd98a2ab2010-06-29 22:46:25 +0000312 S->setAsmString(cast_or_null<StringLiteral>(Reader.ReadSubStmt()));
Chris Lattner4c6f9522009-04-27 05:14:47 +0000313
John McCallaeeacf72013-05-03 00:10:13 +0000314 unsigned NumOutputs = S->getNumOutputs();
315 unsigned NumInputs = S->getNumInputs();
316 unsigned NumClobbers = S->getNumClobbers();
317
Chris Lattner4c6f9522009-04-27 05:14:47 +0000318 // Outputs and inputs
Chris Lattner5f9e2722011-07-23 10:55:15 +0000319 SmallVector<IdentifierInfo *, 16> Names;
320 SmallVector<StringLiteral*, 16> Constraints;
321 SmallVector<Stmt*, 16> Exprs;
Chris Lattner4c6f9522009-04-27 05:14:47 +0000322 for (unsigned I = 0, N = NumOutputs + NumInputs; I != N; ++I) {
Douglas Gregor95eab172011-07-28 20:55:49 +0000323 Names.push_back(Reader.GetIdentifierInfo(F, Record, Idx));
Argyrios Kyrtzidisd98a2ab2010-06-29 22:46:25 +0000324 Constraints.push_back(cast_or_null<StringLiteral>(Reader.ReadSubStmt()));
325 Exprs.push_back(Reader.ReadSubStmt());
Chris Lattner4c6f9522009-04-27 05:14:47 +0000326 }
Chris Lattner4c6f9522009-04-27 05:14:47 +0000327
328 // Constraints
Chris Lattner5f9e2722011-07-23 10:55:15 +0000329 SmallVector<StringLiteral*, 16> Clobbers;
Chris Lattner4c6f9522009-04-27 05:14:47 +0000330 for (unsigned I = 0; I != NumClobbers; ++I)
Argyrios Kyrtzidisd98a2ab2010-06-29 22:46:25 +0000331 Clobbers.push_back(cast_or_null<StringLiteral>(Reader.ReadSubStmt()));
Anders Carlssonfdba9c02010-01-30 19:34:25 +0000332
Douglas Gregor35942772011-09-09 21:34:22 +0000333 S->setOutputsAndInputsAndClobbers(Reader.getContext(),
Anders Carlssonacb6bcb2010-01-30 20:38:10 +0000334 Names.data(), Constraints.data(),
Anders Carlssonfdba9c02010-01-30 19:34:25 +0000335 Exprs.data(), NumOutputs, NumInputs,
336 Clobbers.data(), NumClobbers);
Chris Lattner4c6f9522009-04-27 05:14:47 +0000337}
338
Chad Rosier8cd64b42012-06-11 20:47:18 +0000339void ASTStmtReader::VisitMSAsmStmt(MSAsmStmt *S) {
John McCallaeeacf72013-05-03 00:10:13 +0000340 VisitAsmStmt(S);
341 S->LBraceLoc = ReadSourceLocation(Record, Idx);
342 S->EndLoc = ReadSourceLocation(Record, Idx);
343 S->NumAsmToks = Record[Idx++];
344 std::string AsmStr = ReadString(Record, Idx);
345
346 // Read the tokens.
347 SmallVector<Token, 16> AsmToks;
348 AsmToks.reserve(S->NumAsmToks);
349 for (unsigned i = 0, e = S->NumAsmToks; i != e; ++i) {
350 AsmToks.push_back(ReadToken(Record, Idx));
351 }
352
353 // The calls to reserve() for the FooData vectors are mandatory to
354 // prevent dead StringRefs in the Foo vectors.
355
356 // Read the clobbers.
357 SmallVector<std::string, 16> ClobbersData;
358 SmallVector<StringRef, 16> Clobbers;
359 ClobbersData.reserve(S->NumClobbers);
360 Clobbers.reserve(S->NumClobbers);
361 for (unsigned i = 0, e = S->NumClobbers; i != e; ++i) {
362 ClobbersData.push_back(ReadString(Record, Idx));
363 Clobbers.push_back(ClobbersData.back());
364 }
365
366 // Read the operands.
367 unsigned NumOperands = S->NumOutputs + S->NumInputs;
368 SmallVector<Expr*, 16> Exprs;
369 SmallVector<std::string, 16> ConstraintsData;
370 SmallVector<StringRef, 16> Constraints;
371 Exprs.reserve(NumOperands);
372 ConstraintsData.reserve(NumOperands);
373 Constraints.reserve(NumOperands);
374 for (unsigned i = 0; i != NumOperands; ++i) {
375 Exprs.push_back(cast<Expr>(Reader.ReadSubStmt()));
376 ConstraintsData.push_back(ReadString(Record, Idx));
377 Constraints.push_back(ConstraintsData.back());
378 }
379
380 S->initialize(Reader.getContext(), AsmStr, AsmToks,
381 Constraints, Exprs, Clobbers);
Chad Rosier8cd64b42012-06-11 20:47:18 +0000382}
383
Tareq A. Siraj051303c2013-04-16 18:53:08 +0000384void ASTStmtReader::VisitCapturedStmt(CapturedStmt *S) {
Ben Langmuirdc5be4f2013-05-03 19:20:19 +0000385 VisitStmt(S);
Alexey Bataev4fa7eab2013-07-19 03:13:43 +0000386 ++Idx;
Wei Pan9fd6b8f2013-05-04 03:59:06 +0000387 S->setCapturedDecl(ReadDeclAs<CapturedDecl>(Record, Idx));
388 S->setCapturedRegionKind(static_cast<CapturedRegionKind>(Record[Idx++]));
389 S->setCapturedRecordDecl(ReadDeclAs<RecordDecl>(Record, Idx));
Ben Langmuirdc5be4f2013-05-03 19:20:19 +0000390
391 // Capture inits
392 for (CapturedStmt::capture_init_iterator I = S->capture_init_begin(),
393 E = S->capture_init_end();
394 I != E; ++I)
395 *I = Reader.ReadSubExpr();
396
397 // Body
398 S->setCapturedStmt(Reader.ReadSubStmt());
Wei Pan9fd6b8f2013-05-04 03:59:06 +0000399 S->getCapturedDecl()->setBody(S->getCapturedStmt());
Ben Langmuirdc5be4f2013-05-03 19:20:19 +0000400
401 // Captures
402 for (CapturedStmt::capture_iterator I = S->capture_begin(),
403 E = S->capture_end();
404 I != E; ++I) {
405 I->VarAndKind.setPointer(ReadDeclAs<VarDecl>(Record, Idx));
406 I->VarAndKind
407 .setInt(static_cast<CapturedStmt::VariableCaptureKind>(Record[Idx++]));
408 I->Loc = ReadSourceLocation(Record, Idx);
409 }
Tareq A. Siraj051303c2013-04-16 18:53:08 +0000410}
411
Sebastian Redl60adf4a2010-08-18 23:56:52 +0000412void ASTStmtReader::VisitExpr(Expr *E) {
Chris Lattner4c6f9522009-04-27 05:14:47 +0000413 VisitStmt(E);
Douglas Gregor393f2492011-07-22 00:38:23 +0000414 E->setType(Reader.readType(F, Record, Idx));
Chris Lattner4c6f9522009-04-27 05:14:47 +0000415 E->setTypeDependent(Record[Idx++]);
416 E->setValueDependent(Record[Idx++]);
Douglas Gregor561f8122011-07-01 01:22:09 +0000417 E->setInstantiationDependent(Record[Idx++]);
Douglas Gregord0937222010-12-13 22:49:22 +0000418 E->ExprBits.ContainsUnexpandedParameterPack = Record[Idx++];
John McCallf89e55a2010-11-18 06:31:45 +0000419 E->setValueKind(static_cast<ExprValueKind>(Record[Idx++]));
420 E->setObjectKind(static_cast<ExprObjectKind>(Record[Idx++]));
Chris Lattner4c6f9522009-04-27 05:14:47 +0000421 assert(Idx == NumExprFields && "Incorrect expression field count");
Chris Lattner4c6f9522009-04-27 05:14:47 +0000422}
423
Sebastian Redl60adf4a2010-08-18 23:56:52 +0000424void ASTStmtReader::VisitPredefinedExpr(PredefinedExpr *E) {
Chris Lattner4c6f9522009-04-27 05:14:47 +0000425 VisitExpr(E);
Sebastian Redlc3632732010-10-05 15:59:54 +0000426 E->setLocation(ReadSourceLocation(Record, Idx));
Chris Lattner4c6f9522009-04-27 05:14:47 +0000427 E->setIdentType((PredefinedExpr::IdentType)Record[Idx++]);
Chris Lattner4c6f9522009-04-27 05:14:47 +0000428}
429
Sebastian Redl60adf4a2010-08-18 23:56:52 +0000430void ASTStmtReader::VisitDeclRefExpr(DeclRefExpr *E) {
Chris Lattner4c6f9522009-04-27 05:14:47 +0000431 VisitExpr(E);
Argyrios Kyrtzidis663e3802010-07-08 13:09:47 +0000432
Chandler Carruthcb66cff2011-05-01 21:29:53 +0000433 E->DeclRefExprBits.HasQualifier = Record[Idx++];
Chandler Carruth3aa81402011-05-01 23:48:14 +0000434 E->DeclRefExprBits.HasFoundDecl = Record[Idx++];
Abramo Bagnarae4b92762012-01-27 09:46:47 +0000435 E->DeclRefExprBits.HasTemplateKWAndArgsInfo = Record[Idx++];
Abramo Bagnara7cc58b42011-10-05 07:56:41 +0000436 E->DeclRefExprBits.HadMultipleCandidates = Record[Idx++];
John McCallf4b88a42012-03-10 09:33:50 +0000437 E->DeclRefExprBits.RefersToEnclosingLocal = Record[Idx++];
Anders Carlssonb0ca1372011-03-06 18:19:42 +0000438 unsigned NumTemplateArgs = 0;
Abramo Bagnarae4b92762012-01-27 09:46:47 +0000439 if (E->hasTemplateKWAndArgsInfo())
Anders Carlssonb0ca1372011-03-06 18:19:42 +0000440 NumTemplateArgs = Record[Idx++];
441
Chandler Carruthcb66cff2011-05-01 21:29:53 +0000442 if (E->hasQualifier())
Chandler Carruth6857c3e2011-05-01 22:14:37 +0000443 E->getInternalQualifierLoc()
Douglas Gregor40d96a62011-02-28 21:54:11 +0000444 = Reader.ReadNestedNameSpecifierLoc(F, Record, Idx);
Argyrios Kyrtzidis663e3802010-07-08 13:09:47 +0000445
Chandler Carruth3aa81402011-05-01 23:48:14 +0000446 if (E->hasFoundDecl())
Douglas Gregor409448c2011-07-21 22:35:25 +0000447 E->getInternalFoundDecl() = ReadDeclAs<NamedDecl>(Record, Idx);
Chandler Carruth3aa81402011-05-01 23:48:14 +0000448
Abramo Bagnarae4b92762012-01-27 09:46:47 +0000449 if (E->hasTemplateKWAndArgsInfo())
450 ReadTemplateKWAndArgsInfo(*E->getTemplateKWAndArgsInfo(),
451 NumTemplateArgs);
Argyrios Kyrtzidis663e3802010-07-08 13:09:47 +0000452
Douglas Gregor409448c2011-07-21 22:35:25 +0000453 E->setDecl(ReadDeclAs<ValueDecl>(Record, Idx));
Sebastian Redlc3632732010-10-05 15:59:54 +0000454 E->setLocation(ReadSourceLocation(Record, Idx));
Argyrios Kyrtzidis40451072010-10-15 18:21:24 +0000455 ReadDeclarationNameLoc(E->DNLoc, E->getDecl()->getDeclName(), Record, Idx);
Chris Lattner4c6f9522009-04-27 05:14:47 +0000456}
457
Sebastian Redl60adf4a2010-08-18 23:56:52 +0000458void ASTStmtReader::VisitIntegerLiteral(IntegerLiteral *E) {
Chris Lattner4c6f9522009-04-27 05:14:47 +0000459 VisitExpr(E);
Sebastian Redlc3632732010-10-05 15:59:54 +0000460 E->setLocation(ReadSourceLocation(Record, Idx));
Douglas Gregor35942772011-09-09 21:34:22 +0000461 E->setValue(Reader.getContext(), Reader.ReadAPInt(Record, Idx));
Chris Lattner4c6f9522009-04-27 05:14:47 +0000462}
463
Sebastian Redl60adf4a2010-08-18 23:56:52 +0000464void ASTStmtReader::VisitFloatingLiteral(FloatingLiteral *E) {
Chris Lattner4c6f9522009-04-27 05:14:47 +0000465 VisitExpr(E);
Tim Northover9ec55f22013-01-22 09:46:51 +0000466 E->setRawSemantics(static_cast<Stmt::APFloatSemantics>(Record[Idx++]));
Chris Lattner4c6f9522009-04-27 05:14:47 +0000467 E->setExact(Record[Idx++]);
Tim Northover9ec55f22013-01-22 09:46:51 +0000468 E->setValue(Reader.getContext(),
469 Reader.ReadAPFloat(Record, E->getSemantics(), Idx));
Sebastian Redlc3632732010-10-05 15:59:54 +0000470 E->setLocation(ReadSourceLocation(Record, Idx));
Chris Lattner4c6f9522009-04-27 05:14:47 +0000471}
472
Sebastian Redl60adf4a2010-08-18 23:56:52 +0000473void ASTStmtReader::VisitImaginaryLiteral(ImaginaryLiteral *E) {
Chris Lattner4c6f9522009-04-27 05:14:47 +0000474 VisitExpr(E);
Argyrios Kyrtzidisd98a2ab2010-06-29 22:46:25 +0000475 E->setSubExpr(Reader.ReadSubExpr());
Chris Lattner4c6f9522009-04-27 05:14:47 +0000476}
477
Sebastian Redl60adf4a2010-08-18 23:56:52 +0000478void ASTStmtReader::VisitStringLiteral(StringLiteral *E) {
Chris Lattner4c6f9522009-04-27 05:14:47 +0000479 VisitExpr(E);
480 unsigned Len = Record[Idx++];
Mike Stump1eb44332009-09-09 15:08:12 +0000481 assert(Record[Idx] == E->getNumConcatenated() &&
Chris Lattner4c6f9522009-04-27 05:14:47 +0000482 "Wrong number of concatenated tokens!");
483 ++Idx;
Eli Friedman64f45a22011-11-01 02:23:42 +0000484 StringLiteral::StringKind kind =
485 static_cast<StringLiteral::StringKind>(Record[Idx++]);
486 bool isPascal = Record[Idx++];
Chris Lattner4c6f9522009-04-27 05:14:47 +0000487
Mike Stump1eb44332009-09-09 15:08:12 +0000488 // Read string data
Dylan Noblesmithf7ccbad2012-02-05 02:13:05 +0000489 SmallString<16> Str(&Record[Idx], &Record[Idx] + Len);
Eli Friedman64f45a22011-11-01 02:23:42 +0000490 E->setString(Reader.getContext(), Str.str(), kind, isPascal);
Chris Lattner4c6f9522009-04-27 05:14:47 +0000491 Idx += Len;
492
493 // Read source locations
494 for (unsigned I = 0, N = E->getNumConcatenated(); I != N; ++I)
Sebastian Redlc3632732010-10-05 15:59:54 +0000495 E->setStrTokenLoc(I, ReadSourceLocation(Record, Idx));
Chris Lattner4c6f9522009-04-27 05:14:47 +0000496}
497
Sebastian Redl60adf4a2010-08-18 23:56:52 +0000498void ASTStmtReader::VisitCharacterLiteral(CharacterLiteral *E) {
Chris Lattner4c6f9522009-04-27 05:14:47 +0000499 VisitExpr(E);
500 E->setValue(Record[Idx++]);
Sebastian Redlc3632732010-10-05 15:59:54 +0000501 E->setLocation(ReadSourceLocation(Record, Idx));
Douglas Gregor5cee1192011-07-27 05:40:30 +0000502 E->setKind(static_cast<CharacterLiteral::CharacterKind>(Record[Idx++]));
Chris Lattner4c6f9522009-04-27 05:14:47 +0000503}
504
Sebastian Redl60adf4a2010-08-18 23:56:52 +0000505void ASTStmtReader::VisitParenExpr(ParenExpr *E) {
Chris Lattner4c6f9522009-04-27 05:14:47 +0000506 VisitExpr(E);
Sebastian Redlc3632732010-10-05 15:59:54 +0000507 E->setLParen(ReadSourceLocation(Record, Idx));
508 E->setRParen(ReadSourceLocation(Record, Idx));
Argyrios Kyrtzidisd98a2ab2010-06-29 22:46:25 +0000509 E->setSubExpr(Reader.ReadSubExpr());
Chris Lattner4c6f9522009-04-27 05:14:47 +0000510}
511
Sebastian Redl60adf4a2010-08-18 23:56:52 +0000512void ASTStmtReader::VisitParenListExpr(ParenListExpr *E) {
Argyrios Kyrtzidis37bdfe22010-06-30 08:49:18 +0000513 VisitExpr(E);
514 unsigned NumExprs = Record[Idx++];
Douglas Gregor35942772011-09-09 21:34:22 +0000515 E->Exprs = new (Reader.getContext()) Stmt*[NumExprs];
Argyrios Kyrtzidis37bdfe22010-06-30 08:49:18 +0000516 for (unsigned i = 0; i != NumExprs; ++i)
517 E->Exprs[i] = Reader.ReadSubStmt();
518 E->NumExprs = NumExprs;
Sebastian Redlc3632732010-10-05 15:59:54 +0000519 E->LParenLoc = ReadSourceLocation(Record, Idx);
520 E->RParenLoc = ReadSourceLocation(Record, Idx);
Argyrios Kyrtzidis37bdfe22010-06-30 08:49:18 +0000521}
522
Sebastian Redl60adf4a2010-08-18 23:56:52 +0000523void ASTStmtReader::VisitUnaryOperator(UnaryOperator *E) {
Chris Lattner4c6f9522009-04-27 05:14:47 +0000524 VisitExpr(E);
Argyrios Kyrtzidisd98a2ab2010-06-29 22:46:25 +0000525 E->setSubExpr(Reader.ReadSubExpr());
Chris Lattner4c6f9522009-04-27 05:14:47 +0000526 E->setOpcode((UnaryOperator::Opcode)Record[Idx++]);
Sebastian Redlc3632732010-10-05 15:59:54 +0000527 E->setOperatorLoc(ReadSourceLocation(Record, Idx));
Chris Lattner4c6f9522009-04-27 05:14:47 +0000528}
529
Sebastian Redl60adf4a2010-08-18 23:56:52 +0000530void ASTStmtReader::VisitOffsetOfExpr(OffsetOfExpr *E) {
Douglas Gregor8ecdb652010-04-28 22:16:22 +0000531 typedef OffsetOfExpr::OffsetOfNode Node;
532 VisitExpr(E);
533 assert(E->getNumComponents() == Record[Idx]);
534 ++Idx;
535 assert(E->getNumExpressions() == Record[Idx]);
536 ++Idx;
Sebastian Redlc3632732010-10-05 15:59:54 +0000537 E->setOperatorLoc(ReadSourceLocation(Record, Idx));
538 E->setRParenLoc(ReadSourceLocation(Record, Idx));
539 E->setTypeSourceInfo(GetTypeSourceInfo(Record, Idx));
Douglas Gregor8ecdb652010-04-28 22:16:22 +0000540 for (unsigned I = 0, N = E->getNumComponents(); I != N; ++I) {
541 Node::Kind Kind = static_cast<Node::Kind>(Record[Idx++]);
Sebastian Redlc3632732010-10-05 15:59:54 +0000542 SourceLocation Start = ReadSourceLocation(Record, Idx);
543 SourceLocation End = ReadSourceLocation(Record, Idx);
Douglas Gregor8ecdb652010-04-28 22:16:22 +0000544 switch (Kind) {
545 case Node::Array:
546 E->setComponent(I, Node(Start, Record[Idx++], End));
547 break;
548
549 case Node::Field:
Douglas Gregor409448c2011-07-21 22:35:25 +0000550 E->setComponent(I, Node(Start, ReadDeclAs<FieldDecl>(Record, Idx), End));
Douglas Gregor8ecdb652010-04-28 22:16:22 +0000551 break;
552
553 case Node::Identifier:
Douglas Gregor95eab172011-07-28 20:55:49 +0000554 E->setComponent(I,
555 Node(Start,
556 Reader.GetIdentifierInfo(F, Record, Idx),
557 End));
Douglas Gregor8ecdb652010-04-28 22:16:22 +0000558 break;
Douglas Gregorcc8a5d52010-04-29 00:18:15 +0000559
Argyrios Kyrtzidisafbf3122010-07-29 18:16:10 +0000560 case Node::Base: {
Douglas Gregor35942772011-09-09 21:34:22 +0000561 CXXBaseSpecifier *Base = new (Reader.getContext()) CXXBaseSpecifier();
Sebastian Redlc3632732010-10-05 15:59:54 +0000562 *Base = Reader.ReadCXXBaseSpecifier(F, Record, Idx);
Argyrios Kyrtzidisafbf3122010-07-29 18:16:10 +0000563 E->setComponent(I, Node(Base));
Douglas Gregorcc8a5d52010-04-29 00:18:15 +0000564 break;
Douglas Gregor8ecdb652010-04-28 22:16:22 +0000565 }
Argyrios Kyrtzidisafbf3122010-07-29 18:16:10 +0000566 }
Douglas Gregor8ecdb652010-04-28 22:16:22 +0000567 }
568
569 for (unsigned I = 0, N = E->getNumExpressions(); I != N; ++I)
Argyrios Kyrtzidisd98a2ab2010-06-29 22:46:25 +0000570 E->setIndexExpr(I, Reader.ReadSubExpr());
Douglas Gregor8ecdb652010-04-28 22:16:22 +0000571}
572
Peter Collingbournef4e3cfb2011-03-11 19:24:49 +0000573void ASTStmtReader::VisitUnaryExprOrTypeTraitExpr(UnaryExprOrTypeTraitExpr *E) {
Chris Lattner4c6f9522009-04-27 05:14:47 +0000574 VisitExpr(E);
Peter Collingbournef4e3cfb2011-03-11 19:24:49 +0000575 E->setKind(static_cast<UnaryExprOrTypeTrait>(Record[Idx++]));
Chris Lattner4c6f9522009-04-27 05:14:47 +0000576 if (Record[Idx] == 0) {
Argyrios Kyrtzidisd98a2ab2010-06-29 22:46:25 +0000577 E->setArgument(Reader.ReadSubExpr());
Chris Lattner4c6f9522009-04-27 05:14:47 +0000578 ++Idx;
579 } else {
Sebastian Redlc3632732010-10-05 15:59:54 +0000580 E->setArgument(GetTypeSourceInfo(Record, Idx));
Chris Lattner4c6f9522009-04-27 05:14:47 +0000581 }
Sebastian Redlc3632732010-10-05 15:59:54 +0000582 E->setOperatorLoc(ReadSourceLocation(Record, Idx));
583 E->setRParenLoc(ReadSourceLocation(Record, Idx));
Chris Lattner4c6f9522009-04-27 05:14:47 +0000584}
585
Sebastian Redl60adf4a2010-08-18 23:56:52 +0000586void ASTStmtReader::VisitArraySubscriptExpr(ArraySubscriptExpr *E) {
Chris Lattner4c6f9522009-04-27 05:14:47 +0000587 VisitExpr(E);
Argyrios Kyrtzidisd98a2ab2010-06-29 22:46:25 +0000588 E->setLHS(Reader.ReadSubExpr());
589 E->setRHS(Reader.ReadSubExpr());
Sebastian Redlc3632732010-10-05 15:59:54 +0000590 E->setRBracketLoc(ReadSourceLocation(Record, Idx));
Chris Lattner4c6f9522009-04-27 05:14:47 +0000591}
592
Sebastian Redl60adf4a2010-08-18 23:56:52 +0000593void ASTStmtReader::VisitCallExpr(CallExpr *E) {
Chris Lattner4c6f9522009-04-27 05:14:47 +0000594 VisitExpr(E);
Douglas Gregor35942772011-09-09 21:34:22 +0000595 E->setNumArgs(Reader.getContext(), Record[Idx++]);
Sebastian Redlc3632732010-10-05 15:59:54 +0000596 E->setRParenLoc(ReadSourceLocation(Record, Idx));
Argyrios Kyrtzidisd98a2ab2010-06-29 22:46:25 +0000597 E->setCallee(Reader.ReadSubExpr());
Chris Lattner4c6f9522009-04-27 05:14:47 +0000598 for (unsigned I = 0, N = E->getNumArgs(); I != N; ++I)
Argyrios Kyrtzidisd98a2ab2010-06-29 22:46:25 +0000599 E->setArg(I, Reader.ReadSubExpr());
Chris Lattner4c6f9522009-04-27 05:14:47 +0000600}
601
John McCall7110fd62011-07-15 07:00:14 +0000602void ASTStmtReader::VisitCXXMemberCallExpr(CXXMemberCallExpr *E) {
603 VisitCallExpr(E);
604}
605
Sebastian Redl60adf4a2010-08-18 23:56:52 +0000606void ASTStmtReader::VisitMemberExpr(MemberExpr *E) {
Argyrios Kyrtzidis663e3802010-07-08 13:09:47 +0000607 // Don't call VisitExpr, this is fully initialized at creation.
608 assert(E->getStmtClass() == Stmt::MemberExprClass &&
609 "It's a subclass, we must advance Idx!");
Chris Lattner4c6f9522009-04-27 05:14:47 +0000610}
611
Sebastian Redl60adf4a2010-08-18 23:56:52 +0000612void ASTStmtReader::VisitObjCIsaExpr(ObjCIsaExpr *E) {
Steve Narofff242b1b2009-07-24 17:54:45 +0000613 VisitExpr(E);
Argyrios Kyrtzidisd98a2ab2010-06-29 22:46:25 +0000614 E->setBase(Reader.ReadSubExpr());
Sebastian Redlc3632732010-10-05 15:59:54 +0000615 E->setIsaMemberLoc(ReadSourceLocation(Record, Idx));
Fariborz Jahanianec8deba2013-03-28 19:50:55 +0000616 E->setOpLoc(ReadSourceLocation(Record, Idx));
Steve Narofff242b1b2009-07-24 17:54:45 +0000617 E->setArrow(Record[Idx++]);
Steve Narofff242b1b2009-07-24 17:54:45 +0000618}
619
John McCallf85e1932011-06-15 23:02:42 +0000620void ASTStmtReader::
621VisitObjCIndirectCopyRestoreExpr(ObjCIndirectCopyRestoreExpr *E) {
622 VisitExpr(E);
623 E->Operand = Reader.ReadSubExpr();
624 E->setShouldCopy(Record[Idx++]);
625}
626
627void ASTStmtReader::VisitObjCBridgedCastExpr(ObjCBridgedCastExpr *E) {
628 VisitExplicitCastExpr(E);
629 E->LParenLoc = ReadSourceLocation(Record, Idx);
630 E->BridgeKeywordLoc = ReadSourceLocation(Record, Idx);
631 E->Kind = Record[Idx++];
632}
633
Sebastian Redl60adf4a2010-08-18 23:56:52 +0000634void ASTStmtReader::VisitCastExpr(CastExpr *E) {
Chris Lattner4c6f9522009-04-27 05:14:47 +0000635 VisitExpr(E);
John McCallf871d0c2010-08-07 06:22:56 +0000636 unsigned NumBaseSpecs = Record[Idx++];
637 assert(NumBaseSpecs == E->path_size());
Argyrios Kyrtzidisd98a2ab2010-06-29 22:46:25 +0000638 E->setSubExpr(Reader.ReadSubExpr());
Anders Carlssoncdef2b72009-07-31 00:48:10 +0000639 E->setCastKind((CastExpr::CastKind)Record[Idx++]);
John McCallf871d0c2010-08-07 06:22:56 +0000640 CastExpr::path_iterator BaseI = E->path_begin();
Argyrios Kyrtzidis0745d0a2010-07-02 23:30:27 +0000641 while (NumBaseSpecs--) {
Douglas Gregor35942772011-09-09 21:34:22 +0000642 CXXBaseSpecifier *BaseSpec = new (Reader.getContext()) CXXBaseSpecifier;
Sebastian Redlc3632732010-10-05 15:59:54 +0000643 *BaseSpec = Reader.ReadCXXBaseSpecifier(F, Record, Idx);
John McCallf871d0c2010-08-07 06:22:56 +0000644 *BaseI++ = BaseSpec;
Argyrios Kyrtzidis0745d0a2010-07-02 23:30:27 +0000645 }
Chris Lattner4c6f9522009-04-27 05:14:47 +0000646}
647
Sebastian Redl60adf4a2010-08-18 23:56:52 +0000648void ASTStmtReader::VisitBinaryOperator(BinaryOperator *E) {
Chris Lattner4c6f9522009-04-27 05:14:47 +0000649 VisitExpr(E);
Argyrios Kyrtzidisd98a2ab2010-06-29 22:46:25 +0000650 E->setLHS(Reader.ReadSubExpr());
651 E->setRHS(Reader.ReadSubExpr());
Chris Lattner4c6f9522009-04-27 05:14:47 +0000652 E->setOpcode((BinaryOperator::Opcode)Record[Idx++]);
Sebastian Redlc3632732010-10-05 15:59:54 +0000653 E->setOperatorLoc(ReadSourceLocation(Record, Idx));
Lang Hamesbe9af122012-10-02 04:45:10 +0000654 E->setFPContractable((bool)Record[Idx++]);
Chris Lattner4c6f9522009-04-27 05:14:47 +0000655}
656
Sebastian Redl60adf4a2010-08-18 23:56:52 +0000657void ASTStmtReader::VisitCompoundAssignOperator(CompoundAssignOperator *E) {
Chris Lattner4c6f9522009-04-27 05:14:47 +0000658 VisitBinaryOperator(E);
Douglas Gregor393f2492011-07-22 00:38:23 +0000659 E->setComputationLHSType(Reader.readType(F, Record, Idx));
660 E->setComputationResultType(Reader.readType(F, Record, Idx));
Chris Lattner4c6f9522009-04-27 05:14:47 +0000661}
662
Sebastian Redl60adf4a2010-08-18 23:56:52 +0000663void ASTStmtReader::VisitConditionalOperator(ConditionalOperator *E) {
Chris Lattner4c6f9522009-04-27 05:14:47 +0000664 VisitExpr(E);
John McCall56ca35d2011-02-17 10:25:35 +0000665 E->SubExprs[ConditionalOperator::COND] = Reader.ReadSubExpr();
666 E->SubExprs[ConditionalOperator::LHS] = Reader.ReadSubExpr();
667 E->SubExprs[ConditionalOperator::RHS] = Reader.ReadSubExpr();
668 E->QuestionLoc = ReadSourceLocation(Record, Idx);
669 E->ColonLoc = ReadSourceLocation(Record, Idx);
670}
671
672void
673ASTStmtReader::VisitBinaryConditionalOperator(BinaryConditionalOperator *E) {
674 VisitExpr(E);
675 E->OpaqueValue = cast<OpaqueValueExpr>(Reader.ReadSubExpr());
676 E->SubExprs[BinaryConditionalOperator::COMMON] = Reader.ReadSubExpr();
677 E->SubExprs[BinaryConditionalOperator::COND] = Reader.ReadSubExpr();
678 E->SubExprs[BinaryConditionalOperator::LHS] = Reader.ReadSubExpr();
679 E->SubExprs[BinaryConditionalOperator::RHS] = Reader.ReadSubExpr();
680 E->QuestionLoc = ReadSourceLocation(Record, Idx);
681 E->ColonLoc = ReadSourceLocation(Record, Idx);
Chris Lattner4c6f9522009-04-27 05:14:47 +0000682}
683
Sebastian Redl60adf4a2010-08-18 23:56:52 +0000684void ASTStmtReader::VisitImplicitCastExpr(ImplicitCastExpr *E) {
Chris Lattner4c6f9522009-04-27 05:14:47 +0000685 VisitCastExpr(E);
Chris Lattner4c6f9522009-04-27 05:14:47 +0000686}
687
Sebastian Redl60adf4a2010-08-18 23:56:52 +0000688void ASTStmtReader::VisitExplicitCastExpr(ExplicitCastExpr *E) {
Chris Lattner4c6f9522009-04-27 05:14:47 +0000689 VisitCastExpr(E);
Sebastian Redlc3632732010-10-05 15:59:54 +0000690 E->setTypeInfoAsWritten(GetTypeSourceInfo(Record, Idx));
Chris Lattner4c6f9522009-04-27 05:14:47 +0000691}
692
Sebastian Redl60adf4a2010-08-18 23:56:52 +0000693void ASTStmtReader::VisitCStyleCastExpr(CStyleCastExpr *E) {
Chris Lattner4c6f9522009-04-27 05:14:47 +0000694 VisitExplicitCastExpr(E);
Sebastian Redlc3632732010-10-05 15:59:54 +0000695 E->setLParenLoc(ReadSourceLocation(Record, Idx));
696 E->setRParenLoc(ReadSourceLocation(Record, Idx));
Chris Lattner4c6f9522009-04-27 05:14:47 +0000697}
698
Sebastian Redl60adf4a2010-08-18 23:56:52 +0000699void ASTStmtReader::VisitCompoundLiteralExpr(CompoundLiteralExpr *E) {
Chris Lattner4c6f9522009-04-27 05:14:47 +0000700 VisitExpr(E);
Sebastian Redlc3632732010-10-05 15:59:54 +0000701 E->setLParenLoc(ReadSourceLocation(Record, Idx));
702 E->setTypeSourceInfo(GetTypeSourceInfo(Record, Idx));
Argyrios Kyrtzidisd98a2ab2010-06-29 22:46:25 +0000703 E->setInitializer(Reader.ReadSubExpr());
Chris Lattner4c6f9522009-04-27 05:14:47 +0000704 E->setFileScope(Record[Idx++]);
Chris Lattner4c6f9522009-04-27 05:14:47 +0000705}
706
Sebastian Redl60adf4a2010-08-18 23:56:52 +0000707void ASTStmtReader::VisitExtVectorElementExpr(ExtVectorElementExpr *E) {
Chris Lattner4c6f9522009-04-27 05:14:47 +0000708 VisitExpr(E);
Argyrios Kyrtzidisd98a2ab2010-06-29 22:46:25 +0000709 E->setBase(Reader.ReadSubExpr());
Douglas Gregor95eab172011-07-28 20:55:49 +0000710 E->setAccessor(Reader.GetIdentifierInfo(F, Record, Idx));
Sebastian Redlc3632732010-10-05 15:59:54 +0000711 E->setAccessorLoc(ReadSourceLocation(Record, Idx));
Chris Lattner4c6f9522009-04-27 05:14:47 +0000712}
713
Sebastian Redl60adf4a2010-08-18 23:56:52 +0000714void ASTStmtReader::VisitInitListExpr(InitListExpr *E) {
Chris Lattner4c6f9522009-04-27 05:14:47 +0000715 VisitExpr(E);
Abramo Bagnara23700f02012-11-08 18:41:43 +0000716 if (InitListExpr *SyntForm = cast_or_null<InitListExpr>(Reader.ReadSubStmt()))
717 E->setSyntacticForm(SyntForm);
Sebastian Redlc3632732010-10-05 15:59:54 +0000718 E->setLBraceLoc(ReadSourceLocation(Record, Idx));
719 E->setRBraceLoc(ReadSourceLocation(Record, Idx));
Argyrios Kyrtzidis2ac0b7a2011-04-22 05:29:30 +0000720 bool isArrayFiller = Record[Idx++];
721 Expr *filler = 0;
722 if (isArrayFiller) {
723 filler = Reader.ReadSubExpr();
724 E->ArrayFillerOrUnionFieldInit = filler;
725 } else
Douglas Gregor409448c2011-07-21 22:35:25 +0000726 E->ArrayFillerOrUnionFieldInit = ReadDeclAs<FieldDecl>(Record, Idx);
Chris Lattner4c6f9522009-04-27 05:14:47 +0000727 E->sawArrayRangeDesignator(Record[Idx++]);
Argyrios Kyrtzidis2ac0b7a2011-04-22 05:29:30 +0000728 unsigned NumInits = Record[Idx++];
Douglas Gregor35942772011-09-09 21:34:22 +0000729 E->reserveInits(Reader.getContext(), NumInits);
Argyrios Kyrtzidis2ac0b7a2011-04-22 05:29:30 +0000730 if (isArrayFiller) {
731 for (unsigned I = 0; I != NumInits; ++I) {
732 Expr *init = Reader.ReadSubExpr();
Douglas Gregor35942772011-09-09 21:34:22 +0000733 E->updateInit(Reader.getContext(), I, init ? init : filler);
Argyrios Kyrtzidis2ac0b7a2011-04-22 05:29:30 +0000734 }
735 } else {
736 for (unsigned I = 0; I != NumInits; ++I)
Douglas Gregor35942772011-09-09 21:34:22 +0000737 E->updateInit(Reader.getContext(), I, Reader.ReadSubExpr());
Argyrios Kyrtzidis2ac0b7a2011-04-22 05:29:30 +0000738 }
Chris Lattner4c6f9522009-04-27 05:14:47 +0000739}
740
Sebastian Redl60adf4a2010-08-18 23:56:52 +0000741void ASTStmtReader::VisitDesignatedInitExpr(DesignatedInitExpr *E) {
Chris Lattner4c6f9522009-04-27 05:14:47 +0000742 typedef DesignatedInitExpr::Designator Designator;
743
744 VisitExpr(E);
745 unsigned NumSubExprs = Record[Idx++];
746 assert(NumSubExprs == E->getNumSubExprs() && "Wrong number of subexprs");
747 for (unsigned I = 0; I != NumSubExprs; ++I)
Argyrios Kyrtzidisd98a2ab2010-06-29 22:46:25 +0000748 E->setSubExpr(I, Reader.ReadSubExpr());
Sebastian Redlc3632732010-10-05 15:59:54 +0000749 E->setEqualOrColonLoc(ReadSourceLocation(Record, Idx));
Chris Lattner4c6f9522009-04-27 05:14:47 +0000750 E->setGNUSyntax(Record[Idx++]);
751
Chris Lattner5f9e2722011-07-23 10:55:15 +0000752 SmallVector<Designator, 4> Designators;
Chris Lattner4c6f9522009-04-27 05:14:47 +0000753 while (Idx < Record.size()) {
Sebastian Redl8538e8d2010-08-18 23:57:32 +0000754 switch ((DesignatorTypes)Record[Idx++]) {
755 case DESIG_FIELD_DECL: {
Douglas Gregor409448c2011-07-21 22:35:25 +0000756 FieldDecl *Field = ReadDeclAs<FieldDecl>(Record, Idx);
Mike Stump1eb44332009-09-09 15:08:12 +0000757 SourceLocation DotLoc
Sebastian Redlc3632732010-10-05 15:59:54 +0000758 = ReadSourceLocation(Record, Idx);
Mike Stump1eb44332009-09-09 15:08:12 +0000759 SourceLocation FieldLoc
Sebastian Redlc3632732010-10-05 15:59:54 +0000760 = ReadSourceLocation(Record, Idx);
Mike Stump1eb44332009-09-09 15:08:12 +0000761 Designators.push_back(Designator(Field->getIdentifier(), DotLoc,
Chris Lattner4c6f9522009-04-27 05:14:47 +0000762 FieldLoc));
763 Designators.back().setField(Field);
764 break;
765 }
766
Sebastian Redl8538e8d2010-08-18 23:57:32 +0000767 case DESIG_FIELD_NAME: {
Douglas Gregor95eab172011-07-28 20:55:49 +0000768 const IdentifierInfo *Name = Reader.GetIdentifierInfo(F, Record, Idx);
Mike Stump1eb44332009-09-09 15:08:12 +0000769 SourceLocation DotLoc
Sebastian Redlc3632732010-10-05 15:59:54 +0000770 = ReadSourceLocation(Record, Idx);
Mike Stump1eb44332009-09-09 15:08:12 +0000771 SourceLocation FieldLoc
Sebastian Redlc3632732010-10-05 15:59:54 +0000772 = ReadSourceLocation(Record, Idx);
Chris Lattner4c6f9522009-04-27 05:14:47 +0000773 Designators.push_back(Designator(Name, DotLoc, FieldLoc));
774 break;
775 }
Mike Stump1eb44332009-09-09 15:08:12 +0000776
Sebastian Redl8538e8d2010-08-18 23:57:32 +0000777 case DESIG_ARRAY: {
Chris Lattner4c6f9522009-04-27 05:14:47 +0000778 unsigned Index = Record[Idx++];
779 SourceLocation LBracketLoc
Sebastian Redlc3632732010-10-05 15:59:54 +0000780 = ReadSourceLocation(Record, Idx);
Chris Lattner4c6f9522009-04-27 05:14:47 +0000781 SourceLocation RBracketLoc
Sebastian Redlc3632732010-10-05 15:59:54 +0000782 = ReadSourceLocation(Record, Idx);
Chris Lattner4c6f9522009-04-27 05:14:47 +0000783 Designators.push_back(Designator(Index, LBracketLoc, RBracketLoc));
784 break;
785 }
786
Sebastian Redl8538e8d2010-08-18 23:57:32 +0000787 case DESIG_ARRAY_RANGE: {
Chris Lattner4c6f9522009-04-27 05:14:47 +0000788 unsigned Index = Record[Idx++];
789 SourceLocation LBracketLoc
Sebastian Redlc3632732010-10-05 15:59:54 +0000790 = ReadSourceLocation(Record, Idx);
Chris Lattner4c6f9522009-04-27 05:14:47 +0000791 SourceLocation EllipsisLoc
Sebastian Redlc3632732010-10-05 15:59:54 +0000792 = ReadSourceLocation(Record, Idx);
Chris Lattner4c6f9522009-04-27 05:14:47 +0000793 SourceLocation RBracketLoc
Sebastian Redlc3632732010-10-05 15:59:54 +0000794 = ReadSourceLocation(Record, Idx);
Chris Lattner4c6f9522009-04-27 05:14:47 +0000795 Designators.push_back(Designator(Index, LBracketLoc, EllipsisLoc,
796 RBracketLoc));
797 break;
798 }
799 }
800 }
Douglas Gregor35942772011-09-09 21:34:22 +0000801 E->setDesignators(Reader.getContext(),
Douglas Gregor319d57f2010-01-06 23:17:19 +0000802 Designators.data(), Designators.size());
Chris Lattner4c6f9522009-04-27 05:14:47 +0000803}
804
Sebastian Redl60adf4a2010-08-18 23:56:52 +0000805void ASTStmtReader::VisitImplicitValueInitExpr(ImplicitValueInitExpr *E) {
Chris Lattner4c6f9522009-04-27 05:14:47 +0000806 VisitExpr(E);
Chris Lattner4c6f9522009-04-27 05:14:47 +0000807}
808
Sebastian Redl60adf4a2010-08-18 23:56:52 +0000809void ASTStmtReader::VisitVAArgExpr(VAArgExpr *E) {
Chris Lattner4c6f9522009-04-27 05:14:47 +0000810 VisitExpr(E);
Argyrios Kyrtzidisd98a2ab2010-06-29 22:46:25 +0000811 E->setSubExpr(Reader.ReadSubExpr());
Sebastian Redlc3632732010-10-05 15:59:54 +0000812 E->setWrittenTypeInfo(GetTypeSourceInfo(Record, Idx));
813 E->setBuiltinLoc(ReadSourceLocation(Record, Idx));
814 E->setRParenLoc(ReadSourceLocation(Record, Idx));
Chris Lattner4c6f9522009-04-27 05:14:47 +0000815}
816
Sebastian Redl60adf4a2010-08-18 23:56:52 +0000817void ASTStmtReader::VisitAddrLabelExpr(AddrLabelExpr *E) {
Chris Lattner4c6f9522009-04-27 05:14:47 +0000818 VisitExpr(E);
Sebastian Redlc3632732010-10-05 15:59:54 +0000819 E->setAmpAmpLoc(ReadSourceLocation(Record, Idx));
820 E->setLabelLoc(ReadSourceLocation(Record, Idx));
Douglas Gregor409448c2011-07-21 22:35:25 +0000821 E->setLabel(ReadDeclAs<LabelDecl>(Record, Idx));
Chris Lattner4c6f9522009-04-27 05:14:47 +0000822}
823
Sebastian Redl60adf4a2010-08-18 23:56:52 +0000824void ASTStmtReader::VisitStmtExpr(StmtExpr *E) {
Chris Lattner4c6f9522009-04-27 05:14:47 +0000825 VisitExpr(E);
Sebastian Redlc3632732010-10-05 15:59:54 +0000826 E->setLParenLoc(ReadSourceLocation(Record, Idx));
827 E->setRParenLoc(ReadSourceLocation(Record, Idx));
Argyrios Kyrtzidisd98a2ab2010-06-29 22:46:25 +0000828 E->setSubStmt(cast_or_null<CompoundStmt>(Reader.ReadSubStmt()));
Chris Lattner4c6f9522009-04-27 05:14:47 +0000829}
830
Sebastian Redl60adf4a2010-08-18 23:56:52 +0000831void ASTStmtReader::VisitChooseExpr(ChooseExpr *E) {
Chris Lattner4c6f9522009-04-27 05:14:47 +0000832 VisitExpr(E);
Argyrios Kyrtzidisd98a2ab2010-06-29 22:46:25 +0000833 E->setCond(Reader.ReadSubExpr());
834 E->setLHS(Reader.ReadSubExpr());
835 E->setRHS(Reader.ReadSubExpr());
Sebastian Redlc3632732010-10-05 15:59:54 +0000836 E->setBuiltinLoc(ReadSourceLocation(Record, Idx));
837 E->setRParenLoc(ReadSourceLocation(Record, Idx));
Eli Friedmana5e66012013-07-20 00:40:58 +0000838 E->setIsConditionTrue(Record[Idx++]);
Chris Lattner4c6f9522009-04-27 05:14:47 +0000839}
840
Sebastian Redl60adf4a2010-08-18 23:56:52 +0000841void ASTStmtReader::VisitGNUNullExpr(GNUNullExpr *E) {
Chris Lattner4c6f9522009-04-27 05:14:47 +0000842 VisitExpr(E);
Sebastian Redlc3632732010-10-05 15:59:54 +0000843 E->setTokenLocation(ReadSourceLocation(Record, Idx));
Chris Lattner4c6f9522009-04-27 05:14:47 +0000844}
845
Sebastian Redl60adf4a2010-08-18 23:56:52 +0000846void ASTStmtReader::VisitShuffleVectorExpr(ShuffleVectorExpr *E) {
Chris Lattner4c6f9522009-04-27 05:14:47 +0000847 VisitExpr(E);
Chris Lattner5f9e2722011-07-23 10:55:15 +0000848 SmallVector<Expr *, 16> Exprs;
Chris Lattner4c6f9522009-04-27 05:14:47 +0000849 unsigned NumExprs = Record[Idx++];
Argyrios Kyrtzidis919e6932010-06-28 22:28:35 +0000850 while (NumExprs--)
Argyrios Kyrtzidisd98a2ab2010-06-29 22:46:25 +0000851 Exprs.push_back(Reader.ReadSubExpr());
Dmitri Gribenko27365ee2013-05-10 00:43:44 +0000852 E->setExprs(Reader.getContext(), Exprs);
Sebastian Redlc3632732010-10-05 15:59:54 +0000853 E->setBuiltinLoc(ReadSourceLocation(Record, Idx));
854 E->setRParenLoc(ReadSourceLocation(Record, Idx));
Chris Lattner4c6f9522009-04-27 05:14:47 +0000855}
856
Sebastian Redl60adf4a2010-08-18 23:56:52 +0000857void ASTStmtReader::VisitBlockExpr(BlockExpr *E) {
Chris Lattner4c6f9522009-04-27 05:14:47 +0000858 VisitExpr(E);
Douglas Gregor409448c2011-07-21 22:35:25 +0000859 E->setBlockDecl(ReadDeclAs<BlockDecl>(Record, Idx));
Chris Lattner4c6f9522009-04-27 05:14:47 +0000860}
861
Peter Collingbournef111d932011-04-15 00:35:48 +0000862void ASTStmtReader::VisitGenericSelectionExpr(GenericSelectionExpr *E) {
863 VisitExpr(E);
864 E->NumAssocs = Record[Idx++];
Douglas Gregor35942772011-09-09 21:34:22 +0000865 E->AssocTypes = new (Reader.getContext()) TypeSourceInfo*[E->NumAssocs];
Peter Collingbournef111d932011-04-15 00:35:48 +0000866 E->SubExprs =
Douglas Gregor35942772011-09-09 21:34:22 +0000867 new(Reader.getContext()) Stmt*[GenericSelectionExpr::END_EXPR+E->NumAssocs];
Peter Collingbournef111d932011-04-15 00:35:48 +0000868
869 E->SubExprs[GenericSelectionExpr::CONTROLLING] = Reader.ReadSubExpr();
870 for (unsigned I = 0, N = E->getNumAssocs(); I != N; ++I) {
871 E->AssocTypes[I] = GetTypeSourceInfo(Record, Idx);
872 E->SubExprs[GenericSelectionExpr::END_EXPR+I] = Reader.ReadSubExpr();
873 }
874 E->ResultIndex = Record[Idx++];
875
876 E->GenericLoc = ReadSourceLocation(Record, Idx);
877 E->DefaultLoc = ReadSourceLocation(Record, Idx);
878 E->RParenLoc = ReadSourceLocation(Record, Idx);
879}
880
John McCall4b9c2d22011-11-06 09:01:30 +0000881void ASTStmtReader::VisitPseudoObjectExpr(PseudoObjectExpr *E) {
882 VisitExpr(E);
883 unsigned numSemanticExprs = Record[Idx++];
884 assert(numSemanticExprs + 1 == E->PseudoObjectExprBits.NumSubExprs);
885 E->PseudoObjectExprBits.ResultIndex = Record[Idx++];
886
887 // Read the syntactic expression.
888 E->getSubExprsBuffer()[0] = Reader.ReadSubExpr();
889
890 // Read all the semantic expressions.
891 for (unsigned i = 0; i != numSemanticExprs; ++i) {
892 Expr *subExpr = Reader.ReadSubExpr();
John McCall4b9c2d22011-11-06 09:01:30 +0000893 E->getSubExprsBuffer()[i+1] = subExpr;
894 }
895}
896
Eli Friedman276b0612011-10-11 02:20:01 +0000897void ASTStmtReader::VisitAtomicExpr(AtomicExpr *E) {
898 VisitExpr(E);
Richard Smithe1b2abc2012-04-10 22:49:28 +0000899 E->Op = AtomicExpr::AtomicOp(Record[Idx++]);
900 E->NumSubExprs = AtomicExpr::getNumSubExprs(E->Op);
901 for (unsigned I = 0; I != E->NumSubExprs; ++I)
902 E->SubExprs[I] = Reader.ReadSubExpr();
903 E->BuiltinLoc = ReadSourceLocation(Record, Idx);
904 E->RParenLoc = ReadSourceLocation(Record, Idx);
Eli Friedman276b0612011-10-11 02:20:01 +0000905}
906
Chris Lattner4c6f9522009-04-27 05:14:47 +0000907//===----------------------------------------------------------------------===//
908// Objective-C Expressions and Statements
909
Sebastian Redl60adf4a2010-08-18 23:56:52 +0000910void ASTStmtReader::VisitObjCStringLiteral(ObjCStringLiteral *E) {
Chris Lattner4c6f9522009-04-27 05:14:47 +0000911 VisitExpr(E);
Argyrios Kyrtzidisd98a2ab2010-06-29 22:46:25 +0000912 E->setString(cast<StringLiteral>(Reader.ReadSubStmt()));
Sebastian Redlc3632732010-10-05 15:59:54 +0000913 E->setAtLoc(ReadSourceLocation(Record, Idx));
Chris Lattner4c6f9522009-04-27 05:14:47 +0000914}
915
Patrick Beardeb382ec2012-04-19 00:25:12 +0000916void ASTStmtReader::VisitObjCBoxedExpr(ObjCBoxedExpr *E) {
Ted Kremenekebcb57a2012-03-06 20:05:56 +0000917 VisitExpr(E);
918 // could be one of several IntegerLiteral, FloatLiteral, etc.
Patrick Beardeb382ec2012-04-19 00:25:12 +0000919 E->SubExpr = Reader.ReadSubStmt();
920 E->BoxingMethod = ReadDeclAs<ObjCMethodDecl>(Record, Idx);
921 E->Range = ReadSourceRange(Record, Idx);
Ted Kremenekebcb57a2012-03-06 20:05:56 +0000922}
923
924void ASTStmtReader::VisitObjCArrayLiteral(ObjCArrayLiteral *E) {
925 VisitExpr(E);
926 unsigned NumElements = Record[Idx++];
927 assert(NumElements == E->getNumElements() && "Wrong number of elements");
928 Expr **Elements = E->getElements();
929 for (unsigned I = 0, N = NumElements; I != N; ++I)
930 Elements[I] = Reader.ReadSubExpr();
931 E->ArrayWithObjectsMethod = ReadDeclAs<ObjCMethodDecl>(Record, Idx);
932 E->Range = ReadSourceRange(Record, Idx);
933}
934
935void ASTStmtReader::VisitObjCDictionaryLiteral(ObjCDictionaryLiteral *E) {
936 VisitExpr(E);
937 unsigned NumElements = Record[Idx++];
938 assert(NumElements == E->getNumElements() && "Wrong number of elements");
939 bool HasPackExpansions = Record[Idx++];
940 assert(HasPackExpansions == E->HasPackExpansions &&"Pack expansion mismatch");
941 ObjCDictionaryLiteral::KeyValuePair *KeyValues = E->getKeyValues();
942 ObjCDictionaryLiteral::ExpansionData *Expansions = E->getExpansionData();
943 for (unsigned I = 0; I != NumElements; ++I) {
944 KeyValues[I].Key = Reader.ReadSubExpr();
945 KeyValues[I].Value = Reader.ReadSubExpr();
946 if (HasPackExpansions) {
947 Expansions[I].EllipsisLoc = ReadSourceLocation(Record, Idx);
948 Expansions[I].NumExpansionsPlusOne = Record[Idx++];
949 }
950 }
951 E->DictWithObjectsMethod = ReadDeclAs<ObjCMethodDecl>(Record, Idx);
952 E->Range = ReadSourceRange(Record, Idx);
953}
954
Sebastian Redl60adf4a2010-08-18 23:56:52 +0000955void ASTStmtReader::VisitObjCEncodeExpr(ObjCEncodeExpr *E) {
Chris Lattner4c6f9522009-04-27 05:14:47 +0000956 VisitExpr(E);
Sebastian Redlc3632732010-10-05 15:59:54 +0000957 E->setEncodedTypeSourceInfo(GetTypeSourceInfo(Record, Idx));
958 E->setAtLoc(ReadSourceLocation(Record, Idx));
959 E->setRParenLoc(ReadSourceLocation(Record, Idx));
Chris Lattner4c6f9522009-04-27 05:14:47 +0000960}
961
Sebastian Redl60adf4a2010-08-18 23:56:52 +0000962void ASTStmtReader::VisitObjCSelectorExpr(ObjCSelectorExpr *E) {
Chris Lattner4c6f9522009-04-27 05:14:47 +0000963 VisitExpr(E);
Douglas Gregor2d2689a2011-07-28 21:16:51 +0000964 E->setSelector(Reader.ReadSelector(F, Record, Idx));
Sebastian Redlc3632732010-10-05 15:59:54 +0000965 E->setAtLoc(ReadSourceLocation(Record, Idx));
966 E->setRParenLoc(ReadSourceLocation(Record, Idx));
Chris Lattner4c6f9522009-04-27 05:14:47 +0000967}
968
Sebastian Redl60adf4a2010-08-18 23:56:52 +0000969void ASTStmtReader::VisitObjCProtocolExpr(ObjCProtocolExpr *E) {
Chris Lattner4c6f9522009-04-27 05:14:47 +0000970 VisitExpr(E);
Douglas Gregor409448c2011-07-21 22:35:25 +0000971 E->setProtocol(ReadDeclAs<ObjCProtocolDecl>(Record, Idx));
Sebastian Redlc3632732010-10-05 15:59:54 +0000972 E->setAtLoc(ReadSourceLocation(Record, Idx));
Argyrios Kyrtzidis7d24e282012-05-16 00:50:02 +0000973 E->ProtoLoc = ReadSourceLocation(Record, Idx);
Sebastian Redlc3632732010-10-05 15:59:54 +0000974 E->setRParenLoc(ReadSourceLocation(Record, Idx));
Chris Lattner4c6f9522009-04-27 05:14:47 +0000975}
976
Sebastian Redl60adf4a2010-08-18 23:56:52 +0000977void ASTStmtReader::VisitObjCIvarRefExpr(ObjCIvarRefExpr *E) {
Chris Lattner4c6f9522009-04-27 05:14:47 +0000978 VisitExpr(E);
Douglas Gregor409448c2011-07-21 22:35:25 +0000979 E->setDecl(ReadDeclAs<ObjCIvarDecl>(Record, Idx));
Sebastian Redlc3632732010-10-05 15:59:54 +0000980 E->setLocation(ReadSourceLocation(Record, Idx));
Fariborz Jahanian0c701812013-04-02 18:57:54 +0000981 E->setOpLoc(ReadSourceLocation(Record, Idx));
Argyrios Kyrtzidisd98a2ab2010-06-29 22:46:25 +0000982 E->setBase(Reader.ReadSubExpr());
Chris Lattner4c6f9522009-04-27 05:14:47 +0000983 E->setIsArrow(Record[Idx++]);
984 E->setIsFreeIvar(Record[Idx++]);
Chris Lattner4c6f9522009-04-27 05:14:47 +0000985}
986
Sebastian Redl60adf4a2010-08-18 23:56:52 +0000987void ASTStmtReader::VisitObjCPropertyRefExpr(ObjCPropertyRefExpr *E) {
Chris Lattner4c6f9522009-04-27 05:14:47 +0000988 VisitExpr(E);
Argyrios Kyrtzidisb085d892012-03-30 00:19:18 +0000989 unsigned MethodRefFlags = Record[Idx++];
John McCall12f78a62010-12-02 01:19:52 +0000990 bool Implicit = Record[Idx++] != 0;
991 if (Implicit) {
Douglas Gregor409448c2011-07-21 22:35:25 +0000992 ObjCMethodDecl *Getter = ReadDeclAs<ObjCMethodDecl>(Record, Idx);
993 ObjCMethodDecl *Setter = ReadDeclAs<ObjCMethodDecl>(Record, Idx);
Argyrios Kyrtzidisb085d892012-03-30 00:19:18 +0000994 E->setImplicitProperty(Getter, Setter, MethodRefFlags);
John McCall12f78a62010-12-02 01:19:52 +0000995 } else {
Argyrios Kyrtzidisb085d892012-03-30 00:19:18 +0000996 E->setExplicitProperty(ReadDeclAs<ObjCPropertyDecl>(Record, Idx),
997 MethodRefFlags);
Fariborz Jahanian8ac2d442010-10-14 16:04:05 +0000998 }
Sebastian Redlc3632732010-10-05 15:59:54 +0000999 E->setLocation(ReadSourceLocation(Record, Idx));
John McCall12f78a62010-12-02 01:19:52 +00001000 E->setReceiverLocation(ReadSourceLocation(Record, Idx));
1001 switch (Record[Idx++]) {
1002 case 0:
1003 E->setBase(Reader.ReadSubExpr());
1004 break;
1005 case 1:
Douglas Gregor393f2492011-07-22 00:38:23 +00001006 E->setSuperReceiver(Reader.readType(F, Record, Idx));
John McCall12f78a62010-12-02 01:19:52 +00001007 break;
1008 case 2:
Douglas Gregor409448c2011-07-21 22:35:25 +00001009 E->setClassReceiver(ReadDeclAs<ObjCInterfaceDecl>(Record, Idx));
John McCall12f78a62010-12-02 01:19:52 +00001010 break;
1011 }
Chris Lattner4c6f9522009-04-27 05:14:47 +00001012}
1013
Ted Kremenekebcb57a2012-03-06 20:05:56 +00001014void ASTStmtReader::VisitObjCSubscriptRefExpr(ObjCSubscriptRefExpr *E) {
1015 VisitExpr(E);
1016 E->setRBracket(ReadSourceLocation(Record, Idx));
1017 E->setBaseExpr(Reader.ReadSubExpr());
1018 E->setKeyExpr(Reader.ReadSubExpr());
1019 E->GetAtIndexMethodDecl = ReadDeclAs<ObjCMethodDecl>(Record, Idx);
1020 E->SetAtIndexMethodDecl = ReadDeclAs<ObjCMethodDecl>(Record, Idx);
1021}
1022
Sebastian Redl60adf4a2010-08-18 23:56:52 +00001023void ASTStmtReader::VisitObjCMessageExpr(ObjCMessageExpr *E) {
Chris Lattner4c6f9522009-04-27 05:14:47 +00001024 VisitExpr(E);
Douglas Gregor04badcf2010-04-21 00:45:42 +00001025 assert(Record[Idx] == E->getNumArgs());
1026 ++Idx;
Argyrios Kyrtzidis20718082011-10-03 06:36:51 +00001027 unsigned NumStoredSelLocs = Record[Idx++];
1028 E->SelLocsKind = Record[Idx++];
John McCallf85e1932011-06-15 23:02:42 +00001029 E->setDelegateInitCall(Record[Idx++]);
Argyrios Kyrtzidis746f5bc2012-01-12 02:34:39 +00001030 E->IsImplicit = Record[Idx++];
Douglas Gregor04badcf2010-04-21 00:45:42 +00001031 ObjCMessageExpr::ReceiverKind Kind
1032 = static_cast<ObjCMessageExpr::ReceiverKind>(Record[Idx++]);
1033 switch (Kind) {
1034 case ObjCMessageExpr::Instance:
Argyrios Kyrtzidisd98a2ab2010-06-29 22:46:25 +00001035 E->setInstanceReceiver(Reader.ReadSubExpr());
Douglas Gregor04badcf2010-04-21 00:45:42 +00001036 break;
1037
1038 case ObjCMessageExpr::Class:
Sebastian Redlc3632732010-10-05 15:59:54 +00001039 E->setClassReceiver(GetTypeSourceInfo(Record, Idx));
Douglas Gregor04badcf2010-04-21 00:45:42 +00001040 break;
1041
1042 case ObjCMessageExpr::SuperClass:
1043 case ObjCMessageExpr::SuperInstance: {
Douglas Gregor393f2492011-07-22 00:38:23 +00001044 QualType T = Reader.readType(F, Record, Idx);
Sebastian Redlc3632732010-10-05 15:59:54 +00001045 SourceLocation SuperLoc = ReadSourceLocation(Record, Idx);
Douglas Gregor04badcf2010-04-21 00:45:42 +00001046 E->setSuper(SuperLoc, T, Kind == ObjCMessageExpr::SuperInstance);
1047 break;
1048 }
1049 }
1050
1051 assert(Kind == E->getReceiverKind());
1052
1053 if (Record[Idx++])
Douglas Gregor409448c2011-07-21 22:35:25 +00001054 E->setMethodDecl(ReadDeclAs<ObjCMethodDecl>(Record, Idx));
Douglas Gregor04badcf2010-04-21 00:45:42 +00001055 else
Douglas Gregor2d2689a2011-07-28 21:16:51 +00001056 E->setSelector(Reader.ReadSelector(F, Record, Idx));
Douglas Gregor04badcf2010-04-21 00:45:42 +00001057
Argyrios Kyrtzidisf40f0d52010-12-10 20:08:27 +00001058 E->LBracLoc = ReadSourceLocation(Record, Idx);
1059 E->RBracLoc = ReadSourceLocation(Record, Idx);
Chris Lattner4c6f9522009-04-27 05:14:47 +00001060
1061 for (unsigned I = 0, N = E->getNumArgs(); I != N; ++I)
Argyrios Kyrtzidisd98a2ab2010-06-29 22:46:25 +00001062 E->setArg(I, Reader.ReadSubExpr());
Argyrios Kyrtzidis20718082011-10-03 06:36:51 +00001063
1064 SourceLocation *Locs = E->getStoredSelLocs();
1065 for (unsigned I = 0; I != NumStoredSelLocs; ++I)
1066 Locs[I] = ReadSourceLocation(Record, Idx);
Chris Lattner4c6f9522009-04-27 05:14:47 +00001067}
1068
Sebastian Redl60adf4a2010-08-18 23:56:52 +00001069void ASTStmtReader::VisitObjCForCollectionStmt(ObjCForCollectionStmt *S) {
Chris Lattner4c6f9522009-04-27 05:14:47 +00001070 VisitStmt(S);
Argyrios Kyrtzidisd98a2ab2010-06-29 22:46:25 +00001071 S->setElement(Reader.ReadSubStmt());
1072 S->setCollection(Reader.ReadSubExpr());
1073 S->setBody(Reader.ReadSubStmt());
Sebastian Redlc3632732010-10-05 15:59:54 +00001074 S->setForLoc(ReadSourceLocation(Record, Idx));
1075 S->setRParenLoc(ReadSourceLocation(Record, Idx));
Chris Lattner4c6f9522009-04-27 05:14:47 +00001076}
1077
Sebastian Redl60adf4a2010-08-18 23:56:52 +00001078void ASTStmtReader::VisitObjCAtCatchStmt(ObjCAtCatchStmt *S) {
Chris Lattner4c6f9522009-04-27 05:14:47 +00001079 VisitStmt(S);
Argyrios Kyrtzidisd98a2ab2010-06-29 22:46:25 +00001080 S->setCatchBody(Reader.ReadSubStmt());
Douglas Gregor409448c2011-07-21 22:35:25 +00001081 S->setCatchParamDecl(ReadDeclAs<VarDecl>(Record, Idx));
Sebastian Redlc3632732010-10-05 15:59:54 +00001082 S->setAtCatchLoc(ReadSourceLocation(Record, Idx));
1083 S->setRParenLoc(ReadSourceLocation(Record, Idx));
Chris Lattner4c6f9522009-04-27 05:14:47 +00001084}
1085
Sebastian Redl60adf4a2010-08-18 23:56:52 +00001086void ASTStmtReader::VisitObjCAtFinallyStmt(ObjCAtFinallyStmt *S) {
Chris Lattner4c6f9522009-04-27 05:14:47 +00001087 VisitStmt(S);
Argyrios Kyrtzidisd98a2ab2010-06-29 22:46:25 +00001088 S->setFinallyBody(Reader.ReadSubStmt());
Sebastian Redlc3632732010-10-05 15:59:54 +00001089 S->setAtFinallyLoc(ReadSourceLocation(Record, Idx));
Chris Lattner4c6f9522009-04-27 05:14:47 +00001090}
1091
John McCallf85e1932011-06-15 23:02:42 +00001092void ASTStmtReader::VisitObjCAutoreleasePoolStmt(ObjCAutoreleasePoolStmt *S) {
1093 VisitStmt(S);
1094 S->setSubStmt(Reader.ReadSubStmt());
1095 S->setAtLoc(ReadSourceLocation(Record, Idx));
1096}
1097
Sebastian Redl60adf4a2010-08-18 23:56:52 +00001098void ASTStmtReader::VisitObjCAtTryStmt(ObjCAtTryStmt *S) {
Chris Lattner4c6f9522009-04-27 05:14:47 +00001099 VisitStmt(S);
Douglas Gregor8f5e3dd2010-04-23 22:50:49 +00001100 assert(Record[Idx] == S->getNumCatchStmts());
1101 ++Idx;
1102 bool HasFinally = Record[Idx++];
Argyrios Kyrtzidisd98a2ab2010-06-29 22:46:25 +00001103 S->setTryBody(Reader.ReadSubStmt());
Argyrios Kyrtzidis919e6932010-06-28 22:28:35 +00001104 for (unsigned I = 0, N = S->getNumCatchStmts(); I != N; ++I)
Argyrios Kyrtzidisd98a2ab2010-06-29 22:46:25 +00001105 S->setCatchStmt(I, cast_or_null<ObjCAtCatchStmt>(Reader.ReadSubStmt()));
Douglas Gregor8f5e3dd2010-04-23 22:50:49 +00001106
Douglas Gregor8f5e3dd2010-04-23 22:50:49 +00001107 if (HasFinally)
Argyrios Kyrtzidisd98a2ab2010-06-29 22:46:25 +00001108 S->setFinallyStmt(Reader.ReadSubStmt());
Sebastian Redlc3632732010-10-05 15:59:54 +00001109 S->setAtTryLoc(ReadSourceLocation(Record, Idx));
Chris Lattner4c6f9522009-04-27 05:14:47 +00001110}
1111
Sebastian Redl60adf4a2010-08-18 23:56:52 +00001112void ASTStmtReader::VisitObjCAtSynchronizedStmt(ObjCAtSynchronizedStmt *S) {
Chris Lattner4c6f9522009-04-27 05:14:47 +00001113 VisitStmt(S);
Argyrios Kyrtzidisd98a2ab2010-06-29 22:46:25 +00001114 S->setSynchExpr(Reader.ReadSubStmt());
1115 S->setSynchBody(Reader.ReadSubStmt());
Sebastian Redlc3632732010-10-05 15:59:54 +00001116 S->setAtSynchronizedLoc(ReadSourceLocation(Record, Idx));
Chris Lattner4c6f9522009-04-27 05:14:47 +00001117}
1118
Sebastian Redl60adf4a2010-08-18 23:56:52 +00001119void ASTStmtReader::VisitObjCAtThrowStmt(ObjCAtThrowStmt *S) {
Chris Lattner4c6f9522009-04-27 05:14:47 +00001120 VisitStmt(S);
Argyrios Kyrtzidisd98a2ab2010-06-29 22:46:25 +00001121 S->setThrowExpr(Reader.ReadSubStmt());
Sebastian Redlc3632732010-10-05 15:59:54 +00001122 S->setThrowLoc(ReadSourceLocation(Record, Idx));
Chris Lattner4c6f9522009-04-27 05:14:47 +00001123}
1124
Ted Kremenekebcb57a2012-03-06 20:05:56 +00001125void ASTStmtReader::VisitObjCBoolLiteralExpr(ObjCBoolLiteralExpr *E) {
1126 VisitExpr(E);
1127 E->setValue(Record[Idx++]);
1128 E->setLocation(ReadSourceLocation(Record, Idx));
1129}
1130
Argyrios Kyrtzidisba0a9002009-07-14 03:19:21 +00001131//===----------------------------------------------------------------------===//
1132// C++ Expressions and Statements
Argyrios Kyrtzidis7cb45e32010-07-22 16:03:56 +00001133//===----------------------------------------------------------------------===//
1134
Sebastian Redl60adf4a2010-08-18 23:56:52 +00001135void ASTStmtReader::VisitCXXCatchStmt(CXXCatchStmt *S) {
Argyrios Kyrtzidis7cb45e32010-07-22 16:03:56 +00001136 VisitStmt(S);
Sebastian Redlc3632732010-10-05 15:59:54 +00001137 S->CatchLoc = ReadSourceLocation(Record, Idx);
Douglas Gregor409448c2011-07-21 22:35:25 +00001138 S->ExceptionDecl = ReadDeclAs<VarDecl>(Record, Idx);
Argyrios Kyrtzidis7cb45e32010-07-22 16:03:56 +00001139 S->HandlerBlock = Reader.ReadSubStmt();
1140}
1141
Sebastian Redl60adf4a2010-08-18 23:56:52 +00001142void ASTStmtReader::VisitCXXTryStmt(CXXTryStmt *S) {
Argyrios Kyrtzidis7cb45e32010-07-22 16:03:56 +00001143 VisitStmt(S);
1144 assert(Record[Idx] == S->getNumHandlers() && "NumStmtFields is wrong ?");
1145 ++Idx;
Sebastian Redlc3632732010-10-05 15:59:54 +00001146 S->TryLoc = ReadSourceLocation(Record, Idx);
Argyrios Kyrtzidis7cb45e32010-07-22 16:03:56 +00001147 S->getStmts()[0] = Reader.ReadSubStmt();
1148 for (unsigned i = 0, e = S->getNumHandlers(); i != e; ++i)
1149 S->getStmts()[i + 1] = Reader.ReadSubStmt();
1150}
Argyrios Kyrtzidisba0a9002009-07-14 03:19:21 +00001151
Richard Smithad762fc2011-04-14 22:09:26 +00001152void ASTStmtReader::VisitCXXForRangeStmt(CXXForRangeStmt *S) {
1153 VisitStmt(S);
1154 S->setForLoc(ReadSourceLocation(Record, Idx));
1155 S->setColonLoc(ReadSourceLocation(Record, Idx));
1156 S->setRParenLoc(ReadSourceLocation(Record, Idx));
1157 S->setRangeStmt(Reader.ReadSubStmt());
1158 S->setBeginEndStmt(Reader.ReadSubStmt());
1159 S->setCond(Reader.ReadSubExpr());
1160 S->setInc(Reader.ReadSubExpr());
1161 S->setLoopVarStmt(Reader.ReadSubStmt());
1162 S->setBody(Reader.ReadSubStmt());
1163}
1164
Douglas Gregorba0513d2011-10-25 01:33:02 +00001165void ASTStmtReader::VisitMSDependentExistsStmt(MSDependentExistsStmt *S) {
1166 VisitStmt(S);
1167 S->KeywordLoc = ReadSourceLocation(Record, Idx);
1168 S->IsIfExists = Record[Idx++];
1169 S->QualifierLoc = Reader.ReadNestedNameSpecifierLoc(F, Record, Idx);
1170 ReadDeclarationNameInfo(S->NameInfo, Record, Idx);
1171 S->SubStmt = Reader.ReadSubStmt();
1172}
1173
Sebastian Redl60adf4a2010-08-18 23:56:52 +00001174void ASTStmtReader::VisitCXXOperatorCallExpr(CXXOperatorCallExpr *E) {
Argyrios Kyrtzidis919e6932010-06-28 22:28:35 +00001175 VisitCallExpr(E);
Argyrios Kyrtzidis4548ca22012-04-30 22:12:22 +00001176 E->Operator = (OverloadedOperatorKind)Record[Idx++];
1177 E->Range = Reader.ReadSourceRange(F, Record, Idx);
Lang Hamesbe9af122012-10-02 04:45:10 +00001178 E->setFPContractable((bool)Record[Idx++]);
Argyrios Kyrtzidisba0a9002009-07-14 03:19:21 +00001179}
1180
Sebastian Redl60adf4a2010-08-18 23:56:52 +00001181void ASTStmtReader::VisitCXXConstructExpr(CXXConstructExpr *E) {
Douglas Gregor39da0b82009-09-09 23:08:42 +00001182 VisitExpr(E);
Argyrios Kyrtzidis6d00c132010-07-10 11:46:15 +00001183 E->NumArgs = Record[Idx++];
1184 if (E->NumArgs)
Douglas Gregor35942772011-09-09 21:34:22 +00001185 E->Args = new (Reader.getContext()) Stmt*[E->NumArgs];
Argyrios Kyrtzidis5e1b7c22010-06-24 08:57:09 +00001186 for (unsigned I = 0, N = E->getNumArgs(); I != N; ++I)
Argyrios Kyrtzidisd98a2ab2010-06-29 22:46:25 +00001187 E->setArg(I, Reader.ReadSubExpr());
Douglas Gregor409448c2011-07-21 22:35:25 +00001188 E->setConstructor(ReadDeclAs<CXXConstructorDecl>(Record, Idx));
Sebastian Redlc3632732010-10-05 15:59:54 +00001189 E->setLocation(ReadSourceLocation(Record, Idx));
Abramo Bagnara7cc58b42011-10-05 07:56:41 +00001190 E->setElidable(Record[Idx++]);
1191 E->setHadMultipleCandidates(Record[Idx++]);
Richard Smithc83c2302012-12-19 01:39:02 +00001192 E->setListInitialization(Record[Idx++]);
Douglas Gregor16006c92009-12-16 18:50:27 +00001193 E->setRequiresZeroInitialization(Record[Idx++]);
Douglas Gregor3c9034c2010-05-15 00:13:29 +00001194 E->setConstructionKind((CXXConstructExpr::ConstructionKind)Record[Idx++]);
Chandler Carruth428edaf2010-10-25 08:47:36 +00001195 E->ParenRange = ReadSourceRange(Record, Idx);
Douglas Gregor39da0b82009-09-09 23:08:42 +00001196}
Chris Lattner4c6f9522009-04-27 05:14:47 +00001197
Sebastian Redl60adf4a2010-08-18 23:56:52 +00001198void ASTStmtReader::VisitCXXTemporaryObjectExpr(CXXTemporaryObjectExpr *E) {
Argyrios Kyrtzidis6d00c132010-07-10 11:46:15 +00001199 VisitCXXConstructExpr(E);
Sebastian Redlc3632732010-10-05 15:59:54 +00001200 E->Type = GetTypeSourceInfo(Record, Idx);
Argyrios Kyrtzidis6d00c132010-07-10 11:46:15 +00001201}
1202
Douglas Gregor01d08012012-02-07 10:09:13 +00001203void ASTStmtReader::VisitLambdaExpr(LambdaExpr *E) {
1204 VisitExpr(E);
Douglas Gregor9d36f5d2012-02-14 17:54:36 +00001205 unsigned NumCaptures = Record[Idx++];
1206 assert(NumCaptures == E->NumCaptures);(void)NumCaptures;
1207 unsigned NumArrayIndexVars = Record[Idx++];
1208 E->IntroducerRange = ReadSourceRange(Record, Idx);
1209 E->CaptureDefault = static_cast<LambdaCaptureDefault>(Record[Idx++]);
James Dennettf68af642013-08-09 23:08:25 +00001210 E->CaptureDefaultLoc = ReadSourceLocation(Record, Idx);
Douglas Gregor9d36f5d2012-02-14 17:54:36 +00001211 E->ExplicitParams = Record[Idx++];
1212 E->ExplicitResultType = Record[Idx++];
1213 E->ClosingBrace = ReadSourceLocation(Record, Idx);
1214
1215 // Read capture initializers.
1216 for (LambdaExpr::capture_init_iterator C = E->capture_init_begin(),
1217 CEnd = E->capture_init_end();
1218 C != CEnd; ++C)
1219 *C = Reader.ReadSubExpr();
1220
1221 // Read array capture index variables.
1222 if (NumArrayIndexVars > 0) {
1223 unsigned *ArrayIndexStarts = E->getArrayIndexStarts();
1224 for (unsigned I = 0; I != NumCaptures + 1; ++I)
1225 ArrayIndexStarts[I] = Record[Idx++];
1226
1227 VarDecl **ArrayIndexVars = E->getArrayIndexVars();
1228 for (unsigned I = 0; I != NumArrayIndexVars; ++I)
1229 ArrayIndexVars[I] = ReadDeclAs<VarDecl>(Record, Idx);
1230 }
Douglas Gregor01d08012012-02-07 10:09:13 +00001231}
1232
Richard Smith7c3e6152013-06-12 22:31:48 +00001233void
1234ASTStmtReader::VisitCXXStdInitializerListExpr(CXXStdInitializerListExpr *E) {
1235 VisitExpr(E);
1236 E->SubExpr = Reader.ReadSubExpr();
1237}
1238
Sebastian Redl60adf4a2010-08-18 23:56:52 +00001239void ASTStmtReader::VisitCXXNamedCastExpr(CXXNamedCastExpr *E) {
Argyrios Kyrtzidis919e6932010-06-28 22:28:35 +00001240 VisitExplicitCastExpr(E);
Douglas Gregor1d5d0b92011-01-12 22:41:29 +00001241 SourceRange R = ReadSourceRange(Record, Idx);
1242 E->Loc = R.getBegin();
1243 E->RParenLoc = R.getEnd();
Fariborz Jahanianf799ae12013-02-22 22:02:53 +00001244 R = ReadSourceRange(Record, Idx);
1245 E->AngleBrackets = R;
Sam Weinigce757a72010-01-16 21:21:01 +00001246}
1247
Sebastian Redl60adf4a2010-08-18 23:56:52 +00001248void ASTStmtReader::VisitCXXStaticCastExpr(CXXStaticCastExpr *E) {
Sam Weinigce757a72010-01-16 21:21:01 +00001249 return VisitCXXNamedCastExpr(E);
1250}
1251
Sebastian Redl60adf4a2010-08-18 23:56:52 +00001252void ASTStmtReader::VisitCXXDynamicCastExpr(CXXDynamicCastExpr *E) {
Sam Weinigce757a72010-01-16 21:21:01 +00001253 return VisitCXXNamedCastExpr(E);
1254}
1255
Sebastian Redl60adf4a2010-08-18 23:56:52 +00001256void ASTStmtReader::VisitCXXReinterpretCastExpr(CXXReinterpretCastExpr *E) {
Sam Weinigce757a72010-01-16 21:21:01 +00001257 return VisitCXXNamedCastExpr(E);
1258}
1259
Sebastian Redl60adf4a2010-08-18 23:56:52 +00001260void ASTStmtReader::VisitCXXConstCastExpr(CXXConstCastExpr *E) {
Sam Weinigce757a72010-01-16 21:21:01 +00001261 return VisitCXXNamedCastExpr(E);
1262}
1263
Sebastian Redl60adf4a2010-08-18 23:56:52 +00001264void ASTStmtReader::VisitCXXFunctionalCastExpr(CXXFunctionalCastExpr *E) {
Argyrios Kyrtzidis919e6932010-06-28 22:28:35 +00001265 VisitExplicitCastExpr(E);
Eli Friedmancdd4b782013-08-15 22:02:56 +00001266 E->setLParenLoc(ReadSourceLocation(Record, Idx));
Sebastian Redlc3632732010-10-05 15:59:54 +00001267 E->setRParenLoc(ReadSourceLocation(Record, Idx));
Sam Weinigce757a72010-01-16 21:21:01 +00001268}
1269
Richard Smith9fcce652012-03-07 08:35:16 +00001270void ASTStmtReader::VisitUserDefinedLiteral(UserDefinedLiteral *E) {
1271 VisitCallExpr(E);
1272 E->UDSuffixLoc = ReadSourceLocation(Record, Idx);
1273}
1274
Sebastian Redl60adf4a2010-08-18 23:56:52 +00001275void ASTStmtReader::VisitCXXBoolLiteralExpr(CXXBoolLiteralExpr *E) {
Sam Weinigeb7f9612010-02-07 06:32:43 +00001276 VisitExpr(E);
1277 E->setValue(Record[Idx++]);
Sebastian Redlc3632732010-10-05 15:59:54 +00001278 E->setLocation(ReadSourceLocation(Record, Idx));
Sam Weinigeb7f9612010-02-07 06:32:43 +00001279}
1280
Sebastian Redl60adf4a2010-08-18 23:56:52 +00001281void ASTStmtReader::VisitCXXNullPtrLiteralExpr(CXXNullPtrLiteralExpr *E) {
Sam Weinigeb7f9612010-02-07 06:32:43 +00001282 VisitExpr(E);
Sebastian Redlc3632732010-10-05 15:59:54 +00001283 E->setLocation(ReadSourceLocation(Record, Idx));
Sam Weinigeb7f9612010-02-07 06:32:43 +00001284}
1285
Sebastian Redl60adf4a2010-08-18 23:56:52 +00001286void ASTStmtReader::VisitCXXTypeidExpr(CXXTypeidExpr *E) {
Chris Lattner14ab24f2010-05-09 06:03:39 +00001287 VisitExpr(E);
Sebastian Redlc3632732010-10-05 15:59:54 +00001288 E->setSourceRange(ReadSourceRange(Record, Idx));
Chris Lattner14ab24f2010-05-09 06:03:39 +00001289 if (E->isTypeOperand()) { // typeid(int)
Sebastian Redl577d4792010-07-22 22:43:28 +00001290 E->setTypeOperandSourceInfo(
Sebastian Redlc3632732010-10-05 15:59:54 +00001291 GetTypeSourceInfo(Record, Idx));
Argyrios Kyrtzidis919e6932010-06-28 22:28:35 +00001292 return;
Chris Lattner14ab24f2010-05-09 06:03:39 +00001293 }
1294
1295 // typeid(42+2)
Argyrios Kyrtzidisd98a2ab2010-06-29 22:46:25 +00001296 E->setExprOperand(Reader.ReadSubExpr());
Chris Lattner14ab24f2010-05-09 06:03:39 +00001297}
1298
Sebastian Redl60adf4a2010-08-18 23:56:52 +00001299void ASTStmtReader::VisitCXXThisExpr(CXXThisExpr *E) {
Chris Lattner2fbdfcd2010-05-09 06:15:05 +00001300 VisitExpr(E);
Sebastian Redlc3632732010-10-05 15:59:54 +00001301 E->setLocation(ReadSourceLocation(Record, Idx));
Chris Lattner2fbdfcd2010-05-09 06:15:05 +00001302 E->setImplicit(Record[Idx++]);
Chris Lattner2fbdfcd2010-05-09 06:15:05 +00001303}
1304
Sebastian Redl60adf4a2010-08-18 23:56:52 +00001305void ASTStmtReader::VisitCXXThrowExpr(CXXThrowExpr *E) {
Chris Lattner2fbdfcd2010-05-09 06:15:05 +00001306 VisitExpr(E);
Douglas Gregorbca01b42011-07-06 22:04:06 +00001307 E->ThrowLoc = ReadSourceLocation(Record, Idx);
1308 E->Op = Reader.ReadSubExpr();
1309 E->IsThrownVariableInScope = Record[Idx++];
Chris Lattner2fbdfcd2010-05-09 06:15:05 +00001310}
Chris Lattner14ab24f2010-05-09 06:03:39 +00001311
Sebastian Redl60adf4a2010-08-18 23:56:52 +00001312void ASTStmtReader::VisitCXXDefaultArgExpr(CXXDefaultArgExpr *E) {
Chris Lattner030854b2010-05-09 06:40:08 +00001313 VisitExpr(E);
Argyrios Kyrtzidis8a507332010-07-02 23:30:15 +00001314
Douglas Gregordf226552011-09-23 22:07:41 +00001315 assert((bool)Record[Idx] == E->Param.getInt() && "We messed up at creation ?");
Argyrios Kyrtzidis8a507332010-07-02 23:30:15 +00001316 ++Idx; // HasOtherExprStored and SubExpr was handled during creation.
Douglas Gregor409448c2011-07-21 22:35:25 +00001317 E->Param.setPointer(ReadDeclAs<ParmVarDecl>(Record, Idx));
Sebastian Redlc3632732010-10-05 15:59:54 +00001318 E->Loc = ReadSourceLocation(Record, Idx);
Chris Lattnerd2598362010-05-10 00:25:06 +00001319}
1320
Richard Smithc3bf52c2013-04-20 22:23:05 +00001321void ASTStmtReader::VisitCXXDefaultInitExpr(CXXDefaultInitExpr *E) {
1322 VisitExpr(E);
1323 E->Field = ReadDeclAs<FieldDecl>(Record, Idx);
1324 E->Loc = ReadSourceLocation(Record, Idx);
1325}
1326
Sebastian Redl60adf4a2010-08-18 23:56:52 +00001327void ASTStmtReader::VisitCXXBindTemporaryExpr(CXXBindTemporaryExpr *E) {
Chris Lattnerd2598362010-05-10 00:25:06 +00001328 VisitExpr(E);
Douglas Gregor409448c2011-07-21 22:35:25 +00001329 E->setTemporary(Reader.ReadCXXTemporary(F, Record, Idx));
Argyrios Kyrtzidisd98a2ab2010-06-29 22:46:25 +00001330 E->setSubExpr(Reader.ReadSubExpr());
Chris Lattnerd2598362010-05-10 00:25:06 +00001331}
1332
Sebastian Redl60adf4a2010-08-18 23:56:52 +00001333void ASTStmtReader::VisitCXXScalarValueInitExpr(CXXScalarValueInitExpr *E) {
Chris Lattner59218632010-05-10 01:22:27 +00001334 VisitExpr(E);
Sebastian Redlc3632732010-10-05 15:59:54 +00001335 E->TypeInfo = GetTypeSourceInfo(Record, Idx);
1336 E->RParenLoc = ReadSourceLocation(Record, Idx);
Chris Lattner59218632010-05-10 01:22:27 +00001337}
1338
Sebastian Redl60adf4a2010-08-18 23:56:52 +00001339void ASTStmtReader::VisitCXXNewExpr(CXXNewExpr *E) {
Chris Lattner59218632010-05-10 01:22:27 +00001340 VisitExpr(E);
John McCall6ec278d2011-01-27 09:37:56 +00001341 E->GlobalNew = Record[Idx++];
Sebastian Redl1548d142012-02-16 11:35:52 +00001342 bool isArray = Record[Idx++];
Sebastian Redl2aed8b82012-02-16 12:22:20 +00001343 E->UsualArrayDeleteWantsSize = Record[Idx++];
Chris Lattner59218632010-05-10 01:22:27 +00001344 unsigned NumPlacementArgs = Record[Idx++];
Sebastian Redl2aed8b82012-02-16 12:22:20 +00001345 E->StoredInitializationStyle = Record[Idx++];
Douglas Gregor409448c2011-07-21 22:35:25 +00001346 E->setOperatorNew(ReadDeclAs<FunctionDecl>(Record, Idx));
1347 E->setOperatorDelete(ReadDeclAs<FunctionDecl>(Record, Idx));
Sebastian Redlc3632732010-10-05 15:59:54 +00001348 E->AllocatedTypeInfo = GetTypeSourceInfo(Record, Idx);
Douglas Gregor83bc2762012-02-20 16:12:14 +00001349 E->TypeIdParens = ReadSourceRange(Record, Idx);
David Blaikie53056412012-11-07 00:12:38 +00001350 E->Range = ReadSourceRange(Record, Idx);
Douglas Gregor83bc2762012-02-20 16:12:14 +00001351 E->DirectInitRange = ReadSourceRange(Record, Idx);
Chandler Carruth428edaf2010-10-25 08:47:36 +00001352
Douglas Gregor35942772011-09-09 21:34:22 +00001353 E->AllocateArgsArray(Reader.getContext(), isArray, NumPlacementArgs,
Sebastian Redl2aed8b82012-02-16 12:22:20 +00001354 E->StoredInitializationStyle != 0);
Chris Lattner59218632010-05-10 01:22:27 +00001355
1356 // Install all the subexpressions.
Chris Lattner59218632010-05-10 01:22:27 +00001357 for (CXXNewExpr::raw_arg_iterator I = E->raw_arg_begin(),e = E->raw_arg_end();
1358 I != e; ++I)
Argyrios Kyrtzidisd98a2ab2010-06-29 22:46:25 +00001359 *I = Reader.ReadSubStmt();
Chris Lattner59218632010-05-10 01:22:27 +00001360}
1361
Sebastian Redl60adf4a2010-08-18 23:56:52 +00001362void ASTStmtReader::VisitCXXDeleteExpr(CXXDeleteExpr *E) {
Argyrios Kyrtzidis95fc98c2010-06-22 17:07:59 +00001363 VisitExpr(E);
Argyrios Kyrtzidisf1b89112010-09-13 20:15:40 +00001364 E->GlobalDelete = Record[Idx++];
1365 E->ArrayForm = Record[Idx++];
Argyrios Kyrtzidis4076dac2010-09-13 20:15:54 +00001366 E->ArrayFormAsWritten = Record[Idx++];
John McCall6ec278d2011-01-27 09:37:56 +00001367 E->UsualArrayDeleteWantsSize = Record[Idx++];
Douglas Gregor409448c2011-07-21 22:35:25 +00001368 E->OperatorDelete = ReadDeclAs<FunctionDecl>(Record, Idx);
Argyrios Kyrtzidisf1b89112010-09-13 20:15:40 +00001369 E->Argument = Reader.ReadSubExpr();
Sebastian Redlc3632732010-10-05 15:59:54 +00001370 E->Loc = ReadSourceLocation(Record, Idx);
Argyrios Kyrtzidis95fc98c2010-06-22 17:07:59 +00001371}
Chris Lattnerd2598362010-05-10 00:25:06 +00001372
Sebastian Redl60adf4a2010-08-18 23:56:52 +00001373void ASTStmtReader::VisitCXXPseudoDestructorExpr(CXXPseudoDestructorExpr *E) {
Argyrios Kyrtzidisde4bd182010-06-28 09:32:03 +00001374 VisitExpr(E);
1375
Douglas Gregorf3db29f2011-02-25 18:19:59 +00001376 E->Base = Reader.ReadSubExpr();
1377 E->IsArrow = Record[Idx++];
1378 E->OperatorLoc = ReadSourceLocation(Record, Idx);
1379 E->QualifierLoc = Reader.ReadNestedNameSpecifierLoc(F, Record, Idx);
1380 E->ScopeType = GetTypeSourceInfo(Record, Idx);
1381 E->ColonColonLoc = ReadSourceLocation(Record, Idx);
1382 E->TildeLoc = ReadSourceLocation(Record, Idx);
Argyrios Kyrtzidisde4bd182010-06-28 09:32:03 +00001383
Douglas Gregor95eab172011-07-28 20:55:49 +00001384 IdentifierInfo *II = Reader.GetIdentifierInfo(F, Record, Idx);
Argyrios Kyrtzidisde4bd182010-06-28 09:32:03 +00001385 if (II)
Sebastian Redlc3632732010-10-05 15:59:54 +00001386 E->setDestroyedType(II, ReadSourceLocation(Record, Idx));
Argyrios Kyrtzidisde4bd182010-06-28 09:32:03 +00001387 else
Sebastian Redlc3632732010-10-05 15:59:54 +00001388 E->setDestroyedType(GetTypeSourceInfo(Record, Idx));
Argyrios Kyrtzidisde4bd182010-06-28 09:32:03 +00001389}
1390
John McCall4765fa02010-12-06 08:20:24 +00001391void ASTStmtReader::VisitExprWithCleanups(ExprWithCleanups *E) {
Chris Lattnerd2598362010-05-10 00:25:06 +00001392 VisitExpr(E);
John McCall80ee6e82011-11-10 05:35:25 +00001393
1394 unsigned NumObjects = Record[Idx++];
1395 assert(NumObjects == E->getNumObjects());
1396 for (unsigned i = 0; i != NumObjects; ++i)
1397 E->getObjectsBuffer()[i] = ReadDeclAs<BlockDecl>(Record, Idx);
1398
1399 E->SubExpr = Reader.ReadSubExpr();
Chris Lattner030854b2010-05-09 06:40:08 +00001400}
1401
Argyrios Kyrtzidis919e6932010-06-28 22:28:35 +00001402void
Sebastian Redl60adf4a2010-08-18 23:56:52 +00001403ASTStmtReader::VisitCXXDependentScopeMemberExpr(CXXDependentScopeMemberExpr *E){
Argyrios Kyrtzidis8dfbd8b2010-06-24 08:57:31 +00001404 VisitExpr(E);
Abramo Bagnarae4b92762012-01-27 09:46:47 +00001405
1406 if (Record[Idx++]) // HasTemplateKWAndArgsInfo
1407 ReadTemplateKWAndArgsInfo(*E->getTemplateKWAndArgsInfo(),
1408 /*NumTemplateArgs=*/Record[Idx++]);
Argyrios Kyrtzidis8dfbd8b2010-06-24 08:57:31 +00001409
Douglas Gregor7c3179c2011-02-28 18:50:33 +00001410 E->Base = Reader.ReadSubExpr();
Douglas Gregor393f2492011-07-22 00:38:23 +00001411 E->BaseType = Reader.readType(F, Record, Idx);
Douglas Gregor7c3179c2011-02-28 18:50:33 +00001412 E->IsArrow = Record[Idx++];
1413 E->OperatorLoc = ReadSourceLocation(Record, Idx);
1414 E->QualifierLoc = Reader.ReadNestedNameSpecifierLoc(F, Record, Idx);
Douglas Gregor409448c2011-07-21 22:35:25 +00001415 E->FirstQualifierFoundInScope = ReadDeclAs<NamedDecl>(Record, Idx);
Argyrios Kyrtzidis40451072010-10-15 18:21:24 +00001416 ReadDeclarationNameInfo(E->MemberNameInfo, Record, Idx);
Argyrios Kyrtzidis8dfbd8b2010-06-24 08:57:31 +00001417}
1418
Argyrios Kyrtzidis919e6932010-06-28 22:28:35 +00001419void
Sebastian Redl60adf4a2010-08-18 23:56:52 +00001420ASTStmtReader::VisitDependentScopeDeclRefExpr(DependentScopeDeclRefExpr *E) {
Argyrios Kyrtzidis12dffcd2010-06-28 09:31:56 +00001421 VisitExpr(E);
Abramo Bagnarae4b92762012-01-27 09:46:47 +00001422
1423 if (Record[Idx++]) // HasTemplateKWAndArgsInfo
1424 ReadTemplateKWAndArgsInfo(*E->getTemplateKWAndArgsInfo(),
1425 /*NumTemplateArgs=*/Record[Idx++]);
Douglas Gregor00cf3cc2011-02-25 20:49:16 +00001426
1427 E->QualifierLoc = Reader.ReadNestedNameSpecifierLoc(F, Record, Idx);
Argyrios Kyrtzidis40451072010-10-15 18:21:24 +00001428 ReadDeclarationNameInfo(E->NameInfo, Record, Idx);
Argyrios Kyrtzidis12dffcd2010-06-28 09:31:56 +00001429}
1430
Argyrios Kyrtzidis919e6932010-06-28 22:28:35 +00001431void
Sebastian Redl60adf4a2010-08-18 23:56:52 +00001432ASTStmtReader::VisitCXXUnresolvedConstructExpr(CXXUnresolvedConstructExpr *E) {
Argyrios Kyrtzidis8dfbd8b2010-06-24 08:57:31 +00001433 VisitExpr(E);
1434 assert(Record[Idx] == E->arg_size() && "Read wrong record during creation ?");
1435 ++Idx; // NumArgs;
1436 for (unsigned I = 0, N = E->arg_size(); I != N; ++I)
Argyrios Kyrtzidisd98a2ab2010-06-29 22:46:25 +00001437 E->setArg(I, Reader.ReadSubExpr());
Sebastian Redlc3632732010-10-05 15:59:54 +00001438 E->Type = GetTypeSourceInfo(Record, Idx);
1439 E->setLParenLoc(ReadSourceLocation(Record, Idx));
1440 E->setRParenLoc(ReadSourceLocation(Record, Idx));
Argyrios Kyrtzidis8dfbd8b2010-06-24 08:57:31 +00001441}
1442
Sebastian Redl60adf4a2010-08-18 23:56:52 +00001443void ASTStmtReader::VisitOverloadExpr(OverloadExpr *E) {
Argyrios Kyrtzidisa77eb082010-06-25 09:03:26 +00001444 VisitExpr(E);
Abramo Bagnarae4b92762012-01-27 09:46:47 +00001445
1446 if (Record[Idx++]) // HasTemplateKWAndArgsInfo
1447 ReadTemplateKWAndArgsInfo(*E->getTemplateKWAndArgsInfo(),
1448 /*NumTemplateArgs=*/Record[Idx++]);
Argyrios Kyrtzidisa77eb082010-06-25 09:03:26 +00001449
1450 unsigned NumDecls = Record[Idx++];
1451 UnresolvedSet<8> Decls;
1452 for (unsigned i = 0; i != NumDecls; ++i) {
Douglas Gregor409448c2011-07-21 22:35:25 +00001453 NamedDecl *D = ReadDeclAs<NamedDecl>(Record, Idx);
Argyrios Kyrtzidisa77eb082010-06-25 09:03:26 +00001454 AccessSpecifier AS = (AccessSpecifier)Record[Idx++];
1455 Decls.addDecl(D, AS);
1456 }
Douglas Gregor35942772011-09-09 21:34:22 +00001457 E->initializeResults(Reader.getContext(), Decls.begin(), Decls.end());
Argyrios Kyrtzidisa77eb082010-06-25 09:03:26 +00001458
Argyrios Kyrtzidis40451072010-10-15 18:21:24 +00001459 ReadDeclarationNameInfo(E->NameInfo, Record, Idx);
Douglas Gregor4c9be892011-02-28 20:01:57 +00001460 E->QualifierLoc = Reader.ReadNestedNameSpecifierLoc(F, Record, Idx);
Argyrios Kyrtzidisa77eb082010-06-25 09:03:26 +00001461}
1462
Sebastian Redl60adf4a2010-08-18 23:56:52 +00001463void ASTStmtReader::VisitUnresolvedMemberExpr(UnresolvedMemberExpr *E) {
Argyrios Kyrtzidis919e6932010-06-28 22:28:35 +00001464 VisitOverloadExpr(E);
Douglas Gregor4c9be892011-02-28 20:01:57 +00001465 E->IsArrow = Record[Idx++];
1466 E->HasUnresolvedUsing = Record[Idx++];
1467 E->Base = Reader.ReadSubExpr();
Douglas Gregor393f2492011-07-22 00:38:23 +00001468 E->BaseType = Reader.readType(F, Record, Idx);
Douglas Gregor4c9be892011-02-28 20:01:57 +00001469 E->OperatorLoc = ReadSourceLocation(Record, Idx);
Argyrios Kyrtzidisa77eb082010-06-25 09:03:26 +00001470}
1471
Sebastian Redl60adf4a2010-08-18 23:56:52 +00001472void ASTStmtReader::VisitUnresolvedLookupExpr(UnresolvedLookupExpr *E) {
Argyrios Kyrtzidis919e6932010-06-28 22:28:35 +00001473 VisitOverloadExpr(E);
Douglas Gregor4c9be892011-02-28 20:01:57 +00001474 E->RequiresADL = Record[Idx++];
1475 E->Overloaded = Record[Idx++];
Douglas Gregor409448c2011-07-21 22:35:25 +00001476 E->NamingClass = ReadDeclAs<CXXRecordDecl>(Record, Idx);
Argyrios Kyrtzidisbd65bb52010-06-25 09:03:34 +00001477}
1478
Sebastian Redl60adf4a2010-08-18 23:56:52 +00001479void ASTStmtReader::VisitUnaryTypeTraitExpr(UnaryTypeTraitExpr *E) {
Argyrios Kyrtzidis6d00c132010-07-10 11:46:15 +00001480 VisitExpr(E);
1481 E->UTT = (UnaryTypeTrait)Record[Idx++];
Sebastian Redl0dfd8482010-09-13 20:56:31 +00001482 E->Value = (bool)Record[Idx++];
Sebastian Redlc3632732010-10-05 15:59:54 +00001483 SourceRange Range = ReadSourceRange(Record, Idx);
Argyrios Kyrtzidis6d00c132010-07-10 11:46:15 +00001484 E->Loc = Range.getBegin();
1485 E->RParen = Range.getEnd();
Sebastian Redlc3632732010-10-05 15:59:54 +00001486 E->QueriedType = GetTypeSourceInfo(Record, Idx);
Argyrios Kyrtzidis6d00c132010-07-10 11:46:15 +00001487}
1488
Francois Pichet6ad6f282010-12-07 00:08:36 +00001489void ASTStmtReader::VisitBinaryTypeTraitExpr(BinaryTypeTraitExpr *E) {
1490 VisitExpr(E);
1491 E->BTT = (BinaryTypeTrait)Record[Idx++];
1492 E->Value = (bool)Record[Idx++];
1493 SourceRange Range = ReadSourceRange(Record, Idx);
1494 E->Loc = Range.getBegin();
1495 E->RParen = Range.getEnd();
1496 E->LhsType = GetTypeSourceInfo(Record, Idx);
1497 E->RhsType = GetTypeSourceInfo(Record, Idx);
1498}
1499
Douglas Gregor4ca8ac22012-02-24 07:38:34 +00001500void ASTStmtReader::VisitTypeTraitExpr(TypeTraitExpr *E) {
1501 VisitExpr(E);
1502 E->TypeTraitExprBits.NumArgs = Record[Idx++];
1503 E->TypeTraitExprBits.Kind = Record[Idx++];
1504 E->TypeTraitExprBits.Value = Record[Idx++];
1505
1506 TypeSourceInfo **Args = E->getTypeSourceInfos();
1507 for (unsigned I = 0, N = E->getNumArgs(); I != N; ++I)
1508 Args[I] = GetTypeSourceInfo(Record, Idx);
1509}
1510
John Wiegley21ff2e52011-04-28 00:16:57 +00001511void ASTStmtReader::VisitArrayTypeTraitExpr(ArrayTypeTraitExpr *E) {
1512 VisitExpr(E);
1513 E->ATT = (ArrayTypeTrait)Record[Idx++];
1514 E->Value = (unsigned int)Record[Idx++];
1515 SourceRange Range = ReadSourceRange(Record, Idx);
1516 E->Loc = Range.getBegin();
1517 E->RParen = Range.getEnd();
1518 E->QueriedType = GetTypeSourceInfo(Record, Idx);
1519}
1520
John Wiegley55262202011-04-25 06:54:41 +00001521void ASTStmtReader::VisitExpressionTraitExpr(ExpressionTraitExpr *E) {
1522 VisitExpr(E);
1523 E->ET = (ExpressionTrait)Record[Idx++];
1524 E->Value = (bool)Record[Idx++];
1525 SourceRange Range = ReadSourceRange(Record, Idx);
1526 E->QueriedExpression = Reader.ReadSubExpr();
1527 E->Loc = Range.getBegin();
1528 E->RParen = Range.getEnd();
1529}
1530
Sebastian Redl6b219d02010-09-10 20:55:54 +00001531void ASTStmtReader::VisitCXXNoexceptExpr(CXXNoexceptExpr *E) {
1532 VisitExpr(E);
Sebastian Redl5221d8f2010-09-10 22:34:40 +00001533 E->Value = (bool)Record[Idx++];
Sebastian Redlc3632732010-10-05 15:59:54 +00001534 E->Range = ReadSourceRange(Record, Idx);
Sebastian Redl5221d8f2010-09-10 22:34:40 +00001535 E->Operand = Reader.ReadSubExpr();
Sebastian Redl6b219d02010-09-10 20:55:54 +00001536}
1537
Douglas Gregorbe230c32011-01-03 17:17:50 +00001538void ASTStmtReader::VisitPackExpansionExpr(PackExpansionExpr *E) {
1539 VisitExpr(E);
1540 E->EllipsisLoc = ReadSourceLocation(Record, Idx);
Douglas Gregor67fd1252011-01-14 21:20:45 +00001541 E->NumExpansions = Record[Idx++];
Douglas Gregorbe230c32011-01-03 17:17:50 +00001542 E->Pattern = Reader.ReadSubExpr();
1543}
1544
Douglas Gregoree8aff02011-01-04 17:33:58 +00001545void ASTStmtReader::VisitSizeOfPackExpr(SizeOfPackExpr *E) {
1546 VisitExpr(E);
1547 E->OperatorLoc = ReadSourceLocation(Record, Idx);
1548 E->PackLoc = ReadSourceLocation(Record, Idx);
1549 E->RParenLoc = ReadSourceLocation(Record, Idx);
1550 E->Length = Record[Idx++];
Douglas Gregor409448c2011-07-21 22:35:25 +00001551 E->Pack = ReadDeclAs<NamedDecl>(Record, Idx);
Douglas Gregoree8aff02011-01-04 17:33:58 +00001552}
1553
John McCall7110fd62011-07-15 07:00:14 +00001554void ASTStmtReader::VisitSubstNonTypeTemplateParmExpr(
1555 SubstNonTypeTemplateParmExpr *E) {
1556 VisitExpr(E);
Douglas Gregor409448c2011-07-21 22:35:25 +00001557 E->Param = ReadDeclAs<NonTypeTemplateParmDecl>(Record, Idx);
John McCall7110fd62011-07-15 07:00:14 +00001558 E->NameLoc = ReadSourceLocation(Record, Idx);
1559 E->Replacement = Reader.ReadSubExpr();
1560}
1561
Douglas Gregorc7793c72011-01-15 01:15:58 +00001562void ASTStmtReader::VisitSubstNonTypeTemplateParmPackExpr(
1563 SubstNonTypeTemplateParmPackExpr *E) {
1564 VisitExpr(E);
Douglas Gregor409448c2011-07-21 22:35:25 +00001565 E->Param = ReadDeclAs<NonTypeTemplateParmDecl>(Record, Idx);
Douglas Gregorc7793c72011-01-15 01:15:58 +00001566 TemplateArgument ArgPack = Reader.ReadTemplateArgument(F, Record, Idx);
1567 if (ArgPack.getKind() != TemplateArgument::Pack)
1568 return;
1569
1570 E->Arguments = ArgPack.pack_begin();
1571 E->NumArguments = ArgPack.pack_size();
1572 E->NameLoc = ReadSourceLocation(Record, Idx);
1573}
1574
Richard Smith9a4db032012-09-12 00:56:43 +00001575void ASTStmtReader::VisitFunctionParmPackExpr(FunctionParmPackExpr *E) {
1576 VisitExpr(E);
1577 E->NumParameters = Record[Idx++];
1578 E->ParamPack = ReadDeclAs<ParmVarDecl>(Record, Idx);
1579 E->NameLoc = ReadSourceLocation(Record, Idx);
1580 ParmVarDecl **Parms = reinterpret_cast<ParmVarDecl**>(E+1);
1581 for (unsigned i = 0, n = E->NumParameters; i != n; ++i)
1582 Parms[i] = ReadDeclAs<ParmVarDecl>(Record, Idx);
1583}
1584
Douglas Gregor03e80032011-06-21 17:03:29 +00001585void ASTStmtReader::VisitMaterializeTemporaryExpr(MaterializeTemporaryExpr *E) {
1586 VisitExpr(E);
1587 E->Temporary = Reader.ReadSubExpr();
Richard Smith211c8dd2013-06-05 00:46:14 +00001588 E->ExtendingDecl = ReadDeclAs<ValueDecl>(Record, Idx);
Douglas Gregor03e80032011-06-21 17:03:29 +00001589}
1590
John McCall7cd7d1a2010-11-15 23:31:06 +00001591void ASTStmtReader::VisitOpaqueValueExpr(OpaqueValueExpr *E) {
1592 VisitExpr(E);
Argyrios Kyrtzidis8bc27822011-12-03 03:49:52 +00001593 E->SourceExpr = Reader.ReadSubExpr();
Douglas Gregorb608b982011-01-28 02:26:04 +00001594 E->Loc = ReadSourceLocation(Record, Idx);
John McCall7cd7d1a2010-11-15 23:31:06 +00001595}
1596
Peter Collingbournee08ce652011-02-09 21:07:24 +00001597//===----------------------------------------------------------------------===//
John McCall7110fd62011-07-15 07:00:14 +00001598// Microsoft Expressions and Statements
1599//===----------------------------------------------------------------------===//
John McCall76da55d2013-04-16 07:28:30 +00001600void ASTStmtReader::VisitMSPropertyRefExpr(MSPropertyRefExpr *E) {
1601 VisitExpr(E);
1602 E->IsArrow = (Record[Idx++] != 0);
1603 E->BaseExpr = Reader.ReadSubExpr();
1604 E->QualifierLoc = Reader.ReadNestedNameSpecifierLoc(F, Record, Idx);
1605 E->MemberLoc = ReadSourceLocation(Record, Idx);
1606 E->TheDecl = ReadDeclAs<MSPropertyDecl>(Record, Idx);
1607}
1608
John McCall7110fd62011-07-15 07:00:14 +00001609void ASTStmtReader::VisitCXXUuidofExpr(CXXUuidofExpr *E) {
1610 VisitExpr(E);
1611 E->setSourceRange(ReadSourceRange(Record, Idx));
1612 if (E->isTypeOperand()) { // __uuidof(ComType)
1613 E->setTypeOperandSourceInfo(
1614 GetTypeSourceInfo(Record, Idx));
1615 return;
1616 }
1617
1618 // __uuidof(expr)
1619 E->setExprOperand(Reader.ReadSubExpr());
1620}
1621
1622void ASTStmtReader::VisitSEHExceptStmt(SEHExceptStmt *S) {
1623 VisitStmt(S);
1624 S->Loc = ReadSourceLocation(Record, Idx);
1625 S->Children[SEHExceptStmt::FILTER_EXPR] = Reader.ReadSubStmt();
1626 S->Children[SEHExceptStmt::BLOCK] = Reader.ReadSubStmt();
1627}
1628
1629void ASTStmtReader::VisitSEHFinallyStmt(SEHFinallyStmt *S) {
1630 VisitStmt(S);
1631 S->Loc = ReadSourceLocation(Record, Idx);
1632 S->Block = Reader.ReadSubStmt();
1633}
1634
1635void ASTStmtReader::VisitSEHTryStmt(SEHTryStmt *S) {
1636 VisitStmt(S);
1637 S->IsCXXTry = Record[Idx++];
1638 S->TryLoc = ReadSourceLocation(Record, Idx);
1639 S->Children[SEHTryStmt::TRY] = Reader.ReadSubStmt();
1640 S->Children[SEHTryStmt::HANDLER] = Reader.ReadSubStmt();
1641}
1642
1643//===----------------------------------------------------------------------===//
Peter Collingbournee08ce652011-02-09 21:07:24 +00001644// CUDA Expressions and Statements
1645//===----------------------------------------------------------------------===//
1646
1647void ASTStmtReader::VisitCUDAKernelCallExpr(CUDAKernelCallExpr *E) {
1648 VisitCallExpr(E);
1649 E->setConfig(cast<CallExpr>(Reader.ReadSubExpr()));
1650}
1651
John McCall7110fd62011-07-15 07:00:14 +00001652//===----------------------------------------------------------------------===//
1653// OpenCL Expressions and Statements.
1654//===----------------------------------------------------------------------===//
1655void ASTStmtReader::VisitAsTypeExpr(AsTypeExpr *E) {
1656 VisitExpr(E);
1657 E->BuiltinLoc = ReadSourceLocation(Record, Idx);
1658 E->RParenLoc = ReadSourceLocation(Record, Idx);
1659 E->SrcExpr = Reader.ReadSubExpr();
1660}
1661
1662//===----------------------------------------------------------------------===//
Alexey Bataev4fa7eab2013-07-19 03:13:43 +00001663// OpenMP Clauses.
1664//===----------------------------------------------------------------------===//
1665
1666namespace clang {
1667class OMPClauseReader : public OMPClauseVisitor<OMPClauseReader> {
1668 ASTStmtReader *Reader;
1669 ASTContext &Context;
1670 const ASTReader::RecordData &Record;
1671 unsigned &Idx;
1672public:
1673 OMPClauseReader(ASTStmtReader *R, ASTContext &C,
1674 const ASTReader::RecordData &Record, unsigned &Idx)
1675 : Reader(R), Context(C), Record(Record), Idx(Idx) { }
1676#define OPENMP_CLAUSE(Name, Class) \
1677 void Visit##Class(Class *S);
1678#include "clang/Basic/OpenMPKinds.def"
1679 OMPClause *readClause();
1680};
1681}
1682
1683OMPClause *OMPClauseReader::readClause() {
1684 OMPClause *C;
1685 switch (Record[Idx++]) {
1686 case OMPC_default:
1687 C = new (Context) OMPDefaultClause();
1688 break;
1689 case OMPC_private:
1690 C = OMPPrivateClause::CreateEmpty(Context, Record[Idx++]);
1691 break;
Alexey Bataev0c018352013-09-06 18:03:48 +00001692 case OMPC_shared:
1693 C = OMPSharedClause::CreateEmpty(Context, Record[Idx++]);
1694 break;
Alexey Bataev4fa7eab2013-07-19 03:13:43 +00001695 }
1696 Visit(C);
1697 C->setLocStart(Reader->ReadSourceLocation(Record, Idx));
1698 C->setLocEnd(Reader->ReadSourceLocation(Record, Idx));
1699
1700 return C;
1701}
1702
1703void OMPClauseReader::VisitOMPDefaultClause(OMPDefaultClause *C) {
1704 C->setDefaultKind(
1705 static_cast<OpenMPDefaultClauseKind>(Record[Idx++]));
1706 C->setLParenLoc(Reader->ReadSourceLocation(Record, Idx));
1707 C->setDefaultKindKwLoc(Reader->ReadSourceLocation(Record, Idx));
1708}
1709
1710void OMPClauseReader::VisitOMPPrivateClause(OMPPrivateClause *C) {
1711 C->setLParenLoc(Reader->ReadSourceLocation(Record, Idx));
1712 unsigned NumVars = C->varlist_size();
1713 SmallVector<Expr *, 16> Vars;
1714 Vars.reserve(NumVars);
1715 for (unsigned i = 0; i != NumVars; ++i)
1716 Vars.push_back(Reader->Reader.ReadSubExpr());
1717 C->setVarRefs(Vars);
1718}
1719
Alexey Bataev0c018352013-09-06 18:03:48 +00001720void OMPClauseReader::VisitOMPSharedClause(OMPSharedClause *C) {
1721 C->setLParenLoc(Reader->ReadSourceLocation(Record, Idx));
1722 unsigned NumVars = C->varlist_size();
1723 SmallVector<Expr *, 16> Vars;
1724 Vars.reserve(NumVars);
1725 for (unsigned i = 0; i != NumVars; ++i)
1726 Vars.push_back(Reader->Reader.ReadSubExpr());
1727 C->setVarRefs(Vars);
1728}
1729
Alexey Bataev4fa7eab2013-07-19 03:13:43 +00001730//===----------------------------------------------------------------------===//
1731// OpenMP Directives.
1732//===----------------------------------------------------------------------===//
1733void ASTStmtReader::VisitOMPExecutableDirective(OMPExecutableDirective *E) {
1734 VisitStmt(E);
1735 ++Idx;
1736 E->setLocStart(ReadSourceLocation(Record, Idx));
1737 E->setLocEnd(ReadSourceLocation(Record, Idx));
1738 OMPClauseReader ClauseReader(this, Reader.getContext(), Record, Idx);
1739 SmallVector<OMPClause *, 5> Clauses;
1740 for (unsigned i = 0; i < E->getNumClauses(); ++i)
1741 Clauses.push_back(ClauseReader.readClause());
1742 E->setClauses(Clauses);
1743 E->setAssociatedStmt(Reader.ReadSubStmt());
1744}
1745
1746void ASTStmtReader::VisitOMPParallelDirective(OMPParallelDirective *D) {
1747 VisitOMPExecutableDirective(D);
1748}
1749
1750//===----------------------------------------------------------------------===//
John McCall7110fd62011-07-15 07:00:14 +00001751// ASTReader Implementation
1752//===----------------------------------------------------------------------===//
1753
Douglas Gregor1a4761e2011-11-30 23:21:26 +00001754Stmt *ASTReader::ReadStmt(ModuleFile &F) {
Argyrios Kyrtzidis919e6932010-06-28 22:28:35 +00001755 switch (ReadingKind) {
Richard Smithafb90df2013-07-31 00:26:46 +00001756 case Read_None:
1757 llvm_unreachable("should not call this when not reading anything");
Argyrios Kyrtzidis919e6932010-06-28 22:28:35 +00001758 case Read_Decl:
1759 case Read_Type:
Sebastian Redlc3632732010-10-05 15:59:54 +00001760 return ReadStmtFromStream(F);
Argyrios Kyrtzidis919e6932010-06-28 22:28:35 +00001761 case Read_Stmt:
Argyrios Kyrtzidisd98a2ab2010-06-29 22:46:25 +00001762 return ReadSubStmt();
Argyrios Kyrtzidis919e6932010-06-28 22:28:35 +00001763 }
1764
1765 llvm_unreachable("ReadingKind not set ?");
Argyrios Kyrtzidis919e6932010-06-28 22:28:35 +00001766}
1767
Douglas Gregor1a4761e2011-11-30 23:21:26 +00001768Expr *ASTReader::ReadExpr(ModuleFile &F) {
Sebastian Redlc3632732010-10-05 15:59:54 +00001769 return cast_or_null<Expr>(ReadStmt(F));
Argyrios Kyrtzidis919e6932010-06-28 22:28:35 +00001770}
Chris Lattner030854b2010-05-09 06:40:08 +00001771
Sebastian Redlc43b54c2010-08-18 23:56:43 +00001772Expr *ASTReader::ReadSubExpr() {
Argyrios Kyrtzidisd98a2ab2010-06-29 22:46:25 +00001773 return cast_or_null<Expr>(ReadSubStmt());
1774}
1775
Chris Lattner52e97d12009-04-27 05:41:06 +00001776// Within the bitstream, expressions are stored in Reverse Polish
1777// Notation, with each of the subexpressions preceding the
Argyrios Kyrtzidis919e6932010-06-28 22:28:35 +00001778// expression they are stored in. Subexpressions are stored from last to first.
1779// To evaluate expressions, we continue reading expressions and placing them on
1780// the stack, with expressions having operands removing those operands from the
Chris Lattner52e97d12009-04-27 05:41:06 +00001781// stack. Evaluation terminates when we see a STMT_STOP record, and
1782// the single remaining expression on the stack is our result.
Douglas Gregor1a4761e2011-11-30 23:21:26 +00001783Stmt *ASTReader::ReadStmtFromStream(ModuleFile &F) {
Argyrios Kyrtzidis919e6932010-06-28 22:28:35 +00001784
1785 ReadingKindTracker ReadingKind(Read_Stmt, *this);
Sebastian Redlc3632732010-10-05 15:59:54 +00001786 llvm::BitstreamCursor &Cursor = F.DeclsCursor;
Argyrios Kyrtzidise6f08682011-10-21 23:02:28 +00001787
1788 // Map of offset to previously deserialized stmt. The offset points
1789 /// just after the stmt record.
1790 llvm::DenseMap<uint64_t, Stmt *> StmtEntries;
Sebastian Redlc3632732010-10-05 15:59:54 +00001791
Argyrios Kyrtzidis919e6932010-06-28 22:28:35 +00001792#ifndef NDEBUG
1793 unsigned PrevNumStmts = StmtStack.size();
1794#endif
1795
Chris Lattner4c6f9522009-04-27 05:14:47 +00001796 RecordData Record;
1797 unsigned Idx;
Sebastian Redlc3632732010-10-05 15:59:54 +00001798 ASTStmtReader Reader(*this, F, Cursor, Record, Idx);
Chris Lattner4c6f9522009-04-27 05:14:47 +00001799 Stmt::EmptyShell Empty;
1800
1801 while (true) {
Chris Lattnerb3ce3572013-01-20 02:38:54 +00001802 llvm::BitstreamEntry Entry = Cursor.advanceSkippingSubblocks();
1803
1804 switch (Entry.Kind) {
1805 case llvm::BitstreamEntry::SubBlock: // Handled for us already.
1806 case llvm::BitstreamEntry::Error:
1807 Error("malformed block record in AST file");
1808 return 0;
1809 case llvm::BitstreamEntry::EndBlock:
1810 goto Done;
1811 case llvm::BitstreamEntry::Record:
1812 // The interesting case.
Chris Lattner4c6f9522009-04-27 05:14:47 +00001813 break;
1814 }
1815
Chris Lattner4c6f9522009-04-27 05:14:47 +00001816
1817 Stmt *S = 0;
1818 Idx = 0;
1819 Record.clear();
1820 bool Finished = false;
Argyrios Kyrtzidise6f08682011-10-21 23:02:28 +00001821 bool IsStmtReference = false;
Chris Lattnerb3ce3572013-01-20 02:38:54 +00001822 switch ((StmtCode)Cursor.readRecord(Entry.ID, Record)) {
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001823 case STMT_STOP:
Chris Lattner4c6f9522009-04-27 05:14:47 +00001824 Finished = true;
1825 break;
1826
Argyrios Kyrtzidise6f08682011-10-21 23:02:28 +00001827 case STMT_REF_PTR:
1828 IsStmtReference = true;
1829 assert(StmtEntries.find(Record[0]) != StmtEntries.end() &&
1830 "No stmt was recorded for this offset reference!");
1831 S = StmtEntries[Record[Idx++]];
1832 break;
1833
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001834 case STMT_NULL_PTR:
Mike Stump1eb44332009-09-09 15:08:12 +00001835 S = 0;
Chris Lattner4c6f9522009-04-27 05:14:47 +00001836 break;
1837
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001838 case STMT_NULL:
Chris Lattner4c6f9522009-04-27 05:14:47 +00001839 S = new (Context) NullStmt(Empty);
1840 break;
1841
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001842 case STMT_COMPOUND:
Chris Lattner4c6f9522009-04-27 05:14:47 +00001843 S = new (Context) CompoundStmt(Empty);
1844 break;
1845
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001846 case STMT_CASE:
Chris Lattner4c6f9522009-04-27 05:14:47 +00001847 S = new (Context) CaseStmt(Empty);
1848 break;
1849
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001850 case STMT_DEFAULT:
Chris Lattner4c6f9522009-04-27 05:14:47 +00001851 S = new (Context) DefaultStmt(Empty);
1852 break;
1853
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001854 case STMT_LABEL:
Chris Lattner4c6f9522009-04-27 05:14:47 +00001855 S = new (Context) LabelStmt(Empty);
1856 break;
1857
Richard Smith534986f2012-04-14 00:33:13 +00001858 case STMT_ATTRIBUTED:
Alexander Kornienko49908902012-07-09 10:04:07 +00001859 S = AttributedStmt::CreateEmpty(
1860 Context,
1861 /*NumAttrs*/Record[ASTStmtReader::NumStmtFields]);
Richard Smith534986f2012-04-14 00:33:13 +00001862 break;
1863
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001864 case STMT_IF:
Chris Lattner4c6f9522009-04-27 05:14:47 +00001865 S = new (Context) IfStmt(Empty);
1866 break;
1867
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001868 case STMT_SWITCH:
Chris Lattner4c6f9522009-04-27 05:14:47 +00001869 S = new (Context) SwitchStmt(Empty);
1870 break;
1871
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001872 case STMT_WHILE:
Chris Lattner4c6f9522009-04-27 05:14:47 +00001873 S = new (Context) WhileStmt(Empty);
1874 break;
1875
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001876 case STMT_DO:
Chris Lattner4c6f9522009-04-27 05:14:47 +00001877 S = new (Context) DoStmt(Empty);
1878 break;
Mike Stump1eb44332009-09-09 15:08:12 +00001879
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001880 case STMT_FOR:
Chris Lattner4c6f9522009-04-27 05:14:47 +00001881 S = new (Context) ForStmt(Empty);
1882 break;
1883
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001884 case STMT_GOTO:
Chris Lattner4c6f9522009-04-27 05:14:47 +00001885 S = new (Context) GotoStmt(Empty);
1886 break;
Mike Stump1eb44332009-09-09 15:08:12 +00001887
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001888 case STMT_INDIRECT_GOTO:
Chris Lattner4c6f9522009-04-27 05:14:47 +00001889 S = new (Context) IndirectGotoStmt(Empty);
1890 break;
1891
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001892 case STMT_CONTINUE:
Chris Lattner4c6f9522009-04-27 05:14:47 +00001893 S = new (Context) ContinueStmt(Empty);
1894 break;
1895
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001896 case STMT_BREAK:
Chris Lattner4c6f9522009-04-27 05:14:47 +00001897 S = new (Context) BreakStmt(Empty);
1898 break;
1899
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001900 case STMT_RETURN:
Chris Lattner4c6f9522009-04-27 05:14:47 +00001901 S = new (Context) ReturnStmt(Empty);
1902 break;
1903
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001904 case STMT_DECL:
Chris Lattner4c6f9522009-04-27 05:14:47 +00001905 S = new (Context) DeclStmt(Empty);
1906 break;
1907
Chad Rosierdf5faf52012-08-25 00:11:56 +00001908 case STMT_GCCASM:
1909 S = new (Context) GCCAsmStmt(Empty);
Chris Lattner4c6f9522009-04-27 05:14:47 +00001910 break;
1911
Chad Rosiercd518a02012-08-24 23:51:02 +00001912 case STMT_MSASM:
1913 S = new (Context) MSAsmStmt(Empty);
1914 break;
1915
Tareq A. Siraj051303c2013-04-16 18:53:08 +00001916 case STMT_CAPTURED:
Ben Langmuirdc5be4f2013-05-03 19:20:19 +00001917 S = CapturedStmt::CreateDeserialized(Context,
Alexey Bataev4fa7eab2013-07-19 03:13:43 +00001918 Record[ASTStmtReader::NumStmtFields]);
Tareq A. Siraj051303c2013-04-16 18:53:08 +00001919 break;
1920
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001921 case EXPR_PREDEFINED:
Chris Lattner4c6f9522009-04-27 05:14:47 +00001922 S = new (Context) PredefinedExpr(Empty);
1923 break;
Mike Stump1eb44332009-09-09 15:08:12 +00001924
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001925 case EXPR_DECL_REF:
Chandler Carruth3aa81402011-05-01 23:48:14 +00001926 S = DeclRefExpr::CreateEmpty(
Douglas Gregor35942772011-09-09 21:34:22 +00001927 Context,
Chandler Carruth3aa81402011-05-01 23:48:14 +00001928 /*HasQualifier=*/Record[ASTStmtReader::NumExprFields],
1929 /*HasFoundDecl=*/Record[ASTStmtReader::NumExprFields + 1],
Abramo Bagnarae4b92762012-01-27 09:46:47 +00001930 /*HasTemplateKWAndArgsInfo=*/Record[ASTStmtReader::NumExprFields + 2],
Chandler Carruth3aa81402011-05-01 23:48:14 +00001931 /*NumTemplateArgs=*/Record[ASTStmtReader::NumExprFields + 2] ?
John McCallf4b88a42012-03-10 09:33:50 +00001932 Record[ASTStmtReader::NumExprFields + 5] : 0);
Chris Lattner4c6f9522009-04-27 05:14:47 +00001933 break;
Mike Stump1eb44332009-09-09 15:08:12 +00001934
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001935 case EXPR_INTEGER_LITERAL:
Douglas Gregor35942772011-09-09 21:34:22 +00001936 S = IntegerLiteral::Create(Context, Empty);
Chris Lattner4c6f9522009-04-27 05:14:47 +00001937 break;
Mike Stump1eb44332009-09-09 15:08:12 +00001938
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001939 case EXPR_FLOATING_LITERAL:
Douglas Gregor35942772011-09-09 21:34:22 +00001940 S = FloatingLiteral::Create(Context, Empty);
Chris Lattner4c6f9522009-04-27 05:14:47 +00001941 break;
Mike Stump1eb44332009-09-09 15:08:12 +00001942
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001943 case EXPR_IMAGINARY_LITERAL:
Chris Lattner4c6f9522009-04-27 05:14:47 +00001944 S = new (Context) ImaginaryLiteral(Empty);
1945 break;
1946
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001947 case EXPR_STRING_LITERAL:
Douglas Gregor35942772011-09-09 21:34:22 +00001948 S = StringLiteral::CreateEmpty(Context,
Sebastian Redl60adf4a2010-08-18 23:56:52 +00001949 Record[ASTStmtReader::NumExprFields + 1]);
Chris Lattner4c6f9522009-04-27 05:14:47 +00001950 break;
1951
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001952 case EXPR_CHARACTER_LITERAL:
Chris Lattner4c6f9522009-04-27 05:14:47 +00001953 S = new (Context) CharacterLiteral(Empty);
1954 break;
1955
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001956 case EXPR_PAREN:
Chris Lattner4c6f9522009-04-27 05:14:47 +00001957 S = new (Context) ParenExpr(Empty);
1958 break;
1959
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001960 case EXPR_PAREN_LIST:
Argyrios Kyrtzidis37bdfe22010-06-30 08:49:18 +00001961 S = new (Context) ParenListExpr(Empty);
1962 break;
1963
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001964 case EXPR_UNARY_OPERATOR:
Chris Lattner4c6f9522009-04-27 05:14:47 +00001965 S = new (Context) UnaryOperator(Empty);
1966 break;
1967
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001968 case EXPR_OFFSETOF:
Douglas Gregor35942772011-09-09 21:34:22 +00001969 S = OffsetOfExpr::CreateEmpty(Context,
Sebastian Redl60adf4a2010-08-18 23:56:52 +00001970 Record[ASTStmtReader::NumExprFields],
1971 Record[ASTStmtReader::NumExprFields + 1]);
Douglas Gregor8ecdb652010-04-28 22:16:22 +00001972 break;
1973
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001974 case EXPR_SIZEOF_ALIGN_OF:
Peter Collingbournef4e3cfb2011-03-11 19:24:49 +00001975 S = new (Context) UnaryExprOrTypeTraitExpr(Empty);
Chris Lattner4c6f9522009-04-27 05:14:47 +00001976 break;
1977
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001978 case EXPR_ARRAY_SUBSCRIPT:
Chris Lattner4c6f9522009-04-27 05:14:47 +00001979 S = new (Context) ArraySubscriptExpr(Empty);
1980 break;
1981
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001982 case EXPR_CALL:
Douglas Gregor35942772011-09-09 21:34:22 +00001983 S = new (Context) CallExpr(Context, Stmt::CallExprClass, Empty);
Chris Lattner4c6f9522009-04-27 05:14:47 +00001984 break;
1985
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001986 case EXPR_MEMBER: {
Argyrios Kyrtzidis663e3802010-07-08 13:09:47 +00001987 // We load everything here and fully initialize it at creation.
1988 // That way we can use MemberExpr::Create and don't have to duplicate its
1989 // logic with a MemberExpr::CreateEmpty.
1990
1991 assert(Idx == 0);
Douglas Gregor40d96a62011-02-28 21:54:11 +00001992 NestedNameSpecifierLoc QualifierLoc;
Argyrios Kyrtzidis663e3802010-07-08 13:09:47 +00001993 if (Record[Idx++]) { // HasQualifier.
Douglas Gregor40d96a62011-02-28 21:54:11 +00001994 QualifierLoc = ReadNestedNameSpecifierLoc(F, Record, Idx);
Argyrios Kyrtzidis663e3802010-07-08 13:09:47 +00001995 }
1996
Abramo Bagnarae4b92762012-01-27 09:46:47 +00001997 SourceLocation TemplateKWLoc;
Argyrios Kyrtzidis663e3802010-07-08 13:09:47 +00001998 TemplateArgumentListInfo ArgInfo;
Abramo Bagnarae4b92762012-01-27 09:46:47 +00001999 bool HasTemplateKWAndArgsInfo = Record[Idx++];
2000 if (HasTemplateKWAndArgsInfo) {
2001 TemplateKWLoc = ReadSourceLocation(F, Record, Idx);
Douglas Gregordef03542011-02-04 12:01:24 +00002002 unsigned NumTemplateArgs = Record[Idx++];
Sebastian Redlc3632732010-10-05 15:59:54 +00002003 ArgInfo.setLAngleLoc(ReadSourceLocation(F, Record, Idx));
2004 ArgInfo.setRAngleLoc(ReadSourceLocation(F, Record, Idx));
Argyrios Kyrtzidis663e3802010-07-08 13:09:47 +00002005 for (unsigned i = 0; i != NumTemplateArgs; ++i)
Sebastian Redlc3632732010-10-05 15:59:54 +00002006 ArgInfo.addArgument(ReadTemplateArgumentLoc(F, Record, Idx));
Argyrios Kyrtzidis663e3802010-07-08 13:09:47 +00002007 }
Abramo Bagnara7cc58b42011-10-05 07:56:41 +00002008
2009 bool HadMultipleCandidates = Record[Idx++];
2010
Douglas Gregor409448c2011-07-21 22:35:25 +00002011 NamedDecl *FoundD = ReadDeclAs<NamedDecl>(F, Record, Idx);
Argyrios Kyrtzidis663e3802010-07-08 13:09:47 +00002012 AccessSpecifier AS = (AccessSpecifier)Record[Idx++];
2013 DeclAccessPair FoundDecl = DeclAccessPair::make(FoundD, AS);
2014
Douglas Gregor393f2492011-07-22 00:38:23 +00002015 QualType T = readType(F, Record, Idx);
John McCallf89e55a2010-11-18 06:31:45 +00002016 ExprValueKind VK = static_cast<ExprValueKind>(Record[Idx++]);
2017 ExprObjectKind OK = static_cast<ExprObjectKind>(Record[Idx++]);
Argyrios Kyrtzidis663e3802010-07-08 13:09:47 +00002018 Expr *Base = ReadSubExpr();
Douglas Gregor409448c2011-07-21 22:35:25 +00002019 ValueDecl *MemberD = ReadDeclAs<ValueDecl>(F, Record, Idx);
Sebastian Redlc3632732010-10-05 15:59:54 +00002020 SourceLocation MemberLoc = ReadSourceLocation(F, Record, Idx);
Abramo Bagnara25777432010-08-11 22:01:17 +00002021 DeclarationNameInfo MemberNameInfo(MemberD->getDeclName(), MemberLoc);
Argyrios Kyrtzidis663e3802010-07-08 13:09:47 +00002022 bool IsArrow = Record[Idx++];
2023
Douglas Gregor35942772011-09-09 21:34:22 +00002024 S = MemberExpr::Create(Context, Base, IsArrow, QualifierLoc,
Abramo Bagnarae4b92762012-01-27 09:46:47 +00002025 TemplateKWLoc, MemberD, FoundDecl, MemberNameInfo,
2026 HasTemplateKWAndArgsInfo ? &ArgInfo : 0,
2027 T, VK, OK);
Argyrios Kyrtzidis40451072010-10-15 18:21:24 +00002028 ReadDeclarationNameLoc(F, cast<MemberExpr>(S)->MemberDNLoc,
2029 MemberD->getDeclName(), Record, Idx);
Abramo Bagnara7cc58b42011-10-05 07:56:41 +00002030 if (HadMultipleCandidates)
2031 cast<MemberExpr>(S)->setHadMultipleCandidates(true);
Chris Lattner4c6f9522009-04-27 05:14:47 +00002032 break;
Argyrios Kyrtzidis663e3802010-07-08 13:09:47 +00002033 }
Chris Lattner4c6f9522009-04-27 05:14:47 +00002034
Sebastian Redl8538e8d2010-08-18 23:57:32 +00002035 case EXPR_BINARY_OPERATOR:
Chris Lattner4c6f9522009-04-27 05:14:47 +00002036 S = new (Context) BinaryOperator(Empty);
2037 break;
2038
Sebastian Redl8538e8d2010-08-18 23:57:32 +00002039 case EXPR_COMPOUND_ASSIGN_OPERATOR:
Chris Lattner4c6f9522009-04-27 05:14:47 +00002040 S = new (Context) CompoundAssignOperator(Empty);
2041 break;
2042
Sebastian Redl8538e8d2010-08-18 23:57:32 +00002043 case EXPR_CONDITIONAL_OPERATOR:
Chris Lattner4c6f9522009-04-27 05:14:47 +00002044 S = new (Context) ConditionalOperator(Empty);
2045 break;
2046
John McCall56ca35d2011-02-17 10:25:35 +00002047 case EXPR_BINARY_CONDITIONAL_OPERATOR:
2048 S = new (Context) BinaryConditionalOperator(Empty);
2049 break;
2050
Sebastian Redl8538e8d2010-08-18 23:57:32 +00002051 case EXPR_IMPLICIT_CAST:
Douglas Gregor35942772011-09-09 21:34:22 +00002052 S = ImplicitCastExpr::CreateEmpty(Context,
Sebastian Redl60adf4a2010-08-18 23:56:52 +00002053 /*PathSize*/ Record[ASTStmtReader::NumExprFields]);
Chris Lattner4c6f9522009-04-27 05:14:47 +00002054 break;
2055
Sebastian Redl8538e8d2010-08-18 23:57:32 +00002056 case EXPR_CSTYLE_CAST:
Douglas Gregor35942772011-09-09 21:34:22 +00002057 S = CStyleCastExpr::CreateEmpty(Context,
Sebastian Redl60adf4a2010-08-18 23:56:52 +00002058 /*PathSize*/ Record[ASTStmtReader::NumExprFields]);
Chris Lattner4c6f9522009-04-27 05:14:47 +00002059 break;
2060
Sebastian Redl8538e8d2010-08-18 23:57:32 +00002061 case EXPR_COMPOUND_LITERAL:
Chris Lattner4c6f9522009-04-27 05:14:47 +00002062 S = new (Context) CompoundLiteralExpr(Empty);
2063 break;
2064
Sebastian Redl8538e8d2010-08-18 23:57:32 +00002065 case EXPR_EXT_VECTOR_ELEMENT:
Chris Lattner4c6f9522009-04-27 05:14:47 +00002066 S = new (Context) ExtVectorElementExpr(Empty);
2067 break;
2068
Sebastian Redl8538e8d2010-08-18 23:57:32 +00002069 case EXPR_INIT_LIST:
Argyrios Kyrtzidis2a82ca22012-11-28 03:56:16 +00002070 S = new (Context) InitListExpr(Empty);
Chris Lattner4c6f9522009-04-27 05:14:47 +00002071 break;
2072
Sebastian Redl8538e8d2010-08-18 23:57:32 +00002073 case EXPR_DESIGNATED_INIT:
Douglas Gregor35942772011-09-09 21:34:22 +00002074 S = DesignatedInitExpr::CreateEmpty(Context,
Sebastian Redl60adf4a2010-08-18 23:56:52 +00002075 Record[ASTStmtReader::NumExprFields] - 1);
Mike Stump1eb44332009-09-09 15:08:12 +00002076
Chris Lattner4c6f9522009-04-27 05:14:47 +00002077 break;
2078
Sebastian Redl8538e8d2010-08-18 23:57:32 +00002079 case EXPR_IMPLICIT_VALUE_INIT:
Chris Lattner4c6f9522009-04-27 05:14:47 +00002080 S = new (Context) ImplicitValueInitExpr(Empty);
2081 break;
2082
Sebastian Redl8538e8d2010-08-18 23:57:32 +00002083 case EXPR_VA_ARG:
Chris Lattner4c6f9522009-04-27 05:14:47 +00002084 S = new (Context) VAArgExpr(Empty);
2085 break;
2086
Sebastian Redl8538e8d2010-08-18 23:57:32 +00002087 case EXPR_ADDR_LABEL:
Chris Lattner4c6f9522009-04-27 05:14:47 +00002088 S = new (Context) AddrLabelExpr(Empty);
2089 break;
2090
Sebastian Redl8538e8d2010-08-18 23:57:32 +00002091 case EXPR_STMT:
Chris Lattner4c6f9522009-04-27 05:14:47 +00002092 S = new (Context) StmtExpr(Empty);
2093 break;
2094
Sebastian Redl8538e8d2010-08-18 23:57:32 +00002095 case EXPR_CHOOSE:
Chris Lattner4c6f9522009-04-27 05:14:47 +00002096 S = new (Context) ChooseExpr(Empty);
2097 break;
2098
Sebastian Redl8538e8d2010-08-18 23:57:32 +00002099 case EXPR_GNU_NULL:
Chris Lattner4c6f9522009-04-27 05:14:47 +00002100 S = new (Context) GNUNullExpr(Empty);
2101 break;
2102
Sebastian Redl8538e8d2010-08-18 23:57:32 +00002103 case EXPR_SHUFFLE_VECTOR:
Chris Lattner4c6f9522009-04-27 05:14:47 +00002104 S = new (Context) ShuffleVectorExpr(Empty);
2105 break;
Mike Stump1eb44332009-09-09 15:08:12 +00002106
Sebastian Redl8538e8d2010-08-18 23:57:32 +00002107 case EXPR_BLOCK:
Chris Lattner4c6f9522009-04-27 05:14:47 +00002108 S = new (Context) BlockExpr(Empty);
2109 break;
2110
Peter Collingbournef111d932011-04-15 00:35:48 +00002111 case EXPR_GENERIC_SELECTION:
2112 S = new (Context) GenericSelectionExpr(Empty);
2113 break;
2114
Sebastian Redl8538e8d2010-08-18 23:57:32 +00002115 case EXPR_OBJC_STRING_LITERAL:
Chris Lattner4c6f9522009-04-27 05:14:47 +00002116 S = new (Context) ObjCStringLiteral(Empty);
2117 break;
Patrick Beardeb382ec2012-04-19 00:25:12 +00002118 case EXPR_OBJC_BOXED_EXPRESSION:
2119 S = new (Context) ObjCBoxedExpr(Empty);
Ted Kremenekebcb57a2012-03-06 20:05:56 +00002120 break;
2121 case EXPR_OBJC_ARRAY_LITERAL:
2122 S = ObjCArrayLiteral::CreateEmpty(Context,
2123 Record[ASTStmtReader::NumExprFields]);
2124 break;
2125 case EXPR_OBJC_DICTIONARY_LITERAL:
2126 S = ObjCDictionaryLiteral::CreateEmpty(Context,
2127 Record[ASTStmtReader::NumExprFields],
2128 Record[ASTStmtReader::NumExprFields + 1]);
2129 break;
Sebastian Redl8538e8d2010-08-18 23:57:32 +00002130 case EXPR_OBJC_ENCODE:
Chris Lattner4c6f9522009-04-27 05:14:47 +00002131 S = new (Context) ObjCEncodeExpr(Empty);
2132 break;
Sebastian Redl8538e8d2010-08-18 23:57:32 +00002133 case EXPR_OBJC_SELECTOR_EXPR:
Chris Lattner4c6f9522009-04-27 05:14:47 +00002134 S = new (Context) ObjCSelectorExpr(Empty);
2135 break;
Sebastian Redl8538e8d2010-08-18 23:57:32 +00002136 case EXPR_OBJC_PROTOCOL_EXPR:
Chris Lattner4c6f9522009-04-27 05:14:47 +00002137 S = new (Context) ObjCProtocolExpr(Empty);
2138 break;
Sebastian Redl8538e8d2010-08-18 23:57:32 +00002139 case EXPR_OBJC_IVAR_REF_EXPR:
Chris Lattner4c6f9522009-04-27 05:14:47 +00002140 S = new (Context) ObjCIvarRefExpr(Empty);
2141 break;
Sebastian Redl8538e8d2010-08-18 23:57:32 +00002142 case EXPR_OBJC_PROPERTY_REF_EXPR:
Chris Lattner4c6f9522009-04-27 05:14:47 +00002143 S = new (Context) ObjCPropertyRefExpr(Empty);
2144 break;
Ted Kremenekebcb57a2012-03-06 20:05:56 +00002145 case EXPR_OBJC_SUBSCRIPT_REF_EXPR:
2146 S = new (Context) ObjCSubscriptRefExpr(Empty);
2147 break;
Sebastian Redl8538e8d2010-08-18 23:57:32 +00002148 case EXPR_OBJC_KVC_REF_EXPR:
John McCall12f78a62010-12-02 01:19:52 +00002149 llvm_unreachable("mismatching AST file");
Sebastian Redl8538e8d2010-08-18 23:57:32 +00002150 case EXPR_OBJC_MESSAGE_EXPR:
Douglas Gregor35942772011-09-09 21:34:22 +00002151 S = ObjCMessageExpr::CreateEmpty(Context,
Argyrios Kyrtzidis20718082011-10-03 06:36:51 +00002152 Record[ASTStmtReader::NumExprFields],
2153 Record[ASTStmtReader::NumExprFields + 1]);
Chris Lattner4c6f9522009-04-27 05:14:47 +00002154 break;
Sebastian Redl8538e8d2010-08-18 23:57:32 +00002155 case EXPR_OBJC_ISA:
Steve Narofff242b1b2009-07-24 17:54:45 +00002156 S = new (Context) ObjCIsaExpr(Empty);
2157 break;
John McCallf85e1932011-06-15 23:02:42 +00002158 case EXPR_OBJC_INDIRECT_COPY_RESTORE:
2159 S = new (Context) ObjCIndirectCopyRestoreExpr(Empty);
2160 break;
2161 case EXPR_OBJC_BRIDGED_CAST:
2162 S = new (Context) ObjCBridgedCastExpr(Empty);
2163 break;
Sebastian Redl8538e8d2010-08-18 23:57:32 +00002164 case STMT_OBJC_FOR_COLLECTION:
Chris Lattner4c6f9522009-04-27 05:14:47 +00002165 S = new (Context) ObjCForCollectionStmt(Empty);
2166 break;
Sebastian Redl8538e8d2010-08-18 23:57:32 +00002167 case STMT_OBJC_CATCH:
Chris Lattner4c6f9522009-04-27 05:14:47 +00002168 S = new (Context) ObjCAtCatchStmt(Empty);
2169 break;
Sebastian Redl8538e8d2010-08-18 23:57:32 +00002170 case STMT_OBJC_FINALLY:
Chris Lattner4c6f9522009-04-27 05:14:47 +00002171 S = new (Context) ObjCAtFinallyStmt(Empty);
2172 break;
Sebastian Redl8538e8d2010-08-18 23:57:32 +00002173 case STMT_OBJC_AT_TRY:
Douglas Gregor35942772011-09-09 21:34:22 +00002174 S = ObjCAtTryStmt::CreateEmpty(Context,
Sebastian Redl60adf4a2010-08-18 23:56:52 +00002175 Record[ASTStmtReader::NumStmtFields],
2176 Record[ASTStmtReader::NumStmtFields + 1]);
Chris Lattner4c6f9522009-04-27 05:14:47 +00002177 break;
Sebastian Redl8538e8d2010-08-18 23:57:32 +00002178 case STMT_OBJC_AT_SYNCHRONIZED:
Chris Lattner4c6f9522009-04-27 05:14:47 +00002179 S = new (Context) ObjCAtSynchronizedStmt(Empty);
2180 break;
Sebastian Redl8538e8d2010-08-18 23:57:32 +00002181 case STMT_OBJC_AT_THROW:
Chris Lattner4c6f9522009-04-27 05:14:47 +00002182 S = new (Context) ObjCAtThrowStmt(Empty);
2183 break;
John McCallf85e1932011-06-15 23:02:42 +00002184 case STMT_OBJC_AUTORELEASE_POOL:
2185 S = new (Context) ObjCAutoreleasePoolStmt(Empty);
2186 break;
Ted Kremenekebcb57a2012-03-06 20:05:56 +00002187 case EXPR_OBJC_BOOL_LITERAL:
2188 S = new (Context) ObjCBoolLiteralExpr(Empty);
2189 break;
John McCall7110fd62011-07-15 07:00:14 +00002190 case STMT_SEH_EXCEPT:
2191 S = new (Context) SEHExceptStmt(Empty);
2192 break;
2193 case STMT_SEH_FINALLY:
2194 S = new (Context) SEHFinallyStmt(Empty);
2195 break;
2196 case STMT_SEH_TRY:
2197 S = new (Context) SEHTryStmt(Empty);
2198 break;
Sebastian Redl8538e8d2010-08-18 23:57:32 +00002199 case STMT_CXX_CATCH:
Argyrios Kyrtzidis7cb45e32010-07-22 16:03:56 +00002200 S = new (Context) CXXCatchStmt(Empty);
2201 break;
2202
Sebastian Redl8538e8d2010-08-18 23:57:32 +00002203 case STMT_CXX_TRY:
Douglas Gregor35942772011-09-09 21:34:22 +00002204 S = CXXTryStmt::Create(Context, Empty,
Sebastian Redl60adf4a2010-08-18 23:56:52 +00002205 /*NumHandlers=*/Record[ASTStmtReader::NumStmtFields]);
Argyrios Kyrtzidis7cb45e32010-07-22 16:03:56 +00002206 break;
2207
Richard Smithad762fc2011-04-14 22:09:26 +00002208 case STMT_CXX_FOR_RANGE:
2209 S = new (Context) CXXForRangeStmt(Empty);
2210 break;
2211
Douglas Gregorba0513d2011-10-25 01:33:02 +00002212 case STMT_MS_DEPENDENT_EXISTS:
2213 S = new (Context) MSDependentExistsStmt(SourceLocation(), true,
2214 NestedNameSpecifierLoc(),
2215 DeclarationNameInfo(),
2216 0);
2217 break;
Alexey Bataev4fa7eab2013-07-19 03:13:43 +00002218 case STMT_OMP_PARALLEL_DIRECTIVE:
2219 S =
2220 OMPParallelDirective::CreateEmpty(Context,
2221 Record[ASTStmtReader::NumStmtFields],
2222 Empty);
2223 break;
Douglas Gregorba0513d2011-10-25 01:33:02 +00002224
Sebastian Redl8538e8d2010-08-18 23:57:32 +00002225 case EXPR_CXX_OPERATOR_CALL:
Douglas Gregor35942772011-09-09 21:34:22 +00002226 S = new (Context) CXXOperatorCallExpr(Context, Empty);
Argyrios Kyrtzidisba0a9002009-07-14 03:19:21 +00002227 break;
Chris Lattner1817bd42010-05-09 05:36:05 +00002228
Sebastian Redl8538e8d2010-08-18 23:57:32 +00002229 case EXPR_CXX_MEMBER_CALL:
Douglas Gregor35942772011-09-09 21:34:22 +00002230 S = new (Context) CXXMemberCallExpr(Context, Empty);
Chris Lattner1817bd42010-05-09 05:36:05 +00002231 break;
Douglas Gregor39da0b82009-09-09 23:08:42 +00002232
Sebastian Redl8538e8d2010-08-18 23:57:32 +00002233 case EXPR_CXX_CONSTRUCT:
Argyrios Kyrtzidis6d00c132010-07-10 11:46:15 +00002234 S = new (Context) CXXConstructExpr(Empty);
2235 break;
2236
Sebastian Redl8538e8d2010-08-18 23:57:32 +00002237 case EXPR_CXX_TEMPORARY_OBJECT:
Argyrios Kyrtzidis6d00c132010-07-10 11:46:15 +00002238 S = new (Context) CXXTemporaryObjectExpr(Empty);
Douglas Gregor39da0b82009-09-09 23:08:42 +00002239 break;
Sam Weinigce757a72010-01-16 21:21:01 +00002240
Sebastian Redl8538e8d2010-08-18 23:57:32 +00002241 case EXPR_CXX_STATIC_CAST:
Douglas Gregor35942772011-09-09 21:34:22 +00002242 S = CXXStaticCastExpr::CreateEmpty(Context,
Sebastian Redl60adf4a2010-08-18 23:56:52 +00002243 /*PathSize*/ Record[ASTStmtReader::NumExprFields]);
Sam Weinigce757a72010-01-16 21:21:01 +00002244 break;
2245
Sebastian Redl8538e8d2010-08-18 23:57:32 +00002246 case EXPR_CXX_DYNAMIC_CAST:
Douglas Gregor35942772011-09-09 21:34:22 +00002247 S = CXXDynamicCastExpr::CreateEmpty(Context,
Sebastian Redl60adf4a2010-08-18 23:56:52 +00002248 /*PathSize*/ Record[ASTStmtReader::NumExprFields]);
Sam Weinigce757a72010-01-16 21:21:01 +00002249 break;
2250
Sebastian Redl8538e8d2010-08-18 23:57:32 +00002251 case EXPR_CXX_REINTERPRET_CAST:
Douglas Gregor35942772011-09-09 21:34:22 +00002252 S = CXXReinterpretCastExpr::CreateEmpty(Context,
Sebastian Redl60adf4a2010-08-18 23:56:52 +00002253 /*PathSize*/ Record[ASTStmtReader::NumExprFields]);
Sam Weinigce757a72010-01-16 21:21:01 +00002254 break;
2255
Sebastian Redl8538e8d2010-08-18 23:57:32 +00002256 case EXPR_CXX_CONST_CAST:
Douglas Gregor35942772011-09-09 21:34:22 +00002257 S = CXXConstCastExpr::CreateEmpty(Context);
Sam Weinigce757a72010-01-16 21:21:01 +00002258 break;
2259
Sebastian Redl8538e8d2010-08-18 23:57:32 +00002260 case EXPR_CXX_FUNCTIONAL_CAST:
Douglas Gregor35942772011-09-09 21:34:22 +00002261 S = CXXFunctionalCastExpr::CreateEmpty(Context,
Sebastian Redl60adf4a2010-08-18 23:56:52 +00002262 /*PathSize*/ Record[ASTStmtReader::NumExprFields]);
Sam Weinigce757a72010-01-16 21:21:01 +00002263 break;
2264
Richard Smith9fcce652012-03-07 08:35:16 +00002265 case EXPR_USER_DEFINED_LITERAL:
2266 S = new (Context) UserDefinedLiteral(Context, Empty);
2267 break;
2268
Richard Smith7c3e6152013-06-12 22:31:48 +00002269 case EXPR_CXX_STD_INITIALIZER_LIST:
2270 S = new (Context) CXXStdInitializerListExpr(Empty);
2271 break;
2272
Sebastian Redl8538e8d2010-08-18 23:57:32 +00002273 case EXPR_CXX_BOOL_LITERAL:
Sam Weinigeb7f9612010-02-07 06:32:43 +00002274 S = new (Context) CXXBoolLiteralExpr(Empty);
2275 break;
Sam Weinigce757a72010-01-16 21:21:01 +00002276
Sebastian Redl8538e8d2010-08-18 23:57:32 +00002277 case EXPR_CXX_NULL_PTR_LITERAL:
Sam Weinigeb7f9612010-02-07 06:32:43 +00002278 S = new (Context) CXXNullPtrLiteralExpr(Empty);
2279 break;
Sebastian Redl8538e8d2010-08-18 23:57:32 +00002280 case EXPR_CXX_TYPEID_EXPR:
Chris Lattner14ab24f2010-05-09 06:03:39 +00002281 S = new (Context) CXXTypeidExpr(Empty, true);
2282 break;
Sebastian Redl8538e8d2010-08-18 23:57:32 +00002283 case EXPR_CXX_TYPEID_TYPE:
Chris Lattner14ab24f2010-05-09 06:03:39 +00002284 S = new (Context) CXXTypeidExpr(Empty, false);
2285 break;
Francois Pichet01b7c302010-09-08 12:20:18 +00002286 case EXPR_CXX_UUIDOF_EXPR:
2287 S = new (Context) CXXUuidofExpr(Empty, true);
2288 break;
John McCall76da55d2013-04-16 07:28:30 +00002289 case EXPR_CXX_PROPERTY_REF_EXPR:
2290 S = new (Context) MSPropertyRefExpr(Empty);
2291 break;
Francois Pichet01b7c302010-09-08 12:20:18 +00002292 case EXPR_CXX_UUIDOF_TYPE:
2293 S = new (Context) CXXUuidofExpr(Empty, false);
2294 break;
Sebastian Redl8538e8d2010-08-18 23:57:32 +00002295 case EXPR_CXX_THIS:
Chris Lattner2fbdfcd2010-05-09 06:15:05 +00002296 S = new (Context) CXXThisExpr(Empty);
2297 break;
Sebastian Redl8538e8d2010-08-18 23:57:32 +00002298 case EXPR_CXX_THROW:
Chris Lattner2fbdfcd2010-05-09 06:15:05 +00002299 S = new (Context) CXXThrowExpr(Empty);
2300 break;
Sebastian Redl8538e8d2010-08-18 23:57:32 +00002301 case EXPR_CXX_DEFAULT_ARG: {
Sebastian Redl60adf4a2010-08-18 23:56:52 +00002302 bool HasOtherExprStored = Record[ASTStmtReader::NumExprFields];
Argyrios Kyrtzidis8a507332010-07-02 23:30:15 +00002303 if (HasOtherExprStored) {
2304 Expr *SubExpr = ReadSubExpr();
Douglas Gregor35942772011-09-09 21:34:22 +00002305 S = CXXDefaultArgExpr::Create(Context, SourceLocation(), 0, SubExpr);
Argyrios Kyrtzidis8a507332010-07-02 23:30:15 +00002306 } else
2307 S = new (Context) CXXDefaultArgExpr(Empty);
Chris Lattner030854b2010-05-09 06:40:08 +00002308 break;
Argyrios Kyrtzidis8a507332010-07-02 23:30:15 +00002309 }
Richard Smithc3bf52c2013-04-20 22:23:05 +00002310 case EXPR_CXX_DEFAULT_INIT:
2311 S = new (Context) CXXDefaultInitExpr(Empty);
2312 break;
Sebastian Redl8538e8d2010-08-18 23:57:32 +00002313 case EXPR_CXX_BIND_TEMPORARY:
Chris Lattnerd2598362010-05-10 00:25:06 +00002314 S = new (Context) CXXBindTemporaryExpr(Empty);
2315 break;
Douglas Gregore2ca6d42010-09-02 21:50:02 +00002316
Sebastian Redl8538e8d2010-08-18 23:57:32 +00002317 case EXPR_CXX_SCALAR_VALUE_INIT:
Douglas Gregored8abf12010-07-08 06:14:04 +00002318 S = new (Context) CXXScalarValueInitExpr(Empty);
Chris Lattner59218632010-05-10 01:22:27 +00002319 break;
Sebastian Redl8538e8d2010-08-18 23:57:32 +00002320 case EXPR_CXX_NEW:
Chris Lattner59218632010-05-10 01:22:27 +00002321 S = new (Context) CXXNewExpr(Empty);
2322 break;
Sebastian Redl8538e8d2010-08-18 23:57:32 +00002323 case EXPR_CXX_DELETE:
Argyrios Kyrtzidis95fc98c2010-06-22 17:07:59 +00002324 S = new (Context) CXXDeleteExpr(Empty);
2325 break;
Sebastian Redl8538e8d2010-08-18 23:57:32 +00002326 case EXPR_CXX_PSEUDO_DESTRUCTOR:
Argyrios Kyrtzidisde4bd182010-06-28 09:32:03 +00002327 S = new (Context) CXXPseudoDestructorExpr(Empty);
2328 break;
Chris Lattner59218632010-05-10 01:22:27 +00002329
John McCall4765fa02010-12-06 08:20:24 +00002330 case EXPR_EXPR_WITH_CLEANUPS:
John McCall80ee6e82011-11-10 05:35:25 +00002331 S = ExprWithCleanups::Create(Context, Empty,
2332 Record[ASTStmtReader::NumExprFields]);
Chris Lattnerd2598362010-05-10 00:25:06 +00002333 break;
Argyrios Kyrtzidis8dfbd8b2010-06-24 08:57:31 +00002334
Sebastian Redl8538e8d2010-08-18 23:57:32 +00002335 case EXPR_CXX_DEPENDENT_SCOPE_MEMBER:
Douglas Gregor35942772011-09-09 21:34:22 +00002336 S = CXXDependentScopeMemberExpr::CreateEmpty(Context,
Abramo Bagnarae4b92762012-01-27 09:46:47 +00002337 /*HasTemplateKWAndArgsInfo=*/Record[ASTStmtReader::NumExprFields],
Douglas Gregordef03542011-02-04 12:01:24 +00002338 /*NumTemplateArgs=*/Record[ASTStmtReader::NumExprFields]
2339 ? Record[ASTStmtReader::NumExprFields + 1]
2340 : 0);
Argyrios Kyrtzidis8dfbd8b2010-06-24 08:57:31 +00002341 break;
2342
Sebastian Redl8538e8d2010-08-18 23:57:32 +00002343 case EXPR_CXX_DEPENDENT_SCOPE_DECL_REF:
Douglas Gregor35942772011-09-09 21:34:22 +00002344 S = DependentScopeDeclRefExpr::CreateEmpty(Context,
Abramo Bagnarae4b92762012-01-27 09:46:47 +00002345 /*HasTemplateKWAndArgsInfo=*/Record[ASTStmtReader::NumExprFields],
Douglas Gregordef03542011-02-04 12:01:24 +00002346 /*NumTemplateArgs=*/Record[ASTStmtReader::NumExprFields]
2347 ? Record[ASTStmtReader::NumExprFields + 1]
2348 : 0);
Argyrios Kyrtzidis12dffcd2010-06-28 09:31:56 +00002349 break;
2350
Sebastian Redl8538e8d2010-08-18 23:57:32 +00002351 case EXPR_CXX_UNRESOLVED_CONSTRUCT:
Douglas Gregor35942772011-09-09 21:34:22 +00002352 S = CXXUnresolvedConstructExpr::CreateEmpty(Context,
Sebastian Redl60adf4a2010-08-18 23:56:52 +00002353 /*NumArgs=*/Record[ASTStmtReader::NumExprFields]);
Argyrios Kyrtzidisa77eb082010-06-25 09:03:26 +00002354 break;
2355
Sebastian Redl8538e8d2010-08-18 23:57:32 +00002356 case EXPR_CXX_UNRESOLVED_MEMBER:
Douglas Gregor35942772011-09-09 21:34:22 +00002357 S = UnresolvedMemberExpr::CreateEmpty(Context,
Abramo Bagnarae4b92762012-01-27 09:46:47 +00002358 /*HasTemplateKWAndArgsInfo=*/Record[ASTStmtReader::NumExprFields],
Douglas Gregordef03542011-02-04 12:01:24 +00002359 /*NumTemplateArgs=*/Record[ASTStmtReader::NumExprFields]
2360 ? Record[ASTStmtReader::NumExprFields + 1]
2361 : 0);
Argyrios Kyrtzidis8dfbd8b2010-06-24 08:57:31 +00002362 break;
Argyrios Kyrtzidisbd65bb52010-06-25 09:03:34 +00002363
Sebastian Redl8538e8d2010-08-18 23:57:32 +00002364 case EXPR_CXX_UNRESOLVED_LOOKUP:
Douglas Gregor35942772011-09-09 21:34:22 +00002365 S = UnresolvedLookupExpr::CreateEmpty(Context,
Abramo Bagnarae4b92762012-01-27 09:46:47 +00002366 /*HasTemplateKWAndArgsInfo=*/Record[ASTStmtReader::NumExprFields],
Douglas Gregordef03542011-02-04 12:01:24 +00002367 /*NumTemplateArgs=*/Record[ASTStmtReader::NumExprFields]
2368 ? Record[ASTStmtReader::NumExprFields + 1]
2369 : 0);
Argyrios Kyrtzidisbd65bb52010-06-25 09:03:34 +00002370 break;
Argyrios Kyrtzidis6d00c132010-07-10 11:46:15 +00002371
Sebastian Redl8538e8d2010-08-18 23:57:32 +00002372 case EXPR_CXX_UNARY_TYPE_TRAIT:
Argyrios Kyrtzidis6d00c132010-07-10 11:46:15 +00002373 S = new (Context) UnaryTypeTraitExpr(Empty);
2374 break;
Sebastian Redl6b219d02010-09-10 20:55:54 +00002375
Francois Pichetf1872372010-12-08 22:35:30 +00002376 case EXPR_BINARY_TYPE_TRAIT:
Francois Pichet6ad6f282010-12-07 00:08:36 +00002377 S = new (Context) BinaryTypeTraitExpr(Empty);
2378 break;
2379
Douglas Gregor4ca8ac22012-02-24 07:38:34 +00002380 case EXPR_TYPE_TRAIT:
2381 S = TypeTraitExpr::CreateDeserialized(Context,
2382 Record[ASTStmtReader::NumExprFields]);
2383 break;
2384
John Wiegley21ff2e52011-04-28 00:16:57 +00002385 case EXPR_ARRAY_TYPE_TRAIT:
2386 S = new (Context) ArrayTypeTraitExpr(Empty);
2387 break;
2388
John Wiegley55262202011-04-25 06:54:41 +00002389 case EXPR_CXX_EXPRESSION_TRAIT:
2390 S = new (Context) ExpressionTraitExpr(Empty);
2391 break;
2392
Sebastian Redl6b219d02010-09-10 20:55:54 +00002393 case EXPR_CXX_NOEXCEPT:
2394 S = new (Context) CXXNoexceptExpr(Empty);
2395 break;
John McCall7cd7d1a2010-11-15 23:31:06 +00002396
Douglas Gregorbe230c32011-01-03 17:17:50 +00002397 case EXPR_PACK_EXPANSION:
2398 S = new (Context) PackExpansionExpr(Empty);
2399 break;
2400
Douglas Gregoree8aff02011-01-04 17:33:58 +00002401 case EXPR_SIZEOF_PACK:
2402 S = new (Context) SizeOfPackExpr(Empty);
2403 break;
2404
John McCall7110fd62011-07-15 07:00:14 +00002405 case EXPR_SUBST_NON_TYPE_TEMPLATE_PARM:
2406 S = new (Context) SubstNonTypeTemplateParmExpr(Empty);
2407 break;
2408
Douglas Gregorc7793c72011-01-15 01:15:58 +00002409 case EXPR_SUBST_NON_TYPE_TEMPLATE_PARM_PACK:
2410 S = new (Context) SubstNonTypeTemplateParmPackExpr(Empty);
2411 break;
Richard Smith9a4db032012-09-12 00:56:43 +00002412
2413 case EXPR_FUNCTION_PARM_PACK:
2414 S = FunctionParmPackExpr::CreateEmpty(Context,
2415 Record[ASTStmtReader::NumExprFields]);
2416 break;
Douglas Gregorc7793c72011-01-15 01:15:58 +00002417
Douglas Gregor03e80032011-06-21 17:03:29 +00002418 case EXPR_MATERIALIZE_TEMPORARY:
2419 S = new (Context) MaterializeTemporaryExpr(Empty);
2420 break;
2421
Argyrios Kyrtzidis8bc27822011-12-03 03:49:52 +00002422 case EXPR_OPAQUE_VALUE:
2423 S = new (Context) OpaqueValueExpr(Empty);
John McCall7cd7d1a2010-11-15 23:31:06 +00002424 break;
Peter Collingbournee08ce652011-02-09 21:07:24 +00002425
2426 case EXPR_CUDA_KERNEL_CALL:
Douglas Gregor35942772011-09-09 21:34:22 +00002427 S = new (Context) CUDAKernelCallExpr(Context, Empty);
Peter Collingbournee08ce652011-02-09 21:07:24 +00002428 break;
Tanya Lattner61eee0c2011-06-04 00:47:47 +00002429
2430 case EXPR_ASTYPE:
2431 S = new (Context) AsTypeExpr(Empty);
2432 break;
Eli Friedman276b0612011-10-11 02:20:01 +00002433
John McCall4b9c2d22011-11-06 09:01:30 +00002434 case EXPR_PSEUDO_OBJECT: {
2435 unsigned numSemanticExprs = Record[ASTStmtReader::NumExprFields];
2436 S = PseudoObjectExpr::Create(Context, Empty, numSemanticExprs);
2437 break;
2438 }
2439
Eli Friedman276b0612011-10-11 02:20:01 +00002440 case EXPR_ATOMIC:
2441 S = new (Context) AtomicExpr(Empty);
2442 break;
Douglas Gregor9d36f5d2012-02-14 17:54:36 +00002443
2444 case EXPR_LAMBDA: {
2445 unsigned NumCaptures = Record[ASTStmtReader::NumExprFields];
2446 unsigned NumArrayIndexVars = Record[ASTStmtReader::NumExprFields + 1];
2447 S = LambdaExpr::CreateDeserialized(Context, NumCaptures,
2448 NumArrayIndexVars);
2449 break;
2450 }
Chris Lattner4c6f9522009-04-27 05:14:47 +00002451 }
Argyrios Kyrtzidis6d00c132010-07-10 11:46:15 +00002452
Chris Lattner4c6f9522009-04-27 05:14:47 +00002453 // We hit a STMT_STOP, so we're done with this expression.
2454 if (Finished)
2455 break;
2456
2457 ++NumStatementsRead;
2458
Argyrios Kyrtzidise6f08682011-10-21 23:02:28 +00002459 if (S && !IsStmtReference) {
Argyrios Kyrtzidis919e6932010-06-28 22:28:35 +00002460 Reader.Visit(S);
Argyrios Kyrtzidise6f08682011-10-21 23:02:28 +00002461 StmtEntries[Cursor.GetCurrentBitNo()] = S;
2462 }
2463
Chris Lattner4c6f9522009-04-27 05:14:47 +00002464
2465 assert(Idx == Record.size() && "Invalid deserialization of statement");
2466 StmtStack.push_back(S);
2467 }
Chris Lattnerb3ce3572013-01-20 02:38:54 +00002468Done:
Argyrios Kyrtzidis919e6932010-06-28 22:28:35 +00002469 assert(StmtStack.size() > PrevNumStmts && "Read too many sub stmts!");
2470 assert(StmtStack.size() == PrevNumStmts + 1 && "Extra expressions on stack!");
Argyrios Kyrtzidis919e6932010-06-28 22:28:35 +00002471 return StmtStack.pop_back_val();
Chris Lattner4c6f9522009-04-27 05:14:47 +00002472}