blob: d8289f227f505b26073e75de7251ccc0b0942938 [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"
Douglas Gregor39da0b82009-09-09 23:08:42 +000016#include "clang/AST/DeclCXX.h"
Douglas Gregorc7793c72011-01-15 01:15:58 +000017#include "clang/AST/DeclTemplate.h"
Chris Lattner4c6f9522009-04-27 05:14:47 +000018#include "clang/AST/StmtVisitor.h"
Benjamin Kramer8fe83e12012-02-04 13:45:25 +000019#include "llvm/ADT/SmallString.h"
Chris Lattner4c6f9522009-04-27 05:14:47 +000020using namespace clang;
Sebastian Redl8538e8d2010-08-18 23:57:32 +000021using namespace clang::serialization;
Chris Lattner4c6f9522009-04-27 05:14:47 +000022
Argyrios Kyrtzidis37bdfe22010-06-30 08:49:18 +000023namespace clang {
Argyrios Kyrtzidis17cfded2010-06-28 09:31:42 +000024
Sebastian Redl60adf4a2010-08-18 23:56:52 +000025 class ASTStmtReader : public StmtVisitor<ASTStmtReader> {
Douglas Gregor409448c2011-07-21 22:35:25 +000026 typedef ASTReader::RecordData RecordData;
27
Sebastian Redlc43b54c2010-08-18 23:56:43 +000028 ASTReader &Reader;
Douglas Gregor1a4761e2011-11-30 23:21:26 +000029 ModuleFile &F;
Sebastian Redl577d4792010-07-22 22:43:28 +000030 llvm::BitstreamCursor &DeclsCursor;
Sebastian Redlc43b54c2010-08-18 23:56:43 +000031 const ASTReader::RecordData &Record;
Chris Lattner4c6f9522009-04-27 05:14:47 +000032 unsigned &Idx;
Chris Lattner4c6f9522009-04-27 05:14:47 +000033
Douglas Gregor409448c2011-07-21 22:35:25 +000034 SourceLocation ReadSourceLocation(const RecordData &R, unsigned &I) {
Sebastian Redlc3632732010-10-05 15:59:54 +000035 return Reader.ReadSourceLocation(F, R, I);
36 }
Douglas Gregor409448c2011-07-21 22:35:25 +000037
38 SourceRange ReadSourceRange(const RecordData &R, unsigned &I) {
Sebastian Redlc3632732010-10-05 15:59:54 +000039 return Reader.ReadSourceRange(F, R, I);
40 }
Douglas Gregor409448c2011-07-21 22:35:25 +000041
42 TypeSourceInfo *GetTypeSourceInfo(const RecordData &R, unsigned &I) {
Sebastian Redlc3632732010-10-05 15:59:54 +000043 return Reader.GetTypeSourceInfo(F, R, I);
44 }
Douglas Gregor409448c2011-07-21 22:35:25 +000045
46 serialization::DeclID ReadDeclID(const RecordData &R, unsigned &I) {
47 return Reader.ReadDeclID(F, R, I);
48 }
49
50 Decl *ReadDecl(const RecordData &R, unsigned &I) {
51 return Reader.ReadDecl(F, R, I);
52 }
53
54 template<typename T>
55 T *ReadDeclAs(const RecordData &R, unsigned &I) {
56 return Reader.ReadDeclAs<T>(F, R, I);
57 }
58
Argyrios Kyrtzidis40451072010-10-15 18:21:24 +000059 void ReadDeclarationNameLoc(DeclarationNameLoc &DNLoc, DeclarationName Name,
60 const ASTReader::RecordData &R, unsigned &I) {
61 Reader.ReadDeclarationNameLoc(F, DNLoc, Name, R, I);
62 }
Douglas Gregor409448c2011-07-21 22:35:25 +000063
Argyrios Kyrtzidis40451072010-10-15 18:21:24 +000064 void ReadDeclarationNameInfo(DeclarationNameInfo &NameInfo,
65 const ASTReader::RecordData &R, unsigned &I) {
66 Reader.ReadDeclarationNameInfo(F, NameInfo, R, I);
67 }
Sebastian Redlc3632732010-10-05 15:59:54 +000068
Chris Lattner4c6f9522009-04-27 05:14:47 +000069 public:
Douglas Gregor1a4761e2011-11-30 23:21:26 +000070 ASTStmtReader(ASTReader &Reader, ModuleFile &F,
Sebastian Redlc3632732010-10-05 15:59:54 +000071 llvm::BitstreamCursor &Cursor,
Sebastian Redlc43b54c2010-08-18 23:56:43 +000072 const ASTReader::RecordData &Record, unsigned &Idx)
Sebastian Redlc3632732010-10-05 15:59:54 +000073 : Reader(Reader), F(F), DeclsCursor(Cursor), Record(Record), Idx(Idx) { }
Chris Lattner4c6f9522009-04-27 05:14:47 +000074
75 /// \brief The number of record fields required for the Stmt class
76 /// itself.
77 static const unsigned NumStmtFields = 0;
78
79 /// \brief The number of record fields required for the Expr class
80 /// itself.
Douglas Gregor561f8122011-07-01 01:22:09 +000081 static const unsigned NumExprFields = NumStmtFields + 7;
Abramo Bagnarae4b92762012-01-27 09:46:47 +000082
83 /// \brief Read and initialize a ExplicitTemplateArgumentList structure.
84 void ReadTemplateKWAndArgsInfo(ASTTemplateKWAndArgsInfo &Args,
85 unsigned NumTemplateArgs);
Argyrios Kyrtzidis36c76f02010-06-28 09:31:48 +000086 /// \brief Read and initialize a ExplicitTemplateArgumentList structure.
Argyrios Kyrtzidisb0c3e092011-09-22 20:07:03 +000087 void ReadExplicitTemplateArgumentList(ASTTemplateArgumentListInfo &ArgList,
Argyrios Kyrtzidis919e6932010-06-28 22:28:35 +000088 unsigned NumTemplateArgs);
Chris Lattner4c6f9522009-04-27 05:14:47 +000089
Argyrios Kyrtzidis919e6932010-06-28 22:28:35 +000090 void VisitStmt(Stmt *S);
John McCall7110fd62011-07-15 07:00:14 +000091#define STMT(Type, Base) \
92 void Visit##Type(Type *);
93#include "clang/AST/StmtNodes.inc"
Chris Lattner4c6f9522009-04-27 05:14:47 +000094 };
95}
96
Sebastian Redl60adf4a2010-08-18 23:56:52 +000097void ASTStmtReader::
Abramo Bagnarae4b92762012-01-27 09:46:47 +000098ReadTemplateKWAndArgsInfo(ASTTemplateKWAndArgsInfo &Args,
99 unsigned NumTemplateArgs) {
100 SourceLocation TemplateKWLoc = ReadSourceLocation(Record, Idx);
Argyrios Kyrtzidis36c76f02010-06-28 09:31:48 +0000101 TemplateArgumentListInfo ArgInfo;
Sebastian Redlc3632732010-10-05 15:59:54 +0000102 ArgInfo.setLAngleLoc(ReadSourceLocation(Record, Idx));
103 ArgInfo.setRAngleLoc(ReadSourceLocation(Record, Idx));
Argyrios Kyrtzidis36c76f02010-06-28 09:31:48 +0000104 for (unsigned i = 0; i != NumTemplateArgs; ++i)
Sebastian Redl577d4792010-07-22 22:43:28 +0000105 ArgInfo.addArgument(
Sebastian Redlc3632732010-10-05 15:59:54 +0000106 Reader.ReadTemplateArgumentLoc(F, Record, Idx));
Abramo Bagnarae4b92762012-01-27 09:46:47 +0000107 Args.initializeFrom(TemplateKWLoc, ArgInfo);
Argyrios Kyrtzidis36c76f02010-06-28 09:31:48 +0000108}
109
Sebastian Redl60adf4a2010-08-18 23:56:52 +0000110void ASTStmtReader::VisitStmt(Stmt *S) {
Chris Lattner4c6f9522009-04-27 05:14:47 +0000111 assert(Idx == NumStmtFields && "Incorrect statement field count");
Chris Lattner4c6f9522009-04-27 05:14:47 +0000112}
113
Sebastian Redl60adf4a2010-08-18 23:56:52 +0000114void ASTStmtReader::VisitNullStmt(NullStmt *S) {
Chris Lattner4c6f9522009-04-27 05:14:47 +0000115 VisitStmt(S);
Sebastian Redlc3632732010-10-05 15:59:54 +0000116 S->setSemiLoc(ReadSourceLocation(Record, Idx));
Argyrios Kyrtzidise2ca8282011-09-01 21:53:45 +0000117 S->HasLeadingEmptyMacro = Record[Idx++];
Chris Lattner4c6f9522009-04-27 05:14:47 +0000118}
119
Sebastian Redl60adf4a2010-08-18 23:56:52 +0000120void ASTStmtReader::VisitCompoundStmt(CompoundStmt *S) {
Chris Lattner4c6f9522009-04-27 05:14:47 +0000121 VisitStmt(S);
Chris Lattner5f9e2722011-07-23 10:55:15 +0000122 SmallVector<Stmt *, 16> Stmts;
Chris Lattner4c6f9522009-04-27 05:14:47 +0000123 unsigned NumStmts = Record[Idx++];
Argyrios Kyrtzidis919e6932010-06-28 22:28:35 +0000124 while (NumStmts--)
Argyrios Kyrtzidisd98a2ab2010-06-29 22:46:25 +0000125 Stmts.push_back(Reader.ReadSubStmt());
Douglas Gregor35942772011-09-09 21:34:22 +0000126 S->setStmts(Reader.getContext(), Stmts.data(), Stmts.size());
Sebastian Redlc3632732010-10-05 15:59:54 +0000127 S->setLBracLoc(ReadSourceLocation(Record, Idx));
128 S->setRBracLoc(ReadSourceLocation(Record, Idx));
Chris Lattner4c6f9522009-04-27 05:14:47 +0000129}
130
Sebastian Redl60adf4a2010-08-18 23:56:52 +0000131void ASTStmtReader::VisitSwitchCase(SwitchCase *S) {
Chris Lattner4c6f9522009-04-27 05:14:47 +0000132 VisitStmt(S);
133 Reader.RecordSwitchCaseID(S, Record[Idx++]);
Chris Lattner4c6f9522009-04-27 05:14:47 +0000134}
135
Sebastian Redl60adf4a2010-08-18 23:56:52 +0000136void ASTStmtReader::VisitCaseStmt(CaseStmt *S) {
Chris Lattner4c6f9522009-04-27 05:14:47 +0000137 VisitSwitchCase(S);
Argyrios Kyrtzidisd98a2ab2010-06-29 22:46:25 +0000138 S->setLHS(Reader.ReadSubExpr());
139 S->setRHS(Reader.ReadSubExpr());
140 S->setSubStmt(Reader.ReadSubStmt());
Sebastian Redlc3632732010-10-05 15:59:54 +0000141 S->setCaseLoc(ReadSourceLocation(Record, Idx));
142 S->setEllipsisLoc(ReadSourceLocation(Record, Idx));
143 S->setColonLoc(ReadSourceLocation(Record, Idx));
Chris Lattner4c6f9522009-04-27 05:14:47 +0000144}
145
Sebastian Redl60adf4a2010-08-18 23:56:52 +0000146void ASTStmtReader::VisitDefaultStmt(DefaultStmt *S) {
Chris Lattner4c6f9522009-04-27 05:14:47 +0000147 VisitSwitchCase(S);
Argyrios Kyrtzidisd98a2ab2010-06-29 22:46:25 +0000148 S->setSubStmt(Reader.ReadSubStmt());
Sebastian Redlc3632732010-10-05 15:59:54 +0000149 S->setDefaultLoc(ReadSourceLocation(Record, Idx));
150 S->setColonLoc(ReadSourceLocation(Record, Idx));
Chris Lattner4c6f9522009-04-27 05:14:47 +0000151}
152
Sebastian Redl60adf4a2010-08-18 23:56:52 +0000153void ASTStmtReader::VisitLabelStmt(LabelStmt *S) {
Chris Lattner4c6f9522009-04-27 05:14:47 +0000154 VisitStmt(S);
Douglas Gregor409448c2011-07-21 22:35:25 +0000155 LabelDecl *LD = ReadDeclAs<LabelDecl>(Record, Idx);
Chris Lattnerad8dcf42011-02-17 07:39:24 +0000156 LD->setStmt(S);
157 S->setDecl(LD);
Argyrios Kyrtzidisd98a2ab2010-06-29 22:46:25 +0000158 S->setSubStmt(Reader.ReadSubStmt());
Sebastian Redlc3632732010-10-05 15:59:54 +0000159 S->setIdentLoc(ReadSourceLocation(Record, Idx));
Chris Lattner4c6f9522009-04-27 05:14:47 +0000160}
161
Sebastian Redl60adf4a2010-08-18 23:56:52 +0000162void ASTStmtReader::VisitIfStmt(IfStmt *S) {
Chris Lattner4c6f9522009-04-27 05:14:47 +0000163 VisitStmt(S);
Douglas Gregor35942772011-09-09 21:34:22 +0000164 S->setConditionVariable(Reader.getContext(),
Douglas Gregor409448c2011-07-21 22:35:25 +0000165 ReadDeclAs<VarDecl>(Record, Idx));
Argyrios Kyrtzidisd98a2ab2010-06-29 22:46:25 +0000166 S->setCond(Reader.ReadSubExpr());
167 S->setThen(Reader.ReadSubStmt());
168 S->setElse(Reader.ReadSubStmt());
Sebastian Redlc3632732010-10-05 15:59:54 +0000169 S->setIfLoc(ReadSourceLocation(Record, Idx));
170 S->setElseLoc(ReadSourceLocation(Record, Idx));
Chris Lattner4c6f9522009-04-27 05:14:47 +0000171}
172
Sebastian Redl60adf4a2010-08-18 23:56:52 +0000173void ASTStmtReader::VisitSwitchStmt(SwitchStmt *S) {
Chris Lattner4c6f9522009-04-27 05:14:47 +0000174 VisitStmt(S);
Douglas Gregor35942772011-09-09 21:34:22 +0000175 S->setConditionVariable(Reader.getContext(),
Douglas Gregor409448c2011-07-21 22:35:25 +0000176 ReadDeclAs<VarDecl>(Record, Idx));
Argyrios Kyrtzidisd98a2ab2010-06-29 22:46:25 +0000177 S->setCond(Reader.ReadSubExpr());
178 S->setBody(Reader.ReadSubStmt());
Sebastian Redlc3632732010-10-05 15:59:54 +0000179 S->setSwitchLoc(ReadSourceLocation(Record, Idx));
Ted Kremenek559fb552010-09-09 00:05:53 +0000180 if (Record[Idx++])
181 S->setAllEnumCasesCovered();
182
Chris Lattner4c6f9522009-04-27 05:14:47 +0000183 SwitchCase *PrevSC = 0;
184 for (unsigned N = Record.size(); Idx != N; ++Idx) {
185 SwitchCase *SC = Reader.getSwitchCaseWithID(Record[Idx]);
186 if (PrevSC)
187 PrevSC->setNextSwitchCase(SC);
188 else
189 S->setSwitchCaseList(SC);
Mike Stump1eb44332009-09-09 15:08:12 +0000190
Chris Lattner4c6f9522009-04-27 05:14:47 +0000191 PrevSC = SC;
192 }
Chris Lattner4c6f9522009-04-27 05:14:47 +0000193}
194
Sebastian Redl60adf4a2010-08-18 23:56:52 +0000195void ASTStmtReader::VisitWhileStmt(WhileStmt *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));
199
Argyrios Kyrtzidisd98a2ab2010-06-29 22:46:25 +0000200 S->setCond(Reader.ReadSubExpr());
201 S->setBody(Reader.ReadSubStmt());
Sebastian Redlc3632732010-10-05 15:59:54 +0000202 S->setWhileLoc(ReadSourceLocation(Record, Idx));
Chris Lattner4c6f9522009-04-27 05:14:47 +0000203}
204
Sebastian Redl60adf4a2010-08-18 23:56:52 +0000205void ASTStmtReader::VisitDoStmt(DoStmt *S) {
Chris Lattner4c6f9522009-04-27 05:14:47 +0000206 VisitStmt(S);
Argyrios Kyrtzidisd98a2ab2010-06-29 22:46:25 +0000207 S->setCond(Reader.ReadSubExpr());
208 S->setBody(Reader.ReadSubStmt());
Sebastian Redlc3632732010-10-05 15:59:54 +0000209 S->setDoLoc(ReadSourceLocation(Record, Idx));
210 S->setWhileLoc(ReadSourceLocation(Record, Idx));
211 S->setRParenLoc(ReadSourceLocation(Record, Idx));
Chris Lattner4c6f9522009-04-27 05:14:47 +0000212}
213
Sebastian Redl60adf4a2010-08-18 23:56:52 +0000214void ASTStmtReader::VisitForStmt(ForStmt *S) {
Chris Lattner4c6f9522009-04-27 05:14:47 +0000215 VisitStmt(S);
Argyrios Kyrtzidisd98a2ab2010-06-29 22:46:25 +0000216 S->setInit(Reader.ReadSubStmt());
217 S->setCond(Reader.ReadSubExpr());
Douglas Gregor35942772011-09-09 21:34:22 +0000218 S->setConditionVariable(Reader.getContext(),
Douglas Gregor409448c2011-07-21 22:35:25 +0000219 ReadDeclAs<VarDecl>(Record, Idx));
Argyrios Kyrtzidisd98a2ab2010-06-29 22:46:25 +0000220 S->setInc(Reader.ReadSubExpr());
221 S->setBody(Reader.ReadSubStmt());
Sebastian Redlc3632732010-10-05 15:59:54 +0000222 S->setForLoc(ReadSourceLocation(Record, Idx));
223 S->setLParenLoc(ReadSourceLocation(Record, Idx));
224 S->setRParenLoc(ReadSourceLocation(Record, Idx));
Chris Lattner4c6f9522009-04-27 05:14:47 +0000225}
226
Sebastian Redl60adf4a2010-08-18 23:56:52 +0000227void ASTStmtReader::VisitGotoStmt(GotoStmt *S) {
Chris Lattner4c6f9522009-04-27 05:14:47 +0000228 VisitStmt(S);
Douglas Gregor409448c2011-07-21 22:35:25 +0000229 S->setLabel(ReadDeclAs<LabelDecl>(Record, Idx));
Sebastian Redlc3632732010-10-05 15:59:54 +0000230 S->setGotoLoc(ReadSourceLocation(Record, Idx));
231 S->setLabelLoc(ReadSourceLocation(Record, Idx));
Chris Lattner4c6f9522009-04-27 05:14:47 +0000232}
233
Sebastian Redl60adf4a2010-08-18 23:56:52 +0000234void ASTStmtReader::VisitIndirectGotoStmt(IndirectGotoStmt *S) {
Chris Lattner4c6f9522009-04-27 05:14:47 +0000235 VisitStmt(S);
Sebastian Redlc3632732010-10-05 15:59:54 +0000236 S->setGotoLoc(ReadSourceLocation(Record, Idx));
237 S->setStarLoc(ReadSourceLocation(Record, Idx));
Argyrios Kyrtzidisd98a2ab2010-06-29 22:46:25 +0000238 S->setTarget(Reader.ReadSubExpr());
Chris Lattner4c6f9522009-04-27 05:14:47 +0000239}
240
Sebastian Redl60adf4a2010-08-18 23:56:52 +0000241void ASTStmtReader::VisitContinueStmt(ContinueStmt *S) {
Chris Lattner4c6f9522009-04-27 05:14:47 +0000242 VisitStmt(S);
Sebastian Redlc3632732010-10-05 15:59:54 +0000243 S->setContinueLoc(ReadSourceLocation(Record, Idx));
Chris Lattner4c6f9522009-04-27 05:14:47 +0000244}
245
Sebastian Redl60adf4a2010-08-18 23:56:52 +0000246void ASTStmtReader::VisitBreakStmt(BreakStmt *S) {
Chris Lattner4c6f9522009-04-27 05:14:47 +0000247 VisitStmt(S);
Sebastian Redlc3632732010-10-05 15:59:54 +0000248 S->setBreakLoc(ReadSourceLocation(Record, Idx));
Chris Lattner4c6f9522009-04-27 05:14:47 +0000249}
250
Sebastian Redl60adf4a2010-08-18 23:56:52 +0000251void ASTStmtReader::VisitReturnStmt(ReturnStmt *S) {
Chris Lattner4c6f9522009-04-27 05:14:47 +0000252 VisitStmt(S);
Argyrios Kyrtzidisd98a2ab2010-06-29 22:46:25 +0000253 S->setRetValue(Reader.ReadSubExpr());
Sebastian Redlc3632732010-10-05 15:59:54 +0000254 S->setReturnLoc(ReadSourceLocation(Record, Idx));
Douglas Gregor409448c2011-07-21 22:35:25 +0000255 S->setNRVOCandidate(ReadDeclAs<VarDecl>(Record, Idx));
Chris Lattner4c6f9522009-04-27 05:14:47 +0000256}
257
Sebastian Redl60adf4a2010-08-18 23:56:52 +0000258void ASTStmtReader::VisitDeclStmt(DeclStmt *S) {
Chris Lattner4c6f9522009-04-27 05:14:47 +0000259 VisitStmt(S);
Sebastian Redlc3632732010-10-05 15:59:54 +0000260 S->setStartLoc(ReadSourceLocation(Record, Idx));
261 S->setEndLoc(ReadSourceLocation(Record, Idx));
Chris Lattner4c6f9522009-04-27 05:14:47 +0000262
263 if (Idx + 1 == Record.size()) {
264 // Single declaration
Douglas Gregor409448c2011-07-21 22:35:25 +0000265 S->setDeclGroup(DeclGroupRef(ReadDecl(Record, Idx)));
Chris Lattner4c6f9522009-04-27 05:14:47 +0000266 } else {
Chris Lattner5f9e2722011-07-23 10:55:15 +0000267 SmallVector<Decl *, 16> Decls;
Douglas Gregor409448c2011-07-21 22:35:25 +0000268 Decls.reserve(Record.size() - Idx);
269 for (unsigned N = Record.size(); Idx != N; )
270 Decls.push_back(ReadDecl(Record, Idx));
Douglas Gregor35942772011-09-09 21:34:22 +0000271 S->setDeclGroup(DeclGroupRef(DeclGroup::Create(Reader.getContext(),
Douglas Gregor75fdb232009-05-22 22:45:36 +0000272 Decls.data(),
273 Decls.size())));
Chris Lattner4c6f9522009-04-27 05:14:47 +0000274 }
Chris Lattner4c6f9522009-04-27 05:14:47 +0000275}
276
Sebastian Redl60adf4a2010-08-18 23:56:52 +0000277void ASTStmtReader::VisitAsmStmt(AsmStmt *S) {
Chris Lattner4c6f9522009-04-27 05:14:47 +0000278 VisitStmt(S);
279 unsigned NumOutputs = Record[Idx++];
280 unsigned NumInputs = Record[Idx++];
281 unsigned NumClobbers = Record[Idx++];
Sebastian Redlc3632732010-10-05 15:59:54 +0000282 S->setAsmLoc(ReadSourceLocation(Record, Idx));
283 S->setRParenLoc(ReadSourceLocation(Record, Idx));
Chris Lattner4c6f9522009-04-27 05:14:47 +0000284 S->setVolatile(Record[Idx++]);
285 S->setSimple(Record[Idx++]);
Mike Stump3b11fd32010-01-04 22:37:17 +0000286 S->setMSAsm(Record[Idx++]);
Mike Stump1eb44332009-09-09 15:08:12 +0000287
Argyrios Kyrtzidisd98a2ab2010-06-29 22:46:25 +0000288 S->setAsmString(cast_or_null<StringLiteral>(Reader.ReadSubStmt()));
Chris Lattner4c6f9522009-04-27 05:14:47 +0000289
290 // Outputs and inputs
Chris Lattner5f9e2722011-07-23 10:55:15 +0000291 SmallVector<IdentifierInfo *, 16> Names;
292 SmallVector<StringLiteral*, 16> Constraints;
293 SmallVector<Stmt*, 16> Exprs;
Chris Lattner4c6f9522009-04-27 05:14:47 +0000294 for (unsigned I = 0, N = NumOutputs + NumInputs; I != N; ++I) {
Douglas Gregor95eab172011-07-28 20:55:49 +0000295 Names.push_back(Reader.GetIdentifierInfo(F, Record, Idx));
Argyrios Kyrtzidisd98a2ab2010-06-29 22:46:25 +0000296 Constraints.push_back(cast_or_null<StringLiteral>(Reader.ReadSubStmt()));
297 Exprs.push_back(Reader.ReadSubStmt());
Chris Lattner4c6f9522009-04-27 05:14:47 +0000298 }
Chris Lattner4c6f9522009-04-27 05:14:47 +0000299
300 // Constraints
Chris Lattner5f9e2722011-07-23 10:55:15 +0000301 SmallVector<StringLiteral*, 16> Clobbers;
Chris Lattner4c6f9522009-04-27 05:14:47 +0000302 for (unsigned I = 0; I != NumClobbers; ++I)
Argyrios Kyrtzidisd98a2ab2010-06-29 22:46:25 +0000303 Clobbers.push_back(cast_or_null<StringLiteral>(Reader.ReadSubStmt()));
Anders Carlssonfdba9c02010-01-30 19:34:25 +0000304
Douglas Gregor35942772011-09-09 21:34:22 +0000305 S->setOutputsAndInputsAndClobbers(Reader.getContext(),
Anders Carlssonacb6bcb2010-01-30 20:38:10 +0000306 Names.data(), Constraints.data(),
Anders Carlssonfdba9c02010-01-30 19:34:25 +0000307 Exprs.data(), NumOutputs, NumInputs,
308 Clobbers.data(), NumClobbers);
Chris Lattner4c6f9522009-04-27 05:14:47 +0000309}
310
Sebastian Redl60adf4a2010-08-18 23:56:52 +0000311void ASTStmtReader::VisitExpr(Expr *E) {
Chris Lattner4c6f9522009-04-27 05:14:47 +0000312 VisitStmt(E);
Douglas Gregor393f2492011-07-22 00:38:23 +0000313 E->setType(Reader.readType(F, Record, Idx));
Chris Lattner4c6f9522009-04-27 05:14:47 +0000314 E->setTypeDependent(Record[Idx++]);
315 E->setValueDependent(Record[Idx++]);
Douglas Gregor561f8122011-07-01 01:22:09 +0000316 E->setInstantiationDependent(Record[Idx++]);
Douglas Gregord0937222010-12-13 22:49:22 +0000317 E->ExprBits.ContainsUnexpandedParameterPack = Record[Idx++];
John McCallf89e55a2010-11-18 06:31:45 +0000318 E->setValueKind(static_cast<ExprValueKind>(Record[Idx++]));
319 E->setObjectKind(static_cast<ExprObjectKind>(Record[Idx++]));
Chris Lattner4c6f9522009-04-27 05:14:47 +0000320 assert(Idx == NumExprFields && "Incorrect expression field count");
Chris Lattner4c6f9522009-04-27 05:14:47 +0000321}
322
Sebastian Redl60adf4a2010-08-18 23:56:52 +0000323void ASTStmtReader::VisitPredefinedExpr(PredefinedExpr *E) {
Chris Lattner4c6f9522009-04-27 05:14:47 +0000324 VisitExpr(E);
Sebastian Redlc3632732010-10-05 15:59:54 +0000325 E->setLocation(ReadSourceLocation(Record, Idx));
Chris Lattner4c6f9522009-04-27 05:14:47 +0000326 E->setIdentType((PredefinedExpr::IdentType)Record[Idx++]);
Chris Lattner4c6f9522009-04-27 05:14:47 +0000327}
328
Sebastian Redl60adf4a2010-08-18 23:56:52 +0000329void ASTStmtReader::VisitDeclRefExpr(DeclRefExpr *E) {
Chris Lattner4c6f9522009-04-27 05:14:47 +0000330 VisitExpr(E);
Argyrios Kyrtzidis663e3802010-07-08 13:09:47 +0000331
Chandler Carruthcb66cff2011-05-01 21:29:53 +0000332 E->DeclRefExprBits.HasQualifier = Record[Idx++];
Chandler Carruth3aa81402011-05-01 23:48:14 +0000333 E->DeclRefExprBits.HasFoundDecl = Record[Idx++];
Abramo Bagnarae4b92762012-01-27 09:46:47 +0000334 E->DeclRefExprBits.HasTemplateKWAndArgsInfo = Record[Idx++];
Abramo Bagnara7cc58b42011-10-05 07:56:41 +0000335 E->DeclRefExprBits.HadMultipleCandidates = Record[Idx++];
John McCallf4b88a42012-03-10 09:33:50 +0000336 E->DeclRefExprBits.RefersToEnclosingLocal = Record[Idx++];
Anders Carlssonb0ca1372011-03-06 18:19:42 +0000337 unsigned NumTemplateArgs = 0;
Abramo Bagnarae4b92762012-01-27 09:46:47 +0000338 if (E->hasTemplateKWAndArgsInfo())
Anders Carlssonb0ca1372011-03-06 18:19:42 +0000339 NumTemplateArgs = Record[Idx++];
340
Chandler Carruthcb66cff2011-05-01 21:29:53 +0000341 if (E->hasQualifier())
Chandler Carruth6857c3e2011-05-01 22:14:37 +0000342 E->getInternalQualifierLoc()
Douglas Gregor40d96a62011-02-28 21:54:11 +0000343 = Reader.ReadNestedNameSpecifierLoc(F, Record, Idx);
Argyrios Kyrtzidis663e3802010-07-08 13:09:47 +0000344
Chandler Carruth3aa81402011-05-01 23:48:14 +0000345 if (E->hasFoundDecl())
Douglas Gregor409448c2011-07-21 22:35:25 +0000346 E->getInternalFoundDecl() = ReadDeclAs<NamedDecl>(Record, Idx);
Chandler Carruth3aa81402011-05-01 23:48:14 +0000347
Abramo Bagnarae4b92762012-01-27 09:46:47 +0000348 if (E->hasTemplateKWAndArgsInfo())
349 ReadTemplateKWAndArgsInfo(*E->getTemplateKWAndArgsInfo(),
350 NumTemplateArgs);
Argyrios Kyrtzidis663e3802010-07-08 13:09:47 +0000351
Douglas Gregor409448c2011-07-21 22:35:25 +0000352 E->setDecl(ReadDeclAs<ValueDecl>(Record, Idx));
Sebastian Redlc3632732010-10-05 15:59:54 +0000353 E->setLocation(ReadSourceLocation(Record, Idx));
Argyrios Kyrtzidis40451072010-10-15 18:21:24 +0000354 ReadDeclarationNameLoc(E->DNLoc, E->getDecl()->getDeclName(), Record, Idx);
Chris Lattner4c6f9522009-04-27 05:14:47 +0000355}
356
Sebastian Redl60adf4a2010-08-18 23:56:52 +0000357void ASTStmtReader::VisitIntegerLiteral(IntegerLiteral *E) {
Chris Lattner4c6f9522009-04-27 05:14:47 +0000358 VisitExpr(E);
Sebastian Redlc3632732010-10-05 15:59:54 +0000359 E->setLocation(ReadSourceLocation(Record, Idx));
Douglas Gregor35942772011-09-09 21:34:22 +0000360 E->setValue(Reader.getContext(), Reader.ReadAPInt(Record, Idx));
Chris Lattner4c6f9522009-04-27 05:14:47 +0000361}
362
Sebastian Redl60adf4a2010-08-18 23:56:52 +0000363void ASTStmtReader::VisitFloatingLiteral(FloatingLiteral *E) {
Chris Lattner4c6f9522009-04-27 05:14:47 +0000364 VisitExpr(E);
Douglas Gregor35942772011-09-09 21:34:22 +0000365 E->setValue(Reader.getContext(), Reader.ReadAPFloat(Record, Idx));
Chris Lattner4c6f9522009-04-27 05:14:47 +0000366 E->setExact(Record[Idx++]);
Sebastian Redlc3632732010-10-05 15:59:54 +0000367 E->setLocation(ReadSourceLocation(Record, Idx));
Chris Lattner4c6f9522009-04-27 05:14:47 +0000368}
369
Sebastian Redl60adf4a2010-08-18 23:56:52 +0000370void ASTStmtReader::VisitImaginaryLiteral(ImaginaryLiteral *E) {
Chris Lattner4c6f9522009-04-27 05:14:47 +0000371 VisitExpr(E);
Argyrios Kyrtzidisd98a2ab2010-06-29 22:46:25 +0000372 E->setSubExpr(Reader.ReadSubExpr());
Chris Lattner4c6f9522009-04-27 05:14:47 +0000373}
374
Sebastian Redl60adf4a2010-08-18 23:56:52 +0000375void ASTStmtReader::VisitStringLiteral(StringLiteral *E) {
Chris Lattner4c6f9522009-04-27 05:14:47 +0000376 VisitExpr(E);
377 unsigned Len = Record[Idx++];
Mike Stump1eb44332009-09-09 15:08:12 +0000378 assert(Record[Idx] == E->getNumConcatenated() &&
Chris Lattner4c6f9522009-04-27 05:14:47 +0000379 "Wrong number of concatenated tokens!");
380 ++Idx;
Eli Friedman64f45a22011-11-01 02:23:42 +0000381 StringLiteral::StringKind kind =
382 static_cast<StringLiteral::StringKind>(Record[Idx++]);
383 bool isPascal = Record[Idx++];
Chris Lattner4c6f9522009-04-27 05:14:47 +0000384
Mike Stump1eb44332009-09-09 15:08:12 +0000385 // Read string data
Dylan Noblesmithf7ccbad2012-02-05 02:13:05 +0000386 SmallString<16> Str(&Record[Idx], &Record[Idx] + Len);
Eli Friedman64f45a22011-11-01 02:23:42 +0000387 E->setString(Reader.getContext(), Str.str(), kind, isPascal);
Chris Lattner4c6f9522009-04-27 05:14:47 +0000388 Idx += Len;
389
390 // Read source locations
391 for (unsigned I = 0, N = E->getNumConcatenated(); I != N; ++I)
Sebastian Redlc3632732010-10-05 15:59:54 +0000392 E->setStrTokenLoc(I, ReadSourceLocation(Record, Idx));
Chris Lattner4c6f9522009-04-27 05:14:47 +0000393}
394
Sebastian Redl60adf4a2010-08-18 23:56:52 +0000395void ASTStmtReader::VisitCharacterLiteral(CharacterLiteral *E) {
Chris Lattner4c6f9522009-04-27 05:14:47 +0000396 VisitExpr(E);
397 E->setValue(Record[Idx++]);
Sebastian Redlc3632732010-10-05 15:59:54 +0000398 E->setLocation(ReadSourceLocation(Record, Idx));
Douglas Gregor5cee1192011-07-27 05:40:30 +0000399 E->setKind(static_cast<CharacterLiteral::CharacterKind>(Record[Idx++]));
Chris Lattner4c6f9522009-04-27 05:14:47 +0000400}
401
Sebastian Redl60adf4a2010-08-18 23:56:52 +0000402void ASTStmtReader::VisitParenExpr(ParenExpr *E) {
Chris Lattner4c6f9522009-04-27 05:14:47 +0000403 VisitExpr(E);
Sebastian Redlc3632732010-10-05 15:59:54 +0000404 E->setLParen(ReadSourceLocation(Record, Idx));
405 E->setRParen(ReadSourceLocation(Record, Idx));
Argyrios Kyrtzidisd98a2ab2010-06-29 22:46:25 +0000406 E->setSubExpr(Reader.ReadSubExpr());
Chris Lattner4c6f9522009-04-27 05:14:47 +0000407}
408
Sebastian Redl60adf4a2010-08-18 23:56:52 +0000409void ASTStmtReader::VisitParenListExpr(ParenListExpr *E) {
Argyrios Kyrtzidis37bdfe22010-06-30 08:49:18 +0000410 VisitExpr(E);
411 unsigned NumExprs = Record[Idx++];
Douglas Gregor35942772011-09-09 21:34:22 +0000412 E->Exprs = new (Reader.getContext()) Stmt*[NumExprs];
Argyrios Kyrtzidis37bdfe22010-06-30 08:49:18 +0000413 for (unsigned i = 0; i != NumExprs; ++i)
414 E->Exprs[i] = Reader.ReadSubStmt();
415 E->NumExprs = NumExprs;
Sebastian Redlc3632732010-10-05 15:59:54 +0000416 E->LParenLoc = ReadSourceLocation(Record, Idx);
417 E->RParenLoc = ReadSourceLocation(Record, Idx);
Argyrios Kyrtzidis37bdfe22010-06-30 08:49:18 +0000418}
419
Sebastian Redl60adf4a2010-08-18 23:56:52 +0000420void ASTStmtReader::VisitUnaryOperator(UnaryOperator *E) {
Chris Lattner4c6f9522009-04-27 05:14:47 +0000421 VisitExpr(E);
Argyrios Kyrtzidisd98a2ab2010-06-29 22:46:25 +0000422 E->setSubExpr(Reader.ReadSubExpr());
Chris Lattner4c6f9522009-04-27 05:14:47 +0000423 E->setOpcode((UnaryOperator::Opcode)Record[Idx++]);
Sebastian Redlc3632732010-10-05 15:59:54 +0000424 E->setOperatorLoc(ReadSourceLocation(Record, Idx));
Chris Lattner4c6f9522009-04-27 05:14:47 +0000425}
426
Sebastian Redl60adf4a2010-08-18 23:56:52 +0000427void ASTStmtReader::VisitOffsetOfExpr(OffsetOfExpr *E) {
Douglas Gregor8ecdb652010-04-28 22:16:22 +0000428 typedef OffsetOfExpr::OffsetOfNode Node;
429 VisitExpr(E);
430 assert(E->getNumComponents() == Record[Idx]);
431 ++Idx;
432 assert(E->getNumExpressions() == Record[Idx]);
433 ++Idx;
Sebastian Redlc3632732010-10-05 15:59:54 +0000434 E->setOperatorLoc(ReadSourceLocation(Record, Idx));
435 E->setRParenLoc(ReadSourceLocation(Record, Idx));
436 E->setTypeSourceInfo(GetTypeSourceInfo(Record, Idx));
Douglas Gregor8ecdb652010-04-28 22:16:22 +0000437 for (unsigned I = 0, N = E->getNumComponents(); I != N; ++I) {
438 Node::Kind Kind = static_cast<Node::Kind>(Record[Idx++]);
Sebastian Redlc3632732010-10-05 15:59:54 +0000439 SourceLocation Start = ReadSourceLocation(Record, Idx);
440 SourceLocation End = ReadSourceLocation(Record, Idx);
Douglas Gregor8ecdb652010-04-28 22:16:22 +0000441 switch (Kind) {
442 case Node::Array:
443 E->setComponent(I, Node(Start, Record[Idx++], End));
444 break;
445
446 case Node::Field:
Douglas Gregor409448c2011-07-21 22:35:25 +0000447 E->setComponent(I, Node(Start, ReadDeclAs<FieldDecl>(Record, Idx), End));
Douglas Gregor8ecdb652010-04-28 22:16:22 +0000448 break;
449
450 case Node::Identifier:
Douglas Gregor95eab172011-07-28 20:55:49 +0000451 E->setComponent(I,
452 Node(Start,
453 Reader.GetIdentifierInfo(F, Record, Idx),
454 End));
Douglas Gregor8ecdb652010-04-28 22:16:22 +0000455 break;
Douglas Gregorcc8a5d52010-04-29 00:18:15 +0000456
Argyrios Kyrtzidisafbf3122010-07-29 18:16:10 +0000457 case Node::Base: {
Douglas Gregor35942772011-09-09 21:34:22 +0000458 CXXBaseSpecifier *Base = new (Reader.getContext()) CXXBaseSpecifier();
Sebastian Redlc3632732010-10-05 15:59:54 +0000459 *Base = Reader.ReadCXXBaseSpecifier(F, Record, Idx);
Argyrios Kyrtzidisafbf3122010-07-29 18:16:10 +0000460 E->setComponent(I, Node(Base));
Douglas Gregorcc8a5d52010-04-29 00:18:15 +0000461 break;
Douglas Gregor8ecdb652010-04-28 22:16:22 +0000462 }
Argyrios Kyrtzidisafbf3122010-07-29 18:16:10 +0000463 }
Douglas Gregor8ecdb652010-04-28 22:16:22 +0000464 }
465
466 for (unsigned I = 0, N = E->getNumExpressions(); I != N; ++I)
Argyrios Kyrtzidisd98a2ab2010-06-29 22:46:25 +0000467 E->setIndexExpr(I, Reader.ReadSubExpr());
Douglas Gregor8ecdb652010-04-28 22:16:22 +0000468}
469
Peter Collingbournef4e3cfb2011-03-11 19:24:49 +0000470void ASTStmtReader::VisitUnaryExprOrTypeTraitExpr(UnaryExprOrTypeTraitExpr *E) {
Chris Lattner4c6f9522009-04-27 05:14:47 +0000471 VisitExpr(E);
Peter Collingbournef4e3cfb2011-03-11 19:24:49 +0000472 E->setKind(static_cast<UnaryExprOrTypeTrait>(Record[Idx++]));
Chris Lattner4c6f9522009-04-27 05:14:47 +0000473 if (Record[Idx] == 0) {
Argyrios Kyrtzidisd98a2ab2010-06-29 22:46:25 +0000474 E->setArgument(Reader.ReadSubExpr());
Chris Lattner4c6f9522009-04-27 05:14:47 +0000475 ++Idx;
476 } else {
Sebastian Redlc3632732010-10-05 15:59:54 +0000477 E->setArgument(GetTypeSourceInfo(Record, Idx));
Chris Lattner4c6f9522009-04-27 05:14:47 +0000478 }
Sebastian Redlc3632732010-10-05 15:59:54 +0000479 E->setOperatorLoc(ReadSourceLocation(Record, Idx));
480 E->setRParenLoc(ReadSourceLocation(Record, Idx));
Chris Lattner4c6f9522009-04-27 05:14:47 +0000481}
482
Sebastian Redl60adf4a2010-08-18 23:56:52 +0000483void ASTStmtReader::VisitArraySubscriptExpr(ArraySubscriptExpr *E) {
Chris Lattner4c6f9522009-04-27 05:14:47 +0000484 VisitExpr(E);
Argyrios Kyrtzidisd98a2ab2010-06-29 22:46:25 +0000485 E->setLHS(Reader.ReadSubExpr());
486 E->setRHS(Reader.ReadSubExpr());
Sebastian Redlc3632732010-10-05 15:59:54 +0000487 E->setRBracketLoc(ReadSourceLocation(Record, Idx));
Chris Lattner4c6f9522009-04-27 05:14:47 +0000488}
489
Sebastian Redl60adf4a2010-08-18 23:56:52 +0000490void ASTStmtReader::VisitCallExpr(CallExpr *E) {
Chris Lattner4c6f9522009-04-27 05:14:47 +0000491 VisitExpr(E);
Douglas Gregor35942772011-09-09 21:34:22 +0000492 E->setNumArgs(Reader.getContext(), Record[Idx++]);
Sebastian Redlc3632732010-10-05 15:59:54 +0000493 E->setRParenLoc(ReadSourceLocation(Record, Idx));
Argyrios Kyrtzidisd98a2ab2010-06-29 22:46:25 +0000494 E->setCallee(Reader.ReadSubExpr());
Chris Lattner4c6f9522009-04-27 05:14:47 +0000495 for (unsigned I = 0, N = E->getNumArgs(); I != N; ++I)
Argyrios Kyrtzidisd98a2ab2010-06-29 22:46:25 +0000496 E->setArg(I, Reader.ReadSubExpr());
Chris Lattner4c6f9522009-04-27 05:14:47 +0000497}
498
John McCall7110fd62011-07-15 07:00:14 +0000499void ASTStmtReader::VisitCXXMemberCallExpr(CXXMemberCallExpr *E) {
500 VisitCallExpr(E);
501}
502
Sebastian Redl60adf4a2010-08-18 23:56:52 +0000503void ASTStmtReader::VisitMemberExpr(MemberExpr *E) {
Argyrios Kyrtzidis663e3802010-07-08 13:09:47 +0000504 // Don't call VisitExpr, this is fully initialized at creation.
505 assert(E->getStmtClass() == Stmt::MemberExprClass &&
506 "It's a subclass, we must advance Idx!");
Chris Lattner4c6f9522009-04-27 05:14:47 +0000507}
508
Sebastian Redl60adf4a2010-08-18 23:56:52 +0000509void ASTStmtReader::VisitObjCIsaExpr(ObjCIsaExpr *E) {
Steve Narofff242b1b2009-07-24 17:54:45 +0000510 VisitExpr(E);
Argyrios Kyrtzidisd98a2ab2010-06-29 22:46:25 +0000511 E->setBase(Reader.ReadSubExpr());
Sebastian Redlc3632732010-10-05 15:59:54 +0000512 E->setIsaMemberLoc(ReadSourceLocation(Record, Idx));
Steve Narofff242b1b2009-07-24 17:54:45 +0000513 E->setArrow(Record[Idx++]);
Steve Narofff242b1b2009-07-24 17:54:45 +0000514}
515
John McCallf85e1932011-06-15 23:02:42 +0000516void ASTStmtReader::
517VisitObjCIndirectCopyRestoreExpr(ObjCIndirectCopyRestoreExpr *E) {
518 VisitExpr(E);
519 E->Operand = Reader.ReadSubExpr();
520 E->setShouldCopy(Record[Idx++]);
521}
522
523void ASTStmtReader::VisitObjCBridgedCastExpr(ObjCBridgedCastExpr *E) {
524 VisitExplicitCastExpr(E);
525 E->LParenLoc = ReadSourceLocation(Record, Idx);
526 E->BridgeKeywordLoc = ReadSourceLocation(Record, Idx);
527 E->Kind = Record[Idx++];
528}
529
Sebastian Redl60adf4a2010-08-18 23:56:52 +0000530void ASTStmtReader::VisitCastExpr(CastExpr *E) {
Chris Lattner4c6f9522009-04-27 05:14:47 +0000531 VisitExpr(E);
John McCallf871d0c2010-08-07 06:22:56 +0000532 unsigned NumBaseSpecs = Record[Idx++];
533 assert(NumBaseSpecs == E->path_size());
Argyrios Kyrtzidisd98a2ab2010-06-29 22:46:25 +0000534 E->setSubExpr(Reader.ReadSubExpr());
Anders Carlssoncdef2b72009-07-31 00:48:10 +0000535 E->setCastKind((CastExpr::CastKind)Record[Idx++]);
John McCallf871d0c2010-08-07 06:22:56 +0000536 CastExpr::path_iterator BaseI = E->path_begin();
Argyrios Kyrtzidis0745d0a2010-07-02 23:30:27 +0000537 while (NumBaseSpecs--) {
Douglas Gregor35942772011-09-09 21:34:22 +0000538 CXXBaseSpecifier *BaseSpec = new (Reader.getContext()) CXXBaseSpecifier;
Sebastian Redlc3632732010-10-05 15:59:54 +0000539 *BaseSpec = Reader.ReadCXXBaseSpecifier(F, Record, Idx);
John McCallf871d0c2010-08-07 06:22:56 +0000540 *BaseI++ = BaseSpec;
Argyrios Kyrtzidis0745d0a2010-07-02 23:30:27 +0000541 }
Chris Lattner4c6f9522009-04-27 05:14:47 +0000542}
543
Sebastian Redl60adf4a2010-08-18 23:56:52 +0000544void ASTStmtReader::VisitBinaryOperator(BinaryOperator *E) {
Chris Lattner4c6f9522009-04-27 05:14:47 +0000545 VisitExpr(E);
Argyrios Kyrtzidisd98a2ab2010-06-29 22:46:25 +0000546 E->setLHS(Reader.ReadSubExpr());
547 E->setRHS(Reader.ReadSubExpr());
Chris Lattner4c6f9522009-04-27 05:14:47 +0000548 E->setOpcode((BinaryOperator::Opcode)Record[Idx++]);
Sebastian Redlc3632732010-10-05 15:59:54 +0000549 E->setOperatorLoc(ReadSourceLocation(Record, Idx));
Chris Lattner4c6f9522009-04-27 05:14:47 +0000550}
551
Sebastian Redl60adf4a2010-08-18 23:56:52 +0000552void ASTStmtReader::VisitCompoundAssignOperator(CompoundAssignOperator *E) {
Chris Lattner4c6f9522009-04-27 05:14:47 +0000553 VisitBinaryOperator(E);
Douglas Gregor393f2492011-07-22 00:38:23 +0000554 E->setComputationLHSType(Reader.readType(F, Record, Idx));
555 E->setComputationResultType(Reader.readType(F, Record, Idx));
Chris Lattner4c6f9522009-04-27 05:14:47 +0000556}
557
Sebastian Redl60adf4a2010-08-18 23:56:52 +0000558void ASTStmtReader::VisitConditionalOperator(ConditionalOperator *E) {
Chris Lattner4c6f9522009-04-27 05:14:47 +0000559 VisitExpr(E);
John McCall56ca35d2011-02-17 10:25:35 +0000560 E->SubExprs[ConditionalOperator::COND] = Reader.ReadSubExpr();
561 E->SubExprs[ConditionalOperator::LHS] = Reader.ReadSubExpr();
562 E->SubExprs[ConditionalOperator::RHS] = Reader.ReadSubExpr();
563 E->QuestionLoc = ReadSourceLocation(Record, Idx);
564 E->ColonLoc = ReadSourceLocation(Record, Idx);
565}
566
567void
568ASTStmtReader::VisitBinaryConditionalOperator(BinaryConditionalOperator *E) {
569 VisitExpr(E);
570 E->OpaqueValue = cast<OpaqueValueExpr>(Reader.ReadSubExpr());
571 E->SubExprs[BinaryConditionalOperator::COMMON] = Reader.ReadSubExpr();
572 E->SubExprs[BinaryConditionalOperator::COND] = Reader.ReadSubExpr();
573 E->SubExprs[BinaryConditionalOperator::LHS] = Reader.ReadSubExpr();
574 E->SubExprs[BinaryConditionalOperator::RHS] = Reader.ReadSubExpr();
575 E->QuestionLoc = ReadSourceLocation(Record, Idx);
576 E->ColonLoc = ReadSourceLocation(Record, Idx);
Chris Lattner4c6f9522009-04-27 05:14:47 +0000577}
578
Sebastian Redl60adf4a2010-08-18 23:56:52 +0000579void ASTStmtReader::VisitImplicitCastExpr(ImplicitCastExpr *E) {
Chris Lattner4c6f9522009-04-27 05:14:47 +0000580 VisitCastExpr(E);
Chris Lattner4c6f9522009-04-27 05:14:47 +0000581}
582
Sebastian Redl60adf4a2010-08-18 23:56:52 +0000583void ASTStmtReader::VisitExplicitCastExpr(ExplicitCastExpr *E) {
Chris Lattner4c6f9522009-04-27 05:14:47 +0000584 VisitCastExpr(E);
Sebastian Redlc3632732010-10-05 15:59:54 +0000585 E->setTypeInfoAsWritten(GetTypeSourceInfo(Record, Idx));
Chris Lattner4c6f9522009-04-27 05:14:47 +0000586}
587
Sebastian Redl60adf4a2010-08-18 23:56:52 +0000588void ASTStmtReader::VisitCStyleCastExpr(CStyleCastExpr *E) {
Chris Lattner4c6f9522009-04-27 05:14:47 +0000589 VisitExplicitCastExpr(E);
Sebastian Redlc3632732010-10-05 15:59:54 +0000590 E->setLParenLoc(ReadSourceLocation(Record, Idx));
591 E->setRParenLoc(ReadSourceLocation(Record, Idx));
Chris Lattner4c6f9522009-04-27 05:14:47 +0000592}
593
Sebastian Redl60adf4a2010-08-18 23:56:52 +0000594void ASTStmtReader::VisitCompoundLiteralExpr(CompoundLiteralExpr *E) {
Chris Lattner4c6f9522009-04-27 05:14:47 +0000595 VisitExpr(E);
Sebastian Redlc3632732010-10-05 15:59:54 +0000596 E->setLParenLoc(ReadSourceLocation(Record, Idx));
597 E->setTypeSourceInfo(GetTypeSourceInfo(Record, Idx));
Argyrios Kyrtzidisd98a2ab2010-06-29 22:46:25 +0000598 E->setInitializer(Reader.ReadSubExpr());
Chris Lattner4c6f9522009-04-27 05:14:47 +0000599 E->setFileScope(Record[Idx++]);
Chris Lattner4c6f9522009-04-27 05:14:47 +0000600}
601
Sebastian Redl60adf4a2010-08-18 23:56:52 +0000602void ASTStmtReader::VisitExtVectorElementExpr(ExtVectorElementExpr *E) {
Chris Lattner4c6f9522009-04-27 05:14:47 +0000603 VisitExpr(E);
Argyrios Kyrtzidisd98a2ab2010-06-29 22:46:25 +0000604 E->setBase(Reader.ReadSubExpr());
Douglas Gregor95eab172011-07-28 20:55:49 +0000605 E->setAccessor(Reader.GetIdentifierInfo(F, Record, Idx));
Sebastian Redlc3632732010-10-05 15:59:54 +0000606 E->setAccessorLoc(ReadSourceLocation(Record, Idx));
Chris Lattner4c6f9522009-04-27 05:14:47 +0000607}
608
Sebastian Redl60adf4a2010-08-18 23:56:52 +0000609void ASTStmtReader::VisitInitListExpr(InitListExpr *E) {
Chris Lattner4c6f9522009-04-27 05:14:47 +0000610 VisitExpr(E);
Argyrios Kyrtzidisd98a2ab2010-06-29 22:46:25 +0000611 E->setSyntacticForm(cast_or_null<InitListExpr>(Reader.ReadSubStmt()));
Sebastian Redlc3632732010-10-05 15:59:54 +0000612 E->setLBraceLoc(ReadSourceLocation(Record, Idx));
613 E->setRBraceLoc(ReadSourceLocation(Record, Idx));
Argyrios Kyrtzidis2ac0b7a2011-04-22 05:29:30 +0000614 bool isArrayFiller = Record[Idx++];
615 Expr *filler = 0;
616 if (isArrayFiller) {
617 filler = Reader.ReadSubExpr();
618 E->ArrayFillerOrUnionFieldInit = filler;
619 } else
Douglas Gregor409448c2011-07-21 22:35:25 +0000620 E->ArrayFillerOrUnionFieldInit = ReadDeclAs<FieldDecl>(Record, Idx);
Chris Lattner4c6f9522009-04-27 05:14:47 +0000621 E->sawArrayRangeDesignator(Record[Idx++]);
Benjamin Kramer1b1a5072012-02-27 13:20:39 +0000622 E->setInitializesStdInitializerList(Record[Idx++]);
Argyrios Kyrtzidis2ac0b7a2011-04-22 05:29:30 +0000623 unsigned NumInits = Record[Idx++];
Douglas Gregor35942772011-09-09 21:34:22 +0000624 E->reserveInits(Reader.getContext(), NumInits);
Argyrios Kyrtzidis2ac0b7a2011-04-22 05:29:30 +0000625 if (isArrayFiller) {
626 for (unsigned I = 0; I != NumInits; ++I) {
627 Expr *init = Reader.ReadSubExpr();
Douglas Gregor35942772011-09-09 21:34:22 +0000628 E->updateInit(Reader.getContext(), I, init ? init : filler);
Argyrios Kyrtzidis2ac0b7a2011-04-22 05:29:30 +0000629 }
630 } else {
631 for (unsigned I = 0; I != NumInits; ++I)
Douglas Gregor35942772011-09-09 21:34:22 +0000632 E->updateInit(Reader.getContext(), I, Reader.ReadSubExpr());
Argyrios Kyrtzidis2ac0b7a2011-04-22 05:29:30 +0000633 }
Chris Lattner4c6f9522009-04-27 05:14:47 +0000634}
635
Sebastian Redl60adf4a2010-08-18 23:56:52 +0000636void ASTStmtReader::VisitDesignatedInitExpr(DesignatedInitExpr *E) {
Chris Lattner4c6f9522009-04-27 05:14:47 +0000637 typedef DesignatedInitExpr::Designator Designator;
638
639 VisitExpr(E);
640 unsigned NumSubExprs = Record[Idx++];
641 assert(NumSubExprs == E->getNumSubExprs() && "Wrong number of subexprs");
642 for (unsigned I = 0; I != NumSubExprs; ++I)
Argyrios Kyrtzidisd98a2ab2010-06-29 22:46:25 +0000643 E->setSubExpr(I, Reader.ReadSubExpr());
Sebastian Redlc3632732010-10-05 15:59:54 +0000644 E->setEqualOrColonLoc(ReadSourceLocation(Record, Idx));
Chris Lattner4c6f9522009-04-27 05:14:47 +0000645 E->setGNUSyntax(Record[Idx++]);
646
Chris Lattner5f9e2722011-07-23 10:55:15 +0000647 SmallVector<Designator, 4> Designators;
Chris Lattner4c6f9522009-04-27 05:14:47 +0000648 while (Idx < Record.size()) {
Sebastian Redl8538e8d2010-08-18 23:57:32 +0000649 switch ((DesignatorTypes)Record[Idx++]) {
650 case DESIG_FIELD_DECL: {
Douglas Gregor409448c2011-07-21 22:35:25 +0000651 FieldDecl *Field = ReadDeclAs<FieldDecl>(Record, Idx);
Mike Stump1eb44332009-09-09 15:08:12 +0000652 SourceLocation DotLoc
Sebastian Redlc3632732010-10-05 15:59:54 +0000653 = ReadSourceLocation(Record, Idx);
Mike Stump1eb44332009-09-09 15:08:12 +0000654 SourceLocation FieldLoc
Sebastian Redlc3632732010-10-05 15:59:54 +0000655 = ReadSourceLocation(Record, Idx);
Mike Stump1eb44332009-09-09 15:08:12 +0000656 Designators.push_back(Designator(Field->getIdentifier(), DotLoc,
Chris Lattner4c6f9522009-04-27 05:14:47 +0000657 FieldLoc));
658 Designators.back().setField(Field);
659 break;
660 }
661
Sebastian Redl8538e8d2010-08-18 23:57:32 +0000662 case DESIG_FIELD_NAME: {
Douglas Gregor95eab172011-07-28 20:55:49 +0000663 const IdentifierInfo *Name = Reader.GetIdentifierInfo(F, Record, Idx);
Mike Stump1eb44332009-09-09 15:08:12 +0000664 SourceLocation DotLoc
Sebastian Redlc3632732010-10-05 15:59:54 +0000665 = ReadSourceLocation(Record, Idx);
Mike Stump1eb44332009-09-09 15:08:12 +0000666 SourceLocation FieldLoc
Sebastian Redlc3632732010-10-05 15:59:54 +0000667 = ReadSourceLocation(Record, Idx);
Chris Lattner4c6f9522009-04-27 05:14:47 +0000668 Designators.push_back(Designator(Name, DotLoc, FieldLoc));
669 break;
670 }
Mike Stump1eb44332009-09-09 15:08:12 +0000671
Sebastian Redl8538e8d2010-08-18 23:57:32 +0000672 case DESIG_ARRAY: {
Chris Lattner4c6f9522009-04-27 05:14:47 +0000673 unsigned Index = Record[Idx++];
674 SourceLocation LBracketLoc
Sebastian Redlc3632732010-10-05 15:59:54 +0000675 = ReadSourceLocation(Record, Idx);
Chris Lattner4c6f9522009-04-27 05:14:47 +0000676 SourceLocation RBracketLoc
Sebastian Redlc3632732010-10-05 15:59:54 +0000677 = ReadSourceLocation(Record, Idx);
Chris Lattner4c6f9522009-04-27 05:14:47 +0000678 Designators.push_back(Designator(Index, LBracketLoc, RBracketLoc));
679 break;
680 }
681
Sebastian Redl8538e8d2010-08-18 23:57:32 +0000682 case DESIG_ARRAY_RANGE: {
Chris Lattner4c6f9522009-04-27 05:14:47 +0000683 unsigned Index = Record[Idx++];
684 SourceLocation LBracketLoc
Sebastian Redlc3632732010-10-05 15:59:54 +0000685 = ReadSourceLocation(Record, Idx);
Chris Lattner4c6f9522009-04-27 05:14:47 +0000686 SourceLocation EllipsisLoc
Sebastian Redlc3632732010-10-05 15:59:54 +0000687 = ReadSourceLocation(Record, Idx);
Chris Lattner4c6f9522009-04-27 05:14:47 +0000688 SourceLocation RBracketLoc
Sebastian Redlc3632732010-10-05 15:59:54 +0000689 = ReadSourceLocation(Record, Idx);
Chris Lattner4c6f9522009-04-27 05:14:47 +0000690 Designators.push_back(Designator(Index, LBracketLoc, EllipsisLoc,
691 RBracketLoc));
692 break;
693 }
694 }
695 }
Douglas Gregor35942772011-09-09 21:34:22 +0000696 E->setDesignators(Reader.getContext(),
Douglas Gregor319d57f2010-01-06 23:17:19 +0000697 Designators.data(), Designators.size());
Chris Lattner4c6f9522009-04-27 05:14:47 +0000698}
699
Sebastian Redl60adf4a2010-08-18 23:56:52 +0000700void ASTStmtReader::VisitImplicitValueInitExpr(ImplicitValueInitExpr *E) {
Chris Lattner4c6f9522009-04-27 05:14:47 +0000701 VisitExpr(E);
Chris Lattner4c6f9522009-04-27 05:14:47 +0000702}
703
Sebastian Redl60adf4a2010-08-18 23:56:52 +0000704void ASTStmtReader::VisitVAArgExpr(VAArgExpr *E) {
Chris Lattner4c6f9522009-04-27 05:14:47 +0000705 VisitExpr(E);
Argyrios Kyrtzidisd98a2ab2010-06-29 22:46:25 +0000706 E->setSubExpr(Reader.ReadSubExpr());
Sebastian Redlc3632732010-10-05 15:59:54 +0000707 E->setWrittenTypeInfo(GetTypeSourceInfo(Record, Idx));
708 E->setBuiltinLoc(ReadSourceLocation(Record, Idx));
709 E->setRParenLoc(ReadSourceLocation(Record, Idx));
Chris Lattner4c6f9522009-04-27 05:14:47 +0000710}
711
Sebastian Redl60adf4a2010-08-18 23:56:52 +0000712void ASTStmtReader::VisitAddrLabelExpr(AddrLabelExpr *E) {
Chris Lattner4c6f9522009-04-27 05:14:47 +0000713 VisitExpr(E);
Sebastian Redlc3632732010-10-05 15:59:54 +0000714 E->setAmpAmpLoc(ReadSourceLocation(Record, Idx));
715 E->setLabelLoc(ReadSourceLocation(Record, Idx));
Douglas Gregor409448c2011-07-21 22:35:25 +0000716 E->setLabel(ReadDeclAs<LabelDecl>(Record, Idx));
Chris Lattner4c6f9522009-04-27 05:14:47 +0000717}
718
Sebastian Redl60adf4a2010-08-18 23:56:52 +0000719void ASTStmtReader::VisitStmtExpr(StmtExpr *E) {
Chris Lattner4c6f9522009-04-27 05:14:47 +0000720 VisitExpr(E);
Sebastian Redlc3632732010-10-05 15:59:54 +0000721 E->setLParenLoc(ReadSourceLocation(Record, Idx));
722 E->setRParenLoc(ReadSourceLocation(Record, Idx));
Argyrios Kyrtzidisd98a2ab2010-06-29 22:46:25 +0000723 E->setSubStmt(cast_or_null<CompoundStmt>(Reader.ReadSubStmt()));
Chris Lattner4c6f9522009-04-27 05:14:47 +0000724}
725
Sebastian Redl60adf4a2010-08-18 23:56:52 +0000726void ASTStmtReader::VisitChooseExpr(ChooseExpr *E) {
Chris Lattner4c6f9522009-04-27 05:14:47 +0000727 VisitExpr(E);
Argyrios Kyrtzidisd98a2ab2010-06-29 22:46:25 +0000728 E->setCond(Reader.ReadSubExpr());
729 E->setLHS(Reader.ReadSubExpr());
730 E->setRHS(Reader.ReadSubExpr());
Sebastian Redlc3632732010-10-05 15:59:54 +0000731 E->setBuiltinLoc(ReadSourceLocation(Record, Idx));
732 E->setRParenLoc(ReadSourceLocation(Record, Idx));
Chris Lattner4c6f9522009-04-27 05:14:47 +0000733}
734
Sebastian Redl60adf4a2010-08-18 23:56:52 +0000735void ASTStmtReader::VisitGNUNullExpr(GNUNullExpr *E) {
Chris Lattner4c6f9522009-04-27 05:14:47 +0000736 VisitExpr(E);
Sebastian Redlc3632732010-10-05 15:59:54 +0000737 E->setTokenLocation(ReadSourceLocation(Record, Idx));
Chris Lattner4c6f9522009-04-27 05:14:47 +0000738}
739
Sebastian Redl60adf4a2010-08-18 23:56:52 +0000740void ASTStmtReader::VisitShuffleVectorExpr(ShuffleVectorExpr *E) {
Chris Lattner4c6f9522009-04-27 05:14:47 +0000741 VisitExpr(E);
Chris Lattner5f9e2722011-07-23 10:55:15 +0000742 SmallVector<Expr *, 16> Exprs;
Chris Lattner4c6f9522009-04-27 05:14:47 +0000743 unsigned NumExprs = Record[Idx++];
Argyrios Kyrtzidis919e6932010-06-28 22:28:35 +0000744 while (NumExprs--)
Argyrios Kyrtzidisd98a2ab2010-06-29 22:46:25 +0000745 Exprs.push_back(Reader.ReadSubExpr());
Douglas Gregor35942772011-09-09 21:34:22 +0000746 E->setExprs(Reader.getContext(), Exprs.data(), Exprs.size());
Sebastian Redlc3632732010-10-05 15:59:54 +0000747 E->setBuiltinLoc(ReadSourceLocation(Record, Idx));
748 E->setRParenLoc(ReadSourceLocation(Record, Idx));
Chris Lattner4c6f9522009-04-27 05:14:47 +0000749}
750
Sebastian Redl60adf4a2010-08-18 23:56:52 +0000751void ASTStmtReader::VisitBlockExpr(BlockExpr *E) {
Chris Lattner4c6f9522009-04-27 05:14:47 +0000752 VisitExpr(E);
Douglas Gregor409448c2011-07-21 22:35:25 +0000753 E->setBlockDecl(ReadDeclAs<BlockDecl>(Record, Idx));
Chris Lattner4c6f9522009-04-27 05:14:47 +0000754}
755
Peter Collingbournef111d932011-04-15 00:35:48 +0000756void ASTStmtReader::VisitGenericSelectionExpr(GenericSelectionExpr *E) {
757 VisitExpr(E);
758 E->NumAssocs = Record[Idx++];
Douglas Gregor35942772011-09-09 21:34:22 +0000759 E->AssocTypes = new (Reader.getContext()) TypeSourceInfo*[E->NumAssocs];
Peter Collingbournef111d932011-04-15 00:35:48 +0000760 E->SubExprs =
Douglas Gregor35942772011-09-09 21:34:22 +0000761 new(Reader.getContext()) Stmt*[GenericSelectionExpr::END_EXPR+E->NumAssocs];
Peter Collingbournef111d932011-04-15 00:35:48 +0000762
763 E->SubExprs[GenericSelectionExpr::CONTROLLING] = Reader.ReadSubExpr();
764 for (unsigned I = 0, N = E->getNumAssocs(); I != N; ++I) {
765 E->AssocTypes[I] = GetTypeSourceInfo(Record, Idx);
766 E->SubExprs[GenericSelectionExpr::END_EXPR+I] = Reader.ReadSubExpr();
767 }
768 E->ResultIndex = Record[Idx++];
769
770 E->GenericLoc = ReadSourceLocation(Record, Idx);
771 E->DefaultLoc = ReadSourceLocation(Record, Idx);
772 E->RParenLoc = ReadSourceLocation(Record, Idx);
773}
774
John McCall4b9c2d22011-11-06 09:01:30 +0000775void ASTStmtReader::VisitPseudoObjectExpr(PseudoObjectExpr *E) {
776 VisitExpr(E);
777 unsigned numSemanticExprs = Record[Idx++];
778 assert(numSemanticExprs + 1 == E->PseudoObjectExprBits.NumSubExprs);
779 E->PseudoObjectExprBits.ResultIndex = Record[Idx++];
780
781 // Read the syntactic expression.
782 E->getSubExprsBuffer()[0] = Reader.ReadSubExpr();
783
784 // Read all the semantic expressions.
785 for (unsigned i = 0; i != numSemanticExprs; ++i) {
786 Expr *subExpr = Reader.ReadSubExpr();
John McCall4b9c2d22011-11-06 09:01:30 +0000787 E->getSubExprsBuffer()[i+1] = subExpr;
788 }
789}
790
Eli Friedman276b0612011-10-11 02:20:01 +0000791void ASTStmtReader::VisitAtomicExpr(AtomicExpr *E) {
792 VisitExpr(E);
793 E->setOp(AtomicExpr::AtomicOp(Record[Idx++]));
794 E->setPtr(Reader.ReadSubExpr());
795 E->setOrder(Reader.ReadSubExpr());
796 E->setNumSubExprs(2);
797 if (E->getOp() != AtomicExpr::Load) {
798 E->setVal1(Reader.ReadSubExpr());
799 E->setNumSubExprs(3);
800 }
801 if (E->isCmpXChg()) {
802 E->setOrderFail(Reader.ReadSubExpr());
803 E->setVal2(Reader.ReadSubExpr());
804 E->setNumSubExprs(5);
805 }
806 E->setBuiltinLoc(ReadSourceLocation(Record, Idx));
807 E->setRParenLoc(ReadSourceLocation(Record, Idx));
808}
809
Chris Lattner4c6f9522009-04-27 05:14:47 +0000810//===----------------------------------------------------------------------===//
811// Objective-C Expressions and Statements
812
Sebastian Redl60adf4a2010-08-18 23:56:52 +0000813void ASTStmtReader::VisitObjCStringLiteral(ObjCStringLiteral *E) {
Chris Lattner4c6f9522009-04-27 05:14:47 +0000814 VisitExpr(E);
Argyrios Kyrtzidisd98a2ab2010-06-29 22:46:25 +0000815 E->setString(cast<StringLiteral>(Reader.ReadSubStmt()));
Sebastian Redlc3632732010-10-05 15:59:54 +0000816 E->setAtLoc(ReadSourceLocation(Record, Idx));
Chris Lattner4c6f9522009-04-27 05:14:47 +0000817}
818
Ted Kremenekebcb57a2012-03-06 20:05:56 +0000819void ASTStmtReader::VisitObjCNumericLiteral(ObjCNumericLiteral *E) {
820 VisitExpr(E);
821 // could be one of several IntegerLiteral, FloatLiteral, etc.
822 E->Number = Reader.ReadSubStmt();
823 E->ObjCNumericLiteralMethod = ReadDeclAs<ObjCMethodDecl>(Record, Idx);
824 E->AtLoc = ReadSourceLocation(Record, Idx);
825}
826
827void ASTStmtReader::VisitObjCArrayLiteral(ObjCArrayLiteral *E) {
828 VisitExpr(E);
829 unsigned NumElements = Record[Idx++];
830 assert(NumElements == E->getNumElements() && "Wrong number of elements");
831 Expr **Elements = E->getElements();
832 for (unsigned I = 0, N = NumElements; I != N; ++I)
833 Elements[I] = Reader.ReadSubExpr();
834 E->ArrayWithObjectsMethod = ReadDeclAs<ObjCMethodDecl>(Record, Idx);
835 E->Range = ReadSourceRange(Record, Idx);
836}
837
838void ASTStmtReader::VisitObjCDictionaryLiteral(ObjCDictionaryLiteral *E) {
839 VisitExpr(E);
840 unsigned NumElements = Record[Idx++];
841 assert(NumElements == E->getNumElements() && "Wrong number of elements");
842 bool HasPackExpansions = Record[Idx++];
843 assert(HasPackExpansions == E->HasPackExpansions &&"Pack expansion mismatch");
844 ObjCDictionaryLiteral::KeyValuePair *KeyValues = E->getKeyValues();
845 ObjCDictionaryLiteral::ExpansionData *Expansions = E->getExpansionData();
846 for (unsigned I = 0; I != NumElements; ++I) {
847 KeyValues[I].Key = Reader.ReadSubExpr();
848 KeyValues[I].Value = Reader.ReadSubExpr();
849 if (HasPackExpansions) {
850 Expansions[I].EllipsisLoc = ReadSourceLocation(Record, Idx);
851 Expansions[I].NumExpansionsPlusOne = Record[Idx++];
852 }
853 }
854 E->DictWithObjectsMethod = ReadDeclAs<ObjCMethodDecl>(Record, Idx);
855 E->Range = ReadSourceRange(Record, Idx);
856}
857
Sebastian Redl60adf4a2010-08-18 23:56:52 +0000858void ASTStmtReader::VisitObjCEncodeExpr(ObjCEncodeExpr *E) {
Chris Lattner4c6f9522009-04-27 05:14:47 +0000859 VisitExpr(E);
Sebastian Redlc3632732010-10-05 15:59:54 +0000860 E->setEncodedTypeSourceInfo(GetTypeSourceInfo(Record, Idx));
861 E->setAtLoc(ReadSourceLocation(Record, Idx));
862 E->setRParenLoc(ReadSourceLocation(Record, Idx));
Chris Lattner4c6f9522009-04-27 05:14:47 +0000863}
864
Sebastian Redl60adf4a2010-08-18 23:56:52 +0000865void ASTStmtReader::VisitObjCSelectorExpr(ObjCSelectorExpr *E) {
Chris Lattner4c6f9522009-04-27 05:14:47 +0000866 VisitExpr(E);
Douglas Gregor2d2689a2011-07-28 21:16:51 +0000867 E->setSelector(Reader.ReadSelector(F, Record, Idx));
Sebastian Redlc3632732010-10-05 15:59:54 +0000868 E->setAtLoc(ReadSourceLocation(Record, Idx));
869 E->setRParenLoc(ReadSourceLocation(Record, Idx));
Chris Lattner4c6f9522009-04-27 05:14:47 +0000870}
871
Sebastian Redl60adf4a2010-08-18 23:56:52 +0000872void ASTStmtReader::VisitObjCProtocolExpr(ObjCProtocolExpr *E) {
Chris Lattner4c6f9522009-04-27 05:14:47 +0000873 VisitExpr(E);
Douglas Gregor409448c2011-07-21 22:35:25 +0000874 E->setProtocol(ReadDeclAs<ObjCProtocolDecl>(Record, Idx));
Sebastian Redlc3632732010-10-05 15:59:54 +0000875 E->setAtLoc(ReadSourceLocation(Record, Idx));
876 E->setRParenLoc(ReadSourceLocation(Record, Idx));
Chris Lattner4c6f9522009-04-27 05:14:47 +0000877}
878
Sebastian Redl60adf4a2010-08-18 23:56:52 +0000879void ASTStmtReader::VisitObjCIvarRefExpr(ObjCIvarRefExpr *E) {
Chris Lattner4c6f9522009-04-27 05:14:47 +0000880 VisitExpr(E);
Douglas Gregor409448c2011-07-21 22:35:25 +0000881 E->setDecl(ReadDeclAs<ObjCIvarDecl>(Record, Idx));
Sebastian Redlc3632732010-10-05 15:59:54 +0000882 E->setLocation(ReadSourceLocation(Record, Idx));
Argyrios Kyrtzidisd98a2ab2010-06-29 22:46:25 +0000883 E->setBase(Reader.ReadSubExpr());
Chris Lattner4c6f9522009-04-27 05:14:47 +0000884 E->setIsArrow(Record[Idx++]);
885 E->setIsFreeIvar(Record[Idx++]);
Chris Lattner4c6f9522009-04-27 05:14:47 +0000886}
887
Sebastian Redl60adf4a2010-08-18 23:56:52 +0000888void ASTStmtReader::VisitObjCPropertyRefExpr(ObjCPropertyRefExpr *E) {
Chris Lattner4c6f9522009-04-27 05:14:47 +0000889 VisitExpr(E);
John McCall12f78a62010-12-02 01:19:52 +0000890 bool Implicit = Record[Idx++] != 0;
891 if (Implicit) {
Douglas Gregor409448c2011-07-21 22:35:25 +0000892 ObjCMethodDecl *Getter = ReadDeclAs<ObjCMethodDecl>(Record, Idx);
893 ObjCMethodDecl *Setter = ReadDeclAs<ObjCMethodDecl>(Record, Idx);
John McCall12f78a62010-12-02 01:19:52 +0000894 E->setImplicitProperty(Getter, Setter);
895 } else {
Douglas Gregor409448c2011-07-21 22:35:25 +0000896 E->setExplicitProperty(ReadDeclAs<ObjCPropertyDecl>(Record, Idx));
Fariborz Jahanian8ac2d442010-10-14 16:04:05 +0000897 }
Sebastian Redlc3632732010-10-05 15:59:54 +0000898 E->setLocation(ReadSourceLocation(Record, Idx));
John McCall12f78a62010-12-02 01:19:52 +0000899 E->setReceiverLocation(ReadSourceLocation(Record, Idx));
900 switch (Record[Idx++]) {
901 case 0:
902 E->setBase(Reader.ReadSubExpr());
903 break;
904 case 1:
Douglas Gregor393f2492011-07-22 00:38:23 +0000905 E->setSuperReceiver(Reader.readType(F, Record, Idx));
John McCall12f78a62010-12-02 01:19:52 +0000906 break;
907 case 2:
Douglas Gregor409448c2011-07-21 22:35:25 +0000908 E->setClassReceiver(ReadDeclAs<ObjCInterfaceDecl>(Record, Idx));
John McCall12f78a62010-12-02 01:19:52 +0000909 break;
910 }
Chris Lattner4c6f9522009-04-27 05:14:47 +0000911}
912
Ted Kremenekebcb57a2012-03-06 20:05:56 +0000913void ASTStmtReader::VisitObjCSubscriptRefExpr(ObjCSubscriptRefExpr *E) {
914 VisitExpr(E);
915 E->setRBracket(ReadSourceLocation(Record, Idx));
916 E->setBaseExpr(Reader.ReadSubExpr());
917 E->setKeyExpr(Reader.ReadSubExpr());
918 E->GetAtIndexMethodDecl = ReadDeclAs<ObjCMethodDecl>(Record, Idx);
919 E->SetAtIndexMethodDecl = ReadDeclAs<ObjCMethodDecl>(Record, Idx);
920}
921
Sebastian Redl60adf4a2010-08-18 23:56:52 +0000922void ASTStmtReader::VisitObjCMessageExpr(ObjCMessageExpr *E) {
Chris Lattner4c6f9522009-04-27 05:14:47 +0000923 VisitExpr(E);
Douglas Gregor04badcf2010-04-21 00:45:42 +0000924 assert(Record[Idx] == E->getNumArgs());
925 ++Idx;
Argyrios Kyrtzidis20718082011-10-03 06:36:51 +0000926 unsigned NumStoredSelLocs = Record[Idx++];
927 E->SelLocsKind = Record[Idx++];
John McCallf85e1932011-06-15 23:02:42 +0000928 E->setDelegateInitCall(Record[Idx++]);
Argyrios Kyrtzidis746f5bc2012-01-12 02:34:39 +0000929 E->IsImplicit = Record[Idx++];
Douglas Gregor04badcf2010-04-21 00:45:42 +0000930 ObjCMessageExpr::ReceiverKind Kind
931 = static_cast<ObjCMessageExpr::ReceiverKind>(Record[Idx++]);
932 switch (Kind) {
933 case ObjCMessageExpr::Instance:
Argyrios Kyrtzidisd98a2ab2010-06-29 22:46:25 +0000934 E->setInstanceReceiver(Reader.ReadSubExpr());
Douglas Gregor04badcf2010-04-21 00:45:42 +0000935 break;
936
937 case ObjCMessageExpr::Class:
Sebastian Redlc3632732010-10-05 15:59:54 +0000938 E->setClassReceiver(GetTypeSourceInfo(Record, Idx));
Douglas Gregor04badcf2010-04-21 00:45:42 +0000939 break;
940
941 case ObjCMessageExpr::SuperClass:
942 case ObjCMessageExpr::SuperInstance: {
Douglas Gregor393f2492011-07-22 00:38:23 +0000943 QualType T = Reader.readType(F, Record, Idx);
Sebastian Redlc3632732010-10-05 15:59:54 +0000944 SourceLocation SuperLoc = ReadSourceLocation(Record, Idx);
Douglas Gregor04badcf2010-04-21 00:45:42 +0000945 E->setSuper(SuperLoc, T, Kind == ObjCMessageExpr::SuperInstance);
946 break;
947 }
948 }
949
950 assert(Kind == E->getReceiverKind());
951
952 if (Record[Idx++])
Douglas Gregor409448c2011-07-21 22:35:25 +0000953 E->setMethodDecl(ReadDeclAs<ObjCMethodDecl>(Record, Idx));
Douglas Gregor04badcf2010-04-21 00:45:42 +0000954 else
Douglas Gregor2d2689a2011-07-28 21:16:51 +0000955 E->setSelector(Reader.ReadSelector(F, Record, Idx));
Douglas Gregor04badcf2010-04-21 00:45:42 +0000956
Argyrios Kyrtzidisf40f0d52010-12-10 20:08:27 +0000957 E->LBracLoc = ReadSourceLocation(Record, Idx);
958 E->RBracLoc = ReadSourceLocation(Record, Idx);
Chris Lattner4c6f9522009-04-27 05:14:47 +0000959
960 for (unsigned I = 0, N = E->getNumArgs(); I != N; ++I)
Argyrios Kyrtzidisd98a2ab2010-06-29 22:46:25 +0000961 E->setArg(I, Reader.ReadSubExpr());
Argyrios Kyrtzidis20718082011-10-03 06:36:51 +0000962
963 SourceLocation *Locs = E->getStoredSelLocs();
964 for (unsigned I = 0; I != NumStoredSelLocs; ++I)
965 Locs[I] = ReadSourceLocation(Record, Idx);
Chris Lattner4c6f9522009-04-27 05:14:47 +0000966}
967
Sebastian Redl60adf4a2010-08-18 23:56:52 +0000968void ASTStmtReader::VisitObjCForCollectionStmt(ObjCForCollectionStmt *S) {
Chris Lattner4c6f9522009-04-27 05:14:47 +0000969 VisitStmt(S);
Argyrios Kyrtzidisd98a2ab2010-06-29 22:46:25 +0000970 S->setElement(Reader.ReadSubStmt());
971 S->setCollection(Reader.ReadSubExpr());
972 S->setBody(Reader.ReadSubStmt());
Sebastian Redlc3632732010-10-05 15:59:54 +0000973 S->setForLoc(ReadSourceLocation(Record, Idx));
974 S->setRParenLoc(ReadSourceLocation(Record, Idx));
Chris Lattner4c6f9522009-04-27 05:14:47 +0000975}
976
Sebastian Redl60adf4a2010-08-18 23:56:52 +0000977void ASTStmtReader::VisitObjCAtCatchStmt(ObjCAtCatchStmt *S) {
Chris Lattner4c6f9522009-04-27 05:14:47 +0000978 VisitStmt(S);
Argyrios Kyrtzidisd98a2ab2010-06-29 22:46:25 +0000979 S->setCatchBody(Reader.ReadSubStmt());
Douglas Gregor409448c2011-07-21 22:35:25 +0000980 S->setCatchParamDecl(ReadDeclAs<VarDecl>(Record, Idx));
Sebastian Redlc3632732010-10-05 15:59:54 +0000981 S->setAtCatchLoc(ReadSourceLocation(Record, Idx));
982 S->setRParenLoc(ReadSourceLocation(Record, Idx));
Chris Lattner4c6f9522009-04-27 05:14:47 +0000983}
984
Sebastian Redl60adf4a2010-08-18 23:56:52 +0000985void ASTStmtReader::VisitObjCAtFinallyStmt(ObjCAtFinallyStmt *S) {
Chris Lattner4c6f9522009-04-27 05:14:47 +0000986 VisitStmt(S);
Argyrios Kyrtzidisd98a2ab2010-06-29 22:46:25 +0000987 S->setFinallyBody(Reader.ReadSubStmt());
Sebastian Redlc3632732010-10-05 15:59:54 +0000988 S->setAtFinallyLoc(ReadSourceLocation(Record, Idx));
Chris Lattner4c6f9522009-04-27 05:14:47 +0000989}
990
John McCallf85e1932011-06-15 23:02:42 +0000991void ASTStmtReader::VisitObjCAutoreleasePoolStmt(ObjCAutoreleasePoolStmt *S) {
992 VisitStmt(S);
993 S->setSubStmt(Reader.ReadSubStmt());
994 S->setAtLoc(ReadSourceLocation(Record, Idx));
995}
996
Sebastian Redl60adf4a2010-08-18 23:56:52 +0000997void ASTStmtReader::VisitObjCAtTryStmt(ObjCAtTryStmt *S) {
Chris Lattner4c6f9522009-04-27 05:14:47 +0000998 VisitStmt(S);
Douglas Gregor8f5e3dd2010-04-23 22:50:49 +0000999 assert(Record[Idx] == S->getNumCatchStmts());
1000 ++Idx;
1001 bool HasFinally = Record[Idx++];
Argyrios Kyrtzidisd98a2ab2010-06-29 22:46:25 +00001002 S->setTryBody(Reader.ReadSubStmt());
Argyrios Kyrtzidis919e6932010-06-28 22:28:35 +00001003 for (unsigned I = 0, N = S->getNumCatchStmts(); I != N; ++I)
Argyrios Kyrtzidisd98a2ab2010-06-29 22:46:25 +00001004 S->setCatchStmt(I, cast_or_null<ObjCAtCatchStmt>(Reader.ReadSubStmt()));
Douglas Gregor8f5e3dd2010-04-23 22:50:49 +00001005
Douglas Gregor8f5e3dd2010-04-23 22:50:49 +00001006 if (HasFinally)
Argyrios Kyrtzidisd98a2ab2010-06-29 22:46:25 +00001007 S->setFinallyStmt(Reader.ReadSubStmt());
Sebastian Redlc3632732010-10-05 15:59:54 +00001008 S->setAtTryLoc(ReadSourceLocation(Record, Idx));
Chris Lattner4c6f9522009-04-27 05:14:47 +00001009}
1010
Sebastian Redl60adf4a2010-08-18 23:56:52 +00001011void ASTStmtReader::VisitObjCAtSynchronizedStmt(ObjCAtSynchronizedStmt *S) {
Chris Lattner4c6f9522009-04-27 05:14:47 +00001012 VisitStmt(S);
Argyrios Kyrtzidisd98a2ab2010-06-29 22:46:25 +00001013 S->setSynchExpr(Reader.ReadSubStmt());
1014 S->setSynchBody(Reader.ReadSubStmt());
Sebastian Redlc3632732010-10-05 15:59:54 +00001015 S->setAtSynchronizedLoc(ReadSourceLocation(Record, Idx));
Chris Lattner4c6f9522009-04-27 05:14:47 +00001016}
1017
Sebastian Redl60adf4a2010-08-18 23:56:52 +00001018void ASTStmtReader::VisitObjCAtThrowStmt(ObjCAtThrowStmt *S) {
Chris Lattner4c6f9522009-04-27 05:14:47 +00001019 VisitStmt(S);
Argyrios Kyrtzidisd98a2ab2010-06-29 22:46:25 +00001020 S->setThrowExpr(Reader.ReadSubStmt());
Sebastian Redlc3632732010-10-05 15:59:54 +00001021 S->setThrowLoc(ReadSourceLocation(Record, Idx));
Chris Lattner4c6f9522009-04-27 05:14:47 +00001022}
1023
Ted Kremenekebcb57a2012-03-06 20:05:56 +00001024void ASTStmtReader::VisitObjCBoolLiteralExpr(ObjCBoolLiteralExpr *E) {
1025 VisitExpr(E);
1026 E->setValue(Record[Idx++]);
1027 E->setLocation(ReadSourceLocation(Record, Idx));
1028}
1029
Argyrios Kyrtzidisba0a9002009-07-14 03:19:21 +00001030//===----------------------------------------------------------------------===//
1031// C++ Expressions and Statements
Argyrios Kyrtzidis7cb45e32010-07-22 16:03:56 +00001032//===----------------------------------------------------------------------===//
1033
Sebastian Redl60adf4a2010-08-18 23:56:52 +00001034void ASTStmtReader::VisitCXXCatchStmt(CXXCatchStmt *S) {
Argyrios Kyrtzidis7cb45e32010-07-22 16:03:56 +00001035 VisitStmt(S);
Sebastian Redlc3632732010-10-05 15:59:54 +00001036 S->CatchLoc = ReadSourceLocation(Record, Idx);
Douglas Gregor409448c2011-07-21 22:35:25 +00001037 S->ExceptionDecl = ReadDeclAs<VarDecl>(Record, Idx);
Argyrios Kyrtzidis7cb45e32010-07-22 16:03:56 +00001038 S->HandlerBlock = Reader.ReadSubStmt();
1039}
1040
Sebastian Redl60adf4a2010-08-18 23:56:52 +00001041void ASTStmtReader::VisitCXXTryStmt(CXXTryStmt *S) {
Argyrios Kyrtzidis7cb45e32010-07-22 16:03:56 +00001042 VisitStmt(S);
1043 assert(Record[Idx] == S->getNumHandlers() && "NumStmtFields is wrong ?");
1044 ++Idx;
Sebastian Redlc3632732010-10-05 15:59:54 +00001045 S->TryLoc = ReadSourceLocation(Record, Idx);
Argyrios Kyrtzidis7cb45e32010-07-22 16:03:56 +00001046 S->getStmts()[0] = Reader.ReadSubStmt();
1047 for (unsigned i = 0, e = S->getNumHandlers(); i != e; ++i)
1048 S->getStmts()[i + 1] = Reader.ReadSubStmt();
1049}
Argyrios Kyrtzidisba0a9002009-07-14 03:19:21 +00001050
Richard Smithad762fc2011-04-14 22:09:26 +00001051void ASTStmtReader::VisitCXXForRangeStmt(CXXForRangeStmt *S) {
1052 VisitStmt(S);
1053 S->setForLoc(ReadSourceLocation(Record, Idx));
1054 S->setColonLoc(ReadSourceLocation(Record, Idx));
1055 S->setRParenLoc(ReadSourceLocation(Record, Idx));
1056 S->setRangeStmt(Reader.ReadSubStmt());
1057 S->setBeginEndStmt(Reader.ReadSubStmt());
1058 S->setCond(Reader.ReadSubExpr());
1059 S->setInc(Reader.ReadSubExpr());
1060 S->setLoopVarStmt(Reader.ReadSubStmt());
1061 S->setBody(Reader.ReadSubStmt());
1062}
1063
Douglas Gregorba0513d2011-10-25 01:33:02 +00001064void ASTStmtReader::VisitMSDependentExistsStmt(MSDependentExistsStmt *S) {
1065 VisitStmt(S);
1066 S->KeywordLoc = ReadSourceLocation(Record, Idx);
1067 S->IsIfExists = Record[Idx++];
1068 S->QualifierLoc = Reader.ReadNestedNameSpecifierLoc(F, Record, Idx);
1069 ReadDeclarationNameInfo(S->NameInfo, Record, Idx);
1070 S->SubStmt = Reader.ReadSubStmt();
1071}
1072
Sebastian Redl60adf4a2010-08-18 23:56:52 +00001073void ASTStmtReader::VisitCXXOperatorCallExpr(CXXOperatorCallExpr *E) {
Argyrios Kyrtzidis919e6932010-06-28 22:28:35 +00001074 VisitCallExpr(E);
Argyrios Kyrtzidisba0a9002009-07-14 03:19:21 +00001075 E->setOperator((OverloadedOperatorKind)Record[Idx++]);
Argyrios Kyrtzidisba0a9002009-07-14 03:19:21 +00001076}
1077
Sebastian Redl60adf4a2010-08-18 23:56:52 +00001078void ASTStmtReader::VisitCXXConstructExpr(CXXConstructExpr *E) {
Douglas Gregor39da0b82009-09-09 23:08:42 +00001079 VisitExpr(E);
Argyrios Kyrtzidis6d00c132010-07-10 11:46:15 +00001080 E->NumArgs = Record[Idx++];
1081 if (E->NumArgs)
Douglas Gregor35942772011-09-09 21:34:22 +00001082 E->Args = new (Reader.getContext()) Stmt*[E->NumArgs];
Argyrios Kyrtzidis5e1b7c22010-06-24 08:57:09 +00001083 for (unsigned I = 0, N = E->getNumArgs(); I != N; ++I)
Argyrios Kyrtzidisd98a2ab2010-06-29 22:46:25 +00001084 E->setArg(I, Reader.ReadSubExpr());
Douglas Gregor409448c2011-07-21 22:35:25 +00001085 E->setConstructor(ReadDeclAs<CXXConstructorDecl>(Record, Idx));
Sebastian Redlc3632732010-10-05 15:59:54 +00001086 E->setLocation(ReadSourceLocation(Record, Idx));
Abramo Bagnara7cc58b42011-10-05 07:56:41 +00001087 E->setElidable(Record[Idx++]);
1088 E->setHadMultipleCandidates(Record[Idx++]);
Douglas Gregor16006c92009-12-16 18:50:27 +00001089 E->setRequiresZeroInitialization(Record[Idx++]);
Douglas Gregor3c9034c2010-05-15 00:13:29 +00001090 E->setConstructionKind((CXXConstructExpr::ConstructionKind)Record[Idx++]);
Chandler Carruth428edaf2010-10-25 08:47:36 +00001091 E->ParenRange = ReadSourceRange(Record, Idx);
Douglas Gregor39da0b82009-09-09 23:08:42 +00001092}
Chris Lattner4c6f9522009-04-27 05:14:47 +00001093
Sebastian Redl60adf4a2010-08-18 23:56:52 +00001094void ASTStmtReader::VisitCXXTemporaryObjectExpr(CXXTemporaryObjectExpr *E) {
Argyrios Kyrtzidis6d00c132010-07-10 11:46:15 +00001095 VisitCXXConstructExpr(E);
Sebastian Redlc3632732010-10-05 15:59:54 +00001096 E->Type = GetTypeSourceInfo(Record, Idx);
Argyrios Kyrtzidis6d00c132010-07-10 11:46:15 +00001097}
1098
Douglas Gregor01d08012012-02-07 10:09:13 +00001099void ASTStmtReader::VisitLambdaExpr(LambdaExpr *E) {
1100 VisitExpr(E);
Douglas Gregor9d36f5d2012-02-14 17:54:36 +00001101 unsigned NumCaptures = Record[Idx++];
1102 assert(NumCaptures == E->NumCaptures);(void)NumCaptures;
1103 unsigned NumArrayIndexVars = Record[Idx++];
1104 E->IntroducerRange = ReadSourceRange(Record, Idx);
1105 E->CaptureDefault = static_cast<LambdaCaptureDefault>(Record[Idx++]);
1106 E->ExplicitParams = Record[Idx++];
1107 E->ExplicitResultType = Record[Idx++];
1108 E->ClosingBrace = ReadSourceLocation(Record, Idx);
1109
1110 // Read capture initializers.
1111 for (LambdaExpr::capture_init_iterator C = E->capture_init_begin(),
1112 CEnd = E->capture_init_end();
1113 C != CEnd; ++C)
1114 *C = Reader.ReadSubExpr();
1115
1116 // Read array capture index variables.
1117 if (NumArrayIndexVars > 0) {
1118 unsigned *ArrayIndexStarts = E->getArrayIndexStarts();
1119 for (unsigned I = 0; I != NumCaptures + 1; ++I)
1120 ArrayIndexStarts[I] = Record[Idx++];
1121
1122 VarDecl **ArrayIndexVars = E->getArrayIndexVars();
1123 for (unsigned I = 0; I != NumArrayIndexVars; ++I)
1124 ArrayIndexVars[I] = ReadDeclAs<VarDecl>(Record, Idx);
1125 }
Douglas Gregor01d08012012-02-07 10:09:13 +00001126}
1127
Sebastian Redl60adf4a2010-08-18 23:56:52 +00001128void ASTStmtReader::VisitCXXNamedCastExpr(CXXNamedCastExpr *E) {
Argyrios Kyrtzidis919e6932010-06-28 22:28:35 +00001129 VisitExplicitCastExpr(E);
Douglas Gregor1d5d0b92011-01-12 22:41:29 +00001130 SourceRange R = ReadSourceRange(Record, Idx);
1131 E->Loc = R.getBegin();
1132 E->RParenLoc = R.getEnd();
Sam Weinigce757a72010-01-16 21:21:01 +00001133}
1134
Sebastian Redl60adf4a2010-08-18 23:56:52 +00001135void ASTStmtReader::VisitCXXStaticCastExpr(CXXStaticCastExpr *E) {
Sam Weinigce757a72010-01-16 21:21:01 +00001136 return VisitCXXNamedCastExpr(E);
1137}
1138
Sebastian Redl60adf4a2010-08-18 23:56:52 +00001139void ASTStmtReader::VisitCXXDynamicCastExpr(CXXDynamicCastExpr *E) {
Sam Weinigce757a72010-01-16 21:21:01 +00001140 return VisitCXXNamedCastExpr(E);
1141}
1142
Sebastian Redl60adf4a2010-08-18 23:56:52 +00001143void ASTStmtReader::VisitCXXReinterpretCastExpr(CXXReinterpretCastExpr *E) {
Sam Weinigce757a72010-01-16 21:21:01 +00001144 return VisitCXXNamedCastExpr(E);
1145}
1146
Sebastian Redl60adf4a2010-08-18 23:56:52 +00001147void ASTStmtReader::VisitCXXConstCastExpr(CXXConstCastExpr *E) {
Sam Weinigce757a72010-01-16 21:21:01 +00001148 return VisitCXXNamedCastExpr(E);
1149}
1150
Sebastian Redl60adf4a2010-08-18 23:56:52 +00001151void ASTStmtReader::VisitCXXFunctionalCastExpr(CXXFunctionalCastExpr *E) {
Argyrios Kyrtzidis919e6932010-06-28 22:28:35 +00001152 VisitExplicitCastExpr(E);
Sebastian Redlc3632732010-10-05 15:59:54 +00001153 E->setTypeBeginLoc(ReadSourceLocation(Record, Idx));
1154 E->setRParenLoc(ReadSourceLocation(Record, Idx));
Sam Weinigce757a72010-01-16 21:21:01 +00001155}
1156
Richard Smith9fcce652012-03-07 08:35:16 +00001157void ASTStmtReader::VisitUserDefinedLiteral(UserDefinedLiteral *E) {
1158 VisitCallExpr(E);
1159 E->UDSuffixLoc = ReadSourceLocation(Record, Idx);
1160}
1161
Sebastian Redl60adf4a2010-08-18 23:56:52 +00001162void ASTStmtReader::VisitCXXBoolLiteralExpr(CXXBoolLiteralExpr *E) {
Sam Weinigeb7f9612010-02-07 06:32:43 +00001163 VisitExpr(E);
1164 E->setValue(Record[Idx++]);
Sebastian Redlc3632732010-10-05 15:59:54 +00001165 E->setLocation(ReadSourceLocation(Record, Idx));
Sam Weinigeb7f9612010-02-07 06:32:43 +00001166}
1167
Sebastian Redl60adf4a2010-08-18 23:56:52 +00001168void ASTStmtReader::VisitCXXNullPtrLiteralExpr(CXXNullPtrLiteralExpr *E) {
Sam Weinigeb7f9612010-02-07 06:32:43 +00001169 VisitExpr(E);
Sebastian Redlc3632732010-10-05 15:59:54 +00001170 E->setLocation(ReadSourceLocation(Record, Idx));
Sam Weinigeb7f9612010-02-07 06:32:43 +00001171}
1172
Sebastian Redl60adf4a2010-08-18 23:56:52 +00001173void ASTStmtReader::VisitCXXTypeidExpr(CXXTypeidExpr *E) {
Chris Lattner14ab24f2010-05-09 06:03:39 +00001174 VisitExpr(E);
Sebastian Redlc3632732010-10-05 15:59:54 +00001175 E->setSourceRange(ReadSourceRange(Record, Idx));
Chris Lattner14ab24f2010-05-09 06:03:39 +00001176 if (E->isTypeOperand()) { // typeid(int)
Sebastian Redl577d4792010-07-22 22:43:28 +00001177 E->setTypeOperandSourceInfo(
Sebastian Redlc3632732010-10-05 15:59:54 +00001178 GetTypeSourceInfo(Record, Idx));
Argyrios Kyrtzidis919e6932010-06-28 22:28:35 +00001179 return;
Chris Lattner14ab24f2010-05-09 06:03:39 +00001180 }
1181
1182 // typeid(42+2)
Argyrios Kyrtzidisd98a2ab2010-06-29 22:46:25 +00001183 E->setExprOperand(Reader.ReadSubExpr());
Chris Lattner14ab24f2010-05-09 06:03:39 +00001184}
1185
Sebastian Redl60adf4a2010-08-18 23:56:52 +00001186void ASTStmtReader::VisitCXXThisExpr(CXXThisExpr *E) {
Chris Lattner2fbdfcd2010-05-09 06:15:05 +00001187 VisitExpr(E);
Sebastian Redlc3632732010-10-05 15:59:54 +00001188 E->setLocation(ReadSourceLocation(Record, Idx));
Chris Lattner2fbdfcd2010-05-09 06:15:05 +00001189 E->setImplicit(Record[Idx++]);
Chris Lattner2fbdfcd2010-05-09 06:15:05 +00001190}
1191
Sebastian Redl60adf4a2010-08-18 23:56:52 +00001192void ASTStmtReader::VisitCXXThrowExpr(CXXThrowExpr *E) {
Chris Lattner2fbdfcd2010-05-09 06:15:05 +00001193 VisitExpr(E);
Douglas Gregorbca01b42011-07-06 22:04:06 +00001194 E->ThrowLoc = ReadSourceLocation(Record, Idx);
1195 E->Op = Reader.ReadSubExpr();
1196 E->IsThrownVariableInScope = Record[Idx++];
Chris Lattner2fbdfcd2010-05-09 06:15:05 +00001197}
Chris Lattner14ab24f2010-05-09 06:03:39 +00001198
Sebastian Redl60adf4a2010-08-18 23:56:52 +00001199void ASTStmtReader::VisitCXXDefaultArgExpr(CXXDefaultArgExpr *E) {
Chris Lattner030854b2010-05-09 06:40:08 +00001200 VisitExpr(E);
Argyrios Kyrtzidis8a507332010-07-02 23:30:15 +00001201
Douglas Gregordf226552011-09-23 22:07:41 +00001202 assert((bool)Record[Idx] == E->Param.getInt() && "We messed up at creation ?");
Argyrios Kyrtzidis8a507332010-07-02 23:30:15 +00001203 ++Idx; // HasOtherExprStored and SubExpr was handled during creation.
Douglas Gregor409448c2011-07-21 22:35:25 +00001204 E->Param.setPointer(ReadDeclAs<ParmVarDecl>(Record, Idx));
Sebastian Redlc3632732010-10-05 15:59:54 +00001205 E->Loc = ReadSourceLocation(Record, Idx);
Chris Lattnerd2598362010-05-10 00:25:06 +00001206}
1207
Sebastian Redl60adf4a2010-08-18 23:56:52 +00001208void ASTStmtReader::VisitCXXBindTemporaryExpr(CXXBindTemporaryExpr *E) {
Chris Lattnerd2598362010-05-10 00:25:06 +00001209 VisitExpr(E);
Douglas Gregor409448c2011-07-21 22:35:25 +00001210 E->setTemporary(Reader.ReadCXXTemporary(F, Record, Idx));
Argyrios Kyrtzidisd98a2ab2010-06-29 22:46:25 +00001211 E->setSubExpr(Reader.ReadSubExpr());
Chris Lattnerd2598362010-05-10 00:25:06 +00001212}
1213
Sebastian Redl60adf4a2010-08-18 23:56:52 +00001214void ASTStmtReader::VisitCXXScalarValueInitExpr(CXXScalarValueInitExpr *E) {
Chris Lattner59218632010-05-10 01:22:27 +00001215 VisitExpr(E);
Sebastian Redlc3632732010-10-05 15:59:54 +00001216 E->TypeInfo = GetTypeSourceInfo(Record, Idx);
1217 E->RParenLoc = ReadSourceLocation(Record, Idx);
Chris Lattner59218632010-05-10 01:22:27 +00001218}
1219
Sebastian Redl60adf4a2010-08-18 23:56:52 +00001220void ASTStmtReader::VisitCXXNewExpr(CXXNewExpr *E) {
Chris Lattner59218632010-05-10 01:22:27 +00001221 VisitExpr(E);
John McCall6ec278d2011-01-27 09:37:56 +00001222 E->GlobalNew = Record[Idx++];
Sebastian Redl1548d142012-02-16 11:35:52 +00001223 bool isArray = Record[Idx++];
Sebastian Redl2aed8b82012-02-16 12:22:20 +00001224 E->UsualArrayDeleteWantsSize = Record[Idx++];
Chris Lattner59218632010-05-10 01:22:27 +00001225 unsigned NumPlacementArgs = Record[Idx++];
Sebastian Redl2aed8b82012-02-16 12:22:20 +00001226 E->StoredInitializationStyle = Record[Idx++];
Douglas Gregor409448c2011-07-21 22:35:25 +00001227 E->setOperatorNew(ReadDeclAs<FunctionDecl>(Record, Idx));
1228 E->setOperatorDelete(ReadDeclAs<FunctionDecl>(Record, Idx));
Sebastian Redlc3632732010-10-05 15:59:54 +00001229 E->AllocatedTypeInfo = GetTypeSourceInfo(Record, Idx);
Douglas Gregor83bc2762012-02-20 16:12:14 +00001230 E->TypeIdParens = ReadSourceRange(Record, Idx);
Chandler Carruth428edaf2010-10-25 08:47:36 +00001231 E->StartLoc = ReadSourceLocation(Record, Idx);
Douglas Gregor83bc2762012-02-20 16:12:14 +00001232 E->DirectInitRange = ReadSourceRange(Record, Idx);
Chandler Carruth428edaf2010-10-25 08:47:36 +00001233
Douglas Gregor35942772011-09-09 21:34:22 +00001234 E->AllocateArgsArray(Reader.getContext(), isArray, NumPlacementArgs,
Sebastian Redl2aed8b82012-02-16 12:22:20 +00001235 E->StoredInitializationStyle != 0);
Chris Lattner59218632010-05-10 01:22:27 +00001236
1237 // Install all the subexpressions.
Chris Lattner59218632010-05-10 01:22:27 +00001238 for (CXXNewExpr::raw_arg_iterator I = E->raw_arg_begin(),e = E->raw_arg_end();
1239 I != e; ++I)
Argyrios Kyrtzidisd98a2ab2010-06-29 22:46:25 +00001240 *I = Reader.ReadSubStmt();
Chris Lattner59218632010-05-10 01:22:27 +00001241}
1242
Sebastian Redl60adf4a2010-08-18 23:56:52 +00001243void ASTStmtReader::VisitCXXDeleteExpr(CXXDeleteExpr *E) {
Argyrios Kyrtzidis95fc98c2010-06-22 17:07:59 +00001244 VisitExpr(E);
Argyrios Kyrtzidisf1b89112010-09-13 20:15:40 +00001245 E->GlobalDelete = Record[Idx++];
1246 E->ArrayForm = Record[Idx++];
Argyrios Kyrtzidis4076dac2010-09-13 20:15:54 +00001247 E->ArrayFormAsWritten = Record[Idx++];
John McCall6ec278d2011-01-27 09:37:56 +00001248 E->UsualArrayDeleteWantsSize = Record[Idx++];
Douglas Gregor409448c2011-07-21 22:35:25 +00001249 E->OperatorDelete = ReadDeclAs<FunctionDecl>(Record, Idx);
Argyrios Kyrtzidisf1b89112010-09-13 20:15:40 +00001250 E->Argument = Reader.ReadSubExpr();
Sebastian Redlc3632732010-10-05 15:59:54 +00001251 E->Loc = ReadSourceLocation(Record, Idx);
Argyrios Kyrtzidis95fc98c2010-06-22 17:07:59 +00001252}
Chris Lattnerd2598362010-05-10 00:25:06 +00001253
Sebastian Redl60adf4a2010-08-18 23:56:52 +00001254void ASTStmtReader::VisitCXXPseudoDestructorExpr(CXXPseudoDestructorExpr *E) {
Argyrios Kyrtzidisde4bd182010-06-28 09:32:03 +00001255 VisitExpr(E);
1256
Douglas Gregorf3db29f2011-02-25 18:19:59 +00001257 E->Base = Reader.ReadSubExpr();
1258 E->IsArrow = Record[Idx++];
1259 E->OperatorLoc = ReadSourceLocation(Record, Idx);
1260 E->QualifierLoc = Reader.ReadNestedNameSpecifierLoc(F, Record, Idx);
1261 E->ScopeType = GetTypeSourceInfo(Record, Idx);
1262 E->ColonColonLoc = ReadSourceLocation(Record, Idx);
1263 E->TildeLoc = ReadSourceLocation(Record, Idx);
Argyrios Kyrtzidisde4bd182010-06-28 09:32:03 +00001264
Douglas Gregor95eab172011-07-28 20:55:49 +00001265 IdentifierInfo *II = Reader.GetIdentifierInfo(F, Record, Idx);
Argyrios Kyrtzidisde4bd182010-06-28 09:32:03 +00001266 if (II)
Sebastian Redlc3632732010-10-05 15:59:54 +00001267 E->setDestroyedType(II, ReadSourceLocation(Record, Idx));
Argyrios Kyrtzidisde4bd182010-06-28 09:32:03 +00001268 else
Sebastian Redlc3632732010-10-05 15:59:54 +00001269 E->setDestroyedType(GetTypeSourceInfo(Record, Idx));
Argyrios Kyrtzidisde4bd182010-06-28 09:32:03 +00001270}
1271
John McCall4765fa02010-12-06 08:20:24 +00001272void ASTStmtReader::VisitExprWithCleanups(ExprWithCleanups *E) {
Chris Lattnerd2598362010-05-10 00:25:06 +00001273 VisitExpr(E);
John McCall80ee6e82011-11-10 05:35:25 +00001274
1275 unsigned NumObjects = Record[Idx++];
1276 assert(NumObjects == E->getNumObjects());
1277 for (unsigned i = 0; i != NumObjects; ++i)
1278 E->getObjectsBuffer()[i] = ReadDeclAs<BlockDecl>(Record, Idx);
1279
1280 E->SubExpr = Reader.ReadSubExpr();
Chris Lattner030854b2010-05-09 06:40:08 +00001281}
1282
Argyrios Kyrtzidis919e6932010-06-28 22:28:35 +00001283void
Sebastian Redl60adf4a2010-08-18 23:56:52 +00001284ASTStmtReader::VisitCXXDependentScopeMemberExpr(CXXDependentScopeMemberExpr *E){
Argyrios Kyrtzidis8dfbd8b2010-06-24 08:57:31 +00001285 VisitExpr(E);
Abramo Bagnarae4b92762012-01-27 09:46:47 +00001286
1287 if (Record[Idx++]) // HasTemplateKWAndArgsInfo
1288 ReadTemplateKWAndArgsInfo(*E->getTemplateKWAndArgsInfo(),
1289 /*NumTemplateArgs=*/Record[Idx++]);
Argyrios Kyrtzidis8dfbd8b2010-06-24 08:57:31 +00001290
Douglas Gregor7c3179c2011-02-28 18:50:33 +00001291 E->Base = Reader.ReadSubExpr();
Douglas Gregor393f2492011-07-22 00:38:23 +00001292 E->BaseType = Reader.readType(F, Record, Idx);
Douglas Gregor7c3179c2011-02-28 18:50:33 +00001293 E->IsArrow = Record[Idx++];
1294 E->OperatorLoc = ReadSourceLocation(Record, Idx);
1295 E->QualifierLoc = Reader.ReadNestedNameSpecifierLoc(F, Record, Idx);
Douglas Gregor409448c2011-07-21 22:35:25 +00001296 E->FirstQualifierFoundInScope = ReadDeclAs<NamedDecl>(Record, Idx);
Argyrios Kyrtzidis40451072010-10-15 18:21:24 +00001297 ReadDeclarationNameInfo(E->MemberNameInfo, Record, Idx);
Argyrios Kyrtzidis8dfbd8b2010-06-24 08:57:31 +00001298}
1299
Argyrios Kyrtzidis919e6932010-06-28 22:28:35 +00001300void
Sebastian Redl60adf4a2010-08-18 23:56:52 +00001301ASTStmtReader::VisitDependentScopeDeclRefExpr(DependentScopeDeclRefExpr *E) {
Argyrios Kyrtzidis12dffcd2010-06-28 09:31:56 +00001302 VisitExpr(E);
Abramo Bagnarae4b92762012-01-27 09:46:47 +00001303
1304 if (Record[Idx++]) // HasTemplateKWAndArgsInfo
1305 ReadTemplateKWAndArgsInfo(*E->getTemplateKWAndArgsInfo(),
1306 /*NumTemplateArgs=*/Record[Idx++]);
Douglas Gregor00cf3cc2011-02-25 20:49:16 +00001307
1308 E->QualifierLoc = Reader.ReadNestedNameSpecifierLoc(F, Record, Idx);
Argyrios Kyrtzidis40451072010-10-15 18:21:24 +00001309 ReadDeclarationNameInfo(E->NameInfo, Record, Idx);
Argyrios Kyrtzidis12dffcd2010-06-28 09:31:56 +00001310}
1311
Argyrios Kyrtzidis919e6932010-06-28 22:28:35 +00001312void
Sebastian Redl60adf4a2010-08-18 23:56:52 +00001313ASTStmtReader::VisitCXXUnresolvedConstructExpr(CXXUnresolvedConstructExpr *E) {
Argyrios Kyrtzidis8dfbd8b2010-06-24 08:57:31 +00001314 VisitExpr(E);
1315 assert(Record[Idx] == E->arg_size() && "Read wrong record during creation ?");
1316 ++Idx; // NumArgs;
1317 for (unsigned I = 0, N = E->arg_size(); I != N; ++I)
Argyrios Kyrtzidisd98a2ab2010-06-29 22:46:25 +00001318 E->setArg(I, Reader.ReadSubExpr());
Sebastian Redlc3632732010-10-05 15:59:54 +00001319 E->Type = GetTypeSourceInfo(Record, Idx);
1320 E->setLParenLoc(ReadSourceLocation(Record, Idx));
1321 E->setRParenLoc(ReadSourceLocation(Record, Idx));
Argyrios Kyrtzidis8dfbd8b2010-06-24 08:57:31 +00001322}
1323
Sebastian Redl60adf4a2010-08-18 23:56:52 +00001324void ASTStmtReader::VisitOverloadExpr(OverloadExpr *E) {
Argyrios Kyrtzidisa77eb082010-06-25 09:03:26 +00001325 VisitExpr(E);
Abramo Bagnarae4b92762012-01-27 09:46:47 +00001326
1327 if (Record[Idx++]) // HasTemplateKWAndArgsInfo
1328 ReadTemplateKWAndArgsInfo(*E->getTemplateKWAndArgsInfo(),
1329 /*NumTemplateArgs=*/Record[Idx++]);
Argyrios Kyrtzidisa77eb082010-06-25 09:03:26 +00001330
1331 unsigned NumDecls = Record[Idx++];
1332 UnresolvedSet<8> Decls;
1333 for (unsigned i = 0; i != NumDecls; ++i) {
Douglas Gregor409448c2011-07-21 22:35:25 +00001334 NamedDecl *D = ReadDeclAs<NamedDecl>(Record, Idx);
Argyrios Kyrtzidisa77eb082010-06-25 09:03:26 +00001335 AccessSpecifier AS = (AccessSpecifier)Record[Idx++];
1336 Decls.addDecl(D, AS);
1337 }
Douglas Gregor35942772011-09-09 21:34:22 +00001338 E->initializeResults(Reader.getContext(), Decls.begin(), Decls.end());
Argyrios Kyrtzidisa77eb082010-06-25 09:03:26 +00001339
Argyrios Kyrtzidis40451072010-10-15 18:21:24 +00001340 ReadDeclarationNameInfo(E->NameInfo, Record, Idx);
Douglas Gregor4c9be892011-02-28 20:01:57 +00001341 E->QualifierLoc = Reader.ReadNestedNameSpecifierLoc(F, Record, Idx);
Argyrios Kyrtzidisa77eb082010-06-25 09:03:26 +00001342}
1343
Sebastian Redl60adf4a2010-08-18 23:56:52 +00001344void ASTStmtReader::VisitUnresolvedMemberExpr(UnresolvedMemberExpr *E) {
Argyrios Kyrtzidis919e6932010-06-28 22:28:35 +00001345 VisitOverloadExpr(E);
Douglas Gregor4c9be892011-02-28 20:01:57 +00001346 E->IsArrow = Record[Idx++];
1347 E->HasUnresolvedUsing = Record[Idx++];
1348 E->Base = Reader.ReadSubExpr();
Douglas Gregor393f2492011-07-22 00:38:23 +00001349 E->BaseType = Reader.readType(F, Record, Idx);
Douglas Gregor4c9be892011-02-28 20:01:57 +00001350 E->OperatorLoc = ReadSourceLocation(Record, Idx);
Argyrios Kyrtzidisa77eb082010-06-25 09:03:26 +00001351}
1352
Sebastian Redl60adf4a2010-08-18 23:56:52 +00001353void ASTStmtReader::VisitUnresolvedLookupExpr(UnresolvedLookupExpr *E) {
Argyrios Kyrtzidis919e6932010-06-28 22:28:35 +00001354 VisitOverloadExpr(E);
Douglas Gregor4c9be892011-02-28 20:01:57 +00001355 E->RequiresADL = Record[Idx++];
Richard Smithad762fc2011-04-14 22:09:26 +00001356 if (E->RequiresADL)
1357 E->StdIsAssociatedNamespace = Record[Idx++];
Douglas Gregor4c9be892011-02-28 20:01:57 +00001358 E->Overloaded = Record[Idx++];
Douglas Gregor409448c2011-07-21 22:35:25 +00001359 E->NamingClass = ReadDeclAs<CXXRecordDecl>(Record, Idx);
Argyrios Kyrtzidisbd65bb52010-06-25 09:03:34 +00001360}
1361
Sebastian Redl60adf4a2010-08-18 23:56:52 +00001362void ASTStmtReader::VisitUnaryTypeTraitExpr(UnaryTypeTraitExpr *E) {
Argyrios Kyrtzidis6d00c132010-07-10 11:46:15 +00001363 VisitExpr(E);
1364 E->UTT = (UnaryTypeTrait)Record[Idx++];
Sebastian Redl0dfd8482010-09-13 20:56:31 +00001365 E->Value = (bool)Record[Idx++];
Sebastian Redlc3632732010-10-05 15:59:54 +00001366 SourceRange Range = ReadSourceRange(Record, Idx);
Argyrios Kyrtzidis6d00c132010-07-10 11:46:15 +00001367 E->Loc = Range.getBegin();
1368 E->RParen = Range.getEnd();
Sebastian Redlc3632732010-10-05 15:59:54 +00001369 E->QueriedType = GetTypeSourceInfo(Record, Idx);
Argyrios Kyrtzidis6d00c132010-07-10 11:46:15 +00001370}
1371
Francois Pichet6ad6f282010-12-07 00:08:36 +00001372void ASTStmtReader::VisitBinaryTypeTraitExpr(BinaryTypeTraitExpr *E) {
1373 VisitExpr(E);
1374 E->BTT = (BinaryTypeTrait)Record[Idx++];
1375 E->Value = (bool)Record[Idx++];
1376 SourceRange Range = ReadSourceRange(Record, Idx);
1377 E->Loc = Range.getBegin();
1378 E->RParen = Range.getEnd();
1379 E->LhsType = GetTypeSourceInfo(Record, Idx);
1380 E->RhsType = GetTypeSourceInfo(Record, Idx);
1381}
1382
Douglas Gregor4ca8ac22012-02-24 07:38:34 +00001383void ASTStmtReader::VisitTypeTraitExpr(TypeTraitExpr *E) {
1384 VisitExpr(E);
1385 E->TypeTraitExprBits.NumArgs = Record[Idx++];
1386 E->TypeTraitExprBits.Kind = Record[Idx++];
1387 E->TypeTraitExprBits.Value = Record[Idx++];
1388
1389 TypeSourceInfo **Args = E->getTypeSourceInfos();
1390 for (unsigned I = 0, N = E->getNumArgs(); I != N; ++I)
1391 Args[I] = GetTypeSourceInfo(Record, Idx);
1392}
1393
John Wiegley21ff2e52011-04-28 00:16:57 +00001394void ASTStmtReader::VisitArrayTypeTraitExpr(ArrayTypeTraitExpr *E) {
1395 VisitExpr(E);
1396 E->ATT = (ArrayTypeTrait)Record[Idx++];
1397 E->Value = (unsigned int)Record[Idx++];
1398 SourceRange Range = ReadSourceRange(Record, Idx);
1399 E->Loc = Range.getBegin();
1400 E->RParen = Range.getEnd();
1401 E->QueriedType = GetTypeSourceInfo(Record, Idx);
1402}
1403
John Wiegley55262202011-04-25 06:54:41 +00001404void ASTStmtReader::VisitExpressionTraitExpr(ExpressionTraitExpr *E) {
1405 VisitExpr(E);
1406 E->ET = (ExpressionTrait)Record[Idx++];
1407 E->Value = (bool)Record[Idx++];
1408 SourceRange Range = ReadSourceRange(Record, Idx);
1409 E->QueriedExpression = Reader.ReadSubExpr();
1410 E->Loc = Range.getBegin();
1411 E->RParen = Range.getEnd();
1412}
1413
Sebastian Redl6b219d02010-09-10 20:55:54 +00001414void ASTStmtReader::VisitCXXNoexceptExpr(CXXNoexceptExpr *E) {
1415 VisitExpr(E);
Sebastian Redl5221d8f2010-09-10 22:34:40 +00001416 E->Value = (bool)Record[Idx++];
Sebastian Redlc3632732010-10-05 15:59:54 +00001417 E->Range = ReadSourceRange(Record, Idx);
Sebastian Redl5221d8f2010-09-10 22:34:40 +00001418 E->Operand = Reader.ReadSubExpr();
Sebastian Redl6b219d02010-09-10 20:55:54 +00001419}
1420
Douglas Gregorbe230c32011-01-03 17:17:50 +00001421void ASTStmtReader::VisitPackExpansionExpr(PackExpansionExpr *E) {
1422 VisitExpr(E);
1423 E->EllipsisLoc = ReadSourceLocation(Record, Idx);
Douglas Gregor67fd1252011-01-14 21:20:45 +00001424 E->NumExpansions = Record[Idx++];
Douglas Gregorbe230c32011-01-03 17:17:50 +00001425 E->Pattern = Reader.ReadSubExpr();
1426}
1427
Douglas Gregoree8aff02011-01-04 17:33:58 +00001428void ASTStmtReader::VisitSizeOfPackExpr(SizeOfPackExpr *E) {
1429 VisitExpr(E);
1430 E->OperatorLoc = ReadSourceLocation(Record, Idx);
1431 E->PackLoc = ReadSourceLocation(Record, Idx);
1432 E->RParenLoc = ReadSourceLocation(Record, Idx);
1433 E->Length = Record[Idx++];
Douglas Gregor409448c2011-07-21 22:35:25 +00001434 E->Pack = ReadDeclAs<NamedDecl>(Record, Idx);
Douglas Gregoree8aff02011-01-04 17:33:58 +00001435}
1436
John McCall7110fd62011-07-15 07:00:14 +00001437void ASTStmtReader::VisitSubstNonTypeTemplateParmExpr(
1438 SubstNonTypeTemplateParmExpr *E) {
1439 VisitExpr(E);
Douglas Gregor409448c2011-07-21 22:35:25 +00001440 E->Param = ReadDeclAs<NonTypeTemplateParmDecl>(Record, Idx);
John McCall7110fd62011-07-15 07:00:14 +00001441 E->NameLoc = ReadSourceLocation(Record, Idx);
1442 E->Replacement = Reader.ReadSubExpr();
1443}
1444
Douglas Gregorc7793c72011-01-15 01:15:58 +00001445void ASTStmtReader::VisitSubstNonTypeTemplateParmPackExpr(
1446 SubstNonTypeTemplateParmPackExpr *E) {
1447 VisitExpr(E);
Douglas Gregor409448c2011-07-21 22:35:25 +00001448 E->Param = ReadDeclAs<NonTypeTemplateParmDecl>(Record, Idx);
Douglas Gregorc7793c72011-01-15 01:15:58 +00001449 TemplateArgument ArgPack = Reader.ReadTemplateArgument(F, Record, Idx);
1450 if (ArgPack.getKind() != TemplateArgument::Pack)
1451 return;
1452
1453 E->Arguments = ArgPack.pack_begin();
1454 E->NumArguments = ArgPack.pack_size();
1455 E->NameLoc = ReadSourceLocation(Record, Idx);
1456}
1457
Douglas Gregor03e80032011-06-21 17:03:29 +00001458void ASTStmtReader::VisitMaterializeTemporaryExpr(MaterializeTemporaryExpr *E) {
1459 VisitExpr(E);
1460 E->Temporary = Reader.ReadSubExpr();
1461}
1462
John McCall7cd7d1a2010-11-15 23:31:06 +00001463void ASTStmtReader::VisitOpaqueValueExpr(OpaqueValueExpr *E) {
1464 VisitExpr(E);
Argyrios Kyrtzidis8bc27822011-12-03 03:49:52 +00001465 E->SourceExpr = Reader.ReadSubExpr();
Douglas Gregorb608b982011-01-28 02:26:04 +00001466 E->Loc = ReadSourceLocation(Record, Idx);
John McCall7cd7d1a2010-11-15 23:31:06 +00001467}
1468
Peter Collingbournee08ce652011-02-09 21:07:24 +00001469//===----------------------------------------------------------------------===//
John McCall7110fd62011-07-15 07:00:14 +00001470// Microsoft Expressions and Statements
1471//===----------------------------------------------------------------------===//
1472void ASTStmtReader::VisitCXXUuidofExpr(CXXUuidofExpr *E) {
1473 VisitExpr(E);
1474 E->setSourceRange(ReadSourceRange(Record, Idx));
1475 if (E->isTypeOperand()) { // __uuidof(ComType)
1476 E->setTypeOperandSourceInfo(
1477 GetTypeSourceInfo(Record, Idx));
1478 return;
1479 }
1480
1481 // __uuidof(expr)
1482 E->setExprOperand(Reader.ReadSubExpr());
1483}
1484
1485void ASTStmtReader::VisitSEHExceptStmt(SEHExceptStmt *S) {
1486 VisitStmt(S);
1487 S->Loc = ReadSourceLocation(Record, Idx);
1488 S->Children[SEHExceptStmt::FILTER_EXPR] = Reader.ReadSubStmt();
1489 S->Children[SEHExceptStmt::BLOCK] = Reader.ReadSubStmt();
1490}
1491
1492void ASTStmtReader::VisitSEHFinallyStmt(SEHFinallyStmt *S) {
1493 VisitStmt(S);
1494 S->Loc = ReadSourceLocation(Record, Idx);
1495 S->Block = Reader.ReadSubStmt();
1496}
1497
1498void ASTStmtReader::VisitSEHTryStmt(SEHTryStmt *S) {
1499 VisitStmt(S);
1500 S->IsCXXTry = Record[Idx++];
1501 S->TryLoc = ReadSourceLocation(Record, Idx);
1502 S->Children[SEHTryStmt::TRY] = Reader.ReadSubStmt();
1503 S->Children[SEHTryStmt::HANDLER] = Reader.ReadSubStmt();
1504}
1505
1506//===----------------------------------------------------------------------===//
Peter Collingbournee08ce652011-02-09 21:07:24 +00001507// CUDA Expressions and Statements
1508//===----------------------------------------------------------------------===//
1509
1510void ASTStmtReader::VisitCUDAKernelCallExpr(CUDAKernelCallExpr *E) {
1511 VisitCallExpr(E);
1512 E->setConfig(cast<CallExpr>(Reader.ReadSubExpr()));
1513}
1514
John McCall7110fd62011-07-15 07:00:14 +00001515//===----------------------------------------------------------------------===//
1516// OpenCL Expressions and Statements.
1517//===----------------------------------------------------------------------===//
1518void ASTStmtReader::VisitAsTypeExpr(AsTypeExpr *E) {
1519 VisitExpr(E);
1520 E->BuiltinLoc = ReadSourceLocation(Record, Idx);
1521 E->RParenLoc = ReadSourceLocation(Record, Idx);
1522 E->SrcExpr = Reader.ReadSubExpr();
1523}
1524
1525//===----------------------------------------------------------------------===//
1526// ASTReader Implementation
1527//===----------------------------------------------------------------------===//
1528
Douglas Gregor1a4761e2011-11-30 23:21:26 +00001529Stmt *ASTReader::ReadStmt(ModuleFile &F) {
Argyrios Kyrtzidis919e6932010-06-28 22:28:35 +00001530 switch (ReadingKind) {
1531 case Read_Decl:
1532 case Read_Type:
Sebastian Redlc3632732010-10-05 15:59:54 +00001533 return ReadStmtFromStream(F);
Argyrios Kyrtzidis919e6932010-06-28 22:28:35 +00001534 case Read_Stmt:
Argyrios Kyrtzidisd98a2ab2010-06-29 22:46:25 +00001535 return ReadSubStmt();
Argyrios Kyrtzidis919e6932010-06-28 22:28:35 +00001536 }
1537
1538 llvm_unreachable("ReadingKind not set ?");
Argyrios Kyrtzidis919e6932010-06-28 22:28:35 +00001539}
1540
Douglas Gregor1a4761e2011-11-30 23:21:26 +00001541Expr *ASTReader::ReadExpr(ModuleFile &F) {
Sebastian Redlc3632732010-10-05 15:59:54 +00001542 return cast_or_null<Expr>(ReadStmt(F));
Argyrios Kyrtzidis919e6932010-06-28 22:28:35 +00001543}
Chris Lattner030854b2010-05-09 06:40:08 +00001544
Sebastian Redlc43b54c2010-08-18 23:56:43 +00001545Expr *ASTReader::ReadSubExpr() {
Argyrios Kyrtzidisd98a2ab2010-06-29 22:46:25 +00001546 return cast_or_null<Expr>(ReadSubStmt());
1547}
1548
Chris Lattner52e97d12009-04-27 05:41:06 +00001549// Within the bitstream, expressions are stored in Reverse Polish
1550// Notation, with each of the subexpressions preceding the
Argyrios Kyrtzidis919e6932010-06-28 22:28:35 +00001551// expression they are stored in. Subexpressions are stored from last to first.
1552// To evaluate expressions, we continue reading expressions and placing them on
1553// the stack, with expressions having operands removing those operands from the
Chris Lattner52e97d12009-04-27 05:41:06 +00001554// stack. Evaluation terminates when we see a STMT_STOP record, and
1555// the single remaining expression on the stack is our result.
Douglas Gregor1a4761e2011-11-30 23:21:26 +00001556Stmt *ASTReader::ReadStmtFromStream(ModuleFile &F) {
Argyrios Kyrtzidis919e6932010-06-28 22:28:35 +00001557
1558 ReadingKindTracker ReadingKind(Read_Stmt, *this);
Sebastian Redlc3632732010-10-05 15:59:54 +00001559 llvm::BitstreamCursor &Cursor = F.DeclsCursor;
Argyrios Kyrtzidise6f08682011-10-21 23:02:28 +00001560
1561 // Map of offset to previously deserialized stmt. The offset points
1562 /// just after the stmt record.
1563 llvm::DenseMap<uint64_t, Stmt *> StmtEntries;
Sebastian Redlc3632732010-10-05 15:59:54 +00001564
Argyrios Kyrtzidis919e6932010-06-28 22:28:35 +00001565#ifndef NDEBUG
1566 unsigned PrevNumStmts = StmtStack.size();
1567#endif
1568
Chris Lattner4c6f9522009-04-27 05:14:47 +00001569 RecordData Record;
1570 unsigned Idx;
Sebastian Redlc3632732010-10-05 15:59:54 +00001571 ASTStmtReader Reader(*this, F, Cursor, Record, Idx);
Chris Lattner4c6f9522009-04-27 05:14:47 +00001572 Stmt::EmptyShell Empty;
1573
1574 while (true) {
Chris Lattner52e97d12009-04-27 05:41:06 +00001575 unsigned Code = Cursor.ReadCode();
Chris Lattner4c6f9522009-04-27 05:14:47 +00001576 if (Code == llvm::bitc::END_BLOCK) {
Chris Lattner52e97d12009-04-27 05:41:06 +00001577 if (Cursor.ReadBlockEnd()) {
Sebastian Redl3c7f4132010-08-18 23:57:06 +00001578 Error("error at end of block in AST file");
Chris Lattner4c6f9522009-04-27 05:14:47 +00001579 return 0;
1580 }
1581 break;
1582 }
1583
1584 if (Code == llvm::bitc::ENTER_SUBBLOCK) {
1585 // No known subblocks, always skip them.
Chris Lattner52e97d12009-04-27 05:41:06 +00001586 Cursor.ReadSubBlockID();
1587 if (Cursor.SkipBlock()) {
Sebastian Redl3c7f4132010-08-18 23:57:06 +00001588 Error("malformed block record in AST file");
Chris Lattner4c6f9522009-04-27 05:14:47 +00001589 return 0;
1590 }
1591 continue;
1592 }
1593
1594 if (Code == llvm::bitc::DEFINE_ABBREV) {
Chris Lattner52e97d12009-04-27 05:41:06 +00001595 Cursor.ReadAbbrevRecord();
Chris Lattner4c6f9522009-04-27 05:14:47 +00001596 continue;
1597 }
1598
1599 Stmt *S = 0;
1600 Idx = 0;
1601 Record.clear();
1602 bool Finished = false;
Argyrios Kyrtzidise6f08682011-10-21 23:02:28 +00001603 bool IsStmtReference = false;
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001604 switch ((StmtCode)Cursor.ReadRecord(Code, Record)) {
1605 case STMT_STOP:
Chris Lattner4c6f9522009-04-27 05:14:47 +00001606 Finished = true;
1607 break;
1608
Argyrios Kyrtzidise6f08682011-10-21 23:02:28 +00001609 case STMT_REF_PTR:
1610 IsStmtReference = true;
1611 assert(StmtEntries.find(Record[0]) != StmtEntries.end() &&
1612 "No stmt was recorded for this offset reference!");
1613 S = StmtEntries[Record[Idx++]];
1614 break;
1615
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001616 case STMT_NULL_PTR:
Mike Stump1eb44332009-09-09 15:08:12 +00001617 S = 0;
Chris Lattner4c6f9522009-04-27 05:14:47 +00001618 break;
1619
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001620 case STMT_NULL:
Chris Lattner4c6f9522009-04-27 05:14:47 +00001621 S = new (Context) NullStmt(Empty);
1622 break;
1623
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001624 case STMT_COMPOUND:
Chris Lattner4c6f9522009-04-27 05:14:47 +00001625 S = new (Context) CompoundStmt(Empty);
1626 break;
1627
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001628 case STMT_CASE:
Chris Lattner4c6f9522009-04-27 05:14:47 +00001629 S = new (Context) CaseStmt(Empty);
1630 break;
1631
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001632 case STMT_DEFAULT:
Chris Lattner4c6f9522009-04-27 05:14:47 +00001633 S = new (Context) DefaultStmt(Empty);
1634 break;
1635
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001636 case STMT_LABEL:
Chris Lattner4c6f9522009-04-27 05:14:47 +00001637 S = new (Context) LabelStmt(Empty);
1638 break;
1639
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001640 case STMT_IF:
Chris Lattner4c6f9522009-04-27 05:14:47 +00001641 S = new (Context) IfStmt(Empty);
1642 break;
1643
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001644 case STMT_SWITCH:
Chris Lattner4c6f9522009-04-27 05:14:47 +00001645 S = new (Context) SwitchStmt(Empty);
1646 break;
1647
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001648 case STMT_WHILE:
Chris Lattner4c6f9522009-04-27 05:14:47 +00001649 S = new (Context) WhileStmt(Empty);
1650 break;
1651
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001652 case STMT_DO:
Chris Lattner4c6f9522009-04-27 05:14:47 +00001653 S = new (Context) DoStmt(Empty);
1654 break;
Mike Stump1eb44332009-09-09 15:08:12 +00001655
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001656 case STMT_FOR:
Chris Lattner4c6f9522009-04-27 05:14:47 +00001657 S = new (Context) ForStmt(Empty);
1658 break;
1659
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001660 case STMT_GOTO:
Chris Lattner4c6f9522009-04-27 05:14:47 +00001661 S = new (Context) GotoStmt(Empty);
1662 break;
Mike Stump1eb44332009-09-09 15:08:12 +00001663
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001664 case STMT_INDIRECT_GOTO:
Chris Lattner4c6f9522009-04-27 05:14:47 +00001665 S = new (Context) IndirectGotoStmt(Empty);
1666 break;
1667
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001668 case STMT_CONTINUE:
Chris Lattner4c6f9522009-04-27 05:14:47 +00001669 S = new (Context) ContinueStmt(Empty);
1670 break;
1671
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001672 case STMT_BREAK:
Chris Lattner4c6f9522009-04-27 05:14:47 +00001673 S = new (Context) BreakStmt(Empty);
1674 break;
1675
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001676 case STMT_RETURN:
Chris Lattner4c6f9522009-04-27 05:14:47 +00001677 S = new (Context) ReturnStmt(Empty);
1678 break;
1679
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001680 case STMT_DECL:
Chris Lattner4c6f9522009-04-27 05:14:47 +00001681 S = new (Context) DeclStmt(Empty);
1682 break;
1683
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001684 case STMT_ASM:
Chris Lattner4c6f9522009-04-27 05:14:47 +00001685 S = new (Context) AsmStmt(Empty);
1686 break;
1687
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001688 case EXPR_PREDEFINED:
Chris Lattner4c6f9522009-04-27 05:14:47 +00001689 S = new (Context) PredefinedExpr(Empty);
1690 break;
Mike Stump1eb44332009-09-09 15:08:12 +00001691
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001692 case EXPR_DECL_REF:
Chandler Carruth3aa81402011-05-01 23:48:14 +00001693 S = DeclRefExpr::CreateEmpty(
Douglas Gregor35942772011-09-09 21:34:22 +00001694 Context,
Chandler Carruth3aa81402011-05-01 23:48:14 +00001695 /*HasQualifier=*/Record[ASTStmtReader::NumExprFields],
1696 /*HasFoundDecl=*/Record[ASTStmtReader::NumExprFields + 1],
Abramo Bagnarae4b92762012-01-27 09:46:47 +00001697 /*HasTemplateKWAndArgsInfo=*/Record[ASTStmtReader::NumExprFields + 2],
Chandler Carruth3aa81402011-05-01 23:48:14 +00001698 /*NumTemplateArgs=*/Record[ASTStmtReader::NumExprFields + 2] ?
John McCallf4b88a42012-03-10 09:33:50 +00001699 Record[ASTStmtReader::NumExprFields + 5] : 0);
Chris Lattner4c6f9522009-04-27 05:14:47 +00001700 break;
Mike Stump1eb44332009-09-09 15:08:12 +00001701
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001702 case EXPR_INTEGER_LITERAL:
Douglas Gregor35942772011-09-09 21:34:22 +00001703 S = IntegerLiteral::Create(Context, Empty);
Chris Lattner4c6f9522009-04-27 05:14:47 +00001704 break;
Mike Stump1eb44332009-09-09 15:08:12 +00001705
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001706 case EXPR_FLOATING_LITERAL:
Douglas Gregor35942772011-09-09 21:34:22 +00001707 S = FloatingLiteral::Create(Context, Empty);
Chris Lattner4c6f9522009-04-27 05:14:47 +00001708 break;
Mike Stump1eb44332009-09-09 15:08:12 +00001709
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001710 case EXPR_IMAGINARY_LITERAL:
Chris Lattner4c6f9522009-04-27 05:14:47 +00001711 S = new (Context) ImaginaryLiteral(Empty);
1712 break;
1713
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001714 case EXPR_STRING_LITERAL:
Douglas Gregor35942772011-09-09 21:34:22 +00001715 S = StringLiteral::CreateEmpty(Context,
Sebastian Redl60adf4a2010-08-18 23:56:52 +00001716 Record[ASTStmtReader::NumExprFields + 1]);
Chris Lattner4c6f9522009-04-27 05:14:47 +00001717 break;
1718
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001719 case EXPR_CHARACTER_LITERAL:
Chris Lattner4c6f9522009-04-27 05:14:47 +00001720 S = new (Context) CharacterLiteral(Empty);
1721 break;
1722
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001723 case EXPR_PAREN:
Chris Lattner4c6f9522009-04-27 05:14:47 +00001724 S = new (Context) ParenExpr(Empty);
1725 break;
1726
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001727 case EXPR_PAREN_LIST:
Argyrios Kyrtzidis37bdfe22010-06-30 08:49:18 +00001728 S = new (Context) ParenListExpr(Empty);
1729 break;
1730
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001731 case EXPR_UNARY_OPERATOR:
Chris Lattner4c6f9522009-04-27 05:14:47 +00001732 S = new (Context) UnaryOperator(Empty);
1733 break;
1734
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001735 case EXPR_OFFSETOF:
Douglas Gregor35942772011-09-09 21:34:22 +00001736 S = OffsetOfExpr::CreateEmpty(Context,
Sebastian Redl60adf4a2010-08-18 23:56:52 +00001737 Record[ASTStmtReader::NumExprFields],
1738 Record[ASTStmtReader::NumExprFields + 1]);
Douglas Gregor8ecdb652010-04-28 22:16:22 +00001739 break;
1740
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001741 case EXPR_SIZEOF_ALIGN_OF:
Peter Collingbournef4e3cfb2011-03-11 19:24:49 +00001742 S = new (Context) UnaryExprOrTypeTraitExpr(Empty);
Chris Lattner4c6f9522009-04-27 05:14:47 +00001743 break;
1744
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001745 case EXPR_ARRAY_SUBSCRIPT:
Chris Lattner4c6f9522009-04-27 05:14:47 +00001746 S = new (Context) ArraySubscriptExpr(Empty);
1747 break;
1748
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001749 case EXPR_CALL:
Douglas Gregor35942772011-09-09 21:34:22 +00001750 S = new (Context) CallExpr(Context, Stmt::CallExprClass, Empty);
Chris Lattner4c6f9522009-04-27 05:14:47 +00001751 break;
1752
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001753 case EXPR_MEMBER: {
Argyrios Kyrtzidis663e3802010-07-08 13:09:47 +00001754 // We load everything here and fully initialize it at creation.
1755 // That way we can use MemberExpr::Create and don't have to duplicate its
1756 // logic with a MemberExpr::CreateEmpty.
1757
1758 assert(Idx == 0);
Douglas Gregor40d96a62011-02-28 21:54:11 +00001759 NestedNameSpecifierLoc QualifierLoc;
Argyrios Kyrtzidis663e3802010-07-08 13:09:47 +00001760 if (Record[Idx++]) { // HasQualifier.
Douglas Gregor40d96a62011-02-28 21:54:11 +00001761 QualifierLoc = ReadNestedNameSpecifierLoc(F, Record, Idx);
Argyrios Kyrtzidis663e3802010-07-08 13:09:47 +00001762 }
1763
Abramo Bagnarae4b92762012-01-27 09:46:47 +00001764 SourceLocation TemplateKWLoc;
Argyrios Kyrtzidis663e3802010-07-08 13:09:47 +00001765 TemplateArgumentListInfo ArgInfo;
Abramo Bagnarae4b92762012-01-27 09:46:47 +00001766 bool HasTemplateKWAndArgsInfo = Record[Idx++];
1767 if (HasTemplateKWAndArgsInfo) {
1768 TemplateKWLoc = ReadSourceLocation(F, Record, Idx);
Douglas Gregordef03542011-02-04 12:01:24 +00001769 unsigned NumTemplateArgs = Record[Idx++];
Sebastian Redlc3632732010-10-05 15:59:54 +00001770 ArgInfo.setLAngleLoc(ReadSourceLocation(F, Record, Idx));
1771 ArgInfo.setRAngleLoc(ReadSourceLocation(F, Record, Idx));
Argyrios Kyrtzidis663e3802010-07-08 13:09:47 +00001772 for (unsigned i = 0; i != NumTemplateArgs; ++i)
Sebastian Redlc3632732010-10-05 15:59:54 +00001773 ArgInfo.addArgument(ReadTemplateArgumentLoc(F, Record, Idx));
Argyrios Kyrtzidis663e3802010-07-08 13:09:47 +00001774 }
Abramo Bagnara7cc58b42011-10-05 07:56:41 +00001775
1776 bool HadMultipleCandidates = Record[Idx++];
1777
Douglas Gregor409448c2011-07-21 22:35:25 +00001778 NamedDecl *FoundD = ReadDeclAs<NamedDecl>(F, Record, Idx);
Argyrios Kyrtzidis663e3802010-07-08 13:09:47 +00001779 AccessSpecifier AS = (AccessSpecifier)Record[Idx++];
1780 DeclAccessPair FoundDecl = DeclAccessPair::make(FoundD, AS);
1781
Douglas Gregor393f2492011-07-22 00:38:23 +00001782 QualType T = readType(F, Record, Idx);
John McCallf89e55a2010-11-18 06:31:45 +00001783 ExprValueKind VK = static_cast<ExprValueKind>(Record[Idx++]);
1784 ExprObjectKind OK = static_cast<ExprObjectKind>(Record[Idx++]);
Argyrios Kyrtzidis663e3802010-07-08 13:09:47 +00001785 Expr *Base = ReadSubExpr();
Douglas Gregor409448c2011-07-21 22:35:25 +00001786 ValueDecl *MemberD = ReadDeclAs<ValueDecl>(F, Record, Idx);
Sebastian Redlc3632732010-10-05 15:59:54 +00001787 SourceLocation MemberLoc = ReadSourceLocation(F, Record, Idx);
Abramo Bagnara25777432010-08-11 22:01:17 +00001788 DeclarationNameInfo MemberNameInfo(MemberD->getDeclName(), MemberLoc);
Argyrios Kyrtzidis663e3802010-07-08 13:09:47 +00001789 bool IsArrow = Record[Idx++];
1790
Douglas Gregor35942772011-09-09 21:34:22 +00001791 S = MemberExpr::Create(Context, Base, IsArrow, QualifierLoc,
Abramo Bagnarae4b92762012-01-27 09:46:47 +00001792 TemplateKWLoc, MemberD, FoundDecl, MemberNameInfo,
1793 HasTemplateKWAndArgsInfo ? &ArgInfo : 0,
1794 T, VK, OK);
Argyrios Kyrtzidis40451072010-10-15 18:21:24 +00001795 ReadDeclarationNameLoc(F, cast<MemberExpr>(S)->MemberDNLoc,
1796 MemberD->getDeclName(), Record, Idx);
Abramo Bagnara7cc58b42011-10-05 07:56:41 +00001797 if (HadMultipleCandidates)
1798 cast<MemberExpr>(S)->setHadMultipleCandidates(true);
Chris Lattner4c6f9522009-04-27 05:14:47 +00001799 break;
Argyrios Kyrtzidis663e3802010-07-08 13:09:47 +00001800 }
Chris Lattner4c6f9522009-04-27 05:14:47 +00001801
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001802 case EXPR_BINARY_OPERATOR:
Chris Lattner4c6f9522009-04-27 05:14:47 +00001803 S = new (Context) BinaryOperator(Empty);
1804 break;
1805
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001806 case EXPR_COMPOUND_ASSIGN_OPERATOR:
Chris Lattner4c6f9522009-04-27 05:14:47 +00001807 S = new (Context) CompoundAssignOperator(Empty);
1808 break;
1809
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001810 case EXPR_CONDITIONAL_OPERATOR:
Chris Lattner4c6f9522009-04-27 05:14:47 +00001811 S = new (Context) ConditionalOperator(Empty);
1812 break;
1813
John McCall56ca35d2011-02-17 10:25:35 +00001814 case EXPR_BINARY_CONDITIONAL_OPERATOR:
1815 S = new (Context) BinaryConditionalOperator(Empty);
1816 break;
1817
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001818 case EXPR_IMPLICIT_CAST:
Douglas Gregor35942772011-09-09 21:34:22 +00001819 S = ImplicitCastExpr::CreateEmpty(Context,
Sebastian Redl60adf4a2010-08-18 23:56:52 +00001820 /*PathSize*/ Record[ASTStmtReader::NumExprFields]);
Chris Lattner4c6f9522009-04-27 05:14:47 +00001821 break;
1822
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001823 case EXPR_CSTYLE_CAST:
Douglas Gregor35942772011-09-09 21:34:22 +00001824 S = CStyleCastExpr::CreateEmpty(Context,
Sebastian Redl60adf4a2010-08-18 23:56:52 +00001825 /*PathSize*/ Record[ASTStmtReader::NumExprFields]);
Chris Lattner4c6f9522009-04-27 05:14:47 +00001826 break;
1827
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001828 case EXPR_COMPOUND_LITERAL:
Chris Lattner4c6f9522009-04-27 05:14:47 +00001829 S = new (Context) CompoundLiteralExpr(Empty);
1830 break;
1831
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001832 case EXPR_EXT_VECTOR_ELEMENT:
Chris Lattner4c6f9522009-04-27 05:14:47 +00001833 S = new (Context) ExtVectorElementExpr(Empty);
1834 break;
1835
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001836 case EXPR_INIT_LIST:
Douglas Gregor35942772011-09-09 21:34:22 +00001837 S = new (Context) InitListExpr(getContext(), Empty);
Chris Lattner4c6f9522009-04-27 05:14:47 +00001838 break;
1839
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001840 case EXPR_DESIGNATED_INIT:
Douglas Gregor35942772011-09-09 21:34:22 +00001841 S = DesignatedInitExpr::CreateEmpty(Context,
Sebastian Redl60adf4a2010-08-18 23:56:52 +00001842 Record[ASTStmtReader::NumExprFields] - 1);
Mike Stump1eb44332009-09-09 15:08:12 +00001843
Chris Lattner4c6f9522009-04-27 05:14:47 +00001844 break;
1845
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001846 case EXPR_IMPLICIT_VALUE_INIT:
Chris Lattner4c6f9522009-04-27 05:14:47 +00001847 S = new (Context) ImplicitValueInitExpr(Empty);
1848 break;
1849
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001850 case EXPR_VA_ARG:
Chris Lattner4c6f9522009-04-27 05:14:47 +00001851 S = new (Context) VAArgExpr(Empty);
1852 break;
1853
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001854 case EXPR_ADDR_LABEL:
Chris Lattner4c6f9522009-04-27 05:14:47 +00001855 S = new (Context) AddrLabelExpr(Empty);
1856 break;
1857
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001858 case EXPR_STMT:
Chris Lattner4c6f9522009-04-27 05:14:47 +00001859 S = new (Context) StmtExpr(Empty);
1860 break;
1861
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001862 case EXPR_CHOOSE:
Chris Lattner4c6f9522009-04-27 05:14:47 +00001863 S = new (Context) ChooseExpr(Empty);
1864 break;
1865
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001866 case EXPR_GNU_NULL:
Chris Lattner4c6f9522009-04-27 05:14:47 +00001867 S = new (Context) GNUNullExpr(Empty);
1868 break;
1869
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001870 case EXPR_SHUFFLE_VECTOR:
Chris Lattner4c6f9522009-04-27 05:14:47 +00001871 S = new (Context) ShuffleVectorExpr(Empty);
1872 break;
Mike Stump1eb44332009-09-09 15:08:12 +00001873
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001874 case EXPR_BLOCK:
Chris Lattner4c6f9522009-04-27 05:14:47 +00001875 S = new (Context) BlockExpr(Empty);
1876 break;
1877
Peter Collingbournef111d932011-04-15 00:35:48 +00001878 case EXPR_GENERIC_SELECTION:
1879 S = new (Context) GenericSelectionExpr(Empty);
1880 break;
1881
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001882 case EXPR_OBJC_STRING_LITERAL:
Chris Lattner4c6f9522009-04-27 05:14:47 +00001883 S = new (Context) ObjCStringLiteral(Empty);
1884 break;
Ted Kremenekebcb57a2012-03-06 20:05:56 +00001885 case EXPR_OBJC_NUMERIC_LITERAL:
1886 S = new (Context) ObjCNumericLiteral(Empty);
1887 break;
1888 case EXPR_OBJC_ARRAY_LITERAL:
1889 S = ObjCArrayLiteral::CreateEmpty(Context,
1890 Record[ASTStmtReader::NumExprFields]);
1891 break;
1892 case EXPR_OBJC_DICTIONARY_LITERAL:
1893 S = ObjCDictionaryLiteral::CreateEmpty(Context,
1894 Record[ASTStmtReader::NumExprFields],
1895 Record[ASTStmtReader::NumExprFields + 1]);
1896 break;
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001897 case EXPR_OBJC_ENCODE:
Chris Lattner4c6f9522009-04-27 05:14:47 +00001898 S = new (Context) ObjCEncodeExpr(Empty);
1899 break;
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001900 case EXPR_OBJC_SELECTOR_EXPR:
Chris Lattner4c6f9522009-04-27 05:14:47 +00001901 S = new (Context) ObjCSelectorExpr(Empty);
1902 break;
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001903 case EXPR_OBJC_PROTOCOL_EXPR:
Chris Lattner4c6f9522009-04-27 05:14:47 +00001904 S = new (Context) ObjCProtocolExpr(Empty);
1905 break;
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001906 case EXPR_OBJC_IVAR_REF_EXPR:
Chris Lattner4c6f9522009-04-27 05:14:47 +00001907 S = new (Context) ObjCIvarRefExpr(Empty);
1908 break;
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001909 case EXPR_OBJC_PROPERTY_REF_EXPR:
Chris Lattner4c6f9522009-04-27 05:14:47 +00001910 S = new (Context) ObjCPropertyRefExpr(Empty);
1911 break;
Ted Kremenekebcb57a2012-03-06 20:05:56 +00001912 case EXPR_OBJC_SUBSCRIPT_REF_EXPR:
1913 S = new (Context) ObjCSubscriptRefExpr(Empty);
1914 break;
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001915 case EXPR_OBJC_KVC_REF_EXPR:
John McCall12f78a62010-12-02 01:19:52 +00001916 llvm_unreachable("mismatching AST file");
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001917 case EXPR_OBJC_MESSAGE_EXPR:
Douglas Gregor35942772011-09-09 21:34:22 +00001918 S = ObjCMessageExpr::CreateEmpty(Context,
Argyrios Kyrtzidis20718082011-10-03 06:36:51 +00001919 Record[ASTStmtReader::NumExprFields],
1920 Record[ASTStmtReader::NumExprFields + 1]);
Chris Lattner4c6f9522009-04-27 05:14:47 +00001921 break;
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001922 case EXPR_OBJC_ISA:
Steve Narofff242b1b2009-07-24 17:54:45 +00001923 S = new (Context) ObjCIsaExpr(Empty);
1924 break;
John McCallf85e1932011-06-15 23:02:42 +00001925 case EXPR_OBJC_INDIRECT_COPY_RESTORE:
1926 S = new (Context) ObjCIndirectCopyRestoreExpr(Empty);
1927 break;
1928 case EXPR_OBJC_BRIDGED_CAST:
1929 S = new (Context) ObjCBridgedCastExpr(Empty);
1930 break;
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001931 case STMT_OBJC_FOR_COLLECTION:
Chris Lattner4c6f9522009-04-27 05:14:47 +00001932 S = new (Context) ObjCForCollectionStmt(Empty);
1933 break;
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001934 case STMT_OBJC_CATCH:
Chris Lattner4c6f9522009-04-27 05:14:47 +00001935 S = new (Context) ObjCAtCatchStmt(Empty);
1936 break;
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001937 case STMT_OBJC_FINALLY:
Chris Lattner4c6f9522009-04-27 05:14:47 +00001938 S = new (Context) ObjCAtFinallyStmt(Empty);
1939 break;
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001940 case STMT_OBJC_AT_TRY:
Douglas Gregor35942772011-09-09 21:34:22 +00001941 S = ObjCAtTryStmt::CreateEmpty(Context,
Sebastian Redl60adf4a2010-08-18 23:56:52 +00001942 Record[ASTStmtReader::NumStmtFields],
1943 Record[ASTStmtReader::NumStmtFields + 1]);
Chris Lattner4c6f9522009-04-27 05:14:47 +00001944 break;
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001945 case STMT_OBJC_AT_SYNCHRONIZED:
Chris Lattner4c6f9522009-04-27 05:14:47 +00001946 S = new (Context) ObjCAtSynchronizedStmt(Empty);
1947 break;
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001948 case STMT_OBJC_AT_THROW:
Chris Lattner4c6f9522009-04-27 05:14:47 +00001949 S = new (Context) ObjCAtThrowStmt(Empty);
1950 break;
John McCallf85e1932011-06-15 23:02:42 +00001951 case STMT_OBJC_AUTORELEASE_POOL:
1952 S = new (Context) ObjCAutoreleasePoolStmt(Empty);
1953 break;
Ted Kremenekebcb57a2012-03-06 20:05:56 +00001954 case EXPR_OBJC_BOOL_LITERAL:
1955 S = new (Context) ObjCBoolLiteralExpr(Empty);
1956 break;
John McCall7110fd62011-07-15 07:00:14 +00001957 case STMT_SEH_EXCEPT:
1958 S = new (Context) SEHExceptStmt(Empty);
1959 break;
1960 case STMT_SEH_FINALLY:
1961 S = new (Context) SEHFinallyStmt(Empty);
1962 break;
1963 case STMT_SEH_TRY:
1964 S = new (Context) SEHTryStmt(Empty);
1965 break;
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001966 case STMT_CXX_CATCH:
Argyrios Kyrtzidis7cb45e32010-07-22 16:03:56 +00001967 S = new (Context) CXXCatchStmt(Empty);
1968 break;
1969
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001970 case STMT_CXX_TRY:
Douglas Gregor35942772011-09-09 21:34:22 +00001971 S = CXXTryStmt::Create(Context, Empty,
Sebastian Redl60adf4a2010-08-18 23:56:52 +00001972 /*NumHandlers=*/Record[ASTStmtReader::NumStmtFields]);
Argyrios Kyrtzidis7cb45e32010-07-22 16:03:56 +00001973 break;
1974
Richard Smithad762fc2011-04-14 22:09:26 +00001975 case STMT_CXX_FOR_RANGE:
1976 S = new (Context) CXXForRangeStmt(Empty);
1977 break;
1978
Douglas Gregorba0513d2011-10-25 01:33:02 +00001979 case STMT_MS_DEPENDENT_EXISTS:
1980 S = new (Context) MSDependentExistsStmt(SourceLocation(), true,
1981 NestedNameSpecifierLoc(),
1982 DeclarationNameInfo(),
1983 0);
1984 break;
1985
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001986 case EXPR_CXX_OPERATOR_CALL:
Douglas Gregor35942772011-09-09 21:34:22 +00001987 S = new (Context) CXXOperatorCallExpr(Context, Empty);
Argyrios Kyrtzidisba0a9002009-07-14 03:19:21 +00001988 break;
Chris Lattner1817bd42010-05-09 05:36:05 +00001989
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001990 case EXPR_CXX_MEMBER_CALL:
Douglas Gregor35942772011-09-09 21:34:22 +00001991 S = new (Context) CXXMemberCallExpr(Context, Empty);
Chris Lattner1817bd42010-05-09 05:36:05 +00001992 break;
Douglas Gregor39da0b82009-09-09 23:08:42 +00001993
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001994 case EXPR_CXX_CONSTRUCT:
Argyrios Kyrtzidis6d00c132010-07-10 11:46:15 +00001995 S = new (Context) CXXConstructExpr(Empty);
1996 break;
1997
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001998 case EXPR_CXX_TEMPORARY_OBJECT:
Argyrios Kyrtzidis6d00c132010-07-10 11:46:15 +00001999 S = new (Context) CXXTemporaryObjectExpr(Empty);
Douglas Gregor39da0b82009-09-09 23:08:42 +00002000 break;
Sam Weinigce757a72010-01-16 21:21:01 +00002001
Sebastian Redl8538e8d2010-08-18 23:57:32 +00002002 case EXPR_CXX_STATIC_CAST:
Douglas Gregor35942772011-09-09 21:34:22 +00002003 S = CXXStaticCastExpr::CreateEmpty(Context,
Sebastian Redl60adf4a2010-08-18 23:56:52 +00002004 /*PathSize*/ Record[ASTStmtReader::NumExprFields]);
Sam Weinigce757a72010-01-16 21:21:01 +00002005 break;
2006
Sebastian Redl8538e8d2010-08-18 23:57:32 +00002007 case EXPR_CXX_DYNAMIC_CAST:
Douglas Gregor35942772011-09-09 21:34:22 +00002008 S = CXXDynamicCastExpr::CreateEmpty(Context,
Sebastian Redl60adf4a2010-08-18 23:56:52 +00002009 /*PathSize*/ Record[ASTStmtReader::NumExprFields]);
Sam Weinigce757a72010-01-16 21:21:01 +00002010 break;
2011
Sebastian Redl8538e8d2010-08-18 23:57:32 +00002012 case EXPR_CXX_REINTERPRET_CAST:
Douglas Gregor35942772011-09-09 21:34:22 +00002013 S = CXXReinterpretCastExpr::CreateEmpty(Context,
Sebastian Redl60adf4a2010-08-18 23:56:52 +00002014 /*PathSize*/ Record[ASTStmtReader::NumExprFields]);
Sam Weinigce757a72010-01-16 21:21:01 +00002015 break;
2016
Sebastian Redl8538e8d2010-08-18 23:57:32 +00002017 case EXPR_CXX_CONST_CAST:
Douglas Gregor35942772011-09-09 21:34:22 +00002018 S = CXXConstCastExpr::CreateEmpty(Context);
Sam Weinigce757a72010-01-16 21:21:01 +00002019 break;
2020
Sebastian Redl8538e8d2010-08-18 23:57:32 +00002021 case EXPR_CXX_FUNCTIONAL_CAST:
Douglas Gregor35942772011-09-09 21:34:22 +00002022 S = CXXFunctionalCastExpr::CreateEmpty(Context,
Sebastian Redl60adf4a2010-08-18 23:56:52 +00002023 /*PathSize*/ Record[ASTStmtReader::NumExprFields]);
Sam Weinigce757a72010-01-16 21:21:01 +00002024 break;
2025
Richard Smith9fcce652012-03-07 08:35:16 +00002026 case EXPR_USER_DEFINED_LITERAL:
2027 S = new (Context) UserDefinedLiteral(Context, Empty);
2028 break;
2029
Sebastian Redl8538e8d2010-08-18 23:57:32 +00002030 case EXPR_CXX_BOOL_LITERAL:
Sam Weinigeb7f9612010-02-07 06:32:43 +00002031 S = new (Context) CXXBoolLiteralExpr(Empty);
2032 break;
Sam Weinigce757a72010-01-16 21:21:01 +00002033
Sebastian Redl8538e8d2010-08-18 23:57:32 +00002034 case EXPR_CXX_NULL_PTR_LITERAL:
Sam Weinigeb7f9612010-02-07 06:32:43 +00002035 S = new (Context) CXXNullPtrLiteralExpr(Empty);
2036 break;
Sebastian Redl8538e8d2010-08-18 23:57:32 +00002037 case EXPR_CXX_TYPEID_EXPR:
Chris Lattner14ab24f2010-05-09 06:03:39 +00002038 S = new (Context) CXXTypeidExpr(Empty, true);
2039 break;
Sebastian Redl8538e8d2010-08-18 23:57:32 +00002040 case EXPR_CXX_TYPEID_TYPE:
Chris Lattner14ab24f2010-05-09 06:03:39 +00002041 S = new (Context) CXXTypeidExpr(Empty, false);
2042 break;
Francois Pichet01b7c302010-09-08 12:20:18 +00002043 case EXPR_CXX_UUIDOF_EXPR:
2044 S = new (Context) CXXUuidofExpr(Empty, true);
2045 break;
2046 case EXPR_CXX_UUIDOF_TYPE:
2047 S = new (Context) CXXUuidofExpr(Empty, false);
2048 break;
Sebastian Redl8538e8d2010-08-18 23:57:32 +00002049 case EXPR_CXX_THIS:
Chris Lattner2fbdfcd2010-05-09 06:15:05 +00002050 S = new (Context) CXXThisExpr(Empty);
2051 break;
Sebastian Redl8538e8d2010-08-18 23:57:32 +00002052 case EXPR_CXX_THROW:
Chris Lattner2fbdfcd2010-05-09 06:15:05 +00002053 S = new (Context) CXXThrowExpr(Empty);
2054 break;
Sebastian Redl8538e8d2010-08-18 23:57:32 +00002055 case EXPR_CXX_DEFAULT_ARG: {
Sebastian Redl60adf4a2010-08-18 23:56:52 +00002056 bool HasOtherExprStored = Record[ASTStmtReader::NumExprFields];
Argyrios Kyrtzidis8a507332010-07-02 23:30:15 +00002057 if (HasOtherExprStored) {
2058 Expr *SubExpr = ReadSubExpr();
Douglas Gregor35942772011-09-09 21:34:22 +00002059 S = CXXDefaultArgExpr::Create(Context, SourceLocation(), 0, SubExpr);
Argyrios Kyrtzidis8a507332010-07-02 23:30:15 +00002060 } else
2061 S = new (Context) CXXDefaultArgExpr(Empty);
Chris Lattner030854b2010-05-09 06:40:08 +00002062 break;
Argyrios Kyrtzidis8a507332010-07-02 23:30:15 +00002063 }
Sebastian Redl8538e8d2010-08-18 23:57:32 +00002064 case EXPR_CXX_BIND_TEMPORARY:
Chris Lattnerd2598362010-05-10 00:25:06 +00002065 S = new (Context) CXXBindTemporaryExpr(Empty);
2066 break;
Douglas Gregore2ca6d42010-09-02 21:50:02 +00002067
Sebastian Redl8538e8d2010-08-18 23:57:32 +00002068 case EXPR_CXX_SCALAR_VALUE_INIT:
Douglas Gregored8abf12010-07-08 06:14:04 +00002069 S = new (Context) CXXScalarValueInitExpr(Empty);
Chris Lattner59218632010-05-10 01:22:27 +00002070 break;
Sebastian Redl8538e8d2010-08-18 23:57:32 +00002071 case EXPR_CXX_NEW:
Chris Lattner59218632010-05-10 01:22:27 +00002072 S = new (Context) CXXNewExpr(Empty);
2073 break;
Sebastian Redl8538e8d2010-08-18 23:57:32 +00002074 case EXPR_CXX_DELETE:
Argyrios Kyrtzidis95fc98c2010-06-22 17:07:59 +00002075 S = new (Context) CXXDeleteExpr(Empty);
2076 break;
Sebastian Redl8538e8d2010-08-18 23:57:32 +00002077 case EXPR_CXX_PSEUDO_DESTRUCTOR:
Argyrios Kyrtzidisde4bd182010-06-28 09:32:03 +00002078 S = new (Context) CXXPseudoDestructorExpr(Empty);
2079 break;
Chris Lattner59218632010-05-10 01:22:27 +00002080
John McCall4765fa02010-12-06 08:20:24 +00002081 case EXPR_EXPR_WITH_CLEANUPS:
John McCall80ee6e82011-11-10 05:35:25 +00002082 S = ExprWithCleanups::Create(Context, Empty,
2083 Record[ASTStmtReader::NumExprFields]);
Chris Lattnerd2598362010-05-10 00:25:06 +00002084 break;
Argyrios Kyrtzidis8dfbd8b2010-06-24 08:57:31 +00002085
Sebastian Redl8538e8d2010-08-18 23:57:32 +00002086 case EXPR_CXX_DEPENDENT_SCOPE_MEMBER:
Douglas Gregor35942772011-09-09 21:34:22 +00002087 S = CXXDependentScopeMemberExpr::CreateEmpty(Context,
Abramo Bagnarae4b92762012-01-27 09:46:47 +00002088 /*HasTemplateKWAndArgsInfo=*/Record[ASTStmtReader::NumExprFields],
Douglas Gregordef03542011-02-04 12:01:24 +00002089 /*NumTemplateArgs=*/Record[ASTStmtReader::NumExprFields]
2090 ? Record[ASTStmtReader::NumExprFields + 1]
2091 : 0);
Argyrios Kyrtzidis8dfbd8b2010-06-24 08:57:31 +00002092 break;
2093
Sebastian Redl8538e8d2010-08-18 23:57:32 +00002094 case EXPR_CXX_DEPENDENT_SCOPE_DECL_REF:
Douglas Gregor35942772011-09-09 21:34:22 +00002095 S = DependentScopeDeclRefExpr::CreateEmpty(Context,
Abramo Bagnarae4b92762012-01-27 09:46:47 +00002096 /*HasTemplateKWAndArgsInfo=*/Record[ASTStmtReader::NumExprFields],
Douglas Gregordef03542011-02-04 12:01:24 +00002097 /*NumTemplateArgs=*/Record[ASTStmtReader::NumExprFields]
2098 ? Record[ASTStmtReader::NumExprFields + 1]
2099 : 0);
Argyrios Kyrtzidis12dffcd2010-06-28 09:31:56 +00002100 break;
2101
Sebastian Redl8538e8d2010-08-18 23:57:32 +00002102 case EXPR_CXX_UNRESOLVED_CONSTRUCT:
Douglas Gregor35942772011-09-09 21:34:22 +00002103 S = CXXUnresolvedConstructExpr::CreateEmpty(Context,
Sebastian Redl60adf4a2010-08-18 23:56:52 +00002104 /*NumArgs=*/Record[ASTStmtReader::NumExprFields]);
Argyrios Kyrtzidisa77eb082010-06-25 09:03:26 +00002105 break;
2106
Sebastian Redl8538e8d2010-08-18 23:57:32 +00002107 case EXPR_CXX_UNRESOLVED_MEMBER:
Douglas Gregor35942772011-09-09 21:34:22 +00002108 S = UnresolvedMemberExpr::CreateEmpty(Context,
Abramo Bagnarae4b92762012-01-27 09:46:47 +00002109 /*HasTemplateKWAndArgsInfo=*/Record[ASTStmtReader::NumExprFields],
Douglas Gregordef03542011-02-04 12:01:24 +00002110 /*NumTemplateArgs=*/Record[ASTStmtReader::NumExprFields]
2111 ? Record[ASTStmtReader::NumExprFields + 1]
2112 : 0);
Argyrios Kyrtzidis8dfbd8b2010-06-24 08:57:31 +00002113 break;
Argyrios Kyrtzidisbd65bb52010-06-25 09:03:34 +00002114
Sebastian Redl8538e8d2010-08-18 23:57:32 +00002115 case EXPR_CXX_UNRESOLVED_LOOKUP:
Douglas Gregor35942772011-09-09 21:34:22 +00002116 S = UnresolvedLookupExpr::CreateEmpty(Context,
Abramo Bagnarae4b92762012-01-27 09:46:47 +00002117 /*HasTemplateKWAndArgsInfo=*/Record[ASTStmtReader::NumExprFields],
Douglas Gregordef03542011-02-04 12:01:24 +00002118 /*NumTemplateArgs=*/Record[ASTStmtReader::NumExprFields]
2119 ? Record[ASTStmtReader::NumExprFields + 1]
2120 : 0);
Argyrios Kyrtzidisbd65bb52010-06-25 09:03:34 +00002121 break;
Argyrios Kyrtzidis6d00c132010-07-10 11:46:15 +00002122
Sebastian Redl8538e8d2010-08-18 23:57:32 +00002123 case EXPR_CXX_UNARY_TYPE_TRAIT:
Argyrios Kyrtzidis6d00c132010-07-10 11:46:15 +00002124 S = new (Context) UnaryTypeTraitExpr(Empty);
2125 break;
Sebastian Redl6b219d02010-09-10 20:55:54 +00002126
Francois Pichetf1872372010-12-08 22:35:30 +00002127 case EXPR_BINARY_TYPE_TRAIT:
Francois Pichet6ad6f282010-12-07 00:08:36 +00002128 S = new (Context) BinaryTypeTraitExpr(Empty);
2129 break;
2130
Douglas Gregor4ca8ac22012-02-24 07:38:34 +00002131 case EXPR_TYPE_TRAIT:
2132 S = TypeTraitExpr::CreateDeserialized(Context,
2133 Record[ASTStmtReader::NumExprFields]);
2134 break;
2135
John Wiegley21ff2e52011-04-28 00:16:57 +00002136 case EXPR_ARRAY_TYPE_TRAIT:
2137 S = new (Context) ArrayTypeTraitExpr(Empty);
2138 break;
2139
John Wiegley55262202011-04-25 06:54:41 +00002140 case EXPR_CXX_EXPRESSION_TRAIT:
2141 S = new (Context) ExpressionTraitExpr(Empty);
2142 break;
2143
Sebastian Redl6b219d02010-09-10 20:55:54 +00002144 case EXPR_CXX_NOEXCEPT:
2145 S = new (Context) CXXNoexceptExpr(Empty);
2146 break;
John McCall7cd7d1a2010-11-15 23:31:06 +00002147
Douglas Gregorbe230c32011-01-03 17:17:50 +00002148 case EXPR_PACK_EXPANSION:
2149 S = new (Context) PackExpansionExpr(Empty);
2150 break;
2151
Douglas Gregoree8aff02011-01-04 17:33:58 +00002152 case EXPR_SIZEOF_PACK:
2153 S = new (Context) SizeOfPackExpr(Empty);
2154 break;
2155
John McCall7110fd62011-07-15 07:00:14 +00002156 case EXPR_SUBST_NON_TYPE_TEMPLATE_PARM:
2157 S = new (Context) SubstNonTypeTemplateParmExpr(Empty);
2158 break;
2159
Douglas Gregorc7793c72011-01-15 01:15:58 +00002160 case EXPR_SUBST_NON_TYPE_TEMPLATE_PARM_PACK:
2161 S = new (Context) SubstNonTypeTemplateParmPackExpr(Empty);
2162 break;
2163
Douglas Gregor03e80032011-06-21 17:03:29 +00002164 case EXPR_MATERIALIZE_TEMPORARY:
2165 S = new (Context) MaterializeTemporaryExpr(Empty);
2166 break;
2167
Argyrios Kyrtzidis8bc27822011-12-03 03:49:52 +00002168 case EXPR_OPAQUE_VALUE:
2169 S = new (Context) OpaqueValueExpr(Empty);
John McCall7cd7d1a2010-11-15 23:31:06 +00002170 break;
Peter Collingbournee08ce652011-02-09 21:07:24 +00002171
2172 case EXPR_CUDA_KERNEL_CALL:
Douglas Gregor35942772011-09-09 21:34:22 +00002173 S = new (Context) CUDAKernelCallExpr(Context, Empty);
Peter Collingbournee08ce652011-02-09 21:07:24 +00002174 break;
Tanya Lattner61eee0c2011-06-04 00:47:47 +00002175
2176 case EXPR_ASTYPE:
2177 S = new (Context) AsTypeExpr(Empty);
2178 break;
Eli Friedman276b0612011-10-11 02:20:01 +00002179
John McCall4b9c2d22011-11-06 09:01:30 +00002180 case EXPR_PSEUDO_OBJECT: {
2181 unsigned numSemanticExprs = Record[ASTStmtReader::NumExprFields];
2182 S = PseudoObjectExpr::Create(Context, Empty, numSemanticExprs);
2183 break;
2184 }
2185
Eli Friedman276b0612011-10-11 02:20:01 +00002186 case EXPR_ATOMIC:
2187 S = new (Context) AtomicExpr(Empty);
2188 break;
Douglas Gregor9d36f5d2012-02-14 17:54:36 +00002189
2190 case EXPR_LAMBDA: {
2191 unsigned NumCaptures = Record[ASTStmtReader::NumExprFields];
2192 unsigned NumArrayIndexVars = Record[ASTStmtReader::NumExprFields + 1];
2193 S = LambdaExpr::CreateDeserialized(Context, NumCaptures,
2194 NumArrayIndexVars);
2195 break;
2196 }
Chris Lattner4c6f9522009-04-27 05:14:47 +00002197 }
Argyrios Kyrtzidis6d00c132010-07-10 11:46:15 +00002198
Chris Lattner4c6f9522009-04-27 05:14:47 +00002199 // We hit a STMT_STOP, so we're done with this expression.
2200 if (Finished)
2201 break;
2202
2203 ++NumStatementsRead;
2204
Argyrios Kyrtzidise6f08682011-10-21 23:02:28 +00002205 if (S && !IsStmtReference) {
Argyrios Kyrtzidis919e6932010-06-28 22:28:35 +00002206 Reader.Visit(S);
Argyrios Kyrtzidise6f08682011-10-21 23:02:28 +00002207 StmtEntries[Cursor.GetCurrentBitNo()] = S;
2208 }
2209
Chris Lattner4c6f9522009-04-27 05:14:47 +00002210
2211 assert(Idx == Record.size() && "Invalid deserialization of statement");
2212 StmtStack.push_back(S);
2213 }
Argyrios Kyrtzidis919e6932010-06-28 22:28:35 +00002214
2215#ifndef NDEBUG
2216 assert(StmtStack.size() > PrevNumStmts && "Read too many sub stmts!");
2217 assert(StmtStack.size() == PrevNumStmts + 1 && "Extra expressions on stack!");
2218#endif
2219
2220 return StmtStack.pop_back_val();
Chris Lattner4c6f9522009-04-27 05:14:47 +00002221}