blob: 23cd9cc726bd699c7e5503dc2946f3cc874eb784 [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
Hal Finkel414a1bd2013-09-18 03:29:45 +0000857void ASTStmtReader::VisitConvertVectorExpr(ConvertVectorExpr *E) {
858 VisitExpr(E);
859 E->BuiltinLoc = ReadSourceLocation(Record, Idx);
860 E->RParenLoc = ReadSourceLocation(Record, Idx);
861 E->TInfo = GetTypeSourceInfo(Record, Idx);
862 E->SrcExpr = Reader.ReadSubExpr();
863}
864
Sebastian Redl60adf4a2010-08-18 23:56:52 +0000865void ASTStmtReader::VisitBlockExpr(BlockExpr *E) {
Chris Lattner4c6f9522009-04-27 05:14:47 +0000866 VisitExpr(E);
Douglas Gregor409448c2011-07-21 22:35:25 +0000867 E->setBlockDecl(ReadDeclAs<BlockDecl>(Record, Idx));
Chris Lattner4c6f9522009-04-27 05:14:47 +0000868}
869
Peter Collingbournef111d932011-04-15 00:35:48 +0000870void ASTStmtReader::VisitGenericSelectionExpr(GenericSelectionExpr *E) {
871 VisitExpr(E);
872 E->NumAssocs = Record[Idx++];
Douglas Gregor35942772011-09-09 21:34:22 +0000873 E->AssocTypes = new (Reader.getContext()) TypeSourceInfo*[E->NumAssocs];
Peter Collingbournef111d932011-04-15 00:35:48 +0000874 E->SubExprs =
Douglas Gregor35942772011-09-09 21:34:22 +0000875 new(Reader.getContext()) Stmt*[GenericSelectionExpr::END_EXPR+E->NumAssocs];
Peter Collingbournef111d932011-04-15 00:35:48 +0000876
877 E->SubExprs[GenericSelectionExpr::CONTROLLING] = Reader.ReadSubExpr();
878 for (unsigned I = 0, N = E->getNumAssocs(); I != N; ++I) {
879 E->AssocTypes[I] = GetTypeSourceInfo(Record, Idx);
880 E->SubExprs[GenericSelectionExpr::END_EXPR+I] = Reader.ReadSubExpr();
881 }
882 E->ResultIndex = Record[Idx++];
883
884 E->GenericLoc = ReadSourceLocation(Record, Idx);
885 E->DefaultLoc = ReadSourceLocation(Record, Idx);
886 E->RParenLoc = ReadSourceLocation(Record, Idx);
887}
888
John McCall4b9c2d22011-11-06 09:01:30 +0000889void ASTStmtReader::VisitPseudoObjectExpr(PseudoObjectExpr *E) {
890 VisitExpr(E);
891 unsigned numSemanticExprs = Record[Idx++];
892 assert(numSemanticExprs + 1 == E->PseudoObjectExprBits.NumSubExprs);
893 E->PseudoObjectExprBits.ResultIndex = Record[Idx++];
894
895 // Read the syntactic expression.
896 E->getSubExprsBuffer()[0] = Reader.ReadSubExpr();
897
898 // Read all the semantic expressions.
899 for (unsigned i = 0; i != numSemanticExprs; ++i) {
900 Expr *subExpr = Reader.ReadSubExpr();
John McCall4b9c2d22011-11-06 09:01:30 +0000901 E->getSubExprsBuffer()[i+1] = subExpr;
902 }
903}
904
Eli Friedman276b0612011-10-11 02:20:01 +0000905void ASTStmtReader::VisitAtomicExpr(AtomicExpr *E) {
906 VisitExpr(E);
Richard Smithe1b2abc2012-04-10 22:49:28 +0000907 E->Op = AtomicExpr::AtomicOp(Record[Idx++]);
908 E->NumSubExprs = AtomicExpr::getNumSubExprs(E->Op);
909 for (unsigned I = 0; I != E->NumSubExprs; ++I)
910 E->SubExprs[I] = Reader.ReadSubExpr();
911 E->BuiltinLoc = ReadSourceLocation(Record, Idx);
912 E->RParenLoc = ReadSourceLocation(Record, Idx);
Eli Friedman276b0612011-10-11 02:20:01 +0000913}
914
Chris Lattner4c6f9522009-04-27 05:14:47 +0000915//===----------------------------------------------------------------------===//
916// Objective-C Expressions and Statements
917
Sebastian Redl60adf4a2010-08-18 23:56:52 +0000918void ASTStmtReader::VisitObjCStringLiteral(ObjCStringLiteral *E) {
Chris Lattner4c6f9522009-04-27 05:14:47 +0000919 VisitExpr(E);
Argyrios Kyrtzidisd98a2ab2010-06-29 22:46:25 +0000920 E->setString(cast<StringLiteral>(Reader.ReadSubStmt()));
Sebastian Redlc3632732010-10-05 15:59:54 +0000921 E->setAtLoc(ReadSourceLocation(Record, Idx));
Chris Lattner4c6f9522009-04-27 05:14:47 +0000922}
923
Patrick Beardeb382ec2012-04-19 00:25:12 +0000924void ASTStmtReader::VisitObjCBoxedExpr(ObjCBoxedExpr *E) {
Ted Kremenekebcb57a2012-03-06 20:05:56 +0000925 VisitExpr(E);
926 // could be one of several IntegerLiteral, FloatLiteral, etc.
Patrick Beardeb382ec2012-04-19 00:25:12 +0000927 E->SubExpr = Reader.ReadSubStmt();
928 E->BoxingMethod = ReadDeclAs<ObjCMethodDecl>(Record, Idx);
929 E->Range = ReadSourceRange(Record, Idx);
Ted Kremenekebcb57a2012-03-06 20:05:56 +0000930}
931
932void ASTStmtReader::VisitObjCArrayLiteral(ObjCArrayLiteral *E) {
933 VisitExpr(E);
934 unsigned NumElements = Record[Idx++];
935 assert(NumElements == E->getNumElements() && "Wrong number of elements");
936 Expr **Elements = E->getElements();
937 for (unsigned I = 0, N = NumElements; I != N; ++I)
938 Elements[I] = Reader.ReadSubExpr();
939 E->ArrayWithObjectsMethod = ReadDeclAs<ObjCMethodDecl>(Record, Idx);
940 E->Range = ReadSourceRange(Record, Idx);
941}
942
943void ASTStmtReader::VisitObjCDictionaryLiteral(ObjCDictionaryLiteral *E) {
944 VisitExpr(E);
945 unsigned NumElements = Record[Idx++];
946 assert(NumElements == E->getNumElements() && "Wrong number of elements");
947 bool HasPackExpansions = Record[Idx++];
948 assert(HasPackExpansions == E->HasPackExpansions &&"Pack expansion mismatch");
949 ObjCDictionaryLiteral::KeyValuePair *KeyValues = E->getKeyValues();
950 ObjCDictionaryLiteral::ExpansionData *Expansions = E->getExpansionData();
951 for (unsigned I = 0; I != NumElements; ++I) {
952 KeyValues[I].Key = Reader.ReadSubExpr();
953 KeyValues[I].Value = Reader.ReadSubExpr();
954 if (HasPackExpansions) {
955 Expansions[I].EllipsisLoc = ReadSourceLocation(Record, Idx);
956 Expansions[I].NumExpansionsPlusOne = Record[Idx++];
957 }
958 }
959 E->DictWithObjectsMethod = ReadDeclAs<ObjCMethodDecl>(Record, Idx);
960 E->Range = ReadSourceRange(Record, Idx);
961}
962
Sebastian Redl60adf4a2010-08-18 23:56:52 +0000963void ASTStmtReader::VisitObjCEncodeExpr(ObjCEncodeExpr *E) {
Chris Lattner4c6f9522009-04-27 05:14:47 +0000964 VisitExpr(E);
Sebastian Redlc3632732010-10-05 15:59:54 +0000965 E->setEncodedTypeSourceInfo(GetTypeSourceInfo(Record, Idx));
966 E->setAtLoc(ReadSourceLocation(Record, Idx));
967 E->setRParenLoc(ReadSourceLocation(Record, Idx));
Chris Lattner4c6f9522009-04-27 05:14:47 +0000968}
969
Sebastian Redl60adf4a2010-08-18 23:56:52 +0000970void ASTStmtReader::VisitObjCSelectorExpr(ObjCSelectorExpr *E) {
Chris Lattner4c6f9522009-04-27 05:14:47 +0000971 VisitExpr(E);
Douglas Gregor2d2689a2011-07-28 21:16:51 +0000972 E->setSelector(Reader.ReadSelector(F, Record, Idx));
Sebastian Redlc3632732010-10-05 15:59:54 +0000973 E->setAtLoc(ReadSourceLocation(Record, Idx));
974 E->setRParenLoc(ReadSourceLocation(Record, Idx));
Chris Lattner4c6f9522009-04-27 05:14:47 +0000975}
976
Sebastian Redl60adf4a2010-08-18 23:56:52 +0000977void ASTStmtReader::VisitObjCProtocolExpr(ObjCProtocolExpr *E) {
Chris Lattner4c6f9522009-04-27 05:14:47 +0000978 VisitExpr(E);
Douglas Gregor409448c2011-07-21 22:35:25 +0000979 E->setProtocol(ReadDeclAs<ObjCProtocolDecl>(Record, Idx));
Sebastian Redlc3632732010-10-05 15:59:54 +0000980 E->setAtLoc(ReadSourceLocation(Record, Idx));
Argyrios Kyrtzidis7d24e282012-05-16 00:50:02 +0000981 E->ProtoLoc = ReadSourceLocation(Record, Idx);
Sebastian Redlc3632732010-10-05 15:59:54 +0000982 E->setRParenLoc(ReadSourceLocation(Record, Idx));
Chris Lattner4c6f9522009-04-27 05:14:47 +0000983}
984
Sebastian Redl60adf4a2010-08-18 23:56:52 +0000985void ASTStmtReader::VisitObjCIvarRefExpr(ObjCIvarRefExpr *E) {
Chris Lattner4c6f9522009-04-27 05:14:47 +0000986 VisitExpr(E);
Douglas Gregor409448c2011-07-21 22:35:25 +0000987 E->setDecl(ReadDeclAs<ObjCIvarDecl>(Record, Idx));
Sebastian Redlc3632732010-10-05 15:59:54 +0000988 E->setLocation(ReadSourceLocation(Record, Idx));
Fariborz Jahanian0c701812013-04-02 18:57:54 +0000989 E->setOpLoc(ReadSourceLocation(Record, Idx));
Argyrios Kyrtzidisd98a2ab2010-06-29 22:46:25 +0000990 E->setBase(Reader.ReadSubExpr());
Chris Lattner4c6f9522009-04-27 05:14:47 +0000991 E->setIsArrow(Record[Idx++]);
992 E->setIsFreeIvar(Record[Idx++]);
Chris Lattner4c6f9522009-04-27 05:14:47 +0000993}
994
Sebastian Redl60adf4a2010-08-18 23:56:52 +0000995void ASTStmtReader::VisitObjCPropertyRefExpr(ObjCPropertyRefExpr *E) {
Chris Lattner4c6f9522009-04-27 05:14:47 +0000996 VisitExpr(E);
Argyrios Kyrtzidisb085d892012-03-30 00:19:18 +0000997 unsigned MethodRefFlags = Record[Idx++];
John McCall12f78a62010-12-02 01:19:52 +0000998 bool Implicit = Record[Idx++] != 0;
999 if (Implicit) {
Douglas Gregor409448c2011-07-21 22:35:25 +00001000 ObjCMethodDecl *Getter = ReadDeclAs<ObjCMethodDecl>(Record, Idx);
1001 ObjCMethodDecl *Setter = ReadDeclAs<ObjCMethodDecl>(Record, Idx);
Argyrios Kyrtzidisb085d892012-03-30 00:19:18 +00001002 E->setImplicitProperty(Getter, Setter, MethodRefFlags);
John McCall12f78a62010-12-02 01:19:52 +00001003 } else {
Argyrios Kyrtzidisb085d892012-03-30 00:19:18 +00001004 E->setExplicitProperty(ReadDeclAs<ObjCPropertyDecl>(Record, Idx),
1005 MethodRefFlags);
Fariborz Jahanian8ac2d442010-10-14 16:04:05 +00001006 }
Sebastian Redlc3632732010-10-05 15:59:54 +00001007 E->setLocation(ReadSourceLocation(Record, Idx));
John McCall12f78a62010-12-02 01:19:52 +00001008 E->setReceiverLocation(ReadSourceLocation(Record, Idx));
1009 switch (Record[Idx++]) {
1010 case 0:
1011 E->setBase(Reader.ReadSubExpr());
1012 break;
1013 case 1:
Douglas Gregor393f2492011-07-22 00:38:23 +00001014 E->setSuperReceiver(Reader.readType(F, Record, Idx));
John McCall12f78a62010-12-02 01:19:52 +00001015 break;
1016 case 2:
Douglas Gregor409448c2011-07-21 22:35:25 +00001017 E->setClassReceiver(ReadDeclAs<ObjCInterfaceDecl>(Record, Idx));
John McCall12f78a62010-12-02 01:19:52 +00001018 break;
1019 }
Chris Lattner4c6f9522009-04-27 05:14:47 +00001020}
1021
Ted Kremenekebcb57a2012-03-06 20:05:56 +00001022void ASTStmtReader::VisitObjCSubscriptRefExpr(ObjCSubscriptRefExpr *E) {
1023 VisitExpr(E);
1024 E->setRBracket(ReadSourceLocation(Record, Idx));
1025 E->setBaseExpr(Reader.ReadSubExpr());
1026 E->setKeyExpr(Reader.ReadSubExpr());
1027 E->GetAtIndexMethodDecl = ReadDeclAs<ObjCMethodDecl>(Record, Idx);
1028 E->SetAtIndexMethodDecl = ReadDeclAs<ObjCMethodDecl>(Record, Idx);
1029}
1030
Sebastian Redl60adf4a2010-08-18 23:56:52 +00001031void ASTStmtReader::VisitObjCMessageExpr(ObjCMessageExpr *E) {
Chris Lattner4c6f9522009-04-27 05:14:47 +00001032 VisitExpr(E);
Douglas Gregor04badcf2010-04-21 00:45:42 +00001033 assert(Record[Idx] == E->getNumArgs());
1034 ++Idx;
Argyrios Kyrtzidis20718082011-10-03 06:36:51 +00001035 unsigned NumStoredSelLocs = Record[Idx++];
1036 E->SelLocsKind = Record[Idx++];
John McCallf85e1932011-06-15 23:02:42 +00001037 E->setDelegateInitCall(Record[Idx++]);
Argyrios Kyrtzidis746f5bc2012-01-12 02:34:39 +00001038 E->IsImplicit = Record[Idx++];
Douglas Gregor04badcf2010-04-21 00:45:42 +00001039 ObjCMessageExpr::ReceiverKind Kind
1040 = static_cast<ObjCMessageExpr::ReceiverKind>(Record[Idx++]);
1041 switch (Kind) {
1042 case ObjCMessageExpr::Instance:
Argyrios Kyrtzidisd98a2ab2010-06-29 22:46:25 +00001043 E->setInstanceReceiver(Reader.ReadSubExpr());
Douglas Gregor04badcf2010-04-21 00:45:42 +00001044 break;
1045
1046 case ObjCMessageExpr::Class:
Sebastian Redlc3632732010-10-05 15:59:54 +00001047 E->setClassReceiver(GetTypeSourceInfo(Record, Idx));
Douglas Gregor04badcf2010-04-21 00:45:42 +00001048 break;
1049
1050 case ObjCMessageExpr::SuperClass:
1051 case ObjCMessageExpr::SuperInstance: {
Douglas Gregor393f2492011-07-22 00:38:23 +00001052 QualType T = Reader.readType(F, Record, Idx);
Sebastian Redlc3632732010-10-05 15:59:54 +00001053 SourceLocation SuperLoc = ReadSourceLocation(Record, Idx);
Douglas Gregor04badcf2010-04-21 00:45:42 +00001054 E->setSuper(SuperLoc, T, Kind == ObjCMessageExpr::SuperInstance);
1055 break;
1056 }
1057 }
1058
1059 assert(Kind == E->getReceiverKind());
1060
1061 if (Record[Idx++])
Douglas Gregor409448c2011-07-21 22:35:25 +00001062 E->setMethodDecl(ReadDeclAs<ObjCMethodDecl>(Record, Idx));
Douglas Gregor04badcf2010-04-21 00:45:42 +00001063 else
Douglas Gregor2d2689a2011-07-28 21:16:51 +00001064 E->setSelector(Reader.ReadSelector(F, Record, Idx));
Douglas Gregor04badcf2010-04-21 00:45:42 +00001065
Argyrios Kyrtzidisf40f0d52010-12-10 20:08:27 +00001066 E->LBracLoc = ReadSourceLocation(Record, Idx);
1067 E->RBracLoc = ReadSourceLocation(Record, Idx);
Chris Lattner4c6f9522009-04-27 05:14:47 +00001068
1069 for (unsigned I = 0, N = E->getNumArgs(); I != N; ++I)
Argyrios Kyrtzidisd98a2ab2010-06-29 22:46:25 +00001070 E->setArg(I, Reader.ReadSubExpr());
Argyrios Kyrtzidis20718082011-10-03 06:36:51 +00001071
1072 SourceLocation *Locs = E->getStoredSelLocs();
1073 for (unsigned I = 0; I != NumStoredSelLocs; ++I)
1074 Locs[I] = ReadSourceLocation(Record, Idx);
Chris Lattner4c6f9522009-04-27 05:14:47 +00001075}
1076
Sebastian Redl60adf4a2010-08-18 23:56:52 +00001077void ASTStmtReader::VisitObjCForCollectionStmt(ObjCForCollectionStmt *S) {
Chris Lattner4c6f9522009-04-27 05:14:47 +00001078 VisitStmt(S);
Argyrios Kyrtzidisd98a2ab2010-06-29 22:46:25 +00001079 S->setElement(Reader.ReadSubStmt());
1080 S->setCollection(Reader.ReadSubExpr());
1081 S->setBody(Reader.ReadSubStmt());
Sebastian Redlc3632732010-10-05 15:59:54 +00001082 S->setForLoc(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::VisitObjCAtCatchStmt(ObjCAtCatchStmt *S) {
Chris Lattner4c6f9522009-04-27 05:14:47 +00001087 VisitStmt(S);
Argyrios Kyrtzidisd98a2ab2010-06-29 22:46:25 +00001088 S->setCatchBody(Reader.ReadSubStmt());
Douglas Gregor409448c2011-07-21 22:35:25 +00001089 S->setCatchParamDecl(ReadDeclAs<VarDecl>(Record, Idx));
Sebastian Redlc3632732010-10-05 15:59:54 +00001090 S->setAtCatchLoc(ReadSourceLocation(Record, Idx));
1091 S->setRParenLoc(ReadSourceLocation(Record, Idx));
Chris Lattner4c6f9522009-04-27 05:14:47 +00001092}
1093
Sebastian Redl60adf4a2010-08-18 23:56:52 +00001094void ASTStmtReader::VisitObjCAtFinallyStmt(ObjCAtFinallyStmt *S) {
Chris Lattner4c6f9522009-04-27 05:14:47 +00001095 VisitStmt(S);
Argyrios Kyrtzidisd98a2ab2010-06-29 22:46:25 +00001096 S->setFinallyBody(Reader.ReadSubStmt());
Sebastian Redlc3632732010-10-05 15:59:54 +00001097 S->setAtFinallyLoc(ReadSourceLocation(Record, Idx));
Chris Lattner4c6f9522009-04-27 05:14:47 +00001098}
1099
John McCallf85e1932011-06-15 23:02:42 +00001100void ASTStmtReader::VisitObjCAutoreleasePoolStmt(ObjCAutoreleasePoolStmt *S) {
1101 VisitStmt(S);
1102 S->setSubStmt(Reader.ReadSubStmt());
1103 S->setAtLoc(ReadSourceLocation(Record, Idx));
1104}
1105
Sebastian Redl60adf4a2010-08-18 23:56:52 +00001106void ASTStmtReader::VisitObjCAtTryStmt(ObjCAtTryStmt *S) {
Chris Lattner4c6f9522009-04-27 05:14:47 +00001107 VisitStmt(S);
Douglas Gregor8f5e3dd2010-04-23 22:50:49 +00001108 assert(Record[Idx] == S->getNumCatchStmts());
1109 ++Idx;
1110 bool HasFinally = Record[Idx++];
Argyrios Kyrtzidisd98a2ab2010-06-29 22:46:25 +00001111 S->setTryBody(Reader.ReadSubStmt());
Argyrios Kyrtzidis919e6932010-06-28 22:28:35 +00001112 for (unsigned I = 0, N = S->getNumCatchStmts(); I != N; ++I)
Argyrios Kyrtzidisd98a2ab2010-06-29 22:46:25 +00001113 S->setCatchStmt(I, cast_or_null<ObjCAtCatchStmt>(Reader.ReadSubStmt()));
Douglas Gregor8f5e3dd2010-04-23 22:50:49 +00001114
Douglas Gregor8f5e3dd2010-04-23 22:50:49 +00001115 if (HasFinally)
Argyrios Kyrtzidisd98a2ab2010-06-29 22:46:25 +00001116 S->setFinallyStmt(Reader.ReadSubStmt());
Sebastian Redlc3632732010-10-05 15:59:54 +00001117 S->setAtTryLoc(ReadSourceLocation(Record, Idx));
Chris Lattner4c6f9522009-04-27 05:14:47 +00001118}
1119
Sebastian Redl60adf4a2010-08-18 23:56:52 +00001120void ASTStmtReader::VisitObjCAtSynchronizedStmt(ObjCAtSynchronizedStmt *S) {
Chris Lattner4c6f9522009-04-27 05:14:47 +00001121 VisitStmt(S);
Argyrios Kyrtzidisd98a2ab2010-06-29 22:46:25 +00001122 S->setSynchExpr(Reader.ReadSubStmt());
1123 S->setSynchBody(Reader.ReadSubStmt());
Sebastian Redlc3632732010-10-05 15:59:54 +00001124 S->setAtSynchronizedLoc(ReadSourceLocation(Record, Idx));
Chris Lattner4c6f9522009-04-27 05:14:47 +00001125}
1126
Sebastian Redl60adf4a2010-08-18 23:56:52 +00001127void ASTStmtReader::VisitObjCAtThrowStmt(ObjCAtThrowStmt *S) {
Chris Lattner4c6f9522009-04-27 05:14:47 +00001128 VisitStmt(S);
Argyrios Kyrtzidisd98a2ab2010-06-29 22:46:25 +00001129 S->setThrowExpr(Reader.ReadSubStmt());
Sebastian Redlc3632732010-10-05 15:59:54 +00001130 S->setThrowLoc(ReadSourceLocation(Record, Idx));
Chris Lattner4c6f9522009-04-27 05:14:47 +00001131}
1132
Ted Kremenekebcb57a2012-03-06 20:05:56 +00001133void ASTStmtReader::VisitObjCBoolLiteralExpr(ObjCBoolLiteralExpr *E) {
1134 VisitExpr(E);
1135 E->setValue(Record[Idx++]);
1136 E->setLocation(ReadSourceLocation(Record, Idx));
1137}
1138
Argyrios Kyrtzidisba0a9002009-07-14 03:19:21 +00001139//===----------------------------------------------------------------------===//
1140// C++ Expressions and Statements
Argyrios Kyrtzidis7cb45e32010-07-22 16:03:56 +00001141//===----------------------------------------------------------------------===//
1142
Sebastian Redl60adf4a2010-08-18 23:56:52 +00001143void ASTStmtReader::VisitCXXCatchStmt(CXXCatchStmt *S) {
Argyrios Kyrtzidis7cb45e32010-07-22 16:03:56 +00001144 VisitStmt(S);
Sebastian Redlc3632732010-10-05 15:59:54 +00001145 S->CatchLoc = ReadSourceLocation(Record, Idx);
Douglas Gregor409448c2011-07-21 22:35:25 +00001146 S->ExceptionDecl = ReadDeclAs<VarDecl>(Record, Idx);
Argyrios Kyrtzidis7cb45e32010-07-22 16:03:56 +00001147 S->HandlerBlock = Reader.ReadSubStmt();
1148}
1149
Sebastian Redl60adf4a2010-08-18 23:56:52 +00001150void ASTStmtReader::VisitCXXTryStmt(CXXTryStmt *S) {
Argyrios Kyrtzidis7cb45e32010-07-22 16:03:56 +00001151 VisitStmt(S);
1152 assert(Record[Idx] == S->getNumHandlers() && "NumStmtFields is wrong ?");
1153 ++Idx;
Sebastian Redlc3632732010-10-05 15:59:54 +00001154 S->TryLoc = ReadSourceLocation(Record, Idx);
Argyrios Kyrtzidis7cb45e32010-07-22 16:03:56 +00001155 S->getStmts()[0] = Reader.ReadSubStmt();
1156 for (unsigned i = 0, e = S->getNumHandlers(); i != e; ++i)
1157 S->getStmts()[i + 1] = Reader.ReadSubStmt();
1158}
Argyrios Kyrtzidisba0a9002009-07-14 03:19:21 +00001159
Richard Smithad762fc2011-04-14 22:09:26 +00001160void ASTStmtReader::VisitCXXForRangeStmt(CXXForRangeStmt *S) {
1161 VisitStmt(S);
1162 S->setForLoc(ReadSourceLocation(Record, Idx));
1163 S->setColonLoc(ReadSourceLocation(Record, Idx));
1164 S->setRParenLoc(ReadSourceLocation(Record, Idx));
1165 S->setRangeStmt(Reader.ReadSubStmt());
1166 S->setBeginEndStmt(Reader.ReadSubStmt());
1167 S->setCond(Reader.ReadSubExpr());
1168 S->setInc(Reader.ReadSubExpr());
1169 S->setLoopVarStmt(Reader.ReadSubStmt());
1170 S->setBody(Reader.ReadSubStmt());
1171}
1172
Douglas Gregorba0513d2011-10-25 01:33:02 +00001173void ASTStmtReader::VisitMSDependentExistsStmt(MSDependentExistsStmt *S) {
1174 VisitStmt(S);
1175 S->KeywordLoc = ReadSourceLocation(Record, Idx);
1176 S->IsIfExists = Record[Idx++];
1177 S->QualifierLoc = Reader.ReadNestedNameSpecifierLoc(F, Record, Idx);
1178 ReadDeclarationNameInfo(S->NameInfo, Record, Idx);
1179 S->SubStmt = Reader.ReadSubStmt();
1180}
1181
Sebastian Redl60adf4a2010-08-18 23:56:52 +00001182void ASTStmtReader::VisitCXXOperatorCallExpr(CXXOperatorCallExpr *E) {
Argyrios Kyrtzidis919e6932010-06-28 22:28:35 +00001183 VisitCallExpr(E);
Argyrios Kyrtzidis4548ca22012-04-30 22:12:22 +00001184 E->Operator = (OverloadedOperatorKind)Record[Idx++];
1185 E->Range = Reader.ReadSourceRange(F, Record, Idx);
Lang Hamesbe9af122012-10-02 04:45:10 +00001186 E->setFPContractable((bool)Record[Idx++]);
Argyrios Kyrtzidisba0a9002009-07-14 03:19:21 +00001187}
1188
Sebastian Redl60adf4a2010-08-18 23:56:52 +00001189void ASTStmtReader::VisitCXXConstructExpr(CXXConstructExpr *E) {
Douglas Gregor39da0b82009-09-09 23:08:42 +00001190 VisitExpr(E);
Argyrios Kyrtzidis6d00c132010-07-10 11:46:15 +00001191 E->NumArgs = Record[Idx++];
1192 if (E->NumArgs)
Douglas Gregor35942772011-09-09 21:34:22 +00001193 E->Args = new (Reader.getContext()) Stmt*[E->NumArgs];
Argyrios Kyrtzidis5e1b7c22010-06-24 08:57:09 +00001194 for (unsigned I = 0, N = E->getNumArgs(); I != N; ++I)
Argyrios Kyrtzidisd98a2ab2010-06-29 22:46:25 +00001195 E->setArg(I, Reader.ReadSubExpr());
Douglas Gregor409448c2011-07-21 22:35:25 +00001196 E->setConstructor(ReadDeclAs<CXXConstructorDecl>(Record, Idx));
Sebastian Redlc3632732010-10-05 15:59:54 +00001197 E->setLocation(ReadSourceLocation(Record, Idx));
Abramo Bagnara7cc58b42011-10-05 07:56:41 +00001198 E->setElidable(Record[Idx++]);
1199 E->setHadMultipleCandidates(Record[Idx++]);
Richard Smithc83c2302012-12-19 01:39:02 +00001200 E->setListInitialization(Record[Idx++]);
Douglas Gregor16006c92009-12-16 18:50:27 +00001201 E->setRequiresZeroInitialization(Record[Idx++]);
Douglas Gregor3c9034c2010-05-15 00:13:29 +00001202 E->setConstructionKind((CXXConstructExpr::ConstructionKind)Record[Idx++]);
Enea Zaffanella1245a542013-09-07 05:49:53 +00001203 E->ParenOrBraceRange = ReadSourceRange(Record, Idx);
Douglas Gregor39da0b82009-09-09 23:08:42 +00001204}
Chris Lattner4c6f9522009-04-27 05:14:47 +00001205
Sebastian Redl60adf4a2010-08-18 23:56:52 +00001206void ASTStmtReader::VisitCXXTemporaryObjectExpr(CXXTemporaryObjectExpr *E) {
Argyrios Kyrtzidis6d00c132010-07-10 11:46:15 +00001207 VisitCXXConstructExpr(E);
Sebastian Redlc3632732010-10-05 15:59:54 +00001208 E->Type = GetTypeSourceInfo(Record, Idx);
Argyrios Kyrtzidis6d00c132010-07-10 11:46:15 +00001209}
1210
Douglas Gregor01d08012012-02-07 10:09:13 +00001211void ASTStmtReader::VisitLambdaExpr(LambdaExpr *E) {
1212 VisitExpr(E);
Douglas Gregor9d36f5d2012-02-14 17:54:36 +00001213 unsigned NumCaptures = Record[Idx++];
1214 assert(NumCaptures == E->NumCaptures);(void)NumCaptures;
1215 unsigned NumArrayIndexVars = Record[Idx++];
1216 E->IntroducerRange = ReadSourceRange(Record, Idx);
1217 E->CaptureDefault = static_cast<LambdaCaptureDefault>(Record[Idx++]);
James Dennettf68af642013-08-09 23:08:25 +00001218 E->CaptureDefaultLoc = ReadSourceLocation(Record, Idx);
Douglas Gregor9d36f5d2012-02-14 17:54:36 +00001219 E->ExplicitParams = Record[Idx++];
1220 E->ExplicitResultType = Record[Idx++];
1221 E->ClosingBrace = ReadSourceLocation(Record, Idx);
1222
1223 // Read capture initializers.
1224 for (LambdaExpr::capture_init_iterator C = E->capture_init_begin(),
1225 CEnd = E->capture_init_end();
1226 C != CEnd; ++C)
1227 *C = Reader.ReadSubExpr();
1228
1229 // Read array capture index variables.
1230 if (NumArrayIndexVars > 0) {
1231 unsigned *ArrayIndexStarts = E->getArrayIndexStarts();
1232 for (unsigned I = 0; I != NumCaptures + 1; ++I)
1233 ArrayIndexStarts[I] = Record[Idx++];
1234
1235 VarDecl **ArrayIndexVars = E->getArrayIndexVars();
1236 for (unsigned I = 0; I != NumArrayIndexVars; ++I)
1237 ArrayIndexVars[I] = ReadDeclAs<VarDecl>(Record, Idx);
1238 }
Douglas Gregor01d08012012-02-07 10:09:13 +00001239}
1240
Richard Smith7c3e6152013-06-12 22:31:48 +00001241void
1242ASTStmtReader::VisitCXXStdInitializerListExpr(CXXStdInitializerListExpr *E) {
1243 VisitExpr(E);
1244 E->SubExpr = Reader.ReadSubExpr();
1245}
1246
Sebastian Redl60adf4a2010-08-18 23:56:52 +00001247void ASTStmtReader::VisitCXXNamedCastExpr(CXXNamedCastExpr *E) {
Argyrios Kyrtzidis919e6932010-06-28 22:28:35 +00001248 VisitExplicitCastExpr(E);
Douglas Gregor1d5d0b92011-01-12 22:41:29 +00001249 SourceRange R = ReadSourceRange(Record, Idx);
1250 E->Loc = R.getBegin();
1251 E->RParenLoc = R.getEnd();
Fariborz Jahanianf799ae12013-02-22 22:02:53 +00001252 R = ReadSourceRange(Record, Idx);
1253 E->AngleBrackets = R;
Sam Weinigce757a72010-01-16 21:21:01 +00001254}
1255
Sebastian Redl60adf4a2010-08-18 23:56:52 +00001256void ASTStmtReader::VisitCXXStaticCastExpr(CXXStaticCastExpr *E) {
Sam Weinigce757a72010-01-16 21:21:01 +00001257 return VisitCXXNamedCastExpr(E);
1258}
1259
Sebastian Redl60adf4a2010-08-18 23:56:52 +00001260void ASTStmtReader::VisitCXXDynamicCastExpr(CXXDynamicCastExpr *E) {
Sam Weinigce757a72010-01-16 21:21:01 +00001261 return VisitCXXNamedCastExpr(E);
1262}
1263
Sebastian Redl60adf4a2010-08-18 23:56:52 +00001264void ASTStmtReader::VisitCXXReinterpretCastExpr(CXXReinterpretCastExpr *E) {
Sam Weinigce757a72010-01-16 21:21:01 +00001265 return VisitCXXNamedCastExpr(E);
1266}
1267
Sebastian Redl60adf4a2010-08-18 23:56:52 +00001268void ASTStmtReader::VisitCXXConstCastExpr(CXXConstCastExpr *E) {
Sam Weinigce757a72010-01-16 21:21:01 +00001269 return VisitCXXNamedCastExpr(E);
1270}
1271
Sebastian Redl60adf4a2010-08-18 23:56:52 +00001272void ASTStmtReader::VisitCXXFunctionalCastExpr(CXXFunctionalCastExpr *E) {
Argyrios Kyrtzidis919e6932010-06-28 22:28:35 +00001273 VisitExplicitCastExpr(E);
Eli Friedmancdd4b782013-08-15 22:02:56 +00001274 E->setLParenLoc(ReadSourceLocation(Record, Idx));
Sebastian Redlc3632732010-10-05 15:59:54 +00001275 E->setRParenLoc(ReadSourceLocation(Record, Idx));
Sam Weinigce757a72010-01-16 21:21:01 +00001276}
1277
Richard Smith9fcce652012-03-07 08:35:16 +00001278void ASTStmtReader::VisitUserDefinedLiteral(UserDefinedLiteral *E) {
1279 VisitCallExpr(E);
1280 E->UDSuffixLoc = ReadSourceLocation(Record, Idx);
1281}
1282
Sebastian Redl60adf4a2010-08-18 23:56:52 +00001283void ASTStmtReader::VisitCXXBoolLiteralExpr(CXXBoolLiteralExpr *E) {
Sam Weinigeb7f9612010-02-07 06:32:43 +00001284 VisitExpr(E);
1285 E->setValue(Record[Idx++]);
Sebastian Redlc3632732010-10-05 15:59:54 +00001286 E->setLocation(ReadSourceLocation(Record, Idx));
Sam Weinigeb7f9612010-02-07 06:32:43 +00001287}
1288
Sebastian Redl60adf4a2010-08-18 23:56:52 +00001289void ASTStmtReader::VisitCXXNullPtrLiteralExpr(CXXNullPtrLiteralExpr *E) {
Sam Weinigeb7f9612010-02-07 06:32:43 +00001290 VisitExpr(E);
Sebastian Redlc3632732010-10-05 15:59:54 +00001291 E->setLocation(ReadSourceLocation(Record, Idx));
Sam Weinigeb7f9612010-02-07 06:32:43 +00001292}
1293
Sebastian Redl60adf4a2010-08-18 23:56:52 +00001294void ASTStmtReader::VisitCXXTypeidExpr(CXXTypeidExpr *E) {
Chris Lattner14ab24f2010-05-09 06:03:39 +00001295 VisitExpr(E);
Sebastian Redlc3632732010-10-05 15:59:54 +00001296 E->setSourceRange(ReadSourceRange(Record, Idx));
Chris Lattner14ab24f2010-05-09 06:03:39 +00001297 if (E->isTypeOperand()) { // typeid(int)
Sebastian Redl577d4792010-07-22 22:43:28 +00001298 E->setTypeOperandSourceInfo(
Sebastian Redlc3632732010-10-05 15:59:54 +00001299 GetTypeSourceInfo(Record, Idx));
Argyrios Kyrtzidis919e6932010-06-28 22:28:35 +00001300 return;
Chris Lattner14ab24f2010-05-09 06:03:39 +00001301 }
1302
1303 // typeid(42+2)
Argyrios Kyrtzidisd98a2ab2010-06-29 22:46:25 +00001304 E->setExprOperand(Reader.ReadSubExpr());
Chris Lattner14ab24f2010-05-09 06:03:39 +00001305}
1306
Sebastian Redl60adf4a2010-08-18 23:56:52 +00001307void ASTStmtReader::VisitCXXThisExpr(CXXThisExpr *E) {
Chris Lattner2fbdfcd2010-05-09 06:15:05 +00001308 VisitExpr(E);
Sebastian Redlc3632732010-10-05 15:59:54 +00001309 E->setLocation(ReadSourceLocation(Record, Idx));
Chris Lattner2fbdfcd2010-05-09 06:15:05 +00001310 E->setImplicit(Record[Idx++]);
Chris Lattner2fbdfcd2010-05-09 06:15:05 +00001311}
1312
Sebastian Redl60adf4a2010-08-18 23:56:52 +00001313void ASTStmtReader::VisitCXXThrowExpr(CXXThrowExpr *E) {
Chris Lattner2fbdfcd2010-05-09 06:15:05 +00001314 VisitExpr(E);
Douglas Gregorbca01b42011-07-06 22:04:06 +00001315 E->ThrowLoc = ReadSourceLocation(Record, Idx);
1316 E->Op = Reader.ReadSubExpr();
1317 E->IsThrownVariableInScope = Record[Idx++];
Chris Lattner2fbdfcd2010-05-09 06:15:05 +00001318}
Chris Lattner14ab24f2010-05-09 06:03:39 +00001319
Sebastian Redl60adf4a2010-08-18 23:56:52 +00001320void ASTStmtReader::VisitCXXDefaultArgExpr(CXXDefaultArgExpr *E) {
Chris Lattner030854b2010-05-09 06:40:08 +00001321 VisitExpr(E);
Argyrios Kyrtzidis8a507332010-07-02 23:30:15 +00001322
Douglas Gregordf226552011-09-23 22:07:41 +00001323 assert((bool)Record[Idx] == E->Param.getInt() && "We messed up at creation ?");
Argyrios Kyrtzidis8a507332010-07-02 23:30:15 +00001324 ++Idx; // HasOtherExprStored and SubExpr was handled during creation.
Douglas Gregor409448c2011-07-21 22:35:25 +00001325 E->Param.setPointer(ReadDeclAs<ParmVarDecl>(Record, Idx));
Sebastian Redlc3632732010-10-05 15:59:54 +00001326 E->Loc = ReadSourceLocation(Record, Idx);
Chris Lattnerd2598362010-05-10 00:25:06 +00001327}
1328
Richard Smithc3bf52c2013-04-20 22:23:05 +00001329void ASTStmtReader::VisitCXXDefaultInitExpr(CXXDefaultInitExpr *E) {
1330 VisitExpr(E);
1331 E->Field = ReadDeclAs<FieldDecl>(Record, Idx);
1332 E->Loc = ReadSourceLocation(Record, Idx);
1333}
1334
Sebastian Redl60adf4a2010-08-18 23:56:52 +00001335void ASTStmtReader::VisitCXXBindTemporaryExpr(CXXBindTemporaryExpr *E) {
Chris Lattnerd2598362010-05-10 00:25:06 +00001336 VisitExpr(E);
Douglas Gregor409448c2011-07-21 22:35:25 +00001337 E->setTemporary(Reader.ReadCXXTemporary(F, Record, Idx));
Argyrios Kyrtzidisd98a2ab2010-06-29 22:46:25 +00001338 E->setSubExpr(Reader.ReadSubExpr());
Chris Lattnerd2598362010-05-10 00:25:06 +00001339}
1340
Sebastian Redl60adf4a2010-08-18 23:56:52 +00001341void ASTStmtReader::VisitCXXScalarValueInitExpr(CXXScalarValueInitExpr *E) {
Chris Lattner59218632010-05-10 01:22:27 +00001342 VisitExpr(E);
Sebastian Redlc3632732010-10-05 15:59:54 +00001343 E->TypeInfo = GetTypeSourceInfo(Record, Idx);
1344 E->RParenLoc = ReadSourceLocation(Record, Idx);
Chris Lattner59218632010-05-10 01:22:27 +00001345}
1346
Sebastian Redl60adf4a2010-08-18 23:56:52 +00001347void ASTStmtReader::VisitCXXNewExpr(CXXNewExpr *E) {
Chris Lattner59218632010-05-10 01:22:27 +00001348 VisitExpr(E);
John McCall6ec278d2011-01-27 09:37:56 +00001349 E->GlobalNew = Record[Idx++];
Sebastian Redl1548d142012-02-16 11:35:52 +00001350 bool isArray = Record[Idx++];
Sebastian Redl2aed8b82012-02-16 12:22:20 +00001351 E->UsualArrayDeleteWantsSize = Record[Idx++];
Chris Lattner59218632010-05-10 01:22:27 +00001352 unsigned NumPlacementArgs = Record[Idx++];
Sebastian Redl2aed8b82012-02-16 12:22:20 +00001353 E->StoredInitializationStyle = Record[Idx++];
Douglas Gregor409448c2011-07-21 22:35:25 +00001354 E->setOperatorNew(ReadDeclAs<FunctionDecl>(Record, Idx));
1355 E->setOperatorDelete(ReadDeclAs<FunctionDecl>(Record, Idx));
Sebastian Redlc3632732010-10-05 15:59:54 +00001356 E->AllocatedTypeInfo = GetTypeSourceInfo(Record, Idx);
Douglas Gregor83bc2762012-02-20 16:12:14 +00001357 E->TypeIdParens = ReadSourceRange(Record, Idx);
David Blaikie53056412012-11-07 00:12:38 +00001358 E->Range = ReadSourceRange(Record, Idx);
Douglas Gregor83bc2762012-02-20 16:12:14 +00001359 E->DirectInitRange = ReadSourceRange(Record, Idx);
Chandler Carruth428edaf2010-10-25 08:47:36 +00001360
Douglas Gregor35942772011-09-09 21:34:22 +00001361 E->AllocateArgsArray(Reader.getContext(), isArray, NumPlacementArgs,
Sebastian Redl2aed8b82012-02-16 12:22:20 +00001362 E->StoredInitializationStyle != 0);
Chris Lattner59218632010-05-10 01:22:27 +00001363
1364 // Install all the subexpressions.
Chris Lattner59218632010-05-10 01:22:27 +00001365 for (CXXNewExpr::raw_arg_iterator I = E->raw_arg_begin(),e = E->raw_arg_end();
1366 I != e; ++I)
Argyrios Kyrtzidisd98a2ab2010-06-29 22:46:25 +00001367 *I = Reader.ReadSubStmt();
Chris Lattner59218632010-05-10 01:22:27 +00001368}
1369
Sebastian Redl60adf4a2010-08-18 23:56:52 +00001370void ASTStmtReader::VisitCXXDeleteExpr(CXXDeleteExpr *E) {
Argyrios Kyrtzidis95fc98c2010-06-22 17:07:59 +00001371 VisitExpr(E);
Argyrios Kyrtzidisf1b89112010-09-13 20:15:40 +00001372 E->GlobalDelete = Record[Idx++];
1373 E->ArrayForm = Record[Idx++];
Argyrios Kyrtzidis4076dac2010-09-13 20:15:54 +00001374 E->ArrayFormAsWritten = Record[Idx++];
John McCall6ec278d2011-01-27 09:37:56 +00001375 E->UsualArrayDeleteWantsSize = Record[Idx++];
Douglas Gregor409448c2011-07-21 22:35:25 +00001376 E->OperatorDelete = ReadDeclAs<FunctionDecl>(Record, Idx);
Argyrios Kyrtzidisf1b89112010-09-13 20:15:40 +00001377 E->Argument = Reader.ReadSubExpr();
Sebastian Redlc3632732010-10-05 15:59:54 +00001378 E->Loc = ReadSourceLocation(Record, Idx);
Argyrios Kyrtzidis95fc98c2010-06-22 17:07:59 +00001379}
Chris Lattnerd2598362010-05-10 00:25:06 +00001380
Sebastian Redl60adf4a2010-08-18 23:56:52 +00001381void ASTStmtReader::VisitCXXPseudoDestructorExpr(CXXPseudoDestructorExpr *E) {
Argyrios Kyrtzidisde4bd182010-06-28 09:32:03 +00001382 VisitExpr(E);
1383
Douglas Gregorf3db29f2011-02-25 18:19:59 +00001384 E->Base = Reader.ReadSubExpr();
1385 E->IsArrow = Record[Idx++];
1386 E->OperatorLoc = ReadSourceLocation(Record, Idx);
1387 E->QualifierLoc = Reader.ReadNestedNameSpecifierLoc(F, Record, Idx);
1388 E->ScopeType = GetTypeSourceInfo(Record, Idx);
1389 E->ColonColonLoc = ReadSourceLocation(Record, Idx);
1390 E->TildeLoc = ReadSourceLocation(Record, Idx);
Argyrios Kyrtzidisde4bd182010-06-28 09:32:03 +00001391
Douglas Gregor95eab172011-07-28 20:55:49 +00001392 IdentifierInfo *II = Reader.GetIdentifierInfo(F, Record, Idx);
Argyrios Kyrtzidisde4bd182010-06-28 09:32:03 +00001393 if (II)
Sebastian Redlc3632732010-10-05 15:59:54 +00001394 E->setDestroyedType(II, ReadSourceLocation(Record, Idx));
Argyrios Kyrtzidisde4bd182010-06-28 09:32:03 +00001395 else
Sebastian Redlc3632732010-10-05 15:59:54 +00001396 E->setDestroyedType(GetTypeSourceInfo(Record, Idx));
Argyrios Kyrtzidisde4bd182010-06-28 09:32:03 +00001397}
1398
John McCall4765fa02010-12-06 08:20:24 +00001399void ASTStmtReader::VisitExprWithCleanups(ExprWithCleanups *E) {
Chris Lattnerd2598362010-05-10 00:25:06 +00001400 VisitExpr(E);
John McCall80ee6e82011-11-10 05:35:25 +00001401
1402 unsigned NumObjects = Record[Idx++];
1403 assert(NumObjects == E->getNumObjects());
1404 for (unsigned i = 0; i != NumObjects; ++i)
1405 E->getObjectsBuffer()[i] = ReadDeclAs<BlockDecl>(Record, Idx);
1406
1407 E->SubExpr = Reader.ReadSubExpr();
Chris Lattner030854b2010-05-09 06:40:08 +00001408}
1409
Argyrios Kyrtzidis919e6932010-06-28 22:28:35 +00001410void
Sebastian Redl60adf4a2010-08-18 23:56:52 +00001411ASTStmtReader::VisitCXXDependentScopeMemberExpr(CXXDependentScopeMemberExpr *E){
Argyrios Kyrtzidis8dfbd8b2010-06-24 08:57:31 +00001412 VisitExpr(E);
Abramo Bagnarae4b92762012-01-27 09:46:47 +00001413
1414 if (Record[Idx++]) // HasTemplateKWAndArgsInfo
1415 ReadTemplateKWAndArgsInfo(*E->getTemplateKWAndArgsInfo(),
1416 /*NumTemplateArgs=*/Record[Idx++]);
Argyrios Kyrtzidis8dfbd8b2010-06-24 08:57:31 +00001417
Douglas Gregor7c3179c2011-02-28 18:50:33 +00001418 E->Base = Reader.ReadSubExpr();
Douglas Gregor393f2492011-07-22 00:38:23 +00001419 E->BaseType = Reader.readType(F, Record, Idx);
Douglas Gregor7c3179c2011-02-28 18:50:33 +00001420 E->IsArrow = Record[Idx++];
1421 E->OperatorLoc = ReadSourceLocation(Record, Idx);
1422 E->QualifierLoc = Reader.ReadNestedNameSpecifierLoc(F, Record, Idx);
Douglas Gregor409448c2011-07-21 22:35:25 +00001423 E->FirstQualifierFoundInScope = ReadDeclAs<NamedDecl>(Record, Idx);
Argyrios Kyrtzidis40451072010-10-15 18:21:24 +00001424 ReadDeclarationNameInfo(E->MemberNameInfo, Record, Idx);
Argyrios Kyrtzidis8dfbd8b2010-06-24 08:57:31 +00001425}
1426
Argyrios Kyrtzidis919e6932010-06-28 22:28:35 +00001427void
Sebastian Redl60adf4a2010-08-18 23:56:52 +00001428ASTStmtReader::VisitDependentScopeDeclRefExpr(DependentScopeDeclRefExpr *E) {
Argyrios Kyrtzidis12dffcd2010-06-28 09:31:56 +00001429 VisitExpr(E);
Abramo Bagnarae4b92762012-01-27 09:46:47 +00001430
1431 if (Record[Idx++]) // HasTemplateKWAndArgsInfo
1432 ReadTemplateKWAndArgsInfo(*E->getTemplateKWAndArgsInfo(),
1433 /*NumTemplateArgs=*/Record[Idx++]);
Douglas Gregor00cf3cc2011-02-25 20:49:16 +00001434
1435 E->QualifierLoc = Reader.ReadNestedNameSpecifierLoc(F, Record, Idx);
Argyrios Kyrtzidis40451072010-10-15 18:21:24 +00001436 ReadDeclarationNameInfo(E->NameInfo, Record, Idx);
Argyrios Kyrtzidis12dffcd2010-06-28 09:31:56 +00001437}
1438
Argyrios Kyrtzidis919e6932010-06-28 22:28:35 +00001439void
Sebastian Redl60adf4a2010-08-18 23:56:52 +00001440ASTStmtReader::VisitCXXUnresolvedConstructExpr(CXXUnresolvedConstructExpr *E) {
Argyrios Kyrtzidis8dfbd8b2010-06-24 08:57:31 +00001441 VisitExpr(E);
1442 assert(Record[Idx] == E->arg_size() && "Read wrong record during creation ?");
1443 ++Idx; // NumArgs;
1444 for (unsigned I = 0, N = E->arg_size(); I != N; ++I)
Argyrios Kyrtzidisd98a2ab2010-06-29 22:46:25 +00001445 E->setArg(I, Reader.ReadSubExpr());
Sebastian Redlc3632732010-10-05 15:59:54 +00001446 E->Type = GetTypeSourceInfo(Record, Idx);
1447 E->setLParenLoc(ReadSourceLocation(Record, Idx));
1448 E->setRParenLoc(ReadSourceLocation(Record, Idx));
Argyrios Kyrtzidis8dfbd8b2010-06-24 08:57:31 +00001449}
1450
Sebastian Redl60adf4a2010-08-18 23:56:52 +00001451void ASTStmtReader::VisitOverloadExpr(OverloadExpr *E) {
Argyrios Kyrtzidisa77eb082010-06-25 09:03:26 +00001452 VisitExpr(E);
Abramo Bagnarae4b92762012-01-27 09:46:47 +00001453
1454 if (Record[Idx++]) // HasTemplateKWAndArgsInfo
1455 ReadTemplateKWAndArgsInfo(*E->getTemplateKWAndArgsInfo(),
1456 /*NumTemplateArgs=*/Record[Idx++]);
Argyrios Kyrtzidisa77eb082010-06-25 09:03:26 +00001457
1458 unsigned NumDecls = Record[Idx++];
1459 UnresolvedSet<8> Decls;
1460 for (unsigned i = 0; i != NumDecls; ++i) {
Douglas Gregor409448c2011-07-21 22:35:25 +00001461 NamedDecl *D = ReadDeclAs<NamedDecl>(Record, Idx);
Argyrios Kyrtzidisa77eb082010-06-25 09:03:26 +00001462 AccessSpecifier AS = (AccessSpecifier)Record[Idx++];
1463 Decls.addDecl(D, AS);
1464 }
Douglas Gregor35942772011-09-09 21:34:22 +00001465 E->initializeResults(Reader.getContext(), Decls.begin(), Decls.end());
Argyrios Kyrtzidisa77eb082010-06-25 09:03:26 +00001466
Argyrios Kyrtzidis40451072010-10-15 18:21:24 +00001467 ReadDeclarationNameInfo(E->NameInfo, Record, Idx);
Douglas Gregor4c9be892011-02-28 20:01:57 +00001468 E->QualifierLoc = Reader.ReadNestedNameSpecifierLoc(F, Record, Idx);
Argyrios Kyrtzidisa77eb082010-06-25 09:03:26 +00001469}
1470
Sebastian Redl60adf4a2010-08-18 23:56:52 +00001471void ASTStmtReader::VisitUnresolvedMemberExpr(UnresolvedMemberExpr *E) {
Argyrios Kyrtzidis919e6932010-06-28 22:28:35 +00001472 VisitOverloadExpr(E);
Douglas Gregor4c9be892011-02-28 20:01:57 +00001473 E->IsArrow = Record[Idx++];
1474 E->HasUnresolvedUsing = Record[Idx++];
1475 E->Base = Reader.ReadSubExpr();
Douglas Gregor393f2492011-07-22 00:38:23 +00001476 E->BaseType = Reader.readType(F, Record, Idx);
Douglas Gregor4c9be892011-02-28 20:01:57 +00001477 E->OperatorLoc = ReadSourceLocation(Record, Idx);
Argyrios Kyrtzidisa77eb082010-06-25 09:03:26 +00001478}
1479
Sebastian Redl60adf4a2010-08-18 23:56:52 +00001480void ASTStmtReader::VisitUnresolvedLookupExpr(UnresolvedLookupExpr *E) {
Argyrios Kyrtzidis919e6932010-06-28 22:28:35 +00001481 VisitOverloadExpr(E);
Douglas Gregor4c9be892011-02-28 20:01:57 +00001482 E->RequiresADL = Record[Idx++];
1483 E->Overloaded = Record[Idx++];
Douglas Gregor409448c2011-07-21 22:35:25 +00001484 E->NamingClass = ReadDeclAs<CXXRecordDecl>(Record, Idx);
Argyrios Kyrtzidisbd65bb52010-06-25 09:03:34 +00001485}
1486
Sebastian Redl60adf4a2010-08-18 23:56:52 +00001487void ASTStmtReader::VisitUnaryTypeTraitExpr(UnaryTypeTraitExpr *E) {
Argyrios Kyrtzidis6d00c132010-07-10 11:46:15 +00001488 VisitExpr(E);
1489 E->UTT = (UnaryTypeTrait)Record[Idx++];
Sebastian Redl0dfd8482010-09-13 20:56:31 +00001490 E->Value = (bool)Record[Idx++];
Sebastian Redlc3632732010-10-05 15:59:54 +00001491 SourceRange Range = ReadSourceRange(Record, Idx);
Argyrios Kyrtzidis6d00c132010-07-10 11:46:15 +00001492 E->Loc = Range.getBegin();
1493 E->RParen = Range.getEnd();
Sebastian Redlc3632732010-10-05 15:59:54 +00001494 E->QueriedType = GetTypeSourceInfo(Record, Idx);
Argyrios Kyrtzidis6d00c132010-07-10 11:46:15 +00001495}
1496
Francois Pichet6ad6f282010-12-07 00:08:36 +00001497void ASTStmtReader::VisitBinaryTypeTraitExpr(BinaryTypeTraitExpr *E) {
1498 VisitExpr(E);
1499 E->BTT = (BinaryTypeTrait)Record[Idx++];
1500 E->Value = (bool)Record[Idx++];
1501 SourceRange Range = ReadSourceRange(Record, Idx);
1502 E->Loc = Range.getBegin();
1503 E->RParen = Range.getEnd();
1504 E->LhsType = GetTypeSourceInfo(Record, Idx);
1505 E->RhsType = GetTypeSourceInfo(Record, Idx);
1506}
1507
Douglas Gregor4ca8ac22012-02-24 07:38:34 +00001508void ASTStmtReader::VisitTypeTraitExpr(TypeTraitExpr *E) {
1509 VisitExpr(E);
1510 E->TypeTraitExprBits.NumArgs = Record[Idx++];
1511 E->TypeTraitExprBits.Kind = Record[Idx++];
1512 E->TypeTraitExprBits.Value = Record[Idx++];
1513
1514 TypeSourceInfo **Args = E->getTypeSourceInfos();
1515 for (unsigned I = 0, N = E->getNumArgs(); I != N; ++I)
1516 Args[I] = GetTypeSourceInfo(Record, Idx);
1517}
1518
John Wiegley21ff2e52011-04-28 00:16:57 +00001519void ASTStmtReader::VisitArrayTypeTraitExpr(ArrayTypeTraitExpr *E) {
1520 VisitExpr(E);
1521 E->ATT = (ArrayTypeTrait)Record[Idx++];
1522 E->Value = (unsigned int)Record[Idx++];
1523 SourceRange Range = ReadSourceRange(Record, Idx);
1524 E->Loc = Range.getBegin();
1525 E->RParen = Range.getEnd();
1526 E->QueriedType = GetTypeSourceInfo(Record, Idx);
1527}
1528
John Wiegley55262202011-04-25 06:54:41 +00001529void ASTStmtReader::VisitExpressionTraitExpr(ExpressionTraitExpr *E) {
1530 VisitExpr(E);
1531 E->ET = (ExpressionTrait)Record[Idx++];
1532 E->Value = (bool)Record[Idx++];
1533 SourceRange Range = ReadSourceRange(Record, Idx);
1534 E->QueriedExpression = Reader.ReadSubExpr();
1535 E->Loc = Range.getBegin();
1536 E->RParen = Range.getEnd();
1537}
1538
Sebastian Redl6b219d02010-09-10 20:55:54 +00001539void ASTStmtReader::VisitCXXNoexceptExpr(CXXNoexceptExpr *E) {
1540 VisitExpr(E);
Sebastian Redl5221d8f2010-09-10 22:34:40 +00001541 E->Value = (bool)Record[Idx++];
Sebastian Redlc3632732010-10-05 15:59:54 +00001542 E->Range = ReadSourceRange(Record, Idx);
Sebastian Redl5221d8f2010-09-10 22:34:40 +00001543 E->Operand = Reader.ReadSubExpr();
Sebastian Redl6b219d02010-09-10 20:55:54 +00001544}
1545
Douglas Gregorbe230c32011-01-03 17:17:50 +00001546void ASTStmtReader::VisitPackExpansionExpr(PackExpansionExpr *E) {
1547 VisitExpr(E);
1548 E->EllipsisLoc = ReadSourceLocation(Record, Idx);
Douglas Gregor67fd1252011-01-14 21:20:45 +00001549 E->NumExpansions = Record[Idx++];
Douglas Gregorbe230c32011-01-03 17:17:50 +00001550 E->Pattern = Reader.ReadSubExpr();
1551}
1552
Douglas Gregoree8aff02011-01-04 17:33:58 +00001553void ASTStmtReader::VisitSizeOfPackExpr(SizeOfPackExpr *E) {
1554 VisitExpr(E);
1555 E->OperatorLoc = ReadSourceLocation(Record, Idx);
1556 E->PackLoc = ReadSourceLocation(Record, Idx);
1557 E->RParenLoc = ReadSourceLocation(Record, Idx);
1558 E->Length = Record[Idx++];
Douglas Gregor409448c2011-07-21 22:35:25 +00001559 E->Pack = ReadDeclAs<NamedDecl>(Record, Idx);
Douglas Gregoree8aff02011-01-04 17:33:58 +00001560}
1561
John McCall7110fd62011-07-15 07:00:14 +00001562void ASTStmtReader::VisitSubstNonTypeTemplateParmExpr(
1563 SubstNonTypeTemplateParmExpr *E) {
1564 VisitExpr(E);
Douglas Gregor409448c2011-07-21 22:35:25 +00001565 E->Param = ReadDeclAs<NonTypeTemplateParmDecl>(Record, Idx);
John McCall7110fd62011-07-15 07:00:14 +00001566 E->NameLoc = ReadSourceLocation(Record, Idx);
1567 E->Replacement = Reader.ReadSubExpr();
1568}
1569
Douglas Gregorc7793c72011-01-15 01:15:58 +00001570void ASTStmtReader::VisitSubstNonTypeTemplateParmPackExpr(
1571 SubstNonTypeTemplateParmPackExpr *E) {
1572 VisitExpr(E);
Douglas Gregor409448c2011-07-21 22:35:25 +00001573 E->Param = ReadDeclAs<NonTypeTemplateParmDecl>(Record, Idx);
Douglas Gregorc7793c72011-01-15 01:15:58 +00001574 TemplateArgument ArgPack = Reader.ReadTemplateArgument(F, Record, Idx);
1575 if (ArgPack.getKind() != TemplateArgument::Pack)
1576 return;
1577
1578 E->Arguments = ArgPack.pack_begin();
1579 E->NumArguments = ArgPack.pack_size();
1580 E->NameLoc = ReadSourceLocation(Record, Idx);
1581}
1582
Richard Smith9a4db032012-09-12 00:56:43 +00001583void ASTStmtReader::VisitFunctionParmPackExpr(FunctionParmPackExpr *E) {
1584 VisitExpr(E);
1585 E->NumParameters = Record[Idx++];
1586 E->ParamPack = ReadDeclAs<ParmVarDecl>(Record, Idx);
1587 E->NameLoc = ReadSourceLocation(Record, Idx);
1588 ParmVarDecl **Parms = reinterpret_cast<ParmVarDecl**>(E+1);
1589 for (unsigned i = 0, n = E->NumParameters; i != n; ++i)
1590 Parms[i] = ReadDeclAs<ParmVarDecl>(Record, Idx);
1591}
1592
Douglas Gregor03e80032011-06-21 17:03:29 +00001593void ASTStmtReader::VisitMaterializeTemporaryExpr(MaterializeTemporaryExpr *E) {
1594 VisitExpr(E);
1595 E->Temporary = Reader.ReadSubExpr();
Richard Smith211c8dd2013-06-05 00:46:14 +00001596 E->ExtendingDecl = ReadDeclAs<ValueDecl>(Record, Idx);
Douglas Gregor03e80032011-06-21 17:03:29 +00001597}
1598
John McCall7cd7d1a2010-11-15 23:31:06 +00001599void ASTStmtReader::VisitOpaqueValueExpr(OpaqueValueExpr *E) {
1600 VisitExpr(E);
Argyrios Kyrtzidis8bc27822011-12-03 03:49:52 +00001601 E->SourceExpr = Reader.ReadSubExpr();
Douglas Gregorb608b982011-01-28 02:26:04 +00001602 E->Loc = ReadSourceLocation(Record, Idx);
John McCall7cd7d1a2010-11-15 23:31:06 +00001603}
1604
Peter Collingbournee08ce652011-02-09 21:07:24 +00001605//===----------------------------------------------------------------------===//
John McCall7110fd62011-07-15 07:00:14 +00001606// Microsoft Expressions and Statements
1607//===----------------------------------------------------------------------===//
John McCall76da55d2013-04-16 07:28:30 +00001608void ASTStmtReader::VisitMSPropertyRefExpr(MSPropertyRefExpr *E) {
1609 VisitExpr(E);
1610 E->IsArrow = (Record[Idx++] != 0);
1611 E->BaseExpr = Reader.ReadSubExpr();
1612 E->QualifierLoc = Reader.ReadNestedNameSpecifierLoc(F, Record, Idx);
1613 E->MemberLoc = ReadSourceLocation(Record, Idx);
1614 E->TheDecl = ReadDeclAs<MSPropertyDecl>(Record, Idx);
1615}
1616
John McCall7110fd62011-07-15 07:00:14 +00001617void ASTStmtReader::VisitCXXUuidofExpr(CXXUuidofExpr *E) {
1618 VisitExpr(E);
1619 E->setSourceRange(ReadSourceRange(Record, Idx));
1620 if (E->isTypeOperand()) { // __uuidof(ComType)
1621 E->setTypeOperandSourceInfo(
1622 GetTypeSourceInfo(Record, Idx));
1623 return;
1624 }
1625
1626 // __uuidof(expr)
1627 E->setExprOperand(Reader.ReadSubExpr());
1628}
1629
1630void ASTStmtReader::VisitSEHExceptStmt(SEHExceptStmt *S) {
1631 VisitStmt(S);
1632 S->Loc = ReadSourceLocation(Record, Idx);
1633 S->Children[SEHExceptStmt::FILTER_EXPR] = Reader.ReadSubStmt();
1634 S->Children[SEHExceptStmt::BLOCK] = Reader.ReadSubStmt();
1635}
1636
1637void ASTStmtReader::VisitSEHFinallyStmt(SEHFinallyStmt *S) {
1638 VisitStmt(S);
1639 S->Loc = ReadSourceLocation(Record, Idx);
1640 S->Block = Reader.ReadSubStmt();
1641}
1642
1643void ASTStmtReader::VisitSEHTryStmt(SEHTryStmt *S) {
1644 VisitStmt(S);
1645 S->IsCXXTry = Record[Idx++];
1646 S->TryLoc = ReadSourceLocation(Record, Idx);
1647 S->Children[SEHTryStmt::TRY] = Reader.ReadSubStmt();
1648 S->Children[SEHTryStmt::HANDLER] = Reader.ReadSubStmt();
1649}
1650
1651//===----------------------------------------------------------------------===//
Peter Collingbournee08ce652011-02-09 21:07:24 +00001652// CUDA Expressions and Statements
1653//===----------------------------------------------------------------------===//
1654
1655void ASTStmtReader::VisitCUDAKernelCallExpr(CUDAKernelCallExpr *E) {
1656 VisitCallExpr(E);
1657 E->setConfig(cast<CallExpr>(Reader.ReadSubExpr()));
1658}
1659
John McCall7110fd62011-07-15 07:00:14 +00001660//===----------------------------------------------------------------------===//
1661// OpenCL Expressions and Statements.
1662//===----------------------------------------------------------------------===//
1663void ASTStmtReader::VisitAsTypeExpr(AsTypeExpr *E) {
1664 VisitExpr(E);
1665 E->BuiltinLoc = ReadSourceLocation(Record, Idx);
1666 E->RParenLoc = ReadSourceLocation(Record, Idx);
1667 E->SrcExpr = Reader.ReadSubExpr();
1668}
1669
1670//===----------------------------------------------------------------------===//
Alexey Bataev4fa7eab2013-07-19 03:13:43 +00001671// OpenMP Clauses.
1672//===----------------------------------------------------------------------===//
1673
1674namespace clang {
1675class OMPClauseReader : public OMPClauseVisitor<OMPClauseReader> {
1676 ASTStmtReader *Reader;
1677 ASTContext &Context;
1678 const ASTReader::RecordData &Record;
1679 unsigned &Idx;
1680public:
1681 OMPClauseReader(ASTStmtReader *R, ASTContext &C,
1682 const ASTReader::RecordData &Record, unsigned &Idx)
1683 : Reader(R), Context(C), Record(Record), Idx(Idx) { }
1684#define OPENMP_CLAUSE(Name, Class) \
1685 void Visit##Class(Class *S);
1686#include "clang/Basic/OpenMPKinds.def"
1687 OMPClause *readClause();
1688};
1689}
1690
1691OMPClause *OMPClauseReader::readClause() {
1692 OMPClause *C;
1693 switch (Record[Idx++]) {
1694 case OMPC_default:
1695 C = new (Context) OMPDefaultClause();
1696 break;
1697 case OMPC_private:
1698 C = OMPPrivateClause::CreateEmpty(Context, Record[Idx++]);
1699 break;
Alexey Bataev0c018352013-09-06 18:03:48 +00001700 case OMPC_shared:
1701 C = OMPSharedClause::CreateEmpty(Context, Record[Idx++]);
1702 break;
Alexey Bataev4fa7eab2013-07-19 03:13:43 +00001703 }
1704 Visit(C);
1705 C->setLocStart(Reader->ReadSourceLocation(Record, Idx));
1706 C->setLocEnd(Reader->ReadSourceLocation(Record, Idx));
1707
1708 return C;
1709}
1710
1711void OMPClauseReader::VisitOMPDefaultClause(OMPDefaultClause *C) {
1712 C->setDefaultKind(
1713 static_cast<OpenMPDefaultClauseKind>(Record[Idx++]));
1714 C->setLParenLoc(Reader->ReadSourceLocation(Record, Idx));
1715 C->setDefaultKindKwLoc(Reader->ReadSourceLocation(Record, Idx));
1716}
1717
1718void OMPClauseReader::VisitOMPPrivateClause(OMPPrivateClause *C) {
1719 C->setLParenLoc(Reader->ReadSourceLocation(Record, Idx));
1720 unsigned NumVars = C->varlist_size();
1721 SmallVector<Expr *, 16> Vars;
1722 Vars.reserve(NumVars);
1723 for (unsigned i = 0; i != NumVars; ++i)
1724 Vars.push_back(Reader->Reader.ReadSubExpr());
1725 C->setVarRefs(Vars);
1726}
1727
Alexey Bataev0c018352013-09-06 18:03:48 +00001728void OMPClauseReader::VisitOMPSharedClause(OMPSharedClause *C) {
1729 C->setLParenLoc(Reader->ReadSourceLocation(Record, Idx));
1730 unsigned NumVars = C->varlist_size();
1731 SmallVector<Expr *, 16> Vars;
1732 Vars.reserve(NumVars);
1733 for (unsigned i = 0; i != NumVars; ++i)
1734 Vars.push_back(Reader->Reader.ReadSubExpr());
1735 C->setVarRefs(Vars);
1736}
1737
Alexey Bataev4fa7eab2013-07-19 03:13:43 +00001738//===----------------------------------------------------------------------===//
1739// OpenMP Directives.
1740//===----------------------------------------------------------------------===//
1741void ASTStmtReader::VisitOMPExecutableDirective(OMPExecutableDirective *E) {
1742 VisitStmt(E);
1743 ++Idx;
1744 E->setLocStart(ReadSourceLocation(Record, Idx));
1745 E->setLocEnd(ReadSourceLocation(Record, Idx));
1746 OMPClauseReader ClauseReader(this, Reader.getContext(), Record, Idx);
1747 SmallVector<OMPClause *, 5> Clauses;
1748 for (unsigned i = 0; i < E->getNumClauses(); ++i)
1749 Clauses.push_back(ClauseReader.readClause());
1750 E->setClauses(Clauses);
1751 E->setAssociatedStmt(Reader.ReadSubStmt());
1752}
1753
1754void ASTStmtReader::VisitOMPParallelDirective(OMPParallelDirective *D) {
1755 VisitOMPExecutableDirective(D);
1756}
1757
1758//===----------------------------------------------------------------------===//
John McCall7110fd62011-07-15 07:00:14 +00001759// ASTReader Implementation
1760//===----------------------------------------------------------------------===//
1761
Douglas Gregor1a4761e2011-11-30 23:21:26 +00001762Stmt *ASTReader::ReadStmt(ModuleFile &F) {
Argyrios Kyrtzidis919e6932010-06-28 22:28:35 +00001763 switch (ReadingKind) {
Richard Smithafb90df2013-07-31 00:26:46 +00001764 case Read_None:
1765 llvm_unreachable("should not call this when not reading anything");
Argyrios Kyrtzidis919e6932010-06-28 22:28:35 +00001766 case Read_Decl:
1767 case Read_Type:
Sebastian Redlc3632732010-10-05 15:59:54 +00001768 return ReadStmtFromStream(F);
Argyrios Kyrtzidis919e6932010-06-28 22:28:35 +00001769 case Read_Stmt:
Argyrios Kyrtzidisd98a2ab2010-06-29 22:46:25 +00001770 return ReadSubStmt();
Argyrios Kyrtzidis919e6932010-06-28 22:28:35 +00001771 }
1772
1773 llvm_unreachable("ReadingKind not set ?");
Argyrios Kyrtzidis919e6932010-06-28 22:28:35 +00001774}
1775
Douglas Gregor1a4761e2011-11-30 23:21:26 +00001776Expr *ASTReader::ReadExpr(ModuleFile &F) {
Sebastian Redlc3632732010-10-05 15:59:54 +00001777 return cast_or_null<Expr>(ReadStmt(F));
Argyrios Kyrtzidis919e6932010-06-28 22:28:35 +00001778}
Chris Lattner030854b2010-05-09 06:40:08 +00001779
Sebastian Redlc43b54c2010-08-18 23:56:43 +00001780Expr *ASTReader::ReadSubExpr() {
Argyrios Kyrtzidisd98a2ab2010-06-29 22:46:25 +00001781 return cast_or_null<Expr>(ReadSubStmt());
1782}
1783
Chris Lattner52e97d12009-04-27 05:41:06 +00001784// Within the bitstream, expressions are stored in Reverse Polish
1785// Notation, with each of the subexpressions preceding the
Argyrios Kyrtzidis919e6932010-06-28 22:28:35 +00001786// expression they are stored in. Subexpressions are stored from last to first.
1787// To evaluate expressions, we continue reading expressions and placing them on
1788// the stack, with expressions having operands removing those operands from the
Chris Lattner52e97d12009-04-27 05:41:06 +00001789// stack. Evaluation terminates when we see a STMT_STOP record, and
1790// the single remaining expression on the stack is our result.
Douglas Gregor1a4761e2011-11-30 23:21:26 +00001791Stmt *ASTReader::ReadStmtFromStream(ModuleFile &F) {
Argyrios Kyrtzidis919e6932010-06-28 22:28:35 +00001792
1793 ReadingKindTracker ReadingKind(Read_Stmt, *this);
Sebastian Redlc3632732010-10-05 15:59:54 +00001794 llvm::BitstreamCursor &Cursor = F.DeclsCursor;
Argyrios Kyrtzidise6f08682011-10-21 23:02:28 +00001795
1796 // Map of offset to previously deserialized stmt. The offset points
1797 /// just after the stmt record.
1798 llvm::DenseMap<uint64_t, Stmt *> StmtEntries;
Sebastian Redlc3632732010-10-05 15:59:54 +00001799
Argyrios Kyrtzidis919e6932010-06-28 22:28:35 +00001800#ifndef NDEBUG
1801 unsigned PrevNumStmts = StmtStack.size();
1802#endif
1803
Chris Lattner4c6f9522009-04-27 05:14:47 +00001804 RecordData Record;
1805 unsigned Idx;
Sebastian Redlc3632732010-10-05 15:59:54 +00001806 ASTStmtReader Reader(*this, F, Cursor, Record, Idx);
Chris Lattner4c6f9522009-04-27 05:14:47 +00001807 Stmt::EmptyShell Empty;
1808
1809 while (true) {
Chris Lattnerb3ce3572013-01-20 02:38:54 +00001810 llvm::BitstreamEntry Entry = Cursor.advanceSkippingSubblocks();
1811
1812 switch (Entry.Kind) {
1813 case llvm::BitstreamEntry::SubBlock: // Handled for us already.
1814 case llvm::BitstreamEntry::Error:
1815 Error("malformed block record in AST file");
1816 return 0;
1817 case llvm::BitstreamEntry::EndBlock:
1818 goto Done;
1819 case llvm::BitstreamEntry::Record:
1820 // The interesting case.
Chris Lattner4c6f9522009-04-27 05:14:47 +00001821 break;
1822 }
1823
Chris Lattner4c6f9522009-04-27 05:14:47 +00001824
1825 Stmt *S = 0;
1826 Idx = 0;
1827 Record.clear();
1828 bool Finished = false;
Argyrios Kyrtzidise6f08682011-10-21 23:02:28 +00001829 bool IsStmtReference = false;
Chris Lattnerb3ce3572013-01-20 02:38:54 +00001830 switch ((StmtCode)Cursor.readRecord(Entry.ID, Record)) {
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001831 case STMT_STOP:
Chris Lattner4c6f9522009-04-27 05:14:47 +00001832 Finished = true;
1833 break;
1834
Argyrios Kyrtzidise6f08682011-10-21 23:02:28 +00001835 case STMT_REF_PTR:
1836 IsStmtReference = true;
1837 assert(StmtEntries.find(Record[0]) != StmtEntries.end() &&
1838 "No stmt was recorded for this offset reference!");
1839 S = StmtEntries[Record[Idx++]];
1840 break;
1841
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001842 case STMT_NULL_PTR:
Mike Stump1eb44332009-09-09 15:08:12 +00001843 S = 0;
Chris Lattner4c6f9522009-04-27 05:14:47 +00001844 break;
1845
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001846 case STMT_NULL:
Chris Lattner4c6f9522009-04-27 05:14:47 +00001847 S = new (Context) NullStmt(Empty);
1848 break;
1849
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001850 case STMT_COMPOUND:
Chris Lattner4c6f9522009-04-27 05:14:47 +00001851 S = new (Context) CompoundStmt(Empty);
1852 break;
1853
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001854 case STMT_CASE:
Chris Lattner4c6f9522009-04-27 05:14:47 +00001855 S = new (Context) CaseStmt(Empty);
1856 break;
1857
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001858 case STMT_DEFAULT:
Chris Lattner4c6f9522009-04-27 05:14:47 +00001859 S = new (Context) DefaultStmt(Empty);
1860 break;
1861
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001862 case STMT_LABEL:
Chris Lattner4c6f9522009-04-27 05:14:47 +00001863 S = new (Context) LabelStmt(Empty);
1864 break;
1865
Richard Smith534986f2012-04-14 00:33:13 +00001866 case STMT_ATTRIBUTED:
Alexander Kornienko49908902012-07-09 10:04:07 +00001867 S = AttributedStmt::CreateEmpty(
1868 Context,
1869 /*NumAttrs*/Record[ASTStmtReader::NumStmtFields]);
Richard Smith534986f2012-04-14 00:33:13 +00001870 break;
1871
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001872 case STMT_IF:
Chris Lattner4c6f9522009-04-27 05:14:47 +00001873 S = new (Context) IfStmt(Empty);
1874 break;
1875
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001876 case STMT_SWITCH:
Chris Lattner4c6f9522009-04-27 05:14:47 +00001877 S = new (Context) SwitchStmt(Empty);
1878 break;
1879
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001880 case STMT_WHILE:
Chris Lattner4c6f9522009-04-27 05:14:47 +00001881 S = new (Context) WhileStmt(Empty);
1882 break;
1883
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001884 case STMT_DO:
Chris Lattner4c6f9522009-04-27 05:14:47 +00001885 S = new (Context) DoStmt(Empty);
1886 break;
Mike Stump1eb44332009-09-09 15:08:12 +00001887
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001888 case STMT_FOR:
Chris Lattner4c6f9522009-04-27 05:14:47 +00001889 S = new (Context) ForStmt(Empty);
1890 break;
1891
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001892 case STMT_GOTO:
Chris Lattner4c6f9522009-04-27 05:14:47 +00001893 S = new (Context) GotoStmt(Empty);
1894 break;
Mike Stump1eb44332009-09-09 15:08:12 +00001895
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001896 case STMT_INDIRECT_GOTO:
Chris Lattner4c6f9522009-04-27 05:14:47 +00001897 S = new (Context) IndirectGotoStmt(Empty);
1898 break;
1899
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001900 case STMT_CONTINUE:
Chris Lattner4c6f9522009-04-27 05:14:47 +00001901 S = new (Context) ContinueStmt(Empty);
1902 break;
1903
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001904 case STMT_BREAK:
Chris Lattner4c6f9522009-04-27 05:14:47 +00001905 S = new (Context) BreakStmt(Empty);
1906 break;
1907
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001908 case STMT_RETURN:
Chris Lattner4c6f9522009-04-27 05:14:47 +00001909 S = new (Context) ReturnStmt(Empty);
1910 break;
1911
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001912 case STMT_DECL:
Chris Lattner4c6f9522009-04-27 05:14:47 +00001913 S = new (Context) DeclStmt(Empty);
1914 break;
1915
Chad Rosierdf5faf52012-08-25 00:11:56 +00001916 case STMT_GCCASM:
1917 S = new (Context) GCCAsmStmt(Empty);
Chris Lattner4c6f9522009-04-27 05:14:47 +00001918 break;
1919
Chad Rosiercd518a02012-08-24 23:51:02 +00001920 case STMT_MSASM:
1921 S = new (Context) MSAsmStmt(Empty);
1922 break;
1923
Tareq A. Siraj051303c2013-04-16 18:53:08 +00001924 case STMT_CAPTURED:
Ben Langmuirdc5be4f2013-05-03 19:20:19 +00001925 S = CapturedStmt::CreateDeserialized(Context,
Alexey Bataev4fa7eab2013-07-19 03:13:43 +00001926 Record[ASTStmtReader::NumStmtFields]);
Tareq A. Siraj051303c2013-04-16 18:53:08 +00001927 break;
1928
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001929 case EXPR_PREDEFINED:
Chris Lattner4c6f9522009-04-27 05:14:47 +00001930 S = new (Context) PredefinedExpr(Empty);
1931 break;
Mike Stump1eb44332009-09-09 15:08:12 +00001932
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001933 case EXPR_DECL_REF:
Chandler Carruth3aa81402011-05-01 23:48:14 +00001934 S = DeclRefExpr::CreateEmpty(
Douglas Gregor35942772011-09-09 21:34:22 +00001935 Context,
Chandler Carruth3aa81402011-05-01 23:48:14 +00001936 /*HasQualifier=*/Record[ASTStmtReader::NumExprFields],
1937 /*HasFoundDecl=*/Record[ASTStmtReader::NumExprFields + 1],
Abramo Bagnarae4b92762012-01-27 09:46:47 +00001938 /*HasTemplateKWAndArgsInfo=*/Record[ASTStmtReader::NumExprFields + 2],
Chandler Carruth3aa81402011-05-01 23:48:14 +00001939 /*NumTemplateArgs=*/Record[ASTStmtReader::NumExprFields + 2] ?
John McCallf4b88a42012-03-10 09:33:50 +00001940 Record[ASTStmtReader::NumExprFields + 5] : 0);
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_INTEGER_LITERAL:
Douglas Gregor35942772011-09-09 21:34:22 +00001944 S = IntegerLiteral::Create(Context, Empty);
Chris Lattner4c6f9522009-04-27 05:14:47 +00001945 break;
Mike Stump1eb44332009-09-09 15:08:12 +00001946
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001947 case EXPR_FLOATING_LITERAL:
Douglas Gregor35942772011-09-09 21:34:22 +00001948 S = FloatingLiteral::Create(Context, Empty);
Chris Lattner4c6f9522009-04-27 05:14:47 +00001949 break;
Mike Stump1eb44332009-09-09 15:08:12 +00001950
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001951 case EXPR_IMAGINARY_LITERAL:
Chris Lattner4c6f9522009-04-27 05:14:47 +00001952 S = new (Context) ImaginaryLiteral(Empty);
1953 break;
1954
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001955 case EXPR_STRING_LITERAL:
Douglas Gregor35942772011-09-09 21:34:22 +00001956 S = StringLiteral::CreateEmpty(Context,
Sebastian Redl60adf4a2010-08-18 23:56:52 +00001957 Record[ASTStmtReader::NumExprFields + 1]);
Chris Lattner4c6f9522009-04-27 05:14:47 +00001958 break;
1959
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001960 case EXPR_CHARACTER_LITERAL:
Chris Lattner4c6f9522009-04-27 05:14:47 +00001961 S = new (Context) CharacterLiteral(Empty);
1962 break;
1963
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001964 case EXPR_PAREN:
Chris Lattner4c6f9522009-04-27 05:14:47 +00001965 S = new (Context) ParenExpr(Empty);
1966 break;
1967
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001968 case EXPR_PAREN_LIST:
Argyrios Kyrtzidis37bdfe22010-06-30 08:49:18 +00001969 S = new (Context) ParenListExpr(Empty);
1970 break;
1971
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001972 case EXPR_UNARY_OPERATOR:
Chris Lattner4c6f9522009-04-27 05:14:47 +00001973 S = new (Context) UnaryOperator(Empty);
1974 break;
1975
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001976 case EXPR_OFFSETOF:
Douglas Gregor35942772011-09-09 21:34:22 +00001977 S = OffsetOfExpr::CreateEmpty(Context,
Sebastian Redl60adf4a2010-08-18 23:56:52 +00001978 Record[ASTStmtReader::NumExprFields],
1979 Record[ASTStmtReader::NumExprFields + 1]);
Douglas Gregor8ecdb652010-04-28 22:16:22 +00001980 break;
1981
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001982 case EXPR_SIZEOF_ALIGN_OF:
Peter Collingbournef4e3cfb2011-03-11 19:24:49 +00001983 S = new (Context) UnaryExprOrTypeTraitExpr(Empty);
Chris Lattner4c6f9522009-04-27 05:14:47 +00001984 break;
1985
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001986 case EXPR_ARRAY_SUBSCRIPT:
Chris Lattner4c6f9522009-04-27 05:14:47 +00001987 S = new (Context) ArraySubscriptExpr(Empty);
1988 break;
1989
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001990 case EXPR_CALL:
Douglas Gregor35942772011-09-09 21:34:22 +00001991 S = new (Context) CallExpr(Context, Stmt::CallExprClass, Empty);
Chris Lattner4c6f9522009-04-27 05:14:47 +00001992 break;
1993
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001994 case EXPR_MEMBER: {
Argyrios Kyrtzidis663e3802010-07-08 13:09:47 +00001995 // We load everything here and fully initialize it at creation.
1996 // That way we can use MemberExpr::Create and don't have to duplicate its
1997 // logic with a MemberExpr::CreateEmpty.
1998
1999 assert(Idx == 0);
Douglas Gregor40d96a62011-02-28 21:54:11 +00002000 NestedNameSpecifierLoc QualifierLoc;
Argyrios Kyrtzidis663e3802010-07-08 13:09:47 +00002001 if (Record[Idx++]) { // HasQualifier.
Douglas Gregor40d96a62011-02-28 21:54:11 +00002002 QualifierLoc = ReadNestedNameSpecifierLoc(F, Record, Idx);
Argyrios Kyrtzidis663e3802010-07-08 13:09:47 +00002003 }
2004
Abramo Bagnarae4b92762012-01-27 09:46:47 +00002005 SourceLocation TemplateKWLoc;
Argyrios Kyrtzidis663e3802010-07-08 13:09:47 +00002006 TemplateArgumentListInfo ArgInfo;
Abramo Bagnarae4b92762012-01-27 09:46:47 +00002007 bool HasTemplateKWAndArgsInfo = Record[Idx++];
2008 if (HasTemplateKWAndArgsInfo) {
2009 TemplateKWLoc = ReadSourceLocation(F, Record, Idx);
Douglas Gregordef03542011-02-04 12:01:24 +00002010 unsigned NumTemplateArgs = Record[Idx++];
Sebastian Redlc3632732010-10-05 15:59:54 +00002011 ArgInfo.setLAngleLoc(ReadSourceLocation(F, Record, Idx));
2012 ArgInfo.setRAngleLoc(ReadSourceLocation(F, Record, Idx));
Argyrios Kyrtzidis663e3802010-07-08 13:09:47 +00002013 for (unsigned i = 0; i != NumTemplateArgs; ++i)
Sebastian Redlc3632732010-10-05 15:59:54 +00002014 ArgInfo.addArgument(ReadTemplateArgumentLoc(F, Record, Idx));
Argyrios Kyrtzidis663e3802010-07-08 13:09:47 +00002015 }
Abramo Bagnara7cc58b42011-10-05 07:56:41 +00002016
2017 bool HadMultipleCandidates = Record[Idx++];
2018
Douglas Gregor409448c2011-07-21 22:35:25 +00002019 NamedDecl *FoundD = ReadDeclAs<NamedDecl>(F, Record, Idx);
Argyrios Kyrtzidis663e3802010-07-08 13:09:47 +00002020 AccessSpecifier AS = (AccessSpecifier)Record[Idx++];
2021 DeclAccessPair FoundDecl = DeclAccessPair::make(FoundD, AS);
2022
Douglas Gregor393f2492011-07-22 00:38:23 +00002023 QualType T = readType(F, Record, Idx);
John McCallf89e55a2010-11-18 06:31:45 +00002024 ExprValueKind VK = static_cast<ExprValueKind>(Record[Idx++]);
2025 ExprObjectKind OK = static_cast<ExprObjectKind>(Record[Idx++]);
Argyrios Kyrtzidis663e3802010-07-08 13:09:47 +00002026 Expr *Base = ReadSubExpr();
Douglas Gregor409448c2011-07-21 22:35:25 +00002027 ValueDecl *MemberD = ReadDeclAs<ValueDecl>(F, Record, Idx);
Sebastian Redlc3632732010-10-05 15:59:54 +00002028 SourceLocation MemberLoc = ReadSourceLocation(F, Record, Idx);
Abramo Bagnara25777432010-08-11 22:01:17 +00002029 DeclarationNameInfo MemberNameInfo(MemberD->getDeclName(), MemberLoc);
Argyrios Kyrtzidis663e3802010-07-08 13:09:47 +00002030 bool IsArrow = Record[Idx++];
2031
Douglas Gregor35942772011-09-09 21:34:22 +00002032 S = MemberExpr::Create(Context, Base, IsArrow, QualifierLoc,
Abramo Bagnarae4b92762012-01-27 09:46:47 +00002033 TemplateKWLoc, MemberD, FoundDecl, MemberNameInfo,
2034 HasTemplateKWAndArgsInfo ? &ArgInfo : 0,
2035 T, VK, OK);
Argyrios Kyrtzidis40451072010-10-15 18:21:24 +00002036 ReadDeclarationNameLoc(F, cast<MemberExpr>(S)->MemberDNLoc,
2037 MemberD->getDeclName(), Record, Idx);
Abramo Bagnara7cc58b42011-10-05 07:56:41 +00002038 if (HadMultipleCandidates)
2039 cast<MemberExpr>(S)->setHadMultipleCandidates(true);
Chris Lattner4c6f9522009-04-27 05:14:47 +00002040 break;
Argyrios Kyrtzidis663e3802010-07-08 13:09:47 +00002041 }
Chris Lattner4c6f9522009-04-27 05:14:47 +00002042
Sebastian Redl8538e8d2010-08-18 23:57:32 +00002043 case EXPR_BINARY_OPERATOR:
Chris Lattner4c6f9522009-04-27 05:14:47 +00002044 S = new (Context) BinaryOperator(Empty);
2045 break;
2046
Sebastian Redl8538e8d2010-08-18 23:57:32 +00002047 case EXPR_COMPOUND_ASSIGN_OPERATOR:
Chris Lattner4c6f9522009-04-27 05:14:47 +00002048 S = new (Context) CompoundAssignOperator(Empty);
2049 break;
2050
Sebastian Redl8538e8d2010-08-18 23:57:32 +00002051 case EXPR_CONDITIONAL_OPERATOR:
Chris Lattner4c6f9522009-04-27 05:14:47 +00002052 S = new (Context) ConditionalOperator(Empty);
2053 break;
2054
John McCall56ca35d2011-02-17 10:25:35 +00002055 case EXPR_BINARY_CONDITIONAL_OPERATOR:
2056 S = new (Context) BinaryConditionalOperator(Empty);
2057 break;
2058
Sebastian Redl8538e8d2010-08-18 23:57:32 +00002059 case EXPR_IMPLICIT_CAST:
Douglas Gregor35942772011-09-09 21:34:22 +00002060 S = ImplicitCastExpr::CreateEmpty(Context,
Sebastian Redl60adf4a2010-08-18 23:56:52 +00002061 /*PathSize*/ Record[ASTStmtReader::NumExprFields]);
Chris Lattner4c6f9522009-04-27 05:14:47 +00002062 break;
2063
Sebastian Redl8538e8d2010-08-18 23:57:32 +00002064 case EXPR_CSTYLE_CAST:
Douglas Gregor35942772011-09-09 21:34:22 +00002065 S = CStyleCastExpr::CreateEmpty(Context,
Sebastian Redl60adf4a2010-08-18 23:56:52 +00002066 /*PathSize*/ Record[ASTStmtReader::NumExprFields]);
Chris Lattner4c6f9522009-04-27 05:14:47 +00002067 break;
2068
Sebastian Redl8538e8d2010-08-18 23:57:32 +00002069 case EXPR_COMPOUND_LITERAL:
Chris Lattner4c6f9522009-04-27 05:14:47 +00002070 S = new (Context) CompoundLiteralExpr(Empty);
2071 break;
2072
Sebastian Redl8538e8d2010-08-18 23:57:32 +00002073 case EXPR_EXT_VECTOR_ELEMENT:
Chris Lattner4c6f9522009-04-27 05:14:47 +00002074 S = new (Context) ExtVectorElementExpr(Empty);
2075 break;
2076
Sebastian Redl8538e8d2010-08-18 23:57:32 +00002077 case EXPR_INIT_LIST:
Argyrios Kyrtzidis2a82ca22012-11-28 03:56:16 +00002078 S = new (Context) InitListExpr(Empty);
Chris Lattner4c6f9522009-04-27 05:14:47 +00002079 break;
2080
Sebastian Redl8538e8d2010-08-18 23:57:32 +00002081 case EXPR_DESIGNATED_INIT:
Douglas Gregor35942772011-09-09 21:34:22 +00002082 S = DesignatedInitExpr::CreateEmpty(Context,
Sebastian Redl60adf4a2010-08-18 23:56:52 +00002083 Record[ASTStmtReader::NumExprFields] - 1);
Mike Stump1eb44332009-09-09 15:08:12 +00002084
Chris Lattner4c6f9522009-04-27 05:14:47 +00002085 break;
2086
Sebastian Redl8538e8d2010-08-18 23:57:32 +00002087 case EXPR_IMPLICIT_VALUE_INIT:
Chris Lattner4c6f9522009-04-27 05:14:47 +00002088 S = new (Context) ImplicitValueInitExpr(Empty);
2089 break;
2090
Sebastian Redl8538e8d2010-08-18 23:57:32 +00002091 case EXPR_VA_ARG:
Chris Lattner4c6f9522009-04-27 05:14:47 +00002092 S = new (Context) VAArgExpr(Empty);
2093 break;
2094
Sebastian Redl8538e8d2010-08-18 23:57:32 +00002095 case EXPR_ADDR_LABEL:
Chris Lattner4c6f9522009-04-27 05:14:47 +00002096 S = new (Context) AddrLabelExpr(Empty);
2097 break;
2098
Sebastian Redl8538e8d2010-08-18 23:57:32 +00002099 case EXPR_STMT:
Chris Lattner4c6f9522009-04-27 05:14:47 +00002100 S = new (Context) StmtExpr(Empty);
2101 break;
2102
Sebastian Redl8538e8d2010-08-18 23:57:32 +00002103 case EXPR_CHOOSE:
Chris Lattner4c6f9522009-04-27 05:14:47 +00002104 S = new (Context) ChooseExpr(Empty);
2105 break;
2106
Sebastian Redl8538e8d2010-08-18 23:57:32 +00002107 case EXPR_GNU_NULL:
Chris Lattner4c6f9522009-04-27 05:14:47 +00002108 S = new (Context) GNUNullExpr(Empty);
2109 break;
2110
Sebastian Redl8538e8d2010-08-18 23:57:32 +00002111 case EXPR_SHUFFLE_VECTOR:
Chris Lattner4c6f9522009-04-27 05:14:47 +00002112 S = new (Context) ShuffleVectorExpr(Empty);
2113 break;
Mike Stump1eb44332009-09-09 15:08:12 +00002114
Hal Finkel414a1bd2013-09-18 03:29:45 +00002115 case EXPR_CONVERT_VECTOR:
2116 S = new (Context) ConvertVectorExpr(Empty);
2117 break;
2118
Sebastian Redl8538e8d2010-08-18 23:57:32 +00002119 case EXPR_BLOCK:
Chris Lattner4c6f9522009-04-27 05:14:47 +00002120 S = new (Context) BlockExpr(Empty);
2121 break;
2122
Peter Collingbournef111d932011-04-15 00:35:48 +00002123 case EXPR_GENERIC_SELECTION:
2124 S = new (Context) GenericSelectionExpr(Empty);
2125 break;
2126
Sebastian Redl8538e8d2010-08-18 23:57:32 +00002127 case EXPR_OBJC_STRING_LITERAL:
Chris Lattner4c6f9522009-04-27 05:14:47 +00002128 S = new (Context) ObjCStringLiteral(Empty);
2129 break;
Patrick Beardeb382ec2012-04-19 00:25:12 +00002130 case EXPR_OBJC_BOXED_EXPRESSION:
2131 S = new (Context) ObjCBoxedExpr(Empty);
Ted Kremenekebcb57a2012-03-06 20:05:56 +00002132 break;
2133 case EXPR_OBJC_ARRAY_LITERAL:
2134 S = ObjCArrayLiteral::CreateEmpty(Context,
2135 Record[ASTStmtReader::NumExprFields]);
2136 break;
2137 case EXPR_OBJC_DICTIONARY_LITERAL:
2138 S = ObjCDictionaryLiteral::CreateEmpty(Context,
2139 Record[ASTStmtReader::NumExprFields],
2140 Record[ASTStmtReader::NumExprFields + 1]);
2141 break;
Sebastian Redl8538e8d2010-08-18 23:57:32 +00002142 case EXPR_OBJC_ENCODE:
Chris Lattner4c6f9522009-04-27 05:14:47 +00002143 S = new (Context) ObjCEncodeExpr(Empty);
2144 break;
Sebastian Redl8538e8d2010-08-18 23:57:32 +00002145 case EXPR_OBJC_SELECTOR_EXPR:
Chris Lattner4c6f9522009-04-27 05:14:47 +00002146 S = new (Context) ObjCSelectorExpr(Empty);
2147 break;
Sebastian Redl8538e8d2010-08-18 23:57:32 +00002148 case EXPR_OBJC_PROTOCOL_EXPR:
Chris Lattner4c6f9522009-04-27 05:14:47 +00002149 S = new (Context) ObjCProtocolExpr(Empty);
2150 break;
Sebastian Redl8538e8d2010-08-18 23:57:32 +00002151 case EXPR_OBJC_IVAR_REF_EXPR:
Chris Lattner4c6f9522009-04-27 05:14:47 +00002152 S = new (Context) ObjCIvarRefExpr(Empty);
2153 break;
Sebastian Redl8538e8d2010-08-18 23:57:32 +00002154 case EXPR_OBJC_PROPERTY_REF_EXPR:
Chris Lattner4c6f9522009-04-27 05:14:47 +00002155 S = new (Context) ObjCPropertyRefExpr(Empty);
2156 break;
Ted Kremenekebcb57a2012-03-06 20:05:56 +00002157 case EXPR_OBJC_SUBSCRIPT_REF_EXPR:
2158 S = new (Context) ObjCSubscriptRefExpr(Empty);
2159 break;
Sebastian Redl8538e8d2010-08-18 23:57:32 +00002160 case EXPR_OBJC_KVC_REF_EXPR:
John McCall12f78a62010-12-02 01:19:52 +00002161 llvm_unreachable("mismatching AST file");
Sebastian Redl8538e8d2010-08-18 23:57:32 +00002162 case EXPR_OBJC_MESSAGE_EXPR:
Douglas Gregor35942772011-09-09 21:34:22 +00002163 S = ObjCMessageExpr::CreateEmpty(Context,
Argyrios Kyrtzidis20718082011-10-03 06:36:51 +00002164 Record[ASTStmtReader::NumExprFields],
2165 Record[ASTStmtReader::NumExprFields + 1]);
Chris Lattner4c6f9522009-04-27 05:14:47 +00002166 break;
Sebastian Redl8538e8d2010-08-18 23:57:32 +00002167 case EXPR_OBJC_ISA:
Steve Narofff242b1b2009-07-24 17:54:45 +00002168 S = new (Context) ObjCIsaExpr(Empty);
2169 break;
John McCallf85e1932011-06-15 23:02:42 +00002170 case EXPR_OBJC_INDIRECT_COPY_RESTORE:
2171 S = new (Context) ObjCIndirectCopyRestoreExpr(Empty);
2172 break;
2173 case EXPR_OBJC_BRIDGED_CAST:
2174 S = new (Context) ObjCBridgedCastExpr(Empty);
2175 break;
Sebastian Redl8538e8d2010-08-18 23:57:32 +00002176 case STMT_OBJC_FOR_COLLECTION:
Chris Lattner4c6f9522009-04-27 05:14:47 +00002177 S = new (Context) ObjCForCollectionStmt(Empty);
2178 break;
Sebastian Redl8538e8d2010-08-18 23:57:32 +00002179 case STMT_OBJC_CATCH:
Chris Lattner4c6f9522009-04-27 05:14:47 +00002180 S = new (Context) ObjCAtCatchStmt(Empty);
2181 break;
Sebastian Redl8538e8d2010-08-18 23:57:32 +00002182 case STMT_OBJC_FINALLY:
Chris Lattner4c6f9522009-04-27 05:14:47 +00002183 S = new (Context) ObjCAtFinallyStmt(Empty);
2184 break;
Sebastian Redl8538e8d2010-08-18 23:57:32 +00002185 case STMT_OBJC_AT_TRY:
Douglas Gregor35942772011-09-09 21:34:22 +00002186 S = ObjCAtTryStmt::CreateEmpty(Context,
Sebastian Redl60adf4a2010-08-18 23:56:52 +00002187 Record[ASTStmtReader::NumStmtFields],
2188 Record[ASTStmtReader::NumStmtFields + 1]);
Chris Lattner4c6f9522009-04-27 05:14:47 +00002189 break;
Sebastian Redl8538e8d2010-08-18 23:57:32 +00002190 case STMT_OBJC_AT_SYNCHRONIZED:
Chris Lattner4c6f9522009-04-27 05:14:47 +00002191 S = new (Context) ObjCAtSynchronizedStmt(Empty);
2192 break;
Sebastian Redl8538e8d2010-08-18 23:57:32 +00002193 case STMT_OBJC_AT_THROW:
Chris Lattner4c6f9522009-04-27 05:14:47 +00002194 S = new (Context) ObjCAtThrowStmt(Empty);
2195 break;
John McCallf85e1932011-06-15 23:02:42 +00002196 case STMT_OBJC_AUTORELEASE_POOL:
2197 S = new (Context) ObjCAutoreleasePoolStmt(Empty);
2198 break;
Ted Kremenekebcb57a2012-03-06 20:05:56 +00002199 case EXPR_OBJC_BOOL_LITERAL:
2200 S = new (Context) ObjCBoolLiteralExpr(Empty);
2201 break;
John McCall7110fd62011-07-15 07:00:14 +00002202 case STMT_SEH_EXCEPT:
2203 S = new (Context) SEHExceptStmt(Empty);
2204 break;
2205 case STMT_SEH_FINALLY:
2206 S = new (Context) SEHFinallyStmt(Empty);
2207 break;
2208 case STMT_SEH_TRY:
2209 S = new (Context) SEHTryStmt(Empty);
2210 break;
Sebastian Redl8538e8d2010-08-18 23:57:32 +00002211 case STMT_CXX_CATCH:
Argyrios Kyrtzidis7cb45e32010-07-22 16:03:56 +00002212 S = new (Context) CXXCatchStmt(Empty);
2213 break;
2214
Sebastian Redl8538e8d2010-08-18 23:57:32 +00002215 case STMT_CXX_TRY:
Douglas Gregor35942772011-09-09 21:34:22 +00002216 S = CXXTryStmt::Create(Context, Empty,
Sebastian Redl60adf4a2010-08-18 23:56:52 +00002217 /*NumHandlers=*/Record[ASTStmtReader::NumStmtFields]);
Argyrios Kyrtzidis7cb45e32010-07-22 16:03:56 +00002218 break;
2219
Richard Smithad762fc2011-04-14 22:09:26 +00002220 case STMT_CXX_FOR_RANGE:
2221 S = new (Context) CXXForRangeStmt(Empty);
2222 break;
2223
Douglas Gregorba0513d2011-10-25 01:33:02 +00002224 case STMT_MS_DEPENDENT_EXISTS:
2225 S = new (Context) MSDependentExistsStmt(SourceLocation(), true,
2226 NestedNameSpecifierLoc(),
2227 DeclarationNameInfo(),
2228 0);
2229 break;
Alexey Bataev4fa7eab2013-07-19 03:13:43 +00002230 case STMT_OMP_PARALLEL_DIRECTIVE:
2231 S =
2232 OMPParallelDirective::CreateEmpty(Context,
2233 Record[ASTStmtReader::NumStmtFields],
2234 Empty);
2235 break;
Douglas Gregorba0513d2011-10-25 01:33:02 +00002236
Sebastian Redl8538e8d2010-08-18 23:57:32 +00002237 case EXPR_CXX_OPERATOR_CALL:
Douglas Gregor35942772011-09-09 21:34:22 +00002238 S = new (Context) CXXOperatorCallExpr(Context, Empty);
Argyrios Kyrtzidisba0a9002009-07-14 03:19:21 +00002239 break;
Chris Lattner1817bd42010-05-09 05:36:05 +00002240
Sebastian Redl8538e8d2010-08-18 23:57:32 +00002241 case EXPR_CXX_MEMBER_CALL:
Douglas Gregor35942772011-09-09 21:34:22 +00002242 S = new (Context) CXXMemberCallExpr(Context, Empty);
Chris Lattner1817bd42010-05-09 05:36:05 +00002243 break;
Douglas Gregor39da0b82009-09-09 23:08:42 +00002244
Sebastian Redl8538e8d2010-08-18 23:57:32 +00002245 case EXPR_CXX_CONSTRUCT:
Argyrios Kyrtzidis6d00c132010-07-10 11:46:15 +00002246 S = new (Context) CXXConstructExpr(Empty);
2247 break;
2248
Sebastian Redl8538e8d2010-08-18 23:57:32 +00002249 case EXPR_CXX_TEMPORARY_OBJECT:
Argyrios Kyrtzidis6d00c132010-07-10 11:46:15 +00002250 S = new (Context) CXXTemporaryObjectExpr(Empty);
Douglas Gregor39da0b82009-09-09 23:08:42 +00002251 break;
Sam Weinigce757a72010-01-16 21:21:01 +00002252
Sebastian Redl8538e8d2010-08-18 23:57:32 +00002253 case EXPR_CXX_STATIC_CAST:
Douglas Gregor35942772011-09-09 21:34:22 +00002254 S = CXXStaticCastExpr::CreateEmpty(Context,
Sebastian Redl60adf4a2010-08-18 23:56:52 +00002255 /*PathSize*/ Record[ASTStmtReader::NumExprFields]);
Sam Weinigce757a72010-01-16 21:21:01 +00002256 break;
2257
Sebastian Redl8538e8d2010-08-18 23:57:32 +00002258 case EXPR_CXX_DYNAMIC_CAST:
Douglas Gregor35942772011-09-09 21:34:22 +00002259 S = CXXDynamicCastExpr::CreateEmpty(Context,
Sebastian Redl60adf4a2010-08-18 23:56:52 +00002260 /*PathSize*/ Record[ASTStmtReader::NumExprFields]);
Sam Weinigce757a72010-01-16 21:21:01 +00002261 break;
2262
Sebastian Redl8538e8d2010-08-18 23:57:32 +00002263 case EXPR_CXX_REINTERPRET_CAST:
Douglas Gregor35942772011-09-09 21:34:22 +00002264 S = CXXReinterpretCastExpr::CreateEmpty(Context,
Sebastian Redl60adf4a2010-08-18 23:56:52 +00002265 /*PathSize*/ Record[ASTStmtReader::NumExprFields]);
Sam Weinigce757a72010-01-16 21:21:01 +00002266 break;
2267
Sebastian Redl8538e8d2010-08-18 23:57:32 +00002268 case EXPR_CXX_CONST_CAST:
Douglas Gregor35942772011-09-09 21:34:22 +00002269 S = CXXConstCastExpr::CreateEmpty(Context);
Sam Weinigce757a72010-01-16 21:21:01 +00002270 break;
2271
Sebastian Redl8538e8d2010-08-18 23:57:32 +00002272 case EXPR_CXX_FUNCTIONAL_CAST:
Douglas Gregor35942772011-09-09 21:34:22 +00002273 S = CXXFunctionalCastExpr::CreateEmpty(Context,
Sebastian Redl60adf4a2010-08-18 23:56:52 +00002274 /*PathSize*/ Record[ASTStmtReader::NumExprFields]);
Sam Weinigce757a72010-01-16 21:21:01 +00002275 break;
2276
Richard Smith9fcce652012-03-07 08:35:16 +00002277 case EXPR_USER_DEFINED_LITERAL:
2278 S = new (Context) UserDefinedLiteral(Context, Empty);
2279 break;
2280
Richard Smith7c3e6152013-06-12 22:31:48 +00002281 case EXPR_CXX_STD_INITIALIZER_LIST:
2282 S = new (Context) CXXStdInitializerListExpr(Empty);
2283 break;
2284
Sebastian Redl8538e8d2010-08-18 23:57:32 +00002285 case EXPR_CXX_BOOL_LITERAL:
Sam Weinigeb7f9612010-02-07 06:32:43 +00002286 S = new (Context) CXXBoolLiteralExpr(Empty);
2287 break;
Sam Weinigce757a72010-01-16 21:21:01 +00002288
Sebastian Redl8538e8d2010-08-18 23:57:32 +00002289 case EXPR_CXX_NULL_PTR_LITERAL:
Sam Weinigeb7f9612010-02-07 06:32:43 +00002290 S = new (Context) CXXNullPtrLiteralExpr(Empty);
2291 break;
Sebastian Redl8538e8d2010-08-18 23:57:32 +00002292 case EXPR_CXX_TYPEID_EXPR:
Chris Lattner14ab24f2010-05-09 06:03:39 +00002293 S = new (Context) CXXTypeidExpr(Empty, true);
2294 break;
Sebastian Redl8538e8d2010-08-18 23:57:32 +00002295 case EXPR_CXX_TYPEID_TYPE:
Chris Lattner14ab24f2010-05-09 06:03:39 +00002296 S = new (Context) CXXTypeidExpr(Empty, false);
2297 break;
Francois Pichet01b7c302010-09-08 12:20:18 +00002298 case EXPR_CXX_UUIDOF_EXPR:
2299 S = new (Context) CXXUuidofExpr(Empty, true);
2300 break;
John McCall76da55d2013-04-16 07:28:30 +00002301 case EXPR_CXX_PROPERTY_REF_EXPR:
2302 S = new (Context) MSPropertyRefExpr(Empty);
2303 break;
Francois Pichet01b7c302010-09-08 12:20:18 +00002304 case EXPR_CXX_UUIDOF_TYPE:
2305 S = new (Context) CXXUuidofExpr(Empty, false);
2306 break;
Sebastian Redl8538e8d2010-08-18 23:57:32 +00002307 case EXPR_CXX_THIS:
Chris Lattner2fbdfcd2010-05-09 06:15:05 +00002308 S = new (Context) CXXThisExpr(Empty);
2309 break;
Sebastian Redl8538e8d2010-08-18 23:57:32 +00002310 case EXPR_CXX_THROW:
Chris Lattner2fbdfcd2010-05-09 06:15:05 +00002311 S = new (Context) CXXThrowExpr(Empty);
2312 break;
Sebastian Redl8538e8d2010-08-18 23:57:32 +00002313 case EXPR_CXX_DEFAULT_ARG: {
Sebastian Redl60adf4a2010-08-18 23:56:52 +00002314 bool HasOtherExprStored = Record[ASTStmtReader::NumExprFields];
Argyrios Kyrtzidis8a507332010-07-02 23:30:15 +00002315 if (HasOtherExprStored) {
2316 Expr *SubExpr = ReadSubExpr();
Douglas Gregor35942772011-09-09 21:34:22 +00002317 S = CXXDefaultArgExpr::Create(Context, SourceLocation(), 0, SubExpr);
Argyrios Kyrtzidis8a507332010-07-02 23:30:15 +00002318 } else
2319 S = new (Context) CXXDefaultArgExpr(Empty);
Chris Lattner030854b2010-05-09 06:40:08 +00002320 break;
Argyrios Kyrtzidis8a507332010-07-02 23:30:15 +00002321 }
Richard Smithc3bf52c2013-04-20 22:23:05 +00002322 case EXPR_CXX_DEFAULT_INIT:
2323 S = new (Context) CXXDefaultInitExpr(Empty);
2324 break;
Sebastian Redl8538e8d2010-08-18 23:57:32 +00002325 case EXPR_CXX_BIND_TEMPORARY:
Chris Lattnerd2598362010-05-10 00:25:06 +00002326 S = new (Context) CXXBindTemporaryExpr(Empty);
2327 break;
Douglas Gregore2ca6d42010-09-02 21:50:02 +00002328
Sebastian Redl8538e8d2010-08-18 23:57:32 +00002329 case EXPR_CXX_SCALAR_VALUE_INIT:
Douglas Gregored8abf12010-07-08 06:14:04 +00002330 S = new (Context) CXXScalarValueInitExpr(Empty);
Chris Lattner59218632010-05-10 01:22:27 +00002331 break;
Sebastian Redl8538e8d2010-08-18 23:57:32 +00002332 case EXPR_CXX_NEW:
Chris Lattner59218632010-05-10 01:22:27 +00002333 S = new (Context) CXXNewExpr(Empty);
2334 break;
Sebastian Redl8538e8d2010-08-18 23:57:32 +00002335 case EXPR_CXX_DELETE:
Argyrios Kyrtzidis95fc98c2010-06-22 17:07:59 +00002336 S = new (Context) CXXDeleteExpr(Empty);
2337 break;
Sebastian Redl8538e8d2010-08-18 23:57:32 +00002338 case EXPR_CXX_PSEUDO_DESTRUCTOR:
Argyrios Kyrtzidisde4bd182010-06-28 09:32:03 +00002339 S = new (Context) CXXPseudoDestructorExpr(Empty);
2340 break;
Chris Lattner59218632010-05-10 01:22:27 +00002341
John McCall4765fa02010-12-06 08:20:24 +00002342 case EXPR_EXPR_WITH_CLEANUPS:
John McCall80ee6e82011-11-10 05:35:25 +00002343 S = ExprWithCleanups::Create(Context, Empty,
2344 Record[ASTStmtReader::NumExprFields]);
Chris Lattnerd2598362010-05-10 00:25:06 +00002345 break;
Argyrios Kyrtzidis8dfbd8b2010-06-24 08:57:31 +00002346
Sebastian Redl8538e8d2010-08-18 23:57:32 +00002347 case EXPR_CXX_DEPENDENT_SCOPE_MEMBER:
Douglas Gregor35942772011-09-09 21:34:22 +00002348 S = CXXDependentScopeMemberExpr::CreateEmpty(Context,
Abramo Bagnarae4b92762012-01-27 09:46:47 +00002349 /*HasTemplateKWAndArgsInfo=*/Record[ASTStmtReader::NumExprFields],
Douglas Gregordef03542011-02-04 12:01:24 +00002350 /*NumTemplateArgs=*/Record[ASTStmtReader::NumExprFields]
2351 ? Record[ASTStmtReader::NumExprFields + 1]
2352 : 0);
Argyrios Kyrtzidis8dfbd8b2010-06-24 08:57:31 +00002353 break;
2354
Sebastian Redl8538e8d2010-08-18 23:57:32 +00002355 case EXPR_CXX_DEPENDENT_SCOPE_DECL_REF:
Douglas Gregor35942772011-09-09 21:34:22 +00002356 S = DependentScopeDeclRefExpr::CreateEmpty(Context,
Abramo Bagnarae4b92762012-01-27 09:46:47 +00002357 /*HasTemplateKWAndArgsInfo=*/Record[ASTStmtReader::NumExprFields],
Douglas Gregordef03542011-02-04 12:01:24 +00002358 /*NumTemplateArgs=*/Record[ASTStmtReader::NumExprFields]
2359 ? Record[ASTStmtReader::NumExprFields + 1]
2360 : 0);
Argyrios Kyrtzidis12dffcd2010-06-28 09:31:56 +00002361 break;
2362
Sebastian Redl8538e8d2010-08-18 23:57:32 +00002363 case EXPR_CXX_UNRESOLVED_CONSTRUCT:
Douglas Gregor35942772011-09-09 21:34:22 +00002364 S = CXXUnresolvedConstructExpr::CreateEmpty(Context,
Sebastian Redl60adf4a2010-08-18 23:56:52 +00002365 /*NumArgs=*/Record[ASTStmtReader::NumExprFields]);
Argyrios Kyrtzidisa77eb082010-06-25 09:03:26 +00002366 break;
2367
Sebastian Redl8538e8d2010-08-18 23:57:32 +00002368 case EXPR_CXX_UNRESOLVED_MEMBER:
Douglas Gregor35942772011-09-09 21:34:22 +00002369 S = UnresolvedMemberExpr::CreateEmpty(Context,
Abramo Bagnarae4b92762012-01-27 09:46:47 +00002370 /*HasTemplateKWAndArgsInfo=*/Record[ASTStmtReader::NumExprFields],
Douglas Gregordef03542011-02-04 12:01:24 +00002371 /*NumTemplateArgs=*/Record[ASTStmtReader::NumExprFields]
2372 ? Record[ASTStmtReader::NumExprFields + 1]
2373 : 0);
Argyrios Kyrtzidis8dfbd8b2010-06-24 08:57:31 +00002374 break;
Argyrios Kyrtzidisbd65bb52010-06-25 09:03:34 +00002375
Sebastian Redl8538e8d2010-08-18 23:57:32 +00002376 case EXPR_CXX_UNRESOLVED_LOOKUP:
Douglas Gregor35942772011-09-09 21:34:22 +00002377 S = UnresolvedLookupExpr::CreateEmpty(Context,
Abramo Bagnarae4b92762012-01-27 09:46:47 +00002378 /*HasTemplateKWAndArgsInfo=*/Record[ASTStmtReader::NumExprFields],
Douglas Gregordef03542011-02-04 12:01:24 +00002379 /*NumTemplateArgs=*/Record[ASTStmtReader::NumExprFields]
2380 ? Record[ASTStmtReader::NumExprFields + 1]
2381 : 0);
Argyrios Kyrtzidisbd65bb52010-06-25 09:03:34 +00002382 break;
Argyrios Kyrtzidis6d00c132010-07-10 11:46:15 +00002383
Sebastian Redl8538e8d2010-08-18 23:57:32 +00002384 case EXPR_CXX_UNARY_TYPE_TRAIT:
Argyrios Kyrtzidis6d00c132010-07-10 11:46:15 +00002385 S = new (Context) UnaryTypeTraitExpr(Empty);
2386 break;
Sebastian Redl6b219d02010-09-10 20:55:54 +00002387
Francois Pichetf1872372010-12-08 22:35:30 +00002388 case EXPR_BINARY_TYPE_TRAIT:
Francois Pichet6ad6f282010-12-07 00:08:36 +00002389 S = new (Context) BinaryTypeTraitExpr(Empty);
2390 break;
2391
Douglas Gregor4ca8ac22012-02-24 07:38:34 +00002392 case EXPR_TYPE_TRAIT:
2393 S = TypeTraitExpr::CreateDeserialized(Context,
2394 Record[ASTStmtReader::NumExprFields]);
2395 break;
2396
John Wiegley21ff2e52011-04-28 00:16:57 +00002397 case EXPR_ARRAY_TYPE_TRAIT:
2398 S = new (Context) ArrayTypeTraitExpr(Empty);
2399 break;
2400
John Wiegley55262202011-04-25 06:54:41 +00002401 case EXPR_CXX_EXPRESSION_TRAIT:
2402 S = new (Context) ExpressionTraitExpr(Empty);
2403 break;
2404
Sebastian Redl6b219d02010-09-10 20:55:54 +00002405 case EXPR_CXX_NOEXCEPT:
2406 S = new (Context) CXXNoexceptExpr(Empty);
2407 break;
John McCall7cd7d1a2010-11-15 23:31:06 +00002408
Douglas Gregorbe230c32011-01-03 17:17:50 +00002409 case EXPR_PACK_EXPANSION:
2410 S = new (Context) PackExpansionExpr(Empty);
2411 break;
2412
Douglas Gregoree8aff02011-01-04 17:33:58 +00002413 case EXPR_SIZEOF_PACK:
2414 S = new (Context) SizeOfPackExpr(Empty);
2415 break;
2416
John McCall7110fd62011-07-15 07:00:14 +00002417 case EXPR_SUBST_NON_TYPE_TEMPLATE_PARM:
2418 S = new (Context) SubstNonTypeTemplateParmExpr(Empty);
2419 break;
2420
Douglas Gregorc7793c72011-01-15 01:15:58 +00002421 case EXPR_SUBST_NON_TYPE_TEMPLATE_PARM_PACK:
2422 S = new (Context) SubstNonTypeTemplateParmPackExpr(Empty);
2423 break;
Richard Smith9a4db032012-09-12 00:56:43 +00002424
2425 case EXPR_FUNCTION_PARM_PACK:
2426 S = FunctionParmPackExpr::CreateEmpty(Context,
2427 Record[ASTStmtReader::NumExprFields]);
2428 break;
Douglas Gregorc7793c72011-01-15 01:15:58 +00002429
Douglas Gregor03e80032011-06-21 17:03:29 +00002430 case EXPR_MATERIALIZE_TEMPORARY:
2431 S = new (Context) MaterializeTemporaryExpr(Empty);
2432 break;
2433
Argyrios Kyrtzidis8bc27822011-12-03 03:49:52 +00002434 case EXPR_OPAQUE_VALUE:
2435 S = new (Context) OpaqueValueExpr(Empty);
John McCall7cd7d1a2010-11-15 23:31:06 +00002436 break;
Peter Collingbournee08ce652011-02-09 21:07:24 +00002437
2438 case EXPR_CUDA_KERNEL_CALL:
Douglas Gregor35942772011-09-09 21:34:22 +00002439 S = new (Context) CUDAKernelCallExpr(Context, Empty);
Peter Collingbournee08ce652011-02-09 21:07:24 +00002440 break;
Tanya Lattner61eee0c2011-06-04 00:47:47 +00002441
2442 case EXPR_ASTYPE:
2443 S = new (Context) AsTypeExpr(Empty);
2444 break;
Eli Friedman276b0612011-10-11 02:20:01 +00002445
John McCall4b9c2d22011-11-06 09:01:30 +00002446 case EXPR_PSEUDO_OBJECT: {
2447 unsigned numSemanticExprs = Record[ASTStmtReader::NumExprFields];
2448 S = PseudoObjectExpr::Create(Context, Empty, numSemanticExprs);
2449 break;
2450 }
2451
Eli Friedman276b0612011-10-11 02:20:01 +00002452 case EXPR_ATOMIC:
2453 S = new (Context) AtomicExpr(Empty);
2454 break;
Douglas Gregor9d36f5d2012-02-14 17:54:36 +00002455
2456 case EXPR_LAMBDA: {
2457 unsigned NumCaptures = Record[ASTStmtReader::NumExprFields];
2458 unsigned NumArrayIndexVars = Record[ASTStmtReader::NumExprFields + 1];
2459 S = LambdaExpr::CreateDeserialized(Context, NumCaptures,
2460 NumArrayIndexVars);
2461 break;
2462 }
Chris Lattner4c6f9522009-04-27 05:14:47 +00002463 }
Argyrios Kyrtzidis6d00c132010-07-10 11:46:15 +00002464
Chris Lattner4c6f9522009-04-27 05:14:47 +00002465 // We hit a STMT_STOP, so we're done with this expression.
2466 if (Finished)
2467 break;
2468
2469 ++NumStatementsRead;
2470
Argyrios Kyrtzidise6f08682011-10-21 23:02:28 +00002471 if (S && !IsStmtReference) {
Argyrios Kyrtzidis919e6932010-06-28 22:28:35 +00002472 Reader.Visit(S);
Argyrios Kyrtzidise6f08682011-10-21 23:02:28 +00002473 StmtEntries[Cursor.GetCurrentBitNo()] = S;
2474 }
2475
Chris Lattner4c6f9522009-04-27 05:14:47 +00002476
2477 assert(Idx == Record.size() && "Invalid deserialization of statement");
2478 StmtStack.push_back(S);
2479 }
Chris Lattnerb3ce3572013-01-20 02:38:54 +00002480Done:
Argyrios Kyrtzidis919e6932010-06-28 22:28:35 +00002481 assert(StmtStack.size() > PrevNumStmts && "Read too many sub stmts!");
2482 assert(StmtStack.size() == PrevNumStmts + 1 && "Extra expressions on stack!");
Argyrios Kyrtzidis919e6932010-06-28 22:28:35 +00002483 return StmtStack.pop_back_val();
Chris Lattner4c6f9522009-04-27 05:14:47 +00002484}