xref: /minix3/external/bsd/llvm/dist/clang/lib/Serialization/ASTWriterStmt.cpp (revision 0a6a1f1d05b60e214de2f05a7310ddd1f0e590e7)
1f4a2713aSLionel Sambuc //===--- ASTWriterStmt.cpp - Statement and Expression Serialization -------===//
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 /// \file
11f4a2713aSLionel Sambuc /// \brief Implements serialization for Statements and Expressions.
12f4a2713aSLionel Sambuc ///
13f4a2713aSLionel Sambuc //===----------------------------------------------------------------------===//
14f4a2713aSLionel Sambuc 
15f4a2713aSLionel Sambuc #include "clang/Serialization/ASTWriter.h"
16f4a2713aSLionel Sambuc #include "clang/AST/ASTContext.h"
17f4a2713aSLionel Sambuc #include "clang/AST/DeclCXX.h"
18f4a2713aSLionel Sambuc #include "clang/AST/DeclObjC.h"
19f4a2713aSLionel Sambuc #include "clang/AST/DeclTemplate.h"
20f4a2713aSLionel Sambuc #include "clang/AST/StmtVisitor.h"
21f4a2713aSLionel Sambuc #include "clang/Lex/Token.h"
22f4a2713aSLionel Sambuc #include "llvm/Bitcode/BitstreamWriter.h"
23f4a2713aSLionel Sambuc using namespace clang;
24f4a2713aSLionel Sambuc 
25f4a2713aSLionel Sambuc //===----------------------------------------------------------------------===//
26f4a2713aSLionel Sambuc // Statement/expression serialization
27f4a2713aSLionel Sambuc //===----------------------------------------------------------------------===//
28f4a2713aSLionel Sambuc 
29f4a2713aSLionel Sambuc namespace clang {
30f4a2713aSLionel Sambuc 
31f4a2713aSLionel Sambuc   class ASTStmtWriter : public StmtVisitor<ASTStmtWriter, void> {
32f4a2713aSLionel Sambuc     friend class OMPClauseWriter;
33f4a2713aSLionel Sambuc     ASTWriter &Writer;
34f4a2713aSLionel Sambuc     ASTWriter::RecordData &Record;
35f4a2713aSLionel Sambuc 
36f4a2713aSLionel Sambuc   public:
37f4a2713aSLionel Sambuc     serialization::StmtCode Code;
38f4a2713aSLionel Sambuc     unsigned AbbrevToUse;
39f4a2713aSLionel Sambuc 
ASTStmtWriter(ASTWriter & Writer,ASTWriter::RecordData & Record)40f4a2713aSLionel Sambuc     ASTStmtWriter(ASTWriter &Writer, ASTWriter::RecordData &Record)
41f4a2713aSLionel Sambuc       : Writer(Writer), Record(Record) { }
42f4a2713aSLionel Sambuc 
43f4a2713aSLionel Sambuc     void AddTemplateKWAndArgsInfo(const ASTTemplateKWAndArgsInfo &Args);
44f4a2713aSLionel Sambuc 
45f4a2713aSLionel Sambuc     void VisitStmt(Stmt *S);
46f4a2713aSLionel Sambuc #define STMT(Type, Base) \
47f4a2713aSLionel Sambuc     void Visit##Type(Type *);
48f4a2713aSLionel Sambuc #include "clang/AST/StmtNodes.inc"
49f4a2713aSLionel Sambuc   };
50f4a2713aSLionel Sambuc }
51f4a2713aSLionel Sambuc 
52f4a2713aSLionel Sambuc void ASTStmtWriter::
AddTemplateKWAndArgsInfo(const ASTTemplateKWAndArgsInfo & Args)53f4a2713aSLionel Sambuc AddTemplateKWAndArgsInfo(const ASTTemplateKWAndArgsInfo &Args) {
54f4a2713aSLionel Sambuc   Writer.AddSourceLocation(Args.getTemplateKeywordLoc(), Record);
55f4a2713aSLionel Sambuc   Writer.AddSourceLocation(Args.LAngleLoc, Record);
56f4a2713aSLionel Sambuc   Writer.AddSourceLocation(Args.RAngleLoc, Record);
57f4a2713aSLionel Sambuc   for (unsigned i=0; i != Args.NumTemplateArgs; ++i)
58f4a2713aSLionel Sambuc     Writer.AddTemplateArgumentLoc(Args.getTemplateArgs()[i], Record);
59f4a2713aSLionel Sambuc }
60f4a2713aSLionel Sambuc 
VisitStmt(Stmt * S)61f4a2713aSLionel Sambuc void ASTStmtWriter::VisitStmt(Stmt *S) {
62f4a2713aSLionel Sambuc }
63f4a2713aSLionel Sambuc 
VisitNullStmt(NullStmt * S)64f4a2713aSLionel Sambuc void ASTStmtWriter::VisitNullStmt(NullStmt *S) {
65f4a2713aSLionel Sambuc   VisitStmt(S);
66f4a2713aSLionel Sambuc   Writer.AddSourceLocation(S->getSemiLoc(), Record);
67f4a2713aSLionel Sambuc   Record.push_back(S->HasLeadingEmptyMacro);
68f4a2713aSLionel Sambuc   Code = serialization::STMT_NULL;
69f4a2713aSLionel Sambuc }
70f4a2713aSLionel Sambuc 
VisitCompoundStmt(CompoundStmt * S)71f4a2713aSLionel Sambuc void ASTStmtWriter::VisitCompoundStmt(CompoundStmt *S) {
72f4a2713aSLionel Sambuc   VisitStmt(S);
73f4a2713aSLionel Sambuc   Record.push_back(S->size());
74*0a6a1f1dSLionel Sambuc   for (auto *CS : S->body())
75*0a6a1f1dSLionel Sambuc     Writer.AddStmt(CS);
76f4a2713aSLionel Sambuc   Writer.AddSourceLocation(S->getLBracLoc(), Record);
77f4a2713aSLionel Sambuc   Writer.AddSourceLocation(S->getRBracLoc(), Record);
78f4a2713aSLionel Sambuc   Code = serialization::STMT_COMPOUND;
79f4a2713aSLionel Sambuc }
80f4a2713aSLionel Sambuc 
VisitSwitchCase(SwitchCase * S)81f4a2713aSLionel Sambuc void ASTStmtWriter::VisitSwitchCase(SwitchCase *S) {
82f4a2713aSLionel Sambuc   VisitStmt(S);
83f4a2713aSLionel Sambuc   Record.push_back(Writer.getSwitchCaseID(S));
84f4a2713aSLionel Sambuc   Writer.AddSourceLocation(S->getKeywordLoc(), Record);
85f4a2713aSLionel Sambuc   Writer.AddSourceLocation(S->getColonLoc(), Record);
86f4a2713aSLionel Sambuc }
87f4a2713aSLionel Sambuc 
VisitCaseStmt(CaseStmt * S)88f4a2713aSLionel Sambuc void ASTStmtWriter::VisitCaseStmt(CaseStmt *S) {
89f4a2713aSLionel Sambuc   VisitSwitchCase(S);
90f4a2713aSLionel Sambuc   Writer.AddStmt(S->getLHS());
91f4a2713aSLionel Sambuc   Writer.AddStmt(S->getRHS());
92f4a2713aSLionel Sambuc   Writer.AddStmt(S->getSubStmt());
93f4a2713aSLionel Sambuc   Writer.AddSourceLocation(S->getEllipsisLoc(), Record);
94f4a2713aSLionel Sambuc   Code = serialization::STMT_CASE;
95f4a2713aSLionel Sambuc }
96f4a2713aSLionel Sambuc 
VisitDefaultStmt(DefaultStmt * S)97f4a2713aSLionel Sambuc void ASTStmtWriter::VisitDefaultStmt(DefaultStmt *S) {
98f4a2713aSLionel Sambuc   VisitSwitchCase(S);
99f4a2713aSLionel Sambuc   Writer.AddStmt(S->getSubStmt());
100f4a2713aSLionel Sambuc   Code = serialization::STMT_DEFAULT;
101f4a2713aSLionel Sambuc }
102f4a2713aSLionel Sambuc 
VisitLabelStmt(LabelStmt * S)103f4a2713aSLionel Sambuc void ASTStmtWriter::VisitLabelStmt(LabelStmt *S) {
104f4a2713aSLionel Sambuc   VisitStmt(S);
105f4a2713aSLionel Sambuc   Writer.AddDeclRef(S->getDecl(), Record);
106f4a2713aSLionel Sambuc   Writer.AddStmt(S->getSubStmt());
107f4a2713aSLionel Sambuc   Writer.AddSourceLocation(S->getIdentLoc(), Record);
108f4a2713aSLionel Sambuc   Code = serialization::STMT_LABEL;
109f4a2713aSLionel Sambuc }
110f4a2713aSLionel Sambuc 
VisitAttributedStmt(AttributedStmt * S)111f4a2713aSLionel Sambuc void ASTStmtWriter::VisitAttributedStmt(AttributedStmt *S) {
112f4a2713aSLionel Sambuc   VisitStmt(S);
113f4a2713aSLionel Sambuc   Record.push_back(S->getAttrs().size());
114f4a2713aSLionel Sambuc   Writer.WriteAttributes(S->getAttrs(), Record);
115f4a2713aSLionel Sambuc   Writer.AddStmt(S->getSubStmt());
116f4a2713aSLionel Sambuc   Writer.AddSourceLocation(S->getAttrLoc(), Record);
117f4a2713aSLionel Sambuc   Code = serialization::STMT_ATTRIBUTED;
118f4a2713aSLionel Sambuc }
119f4a2713aSLionel Sambuc 
VisitIfStmt(IfStmt * S)120f4a2713aSLionel Sambuc void ASTStmtWriter::VisitIfStmt(IfStmt *S) {
121f4a2713aSLionel Sambuc   VisitStmt(S);
122f4a2713aSLionel Sambuc   Writer.AddDeclRef(S->getConditionVariable(), Record);
123f4a2713aSLionel Sambuc   Writer.AddStmt(S->getCond());
124f4a2713aSLionel Sambuc   Writer.AddStmt(S->getThen());
125f4a2713aSLionel Sambuc   Writer.AddStmt(S->getElse());
126f4a2713aSLionel Sambuc   Writer.AddSourceLocation(S->getIfLoc(), Record);
127f4a2713aSLionel Sambuc   Writer.AddSourceLocation(S->getElseLoc(), Record);
128f4a2713aSLionel Sambuc   Code = serialization::STMT_IF;
129f4a2713aSLionel Sambuc }
130f4a2713aSLionel Sambuc 
VisitSwitchStmt(SwitchStmt * S)131f4a2713aSLionel Sambuc void ASTStmtWriter::VisitSwitchStmt(SwitchStmt *S) {
132f4a2713aSLionel Sambuc   VisitStmt(S);
133f4a2713aSLionel Sambuc   Writer.AddDeclRef(S->getConditionVariable(), Record);
134f4a2713aSLionel Sambuc   Writer.AddStmt(S->getCond());
135f4a2713aSLionel Sambuc   Writer.AddStmt(S->getBody());
136f4a2713aSLionel Sambuc   Writer.AddSourceLocation(S->getSwitchLoc(), Record);
137f4a2713aSLionel Sambuc   Record.push_back(S->isAllEnumCasesCovered());
138f4a2713aSLionel Sambuc   for (SwitchCase *SC = S->getSwitchCaseList(); SC;
139f4a2713aSLionel Sambuc        SC = SC->getNextSwitchCase())
140f4a2713aSLionel Sambuc     Record.push_back(Writer.RecordSwitchCaseID(SC));
141f4a2713aSLionel Sambuc   Code = serialization::STMT_SWITCH;
142f4a2713aSLionel Sambuc }
143f4a2713aSLionel Sambuc 
VisitWhileStmt(WhileStmt * S)144f4a2713aSLionel Sambuc void ASTStmtWriter::VisitWhileStmt(WhileStmt *S) {
145f4a2713aSLionel Sambuc   VisitStmt(S);
146f4a2713aSLionel Sambuc   Writer.AddDeclRef(S->getConditionVariable(), Record);
147f4a2713aSLionel Sambuc   Writer.AddStmt(S->getCond());
148f4a2713aSLionel Sambuc   Writer.AddStmt(S->getBody());
149f4a2713aSLionel Sambuc   Writer.AddSourceLocation(S->getWhileLoc(), Record);
150f4a2713aSLionel Sambuc   Code = serialization::STMT_WHILE;
151f4a2713aSLionel Sambuc }
152f4a2713aSLionel Sambuc 
VisitDoStmt(DoStmt * S)153f4a2713aSLionel Sambuc void ASTStmtWriter::VisitDoStmt(DoStmt *S) {
154f4a2713aSLionel Sambuc   VisitStmt(S);
155f4a2713aSLionel Sambuc   Writer.AddStmt(S->getCond());
156f4a2713aSLionel Sambuc   Writer.AddStmt(S->getBody());
157f4a2713aSLionel Sambuc   Writer.AddSourceLocation(S->getDoLoc(), Record);
158f4a2713aSLionel Sambuc   Writer.AddSourceLocation(S->getWhileLoc(), Record);
159f4a2713aSLionel Sambuc   Writer.AddSourceLocation(S->getRParenLoc(), Record);
160f4a2713aSLionel Sambuc   Code = serialization::STMT_DO;
161f4a2713aSLionel Sambuc }
162f4a2713aSLionel Sambuc 
VisitForStmt(ForStmt * S)163f4a2713aSLionel Sambuc void ASTStmtWriter::VisitForStmt(ForStmt *S) {
164f4a2713aSLionel Sambuc   VisitStmt(S);
165f4a2713aSLionel Sambuc   Writer.AddStmt(S->getInit());
166f4a2713aSLionel Sambuc   Writer.AddStmt(S->getCond());
167f4a2713aSLionel Sambuc   Writer.AddDeclRef(S->getConditionVariable(), Record);
168f4a2713aSLionel Sambuc   Writer.AddStmt(S->getInc());
169f4a2713aSLionel Sambuc   Writer.AddStmt(S->getBody());
170f4a2713aSLionel Sambuc   Writer.AddSourceLocation(S->getForLoc(), Record);
171f4a2713aSLionel Sambuc   Writer.AddSourceLocation(S->getLParenLoc(), Record);
172f4a2713aSLionel Sambuc   Writer.AddSourceLocation(S->getRParenLoc(), Record);
173f4a2713aSLionel Sambuc   Code = serialization::STMT_FOR;
174f4a2713aSLionel Sambuc }
175f4a2713aSLionel Sambuc 
VisitGotoStmt(GotoStmt * S)176f4a2713aSLionel Sambuc void ASTStmtWriter::VisitGotoStmt(GotoStmt *S) {
177f4a2713aSLionel Sambuc   VisitStmt(S);
178f4a2713aSLionel Sambuc   Writer.AddDeclRef(S->getLabel(), Record);
179f4a2713aSLionel Sambuc   Writer.AddSourceLocation(S->getGotoLoc(), Record);
180f4a2713aSLionel Sambuc   Writer.AddSourceLocation(S->getLabelLoc(), Record);
181f4a2713aSLionel Sambuc   Code = serialization::STMT_GOTO;
182f4a2713aSLionel Sambuc }
183f4a2713aSLionel Sambuc 
VisitIndirectGotoStmt(IndirectGotoStmt * S)184f4a2713aSLionel Sambuc void ASTStmtWriter::VisitIndirectGotoStmt(IndirectGotoStmt *S) {
185f4a2713aSLionel Sambuc   VisitStmt(S);
186f4a2713aSLionel Sambuc   Writer.AddSourceLocation(S->getGotoLoc(), Record);
187f4a2713aSLionel Sambuc   Writer.AddSourceLocation(S->getStarLoc(), Record);
188f4a2713aSLionel Sambuc   Writer.AddStmt(S->getTarget());
189f4a2713aSLionel Sambuc   Code = serialization::STMT_INDIRECT_GOTO;
190f4a2713aSLionel Sambuc }
191f4a2713aSLionel Sambuc 
VisitContinueStmt(ContinueStmt * S)192f4a2713aSLionel Sambuc void ASTStmtWriter::VisitContinueStmt(ContinueStmt *S) {
193f4a2713aSLionel Sambuc   VisitStmt(S);
194f4a2713aSLionel Sambuc   Writer.AddSourceLocation(S->getContinueLoc(), Record);
195f4a2713aSLionel Sambuc   Code = serialization::STMT_CONTINUE;
196f4a2713aSLionel Sambuc }
197f4a2713aSLionel Sambuc 
VisitBreakStmt(BreakStmt * S)198f4a2713aSLionel Sambuc void ASTStmtWriter::VisitBreakStmt(BreakStmt *S) {
199f4a2713aSLionel Sambuc   VisitStmt(S);
200f4a2713aSLionel Sambuc   Writer.AddSourceLocation(S->getBreakLoc(), Record);
201f4a2713aSLionel Sambuc   Code = serialization::STMT_BREAK;
202f4a2713aSLionel Sambuc }
203f4a2713aSLionel Sambuc 
VisitReturnStmt(ReturnStmt * S)204f4a2713aSLionel Sambuc void ASTStmtWriter::VisitReturnStmt(ReturnStmt *S) {
205f4a2713aSLionel Sambuc   VisitStmt(S);
206f4a2713aSLionel Sambuc   Writer.AddStmt(S->getRetValue());
207f4a2713aSLionel Sambuc   Writer.AddSourceLocation(S->getReturnLoc(), Record);
208f4a2713aSLionel Sambuc   Writer.AddDeclRef(S->getNRVOCandidate(), Record);
209f4a2713aSLionel Sambuc   Code = serialization::STMT_RETURN;
210f4a2713aSLionel Sambuc }
211f4a2713aSLionel Sambuc 
VisitDeclStmt(DeclStmt * S)212f4a2713aSLionel Sambuc void ASTStmtWriter::VisitDeclStmt(DeclStmt *S) {
213f4a2713aSLionel Sambuc   VisitStmt(S);
214f4a2713aSLionel Sambuc   Writer.AddSourceLocation(S->getStartLoc(), Record);
215f4a2713aSLionel Sambuc   Writer.AddSourceLocation(S->getEndLoc(), Record);
216f4a2713aSLionel Sambuc   DeclGroupRef DG = S->getDeclGroup();
217f4a2713aSLionel Sambuc   for (DeclGroupRef::iterator D = DG.begin(), DEnd = DG.end(); D != DEnd; ++D)
218f4a2713aSLionel Sambuc     Writer.AddDeclRef(*D, Record);
219f4a2713aSLionel Sambuc   Code = serialization::STMT_DECL;
220f4a2713aSLionel Sambuc }
221f4a2713aSLionel Sambuc 
VisitAsmStmt(AsmStmt * S)222f4a2713aSLionel Sambuc void ASTStmtWriter::VisitAsmStmt(AsmStmt *S) {
223f4a2713aSLionel Sambuc   VisitStmt(S);
224f4a2713aSLionel Sambuc   Record.push_back(S->getNumOutputs());
225f4a2713aSLionel Sambuc   Record.push_back(S->getNumInputs());
226f4a2713aSLionel Sambuc   Record.push_back(S->getNumClobbers());
227f4a2713aSLionel Sambuc   Writer.AddSourceLocation(S->getAsmLoc(), Record);
228f4a2713aSLionel Sambuc   Record.push_back(S->isVolatile());
229f4a2713aSLionel Sambuc   Record.push_back(S->isSimple());
230f4a2713aSLionel Sambuc }
231f4a2713aSLionel Sambuc 
VisitGCCAsmStmt(GCCAsmStmt * S)232f4a2713aSLionel Sambuc void ASTStmtWriter::VisitGCCAsmStmt(GCCAsmStmt *S) {
233f4a2713aSLionel Sambuc   VisitAsmStmt(S);
234f4a2713aSLionel Sambuc   Writer.AddSourceLocation(S->getRParenLoc(), Record);
235f4a2713aSLionel Sambuc   Writer.AddStmt(S->getAsmString());
236f4a2713aSLionel Sambuc 
237f4a2713aSLionel Sambuc   // Outputs
238f4a2713aSLionel Sambuc   for (unsigned I = 0, N = S->getNumOutputs(); I != N; ++I) {
239f4a2713aSLionel Sambuc     Writer.AddIdentifierRef(S->getOutputIdentifier(I), Record);
240f4a2713aSLionel Sambuc     Writer.AddStmt(S->getOutputConstraintLiteral(I));
241f4a2713aSLionel Sambuc     Writer.AddStmt(S->getOutputExpr(I));
242f4a2713aSLionel Sambuc   }
243f4a2713aSLionel Sambuc 
244f4a2713aSLionel Sambuc   // Inputs
245f4a2713aSLionel Sambuc   for (unsigned I = 0, N = S->getNumInputs(); I != N; ++I) {
246f4a2713aSLionel Sambuc     Writer.AddIdentifierRef(S->getInputIdentifier(I), Record);
247f4a2713aSLionel Sambuc     Writer.AddStmt(S->getInputConstraintLiteral(I));
248f4a2713aSLionel Sambuc     Writer.AddStmt(S->getInputExpr(I));
249f4a2713aSLionel Sambuc   }
250f4a2713aSLionel Sambuc 
251f4a2713aSLionel Sambuc   // Clobbers
252f4a2713aSLionel Sambuc   for (unsigned I = 0, N = S->getNumClobbers(); I != N; ++I)
253f4a2713aSLionel Sambuc     Writer.AddStmt(S->getClobberStringLiteral(I));
254f4a2713aSLionel Sambuc 
255f4a2713aSLionel Sambuc   Code = serialization::STMT_GCCASM;
256f4a2713aSLionel Sambuc }
257f4a2713aSLionel Sambuc 
VisitMSAsmStmt(MSAsmStmt * S)258f4a2713aSLionel Sambuc void ASTStmtWriter::VisitMSAsmStmt(MSAsmStmt *S) {
259f4a2713aSLionel Sambuc   VisitAsmStmt(S);
260f4a2713aSLionel Sambuc   Writer.AddSourceLocation(S->getLBraceLoc(), Record);
261f4a2713aSLionel Sambuc   Writer.AddSourceLocation(S->getEndLoc(), Record);
262f4a2713aSLionel Sambuc   Record.push_back(S->getNumAsmToks());
263f4a2713aSLionel Sambuc   Writer.AddString(S->getAsmString(), Record);
264f4a2713aSLionel Sambuc 
265f4a2713aSLionel Sambuc   // Tokens
266f4a2713aSLionel Sambuc   for (unsigned I = 0, N = S->getNumAsmToks(); I != N; ++I) {
267f4a2713aSLionel Sambuc     Writer.AddToken(S->getAsmToks()[I], Record);
268f4a2713aSLionel Sambuc   }
269f4a2713aSLionel Sambuc 
270f4a2713aSLionel Sambuc   // Clobbers
271f4a2713aSLionel Sambuc   for (unsigned I = 0, N = S->getNumClobbers(); I != N; ++I) {
272f4a2713aSLionel Sambuc     Writer.AddString(S->getClobber(I), Record);
273f4a2713aSLionel Sambuc   }
274f4a2713aSLionel Sambuc 
275f4a2713aSLionel Sambuc   // Outputs
276f4a2713aSLionel Sambuc   for (unsigned I = 0, N = S->getNumOutputs(); I != N; ++I) {
277f4a2713aSLionel Sambuc     Writer.AddStmt(S->getOutputExpr(I));
278f4a2713aSLionel Sambuc     Writer.AddString(S->getOutputConstraint(I), Record);
279f4a2713aSLionel Sambuc   }
280f4a2713aSLionel Sambuc 
281f4a2713aSLionel Sambuc   // Inputs
282f4a2713aSLionel Sambuc   for (unsigned I = 0, N = S->getNumInputs(); I != N; ++I) {
283f4a2713aSLionel Sambuc     Writer.AddStmt(S->getInputExpr(I));
284f4a2713aSLionel Sambuc     Writer.AddString(S->getInputConstraint(I), Record);
285f4a2713aSLionel Sambuc   }
286f4a2713aSLionel Sambuc 
287f4a2713aSLionel Sambuc   Code = serialization::STMT_MSASM;
288f4a2713aSLionel Sambuc }
289f4a2713aSLionel Sambuc 
VisitCapturedStmt(CapturedStmt * S)290f4a2713aSLionel Sambuc void ASTStmtWriter::VisitCapturedStmt(CapturedStmt *S) {
291f4a2713aSLionel Sambuc   VisitStmt(S);
292f4a2713aSLionel Sambuc   // NumCaptures
293f4a2713aSLionel Sambuc   Record.push_back(std::distance(S->capture_begin(), S->capture_end()));
294f4a2713aSLionel Sambuc 
295f4a2713aSLionel Sambuc   // CapturedDecl and captured region kind
296f4a2713aSLionel Sambuc   Writer.AddDeclRef(S->getCapturedDecl(), Record);
297f4a2713aSLionel Sambuc   Record.push_back(S->getCapturedRegionKind());
298f4a2713aSLionel Sambuc 
299f4a2713aSLionel Sambuc   Writer.AddDeclRef(S->getCapturedRecordDecl(), Record);
300f4a2713aSLionel Sambuc 
301f4a2713aSLionel Sambuc   // Capture inits
302*0a6a1f1dSLionel Sambuc   for (auto *I : S->capture_inits())
303*0a6a1f1dSLionel Sambuc     Writer.AddStmt(I);
304f4a2713aSLionel Sambuc 
305f4a2713aSLionel Sambuc   // Body
306f4a2713aSLionel Sambuc   Writer.AddStmt(S->getCapturedStmt());
307f4a2713aSLionel Sambuc 
308f4a2713aSLionel Sambuc   // Captures
309*0a6a1f1dSLionel Sambuc   for (const auto &I : S->captures()) {
310*0a6a1f1dSLionel Sambuc     if (I.capturesThis() || I.capturesVariableArrayType())
311*0a6a1f1dSLionel Sambuc       Writer.AddDeclRef(nullptr, Record);
312f4a2713aSLionel Sambuc     else
313*0a6a1f1dSLionel Sambuc       Writer.AddDeclRef(I.getCapturedVar(), Record);
314*0a6a1f1dSLionel Sambuc     Record.push_back(I.getCaptureKind());
315*0a6a1f1dSLionel Sambuc     Writer.AddSourceLocation(I.getLocation(), Record);
316f4a2713aSLionel Sambuc   }
317f4a2713aSLionel Sambuc 
318f4a2713aSLionel Sambuc   Code = serialization::STMT_CAPTURED;
319f4a2713aSLionel Sambuc }
320f4a2713aSLionel Sambuc 
VisitExpr(Expr * E)321f4a2713aSLionel Sambuc void ASTStmtWriter::VisitExpr(Expr *E) {
322f4a2713aSLionel Sambuc   VisitStmt(E);
323f4a2713aSLionel Sambuc   Writer.AddTypeRef(E->getType(), Record);
324f4a2713aSLionel Sambuc   Record.push_back(E->isTypeDependent());
325f4a2713aSLionel Sambuc   Record.push_back(E->isValueDependent());
326f4a2713aSLionel Sambuc   Record.push_back(E->isInstantiationDependent());
327f4a2713aSLionel Sambuc   Record.push_back(E->containsUnexpandedParameterPack());
328f4a2713aSLionel Sambuc   Record.push_back(E->getValueKind());
329f4a2713aSLionel Sambuc   Record.push_back(E->getObjectKind());
330f4a2713aSLionel Sambuc }
331f4a2713aSLionel Sambuc 
VisitPredefinedExpr(PredefinedExpr * E)332f4a2713aSLionel Sambuc void ASTStmtWriter::VisitPredefinedExpr(PredefinedExpr *E) {
333f4a2713aSLionel Sambuc   VisitExpr(E);
334f4a2713aSLionel Sambuc   Writer.AddSourceLocation(E->getLocation(), Record);
335f4a2713aSLionel Sambuc   Record.push_back(E->getIdentType()); // FIXME: stable encoding
336*0a6a1f1dSLionel Sambuc   Writer.AddStmt(E->getFunctionName());
337f4a2713aSLionel Sambuc   Code = serialization::EXPR_PREDEFINED;
338f4a2713aSLionel Sambuc }
339f4a2713aSLionel Sambuc 
VisitDeclRefExpr(DeclRefExpr * E)340f4a2713aSLionel Sambuc void ASTStmtWriter::VisitDeclRefExpr(DeclRefExpr *E) {
341f4a2713aSLionel Sambuc   VisitExpr(E);
342f4a2713aSLionel Sambuc 
343f4a2713aSLionel Sambuc   Record.push_back(E->hasQualifier());
344f4a2713aSLionel Sambuc   Record.push_back(E->getDecl() != E->getFoundDecl());
345f4a2713aSLionel Sambuc   Record.push_back(E->hasTemplateKWAndArgsInfo());
346f4a2713aSLionel Sambuc   Record.push_back(E->hadMultipleCandidates());
347*0a6a1f1dSLionel Sambuc   Record.push_back(E->refersToEnclosingVariableOrCapture());
348f4a2713aSLionel Sambuc 
349f4a2713aSLionel Sambuc   if (E->hasTemplateKWAndArgsInfo()) {
350f4a2713aSLionel Sambuc     unsigned NumTemplateArgs = E->getNumTemplateArgs();
351f4a2713aSLionel Sambuc     Record.push_back(NumTemplateArgs);
352f4a2713aSLionel Sambuc   }
353f4a2713aSLionel Sambuc 
354f4a2713aSLionel Sambuc   DeclarationName::NameKind nk = (E->getDecl()->getDeclName().getNameKind());
355f4a2713aSLionel Sambuc 
356f4a2713aSLionel Sambuc   if ((!E->hasTemplateKWAndArgsInfo()) && (!E->hasQualifier()) &&
357f4a2713aSLionel Sambuc       (E->getDecl() == E->getFoundDecl()) &&
358f4a2713aSLionel Sambuc       nk == DeclarationName::Identifier) {
359f4a2713aSLionel Sambuc     AbbrevToUse = Writer.getDeclRefExprAbbrev();
360f4a2713aSLionel Sambuc   }
361f4a2713aSLionel Sambuc 
362f4a2713aSLionel Sambuc   if (E->hasQualifier())
363f4a2713aSLionel Sambuc     Writer.AddNestedNameSpecifierLoc(E->getQualifierLoc(), Record);
364f4a2713aSLionel Sambuc 
365f4a2713aSLionel Sambuc   if (E->getDecl() != E->getFoundDecl())
366f4a2713aSLionel Sambuc     Writer.AddDeclRef(E->getFoundDecl(), Record);
367f4a2713aSLionel Sambuc 
368f4a2713aSLionel Sambuc   if (E->hasTemplateKWAndArgsInfo())
369f4a2713aSLionel Sambuc     AddTemplateKWAndArgsInfo(*E->getTemplateKWAndArgsInfo());
370f4a2713aSLionel Sambuc 
371f4a2713aSLionel Sambuc   Writer.AddDeclRef(E->getDecl(), Record);
372f4a2713aSLionel Sambuc   Writer.AddSourceLocation(E->getLocation(), Record);
373f4a2713aSLionel Sambuc   Writer.AddDeclarationNameLoc(E->DNLoc, E->getDecl()->getDeclName(), Record);
374f4a2713aSLionel Sambuc   Code = serialization::EXPR_DECL_REF;
375f4a2713aSLionel Sambuc }
376f4a2713aSLionel Sambuc 
VisitIntegerLiteral(IntegerLiteral * E)377f4a2713aSLionel Sambuc void ASTStmtWriter::VisitIntegerLiteral(IntegerLiteral *E) {
378f4a2713aSLionel Sambuc   VisitExpr(E);
379f4a2713aSLionel Sambuc   Writer.AddSourceLocation(E->getLocation(), Record);
380f4a2713aSLionel Sambuc   Writer.AddAPInt(E->getValue(), Record);
381f4a2713aSLionel Sambuc 
382f4a2713aSLionel Sambuc   if (E->getValue().getBitWidth() == 32) {
383f4a2713aSLionel Sambuc     AbbrevToUse = Writer.getIntegerLiteralAbbrev();
384f4a2713aSLionel Sambuc   }
385f4a2713aSLionel Sambuc 
386f4a2713aSLionel Sambuc   Code = serialization::EXPR_INTEGER_LITERAL;
387f4a2713aSLionel Sambuc }
388f4a2713aSLionel Sambuc 
VisitFloatingLiteral(FloatingLiteral * E)389f4a2713aSLionel Sambuc void ASTStmtWriter::VisitFloatingLiteral(FloatingLiteral *E) {
390f4a2713aSLionel Sambuc   VisitExpr(E);
391f4a2713aSLionel Sambuc   Record.push_back(E->getRawSemantics());
392f4a2713aSLionel Sambuc   Record.push_back(E->isExact());
393f4a2713aSLionel Sambuc   Writer.AddAPFloat(E->getValue(), Record);
394f4a2713aSLionel Sambuc   Writer.AddSourceLocation(E->getLocation(), Record);
395f4a2713aSLionel Sambuc   Code = serialization::EXPR_FLOATING_LITERAL;
396f4a2713aSLionel Sambuc }
397f4a2713aSLionel Sambuc 
VisitImaginaryLiteral(ImaginaryLiteral * E)398f4a2713aSLionel Sambuc void ASTStmtWriter::VisitImaginaryLiteral(ImaginaryLiteral *E) {
399f4a2713aSLionel Sambuc   VisitExpr(E);
400f4a2713aSLionel Sambuc   Writer.AddStmt(E->getSubExpr());
401f4a2713aSLionel Sambuc   Code = serialization::EXPR_IMAGINARY_LITERAL;
402f4a2713aSLionel Sambuc }
403f4a2713aSLionel Sambuc 
VisitStringLiteral(StringLiteral * E)404f4a2713aSLionel Sambuc void ASTStmtWriter::VisitStringLiteral(StringLiteral *E) {
405f4a2713aSLionel Sambuc   VisitExpr(E);
406f4a2713aSLionel Sambuc   Record.push_back(E->getByteLength());
407f4a2713aSLionel Sambuc   Record.push_back(E->getNumConcatenated());
408f4a2713aSLionel Sambuc   Record.push_back(E->getKind());
409f4a2713aSLionel Sambuc   Record.push_back(E->isPascal());
410f4a2713aSLionel Sambuc   // FIXME: String data should be stored as a blob at the end of the
411f4a2713aSLionel Sambuc   // StringLiteral. However, we can't do so now because we have no
412f4a2713aSLionel Sambuc   // provision for coping with abbreviations when we're jumping around
413f4a2713aSLionel Sambuc   // the AST file during deserialization.
414f4a2713aSLionel Sambuc   Record.append(E->getBytes().begin(), E->getBytes().end());
415f4a2713aSLionel Sambuc   for (unsigned I = 0, N = E->getNumConcatenated(); I != N; ++I)
416f4a2713aSLionel Sambuc     Writer.AddSourceLocation(E->getStrTokenLoc(I), Record);
417f4a2713aSLionel Sambuc   Code = serialization::EXPR_STRING_LITERAL;
418f4a2713aSLionel Sambuc }
419f4a2713aSLionel Sambuc 
VisitCharacterLiteral(CharacterLiteral * E)420f4a2713aSLionel Sambuc void ASTStmtWriter::VisitCharacterLiteral(CharacterLiteral *E) {
421f4a2713aSLionel Sambuc   VisitExpr(E);
422f4a2713aSLionel Sambuc   Record.push_back(E->getValue());
423f4a2713aSLionel Sambuc   Writer.AddSourceLocation(E->getLocation(), Record);
424f4a2713aSLionel Sambuc   Record.push_back(E->getKind());
425f4a2713aSLionel Sambuc 
426f4a2713aSLionel Sambuc   AbbrevToUse = Writer.getCharacterLiteralAbbrev();
427f4a2713aSLionel Sambuc 
428f4a2713aSLionel Sambuc   Code = serialization::EXPR_CHARACTER_LITERAL;
429f4a2713aSLionel Sambuc }
430f4a2713aSLionel Sambuc 
VisitParenExpr(ParenExpr * E)431f4a2713aSLionel Sambuc void ASTStmtWriter::VisitParenExpr(ParenExpr *E) {
432f4a2713aSLionel Sambuc   VisitExpr(E);
433f4a2713aSLionel Sambuc   Writer.AddSourceLocation(E->getLParen(), Record);
434f4a2713aSLionel Sambuc   Writer.AddSourceLocation(E->getRParen(), Record);
435f4a2713aSLionel Sambuc   Writer.AddStmt(E->getSubExpr());
436f4a2713aSLionel Sambuc   Code = serialization::EXPR_PAREN;
437f4a2713aSLionel Sambuc }
438f4a2713aSLionel Sambuc 
VisitParenListExpr(ParenListExpr * E)439f4a2713aSLionel Sambuc void ASTStmtWriter::VisitParenListExpr(ParenListExpr *E) {
440f4a2713aSLionel Sambuc   VisitExpr(E);
441f4a2713aSLionel Sambuc   Record.push_back(E->NumExprs);
442f4a2713aSLionel Sambuc   for (unsigned i=0; i != E->NumExprs; ++i)
443f4a2713aSLionel Sambuc     Writer.AddStmt(E->Exprs[i]);
444f4a2713aSLionel Sambuc   Writer.AddSourceLocation(E->LParenLoc, Record);
445f4a2713aSLionel Sambuc   Writer.AddSourceLocation(E->RParenLoc, Record);
446f4a2713aSLionel Sambuc   Code = serialization::EXPR_PAREN_LIST;
447f4a2713aSLionel Sambuc }
448f4a2713aSLionel Sambuc 
VisitUnaryOperator(UnaryOperator * E)449f4a2713aSLionel Sambuc void ASTStmtWriter::VisitUnaryOperator(UnaryOperator *E) {
450f4a2713aSLionel Sambuc   VisitExpr(E);
451f4a2713aSLionel Sambuc   Writer.AddStmt(E->getSubExpr());
452f4a2713aSLionel Sambuc   Record.push_back(E->getOpcode()); // FIXME: stable encoding
453f4a2713aSLionel Sambuc   Writer.AddSourceLocation(E->getOperatorLoc(), Record);
454f4a2713aSLionel Sambuc   Code = serialization::EXPR_UNARY_OPERATOR;
455f4a2713aSLionel Sambuc }
456f4a2713aSLionel Sambuc 
VisitOffsetOfExpr(OffsetOfExpr * E)457f4a2713aSLionel Sambuc void ASTStmtWriter::VisitOffsetOfExpr(OffsetOfExpr *E) {
458f4a2713aSLionel Sambuc   VisitExpr(E);
459f4a2713aSLionel Sambuc   Record.push_back(E->getNumComponents());
460f4a2713aSLionel Sambuc   Record.push_back(E->getNumExpressions());
461f4a2713aSLionel Sambuc   Writer.AddSourceLocation(E->getOperatorLoc(), Record);
462f4a2713aSLionel Sambuc   Writer.AddSourceLocation(E->getRParenLoc(), Record);
463f4a2713aSLionel Sambuc   Writer.AddTypeSourceInfo(E->getTypeSourceInfo(), Record);
464f4a2713aSLionel Sambuc   for (unsigned I = 0, N = E->getNumComponents(); I != N; ++I) {
465f4a2713aSLionel Sambuc     const OffsetOfExpr::OffsetOfNode &ON = E->getComponent(I);
466f4a2713aSLionel Sambuc     Record.push_back(ON.getKind()); // FIXME: Stable encoding
467f4a2713aSLionel Sambuc     Writer.AddSourceLocation(ON.getSourceRange().getBegin(), Record);
468f4a2713aSLionel Sambuc     Writer.AddSourceLocation(ON.getSourceRange().getEnd(), Record);
469f4a2713aSLionel Sambuc     switch (ON.getKind()) {
470f4a2713aSLionel Sambuc     case OffsetOfExpr::OffsetOfNode::Array:
471f4a2713aSLionel Sambuc       Record.push_back(ON.getArrayExprIndex());
472f4a2713aSLionel Sambuc       break;
473f4a2713aSLionel Sambuc 
474f4a2713aSLionel Sambuc     case OffsetOfExpr::OffsetOfNode::Field:
475f4a2713aSLionel Sambuc       Writer.AddDeclRef(ON.getField(), Record);
476f4a2713aSLionel Sambuc       break;
477f4a2713aSLionel Sambuc 
478f4a2713aSLionel Sambuc     case OffsetOfExpr::OffsetOfNode::Identifier:
479f4a2713aSLionel Sambuc       Writer.AddIdentifierRef(ON.getFieldName(), Record);
480f4a2713aSLionel Sambuc       break;
481f4a2713aSLionel Sambuc 
482f4a2713aSLionel Sambuc     case OffsetOfExpr::OffsetOfNode::Base:
483f4a2713aSLionel Sambuc       Writer.AddCXXBaseSpecifier(*ON.getBase(), Record);
484f4a2713aSLionel Sambuc       break;
485f4a2713aSLionel Sambuc     }
486f4a2713aSLionel Sambuc   }
487f4a2713aSLionel Sambuc   for (unsigned I = 0, N = E->getNumExpressions(); I != N; ++I)
488f4a2713aSLionel Sambuc     Writer.AddStmt(E->getIndexExpr(I));
489f4a2713aSLionel Sambuc   Code = serialization::EXPR_OFFSETOF;
490f4a2713aSLionel Sambuc }
491f4a2713aSLionel Sambuc 
VisitUnaryExprOrTypeTraitExpr(UnaryExprOrTypeTraitExpr * E)492f4a2713aSLionel Sambuc void ASTStmtWriter::VisitUnaryExprOrTypeTraitExpr(UnaryExprOrTypeTraitExpr *E) {
493f4a2713aSLionel Sambuc   VisitExpr(E);
494f4a2713aSLionel Sambuc   Record.push_back(E->getKind());
495f4a2713aSLionel Sambuc   if (E->isArgumentType())
496f4a2713aSLionel Sambuc     Writer.AddTypeSourceInfo(E->getArgumentTypeInfo(), Record);
497f4a2713aSLionel Sambuc   else {
498f4a2713aSLionel Sambuc     Record.push_back(0);
499f4a2713aSLionel Sambuc     Writer.AddStmt(E->getArgumentExpr());
500f4a2713aSLionel Sambuc   }
501f4a2713aSLionel Sambuc   Writer.AddSourceLocation(E->getOperatorLoc(), Record);
502f4a2713aSLionel Sambuc   Writer.AddSourceLocation(E->getRParenLoc(), Record);
503f4a2713aSLionel Sambuc   Code = serialization::EXPR_SIZEOF_ALIGN_OF;
504f4a2713aSLionel Sambuc }
505f4a2713aSLionel Sambuc 
VisitArraySubscriptExpr(ArraySubscriptExpr * E)506f4a2713aSLionel Sambuc void ASTStmtWriter::VisitArraySubscriptExpr(ArraySubscriptExpr *E) {
507f4a2713aSLionel Sambuc   VisitExpr(E);
508f4a2713aSLionel Sambuc   Writer.AddStmt(E->getLHS());
509f4a2713aSLionel Sambuc   Writer.AddStmt(E->getRHS());
510f4a2713aSLionel Sambuc   Writer.AddSourceLocation(E->getRBracketLoc(), Record);
511f4a2713aSLionel Sambuc   Code = serialization::EXPR_ARRAY_SUBSCRIPT;
512f4a2713aSLionel Sambuc }
513f4a2713aSLionel Sambuc 
VisitCallExpr(CallExpr * E)514f4a2713aSLionel Sambuc void ASTStmtWriter::VisitCallExpr(CallExpr *E) {
515f4a2713aSLionel Sambuc   VisitExpr(E);
516f4a2713aSLionel Sambuc   Record.push_back(E->getNumArgs());
517f4a2713aSLionel Sambuc   Writer.AddSourceLocation(E->getRParenLoc(), Record);
518f4a2713aSLionel Sambuc   Writer.AddStmt(E->getCallee());
519f4a2713aSLionel Sambuc   for (CallExpr::arg_iterator Arg = E->arg_begin(), ArgEnd = E->arg_end();
520f4a2713aSLionel Sambuc        Arg != ArgEnd; ++Arg)
521f4a2713aSLionel Sambuc     Writer.AddStmt(*Arg);
522f4a2713aSLionel Sambuc   Code = serialization::EXPR_CALL;
523f4a2713aSLionel Sambuc }
524f4a2713aSLionel Sambuc 
VisitMemberExpr(MemberExpr * E)525f4a2713aSLionel Sambuc void ASTStmtWriter::VisitMemberExpr(MemberExpr *E) {
526f4a2713aSLionel Sambuc   // Don't call VisitExpr, we'll write everything here.
527f4a2713aSLionel Sambuc 
528f4a2713aSLionel Sambuc   Record.push_back(E->hasQualifier());
529f4a2713aSLionel Sambuc   if (E->hasQualifier())
530f4a2713aSLionel Sambuc     Writer.AddNestedNameSpecifierLoc(E->getQualifierLoc(), Record);
531f4a2713aSLionel Sambuc 
532f4a2713aSLionel Sambuc   Record.push_back(E->HasTemplateKWAndArgsInfo);
533f4a2713aSLionel Sambuc   if (E->HasTemplateKWAndArgsInfo) {
534f4a2713aSLionel Sambuc     Writer.AddSourceLocation(E->getTemplateKeywordLoc(), Record);
535f4a2713aSLionel Sambuc     unsigned NumTemplateArgs = E->getNumTemplateArgs();
536f4a2713aSLionel Sambuc     Record.push_back(NumTemplateArgs);
537f4a2713aSLionel Sambuc     Writer.AddSourceLocation(E->getLAngleLoc(), Record);
538f4a2713aSLionel Sambuc     Writer.AddSourceLocation(E->getRAngleLoc(), Record);
539f4a2713aSLionel Sambuc     for (unsigned i=0; i != NumTemplateArgs; ++i)
540f4a2713aSLionel Sambuc       Writer.AddTemplateArgumentLoc(E->getTemplateArgs()[i], Record);
541f4a2713aSLionel Sambuc   }
542f4a2713aSLionel Sambuc 
543f4a2713aSLionel Sambuc   Record.push_back(E->hadMultipleCandidates());
544f4a2713aSLionel Sambuc 
545f4a2713aSLionel Sambuc   DeclAccessPair FoundDecl = E->getFoundDecl();
546f4a2713aSLionel Sambuc   Writer.AddDeclRef(FoundDecl.getDecl(), Record);
547f4a2713aSLionel Sambuc   Record.push_back(FoundDecl.getAccess());
548f4a2713aSLionel Sambuc 
549f4a2713aSLionel Sambuc   Writer.AddTypeRef(E->getType(), Record);
550f4a2713aSLionel Sambuc   Record.push_back(E->getValueKind());
551f4a2713aSLionel Sambuc   Record.push_back(E->getObjectKind());
552f4a2713aSLionel Sambuc   Writer.AddStmt(E->getBase());
553f4a2713aSLionel Sambuc   Writer.AddDeclRef(E->getMemberDecl(), Record);
554f4a2713aSLionel Sambuc   Writer.AddSourceLocation(E->getMemberLoc(), Record);
555f4a2713aSLionel Sambuc   Record.push_back(E->isArrow());
556f4a2713aSLionel Sambuc   Writer.AddDeclarationNameLoc(E->MemberDNLoc,
557f4a2713aSLionel Sambuc                                E->getMemberDecl()->getDeclName(), Record);
558f4a2713aSLionel Sambuc   Code = serialization::EXPR_MEMBER;
559f4a2713aSLionel Sambuc }
560f4a2713aSLionel Sambuc 
VisitObjCIsaExpr(ObjCIsaExpr * E)561f4a2713aSLionel Sambuc void ASTStmtWriter::VisitObjCIsaExpr(ObjCIsaExpr *E) {
562f4a2713aSLionel Sambuc   VisitExpr(E);
563f4a2713aSLionel Sambuc   Writer.AddStmt(E->getBase());
564f4a2713aSLionel Sambuc   Writer.AddSourceLocation(E->getIsaMemberLoc(), Record);
565f4a2713aSLionel Sambuc   Writer.AddSourceLocation(E->getOpLoc(), Record);
566f4a2713aSLionel Sambuc   Record.push_back(E->isArrow());
567f4a2713aSLionel Sambuc   Code = serialization::EXPR_OBJC_ISA;
568f4a2713aSLionel Sambuc }
569f4a2713aSLionel Sambuc 
570f4a2713aSLionel Sambuc void ASTStmtWriter::
VisitObjCIndirectCopyRestoreExpr(ObjCIndirectCopyRestoreExpr * E)571f4a2713aSLionel Sambuc VisitObjCIndirectCopyRestoreExpr(ObjCIndirectCopyRestoreExpr *E) {
572f4a2713aSLionel Sambuc   VisitExpr(E);
573f4a2713aSLionel Sambuc   Writer.AddStmt(E->getSubExpr());
574f4a2713aSLionel Sambuc   Record.push_back(E->shouldCopy());
575f4a2713aSLionel Sambuc   Code = serialization::EXPR_OBJC_INDIRECT_COPY_RESTORE;
576f4a2713aSLionel Sambuc }
577f4a2713aSLionel Sambuc 
VisitObjCBridgedCastExpr(ObjCBridgedCastExpr * E)578f4a2713aSLionel Sambuc void ASTStmtWriter::VisitObjCBridgedCastExpr(ObjCBridgedCastExpr *E) {
579f4a2713aSLionel Sambuc   VisitExplicitCastExpr(E);
580f4a2713aSLionel Sambuc   Writer.AddSourceLocation(E->getLParenLoc(), Record);
581f4a2713aSLionel Sambuc   Writer.AddSourceLocation(E->getBridgeKeywordLoc(), Record);
582f4a2713aSLionel Sambuc   Record.push_back(E->getBridgeKind()); // FIXME: Stable encoding
583f4a2713aSLionel Sambuc   Code = serialization::EXPR_OBJC_BRIDGED_CAST;
584f4a2713aSLionel Sambuc }
585f4a2713aSLionel Sambuc 
VisitCastExpr(CastExpr * E)586f4a2713aSLionel Sambuc void ASTStmtWriter::VisitCastExpr(CastExpr *E) {
587f4a2713aSLionel Sambuc   VisitExpr(E);
588f4a2713aSLionel Sambuc   Record.push_back(E->path_size());
589f4a2713aSLionel Sambuc   Writer.AddStmt(E->getSubExpr());
590f4a2713aSLionel Sambuc   Record.push_back(E->getCastKind()); // FIXME: stable encoding
591f4a2713aSLionel Sambuc 
592f4a2713aSLionel Sambuc   for (CastExpr::path_iterator
593f4a2713aSLionel Sambuc          PI = E->path_begin(), PE = E->path_end(); PI != PE; ++PI)
594f4a2713aSLionel Sambuc     Writer.AddCXXBaseSpecifier(**PI, Record);
595f4a2713aSLionel Sambuc }
596f4a2713aSLionel Sambuc 
VisitBinaryOperator(BinaryOperator * E)597f4a2713aSLionel Sambuc void ASTStmtWriter::VisitBinaryOperator(BinaryOperator *E) {
598f4a2713aSLionel Sambuc   VisitExpr(E);
599f4a2713aSLionel Sambuc   Writer.AddStmt(E->getLHS());
600f4a2713aSLionel Sambuc   Writer.AddStmt(E->getRHS());
601f4a2713aSLionel Sambuc   Record.push_back(E->getOpcode()); // FIXME: stable encoding
602f4a2713aSLionel Sambuc   Writer.AddSourceLocation(E->getOperatorLoc(), Record);
603f4a2713aSLionel Sambuc   Record.push_back(E->isFPContractable());
604f4a2713aSLionel Sambuc   Code = serialization::EXPR_BINARY_OPERATOR;
605f4a2713aSLionel Sambuc }
606f4a2713aSLionel Sambuc 
VisitCompoundAssignOperator(CompoundAssignOperator * E)607f4a2713aSLionel Sambuc void ASTStmtWriter::VisitCompoundAssignOperator(CompoundAssignOperator *E) {
608f4a2713aSLionel Sambuc   VisitBinaryOperator(E);
609f4a2713aSLionel Sambuc   Writer.AddTypeRef(E->getComputationLHSType(), Record);
610f4a2713aSLionel Sambuc   Writer.AddTypeRef(E->getComputationResultType(), Record);
611f4a2713aSLionel Sambuc   Code = serialization::EXPR_COMPOUND_ASSIGN_OPERATOR;
612f4a2713aSLionel Sambuc }
613f4a2713aSLionel Sambuc 
VisitConditionalOperator(ConditionalOperator * E)614f4a2713aSLionel Sambuc void ASTStmtWriter::VisitConditionalOperator(ConditionalOperator *E) {
615f4a2713aSLionel Sambuc   VisitExpr(E);
616f4a2713aSLionel Sambuc   Writer.AddStmt(E->getCond());
617f4a2713aSLionel Sambuc   Writer.AddStmt(E->getLHS());
618f4a2713aSLionel Sambuc   Writer.AddStmt(E->getRHS());
619f4a2713aSLionel Sambuc   Writer.AddSourceLocation(E->getQuestionLoc(), Record);
620f4a2713aSLionel Sambuc   Writer.AddSourceLocation(E->getColonLoc(), Record);
621f4a2713aSLionel Sambuc   Code = serialization::EXPR_CONDITIONAL_OPERATOR;
622f4a2713aSLionel Sambuc }
623f4a2713aSLionel Sambuc 
624f4a2713aSLionel Sambuc void
VisitBinaryConditionalOperator(BinaryConditionalOperator * E)625f4a2713aSLionel Sambuc ASTStmtWriter::VisitBinaryConditionalOperator(BinaryConditionalOperator *E) {
626f4a2713aSLionel Sambuc   VisitExpr(E);
627f4a2713aSLionel Sambuc   Writer.AddStmt(E->getOpaqueValue());
628f4a2713aSLionel Sambuc   Writer.AddStmt(E->getCommon());
629f4a2713aSLionel Sambuc   Writer.AddStmt(E->getCond());
630f4a2713aSLionel Sambuc   Writer.AddStmt(E->getTrueExpr());
631f4a2713aSLionel Sambuc   Writer.AddStmt(E->getFalseExpr());
632f4a2713aSLionel Sambuc   Writer.AddSourceLocation(E->getQuestionLoc(), Record);
633f4a2713aSLionel Sambuc   Writer.AddSourceLocation(E->getColonLoc(), Record);
634f4a2713aSLionel Sambuc   Code = serialization::EXPR_BINARY_CONDITIONAL_OPERATOR;
635f4a2713aSLionel Sambuc }
636f4a2713aSLionel Sambuc 
VisitImplicitCastExpr(ImplicitCastExpr * E)637f4a2713aSLionel Sambuc void ASTStmtWriter::VisitImplicitCastExpr(ImplicitCastExpr *E) {
638f4a2713aSLionel Sambuc   VisitCastExpr(E);
639*0a6a1f1dSLionel Sambuc 
640*0a6a1f1dSLionel Sambuc   if (E->path_size() == 0)
641*0a6a1f1dSLionel Sambuc     AbbrevToUse = Writer.getExprImplicitCastAbbrev();
642*0a6a1f1dSLionel Sambuc 
643f4a2713aSLionel Sambuc   Code = serialization::EXPR_IMPLICIT_CAST;
644f4a2713aSLionel Sambuc }
645f4a2713aSLionel Sambuc 
VisitExplicitCastExpr(ExplicitCastExpr * E)646f4a2713aSLionel Sambuc void ASTStmtWriter::VisitExplicitCastExpr(ExplicitCastExpr *E) {
647f4a2713aSLionel Sambuc   VisitCastExpr(E);
648f4a2713aSLionel Sambuc   Writer.AddTypeSourceInfo(E->getTypeInfoAsWritten(), Record);
649f4a2713aSLionel Sambuc }
650f4a2713aSLionel Sambuc 
VisitCStyleCastExpr(CStyleCastExpr * E)651f4a2713aSLionel Sambuc void ASTStmtWriter::VisitCStyleCastExpr(CStyleCastExpr *E) {
652f4a2713aSLionel Sambuc   VisitExplicitCastExpr(E);
653f4a2713aSLionel Sambuc   Writer.AddSourceLocation(E->getLParenLoc(), Record);
654f4a2713aSLionel Sambuc   Writer.AddSourceLocation(E->getRParenLoc(), Record);
655f4a2713aSLionel Sambuc   Code = serialization::EXPR_CSTYLE_CAST;
656f4a2713aSLionel Sambuc }
657f4a2713aSLionel Sambuc 
VisitCompoundLiteralExpr(CompoundLiteralExpr * E)658f4a2713aSLionel Sambuc void ASTStmtWriter::VisitCompoundLiteralExpr(CompoundLiteralExpr *E) {
659f4a2713aSLionel Sambuc   VisitExpr(E);
660f4a2713aSLionel Sambuc   Writer.AddSourceLocation(E->getLParenLoc(), Record);
661f4a2713aSLionel Sambuc   Writer.AddTypeSourceInfo(E->getTypeSourceInfo(), Record);
662f4a2713aSLionel Sambuc   Writer.AddStmt(E->getInitializer());
663f4a2713aSLionel Sambuc   Record.push_back(E->isFileScope());
664f4a2713aSLionel Sambuc   Code = serialization::EXPR_COMPOUND_LITERAL;
665f4a2713aSLionel Sambuc }
666f4a2713aSLionel Sambuc 
VisitExtVectorElementExpr(ExtVectorElementExpr * E)667f4a2713aSLionel Sambuc void ASTStmtWriter::VisitExtVectorElementExpr(ExtVectorElementExpr *E) {
668f4a2713aSLionel Sambuc   VisitExpr(E);
669f4a2713aSLionel Sambuc   Writer.AddStmt(E->getBase());
670f4a2713aSLionel Sambuc   Writer.AddIdentifierRef(&E->getAccessor(), Record);
671f4a2713aSLionel Sambuc   Writer.AddSourceLocation(E->getAccessorLoc(), Record);
672f4a2713aSLionel Sambuc   Code = serialization::EXPR_EXT_VECTOR_ELEMENT;
673f4a2713aSLionel Sambuc }
674f4a2713aSLionel Sambuc 
VisitInitListExpr(InitListExpr * E)675f4a2713aSLionel Sambuc void ASTStmtWriter::VisitInitListExpr(InitListExpr *E) {
676f4a2713aSLionel Sambuc   VisitExpr(E);
677f4a2713aSLionel Sambuc   // NOTE: only add the (possibly null) syntactic form.
678f4a2713aSLionel Sambuc   // No need to serialize the isSemanticForm flag and the semantic form.
679f4a2713aSLionel Sambuc   Writer.AddStmt(E->getSyntacticForm());
680f4a2713aSLionel Sambuc   Writer.AddSourceLocation(E->getLBraceLoc(), Record);
681f4a2713aSLionel Sambuc   Writer.AddSourceLocation(E->getRBraceLoc(), Record);
682f4a2713aSLionel Sambuc   bool isArrayFiller = E->ArrayFillerOrUnionFieldInit.is<Expr*>();
683f4a2713aSLionel Sambuc   Record.push_back(isArrayFiller);
684f4a2713aSLionel Sambuc   if (isArrayFiller)
685f4a2713aSLionel Sambuc     Writer.AddStmt(E->getArrayFiller());
686f4a2713aSLionel Sambuc   else
687f4a2713aSLionel Sambuc     Writer.AddDeclRef(E->getInitializedFieldInUnion(), Record);
688f4a2713aSLionel Sambuc   Record.push_back(E->hadArrayRangeDesignator());
689f4a2713aSLionel Sambuc   Record.push_back(E->getNumInits());
690f4a2713aSLionel Sambuc   if (isArrayFiller) {
691f4a2713aSLionel Sambuc     // ArrayFiller may have filled "holes" due to designated initializer.
692f4a2713aSLionel Sambuc     // Replace them by 0 to indicate that the filler goes in that place.
693f4a2713aSLionel Sambuc     Expr *filler = E->getArrayFiller();
694f4a2713aSLionel Sambuc     for (unsigned I = 0, N = E->getNumInits(); I != N; ++I)
695*0a6a1f1dSLionel Sambuc       Writer.AddStmt(E->getInit(I) != filler ? E->getInit(I) : nullptr);
696f4a2713aSLionel Sambuc   } else {
697f4a2713aSLionel Sambuc     for (unsigned I = 0, N = E->getNumInits(); I != N; ++I)
698f4a2713aSLionel Sambuc       Writer.AddStmt(E->getInit(I));
699f4a2713aSLionel Sambuc   }
700f4a2713aSLionel Sambuc   Code = serialization::EXPR_INIT_LIST;
701f4a2713aSLionel Sambuc }
702f4a2713aSLionel Sambuc 
VisitDesignatedInitExpr(DesignatedInitExpr * E)703f4a2713aSLionel Sambuc void ASTStmtWriter::VisitDesignatedInitExpr(DesignatedInitExpr *E) {
704f4a2713aSLionel Sambuc   VisitExpr(E);
705f4a2713aSLionel Sambuc   Record.push_back(E->getNumSubExprs());
706f4a2713aSLionel Sambuc   for (unsigned I = 0, N = E->getNumSubExprs(); I != N; ++I)
707f4a2713aSLionel Sambuc     Writer.AddStmt(E->getSubExpr(I));
708f4a2713aSLionel Sambuc   Writer.AddSourceLocation(E->getEqualOrColonLoc(), Record);
709f4a2713aSLionel Sambuc   Record.push_back(E->usesGNUSyntax());
710f4a2713aSLionel Sambuc   for (DesignatedInitExpr::designators_iterator D = E->designators_begin(),
711f4a2713aSLionel Sambuc                                              DEnd = E->designators_end();
712f4a2713aSLionel Sambuc        D != DEnd; ++D) {
713f4a2713aSLionel Sambuc     if (D->isFieldDesignator()) {
714f4a2713aSLionel Sambuc       if (FieldDecl *Field = D->getField()) {
715f4a2713aSLionel Sambuc         Record.push_back(serialization::DESIG_FIELD_DECL);
716f4a2713aSLionel Sambuc         Writer.AddDeclRef(Field, Record);
717f4a2713aSLionel Sambuc       } else {
718f4a2713aSLionel Sambuc         Record.push_back(serialization::DESIG_FIELD_NAME);
719f4a2713aSLionel Sambuc         Writer.AddIdentifierRef(D->getFieldName(), Record);
720f4a2713aSLionel Sambuc       }
721f4a2713aSLionel Sambuc       Writer.AddSourceLocation(D->getDotLoc(), Record);
722f4a2713aSLionel Sambuc       Writer.AddSourceLocation(D->getFieldLoc(), Record);
723f4a2713aSLionel Sambuc     } else if (D->isArrayDesignator()) {
724f4a2713aSLionel Sambuc       Record.push_back(serialization::DESIG_ARRAY);
725f4a2713aSLionel Sambuc       Record.push_back(D->getFirstExprIndex());
726f4a2713aSLionel Sambuc       Writer.AddSourceLocation(D->getLBracketLoc(), Record);
727f4a2713aSLionel Sambuc       Writer.AddSourceLocation(D->getRBracketLoc(), Record);
728f4a2713aSLionel Sambuc     } else {
729f4a2713aSLionel Sambuc       assert(D->isArrayRangeDesignator() && "Unknown designator");
730f4a2713aSLionel Sambuc       Record.push_back(serialization::DESIG_ARRAY_RANGE);
731f4a2713aSLionel Sambuc       Record.push_back(D->getFirstExprIndex());
732f4a2713aSLionel Sambuc       Writer.AddSourceLocation(D->getLBracketLoc(), Record);
733f4a2713aSLionel Sambuc       Writer.AddSourceLocation(D->getEllipsisLoc(), Record);
734f4a2713aSLionel Sambuc       Writer.AddSourceLocation(D->getRBracketLoc(), Record);
735f4a2713aSLionel Sambuc     }
736f4a2713aSLionel Sambuc   }
737f4a2713aSLionel Sambuc   Code = serialization::EXPR_DESIGNATED_INIT;
738f4a2713aSLionel Sambuc }
739f4a2713aSLionel Sambuc 
VisitImplicitValueInitExpr(ImplicitValueInitExpr * E)740f4a2713aSLionel Sambuc void ASTStmtWriter::VisitImplicitValueInitExpr(ImplicitValueInitExpr *E) {
741f4a2713aSLionel Sambuc   VisitExpr(E);
742f4a2713aSLionel Sambuc   Code = serialization::EXPR_IMPLICIT_VALUE_INIT;
743f4a2713aSLionel Sambuc }
744f4a2713aSLionel Sambuc 
VisitVAArgExpr(VAArgExpr * E)745f4a2713aSLionel Sambuc void ASTStmtWriter::VisitVAArgExpr(VAArgExpr *E) {
746f4a2713aSLionel Sambuc   VisitExpr(E);
747f4a2713aSLionel Sambuc   Writer.AddStmt(E->getSubExpr());
748f4a2713aSLionel Sambuc   Writer.AddTypeSourceInfo(E->getWrittenTypeInfo(), Record);
749f4a2713aSLionel Sambuc   Writer.AddSourceLocation(E->getBuiltinLoc(), Record);
750f4a2713aSLionel Sambuc   Writer.AddSourceLocation(E->getRParenLoc(), Record);
751f4a2713aSLionel Sambuc   Code = serialization::EXPR_VA_ARG;
752f4a2713aSLionel Sambuc }
753f4a2713aSLionel Sambuc 
VisitAddrLabelExpr(AddrLabelExpr * E)754f4a2713aSLionel Sambuc void ASTStmtWriter::VisitAddrLabelExpr(AddrLabelExpr *E) {
755f4a2713aSLionel Sambuc   VisitExpr(E);
756f4a2713aSLionel Sambuc   Writer.AddSourceLocation(E->getAmpAmpLoc(), Record);
757f4a2713aSLionel Sambuc   Writer.AddSourceLocation(E->getLabelLoc(), Record);
758f4a2713aSLionel Sambuc   Writer.AddDeclRef(E->getLabel(), Record);
759f4a2713aSLionel Sambuc   Code = serialization::EXPR_ADDR_LABEL;
760f4a2713aSLionel Sambuc }
761f4a2713aSLionel Sambuc 
VisitStmtExpr(StmtExpr * E)762f4a2713aSLionel Sambuc void ASTStmtWriter::VisitStmtExpr(StmtExpr *E) {
763f4a2713aSLionel Sambuc   VisitExpr(E);
764f4a2713aSLionel Sambuc   Writer.AddStmt(E->getSubStmt());
765f4a2713aSLionel Sambuc   Writer.AddSourceLocation(E->getLParenLoc(), Record);
766f4a2713aSLionel Sambuc   Writer.AddSourceLocation(E->getRParenLoc(), Record);
767f4a2713aSLionel Sambuc   Code = serialization::EXPR_STMT;
768f4a2713aSLionel Sambuc }
769f4a2713aSLionel Sambuc 
VisitChooseExpr(ChooseExpr * E)770f4a2713aSLionel Sambuc void ASTStmtWriter::VisitChooseExpr(ChooseExpr *E) {
771f4a2713aSLionel Sambuc   VisitExpr(E);
772f4a2713aSLionel Sambuc   Writer.AddStmt(E->getCond());
773f4a2713aSLionel Sambuc   Writer.AddStmt(E->getLHS());
774f4a2713aSLionel Sambuc   Writer.AddStmt(E->getRHS());
775f4a2713aSLionel Sambuc   Writer.AddSourceLocation(E->getBuiltinLoc(), Record);
776f4a2713aSLionel Sambuc   Writer.AddSourceLocation(E->getRParenLoc(), Record);
777f4a2713aSLionel Sambuc   Record.push_back(E->isConditionDependent() ? false : E->isConditionTrue());
778f4a2713aSLionel Sambuc   Code = serialization::EXPR_CHOOSE;
779f4a2713aSLionel Sambuc }
780f4a2713aSLionel Sambuc 
VisitGNUNullExpr(GNUNullExpr * E)781f4a2713aSLionel Sambuc void ASTStmtWriter::VisitGNUNullExpr(GNUNullExpr *E) {
782f4a2713aSLionel Sambuc   VisitExpr(E);
783f4a2713aSLionel Sambuc   Writer.AddSourceLocation(E->getTokenLocation(), Record);
784f4a2713aSLionel Sambuc   Code = serialization::EXPR_GNU_NULL;
785f4a2713aSLionel Sambuc }
786f4a2713aSLionel Sambuc 
VisitShuffleVectorExpr(ShuffleVectorExpr * E)787f4a2713aSLionel Sambuc void ASTStmtWriter::VisitShuffleVectorExpr(ShuffleVectorExpr *E) {
788f4a2713aSLionel Sambuc   VisitExpr(E);
789f4a2713aSLionel Sambuc   Record.push_back(E->getNumSubExprs());
790f4a2713aSLionel Sambuc   for (unsigned I = 0, N = E->getNumSubExprs(); I != N; ++I)
791f4a2713aSLionel Sambuc     Writer.AddStmt(E->getExpr(I));
792f4a2713aSLionel Sambuc   Writer.AddSourceLocation(E->getBuiltinLoc(), Record);
793f4a2713aSLionel Sambuc   Writer.AddSourceLocation(E->getRParenLoc(), Record);
794f4a2713aSLionel Sambuc   Code = serialization::EXPR_SHUFFLE_VECTOR;
795f4a2713aSLionel Sambuc }
796f4a2713aSLionel Sambuc 
VisitConvertVectorExpr(ConvertVectorExpr * E)797f4a2713aSLionel Sambuc void ASTStmtWriter::VisitConvertVectorExpr(ConvertVectorExpr *E) {
798f4a2713aSLionel Sambuc   VisitExpr(E);
799f4a2713aSLionel Sambuc   Writer.AddSourceLocation(E->getBuiltinLoc(), Record);
800f4a2713aSLionel Sambuc   Writer.AddSourceLocation(E->getRParenLoc(), Record);
801f4a2713aSLionel Sambuc   Writer.AddTypeSourceInfo(E->getTypeSourceInfo(), Record);
802f4a2713aSLionel Sambuc   Writer.AddStmt(E->getSrcExpr());
803f4a2713aSLionel Sambuc   Code = serialization::EXPR_CONVERT_VECTOR;
804f4a2713aSLionel Sambuc }
805f4a2713aSLionel Sambuc 
VisitBlockExpr(BlockExpr * E)806f4a2713aSLionel Sambuc void ASTStmtWriter::VisitBlockExpr(BlockExpr *E) {
807f4a2713aSLionel Sambuc   VisitExpr(E);
808f4a2713aSLionel Sambuc   Writer.AddDeclRef(E->getBlockDecl(), Record);
809f4a2713aSLionel Sambuc   Code = serialization::EXPR_BLOCK;
810f4a2713aSLionel Sambuc }
811f4a2713aSLionel Sambuc 
VisitGenericSelectionExpr(GenericSelectionExpr * E)812f4a2713aSLionel Sambuc void ASTStmtWriter::VisitGenericSelectionExpr(GenericSelectionExpr *E) {
813f4a2713aSLionel Sambuc   VisitExpr(E);
814f4a2713aSLionel Sambuc   Record.push_back(E->getNumAssocs());
815f4a2713aSLionel Sambuc 
816f4a2713aSLionel Sambuc   Writer.AddStmt(E->getControllingExpr());
817f4a2713aSLionel Sambuc   for (unsigned I = 0, N = E->getNumAssocs(); I != N; ++I) {
818f4a2713aSLionel Sambuc     Writer.AddTypeSourceInfo(E->getAssocTypeSourceInfo(I), Record);
819f4a2713aSLionel Sambuc     Writer.AddStmt(E->getAssocExpr(I));
820f4a2713aSLionel Sambuc   }
821f4a2713aSLionel Sambuc   Record.push_back(E->isResultDependent() ? -1U : E->getResultIndex());
822f4a2713aSLionel Sambuc 
823f4a2713aSLionel Sambuc   Writer.AddSourceLocation(E->getGenericLoc(), Record);
824f4a2713aSLionel Sambuc   Writer.AddSourceLocation(E->getDefaultLoc(), Record);
825f4a2713aSLionel Sambuc   Writer.AddSourceLocation(E->getRParenLoc(), Record);
826f4a2713aSLionel Sambuc   Code = serialization::EXPR_GENERIC_SELECTION;
827f4a2713aSLionel Sambuc }
828f4a2713aSLionel Sambuc 
VisitPseudoObjectExpr(PseudoObjectExpr * E)829f4a2713aSLionel Sambuc void ASTStmtWriter::VisitPseudoObjectExpr(PseudoObjectExpr *E) {
830f4a2713aSLionel Sambuc   VisitExpr(E);
831f4a2713aSLionel Sambuc   Record.push_back(E->getNumSemanticExprs());
832f4a2713aSLionel Sambuc 
833f4a2713aSLionel Sambuc   // Push the result index.  Currently, this needs to exactly match
834f4a2713aSLionel Sambuc   // the encoding used internally for ResultIndex.
835f4a2713aSLionel Sambuc   unsigned result = E->getResultExprIndex();
836f4a2713aSLionel Sambuc   result = (result == PseudoObjectExpr::NoResult ? 0 : result + 1);
837f4a2713aSLionel Sambuc   Record.push_back(result);
838f4a2713aSLionel Sambuc 
839f4a2713aSLionel Sambuc   Writer.AddStmt(E->getSyntacticForm());
840f4a2713aSLionel Sambuc   for (PseudoObjectExpr::semantics_iterator
841f4a2713aSLionel Sambuc          i = E->semantics_begin(), e = E->semantics_end(); i != e; ++i) {
842f4a2713aSLionel Sambuc     Writer.AddStmt(*i);
843f4a2713aSLionel Sambuc   }
844f4a2713aSLionel Sambuc   Code = serialization::EXPR_PSEUDO_OBJECT;
845f4a2713aSLionel Sambuc }
846f4a2713aSLionel Sambuc 
VisitAtomicExpr(AtomicExpr * E)847f4a2713aSLionel Sambuc void ASTStmtWriter::VisitAtomicExpr(AtomicExpr *E) {
848f4a2713aSLionel Sambuc   VisitExpr(E);
849f4a2713aSLionel Sambuc   Record.push_back(E->getOp());
850f4a2713aSLionel Sambuc   for (unsigned I = 0, N = E->getNumSubExprs(); I != N; ++I)
851f4a2713aSLionel Sambuc     Writer.AddStmt(E->getSubExprs()[I]);
852f4a2713aSLionel Sambuc   Writer.AddSourceLocation(E->getBuiltinLoc(), Record);
853f4a2713aSLionel Sambuc   Writer.AddSourceLocation(E->getRParenLoc(), Record);
854f4a2713aSLionel Sambuc   Code = serialization::EXPR_ATOMIC;
855f4a2713aSLionel Sambuc }
856f4a2713aSLionel Sambuc 
857f4a2713aSLionel Sambuc //===----------------------------------------------------------------------===//
858f4a2713aSLionel Sambuc // Objective-C Expressions and Statements.
859f4a2713aSLionel Sambuc //===----------------------------------------------------------------------===//
860f4a2713aSLionel Sambuc 
VisitObjCStringLiteral(ObjCStringLiteral * E)861f4a2713aSLionel Sambuc void ASTStmtWriter::VisitObjCStringLiteral(ObjCStringLiteral *E) {
862f4a2713aSLionel Sambuc   VisitExpr(E);
863f4a2713aSLionel Sambuc   Writer.AddStmt(E->getString());
864f4a2713aSLionel Sambuc   Writer.AddSourceLocation(E->getAtLoc(), Record);
865f4a2713aSLionel Sambuc   Code = serialization::EXPR_OBJC_STRING_LITERAL;
866f4a2713aSLionel Sambuc }
867f4a2713aSLionel Sambuc 
VisitObjCBoxedExpr(ObjCBoxedExpr * E)868f4a2713aSLionel Sambuc void ASTStmtWriter::VisitObjCBoxedExpr(ObjCBoxedExpr *E) {
869f4a2713aSLionel Sambuc   VisitExpr(E);
870f4a2713aSLionel Sambuc   Writer.AddStmt(E->getSubExpr());
871f4a2713aSLionel Sambuc   Writer.AddDeclRef(E->getBoxingMethod(), Record);
872f4a2713aSLionel Sambuc   Writer.AddSourceRange(E->getSourceRange(), Record);
873f4a2713aSLionel Sambuc   Code = serialization::EXPR_OBJC_BOXED_EXPRESSION;
874f4a2713aSLionel Sambuc }
875f4a2713aSLionel Sambuc 
VisitObjCArrayLiteral(ObjCArrayLiteral * E)876f4a2713aSLionel Sambuc void ASTStmtWriter::VisitObjCArrayLiteral(ObjCArrayLiteral *E) {
877f4a2713aSLionel Sambuc   VisitExpr(E);
878f4a2713aSLionel Sambuc   Record.push_back(E->getNumElements());
879f4a2713aSLionel Sambuc   for (unsigned i = 0; i < E->getNumElements(); i++)
880f4a2713aSLionel Sambuc     Writer.AddStmt(E->getElement(i));
881f4a2713aSLionel Sambuc   Writer.AddDeclRef(E->getArrayWithObjectsMethod(), Record);
882f4a2713aSLionel Sambuc   Writer.AddSourceRange(E->getSourceRange(), Record);
883f4a2713aSLionel Sambuc   Code = serialization::EXPR_OBJC_ARRAY_LITERAL;
884f4a2713aSLionel Sambuc }
885f4a2713aSLionel Sambuc 
VisitObjCDictionaryLiteral(ObjCDictionaryLiteral * E)886f4a2713aSLionel Sambuc void ASTStmtWriter::VisitObjCDictionaryLiteral(ObjCDictionaryLiteral *E) {
887f4a2713aSLionel Sambuc   VisitExpr(E);
888f4a2713aSLionel Sambuc   Record.push_back(E->getNumElements());
889f4a2713aSLionel Sambuc   Record.push_back(E->HasPackExpansions);
890f4a2713aSLionel Sambuc   for (unsigned i = 0; i < E->getNumElements(); i++) {
891f4a2713aSLionel Sambuc     ObjCDictionaryElement Element = E->getKeyValueElement(i);
892f4a2713aSLionel Sambuc     Writer.AddStmt(Element.Key);
893f4a2713aSLionel Sambuc     Writer.AddStmt(Element.Value);
894f4a2713aSLionel Sambuc     if (E->HasPackExpansions) {
895f4a2713aSLionel Sambuc       Writer.AddSourceLocation(Element.EllipsisLoc, Record);
896f4a2713aSLionel Sambuc       unsigned NumExpansions = 0;
897f4a2713aSLionel Sambuc       if (Element.NumExpansions)
898f4a2713aSLionel Sambuc         NumExpansions = *Element.NumExpansions + 1;
899f4a2713aSLionel Sambuc       Record.push_back(NumExpansions);
900f4a2713aSLionel Sambuc     }
901f4a2713aSLionel Sambuc   }
902f4a2713aSLionel Sambuc 
903f4a2713aSLionel Sambuc   Writer.AddDeclRef(E->getDictWithObjectsMethod(), Record);
904f4a2713aSLionel Sambuc   Writer.AddSourceRange(E->getSourceRange(), Record);
905f4a2713aSLionel Sambuc   Code = serialization::EXPR_OBJC_DICTIONARY_LITERAL;
906f4a2713aSLionel Sambuc }
907f4a2713aSLionel Sambuc 
VisitObjCEncodeExpr(ObjCEncodeExpr * E)908f4a2713aSLionel Sambuc void ASTStmtWriter::VisitObjCEncodeExpr(ObjCEncodeExpr *E) {
909f4a2713aSLionel Sambuc   VisitExpr(E);
910f4a2713aSLionel Sambuc   Writer.AddTypeSourceInfo(E->getEncodedTypeSourceInfo(), Record);
911f4a2713aSLionel Sambuc   Writer.AddSourceLocation(E->getAtLoc(), Record);
912f4a2713aSLionel Sambuc   Writer.AddSourceLocation(E->getRParenLoc(), Record);
913f4a2713aSLionel Sambuc   Code = serialization::EXPR_OBJC_ENCODE;
914f4a2713aSLionel Sambuc }
915f4a2713aSLionel Sambuc 
VisitObjCSelectorExpr(ObjCSelectorExpr * E)916f4a2713aSLionel Sambuc void ASTStmtWriter::VisitObjCSelectorExpr(ObjCSelectorExpr *E) {
917f4a2713aSLionel Sambuc   VisitExpr(E);
918f4a2713aSLionel Sambuc   Writer.AddSelectorRef(E->getSelector(), Record);
919f4a2713aSLionel Sambuc   Writer.AddSourceLocation(E->getAtLoc(), Record);
920f4a2713aSLionel Sambuc   Writer.AddSourceLocation(E->getRParenLoc(), Record);
921f4a2713aSLionel Sambuc   Code = serialization::EXPR_OBJC_SELECTOR_EXPR;
922f4a2713aSLionel Sambuc }
923f4a2713aSLionel Sambuc 
VisitObjCProtocolExpr(ObjCProtocolExpr * E)924f4a2713aSLionel Sambuc void ASTStmtWriter::VisitObjCProtocolExpr(ObjCProtocolExpr *E) {
925f4a2713aSLionel Sambuc   VisitExpr(E);
926f4a2713aSLionel Sambuc   Writer.AddDeclRef(E->getProtocol(), Record);
927f4a2713aSLionel Sambuc   Writer.AddSourceLocation(E->getAtLoc(), Record);
928f4a2713aSLionel Sambuc   Writer.AddSourceLocation(E->ProtoLoc, Record);
929f4a2713aSLionel Sambuc   Writer.AddSourceLocation(E->getRParenLoc(), Record);
930f4a2713aSLionel Sambuc   Code = serialization::EXPR_OBJC_PROTOCOL_EXPR;
931f4a2713aSLionel Sambuc }
932f4a2713aSLionel Sambuc 
VisitObjCIvarRefExpr(ObjCIvarRefExpr * E)933f4a2713aSLionel Sambuc void ASTStmtWriter::VisitObjCIvarRefExpr(ObjCIvarRefExpr *E) {
934f4a2713aSLionel Sambuc   VisitExpr(E);
935f4a2713aSLionel Sambuc   Writer.AddDeclRef(E->getDecl(), Record);
936f4a2713aSLionel Sambuc   Writer.AddSourceLocation(E->getLocation(), Record);
937f4a2713aSLionel Sambuc   Writer.AddSourceLocation(E->getOpLoc(), Record);
938f4a2713aSLionel Sambuc   Writer.AddStmt(E->getBase());
939f4a2713aSLionel Sambuc   Record.push_back(E->isArrow());
940f4a2713aSLionel Sambuc   Record.push_back(E->isFreeIvar());
941f4a2713aSLionel Sambuc   Code = serialization::EXPR_OBJC_IVAR_REF_EXPR;
942f4a2713aSLionel Sambuc }
943f4a2713aSLionel Sambuc 
VisitObjCPropertyRefExpr(ObjCPropertyRefExpr * E)944f4a2713aSLionel Sambuc void ASTStmtWriter::VisitObjCPropertyRefExpr(ObjCPropertyRefExpr *E) {
945f4a2713aSLionel Sambuc   VisitExpr(E);
946f4a2713aSLionel Sambuc   Record.push_back(E->SetterAndMethodRefFlags.getInt());
947f4a2713aSLionel Sambuc   Record.push_back(E->isImplicitProperty());
948f4a2713aSLionel Sambuc   if (E->isImplicitProperty()) {
949f4a2713aSLionel Sambuc     Writer.AddDeclRef(E->getImplicitPropertyGetter(), Record);
950f4a2713aSLionel Sambuc     Writer.AddDeclRef(E->getImplicitPropertySetter(), Record);
951f4a2713aSLionel Sambuc   } else {
952f4a2713aSLionel Sambuc     Writer.AddDeclRef(E->getExplicitProperty(), Record);
953f4a2713aSLionel Sambuc   }
954f4a2713aSLionel Sambuc   Writer.AddSourceLocation(E->getLocation(), Record);
955f4a2713aSLionel Sambuc   Writer.AddSourceLocation(E->getReceiverLocation(), Record);
956f4a2713aSLionel Sambuc   if (E->isObjectReceiver()) {
957f4a2713aSLionel Sambuc     Record.push_back(0);
958f4a2713aSLionel Sambuc     Writer.AddStmt(E->getBase());
959f4a2713aSLionel Sambuc   } else if (E->isSuperReceiver()) {
960f4a2713aSLionel Sambuc     Record.push_back(1);
961f4a2713aSLionel Sambuc     Writer.AddTypeRef(E->getSuperReceiverType(), Record);
962f4a2713aSLionel Sambuc   } else {
963f4a2713aSLionel Sambuc     Record.push_back(2);
964f4a2713aSLionel Sambuc     Writer.AddDeclRef(E->getClassReceiver(), Record);
965f4a2713aSLionel Sambuc   }
966f4a2713aSLionel Sambuc 
967f4a2713aSLionel Sambuc   Code = serialization::EXPR_OBJC_PROPERTY_REF_EXPR;
968f4a2713aSLionel Sambuc }
969f4a2713aSLionel Sambuc 
VisitObjCSubscriptRefExpr(ObjCSubscriptRefExpr * E)970f4a2713aSLionel Sambuc void ASTStmtWriter::VisitObjCSubscriptRefExpr(ObjCSubscriptRefExpr *E) {
971f4a2713aSLionel Sambuc   VisitExpr(E);
972f4a2713aSLionel Sambuc   Writer.AddSourceLocation(E->getRBracket(), Record);
973f4a2713aSLionel Sambuc   Writer.AddStmt(E->getBaseExpr());
974f4a2713aSLionel Sambuc   Writer.AddStmt(E->getKeyExpr());
975f4a2713aSLionel Sambuc   Writer.AddDeclRef(E->getAtIndexMethodDecl(), Record);
976f4a2713aSLionel Sambuc   Writer.AddDeclRef(E->setAtIndexMethodDecl(), Record);
977f4a2713aSLionel Sambuc 
978f4a2713aSLionel Sambuc   Code = serialization::EXPR_OBJC_SUBSCRIPT_REF_EXPR;
979f4a2713aSLionel Sambuc }
980f4a2713aSLionel Sambuc 
VisitObjCMessageExpr(ObjCMessageExpr * E)981f4a2713aSLionel Sambuc void ASTStmtWriter::VisitObjCMessageExpr(ObjCMessageExpr *E) {
982f4a2713aSLionel Sambuc   VisitExpr(E);
983f4a2713aSLionel Sambuc   Record.push_back(E->getNumArgs());
984f4a2713aSLionel Sambuc   Record.push_back(E->getNumStoredSelLocs());
985f4a2713aSLionel Sambuc   Record.push_back(E->SelLocsKind);
986f4a2713aSLionel Sambuc   Record.push_back(E->isDelegateInitCall());
987f4a2713aSLionel Sambuc   Record.push_back(E->IsImplicit);
988f4a2713aSLionel Sambuc   Record.push_back((unsigned)E->getReceiverKind()); // FIXME: stable encoding
989f4a2713aSLionel Sambuc   switch (E->getReceiverKind()) {
990f4a2713aSLionel Sambuc   case ObjCMessageExpr::Instance:
991f4a2713aSLionel Sambuc     Writer.AddStmt(E->getInstanceReceiver());
992f4a2713aSLionel Sambuc     break;
993f4a2713aSLionel Sambuc 
994f4a2713aSLionel Sambuc   case ObjCMessageExpr::Class:
995f4a2713aSLionel Sambuc     Writer.AddTypeSourceInfo(E->getClassReceiverTypeInfo(), Record);
996f4a2713aSLionel Sambuc     break;
997f4a2713aSLionel Sambuc 
998f4a2713aSLionel Sambuc   case ObjCMessageExpr::SuperClass:
999f4a2713aSLionel Sambuc   case ObjCMessageExpr::SuperInstance:
1000f4a2713aSLionel Sambuc     Writer.AddTypeRef(E->getSuperType(), Record);
1001f4a2713aSLionel Sambuc     Writer.AddSourceLocation(E->getSuperLoc(), Record);
1002f4a2713aSLionel Sambuc     break;
1003f4a2713aSLionel Sambuc   }
1004f4a2713aSLionel Sambuc 
1005f4a2713aSLionel Sambuc   if (E->getMethodDecl()) {
1006f4a2713aSLionel Sambuc     Record.push_back(1);
1007f4a2713aSLionel Sambuc     Writer.AddDeclRef(E->getMethodDecl(), Record);
1008f4a2713aSLionel Sambuc   } else {
1009f4a2713aSLionel Sambuc     Record.push_back(0);
1010f4a2713aSLionel Sambuc     Writer.AddSelectorRef(E->getSelector(), Record);
1011f4a2713aSLionel Sambuc   }
1012f4a2713aSLionel Sambuc 
1013f4a2713aSLionel Sambuc   Writer.AddSourceLocation(E->getLeftLoc(), Record);
1014f4a2713aSLionel Sambuc   Writer.AddSourceLocation(E->getRightLoc(), Record);
1015f4a2713aSLionel Sambuc 
1016f4a2713aSLionel Sambuc   for (CallExpr::arg_iterator Arg = E->arg_begin(), ArgEnd = E->arg_end();
1017f4a2713aSLionel Sambuc        Arg != ArgEnd; ++Arg)
1018f4a2713aSLionel Sambuc     Writer.AddStmt(*Arg);
1019f4a2713aSLionel Sambuc 
1020f4a2713aSLionel Sambuc   SourceLocation *Locs = E->getStoredSelLocs();
1021f4a2713aSLionel Sambuc   for (unsigned i = 0, e = E->getNumStoredSelLocs(); i != e; ++i)
1022f4a2713aSLionel Sambuc     Writer.AddSourceLocation(Locs[i], Record);
1023f4a2713aSLionel Sambuc 
1024f4a2713aSLionel Sambuc   Code = serialization::EXPR_OBJC_MESSAGE_EXPR;
1025f4a2713aSLionel Sambuc }
1026f4a2713aSLionel Sambuc 
VisitObjCForCollectionStmt(ObjCForCollectionStmt * S)1027f4a2713aSLionel Sambuc void ASTStmtWriter::VisitObjCForCollectionStmt(ObjCForCollectionStmt *S) {
1028f4a2713aSLionel Sambuc   VisitStmt(S);
1029f4a2713aSLionel Sambuc   Writer.AddStmt(S->getElement());
1030f4a2713aSLionel Sambuc   Writer.AddStmt(S->getCollection());
1031f4a2713aSLionel Sambuc   Writer.AddStmt(S->getBody());
1032f4a2713aSLionel Sambuc   Writer.AddSourceLocation(S->getForLoc(), Record);
1033f4a2713aSLionel Sambuc   Writer.AddSourceLocation(S->getRParenLoc(), Record);
1034f4a2713aSLionel Sambuc   Code = serialization::STMT_OBJC_FOR_COLLECTION;
1035f4a2713aSLionel Sambuc }
1036f4a2713aSLionel Sambuc 
VisitObjCAtCatchStmt(ObjCAtCatchStmt * S)1037f4a2713aSLionel Sambuc void ASTStmtWriter::VisitObjCAtCatchStmt(ObjCAtCatchStmt *S) {
1038f4a2713aSLionel Sambuc   Writer.AddStmt(S->getCatchBody());
1039f4a2713aSLionel Sambuc   Writer.AddDeclRef(S->getCatchParamDecl(), Record);
1040f4a2713aSLionel Sambuc   Writer.AddSourceLocation(S->getAtCatchLoc(), Record);
1041f4a2713aSLionel Sambuc   Writer.AddSourceLocation(S->getRParenLoc(), Record);
1042f4a2713aSLionel Sambuc   Code = serialization::STMT_OBJC_CATCH;
1043f4a2713aSLionel Sambuc }
1044f4a2713aSLionel Sambuc 
VisitObjCAtFinallyStmt(ObjCAtFinallyStmt * S)1045f4a2713aSLionel Sambuc void ASTStmtWriter::VisitObjCAtFinallyStmt(ObjCAtFinallyStmt *S) {
1046f4a2713aSLionel Sambuc   Writer.AddStmt(S->getFinallyBody());
1047f4a2713aSLionel Sambuc   Writer.AddSourceLocation(S->getAtFinallyLoc(), Record);
1048f4a2713aSLionel Sambuc   Code = serialization::STMT_OBJC_FINALLY;
1049f4a2713aSLionel Sambuc }
1050f4a2713aSLionel Sambuc 
VisitObjCAutoreleasePoolStmt(ObjCAutoreleasePoolStmt * S)1051f4a2713aSLionel Sambuc void ASTStmtWriter::VisitObjCAutoreleasePoolStmt(ObjCAutoreleasePoolStmt *S) {
1052f4a2713aSLionel Sambuc   Writer.AddStmt(S->getSubStmt());
1053f4a2713aSLionel Sambuc   Writer.AddSourceLocation(S->getAtLoc(), Record);
1054f4a2713aSLionel Sambuc   Code = serialization::STMT_OBJC_AUTORELEASE_POOL;
1055f4a2713aSLionel Sambuc }
1056f4a2713aSLionel Sambuc 
VisitObjCAtTryStmt(ObjCAtTryStmt * S)1057f4a2713aSLionel Sambuc void ASTStmtWriter::VisitObjCAtTryStmt(ObjCAtTryStmt *S) {
1058f4a2713aSLionel Sambuc   Record.push_back(S->getNumCatchStmts());
1059*0a6a1f1dSLionel Sambuc   Record.push_back(S->getFinallyStmt() != nullptr);
1060f4a2713aSLionel Sambuc   Writer.AddStmt(S->getTryBody());
1061f4a2713aSLionel Sambuc   for (unsigned I = 0, N = S->getNumCatchStmts(); I != N; ++I)
1062f4a2713aSLionel Sambuc     Writer.AddStmt(S->getCatchStmt(I));
1063f4a2713aSLionel Sambuc   if (S->getFinallyStmt())
1064f4a2713aSLionel Sambuc     Writer.AddStmt(S->getFinallyStmt());
1065f4a2713aSLionel Sambuc   Writer.AddSourceLocation(S->getAtTryLoc(), Record);
1066f4a2713aSLionel Sambuc   Code = serialization::STMT_OBJC_AT_TRY;
1067f4a2713aSLionel Sambuc }
1068f4a2713aSLionel Sambuc 
VisitObjCAtSynchronizedStmt(ObjCAtSynchronizedStmt * S)1069f4a2713aSLionel Sambuc void ASTStmtWriter::VisitObjCAtSynchronizedStmt(ObjCAtSynchronizedStmt *S) {
1070f4a2713aSLionel Sambuc   Writer.AddStmt(S->getSynchExpr());
1071f4a2713aSLionel Sambuc   Writer.AddStmt(S->getSynchBody());
1072f4a2713aSLionel Sambuc   Writer.AddSourceLocation(S->getAtSynchronizedLoc(), Record);
1073f4a2713aSLionel Sambuc   Code = serialization::STMT_OBJC_AT_SYNCHRONIZED;
1074f4a2713aSLionel Sambuc }
1075f4a2713aSLionel Sambuc 
VisitObjCAtThrowStmt(ObjCAtThrowStmt * S)1076f4a2713aSLionel Sambuc void ASTStmtWriter::VisitObjCAtThrowStmt(ObjCAtThrowStmt *S) {
1077f4a2713aSLionel Sambuc   Writer.AddStmt(S->getThrowExpr());
1078f4a2713aSLionel Sambuc   Writer.AddSourceLocation(S->getThrowLoc(), Record);
1079f4a2713aSLionel Sambuc   Code = serialization::STMT_OBJC_AT_THROW;
1080f4a2713aSLionel Sambuc }
1081f4a2713aSLionel Sambuc 
VisitObjCBoolLiteralExpr(ObjCBoolLiteralExpr * E)1082f4a2713aSLionel Sambuc void ASTStmtWriter::VisitObjCBoolLiteralExpr(ObjCBoolLiteralExpr *E) {
1083f4a2713aSLionel Sambuc   VisitExpr(E);
1084f4a2713aSLionel Sambuc   Record.push_back(E->getValue());
1085f4a2713aSLionel Sambuc   Writer.AddSourceLocation(E->getLocation(), Record);
1086f4a2713aSLionel Sambuc   Code = serialization::EXPR_OBJC_BOOL_LITERAL;
1087f4a2713aSLionel Sambuc }
1088f4a2713aSLionel Sambuc 
1089f4a2713aSLionel Sambuc //===----------------------------------------------------------------------===//
1090f4a2713aSLionel Sambuc // C++ Expressions and Statements.
1091f4a2713aSLionel Sambuc //===----------------------------------------------------------------------===//
1092f4a2713aSLionel Sambuc 
VisitCXXCatchStmt(CXXCatchStmt * S)1093f4a2713aSLionel Sambuc void ASTStmtWriter::VisitCXXCatchStmt(CXXCatchStmt *S) {
1094f4a2713aSLionel Sambuc   VisitStmt(S);
1095f4a2713aSLionel Sambuc   Writer.AddSourceLocation(S->getCatchLoc(), Record);
1096f4a2713aSLionel Sambuc   Writer.AddDeclRef(S->getExceptionDecl(), Record);
1097f4a2713aSLionel Sambuc   Writer.AddStmt(S->getHandlerBlock());
1098f4a2713aSLionel Sambuc   Code = serialization::STMT_CXX_CATCH;
1099f4a2713aSLionel Sambuc }
1100f4a2713aSLionel Sambuc 
VisitCXXTryStmt(CXXTryStmt * S)1101f4a2713aSLionel Sambuc void ASTStmtWriter::VisitCXXTryStmt(CXXTryStmt *S) {
1102f4a2713aSLionel Sambuc   VisitStmt(S);
1103f4a2713aSLionel Sambuc   Record.push_back(S->getNumHandlers());
1104f4a2713aSLionel Sambuc   Writer.AddSourceLocation(S->getTryLoc(), Record);
1105f4a2713aSLionel Sambuc   Writer.AddStmt(S->getTryBlock());
1106f4a2713aSLionel Sambuc   for (unsigned i = 0, e = S->getNumHandlers(); i != e; ++i)
1107f4a2713aSLionel Sambuc     Writer.AddStmt(S->getHandler(i));
1108f4a2713aSLionel Sambuc   Code = serialization::STMT_CXX_TRY;
1109f4a2713aSLionel Sambuc }
1110f4a2713aSLionel Sambuc 
VisitCXXForRangeStmt(CXXForRangeStmt * S)1111f4a2713aSLionel Sambuc void ASTStmtWriter::VisitCXXForRangeStmt(CXXForRangeStmt *S) {
1112f4a2713aSLionel Sambuc   VisitStmt(S);
1113f4a2713aSLionel Sambuc   Writer.AddSourceLocation(S->getForLoc(), Record);
1114f4a2713aSLionel Sambuc   Writer.AddSourceLocation(S->getColonLoc(), Record);
1115f4a2713aSLionel Sambuc   Writer.AddSourceLocation(S->getRParenLoc(), Record);
1116f4a2713aSLionel Sambuc   Writer.AddStmt(S->getRangeStmt());
1117f4a2713aSLionel Sambuc   Writer.AddStmt(S->getBeginEndStmt());
1118f4a2713aSLionel Sambuc   Writer.AddStmt(S->getCond());
1119f4a2713aSLionel Sambuc   Writer.AddStmt(S->getInc());
1120f4a2713aSLionel Sambuc   Writer.AddStmt(S->getLoopVarStmt());
1121f4a2713aSLionel Sambuc   Writer.AddStmt(S->getBody());
1122f4a2713aSLionel Sambuc   Code = serialization::STMT_CXX_FOR_RANGE;
1123f4a2713aSLionel Sambuc }
1124f4a2713aSLionel Sambuc 
VisitMSDependentExistsStmt(MSDependentExistsStmt * S)1125f4a2713aSLionel Sambuc void ASTStmtWriter::VisitMSDependentExistsStmt(MSDependentExistsStmt *S) {
1126f4a2713aSLionel Sambuc   VisitStmt(S);
1127f4a2713aSLionel Sambuc   Writer.AddSourceLocation(S->getKeywordLoc(), Record);
1128f4a2713aSLionel Sambuc   Record.push_back(S->isIfExists());
1129f4a2713aSLionel Sambuc   Writer.AddNestedNameSpecifierLoc(S->getQualifierLoc(), Record);
1130f4a2713aSLionel Sambuc   Writer.AddDeclarationNameInfo(S->getNameInfo(), Record);
1131f4a2713aSLionel Sambuc   Writer.AddStmt(S->getSubStmt());
1132f4a2713aSLionel Sambuc   Code = serialization::STMT_MS_DEPENDENT_EXISTS;
1133f4a2713aSLionel Sambuc }
1134f4a2713aSLionel Sambuc 
VisitCXXOperatorCallExpr(CXXOperatorCallExpr * E)1135f4a2713aSLionel Sambuc void ASTStmtWriter::VisitCXXOperatorCallExpr(CXXOperatorCallExpr *E) {
1136f4a2713aSLionel Sambuc   VisitCallExpr(E);
1137f4a2713aSLionel Sambuc   Record.push_back(E->getOperator());
1138f4a2713aSLionel Sambuc   Writer.AddSourceRange(E->Range, Record);
1139f4a2713aSLionel Sambuc   Record.push_back(E->isFPContractable());
1140f4a2713aSLionel Sambuc   Code = serialization::EXPR_CXX_OPERATOR_CALL;
1141f4a2713aSLionel Sambuc }
1142f4a2713aSLionel Sambuc 
VisitCXXMemberCallExpr(CXXMemberCallExpr * E)1143f4a2713aSLionel Sambuc void ASTStmtWriter::VisitCXXMemberCallExpr(CXXMemberCallExpr *E) {
1144f4a2713aSLionel Sambuc   VisitCallExpr(E);
1145f4a2713aSLionel Sambuc   Code = serialization::EXPR_CXX_MEMBER_CALL;
1146f4a2713aSLionel Sambuc }
1147f4a2713aSLionel Sambuc 
VisitCXXConstructExpr(CXXConstructExpr * E)1148f4a2713aSLionel Sambuc void ASTStmtWriter::VisitCXXConstructExpr(CXXConstructExpr *E) {
1149f4a2713aSLionel Sambuc   VisitExpr(E);
1150f4a2713aSLionel Sambuc   Record.push_back(E->getNumArgs());
1151f4a2713aSLionel Sambuc   for (unsigned I = 0, N = E->getNumArgs(); I != N; ++I)
1152f4a2713aSLionel Sambuc     Writer.AddStmt(E->getArg(I));
1153f4a2713aSLionel Sambuc   Writer.AddDeclRef(E->getConstructor(), Record);
1154f4a2713aSLionel Sambuc   Writer.AddSourceLocation(E->getLocation(), Record);
1155f4a2713aSLionel Sambuc   Record.push_back(E->isElidable());
1156f4a2713aSLionel Sambuc   Record.push_back(E->hadMultipleCandidates());
1157f4a2713aSLionel Sambuc   Record.push_back(E->isListInitialization());
1158*0a6a1f1dSLionel Sambuc   Record.push_back(E->isStdInitListInitialization());
1159f4a2713aSLionel Sambuc   Record.push_back(E->requiresZeroInitialization());
1160f4a2713aSLionel Sambuc   Record.push_back(E->getConstructionKind()); // FIXME: stable encoding
1161f4a2713aSLionel Sambuc   Writer.AddSourceRange(E->getParenOrBraceRange(), Record);
1162f4a2713aSLionel Sambuc   Code = serialization::EXPR_CXX_CONSTRUCT;
1163f4a2713aSLionel Sambuc }
1164f4a2713aSLionel Sambuc 
VisitCXXTemporaryObjectExpr(CXXTemporaryObjectExpr * E)1165f4a2713aSLionel Sambuc void ASTStmtWriter::VisitCXXTemporaryObjectExpr(CXXTemporaryObjectExpr *E) {
1166f4a2713aSLionel Sambuc   VisitCXXConstructExpr(E);
1167f4a2713aSLionel Sambuc   Writer.AddTypeSourceInfo(E->getTypeSourceInfo(), Record);
1168f4a2713aSLionel Sambuc   Code = serialization::EXPR_CXX_TEMPORARY_OBJECT;
1169f4a2713aSLionel Sambuc }
1170f4a2713aSLionel Sambuc 
VisitLambdaExpr(LambdaExpr * E)1171f4a2713aSLionel Sambuc void ASTStmtWriter::VisitLambdaExpr(LambdaExpr *E) {
1172f4a2713aSLionel Sambuc   VisitExpr(E);
1173f4a2713aSLionel Sambuc   Record.push_back(E->NumCaptures);
1174f4a2713aSLionel Sambuc   unsigned NumArrayIndexVars = 0;
1175f4a2713aSLionel Sambuc   if (E->HasArrayIndexVars)
1176f4a2713aSLionel Sambuc     NumArrayIndexVars = E->getArrayIndexStarts()[E->NumCaptures];
1177f4a2713aSLionel Sambuc   Record.push_back(NumArrayIndexVars);
1178f4a2713aSLionel Sambuc   Writer.AddSourceRange(E->IntroducerRange, Record);
1179f4a2713aSLionel Sambuc   Record.push_back(E->CaptureDefault); // FIXME: stable encoding
1180f4a2713aSLionel Sambuc   Writer.AddSourceLocation(E->CaptureDefaultLoc, Record);
1181f4a2713aSLionel Sambuc   Record.push_back(E->ExplicitParams);
1182f4a2713aSLionel Sambuc   Record.push_back(E->ExplicitResultType);
1183f4a2713aSLionel Sambuc   Writer.AddSourceLocation(E->ClosingBrace, Record);
1184f4a2713aSLionel Sambuc 
1185f4a2713aSLionel Sambuc   // Add capture initializers.
1186f4a2713aSLionel Sambuc   for (LambdaExpr::capture_init_iterator C = E->capture_init_begin(),
1187f4a2713aSLionel Sambuc                                       CEnd = E->capture_init_end();
1188f4a2713aSLionel Sambuc        C != CEnd; ++C) {
1189f4a2713aSLionel Sambuc     Writer.AddStmt(*C);
1190f4a2713aSLionel Sambuc   }
1191f4a2713aSLionel Sambuc 
1192f4a2713aSLionel Sambuc   // Add array index variables, if any.
1193f4a2713aSLionel Sambuc   if (NumArrayIndexVars) {
1194f4a2713aSLionel Sambuc     Record.append(E->getArrayIndexStarts(),
1195f4a2713aSLionel Sambuc                   E->getArrayIndexStarts() + E->NumCaptures + 1);
1196f4a2713aSLionel Sambuc     VarDecl **ArrayIndexVars = E->getArrayIndexVars();
1197f4a2713aSLionel Sambuc     for (unsigned I = 0; I != NumArrayIndexVars; ++I)
1198f4a2713aSLionel Sambuc       Writer.AddDeclRef(ArrayIndexVars[I], Record);
1199f4a2713aSLionel Sambuc   }
1200f4a2713aSLionel Sambuc 
1201f4a2713aSLionel Sambuc   Code = serialization::EXPR_LAMBDA;
1202f4a2713aSLionel Sambuc }
1203f4a2713aSLionel Sambuc 
VisitCXXStdInitializerListExpr(CXXStdInitializerListExpr * E)1204f4a2713aSLionel Sambuc void ASTStmtWriter::VisitCXXStdInitializerListExpr(CXXStdInitializerListExpr *E) {
1205f4a2713aSLionel Sambuc   VisitExpr(E);
1206f4a2713aSLionel Sambuc   Writer.AddStmt(E->getSubExpr());
1207f4a2713aSLionel Sambuc   Code = serialization::EXPR_CXX_STD_INITIALIZER_LIST;
1208f4a2713aSLionel Sambuc }
1209f4a2713aSLionel Sambuc 
VisitCXXNamedCastExpr(CXXNamedCastExpr * E)1210f4a2713aSLionel Sambuc void ASTStmtWriter::VisitCXXNamedCastExpr(CXXNamedCastExpr *E) {
1211f4a2713aSLionel Sambuc   VisitExplicitCastExpr(E);
1212f4a2713aSLionel Sambuc   Writer.AddSourceRange(SourceRange(E->getOperatorLoc(), E->getRParenLoc()),
1213f4a2713aSLionel Sambuc                         Record);
1214f4a2713aSLionel Sambuc   Writer.AddSourceRange(E->getAngleBrackets(), Record);
1215f4a2713aSLionel Sambuc }
1216f4a2713aSLionel Sambuc 
VisitCXXStaticCastExpr(CXXStaticCastExpr * E)1217f4a2713aSLionel Sambuc void ASTStmtWriter::VisitCXXStaticCastExpr(CXXStaticCastExpr *E) {
1218f4a2713aSLionel Sambuc   VisitCXXNamedCastExpr(E);
1219f4a2713aSLionel Sambuc   Code = serialization::EXPR_CXX_STATIC_CAST;
1220f4a2713aSLionel Sambuc }
1221f4a2713aSLionel Sambuc 
VisitCXXDynamicCastExpr(CXXDynamicCastExpr * E)1222f4a2713aSLionel Sambuc void ASTStmtWriter::VisitCXXDynamicCastExpr(CXXDynamicCastExpr *E) {
1223f4a2713aSLionel Sambuc   VisitCXXNamedCastExpr(E);
1224f4a2713aSLionel Sambuc   Code = serialization::EXPR_CXX_DYNAMIC_CAST;
1225f4a2713aSLionel Sambuc }
1226f4a2713aSLionel Sambuc 
VisitCXXReinterpretCastExpr(CXXReinterpretCastExpr * E)1227f4a2713aSLionel Sambuc void ASTStmtWriter::VisitCXXReinterpretCastExpr(CXXReinterpretCastExpr *E) {
1228f4a2713aSLionel Sambuc   VisitCXXNamedCastExpr(E);
1229f4a2713aSLionel Sambuc   Code = serialization::EXPR_CXX_REINTERPRET_CAST;
1230f4a2713aSLionel Sambuc }
1231f4a2713aSLionel Sambuc 
VisitCXXConstCastExpr(CXXConstCastExpr * E)1232f4a2713aSLionel Sambuc void ASTStmtWriter::VisitCXXConstCastExpr(CXXConstCastExpr *E) {
1233f4a2713aSLionel Sambuc   VisitCXXNamedCastExpr(E);
1234f4a2713aSLionel Sambuc   Code = serialization::EXPR_CXX_CONST_CAST;
1235f4a2713aSLionel Sambuc }
1236f4a2713aSLionel Sambuc 
VisitCXXFunctionalCastExpr(CXXFunctionalCastExpr * E)1237f4a2713aSLionel Sambuc void ASTStmtWriter::VisitCXXFunctionalCastExpr(CXXFunctionalCastExpr *E) {
1238f4a2713aSLionel Sambuc   VisitExplicitCastExpr(E);
1239f4a2713aSLionel Sambuc   Writer.AddSourceLocation(E->getLParenLoc(), Record);
1240f4a2713aSLionel Sambuc   Writer.AddSourceLocation(E->getRParenLoc(), Record);
1241f4a2713aSLionel Sambuc   Code = serialization::EXPR_CXX_FUNCTIONAL_CAST;
1242f4a2713aSLionel Sambuc }
1243f4a2713aSLionel Sambuc 
VisitUserDefinedLiteral(UserDefinedLiteral * E)1244f4a2713aSLionel Sambuc void ASTStmtWriter::VisitUserDefinedLiteral(UserDefinedLiteral *E) {
1245f4a2713aSLionel Sambuc   VisitCallExpr(E);
1246f4a2713aSLionel Sambuc   Writer.AddSourceLocation(E->UDSuffixLoc, Record);
1247f4a2713aSLionel Sambuc   Code = serialization::EXPR_USER_DEFINED_LITERAL;
1248f4a2713aSLionel Sambuc }
1249f4a2713aSLionel Sambuc 
VisitCXXBoolLiteralExpr(CXXBoolLiteralExpr * E)1250f4a2713aSLionel Sambuc void ASTStmtWriter::VisitCXXBoolLiteralExpr(CXXBoolLiteralExpr *E) {
1251f4a2713aSLionel Sambuc   VisitExpr(E);
1252f4a2713aSLionel Sambuc   Record.push_back(E->getValue());
1253f4a2713aSLionel Sambuc   Writer.AddSourceLocation(E->getLocation(), Record);
1254f4a2713aSLionel Sambuc   Code = serialization::EXPR_CXX_BOOL_LITERAL;
1255f4a2713aSLionel Sambuc }
1256f4a2713aSLionel Sambuc 
VisitCXXNullPtrLiteralExpr(CXXNullPtrLiteralExpr * E)1257f4a2713aSLionel Sambuc void ASTStmtWriter::VisitCXXNullPtrLiteralExpr(CXXNullPtrLiteralExpr *E) {
1258f4a2713aSLionel Sambuc   VisitExpr(E);
1259f4a2713aSLionel Sambuc   Writer.AddSourceLocation(E->getLocation(), Record);
1260f4a2713aSLionel Sambuc   Code = serialization::EXPR_CXX_NULL_PTR_LITERAL;
1261f4a2713aSLionel Sambuc }
1262f4a2713aSLionel Sambuc 
VisitCXXTypeidExpr(CXXTypeidExpr * E)1263f4a2713aSLionel Sambuc void ASTStmtWriter::VisitCXXTypeidExpr(CXXTypeidExpr *E) {
1264f4a2713aSLionel Sambuc   VisitExpr(E);
1265f4a2713aSLionel Sambuc   Writer.AddSourceRange(E->getSourceRange(), Record);
1266f4a2713aSLionel Sambuc   if (E->isTypeOperand()) {
1267f4a2713aSLionel Sambuc     Writer.AddTypeSourceInfo(E->getTypeOperandSourceInfo(), Record);
1268f4a2713aSLionel Sambuc     Code = serialization::EXPR_CXX_TYPEID_TYPE;
1269f4a2713aSLionel Sambuc   } else {
1270f4a2713aSLionel Sambuc     Writer.AddStmt(E->getExprOperand());
1271f4a2713aSLionel Sambuc     Code = serialization::EXPR_CXX_TYPEID_EXPR;
1272f4a2713aSLionel Sambuc   }
1273f4a2713aSLionel Sambuc }
1274f4a2713aSLionel Sambuc 
VisitCXXThisExpr(CXXThisExpr * E)1275f4a2713aSLionel Sambuc void ASTStmtWriter::VisitCXXThisExpr(CXXThisExpr *E) {
1276f4a2713aSLionel Sambuc   VisitExpr(E);
1277f4a2713aSLionel Sambuc   Writer.AddSourceLocation(E->getLocation(), Record);
1278f4a2713aSLionel Sambuc   Record.push_back(E->isImplicit());
1279f4a2713aSLionel Sambuc   Code = serialization::EXPR_CXX_THIS;
1280f4a2713aSLionel Sambuc }
1281f4a2713aSLionel Sambuc 
VisitCXXThrowExpr(CXXThrowExpr * E)1282f4a2713aSLionel Sambuc void ASTStmtWriter::VisitCXXThrowExpr(CXXThrowExpr *E) {
1283f4a2713aSLionel Sambuc   VisitExpr(E);
1284f4a2713aSLionel Sambuc   Writer.AddSourceLocation(E->getThrowLoc(), Record);
1285f4a2713aSLionel Sambuc   Writer.AddStmt(E->getSubExpr());
1286f4a2713aSLionel Sambuc   Record.push_back(E->isThrownVariableInScope());
1287f4a2713aSLionel Sambuc   Code = serialization::EXPR_CXX_THROW;
1288f4a2713aSLionel Sambuc }
1289f4a2713aSLionel Sambuc 
VisitCXXDefaultArgExpr(CXXDefaultArgExpr * E)1290f4a2713aSLionel Sambuc void ASTStmtWriter::VisitCXXDefaultArgExpr(CXXDefaultArgExpr *E) {
1291f4a2713aSLionel Sambuc   VisitExpr(E);
1292f4a2713aSLionel Sambuc 
1293f4a2713aSLionel Sambuc   bool HasOtherExprStored = E->Param.getInt();
1294f4a2713aSLionel Sambuc   // Store these first, the reader reads them before creation.
1295f4a2713aSLionel Sambuc   Record.push_back(HasOtherExprStored);
1296f4a2713aSLionel Sambuc   if (HasOtherExprStored)
1297f4a2713aSLionel Sambuc     Writer.AddStmt(E->getExpr());
1298f4a2713aSLionel Sambuc   Writer.AddDeclRef(E->getParam(), Record);
1299f4a2713aSLionel Sambuc   Writer.AddSourceLocation(E->getUsedLocation(), Record);
1300f4a2713aSLionel Sambuc 
1301f4a2713aSLionel Sambuc   Code = serialization::EXPR_CXX_DEFAULT_ARG;
1302f4a2713aSLionel Sambuc }
1303f4a2713aSLionel Sambuc 
VisitCXXDefaultInitExpr(CXXDefaultInitExpr * E)1304f4a2713aSLionel Sambuc void ASTStmtWriter::VisitCXXDefaultInitExpr(CXXDefaultInitExpr *E) {
1305f4a2713aSLionel Sambuc   VisitExpr(E);
1306f4a2713aSLionel Sambuc   Writer.AddDeclRef(E->getField(), Record);
1307f4a2713aSLionel Sambuc   Writer.AddSourceLocation(E->getExprLoc(), Record);
1308f4a2713aSLionel Sambuc   Code = serialization::EXPR_CXX_DEFAULT_INIT;
1309f4a2713aSLionel Sambuc }
1310f4a2713aSLionel Sambuc 
VisitCXXBindTemporaryExpr(CXXBindTemporaryExpr * E)1311f4a2713aSLionel Sambuc void ASTStmtWriter::VisitCXXBindTemporaryExpr(CXXBindTemporaryExpr *E) {
1312f4a2713aSLionel Sambuc   VisitExpr(E);
1313f4a2713aSLionel Sambuc   Writer.AddCXXTemporary(E->getTemporary(), Record);
1314f4a2713aSLionel Sambuc   Writer.AddStmt(E->getSubExpr());
1315f4a2713aSLionel Sambuc   Code = serialization::EXPR_CXX_BIND_TEMPORARY;
1316f4a2713aSLionel Sambuc }
1317f4a2713aSLionel Sambuc 
VisitCXXScalarValueInitExpr(CXXScalarValueInitExpr * E)1318f4a2713aSLionel Sambuc void ASTStmtWriter::VisitCXXScalarValueInitExpr(CXXScalarValueInitExpr *E) {
1319f4a2713aSLionel Sambuc   VisitExpr(E);
1320f4a2713aSLionel Sambuc   Writer.AddTypeSourceInfo(E->getTypeSourceInfo(), Record);
1321f4a2713aSLionel Sambuc   Writer.AddSourceLocation(E->getRParenLoc(), Record);
1322f4a2713aSLionel Sambuc   Code = serialization::EXPR_CXX_SCALAR_VALUE_INIT;
1323f4a2713aSLionel Sambuc }
1324f4a2713aSLionel Sambuc 
VisitCXXNewExpr(CXXNewExpr * E)1325f4a2713aSLionel Sambuc void ASTStmtWriter::VisitCXXNewExpr(CXXNewExpr *E) {
1326f4a2713aSLionel Sambuc   VisitExpr(E);
1327f4a2713aSLionel Sambuc   Record.push_back(E->isGlobalNew());
1328f4a2713aSLionel Sambuc   Record.push_back(E->isArray());
1329f4a2713aSLionel Sambuc   Record.push_back(E->doesUsualArrayDeleteWantSize());
1330f4a2713aSLionel Sambuc   Record.push_back(E->getNumPlacementArgs());
1331f4a2713aSLionel Sambuc   Record.push_back(E->StoredInitializationStyle);
1332f4a2713aSLionel Sambuc   Writer.AddDeclRef(E->getOperatorNew(), Record);
1333f4a2713aSLionel Sambuc   Writer.AddDeclRef(E->getOperatorDelete(), Record);
1334f4a2713aSLionel Sambuc   Writer.AddTypeSourceInfo(E->getAllocatedTypeSourceInfo(), Record);
1335f4a2713aSLionel Sambuc   Writer.AddSourceRange(E->getTypeIdParens(), Record);
1336f4a2713aSLionel Sambuc   Writer.AddSourceRange(E->getSourceRange(), Record);
1337f4a2713aSLionel Sambuc   Writer.AddSourceRange(E->getDirectInitRange(), Record);
1338f4a2713aSLionel Sambuc   for (CXXNewExpr::arg_iterator I = E->raw_arg_begin(), e = E->raw_arg_end();
1339f4a2713aSLionel Sambuc        I != e; ++I)
1340f4a2713aSLionel Sambuc     Writer.AddStmt(*I);
1341f4a2713aSLionel Sambuc 
1342f4a2713aSLionel Sambuc   Code = serialization::EXPR_CXX_NEW;
1343f4a2713aSLionel Sambuc }
1344f4a2713aSLionel Sambuc 
VisitCXXDeleteExpr(CXXDeleteExpr * E)1345f4a2713aSLionel Sambuc void ASTStmtWriter::VisitCXXDeleteExpr(CXXDeleteExpr *E) {
1346f4a2713aSLionel Sambuc   VisitExpr(E);
1347f4a2713aSLionel Sambuc   Record.push_back(E->isGlobalDelete());
1348f4a2713aSLionel Sambuc   Record.push_back(E->isArrayForm());
1349f4a2713aSLionel Sambuc   Record.push_back(E->isArrayFormAsWritten());
1350f4a2713aSLionel Sambuc   Record.push_back(E->doesUsualArrayDeleteWantSize());
1351f4a2713aSLionel Sambuc   Writer.AddDeclRef(E->getOperatorDelete(), Record);
1352f4a2713aSLionel Sambuc   Writer.AddStmt(E->getArgument());
1353f4a2713aSLionel Sambuc   Writer.AddSourceLocation(E->getSourceRange().getBegin(), Record);
1354f4a2713aSLionel Sambuc 
1355f4a2713aSLionel Sambuc   Code = serialization::EXPR_CXX_DELETE;
1356f4a2713aSLionel Sambuc }
1357f4a2713aSLionel Sambuc 
VisitCXXPseudoDestructorExpr(CXXPseudoDestructorExpr * E)1358f4a2713aSLionel Sambuc void ASTStmtWriter::VisitCXXPseudoDestructorExpr(CXXPseudoDestructorExpr *E) {
1359f4a2713aSLionel Sambuc   VisitExpr(E);
1360f4a2713aSLionel Sambuc 
1361f4a2713aSLionel Sambuc   Writer.AddStmt(E->getBase());
1362f4a2713aSLionel Sambuc   Record.push_back(E->isArrow());
1363f4a2713aSLionel Sambuc   Writer.AddSourceLocation(E->getOperatorLoc(), Record);
1364f4a2713aSLionel Sambuc   Writer.AddNestedNameSpecifierLoc(E->getQualifierLoc(), Record);
1365f4a2713aSLionel Sambuc   Writer.AddTypeSourceInfo(E->getScopeTypeInfo(), Record);
1366f4a2713aSLionel Sambuc   Writer.AddSourceLocation(E->getColonColonLoc(), Record);
1367f4a2713aSLionel Sambuc   Writer.AddSourceLocation(E->getTildeLoc(), Record);
1368f4a2713aSLionel Sambuc 
1369f4a2713aSLionel Sambuc   // PseudoDestructorTypeStorage.
1370f4a2713aSLionel Sambuc   Writer.AddIdentifierRef(E->getDestroyedTypeIdentifier(), Record);
1371f4a2713aSLionel Sambuc   if (E->getDestroyedTypeIdentifier())
1372f4a2713aSLionel Sambuc     Writer.AddSourceLocation(E->getDestroyedTypeLoc(), Record);
1373f4a2713aSLionel Sambuc   else
1374f4a2713aSLionel Sambuc     Writer.AddTypeSourceInfo(E->getDestroyedTypeInfo(), Record);
1375f4a2713aSLionel Sambuc 
1376f4a2713aSLionel Sambuc   Code = serialization::EXPR_CXX_PSEUDO_DESTRUCTOR;
1377f4a2713aSLionel Sambuc }
1378f4a2713aSLionel Sambuc 
VisitExprWithCleanups(ExprWithCleanups * E)1379f4a2713aSLionel Sambuc void ASTStmtWriter::VisitExprWithCleanups(ExprWithCleanups *E) {
1380f4a2713aSLionel Sambuc   VisitExpr(E);
1381f4a2713aSLionel Sambuc   Record.push_back(E->getNumObjects());
1382f4a2713aSLionel Sambuc   for (unsigned i = 0, e = E->getNumObjects(); i != e; ++i)
1383f4a2713aSLionel Sambuc     Writer.AddDeclRef(E->getObject(i), Record);
1384f4a2713aSLionel Sambuc 
1385f4a2713aSLionel Sambuc   Writer.AddStmt(E->getSubExpr());
1386f4a2713aSLionel Sambuc   Code = serialization::EXPR_EXPR_WITH_CLEANUPS;
1387f4a2713aSLionel Sambuc }
1388f4a2713aSLionel Sambuc 
1389f4a2713aSLionel Sambuc void
VisitCXXDependentScopeMemberExpr(CXXDependentScopeMemberExpr * E)1390f4a2713aSLionel Sambuc ASTStmtWriter::VisitCXXDependentScopeMemberExpr(CXXDependentScopeMemberExpr *E){
1391f4a2713aSLionel Sambuc   VisitExpr(E);
1392f4a2713aSLionel Sambuc 
1393f4a2713aSLionel Sambuc   // Don't emit anything here, HasTemplateKWAndArgsInfo must be
1394f4a2713aSLionel Sambuc   // emitted first.
1395f4a2713aSLionel Sambuc 
1396f4a2713aSLionel Sambuc   Record.push_back(E->HasTemplateKWAndArgsInfo);
1397f4a2713aSLionel Sambuc   if (E->HasTemplateKWAndArgsInfo) {
1398f4a2713aSLionel Sambuc     const ASTTemplateKWAndArgsInfo &Args = *E->getTemplateKWAndArgsInfo();
1399f4a2713aSLionel Sambuc     Record.push_back(Args.NumTemplateArgs);
1400f4a2713aSLionel Sambuc     AddTemplateKWAndArgsInfo(Args);
1401f4a2713aSLionel Sambuc   }
1402f4a2713aSLionel Sambuc 
1403f4a2713aSLionel Sambuc   if (!E->isImplicitAccess())
1404f4a2713aSLionel Sambuc     Writer.AddStmt(E->getBase());
1405f4a2713aSLionel Sambuc   else
1406*0a6a1f1dSLionel Sambuc     Writer.AddStmt(nullptr);
1407f4a2713aSLionel Sambuc   Writer.AddTypeRef(E->getBaseType(), Record);
1408f4a2713aSLionel Sambuc   Record.push_back(E->isArrow());
1409f4a2713aSLionel Sambuc   Writer.AddSourceLocation(E->getOperatorLoc(), Record);
1410f4a2713aSLionel Sambuc   Writer.AddNestedNameSpecifierLoc(E->getQualifierLoc(), Record);
1411f4a2713aSLionel Sambuc   Writer.AddDeclRef(E->getFirstQualifierFoundInScope(), Record);
1412f4a2713aSLionel Sambuc   Writer.AddDeclarationNameInfo(E->MemberNameInfo, Record);
1413f4a2713aSLionel Sambuc   Code = serialization::EXPR_CXX_DEPENDENT_SCOPE_MEMBER;
1414f4a2713aSLionel Sambuc }
1415f4a2713aSLionel Sambuc 
1416f4a2713aSLionel Sambuc void
VisitDependentScopeDeclRefExpr(DependentScopeDeclRefExpr * E)1417f4a2713aSLionel Sambuc ASTStmtWriter::VisitDependentScopeDeclRefExpr(DependentScopeDeclRefExpr *E) {
1418f4a2713aSLionel Sambuc   VisitExpr(E);
1419f4a2713aSLionel Sambuc 
1420f4a2713aSLionel Sambuc   // Don't emit anything here, HasTemplateKWAndArgsInfo must be
1421f4a2713aSLionel Sambuc   // emitted first.
1422f4a2713aSLionel Sambuc 
1423f4a2713aSLionel Sambuc   Record.push_back(E->HasTemplateKWAndArgsInfo);
1424f4a2713aSLionel Sambuc   if (E->HasTemplateKWAndArgsInfo) {
1425f4a2713aSLionel Sambuc     const ASTTemplateKWAndArgsInfo &Args = *E->getTemplateKWAndArgsInfo();
1426f4a2713aSLionel Sambuc     Record.push_back(Args.NumTemplateArgs);
1427f4a2713aSLionel Sambuc     AddTemplateKWAndArgsInfo(Args);
1428f4a2713aSLionel Sambuc   }
1429f4a2713aSLionel Sambuc 
1430f4a2713aSLionel Sambuc   Writer.AddNestedNameSpecifierLoc(E->getQualifierLoc(), Record);
1431f4a2713aSLionel Sambuc   Writer.AddDeclarationNameInfo(E->NameInfo, Record);
1432f4a2713aSLionel Sambuc   Code = serialization::EXPR_CXX_DEPENDENT_SCOPE_DECL_REF;
1433f4a2713aSLionel Sambuc }
1434f4a2713aSLionel Sambuc 
1435f4a2713aSLionel Sambuc void
VisitCXXUnresolvedConstructExpr(CXXUnresolvedConstructExpr * E)1436f4a2713aSLionel Sambuc ASTStmtWriter::VisitCXXUnresolvedConstructExpr(CXXUnresolvedConstructExpr *E) {
1437f4a2713aSLionel Sambuc   VisitExpr(E);
1438f4a2713aSLionel Sambuc   Record.push_back(E->arg_size());
1439f4a2713aSLionel Sambuc   for (CXXUnresolvedConstructExpr::arg_iterator
1440f4a2713aSLionel Sambuc          ArgI = E->arg_begin(), ArgE = E->arg_end(); ArgI != ArgE; ++ArgI)
1441f4a2713aSLionel Sambuc     Writer.AddStmt(*ArgI);
1442f4a2713aSLionel Sambuc   Writer.AddTypeSourceInfo(E->getTypeSourceInfo(), Record);
1443f4a2713aSLionel Sambuc   Writer.AddSourceLocation(E->getLParenLoc(), Record);
1444f4a2713aSLionel Sambuc   Writer.AddSourceLocation(E->getRParenLoc(), Record);
1445f4a2713aSLionel Sambuc   Code = serialization::EXPR_CXX_UNRESOLVED_CONSTRUCT;
1446f4a2713aSLionel Sambuc }
1447f4a2713aSLionel Sambuc 
VisitOverloadExpr(OverloadExpr * E)1448f4a2713aSLionel Sambuc void ASTStmtWriter::VisitOverloadExpr(OverloadExpr *E) {
1449f4a2713aSLionel Sambuc   VisitExpr(E);
1450f4a2713aSLionel Sambuc 
1451f4a2713aSLionel Sambuc   // Don't emit anything here, HasTemplateKWAndArgsInfo must be
1452f4a2713aSLionel Sambuc   // emitted first.
1453f4a2713aSLionel Sambuc 
1454f4a2713aSLionel Sambuc   Record.push_back(E->HasTemplateKWAndArgsInfo);
1455f4a2713aSLionel Sambuc   if (E->HasTemplateKWAndArgsInfo) {
1456f4a2713aSLionel Sambuc     const ASTTemplateKWAndArgsInfo &Args = *E->getTemplateKWAndArgsInfo();
1457f4a2713aSLionel Sambuc     Record.push_back(Args.NumTemplateArgs);
1458f4a2713aSLionel Sambuc     AddTemplateKWAndArgsInfo(Args);
1459f4a2713aSLionel Sambuc   }
1460f4a2713aSLionel Sambuc 
1461f4a2713aSLionel Sambuc   Record.push_back(E->getNumDecls());
1462f4a2713aSLionel Sambuc   for (OverloadExpr::decls_iterator
1463f4a2713aSLionel Sambuc          OvI = E->decls_begin(), OvE = E->decls_end(); OvI != OvE; ++OvI) {
1464f4a2713aSLionel Sambuc     Writer.AddDeclRef(OvI.getDecl(), Record);
1465f4a2713aSLionel Sambuc     Record.push_back(OvI.getAccess());
1466f4a2713aSLionel Sambuc   }
1467f4a2713aSLionel Sambuc 
1468f4a2713aSLionel Sambuc   Writer.AddDeclarationNameInfo(E->NameInfo, Record);
1469f4a2713aSLionel Sambuc   Writer.AddNestedNameSpecifierLoc(E->getQualifierLoc(), Record);
1470f4a2713aSLionel Sambuc }
1471f4a2713aSLionel Sambuc 
VisitUnresolvedMemberExpr(UnresolvedMemberExpr * E)1472f4a2713aSLionel Sambuc void ASTStmtWriter::VisitUnresolvedMemberExpr(UnresolvedMemberExpr *E) {
1473f4a2713aSLionel Sambuc   VisitOverloadExpr(E);
1474f4a2713aSLionel Sambuc   Record.push_back(E->isArrow());
1475f4a2713aSLionel Sambuc   Record.push_back(E->hasUnresolvedUsing());
1476*0a6a1f1dSLionel Sambuc   Writer.AddStmt(!E->isImplicitAccess() ? E->getBase() : nullptr);
1477f4a2713aSLionel Sambuc   Writer.AddTypeRef(E->getBaseType(), Record);
1478f4a2713aSLionel Sambuc   Writer.AddSourceLocation(E->getOperatorLoc(), Record);
1479f4a2713aSLionel Sambuc   Code = serialization::EXPR_CXX_UNRESOLVED_MEMBER;
1480f4a2713aSLionel Sambuc }
1481f4a2713aSLionel Sambuc 
VisitUnresolvedLookupExpr(UnresolvedLookupExpr * E)1482f4a2713aSLionel Sambuc void ASTStmtWriter::VisitUnresolvedLookupExpr(UnresolvedLookupExpr *E) {
1483f4a2713aSLionel Sambuc   VisitOverloadExpr(E);
1484f4a2713aSLionel Sambuc   Record.push_back(E->requiresADL());
1485f4a2713aSLionel Sambuc   Record.push_back(E->isOverloaded());
1486f4a2713aSLionel Sambuc   Writer.AddDeclRef(E->getNamingClass(), Record);
1487f4a2713aSLionel Sambuc   Code = serialization::EXPR_CXX_UNRESOLVED_LOOKUP;
1488f4a2713aSLionel Sambuc }
1489f4a2713aSLionel Sambuc 
VisitTypeTraitExpr(TypeTraitExpr * E)1490f4a2713aSLionel Sambuc void ASTStmtWriter::VisitTypeTraitExpr(TypeTraitExpr *E) {
1491f4a2713aSLionel Sambuc   VisitExpr(E);
1492f4a2713aSLionel Sambuc   Record.push_back(E->TypeTraitExprBits.NumArgs);
1493f4a2713aSLionel Sambuc   Record.push_back(E->TypeTraitExprBits.Kind); // FIXME: Stable encoding
1494f4a2713aSLionel Sambuc   Record.push_back(E->TypeTraitExprBits.Value);
1495*0a6a1f1dSLionel Sambuc   Writer.AddSourceRange(E->getSourceRange(), Record);
1496f4a2713aSLionel Sambuc   for (unsigned I = 0, N = E->getNumArgs(); I != N; ++I)
1497f4a2713aSLionel Sambuc     Writer.AddTypeSourceInfo(E->getArg(I), Record);
1498f4a2713aSLionel Sambuc   Code = serialization::EXPR_TYPE_TRAIT;
1499f4a2713aSLionel Sambuc }
1500f4a2713aSLionel Sambuc 
VisitArrayTypeTraitExpr(ArrayTypeTraitExpr * E)1501f4a2713aSLionel Sambuc void ASTStmtWriter::VisitArrayTypeTraitExpr(ArrayTypeTraitExpr *E) {
1502f4a2713aSLionel Sambuc   VisitExpr(E);
1503f4a2713aSLionel Sambuc   Record.push_back(E->getTrait());
1504f4a2713aSLionel Sambuc   Record.push_back(E->getValue());
1505f4a2713aSLionel Sambuc   Writer.AddSourceRange(E->getSourceRange(), Record);
1506f4a2713aSLionel Sambuc   Writer.AddTypeSourceInfo(E->getQueriedTypeSourceInfo(), Record);
1507f4a2713aSLionel Sambuc   Code = serialization::EXPR_ARRAY_TYPE_TRAIT;
1508f4a2713aSLionel Sambuc }
1509f4a2713aSLionel Sambuc 
VisitExpressionTraitExpr(ExpressionTraitExpr * E)1510f4a2713aSLionel Sambuc void ASTStmtWriter::VisitExpressionTraitExpr(ExpressionTraitExpr *E) {
1511f4a2713aSLionel Sambuc   VisitExpr(E);
1512f4a2713aSLionel Sambuc   Record.push_back(E->getTrait());
1513f4a2713aSLionel Sambuc   Record.push_back(E->getValue());
1514f4a2713aSLionel Sambuc   Writer.AddSourceRange(E->getSourceRange(), Record);
1515f4a2713aSLionel Sambuc   Writer.AddStmt(E->getQueriedExpression());
1516f4a2713aSLionel Sambuc   Code = serialization::EXPR_CXX_EXPRESSION_TRAIT;
1517f4a2713aSLionel Sambuc }
1518f4a2713aSLionel Sambuc 
VisitCXXNoexceptExpr(CXXNoexceptExpr * E)1519f4a2713aSLionel Sambuc void ASTStmtWriter::VisitCXXNoexceptExpr(CXXNoexceptExpr *E) {
1520f4a2713aSLionel Sambuc   VisitExpr(E);
1521f4a2713aSLionel Sambuc   Record.push_back(E->getValue());
1522f4a2713aSLionel Sambuc   Writer.AddSourceRange(E->getSourceRange(), Record);
1523f4a2713aSLionel Sambuc   Writer.AddStmt(E->getOperand());
1524f4a2713aSLionel Sambuc   Code = serialization::EXPR_CXX_NOEXCEPT;
1525f4a2713aSLionel Sambuc }
1526f4a2713aSLionel Sambuc 
VisitPackExpansionExpr(PackExpansionExpr * E)1527f4a2713aSLionel Sambuc void ASTStmtWriter::VisitPackExpansionExpr(PackExpansionExpr *E) {
1528f4a2713aSLionel Sambuc   VisitExpr(E);
1529f4a2713aSLionel Sambuc   Writer.AddSourceLocation(E->getEllipsisLoc(), Record);
1530f4a2713aSLionel Sambuc   Record.push_back(E->NumExpansions);
1531f4a2713aSLionel Sambuc   Writer.AddStmt(E->getPattern());
1532f4a2713aSLionel Sambuc   Code = serialization::EXPR_PACK_EXPANSION;
1533f4a2713aSLionel Sambuc }
1534f4a2713aSLionel Sambuc 
VisitSizeOfPackExpr(SizeOfPackExpr * E)1535f4a2713aSLionel Sambuc void ASTStmtWriter::VisitSizeOfPackExpr(SizeOfPackExpr *E) {
1536f4a2713aSLionel Sambuc   VisitExpr(E);
1537f4a2713aSLionel Sambuc   Writer.AddSourceLocation(E->OperatorLoc, Record);
1538f4a2713aSLionel Sambuc   Writer.AddSourceLocation(E->PackLoc, Record);
1539f4a2713aSLionel Sambuc   Writer.AddSourceLocation(E->RParenLoc, Record);
1540f4a2713aSLionel Sambuc   Record.push_back(E->Length);
1541f4a2713aSLionel Sambuc   Writer.AddDeclRef(E->Pack, Record);
1542f4a2713aSLionel Sambuc   Code = serialization::EXPR_SIZEOF_PACK;
1543f4a2713aSLionel Sambuc }
1544f4a2713aSLionel Sambuc 
VisitSubstNonTypeTemplateParmExpr(SubstNonTypeTemplateParmExpr * E)1545f4a2713aSLionel Sambuc void ASTStmtWriter::VisitSubstNonTypeTemplateParmExpr(
1546f4a2713aSLionel Sambuc                                               SubstNonTypeTemplateParmExpr *E) {
1547f4a2713aSLionel Sambuc   VisitExpr(E);
1548f4a2713aSLionel Sambuc   Writer.AddDeclRef(E->getParameter(), Record);
1549f4a2713aSLionel Sambuc   Writer.AddSourceLocation(E->getNameLoc(), Record);
1550f4a2713aSLionel Sambuc   Writer.AddStmt(E->getReplacement());
1551f4a2713aSLionel Sambuc   Code = serialization::EXPR_SUBST_NON_TYPE_TEMPLATE_PARM;
1552f4a2713aSLionel Sambuc }
1553f4a2713aSLionel Sambuc 
VisitSubstNonTypeTemplateParmPackExpr(SubstNonTypeTemplateParmPackExpr * E)1554f4a2713aSLionel Sambuc void ASTStmtWriter::VisitSubstNonTypeTemplateParmPackExpr(
1555f4a2713aSLionel Sambuc                                           SubstNonTypeTemplateParmPackExpr *E) {
1556f4a2713aSLionel Sambuc   VisitExpr(E);
1557f4a2713aSLionel Sambuc   Writer.AddDeclRef(E->getParameterPack(), Record);
1558f4a2713aSLionel Sambuc   Writer.AddTemplateArgument(E->getArgumentPack(), Record);
1559f4a2713aSLionel Sambuc   Writer.AddSourceLocation(E->getParameterPackLocation(), Record);
1560f4a2713aSLionel Sambuc   Code = serialization::EXPR_SUBST_NON_TYPE_TEMPLATE_PARM_PACK;
1561f4a2713aSLionel Sambuc }
1562f4a2713aSLionel Sambuc 
VisitFunctionParmPackExpr(FunctionParmPackExpr * E)1563f4a2713aSLionel Sambuc void ASTStmtWriter::VisitFunctionParmPackExpr(FunctionParmPackExpr *E) {
1564f4a2713aSLionel Sambuc   VisitExpr(E);
1565f4a2713aSLionel Sambuc   Record.push_back(E->getNumExpansions());
1566f4a2713aSLionel Sambuc   Writer.AddDeclRef(E->getParameterPack(), Record);
1567f4a2713aSLionel Sambuc   Writer.AddSourceLocation(E->getParameterPackLocation(), Record);
1568f4a2713aSLionel Sambuc   for (FunctionParmPackExpr::iterator I = E->begin(), End = E->end();
1569f4a2713aSLionel Sambuc        I != End; ++I)
1570f4a2713aSLionel Sambuc     Writer.AddDeclRef(*I, Record);
1571f4a2713aSLionel Sambuc   Code = serialization::EXPR_FUNCTION_PARM_PACK;
1572f4a2713aSLionel Sambuc }
1573f4a2713aSLionel Sambuc 
VisitMaterializeTemporaryExpr(MaterializeTemporaryExpr * E)1574f4a2713aSLionel Sambuc void ASTStmtWriter::VisitMaterializeTemporaryExpr(MaterializeTemporaryExpr *E) {
1575f4a2713aSLionel Sambuc   VisitExpr(E);
1576*0a6a1f1dSLionel Sambuc   Writer.AddStmt(E->getTemporary());
1577*0a6a1f1dSLionel Sambuc   Writer.AddDeclRef(E->getExtendingDecl(), Record);
1578*0a6a1f1dSLionel Sambuc   Record.push_back(E->getManglingNumber());
1579f4a2713aSLionel Sambuc   Code = serialization::EXPR_MATERIALIZE_TEMPORARY;
1580f4a2713aSLionel Sambuc }
1581f4a2713aSLionel Sambuc 
VisitCXXFoldExpr(CXXFoldExpr * E)1582*0a6a1f1dSLionel Sambuc void ASTStmtWriter::VisitCXXFoldExpr(CXXFoldExpr *E) {
1583*0a6a1f1dSLionel Sambuc   VisitExpr(E);
1584*0a6a1f1dSLionel Sambuc   Writer.AddSourceLocation(E->LParenLoc, Record);
1585*0a6a1f1dSLionel Sambuc   Writer.AddSourceLocation(E->EllipsisLoc, Record);
1586*0a6a1f1dSLionel Sambuc   Writer.AddSourceLocation(E->RParenLoc, Record);
1587*0a6a1f1dSLionel Sambuc   Writer.AddStmt(E->SubExprs[0]);
1588*0a6a1f1dSLionel Sambuc   Writer.AddStmt(E->SubExprs[1]);
1589*0a6a1f1dSLionel Sambuc   Record.push_back(E->Opcode);
1590*0a6a1f1dSLionel Sambuc   Code = serialization::EXPR_CXX_FOLD;
1591*0a6a1f1dSLionel Sambuc }
1592*0a6a1f1dSLionel Sambuc 
VisitOpaqueValueExpr(OpaqueValueExpr * E)1593f4a2713aSLionel Sambuc void ASTStmtWriter::VisitOpaqueValueExpr(OpaqueValueExpr *E) {
1594f4a2713aSLionel Sambuc   VisitExpr(E);
1595f4a2713aSLionel Sambuc   Writer.AddStmt(E->getSourceExpr());
1596f4a2713aSLionel Sambuc   Writer.AddSourceLocation(E->getLocation(), Record);
1597f4a2713aSLionel Sambuc   Code = serialization::EXPR_OPAQUE_VALUE;
1598f4a2713aSLionel Sambuc }
1599f4a2713aSLionel Sambuc 
VisitTypoExpr(TypoExpr * E)1600*0a6a1f1dSLionel Sambuc void ASTStmtWriter::VisitTypoExpr(TypoExpr *E) {
1601*0a6a1f1dSLionel Sambuc   VisitExpr(E);
1602*0a6a1f1dSLionel Sambuc   // TODO: Figure out sane writer behavior for a TypoExpr, if necessary
1603*0a6a1f1dSLionel Sambuc   assert(false && "Cannot write TypoExpr nodes");
1604*0a6a1f1dSLionel Sambuc }
1605*0a6a1f1dSLionel Sambuc 
1606f4a2713aSLionel Sambuc //===----------------------------------------------------------------------===//
1607f4a2713aSLionel Sambuc // CUDA Expressions and Statements.
1608f4a2713aSLionel Sambuc //===----------------------------------------------------------------------===//
1609f4a2713aSLionel Sambuc 
VisitCUDAKernelCallExpr(CUDAKernelCallExpr * E)1610f4a2713aSLionel Sambuc void ASTStmtWriter::VisitCUDAKernelCallExpr(CUDAKernelCallExpr *E) {
1611f4a2713aSLionel Sambuc   VisitCallExpr(E);
1612f4a2713aSLionel Sambuc   Writer.AddStmt(E->getConfig());
1613f4a2713aSLionel Sambuc   Code = serialization::EXPR_CUDA_KERNEL_CALL;
1614f4a2713aSLionel Sambuc }
1615f4a2713aSLionel Sambuc 
1616f4a2713aSLionel Sambuc //===----------------------------------------------------------------------===//
1617f4a2713aSLionel Sambuc // OpenCL Expressions and Statements.
1618f4a2713aSLionel Sambuc //===----------------------------------------------------------------------===//
VisitAsTypeExpr(AsTypeExpr * E)1619f4a2713aSLionel Sambuc void ASTStmtWriter::VisitAsTypeExpr(AsTypeExpr *E) {
1620f4a2713aSLionel Sambuc   VisitExpr(E);
1621f4a2713aSLionel Sambuc   Writer.AddSourceLocation(E->getBuiltinLoc(), Record);
1622f4a2713aSLionel Sambuc   Writer.AddSourceLocation(E->getRParenLoc(), Record);
1623f4a2713aSLionel Sambuc   Writer.AddStmt(E->getSrcExpr());
1624f4a2713aSLionel Sambuc   Code = serialization::EXPR_ASTYPE;
1625f4a2713aSLionel Sambuc }
1626f4a2713aSLionel Sambuc 
1627f4a2713aSLionel Sambuc //===----------------------------------------------------------------------===//
1628f4a2713aSLionel Sambuc // Microsoft Expressions and Statements.
1629f4a2713aSLionel Sambuc //===----------------------------------------------------------------------===//
VisitMSPropertyRefExpr(MSPropertyRefExpr * E)1630f4a2713aSLionel Sambuc void ASTStmtWriter::VisitMSPropertyRefExpr(MSPropertyRefExpr *E) {
1631f4a2713aSLionel Sambuc   VisitExpr(E);
1632f4a2713aSLionel Sambuc   Record.push_back(E->isArrow());
1633f4a2713aSLionel Sambuc   Writer.AddStmt(E->getBaseExpr());
1634f4a2713aSLionel Sambuc   Writer.AddNestedNameSpecifierLoc(E->getQualifierLoc(), Record);
1635f4a2713aSLionel Sambuc   Writer.AddSourceLocation(E->getMemberLoc(), Record);
1636f4a2713aSLionel Sambuc   Writer.AddDeclRef(E->getPropertyDecl(), Record);
1637f4a2713aSLionel Sambuc   Code = serialization::EXPR_CXX_PROPERTY_REF_EXPR;
1638f4a2713aSLionel Sambuc }
1639f4a2713aSLionel Sambuc 
VisitCXXUuidofExpr(CXXUuidofExpr * E)1640f4a2713aSLionel Sambuc void ASTStmtWriter::VisitCXXUuidofExpr(CXXUuidofExpr *E) {
1641f4a2713aSLionel Sambuc   VisitExpr(E);
1642f4a2713aSLionel Sambuc   Writer.AddSourceRange(E->getSourceRange(), Record);
1643f4a2713aSLionel Sambuc   if (E->isTypeOperand()) {
1644f4a2713aSLionel Sambuc     Writer.AddTypeSourceInfo(E->getTypeOperandSourceInfo(), Record);
1645f4a2713aSLionel Sambuc     Code = serialization::EXPR_CXX_UUIDOF_TYPE;
1646f4a2713aSLionel Sambuc   } else {
1647f4a2713aSLionel Sambuc     Writer.AddStmt(E->getExprOperand());
1648f4a2713aSLionel Sambuc     Code = serialization::EXPR_CXX_UUIDOF_EXPR;
1649f4a2713aSLionel Sambuc   }
1650f4a2713aSLionel Sambuc }
1651f4a2713aSLionel Sambuc 
VisitSEHExceptStmt(SEHExceptStmt * S)1652f4a2713aSLionel Sambuc void ASTStmtWriter::VisitSEHExceptStmt(SEHExceptStmt *S) {
1653f4a2713aSLionel Sambuc   VisitStmt(S);
1654f4a2713aSLionel Sambuc   Writer.AddSourceLocation(S->getExceptLoc(), Record);
1655f4a2713aSLionel Sambuc   Writer.AddStmt(S->getFilterExpr());
1656f4a2713aSLionel Sambuc   Writer.AddStmt(S->getBlock());
1657f4a2713aSLionel Sambuc   Code = serialization::STMT_SEH_EXCEPT;
1658f4a2713aSLionel Sambuc }
1659f4a2713aSLionel Sambuc 
VisitSEHFinallyStmt(SEHFinallyStmt * S)1660f4a2713aSLionel Sambuc void ASTStmtWriter::VisitSEHFinallyStmt(SEHFinallyStmt *S) {
1661f4a2713aSLionel Sambuc   VisitStmt(S);
1662f4a2713aSLionel Sambuc   Writer.AddSourceLocation(S->getFinallyLoc(), Record);
1663f4a2713aSLionel Sambuc   Writer.AddStmt(S->getBlock());
1664f4a2713aSLionel Sambuc   Code = serialization::STMT_SEH_FINALLY;
1665f4a2713aSLionel Sambuc }
1666f4a2713aSLionel Sambuc 
VisitSEHTryStmt(SEHTryStmt * S)1667f4a2713aSLionel Sambuc void ASTStmtWriter::VisitSEHTryStmt(SEHTryStmt *S) {
1668f4a2713aSLionel Sambuc   VisitStmt(S);
1669f4a2713aSLionel Sambuc   Record.push_back(S->getIsCXXTry());
1670f4a2713aSLionel Sambuc   Writer.AddSourceLocation(S->getTryLoc(), Record);
1671f4a2713aSLionel Sambuc   Writer.AddStmt(S->getTryBlock());
1672f4a2713aSLionel Sambuc   Writer.AddStmt(S->getHandler());
1673f4a2713aSLionel Sambuc   Code = serialization::STMT_SEH_TRY;
1674f4a2713aSLionel Sambuc }
1675f4a2713aSLionel Sambuc 
VisitSEHLeaveStmt(SEHLeaveStmt * S)1676*0a6a1f1dSLionel Sambuc void ASTStmtWriter::VisitSEHLeaveStmt(SEHLeaveStmt *S) {
1677*0a6a1f1dSLionel Sambuc   VisitStmt(S);
1678*0a6a1f1dSLionel Sambuc   Writer.AddSourceLocation(S->getLeaveLoc(), Record);
1679*0a6a1f1dSLionel Sambuc   Code = serialization::STMT_SEH_LEAVE;
1680*0a6a1f1dSLionel Sambuc }
1681*0a6a1f1dSLionel Sambuc 
1682f4a2713aSLionel Sambuc //===----------------------------------------------------------------------===//
1683f4a2713aSLionel Sambuc // OpenMP Clauses.
1684f4a2713aSLionel Sambuc //===----------------------------------------------------------------------===//
1685f4a2713aSLionel Sambuc 
1686f4a2713aSLionel Sambuc namespace clang {
1687f4a2713aSLionel Sambuc class OMPClauseWriter : public OMPClauseVisitor<OMPClauseWriter> {
1688f4a2713aSLionel Sambuc   ASTStmtWriter *Writer;
1689f4a2713aSLionel Sambuc   ASTWriter::RecordData &Record;
1690f4a2713aSLionel Sambuc public:
OMPClauseWriter(ASTStmtWriter * W,ASTWriter::RecordData & Record)1691f4a2713aSLionel Sambuc   OMPClauseWriter(ASTStmtWriter *W, ASTWriter::RecordData &Record)
1692f4a2713aSLionel Sambuc     : Writer(W), Record(Record) { }
1693f4a2713aSLionel Sambuc #define OPENMP_CLAUSE(Name, Class)    \
1694f4a2713aSLionel Sambuc   void Visit##Class(Class *S);
1695f4a2713aSLionel Sambuc #include "clang/Basic/OpenMPKinds.def"
1696f4a2713aSLionel Sambuc   void writeClause(OMPClause *C);
1697f4a2713aSLionel Sambuc };
1698f4a2713aSLionel Sambuc }
1699f4a2713aSLionel Sambuc 
writeClause(OMPClause * C)1700f4a2713aSLionel Sambuc void OMPClauseWriter::writeClause(OMPClause *C) {
1701f4a2713aSLionel Sambuc   Record.push_back(C->getClauseKind());
1702f4a2713aSLionel Sambuc   Visit(C);
1703f4a2713aSLionel Sambuc   Writer->Writer.AddSourceLocation(C->getLocStart(), Record);
1704f4a2713aSLionel Sambuc   Writer->Writer.AddSourceLocation(C->getLocEnd(), Record);
1705f4a2713aSLionel Sambuc }
1706f4a2713aSLionel Sambuc 
VisitOMPIfClause(OMPIfClause * C)1707*0a6a1f1dSLionel Sambuc void OMPClauseWriter::VisitOMPIfClause(OMPIfClause *C) {
1708*0a6a1f1dSLionel Sambuc   Writer->Writer.AddStmt(C->getCondition());
1709*0a6a1f1dSLionel Sambuc   Writer->Writer.AddSourceLocation(C->getLParenLoc(), Record);
1710*0a6a1f1dSLionel Sambuc }
1711*0a6a1f1dSLionel Sambuc 
VisitOMPFinalClause(OMPFinalClause * C)1712*0a6a1f1dSLionel Sambuc void OMPClauseWriter::VisitOMPFinalClause(OMPFinalClause *C) {
1713*0a6a1f1dSLionel Sambuc   Writer->Writer.AddStmt(C->getCondition());
1714*0a6a1f1dSLionel Sambuc   Writer->Writer.AddSourceLocation(C->getLParenLoc(), Record);
1715*0a6a1f1dSLionel Sambuc }
1716*0a6a1f1dSLionel Sambuc 
VisitOMPNumThreadsClause(OMPNumThreadsClause * C)1717*0a6a1f1dSLionel Sambuc void OMPClauseWriter::VisitOMPNumThreadsClause(OMPNumThreadsClause *C) {
1718*0a6a1f1dSLionel Sambuc   Writer->Writer.AddStmt(C->getNumThreads());
1719*0a6a1f1dSLionel Sambuc   Writer->Writer.AddSourceLocation(C->getLParenLoc(), Record);
1720*0a6a1f1dSLionel Sambuc }
1721*0a6a1f1dSLionel Sambuc 
VisitOMPSafelenClause(OMPSafelenClause * C)1722*0a6a1f1dSLionel Sambuc void OMPClauseWriter::VisitOMPSafelenClause(OMPSafelenClause *C) {
1723*0a6a1f1dSLionel Sambuc   Writer->Writer.AddStmt(C->getSafelen());
1724*0a6a1f1dSLionel Sambuc   Writer->Writer.AddSourceLocation(C->getLParenLoc(), Record);
1725*0a6a1f1dSLionel Sambuc }
1726*0a6a1f1dSLionel Sambuc 
VisitOMPCollapseClause(OMPCollapseClause * C)1727*0a6a1f1dSLionel Sambuc void OMPClauseWriter::VisitOMPCollapseClause(OMPCollapseClause *C) {
1728*0a6a1f1dSLionel Sambuc   Writer->Writer.AddStmt(C->getNumForLoops());
1729*0a6a1f1dSLionel Sambuc   Writer->Writer.AddSourceLocation(C->getLParenLoc(), Record);
1730*0a6a1f1dSLionel Sambuc }
1731*0a6a1f1dSLionel Sambuc 
VisitOMPDefaultClause(OMPDefaultClause * C)1732f4a2713aSLionel Sambuc void OMPClauseWriter::VisitOMPDefaultClause(OMPDefaultClause *C) {
1733f4a2713aSLionel Sambuc   Record.push_back(C->getDefaultKind());
1734f4a2713aSLionel Sambuc   Writer->Writer.AddSourceLocation(C->getLParenLoc(), Record);
1735f4a2713aSLionel Sambuc   Writer->Writer.AddSourceLocation(C->getDefaultKindKwLoc(), Record);
1736f4a2713aSLionel Sambuc }
1737f4a2713aSLionel Sambuc 
VisitOMPProcBindClause(OMPProcBindClause * C)1738*0a6a1f1dSLionel Sambuc void OMPClauseWriter::VisitOMPProcBindClause(OMPProcBindClause *C) {
1739*0a6a1f1dSLionel Sambuc   Record.push_back(C->getProcBindKind());
1740*0a6a1f1dSLionel Sambuc   Writer->Writer.AddSourceLocation(C->getLParenLoc(), Record);
1741*0a6a1f1dSLionel Sambuc   Writer->Writer.AddSourceLocation(C->getProcBindKindKwLoc(), Record);
1742*0a6a1f1dSLionel Sambuc }
1743*0a6a1f1dSLionel Sambuc 
VisitOMPScheduleClause(OMPScheduleClause * C)1744*0a6a1f1dSLionel Sambuc void OMPClauseWriter::VisitOMPScheduleClause(OMPScheduleClause *C) {
1745*0a6a1f1dSLionel Sambuc   Record.push_back(C->getScheduleKind());
1746*0a6a1f1dSLionel Sambuc   Writer->Writer.AddStmt(C->getChunkSize());
1747*0a6a1f1dSLionel Sambuc   Writer->Writer.AddSourceLocation(C->getLParenLoc(), Record);
1748*0a6a1f1dSLionel Sambuc   Writer->Writer.AddSourceLocation(C->getScheduleKindLoc(), Record);
1749*0a6a1f1dSLionel Sambuc   Writer->Writer.AddSourceLocation(C->getCommaLoc(), Record);
1750*0a6a1f1dSLionel Sambuc }
1751*0a6a1f1dSLionel Sambuc 
VisitOMPOrderedClause(OMPOrderedClause *)1752*0a6a1f1dSLionel Sambuc void OMPClauseWriter::VisitOMPOrderedClause(OMPOrderedClause *) {}
1753*0a6a1f1dSLionel Sambuc 
VisitOMPNowaitClause(OMPNowaitClause *)1754*0a6a1f1dSLionel Sambuc void OMPClauseWriter::VisitOMPNowaitClause(OMPNowaitClause *) {}
1755*0a6a1f1dSLionel Sambuc 
VisitOMPUntiedClause(OMPUntiedClause *)1756*0a6a1f1dSLionel Sambuc void OMPClauseWriter::VisitOMPUntiedClause(OMPUntiedClause *) {}
1757*0a6a1f1dSLionel Sambuc 
VisitOMPMergeableClause(OMPMergeableClause *)1758*0a6a1f1dSLionel Sambuc void OMPClauseWriter::VisitOMPMergeableClause(OMPMergeableClause *) {}
1759*0a6a1f1dSLionel Sambuc 
VisitOMPReadClause(OMPReadClause *)1760*0a6a1f1dSLionel Sambuc void OMPClauseWriter::VisitOMPReadClause(OMPReadClause *) {}
1761*0a6a1f1dSLionel Sambuc 
VisitOMPWriteClause(OMPWriteClause *)1762*0a6a1f1dSLionel Sambuc void OMPClauseWriter::VisitOMPWriteClause(OMPWriteClause *) {}
1763*0a6a1f1dSLionel Sambuc 
VisitOMPUpdateClause(OMPUpdateClause *)1764*0a6a1f1dSLionel Sambuc void OMPClauseWriter::VisitOMPUpdateClause(OMPUpdateClause *) {}
1765*0a6a1f1dSLionel Sambuc 
VisitOMPCaptureClause(OMPCaptureClause *)1766*0a6a1f1dSLionel Sambuc void OMPClauseWriter::VisitOMPCaptureClause(OMPCaptureClause *) {}
1767*0a6a1f1dSLionel Sambuc 
VisitOMPSeqCstClause(OMPSeqCstClause *)1768*0a6a1f1dSLionel Sambuc void OMPClauseWriter::VisitOMPSeqCstClause(OMPSeqCstClause *) {}
1769*0a6a1f1dSLionel Sambuc 
VisitOMPPrivateClause(OMPPrivateClause * C)1770f4a2713aSLionel Sambuc void OMPClauseWriter::VisitOMPPrivateClause(OMPPrivateClause *C) {
1771f4a2713aSLionel Sambuc   Record.push_back(C->varlist_size());
1772f4a2713aSLionel Sambuc   Writer->Writer.AddSourceLocation(C->getLParenLoc(), Record);
1773*0a6a1f1dSLionel Sambuc   for (auto *VE : C->varlists()) {
1774*0a6a1f1dSLionel Sambuc     Writer->Writer.AddStmt(VE);
1775*0a6a1f1dSLionel Sambuc   }
1776*0a6a1f1dSLionel Sambuc   for (auto *VE : C->private_copies()) {
1777*0a6a1f1dSLionel Sambuc     Writer->Writer.AddStmt(VE);
1778*0a6a1f1dSLionel Sambuc   }
1779f4a2713aSLionel Sambuc }
1780f4a2713aSLionel Sambuc 
VisitOMPFirstprivateClause(OMPFirstprivateClause * C)1781f4a2713aSLionel Sambuc void OMPClauseWriter::VisitOMPFirstprivateClause(OMPFirstprivateClause *C) {
1782f4a2713aSLionel Sambuc   Record.push_back(C->varlist_size());
1783f4a2713aSLionel Sambuc   Writer->Writer.AddSourceLocation(C->getLParenLoc(), Record);
1784*0a6a1f1dSLionel Sambuc   for (auto *VE : C->varlists()) {
1785*0a6a1f1dSLionel Sambuc     Writer->Writer.AddStmt(VE);
1786*0a6a1f1dSLionel Sambuc   }
1787*0a6a1f1dSLionel Sambuc   for (auto *VE : C->private_copies()) {
1788*0a6a1f1dSLionel Sambuc     Writer->Writer.AddStmt(VE);
1789*0a6a1f1dSLionel Sambuc   }
1790*0a6a1f1dSLionel Sambuc   for (auto *VE : C->inits()) {
1791*0a6a1f1dSLionel Sambuc     Writer->Writer.AddStmt(VE);
1792*0a6a1f1dSLionel Sambuc   }
1793*0a6a1f1dSLionel Sambuc }
1794*0a6a1f1dSLionel Sambuc 
VisitOMPLastprivateClause(OMPLastprivateClause * C)1795*0a6a1f1dSLionel Sambuc void OMPClauseWriter::VisitOMPLastprivateClause(OMPLastprivateClause *C) {
1796*0a6a1f1dSLionel Sambuc   Record.push_back(C->varlist_size());
1797*0a6a1f1dSLionel Sambuc   Writer->Writer.AddSourceLocation(C->getLParenLoc(), Record);
1798*0a6a1f1dSLionel Sambuc   for (auto *VE : C->varlists())
1799*0a6a1f1dSLionel Sambuc     Writer->Writer.AddStmt(VE);
1800f4a2713aSLionel Sambuc }
1801f4a2713aSLionel Sambuc 
VisitOMPSharedClause(OMPSharedClause * C)1802f4a2713aSLionel Sambuc void OMPClauseWriter::VisitOMPSharedClause(OMPSharedClause *C) {
1803f4a2713aSLionel Sambuc   Record.push_back(C->varlist_size());
1804f4a2713aSLionel Sambuc   Writer->Writer.AddSourceLocation(C->getLParenLoc(), Record);
1805*0a6a1f1dSLionel Sambuc   for (auto *VE : C->varlists())
1806*0a6a1f1dSLionel Sambuc     Writer->Writer.AddStmt(VE);
1807*0a6a1f1dSLionel Sambuc }
1808*0a6a1f1dSLionel Sambuc 
VisitOMPReductionClause(OMPReductionClause * C)1809*0a6a1f1dSLionel Sambuc void OMPClauseWriter::VisitOMPReductionClause(OMPReductionClause *C) {
1810*0a6a1f1dSLionel Sambuc   Record.push_back(C->varlist_size());
1811*0a6a1f1dSLionel Sambuc   Writer->Writer.AddSourceLocation(C->getLParenLoc(), Record);
1812*0a6a1f1dSLionel Sambuc   Writer->Writer.AddSourceLocation(C->getColonLoc(), Record);
1813*0a6a1f1dSLionel Sambuc   Writer->Writer.AddNestedNameSpecifierLoc(C->getQualifierLoc(), Record);
1814*0a6a1f1dSLionel Sambuc   Writer->Writer.AddDeclarationNameInfo(C->getNameInfo(), Record);
1815*0a6a1f1dSLionel Sambuc   for (auto *VE : C->varlists())
1816*0a6a1f1dSLionel Sambuc     Writer->Writer.AddStmt(VE);
1817*0a6a1f1dSLionel Sambuc }
1818*0a6a1f1dSLionel Sambuc 
VisitOMPLinearClause(OMPLinearClause * C)1819*0a6a1f1dSLionel Sambuc void OMPClauseWriter::VisitOMPLinearClause(OMPLinearClause *C) {
1820*0a6a1f1dSLionel Sambuc   Record.push_back(C->varlist_size());
1821*0a6a1f1dSLionel Sambuc   Writer->Writer.AddSourceLocation(C->getLParenLoc(), Record);
1822*0a6a1f1dSLionel Sambuc   Writer->Writer.AddSourceLocation(C->getColonLoc(), Record);
1823*0a6a1f1dSLionel Sambuc   for (auto *VE : C->varlists())
1824*0a6a1f1dSLionel Sambuc     Writer->Writer.AddStmt(VE);
1825*0a6a1f1dSLionel Sambuc   Writer->Writer.AddStmt(C->getStep());
1826*0a6a1f1dSLionel Sambuc }
1827*0a6a1f1dSLionel Sambuc 
VisitOMPAlignedClause(OMPAlignedClause * C)1828*0a6a1f1dSLionel Sambuc void OMPClauseWriter::VisitOMPAlignedClause(OMPAlignedClause *C) {
1829*0a6a1f1dSLionel Sambuc   Record.push_back(C->varlist_size());
1830*0a6a1f1dSLionel Sambuc   Writer->Writer.AddSourceLocation(C->getLParenLoc(), Record);
1831*0a6a1f1dSLionel Sambuc   Writer->Writer.AddSourceLocation(C->getColonLoc(), Record);
1832*0a6a1f1dSLionel Sambuc   for (auto *VE : C->varlists())
1833*0a6a1f1dSLionel Sambuc     Writer->Writer.AddStmt(VE);
1834*0a6a1f1dSLionel Sambuc   Writer->Writer.AddStmt(C->getAlignment());
1835*0a6a1f1dSLionel Sambuc }
1836*0a6a1f1dSLionel Sambuc 
VisitOMPCopyinClause(OMPCopyinClause * C)1837*0a6a1f1dSLionel Sambuc void OMPClauseWriter::VisitOMPCopyinClause(OMPCopyinClause *C) {
1838*0a6a1f1dSLionel Sambuc   Record.push_back(C->varlist_size());
1839*0a6a1f1dSLionel Sambuc   Writer->Writer.AddSourceLocation(C->getLParenLoc(), Record);
1840*0a6a1f1dSLionel Sambuc   for (auto *VE : C->varlists())
1841*0a6a1f1dSLionel Sambuc     Writer->Writer.AddStmt(VE);
1842*0a6a1f1dSLionel Sambuc }
1843*0a6a1f1dSLionel Sambuc 
VisitOMPCopyprivateClause(OMPCopyprivateClause * C)1844*0a6a1f1dSLionel Sambuc void OMPClauseWriter::VisitOMPCopyprivateClause(OMPCopyprivateClause *C) {
1845*0a6a1f1dSLionel Sambuc   Record.push_back(C->varlist_size());
1846*0a6a1f1dSLionel Sambuc   Writer->Writer.AddSourceLocation(C->getLParenLoc(), Record);
1847*0a6a1f1dSLionel Sambuc   for (auto *VE : C->varlists())
1848*0a6a1f1dSLionel Sambuc     Writer->Writer.AddStmt(VE);
1849*0a6a1f1dSLionel Sambuc }
1850*0a6a1f1dSLionel Sambuc 
VisitOMPFlushClause(OMPFlushClause * C)1851*0a6a1f1dSLionel Sambuc void OMPClauseWriter::VisitOMPFlushClause(OMPFlushClause *C) {
1852*0a6a1f1dSLionel Sambuc   Record.push_back(C->varlist_size());
1853*0a6a1f1dSLionel Sambuc   Writer->Writer.AddSourceLocation(C->getLParenLoc(), Record);
1854*0a6a1f1dSLionel Sambuc   for (auto *VE : C->varlists())
1855*0a6a1f1dSLionel Sambuc     Writer->Writer.AddStmt(VE);
1856f4a2713aSLionel Sambuc }
1857f4a2713aSLionel Sambuc 
1858f4a2713aSLionel Sambuc //===----------------------------------------------------------------------===//
1859f4a2713aSLionel Sambuc // OpenMP Directives.
1860f4a2713aSLionel Sambuc //===----------------------------------------------------------------------===//
VisitOMPExecutableDirective(OMPExecutableDirective * E)1861f4a2713aSLionel Sambuc void ASTStmtWriter::VisitOMPExecutableDirective(OMPExecutableDirective *E) {
1862f4a2713aSLionel Sambuc   Writer.AddSourceLocation(E->getLocStart(), Record);
1863f4a2713aSLionel Sambuc   Writer.AddSourceLocation(E->getLocEnd(), Record);
1864f4a2713aSLionel Sambuc   OMPClauseWriter ClauseWriter(this, Record);
1865f4a2713aSLionel Sambuc   for (unsigned i = 0; i < E->getNumClauses(); ++i) {
1866f4a2713aSLionel Sambuc     ClauseWriter.writeClause(E->getClause(i));
1867f4a2713aSLionel Sambuc   }
1868*0a6a1f1dSLionel Sambuc   if (E->hasAssociatedStmt())
1869f4a2713aSLionel Sambuc     Writer.AddStmt(E->getAssociatedStmt());
1870f4a2713aSLionel Sambuc }
1871f4a2713aSLionel Sambuc 
VisitOMPLoopDirective(OMPLoopDirective * D)1872*0a6a1f1dSLionel Sambuc void ASTStmtWriter::VisitOMPLoopDirective(OMPLoopDirective *D) {
1873*0a6a1f1dSLionel Sambuc   VisitStmt(D);
1874*0a6a1f1dSLionel Sambuc   Record.push_back(D->getNumClauses());
1875*0a6a1f1dSLionel Sambuc   Record.push_back(D->getCollapsedNumber());
1876*0a6a1f1dSLionel Sambuc   VisitOMPExecutableDirective(D);
1877*0a6a1f1dSLionel Sambuc   Writer.AddStmt(D->getIterationVariable());
1878*0a6a1f1dSLionel Sambuc   Writer.AddStmt(D->getLastIteration());
1879*0a6a1f1dSLionel Sambuc   Writer.AddStmt(D->getCalcLastIteration());
1880*0a6a1f1dSLionel Sambuc   Writer.AddStmt(D->getPreCond());
1881*0a6a1f1dSLionel Sambuc   Writer.AddStmt(D->getCond(/* SeparateIter */ false));
1882*0a6a1f1dSLionel Sambuc   Writer.AddStmt(D->getCond(/* SeparateIter */ true));
1883*0a6a1f1dSLionel Sambuc   Writer.AddStmt(D->getInit());
1884*0a6a1f1dSLionel Sambuc   Writer.AddStmt(D->getInc());
1885*0a6a1f1dSLionel Sambuc   if (isOpenMPWorksharingDirective(D->getDirectiveKind())) {
1886*0a6a1f1dSLionel Sambuc     Writer.AddStmt(D->getIsLastIterVariable());
1887*0a6a1f1dSLionel Sambuc     Writer.AddStmt(D->getLowerBoundVariable());
1888*0a6a1f1dSLionel Sambuc     Writer.AddStmt(D->getUpperBoundVariable());
1889*0a6a1f1dSLionel Sambuc     Writer.AddStmt(D->getStrideVariable());
1890*0a6a1f1dSLionel Sambuc     Writer.AddStmt(D->getEnsureUpperBound());
1891*0a6a1f1dSLionel Sambuc     Writer.AddStmt(D->getNextLowerBound());
1892*0a6a1f1dSLionel Sambuc     Writer.AddStmt(D->getNextUpperBound());
1893*0a6a1f1dSLionel Sambuc   }
1894*0a6a1f1dSLionel Sambuc   for (auto I : D->counters()) {
1895*0a6a1f1dSLionel Sambuc     Writer.AddStmt(I);
1896*0a6a1f1dSLionel Sambuc   }
1897*0a6a1f1dSLionel Sambuc   for (auto I : D->updates()) {
1898*0a6a1f1dSLionel Sambuc     Writer.AddStmt(I);
1899*0a6a1f1dSLionel Sambuc   }
1900*0a6a1f1dSLionel Sambuc   for (auto I : D->finals()) {
1901*0a6a1f1dSLionel Sambuc     Writer.AddStmt(I);
1902*0a6a1f1dSLionel Sambuc   }
1903*0a6a1f1dSLionel Sambuc }
1904*0a6a1f1dSLionel Sambuc 
VisitOMPParallelDirective(OMPParallelDirective * D)1905f4a2713aSLionel Sambuc void ASTStmtWriter::VisitOMPParallelDirective(OMPParallelDirective *D) {
1906*0a6a1f1dSLionel Sambuc   VisitStmt(D);
1907*0a6a1f1dSLionel Sambuc   Record.push_back(D->getNumClauses());
1908f4a2713aSLionel Sambuc   VisitOMPExecutableDirective(D);
1909f4a2713aSLionel Sambuc   Code = serialization::STMT_OMP_PARALLEL_DIRECTIVE;
1910f4a2713aSLionel Sambuc }
1911f4a2713aSLionel Sambuc 
VisitOMPSimdDirective(OMPSimdDirective * D)1912*0a6a1f1dSLionel Sambuc void ASTStmtWriter::VisitOMPSimdDirective(OMPSimdDirective *D) {
1913*0a6a1f1dSLionel Sambuc   VisitOMPLoopDirective(D);
1914*0a6a1f1dSLionel Sambuc   Code = serialization::STMT_OMP_SIMD_DIRECTIVE;
1915*0a6a1f1dSLionel Sambuc }
1916*0a6a1f1dSLionel Sambuc 
VisitOMPForDirective(OMPForDirective * D)1917*0a6a1f1dSLionel Sambuc void ASTStmtWriter::VisitOMPForDirective(OMPForDirective *D) {
1918*0a6a1f1dSLionel Sambuc   VisitOMPLoopDirective(D);
1919*0a6a1f1dSLionel Sambuc   Code = serialization::STMT_OMP_FOR_DIRECTIVE;
1920*0a6a1f1dSLionel Sambuc }
1921*0a6a1f1dSLionel Sambuc 
VisitOMPForSimdDirective(OMPForSimdDirective * D)1922*0a6a1f1dSLionel Sambuc void ASTStmtWriter::VisitOMPForSimdDirective(OMPForSimdDirective *D) {
1923*0a6a1f1dSLionel Sambuc   VisitOMPLoopDirective(D);
1924*0a6a1f1dSLionel Sambuc   Code = serialization::STMT_OMP_FOR_SIMD_DIRECTIVE;
1925*0a6a1f1dSLionel Sambuc }
1926*0a6a1f1dSLionel Sambuc 
VisitOMPSectionsDirective(OMPSectionsDirective * D)1927*0a6a1f1dSLionel Sambuc void ASTStmtWriter::VisitOMPSectionsDirective(OMPSectionsDirective *D) {
1928*0a6a1f1dSLionel Sambuc   VisitStmt(D);
1929*0a6a1f1dSLionel Sambuc   Record.push_back(D->getNumClauses());
1930*0a6a1f1dSLionel Sambuc   VisitOMPExecutableDirective(D);
1931*0a6a1f1dSLionel Sambuc   Code = serialization::STMT_OMP_SECTIONS_DIRECTIVE;
1932*0a6a1f1dSLionel Sambuc }
1933*0a6a1f1dSLionel Sambuc 
VisitOMPSectionDirective(OMPSectionDirective * D)1934*0a6a1f1dSLionel Sambuc void ASTStmtWriter::VisitOMPSectionDirective(OMPSectionDirective *D) {
1935*0a6a1f1dSLionel Sambuc   VisitStmt(D);
1936*0a6a1f1dSLionel Sambuc   VisitOMPExecutableDirective(D);
1937*0a6a1f1dSLionel Sambuc   Code = serialization::STMT_OMP_SECTION_DIRECTIVE;
1938*0a6a1f1dSLionel Sambuc }
1939*0a6a1f1dSLionel Sambuc 
VisitOMPSingleDirective(OMPSingleDirective * D)1940*0a6a1f1dSLionel Sambuc void ASTStmtWriter::VisitOMPSingleDirective(OMPSingleDirective *D) {
1941*0a6a1f1dSLionel Sambuc   VisitStmt(D);
1942*0a6a1f1dSLionel Sambuc   Record.push_back(D->getNumClauses());
1943*0a6a1f1dSLionel Sambuc   VisitOMPExecutableDirective(D);
1944*0a6a1f1dSLionel Sambuc   Code = serialization::STMT_OMP_SINGLE_DIRECTIVE;
1945*0a6a1f1dSLionel Sambuc }
1946*0a6a1f1dSLionel Sambuc 
VisitOMPMasterDirective(OMPMasterDirective * D)1947*0a6a1f1dSLionel Sambuc void ASTStmtWriter::VisitOMPMasterDirective(OMPMasterDirective *D) {
1948*0a6a1f1dSLionel Sambuc   VisitStmt(D);
1949*0a6a1f1dSLionel Sambuc   VisitOMPExecutableDirective(D);
1950*0a6a1f1dSLionel Sambuc   Code = serialization::STMT_OMP_MASTER_DIRECTIVE;
1951*0a6a1f1dSLionel Sambuc }
1952*0a6a1f1dSLionel Sambuc 
VisitOMPCriticalDirective(OMPCriticalDirective * D)1953*0a6a1f1dSLionel Sambuc void ASTStmtWriter::VisitOMPCriticalDirective(OMPCriticalDirective *D) {
1954*0a6a1f1dSLionel Sambuc   VisitStmt(D);
1955*0a6a1f1dSLionel Sambuc   VisitOMPExecutableDirective(D);
1956*0a6a1f1dSLionel Sambuc   Writer.AddDeclarationNameInfo(D->getDirectiveName(), Record);
1957*0a6a1f1dSLionel Sambuc   Code = serialization::STMT_OMP_CRITICAL_DIRECTIVE;
1958*0a6a1f1dSLionel Sambuc }
1959*0a6a1f1dSLionel Sambuc 
VisitOMPParallelForDirective(OMPParallelForDirective * D)1960*0a6a1f1dSLionel Sambuc void ASTStmtWriter::VisitOMPParallelForDirective(OMPParallelForDirective *D) {
1961*0a6a1f1dSLionel Sambuc   VisitOMPLoopDirective(D);
1962*0a6a1f1dSLionel Sambuc   Code = serialization::STMT_OMP_PARALLEL_FOR_DIRECTIVE;
1963*0a6a1f1dSLionel Sambuc }
1964*0a6a1f1dSLionel Sambuc 
VisitOMPParallelForSimdDirective(OMPParallelForSimdDirective * D)1965*0a6a1f1dSLionel Sambuc void ASTStmtWriter::VisitOMPParallelForSimdDirective(
1966*0a6a1f1dSLionel Sambuc     OMPParallelForSimdDirective *D) {
1967*0a6a1f1dSLionel Sambuc   VisitOMPLoopDirective(D);
1968*0a6a1f1dSLionel Sambuc   Code = serialization::STMT_OMP_PARALLEL_FOR_SIMD_DIRECTIVE;
1969*0a6a1f1dSLionel Sambuc }
1970*0a6a1f1dSLionel Sambuc 
VisitOMPParallelSectionsDirective(OMPParallelSectionsDirective * D)1971*0a6a1f1dSLionel Sambuc void ASTStmtWriter::VisitOMPParallelSectionsDirective(
1972*0a6a1f1dSLionel Sambuc     OMPParallelSectionsDirective *D) {
1973*0a6a1f1dSLionel Sambuc   VisitStmt(D);
1974*0a6a1f1dSLionel Sambuc   Record.push_back(D->getNumClauses());
1975*0a6a1f1dSLionel Sambuc   VisitOMPExecutableDirective(D);
1976*0a6a1f1dSLionel Sambuc   Code = serialization::STMT_OMP_PARALLEL_SECTIONS_DIRECTIVE;
1977*0a6a1f1dSLionel Sambuc }
1978*0a6a1f1dSLionel Sambuc 
VisitOMPTaskDirective(OMPTaskDirective * D)1979*0a6a1f1dSLionel Sambuc void ASTStmtWriter::VisitOMPTaskDirective(OMPTaskDirective *D) {
1980*0a6a1f1dSLionel Sambuc   VisitStmt(D);
1981*0a6a1f1dSLionel Sambuc   Record.push_back(D->getNumClauses());
1982*0a6a1f1dSLionel Sambuc   VisitOMPExecutableDirective(D);
1983*0a6a1f1dSLionel Sambuc   Code = serialization::STMT_OMP_TASK_DIRECTIVE;
1984*0a6a1f1dSLionel Sambuc }
1985*0a6a1f1dSLionel Sambuc 
VisitOMPAtomicDirective(OMPAtomicDirective * D)1986*0a6a1f1dSLionel Sambuc void ASTStmtWriter::VisitOMPAtomicDirective(OMPAtomicDirective *D) {
1987*0a6a1f1dSLionel Sambuc   VisitStmt(D);
1988*0a6a1f1dSLionel Sambuc   Record.push_back(D->getNumClauses());
1989*0a6a1f1dSLionel Sambuc   VisitOMPExecutableDirective(D);
1990*0a6a1f1dSLionel Sambuc   Writer.AddStmt(D->getX());
1991*0a6a1f1dSLionel Sambuc   Writer.AddStmt(D->getV());
1992*0a6a1f1dSLionel Sambuc   Writer.AddStmt(D->getExpr());
1993*0a6a1f1dSLionel Sambuc   Code = serialization::STMT_OMP_ATOMIC_DIRECTIVE;
1994*0a6a1f1dSLionel Sambuc }
1995*0a6a1f1dSLionel Sambuc 
VisitOMPTargetDirective(OMPTargetDirective * D)1996*0a6a1f1dSLionel Sambuc void ASTStmtWriter::VisitOMPTargetDirective(OMPTargetDirective *D) {
1997*0a6a1f1dSLionel Sambuc   VisitStmt(D);
1998*0a6a1f1dSLionel Sambuc   Record.push_back(D->getNumClauses());
1999*0a6a1f1dSLionel Sambuc   VisitOMPExecutableDirective(D);
2000*0a6a1f1dSLionel Sambuc   Code = serialization::STMT_OMP_TARGET_DIRECTIVE;
2001*0a6a1f1dSLionel Sambuc }
2002*0a6a1f1dSLionel Sambuc 
VisitOMPTaskyieldDirective(OMPTaskyieldDirective * D)2003*0a6a1f1dSLionel Sambuc void ASTStmtWriter::VisitOMPTaskyieldDirective(OMPTaskyieldDirective *D) {
2004*0a6a1f1dSLionel Sambuc   VisitStmt(D);
2005*0a6a1f1dSLionel Sambuc   VisitOMPExecutableDirective(D);
2006*0a6a1f1dSLionel Sambuc   Code = serialization::STMT_OMP_TASKYIELD_DIRECTIVE;
2007*0a6a1f1dSLionel Sambuc }
2008*0a6a1f1dSLionel Sambuc 
VisitOMPBarrierDirective(OMPBarrierDirective * D)2009*0a6a1f1dSLionel Sambuc void ASTStmtWriter::VisitOMPBarrierDirective(OMPBarrierDirective *D) {
2010*0a6a1f1dSLionel Sambuc   VisitStmt(D);
2011*0a6a1f1dSLionel Sambuc   VisitOMPExecutableDirective(D);
2012*0a6a1f1dSLionel Sambuc   Code = serialization::STMT_OMP_BARRIER_DIRECTIVE;
2013*0a6a1f1dSLionel Sambuc }
2014*0a6a1f1dSLionel Sambuc 
VisitOMPTaskwaitDirective(OMPTaskwaitDirective * D)2015*0a6a1f1dSLionel Sambuc void ASTStmtWriter::VisitOMPTaskwaitDirective(OMPTaskwaitDirective *D) {
2016*0a6a1f1dSLionel Sambuc   VisitStmt(D);
2017*0a6a1f1dSLionel Sambuc   VisitOMPExecutableDirective(D);
2018*0a6a1f1dSLionel Sambuc   Code = serialization::STMT_OMP_TASKWAIT_DIRECTIVE;
2019*0a6a1f1dSLionel Sambuc }
2020*0a6a1f1dSLionel Sambuc 
VisitOMPFlushDirective(OMPFlushDirective * D)2021*0a6a1f1dSLionel Sambuc void ASTStmtWriter::VisitOMPFlushDirective(OMPFlushDirective *D) {
2022*0a6a1f1dSLionel Sambuc   VisitStmt(D);
2023*0a6a1f1dSLionel Sambuc   Record.push_back(D->getNumClauses());
2024*0a6a1f1dSLionel Sambuc   VisitOMPExecutableDirective(D);
2025*0a6a1f1dSLionel Sambuc   Code = serialization::STMT_OMP_FLUSH_DIRECTIVE;
2026*0a6a1f1dSLionel Sambuc }
2027*0a6a1f1dSLionel Sambuc 
VisitOMPOrderedDirective(OMPOrderedDirective * D)2028*0a6a1f1dSLionel Sambuc void ASTStmtWriter::VisitOMPOrderedDirective(OMPOrderedDirective *D) {
2029*0a6a1f1dSLionel Sambuc   VisitStmt(D);
2030*0a6a1f1dSLionel Sambuc   VisitOMPExecutableDirective(D);
2031*0a6a1f1dSLionel Sambuc   Code = serialization::STMT_OMP_ORDERED_DIRECTIVE;
2032*0a6a1f1dSLionel Sambuc }
2033*0a6a1f1dSLionel Sambuc 
VisitOMPTeamsDirective(OMPTeamsDirective * D)2034*0a6a1f1dSLionel Sambuc void ASTStmtWriter::VisitOMPTeamsDirective(OMPTeamsDirective *D) {
2035*0a6a1f1dSLionel Sambuc   VisitStmt(D);
2036*0a6a1f1dSLionel Sambuc   Record.push_back(D->getNumClauses());
2037*0a6a1f1dSLionel Sambuc   VisitOMPExecutableDirective(D);
2038*0a6a1f1dSLionel Sambuc   Code = serialization::STMT_OMP_TEAMS_DIRECTIVE;
2039*0a6a1f1dSLionel Sambuc }
2040*0a6a1f1dSLionel Sambuc 
2041f4a2713aSLionel Sambuc //===----------------------------------------------------------------------===//
2042f4a2713aSLionel Sambuc // ASTWriter Implementation
2043f4a2713aSLionel Sambuc //===----------------------------------------------------------------------===//
2044f4a2713aSLionel Sambuc 
RecordSwitchCaseID(SwitchCase * S)2045f4a2713aSLionel Sambuc unsigned ASTWriter::RecordSwitchCaseID(SwitchCase *S) {
2046f4a2713aSLionel Sambuc   assert(SwitchCaseIDs.find(S) == SwitchCaseIDs.end() &&
2047f4a2713aSLionel Sambuc          "SwitchCase recorded twice");
2048f4a2713aSLionel Sambuc   unsigned NextID = SwitchCaseIDs.size();
2049f4a2713aSLionel Sambuc   SwitchCaseIDs[S] = NextID;
2050f4a2713aSLionel Sambuc   return NextID;
2051f4a2713aSLionel Sambuc }
2052f4a2713aSLionel Sambuc 
getSwitchCaseID(SwitchCase * S)2053f4a2713aSLionel Sambuc unsigned ASTWriter::getSwitchCaseID(SwitchCase *S) {
2054f4a2713aSLionel Sambuc   assert(SwitchCaseIDs.find(S) != SwitchCaseIDs.end() &&
2055f4a2713aSLionel Sambuc          "SwitchCase hasn't been seen yet");
2056f4a2713aSLionel Sambuc   return SwitchCaseIDs[S];
2057f4a2713aSLionel Sambuc }
2058f4a2713aSLionel Sambuc 
ClearSwitchCaseIDs()2059f4a2713aSLionel Sambuc void ASTWriter::ClearSwitchCaseIDs() {
2060f4a2713aSLionel Sambuc   SwitchCaseIDs.clear();
2061f4a2713aSLionel Sambuc }
2062f4a2713aSLionel Sambuc 
2063f4a2713aSLionel Sambuc /// \brief Write the given substatement or subexpression to the
2064f4a2713aSLionel Sambuc /// bitstream.
WriteSubStmt(Stmt * S,llvm::DenseMap<Stmt *,uint64_t> & SubStmtEntries,llvm::DenseSet<Stmt * > & ParentStmts)2065f4a2713aSLionel Sambuc void ASTWriter::WriteSubStmt(Stmt *S,
2066f4a2713aSLionel Sambuc                              llvm::DenseMap<Stmt *, uint64_t> &SubStmtEntries,
2067f4a2713aSLionel Sambuc                              llvm::DenseSet<Stmt *> &ParentStmts) {
2068f4a2713aSLionel Sambuc   RecordData Record;
2069f4a2713aSLionel Sambuc   ASTStmtWriter Writer(*this, Record);
2070f4a2713aSLionel Sambuc   ++NumStatements;
2071f4a2713aSLionel Sambuc 
2072f4a2713aSLionel Sambuc   if (!S) {
2073f4a2713aSLionel Sambuc     Stream.EmitRecord(serialization::STMT_NULL_PTR, Record);
2074f4a2713aSLionel Sambuc     return;
2075f4a2713aSLionel Sambuc   }
2076f4a2713aSLionel Sambuc 
2077f4a2713aSLionel Sambuc   llvm::DenseMap<Stmt *, uint64_t>::iterator I = SubStmtEntries.find(S);
2078f4a2713aSLionel Sambuc   if (I != SubStmtEntries.end()) {
2079f4a2713aSLionel Sambuc     Record.push_back(I->second);
2080f4a2713aSLionel Sambuc     Stream.EmitRecord(serialization::STMT_REF_PTR, Record);
2081f4a2713aSLionel Sambuc     return;
2082f4a2713aSLionel Sambuc   }
2083f4a2713aSLionel Sambuc 
2084f4a2713aSLionel Sambuc #ifndef NDEBUG
2085f4a2713aSLionel Sambuc   assert(!ParentStmts.count(S) && "There is a Stmt cycle!");
2086f4a2713aSLionel Sambuc 
2087f4a2713aSLionel Sambuc   struct ParentStmtInserterRAII {
2088f4a2713aSLionel Sambuc     Stmt *S;
2089f4a2713aSLionel Sambuc     llvm::DenseSet<Stmt *> &ParentStmts;
2090f4a2713aSLionel Sambuc 
2091f4a2713aSLionel Sambuc     ParentStmtInserterRAII(Stmt *S, llvm::DenseSet<Stmt *> &ParentStmts)
2092f4a2713aSLionel Sambuc       : S(S), ParentStmts(ParentStmts) {
2093f4a2713aSLionel Sambuc       ParentStmts.insert(S);
2094f4a2713aSLionel Sambuc     }
2095f4a2713aSLionel Sambuc     ~ParentStmtInserterRAII() {
2096f4a2713aSLionel Sambuc       ParentStmts.erase(S);
2097f4a2713aSLionel Sambuc     }
2098f4a2713aSLionel Sambuc   };
2099f4a2713aSLionel Sambuc 
2100f4a2713aSLionel Sambuc   ParentStmtInserterRAII ParentStmtInserter(S, ParentStmts);
2101f4a2713aSLionel Sambuc #endif
2102f4a2713aSLionel Sambuc 
2103*0a6a1f1dSLionel Sambuc   // Redirect ASTWriter::AddStmt to collect sub-stmts.
2104f4a2713aSLionel Sambuc   SmallVector<Stmt *, 16> SubStmts;
2105f4a2713aSLionel Sambuc   CollectedStmts = &SubStmts;
2106f4a2713aSLionel Sambuc 
2107f4a2713aSLionel Sambuc   Writer.Code = serialization::STMT_NULL_PTR;
2108f4a2713aSLionel Sambuc   Writer.AbbrevToUse = 0;
2109f4a2713aSLionel Sambuc   Writer.Visit(S);
2110f4a2713aSLionel Sambuc 
2111f4a2713aSLionel Sambuc #ifndef NDEBUG
2112f4a2713aSLionel Sambuc   if (Writer.Code == serialization::STMT_NULL_PTR) {
2113f4a2713aSLionel Sambuc     SourceManager &SrcMgr
2114f4a2713aSLionel Sambuc       = DeclIDs.begin()->first->getASTContext().getSourceManager();
2115f4a2713aSLionel Sambuc     S->dump(SrcMgr);
2116*0a6a1f1dSLionel Sambuc     llvm_unreachable("Unhandled sub-statement writing AST file");
2117f4a2713aSLionel Sambuc   }
2118f4a2713aSLionel Sambuc #endif
2119f4a2713aSLionel Sambuc 
2120f4a2713aSLionel Sambuc   // Revert ASTWriter::AddStmt.
2121f4a2713aSLionel Sambuc   CollectedStmts = &StmtsToEmit;
2122f4a2713aSLionel Sambuc 
2123*0a6a1f1dSLionel Sambuc   // Write the sub-stmts in reverse order, last to first. When reading them back
2124f4a2713aSLionel Sambuc   // we will read them in correct order by "pop"ing them from the Stmts stack.
2125*0a6a1f1dSLionel Sambuc   // This simplifies reading and allows to store a variable number of sub-stmts
2126f4a2713aSLionel Sambuc   // without knowing it in advance.
2127f4a2713aSLionel Sambuc   while (!SubStmts.empty())
2128f4a2713aSLionel Sambuc     WriteSubStmt(SubStmts.pop_back_val(), SubStmtEntries, ParentStmts);
2129f4a2713aSLionel Sambuc 
2130f4a2713aSLionel Sambuc   Stream.EmitRecord(Writer.Code, Record, Writer.AbbrevToUse);
2131f4a2713aSLionel Sambuc 
2132f4a2713aSLionel Sambuc   SubStmtEntries[S] = Stream.GetCurrentBitNo();
2133f4a2713aSLionel Sambuc }
2134f4a2713aSLionel Sambuc 
2135f4a2713aSLionel Sambuc /// \brief Flush all of the statements that have been added to the
2136f4a2713aSLionel Sambuc /// queue via AddStmt().
FlushStmts()2137f4a2713aSLionel Sambuc void ASTWriter::FlushStmts() {
2138f4a2713aSLionel Sambuc   RecordData Record;
2139f4a2713aSLionel Sambuc 
2140f4a2713aSLionel Sambuc   // We expect to be the only consumer of the two temporary statement maps,
2141f4a2713aSLionel Sambuc   // assert that they are empty.
2142*0a6a1f1dSLionel Sambuc   assert(SubStmtEntries.empty() && "unexpected entries in sub-stmt map");
2143f4a2713aSLionel Sambuc   assert(ParentStmts.empty() && "unexpected entries in parent stmt map");
2144f4a2713aSLionel Sambuc 
2145f4a2713aSLionel Sambuc   for (unsigned I = 0, N = StmtsToEmit.size(); I != N; ++I) {
2146f4a2713aSLionel Sambuc     WriteSubStmt(StmtsToEmit[I], SubStmtEntries, ParentStmts);
2147f4a2713aSLionel Sambuc 
2148f4a2713aSLionel Sambuc     assert(N == StmtsToEmit.size() &&
2149f4a2713aSLionel Sambuc            "Substatement written via AddStmt rather than WriteSubStmt!");
2150f4a2713aSLionel Sambuc 
2151f4a2713aSLionel Sambuc     // Note that we are at the end of a full expression. Any
2152f4a2713aSLionel Sambuc     // expression records that follow this one are part of a different
2153f4a2713aSLionel Sambuc     // expression.
2154f4a2713aSLionel Sambuc     Stream.EmitRecord(serialization::STMT_STOP, Record);
2155f4a2713aSLionel Sambuc 
2156f4a2713aSLionel Sambuc     SubStmtEntries.clear();
2157f4a2713aSLionel Sambuc     ParentStmts.clear();
2158f4a2713aSLionel Sambuc   }
2159f4a2713aSLionel Sambuc 
2160f4a2713aSLionel Sambuc   StmtsToEmit.clear();
2161f4a2713aSLionel Sambuc }
2162