blob: 1115e8fd4f4563964a468f8b7228cb7233763ef1 [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 Bataevd195bc32013-10-01 05:32:34 +00001700 case OMPC_firstprivate:
1701 C = OMPFirstprivateClause::CreateEmpty(Context, Record[Idx++]);
1702 break;
Alexey Bataev0c018352013-09-06 18:03:48 +00001703 case OMPC_shared:
1704 C = OMPSharedClause::CreateEmpty(Context, Record[Idx++]);
1705 break;
Alexey Bataev4fa7eab2013-07-19 03:13:43 +00001706 }
1707 Visit(C);
1708 C->setLocStart(Reader->ReadSourceLocation(Record, Idx));
1709 C->setLocEnd(Reader->ReadSourceLocation(Record, Idx));
1710
1711 return C;
1712}
1713
1714void OMPClauseReader::VisitOMPDefaultClause(OMPDefaultClause *C) {
1715 C->setDefaultKind(
1716 static_cast<OpenMPDefaultClauseKind>(Record[Idx++]));
1717 C->setLParenLoc(Reader->ReadSourceLocation(Record, Idx));
1718 C->setDefaultKindKwLoc(Reader->ReadSourceLocation(Record, Idx));
1719}
1720
1721void OMPClauseReader::VisitOMPPrivateClause(OMPPrivateClause *C) {
1722 C->setLParenLoc(Reader->ReadSourceLocation(Record, Idx));
1723 unsigned NumVars = C->varlist_size();
1724 SmallVector<Expr *, 16> Vars;
1725 Vars.reserve(NumVars);
1726 for (unsigned i = 0; i != NumVars; ++i)
1727 Vars.push_back(Reader->Reader.ReadSubExpr());
1728 C->setVarRefs(Vars);
1729}
1730
Alexey Bataevd195bc32013-10-01 05:32:34 +00001731void OMPClauseReader::VisitOMPFirstprivateClause(OMPFirstprivateClause *C) {
1732 C->setLParenLoc(Reader->ReadSourceLocation(Record, Idx));
1733 unsigned NumVars = C->varlist_size();
1734 SmallVector<Expr *, 16> Vars;
1735 Vars.reserve(NumVars);
1736 for (unsigned i = 0; i != NumVars; ++i)
1737 Vars.push_back(Reader->Reader.ReadSubExpr());
1738 C->setVarRefs(Vars);
1739}
1740
Alexey Bataev0c018352013-09-06 18:03:48 +00001741void OMPClauseReader::VisitOMPSharedClause(OMPSharedClause *C) {
1742 C->setLParenLoc(Reader->ReadSourceLocation(Record, Idx));
1743 unsigned NumVars = C->varlist_size();
1744 SmallVector<Expr *, 16> Vars;
1745 Vars.reserve(NumVars);
1746 for (unsigned i = 0; i != NumVars; ++i)
1747 Vars.push_back(Reader->Reader.ReadSubExpr());
1748 C->setVarRefs(Vars);
1749}
1750
Alexey Bataev4fa7eab2013-07-19 03:13:43 +00001751//===----------------------------------------------------------------------===//
1752// OpenMP Directives.
1753//===----------------------------------------------------------------------===//
1754void ASTStmtReader::VisitOMPExecutableDirective(OMPExecutableDirective *E) {
1755 VisitStmt(E);
1756 ++Idx;
1757 E->setLocStart(ReadSourceLocation(Record, Idx));
1758 E->setLocEnd(ReadSourceLocation(Record, Idx));
1759 OMPClauseReader ClauseReader(this, Reader.getContext(), Record, Idx);
1760 SmallVector<OMPClause *, 5> Clauses;
1761 for (unsigned i = 0; i < E->getNumClauses(); ++i)
1762 Clauses.push_back(ClauseReader.readClause());
1763 E->setClauses(Clauses);
1764 E->setAssociatedStmt(Reader.ReadSubStmt());
1765}
1766
1767void ASTStmtReader::VisitOMPParallelDirective(OMPParallelDirective *D) {
1768 VisitOMPExecutableDirective(D);
1769}
1770
1771//===----------------------------------------------------------------------===//
John McCall7110fd62011-07-15 07:00:14 +00001772// ASTReader Implementation
1773//===----------------------------------------------------------------------===//
1774
Douglas Gregor1a4761e2011-11-30 23:21:26 +00001775Stmt *ASTReader::ReadStmt(ModuleFile &F) {
Argyrios Kyrtzidis919e6932010-06-28 22:28:35 +00001776 switch (ReadingKind) {
Richard Smithafb90df2013-07-31 00:26:46 +00001777 case Read_None:
1778 llvm_unreachable("should not call this when not reading anything");
Argyrios Kyrtzidis919e6932010-06-28 22:28:35 +00001779 case Read_Decl:
1780 case Read_Type:
Sebastian Redlc3632732010-10-05 15:59:54 +00001781 return ReadStmtFromStream(F);
Argyrios Kyrtzidis919e6932010-06-28 22:28:35 +00001782 case Read_Stmt:
Argyrios Kyrtzidisd98a2ab2010-06-29 22:46:25 +00001783 return ReadSubStmt();
Argyrios Kyrtzidis919e6932010-06-28 22:28:35 +00001784 }
1785
1786 llvm_unreachable("ReadingKind not set ?");
Argyrios Kyrtzidis919e6932010-06-28 22:28:35 +00001787}
1788
Douglas Gregor1a4761e2011-11-30 23:21:26 +00001789Expr *ASTReader::ReadExpr(ModuleFile &F) {
Sebastian Redlc3632732010-10-05 15:59:54 +00001790 return cast_or_null<Expr>(ReadStmt(F));
Argyrios Kyrtzidis919e6932010-06-28 22:28:35 +00001791}
Chris Lattner030854b2010-05-09 06:40:08 +00001792
Sebastian Redlc43b54c2010-08-18 23:56:43 +00001793Expr *ASTReader::ReadSubExpr() {
Argyrios Kyrtzidisd98a2ab2010-06-29 22:46:25 +00001794 return cast_or_null<Expr>(ReadSubStmt());
1795}
1796
Chris Lattner52e97d12009-04-27 05:41:06 +00001797// Within the bitstream, expressions are stored in Reverse Polish
1798// Notation, with each of the subexpressions preceding the
Argyrios Kyrtzidis919e6932010-06-28 22:28:35 +00001799// expression they are stored in. Subexpressions are stored from last to first.
1800// To evaluate expressions, we continue reading expressions and placing them on
1801// the stack, with expressions having operands removing those operands from the
Chris Lattner52e97d12009-04-27 05:41:06 +00001802// stack. Evaluation terminates when we see a STMT_STOP record, and
1803// the single remaining expression on the stack is our result.
Douglas Gregor1a4761e2011-11-30 23:21:26 +00001804Stmt *ASTReader::ReadStmtFromStream(ModuleFile &F) {
Argyrios Kyrtzidis919e6932010-06-28 22:28:35 +00001805
1806 ReadingKindTracker ReadingKind(Read_Stmt, *this);
Sebastian Redlc3632732010-10-05 15:59:54 +00001807 llvm::BitstreamCursor &Cursor = F.DeclsCursor;
Argyrios Kyrtzidise6f08682011-10-21 23:02:28 +00001808
1809 // Map of offset to previously deserialized stmt. The offset points
1810 /// just after the stmt record.
1811 llvm::DenseMap<uint64_t, Stmt *> StmtEntries;
Sebastian Redlc3632732010-10-05 15:59:54 +00001812
Argyrios Kyrtzidis919e6932010-06-28 22:28:35 +00001813#ifndef NDEBUG
1814 unsigned PrevNumStmts = StmtStack.size();
1815#endif
1816
Chris Lattner4c6f9522009-04-27 05:14:47 +00001817 RecordData Record;
1818 unsigned Idx;
Sebastian Redlc3632732010-10-05 15:59:54 +00001819 ASTStmtReader Reader(*this, F, Cursor, Record, Idx);
Chris Lattner4c6f9522009-04-27 05:14:47 +00001820 Stmt::EmptyShell Empty;
1821
1822 while (true) {
Chris Lattnerb3ce3572013-01-20 02:38:54 +00001823 llvm::BitstreamEntry Entry = Cursor.advanceSkippingSubblocks();
1824
1825 switch (Entry.Kind) {
1826 case llvm::BitstreamEntry::SubBlock: // Handled for us already.
1827 case llvm::BitstreamEntry::Error:
1828 Error("malformed block record in AST file");
1829 return 0;
1830 case llvm::BitstreamEntry::EndBlock:
1831 goto Done;
1832 case llvm::BitstreamEntry::Record:
1833 // The interesting case.
Chris Lattner4c6f9522009-04-27 05:14:47 +00001834 break;
1835 }
1836
Chris Lattner4c6f9522009-04-27 05:14:47 +00001837
1838 Stmt *S = 0;
1839 Idx = 0;
1840 Record.clear();
1841 bool Finished = false;
Argyrios Kyrtzidise6f08682011-10-21 23:02:28 +00001842 bool IsStmtReference = false;
Chris Lattnerb3ce3572013-01-20 02:38:54 +00001843 switch ((StmtCode)Cursor.readRecord(Entry.ID, Record)) {
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001844 case STMT_STOP:
Chris Lattner4c6f9522009-04-27 05:14:47 +00001845 Finished = true;
1846 break;
1847
Argyrios Kyrtzidise6f08682011-10-21 23:02:28 +00001848 case STMT_REF_PTR:
1849 IsStmtReference = true;
1850 assert(StmtEntries.find(Record[0]) != StmtEntries.end() &&
1851 "No stmt was recorded for this offset reference!");
1852 S = StmtEntries[Record[Idx++]];
1853 break;
1854
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001855 case STMT_NULL_PTR:
Mike Stump1eb44332009-09-09 15:08:12 +00001856 S = 0;
Chris Lattner4c6f9522009-04-27 05:14:47 +00001857 break;
1858
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001859 case STMT_NULL:
Chris Lattner4c6f9522009-04-27 05:14:47 +00001860 S = new (Context) NullStmt(Empty);
1861 break;
1862
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001863 case STMT_COMPOUND:
Chris Lattner4c6f9522009-04-27 05:14:47 +00001864 S = new (Context) CompoundStmt(Empty);
1865 break;
1866
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001867 case STMT_CASE:
Chris Lattner4c6f9522009-04-27 05:14:47 +00001868 S = new (Context) CaseStmt(Empty);
1869 break;
1870
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001871 case STMT_DEFAULT:
Chris Lattner4c6f9522009-04-27 05:14:47 +00001872 S = new (Context) DefaultStmt(Empty);
1873 break;
1874
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001875 case STMT_LABEL:
Chris Lattner4c6f9522009-04-27 05:14:47 +00001876 S = new (Context) LabelStmt(Empty);
1877 break;
1878
Richard Smith534986f2012-04-14 00:33:13 +00001879 case STMT_ATTRIBUTED:
Alexander Kornienko49908902012-07-09 10:04:07 +00001880 S = AttributedStmt::CreateEmpty(
1881 Context,
1882 /*NumAttrs*/Record[ASTStmtReader::NumStmtFields]);
Richard Smith534986f2012-04-14 00:33:13 +00001883 break;
1884
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001885 case STMT_IF:
Chris Lattner4c6f9522009-04-27 05:14:47 +00001886 S = new (Context) IfStmt(Empty);
1887 break;
1888
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001889 case STMT_SWITCH:
Chris Lattner4c6f9522009-04-27 05:14:47 +00001890 S = new (Context) SwitchStmt(Empty);
1891 break;
1892
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001893 case STMT_WHILE:
Chris Lattner4c6f9522009-04-27 05:14:47 +00001894 S = new (Context) WhileStmt(Empty);
1895 break;
1896
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001897 case STMT_DO:
Chris Lattner4c6f9522009-04-27 05:14:47 +00001898 S = new (Context) DoStmt(Empty);
1899 break;
Mike Stump1eb44332009-09-09 15:08:12 +00001900
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001901 case STMT_FOR:
Chris Lattner4c6f9522009-04-27 05:14:47 +00001902 S = new (Context) ForStmt(Empty);
1903 break;
1904
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001905 case STMT_GOTO:
Chris Lattner4c6f9522009-04-27 05:14:47 +00001906 S = new (Context) GotoStmt(Empty);
1907 break;
Mike Stump1eb44332009-09-09 15:08:12 +00001908
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001909 case STMT_INDIRECT_GOTO:
Chris Lattner4c6f9522009-04-27 05:14:47 +00001910 S = new (Context) IndirectGotoStmt(Empty);
1911 break;
1912
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001913 case STMT_CONTINUE:
Chris Lattner4c6f9522009-04-27 05:14:47 +00001914 S = new (Context) ContinueStmt(Empty);
1915 break;
1916
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001917 case STMT_BREAK:
Chris Lattner4c6f9522009-04-27 05:14:47 +00001918 S = new (Context) BreakStmt(Empty);
1919 break;
1920
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001921 case STMT_RETURN:
Chris Lattner4c6f9522009-04-27 05:14:47 +00001922 S = new (Context) ReturnStmt(Empty);
1923 break;
1924
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001925 case STMT_DECL:
Chris Lattner4c6f9522009-04-27 05:14:47 +00001926 S = new (Context) DeclStmt(Empty);
1927 break;
1928
Chad Rosierdf5faf52012-08-25 00:11:56 +00001929 case STMT_GCCASM:
1930 S = new (Context) GCCAsmStmt(Empty);
Chris Lattner4c6f9522009-04-27 05:14:47 +00001931 break;
1932
Chad Rosiercd518a02012-08-24 23:51:02 +00001933 case STMT_MSASM:
1934 S = new (Context) MSAsmStmt(Empty);
1935 break;
1936
Tareq A. Siraj051303c2013-04-16 18:53:08 +00001937 case STMT_CAPTURED:
Ben Langmuirdc5be4f2013-05-03 19:20:19 +00001938 S = CapturedStmt::CreateDeserialized(Context,
Alexey Bataev4fa7eab2013-07-19 03:13:43 +00001939 Record[ASTStmtReader::NumStmtFields]);
Tareq A. Siraj051303c2013-04-16 18:53:08 +00001940 break;
1941
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001942 case EXPR_PREDEFINED:
Chris Lattner4c6f9522009-04-27 05:14:47 +00001943 S = new (Context) PredefinedExpr(Empty);
1944 break;
Mike Stump1eb44332009-09-09 15:08:12 +00001945
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001946 case EXPR_DECL_REF:
Chandler Carruth3aa81402011-05-01 23:48:14 +00001947 S = DeclRefExpr::CreateEmpty(
Douglas Gregor35942772011-09-09 21:34:22 +00001948 Context,
Chandler Carruth3aa81402011-05-01 23:48:14 +00001949 /*HasQualifier=*/Record[ASTStmtReader::NumExprFields],
1950 /*HasFoundDecl=*/Record[ASTStmtReader::NumExprFields + 1],
Abramo Bagnarae4b92762012-01-27 09:46:47 +00001951 /*HasTemplateKWAndArgsInfo=*/Record[ASTStmtReader::NumExprFields + 2],
Chandler Carruth3aa81402011-05-01 23:48:14 +00001952 /*NumTemplateArgs=*/Record[ASTStmtReader::NumExprFields + 2] ?
John McCallf4b88a42012-03-10 09:33:50 +00001953 Record[ASTStmtReader::NumExprFields + 5] : 0);
Chris Lattner4c6f9522009-04-27 05:14:47 +00001954 break;
Mike Stump1eb44332009-09-09 15:08:12 +00001955
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001956 case EXPR_INTEGER_LITERAL:
Douglas Gregor35942772011-09-09 21:34:22 +00001957 S = IntegerLiteral::Create(Context, Empty);
Chris Lattner4c6f9522009-04-27 05:14:47 +00001958 break;
Mike Stump1eb44332009-09-09 15:08:12 +00001959
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001960 case EXPR_FLOATING_LITERAL:
Douglas Gregor35942772011-09-09 21:34:22 +00001961 S = FloatingLiteral::Create(Context, Empty);
Chris Lattner4c6f9522009-04-27 05:14:47 +00001962 break;
Mike Stump1eb44332009-09-09 15:08:12 +00001963
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001964 case EXPR_IMAGINARY_LITERAL:
Chris Lattner4c6f9522009-04-27 05:14:47 +00001965 S = new (Context) ImaginaryLiteral(Empty);
1966 break;
1967
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001968 case EXPR_STRING_LITERAL:
Douglas Gregor35942772011-09-09 21:34:22 +00001969 S = StringLiteral::CreateEmpty(Context,
Sebastian Redl60adf4a2010-08-18 23:56:52 +00001970 Record[ASTStmtReader::NumExprFields + 1]);
Chris Lattner4c6f9522009-04-27 05:14:47 +00001971 break;
1972
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001973 case EXPR_CHARACTER_LITERAL:
Chris Lattner4c6f9522009-04-27 05:14:47 +00001974 S = new (Context) CharacterLiteral(Empty);
1975 break;
1976
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001977 case EXPR_PAREN:
Chris Lattner4c6f9522009-04-27 05:14:47 +00001978 S = new (Context) ParenExpr(Empty);
1979 break;
1980
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001981 case EXPR_PAREN_LIST:
Argyrios Kyrtzidis37bdfe22010-06-30 08:49:18 +00001982 S = new (Context) ParenListExpr(Empty);
1983 break;
1984
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001985 case EXPR_UNARY_OPERATOR:
Chris Lattner4c6f9522009-04-27 05:14:47 +00001986 S = new (Context) UnaryOperator(Empty);
1987 break;
1988
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001989 case EXPR_OFFSETOF:
Douglas Gregor35942772011-09-09 21:34:22 +00001990 S = OffsetOfExpr::CreateEmpty(Context,
Sebastian Redl60adf4a2010-08-18 23:56:52 +00001991 Record[ASTStmtReader::NumExprFields],
1992 Record[ASTStmtReader::NumExprFields + 1]);
Douglas Gregor8ecdb652010-04-28 22:16:22 +00001993 break;
1994
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001995 case EXPR_SIZEOF_ALIGN_OF:
Peter Collingbournef4e3cfb2011-03-11 19:24:49 +00001996 S = new (Context) UnaryExprOrTypeTraitExpr(Empty);
Chris Lattner4c6f9522009-04-27 05:14:47 +00001997 break;
1998
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001999 case EXPR_ARRAY_SUBSCRIPT:
Chris Lattner4c6f9522009-04-27 05:14:47 +00002000 S = new (Context) ArraySubscriptExpr(Empty);
2001 break;
2002
Sebastian Redl8538e8d2010-08-18 23:57:32 +00002003 case EXPR_CALL:
Douglas Gregor35942772011-09-09 21:34:22 +00002004 S = new (Context) CallExpr(Context, Stmt::CallExprClass, Empty);
Chris Lattner4c6f9522009-04-27 05:14:47 +00002005 break;
2006
Sebastian Redl8538e8d2010-08-18 23:57:32 +00002007 case EXPR_MEMBER: {
Argyrios Kyrtzidis663e3802010-07-08 13:09:47 +00002008 // We load everything here and fully initialize it at creation.
2009 // That way we can use MemberExpr::Create and don't have to duplicate its
2010 // logic with a MemberExpr::CreateEmpty.
2011
2012 assert(Idx == 0);
Douglas Gregor40d96a62011-02-28 21:54:11 +00002013 NestedNameSpecifierLoc QualifierLoc;
Argyrios Kyrtzidis663e3802010-07-08 13:09:47 +00002014 if (Record[Idx++]) { // HasQualifier.
Douglas Gregor40d96a62011-02-28 21:54:11 +00002015 QualifierLoc = ReadNestedNameSpecifierLoc(F, Record, Idx);
Argyrios Kyrtzidis663e3802010-07-08 13:09:47 +00002016 }
2017
Abramo Bagnarae4b92762012-01-27 09:46:47 +00002018 SourceLocation TemplateKWLoc;
Argyrios Kyrtzidis663e3802010-07-08 13:09:47 +00002019 TemplateArgumentListInfo ArgInfo;
Abramo Bagnarae4b92762012-01-27 09:46:47 +00002020 bool HasTemplateKWAndArgsInfo = Record[Idx++];
2021 if (HasTemplateKWAndArgsInfo) {
2022 TemplateKWLoc = ReadSourceLocation(F, Record, Idx);
Douglas Gregordef03542011-02-04 12:01:24 +00002023 unsigned NumTemplateArgs = Record[Idx++];
Sebastian Redlc3632732010-10-05 15:59:54 +00002024 ArgInfo.setLAngleLoc(ReadSourceLocation(F, Record, Idx));
2025 ArgInfo.setRAngleLoc(ReadSourceLocation(F, Record, Idx));
Argyrios Kyrtzidis663e3802010-07-08 13:09:47 +00002026 for (unsigned i = 0; i != NumTemplateArgs; ++i)
Sebastian Redlc3632732010-10-05 15:59:54 +00002027 ArgInfo.addArgument(ReadTemplateArgumentLoc(F, Record, Idx));
Argyrios Kyrtzidis663e3802010-07-08 13:09:47 +00002028 }
Abramo Bagnara7cc58b42011-10-05 07:56:41 +00002029
2030 bool HadMultipleCandidates = Record[Idx++];
2031
Douglas Gregor409448c2011-07-21 22:35:25 +00002032 NamedDecl *FoundD = ReadDeclAs<NamedDecl>(F, Record, Idx);
Argyrios Kyrtzidis663e3802010-07-08 13:09:47 +00002033 AccessSpecifier AS = (AccessSpecifier)Record[Idx++];
2034 DeclAccessPair FoundDecl = DeclAccessPair::make(FoundD, AS);
2035
Douglas Gregor393f2492011-07-22 00:38:23 +00002036 QualType T = readType(F, Record, Idx);
John McCallf89e55a2010-11-18 06:31:45 +00002037 ExprValueKind VK = static_cast<ExprValueKind>(Record[Idx++]);
2038 ExprObjectKind OK = static_cast<ExprObjectKind>(Record[Idx++]);
Argyrios Kyrtzidis663e3802010-07-08 13:09:47 +00002039 Expr *Base = ReadSubExpr();
Douglas Gregor409448c2011-07-21 22:35:25 +00002040 ValueDecl *MemberD = ReadDeclAs<ValueDecl>(F, Record, Idx);
Sebastian Redlc3632732010-10-05 15:59:54 +00002041 SourceLocation MemberLoc = ReadSourceLocation(F, Record, Idx);
Abramo Bagnara25777432010-08-11 22:01:17 +00002042 DeclarationNameInfo MemberNameInfo(MemberD->getDeclName(), MemberLoc);
Argyrios Kyrtzidis663e3802010-07-08 13:09:47 +00002043 bool IsArrow = Record[Idx++];
2044
Douglas Gregor35942772011-09-09 21:34:22 +00002045 S = MemberExpr::Create(Context, Base, IsArrow, QualifierLoc,
Abramo Bagnarae4b92762012-01-27 09:46:47 +00002046 TemplateKWLoc, MemberD, FoundDecl, MemberNameInfo,
2047 HasTemplateKWAndArgsInfo ? &ArgInfo : 0,
2048 T, VK, OK);
Argyrios Kyrtzidis40451072010-10-15 18:21:24 +00002049 ReadDeclarationNameLoc(F, cast<MemberExpr>(S)->MemberDNLoc,
2050 MemberD->getDeclName(), Record, Idx);
Abramo Bagnara7cc58b42011-10-05 07:56:41 +00002051 if (HadMultipleCandidates)
2052 cast<MemberExpr>(S)->setHadMultipleCandidates(true);
Chris Lattner4c6f9522009-04-27 05:14:47 +00002053 break;
Argyrios Kyrtzidis663e3802010-07-08 13:09:47 +00002054 }
Chris Lattner4c6f9522009-04-27 05:14:47 +00002055
Sebastian Redl8538e8d2010-08-18 23:57:32 +00002056 case EXPR_BINARY_OPERATOR:
Chris Lattner4c6f9522009-04-27 05:14:47 +00002057 S = new (Context) BinaryOperator(Empty);
2058 break;
2059
Sebastian Redl8538e8d2010-08-18 23:57:32 +00002060 case EXPR_COMPOUND_ASSIGN_OPERATOR:
Chris Lattner4c6f9522009-04-27 05:14:47 +00002061 S = new (Context) CompoundAssignOperator(Empty);
2062 break;
2063
Sebastian Redl8538e8d2010-08-18 23:57:32 +00002064 case EXPR_CONDITIONAL_OPERATOR:
Chris Lattner4c6f9522009-04-27 05:14:47 +00002065 S = new (Context) ConditionalOperator(Empty);
2066 break;
2067
John McCall56ca35d2011-02-17 10:25:35 +00002068 case EXPR_BINARY_CONDITIONAL_OPERATOR:
2069 S = new (Context) BinaryConditionalOperator(Empty);
2070 break;
2071
Sebastian Redl8538e8d2010-08-18 23:57:32 +00002072 case EXPR_IMPLICIT_CAST:
Douglas Gregor35942772011-09-09 21:34:22 +00002073 S = ImplicitCastExpr::CreateEmpty(Context,
Sebastian Redl60adf4a2010-08-18 23:56:52 +00002074 /*PathSize*/ Record[ASTStmtReader::NumExprFields]);
Chris Lattner4c6f9522009-04-27 05:14:47 +00002075 break;
2076
Sebastian Redl8538e8d2010-08-18 23:57:32 +00002077 case EXPR_CSTYLE_CAST:
Douglas Gregor35942772011-09-09 21:34:22 +00002078 S = CStyleCastExpr::CreateEmpty(Context,
Sebastian Redl60adf4a2010-08-18 23:56:52 +00002079 /*PathSize*/ Record[ASTStmtReader::NumExprFields]);
Chris Lattner4c6f9522009-04-27 05:14:47 +00002080 break;
2081
Sebastian Redl8538e8d2010-08-18 23:57:32 +00002082 case EXPR_COMPOUND_LITERAL:
Chris Lattner4c6f9522009-04-27 05:14:47 +00002083 S = new (Context) CompoundLiteralExpr(Empty);
2084 break;
2085
Sebastian Redl8538e8d2010-08-18 23:57:32 +00002086 case EXPR_EXT_VECTOR_ELEMENT:
Chris Lattner4c6f9522009-04-27 05:14:47 +00002087 S = new (Context) ExtVectorElementExpr(Empty);
2088 break;
2089
Sebastian Redl8538e8d2010-08-18 23:57:32 +00002090 case EXPR_INIT_LIST:
Argyrios Kyrtzidis2a82ca22012-11-28 03:56:16 +00002091 S = new (Context) InitListExpr(Empty);
Chris Lattner4c6f9522009-04-27 05:14:47 +00002092 break;
2093
Sebastian Redl8538e8d2010-08-18 23:57:32 +00002094 case EXPR_DESIGNATED_INIT:
Douglas Gregor35942772011-09-09 21:34:22 +00002095 S = DesignatedInitExpr::CreateEmpty(Context,
Sebastian Redl60adf4a2010-08-18 23:56:52 +00002096 Record[ASTStmtReader::NumExprFields] - 1);
Mike Stump1eb44332009-09-09 15:08:12 +00002097
Chris Lattner4c6f9522009-04-27 05:14:47 +00002098 break;
2099
Sebastian Redl8538e8d2010-08-18 23:57:32 +00002100 case EXPR_IMPLICIT_VALUE_INIT:
Chris Lattner4c6f9522009-04-27 05:14:47 +00002101 S = new (Context) ImplicitValueInitExpr(Empty);
2102 break;
2103
Sebastian Redl8538e8d2010-08-18 23:57:32 +00002104 case EXPR_VA_ARG:
Chris Lattner4c6f9522009-04-27 05:14:47 +00002105 S = new (Context) VAArgExpr(Empty);
2106 break;
2107
Sebastian Redl8538e8d2010-08-18 23:57:32 +00002108 case EXPR_ADDR_LABEL:
Chris Lattner4c6f9522009-04-27 05:14:47 +00002109 S = new (Context) AddrLabelExpr(Empty);
2110 break;
2111
Sebastian Redl8538e8d2010-08-18 23:57:32 +00002112 case EXPR_STMT:
Chris Lattner4c6f9522009-04-27 05:14:47 +00002113 S = new (Context) StmtExpr(Empty);
2114 break;
2115
Sebastian Redl8538e8d2010-08-18 23:57:32 +00002116 case EXPR_CHOOSE:
Chris Lattner4c6f9522009-04-27 05:14:47 +00002117 S = new (Context) ChooseExpr(Empty);
2118 break;
2119
Sebastian Redl8538e8d2010-08-18 23:57:32 +00002120 case EXPR_GNU_NULL:
Chris Lattner4c6f9522009-04-27 05:14:47 +00002121 S = new (Context) GNUNullExpr(Empty);
2122 break;
2123
Sebastian Redl8538e8d2010-08-18 23:57:32 +00002124 case EXPR_SHUFFLE_VECTOR:
Chris Lattner4c6f9522009-04-27 05:14:47 +00002125 S = new (Context) ShuffleVectorExpr(Empty);
2126 break;
Mike Stump1eb44332009-09-09 15:08:12 +00002127
Hal Finkel414a1bd2013-09-18 03:29:45 +00002128 case EXPR_CONVERT_VECTOR:
2129 S = new (Context) ConvertVectorExpr(Empty);
2130 break;
2131
Sebastian Redl8538e8d2010-08-18 23:57:32 +00002132 case EXPR_BLOCK:
Chris Lattner4c6f9522009-04-27 05:14:47 +00002133 S = new (Context) BlockExpr(Empty);
2134 break;
2135
Peter Collingbournef111d932011-04-15 00:35:48 +00002136 case EXPR_GENERIC_SELECTION:
2137 S = new (Context) GenericSelectionExpr(Empty);
2138 break;
2139
Sebastian Redl8538e8d2010-08-18 23:57:32 +00002140 case EXPR_OBJC_STRING_LITERAL:
Chris Lattner4c6f9522009-04-27 05:14:47 +00002141 S = new (Context) ObjCStringLiteral(Empty);
2142 break;
Patrick Beardeb382ec2012-04-19 00:25:12 +00002143 case EXPR_OBJC_BOXED_EXPRESSION:
2144 S = new (Context) ObjCBoxedExpr(Empty);
Ted Kremenekebcb57a2012-03-06 20:05:56 +00002145 break;
2146 case EXPR_OBJC_ARRAY_LITERAL:
2147 S = ObjCArrayLiteral::CreateEmpty(Context,
2148 Record[ASTStmtReader::NumExprFields]);
2149 break;
2150 case EXPR_OBJC_DICTIONARY_LITERAL:
2151 S = ObjCDictionaryLiteral::CreateEmpty(Context,
2152 Record[ASTStmtReader::NumExprFields],
2153 Record[ASTStmtReader::NumExprFields + 1]);
2154 break;
Sebastian Redl8538e8d2010-08-18 23:57:32 +00002155 case EXPR_OBJC_ENCODE:
Chris Lattner4c6f9522009-04-27 05:14:47 +00002156 S = new (Context) ObjCEncodeExpr(Empty);
2157 break;
Sebastian Redl8538e8d2010-08-18 23:57:32 +00002158 case EXPR_OBJC_SELECTOR_EXPR:
Chris Lattner4c6f9522009-04-27 05:14:47 +00002159 S = new (Context) ObjCSelectorExpr(Empty);
2160 break;
Sebastian Redl8538e8d2010-08-18 23:57:32 +00002161 case EXPR_OBJC_PROTOCOL_EXPR:
Chris Lattner4c6f9522009-04-27 05:14:47 +00002162 S = new (Context) ObjCProtocolExpr(Empty);
2163 break;
Sebastian Redl8538e8d2010-08-18 23:57:32 +00002164 case EXPR_OBJC_IVAR_REF_EXPR:
Chris Lattner4c6f9522009-04-27 05:14:47 +00002165 S = new (Context) ObjCIvarRefExpr(Empty);
2166 break;
Sebastian Redl8538e8d2010-08-18 23:57:32 +00002167 case EXPR_OBJC_PROPERTY_REF_EXPR:
Chris Lattner4c6f9522009-04-27 05:14:47 +00002168 S = new (Context) ObjCPropertyRefExpr(Empty);
2169 break;
Ted Kremenekebcb57a2012-03-06 20:05:56 +00002170 case EXPR_OBJC_SUBSCRIPT_REF_EXPR:
2171 S = new (Context) ObjCSubscriptRefExpr(Empty);
2172 break;
Sebastian Redl8538e8d2010-08-18 23:57:32 +00002173 case EXPR_OBJC_KVC_REF_EXPR:
John McCall12f78a62010-12-02 01:19:52 +00002174 llvm_unreachable("mismatching AST file");
Sebastian Redl8538e8d2010-08-18 23:57:32 +00002175 case EXPR_OBJC_MESSAGE_EXPR:
Douglas Gregor35942772011-09-09 21:34:22 +00002176 S = ObjCMessageExpr::CreateEmpty(Context,
Argyrios Kyrtzidis20718082011-10-03 06:36:51 +00002177 Record[ASTStmtReader::NumExprFields],
2178 Record[ASTStmtReader::NumExprFields + 1]);
Chris Lattner4c6f9522009-04-27 05:14:47 +00002179 break;
Sebastian Redl8538e8d2010-08-18 23:57:32 +00002180 case EXPR_OBJC_ISA:
Steve Narofff242b1b2009-07-24 17:54:45 +00002181 S = new (Context) ObjCIsaExpr(Empty);
2182 break;
John McCallf85e1932011-06-15 23:02:42 +00002183 case EXPR_OBJC_INDIRECT_COPY_RESTORE:
2184 S = new (Context) ObjCIndirectCopyRestoreExpr(Empty);
2185 break;
2186 case EXPR_OBJC_BRIDGED_CAST:
2187 S = new (Context) ObjCBridgedCastExpr(Empty);
2188 break;
Sebastian Redl8538e8d2010-08-18 23:57:32 +00002189 case STMT_OBJC_FOR_COLLECTION:
Chris Lattner4c6f9522009-04-27 05:14:47 +00002190 S = new (Context) ObjCForCollectionStmt(Empty);
2191 break;
Sebastian Redl8538e8d2010-08-18 23:57:32 +00002192 case STMT_OBJC_CATCH:
Chris Lattner4c6f9522009-04-27 05:14:47 +00002193 S = new (Context) ObjCAtCatchStmt(Empty);
2194 break;
Sebastian Redl8538e8d2010-08-18 23:57:32 +00002195 case STMT_OBJC_FINALLY:
Chris Lattner4c6f9522009-04-27 05:14:47 +00002196 S = new (Context) ObjCAtFinallyStmt(Empty);
2197 break;
Sebastian Redl8538e8d2010-08-18 23:57:32 +00002198 case STMT_OBJC_AT_TRY:
Douglas Gregor35942772011-09-09 21:34:22 +00002199 S = ObjCAtTryStmt::CreateEmpty(Context,
Sebastian Redl60adf4a2010-08-18 23:56:52 +00002200 Record[ASTStmtReader::NumStmtFields],
2201 Record[ASTStmtReader::NumStmtFields + 1]);
Chris Lattner4c6f9522009-04-27 05:14:47 +00002202 break;
Sebastian Redl8538e8d2010-08-18 23:57:32 +00002203 case STMT_OBJC_AT_SYNCHRONIZED:
Chris Lattner4c6f9522009-04-27 05:14:47 +00002204 S = new (Context) ObjCAtSynchronizedStmt(Empty);
2205 break;
Sebastian Redl8538e8d2010-08-18 23:57:32 +00002206 case STMT_OBJC_AT_THROW:
Chris Lattner4c6f9522009-04-27 05:14:47 +00002207 S = new (Context) ObjCAtThrowStmt(Empty);
2208 break;
John McCallf85e1932011-06-15 23:02:42 +00002209 case STMT_OBJC_AUTORELEASE_POOL:
2210 S = new (Context) ObjCAutoreleasePoolStmt(Empty);
2211 break;
Ted Kremenekebcb57a2012-03-06 20:05:56 +00002212 case EXPR_OBJC_BOOL_LITERAL:
2213 S = new (Context) ObjCBoolLiteralExpr(Empty);
2214 break;
John McCall7110fd62011-07-15 07:00:14 +00002215 case STMT_SEH_EXCEPT:
2216 S = new (Context) SEHExceptStmt(Empty);
2217 break;
2218 case STMT_SEH_FINALLY:
2219 S = new (Context) SEHFinallyStmt(Empty);
2220 break;
2221 case STMT_SEH_TRY:
2222 S = new (Context) SEHTryStmt(Empty);
2223 break;
Sebastian Redl8538e8d2010-08-18 23:57:32 +00002224 case STMT_CXX_CATCH:
Argyrios Kyrtzidis7cb45e32010-07-22 16:03:56 +00002225 S = new (Context) CXXCatchStmt(Empty);
2226 break;
2227
Sebastian Redl8538e8d2010-08-18 23:57:32 +00002228 case STMT_CXX_TRY:
Douglas Gregor35942772011-09-09 21:34:22 +00002229 S = CXXTryStmt::Create(Context, Empty,
Sebastian Redl60adf4a2010-08-18 23:56:52 +00002230 /*NumHandlers=*/Record[ASTStmtReader::NumStmtFields]);
Argyrios Kyrtzidis7cb45e32010-07-22 16:03:56 +00002231 break;
2232
Richard Smithad762fc2011-04-14 22:09:26 +00002233 case STMT_CXX_FOR_RANGE:
2234 S = new (Context) CXXForRangeStmt(Empty);
2235 break;
2236
Douglas Gregorba0513d2011-10-25 01:33:02 +00002237 case STMT_MS_DEPENDENT_EXISTS:
2238 S = new (Context) MSDependentExistsStmt(SourceLocation(), true,
2239 NestedNameSpecifierLoc(),
2240 DeclarationNameInfo(),
2241 0);
2242 break;
Alexey Bataev4fa7eab2013-07-19 03:13:43 +00002243 case STMT_OMP_PARALLEL_DIRECTIVE:
2244 S =
2245 OMPParallelDirective::CreateEmpty(Context,
2246 Record[ASTStmtReader::NumStmtFields],
2247 Empty);
2248 break;
Douglas Gregorba0513d2011-10-25 01:33:02 +00002249
Sebastian Redl8538e8d2010-08-18 23:57:32 +00002250 case EXPR_CXX_OPERATOR_CALL:
Douglas Gregor35942772011-09-09 21:34:22 +00002251 S = new (Context) CXXOperatorCallExpr(Context, Empty);
Argyrios Kyrtzidisba0a9002009-07-14 03:19:21 +00002252 break;
Chris Lattner1817bd42010-05-09 05:36:05 +00002253
Sebastian Redl8538e8d2010-08-18 23:57:32 +00002254 case EXPR_CXX_MEMBER_CALL:
Douglas Gregor35942772011-09-09 21:34:22 +00002255 S = new (Context) CXXMemberCallExpr(Context, Empty);
Chris Lattner1817bd42010-05-09 05:36:05 +00002256 break;
Douglas Gregor39da0b82009-09-09 23:08:42 +00002257
Sebastian Redl8538e8d2010-08-18 23:57:32 +00002258 case EXPR_CXX_CONSTRUCT:
Argyrios Kyrtzidis6d00c132010-07-10 11:46:15 +00002259 S = new (Context) CXXConstructExpr(Empty);
2260 break;
2261
Sebastian Redl8538e8d2010-08-18 23:57:32 +00002262 case EXPR_CXX_TEMPORARY_OBJECT:
Argyrios Kyrtzidis6d00c132010-07-10 11:46:15 +00002263 S = new (Context) CXXTemporaryObjectExpr(Empty);
Douglas Gregor39da0b82009-09-09 23:08:42 +00002264 break;
Sam Weinigce757a72010-01-16 21:21:01 +00002265
Sebastian Redl8538e8d2010-08-18 23:57:32 +00002266 case EXPR_CXX_STATIC_CAST:
Douglas Gregor35942772011-09-09 21:34:22 +00002267 S = CXXStaticCastExpr::CreateEmpty(Context,
Sebastian Redl60adf4a2010-08-18 23:56:52 +00002268 /*PathSize*/ Record[ASTStmtReader::NumExprFields]);
Sam Weinigce757a72010-01-16 21:21:01 +00002269 break;
2270
Sebastian Redl8538e8d2010-08-18 23:57:32 +00002271 case EXPR_CXX_DYNAMIC_CAST:
Douglas Gregor35942772011-09-09 21:34:22 +00002272 S = CXXDynamicCastExpr::CreateEmpty(Context,
Sebastian Redl60adf4a2010-08-18 23:56:52 +00002273 /*PathSize*/ Record[ASTStmtReader::NumExprFields]);
Sam Weinigce757a72010-01-16 21:21:01 +00002274 break;
2275
Sebastian Redl8538e8d2010-08-18 23:57:32 +00002276 case EXPR_CXX_REINTERPRET_CAST:
Douglas Gregor35942772011-09-09 21:34:22 +00002277 S = CXXReinterpretCastExpr::CreateEmpty(Context,
Sebastian Redl60adf4a2010-08-18 23:56:52 +00002278 /*PathSize*/ Record[ASTStmtReader::NumExprFields]);
Sam Weinigce757a72010-01-16 21:21:01 +00002279 break;
2280
Sebastian Redl8538e8d2010-08-18 23:57:32 +00002281 case EXPR_CXX_CONST_CAST:
Douglas Gregor35942772011-09-09 21:34:22 +00002282 S = CXXConstCastExpr::CreateEmpty(Context);
Sam Weinigce757a72010-01-16 21:21:01 +00002283 break;
2284
Sebastian Redl8538e8d2010-08-18 23:57:32 +00002285 case EXPR_CXX_FUNCTIONAL_CAST:
Douglas Gregor35942772011-09-09 21:34:22 +00002286 S = CXXFunctionalCastExpr::CreateEmpty(Context,
Sebastian Redl60adf4a2010-08-18 23:56:52 +00002287 /*PathSize*/ Record[ASTStmtReader::NumExprFields]);
Sam Weinigce757a72010-01-16 21:21:01 +00002288 break;
2289
Richard Smith9fcce652012-03-07 08:35:16 +00002290 case EXPR_USER_DEFINED_LITERAL:
2291 S = new (Context) UserDefinedLiteral(Context, Empty);
2292 break;
2293
Richard Smith7c3e6152013-06-12 22:31:48 +00002294 case EXPR_CXX_STD_INITIALIZER_LIST:
2295 S = new (Context) CXXStdInitializerListExpr(Empty);
2296 break;
2297
Sebastian Redl8538e8d2010-08-18 23:57:32 +00002298 case EXPR_CXX_BOOL_LITERAL:
Sam Weinigeb7f9612010-02-07 06:32:43 +00002299 S = new (Context) CXXBoolLiteralExpr(Empty);
2300 break;
Sam Weinigce757a72010-01-16 21:21:01 +00002301
Sebastian Redl8538e8d2010-08-18 23:57:32 +00002302 case EXPR_CXX_NULL_PTR_LITERAL:
Sam Weinigeb7f9612010-02-07 06:32:43 +00002303 S = new (Context) CXXNullPtrLiteralExpr(Empty);
2304 break;
Sebastian Redl8538e8d2010-08-18 23:57:32 +00002305 case EXPR_CXX_TYPEID_EXPR:
Chris Lattner14ab24f2010-05-09 06:03:39 +00002306 S = new (Context) CXXTypeidExpr(Empty, true);
2307 break;
Sebastian Redl8538e8d2010-08-18 23:57:32 +00002308 case EXPR_CXX_TYPEID_TYPE:
Chris Lattner14ab24f2010-05-09 06:03:39 +00002309 S = new (Context) CXXTypeidExpr(Empty, false);
2310 break;
Francois Pichet01b7c302010-09-08 12:20:18 +00002311 case EXPR_CXX_UUIDOF_EXPR:
2312 S = new (Context) CXXUuidofExpr(Empty, true);
2313 break;
John McCall76da55d2013-04-16 07:28:30 +00002314 case EXPR_CXX_PROPERTY_REF_EXPR:
2315 S = new (Context) MSPropertyRefExpr(Empty);
2316 break;
Francois Pichet01b7c302010-09-08 12:20:18 +00002317 case EXPR_CXX_UUIDOF_TYPE:
2318 S = new (Context) CXXUuidofExpr(Empty, false);
2319 break;
Sebastian Redl8538e8d2010-08-18 23:57:32 +00002320 case EXPR_CXX_THIS:
Chris Lattner2fbdfcd2010-05-09 06:15:05 +00002321 S = new (Context) CXXThisExpr(Empty);
2322 break;
Sebastian Redl8538e8d2010-08-18 23:57:32 +00002323 case EXPR_CXX_THROW:
Chris Lattner2fbdfcd2010-05-09 06:15:05 +00002324 S = new (Context) CXXThrowExpr(Empty);
2325 break;
Sebastian Redl8538e8d2010-08-18 23:57:32 +00002326 case EXPR_CXX_DEFAULT_ARG: {
Sebastian Redl60adf4a2010-08-18 23:56:52 +00002327 bool HasOtherExprStored = Record[ASTStmtReader::NumExprFields];
Argyrios Kyrtzidis8a507332010-07-02 23:30:15 +00002328 if (HasOtherExprStored) {
2329 Expr *SubExpr = ReadSubExpr();
Douglas Gregor35942772011-09-09 21:34:22 +00002330 S = CXXDefaultArgExpr::Create(Context, SourceLocation(), 0, SubExpr);
Argyrios Kyrtzidis8a507332010-07-02 23:30:15 +00002331 } else
2332 S = new (Context) CXXDefaultArgExpr(Empty);
Chris Lattner030854b2010-05-09 06:40:08 +00002333 break;
Argyrios Kyrtzidis8a507332010-07-02 23:30:15 +00002334 }
Richard Smithc3bf52c2013-04-20 22:23:05 +00002335 case EXPR_CXX_DEFAULT_INIT:
2336 S = new (Context) CXXDefaultInitExpr(Empty);
2337 break;
Sebastian Redl8538e8d2010-08-18 23:57:32 +00002338 case EXPR_CXX_BIND_TEMPORARY:
Chris Lattnerd2598362010-05-10 00:25:06 +00002339 S = new (Context) CXXBindTemporaryExpr(Empty);
2340 break;
Douglas Gregore2ca6d42010-09-02 21:50:02 +00002341
Sebastian Redl8538e8d2010-08-18 23:57:32 +00002342 case EXPR_CXX_SCALAR_VALUE_INIT:
Douglas Gregored8abf12010-07-08 06:14:04 +00002343 S = new (Context) CXXScalarValueInitExpr(Empty);
Chris Lattner59218632010-05-10 01:22:27 +00002344 break;
Sebastian Redl8538e8d2010-08-18 23:57:32 +00002345 case EXPR_CXX_NEW:
Chris Lattner59218632010-05-10 01:22:27 +00002346 S = new (Context) CXXNewExpr(Empty);
2347 break;
Sebastian Redl8538e8d2010-08-18 23:57:32 +00002348 case EXPR_CXX_DELETE:
Argyrios Kyrtzidis95fc98c2010-06-22 17:07:59 +00002349 S = new (Context) CXXDeleteExpr(Empty);
2350 break;
Sebastian Redl8538e8d2010-08-18 23:57:32 +00002351 case EXPR_CXX_PSEUDO_DESTRUCTOR:
Argyrios Kyrtzidisde4bd182010-06-28 09:32:03 +00002352 S = new (Context) CXXPseudoDestructorExpr(Empty);
2353 break;
Chris Lattner59218632010-05-10 01:22:27 +00002354
John McCall4765fa02010-12-06 08:20:24 +00002355 case EXPR_EXPR_WITH_CLEANUPS:
John McCall80ee6e82011-11-10 05:35:25 +00002356 S = ExprWithCleanups::Create(Context, Empty,
2357 Record[ASTStmtReader::NumExprFields]);
Chris Lattnerd2598362010-05-10 00:25:06 +00002358 break;
Argyrios Kyrtzidis8dfbd8b2010-06-24 08:57:31 +00002359
Sebastian Redl8538e8d2010-08-18 23:57:32 +00002360 case EXPR_CXX_DEPENDENT_SCOPE_MEMBER:
Douglas Gregor35942772011-09-09 21:34:22 +00002361 S = CXXDependentScopeMemberExpr::CreateEmpty(Context,
Abramo Bagnarae4b92762012-01-27 09:46:47 +00002362 /*HasTemplateKWAndArgsInfo=*/Record[ASTStmtReader::NumExprFields],
Douglas Gregordef03542011-02-04 12:01:24 +00002363 /*NumTemplateArgs=*/Record[ASTStmtReader::NumExprFields]
2364 ? Record[ASTStmtReader::NumExprFields + 1]
2365 : 0);
Argyrios Kyrtzidis8dfbd8b2010-06-24 08:57:31 +00002366 break;
2367
Sebastian Redl8538e8d2010-08-18 23:57:32 +00002368 case EXPR_CXX_DEPENDENT_SCOPE_DECL_REF:
Douglas Gregor35942772011-09-09 21:34:22 +00002369 S = DependentScopeDeclRefExpr::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 Kyrtzidis12dffcd2010-06-28 09:31:56 +00002374 break;
2375
Sebastian Redl8538e8d2010-08-18 23:57:32 +00002376 case EXPR_CXX_UNRESOLVED_CONSTRUCT:
Douglas Gregor35942772011-09-09 21:34:22 +00002377 S = CXXUnresolvedConstructExpr::CreateEmpty(Context,
Sebastian Redl60adf4a2010-08-18 23:56:52 +00002378 /*NumArgs=*/Record[ASTStmtReader::NumExprFields]);
Argyrios Kyrtzidisa77eb082010-06-25 09:03:26 +00002379 break;
2380
Sebastian Redl8538e8d2010-08-18 23:57:32 +00002381 case EXPR_CXX_UNRESOLVED_MEMBER:
Douglas Gregor35942772011-09-09 21:34:22 +00002382 S = UnresolvedMemberExpr::CreateEmpty(Context,
Abramo Bagnarae4b92762012-01-27 09:46:47 +00002383 /*HasTemplateKWAndArgsInfo=*/Record[ASTStmtReader::NumExprFields],
Douglas Gregordef03542011-02-04 12:01:24 +00002384 /*NumTemplateArgs=*/Record[ASTStmtReader::NumExprFields]
2385 ? Record[ASTStmtReader::NumExprFields + 1]
2386 : 0);
Argyrios Kyrtzidis8dfbd8b2010-06-24 08:57:31 +00002387 break;
Argyrios Kyrtzidisbd65bb52010-06-25 09:03:34 +00002388
Sebastian Redl8538e8d2010-08-18 23:57:32 +00002389 case EXPR_CXX_UNRESOLVED_LOOKUP:
Douglas Gregor35942772011-09-09 21:34:22 +00002390 S = UnresolvedLookupExpr::CreateEmpty(Context,
Abramo Bagnarae4b92762012-01-27 09:46:47 +00002391 /*HasTemplateKWAndArgsInfo=*/Record[ASTStmtReader::NumExprFields],
Douglas Gregordef03542011-02-04 12:01:24 +00002392 /*NumTemplateArgs=*/Record[ASTStmtReader::NumExprFields]
2393 ? Record[ASTStmtReader::NumExprFields + 1]
2394 : 0);
Argyrios Kyrtzidisbd65bb52010-06-25 09:03:34 +00002395 break;
Argyrios Kyrtzidis6d00c132010-07-10 11:46:15 +00002396
Sebastian Redl8538e8d2010-08-18 23:57:32 +00002397 case EXPR_CXX_UNARY_TYPE_TRAIT:
Argyrios Kyrtzidis6d00c132010-07-10 11:46:15 +00002398 S = new (Context) UnaryTypeTraitExpr(Empty);
2399 break;
Sebastian Redl6b219d02010-09-10 20:55:54 +00002400
Francois Pichetf1872372010-12-08 22:35:30 +00002401 case EXPR_BINARY_TYPE_TRAIT:
Francois Pichet6ad6f282010-12-07 00:08:36 +00002402 S = new (Context) BinaryTypeTraitExpr(Empty);
2403 break;
2404
Douglas Gregor4ca8ac22012-02-24 07:38:34 +00002405 case EXPR_TYPE_TRAIT:
2406 S = TypeTraitExpr::CreateDeserialized(Context,
2407 Record[ASTStmtReader::NumExprFields]);
2408 break;
2409
John Wiegley21ff2e52011-04-28 00:16:57 +00002410 case EXPR_ARRAY_TYPE_TRAIT:
2411 S = new (Context) ArrayTypeTraitExpr(Empty);
2412 break;
2413
John Wiegley55262202011-04-25 06:54:41 +00002414 case EXPR_CXX_EXPRESSION_TRAIT:
2415 S = new (Context) ExpressionTraitExpr(Empty);
2416 break;
2417
Sebastian Redl6b219d02010-09-10 20:55:54 +00002418 case EXPR_CXX_NOEXCEPT:
2419 S = new (Context) CXXNoexceptExpr(Empty);
2420 break;
John McCall7cd7d1a2010-11-15 23:31:06 +00002421
Douglas Gregorbe230c32011-01-03 17:17:50 +00002422 case EXPR_PACK_EXPANSION:
2423 S = new (Context) PackExpansionExpr(Empty);
2424 break;
2425
Douglas Gregoree8aff02011-01-04 17:33:58 +00002426 case EXPR_SIZEOF_PACK:
2427 S = new (Context) SizeOfPackExpr(Empty);
2428 break;
2429
John McCall7110fd62011-07-15 07:00:14 +00002430 case EXPR_SUBST_NON_TYPE_TEMPLATE_PARM:
2431 S = new (Context) SubstNonTypeTemplateParmExpr(Empty);
2432 break;
2433
Douglas Gregorc7793c72011-01-15 01:15:58 +00002434 case EXPR_SUBST_NON_TYPE_TEMPLATE_PARM_PACK:
2435 S = new (Context) SubstNonTypeTemplateParmPackExpr(Empty);
2436 break;
Richard Smith9a4db032012-09-12 00:56:43 +00002437
2438 case EXPR_FUNCTION_PARM_PACK:
2439 S = FunctionParmPackExpr::CreateEmpty(Context,
2440 Record[ASTStmtReader::NumExprFields]);
2441 break;
Douglas Gregorc7793c72011-01-15 01:15:58 +00002442
Douglas Gregor03e80032011-06-21 17:03:29 +00002443 case EXPR_MATERIALIZE_TEMPORARY:
2444 S = new (Context) MaterializeTemporaryExpr(Empty);
2445 break;
2446
Argyrios Kyrtzidis8bc27822011-12-03 03:49:52 +00002447 case EXPR_OPAQUE_VALUE:
2448 S = new (Context) OpaqueValueExpr(Empty);
John McCall7cd7d1a2010-11-15 23:31:06 +00002449 break;
Peter Collingbournee08ce652011-02-09 21:07:24 +00002450
2451 case EXPR_CUDA_KERNEL_CALL:
Douglas Gregor35942772011-09-09 21:34:22 +00002452 S = new (Context) CUDAKernelCallExpr(Context, Empty);
Peter Collingbournee08ce652011-02-09 21:07:24 +00002453 break;
Tanya Lattner61eee0c2011-06-04 00:47:47 +00002454
2455 case EXPR_ASTYPE:
2456 S = new (Context) AsTypeExpr(Empty);
2457 break;
Eli Friedman276b0612011-10-11 02:20:01 +00002458
John McCall4b9c2d22011-11-06 09:01:30 +00002459 case EXPR_PSEUDO_OBJECT: {
2460 unsigned numSemanticExprs = Record[ASTStmtReader::NumExprFields];
2461 S = PseudoObjectExpr::Create(Context, Empty, numSemanticExprs);
2462 break;
2463 }
2464
Eli Friedman276b0612011-10-11 02:20:01 +00002465 case EXPR_ATOMIC:
2466 S = new (Context) AtomicExpr(Empty);
2467 break;
Douglas Gregor9d36f5d2012-02-14 17:54:36 +00002468
2469 case EXPR_LAMBDA: {
2470 unsigned NumCaptures = Record[ASTStmtReader::NumExprFields];
2471 unsigned NumArrayIndexVars = Record[ASTStmtReader::NumExprFields + 1];
2472 S = LambdaExpr::CreateDeserialized(Context, NumCaptures,
2473 NumArrayIndexVars);
2474 break;
2475 }
Chris Lattner4c6f9522009-04-27 05:14:47 +00002476 }
Argyrios Kyrtzidis6d00c132010-07-10 11:46:15 +00002477
Chris Lattner4c6f9522009-04-27 05:14:47 +00002478 // We hit a STMT_STOP, so we're done with this expression.
2479 if (Finished)
2480 break;
2481
2482 ++NumStatementsRead;
2483
Argyrios Kyrtzidise6f08682011-10-21 23:02:28 +00002484 if (S && !IsStmtReference) {
Argyrios Kyrtzidis919e6932010-06-28 22:28:35 +00002485 Reader.Visit(S);
Argyrios Kyrtzidise6f08682011-10-21 23:02:28 +00002486 StmtEntries[Cursor.GetCurrentBitNo()] = S;
2487 }
2488
Chris Lattner4c6f9522009-04-27 05:14:47 +00002489
2490 assert(Idx == Record.size() && "Invalid deserialization of statement");
2491 StmtStack.push_back(S);
2492 }
Chris Lattnerb3ce3572013-01-20 02:38:54 +00002493Done:
Argyrios Kyrtzidis919e6932010-06-28 22:28:35 +00002494 assert(StmtStack.size() > PrevNumStmts && "Read too many sub stmts!");
2495 assert(StmtStack.size() == PrevNumStmts + 1 && "Extra expressions on stack!");
Argyrios Kyrtzidis919e6932010-06-28 22:28:35 +00002496 return StmtStack.pop_back_val();
Chris Lattner4c6f9522009-04-27 05:14:47 +00002497}