/Users/buildslave/jenkins/workspace/clang-stage2-coverage-R/llvm/tools/clang/lib/Serialization/ASTWriterStmt.cpp
Line | Count | Source (jump to first uncovered line) |
1 | | //===--- ASTWriterStmt.cpp - Statement and Expression Serialization -------===// |
2 | | // |
3 | | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. |
4 | | // See https://llvm.org/LICENSE.txt for license information. |
5 | | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception |
6 | | // |
7 | | //===----------------------------------------------------------------------===// |
8 | | /// |
9 | | /// \file |
10 | | /// Implements serialization for Statements and Expressions. |
11 | | /// |
12 | | //===----------------------------------------------------------------------===// |
13 | | |
14 | | #include "clang/Serialization/ASTWriter.h" |
15 | | #include "clang/AST/ASTContext.h" |
16 | | #include "clang/AST/DeclCXX.h" |
17 | | #include "clang/AST/DeclObjC.h" |
18 | | #include "clang/AST/DeclTemplate.h" |
19 | | #include "clang/AST/StmtVisitor.h" |
20 | | #include "clang/Lex/Token.h" |
21 | | #include "llvm/Bitstream/BitstreamWriter.h" |
22 | | using namespace clang; |
23 | | |
24 | | //===----------------------------------------------------------------------===// |
25 | | // Statement/expression serialization |
26 | | //===----------------------------------------------------------------------===// |
27 | | |
28 | | namespace clang { |
29 | | |
30 | | class ASTStmtWriter : public StmtVisitor<ASTStmtWriter, void> { |
31 | | ASTWriter &Writer; |
32 | | ASTRecordWriter Record; |
33 | | |
34 | | serialization::StmtCode Code; |
35 | | unsigned AbbrevToUse; |
36 | | |
37 | | public: |
38 | | ASTStmtWriter(ASTWriter &Writer, ASTWriter::RecordData &Record) |
39 | | : Writer(Writer), Record(Writer, Record), |
40 | 1.30M | Code(serialization::STMT_NULL_PTR), AbbrevToUse(0) {} |
41 | | |
42 | | ASTStmtWriter(const ASTStmtWriter&) = delete; |
43 | | |
44 | 1.06M | uint64_t Emit() { |
45 | 1.06M | assert(Code != serialization::STMT_NULL_PTR && |
46 | 1.06M | "unhandled sub-statement writing AST file"); |
47 | 1.06M | return Record.EmitStmt(Code, AbbrevToUse); |
48 | 1.06M | } |
49 | | |
50 | | void AddTemplateKWAndArgsInfo(const ASTTemplateKWAndArgsInfo &ArgInfo, |
51 | | const TemplateArgumentLoc *Args); |
52 | | |
53 | | void VisitStmt(Stmt *S); |
54 | | #define STMT(Type, Base) \ |
55 | | void Visit##Type(Type *); |
56 | | #include "clang/AST/StmtNodes.inc" |
57 | | }; |
58 | | } |
59 | | |
60 | | void ASTStmtWriter::AddTemplateKWAndArgsInfo( |
61 | 859 | const ASTTemplateKWAndArgsInfo &ArgInfo, const TemplateArgumentLoc *Args) { |
62 | 859 | Record.AddSourceLocation(ArgInfo.TemplateKWLoc); |
63 | 859 | Record.AddSourceLocation(ArgInfo.LAngleLoc); |
64 | 859 | Record.AddSourceLocation(ArgInfo.RAngleLoc); |
65 | 1.99k | for (unsigned i = 0; i != ArgInfo.NumTemplateArgs; ++i1.13k ) |
66 | 1.13k | Record.AddTemplateArgumentLoc(Args[i]); |
67 | 859 | } |
68 | | |
69 | 1.06M | void ASTStmtWriter::VisitStmt(Stmt *S) { |
70 | 1.06M | Record.push_back(S->StmtBits.IsOMPStructuredBlock); |
71 | 1.06M | } |
72 | | |
73 | 282 | void ASTStmtWriter::VisitNullStmt(NullStmt *S) { |
74 | 282 | VisitStmt(S); |
75 | 282 | Record.AddSourceLocation(S->getSemiLoc()); |
76 | 282 | Record.push_back(S->NullStmtBits.HasLeadingEmptyMacro); |
77 | 282 | Code = serialization::STMT_NULL; |
78 | 282 | } |
79 | | |
80 | 44.3k | void ASTStmtWriter::VisitCompoundStmt(CompoundStmt *S) { |
81 | 44.3k | VisitStmt(S); |
82 | 44.3k | Record.push_back(S->size()); |
83 | 44.3k | for (auto *CS : S->body()) |
84 | 73.7k | Record.AddStmt(CS); |
85 | 44.3k | Record.AddSourceLocation(S->getLBracLoc()); |
86 | 44.3k | Record.AddSourceLocation(S->getRBracLoc()); |
87 | 44.3k | Code = serialization::STMT_COMPOUND; |
88 | 44.3k | } |
89 | | |
90 | 31 | void ASTStmtWriter::VisitSwitchCase(SwitchCase *S) { |
91 | 31 | VisitStmt(S); |
92 | 31 | Record.push_back(Writer.getSwitchCaseID(S)); |
93 | 31 | Record.AddSourceLocation(S->getKeywordLoc()); |
94 | 31 | Record.AddSourceLocation(S->getColonLoc()); |
95 | 31 | } |
96 | | |
97 | 25 | void ASTStmtWriter::VisitCaseStmt(CaseStmt *S) { |
98 | 25 | VisitSwitchCase(S); |
99 | 25 | Record.push_back(S->caseStmtIsGNURange()); |
100 | 25 | Record.AddStmt(S->getLHS()); |
101 | 25 | Record.AddStmt(S->getSubStmt()); |
102 | 25 | if (S->caseStmtIsGNURange()) { |
103 | 0 | Record.AddStmt(S->getRHS()); |
104 | 0 | Record.AddSourceLocation(S->getEllipsisLoc()); |
105 | 0 | } |
106 | 25 | Code = serialization::STMT_CASE; |
107 | 25 | } |
108 | | |
109 | 6 | void ASTStmtWriter::VisitDefaultStmt(DefaultStmt *S) { |
110 | 6 | VisitSwitchCase(S); |
111 | 6 | Record.AddStmt(S->getSubStmt()); |
112 | 6 | Code = serialization::STMT_DEFAULT; |
113 | 6 | } |
114 | | |
115 | 6 | void ASTStmtWriter::VisitLabelStmt(LabelStmt *S) { |
116 | 6 | VisitStmt(S); |
117 | 6 | Record.AddDeclRef(S->getDecl()); |
118 | 6 | Record.AddStmt(S->getSubStmt()); |
119 | 6 | Record.AddSourceLocation(S->getIdentLoc()); |
120 | 6 | Code = serialization::STMT_LABEL; |
121 | 6 | } |
122 | | |
123 | 10 | void ASTStmtWriter::VisitAttributedStmt(AttributedStmt *S) { |
124 | 10 | VisitStmt(S); |
125 | 10 | Record.push_back(S->getAttrs().size()); |
126 | 10 | Record.AddAttributes(S->getAttrs()); |
127 | 10 | Record.AddStmt(S->getSubStmt()); |
128 | 10 | Record.AddSourceLocation(S->getAttrLoc()); |
129 | 10 | Code = serialization::STMT_ATTRIBUTED; |
130 | 10 | } |
131 | | |
132 | 53 | void ASTStmtWriter::VisitIfStmt(IfStmt *S) { |
133 | 53 | VisitStmt(S); |
134 | 53 | |
135 | 53 | bool HasElse = S->getElse() != nullptr; |
136 | 53 | bool HasVar = S->getConditionVariableDeclStmt() != nullptr; |
137 | 53 | bool HasInit = S->getInit() != nullptr; |
138 | 53 | |
139 | 53 | Record.push_back(S->isConstexpr()); |
140 | 53 | Record.push_back(HasElse); |
141 | 53 | Record.push_back(HasVar); |
142 | 53 | Record.push_back(HasInit); |
143 | 53 | |
144 | 53 | Record.AddStmt(S->getCond()); |
145 | 53 | Record.AddStmt(S->getThen()); |
146 | 53 | if (HasElse) |
147 | 5 | Record.AddStmt(S->getElse()); |
148 | 53 | if (HasVar) |
149 | 0 | Record.AddDeclRef(S->getConditionVariable()); |
150 | 53 | if (HasInit) |
151 | 2 | Record.AddStmt(S->getInit()); |
152 | 53 | |
153 | 53 | Record.AddSourceLocation(S->getIfLoc()); |
154 | 53 | if (HasElse) |
155 | 5 | Record.AddSourceLocation(S->getElseLoc()); |
156 | 53 | |
157 | 53 | Code = serialization::STMT_IF; |
158 | 53 | } |
159 | | |
160 | 15 | void ASTStmtWriter::VisitSwitchStmt(SwitchStmt *S) { |
161 | 15 | VisitStmt(S); |
162 | 15 | |
163 | 15 | bool HasInit = S->getInit() != nullptr; |
164 | 15 | bool HasVar = S->getConditionVariableDeclStmt() != nullptr; |
165 | 15 | Record.push_back(HasInit); |
166 | 15 | Record.push_back(HasVar); |
167 | 15 | Record.push_back(S->isAllEnumCasesCovered()); |
168 | 15 | |
169 | 15 | Record.AddStmt(S->getCond()); |
170 | 15 | Record.AddStmt(S->getBody()); |
171 | 15 | if (HasInit) |
172 | 1 | Record.AddStmt(S->getInit()); |
173 | 15 | if (HasVar) |
174 | 0 | Record.AddDeclRef(S->getConditionVariable()); |
175 | 15 | |
176 | 15 | Record.AddSourceLocation(S->getSwitchLoc()); |
177 | 15 | |
178 | 46 | for (SwitchCase *SC = S->getSwitchCaseList(); SC; |
179 | 31 | SC = SC->getNextSwitchCase()) |
180 | 31 | Record.push_back(Writer.RecordSwitchCaseID(SC)); |
181 | 15 | Code = serialization::STMT_SWITCH; |
182 | 15 | } |
183 | | |
184 | 13 | void ASTStmtWriter::VisitWhileStmt(WhileStmt *S) { |
185 | 13 | VisitStmt(S); |
186 | 13 | |
187 | 13 | bool HasVar = S->getConditionVariableDeclStmt() != nullptr; |
188 | 13 | Record.push_back(HasVar); |
189 | 13 | |
190 | 13 | Record.AddStmt(S->getCond()); |
191 | 13 | Record.AddStmt(S->getBody()); |
192 | 13 | if (HasVar) |
193 | 0 | Record.AddDeclRef(S->getConditionVariable()); |
194 | 13 | |
195 | 13 | Record.AddSourceLocation(S->getWhileLoc()); |
196 | 13 | Code = serialization::STMT_WHILE; |
197 | 13 | } |
198 | | |
199 | 3 | void ASTStmtWriter::VisitDoStmt(DoStmt *S) { |
200 | 3 | VisitStmt(S); |
201 | 3 | Record.AddStmt(S->getCond()); |
202 | 3 | Record.AddStmt(S->getBody()); |
203 | 3 | Record.AddSourceLocation(S->getDoLoc()); |
204 | 3 | Record.AddSourceLocation(S->getWhileLoc()); |
205 | 3 | Record.AddSourceLocation(S->getRParenLoc()); |
206 | 3 | Code = serialization::STMT_DO; |
207 | 3 | } |
208 | | |
209 | 4.77k | void ASTStmtWriter::VisitForStmt(ForStmt *S) { |
210 | 4.77k | VisitStmt(S); |
211 | 4.77k | Record.AddStmt(S->getInit()); |
212 | 4.77k | Record.AddStmt(S->getCond()); |
213 | 4.77k | Record.AddDeclRef(S->getConditionVariable()); |
214 | 4.77k | Record.AddStmt(S->getInc()); |
215 | 4.77k | Record.AddStmt(S->getBody()); |
216 | 4.77k | Record.AddSourceLocation(S->getForLoc()); |
217 | 4.77k | Record.AddSourceLocation(S->getLParenLoc()); |
218 | 4.77k | Record.AddSourceLocation(S->getRParenLoc()); |
219 | 4.77k | Code = serialization::STMT_FOR; |
220 | 4.77k | } |
221 | | |
222 | 2 | void ASTStmtWriter::VisitGotoStmt(GotoStmt *S) { |
223 | 2 | VisitStmt(S); |
224 | 2 | Record.AddDeclRef(S->getLabel()); |
225 | 2 | Record.AddSourceLocation(S->getGotoLoc()); |
226 | 2 | Record.AddSourceLocation(S->getLabelLoc()); |
227 | 2 | Code = serialization::STMT_GOTO; |
228 | 2 | } |
229 | | |
230 | 1 | void ASTStmtWriter::VisitIndirectGotoStmt(IndirectGotoStmt *S) { |
231 | 1 | VisitStmt(S); |
232 | 1 | Record.AddSourceLocation(S->getGotoLoc()); |
233 | 1 | Record.AddSourceLocation(S->getStarLoc()); |
234 | 1 | Record.AddStmt(S->getTarget()); |
235 | 1 | Code = serialization::STMT_INDIRECT_GOTO; |
236 | 1 | } |
237 | | |
238 | 1 | void ASTStmtWriter::VisitContinueStmt(ContinueStmt *S) { |
239 | 1 | VisitStmt(S); |
240 | 1 | Record.AddSourceLocation(S->getContinueLoc()); |
241 | 1 | Code = serialization::STMT_CONTINUE; |
242 | 1 | } |
243 | | |
244 | 19 | void ASTStmtWriter::VisitBreakStmt(BreakStmt *S) { |
245 | 19 | VisitStmt(S); |
246 | 19 | Record.AddSourceLocation(S->getBreakLoc()); |
247 | 19 | Code = serialization::STMT_BREAK; |
248 | 19 | } |
249 | | |
250 | 30.5k | void ASTStmtWriter::VisitReturnStmt(ReturnStmt *S) { |
251 | 30.5k | VisitStmt(S); |
252 | 30.5k | |
253 | 30.5k | bool HasNRVOCandidate = S->getNRVOCandidate() != nullptr; |
254 | 30.5k | Record.push_back(HasNRVOCandidate); |
255 | 30.5k | |
256 | 30.5k | Record.AddStmt(S->getRetValue()); |
257 | 30.5k | if (HasNRVOCandidate) |
258 | 256 | Record.AddDeclRef(S->getNRVOCandidate()); |
259 | 30.5k | |
260 | 30.5k | Record.AddSourceLocation(S->getReturnLoc()); |
261 | 30.5k | Code = serialization::STMT_RETURN; |
262 | 30.5k | } |
263 | | |
264 | 23.5k | void ASTStmtWriter::VisitDeclStmt(DeclStmt *S) { |
265 | 23.5k | VisitStmt(S); |
266 | 23.5k | Record.AddSourceLocation(S->getBeginLoc()); |
267 | 23.5k | Record.AddSourceLocation(S->getEndLoc()); |
268 | 23.5k | DeclGroupRef DG = S->getDeclGroup(); |
269 | 49.0k | for (DeclGroupRef::iterator D = DG.begin(), DEnd = DG.end(); D != DEnd; ++D25.5k ) |
270 | 25.5k | Record.AddDeclRef(*D); |
271 | 23.5k | Code = serialization::STMT_DECL; |
272 | 23.5k | } |
273 | | |
274 | 38 | void ASTStmtWriter::VisitAsmStmt(AsmStmt *S) { |
275 | 38 | VisitStmt(S); |
276 | 38 | Record.push_back(S->getNumOutputs()); |
277 | 38 | Record.push_back(S->getNumInputs()); |
278 | 38 | Record.push_back(S->getNumClobbers()); |
279 | 38 | Record.AddSourceLocation(S->getAsmLoc()); |
280 | 38 | Record.push_back(S->isVolatile()); |
281 | 38 | Record.push_back(S->isSimple()); |
282 | 38 | } |
283 | | |
284 | 38 | void ASTStmtWriter::VisitGCCAsmStmt(GCCAsmStmt *S) { |
285 | 38 | VisitAsmStmt(S); |
286 | 38 | Record.push_back(S->getNumLabels()); |
287 | 38 | Record.AddSourceLocation(S->getRParenLoc()); |
288 | 38 | Record.AddStmt(S->getAsmString()); |
289 | 38 | |
290 | 38 | // Outputs |
291 | 155 | for (unsigned I = 0, N = S->getNumOutputs(); I != N; ++I117 ) { |
292 | 117 | Record.AddIdentifierRef(S->getOutputIdentifier(I)); |
293 | 117 | Record.AddStmt(S->getOutputConstraintLiteral(I)); |
294 | 117 | Record.AddStmt(S->getOutputExpr(I)); |
295 | 117 | } |
296 | 38 | |
297 | 38 | // Inputs |
298 | 124 | for (unsigned I = 0, N = S->getNumInputs(); I != N; ++I86 ) { |
299 | 86 | Record.AddIdentifierRef(S->getInputIdentifier(I)); |
300 | 86 | Record.AddStmt(S->getInputConstraintLiteral(I)); |
301 | 86 | Record.AddStmt(S->getInputExpr(I)); |
302 | 86 | } |
303 | 38 | |
304 | 38 | // Clobbers |
305 | 69 | for (unsigned I = 0, N = S->getNumClobbers(); I != N; ++I31 ) |
306 | 31 | Record.AddStmt(S->getClobberStringLiteral(I)); |
307 | 38 | |
308 | 38 | // Labels |
309 | 38 | for (auto *E : S->labels()) Record.AddStmt(E)2 ; |
310 | 38 | |
311 | 38 | Code = serialization::STMT_GCCASM; |
312 | 38 | } |
313 | | |
314 | 0 | void ASTStmtWriter::VisitMSAsmStmt(MSAsmStmt *S) { |
315 | 0 | VisitAsmStmt(S); |
316 | 0 | Record.AddSourceLocation(S->getLBraceLoc()); |
317 | 0 | Record.AddSourceLocation(S->getEndLoc()); |
318 | 0 | Record.push_back(S->getNumAsmToks()); |
319 | 0 | Record.AddString(S->getAsmString()); |
320 | 0 |
|
321 | 0 | // Tokens |
322 | 0 | for (unsigned I = 0, N = S->getNumAsmToks(); I != N; ++I) { |
323 | 0 | // FIXME: Move this to ASTRecordWriter? |
324 | 0 | Writer.AddToken(S->getAsmToks()[I], Record.getRecordData()); |
325 | 0 | } |
326 | 0 |
|
327 | 0 | // Clobbers |
328 | 0 | for (unsigned I = 0, N = S->getNumClobbers(); I != N; ++I) { |
329 | 0 | Record.AddString(S->getClobber(I)); |
330 | 0 | } |
331 | 0 |
|
332 | 0 | // Outputs |
333 | 0 | for (unsigned I = 0, N = S->getNumOutputs(); I != N; ++I) { |
334 | 0 | Record.AddStmt(S->getOutputExpr(I)); |
335 | 0 | Record.AddString(S->getOutputConstraint(I)); |
336 | 0 | } |
337 | 0 |
|
338 | 0 | // Inputs |
339 | 0 | for (unsigned I = 0, N = S->getNumInputs(); I != N; ++I) { |
340 | 0 | Record.AddStmt(S->getInputExpr(I)); |
341 | 0 | Record.AddString(S->getInputConstraint(I)); |
342 | 0 | } |
343 | 0 |
|
344 | 0 | Code = serialization::STMT_MSASM; |
345 | 0 | } |
346 | | |
347 | 3 | void ASTStmtWriter::VisitCoroutineBodyStmt(CoroutineBodyStmt *CoroStmt) { |
348 | 3 | VisitStmt(CoroStmt); |
349 | 3 | Record.push_back(CoroStmt->getParamMoves().size()); |
350 | 3 | for (Stmt *S : CoroStmt->children()) |
351 | 36 | Record.AddStmt(S); |
352 | 3 | Code = serialization::STMT_COROUTINE_BODY; |
353 | 3 | } |
354 | | |
355 | 2 | void ASTStmtWriter::VisitCoreturnStmt(CoreturnStmt *S) { |
356 | 2 | VisitStmt(S); |
357 | 2 | Record.AddSourceLocation(S->getKeywordLoc()); |
358 | 2 | Record.AddStmt(S->getOperand()); |
359 | 2 | Record.AddStmt(S->getPromiseCall()); |
360 | 2 | Record.push_back(S->isImplicit()); |
361 | 2 | Code = serialization::STMT_CORETURN; |
362 | 2 | } |
363 | | |
364 | 7 | void ASTStmtWriter::VisitCoroutineSuspendExpr(CoroutineSuspendExpr *E) { |
365 | 7 | VisitExpr(E); |
366 | 7 | Record.AddSourceLocation(E->getKeywordLoc()); |
367 | 7 | for (Stmt *S : E->children()) |
368 | 28 | Record.AddStmt(S); |
369 | 7 | Record.AddStmt(E->getOpaqueValue()); |
370 | 7 | } |
371 | | |
372 | 6 | void ASTStmtWriter::VisitCoawaitExpr(CoawaitExpr *E) { |
373 | 6 | VisitCoroutineSuspendExpr(E); |
374 | 6 | Record.push_back(E->isImplicit()); |
375 | 6 | Code = serialization::EXPR_COAWAIT; |
376 | 6 | } |
377 | | |
378 | 1 | void ASTStmtWriter::VisitCoyieldExpr(CoyieldExpr *E) { |
379 | 1 | VisitCoroutineSuspendExpr(E); |
380 | 1 | Code = serialization::EXPR_COYIELD; |
381 | 1 | } |
382 | | |
383 | 2 | void ASTStmtWriter::VisitDependentCoawaitExpr(DependentCoawaitExpr *E) { |
384 | 2 | VisitExpr(E); |
385 | 2 | Record.AddSourceLocation(E->getKeywordLoc()); |
386 | 2 | for (Stmt *S : E->children()) |
387 | 4 | Record.AddStmt(S); |
388 | 2 | Code = serialization::EXPR_DEPENDENT_COAWAIT; |
389 | 2 | } |
390 | | |
391 | 19.9k | void ASTStmtWriter::VisitCapturedStmt(CapturedStmt *S) { |
392 | 19.9k | VisitStmt(S); |
393 | 19.9k | // NumCaptures |
394 | 19.9k | Record.push_back(std::distance(S->capture_begin(), S->capture_end())); |
395 | 19.9k | |
396 | 19.9k | // CapturedDecl and captured region kind |
397 | 19.9k | Record.AddDeclRef(S->getCapturedDecl()); |
398 | 19.9k | Record.push_back(S->getCapturedRegionKind()); |
399 | 19.9k | |
400 | 19.9k | Record.AddDeclRef(S->getCapturedRecordDecl()); |
401 | 19.9k | |
402 | 19.9k | // Capture inits |
403 | 19.9k | for (auto *I : S->capture_inits()) |
404 | 25.6k | Record.AddStmt(I); |
405 | 19.9k | |
406 | 19.9k | // Body |
407 | 19.9k | Record.AddStmt(S->getCapturedStmt()); |
408 | 19.9k | |
409 | 19.9k | // Captures |
410 | 25.6k | for (const auto &I : S->captures()) { |
411 | 25.6k | if (I.capturesThis() || I.capturesVariableArrayType()23.5k ) |
412 | 4.42k | Record.AddDeclRef(nullptr); |
413 | 21.2k | else |
414 | 21.2k | Record.AddDeclRef(I.getCapturedVar()); |
415 | 25.6k | Record.push_back(I.getCaptureKind()); |
416 | 25.6k | Record.AddSourceLocation(I.getLocation()); |
417 | 25.6k | } |
418 | 19.9k | |
419 | 19.9k | Code = serialization::STMT_CAPTURED; |
420 | 19.9k | } |
421 | | |
422 | 934k | void ASTStmtWriter::VisitExpr(Expr *E) { |
423 | 934k | VisitStmt(E); |
424 | 934k | Record.AddTypeRef(E->getType()); |
425 | 934k | Record.push_back(E->isTypeDependent()); |
426 | 934k | Record.push_back(E->isValueDependent()); |
427 | 934k | Record.push_back(E->isInstantiationDependent()); |
428 | 934k | Record.push_back(E->containsUnexpandedParameterPack()); |
429 | 934k | Record.push_back(E->getValueKind()); |
430 | 934k | Record.push_back(E->getObjectKind()); |
431 | 934k | } |
432 | | |
433 | 10.6k | void ASTStmtWriter::VisitConstantExpr(ConstantExpr *E) { |
434 | 10.6k | VisitExpr(E); |
435 | 10.6k | Record.push_back(static_cast<uint64_t>(E->ConstantExprBits.ResultKind)); |
436 | 10.6k | switch (E->ConstantExprBits.ResultKind) { |
437 | 10.6k | case ConstantExpr::RSK_Int64: |
438 | 6.36k | Record.push_back(E->Int64Result()); |
439 | 6.36k | Record.push_back(E->ConstantExprBits.IsUnsigned | |
440 | 6.36k | E->ConstantExprBits.BitWidth << 1); |
441 | 6.36k | break; |
442 | 10.6k | case ConstantExpr::RSK_APValue: |
443 | 4 | Record.AddAPValue(E->APValueResult()); |
444 | 10.6k | } |
445 | 10.6k | Record.AddStmt(E->getSubExpr()); |
446 | 10.6k | Code = serialization::EXPR_CONSTANT; |
447 | 10.6k | } |
448 | | |
449 | 23 | void ASTStmtWriter::VisitPredefinedExpr(PredefinedExpr *E) { |
450 | 23 | VisitExpr(E); |
451 | 23 | |
452 | 23 | bool HasFunctionName = E->getFunctionName() != nullptr; |
453 | 23 | Record.push_back(HasFunctionName); |
454 | 23 | Record.push_back(E->getIdentKind()); // FIXME: stable encoding |
455 | 23 | Record.AddSourceLocation(E->getLocation()); |
456 | 23 | if (HasFunctionName) |
457 | 16 | Record.AddStmt(E->getFunctionName()); |
458 | 23 | Code = serialization::EXPR_PREDEFINED; |
459 | 23 | } |
460 | | |
461 | 267k | void ASTStmtWriter::VisitDeclRefExpr(DeclRefExpr *E) { |
462 | 267k | VisitExpr(E); |
463 | 267k | |
464 | 267k | Record.push_back(E->hasQualifier()); |
465 | 267k | Record.push_back(E->getDecl() != E->getFoundDecl()); |
466 | 267k | Record.push_back(E->hasTemplateKWAndArgsInfo()); |
467 | 267k | Record.push_back(E->hadMultipleCandidates()); |
468 | 267k | Record.push_back(E->refersToEnclosingVariableOrCapture()); |
469 | 267k | Record.push_back(E->isNonOdrUse()); |
470 | 267k | |
471 | 267k | if (E->hasTemplateKWAndArgsInfo()) { |
472 | 816 | unsigned NumTemplateArgs = E->getNumTemplateArgs(); |
473 | 816 | Record.push_back(NumTemplateArgs); |
474 | 816 | } |
475 | 267k | |
476 | 267k | DeclarationName::NameKind nk = (E->getDecl()->getDeclName().getNameKind()); |
477 | 267k | |
478 | 267k | if ((!E->hasTemplateKWAndArgsInfo()) && (!E->hasQualifier())266k && |
479 | 267k | (E->getDecl() == E->getFoundDecl())266k && |
480 | 267k | nk == DeclarationName::Identifier266k && |
481 | 267k | !E->refersToEnclosingVariableOrCapture()265k && !E->isNonOdrUse()224k ) { |
482 | 223k | AbbrevToUse = Writer.getDeclRefExprAbbrev(); |
483 | 223k | } |
484 | 267k | |
485 | 267k | if (E->hasQualifier()) |
486 | 251 | Record.AddNestedNameSpecifierLoc(E->getQualifierLoc()); |
487 | 267k | |
488 | 267k | if (E->getDecl() != E->getFoundDecl()) |
489 | 895 | Record.AddDeclRef(E->getFoundDecl()); |
490 | 267k | |
491 | 267k | if (E->hasTemplateKWAndArgsInfo()) |
492 | 816 | AddTemplateKWAndArgsInfo(*E->getTrailingObjects<ASTTemplateKWAndArgsInfo>(), |
493 | 816 | E->getTrailingObjects<TemplateArgumentLoc>()); |
494 | 267k | |
495 | 267k | Record.AddDeclRef(E->getDecl()); |
496 | 267k | Record.AddSourceLocation(E->getLocation()); |
497 | 267k | Record.AddDeclarationNameLoc(E->DNLoc, E->getDecl()->getDeclName()); |
498 | 267k | Code = serialization::EXPR_DECL_REF; |
499 | 267k | } |
500 | | |
501 | 94.6k | void ASTStmtWriter::VisitIntegerLiteral(IntegerLiteral *E) { |
502 | 94.6k | VisitExpr(E); |
503 | 94.6k | Record.AddSourceLocation(E->getLocation()); |
504 | 94.6k | Record.AddAPInt(E->getValue()); |
505 | 94.6k | |
506 | 94.6k | if (E->getValue().getBitWidth() == 32) { |
507 | 94.4k | AbbrevToUse = Writer.getIntegerLiteralAbbrev(); |
508 | 94.4k | } |
509 | 94.6k | |
510 | 94.6k | Code = serialization::EXPR_INTEGER_LITERAL; |
511 | 94.6k | } |
512 | | |
513 | 0 | void ASTStmtWriter::VisitFixedPointLiteral(FixedPointLiteral *E) { |
514 | 0 | VisitExpr(E); |
515 | 0 | Record.AddSourceLocation(E->getLocation()); |
516 | 0 | Record.AddAPInt(E->getValue()); |
517 | 0 | Code = serialization::EXPR_INTEGER_LITERAL; |
518 | 0 | } |
519 | | |
520 | 1.08k | void ASTStmtWriter::VisitFloatingLiteral(FloatingLiteral *E) { |
521 | 1.08k | VisitExpr(E); |
522 | 1.08k | Record.push_back(E->getRawSemantics()); |
523 | 1.08k | Record.push_back(E->isExact()); |
524 | 1.08k | Record.AddAPFloat(E->getValue()); |
525 | 1.08k | Record.AddSourceLocation(E->getLocation()); |
526 | 1.08k | Code = serialization::EXPR_FLOATING_LITERAL; |
527 | 1.08k | } |
528 | | |
529 | 1 | void ASTStmtWriter::VisitImaginaryLiteral(ImaginaryLiteral *E) { |
530 | 1 | VisitExpr(E); |
531 | 1 | Record.AddStmt(E->getSubExpr()); |
532 | 1 | Code = serialization::EXPR_IMAGINARY_LITERAL; |
533 | 1 | } |
534 | | |
535 | 432 | void ASTStmtWriter::VisitStringLiteral(StringLiteral *E) { |
536 | 432 | VisitExpr(E); |
537 | 432 | |
538 | 432 | // Store the various bits of data of StringLiteral. |
539 | 432 | Record.push_back(E->getNumConcatenated()); |
540 | 432 | Record.push_back(E->getLength()); |
541 | 432 | Record.push_back(E->getCharByteWidth()); |
542 | 432 | Record.push_back(E->getKind()); |
543 | 432 | Record.push_back(E->isPascal()); |
544 | 432 | |
545 | 432 | // Store the trailing array of SourceLocation. |
546 | 900 | for (unsigned I = 0, N = E->getNumConcatenated(); I != N; ++I468 ) |
547 | 468 | Record.AddSourceLocation(E->getStrTokenLoc(I)); |
548 | 432 | |
549 | 432 | // Store the trailing array of char holding the string data. |
550 | 432 | StringRef StrData = E->getBytes(); |
551 | 3.01k | for (unsigned I = 0, N = E->getByteLength(); I != N; ++I2.58k ) |
552 | 2.58k | Record.push_back(StrData[I]); |
553 | 432 | |
554 | 432 | Code = serialization::EXPR_STRING_LITERAL; |
555 | 432 | } |
556 | | |
557 | 212 | void ASTStmtWriter::VisitCharacterLiteral(CharacterLiteral *E) { |
558 | 212 | VisitExpr(E); |
559 | 212 | Record.push_back(E->getValue()); |
560 | 212 | Record.AddSourceLocation(E->getLocation()); |
561 | 212 | Record.push_back(E->getKind()); |
562 | 212 | |
563 | 212 | AbbrevToUse = Writer.getCharacterLiteralAbbrev(); |
564 | 212 | |
565 | 212 | Code = serialization::EXPR_CHARACTER_LITERAL; |
566 | 212 | } |
567 | | |
568 | 19.3k | void ASTStmtWriter::VisitParenExpr(ParenExpr *E) { |
569 | 19.3k | VisitExpr(E); |
570 | 19.3k | Record.AddSourceLocation(E->getLParen()); |
571 | 19.3k | Record.AddSourceLocation(E->getRParen()); |
572 | 19.3k | Record.AddStmt(E->getSubExpr()); |
573 | 19.3k | Code = serialization::EXPR_PAREN; |
574 | 19.3k | } |
575 | | |
576 | 1.10k | void ASTStmtWriter::VisitParenListExpr(ParenListExpr *E) { |
577 | 1.10k | VisitExpr(E); |
578 | 1.10k | Record.push_back(E->getNumExprs()); |
579 | 1.10k | for (auto *SubStmt : E->exprs()) |
580 | 900 | Record.AddStmt(SubStmt); |
581 | 1.10k | Record.AddSourceLocation(E->getLParenLoc()); |
582 | 1.10k | Record.AddSourceLocation(E->getRParenLoc()); |
583 | 1.10k | Code = serialization::EXPR_PAREN_LIST; |
584 | 1.10k | } |
585 | | |
586 | 14.4k | void ASTStmtWriter::VisitUnaryOperator(UnaryOperator *E) { |
587 | 14.4k | VisitExpr(E); |
588 | 14.4k | Record.AddStmt(E->getSubExpr()); |
589 | 14.4k | Record.push_back(E->getOpcode()); // FIXME: stable encoding |
590 | 14.4k | Record.AddSourceLocation(E->getOperatorLoc()); |
591 | 14.4k | Record.push_back(E->canOverflow()); |
592 | 14.4k | Code = serialization::EXPR_UNARY_OPERATOR; |
593 | 14.4k | } |
594 | | |
595 | 3 | void ASTStmtWriter::VisitOffsetOfExpr(OffsetOfExpr *E) { |
596 | 3 | VisitExpr(E); |
597 | 3 | Record.push_back(E->getNumComponents()); |
598 | 3 | Record.push_back(E->getNumExpressions()); |
599 | 3 | Record.AddSourceLocation(E->getOperatorLoc()); |
600 | 3 | Record.AddSourceLocation(E->getRParenLoc()); |
601 | 3 | Record.AddTypeSourceInfo(E->getTypeSourceInfo()); |
602 | 12 | for (unsigned I = 0, N = E->getNumComponents(); I != N; ++I9 ) { |
603 | 9 | const OffsetOfNode &ON = E->getComponent(I); |
604 | 9 | Record.push_back(ON.getKind()); // FIXME: Stable encoding |
605 | 9 | Record.AddSourceLocation(ON.getSourceRange().getBegin()); |
606 | 9 | Record.AddSourceLocation(ON.getSourceRange().getEnd()); |
607 | 9 | switch (ON.getKind()) { |
608 | 9 | case OffsetOfNode::Array: |
609 | 2 | Record.push_back(ON.getArrayExprIndex()); |
610 | 2 | break; |
611 | 9 | |
612 | 9 | case OffsetOfNode::Field: |
613 | 6 | Record.AddDeclRef(ON.getField()); |
614 | 6 | break; |
615 | 9 | |
616 | 9 | case OffsetOfNode::Identifier: |
617 | 0 | Record.AddIdentifierRef(ON.getFieldName()); |
618 | 0 | break; |
619 | 9 | |
620 | 9 | case OffsetOfNode::Base: |
621 | 1 | Record.AddCXXBaseSpecifier(*ON.getBase()); |
622 | 1 | break; |
623 | 9 | } |
624 | 9 | } |
625 | 5 | for (unsigned I = 0, N = E->getNumExpressions(); 3 I != N; ++I2 ) |
626 | 2 | Record.AddStmt(E->getIndexExpr(I)); |
627 | 3 | Code = serialization::EXPR_OFFSETOF; |
628 | 3 | } |
629 | | |
630 | 42 | void ASTStmtWriter::VisitUnaryExprOrTypeTraitExpr(UnaryExprOrTypeTraitExpr *E) { |
631 | 42 | VisitExpr(E); |
632 | 42 | Record.push_back(E->getKind()); |
633 | 42 | if (E->isArgumentType()) |
634 | 23 | Record.AddTypeSourceInfo(E->getArgumentTypeInfo()); |
635 | 19 | else { |
636 | 19 | Record.push_back(0); |
637 | 19 | Record.AddStmt(E->getArgumentExpr()); |
638 | 19 | } |
639 | 42 | Record.AddSourceLocation(E->getOperatorLoc()); |
640 | 42 | Record.AddSourceLocation(E->getRParenLoc()); |
641 | 42 | Code = serialization::EXPR_SIZEOF_ALIGN_OF; |
642 | 42 | } |
643 | | |
644 | 6.56k | void ASTStmtWriter::VisitArraySubscriptExpr(ArraySubscriptExpr *E) { |
645 | 6.56k | VisitExpr(E); |
646 | 6.56k | Record.AddStmt(E->getLHS()); |
647 | 6.56k | Record.AddStmt(E->getRHS()); |
648 | 6.56k | Record.AddSourceLocation(E->getRBracketLoc()); |
649 | 6.56k | Code = serialization::EXPR_ARRAY_SUBSCRIPT; |
650 | 6.56k | } |
651 | | |
652 | 802 | void ASTStmtWriter::VisitOMPArraySectionExpr(OMPArraySectionExpr *E) { |
653 | 802 | VisitExpr(E); |
654 | 802 | Record.AddStmt(E->getBase()); |
655 | 802 | Record.AddStmt(E->getLowerBound()); |
656 | 802 | Record.AddStmt(E->getLength()); |
657 | 802 | Record.AddSourceLocation(E->getColonLoc()); |
658 | 802 | Record.AddSourceLocation(E->getRBracketLoc()); |
659 | 802 | Code = serialization::EXPR_OMP_ARRAY_SECTION; |
660 | 802 | } |
661 | | |
662 | 44.6k | void ASTStmtWriter::VisitCallExpr(CallExpr *E) { |
663 | 44.6k | VisitExpr(E); |
664 | 44.6k | Record.push_back(E->getNumArgs()); |
665 | 44.6k | Record.AddSourceLocation(E->getRParenLoc()); |
666 | 44.6k | Record.AddStmt(E->getCallee()); |
667 | 44.6k | for (CallExpr::arg_iterator Arg = E->arg_begin(), ArgEnd = E->arg_end(); |
668 | 131k | Arg != ArgEnd; ++Arg86.5k ) |
669 | 86.5k | Record.AddStmt(*Arg); |
670 | 44.6k | Record.push_back(static_cast<unsigned>(E->getADLCallKind())); |
671 | 44.6k | Code = serialization::EXPR_CALL; |
672 | 44.6k | } |
673 | | |
674 | 6.80k | void ASTStmtWriter::VisitMemberExpr(MemberExpr *E) { |
675 | 6.80k | VisitExpr(E); |
676 | 6.80k | |
677 | 6.80k | bool HasQualifier = E->hasQualifier(); |
678 | 6.80k | bool HasFoundDecl = |
679 | 6.80k | E->hasQualifierOrFoundDecl() && |
680 | 6.80k | (238 E->getFoundDecl().getDecl() != E->getMemberDecl()238 || |
681 | 238 | E->getFoundDecl().getAccess() != E->getMemberDecl()->getAccess()196 ); |
682 | 6.80k | bool HasTemplateInfo = E->hasTemplateKWAndArgsInfo(); |
683 | 6.80k | unsigned NumTemplateArgs = E->getNumTemplateArgs(); |
684 | 6.80k | |
685 | 6.80k | // Write these first for easy access when deserializing, as they affect the |
686 | 6.80k | // size of the MemberExpr. |
687 | 6.80k | Record.push_back(HasQualifier); |
688 | 6.80k | Record.push_back(HasFoundDecl); |
689 | 6.80k | Record.push_back(HasTemplateInfo); |
690 | 6.80k | Record.push_back(NumTemplateArgs); |
691 | 6.80k | |
692 | 6.80k | Record.AddStmt(E->getBase()); |
693 | 6.80k | Record.AddDeclRef(E->getMemberDecl()); |
694 | 6.80k | Record.AddDeclarationNameLoc(E->MemberDNLoc, |
695 | 6.80k | E->getMemberDecl()->getDeclName()); |
696 | 6.80k | Record.AddSourceLocation(E->getMemberLoc()); |
697 | 6.80k | Record.push_back(E->isArrow()); |
698 | 6.80k | Record.push_back(E->hadMultipleCandidates()); |
699 | 6.80k | Record.push_back(E->isNonOdrUse()); |
700 | 6.80k | Record.AddSourceLocation(E->getOperatorLoc()); |
701 | 6.80k | |
702 | 6.80k | if (HasFoundDecl) { |
703 | 167 | DeclAccessPair FoundDecl = E->getFoundDecl(); |
704 | 167 | Record.AddDeclRef(FoundDecl.getDecl()); |
705 | 167 | Record.push_back(FoundDecl.getAccess()); |
706 | 167 | } |
707 | 6.80k | |
708 | 6.80k | if (HasQualifier) |
709 | 71 | Record.AddNestedNameSpecifierLoc(E->getQualifierLoc()); |
710 | 6.80k | |
711 | 6.80k | if (HasTemplateInfo) |
712 | 6 | AddTemplateKWAndArgsInfo(*E->getTrailingObjects<ASTTemplateKWAndArgsInfo>(), |
713 | 6 | E->getTrailingObjects<TemplateArgumentLoc>()); |
714 | 6.80k | |
715 | 6.80k | Code = serialization::EXPR_MEMBER; |
716 | 6.80k | } |
717 | | |
718 | 0 | void ASTStmtWriter::VisitObjCIsaExpr(ObjCIsaExpr *E) { |
719 | 0 | VisitExpr(E); |
720 | 0 | Record.AddStmt(E->getBase()); |
721 | 0 | Record.AddSourceLocation(E->getIsaMemberLoc()); |
722 | 0 | Record.AddSourceLocation(E->getOpLoc()); |
723 | 0 | Record.push_back(E->isArrow()); |
724 | 0 | Code = serialization::EXPR_OBJC_ISA; |
725 | 0 | } |
726 | | |
727 | | void ASTStmtWriter:: |
728 | 0 | VisitObjCIndirectCopyRestoreExpr(ObjCIndirectCopyRestoreExpr *E) { |
729 | 0 | VisitExpr(E); |
730 | 0 | Record.AddStmt(E->getSubExpr()); |
731 | 0 | Record.push_back(E->shouldCopy()); |
732 | 0 | Code = serialization::EXPR_OBJC_INDIRECT_COPY_RESTORE; |
733 | 0 | } |
734 | | |
735 | 2 | void ASTStmtWriter::VisitObjCBridgedCastExpr(ObjCBridgedCastExpr *E) { |
736 | 2 | VisitExplicitCastExpr(E); |
737 | 2 | Record.AddSourceLocation(E->getLParenLoc()); |
738 | 2 | Record.AddSourceLocation(E->getBridgeKeywordLoc()); |
739 | 2 | Record.push_back(E->getBridgeKind()); // FIXME: Stable encoding |
740 | 2 | Code = serialization::EXPR_OBJC_BRIDGED_CAST; |
741 | 2 | } |
742 | | |
743 | 316k | void ASTStmtWriter::VisitCastExpr(CastExpr *E) { |
744 | 316k | VisitExpr(E); |
745 | 316k | Record.push_back(E->path_size()); |
746 | 316k | Record.AddStmt(E->getSubExpr()); |
747 | 316k | Record.push_back(E->getCastKind()); // FIXME: stable encoding |
748 | 316k | |
749 | 316k | for (CastExpr::path_iterator |
750 | 317k | PI = E->path_begin(), PE = E->path_end(); PI != PE; ++PI601 ) |
751 | 601 | Record.AddCXXBaseSpecifier(**PI); |
752 | 316k | } |
753 | | |
754 | 118k | void ASTStmtWriter::VisitBinaryOperator(BinaryOperator *E) { |
755 | 118k | VisitExpr(E); |
756 | 118k | Record.AddStmt(E->getLHS()); |
757 | 118k | Record.AddStmt(E->getRHS()); |
758 | 118k | Record.push_back(E->getOpcode()); // FIXME: stable encoding |
759 | 118k | Record.AddSourceLocation(E->getOperatorLoc()); |
760 | 118k | Record.push_back(E->getFPFeatures().getInt()); |
761 | 118k | Code = serialization::EXPR_BINARY_OPERATOR; |
762 | 118k | } |
763 | | |
764 | 4.32k | void ASTStmtWriter::VisitCompoundAssignOperator(CompoundAssignOperator *E) { |
765 | 4.32k | VisitBinaryOperator(E); |
766 | 4.32k | Record.AddTypeRef(E->getComputationLHSType()); |
767 | 4.32k | Record.AddTypeRef(E->getComputationResultType()); |
768 | 4.32k | Code = serialization::EXPR_COMPOUND_ASSIGN_OPERATOR; |
769 | 4.32k | } |
770 | | |
771 | 4.23k | void ASTStmtWriter::VisitConditionalOperator(ConditionalOperator *E) { |
772 | 4.23k | VisitExpr(E); |
773 | 4.23k | Record.AddStmt(E->getCond()); |
774 | 4.23k | Record.AddStmt(E->getLHS()); |
775 | 4.23k | Record.AddStmt(E->getRHS()); |
776 | 4.23k | Record.AddSourceLocation(E->getQuestionLoc()); |
777 | 4.23k | Record.AddSourceLocation(E->getColonLoc()); |
778 | 4.23k | Code = serialization::EXPR_CONDITIONAL_OPERATOR; |
779 | 4.23k | } |
780 | | |
781 | | void |
782 | 1 | ASTStmtWriter::VisitBinaryConditionalOperator(BinaryConditionalOperator *E) { |
783 | 1 | VisitExpr(E); |
784 | 1 | Record.AddStmt(E->getOpaqueValue()); |
785 | 1 | Record.AddStmt(E->getCommon()); |
786 | 1 | Record.AddStmt(E->getCond()); |
787 | 1 | Record.AddStmt(E->getTrueExpr()); |
788 | 1 | Record.AddStmt(E->getFalseExpr()); |
789 | 1 | Record.AddSourceLocation(E->getQuestionLoc()); |
790 | 1 | Record.AddSourceLocation(E->getColonLoc()); |
791 | 1 | Code = serialization::EXPR_BINARY_CONDITIONAL_OPERATOR; |
792 | 1 | } |
793 | | |
794 | 230k | void ASTStmtWriter::VisitImplicitCastExpr(ImplicitCastExpr *E) { |
795 | 230k | VisitCastExpr(E); |
796 | 230k | Record.push_back(E->isPartOfExplicitCast()); |
797 | 230k | |
798 | 230k | if (E->path_size() == 0) |
799 | 229k | AbbrevToUse = Writer.getExprImplicitCastAbbrev(); |
800 | 230k | |
801 | 230k | Code = serialization::EXPR_IMPLICIT_CAST; |
802 | 230k | } |
803 | | |
804 | 86.9k | void ASTStmtWriter::VisitExplicitCastExpr(ExplicitCastExpr *E) { |
805 | 86.9k | VisitCastExpr(E); |
806 | 86.9k | Record.AddTypeSourceInfo(E->getTypeInfoAsWritten()); |
807 | 86.9k | } |
808 | | |
809 | 86.7k | void ASTStmtWriter::VisitCStyleCastExpr(CStyleCastExpr *E) { |
810 | 86.7k | VisitExplicitCastExpr(E); |
811 | 86.7k | Record.AddSourceLocation(E->getLParenLoc()); |
812 | 86.7k | Record.AddSourceLocation(E->getRParenLoc()); |
813 | 86.7k | Code = serialization::EXPR_CSTYLE_CAST; |
814 | 86.7k | } |
815 | | |
816 | 683 | void ASTStmtWriter::VisitCompoundLiteralExpr(CompoundLiteralExpr *E) { |
817 | 683 | VisitExpr(E); |
818 | 683 | Record.AddSourceLocation(E->getLParenLoc()); |
819 | 683 | Record.AddTypeSourceInfo(E->getTypeSourceInfo()); |
820 | 683 | Record.AddStmt(E->getInitializer()); |
821 | 683 | Record.push_back(E->isFileScope()); |
822 | 683 | Code = serialization::EXPR_COMPOUND_LITERAL; |
823 | 683 | } |
824 | | |
825 | 15 | void ASTStmtWriter::VisitExtVectorElementExpr(ExtVectorElementExpr *E) { |
826 | 15 | VisitExpr(E); |
827 | 15 | Record.AddStmt(E->getBase()); |
828 | 15 | Record.AddIdentifierRef(&E->getAccessor()); |
829 | 15 | Record.AddSourceLocation(E->getAccessorLoc()); |
830 | 15 | Code = serialization::EXPR_EXT_VECTOR_ELEMENT; |
831 | 15 | } |
832 | | |
833 | 3.48k | void ASTStmtWriter::VisitInitListExpr(InitListExpr *E) { |
834 | 3.48k | VisitExpr(E); |
835 | 3.48k | // NOTE: only add the (possibly null) syntactic form. |
836 | 3.48k | // No need to serialize the isSemanticForm flag and the semantic form. |
837 | 3.48k | Record.AddStmt(E->getSyntacticForm()); |
838 | 3.48k | Record.AddSourceLocation(E->getLBraceLoc()); |
839 | 3.48k | Record.AddSourceLocation(E->getRBraceLoc()); |
840 | 3.48k | bool isArrayFiller = E->ArrayFillerOrUnionFieldInit.is<Expr*>(); |
841 | 3.48k | Record.push_back(isArrayFiller); |
842 | 3.48k | if (isArrayFiller) |
843 | 3.47k | Record.AddStmt(E->getArrayFiller()); |
844 | 3 | else |
845 | 3 | Record.AddDeclRef(E->getInitializedFieldInUnion()); |
846 | 3.48k | Record.push_back(E->hadArrayRangeDesignator()); |
847 | 3.48k | Record.push_back(E->getNumInits()); |
848 | 3.48k | if (isArrayFiller) { |
849 | 3.47k | // ArrayFiller may have filled "holes" due to designated initializer. |
850 | 3.47k | // Replace them by 0 to indicate that the filler goes in that place. |
851 | 3.47k | Expr *filler = E->getArrayFiller(); |
852 | 19.2k | for (unsigned I = 0, N = E->getNumInits(); I != N; ++I15.7k ) |
853 | 15.7k | Record.AddStmt(E->getInit(I) != filler ? E->getInit(I)15.7k : nullptr6 ); |
854 | 3.47k | } else { |
855 | 6 | for (unsigned I = 0, N = E->getNumInits(); I != N; ++I3 ) |
856 | 3 | Record.AddStmt(E->getInit(I)); |
857 | 3 | } |
858 | 3.48k | Code = serialization::EXPR_INIT_LIST; |
859 | 3.48k | } |
860 | | |
861 | 53 | void ASTStmtWriter::VisitDesignatedInitExpr(DesignatedInitExpr *E) { |
862 | 53 | VisitExpr(E); |
863 | 53 | Record.push_back(E->getNumSubExprs()); |
864 | 132 | for (unsigned I = 0, N = E->getNumSubExprs(); I != N; ++I79 ) |
865 | 79 | Record.AddStmt(E->getSubExpr(I)); |
866 | 53 | Record.AddSourceLocation(E->getEqualOrColonLoc()); |
867 | 53 | Record.push_back(E->usesGNUSyntax()); |
868 | 64 | for (const DesignatedInitExpr::Designator &D : E->designators()) { |
869 | 64 | if (D.isFieldDesignator()) { |
870 | 38 | if (FieldDecl *Field = D.getField()) { |
871 | 38 | Record.push_back(serialization::DESIG_FIELD_DECL); |
872 | 38 | Record.AddDeclRef(Field); |
873 | 38 | } else { |
874 | 0 | Record.push_back(serialization::DESIG_FIELD_NAME); |
875 | 0 | Record.AddIdentifierRef(D.getFieldName()); |
876 | 0 | } |
877 | 38 | Record.AddSourceLocation(D.getDotLoc()); |
878 | 38 | Record.AddSourceLocation(D.getFieldLoc()); |
879 | 38 | } else if (26 D.isArrayDesignator()26 ) { |
880 | 26 | Record.push_back(serialization::DESIG_ARRAY); |
881 | 26 | Record.push_back(D.getFirstExprIndex()); |
882 | 26 | Record.AddSourceLocation(D.getLBracketLoc()); |
883 | 26 | Record.AddSourceLocation(D.getRBracketLoc()); |
884 | 26 | } else { |
885 | 0 | assert(D.isArrayRangeDesignator() && "Unknown designator"); |
886 | 0 | Record.push_back(serialization::DESIG_ARRAY_RANGE); |
887 | 0 | Record.push_back(D.getFirstExprIndex()); |
888 | 0 | Record.AddSourceLocation(D.getLBracketLoc()); |
889 | 0 | Record.AddSourceLocation(D.getEllipsisLoc()); |
890 | 0 | Record.AddSourceLocation(D.getRBracketLoc()); |
891 | 0 | } |
892 | 64 | } |
893 | 53 | Code = serialization::EXPR_DESIGNATED_INIT; |
894 | 53 | } |
895 | | |
896 | 2 | void ASTStmtWriter::VisitDesignatedInitUpdateExpr(DesignatedInitUpdateExpr *E) { |
897 | 2 | VisitExpr(E); |
898 | 2 | Record.AddStmt(E->getBase()); |
899 | 2 | Record.AddStmt(E->getUpdater()); |
900 | 2 | Code = serialization::EXPR_DESIGNATED_INIT_UPDATE; |
901 | 2 | } |
902 | | |
903 | 2 | void ASTStmtWriter::VisitNoInitExpr(NoInitExpr *E) { |
904 | 2 | VisitExpr(E); |
905 | 2 | Code = serialization::EXPR_NO_INIT; |
906 | 2 | } |
907 | | |
908 | 2 | void ASTStmtWriter::VisitArrayInitLoopExpr(ArrayInitLoopExpr *E) { |
909 | 2 | VisitExpr(E); |
910 | 2 | Record.AddStmt(E->SubExprs[0]); |
911 | 2 | Record.AddStmt(E->SubExprs[1]); |
912 | 2 | Code = serialization::EXPR_ARRAY_INIT_LOOP; |
913 | 2 | } |
914 | | |
915 | 2 | void ASTStmtWriter::VisitArrayInitIndexExpr(ArrayInitIndexExpr *E) { |
916 | 2 | VisitExpr(E); |
917 | 2 | Code = serialization::EXPR_ARRAY_INIT_INDEX; |
918 | 2 | } |
919 | | |
920 | 95 | void ASTStmtWriter::VisitImplicitValueInitExpr(ImplicitValueInitExpr *E) { |
921 | 95 | VisitExpr(E); |
922 | 95 | Code = serialization::EXPR_IMPLICIT_VALUE_INIT; |
923 | 95 | } |
924 | | |
925 | 2 | void ASTStmtWriter::VisitVAArgExpr(VAArgExpr *E) { |
926 | 2 | VisitExpr(E); |
927 | 2 | Record.AddStmt(E->getSubExpr()); |
928 | 2 | Record.AddTypeSourceInfo(E->getWrittenTypeInfo()); |
929 | 2 | Record.AddSourceLocation(E->getBuiltinLoc()); |
930 | 2 | Record.AddSourceLocation(E->getRParenLoc()); |
931 | 2 | Record.push_back(E->isMicrosoftABI()); |
932 | 2 | Code = serialization::EXPR_VA_ARG; |
933 | 2 | } |
934 | | |
935 | 0 | void ASTStmtWriter::VisitSourceLocExpr(SourceLocExpr *E) { |
936 | 0 | VisitExpr(E); |
937 | 0 | Record.AddDeclRef(cast_or_null<Decl>(E->getParentContext())); |
938 | 0 | Record.AddSourceLocation(E->getBeginLoc()); |
939 | 0 | Record.AddSourceLocation(E->getEndLoc()); |
940 | 0 | Record.push_back(E->getIdentKind()); |
941 | 0 | Code = serialization::EXPR_SOURCE_LOC; |
942 | 0 | } |
943 | | |
944 | 4 | void ASTStmtWriter::VisitAddrLabelExpr(AddrLabelExpr *E) { |
945 | 4 | VisitExpr(E); |
946 | 4 | Record.AddSourceLocation(E->getAmpAmpLoc()); |
947 | 4 | Record.AddSourceLocation(E->getLabelLoc()); |
948 | 4 | Record.AddDeclRef(E->getLabel()); |
949 | 4 | Code = serialization::EXPR_ADDR_LABEL; |
950 | 4 | } |
951 | | |
952 | 19 | void ASTStmtWriter::VisitStmtExpr(StmtExpr *E) { |
953 | 19 | VisitExpr(E); |
954 | 19 | Record.AddStmt(E->getSubStmt()); |
955 | 19 | Record.AddSourceLocation(E->getLParenLoc()); |
956 | 19 | Record.AddSourceLocation(E->getRParenLoc()); |
957 | 19 | Code = serialization::EXPR_STMT; |
958 | 19 | } |
959 | | |
960 | 3 | void ASTStmtWriter::VisitChooseExpr(ChooseExpr *E) { |
961 | 3 | VisitExpr(E); |
962 | 3 | Record.AddStmt(E->getCond()); |
963 | 3 | Record.AddStmt(E->getLHS()); |
964 | 3 | Record.AddStmt(E->getRHS()); |
965 | 3 | Record.AddSourceLocation(E->getBuiltinLoc()); |
966 | 3 | Record.AddSourceLocation(E->getRParenLoc()); |
967 | 3 | Record.push_back(E->isConditionDependent() ? false0 : E->isConditionTrue()); |
968 | 3 | Code = serialization::EXPR_CHOOSE; |
969 | 3 | } |
970 | | |
971 | 0 | void ASTStmtWriter::VisitGNUNullExpr(GNUNullExpr *E) { |
972 | 0 | VisitExpr(E); |
973 | 0 | Record.AddSourceLocation(E->getTokenLocation()); |
974 | 0 | Code = serialization::EXPR_GNU_NULL; |
975 | 0 | } |
976 | | |
977 | 1.81k | void ASTStmtWriter::VisitShuffleVectorExpr(ShuffleVectorExpr *E) { |
978 | 1.81k | VisitExpr(E); |
979 | 1.81k | Record.push_back(E->getNumSubExprs()); |
980 | 18.9k | for (unsigned I = 0, N = E->getNumSubExprs(); I != N; ++I17.1k ) |
981 | 17.1k | Record.AddStmt(E->getExpr(I)); |
982 | 1.81k | Record.AddSourceLocation(E->getBuiltinLoc()); |
983 | 1.81k | Record.AddSourceLocation(E->getRParenLoc()); |
984 | 1.81k | Code = serialization::EXPR_SHUFFLE_VECTOR; |
985 | 1.81k | } |
986 | | |
987 | 427 | void ASTStmtWriter::VisitConvertVectorExpr(ConvertVectorExpr *E) { |
988 | 427 | VisitExpr(E); |
989 | 427 | Record.AddSourceLocation(E->getBuiltinLoc()); |
990 | 427 | Record.AddSourceLocation(E->getRParenLoc()); |
991 | 427 | Record.AddTypeSourceInfo(E->getTypeSourceInfo()); |
992 | 427 | Record.AddStmt(E->getSrcExpr()); |
993 | 427 | Code = serialization::EXPR_CONVERT_VECTOR; |
994 | 427 | } |
995 | | |
996 | 18 | void ASTStmtWriter::VisitBlockExpr(BlockExpr *E) { |
997 | 18 | VisitExpr(E); |
998 | 18 | Record.AddDeclRef(E->getBlockDecl()); |
999 | 18 | Code = serialization::EXPR_BLOCK; |
1000 | 18 | } |
1001 | | |
1002 | 1 | void ASTStmtWriter::VisitGenericSelectionExpr(GenericSelectionExpr *E) { |
1003 | 1 | VisitExpr(E); |
1004 | 1 | |
1005 | 1 | Record.push_back(E->getNumAssocs()); |
1006 | 1 | Record.push_back(E->ResultIndex); |
1007 | 1 | Record.AddSourceLocation(E->getGenericLoc()); |
1008 | 1 | Record.AddSourceLocation(E->getDefaultLoc()); |
1009 | 1 | Record.AddSourceLocation(E->getRParenLoc()); |
1010 | 1 | |
1011 | 1 | Stmt **Stmts = E->getTrailingObjects<Stmt *>(); |
1012 | 1 | // Add 1 to account for the controlling expression which is the first |
1013 | 1 | // expression in the trailing array of Stmt *. This is not needed for |
1014 | 1 | // the trailing array of TypeSourceInfo *. |
1015 | 5 | for (unsigned I = 0, N = E->getNumAssocs() + 1; I < N; ++I4 ) |
1016 | 4 | Record.AddStmt(Stmts[I]); |
1017 | 1 | |
1018 | 1 | TypeSourceInfo **TSIs = E->getTrailingObjects<TypeSourceInfo *>(); |
1019 | 4 | for (unsigned I = 0, N = E->getNumAssocs(); I < N; ++I3 ) |
1020 | 3 | Record.AddTypeSourceInfo(TSIs[I]); |
1021 | 1 | |
1022 | 1 | Code = serialization::EXPR_GENERIC_SELECTION; |
1023 | 1 | } |
1024 | | |
1025 | 31 | void ASTStmtWriter::VisitPseudoObjectExpr(PseudoObjectExpr *E) { |
1026 | 31 | VisitExpr(E); |
1027 | 31 | Record.push_back(E->getNumSemanticExprs()); |
1028 | 31 | |
1029 | 31 | // Push the result index. Currently, this needs to exactly match |
1030 | 31 | // the encoding used internally for ResultIndex. |
1031 | 31 | unsigned result = E->getResultExprIndex(); |
1032 | 31 | result = (result == PseudoObjectExpr::NoResult ? 03 : result + 128 ); |
1033 | 31 | Record.push_back(result); |
1034 | 31 | |
1035 | 31 | Record.AddStmt(E->getSyntacticForm()); |
1036 | 31 | for (PseudoObjectExpr::semantics_iterator |
1037 | 153 | i = E->semantics_begin(), e = E->semantics_end(); i != e; ++i122 ) { |
1038 | 122 | Record.AddStmt(*i); |
1039 | 122 | } |
1040 | 31 | Code = serialization::EXPR_PSEUDO_OBJECT; |
1041 | 31 | } |
1042 | | |
1043 | 120 | void ASTStmtWriter::VisitAtomicExpr(AtomicExpr *E) { |
1044 | 120 | VisitExpr(E); |
1045 | 120 | Record.push_back(E->getOp()); |
1046 | 553 | for (unsigned I = 0, N = E->getNumSubExprs(); I != N; ++I433 ) |
1047 | 433 | Record.AddStmt(E->getSubExprs()[I]); |
1048 | 120 | Record.AddSourceLocation(E->getBuiltinLoc()); |
1049 | 120 | Record.AddSourceLocation(E->getRParenLoc()); |
1050 | 120 | Code = serialization::EXPR_ATOMIC; |
1051 | 120 | } |
1052 | | |
1053 | | //===----------------------------------------------------------------------===// |
1054 | | // Objective-C Expressions and Statements. |
1055 | | //===----------------------------------------------------------------------===// |
1056 | | |
1057 | 7 | void ASTStmtWriter::VisitObjCStringLiteral(ObjCStringLiteral *E) { |
1058 | 7 | VisitExpr(E); |
1059 | 7 | Record.AddStmt(E->getString()); |
1060 | 7 | Record.AddSourceLocation(E->getAtLoc()); |
1061 | 7 | Code = serialization::EXPR_OBJC_STRING_LITERAL; |
1062 | 7 | } |
1063 | | |
1064 | 10 | void ASTStmtWriter::VisitObjCBoxedExpr(ObjCBoxedExpr *E) { |
1065 | 10 | VisitExpr(E); |
1066 | 10 | Record.AddStmt(E->getSubExpr()); |
1067 | 10 | Record.AddDeclRef(E->getBoxingMethod()); |
1068 | 10 | Record.AddSourceRange(E->getSourceRange()); |
1069 | 10 | Code = serialization::EXPR_OBJC_BOXED_EXPRESSION; |
1070 | 10 | } |
1071 | | |
1072 | 2 | void ASTStmtWriter::VisitObjCArrayLiteral(ObjCArrayLiteral *E) { |
1073 | 2 | VisitExpr(E); |
1074 | 2 | Record.push_back(E->getNumElements()); |
1075 | 6 | for (unsigned i = 0; i < E->getNumElements(); i++4 ) |
1076 | 4 | Record.AddStmt(E->getElement(i)); |
1077 | 2 | Record.AddDeclRef(E->getArrayWithObjectsMethod()); |
1078 | 2 | Record.AddSourceRange(E->getSourceRange()); |
1079 | 2 | Code = serialization::EXPR_OBJC_ARRAY_LITERAL; |
1080 | 2 | } |
1081 | | |
1082 | 3 | void ASTStmtWriter::VisitObjCDictionaryLiteral(ObjCDictionaryLiteral *E) { |
1083 | 3 | VisitExpr(E); |
1084 | 3 | Record.push_back(E->getNumElements()); |
1085 | 3 | Record.push_back(E->HasPackExpansions); |
1086 | 8 | for (unsigned i = 0; i < E->getNumElements(); i++5 ) { |
1087 | 5 | ObjCDictionaryElement Element = E->getKeyValueElement(i); |
1088 | 5 | Record.AddStmt(Element.Key); |
1089 | 5 | Record.AddStmt(Element.Value); |
1090 | 5 | if (E->HasPackExpansions) { |
1091 | 1 | Record.AddSourceLocation(Element.EllipsisLoc); |
1092 | 1 | unsigned NumExpansions = 0; |
1093 | 1 | if (Element.NumExpansions) |
1094 | 0 | NumExpansions = *Element.NumExpansions + 1; |
1095 | 1 | Record.push_back(NumExpansions); |
1096 | 1 | } |
1097 | 5 | } |
1098 | 3 | |
1099 | 3 | Record.AddDeclRef(E->getDictWithObjectsMethod()); |
1100 | 3 | Record.AddSourceRange(E->getSourceRange()); |
1101 | 3 | Code = serialization::EXPR_OBJC_DICTIONARY_LITERAL; |
1102 | 3 | } |
1103 | | |
1104 | 1 | void ASTStmtWriter::VisitObjCEncodeExpr(ObjCEncodeExpr *E) { |
1105 | 1 | VisitExpr(E); |
1106 | 1 | Record.AddTypeSourceInfo(E->getEncodedTypeSourceInfo()); |
1107 | 1 | Record.AddSourceLocation(E->getAtLoc()); |
1108 | 1 | Record.AddSourceLocation(E->getRParenLoc()); |
1109 | 1 | Code = serialization::EXPR_OBJC_ENCODE; |
1110 | 1 | } |
1111 | | |
1112 | 15 | void ASTStmtWriter::VisitObjCSelectorExpr(ObjCSelectorExpr *E) { |
1113 | 15 | VisitExpr(E); |
1114 | 15 | Record.AddSelectorRef(E->getSelector()); |
1115 | 15 | Record.AddSourceLocation(E->getAtLoc()); |
1116 | 15 | Record.AddSourceLocation(E->getRParenLoc()); |
1117 | 15 | Code = serialization::EXPR_OBJC_SELECTOR_EXPR; |
1118 | 15 | } |
1119 | | |
1120 | 1 | void ASTStmtWriter::VisitObjCProtocolExpr(ObjCProtocolExpr *E) { |
1121 | 1 | VisitExpr(E); |
1122 | 1 | Record.AddDeclRef(E->getProtocol()); |
1123 | 1 | Record.AddSourceLocation(E->getAtLoc()); |
1124 | 1 | Record.AddSourceLocation(E->ProtoLoc); |
1125 | 1 | Record.AddSourceLocation(E->getRParenLoc()); |
1126 | 1 | Code = serialization::EXPR_OBJC_PROTOCOL_EXPR; |
1127 | 1 | } |
1128 | | |
1129 | 10 | void ASTStmtWriter::VisitObjCIvarRefExpr(ObjCIvarRefExpr *E) { |
1130 | 10 | VisitExpr(E); |
1131 | 10 | Record.AddDeclRef(E->getDecl()); |
1132 | 10 | Record.AddSourceLocation(E->getLocation()); |
1133 | 10 | Record.AddSourceLocation(E->getOpLoc()); |
1134 | 10 | Record.AddStmt(E->getBase()); |
1135 | 10 | Record.push_back(E->isArrow()); |
1136 | 10 | Record.push_back(E->isFreeIvar()); |
1137 | 10 | Code = serialization::EXPR_OBJC_IVAR_REF_EXPR; |
1138 | 10 | } |
1139 | | |
1140 | 1 | void ASTStmtWriter::VisitObjCPropertyRefExpr(ObjCPropertyRefExpr *E) { |
1141 | 1 | VisitExpr(E); |
1142 | 1 | Record.push_back(E->SetterAndMethodRefFlags.getInt()); |
1143 | 1 | Record.push_back(E->isImplicitProperty()); |
1144 | 1 | if (E->isImplicitProperty()) { |
1145 | 0 | Record.AddDeclRef(E->getImplicitPropertyGetter()); |
1146 | 0 | Record.AddDeclRef(E->getImplicitPropertySetter()); |
1147 | 1 | } else { |
1148 | 1 | Record.AddDeclRef(E->getExplicitProperty()); |
1149 | 1 | } |
1150 | 1 | Record.AddSourceLocation(E->getLocation()); |
1151 | 1 | Record.AddSourceLocation(E->getReceiverLocation()); |
1152 | 1 | if (E->isObjectReceiver()) { |
1153 | 1 | Record.push_back(0); |
1154 | 1 | Record.AddStmt(E->getBase()); |
1155 | 1 | } else if (0 E->isSuperReceiver()0 ) { |
1156 | 0 | Record.push_back(1); |
1157 | 0 | Record.AddTypeRef(E->getSuperReceiverType()); |
1158 | 0 | } else { |
1159 | 0 | Record.push_back(2); |
1160 | 0 | Record.AddDeclRef(E->getClassReceiver()); |
1161 | 0 | } |
1162 | 1 | |
1163 | 1 | Code = serialization::EXPR_OBJC_PROPERTY_REF_EXPR; |
1164 | 1 | } |
1165 | | |
1166 | 8 | void ASTStmtWriter::VisitObjCSubscriptRefExpr(ObjCSubscriptRefExpr *E) { |
1167 | 8 | VisitExpr(E); |
1168 | 8 | Record.AddSourceLocation(E->getRBracket()); |
1169 | 8 | Record.AddStmt(E->getBaseExpr()); |
1170 | 8 | Record.AddStmt(E->getKeyExpr()); |
1171 | 8 | Record.AddDeclRef(E->getAtIndexMethodDecl()); |
1172 | 8 | Record.AddDeclRef(E->setAtIndexMethodDecl()); |
1173 | 8 | |
1174 | 8 | Code = serialization::EXPR_OBJC_SUBSCRIPT_REF_EXPR; |
1175 | 8 | } |
1176 | | |
1177 | 32 | void ASTStmtWriter::VisitObjCMessageExpr(ObjCMessageExpr *E) { |
1178 | 32 | VisitExpr(E); |
1179 | 32 | Record.push_back(E->getNumArgs()); |
1180 | 32 | Record.push_back(E->getNumStoredSelLocs()); |
1181 | 32 | Record.push_back(E->SelLocsKind); |
1182 | 32 | Record.push_back(E->isDelegateInitCall()); |
1183 | 32 | Record.push_back(E->IsImplicit); |
1184 | 32 | Record.push_back((unsigned)E->getReceiverKind()); // FIXME: stable encoding |
1185 | 32 | switch (E->getReceiverKind()) { |
1186 | 32 | case ObjCMessageExpr::Instance: |
1187 | 26 | Record.AddStmt(E->getInstanceReceiver()); |
1188 | 26 | break; |
1189 | 32 | |
1190 | 32 | case ObjCMessageExpr::Class: |
1191 | 6 | Record.AddTypeSourceInfo(E->getClassReceiverTypeInfo()); |
1192 | 6 | break; |
1193 | 32 | |
1194 | 32 | case ObjCMessageExpr::SuperClass: |
1195 | 0 | case ObjCMessageExpr::SuperInstance: |
1196 | 0 | Record.AddTypeRef(E->getSuperType()); |
1197 | 0 | Record.AddSourceLocation(E->getSuperLoc()); |
1198 | 0 | break; |
1199 | 32 | } |
1200 | 32 | |
1201 | 32 | if (E->getMethodDecl()) { |
1202 | 32 | Record.push_back(1); |
1203 | 32 | Record.AddDeclRef(E->getMethodDecl()); |
1204 | 32 | } else { |
1205 | 0 | Record.push_back(0); |
1206 | 0 | Record.AddSelectorRef(E->getSelector()); |
1207 | 0 | } |
1208 | 32 | |
1209 | 32 | Record.AddSourceLocation(E->getLeftLoc()); |
1210 | 32 | Record.AddSourceLocation(E->getRightLoc()); |
1211 | 32 | |
1212 | 32 | for (CallExpr::arg_iterator Arg = E->arg_begin(), ArgEnd = E->arg_end(); |
1213 | 56 | Arg != ArgEnd; ++Arg24 ) |
1214 | 24 | Record.AddStmt(*Arg); |
1215 | 32 | |
1216 | 32 | SourceLocation *Locs = E->getStoredSelLocs(); |
1217 | 34 | for (unsigned i = 0, e = E->getNumStoredSelLocs(); i != e; ++i2 ) |
1218 | 2 | Record.AddSourceLocation(Locs[i]); |
1219 | 32 | |
1220 | 32 | Code = serialization::EXPR_OBJC_MESSAGE_EXPR; |
1221 | 32 | } |
1222 | | |
1223 | 0 | void ASTStmtWriter::VisitObjCForCollectionStmt(ObjCForCollectionStmt *S) { |
1224 | 0 | VisitStmt(S); |
1225 | 0 | Record.AddStmt(S->getElement()); |
1226 | 0 | Record.AddStmt(S->getCollection()); |
1227 | 0 | Record.AddStmt(S->getBody()); |
1228 | 0 | Record.AddSourceLocation(S->getForLoc()); |
1229 | 0 | Record.AddSourceLocation(S->getRParenLoc()); |
1230 | 0 | Code = serialization::STMT_OBJC_FOR_COLLECTION; |
1231 | 0 | } |
1232 | | |
1233 | 3 | void ASTStmtWriter::VisitObjCAtCatchStmt(ObjCAtCatchStmt *S) { |
1234 | 3 | VisitStmt(S); |
1235 | 3 | Record.AddStmt(S->getCatchBody()); |
1236 | 3 | Record.AddDeclRef(S->getCatchParamDecl()); |
1237 | 3 | Record.AddSourceLocation(S->getAtCatchLoc()); |
1238 | 3 | Record.AddSourceLocation(S->getRParenLoc()); |
1239 | 3 | Code = serialization::STMT_OBJC_CATCH; |
1240 | 3 | } |
1241 | | |
1242 | 1 | void ASTStmtWriter::VisitObjCAtFinallyStmt(ObjCAtFinallyStmt *S) { |
1243 | 1 | VisitStmt(S); |
1244 | 1 | Record.AddStmt(S->getFinallyBody()); |
1245 | 1 | Record.AddSourceLocation(S->getAtFinallyLoc()); |
1246 | 1 | Code = serialization::STMT_OBJC_FINALLY; |
1247 | 1 | } |
1248 | | |
1249 | 0 | void ASTStmtWriter::VisitObjCAutoreleasePoolStmt(ObjCAutoreleasePoolStmt *S) { |
1250 | 0 | VisitStmt(S); // FIXME: no test coverage. |
1251 | 0 | Record.AddStmt(S->getSubStmt()); |
1252 | 0 | Record.AddSourceLocation(S->getAtLoc()); |
1253 | 0 | Code = serialization::STMT_OBJC_AUTORELEASE_POOL; |
1254 | 0 | } |
1255 | | |
1256 | 1 | void ASTStmtWriter::VisitObjCAtTryStmt(ObjCAtTryStmt *S) { |
1257 | 1 | VisitStmt(S); |
1258 | 1 | Record.push_back(S->getNumCatchStmts()); |
1259 | 1 | Record.push_back(S->getFinallyStmt() != nullptr); |
1260 | 1 | Record.AddStmt(S->getTryBody()); |
1261 | 4 | for (unsigned I = 0, N = S->getNumCatchStmts(); I != N; ++I3 ) |
1262 | 3 | Record.AddStmt(S->getCatchStmt(I)); |
1263 | 1 | if (S->getFinallyStmt()) |
1264 | 1 | Record.AddStmt(S->getFinallyStmt()); |
1265 | 1 | Record.AddSourceLocation(S->getAtTryLoc()); |
1266 | 1 | Code = serialization::STMT_OBJC_AT_TRY; |
1267 | 1 | } |
1268 | | |
1269 | 0 | void ASTStmtWriter::VisitObjCAtSynchronizedStmt(ObjCAtSynchronizedStmt *S) { |
1270 | 0 | VisitStmt(S); // FIXME: no test coverage. |
1271 | 0 | Record.AddStmt(S->getSynchExpr()); |
1272 | 0 | Record.AddStmt(S->getSynchBody()); |
1273 | 0 | Record.AddSourceLocation(S->getAtSynchronizedLoc()); |
1274 | 0 | Code = serialization::STMT_OBJC_AT_SYNCHRONIZED; |
1275 | 0 | } |
1276 | | |
1277 | 0 | void ASTStmtWriter::VisitObjCAtThrowStmt(ObjCAtThrowStmt *S) { |
1278 | 0 | VisitStmt(S); // FIXME: no test coverage. |
1279 | 0 | Record.AddStmt(S->getThrowExpr()); |
1280 | 0 | Record.AddSourceLocation(S->getThrowLoc()); |
1281 | 0 | Code = serialization::STMT_OBJC_AT_THROW; |
1282 | 0 | } |
1283 | | |
1284 | 0 | void ASTStmtWriter::VisitObjCBoolLiteralExpr(ObjCBoolLiteralExpr *E) { |
1285 | 0 | VisitExpr(E); |
1286 | 0 | Record.push_back(E->getValue()); |
1287 | 0 | Record.AddSourceLocation(E->getLocation()); |
1288 | 0 | Code = serialization::EXPR_OBJC_BOOL_LITERAL; |
1289 | 0 | } |
1290 | | |
1291 | 0 | void ASTStmtWriter::VisitObjCAvailabilityCheckExpr(ObjCAvailabilityCheckExpr *E) { |
1292 | 0 | VisitExpr(E); |
1293 | 0 | Record.AddSourceRange(E->getSourceRange()); |
1294 | 0 | Record.AddVersionTuple(E->getVersion()); |
1295 | 0 | Code = serialization::EXPR_OBJC_AVAILABILITY_CHECK; |
1296 | 0 | } |
1297 | | |
1298 | | //===----------------------------------------------------------------------===// |
1299 | | // C++ Expressions and Statements. |
1300 | | //===----------------------------------------------------------------------===// |
1301 | | |
1302 | 4 | void ASTStmtWriter::VisitCXXCatchStmt(CXXCatchStmt *S) { |
1303 | 4 | VisitStmt(S); |
1304 | 4 | Record.AddSourceLocation(S->getCatchLoc()); |
1305 | 4 | Record.AddDeclRef(S->getExceptionDecl()); |
1306 | 4 | Record.AddStmt(S->getHandlerBlock()); |
1307 | 4 | Code = serialization::STMT_CXX_CATCH; |
1308 | 4 | } |
1309 | | |
1310 | 4 | void ASTStmtWriter::VisitCXXTryStmt(CXXTryStmt *S) { |
1311 | 4 | VisitStmt(S); |
1312 | 4 | Record.push_back(S->getNumHandlers()); |
1313 | 4 | Record.AddSourceLocation(S->getTryLoc()); |
1314 | 4 | Record.AddStmt(S->getTryBlock()); |
1315 | 8 | for (unsigned i = 0, e = S->getNumHandlers(); i != e; ++i4 ) |
1316 | 4 | Record.AddStmt(S->getHandler(i)); |
1317 | 4 | Code = serialization::STMT_CXX_TRY; |
1318 | 4 | } |
1319 | | |
1320 | 9 | void ASTStmtWriter::VisitCXXForRangeStmt(CXXForRangeStmt *S) { |
1321 | 9 | VisitStmt(S); |
1322 | 9 | Record.AddSourceLocation(S->getForLoc()); |
1323 | 9 | Record.AddSourceLocation(S->getCoawaitLoc()); |
1324 | 9 | Record.AddSourceLocation(S->getColonLoc()); |
1325 | 9 | Record.AddSourceLocation(S->getRParenLoc()); |
1326 | 9 | Record.AddStmt(S->getInit()); |
1327 | 9 | Record.AddStmt(S->getRangeStmt()); |
1328 | 9 | Record.AddStmt(S->getBeginStmt()); |
1329 | 9 | Record.AddStmt(S->getEndStmt()); |
1330 | 9 | Record.AddStmt(S->getCond()); |
1331 | 9 | Record.AddStmt(S->getInc()); |
1332 | 9 | Record.AddStmt(S->getLoopVarStmt()); |
1333 | 9 | Record.AddStmt(S->getBody()); |
1334 | 9 | Code = serialization::STMT_CXX_FOR_RANGE; |
1335 | 9 | } |
1336 | | |
1337 | 2 | void ASTStmtWriter::VisitMSDependentExistsStmt(MSDependentExistsStmt *S) { |
1338 | 2 | VisitStmt(S); |
1339 | 2 | Record.AddSourceLocation(S->getKeywordLoc()); |
1340 | 2 | Record.push_back(S->isIfExists()); |
1341 | 2 | Record.AddNestedNameSpecifierLoc(S->getQualifierLoc()); |
1342 | 2 | Record.AddDeclarationNameInfo(S->getNameInfo()); |
1343 | 2 | Record.AddStmt(S->getSubStmt()); |
1344 | 2 | Code = serialization::STMT_MS_DEPENDENT_EXISTS; |
1345 | 2 | } |
1346 | | |
1347 | 1.17k | void ASTStmtWriter::VisitCXXOperatorCallExpr(CXXOperatorCallExpr *E) { |
1348 | 1.17k | VisitCallExpr(E); |
1349 | 1.17k | Record.push_back(E->getOperator()); |
1350 | 1.17k | Record.push_back(E->getFPFeatures().getInt()); |
1351 | 1.17k | Record.AddSourceRange(E->Range); |
1352 | 1.17k | Code = serialization::EXPR_CXX_OPERATOR_CALL; |
1353 | 1.17k | } |
1354 | | |
1355 | 1.14k | void ASTStmtWriter::VisitCXXMemberCallExpr(CXXMemberCallExpr *E) { |
1356 | 1.14k | VisitCallExpr(E); |
1357 | 1.14k | Code = serialization::EXPR_CXX_MEMBER_CALL; |
1358 | 1.14k | } |
1359 | | |
1360 | 5.23k | void ASTStmtWriter::VisitCXXConstructExpr(CXXConstructExpr *E) { |
1361 | 5.23k | VisitExpr(E); |
1362 | 5.23k | |
1363 | 5.23k | Record.push_back(E->getNumArgs()); |
1364 | 5.23k | Record.push_back(E->isElidable()); |
1365 | 5.23k | Record.push_back(E->hadMultipleCandidates()); |
1366 | 5.23k | Record.push_back(E->isListInitialization()); |
1367 | 5.23k | Record.push_back(E->isStdInitListInitialization()); |
1368 | 5.23k | Record.push_back(E->requiresZeroInitialization()); |
1369 | 5.23k | Record.push_back(E->getConstructionKind()); // FIXME: stable encoding |
1370 | 5.23k | Record.AddSourceLocation(E->getLocation()); |
1371 | 5.23k | Record.AddDeclRef(E->getConstructor()); |
1372 | 5.23k | Record.AddSourceRange(E->getParenOrBraceRange()); |
1373 | 5.23k | |
1374 | 7.92k | for (unsigned I = 0, N = E->getNumArgs(); I != N; ++I2.68k ) |
1375 | 2.68k | Record.AddStmt(E->getArg(I)); |
1376 | 5.23k | |
1377 | 5.23k | Code = serialization::EXPR_CXX_CONSTRUCT; |
1378 | 5.23k | } |
1379 | | |
1380 | 1 | void ASTStmtWriter::VisitCXXInheritedCtorInitExpr(CXXInheritedCtorInitExpr *E) { |
1381 | 1 | VisitExpr(E); |
1382 | 1 | Record.AddDeclRef(E->getConstructor()); |
1383 | 1 | Record.AddSourceLocation(E->getLocation()); |
1384 | 1 | Record.push_back(E->constructsVBase()); |
1385 | 1 | Record.push_back(E->inheritedFromVBase()); |
1386 | 1 | Code = serialization::EXPR_CXX_INHERITED_CTOR_INIT; |
1387 | 1 | } |
1388 | | |
1389 | 325 | void ASTStmtWriter::VisitCXXTemporaryObjectExpr(CXXTemporaryObjectExpr *E) { |
1390 | 325 | VisitCXXConstructExpr(E); |
1391 | 325 | Record.AddTypeSourceInfo(E->getTypeSourceInfo()); |
1392 | 325 | Code = serialization::EXPR_CXX_TEMPORARY_OBJECT; |
1393 | 325 | } |
1394 | | |
1395 | 499 | void ASTStmtWriter::VisitLambdaExpr(LambdaExpr *E) { |
1396 | 499 | VisitExpr(E); |
1397 | 499 | Record.push_back(E->NumCaptures); |
1398 | 499 | Record.AddSourceRange(E->IntroducerRange); |
1399 | 499 | Record.push_back(E->CaptureDefault); // FIXME: stable encoding |
1400 | 499 | Record.AddSourceLocation(E->CaptureDefaultLoc); |
1401 | 499 | Record.push_back(E->ExplicitParams); |
1402 | 499 | Record.push_back(E->ExplicitResultType); |
1403 | 499 | Record.AddSourceLocation(E->ClosingBrace); |
1404 | 499 | |
1405 | 499 | // Add capture initializers. |
1406 | 499 | for (LambdaExpr::capture_init_iterator C = E->capture_init_begin(), |
1407 | 499 | CEnd = E->capture_init_end(); |
1408 | 1.52k | C != CEnd; ++C1.03k ) { |
1409 | 1.03k | Record.AddStmt(*C); |
1410 | 1.03k | } |
1411 | 499 | |
1412 | 499 | Code = serialization::EXPR_LAMBDA; |
1413 | 499 | } |
1414 | | |
1415 | 1 | void ASTStmtWriter::VisitCXXStdInitializerListExpr(CXXStdInitializerListExpr *E) { |
1416 | 1 | VisitExpr(E); |
1417 | 1 | Record.AddStmt(E->getSubExpr()); |
1418 | 1 | Code = serialization::EXPR_CXX_STD_INITIALIZER_LIST; |
1419 | 1 | } |
1420 | | |
1421 | 155 | void ASTStmtWriter::VisitCXXNamedCastExpr(CXXNamedCastExpr *E) { |
1422 | 155 | VisitExplicitCastExpr(E); |
1423 | 155 | Record.AddSourceRange(SourceRange(E->getOperatorLoc(), E->getRParenLoc())); |
1424 | 155 | Record.AddSourceRange(E->getAngleBrackets()); |
1425 | 155 | } |
1426 | | |
1427 | 141 | void ASTStmtWriter::VisitCXXStaticCastExpr(CXXStaticCastExpr *E) { |
1428 | 141 | VisitCXXNamedCastExpr(E); |
1429 | 141 | Code = serialization::EXPR_CXX_STATIC_CAST; |
1430 | 141 | } |
1431 | | |
1432 | 2 | void ASTStmtWriter::VisitCXXDynamicCastExpr(CXXDynamicCastExpr *E) { |
1433 | 2 | VisitCXXNamedCastExpr(E); |
1434 | 2 | Code = serialization::EXPR_CXX_DYNAMIC_CAST; |
1435 | 2 | } |
1436 | | |
1437 | 10 | void ASTStmtWriter::VisitCXXReinterpretCastExpr(CXXReinterpretCastExpr *E) { |
1438 | 10 | VisitCXXNamedCastExpr(E); |
1439 | 10 | Code = serialization::EXPR_CXX_REINTERPRET_CAST; |
1440 | 10 | } |
1441 | | |
1442 | 2 | void ASTStmtWriter::VisitCXXConstCastExpr(CXXConstCastExpr *E) { |
1443 | 2 | VisitCXXNamedCastExpr(E); |
1444 | 2 | Code = serialization::EXPR_CXX_CONST_CAST; |
1445 | 2 | } |
1446 | | |
1447 | 54 | void ASTStmtWriter::VisitCXXFunctionalCastExpr(CXXFunctionalCastExpr *E) { |
1448 | 54 | VisitExplicitCastExpr(E); |
1449 | 54 | Record.AddSourceLocation(E->getLParenLoc()); |
1450 | 54 | Record.AddSourceLocation(E->getRParenLoc()); |
1451 | 54 | Code = serialization::EXPR_CXX_FUNCTIONAL_CAST; |
1452 | 54 | } |
1453 | | |
1454 | 0 | void ASTStmtWriter::VisitBuiltinBitCastExpr(BuiltinBitCastExpr *E) { |
1455 | 0 | VisitExplicitCastExpr(E); |
1456 | 0 | Record.AddSourceLocation(E->getBeginLoc()); |
1457 | 0 | Record.AddSourceLocation(E->getEndLoc()); |
1458 | 0 | } |
1459 | | |
1460 | 1 | void ASTStmtWriter::VisitUserDefinedLiteral(UserDefinedLiteral *E) { |
1461 | 1 | VisitCallExpr(E); |
1462 | 1 | Record.AddSourceLocation(E->UDSuffixLoc); |
1463 | 1 | Code = serialization::EXPR_USER_DEFINED_LITERAL; |
1464 | 1 | } |
1465 | | |
1466 | 213 | void ASTStmtWriter::VisitCXXBoolLiteralExpr(CXXBoolLiteralExpr *E) { |
1467 | 213 | VisitExpr(E); |
1468 | 213 | Record.push_back(E->getValue()); |
1469 | 213 | Record.AddSourceLocation(E->getLocation()); |
1470 | 213 | Code = serialization::EXPR_CXX_BOOL_LITERAL; |
1471 | 213 | } |
1472 | | |
1473 | 20 | void ASTStmtWriter::VisitCXXNullPtrLiteralExpr(CXXNullPtrLiteralExpr *E) { |
1474 | 20 | VisitExpr(E); |
1475 | 20 | Record.AddSourceLocation(E->getLocation()); |
1476 | 20 | Code = serialization::EXPR_CXX_NULL_PTR_LITERAL; |
1477 | 20 | } |
1478 | | |
1479 | 2 | void ASTStmtWriter::VisitCXXTypeidExpr(CXXTypeidExpr *E) { |
1480 | 2 | VisitExpr(E); |
1481 | 2 | Record.AddSourceRange(E->getSourceRange()); |
1482 | 2 | if (E->isTypeOperand()) { |
1483 | 1 | Record.AddTypeSourceInfo(E->getTypeOperandSourceInfo()); |
1484 | 1 | Code = serialization::EXPR_CXX_TYPEID_TYPE; |
1485 | 1 | } else { |
1486 | 1 | Record.AddStmt(E->getExprOperand()); |
1487 | 1 | Code = serialization::EXPR_CXX_TYPEID_EXPR; |
1488 | 1 | } |
1489 | 2 | } |
1490 | | |
1491 | 5.21k | void ASTStmtWriter::VisitCXXThisExpr(CXXThisExpr *E) { |
1492 | 5.21k | VisitExpr(E); |
1493 | 5.21k | Record.AddSourceLocation(E->getLocation()); |
1494 | 5.21k | Record.push_back(E->isImplicit()); |
1495 | 5.21k | Code = serialization::EXPR_CXX_THIS; |
1496 | 5.21k | } |
1497 | | |
1498 | 4 | void ASTStmtWriter::VisitCXXThrowExpr(CXXThrowExpr *E) { |
1499 | 4 | VisitExpr(E); |
1500 | 4 | Record.AddSourceLocation(E->getThrowLoc()); |
1501 | 4 | Record.AddStmt(E->getSubExpr()); |
1502 | 4 | Record.push_back(E->isThrownVariableInScope()); |
1503 | 4 | Code = serialization::EXPR_CXX_THROW; |
1504 | 4 | } |
1505 | | |
1506 | 447 | void ASTStmtWriter::VisitCXXDefaultArgExpr(CXXDefaultArgExpr *E) { |
1507 | 447 | VisitExpr(E); |
1508 | 447 | Record.AddDeclRef(E->getParam()); |
1509 | 447 | Record.AddDeclRef(cast_or_null<Decl>(E->getUsedContext())); |
1510 | 447 | Record.AddSourceLocation(E->getUsedLocation()); |
1511 | 447 | Code = serialization::EXPR_CXX_DEFAULT_ARG; |
1512 | 447 | } |
1513 | | |
1514 | 6 | void ASTStmtWriter::VisitCXXDefaultInitExpr(CXXDefaultInitExpr *E) { |
1515 | 6 | VisitExpr(E); |
1516 | 6 | Record.AddDeclRef(E->getField()); |
1517 | 6 | Record.AddDeclRef(cast_or_null<Decl>(E->getUsedContext())); |
1518 | 6 | Record.AddSourceLocation(E->getExprLoc()); |
1519 | 6 | Code = serialization::EXPR_CXX_DEFAULT_INIT; |
1520 | 6 | } |
1521 | | |
1522 | 1.10k | void ASTStmtWriter::VisitCXXBindTemporaryExpr(CXXBindTemporaryExpr *E) { |
1523 | 1.10k | VisitExpr(E); |
1524 | 1.10k | Record.AddCXXTemporary(E->getTemporary()); |
1525 | 1.10k | Record.AddStmt(E->getSubExpr()); |
1526 | 1.10k | Code = serialization::EXPR_CXX_BIND_TEMPORARY; |
1527 | 1.10k | } |
1528 | | |
1529 | 33 | void ASTStmtWriter::VisitCXXScalarValueInitExpr(CXXScalarValueInitExpr *E) { |
1530 | 33 | VisitExpr(E); |
1531 | 33 | Record.AddTypeSourceInfo(E->getTypeSourceInfo()); |
1532 | 33 | Record.AddSourceLocation(E->getRParenLoc()); |
1533 | 33 | Code = serialization::EXPR_CXX_SCALAR_VALUE_INIT; |
1534 | 33 | } |
1535 | | |
1536 | 20 | void ASTStmtWriter::VisitCXXNewExpr(CXXNewExpr *E) { |
1537 | 20 | VisitExpr(E); |
1538 | 20 | |
1539 | 20 | Record.push_back(E->isArray()); |
1540 | 20 | Record.push_back(E->hasInitializer()); |
1541 | 20 | Record.push_back(E->getNumPlacementArgs()); |
1542 | 20 | Record.push_back(E->isParenTypeId()); |
1543 | 20 | |
1544 | 20 | Record.push_back(E->isGlobalNew()); |
1545 | 20 | Record.push_back(E->passAlignment()); |
1546 | 20 | Record.push_back(E->doesUsualArrayDeleteWantSize()); |
1547 | 20 | Record.push_back(E->CXXNewExprBits.StoredInitializationStyle); |
1548 | 20 | |
1549 | 20 | Record.AddDeclRef(E->getOperatorNew()); |
1550 | 20 | Record.AddDeclRef(E->getOperatorDelete()); |
1551 | 20 | Record.AddTypeSourceInfo(E->getAllocatedTypeSourceInfo()); |
1552 | 20 | if (E->isParenTypeId()) |
1553 | 0 | Record.AddSourceRange(E->getTypeIdParens()); |
1554 | 20 | Record.AddSourceRange(E->getSourceRange()); |
1555 | 20 | Record.AddSourceRange(E->getDirectInitRange()); |
1556 | 20 | |
1557 | 20 | for (CXXNewExpr::arg_iterator I = E->raw_arg_begin(), N = E->raw_arg_end(); |
1558 | 41 | I != N; ++I21 ) |
1559 | 21 | Record.AddStmt(*I); |
1560 | 20 | |
1561 | 20 | Code = serialization::EXPR_CXX_NEW; |
1562 | 20 | } |
1563 | | |
1564 | 5 | void ASTStmtWriter::VisitCXXDeleteExpr(CXXDeleteExpr *E) { |
1565 | 5 | VisitExpr(E); |
1566 | 5 | Record.push_back(E->isGlobalDelete()); |
1567 | 5 | Record.push_back(E->isArrayForm()); |
1568 | 5 | Record.push_back(E->isArrayFormAsWritten()); |
1569 | 5 | Record.push_back(E->doesUsualArrayDeleteWantSize()); |
1570 | 5 | Record.AddDeclRef(E->getOperatorDelete()); |
1571 | 5 | Record.AddStmt(E->getArgument()); |
1572 | 5 | Record.AddSourceLocation(E->getBeginLoc()); |
1573 | 5 | |
1574 | 5 | Code = serialization::EXPR_CXX_DELETE; |
1575 | 5 | } |
1576 | | |
1577 | 0 | void ASTStmtWriter::VisitCXXPseudoDestructorExpr(CXXPseudoDestructorExpr *E) { |
1578 | 0 | VisitExpr(E); |
1579 | 0 |
|
1580 | 0 | Record.AddStmt(E->getBase()); |
1581 | 0 | Record.push_back(E->isArrow()); |
1582 | 0 | Record.AddSourceLocation(E->getOperatorLoc()); |
1583 | 0 | Record.AddNestedNameSpecifierLoc(E->getQualifierLoc()); |
1584 | 0 | Record.AddTypeSourceInfo(E->getScopeTypeInfo()); |
1585 | 0 | Record.AddSourceLocation(E->getColonColonLoc()); |
1586 | 0 | Record.AddSourceLocation(E->getTildeLoc()); |
1587 | 0 |
|
1588 | 0 | // PseudoDestructorTypeStorage. |
1589 | 0 | Record.AddIdentifierRef(E->getDestroyedTypeIdentifier()); |
1590 | 0 | if (E->getDestroyedTypeIdentifier()) |
1591 | 0 | Record.AddSourceLocation(E->getDestroyedTypeLoc()); |
1592 | 0 | else |
1593 | 0 | Record.AddTypeSourceInfo(E->getDestroyedTypeInfo()); |
1594 | 0 |
|
1595 | 0 | Code = serialization::EXPR_CXX_PSEUDO_DESTRUCTOR; |
1596 | 0 | } |
1597 | | |
1598 | 1.14k | void ASTStmtWriter::VisitExprWithCleanups(ExprWithCleanups *E) { |
1599 | 1.14k | VisitExpr(E); |
1600 | 1.14k | Record.push_back(E->getNumObjects()); |
1601 | 1.15k | for (unsigned i = 0, e = E->getNumObjects(); i != e; ++i7 ) |
1602 | 7 | Record.AddDeclRef(E->getObject(i)); |
1603 | 1.14k | |
1604 | 1.14k | Record.push_back(E->cleanupsHaveSideEffects()); |
1605 | 1.14k | Record.AddStmt(E->getSubExpr()); |
1606 | 1.14k | Code = serialization::EXPR_EXPR_WITH_CLEANUPS; |
1607 | 1.14k | } |
1608 | | |
1609 | | void ASTStmtWriter::VisitCXXDependentScopeMemberExpr( |
1610 | 905 | CXXDependentScopeMemberExpr *E) { |
1611 | 905 | VisitExpr(E); |
1612 | 905 | |
1613 | 905 | // Don't emit anything here (or if you do you will have to update |
1614 | 905 | // the corresponding deserialization function). |
1615 | 905 | |
1616 | 905 | Record.push_back(E->hasTemplateKWAndArgsInfo()); |
1617 | 905 | Record.push_back(E->getNumTemplateArgs()); |
1618 | 905 | Record.push_back(E->hasFirstQualifierFoundInScope()); |
1619 | 905 | |
1620 | 905 | if (E->hasTemplateKWAndArgsInfo()) { |
1621 | 4 | const ASTTemplateKWAndArgsInfo &ArgInfo = |
1622 | 4 | *E->getTrailingObjects<ASTTemplateKWAndArgsInfo>(); |
1623 | 4 | AddTemplateKWAndArgsInfo(ArgInfo, |
1624 | 4 | E->getTrailingObjects<TemplateArgumentLoc>()); |
1625 | 4 | } |
1626 | 905 | |
1627 | 905 | Record.push_back(E->isArrow()); |
1628 | 905 | Record.AddSourceLocation(E->getOperatorLoc()); |
1629 | 905 | Record.AddTypeRef(E->getBaseType()); |
1630 | 905 | Record.AddNestedNameSpecifierLoc(E->getQualifierLoc()); |
1631 | 905 | if (!E->isImplicitAccess()) |
1632 | 846 | Record.AddStmt(E->getBase()); |
1633 | 59 | else |
1634 | 59 | Record.AddStmt(nullptr); |
1635 | 905 | |
1636 | 905 | if (E->hasFirstQualifierFoundInScope()) |
1637 | 6 | Record.AddDeclRef(E->getFirstQualifierFoundInScope()); |
1638 | 905 | |
1639 | 905 | Record.AddDeclarationNameInfo(E->MemberNameInfo); |
1640 | 905 | Code = serialization::EXPR_CXX_DEPENDENT_SCOPE_MEMBER; |
1641 | 905 | } |
1642 | | |
1643 | | void |
1644 | 76 | ASTStmtWriter::VisitDependentScopeDeclRefExpr(DependentScopeDeclRefExpr *E) { |
1645 | 76 | VisitExpr(E); |
1646 | 76 | |
1647 | 76 | // Don't emit anything here, HasTemplateKWAndArgsInfo must be |
1648 | 76 | // emitted first. |
1649 | 76 | |
1650 | 76 | Record.push_back(E->DependentScopeDeclRefExprBits.HasTemplateKWAndArgsInfo); |
1651 | 76 | if (E->DependentScopeDeclRefExprBits.HasTemplateKWAndArgsInfo) { |
1652 | 2 | const ASTTemplateKWAndArgsInfo &ArgInfo = |
1653 | 2 | *E->getTrailingObjects<ASTTemplateKWAndArgsInfo>(); |
1654 | 2 | Record.push_back(ArgInfo.NumTemplateArgs); |
1655 | 2 | AddTemplateKWAndArgsInfo(ArgInfo, |
1656 | 2 | E->getTrailingObjects<TemplateArgumentLoc>()); |
1657 | 2 | } |
1658 | 76 | |
1659 | 76 | Record.AddNestedNameSpecifierLoc(E->getQualifierLoc()); |
1660 | 76 | Record.AddDeclarationNameInfo(E->NameInfo); |
1661 | 76 | Code = serialization::EXPR_CXX_DEPENDENT_SCOPE_DECL_REF; |
1662 | 76 | } |
1663 | | |
1664 | | void |
1665 | 1.40k | ASTStmtWriter::VisitCXXUnresolvedConstructExpr(CXXUnresolvedConstructExpr *E) { |
1666 | 1.40k | VisitExpr(E); |
1667 | 1.40k | Record.push_back(E->arg_size()); |
1668 | 1.40k | for (CXXUnresolvedConstructExpr::arg_iterator |
1669 | 1.47k | ArgI = E->arg_begin(), ArgE = E->arg_end(); ArgI != ArgE; ++ArgI69 ) |
1670 | 69 | Record.AddStmt(*ArgI); |
1671 | 1.40k | Record.AddTypeSourceInfo(E->getTypeSourceInfo()); |
1672 | 1.40k | Record.AddSourceLocation(E->getLParenLoc()); |
1673 | 1.40k | Record.AddSourceLocation(E->getRParenLoc()); |
1674 | 1.40k | Code = serialization::EXPR_CXX_UNRESOLVED_CONSTRUCT; |
1675 | 1.40k | } |
1676 | | |
1677 | 846 | void ASTStmtWriter::VisitOverloadExpr(OverloadExpr *E) { |
1678 | 846 | VisitExpr(E); |
1679 | 846 | |
1680 | 846 | Record.push_back(E->getNumDecls()); |
1681 | 846 | Record.push_back(E->hasTemplateKWAndArgsInfo()); |
1682 | 846 | if (E->hasTemplateKWAndArgsInfo()) { |
1683 | 31 | const ASTTemplateKWAndArgsInfo &ArgInfo = |
1684 | 31 | *E->getTrailingASTTemplateKWAndArgsInfo(); |
1685 | 31 | Record.push_back(ArgInfo.NumTemplateArgs); |
1686 | 31 | AddTemplateKWAndArgsInfo(ArgInfo, E->getTrailingTemplateArgumentLoc()); |
1687 | 31 | } |
1688 | 846 | |
1689 | 846 | for (OverloadExpr::decls_iterator OvI = E->decls_begin(), |
1690 | 846 | OvE = E->decls_end(); |
1691 | 1.04k | OvI != OvE; ++OvI196 ) { |
1692 | 196 | Record.AddDeclRef(OvI.getDecl()); |
1693 | 196 | Record.push_back(OvI.getAccess()); |
1694 | 196 | } |
1695 | 846 | |
1696 | 846 | Record.AddDeclarationNameInfo(E->getNameInfo()); |
1697 | 846 | Record.AddNestedNameSpecifierLoc(E->getQualifierLoc()); |
1698 | 846 | } |
1699 | | |
1700 | 5 | void ASTStmtWriter::VisitUnresolvedMemberExpr(UnresolvedMemberExpr *E) { |
1701 | 5 | VisitOverloadExpr(E); |
1702 | 5 | Record.push_back(E->isArrow()); |
1703 | 5 | Record.push_back(E->hasUnresolvedUsing()); |
1704 | 5 | Record.AddStmt(!E->isImplicitAccess() ? E->getBase()0 : nullptr); |
1705 | 5 | Record.AddTypeRef(E->getBaseType()); |
1706 | 5 | Record.AddSourceLocation(E->getOperatorLoc()); |
1707 | 5 | Code = serialization::EXPR_CXX_UNRESOLVED_MEMBER; |
1708 | 5 | } |
1709 | | |
1710 | 841 | void ASTStmtWriter::VisitUnresolvedLookupExpr(UnresolvedLookupExpr *E) { |
1711 | 841 | VisitOverloadExpr(E); |
1712 | 841 | Record.push_back(E->requiresADL()); |
1713 | 841 | Record.push_back(E->isOverloaded()); |
1714 | 841 | Record.AddDeclRef(E->getNamingClass()); |
1715 | 841 | Code = serialization::EXPR_CXX_UNRESOLVED_LOOKUP; |
1716 | 841 | } |
1717 | | |
1718 | 20 | void ASTStmtWriter::VisitTypeTraitExpr(TypeTraitExpr *E) { |
1719 | 20 | VisitExpr(E); |
1720 | 20 | Record.push_back(E->TypeTraitExprBits.NumArgs); |
1721 | 20 | Record.push_back(E->TypeTraitExprBits.Kind); // FIXME: Stable encoding |
1722 | 20 | Record.push_back(E->TypeTraitExprBits.Value); |
1723 | 20 | Record.AddSourceRange(E->getSourceRange()); |
1724 | 48 | for (unsigned I = 0, N = E->getNumArgs(); I != N; ++I28 ) |
1725 | 28 | Record.AddTypeSourceInfo(E->getArg(I)); |
1726 | 20 | Code = serialization::EXPR_TYPE_TRAIT; |
1727 | 20 | } |
1728 | | |
1729 | 2 | void ASTStmtWriter::VisitArrayTypeTraitExpr(ArrayTypeTraitExpr *E) { |
1730 | 2 | VisitExpr(E); |
1731 | 2 | Record.push_back(E->getTrait()); |
1732 | 2 | Record.push_back(E->getValue()); |
1733 | 2 | Record.AddSourceRange(E->getSourceRange()); |
1734 | 2 | Record.AddTypeSourceInfo(E->getQueriedTypeSourceInfo()); |
1735 | 2 | Record.AddStmt(E->getDimensionExpression()); |
1736 | 2 | Code = serialization::EXPR_ARRAY_TYPE_TRAIT; |
1737 | 2 | } |
1738 | | |
1739 | 1 | void ASTStmtWriter::VisitExpressionTraitExpr(ExpressionTraitExpr *E) { |
1740 | 1 | VisitExpr(E); |
1741 | 1 | Record.push_back(E->getTrait()); |
1742 | 1 | Record.push_back(E->getValue()); |
1743 | 1 | Record.AddSourceRange(E->getSourceRange()); |
1744 | 1 | Record.AddStmt(E->getQueriedExpression()); |
1745 | 1 | Code = serialization::EXPR_CXX_EXPRESSION_TRAIT; |
1746 | 1 | } |
1747 | | |
1748 | 3 | void ASTStmtWriter::VisitCXXNoexceptExpr(CXXNoexceptExpr *E) { |
1749 | 3 | VisitExpr(E); |
1750 | 3 | Record.push_back(E->getValue()); |
1751 | 3 | Record.AddSourceRange(E->getSourceRange()); |
1752 | 3 | Record.AddStmt(E->getOperand()); |
1753 | 3 | Code = serialization::EXPR_CXX_NOEXCEPT; |
1754 | 3 | } |
1755 | | |
1756 | 29 | void ASTStmtWriter::VisitPackExpansionExpr(PackExpansionExpr *E) { |
1757 | 29 | VisitExpr(E); |
1758 | 29 | Record.AddSourceLocation(E->getEllipsisLoc()); |
1759 | 29 | Record.push_back(E->NumExpansions); |
1760 | 29 | Record.AddStmt(E->getPattern()); |
1761 | 29 | Code = serialization::EXPR_PACK_EXPANSION; |
1762 | 29 | } |
1763 | | |
1764 | 2 | void ASTStmtWriter::VisitSizeOfPackExpr(SizeOfPackExpr *E) { |
1765 | 2 | VisitExpr(E); |
1766 | 2 | Record.push_back(E->isPartiallySubstituted() ? E->getPartialArguments().size()0 |
1767 | 2 | : 0); |
1768 | 2 | Record.AddSourceLocation(E->OperatorLoc); |
1769 | 2 | Record.AddSourceLocation(E->PackLoc); |
1770 | 2 | Record.AddSourceLocation(E->RParenLoc); |
1771 | 2 | Record.AddDeclRef(E->Pack); |
1772 | 2 | if (E->isPartiallySubstituted()) { |
1773 | 0 | for (const auto &TA : E->getPartialArguments()) |
1774 | 0 | Record.AddTemplateArgument(TA); |
1775 | 2 | } else if (!E->isValueDependent()) { |
1776 | 1 | Record.push_back(E->getPackLength()); |
1777 | 1 | } |
1778 | 2 | Code = serialization::EXPR_SIZEOF_PACK; |
1779 | 2 | } |
1780 | | |
1781 | | void ASTStmtWriter::VisitSubstNonTypeTemplateParmExpr( |
1782 | 334 | SubstNonTypeTemplateParmExpr *E) { |
1783 | 334 | VisitExpr(E); |
1784 | 334 | Record.AddDeclRef(E->getParameter()); |
1785 | 334 | Record.AddSourceLocation(E->getNameLoc()); |
1786 | 334 | Record.AddStmt(E->getReplacement()); |
1787 | 334 | Code = serialization::EXPR_SUBST_NON_TYPE_TEMPLATE_PARM; |
1788 | 334 | } |
1789 | | |
1790 | | void ASTStmtWriter::VisitSubstNonTypeTemplateParmPackExpr( |
1791 | 0 | SubstNonTypeTemplateParmPackExpr *E) { |
1792 | 0 | VisitExpr(E); |
1793 | 0 | Record.AddDeclRef(E->getParameterPack()); |
1794 | 0 | Record.AddTemplateArgument(E->getArgumentPack()); |
1795 | 0 | Record.AddSourceLocation(E->getParameterPackLocation()); |
1796 | 0 | Code = serialization::EXPR_SUBST_NON_TYPE_TEMPLATE_PARM_PACK; |
1797 | 0 | } |
1798 | | |
1799 | 3 | void ASTStmtWriter::VisitFunctionParmPackExpr(FunctionParmPackExpr *E) { |
1800 | 3 | VisitExpr(E); |
1801 | 3 | Record.push_back(E->getNumExpansions()); |
1802 | 3 | Record.AddDeclRef(E->getParameterPack()); |
1803 | 3 | Record.AddSourceLocation(E->getParameterPackLocation()); |
1804 | 3 | for (FunctionParmPackExpr::iterator I = E->begin(), End = E->end(); |
1805 | 12 | I != End; ++I9 ) |
1806 | 9 | Record.AddDeclRef(*I); |
1807 | 3 | Code = serialization::EXPR_FUNCTION_PARM_PACK; |
1808 | 3 | } |
1809 | | |
1810 | 1.40k | void ASTStmtWriter::VisitMaterializeTemporaryExpr(MaterializeTemporaryExpr *E) { |
1811 | 1.40k | VisitExpr(E); |
1812 | 1.40k | Record.AddStmt(E->getTemporary()); |
1813 | 1.40k | Record.AddDeclRef(E->getExtendingDecl()); |
1814 | 1.40k | Record.push_back(E->getManglingNumber()); |
1815 | 1.40k | Code = serialization::EXPR_MATERIALIZE_TEMPORARY; |
1816 | 1.40k | } |
1817 | | |
1818 | 0 | void ASTStmtWriter::VisitCXXFoldExpr(CXXFoldExpr *E) { |
1819 | 0 | VisitExpr(E); |
1820 | 0 | Record.AddSourceLocation(E->LParenLoc); |
1821 | 0 | Record.AddSourceLocation(E->EllipsisLoc); |
1822 | 0 | Record.AddSourceLocation(E->RParenLoc); |
1823 | 0 | Record.push_back(E->NumExpansions); |
1824 | 0 | Record.AddStmt(E->SubExprs[0]); |
1825 | 0 | Record.AddStmt(E->SubExprs[1]); |
1826 | 0 | Record.push_back(E->Opcode); |
1827 | 0 | Code = serialization::EXPR_CXX_FOLD; |
1828 | 0 | } |
1829 | | |
1830 | 615 | void ASTStmtWriter::VisitOpaqueValueExpr(OpaqueValueExpr *E) { |
1831 | 615 | VisitExpr(E); |
1832 | 615 | Record.AddStmt(E->getSourceExpr()); |
1833 | 615 | Record.AddSourceLocation(E->getLocation()); |
1834 | 615 | Record.push_back(E->isUnique()); |
1835 | 615 | Code = serialization::EXPR_OPAQUE_VALUE; |
1836 | 615 | } |
1837 | | |
1838 | 0 | void ASTStmtWriter::VisitTypoExpr(TypoExpr *E) { |
1839 | 0 | VisitExpr(E); |
1840 | 0 | // TODO: Figure out sane writer behavior for a TypoExpr, if necessary |
1841 | 0 | llvm_unreachable("Cannot write TypoExpr nodes"); |
1842 | 0 | } |
1843 | | |
1844 | | //===----------------------------------------------------------------------===// |
1845 | | // CUDA Expressions and Statements. |
1846 | | //===----------------------------------------------------------------------===// |
1847 | | |
1848 | 1 | void ASTStmtWriter::VisitCUDAKernelCallExpr(CUDAKernelCallExpr *E) { |
1849 | 1 | VisitCallExpr(E); |
1850 | 1 | Record.AddStmt(E->getConfig()); |
1851 | 1 | Code = serialization::EXPR_CUDA_KERNEL_CALL; |
1852 | 1 | } |
1853 | | |
1854 | | //===----------------------------------------------------------------------===// |
1855 | | // OpenCL Expressions and Statements. |
1856 | | //===----------------------------------------------------------------------===// |
1857 | 0 | void ASTStmtWriter::VisitAsTypeExpr(AsTypeExpr *E) { |
1858 | 0 | VisitExpr(E); |
1859 | 0 | Record.AddSourceLocation(E->getBuiltinLoc()); |
1860 | 0 | Record.AddSourceLocation(E->getRParenLoc()); |
1861 | 0 | Record.AddStmt(E->getSrcExpr()); |
1862 | 0 | Code = serialization::EXPR_ASTYPE; |
1863 | 0 | } |
1864 | | |
1865 | | //===----------------------------------------------------------------------===// |
1866 | | // Microsoft Expressions and Statements. |
1867 | | //===----------------------------------------------------------------------===// |
1868 | 22 | void ASTStmtWriter::VisitMSPropertyRefExpr(MSPropertyRefExpr *E) { |
1869 | 22 | VisitExpr(E); |
1870 | 22 | Record.push_back(E->isArrow()); |
1871 | 22 | Record.AddStmt(E->getBaseExpr()); |
1872 | 22 | Record.AddNestedNameSpecifierLoc(E->getQualifierLoc()); |
1873 | 22 | Record.AddSourceLocation(E->getMemberLoc()); |
1874 | 22 | Record.AddDeclRef(E->getPropertyDecl()); |
1875 | 22 | Code = serialization::EXPR_CXX_PROPERTY_REF_EXPR; |
1876 | 22 | } |
1877 | | |
1878 | 36 | void ASTStmtWriter::VisitMSPropertySubscriptExpr(MSPropertySubscriptExpr *E) { |
1879 | 36 | VisitExpr(E); |
1880 | 36 | Record.AddStmt(E->getBase()); |
1881 | 36 | Record.AddStmt(E->getIdx()); |
1882 | 36 | Record.AddSourceLocation(E->getRBracketLoc()); |
1883 | 36 | Code = serialization::EXPR_CXX_PROPERTY_SUBSCRIPT_EXPR; |
1884 | 36 | } |
1885 | | |
1886 | 1 | void ASTStmtWriter::VisitCXXUuidofExpr(CXXUuidofExpr *E) { |
1887 | 1 | VisitExpr(E); |
1888 | 1 | Record.AddSourceRange(E->getSourceRange()); |
1889 | 1 | Record.AddString(E->getUuidStr()); |
1890 | 1 | if (E->isTypeOperand()) { |
1891 | 0 | Record.AddTypeSourceInfo(E->getTypeOperandSourceInfo()); |
1892 | 0 | Code = serialization::EXPR_CXX_UUIDOF_TYPE; |
1893 | 1 | } else { |
1894 | 1 | Record.AddStmt(E->getExprOperand()); |
1895 | 1 | Code = serialization::EXPR_CXX_UUIDOF_EXPR; |
1896 | 1 | } |
1897 | 1 | } |
1898 | | |
1899 | 1 | void ASTStmtWriter::VisitSEHExceptStmt(SEHExceptStmt *S) { |
1900 | 1 | VisitStmt(S); |
1901 | 1 | Record.AddSourceLocation(S->getExceptLoc()); |
1902 | 1 | Record.AddStmt(S->getFilterExpr()); |
1903 | 1 | Record.AddStmt(S->getBlock()); |
1904 | 1 | Code = serialization::STMT_SEH_EXCEPT; |
1905 | 1 | } |
1906 | | |
1907 | 0 | void ASTStmtWriter::VisitSEHFinallyStmt(SEHFinallyStmt *S) { |
1908 | 0 | VisitStmt(S); |
1909 | 0 | Record.AddSourceLocation(S->getFinallyLoc()); |
1910 | 0 | Record.AddStmt(S->getBlock()); |
1911 | 0 | Code = serialization::STMT_SEH_FINALLY; |
1912 | 0 | } |
1913 | | |
1914 | 1 | void ASTStmtWriter::VisitSEHTryStmt(SEHTryStmt *S) { |
1915 | 1 | VisitStmt(S); |
1916 | 1 | Record.push_back(S->getIsCXXTry()); |
1917 | 1 | Record.AddSourceLocation(S->getTryLoc()); |
1918 | 1 | Record.AddStmt(S->getTryBlock()); |
1919 | 1 | Record.AddStmt(S->getHandler()); |
1920 | 1 | Code = serialization::STMT_SEH_TRY; |
1921 | 1 | } |
1922 | | |
1923 | 0 | void ASTStmtWriter::VisitSEHLeaveStmt(SEHLeaveStmt *S) { |
1924 | 0 | VisitStmt(S); |
1925 | 0 | Record.AddSourceLocation(S->getLeaveLoc()); |
1926 | 0 | Code = serialization::STMT_SEH_LEAVE; |
1927 | 0 | } |
1928 | | |
1929 | | //===----------------------------------------------------------------------===// |
1930 | | // OpenMP Directives. |
1931 | | //===----------------------------------------------------------------------===// |
1932 | 10.4k | void ASTStmtWriter::VisitOMPExecutableDirective(OMPExecutableDirective *E) { |
1933 | 10.4k | Record.AddSourceLocation(E->getBeginLoc()); |
1934 | 10.4k | Record.AddSourceLocation(E->getEndLoc()); |
1935 | 10.4k | OMPClauseWriter ClauseWriter(Record); |
1936 | 23.5k | for (unsigned i = 0; i < E->getNumClauses(); ++i13.1k ) { |
1937 | 13.1k | ClauseWriter.writeClause(E->getClause(i)); |
1938 | 13.1k | } |
1939 | 10.4k | if (E->hasAssociatedStmt()) |
1940 | 10.2k | Record.AddStmt(E->getAssociatedStmt()); |
1941 | 10.4k | } |
1942 | | |
1943 | 4.28k | void ASTStmtWriter::VisitOMPLoopDirective(OMPLoopDirective *D) { |
1944 | 4.28k | VisitStmt(D); |
1945 | 4.28k | Record.push_back(D->getNumClauses()); |
1946 | 4.28k | Record.push_back(D->getCollapsedNumber()); |
1947 | 4.28k | VisitOMPExecutableDirective(D); |
1948 | 4.28k | Record.AddStmt(D->getIterationVariable()); |
1949 | 4.28k | Record.AddStmt(D->getLastIteration()); |
1950 | 4.28k | Record.AddStmt(D->getCalcLastIteration()); |
1951 | 4.28k | Record.AddStmt(D->getPreCond()); |
1952 | 4.28k | Record.AddStmt(D->getCond()); |
1953 | 4.28k | Record.AddStmt(D->getInit()); |
1954 | 4.28k | Record.AddStmt(D->getInc()); |
1955 | 4.28k | Record.AddStmt(D->getPreInits()); |
1956 | 4.28k | if (isOpenMPWorksharingDirective(D->getDirectiveKind()) || |
1957 | 4.28k | isOpenMPTaskLoopDirective(D->getDirectiveKind())1.65k || |
1958 | 4.28k | isOpenMPDistributeDirective(D->getDirectiveKind())1.59k ) { |
1959 | 3.93k | Record.AddStmt(D->getIsLastIterVariable()); |
1960 | 3.93k | Record.AddStmt(D->getLowerBoundVariable()); |
1961 | 3.93k | Record.AddStmt(D->getUpperBoundVariable()); |
1962 | 3.93k | Record.AddStmt(D->getStrideVariable()); |
1963 | 3.93k | Record.AddStmt(D->getEnsureUpperBound()); |
1964 | 3.93k | Record.AddStmt(D->getNextLowerBound()); |
1965 | 3.93k | Record.AddStmt(D->getNextUpperBound()); |
1966 | 3.93k | Record.AddStmt(D->getNumIterations()); |
1967 | 3.93k | } |
1968 | 4.28k | if (isOpenMPLoopBoundSharingDirective(D->getDirectiveKind())) { |
1969 | 1.67k | Record.AddStmt(D->getPrevLowerBoundVariable()); |
1970 | 1.67k | Record.AddStmt(D->getPrevUpperBoundVariable()); |
1971 | 1.67k | Record.AddStmt(D->getDistInc()); |
1972 | 1.67k | Record.AddStmt(D->getPrevEnsureUpperBound()); |
1973 | 1.67k | Record.AddStmt(D->getCombinedLowerBoundVariable()); |
1974 | 1.67k | Record.AddStmt(D->getCombinedUpperBoundVariable()); |
1975 | 1.67k | Record.AddStmt(D->getCombinedEnsureUpperBound()); |
1976 | 1.67k | Record.AddStmt(D->getCombinedInit()); |
1977 | 1.67k | Record.AddStmt(D->getCombinedCond()); |
1978 | 1.67k | Record.AddStmt(D->getCombinedNextLowerBound()); |
1979 | 1.67k | Record.AddStmt(D->getCombinedNextUpperBound()); |
1980 | 1.67k | Record.AddStmt(D->getCombinedDistCond()); |
1981 | 1.67k | Record.AddStmt(D->getCombinedParForInDistCond()); |
1982 | 1.67k | } |
1983 | 4.49k | for (auto I : D->counters()) { |
1984 | 4.49k | Record.AddStmt(I); |
1985 | 4.49k | } |
1986 | 4.49k | for (auto I : D->private_counters()) { |
1987 | 4.49k | Record.AddStmt(I); |
1988 | 4.49k | } |
1989 | 4.49k | for (auto I : D->inits()) { |
1990 | 4.49k | Record.AddStmt(I); |
1991 | 4.49k | } |
1992 | 4.49k | for (auto I : D->updates()) { |
1993 | 4.49k | Record.AddStmt(I); |
1994 | 4.49k | } |
1995 | 4.49k | for (auto I : D->finals()) { |
1996 | 4.49k | Record.AddStmt(I); |
1997 | 4.49k | } |
1998 | 4.28k | } |
1999 | | |
2000 | 461 | void ASTStmtWriter::VisitOMPParallelDirective(OMPParallelDirective *D) { |
2001 | 461 | VisitStmt(D); |
2002 | 461 | Record.push_back(D->getNumClauses()); |
2003 | 461 | VisitOMPExecutableDirective(D); |
2004 | 461 | Record.push_back(D->hasCancel() ? 16 : 0455 ); |
2005 | 461 | Code = serialization::STMT_OMP_PARALLEL_DIRECTIVE; |
2006 | 461 | } |
2007 | | |
2008 | 84 | void ASTStmtWriter::VisitOMPSimdDirective(OMPSimdDirective *D) { |
2009 | 84 | VisitOMPLoopDirective(D); |
2010 | 84 | Code = serialization::STMT_OMP_SIMD_DIRECTIVE; |
2011 | 84 | } |
2012 | | |
2013 | 202 | void ASTStmtWriter::VisitOMPForDirective(OMPForDirective *D) { |
2014 | 202 | VisitOMPLoopDirective(D); |
2015 | 202 | Record.push_back(D->hasCancel() ? 16 : 0196 ); |
2016 | 202 | Code = serialization::STMT_OMP_FOR_DIRECTIVE; |
2017 | 202 | } |
2018 | | |
2019 | 54 | void ASTStmtWriter::VisitOMPForSimdDirective(OMPForSimdDirective *D) { |
2020 | 54 | VisitOMPLoopDirective(D); |
2021 | 54 | Code = serialization::STMT_OMP_FOR_SIMD_DIRECTIVE; |
2022 | 54 | } |
2023 | | |
2024 | 40 | void ASTStmtWriter::VisitOMPSectionsDirective(OMPSectionsDirective *D) { |
2025 | 40 | VisitStmt(D); |
2026 | 40 | Record.push_back(D->getNumClauses()); |
2027 | 40 | VisitOMPExecutableDirective(D); |
2028 | 40 | Record.push_back(D->hasCancel() ? 110 : 030 ); |
2029 | 40 | Code = serialization::STMT_OMP_SECTIONS_DIRECTIVE; |
2030 | 40 | } |
2031 | | |
2032 | 38 | void ASTStmtWriter::VisitOMPSectionDirective(OMPSectionDirective *D) { |
2033 | 38 | VisitStmt(D); |
2034 | 38 | VisitOMPExecutableDirective(D); |
2035 | 38 | Record.push_back(D->hasCancel() ? 18 : 030 ); |
2036 | 38 | Code = serialization::STMT_OMP_SECTION_DIRECTIVE; |
2037 | 38 | } |
2038 | | |
2039 | 36 | void ASTStmtWriter::VisitOMPSingleDirective(OMPSingleDirective *D) { |
2040 | 36 | VisitStmt(D); |
2041 | 36 | Record.push_back(D->getNumClauses()); |
2042 | 36 | VisitOMPExecutableDirective(D); |
2043 | 36 | Code = serialization::STMT_OMP_SINGLE_DIRECTIVE; |
2044 | 36 | } |
2045 | | |
2046 | 8 | void ASTStmtWriter::VisitOMPMasterDirective(OMPMasterDirective *D) { |
2047 | 8 | VisitStmt(D); |
2048 | 8 | VisitOMPExecutableDirective(D); |
2049 | 8 | Code = serialization::STMT_OMP_MASTER_DIRECTIVE; |
2050 | 8 | } |
2051 | | |
2052 | 24 | void ASTStmtWriter::VisitOMPCriticalDirective(OMPCriticalDirective *D) { |
2053 | 24 | VisitStmt(D); |
2054 | 24 | Record.push_back(D->getNumClauses()); |
2055 | 24 | VisitOMPExecutableDirective(D); |
2056 | 24 | Record.AddDeclarationNameInfo(D->getDirectiveName()); |
2057 | 24 | Code = serialization::STMT_OMP_CRITICAL_DIRECTIVE; |
2058 | 24 | } |
2059 | | |
2060 | 60 | void ASTStmtWriter::VisitOMPParallelForDirective(OMPParallelForDirective *D) { |
2061 | 60 | VisitOMPLoopDirective(D); |
2062 | 60 | Record.push_back(D->hasCancel() ? 14 : 056 ); |
2063 | 60 | Code = serialization::STMT_OMP_PARALLEL_FOR_DIRECTIVE; |
2064 | 60 | } |
2065 | | |
2066 | | void ASTStmtWriter::VisitOMPParallelForSimdDirective( |
2067 | 52 | OMPParallelForSimdDirective *D) { |
2068 | 52 | VisitOMPLoopDirective(D); |
2069 | 52 | Code = serialization::STMT_OMP_PARALLEL_FOR_SIMD_DIRECTIVE; |
2070 | 52 | } |
2071 | | |
2072 | | void ASTStmtWriter::VisitOMPParallelSectionsDirective( |
2073 | 22 | OMPParallelSectionsDirective *D) { |
2074 | 22 | VisitStmt(D); |
2075 | 22 | Record.push_back(D->getNumClauses()); |
2076 | 22 | VisitOMPExecutableDirective(D); |
2077 | 22 | Record.push_back(D->hasCancel() ? 18 : 014 ); |
2078 | 22 | Code = serialization::STMT_OMP_PARALLEL_SECTIONS_DIRECTIVE; |
2079 | 22 | } |
2080 | | |
2081 | 100 | void ASTStmtWriter::VisitOMPTaskDirective(OMPTaskDirective *D) { |
2082 | 100 | VisitStmt(D); |
2083 | 100 | Record.push_back(D->getNumClauses()); |
2084 | 100 | VisitOMPExecutableDirective(D); |
2085 | 100 | Record.push_back(D->hasCancel() ? 16 : 094 ); |
2086 | 100 | Code = serialization::STMT_OMP_TASK_DIRECTIVE; |
2087 | 100 | } |
2088 | | |
2089 | 430 | void ASTStmtWriter::VisitOMPAtomicDirective(OMPAtomicDirective *D) { |
2090 | 430 | VisitStmt(D); |
2091 | 430 | Record.push_back(D->getNumClauses()); |
2092 | 430 | VisitOMPExecutableDirective(D); |
2093 | 430 | Record.AddStmt(D->getX()); |
2094 | 430 | Record.AddStmt(D->getV()); |
2095 | 430 | Record.AddStmt(D->getExpr()); |
2096 | 430 | Record.AddStmt(D->getUpdateExpr()); |
2097 | 430 | Record.push_back(D->isXLHSInRHSPart() ? 1158 : 0272 ); |
2098 | 430 | Record.push_back(D->isPostfixUpdate() ? 144 : 0386 ); |
2099 | 430 | Code = serialization::STMT_OMP_ATOMIC_DIRECTIVE; |
2100 | 430 | } |
2101 | | |
2102 | 2.67k | void ASTStmtWriter::VisitOMPTargetDirective(OMPTargetDirective *D) { |
2103 | 2.67k | VisitStmt(D); |
2104 | 2.67k | Record.push_back(D->getNumClauses()); |
2105 | 2.67k | VisitOMPExecutableDirective(D); |
2106 | 2.67k | Code = serialization::STMT_OMP_TARGET_DIRECTIVE; |
2107 | 2.67k | } |
2108 | | |
2109 | 148 | void ASTStmtWriter::VisitOMPTargetDataDirective(OMPTargetDataDirective *D) { |
2110 | 148 | VisitStmt(D); |
2111 | 148 | Record.push_back(D->getNumClauses()); |
2112 | 148 | VisitOMPExecutableDirective(D); |
2113 | 148 | Code = serialization::STMT_OMP_TARGET_DATA_DIRECTIVE; |
2114 | 148 | } |
2115 | | |
2116 | | void ASTStmtWriter::VisitOMPTargetEnterDataDirective( |
2117 | 152 | OMPTargetEnterDataDirective *D) { |
2118 | 152 | VisitStmt(D); |
2119 | 152 | Record.push_back(D->getNumClauses()); |
2120 | 152 | VisitOMPExecutableDirective(D); |
2121 | 152 | Code = serialization::STMT_OMP_TARGET_ENTER_DATA_DIRECTIVE; |
2122 | 152 | } |
2123 | | |
2124 | | void ASTStmtWriter::VisitOMPTargetExitDataDirective( |
2125 | 152 | OMPTargetExitDataDirective *D) { |
2126 | 152 | VisitStmt(D); |
2127 | 152 | Record.push_back(D->getNumClauses()); |
2128 | 152 | VisitOMPExecutableDirective(D); |
2129 | 152 | Code = serialization::STMT_OMP_TARGET_EXIT_DATA_DIRECTIVE; |
2130 | 152 | } |
2131 | | |
2132 | | void ASTStmtWriter::VisitOMPTargetParallelDirective( |
2133 | 377 | OMPTargetParallelDirective *D) { |
2134 | 377 | VisitStmt(D); |
2135 | 377 | Record.push_back(D->getNumClauses()); |
2136 | 377 | VisitOMPExecutableDirective(D); |
2137 | 377 | Code = serialization::STMT_OMP_TARGET_PARALLEL_DIRECTIVE; |
2138 | 377 | } |
2139 | | |
2140 | | void ASTStmtWriter::VisitOMPTargetParallelForDirective( |
2141 | 290 | OMPTargetParallelForDirective *D) { |
2142 | 290 | VisitOMPLoopDirective(D); |
2143 | 290 | Record.push_back(D->hasCancel() ? 18 : 0282 ); |
2144 | 290 | Code = serialization::STMT_OMP_TARGET_PARALLEL_FOR_DIRECTIVE; |
2145 | 290 | } |
2146 | | |
2147 | 10 | void ASTStmtWriter::VisitOMPTaskyieldDirective(OMPTaskyieldDirective *D) { |
2148 | 10 | VisitStmt(D); |
2149 | 10 | VisitOMPExecutableDirective(D); |
2150 | 10 | Code = serialization::STMT_OMP_TASKYIELD_DIRECTIVE; |
2151 | 10 | } |
2152 | | |
2153 | 22 | void ASTStmtWriter::VisitOMPBarrierDirective(OMPBarrierDirective *D) { |
2154 | 22 | VisitStmt(D); |
2155 | 22 | VisitOMPExecutableDirective(D); |
2156 | 22 | Code = serialization::STMT_OMP_BARRIER_DIRECTIVE; |
2157 | 22 | } |
2158 | | |
2159 | 10 | void ASTStmtWriter::VisitOMPTaskwaitDirective(OMPTaskwaitDirective *D) { |
2160 | 10 | VisitStmt(D); |
2161 | 10 | VisitOMPExecutableDirective(D); |
2162 | 10 | Code = serialization::STMT_OMP_TASKWAIT_DIRECTIVE; |
2163 | 10 | } |
2164 | | |
2165 | 52 | void ASTStmtWriter::VisitOMPTaskgroupDirective(OMPTaskgroupDirective *D) { |
2166 | 52 | VisitStmt(D); |
2167 | 52 | Record.push_back(D->getNumClauses()); |
2168 | 52 | VisitOMPExecutableDirective(D); |
2169 | 52 | Record.AddStmt(D->getReductionRef()); |
2170 | 52 | Code = serialization::STMT_OMP_TASKGROUP_DIRECTIVE; |
2171 | 52 | } |
2172 | | |
2173 | 16 | void ASTStmtWriter::VisitOMPFlushDirective(OMPFlushDirective *D) { |
2174 | 16 | VisitStmt(D); |
2175 | 16 | Record.push_back(D->getNumClauses()); |
2176 | 16 | VisitOMPExecutableDirective(D); |
2177 | 16 | Code = serialization::STMT_OMP_FLUSH_DIRECTIVE; |
2178 | 16 | } |
2179 | | |
2180 | 52 | void ASTStmtWriter::VisitOMPOrderedDirective(OMPOrderedDirective *D) { |
2181 | 52 | VisitStmt(D); |
2182 | 52 | Record.push_back(D->getNumClauses()); |
2183 | 52 | VisitOMPExecutableDirective(D); |
2184 | 52 | Code = serialization::STMT_OMP_ORDERED_DIRECTIVE; |
2185 | 52 | } |
2186 | | |
2187 | 796 | void ASTStmtWriter::VisitOMPTeamsDirective(OMPTeamsDirective *D) { |
2188 | 796 | VisitStmt(D); |
2189 | 796 | Record.push_back(D->getNumClauses()); |
2190 | 796 | VisitOMPExecutableDirective(D); |
2191 | 796 | Code = serialization::STMT_OMP_TEAMS_DIRECTIVE; |
2192 | 796 | } |
2193 | | |
2194 | | void ASTStmtWriter::VisitOMPCancellationPointDirective( |
2195 | 38 | OMPCancellationPointDirective *D) { |
2196 | 38 | VisitStmt(D); |
2197 | 38 | VisitOMPExecutableDirective(D); |
2198 | 38 | Record.push_back(D->getCancelRegion()); |
2199 | 38 | Code = serialization::STMT_OMP_CANCELLATION_POINT_DIRECTIVE; |
2200 | 38 | } |
2201 | | |
2202 | 74 | void ASTStmtWriter::VisitOMPCancelDirective(OMPCancelDirective *D) { |
2203 | 74 | VisitStmt(D); |
2204 | 74 | Record.push_back(D->getNumClauses()); |
2205 | 74 | VisitOMPExecutableDirective(D); |
2206 | 74 | Record.push_back(D->getCancelRegion()); |
2207 | 74 | Code = serialization::STMT_OMP_CANCEL_DIRECTIVE; |
2208 | 74 | } |
2209 | | |
2210 | 30 | void ASTStmtWriter::VisitOMPTaskLoopDirective(OMPTaskLoopDirective *D) { |
2211 | 30 | VisitOMPLoopDirective(D); |
2212 | 30 | Code = serialization::STMT_OMP_TASKLOOP_DIRECTIVE; |
2213 | 30 | } |
2214 | | |
2215 | 30 | void ASTStmtWriter::VisitOMPTaskLoopSimdDirective(OMPTaskLoopSimdDirective *D) { |
2216 | 30 | VisitOMPLoopDirective(D); |
2217 | 30 | Code = serialization::STMT_OMP_TASKLOOP_SIMD_DIRECTIVE; |
2218 | 30 | } |
2219 | | |
2220 | 132 | void ASTStmtWriter::VisitOMPDistributeDirective(OMPDistributeDirective *D) { |
2221 | 132 | VisitOMPLoopDirective(D); |
2222 | 132 | Code = serialization::STMT_OMP_DISTRIBUTE_DIRECTIVE; |
2223 | 132 | } |
2224 | | |
2225 | 90 | void ASTStmtWriter::VisitOMPTargetUpdateDirective(OMPTargetUpdateDirective *D) { |
2226 | 90 | VisitStmt(D); |
2227 | 90 | Record.push_back(D->getNumClauses()); |
2228 | 90 | VisitOMPExecutableDirective(D); |
2229 | 90 | Code = serialization::STMT_OMP_TARGET_UPDATE_DIRECTIVE; |
2230 | 90 | } |
2231 | | |
2232 | | void ASTStmtWriter::VisitOMPDistributeParallelForDirective( |
2233 | 218 | OMPDistributeParallelForDirective *D) { |
2234 | 218 | VisitOMPLoopDirective(D); |
2235 | 218 | Record.push_back(D->hasCancel() ? 18 : 0210 ); |
2236 | 218 | Code = serialization::STMT_OMP_DISTRIBUTE_PARALLEL_FOR_DIRECTIVE; |
2237 | 218 | } |
2238 | | |
2239 | | void ASTStmtWriter::VisitOMPDistributeParallelForSimdDirective( |
2240 | 208 | OMPDistributeParallelForSimdDirective *D) { |
2241 | 208 | VisitOMPLoopDirective(D); |
2242 | 208 | Code = serialization::STMT_OMP_DISTRIBUTE_PARALLEL_FOR_SIMD_DIRECTIVE; |
2243 | 208 | } |
2244 | | |
2245 | | void ASTStmtWriter::VisitOMPDistributeSimdDirective( |
2246 | 122 | OMPDistributeSimdDirective *D) { |
2247 | 122 | VisitOMPLoopDirective(D); |
2248 | 122 | Code = serialization::STMT_OMP_DISTRIBUTE_SIMD_DIRECTIVE; |
2249 | 122 | } |
2250 | | |
2251 | | void ASTStmtWriter::VisitOMPTargetParallelForSimdDirective( |
2252 | 302 | OMPTargetParallelForSimdDirective *D) { |
2253 | 302 | VisitOMPLoopDirective(D); |
2254 | 302 | Code = serialization::STMT_OMP_TARGET_PARALLEL_FOR_SIMD_DIRECTIVE; |
2255 | 302 | } |
2256 | | |
2257 | 260 | void ASTStmtWriter::VisitOMPTargetSimdDirective(OMPTargetSimdDirective *D) { |
2258 | 260 | VisitOMPLoopDirective(D); |
2259 | 260 | Code = serialization::STMT_OMP_TARGET_SIMD_DIRECTIVE; |
2260 | 260 | } |
2261 | | |
2262 | | void ASTStmtWriter::VisitOMPTeamsDistributeDirective( |
2263 | 152 | OMPTeamsDistributeDirective *D) { |
2264 | 152 | VisitOMPLoopDirective(D); |
2265 | 152 | Code = serialization::STMT_OMP_TEAMS_DISTRIBUTE_DIRECTIVE; |
2266 | 152 | } |
2267 | | |
2268 | | void ASTStmtWriter::VisitOMPTeamsDistributeSimdDirective( |
2269 | 164 | OMPTeamsDistributeSimdDirective *D) { |
2270 | 164 | VisitOMPLoopDirective(D); |
2271 | 164 | Code = serialization::STMT_OMP_TEAMS_DISTRIBUTE_SIMD_DIRECTIVE; |
2272 | 164 | } |
2273 | | |
2274 | | void ASTStmtWriter::VisitOMPTeamsDistributeParallelForSimdDirective( |
2275 | 254 | OMPTeamsDistributeParallelForSimdDirective *D) { |
2276 | 254 | VisitOMPLoopDirective(D); |
2277 | 254 | Code = serialization::STMT_OMP_TEAMS_DISTRIBUTE_PARALLEL_FOR_SIMD_DIRECTIVE; |
2278 | 254 | } |
2279 | | |
2280 | | void ASTStmtWriter::VisitOMPTeamsDistributeParallelForDirective( |
2281 | 258 | OMPTeamsDistributeParallelForDirective *D) { |
2282 | 258 | VisitOMPLoopDirective(D); |
2283 | 258 | Record.push_back(D->hasCancel() ? 14 : 0254 ); |
2284 | 258 | Code = serialization::STMT_OMP_TEAMS_DISTRIBUTE_PARALLEL_FOR_DIRECTIVE; |
2285 | 258 | } |
2286 | | |
2287 | 348 | void ASTStmtWriter::VisitOMPTargetTeamsDirective(OMPTargetTeamsDirective *D) { |
2288 | 348 | VisitStmt(D); |
2289 | 348 | Record.push_back(D->getNumClauses()); |
2290 | 348 | VisitOMPExecutableDirective(D); |
2291 | 348 | Code = serialization::STMT_OMP_TARGET_TEAMS_DIRECTIVE; |
2292 | 348 | } |
2293 | | |
2294 | | void ASTStmtWriter::VisitOMPTargetTeamsDistributeDirective( |
2295 | 312 | OMPTargetTeamsDistributeDirective *D) { |
2296 | 312 | VisitOMPLoopDirective(D); |
2297 | 312 | Code = serialization::STMT_OMP_TARGET_TEAMS_DISTRIBUTE_DIRECTIVE; |
2298 | 312 | } |
2299 | | |
2300 | | void ASTStmtWriter::VisitOMPTargetTeamsDistributeParallelForDirective( |
2301 | 316 | OMPTargetTeamsDistributeParallelForDirective *D) { |
2302 | 316 | VisitOMPLoopDirective(D); |
2303 | 316 | Record.push_back(D->hasCancel() ? 110 : 0306 ); |
2304 | 316 | Code = serialization::STMT_OMP_TARGET_TEAMS_DISTRIBUTE_PARALLEL_FOR_DIRECTIVE; |
2305 | 316 | } |
2306 | | |
2307 | | void ASTStmtWriter::VisitOMPTargetTeamsDistributeParallelForSimdDirective( |
2308 | 416 | OMPTargetTeamsDistributeParallelForSimdDirective *D) { |
2309 | 416 | VisitOMPLoopDirective(D); |
2310 | 416 | Code = serialization:: |
2311 | 416 | STMT_OMP_TARGET_TEAMS_DISTRIBUTE_PARALLEL_FOR_SIMD_DIRECTIVE; |
2312 | 416 | } |
2313 | | |
2314 | | void ASTStmtWriter::VisitOMPTargetTeamsDistributeSimdDirective( |
2315 | 366 | OMPTargetTeamsDistributeSimdDirective *D) { |
2316 | 366 | VisitOMPLoopDirective(D); |
2317 | 366 | Code = serialization::STMT_OMP_TARGET_TEAMS_DISTRIBUTE_SIMD_DIRECTIVE; |
2318 | 366 | } |
2319 | | |
2320 | | //===----------------------------------------------------------------------===// |
2321 | | // ASTWriter Implementation |
2322 | | //===----------------------------------------------------------------------===// |
2323 | | |
2324 | 31 | unsigned ASTWriter::RecordSwitchCaseID(SwitchCase *S) { |
2325 | 31 | assert(SwitchCaseIDs.find(S) == SwitchCaseIDs.end() && |
2326 | 31 | "SwitchCase recorded twice"); |
2327 | 31 | unsigned NextID = SwitchCaseIDs.size(); |
2328 | 31 | SwitchCaseIDs[S] = NextID; |
2329 | 31 | return NextID; |
2330 | 31 | } |
2331 | | |
2332 | 31 | unsigned ASTWriter::getSwitchCaseID(SwitchCase *S) { |
2333 | 31 | assert(SwitchCaseIDs.find(S) != SwitchCaseIDs.end() && |
2334 | 31 | "SwitchCase hasn't been seen yet"); |
2335 | 31 | return SwitchCaseIDs[S]; |
2336 | 31 | } |
2337 | | |
2338 | 38.7k | void ASTWriter::ClearSwitchCaseIDs() { |
2339 | 38.7k | SwitchCaseIDs.clear(); |
2340 | 38.7k | } |
2341 | | |
2342 | | /// Write the given substatement or subexpression to the |
2343 | | /// bitstream. |
2344 | 1.30M | void ASTWriter::WriteSubStmt(Stmt *S) { |
2345 | 1.30M | RecordData Record; |
2346 | 1.30M | ASTStmtWriter Writer(*this, Record); |
2347 | 1.30M | ++NumStatements; |
2348 | 1.30M | |
2349 | 1.30M | if (!S) { |
2350 | 109k | Stream.EmitRecord(serialization::STMT_NULL_PTR, Record); |
2351 | 109k | return; |
2352 | 109k | } |
2353 | 1.19M | |
2354 | 1.19M | llvm::DenseMap<Stmt *, uint64_t>::iterator I = SubStmtEntries.find(S); |
2355 | 1.19M | if (I != SubStmtEntries.end()) { |
2356 | 125k | Record.push_back(I->second); |
2357 | 125k | Stream.EmitRecord(serialization::STMT_REF_PTR, Record); |
2358 | 125k | return; |
2359 | 125k | } |
2360 | 1.06M | |
2361 | | #ifndef NDEBUG |
2362 | | assert(!ParentStmts.count(S) && "There is a Stmt cycle!"); |
2363 | | |
2364 | | struct ParentStmtInserterRAII { |
2365 | | Stmt *S; |
2366 | | llvm::DenseSet<Stmt *> &ParentStmts; |
2367 | | |
2368 | | ParentStmtInserterRAII(Stmt *S, llvm::DenseSet<Stmt *> &ParentStmts) |
2369 | | : S(S), ParentStmts(ParentStmts) { |
2370 | | ParentStmts.insert(S); |
2371 | | } |
2372 | | ~ParentStmtInserterRAII() { |
2373 | | ParentStmts.erase(S); |
2374 | | } |
2375 | | }; |
2376 | | |
2377 | | ParentStmtInserterRAII ParentStmtInserter(S, ParentStmts); |
2378 | | #endif |
2379 | | |
2380 | 1.06M | Writer.Visit(S); |
2381 | 1.06M | |
2382 | 1.06M | uint64_t Offset = Writer.Emit(); |
2383 | 1.06M | SubStmtEntries[S] = Offset; |
2384 | 1.06M | } |
2385 | | |
2386 | | /// Flush all of the statements that have been added to the |
2387 | | /// queue via AddStmt(). |
2388 | 690k | void ASTRecordWriter::FlushStmts() { |
2389 | 690k | // We expect to be the only consumer of the two temporary statement maps, |
2390 | 690k | // assert that they are empty. |
2391 | 690k | assert(Writer->SubStmtEntries.empty() && "unexpected entries in sub-stmt map"); |
2392 | 690k | assert(Writer->ParentStmts.empty() && "unexpected entries in parent stmt map"); |
2393 | 690k | |
2394 | 828k | for (unsigned I = 0, N = StmtsToEmit.size(); I != N; ++I138k ) { |
2395 | 138k | Writer->WriteSubStmt(StmtsToEmit[I]); |
2396 | 138k | |
2397 | 138k | assert(N == StmtsToEmit.size() && "record modified while being written!"); |
2398 | 138k | |
2399 | 138k | // Note that we are at the end of a full expression. Any |
2400 | 138k | // expression records that follow this one are part of a different |
2401 | 138k | // expression. |
2402 | 138k | Writer->Stream.EmitRecord(serialization::STMT_STOP, ArrayRef<uint32_t>()); |
2403 | 138k | |
2404 | 138k | Writer->SubStmtEntries.clear(); |
2405 | 138k | Writer->ParentStmts.clear(); |
2406 | 138k | } |
2407 | 690k | |
2408 | 690k | StmtsToEmit.clear(); |
2409 | 690k | } |
2410 | | |
2411 | 1.06M | void ASTRecordWriter::FlushSubStmts() { |
2412 | 1.06M | // For a nested statement, write out the substatements in reverse order (so |
2413 | 1.06M | // that a simple stack machine can be used when loading), and don't emit a |
2414 | 1.06M | // STMT_STOP after each one. |
2415 | 2.23M | for (unsigned I = 0, N = StmtsToEmit.size(); I != N; ++I1.16M ) { |
2416 | 1.16M | Writer->WriteSubStmt(StmtsToEmit[N - I - 1]); |
2417 | 1.16M | assert(N == StmtsToEmit.size() && "record modified while being written!"); |
2418 | 1.16M | } |
2419 | 1.06M | |
2420 | 1.06M | StmtsToEmit.clear(); |
2421 | 1.06M | } |