xref: /minix3/external/bsd/llvm/dist/clang/lib/Serialization/ASTReaderStmt.cpp (revision 0a6a1f1d05b60e214de2f05a7310ddd1f0e590e7)
1f4a2713aSLionel Sambuc //===--- ASTReaderStmt.cpp - Stmt/Expr Deserialization ----------*- C++ -*-===//
2f4a2713aSLionel Sambuc //
3f4a2713aSLionel Sambuc //                     The LLVM Compiler Infrastructure
4f4a2713aSLionel Sambuc //
5f4a2713aSLionel Sambuc // This file is distributed under the University of Illinois Open Source
6f4a2713aSLionel Sambuc // License. See LICENSE.TXT for details.
7f4a2713aSLionel Sambuc //
8f4a2713aSLionel Sambuc //===----------------------------------------------------------------------===//
9f4a2713aSLionel Sambuc //
10f4a2713aSLionel Sambuc // Statement/expression deserialization.  This implements the
11f4a2713aSLionel Sambuc // ASTReader::ReadStmt method.
12f4a2713aSLionel Sambuc //
13f4a2713aSLionel Sambuc //===----------------------------------------------------------------------===//
14f4a2713aSLionel Sambuc 
15f4a2713aSLionel Sambuc #include "clang/Serialization/ASTReader.h"
16f4a2713aSLionel Sambuc #include "clang/AST/ASTContext.h"
17f4a2713aSLionel Sambuc #include "clang/AST/DeclCXX.h"
18f4a2713aSLionel Sambuc #include "clang/AST/DeclTemplate.h"
19f4a2713aSLionel Sambuc #include "clang/AST/StmtVisitor.h"
20f4a2713aSLionel Sambuc #include "clang/Lex/Token.h"
21f4a2713aSLionel Sambuc #include "llvm/ADT/SmallString.h"
22f4a2713aSLionel Sambuc using namespace clang;
23f4a2713aSLionel Sambuc using namespace clang::serialization;
24f4a2713aSLionel Sambuc 
25f4a2713aSLionel Sambuc namespace clang {
26f4a2713aSLionel Sambuc 
27f4a2713aSLionel Sambuc   class ASTStmtReader : public StmtVisitor<ASTStmtReader> {
28f4a2713aSLionel Sambuc     friend class OMPClauseReader;
29f4a2713aSLionel Sambuc     typedef ASTReader::RecordData RecordData;
30f4a2713aSLionel Sambuc 
31f4a2713aSLionel Sambuc     ASTReader &Reader;
32f4a2713aSLionel Sambuc     ModuleFile &F;
33f4a2713aSLionel Sambuc     llvm::BitstreamCursor &DeclsCursor;
34f4a2713aSLionel Sambuc     const ASTReader::RecordData &Record;
35f4a2713aSLionel Sambuc     unsigned &Idx;
36f4a2713aSLionel Sambuc 
ReadToken(const RecordData & R,unsigned & I)37f4a2713aSLionel Sambuc     Token ReadToken(const RecordData &R, unsigned &I) {
38f4a2713aSLionel Sambuc       return Reader.ReadToken(F, R, I);
39f4a2713aSLionel Sambuc     }
40f4a2713aSLionel Sambuc 
ReadSourceLocation(const RecordData & R,unsigned & I)41f4a2713aSLionel Sambuc     SourceLocation ReadSourceLocation(const RecordData &R, unsigned &I) {
42f4a2713aSLionel Sambuc       return Reader.ReadSourceLocation(F, R, I);
43f4a2713aSLionel Sambuc     }
44f4a2713aSLionel Sambuc 
ReadSourceRange(const RecordData & R,unsigned & I)45f4a2713aSLionel Sambuc     SourceRange ReadSourceRange(const RecordData &R, unsigned &I) {
46f4a2713aSLionel Sambuc       return Reader.ReadSourceRange(F, R, I);
47f4a2713aSLionel Sambuc     }
48f4a2713aSLionel Sambuc 
ReadString(const RecordData & R,unsigned & I)49f4a2713aSLionel Sambuc     std::string ReadString(const RecordData &R, unsigned &I) {
50f4a2713aSLionel Sambuc       return Reader.ReadString(R, I);
51f4a2713aSLionel Sambuc     }
52f4a2713aSLionel Sambuc 
GetTypeSourceInfo(const RecordData & R,unsigned & I)53f4a2713aSLionel Sambuc     TypeSourceInfo *GetTypeSourceInfo(const RecordData &R, unsigned &I) {
54f4a2713aSLionel Sambuc       return Reader.GetTypeSourceInfo(F, R, I);
55f4a2713aSLionel Sambuc     }
56f4a2713aSLionel Sambuc 
ReadDeclID(const RecordData & R,unsigned & I)57f4a2713aSLionel Sambuc     serialization::DeclID ReadDeclID(const RecordData &R, unsigned &I) {
58f4a2713aSLionel Sambuc       return Reader.ReadDeclID(F, R, I);
59f4a2713aSLionel Sambuc     }
60f4a2713aSLionel Sambuc 
ReadDecl(const RecordData & R,unsigned & I)61f4a2713aSLionel Sambuc     Decl *ReadDecl(const RecordData &R, unsigned &I) {
62f4a2713aSLionel Sambuc       return Reader.ReadDecl(F, R, I);
63f4a2713aSLionel Sambuc     }
64f4a2713aSLionel Sambuc 
65f4a2713aSLionel Sambuc     template<typename T>
ReadDeclAs(const RecordData & R,unsigned & I)66f4a2713aSLionel Sambuc     T *ReadDeclAs(const RecordData &R, unsigned &I) {
67f4a2713aSLionel Sambuc       return Reader.ReadDeclAs<T>(F, R, I);
68f4a2713aSLionel Sambuc     }
69f4a2713aSLionel Sambuc 
ReadDeclarationNameLoc(DeclarationNameLoc & DNLoc,DeclarationName Name,const ASTReader::RecordData & R,unsigned & I)70f4a2713aSLionel Sambuc     void ReadDeclarationNameLoc(DeclarationNameLoc &DNLoc, DeclarationName Name,
71f4a2713aSLionel Sambuc                                 const ASTReader::RecordData &R, unsigned &I) {
72f4a2713aSLionel Sambuc       Reader.ReadDeclarationNameLoc(F, DNLoc, Name, R, I);
73f4a2713aSLionel Sambuc     }
74f4a2713aSLionel Sambuc 
ReadDeclarationNameInfo(DeclarationNameInfo & NameInfo,const ASTReader::RecordData & R,unsigned & I)75f4a2713aSLionel Sambuc     void ReadDeclarationNameInfo(DeclarationNameInfo &NameInfo,
76f4a2713aSLionel Sambuc                                 const ASTReader::RecordData &R, unsigned &I) {
77f4a2713aSLionel Sambuc       Reader.ReadDeclarationNameInfo(F, NameInfo, R, I);
78f4a2713aSLionel Sambuc     }
79f4a2713aSLionel Sambuc 
80f4a2713aSLionel Sambuc   public:
ASTStmtReader(ASTReader & Reader,ModuleFile & F,llvm::BitstreamCursor & Cursor,const ASTReader::RecordData & Record,unsigned & Idx)81f4a2713aSLionel Sambuc     ASTStmtReader(ASTReader &Reader, ModuleFile &F,
82f4a2713aSLionel Sambuc                   llvm::BitstreamCursor &Cursor,
83f4a2713aSLionel Sambuc                   const ASTReader::RecordData &Record, unsigned &Idx)
84f4a2713aSLionel Sambuc       : Reader(Reader), F(F), DeclsCursor(Cursor), Record(Record), Idx(Idx) { }
85f4a2713aSLionel Sambuc 
86f4a2713aSLionel Sambuc     /// \brief The number of record fields required for the Stmt class
87f4a2713aSLionel Sambuc     /// itself.
88f4a2713aSLionel Sambuc     static const unsigned NumStmtFields = 0;
89f4a2713aSLionel Sambuc 
90f4a2713aSLionel Sambuc     /// \brief The number of record fields required for the Expr class
91f4a2713aSLionel Sambuc     /// itself.
92f4a2713aSLionel Sambuc     static const unsigned NumExprFields = NumStmtFields + 7;
93f4a2713aSLionel Sambuc 
94f4a2713aSLionel Sambuc     /// \brief Read and initialize a ExplicitTemplateArgumentList structure.
95f4a2713aSLionel Sambuc     void ReadTemplateKWAndArgsInfo(ASTTemplateKWAndArgsInfo &Args,
96f4a2713aSLionel Sambuc                                    unsigned NumTemplateArgs);
97f4a2713aSLionel Sambuc     /// \brief Read and initialize a ExplicitTemplateArgumentList structure.
98f4a2713aSLionel Sambuc     void ReadExplicitTemplateArgumentList(ASTTemplateArgumentListInfo &ArgList,
99f4a2713aSLionel Sambuc                                           unsigned NumTemplateArgs);
100f4a2713aSLionel Sambuc 
101f4a2713aSLionel Sambuc     void VisitStmt(Stmt *S);
102f4a2713aSLionel Sambuc #define STMT(Type, Base) \
103f4a2713aSLionel Sambuc     void Visit##Type(Type *);
104f4a2713aSLionel Sambuc #include "clang/AST/StmtNodes.inc"
105f4a2713aSLionel Sambuc   };
106f4a2713aSLionel Sambuc }
107f4a2713aSLionel Sambuc 
108f4a2713aSLionel Sambuc void ASTStmtReader::
ReadTemplateKWAndArgsInfo(ASTTemplateKWAndArgsInfo & Args,unsigned NumTemplateArgs)109f4a2713aSLionel Sambuc ReadTemplateKWAndArgsInfo(ASTTemplateKWAndArgsInfo &Args,
110f4a2713aSLionel Sambuc                           unsigned NumTemplateArgs) {
111f4a2713aSLionel Sambuc   SourceLocation TemplateKWLoc = ReadSourceLocation(Record, Idx);
112f4a2713aSLionel Sambuc   TemplateArgumentListInfo ArgInfo;
113f4a2713aSLionel Sambuc   ArgInfo.setLAngleLoc(ReadSourceLocation(Record, Idx));
114f4a2713aSLionel Sambuc   ArgInfo.setRAngleLoc(ReadSourceLocation(Record, Idx));
115f4a2713aSLionel Sambuc   for (unsigned i = 0; i != NumTemplateArgs; ++i)
116f4a2713aSLionel Sambuc     ArgInfo.addArgument(
117f4a2713aSLionel Sambuc         Reader.ReadTemplateArgumentLoc(F, Record, Idx));
118f4a2713aSLionel Sambuc   Args.initializeFrom(TemplateKWLoc, ArgInfo);
119f4a2713aSLionel Sambuc }
120f4a2713aSLionel Sambuc 
VisitStmt(Stmt * S)121f4a2713aSLionel Sambuc void ASTStmtReader::VisitStmt(Stmt *S) {
122f4a2713aSLionel Sambuc   assert(Idx == NumStmtFields && "Incorrect statement field count");
123f4a2713aSLionel Sambuc }
124f4a2713aSLionel Sambuc 
VisitNullStmt(NullStmt * S)125f4a2713aSLionel Sambuc void ASTStmtReader::VisitNullStmt(NullStmt *S) {
126f4a2713aSLionel Sambuc   VisitStmt(S);
127f4a2713aSLionel Sambuc   S->setSemiLoc(ReadSourceLocation(Record, Idx));
128f4a2713aSLionel Sambuc   S->HasLeadingEmptyMacro = Record[Idx++];
129f4a2713aSLionel Sambuc }
130f4a2713aSLionel Sambuc 
VisitCompoundStmt(CompoundStmt * S)131f4a2713aSLionel Sambuc void ASTStmtReader::VisitCompoundStmt(CompoundStmt *S) {
132f4a2713aSLionel Sambuc   VisitStmt(S);
133f4a2713aSLionel Sambuc   SmallVector<Stmt *, 16> Stmts;
134f4a2713aSLionel Sambuc   unsigned NumStmts = Record[Idx++];
135f4a2713aSLionel Sambuc   while (NumStmts--)
136f4a2713aSLionel Sambuc     Stmts.push_back(Reader.ReadSubStmt());
137f4a2713aSLionel Sambuc   S->setStmts(Reader.getContext(), Stmts.data(), Stmts.size());
138*0a6a1f1dSLionel Sambuc   S->LBraceLoc = ReadSourceLocation(Record, Idx);
139*0a6a1f1dSLionel Sambuc   S->RBraceLoc = ReadSourceLocation(Record, Idx);
140f4a2713aSLionel Sambuc }
141f4a2713aSLionel Sambuc 
VisitSwitchCase(SwitchCase * S)142f4a2713aSLionel Sambuc void ASTStmtReader::VisitSwitchCase(SwitchCase *S) {
143f4a2713aSLionel Sambuc   VisitStmt(S);
144f4a2713aSLionel Sambuc   Reader.RecordSwitchCaseID(S, Record[Idx++]);
145f4a2713aSLionel Sambuc   S->setKeywordLoc(ReadSourceLocation(Record, Idx));
146f4a2713aSLionel Sambuc   S->setColonLoc(ReadSourceLocation(Record, Idx));
147f4a2713aSLionel Sambuc }
148f4a2713aSLionel Sambuc 
VisitCaseStmt(CaseStmt * S)149f4a2713aSLionel Sambuc void ASTStmtReader::VisitCaseStmt(CaseStmt *S) {
150f4a2713aSLionel Sambuc   VisitSwitchCase(S);
151f4a2713aSLionel Sambuc   S->setLHS(Reader.ReadSubExpr());
152f4a2713aSLionel Sambuc   S->setRHS(Reader.ReadSubExpr());
153f4a2713aSLionel Sambuc   S->setSubStmt(Reader.ReadSubStmt());
154f4a2713aSLionel Sambuc   S->setEllipsisLoc(ReadSourceLocation(Record, Idx));
155f4a2713aSLionel Sambuc }
156f4a2713aSLionel Sambuc 
VisitDefaultStmt(DefaultStmt * S)157f4a2713aSLionel Sambuc void ASTStmtReader::VisitDefaultStmt(DefaultStmt *S) {
158f4a2713aSLionel Sambuc   VisitSwitchCase(S);
159f4a2713aSLionel Sambuc   S->setSubStmt(Reader.ReadSubStmt());
160f4a2713aSLionel Sambuc }
161f4a2713aSLionel Sambuc 
VisitLabelStmt(LabelStmt * S)162f4a2713aSLionel Sambuc void ASTStmtReader::VisitLabelStmt(LabelStmt *S) {
163f4a2713aSLionel Sambuc   VisitStmt(S);
164f4a2713aSLionel Sambuc   LabelDecl *LD = ReadDeclAs<LabelDecl>(Record, Idx);
165f4a2713aSLionel Sambuc   LD->setStmt(S);
166f4a2713aSLionel Sambuc   S->setDecl(LD);
167f4a2713aSLionel Sambuc   S->setSubStmt(Reader.ReadSubStmt());
168f4a2713aSLionel Sambuc   S->setIdentLoc(ReadSourceLocation(Record, Idx));
169f4a2713aSLionel Sambuc }
170f4a2713aSLionel Sambuc 
VisitAttributedStmt(AttributedStmt * S)171f4a2713aSLionel Sambuc void ASTStmtReader::VisitAttributedStmt(AttributedStmt *S) {
172f4a2713aSLionel Sambuc   VisitStmt(S);
173f4a2713aSLionel Sambuc   uint64_t NumAttrs = Record[Idx++];
174f4a2713aSLionel Sambuc   AttrVec Attrs;
175f4a2713aSLionel Sambuc   Reader.ReadAttributes(F, Attrs, Record, Idx);
176f4a2713aSLionel Sambuc   (void)NumAttrs;
177f4a2713aSLionel Sambuc   assert(NumAttrs == S->NumAttrs);
178f4a2713aSLionel Sambuc   assert(NumAttrs == Attrs.size());
179*0a6a1f1dSLionel Sambuc   std::copy(Attrs.begin(), Attrs.end(), S->getAttrArrayPtr());
180f4a2713aSLionel Sambuc   S->SubStmt = Reader.ReadSubStmt();
181f4a2713aSLionel Sambuc   S->AttrLoc = ReadSourceLocation(Record, Idx);
182f4a2713aSLionel Sambuc }
183f4a2713aSLionel Sambuc 
VisitIfStmt(IfStmt * S)184f4a2713aSLionel Sambuc void ASTStmtReader::VisitIfStmt(IfStmt *S) {
185f4a2713aSLionel Sambuc   VisitStmt(S);
186f4a2713aSLionel Sambuc   S->setConditionVariable(Reader.getContext(),
187f4a2713aSLionel Sambuc                           ReadDeclAs<VarDecl>(Record, Idx));
188f4a2713aSLionel Sambuc   S->setCond(Reader.ReadSubExpr());
189f4a2713aSLionel Sambuc   S->setThen(Reader.ReadSubStmt());
190f4a2713aSLionel Sambuc   S->setElse(Reader.ReadSubStmt());
191f4a2713aSLionel Sambuc   S->setIfLoc(ReadSourceLocation(Record, Idx));
192f4a2713aSLionel Sambuc   S->setElseLoc(ReadSourceLocation(Record, Idx));
193f4a2713aSLionel Sambuc }
194f4a2713aSLionel Sambuc 
VisitSwitchStmt(SwitchStmt * S)195f4a2713aSLionel Sambuc void ASTStmtReader::VisitSwitchStmt(SwitchStmt *S) {
196f4a2713aSLionel Sambuc   VisitStmt(S);
197f4a2713aSLionel Sambuc   S->setConditionVariable(Reader.getContext(),
198f4a2713aSLionel Sambuc                           ReadDeclAs<VarDecl>(Record, Idx));
199f4a2713aSLionel Sambuc   S->setCond(Reader.ReadSubExpr());
200f4a2713aSLionel Sambuc   S->setBody(Reader.ReadSubStmt());
201f4a2713aSLionel Sambuc   S->setSwitchLoc(ReadSourceLocation(Record, Idx));
202f4a2713aSLionel Sambuc   if (Record[Idx++])
203f4a2713aSLionel Sambuc     S->setAllEnumCasesCovered();
204f4a2713aSLionel Sambuc 
205*0a6a1f1dSLionel Sambuc   SwitchCase *PrevSC = nullptr;
206f4a2713aSLionel Sambuc   for (unsigned N = Record.size(); Idx != N; ++Idx) {
207f4a2713aSLionel Sambuc     SwitchCase *SC = Reader.getSwitchCaseWithID(Record[Idx]);
208f4a2713aSLionel Sambuc     if (PrevSC)
209f4a2713aSLionel Sambuc       PrevSC->setNextSwitchCase(SC);
210f4a2713aSLionel Sambuc     else
211f4a2713aSLionel Sambuc       S->setSwitchCaseList(SC);
212f4a2713aSLionel Sambuc 
213f4a2713aSLionel Sambuc     PrevSC = SC;
214f4a2713aSLionel Sambuc   }
215f4a2713aSLionel Sambuc }
216f4a2713aSLionel Sambuc 
VisitWhileStmt(WhileStmt * S)217f4a2713aSLionel Sambuc void ASTStmtReader::VisitWhileStmt(WhileStmt *S) {
218f4a2713aSLionel Sambuc   VisitStmt(S);
219f4a2713aSLionel Sambuc   S->setConditionVariable(Reader.getContext(),
220f4a2713aSLionel Sambuc                           ReadDeclAs<VarDecl>(Record, Idx));
221f4a2713aSLionel Sambuc 
222f4a2713aSLionel Sambuc   S->setCond(Reader.ReadSubExpr());
223f4a2713aSLionel Sambuc   S->setBody(Reader.ReadSubStmt());
224f4a2713aSLionel Sambuc   S->setWhileLoc(ReadSourceLocation(Record, Idx));
225f4a2713aSLionel Sambuc }
226f4a2713aSLionel Sambuc 
VisitDoStmt(DoStmt * S)227f4a2713aSLionel Sambuc void ASTStmtReader::VisitDoStmt(DoStmt *S) {
228f4a2713aSLionel Sambuc   VisitStmt(S);
229f4a2713aSLionel Sambuc   S->setCond(Reader.ReadSubExpr());
230f4a2713aSLionel Sambuc   S->setBody(Reader.ReadSubStmt());
231f4a2713aSLionel Sambuc   S->setDoLoc(ReadSourceLocation(Record, Idx));
232f4a2713aSLionel Sambuc   S->setWhileLoc(ReadSourceLocation(Record, Idx));
233f4a2713aSLionel Sambuc   S->setRParenLoc(ReadSourceLocation(Record, Idx));
234f4a2713aSLionel Sambuc }
235f4a2713aSLionel Sambuc 
VisitForStmt(ForStmt * S)236f4a2713aSLionel Sambuc void ASTStmtReader::VisitForStmt(ForStmt *S) {
237f4a2713aSLionel Sambuc   VisitStmt(S);
238f4a2713aSLionel Sambuc   S->setInit(Reader.ReadSubStmt());
239f4a2713aSLionel Sambuc   S->setCond(Reader.ReadSubExpr());
240f4a2713aSLionel Sambuc   S->setConditionVariable(Reader.getContext(),
241f4a2713aSLionel Sambuc                           ReadDeclAs<VarDecl>(Record, Idx));
242f4a2713aSLionel Sambuc   S->setInc(Reader.ReadSubExpr());
243f4a2713aSLionel Sambuc   S->setBody(Reader.ReadSubStmt());
244f4a2713aSLionel Sambuc   S->setForLoc(ReadSourceLocation(Record, Idx));
245f4a2713aSLionel Sambuc   S->setLParenLoc(ReadSourceLocation(Record, Idx));
246f4a2713aSLionel Sambuc   S->setRParenLoc(ReadSourceLocation(Record, Idx));
247f4a2713aSLionel Sambuc }
248f4a2713aSLionel Sambuc 
VisitGotoStmt(GotoStmt * S)249f4a2713aSLionel Sambuc void ASTStmtReader::VisitGotoStmt(GotoStmt *S) {
250f4a2713aSLionel Sambuc   VisitStmt(S);
251f4a2713aSLionel Sambuc   S->setLabel(ReadDeclAs<LabelDecl>(Record, Idx));
252f4a2713aSLionel Sambuc   S->setGotoLoc(ReadSourceLocation(Record, Idx));
253f4a2713aSLionel Sambuc   S->setLabelLoc(ReadSourceLocation(Record, Idx));
254f4a2713aSLionel Sambuc }
255f4a2713aSLionel Sambuc 
VisitIndirectGotoStmt(IndirectGotoStmt * S)256f4a2713aSLionel Sambuc void ASTStmtReader::VisitIndirectGotoStmt(IndirectGotoStmt *S) {
257f4a2713aSLionel Sambuc   VisitStmt(S);
258f4a2713aSLionel Sambuc   S->setGotoLoc(ReadSourceLocation(Record, Idx));
259f4a2713aSLionel Sambuc   S->setStarLoc(ReadSourceLocation(Record, Idx));
260f4a2713aSLionel Sambuc   S->setTarget(Reader.ReadSubExpr());
261f4a2713aSLionel Sambuc }
262f4a2713aSLionel Sambuc 
VisitContinueStmt(ContinueStmt * S)263f4a2713aSLionel Sambuc void ASTStmtReader::VisitContinueStmt(ContinueStmt *S) {
264f4a2713aSLionel Sambuc   VisitStmt(S);
265f4a2713aSLionel Sambuc   S->setContinueLoc(ReadSourceLocation(Record, Idx));
266f4a2713aSLionel Sambuc }
267f4a2713aSLionel Sambuc 
VisitBreakStmt(BreakStmt * S)268f4a2713aSLionel Sambuc void ASTStmtReader::VisitBreakStmt(BreakStmt *S) {
269f4a2713aSLionel Sambuc   VisitStmt(S);
270f4a2713aSLionel Sambuc   S->setBreakLoc(ReadSourceLocation(Record, Idx));
271f4a2713aSLionel Sambuc }
272f4a2713aSLionel Sambuc 
VisitReturnStmt(ReturnStmt * S)273f4a2713aSLionel Sambuc void ASTStmtReader::VisitReturnStmt(ReturnStmt *S) {
274f4a2713aSLionel Sambuc   VisitStmt(S);
275f4a2713aSLionel Sambuc   S->setRetValue(Reader.ReadSubExpr());
276f4a2713aSLionel Sambuc   S->setReturnLoc(ReadSourceLocation(Record, Idx));
277f4a2713aSLionel Sambuc   S->setNRVOCandidate(ReadDeclAs<VarDecl>(Record, Idx));
278f4a2713aSLionel Sambuc }
279f4a2713aSLionel Sambuc 
VisitDeclStmt(DeclStmt * S)280f4a2713aSLionel Sambuc void ASTStmtReader::VisitDeclStmt(DeclStmt *S) {
281f4a2713aSLionel Sambuc   VisitStmt(S);
282f4a2713aSLionel Sambuc   S->setStartLoc(ReadSourceLocation(Record, Idx));
283f4a2713aSLionel Sambuc   S->setEndLoc(ReadSourceLocation(Record, Idx));
284f4a2713aSLionel Sambuc 
285f4a2713aSLionel Sambuc   if (Idx + 1 == Record.size()) {
286f4a2713aSLionel Sambuc     // Single declaration
287f4a2713aSLionel Sambuc     S->setDeclGroup(DeclGroupRef(ReadDecl(Record, Idx)));
288f4a2713aSLionel Sambuc   } else {
289f4a2713aSLionel Sambuc     SmallVector<Decl *, 16> Decls;
290f4a2713aSLionel Sambuc     Decls.reserve(Record.size() - Idx);
291f4a2713aSLionel Sambuc     for (unsigned N = Record.size(); Idx != N; )
292f4a2713aSLionel Sambuc       Decls.push_back(ReadDecl(Record, Idx));
293f4a2713aSLionel Sambuc     S->setDeclGroup(DeclGroupRef(DeclGroup::Create(Reader.getContext(),
294f4a2713aSLionel Sambuc                                                    Decls.data(),
295f4a2713aSLionel Sambuc                                                    Decls.size())));
296f4a2713aSLionel Sambuc   }
297f4a2713aSLionel Sambuc }
298f4a2713aSLionel Sambuc 
VisitAsmStmt(AsmStmt * S)299f4a2713aSLionel Sambuc void ASTStmtReader::VisitAsmStmt(AsmStmt *S) {
300f4a2713aSLionel Sambuc   VisitStmt(S);
301f4a2713aSLionel Sambuc   S->NumOutputs = Record[Idx++];
302f4a2713aSLionel Sambuc   S->NumInputs = Record[Idx++];
303f4a2713aSLionel Sambuc   S->NumClobbers = Record[Idx++];
304f4a2713aSLionel Sambuc   S->setAsmLoc(ReadSourceLocation(Record, Idx));
305f4a2713aSLionel Sambuc   S->setVolatile(Record[Idx++]);
306f4a2713aSLionel Sambuc   S->setSimple(Record[Idx++]);
307f4a2713aSLionel Sambuc }
308f4a2713aSLionel Sambuc 
VisitGCCAsmStmt(GCCAsmStmt * S)309f4a2713aSLionel Sambuc void ASTStmtReader::VisitGCCAsmStmt(GCCAsmStmt *S) {
310f4a2713aSLionel Sambuc   VisitAsmStmt(S);
311f4a2713aSLionel Sambuc   S->setRParenLoc(ReadSourceLocation(Record, Idx));
312f4a2713aSLionel Sambuc   S->setAsmString(cast_or_null<StringLiteral>(Reader.ReadSubStmt()));
313f4a2713aSLionel Sambuc 
314f4a2713aSLionel Sambuc   unsigned NumOutputs = S->getNumOutputs();
315f4a2713aSLionel Sambuc   unsigned NumInputs = S->getNumInputs();
316f4a2713aSLionel Sambuc   unsigned NumClobbers = S->getNumClobbers();
317f4a2713aSLionel Sambuc 
318f4a2713aSLionel Sambuc   // Outputs and inputs
319f4a2713aSLionel Sambuc   SmallVector<IdentifierInfo *, 16> Names;
320f4a2713aSLionel Sambuc   SmallVector<StringLiteral*, 16> Constraints;
321f4a2713aSLionel Sambuc   SmallVector<Stmt*, 16> Exprs;
322f4a2713aSLionel Sambuc   for (unsigned I = 0, N = NumOutputs + NumInputs; I != N; ++I) {
323f4a2713aSLionel Sambuc     Names.push_back(Reader.GetIdentifierInfo(F, Record, Idx));
324f4a2713aSLionel Sambuc     Constraints.push_back(cast_or_null<StringLiteral>(Reader.ReadSubStmt()));
325f4a2713aSLionel Sambuc     Exprs.push_back(Reader.ReadSubStmt());
326f4a2713aSLionel Sambuc   }
327f4a2713aSLionel Sambuc 
328f4a2713aSLionel Sambuc   // Constraints
329f4a2713aSLionel Sambuc   SmallVector<StringLiteral*, 16> Clobbers;
330f4a2713aSLionel Sambuc   for (unsigned I = 0; I != NumClobbers; ++I)
331f4a2713aSLionel Sambuc     Clobbers.push_back(cast_or_null<StringLiteral>(Reader.ReadSubStmt()));
332f4a2713aSLionel Sambuc 
333f4a2713aSLionel Sambuc   S->setOutputsAndInputsAndClobbers(Reader.getContext(),
334f4a2713aSLionel Sambuc                                     Names.data(), Constraints.data(),
335f4a2713aSLionel Sambuc                                     Exprs.data(), NumOutputs, NumInputs,
336f4a2713aSLionel Sambuc                                     Clobbers.data(), NumClobbers);
337f4a2713aSLionel Sambuc }
338f4a2713aSLionel Sambuc 
VisitMSAsmStmt(MSAsmStmt * S)339f4a2713aSLionel Sambuc void ASTStmtReader::VisitMSAsmStmt(MSAsmStmt *S) {
340f4a2713aSLionel Sambuc   VisitAsmStmt(S);
341f4a2713aSLionel Sambuc   S->LBraceLoc = ReadSourceLocation(Record, Idx);
342f4a2713aSLionel Sambuc   S->EndLoc = ReadSourceLocation(Record, Idx);
343f4a2713aSLionel Sambuc   S->NumAsmToks = Record[Idx++];
344f4a2713aSLionel Sambuc   std::string AsmStr = ReadString(Record, Idx);
345f4a2713aSLionel Sambuc 
346f4a2713aSLionel Sambuc   // Read the tokens.
347f4a2713aSLionel Sambuc   SmallVector<Token, 16> AsmToks;
348f4a2713aSLionel Sambuc   AsmToks.reserve(S->NumAsmToks);
349f4a2713aSLionel Sambuc   for (unsigned i = 0, e = S->NumAsmToks; i != e; ++i) {
350f4a2713aSLionel Sambuc     AsmToks.push_back(ReadToken(Record, Idx));
351f4a2713aSLionel Sambuc   }
352f4a2713aSLionel Sambuc 
353f4a2713aSLionel Sambuc   // The calls to reserve() for the FooData vectors are mandatory to
354f4a2713aSLionel Sambuc   // prevent dead StringRefs in the Foo vectors.
355f4a2713aSLionel Sambuc 
356f4a2713aSLionel Sambuc   // Read the clobbers.
357f4a2713aSLionel Sambuc   SmallVector<std::string, 16> ClobbersData;
358f4a2713aSLionel Sambuc   SmallVector<StringRef, 16> Clobbers;
359f4a2713aSLionel Sambuc   ClobbersData.reserve(S->NumClobbers);
360f4a2713aSLionel Sambuc   Clobbers.reserve(S->NumClobbers);
361f4a2713aSLionel Sambuc   for (unsigned i = 0, e = S->NumClobbers; i != e; ++i) {
362f4a2713aSLionel Sambuc     ClobbersData.push_back(ReadString(Record, Idx));
363f4a2713aSLionel Sambuc     Clobbers.push_back(ClobbersData.back());
364f4a2713aSLionel Sambuc   }
365f4a2713aSLionel Sambuc 
366f4a2713aSLionel Sambuc   // Read the operands.
367f4a2713aSLionel Sambuc   unsigned NumOperands = S->NumOutputs + S->NumInputs;
368f4a2713aSLionel Sambuc   SmallVector<Expr*, 16> Exprs;
369f4a2713aSLionel Sambuc   SmallVector<std::string, 16> ConstraintsData;
370f4a2713aSLionel Sambuc   SmallVector<StringRef, 16> Constraints;
371f4a2713aSLionel Sambuc   Exprs.reserve(NumOperands);
372f4a2713aSLionel Sambuc   ConstraintsData.reserve(NumOperands);
373f4a2713aSLionel Sambuc   Constraints.reserve(NumOperands);
374f4a2713aSLionel Sambuc   for (unsigned i = 0; i != NumOperands; ++i) {
375f4a2713aSLionel Sambuc     Exprs.push_back(cast<Expr>(Reader.ReadSubStmt()));
376f4a2713aSLionel Sambuc     ConstraintsData.push_back(ReadString(Record, Idx));
377f4a2713aSLionel Sambuc     Constraints.push_back(ConstraintsData.back());
378f4a2713aSLionel Sambuc   }
379f4a2713aSLionel Sambuc 
380f4a2713aSLionel Sambuc   S->initialize(Reader.getContext(), AsmStr, AsmToks,
381f4a2713aSLionel Sambuc                 Constraints, Exprs, Clobbers);
382f4a2713aSLionel Sambuc }
383f4a2713aSLionel Sambuc 
VisitCapturedStmt(CapturedStmt * S)384f4a2713aSLionel Sambuc void ASTStmtReader::VisitCapturedStmt(CapturedStmt *S) {
385f4a2713aSLionel Sambuc   VisitStmt(S);
386f4a2713aSLionel Sambuc   ++Idx;
387f4a2713aSLionel Sambuc   S->setCapturedDecl(ReadDeclAs<CapturedDecl>(Record, Idx));
388f4a2713aSLionel Sambuc   S->setCapturedRegionKind(static_cast<CapturedRegionKind>(Record[Idx++]));
389f4a2713aSLionel Sambuc   S->setCapturedRecordDecl(ReadDeclAs<RecordDecl>(Record, Idx));
390f4a2713aSLionel Sambuc 
391f4a2713aSLionel Sambuc   // Capture inits
392f4a2713aSLionel Sambuc   for (CapturedStmt::capture_init_iterator I = S->capture_init_begin(),
393f4a2713aSLionel Sambuc                                            E = S->capture_init_end();
394f4a2713aSLionel Sambuc        I != E; ++I)
395f4a2713aSLionel Sambuc     *I = Reader.ReadSubExpr();
396f4a2713aSLionel Sambuc 
397f4a2713aSLionel Sambuc   // Body
398f4a2713aSLionel Sambuc   S->setCapturedStmt(Reader.ReadSubStmt());
399f4a2713aSLionel Sambuc   S->getCapturedDecl()->setBody(S->getCapturedStmt());
400f4a2713aSLionel Sambuc 
401f4a2713aSLionel Sambuc   // Captures
402*0a6a1f1dSLionel Sambuc   for (auto &I : S->captures()) {
403*0a6a1f1dSLionel Sambuc     I.VarAndKind.setPointer(ReadDeclAs<VarDecl>(Record, Idx));
404*0a6a1f1dSLionel Sambuc     I.VarAndKind
405f4a2713aSLionel Sambuc         .setInt(static_cast<CapturedStmt::VariableCaptureKind>(Record[Idx++]));
406*0a6a1f1dSLionel Sambuc     I.Loc = ReadSourceLocation(Record, Idx);
407f4a2713aSLionel Sambuc   }
408f4a2713aSLionel Sambuc }
409f4a2713aSLionel Sambuc 
VisitExpr(Expr * E)410f4a2713aSLionel Sambuc void ASTStmtReader::VisitExpr(Expr *E) {
411f4a2713aSLionel Sambuc   VisitStmt(E);
412f4a2713aSLionel Sambuc   E->setType(Reader.readType(F, Record, Idx));
413f4a2713aSLionel Sambuc   E->setTypeDependent(Record[Idx++]);
414f4a2713aSLionel Sambuc   E->setValueDependent(Record[Idx++]);
415f4a2713aSLionel Sambuc   E->setInstantiationDependent(Record[Idx++]);
416f4a2713aSLionel Sambuc   E->ExprBits.ContainsUnexpandedParameterPack = Record[Idx++];
417f4a2713aSLionel Sambuc   E->setValueKind(static_cast<ExprValueKind>(Record[Idx++]));
418f4a2713aSLionel Sambuc   E->setObjectKind(static_cast<ExprObjectKind>(Record[Idx++]));
419f4a2713aSLionel Sambuc   assert(Idx == NumExprFields && "Incorrect expression field count");
420f4a2713aSLionel Sambuc }
421f4a2713aSLionel Sambuc 
VisitPredefinedExpr(PredefinedExpr * E)422f4a2713aSLionel Sambuc void ASTStmtReader::VisitPredefinedExpr(PredefinedExpr *E) {
423f4a2713aSLionel Sambuc   VisitExpr(E);
424f4a2713aSLionel Sambuc   E->setLocation(ReadSourceLocation(Record, Idx));
425*0a6a1f1dSLionel Sambuc   E->Type = (PredefinedExpr::IdentType)Record[Idx++];
426*0a6a1f1dSLionel Sambuc   E->FnName = cast_or_null<StringLiteral>(Reader.ReadSubExpr());
427f4a2713aSLionel Sambuc }
428f4a2713aSLionel Sambuc 
VisitDeclRefExpr(DeclRefExpr * E)429f4a2713aSLionel Sambuc void ASTStmtReader::VisitDeclRefExpr(DeclRefExpr *E) {
430f4a2713aSLionel Sambuc   VisitExpr(E);
431f4a2713aSLionel Sambuc 
432f4a2713aSLionel Sambuc   E->DeclRefExprBits.HasQualifier = Record[Idx++];
433f4a2713aSLionel Sambuc   E->DeclRefExprBits.HasFoundDecl = Record[Idx++];
434f4a2713aSLionel Sambuc   E->DeclRefExprBits.HasTemplateKWAndArgsInfo = Record[Idx++];
435f4a2713aSLionel Sambuc   E->DeclRefExprBits.HadMultipleCandidates = Record[Idx++];
436*0a6a1f1dSLionel Sambuc   E->DeclRefExprBits.RefersToEnclosingVariableOrCapture = Record[Idx++];
437f4a2713aSLionel Sambuc   unsigned NumTemplateArgs = 0;
438f4a2713aSLionel Sambuc   if (E->hasTemplateKWAndArgsInfo())
439f4a2713aSLionel Sambuc     NumTemplateArgs = Record[Idx++];
440f4a2713aSLionel Sambuc 
441f4a2713aSLionel Sambuc   if (E->hasQualifier())
442f4a2713aSLionel Sambuc     E->getInternalQualifierLoc()
443f4a2713aSLionel Sambuc       = Reader.ReadNestedNameSpecifierLoc(F, Record, Idx);
444f4a2713aSLionel Sambuc 
445f4a2713aSLionel Sambuc   if (E->hasFoundDecl())
446f4a2713aSLionel Sambuc     E->getInternalFoundDecl() = ReadDeclAs<NamedDecl>(Record, Idx);
447f4a2713aSLionel Sambuc 
448f4a2713aSLionel Sambuc   if (E->hasTemplateKWAndArgsInfo())
449f4a2713aSLionel Sambuc     ReadTemplateKWAndArgsInfo(*E->getTemplateKWAndArgsInfo(),
450f4a2713aSLionel Sambuc                               NumTemplateArgs);
451f4a2713aSLionel Sambuc 
452f4a2713aSLionel Sambuc   E->setDecl(ReadDeclAs<ValueDecl>(Record, Idx));
453f4a2713aSLionel Sambuc   E->setLocation(ReadSourceLocation(Record, Idx));
454f4a2713aSLionel Sambuc   ReadDeclarationNameLoc(E->DNLoc, E->getDecl()->getDeclName(), Record, Idx);
455f4a2713aSLionel Sambuc }
456f4a2713aSLionel Sambuc 
VisitIntegerLiteral(IntegerLiteral * E)457f4a2713aSLionel Sambuc void ASTStmtReader::VisitIntegerLiteral(IntegerLiteral *E) {
458f4a2713aSLionel Sambuc   VisitExpr(E);
459f4a2713aSLionel Sambuc   E->setLocation(ReadSourceLocation(Record, Idx));
460f4a2713aSLionel Sambuc   E->setValue(Reader.getContext(), Reader.ReadAPInt(Record, Idx));
461f4a2713aSLionel Sambuc }
462f4a2713aSLionel Sambuc 
VisitFloatingLiteral(FloatingLiteral * E)463f4a2713aSLionel Sambuc void ASTStmtReader::VisitFloatingLiteral(FloatingLiteral *E) {
464f4a2713aSLionel Sambuc   VisitExpr(E);
465f4a2713aSLionel Sambuc   E->setRawSemantics(static_cast<Stmt::APFloatSemantics>(Record[Idx++]));
466f4a2713aSLionel Sambuc   E->setExact(Record[Idx++]);
467f4a2713aSLionel Sambuc   E->setValue(Reader.getContext(),
468f4a2713aSLionel Sambuc               Reader.ReadAPFloat(Record, E->getSemantics(), Idx));
469f4a2713aSLionel Sambuc   E->setLocation(ReadSourceLocation(Record, Idx));
470f4a2713aSLionel Sambuc }
471f4a2713aSLionel Sambuc 
VisitImaginaryLiteral(ImaginaryLiteral * E)472f4a2713aSLionel Sambuc void ASTStmtReader::VisitImaginaryLiteral(ImaginaryLiteral *E) {
473f4a2713aSLionel Sambuc   VisitExpr(E);
474f4a2713aSLionel Sambuc   E->setSubExpr(Reader.ReadSubExpr());
475f4a2713aSLionel Sambuc }
476f4a2713aSLionel Sambuc 
VisitStringLiteral(StringLiteral * E)477f4a2713aSLionel Sambuc void ASTStmtReader::VisitStringLiteral(StringLiteral *E) {
478f4a2713aSLionel Sambuc   VisitExpr(E);
479f4a2713aSLionel Sambuc   unsigned Len = Record[Idx++];
480f4a2713aSLionel Sambuc   assert(Record[Idx] == E->getNumConcatenated() &&
481f4a2713aSLionel Sambuc          "Wrong number of concatenated tokens!");
482f4a2713aSLionel Sambuc   ++Idx;
483f4a2713aSLionel Sambuc   StringLiteral::StringKind kind =
484f4a2713aSLionel Sambuc         static_cast<StringLiteral::StringKind>(Record[Idx++]);
485f4a2713aSLionel Sambuc   bool isPascal = Record[Idx++];
486f4a2713aSLionel Sambuc 
487f4a2713aSLionel Sambuc   // Read string data
488f4a2713aSLionel Sambuc   SmallString<16> Str(&Record[Idx], &Record[Idx] + Len);
489f4a2713aSLionel Sambuc   E->setString(Reader.getContext(), Str.str(), kind, isPascal);
490f4a2713aSLionel Sambuc   Idx += Len;
491f4a2713aSLionel Sambuc 
492f4a2713aSLionel Sambuc   // Read source locations
493f4a2713aSLionel Sambuc   for (unsigned I = 0, N = E->getNumConcatenated(); I != N; ++I)
494f4a2713aSLionel Sambuc     E->setStrTokenLoc(I, ReadSourceLocation(Record, Idx));
495f4a2713aSLionel Sambuc }
496f4a2713aSLionel Sambuc 
VisitCharacterLiteral(CharacterLiteral * E)497f4a2713aSLionel Sambuc void ASTStmtReader::VisitCharacterLiteral(CharacterLiteral *E) {
498f4a2713aSLionel Sambuc   VisitExpr(E);
499f4a2713aSLionel Sambuc   E->setValue(Record[Idx++]);
500f4a2713aSLionel Sambuc   E->setLocation(ReadSourceLocation(Record, Idx));
501f4a2713aSLionel Sambuc   E->setKind(static_cast<CharacterLiteral::CharacterKind>(Record[Idx++]));
502f4a2713aSLionel Sambuc }
503f4a2713aSLionel Sambuc 
VisitParenExpr(ParenExpr * E)504f4a2713aSLionel Sambuc void ASTStmtReader::VisitParenExpr(ParenExpr *E) {
505f4a2713aSLionel Sambuc   VisitExpr(E);
506f4a2713aSLionel Sambuc   E->setLParen(ReadSourceLocation(Record, Idx));
507f4a2713aSLionel Sambuc   E->setRParen(ReadSourceLocation(Record, Idx));
508f4a2713aSLionel Sambuc   E->setSubExpr(Reader.ReadSubExpr());
509f4a2713aSLionel Sambuc }
510f4a2713aSLionel Sambuc 
VisitParenListExpr(ParenListExpr * E)511f4a2713aSLionel Sambuc void ASTStmtReader::VisitParenListExpr(ParenListExpr *E) {
512f4a2713aSLionel Sambuc   VisitExpr(E);
513f4a2713aSLionel Sambuc   unsigned NumExprs = Record[Idx++];
514f4a2713aSLionel Sambuc   E->Exprs = new (Reader.getContext()) Stmt*[NumExprs];
515f4a2713aSLionel Sambuc   for (unsigned i = 0; i != NumExprs; ++i)
516f4a2713aSLionel Sambuc     E->Exprs[i] = Reader.ReadSubStmt();
517f4a2713aSLionel Sambuc   E->NumExprs = NumExprs;
518f4a2713aSLionel Sambuc   E->LParenLoc = ReadSourceLocation(Record, Idx);
519f4a2713aSLionel Sambuc   E->RParenLoc = ReadSourceLocation(Record, Idx);
520f4a2713aSLionel Sambuc }
521f4a2713aSLionel Sambuc 
VisitUnaryOperator(UnaryOperator * E)522f4a2713aSLionel Sambuc void ASTStmtReader::VisitUnaryOperator(UnaryOperator *E) {
523f4a2713aSLionel Sambuc   VisitExpr(E);
524f4a2713aSLionel Sambuc   E->setSubExpr(Reader.ReadSubExpr());
525f4a2713aSLionel Sambuc   E->setOpcode((UnaryOperator::Opcode)Record[Idx++]);
526f4a2713aSLionel Sambuc   E->setOperatorLoc(ReadSourceLocation(Record, Idx));
527f4a2713aSLionel Sambuc }
528f4a2713aSLionel Sambuc 
VisitOffsetOfExpr(OffsetOfExpr * E)529f4a2713aSLionel Sambuc void ASTStmtReader::VisitOffsetOfExpr(OffsetOfExpr *E) {
530f4a2713aSLionel Sambuc   typedef OffsetOfExpr::OffsetOfNode Node;
531f4a2713aSLionel Sambuc   VisitExpr(E);
532f4a2713aSLionel Sambuc   assert(E->getNumComponents() == Record[Idx]);
533f4a2713aSLionel Sambuc   ++Idx;
534f4a2713aSLionel Sambuc   assert(E->getNumExpressions() == Record[Idx]);
535f4a2713aSLionel Sambuc   ++Idx;
536f4a2713aSLionel Sambuc   E->setOperatorLoc(ReadSourceLocation(Record, Idx));
537f4a2713aSLionel Sambuc   E->setRParenLoc(ReadSourceLocation(Record, Idx));
538f4a2713aSLionel Sambuc   E->setTypeSourceInfo(GetTypeSourceInfo(Record, Idx));
539f4a2713aSLionel Sambuc   for (unsigned I = 0, N = E->getNumComponents(); I != N; ++I) {
540f4a2713aSLionel Sambuc     Node::Kind Kind = static_cast<Node::Kind>(Record[Idx++]);
541f4a2713aSLionel Sambuc     SourceLocation Start = ReadSourceLocation(Record, Idx);
542f4a2713aSLionel Sambuc     SourceLocation End = ReadSourceLocation(Record, Idx);
543f4a2713aSLionel Sambuc     switch (Kind) {
544f4a2713aSLionel Sambuc     case Node::Array:
545f4a2713aSLionel Sambuc       E->setComponent(I, Node(Start, Record[Idx++], End));
546f4a2713aSLionel Sambuc       break;
547f4a2713aSLionel Sambuc 
548f4a2713aSLionel Sambuc     case Node::Field:
549f4a2713aSLionel Sambuc       E->setComponent(I, Node(Start, ReadDeclAs<FieldDecl>(Record, Idx), End));
550f4a2713aSLionel Sambuc       break;
551f4a2713aSLionel Sambuc 
552f4a2713aSLionel Sambuc     case Node::Identifier:
553f4a2713aSLionel Sambuc       E->setComponent(I,
554f4a2713aSLionel Sambuc                       Node(Start,
555f4a2713aSLionel Sambuc                            Reader.GetIdentifierInfo(F, Record, Idx),
556f4a2713aSLionel Sambuc                            End));
557f4a2713aSLionel Sambuc       break;
558f4a2713aSLionel Sambuc 
559f4a2713aSLionel Sambuc     case Node::Base: {
560f4a2713aSLionel Sambuc       CXXBaseSpecifier *Base = new (Reader.getContext()) CXXBaseSpecifier();
561f4a2713aSLionel Sambuc       *Base = Reader.ReadCXXBaseSpecifier(F, Record, Idx);
562f4a2713aSLionel Sambuc       E->setComponent(I, Node(Base));
563f4a2713aSLionel Sambuc       break;
564f4a2713aSLionel Sambuc     }
565f4a2713aSLionel Sambuc     }
566f4a2713aSLionel Sambuc   }
567f4a2713aSLionel Sambuc 
568f4a2713aSLionel Sambuc   for (unsigned I = 0, N = E->getNumExpressions(); I != N; ++I)
569f4a2713aSLionel Sambuc     E->setIndexExpr(I, Reader.ReadSubExpr());
570f4a2713aSLionel Sambuc }
571f4a2713aSLionel Sambuc 
VisitUnaryExprOrTypeTraitExpr(UnaryExprOrTypeTraitExpr * E)572f4a2713aSLionel Sambuc void ASTStmtReader::VisitUnaryExprOrTypeTraitExpr(UnaryExprOrTypeTraitExpr *E) {
573f4a2713aSLionel Sambuc   VisitExpr(E);
574f4a2713aSLionel Sambuc   E->setKind(static_cast<UnaryExprOrTypeTrait>(Record[Idx++]));
575f4a2713aSLionel Sambuc   if (Record[Idx] == 0) {
576f4a2713aSLionel Sambuc     E->setArgument(Reader.ReadSubExpr());
577f4a2713aSLionel Sambuc     ++Idx;
578f4a2713aSLionel Sambuc   } else {
579f4a2713aSLionel Sambuc     E->setArgument(GetTypeSourceInfo(Record, Idx));
580f4a2713aSLionel Sambuc   }
581f4a2713aSLionel Sambuc   E->setOperatorLoc(ReadSourceLocation(Record, Idx));
582f4a2713aSLionel Sambuc   E->setRParenLoc(ReadSourceLocation(Record, Idx));
583f4a2713aSLionel Sambuc }
584f4a2713aSLionel Sambuc 
VisitArraySubscriptExpr(ArraySubscriptExpr * E)585f4a2713aSLionel Sambuc void ASTStmtReader::VisitArraySubscriptExpr(ArraySubscriptExpr *E) {
586f4a2713aSLionel Sambuc   VisitExpr(E);
587f4a2713aSLionel Sambuc   E->setLHS(Reader.ReadSubExpr());
588f4a2713aSLionel Sambuc   E->setRHS(Reader.ReadSubExpr());
589f4a2713aSLionel Sambuc   E->setRBracketLoc(ReadSourceLocation(Record, Idx));
590f4a2713aSLionel Sambuc }
591f4a2713aSLionel Sambuc 
VisitCallExpr(CallExpr * E)592f4a2713aSLionel Sambuc void ASTStmtReader::VisitCallExpr(CallExpr *E) {
593f4a2713aSLionel Sambuc   VisitExpr(E);
594f4a2713aSLionel Sambuc   E->setNumArgs(Reader.getContext(), Record[Idx++]);
595f4a2713aSLionel Sambuc   E->setRParenLoc(ReadSourceLocation(Record, Idx));
596f4a2713aSLionel Sambuc   E->setCallee(Reader.ReadSubExpr());
597f4a2713aSLionel Sambuc   for (unsigned I = 0, N = E->getNumArgs(); I != N; ++I)
598f4a2713aSLionel Sambuc     E->setArg(I, Reader.ReadSubExpr());
599f4a2713aSLionel Sambuc }
600f4a2713aSLionel Sambuc 
VisitCXXMemberCallExpr(CXXMemberCallExpr * E)601f4a2713aSLionel Sambuc void ASTStmtReader::VisitCXXMemberCallExpr(CXXMemberCallExpr *E) {
602f4a2713aSLionel Sambuc   VisitCallExpr(E);
603f4a2713aSLionel Sambuc }
604f4a2713aSLionel Sambuc 
VisitMemberExpr(MemberExpr * E)605f4a2713aSLionel Sambuc void ASTStmtReader::VisitMemberExpr(MemberExpr *E) {
606f4a2713aSLionel Sambuc   // Don't call VisitExpr, this is fully initialized at creation.
607f4a2713aSLionel Sambuc   assert(E->getStmtClass() == Stmt::MemberExprClass &&
608f4a2713aSLionel Sambuc          "It's a subclass, we must advance Idx!");
609f4a2713aSLionel Sambuc }
610f4a2713aSLionel Sambuc 
VisitObjCIsaExpr(ObjCIsaExpr * E)611f4a2713aSLionel Sambuc void ASTStmtReader::VisitObjCIsaExpr(ObjCIsaExpr *E) {
612f4a2713aSLionel Sambuc   VisitExpr(E);
613f4a2713aSLionel Sambuc   E->setBase(Reader.ReadSubExpr());
614f4a2713aSLionel Sambuc   E->setIsaMemberLoc(ReadSourceLocation(Record, Idx));
615f4a2713aSLionel Sambuc   E->setOpLoc(ReadSourceLocation(Record, Idx));
616f4a2713aSLionel Sambuc   E->setArrow(Record[Idx++]);
617f4a2713aSLionel Sambuc }
618f4a2713aSLionel Sambuc 
619f4a2713aSLionel Sambuc void ASTStmtReader::
VisitObjCIndirectCopyRestoreExpr(ObjCIndirectCopyRestoreExpr * E)620f4a2713aSLionel Sambuc VisitObjCIndirectCopyRestoreExpr(ObjCIndirectCopyRestoreExpr *E) {
621f4a2713aSLionel Sambuc   VisitExpr(E);
622f4a2713aSLionel Sambuc   E->Operand = Reader.ReadSubExpr();
623f4a2713aSLionel Sambuc   E->setShouldCopy(Record[Idx++]);
624f4a2713aSLionel Sambuc }
625f4a2713aSLionel Sambuc 
VisitObjCBridgedCastExpr(ObjCBridgedCastExpr * E)626f4a2713aSLionel Sambuc void ASTStmtReader::VisitObjCBridgedCastExpr(ObjCBridgedCastExpr *E) {
627f4a2713aSLionel Sambuc   VisitExplicitCastExpr(E);
628f4a2713aSLionel Sambuc   E->LParenLoc = ReadSourceLocation(Record, Idx);
629f4a2713aSLionel Sambuc   E->BridgeKeywordLoc = ReadSourceLocation(Record, Idx);
630f4a2713aSLionel Sambuc   E->Kind = Record[Idx++];
631f4a2713aSLionel Sambuc }
632f4a2713aSLionel Sambuc 
VisitCastExpr(CastExpr * E)633f4a2713aSLionel Sambuc void ASTStmtReader::VisitCastExpr(CastExpr *E) {
634f4a2713aSLionel Sambuc   VisitExpr(E);
635f4a2713aSLionel Sambuc   unsigned NumBaseSpecs = Record[Idx++];
636f4a2713aSLionel Sambuc   assert(NumBaseSpecs == E->path_size());
637f4a2713aSLionel Sambuc   E->setSubExpr(Reader.ReadSubExpr());
638*0a6a1f1dSLionel Sambuc   E->setCastKind((CastKind)Record[Idx++]);
639f4a2713aSLionel Sambuc   CastExpr::path_iterator BaseI = E->path_begin();
640f4a2713aSLionel Sambuc   while (NumBaseSpecs--) {
641f4a2713aSLionel Sambuc     CXXBaseSpecifier *BaseSpec = new (Reader.getContext()) CXXBaseSpecifier;
642f4a2713aSLionel Sambuc     *BaseSpec = Reader.ReadCXXBaseSpecifier(F, Record, Idx);
643f4a2713aSLionel Sambuc     *BaseI++ = BaseSpec;
644f4a2713aSLionel Sambuc   }
645f4a2713aSLionel Sambuc }
646f4a2713aSLionel Sambuc 
VisitBinaryOperator(BinaryOperator * E)647f4a2713aSLionel Sambuc void ASTStmtReader::VisitBinaryOperator(BinaryOperator *E) {
648f4a2713aSLionel Sambuc   VisitExpr(E);
649f4a2713aSLionel Sambuc   E->setLHS(Reader.ReadSubExpr());
650f4a2713aSLionel Sambuc   E->setRHS(Reader.ReadSubExpr());
651f4a2713aSLionel Sambuc   E->setOpcode((BinaryOperator::Opcode)Record[Idx++]);
652f4a2713aSLionel Sambuc   E->setOperatorLoc(ReadSourceLocation(Record, Idx));
653f4a2713aSLionel Sambuc   E->setFPContractable((bool)Record[Idx++]);
654f4a2713aSLionel Sambuc }
655f4a2713aSLionel Sambuc 
VisitCompoundAssignOperator(CompoundAssignOperator * E)656f4a2713aSLionel Sambuc void ASTStmtReader::VisitCompoundAssignOperator(CompoundAssignOperator *E) {
657f4a2713aSLionel Sambuc   VisitBinaryOperator(E);
658f4a2713aSLionel Sambuc   E->setComputationLHSType(Reader.readType(F, Record, Idx));
659f4a2713aSLionel Sambuc   E->setComputationResultType(Reader.readType(F, Record, Idx));
660f4a2713aSLionel Sambuc }
661f4a2713aSLionel Sambuc 
VisitConditionalOperator(ConditionalOperator * E)662f4a2713aSLionel Sambuc void ASTStmtReader::VisitConditionalOperator(ConditionalOperator *E) {
663f4a2713aSLionel Sambuc   VisitExpr(E);
664f4a2713aSLionel Sambuc   E->SubExprs[ConditionalOperator::COND] = Reader.ReadSubExpr();
665f4a2713aSLionel Sambuc   E->SubExprs[ConditionalOperator::LHS] = Reader.ReadSubExpr();
666f4a2713aSLionel Sambuc   E->SubExprs[ConditionalOperator::RHS] = Reader.ReadSubExpr();
667f4a2713aSLionel Sambuc   E->QuestionLoc = ReadSourceLocation(Record, Idx);
668f4a2713aSLionel Sambuc   E->ColonLoc = ReadSourceLocation(Record, Idx);
669f4a2713aSLionel Sambuc }
670f4a2713aSLionel Sambuc 
671f4a2713aSLionel Sambuc void
VisitBinaryConditionalOperator(BinaryConditionalOperator * E)672f4a2713aSLionel Sambuc ASTStmtReader::VisitBinaryConditionalOperator(BinaryConditionalOperator *E) {
673f4a2713aSLionel Sambuc   VisitExpr(E);
674f4a2713aSLionel Sambuc   E->OpaqueValue = cast<OpaqueValueExpr>(Reader.ReadSubExpr());
675f4a2713aSLionel Sambuc   E->SubExprs[BinaryConditionalOperator::COMMON] = Reader.ReadSubExpr();
676f4a2713aSLionel Sambuc   E->SubExprs[BinaryConditionalOperator::COND] = Reader.ReadSubExpr();
677f4a2713aSLionel Sambuc   E->SubExprs[BinaryConditionalOperator::LHS] = Reader.ReadSubExpr();
678f4a2713aSLionel Sambuc   E->SubExprs[BinaryConditionalOperator::RHS] = Reader.ReadSubExpr();
679f4a2713aSLionel Sambuc   E->QuestionLoc = ReadSourceLocation(Record, Idx);
680f4a2713aSLionel Sambuc   E->ColonLoc = ReadSourceLocation(Record, Idx);
681f4a2713aSLionel Sambuc }
682f4a2713aSLionel Sambuc 
VisitImplicitCastExpr(ImplicitCastExpr * E)683f4a2713aSLionel Sambuc void ASTStmtReader::VisitImplicitCastExpr(ImplicitCastExpr *E) {
684f4a2713aSLionel Sambuc   VisitCastExpr(E);
685f4a2713aSLionel Sambuc }
686f4a2713aSLionel Sambuc 
VisitExplicitCastExpr(ExplicitCastExpr * E)687f4a2713aSLionel Sambuc void ASTStmtReader::VisitExplicitCastExpr(ExplicitCastExpr *E) {
688f4a2713aSLionel Sambuc   VisitCastExpr(E);
689f4a2713aSLionel Sambuc   E->setTypeInfoAsWritten(GetTypeSourceInfo(Record, Idx));
690f4a2713aSLionel Sambuc }
691f4a2713aSLionel Sambuc 
VisitCStyleCastExpr(CStyleCastExpr * E)692f4a2713aSLionel Sambuc void ASTStmtReader::VisitCStyleCastExpr(CStyleCastExpr *E) {
693f4a2713aSLionel Sambuc   VisitExplicitCastExpr(E);
694f4a2713aSLionel Sambuc   E->setLParenLoc(ReadSourceLocation(Record, Idx));
695f4a2713aSLionel Sambuc   E->setRParenLoc(ReadSourceLocation(Record, Idx));
696f4a2713aSLionel Sambuc }
697f4a2713aSLionel Sambuc 
VisitCompoundLiteralExpr(CompoundLiteralExpr * E)698f4a2713aSLionel Sambuc void ASTStmtReader::VisitCompoundLiteralExpr(CompoundLiteralExpr *E) {
699f4a2713aSLionel Sambuc   VisitExpr(E);
700f4a2713aSLionel Sambuc   E->setLParenLoc(ReadSourceLocation(Record, Idx));
701f4a2713aSLionel Sambuc   E->setTypeSourceInfo(GetTypeSourceInfo(Record, Idx));
702f4a2713aSLionel Sambuc   E->setInitializer(Reader.ReadSubExpr());
703f4a2713aSLionel Sambuc   E->setFileScope(Record[Idx++]);
704f4a2713aSLionel Sambuc }
705f4a2713aSLionel Sambuc 
VisitExtVectorElementExpr(ExtVectorElementExpr * E)706f4a2713aSLionel Sambuc void ASTStmtReader::VisitExtVectorElementExpr(ExtVectorElementExpr *E) {
707f4a2713aSLionel Sambuc   VisitExpr(E);
708f4a2713aSLionel Sambuc   E->setBase(Reader.ReadSubExpr());
709f4a2713aSLionel Sambuc   E->setAccessor(Reader.GetIdentifierInfo(F, Record, Idx));
710f4a2713aSLionel Sambuc   E->setAccessorLoc(ReadSourceLocation(Record, Idx));
711f4a2713aSLionel Sambuc }
712f4a2713aSLionel Sambuc 
VisitInitListExpr(InitListExpr * E)713f4a2713aSLionel Sambuc void ASTStmtReader::VisitInitListExpr(InitListExpr *E) {
714f4a2713aSLionel Sambuc   VisitExpr(E);
715f4a2713aSLionel Sambuc   if (InitListExpr *SyntForm = cast_or_null<InitListExpr>(Reader.ReadSubStmt()))
716f4a2713aSLionel Sambuc     E->setSyntacticForm(SyntForm);
717f4a2713aSLionel Sambuc   E->setLBraceLoc(ReadSourceLocation(Record, Idx));
718f4a2713aSLionel Sambuc   E->setRBraceLoc(ReadSourceLocation(Record, Idx));
719f4a2713aSLionel Sambuc   bool isArrayFiller = Record[Idx++];
720*0a6a1f1dSLionel Sambuc   Expr *filler = nullptr;
721f4a2713aSLionel Sambuc   if (isArrayFiller) {
722f4a2713aSLionel Sambuc     filler = Reader.ReadSubExpr();
723f4a2713aSLionel Sambuc     E->ArrayFillerOrUnionFieldInit = filler;
724f4a2713aSLionel Sambuc   } else
725f4a2713aSLionel Sambuc     E->ArrayFillerOrUnionFieldInit = ReadDeclAs<FieldDecl>(Record, Idx);
726f4a2713aSLionel Sambuc   E->sawArrayRangeDesignator(Record[Idx++]);
727f4a2713aSLionel Sambuc   unsigned NumInits = Record[Idx++];
728f4a2713aSLionel Sambuc   E->reserveInits(Reader.getContext(), NumInits);
729f4a2713aSLionel Sambuc   if (isArrayFiller) {
730f4a2713aSLionel Sambuc     for (unsigned I = 0; I != NumInits; ++I) {
731f4a2713aSLionel Sambuc       Expr *init = Reader.ReadSubExpr();
732f4a2713aSLionel Sambuc       E->updateInit(Reader.getContext(), I, init ? init : filler);
733f4a2713aSLionel Sambuc     }
734f4a2713aSLionel Sambuc   } else {
735f4a2713aSLionel Sambuc     for (unsigned I = 0; I != NumInits; ++I)
736f4a2713aSLionel Sambuc       E->updateInit(Reader.getContext(), I, Reader.ReadSubExpr());
737f4a2713aSLionel Sambuc   }
738f4a2713aSLionel Sambuc }
739f4a2713aSLionel Sambuc 
VisitDesignatedInitExpr(DesignatedInitExpr * E)740f4a2713aSLionel Sambuc void ASTStmtReader::VisitDesignatedInitExpr(DesignatedInitExpr *E) {
741f4a2713aSLionel Sambuc   typedef DesignatedInitExpr::Designator Designator;
742f4a2713aSLionel Sambuc 
743f4a2713aSLionel Sambuc   VisitExpr(E);
744f4a2713aSLionel Sambuc   unsigned NumSubExprs = Record[Idx++];
745f4a2713aSLionel Sambuc   assert(NumSubExprs == E->getNumSubExprs() && "Wrong number of subexprs");
746f4a2713aSLionel Sambuc   for (unsigned I = 0; I != NumSubExprs; ++I)
747f4a2713aSLionel Sambuc     E->setSubExpr(I, Reader.ReadSubExpr());
748f4a2713aSLionel Sambuc   E->setEqualOrColonLoc(ReadSourceLocation(Record, Idx));
749f4a2713aSLionel Sambuc   E->setGNUSyntax(Record[Idx++]);
750f4a2713aSLionel Sambuc 
751f4a2713aSLionel Sambuc   SmallVector<Designator, 4> Designators;
752f4a2713aSLionel Sambuc   while (Idx < Record.size()) {
753f4a2713aSLionel Sambuc     switch ((DesignatorTypes)Record[Idx++]) {
754f4a2713aSLionel Sambuc     case DESIG_FIELD_DECL: {
755f4a2713aSLionel Sambuc       FieldDecl *Field = ReadDeclAs<FieldDecl>(Record, Idx);
756f4a2713aSLionel Sambuc       SourceLocation DotLoc
757f4a2713aSLionel Sambuc         = ReadSourceLocation(Record, Idx);
758f4a2713aSLionel Sambuc       SourceLocation FieldLoc
759f4a2713aSLionel Sambuc         = ReadSourceLocation(Record, Idx);
760f4a2713aSLionel Sambuc       Designators.push_back(Designator(Field->getIdentifier(), DotLoc,
761f4a2713aSLionel Sambuc                                        FieldLoc));
762f4a2713aSLionel Sambuc       Designators.back().setField(Field);
763f4a2713aSLionel Sambuc       break;
764f4a2713aSLionel Sambuc     }
765f4a2713aSLionel Sambuc 
766f4a2713aSLionel Sambuc     case DESIG_FIELD_NAME: {
767f4a2713aSLionel Sambuc       const IdentifierInfo *Name = Reader.GetIdentifierInfo(F, Record, Idx);
768f4a2713aSLionel Sambuc       SourceLocation DotLoc
769f4a2713aSLionel Sambuc         = ReadSourceLocation(Record, Idx);
770f4a2713aSLionel Sambuc       SourceLocation FieldLoc
771f4a2713aSLionel Sambuc         = ReadSourceLocation(Record, Idx);
772f4a2713aSLionel Sambuc       Designators.push_back(Designator(Name, DotLoc, FieldLoc));
773f4a2713aSLionel Sambuc       break;
774f4a2713aSLionel Sambuc     }
775f4a2713aSLionel Sambuc 
776f4a2713aSLionel Sambuc     case DESIG_ARRAY: {
777f4a2713aSLionel Sambuc       unsigned Index = Record[Idx++];
778f4a2713aSLionel Sambuc       SourceLocation LBracketLoc
779f4a2713aSLionel Sambuc         = ReadSourceLocation(Record, Idx);
780f4a2713aSLionel Sambuc       SourceLocation RBracketLoc
781f4a2713aSLionel Sambuc         = ReadSourceLocation(Record, Idx);
782f4a2713aSLionel Sambuc       Designators.push_back(Designator(Index, LBracketLoc, RBracketLoc));
783f4a2713aSLionel Sambuc       break;
784f4a2713aSLionel Sambuc     }
785f4a2713aSLionel Sambuc 
786f4a2713aSLionel Sambuc     case DESIG_ARRAY_RANGE: {
787f4a2713aSLionel Sambuc       unsigned Index = Record[Idx++];
788f4a2713aSLionel Sambuc       SourceLocation LBracketLoc
789f4a2713aSLionel Sambuc         = ReadSourceLocation(Record, Idx);
790f4a2713aSLionel Sambuc       SourceLocation EllipsisLoc
791f4a2713aSLionel Sambuc         = ReadSourceLocation(Record, Idx);
792f4a2713aSLionel Sambuc       SourceLocation RBracketLoc
793f4a2713aSLionel Sambuc         = ReadSourceLocation(Record, Idx);
794f4a2713aSLionel Sambuc       Designators.push_back(Designator(Index, LBracketLoc, EllipsisLoc,
795f4a2713aSLionel Sambuc                                        RBracketLoc));
796f4a2713aSLionel Sambuc       break;
797f4a2713aSLionel Sambuc     }
798f4a2713aSLionel Sambuc     }
799f4a2713aSLionel Sambuc   }
800f4a2713aSLionel Sambuc   E->setDesignators(Reader.getContext(),
801f4a2713aSLionel Sambuc                     Designators.data(), Designators.size());
802f4a2713aSLionel Sambuc }
803f4a2713aSLionel Sambuc 
VisitImplicitValueInitExpr(ImplicitValueInitExpr * E)804f4a2713aSLionel Sambuc void ASTStmtReader::VisitImplicitValueInitExpr(ImplicitValueInitExpr *E) {
805f4a2713aSLionel Sambuc   VisitExpr(E);
806f4a2713aSLionel Sambuc }
807f4a2713aSLionel Sambuc 
VisitVAArgExpr(VAArgExpr * E)808f4a2713aSLionel Sambuc void ASTStmtReader::VisitVAArgExpr(VAArgExpr *E) {
809f4a2713aSLionel Sambuc   VisitExpr(E);
810f4a2713aSLionel Sambuc   E->setSubExpr(Reader.ReadSubExpr());
811f4a2713aSLionel Sambuc   E->setWrittenTypeInfo(GetTypeSourceInfo(Record, Idx));
812f4a2713aSLionel Sambuc   E->setBuiltinLoc(ReadSourceLocation(Record, Idx));
813f4a2713aSLionel Sambuc   E->setRParenLoc(ReadSourceLocation(Record, Idx));
814f4a2713aSLionel Sambuc }
815f4a2713aSLionel Sambuc 
VisitAddrLabelExpr(AddrLabelExpr * E)816f4a2713aSLionel Sambuc void ASTStmtReader::VisitAddrLabelExpr(AddrLabelExpr *E) {
817f4a2713aSLionel Sambuc   VisitExpr(E);
818f4a2713aSLionel Sambuc   E->setAmpAmpLoc(ReadSourceLocation(Record, Idx));
819f4a2713aSLionel Sambuc   E->setLabelLoc(ReadSourceLocation(Record, Idx));
820f4a2713aSLionel Sambuc   E->setLabel(ReadDeclAs<LabelDecl>(Record, Idx));
821f4a2713aSLionel Sambuc }
822f4a2713aSLionel Sambuc 
VisitStmtExpr(StmtExpr * E)823f4a2713aSLionel Sambuc void ASTStmtReader::VisitStmtExpr(StmtExpr *E) {
824f4a2713aSLionel Sambuc   VisitExpr(E);
825f4a2713aSLionel Sambuc   E->setLParenLoc(ReadSourceLocation(Record, Idx));
826f4a2713aSLionel Sambuc   E->setRParenLoc(ReadSourceLocation(Record, Idx));
827f4a2713aSLionel Sambuc   E->setSubStmt(cast_or_null<CompoundStmt>(Reader.ReadSubStmt()));
828f4a2713aSLionel Sambuc }
829f4a2713aSLionel Sambuc 
VisitChooseExpr(ChooseExpr * E)830f4a2713aSLionel Sambuc void ASTStmtReader::VisitChooseExpr(ChooseExpr *E) {
831f4a2713aSLionel Sambuc   VisitExpr(E);
832f4a2713aSLionel Sambuc   E->setCond(Reader.ReadSubExpr());
833f4a2713aSLionel Sambuc   E->setLHS(Reader.ReadSubExpr());
834f4a2713aSLionel Sambuc   E->setRHS(Reader.ReadSubExpr());
835f4a2713aSLionel Sambuc   E->setBuiltinLoc(ReadSourceLocation(Record, Idx));
836f4a2713aSLionel Sambuc   E->setRParenLoc(ReadSourceLocation(Record, Idx));
837f4a2713aSLionel Sambuc   E->setIsConditionTrue(Record[Idx++]);
838f4a2713aSLionel Sambuc }
839f4a2713aSLionel Sambuc 
VisitGNUNullExpr(GNUNullExpr * E)840f4a2713aSLionel Sambuc void ASTStmtReader::VisitGNUNullExpr(GNUNullExpr *E) {
841f4a2713aSLionel Sambuc   VisitExpr(E);
842f4a2713aSLionel Sambuc   E->setTokenLocation(ReadSourceLocation(Record, Idx));
843f4a2713aSLionel Sambuc }
844f4a2713aSLionel Sambuc 
VisitShuffleVectorExpr(ShuffleVectorExpr * E)845f4a2713aSLionel Sambuc void ASTStmtReader::VisitShuffleVectorExpr(ShuffleVectorExpr *E) {
846f4a2713aSLionel Sambuc   VisitExpr(E);
847f4a2713aSLionel Sambuc   SmallVector<Expr *, 16> Exprs;
848f4a2713aSLionel Sambuc   unsigned NumExprs = Record[Idx++];
849f4a2713aSLionel Sambuc   while (NumExprs--)
850f4a2713aSLionel Sambuc     Exprs.push_back(Reader.ReadSubExpr());
851f4a2713aSLionel Sambuc   E->setExprs(Reader.getContext(), Exprs);
852f4a2713aSLionel Sambuc   E->setBuiltinLoc(ReadSourceLocation(Record, Idx));
853f4a2713aSLionel Sambuc   E->setRParenLoc(ReadSourceLocation(Record, Idx));
854f4a2713aSLionel Sambuc }
855f4a2713aSLionel Sambuc 
VisitConvertVectorExpr(ConvertVectorExpr * E)856f4a2713aSLionel Sambuc void ASTStmtReader::VisitConvertVectorExpr(ConvertVectorExpr *E) {
857f4a2713aSLionel Sambuc   VisitExpr(E);
858f4a2713aSLionel Sambuc   E->BuiltinLoc = ReadSourceLocation(Record, Idx);
859f4a2713aSLionel Sambuc   E->RParenLoc = ReadSourceLocation(Record, Idx);
860f4a2713aSLionel Sambuc   E->TInfo = GetTypeSourceInfo(Record, Idx);
861f4a2713aSLionel Sambuc   E->SrcExpr = Reader.ReadSubExpr();
862f4a2713aSLionel Sambuc }
863f4a2713aSLionel Sambuc 
VisitBlockExpr(BlockExpr * E)864f4a2713aSLionel Sambuc void ASTStmtReader::VisitBlockExpr(BlockExpr *E) {
865f4a2713aSLionel Sambuc   VisitExpr(E);
866f4a2713aSLionel Sambuc   E->setBlockDecl(ReadDeclAs<BlockDecl>(Record, Idx));
867f4a2713aSLionel Sambuc }
868f4a2713aSLionel Sambuc 
VisitGenericSelectionExpr(GenericSelectionExpr * E)869f4a2713aSLionel Sambuc void ASTStmtReader::VisitGenericSelectionExpr(GenericSelectionExpr *E) {
870f4a2713aSLionel Sambuc   VisitExpr(E);
871f4a2713aSLionel Sambuc   E->NumAssocs = Record[Idx++];
872f4a2713aSLionel Sambuc   E->AssocTypes = new (Reader.getContext()) TypeSourceInfo*[E->NumAssocs];
873f4a2713aSLionel Sambuc   E->SubExprs =
874f4a2713aSLionel Sambuc    new(Reader.getContext()) Stmt*[GenericSelectionExpr::END_EXPR+E->NumAssocs];
875f4a2713aSLionel Sambuc 
876f4a2713aSLionel Sambuc   E->SubExprs[GenericSelectionExpr::CONTROLLING] = Reader.ReadSubExpr();
877f4a2713aSLionel Sambuc   for (unsigned I = 0, N = E->getNumAssocs(); I != N; ++I) {
878f4a2713aSLionel Sambuc     E->AssocTypes[I] = GetTypeSourceInfo(Record, Idx);
879f4a2713aSLionel Sambuc     E->SubExprs[GenericSelectionExpr::END_EXPR+I] = Reader.ReadSubExpr();
880f4a2713aSLionel Sambuc   }
881f4a2713aSLionel Sambuc   E->ResultIndex = Record[Idx++];
882f4a2713aSLionel Sambuc 
883f4a2713aSLionel Sambuc   E->GenericLoc = ReadSourceLocation(Record, Idx);
884f4a2713aSLionel Sambuc   E->DefaultLoc = ReadSourceLocation(Record, Idx);
885f4a2713aSLionel Sambuc   E->RParenLoc = ReadSourceLocation(Record, Idx);
886f4a2713aSLionel Sambuc }
887f4a2713aSLionel Sambuc 
VisitPseudoObjectExpr(PseudoObjectExpr * E)888f4a2713aSLionel Sambuc void ASTStmtReader::VisitPseudoObjectExpr(PseudoObjectExpr *E) {
889f4a2713aSLionel Sambuc   VisitExpr(E);
890f4a2713aSLionel Sambuc   unsigned numSemanticExprs = Record[Idx++];
891f4a2713aSLionel Sambuc   assert(numSemanticExprs + 1 == E->PseudoObjectExprBits.NumSubExprs);
892f4a2713aSLionel Sambuc   E->PseudoObjectExprBits.ResultIndex = Record[Idx++];
893f4a2713aSLionel Sambuc 
894f4a2713aSLionel Sambuc   // Read the syntactic expression.
895f4a2713aSLionel Sambuc   E->getSubExprsBuffer()[0] = Reader.ReadSubExpr();
896f4a2713aSLionel Sambuc 
897f4a2713aSLionel Sambuc   // Read all the semantic expressions.
898f4a2713aSLionel Sambuc   for (unsigned i = 0; i != numSemanticExprs; ++i) {
899f4a2713aSLionel Sambuc     Expr *subExpr = Reader.ReadSubExpr();
900f4a2713aSLionel Sambuc     E->getSubExprsBuffer()[i+1] = subExpr;
901f4a2713aSLionel Sambuc   }
902f4a2713aSLionel Sambuc }
903f4a2713aSLionel Sambuc 
VisitAtomicExpr(AtomicExpr * E)904f4a2713aSLionel Sambuc void ASTStmtReader::VisitAtomicExpr(AtomicExpr *E) {
905f4a2713aSLionel Sambuc   VisitExpr(E);
906f4a2713aSLionel Sambuc   E->Op = AtomicExpr::AtomicOp(Record[Idx++]);
907f4a2713aSLionel Sambuc   E->NumSubExprs = AtomicExpr::getNumSubExprs(E->Op);
908f4a2713aSLionel Sambuc   for (unsigned I = 0; I != E->NumSubExprs; ++I)
909f4a2713aSLionel Sambuc     E->SubExprs[I] = Reader.ReadSubExpr();
910f4a2713aSLionel Sambuc   E->BuiltinLoc = ReadSourceLocation(Record, Idx);
911f4a2713aSLionel Sambuc   E->RParenLoc = ReadSourceLocation(Record, Idx);
912f4a2713aSLionel Sambuc }
913f4a2713aSLionel Sambuc 
914f4a2713aSLionel Sambuc //===----------------------------------------------------------------------===//
915f4a2713aSLionel Sambuc // Objective-C Expressions and Statements
916f4a2713aSLionel Sambuc 
VisitObjCStringLiteral(ObjCStringLiteral * E)917f4a2713aSLionel Sambuc void ASTStmtReader::VisitObjCStringLiteral(ObjCStringLiteral *E) {
918f4a2713aSLionel Sambuc   VisitExpr(E);
919f4a2713aSLionel Sambuc   E->setString(cast<StringLiteral>(Reader.ReadSubStmt()));
920f4a2713aSLionel Sambuc   E->setAtLoc(ReadSourceLocation(Record, Idx));
921f4a2713aSLionel Sambuc }
922f4a2713aSLionel Sambuc 
VisitObjCBoxedExpr(ObjCBoxedExpr * E)923f4a2713aSLionel Sambuc void ASTStmtReader::VisitObjCBoxedExpr(ObjCBoxedExpr *E) {
924f4a2713aSLionel Sambuc   VisitExpr(E);
925f4a2713aSLionel Sambuc   // could be one of several IntegerLiteral, FloatLiteral, etc.
926f4a2713aSLionel Sambuc   E->SubExpr = Reader.ReadSubStmt();
927f4a2713aSLionel Sambuc   E->BoxingMethod = ReadDeclAs<ObjCMethodDecl>(Record, Idx);
928f4a2713aSLionel Sambuc   E->Range = ReadSourceRange(Record, Idx);
929f4a2713aSLionel Sambuc }
930f4a2713aSLionel Sambuc 
VisitObjCArrayLiteral(ObjCArrayLiteral * E)931f4a2713aSLionel Sambuc void ASTStmtReader::VisitObjCArrayLiteral(ObjCArrayLiteral *E) {
932f4a2713aSLionel Sambuc   VisitExpr(E);
933f4a2713aSLionel Sambuc   unsigned NumElements = Record[Idx++];
934f4a2713aSLionel Sambuc   assert(NumElements == E->getNumElements() && "Wrong number of elements");
935f4a2713aSLionel Sambuc   Expr **Elements = E->getElements();
936f4a2713aSLionel Sambuc   for (unsigned I = 0, N = NumElements; I != N; ++I)
937f4a2713aSLionel Sambuc     Elements[I] = Reader.ReadSubExpr();
938f4a2713aSLionel Sambuc   E->ArrayWithObjectsMethod = ReadDeclAs<ObjCMethodDecl>(Record, Idx);
939f4a2713aSLionel Sambuc   E->Range = ReadSourceRange(Record, Idx);
940f4a2713aSLionel Sambuc }
941f4a2713aSLionel Sambuc 
VisitObjCDictionaryLiteral(ObjCDictionaryLiteral * E)942f4a2713aSLionel Sambuc void ASTStmtReader::VisitObjCDictionaryLiteral(ObjCDictionaryLiteral *E) {
943f4a2713aSLionel Sambuc   VisitExpr(E);
944f4a2713aSLionel Sambuc   unsigned NumElements = Record[Idx++];
945f4a2713aSLionel Sambuc   assert(NumElements == E->getNumElements() && "Wrong number of elements");
946f4a2713aSLionel Sambuc   bool HasPackExpansions = Record[Idx++];
947f4a2713aSLionel Sambuc   assert(HasPackExpansions == E->HasPackExpansions &&"Pack expansion mismatch");
948f4a2713aSLionel Sambuc   ObjCDictionaryLiteral::KeyValuePair *KeyValues = E->getKeyValues();
949f4a2713aSLionel Sambuc   ObjCDictionaryLiteral::ExpansionData *Expansions = E->getExpansionData();
950f4a2713aSLionel Sambuc   for (unsigned I = 0; I != NumElements; ++I) {
951f4a2713aSLionel Sambuc     KeyValues[I].Key = Reader.ReadSubExpr();
952f4a2713aSLionel Sambuc     KeyValues[I].Value = Reader.ReadSubExpr();
953f4a2713aSLionel Sambuc     if (HasPackExpansions) {
954f4a2713aSLionel Sambuc       Expansions[I].EllipsisLoc = ReadSourceLocation(Record, Idx);
955f4a2713aSLionel Sambuc       Expansions[I].NumExpansionsPlusOne = Record[Idx++];
956f4a2713aSLionel Sambuc     }
957f4a2713aSLionel Sambuc   }
958f4a2713aSLionel Sambuc   E->DictWithObjectsMethod = ReadDeclAs<ObjCMethodDecl>(Record, Idx);
959f4a2713aSLionel Sambuc   E->Range = ReadSourceRange(Record, Idx);
960f4a2713aSLionel Sambuc }
961f4a2713aSLionel Sambuc 
VisitObjCEncodeExpr(ObjCEncodeExpr * E)962f4a2713aSLionel Sambuc void ASTStmtReader::VisitObjCEncodeExpr(ObjCEncodeExpr *E) {
963f4a2713aSLionel Sambuc   VisitExpr(E);
964f4a2713aSLionel Sambuc   E->setEncodedTypeSourceInfo(GetTypeSourceInfo(Record, Idx));
965f4a2713aSLionel Sambuc   E->setAtLoc(ReadSourceLocation(Record, Idx));
966f4a2713aSLionel Sambuc   E->setRParenLoc(ReadSourceLocation(Record, Idx));
967f4a2713aSLionel Sambuc }
968f4a2713aSLionel Sambuc 
VisitObjCSelectorExpr(ObjCSelectorExpr * E)969f4a2713aSLionel Sambuc void ASTStmtReader::VisitObjCSelectorExpr(ObjCSelectorExpr *E) {
970f4a2713aSLionel Sambuc   VisitExpr(E);
971f4a2713aSLionel Sambuc   E->setSelector(Reader.ReadSelector(F, Record, Idx));
972f4a2713aSLionel Sambuc   E->setAtLoc(ReadSourceLocation(Record, Idx));
973f4a2713aSLionel Sambuc   E->setRParenLoc(ReadSourceLocation(Record, Idx));
974f4a2713aSLionel Sambuc }
975f4a2713aSLionel Sambuc 
VisitObjCProtocolExpr(ObjCProtocolExpr * E)976f4a2713aSLionel Sambuc void ASTStmtReader::VisitObjCProtocolExpr(ObjCProtocolExpr *E) {
977f4a2713aSLionel Sambuc   VisitExpr(E);
978f4a2713aSLionel Sambuc   E->setProtocol(ReadDeclAs<ObjCProtocolDecl>(Record, Idx));
979f4a2713aSLionel Sambuc   E->setAtLoc(ReadSourceLocation(Record, Idx));
980f4a2713aSLionel Sambuc   E->ProtoLoc = ReadSourceLocation(Record, Idx);
981f4a2713aSLionel Sambuc   E->setRParenLoc(ReadSourceLocation(Record, Idx));
982f4a2713aSLionel Sambuc }
983f4a2713aSLionel Sambuc 
VisitObjCIvarRefExpr(ObjCIvarRefExpr * E)984f4a2713aSLionel Sambuc void ASTStmtReader::VisitObjCIvarRefExpr(ObjCIvarRefExpr *E) {
985f4a2713aSLionel Sambuc   VisitExpr(E);
986f4a2713aSLionel Sambuc   E->setDecl(ReadDeclAs<ObjCIvarDecl>(Record, Idx));
987f4a2713aSLionel Sambuc   E->setLocation(ReadSourceLocation(Record, Idx));
988f4a2713aSLionel Sambuc   E->setOpLoc(ReadSourceLocation(Record, Idx));
989f4a2713aSLionel Sambuc   E->setBase(Reader.ReadSubExpr());
990f4a2713aSLionel Sambuc   E->setIsArrow(Record[Idx++]);
991f4a2713aSLionel Sambuc   E->setIsFreeIvar(Record[Idx++]);
992f4a2713aSLionel Sambuc }
993f4a2713aSLionel Sambuc 
VisitObjCPropertyRefExpr(ObjCPropertyRefExpr * E)994f4a2713aSLionel Sambuc void ASTStmtReader::VisitObjCPropertyRefExpr(ObjCPropertyRefExpr *E) {
995f4a2713aSLionel Sambuc   VisitExpr(E);
996f4a2713aSLionel Sambuc   unsigned MethodRefFlags = Record[Idx++];
997f4a2713aSLionel Sambuc   bool Implicit = Record[Idx++] != 0;
998f4a2713aSLionel Sambuc   if (Implicit) {
999f4a2713aSLionel Sambuc     ObjCMethodDecl *Getter = ReadDeclAs<ObjCMethodDecl>(Record, Idx);
1000f4a2713aSLionel Sambuc     ObjCMethodDecl *Setter = ReadDeclAs<ObjCMethodDecl>(Record, Idx);
1001f4a2713aSLionel Sambuc     E->setImplicitProperty(Getter, Setter, MethodRefFlags);
1002f4a2713aSLionel Sambuc   } else {
1003f4a2713aSLionel Sambuc     E->setExplicitProperty(ReadDeclAs<ObjCPropertyDecl>(Record, Idx),
1004f4a2713aSLionel Sambuc                            MethodRefFlags);
1005f4a2713aSLionel Sambuc   }
1006f4a2713aSLionel Sambuc   E->setLocation(ReadSourceLocation(Record, Idx));
1007f4a2713aSLionel Sambuc   E->setReceiverLocation(ReadSourceLocation(Record, Idx));
1008f4a2713aSLionel Sambuc   switch (Record[Idx++]) {
1009f4a2713aSLionel Sambuc   case 0:
1010f4a2713aSLionel Sambuc     E->setBase(Reader.ReadSubExpr());
1011f4a2713aSLionel Sambuc     break;
1012f4a2713aSLionel Sambuc   case 1:
1013f4a2713aSLionel Sambuc     E->setSuperReceiver(Reader.readType(F, Record, Idx));
1014f4a2713aSLionel Sambuc     break;
1015f4a2713aSLionel Sambuc   case 2:
1016f4a2713aSLionel Sambuc     E->setClassReceiver(ReadDeclAs<ObjCInterfaceDecl>(Record, Idx));
1017f4a2713aSLionel Sambuc     break;
1018f4a2713aSLionel Sambuc   }
1019f4a2713aSLionel Sambuc }
1020f4a2713aSLionel Sambuc 
VisitObjCSubscriptRefExpr(ObjCSubscriptRefExpr * E)1021f4a2713aSLionel Sambuc void ASTStmtReader::VisitObjCSubscriptRefExpr(ObjCSubscriptRefExpr *E) {
1022f4a2713aSLionel Sambuc   VisitExpr(E);
1023f4a2713aSLionel Sambuc   E->setRBracket(ReadSourceLocation(Record, Idx));
1024f4a2713aSLionel Sambuc   E->setBaseExpr(Reader.ReadSubExpr());
1025f4a2713aSLionel Sambuc   E->setKeyExpr(Reader.ReadSubExpr());
1026f4a2713aSLionel Sambuc   E->GetAtIndexMethodDecl = ReadDeclAs<ObjCMethodDecl>(Record, Idx);
1027f4a2713aSLionel Sambuc   E->SetAtIndexMethodDecl = ReadDeclAs<ObjCMethodDecl>(Record, Idx);
1028f4a2713aSLionel Sambuc }
1029f4a2713aSLionel Sambuc 
VisitObjCMessageExpr(ObjCMessageExpr * E)1030f4a2713aSLionel Sambuc void ASTStmtReader::VisitObjCMessageExpr(ObjCMessageExpr *E) {
1031f4a2713aSLionel Sambuc   VisitExpr(E);
1032f4a2713aSLionel Sambuc   assert(Record[Idx] == E->getNumArgs());
1033f4a2713aSLionel Sambuc   ++Idx;
1034f4a2713aSLionel Sambuc   unsigned NumStoredSelLocs = Record[Idx++];
1035f4a2713aSLionel Sambuc   E->SelLocsKind = Record[Idx++];
1036f4a2713aSLionel Sambuc   E->setDelegateInitCall(Record[Idx++]);
1037f4a2713aSLionel Sambuc   E->IsImplicit = Record[Idx++];
1038f4a2713aSLionel Sambuc   ObjCMessageExpr::ReceiverKind Kind
1039f4a2713aSLionel Sambuc     = static_cast<ObjCMessageExpr::ReceiverKind>(Record[Idx++]);
1040f4a2713aSLionel Sambuc   switch (Kind) {
1041f4a2713aSLionel Sambuc   case ObjCMessageExpr::Instance:
1042f4a2713aSLionel Sambuc     E->setInstanceReceiver(Reader.ReadSubExpr());
1043f4a2713aSLionel Sambuc     break;
1044f4a2713aSLionel Sambuc 
1045f4a2713aSLionel Sambuc   case ObjCMessageExpr::Class:
1046f4a2713aSLionel Sambuc     E->setClassReceiver(GetTypeSourceInfo(Record, Idx));
1047f4a2713aSLionel Sambuc     break;
1048f4a2713aSLionel Sambuc 
1049f4a2713aSLionel Sambuc   case ObjCMessageExpr::SuperClass:
1050f4a2713aSLionel Sambuc   case ObjCMessageExpr::SuperInstance: {
1051f4a2713aSLionel Sambuc     QualType T = Reader.readType(F, Record, Idx);
1052f4a2713aSLionel Sambuc     SourceLocation SuperLoc = ReadSourceLocation(Record, Idx);
1053f4a2713aSLionel Sambuc     E->setSuper(SuperLoc, T, Kind == ObjCMessageExpr::SuperInstance);
1054f4a2713aSLionel Sambuc     break;
1055f4a2713aSLionel Sambuc   }
1056f4a2713aSLionel Sambuc   }
1057f4a2713aSLionel Sambuc 
1058f4a2713aSLionel Sambuc   assert(Kind == E->getReceiverKind());
1059f4a2713aSLionel Sambuc 
1060f4a2713aSLionel Sambuc   if (Record[Idx++])
1061f4a2713aSLionel Sambuc     E->setMethodDecl(ReadDeclAs<ObjCMethodDecl>(Record, Idx));
1062f4a2713aSLionel Sambuc   else
1063f4a2713aSLionel Sambuc     E->setSelector(Reader.ReadSelector(F, Record, Idx));
1064f4a2713aSLionel Sambuc 
1065f4a2713aSLionel Sambuc   E->LBracLoc = ReadSourceLocation(Record, Idx);
1066f4a2713aSLionel Sambuc   E->RBracLoc = ReadSourceLocation(Record, Idx);
1067f4a2713aSLionel Sambuc 
1068f4a2713aSLionel Sambuc   for (unsigned I = 0, N = E->getNumArgs(); I != N; ++I)
1069f4a2713aSLionel Sambuc     E->setArg(I, Reader.ReadSubExpr());
1070f4a2713aSLionel Sambuc 
1071f4a2713aSLionel Sambuc   SourceLocation *Locs = E->getStoredSelLocs();
1072f4a2713aSLionel Sambuc   for (unsigned I = 0; I != NumStoredSelLocs; ++I)
1073f4a2713aSLionel Sambuc     Locs[I] = ReadSourceLocation(Record, Idx);
1074f4a2713aSLionel Sambuc }
1075f4a2713aSLionel Sambuc 
VisitObjCForCollectionStmt(ObjCForCollectionStmt * S)1076f4a2713aSLionel Sambuc void ASTStmtReader::VisitObjCForCollectionStmt(ObjCForCollectionStmt *S) {
1077f4a2713aSLionel Sambuc   VisitStmt(S);
1078f4a2713aSLionel Sambuc   S->setElement(Reader.ReadSubStmt());
1079f4a2713aSLionel Sambuc   S->setCollection(Reader.ReadSubExpr());
1080f4a2713aSLionel Sambuc   S->setBody(Reader.ReadSubStmt());
1081f4a2713aSLionel Sambuc   S->setForLoc(ReadSourceLocation(Record, Idx));
1082f4a2713aSLionel Sambuc   S->setRParenLoc(ReadSourceLocation(Record, Idx));
1083f4a2713aSLionel Sambuc }
1084f4a2713aSLionel Sambuc 
VisitObjCAtCatchStmt(ObjCAtCatchStmt * S)1085f4a2713aSLionel Sambuc void ASTStmtReader::VisitObjCAtCatchStmt(ObjCAtCatchStmt *S) {
1086f4a2713aSLionel Sambuc   VisitStmt(S);
1087f4a2713aSLionel Sambuc   S->setCatchBody(Reader.ReadSubStmt());
1088f4a2713aSLionel Sambuc   S->setCatchParamDecl(ReadDeclAs<VarDecl>(Record, Idx));
1089f4a2713aSLionel Sambuc   S->setAtCatchLoc(ReadSourceLocation(Record, Idx));
1090f4a2713aSLionel Sambuc   S->setRParenLoc(ReadSourceLocation(Record, Idx));
1091f4a2713aSLionel Sambuc }
1092f4a2713aSLionel Sambuc 
VisitObjCAtFinallyStmt(ObjCAtFinallyStmt * S)1093f4a2713aSLionel Sambuc void ASTStmtReader::VisitObjCAtFinallyStmt(ObjCAtFinallyStmt *S) {
1094f4a2713aSLionel Sambuc   VisitStmt(S);
1095f4a2713aSLionel Sambuc   S->setFinallyBody(Reader.ReadSubStmt());
1096f4a2713aSLionel Sambuc   S->setAtFinallyLoc(ReadSourceLocation(Record, Idx));
1097f4a2713aSLionel Sambuc }
1098f4a2713aSLionel Sambuc 
VisitObjCAutoreleasePoolStmt(ObjCAutoreleasePoolStmt * S)1099f4a2713aSLionel Sambuc void ASTStmtReader::VisitObjCAutoreleasePoolStmt(ObjCAutoreleasePoolStmt *S) {
1100f4a2713aSLionel Sambuc   VisitStmt(S);
1101f4a2713aSLionel Sambuc   S->setSubStmt(Reader.ReadSubStmt());
1102f4a2713aSLionel Sambuc   S->setAtLoc(ReadSourceLocation(Record, Idx));
1103f4a2713aSLionel Sambuc }
1104f4a2713aSLionel Sambuc 
VisitObjCAtTryStmt(ObjCAtTryStmt * S)1105f4a2713aSLionel Sambuc void ASTStmtReader::VisitObjCAtTryStmt(ObjCAtTryStmt *S) {
1106f4a2713aSLionel Sambuc   VisitStmt(S);
1107f4a2713aSLionel Sambuc   assert(Record[Idx] == S->getNumCatchStmts());
1108f4a2713aSLionel Sambuc   ++Idx;
1109f4a2713aSLionel Sambuc   bool HasFinally = Record[Idx++];
1110f4a2713aSLionel Sambuc   S->setTryBody(Reader.ReadSubStmt());
1111f4a2713aSLionel Sambuc   for (unsigned I = 0, N = S->getNumCatchStmts(); I != N; ++I)
1112f4a2713aSLionel Sambuc     S->setCatchStmt(I, cast_or_null<ObjCAtCatchStmt>(Reader.ReadSubStmt()));
1113f4a2713aSLionel Sambuc 
1114f4a2713aSLionel Sambuc   if (HasFinally)
1115f4a2713aSLionel Sambuc     S->setFinallyStmt(Reader.ReadSubStmt());
1116f4a2713aSLionel Sambuc   S->setAtTryLoc(ReadSourceLocation(Record, Idx));
1117f4a2713aSLionel Sambuc }
1118f4a2713aSLionel Sambuc 
VisitObjCAtSynchronizedStmt(ObjCAtSynchronizedStmt * S)1119f4a2713aSLionel Sambuc void ASTStmtReader::VisitObjCAtSynchronizedStmt(ObjCAtSynchronizedStmt *S) {
1120f4a2713aSLionel Sambuc   VisitStmt(S);
1121f4a2713aSLionel Sambuc   S->setSynchExpr(Reader.ReadSubStmt());
1122f4a2713aSLionel Sambuc   S->setSynchBody(Reader.ReadSubStmt());
1123f4a2713aSLionel Sambuc   S->setAtSynchronizedLoc(ReadSourceLocation(Record, Idx));
1124f4a2713aSLionel Sambuc }
1125f4a2713aSLionel Sambuc 
VisitObjCAtThrowStmt(ObjCAtThrowStmt * S)1126f4a2713aSLionel Sambuc void ASTStmtReader::VisitObjCAtThrowStmt(ObjCAtThrowStmt *S) {
1127f4a2713aSLionel Sambuc   VisitStmt(S);
1128f4a2713aSLionel Sambuc   S->setThrowExpr(Reader.ReadSubStmt());
1129f4a2713aSLionel Sambuc   S->setThrowLoc(ReadSourceLocation(Record, Idx));
1130f4a2713aSLionel Sambuc }
1131f4a2713aSLionel Sambuc 
VisitObjCBoolLiteralExpr(ObjCBoolLiteralExpr * E)1132f4a2713aSLionel Sambuc void ASTStmtReader::VisitObjCBoolLiteralExpr(ObjCBoolLiteralExpr *E) {
1133f4a2713aSLionel Sambuc   VisitExpr(E);
1134f4a2713aSLionel Sambuc   E->setValue(Record[Idx++]);
1135f4a2713aSLionel Sambuc   E->setLocation(ReadSourceLocation(Record, Idx));
1136f4a2713aSLionel Sambuc }
1137f4a2713aSLionel Sambuc 
1138f4a2713aSLionel Sambuc //===----------------------------------------------------------------------===//
1139f4a2713aSLionel Sambuc // C++ Expressions and Statements
1140f4a2713aSLionel Sambuc //===----------------------------------------------------------------------===//
1141f4a2713aSLionel Sambuc 
VisitCXXCatchStmt(CXXCatchStmt * S)1142f4a2713aSLionel Sambuc void ASTStmtReader::VisitCXXCatchStmt(CXXCatchStmt *S) {
1143f4a2713aSLionel Sambuc   VisitStmt(S);
1144f4a2713aSLionel Sambuc   S->CatchLoc = ReadSourceLocation(Record, Idx);
1145f4a2713aSLionel Sambuc   S->ExceptionDecl = ReadDeclAs<VarDecl>(Record, Idx);
1146f4a2713aSLionel Sambuc   S->HandlerBlock = Reader.ReadSubStmt();
1147f4a2713aSLionel Sambuc }
1148f4a2713aSLionel Sambuc 
VisitCXXTryStmt(CXXTryStmt * S)1149f4a2713aSLionel Sambuc void ASTStmtReader::VisitCXXTryStmt(CXXTryStmt *S) {
1150f4a2713aSLionel Sambuc   VisitStmt(S);
1151f4a2713aSLionel Sambuc   assert(Record[Idx] == S->getNumHandlers() && "NumStmtFields is wrong ?");
1152f4a2713aSLionel Sambuc   ++Idx;
1153f4a2713aSLionel Sambuc   S->TryLoc = ReadSourceLocation(Record, Idx);
1154f4a2713aSLionel Sambuc   S->getStmts()[0] = Reader.ReadSubStmt();
1155f4a2713aSLionel Sambuc   for (unsigned i = 0, e = S->getNumHandlers(); i != e; ++i)
1156f4a2713aSLionel Sambuc     S->getStmts()[i + 1] = Reader.ReadSubStmt();
1157f4a2713aSLionel Sambuc }
1158f4a2713aSLionel Sambuc 
VisitCXXForRangeStmt(CXXForRangeStmt * S)1159f4a2713aSLionel Sambuc void ASTStmtReader::VisitCXXForRangeStmt(CXXForRangeStmt *S) {
1160f4a2713aSLionel Sambuc   VisitStmt(S);
1161f4a2713aSLionel Sambuc   S->setForLoc(ReadSourceLocation(Record, Idx));
1162f4a2713aSLionel Sambuc   S->setColonLoc(ReadSourceLocation(Record, Idx));
1163f4a2713aSLionel Sambuc   S->setRParenLoc(ReadSourceLocation(Record, Idx));
1164f4a2713aSLionel Sambuc   S->setRangeStmt(Reader.ReadSubStmt());
1165f4a2713aSLionel Sambuc   S->setBeginEndStmt(Reader.ReadSubStmt());
1166f4a2713aSLionel Sambuc   S->setCond(Reader.ReadSubExpr());
1167f4a2713aSLionel Sambuc   S->setInc(Reader.ReadSubExpr());
1168f4a2713aSLionel Sambuc   S->setLoopVarStmt(Reader.ReadSubStmt());
1169f4a2713aSLionel Sambuc   S->setBody(Reader.ReadSubStmt());
1170f4a2713aSLionel Sambuc }
1171f4a2713aSLionel Sambuc 
VisitMSDependentExistsStmt(MSDependentExistsStmt * S)1172f4a2713aSLionel Sambuc void ASTStmtReader::VisitMSDependentExistsStmt(MSDependentExistsStmt *S) {
1173f4a2713aSLionel Sambuc   VisitStmt(S);
1174f4a2713aSLionel Sambuc   S->KeywordLoc = ReadSourceLocation(Record, Idx);
1175f4a2713aSLionel Sambuc   S->IsIfExists = Record[Idx++];
1176f4a2713aSLionel Sambuc   S->QualifierLoc = Reader.ReadNestedNameSpecifierLoc(F, Record, Idx);
1177f4a2713aSLionel Sambuc   ReadDeclarationNameInfo(S->NameInfo, Record, Idx);
1178f4a2713aSLionel Sambuc   S->SubStmt = Reader.ReadSubStmt();
1179f4a2713aSLionel Sambuc }
1180f4a2713aSLionel Sambuc 
VisitCXXOperatorCallExpr(CXXOperatorCallExpr * E)1181f4a2713aSLionel Sambuc void ASTStmtReader::VisitCXXOperatorCallExpr(CXXOperatorCallExpr *E) {
1182f4a2713aSLionel Sambuc   VisitCallExpr(E);
1183f4a2713aSLionel Sambuc   E->Operator = (OverloadedOperatorKind)Record[Idx++];
1184f4a2713aSLionel Sambuc   E->Range = Reader.ReadSourceRange(F, Record, Idx);
1185f4a2713aSLionel Sambuc   E->setFPContractable((bool)Record[Idx++]);
1186f4a2713aSLionel Sambuc }
1187f4a2713aSLionel Sambuc 
VisitCXXConstructExpr(CXXConstructExpr * E)1188f4a2713aSLionel Sambuc void ASTStmtReader::VisitCXXConstructExpr(CXXConstructExpr *E) {
1189f4a2713aSLionel Sambuc   VisitExpr(E);
1190f4a2713aSLionel Sambuc   E->NumArgs = Record[Idx++];
1191f4a2713aSLionel Sambuc   if (E->NumArgs)
1192f4a2713aSLionel Sambuc     E->Args = new (Reader.getContext()) Stmt*[E->NumArgs];
1193f4a2713aSLionel Sambuc   for (unsigned I = 0, N = E->getNumArgs(); I != N; ++I)
1194f4a2713aSLionel Sambuc     E->setArg(I, Reader.ReadSubExpr());
1195f4a2713aSLionel Sambuc   E->setConstructor(ReadDeclAs<CXXConstructorDecl>(Record, Idx));
1196f4a2713aSLionel Sambuc   E->setLocation(ReadSourceLocation(Record, Idx));
1197f4a2713aSLionel Sambuc   E->setElidable(Record[Idx++]);
1198f4a2713aSLionel Sambuc   E->setHadMultipleCandidates(Record[Idx++]);
1199f4a2713aSLionel Sambuc   E->setListInitialization(Record[Idx++]);
1200*0a6a1f1dSLionel Sambuc   E->setStdInitListInitialization(Record[Idx++]);
1201f4a2713aSLionel Sambuc   E->setRequiresZeroInitialization(Record[Idx++]);
1202f4a2713aSLionel Sambuc   E->setConstructionKind((CXXConstructExpr::ConstructionKind)Record[Idx++]);
1203f4a2713aSLionel Sambuc   E->ParenOrBraceRange = ReadSourceRange(Record, Idx);
1204f4a2713aSLionel Sambuc }
1205f4a2713aSLionel Sambuc 
VisitCXXTemporaryObjectExpr(CXXTemporaryObjectExpr * E)1206f4a2713aSLionel Sambuc void ASTStmtReader::VisitCXXTemporaryObjectExpr(CXXTemporaryObjectExpr *E) {
1207f4a2713aSLionel Sambuc   VisitCXXConstructExpr(E);
1208f4a2713aSLionel Sambuc   E->Type = GetTypeSourceInfo(Record, Idx);
1209f4a2713aSLionel Sambuc }
1210f4a2713aSLionel Sambuc 
VisitLambdaExpr(LambdaExpr * E)1211f4a2713aSLionel Sambuc void ASTStmtReader::VisitLambdaExpr(LambdaExpr *E) {
1212f4a2713aSLionel Sambuc   VisitExpr(E);
1213f4a2713aSLionel Sambuc   unsigned NumCaptures = Record[Idx++];
1214f4a2713aSLionel Sambuc   assert(NumCaptures == E->NumCaptures);(void)NumCaptures;
1215f4a2713aSLionel Sambuc   unsigned NumArrayIndexVars = Record[Idx++];
1216f4a2713aSLionel Sambuc   E->IntroducerRange = ReadSourceRange(Record, Idx);
1217f4a2713aSLionel Sambuc   E->CaptureDefault = static_cast<LambdaCaptureDefault>(Record[Idx++]);
1218f4a2713aSLionel Sambuc   E->CaptureDefaultLoc = ReadSourceLocation(Record, Idx);
1219f4a2713aSLionel Sambuc   E->ExplicitParams = Record[Idx++];
1220f4a2713aSLionel Sambuc   E->ExplicitResultType = Record[Idx++];
1221f4a2713aSLionel Sambuc   E->ClosingBrace = ReadSourceLocation(Record, Idx);
1222f4a2713aSLionel Sambuc 
1223f4a2713aSLionel Sambuc   // Read capture initializers.
1224f4a2713aSLionel Sambuc   for (LambdaExpr::capture_init_iterator C = E->capture_init_begin(),
1225f4a2713aSLionel Sambuc                                       CEnd = E->capture_init_end();
1226f4a2713aSLionel Sambuc        C != CEnd; ++C)
1227f4a2713aSLionel Sambuc     *C = Reader.ReadSubExpr();
1228f4a2713aSLionel Sambuc 
1229f4a2713aSLionel Sambuc   // Read array capture index variables.
1230f4a2713aSLionel Sambuc   if (NumArrayIndexVars > 0) {
1231f4a2713aSLionel Sambuc     unsigned *ArrayIndexStarts = E->getArrayIndexStarts();
1232f4a2713aSLionel Sambuc     for (unsigned I = 0; I != NumCaptures + 1; ++I)
1233f4a2713aSLionel Sambuc       ArrayIndexStarts[I] = Record[Idx++];
1234f4a2713aSLionel Sambuc 
1235f4a2713aSLionel Sambuc     VarDecl **ArrayIndexVars = E->getArrayIndexVars();
1236f4a2713aSLionel Sambuc     for (unsigned I = 0; I != NumArrayIndexVars; ++I)
1237f4a2713aSLionel Sambuc       ArrayIndexVars[I] = ReadDeclAs<VarDecl>(Record, Idx);
1238f4a2713aSLionel Sambuc   }
1239f4a2713aSLionel Sambuc }
1240f4a2713aSLionel Sambuc 
1241f4a2713aSLionel Sambuc void
VisitCXXStdInitializerListExpr(CXXStdInitializerListExpr * E)1242f4a2713aSLionel Sambuc ASTStmtReader::VisitCXXStdInitializerListExpr(CXXStdInitializerListExpr *E) {
1243f4a2713aSLionel Sambuc   VisitExpr(E);
1244f4a2713aSLionel Sambuc   E->SubExpr = Reader.ReadSubExpr();
1245f4a2713aSLionel Sambuc }
1246f4a2713aSLionel Sambuc 
VisitCXXNamedCastExpr(CXXNamedCastExpr * E)1247f4a2713aSLionel Sambuc void ASTStmtReader::VisitCXXNamedCastExpr(CXXNamedCastExpr *E) {
1248f4a2713aSLionel Sambuc   VisitExplicitCastExpr(E);
1249f4a2713aSLionel Sambuc   SourceRange R = ReadSourceRange(Record, Idx);
1250f4a2713aSLionel Sambuc   E->Loc = R.getBegin();
1251f4a2713aSLionel Sambuc   E->RParenLoc = R.getEnd();
1252f4a2713aSLionel Sambuc   R = ReadSourceRange(Record, Idx);
1253f4a2713aSLionel Sambuc   E->AngleBrackets = R;
1254f4a2713aSLionel Sambuc }
1255f4a2713aSLionel Sambuc 
VisitCXXStaticCastExpr(CXXStaticCastExpr * E)1256f4a2713aSLionel Sambuc void ASTStmtReader::VisitCXXStaticCastExpr(CXXStaticCastExpr *E) {
1257f4a2713aSLionel Sambuc   return VisitCXXNamedCastExpr(E);
1258f4a2713aSLionel Sambuc }
1259f4a2713aSLionel Sambuc 
VisitCXXDynamicCastExpr(CXXDynamicCastExpr * E)1260f4a2713aSLionel Sambuc void ASTStmtReader::VisitCXXDynamicCastExpr(CXXDynamicCastExpr *E) {
1261f4a2713aSLionel Sambuc   return VisitCXXNamedCastExpr(E);
1262f4a2713aSLionel Sambuc }
1263f4a2713aSLionel Sambuc 
VisitCXXReinterpretCastExpr(CXXReinterpretCastExpr * E)1264f4a2713aSLionel Sambuc void ASTStmtReader::VisitCXXReinterpretCastExpr(CXXReinterpretCastExpr *E) {
1265f4a2713aSLionel Sambuc   return VisitCXXNamedCastExpr(E);
1266f4a2713aSLionel Sambuc }
1267f4a2713aSLionel Sambuc 
VisitCXXConstCastExpr(CXXConstCastExpr * E)1268f4a2713aSLionel Sambuc void ASTStmtReader::VisitCXXConstCastExpr(CXXConstCastExpr *E) {
1269f4a2713aSLionel Sambuc   return VisitCXXNamedCastExpr(E);
1270f4a2713aSLionel Sambuc }
1271f4a2713aSLionel Sambuc 
VisitCXXFunctionalCastExpr(CXXFunctionalCastExpr * E)1272f4a2713aSLionel Sambuc void ASTStmtReader::VisitCXXFunctionalCastExpr(CXXFunctionalCastExpr *E) {
1273f4a2713aSLionel Sambuc   VisitExplicitCastExpr(E);
1274f4a2713aSLionel Sambuc   E->setLParenLoc(ReadSourceLocation(Record, Idx));
1275f4a2713aSLionel Sambuc   E->setRParenLoc(ReadSourceLocation(Record, Idx));
1276f4a2713aSLionel Sambuc }
1277f4a2713aSLionel Sambuc 
VisitUserDefinedLiteral(UserDefinedLiteral * E)1278f4a2713aSLionel Sambuc void ASTStmtReader::VisitUserDefinedLiteral(UserDefinedLiteral *E) {
1279f4a2713aSLionel Sambuc   VisitCallExpr(E);
1280f4a2713aSLionel Sambuc   E->UDSuffixLoc = ReadSourceLocation(Record, Idx);
1281f4a2713aSLionel Sambuc }
1282f4a2713aSLionel Sambuc 
VisitCXXBoolLiteralExpr(CXXBoolLiteralExpr * E)1283f4a2713aSLionel Sambuc void ASTStmtReader::VisitCXXBoolLiteralExpr(CXXBoolLiteralExpr *E) {
1284f4a2713aSLionel Sambuc   VisitExpr(E);
1285f4a2713aSLionel Sambuc   E->setValue(Record[Idx++]);
1286f4a2713aSLionel Sambuc   E->setLocation(ReadSourceLocation(Record, Idx));
1287f4a2713aSLionel Sambuc }
1288f4a2713aSLionel Sambuc 
VisitCXXNullPtrLiteralExpr(CXXNullPtrLiteralExpr * E)1289f4a2713aSLionel Sambuc void ASTStmtReader::VisitCXXNullPtrLiteralExpr(CXXNullPtrLiteralExpr *E) {
1290f4a2713aSLionel Sambuc   VisitExpr(E);
1291f4a2713aSLionel Sambuc   E->setLocation(ReadSourceLocation(Record, Idx));
1292f4a2713aSLionel Sambuc }
1293f4a2713aSLionel Sambuc 
VisitCXXTypeidExpr(CXXTypeidExpr * E)1294f4a2713aSLionel Sambuc void ASTStmtReader::VisitCXXTypeidExpr(CXXTypeidExpr *E) {
1295f4a2713aSLionel Sambuc   VisitExpr(E);
1296f4a2713aSLionel Sambuc   E->setSourceRange(ReadSourceRange(Record, Idx));
1297f4a2713aSLionel Sambuc   if (E->isTypeOperand()) { // typeid(int)
1298f4a2713aSLionel Sambuc     E->setTypeOperandSourceInfo(
1299f4a2713aSLionel Sambuc         GetTypeSourceInfo(Record, Idx));
1300f4a2713aSLionel Sambuc     return;
1301f4a2713aSLionel Sambuc   }
1302f4a2713aSLionel Sambuc 
1303f4a2713aSLionel Sambuc   // typeid(42+2)
1304f4a2713aSLionel Sambuc   E->setExprOperand(Reader.ReadSubExpr());
1305f4a2713aSLionel Sambuc }
1306f4a2713aSLionel Sambuc 
VisitCXXThisExpr(CXXThisExpr * E)1307f4a2713aSLionel Sambuc void ASTStmtReader::VisitCXXThisExpr(CXXThisExpr *E) {
1308f4a2713aSLionel Sambuc   VisitExpr(E);
1309f4a2713aSLionel Sambuc   E->setLocation(ReadSourceLocation(Record, Idx));
1310f4a2713aSLionel Sambuc   E->setImplicit(Record[Idx++]);
1311f4a2713aSLionel Sambuc }
1312f4a2713aSLionel Sambuc 
VisitCXXThrowExpr(CXXThrowExpr * E)1313f4a2713aSLionel Sambuc void ASTStmtReader::VisitCXXThrowExpr(CXXThrowExpr *E) {
1314f4a2713aSLionel Sambuc   VisitExpr(E);
1315f4a2713aSLionel Sambuc   E->ThrowLoc = ReadSourceLocation(Record, Idx);
1316f4a2713aSLionel Sambuc   E->Op = Reader.ReadSubExpr();
1317f4a2713aSLionel Sambuc   E->IsThrownVariableInScope = Record[Idx++];
1318f4a2713aSLionel Sambuc }
1319f4a2713aSLionel Sambuc 
VisitCXXDefaultArgExpr(CXXDefaultArgExpr * E)1320f4a2713aSLionel Sambuc void ASTStmtReader::VisitCXXDefaultArgExpr(CXXDefaultArgExpr *E) {
1321f4a2713aSLionel Sambuc   VisitExpr(E);
1322f4a2713aSLionel Sambuc 
1323f4a2713aSLionel Sambuc   assert((bool)Record[Idx] == E->Param.getInt() && "We messed up at creation ?");
1324f4a2713aSLionel Sambuc   ++Idx; // HasOtherExprStored and SubExpr was handled during creation.
1325f4a2713aSLionel Sambuc   E->Param.setPointer(ReadDeclAs<ParmVarDecl>(Record, Idx));
1326f4a2713aSLionel Sambuc   E->Loc = ReadSourceLocation(Record, Idx);
1327f4a2713aSLionel Sambuc }
1328f4a2713aSLionel Sambuc 
VisitCXXDefaultInitExpr(CXXDefaultInitExpr * E)1329f4a2713aSLionel Sambuc void ASTStmtReader::VisitCXXDefaultInitExpr(CXXDefaultInitExpr *E) {
1330f4a2713aSLionel Sambuc   VisitExpr(E);
1331f4a2713aSLionel Sambuc   E->Field = ReadDeclAs<FieldDecl>(Record, Idx);
1332f4a2713aSLionel Sambuc   E->Loc = ReadSourceLocation(Record, Idx);
1333f4a2713aSLionel Sambuc }
1334f4a2713aSLionel Sambuc 
VisitCXXBindTemporaryExpr(CXXBindTemporaryExpr * E)1335f4a2713aSLionel Sambuc void ASTStmtReader::VisitCXXBindTemporaryExpr(CXXBindTemporaryExpr *E) {
1336f4a2713aSLionel Sambuc   VisitExpr(E);
1337f4a2713aSLionel Sambuc   E->setTemporary(Reader.ReadCXXTemporary(F, Record, Idx));
1338f4a2713aSLionel Sambuc   E->setSubExpr(Reader.ReadSubExpr());
1339f4a2713aSLionel Sambuc }
1340f4a2713aSLionel Sambuc 
VisitCXXScalarValueInitExpr(CXXScalarValueInitExpr * E)1341f4a2713aSLionel Sambuc void ASTStmtReader::VisitCXXScalarValueInitExpr(CXXScalarValueInitExpr *E) {
1342f4a2713aSLionel Sambuc   VisitExpr(E);
1343f4a2713aSLionel Sambuc   E->TypeInfo = GetTypeSourceInfo(Record, Idx);
1344f4a2713aSLionel Sambuc   E->RParenLoc = ReadSourceLocation(Record, Idx);
1345f4a2713aSLionel Sambuc }
1346f4a2713aSLionel Sambuc 
VisitCXXNewExpr(CXXNewExpr * E)1347f4a2713aSLionel Sambuc void ASTStmtReader::VisitCXXNewExpr(CXXNewExpr *E) {
1348f4a2713aSLionel Sambuc   VisitExpr(E);
1349f4a2713aSLionel Sambuc   E->GlobalNew = Record[Idx++];
1350f4a2713aSLionel Sambuc   bool isArray = Record[Idx++];
1351f4a2713aSLionel Sambuc   E->UsualArrayDeleteWantsSize = Record[Idx++];
1352f4a2713aSLionel Sambuc   unsigned NumPlacementArgs = Record[Idx++];
1353f4a2713aSLionel Sambuc   E->StoredInitializationStyle = Record[Idx++];
1354f4a2713aSLionel Sambuc   E->setOperatorNew(ReadDeclAs<FunctionDecl>(Record, Idx));
1355f4a2713aSLionel Sambuc   E->setOperatorDelete(ReadDeclAs<FunctionDecl>(Record, Idx));
1356f4a2713aSLionel Sambuc   E->AllocatedTypeInfo = GetTypeSourceInfo(Record, Idx);
1357f4a2713aSLionel Sambuc   E->TypeIdParens = ReadSourceRange(Record, Idx);
1358f4a2713aSLionel Sambuc   E->Range = ReadSourceRange(Record, Idx);
1359f4a2713aSLionel Sambuc   E->DirectInitRange = ReadSourceRange(Record, Idx);
1360f4a2713aSLionel Sambuc 
1361f4a2713aSLionel Sambuc   E->AllocateArgsArray(Reader.getContext(), isArray, NumPlacementArgs,
1362f4a2713aSLionel Sambuc                        E->StoredInitializationStyle != 0);
1363f4a2713aSLionel Sambuc 
1364f4a2713aSLionel Sambuc   // Install all the subexpressions.
1365f4a2713aSLionel Sambuc   for (CXXNewExpr::raw_arg_iterator I = E->raw_arg_begin(),e = E->raw_arg_end();
1366f4a2713aSLionel Sambuc        I != e; ++I)
1367f4a2713aSLionel Sambuc     *I = Reader.ReadSubStmt();
1368f4a2713aSLionel Sambuc }
1369f4a2713aSLionel Sambuc 
VisitCXXDeleteExpr(CXXDeleteExpr * E)1370f4a2713aSLionel Sambuc void ASTStmtReader::VisitCXXDeleteExpr(CXXDeleteExpr *E) {
1371f4a2713aSLionel Sambuc   VisitExpr(E);
1372f4a2713aSLionel Sambuc   E->GlobalDelete = Record[Idx++];
1373f4a2713aSLionel Sambuc   E->ArrayForm = Record[Idx++];
1374f4a2713aSLionel Sambuc   E->ArrayFormAsWritten = Record[Idx++];
1375f4a2713aSLionel Sambuc   E->UsualArrayDeleteWantsSize = Record[Idx++];
1376f4a2713aSLionel Sambuc   E->OperatorDelete = ReadDeclAs<FunctionDecl>(Record, Idx);
1377f4a2713aSLionel Sambuc   E->Argument = Reader.ReadSubExpr();
1378f4a2713aSLionel Sambuc   E->Loc = ReadSourceLocation(Record, Idx);
1379f4a2713aSLionel Sambuc }
1380f4a2713aSLionel Sambuc 
VisitCXXPseudoDestructorExpr(CXXPseudoDestructorExpr * E)1381f4a2713aSLionel Sambuc void ASTStmtReader::VisitCXXPseudoDestructorExpr(CXXPseudoDestructorExpr *E) {
1382f4a2713aSLionel Sambuc   VisitExpr(E);
1383f4a2713aSLionel Sambuc 
1384f4a2713aSLionel Sambuc   E->Base = Reader.ReadSubExpr();
1385f4a2713aSLionel Sambuc   E->IsArrow = Record[Idx++];
1386f4a2713aSLionel Sambuc   E->OperatorLoc = ReadSourceLocation(Record, Idx);
1387f4a2713aSLionel Sambuc   E->QualifierLoc = Reader.ReadNestedNameSpecifierLoc(F, Record, Idx);
1388f4a2713aSLionel Sambuc   E->ScopeType = GetTypeSourceInfo(Record, Idx);
1389f4a2713aSLionel Sambuc   E->ColonColonLoc = ReadSourceLocation(Record, Idx);
1390f4a2713aSLionel Sambuc   E->TildeLoc = ReadSourceLocation(Record, Idx);
1391f4a2713aSLionel Sambuc 
1392f4a2713aSLionel Sambuc   IdentifierInfo *II = Reader.GetIdentifierInfo(F, Record, Idx);
1393f4a2713aSLionel Sambuc   if (II)
1394f4a2713aSLionel Sambuc     E->setDestroyedType(II, ReadSourceLocation(Record, Idx));
1395f4a2713aSLionel Sambuc   else
1396f4a2713aSLionel Sambuc     E->setDestroyedType(GetTypeSourceInfo(Record, Idx));
1397f4a2713aSLionel Sambuc }
1398f4a2713aSLionel Sambuc 
VisitExprWithCleanups(ExprWithCleanups * E)1399f4a2713aSLionel Sambuc void ASTStmtReader::VisitExprWithCleanups(ExprWithCleanups *E) {
1400f4a2713aSLionel Sambuc   VisitExpr(E);
1401f4a2713aSLionel Sambuc 
1402f4a2713aSLionel Sambuc   unsigned NumObjects = Record[Idx++];
1403f4a2713aSLionel Sambuc   assert(NumObjects == E->getNumObjects());
1404f4a2713aSLionel Sambuc   for (unsigned i = 0; i != NumObjects; ++i)
1405f4a2713aSLionel Sambuc     E->getObjectsBuffer()[i] = ReadDeclAs<BlockDecl>(Record, Idx);
1406f4a2713aSLionel Sambuc 
1407f4a2713aSLionel Sambuc   E->SubExpr = Reader.ReadSubExpr();
1408f4a2713aSLionel Sambuc }
1409f4a2713aSLionel Sambuc 
1410f4a2713aSLionel Sambuc void
VisitCXXDependentScopeMemberExpr(CXXDependentScopeMemberExpr * E)1411f4a2713aSLionel Sambuc ASTStmtReader::VisitCXXDependentScopeMemberExpr(CXXDependentScopeMemberExpr *E){
1412f4a2713aSLionel Sambuc   VisitExpr(E);
1413f4a2713aSLionel Sambuc 
1414f4a2713aSLionel Sambuc   if (Record[Idx++]) // HasTemplateKWAndArgsInfo
1415f4a2713aSLionel Sambuc     ReadTemplateKWAndArgsInfo(*E->getTemplateKWAndArgsInfo(),
1416f4a2713aSLionel Sambuc                               /*NumTemplateArgs=*/Record[Idx++]);
1417f4a2713aSLionel Sambuc 
1418f4a2713aSLionel Sambuc   E->Base = Reader.ReadSubExpr();
1419f4a2713aSLionel Sambuc   E->BaseType = Reader.readType(F, Record, Idx);
1420f4a2713aSLionel Sambuc   E->IsArrow = Record[Idx++];
1421f4a2713aSLionel Sambuc   E->OperatorLoc = ReadSourceLocation(Record, Idx);
1422f4a2713aSLionel Sambuc   E->QualifierLoc = Reader.ReadNestedNameSpecifierLoc(F, Record, Idx);
1423f4a2713aSLionel Sambuc   E->FirstQualifierFoundInScope = ReadDeclAs<NamedDecl>(Record, Idx);
1424f4a2713aSLionel Sambuc   ReadDeclarationNameInfo(E->MemberNameInfo, Record, Idx);
1425f4a2713aSLionel Sambuc }
1426f4a2713aSLionel Sambuc 
1427f4a2713aSLionel Sambuc void
VisitDependentScopeDeclRefExpr(DependentScopeDeclRefExpr * E)1428f4a2713aSLionel Sambuc ASTStmtReader::VisitDependentScopeDeclRefExpr(DependentScopeDeclRefExpr *E) {
1429f4a2713aSLionel Sambuc   VisitExpr(E);
1430f4a2713aSLionel Sambuc 
1431f4a2713aSLionel Sambuc   if (Record[Idx++]) // HasTemplateKWAndArgsInfo
1432f4a2713aSLionel Sambuc     ReadTemplateKWAndArgsInfo(*E->getTemplateKWAndArgsInfo(),
1433f4a2713aSLionel Sambuc                               /*NumTemplateArgs=*/Record[Idx++]);
1434f4a2713aSLionel Sambuc 
1435f4a2713aSLionel Sambuc   E->QualifierLoc = Reader.ReadNestedNameSpecifierLoc(F, Record, Idx);
1436f4a2713aSLionel Sambuc   ReadDeclarationNameInfo(E->NameInfo, Record, Idx);
1437f4a2713aSLionel Sambuc }
1438f4a2713aSLionel Sambuc 
1439f4a2713aSLionel Sambuc void
VisitCXXUnresolvedConstructExpr(CXXUnresolvedConstructExpr * E)1440f4a2713aSLionel Sambuc ASTStmtReader::VisitCXXUnresolvedConstructExpr(CXXUnresolvedConstructExpr *E) {
1441f4a2713aSLionel Sambuc   VisitExpr(E);
1442f4a2713aSLionel Sambuc   assert(Record[Idx] == E->arg_size() && "Read wrong record during creation ?");
1443f4a2713aSLionel Sambuc   ++Idx; // NumArgs;
1444f4a2713aSLionel Sambuc   for (unsigned I = 0, N = E->arg_size(); I != N; ++I)
1445f4a2713aSLionel Sambuc     E->setArg(I, Reader.ReadSubExpr());
1446f4a2713aSLionel Sambuc   E->Type = GetTypeSourceInfo(Record, Idx);
1447f4a2713aSLionel Sambuc   E->setLParenLoc(ReadSourceLocation(Record, Idx));
1448f4a2713aSLionel Sambuc   E->setRParenLoc(ReadSourceLocation(Record, Idx));
1449f4a2713aSLionel Sambuc }
1450f4a2713aSLionel Sambuc 
VisitOverloadExpr(OverloadExpr * E)1451f4a2713aSLionel Sambuc void ASTStmtReader::VisitOverloadExpr(OverloadExpr *E) {
1452f4a2713aSLionel Sambuc   VisitExpr(E);
1453f4a2713aSLionel Sambuc 
1454f4a2713aSLionel Sambuc   if (Record[Idx++]) // HasTemplateKWAndArgsInfo
1455f4a2713aSLionel Sambuc     ReadTemplateKWAndArgsInfo(*E->getTemplateKWAndArgsInfo(),
1456f4a2713aSLionel Sambuc                               /*NumTemplateArgs=*/Record[Idx++]);
1457f4a2713aSLionel Sambuc 
1458f4a2713aSLionel Sambuc   unsigned NumDecls = Record[Idx++];
1459f4a2713aSLionel Sambuc   UnresolvedSet<8> Decls;
1460f4a2713aSLionel Sambuc   for (unsigned i = 0; i != NumDecls; ++i) {
1461f4a2713aSLionel Sambuc     NamedDecl *D = ReadDeclAs<NamedDecl>(Record, Idx);
1462f4a2713aSLionel Sambuc     AccessSpecifier AS = (AccessSpecifier)Record[Idx++];
1463f4a2713aSLionel Sambuc     Decls.addDecl(D, AS);
1464f4a2713aSLionel Sambuc   }
1465f4a2713aSLionel Sambuc   E->initializeResults(Reader.getContext(), Decls.begin(), Decls.end());
1466f4a2713aSLionel Sambuc 
1467f4a2713aSLionel Sambuc   ReadDeclarationNameInfo(E->NameInfo, Record, Idx);
1468f4a2713aSLionel Sambuc   E->QualifierLoc = Reader.ReadNestedNameSpecifierLoc(F, Record, Idx);
1469f4a2713aSLionel Sambuc }
1470f4a2713aSLionel Sambuc 
VisitUnresolvedMemberExpr(UnresolvedMemberExpr * E)1471f4a2713aSLionel Sambuc void ASTStmtReader::VisitUnresolvedMemberExpr(UnresolvedMemberExpr *E) {
1472f4a2713aSLionel Sambuc   VisitOverloadExpr(E);
1473f4a2713aSLionel Sambuc   E->IsArrow = Record[Idx++];
1474f4a2713aSLionel Sambuc   E->HasUnresolvedUsing = Record[Idx++];
1475f4a2713aSLionel Sambuc   E->Base = Reader.ReadSubExpr();
1476f4a2713aSLionel Sambuc   E->BaseType = Reader.readType(F, Record, Idx);
1477f4a2713aSLionel Sambuc   E->OperatorLoc = ReadSourceLocation(Record, Idx);
1478f4a2713aSLionel Sambuc }
1479f4a2713aSLionel Sambuc 
VisitUnresolvedLookupExpr(UnresolvedLookupExpr * E)1480f4a2713aSLionel Sambuc void ASTStmtReader::VisitUnresolvedLookupExpr(UnresolvedLookupExpr *E) {
1481f4a2713aSLionel Sambuc   VisitOverloadExpr(E);
1482f4a2713aSLionel Sambuc   E->RequiresADL = Record[Idx++];
1483f4a2713aSLionel Sambuc   E->Overloaded = Record[Idx++];
1484f4a2713aSLionel Sambuc   E->NamingClass = ReadDeclAs<CXXRecordDecl>(Record, Idx);
1485f4a2713aSLionel Sambuc }
1486f4a2713aSLionel Sambuc 
VisitTypeTraitExpr(TypeTraitExpr * E)1487f4a2713aSLionel Sambuc void ASTStmtReader::VisitTypeTraitExpr(TypeTraitExpr *E) {
1488f4a2713aSLionel Sambuc   VisitExpr(E);
1489f4a2713aSLionel Sambuc   E->TypeTraitExprBits.NumArgs = Record[Idx++];
1490f4a2713aSLionel Sambuc   E->TypeTraitExprBits.Kind = Record[Idx++];
1491f4a2713aSLionel Sambuc   E->TypeTraitExprBits.Value = Record[Idx++];
1492*0a6a1f1dSLionel Sambuc   SourceRange Range = ReadSourceRange(Record, Idx);
1493*0a6a1f1dSLionel Sambuc   E->Loc = Range.getBegin();
1494*0a6a1f1dSLionel Sambuc   E->RParenLoc = Range.getEnd();
1495f4a2713aSLionel Sambuc 
1496f4a2713aSLionel Sambuc   TypeSourceInfo **Args = E->getTypeSourceInfos();
1497f4a2713aSLionel Sambuc   for (unsigned I = 0, N = E->getNumArgs(); I != N; ++I)
1498f4a2713aSLionel Sambuc     Args[I] = GetTypeSourceInfo(Record, Idx);
1499f4a2713aSLionel Sambuc }
1500f4a2713aSLionel Sambuc 
VisitArrayTypeTraitExpr(ArrayTypeTraitExpr * E)1501f4a2713aSLionel Sambuc void ASTStmtReader::VisitArrayTypeTraitExpr(ArrayTypeTraitExpr *E) {
1502f4a2713aSLionel Sambuc   VisitExpr(E);
1503f4a2713aSLionel Sambuc   E->ATT = (ArrayTypeTrait)Record[Idx++];
1504f4a2713aSLionel Sambuc   E->Value = (unsigned int)Record[Idx++];
1505f4a2713aSLionel Sambuc   SourceRange Range = ReadSourceRange(Record, Idx);
1506f4a2713aSLionel Sambuc   E->Loc = Range.getBegin();
1507f4a2713aSLionel Sambuc   E->RParen = Range.getEnd();
1508f4a2713aSLionel Sambuc   E->QueriedType = GetTypeSourceInfo(Record, Idx);
1509f4a2713aSLionel Sambuc }
1510f4a2713aSLionel Sambuc 
VisitExpressionTraitExpr(ExpressionTraitExpr * E)1511f4a2713aSLionel Sambuc void ASTStmtReader::VisitExpressionTraitExpr(ExpressionTraitExpr *E) {
1512f4a2713aSLionel Sambuc   VisitExpr(E);
1513f4a2713aSLionel Sambuc   E->ET = (ExpressionTrait)Record[Idx++];
1514f4a2713aSLionel Sambuc   E->Value = (bool)Record[Idx++];
1515f4a2713aSLionel Sambuc   SourceRange Range = ReadSourceRange(Record, Idx);
1516f4a2713aSLionel Sambuc   E->QueriedExpression = Reader.ReadSubExpr();
1517f4a2713aSLionel Sambuc   E->Loc = Range.getBegin();
1518f4a2713aSLionel Sambuc   E->RParen = Range.getEnd();
1519f4a2713aSLionel Sambuc }
1520f4a2713aSLionel Sambuc 
VisitCXXNoexceptExpr(CXXNoexceptExpr * E)1521f4a2713aSLionel Sambuc void ASTStmtReader::VisitCXXNoexceptExpr(CXXNoexceptExpr *E) {
1522f4a2713aSLionel Sambuc   VisitExpr(E);
1523f4a2713aSLionel Sambuc   E->Value = (bool)Record[Idx++];
1524f4a2713aSLionel Sambuc   E->Range = ReadSourceRange(Record, Idx);
1525f4a2713aSLionel Sambuc   E->Operand = Reader.ReadSubExpr();
1526f4a2713aSLionel Sambuc }
1527f4a2713aSLionel Sambuc 
VisitPackExpansionExpr(PackExpansionExpr * E)1528f4a2713aSLionel Sambuc void ASTStmtReader::VisitPackExpansionExpr(PackExpansionExpr *E) {
1529f4a2713aSLionel Sambuc   VisitExpr(E);
1530f4a2713aSLionel Sambuc   E->EllipsisLoc = ReadSourceLocation(Record, Idx);
1531f4a2713aSLionel Sambuc   E->NumExpansions = Record[Idx++];
1532f4a2713aSLionel Sambuc   E->Pattern = Reader.ReadSubExpr();
1533f4a2713aSLionel Sambuc }
1534f4a2713aSLionel Sambuc 
VisitSizeOfPackExpr(SizeOfPackExpr * E)1535f4a2713aSLionel Sambuc void ASTStmtReader::VisitSizeOfPackExpr(SizeOfPackExpr *E) {
1536f4a2713aSLionel Sambuc   VisitExpr(E);
1537f4a2713aSLionel Sambuc   E->OperatorLoc = ReadSourceLocation(Record, Idx);
1538f4a2713aSLionel Sambuc   E->PackLoc = ReadSourceLocation(Record, Idx);
1539f4a2713aSLionel Sambuc   E->RParenLoc = ReadSourceLocation(Record, Idx);
1540f4a2713aSLionel Sambuc   E->Length = Record[Idx++];
1541f4a2713aSLionel Sambuc   E->Pack = ReadDeclAs<NamedDecl>(Record, Idx);
1542f4a2713aSLionel Sambuc }
1543f4a2713aSLionel Sambuc 
VisitSubstNonTypeTemplateParmExpr(SubstNonTypeTemplateParmExpr * E)1544f4a2713aSLionel Sambuc void ASTStmtReader::VisitSubstNonTypeTemplateParmExpr(
1545f4a2713aSLionel Sambuc                                               SubstNonTypeTemplateParmExpr *E) {
1546f4a2713aSLionel Sambuc   VisitExpr(E);
1547f4a2713aSLionel Sambuc   E->Param = ReadDeclAs<NonTypeTemplateParmDecl>(Record, Idx);
1548f4a2713aSLionel Sambuc   E->NameLoc = ReadSourceLocation(Record, Idx);
1549f4a2713aSLionel Sambuc   E->Replacement = Reader.ReadSubExpr();
1550f4a2713aSLionel Sambuc }
1551f4a2713aSLionel Sambuc 
VisitSubstNonTypeTemplateParmPackExpr(SubstNonTypeTemplateParmPackExpr * E)1552f4a2713aSLionel Sambuc void ASTStmtReader::VisitSubstNonTypeTemplateParmPackExpr(
1553f4a2713aSLionel Sambuc                                           SubstNonTypeTemplateParmPackExpr *E) {
1554f4a2713aSLionel Sambuc   VisitExpr(E);
1555f4a2713aSLionel Sambuc   E->Param = ReadDeclAs<NonTypeTemplateParmDecl>(Record, Idx);
1556f4a2713aSLionel Sambuc   TemplateArgument ArgPack = Reader.ReadTemplateArgument(F, Record, Idx);
1557f4a2713aSLionel Sambuc   if (ArgPack.getKind() != TemplateArgument::Pack)
1558f4a2713aSLionel Sambuc     return;
1559f4a2713aSLionel Sambuc 
1560f4a2713aSLionel Sambuc   E->Arguments = ArgPack.pack_begin();
1561f4a2713aSLionel Sambuc   E->NumArguments = ArgPack.pack_size();
1562f4a2713aSLionel Sambuc   E->NameLoc = ReadSourceLocation(Record, Idx);
1563f4a2713aSLionel Sambuc }
1564f4a2713aSLionel Sambuc 
VisitFunctionParmPackExpr(FunctionParmPackExpr * E)1565f4a2713aSLionel Sambuc void ASTStmtReader::VisitFunctionParmPackExpr(FunctionParmPackExpr *E) {
1566f4a2713aSLionel Sambuc   VisitExpr(E);
1567f4a2713aSLionel Sambuc   E->NumParameters = Record[Idx++];
1568f4a2713aSLionel Sambuc   E->ParamPack = ReadDeclAs<ParmVarDecl>(Record, Idx);
1569f4a2713aSLionel Sambuc   E->NameLoc = ReadSourceLocation(Record, Idx);
1570f4a2713aSLionel Sambuc   ParmVarDecl **Parms = reinterpret_cast<ParmVarDecl**>(E+1);
1571f4a2713aSLionel Sambuc   for (unsigned i = 0, n = E->NumParameters; i != n; ++i)
1572f4a2713aSLionel Sambuc     Parms[i] = ReadDeclAs<ParmVarDecl>(Record, Idx);
1573f4a2713aSLionel Sambuc }
1574f4a2713aSLionel Sambuc 
VisitMaterializeTemporaryExpr(MaterializeTemporaryExpr * E)1575f4a2713aSLionel Sambuc void ASTStmtReader::VisitMaterializeTemporaryExpr(MaterializeTemporaryExpr *E) {
1576f4a2713aSLionel Sambuc   VisitExpr(E);
1577*0a6a1f1dSLionel Sambuc   E->State = Reader.ReadSubExpr();
1578*0a6a1f1dSLionel Sambuc   auto VD = ReadDeclAs<ValueDecl>(Record, Idx);
1579*0a6a1f1dSLionel Sambuc   unsigned ManglingNumber = Record[Idx++];
1580*0a6a1f1dSLionel Sambuc   E->setExtendingDecl(VD, ManglingNumber);
1581*0a6a1f1dSLionel Sambuc }
1582*0a6a1f1dSLionel Sambuc 
VisitCXXFoldExpr(CXXFoldExpr * E)1583*0a6a1f1dSLionel Sambuc void ASTStmtReader::VisitCXXFoldExpr(CXXFoldExpr *E) {
1584*0a6a1f1dSLionel Sambuc   VisitExpr(E);
1585*0a6a1f1dSLionel Sambuc   E->LParenLoc = ReadSourceLocation(Record, Idx);
1586*0a6a1f1dSLionel Sambuc   E->EllipsisLoc = ReadSourceLocation(Record, Idx);
1587*0a6a1f1dSLionel Sambuc   E->RParenLoc = ReadSourceLocation(Record, Idx);
1588*0a6a1f1dSLionel Sambuc   E->SubExprs[0] = Reader.ReadSubExpr();
1589*0a6a1f1dSLionel Sambuc   E->SubExprs[1] = Reader.ReadSubExpr();
1590*0a6a1f1dSLionel Sambuc   E->Opcode = (BinaryOperatorKind)Record[Idx++];
1591f4a2713aSLionel Sambuc }
1592f4a2713aSLionel Sambuc 
VisitOpaqueValueExpr(OpaqueValueExpr * E)1593f4a2713aSLionel Sambuc void ASTStmtReader::VisitOpaqueValueExpr(OpaqueValueExpr *E) {
1594f4a2713aSLionel Sambuc   VisitExpr(E);
1595f4a2713aSLionel Sambuc   E->SourceExpr = Reader.ReadSubExpr();
1596f4a2713aSLionel Sambuc   E->Loc = ReadSourceLocation(Record, Idx);
1597f4a2713aSLionel Sambuc }
1598f4a2713aSLionel Sambuc 
VisitTypoExpr(TypoExpr * E)1599*0a6a1f1dSLionel Sambuc void ASTStmtReader::VisitTypoExpr(TypoExpr *E) {
1600*0a6a1f1dSLionel Sambuc   llvm_unreachable("Cannot read TypoExpr nodes");
1601*0a6a1f1dSLionel Sambuc }
1602*0a6a1f1dSLionel Sambuc 
1603f4a2713aSLionel Sambuc //===----------------------------------------------------------------------===//
1604f4a2713aSLionel Sambuc // Microsoft Expressions and Statements
1605f4a2713aSLionel Sambuc //===----------------------------------------------------------------------===//
VisitMSPropertyRefExpr(MSPropertyRefExpr * E)1606f4a2713aSLionel Sambuc void ASTStmtReader::VisitMSPropertyRefExpr(MSPropertyRefExpr *E) {
1607f4a2713aSLionel Sambuc   VisitExpr(E);
1608f4a2713aSLionel Sambuc   E->IsArrow = (Record[Idx++] != 0);
1609f4a2713aSLionel Sambuc   E->BaseExpr = Reader.ReadSubExpr();
1610f4a2713aSLionel Sambuc   E->QualifierLoc = Reader.ReadNestedNameSpecifierLoc(F, Record, Idx);
1611f4a2713aSLionel Sambuc   E->MemberLoc = ReadSourceLocation(Record, Idx);
1612f4a2713aSLionel Sambuc   E->TheDecl = ReadDeclAs<MSPropertyDecl>(Record, Idx);
1613f4a2713aSLionel Sambuc }
1614f4a2713aSLionel Sambuc 
VisitCXXUuidofExpr(CXXUuidofExpr * E)1615f4a2713aSLionel Sambuc void ASTStmtReader::VisitCXXUuidofExpr(CXXUuidofExpr *E) {
1616f4a2713aSLionel Sambuc   VisitExpr(E);
1617f4a2713aSLionel Sambuc   E->setSourceRange(ReadSourceRange(Record, Idx));
1618f4a2713aSLionel Sambuc   if (E->isTypeOperand()) { // __uuidof(ComType)
1619f4a2713aSLionel Sambuc     E->setTypeOperandSourceInfo(
1620f4a2713aSLionel Sambuc         GetTypeSourceInfo(Record, Idx));
1621f4a2713aSLionel Sambuc     return;
1622f4a2713aSLionel Sambuc   }
1623f4a2713aSLionel Sambuc 
1624f4a2713aSLionel Sambuc   // __uuidof(expr)
1625f4a2713aSLionel Sambuc   E->setExprOperand(Reader.ReadSubExpr());
1626f4a2713aSLionel Sambuc }
1627f4a2713aSLionel Sambuc 
VisitSEHLeaveStmt(SEHLeaveStmt * S)1628*0a6a1f1dSLionel Sambuc void ASTStmtReader::VisitSEHLeaveStmt(SEHLeaveStmt *S) {
1629*0a6a1f1dSLionel Sambuc   VisitStmt(S);
1630*0a6a1f1dSLionel Sambuc   S->setLeaveLoc(ReadSourceLocation(Record, Idx));
1631*0a6a1f1dSLionel Sambuc }
1632*0a6a1f1dSLionel Sambuc 
VisitSEHExceptStmt(SEHExceptStmt * S)1633f4a2713aSLionel Sambuc void ASTStmtReader::VisitSEHExceptStmt(SEHExceptStmt *S) {
1634f4a2713aSLionel Sambuc   VisitStmt(S);
1635f4a2713aSLionel Sambuc   S->Loc = ReadSourceLocation(Record, Idx);
1636f4a2713aSLionel Sambuc   S->Children[SEHExceptStmt::FILTER_EXPR] = Reader.ReadSubStmt();
1637f4a2713aSLionel Sambuc   S->Children[SEHExceptStmt::BLOCK] = Reader.ReadSubStmt();
1638f4a2713aSLionel Sambuc }
1639f4a2713aSLionel Sambuc 
VisitSEHFinallyStmt(SEHFinallyStmt * S)1640f4a2713aSLionel Sambuc void ASTStmtReader::VisitSEHFinallyStmt(SEHFinallyStmt *S) {
1641f4a2713aSLionel Sambuc   VisitStmt(S);
1642f4a2713aSLionel Sambuc   S->Loc = ReadSourceLocation(Record, Idx);
1643f4a2713aSLionel Sambuc   S->Block = Reader.ReadSubStmt();
1644f4a2713aSLionel Sambuc }
1645f4a2713aSLionel Sambuc 
VisitSEHTryStmt(SEHTryStmt * S)1646f4a2713aSLionel Sambuc void ASTStmtReader::VisitSEHTryStmt(SEHTryStmt *S) {
1647f4a2713aSLionel Sambuc   VisitStmt(S);
1648f4a2713aSLionel Sambuc   S->IsCXXTry = Record[Idx++];
1649f4a2713aSLionel Sambuc   S->TryLoc = ReadSourceLocation(Record, Idx);
1650f4a2713aSLionel Sambuc   S->Children[SEHTryStmt::TRY] = Reader.ReadSubStmt();
1651f4a2713aSLionel Sambuc   S->Children[SEHTryStmt::HANDLER] = Reader.ReadSubStmt();
1652f4a2713aSLionel Sambuc }
1653f4a2713aSLionel Sambuc 
1654f4a2713aSLionel Sambuc //===----------------------------------------------------------------------===//
1655f4a2713aSLionel Sambuc // CUDA Expressions and Statements
1656f4a2713aSLionel Sambuc //===----------------------------------------------------------------------===//
1657f4a2713aSLionel Sambuc 
VisitCUDAKernelCallExpr(CUDAKernelCallExpr * E)1658f4a2713aSLionel Sambuc void ASTStmtReader::VisitCUDAKernelCallExpr(CUDAKernelCallExpr *E) {
1659f4a2713aSLionel Sambuc   VisitCallExpr(E);
1660f4a2713aSLionel Sambuc   E->setConfig(cast<CallExpr>(Reader.ReadSubExpr()));
1661f4a2713aSLionel Sambuc }
1662f4a2713aSLionel Sambuc 
1663f4a2713aSLionel Sambuc //===----------------------------------------------------------------------===//
1664f4a2713aSLionel Sambuc // OpenCL Expressions and Statements.
1665f4a2713aSLionel Sambuc //===----------------------------------------------------------------------===//
VisitAsTypeExpr(AsTypeExpr * E)1666f4a2713aSLionel Sambuc void ASTStmtReader::VisitAsTypeExpr(AsTypeExpr *E) {
1667f4a2713aSLionel Sambuc   VisitExpr(E);
1668f4a2713aSLionel Sambuc   E->BuiltinLoc = ReadSourceLocation(Record, Idx);
1669f4a2713aSLionel Sambuc   E->RParenLoc = ReadSourceLocation(Record, Idx);
1670f4a2713aSLionel Sambuc   E->SrcExpr = Reader.ReadSubExpr();
1671f4a2713aSLionel Sambuc }
1672f4a2713aSLionel Sambuc 
1673f4a2713aSLionel Sambuc //===----------------------------------------------------------------------===//
1674f4a2713aSLionel Sambuc // OpenMP Clauses.
1675f4a2713aSLionel Sambuc //===----------------------------------------------------------------------===//
1676f4a2713aSLionel Sambuc 
1677f4a2713aSLionel Sambuc namespace clang {
1678f4a2713aSLionel Sambuc class OMPClauseReader : public OMPClauseVisitor<OMPClauseReader> {
1679f4a2713aSLionel Sambuc   ASTStmtReader *Reader;
1680f4a2713aSLionel Sambuc   ASTContext &Context;
1681f4a2713aSLionel Sambuc   const ASTReader::RecordData &Record;
1682f4a2713aSLionel Sambuc   unsigned &Idx;
1683f4a2713aSLionel Sambuc public:
OMPClauseReader(ASTStmtReader * R,ASTContext & C,const ASTReader::RecordData & Record,unsigned & Idx)1684f4a2713aSLionel Sambuc   OMPClauseReader(ASTStmtReader *R, ASTContext &C,
1685f4a2713aSLionel Sambuc                   const ASTReader::RecordData &Record, unsigned &Idx)
1686f4a2713aSLionel Sambuc     : Reader(R), Context(C), Record(Record), Idx(Idx) { }
1687f4a2713aSLionel Sambuc #define OPENMP_CLAUSE(Name, Class)    \
1688f4a2713aSLionel Sambuc   void Visit##Class(Class *S);
1689f4a2713aSLionel Sambuc #include "clang/Basic/OpenMPKinds.def"
1690f4a2713aSLionel Sambuc   OMPClause *readClause();
1691f4a2713aSLionel Sambuc };
1692f4a2713aSLionel Sambuc }
1693f4a2713aSLionel Sambuc 
readClause()1694f4a2713aSLionel Sambuc OMPClause *OMPClauseReader::readClause() {
1695f4a2713aSLionel Sambuc   OMPClause *C;
1696f4a2713aSLionel Sambuc   switch (Record[Idx++]) {
1697*0a6a1f1dSLionel Sambuc   case OMPC_if:
1698*0a6a1f1dSLionel Sambuc     C = new (Context) OMPIfClause();
1699*0a6a1f1dSLionel Sambuc     break;
1700*0a6a1f1dSLionel Sambuc   case OMPC_final:
1701*0a6a1f1dSLionel Sambuc     C = new (Context) OMPFinalClause();
1702*0a6a1f1dSLionel Sambuc     break;
1703*0a6a1f1dSLionel Sambuc   case OMPC_num_threads:
1704*0a6a1f1dSLionel Sambuc     C = new (Context) OMPNumThreadsClause();
1705*0a6a1f1dSLionel Sambuc     break;
1706*0a6a1f1dSLionel Sambuc   case OMPC_safelen:
1707*0a6a1f1dSLionel Sambuc     C = new (Context) OMPSafelenClause();
1708*0a6a1f1dSLionel Sambuc     break;
1709*0a6a1f1dSLionel Sambuc   case OMPC_collapse:
1710*0a6a1f1dSLionel Sambuc     C = new (Context) OMPCollapseClause();
1711*0a6a1f1dSLionel Sambuc     break;
1712f4a2713aSLionel Sambuc   case OMPC_default:
1713f4a2713aSLionel Sambuc     C = new (Context) OMPDefaultClause();
1714f4a2713aSLionel Sambuc     break;
1715*0a6a1f1dSLionel Sambuc   case OMPC_proc_bind:
1716*0a6a1f1dSLionel Sambuc     C = new (Context) OMPProcBindClause();
1717*0a6a1f1dSLionel Sambuc     break;
1718*0a6a1f1dSLionel Sambuc   case OMPC_schedule:
1719*0a6a1f1dSLionel Sambuc     C = new (Context) OMPScheduleClause();
1720*0a6a1f1dSLionel Sambuc     break;
1721*0a6a1f1dSLionel Sambuc   case OMPC_ordered:
1722*0a6a1f1dSLionel Sambuc     C = new (Context) OMPOrderedClause();
1723*0a6a1f1dSLionel Sambuc     break;
1724*0a6a1f1dSLionel Sambuc   case OMPC_nowait:
1725*0a6a1f1dSLionel Sambuc     C = new (Context) OMPNowaitClause();
1726*0a6a1f1dSLionel Sambuc     break;
1727*0a6a1f1dSLionel Sambuc   case OMPC_untied:
1728*0a6a1f1dSLionel Sambuc     C = new (Context) OMPUntiedClause();
1729*0a6a1f1dSLionel Sambuc     break;
1730*0a6a1f1dSLionel Sambuc   case OMPC_mergeable:
1731*0a6a1f1dSLionel Sambuc     C = new (Context) OMPMergeableClause();
1732*0a6a1f1dSLionel Sambuc     break;
1733*0a6a1f1dSLionel Sambuc   case OMPC_read:
1734*0a6a1f1dSLionel Sambuc     C = new (Context) OMPReadClause();
1735*0a6a1f1dSLionel Sambuc     break;
1736*0a6a1f1dSLionel Sambuc   case OMPC_write:
1737*0a6a1f1dSLionel Sambuc     C = new (Context) OMPWriteClause();
1738*0a6a1f1dSLionel Sambuc     break;
1739*0a6a1f1dSLionel Sambuc   case OMPC_update:
1740*0a6a1f1dSLionel Sambuc     C = new (Context) OMPUpdateClause();
1741*0a6a1f1dSLionel Sambuc     break;
1742*0a6a1f1dSLionel Sambuc   case OMPC_capture:
1743*0a6a1f1dSLionel Sambuc     C = new (Context) OMPCaptureClause();
1744*0a6a1f1dSLionel Sambuc     break;
1745*0a6a1f1dSLionel Sambuc   case OMPC_seq_cst:
1746*0a6a1f1dSLionel Sambuc     C = new (Context) OMPSeqCstClause();
1747*0a6a1f1dSLionel Sambuc     break;
1748f4a2713aSLionel Sambuc   case OMPC_private:
1749f4a2713aSLionel Sambuc     C = OMPPrivateClause::CreateEmpty(Context, Record[Idx++]);
1750f4a2713aSLionel Sambuc     break;
1751f4a2713aSLionel Sambuc   case OMPC_firstprivate:
1752f4a2713aSLionel Sambuc     C = OMPFirstprivateClause::CreateEmpty(Context, Record[Idx++]);
1753f4a2713aSLionel Sambuc     break;
1754*0a6a1f1dSLionel Sambuc   case OMPC_lastprivate:
1755*0a6a1f1dSLionel Sambuc     C = OMPLastprivateClause::CreateEmpty(Context, Record[Idx++]);
1756*0a6a1f1dSLionel Sambuc     break;
1757f4a2713aSLionel Sambuc   case OMPC_shared:
1758f4a2713aSLionel Sambuc     C = OMPSharedClause::CreateEmpty(Context, Record[Idx++]);
1759f4a2713aSLionel Sambuc     break;
1760*0a6a1f1dSLionel Sambuc   case OMPC_reduction:
1761*0a6a1f1dSLionel Sambuc     C = OMPReductionClause::CreateEmpty(Context, Record[Idx++]);
1762*0a6a1f1dSLionel Sambuc     break;
1763*0a6a1f1dSLionel Sambuc   case OMPC_linear:
1764*0a6a1f1dSLionel Sambuc     C = OMPLinearClause::CreateEmpty(Context, Record[Idx++]);
1765*0a6a1f1dSLionel Sambuc     break;
1766*0a6a1f1dSLionel Sambuc   case OMPC_aligned:
1767*0a6a1f1dSLionel Sambuc     C = OMPAlignedClause::CreateEmpty(Context, Record[Idx++]);
1768*0a6a1f1dSLionel Sambuc     break;
1769*0a6a1f1dSLionel Sambuc   case OMPC_copyin:
1770*0a6a1f1dSLionel Sambuc     C = OMPCopyinClause::CreateEmpty(Context, Record[Idx++]);
1771*0a6a1f1dSLionel Sambuc     break;
1772*0a6a1f1dSLionel Sambuc   case OMPC_copyprivate:
1773*0a6a1f1dSLionel Sambuc     C = OMPCopyprivateClause::CreateEmpty(Context, Record[Idx++]);
1774*0a6a1f1dSLionel Sambuc     break;
1775*0a6a1f1dSLionel Sambuc   case OMPC_flush:
1776*0a6a1f1dSLionel Sambuc     C = OMPFlushClause::CreateEmpty(Context, Record[Idx++]);
1777*0a6a1f1dSLionel Sambuc     break;
1778f4a2713aSLionel Sambuc   }
1779f4a2713aSLionel Sambuc   Visit(C);
1780f4a2713aSLionel Sambuc   C->setLocStart(Reader->ReadSourceLocation(Record, Idx));
1781f4a2713aSLionel Sambuc   C->setLocEnd(Reader->ReadSourceLocation(Record, Idx));
1782f4a2713aSLionel Sambuc 
1783f4a2713aSLionel Sambuc   return C;
1784f4a2713aSLionel Sambuc }
1785f4a2713aSLionel Sambuc 
VisitOMPIfClause(OMPIfClause * C)1786*0a6a1f1dSLionel Sambuc void OMPClauseReader::VisitOMPIfClause(OMPIfClause *C) {
1787*0a6a1f1dSLionel Sambuc   C->setCondition(Reader->Reader.ReadSubExpr());
1788*0a6a1f1dSLionel Sambuc   C->setLParenLoc(Reader->ReadSourceLocation(Record, Idx));
1789*0a6a1f1dSLionel Sambuc }
1790*0a6a1f1dSLionel Sambuc 
VisitOMPFinalClause(OMPFinalClause * C)1791*0a6a1f1dSLionel Sambuc void OMPClauseReader::VisitOMPFinalClause(OMPFinalClause *C) {
1792*0a6a1f1dSLionel Sambuc   C->setCondition(Reader->Reader.ReadSubExpr());
1793*0a6a1f1dSLionel Sambuc   C->setLParenLoc(Reader->ReadSourceLocation(Record, Idx));
1794*0a6a1f1dSLionel Sambuc }
1795*0a6a1f1dSLionel Sambuc 
VisitOMPNumThreadsClause(OMPNumThreadsClause * C)1796*0a6a1f1dSLionel Sambuc void OMPClauseReader::VisitOMPNumThreadsClause(OMPNumThreadsClause *C) {
1797*0a6a1f1dSLionel Sambuc   C->setNumThreads(Reader->Reader.ReadSubExpr());
1798*0a6a1f1dSLionel Sambuc   C->setLParenLoc(Reader->ReadSourceLocation(Record, Idx));
1799*0a6a1f1dSLionel Sambuc }
1800*0a6a1f1dSLionel Sambuc 
VisitOMPSafelenClause(OMPSafelenClause * C)1801*0a6a1f1dSLionel Sambuc void OMPClauseReader::VisitOMPSafelenClause(OMPSafelenClause *C) {
1802*0a6a1f1dSLionel Sambuc   C->setSafelen(Reader->Reader.ReadSubExpr());
1803*0a6a1f1dSLionel Sambuc   C->setLParenLoc(Reader->ReadSourceLocation(Record, Idx));
1804*0a6a1f1dSLionel Sambuc }
1805*0a6a1f1dSLionel Sambuc 
VisitOMPCollapseClause(OMPCollapseClause * C)1806*0a6a1f1dSLionel Sambuc void OMPClauseReader::VisitOMPCollapseClause(OMPCollapseClause *C) {
1807*0a6a1f1dSLionel Sambuc   C->setNumForLoops(Reader->Reader.ReadSubExpr());
1808*0a6a1f1dSLionel Sambuc   C->setLParenLoc(Reader->ReadSourceLocation(Record, Idx));
1809*0a6a1f1dSLionel Sambuc }
1810*0a6a1f1dSLionel Sambuc 
VisitOMPDefaultClause(OMPDefaultClause * C)1811f4a2713aSLionel Sambuc void OMPClauseReader::VisitOMPDefaultClause(OMPDefaultClause *C) {
1812f4a2713aSLionel Sambuc   C->setDefaultKind(
1813f4a2713aSLionel Sambuc        static_cast<OpenMPDefaultClauseKind>(Record[Idx++]));
1814f4a2713aSLionel Sambuc   C->setLParenLoc(Reader->ReadSourceLocation(Record, Idx));
1815f4a2713aSLionel Sambuc   C->setDefaultKindKwLoc(Reader->ReadSourceLocation(Record, Idx));
1816f4a2713aSLionel Sambuc }
1817f4a2713aSLionel Sambuc 
VisitOMPProcBindClause(OMPProcBindClause * C)1818*0a6a1f1dSLionel Sambuc void OMPClauseReader::VisitOMPProcBindClause(OMPProcBindClause *C) {
1819*0a6a1f1dSLionel Sambuc   C->setProcBindKind(
1820*0a6a1f1dSLionel Sambuc        static_cast<OpenMPProcBindClauseKind>(Record[Idx++]));
1821*0a6a1f1dSLionel Sambuc   C->setLParenLoc(Reader->ReadSourceLocation(Record, Idx));
1822*0a6a1f1dSLionel Sambuc   C->setProcBindKindKwLoc(Reader->ReadSourceLocation(Record, Idx));
1823*0a6a1f1dSLionel Sambuc }
1824*0a6a1f1dSLionel Sambuc 
VisitOMPScheduleClause(OMPScheduleClause * C)1825*0a6a1f1dSLionel Sambuc void OMPClauseReader::VisitOMPScheduleClause(OMPScheduleClause *C) {
1826*0a6a1f1dSLionel Sambuc   C->setScheduleKind(
1827*0a6a1f1dSLionel Sambuc        static_cast<OpenMPScheduleClauseKind>(Record[Idx++]));
1828*0a6a1f1dSLionel Sambuc   C->setChunkSize(Reader->Reader.ReadSubExpr());
1829*0a6a1f1dSLionel Sambuc   C->setLParenLoc(Reader->ReadSourceLocation(Record, Idx));
1830*0a6a1f1dSLionel Sambuc   C->setScheduleKindLoc(Reader->ReadSourceLocation(Record, Idx));
1831*0a6a1f1dSLionel Sambuc   C->setCommaLoc(Reader->ReadSourceLocation(Record, Idx));
1832*0a6a1f1dSLionel Sambuc }
1833*0a6a1f1dSLionel Sambuc 
VisitOMPOrderedClause(OMPOrderedClause *)1834*0a6a1f1dSLionel Sambuc void OMPClauseReader::VisitOMPOrderedClause(OMPOrderedClause *) {}
1835*0a6a1f1dSLionel Sambuc 
VisitOMPNowaitClause(OMPNowaitClause *)1836*0a6a1f1dSLionel Sambuc void OMPClauseReader::VisitOMPNowaitClause(OMPNowaitClause *) {}
1837*0a6a1f1dSLionel Sambuc 
VisitOMPUntiedClause(OMPUntiedClause *)1838*0a6a1f1dSLionel Sambuc void OMPClauseReader::VisitOMPUntiedClause(OMPUntiedClause *) {}
1839*0a6a1f1dSLionel Sambuc 
VisitOMPMergeableClause(OMPMergeableClause *)1840*0a6a1f1dSLionel Sambuc void OMPClauseReader::VisitOMPMergeableClause(OMPMergeableClause *) {}
1841*0a6a1f1dSLionel Sambuc 
VisitOMPReadClause(OMPReadClause *)1842*0a6a1f1dSLionel Sambuc void OMPClauseReader::VisitOMPReadClause(OMPReadClause *) {}
1843*0a6a1f1dSLionel Sambuc 
VisitOMPWriteClause(OMPWriteClause *)1844*0a6a1f1dSLionel Sambuc void OMPClauseReader::VisitOMPWriteClause(OMPWriteClause *) {}
1845*0a6a1f1dSLionel Sambuc 
VisitOMPUpdateClause(OMPUpdateClause *)1846*0a6a1f1dSLionel Sambuc void OMPClauseReader::VisitOMPUpdateClause(OMPUpdateClause *) {}
1847*0a6a1f1dSLionel Sambuc 
VisitOMPCaptureClause(OMPCaptureClause *)1848*0a6a1f1dSLionel Sambuc void OMPClauseReader::VisitOMPCaptureClause(OMPCaptureClause *) {}
1849*0a6a1f1dSLionel Sambuc 
VisitOMPSeqCstClause(OMPSeqCstClause *)1850*0a6a1f1dSLionel Sambuc void OMPClauseReader::VisitOMPSeqCstClause(OMPSeqCstClause *) {}
1851*0a6a1f1dSLionel Sambuc 
VisitOMPPrivateClause(OMPPrivateClause * C)1852f4a2713aSLionel Sambuc void OMPClauseReader::VisitOMPPrivateClause(OMPPrivateClause *C) {
1853f4a2713aSLionel Sambuc   C->setLParenLoc(Reader->ReadSourceLocation(Record, Idx));
1854f4a2713aSLionel Sambuc   unsigned NumVars = C->varlist_size();
1855f4a2713aSLionel Sambuc   SmallVector<Expr *, 16> Vars;
1856f4a2713aSLionel Sambuc   Vars.reserve(NumVars);
1857f4a2713aSLionel Sambuc   for (unsigned i = 0; i != NumVars; ++i)
1858f4a2713aSLionel Sambuc     Vars.push_back(Reader->Reader.ReadSubExpr());
1859f4a2713aSLionel Sambuc   C->setVarRefs(Vars);
1860*0a6a1f1dSLionel Sambuc   Vars.clear();
1861*0a6a1f1dSLionel Sambuc   for (unsigned i = 0; i != NumVars; ++i)
1862*0a6a1f1dSLionel Sambuc     Vars.push_back(Reader->Reader.ReadSubExpr());
1863*0a6a1f1dSLionel Sambuc   C->setPrivateCopies(Vars);
1864f4a2713aSLionel Sambuc }
1865f4a2713aSLionel Sambuc 
VisitOMPFirstprivateClause(OMPFirstprivateClause * C)1866f4a2713aSLionel Sambuc void OMPClauseReader::VisitOMPFirstprivateClause(OMPFirstprivateClause *C) {
1867f4a2713aSLionel Sambuc   C->setLParenLoc(Reader->ReadSourceLocation(Record, Idx));
1868f4a2713aSLionel Sambuc   unsigned NumVars = C->varlist_size();
1869f4a2713aSLionel Sambuc   SmallVector<Expr *, 16> Vars;
1870f4a2713aSLionel Sambuc   Vars.reserve(NumVars);
1871f4a2713aSLionel Sambuc   for (unsigned i = 0; i != NumVars; ++i)
1872f4a2713aSLionel Sambuc     Vars.push_back(Reader->Reader.ReadSubExpr());
1873f4a2713aSLionel Sambuc   C->setVarRefs(Vars);
1874*0a6a1f1dSLionel Sambuc   Vars.clear();
1875*0a6a1f1dSLionel Sambuc   for (unsigned i = 0; i != NumVars; ++i)
1876*0a6a1f1dSLionel Sambuc     Vars.push_back(Reader->Reader.ReadSubExpr());
1877*0a6a1f1dSLionel Sambuc   C->setPrivateCopies(Vars);
1878*0a6a1f1dSLionel Sambuc   Vars.clear();
1879*0a6a1f1dSLionel Sambuc   for (unsigned i = 0; i != NumVars; ++i)
1880*0a6a1f1dSLionel Sambuc     Vars.push_back(Reader->Reader.ReadSubExpr());
1881*0a6a1f1dSLionel Sambuc   C->setInits(Vars);
1882*0a6a1f1dSLionel Sambuc }
1883*0a6a1f1dSLionel Sambuc 
VisitOMPLastprivateClause(OMPLastprivateClause * C)1884*0a6a1f1dSLionel Sambuc void OMPClauseReader::VisitOMPLastprivateClause(OMPLastprivateClause *C) {
1885*0a6a1f1dSLionel Sambuc   C->setLParenLoc(Reader->ReadSourceLocation(Record, Idx));
1886*0a6a1f1dSLionel Sambuc   unsigned NumVars = C->varlist_size();
1887*0a6a1f1dSLionel Sambuc   SmallVector<Expr *, 16> Vars;
1888*0a6a1f1dSLionel Sambuc   Vars.reserve(NumVars);
1889*0a6a1f1dSLionel Sambuc   for (unsigned i = 0; i != NumVars; ++i)
1890*0a6a1f1dSLionel Sambuc     Vars.push_back(Reader->Reader.ReadSubExpr());
1891*0a6a1f1dSLionel Sambuc   C->setVarRefs(Vars);
1892f4a2713aSLionel Sambuc }
1893f4a2713aSLionel Sambuc 
VisitOMPSharedClause(OMPSharedClause * C)1894f4a2713aSLionel Sambuc void OMPClauseReader::VisitOMPSharedClause(OMPSharedClause *C) {
1895f4a2713aSLionel Sambuc   C->setLParenLoc(Reader->ReadSourceLocation(Record, Idx));
1896f4a2713aSLionel Sambuc   unsigned NumVars = C->varlist_size();
1897f4a2713aSLionel Sambuc   SmallVector<Expr *, 16> Vars;
1898f4a2713aSLionel Sambuc   Vars.reserve(NumVars);
1899f4a2713aSLionel Sambuc   for (unsigned i = 0; i != NumVars; ++i)
1900f4a2713aSLionel Sambuc     Vars.push_back(Reader->Reader.ReadSubExpr());
1901f4a2713aSLionel Sambuc   C->setVarRefs(Vars);
1902f4a2713aSLionel Sambuc }
1903f4a2713aSLionel Sambuc 
VisitOMPReductionClause(OMPReductionClause * C)1904*0a6a1f1dSLionel Sambuc void OMPClauseReader::VisitOMPReductionClause(OMPReductionClause *C) {
1905*0a6a1f1dSLionel Sambuc   C->setLParenLoc(Reader->ReadSourceLocation(Record, Idx));
1906*0a6a1f1dSLionel Sambuc   C->setColonLoc(Reader->ReadSourceLocation(Record, Idx));
1907*0a6a1f1dSLionel Sambuc   NestedNameSpecifierLoc NNSL =
1908*0a6a1f1dSLionel Sambuc     Reader->Reader.ReadNestedNameSpecifierLoc(Reader->F, Record, Idx);
1909*0a6a1f1dSLionel Sambuc   DeclarationNameInfo DNI;
1910*0a6a1f1dSLionel Sambuc   Reader->ReadDeclarationNameInfo(DNI, Record, Idx);
1911*0a6a1f1dSLionel Sambuc   C->setQualifierLoc(NNSL);
1912*0a6a1f1dSLionel Sambuc   C->setNameInfo(DNI);
1913*0a6a1f1dSLionel Sambuc 
1914*0a6a1f1dSLionel Sambuc   unsigned NumVars = C->varlist_size();
1915*0a6a1f1dSLionel Sambuc   SmallVector<Expr *, 16> Vars;
1916*0a6a1f1dSLionel Sambuc   Vars.reserve(NumVars);
1917*0a6a1f1dSLionel Sambuc   for (unsigned i = 0; i != NumVars; ++i)
1918*0a6a1f1dSLionel Sambuc     Vars.push_back(Reader->Reader.ReadSubExpr());
1919*0a6a1f1dSLionel Sambuc   C->setVarRefs(Vars);
1920*0a6a1f1dSLionel Sambuc }
1921*0a6a1f1dSLionel Sambuc 
VisitOMPLinearClause(OMPLinearClause * C)1922*0a6a1f1dSLionel Sambuc void OMPClauseReader::VisitOMPLinearClause(OMPLinearClause *C) {
1923*0a6a1f1dSLionel Sambuc   C->setLParenLoc(Reader->ReadSourceLocation(Record, Idx));
1924*0a6a1f1dSLionel Sambuc   C->setColonLoc(Reader->ReadSourceLocation(Record, Idx));
1925*0a6a1f1dSLionel Sambuc   unsigned NumVars = C->varlist_size();
1926*0a6a1f1dSLionel Sambuc   SmallVector<Expr *, 16> Vars;
1927*0a6a1f1dSLionel Sambuc   Vars.reserve(NumVars);
1928*0a6a1f1dSLionel Sambuc   for (unsigned i = 0; i != NumVars; ++i)
1929*0a6a1f1dSLionel Sambuc     Vars.push_back(Reader->Reader.ReadSubExpr());
1930*0a6a1f1dSLionel Sambuc   C->setVarRefs(Vars);
1931*0a6a1f1dSLionel Sambuc   C->setStep(Reader->Reader.ReadSubExpr());
1932*0a6a1f1dSLionel Sambuc }
1933*0a6a1f1dSLionel Sambuc 
VisitOMPAlignedClause(OMPAlignedClause * C)1934*0a6a1f1dSLionel Sambuc void OMPClauseReader::VisitOMPAlignedClause(OMPAlignedClause *C) {
1935*0a6a1f1dSLionel Sambuc   C->setLParenLoc(Reader->ReadSourceLocation(Record, Idx));
1936*0a6a1f1dSLionel Sambuc   C->setColonLoc(Reader->ReadSourceLocation(Record, Idx));
1937*0a6a1f1dSLionel Sambuc   unsigned NumVars = C->varlist_size();
1938*0a6a1f1dSLionel Sambuc   SmallVector<Expr *, 16> Vars;
1939*0a6a1f1dSLionel Sambuc   Vars.reserve(NumVars);
1940*0a6a1f1dSLionel Sambuc   for (unsigned i = 0; i != NumVars; ++i)
1941*0a6a1f1dSLionel Sambuc     Vars.push_back(Reader->Reader.ReadSubExpr());
1942*0a6a1f1dSLionel Sambuc   C->setVarRefs(Vars);
1943*0a6a1f1dSLionel Sambuc   C->setAlignment(Reader->Reader.ReadSubExpr());
1944*0a6a1f1dSLionel Sambuc }
1945*0a6a1f1dSLionel Sambuc 
VisitOMPCopyinClause(OMPCopyinClause * C)1946*0a6a1f1dSLionel Sambuc void OMPClauseReader::VisitOMPCopyinClause(OMPCopyinClause *C) {
1947*0a6a1f1dSLionel Sambuc   C->setLParenLoc(Reader->ReadSourceLocation(Record, Idx));
1948*0a6a1f1dSLionel Sambuc   unsigned NumVars = C->varlist_size();
1949*0a6a1f1dSLionel Sambuc   SmallVector<Expr *, 16> Vars;
1950*0a6a1f1dSLionel Sambuc   Vars.reserve(NumVars);
1951*0a6a1f1dSLionel Sambuc   for (unsigned i = 0; i != NumVars; ++i)
1952*0a6a1f1dSLionel Sambuc     Vars.push_back(Reader->Reader.ReadSubExpr());
1953*0a6a1f1dSLionel Sambuc   C->setVarRefs(Vars);
1954*0a6a1f1dSLionel Sambuc }
1955*0a6a1f1dSLionel Sambuc 
VisitOMPCopyprivateClause(OMPCopyprivateClause * C)1956*0a6a1f1dSLionel Sambuc void OMPClauseReader::VisitOMPCopyprivateClause(OMPCopyprivateClause *C) {
1957*0a6a1f1dSLionel Sambuc   C->setLParenLoc(Reader->ReadSourceLocation(Record, Idx));
1958*0a6a1f1dSLionel Sambuc   unsigned NumVars = C->varlist_size();
1959*0a6a1f1dSLionel Sambuc   SmallVector<Expr *, 16> Vars;
1960*0a6a1f1dSLionel Sambuc   Vars.reserve(NumVars);
1961*0a6a1f1dSLionel Sambuc   for (unsigned i = 0; i != NumVars; ++i)
1962*0a6a1f1dSLionel Sambuc     Vars.push_back(Reader->Reader.ReadSubExpr());
1963*0a6a1f1dSLionel Sambuc   C->setVarRefs(Vars);
1964*0a6a1f1dSLionel Sambuc }
1965*0a6a1f1dSLionel Sambuc 
VisitOMPFlushClause(OMPFlushClause * C)1966*0a6a1f1dSLionel Sambuc void OMPClauseReader::VisitOMPFlushClause(OMPFlushClause *C) {
1967*0a6a1f1dSLionel Sambuc   C->setLParenLoc(Reader->ReadSourceLocation(Record, Idx));
1968*0a6a1f1dSLionel Sambuc   unsigned NumVars = C->varlist_size();
1969*0a6a1f1dSLionel Sambuc   SmallVector<Expr *, 16> Vars;
1970*0a6a1f1dSLionel Sambuc   Vars.reserve(NumVars);
1971*0a6a1f1dSLionel Sambuc   for (unsigned i = 0; i != NumVars; ++i)
1972*0a6a1f1dSLionel Sambuc     Vars.push_back(Reader->Reader.ReadSubExpr());
1973*0a6a1f1dSLionel Sambuc   C->setVarRefs(Vars);
1974*0a6a1f1dSLionel Sambuc }
1975*0a6a1f1dSLionel Sambuc 
1976f4a2713aSLionel Sambuc //===----------------------------------------------------------------------===//
1977f4a2713aSLionel Sambuc // OpenMP Directives.
1978f4a2713aSLionel Sambuc //===----------------------------------------------------------------------===//
VisitOMPExecutableDirective(OMPExecutableDirective * E)1979f4a2713aSLionel Sambuc void ASTStmtReader::VisitOMPExecutableDirective(OMPExecutableDirective *E) {
1980f4a2713aSLionel Sambuc   E->setLocStart(ReadSourceLocation(Record, Idx));
1981f4a2713aSLionel Sambuc   E->setLocEnd(ReadSourceLocation(Record, Idx));
1982f4a2713aSLionel Sambuc   OMPClauseReader ClauseReader(this, Reader.getContext(), Record, Idx);
1983f4a2713aSLionel Sambuc   SmallVector<OMPClause *, 5> Clauses;
1984f4a2713aSLionel Sambuc   for (unsigned i = 0; i < E->getNumClauses(); ++i)
1985f4a2713aSLionel Sambuc     Clauses.push_back(ClauseReader.readClause());
1986f4a2713aSLionel Sambuc   E->setClauses(Clauses);
1987*0a6a1f1dSLionel Sambuc   if (E->hasAssociatedStmt())
1988f4a2713aSLionel Sambuc     E->setAssociatedStmt(Reader.ReadSubStmt());
1989f4a2713aSLionel Sambuc }
1990f4a2713aSLionel Sambuc 
VisitOMPLoopDirective(OMPLoopDirective * D)1991*0a6a1f1dSLionel Sambuc void ASTStmtReader::VisitOMPLoopDirective(OMPLoopDirective *D) {
1992*0a6a1f1dSLionel Sambuc   VisitStmt(D);
1993*0a6a1f1dSLionel Sambuc   // Two fields (NumClauses and CollapsedNum) were read in ReadStmtFromStream.
1994*0a6a1f1dSLionel Sambuc   Idx += 2;
1995*0a6a1f1dSLionel Sambuc   VisitOMPExecutableDirective(D);
1996*0a6a1f1dSLionel Sambuc   D->setIterationVariable(Reader.ReadSubExpr());
1997*0a6a1f1dSLionel Sambuc   D->setLastIteration(Reader.ReadSubExpr());
1998*0a6a1f1dSLionel Sambuc   D->setCalcLastIteration(Reader.ReadSubExpr());
1999*0a6a1f1dSLionel Sambuc   D->setPreCond(Reader.ReadSubExpr());
2000*0a6a1f1dSLionel Sambuc   auto Fst = Reader.ReadSubExpr();
2001*0a6a1f1dSLionel Sambuc   auto Snd = Reader.ReadSubExpr();
2002*0a6a1f1dSLionel Sambuc   D->setCond(Fst, Snd);
2003*0a6a1f1dSLionel Sambuc   D->setInit(Reader.ReadSubExpr());
2004*0a6a1f1dSLionel Sambuc   D->setInc(Reader.ReadSubExpr());
2005*0a6a1f1dSLionel Sambuc   if (isOpenMPWorksharingDirective(D->getDirectiveKind())) {
2006*0a6a1f1dSLionel Sambuc     D->setIsLastIterVariable(Reader.ReadSubExpr());
2007*0a6a1f1dSLionel Sambuc     D->setLowerBoundVariable(Reader.ReadSubExpr());
2008*0a6a1f1dSLionel Sambuc     D->setUpperBoundVariable(Reader.ReadSubExpr());
2009*0a6a1f1dSLionel Sambuc     D->setStrideVariable(Reader.ReadSubExpr());
2010*0a6a1f1dSLionel Sambuc     D->setEnsureUpperBound(Reader.ReadSubExpr());
2011*0a6a1f1dSLionel Sambuc     D->setNextLowerBound(Reader.ReadSubExpr());
2012*0a6a1f1dSLionel Sambuc     D->setNextUpperBound(Reader.ReadSubExpr());
2013*0a6a1f1dSLionel Sambuc   }
2014*0a6a1f1dSLionel Sambuc   SmallVector<Expr *, 4> Sub;
2015*0a6a1f1dSLionel Sambuc   unsigned CollapsedNum = D->getCollapsedNumber();
2016*0a6a1f1dSLionel Sambuc   Sub.reserve(CollapsedNum);
2017*0a6a1f1dSLionel Sambuc   for (unsigned i = 0; i < CollapsedNum; ++i)
2018*0a6a1f1dSLionel Sambuc     Sub.push_back(Reader.ReadSubExpr());
2019*0a6a1f1dSLionel Sambuc   D->setCounters(Sub);
2020*0a6a1f1dSLionel Sambuc   Sub.clear();
2021*0a6a1f1dSLionel Sambuc   for (unsigned i = 0; i < CollapsedNum; ++i)
2022*0a6a1f1dSLionel Sambuc     Sub.push_back(Reader.ReadSubExpr());
2023*0a6a1f1dSLionel Sambuc   D->setUpdates(Sub);
2024*0a6a1f1dSLionel Sambuc   Sub.clear();
2025*0a6a1f1dSLionel Sambuc   for (unsigned i = 0; i < CollapsedNum; ++i)
2026*0a6a1f1dSLionel Sambuc     Sub.push_back(Reader.ReadSubExpr());
2027*0a6a1f1dSLionel Sambuc   D->setFinals(Sub);
2028*0a6a1f1dSLionel Sambuc }
2029*0a6a1f1dSLionel Sambuc 
VisitOMPParallelDirective(OMPParallelDirective * D)2030f4a2713aSLionel Sambuc void ASTStmtReader::VisitOMPParallelDirective(OMPParallelDirective *D) {
2031*0a6a1f1dSLionel Sambuc   VisitStmt(D);
2032*0a6a1f1dSLionel Sambuc   // The NumClauses field was read in ReadStmtFromStream.
2033*0a6a1f1dSLionel Sambuc   ++Idx;
2034*0a6a1f1dSLionel Sambuc   VisitOMPExecutableDirective(D);
2035*0a6a1f1dSLionel Sambuc }
2036*0a6a1f1dSLionel Sambuc 
VisitOMPSimdDirective(OMPSimdDirective * D)2037*0a6a1f1dSLionel Sambuc void ASTStmtReader::VisitOMPSimdDirective(OMPSimdDirective *D) {
2038*0a6a1f1dSLionel Sambuc   VisitOMPLoopDirective(D);
2039*0a6a1f1dSLionel Sambuc }
2040*0a6a1f1dSLionel Sambuc 
VisitOMPForDirective(OMPForDirective * D)2041*0a6a1f1dSLionel Sambuc void ASTStmtReader::VisitOMPForDirective(OMPForDirective *D) {
2042*0a6a1f1dSLionel Sambuc   VisitOMPLoopDirective(D);
2043*0a6a1f1dSLionel Sambuc }
2044*0a6a1f1dSLionel Sambuc 
VisitOMPForSimdDirective(OMPForSimdDirective * D)2045*0a6a1f1dSLionel Sambuc void ASTStmtReader::VisitOMPForSimdDirective(OMPForSimdDirective *D) {
2046*0a6a1f1dSLionel Sambuc   VisitOMPLoopDirective(D);
2047*0a6a1f1dSLionel Sambuc }
2048*0a6a1f1dSLionel Sambuc 
VisitOMPSectionsDirective(OMPSectionsDirective * D)2049*0a6a1f1dSLionel Sambuc void ASTStmtReader::VisitOMPSectionsDirective(OMPSectionsDirective *D) {
2050*0a6a1f1dSLionel Sambuc   VisitStmt(D);
2051*0a6a1f1dSLionel Sambuc   // The NumClauses field was read in ReadStmtFromStream.
2052*0a6a1f1dSLionel Sambuc   ++Idx;
2053*0a6a1f1dSLionel Sambuc   VisitOMPExecutableDirective(D);
2054*0a6a1f1dSLionel Sambuc }
2055*0a6a1f1dSLionel Sambuc 
VisitOMPSectionDirective(OMPSectionDirective * D)2056*0a6a1f1dSLionel Sambuc void ASTStmtReader::VisitOMPSectionDirective(OMPSectionDirective *D) {
2057*0a6a1f1dSLionel Sambuc   VisitStmt(D);
2058*0a6a1f1dSLionel Sambuc   VisitOMPExecutableDirective(D);
2059*0a6a1f1dSLionel Sambuc }
2060*0a6a1f1dSLionel Sambuc 
VisitOMPSingleDirective(OMPSingleDirective * D)2061*0a6a1f1dSLionel Sambuc void ASTStmtReader::VisitOMPSingleDirective(OMPSingleDirective *D) {
2062*0a6a1f1dSLionel Sambuc   VisitStmt(D);
2063*0a6a1f1dSLionel Sambuc   // The NumClauses field was read in ReadStmtFromStream.
2064*0a6a1f1dSLionel Sambuc   ++Idx;
2065*0a6a1f1dSLionel Sambuc   VisitOMPExecutableDirective(D);
2066*0a6a1f1dSLionel Sambuc }
2067*0a6a1f1dSLionel Sambuc 
VisitOMPMasterDirective(OMPMasterDirective * D)2068*0a6a1f1dSLionel Sambuc void ASTStmtReader::VisitOMPMasterDirective(OMPMasterDirective *D) {
2069*0a6a1f1dSLionel Sambuc   VisitStmt(D);
2070*0a6a1f1dSLionel Sambuc   VisitOMPExecutableDirective(D);
2071*0a6a1f1dSLionel Sambuc }
2072*0a6a1f1dSLionel Sambuc 
VisitOMPCriticalDirective(OMPCriticalDirective * D)2073*0a6a1f1dSLionel Sambuc void ASTStmtReader::VisitOMPCriticalDirective(OMPCriticalDirective *D) {
2074*0a6a1f1dSLionel Sambuc   VisitStmt(D);
2075*0a6a1f1dSLionel Sambuc   VisitOMPExecutableDirective(D);
2076*0a6a1f1dSLionel Sambuc   ReadDeclarationNameInfo(D->DirName, Record, Idx);
2077*0a6a1f1dSLionel Sambuc }
2078*0a6a1f1dSLionel Sambuc 
VisitOMPParallelForDirective(OMPParallelForDirective * D)2079*0a6a1f1dSLionel Sambuc void ASTStmtReader::VisitOMPParallelForDirective(OMPParallelForDirective *D) {
2080*0a6a1f1dSLionel Sambuc   VisitOMPLoopDirective(D);
2081*0a6a1f1dSLionel Sambuc }
2082*0a6a1f1dSLionel Sambuc 
VisitOMPParallelForSimdDirective(OMPParallelForSimdDirective * D)2083*0a6a1f1dSLionel Sambuc void ASTStmtReader::VisitOMPParallelForSimdDirective(
2084*0a6a1f1dSLionel Sambuc     OMPParallelForSimdDirective *D) {
2085*0a6a1f1dSLionel Sambuc   VisitOMPLoopDirective(D);
2086*0a6a1f1dSLionel Sambuc }
2087*0a6a1f1dSLionel Sambuc 
VisitOMPParallelSectionsDirective(OMPParallelSectionsDirective * D)2088*0a6a1f1dSLionel Sambuc void ASTStmtReader::VisitOMPParallelSectionsDirective(
2089*0a6a1f1dSLionel Sambuc     OMPParallelSectionsDirective *D) {
2090*0a6a1f1dSLionel Sambuc   VisitStmt(D);
2091*0a6a1f1dSLionel Sambuc   // The NumClauses field was read in ReadStmtFromStream.
2092*0a6a1f1dSLionel Sambuc   ++Idx;
2093*0a6a1f1dSLionel Sambuc   VisitOMPExecutableDirective(D);
2094*0a6a1f1dSLionel Sambuc }
2095*0a6a1f1dSLionel Sambuc 
VisitOMPTaskDirective(OMPTaskDirective * D)2096*0a6a1f1dSLionel Sambuc void ASTStmtReader::VisitOMPTaskDirective(OMPTaskDirective *D) {
2097*0a6a1f1dSLionel Sambuc   VisitStmt(D);
2098*0a6a1f1dSLionel Sambuc   // The NumClauses field was read in ReadStmtFromStream.
2099*0a6a1f1dSLionel Sambuc   ++Idx;
2100*0a6a1f1dSLionel Sambuc   VisitOMPExecutableDirective(D);
2101*0a6a1f1dSLionel Sambuc }
2102*0a6a1f1dSLionel Sambuc 
VisitOMPTaskyieldDirective(OMPTaskyieldDirective * D)2103*0a6a1f1dSLionel Sambuc void ASTStmtReader::VisitOMPTaskyieldDirective(OMPTaskyieldDirective *D) {
2104*0a6a1f1dSLionel Sambuc   VisitStmt(D);
2105*0a6a1f1dSLionel Sambuc   VisitOMPExecutableDirective(D);
2106*0a6a1f1dSLionel Sambuc }
2107*0a6a1f1dSLionel Sambuc 
VisitOMPBarrierDirective(OMPBarrierDirective * D)2108*0a6a1f1dSLionel Sambuc void ASTStmtReader::VisitOMPBarrierDirective(OMPBarrierDirective *D) {
2109*0a6a1f1dSLionel Sambuc   VisitStmt(D);
2110*0a6a1f1dSLionel Sambuc   VisitOMPExecutableDirective(D);
2111*0a6a1f1dSLionel Sambuc }
2112*0a6a1f1dSLionel Sambuc 
VisitOMPTaskwaitDirective(OMPTaskwaitDirective * D)2113*0a6a1f1dSLionel Sambuc void ASTStmtReader::VisitOMPTaskwaitDirective(OMPTaskwaitDirective *D) {
2114*0a6a1f1dSLionel Sambuc   VisitStmt(D);
2115*0a6a1f1dSLionel Sambuc   VisitOMPExecutableDirective(D);
2116*0a6a1f1dSLionel Sambuc }
2117*0a6a1f1dSLionel Sambuc 
VisitOMPFlushDirective(OMPFlushDirective * D)2118*0a6a1f1dSLionel Sambuc void ASTStmtReader::VisitOMPFlushDirective(OMPFlushDirective *D) {
2119*0a6a1f1dSLionel Sambuc   VisitStmt(D);
2120*0a6a1f1dSLionel Sambuc   // The NumClauses field was read in ReadStmtFromStream.
2121*0a6a1f1dSLionel Sambuc   ++Idx;
2122*0a6a1f1dSLionel Sambuc   VisitOMPExecutableDirective(D);
2123*0a6a1f1dSLionel Sambuc }
2124*0a6a1f1dSLionel Sambuc 
VisitOMPOrderedDirective(OMPOrderedDirective * D)2125*0a6a1f1dSLionel Sambuc void ASTStmtReader::VisitOMPOrderedDirective(OMPOrderedDirective *D) {
2126*0a6a1f1dSLionel Sambuc   VisitStmt(D);
2127*0a6a1f1dSLionel Sambuc   VisitOMPExecutableDirective(D);
2128*0a6a1f1dSLionel Sambuc }
2129*0a6a1f1dSLionel Sambuc 
VisitOMPAtomicDirective(OMPAtomicDirective * D)2130*0a6a1f1dSLionel Sambuc void ASTStmtReader::VisitOMPAtomicDirective(OMPAtomicDirective *D) {
2131*0a6a1f1dSLionel Sambuc   VisitStmt(D);
2132*0a6a1f1dSLionel Sambuc   // The NumClauses field was read in ReadStmtFromStream.
2133*0a6a1f1dSLionel Sambuc   ++Idx;
2134*0a6a1f1dSLionel Sambuc   VisitOMPExecutableDirective(D);
2135*0a6a1f1dSLionel Sambuc   D->setX(Reader.ReadSubExpr());
2136*0a6a1f1dSLionel Sambuc   D->setV(Reader.ReadSubExpr());
2137*0a6a1f1dSLionel Sambuc   D->setExpr(Reader.ReadSubExpr());
2138*0a6a1f1dSLionel Sambuc }
2139*0a6a1f1dSLionel Sambuc 
VisitOMPTargetDirective(OMPTargetDirective * D)2140*0a6a1f1dSLionel Sambuc void ASTStmtReader::VisitOMPTargetDirective(OMPTargetDirective *D) {
2141*0a6a1f1dSLionel Sambuc   VisitStmt(D);
2142*0a6a1f1dSLionel Sambuc   // The NumClauses field was read in ReadStmtFromStream.
2143*0a6a1f1dSLionel Sambuc   ++Idx;
2144*0a6a1f1dSLionel Sambuc   VisitOMPExecutableDirective(D);
2145*0a6a1f1dSLionel Sambuc }
2146*0a6a1f1dSLionel Sambuc 
VisitOMPTeamsDirective(OMPTeamsDirective * D)2147*0a6a1f1dSLionel Sambuc void ASTStmtReader::VisitOMPTeamsDirective(OMPTeamsDirective *D) {
2148*0a6a1f1dSLionel Sambuc   VisitStmt(D);
2149*0a6a1f1dSLionel Sambuc   // The NumClauses field was read in ReadStmtFromStream.
2150*0a6a1f1dSLionel Sambuc   ++Idx;
2151f4a2713aSLionel Sambuc   VisitOMPExecutableDirective(D);
2152f4a2713aSLionel Sambuc }
2153f4a2713aSLionel Sambuc 
2154f4a2713aSLionel Sambuc //===----------------------------------------------------------------------===//
2155f4a2713aSLionel Sambuc // ASTReader Implementation
2156f4a2713aSLionel Sambuc //===----------------------------------------------------------------------===//
2157f4a2713aSLionel Sambuc 
ReadStmt(ModuleFile & F)2158f4a2713aSLionel Sambuc Stmt *ASTReader::ReadStmt(ModuleFile &F) {
2159f4a2713aSLionel Sambuc   switch (ReadingKind) {
2160f4a2713aSLionel Sambuc   case Read_None:
2161f4a2713aSLionel Sambuc     llvm_unreachable("should not call this when not reading anything");
2162f4a2713aSLionel Sambuc   case Read_Decl:
2163f4a2713aSLionel Sambuc   case Read_Type:
2164f4a2713aSLionel Sambuc     return ReadStmtFromStream(F);
2165f4a2713aSLionel Sambuc   case Read_Stmt:
2166f4a2713aSLionel Sambuc     return ReadSubStmt();
2167f4a2713aSLionel Sambuc   }
2168f4a2713aSLionel Sambuc 
2169f4a2713aSLionel Sambuc   llvm_unreachable("ReadingKind not set ?");
2170f4a2713aSLionel Sambuc }
2171f4a2713aSLionel Sambuc 
ReadExpr(ModuleFile & F)2172f4a2713aSLionel Sambuc Expr *ASTReader::ReadExpr(ModuleFile &F) {
2173f4a2713aSLionel Sambuc   return cast_or_null<Expr>(ReadStmt(F));
2174f4a2713aSLionel Sambuc }
2175f4a2713aSLionel Sambuc 
ReadSubExpr()2176f4a2713aSLionel Sambuc Expr *ASTReader::ReadSubExpr() {
2177f4a2713aSLionel Sambuc   return cast_or_null<Expr>(ReadSubStmt());
2178f4a2713aSLionel Sambuc }
2179f4a2713aSLionel Sambuc 
2180f4a2713aSLionel Sambuc // Within the bitstream, expressions are stored in Reverse Polish
2181f4a2713aSLionel Sambuc // Notation, with each of the subexpressions preceding the
2182f4a2713aSLionel Sambuc // expression they are stored in. Subexpressions are stored from last to first.
2183f4a2713aSLionel Sambuc // To evaluate expressions, we continue reading expressions and placing them on
2184f4a2713aSLionel Sambuc // the stack, with expressions having operands removing those operands from the
2185f4a2713aSLionel Sambuc // stack. Evaluation terminates when we see a STMT_STOP record, and
2186f4a2713aSLionel Sambuc // the single remaining expression on the stack is our result.
ReadStmtFromStream(ModuleFile & F)2187f4a2713aSLionel Sambuc Stmt *ASTReader::ReadStmtFromStream(ModuleFile &F) {
2188f4a2713aSLionel Sambuc 
2189f4a2713aSLionel Sambuc   ReadingKindTracker ReadingKind(Read_Stmt, *this);
2190f4a2713aSLionel Sambuc   llvm::BitstreamCursor &Cursor = F.DeclsCursor;
2191f4a2713aSLionel Sambuc 
2192f4a2713aSLionel Sambuc   // Map of offset to previously deserialized stmt. The offset points
2193f4a2713aSLionel Sambuc   /// just after the stmt record.
2194f4a2713aSLionel Sambuc   llvm::DenseMap<uint64_t, Stmt *> StmtEntries;
2195f4a2713aSLionel Sambuc 
2196f4a2713aSLionel Sambuc #ifndef NDEBUG
2197f4a2713aSLionel Sambuc   unsigned PrevNumStmts = StmtStack.size();
2198f4a2713aSLionel Sambuc #endif
2199f4a2713aSLionel Sambuc 
2200f4a2713aSLionel Sambuc   RecordData Record;
2201f4a2713aSLionel Sambuc   unsigned Idx;
2202f4a2713aSLionel Sambuc   ASTStmtReader Reader(*this, F, Cursor, Record, Idx);
2203f4a2713aSLionel Sambuc   Stmt::EmptyShell Empty;
2204f4a2713aSLionel Sambuc 
2205f4a2713aSLionel Sambuc   while (true) {
2206f4a2713aSLionel Sambuc     llvm::BitstreamEntry Entry = Cursor.advanceSkippingSubblocks();
2207f4a2713aSLionel Sambuc 
2208f4a2713aSLionel Sambuc     switch (Entry.Kind) {
2209f4a2713aSLionel Sambuc     case llvm::BitstreamEntry::SubBlock: // Handled for us already.
2210f4a2713aSLionel Sambuc     case llvm::BitstreamEntry::Error:
2211f4a2713aSLionel Sambuc       Error("malformed block record in AST file");
2212*0a6a1f1dSLionel Sambuc       return nullptr;
2213f4a2713aSLionel Sambuc     case llvm::BitstreamEntry::EndBlock:
2214f4a2713aSLionel Sambuc       goto Done;
2215f4a2713aSLionel Sambuc     case llvm::BitstreamEntry::Record:
2216f4a2713aSLionel Sambuc       // The interesting case.
2217f4a2713aSLionel Sambuc       break;
2218f4a2713aSLionel Sambuc     }
2219f4a2713aSLionel Sambuc 
2220*0a6a1f1dSLionel Sambuc     Stmt *S = nullptr;
2221f4a2713aSLionel Sambuc     Idx = 0;
2222f4a2713aSLionel Sambuc     Record.clear();
2223f4a2713aSLionel Sambuc     bool Finished = false;
2224f4a2713aSLionel Sambuc     bool IsStmtReference = false;
2225f4a2713aSLionel Sambuc     switch ((StmtCode)Cursor.readRecord(Entry.ID, Record)) {
2226f4a2713aSLionel Sambuc     case STMT_STOP:
2227f4a2713aSLionel Sambuc       Finished = true;
2228f4a2713aSLionel Sambuc       break;
2229f4a2713aSLionel Sambuc 
2230f4a2713aSLionel Sambuc     case STMT_REF_PTR:
2231f4a2713aSLionel Sambuc       IsStmtReference = true;
2232f4a2713aSLionel Sambuc       assert(StmtEntries.find(Record[0]) != StmtEntries.end() &&
2233f4a2713aSLionel Sambuc              "No stmt was recorded for this offset reference!");
2234f4a2713aSLionel Sambuc       S = StmtEntries[Record[Idx++]];
2235f4a2713aSLionel Sambuc       break;
2236f4a2713aSLionel Sambuc 
2237f4a2713aSLionel Sambuc     case STMT_NULL_PTR:
2238*0a6a1f1dSLionel Sambuc       S = nullptr;
2239f4a2713aSLionel Sambuc       break;
2240f4a2713aSLionel Sambuc 
2241f4a2713aSLionel Sambuc     case STMT_NULL:
2242f4a2713aSLionel Sambuc       S = new (Context) NullStmt(Empty);
2243f4a2713aSLionel Sambuc       break;
2244f4a2713aSLionel Sambuc 
2245f4a2713aSLionel Sambuc     case STMT_COMPOUND:
2246f4a2713aSLionel Sambuc       S = new (Context) CompoundStmt(Empty);
2247f4a2713aSLionel Sambuc       break;
2248f4a2713aSLionel Sambuc 
2249f4a2713aSLionel Sambuc     case STMT_CASE:
2250f4a2713aSLionel Sambuc       S = new (Context) CaseStmt(Empty);
2251f4a2713aSLionel Sambuc       break;
2252f4a2713aSLionel Sambuc 
2253f4a2713aSLionel Sambuc     case STMT_DEFAULT:
2254f4a2713aSLionel Sambuc       S = new (Context) DefaultStmt(Empty);
2255f4a2713aSLionel Sambuc       break;
2256f4a2713aSLionel Sambuc 
2257f4a2713aSLionel Sambuc     case STMT_LABEL:
2258f4a2713aSLionel Sambuc       S = new (Context) LabelStmt(Empty);
2259f4a2713aSLionel Sambuc       break;
2260f4a2713aSLionel Sambuc 
2261f4a2713aSLionel Sambuc     case STMT_ATTRIBUTED:
2262f4a2713aSLionel Sambuc       S = AttributedStmt::CreateEmpty(
2263f4a2713aSLionel Sambuc         Context,
2264f4a2713aSLionel Sambuc         /*NumAttrs*/Record[ASTStmtReader::NumStmtFields]);
2265f4a2713aSLionel Sambuc       break;
2266f4a2713aSLionel Sambuc 
2267f4a2713aSLionel Sambuc     case STMT_IF:
2268f4a2713aSLionel Sambuc       S = new (Context) IfStmt(Empty);
2269f4a2713aSLionel Sambuc       break;
2270f4a2713aSLionel Sambuc 
2271f4a2713aSLionel Sambuc     case STMT_SWITCH:
2272f4a2713aSLionel Sambuc       S = new (Context) SwitchStmt(Empty);
2273f4a2713aSLionel Sambuc       break;
2274f4a2713aSLionel Sambuc 
2275f4a2713aSLionel Sambuc     case STMT_WHILE:
2276f4a2713aSLionel Sambuc       S = new (Context) WhileStmt(Empty);
2277f4a2713aSLionel Sambuc       break;
2278f4a2713aSLionel Sambuc 
2279f4a2713aSLionel Sambuc     case STMT_DO:
2280f4a2713aSLionel Sambuc       S = new (Context) DoStmt(Empty);
2281f4a2713aSLionel Sambuc       break;
2282f4a2713aSLionel Sambuc 
2283f4a2713aSLionel Sambuc     case STMT_FOR:
2284f4a2713aSLionel Sambuc       S = new (Context) ForStmt(Empty);
2285f4a2713aSLionel Sambuc       break;
2286f4a2713aSLionel Sambuc 
2287f4a2713aSLionel Sambuc     case STMT_GOTO:
2288f4a2713aSLionel Sambuc       S = new (Context) GotoStmt(Empty);
2289f4a2713aSLionel Sambuc       break;
2290f4a2713aSLionel Sambuc 
2291f4a2713aSLionel Sambuc     case STMT_INDIRECT_GOTO:
2292f4a2713aSLionel Sambuc       S = new (Context) IndirectGotoStmt(Empty);
2293f4a2713aSLionel Sambuc       break;
2294f4a2713aSLionel Sambuc 
2295f4a2713aSLionel Sambuc     case STMT_CONTINUE:
2296f4a2713aSLionel Sambuc       S = new (Context) ContinueStmt(Empty);
2297f4a2713aSLionel Sambuc       break;
2298f4a2713aSLionel Sambuc 
2299f4a2713aSLionel Sambuc     case STMT_BREAK:
2300f4a2713aSLionel Sambuc       S = new (Context) BreakStmt(Empty);
2301f4a2713aSLionel Sambuc       break;
2302f4a2713aSLionel Sambuc 
2303f4a2713aSLionel Sambuc     case STMT_RETURN:
2304f4a2713aSLionel Sambuc       S = new (Context) ReturnStmt(Empty);
2305f4a2713aSLionel Sambuc       break;
2306f4a2713aSLionel Sambuc 
2307f4a2713aSLionel Sambuc     case STMT_DECL:
2308f4a2713aSLionel Sambuc       S = new (Context) DeclStmt(Empty);
2309f4a2713aSLionel Sambuc       break;
2310f4a2713aSLionel Sambuc 
2311f4a2713aSLionel Sambuc     case STMT_GCCASM:
2312f4a2713aSLionel Sambuc       S = new (Context) GCCAsmStmt(Empty);
2313f4a2713aSLionel Sambuc       break;
2314f4a2713aSLionel Sambuc 
2315f4a2713aSLionel Sambuc     case STMT_MSASM:
2316f4a2713aSLionel Sambuc       S = new (Context) MSAsmStmt(Empty);
2317f4a2713aSLionel Sambuc       break;
2318f4a2713aSLionel Sambuc 
2319f4a2713aSLionel Sambuc     case STMT_CAPTURED:
2320f4a2713aSLionel Sambuc       S = CapturedStmt::CreateDeserialized(Context,
2321f4a2713aSLionel Sambuc                                            Record[ASTStmtReader::NumStmtFields]);
2322f4a2713aSLionel Sambuc       break;
2323f4a2713aSLionel Sambuc 
2324f4a2713aSLionel Sambuc     case EXPR_PREDEFINED:
2325f4a2713aSLionel Sambuc       S = new (Context) PredefinedExpr(Empty);
2326f4a2713aSLionel Sambuc       break;
2327f4a2713aSLionel Sambuc 
2328f4a2713aSLionel Sambuc     case EXPR_DECL_REF:
2329f4a2713aSLionel Sambuc       S = DeclRefExpr::CreateEmpty(
2330f4a2713aSLionel Sambuc         Context,
2331f4a2713aSLionel Sambuc         /*HasQualifier=*/Record[ASTStmtReader::NumExprFields],
2332f4a2713aSLionel Sambuc         /*HasFoundDecl=*/Record[ASTStmtReader::NumExprFields + 1],
2333f4a2713aSLionel Sambuc         /*HasTemplateKWAndArgsInfo=*/Record[ASTStmtReader::NumExprFields + 2],
2334f4a2713aSLionel Sambuc         /*NumTemplateArgs=*/Record[ASTStmtReader::NumExprFields + 2] ?
2335f4a2713aSLionel Sambuc           Record[ASTStmtReader::NumExprFields + 5] : 0);
2336f4a2713aSLionel Sambuc       break;
2337f4a2713aSLionel Sambuc 
2338f4a2713aSLionel Sambuc     case EXPR_INTEGER_LITERAL:
2339f4a2713aSLionel Sambuc       S = IntegerLiteral::Create(Context, Empty);
2340f4a2713aSLionel Sambuc       break;
2341f4a2713aSLionel Sambuc 
2342f4a2713aSLionel Sambuc     case EXPR_FLOATING_LITERAL:
2343f4a2713aSLionel Sambuc       S = FloatingLiteral::Create(Context, Empty);
2344f4a2713aSLionel Sambuc       break;
2345f4a2713aSLionel Sambuc 
2346f4a2713aSLionel Sambuc     case EXPR_IMAGINARY_LITERAL:
2347f4a2713aSLionel Sambuc       S = new (Context) ImaginaryLiteral(Empty);
2348f4a2713aSLionel Sambuc       break;
2349f4a2713aSLionel Sambuc 
2350f4a2713aSLionel Sambuc     case EXPR_STRING_LITERAL:
2351f4a2713aSLionel Sambuc       S = StringLiteral::CreateEmpty(Context,
2352f4a2713aSLionel Sambuc                                      Record[ASTStmtReader::NumExprFields + 1]);
2353f4a2713aSLionel Sambuc       break;
2354f4a2713aSLionel Sambuc 
2355f4a2713aSLionel Sambuc     case EXPR_CHARACTER_LITERAL:
2356f4a2713aSLionel Sambuc       S = new (Context) CharacterLiteral(Empty);
2357f4a2713aSLionel Sambuc       break;
2358f4a2713aSLionel Sambuc 
2359f4a2713aSLionel Sambuc     case EXPR_PAREN:
2360f4a2713aSLionel Sambuc       S = new (Context) ParenExpr(Empty);
2361f4a2713aSLionel Sambuc       break;
2362f4a2713aSLionel Sambuc 
2363f4a2713aSLionel Sambuc     case EXPR_PAREN_LIST:
2364f4a2713aSLionel Sambuc       S = new (Context) ParenListExpr(Empty);
2365f4a2713aSLionel Sambuc       break;
2366f4a2713aSLionel Sambuc 
2367f4a2713aSLionel Sambuc     case EXPR_UNARY_OPERATOR:
2368f4a2713aSLionel Sambuc       S = new (Context) UnaryOperator(Empty);
2369f4a2713aSLionel Sambuc       break;
2370f4a2713aSLionel Sambuc 
2371f4a2713aSLionel Sambuc     case EXPR_OFFSETOF:
2372f4a2713aSLionel Sambuc       S = OffsetOfExpr::CreateEmpty(Context,
2373f4a2713aSLionel Sambuc                                     Record[ASTStmtReader::NumExprFields],
2374f4a2713aSLionel Sambuc                                     Record[ASTStmtReader::NumExprFields + 1]);
2375f4a2713aSLionel Sambuc       break;
2376f4a2713aSLionel Sambuc 
2377f4a2713aSLionel Sambuc     case EXPR_SIZEOF_ALIGN_OF:
2378f4a2713aSLionel Sambuc       S = new (Context) UnaryExprOrTypeTraitExpr(Empty);
2379f4a2713aSLionel Sambuc       break;
2380f4a2713aSLionel Sambuc 
2381f4a2713aSLionel Sambuc     case EXPR_ARRAY_SUBSCRIPT:
2382f4a2713aSLionel Sambuc       S = new (Context) ArraySubscriptExpr(Empty);
2383f4a2713aSLionel Sambuc       break;
2384f4a2713aSLionel Sambuc 
2385f4a2713aSLionel Sambuc     case EXPR_CALL:
2386f4a2713aSLionel Sambuc       S = new (Context) CallExpr(Context, Stmt::CallExprClass, Empty);
2387f4a2713aSLionel Sambuc       break;
2388f4a2713aSLionel Sambuc 
2389f4a2713aSLionel Sambuc     case EXPR_MEMBER: {
2390f4a2713aSLionel Sambuc       // We load everything here and fully initialize it at creation.
2391f4a2713aSLionel Sambuc       // That way we can use MemberExpr::Create and don't have to duplicate its
2392f4a2713aSLionel Sambuc       // logic with a MemberExpr::CreateEmpty.
2393f4a2713aSLionel Sambuc 
2394f4a2713aSLionel Sambuc       assert(Idx == 0);
2395f4a2713aSLionel Sambuc       NestedNameSpecifierLoc QualifierLoc;
2396f4a2713aSLionel Sambuc       if (Record[Idx++]) { // HasQualifier.
2397f4a2713aSLionel Sambuc         QualifierLoc = ReadNestedNameSpecifierLoc(F, Record, Idx);
2398f4a2713aSLionel Sambuc       }
2399f4a2713aSLionel Sambuc 
2400f4a2713aSLionel Sambuc       SourceLocation TemplateKWLoc;
2401f4a2713aSLionel Sambuc       TemplateArgumentListInfo ArgInfo;
2402f4a2713aSLionel Sambuc       bool HasTemplateKWAndArgsInfo = Record[Idx++];
2403f4a2713aSLionel Sambuc       if (HasTemplateKWAndArgsInfo) {
2404f4a2713aSLionel Sambuc         TemplateKWLoc = ReadSourceLocation(F, Record, Idx);
2405f4a2713aSLionel Sambuc         unsigned NumTemplateArgs = Record[Idx++];
2406f4a2713aSLionel Sambuc         ArgInfo.setLAngleLoc(ReadSourceLocation(F, Record, Idx));
2407f4a2713aSLionel Sambuc         ArgInfo.setRAngleLoc(ReadSourceLocation(F, Record, Idx));
2408f4a2713aSLionel Sambuc         for (unsigned i = 0; i != NumTemplateArgs; ++i)
2409f4a2713aSLionel Sambuc           ArgInfo.addArgument(ReadTemplateArgumentLoc(F, Record, Idx));
2410f4a2713aSLionel Sambuc       }
2411f4a2713aSLionel Sambuc 
2412f4a2713aSLionel Sambuc       bool HadMultipleCandidates = Record[Idx++];
2413f4a2713aSLionel Sambuc 
2414f4a2713aSLionel Sambuc       NamedDecl *FoundD = ReadDeclAs<NamedDecl>(F, Record, Idx);
2415f4a2713aSLionel Sambuc       AccessSpecifier AS = (AccessSpecifier)Record[Idx++];
2416f4a2713aSLionel Sambuc       DeclAccessPair FoundDecl = DeclAccessPair::make(FoundD, AS);
2417f4a2713aSLionel Sambuc 
2418f4a2713aSLionel Sambuc       QualType T = readType(F, Record, Idx);
2419f4a2713aSLionel Sambuc       ExprValueKind VK = static_cast<ExprValueKind>(Record[Idx++]);
2420f4a2713aSLionel Sambuc       ExprObjectKind OK = static_cast<ExprObjectKind>(Record[Idx++]);
2421f4a2713aSLionel Sambuc       Expr *Base = ReadSubExpr();
2422f4a2713aSLionel Sambuc       ValueDecl *MemberD = ReadDeclAs<ValueDecl>(F, Record, Idx);
2423f4a2713aSLionel Sambuc       SourceLocation MemberLoc = ReadSourceLocation(F, Record, Idx);
2424f4a2713aSLionel Sambuc       DeclarationNameInfo MemberNameInfo(MemberD->getDeclName(), MemberLoc);
2425f4a2713aSLionel Sambuc       bool IsArrow = Record[Idx++];
2426f4a2713aSLionel Sambuc 
2427f4a2713aSLionel Sambuc       S = MemberExpr::Create(Context, Base, IsArrow, QualifierLoc,
2428f4a2713aSLionel Sambuc                              TemplateKWLoc, MemberD, FoundDecl, MemberNameInfo,
2429*0a6a1f1dSLionel Sambuc                              HasTemplateKWAndArgsInfo ? &ArgInfo : nullptr,
2430f4a2713aSLionel Sambuc                              T, VK, OK);
2431f4a2713aSLionel Sambuc       ReadDeclarationNameLoc(F, cast<MemberExpr>(S)->MemberDNLoc,
2432f4a2713aSLionel Sambuc                              MemberD->getDeclName(), Record, Idx);
2433f4a2713aSLionel Sambuc       if (HadMultipleCandidates)
2434f4a2713aSLionel Sambuc         cast<MemberExpr>(S)->setHadMultipleCandidates(true);
2435f4a2713aSLionel Sambuc       break;
2436f4a2713aSLionel Sambuc     }
2437f4a2713aSLionel Sambuc 
2438f4a2713aSLionel Sambuc     case EXPR_BINARY_OPERATOR:
2439f4a2713aSLionel Sambuc       S = new (Context) BinaryOperator(Empty);
2440f4a2713aSLionel Sambuc       break;
2441f4a2713aSLionel Sambuc 
2442f4a2713aSLionel Sambuc     case EXPR_COMPOUND_ASSIGN_OPERATOR:
2443f4a2713aSLionel Sambuc       S = new (Context) CompoundAssignOperator(Empty);
2444f4a2713aSLionel Sambuc       break;
2445f4a2713aSLionel Sambuc 
2446f4a2713aSLionel Sambuc     case EXPR_CONDITIONAL_OPERATOR:
2447f4a2713aSLionel Sambuc       S = new (Context) ConditionalOperator(Empty);
2448f4a2713aSLionel Sambuc       break;
2449f4a2713aSLionel Sambuc 
2450f4a2713aSLionel Sambuc     case EXPR_BINARY_CONDITIONAL_OPERATOR:
2451f4a2713aSLionel Sambuc       S = new (Context) BinaryConditionalOperator(Empty);
2452f4a2713aSLionel Sambuc       break;
2453f4a2713aSLionel Sambuc 
2454f4a2713aSLionel Sambuc     case EXPR_IMPLICIT_CAST:
2455f4a2713aSLionel Sambuc       S = ImplicitCastExpr::CreateEmpty(Context,
2456f4a2713aSLionel Sambuc                        /*PathSize*/ Record[ASTStmtReader::NumExprFields]);
2457f4a2713aSLionel Sambuc       break;
2458f4a2713aSLionel Sambuc 
2459f4a2713aSLionel Sambuc     case EXPR_CSTYLE_CAST:
2460f4a2713aSLionel Sambuc       S = CStyleCastExpr::CreateEmpty(Context,
2461f4a2713aSLionel Sambuc                        /*PathSize*/ Record[ASTStmtReader::NumExprFields]);
2462f4a2713aSLionel Sambuc       break;
2463f4a2713aSLionel Sambuc 
2464f4a2713aSLionel Sambuc     case EXPR_COMPOUND_LITERAL:
2465f4a2713aSLionel Sambuc       S = new (Context) CompoundLiteralExpr(Empty);
2466f4a2713aSLionel Sambuc       break;
2467f4a2713aSLionel Sambuc 
2468f4a2713aSLionel Sambuc     case EXPR_EXT_VECTOR_ELEMENT:
2469f4a2713aSLionel Sambuc       S = new (Context) ExtVectorElementExpr(Empty);
2470f4a2713aSLionel Sambuc       break;
2471f4a2713aSLionel Sambuc 
2472f4a2713aSLionel Sambuc     case EXPR_INIT_LIST:
2473f4a2713aSLionel Sambuc       S = new (Context) InitListExpr(Empty);
2474f4a2713aSLionel Sambuc       break;
2475f4a2713aSLionel Sambuc 
2476f4a2713aSLionel Sambuc     case EXPR_DESIGNATED_INIT:
2477f4a2713aSLionel Sambuc       S = DesignatedInitExpr::CreateEmpty(Context,
2478f4a2713aSLionel Sambuc                                      Record[ASTStmtReader::NumExprFields] - 1);
2479f4a2713aSLionel Sambuc 
2480f4a2713aSLionel Sambuc       break;
2481f4a2713aSLionel Sambuc 
2482f4a2713aSLionel Sambuc     case EXPR_IMPLICIT_VALUE_INIT:
2483f4a2713aSLionel Sambuc       S = new (Context) ImplicitValueInitExpr(Empty);
2484f4a2713aSLionel Sambuc       break;
2485f4a2713aSLionel Sambuc 
2486f4a2713aSLionel Sambuc     case EXPR_VA_ARG:
2487f4a2713aSLionel Sambuc       S = new (Context) VAArgExpr(Empty);
2488f4a2713aSLionel Sambuc       break;
2489f4a2713aSLionel Sambuc 
2490f4a2713aSLionel Sambuc     case EXPR_ADDR_LABEL:
2491f4a2713aSLionel Sambuc       S = new (Context) AddrLabelExpr(Empty);
2492f4a2713aSLionel Sambuc       break;
2493f4a2713aSLionel Sambuc 
2494f4a2713aSLionel Sambuc     case EXPR_STMT:
2495f4a2713aSLionel Sambuc       S = new (Context) StmtExpr(Empty);
2496f4a2713aSLionel Sambuc       break;
2497f4a2713aSLionel Sambuc 
2498f4a2713aSLionel Sambuc     case EXPR_CHOOSE:
2499f4a2713aSLionel Sambuc       S = new (Context) ChooseExpr(Empty);
2500f4a2713aSLionel Sambuc       break;
2501f4a2713aSLionel Sambuc 
2502f4a2713aSLionel Sambuc     case EXPR_GNU_NULL:
2503f4a2713aSLionel Sambuc       S = new (Context) GNUNullExpr(Empty);
2504f4a2713aSLionel Sambuc       break;
2505f4a2713aSLionel Sambuc 
2506f4a2713aSLionel Sambuc     case EXPR_SHUFFLE_VECTOR:
2507f4a2713aSLionel Sambuc       S = new (Context) ShuffleVectorExpr(Empty);
2508f4a2713aSLionel Sambuc       break;
2509f4a2713aSLionel Sambuc 
2510f4a2713aSLionel Sambuc     case EXPR_CONVERT_VECTOR:
2511f4a2713aSLionel Sambuc       S = new (Context) ConvertVectorExpr(Empty);
2512f4a2713aSLionel Sambuc       break;
2513f4a2713aSLionel Sambuc 
2514f4a2713aSLionel Sambuc     case EXPR_BLOCK:
2515f4a2713aSLionel Sambuc       S = new (Context) BlockExpr(Empty);
2516f4a2713aSLionel Sambuc       break;
2517f4a2713aSLionel Sambuc 
2518f4a2713aSLionel Sambuc     case EXPR_GENERIC_SELECTION:
2519f4a2713aSLionel Sambuc       S = new (Context) GenericSelectionExpr(Empty);
2520f4a2713aSLionel Sambuc       break;
2521f4a2713aSLionel Sambuc 
2522f4a2713aSLionel Sambuc     case EXPR_OBJC_STRING_LITERAL:
2523f4a2713aSLionel Sambuc       S = new (Context) ObjCStringLiteral(Empty);
2524f4a2713aSLionel Sambuc       break;
2525f4a2713aSLionel Sambuc     case EXPR_OBJC_BOXED_EXPRESSION:
2526f4a2713aSLionel Sambuc       S = new (Context) ObjCBoxedExpr(Empty);
2527f4a2713aSLionel Sambuc       break;
2528f4a2713aSLionel Sambuc     case EXPR_OBJC_ARRAY_LITERAL:
2529f4a2713aSLionel Sambuc       S = ObjCArrayLiteral::CreateEmpty(Context,
2530f4a2713aSLionel Sambuc                                         Record[ASTStmtReader::NumExprFields]);
2531f4a2713aSLionel Sambuc       break;
2532f4a2713aSLionel Sambuc     case EXPR_OBJC_DICTIONARY_LITERAL:
2533f4a2713aSLionel Sambuc       S = ObjCDictionaryLiteral::CreateEmpty(Context,
2534f4a2713aSLionel Sambuc             Record[ASTStmtReader::NumExprFields],
2535f4a2713aSLionel Sambuc             Record[ASTStmtReader::NumExprFields + 1]);
2536f4a2713aSLionel Sambuc       break;
2537f4a2713aSLionel Sambuc     case EXPR_OBJC_ENCODE:
2538f4a2713aSLionel Sambuc       S = new (Context) ObjCEncodeExpr(Empty);
2539f4a2713aSLionel Sambuc       break;
2540f4a2713aSLionel Sambuc     case EXPR_OBJC_SELECTOR_EXPR:
2541f4a2713aSLionel Sambuc       S = new (Context) ObjCSelectorExpr(Empty);
2542f4a2713aSLionel Sambuc       break;
2543f4a2713aSLionel Sambuc     case EXPR_OBJC_PROTOCOL_EXPR:
2544f4a2713aSLionel Sambuc       S = new (Context) ObjCProtocolExpr(Empty);
2545f4a2713aSLionel Sambuc       break;
2546f4a2713aSLionel Sambuc     case EXPR_OBJC_IVAR_REF_EXPR:
2547f4a2713aSLionel Sambuc       S = new (Context) ObjCIvarRefExpr(Empty);
2548f4a2713aSLionel Sambuc       break;
2549f4a2713aSLionel Sambuc     case EXPR_OBJC_PROPERTY_REF_EXPR:
2550f4a2713aSLionel Sambuc       S = new (Context) ObjCPropertyRefExpr(Empty);
2551f4a2713aSLionel Sambuc       break;
2552f4a2713aSLionel Sambuc     case EXPR_OBJC_SUBSCRIPT_REF_EXPR:
2553f4a2713aSLionel Sambuc       S = new (Context) ObjCSubscriptRefExpr(Empty);
2554f4a2713aSLionel Sambuc       break;
2555f4a2713aSLionel Sambuc     case EXPR_OBJC_KVC_REF_EXPR:
2556f4a2713aSLionel Sambuc       llvm_unreachable("mismatching AST file");
2557f4a2713aSLionel Sambuc     case EXPR_OBJC_MESSAGE_EXPR:
2558f4a2713aSLionel Sambuc       S = ObjCMessageExpr::CreateEmpty(Context,
2559f4a2713aSLionel Sambuc                                      Record[ASTStmtReader::NumExprFields],
2560f4a2713aSLionel Sambuc                                      Record[ASTStmtReader::NumExprFields + 1]);
2561f4a2713aSLionel Sambuc       break;
2562f4a2713aSLionel Sambuc     case EXPR_OBJC_ISA:
2563f4a2713aSLionel Sambuc       S = new (Context) ObjCIsaExpr(Empty);
2564f4a2713aSLionel Sambuc       break;
2565f4a2713aSLionel Sambuc     case EXPR_OBJC_INDIRECT_COPY_RESTORE:
2566f4a2713aSLionel Sambuc       S = new (Context) ObjCIndirectCopyRestoreExpr(Empty);
2567f4a2713aSLionel Sambuc       break;
2568f4a2713aSLionel Sambuc     case EXPR_OBJC_BRIDGED_CAST:
2569f4a2713aSLionel Sambuc       S = new (Context) ObjCBridgedCastExpr(Empty);
2570f4a2713aSLionel Sambuc       break;
2571f4a2713aSLionel Sambuc     case STMT_OBJC_FOR_COLLECTION:
2572f4a2713aSLionel Sambuc       S = new (Context) ObjCForCollectionStmt(Empty);
2573f4a2713aSLionel Sambuc       break;
2574f4a2713aSLionel Sambuc     case STMT_OBJC_CATCH:
2575f4a2713aSLionel Sambuc       S = new (Context) ObjCAtCatchStmt(Empty);
2576f4a2713aSLionel Sambuc       break;
2577f4a2713aSLionel Sambuc     case STMT_OBJC_FINALLY:
2578f4a2713aSLionel Sambuc       S = new (Context) ObjCAtFinallyStmt(Empty);
2579f4a2713aSLionel Sambuc       break;
2580f4a2713aSLionel Sambuc     case STMT_OBJC_AT_TRY:
2581f4a2713aSLionel Sambuc       S = ObjCAtTryStmt::CreateEmpty(Context,
2582f4a2713aSLionel Sambuc                                      Record[ASTStmtReader::NumStmtFields],
2583f4a2713aSLionel Sambuc                                      Record[ASTStmtReader::NumStmtFields + 1]);
2584f4a2713aSLionel Sambuc       break;
2585f4a2713aSLionel Sambuc     case STMT_OBJC_AT_SYNCHRONIZED:
2586f4a2713aSLionel Sambuc       S = new (Context) ObjCAtSynchronizedStmt(Empty);
2587f4a2713aSLionel Sambuc       break;
2588f4a2713aSLionel Sambuc     case STMT_OBJC_AT_THROW:
2589f4a2713aSLionel Sambuc       S = new (Context) ObjCAtThrowStmt(Empty);
2590f4a2713aSLionel Sambuc       break;
2591f4a2713aSLionel Sambuc     case STMT_OBJC_AUTORELEASE_POOL:
2592f4a2713aSLionel Sambuc       S = new (Context) ObjCAutoreleasePoolStmt(Empty);
2593f4a2713aSLionel Sambuc       break;
2594f4a2713aSLionel Sambuc     case EXPR_OBJC_BOOL_LITERAL:
2595f4a2713aSLionel Sambuc       S = new (Context) ObjCBoolLiteralExpr(Empty);
2596f4a2713aSLionel Sambuc       break;
2597*0a6a1f1dSLionel Sambuc     case STMT_SEH_LEAVE:
2598*0a6a1f1dSLionel Sambuc       S = new (Context) SEHLeaveStmt(Empty);
2599*0a6a1f1dSLionel Sambuc       break;
2600f4a2713aSLionel Sambuc     case STMT_SEH_EXCEPT:
2601f4a2713aSLionel Sambuc       S = new (Context) SEHExceptStmt(Empty);
2602f4a2713aSLionel Sambuc       break;
2603f4a2713aSLionel Sambuc     case STMT_SEH_FINALLY:
2604f4a2713aSLionel Sambuc       S = new (Context) SEHFinallyStmt(Empty);
2605f4a2713aSLionel Sambuc       break;
2606f4a2713aSLionel Sambuc     case STMT_SEH_TRY:
2607f4a2713aSLionel Sambuc       S = new (Context) SEHTryStmt(Empty);
2608f4a2713aSLionel Sambuc       break;
2609f4a2713aSLionel Sambuc     case STMT_CXX_CATCH:
2610f4a2713aSLionel Sambuc       S = new (Context) CXXCatchStmt(Empty);
2611f4a2713aSLionel Sambuc       break;
2612f4a2713aSLionel Sambuc 
2613f4a2713aSLionel Sambuc     case STMT_CXX_TRY:
2614f4a2713aSLionel Sambuc       S = CXXTryStmt::Create(Context, Empty,
2615f4a2713aSLionel Sambuc              /*NumHandlers=*/Record[ASTStmtReader::NumStmtFields]);
2616f4a2713aSLionel Sambuc       break;
2617f4a2713aSLionel Sambuc 
2618f4a2713aSLionel Sambuc     case STMT_CXX_FOR_RANGE:
2619f4a2713aSLionel Sambuc       S = new (Context) CXXForRangeStmt(Empty);
2620f4a2713aSLionel Sambuc       break;
2621f4a2713aSLionel Sambuc 
2622f4a2713aSLionel Sambuc     case STMT_MS_DEPENDENT_EXISTS:
2623f4a2713aSLionel Sambuc       S = new (Context) MSDependentExistsStmt(SourceLocation(), true,
2624f4a2713aSLionel Sambuc                                               NestedNameSpecifierLoc(),
2625f4a2713aSLionel Sambuc                                               DeclarationNameInfo(),
2626*0a6a1f1dSLionel Sambuc                                               nullptr);
2627f4a2713aSLionel Sambuc       break;
2628*0a6a1f1dSLionel Sambuc 
2629f4a2713aSLionel Sambuc     case STMT_OMP_PARALLEL_DIRECTIVE:
2630f4a2713aSLionel Sambuc       S =
2631f4a2713aSLionel Sambuc         OMPParallelDirective::CreateEmpty(Context,
2632f4a2713aSLionel Sambuc                                           Record[ASTStmtReader::NumStmtFields],
2633f4a2713aSLionel Sambuc                                           Empty);
2634f4a2713aSLionel Sambuc       break;
2635f4a2713aSLionel Sambuc 
2636*0a6a1f1dSLionel Sambuc     case STMT_OMP_SIMD_DIRECTIVE: {
2637*0a6a1f1dSLionel Sambuc       unsigned NumClauses = Record[ASTStmtReader::NumStmtFields];
2638*0a6a1f1dSLionel Sambuc       unsigned CollapsedNum = Record[ASTStmtReader::NumStmtFields + 1];
2639*0a6a1f1dSLionel Sambuc       S = OMPSimdDirective::CreateEmpty(Context, NumClauses,
2640*0a6a1f1dSLionel Sambuc                                         CollapsedNum, Empty);
2641*0a6a1f1dSLionel Sambuc       break;
2642*0a6a1f1dSLionel Sambuc     }
2643*0a6a1f1dSLionel Sambuc 
2644*0a6a1f1dSLionel Sambuc     case STMT_OMP_FOR_DIRECTIVE: {
2645*0a6a1f1dSLionel Sambuc       unsigned NumClauses = Record[ASTStmtReader::NumStmtFields];
2646*0a6a1f1dSLionel Sambuc       unsigned CollapsedNum = Record[ASTStmtReader::NumStmtFields + 1];
2647*0a6a1f1dSLionel Sambuc       S = OMPForDirective::CreateEmpty(Context, NumClauses, CollapsedNum,
2648*0a6a1f1dSLionel Sambuc                                        Empty);
2649*0a6a1f1dSLionel Sambuc       break;
2650*0a6a1f1dSLionel Sambuc     }
2651*0a6a1f1dSLionel Sambuc 
2652*0a6a1f1dSLionel Sambuc     case STMT_OMP_FOR_SIMD_DIRECTIVE: {
2653*0a6a1f1dSLionel Sambuc       unsigned NumClauses = Record[ASTStmtReader::NumStmtFields];
2654*0a6a1f1dSLionel Sambuc       unsigned CollapsedNum = Record[ASTStmtReader::NumStmtFields + 1];
2655*0a6a1f1dSLionel Sambuc       S = OMPForSimdDirective::CreateEmpty(Context, NumClauses, CollapsedNum,
2656*0a6a1f1dSLionel Sambuc                                            Empty);
2657*0a6a1f1dSLionel Sambuc       break;
2658*0a6a1f1dSLionel Sambuc     }
2659*0a6a1f1dSLionel Sambuc 
2660*0a6a1f1dSLionel Sambuc     case STMT_OMP_SECTIONS_DIRECTIVE:
2661*0a6a1f1dSLionel Sambuc       S = OMPSectionsDirective::CreateEmpty(
2662*0a6a1f1dSLionel Sambuc           Context, Record[ASTStmtReader::NumStmtFields], Empty);
2663*0a6a1f1dSLionel Sambuc       break;
2664*0a6a1f1dSLionel Sambuc 
2665*0a6a1f1dSLionel Sambuc     case STMT_OMP_SECTION_DIRECTIVE:
2666*0a6a1f1dSLionel Sambuc       S = OMPSectionDirective::CreateEmpty(Context, Empty);
2667*0a6a1f1dSLionel Sambuc       break;
2668*0a6a1f1dSLionel Sambuc 
2669*0a6a1f1dSLionel Sambuc     case STMT_OMP_SINGLE_DIRECTIVE:
2670*0a6a1f1dSLionel Sambuc       S = OMPSingleDirective::CreateEmpty(
2671*0a6a1f1dSLionel Sambuc           Context, Record[ASTStmtReader::NumStmtFields], Empty);
2672*0a6a1f1dSLionel Sambuc       break;
2673*0a6a1f1dSLionel Sambuc 
2674*0a6a1f1dSLionel Sambuc     case STMT_OMP_MASTER_DIRECTIVE:
2675*0a6a1f1dSLionel Sambuc       S = OMPMasterDirective::CreateEmpty(Context, Empty);
2676*0a6a1f1dSLionel Sambuc       break;
2677*0a6a1f1dSLionel Sambuc 
2678*0a6a1f1dSLionel Sambuc     case STMT_OMP_CRITICAL_DIRECTIVE:
2679*0a6a1f1dSLionel Sambuc       S = OMPCriticalDirective::CreateEmpty(Context, Empty);
2680*0a6a1f1dSLionel Sambuc       break;
2681*0a6a1f1dSLionel Sambuc 
2682*0a6a1f1dSLionel Sambuc     case STMT_OMP_PARALLEL_FOR_DIRECTIVE: {
2683*0a6a1f1dSLionel Sambuc       unsigned NumClauses = Record[ASTStmtReader::NumStmtFields];
2684*0a6a1f1dSLionel Sambuc       unsigned CollapsedNum = Record[ASTStmtReader::NumStmtFields + 1];
2685*0a6a1f1dSLionel Sambuc       S = OMPParallelForDirective::CreateEmpty(Context, NumClauses,
2686*0a6a1f1dSLionel Sambuc                                                CollapsedNum, Empty);
2687*0a6a1f1dSLionel Sambuc       break;
2688*0a6a1f1dSLionel Sambuc     }
2689*0a6a1f1dSLionel Sambuc 
2690*0a6a1f1dSLionel Sambuc     case STMT_OMP_PARALLEL_FOR_SIMD_DIRECTIVE: {
2691*0a6a1f1dSLionel Sambuc       unsigned NumClauses = Record[ASTStmtReader::NumStmtFields];
2692*0a6a1f1dSLionel Sambuc       unsigned CollapsedNum = Record[ASTStmtReader::NumStmtFields + 1];
2693*0a6a1f1dSLionel Sambuc       S = OMPParallelForSimdDirective::CreateEmpty(Context, NumClauses,
2694*0a6a1f1dSLionel Sambuc                                                    CollapsedNum, Empty);
2695*0a6a1f1dSLionel Sambuc       break;
2696*0a6a1f1dSLionel Sambuc     }
2697*0a6a1f1dSLionel Sambuc 
2698*0a6a1f1dSLionel Sambuc     case STMT_OMP_PARALLEL_SECTIONS_DIRECTIVE:
2699*0a6a1f1dSLionel Sambuc       S = OMPParallelSectionsDirective::CreateEmpty(
2700*0a6a1f1dSLionel Sambuc           Context, Record[ASTStmtReader::NumStmtFields], Empty);
2701*0a6a1f1dSLionel Sambuc       break;
2702*0a6a1f1dSLionel Sambuc 
2703*0a6a1f1dSLionel Sambuc     case STMT_OMP_TASK_DIRECTIVE:
2704*0a6a1f1dSLionel Sambuc       S = OMPTaskDirective::CreateEmpty(
2705*0a6a1f1dSLionel Sambuc           Context, Record[ASTStmtReader::NumStmtFields], Empty);
2706*0a6a1f1dSLionel Sambuc       break;
2707*0a6a1f1dSLionel Sambuc 
2708*0a6a1f1dSLionel Sambuc     case STMT_OMP_TASKYIELD_DIRECTIVE:
2709*0a6a1f1dSLionel Sambuc       S = OMPTaskyieldDirective::CreateEmpty(Context, Empty);
2710*0a6a1f1dSLionel Sambuc       break;
2711*0a6a1f1dSLionel Sambuc 
2712*0a6a1f1dSLionel Sambuc     case STMT_OMP_BARRIER_DIRECTIVE:
2713*0a6a1f1dSLionel Sambuc       S = OMPBarrierDirective::CreateEmpty(Context, Empty);
2714*0a6a1f1dSLionel Sambuc       break;
2715*0a6a1f1dSLionel Sambuc 
2716*0a6a1f1dSLionel Sambuc     case STMT_OMP_TASKWAIT_DIRECTIVE:
2717*0a6a1f1dSLionel Sambuc       S = OMPTaskwaitDirective::CreateEmpty(Context, Empty);
2718*0a6a1f1dSLionel Sambuc       break;
2719*0a6a1f1dSLionel Sambuc 
2720*0a6a1f1dSLionel Sambuc     case STMT_OMP_FLUSH_DIRECTIVE:
2721*0a6a1f1dSLionel Sambuc       S = OMPFlushDirective::CreateEmpty(
2722*0a6a1f1dSLionel Sambuc           Context, Record[ASTStmtReader::NumStmtFields], Empty);
2723*0a6a1f1dSLionel Sambuc       break;
2724*0a6a1f1dSLionel Sambuc 
2725*0a6a1f1dSLionel Sambuc     case STMT_OMP_ORDERED_DIRECTIVE:
2726*0a6a1f1dSLionel Sambuc       S = OMPOrderedDirective::CreateEmpty(Context, Empty);
2727*0a6a1f1dSLionel Sambuc       break;
2728*0a6a1f1dSLionel Sambuc 
2729*0a6a1f1dSLionel Sambuc     case STMT_OMP_ATOMIC_DIRECTIVE:
2730*0a6a1f1dSLionel Sambuc       S = OMPAtomicDirective::CreateEmpty(
2731*0a6a1f1dSLionel Sambuc           Context, Record[ASTStmtReader::NumStmtFields], Empty);
2732*0a6a1f1dSLionel Sambuc       break;
2733*0a6a1f1dSLionel Sambuc 
2734*0a6a1f1dSLionel Sambuc     case STMT_OMP_TARGET_DIRECTIVE:
2735*0a6a1f1dSLionel Sambuc       S = OMPTargetDirective::CreateEmpty(
2736*0a6a1f1dSLionel Sambuc           Context, Record[ASTStmtReader::NumStmtFields], Empty);
2737*0a6a1f1dSLionel Sambuc       break;
2738*0a6a1f1dSLionel Sambuc 
2739*0a6a1f1dSLionel Sambuc     case STMT_OMP_TEAMS_DIRECTIVE:
2740*0a6a1f1dSLionel Sambuc       S = OMPTeamsDirective::CreateEmpty(
2741*0a6a1f1dSLionel Sambuc           Context, Record[ASTStmtReader::NumStmtFields], Empty);
2742*0a6a1f1dSLionel Sambuc       break;
2743*0a6a1f1dSLionel Sambuc 
2744f4a2713aSLionel Sambuc     case EXPR_CXX_OPERATOR_CALL:
2745f4a2713aSLionel Sambuc       S = new (Context) CXXOperatorCallExpr(Context, Empty);
2746f4a2713aSLionel Sambuc       break;
2747f4a2713aSLionel Sambuc 
2748f4a2713aSLionel Sambuc     case EXPR_CXX_MEMBER_CALL:
2749f4a2713aSLionel Sambuc       S = new (Context) CXXMemberCallExpr(Context, Empty);
2750f4a2713aSLionel Sambuc       break;
2751f4a2713aSLionel Sambuc 
2752f4a2713aSLionel Sambuc     case EXPR_CXX_CONSTRUCT:
2753f4a2713aSLionel Sambuc       S = new (Context) CXXConstructExpr(Empty);
2754f4a2713aSLionel Sambuc       break;
2755f4a2713aSLionel Sambuc 
2756f4a2713aSLionel Sambuc     case EXPR_CXX_TEMPORARY_OBJECT:
2757f4a2713aSLionel Sambuc       S = new (Context) CXXTemporaryObjectExpr(Empty);
2758f4a2713aSLionel Sambuc       break;
2759f4a2713aSLionel Sambuc 
2760f4a2713aSLionel Sambuc     case EXPR_CXX_STATIC_CAST:
2761f4a2713aSLionel Sambuc       S = CXXStaticCastExpr::CreateEmpty(Context,
2762f4a2713aSLionel Sambuc                        /*PathSize*/ Record[ASTStmtReader::NumExprFields]);
2763f4a2713aSLionel Sambuc       break;
2764f4a2713aSLionel Sambuc 
2765f4a2713aSLionel Sambuc     case EXPR_CXX_DYNAMIC_CAST:
2766f4a2713aSLionel Sambuc       S = CXXDynamicCastExpr::CreateEmpty(Context,
2767f4a2713aSLionel Sambuc                        /*PathSize*/ Record[ASTStmtReader::NumExprFields]);
2768f4a2713aSLionel Sambuc       break;
2769f4a2713aSLionel Sambuc 
2770f4a2713aSLionel Sambuc     case EXPR_CXX_REINTERPRET_CAST:
2771f4a2713aSLionel Sambuc       S = CXXReinterpretCastExpr::CreateEmpty(Context,
2772f4a2713aSLionel Sambuc                        /*PathSize*/ Record[ASTStmtReader::NumExprFields]);
2773f4a2713aSLionel Sambuc       break;
2774f4a2713aSLionel Sambuc 
2775f4a2713aSLionel Sambuc     case EXPR_CXX_CONST_CAST:
2776f4a2713aSLionel Sambuc       S = CXXConstCastExpr::CreateEmpty(Context);
2777f4a2713aSLionel Sambuc       break;
2778f4a2713aSLionel Sambuc 
2779f4a2713aSLionel Sambuc     case EXPR_CXX_FUNCTIONAL_CAST:
2780f4a2713aSLionel Sambuc       S = CXXFunctionalCastExpr::CreateEmpty(Context,
2781f4a2713aSLionel Sambuc                        /*PathSize*/ Record[ASTStmtReader::NumExprFields]);
2782f4a2713aSLionel Sambuc       break;
2783f4a2713aSLionel Sambuc 
2784f4a2713aSLionel Sambuc     case EXPR_USER_DEFINED_LITERAL:
2785f4a2713aSLionel Sambuc       S = new (Context) UserDefinedLiteral(Context, Empty);
2786f4a2713aSLionel Sambuc       break;
2787f4a2713aSLionel Sambuc 
2788f4a2713aSLionel Sambuc     case EXPR_CXX_STD_INITIALIZER_LIST:
2789f4a2713aSLionel Sambuc       S = new (Context) CXXStdInitializerListExpr(Empty);
2790f4a2713aSLionel Sambuc       break;
2791f4a2713aSLionel Sambuc 
2792f4a2713aSLionel Sambuc     case EXPR_CXX_BOOL_LITERAL:
2793f4a2713aSLionel Sambuc       S = new (Context) CXXBoolLiteralExpr(Empty);
2794f4a2713aSLionel Sambuc       break;
2795f4a2713aSLionel Sambuc 
2796f4a2713aSLionel Sambuc     case EXPR_CXX_NULL_PTR_LITERAL:
2797f4a2713aSLionel Sambuc       S = new (Context) CXXNullPtrLiteralExpr(Empty);
2798f4a2713aSLionel Sambuc       break;
2799f4a2713aSLionel Sambuc     case EXPR_CXX_TYPEID_EXPR:
2800f4a2713aSLionel Sambuc       S = new (Context) CXXTypeidExpr(Empty, true);
2801f4a2713aSLionel Sambuc       break;
2802f4a2713aSLionel Sambuc     case EXPR_CXX_TYPEID_TYPE:
2803f4a2713aSLionel Sambuc       S = new (Context) CXXTypeidExpr(Empty, false);
2804f4a2713aSLionel Sambuc       break;
2805f4a2713aSLionel Sambuc     case EXPR_CXX_UUIDOF_EXPR:
2806f4a2713aSLionel Sambuc       S = new (Context) CXXUuidofExpr(Empty, true);
2807f4a2713aSLionel Sambuc       break;
2808f4a2713aSLionel Sambuc     case EXPR_CXX_PROPERTY_REF_EXPR:
2809f4a2713aSLionel Sambuc       S = new (Context) MSPropertyRefExpr(Empty);
2810f4a2713aSLionel Sambuc       break;
2811f4a2713aSLionel Sambuc     case EXPR_CXX_UUIDOF_TYPE:
2812f4a2713aSLionel Sambuc       S = new (Context) CXXUuidofExpr(Empty, false);
2813f4a2713aSLionel Sambuc       break;
2814f4a2713aSLionel Sambuc     case EXPR_CXX_THIS:
2815f4a2713aSLionel Sambuc       S = new (Context) CXXThisExpr(Empty);
2816f4a2713aSLionel Sambuc       break;
2817f4a2713aSLionel Sambuc     case EXPR_CXX_THROW:
2818f4a2713aSLionel Sambuc       S = new (Context) CXXThrowExpr(Empty);
2819f4a2713aSLionel Sambuc       break;
2820f4a2713aSLionel Sambuc     case EXPR_CXX_DEFAULT_ARG: {
2821f4a2713aSLionel Sambuc       bool HasOtherExprStored = Record[ASTStmtReader::NumExprFields];
2822f4a2713aSLionel Sambuc       if (HasOtherExprStored) {
2823f4a2713aSLionel Sambuc         Expr *SubExpr = ReadSubExpr();
2824*0a6a1f1dSLionel Sambuc         S = CXXDefaultArgExpr::Create(Context, SourceLocation(), nullptr,
2825*0a6a1f1dSLionel Sambuc                                       SubExpr);
2826f4a2713aSLionel Sambuc       } else
2827f4a2713aSLionel Sambuc         S = new (Context) CXXDefaultArgExpr(Empty);
2828f4a2713aSLionel Sambuc       break;
2829f4a2713aSLionel Sambuc     }
2830f4a2713aSLionel Sambuc     case EXPR_CXX_DEFAULT_INIT:
2831f4a2713aSLionel Sambuc       S = new (Context) CXXDefaultInitExpr(Empty);
2832f4a2713aSLionel Sambuc       break;
2833f4a2713aSLionel Sambuc     case EXPR_CXX_BIND_TEMPORARY:
2834f4a2713aSLionel Sambuc       S = new (Context) CXXBindTemporaryExpr(Empty);
2835f4a2713aSLionel Sambuc       break;
2836f4a2713aSLionel Sambuc 
2837f4a2713aSLionel Sambuc     case EXPR_CXX_SCALAR_VALUE_INIT:
2838f4a2713aSLionel Sambuc       S = new (Context) CXXScalarValueInitExpr(Empty);
2839f4a2713aSLionel Sambuc       break;
2840f4a2713aSLionel Sambuc     case EXPR_CXX_NEW:
2841f4a2713aSLionel Sambuc       S = new (Context) CXXNewExpr(Empty);
2842f4a2713aSLionel Sambuc       break;
2843f4a2713aSLionel Sambuc     case EXPR_CXX_DELETE:
2844f4a2713aSLionel Sambuc       S = new (Context) CXXDeleteExpr(Empty);
2845f4a2713aSLionel Sambuc       break;
2846f4a2713aSLionel Sambuc     case EXPR_CXX_PSEUDO_DESTRUCTOR:
2847f4a2713aSLionel Sambuc       S = new (Context) CXXPseudoDestructorExpr(Empty);
2848f4a2713aSLionel Sambuc       break;
2849f4a2713aSLionel Sambuc 
2850f4a2713aSLionel Sambuc     case EXPR_EXPR_WITH_CLEANUPS:
2851f4a2713aSLionel Sambuc       S = ExprWithCleanups::Create(Context, Empty,
2852f4a2713aSLionel Sambuc                                    Record[ASTStmtReader::NumExprFields]);
2853f4a2713aSLionel Sambuc       break;
2854f4a2713aSLionel Sambuc 
2855f4a2713aSLionel Sambuc     case EXPR_CXX_DEPENDENT_SCOPE_MEMBER:
2856f4a2713aSLionel Sambuc       S = CXXDependentScopeMemberExpr::CreateEmpty(Context,
2857f4a2713aSLionel Sambuc          /*HasTemplateKWAndArgsInfo=*/Record[ASTStmtReader::NumExprFields],
2858f4a2713aSLionel Sambuc                   /*NumTemplateArgs=*/Record[ASTStmtReader::NumExprFields]
2859f4a2713aSLionel Sambuc                                    ? Record[ASTStmtReader::NumExprFields + 1]
2860f4a2713aSLionel Sambuc                                    : 0);
2861f4a2713aSLionel Sambuc       break;
2862f4a2713aSLionel Sambuc 
2863f4a2713aSLionel Sambuc     case EXPR_CXX_DEPENDENT_SCOPE_DECL_REF:
2864f4a2713aSLionel Sambuc       S = DependentScopeDeclRefExpr::CreateEmpty(Context,
2865f4a2713aSLionel Sambuc          /*HasTemplateKWAndArgsInfo=*/Record[ASTStmtReader::NumExprFields],
2866f4a2713aSLionel Sambuc                   /*NumTemplateArgs=*/Record[ASTStmtReader::NumExprFields]
2867f4a2713aSLionel Sambuc                                    ? Record[ASTStmtReader::NumExprFields + 1]
2868f4a2713aSLionel Sambuc                                    : 0);
2869f4a2713aSLionel Sambuc       break;
2870f4a2713aSLionel Sambuc 
2871f4a2713aSLionel Sambuc     case EXPR_CXX_UNRESOLVED_CONSTRUCT:
2872f4a2713aSLionel Sambuc       S = CXXUnresolvedConstructExpr::CreateEmpty(Context,
2873f4a2713aSLionel Sambuc                               /*NumArgs=*/Record[ASTStmtReader::NumExprFields]);
2874f4a2713aSLionel Sambuc       break;
2875f4a2713aSLionel Sambuc 
2876f4a2713aSLionel Sambuc     case EXPR_CXX_UNRESOLVED_MEMBER:
2877f4a2713aSLionel Sambuc       S = UnresolvedMemberExpr::CreateEmpty(Context,
2878f4a2713aSLionel Sambuc          /*HasTemplateKWAndArgsInfo=*/Record[ASTStmtReader::NumExprFields],
2879f4a2713aSLionel Sambuc                   /*NumTemplateArgs=*/Record[ASTStmtReader::NumExprFields]
2880f4a2713aSLionel Sambuc                                    ? Record[ASTStmtReader::NumExprFields + 1]
2881f4a2713aSLionel Sambuc                                    : 0);
2882f4a2713aSLionel Sambuc       break;
2883f4a2713aSLionel Sambuc 
2884f4a2713aSLionel Sambuc     case EXPR_CXX_UNRESOLVED_LOOKUP:
2885f4a2713aSLionel Sambuc       S = UnresolvedLookupExpr::CreateEmpty(Context,
2886f4a2713aSLionel Sambuc          /*HasTemplateKWAndArgsInfo=*/Record[ASTStmtReader::NumExprFields],
2887f4a2713aSLionel Sambuc                   /*NumTemplateArgs=*/Record[ASTStmtReader::NumExprFields]
2888f4a2713aSLionel Sambuc                                    ? Record[ASTStmtReader::NumExprFields + 1]
2889f4a2713aSLionel Sambuc                                    : 0);
2890f4a2713aSLionel Sambuc       break;
2891f4a2713aSLionel Sambuc 
2892f4a2713aSLionel Sambuc     case EXPR_TYPE_TRAIT:
2893f4a2713aSLionel Sambuc       S = TypeTraitExpr::CreateDeserialized(Context,
2894f4a2713aSLionel Sambuc             Record[ASTStmtReader::NumExprFields]);
2895f4a2713aSLionel Sambuc       break;
2896f4a2713aSLionel Sambuc 
2897f4a2713aSLionel Sambuc     case EXPR_ARRAY_TYPE_TRAIT:
2898f4a2713aSLionel Sambuc       S = new (Context) ArrayTypeTraitExpr(Empty);
2899f4a2713aSLionel Sambuc       break;
2900f4a2713aSLionel Sambuc 
2901f4a2713aSLionel Sambuc     case EXPR_CXX_EXPRESSION_TRAIT:
2902f4a2713aSLionel Sambuc       S = new (Context) ExpressionTraitExpr(Empty);
2903f4a2713aSLionel Sambuc       break;
2904f4a2713aSLionel Sambuc 
2905f4a2713aSLionel Sambuc     case EXPR_CXX_NOEXCEPT:
2906f4a2713aSLionel Sambuc       S = new (Context) CXXNoexceptExpr(Empty);
2907f4a2713aSLionel Sambuc       break;
2908f4a2713aSLionel Sambuc 
2909f4a2713aSLionel Sambuc     case EXPR_PACK_EXPANSION:
2910f4a2713aSLionel Sambuc       S = new (Context) PackExpansionExpr(Empty);
2911f4a2713aSLionel Sambuc       break;
2912f4a2713aSLionel Sambuc 
2913f4a2713aSLionel Sambuc     case EXPR_SIZEOF_PACK:
2914f4a2713aSLionel Sambuc       S = new (Context) SizeOfPackExpr(Empty);
2915f4a2713aSLionel Sambuc       break;
2916f4a2713aSLionel Sambuc 
2917f4a2713aSLionel Sambuc     case EXPR_SUBST_NON_TYPE_TEMPLATE_PARM:
2918f4a2713aSLionel Sambuc       S = new (Context) SubstNonTypeTemplateParmExpr(Empty);
2919f4a2713aSLionel Sambuc       break;
2920f4a2713aSLionel Sambuc 
2921f4a2713aSLionel Sambuc     case EXPR_SUBST_NON_TYPE_TEMPLATE_PARM_PACK:
2922f4a2713aSLionel Sambuc       S = new (Context) SubstNonTypeTemplateParmPackExpr(Empty);
2923f4a2713aSLionel Sambuc       break;
2924f4a2713aSLionel Sambuc 
2925f4a2713aSLionel Sambuc     case EXPR_FUNCTION_PARM_PACK:
2926f4a2713aSLionel Sambuc       S = FunctionParmPackExpr::CreateEmpty(Context,
2927f4a2713aSLionel Sambuc                                           Record[ASTStmtReader::NumExprFields]);
2928f4a2713aSLionel Sambuc       break;
2929f4a2713aSLionel Sambuc 
2930f4a2713aSLionel Sambuc     case EXPR_MATERIALIZE_TEMPORARY:
2931f4a2713aSLionel Sambuc       S = new (Context) MaterializeTemporaryExpr(Empty);
2932f4a2713aSLionel Sambuc       break;
2933f4a2713aSLionel Sambuc 
2934*0a6a1f1dSLionel Sambuc     case EXPR_CXX_FOLD:
2935*0a6a1f1dSLionel Sambuc       S = new (Context) CXXFoldExpr(Empty);
2936*0a6a1f1dSLionel Sambuc       break;
2937*0a6a1f1dSLionel Sambuc 
2938f4a2713aSLionel Sambuc     case EXPR_OPAQUE_VALUE:
2939f4a2713aSLionel Sambuc       S = new (Context) OpaqueValueExpr(Empty);
2940f4a2713aSLionel Sambuc       break;
2941f4a2713aSLionel Sambuc 
2942f4a2713aSLionel Sambuc     case EXPR_CUDA_KERNEL_CALL:
2943f4a2713aSLionel Sambuc       S = new (Context) CUDAKernelCallExpr(Context, Empty);
2944f4a2713aSLionel Sambuc       break;
2945f4a2713aSLionel Sambuc 
2946f4a2713aSLionel Sambuc     case EXPR_ASTYPE:
2947f4a2713aSLionel Sambuc       S = new (Context) AsTypeExpr(Empty);
2948f4a2713aSLionel Sambuc       break;
2949f4a2713aSLionel Sambuc 
2950f4a2713aSLionel Sambuc     case EXPR_PSEUDO_OBJECT: {
2951f4a2713aSLionel Sambuc       unsigned numSemanticExprs = Record[ASTStmtReader::NumExprFields];
2952f4a2713aSLionel Sambuc       S = PseudoObjectExpr::Create(Context, Empty, numSemanticExprs);
2953f4a2713aSLionel Sambuc       break;
2954f4a2713aSLionel Sambuc     }
2955f4a2713aSLionel Sambuc 
2956f4a2713aSLionel Sambuc     case EXPR_ATOMIC:
2957f4a2713aSLionel Sambuc       S = new (Context) AtomicExpr(Empty);
2958f4a2713aSLionel Sambuc       break;
2959f4a2713aSLionel Sambuc 
2960f4a2713aSLionel Sambuc     case EXPR_LAMBDA: {
2961f4a2713aSLionel Sambuc       unsigned NumCaptures = Record[ASTStmtReader::NumExprFields];
2962f4a2713aSLionel Sambuc       unsigned NumArrayIndexVars = Record[ASTStmtReader::NumExprFields + 1];
2963f4a2713aSLionel Sambuc       S = LambdaExpr::CreateDeserialized(Context, NumCaptures,
2964f4a2713aSLionel Sambuc                                          NumArrayIndexVars);
2965f4a2713aSLionel Sambuc       break;
2966f4a2713aSLionel Sambuc     }
2967f4a2713aSLionel Sambuc     }
2968f4a2713aSLionel Sambuc 
2969f4a2713aSLionel Sambuc     // We hit a STMT_STOP, so we're done with this expression.
2970f4a2713aSLionel Sambuc     if (Finished)
2971f4a2713aSLionel Sambuc       break;
2972f4a2713aSLionel Sambuc 
2973f4a2713aSLionel Sambuc     ++NumStatementsRead;
2974f4a2713aSLionel Sambuc 
2975f4a2713aSLionel Sambuc     if (S && !IsStmtReference) {
2976f4a2713aSLionel Sambuc       Reader.Visit(S);
2977f4a2713aSLionel Sambuc       StmtEntries[Cursor.GetCurrentBitNo()] = S;
2978f4a2713aSLionel Sambuc     }
2979f4a2713aSLionel Sambuc 
2980f4a2713aSLionel Sambuc 
2981f4a2713aSLionel Sambuc     assert(Idx == Record.size() && "Invalid deserialization of statement");
2982f4a2713aSLionel Sambuc     StmtStack.push_back(S);
2983f4a2713aSLionel Sambuc   }
2984f4a2713aSLionel Sambuc Done:
2985*0a6a1f1dSLionel Sambuc   assert(StmtStack.size() > PrevNumStmts && "Read too many sub-stmts!");
2986f4a2713aSLionel Sambuc   assert(StmtStack.size() == PrevNumStmts + 1 && "Extra expressions on stack!");
2987f4a2713aSLionel Sambuc   return StmtStack.pop_back_val();
2988f4a2713aSLionel Sambuc }
2989