blob: 6159916c8253698a7e0012901020bc21c18c82f6 [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
Sebastian Redl60adf4a2010-08-18 23:56:52 +0000327void ASTStmtReader::VisitExpr(Expr *E) {
Chris Lattner4c6f9522009-04-27 05:14:47 +0000328 VisitStmt(E);
Douglas Gregor393f2492011-07-22 00:38:23 +0000329 E->setType(Reader.readType(F, Record, Idx));
Chris Lattner4c6f9522009-04-27 05:14:47 +0000330 E->setTypeDependent(Record[Idx++]);
331 E->setValueDependent(Record[Idx++]);
Douglas Gregor561f8122011-07-01 01:22:09 +0000332 E->setInstantiationDependent(Record[Idx++]);
Douglas Gregord0937222010-12-13 22:49:22 +0000333 E->ExprBits.ContainsUnexpandedParameterPack = Record[Idx++];
John McCallf89e55a2010-11-18 06:31:45 +0000334 E->setValueKind(static_cast<ExprValueKind>(Record[Idx++]));
335 E->setObjectKind(static_cast<ExprObjectKind>(Record[Idx++]));
Chris Lattner4c6f9522009-04-27 05:14:47 +0000336 assert(Idx == NumExprFields && "Incorrect expression field count");
Chris Lattner4c6f9522009-04-27 05:14:47 +0000337}
338
Sebastian Redl60adf4a2010-08-18 23:56:52 +0000339void ASTStmtReader::VisitPredefinedExpr(PredefinedExpr *E) {
Chris Lattner4c6f9522009-04-27 05:14:47 +0000340 VisitExpr(E);
Sebastian Redlc3632732010-10-05 15:59:54 +0000341 E->setLocation(ReadSourceLocation(Record, Idx));
Chris Lattner4c6f9522009-04-27 05:14:47 +0000342 E->setIdentType((PredefinedExpr::IdentType)Record[Idx++]);
Chris Lattner4c6f9522009-04-27 05:14:47 +0000343}
344
Sebastian Redl60adf4a2010-08-18 23:56:52 +0000345void ASTStmtReader::VisitDeclRefExpr(DeclRefExpr *E) {
Chris Lattner4c6f9522009-04-27 05:14:47 +0000346 VisitExpr(E);
Argyrios Kyrtzidis663e3802010-07-08 13:09:47 +0000347
Chandler Carruthcb66cff2011-05-01 21:29:53 +0000348 E->DeclRefExprBits.HasQualifier = Record[Idx++];
Chandler Carruth3aa81402011-05-01 23:48:14 +0000349 E->DeclRefExprBits.HasFoundDecl = Record[Idx++];
Abramo Bagnarae4b92762012-01-27 09:46:47 +0000350 E->DeclRefExprBits.HasTemplateKWAndArgsInfo = Record[Idx++];
Abramo Bagnara7cc58b42011-10-05 07:56:41 +0000351 E->DeclRefExprBits.HadMultipleCandidates = Record[Idx++];
John McCallf4b88a42012-03-10 09:33:50 +0000352 E->DeclRefExprBits.RefersToEnclosingLocal = Record[Idx++];
Anders Carlssonb0ca1372011-03-06 18:19:42 +0000353 unsigned NumTemplateArgs = 0;
Abramo Bagnarae4b92762012-01-27 09:46:47 +0000354 if (E->hasTemplateKWAndArgsInfo())
Anders Carlssonb0ca1372011-03-06 18:19:42 +0000355 NumTemplateArgs = Record[Idx++];
356
Chandler Carruthcb66cff2011-05-01 21:29:53 +0000357 if (E->hasQualifier())
Chandler Carruth6857c3e2011-05-01 22:14:37 +0000358 E->getInternalQualifierLoc()
Douglas Gregor40d96a62011-02-28 21:54:11 +0000359 = Reader.ReadNestedNameSpecifierLoc(F, Record, Idx);
Argyrios Kyrtzidis663e3802010-07-08 13:09:47 +0000360
Chandler Carruth3aa81402011-05-01 23:48:14 +0000361 if (E->hasFoundDecl())
Douglas Gregor409448c2011-07-21 22:35:25 +0000362 E->getInternalFoundDecl() = ReadDeclAs<NamedDecl>(Record, Idx);
Chandler Carruth3aa81402011-05-01 23:48:14 +0000363
Abramo Bagnarae4b92762012-01-27 09:46:47 +0000364 if (E->hasTemplateKWAndArgsInfo())
365 ReadTemplateKWAndArgsInfo(*E->getTemplateKWAndArgsInfo(),
366 NumTemplateArgs);
Argyrios Kyrtzidis663e3802010-07-08 13:09:47 +0000367
Douglas Gregor409448c2011-07-21 22:35:25 +0000368 E->setDecl(ReadDeclAs<ValueDecl>(Record, Idx));
Sebastian Redlc3632732010-10-05 15:59:54 +0000369 E->setLocation(ReadSourceLocation(Record, Idx));
Argyrios Kyrtzidis40451072010-10-15 18:21:24 +0000370 ReadDeclarationNameLoc(E->DNLoc, E->getDecl()->getDeclName(), Record, Idx);
Chris Lattner4c6f9522009-04-27 05:14:47 +0000371}
372
Sebastian Redl60adf4a2010-08-18 23:56:52 +0000373void ASTStmtReader::VisitIntegerLiteral(IntegerLiteral *E) {
Chris Lattner4c6f9522009-04-27 05:14:47 +0000374 VisitExpr(E);
Sebastian Redlc3632732010-10-05 15:59:54 +0000375 E->setLocation(ReadSourceLocation(Record, Idx));
Douglas Gregor35942772011-09-09 21:34:22 +0000376 E->setValue(Reader.getContext(), Reader.ReadAPInt(Record, Idx));
Chris Lattner4c6f9522009-04-27 05:14:47 +0000377}
378
Sebastian Redl60adf4a2010-08-18 23:56:52 +0000379void ASTStmtReader::VisitFloatingLiteral(FloatingLiteral *E) {
Chris Lattner4c6f9522009-04-27 05:14:47 +0000380 VisitExpr(E);
Tim Northover9ec55f22013-01-22 09:46:51 +0000381 E->setRawSemantics(static_cast<Stmt::APFloatSemantics>(Record[Idx++]));
Chris Lattner4c6f9522009-04-27 05:14:47 +0000382 E->setExact(Record[Idx++]);
Tim Northover9ec55f22013-01-22 09:46:51 +0000383 E->setValue(Reader.getContext(),
384 Reader.ReadAPFloat(Record, E->getSemantics(), Idx));
Sebastian Redlc3632732010-10-05 15:59:54 +0000385 E->setLocation(ReadSourceLocation(Record, Idx));
Chris Lattner4c6f9522009-04-27 05:14:47 +0000386}
387
Sebastian Redl60adf4a2010-08-18 23:56:52 +0000388void ASTStmtReader::VisitImaginaryLiteral(ImaginaryLiteral *E) {
Chris Lattner4c6f9522009-04-27 05:14:47 +0000389 VisitExpr(E);
Argyrios Kyrtzidisd98a2ab2010-06-29 22:46:25 +0000390 E->setSubExpr(Reader.ReadSubExpr());
Chris Lattner4c6f9522009-04-27 05:14:47 +0000391}
392
Sebastian Redl60adf4a2010-08-18 23:56:52 +0000393void ASTStmtReader::VisitStringLiteral(StringLiteral *E) {
Chris Lattner4c6f9522009-04-27 05:14:47 +0000394 VisitExpr(E);
395 unsigned Len = Record[Idx++];
Mike Stump1eb44332009-09-09 15:08:12 +0000396 assert(Record[Idx] == E->getNumConcatenated() &&
Chris Lattner4c6f9522009-04-27 05:14:47 +0000397 "Wrong number of concatenated tokens!");
398 ++Idx;
Eli Friedman64f45a22011-11-01 02:23:42 +0000399 StringLiteral::StringKind kind =
400 static_cast<StringLiteral::StringKind>(Record[Idx++]);
401 bool isPascal = Record[Idx++];
Chris Lattner4c6f9522009-04-27 05:14:47 +0000402
Mike Stump1eb44332009-09-09 15:08:12 +0000403 // Read string data
Dylan Noblesmithf7ccbad2012-02-05 02:13:05 +0000404 SmallString<16> Str(&Record[Idx], &Record[Idx] + Len);
Eli Friedman64f45a22011-11-01 02:23:42 +0000405 E->setString(Reader.getContext(), Str.str(), kind, isPascal);
Chris Lattner4c6f9522009-04-27 05:14:47 +0000406 Idx += Len;
407
408 // Read source locations
409 for (unsigned I = 0, N = E->getNumConcatenated(); I != N; ++I)
Sebastian Redlc3632732010-10-05 15:59:54 +0000410 E->setStrTokenLoc(I, ReadSourceLocation(Record, Idx));
Chris Lattner4c6f9522009-04-27 05:14:47 +0000411}
412
Sebastian Redl60adf4a2010-08-18 23:56:52 +0000413void ASTStmtReader::VisitCharacterLiteral(CharacterLiteral *E) {
Chris Lattner4c6f9522009-04-27 05:14:47 +0000414 VisitExpr(E);
415 E->setValue(Record[Idx++]);
Sebastian Redlc3632732010-10-05 15:59:54 +0000416 E->setLocation(ReadSourceLocation(Record, Idx));
Douglas Gregor5cee1192011-07-27 05:40:30 +0000417 E->setKind(static_cast<CharacterLiteral::CharacterKind>(Record[Idx++]));
Chris Lattner4c6f9522009-04-27 05:14:47 +0000418}
419
Sebastian Redl60adf4a2010-08-18 23:56:52 +0000420void ASTStmtReader::VisitParenExpr(ParenExpr *E) {
Chris Lattner4c6f9522009-04-27 05:14:47 +0000421 VisitExpr(E);
Sebastian Redlc3632732010-10-05 15:59:54 +0000422 E->setLParen(ReadSourceLocation(Record, Idx));
423 E->setRParen(ReadSourceLocation(Record, Idx));
Argyrios Kyrtzidisd98a2ab2010-06-29 22:46:25 +0000424 E->setSubExpr(Reader.ReadSubExpr());
Chris Lattner4c6f9522009-04-27 05:14:47 +0000425}
426
Sebastian Redl60adf4a2010-08-18 23:56:52 +0000427void ASTStmtReader::VisitParenListExpr(ParenListExpr *E) {
Argyrios Kyrtzidis37bdfe22010-06-30 08:49:18 +0000428 VisitExpr(E);
429 unsigned NumExprs = Record[Idx++];
Douglas Gregor35942772011-09-09 21:34:22 +0000430 E->Exprs = new (Reader.getContext()) Stmt*[NumExprs];
Argyrios Kyrtzidis37bdfe22010-06-30 08:49:18 +0000431 for (unsigned i = 0; i != NumExprs; ++i)
432 E->Exprs[i] = Reader.ReadSubStmt();
433 E->NumExprs = NumExprs;
Sebastian Redlc3632732010-10-05 15:59:54 +0000434 E->LParenLoc = ReadSourceLocation(Record, Idx);
435 E->RParenLoc = ReadSourceLocation(Record, Idx);
Argyrios Kyrtzidis37bdfe22010-06-30 08:49:18 +0000436}
437
Sebastian Redl60adf4a2010-08-18 23:56:52 +0000438void ASTStmtReader::VisitUnaryOperator(UnaryOperator *E) {
Chris Lattner4c6f9522009-04-27 05:14:47 +0000439 VisitExpr(E);
Argyrios Kyrtzidisd98a2ab2010-06-29 22:46:25 +0000440 E->setSubExpr(Reader.ReadSubExpr());
Chris Lattner4c6f9522009-04-27 05:14:47 +0000441 E->setOpcode((UnaryOperator::Opcode)Record[Idx++]);
Sebastian Redlc3632732010-10-05 15:59:54 +0000442 E->setOperatorLoc(ReadSourceLocation(Record, Idx));
Chris Lattner4c6f9522009-04-27 05:14:47 +0000443}
444
Sebastian Redl60adf4a2010-08-18 23:56:52 +0000445void ASTStmtReader::VisitOffsetOfExpr(OffsetOfExpr *E) {
Douglas Gregor8ecdb652010-04-28 22:16:22 +0000446 typedef OffsetOfExpr::OffsetOfNode Node;
447 VisitExpr(E);
448 assert(E->getNumComponents() == Record[Idx]);
449 ++Idx;
450 assert(E->getNumExpressions() == Record[Idx]);
451 ++Idx;
Sebastian Redlc3632732010-10-05 15:59:54 +0000452 E->setOperatorLoc(ReadSourceLocation(Record, Idx));
453 E->setRParenLoc(ReadSourceLocation(Record, Idx));
454 E->setTypeSourceInfo(GetTypeSourceInfo(Record, Idx));
Douglas Gregor8ecdb652010-04-28 22:16:22 +0000455 for (unsigned I = 0, N = E->getNumComponents(); I != N; ++I) {
456 Node::Kind Kind = static_cast<Node::Kind>(Record[Idx++]);
Sebastian Redlc3632732010-10-05 15:59:54 +0000457 SourceLocation Start = ReadSourceLocation(Record, Idx);
458 SourceLocation End = ReadSourceLocation(Record, Idx);
Douglas Gregor8ecdb652010-04-28 22:16:22 +0000459 switch (Kind) {
460 case Node::Array:
461 E->setComponent(I, Node(Start, Record[Idx++], End));
462 break;
463
464 case Node::Field:
Douglas Gregor409448c2011-07-21 22:35:25 +0000465 E->setComponent(I, Node(Start, ReadDeclAs<FieldDecl>(Record, Idx), End));
Douglas Gregor8ecdb652010-04-28 22:16:22 +0000466 break;
467
468 case Node::Identifier:
Douglas Gregor95eab172011-07-28 20:55:49 +0000469 E->setComponent(I,
470 Node(Start,
471 Reader.GetIdentifierInfo(F, Record, Idx),
472 End));
Douglas Gregor8ecdb652010-04-28 22:16:22 +0000473 break;
Douglas Gregorcc8a5d52010-04-29 00:18:15 +0000474
Argyrios Kyrtzidisafbf3122010-07-29 18:16:10 +0000475 case Node::Base: {
Douglas Gregor35942772011-09-09 21:34:22 +0000476 CXXBaseSpecifier *Base = new (Reader.getContext()) CXXBaseSpecifier();
Sebastian Redlc3632732010-10-05 15:59:54 +0000477 *Base = Reader.ReadCXXBaseSpecifier(F, Record, Idx);
Argyrios Kyrtzidisafbf3122010-07-29 18:16:10 +0000478 E->setComponent(I, Node(Base));
Douglas Gregorcc8a5d52010-04-29 00:18:15 +0000479 break;
Douglas Gregor8ecdb652010-04-28 22:16:22 +0000480 }
Argyrios Kyrtzidisafbf3122010-07-29 18:16:10 +0000481 }
Douglas Gregor8ecdb652010-04-28 22:16:22 +0000482 }
483
484 for (unsigned I = 0, N = E->getNumExpressions(); I != N; ++I)
Argyrios Kyrtzidisd98a2ab2010-06-29 22:46:25 +0000485 E->setIndexExpr(I, Reader.ReadSubExpr());
Douglas Gregor8ecdb652010-04-28 22:16:22 +0000486}
487
Peter Collingbournef4e3cfb2011-03-11 19:24:49 +0000488void ASTStmtReader::VisitUnaryExprOrTypeTraitExpr(UnaryExprOrTypeTraitExpr *E) {
Chris Lattner4c6f9522009-04-27 05:14:47 +0000489 VisitExpr(E);
Peter Collingbournef4e3cfb2011-03-11 19:24:49 +0000490 E->setKind(static_cast<UnaryExprOrTypeTrait>(Record[Idx++]));
Chris Lattner4c6f9522009-04-27 05:14:47 +0000491 if (Record[Idx] == 0) {
Argyrios Kyrtzidisd98a2ab2010-06-29 22:46:25 +0000492 E->setArgument(Reader.ReadSubExpr());
Chris Lattner4c6f9522009-04-27 05:14:47 +0000493 ++Idx;
494 } else {
Sebastian Redlc3632732010-10-05 15:59:54 +0000495 E->setArgument(GetTypeSourceInfo(Record, Idx));
Chris Lattner4c6f9522009-04-27 05:14:47 +0000496 }
Sebastian Redlc3632732010-10-05 15:59:54 +0000497 E->setOperatorLoc(ReadSourceLocation(Record, Idx));
498 E->setRParenLoc(ReadSourceLocation(Record, Idx));
Chris Lattner4c6f9522009-04-27 05:14:47 +0000499}
500
Sebastian Redl60adf4a2010-08-18 23:56:52 +0000501void ASTStmtReader::VisitArraySubscriptExpr(ArraySubscriptExpr *E) {
Chris Lattner4c6f9522009-04-27 05:14:47 +0000502 VisitExpr(E);
Argyrios Kyrtzidisd98a2ab2010-06-29 22:46:25 +0000503 E->setLHS(Reader.ReadSubExpr());
504 E->setRHS(Reader.ReadSubExpr());
Sebastian Redlc3632732010-10-05 15:59:54 +0000505 E->setRBracketLoc(ReadSourceLocation(Record, Idx));
Chris Lattner4c6f9522009-04-27 05:14:47 +0000506}
507
Sebastian Redl60adf4a2010-08-18 23:56:52 +0000508void ASTStmtReader::VisitCallExpr(CallExpr *E) {
Chris Lattner4c6f9522009-04-27 05:14:47 +0000509 VisitExpr(E);
Douglas Gregor35942772011-09-09 21:34:22 +0000510 E->setNumArgs(Reader.getContext(), Record[Idx++]);
Sebastian Redlc3632732010-10-05 15:59:54 +0000511 E->setRParenLoc(ReadSourceLocation(Record, Idx));
Argyrios Kyrtzidisd98a2ab2010-06-29 22:46:25 +0000512 E->setCallee(Reader.ReadSubExpr());
Chris Lattner4c6f9522009-04-27 05:14:47 +0000513 for (unsigned I = 0, N = E->getNumArgs(); I != N; ++I)
Argyrios Kyrtzidisd98a2ab2010-06-29 22:46:25 +0000514 E->setArg(I, Reader.ReadSubExpr());
Chris Lattner4c6f9522009-04-27 05:14:47 +0000515}
516
John McCall7110fd62011-07-15 07:00:14 +0000517void ASTStmtReader::VisitCXXMemberCallExpr(CXXMemberCallExpr *E) {
518 VisitCallExpr(E);
519}
520
Sebastian Redl60adf4a2010-08-18 23:56:52 +0000521void ASTStmtReader::VisitMemberExpr(MemberExpr *E) {
Argyrios Kyrtzidis663e3802010-07-08 13:09:47 +0000522 // Don't call VisitExpr, this is fully initialized at creation.
523 assert(E->getStmtClass() == Stmt::MemberExprClass &&
524 "It's a subclass, we must advance Idx!");
Chris Lattner4c6f9522009-04-27 05:14:47 +0000525}
526
Sebastian Redl60adf4a2010-08-18 23:56:52 +0000527void ASTStmtReader::VisitObjCIsaExpr(ObjCIsaExpr *E) {
Steve Narofff242b1b2009-07-24 17:54:45 +0000528 VisitExpr(E);
Argyrios Kyrtzidisd98a2ab2010-06-29 22:46:25 +0000529 E->setBase(Reader.ReadSubExpr());
Sebastian Redlc3632732010-10-05 15:59:54 +0000530 E->setIsaMemberLoc(ReadSourceLocation(Record, Idx));
Fariborz Jahanianec8deba2013-03-28 19:50:55 +0000531 E->setOpLoc(ReadSourceLocation(Record, Idx));
Steve Narofff242b1b2009-07-24 17:54:45 +0000532 E->setArrow(Record[Idx++]);
Steve Narofff242b1b2009-07-24 17:54:45 +0000533}
534
John McCallf85e1932011-06-15 23:02:42 +0000535void ASTStmtReader::
536VisitObjCIndirectCopyRestoreExpr(ObjCIndirectCopyRestoreExpr *E) {
537 VisitExpr(E);
538 E->Operand = Reader.ReadSubExpr();
539 E->setShouldCopy(Record[Idx++]);
540}
541
542void ASTStmtReader::VisitObjCBridgedCastExpr(ObjCBridgedCastExpr *E) {
543 VisitExplicitCastExpr(E);
544 E->LParenLoc = ReadSourceLocation(Record, Idx);
545 E->BridgeKeywordLoc = ReadSourceLocation(Record, Idx);
546 E->Kind = Record[Idx++];
547}
548
Sebastian Redl60adf4a2010-08-18 23:56:52 +0000549void ASTStmtReader::VisitCastExpr(CastExpr *E) {
Chris Lattner4c6f9522009-04-27 05:14:47 +0000550 VisitExpr(E);
John McCallf871d0c2010-08-07 06:22:56 +0000551 unsigned NumBaseSpecs = Record[Idx++];
552 assert(NumBaseSpecs == E->path_size());
Argyrios Kyrtzidisd98a2ab2010-06-29 22:46:25 +0000553 E->setSubExpr(Reader.ReadSubExpr());
Anders Carlssoncdef2b72009-07-31 00:48:10 +0000554 E->setCastKind((CastExpr::CastKind)Record[Idx++]);
John McCallf871d0c2010-08-07 06:22:56 +0000555 CastExpr::path_iterator BaseI = E->path_begin();
Argyrios Kyrtzidis0745d0a2010-07-02 23:30:27 +0000556 while (NumBaseSpecs--) {
Douglas Gregor35942772011-09-09 21:34:22 +0000557 CXXBaseSpecifier *BaseSpec = new (Reader.getContext()) CXXBaseSpecifier;
Sebastian Redlc3632732010-10-05 15:59:54 +0000558 *BaseSpec = Reader.ReadCXXBaseSpecifier(F, Record, Idx);
John McCallf871d0c2010-08-07 06:22:56 +0000559 *BaseI++ = BaseSpec;
Argyrios Kyrtzidis0745d0a2010-07-02 23:30:27 +0000560 }
Chris Lattner4c6f9522009-04-27 05:14:47 +0000561}
562
Sebastian Redl60adf4a2010-08-18 23:56:52 +0000563void ASTStmtReader::VisitBinaryOperator(BinaryOperator *E) {
Chris Lattner4c6f9522009-04-27 05:14:47 +0000564 VisitExpr(E);
Argyrios Kyrtzidisd98a2ab2010-06-29 22:46:25 +0000565 E->setLHS(Reader.ReadSubExpr());
566 E->setRHS(Reader.ReadSubExpr());
Chris Lattner4c6f9522009-04-27 05:14:47 +0000567 E->setOpcode((BinaryOperator::Opcode)Record[Idx++]);
Sebastian Redlc3632732010-10-05 15:59:54 +0000568 E->setOperatorLoc(ReadSourceLocation(Record, Idx));
Lang Hamesbe9af122012-10-02 04:45:10 +0000569 E->setFPContractable((bool)Record[Idx++]);
Chris Lattner4c6f9522009-04-27 05:14:47 +0000570}
571
Sebastian Redl60adf4a2010-08-18 23:56:52 +0000572void ASTStmtReader::VisitCompoundAssignOperator(CompoundAssignOperator *E) {
Chris Lattner4c6f9522009-04-27 05:14:47 +0000573 VisitBinaryOperator(E);
Douglas Gregor393f2492011-07-22 00:38:23 +0000574 E->setComputationLHSType(Reader.readType(F, Record, Idx));
575 E->setComputationResultType(Reader.readType(F, Record, Idx));
Chris Lattner4c6f9522009-04-27 05:14:47 +0000576}
577
Sebastian Redl60adf4a2010-08-18 23:56:52 +0000578void ASTStmtReader::VisitConditionalOperator(ConditionalOperator *E) {
Chris Lattner4c6f9522009-04-27 05:14:47 +0000579 VisitExpr(E);
John McCall56ca35d2011-02-17 10:25:35 +0000580 E->SubExprs[ConditionalOperator::COND] = Reader.ReadSubExpr();
581 E->SubExprs[ConditionalOperator::LHS] = Reader.ReadSubExpr();
582 E->SubExprs[ConditionalOperator::RHS] = Reader.ReadSubExpr();
583 E->QuestionLoc = ReadSourceLocation(Record, Idx);
584 E->ColonLoc = ReadSourceLocation(Record, Idx);
585}
586
587void
588ASTStmtReader::VisitBinaryConditionalOperator(BinaryConditionalOperator *E) {
589 VisitExpr(E);
590 E->OpaqueValue = cast<OpaqueValueExpr>(Reader.ReadSubExpr());
591 E->SubExprs[BinaryConditionalOperator::COMMON] = Reader.ReadSubExpr();
592 E->SubExprs[BinaryConditionalOperator::COND] = Reader.ReadSubExpr();
593 E->SubExprs[BinaryConditionalOperator::LHS] = Reader.ReadSubExpr();
594 E->SubExprs[BinaryConditionalOperator::RHS] = Reader.ReadSubExpr();
595 E->QuestionLoc = ReadSourceLocation(Record, Idx);
596 E->ColonLoc = ReadSourceLocation(Record, Idx);
Chris Lattner4c6f9522009-04-27 05:14:47 +0000597}
598
Sebastian Redl60adf4a2010-08-18 23:56:52 +0000599void ASTStmtReader::VisitImplicitCastExpr(ImplicitCastExpr *E) {
Chris Lattner4c6f9522009-04-27 05:14:47 +0000600 VisitCastExpr(E);
Chris Lattner4c6f9522009-04-27 05:14:47 +0000601}
602
Sebastian Redl60adf4a2010-08-18 23:56:52 +0000603void ASTStmtReader::VisitExplicitCastExpr(ExplicitCastExpr *E) {
Chris Lattner4c6f9522009-04-27 05:14:47 +0000604 VisitCastExpr(E);
Sebastian Redlc3632732010-10-05 15:59:54 +0000605 E->setTypeInfoAsWritten(GetTypeSourceInfo(Record, Idx));
Chris Lattner4c6f9522009-04-27 05:14:47 +0000606}
607
Sebastian Redl60adf4a2010-08-18 23:56:52 +0000608void ASTStmtReader::VisitCStyleCastExpr(CStyleCastExpr *E) {
Chris Lattner4c6f9522009-04-27 05:14:47 +0000609 VisitExplicitCastExpr(E);
Sebastian Redlc3632732010-10-05 15:59:54 +0000610 E->setLParenLoc(ReadSourceLocation(Record, Idx));
611 E->setRParenLoc(ReadSourceLocation(Record, Idx));
Chris Lattner4c6f9522009-04-27 05:14:47 +0000612}
613
Sebastian Redl60adf4a2010-08-18 23:56:52 +0000614void ASTStmtReader::VisitCompoundLiteralExpr(CompoundLiteralExpr *E) {
Chris Lattner4c6f9522009-04-27 05:14:47 +0000615 VisitExpr(E);
Sebastian Redlc3632732010-10-05 15:59:54 +0000616 E->setLParenLoc(ReadSourceLocation(Record, Idx));
617 E->setTypeSourceInfo(GetTypeSourceInfo(Record, Idx));
Argyrios Kyrtzidisd98a2ab2010-06-29 22:46:25 +0000618 E->setInitializer(Reader.ReadSubExpr());
Chris Lattner4c6f9522009-04-27 05:14:47 +0000619 E->setFileScope(Record[Idx++]);
Chris Lattner4c6f9522009-04-27 05:14:47 +0000620}
621
Sebastian Redl60adf4a2010-08-18 23:56:52 +0000622void ASTStmtReader::VisitExtVectorElementExpr(ExtVectorElementExpr *E) {
Chris Lattner4c6f9522009-04-27 05:14:47 +0000623 VisitExpr(E);
Argyrios Kyrtzidisd98a2ab2010-06-29 22:46:25 +0000624 E->setBase(Reader.ReadSubExpr());
Douglas Gregor95eab172011-07-28 20:55:49 +0000625 E->setAccessor(Reader.GetIdentifierInfo(F, Record, Idx));
Sebastian Redlc3632732010-10-05 15:59:54 +0000626 E->setAccessorLoc(ReadSourceLocation(Record, Idx));
Chris Lattner4c6f9522009-04-27 05:14:47 +0000627}
628
Sebastian Redl60adf4a2010-08-18 23:56:52 +0000629void ASTStmtReader::VisitInitListExpr(InitListExpr *E) {
Chris Lattner4c6f9522009-04-27 05:14:47 +0000630 VisitExpr(E);
Abramo Bagnara23700f02012-11-08 18:41:43 +0000631 if (InitListExpr *SyntForm = cast_or_null<InitListExpr>(Reader.ReadSubStmt()))
632 E->setSyntacticForm(SyntForm);
Sebastian Redlc3632732010-10-05 15:59:54 +0000633 E->setLBraceLoc(ReadSourceLocation(Record, Idx));
634 E->setRBraceLoc(ReadSourceLocation(Record, Idx));
Argyrios Kyrtzidis2ac0b7a2011-04-22 05:29:30 +0000635 bool isArrayFiller = Record[Idx++];
636 Expr *filler = 0;
637 if (isArrayFiller) {
638 filler = Reader.ReadSubExpr();
639 E->ArrayFillerOrUnionFieldInit = filler;
640 } else
Douglas Gregor409448c2011-07-21 22:35:25 +0000641 E->ArrayFillerOrUnionFieldInit = ReadDeclAs<FieldDecl>(Record, Idx);
Chris Lattner4c6f9522009-04-27 05:14:47 +0000642 E->sawArrayRangeDesignator(Record[Idx++]);
Benjamin Kramer1b1a5072012-02-27 13:20:39 +0000643 E->setInitializesStdInitializerList(Record[Idx++]);
Argyrios Kyrtzidis2ac0b7a2011-04-22 05:29:30 +0000644 unsigned NumInits = Record[Idx++];
Douglas Gregor35942772011-09-09 21:34:22 +0000645 E->reserveInits(Reader.getContext(), NumInits);
Argyrios Kyrtzidis2ac0b7a2011-04-22 05:29:30 +0000646 if (isArrayFiller) {
647 for (unsigned I = 0; I != NumInits; ++I) {
648 Expr *init = Reader.ReadSubExpr();
Douglas Gregor35942772011-09-09 21:34:22 +0000649 E->updateInit(Reader.getContext(), I, init ? init : filler);
Argyrios Kyrtzidis2ac0b7a2011-04-22 05:29:30 +0000650 }
651 } else {
652 for (unsigned I = 0; I != NumInits; ++I)
Douglas Gregor35942772011-09-09 21:34:22 +0000653 E->updateInit(Reader.getContext(), I, Reader.ReadSubExpr());
Argyrios Kyrtzidis2ac0b7a2011-04-22 05:29:30 +0000654 }
Chris Lattner4c6f9522009-04-27 05:14:47 +0000655}
656
Sebastian Redl60adf4a2010-08-18 23:56:52 +0000657void ASTStmtReader::VisitDesignatedInitExpr(DesignatedInitExpr *E) {
Chris Lattner4c6f9522009-04-27 05:14:47 +0000658 typedef DesignatedInitExpr::Designator Designator;
659
660 VisitExpr(E);
661 unsigned NumSubExprs = Record[Idx++];
662 assert(NumSubExprs == E->getNumSubExprs() && "Wrong number of subexprs");
663 for (unsigned I = 0; I != NumSubExprs; ++I)
Argyrios Kyrtzidisd98a2ab2010-06-29 22:46:25 +0000664 E->setSubExpr(I, Reader.ReadSubExpr());
Sebastian Redlc3632732010-10-05 15:59:54 +0000665 E->setEqualOrColonLoc(ReadSourceLocation(Record, Idx));
Chris Lattner4c6f9522009-04-27 05:14:47 +0000666 E->setGNUSyntax(Record[Idx++]);
667
Chris Lattner5f9e2722011-07-23 10:55:15 +0000668 SmallVector<Designator, 4> Designators;
Chris Lattner4c6f9522009-04-27 05:14:47 +0000669 while (Idx < Record.size()) {
Sebastian Redl8538e8d2010-08-18 23:57:32 +0000670 switch ((DesignatorTypes)Record[Idx++]) {
671 case DESIG_FIELD_DECL: {
Douglas Gregor409448c2011-07-21 22:35:25 +0000672 FieldDecl *Field = ReadDeclAs<FieldDecl>(Record, Idx);
Mike Stump1eb44332009-09-09 15:08:12 +0000673 SourceLocation DotLoc
Sebastian Redlc3632732010-10-05 15:59:54 +0000674 = ReadSourceLocation(Record, Idx);
Mike Stump1eb44332009-09-09 15:08:12 +0000675 SourceLocation FieldLoc
Sebastian Redlc3632732010-10-05 15:59:54 +0000676 = ReadSourceLocation(Record, Idx);
Mike Stump1eb44332009-09-09 15:08:12 +0000677 Designators.push_back(Designator(Field->getIdentifier(), DotLoc,
Chris Lattner4c6f9522009-04-27 05:14:47 +0000678 FieldLoc));
679 Designators.back().setField(Field);
680 break;
681 }
682
Sebastian Redl8538e8d2010-08-18 23:57:32 +0000683 case DESIG_FIELD_NAME: {
Douglas Gregor95eab172011-07-28 20:55:49 +0000684 const IdentifierInfo *Name = Reader.GetIdentifierInfo(F, Record, Idx);
Mike Stump1eb44332009-09-09 15:08:12 +0000685 SourceLocation DotLoc
Sebastian Redlc3632732010-10-05 15:59:54 +0000686 = ReadSourceLocation(Record, Idx);
Mike Stump1eb44332009-09-09 15:08:12 +0000687 SourceLocation FieldLoc
Sebastian Redlc3632732010-10-05 15:59:54 +0000688 = ReadSourceLocation(Record, Idx);
Chris Lattner4c6f9522009-04-27 05:14:47 +0000689 Designators.push_back(Designator(Name, DotLoc, FieldLoc));
690 break;
691 }
Mike Stump1eb44332009-09-09 15:08:12 +0000692
Sebastian Redl8538e8d2010-08-18 23:57:32 +0000693 case DESIG_ARRAY: {
Chris Lattner4c6f9522009-04-27 05:14:47 +0000694 unsigned Index = Record[Idx++];
695 SourceLocation LBracketLoc
Sebastian Redlc3632732010-10-05 15:59:54 +0000696 = ReadSourceLocation(Record, Idx);
Chris Lattner4c6f9522009-04-27 05:14:47 +0000697 SourceLocation RBracketLoc
Sebastian Redlc3632732010-10-05 15:59:54 +0000698 = ReadSourceLocation(Record, Idx);
Chris Lattner4c6f9522009-04-27 05:14:47 +0000699 Designators.push_back(Designator(Index, LBracketLoc, RBracketLoc));
700 break;
701 }
702
Sebastian Redl8538e8d2010-08-18 23:57:32 +0000703 case DESIG_ARRAY_RANGE: {
Chris Lattner4c6f9522009-04-27 05:14:47 +0000704 unsigned Index = Record[Idx++];
705 SourceLocation LBracketLoc
Sebastian Redlc3632732010-10-05 15:59:54 +0000706 = ReadSourceLocation(Record, Idx);
Chris Lattner4c6f9522009-04-27 05:14:47 +0000707 SourceLocation EllipsisLoc
Sebastian Redlc3632732010-10-05 15:59:54 +0000708 = ReadSourceLocation(Record, Idx);
Chris Lattner4c6f9522009-04-27 05:14:47 +0000709 SourceLocation RBracketLoc
Sebastian Redlc3632732010-10-05 15:59:54 +0000710 = ReadSourceLocation(Record, Idx);
Chris Lattner4c6f9522009-04-27 05:14:47 +0000711 Designators.push_back(Designator(Index, LBracketLoc, EllipsisLoc,
712 RBracketLoc));
713 break;
714 }
715 }
716 }
Douglas Gregor35942772011-09-09 21:34:22 +0000717 E->setDesignators(Reader.getContext(),
Douglas Gregor319d57f2010-01-06 23:17:19 +0000718 Designators.data(), Designators.size());
Chris Lattner4c6f9522009-04-27 05:14:47 +0000719}
720
Sebastian Redl60adf4a2010-08-18 23:56:52 +0000721void ASTStmtReader::VisitImplicitValueInitExpr(ImplicitValueInitExpr *E) {
Chris Lattner4c6f9522009-04-27 05:14:47 +0000722 VisitExpr(E);
Chris Lattner4c6f9522009-04-27 05:14:47 +0000723}
724
Sebastian Redl60adf4a2010-08-18 23:56:52 +0000725void ASTStmtReader::VisitVAArgExpr(VAArgExpr *E) {
Chris Lattner4c6f9522009-04-27 05:14:47 +0000726 VisitExpr(E);
Argyrios Kyrtzidisd98a2ab2010-06-29 22:46:25 +0000727 E->setSubExpr(Reader.ReadSubExpr());
Sebastian Redlc3632732010-10-05 15:59:54 +0000728 E->setWrittenTypeInfo(GetTypeSourceInfo(Record, Idx));
729 E->setBuiltinLoc(ReadSourceLocation(Record, Idx));
730 E->setRParenLoc(ReadSourceLocation(Record, Idx));
Chris Lattner4c6f9522009-04-27 05:14:47 +0000731}
732
Sebastian Redl60adf4a2010-08-18 23:56:52 +0000733void ASTStmtReader::VisitAddrLabelExpr(AddrLabelExpr *E) {
Chris Lattner4c6f9522009-04-27 05:14:47 +0000734 VisitExpr(E);
Sebastian Redlc3632732010-10-05 15:59:54 +0000735 E->setAmpAmpLoc(ReadSourceLocation(Record, Idx));
736 E->setLabelLoc(ReadSourceLocation(Record, Idx));
Douglas Gregor409448c2011-07-21 22:35:25 +0000737 E->setLabel(ReadDeclAs<LabelDecl>(Record, Idx));
Chris Lattner4c6f9522009-04-27 05:14:47 +0000738}
739
Sebastian Redl60adf4a2010-08-18 23:56:52 +0000740void ASTStmtReader::VisitStmtExpr(StmtExpr *E) {
Chris Lattner4c6f9522009-04-27 05:14:47 +0000741 VisitExpr(E);
Sebastian Redlc3632732010-10-05 15:59:54 +0000742 E->setLParenLoc(ReadSourceLocation(Record, Idx));
743 E->setRParenLoc(ReadSourceLocation(Record, Idx));
Argyrios Kyrtzidisd98a2ab2010-06-29 22:46:25 +0000744 E->setSubStmt(cast_or_null<CompoundStmt>(Reader.ReadSubStmt()));
Chris Lattner4c6f9522009-04-27 05:14:47 +0000745}
746
Sebastian Redl60adf4a2010-08-18 23:56:52 +0000747void ASTStmtReader::VisitChooseExpr(ChooseExpr *E) {
Chris Lattner4c6f9522009-04-27 05:14:47 +0000748 VisitExpr(E);
Argyrios Kyrtzidisd98a2ab2010-06-29 22:46:25 +0000749 E->setCond(Reader.ReadSubExpr());
750 E->setLHS(Reader.ReadSubExpr());
751 E->setRHS(Reader.ReadSubExpr());
Sebastian Redlc3632732010-10-05 15:59:54 +0000752 E->setBuiltinLoc(ReadSourceLocation(Record, Idx));
753 E->setRParenLoc(ReadSourceLocation(Record, Idx));
Chris Lattner4c6f9522009-04-27 05:14:47 +0000754}
755
Sebastian Redl60adf4a2010-08-18 23:56:52 +0000756void ASTStmtReader::VisitGNUNullExpr(GNUNullExpr *E) {
Chris Lattner4c6f9522009-04-27 05:14:47 +0000757 VisitExpr(E);
Sebastian Redlc3632732010-10-05 15:59:54 +0000758 E->setTokenLocation(ReadSourceLocation(Record, Idx));
Chris Lattner4c6f9522009-04-27 05:14:47 +0000759}
760
Sebastian Redl60adf4a2010-08-18 23:56:52 +0000761void ASTStmtReader::VisitShuffleVectorExpr(ShuffleVectorExpr *E) {
Chris Lattner4c6f9522009-04-27 05:14:47 +0000762 VisitExpr(E);
Chris Lattner5f9e2722011-07-23 10:55:15 +0000763 SmallVector<Expr *, 16> Exprs;
Chris Lattner4c6f9522009-04-27 05:14:47 +0000764 unsigned NumExprs = Record[Idx++];
Argyrios Kyrtzidis919e6932010-06-28 22:28:35 +0000765 while (NumExprs--)
Argyrios Kyrtzidisd98a2ab2010-06-29 22:46:25 +0000766 Exprs.push_back(Reader.ReadSubExpr());
Douglas Gregor35942772011-09-09 21:34:22 +0000767 E->setExprs(Reader.getContext(), Exprs.data(), Exprs.size());
Sebastian Redlc3632732010-10-05 15:59:54 +0000768 E->setBuiltinLoc(ReadSourceLocation(Record, Idx));
769 E->setRParenLoc(ReadSourceLocation(Record, Idx));
Chris Lattner4c6f9522009-04-27 05:14:47 +0000770}
771
Sebastian Redl60adf4a2010-08-18 23:56:52 +0000772void ASTStmtReader::VisitBlockExpr(BlockExpr *E) {
Chris Lattner4c6f9522009-04-27 05:14:47 +0000773 VisitExpr(E);
Douglas Gregor409448c2011-07-21 22:35:25 +0000774 E->setBlockDecl(ReadDeclAs<BlockDecl>(Record, Idx));
Chris Lattner4c6f9522009-04-27 05:14:47 +0000775}
776
Peter Collingbournef111d932011-04-15 00:35:48 +0000777void ASTStmtReader::VisitGenericSelectionExpr(GenericSelectionExpr *E) {
778 VisitExpr(E);
779 E->NumAssocs = Record[Idx++];
Douglas Gregor35942772011-09-09 21:34:22 +0000780 E->AssocTypes = new (Reader.getContext()) TypeSourceInfo*[E->NumAssocs];
Peter Collingbournef111d932011-04-15 00:35:48 +0000781 E->SubExprs =
Douglas Gregor35942772011-09-09 21:34:22 +0000782 new(Reader.getContext()) Stmt*[GenericSelectionExpr::END_EXPR+E->NumAssocs];
Peter Collingbournef111d932011-04-15 00:35:48 +0000783
784 E->SubExprs[GenericSelectionExpr::CONTROLLING] = Reader.ReadSubExpr();
785 for (unsigned I = 0, N = E->getNumAssocs(); I != N; ++I) {
786 E->AssocTypes[I] = GetTypeSourceInfo(Record, Idx);
787 E->SubExprs[GenericSelectionExpr::END_EXPR+I] = Reader.ReadSubExpr();
788 }
789 E->ResultIndex = Record[Idx++];
790
791 E->GenericLoc = ReadSourceLocation(Record, Idx);
792 E->DefaultLoc = ReadSourceLocation(Record, Idx);
793 E->RParenLoc = ReadSourceLocation(Record, Idx);
794}
795
John McCall4b9c2d22011-11-06 09:01:30 +0000796void ASTStmtReader::VisitPseudoObjectExpr(PseudoObjectExpr *E) {
797 VisitExpr(E);
798 unsigned numSemanticExprs = Record[Idx++];
799 assert(numSemanticExprs + 1 == E->PseudoObjectExprBits.NumSubExprs);
800 E->PseudoObjectExprBits.ResultIndex = Record[Idx++];
801
802 // Read the syntactic expression.
803 E->getSubExprsBuffer()[0] = Reader.ReadSubExpr();
804
805 // Read all the semantic expressions.
806 for (unsigned i = 0; i != numSemanticExprs; ++i) {
807 Expr *subExpr = Reader.ReadSubExpr();
John McCall4b9c2d22011-11-06 09:01:30 +0000808 E->getSubExprsBuffer()[i+1] = subExpr;
809 }
810}
811
Eli Friedman276b0612011-10-11 02:20:01 +0000812void ASTStmtReader::VisitAtomicExpr(AtomicExpr *E) {
813 VisitExpr(E);
Richard Smithe1b2abc2012-04-10 22:49:28 +0000814 E->Op = AtomicExpr::AtomicOp(Record[Idx++]);
815 E->NumSubExprs = AtomicExpr::getNumSubExprs(E->Op);
816 for (unsigned I = 0; I != E->NumSubExprs; ++I)
817 E->SubExprs[I] = Reader.ReadSubExpr();
818 E->BuiltinLoc = ReadSourceLocation(Record, Idx);
819 E->RParenLoc = ReadSourceLocation(Record, Idx);
Eli Friedman276b0612011-10-11 02:20:01 +0000820}
821
Chris Lattner4c6f9522009-04-27 05:14:47 +0000822//===----------------------------------------------------------------------===//
823// Objective-C Expressions and Statements
824
Sebastian Redl60adf4a2010-08-18 23:56:52 +0000825void ASTStmtReader::VisitObjCStringLiteral(ObjCStringLiteral *E) {
Chris Lattner4c6f9522009-04-27 05:14:47 +0000826 VisitExpr(E);
Argyrios Kyrtzidisd98a2ab2010-06-29 22:46:25 +0000827 E->setString(cast<StringLiteral>(Reader.ReadSubStmt()));
Sebastian Redlc3632732010-10-05 15:59:54 +0000828 E->setAtLoc(ReadSourceLocation(Record, Idx));
Chris Lattner4c6f9522009-04-27 05:14:47 +0000829}
830
Patrick Beardeb382ec2012-04-19 00:25:12 +0000831void ASTStmtReader::VisitObjCBoxedExpr(ObjCBoxedExpr *E) {
Ted Kremenekebcb57a2012-03-06 20:05:56 +0000832 VisitExpr(E);
833 // could be one of several IntegerLiteral, FloatLiteral, etc.
Patrick Beardeb382ec2012-04-19 00:25:12 +0000834 E->SubExpr = Reader.ReadSubStmt();
835 E->BoxingMethod = ReadDeclAs<ObjCMethodDecl>(Record, Idx);
836 E->Range = ReadSourceRange(Record, Idx);
Ted Kremenekebcb57a2012-03-06 20:05:56 +0000837}
838
839void ASTStmtReader::VisitObjCArrayLiteral(ObjCArrayLiteral *E) {
840 VisitExpr(E);
841 unsigned NumElements = Record[Idx++];
842 assert(NumElements == E->getNumElements() && "Wrong number of elements");
843 Expr **Elements = E->getElements();
844 for (unsigned I = 0, N = NumElements; I != N; ++I)
845 Elements[I] = Reader.ReadSubExpr();
846 E->ArrayWithObjectsMethod = ReadDeclAs<ObjCMethodDecl>(Record, Idx);
847 E->Range = ReadSourceRange(Record, Idx);
848}
849
850void ASTStmtReader::VisitObjCDictionaryLiteral(ObjCDictionaryLiteral *E) {
851 VisitExpr(E);
852 unsigned NumElements = Record[Idx++];
853 assert(NumElements == E->getNumElements() && "Wrong number of elements");
854 bool HasPackExpansions = Record[Idx++];
855 assert(HasPackExpansions == E->HasPackExpansions &&"Pack expansion mismatch");
856 ObjCDictionaryLiteral::KeyValuePair *KeyValues = E->getKeyValues();
857 ObjCDictionaryLiteral::ExpansionData *Expansions = E->getExpansionData();
858 for (unsigned I = 0; I != NumElements; ++I) {
859 KeyValues[I].Key = Reader.ReadSubExpr();
860 KeyValues[I].Value = Reader.ReadSubExpr();
861 if (HasPackExpansions) {
862 Expansions[I].EllipsisLoc = ReadSourceLocation(Record, Idx);
863 Expansions[I].NumExpansionsPlusOne = Record[Idx++];
864 }
865 }
866 E->DictWithObjectsMethod = ReadDeclAs<ObjCMethodDecl>(Record, Idx);
867 E->Range = ReadSourceRange(Record, Idx);
868}
869
Sebastian Redl60adf4a2010-08-18 23:56:52 +0000870void ASTStmtReader::VisitObjCEncodeExpr(ObjCEncodeExpr *E) {
Chris Lattner4c6f9522009-04-27 05:14:47 +0000871 VisitExpr(E);
Sebastian Redlc3632732010-10-05 15:59:54 +0000872 E->setEncodedTypeSourceInfo(GetTypeSourceInfo(Record, Idx));
873 E->setAtLoc(ReadSourceLocation(Record, Idx));
874 E->setRParenLoc(ReadSourceLocation(Record, Idx));
Chris Lattner4c6f9522009-04-27 05:14:47 +0000875}
876
Sebastian Redl60adf4a2010-08-18 23:56:52 +0000877void ASTStmtReader::VisitObjCSelectorExpr(ObjCSelectorExpr *E) {
Chris Lattner4c6f9522009-04-27 05:14:47 +0000878 VisitExpr(E);
Douglas Gregor2d2689a2011-07-28 21:16:51 +0000879 E->setSelector(Reader.ReadSelector(F, Record, Idx));
Sebastian Redlc3632732010-10-05 15:59:54 +0000880 E->setAtLoc(ReadSourceLocation(Record, Idx));
881 E->setRParenLoc(ReadSourceLocation(Record, Idx));
Chris Lattner4c6f9522009-04-27 05:14:47 +0000882}
883
Sebastian Redl60adf4a2010-08-18 23:56:52 +0000884void ASTStmtReader::VisitObjCProtocolExpr(ObjCProtocolExpr *E) {
Chris Lattner4c6f9522009-04-27 05:14:47 +0000885 VisitExpr(E);
Douglas Gregor409448c2011-07-21 22:35:25 +0000886 E->setProtocol(ReadDeclAs<ObjCProtocolDecl>(Record, Idx));
Sebastian Redlc3632732010-10-05 15:59:54 +0000887 E->setAtLoc(ReadSourceLocation(Record, Idx));
Argyrios Kyrtzidis7d24e282012-05-16 00:50:02 +0000888 E->ProtoLoc = ReadSourceLocation(Record, Idx);
Sebastian Redlc3632732010-10-05 15:59:54 +0000889 E->setRParenLoc(ReadSourceLocation(Record, Idx));
Chris Lattner4c6f9522009-04-27 05:14:47 +0000890}
891
Sebastian Redl60adf4a2010-08-18 23:56:52 +0000892void ASTStmtReader::VisitObjCIvarRefExpr(ObjCIvarRefExpr *E) {
Chris Lattner4c6f9522009-04-27 05:14:47 +0000893 VisitExpr(E);
Douglas Gregor409448c2011-07-21 22:35:25 +0000894 E->setDecl(ReadDeclAs<ObjCIvarDecl>(Record, Idx));
Sebastian Redlc3632732010-10-05 15:59:54 +0000895 E->setLocation(ReadSourceLocation(Record, Idx));
Argyrios Kyrtzidisd98a2ab2010-06-29 22:46:25 +0000896 E->setBase(Reader.ReadSubExpr());
Chris Lattner4c6f9522009-04-27 05:14:47 +0000897 E->setIsArrow(Record[Idx++]);
898 E->setIsFreeIvar(Record[Idx++]);
Chris Lattner4c6f9522009-04-27 05:14:47 +0000899}
900
Sebastian Redl60adf4a2010-08-18 23:56:52 +0000901void ASTStmtReader::VisitObjCPropertyRefExpr(ObjCPropertyRefExpr *E) {
Chris Lattner4c6f9522009-04-27 05:14:47 +0000902 VisitExpr(E);
Argyrios Kyrtzidisb085d892012-03-30 00:19:18 +0000903 unsigned MethodRefFlags = Record[Idx++];
John McCall12f78a62010-12-02 01:19:52 +0000904 bool Implicit = Record[Idx++] != 0;
905 if (Implicit) {
Douglas Gregor409448c2011-07-21 22:35:25 +0000906 ObjCMethodDecl *Getter = ReadDeclAs<ObjCMethodDecl>(Record, Idx);
907 ObjCMethodDecl *Setter = ReadDeclAs<ObjCMethodDecl>(Record, Idx);
Argyrios Kyrtzidisb085d892012-03-30 00:19:18 +0000908 E->setImplicitProperty(Getter, Setter, MethodRefFlags);
John McCall12f78a62010-12-02 01:19:52 +0000909 } else {
Argyrios Kyrtzidisb085d892012-03-30 00:19:18 +0000910 E->setExplicitProperty(ReadDeclAs<ObjCPropertyDecl>(Record, Idx),
911 MethodRefFlags);
Fariborz Jahanian8ac2d442010-10-14 16:04:05 +0000912 }
Sebastian Redlc3632732010-10-05 15:59:54 +0000913 E->setLocation(ReadSourceLocation(Record, Idx));
John McCall12f78a62010-12-02 01:19:52 +0000914 E->setReceiverLocation(ReadSourceLocation(Record, Idx));
915 switch (Record[Idx++]) {
916 case 0:
917 E->setBase(Reader.ReadSubExpr());
918 break;
919 case 1:
Douglas Gregor393f2492011-07-22 00:38:23 +0000920 E->setSuperReceiver(Reader.readType(F, Record, Idx));
John McCall12f78a62010-12-02 01:19:52 +0000921 break;
922 case 2:
Douglas Gregor409448c2011-07-21 22:35:25 +0000923 E->setClassReceiver(ReadDeclAs<ObjCInterfaceDecl>(Record, Idx));
John McCall12f78a62010-12-02 01:19:52 +0000924 break;
925 }
Chris Lattner4c6f9522009-04-27 05:14:47 +0000926}
927
Ted Kremenekebcb57a2012-03-06 20:05:56 +0000928void ASTStmtReader::VisitObjCSubscriptRefExpr(ObjCSubscriptRefExpr *E) {
929 VisitExpr(E);
930 E->setRBracket(ReadSourceLocation(Record, Idx));
931 E->setBaseExpr(Reader.ReadSubExpr());
932 E->setKeyExpr(Reader.ReadSubExpr());
933 E->GetAtIndexMethodDecl = ReadDeclAs<ObjCMethodDecl>(Record, Idx);
934 E->SetAtIndexMethodDecl = ReadDeclAs<ObjCMethodDecl>(Record, Idx);
935}
936
Sebastian Redl60adf4a2010-08-18 23:56:52 +0000937void ASTStmtReader::VisitObjCMessageExpr(ObjCMessageExpr *E) {
Chris Lattner4c6f9522009-04-27 05:14:47 +0000938 VisitExpr(E);
Douglas Gregor04badcf2010-04-21 00:45:42 +0000939 assert(Record[Idx] == E->getNumArgs());
940 ++Idx;
Argyrios Kyrtzidis20718082011-10-03 06:36:51 +0000941 unsigned NumStoredSelLocs = Record[Idx++];
942 E->SelLocsKind = Record[Idx++];
John McCallf85e1932011-06-15 23:02:42 +0000943 E->setDelegateInitCall(Record[Idx++]);
Argyrios Kyrtzidis746f5bc2012-01-12 02:34:39 +0000944 E->IsImplicit = Record[Idx++];
Douglas Gregor04badcf2010-04-21 00:45:42 +0000945 ObjCMessageExpr::ReceiverKind Kind
946 = static_cast<ObjCMessageExpr::ReceiverKind>(Record[Idx++]);
947 switch (Kind) {
948 case ObjCMessageExpr::Instance:
Argyrios Kyrtzidisd98a2ab2010-06-29 22:46:25 +0000949 E->setInstanceReceiver(Reader.ReadSubExpr());
Douglas Gregor04badcf2010-04-21 00:45:42 +0000950 break;
951
952 case ObjCMessageExpr::Class:
Sebastian Redlc3632732010-10-05 15:59:54 +0000953 E->setClassReceiver(GetTypeSourceInfo(Record, Idx));
Douglas Gregor04badcf2010-04-21 00:45:42 +0000954 break;
955
956 case ObjCMessageExpr::SuperClass:
957 case ObjCMessageExpr::SuperInstance: {
Douglas Gregor393f2492011-07-22 00:38:23 +0000958 QualType T = Reader.readType(F, Record, Idx);
Sebastian Redlc3632732010-10-05 15:59:54 +0000959 SourceLocation SuperLoc = ReadSourceLocation(Record, Idx);
Douglas Gregor04badcf2010-04-21 00:45:42 +0000960 E->setSuper(SuperLoc, T, Kind == ObjCMessageExpr::SuperInstance);
961 break;
962 }
963 }
964
965 assert(Kind == E->getReceiverKind());
966
967 if (Record[Idx++])
Douglas Gregor409448c2011-07-21 22:35:25 +0000968 E->setMethodDecl(ReadDeclAs<ObjCMethodDecl>(Record, Idx));
Douglas Gregor04badcf2010-04-21 00:45:42 +0000969 else
Douglas Gregor2d2689a2011-07-28 21:16:51 +0000970 E->setSelector(Reader.ReadSelector(F, Record, Idx));
Douglas Gregor04badcf2010-04-21 00:45:42 +0000971
Argyrios Kyrtzidisf40f0d52010-12-10 20:08:27 +0000972 E->LBracLoc = ReadSourceLocation(Record, Idx);
973 E->RBracLoc = ReadSourceLocation(Record, Idx);
Chris Lattner4c6f9522009-04-27 05:14:47 +0000974
975 for (unsigned I = 0, N = E->getNumArgs(); I != N; ++I)
Argyrios Kyrtzidisd98a2ab2010-06-29 22:46:25 +0000976 E->setArg(I, Reader.ReadSubExpr());
Argyrios Kyrtzidis20718082011-10-03 06:36:51 +0000977
978 SourceLocation *Locs = E->getStoredSelLocs();
979 for (unsigned I = 0; I != NumStoredSelLocs; ++I)
980 Locs[I] = ReadSourceLocation(Record, Idx);
Chris Lattner4c6f9522009-04-27 05:14:47 +0000981}
982
Sebastian Redl60adf4a2010-08-18 23:56:52 +0000983void ASTStmtReader::VisitObjCForCollectionStmt(ObjCForCollectionStmt *S) {
Chris Lattner4c6f9522009-04-27 05:14:47 +0000984 VisitStmt(S);
Argyrios Kyrtzidisd98a2ab2010-06-29 22:46:25 +0000985 S->setElement(Reader.ReadSubStmt());
986 S->setCollection(Reader.ReadSubExpr());
987 S->setBody(Reader.ReadSubStmt());
Sebastian Redlc3632732010-10-05 15:59:54 +0000988 S->setForLoc(ReadSourceLocation(Record, Idx));
989 S->setRParenLoc(ReadSourceLocation(Record, Idx));
Chris Lattner4c6f9522009-04-27 05:14:47 +0000990}
991
Sebastian Redl60adf4a2010-08-18 23:56:52 +0000992void ASTStmtReader::VisitObjCAtCatchStmt(ObjCAtCatchStmt *S) {
Chris Lattner4c6f9522009-04-27 05:14:47 +0000993 VisitStmt(S);
Argyrios Kyrtzidisd98a2ab2010-06-29 22:46:25 +0000994 S->setCatchBody(Reader.ReadSubStmt());
Douglas Gregor409448c2011-07-21 22:35:25 +0000995 S->setCatchParamDecl(ReadDeclAs<VarDecl>(Record, Idx));
Sebastian Redlc3632732010-10-05 15:59:54 +0000996 S->setAtCatchLoc(ReadSourceLocation(Record, Idx));
997 S->setRParenLoc(ReadSourceLocation(Record, Idx));
Chris Lattner4c6f9522009-04-27 05:14:47 +0000998}
999
Sebastian Redl60adf4a2010-08-18 23:56:52 +00001000void ASTStmtReader::VisitObjCAtFinallyStmt(ObjCAtFinallyStmt *S) {
Chris Lattner4c6f9522009-04-27 05:14:47 +00001001 VisitStmt(S);
Argyrios Kyrtzidisd98a2ab2010-06-29 22:46:25 +00001002 S->setFinallyBody(Reader.ReadSubStmt());
Sebastian Redlc3632732010-10-05 15:59:54 +00001003 S->setAtFinallyLoc(ReadSourceLocation(Record, Idx));
Chris Lattner4c6f9522009-04-27 05:14:47 +00001004}
1005
John McCallf85e1932011-06-15 23:02:42 +00001006void ASTStmtReader::VisitObjCAutoreleasePoolStmt(ObjCAutoreleasePoolStmt *S) {
1007 VisitStmt(S);
1008 S->setSubStmt(Reader.ReadSubStmt());
1009 S->setAtLoc(ReadSourceLocation(Record, Idx));
1010}
1011
Sebastian Redl60adf4a2010-08-18 23:56:52 +00001012void ASTStmtReader::VisitObjCAtTryStmt(ObjCAtTryStmt *S) {
Chris Lattner4c6f9522009-04-27 05:14:47 +00001013 VisitStmt(S);
Douglas Gregor8f5e3dd2010-04-23 22:50:49 +00001014 assert(Record[Idx] == S->getNumCatchStmts());
1015 ++Idx;
1016 bool HasFinally = Record[Idx++];
Argyrios Kyrtzidisd98a2ab2010-06-29 22:46:25 +00001017 S->setTryBody(Reader.ReadSubStmt());
Argyrios Kyrtzidis919e6932010-06-28 22:28:35 +00001018 for (unsigned I = 0, N = S->getNumCatchStmts(); I != N; ++I)
Argyrios Kyrtzidisd98a2ab2010-06-29 22:46:25 +00001019 S->setCatchStmt(I, cast_or_null<ObjCAtCatchStmt>(Reader.ReadSubStmt()));
Douglas Gregor8f5e3dd2010-04-23 22:50:49 +00001020
Douglas Gregor8f5e3dd2010-04-23 22:50:49 +00001021 if (HasFinally)
Argyrios Kyrtzidisd98a2ab2010-06-29 22:46:25 +00001022 S->setFinallyStmt(Reader.ReadSubStmt());
Sebastian Redlc3632732010-10-05 15:59:54 +00001023 S->setAtTryLoc(ReadSourceLocation(Record, Idx));
Chris Lattner4c6f9522009-04-27 05:14:47 +00001024}
1025
Sebastian Redl60adf4a2010-08-18 23:56:52 +00001026void ASTStmtReader::VisitObjCAtSynchronizedStmt(ObjCAtSynchronizedStmt *S) {
Chris Lattner4c6f9522009-04-27 05:14:47 +00001027 VisitStmt(S);
Argyrios Kyrtzidisd98a2ab2010-06-29 22:46:25 +00001028 S->setSynchExpr(Reader.ReadSubStmt());
1029 S->setSynchBody(Reader.ReadSubStmt());
Sebastian Redlc3632732010-10-05 15:59:54 +00001030 S->setAtSynchronizedLoc(ReadSourceLocation(Record, Idx));
Chris Lattner4c6f9522009-04-27 05:14:47 +00001031}
1032
Sebastian Redl60adf4a2010-08-18 23:56:52 +00001033void ASTStmtReader::VisitObjCAtThrowStmt(ObjCAtThrowStmt *S) {
Chris Lattner4c6f9522009-04-27 05:14:47 +00001034 VisitStmt(S);
Argyrios Kyrtzidisd98a2ab2010-06-29 22:46:25 +00001035 S->setThrowExpr(Reader.ReadSubStmt());
Sebastian Redlc3632732010-10-05 15:59:54 +00001036 S->setThrowLoc(ReadSourceLocation(Record, Idx));
Chris Lattner4c6f9522009-04-27 05:14:47 +00001037}
1038
Ted Kremenekebcb57a2012-03-06 20:05:56 +00001039void ASTStmtReader::VisitObjCBoolLiteralExpr(ObjCBoolLiteralExpr *E) {
1040 VisitExpr(E);
1041 E->setValue(Record[Idx++]);
1042 E->setLocation(ReadSourceLocation(Record, Idx));
1043}
1044
Argyrios Kyrtzidisba0a9002009-07-14 03:19:21 +00001045//===----------------------------------------------------------------------===//
1046// C++ Expressions and Statements
Argyrios Kyrtzidis7cb45e32010-07-22 16:03:56 +00001047//===----------------------------------------------------------------------===//
1048
Sebastian Redl60adf4a2010-08-18 23:56:52 +00001049void ASTStmtReader::VisitCXXCatchStmt(CXXCatchStmt *S) {
Argyrios Kyrtzidis7cb45e32010-07-22 16:03:56 +00001050 VisitStmt(S);
Sebastian Redlc3632732010-10-05 15:59:54 +00001051 S->CatchLoc = ReadSourceLocation(Record, Idx);
Douglas Gregor409448c2011-07-21 22:35:25 +00001052 S->ExceptionDecl = ReadDeclAs<VarDecl>(Record, Idx);
Argyrios Kyrtzidis7cb45e32010-07-22 16:03:56 +00001053 S->HandlerBlock = Reader.ReadSubStmt();
1054}
1055
Sebastian Redl60adf4a2010-08-18 23:56:52 +00001056void ASTStmtReader::VisitCXXTryStmt(CXXTryStmt *S) {
Argyrios Kyrtzidis7cb45e32010-07-22 16:03:56 +00001057 VisitStmt(S);
1058 assert(Record[Idx] == S->getNumHandlers() && "NumStmtFields is wrong ?");
1059 ++Idx;
Sebastian Redlc3632732010-10-05 15:59:54 +00001060 S->TryLoc = ReadSourceLocation(Record, Idx);
Argyrios Kyrtzidis7cb45e32010-07-22 16:03:56 +00001061 S->getStmts()[0] = Reader.ReadSubStmt();
1062 for (unsigned i = 0, e = S->getNumHandlers(); i != e; ++i)
1063 S->getStmts()[i + 1] = Reader.ReadSubStmt();
1064}
Argyrios Kyrtzidisba0a9002009-07-14 03:19:21 +00001065
Richard Smithad762fc2011-04-14 22:09:26 +00001066void ASTStmtReader::VisitCXXForRangeStmt(CXXForRangeStmt *S) {
1067 VisitStmt(S);
1068 S->setForLoc(ReadSourceLocation(Record, Idx));
1069 S->setColonLoc(ReadSourceLocation(Record, Idx));
1070 S->setRParenLoc(ReadSourceLocation(Record, Idx));
1071 S->setRangeStmt(Reader.ReadSubStmt());
1072 S->setBeginEndStmt(Reader.ReadSubStmt());
1073 S->setCond(Reader.ReadSubExpr());
1074 S->setInc(Reader.ReadSubExpr());
1075 S->setLoopVarStmt(Reader.ReadSubStmt());
1076 S->setBody(Reader.ReadSubStmt());
1077}
1078
Douglas Gregorba0513d2011-10-25 01:33:02 +00001079void ASTStmtReader::VisitMSDependentExistsStmt(MSDependentExistsStmt *S) {
1080 VisitStmt(S);
1081 S->KeywordLoc = ReadSourceLocation(Record, Idx);
1082 S->IsIfExists = Record[Idx++];
1083 S->QualifierLoc = Reader.ReadNestedNameSpecifierLoc(F, Record, Idx);
1084 ReadDeclarationNameInfo(S->NameInfo, Record, Idx);
1085 S->SubStmt = Reader.ReadSubStmt();
1086}
1087
Sebastian Redl60adf4a2010-08-18 23:56:52 +00001088void ASTStmtReader::VisitCXXOperatorCallExpr(CXXOperatorCallExpr *E) {
Argyrios Kyrtzidis919e6932010-06-28 22:28:35 +00001089 VisitCallExpr(E);
Argyrios Kyrtzidis4548ca22012-04-30 22:12:22 +00001090 E->Operator = (OverloadedOperatorKind)Record[Idx++];
1091 E->Range = Reader.ReadSourceRange(F, Record, Idx);
Lang Hamesbe9af122012-10-02 04:45:10 +00001092 E->setFPContractable((bool)Record[Idx++]);
Argyrios Kyrtzidisba0a9002009-07-14 03:19:21 +00001093}
1094
Sebastian Redl60adf4a2010-08-18 23:56:52 +00001095void ASTStmtReader::VisitCXXConstructExpr(CXXConstructExpr *E) {
Douglas Gregor39da0b82009-09-09 23:08:42 +00001096 VisitExpr(E);
Argyrios Kyrtzidis6d00c132010-07-10 11:46:15 +00001097 E->NumArgs = Record[Idx++];
1098 if (E->NumArgs)
Douglas Gregor35942772011-09-09 21:34:22 +00001099 E->Args = new (Reader.getContext()) Stmt*[E->NumArgs];
Argyrios Kyrtzidis5e1b7c22010-06-24 08:57:09 +00001100 for (unsigned I = 0, N = E->getNumArgs(); I != N; ++I)
Argyrios Kyrtzidisd98a2ab2010-06-29 22:46:25 +00001101 E->setArg(I, Reader.ReadSubExpr());
Douglas Gregor409448c2011-07-21 22:35:25 +00001102 E->setConstructor(ReadDeclAs<CXXConstructorDecl>(Record, Idx));
Sebastian Redlc3632732010-10-05 15:59:54 +00001103 E->setLocation(ReadSourceLocation(Record, Idx));
Abramo Bagnara7cc58b42011-10-05 07:56:41 +00001104 E->setElidable(Record[Idx++]);
1105 E->setHadMultipleCandidates(Record[Idx++]);
Richard Smithc83c2302012-12-19 01:39:02 +00001106 E->setListInitialization(Record[Idx++]);
Douglas Gregor16006c92009-12-16 18:50:27 +00001107 E->setRequiresZeroInitialization(Record[Idx++]);
Douglas Gregor3c9034c2010-05-15 00:13:29 +00001108 E->setConstructionKind((CXXConstructExpr::ConstructionKind)Record[Idx++]);
Chandler Carruth428edaf2010-10-25 08:47:36 +00001109 E->ParenRange = ReadSourceRange(Record, Idx);
Douglas Gregor39da0b82009-09-09 23:08:42 +00001110}
Chris Lattner4c6f9522009-04-27 05:14:47 +00001111
Sebastian Redl60adf4a2010-08-18 23:56:52 +00001112void ASTStmtReader::VisitCXXTemporaryObjectExpr(CXXTemporaryObjectExpr *E) {
Argyrios Kyrtzidis6d00c132010-07-10 11:46:15 +00001113 VisitCXXConstructExpr(E);
Sebastian Redlc3632732010-10-05 15:59:54 +00001114 E->Type = GetTypeSourceInfo(Record, Idx);
Argyrios Kyrtzidis6d00c132010-07-10 11:46:15 +00001115}
1116
Douglas Gregor01d08012012-02-07 10:09:13 +00001117void ASTStmtReader::VisitLambdaExpr(LambdaExpr *E) {
1118 VisitExpr(E);
Douglas Gregor9d36f5d2012-02-14 17:54:36 +00001119 unsigned NumCaptures = Record[Idx++];
1120 assert(NumCaptures == E->NumCaptures);(void)NumCaptures;
1121 unsigned NumArrayIndexVars = Record[Idx++];
1122 E->IntroducerRange = ReadSourceRange(Record, Idx);
1123 E->CaptureDefault = static_cast<LambdaCaptureDefault>(Record[Idx++]);
1124 E->ExplicitParams = Record[Idx++];
1125 E->ExplicitResultType = Record[Idx++];
1126 E->ClosingBrace = ReadSourceLocation(Record, Idx);
1127
1128 // Read capture initializers.
1129 for (LambdaExpr::capture_init_iterator C = E->capture_init_begin(),
1130 CEnd = E->capture_init_end();
1131 C != CEnd; ++C)
1132 *C = Reader.ReadSubExpr();
1133
1134 // Read array capture index variables.
1135 if (NumArrayIndexVars > 0) {
1136 unsigned *ArrayIndexStarts = E->getArrayIndexStarts();
1137 for (unsigned I = 0; I != NumCaptures + 1; ++I)
1138 ArrayIndexStarts[I] = Record[Idx++];
1139
1140 VarDecl **ArrayIndexVars = E->getArrayIndexVars();
1141 for (unsigned I = 0; I != NumArrayIndexVars; ++I)
1142 ArrayIndexVars[I] = ReadDeclAs<VarDecl>(Record, Idx);
1143 }
Douglas Gregor01d08012012-02-07 10:09:13 +00001144}
1145
Sebastian Redl60adf4a2010-08-18 23:56:52 +00001146void ASTStmtReader::VisitCXXNamedCastExpr(CXXNamedCastExpr *E) {
Argyrios Kyrtzidis919e6932010-06-28 22:28:35 +00001147 VisitExplicitCastExpr(E);
Douglas Gregor1d5d0b92011-01-12 22:41:29 +00001148 SourceRange R = ReadSourceRange(Record, Idx);
1149 E->Loc = R.getBegin();
1150 E->RParenLoc = R.getEnd();
Fariborz Jahanianf799ae12013-02-22 22:02:53 +00001151 R = ReadSourceRange(Record, Idx);
1152 E->AngleBrackets = R;
Sam Weinigce757a72010-01-16 21:21:01 +00001153}
1154
Sebastian Redl60adf4a2010-08-18 23:56:52 +00001155void ASTStmtReader::VisitCXXStaticCastExpr(CXXStaticCastExpr *E) {
Sam Weinigce757a72010-01-16 21:21:01 +00001156 return VisitCXXNamedCastExpr(E);
1157}
1158
Sebastian Redl60adf4a2010-08-18 23:56:52 +00001159void ASTStmtReader::VisitCXXDynamicCastExpr(CXXDynamicCastExpr *E) {
Sam Weinigce757a72010-01-16 21:21:01 +00001160 return VisitCXXNamedCastExpr(E);
1161}
1162
Sebastian Redl60adf4a2010-08-18 23:56:52 +00001163void ASTStmtReader::VisitCXXReinterpretCastExpr(CXXReinterpretCastExpr *E) {
Sam Weinigce757a72010-01-16 21:21:01 +00001164 return VisitCXXNamedCastExpr(E);
1165}
1166
Sebastian Redl60adf4a2010-08-18 23:56:52 +00001167void ASTStmtReader::VisitCXXConstCastExpr(CXXConstCastExpr *E) {
Sam Weinigce757a72010-01-16 21:21:01 +00001168 return VisitCXXNamedCastExpr(E);
1169}
1170
Sebastian Redl60adf4a2010-08-18 23:56:52 +00001171void ASTStmtReader::VisitCXXFunctionalCastExpr(CXXFunctionalCastExpr *E) {
Argyrios Kyrtzidis919e6932010-06-28 22:28:35 +00001172 VisitExplicitCastExpr(E);
Sebastian Redlc3632732010-10-05 15:59:54 +00001173 E->setTypeBeginLoc(ReadSourceLocation(Record, Idx));
1174 E->setRParenLoc(ReadSourceLocation(Record, Idx));
Sam Weinigce757a72010-01-16 21:21:01 +00001175}
1176
Richard Smith9fcce652012-03-07 08:35:16 +00001177void ASTStmtReader::VisitUserDefinedLiteral(UserDefinedLiteral *E) {
1178 VisitCallExpr(E);
1179 E->UDSuffixLoc = ReadSourceLocation(Record, Idx);
1180}
1181
Sebastian Redl60adf4a2010-08-18 23:56:52 +00001182void ASTStmtReader::VisitCXXBoolLiteralExpr(CXXBoolLiteralExpr *E) {
Sam Weinigeb7f9612010-02-07 06:32:43 +00001183 VisitExpr(E);
1184 E->setValue(Record[Idx++]);
Sebastian Redlc3632732010-10-05 15:59:54 +00001185 E->setLocation(ReadSourceLocation(Record, Idx));
Sam Weinigeb7f9612010-02-07 06:32:43 +00001186}
1187
Sebastian Redl60adf4a2010-08-18 23:56:52 +00001188void ASTStmtReader::VisitCXXNullPtrLiteralExpr(CXXNullPtrLiteralExpr *E) {
Sam Weinigeb7f9612010-02-07 06:32:43 +00001189 VisitExpr(E);
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::VisitCXXTypeidExpr(CXXTypeidExpr *E) {
Chris Lattner14ab24f2010-05-09 06:03:39 +00001194 VisitExpr(E);
Sebastian Redlc3632732010-10-05 15:59:54 +00001195 E->setSourceRange(ReadSourceRange(Record, Idx));
Chris Lattner14ab24f2010-05-09 06:03:39 +00001196 if (E->isTypeOperand()) { // typeid(int)
Sebastian Redl577d4792010-07-22 22:43:28 +00001197 E->setTypeOperandSourceInfo(
Sebastian Redlc3632732010-10-05 15:59:54 +00001198 GetTypeSourceInfo(Record, Idx));
Argyrios Kyrtzidis919e6932010-06-28 22:28:35 +00001199 return;
Chris Lattner14ab24f2010-05-09 06:03:39 +00001200 }
1201
1202 // typeid(42+2)
Argyrios Kyrtzidisd98a2ab2010-06-29 22:46:25 +00001203 E->setExprOperand(Reader.ReadSubExpr());
Chris Lattner14ab24f2010-05-09 06:03:39 +00001204}
1205
Sebastian Redl60adf4a2010-08-18 23:56:52 +00001206void ASTStmtReader::VisitCXXThisExpr(CXXThisExpr *E) {
Chris Lattner2fbdfcd2010-05-09 06:15:05 +00001207 VisitExpr(E);
Sebastian Redlc3632732010-10-05 15:59:54 +00001208 E->setLocation(ReadSourceLocation(Record, Idx));
Chris Lattner2fbdfcd2010-05-09 06:15:05 +00001209 E->setImplicit(Record[Idx++]);
Chris Lattner2fbdfcd2010-05-09 06:15:05 +00001210}
1211
Sebastian Redl60adf4a2010-08-18 23:56:52 +00001212void ASTStmtReader::VisitCXXThrowExpr(CXXThrowExpr *E) {
Chris Lattner2fbdfcd2010-05-09 06:15:05 +00001213 VisitExpr(E);
Douglas Gregorbca01b42011-07-06 22:04:06 +00001214 E->ThrowLoc = ReadSourceLocation(Record, Idx);
1215 E->Op = Reader.ReadSubExpr();
1216 E->IsThrownVariableInScope = Record[Idx++];
Chris Lattner2fbdfcd2010-05-09 06:15:05 +00001217}
Chris Lattner14ab24f2010-05-09 06:03:39 +00001218
Sebastian Redl60adf4a2010-08-18 23:56:52 +00001219void ASTStmtReader::VisitCXXDefaultArgExpr(CXXDefaultArgExpr *E) {
Chris Lattner030854b2010-05-09 06:40:08 +00001220 VisitExpr(E);
Argyrios Kyrtzidis8a507332010-07-02 23:30:15 +00001221
Douglas Gregordf226552011-09-23 22:07:41 +00001222 assert((bool)Record[Idx] == E->Param.getInt() && "We messed up at creation ?");
Argyrios Kyrtzidis8a507332010-07-02 23:30:15 +00001223 ++Idx; // HasOtherExprStored and SubExpr was handled during creation.
Douglas Gregor409448c2011-07-21 22:35:25 +00001224 E->Param.setPointer(ReadDeclAs<ParmVarDecl>(Record, Idx));
Sebastian Redlc3632732010-10-05 15:59:54 +00001225 E->Loc = ReadSourceLocation(Record, Idx);
Chris Lattnerd2598362010-05-10 00:25:06 +00001226}
1227
Sebastian Redl60adf4a2010-08-18 23:56:52 +00001228void ASTStmtReader::VisitCXXBindTemporaryExpr(CXXBindTemporaryExpr *E) {
Chris Lattnerd2598362010-05-10 00:25:06 +00001229 VisitExpr(E);
Douglas Gregor409448c2011-07-21 22:35:25 +00001230 E->setTemporary(Reader.ReadCXXTemporary(F, Record, Idx));
Argyrios Kyrtzidisd98a2ab2010-06-29 22:46:25 +00001231 E->setSubExpr(Reader.ReadSubExpr());
Chris Lattnerd2598362010-05-10 00:25:06 +00001232}
1233
Sebastian Redl60adf4a2010-08-18 23:56:52 +00001234void ASTStmtReader::VisitCXXScalarValueInitExpr(CXXScalarValueInitExpr *E) {
Chris Lattner59218632010-05-10 01:22:27 +00001235 VisitExpr(E);
Sebastian Redlc3632732010-10-05 15:59:54 +00001236 E->TypeInfo = GetTypeSourceInfo(Record, Idx);
1237 E->RParenLoc = ReadSourceLocation(Record, Idx);
Chris Lattner59218632010-05-10 01:22:27 +00001238}
1239
Sebastian Redl60adf4a2010-08-18 23:56:52 +00001240void ASTStmtReader::VisitCXXNewExpr(CXXNewExpr *E) {
Chris Lattner59218632010-05-10 01:22:27 +00001241 VisitExpr(E);
John McCall6ec278d2011-01-27 09:37:56 +00001242 E->GlobalNew = Record[Idx++];
Sebastian Redl1548d142012-02-16 11:35:52 +00001243 bool isArray = Record[Idx++];
Sebastian Redl2aed8b82012-02-16 12:22:20 +00001244 E->UsualArrayDeleteWantsSize = Record[Idx++];
Chris Lattner59218632010-05-10 01:22:27 +00001245 unsigned NumPlacementArgs = Record[Idx++];
Sebastian Redl2aed8b82012-02-16 12:22:20 +00001246 E->StoredInitializationStyle = Record[Idx++];
Douglas Gregor409448c2011-07-21 22:35:25 +00001247 E->setOperatorNew(ReadDeclAs<FunctionDecl>(Record, Idx));
1248 E->setOperatorDelete(ReadDeclAs<FunctionDecl>(Record, Idx));
Sebastian Redlc3632732010-10-05 15:59:54 +00001249 E->AllocatedTypeInfo = GetTypeSourceInfo(Record, Idx);
Douglas Gregor83bc2762012-02-20 16:12:14 +00001250 E->TypeIdParens = ReadSourceRange(Record, Idx);
David Blaikie53056412012-11-07 00:12:38 +00001251 E->Range = ReadSourceRange(Record, Idx);
Douglas Gregor83bc2762012-02-20 16:12:14 +00001252 E->DirectInitRange = ReadSourceRange(Record, Idx);
Chandler Carruth428edaf2010-10-25 08:47:36 +00001253
Douglas Gregor35942772011-09-09 21:34:22 +00001254 E->AllocateArgsArray(Reader.getContext(), isArray, NumPlacementArgs,
Sebastian Redl2aed8b82012-02-16 12:22:20 +00001255 E->StoredInitializationStyle != 0);
Chris Lattner59218632010-05-10 01:22:27 +00001256
1257 // Install all the subexpressions.
Chris Lattner59218632010-05-10 01:22:27 +00001258 for (CXXNewExpr::raw_arg_iterator I = E->raw_arg_begin(),e = E->raw_arg_end();
1259 I != e; ++I)
Argyrios Kyrtzidisd98a2ab2010-06-29 22:46:25 +00001260 *I = Reader.ReadSubStmt();
Chris Lattner59218632010-05-10 01:22:27 +00001261}
1262
Sebastian Redl60adf4a2010-08-18 23:56:52 +00001263void ASTStmtReader::VisitCXXDeleteExpr(CXXDeleteExpr *E) {
Argyrios Kyrtzidis95fc98c2010-06-22 17:07:59 +00001264 VisitExpr(E);
Argyrios Kyrtzidisf1b89112010-09-13 20:15:40 +00001265 E->GlobalDelete = Record[Idx++];
1266 E->ArrayForm = Record[Idx++];
Argyrios Kyrtzidis4076dac2010-09-13 20:15:54 +00001267 E->ArrayFormAsWritten = Record[Idx++];
John McCall6ec278d2011-01-27 09:37:56 +00001268 E->UsualArrayDeleteWantsSize = Record[Idx++];
Douglas Gregor409448c2011-07-21 22:35:25 +00001269 E->OperatorDelete = ReadDeclAs<FunctionDecl>(Record, Idx);
Argyrios Kyrtzidisf1b89112010-09-13 20:15:40 +00001270 E->Argument = Reader.ReadSubExpr();
Sebastian Redlc3632732010-10-05 15:59:54 +00001271 E->Loc = ReadSourceLocation(Record, Idx);
Argyrios Kyrtzidis95fc98c2010-06-22 17:07:59 +00001272}
Chris Lattnerd2598362010-05-10 00:25:06 +00001273
Sebastian Redl60adf4a2010-08-18 23:56:52 +00001274void ASTStmtReader::VisitCXXPseudoDestructorExpr(CXXPseudoDestructorExpr *E) {
Argyrios Kyrtzidisde4bd182010-06-28 09:32:03 +00001275 VisitExpr(E);
1276
Douglas Gregorf3db29f2011-02-25 18:19:59 +00001277 E->Base = Reader.ReadSubExpr();
1278 E->IsArrow = Record[Idx++];
1279 E->OperatorLoc = ReadSourceLocation(Record, Idx);
1280 E->QualifierLoc = Reader.ReadNestedNameSpecifierLoc(F, Record, Idx);
1281 E->ScopeType = GetTypeSourceInfo(Record, Idx);
1282 E->ColonColonLoc = ReadSourceLocation(Record, Idx);
1283 E->TildeLoc = ReadSourceLocation(Record, Idx);
Argyrios Kyrtzidisde4bd182010-06-28 09:32:03 +00001284
Douglas Gregor95eab172011-07-28 20:55:49 +00001285 IdentifierInfo *II = Reader.GetIdentifierInfo(F, Record, Idx);
Argyrios Kyrtzidisde4bd182010-06-28 09:32:03 +00001286 if (II)
Sebastian Redlc3632732010-10-05 15:59:54 +00001287 E->setDestroyedType(II, ReadSourceLocation(Record, Idx));
Argyrios Kyrtzidisde4bd182010-06-28 09:32:03 +00001288 else
Sebastian Redlc3632732010-10-05 15:59:54 +00001289 E->setDestroyedType(GetTypeSourceInfo(Record, Idx));
Argyrios Kyrtzidisde4bd182010-06-28 09:32:03 +00001290}
1291
John McCall4765fa02010-12-06 08:20:24 +00001292void ASTStmtReader::VisitExprWithCleanups(ExprWithCleanups *E) {
Chris Lattnerd2598362010-05-10 00:25:06 +00001293 VisitExpr(E);
John McCall80ee6e82011-11-10 05:35:25 +00001294
1295 unsigned NumObjects = Record[Idx++];
1296 assert(NumObjects == E->getNumObjects());
1297 for (unsigned i = 0; i != NumObjects; ++i)
1298 E->getObjectsBuffer()[i] = ReadDeclAs<BlockDecl>(Record, Idx);
1299
1300 E->SubExpr = Reader.ReadSubExpr();
Chris Lattner030854b2010-05-09 06:40:08 +00001301}
1302
Argyrios Kyrtzidis919e6932010-06-28 22:28:35 +00001303void
Sebastian Redl60adf4a2010-08-18 23:56:52 +00001304ASTStmtReader::VisitCXXDependentScopeMemberExpr(CXXDependentScopeMemberExpr *E){
Argyrios Kyrtzidis8dfbd8b2010-06-24 08:57:31 +00001305 VisitExpr(E);
Abramo Bagnarae4b92762012-01-27 09:46:47 +00001306
1307 if (Record[Idx++]) // HasTemplateKWAndArgsInfo
1308 ReadTemplateKWAndArgsInfo(*E->getTemplateKWAndArgsInfo(),
1309 /*NumTemplateArgs=*/Record[Idx++]);
Argyrios Kyrtzidis8dfbd8b2010-06-24 08:57:31 +00001310
Douglas Gregor7c3179c2011-02-28 18:50:33 +00001311 E->Base = Reader.ReadSubExpr();
Douglas Gregor393f2492011-07-22 00:38:23 +00001312 E->BaseType = Reader.readType(F, Record, Idx);
Douglas Gregor7c3179c2011-02-28 18:50:33 +00001313 E->IsArrow = Record[Idx++];
1314 E->OperatorLoc = ReadSourceLocation(Record, Idx);
1315 E->QualifierLoc = Reader.ReadNestedNameSpecifierLoc(F, Record, Idx);
Douglas Gregor409448c2011-07-21 22:35:25 +00001316 E->FirstQualifierFoundInScope = ReadDeclAs<NamedDecl>(Record, Idx);
Argyrios Kyrtzidis40451072010-10-15 18:21:24 +00001317 ReadDeclarationNameInfo(E->MemberNameInfo, Record, Idx);
Argyrios Kyrtzidis8dfbd8b2010-06-24 08:57:31 +00001318}
1319
Argyrios Kyrtzidis919e6932010-06-28 22:28:35 +00001320void
Sebastian Redl60adf4a2010-08-18 23:56:52 +00001321ASTStmtReader::VisitDependentScopeDeclRefExpr(DependentScopeDeclRefExpr *E) {
Argyrios Kyrtzidis12dffcd2010-06-28 09:31:56 +00001322 VisitExpr(E);
Abramo Bagnarae4b92762012-01-27 09:46:47 +00001323
1324 if (Record[Idx++]) // HasTemplateKWAndArgsInfo
1325 ReadTemplateKWAndArgsInfo(*E->getTemplateKWAndArgsInfo(),
1326 /*NumTemplateArgs=*/Record[Idx++]);
Douglas Gregor00cf3cc2011-02-25 20:49:16 +00001327
1328 E->QualifierLoc = Reader.ReadNestedNameSpecifierLoc(F, Record, Idx);
Argyrios Kyrtzidis40451072010-10-15 18:21:24 +00001329 ReadDeclarationNameInfo(E->NameInfo, Record, Idx);
Argyrios Kyrtzidis12dffcd2010-06-28 09:31:56 +00001330}
1331
Argyrios Kyrtzidis919e6932010-06-28 22:28:35 +00001332void
Sebastian Redl60adf4a2010-08-18 23:56:52 +00001333ASTStmtReader::VisitCXXUnresolvedConstructExpr(CXXUnresolvedConstructExpr *E) {
Argyrios Kyrtzidis8dfbd8b2010-06-24 08:57:31 +00001334 VisitExpr(E);
1335 assert(Record[Idx] == E->arg_size() && "Read wrong record during creation ?");
1336 ++Idx; // NumArgs;
1337 for (unsigned I = 0, N = E->arg_size(); I != N; ++I)
Argyrios Kyrtzidisd98a2ab2010-06-29 22:46:25 +00001338 E->setArg(I, Reader.ReadSubExpr());
Sebastian Redlc3632732010-10-05 15:59:54 +00001339 E->Type = GetTypeSourceInfo(Record, Idx);
1340 E->setLParenLoc(ReadSourceLocation(Record, Idx));
1341 E->setRParenLoc(ReadSourceLocation(Record, Idx));
Argyrios Kyrtzidis8dfbd8b2010-06-24 08:57:31 +00001342}
1343
Sebastian Redl60adf4a2010-08-18 23:56:52 +00001344void ASTStmtReader::VisitOverloadExpr(OverloadExpr *E) {
Argyrios Kyrtzidisa77eb082010-06-25 09:03:26 +00001345 VisitExpr(E);
Abramo Bagnarae4b92762012-01-27 09:46:47 +00001346
1347 if (Record[Idx++]) // HasTemplateKWAndArgsInfo
1348 ReadTemplateKWAndArgsInfo(*E->getTemplateKWAndArgsInfo(),
1349 /*NumTemplateArgs=*/Record[Idx++]);
Argyrios Kyrtzidisa77eb082010-06-25 09:03:26 +00001350
1351 unsigned NumDecls = Record[Idx++];
1352 UnresolvedSet<8> Decls;
1353 for (unsigned i = 0; i != NumDecls; ++i) {
Douglas Gregor409448c2011-07-21 22:35:25 +00001354 NamedDecl *D = ReadDeclAs<NamedDecl>(Record, Idx);
Argyrios Kyrtzidisa77eb082010-06-25 09:03:26 +00001355 AccessSpecifier AS = (AccessSpecifier)Record[Idx++];
1356 Decls.addDecl(D, AS);
1357 }
Douglas Gregor35942772011-09-09 21:34:22 +00001358 E->initializeResults(Reader.getContext(), Decls.begin(), Decls.end());
Argyrios Kyrtzidisa77eb082010-06-25 09:03:26 +00001359
Argyrios Kyrtzidis40451072010-10-15 18:21:24 +00001360 ReadDeclarationNameInfo(E->NameInfo, Record, Idx);
Douglas Gregor4c9be892011-02-28 20:01:57 +00001361 E->QualifierLoc = Reader.ReadNestedNameSpecifierLoc(F, Record, Idx);
Argyrios Kyrtzidisa77eb082010-06-25 09:03:26 +00001362}
1363
Sebastian Redl60adf4a2010-08-18 23:56:52 +00001364void ASTStmtReader::VisitUnresolvedMemberExpr(UnresolvedMemberExpr *E) {
Argyrios Kyrtzidis919e6932010-06-28 22:28:35 +00001365 VisitOverloadExpr(E);
Douglas Gregor4c9be892011-02-28 20:01:57 +00001366 E->IsArrow = Record[Idx++];
1367 E->HasUnresolvedUsing = Record[Idx++];
1368 E->Base = Reader.ReadSubExpr();
Douglas Gregor393f2492011-07-22 00:38:23 +00001369 E->BaseType = Reader.readType(F, Record, Idx);
Douglas Gregor4c9be892011-02-28 20:01:57 +00001370 E->OperatorLoc = ReadSourceLocation(Record, Idx);
Argyrios Kyrtzidisa77eb082010-06-25 09:03:26 +00001371}
1372
Sebastian Redl60adf4a2010-08-18 23:56:52 +00001373void ASTStmtReader::VisitUnresolvedLookupExpr(UnresolvedLookupExpr *E) {
Argyrios Kyrtzidis919e6932010-06-28 22:28:35 +00001374 VisitOverloadExpr(E);
Douglas Gregor4c9be892011-02-28 20:01:57 +00001375 E->RequiresADL = Record[Idx++];
1376 E->Overloaded = Record[Idx++];
Douglas Gregor409448c2011-07-21 22:35:25 +00001377 E->NamingClass = ReadDeclAs<CXXRecordDecl>(Record, Idx);
Argyrios Kyrtzidisbd65bb52010-06-25 09:03:34 +00001378}
1379
Sebastian Redl60adf4a2010-08-18 23:56:52 +00001380void ASTStmtReader::VisitUnaryTypeTraitExpr(UnaryTypeTraitExpr *E) {
Argyrios Kyrtzidis6d00c132010-07-10 11:46:15 +00001381 VisitExpr(E);
1382 E->UTT = (UnaryTypeTrait)Record[Idx++];
Sebastian Redl0dfd8482010-09-13 20:56:31 +00001383 E->Value = (bool)Record[Idx++];
Sebastian Redlc3632732010-10-05 15:59:54 +00001384 SourceRange Range = ReadSourceRange(Record, Idx);
Argyrios Kyrtzidis6d00c132010-07-10 11:46:15 +00001385 E->Loc = Range.getBegin();
1386 E->RParen = Range.getEnd();
Sebastian Redlc3632732010-10-05 15:59:54 +00001387 E->QueriedType = GetTypeSourceInfo(Record, Idx);
Argyrios Kyrtzidis6d00c132010-07-10 11:46:15 +00001388}
1389
Francois Pichet6ad6f282010-12-07 00:08:36 +00001390void ASTStmtReader::VisitBinaryTypeTraitExpr(BinaryTypeTraitExpr *E) {
1391 VisitExpr(E);
1392 E->BTT = (BinaryTypeTrait)Record[Idx++];
1393 E->Value = (bool)Record[Idx++];
1394 SourceRange Range = ReadSourceRange(Record, Idx);
1395 E->Loc = Range.getBegin();
1396 E->RParen = Range.getEnd();
1397 E->LhsType = GetTypeSourceInfo(Record, Idx);
1398 E->RhsType = GetTypeSourceInfo(Record, Idx);
1399}
1400
Douglas Gregor4ca8ac22012-02-24 07:38:34 +00001401void ASTStmtReader::VisitTypeTraitExpr(TypeTraitExpr *E) {
1402 VisitExpr(E);
1403 E->TypeTraitExprBits.NumArgs = Record[Idx++];
1404 E->TypeTraitExprBits.Kind = Record[Idx++];
1405 E->TypeTraitExprBits.Value = Record[Idx++];
1406
1407 TypeSourceInfo **Args = E->getTypeSourceInfos();
1408 for (unsigned I = 0, N = E->getNumArgs(); I != N; ++I)
1409 Args[I] = GetTypeSourceInfo(Record, Idx);
1410}
1411
John Wiegley21ff2e52011-04-28 00:16:57 +00001412void ASTStmtReader::VisitArrayTypeTraitExpr(ArrayTypeTraitExpr *E) {
1413 VisitExpr(E);
1414 E->ATT = (ArrayTypeTrait)Record[Idx++];
1415 E->Value = (unsigned int)Record[Idx++];
1416 SourceRange Range = ReadSourceRange(Record, Idx);
1417 E->Loc = Range.getBegin();
1418 E->RParen = Range.getEnd();
1419 E->QueriedType = GetTypeSourceInfo(Record, Idx);
1420}
1421
John Wiegley55262202011-04-25 06:54:41 +00001422void ASTStmtReader::VisitExpressionTraitExpr(ExpressionTraitExpr *E) {
1423 VisitExpr(E);
1424 E->ET = (ExpressionTrait)Record[Idx++];
1425 E->Value = (bool)Record[Idx++];
1426 SourceRange Range = ReadSourceRange(Record, Idx);
1427 E->QueriedExpression = Reader.ReadSubExpr();
1428 E->Loc = Range.getBegin();
1429 E->RParen = Range.getEnd();
1430}
1431
Sebastian Redl6b219d02010-09-10 20:55:54 +00001432void ASTStmtReader::VisitCXXNoexceptExpr(CXXNoexceptExpr *E) {
1433 VisitExpr(E);
Sebastian Redl5221d8f2010-09-10 22:34:40 +00001434 E->Value = (bool)Record[Idx++];
Sebastian Redlc3632732010-10-05 15:59:54 +00001435 E->Range = ReadSourceRange(Record, Idx);
Sebastian Redl5221d8f2010-09-10 22:34:40 +00001436 E->Operand = Reader.ReadSubExpr();
Sebastian Redl6b219d02010-09-10 20:55:54 +00001437}
1438
Douglas Gregorbe230c32011-01-03 17:17:50 +00001439void ASTStmtReader::VisitPackExpansionExpr(PackExpansionExpr *E) {
1440 VisitExpr(E);
1441 E->EllipsisLoc = ReadSourceLocation(Record, Idx);
Douglas Gregor67fd1252011-01-14 21:20:45 +00001442 E->NumExpansions = Record[Idx++];
Douglas Gregorbe230c32011-01-03 17:17:50 +00001443 E->Pattern = Reader.ReadSubExpr();
1444}
1445
Douglas Gregoree8aff02011-01-04 17:33:58 +00001446void ASTStmtReader::VisitSizeOfPackExpr(SizeOfPackExpr *E) {
1447 VisitExpr(E);
1448 E->OperatorLoc = ReadSourceLocation(Record, Idx);
1449 E->PackLoc = ReadSourceLocation(Record, Idx);
1450 E->RParenLoc = ReadSourceLocation(Record, Idx);
1451 E->Length = Record[Idx++];
Douglas Gregor409448c2011-07-21 22:35:25 +00001452 E->Pack = ReadDeclAs<NamedDecl>(Record, Idx);
Douglas Gregoree8aff02011-01-04 17:33:58 +00001453}
1454
John McCall7110fd62011-07-15 07:00:14 +00001455void ASTStmtReader::VisitSubstNonTypeTemplateParmExpr(
1456 SubstNonTypeTemplateParmExpr *E) {
1457 VisitExpr(E);
Douglas Gregor409448c2011-07-21 22:35:25 +00001458 E->Param = ReadDeclAs<NonTypeTemplateParmDecl>(Record, Idx);
John McCall7110fd62011-07-15 07:00:14 +00001459 E->NameLoc = ReadSourceLocation(Record, Idx);
1460 E->Replacement = Reader.ReadSubExpr();
1461}
1462
Douglas Gregorc7793c72011-01-15 01:15:58 +00001463void ASTStmtReader::VisitSubstNonTypeTemplateParmPackExpr(
1464 SubstNonTypeTemplateParmPackExpr *E) {
1465 VisitExpr(E);
Douglas Gregor409448c2011-07-21 22:35:25 +00001466 E->Param = ReadDeclAs<NonTypeTemplateParmDecl>(Record, Idx);
Douglas Gregorc7793c72011-01-15 01:15:58 +00001467 TemplateArgument ArgPack = Reader.ReadTemplateArgument(F, Record, Idx);
1468 if (ArgPack.getKind() != TemplateArgument::Pack)
1469 return;
1470
1471 E->Arguments = ArgPack.pack_begin();
1472 E->NumArguments = ArgPack.pack_size();
1473 E->NameLoc = ReadSourceLocation(Record, Idx);
1474}
1475
Richard Smith9a4db032012-09-12 00:56:43 +00001476void ASTStmtReader::VisitFunctionParmPackExpr(FunctionParmPackExpr *E) {
1477 VisitExpr(E);
1478 E->NumParameters = Record[Idx++];
1479 E->ParamPack = ReadDeclAs<ParmVarDecl>(Record, Idx);
1480 E->NameLoc = ReadSourceLocation(Record, Idx);
1481 ParmVarDecl **Parms = reinterpret_cast<ParmVarDecl**>(E+1);
1482 for (unsigned i = 0, n = E->NumParameters; i != n; ++i)
1483 Parms[i] = ReadDeclAs<ParmVarDecl>(Record, Idx);
1484}
1485
Douglas Gregor03e80032011-06-21 17:03:29 +00001486void ASTStmtReader::VisitMaterializeTemporaryExpr(MaterializeTemporaryExpr *E) {
1487 VisitExpr(E);
1488 E->Temporary = Reader.ReadSubExpr();
1489}
1490
John McCall7cd7d1a2010-11-15 23:31:06 +00001491void ASTStmtReader::VisitOpaqueValueExpr(OpaqueValueExpr *E) {
1492 VisitExpr(E);
Argyrios Kyrtzidis8bc27822011-12-03 03:49:52 +00001493 E->SourceExpr = Reader.ReadSubExpr();
Douglas Gregorb608b982011-01-28 02:26:04 +00001494 E->Loc = ReadSourceLocation(Record, Idx);
John McCall7cd7d1a2010-11-15 23:31:06 +00001495}
1496
Peter Collingbournee08ce652011-02-09 21:07:24 +00001497//===----------------------------------------------------------------------===//
John McCall7110fd62011-07-15 07:00:14 +00001498// Microsoft Expressions and Statements
1499//===----------------------------------------------------------------------===//
1500void ASTStmtReader::VisitCXXUuidofExpr(CXXUuidofExpr *E) {
1501 VisitExpr(E);
1502 E->setSourceRange(ReadSourceRange(Record, Idx));
1503 if (E->isTypeOperand()) { // __uuidof(ComType)
1504 E->setTypeOperandSourceInfo(
1505 GetTypeSourceInfo(Record, Idx));
1506 return;
1507 }
1508
1509 // __uuidof(expr)
1510 E->setExprOperand(Reader.ReadSubExpr());
1511}
1512
1513void ASTStmtReader::VisitSEHExceptStmt(SEHExceptStmt *S) {
1514 VisitStmt(S);
1515 S->Loc = ReadSourceLocation(Record, Idx);
1516 S->Children[SEHExceptStmt::FILTER_EXPR] = Reader.ReadSubStmt();
1517 S->Children[SEHExceptStmt::BLOCK] = Reader.ReadSubStmt();
1518}
1519
1520void ASTStmtReader::VisitSEHFinallyStmt(SEHFinallyStmt *S) {
1521 VisitStmt(S);
1522 S->Loc = ReadSourceLocation(Record, Idx);
1523 S->Block = Reader.ReadSubStmt();
1524}
1525
1526void ASTStmtReader::VisitSEHTryStmt(SEHTryStmt *S) {
1527 VisitStmt(S);
1528 S->IsCXXTry = Record[Idx++];
1529 S->TryLoc = ReadSourceLocation(Record, Idx);
1530 S->Children[SEHTryStmt::TRY] = Reader.ReadSubStmt();
1531 S->Children[SEHTryStmt::HANDLER] = Reader.ReadSubStmt();
1532}
1533
1534//===----------------------------------------------------------------------===//
Peter Collingbournee08ce652011-02-09 21:07:24 +00001535// CUDA Expressions and Statements
1536//===----------------------------------------------------------------------===//
1537
1538void ASTStmtReader::VisitCUDAKernelCallExpr(CUDAKernelCallExpr *E) {
1539 VisitCallExpr(E);
1540 E->setConfig(cast<CallExpr>(Reader.ReadSubExpr()));
1541}
1542
John McCall7110fd62011-07-15 07:00:14 +00001543//===----------------------------------------------------------------------===//
1544// OpenCL Expressions and Statements.
1545//===----------------------------------------------------------------------===//
1546void ASTStmtReader::VisitAsTypeExpr(AsTypeExpr *E) {
1547 VisitExpr(E);
1548 E->BuiltinLoc = ReadSourceLocation(Record, Idx);
1549 E->RParenLoc = ReadSourceLocation(Record, Idx);
1550 E->SrcExpr = Reader.ReadSubExpr();
1551}
1552
1553//===----------------------------------------------------------------------===//
1554// ASTReader Implementation
1555//===----------------------------------------------------------------------===//
1556
Douglas Gregor1a4761e2011-11-30 23:21:26 +00001557Stmt *ASTReader::ReadStmt(ModuleFile &F) {
Argyrios Kyrtzidis919e6932010-06-28 22:28:35 +00001558 switch (ReadingKind) {
1559 case Read_Decl:
1560 case Read_Type:
Sebastian Redlc3632732010-10-05 15:59:54 +00001561 return ReadStmtFromStream(F);
Argyrios Kyrtzidis919e6932010-06-28 22:28:35 +00001562 case Read_Stmt:
Argyrios Kyrtzidisd98a2ab2010-06-29 22:46:25 +00001563 return ReadSubStmt();
Argyrios Kyrtzidis919e6932010-06-28 22:28:35 +00001564 }
1565
1566 llvm_unreachable("ReadingKind not set ?");
Argyrios Kyrtzidis919e6932010-06-28 22:28:35 +00001567}
1568
Douglas Gregor1a4761e2011-11-30 23:21:26 +00001569Expr *ASTReader::ReadExpr(ModuleFile &F) {
Sebastian Redlc3632732010-10-05 15:59:54 +00001570 return cast_or_null<Expr>(ReadStmt(F));
Argyrios Kyrtzidis919e6932010-06-28 22:28:35 +00001571}
Chris Lattner030854b2010-05-09 06:40:08 +00001572
Sebastian Redlc43b54c2010-08-18 23:56:43 +00001573Expr *ASTReader::ReadSubExpr() {
Argyrios Kyrtzidisd98a2ab2010-06-29 22:46:25 +00001574 return cast_or_null<Expr>(ReadSubStmt());
1575}
1576
Chris Lattner52e97d12009-04-27 05:41:06 +00001577// Within the bitstream, expressions are stored in Reverse Polish
1578// Notation, with each of the subexpressions preceding the
Argyrios Kyrtzidis919e6932010-06-28 22:28:35 +00001579// expression they are stored in. Subexpressions are stored from last to first.
1580// To evaluate expressions, we continue reading expressions and placing them on
1581// the stack, with expressions having operands removing those operands from the
Chris Lattner52e97d12009-04-27 05:41:06 +00001582// stack. Evaluation terminates when we see a STMT_STOP record, and
1583// the single remaining expression on the stack is our result.
Douglas Gregor1a4761e2011-11-30 23:21:26 +00001584Stmt *ASTReader::ReadStmtFromStream(ModuleFile &F) {
Argyrios Kyrtzidis919e6932010-06-28 22:28:35 +00001585
1586 ReadingKindTracker ReadingKind(Read_Stmt, *this);
Sebastian Redlc3632732010-10-05 15:59:54 +00001587 llvm::BitstreamCursor &Cursor = F.DeclsCursor;
Argyrios Kyrtzidise6f08682011-10-21 23:02:28 +00001588
1589 // Map of offset to previously deserialized stmt. The offset points
1590 /// just after the stmt record.
1591 llvm::DenseMap<uint64_t, Stmt *> StmtEntries;
Sebastian Redlc3632732010-10-05 15:59:54 +00001592
Argyrios Kyrtzidis919e6932010-06-28 22:28:35 +00001593#ifndef NDEBUG
1594 unsigned PrevNumStmts = StmtStack.size();
1595#endif
1596
Chris Lattner4c6f9522009-04-27 05:14:47 +00001597 RecordData Record;
1598 unsigned Idx;
Sebastian Redlc3632732010-10-05 15:59:54 +00001599 ASTStmtReader Reader(*this, F, Cursor, Record, Idx);
Chris Lattner4c6f9522009-04-27 05:14:47 +00001600 Stmt::EmptyShell Empty;
1601
1602 while (true) {
Chris Lattnerb3ce3572013-01-20 02:38:54 +00001603 llvm::BitstreamEntry Entry = Cursor.advanceSkippingSubblocks();
1604
1605 switch (Entry.Kind) {
1606 case llvm::BitstreamEntry::SubBlock: // Handled for us already.
1607 case llvm::BitstreamEntry::Error:
1608 Error("malformed block record in AST file");
1609 return 0;
1610 case llvm::BitstreamEntry::EndBlock:
1611 goto Done;
1612 case llvm::BitstreamEntry::Record:
1613 // The interesting case.
Chris Lattner4c6f9522009-04-27 05:14:47 +00001614 break;
1615 }
1616
Chris Lattner4c6f9522009-04-27 05:14:47 +00001617
1618 Stmt *S = 0;
1619 Idx = 0;
1620 Record.clear();
1621 bool Finished = false;
Argyrios Kyrtzidise6f08682011-10-21 23:02:28 +00001622 bool IsStmtReference = false;
Chris Lattnerb3ce3572013-01-20 02:38:54 +00001623 switch ((StmtCode)Cursor.readRecord(Entry.ID, Record)) {
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001624 case STMT_STOP:
Chris Lattner4c6f9522009-04-27 05:14:47 +00001625 Finished = true;
1626 break;
1627
Argyrios Kyrtzidise6f08682011-10-21 23:02:28 +00001628 case STMT_REF_PTR:
1629 IsStmtReference = true;
1630 assert(StmtEntries.find(Record[0]) != StmtEntries.end() &&
1631 "No stmt was recorded for this offset reference!");
1632 S = StmtEntries[Record[Idx++]];
1633 break;
1634
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001635 case STMT_NULL_PTR:
Mike Stump1eb44332009-09-09 15:08:12 +00001636 S = 0;
Chris Lattner4c6f9522009-04-27 05:14:47 +00001637 break;
1638
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001639 case STMT_NULL:
Chris Lattner4c6f9522009-04-27 05:14:47 +00001640 S = new (Context) NullStmt(Empty);
1641 break;
1642
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001643 case STMT_COMPOUND:
Chris Lattner4c6f9522009-04-27 05:14:47 +00001644 S = new (Context) CompoundStmt(Empty);
1645 break;
1646
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001647 case STMT_CASE:
Chris Lattner4c6f9522009-04-27 05:14:47 +00001648 S = new (Context) CaseStmt(Empty);
1649 break;
1650
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001651 case STMT_DEFAULT:
Chris Lattner4c6f9522009-04-27 05:14:47 +00001652 S = new (Context) DefaultStmt(Empty);
1653 break;
1654
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001655 case STMT_LABEL:
Chris Lattner4c6f9522009-04-27 05:14:47 +00001656 S = new (Context) LabelStmt(Empty);
1657 break;
1658
Richard Smith534986f2012-04-14 00:33:13 +00001659 case STMT_ATTRIBUTED:
Alexander Kornienko49908902012-07-09 10:04:07 +00001660 S = AttributedStmt::CreateEmpty(
1661 Context,
1662 /*NumAttrs*/Record[ASTStmtReader::NumStmtFields]);
Richard Smith534986f2012-04-14 00:33:13 +00001663 break;
1664
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001665 case STMT_IF:
Chris Lattner4c6f9522009-04-27 05:14:47 +00001666 S = new (Context) IfStmt(Empty);
1667 break;
1668
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001669 case STMT_SWITCH:
Chris Lattner4c6f9522009-04-27 05:14:47 +00001670 S = new (Context) SwitchStmt(Empty);
1671 break;
1672
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001673 case STMT_WHILE:
Chris Lattner4c6f9522009-04-27 05:14:47 +00001674 S = new (Context) WhileStmt(Empty);
1675 break;
1676
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001677 case STMT_DO:
Chris Lattner4c6f9522009-04-27 05:14:47 +00001678 S = new (Context) DoStmt(Empty);
1679 break;
Mike Stump1eb44332009-09-09 15:08:12 +00001680
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001681 case STMT_FOR:
Chris Lattner4c6f9522009-04-27 05:14:47 +00001682 S = new (Context) ForStmt(Empty);
1683 break;
1684
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001685 case STMT_GOTO:
Chris Lattner4c6f9522009-04-27 05:14:47 +00001686 S = new (Context) GotoStmt(Empty);
1687 break;
Mike Stump1eb44332009-09-09 15:08:12 +00001688
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001689 case STMT_INDIRECT_GOTO:
Chris Lattner4c6f9522009-04-27 05:14:47 +00001690 S = new (Context) IndirectGotoStmt(Empty);
1691 break;
1692
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001693 case STMT_CONTINUE:
Chris Lattner4c6f9522009-04-27 05:14:47 +00001694 S = new (Context) ContinueStmt(Empty);
1695 break;
1696
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001697 case STMT_BREAK:
Chris Lattner4c6f9522009-04-27 05:14:47 +00001698 S = new (Context) BreakStmt(Empty);
1699 break;
1700
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001701 case STMT_RETURN:
Chris Lattner4c6f9522009-04-27 05:14:47 +00001702 S = new (Context) ReturnStmt(Empty);
1703 break;
1704
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001705 case STMT_DECL:
Chris Lattner4c6f9522009-04-27 05:14:47 +00001706 S = new (Context) DeclStmt(Empty);
1707 break;
1708
Chad Rosierdf5faf52012-08-25 00:11:56 +00001709 case STMT_GCCASM:
1710 S = new (Context) GCCAsmStmt(Empty);
Chris Lattner4c6f9522009-04-27 05:14:47 +00001711 break;
1712
Chad Rosiercd518a02012-08-24 23:51:02 +00001713 case STMT_MSASM:
1714 S = new (Context) MSAsmStmt(Empty);
1715 break;
1716
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001717 case EXPR_PREDEFINED:
Chris Lattner4c6f9522009-04-27 05:14:47 +00001718 S = new (Context) PredefinedExpr(Empty);
1719 break;
Mike Stump1eb44332009-09-09 15:08:12 +00001720
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001721 case EXPR_DECL_REF:
Chandler Carruth3aa81402011-05-01 23:48:14 +00001722 S = DeclRefExpr::CreateEmpty(
Douglas Gregor35942772011-09-09 21:34:22 +00001723 Context,
Chandler Carruth3aa81402011-05-01 23:48:14 +00001724 /*HasQualifier=*/Record[ASTStmtReader::NumExprFields],
1725 /*HasFoundDecl=*/Record[ASTStmtReader::NumExprFields + 1],
Abramo Bagnarae4b92762012-01-27 09:46:47 +00001726 /*HasTemplateKWAndArgsInfo=*/Record[ASTStmtReader::NumExprFields + 2],
Chandler Carruth3aa81402011-05-01 23:48:14 +00001727 /*NumTemplateArgs=*/Record[ASTStmtReader::NumExprFields + 2] ?
John McCallf4b88a42012-03-10 09:33:50 +00001728 Record[ASTStmtReader::NumExprFields + 5] : 0);
Chris Lattner4c6f9522009-04-27 05:14:47 +00001729 break;
Mike Stump1eb44332009-09-09 15:08:12 +00001730
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001731 case EXPR_INTEGER_LITERAL:
Douglas Gregor35942772011-09-09 21:34:22 +00001732 S = IntegerLiteral::Create(Context, Empty);
Chris Lattner4c6f9522009-04-27 05:14:47 +00001733 break;
Mike Stump1eb44332009-09-09 15:08:12 +00001734
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001735 case EXPR_FLOATING_LITERAL:
Douglas Gregor35942772011-09-09 21:34:22 +00001736 S = FloatingLiteral::Create(Context, Empty);
Chris Lattner4c6f9522009-04-27 05:14:47 +00001737 break;
Mike Stump1eb44332009-09-09 15:08:12 +00001738
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001739 case EXPR_IMAGINARY_LITERAL:
Chris Lattner4c6f9522009-04-27 05:14:47 +00001740 S = new (Context) ImaginaryLiteral(Empty);
1741 break;
1742
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001743 case EXPR_STRING_LITERAL:
Douglas Gregor35942772011-09-09 21:34:22 +00001744 S = StringLiteral::CreateEmpty(Context,
Sebastian Redl60adf4a2010-08-18 23:56:52 +00001745 Record[ASTStmtReader::NumExprFields + 1]);
Chris Lattner4c6f9522009-04-27 05:14:47 +00001746 break;
1747
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001748 case EXPR_CHARACTER_LITERAL:
Chris Lattner4c6f9522009-04-27 05:14:47 +00001749 S = new (Context) CharacterLiteral(Empty);
1750 break;
1751
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001752 case EXPR_PAREN:
Chris Lattner4c6f9522009-04-27 05:14:47 +00001753 S = new (Context) ParenExpr(Empty);
1754 break;
1755
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001756 case EXPR_PAREN_LIST:
Argyrios Kyrtzidis37bdfe22010-06-30 08:49:18 +00001757 S = new (Context) ParenListExpr(Empty);
1758 break;
1759
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001760 case EXPR_UNARY_OPERATOR:
Chris Lattner4c6f9522009-04-27 05:14:47 +00001761 S = new (Context) UnaryOperator(Empty);
1762 break;
1763
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001764 case EXPR_OFFSETOF:
Douglas Gregor35942772011-09-09 21:34:22 +00001765 S = OffsetOfExpr::CreateEmpty(Context,
Sebastian Redl60adf4a2010-08-18 23:56:52 +00001766 Record[ASTStmtReader::NumExprFields],
1767 Record[ASTStmtReader::NumExprFields + 1]);
Douglas Gregor8ecdb652010-04-28 22:16:22 +00001768 break;
1769
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001770 case EXPR_SIZEOF_ALIGN_OF:
Peter Collingbournef4e3cfb2011-03-11 19:24:49 +00001771 S = new (Context) UnaryExprOrTypeTraitExpr(Empty);
Chris Lattner4c6f9522009-04-27 05:14:47 +00001772 break;
1773
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001774 case EXPR_ARRAY_SUBSCRIPT:
Chris Lattner4c6f9522009-04-27 05:14:47 +00001775 S = new (Context) ArraySubscriptExpr(Empty);
1776 break;
1777
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001778 case EXPR_CALL:
Douglas Gregor35942772011-09-09 21:34:22 +00001779 S = new (Context) CallExpr(Context, Stmt::CallExprClass, Empty);
Chris Lattner4c6f9522009-04-27 05:14:47 +00001780 break;
1781
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001782 case EXPR_MEMBER: {
Argyrios Kyrtzidis663e3802010-07-08 13:09:47 +00001783 // We load everything here and fully initialize it at creation.
1784 // That way we can use MemberExpr::Create and don't have to duplicate its
1785 // logic with a MemberExpr::CreateEmpty.
1786
1787 assert(Idx == 0);
Douglas Gregor40d96a62011-02-28 21:54:11 +00001788 NestedNameSpecifierLoc QualifierLoc;
Argyrios Kyrtzidis663e3802010-07-08 13:09:47 +00001789 if (Record[Idx++]) { // HasQualifier.
Douglas Gregor40d96a62011-02-28 21:54:11 +00001790 QualifierLoc = ReadNestedNameSpecifierLoc(F, Record, Idx);
Argyrios Kyrtzidis663e3802010-07-08 13:09:47 +00001791 }
1792
Abramo Bagnarae4b92762012-01-27 09:46:47 +00001793 SourceLocation TemplateKWLoc;
Argyrios Kyrtzidis663e3802010-07-08 13:09:47 +00001794 TemplateArgumentListInfo ArgInfo;
Abramo Bagnarae4b92762012-01-27 09:46:47 +00001795 bool HasTemplateKWAndArgsInfo = Record[Idx++];
1796 if (HasTemplateKWAndArgsInfo) {
1797 TemplateKWLoc = ReadSourceLocation(F, Record, Idx);
Douglas Gregordef03542011-02-04 12:01:24 +00001798 unsigned NumTemplateArgs = Record[Idx++];
Sebastian Redlc3632732010-10-05 15:59:54 +00001799 ArgInfo.setLAngleLoc(ReadSourceLocation(F, Record, Idx));
1800 ArgInfo.setRAngleLoc(ReadSourceLocation(F, Record, Idx));
Argyrios Kyrtzidis663e3802010-07-08 13:09:47 +00001801 for (unsigned i = 0; i != NumTemplateArgs; ++i)
Sebastian Redlc3632732010-10-05 15:59:54 +00001802 ArgInfo.addArgument(ReadTemplateArgumentLoc(F, Record, Idx));
Argyrios Kyrtzidis663e3802010-07-08 13:09:47 +00001803 }
Abramo Bagnara7cc58b42011-10-05 07:56:41 +00001804
1805 bool HadMultipleCandidates = Record[Idx++];
1806
Douglas Gregor409448c2011-07-21 22:35:25 +00001807 NamedDecl *FoundD = ReadDeclAs<NamedDecl>(F, Record, Idx);
Argyrios Kyrtzidis663e3802010-07-08 13:09:47 +00001808 AccessSpecifier AS = (AccessSpecifier)Record[Idx++];
1809 DeclAccessPair FoundDecl = DeclAccessPair::make(FoundD, AS);
1810
Douglas Gregor393f2492011-07-22 00:38:23 +00001811 QualType T = readType(F, Record, Idx);
John McCallf89e55a2010-11-18 06:31:45 +00001812 ExprValueKind VK = static_cast<ExprValueKind>(Record[Idx++]);
1813 ExprObjectKind OK = static_cast<ExprObjectKind>(Record[Idx++]);
Argyrios Kyrtzidis663e3802010-07-08 13:09:47 +00001814 Expr *Base = ReadSubExpr();
Douglas Gregor409448c2011-07-21 22:35:25 +00001815 ValueDecl *MemberD = ReadDeclAs<ValueDecl>(F, Record, Idx);
Sebastian Redlc3632732010-10-05 15:59:54 +00001816 SourceLocation MemberLoc = ReadSourceLocation(F, Record, Idx);
Abramo Bagnara25777432010-08-11 22:01:17 +00001817 DeclarationNameInfo MemberNameInfo(MemberD->getDeclName(), MemberLoc);
Argyrios Kyrtzidis663e3802010-07-08 13:09:47 +00001818 bool IsArrow = Record[Idx++];
1819
Douglas Gregor35942772011-09-09 21:34:22 +00001820 S = MemberExpr::Create(Context, Base, IsArrow, QualifierLoc,
Abramo Bagnarae4b92762012-01-27 09:46:47 +00001821 TemplateKWLoc, MemberD, FoundDecl, MemberNameInfo,
1822 HasTemplateKWAndArgsInfo ? &ArgInfo : 0,
1823 T, VK, OK);
Argyrios Kyrtzidis40451072010-10-15 18:21:24 +00001824 ReadDeclarationNameLoc(F, cast<MemberExpr>(S)->MemberDNLoc,
1825 MemberD->getDeclName(), Record, Idx);
Abramo Bagnara7cc58b42011-10-05 07:56:41 +00001826 if (HadMultipleCandidates)
1827 cast<MemberExpr>(S)->setHadMultipleCandidates(true);
Chris Lattner4c6f9522009-04-27 05:14:47 +00001828 break;
Argyrios Kyrtzidis663e3802010-07-08 13:09:47 +00001829 }
Chris Lattner4c6f9522009-04-27 05:14:47 +00001830
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001831 case EXPR_BINARY_OPERATOR:
Chris Lattner4c6f9522009-04-27 05:14:47 +00001832 S = new (Context) BinaryOperator(Empty);
1833 break;
1834
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001835 case EXPR_COMPOUND_ASSIGN_OPERATOR:
Chris Lattner4c6f9522009-04-27 05:14:47 +00001836 S = new (Context) CompoundAssignOperator(Empty);
1837 break;
1838
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001839 case EXPR_CONDITIONAL_OPERATOR:
Chris Lattner4c6f9522009-04-27 05:14:47 +00001840 S = new (Context) ConditionalOperator(Empty);
1841 break;
1842
John McCall56ca35d2011-02-17 10:25:35 +00001843 case EXPR_BINARY_CONDITIONAL_OPERATOR:
1844 S = new (Context) BinaryConditionalOperator(Empty);
1845 break;
1846
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001847 case EXPR_IMPLICIT_CAST:
Douglas Gregor35942772011-09-09 21:34:22 +00001848 S = ImplicitCastExpr::CreateEmpty(Context,
Sebastian Redl60adf4a2010-08-18 23:56:52 +00001849 /*PathSize*/ Record[ASTStmtReader::NumExprFields]);
Chris Lattner4c6f9522009-04-27 05:14:47 +00001850 break;
1851
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001852 case EXPR_CSTYLE_CAST:
Douglas Gregor35942772011-09-09 21:34:22 +00001853 S = CStyleCastExpr::CreateEmpty(Context,
Sebastian Redl60adf4a2010-08-18 23:56:52 +00001854 /*PathSize*/ Record[ASTStmtReader::NumExprFields]);
Chris Lattner4c6f9522009-04-27 05:14:47 +00001855 break;
1856
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001857 case EXPR_COMPOUND_LITERAL:
Chris Lattner4c6f9522009-04-27 05:14:47 +00001858 S = new (Context) CompoundLiteralExpr(Empty);
1859 break;
1860
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001861 case EXPR_EXT_VECTOR_ELEMENT:
Chris Lattner4c6f9522009-04-27 05:14:47 +00001862 S = new (Context) ExtVectorElementExpr(Empty);
1863 break;
1864
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001865 case EXPR_INIT_LIST:
Argyrios Kyrtzidis2a82ca22012-11-28 03:56:16 +00001866 S = new (Context) InitListExpr(Empty);
Chris Lattner4c6f9522009-04-27 05:14:47 +00001867 break;
1868
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001869 case EXPR_DESIGNATED_INIT:
Douglas Gregor35942772011-09-09 21:34:22 +00001870 S = DesignatedInitExpr::CreateEmpty(Context,
Sebastian Redl60adf4a2010-08-18 23:56:52 +00001871 Record[ASTStmtReader::NumExprFields] - 1);
Mike Stump1eb44332009-09-09 15:08:12 +00001872
Chris Lattner4c6f9522009-04-27 05:14:47 +00001873 break;
1874
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001875 case EXPR_IMPLICIT_VALUE_INIT:
Chris Lattner4c6f9522009-04-27 05:14:47 +00001876 S = new (Context) ImplicitValueInitExpr(Empty);
1877 break;
1878
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001879 case EXPR_VA_ARG:
Chris Lattner4c6f9522009-04-27 05:14:47 +00001880 S = new (Context) VAArgExpr(Empty);
1881 break;
1882
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001883 case EXPR_ADDR_LABEL:
Chris Lattner4c6f9522009-04-27 05:14:47 +00001884 S = new (Context) AddrLabelExpr(Empty);
1885 break;
1886
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001887 case EXPR_STMT:
Chris Lattner4c6f9522009-04-27 05:14:47 +00001888 S = new (Context) StmtExpr(Empty);
1889 break;
1890
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001891 case EXPR_CHOOSE:
Chris Lattner4c6f9522009-04-27 05:14:47 +00001892 S = new (Context) ChooseExpr(Empty);
1893 break;
1894
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001895 case EXPR_GNU_NULL:
Chris Lattner4c6f9522009-04-27 05:14:47 +00001896 S = new (Context) GNUNullExpr(Empty);
1897 break;
1898
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001899 case EXPR_SHUFFLE_VECTOR:
Chris Lattner4c6f9522009-04-27 05:14:47 +00001900 S = new (Context) ShuffleVectorExpr(Empty);
1901 break;
Mike Stump1eb44332009-09-09 15:08:12 +00001902
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001903 case EXPR_BLOCK:
Chris Lattner4c6f9522009-04-27 05:14:47 +00001904 S = new (Context) BlockExpr(Empty);
1905 break;
1906
Peter Collingbournef111d932011-04-15 00:35:48 +00001907 case EXPR_GENERIC_SELECTION:
1908 S = new (Context) GenericSelectionExpr(Empty);
1909 break;
1910
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001911 case EXPR_OBJC_STRING_LITERAL:
Chris Lattner4c6f9522009-04-27 05:14:47 +00001912 S = new (Context) ObjCStringLiteral(Empty);
1913 break;
Patrick Beardeb382ec2012-04-19 00:25:12 +00001914 case EXPR_OBJC_BOXED_EXPRESSION:
1915 S = new (Context) ObjCBoxedExpr(Empty);
Ted Kremenekebcb57a2012-03-06 20:05:56 +00001916 break;
1917 case EXPR_OBJC_ARRAY_LITERAL:
1918 S = ObjCArrayLiteral::CreateEmpty(Context,
1919 Record[ASTStmtReader::NumExprFields]);
1920 break;
1921 case EXPR_OBJC_DICTIONARY_LITERAL:
1922 S = ObjCDictionaryLiteral::CreateEmpty(Context,
1923 Record[ASTStmtReader::NumExprFields],
1924 Record[ASTStmtReader::NumExprFields + 1]);
1925 break;
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001926 case EXPR_OBJC_ENCODE:
Chris Lattner4c6f9522009-04-27 05:14:47 +00001927 S = new (Context) ObjCEncodeExpr(Empty);
1928 break;
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001929 case EXPR_OBJC_SELECTOR_EXPR:
Chris Lattner4c6f9522009-04-27 05:14:47 +00001930 S = new (Context) ObjCSelectorExpr(Empty);
1931 break;
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001932 case EXPR_OBJC_PROTOCOL_EXPR:
Chris Lattner4c6f9522009-04-27 05:14:47 +00001933 S = new (Context) ObjCProtocolExpr(Empty);
1934 break;
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001935 case EXPR_OBJC_IVAR_REF_EXPR:
Chris Lattner4c6f9522009-04-27 05:14:47 +00001936 S = new (Context) ObjCIvarRefExpr(Empty);
1937 break;
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001938 case EXPR_OBJC_PROPERTY_REF_EXPR:
Chris Lattner4c6f9522009-04-27 05:14:47 +00001939 S = new (Context) ObjCPropertyRefExpr(Empty);
1940 break;
Ted Kremenekebcb57a2012-03-06 20:05:56 +00001941 case EXPR_OBJC_SUBSCRIPT_REF_EXPR:
1942 S = new (Context) ObjCSubscriptRefExpr(Empty);
1943 break;
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001944 case EXPR_OBJC_KVC_REF_EXPR:
John McCall12f78a62010-12-02 01:19:52 +00001945 llvm_unreachable("mismatching AST file");
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001946 case EXPR_OBJC_MESSAGE_EXPR:
Douglas Gregor35942772011-09-09 21:34:22 +00001947 S = ObjCMessageExpr::CreateEmpty(Context,
Argyrios Kyrtzidis20718082011-10-03 06:36:51 +00001948 Record[ASTStmtReader::NumExprFields],
1949 Record[ASTStmtReader::NumExprFields + 1]);
Chris Lattner4c6f9522009-04-27 05:14:47 +00001950 break;
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001951 case EXPR_OBJC_ISA:
Steve Narofff242b1b2009-07-24 17:54:45 +00001952 S = new (Context) ObjCIsaExpr(Empty);
1953 break;
John McCallf85e1932011-06-15 23:02:42 +00001954 case EXPR_OBJC_INDIRECT_COPY_RESTORE:
1955 S = new (Context) ObjCIndirectCopyRestoreExpr(Empty);
1956 break;
1957 case EXPR_OBJC_BRIDGED_CAST:
1958 S = new (Context) ObjCBridgedCastExpr(Empty);
1959 break;
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001960 case STMT_OBJC_FOR_COLLECTION:
Chris Lattner4c6f9522009-04-27 05:14:47 +00001961 S = new (Context) ObjCForCollectionStmt(Empty);
1962 break;
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001963 case STMT_OBJC_CATCH:
Chris Lattner4c6f9522009-04-27 05:14:47 +00001964 S = new (Context) ObjCAtCatchStmt(Empty);
1965 break;
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001966 case STMT_OBJC_FINALLY:
Chris Lattner4c6f9522009-04-27 05:14:47 +00001967 S = new (Context) ObjCAtFinallyStmt(Empty);
1968 break;
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001969 case STMT_OBJC_AT_TRY:
Douglas Gregor35942772011-09-09 21:34:22 +00001970 S = ObjCAtTryStmt::CreateEmpty(Context,
Sebastian Redl60adf4a2010-08-18 23:56:52 +00001971 Record[ASTStmtReader::NumStmtFields],
1972 Record[ASTStmtReader::NumStmtFields + 1]);
Chris Lattner4c6f9522009-04-27 05:14:47 +00001973 break;
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001974 case STMT_OBJC_AT_SYNCHRONIZED:
Chris Lattner4c6f9522009-04-27 05:14:47 +00001975 S = new (Context) ObjCAtSynchronizedStmt(Empty);
1976 break;
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001977 case STMT_OBJC_AT_THROW:
Chris Lattner4c6f9522009-04-27 05:14:47 +00001978 S = new (Context) ObjCAtThrowStmt(Empty);
1979 break;
John McCallf85e1932011-06-15 23:02:42 +00001980 case STMT_OBJC_AUTORELEASE_POOL:
1981 S = new (Context) ObjCAutoreleasePoolStmt(Empty);
1982 break;
Ted Kremenekebcb57a2012-03-06 20:05:56 +00001983 case EXPR_OBJC_BOOL_LITERAL:
1984 S = new (Context) ObjCBoolLiteralExpr(Empty);
1985 break;
John McCall7110fd62011-07-15 07:00:14 +00001986 case STMT_SEH_EXCEPT:
1987 S = new (Context) SEHExceptStmt(Empty);
1988 break;
1989 case STMT_SEH_FINALLY:
1990 S = new (Context) SEHFinallyStmt(Empty);
1991 break;
1992 case STMT_SEH_TRY:
1993 S = new (Context) SEHTryStmt(Empty);
1994 break;
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001995 case STMT_CXX_CATCH:
Argyrios Kyrtzidis7cb45e32010-07-22 16:03:56 +00001996 S = new (Context) CXXCatchStmt(Empty);
1997 break;
1998
Sebastian Redl8538e8d2010-08-18 23:57:32 +00001999 case STMT_CXX_TRY:
Douglas Gregor35942772011-09-09 21:34:22 +00002000 S = CXXTryStmt::Create(Context, Empty,
Sebastian Redl60adf4a2010-08-18 23:56:52 +00002001 /*NumHandlers=*/Record[ASTStmtReader::NumStmtFields]);
Argyrios Kyrtzidis7cb45e32010-07-22 16:03:56 +00002002 break;
2003
Richard Smithad762fc2011-04-14 22:09:26 +00002004 case STMT_CXX_FOR_RANGE:
2005 S = new (Context) CXXForRangeStmt(Empty);
2006 break;
2007
Douglas Gregorba0513d2011-10-25 01:33:02 +00002008 case STMT_MS_DEPENDENT_EXISTS:
2009 S = new (Context) MSDependentExistsStmt(SourceLocation(), true,
2010 NestedNameSpecifierLoc(),
2011 DeclarationNameInfo(),
2012 0);
2013 break;
2014
Sebastian Redl8538e8d2010-08-18 23:57:32 +00002015 case EXPR_CXX_OPERATOR_CALL:
Douglas Gregor35942772011-09-09 21:34:22 +00002016 S = new (Context) CXXOperatorCallExpr(Context, Empty);
Argyrios Kyrtzidisba0a9002009-07-14 03:19:21 +00002017 break;
Chris Lattner1817bd42010-05-09 05:36:05 +00002018
Sebastian Redl8538e8d2010-08-18 23:57:32 +00002019 case EXPR_CXX_MEMBER_CALL:
Douglas Gregor35942772011-09-09 21:34:22 +00002020 S = new (Context) CXXMemberCallExpr(Context, Empty);
Chris Lattner1817bd42010-05-09 05:36:05 +00002021 break;
Douglas Gregor39da0b82009-09-09 23:08:42 +00002022
Sebastian Redl8538e8d2010-08-18 23:57:32 +00002023 case EXPR_CXX_CONSTRUCT:
Argyrios Kyrtzidis6d00c132010-07-10 11:46:15 +00002024 S = new (Context) CXXConstructExpr(Empty);
2025 break;
2026
Sebastian Redl8538e8d2010-08-18 23:57:32 +00002027 case EXPR_CXX_TEMPORARY_OBJECT:
Argyrios Kyrtzidis6d00c132010-07-10 11:46:15 +00002028 S = new (Context) CXXTemporaryObjectExpr(Empty);
Douglas Gregor39da0b82009-09-09 23:08:42 +00002029 break;
Sam Weinigce757a72010-01-16 21:21:01 +00002030
Sebastian Redl8538e8d2010-08-18 23:57:32 +00002031 case EXPR_CXX_STATIC_CAST:
Douglas Gregor35942772011-09-09 21:34:22 +00002032 S = CXXStaticCastExpr::CreateEmpty(Context,
Sebastian Redl60adf4a2010-08-18 23:56:52 +00002033 /*PathSize*/ Record[ASTStmtReader::NumExprFields]);
Sam Weinigce757a72010-01-16 21:21:01 +00002034 break;
2035
Sebastian Redl8538e8d2010-08-18 23:57:32 +00002036 case EXPR_CXX_DYNAMIC_CAST:
Douglas Gregor35942772011-09-09 21:34:22 +00002037 S = CXXDynamicCastExpr::CreateEmpty(Context,
Sebastian Redl60adf4a2010-08-18 23:56:52 +00002038 /*PathSize*/ Record[ASTStmtReader::NumExprFields]);
Sam Weinigce757a72010-01-16 21:21:01 +00002039 break;
2040
Sebastian Redl8538e8d2010-08-18 23:57:32 +00002041 case EXPR_CXX_REINTERPRET_CAST:
Douglas Gregor35942772011-09-09 21:34:22 +00002042 S = CXXReinterpretCastExpr::CreateEmpty(Context,
Sebastian Redl60adf4a2010-08-18 23:56:52 +00002043 /*PathSize*/ Record[ASTStmtReader::NumExprFields]);
Sam Weinigce757a72010-01-16 21:21:01 +00002044 break;
2045
Sebastian Redl8538e8d2010-08-18 23:57:32 +00002046 case EXPR_CXX_CONST_CAST:
Douglas Gregor35942772011-09-09 21:34:22 +00002047 S = CXXConstCastExpr::CreateEmpty(Context);
Sam Weinigce757a72010-01-16 21:21:01 +00002048 break;
2049
Sebastian Redl8538e8d2010-08-18 23:57:32 +00002050 case EXPR_CXX_FUNCTIONAL_CAST:
Douglas Gregor35942772011-09-09 21:34:22 +00002051 S = CXXFunctionalCastExpr::CreateEmpty(Context,
Sebastian Redl60adf4a2010-08-18 23:56:52 +00002052 /*PathSize*/ Record[ASTStmtReader::NumExprFields]);
Sam Weinigce757a72010-01-16 21:21:01 +00002053 break;
2054
Richard Smith9fcce652012-03-07 08:35:16 +00002055 case EXPR_USER_DEFINED_LITERAL:
2056 S = new (Context) UserDefinedLiteral(Context, Empty);
2057 break;
2058
Sebastian Redl8538e8d2010-08-18 23:57:32 +00002059 case EXPR_CXX_BOOL_LITERAL:
Sam Weinigeb7f9612010-02-07 06:32:43 +00002060 S = new (Context) CXXBoolLiteralExpr(Empty);
2061 break;
Sam Weinigce757a72010-01-16 21:21:01 +00002062
Sebastian Redl8538e8d2010-08-18 23:57:32 +00002063 case EXPR_CXX_NULL_PTR_LITERAL:
Sam Weinigeb7f9612010-02-07 06:32:43 +00002064 S = new (Context) CXXNullPtrLiteralExpr(Empty);
2065 break;
Sebastian Redl8538e8d2010-08-18 23:57:32 +00002066 case EXPR_CXX_TYPEID_EXPR:
Chris Lattner14ab24f2010-05-09 06:03:39 +00002067 S = new (Context) CXXTypeidExpr(Empty, true);
2068 break;
Sebastian Redl8538e8d2010-08-18 23:57:32 +00002069 case EXPR_CXX_TYPEID_TYPE:
Chris Lattner14ab24f2010-05-09 06:03:39 +00002070 S = new (Context) CXXTypeidExpr(Empty, false);
2071 break;
Francois Pichet01b7c302010-09-08 12:20:18 +00002072 case EXPR_CXX_UUIDOF_EXPR:
2073 S = new (Context) CXXUuidofExpr(Empty, true);
2074 break;
2075 case EXPR_CXX_UUIDOF_TYPE:
2076 S = new (Context) CXXUuidofExpr(Empty, false);
2077 break;
Sebastian Redl8538e8d2010-08-18 23:57:32 +00002078 case EXPR_CXX_THIS:
Chris Lattner2fbdfcd2010-05-09 06:15:05 +00002079 S = new (Context) CXXThisExpr(Empty);
2080 break;
Sebastian Redl8538e8d2010-08-18 23:57:32 +00002081 case EXPR_CXX_THROW:
Chris Lattner2fbdfcd2010-05-09 06:15:05 +00002082 S = new (Context) CXXThrowExpr(Empty);
2083 break;
Sebastian Redl8538e8d2010-08-18 23:57:32 +00002084 case EXPR_CXX_DEFAULT_ARG: {
Sebastian Redl60adf4a2010-08-18 23:56:52 +00002085 bool HasOtherExprStored = Record[ASTStmtReader::NumExprFields];
Argyrios Kyrtzidis8a507332010-07-02 23:30:15 +00002086 if (HasOtherExprStored) {
2087 Expr *SubExpr = ReadSubExpr();
Douglas Gregor35942772011-09-09 21:34:22 +00002088 S = CXXDefaultArgExpr::Create(Context, SourceLocation(), 0, SubExpr);
Argyrios Kyrtzidis8a507332010-07-02 23:30:15 +00002089 } else
2090 S = new (Context) CXXDefaultArgExpr(Empty);
Chris Lattner030854b2010-05-09 06:40:08 +00002091 break;
Argyrios Kyrtzidis8a507332010-07-02 23:30:15 +00002092 }
Sebastian Redl8538e8d2010-08-18 23:57:32 +00002093 case EXPR_CXX_BIND_TEMPORARY:
Chris Lattnerd2598362010-05-10 00:25:06 +00002094 S = new (Context) CXXBindTemporaryExpr(Empty);
2095 break;
Douglas Gregore2ca6d42010-09-02 21:50:02 +00002096
Sebastian Redl8538e8d2010-08-18 23:57:32 +00002097 case EXPR_CXX_SCALAR_VALUE_INIT:
Douglas Gregored8abf12010-07-08 06:14:04 +00002098 S = new (Context) CXXScalarValueInitExpr(Empty);
Chris Lattner59218632010-05-10 01:22:27 +00002099 break;
Sebastian Redl8538e8d2010-08-18 23:57:32 +00002100 case EXPR_CXX_NEW:
Chris Lattner59218632010-05-10 01:22:27 +00002101 S = new (Context) CXXNewExpr(Empty);
2102 break;
Sebastian Redl8538e8d2010-08-18 23:57:32 +00002103 case EXPR_CXX_DELETE:
Argyrios Kyrtzidis95fc98c2010-06-22 17:07:59 +00002104 S = new (Context) CXXDeleteExpr(Empty);
2105 break;
Sebastian Redl8538e8d2010-08-18 23:57:32 +00002106 case EXPR_CXX_PSEUDO_DESTRUCTOR:
Argyrios Kyrtzidisde4bd182010-06-28 09:32:03 +00002107 S = new (Context) CXXPseudoDestructorExpr(Empty);
2108 break;
Chris Lattner59218632010-05-10 01:22:27 +00002109
John McCall4765fa02010-12-06 08:20:24 +00002110 case EXPR_EXPR_WITH_CLEANUPS:
John McCall80ee6e82011-11-10 05:35:25 +00002111 S = ExprWithCleanups::Create(Context, Empty,
2112 Record[ASTStmtReader::NumExprFields]);
Chris Lattnerd2598362010-05-10 00:25:06 +00002113 break;
Argyrios Kyrtzidis8dfbd8b2010-06-24 08:57:31 +00002114
Sebastian Redl8538e8d2010-08-18 23:57:32 +00002115 case EXPR_CXX_DEPENDENT_SCOPE_MEMBER:
Douglas Gregor35942772011-09-09 21:34:22 +00002116 S = CXXDependentScopeMemberExpr::CreateEmpty(Context,
Abramo Bagnarae4b92762012-01-27 09:46:47 +00002117 /*HasTemplateKWAndArgsInfo=*/Record[ASTStmtReader::NumExprFields],
Douglas Gregordef03542011-02-04 12:01:24 +00002118 /*NumTemplateArgs=*/Record[ASTStmtReader::NumExprFields]
2119 ? Record[ASTStmtReader::NumExprFields + 1]
2120 : 0);
Argyrios Kyrtzidis8dfbd8b2010-06-24 08:57:31 +00002121 break;
2122
Sebastian Redl8538e8d2010-08-18 23:57:32 +00002123 case EXPR_CXX_DEPENDENT_SCOPE_DECL_REF:
Douglas Gregor35942772011-09-09 21:34:22 +00002124 S = DependentScopeDeclRefExpr::CreateEmpty(Context,
Abramo Bagnarae4b92762012-01-27 09:46:47 +00002125 /*HasTemplateKWAndArgsInfo=*/Record[ASTStmtReader::NumExprFields],
Douglas Gregordef03542011-02-04 12:01:24 +00002126 /*NumTemplateArgs=*/Record[ASTStmtReader::NumExprFields]
2127 ? Record[ASTStmtReader::NumExprFields + 1]
2128 : 0);
Argyrios Kyrtzidis12dffcd2010-06-28 09:31:56 +00002129 break;
2130
Sebastian Redl8538e8d2010-08-18 23:57:32 +00002131 case EXPR_CXX_UNRESOLVED_CONSTRUCT:
Douglas Gregor35942772011-09-09 21:34:22 +00002132 S = CXXUnresolvedConstructExpr::CreateEmpty(Context,
Sebastian Redl60adf4a2010-08-18 23:56:52 +00002133 /*NumArgs=*/Record[ASTStmtReader::NumExprFields]);
Argyrios Kyrtzidisa77eb082010-06-25 09:03:26 +00002134 break;
2135
Sebastian Redl8538e8d2010-08-18 23:57:32 +00002136 case EXPR_CXX_UNRESOLVED_MEMBER:
Douglas Gregor35942772011-09-09 21:34:22 +00002137 S = UnresolvedMemberExpr::CreateEmpty(Context,
Abramo Bagnarae4b92762012-01-27 09:46:47 +00002138 /*HasTemplateKWAndArgsInfo=*/Record[ASTStmtReader::NumExprFields],
Douglas Gregordef03542011-02-04 12:01:24 +00002139 /*NumTemplateArgs=*/Record[ASTStmtReader::NumExprFields]
2140 ? Record[ASTStmtReader::NumExprFields + 1]
2141 : 0);
Argyrios Kyrtzidis8dfbd8b2010-06-24 08:57:31 +00002142 break;
Argyrios Kyrtzidisbd65bb52010-06-25 09:03:34 +00002143
Sebastian Redl8538e8d2010-08-18 23:57:32 +00002144 case EXPR_CXX_UNRESOLVED_LOOKUP:
Douglas Gregor35942772011-09-09 21:34:22 +00002145 S = UnresolvedLookupExpr::CreateEmpty(Context,
Abramo Bagnarae4b92762012-01-27 09:46:47 +00002146 /*HasTemplateKWAndArgsInfo=*/Record[ASTStmtReader::NumExprFields],
Douglas Gregordef03542011-02-04 12:01:24 +00002147 /*NumTemplateArgs=*/Record[ASTStmtReader::NumExprFields]
2148 ? Record[ASTStmtReader::NumExprFields + 1]
2149 : 0);
Argyrios Kyrtzidisbd65bb52010-06-25 09:03:34 +00002150 break;
Argyrios Kyrtzidis6d00c132010-07-10 11:46:15 +00002151
Sebastian Redl8538e8d2010-08-18 23:57:32 +00002152 case EXPR_CXX_UNARY_TYPE_TRAIT:
Argyrios Kyrtzidis6d00c132010-07-10 11:46:15 +00002153 S = new (Context) UnaryTypeTraitExpr(Empty);
2154 break;
Sebastian Redl6b219d02010-09-10 20:55:54 +00002155
Francois Pichetf1872372010-12-08 22:35:30 +00002156 case EXPR_BINARY_TYPE_TRAIT:
Francois Pichet6ad6f282010-12-07 00:08:36 +00002157 S = new (Context) BinaryTypeTraitExpr(Empty);
2158 break;
2159
Douglas Gregor4ca8ac22012-02-24 07:38:34 +00002160 case EXPR_TYPE_TRAIT:
2161 S = TypeTraitExpr::CreateDeserialized(Context,
2162 Record[ASTStmtReader::NumExprFields]);
2163 break;
2164
John Wiegley21ff2e52011-04-28 00:16:57 +00002165 case EXPR_ARRAY_TYPE_TRAIT:
2166 S = new (Context) ArrayTypeTraitExpr(Empty);
2167 break;
2168
John Wiegley55262202011-04-25 06:54:41 +00002169 case EXPR_CXX_EXPRESSION_TRAIT:
2170 S = new (Context) ExpressionTraitExpr(Empty);
2171 break;
2172
Sebastian Redl6b219d02010-09-10 20:55:54 +00002173 case EXPR_CXX_NOEXCEPT:
2174 S = new (Context) CXXNoexceptExpr(Empty);
2175 break;
John McCall7cd7d1a2010-11-15 23:31:06 +00002176
Douglas Gregorbe230c32011-01-03 17:17:50 +00002177 case EXPR_PACK_EXPANSION:
2178 S = new (Context) PackExpansionExpr(Empty);
2179 break;
2180
Douglas Gregoree8aff02011-01-04 17:33:58 +00002181 case EXPR_SIZEOF_PACK:
2182 S = new (Context) SizeOfPackExpr(Empty);
2183 break;
2184
John McCall7110fd62011-07-15 07:00:14 +00002185 case EXPR_SUBST_NON_TYPE_TEMPLATE_PARM:
2186 S = new (Context) SubstNonTypeTemplateParmExpr(Empty);
2187 break;
2188
Douglas Gregorc7793c72011-01-15 01:15:58 +00002189 case EXPR_SUBST_NON_TYPE_TEMPLATE_PARM_PACK:
2190 S = new (Context) SubstNonTypeTemplateParmPackExpr(Empty);
2191 break;
Richard Smith9a4db032012-09-12 00:56:43 +00002192
2193 case EXPR_FUNCTION_PARM_PACK:
2194 S = FunctionParmPackExpr::CreateEmpty(Context,
2195 Record[ASTStmtReader::NumExprFields]);
2196 break;
Douglas Gregorc7793c72011-01-15 01:15:58 +00002197
Douglas Gregor03e80032011-06-21 17:03:29 +00002198 case EXPR_MATERIALIZE_TEMPORARY:
2199 S = new (Context) MaterializeTemporaryExpr(Empty);
2200 break;
2201
Argyrios Kyrtzidis8bc27822011-12-03 03:49:52 +00002202 case EXPR_OPAQUE_VALUE:
2203 S = new (Context) OpaqueValueExpr(Empty);
John McCall7cd7d1a2010-11-15 23:31:06 +00002204 break;
Peter Collingbournee08ce652011-02-09 21:07:24 +00002205
2206 case EXPR_CUDA_KERNEL_CALL:
Douglas Gregor35942772011-09-09 21:34:22 +00002207 S = new (Context) CUDAKernelCallExpr(Context, Empty);
Peter Collingbournee08ce652011-02-09 21:07:24 +00002208 break;
Tanya Lattner61eee0c2011-06-04 00:47:47 +00002209
2210 case EXPR_ASTYPE:
2211 S = new (Context) AsTypeExpr(Empty);
2212 break;
Eli Friedman276b0612011-10-11 02:20:01 +00002213
John McCall4b9c2d22011-11-06 09:01:30 +00002214 case EXPR_PSEUDO_OBJECT: {
2215 unsigned numSemanticExprs = Record[ASTStmtReader::NumExprFields];
2216 S = PseudoObjectExpr::Create(Context, Empty, numSemanticExprs);
2217 break;
2218 }
2219
Eli Friedman276b0612011-10-11 02:20:01 +00002220 case EXPR_ATOMIC:
2221 S = new (Context) AtomicExpr(Empty);
2222 break;
Douglas Gregor9d36f5d2012-02-14 17:54:36 +00002223
2224 case EXPR_LAMBDA: {
2225 unsigned NumCaptures = Record[ASTStmtReader::NumExprFields];
2226 unsigned NumArrayIndexVars = Record[ASTStmtReader::NumExprFields + 1];
2227 S = LambdaExpr::CreateDeserialized(Context, NumCaptures,
2228 NumArrayIndexVars);
2229 break;
2230 }
Chris Lattner4c6f9522009-04-27 05:14:47 +00002231 }
Argyrios Kyrtzidis6d00c132010-07-10 11:46:15 +00002232
Chris Lattner4c6f9522009-04-27 05:14:47 +00002233 // We hit a STMT_STOP, so we're done with this expression.
2234 if (Finished)
2235 break;
2236
2237 ++NumStatementsRead;
2238
Argyrios Kyrtzidise6f08682011-10-21 23:02:28 +00002239 if (S && !IsStmtReference) {
Argyrios Kyrtzidis919e6932010-06-28 22:28:35 +00002240 Reader.Visit(S);
Argyrios Kyrtzidise6f08682011-10-21 23:02:28 +00002241 StmtEntries[Cursor.GetCurrentBitNo()] = S;
2242 }
2243
Chris Lattner4c6f9522009-04-27 05:14:47 +00002244
2245 assert(Idx == Record.size() && "Invalid deserialization of statement");
2246 StmtStack.push_back(S);
2247 }
Chris Lattnerb3ce3572013-01-20 02:38:54 +00002248Done:
Argyrios Kyrtzidis919e6932010-06-28 22:28:35 +00002249 assert(StmtStack.size() > PrevNumStmts && "Read too many sub stmts!");
2250 assert(StmtStack.size() == PrevNumStmts + 1 && "Extra expressions on stack!");
Argyrios Kyrtzidis919e6932010-06-28 22:28:35 +00002251 return StmtStack.pop_back_val();
Chris Lattner4c6f9522009-04-27 05:14:47 +00002252}