blob: c7748b7f6bae8e0da9a27e7d5f4a564fe31ed9ea [file] [log] [blame]
Sebastian Redl904c9c82010-08-18 23:57:11 +00001//===--- ASTReaderStmt.cpp - Stmt/Expr Deserialization ----------*- C++ -*-===//
Chris Lattner4c6f9522009-04-27 05:14:47 +00002//
3// The LLVM Compiler Infrastructure
4//
5// This file is distributed under the University of Illinois Open Source
6// License. See LICENSE.TXT for details.
7//
8//===----------------------------------------------------------------------===//
9//
10// Statement/expression deserialization. This implements the
Sebastian Redlc43b54c2010-08-18 23:56:43 +000011// ASTReader::ReadStmt method.
Chris Lattner4c6f9522009-04-27 05:14:47 +000012//
13//===----------------------------------------------------------------------===//
14
Sebastian Redl6ab7cd82010-08-18 23:57:17 +000015#include "clang/Serialization/ASTReader.h"
Benjamin Kramer471c8b42012-07-04 20:19:54 +000016#include "clang/AST/ASTContext.h"
Douglas Gregor39da0b82009-09-09 23:08:42 +000017#include "clang/AST/DeclCXX.h"
Douglas Gregorc7793c72011-01-15 01:15:58 +000018#include "clang/AST/DeclTemplate.h"
Chris Lattner4c6f9522009-04-27 05:14:47 +000019#include "clang/AST/StmtVisitor.h"
Benjamin Kramer8fe83e12012-02-04 13:45:25 +000020#include "llvm/ADT/SmallString.h"
Chris Lattner4c6f9522009-04-27 05:14:47 +000021using namespace clang;
Sebastian Redl8538e8d2010-08-18 23:57:32 +000022using namespace clang::serialization;
Chris Lattner4c6f9522009-04-27 05:14:47 +000023
Argyrios Kyrtzidis37bdfe22010-06-30 08:49:18 +000024namespace clang {
Argyrios Kyrtzidis17cfded2010-06-28 09:31:42 +000025
Sebastian Redl60adf4a2010-08-18 23:56:52 +000026 class ASTStmtReader : public StmtVisitor<ASTStmtReader> {
Douglas Gregor409448c2011-07-21 22:35:25 +000027 typedef ASTReader::RecordData RecordData;
28
Sebastian Redlc43b54c2010-08-18 23:56:43 +000029 ASTReader &Reader;
Douglas Gregor1a4761e2011-11-30 23:21:26 +000030 ModuleFile &F;
Sebastian Redl577d4792010-07-22 22:43:28 +000031 llvm::BitstreamCursor &DeclsCursor;
Sebastian Redlc43b54c2010-08-18 23:56:43 +000032 const ASTReader::RecordData &Record;
Chris Lattner4c6f9522009-04-27 05:14:47 +000033 unsigned &Idx;
Chris Lattner4c6f9522009-04-27 05:14:47 +000034
Douglas Gregor409448c2011-07-21 22:35:25 +000035 SourceLocation ReadSourceLocation(const RecordData &R, unsigned &I) {
Sebastian Redlc3632732010-10-05 15:59:54 +000036 return Reader.ReadSourceLocation(F, R, I);
37 }
Douglas Gregor409448c2011-07-21 22:35:25 +000038
39 SourceRange ReadSourceRange(const RecordData &R, unsigned &I) {
Sebastian Redlc3632732010-10-05 15:59:54 +000040 return Reader.ReadSourceRange(F, R, I);
41 }
Douglas Gregor409448c2011-07-21 22:35:25 +000042
43 TypeSourceInfo *GetTypeSourceInfo(const RecordData &R, unsigned &I) {
Sebastian Redlc3632732010-10-05 15:59:54 +000044 return Reader.GetTypeSourceInfo(F, R, I);
45 }
Douglas Gregor409448c2011-07-21 22:35:25 +000046
47 serialization::DeclID ReadDeclID(const RecordData &R, unsigned &I) {
48 return Reader.ReadDeclID(F, R, I);
49 }
50
51 Decl *ReadDecl(const RecordData &R, unsigned &I) {
52 return Reader.ReadDecl(F, R, I);
53 }
54
55 template<typename T>
56 T *ReadDeclAs(const RecordData &R, unsigned &I) {
57 return Reader.ReadDeclAs<T>(F, R, I);
58 }
59
Argyrios Kyrtzidis40451072010-10-15 18:21:24 +000060 void ReadDeclarationNameLoc(DeclarationNameLoc &DNLoc, DeclarationName Name,
61 const ASTReader::RecordData &R, unsigned &I) {
62 Reader.ReadDeclarationNameLoc(F, DNLoc, Name, R, I);
63 }
Douglas Gregor409448c2011-07-21 22:35:25 +000064
Argyrios Kyrtzidis40451072010-10-15 18:21:24 +000065 void ReadDeclarationNameInfo(DeclarationNameInfo &NameInfo,
66 const ASTReader::RecordData &R, unsigned &I) {
67 Reader.ReadDeclarationNameInfo(F, NameInfo, R, I);
68 }
Sebastian Redlc3632732010-10-05 15:59:54 +000069
Chris Lattner4c6f9522009-04-27 05:14:47 +000070 public:
Douglas Gregor1a4761e2011-11-30 23:21:26 +000071 ASTStmtReader(ASTReader &Reader, ModuleFile &F,
Sebastian Redlc3632732010-10-05 15:59:54 +000072 llvm::BitstreamCursor &Cursor,
Sebastian Redlc43b54c2010-08-18 23:56:43 +000073 const ASTReader::RecordData &Record, unsigned &Idx)
Sebastian Redlc3632732010-10-05 15:59:54 +000074 : Reader(Reader), F(F), DeclsCursor(Cursor), Record(Record), Idx(Idx) { }
Chris Lattner4c6f9522009-04-27 05:14:47 +000075
76 /// \brief The number of record fields required for the Stmt class
77 /// itself.
78 static const unsigned NumStmtFields = 0;
79
80 /// \brief The number of record fields required for the Expr class
81 /// itself.
Douglas Gregor561f8122011-07-01 01:22:09 +000082 static const unsigned NumExprFields = NumStmtFields + 7;
Abramo Bagnarae4b92762012-01-27 09:46:47 +000083
84 /// \brief Read and initialize a ExplicitTemplateArgumentList structure.
85 void ReadTemplateKWAndArgsInfo(ASTTemplateKWAndArgsInfo &Args,
86 unsigned NumTemplateArgs);
Argyrios Kyrtzidis36c76f02010-06-28 09:31:48 +000087 /// \brief Read and initialize a ExplicitTemplateArgumentList structure.
Argyrios Kyrtzidisb0c3e092011-09-22 20:07:03 +000088 void ReadExplicitTemplateArgumentList(ASTTemplateArgumentListInfo &ArgList,
Argyrios Kyrtzidis919e6932010-06-28 22:28:35 +000089 unsigned NumTemplateArgs);
Chris Lattner4c6f9522009-04-27 05:14:47 +000090
Argyrios Kyrtzidis919e6932010-06-28 22:28:35 +000091 void VisitStmt(Stmt *S);
John McCall7110fd62011-07-15 07:00:14 +000092#define STMT(Type, Base) \
93 void Visit##Type(Type *);
94#include "clang/AST/StmtNodes.inc"
Chris Lattner4c6f9522009-04-27 05:14:47 +000095 };
96}
97
Sebastian Redl60adf4a2010-08-18 23:56:52 +000098void ASTStmtReader::
Abramo Bagnarae4b92762012-01-27 09:46:47 +000099ReadTemplateKWAndArgsInfo(ASTTemplateKWAndArgsInfo &Args,
100 unsigned NumTemplateArgs) {
101 SourceLocation TemplateKWLoc = ReadSourceLocation(Record, Idx);
Argyrios Kyrtzidis36c76f02010-06-28 09:31:48 +0000102 TemplateArgumentListInfo ArgInfo;
Sebastian Redlc3632732010-10-05 15:59:54 +0000103 ArgInfo.setLAngleLoc(ReadSourceLocation(Record, Idx));
104 ArgInfo.setRAngleLoc(ReadSourceLocation(Record, Idx));
Argyrios Kyrtzidis36c76f02010-06-28 09:31:48 +0000105 for (unsigned i = 0; i != NumTemplateArgs; ++i)
Sebastian Redl577d4792010-07-22 22:43:28 +0000106 ArgInfo.addArgument(
Sebastian Redlc3632732010-10-05 15:59:54 +0000107 Reader.ReadTemplateArgumentLoc(F, Record, Idx));
Abramo Bagnarae4b92762012-01-27 09:46:47 +0000108 Args.initializeFrom(TemplateKWLoc, ArgInfo);
Argyrios Kyrtzidis36c76f02010-06-28 09:31:48 +0000109}
110
Sebastian Redl60adf4a2010-08-18 23:56:52 +0000111void ASTStmtReader::VisitStmt(Stmt *S) {
Chris Lattner4c6f9522009-04-27 05:14:47 +0000112 assert(Idx == NumStmtFields && "Incorrect statement field count");
Chris Lattner4c6f9522009-04-27 05:14:47 +0000113}
114
Sebastian Redl60adf4a2010-08-18 23:56:52 +0000115void ASTStmtReader::VisitNullStmt(NullStmt *S) {
Chris Lattner4c6f9522009-04-27 05:14:47 +0000116 VisitStmt(S);
Sebastian Redlc3632732010-10-05 15:59:54 +0000117 S->setSemiLoc(ReadSourceLocation(Record, Idx));
Argyrios Kyrtzidise2ca8282011-09-01 21:53:45 +0000118 S->HasLeadingEmptyMacro = Record[Idx++];
Chris Lattner4c6f9522009-04-27 05:14:47 +0000119}
120
Sebastian Redl60adf4a2010-08-18 23:56:52 +0000121void ASTStmtReader::VisitCompoundStmt(CompoundStmt *S) {
Chris Lattner4c6f9522009-04-27 05:14:47 +0000122 VisitStmt(S);
Chris Lattner5f9e2722011-07-23 10:55:15 +0000123 SmallVector<Stmt *, 16> Stmts;
Chris Lattner4c6f9522009-04-27 05:14:47 +0000124 unsigned NumStmts = Record[Idx++];
Argyrios Kyrtzidis919e6932010-06-28 22:28:35 +0000125 while (NumStmts--)
Argyrios Kyrtzidisd98a2ab2010-06-29 22:46:25 +0000126 Stmts.push_back(Reader.ReadSubStmt());
Douglas Gregor35942772011-09-09 21:34:22 +0000127 S->setStmts(Reader.getContext(), Stmts.data(), Stmts.size());
Sebastian Redlc3632732010-10-05 15:59:54 +0000128 S->setLBracLoc(ReadSourceLocation(Record, Idx));
129 S->setRBracLoc(ReadSourceLocation(Record, Idx));
Chris Lattner4c6f9522009-04-27 05:14:47 +0000130}
131
Sebastian Redl60adf4a2010-08-18 23:56:52 +0000132void ASTStmtReader::VisitSwitchCase(SwitchCase *S) {
Chris Lattner4c6f9522009-04-27 05:14:47 +0000133 VisitStmt(S);
134 Reader.RecordSwitchCaseID(S, Record[Idx++]);
Argyrios Kyrtzidis81cc2f12013-01-04 18:30:04 +0000135 S->setKeywordLoc(ReadSourceLocation(Record, Idx));
136 S->setColonLoc(ReadSourceLocation(Record, Idx));
Chris Lattner4c6f9522009-04-27 05:14:47 +0000137}
138
Sebastian Redl60adf4a2010-08-18 23:56:52 +0000139void ASTStmtReader::VisitCaseStmt(CaseStmt *S) {
Chris Lattner4c6f9522009-04-27 05:14:47 +0000140 VisitSwitchCase(S);
Argyrios Kyrtzidisd98a2ab2010-06-29 22:46:25 +0000141 S->setLHS(Reader.ReadSubExpr());
142 S->setRHS(Reader.ReadSubExpr());
143 S->setSubStmt(Reader.ReadSubStmt());
Sebastian Redlc3632732010-10-05 15:59:54 +0000144 S->setEllipsisLoc(ReadSourceLocation(Record, Idx));
Chris Lattner4c6f9522009-04-27 05:14:47 +0000145}
146
Sebastian Redl60adf4a2010-08-18 23:56:52 +0000147void ASTStmtReader::VisitDefaultStmt(DefaultStmt *S) {
Chris Lattner4c6f9522009-04-27 05:14:47 +0000148 VisitSwitchCase(S);
Argyrios Kyrtzidisd98a2ab2010-06-29 22:46:25 +0000149 S->setSubStmt(Reader.ReadSubStmt());
Chris Lattner4c6f9522009-04-27 05:14:47 +0000150}
151
Sebastian Redl60adf4a2010-08-18 23:56:52 +0000152void ASTStmtReader::VisitLabelStmt(LabelStmt *S) {
Chris Lattner4c6f9522009-04-27 05:14:47 +0000153 VisitStmt(S);
Douglas Gregor409448c2011-07-21 22:35:25 +0000154 LabelDecl *LD = ReadDeclAs<LabelDecl>(Record, Idx);
Chris Lattnerad8dcf42011-02-17 07:39:24 +0000155 LD->setStmt(S);
156 S->setDecl(LD);
Argyrios Kyrtzidisd98a2ab2010-06-29 22:46:25 +0000157 S->setSubStmt(Reader.ReadSubStmt());
Sebastian Redlc3632732010-10-05 15:59:54 +0000158 S->setIdentLoc(ReadSourceLocation(Record, Idx));
Chris Lattner4c6f9522009-04-27 05:14:47 +0000159}
160
Richard Smith534986f2012-04-14 00:33:13 +0000161void ASTStmtReader::VisitAttributedStmt(AttributedStmt *S) {
162 VisitStmt(S);
Alexander Kornienko49908902012-07-09 10:04:07 +0000163 uint64_t NumAttrs = Record[Idx++];
Richard Smith534986f2012-04-14 00:33:13 +0000164 AttrVec Attrs;
165 Reader.ReadAttributes(F, Attrs, Record, Idx);
Matt Beaumont-Gay50470242012-07-09 18:55:31 +0000166 (void)NumAttrs;
Alexander Kornienko49908902012-07-09 10:04:07 +0000167 assert(NumAttrs == S->NumAttrs);
168 assert(NumAttrs == Attrs.size());
169 std::copy(Attrs.begin(), Attrs.end(), S->Attrs);
Richard Smith534986f2012-04-14 00:33:13 +0000170 S->SubStmt = Reader.ReadSubStmt();
171 S->AttrLoc = ReadSourceLocation(Record, Idx);
172}
173
Sebastian Redl60adf4a2010-08-18 23:56:52 +0000174void ASTStmtReader::VisitIfStmt(IfStmt *S) {
Chris Lattner4c6f9522009-04-27 05:14:47 +0000175 VisitStmt(S);
Richard Smith534986f2012-04-14 00:33:13 +0000176 S->setConditionVariable(Reader.getContext(),
Douglas Gregor409448c2011-07-21 22:35:25 +0000177 ReadDeclAs<VarDecl>(Record, Idx));
Argyrios Kyrtzidisd98a2ab2010-06-29 22:46:25 +0000178 S->setCond(Reader.ReadSubExpr());
179 S->setThen(Reader.ReadSubStmt());
180 S->setElse(Reader.ReadSubStmt());
Sebastian Redlc3632732010-10-05 15:59:54 +0000181 S->setIfLoc(ReadSourceLocation(Record, Idx));
182 S->setElseLoc(ReadSourceLocation(Record, Idx));
Chris Lattner4c6f9522009-04-27 05:14:47 +0000183}
184
Sebastian Redl60adf4a2010-08-18 23:56:52 +0000185void ASTStmtReader::VisitSwitchStmt(SwitchStmt *S) {
Chris Lattner4c6f9522009-04-27 05:14:47 +0000186 VisitStmt(S);
Douglas Gregor35942772011-09-09 21:34:22 +0000187 S->setConditionVariable(Reader.getContext(),
Douglas Gregor409448c2011-07-21 22:35:25 +0000188 ReadDeclAs<VarDecl>(Record, Idx));
Argyrios Kyrtzidisd98a2ab2010-06-29 22:46:25 +0000189 S->setCond(Reader.ReadSubExpr());
190 S->setBody(Reader.ReadSubStmt());
Sebastian Redlc3632732010-10-05 15:59:54 +0000191 S->setSwitchLoc(ReadSourceLocation(Record, Idx));
Ted Kremenek559fb552010-09-09 00:05:53 +0000192 if (Record[Idx++])
193 S->setAllEnumCasesCovered();
194
Chris Lattner4c6f9522009-04-27 05:14:47 +0000195 SwitchCase *PrevSC = 0;
196 for (unsigned N = Record.size(); Idx != N; ++Idx) {
197 SwitchCase *SC = Reader.getSwitchCaseWithID(Record[Idx]);
198 if (PrevSC)
199 PrevSC->setNextSwitchCase(SC);
200 else
201 S->setSwitchCaseList(SC);
Mike Stump1eb44332009-09-09 15:08:12 +0000202
Chris Lattner4c6f9522009-04-27 05:14:47 +0000203 PrevSC = SC;
204 }
Chris Lattner4c6f9522009-04-27 05:14:47 +0000205}
206
Sebastian Redl60adf4a2010-08-18 23:56:52 +0000207void ASTStmtReader::VisitWhileStmt(WhileStmt *S) {
Chris Lattner4c6f9522009-04-27 05:14:47 +0000208 VisitStmt(S);
Douglas Gregor35942772011-09-09 21:34:22 +0000209 S->setConditionVariable(Reader.getContext(),
Douglas Gregor409448c2011-07-21 22:35:25 +0000210 ReadDeclAs<VarDecl>(Record, Idx));
211
Argyrios Kyrtzidisd98a2ab2010-06-29 22:46:25 +0000212 S->setCond(Reader.ReadSubExpr());
213 S->setBody(Reader.ReadSubStmt());
Sebastian Redlc3632732010-10-05 15:59:54 +0000214 S->setWhileLoc(ReadSourceLocation(Record, Idx));
Chris Lattner4c6f9522009-04-27 05:14:47 +0000215}
216
Sebastian Redl60adf4a2010-08-18 23:56:52 +0000217void ASTStmtReader::VisitDoStmt(DoStmt *S) {
Chris Lattner4c6f9522009-04-27 05:14:47 +0000218 VisitStmt(S);
Argyrios Kyrtzidisd98a2ab2010-06-29 22:46:25 +0000219 S->setCond(Reader.ReadSubExpr());
220 S->setBody(Reader.ReadSubStmt());
Sebastian Redlc3632732010-10-05 15:59:54 +0000221 S->setDoLoc(ReadSourceLocation(Record, Idx));
222 S->setWhileLoc(ReadSourceLocation(Record, Idx));
223 S->setRParenLoc(ReadSourceLocation(Record, Idx));
Chris Lattner4c6f9522009-04-27 05:14:47 +0000224}
225
Sebastian Redl60adf4a2010-08-18 23:56:52 +0000226void ASTStmtReader::VisitForStmt(ForStmt *S) {
Chris Lattner4c6f9522009-04-27 05:14:47 +0000227 VisitStmt(S);
Argyrios Kyrtzidisd98a2ab2010-06-29 22:46:25 +0000228 S->setInit(Reader.ReadSubStmt());
229 S->setCond(Reader.ReadSubExpr());
Douglas Gregor35942772011-09-09 21:34:22 +0000230 S->setConditionVariable(Reader.getContext(),
Douglas Gregor409448c2011-07-21 22:35:25 +0000231 ReadDeclAs<VarDecl>(Record, Idx));
Argyrios Kyrtzidisd98a2ab2010-06-29 22:46:25 +0000232 S->setInc(Reader.ReadSubExpr());
233 S->setBody(Reader.ReadSubStmt());
Sebastian Redlc3632732010-10-05 15:59:54 +0000234 S->setForLoc(ReadSourceLocation(Record, Idx));
235 S->setLParenLoc(ReadSourceLocation(Record, Idx));
236 S->setRParenLoc(ReadSourceLocation(Record, Idx));
Chris Lattner4c6f9522009-04-27 05:14:47 +0000237}
238
Sebastian Redl60adf4a2010-08-18 23:56:52 +0000239void ASTStmtReader::VisitGotoStmt(GotoStmt *S) {
Chris Lattner4c6f9522009-04-27 05:14:47 +0000240 VisitStmt(S);
Douglas Gregor409448c2011-07-21 22:35:25 +0000241 S->setLabel(ReadDeclAs<LabelDecl>(Record, Idx));
Sebastian Redlc3632732010-10-05 15:59:54 +0000242 S->setGotoLoc(ReadSourceLocation(Record, Idx));
243 S->setLabelLoc(ReadSourceLocation(Record, Idx));
Chris Lattner4c6f9522009-04-27 05:14:47 +0000244}
245
Sebastian Redl60adf4a2010-08-18 23:56:52 +0000246void ASTStmtReader::VisitIndirectGotoStmt(IndirectGotoStmt *S) {
Chris Lattner4c6f9522009-04-27 05:14:47 +0000247 VisitStmt(S);
Sebastian Redlc3632732010-10-05 15:59:54 +0000248 S->setGotoLoc(ReadSourceLocation(Record, Idx));
249 S->setStarLoc(ReadSourceLocation(Record, Idx));
Argyrios Kyrtzidisd98a2ab2010-06-29 22:46:25 +0000250 S->setTarget(Reader.ReadSubExpr());
Chris Lattner4c6f9522009-04-27 05:14:47 +0000251}
252
Sebastian Redl60adf4a2010-08-18 23:56:52 +0000253void ASTStmtReader::VisitContinueStmt(ContinueStmt *S) {
Chris Lattner4c6f9522009-04-27 05:14:47 +0000254 VisitStmt(S);
Sebastian Redlc3632732010-10-05 15:59:54 +0000255 S->setContinueLoc(ReadSourceLocation(Record, Idx));
Chris Lattner4c6f9522009-04-27 05:14:47 +0000256}
257
Sebastian Redl60adf4a2010-08-18 23:56:52 +0000258void ASTStmtReader::VisitBreakStmt(BreakStmt *S) {
Chris Lattner4c6f9522009-04-27 05:14:47 +0000259 VisitStmt(S);
Sebastian Redlc3632732010-10-05 15:59:54 +0000260 S->setBreakLoc(ReadSourceLocation(Record, Idx));
Chris Lattner4c6f9522009-04-27 05:14:47 +0000261}
262
Sebastian Redl60adf4a2010-08-18 23:56:52 +0000263void ASTStmtReader::VisitReturnStmt(ReturnStmt *S) {
Chris Lattner4c6f9522009-04-27 05:14:47 +0000264 VisitStmt(S);
Argyrios Kyrtzidisd98a2ab2010-06-29 22:46:25 +0000265 S->setRetValue(Reader.ReadSubExpr());
Sebastian Redlc3632732010-10-05 15:59:54 +0000266 S->setReturnLoc(ReadSourceLocation(Record, Idx));
Douglas Gregor409448c2011-07-21 22:35:25 +0000267 S->setNRVOCandidate(ReadDeclAs<VarDecl>(Record, Idx));
Chris Lattner4c6f9522009-04-27 05:14:47 +0000268}
269
Sebastian Redl60adf4a2010-08-18 23:56:52 +0000270void ASTStmtReader::VisitDeclStmt(DeclStmt *S) {
Chris Lattner4c6f9522009-04-27 05:14:47 +0000271 VisitStmt(S);
Sebastian Redlc3632732010-10-05 15:59:54 +0000272 S->setStartLoc(ReadSourceLocation(Record, Idx));
273 S->setEndLoc(ReadSourceLocation(Record, Idx));
Chris Lattner4c6f9522009-04-27 05:14:47 +0000274
275 if (Idx + 1 == Record.size()) {
276 // Single declaration
Douglas Gregor409448c2011-07-21 22:35:25 +0000277 S->setDeclGroup(DeclGroupRef(ReadDecl(Record, Idx)));
Chris Lattner4c6f9522009-04-27 05:14:47 +0000278 } else {
Chris Lattner5f9e2722011-07-23 10:55:15 +0000279 SmallVector<Decl *, 16> Decls;
Douglas Gregor409448c2011-07-21 22:35:25 +0000280 Decls.reserve(Record.size() - Idx);
281 for (unsigned N = Record.size(); Idx != N; )
282 Decls.push_back(ReadDecl(Record, Idx));
Douglas Gregor35942772011-09-09 21:34:22 +0000283 S->setDeclGroup(DeclGroupRef(DeclGroup::Create(Reader.getContext(),
Douglas Gregor75fdb232009-05-22 22:45:36 +0000284 Decls.data(),
285 Decls.size())));
Chris Lattner4c6f9522009-04-27 05:14:47 +0000286 }
Chris Lattner4c6f9522009-04-27 05:14:47 +0000287}
288
Chad Rosierdf5faf52012-08-25 00:11:56 +0000289void ASTStmtReader::VisitGCCAsmStmt(GCCAsmStmt *S) {
Chris Lattner4c6f9522009-04-27 05:14:47 +0000290 VisitStmt(S);
291 unsigned NumOutputs = Record[Idx++];
292 unsigned NumInputs = Record[Idx++];
293 unsigned NumClobbers = Record[Idx++];
Sebastian Redlc3632732010-10-05 15:59:54 +0000294 S->setAsmLoc(ReadSourceLocation(Record, Idx));
295 S->setRParenLoc(ReadSourceLocation(Record, Idx));
Chris Lattner4c6f9522009-04-27 05:14:47 +0000296 S->setVolatile(Record[Idx++]);
297 S->setSimple(Record[Idx++]);
Mike Stump1eb44332009-09-09 15:08:12 +0000298
Argyrios Kyrtzidisd98a2ab2010-06-29 22:46:25 +0000299 S->setAsmString(cast_or_null<StringLiteral>(Reader.ReadSubStmt()));
Chris Lattner4c6f9522009-04-27 05:14:47 +0000300
301 // Outputs and inputs
Chris Lattner5f9e2722011-07-23 10:55:15 +0000302 SmallVector<IdentifierInfo *, 16> Names;
303 SmallVector<StringLiteral*, 16> Constraints;
304 SmallVector<Stmt*, 16> Exprs;
Chris Lattner4c6f9522009-04-27 05:14:47 +0000305 for (unsigned I = 0, N = NumOutputs + NumInputs; I != N; ++I) {
Douglas Gregor95eab172011-07-28 20:55:49 +0000306 Names.push_back(Reader.GetIdentifierInfo(F, Record, Idx));
Argyrios Kyrtzidisd98a2ab2010-06-29 22:46:25 +0000307 Constraints.push_back(cast_or_null<StringLiteral>(Reader.ReadSubStmt()));
308 Exprs.push_back(Reader.ReadSubStmt());
Chris Lattner4c6f9522009-04-27 05:14:47 +0000309 }
Chris Lattner4c6f9522009-04-27 05:14:47 +0000310
311 // Constraints
Chris Lattner5f9e2722011-07-23 10:55:15 +0000312 SmallVector<StringLiteral*, 16> Clobbers;
Chris Lattner4c6f9522009-04-27 05:14:47 +0000313 for (unsigned I = 0; I != NumClobbers; ++I)
Argyrios Kyrtzidisd98a2ab2010-06-29 22:46:25 +0000314 Clobbers.push_back(cast_or_null<StringLiteral>(Reader.ReadSubStmt()));
Anders Carlssonfdba9c02010-01-30 19:34:25 +0000315
Douglas Gregor35942772011-09-09 21:34:22 +0000316 S->setOutputsAndInputsAndClobbers(Reader.getContext(),
Anders Carlssonacb6bcb2010-01-30 20:38:10 +0000317 Names.data(), Constraints.data(),
Anders Carlssonfdba9c02010-01-30 19:34:25 +0000318 Exprs.data(), NumOutputs, NumInputs,
319 Clobbers.data(), NumClobbers);
Chris Lattner4c6f9522009-04-27 05:14:47 +0000320}
321
Chad Rosier8cd64b42012-06-11 20:47:18 +0000322void ASTStmtReader::VisitMSAsmStmt(MSAsmStmt *S) {
323 // FIXME: Statement reader not yet implemented for MS style inline asm.
324 VisitStmt(S);
325}
326
Tareq A. Siraj051303c2013-04-16 18:53:08 +0000327void ASTStmtReader::VisitCapturedStmt(CapturedStmt *S) {
328 llvm_unreachable("not implemented yet");
329}
330
Sebastian Redl60adf4a2010-08-18 23:56:52 +0000331void ASTStmtReader::VisitExpr(Expr *E) {
Chris Lattner4c6f9522009-04-27 05:14:47 +0000332 VisitStmt(E);
Douglas Gregor393f2492011-07-22 00:38:23 +0000333 E->setType(Reader.readType(F, Record, Idx));
Chris Lattner4c6f9522009-04-27 05:14:47 +0000334 E->setTypeDependent(Record[Idx++]);
335 E->setValueDependent(Record[Idx++]);
Douglas Gregor561f8122011-07-01 01:22:09 +0000336 E->setInstantiationDependent(Record[Idx++]);
Douglas Gregord0937222010-12-13 22:49:22 +0000337 E->ExprBits.ContainsUnexpandedParameterPack = Record[Idx++];
John McCallf89e55a2010-11-18 06:31:45 +0000338 E->setValueKind(static_cast<ExprValueKind>(Record[Idx++]));
339 E->setObjectKind(static_cast<ExprObjectKind>(Record[Idx++]));
Chris Lattner4c6f9522009-04-27 05:14:47 +0000340 assert(Idx == NumExprFields && "Incorrect expression field count");
Chris Lattner4c6f9522009-04-27 05:14:47 +0000341}
342
Sebastian Redl60adf4a2010-08-18 23:56:52 +0000343void ASTStmtReader::VisitPredefinedExpr(PredefinedExpr *E) {
Chris Lattner4c6f9522009-04-27 05:14:47 +0000344 VisitExpr(E);
Sebastian Redlc3632732010-10-05 15:59:54 +0000345 E->setLocation(ReadSourceLocation(Record, Idx));
Chris Lattner4c6f9522009-04-27 05:14:47 +0000346 E->setIdentType((PredefinedExpr::IdentType)Record[Idx++]);
Chris Lattner4c6f9522009-04-27 05:14:47 +0000347}
348
Sebastian Redl60adf4a2010-08-18 23:56:52 +0000349void ASTStmtReader::VisitDeclRefExpr(DeclRefExpr *E) {
Chris Lattner4c6f9522009-04-27 05:14:47 +0000350 VisitExpr(E);
Argyrios Kyrtzidis663e3802010-07-08 13:09:47 +0000351
Chandler Carruthcb66cff2011-05-01 21:29:53 +0000352 E->DeclRefExprBits.HasQualifier = Record[Idx++];
Chandler Carruth3aa81402011-05-01 23:48:14 +0000353 E->DeclRefExprBits.HasFoundDecl = Record[Idx++];
Abramo Bagnarae4b92762012-01-27 09:46:47 +0000354 E->DeclRefExprBits.HasTemplateKWAndArgsInfo = Record[Idx++];
Abramo Bagnara7cc58b42011-10-05 07:56:41 +0000355 E->DeclRefExprBits.HadMultipleCandidates = Record[Idx++];
John McCallf4b88a42012-03-10 09:33:50 +0000356 E->DeclRefExprBits.RefersToEnclosingLocal = Record[Idx++];
Anders Carlssonb0ca1372011-03-06 18:19:42 +0000357 unsigned NumTemplateArgs = 0;
Abramo Bagnarae4b92762012-01-27 09:46:47 +0000358 if (E->hasTemplateKWAndArgsInfo())
Anders Carlssonb0ca1372011-03-06 18:19:42 +0000359 NumTemplateArgs = Record[Idx++];
360
Chandler Carruthcb66cff2011-05-01 21:29:53 +0000361 if (E->hasQualifier())
Chandler Carruth6857c3e2011-05-01 22:14:37 +0000362 E->getInternalQualifierLoc()
Douglas Gregor40d96a62011-02-28 21:54:11 +0000363 = Reader.ReadNestedNameSpecifierLoc(F, Record, Idx);
Argyrios Kyrtzidis663e3802010-07-08 13:09:47 +0000364
Chandler Carruth3aa81402011-05-01 23:48:14 +0000365 if (E->hasFoundDecl())
Douglas Gregor409448c2011-07-21 22:35:25 +0000366 E->getInternalFoundDecl() = ReadDeclAs<NamedDecl>(Record, Idx);
Chandler Carruth3aa81402011-05-01 23:48:14 +0000367
Abramo Bagnarae4b92762012-01-27 09:46:47 +0000368 if (E->hasTemplateKWAndArgsInfo())
369 ReadTemplateKWAndArgsInfo(*E->getTemplateKWAndArgsInfo(),
370 NumTemplateArgs);
Argyrios Kyrtzidis663e3802010-07-08 13:09:47 +0000371
Douglas Gregor409448c2011-07-21 22:35:25 +0000372 E->setDecl(ReadDeclAs<ValueDecl>(Record, Idx));
Sebastian Redlc3632732010-10-05 15:59:54 +0000373 E->setLocation(ReadSourceLocation(Record, Idx));
Argyrios Kyrtzidis40451072010-10-15 18:21:24 +0000374 ReadDeclarationNameLoc(E->DNLoc, E->getDecl()->getDeclName(), Record, Idx);
Chris Lattner4c6f9522009-04-27 05:14:47 +0000375}
376
Sebastian Redl60adf4a2010-08-18 23:56:52 +0000377void ASTStmtReader::VisitIntegerLiteral(IntegerLiteral *E) {
Chris Lattner4c6f9522009-04-27 05:14:47 +0000378 VisitExpr(E);
Sebastian Redlc3632732010-10-05 15:59:54 +0000379 E->setLocation(ReadSourceLocation(Record, Idx));
Douglas Gregor35942772011-09-09 21:34:22 +0000380 E->setValue(Reader.getContext(), Reader.ReadAPInt(Record, Idx));
Chris Lattner4c6f9522009-04-27 05:14:47 +0000381}
382
Sebastian Redl60adf4a2010-08-18 23:56:52 +0000383void ASTStmtReader::VisitFloatingLiteral(FloatingLiteral *E) {
Chris Lattner4c6f9522009-04-27 05:14:47 +0000384 VisitExpr(E);
Tim Northover9ec55f22013-01-22 09:46:51 +0000385 E->setRawSemantics(static_cast<Stmt::APFloatSemantics>(Record[Idx++]));
Chris Lattner4c6f9522009-04-27 05:14:47 +0000386 E->setExact(Record[Idx++]);
Tim Northover9ec55f22013-01-22 09:46:51 +0000387 E->setValue(Reader.getContext(),
388 Reader.ReadAPFloat(Record, E->getSemantics(), Idx));
Sebastian Redlc3632732010-10-05 15:59:54 +0000389 E->setLocation(ReadSourceLocation(Record, Idx));
Chris Lattner4c6f9522009-04-27 05:14:47 +0000390}
391
Sebastian Redl60adf4a2010-08-18 23:56:52 +0000392void ASTStmtReader::VisitImaginaryLiteral(ImaginaryLiteral *E) {
Chris Lattner4c6f9522009-04-27 05:14:47 +0000393 VisitExpr(E);
Argyrios Kyrtzidisd98a2ab2010-06-29 22:46:25 +0000394 E->setSubExpr(Reader.ReadSubExpr());
Chris Lattner4c6f9522009-04-27 05:14:47 +0000395}
396
Sebastian Redl60adf4a2010-08-18 23:56:52 +0000397void ASTStmtReader::VisitStringLiteral(StringLiteral *E) {
Chris Lattner4c6f9522009-04-27 05:14:47 +0000398 VisitExpr(E);
399 unsigned Len = Record[Idx++];
Mike Stump1eb44332009-09-09 15:08:12 +0000400 assert(Record[Idx] == E->getNumConcatenated() &&
Chris Lattner4c6f9522009-04-27 05:14:47 +0000401 "Wrong number of concatenated tokens!");
402 ++Idx;
Eli Friedman64f45a22011-11-01 02:23:42 +0000403 StringLiteral::StringKind kind =
404 static_cast<StringLiteral::StringKind>(Record[Idx++]);
405 bool isPascal = Record[Idx++];
Chris Lattner4c6f9522009-04-27 05:14:47 +0000406
Mike Stump1eb44332009-09-09 15:08:12 +0000407 // Read string data
Dylan Noblesmithf7ccbad2012-02-05 02:13:05 +0000408 SmallString<16> Str(&Record[Idx], &Record[Idx] + Len);
Eli Friedman64f45a22011-11-01 02:23:42 +0000409 E->setString(Reader.getContext(), Str.str(), kind, isPascal);
Chris Lattner4c6f9522009-04-27 05:14:47 +0000410 Idx += Len;
411
412 // Read source locations
413 for (unsigned I = 0, N = E->getNumConcatenated(); I != N; ++I)
Sebastian Redlc3632732010-10-05 15:59:54 +0000414 E->setStrTokenLoc(I, ReadSourceLocation(Record, Idx));
Chris Lattner4c6f9522009-04-27 05:14:47 +0000415}
416
Sebastian Redl60adf4a2010-08-18 23:56:52 +0000417void ASTStmtReader::VisitCharacterLiteral(CharacterLiteral *E) {
Chris Lattner4c6f9522009-04-27 05:14:47 +0000418 VisitExpr(E);
419 E->setValue(Record[Idx++]);
Sebastian Redlc3632732010-10-05 15:59:54 +0000420 E->setLocation(ReadSourceLocation(Record, Idx));
Douglas Gregor5cee1192011-07-27 05:40:30 +0000421 E->setKind(static_cast<CharacterLiteral::CharacterKind>(Record[Idx++]));
Chris Lattner4c6f9522009-04-27 05:14:47 +0000422}
423
Sebastian Redl60adf4a2010-08-18 23:56:52 +0000424void ASTStmtReader::VisitParenExpr(ParenExpr *E) {
Chris Lattner4c6f9522009-04-27 05:14:47 +0000425 VisitExpr(E);
Sebastian Redlc3632732010-10-05 15:59:54 +0000426 E->setLParen(ReadSourceLocation(Record, Idx));
427 E->setRParen(ReadSourceLocation(Record, Idx));
Argyrios Kyrtzidisd98a2ab2010-06-29 22:46:25 +0000428 E->setSubExpr(Reader.ReadSubExpr());
Chris Lattner4c6f9522009-04-27 05:14:47 +0000429}
430
Sebastian Redl60adf4a2010-08-18 23:56:52 +0000431void ASTStmtReader::VisitParenListExpr(ParenListExpr *E) {
Argyrios Kyrtzidis37bdfe22010-06-30 08:49:18 +0000432 VisitExpr(E);
433 unsigned NumExprs = Record[Idx++];
Douglas Gregor35942772011-09-09 21:34:22 +0000434 E->Exprs = new (Reader.getContext()) Stmt*[NumExprs];
Argyrios Kyrtzidis37bdfe22010-06-30 08:49:18 +0000435 for (unsigned i = 0; i != NumExprs; ++i)
436 E->Exprs[i] = Reader.ReadSubStmt();
437 E->NumExprs = NumExprs;
Sebastian Redlc3632732010-10-05 15:59:54 +0000438 E->LParenLoc = ReadSourceLocation(Record, Idx);
439 E->RParenLoc = ReadSourceLocation(Record, Idx);
Argyrios Kyrtzidis37bdfe22010-06-30 08:49:18 +0000440}
441
Sebastian Redl60adf4a2010-08-18 23:56:52 +0000442void ASTStmtReader::VisitUnaryOperator(UnaryOperator *E) {
Chris Lattner4c6f9522009-04-27 05:14:47 +0000443 VisitExpr(E);
Argyrios Kyrtzidisd98a2ab2010-06-29 22:46:25 +0000444 E->setSubExpr(Reader.ReadSubExpr());
Chris Lattner4c6f9522009-04-27 05:14:47 +0000445 E->setOpcode((UnaryOperator::Opcode)Record[Idx++]);
Sebastian Redlc3632732010-10-05 15:59:54 +0000446 E->setOperatorLoc(ReadSourceLocation(Record, Idx));
Chris Lattner4c6f9522009-04-27 05:14:47 +0000447}
448
Sebastian Redl60adf4a2010-08-18 23:56:52 +0000449void ASTStmtReader::VisitOffsetOfExpr(OffsetOfExpr *E) {
Douglas Gregor8ecdb652010-04-28 22:16:22 +0000450 typedef OffsetOfExpr::OffsetOfNode Node;
451 VisitExpr(E);
452 assert(E->getNumComponents() == Record[Idx]);
453 ++Idx;
454 assert(E->getNumExpressions() == Record[Idx]);
455 ++Idx;
Sebastian Redlc3632732010-10-05 15:59:54 +0000456 E->setOperatorLoc(ReadSourceLocation(Record, Idx));
457 E->setRParenLoc(ReadSourceLocation(Record, Idx));
458 E->setTypeSourceInfo(GetTypeSourceInfo(Record, Idx));
Douglas Gregor8ecdb652010-04-28 22:16:22 +0000459 for (unsigned I = 0, N = E->getNumComponents(); I != N; ++I) {
460 Node::Kind Kind = static_cast<Node::Kind>(Record[Idx++]);
Sebastian Redlc3632732010-10-05 15:59:54 +0000461 SourceLocation Start = ReadSourceLocation(Record, Idx);
462 SourceLocation End = ReadSourceLocation(Record, Idx);
Douglas Gregor8ecdb652010-04-28 22:16:22 +0000463 switch (Kind) {
464 case Node::Array:
465 E->setComponent(I, Node(Start, Record[Idx++], End));
466 break;
467
468 case Node::Field:
Douglas Gregor409448c2011-07-21 22:35:25 +0000469 E->setComponent(I, Node(Start, ReadDeclAs<FieldDecl>(Record, Idx), End));
Douglas Gregor8ecdb652010-04-28 22:16:22 +0000470 break;
471
472 case Node::Identifier:
Douglas Gregor95eab172011-07-28 20:55:49 +0000473 E->setComponent(I,
474 Node(Start,
475 Reader.GetIdentifierInfo(F, Record, Idx),
476 End));
Douglas Gregor8ecdb652010-04-28 22:16:22 +0000477 break;
Douglas Gregorcc8a5d52010-04-29 00:18:15 +0000478
Argyrios Kyrtzidisafbf3122010-07-29 18:16:10 +0000479 case Node::Base: {
Douglas Gregor35942772011-09-09 21:34:22 +0000480 CXXBaseSpecifier *Base = new (Reader.getContext()) CXXBaseSpecifier();
Sebastian Redlc3632732010-10-05 15:59:54 +0000481 *Base = Reader.ReadCXXBaseSpecifier(F, Record, Idx);
Argyrios Kyrtzidisafbf3122010-07-29 18:16:10 +0000482 E->setComponent(I, Node(Base));
Douglas Gregorcc8a5d52010-04-29 00:18:15 +0000483 break;
Douglas Gregor8ecdb652010-04-28 22:16:22 +0000484 }
Argyrios Kyrtzidisafbf3122010-07-29 18:16:10 +0000485 }
Douglas Gregor8ecdb652010-04-28 22:16:22 +0000486 }
487
488 for (unsigned I = 0, N = E->getNumExpressions(); I != N; ++I)
Argyrios Kyrtzidisd98a2ab2010-06-29 22:46:25 +0000489 E->setIndexExpr(I, Reader.ReadSubExpr());
Douglas Gregor8ecdb652010-04-28 22:16:22 +0000490}
491
Peter Collingbournef4e3cfb2011-03-11 19:24:49 +0000492void ASTStmtReader::VisitUnaryExprOrTypeTraitExpr(UnaryExprOrTypeTraitExpr *E) {
Chris Lattner4c6f9522009-04-27 05:14:47 +0000493 VisitExpr(E);
Peter Collingbournef4e3cfb2011-03-11 19:24:49 +0000494 E->setKind(static_cast<UnaryExprOrTypeTrait>(Record[Idx++]));
Chris Lattner4c6f9522009-04-27 05:14:47 +0000495 if (Record[Idx] == 0) {
Argyrios Kyrtzidisd98a2ab2010-06-29 22:46:25 +0000496 E->setArgument(Reader.ReadSubExpr());
Chris Lattner4c6f9522009-04-27 05:14:47 +0000497 ++Idx;
498 } else {
Sebastian Redlc3632732010-10-05 15:59:54 +0000499 E->setArgument(GetTypeSourceInfo(Record, Idx));
Chris Lattner4c6f9522009-04-27 05:14:47 +0000500 }
Sebastian Redlc3632732010-10-05 15:59:54 +0000501 E->setOperatorLoc(ReadSourceLocation(Record, Idx));
502 E->setRParenLoc(ReadSourceLocation(Record, Idx));
Chris Lattner4c6f9522009-04-27 05:14:47 +0000503}
504
Sebastian Redl60adf4a2010-08-18 23:56:52 +0000505void ASTStmtReader::VisitArraySubscriptExpr(ArraySubscriptExpr *E) {
Chris Lattner4c6f9522009-04-27 05:14:47 +0000506 VisitExpr(E);
Argyrios Kyrtzidisd98a2ab2010-06-29 22:46:25 +0000507 E->setLHS(Reader.ReadSubExpr());
508 E->setRHS(Reader.ReadSubExpr());
Sebastian Redlc3632732010-10-05 15:59:54 +0000509 E->setRBracketLoc(ReadSourceLocation(Record, Idx));
Chris Lattner4c6f9522009-04-27 05:14:47 +0000510}
511
Sebastian Redl60adf4a2010-08-18 23:56:52 +0000512void ASTStmtReader::VisitCallExpr(CallExpr *E) {
Chris Lattner4c6f9522009-04-27 05:14:47 +0000513 VisitExpr(E);
Douglas Gregor35942772011-09-09 21:34:22 +0000514 E->setNumArgs(Reader.getContext(), Record[Idx++]);
Sebastian Redlc3632732010-10-05 15:59:54 +0000515 E->setRParenLoc(ReadSourceLocation(Record, Idx));
Argyrios Kyrtzidisd98a2ab2010-06-29 22:46:25 +0000516 E->setCallee(Reader.ReadSubExpr());
Chris Lattner4c6f9522009-04-27 05:14:47 +0000517 for (unsigned I = 0, N = E->getNumArgs(); I != N; ++I)
Argyrios Kyrtzidisd98a2ab2010-06-29 22:46:25 +0000518 E->setArg(I, Reader.ReadSubExpr());
Chris Lattner4c6f9522009-04-27 05:14:47 +0000519}
520
John McCall7110fd62011-07-15 07:00:14 +0000521void ASTStmtReader::VisitCXXMemberCallExpr(CXXMemberCallExpr *E) {
522 VisitCallExpr(E);
523}
524
Sebastian Redl60adf4a2010-08-18 23:56:52 +0000525void ASTStmtReader::VisitMemberExpr(MemberExpr *E) {
Argyrios Kyrtzidis663e3802010-07-08 13:09:47 +0000526 // Don't call VisitExpr, this is fully initialized at creation.
527 assert(E->getStmtClass() == Stmt::MemberExprClass &&
528 "It's a subclass, we must advance Idx!");
Chris Lattner4c6f9522009-04-27 05:14:47 +0000529}
530
Sebastian Redl60adf4a2010-08-18 23:56:52 +0000531void ASTStmtReader::VisitObjCIsaExpr(ObjCIsaExpr *E) {
Steve Narofff242b1b2009-07-24 17:54:45 +0000532 VisitExpr(E);
Argyrios Kyrtzidisd98a2ab2010-06-29 22:46:25 +0000533 E->setBase(Reader.ReadSubExpr());
Sebastian Redlc3632732010-10-05 15:59:54 +0000534 E->setIsaMemberLoc(ReadSourceLocation(Record, Idx));
Fariborz Jahanianec8deba2013-03-28 19:50:55 +0000535 E->setOpLoc(ReadSourceLocation(Record, Idx));
Steve Narofff242b1b2009-07-24 17:54:45 +0000536 E->setArrow(Record[Idx++]);
Steve Narofff242b1b2009-07-24 17:54:45 +0000537}
538
John McCallf85e1932011-06-15 23:02:42 +0000539void ASTStmtReader::
540VisitObjCIndirectCopyRestoreExpr(ObjCIndirectCopyRestoreExpr *E) {
541 VisitExpr(E);
542 E->Operand = Reader.ReadSubExpr();
543 E->setShouldCopy(Record[Idx++]);
544}
545
546void ASTStmtReader::VisitObjCBridgedCastExpr(ObjCBridgedCastExpr *E) {
547 VisitExplicitCastExpr(E);
548 E->LParenLoc = ReadSourceLocation(Record, Idx);
549 E->BridgeKeywordLoc = ReadSourceLocation(Record, Idx);
550 E->Kind = Record[Idx++];
551}
552
Sebastian Redl60adf4a2010-08-18 23:56:52 +0000553void ASTStmtReader::VisitCastExpr(CastExpr *E) {
Chris Lattner4c6f9522009-04-27 05:14:47 +0000554 VisitExpr(E);
John McCallf871d0c2010-08-07 06:22:56 +0000555 unsigned NumBaseSpecs = Record[Idx++];
556 assert(NumBaseSpecs == E->path_size());
Argyrios Kyrtzidisd98a2ab2010-06-29 22:46:25 +0000557 E->setSubExpr(Reader.ReadSubExpr());
Anders Carlssoncdef2b72009-07-31 00:48:10 +0000558 E->setCastKind((CastExpr::CastKind)Record[Idx++]);
John McCallf871d0c2010-08-07 06:22:56 +0000559 CastExpr::path_iterator BaseI = E->path_begin();
Argyrios Kyrtzidis0745d0a2010-07-02 23:30:27 +0000560 while (NumBaseSpecs--) {
Douglas Gregor35942772011-09-09 21:34:22 +0000561 CXXBaseSpecifier *BaseSpec = new (Reader.getContext()) CXXBaseSpecifier;
Sebastian Redlc3632732010-10-05 15:59:54 +0000562 *BaseSpec = Reader.ReadCXXBaseSpecifier(F, Record, Idx);
John McCallf871d0c2010-08-07 06:22:56 +0000563 *BaseI++ = BaseSpec;
Argyrios Kyrtzidis0745d0a2010-07-02 23:30:27 +0000564 }
Chris Lattner4c6f9522009-04-27 05:14:47 +0000565}
566
Sebastian Redl60adf4a2010-08-18 23:56:52 +0000567void ASTStmtReader::VisitBinaryOperator(BinaryOperator *E) {
Chris Lattner4c6f9522009-04-27 05:14:47 +0000568 VisitExpr(E);
Argyrios Kyrtzidisd98a2ab2010-06-29 22:46:25 +0000569 E->setLHS(Reader.ReadSubExpr());
570 E->setRHS(Reader.ReadSubExpr());
Chris Lattner4c6f9522009-04-27 05:14:47 +0000571 E->setOpcode((BinaryOperator::Opcode)Record[Idx++]);
Sebastian Redlc3632732010-10-05 15:59:54 +0000572 E->setOperatorLoc(ReadSourceLocation(Record, Idx));
Lang Hamesbe9af122012-10-02 04:45:10 +0000573 E->setFPContractable((bool)Record[Idx++]);
Chris Lattner4c6f9522009-04-27 05:14:47 +0000574}
575
Sebastian Redl60adf4a2010-08-18 23:56:52 +0000576void ASTStmtReader::VisitCompoundAssignOperator(CompoundAssignOperator *E) {
Chris Lattner4c6f9522009-04-27 05:14:47 +0000577 VisitBinaryOperator(E);
Douglas Gregor393f2492011-07-22 00:38:23 +0000578 E->setComputationLHSType(Reader.readType(F, Record, Idx));
579 E->setComputationResultType(Reader.readType(F, Record, Idx));
Chris Lattner4c6f9522009-04-27 05:14:47 +0000580}
581
Sebastian Redl60adf4a2010-08-18 23:56:52 +0000582void ASTStmtReader::VisitConditionalOperator(ConditionalOperator *E) {
Chris Lattner4c6f9522009-04-27 05:14:47 +0000583 VisitExpr(E);
John McCall56ca35d2011-02-17 10:25:35 +0000584 E->SubExprs[ConditionalOperator::COND] = Reader.ReadSubExpr();
585 E->SubExprs[ConditionalOperator::LHS] = Reader.ReadSubExpr();
586 E->SubExprs[ConditionalOperator::RHS] = Reader.ReadSubExpr();
587 E->QuestionLoc = ReadSourceLocation(Record, Idx);
588 E->ColonLoc = ReadSourceLocation(Record, Idx);
589}
590
591void
592ASTStmtReader::VisitBinaryConditionalOperator(BinaryConditionalOperator *E) {
593 VisitExpr(E);
594 E->OpaqueValue = cast<OpaqueValueExpr>(Reader.ReadSubExpr());
595 E->SubExprs[BinaryConditionalOperator::COMMON] = Reader.ReadSubExpr();
596 E->SubExprs[BinaryConditionalOperator::COND] = Reader.ReadSubExpr();
597 E->SubExprs[BinaryConditionalOperator::LHS] = Reader.ReadSubExpr();
598 E->SubExprs[BinaryConditionalOperator::RHS] = Reader.ReadSubExpr();
599 E->QuestionLoc = ReadSourceLocation(Record, Idx);
600 E->ColonLoc = ReadSourceLocation(Record, Idx);
Chris Lattner4c6f9522009-04-27 05:14:47 +0000601}
602
Sebastian Redl60adf4a2010-08-18 23:56:52 +0000603void ASTStmtReader::VisitImplicitCastExpr(ImplicitCastExpr *E) {
Chris Lattner4c6f9522009-04-27 05:14:47 +0000604 VisitCastExpr(E);
Chris Lattner4c6f9522009-04-27 05:14:47 +0000605}
606
Sebastian Redl60adf4a2010-08-18 23:56:52 +0000607void ASTStmtReader::VisitExplicitCastExpr(ExplicitCastExpr *E) {
Chris Lattner4c6f9522009-04-27 05:14:47 +0000608 VisitCastExpr(E);
Sebastian Redlc3632732010-10-05 15:59:54 +0000609 E->setTypeInfoAsWritten(GetTypeSourceInfo(Record, Idx));
Chris Lattner4c6f9522009-04-27 05:14:47 +0000610}
611
Sebastian Redl60adf4a2010-08-18 23:56:52 +0000612void ASTStmtReader::VisitCStyleCastExpr(CStyleCastExpr *E) {
Chris Lattner4c6f9522009-04-27 05:14:47 +0000613 VisitExplicitCastExpr(E);
Sebastian Redlc3632732010-10-05 15:59:54 +0000614 E->setLParenLoc(ReadSourceLocation(Record, Idx));
615 E->setRParenLoc(ReadSourceLocation(Record, Idx));
Chris Lattner4c6f9522009-04-27 05:14:47 +0000616}
617
Sebastian Redl60adf4a2010-08-18 23:56:52 +0000618void ASTStmtReader::VisitCompoundLiteralExpr(CompoundLiteralExpr *E) {
Chris Lattner4c6f9522009-04-27 05:14:47 +0000619 VisitExpr(E);
Sebastian Redlc3632732010-10-05 15:59:54 +0000620 E->setLParenLoc(ReadSourceLocation(Record, Idx));
621 E->setTypeSourceInfo(GetTypeSourceInfo(Record, Idx));
Argyrios Kyrtzidisd98a2ab2010-06-29 22:46:25 +0000622 E->setInitializer(Reader.ReadSubExpr());
Chris Lattner4c6f9522009-04-27 05:14:47 +0000623 E->setFileScope(Record[Idx++]);
Chris Lattner4c6f9522009-04-27 05:14:47 +0000624}
625
Sebastian Redl60adf4a2010-08-18 23:56:52 +0000626void ASTStmtReader::VisitExtVectorElementExpr(ExtVectorElementExpr *E) {
Chris Lattner4c6f9522009-04-27 05:14:47 +0000627 VisitExpr(E);
Argyrios Kyrtzidisd98a2ab2010-06-29 22:46:25 +0000628 E->setBase(Reader.ReadSubExpr());
Douglas Gregor95eab172011-07-28 20:55:49 +0000629 E->setAccessor(Reader.GetIdentifierInfo(F, Record, Idx));
Sebastian Redlc3632732010-10-05 15:59:54 +0000630 E->setAccessorLoc(ReadSourceLocation(Record, Idx));
Chris Lattner4c6f9522009-04-27 05:14:47 +0000631}
632
Sebastian Redl60adf4a2010-08-18 23:56:52 +0000633void ASTStmtReader::VisitInitListExpr(InitListExpr *E) {
Chris Lattner4c6f9522009-04-27 05:14:47 +0000634 VisitExpr(E);
Abramo Bagnara23700f02012-11-08 18:41:43 +0000635 if (InitListExpr *SyntForm = cast_or_null<InitListExpr>(Reader.ReadSubStmt()))
636 E->setSyntacticForm(SyntForm);
Sebastian Redlc3632732010-10-05 15:59:54 +0000637 E->setLBraceLoc(ReadSourceLocation(Record, Idx));
638 E->setRBraceLoc(ReadSourceLocation(Record, Idx));
Argyrios Kyrtzidis2ac0b7a2011-04-22 05:29:30 +0000639 bool isArrayFiller = Record[Idx++];
640 Expr *filler = 0;
641 if (isArrayFiller) {
642 filler = Reader.ReadSubExpr();
643 E->ArrayFillerOrUnionFieldInit = filler;
644 } else
Douglas Gregor409448c2011-07-21 22:35:25 +0000645 E->ArrayFillerOrUnionFieldInit = ReadDeclAs<FieldDecl>(Record, Idx);
Chris Lattner4c6f9522009-04-27 05:14:47 +0000646 E->sawArrayRangeDesignator(Record[Idx++]);
Benjamin Kramer1b1a5072012-02-27 13:20:39 +0000647 E->setInitializesStdInitializerList(Record[Idx++]);
Argyrios Kyrtzidis2ac0b7a2011-04-22 05:29:30 +0000648 unsigned NumInits = Record[Idx++];
Douglas Gregor35942772011-09-09 21:34:22 +0000649 E->reserveInits(Reader.getContext(), NumInits);
Argyrios Kyrtzidis2ac0b7a2011-04-22 05:29:30 +0000650 if (isArrayFiller) {
651 for (unsigned I = 0; I != NumInits; ++I) {
652 Expr *init = Reader.ReadSubExpr();
Douglas Gregor35942772011-09-09 21:34:22 +0000653 E->updateInit(Reader.getContext(), I, init ? init : filler);
Argyrios Kyrtzidis2ac0b7a2011-04-22 05:29:30 +0000654 }
655 } else {
656 for (unsigned I = 0; I != NumInits; ++I)
Douglas Gregor35942772011-09-09 21:34:22 +0000657 E->updateInit(Reader.getContext(), I, Reader.ReadSubExpr());
Argyrios Kyrtzidis2ac0b7a2011-04-22 05:29:30 +0000658 }
Chris Lattner4c6f9522009-04-27 05:14:47 +0000659}
660
Sebastian Redl60adf4a2010-08-18 23:56:52 +0000661void ASTStmtReader::VisitDesignatedInitExpr(DesignatedInitExpr *E) {
Chris Lattner4c6f9522009-04-27 05:14:47 +0000662 typedef DesignatedInitExpr::Designator Designator;
663
664 VisitExpr(E);
665 unsigned NumSubExprs = Record[Idx++];
666 assert(NumSubExprs == E->getNumSubExprs() && "Wrong number of subexprs");
667 for (unsigned I = 0; I != NumSubExprs; ++I)
Argyrios Kyrtzidisd98a2ab2010-06-29 22:46:25 +0000668 E->setSubExpr(I, Reader.ReadSubExpr());
Sebastian Redlc3632732010-10-05 15:59:54 +0000669 E->setEqualOrColonLoc(ReadSourceLocation(Record, Idx));
Chris Lattner4c6f9522009-04-27 05:14:47 +0000670 E->setGNUSyntax(Record[Idx++]);
671
Chris Lattner5f9e2722011-07-23 10:55:15 +0000672 SmallVector<Designator, 4> Designators;
Chris Lattner4c6f9522009-04-27 05:14:47 +0000673 while (Idx < Record.size()) {
Sebastian Redl8538e8d2010-08-18 23:57:32 +0000674 switch ((DesignatorTypes)Record[Idx++]) {
675 case DESIG_FIELD_DECL: {
Douglas Gregor409448c2011-07-21 22:35:25 +0000676 FieldDecl *Field = ReadDeclAs<FieldDecl>(Record, Idx);
Mike Stump1eb44332009-09-09 15:08:12 +0000677 SourceLocation DotLoc
Sebastian Redlc3632732010-10-05 15:59:54 +0000678 = ReadSourceLocation(Record, Idx);
Mike Stump1eb44332009-09-09 15:08:12 +0000679 SourceLocation FieldLoc
Sebastian Redlc3632732010-10-05 15:59:54 +0000680 = ReadSourceLocation(Record, Idx);
Mike Stump1eb44332009-09-09 15:08:12 +0000681 Designators.push_back(Designator(Field->getIdentifier(), DotLoc,
Chris Lattner4c6f9522009-04-27 05:14:47 +0000682 FieldLoc));
683 Designators.back().setField(Field);
684 break;
685 }
686
Sebastian Redl8538e8d2010-08-18 23:57:32 +0000687 case DESIG_FIELD_NAME: {
Douglas Gregor95eab172011-07-28 20:55:49 +0000688 const IdentifierInfo *Name = Reader.GetIdentifierInfo(F, Record, Idx);
Mike Stump1eb44332009-09-09 15:08:12 +0000689 SourceLocation DotLoc
Sebastian Redlc3632732010-10-05 15:59:54 +0000690 = ReadSourceLocation(Record, Idx);
Mike Stump1eb44332009-09-09 15:08:12 +0000691 SourceLocation FieldLoc
Sebastian Redlc3632732010-10-05 15:59:54 +0000692 = ReadSourceLocation(Record, Idx);
Chris Lattner4c6f9522009-04-27 05:14:47 +0000693 Designators.push_back(Designator(Name, DotLoc, FieldLoc));
694 break;
695 }
Mike Stump1eb44332009-09-09 15:08:12 +0000696
Sebastian Redl8538e8d2010-08-18 23:57:32 +0000697 case DESIG_ARRAY: {
Chris Lattner4c6f9522009-04-27 05:14:47 +0000698 unsigned Index = Record[Idx++];
699 SourceLocation LBracketLoc
Sebastian Redlc3632732010-10-05 15:59:54 +0000700 = ReadSourceLocation(Record, Idx);
Chris Lattner4c6f9522009-04-27 05:14:47 +0000701 SourceLocation RBracketLoc
Sebastian Redlc3632732010-10-05 15:59:54 +0000702 = ReadSourceLocation(Record, Idx);
Chris Lattner4c6f9522009-04-27 05:14:47 +0000703 Designators.push_back(Designator(Index, LBracketLoc, RBracketLoc));
704 break;
705 }
706
Sebastian Redl8538e8d2010-08-18 23:57:32 +0000707 case DESIG_ARRAY_RANGE: {
Chris Lattner4c6f9522009-04-27 05:14:47 +0000708 unsigned Index = Record[Idx++];
709 SourceLocation LBracketLoc
Sebastian Redlc3632732010-10-05 15:59:54 +0000710 = ReadSourceLocation(Record, Idx);
Chris Lattner4c6f9522009-04-27 05:14:47 +0000711 SourceLocation EllipsisLoc
Sebastian Redlc3632732010-10-05 15:59:54 +0000712 = ReadSourceLocation(Record, Idx);
Chris Lattner4c6f9522009-04-27 05:14:47 +0000713 SourceLocation RBracketLoc
Sebastian Redlc3632732010-10-05 15:59:54 +0000714 = ReadSourceLocation(Record, Idx);
Chris Lattner4c6f9522009-04-27 05:14:47 +0000715 Designators.push_back(Designator(Index, LBracketLoc, EllipsisLoc,
716 RBracketLoc));
717 break;
718 }
719 }
720 }
Douglas Gregor35942772011-09-09 21:34:22 +0000721 E->setDesignators(Reader.getContext(),
Douglas Gregor319d57f2010-01-06 23:17:19 +0000722 Designators.data(), Designators.size());
Chris Lattner4c6f9522009-04-27 05:14:47 +0000723}
724
Sebastian Redl60adf4a2010-08-18 23:56:52 +0000725void ASTStmtReader::VisitImplicitValueInitExpr(ImplicitValueInitExpr *E) {
Chris Lattner4c6f9522009-04-27 05:14:47 +0000726 VisitExpr(E);
Chris Lattner4c6f9522009-04-27 05:14:47 +0000727}
728
Sebastian Redl60adf4a2010-08-18 23:56:52 +0000729void ASTStmtReader::VisitVAArgExpr(VAArgExpr *E) {
Chris Lattner4c6f9522009-04-27 05:14:47 +0000730 VisitExpr(E);
Argyrios Kyrtzidisd98a2ab2010-06-29 22:46:25 +0000731 E->setSubExpr(Reader.ReadSubExpr());
Sebastian Redlc3632732010-10-05 15:59:54 +0000732 E->setWrittenTypeInfo(GetTypeSourceInfo(Record, Idx));
733 E->setBuiltinLoc(ReadSourceLocation(Record, Idx));
734 E->setRParenLoc(ReadSourceLocation(Record, Idx));
Chris Lattner4c6f9522009-04-27 05:14:47 +0000735}
736
Sebastian Redl60adf4a2010-08-18 23:56:52 +0000737void ASTStmtReader::VisitAddrLabelExpr(AddrLabelExpr *E) {
Chris Lattner4c6f9522009-04-27 05:14:47 +0000738 VisitExpr(E);
Sebastian Redlc3632732010-10-05 15:59:54 +0000739 E->setAmpAmpLoc(ReadSourceLocation(Record, Idx));
740 E->setLabelLoc(ReadSourceLocation(Record, Idx));
Douglas Gregor409448c2011-07-21 22:35:25 +0000741 E->setLabel(ReadDeclAs<LabelDecl>(Record, Idx));
Chris Lattner4c6f9522009-04-27 05:14:47 +0000742}
743
Sebastian Redl60adf4a2010-08-18 23:56:52 +0000744void ASTStmtReader::VisitStmtExpr(StmtExpr *E) {
Chris Lattner4c6f9522009-04-27 05:14:47 +0000745 VisitExpr(E);
Sebastian Redlc3632732010-10-05 15:59:54 +0000746 E->setLParenLoc(ReadSourceLocation(Record, Idx));
747 E->setRParenLoc(ReadSourceLocation(Record, Idx));
Argyrios Kyrtzidisd98a2ab2010-06-29 22:46:25 +0000748 E->setSubStmt(cast_or_null<CompoundStmt>(Reader.ReadSubStmt()));
Chris Lattner4c6f9522009-04-27 05:14:47 +0000749}
750
Sebastian Redl60adf4a2010-08-18 23:56:52 +0000751void ASTStmtReader::VisitChooseExpr(ChooseExpr *E) {
Chris Lattner4c6f9522009-04-27 05:14:47 +0000752 VisitExpr(E);
Argyrios Kyrtzidisd98a2ab2010-06-29 22:46:25 +0000753 E->setCond(Reader.ReadSubExpr());
754 E->setLHS(Reader.ReadSubExpr());
755 E->setRHS(Reader.ReadSubExpr());
Sebastian Redlc3632732010-10-05 15:59:54 +0000756 E->setBuiltinLoc(ReadSourceLocation(Record, Idx));
757 E->setRParenLoc(ReadSourceLocation(Record, Idx));
Chris Lattner4c6f9522009-04-27 05:14:47 +0000758}
759
Sebastian Redl60adf4a2010-08-18 23:56:52 +0000760void ASTStmtReader::VisitGNUNullExpr(GNUNullExpr *E) {
Chris Lattner4c6f9522009-04-27 05:14:47 +0000761 VisitExpr(E);
Sebastian Redlc3632732010-10-05 15:59:54 +0000762 E->setTokenLocation(ReadSourceLocation(Record, Idx));
Chris Lattner4c6f9522009-04-27 05:14:47 +0000763}
764
Sebastian Redl60adf4a2010-08-18 23:56:52 +0000765void ASTStmtReader::VisitShuffleVectorExpr(ShuffleVectorExpr *E) {
Chris Lattner4c6f9522009-04-27 05:14:47 +0000766 VisitExpr(E);
Chris Lattner5f9e2722011-07-23 10:55:15 +0000767 SmallVector<Expr *, 16> Exprs;
Chris Lattner4c6f9522009-04-27 05:14:47 +0000768 unsigned NumExprs = Record[Idx++];
Argyrios Kyrtzidis919e6932010-06-28 22:28:35 +0000769 while (NumExprs--)
Argyrios Kyrtzidisd98a2ab2010-06-29 22:46:25 +0000770 Exprs.push_back(Reader.ReadSubExpr());
Douglas Gregor35942772011-09-09 21:34:22 +0000771 E->setExprs(Reader.getContext(), Exprs.data(), Exprs.size());
Sebastian Redlc3632732010-10-05 15:59:54 +0000772 E->setBuiltinLoc(ReadSourceLocation(Record, Idx));
773 E->setRParenLoc(ReadSourceLocation(Record, Idx));
Chris Lattner4c6f9522009-04-27 05:14:47 +0000774}
775
Sebastian Redl60adf4a2010-08-18 23:56:52 +0000776void ASTStmtReader::VisitBlockExpr(BlockExpr *E) {
Chris Lattner4c6f9522009-04-27 05:14:47 +0000777 VisitExpr(E);
Douglas Gregor409448c2011-07-21 22:35:25 +0000778 E->setBlockDecl(ReadDeclAs<BlockDecl>(Record, Idx));
Chris Lattner4c6f9522009-04-27 05:14:47 +0000779}
780
Peter Collingbournef111d932011-04-15 00:35:48 +0000781void ASTStmtReader::VisitGenericSelectionExpr(GenericSelectionExpr *E) {
782 VisitExpr(E);
783 E->NumAssocs = Record[Idx++];
Douglas Gregor35942772011-09-09 21:34:22 +0000784 E->AssocTypes = new (Reader.getContext()) TypeSourceInfo*[E->NumAssocs];
Peter Collingbournef111d932011-04-15 00:35:48 +0000785 E->SubExprs =
Douglas Gregor35942772011-09-09 21:34:22 +0000786 new(Reader.getContext()) Stmt*[GenericSelectionExpr::END_EXPR+E->NumAssocs];
Peter Collingbournef111d932011-04-15 00:35:48 +0000787
788 E->SubExprs[GenericSelectionExpr::CONTROLLING] = Reader.ReadSubExpr();
789 for (unsigned I = 0, N = E->getNumAssocs(); I != N; ++I) {
790 E->AssocTypes[I] = GetTypeSourceInfo(Record, Idx);
791 E->SubExprs[GenericSelectionExpr::END_EXPR+I] = Reader.ReadSubExpr();
792 }
793 E->ResultIndex = Record[Idx++];
794
795 E->GenericLoc = ReadSourceLocation(Record, Idx);
796 E->DefaultLoc = ReadSourceLocation(Record, Idx);
797 E->RParenLoc = ReadSourceLocation(Record, Idx);
798}
799
John McCall4b9c2d22011-11-06 09:01:30 +0000800void ASTStmtReader::VisitPseudoObjectExpr(PseudoObjectExpr *E) {
801 VisitExpr(E);
802 unsigned numSemanticExprs = Record[Idx++];
803 assert(numSemanticExprs + 1 == E->PseudoObjectExprBits.NumSubExprs);
804 E->PseudoObjectExprBits.ResultIndex = Record[Idx++];
805
806 // Read the syntactic expression.
807 E->getSubExprsBuffer()[0] = Reader.ReadSubExpr();
808
809 // Read all the semantic expressions.
810 for (unsigned i = 0; i != numSemanticExprs; ++i) {
811 Expr *subExpr = Reader.ReadSubExpr();
John McCall4b9c2d22011-11-06 09:01:30 +0000812 E->getSubExprsBuffer()[i+1] = subExpr;
813 }
814}
815
Eli Friedman276b0612011-10-11 02:20:01 +0000816void ASTStmtReader::VisitAtomicExpr(AtomicExpr *E) {
817 VisitExpr(E);
Richard Smithe1b2abc2012-04-10 22:49:28 +0000818 E->Op = AtomicExpr::AtomicOp(Record[Idx++]);
819 E->NumSubExprs = AtomicExpr::getNumSubExprs(E->Op);
820 for (unsigned I = 0; I != E->NumSubExprs; ++I)
821 E->SubExprs[I] = Reader.ReadSubExpr();
822 E->BuiltinLoc = ReadSourceLocation(Record, Idx);
823 E->RParenLoc = ReadSourceLocation(Record, Idx);
Eli Friedman276b0612011-10-11 02:20:01 +0000824}
825
Chris Lattner4c6f9522009-04-27 05:14:47 +0000826//===----------------------------------------------------------------------===//
827// Objective-C Expressions and Statements
828
Sebastian Redl60adf4a2010-08-18 23:56:52 +0000829void ASTStmtReader::VisitObjCStringLiteral(ObjCStringLiteral *E) {
Chris Lattner4c6f9522009-04-27 05:14:47 +0000830 VisitExpr(E);
Argyrios Kyrtzidisd98a2ab2010-06-29 22:46:25 +0000831 E->setString(cast<StringLiteral>(Reader.ReadSubStmt()));
Sebastian Redlc3632732010-10-05 15:59:54 +0000832 E->setAtLoc(ReadSourceLocation(Record, Idx));
Chris Lattner4c6f9522009-04-27 05:14:47 +0000833}
834
Patrick Beardeb382ec2012-04-19 00:25:12 +0000835void ASTStmtReader::VisitObjCBoxedExpr(ObjCBoxedExpr *E) {
Ted Kremenekebcb57a2012-03-06 20:05:56 +0000836 VisitExpr(E);
837 // could be one of several IntegerLiteral, FloatLiteral, etc.
Patrick Beardeb382ec2012-04-19 00:25:12 +0000838 E->SubExpr = Reader.ReadSubStmt();
839 E->BoxingMethod = ReadDeclAs<ObjCMethodDecl>(Record, Idx);
840 E->Range = ReadSourceRange(Record, Idx);
Ted Kremenekebcb57a2012-03-06 20:05:56 +0000841}
842
843void ASTStmtReader::VisitObjCArrayLiteral(ObjCArrayLiteral *E) {
844 VisitExpr(E);
845 unsigned NumElements = Record[Idx++];
846 assert(NumElements == E->getNumElements() && "Wrong number of elements");
847 Expr **Elements = E->getElements();
848 for (unsigned I = 0, N = NumElements; I != N; ++I)
849 Elements[I] = Reader.ReadSubExpr();
850 E->ArrayWithObjectsMethod = ReadDeclAs<ObjCMethodDecl>(Record, Idx);
851 E->Range = ReadSourceRange(Record, Idx);
852}
853
854void ASTStmtReader::VisitObjCDictionaryLiteral(ObjCDictionaryLiteral *E) {
855 VisitExpr(E);
856 unsigned NumElements = Record[Idx++];
857 assert(NumElements == E->getNumElements() && "Wrong number of elements");
858 bool HasPackExpansions = Record[Idx++];
859 assert(HasPackExpansions == E->HasPackExpansions &&"Pack expansion mismatch");
860 ObjCDictionaryLiteral::KeyValuePair *KeyValues = E->getKeyValues();
861 ObjCDictionaryLiteral::ExpansionData *Expansions = E->getExpansionData();
862 for (unsigned I = 0; I != NumElements; ++I) {
863 KeyValues[I].Key = Reader.ReadSubExpr();
864 KeyValues[I].Value = Reader.ReadSubExpr();
865 if (HasPackExpansions) {
866 Expansions[I].EllipsisLoc = ReadSourceLocation(Record, Idx);
867 Expansions[I].NumExpansionsPlusOne = Record[Idx++];
868 }
869 }
870 E->DictWithObjectsMethod = ReadDeclAs<ObjCMethodDecl>(Record, Idx);
871 E->Range = ReadSourceRange(Record, Idx);
872}
873
Sebastian Redl60adf4a2010-08-18 23:56:52 +0000874void ASTStmtReader::VisitObjCEncodeExpr(ObjCEncodeExpr *E) {
Chris Lattner4c6f9522009-04-27 05:14:47 +0000875 VisitExpr(E);
Sebastian Redlc3632732010-10-05 15:59:54 +0000876 E->setEncodedTypeSourceInfo(GetTypeSourceInfo(Record, Idx));
877 E->setAtLoc(ReadSourceLocation(Record, Idx));
878 E->setRParenLoc(ReadSourceLocation(Record, Idx));
Chris Lattner4c6f9522009-04-27 05:14:47 +0000879}
880
Sebastian Redl60adf4a2010-08-18 23:56:52 +0000881void ASTStmtReader::VisitObjCSelectorExpr(ObjCSelectorExpr *E) {
Chris Lattner4c6f9522009-04-27 05:14:47 +0000882 VisitExpr(E);
Douglas Gregor2d2689a2011-07-28 21:16:51 +0000883 E->setSelector(Reader.ReadSelector(F, Record, Idx));
Sebastian Redlc3632732010-10-05 15:59:54 +0000884 E->setAtLoc(ReadSourceLocation(Record, Idx));
885 E->setRParenLoc(ReadSourceLocation(Record, Idx));
Chris Lattner4c6f9522009-04-27 05:14:47 +0000886}
887
Sebastian Redl60adf4a2010-08-18 23:56:52 +0000888void ASTStmtReader::VisitObjCProtocolExpr(ObjCProtocolExpr *E) {
Chris Lattner4c6f9522009-04-27 05:14:47 +0000889 VisitExpr(E);
Douglas Gregor409448c2011-07-21 22:35:25 +0000890 E->setProtocol(ReadDeclAs<ObjCProtocolDecl>(Record, Idx));
Sebastian Redlc3632732010-10-05 15:59:54 +0000891 E->setAtLoc(ReadSourceLocation(Record, Idx));
Argyrios Kyrtzidis7d24e282012-05-16 00:50:02 +0000892 E->ProtoLoc = ReadSourceLocation(Record, Idx);
Sebastian Redlc3632732010-10-05 15:59:54 +0000893 E->setRParenLoc(ReadSourceLocation(Record, Idx));
Chris Lattner4c6f9522009-04-27 05:14:47 +0000894}
895
Sebastian Redl60adf4a2010-08-18 23:56:52 +0000896void ASTStmtReader::VisitObjCIvarRefExpr(ObjCIvarRefExpr *E) {
Chris Lattner4c6f9522009-04-27 05:14:47 +0000897 VisitExpr(E);
Douglas Gregor409448c2011-07-21 22:35:25 +0000898 E->setDecl(ReadDeclAs<ObjCIvarDecl>(Record, Idx));
Sebastian Redlc3632732010-10-05 15:59:54 +0000899 E->setLocation(ReadSourceLocation(Record, Idx));
Fariborz Jahanian0c701812013-04-02 18:57:54 +0000900 E->setOpLoc(ReadSourceLocation(Record, Idx));
Argyrios Kyrtzidisd98a2ab2010-06-29 22:46:25 +0000901 E->setBase(Reader.ReadSubExpr());
Chris Lattner4c6f9522009-04-27 05:14:47 +0000902 E->setIsArrow(Record[Idx++]);
903 E->setIsFreeIvar(Record[Idx++]);
Chris Lattner4c6f9522009-04-27 05:14:47 +0000904}
905
Sebastian Redl60adf4a2010-08-18 23:56:52 +0000906void ASTStmtReader::VisitObjCPropertyRefExpr(ObjCPropertyRefExpr *E) {
Chris Lattner4c6f9522009-04-27 05:14:47 +0000907 VisitExpr(E);
Argyrios Kyrtzidisb085d892012-03-30 00:19:18 +0000908 unsigned MethodRefFlags = Record[Idx++];
John McCall12f78a62010-12-02 01:19:52 +0000909 bool Implicit = Record[Idx++] != 0;
910 if (Implicit) {
Douglas Gregor409448c2011-07-21 22:35:25 +0000911 ObjCMethodDecl *Getter = ReadDeclAs<ObjCMethodDecl>(Record, Idx);
912 ObjCMethodDecl *Setter = ReadDeclAs<ObjCMethodDecl>(Record, Idx);
Argyrios Kyrtzidisb085d892012-03-30 00:19:18 +0000913 E->setImplicitProperty(Getter, Setter, MethodRefFlags);
John McCall12f78a62010-12-02 01:19:52 +0000914 } else {
Argyrios Kyrtzidisb085d892012-03-30 00:19:18 +0000915 E->setExplicitProperty(ReadDeclAs<ObjCPropertyDecl>(Record, Idx),
916 MethodRefFlags);
Fariborz Jahanian8ac2d442010-10-14 16:04:05 +0000917 }
Sebastian Redlc3632732010-10-05 15:59:54 +0000918 E->setLocation(ReadSourceLocation(Record, Idx));
John McCall12f78a62010-12-02 01:19:52 +0000919 E->setReceiverLocation(ReadSourceLocation(Record, Idx));
920 switch (Record[Idx++]) {
921 case 0:
922 E->setBase(Reader.ReadSubExpr());
923 break;
924 case 1:
Douglas Gregor393f2492011-07-22 00:38:23 +0000925 E->setSuperReceiver(Reader.readType(F, Record, Idx));
John McCall12f78a62010-12-02 01:19:52 +0000926 break;
927 case 2:
Douglas Gregor409448c2011-07-21 22:35:25 +0000928 E->setClassReceiver(ReadDeclAs<ObjCInterfaceDecl>(Record, Idx));
John McCall12f78a62010-12-02 01:19:52 +0000929 break;
930 }
Chris Lattner4c6f9522009-04-27 05:14:47 +0000931}
932
Ted Kremenekebcb57a2012-03-06 20:05:56 +0000933void ASTStmtReader::VisitObjCSubscriptRefExpr(ObjCSubscriptRefExpr *E) {
934 VisitExpr(E);
935 E->setRBracket(ReadSourceLocation(Record, Idx));
936 E->setBaseExpr(Reader.ReadSubExpr());
937 E->setKeyExpr(Reader.ReadSubExpr());
938 E->GetAtIndexMethodDecl = ReadDeclAs<ObjCMethodDecl>(Record, Idx);
939 E->SetAtIndexMethodDecl = ReadDeclAs<ObjCMethodDecl>(Record, Idx);
940}
941
Sebastian Redl60adf4a2010-08-18 23:56:52 +0000942void ASTStmtReader::VisitObjCMessageExpr(ObjCMessageExpr *E) {
Chris Lattner4c6f9522009-04-27 05:14:47 +0000943 VisitExpr(E);
Douglas Gregor04badcf2010-04-21 00:45:42 +0000944 assert(Record[Idx] == E->getNumArgs());
945 ++Idx;
Argyrios Kyrtzidis20718082011-10-03 06:36:51 +0000946 unsigned NumStoredSelLocs = Record[Idx++];
947 E->SelLocsKind = Record[Idx++];
John McCallf85e1932011-06-15 23:02:42 +0000948 E->setDelegateInitCall(Record[Idx++]);
Argyrios Kyrtzidis746f5bc2012-01-12 02:34:39 +0000949 E->IsImplicit = Record[Idx++];
Douglas Gregor04badcf2010-04-21 00:45:42 +0000950 ObjCMessageExpr::ReceiverKind Kind
951 = static_cast<ObjCMessageExpr::ReceiverKind>(Record[Idx++]);
952 switch (Kind) {
953 case ObjCMessageExpr::Instance:
Argyrios Kyrtzidisd98a2ab2010-06-29 22:46:25 +0000954 E->setInstanceReceiver(Reader.ReadSubExpr());
Douglas Gregor04badcf2010-04-21 00:45:42 +0000955 break;
956
957 case ObjCMessageExpr::Class:
Sebastian Redlc3632732010-10-05 15:59:54 +0000958 E->setClassReceiver(GetTypeSourceInfo(Record, Idx));
Douglas Gregor04badcf2010-04-21 00:45:42 +0000959 break;
960
961 case ObjCMessageExpr::SuperClass:
962 case ObjCMessageExpr::SuperInstance: {
Douglas Gregor393f2492011-07-22 00:38:23 +0000963 QualType T = Reader.readType(F, Record, Idx);
Sebastian Redlc3632732010-10-05 15:59:54 +0000964 SourceLocation SuperLoc = ReadSourceLocation(Record, Idx);
Douglas Gregor04badcf2010-04-21 00:45:42 +0000965 E->setSuper(SuperLoc, T, Kind == ObjCMessageExpr::SuperInstance);
966 break;
967 }
968 }
969
970 assert(Kind == E->getReceiverKind());
971
972 if (Record[Idx++])
Douglas Gregor409448c2011-07-21 22:35:25 +0000973 E->setMethodDecl(ReadDeclAs<ObjCMethodDecl>(Record, Idx));
Douglas Gregor04badcf2010-04-21 00:45:42 +0000974 else
Douglas Gregor2d2689a2011-07-28 21:16:51 +0000975 E->setSelector(Reader.ReadSelector(F, Record, Idx));
Douglas Gregor04badcf2010-04-21 00:45:42 +0000976
Argyrios Kyrtzidisf40f0d52010-12-10 20:08:27 +0000977 E->LBracLoc = ReadSourceLocation(Record, Idx);
978 E->RBracLoc = ReadSourceLocation(Record, Idx);
Chris Lattner4c6f9522009-04-27 05:14:47 +0000979
980 for (unsigned I = 0, N = E->getNumArgs(); I != N; ++I)
Argyrios Kyrtzidisd98a2ab2010-06-29 22:46:25 +0000981 E->setArg(I, Reader.ReadSubExpr());
Argyrios Kyrtzidis20718082011-10-03 06:36:51 +0000982
983 SourceLocation *Locs = E->getStoredSelLocs();
984 for (unsigned I = 0; I != NumStoredSelLocs; ++I)
985 Locs[I] = ReadSourceLocation(Record, Idx);
Chris Lattner4c6f9522009-04-27 05:14:47 +0000986}
987
Sebastian Redl60adf4a2010-08-18 23:56:52 +0000988void ASTStmtReader::VisitObjCForCollectionStmt(ObjCForCollectionStmt *S) {
Chris Lattner4c6f9522009-04-27 05:14:47 +0000989 VisitStmt(S);
Argyrios Kyrtzidisd98a2ab2010-06-29 22:46:25 +0000990 S->setElement(Reader.ReadSubStmt());
991 S->setCollection(Reader.ReadSubExpr());
992 S->setBody(Reader.ReadSubStmt());
Sebastian Redlc3632732010-10-05 15:59:54 +0000993 S->setForLoc(ReadSourceLocation(Record, Idx));
994 S->setRParenLoc(ReadSourceLocation(Record, Idx));
Chris Lattner4c6f9522009-04-27 05:14:47 +0000995}
996
Sebastian Redl60adf4a2010-08-18 23:56:52 +0000997void ASTStmtReader::VisitObjCAtCatchStmt(ObjCAtCatchStmt *S) {
Chris Lattner4c6f9522009-04-27 05:14:47 +0000998 VisitStmt(S);
Argyrios Kyrtzidisd98a2ab2010-06-29 22:46:25 +0000999 S->setCatchBody(Reader.ReadSubStmt());
Douglas Gregor409448c2011-07-21 22:35:25 +00001000 S->setCatchParamDecl(ReadDeclAs<VarDecl>(Record, Idx));
Sebastian Redlc3632732010-10-05 15:59:54 +00001001 S->setAtCatchLoc(ReadSourceLocation(Record, Idx));
1002 S->setRParenLoc(ReadSourceLocation(Record, Idx));
Chris Lattner4c6f9522009-04-27 05:14:47 +00001003}
1004
Sebastian Redl60adf4a2010-08-18 23:56:52 +00001005void ASTStmtReader::VisitObjCAtFinallyStmt(ObjCAtFinallyStmt *S) {
Chris Lattner4c6f9522009-04-27 05:14:47 +00001006 VisitStmt(S);
Argyrios Kyrtzidisd98a2ab2010-06-29 22:46:25 +00001007 S->setFinallyBody(Reader.ReadSubStmt());
Sebastian Redlc3632732010-10-05 15:59:54 +00001008 S->setAtFinallyLoc(ReadSourceLocation(Record, Idx));
Chris Lattner4c6f9522009-04-27 05:14:47 +00001009}
1010
John McCallf85e1932011-06-15 23:02:42 +00001011void ASTStmtReader::VisitObjCAutoreleasePoolStmt(ObjCAutoreleasePoolStmt *S) {
1012 VisitStmt(S);
1013 S->setSubStmt(Reader.ReadSubStmt());
1014 S->setAtLoc(ReadSourceLocation(Record, Idx));
1015}
1016
Sebastian Redl60adf4a2010-08-18 23:56:52 +00001017void ASTStmtReader::VisitObjCAtTryStmt(ObjCAtTryStmt *S) {
Chris Lattner4c6f9522009-04-27 05:14:47 +00001018 VisitStmt(S);
Douglas Gregor8f5e3dd2010-04-23 22:50:49 +00001019 assert(Record[Idx] == S->getNumCatchStmts());
1020 ++Idx;
1021 bool HasFinally = Record[Idx++];
Argyrios Kyrtzidisd98a2ab2010-06-29 22:46:25 +00001022 S->setTryBody(Reader.ReadSubStmt());
Argyrios Kyrtzidis919e6932010-06-28 22:28:35 +00001023 for (unsigned I = 0, N = S->getNumCatchStmts(); I != N; ++I)
Argyrios Kyrtzidisd98a2ab2010-06-29 22:46:25 +00001024 S->setCatchStmt(I, cast_or_null<ObjCAtCatchStmt>(Reader.ReadSubStmt()));
Douglas Gregor8f5e3dd2010-04-23 22:50:49 +00001025
Douglas Gregor8f5e3dd2010-04-23 22:50:49 +00001026 if (HasFinally)
Argyrios Kyrtzidisd98a2ab2010-06-29 22:46:25 +00001027 S->setFinallyStmt(Reader.ReadSubStmt());
Sebastian Redlc3632732010-10-05 15:59:54 +00001028 S->setAtTryLoc(ReadSourceLocation(Record, Idx));
Chris Lattner4c6f9522009-04-27 05:14:47 +00001029}
1030
Sebastian Redl60adf4a2010-08-18 23:56:52 +00001031void ASTStmtReader::VisitObjCAtSynchronizedStmt(ObjCAtSynchronizedStmt *S) {
Chris Lattner4c6f9522009-04-27 05:14:47 +00001032 VisitStmt(S);
Argyrios Kyrtzidisd98a2ab2010-06-29 22:46:25 +00001033 S->setSynchExpr(Reader.ReadSubStmt());
1034 S->setSynchBody(Reader.ReadSubStmt());
Sebastian Redlc3632732010-10-05 15:59:54 +00001035 S->setAtSynchronizedLoc(ReadSourceLocation(Record, Idx));
Chris Lattner4c6f9522009-04-27 05:14:47 +00001036}
1037
Sebastian Redl60adf4a2010-08-18 23:56:52 +00001038void ASTStmtReader::VisitObjCAtThrowStmt(ObjCAtThrowStmt *S) {
Chris Lattner4c6f9522009-04-27 05:14:47 +00001039 VisitStmt(S);
Argyrios Kyrtzidisd98a2ab2010-06-29 22:46:25 +00001040 S->setThrowExpr(Reader.ReadSubStmt());
Sebastian Redlc3632732010-10-05 15:59:54 +00001041 S->setThrowLoc(ReadSourceLocation(Record, Idx));
Chris Lattner4c6f9522009-04-27 05:14:47 +00001042}
1043
Ted Kremenekebcb57a2012-03-06 20:05:56 +00001044void ASTStmtReader::VisitObjCBoolLiteralExpr(ObjCBoolLiteralExpr *E) {
1045 VisitExpr(E);
1046 E->setValue(Record[Idx++]);
1047 E->setLocation(ReadSourceLocation(Record, Idx));
1048}
1049
Argyrios Kyrtzidisba0a9002009-07-14 03:19:21 +00001050//===----------------------------------------------------------------------===//
1051// C++ Expressions and Statements
Argyrios Kyrtzidis7cb45e32010-07-22 16:03:56 +00001052//===----------------------------------------------------------------------===//
1053
Sebastian Redl60adf4a2010-08-18 23:56:52 +00001054void ASTStmtReader::VisitCXXCatchStmt(CXXCatchStmt *S) {
Argyrios Kyrtzidis7cb45e32010-07-22 16:03:56 +00001055 VisitStmt(S);
Sebastian Redlc3632732010-10-05 15:59:54 +00001056 S->CatchLoc = ReadSourceLocation(Record, Idx);
Douglas Gregor409448c2011-07-21 22:35:25 +00001057 S->ExceptionDecl = ReadDeclAs<VarDecl>(Record, Idx);
Argyrios Kyrtzidis7cb45e32010-07-22 16:03:56 +00001058 S->HandlerBlock = Reader.ReadSubStmt();
1059}
1060
Sebastian Redl60adf4a2010-08-18 23:56:52 +00001061void ASTStmtReader::VisitCXXTryStmt(CXXTryStmt *S) {
Argyrios Kyrtzidis7cb45e32010-07-22 16:03:56 +00001062 VisitStmt(S);
1063 assert(Record[Idx] == S->getNumHandlers() && "NumStmtFields is wrong ?");
1064 ++Idx;
Sebastian Redlc3632732010-10-05 15:59:54 +00001065 S->TryLoc = ReadSourceLocation(Record, Idx);
Argyrios Kyrtzidis7cb45e32010-07-22 16:03:56 +00001066 S->getStmts()[0] = Reader.ReadSubStmt();
1067 for (unsigned i = 0, e = S->getNumHandlers(); i != e; ++i)
1068 S->getStmts()[i + 1] = Reader.ReadSubStmt();
1069}
Argyrios Kyrtzidisba0a9002009-07-14 03:19:21 +00001070
Richard Smithad762fc2011-04-14 22:09:26 +00001071void ASTStmtReader::VisitCXXForRangeStmt(CXXForRangeStmt *S) {
1072 VisitStmt(S);
1073 S->setForLoc(ReadSourceLocation(Record, Idx));
1074 S->setColonLoc(ReadSourceLocation(Record, Idx));
1075 S->setRParenLoc(ReadSourceLocation(Record, Idx));
1076 S->setRangeStmt(Reader.ReadSubStmt());
1077 S->setBeginEndStmt(Reader.ReadSubStmt());
1078 S->setCond(Reader.ReadSubExpr());
1079 S->setInc(Reader.ReadSubExpr());
1080 S->setLoopVarStmt(Reader.ReadSubStmt());
1081 S->setBody(Reader.ReadSubStmt());
1082}
1083
Douglas Gregorba0513d2011-10-25 01:33:02 +00001084void ASTStmtReader::VisitMSDependentExistsStmt(MSDependentExistsStmt *S) {
1085 VisitStmt(S);
1086 S->KeywordLoc = ReadSourceLocation(Record, Idx);
1087 S->IsIfExists = Record[Idx++];
1088 S->QualifierLoc = Reader.ReadNestedNameSpecifierLoc(F, Record, Idx);
1089 ReadDeclarationNameInfo(S->NameInfo, Record, Idx);
1090 S->SubStmt = Reader.ReadSubStmt();
1091}
1092
Sebastian Redl60adf4a2010-08-18 23:56:52 +00001093void ASTStmtReader::VisitCXXOperatorCallExpr(CXXOperatorCallExpr *E) {
Argyrios Kyrtzidis919e6932010-06-28 22:28:35 +00001094 VisitCallExpr(E);
Argyrios Kyrtzidis4548ca22012-04-30 22:12:22 +00001095 E->Operator = (OverloadedOperatorKind)Record[Idx++];
1096 E->Range = Reader.ReadSourceRange(F, Record, Idx);
Lang Hamesbe9af122012-10-02 04:45:10 +00001097 E->setFPContractable((bool)Record[Idx++]);
Argyrios Kyrtzidisba0a9002009-07-14 03:19:21 +00001098}
1099
Sebastian Redl60adf4a2010-08-18 23:56:52 +00001100void ASTStmtReader::VisitCXXConstructExpr(CXXConstructExpr *E) {
Douglas Gregor39da0b82009-09-09 23:08:42 +00001101 VisitExpr(E);
Argyrios Kyrtzidis6d00c132010-07-10 11:46:15 +00001102 E->NumArgs = Record[Idx++];
1103 if (E->NumArgs)
Douglas Gregor35942772011-09-09 21:34:22 +00001104 E->Args = new (Reader.getContext()) Stmt*[E->NumArgs];
Argyrios Kyrtzidis5e1b7c22010-06-24 08:57:09 +00001105 for (unsigned I = 0, N = E->getNumArgs(); I != N; ++I)
Argyrios Kyrtzidisd98a2ab2010-06-29 22:46:25 +00001106 E->setArg(I, Reader.ReadSubExpr());
Douglas Gregor409448c2011-07-21 22:35:25 +00001107 E->setConstructor(ReadDeclAs<CXXConstructorDecl>(Record, Idx));
Sebastian Redlc3632732010-10-05 15:59:54 +00001108 E->setLocation(ReadSourceLocation(Record, Idx));
Abramo Bagnara7cc58b42011-10-05 07:56:41 +00001109 E->setElidable(Record[Idx++]);
1110 E->setHadMultipleCandidates(Record[Idx++]);
Richard Smithc83c2302012-12-19 01:39:02 +00001111 E->setListInitialization(Record[Idx++]);
Douglas Gregor16006c92009-12-16 18:50:27 +00001112 E->setRequiresZeroInitialization(Record[Idx++]);
Douglas Gregor3c9034c2010-05-15 00:13:29 +00001113 E->setConstructionKind((CXXConstructExpr::ConstructionKind)Record[Idx++]);
Chandler Carruth428edaf2010-10-25 08:47:36 +00001114 E->ParenRange = ReadSourceRange(Record, Idx);
Douglas Gregor39da0b82009-09-09 23:08:42 +00001115}
Chris Lattner4c6f9522009-04-27 05:14:47 +00001116
Sebastian Redl60adf4a2010-08-18 23:56:52 +00001117void ASTStmtReader::VisitCXXTemporaryObjectExpr(CXXTemporaryObjectExpr *E) {
Argyrios Kyrtzidis6d00c132010-07-10 11:46:15 +00001118 VisitCXXConstructExpr(E);
Sebastian Redlc3632732010-10-05 15:59:54 +00001119 E->Type = GetTypeSourceInfo(Record, Idx);
Argyrios Kyrtzidis6d00c132010-07-10 11:46:15 +00001120}
1121
Douglas Gregor01d08012012-02-07 10:09:13 +00001122void ASTStmtReader::VisitLambdaExpr(LambdaExpr *E) {
1123 VisitExpr(E);
Douglas Gregor9d36f5d2012-02-14 17:54:36 +00001124 unsigned NumCaptures = Record[Idx++];
1125 assert(NumCaptures == E->NumCaptures);(void)NumCaptures;
1126 unsigned NumArrayIndexVars = Record[Idx++];
1127 E->IntroducerRange = ReadSourceRange(Record, Idx);
1128 E->CaptureDefault = static_cast<LambdaCaptureDefault>(Record[Idx++]);
1129 E->ExplicitParams = Record[Idx++];
1130 E->ExplicitResultType = Record[Idx++];
1131 E->ClosingBrace = ReadSourceLocation(Record, Idx);
1132
1133 // Read capture initializers.
1134 for (LambdaExpr::capture_init_iterator C = E->capture_init_begin(),
1135 CEnd = E->capture_init_end();
1136 C != CEnd; ++C)
1137 *C = Reader.ReadSubExpr();
1138
1139 // Read array capture index variables.
1140 if (NumArrayIndexVars > 0) {
1141 unsigned *ArrayIndexStarts = E->getArrayIndexStarts();
1142 for (unsigned I = 0; I != NumCaptures + 1; ++I)
1143 ArrayIndexStarts[I] = Record[Idx++];
1144
1145 VarDecl **ArrayIndexVars = E->getArrayIndexVars();
1146 for (unsigned I = 0; I != NumArrayIndexVars; ++I)
1147 ArrayIndexVars[I] = ReadDeclAs<VarDecl>(Record, Idx);
1148 }
Douglas Gregor01d08012012-02-07 10:09:13 +00001149}
1150
Sebastian Redl60adf4a2010-08-18 23:56:52 +00001151void ASTStmtReader::VisitCXXNamedCastExpr(CXXNamedCastExpr *E) {
Argyrios Kyrtzidis919e6932010-06-28 22:28:35 +00001152 VisitExplicitCastExpr(E);
Douglas Gregor1d5d0b92011-01-12 22:41:29 +00001153 SourceRange R = ReadSourceRange(Record, Idx);
1154 E->Loc = R.getBegin();
1155 E->RParenLoc = R.getEnd();
Fariborz Jahanianf799ae12013-02-22 22:02:53 +00001156 R = ReadSourceRange(Record, Idx);
1157 E->AngleBrackets = R;
Sam Weinigce757a72010-01-16 21:21:01 +00001158}
1159
Sebastian Redl60adf4a2010-08-18 23:56:52 +00001160void ASTStmtReader::VisitCXXStaticCastExpr(CXXStaticCastExpr *E) {
Sam Weinigce757a72010-01-16 21:21:01 +00001161 return VisitCXXNamedCastExpr(E);
1162}
1163
Sebastian Redl60adf4a2010-08-18 23:56:52 +00001164void ASTStmtReader::VisitCXXDynamicCastExpr(CXXDynamicCastExpr *E) {
Sam Weinigce757a72010-01-16 21:21:01 +00001165 return VisitCXXNamedCastExpr(E);
1166}
1167
Sebastian Redl60adf4a2010-08-18 23:56:52 +00001168void ASTStmtReader::VisitCXXReinterpretCastExpr(CXXReinterpretCastExpr *E) {
Sam Weinigce757a72010-01-16 21:21:01 +00001169 return VisitCXXNamedCastExpr(E);
1170}
1171
Sebastian Redl60adf4a2010-08-18 23:56:52 +00001172void ASTStmtReader::VisitCXXConstCastExpr(CXXConstCastExpr *E) {
Sam Weinigce757a72010-01-16 21:21:01 +00001173 return VisitCXXNamedCastExpr(E);
1174}
1175
Sebastian Redl60adf4a2010-08-18 23:56:52 +00001176void ASTStmtReader::VisitCXXFunctionalCastExpr(CXXFunctionalCastExpr *E) {
Argyrios Kyrtzidis919e6932010-06-28 22:28:35 +00001177 VisitExplicitCastExpr(E);
Sebastian Redlc3632732010-10-05 15:59:54 +00001178 E->setTypeBeginLoc(ReadSourceLocation(Record, Idx));
1179 E->setRParenLoc(ReadSourceLocation(Record, Idx));
Sam Weinigce757a72010-01-16 21:21:01 +00001180}
1181
Richard Smith9fcce652012-03-07 08:35:16 +00001182void ASTStmtReader::VisitUserDefinedLiteral(UserDefinedLiteral *E) {
1183 VisitCallExpr(E);
1184 E->UDSuffixLoc = ReadSourceLocation(Record, Idx);
1185}
1186
Sebastian Redl60adf4a2010-08-18 23:56:52 +00001187void ASTStmtReader::VisitCXXBoolLiteralExpr(CXXBoolLiteralExpr *E) {
Sam Weinigeb7f9612010-02-07 06:32:43 +00001188 VisitExpr(E);
1189 E->setValue(Record[Idx++]);
Sebastian Redlc3632732010-10-05 15:59:54 +00001190 E->setLocation(ReadSourceLocation(Record, Idx));
Sam Weinigeb7f9612010-02-07 06:32:43 +00001191}
1192
Sebastian Redl60adf4a2010-08-18 23:56:52 +00001193void ASTStmtReader::VisitCXXNullPtrLiteralExpr(CXXNullPtrLiteralExpr *E) {
Sam Weinigeb7f9612010-02-07 06:32:43 +00001194 VisitExpr(E);
Sebastian Redlc3632732010-10-05 15:59:54 +00001195 E->setLocation(ReadSourceLocation(Record, Idx));
Sam Weinigeb7f9612010-02-07 06:32:43 +00001196}
1197
Sebastian Redl60adf4a2010-08-18 23:56:52 +00001198void ASTStmtReader::VisitCXXTypeidExpr(CXXTypeidExpr *E) {
Chris Lattner14ab24f2010-05-09 06:03:39 +00001199 VisitExpr(E);
Sebastian Redlc3632732010-10-05 15:59:54 +00001200 E->setSourceRange(ReadSourceRange(Record, Idx));
Chris Lattner14ab24f2010-05-09 06:03:39 +00001201 if (E->isTypeOperand()) { // typeid(int)
Sebastian Redl577d4792010-07-22 22:43:28 +00001202 E->setTypeOperandSourceInfo(
Sebastian Redlc3632732010-10-05 15:59:54 +00001203 GetTypeSourceInfo(Record, Idx));
Argyrios Kyrtzidis919e6932010-06-28 22:28:35 +00001204 return;
Chris Lattner14ab24f2010-05-09 06:03:39 +00001205 }
1206
1207 // typeid(42+2)
Argyrios Kyrtzidisd98a2ab2010-06-29 22:46:25 +00001208 E->setExprOperand(Reader.ReadSubExpr());
Chris Lattner14ab24f2010-05-09 06:03:39 +00001209}
1210
Sebastian Redl60adf4a2010-08-18 23:56:52 +00001211void ASTStmtReader::VisitCXXThisExpr(CXXThisExpr *E) {
Chris Lattner2fbdfcd2010-05-09 06:15:05 +00001212 VisitExpr(E);
Sebastian Redlc3632732010-10-05 15:59:54 +00001213 E->setLocation(ReadSourceLocation(Record, Idx));
Chris Lattner2fbdfcd2010-05-09 06:15:05 +00001214 E->setImplicit(Record[Idx++]);
Chris Lattner2fbdfcd2010-05-09 06:15:05 +00001215}
1216
Sebastian Redl60adf4a2010-08-18 23:56:52 +00001217void ASTStmtReader::VisitCXXThrowExpr(CXXThrowExpr *E) {
Chris Lattner2fbdfcd2010-05-09 06:15:05 +00001218 VisitExpr(E);
Douglas Gregorbca01b42011-07-06 22:04:06 +00001219 E->ThrowLoc = ReadSourceLocation(Record, Idx);
1220 E->Op = Reader.ReadSubExpr();
1221 E->IsThrownVariableInScope = Record[Idx++];
Chris Lattner2fbdfcd2010-05-09 06:15:05 +00001222}
Chris Lattner14ab24f2010-05-09 06:03:39 +00001223
Sebastian Redl60adf4a2010-08-18 23:56:52 +00001224void ASTStmtReader::VisitCXXDefaultArgExpr(CXXDefaultArgExpr *E) {
Chris Lattner030854b2010-05-09 06:40:08 +00001225 VisitExpr(E);
Argyrios Kyrtzidis8a507332010-07-02 23:30:15 +00001226
Douglas Gregordf226552011-09-23 22:07:41 +00001227 assert((bool)Record[Idx] == E->Param.getInt() && "We messed up at creation ?");
Argyrios Kyrtzidis8a507332010-07-02 23:30:15 +00001228 ++Idx; // HasOtherExprStored and SubExpr was handled during creation.
Douglas Gregor409448c2011-07-21 22:35:25 +00001229 E->Param.setPointer(ReadDeclAs<ParmVarDecl>(Record, Idx));
Sebastian Redlc3632732010-10-05 15:59:54 +00001230 E->Loc = ReadSourceLocation(Record, Idx);
Chris Lattnerd2598362010-05-10 00:25:06 +00001231}
1232
Richard Smithc3bf52c2013-04-20 22:23:05 +00001233void ASTStmtReader::VisitCXXDefaultInitExpr(CXXDefaultInitExpr *E) {
1234 VisitExpr(E);
1235 E->Field = ReadDeclAs<FieldDecl>(Record, Idx);
1236 E->Loc = ReadSourceLocation(Record, Idx);
1237}
1238
Sebastian Redl60adf4a2010-08-18 23:56:52 +00001239void ASTStmtReader::VisitCXXBindTemporaryExpr(CXXBindTemporaryExpr *E) {
Chris Lattnerd2598362010-05-10 00:25:06 +00001240 VisitExpr(E);
Douglas Gregor409448c2011-07-21 22:35:25 +00001241 E->setTemporary(Reader.ReadCXXTemporary(F, Record, Idx));
Argyrios Kyrtzidisd98a2ab2010-06-29 22:46:25 +00001242 E->setSubExpr(Reader.ReadSubExpr());
Chris Lattnerd2598362010-05-10 00:25:06 +00001243}
1244
Sebastian Redl60adf4a2010-08-18 23:56:52 +00001245void ASTStmtReader::VisitCXXScalarValueInitExpr(CXXScalarValueInitExpr *E) {
Chris Lattner59218632010-05-10 01:22:27 +00001246 VisitExpr(E);
Sebastian Redlc3632732010-10-05 15:59:54 +00001247 E->TypeInfo = GetTypeSourceInfo(Record, Idx);
1248 E->RParenLoc = ReadSourceLocation(Record, Idx);
Chris Lattner59218632010-05-10 01:22:27 +00001249}
1250
Sebastian Redl60adf4a2010-08-18 23:56:52 +00001251void ASTStmtReader::VisitCXXNewExpr(CXXNewExpr *E) {
Chris Lattner59218632010-05-10 01:22:27 +00001252 VisitExpr(E);
John McCall6ec278d2011-01-27 09:37:56 +00001253 E->GlobalNew = Record[Idx++];
Sebastian Redl1548d142012-02-16 11:35:52 +00001254 bool isArray = Record[Idx++];
Sebastian Redl2aed8b82012-02-16 12:22:20 +00001255 E->UsualArrayDeleteWantsSize = Record[Idx++];
Chris Lattner59218632010-05-10 01:22:27 +00001256 unsigned NumPlacementArgs = Record[Idx++];
Sebastian Redl2aed8b82012-02-16 12:22:20 +00001257 E->StoredInitializationStyle = Record[Idx++];
Douglas Gregor409448c2011-07-21 22:35:25 +00001258 E->setOperatorNew(ReadDeclAs<FunctionDecl>(Record, Idx));
1259 E->setOperatorDelete(ReadDeclAs<FunctionDecl>(Record, Idx));
Sebastian Redlc3632732010-10-05 15:59:54 +00001260 E->AllocatedTypeInfo = GetTypeSourceInfo(Record, Idx);
Douglas Gregor83bc2762012-02-20 16:12:14 +00001261 E->TypeIdParens = ReadSourceRange(Record, Idx);
David Blaikie53056412012-11-07 00:12:38 +00001262 E->Range = ReadSourceRange(Record, Idx);
Douglas Gregor83bc2762012-02-20 16:12:14 +00001263 E->DirectInitRange = ReadSourceRange(Record, Idx);
Chandler Carruth428edaf2010-10-25 08:47:36 +00001264
Douglas Gregor35942772011-09-09 21:34:22 +00001265 E->AllocateArgsArray(Reader.getContext(), isArray, NumPlacementArgs,
Sebastian Redl2aed8b82012-02-16 12:22:20 +00001266 E->StoredInitializationStyle != 0);
Chris Lattner59218632010-05-10 01:22:27 +00001267
1268 // Install all the subexpressions.
Chris Lattner59218632010-05-10 01:22:27 +00001269 for (CXXNewExpr::raw_arg_iterator I = E->raw_arg_begin(),e = E->raw_arg_end();
1270 I != e; ++I)
Argyrios Kyrtzidisd98a2ab2010-06-29 22:46:25 +00001271 *I = Reader.ReadSubStmt();
Chris Lattner59218632010-05-10 01:22:27 +00001272}
1273
Sebastian Redl60adf4a2010-08-18 23:56:52 +00001274void ASTStmtReader::VisitCXXDeleteExpr(CXXDeleteExpr *E) {
Argyrios Kyrtzidis95fc98c2010-06-22 17:07:59 +00001275 VisitExpr(E);
Argyrios Kyrtzidisf1b89112010-09-13 20:15:40 +00001276 E->GlobalDelete = Record[Idx++];
1277 E->ArrayForm = Record[Idx++];
Argyrios Kyrtzidis4076dac2010-09-13 20:15:54 +00001278 E->ArrayFormAsWritten = Record[Idx++];
John McCall6ec278d2011-01-27 09:37:56 +00001279 E->UsualArrayDeleteWantsSize = Record[Idx++];
Douglas Gregor409448c2011-07-21 22:35:25 +00001280 E->OperatorDelete = ReadDeclAs<FunctionDecl>(Record, Idx);
Argyrios Kyrtzidisf1b89112010-09-13 20:15:40 +00001281 E->Argument = Reader.ReadSubExpr();
Sebastian Redlc3632732010-10-05 15:59:54 +00001282 E->Loc = ReadSourceLocation(Record, Idx);
Argyrios Kyrtzidis95fc98c2010-06-22 17:07:59 +00001283}
Chris Lattnerd2598362010-05-10 00:25:06 +00001284
Sebastian Redl60adf4a2010-08-18 23:56:52 +00001285void ASTStmtReader::VisitCXXPseudoDestructorExpr(CXXPseudoDestructorExpr *E) {
Argyrios Kyrtzidisde4bd182010-06-28 09:32:03 +00001286 VisitExpr(E);
1287
Douglas Gregorf3db29f2011-02-25 18:19:59 +00001288 E->Base = Reader.ReadSubExpr();
1289 E->IsArrow = Record[Idx++];
1290 E->OperatorLoc = ReadSourceLocation(Record, Idx);
1291 E->QualifierLoc = Reader.ReadNestedNameSpecifierLoc(F, Record, Idx);
1292 E->ScopeType = GetTypeSourceInfo(Record, Idx);
1293 E->ColonColonLoc = ReadSourceLocation(Record, Idx);
1294 E->TildeLoc = ReadSourceLocation(Record, Idx);
Argyrios Kyrtzidisde4bd182010-06-28 09:32:03 +00001295
Douglas Gregor95eab172011-07-28 20:55:49 +00001296 IdentifierInfo *II = Reader.GetIdentifierInfo(F, Record, Idx);
Argyrios Kyrtzidisde4bd182010-06-28 09:32:03 +00001297 if (II)
Sebastian Redlc3632732010-10-05 15:59:54 +00001298 E->setDestroyedType(II, ReadSourceLocation(Record, Idx));
Argyrios Kyrtzidisde4bd182010-06-28 09:32:03 +00001299 else
Sebastian Redlc3632732010-10-05 15:59:54 +00001300 E->setDestroyedType(GetTypeSourceInfo(Record, Idx));
Argyrios Kyrtzidisde4bd182010-06-28 09:32:03 +00001301}
1302
John McCall4765fa02010-12-06 08:20:24 +00001303void ASTStmtReader::VisitExprWithCleanups(ExprWithCleanups *E) {
Chris Lattnerd2598362010-05-10 00:25:06 +00001304 VisitExpr(E);
John McCall80ee6e82011-11-10 05:35:25 +00001305
1306 unsigned NumObjects = Record[Idx++];
1307 assert(NumObjects == E->getNumObjects());
1308 for (unsigned i = 0; i != NumObjects; ++i)
1309 E->getObjectsBuffer()[i] = ReadDeclAs<BlockDecl>(Record, Idx);
1310
1311 E->SubExpr = Reader.ReadSubExpr();
Chris Lattner030854b2010-05-09 06:40:08 +00001312}
1313
Argyrios Kyrtzidis919e6932010-06-28 22:28:35 +00001314void
Sebastian Redl60adf4a2010-08-18 23:56:52 +00001315ASTStmtReader::VisitCXXDependentScopeMemberExpr(CXXDependentScopeMemberExpr *E){
Argyrios Kyrtzidis8dfbd8b2010-06-24 08:57:31 +00001316 VisitExpr(E);
Abramo Bagnarae4b92762012-01-27 09:46:47 +00001317
1318 if (Record[Idx++]) // HasTemplateKWAndArgsInfo
1319 ReadTemplateKWAndArgsInfo(*E->getTemplateKWAndArgsInfo(),
1320 /*NumTemplateArgs=*/Record[Idx++]);
Argyrios Kyrtzidis8dfbd8b2010-06-24 08:57:31 +00001321
Douglas Gregor7c3179c2011-02-28 18:50:33 +00001322 E->Base = Reader.ReadSubExpr();
Douglas Gregor393f2492011-07-22 00:38:23 +00001323 E->BaseType = Reader.readType(F, Record, Idx);
Douglas Gregor7c3179c2011-02-28 18:50:33 +00001324 E->IsArrow = Record[Idx++];
1325 E->OperatorLoc = ReadSourceLocation(Record, Idx);
1326 E->QualifierLoc = Reader.ReadNestedNameSpecifierLoc(F, Record, Idx);
Douglas Gregor409448c2011-07-21 22:35:25 +00001327 E->FirstQualifierFoundInScope = ReadDeclAs<NamedDecl>(Record, Idx);
Argyrios Kyrtzidis40451072010-10-15 18:21:24 +00001328 ReadDeclarationNameInfo(E->MemberNameInfo, Record, Idx);
Argyrios Kyrtzidis8dfbd8b2010-06-24 08:57:31 +00001329}
1330
Argyrios Kyrtzidis919e6932010-06-28 22:28:35 +00001331void
Sebastian Redl60adf4a2010-08-18 23:56:52 +00001332ASTStmtReader::VisitDependentScopeDeclRefExpr(DependentScopeDeclRefExpr *E) {
Argyrios Kyrtzidis12dffcd2010-06-28 09:31:56 +00001333 VisitExpr(E);
Abramo Bagnarae4b92762012-01-27 09:46:47 +00001334
1335 if (Record[Idx++]) // HasTemplateKWAndArgsInfo
1336 ReadTemplateKWAndArgsInfo(*E->getTemplateKWAndArgsInfo(),
1337 /*NumTemplateArgs=*/Record[Idx++]);
Douglas Gregor00cf3cc2011-02-25 20:49:16 +00001338
1339 E->QualifierLoc = Reader.ReadNestedNameSpecifierLoc(F, Record, Idx);
Argyrios Kyrtzidis40451072010-10-15 18:21:24 +00001340 ReadDeclarationNameInfo(E->NameInfo, Record, Idx);
Argyrios Kyrtzidis12dffcd2010-06-28 09:31:56 +00001341}
1342
Argyrios Kyrtzidis919e6932010-06-28 22:28:35 +00001343void
Sebastian Redl60adf4a2010-08-18 23:56:52 +00001344ASTStmtReader::VisitCXXUnresolvedConstructExpr(CXXUnresolvedConstructExpr *E) {
Argyrios Kyrtzidis8dfbd8b2010-06-24 08:57:31 +00001345 VisitExpr(E);
1346 assert(Record[Idx] == E->arg_size() && "Read wrong record during creation ?");
1347 ++Idx; // NumArgs;
1348 for (unsigned I = 0, N = E->arg_size(); I != N; ++I)
Argyrios Kyrtzidisd98a2ab2010-06-29 22:46:25 +00001349 E->setArg(I, Reader.ReadSubExpr());
Sebastian Redlc3632732010-10-05 15:59:54 +00001350 E->Type = GetTypeSourceInfo(Record, Idx);
1351 E->setLParenLoc(ReadSourceLocation(Record, Idx));
1352 E->setRParenLoc(ReadSourceLocation(Record, Idx));
Argyrios Kyrtzidis8dfbd8b2010-06-24 08:57:31 +00001353}
1354
Sebastian Redl60adf4a2010-08-18 23:56:52 +00001355void ASTStmtReader::VisitOverloadExpr(OverloadExpr *E) {
Argyrios Kyrtzidisa77eb082010-06-25 09:03:26 +00001356 VisitExpr(E);
Abramo Bagnarae4b92762012-01-27 09:46:47 +00001357
1358 if (Record[Idx++]) // HasTemplateKWAndArgsInfo
1359 ReadTemplateKWAndArgsInfo(*E->getTemplateKWAndArgsInfo(),
1360 /*NumTemplateArgs=*/Record[Idx++]);
Argyrios Kyrtzidisa77eb082010-06-25 09:03:26 +00001361
1362 unsigned NumDecls = Record[Idx++];
1363 UnresolvedSet<8> Decls;
1364 for (unsigned i = 0; i != NumDecls; ++i) {
Douglas Gregor409448c2011-07-21 22:35:25 +00001365 NamedDecl *D = ReadDeclAs<NamedDecl>(Record, Idx);
Argyrios Kyrtzidisa77eb082010-06-25 09:03:26 +00001366 AccessSpecifier AS = (AccessSpecifier)Record[Idx++];
1367 Decls.addDecl(D, AS);
1368 }
Douglas Gregor35942772011-09-09 21:34:22 +00001369 E->initializeResults(Reader.getContext(), Decls.begin(), Decls.end());
Argyrios Kyrtzidisa77eb082010-06-25 09:03:26 +00001370
Argyrios Kyrtzidis40451072010-10-15 18:21:24 +00001371 ReadDeclarationNameInfo(E->NameInfo, Record, Idx);
Douglas Gregor4c9be892011-02-28 20:01:57 +00001372 E->QualifierLoc = Reader.ReadNestedNameSpecifierLoc(F, Record, Idx);
Argyrios Kyrtzidisa77eb082010-06-25 09:03:26 +00001373}
1374
Sebastian Redl60adf4a2010-08-18 23:56:52 +00001375void ASTStmtReader::VisitUnresolvedMemberExpr(UnresolvedMemberExpr *E) {
Argyrios Kyrtzidis919e6932010-06-28 22:28:35 +00001376 VisitOverloadExpr(E);
Douglas Gregor4c9be892011-02-28 20:01:57 +00001377 E->IsArrow = Record[Idx++];
1378 E->HasUnresolvedUsing = Record[Idx++];
1379 E->Base = Reader.ReadSubExpr();
Douglas Gregor393f2492011-07-22 00:38:23 +00001380 E->BaseType = Reader.readType(F, Record, Idx);
Douglas Gregor4c9be892011-02-28 20:01:57 +00001381 E->OperatorLoc = ReadSourceLocation(Record, Idx);
Argyrios Kyrtzidisa77eb082010-06-25 09:03:26 +00001382}
1383
Sebastian Redl60adf4a2010-08-18 23:56:52 +00001384void ASTStmtReader::VisitUnresolvedLookupExpr(UnresolvedLookupExpr *E) {
Argyrios Kyrtzidis919e6932010-06-28 22:28:35 +00001385 VisitOverloadExpr(E);
Douglas Gregor4c9be892011-02-28 20:01:57 +00001386 E->RequiresADL = Record[Idx++];
1387 E->Overloaded = Record[Idx++];
Douglas Gregor409448c2011-07-21 22:35:25 +00001388 E->NamingClass = ReadDeclAs<CXXRecordDecl>(Record, Idx);
Argyrios Kyrtzidisbd65bb52010-06-25 09:03:34 +00001389}
1390
Sebastian Redl60adf4a2010-08-18 23:56:52 +00001391void ASTStmtReader::VisitUnaryTypeTraitExpr(UnaryTypeTraitExpr *E) {
Argyrios Kyrtzidis6d00c132010-07-10 11:46:15 +00001392 VisitExpr(E);
1393 E->UTT = (UnaryTypeTrait)Record[Idx++];
Sebastian Redl0dfd8482010-09-13 20:56:31 +00001394 E->Value = (bool)Record[Idx++];
Sebastian Redlc3632732010-10-05 15:59:54 +00001395 SourceRange Range = ReadSourceRange(Record, Idx);
Argyrios Kyrtzidis6d00c132010-07-10 11:46:15 +00001396 E->Loc = Range.getBegin();
1397 E->RParen = Range.getEnd();
Sebastian Redlc3632732010-10-05 15:59:54 +00001398 E->QueriedType = GetTypeSourceInfo(Record, Idx);
Argyrios Kyrtzidis6d00c132010-07-10 11:46:15 +00001399}
1400
Francois Pichet6ad6f282010-12-07 00:08:36 +00001401void ASTStmtReader::VisitBinaryTypeTraitExpr(BinaryTypeTraitExpr *E) {
1402 VisitExpr(E);
1403 E->BTT = (BinaryTypeTrait)Record[Idx++];
1404 E->Value = (bool)Record[Idx++];
1405 SourceRange Range = ReadSourceRange(Record, Idx);
1406 E->Loc = Range.getBegin();
1407 E->RParen = Range.getEnd();
1408 E->LhsType = GetTypeSourceInfo(Record, Idx);
1409 E->RhsType = GetTypeSourceInfo(Record, Idx);
1410}
1411
Douglas Gregor4ca8ac22012-02-24 07:38:34 +00001412void ASTStmtReader::VisitTypeTraitExpr(TypeTraitExpr *E) {
1413 VisitExpr(E);
1414 E->TypeTraitExprBits.NumArgs = Record[Idx++];
1415 E->TypeTraitExprBits.Kind = Record[Idx++];
1416 E->TypeTraitExprBits.Value = Record[Idx++];
1417
1418 TypeSourceInfo **Args = E->getTypeSourceInfos();
1419 for (unsigned I = 0, N = E->getNumArgs(); I != N; ++I)
1420 Args[I] = GetTypeSourceInfo(Record, Idx);
1421}
1422
John Wiegley21ff2e52011-04-28 00:16:57 +00001423void ASTStmtReader::VisitArrayTypeTraitExpr(ArrayTypeTraitExpr *E) {
1424 VisitExpr(E);
1425 E->ATT = (ArrayTypeTrait)Record[Idx++];
1426 E->Value = (unsigned int)Record[Idx++];
1427 SourceRange Range = ReadSourceRange(Record, Idx);
1428 E->Loc = Range.getBegin();
1429 E->RParen = Range.getEnd();
1430 E->QueriedType = GetTypeSourceInfo(Record, Idx);
1431}
1432
John Wiegley55262202011-04-25 06:54:41 +00001433void ASTStmtReader::VisitExpressionTraitExpr(ExpressionTraitExpr *E) {
1434 VisitExpr(E);
1435 E->ET = (ExpressionTrait)Record[Idx++];
1436 E->Value = (bool)Record[Idx++];
1437 SourceRange Range = ReadSourceRange(Record, Idx);
1438 E->QueriedExpression = Reader.ReadSubExpr();
1439 E->Loc = Range.getBegin();
1440 E->RParen = Range.getEnd();
1441}
1442
Sebastian Redl6b219d02010-09-10 20:55:54 +00001443void ASTStmtReader::VisitCXXNoexceptExpr(CXXNoexceptExpr *E) {
1444 VisitExpr(E);
Sebastian Redl5221d8f2010-09-10 22:34:40 +00001445 E->Value = (bool)Record[Idx++];
Sebastian Redlc3632732010-10-05 15:59:54 +00001446 E->Range = ReadSourceRange(Record, Idx);
Sebastian Redl5221d8f2010-09-10 22:34:40 +00001447 E->Operand = Reader.ReadSubExpr();
Sebastian Redl6b219d02010-09-10 20:55:54 +00001448}
1449
Douglas Gregorbe230c32011-01-03 17:17:50 +00001450void ASTStmtReader::VisitPackExpansionExpr(PackExpansionExpr *E) {
1451 VisitExpr(E);
1452 E->EllipsisLoc = ReadSourceLocation(Record, Idx);
Douglas Gregor67fd1252011-01-14 21:20:45 +00001453 E->NumExpansions = Record[Idx++];
Douglas Gregorbe230c32011-01-03 17:17:50 +00001454 E->Pattern = Reader.ReadSubExpr();
1455}
1456
Douglas Gregoree8aff02011-01-04 17:33:58 +00001457void ASTStmtReader::VisitSizeOfPackExpr(SizeOfPackExpr *E) {
1458 VisitExpr(E);
1459 E->OperatorLoc = ReadSourceLocation(Record, Idx);
1460 E->PackLoc = ReadSourceLocation(Record, Idx);
1461 E->RParenLoc = ReadSourceLocation(Record, Idx);
1462 E->Length = Record[Idx++];
Douglas Gregor409448c2011-07-21 22:35:25 +00001463 E->Pack = ReadDeclAs<NamedDecl>(Record, Idx);
Douglas Gregoree8aff02011-01-04 17:33:58 +00001464}
1465
John McCall7110fd62011-07-15 07:00:14 +00001466void ASTStmtReader::VisitSubstNonTypeTemplateParmExpr(
1467 SubstNonTypeTemplateParmExpr *E) {
1468 VisitExpr(E);
Douglas Gregor409448c2011-07-21 22:35:25 +00001469 E->Param = ReadDeclAs<NonTypeTemplateParmDecl>(Record, Idx);
John McCall7110fd62011-07-15 07:00:14 +00001470 E->NameLoc = ReadSourceLocation(Record, Idx);
1471 E->Replacement = Reader.ReadSubExpr();
1472}
1473
Douglas Gregorc7793c72011-01-15 01:15:58 +00001474void ASTStmtReader::VisitSubstNonTypeTemplateParmPackExpr(
1475 SubstNonTypeTemplateParmPackExpr *E) {
1476 VisitExpr(E);
Douglas Gregor409448c2011-07-21 22:35:25 +00001477 E->Param = ReadDeclAs<NonTypeTemplateParmDecl>(Record, Idx);
Douglas Gregorc7793c72011-01-15 01:15:58 +00001478 TemplateArgument ArgPack = Reader.ReadTemplateArgument(F, Record, Idx);
1479 if (ArgPack.getKind() != TemplateArgument::Pack)
1480 return;
1481
1482 E->Arguments = ArgPack.pack_begin();
1483 E->NumArguments = ArgPack.pack_size();
1484 E->NameLoc = ReadSourceLocation(Record, Idx);
1485}
1486
Richard Smith9a4db032012-09-12 00:56:43 +00001487void ASTStmtReader::VisitFunctionParmPackExpr(FunctionParmPackExpr *E) {
1488 VisitExpr(E);
1489 E->NumParameters = Record[Idx++];
1490 E->ParamPack = ReadDeclAs<ParmVarDecl>(Record, Idx);
1491 E->NameLoc = ReadSourceLocation(Record, Idx);
1492 ParmVarDecl **Parms = reinterpret_cast<ParmVarDecl**>(E+1);
1493 for (unsigned i = 0, n = E->NumParameters; i != n; ++i)
1494 Parms[i] = ReadDeclAs<ParmVarDecl>(Record, Idx);
1495}
1496
Douglas Gregor03e80032011-06-21 17:03:29 +00001497void ASTStmtReader::VisitMaterializeTemporaryExpr(MaterializeTemporaryExpr *E) {
1498 VisitExpr(E);
1499 E->Temporary = Reader.ReadSubExpr();
1500}
1501
John McCall7cd7d1a2010-11-15 23:31:06 +00001502void ASTStmtReader::VisitOpaqueValueExpr(OpaqueValueExpr *E) {
1503 VisitExpr(E);
Argyrios Kyrtzidis8bc27822011-12-03 03:49:52 +00001504 E->SourceExpr = Reader.ReadSubExpr();
Douglas Gregorb608b982011-01-28 02:26:04 +00001505 E->Loc = ReadSourceLocation(Record, Idx);
John McCall7cd7d1a2010-11-15 23:31:06 +00001506}
1507
Peter Collingbournee08ce652011-02-09 21:07:24 +00001508//===----------------------------------------------------------------------===//
John McCall7110fd62011-07-15 07:00:14 +00001509// Microsoft Expressions and Statements
1510//===----------------------------------------------------------------------===//
John McCall76da55d2013-04-16 07:28:30 +00001511void ASTStmtReader::VisitMSPropertyRefExpr(MSPropertyRefExpr *E) {
1512 VisitExpr(E);
1513 E->IsArrow = (Record[Idx++] != 0);
1514 E->BaseExpr = Reader.ReadSubExpr();
1515 E->QualifierLoc = Reader.ReadNestedNameSpecifierLoc(F, Record, Idx);
1516 E->MemberLoc = ReadSourceLocation(Record, Idx);
1517 E->TheDecl = ReadDeclAs<MSPropertyDecl>(Record, Idx);
1518}
1519
John McCall7110fd62011-07-15 07:00:14 +00001520void ASTStmtReader::VisitCXXUuidofExpr(CXXUuidofExpr *E) {
1521 VisitExpr(E);
1522 E->setSourceRange(ReadSourceRange(Record, Idx));
1523 if (E->isTypeOperand()) { // __uuidof(ComType)
1524 E->setTypeOperandSourceInfo(
1525 GetTypeSourceInfo(Record, Idx));
1526 return;
1527 }
1528
1529 // __uuidof(expr)
1530 E->setExprOperand(Reader.ReadSubExpr());
1531}
1532
1533void ASTStmtReader::VisitSEHExceptStmt(SEHExceptStmt *S) {
1534 VisitStmt(S);
1535 S->Loc = ReadSourceLocation(Record, Idx);
1536 S->Children[SEHExceptStmt::FILTER_EXPR] = Reader.ReadSubStmt();
1537 S->Children[SEHExceptStmt::BLOCK] = Reader.ReadSubStmt();
1538}
1539
1540void ASTStmtReader::VisitSEHFinallyStmt(SEHFinallyStmt *S) {
1541 VisitStmt(S);
1542 S->Loc = ReadSourceLocation(Record, Idx);
1543 S->Block = Reader.ReadSubStmt();
1544}
1545
1546void ASTStmtReader::VisitSEHTryStmt(SEHTryStmt *S) {
1547 VisitStmt(S);
1548 S->IsCXXTry = Record[Idx++];
1549 S->TryLoc = ReadSourceLocation(Record, Idx);
1550 S->Children[SEHTryStmt::TRY] = Reader.ReadSubStmt();
1551 S->Children[SEHTryStmt::HANDLER] = Reader.ReadSubStmt();
1552}
1553
1554//===----------------------------------------------------------------------===//
Peter Collingbournee08ce652011-02-09 21:07:24 +00001555// CUDA Expressions and Statements
1556//===----------------------------------------------------------------------===//
1557
1558void ASTStmtReader::VisitCUDAKernelCallExpr(CUDAKernelCallExpr *E) {
1559 VisitCallExpr(E);
1560 E->setConfig(cast<CallExpr>(Reader.ReadSubExpr()));
1561}
1562
John McCall7110fd62011-07-15 07:00:14 +00001563//===----------------------------------------------------------------------===//
1564// OpenCL Expressions and Statements.
1565//===----------------------------------------------------------------------===//
1566void ASTStmtReader::VisitAsTypeExpr(AsTypeExpr *E) {
1567 VisitExpr(E);
1568 E->BuiltinLoc = ReadSourceLocation(Record, Idx);
1569 E->RParenLoc = ReadSourceLocation(Record, Idx);
1570 E->SrcExpr = Reader.ReadSubExpr();
1571}
1572
1573//===----------------------------------------------------------------------===//
1574// ASTReader Implementation
1575//===----------------------------------------------------------------------===//
1576
Douglas Gregor1a4761e2011-11-30 23:21:26 +00001577Stmt *ASTReader::ReadStmt(ModuleFile &F) {
Argyrios Kyrtzidis919e6932010-06-28 22:28:35 +00001578 switch (ReadingKind) {
1579 case Read_Decl:
1580 case Read_Type:
Sebastian Redlc3632732010-10-05 15:59:54 +00001581 return ReadStmtFromStream(F);
Argyrios Kyrtzidis919e6932010-06-28 22:28:35 +00001582 case Read_Stmt:
Argyrios Kyrtzidisd98a2ab2010-06-29 22:46:25 +00001583 return ReadSubStmt();
Argyrios Kyrtzidis919e6932010-06-28 22:28:35 +00001584 }
1585
1586 llvm_unreachable("ReadingKind not set ?");
Argyrios Kyrtzidis919e6932010-06-28 22:28:35 +00001587}
1588
Douglas Gregor1a4761e2011-11-30 23:21:26 +00001589Expr *ASTReader::ReadExpr(ModuleFile &F) {
Sebastian Redlc3632732010-10-05 15:59:54 +00001590 return cast_or_null<Expr>(ReadStmt(F));
Argyrios Kyrtzidis919e6932010-06-28 22:28:35 +00001591}
Chris Lattner030854b2010-05-09 06:40:08 +00001592
Sebastian Redlc43b54c2010-08-18 23:56:43 +00001593Expr *ASTReader::ReadSubExpr() {
Argyrios Kyrtzidisd98a2ab2010-06-29 22:46:25 +00001594 return cast_or_null<Expr>(ReadSubStmt());
1595}
1596
Chris Lattner52e97d12009-04-27 05:41:06 +00001597// Within the bitstream, expressions are stored in Reverse Polish
1598// Notation, with each of the subexpressions preceding the
Argyrios Kyrtzidis919e6932010-06-28 22:28:35 +00001599// expression they are stored in. Subexpressions are stored from last to first.
1600// To evaluate expressions, we continue reading expressions and placing them on
1601// the stack, with expressions having operands removing those operands from the
Chris Lattner52e97d12009-04-27 05:41:06 +00001602// stack. Evaluation terminates when we see a STMT_STOP record, and
1603// the single remaining expression on the stack is our result.
Douglas Gregor1a4761e2011-11-30 23:21:26 +00001604Stmt *ASTReader::ReadStmtFromStream(ModuleFile &F) {
Argyrios Kyrtzidis919e6932010-06-28 22:28:35 +00001605
1606 ReadingKindTracker ReadingKind(Read_Stmt, *this);
Sebastian Redlc3632732010-10-05 15:59:54 +00001607 llvm::BitstreamCursor &Cursor = F.DeclsCursor;
Argyrios Kyrtzidise6f08682011-10-21 23:02:28 +00001608
1609 // Map of offset to previously deserialized stmt. The offset points
1610 /// just after the stmt record.
1611 llvm::DenseMap<uint64_t, Stmt *> StmtEntries;
Sebastian Redlc3632732010-10-05 15:59:54 +00001612
Argyrios Kyrtzidis919e6932010-06-28 22:28:35 +00001613#ifndef NDEBUG
1614 unsigned PrevNumStmts = StmtStack.size();
1615#endif
1616
Chris Lattner4c6f9522009-04-27 05:14:47 +00001617 RecordData Record;
1618 unsigned Idx;
Sebastian Redlc3632732010-10-05 15:59:54 +00001619 ASTStmtReader Reader(*this, F, Cursor, Record, Idx);
Chris Lattner4c6f9522009-04-27 05:14:47 +00001620 Stmt::EmptyShell Empty;
1621
1622 while (true) {
Chris Lattnerb3ce3572013-01-20 02:38:54 +00001623 llvm::BitstreamEntry Entry = Cursor.advanceSkippingSubblocks();
1624
1625 switch (Entry.Kind) {
1626 case llvm::BitstreamEntry::SubBlock: // Handled for us already.
1627 case llvm::BitstreamEntry::Error:
1628 Error("malformed block record in AST file");
1629 return 0;
1630 case llvm::BitstreamEntry::EndBlock:
1631 goto Done;
1632 case llvm::BitstreamEntry::Record:
1633 // The interesting case.
Chris Lattner4c6f9522009-04-27 05:14:47 +00001634 break;
1635 }
1636
Chris Lattner4c6f9522009-04-27 05:14:47 +00001637
1638 Stmt *S = 0;
1639 Idx = 0;
1640 Record.clear();
1641 bool Finished = false;
Argyrios Kyrtzidise6f08682011-10-21 23:02:28 +00001642 bool IsStmtReference = false;
Chris Lattnerb3ce3572013-01-20 02:38:54 +00001643 switch ((StmtCode)Cursor.readRecord(Entry.ID, Record)) {
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001644 case STMT_STOP:
Chris Lattner4c6f9522009-04-27 05:14:47 +00001645 Finished = true;
1646 break;
1647
Argyrios Kyrtzidise6f08682011-10-21 23:02:28 +00001648 case STMT_REF_PTR:
1649 IsStmtReference = true;
1650 assert(StmtEntries.find(Record[0]) != StmtEntries.end() &&
1651 "No stmt was recorded for this offset reference!");
1652 S = StmtEntries[Record[Idx++]];
1653 break;
1654
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001655 case STMT_NULL_PTR:
Mike Stump1eb44332009-09-09 15:08:12 +00001656 S = 0;
Chris Lattner4c6f9522009-04-27 05:14:47 +00001657 break;
1658
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001659 case STMT_NULL:
Chris Lattner4c6f9522009-04-27 05:14:47 +00001660 S = new (Context) NullStmt(Empty);
1661 break;
1662
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001663 case STMT_COMPOUND:
Chris Lattner4c6f9522009-04-27 05:14:47 +00001664 S = new (Context) CompoundStmt(Empty);
1665 break;
1666
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001667 case STMT_CASE:
Chris Lattner4c6f9522009-04-27 05:14:47 +00001668 S = new (Context) CaseStmt(Empty);
1669 break;
1670
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001671 case STMT_DEFAULT:
Chris Lattner4c6f9522009-04-27 05:14:47 +00001672 S = new (Context) DefaultStmt(Empty);
1673 break;
1674
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001675 case STMT_LABEL:
Chris Lattner4c6f9522009-04-27 05:14:47 +00001676 S = new (Context) LabelStmt(Empty);
1677 break;
1678
Richard Smith534986f2012-04-14 00:33:13 +00001679 case STMT_ATTRIBUTED:
Alexander Kornienko49908902012-07-09 10:04:07 +00001680 S = AttributedStmt::CreateEmpty(
1681 Context,
1682 /*NumAttrs*/Record[ASTStmtReader::NumStmtFields]);
Richard Smith534986f2012-04-14 00:33:13 +00001683 break;
1684
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001685 case STMT_IF:
Chris Lattner4c6f9522009-04-27 05:14:47 +00001686 S = new (Context) IfStmt(Empty);
1687 break;
1688
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001689 case STMT_SWITCH:
Chris Lattner4c6f9522009-04-27 05:14:47 +00001690 S = new (Context) SwitchStmt(Empty);
1691 break;
1692
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001693 case STMT_WHILE:
Chris Lattner4c6f9522009-04-27 05:14:47 +00001694 S = new (Context) WhileStmt(Empty);
1695 break;
1696
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001697 case STMT_DO:
Chris Lattner4c6f9522009-04-27 05:14:47 +00001698 S = new (Context) DoStmt(Empty);
1699 break;
Mike Stump1eb44332009-09-09 15:08:12 +00001700
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001701 case STMT_FOR:
Chris Lattner4c6f9522009-04-27 05:14:47 +00001702 S = new (Context) ForStmt(Empty);
1703 break;
1704
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001705 case STMT_GOTO:
Chris Lattner4c6f9522009-04-27 05:14:47 +00001706 S = new (Context) GotoStmt(Empty);
1707 break;
Mike Stump1eb44332009-09-09 15:08:12 +00001708
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001709 case STMT_INDIRECT_GOTO:
Chris Lattner4c6f9522009-04-27 05:14:47 +00001710 S = new (Context) IndirectGotoStmt(Empty);
1711 break;
1712
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001713 case STMT_CONTINUE:
Chris Lattner4c6f9522009-04-27 05:14:47 +00001714 S = new (Context) ContinueStmt(Empty);
1715 break;
1716
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001717 case STMT_BREAK:
Chris Lattner4c6f9522009-04-27 05:14:47 +00001718 S = new (Context) BreakStmt(Empty);
1719 break;
1720
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001721 case STMT_RETURN:
Chris Lattner4c6f9522009-04-27 05:14:47 +00001722 S = new (Context) ReturnStmt(Empty);
1723 break;
1724
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001725 case STMT_DECL:
Chris Lattner4c6f9522009-04-27 05:14:47 +00001726 S = new (Context) DeclStmt(Empty);
1727 break;
1728
Chad Rosierdf5faf52012-08-25 00:11:56 +00001729 case STMT_GCCASM:
1730 S = new (Context) GCCAsmStmt(Empty);
Chris Lattner4c6f9522009-04-27 05:14:47 +00001731 break;
1732
Chad Rosiercd518a02012-08-24 23:51:02 +00001733 case STMT_MSASM:
1734 S = new (Context) MSAsmStmt(Empty);
1735 break;
1736
Tareq A. Siraj051303c2013-04-16 18:53:08 +00001737 case STMT_CAPTURED:
1738 llvm_unreachable("not implemented yet");
1739 break;
1740
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001741 case EXPR_PREDEFINED:
Chris Lattner4c6f9522009-04-27 05:14:47 +00001742 S = new (Context) PredefinedExpr(Empty);
1743 break;
Mike Stump1eb44332009-09-09 15:08:12 +00001744
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001745 case EXPR_DECL_REF:
Chandler Carruth3aa81402011-05-01 23:48:14 +00001746 S = DeclRefExpr::CreateEmpty(
Douglas Gregor35942772011-09-09 21:34:22 +00001747 Context,
Chandler Carruth3aa81402011-05-01 23:48:14 +00001748 /*HasQualifier=*/Record[ASTStmtReader::NumExprFields],
1749 /*HasFoundDecl=*/Record[ASTStmtReader::NumExprFields + 1],
Abramo Bagnarae4b92762012-01-27 09:46:47 +00001750 /*HasTemplateKWAndArgsInfo=*/Record[ASTStmtReader::NumExprFields + 2],
Chandler Carruth3aa81402011-05-01 23:48:14 +00001751 /*NumTemplateArgs=*/Record[ASTStmtReader::NumExprFields + 2] ?
John McCallf4b88a42012-03-10 09:33:50 +00001752 Record[ASTStmtReader::NumExprFields + 5] : 0);
Chris Lattner4c6f9522009-04-27 05:14:47 +00001753 break;
Mike Stump1eb44332009-09-09 15:08:12 +00001754
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001755 case EXPR_INTEGER_LITERAL:
Douglas Gregor35942772011-09-09 21:34:22 +00001756 S = IntegerLiteral::Create(Context, Empty);
Chris Lattner4c6f9522009-04-27 05:14:47 +00001757 break;
Mike Stump1eb44332009-09-09 15:08:12 +00001758
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001759 case EXPR_FLOATING_LITERAL:
Douglas Gregor35942772011-09-09 21:34:22 +00001760 S = FloatingLiteral::Create(Context, Empty);
Chris Lattner4c6f9522009-04-27 05:14:47 +00001761 break;
Mike Stump1eb44332009-09-09 15:08:12 +00001762
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001763 case EXPR_IMAGINARY_LITERAL:
Chris Lattner4c6f9522009-04-27 05:14:47 +00001764 S = new (Context) ImaginaryLiteral(Empty);
1765 break;
1766
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001767 case EXPR_STRING_LITERAL:
Douglas Gregor35942772011-09-09 21:34:22 +00001768 S = StringLiteral::CreateEmpty(Context,
Sebastian Redl60adf4a2010-08-18 23:56:52 +00001769 Record[ASTStmtReader::NumExprFields + 1]);
Chris Lattner4c6f9522009-04-27 05:14:47 +00001770 break;
1771
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001772 case EXPR_CHARACTER_LITERAL:
Chris Lattner4c6f9522009-04-27 05:14:47 +00001773 S = new (Context) CharacterLiteral(Empty);
1774 break;
1775
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001776 case EXPR_PAREN:
Chris Lattner4c6f9522009-04-27 05:14:47 +00001777 S = new (Context) ParenExpr(Empty);
1778 break;
1779
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001780 case EXPR_PAREN_LIST:
Argyrios Kyrtzidis37bdfe22010-06-30 08:49:18 +00001781 S = new (Context) ParenListExpr(Empty);
1782 break;
1783
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001784 case EXPR_UNARY_OPERATOR:
Chris Lattner4c6f9522009-04-27 05:14:47 +00001785 S = new (Context) UnaryOperator(Empty);
1786 break;
1787
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001788 case EXPR_OFFSETOF:
Douglas Gregor35942772011-09-09 21:34:22 +00001789 S = OffsetOfExpr::CreateEmpty(Context,
Sebastian Redl60adf4a2010-08-18 23:56:52 +00001790 Record[ASTStmtReader::NumExprFields],
1791 Record[ASTStmtReader::NumExprFields + 1]);
Douglas Gregor8ecdb652010-04-28 22:16:22 +00001792 break;
1793
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001794 case EXPR_SIZEOF_ALIGN_OF:
Peter Collingbournef4e3cfb2011-03-11 19:24:49 +00001795 S = new (Context) UnaryExprOrTypeTraitExpr(Empty);
Chris Lattner4c6f9522009-04-27 05:14:47 +00001796 break;
1797
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001798 case EXPR_ARRAY_SUBSCRIPT:
Chris Lattner4c6f9522009-04-27 05:14:47 +00001799 S = new (Context) ArraySubscriptExpr(Empty);
1800 break;
1801
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001802 case EXPR_CALL:
Douglas Gregor35942772011-09-09 21:34:22 +00001803 S = new (Context) CallExpr(Context, Stmt::CallExprClass, Empty);
Chris Lattner4c6f9522009-04-27 05:14:47 +00001804 break;
1805
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001806 case EXPR_MEMBER: {
Argyrios Kyrtzidis663e3802010-07-08 13:09:47 +00001807 // We load everything here and fully initialize it at creation.
1808 // That way we can use MemberExpr::Create and don't have to duplicate its
1809 // logic with a MemberExpr::CreateEmpty.
1810
1811 assert(Idx == 0);
Douglas Gregor40d96a62011-02-28 21:54:11 +00001812 NestedNameSpecifierLoc QualifierLoc;
Argyrios Kyrtzidis663e3802010-07-08 13:09:47 +00001813 if (Record[Idx++]) { // HasQualifier.
Douglas Gregor40d96a62011-02-28 21:54:11 +00001814 QualifierLoc = ReadNestedNameSpecifierLoc(F, Record, Idx);
Argyrios Kyrtzidis663e3802010-07-08 13:09:47 +00001815 }
1816
Abramo Bagnarae4b92762012-01-27 09:46:47 +00001817 SourceLocation TemplateKWLoc;
Argyrios Kyrtzidis663e3802010-07-08 13:09:47 +00001818 TemplateArgumentListInfo ArgInfo;
Abramo Bagnarae4b92762012-01-27 09:46:47 +00001819 bool HasTemplateKWAndArgsInfo = Record[Idx++];
1820 if (HasTemplateKWAndArgsInfo) {
1821 TemplateKWLoc = ReadSourceLocation(F, Record, Idx);
Douglas Gregordef03542011-02-04 12:01:24 +00001822 unsigned NumTemplateArgs = Record[Idx++];
Sebastian Redlc3632732010-10-05 15:59:54 +00001823 ArgInfo.setLAngleLoc(ReadSourceLocation(F, Record, Idx));
1824 ArgInfo.setRAngleLoc(ReadSourceLocation(F, Record, Idx));
Argyrios Kyrtzidis663e3802010-07-08 13:09:47 +00001825 for (unsigned i = 0; i != NumTemplateArgs; ++i)
Sebastian Redlc3632732010-10-05 15:59:54 +00001826 ArgInfo.addArgument(ReadTemplateArgumentLoc(F, Record, Idx));
Argyrios Kyrtzidis663e3802010-07-08 13:09:47 +00001827 }
Abramo Bagnara7cc58b42011-10-05 07:56:41 +00001828
1829 bool HadMultipleCandidates = Record[Idx++];
1830
Douglas Gregor409448c2011-07-21 22:35:25 +00001831 NamedDecl *FoundD = ReadDeclAs<NamedDecl>(F, Record, Idx);
Argyrios Kyrtzidis663e3802010-07-08 13:09:47 +00001832 AccessSpecifier AS = (AccessSpecifier)Record[Idx++];
1833 DeclAccessPair FoundDecl = DeclAccessPair::make(FoundD, AS);
1834
Douglas Gregor393f2492011-07-22 00:38:23 +00001835 QualType T = readType(F, Record, Idx);
John McCallf89e55a2010-11-18 06:31:45 +00001836 ExprValueKind VK = static_cast<ExprValueKind>(Record[Idx++]);
1837 ExprObjectKind OK = static_cast<ExprObjectKind>(Record[Idx++]);
Argyrios Kyrtzidis663e3802010-07-08 13:09:47 +00001838 Expr *Base = ReadSubExpr();
Douglas Gregor409448c2011-07-21 22:35:25 +00001839 ValueDecl *MemberD = ReadDeclAs<ValueDecl>(F, Record, Idx);
Sebastian Redlc3632732010-10-05 15:59:54 +00001840 SourceLocation MemberLoc = ReadSourceLocation(F, Record, Idx);
Abramo Bagnara25777432010-08-11 22:01:17 +00001841 DeclarationNameInfo MemberNameInfo(MemberD->getDeclName(), MemberLoc);
Argyrios Kyrtzidis663e3802010-07-08 13:09:47 +00001842 bool IsArrow = Record[Idx++];
1843
Douglas Gregor35942772011-09-09 21:34:22 +00001844 S = MemberExpr::Create(Context, Base, IsArrow, QualifierLoc,
Abramo Bagnarae4b92762012-01-27 09:46:47 +00001845 TemplateKWLoc, MemberD, FoundDecl, MemberNameInfo,
1846 HasTemplateKWAndArgsInfo ? &ArgInfo : 0,
1847 T, VK, OK);
Argyrios Kyrtzidis40451072010-10-15 18:21:24 +00001848 ReadDeclarationNameLoc(F, cast<MemberExpr>(S)->MemberDNLoc,
1849 MemberD->getDeclName(), Record, Idx);
Abramo Bagnara7cc58b42011-10-05 07:56:41 +00001850 if (HadMultipleCandidates)
1851 cast<MemberExpr>(S)->setHadMultipleCandidates(true);
Chris Lattner4c6f9522009-04-27 05:14:47 +00001852 break;
Argyrios Kyrtzidis663e3802010-07-08 13:09:47 +00001853 }
Chris Lattner4c6f9522009-04-27 05:14:47 +00001854
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001855 case EXPR_BINARY_OPERATOR:
Chris Lattner4c6f9522009-04-27 05:14:47 +00001856 S = new (Context) BinaryOperator(Empty);
1857 break;
1858
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001859 case EXPR_COMPOUND_ASSIGN_OPERATOR:
Chris Lattner4c6f9522009-04-27 05:14:47 +00001860 S = new (Context) CompoundAssignOperator(Empty);
1861 break;
1862
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001863 case EXPR_CONDITIONAL_OPERATOR:
Chris Lattner4c6f9522009-04-27 05:14:47 +00001864 S = new (Context) ConditionalOperator(Empty);
1865 break;
1866
John McCall56ca35d2011-02-17 10:25:35 +00001867 case EXPR_BINARY_CONDITIONAL_OPERATOR:
1868 S = new (Context) BinaryConditionalOperator(Empty);
1869 break;
1870
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001871 case EXPR_IMPLICIT_CAST:
Douglas Gregor35942772011-09-09 21:34:22 +00001872 S = ImplicitCastExpr::CreateEmpty(Context,
Sebastian Redl60adf4a2010-08-18 23:56:52 +00001873 /*PathSize*/ Record[ASTStmtReader::NumExprFields]);
Chris Lattner4c6f9522009-04-27 05:14:47 +00001874 break;
1875
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001876 case EXPR_CSTYLE_CAST:
Douglas Gregor35942772011-09-09 21:34:22 +00001877 S = CStyleCastExpr::CreateEmpty(Context,
Sebastian Redl60adf4a2010-08-18 23:56:52 +00001878 /*PathSize*/ Record[ASTStmtReader::NumExprFields]);
Chris Lattner4c6f9522009-04-27 05:14:47 +00001879 break;
1880
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001881 case EXPR_COMPOUND_LITERAL:
Chris Lattner4c6f9522009-04-27 05:14:47 +00001882 S = new (Context) CompoundLiteralExpr(Empty);
1883 break;
1884
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001885 case EXPR_EXT_VECTOR_ELEMENT:
Chris Lattner4c6f9522009-04-27 05:14:47 +00001886 S = new (Context) ExtVectorElementExpr(Empty);
1887 break;
1888
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001889 case EXPR_INIT_LIST:
Argyrios Kyrtzidis2a82ca22012-11-28 03:56:16 +00001890 S = new (Context) InitListExpr(Empty);
Chris Lattner4c6f9522009-04-27 05:14:47 +00001891 break;
1892
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001893 case EXPR_DESIGNATED_INIT:
Douglas Gregor35942772011-09-09 21:34:22 +00001894 S = DesignatedInitExpr::CreateEmpty(Context,
Sebastian Redl60adf4a2010-08-18 23:56:52 +00001895 Record[ASTStmtReader::NumExprFields] - 1);
Mike Stump1eb44332009-09-09 15:08:12 +00001896
Chris Lattner4c6f9522009-04-27 05:14:47 +00001897 break;
1898
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001899 case EXPR_IMPLICIT_VALUE_INIT:
Chris Lattner4c6f9522009-04-27 05:14:47 +00001900 S = new (Context) ImplicitValueInitExpr(Empty);
1901 break;
1902
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001903 case EXPR_VA_ARG:
Chris Lattner4c6f9522009-04-27 05:14:47 +00001904 S = new (Context) VAArgExpr(Empty);
1905 break;
1906
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001907 case EXPR_ADDR_LABEL:
Chris Lattner4c6f9522009-04-27 05:14:47 +00001908 S = new (Context) AddrLabelExpr(Empty);
1909 break;
1910
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001911 case EXPR_STMT:
Chris Lattner4c6f9522009-04-27 05:14:47 +00001912 S = new (Context) StmtExpr(Empty);
1913 break;
1914
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001915 case EXPR_CHOOSE:
Chris Lattner4c6f9522009-04-27 05:14:47 +00001916 S = new (Context) ChooseExpr(Empty);
1917 break;
1918
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001919 case EXPR_GNU_NULL:
Chris Lattner4c6f9522009-04-27 05:14:47 +00001920 S = new (Context) GNUNullExpr(Empty);
1921 break;
1922
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001923 case EXPR_SHUFFLE_VECTOR:
Chris Lattner4c6f9522009-04-27 05:14:47 +00001924 S = new (Context) ShuffleVectorExpr(Empty);
1925 break;
Mike Stump1eb44332009-09-09 15:08:12 +00001926
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001927 case EXPR_BLOCK:
Chris Lattner4c6f9522009-04-27 05:14:47 +00001928 S = new (Context) BlockExpr(Empty);
1929 break;
1930
Peter Collingbournef111d932011-04-15 00:35:48 +00001931 case EXPR_GENERIC_SELECTION:
1932 S = new (Context) GenericSelectionExpr(Empty);
1933 break;
1934
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001935 case EXPR_OBJC_STRING_LITERAL:
Chris Lattner4c6f9522009-04-27 05:14:47 +00001936 S = new (Context) ObjCStringLiteral(Empty);
1937 break;
Patrick Beardeb382ec2012-04-19 00:25:12 +00001938 case EXPR_OBJC_BOXED_EXPRESSION:
1939 S = new (Context) ObjCBoxedExpr(Empty);
Ted Kremenekebcb57a2012-03-06 20:05:56 +00001940 break;
1941 case EXPR_OBJC_ARRAY_LITERAL:
1942 S = ObjCArrayLiteral::CreateEmpty(Context,
1943 Record[ASTStmtReader::NumExprFields]);
1944 break;
1945 case EXPR_OBJC_DICTIONARY_LITERAL:
1946 S = ObjCDictionaryLiteral::CreateEmpty(Context,
1947 Record[ASTStmtReader::NumExprFields],
1948 Record[ASTStmtReader::NumExprFields + 1]);
1949 break;
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001950 case EXPR_OBJC_ENCODE:
Chris Lattner4c6f9522009-04-27 05:14:47 +00001951 S = new (Context) ObjCEncodeExpr(Empty);
1952 break;
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001953 case EXPR_OBJC_SELECTOR_EXPR:
Chris Lattner4c6f9522009-04-27 05:14:47 +00001954 S = new (Context) ObjCSelectorExpr(Empty);
1955 break;
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001956 case EXPR_OBJC_PROTOCOL_EXPR:
Chris Lattner4c6f9522009-04-27 05:14:47 +00001957 S = new (Context) ObjCProtocolExpr(Empty);
1958 break;
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001959 case EXPR_OBJC_IVAR_REF_EXPR:
Chris Lattner4c6f9522009-04-27 05:14:47 +00001960 S = new (Context) ObjCIvarRefExpr(Empty);
1961 break;
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001962 case EXPR_OBJC_PROPERTY_REF_EXPR:
Chris Lattner4c6f9522009-04-27 05:14:47 +00001963 S = new (Context) ObjCPropertyRefExpr(Empty);
1964 break;
Ted Kremenekebcb57a2012-03-06 20:05:56 +00001965 case EXPR_OBJC_SUBSCRIPT_REF_EXPR:
1966 S = new (Context) ObjCSubscriptRefExpr(Empty);
1967 break;
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001968 case EXPR_OBJC_KVC_REF_EXPR:
John McCall12f78a62010-12-02 01:19:52 +00001969 llvm_unreachable("mismatching AST file");
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001970 case EXPR_OBJC_MESSAGE_EXPR:
Douglas Gregor35942772011-09-09 21:34:22 +00001971 S = ObjCMessageExpr::CreateEmpty(Context,
Argyrios Kyrtzidis20718082011-10-03 06:36:51 +00001972 Record[ASTStmtReader::NumExprFields],
1973 Record[ASTStmtReader::NumExprFields + 1]);
Chris Lattner4c6f9522009-04-27 05:14:47 +00001974 break;
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001975 case EXPR_OBJC_ISA:
Steve Narofff242b1b2009-07-24 17:54:45 +00001976 S = new (Context) ObjCIsaExpr(Empty);
1977 break;
John McCallf85e1932011-06-15 23:02:42 +00001978 case EXPR_OBJC_INDIRECT_COPY_RESTORE:
1979 S = new (Context) ObjCIndirectCopyRestoreExpr(Empty);
1980 break;
1981 case EXPR_OBJC_BRIDGED_CAST:
1982 S = new (Context) ObjCBridgedCastExpr(Empty);
1983 break;
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001984 case STMT_OBJC_FOR_COLLECTION:
Chris Lattner4c6f9522009-04-27 05:14:47 +00001985 S = new (Context) ObjCForCollectionStmt(Empty);
1986 break;
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001987 case STMT_OBJC_CATCH:
Chris Lattner4c6f9522009-04-27 05:14:47 +00001988 S = new (Context) ObjCAtCatchStmt(Empty);
1989 break;
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001990 case STMT_OBJC_FINALLY:
Chris Lattner4c6f9522009-04-27 05:14:47 +00001991 S = new (Context) ObjCAtFinallyStmt(Empty);
1992 break;
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001993 case STMT_OBJC_AT_TRY:
Douglas Gregor35942772011-09-09 21:34:22 +00001994 S = ObjCAtTryStmt::CreateEmpty(Context,
Sebastian Redl60adf4a2010-08-18 23:56:52 +00001995 Record[ASTStmtReader::NumStmtFields],
1996 Record[ASTStmtReader::NumStmtFields + 1]);
Chris Lattner4c6f9522009-04-27 05:14:47 +00001997 break;
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001998 case STMT_OBJC_AT_SYNCHRONIZED:
Chris Lattner4c6f9522009-04-27 05:14:47 +00001999 S = new (Context) ObjCAtSynchronizedStmt(Empty);
2000 break;
Sebastian Redl8538e8d2010-08-18 23:57:32 +00002001 case STMT_OBJC_AT_THROW:
Chris Lattner4c6f9522009-04-27 05:14:47 +00002002 S = new (Context) ObjCAtThrowStmt(Empty);
2003 break;
John McCallf85e1932011-06-15 23:02:42 +00002004 case STMT_OBJC_AUTORELEASE_POOL:
2005 S = new (Context) ObjCAutoreleasePoolStmt(Empty);
2006 break;
Ted Kremenekebcb57a2012-03-06 20:05:56 +00002007 case EXPR_OBJC_BOOL_LITERAL:
2008 S = new (Context) ObjCBoolLiteralExpr(Empty);
2009 break;
John McCall7110fd62011-07-15 07:00:14 +00002010 case STMT_SEH_EXCEPT:
2011 S = new (Context) SEHExceptStmt(Empty);
2012 break;
2013 case STMT_SEH_FINALLY:
2014 S = new (Context) SEHFinallyStmt(Empty);
2015 break;
2016 case STMT_SEH_TRY:
2017 S = new (Context) SEHTryStmt(Empty);
2018 break;
Sebastian Redl8538e8d2010-08-18 23:57:32 +00002019 case STMT_CXX_CATCH:
Argyrios Kyrtzidis7cb45e32010-07-22 16:03:56 +00002020 S = new (Context) CXXCatchStmt(Empty);
2021 break;
2022
Sebastian Redl8538e8d2010-08-18 23:57:32 +00002023 case STMT_CXX_TRY:
Douglas Gregor35942772011-09-09 21:34:22 +00002024 S = CXXTryStmt::Create(Context, Empty,
Sebastian Redl60adf4a2010-08-18 23:56:52 +00002025 /*NumHandlers=*/Record[ASTStmtReader::NumStmtFields]);
Argyrios Kyrtzidis7cb45e32010-07-22 16:03:56 +00002026 break;
2027
Richard Smithad762fc2011-04-14 22:09:26 +00002028 case STMT_CXX_FOR_RANGE:
2029 S = new (Context) CXXForRangeStmt(Empty);
2030 break;
2031
Douglas Gregorba0513d2011-10-25 01:33:02 +00002032 case STMT_MS_DEPENDENT_EXISTS:
2033 S = new (Context) MSDependentExistsStmt(SourceLocation(), true,
2034 NestedNameSpecifierLoc(),
2035 DeclarationNameInfo(),
2036 0);
2037 break;
2038
Sebastian Redl8538e8d2010-08-18 23:57:32 +00002039 case EXPR_CXX_OPERATOR_CALL:
Douglas Gregor35942772011-09-09 21:34:22 +00002040 S = new (Context) CXXOperatorCallExpr(Context, Empty);
Argyrios Kyrtzidisba0a9002009-07-14 03:19:21 +00002041 break;
Chris Lattner1817bd42010-05-09 05:36:05 +00002042
Sebastian Redl8538e8d2010-08-18 23:57:32 +00002043 case EXPR_CXX_MEMBER_CALL:
Douglas Gregor35942772011-09-09 21:34:22 +00002044 S = new (Context) CXXMemberCallExpr(Context, Empty);
Chris Lattner1817bd42010-05-09 05:36:05 +00002045 break;
Douglas Gregor39da0b82009-09-09 23:08:42 +00002046
Sebastian Redl8538e8d2010-08-18 23:57:32 +00002047 case EXPR_CXX_CONSTRUCT:
Argyrios Kyrtzidis6d00c132010-07-10 11:46:15 +00002048 S = new (Context) CXXConstructExpr(Empty);
2049 break;
2050
Sebastian Redl8538e8d2010-08-18 23:57:32 +00002051 case EXPR_CXX_TEMPORARY_OBJECT:
Argyrios Kyrtzidis6d00c132010-07-10 11:46:15 +00002052 S = new (Context) CXXTemporaryObjectExpr(Empty);
Douglas Gregor39da0b82009-09-09 23:08:42 +00002053 break;
Sam Weinigce757a72010-01-16 21:21:01 +00002054
Sebastian Redl8538e8d2010-08-18 23:57:32 +00002055 case EXPR_CXX_STATIC_CAST:
Douglas Gregor35942772011-09-09 21:34:22 +00002056 S = CXXStaticCastExpr::CreateEmpty(Context,
Sebastian Redl60adf4a2010-08-18 23:56:52 +00002057 /*PathSize*/ Record[ASTStmtReader::NumExprFields]);
Sam Weinigce757a72010-01-16 21:21:01 +00002058 break;
2059
Sebastian Redl8538e8d2010-08-18 23:57:32 +00002060 case EXPR_CXX_DYNAMIC_CAST:
Douglas Gregor35942772011-09-09 21:34:22 +00002061 S = CXXDynamicCastExpr::CreateEmpty(Context,
Sebastian Redl60adf4a2010-08-18 23:56:52 +00002062 /*PathSize*/ Record[ASTStmtReader::NumExprFields]);
Sam Weinigce757a72010-01-16 21:21:01 +00002063 break;
2064
Sebastian Redl8538e8d2010-08-18 23:57:32 +00002065 case EXPR_CXX_REINTERPRET_CAST:
Douglas Gregor35942772011-09-09 21:34:22 +00002066 S = CXXReinterpretCastExpr::CreateEmpty(Context,
Sebastian Redl60adf4a2010-08-18 23:56:52 +00002067 /*PathSize*/ Record[ASTStmtReader::NumExprFields]);
Sam Weinigce757a72010-01-16 21:21:01 +00002068 break;
2069
Sebastian Redl8538e8d2010-08-18 23:57:32 +00002070 case EXPR_CXX_CONST_CAST:
Douglas Gregor35942772011-09-09 21:34:22 +00002071 S = CXXConstCastExpr::CreateEmpty(Context);
Sam Weinigce757a72010-01-16 21:21:01 +00002072 break;
2073
Sebastian Redl8538e8d2010-08-18 23:57:32 +00002074 case EXPR_CXX_FUNCTIONAL_CAST:
Douglas Gregor35942772011-09-09 21:34:22 +00002075 S = CXXFunctionalCastExpr::CreateEmpty(Context,
Sebastian Redl60adf4a2010-08-18 23:56:52 +00002076 /*PathSize*/ Record[ASTStmtReader::NumExprFields]);
Sam Weinigce757a72010-01-16 21:21:01 +00002077 break;
2078
Richard Smith9fcce652012-03-07 08:35:16 +00002079 case EXPR_USER_DEFINED_LITERAL:
2080 S = new (Context) UserDefinedLiteral(Context, Empty);
2081 break;
2082
Sebastian Redl8538e8d2010-08-18 23:57:32 +00002083 case EXPR_CXX_BOOL_LITERAL:
Sam Weinigeb7f9612010-02-07 06:32:43 +00002084 S = new (Context) CXXBoolLiteralExpr(Empty);
2085 break;
Sam Weinigce757a72010-01-16 21:21:01 +00002086
Sebastian Redl8538e8d2010-08-18 23:57:32 +00002087 case EXPR_CXX_NULL_PTR_LITERAL:
Sam Weinigeb7f9612010-02-07 06:32:43 +00002088 S = new (Context) CXXNullPtrLiteralExpr(Empty);
2089 break;
Sebastian Redl8538e8d2010-08-18 23:57:32 +00002090 case EXPR_CXX_TYPEID_EXPR:
Chris Lattner14ab24f2010-05-09 06:03:39 +00002091 S = new (Context) CXXTypeidExpr(Empty, true);
2092 break;
Sebastian Redl8538e8d2010-08-18 23:57:32 +00002093 case EXPR_CXX_TYPEID_TYPE:
Chris Lattner14ab24f2010-05-09 06:03:39 +00002094 S = new (Context) CXXTypeidExpr(Empty, false);
2095 break;
Francois Pichet01b7c302010-09-08 12:20:18 +00002096 case EXPR_CXX_UUIDOF_EXPR:
2097 S = new (Context) CXXUuidofExpr(Empty, true);
2098 break;
John McCall76da55d2013-04-16 07:28:30 +00002099 case EXPR_CXX_PROPERTY_REF_EXPR:
2100 S = new (Context) MSPropertyRefExpr(Empty);
2101 break;
Francois Pichet01b7c302010-09-08 12:20:18 +00002102 case EXPR_CXX_UUIDOF_TYPE:
2103 S = new (Context) CXXUuidofExpr(Empty, false);
2104 break;
Sebastian Redl8538e8d2010-08-18 23:57:32 +00002105 case EXPR_CXX_THIS:
Chris Lattner2fbdfcd2010-05-09 06:15:05 +00002106 S = new (Context) CXXThisExpr(Empty);
2107 break;
Sebastian Redl8538e8d2010-08-18 23:57:32 +00002108 case EXPR_CXX_THROW:
Chris Lattner2fbdfcd2010-05-09 06:15:05 +00002109 S = new (Context) CXXThrowExpr(Empty);
2110 break;
Sebastian Redl8538e8d2010-08-18 23:57:32 +00002111 case EXPR_CXX_DEFAULT_ARG: {
Sebastian Redl60adf4a2010-08-18 23:56:52 +00002112 bool HasOtherExprStored = Record[ASTStmtReader::NumExprFields];
Argyrios Kyrtzidis8a507332010-07-02 23:30:15 +00002113 if (HasOtherExprStored) {
2114 Expr *SubExpr = ReadSubExpr();
Douglas Gregor35942772011-09-09 21:34:22 +00002115 S = CXXDefaultArgExpr::Create(Context, SourceLocation(), 0, SubExpr);
Argyrios Kyrtzidis8a507332010-07-02 23:30:15 +00002116 } else
2117 S = new (Context) CXXDefaultArgExpr(Empty);
Chris Lattner030854b2010-05-09 06:40:08 +00002118 break;
Argyrios Kyrtzidis8a507332010-07-02 23:30:15 +00002119 }
Richard Smithc3bf52c2013-04-20 22:23:05 +00002120 case EXPR_CXX_DEFAULT_INIT:
2121 S = new (Context) CXXDefaultInitExpr(Empty);
2122 break;
Sebastian Redl8538e8d2010-08-18 23:57:32 +00002123 case EXPR_CXX_BIND_TEMPORARY:
Chris Lattnerd2598362010-05-10 00:25:06 +00002124 S = new (Context) CXXBindTemporaryExpr(Empty);
2125 break;
Douglas Gregore2ca6d42010-09-02 21:50:02 +00002126
Sebastian Redl8538e8d2010-08-18 23:57:32 +00002127 case EXPR_CXX_SCALAR_VALUE_INIT:
Douglas Gregored8abf12010-07-08 06:14:04 +00002128 S = new (Context) CXXScalarValueInitExpr(Empty);
Chris Lattner59218632010-05-10 01:22:27 +00002129 break;
Sebastian Redl8538e8d2010-08-18 23:57:32 +00002130 case EXPR_CXX_NEW:
Chris Lattner59218632010-05-10 01:22:27 +00002131 S = new (Context) CXXNewExpr(Empty);
2132 break;
Sebastian Redl8538e8d2010-08-18 23:57:32 +00002133 case EXPR_CXX_DELETE:
Argyrios Kyrtzidis95fc98c2010-06-22 17:07:59 +00002134 S = new (Context) CXXDeleteExpr(Empty);
2135 break;
Sebastian Redl8538e8d2010-08-18 23:57:32 +00002136 case EXPR_CXX_PSEUDO_DESTRUCTOR:
Argyrios Kyrtzidisde4bd182010-06-28 09:32:03 +00002137 S = new (Context) CXXPseudoDestructorExpr(Empty);
2138 break;
Chris Lattner59218632010-05-10 01:22:27 +00002139
John McCall4765fa02010-12-06 08:20:24 +00002140 case EXPR_EXPR_WITH_CLEANUPS:
John McCall80ee6e82011-11-10 05:35:25 +00002141 S = ExprWithCleanups::Create(Context, Empty,
2142 Record[ASTStmtReader::NumExprFields]);
Chris Lattnerd2598362010-05-10 00:25:06 +00002143 break;
Argyrios Kyrtzidis8dfbd8b2010-06-24 08:57:31 +00002144
Sebastian Redl8538e8d2010-08-18 23:57:32 +00002145 case EXPR_CXX_DEPENDENT_SCOPE_MEMBER:
Douglas Gregor35942772011-09-09 21:34:22 +00002146 S = CXXDependentScopeMemberExpr::CreateEmpty(Context,
Abramo Bagnarae4b92762012-01-27 09:46:47 +00002147 /*HasTemplateKWAndArgsInfo=*/Record[ASTStmtReader::NumExprFields],
Douglas Gregordef03542011-02-04 12:01:24 +00002148 /*NumTemplateArgs=*/Record[ASTStmtReader::NumExprFields]
2149 ? Record[ASTStmtReader::NumExprFields + 1]
2150 : 0);
Argyrios Kyrtzidis8dfbd8b2010-06-24 08:57:31 +00002151 break;
2152
Sebastian Redl8538e8d2010-08-18 23:57:32 +00002153 case EXPR_CXX_DEPENDENT_SCOPE_DECL_REF:
Douglas Gregor35942772011-09-09 21:34:22 +00002154 S = DependentScopeDeclRefExpr::CreateEmpty(Context,
Abramo Bagnarae4b92762012-01-27 09:46:47 +00002155 /*HasTemplateKWAndArgsInfo=*/Record[ASTStmtReader::NumExprFields],
Douglas Gregordef03542011-02-04 12:01:24 +00002156 /*NumTemplateArgs=*/Record[ASTStmtReader::NumExprFields]
2157 ? Record[ASTStmtReader::NumExprFields + 1]
2158 : 0);
Argyrios Kyrtzidis12dffcd2010-06-28 09:31:56 +00002159 break;
2160
Sebastian Redl8538e8d2010-08-18 23:57:32 +00002161 case EXPR_CXX_UNRESOLVED_CONSTRUCT:
Douglas Gregor35942772011-09-09 21:34:22 +00002162 S = CXXUnresolvedConstructExpr::CreateEmpty(Context,
Sebastian Redl60adf4a2010-08-18 23:56:52 +00002163 /*NumArgs=*/Record[ASTStmtReader::NumExprFields]);
Argyrios Kyrtzidisa77eb082010-06-25 09:03:26 +00002164 break;
2165
Sebastian Redl8538e8d2010-08-18 23:57:32 +00002166 case EXPR_CXX_UNRESOLVED_MEMBER:
Douglas Gregor35942772011-09-09 21:34:22 +00002167 S = UnresolvedMemberExpr::CreateEmpty(Context,
Abramo Bagnarae4b92762012-01-27 09:46:47 +00002168 /*HasTemplateKWAndArgsInfo=*/Record[ASTStmtReader::NumExprFields],
Douglas Gregordef03542011-02-04 12:01:24 +00002169 /*NumTemplateArgs=*/Record[ASTStmtReader::NumExprFields]
2170 ? Record[ASTStmtReader::NumExprFields + 1]
2171 : 0);
Argyrios Kyrtzidis8dfbd8b2010-06-24 08:57:31 +00002172 break;
Argyrios Kyrtzidisbd65bb52010-06-25 09:03:34 +00002173
Sebastian Redl8538e8d2010-08-18 23:57:32 +00002174 case EXPR_CXX_UNRESOLVED_LOOKUP:
Douglas Gregor35942772011-09-09 21:34:22 +00002175 S = UnresolvedLookupExpr::CreateEmpty(Context,
Abramo Bagnarae4b92762012-01-27 09:46:47 +00002176 /*HasTemplateKWAndArgsInfo=*/Record[ASTStmtReader::NumExprFields],
Douglas Gregordef03542011-02-04 12:01:24 +00002177 /*NumTemplateArgs=*/Record[ASTStmtReader::NumExprFields]
2178 ? Record[ASTStmtReader::NumExprFields + 1]
2179 : 0);
Argyrios Kyrtzidisbd65bb52010-06-25 09:03:34 +00002180 break;
Argyrios Kyrtzidis6d00c132010-07-10 11:46:15 +00002181
Sebastian Redl8538e8d2010-08-18 23:57:32 +00002182 case EXPR_CXX_UNARY_TYPE_TRAIT:
Argyrios Kyrtzidis6d00c132010-07-10 11:46:15 +00002183 S = new (Context) UnaryTypeTraitExpr(Empty);
2184 break;
Sebastian Redl6b219d02010-09-10 20:55:54 +00002185
Francois Pichetf1872372010-12-08 22:35:30 +00002186 case EXPR_BINARY_TYPE_TRAIT:
Francois Pichet6ad6f282010-12-07 00:08:36 +00002187 S = new (Context) BinaryTypeTraitExpr(Empty);
2188 break;
2189
Douglas Gregor4ca8ac22012-02-24 07:38:34 +00002190 case EXPR_TYPE_TRAIT:
2191 S = TypeTraitExpr::CreateDeserialized(Context,
2192 Record[ASTStmtReader::NumExprFields]);
2193 break;
2194
John Wiegley21ff2e52011-04-28 00:16:57 +00002195 case EXPR_ARRAY_TYPE_TRAIT:
2196 S = new (Context) ArrayTypeTraitExpr(Empty);
2197 break;
2198
John Wiegley55262202011-04-25 06:54:41 +00002199 case EXPR_CXX_EXPRESSION_TRAIT:
2200 S = new (Context) ExpressionTraitExpr(Empty);
2201 break;
2202
Sebastian Redl6b219d02010-09-10 20:55:54 +00002203 case EXPR_CXX_NOEXCEPT:
2204 S = new (Context) CXXNoexceptExpr(Empty);
2205 break;
John McCall7cd7d1a2010-11-15 23:31:06 +00002206
Douglas Gregorbe230c32011-01-03 17:17:50 +00002207 case EXPR_PACK_EXPANSION:
2208 S = new (Context) PackExpansionExpr(Empty);
2209 break;
2210
Douglas Gregoree8aff02011-01-04 17:33:58 +00002211 case EXPR_SIZEOF_PACK:
2212 S = new (Context) SizeOfPackExpr(Empty);
2213 break;
2214
John McCall7110fd62011-07-15 07:00:14 +00002215 case EXPR_SUBST_NON_TYPE_TEMPLATE_PARM:
2216 S = new (Context) SubstNonTypeTemplateParmExpr(Empty);
2217 break;
2218
Douglas Gregorc7793c72011-01-15 01:15:58 +00002219 case EXPR_SUBST_NON_TYPE_TEMPLATE_PARM_PACK:
2220 S = new (Context) SubstNonTypeTemplateParmPackExpr(Empty);
2221 break;
Richard Smith9a4db032012-09-12 00:56:43 +00002222
2223 case EXPR_FUNCTION_PARM_PACK:
2224 S = FunctionParmPackExpr::CreateEmpty(Context,
2225 Record[ASTStmtReader::NumExprFields]);
2226 break;
Douglas Gregorc7793c72011-01-15 01:15:58 +00002227
Douglas Gregor03e80032011-06-21 17:03:29 +00002228 case EXPR_MATERIALIZE_TEMPORARY:
2229 S = new (Context) MaterializeTemporaryExpr(Empty);
2230 break;
2231
Argyrios Kyrtzidis8bc27822011-12-03 03:49:52 +00002232 case EXPR_OPAQUE_VALUE:
2233 S = new (Context) OpaqueValueExpr(Empty);
John McCall7cd7d1a2010-11-15 23:31:06 +00002234 break;
Peter Collingbournee08ce652011-02-09 21:07:24 +00002235
2236 case EXPR_CUDA_KERNEL_CALL:
Douglas Gregor35942772011-09-09 21:34:22 +00002237 S = new (Context) CUDAKernelCallExpr(Context, Empty);
Peter Collingbournee08ce652011-02-09 21:07:24 +00002238 break;
Tanya Lattner61eee0c2011-06-04 00:47:47 +00002239
2240 case EXPR_ASTYPE:
2241 S = new (Context) AsTypeExpr(Empty);
2242 break;
Eli Friedman276b0612011-10-11 02:20:01 +00002243
John McCall4b9c2d22011-11-06 09:01:30 +00002244 case EXPR_PSEUDO_OBJECT: {
2245 unsigned numSemanticExprs = Record[ASTStmtReader::NumExprFields];
2246 S = PseudoObjectExpr::Create(Context, Empty, numSemanticExprs);
2247 break;
2248 }
2249
Eli Friedman276b0612011-10-11 02:20:01 +00002250 case EXPR_ATOMIC:
2251 S = new (Context) AtomicExpr(Empty);
2252 break;
Douglas Gregor9d36f5d2012-02-14 17:54:36 +00002253
2254 case EXPR_LAMBDA: {
2255 unsigned NumCaptures = Record[ASTStmtReader::NumExprFields];
2256 unsigned NumArrayIndexVars = Record[ASTStmtReader::NumExprFields + 1];
2257 S = LambdaExpr::CreateDeserialized(Context, NumCaptures,
2258 NumArrayIndexVars);
2259 break;
2260 }
Chris Lattner4c6f9522009-04-27 05:14:47 +00002261 }
Argyrios Kyrtzidis6d00c132010-07-10 11:46:15 +00002262
Chris Lattner4c6f9522009-04-27 05:14:47 +00002263 // We hit a STMT_STOP, so we're done with this expression.
2264 if (Finished)
2265 break;
2266
2267 ++NumStatementsRead;
2268
Argyrios Kyrtzidise6f08682011-10-21 23:02:28 +00002269 if (S && !IsStmtReference) {
Argyrios Kyrtzidis919e6932010-06-28 22:28:35 +00002270 Reader.Visit(S);
Argyrios Kyrtzidise6f08682011-10-21 23:02:28 +00002271 StmtEntries[Cursor.GetCurrentBitNo()] = S;
2272 }
2273
Chris Lattner4c6f9522009-04-27 05:14:47 +00002274
2275 assert(Idx == Record.size() && "Invalid deserialization of statement");
2276 StmtStack.push_back(S);
2277 }
Chris Lattnerb3ce3572013-01-20 02:38:54 +00002278Done:
Argyrios Kyrtzidis919e6932010-06-28 22:28:35 +00002279 assert(StmtStack.size() > PrevNumStmts && "Read too many sub stmts!");
2280 assert(StmtStack.size() == PrevNumStmts + 1 && "Extra expressions on stack!");
Argyrios Kyrtzidis919e6932010-06-28 22:28:35 +00002281 return StmtStack.pop_back_val();
Chris Lattner4c6f9522009-04-27 05:14:47 +00002282}