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