blob: a0d7e457e0c52c6b930ecdc330b5d44b1ccc5b6e [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++];
Anders Carlssonb0ca1372011-03-06 18:19:42 +0000336 unsigned NumTemplateArgs = 0;
Abramo Bagnarae4b92762012-01-27 09:46:47 +0000337 if (E->hasTemplateKWAndArgsInfo())
Anders Carlssonb0ca1372011-03-06 18:19:42 +0000338 NumTemplateArgs = Record[Idx++];
339
Chandler Carruthcb66cff2011-05-01 21:29:53 +0000340 if (E->hasQualifier())
Chandler Carruth6857c3e2011-05-01 22:14:37 +0000341 E->getInternalQualifierLoc()
Douglas Gregor40d96a62011-02-28 21:54:11 +0000342 = Reader.ReadNestedNameSpecifierLoc(F, Record, Idx);
Argyrios Kyrtzidis663e3802010-07-08 13:09:47 +0000343
Chandler Carruth3aa81402011-05-01 23:48:14 +0000344 if (E->hasFoundDecl())
Douglas Gregor409448c2011-07-21 22:35:25 +0000345 E->getInternalFoundDecl() = ReadDeclAs<NamedDecl>(Record, Idx);
Chandler Carruth3aa81402011-05-01 23:48:14 +0000346
Abramo Bagnarae4b92762012-01-27 09:46:47 +0000347 if (E->hasTemplateKWAndArgsInfo())
348 ReadTemplateKWAndArgsInfo(*E->getTemplateKWAndArgsInfo(),
349 NumTemplateArgs);
Argyrios Kyrtzidis663e3802010-07-08 13:09:47 +0000350
Douglas Gregor409448c2011-07-21 22:35:25 +0000351 E->setDecl(ReadDeclAs<ValueDecl>(Record, Idx));
Sebastian Redlc3632732010-10-05 15:59:54 +0000352 E->setLocation(ReadSourceLocation(Record, Idx));
Argyrios Kyrtzidis40451072010-10-15 18:21:24 +0000353 ReadDeclarationNameLoc(E->DNLoc, E->getDecl()->getDeclName(), Record, Idx);
Chris Lattner4c6f9522009-04-27 05:14:47 +0000354}
355
Sebastian Redl60adf4a2010-08-18 23:56:52 +0000356void ASTStmtReader::VisitIntegerLiteral(IntegerLiteral *E) {
Chris Lattner4c6f9522009-04-27 05:14:47 +0000357 VisitExpr(E);
Sebastian Redlc3632732010-10-05 15:59:54 +0000358 E->setLocation(ReadSourceLocation(Record, Idx));
Douglas Gregor35942772011-09-09 21:34:22 +0000359 E->setValue(Reader.getContext(), Reader.ReadAPInt(Record, Idx));
Chris Lattner4c6f9522009-04-27 05:14:47 +0000360}
361
Sebastian Redl60adf4a2010-08-18 23:56:52 +0000362void ASTStmtReader::VisitFloatingLiteral(FloatingLiteral *E) {
Chris Lattner4c6f9522009-04-27 05:14:47 +0000363 VisitExpr(E);
Douglas Gregor35942772011-09-09 21:34:22 +0000364 E->setValue(Reader.getContext(), Reader.ReadAPFloat(Record, Idx));
Chris Lattner4c6f9522009-04-27 05:14:47 +0000365 E->setExact(Record[Idx++]);
Sebastian Redlc3632732010-10-05 15:59:54 +0000366 E->setLocation(ReadSourceLocation(Record, Idx));
Chris Lattner4c6f9522009-04-27 05:14:47 +0000367}
368
Sebastian Redl60adf4a2010-08-18 23:56:52 +0000369void ASTStmtReader::VisitImaginaryLiteral(ImaginaryLiteral *E) {
Chris Lattner4c6f9522009-04-27 05:14:47 +0000370 VisitExpr(E);
Argyrios Kyrtzidisd98a2ab2010-06-29 22:46:25 +0000371 E->setSubExpr(Reader.ReadSubExpr());
Chris Lattner4c6f9522009-04-27 05:14:47 +0000372}
373
Sebastian Redl60adf4a2010-08-18 23:56:52 +0000374void ASTStmtReader::VisitStringLiteral(StringLiteral *E) {
Chris Lattner4c6f9522009-04-27 05:14:47 +0000375 VisitExpr(E);
376 unsigned Len = Record[Idx++];
Mike Stump1eb44332009-09-09 15:08:12 +0000377 assert(Record[Idx] == E->getNumConcatenated() &&
Chris Lattner4c6f9522009-04-27 05:14:47 +0000378 "Wrong number of concatenated tokens!");
379 ++Idx;
Eli Friedman64f45a22011-11-01 02:23:42 +0000380 StringLiteral::StringKind kind =
381 static_cast<StringLiteral::StringKind>(Record[Idx++]);
382 bool isPascal = Record[Idx++];
Chris Lattner4c6f9522009-04-27 05:14:47 +0000383
Mike Stump1eb44332009-09-09 15:08:12 +0000384 // Read string data
Dylan Noblesmithf7ccbad2012-02-05 02:13:05 +0000385 SmallString<16> Str(&Record[Idx], &Record[Idx] + Len);
Eli Friedman64f45a22011-11-01 02:23:42 +0000386 E->setString(Reader.getContext(), Str.str(), kind, isPascal);
Chris Lattner4c6f9522009-04-27 05:14:47 +0000387 Idx += Len;
388
389 // Read source locations
390 for (unsigned I = 0, N = E->getNumConcatenated(); I != N; ++I)
Sebastian Redlc3632732010-10-05 15:59:54 +0000391 E->setStrTokenLoc(I, ReadSourceLocation(Record, Idx));
Chris Lattner4c6f9522009-04-27 05:14:47 +0000392}
393
Sebastian Redl60adf4a2010-08-18 23:56:52 +0000394void ASTStmtReader::VisitCharacterLiteral(CharacterLiteral *E) {
Chris Lattner4c6f9522009-04-27 05:14:47 +0000395 VisitExpr(E);
396 E->setValue(Record[Idx++]);
Sebastian Redlc3632732010-10-05 15:59:54 +0000397 E->setLocation(ReadSourceLocation(Record, Idx));
Douglas Gregor5cee1192011-07-27 05:40:30 +0000398 E->setKind(static_cast<CharacterLiteral::CharacterKind>(Record[Idx++]));
Chris Lattner4c6f9522009-04-27 05:14:47 +0000399}
400
Sebastian Redl60adf4a2010-08-18 23:56:52 +0000401void ASTStmtReader::VisitParenExpr(ParenExpr *E) {
Chris Lattner4c6f9522009-04-27 05:14:47 +0000402 VisitExpr(E);
Sebastian Redlc3632732010-10-05 15:59:54 +0000403 E->setLParen(ReadSourceLocation(Record, Idx));
404 E->setRParen(ReadSourceLocation(Record, Idx));
Argyrios Kyrtzidisd98a2ab2010-06-29 22:46:25 +0000405 E->setSubExpr(Reader.ReadSubExpr());
Chris Lattner4c6f9522009-04-27 05:14:47 +0000406}
407
Sebastian Redl60adf4a2010-08-18 23:56:52 +0000408void ASTStmtReader::VisitParenListExpr(ParenListExpr *E) {
Argyrios Kyrtzidis37bdfe22010-06-30 08:49:18 +0000409 VisitExpr(E);
410 unsigned NumExprs = Record[Idx++];
Douglas Gregor35942772011-09-09 21:34:22 +0000411 E->Exprs = new (Reader.getContext()) Stmt*[NumExprs];
Argyrios Kyrtzidis37bdfe22010-06-30 08:49:18 +0000412 for (unsigned i = 0; i != NumExprs; ++i)
413 E->Exprs[i] = Reader.ReadSubStmt();
414 E->NumExprs = NumExprs;
Sebastian Redlc3632732010-10-05 15:59:54 +0000415 E->LParenLoc = ReadSourceLocation(Record, Idx);
416 E->RParenLoc = ReadSourceLocation(Record, Idx);
Argyrios Kyrtzidis37bdfe22010-06-30 08:49:18 +0000417}
418
Sebastian Redl60adf4a2010-08-18 23:56:52 +0000419void ASTStmtReader::VisitUnaryOperator(UnaryOperator *E) {
Chris Lattner4c6f9522009-04-27 05:14:47 +0000420 VisitExpr(E);
Argyrios Kyrtzidisd98a2ab2010-06-29 22:46:25 +0000421 E->setSubExpr(Reader.ReadSubExpr());
Chris Lattner4c6f9522009-04-27 05:14:47 +0000422 E->setOpcode((UnaryOperator::Opcode)Record[Idx++]);
Sebastian Redlc3632732010-10-05 15:59:54 +0000423 E->setOperatorLoc(ReadSourceLocation(Record, Idx));
Chris Lattner4c6f9522009-04-27 05:14:47 +0000424}
425
Sebastian Redl60adf4a2010-08-18 23:56:52 +0000426void ASTStmtReader::VisitOffsetOfExpr(OffsetOfExpr *E) {
Douglas Gregor8ecdb652010-04-28 22:16:22 +0000427 typedef OffsetOfExpr::OffsetOfNode Node;
428 VisitExpr(E);
429 assert(E->getNumComponents() == Record[Idx]);
430 ++Idx;
431 assert(E->getNumExpressions() == Record[Idx]);
432 ++Idx;
Sebastian Redlc3632732010-10-05 15:59:54 +0000433 E->setOperatorLoc(ReadSourceLocation(Record, Idx));
434 E->setRParenLoc(ReadSourceLocation(Record, Idx));
435 E->setTypeSourceInfo(GetTypeSourceInfo(Record, Idx));
Douglas Gregor8ecdb652010-04-28 22:16:22 +0000436 for (unsigned I = 0, N = E->getNumComponents(); I != N; ++I) {
437 Node::Kind Kind = static_cast<Node::Kind>(Record[Idx++]);
Sebastian Redlc3632732010-10-05 15:59:54 +0000438 SourceLocation Start = ReadSourceLocation(Record, Idx);
439 SourceLocation End = ReadSourceLocation(Record, Idx);
Douglas Gregor8ecdb652010-04-28 22:16:22 +0000440 switch (Kind) {
441 case Node::Array:
442 E->setComponent(I, Node(Start, Record[Idx++], End));
443 break;
444
445 case Node::Field:
Douglas Gregor409448c2011-07-21 22:35:25 +0000446 E->setComponent(I, Node(Start, ReadDeclAs<FieldDecl>(Record, Idx), End));
Douglas Gregor8ecdb652010-04-28 22:16:22 +0000447 break;
448
449 case Node::Identifier:
Douglas Gregor95eab172011-07-28 20:55:49 +0000450 E->setComponent(I,
451 Node(Start,
452 Reader.GetIdentifierInfo(F, Record, Idx),
453 End));
Douglas Gregor8ecdb652010-04-28 22:16:22 +0000454 break;
Douglas Gregorcc8a5d52010-04-29 00:18:15 +0000455
Argyrios Kyrtzidisafbf3122010-07-29 18:16:10 +0000456 case Node::Base: {
Douglas Gregor35942772011-09-09 21:34:22 +0000457 CXXBaseSpecifier *Base = new (Reader.getContext()) CXXBaseSpecifier();
Sebastian Redlc3632732010-10-05 15:59:54 +0000458 *Base = Reader.ReadCXXBaseSpecifier(F, Record, Idx);
Argyrios Kyrtzidisafbf3122010-07-29 18:16:10 +0000459 E->setComponent(I, Node(Base));
Douglas Gregorcc8a5d52010-04-29 00:18:15 +0000460 break;
Douglas Gregor8ecdb652010-04-28 22:16:22 +0000461 }
Argyrios Kyrtzidisafbf3122010-07-29 18:16:10 +0000462 }
Douglas Gregor8ecdb652010-04-28 22:16:22 +0000463 }
464
465 for (unsigned I = 0, N = E->getNumExpressions(); I != N; ++I)
Argyrios Kyrtzidisd98a2ab2010-06-29 22:46:25 +0000466 E->setIndexExpr(I, Reader.ReadSubExpr());
Douglas Gregor8ecdb652010-04-28 22:16:22 +0000467}
468
Peter Collingbournef4e3cfb2011-03-11 19:24:49 +0000469void ASTStmtReader::VisitUnaryExprOrTypeTraitExpr(UnaryExprOrTypeTraitExpr *E) {
Chris Lattner4c6f9522009-04-27 05:14:47 +0000470 VisitExpr(E);
Peter Collingbournef4e3cfb2011-03-11 19:24:49 +0000471 E->setKind(static_cast<UnaryExprOrTypeTrait>(Record[Idx++]));
Chris Lattner4c6f9522009-04-27 05:14:47 +0000472 if (Record[Idx] == 0) {
Argyrios Kyrtzidisd98a2ab2010-06-29 22:46:25 +0000473 E->setArgument(Reader.ReadSubExpr());
Chris Lattner4c6f9522009-04-27 05:14:47 +0000474 ++Idx;
475 } else {
Sebastian Redlc3632732010-10-05 15:59:54 +0000476 E->setArgument(GetTypeSourceInfo(Record, Idx));
Chris Lattner4c6f9522009-04-27 05:14:47 +0000477 }
Sebastian Redlc3632732010-10-05 15:59:54 +0000478 E->setOperatorLoc(ReadSourceLocation(Record, Idx));
479 E->setRParenLoc(ReadSourceLocation(Record, Idx));
Chris Lattner4c6f9522009-04-27 05:14:47 +0000480}
481
Sebastian Redl60adf4a2010-08-18 23:56:52 +0000482void ASTStmtReader::VisitArraySubscriptExpr(ArraySubscriptExpr *E) {
Chris Lattner4c6f9522009-04-27 05:14:47 +0000483 VisitExpr(E);
Argyrios Kyrtzidisd98a2ab2010-06-29 22:46:25 +0000484 E->setLHS(Reader.ReadSubExpr());
485 E->setRHS(Reader.ReadSubExpr());
Sebastian Redlc3632732010-10-05 15:59:54 +0000486 E->setRBracketLoc(ReadSourceLocation(Record, Idx));
Chris Lattner4c6f9522009-04-27 05:14:47 +0000487}
488
Sebastian Redl60adf4a2010-08-18 23:56:52 +0000489void ASTStmtReader::VisitCallExpr(CallExpr *E) {
Chris Lattner4c6f9522009-04-27 05:14:47 +0000490 VisitExpr(E);
Douglas Gregor35942772011-09-09 21:34:22 +0000491 E->setNumArgs(Reader.getContext(), Record[Idx++]);
Sebastian Redlc3632732010-10-05 15:59:54 +0000492 E->setRParenLoc(ReadSourceLocation(Record, Idx));
Argyrios Kyrtzidisd98a2ab2010-06-29 22:46:25 +0000493 E->setCallee(Reader.ReadSubExpr());
Chris Lattner4c6f9522009-04-27 05:14:47 +0000494 for (unsigned I = 0, N = E->getNumArgs(); I != N; ++I)
Argyrios Kyrtzidisd98a2ab2010-06-29 22:46:25 +0000495 E->setArg(I, Reader.ReadSubExpr());
Chris Lattner4c6f9522009-04-27 05:14:47 +0000496}
497
John McCall7110fd62011-07-15 07:00:14 +0000498void ASTStmtReader::VisitCXXMemberCallExpr(CXXMemberCallExpr *E) {
499 VisitCallExpr(E);
500}
501
Sebastian Redl60adf4a2010-08-18 23:56:52 +0000502void ASTStmtReader::VisitMemberExpr(MemberExpr *E) {
Argyrios Kyrtzidis663e3802010-07-08 13:09:47 +0000503 // Don't call VisitExpr, this is fully initialized at creation.
504 assert(E->getStmtClass() == Stmt::MemberExprClass &&
505 "It's a subclass, we must advance Idx!");
Chris Lattner4c6f9522009-04-27 05:14:47 +0000506}
507
Sebastian Redl60adf4a2010-08-18 23:56:52 +0000508void ASTStmtReader::VisitObjCIsaExpr(ObjCIsaExpr *E) {
Steve Narofff242b1b2009-07-24 17:54:45 +0000509 VisitExpr(E);
Argyrios Kyrtzidisd98a2ab2010-06-29 22:46:25 +0000510 E->setBase(Reader.ReadSubExpr());
Sebastian Redlc3632732010-10-05 15:59:54 +0000511 E->setIsaMemberLoc(ReadSourceLocation(Record, Idx));
Steve Narofff242b1b2009-07-24 17:54:45 +0000512 E->setArrow(Record[Idx++]);
Steve Narofff242b1b2009-07-24 17:54:45 +0000513}
514
John McCallf85e1932011-06-15 23:02:42 +0000515void ASTStmtReader::
516VisitObjCIndirectCopyRestoreExpr(ObjCIndirectCopyRestoreExpr *E) {
517 VisitExpr(E);
518 E->Operand = Reader.ReadSubExpr();
519 E->setShouldCopy(Record[Idx++]);
520}
521
522void ASTStmtReader::VisitObjCBridgedCastExpr(ObjCBridgedCastExpr *E) {
523 VisitExplicitCastExpr(E);
524 E->LParenLoc = ReadSourceLocation(Record, Idx);
525 E->BridgeKeywordLoc = ReadSourceLocation(Record, Idx);
526 E->Kind = Record[Idx++];
527}
528
Sebastian Redl60adf4a2010-08-18 23:56:52 +0000529void ASTStmtReader::VisitCastExpr(CastExpr *E) {
Chris Lattner4c6f9522009-04-27 05:14:47 +0000530 VisitExpr(E);
John McCallf871d0c2010-08-07 06:22:56 +0000531 unsigned NumBaseSpecs = Record[Idx++];
532 assert(NumBaseSpecs == E->path_size());
Argyrios Kyrtzidisd98a2ab2010-06-29 22:46:25 +0000533 E->setSubExpr(Reader.ReadSubExpr());
Anders Carlssoncdef2b72009-07-31 00:48:10 +0000534 E->setCastKind((CastExpr::CastKind)Record[Idx++]);
John McCallf871d0c2010-08-07 06:22:56 +0000535 CastExpr::path_iterator BaseI = E->path_begin();
Argyrios Kyrtzidis0745d0a2010-07-02 23:30:27 +0000536 while (NumBaseSpecs--) {
Douglas Gregor35942772011-09-09 21:34:22 +0000537 CXXBaseSpecifier *BaseSpec = new (Reader.getContext()) CXXBaseSpecifier;
Sebastian Redlc3632732010-10-05 15:59:54 +0000538 *BaseSpec = Reader.ReadCXXBaseSpecifier(F, Record, Idx);
John McCallf871d0c2010-08-07 06:22:56 +0000539 *BaseI++ = BaseSpec;
Argyrios Kyrtzidis0745d0a2010-07-02 23:30:27 +0000540 }
Chris Lattner4c6f9522009-04-27 05:14:47 +0000541}
542
Sebastian Redl60adf4a2010-08-18 23:56:52 +0000543void ASTStmtReader::VisitBinaryOperator(BinaryOperator *E) {
Chris Lattner4c6f9522009-04-27 05:14:47 +0000544 VisitExpr(E);
Argyrios Kyrtzidisd98a2ab2010-06-29 22:46:25 +0000545 E->setLHS(Reader.ReadSubExpr());
546 E->setRHS(Reader.ReadSubExpr());
Chris Lattner4c6f9522009-04-27 05:14:47 +0000547 E->setOpcode((BinaryOperator::Opcode)Record[Idx++]);
Sebastian Redlc3632732010-10-05 15:59:54 +0000548 E->setOperatorLoc(ReadSourceLocation(Record, Idx));
Chris Lattner4c6f9522009-04-27 05:14:47 +0000549}
550
Sebastian Redl60adf4a2010-08-18 23:56:52 +0000551void ASTStmtReader::VisitCompoundAssignOperator(CompoundAssignOperator *E) {
Chris Lattner4c6f9522009-04-27 05:14:47 +0000552 VisitBinaryOperator(E);
Douglas Gregor393f2492011-07-22 00:38:23 +0000553 E->setComputationLHSType(Reader.readType(F, Record, Idx));
554 E->setComputationResultType(Reader.readType(F, Record, Idx));
Chris Lattner4c6f9522009-04-27 05:14:47 +0000555}
556
Sebastian Redl60adf4a2010-08-18 23:56:52 +0000557void ASTStmtReader::VisitConditionalOperator(ConditionalOperator *E) {
Chris Lattner4c6f9522009-04-27 05:14:47 +0000558 VisitExpr(E);
John McCall56ca35d2011-02-17 10:25:35 +0000559 E->SubExprs[ConditionalOperator::COND] = Reader.ReadSubExpr();
560 E->SubExprs[ConditionalOperator::LHS] = Reader.ReadSubExpr();
561 E->SubExprs[ConditionalOperator::RHS] = Reader.ReadSubExpr();
562 E->QuestionLoc = ReadSourceLocation(Record, Idx);
563 E->ColonLoc = ReadSourceLocation(Record, Idx);
564}
565
566void
567ASTStmtReader::VisitBinaryConditionalOperator(BinaryConditionalOperator *E) {
568 VisitExpr(E);
569 E->OpaqueValue = cast<OpaqueValueExpr>(Reader.ReadSubExpr());
570 E->SubExprs[BinaryConditionalOperator::COMMON] = Reader.ReadSubExpr();
571 E->SubExprs[BinaryConditionalOperator::COND] = Reader.ReadSubExpr();
572 E->SubExprs[BinaryConditionalOperator::LHS] = Reader.ReadSubExpr();
573 E->SubExprs[BinaryConditionalOperator::RHS] = Reader.ReadSubExpr();
574 E->QuestionLoc = ReadSourceLocation(Record, Idx);
575 E->ColonLoc = ReadSourceLocation(Record, Idx);
Chris Lattner4c6f9522009-04-27 05:14:47 +0000576}
577
Sebastian Redl60adf4a2010-08-18 23:56:52 +0000578void ASTStmtReader::VisitImplicitCastExpr(ImplicitCastExpr *E) {
Chris Lattner4c6f9522009-04-27 05:14:47 +0000579 VisitCastExpr(E);
Chris Lattner4c6f9522009-04-27 05:14:47 +0000580}
581
Sebastian Redl60adf4a2010-08-18 23:56:52 +0000582void ASTStmtReader::VisitExplicitCastExpr(ExplicitCastExpr *E) {
Chris Lattner4c6f9522009-04-27 05:14:47 +0000583 VisitCastExpr(E);
Sebastian Redlc3632732010-10-05 15:59:54 +0000584 E->setTypeInfoAsWritten(GetTypeSourceInfo(Record, Idx));
Chris Lattner4c6f9522009-04-27 05:14:47 +0000585}
586
Sebastian Redl60adf4a2010-08-18 23:56:52 +0000587void ASTStmtReader::VisitCStyleCastExpr(CStyleCastExpr *E) {
Chris Lattner4c6f9522009-04-27 05:14:47 +0000588 VisitExplicitCastExpr(E);
Sebastian Redlc3632732010-10-05 15:59:54 +0000589 E->setLParenLoc(ReadSourceLocation(Record, Idx));
590 E->setRParenLoc(ReadSourceLocation(Record, Idx));
Chris Lattner4c6f9522009-04-27 05:14:47 +0000591}
592
Sebastian Redl60adf4a2010-08-18 23:56:52 +0000593void ASTStmtReader::VisitCompoundLiteralExpr(CompoundLiteralExpr *E) {
Chris Lattner4c6f9522009-04-27 05:14:47 +0000594 VisitExpr(E);
Sebastian Redlc3632732010-10-05 15:59:54 +0000595 E->setLParenLoc(ReadSourceLocation(Record, Idx));
596 E->setTypeSourceInfo(GetTypeSourceInfo(Record, Idx));
Argyrios Kyrtzidisd98a2ab2010-06-29 22:46:25 +0000597 E->setInitializer(Reader.ReadSubExpr());
Chris Lattner4c6f9522009-04-27 05:14:47 +0000598 E->setFileScope(Record[Idx++]);
Chris Lattner4c6f9522009-04-27 05:14:47 +0000599}
600
Sebastian Redl60adf4a2010-08-18 23:56:52 +0000601void ASTStmtReader::VisitExtVectorElementExpr(ExtVectorElementExpr *E) {
Chris Lattner4c6f9522009-04-27 05:14:47 +0000602 VisitExpr(E);
Argyrios Kyrtzidisd98a2ab2010-06-29 22:46:25 +0000603 E->setBase(Reader.ReadSubExpr());
Douglas Gregor95eab172011-07-28 20:55:49 +0000604 E->setAccessor(Reader.GetIdentifierInfo(F, Record, Idx));
Sebastian Redlc3632732010-10-05 15:59:54 +0000605 E->setAccessorLoc(ReadSourceLocation(Record, Idx));
Chris Lattner4c6f9522009-04-27 05:14:47 +0000606}
607
Sebastian Redl60adf4a2010-08-18 23:56:52 +0000608void ASTStmtReader::VisitInitListExpr(InitListExpr *E) {
Chris Lattner4c6f9522009-04-27 05:14:47 +0000609 VisitExpr(E);
Argyrios Kyrtzidisd98a2ab2010-06-29 22:46:25 +0000610 E->setSyntacticForm(cast_or_null<InitListExpr>(Reader.ReadSubStmt()));
Sebastian Redlc3632732010-10-05 15:59:54 +0000611 E->setLBraceLoc(ReadSourceLocation(Record, Idx));
612 E->setRBraceLoc(ReadSourceLocation(Record, Idx));
Argyrios Kyrtzidis2ac0b7a2011-04-22 05:29:30 +0000613 bool isArrayFiller = Record[Idx++];
614 Expr *filler = 0;
615 if (isArrayFiller) {
616 filler = Reader.ReadSubExpr();
617 E->ArrayFillerOrUnionFieldInit = filler;
618 } else
Douglas Gregor409448c2011-07-21 22:35:25 +0000619 E->ArrayFillerOrUnionFieldInit = ReadDeclAs<FieldDecl>(Record, Idx);
Chris Lattner4c6f9522009-04-27 05:14:47 +0000620 E->sawArrayRangeDesignator(Record[Idx++]);
Benjamin Kramer1b1a5072012-02-27 13:20:39 +0000621 E->setInitializesStdInitializerList(Record[Idx++]);
Argyrios Kyrtzidis2ac0b7a2011-04-22 05:29:30 +0000622 unsigned NumInits = Record[Idx++];
Douglas Gregor35942772011-09-09 21:34:22 +0000623 E->reserveInits(Reader.getContext(), NumInits);
Argyrios Kyrtzidis2ac0b7a2011-04-22 05:29:30 +0000624 if (isArrayFiller) {
625 for (unsigned I = 0; I != NumInits; ++I) {
626 Expr *init = Reader.ReadSubExpr();
Douglas Gregor35942772011-09-09 21:34:22 +0000627 E->updateInit(Reader.getContext(), I, init ? init : filler);
Argyrios Kyrtzidis2ac0b7a2011-04-22 05:29:30 +0000628 }
629 } else {
630 for (unsigned I = 0; I != NumInits; ++I)
Douglas Gregor35942772011-09-09 21:34:22 +0000631 E->updateInit(Reader.getContext(), I, Reader.ReadSubExpr());
Argyrios Kyrtzidis2ac0b7a2011-04-22 05:29:30 +0000632 }
Chris Lattner4c6f9522009-04-27 05:14:47 +0000633}
634
Sebastian Redl60adf4a2010-08-18 23:56:52 +0000635void ASTStmtReader::VisitDesignatedInitExpr(DesignatedInitExpr *E) {
Chris Lattner4c6f9522009-04-27 05:14:47 +0000636 typedef DesignatedInitExpr::Designator Designator;
637
638 VisitExpr(E);
639 unsigned NumSubExprs = Record[Idx++];
640 assert(NumSubExprs == E->getNumSubExprs() && "Wrong number of subexprs");
641 for (unsigned I = 0; I != NumSubExprs; ++I)
Argyrios Kyrtzidisd98a2ab2010-06-29 22:46:25 +0000642 E->setSubExpr(I, Reader.ReadSubExpr());
Sebastian Redlc3632732010-10-05 15:59:54 +0000643 E->setEqualOrColonLoc(ReadSourceLocation(Record, Idx));
Chris Lattner4c6f9522009-04-27 05:14:47 +0000644 E->setGNUSyntax(Record[Idx++]);
645
Chris Lattner5f9e2722011-07-23 10:55:15 +0000646 SmallVector<Designator, 4> Designators;
Chris Lattner4c6f9522009-04-27 05:14:47 +0000647 while (Idx < Record.size()) {
Sebastian Redl8538e8d2010-08-18 23:57:32 +0000648 switch ((DesignatorTypes)Record[Idx++]) {
649 case DESIG_FIELD_DECL: {
Douglas Gregor409448c2011-07-21 22:35:25 +0000650 FieldDecl *Field = ReadDeclAs<FieldDecl>(Record, Idx);
Mike Stump1eb44332009-09-09 15:08:12 +0000651 SourceLocation DotLoc
Sebastian Redlc3632732010-10-05 15:59:54 +0000652 = ReadSourceLocation(Record, Idx);
Mike Stump1eb44332009-09-09 15:08:12 +0000653 SourceLocation FieldLoc
Sebastian Redlc3632732010-10-05 15:59:54 +0000654 = ReadSourceLocation(Record, Idx);
Mike Stump1eb44332009-09-09 15:08:12 +0000655 Designators.push_back(Designator(Field->getIdentifier(), DotLoc,
Chris Lattner4c6f9522009-04-27 05:14:47 +0000656 FieldLoc));
657 Designators.back().setField(Field);
658 break;
659 }
660
Sebastian Redl8538e8d2010-08-18 23:57:32 +0000661 case DESIG_FIELD_NAME: {
Douglas Gregor95eab172011-07-28 20:55:49 +0000662 const IdentifierInfo *Name = Reader.GetIdentifierInfo(F, Record, Idx);
Mike Stump1eb44332009-09-09 15:08:12 +0000663 SourceLocation DotLoc
Sebastian Redlc3632732010-10-05 15:59:54 +0000664 = ReadSourceLocation(Record, Idx);
Mike Stump1eb44332009-09-09 15:08:12 +0000665 SourceLocation FieldLoc
Sebastian Redlc3632732010-10-05 15:59:54 +0000666 = ReadSourceLocation(Record, Idx);
Chris Lattner4c6f9522009-04-27 05:14:47 +0000667 Designators.push_back(Designator(Name, DotLoc, FieldLoc));
668 break;
669 }
Mike Stump1eb44332009-09-09 15:08:12 +0000670
Sebastian Redl8538e8d2010-08-18 23:57:32 +0000671 case DESIG_ARRAY: {
Chris Lattner4c6f9522009-04-27 05:14:47 +0000672 unsigned Index = Record[Idx++];
673 SourceLocation LBracketLoc
Sebastian Redlc3632732010-10-05 15:59:54 +0000674 = ReadSourceLocation(Record, Idx);
Chris Lattner4c6f9522009-04-27 05:14:47 +0000675 SourceLocation RBracketLoc
Sebastian Redlc3632732010-10-05 15:59:54 +0000676 = ReadSourceLocation(Record, Idx);
Chris Lattner4c6f9522009-04-27 05:14:47 +0000677 Designators.push_back(Designator(Index, LBracketLoc, RBracketLoc));
678 break;
679 }
680
Sebastian Redl8538e8d2010-08-18 23:57:32 +0000681 case DESIG_ARRAY_RANGE: {
Chris Lattner4c6f9522009-04-27 05:14:47 +0000682 unsigned Index = Record[Idx++];
683 SourceLocation LBracketLoc
Sebastian Redlc3632732010-10-05 15:59:54 +0000684 = ReadSourceLocation(Record, Idx);
Chris Lattner4c6f9522009-04-27 05:14:47 +0000685 SourceLocation EllipsisLoc
Sebastian Redlc3632732010-10-05 15:59:54 +0000686 = ReadSourceLocation(Record, Idx);
Chris Lattner4c6f9522009-04-27 05:14:47 +0000687 SourceLocation RBracketLoc
Sebastian Redlc3632732010-10-05 15:59:54 +0000688 = ReadSourceLocation(Record, Idx);
Chris Lattner4c6f9522009-04-27 05:14:47 +0000689 Designators.push_back(Designator(Index, LBracketLoc, EllipsisLoc,
690 RBracketLoc));
691 break;
692 }
693 }
694 }
Douglas Gregor35942772011-09-09 21:34:22 +0000695 E->setDesignators(Reader.getContext(),
Douglas Gregor319d57f2010-01-06 23:17:19 +0000696 Designators.data(), Designators.size());
Chris Lattner4c6f9522009-04-27 05:14:47 +0000697}
698
Sebastian Redl60adf4a2010-08-18 23:56:52 +0000699void ASTStmtReader::VisitImplicitValueInitExpr(ImplicitValueInitExpr *E) {
Chris Lattner4c6f9522009-04-27 05:14:47 +0000700 VisitExpr(E);
Chris Lattner4c6f9522009-04-27 05:14:47 +0000701}
702
Sebastian Redl60adf4a2010-08-18 23:56:52 +0000703void ASTStmtReader::VisitVAArgExpr(VAArgExpr *E) {
Chris Lattner4c6f9522009-04-27 05:14:47 +0000704 VisitExpr(E);
Argyrios Kyrtzidisd98a2ab2010-06-29 22:46:25 +0000705 E->setSubExpr(Reader.ReadSubExpr());
Sebastian Redlc3632732010-10-05 15:59:54 +0000706 E->setWrittenTypeInfo(GetTypeSourceInfo(Record, Idx));
707 E->setBuiltinLoc(ReadSourceLocation(Record, Idx));
708 E->setRParenLoc(ReadSourceLocation(Record, Idx));
Chris Lattner4c6f9522009-04-27 05:14:47 +0000709}
710
Sebastian Redl60adf4a2010-08-18 23:56:52 +0000711void ASTStmtReader::VisitAddrLabelExpr(AddrLabelExpr *E) {
Chris Lattner4c6f9522009-04-27 05:14:47 +0000712 VisitExpr(E);
Sebastian Redlc3632732010-10-05 15:59:54 +0000713 E->setAmpAmpLoc(ReadSourceLocation(Record, Idx));
714 E->setLabelLoc(ReadSourceLocation(Record, Idx));
Douglas Gregor409448c2011-07-21 22:35:25 +0000715 E->setLabel(ReadDeclAs<LabelDecl>(Record, Idx));
Chris Lattner4c6f9522009-04-27 05:14:47 +0000716}
717
Sebastian Redl60adf4a2010-08-18 23:56:52 +0000718void ASTStmtReader::VisitStmtExpr(StmtExpr *E) {
Chris Lattner4c6f9522009-04-27 05:14:47 +0000719 VisitExpr(E);
Sebastian Redlc3632732010-10-05 15:59:54 +0000720 E->setLParenLoc(ReadSourceLocation(Record, Idx));
721 E->setRParenLoc(ReadSourceLocation(Record, Idx));
Argyrios Kyrtzidisd98a2ab2010-06-29 22:46:25 +0000722 E->setSubStmt(cast_or_null<CompoundStmt>(Reader.ReadSubStmt()));
Chris Lattner4c6f9522009-04-27 05:14:47 +0000723}
724
Sebastian Redl60adf4a2010-08-18 23:56:52 +0000725void ASTStmtReader::VisitChooseExpr(ChooseExpr *E) {
Chris Lattner4c6f9522009-04-27 05:14:47 +0000726 VisitExpr(E);
Argyrios Kyrtzidisd98a2ab2010-06-29 22:46:25 +0000727 E->setCond(Reader.ReadSubExpr());
728 E->setLHS(Reader.ReadSubExpr());
729 E->setRHS(Reader.ReadSubExpr());
Sebastian Redlc3632732010-10-05 15:59:54 +0000730 E->setBuiltinLoc(ReadSourceLocation(Record, Idx));
731 E->setRParenLoc(ReadSourceLocation(Record, Idx));
Chris Lattner4c6f9522009-04-27 05:14:47 +0000732}
733
Sebastian Redl60adf4a2010-08-18 23:56:52 +0000734void ASTStmtReader::VisitGNUNullExpr(GNUNullExpr *E) {
Chris Lattner4c6f9522009-04-27 05:14:47 +0000735 VisitExpr(E);
Sebastian Redlc3632732010-10-05 15:59:54 +0000736 E->setTokenLocation(ReadSourceLocation(Record, Idx));
Chris Lattner4c6f9522009-04-27 05:14:47 +0000737}
738
Sebastian Redl60adf4a2010-08-18 23:56:52 +0000739void ASTStmtReader::VisitShuffleVectorExpr(ShuffleVectorExpr *E) {
Chris Lattner4c6f9522009-04-27 05:14:47 +0000740 VisitExpr(E);
Chris Lattner5f9e2722011-07-23 10:55:15 +0000741 SmallVector<Expr *, 16> Exprs;
Chris Lattner4c6f9522009-04-27 05:14:47 +0000742 unsigned NumExprs = Record[Idx++];
Argyrios Kyrtzidis919e6932010-06-28 22:28:35 +0000743 while (NumExprs--)
Argyrios Kyrtzidisd98a2ab2010-06-29 22:46:25 +0000744 Exprs.push_back(Reader.ReadSubExpr());
Douglas Gregor35942772011-09-09 21:34:22 +0000745 E->setExprs(Reader.getContext(), Exprs.data(), Exprs.size());
Sebastian Redlc3632732010-10-05 15:59:54 +0000746 E->setBuiltinLoc(ReadSourceLocation(Record, Idx));
747 E->setRParenLoc(ReadSourceLocation(Record, Idx));
Chris Lattner4c6f9522009-04-27 05:14:47 +0000748}
749
Sebastian Redl60adf4a2010-08-18 23:56:52 +0000750void ASTStmtReader::VisitBlockExpr(BlockExpr *E) {
Chris Lattner4c6f9522009-04-27 05:14:47 +0000751 VisitExpr(E);
Douglas Gregor409448c2011-07-21 22:35:25 +0000752 E->setBlockDecl(ReadDeclAs<BlockDecl>(Record, Idx));
Chris Lattner4c6f9522009-04-27 05:14:47 +0000753}
754
Sebastian Redl60adf4a2010-08-18 23:56:52 +0000755void ASTStmtReader::VisitBlockDeclRefExpr(BlockDeclRefExpr *E) {
Chris Lattner4c6f9522009-04-27 05:14:47 +0000756 VisitExpr(E);
Douglas Gregor409448c2011-07-21 22:35:25 +0000757 E->setDecl(ReadDeclAs<VarDecl>(Record, Idx));
Sebastian Redlc3632732010-10-05 15:59:54 +0000758 E->setLocation(ReadSourceLocation(Record, Idx));
Chris Lattner4c6f9522009-04-27 05:14:47 +0000759 E->setByRef(Record[Idx++]);
Fariborz Jahanian9b0b57c2009-06-20 00:02:26 +0000760 E->setConstQualAdded(Record[Idx++]);
Chris Lattner4c6f9522009-04-27 05:14:47 +0000761}
762
Peter Collingbournef111d932011-04-15 00:35:48 +0000763void ASTStmtReader::VisitGenericSelectionExpr(GenericSelectionExpr *E) {
764 VisitExpr(E);
765 E->NumAssocs = Record[Idx++];
Douglas Gregor35942772011-09-09 21:34:22 +0000766 E->AssocTypes = new (Reader.getContext()) TypeSourceInfo*[E->NumAssocs];
Peter Collingbournef111d932011-04-15 00:35:48 +0000767 E->SubExprs =
Douglas Gregor35942772011-09-09 21:34:22 +0000768 new(Reader.getContext()) Stmt*[GenericSelectionExpr::END_EXPR+E->NumAssocs];
Peter Collingbournef111d932011-04-15 00:35:48 +0000769
770 E->SubExprs[GenericSelectionExpr::CONTROLLING] = Reader.ReadSubExpr();
771 for (unsigned I = 0, N = E->getNumAssocs(); I != N; ++I) {
772 E->AssocTypes[I] = GetTypeSourceInfo(Record, Idx);
773 E->SubExprs[GenericSelectionExpr::END_EXPR+I] = Reader.ReadSubExpr();
774 }
775 E->ResultIndex = Record[Idx++];
776
777 E->GenericLoc = ReadSourceLocation(Record, Idx);
778 E->DefaultLoc = ReadSourceLocation(Record, Idx);
779 E->RParenLoc = ReadSourceLocation(Record, Idx);
780}
781
John McCall4b9c2d22011-11-06 09:01:30 +0000782void ASTStmtReader::VisitPseudoObjectExpr(PseudoObjectExpr *E) {
783 VisitExpr(E);
784 unsigned numSemanticExprs = Record[Idx++];
785 assert(numSemanticExprs + 1 == E->PseudoObjectExprBits.NumSubExprs);
786 E->PseudoObjectExprBits.ResultIndex = Record[Idx++];
787
788 // Read the syntactic expression.
789 E->getSubExprsBuffer()[0] = Reader.ReadSubExpr();
790
791 // Read all the semantic expressions.
792 for (unsigned i = 0; i != numSemanticExprs; ++i) {
793 Expr *subExpr = Reader.ReadSubExpr();
John McCall4b9c2d22011-11-06 09:01:30 +0000794 E->getSubExprsBuffer()[i+1] = subExpr;
795 }
796}
797
Eli Friedman276b0612011-10-11 02:20:01 +0000798void ASTStmtReader::VisitAtomicExpr(AtomicExpr *E) {
799 VisitExpr(E);
800 E->setOp(AtomicExpr::AtomicOp(Record[Idx++]));
801 E->setPtr(Reader.ReadSubExpr());
802 E->setOrder(Reader.ReadSubExpr());
803 E->setNumSubExprs(2);
804 if (E->getOp() != AtomicExpr::Load) {
805 E->setVal1(Reader.ReadSubExpr());
806 E->setNumSubExprs(3);
807 }
808 if (E->isCmpXChg()) {
809 E->setOrderFail(Reader.ReadSubExpr());
810 E->setVal2(Reader.ReadSubExpr());
811 E->setNumSubExprs(5);
812 }
813 E->setBuiltinLoc(ReadSourceLocation(Record, Idx));
814 E->setRParenLoc(ReadSourceLocation(Record, Idx));
815}
816
Chris Lattner4c6f9522009-04-27 05:14:47 +0000817//===----------------------------------------------------------------------===//
818// Objective-C Expressions and Statements
819
Sebastian Redl60adf4a2010-08-18 23:56:52 +0000820void ASTStmtReader::VisitObjCStringLiteral(ObjCStringLiteral *E) {
Chris Lattner4c6f9522009-04-27 05:14:47 +0000821 VisitExpr(E);
Argyrios Kyrtzidisd98a2ab2010-06-29 22:46:25 +0000822 E->setString(cast<StringLiteral>(Reader.ReadSubStmt()));
Sebastian Redlc3632732010-10-05 15:59:54 +0000823 E->setAtLoc(ReadSourceLocation(Record, Idx));
Chris Lattner4c6f9522009-04-27 05:14:47 +0000824}
825
Ted Kremenekebcb57a2012-03-06 20:05:56 +0000826void ASTStmtReader::VisitObjCNumericLiteral(ObjCNumericLiteral *E) {
827 VisitExpr(E);
828 // could be one of several IntegerLiteral, FloatLiteral, etc.
829 E->Number = Reader.ReadSubStmt();
830 E->ObjCNumericLiteralMethod = ReadDeclAs<ObjCMethodDecl>(Record, Idx);
831 E->AtLoc = ReadSourceLocation(Record, Idx);
832}
833
834void ASTStmtReader::VisitObjCArrayLiteral(ObjCArrayLiteral *E) {
835 VisitExpr(E);
836 unsigned NumElements = Record[Idx++];
837 assert(NumElements == E->getNumElements() && "Wrong number of elements");
838 Expr **Elements = E->getElements();
839 for (unsigned I = 0, N = NumElements; I != N; ++I)
840 Elements[I] = Reader.ReadSubExpr();
841 E->ArrayWithObjectsMethod = ReadDeclAs<ObjCMethodDecl>(Record, Idx);
842 E->Range = ReadSourceRange(Record, Idx);
843}
844
845void ASTStmtReader::VisitObjCDictionaryLiteral(ObjCDictionaryLiteral *E) {
846 VisitExpr(E);
847 unsigned NumElements = Record[Idx++];
848 assert(NumElements == E->getNumElements() && "Wrong number of elements");
849 bool HasPackExpansions = Record[Idx++];
850 assert(HasPackExpansions == E->HasPackExpansions &&"Pack expansion mismatch");
851 ObjCDictionaryLiteral::KeyValuePair *KeyValues = E->getKeyValues();
852 ObjCDictionaryLiteral::ExpansionData *Expansions = E->getExpansionData();
853 for (unsigned I = 0; I != NumElements; ++I) {
854 KeyValues[I].Key = Reader.ReadSubExpr();
855 KeyValues[I].Value = Reader.ReadSubExpr();
856 if (HasPackExpansions) {
857 Expansions[I].EllipsisLoc = ReadSourceLocation(Record, Idx);
858 Expansions[I].NumExpansionsPlusOne = Record[Idx++];
859 }
860 }
861 E->DictWithObjectsMethod = ReadDeclAs<ObjCMethodDecl>(Record, Idx);
862 E->Range = ReadSourceRange(Record, Idx);
863}
864
Sebastian Redl60adf4a2010-08-18 23:56:52 +0000865void ASTStmtReader::VisitObjCEncodeExpr(ObjCEncodeExpr *E) {
Chris Lattner4c6f9522009-04-27 05:14:47 +0000866 VisitExpr(E);
Sebastian Redlc3632732010-10-05 15:59:54 +0000867 E->setEncodedTypeSourceInfo(GetTypeSourceInfo(Record, Idx));
868 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::VisitObjCSelectorExpr(ObjCSelectorExpr *E) {
Chris Lattner4c6f9522009-04-27 05:14:47 +0000873 VisitExpr(E);
Douglas Gregor2d2689a2011-07-28 21:16:51 +0000874 E->setSelector(Reader.ReadSelector(F, 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::VisitObjCProtocolExpr(ObjCProtocolExpr *E) {
Chris Lattner4c6f9522009-04-27 05:14:47 +0000880 VisitExpr(E);
Douglas Gregor409448c2011-07-21 22:35:25 +0000881 E->setProtocol(ReadDeclAs<ObjCProtocolDecl>(Record, Idx));
Sebastian Redlc3632732010-10-05 15:59:54 +0000882 E->setAtLoc(ReadSourceLocation(Record, Idx));
883 E->setRParenLoc(ReadSourceLocation(Record, Idx));
Chris Lattner4c6f9522009-04-27 05:14:47 +0000884}
885
Sebastian Redl60adf4a2010-08-18 23:56:52 +0000886void ASTStmtReader::VisitObjCIvarRefExpr(ObjCIvarRefExpr *E) {
Chris Lattner4c6f9522009-04-27 05:14:47 +0000887 VisitExpr(E);
Douglas Gregor409448c2011-07-21 22:35:25 +0000888 E->setDecl(ReadDeclAs<ObjCIvarDecl>(Record, Idx));
Sebastian Redlc3632732010-10-05 15:59:54 +0000889 E->setLocation(ReadSourceLocation(Record, Idx));
Argyrios Kyrtzidisd98a2ab2010-06-29 22:46:25 +0000890 E->setBase(Reader.ReadSubExpr());
Chris Lattner4c6f9522009-04-27 05:14:47 +0000891 E->setIsArrow(Record[Idx++]);
892 E->setIsFreeIvar(Record[Idx++]);
Chris Lattner4c6f9522009-04-27 05:14:47 +0000893}
894
Sebastian Redl60adf4a2010-08-18 23:56:52 +0000895void ASTStmtReader::VisitObjCPropertyRefExpr(ObjCPropertyRefExpr *E) {
Chris Lattner4c6f9522009-04-27 05:14:47 +0000896 VisitExpr(E);
John McCall12f78a62010-12-02 01:19:52 +0000897 bool Implicit = Record[Idx++] != 0;
898 if (Implicit) {
Douglas Gregor409448c2011-07-21 22:35:25 +0000899 ObjCMethodDecl *Getter = ReadDeclAs<ObjCMethodDecl>(Record, Idx);
900 ObjCMethodDecl *Setter = ReadDeclAs<ObjCMethodDecl>(Record, Idx);
John McCall12f78a62010-12-02 01:19:52 +0000901 E->setImplicitProperty(Getter, Setter);
902 } else {
Douglas Gregor409448c2011-07-21 22:35:25 +0000903 E->setExplicitProperty(ReadDeclAs<ObjCPropertyDecl>(Record, Idx));
Fariborz Jahanian8ac2d442010-10-14 16:04:05 +0000904 }
Sebastian Redlc3632732010-10-05 15:59:54 +0000905 E->setLocation(ReadSourceLocation(Record, Idx));
John McCall12f78a62010-12-02 01:19:52 +0000906 E->setReceiverLocation(ReadSourceLocation(Record, Idx));
907 switch (Record[Idx++]) {
908 case 0:
909 E->setBase(Reader.ReadSubExpr());
910 break;
911 case 1:
Douglas Gregor393f2492011-07-22 00:38:23 +0000912 E->setSuperReceiver(Reader.readType(F, Record, Idx));
John McCall12f78a62010-12-02 01:19:52 +0000913 break;
914 case 2:
Douglas Gregor409448c2011-07-21 22:35:25 +0000915 E->setClassReceiver(ReadDeclAs<ObjCInterfaceDecl>(Record, Idx));
John McCall12f78a62010-12-02 01:19:52 +0000916 break;
917 }
Chris Lattner4c6f9522009-04-27 05:14:47 +0000918}
919
Ted Kremenekebcb57a2012-03-06 20:05:56 +0000920void ASTStmtReader::VisitObjCSubscriptRefExpr(ObjCSubscriptRefExpr *E) {
921 VisitExpr(E);
922 E->setRBracket(ReadSourceLocation(Record, Idx));
923 E->setBaseExpr(Reader.ReadSubExpr());
924 E->setKeyExpr(Reader.ReadSubExpr());
925 E->GetAtIndexMethodDecl = ReadDeclAs<ObjCMethodDecl>(Record, Idx);
926 E->SetAtIndexMethodDecl = ReadDeclAs<ObjCMethodDecl>(Record, Idx);
927}
928
Sebastian Redl60adf4a2010-08-18 23:56:52 +0000929void ASTStmtReader::VisitObjCMessageExpr(ObjCMessageExpr *E) {
Chris Lattner4c6f9522009-04-27 05:14:47 +0000930 VisitExpr(E);
Douglas Gregor04badcf2010-04-21 00:45:42 +0000931 assert(Record[Idx] == E->getNumArgs());
932 ++Idx;
Argyrios Kyrtzidis20718082011-10-03 06:36:51 +0000933 unsigned NumStoredSelLocs = Record[Idx++];
934 E->SelLocsKind = Record[Idx++];
John McCallf85e1932011-06-15 23:02:42 +0000935 E->setDelegateInitCall(Record[Idx++]);
Argyrios Kyrtzidis746f5bc2012-01-12 02:34:39 +0000936 E->IsImplicit = Record[Idx++];
Douglas Gregor04badcf2010-04-21 00:45:42 +0000937 ObjCMessageExpr::ReceiverKind Kind
938 = static_cast<ObjCMessageExpr::ReceiverKind>(Record[Idx++]);
939 switch (Kind) {
940 case ObjCMessageExpr::Instance:
Argyrios Kyrtzidisd98a2ab2010-06-29 22:46:25 +0000941 E->setInstanceReceiver(Reader.ReadSubExpr());
Douglas Gregor04badcf2010-04-21 00:45:42 +0000942 break;
943
944 case ObjCMessageExpr::Class:
Sebastian Redlc3632732010-10-05 15:59:54 +0000945 E->setClassReceiver(GetTypeSourceInfo(Record, Idx));
Douglas Gregor04badcf2010-04-21 00:45:42 +0000946 break;
947
948 case ObjCMessageExpr::SuperClass:
949 case ObjCMessageExpr::SuperInstance: {
Douglas Gregor393f2492011-07-22 00:38:23 +0000950 QualType T = Reader.readType(F, Record, Idx);
Sebastian Redlc3632732010-10-05 15:59:54 +0000951 SourceLocation SuperLoc = ReadSourceLocation(Record, Idx);
Douglas Gregor04badcf2010-04-21 00:45:42 +0000952 E->setSuper(SuperLoc, T, Kind == ObjCMessageExpr::SuperInstance);
953 break;
954 }
955 }
956
957 assert(Kind == E->getReceiverKind());
958
959 if (Record[Idx++])
Douglas Gregor409448c2011-07-21 22:35:25 +0000960 E->setMethodDecl(ReadDeclAs<ObjCMethodDecl>(Record, Idx));
Douglas Gregor04badcf2010-04-21 00:45:42 +0000961 else
Douglas Gregor2d2689a2011-07-28 21:16:51 +0000962 E->setSelector(Reader.ReadSelector(F, Record, Idx));
Douglas Gregor04badcf2010-04-21 00:45:42 +0000963
Argyrios Kyrtzidisf40f0d52010-12-10 20:08:27 +0000964 E->LBracLoc = ReadSourceLocation(Record, Idx);
965 E->RBracLoc = ReadSourceLocation(Record, Idx);
Chris Lattner4c6f9522009-04-27 05:14:47 +0000966
967 for (unsigned I = 0, N = E->getNumArgs(); I != N; ++I)
Argyrios Kyrtzidisd98a2ab2010-06-29 22:46:25 +0000968 E->setArg(I, Reader.ReadSubExpr());
Argyrios Kyrtzidis20718082011-10-03 06:36:51 +0000969
970 SourceLocation *Locs = E->getStoredSelLocs();
971 for (unsigned I = 0; I != NumStoredSelLocs; ++I)
972 Locs[I] = ReadSourceLocation(Record, Idx);
Chris Lattner4c6f9522009-04-27 05:14:47 +0000973}
974
Sebastian Redl60adf4a2010-08-18 23:56:52 +0000975void ASTStmtReader::VisitObjCForCollectionStmt(ObjCForCollectionStmt *S) {
Chris Lattner4c6f9522009-04-27 05:14:47 +0000976 VisitStmt(S);
Argyrios Kyrtzidisd98a2ab2010-06-29 22:46:25 +0000977 S->setElement(Reader.ReadSubStmt());
978 S->setCollection(Reader.ReadSubExpr());
979 S->setBody(Reader.ReadSubStmt());
Sebastian Redlc3632732010-10-05 15:59:54 +0000980 S->setForLoc(ReadSourceLocation(Record, Idx));
981 S->setRParenLoc(ReadSourceLocation(Record, Idx));
Chris Lattner4c6f9522009-04-27 05:14:47 +0000982}
983
Sebastian Redl60adf4a2010-08-18 23:56:52 +0000984void ASTStmtReader::VisitObjCAtCatchStmt(ObjCAtCatchStmt *S) {
Chris Lattner4c6f9522009-04-27 05:14:47 +0000985 VisitStmt(S);
Argyrios Kyrtzidisd98a2ab2010-06-29 22:46:25 +0000986 S->setCatchBody(Reader.ReadSubStmt());
Douglas Gregor409448c2011-07-21 22:35:25 +0000987 S->setCatchParamDecl(ReadDeclAs<VarDecl>(Record, Idx));
Sebastian Redlc3632732010-10-05 15:59:54 +0000988 S->setAtCatchLoc(ReadSourceLocation(Record, Idx));
989 S->setRParenLoc(ReadSourceLocation(Record, Idx));
Chris Lattner4c6f9522009-04-27 05:14:47 +0000990}
991
Sebastian Redl60adf4a2010-08-18 23:56:52 +0000992void ASTStmtReader::VisitObjCAtFinallyStmt(ObjCAtFinallyStmt *S) {
Chris Lattner4c6f9522009-04-27 05:14:47 +0000993 VisitStmt(S);
Argyrios Kyrtzidisd98a2ab2010-06-29 22:46:25 +0000994 S->setFinallyBody(Reader.ReadSubStmt());
Sebastian Redlc3632732010-10-05 15:59:54 +0000995 S->setAtFinallyLoc(ReadSourceLocation(Record, Idx));
Chris Lattner4c6f9522009-04-27 05:14:47 +0000996}
997
John McCallf85e1932011-06-15 23:02:42 +0000998void ASTStmtReader::VisitObjCAutoreleasePoolStmt(ObjCAutoreleasePoolStmt *S) {
999 VisitStmt(S);
1000 S->setSubStmt(Reader.ReadSubStmt());
1001 S->setAtLoc(ReadSourceLocation(Record, Idx));
1002}
1003
Sebastian Redl60adf4a2010-08-18 23:56:52 +00001004void ASTStmtReader::VisitObjCAtTryStmt(ObjCAtTryStmt *S) {
Chris Lattner4c6f9522009-04-27 05:14:47 +00001005 VisitStmt(S);
Douglas Gregor8f5e3dd2010-04-23 22:50:49 +00001006 assert(Record[Idx] == S->getNumCatchStmts());
1007 ++Idx;
1008 bool HasFinally = Record[Idx++];
Argyrios Kyrtzidisd98a2ab2010-06-29 22:46:25 +00001009 S->setTryBody(Reader.ReadSubStmt());
Argyrios Kyrtzidis919e6932010-06-28 22:28:35 +00001010 for (unsigned I = 0, N = S->getNumCatchStmts(); I != N; ++I)
Argyrios Kyrtzidisd98a2ab2010-06-29 22:46:25 +00001011 S->setCatchStmt(I, cast_or_null<ObjCAtCatchStmt>(Reader.ReadSubStmt()));
Douglas Gregor8f5e3dd2010-04-23 22:50:49 +00001012
Douglas Gregor8f5e3dd2010-04-23 22:50:49 +00001013 if (HasFinally)
Argyrios Kyrtzidisd98a2ab2010-06-29 22:46:25 +00001014 S->setFinallyStmt(Reader.ReadSubStmt());
Sebastian Redlc3632732010-10-05 15:59:54 +00001015 S->setAtTryLoc(ReadSourceLocation(Record, Idx));
Chris Lattner4c6f9522009-04-27 05:14:47 +00001016}
1017
Sebastian Redl60adf4a2010-08-18 23:56:52 +00001018void ASTStmtReader::VisitObjCAtSynchronizedStmt(ObjCAtSynchronizedStmt *S) {
Chris Lattner4c6f9522009-04-27 05:14:47 +00001019 VisitStmt(S);
Argyrios Kyrtzidisd98a2ab2010-06-29 22:46:25 +00001020 S->setSynchExpr(Reader.ReadSubStmt());
1021 S->setSynchBody(Reader.ReadSubStmt());
Sebastian Redlc3632732010-10-05 15:59:54 +00001022 S->setAtSynchronizedLoc(ReadSourceLocation(Record, Idx));
Chris Lattner4c6f9522009-04-27 05:14:47 +00001023}
1024
Sebastian Redl60adf4a2010-08-18 23:56:52 +00001025void ASTStmtReader::VisitObjCAtThrowStmt(ObjCAtThrowStmt *S) {
Chris Lattner4c6f9522009-04-27 05:14:47 +00001026 VisitStmt(S);
Argyrios Kyrtzidisd98a2ab2010-06-29 22:46:25 +00001027 S->setThrowExpr(Reader.ReadSubStmt());
Sebastian Redlc3632732010-10-05 15:59:54 +00001028 S->setThrowLoc(ReadSourceLocation(Record, Idx));
Chris Lattner4c6f9522009-04-27 05:14:47 +00001029}
1030
Ted Kremenekebcb57a2012-03-06 20:05:56 +00001031void ASTStmtReader::VisitObjCBoolLiteralExpr(ObjCBoolLiteralExpr *E) {
1032 VisitExpr(E);
1033 E->setValue(Record[Idx++]);
1034 E->setLocation(ReadSourceLocation(Record, Idx));
1035}
1036
Argyrios Kyrtzidisba0a9002009-07-14 03:19:21 +00001037//===----------------------------------------------------------------------===//
1038// C++ Expressions and Statements
Argyrios Kyrtzidis7cb45e32010-07-22 16:03:56 +00001039//===----------------------------------------------------------------------===//
1040
Sebastian Redl60adf4a2010-08-18 23:56:52 +00001041void ASTStmtReader::VisitCXXCatchStmt(CXXCatchStmt *S) {
Argyrios Kyrtzidis7cb45e32010-07-22 16:03:56 +00001042 VisitStmt(S);
Sebastian Redlc3632732010-10-05 15:59:54 +00001043 S->CatchLoc = ReadSourceLocation(Record, Idx);
Douglas Gregor409448c2011-07-21 22:35:25 +00001044 S->ExceptionDecl = ReadDeclAs<VarDecl>(Record, Idx);
Argyrios Kyrtzidis7cb45e32010-07-22 16:03:56 +00001045 S->HandlerBlock = Reader.ReadSubStmt();
1046}
1047
Sebastian Redl60adf4a2010-08-18 23:56:52 +00001048void ASTStmtReader::VisitCXXTryStmt(CXXTryStmt *S) {
Argyrios Kyrtzidis7cb45e32010-07-22 16:03:56 +00001049 VisitStmt(S);
1050 assert(Record[Idx] == S->getNumHandlers() && "NumStmtFields is wrong ?");
1051 ++Idx;
Sebastian Redlc3632732010-10-05 15:59:54 +00001052 S->TryLoc = ReadSourceLocation(Record, Idx);
Argyrios Kyrtzidis7cb45e32010-07-22 16:03:56 +00001053 S->getStmts()[0] = Reader.ReadSubStmt();
1054 for (unsigned i = 0, e = S->getNumHandlers(); i != e; ++i)
1055 S->getStmts()[i + 1] = Reader.ReadSubStmt();
1056}
Argyrios Kyrtzidisba0a9002009-07-14 03:19:21 +00001057
Richard Smithad762fc2011-04-14 22:09:26 +00001058void ASTStmtReader::VisitCXXForRangeStmt(CXXForRangeStmt *S) {
1059 VisitStmt(S);
1060 S->setForLoc(ReadSourceLocation(Record, Idx));
1061 S->setColonLoc(ReadSourceLocation(Record, Idx));
1062 S->setRParenLoc(ReadSourceLocation(Record, Idx));
1063 S->setRangeStmt(Reader.ReadSubStmt());
1064 S->setBeginEndStmt(Reader.ReadSubStmt());
1065 S->setCond(Reader.ReadSubExpr());
1066 S->setInc(Reader.ReadSubExpr());
1067 S->setLoopVarStmt(Reader.ReadSubStmt());
1068 S->setBody(Reader.ReadSubStmt());
1069}
1070
Douglas Gregorba0513d2011-10-25 01:33:02 +00001071void ASTStmtReader::VisitMSDependentExistsStmt(MSDependentExistsStmt *S) {
1072 VisitStmt(S);
1073 S->KeywordLoc = ReadSourceLocation(Record, Idx);
1074 S->IsIfExists = Record[Idx++];
1075 S->QualifierLoc = Reader.ReadNestedNameSpecifierLoc(F, Record, Idx);
1076 ReadDeclarationNameInfo(S->NameInfo, Record, Idx);
1077 S->SubStmt = Reader.ReadSubStmt();
1078}
1079
Sebastian Redl60adf4a2010-08-18 23:56:52 +00001080void ASTStmtReader::VisitCXXOperatorCallExpr(CXXOperatorCallExpr *E) {
Argyrios Kyrtzidis919e6932010-06-28 22:28:35 +00001081 VisitCallExpr(E);
Argyrios Kyrtzidisba0a9002009-07-14 03:19:21 +00001082 E->setOperator((OverloadedOperatorKind)Record[Idx++]);
Argyrios Kyrtzidisba0a9002009-07-14 03:19:21 +00001083}
1084
Sebastian Redl60adf4a2010-08-18 23:56:52 +00001085void ASTStmtReader::VisitCXXConstructExpr(CXXConstructExpr *E) {
Douglas Gregor39da0b82009-09-09 23:08:42 +00001086 VisitExpr(E);
Argyrios Kyrtzidis6d00c132010-07-10 11:46:15 +00001087 E->NumArgs = Record[Idx++];
1088 if (E->NumArgs)
Douglas Gregor35942772011-09-09 21:34:22 +00001089 E->Args = new (Reader.getContext()) Stmt*[E->NumArgs];
Argyrios Kyrtzidis5e1b7c22010-06-24 08:57:09 +00001090 for (unsigned I = 0, N = E->getNumArgs(); I != N; ++I)
Argyrios Kyrtzidisd98a2ab2010-06-29 22:46:25 +00001091 E->setArg(I, Reader.ReadSubExpr());
Douglas Gregor409448c2011-07-21 22:35:25 +00001092 E->setConstructor(ReadDeclAs<CXXConstructorDecl>(Record, Idx));
Sebastian Redlc3632732010-10-05 15:59:54 +00001093 E->setLocation(ReadSourceLocation(Record, Idx));
Abramo Bagnara7cc58b42011-10-05 07:56:41 +00001094 E->setElidable(Record[Idx++]);
1095 E->setHadMultipleCandidates(Record[Idx++]);
Douglas Gregor16006c92009-12-16 18:50:27 +00001096 E->setRequiresZeroInitialization(Record[Idx++]);
Douglas Gregor3c9034c2010-05-15 00:13:29 +00001097 E->setConstructionKind((CXXConstructExpr::ConstructionKind)Record[Idx++]);
Chandler Carruth428edaf2010-10-25 08:47:36 +00001098 E->ParenRange = ReadSourceRange(Record, Idx);
Douglas Gregor39da0b82009-09-09 23:08:42 +00001099}
Chris Lattner4c6f9522009-04-27 05:14:47 +00001100
Sebastian Redl60adf4a2010-08-18 23:56:52 +00001101void ASTStmtReader::VisitCXXTemporaryObjectExpr(CXXTemporaryObjectExpr *E) {
Argyrios Kyrtzidis6d00c132010-07-10 11:46:15 +00001102 VisitCXXConstructExpr(E);
Sebastian Redlc3632732010-10-05 15:59:54 +00001103 E->Type = GetTypeSourceInfo(Record, Idx);
Argyrios Kyrtzidis6d00c132010-07-10 11:46:15 +00001104}
1105
Douglas Gregor01d08012012-02-07 10:09:13 +00001106void ASTStmtReader::VisitLambdaExpr(LambdaExpr *E) {
1107 VisitExpr(E);
Douglas Gregor9d36f5d2012-02-14 17:54:36 +00001108 unsigned NumCaptures = Record[Idx++];
1109 assert(NumCaptures == E->NumCaptures);(void)NumCaptures;
1110 unsigned NumArrayIndexVars = Record[Idx++];
1111 E->IntroducerRange = ReadSourceRange(Record, Idx);
1112 E->CaptureDefault = static_cast<LambdaCaptureDefault>(Record[Idx++]);
1113 E->ExplicitParams = Record[Idx++];
1114 E->ExplicitResultType = Record[Idx++];
1115 E->ClosingBrace = ReadSourceLocation(Record, Idx);
1116
1117 // Read capture initializers.
1118 for (LambdaExpr::capture_init_iterator C = E->capture_init_begin(),
1119 CEnd = E->capture_init_end();
1120 C != CEnd; ++C)
1121 *C = Reader.ReadSubExpr();
1122
1123 // Read array capture index variables.
1124 if (NumArrayIndexVars > 0) {
1125 unsigned *ArrayIndexStarts = E->getArrayIndexStarts();
1126 for (unsigned I = 0; I != NumCaptures + 1; ++I)
1127 ArrayIndexStarts[I] = Record[Idx++];
1128
1129 VarDecl **ArrayIndexVars = E->getArrayIndexVars();
1130 for (unsigned I = 0; I != NumArrayIndexVars; ++I)
1131 ArrayIndexVars[I] = ReadDeclAs<VarDecl>(Record, Idx);
1132 }
Douglas Gregor01d08012012-02-07 10:09:13 +00001133}
1134
Sebastian Redl60adf4a2010-08-18 23:56:52 +00001135void ASTStmtReader::VisitCXXNamedCastExpr(CXXNamedCastExpr *E) {
Argyrios Kyrtzidis919e6932010-06-28 22:28:35 +00001136 VisitExplicitCastExpr(E);
Douglas Gregor1d5d0b92011-01-12 22:41:29 +00001137 SourceRange R = ReadSourceRange(Record, Idx);
1138 E->Loc = R.getBegin();
1139 E->RParenLoc = R.getEnd();
Sam Weinigce757a72010-01-16 21:21:01 +00001140}
1141
Sebastian Redl60adf4a2010-08-18 23:56:52 +00001142void ASTStmtReader::VisitCXXStaticCastExpr(CXXStaticCastExpr *E) {
Sam Weinigce757a72010-01-16 21:21:01 +00001143 return VisitCXXNamedCastExpr(E);
1144}
1145
Sebastian Redl60adf4a2010-08-18 23:56:52 +00001146void ASTStmtReader::VisitCXXDynamicCastExpr(CXXDynamicCastExpr *E) {
Sam Weinigce757a72010-01-16 21:21:01 +00001147 return VisitCXXNamedCastExpr(E);
1148}
1149
Sebastian Redl60adf4a2010-08-18 23:56:52 +00001150void ASTStmtReader::VisitCXXReinterpretCastExpr(CXXReinterpretCastExpr *E) {
Sam Weinigce757a72010-01-16 21:21:01 +00001151 return VisitCXXNamedCastExpr(E);
1152}
1153
Sebastian Redl60adf4a2010-08-18 23:56:52 +00001154void ASTStmtReader::VisitCXXConstCastExpr(CXXConstCastExpr *E) {
Sam Weinigce757a72010-01-16 21:21:01 +00001155 return VisitCXXNamedCastExpr(E);
1156}
1157
Sebastian Redl60adf4a2010-08-18 23:56:52 +00001158void ASTStmtReader::VisitCXXFunctionalCastExpr(CXXFunctionalCastExpr *E) {
Argyrios Kyrtzidis919e6932010-06-28 22:28:35 +00001159 VisitExplicitCastExpr(E);
Sebastian Redlc3632732010-10-05 15:59:54 +00001160 E->setTypeBeginLoc(ReadSourceLocation(Record, Idx));
1161 E->setRParenLoc(ReadSourceLocation(Record, Idx));
Sam Weinigce757a72010-01-16 21:21:01 +00001162}
1163
Richard Smith9fcce652012-03-07 08:35:16 +00001164void ASTStmtReader::VisitUserDefinedLiteral(UserDefinedLiteral *E) {
1165 VisitCallExpr(E);
1166 E->UDSuffixLoc = ReadSourceLocation(Record, Idx);
1167}
1168
Sebastian Redl60adf4a2010-08-18 23:56:52 +00001169void ASTStmtReader::VisitCXXBoolLiteralExpr(CXXBoolLiteralExpr *E) {
Sam Weinigeb7f9612010-02-07 06:32:43 +00001170 VisitExpr(E);
1171 E->setValue(Record[Idx++]);
Sebastian Redlc3632732010-10-05 15:59:54 +00001172 E->setLocation(ReadSourceLocation(Record, Idx));
Sam Weinigeb7f9612010-02-07 06:32:43 +00001173}
1174
Sebastian Redl60adf4a2010-08-18 23:56:52 +00001175void ASTStmtReader::VisitCXXNullPtrLiteralExpr(CXXNullPtrLiteralExpr *E) {
Sam Weinigeb7f9612010-02-07 06:32:43 +00001176 VisitExpr(E);
Sebastian Redlc3632732010-10-05 15:59:54 +00001177 E->setLocation(ReadSourceLocation(Record, Idx));
Sam Weinigeb7f9612010-02-07 06:32:43 +00001178}
1179
Sebastian Redl60adf4a2010-08-18 23:56:52 +00001180void ASTStmtReader::VisitCXXTypeidExpr(CXXTypeidExpr *E) {
Chris Lattner14ab24f2010-05-09 06:03:39 +00001181 VisitExpr(E);
Sebastian Redlc3632732010-10-05 15:59:54 +00001182 E->setSourceRange(ReadSourceRange(Record, Idx));
Chris Lattner14ab24f2010-05-09 06:03:39 +00001183 if (E->isTypeOperand()) { // typeid(int)
Sebastian Redl577d4792010-07-22 22:43:28 +00001184 E->setTypeOperandSourceInfo(
Sebastian Redlc3632732010-10-05 15:59:54 +00001185 GetTypeSourceInfo(Record, Idx));
Argyrios Kyrtzidis919e6932010-06-28 22:28:35 +00001186 return;
Chris Lattner14ab24f2010-05-09 06:03:39 +00001187 }
1188
1189 // typeid(42+2)
Argyrios Kyrtzidisd98a2ab2010-06-29 22:46:25 +00001190 E->setExprOperand(Reader.ReadSubExpr());
Chris Lattner14ab24f2010-05-09 06:03:39 +00001191}
1192
Sebastian Redl60adf4a2010-08-18 23:56:52 +00001193void ASTStmtReader::VisitCXXThisExpr(CXXThisExpr *E) {
Chris Lattner2fbdfcd2010-05-09 06:15:05 +00001194 VisitExpr(E);
Sebastian Redlc3632732010-10-05 15:59:54 +00001195 E->setLocation(ReadSourceLocation(Record, Idx));
Chris Lattner2fbdfcd2010-05-09 06:15:05 +00001196 E->setImplicit(Record[Idx++]);
Chris Lattner2fbdfcd2010-05-09 06:15:05 +00001197}
1198
Sebastian Redl60adf4a2010-08-18 23:56:52 +00001199void ASTStmtReader::VisitCXXThrowExpr(CXXThrowExpr *E) {
Chris Lattner2fbdfcd2010-05-09 06:15:05 +00001200 VisitExpr(E);
Douglas Gregorbca01b42011-07-06 22:04:06 +00001201 E->ThrowLoc = ReadSourceLocation(Record, Idx);
1202 E->Op = Reader.ReadSubExpr();
1203 E->IsThrownVariableInScope = Record[Idx++];
Chris Lattner2fbdfcd2010-05-09 06:15:05 +00001204}
Chris Lattner14ab24f2010-05-09 06:03:39 +00001205
Sebastian Redl60adf4a2010-08-18 23:56:52 +00001206void ASTStmtReader::VisitCXXDefaultArgExpr(CXXDefaultArgExpr *E) {
Chris Lattner030854b2010-05-09 06:40:08 +00001207 VisitExpr(E);
Argyrios Kyrtzidis8a507332010-07-02 23:30:15 +00001208
Douglas Gregordf226552011-09-23 22:07:41 +00001209 assert((bool)Record[Idx] == E->Param.getInt() && "We messed up at creation ?");
Argyrios Kyrtzidis8a507332010-07-02 23:30:15 +00001210 ++Idx; // HasOtherExprStored and SubExpr was handled during creation.
Douglas Gregor409448c2011-07-21 22:35:25 +00001211 E->Param.setPointer(ReadDeclAs<ParmVarDecl>(Record, Idx));
Sebastian Redlc3632732010-10-05 15:59:54 +00001212 E->Loc = ReadSourceLocation(Record, Idx);
Chris Lattnerd2598362010-05-10 00:25:06 +00001213}
1214
Sebastian Redl60adf4a2010-08-18 23:56:52 +00001215void ASTStmtReader::VisitCXXBindTemporaryExpr(CXXBindTemporaryExpr *E) {
Chris Lattnerd2598362010-05-10 00:25:06 +00001216 VisitExpr(E);
Douglas Gregor409448c2011-07-21 22:35:25 +00001217 E->setTemporary(Reader.ReadCXXTemporary(F, Record, Idx));
Argyrios Kyrtzidisd98a2ab2010-06-29 22:46:25 +00001218 E->setSubExpr(Reader.ReadSubExpr());
Chris Lattnerd2598362010-05-10 00:25:06 +00001219}
1220
Sebastian Redl60adf4a2010-08-18 23:56:52 +00001221void ASTStmtReader::VisitCXXScalarValueInitExpr(CXXScalarValueInitExpr *E) {
Chris Lattner59218632010-05-10 01:22:27 +00001222 VisitExpr(E);
Sebastian Redlc3632732010-10-05 15:59:54 +00001223 E->TypeInfo = GetTypeSourceInfo(Record, Idx);
1224 E->RParenLoc = ReadSourceLocation(Record, Idx);
Chris Lattner59218632010-05-10 01:22:27 +00001225}
1226
Sebastian Redl60adf4a2010-08-18 23:56:52 +00001227void ASTStmtReader::VisitCXXNewExpr(CXXNewExpr *E) {
Chris Lattner59218632010-05-10 01:22:27 +00001228 VisitExpr(E);
John McCall6ec278d2011-01-27 09:37:56 +00001229 E->GlobalNew = Record[Idx++];
Sebastian Redl1548d142012-02-16 11:35:52 +00001230 bool isArray = Record[Idx++];
Sebastian Redl2aed8b82012-02-16 12:22:20 +00001231 E->UsualArrayDeleteWantsSize = Record[Idx++];
Chris Lattner59218632010-05-10 01:22:27 +00001232 unsigned NumPlacementArgs = Record[Idx++];
Sebastian Redl2aed8b82012-02-16 12:22:20 +00001233 E->StoredInitializationStyle = Record[Idx++];
Douglas Gregor409448c2011-07-21 22:35:25 +00001234 E->setOperatorNew(ReadDeclAs<FunctionDecl>(Record, Idx));
1235 E->setOperatorDelete(ReadDeclAs<FunctionDecl>(Record, Idx));
Sebastian Redlc3632732010-10-05 15:59:54 +00001236 E->AllocatedTypeInfo = GetTypeSourceInfo(Record, Idx);
Douglas Gregor83bc2762012-02-20 16:12:14 +00001237 E->TypeIdParens = ReadSourceRange(Record, Idx);
Chandler Carruth428edaf2010-10-25 08:47:36 +00001238 E->StartLoc = ReadSourceLocation(Record, Idx);
Douglas Gregor83bc2762012-02-20 16:12:14 +00001239 E->DirectInitRange = ReadSourceRange(Record, Idx);
Chandler Carruth428edaf2010-10-25 08:47:36 +00001240
Douglas Gregor35942772011-09-09 21:34:22 +00001241 E->AllocateArgsArray(Reader.getContext(), isArray, NumPlacementArgs,
Sebastian Redl2aed8b82012-02-16 12:22:20 +00001242 E->StoredInitializationStyle != 0);
Chris Lattner59218632010-05-10 01:22:27 +00001243
1244 // Install all the subexpressions.
Chris Lattner59218632010-05-10 01:22:27 +00001245 for (CXXNewExpr::raw_arg_iterator I = E->raw_arg_begin(),e = E->raw_arg_end();
1246 I != e; ++I)
Argyrios Kyrtzidisd98a2ab2010-06-29 22:46:25 +00001247 *I = Reader.ReadSubStmt();
Chris Lattner59218632010-05-10 01:22:27 +00001248}
1249
Sebastian Redl60adf4a2010-08-18 23:56:52 +00001250void ASTStmtReader::VisitCXXDeleteExpr(CXXDeleteExpr *E) {
Argyrios Kyrtzidis95fc98c2010-06-22 17:07:59 +00001251 VisitExpr(E);
Argyrios Kyrtzidisf1b89112010-09-13 20:15:40 +00001252 E->GlobalDelete = Record[Idx++];
1253 E->ArrayForm = Record[Idx++];
Argyrios Kyrtzidis4076dac2010-09-13 20:15:54 +00001254 E->ArrayFormAsWritten = Record[Idx++];
John McCall6ec278d2011-01-27 09:37:56 +00001255 E->UsualArrayDeleteWantsSize = Record[Idx++];
Douglas Gregor409448c2011-07-21 22:35:25 +00001256 E->OperatorDelete = ReadDeclAs<FunctionDecl>(Record, Idx);
Argyrios Kyrtzidisf1b89112010-09-13 20:15:40 +00001257 E->Argument = Reader.ReadSubExpr();
Sebastian Redlc3632732010-10-05 15:59:54 +00001258 E->Loc = ReadSourceLocation(Record, Idx);
Argyrios Kyrtzidis95fc98c2010-06-22 17:07:59 +00001259}
Chris Lattnerd2598362010-05-10 00:25:06 +00001260
Sebastian Redl60adf4a2010-08-18 23:56:52 +00001261void ASTStmtReader::VisitCXXPseudoDestructorExpr(CXXPseudoDestructorExpr *E) {
Argyrios Kyrtzidisde4bd182010-06-28 09:32:03 +00001262 VisitExpr(E);
1263
Douglas Gregorf3db29f2011-02-25 18:19:59 +00001264 E->Base = Reader.ReadSubExpr();
1265 E->IsArrow = Record[Idx++];
1266 E->OperatorLoc = ReadSourceLocation(Record, Idx);
1267 E->QualifierLoc = Reader.ReadNestedNameSpecifierLoc(F, Record, Idx);
1268 E->ScopeType = GetTypeSourceInfo(Record, Idx);
1269 E->ColonColonLoc = ReadSourceLocation(Record, Idx);
1270 E->TildeLoc = ReadSourceLocation(Record, Idx);
Argyrios Kyrtzidisde4bd182010-06-28 09:32:03 +00001271
Douglas Gregor95eab172011-07-28 20:55:49 +00001272 IdentifierInfo *II = Reader.GetIdentifierInfo(F, Record, Idx);
Argyrios Kyrtzidisde4bd182010-06-28 09:32:03 +00001273 if (II)
Sebastian Redlc3632732010-10-05 15:59:54 +00001274 E->setDestroyedType(II, ReadSourceLocation(Record, Idx));
Argyrios Kyrtzidisde4bd182010-06-28 09:32:03 +00001275 else
Sebastian Redlc3632732010-10-05 15:59:54 +00001276 E->setDestroyedType(GetTypeSourceInfo(Record, Idx));
Argyrios Kyrtzidisde4bd182010-06-28 09:32:03 +00001277}
1278
John McCall4765fa02010-12-06 08:20:24 +00001279void ASTStmtReader::VisitExprWithCleanups(ExprWithCleanups *E) {
Chris Lattnerd2598362010-05-10 00:25:06 +00001280 VisitExpr(E);
John McCall80ee6e82011-11-10 05:35:25 +00001281
1282 unsigned NumObjects = Record[Idx++];
1283 assert(NumObjects == E->getNumObjects());
1284 for (unsigned i = 0; i != NumObjects; ++i)
1285 E->getObjectsBuffer()[i] = ReadDeclAs<BlockDecl>(Record, Idx);
1286
1287 E->SubExpr = Reader.ReadSubExpr();
Chris Lattner030854b2010-05-09 06:40:08 +00001288}
1289
Argyrios Kyrtzidis919e6932010-06-28 22:28:35 +00001290void
Sebastian Redl60adf4a2010-08-18 23:56:52 +00001291ASTStmtReader::VisitCXXDependentScopeMemberExpr(CXXDependentScopeMemberExpr *E){
Argyrios Kyrtzidis8dfbd8b2010-06-24 08:57:31 +00001292 VisitExpr(E);
Abramo Bagnarae4b92762012-01-27 09:46:47 +00001293
1294 if (Record[Idx++]) // HasTemplateKWAndArgsInfo
1295 ReadTemplateKWAndArgsInfo(*E->getTemplateKWAndArgsInfo(),
1296 /*NumTemplateArgs=*/Record[Idx++]);
Argyrios Kyrtzidis8dfbd8b2010-06-24 08:57:31 +00001297
Douglas Gregor7c3179c2011-02-28 18:50:33 +00001298 E->Base = Reader.ReadSubExpr();
Douglas Gregor393f2492011-07-22 00:38:23 +00001299 E->BaseType = Reader.readType(F, Record, Idx);
Douglas Gregor7c3179c2011-02-28 18:50:33 +00001300 E->IsArrow = Record[Idx++];
1301 E->OperatorLoc = ReadSourceLocation(Record, Idx);
1302 E->QualifierLoc = Reader.ReadNestedNameSpecifierLoc(F, Record, Idx);
Douglas Gregor409448c2011-07-21 22:35:25 +00001303 E->FirstQualifierFoundInScope = ReadDeclAs<NamedDecl>(Record, Idx);
Argyrios Kyrtzidis40451072010-10-15 18:21:24 +00001304 ReadDeclarationNameInfo(E->MemberNameInfo, Record, Idx);
Argyrios Kyrtzidis8dfbd8b2010-06-24 08:57:31 +00001305}
1306
Argyrios Kyrtzidis919e6932010-06-28 22:28:35 +00001307void
Sebastian Redl60adf4a2010-08-18 23:56:52 +00001308ASTStmtReader::VisitDependentScopeDeclRefExpr(DependentScopeDeclRefExpr *E) {
Argyrios Kyrtzidis12dffcd2010-06-28 09:31:56 +00001309 VisitExpr(E);
Abramo Bagnarae4b92762012-01-27 09:46:47 +00001310
1311 if (Record[Idx++]) // HasTemplateKWAndArgsInfo
1312 ReadTemplateKWAndArgsInfo(*E->getTemplateKWAndArgsInfo(),
1313 /*NumTemplateArgs=*/Record[Idx++]);
Douglas Gregor00cf3cc2011-02-25 20:49:16 +00001314
1315 E->QualifierLoc = Reader.ReadNestedNameSpecifierLoc(F, Record, Idx);
Argyrios Kyrtzidis40451072010-10-15 18:21:24 +00001316 ReadDeclarationNameInfo(E->NameInfo, Record, Idx);
Argyrios Kyrtzidis12dffcd2010-06-28 09:31:56 +00001317}
1318
Argyrios Kyrtzidis919e6932010-06-28 22:28:35 +00001319void
Sebastian Redl60adf4a2010-08-18 23:56:52 +00001320ASTStmtReader::VisitCXXUnresolvedConstructExpr(CXXUnresolvedConstructExpr *E) {
Argyrios Kyrtzidis8dfbd8b2010-06-24 08:57:31 +00001321 VisitExpr(E);
1322 assert(Record[Idx] == E->arg_size() && "Read wrong record during creation ?");
1323 ++Idx; // NumArgs;
1324 for (unsigned I = 0, N = E->arg_size(); I != N; ++I)
Argyrios Kyrtzidisd98a2ab2010-06-29 22:46:25 +00001325 E->setArg(I, Reader.ReadSubExpr());
Sebastian Redlc3632732010-10-05 15:59:54 +00001326 E->Type = GetTypeSourceInfo(Record, Idx);
1327 E->setLParenLoc(ReadSourceLocation(Record, Idx));
1328 E->setRParenLoc(ReadSourceLocation(Record, Idx));
Argyrios Kyrtzidis8dfbd8b2010-06-24 08:57:31 +00001329}
1330
Sebastian Redl60adf4a2010-08-18 23:56:52 +00001331void ASTStmtReader::VisitOverloadExpr(OverloadExpr *E) {
Argyrios Kyrtzidisa77eb082010-06-25 09:03:26 +00001332 VisitExpr(E);
Abramo Bagnarae4b92762012-01-27 09:46:47 +00001333
1334 if (Record[Idx++]) // HasTemplateKWAndArgsInfo
1335 ReadTemplateKWAndArgsInfo(*E->getTemplateKWAndArgsInfo(),
1336 /*NumTemplateArgs=*/Record[Idx++]);
Argyrios Kyrtzidisa77eb082010-06-25 09:03:26 +00001337
1338 unsigned NumDecls = Record[Idx++];
1339 UnresolvedSet<8> Decls;
1340 for (unsigned i = 0; i != NumDecls; ++i) {
Douglas Gregor409448c2011-07-21 22:35:25 +00001341 NamedDecl *D = ReadDeclAs<NamedDecl>(Record, Idx);
Argyrios Kyrtzidisa77eb082010-06-25 09:03:26 +00001342 AccessSpecifier AS = (AccessSpecifier)Record[Idx++];
1343 Decls.addDecl(D, AS);
1344 }
Douglas Gregor35942772011-09-09 21:34:22 +00001345 E->initializeResults(Reader.getContext(), Decls.begin(), Decls.end());
Argyrios Kyrtzidisa77eb082010-06-25 09:03:26 +00001346
Argyrios Kyrtzidis40451072010-10-15 18:21:24 +00001347 ReadDeclarationNameInfo(E->NameInfo, Record, Idx);
Douglas Gregor4c9be892011-02-28 20:01:57 +00001348 E->QualifierLoc = Reader.ReadNestedNameSpecifierLoc(F, Record, Idx);
Argyrios Kyrtzidisa77eb082010-06-25 09:03:26 +00001349}
1350
Sebastian Redl60adf4a2010-08-18 23:56:52 +00001351void ASTStmtReader::VisitUnresolvedMemberExpr(UnresolvedMemberExpr *E) {
Argyrios Kyrtzidis919e6932010-06-28 22:28:35 +00001352 VisitOverloadExpr(E);
Douglas Gregor4c9be892011-02-28 20:01:57 +00001353 E->IsArrow = Record[Idx++];
1354 E->HasUnresolvedUsing = Record[Idx++];
1355 E->Base = Reader.ReadSubExpr();
Douglas Gregor393f2492011-07-22 00:38:23 +00001356 E->BaseType = Reader.readType(F, Record, Idx);
Douglas Gregor4c9be892011-02-28 20:01:57 +00001357 E->OperatorLoc = ReadSourceLocation(Record, Idx);
Argyrios Kyrtzidisa77eb082010-06-25 09:03:26 +00001358}
1359
Sebastian Redl60adf4a2010-08-18 23:56:52 +00001360void ASTStmtReader::VisitUnresolvedLookupExpr(UnresolvedLookupExpr *E) {
Argyrios Kyrtzidis919e6932010-06-28 22:28:35 +00001361 VisitOverloadExpr(E);
Douglas Gregor4c9be892011-02-28 20:01:57 +00001362 E->RequiresADL = Record[Idx++];
Richard Smithad762fc2011-04-14 22:09:26 +00001363 if (E->RequiresADL)
1364 E->StdIsAssociatedNamespace = Record[Idx++];
Douglas Gregor4c9be892011-02-28 20:01:57 +00001365 E->Overloaded = Record[Idx++];
Douglas Gregor409448c2011-07-21 22:35:25 +00001366 E->NamingClass = ReadDeclAs<CXXRecordDecl>(Record, Idx);
Argyrios Kyrtzidisbd65bb52010-06-25 09:03:34 +00001367}
1368
Sebastian Redl60adf4a2010-08-18 23:56:52 +00001369void ASTStmtReader::VisitUnaryTypeTraitExpr(UnaryTypeTraitExpr *E) {
Argyrios Kyrtzidis6d00c132010-07-10 11:46:15 +00001370 VisitExpr(E);
1371 E->UTT = (UnaryTypeTrait)Record[Idx++];
Sebastian Redl0dfd8482010-09-13 20:56:31 +00001372 E->Value = (bool)Record[Idx++];
Sebastian Redlc3632732010-10-05 15:59:54 +00001373 SourceRange Range = ReadSourceRange(Record, Idx);
Argyrios Kyrtzidis6d00c132010-07-10 11:46:15 +00001374 E->Loc = Range.getBegin();
1375 E->RParen = Range.getEnd();
Sebastian Redlc3632732010-10-05 15:59:54 +00001376 E->QueriedType = GetTypeSourceInfo(Record, Idx);
Argyrios Kyrtzidis6d00c132010-07-10 11:46:15 +00001377}
1378
Francois Pichet6ad6f282010-12-07 00:08:36 +00001379void ASTStmtReader::VisitBinaryTypeTraitExpr(BinaryTypeTraitExpr *E) {
1380 VisitExpr(E);
1381 E->BTT = (BinaryTypeTrait)Record[Idx++];
1382 E->Value = (bool)Record[Idx++];
1383 SourceRange Range = ReadSourceRange(Record, Idx);
1384 E->Loc = Range.getBegin();
1385 E->RParen = Range.getEnd();
1386 E->LhsType = GetTypeSourceInfo(Record, Idx);
1387 E->RhsType = GetTypeSourceInfo(Record, Idx);
1388}
1389
Douglas Gregor4ca8ac22012-02-24 07:38:34 +00001390void ASTStmtReader::VisitTypeTraitExpr(TypeTraitExpr *E) {
1391 VisitExpr(E);
1392 E->TypeTraitExprBits.NumArgs = Record[Idx++];
1393 E->TypeTraitExprBits.Kind = Record[Idx++];
1394 E->TypeTraitExprBits.Value = Record[Idx++];
1395
1396 TypeSourceInfo **Args = E->getTypeSourceInfos();
1397 for (unsigned I = 0, N = E->getNumArgs(); I != N; ++I)
1398 Args[I] = GetTypeSourceInfo(Record, Idx);
1399}
1400
John Wiegley21ff2e52011-04-28 00:16:57 +00001401void ASTStmtReader::VisitArrayTypeTraitExpr(ArrayTypeTraitExpr *E) {
1402 VisitExpr(E);
1403 E->ATT = (ArrayTypeTrait)Record[Idx++];
1404 E->Value = (unsigned int)Record[Idx++];
1405 SourceRange Range = ReadSourceRange(Record, Idx);
1406 E->Loc = Range.getBegin();
1407 E->RParen = Range.getEnd();
1408 E->QueriedType = GetTypeSourceInfo(Record, Idx);
1409}
1410
John Wiegley55262202011-04-25 06:54:41 +00001411void ASTStmtReader::VisitExpressionTraitExpr(ExpressionTraitExpr *E) {
1412 VisitExpr(E);
1413 E->ET = (ExpressionTrait)Record[Idx++];
1414 E->Value = (bool)Record[Idx++];
1415 SourceRange Range = ReadSourceRange(Record, Idx);
1416 E->QueriedExpression = Reader.ReadSubExpr();
1417 E->Loc = Range.getBegin();
1418 E->RParen = Range.getEnd();
1419}
1420
Sebastian Redl6b219d02010-09-10 20:55:54 +00001421void ASTStmtReader::VisitCXXNoexceptExpr(CXXNoexceptExpr *E) {
1422 VisitExpr(E);
Sebastian Redl5221d8f2010-09-10 22:34:40 +00001423 E->Value = (bool)Record[Idx++];
Sebastian Redlc3632732010-10-05 15:59:54 +00001424 E->Range = ReadSourceRange(Record, Idx);
Sebastian Redl5221d8f2010-09-10 22:34:40 +00001425 E->Operand = Reader.ReadSubExpr();
Sebastian Redl6b219d02010-09-10 20:55:54 +00001426}
1427
Douglas Gregorbe230c32011-01-03 17:17:50 +00001428void ASTStmtReader::VisitPackExpansionExpr(PackExpansionExpr *E) {
1429 VisitExpr(E);
1430 E->EllipsisLoc = ReadSourceLocation(Record, Idx);
Douglas Gregor67fd1252011-01-14 21:20:45 +00001431 E->NumExpansions = Record[Idx++];
Douglas Gregorbe230c32011-01-03 17:17:50 +00001432 E->Pattern = Reader.ReadSubExpr();
1433}
1434
Douglas Gregoree8aff02011-01-04 17:33:58 +00001435void ASTStmtReader::VisitSizeOfPackExpr(SizeOfPackExpr *E) {
1436 VisitExpr(E);
1437 E->OperatorLoc = ReadSourceLocation(Record, Idx);
1438 E->PackLoc = ReadSourceLocation(Record, Idx);
1439 E->RParenLoc = ReadSourceLocation(Record, Idx);
1440 E->Length = Record[Idx++];
Douglas Gregor409448c2011-07-21 22:35:25 +00001441 E->Pack = ReadDeclAs<NamedDecl>(Record, Idx);
Douglas Gregoree8aff02011-01-04 17:33:58 +00001442}
1443
John McCall7110fd62011-07-15 07:00:14 +00001444void ASTStmtReader::VisitSubstNonTypeTemplateParmExpr(
1445 SubstNonTypeTemplateParmExpr *E) {
1446 VisitExpr(E);
Douglas Gregor409448c2011-07-21 22:35:25 +00001447 E->Param = ReadDeclAs<NonTypeTemplateParmDecl>(Record, Idx);
John McCall7110fd62011-07-15 07:00:14 +00001448 E->NameLoc = ReadSourceLocation(Record, Idx);
1449 E->Replacement = Reader.ReadSubExpr();
1450}
1451
Douglas Gregorc7793c72011-01-15 01:15:58 +00001452void ASTStmtReader::VisitSubstNonTypeTemplateParmPackExpr(
1453 SubstNonTypeTemplateParmPackExpr *E) {
1454 VisitExpr(E);
Douglas Gregor409448c2011-07-21 22:35:25 +00001455 E->Param = ReadDeclAs<NonTypeTemplateParmDecl>(Record, Idx);
Douglas Gregorc7793c72011-01-15 01:15:58 +00001456 TemplateArgument ArgPack = Reader.ReadTemplateArgument(F, Record, Idx);
1457 if (ArgPack.getKind() != TemplateArgument::Pack)
1458 return;
1459
1460 E->Arguments = ArgPack.pack_begin();
1461 E->NumArguments = ArgPack.pack_size();
1462 E->NameLoc = ReadSourceLocation(Record, Idx);
1463}
1464
Douglas Gregor03e80032011-06-21 17:03:29 +00001465void ASTStmtReader::VisitMaterializeTemporaryExpr(MaterializeTemporaryExpr *E) {
1466 VisitExpr(E);
1467 E->Temporary = Reader.ReadSubExpr();
1468}
1469
John McCall7cd7d1a2010-11-15 23:31:06 +00001470void ASTStmtReader::VisitOpaqueValueExpr(OpaqueValueExpr *E) {
1471 VisitExpr(E);
Argyrios Kyrtzidis8bc27822011-12-03 03:49:52 +00001472 E->SourceExpr = Reader.ReadSubExpr();
Douglas Gregorb608b982011-01-28 02:26:04 +00001473 E->Loc = ReadSourceLocation(Record, Idx);
John McCall7cd7d1a2010-11-15 23:31:06 +00001474}
1475
Peter Collingbournee08ce652011-02-09 21:07:24 +00001476//===----------------------------------------------------------------------===//
John McCall7110fd62011-07-15 07:00:14 +00001477// Microsoft Expressions and Statements
1478//===----------------------------------------------------------------------===//
1479void ASTStmtReader::VisitCXXUuidofExpr(CXXUuidofExpr *E) {
1480 VisitExpr(E);
1481 E->setSourceRange(ReadSourceRange(Record, Idx));
1482 if (E->isTypeOperand()) { // __uuidof(ComType)
1483 E->setTypeOperandSourceInfo(
1484 GetTypeSourceInfo(Record, Idx));
1485 return;
1486 }
1487
1488 // __uuidof(expr)
1489 E->setExprOperand(Reader.ReadSubExpr());
1490}
1491
1492void ASTStmtReader::VisitSEHExceptStmt(SEHExceptStmt *S) {
1493 VisitStmt(S);
1494 S->Loc = ReadSourceLocation(Record, Idx);
1495 S->Children[SEHExceptStmt::FILTER_EXPR] = Reader.ReadSubStmt();
1496 S->Children[SEHExceptStmt::BLOCK] = Reader.ReadSubStmt();
1497}
1498
1499void ASTStmtReader::VisitSEHFinallyStmt(SEHFinallyStmt *S) {
1500 VisitStmt(S);
1501 S->Loc = ReadSourceLocation(Record, Idx);
1502 S->Block = Reader.ReadSubStmt();
1503}
1504
1505void ASTStmtReader::VisitSEHTryStmt(SEHTryStmt *S) {
1506 VisitStmt(S);
1507 S->IsCXXTry = Record[Idx++];
1508 S->TryLoc = ReadSourceLocation(Record, Idx);
1509 S->Children[SEHTryStmt::TRY] = Reader.ReadSubStmt();
1510 S->Children[SEHTryStmt::HANDLER] = Reader.ReadSubStmt();
1511}
1512
1513//===----------------------------------------------------------------------===//
Peter Collingbournee08ce652011-02-09 21:07:24 +00001514// CUDA Expressions and Statements
1515//===----------------------------------------------------------------------===//
1516
1517void ASTStmtReader::VisitCUDAKernelCallExpr(CUDAKernelCallExpr *E) {
1518 VisitCallExpr(E);
1519 E->setConfig(cast<CallExpr>(Reader.ReadSubExpr()));
1520}
1521
John McCall7110fd62011-07-15 07:00:14 +00001522//===----------------------------------------------------------------------===//
1523// OpenCL Expressions and Statements.
1524//===----------------------------------------------------------------------===//
1525void ASTStmtReader::VisitAsTypeExpr(AsTypeExpr *E) {
1526 VisitExpr(E);
1527 E->BuiltinLoc = ReadSourceLocation(Record, Idx);
1528 E->RParenLoc = ReadSourceLocation(Record, Idx);
1529 E->SrcExpr = Reader.ReadSubExpr();
1530}
1531
1532//===----------------------------------------------------------------------===//
1533// ASTReader Implementation
1534//===----------------------------------------------------------------------===//
1535
Douglas Gregor1a4761e2011-11-30 23:21:26 +00001536Stmt *ASTReader::ReadStmt(ModuleFile &F) {
Argyrios Kyrtzidis919e6932010-06-28 22:28:35 +00001537 switch (ReadingKind) {
1538 case Read_Decl:
1539 case Read_Type:
Sebastian Redlc3632732010-10-05 15:59:54 +00001540 return ReadStmtFromStream(F);
Argyrios Kyrtzidis919e6932010-06-28 22:28:35 +00001541 case Read_Stmt:
Argyrios Kyrtzidisd98a2ab2010-06-29 22:46:25 +00001542 return ReadSubStmt();
Argyrios Kyrtzidis919e6932010-06-28 22:28:35 +00001543 }
1544
1545 llvm_unreachable("ReadingKind not set ?");
Argyrios Kyrtzidis919e6932010-06-28 22:28:35 +00001546}
1547
Douglas Gregor1a4761e2011-11-30 23:21:26 +00001548Expr *ASTReader::ReadExpr(ModuleFile &F) {
Sebastian Redlc3632732010-10-05 15:59:54 +00001549 return cast_or_null<Expr>(ReadStmt(F));
Argyrios Kyrtzidis919e6932010-06-28 22:28:35 +00001550}
Chris Lattner030854b2010-05-09 06:40:08 +00001551
Sebastian Redlc43b54c2010-08-18 23:56:43 +00001552Expr *ASTReader::ReadSubExpr() {
Argyrios Kyrtzidisd98a2ab2010-06-29 22:46:25 +00001553 return cast_or_null<Expr>(ReadSubStmt());
1554}
1555
Chris Lattner52e97d12009-04-27 05:41:06 +00001556// Within the bitstream, expressions are stored in Reverse Polish
1557// Notation, with each of the subexpressions preceding the
Argyrios Kyrtzidis919e6932010-06-28 22:28:35 +00001558// expression they are stored in. Subexpressions are stored from last to first.
1559// To evaluate expressions, we continue reading expressions and placing them on
1560// the stack, with expressions having operands removing those operands from the
Chris Lattner52e97d12009-04-27 05:41:06 +00001561// stack. Evaluation terminates when we see a STMT_STOP record, and
1562// the single remaining expression on the stack is our result.
Douglas Gregor1a4761e2011-11-30 23:21:26 +00001563Stmt *ASTReader::ReadStmtFromStream(ModuleFile &F) {
Argyrios Kyrtzidis919e6932010-06-28 22:28:35 +00001564
1565 ReadingKindTracker ReadingKind(Read_Stmt, *this);
Sebastian Redlc3632732010-10-05 15:59:54 +00001566 llvm::BitstreamCursor &Cursor = F.DeclsCursor;
Argyrios Kyrtzidise6f08682011-10-21 23:02:28 +00001567
1568 // Map of offset to previously deserialized stmt. The offset points
1569 /// just after the stmt record.
1570 llvm::DenseMap<uint64_t, Stmt *> StmtEntries;
Sebastian Redlc3632732010-10-05 15:59:54 +00001571
Argyrios Kyrtzidis919e6932010-06-28 22:28:35 +00001572#ifndef NDEBUG
1573 unsigned PrevNumStmts = StmtStack.size();
1574#endif
1575
Chris Lattner4c6f9522009-04-27 05:14:47 +00001576 RecordData Record;
1577 unsigned Idx;
Sebastian Redlc3632732010-10-05 15:59:54 +00001578 ASTStmtReader Reader(*this, F, Cursor, Record, Idx);
Chris Lattner4c6f9522009-04-27 05:14:47 +00001579 Stmt::EmptyShell Empty;
1580
1581 while (true) {
Chris Lattner52e97d12009-04-27 05:41:06 +00001582 unsigned Code = Cursor.ReadCode();
Chris Lattner4c6f9522009-04-27 05:14:47 +00001583 if (Code == llvm::bitc::END_BLOCK) {
Chris Lattner52e97d12009-04-27 05:41:06 +00001584 if (Cursor.ReadBlockEnd()) {
Sebastian Redl3c7f4132010-08-18 23:57:06 +00001585 Error("error at end of block in AST file");
Chris Lattner4c6f9522009-04-27 05:14:47 +00001586 return 0;
1587 }
1588 break;
1589 }
1590
1591 if (Code == llvm::bitc::ENTER_SUBBLOCK) {
1592 // No known subblocks, always skip them.
Chris Lattner52e97d12009-04-27 05:41:06 +00001593 Cursor.ReadSubBlockID();
1594 if (Cursor.SkipBlock()) {
Sebastian Redl3c7f4132010-08-18 23:57:06 +00001595 Error("malformed block record in AST file");
Chris Lattner4c6f9522009-04-27 05:14:47 +00001596 return 0;
1597 }
1598 continue;
1599 }
1600
1601 if (Code == llvm::bitc::DEFINE_ABBREV) {
Chris Lattner52e97d12009-04-27 05:41:06 +00001602 Cursor.ReadAbbrevRecord();
Chris Lattner4c6f9522009-04-27 05:14:47 +00001603 continue;
1604 }
1605
1606 Stmt *S = 0;
1607 Idx = 0;
1608 Record.clear();
1609 bool Finished = false;
Argyrios Kyrtzidise6f08682011-10-21 23:02:28 +00001610 bool IsStmtReference = false;
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001611 switch ((StmtCode)Cursor.ReadRecord(Code, Record)) {
1612 case STMT_STOP:
Chris Lattner4c6f9522009-04-27 05:14:47 +00001613 Finished = true;
1614 break;
1615
Argyrios Kyrtzidise6f08682011-10-21 23:02:28 +00001616 case STMT_REF_PTR:
1617 IsStmtReference = true;
1618 assert(StmtEntries.find(Record[0]) != StmtEntries.end() &&
1619 "No stmt was recorded for this offset reference!");
1620 S = StmtEntries[Record[Idx++]];
1621 break;
1622
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001623 case STMT_NULL_PTR:
Mike Stump1eb44332009-09-09 15:08:12 +00001624 S = 0;
Chris Lattner4c6f9522009-04-27 05:14:47 +00001625 break;
1626
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001627 case STMT_NULL:
Chris Lattner4c6f9522009-04-27 05:14:47 +00001628 S = new (Context) NullStmt(Empty);
1629 break;
1630
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001631 case STMT_COMPOUND:
Chris Lattner4c6f9522009-04-27 05:14:47 +00001632 S = new (Context) CompoundStmt(Empty);
1633 break;
1634
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001635 case STMT_CASE:
Chris Lattner4c6f9522009-04-27 05:14:47 +00001636 S = new (Context) CaseStmt(Empty);
1637 break;
1638
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001639 case STMT_DEFAULT:
Chris Lattner4c6f9522009-04-27 05:14:47 +00001640 S = new (Context) DefaultStmt(Empty);
1641 break;
1642
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001643 case STMT_LABEL:
Chris Lattner4c6f9522009-04-27 05:14:47 +00001644 S = new (Context) LabelStmt(Empty);
1645 break;
1646
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001647 case STMT_IF:
Chris Lattner4c6f9522009-04-27 05:14:47 +00001648 S = new (Context) IfStmt(Empty);
1649 break;
1650
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001651 case STMT_SWITCH:
Chris Lattner4c6f9522009-04-27 05:14:47 +00001652 S = new (Context) SwitchStmt(Empty);
1653 break;
1654
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001655 case STMT_WHILE:
Chris Lattner4c6f9522009-04-27 05:14:47 +00001656 S = new (Context) WhileStmt(Empty);
1657 break;
1658
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001659 case STMT_DO:
Chris Lattner4c6f9522009-04-27 05:14:47 +00001660 S = new (Context) DoStmt(Empty);
1661 break;
Mike Stump1eb44332009-09-09 15:08:12 +00001662
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001663 case STMT_FOR:
Chris Lattner4c6f9522009-04-27 05:14:47 +00001664 S = new (Context) ForStmt(Empty);
1665 break;
1666
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001667 case STMT_GOTO:
Chris Lattner4c6f9522009-04-27 05:14:47 +00001668 S = new (Context) GotoStmt(Empty);
1669 break;
Mike Stump1eb44332009-09-09 15:08:12 +00001670
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001671 case STMT_INDIRECT_GOTO:
Chris Lattner4c6f9522009-04-27 05:14:47 +00001672 S = new (Context) IndirectGotoStmt(Empty);
1673 break;
1674
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001675 case STMT_CONTINUE:
Chris Lattner4c6f9522009-04-27 05:14:47 +00001676 S = new (Context) ContinueStmt(Empty);
1677 break;
1678
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001679 case STMT_BREAK:
Chris Lattner4c6f9522009-04-27 05:14:47 +00001680 S = new (Context) BreakStmt(Empty);
1681 break;
1682
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001683 case STMT_RETURN:
Chris Lattner4c6f9522009-04-27 05:14:47 +00001684 S = new (Context) ReturnStmt(Empty);
1685 break;
1686
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001687 case STMT_DECL:
Chris Lattner4c6f9522009-04-27 05:14:47 +00001688 S = new (Context) DeclStmt(Empty);
1689 break;
1690
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001691 case STMT_ASM:
Chris Lattner4c6f9522009-04-27 05:14:47 +00001692 S = new (Context) AsmStmt(Empty);
1693 break;
1694
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001695 case EXPR_PREDEFINED:
Chris Lattner4c6f9522009-04-27 05:14:47 +00001696 S = new (Context) PredefinedExpr(Empty);
1697 break;
Mike Stump1eb44332009-09-09 15:08:12 +00001698
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001699 case EXPR_DECL_REF:
Chandler Carruth3aa81402011-05-01 23:48:14 +00001700 S = DeclRefExpr::CreateEmpty(
Douglas Gregor35942772011-09-09 21:34:22 +00001701 Context,
Chandler Carruth3aa81402011-05-01 23:48:14 +00001702 /*HasQualifier=*/Record[ASTStmtReader::NumExprFields],
1703 /*HasFoundDecl=*/Record[ASTStmtReader::NumExprFields + 1],
Abramo Bagnarae4b92762012-01-27 09:46:47 +00001704 /*HasTemplateKWAndArgsInfo=*/Record[ASTStmtReader::NumExprFields + 2],
Chandler Carruth3aa81402011-05-01 23:48:14 +00001705 /*NumTemplateArgs=*/Record[ASTStmtReader::NumExprFields + 2] ?
Abramo Bagnara7cc58b42011-10-05 07:56:41 +00001706 Record[ASTStmtReader::NumExprFields + 4] : 0);
Chris Lattner4c6f9522009-04-27 05:14:47 +00001707 break;
Mike Stump1eb44332009-09-09 15:08:12 +00001708
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001709 case EXPR_INTEGER_LITERAL:
Douglas Gregor35942772011-09-09 21:34:22 +00001710 S = IntegerLiteral::Create(Context, Empty);
Chris Lattner4c6f9522009-04-27 05:14:47 +00001711 break;
Mike Stump1eb44332009-09-09 15:08:12 +00001712
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001713 case EXPR_FLOATING_LITERAL:
Douglas Gregor35942772011-09-09 21:34:22 +00001714 S = FloatingLiteral::Create(Context, Empty);
Chris Lattner4c6f9522009-04-27 05:14:47 +00001715 break;
Mike Stump1eb44332009-09-09 15:08:12 +00001716
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001717 case EXPR_IMAGINARY_LITERAL:
Chris Lattner4c6f9522009-04-27 05:14:47 +00001718 S = new (Context) ImaginaryLiteral(Empty);
1719 break;
1720
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001721 case EXPR_STRING_LITERAL:
Douglas Gregor35942772011-09-09 21:34:22 +00001722 S = StringLiteral::CreateEmpty(Context,
Sebastian Redl60adf4a2010-08-18 23:56:52 +00001723 Record[ASTStmtReader::NumExprFields + 1]);
Chris Lattner4c6f9522009-04-27 05:14:47 +00001724 break;
1725
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001726 case EXPR_CHARACTER_LITERAL:
Chris Lattner4c6f9522009-04-27 05:14:47 +00001727 S = new (Context) CharacterLiteral(Empty);
1728 break;
1729
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001730 case EXPR_PAREN:
Chris Lattner4c6f9522009-04-27 05:14:47 +00001731 S = new (Context) ParenExpr(Empty);
1732 break;
1733
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001734 case EXPR_PAREN_LIST:
Argyrios Kyrtzidis37bdfe22010-06-30 08:49:18 +00001735 S = new (Context) ParenListExpr(Empty);
1736 break;
1737
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001738 case EXPR_UNARY_OPERATOR:
Chris Lattner4c6f9522009-04-27 05:14:47 +00001739 S = new (Context) UnaryOperator(Empty);
1740 break;
1741
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001742 case EXPR_OFFSETOF:
Douglas Gregor35942772011-09-09 21:34:22 +00001743 S = OffsetOfExpr::CreateEmpty(Context,
Sebastian Redl60adf4a2010-08-18 23:56:52 +00001744 Record[ASTStmtReader::NumExprFields],
1745 Record[ASTStmtReader::NumExprFields + 1]);
Douglas Gregor8ecdb652010-04-28 22:16:22 +00001746 break;
1747
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001748 case EXPR_SIZEOF_ALIGN_OF:
Peter Collingbournef4e3cfb2011-03-11 19:24:49 +00001749 S = new (Context) UnaryExprOrTypeTraitExpr(Empty);
Chris Lattner4c6f9522009-04-27 05:14:47 +00001750 break;
1751
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001752 case EXPR_ARRAY_SUBSCRIPT:
Chris Lattner4c6f9522009-04-27 05:14:47 +00001753 S = new (Context) ArraySubscriptExpr(Empty);
1754 break;
1755
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001756 case EXPR_CALL:
Douglas Gregor35942772011-09-09 21:34:22 +00001757 S = new (Context) CallExpr(Context, Stmt::CallExprClass, Empty);
Chris Lattner4c6f9522009-04-27 05:14:47 +00001758 break;
1759
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001760 case EXPR_MEMBER: {
Argyrios Kyrtzidis663e3802010-07-08 13:09:47 +00001761 // We load everything here and fully initialize it at creation.
1762 // That way we can use MemberExpr::Create and don't have to duplicate its
1763 // logic with a MemberExpr::CreateEmpty.
1764
1765 assert(Idx == 0);
Douglas Gregor40d96a62011-02-28 21:54:11 +00001766 NestedNameSpecifierLoc QualifierLoc;
Argyrios Kyrtzidis663e3802010-07-08 13:09:47 +00001767 if (Record[Idx++]) { // HasQualifier.
Douglas Gregor40d96a62011-02-28 21:54:11 +00001768 QualifierLoc = ReadNestedNameSpecifierLoc(F, Record, Idx);
Argyrios Kyrtzidis663e3802010-07-08 13:09:47 +00001769 }
1770
Abramo Bagnarae4b92762012-01-27 09:46:47 +00001771 SourceLocation TemplateKWLoc;
Argyrios Kyrtzidis663e3802010-07-08 13:09:47 +00001772 TemplateArgumentListInfo ArgInfo;
Abramo Bagnarae4b92762012-01-27 09:46:47 +00001773 bool HasTemplateKWAndArgsInfo = Record[Idx++];
1774 if (HasTemplateKWAndArgsInfo) {
1775 TemplateKWLoc = ReadSourceLocation(F, Record, Idx);
Douglas Gregordef03542011-02-04 12:01:24 +00001776 unsigned NumTemplateArgs = Record[Idx++];
Sebastian Redlc3632732010-10-05 15:59:54 +00001777 ArgInfo.setLAngleLoc(ReadSourceLocation(F, Record, Idx));
1778 ArgInfo.setRAngleLoc(ReadSourceLocation(F, Record, Idx));
Argyrios Kyrtzidis663e3802010-07-08 13:09:47 +00001779 for (unsigned i = 0; i != NumTemplateArgs; ++i)
Sebastian Redlc3632732010-10-05 15:59:54 +00001780 ArgInfo.addArgument(ReadTemplateArgumentLoc(F, Record, Idx));
Argyrios Kyrtzidis663e3802010-07-08 13:09:47 +00001781 }
Abramo Bagnara7cc58b42011-10-05 07:56:41 +00001782
1783 bool HadMultipleCandidates = Record[Idx++];
1784
Douglas Gregor409448c2011-07-21 22:35:25 +00001785 NamedDecl *FoundD = ReadDeclAs<NamedDecl>(F, Record, Idx);
Argyrios Kyrtzidis663e3802010-07-08 13:09:47 +00001786 AccessSpecifier AS = (AccessSpecifier)Record[Idx++];
1787 DeclAccessPair FoundDecl = DeclAccessPair::make(FoundD, AS);
1788
Douglas Gregor393f2492011-07-22 00:38:23 +00001789 QualType T = readType(F, Record, Idx);
John McCallf89e55a2010-11-18 06:31:45 +00001790 ExprValueKind VK = static_cast<ExprValueKind>(Record[Idx++]);
1791 ExprObjectKind OK = static_cast<ExprObjectKind>(Record[Idx++]);
Argyrios Kyrtzidis663e3802010-07-08 13:09:47 +00001792 Expr *Base = ReadSubExpr();
Douglas Gregor409448c2011-07-21 22:35:25 +00001793 ValueDecl *MemberD = ReadDeclAs<ValueDecl>(F, Record, Idx);
Sebastian Redlc3632732010-10-05 15:59:54 +00001794 SourceLocation MemberLoc = ReadSourceLocation(F, Record, Idx);
Abramo Bagnara25777432010-08-11 22:01:17 +00001795 DeclarationNameInfo MemberNameInfo(MemberD->getDeclName(), MemberLoc);
Argyrios Kyrtzidis663e3802010-07-08 13:09:47 +00001796 bool IsArrow = Record[Idx++];
1797
Douglas Gregor35942772011-09-09 21:34:22 +00001798 S = MemberExpr::Create(Context, Base, IsArrow, QualifierLoc,
Abramo Bagnarae4b92762012-01-27 09:46:47 +00001799 TemplateKWLoc, MemberD, FoundDecl, MemberNameInfo,
1800 HasTemplateKWAndArgsInfo ? &ArgInfo : 0,
1801 T, VK, OK);
Argyrios Kyrtzidis40451072010-10-15 18:21:24 +00001802 ReadDeclarationNameLoc(F, cast<MemberExpr>(S)->MemberDNLoc,
1803 MemberD->getDeclName(), Record, Idx);
Abramo Bagnara7cc58b42011-10-05 07:56:41 +00001804 if (HadMultipleCandidates)
1805 cast<MemberExpr>(S)->setHadMultipleCandidates(true);
Chris Lattner4c6f9522009-04-27 05:14:47 +00001806 break;
Argyrios Kyrtzidis663e3802010-07-08 13:09:47 +00001807 }
Chris Lattner4c6f9522009-04-27 05:14:47 +00001808
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001809 case EXPR_BINARY_OPERATOR:
Chris Lattner4c6f9522009-04-27 05:14:47 +00001810 S = new (Context) BinaryOperator(Empty);
1811 break;
1812
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001813 case EXPR_COMPOUND_ASSIGN_OPERATOR:
Chris Lattner4c6f9522009-04-27 05:14:47 +00001814 S = new (Context) CompoundAssignOperator(Empty);
1815 break;
1816
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001817 case EXPR_CONDITIONAL_OPERATOR:
Chris Lattner4c6f9522009-04-27 05:14:47 +00001818 S = new (Context) ConditionalOperator(Empty);
1819 break;
1820
John McCall56ca35d2011-02-17 10:25:35 +00001821 case EXPR_BINARY_CONDITIONAL_OPERATOR:
1822 S = new (Context) BinaryConditionalOperator(Empty);
1823 break;
1824
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001825 case EXPR_IMPLICIT_CAST:
Douglas Gregor35942772011-09-09 21:34:22 +00001826 S = ImplicitCastExpr::CreateEmpty(Context,
Sebastian Redl60adf4a2010-08-18 23:56:52 +00001827 /*PathSize*/ Record[ASTStmtReader::NumExprFields]);
Chris Lattner4c6f9522009-04-27 05:14:47 +00001828 break;
1829
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001830 case EXPR_CSTYLE_CAST:
Douglas Gregor35942772011-09-09 21:34:22 +00001831 S = CStyleCastExpr::CreateEmpty(Context,
Sebastian Redl60adf4a2010-08-18 23:56:52 +00001832 /*PathSize*/ Record[ASTStmtReader::NumExprFields]);
Chris Lattner4c6f9522009-04-27 05:14:47 +00001833 break;
1834
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001835 case EXPR_COMPOUND_LITERAL:
Chris Lattner4c6f9522009-04-27 05:14:47 +00001836 S = new (Context) CompoundLiteralExpr(Empty);
1837 break;
1838
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001839 case EXPR_EXT_VECTOR_ELEMENT:
Chris Lattner4c6f9522009-04-27 05:14:47 +00001840 S = new (Context) ExtVectorElementExpr(Empty);
1841 break;
1842
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001843 case EXPR_INIT_LIST:
Douglas Gregor35942772011-09-09 21:34:22 +00001844 S = new (Context) InitListExpr(getContext(), Empty);
Chris Lattner4c6f9522009-04-27 05:14:47 +00001845 break;
1846
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001847 case EXPR_DESIGNATED_INIT:
Douglas Gregor35942772011-09-09 21:34:22 +00001848 S = DesignatedInitExpr::CreateEmpty(Context,
Sebastian Redl60adf4a2010-08-18 23:56:52 +00001849 Record[ASTStmtReader::NumExprFields] - 1);
Mike Stump1eb44332009-09-09 15:08:12 +00001850
Chris Lattner4c6f9522009-04-27 05:14:47 +00001851 break;
1852
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001853 case EXPR_IMPLICIT_VALUE_INIT:
Chris Lattner4c6f9522009-04-27 05:14:47 +00001854 S = new (Context) ImplicitValueInitExpr(Empty);
1855 break;
1856
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001857 case EXPR_VA_ARG:
Chris Lattner4c6f9522009-04-27 05:14:47 +00001858 S = new (Context) VAArgExpr(Empty);
1859 break;
1860
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001861 case EXPR_ADDR_LABEL:
Chris Lattner4c6f9522009-04-27 05:14:47 +00001862 S = new (Context) AddrLabelExpr(Empty);
1863 break;
1864
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001865 case EXPR_STMT:
Chris Lattner4c6f9522009-04-27 05:14:47 +00001866 S = new (Context) StmtExpr(Empty);
1867 break;
1868
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001869 case EXPR_CHOOSE:
Chris Lattner4c6f9522009-04-27 05:14:47 +00001870 S = new (Context) ChooseExpr(Empty);
1871 break;
1872
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001873 case EXPR_GNU_NULL:
Chris Lattner4c6f9522009-04-27 05:14:47 +00001874 S = new (Context) GNUNullExpr(Empty);
1875 break;
1876
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001877 case EXPR_SHUFFLE_VECTOR:
Chris Lattner4c6f9522009-04-27 05:14:47 +00001878 S = new (Context) ShuffleVectorExpr(Empty);
1879 break;
Mike Stump1eb44332009-09-09 15:08:12 +00001880
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001881 case EXPR_BLOCK:
Chris Lattner4c6f9522009-04-27 05:14:47 +00001882 S = new (Context) BlockExpr(Empty);
1883 break;
1884
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001885 case EXPR_BLOCK_DECL_REF:
Chris Lattner4c6f9522009-04-27 05:14:47 +00001886 S = new (Context) BlockDeclRefExpr(Empty);
1887 break;
Mike Stump1eb44332009-09-09 15:08:12 +00001888
Peter Collingbournef111d932011-04-15 00:35:48 +00001889 case EXPR_GENERIC_SELECTION:
1890 S = new (Context) GenericSelectionExpr(Empty);
1891 break;
1892
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001893 case EXPR_OBJC_STRING_LITERAL:
Chris Lattner4c6f9522009-04-27 05:14:47 +00001894 S = new (Context) ObjCStringLiteral(Empty);
1895 break;
Ted Kremenekebcb57a2012-03-06 20:05:56 +00001896 case EXPR_OBJC_NUMERIC_LITERAL:
1897 S = new (Context) ObjCNumericLiteral(Empty);
1898 break;
1899 case EXPR_OBJC_ARRAY_LITERAL:
1900 S = ObjCArrayLiteral::CreateEmpty(Context,
1901 Record[ASTStmtReader::NumExprFields]);
1902 break;
1903 case EXPR_OBJC_DICTIONARY_LITERAL:
1904 S = ObjCDictionaryLiteral::CreateEmpty(Context,
1905 Record[ASTStmtReader::NumExprFields],
1906 Record[ASTStmtReader::NumExprFields + 1]);
1907 break;
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001908 case EXPR_OBJC_ENCODE:
Chris Lattner4c6f9522009-04-27 05:14:47 +00001909 S = new (Context) ObjCEncodeExpr(Empty);
1910 break;
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001911 case EXPR_OBJC_SELECTOR_EXPR:
Chris Lattner4c6f9522009-04-27 05:14:47 +00001912 S = new (Context) ObjCSelectorExpr(Empty);
1913 break;
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001914 case EXPR_OBJC_PROTOCOL_EXPR:
Chris Lattner4c6f9522009-04-27 05:14:47 +00001915 S = new (Context) ObjCProtocolExpr(Empty);
1916 break;
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001917 case EXPR_OBJC_IVAR_REF_EXPR:
Chris Lattner4c6f9522009-04-27 05:14:47 +00001918 S = new (Context) ObjCIvarRefExpr(Empty);
1919 break;
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001920 case EXPR_OBJC_PROPERTY_REF_EXPR:
Chris Lattner4c6f9522009-04-27 05:14:47 +00001921 S = new (Context) ObjCPropertyRefExpr(Empty);
1922 break;
Ted Kremenekebcb57a2012-03-06 20:05:56 +00001923 case EXPR_OBJC_SUBSCRIPT_REF_EXPR:
1924 S = new (Context) ObjCSubscriptRefExpr(Empty);
1925 break;
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001926 case EXPR_OBJC_KVC_REF_EXPR:
John McCall12f78a62010-12-02 01:19:52 +00001927 llvm_unreachable("mismatching AST file");
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001928 case EXPR_OBJC_MESSAGE_EXPR:
Douglas Gregor35942772011-09-09 21:34:22 +00001929 S = ObjCMessageExpr::CreateEmpty(Context,
Argyrios Kyrtzidis20718082011-10-03 06:36:51 +00001930 Record[ASTStmtReader::NumExprFields],
1931 Record[ASTStmtReader::NumExprFields + 1]);
Chris Lattner4c6f9522009-04-27 05:14:47 +00001932 break;
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001933 case EXPR_OBJC_ISA:
Steve Narofff242b1b2009-07-24 17:54:45 +00001934 S = new (Context) ObjCIsaExpr(Empty);
1935 break;
John McCallf85e1932011-06-15 23:02:42 +00001936 case EXPR_OBJC_INDIRECT_COPY_RESTORE:
1937 S = new (Context) ObjCIndirectCopyRestoreExpr(Empty);
1938 break;
1939 case EXPR_OBJC_BRIDGED_CAST:
1940 S = new (Context) ObjCBridgedCastExpr(Empty);
1941 break;
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001942 case STMT_OBJC_FOR_COLLECTION:
Chris Lattner4c6f9522009-04-27 05:14:47 +00001943 S = new (Context) ObjCForCollectionStmt(Empty);
1944 break;
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001945 case STMT_OBJC_CATCH:
Chris Lattner4c6f9522009-04-27 05:14:47 +00001946 S = new (Context) ObjCAtCatchStmt(Empty);
1947 break;
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001948 case STMT_OBJC_FINALLY:
Chris Lattner4c6f9522009-04-27 05:14:47 +00001949 S = new (Context) ObjCAtFinallyStmt(Empty);
1950 break;
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001951 case STMT_OBJC_AT_TRY:
Douglas Gregor35942772011-09-09 21:34:22 +00001952 S = ObjCAtTryStmt::CreateEmpty(Context,
Sebastian Redl60adf4a2010-08-18 23:56:52 +00001953 Record[ASTStmtReader::NumStmtFields],
1954 Record[ASTStmtReader::NumStmtFields + 1]);
Chris Lattner4c6f9522009-04-27 05:14:47 +00001955 break;
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001956 case STMT_OBJC_AT_SYNCHRONIZED:
Chris Lattner4c6f9522009-04-27 05:14:47 +00001957 S = new (Context) ObjCAtSynchronizedStmt(Empty);
1958 break;
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001959 case STMT_OBJC_AT_THROW:
Chris Lattner4c6f9522009-04-27 05:14:47 +00001960 S = new (Context) ObjCAtThrowStmt(Empty);
1961 break;
John McCallf85e1932011-06-15 23:02:42 +00001962 case STMT_OBJC_AUTORELEASE_POOL:
1963 S = new (Context) ObjCAutoreleasePoolStmt(Empty);
1964 break;
Ted Kremenekebcb57a2012-03-06 20:05:56 +00001965 case EXPR_OBJC_BOOL_LITERAL:
1966 S = new (Context) ObjCBoolLiteralExpr(Empty);
1967 break;
John McCall7110fd62011-07-15 07:00:14 +00001968 case STMT_SEH_EXCEPT:
1969 S = new (Context) SEHExceptStmt(Empty);
1970 break;
1971 case STMT_SEH_FINALLY:
1972 S = new (Context) SEHFinallyStmt(Empty);
1973 break;
1974 case STMT_SEH_TRY:
1975 S = new (Context) SEHTryStmt(Empty);
1976 break;
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001977 case STMT_CXX_CATCH:
Argyrios Kyrtzidis7cb45e32010-07-22 16:03:56 +00001978 S = new (Context) CXXCatchStmt(Empty);
1979 break;
1980
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001981 case STMT_CXX_TRY:
Douglas Gregor35942772011-09-09 21:34:22 +00001982 S = CXXTryStmt::Create(Context, Empty,
Sebastian Redl60adf4a2010-08-18 23:56:52 +00001983 /*NumHandlers=*/Record[ASTStmtReader::NumStmtFields]);
Argyrios Kyrtzidis7cb45e32010-07-22 16:03:56 +00001984 break;
1985
Richard Smithad762fc2011-04-14 22:09:26 +00001986 case STMT_CXX_FOR_RANGE:
1987 S = new (Context) CXXForRangeStmt(Empty);
1988 break;
1989
Douglas Gregorba0513d2011-10-25 01:33:02 +00001990 case STMT_MS_DEPENDENT_EXISTS:
1991 S = new (Context) MSDependentExistsStmt(SourceLocation(), true,
1992 NestedNameSpecifierLoc(),
1993 DeclarationNameInfo(),
1994 0);
1995 break;
1996
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001997 case EXPR_CXX_OPERATOR_CALL:
Douglas Gregor35942772011-09-09 21:34:22 +00001998 S = new (Context) CXXOperatorCallExpr(Context, Empty);
Argyrios Kyrtzidisba0a9002009-07-14 03:19:21 +00001999 break;
Chris Lattner1817bd42010-05-09 05:36:05 +00002000
Sebastian Redl8538e8d2010-08-18 23:57:32 +00002001 case EXPR_CXX_MEMBER_CALL:
Douglas Gregor35942772011-09-09 21:34:22 +00002002 S = new (Context) CXXMemberCallExpr(Context, Empty);
Chris Lattner1817bd42010-05-09 05:36:05 +00002003 break;
Douglas Gregor39da0b82009-09-09 23:08:42 +00002004
Sebastian Redl8538e8d2010-08-18 23:57:32 +00002005 case EXPR_CXX_CONSTRUCT:
Argyrios Kyrtzidis6d00c132010-07-10 11:46:15 +00002006 S = new (Context) CXXConstructExpr(Empty);
2007 break;
2008
Sebastian Redl8538e8d2010-08-18 23:57:32 +00002009 case EXPR_CXX_TEMPORARY_OBJECT:
Argyrios Kyrtzidis6d00c132010-07-10 11:46:15 +00002010 S = new (Context) CXXTemporaryObjectExpr(Empty);
Douglas Gregor39da0b82009-09-09 23:08:42 +00002011 break;
Sam Weinigce757a72010-01-16 21:21:01 +00002012
Sebastian Redl8538e8d2010-08-18 23:57:32 +00002013 case EXPR_CXX_STATIC_CAST:
Douglas Gregor35942772011-09-09 21:34:22 +00002014 S = CXXStaticCastExpr::CreateEmpty(Context,
Sebastian Redl60adf4a2010-08-18 23:56:52 +00002015 /*PathSize*/ Record[ASTStmtReader::NumExprFields]);
Sam Weinigce757a72010-01-16 21:21:01 +00002016 break;
2017
Sebastian Redl8538e8d2010-08-18 23:57:32 +00002018 case EXPR_CXX_DYNAMIC_CAST:
Douglas Gregor35942772011-09-09 21:34:22 +00002019 S = CXXDynamicCastExpr::CreateEmpty(Context,
Sebastian Redl60adf4a2010-08-18 23:56:52 +00002020 /*PathSize*/ Record[ASTStmtReader::NumExprFields]);
Sam Weinigce757a72010-01-16 21:21:01 +00002021 break;
2022
Sebastian Redl8538e8d2010-08-18 23:57:32 +00002023 case EXPR_CXX_REINTERPRET_CAST:
Douglas Gregor35942772011-09-09 21:34:22 +00002024 S = CXXReinterpretCastExpr::CreateEmpty(Context,
Sebastian Redl60adf4a2010-08-18 23:56:52 +00002025 /*PathSize*/ Record[ASTStmtReader::NumExprFields]);
Sam Weinigce757a72010-01-16 21:21:01 +00002026 break;
2027
Sebastian Redl8538e8d2010-08-18 23:57:32 +00002028 case EXPR_CXX_CONST_CAST:
Douglas Gregor35942772011-09-09 21:34:22 +00002029 S = CXXConstCastExpr::CreateEmpty(Context);
Sam Weinigce757a72010-01-16 21:21:01 +00002030 break;
2031
Sebastian Redl8538e8d2010-08-18 23:57:32 +00002032 case EXPR_CXX_FUNCTIONAL_CAST:
Douglas Gregor35942772011-09-09 21:34:22 +00002033 S = CXXFunctionalCastExpr::CreateEmpty(Context,
Sebastian Redl60adf4a2010-08-18 23:56:52 +00002034 /*PathSize*/ Record[ASTStmtReader::NumExprFields]);
Sam Weinigce757a72010-01-16 21:21:01 +00002035 break;
2036
Richard Smith9fcce652012-03-07 08:35:16 +00002037 case EXPR_USER_DEFINED_LITERAL:
2038 S = new (Context) UserDefinedLiteral(Context, Empty);
2039 break;
2040
Sebastian Redl8538e8d2010-08-18 23:57:32 +00002041 case EXPR_CXX_BOOL_LITERAL:
Sam Weinigeb7f9612010-02-07 06:32:43 +00002042 S = new (Context) CXXBoolLiteralExpr(Empty);
2043 break;
Sam Weinigce757a72010-01-16 21:21:01 +00002044
Sebastian Redl8538e8d2010-08-18 23:57:32 +00002045 case EXPR_CXX_NULL_PTR_LITERAL:
Sam Weinigeb7f9612010-02-07 06:32:43 +00002046 S = new (Context) CXXNullPtrLiteralExpr(Empty);
2047 break;
Sebastian Redl8538e8d2010-08-18 23:57:32 +00002048 case EXPR_CXX_TYPEID_EXPR:
Chris Lattner14ab24f2010-05-09 06:03:39 +00002049 S = new (Context) CXXTypeidExpr(Empty, true);
2050 break;
Sebastian Redl8538e8d2010-08-18 23:57:32 +00002051 case EXPR_CXX_TYPEID_TYPE:
Chris Lattner14ab24f2010-05-09 06:03:39 +00002052 S = new (Context) CXXTypeidExpr(Empty, false);
2053 break;
Francois Pichet01b7c302010-09-08 12:20:18 +00002054 case EXPR_CXX_UUIDOF_EXPR:
2055 S = new (Context) CXXUuidofExpr(Empty, true);
2056 break;
2057 case EXPR_CXX_UUIDOF_TYPE:
2058 S = new (Context) CXXUuidofExpr(Empty, false);
2059 break;
Sebastian Redl8538e8d2010-08-18 23:57:32 +00002060 case EXPR_CXX_THIS:
Chris Lattner2fbdfcd2010-05-09 06:15:05 +00002061 S = new (Context) CXXThisExpr(Empty);
2062 break;
Sebastian Redl8538e8d2010-08-18 23:57:32 +00002063 case EXPR_CXX_THROW:
Chris Lattner2fbdfcd2010-05-09 06:15:05 +00002064 S = new (Context) CXXThrowExpr(Empty);
2065 break;
Sebastian Redl8538e8d2010-08-18 23:57:32 +00002066 case EXPR_CXX_DEFAULT_ARG: {
Sebastian Redl60adf4a2010-08-18 23:56:52 +00002067 bool HasOtherExprStored = Record[ASTStmtReader::NumExprFields];
Argyrios Kyrtzidis8a507332010-07-02 23:30:15 +00002068 if (HasOtherExprStored) {
2069 Expr *SubExpr = ReadSubExpr();
Douglas Gregor35942772011-09-09 21:34:22 +00002070 S = CXXDefaultArgExpr::Create(Context, SourceLocation(), 0, SubExpr);
Argyrios Kyrtzidis8a507332010-07-02 23:30:15 +00002071 } else
2072 S = new (Context) CXXDefaultArgExpr(Empty);
Chris Lattner030854b2010-05-09 06:40:08 +00002073 break;
Argyrios Kyrtzidis8a507332010-07-02 23:30:15 +00002074 }
Sebastian Redl8538e8d2010-08-18 23:57:32 +00002075 case EXPR_CXX_BIND_TEMPORARY:
Chris Lattnerd2598362010-05-10 00:25:06 +00002076 S = new (Context) CXXBindTemporaryExpr(Empty);
2077 break;
Douglas Gregore2ca6d42010-09-02 21:50:02 +00002078
Sebastian Redl8538e8d2010-08-18 23:57:32 +00002079 case EXPR_CXX_SCALAR_VALUE_INIT:
Douglas Gregored8abf12010-07-08 06:14:04 +00002080 S = new (Context) CXXScalarValueInitExpr(Empty);
Chris Lattner59218632010-05-10 01:22:27 +00002081 break;
Sebastian Redl8538e8d2010-08-18 23:57:32 +00002082 case EXPR_CXX_NEW:
Chris Lattner59218632010-05-10 01:22:27 +00002083 S = new (Context) CXXNewExpr(Empty);
2084 break;
Sebastian Redl8538e8d2010-08-18 23:57:32 +00002085 case EXPR_CXX_DELETE:
Argyrios Kyrtzidis95fc98c2010-06-22 17:07:59 +00002086 S = new (Context) CXXDeleteExpr(Empty);
2087 break;
Sebastian Redl8538e8d2010-08-18 23:57:32 +00002088 case EXPR_CXX_PSEUDO_DESTRUCTOR:
Argyrios Kyrtzidisde4bd182010-06-28 09:32:03 +00002089 S = new (Context) CXXPseudoDestructorExpr(Empty);
2090 break;
Chris Lattner59218632010-05-10 01:22:27 +00002091
John McCall4765fa02010-12-06 08:20:24 +00002092 case EXPR_EXPR_WITH_CLEANUPS:
John McCall80ee6e82011-11-10 05:35:25 +00002093 S = ExprWithCleanups::Create(Context, Empty,
2094 Record[ASTStmtReader::NumExprFields]);
Chris Lattnerd2598362010-05-10 00:25:06 +00002095 break;
Argyrios Kyrtzidis8dfbd8b2010-06-24 08:57:31 +00002096
Sebastian Redl8538e8d2010-08-18 23:57:32 +00002097 case EXPR_CXX_DEPENDENT_SCOPE_MEMBER:
Douglas Gregor35942772011-09-09 21:34:22 +00002098 S = CXXDependentScopeMemberExpr::CreateEmpty(Context,
Abramo Bagnarae4b92762012-01-27 09:46:47 +00002099 /*HasTemplateKWAndArgsInfo=*/Record[ASTStmtReader::NumExprFields],
Douglas Gregordef03542011-02-04 12:01:24 +00002100 /*NumTemplateArgs=*/Record[ASTStmtReader::NumExprFields]
2101 ? Record[ASTStmtReader::NumExprFields + 1]
2102 : 0);
Argyrios Kyrtzidis8dfbd8b2010-06-24 08:57:31 +00002103 break;
2104
Sebastian Redl8538e8d2010-08-18 23:57:32 +00002105 case EXPR_CXX_DEPENDENT_SCOPE_DECL_REF:
Douglas Gregor35942772011-09-09 21:34:22 +00002106 S = DependentScopeDeclRefExpr::CreateEmpty(Context,
Abramo Bagnarae4b92762012-01-27 09:46:47 +00002107 /*HasTemplateKWAndArgsInfo=*/Record[ASTStmtReader::NumExprFields],
Douglas Gregordef03542011-02-04 12:01:24 +00002108 /*NumTemplateArgs=*/Record[ASTStmtReader::NumExprFields]
2109 ? Record[ASTStmtReader::NumExprFields + 1]
2110 : 0);
Argyrios Kyrtzidis12dffcd2010-06-28 09:31:56 +00002111 break;
2112
Sebastian Redl8538e8d2010-08-18 23:57:32 +00002113 case EXPR_CXX_UNRESOLVED_CONSTRUCT:
Douglas Gregor35942772011-09-09 21:34:22 +00002114 S = CXXUnresolvedConstructExpr::CreateEmpty(Context,
Sebastian Redl60adf4a2010-08-18 23:56:52 +00002115 /*NumArgs=*/Record[ASTStmtReader::NumExprFields]);
Argyrios Kyrtzidisa77eb082010-06-25 09:03:26 +00002116 break;
2117
Sebastian Redl8538e8d2010-08-18 23:57:32 +00002118 case EXPR_CXX_UNRESOLVED_MEMBER:
Douglas Gregor35942772011-09-09 21:34:22 +00002119 S = UnresolvedMemberExpr::CreateEmpty(Context,
Abramo Bagnarae4b92762012-01-27 09:46:47 +00002120 /*HasTemplateKWAndArgsInfo=*/Record[ASTStmtReader::NumExprFields],
Douglas Gregordef03542011-02-04 12:01:24 +00002121 /*NumTemplateArgs=*/Record[ASTStmtReader::NumExprFields]
2122 ? Record[ASTStmtReader::NumExprFields + 1]
2123 : 0);
Argyrios Kyrtzidis8dfbd8b2010-06-24 08:57:31 +00002124 break;
Argyrios Kyrtzidisbd65bb52010-06-25 09:03:34 +00002125
Sebastian Redl8538e8d2010-08-18 23:57:32 +00002126 case EXPR_CXX_UNRESOLVED_LOOKUP:
Douglas Gregor35942772011-09-09 21:34:22 +00002127 S = UnresolvedLookupExpr::CreateEmpty(Context,
Abramo Bagnarae4b92762012-01-27 09:46:47 +00002128 /*HasTemplateKWAndArgsInfo=*/Record[ASTStmtReader::NumExprFields],
Douglas Gregordef03542011-02-04 12:01:24 +00002129 /*NumTemplateArgs=*/Record[ASTStmtReader::NumExprFields]
2130 ? Record[ASTStmtReader::NumExprFields + 1]
2131 : 0);
Argyrios Kyrtzidisbd65bb52010-06-25 09:03:34 +00002132 break;
Argyrios Kyrtzidis6d00c132010-07-10 11:46:15 +00002133
Sebastian Redl8538e8d2010-08-18 23:57:32 +00002134 case EXPR_CXX_UNARY_TYPE_TRAIT:
Argyrios Kyrtzidis6d00c132010-07-10 11:46:15 +00002135 S = new (Context) UnaryTypeTraitExpr(Empty);
2136 break;
Sebastian Redl6b219d02010-09-10 20:55:54 +00002137
Francois Pichetf1872372010-12-08 22:35:30 +00002138 case EXPR_BINARY_TYPE_TRAIT:
Francois Pichet6ad6f282010-12-07 00:08:36 +00002139 S = new (Context) BinaryTypeTraitExpr(Empty);
2140 break;
2141
Douglas Gregor4ca8ac22012-02-24 07:38:34 +00002142 case EXPR_TYPE_TRAIT:
2143 S = TypeTraitExpr::CreateDeserialized(Context,
2144 Record[ASTStmtReader::NumExprFields]);
2145 break;
2146
John Wiegley21ff2e52011-04-28 00:16:57 +00002147 case EXPR_ARRAY_TYPE_TRAIT:
2148 S = new (Context) ArrayTypeTraitExpr(Empty);
2149 break;
2150
John Wiegley55262202011-04-25 06:54:41 +00002151 case EXPR_CXX_EXPRESSION_TRAIT:
2152 S = new (Context) ExpressionTraitExpr(Empty);
2153 break;
2154
Sebastian Redl6b219d02010-09-10 20:55:54 +00002155 case EXPR_CXX_NOEXCEPT:
2156 S = new (Context) CXXNoexceptExpr(Empty);
2157 break;
John McCall7cd7d1a2010-11-15 23:31:06 +00002158
Douglas Gregorbe230c32011-01-03 17:17:50 +00002159 case EXPR_PACK_EXPANSION:
2160 S = new (Context) PackExpansionExpr(Empty);
2161 break;
2162
Douglas Gregoree8aff02011-01-04 17:33:58 +00002163 case EXPR_SIZEOF_PACK:
2164 S = new (Context) SizeOfPackExpr(Empty);
2165 break;
2166
John McCall7110fd62011-07-15 07:00:14 +00002167 case EXPR_SUBST_NON_TYPE_TEMPLATE_PARM:
2168 S = new (Context) SubstNonTypeTemplateParmExpr(Empty);
2169 break;
2170
Douglas Gregorc7793c72011-01-15 01:15:58 +00002171 case EXPR_SUBST_NON_TYPE_TEMPLATE_PARM_PACK:
2172 S = new (Context) SubstNonTypeTemplateParmPackExpr(Empty);
2173 break;
2174
Douglas Gregor03e80032011-06-21 17:03:29 +00002175 case EXPR_MATERIALIZE_TEMPORARY:
2176 S = new (Context) MaterializeTemporaryExpr(Empty);
2177 break;
2178
Argyrios Kyrtzidis8bc27822011-12-03 03:49:52 +00002179 case EXPR_OPAQUE_VALUE:
2180 S = new (Context) OpaqueValueExpr(Empty);
John McCall7cd7d1a2010-11-15 23:31:06 +00002181 break;
Peter Collingbournee08ce652011-02-09 21:07:24 +00002182
2183 case EXPR_CUDA_KERNEL_CALL:
Douglas Gregor35942772011-09-09 21:34:22 +00002184 S = new (Context) CUDAKernelCallExpr(Context, Empty);
Peter Collingbournee08ce652011-02-09 21:07:24 +00002185 break;
Tanya Lattner61eee0c2011-06-04 00:47:47 +00002186
2187 case EXPR_ASTYPE:
2188 S = new (Context) AsTypeExpr(Empty);
2189 break;
Eli Friedman276b0612011-10-11 02:20:01 +00002190
John McCall4b9c2d22011-11-06 09:01:30 +00002191 case EXPR_PSEUDO_OBJECT: {
2192 unsigned numSemanticExprs = Record[ASTStmtReader::NumExprFields];
2193 S = PseudoObjectExpr::Create(Context, Empty, numSemanticExprs);
2194 break;
2195 }
2196
Eli Friedman276b0612011-10-11 02:20:01 +00002197 case EXPR_ATOMIC:
2198 S = new (Context) AtomicExpr(Empty);
2199 break;
Douglas Gregor9d36f5d2012-02-14 17:54:36 +00002200
2201 case EXPR_LAMBDA: {
2202 unsigned NumCaptures = Record[ASTStmtReader::NumExprFields];
2203 unsigned NumArrayIndexVars = Record[ASTStmtReader::NumExprFields + 1];
2204 S = LambdaExpr::CreateDeserialized(Context, NumCaptures,
2205 NumArrayIndexVars);
2206 break;
2207 }
Chris Lattner4c6f9522009-04-27 05:14:47 +00002208 }
Argyrios Kyrtzidis6d00c132010-07-10 11:46:15 +00002209
Chris Lattner4c6f9522009-04-27 05:14:47 +00002210 // We hit a STMT_STOP, so we're done with this expression.
2211 if (Finished)
2212 break;
2213
2214 ++NumStatementsRead;
2215
Argyrios Kyrtzidise6f08682011-10-21 23:02:28 +00002216 if (S && !IsStmtReference) {
Argyrios Kyrtzidis919e6932010-06-28 22:28:35 +00002217 Reader.Visit(S);
Argyrios Kyrtzidise6f08682011-10-21 23:02:28 +00002218 StmtEntries[Cursor.GetCurrentBitNo()] = S;
2219 }
2220
Chris Lattner4c6f9522009-04-27 05:14:47 +00002221
2222 assert(Idx == Record.size() && "Invalid deserialization of statement");
2223 StmtStack.push_back(S);
2224 }
Argyrios Kyrtzidis919e6932010-06-28 22:28:35 +00002225
2226#ifndef NDEBUG
2227 assert(StmtStack.size() > PrevNumStmts && "Read too many sub stmts!");
2228 assert(StmtStack.size() == PrevNumStmts + 1 && "Extra expressions on stack!");
2229#endif
2230
2231 return StmtStack.pop_back_val();
Chris Lattner4c6f9522009-04-27 05:14:47 +00002232}