1 //===--- ASTWriterStmt.cpp - Statement and Expression Serialization -------===//
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
7 //===----------------------------------------------------------------------===//
10 /// Implements serialization for Statements and Expressions.
12 //===----------------------------------------------------------------------===//
14 #include "clang/AST/ExprOpenMP.h"
15 #include "clang/Serialization/ASTRecordWriter.h"
16 #include "clang/Sema/DeclSpec.h"
17 #include "clang/AST/ASTContext.h"
18 #include "clang/AST/DeclCXX.h"
19 #include "clang/AST/DeclObjC.h"
20 #include "clang/AST/DeclTemplate.h"
21 #include "clang/AST/StmtVisitor.h"
22 #include "clang/Lex/Token.h"
23 #include "llvm/Bitstream/BitstreamWriter.h"
24 using namespace clang
;
26 //===----------------------------------------------------------------------===//
27 // Statement/expression serialization
28 //===----------------------------------------------------------------------===//
32 class ASTStmtWriter
: public StmtVisitor
<ASTStmtWriter
, void> {
34 ASTRecordWriter Record
;
36 serialization::StmtCode Code
;
40 ASTStmtWriter(ASTWriter
&Writer
, ASTWriter::RecordData
&Record
)
41 : Writer(Writer
), Record(Writer
, Record
),
42 Code(serialization::STMT_NULL_PTR
), AbbrevToUse(0) {}
44 ASTStmtWriter(const ASTStmtWriter
&) = delete;
45 ASTStmtWriter
&operator=(const ASTStmtWriter
&) = delete;
48 assert(Code
!= serialization::STMT_NULL_PTR
&&
49 "unhandled sub-statement writing AST file");
50 return Record
.EmitStmt(Code
, AbbrevToUse
);
53 void AddTemplateKWAndArgsInfo(const ASTTemplateKWAndArgsInfo
&ArgInfo
,
54 const TemplateArgumentLoc
*Args
);
56 void VisitStmt(Stmt
*S
);
57 #define STMT(Type, Base) \
58 void Visit##Type(Type *);
59 #include "clang/AST/StmtNodes.inc"
63 void ASTStmtWriter::AddTemplateKWAndArgsInfo(
64 const ASTTemplateKWAndArgsInfo
&ArgInfo
, const TemplateArgumentLoc
*Args
) {
65 Record
.AddSourceLocation(ArgInfo
.TemplateKWLoc
);
66 Record
.AddSourceLocation(ArgInfo
.LAngleLoc
);
67 Record
.AddSourceLocation(ArgInfo
.RAngleLoc
);
68 for (unsigned i
= 0; i
!= ArgInfo
.NumTemplateArgs
; ++i
)
69 Record
.AddTemplateArgumentLoc(Args
[i
]);
72 void ASTStmtWriter::VisitStmt(Stmt
*S
) {
75 void ASTStmtWriter::VisitNullStmt(NullStmt
*S
) {
77 Record
.AddSourceLocation(S
->getSemiLoc());
78 Record
.push_back(S
->NullStmtBits
.HasLeadingEmptyMacro
);
79 Code
= serialization::STMT_NULL
;
82 void ASTStmtWriter::VisitCompoundStmt(CompoundStmt
*S
) {
84 Record
.push_back(S
->size());
85 Record
.push_back(S
->hasStoredFPFeatures());
86 for (auto *CS
: S
->body())
88 if (S
->hasStoredFPFeatures())
89 Record
.push_back(S
->getStoredFPFeatures().getAsOpaqueInt());
90 Record
.AddSourceLocation(S
->getLBracLoc());
91 Record
.AddSourceLocation(S
->getRBracLoc());
92 Code
= serialization::STMT_COMPOUND
;
95 void ASTStmtWriter::VisitSwitchCase(SwitchCase
*S
) {
97 Record
.push_back(Writer
.getSwitchCaseID(S
));
98 Record
.AddSourceLocation(S
->getKeywordLoc());
99 Record
.AddSourceLocation(S
->getColonLoc());
102 void ASTStmtWriter::VisitCaseStmt(CaseStmt
*S
) {
104 Record
.push_back(S
->caseStmtIsGNURange());
105 Record
.AddStmt(S
->getLHS());
106 Record
.AddStmt(S
->getSubStmt());
107 if (S
->caseStmtIsGNURange()) {
108 Record
.AddStmt(S
->getRHS());
109 Record
.AddSourceLocation(S
->getEllipsisLoc());
111 Code
= serialization::STMT_CASE
;
114 void ASTStmtWriter::VisitDefaultStmt(DefaultStmt
*S
) {
116 Record
.AddStmt(S
->getSubStmt());
117 Code
= serialization::STMT_DEFAULT
;
120 void ASTStmtWriter::VisitLabelStmt(LabelStmt
*S
) {
122 Record
.push_back(S
->isSideEntry());
123 Record
.AddDeclRef(S
->getDecl());
124 Record
.AddStmt(S
->getSubStmt());
125 Record
.AddSourceLocation(S
->getIdentLoc());
126 Code
= serialization::STMT_LABEL
;
129 void ASTStmtWriter::VisitAttributedStmt(AttributedStmt
*S
) {
131 Record
.push_back(S
->getAttrs().size());
132 Record
.AddAttributes(S
->getAttrs());
133 Record
.AddStmt(S
->getSubStmt());
134 Record
.AddSourceLocation(S
->getAttrLoc());
135 Code
= serialization::STMT_ATTRIBUTED
;
138 void ASTStmtWriter::VisitIfStmt(IfStmt
*S
) {
141 bool HasElse
= S
->getElse() != nullptr;
142 bool HasVar
= S
->getConditionVariableDeclStmt() != nullptr;
143 bool HasInit
= S
->getInit() != nullptr;
145 Record
.push_back(HasElse
);
146 Record
.push_back(HasVar
);
147 Record
.push_back(HasInit
);
148 Record
.push_back(static_cast<uint64_t>(S
->getStatementKind()));
149 Record
.AddStmt(S
->getCond());
150 Record
.AddStmt(S
->getThen());
152 Record
.AddStmt(S
->getElse());
154 Record
.AddStmt(S
->getConditionVariableDeclStmt());
156 Record
.AddStmt(S
->getInit());
158 Record
.AddSourceLocation(S
->getIfLoc());
159 Record
.AddSourceLocation(S
->getLParenLoc());
160 Record
.AddSourceLocation(S
->getRParenLoc());
162 Record
.AddSourceLocation(S
->getElseLoc());
164 Code
= serialization::STMT_IF
;
167 void ASTStmtWriter::VisitSwitchStmt(SwitchStmt
*S
) {
170 bool HasInit
= S
->getInit() != nullptr;
171 bool HasVar
= S
->getConditionVariableDeclStmt() != nullptr;
172 Record
.push_back(HasInit
);
173 Record
.push_back(HasVar
);
174 Record
.push_back(S
->isAllEnumCasesCovered());
176 Record
.AddStmt(S
->getCond());
177 Record
.AddStmt(S
->getBody());
179 Record
.AddStmt(S
->getInit());
181 Record
.AddStmt(S
->getConditionVariableDeclStmt());
183 Record
.AddSourceLocation(S
->getSwitchLoc());
184 Record
.AddSourceLocation(S
->getLParenLoc());
185 Record
.AddSourceLocation(S
->getRParenLoc());
187 for (SwitchCase
*SC
= S
->getSwitchCaseList(); SC
;
188 SC
= SC
->getNextSwitchCase())
189 Record
.push_back(Writer
.RecordSwitchCaseID(SC
));
190 Code
= serialization::STMT_SWITCH
;
193 void ASTStmtWriter::VisitWhileStmt(WhileStmt
*S
) {
196 bool HasVar
= S
->getConditionVariableDeclStmt() != nullptr;
197 Record
.push_back(HasVar
);
199 Record
.AddStmt(S
->getCond());
200 Record
.AddStmt(S
->getBody());
202 Record
.AddStmt(S
->getConditionVariableDeclStmt());
204 Record
.AddSourceLocation(S
->getWhileLoc());
205 Record
.AddSourceLocation(S
->getLParenLoc());
206 Record
.AddSourceLocation(S
->getRParenLoc());
207 Code
= serialization::STMT_WHILE
;
210 void ASTStmtWriter::VisitDoStmt(DoStmt
*S
) {
212 Record
.AddStmt(S
->getCond());
213 Record
.AddStmt(S
->getBody());
214 Record
.AddSourceLocation(S
->getDoLoc());
215 Record
.AddSourceLocation(S
->getWhileLoc());
216 Record
.AddSourceLocation(S
->getRParenLoc());
217 Code
= serialization::STMT_DO
;
220 void ASTStmtWriter::VisitForStmt(ForStmt
*S
) {
222 Record
.AddStmt(S
->getInit());
223 Record
.AddStmt(S
->getCond());
224 Record
.AddStmt(S
->getConditionVariableDeclStmt());
225 Record
.AddStmt(S
->getInc());
226 Record
.AddStmt(S
->getBody());
227 Record
.AddSourceLocation(S
->getForLoc());
228 Record
.AddSourceLocation(S
->getLParenLoc());
229 Record
.AddSourceLocation(S
->getRParenLoc());
230 Code
= serialization::STMT_FOR
;
233 void ASTStmtWriter::VisitGotoStmt(GotoStmt
*S
) {
235 Record
.AddDeclRef(S
->getLabel());
236 Record
.AddSourceLocation(S
->getGotoLoc());
237 Record
.AddSourceLocation(S
->getLabelLoc());
238 Code
= serialization::STMT_GOTO
;
241 void ASTStmtWriter::VisitIndirectGotoStmt(IndirectGotoStmt
*S
) {
243 Record
.AddSourceLocation(S
->getGotoLoc());
244 Record
.AddSourceLocation(S
->getStarLoc());
245 Record
.AddStmt(S
->getTarget());
246 Code
= serialization::STMT_INDIRECT_GOTO
;
249 void ASTStmtWriter::VisitContinueStmt(ContinueStmt
*S
) {
251 Record
.AddSourceLocation(S
->getContinueLoc());
252 Code
= serialization::STMT_CONTINUE
;
255 void ASTStmtWriter::VisitBreakStmt(BreakStmt
*S
) {
257 Record
.AddSourceLocation(S
->getBreakLoc());
258 Code
= serialization::STMT_BREAK
;
261 void ASTStmtWriter::VisitReturnStmt(ReturnStmt
*S
) {
264 bool HasNRVOCandidate
= S
->getNRVOCandidate() != nullptr;
265 Record
.push_back(HasNRVOCandidate
);
267 Record
.AddStmt(S
->getRetValue());
268 if (HasNRVOCandidate
)
269 Record
.AddDeclRef(S
->getNRVOCandidate());
271 Record
.AddSourceLocation(S
->getReturnLoc());
272 Code
= serialization::STMT_RETURN
;
275 void ASTStmtWriter::VisitDeclStmt(DeclStmt
*S
) {
277 Record
.AddSourceLocation(S
->getBeginLoc());
278 Record
.AddSourceLocation(S
->getEndLoc());
279 DeclGroupRef DG
= S
->getDeclGroup();
280 for (DeclGroupRef::iterator D
= DG
.begin(), DEnd
= DG
.end(); D
!= DEnd
; ++D
)
281 Record
.AddDeclRef(*D
);
282 Code
= serialization::STMT_DECL
;
285 void ASTStmtWriter::VisitAsmStmt(AsmStmt
*S
) {
287 Record
.push_back(S
->getNumOutputs());
288 Record
.push_back(S
->getNumInputs());
289 Record
.push_back(S
->getNumClobbers());
290 Record
.AddSourceLocation(S
->getAsmLoc());
291 Record
.push_back(S
->isVolatile());
292 Record
.push_back(S
->isSimple());
295 void ASTStmtWriter::VisitGCCAsmStmt(GCCAsmStmt
*S
) {
297 Record
.push_back(S
->getNumLabels());
298 Record
.AddSourceLocation(S
->getRParenLoc());
299 Record
.AddStmt(S
->getAsmString());
302 for (unsigned I
= 0, N
= S
->getNumOutputs(); I
!= N
; ++I
) {
303 Record
.AddIdentifierRef(S
->getOutputIdentifier(I
));
304 Record
.AddStmt(S
->getOutputConstraintLiteral(I
));
305 Record
.AddStmt(S
->getOutputExpr(I
));
309 for (unsigned I
= 0, N
= S
->getNumInputs(); I
!= N
; ++I
) {
310 Record
.AddIdentifierRef(S
->getInputIdentifier(I
));
311 Record
.AddStmt(S
->getInputConstraintLiteral(I
));
312 Record
.AddStmt(S
->getInputExpr(I
));
316 for (unsigned I
= 0, N
= S
->getNumClobbers(); I
!= N
; ++I
)
317 Record
.AddStmt(S
->getClobberStringLiteral(I
));
320 for (unsigned I
= 0, N
= S
->getNumLabels(); I
!= N
; ++I
) {
321 Record
.AddIdentifierRef(S
->getLabelIdentifier(I
));
322 Record
.AddStmt(S
->getLabelExpr(I
));
325 Code
= serialization::STMT_GCCASM
;
328 void ASTStmtWriter::VisitMSAsmStmt(MSAsmStmt
*S
) {
330 Record
.AddSourceLocation(S
->getLBraceLoc());
331 Record
.AddSourceLocation(S
->getEndLoc());
332 Record
.push_back(S
->getNumAsmToks());
333 Record
.AddString(S
->getAsmString());
336 for (unsigned I
= 0, N
= S
->getNumAsmToks(); I
!= N
; ++I
) {
337 // FIXME: Move this to ASTRecordWriter?
338 Writer
.AddToken(S
->getAsmToks()[I
], Record
.getRecordData());
342 for (unsigned I
= 0, N
= S
->getNumClobbers(); I
!= N
; ++I
) {
343 Record
.AddString(S
->getClobber(I
));
347 for (unsigned I
= 0, N
= S
->getNumOutputs(); I
!= N
; ++I
) {
348 Record
.AddStmt(S
->getOutputExpr(I
));
349 Record
.AddString(S
->getOutputConstraint(I
));
353 for (unsigned I
= 0, N
= S
->getNumInputs(); I
!= N
; ++I
) {
354 Record
.AddStmt(S
->getInputExpr(I
));
355 Record
.AddString(S
->getInputConstraint(I
));
358 Code
= serialization::STMT_MSASM
;
361 void ASTStmtWriter::VisitCoroutineBodyStmt(CoroutineBodyStmt
*CoroStmt
) {
363 Record
.push_back(CoroStmt
->getParamMoves().size());
364 for (Stmt
*S
: CoroStmt
->children())
366 Code
= serialization::STMT_COROUTINE_BODY
;
369 void ASTStmtWriter::VisitCoreturnStmt(CoreturnStmt
*S
) {
371 Record
.AddSourceLocation(S
->getKeywordLoc());
372 Record
.AddStmt(S
->getOperand());
373 Record
.AddStmt(S
->getPromiseCall());
374 Record
.push_back(S
->isImplicit());
375 Code
= serialization::STMT_CORETURN
;
378 void ASTStmtWriter::VisitCoroutineSuspendExpr(CoroutineSuspendExpr
*E
) {
380 Record
.AddSourceLocation(E
->getKeywordLoc());
381 for (Stmt
*S
: E
->children())
383 Record
.AddStmt(E
->getOpaqueValue());
386 void ASTStmtWriter::VisitCoawaitExpr(CoawaitExpr
*E
) {
387 VisitCoroutineSuspendExpr(E
);
388 Record
.push_back(E
->isImplicit());
389 Code
= serialization::EXPR_COAWAIT
;
392 void ASTStmtWriter::VisitCoyieldExpr(CoyieldExpr
*E
) {
393 VisitCoroutineSuspendExpr(E
);
394 Code
= serialization::EXPR_COYIELD
;
397 void ASTStmtWriter::VisitDependentCoawaitExpr(DependentCoawaitExpr
*E
) {
399 Record
.AddSourceLocation(E
->getKeywordLoc());
400 for (Stmt
*S
: E
->children())
402 Code
= serialization::EXPR_DEPENDENT_COAWAIT
;
406 addConstraintSatisfaction(ASTRecordWriter
&Record
,
407 const ASTConstraintSatisfaction
&Satisfaction
) {
408 Record
.push_back(Satisfaction
.IsSatisfied
);
409 Record
.push_back(Satisfaction
.ContainsErrors
);
410 if (!Satisfaction
.IsSatisfied
) {
411 Record
.push_back(Satisfaction
.NumRecords
);
412 for (const auto &DetailRecord
: Satisfaction
) {
413 Record
.AddStmt(const_cast<Expr
*>(DetailRecord
.first
));
414 auto *E
= DetailRecord
.second
.dyn_cast
<Expr
*>();
415 Record
.push_back(E
== nullptr);
419 auto *Diag
= DetailRecord
.second
.get
<std::pair
<SourceLocation
,
421 Record
.AddSourceLocation(Diag
->first
);
422 Record
.AddString(Diag
->second
);
429 addSubstitutionDiagnostic(
430 ASTRecordWriter
&Record
,
431 const concepts::Requirement::SubstitutionDiagnostic
*D
) {
432 Record
.AddString(D
->SubstitutedEntity
);
433 Record
.AddSourceLocation(D
->DiagLoc
);
434 Record
.AddString(D
->DiagMessage
);
437 void ASTStmtWriter::VisitConceptSpecializationExpr(
438 ConceptSpecializationExpr
*E
) {
440 Record
.AddNestedNameSpecifierLoc(E
->getNestedNameSpecifierLoc());
441 Record
.AddSourceLocation(E
->getTemplateKWLoc());
442 Record
.AddDeclarationNameInfo(E
->getConceptNameInfo());
443 Record
.AddDeclRef(E
->getNamedConcept());
444 Record
.AddDeclRef(E
->getFoundDecl());
445 Record
.AddDeclRef(E
->getSpecializationDecl());
446 Record
.AddASTTemplateArgumentListInfo(E
->getTemplateArgsAsWritten());
447 if (!E
->isValueDependent())
448 addConstraintSatisfaction(Record
, E
->getSatisfaction());
450 Code
= serialization::EXPR_CONCEPT_SPECIALIZATION
;
453 void ASTStmtWriter::VisitRequiresExpr(RequiresExpr
*E
) {
455 Record
.push_back(E
->getLocalParameters().size());
456 Record
.push_back(E
->getRequirements().size());
457 Record
.AddSourceLocation(E
->RequiresExprBits
.RequiresKWLoc
);
458 Record
.push_back(E
->RequiresExprBits
.IsSatisfied
);
459 Record
.AddDeclRef(E
->getBody());
460 for (ParmVarDecl
*P
: E
->getLocalParameters())
461 Record
.AddDeclRef(P
);
462 for (concepts::Requirement
*R
: E
->getRequirements()) {
463 if (auto *TypeReq
= dyn_cast
<concepts::TypeRequirement
>(R
)) {
464 Record
.push_back(concepts::Requirement::RK_Type
);
465 Record
.push_back(TypeReq
->Status
);
466 if (TypeReq
->Status
== concepts::TypeRequirement::SS_SubstitutionFailure
)
467 addSubstitutionDiagnostic(Record
, TypeReq
->getSubstitutionDiagnostic());
469 Record
.AddTypeSourceInfo(TypeReq
->getType());
470 } else if (auto *ExprReq
= dyn_cast
<concepts::ExprRequirement
>(R
)) {
471 Record
.push_back(ExprReq
->getKind());
472 Record
.push_back(ExprReq
->Status
);
473 if (ExprReq
->isExprSubstitutionFailure()) {
474 addSubstitutionDiagnostic(Record
,
475 ExprReq
->Value
.get
<concepts::Requirement::SubstitutionDiagnostic
*>());
477 Record
.AddStmt(ExprReq
->Value
.get
<Expr
*>());
478 if (ExprReq
->getKind() == concepts::Requirement::RK_Compound
) {
479 Record
.AddSourceLocation(ExprReq
->NoexceptLoc
);
480 const auto &RetReq
= ExprReq
->getReturnTypeRequirement();
481 if (RetReq
.isSubstitutionFailure()) {
483 addSubstitutionDiagnostic(Record
, RetReq
.getSubstitutionDiagnostic());
484 } else if (RetReq
.isTypeConstraint()) {
486 Record
.AddTemplateParameterList(
487 RetReq
.getTypeConstraintTemplateParameterList());
488 if (ExprReq
->Status
>=
489 concepts::ExprRequirement::SS_ConstraintsNotSatisfied
)
491 ExprReq
->getReturnTypeRequirementSubstitutedConstraintExpr());
493 assert(RetReq
.isEmpty());
498 auto *NestedReq
= cast
<concepts::NestedRequirement
>(R
);
499 Record
.push_back(concepts::Requirement::RK_Nested
);
500 Record
.push_back(NestedReq
->hasInvalidConstraint());
501 if (NestedReq
->hasInvalidConstraint()) {
502 Record
.AddString(NestedReq
->getInvalidConstraintEntity());
503 addConstraintSatisfaction(Record
, *NestedReq
->Satisfaction
);
505 Record
.AddStmt(NestedReq
->getConstraintExpr());
506 if (!NestedReq
->isDependent())
507 addConstraintSatisfaction(Record
, *NestedReq
->Satisfaction
);
511 Record
.AddSourceLocation(E
->getEndLoc());
513 Code
= serialization::EXPR_REQUIRES
;
517 void ASTStmtWriter::VisitCapturedStmt(CapturedStmt
*S
) {
520 Record
.push_back(std::distance(S
->capture_begin(), S
->capture_end()));
522 // CapturedDecl and captured region kind
523 Record
.AddDeclRef(S
->getCapturedDecl());
524 Record
.push_back(S
->getCapturedRegionKind());
526 Record
.AddDeclRef(S
->getCapturedRecordDecl());
529 for (auto *I
: S
->capture_inits())
533 Record
.AddStmt(S
->getCapturedStmt());
536 for (const auto &I
: S
->captures()) {
537 if (I
.capturesThis() || I
.capturesVariableArrayType())
538 Record
.AddDeclRef(nullptr);
540 Record
.AddDeclRef(I
.getCapturedVar());
541 Record
.push_back(I
.getCaptureKind());
542 Record
.AddSourceLocation(I
.getLocation());
545 Code
= serialization::STMT_CAPTURED
;
548 void ASTStmtWriter::VisitExpr(Expr
*E
) {
550 Record
.AddTypeRef(E
->getType());
551 Record
.push_back(E
->getDependence());
552 Record
.push_back(E
->getValueKind());
553 Record
.push_back(E
->getObjectKind());
556 void ASTStmtWriter::VisitConstantExpr(ConstantExpr
*E
) {
558 Record
.push_back(E
->ConstantExprBits
.ResultKind
);
560 Record
.push_back(E
->ConstantExprBits
.APValueKind
);
561 Record
.push_back(E
->ConstantExprBits
.IsUnsigned
);
562 Record
.push_back(E
->ConstantExprBits
.BitWidth
);
563 // HasCleanup not serialized since we can just query the APValue.
564 Record
.push_back(E
->ConstantExprBits
.IsImmediateInvocation
);
566 switch (E
->ConstantExprBits
.ResultKind
) {
567 case ConstantExpr::RSK_None
:
569 case ConstantExpr::RSK_Int64
:
570 Record
.push_back(E
->Int64Result());
572 case ConstantExpr::RSK_APValue
:
573 Record
.AddAPValue(E
->APValueResult());
576 llvm_unreachable("unexpected ResultKind!");
579 Record
.AddStmt(E
->getSubExpr());
580 Code
= serialization::EXPR_CONSTANT
;
583 void ASTStmtWriter::VisitSYCLUniqueStableNameExpr(SYCLUniqueStableNameExpr
*E
) {
586 Record
.AddSourceLocation(E
->getLocation());
587 Record
.AddSourceLocation(E
->getLParenLocation());
588 Record
.AddSourceLocation(E
->getRParenLocation());
589 Record
.AddTypeSourceInfo(E
->getTypeSourceInfo());
591 Code
= serialization::EXPR_SYCL_UNIQUE_STABLE_NAME
;
594 void ASTStmtWriter::VisitPredefinedExpr(PredefinedExpr
*E
) {
597 bool HasFunctionName
= E
->getFunctionName() != nullptr;
598 Record
.push_back(HasFunctionName
);
599 Record
.push_back(E
->getIdentKind()); // FIXME: stable encoding
600 Record
.push_back(E
->isTransparent());
601 Record
.AddSourceLocation(E
->getLocation());
603 Record
.AddStmt(E
->getFunctionName());
604 Code
= serialization::EXPR_PREDEFINED
;
607 void ASTStmtWriter::VisitDeclRefExpr(DeclRefExpr
*E
) {
610 Record
.push_back(E
->hasQualifier());
611 Record
.push_back(E
->getDecl() != E
->getFoundDecl());
612 Record
.push_back(E
->hasTemplateKWAndArgsInfo());
613 Record
.push_back(E
->hadMultipleCandidates());
614 Record
.push_back(E
->refersToEnclosingVariableOrCapture());
615 Record
.push_back(E
->isNonOdrUse());
616 Record
.push_back(E
->isImmediateEscalating());
618 if (E
->hasTemplateKWAndArgsInfo()) {
619 unsigned NumTemplateArgs
= E
->getNumTemplateArgs();
620 Record
.push_back(NumTemplateArgs
);
623 DeclarationName::NameKind nk
= (E
->getDecl()->getDeclName().getNameKind());
625 if ((!E
->hasTemplateKWAndArgsInfo()) && (!E
->hasQualifier()) &&
626 (E
->getDecl() == E
->getFoundDecl()) &&
627 nk
== DeclarationName::Identifier
&&
628 !E
->refersToEnclosingVariableOrCapture() && !E
->isNonOdrUse() &&
629 !E
->isImmediateEscalating()) {
630 AbbrevToUse
= Writer
.getDeclRefExprAbbrev();
633 if (E
->hasQualifier())
634 Record
.AddNestedNameSpecifierLoc(E
->getQualifierLoc());
636 if (E
->getDecl() != E
->getFoundDecl())
637 Record
.AddDeclRef(E
->getFoundDecl());
639 if (E
->hasTemplateKWAndArgsInfo())
640 AddTemplateKWAndArgsInfo(*E
->getTrailingObjects
<ASTTemplateKWAndArgsInfo
>(),
641 E
->getTrailingObjects
<TemplateArgumentLoc
>());
643 Record
.AddDeclRef(E
->getDecl());
644 Record
.AddSourceLocation(E
->getLocation());
645 Record
.AddDeclarationNameLoc(E
->DNLoc
, E
->getDecl()->getDeclName());
646 Code
= serialization::EXPR_DECL_REF
;
649 void ASTStmtWriter::VisitIntegerLiteral(IntegerLiteral
*E
) {
651 Record
.AddSourceLocation(E
->getLocation());
652 Record
.AddAPInt(E
->getValue());
654 if (E
->getValue().getBitWidth() == 32) {
655 AbbrevToUse
= Writer
.getIntegerLiteralAbbrev();
658 Code
= serialization::EXPR_INTEGER_LITERAL
;
661 void ASTStmtWriter::VisitFixedPointLiteral(FixedPointLiteral
*E
) {
663 Record
.AddSourceLocation(E
->getLocation());
664 Record
.push_back(E
->getScale());
665 Record
.AddAPInt(E
->getValue());
666 Code
= serialization::EXPR_FIXEDPOINT_LITERAL
;
669 void ASTStmtWriter::VisitFloatingLiteral(FloatingLiteral
*E
) {
671 Record
.push_back(E
->getRawSemantics());
672 Record
.push_back(E
->isExact());
673 Record
.AddAPFloat(E
->getValue());
674 Record
.AddSourceLocation(E
->getLocation());
675 Code
= serialization::EXPR_FLOATING_LITERAL
;
678 void ASTStmtWriter::VisitImaginaryLiteral(ImaginaryLiteral
*E
) {
680 Record
.AddStmt(E
->getSubExpr());
681 Code
= serialization::EXPR_IMAGINARY_LITERAL
;
684 void ASTStmtWriter::VisitStringLiteral(StringLiteral
*E
) {
687 // Store the various bits of data of StringLiteral.
688 Record
.push_back(E
->getNumConcatenated());
689 Record
.push_back(E
->getLength());
690 Record
.push_back(E
->getCharByteWidth());
691 Record
.push_back(E
->getKind());
692 Record
.push_back(E
->isPascal());
694 // Store the trailing array of SourceLocation.
695 for (unsigned I
= 0, N
= E
->getNumConcatenated(); I
!= N
; ++I
)
696 Record
.AddSourceLocation(E
->getStrTokenLoc(I
));
698 // Store the trailing array of char holding the string data.
699 StringRef StrData
= E
->getBytes();
700 for (unsigned I
= 0, N
= E
->getByteLength(); I
!= N
; ++I
)
701 Record
.push_back(StrData
[I
]);
703 Code
= serialization::EXPR_STRING_LITERAL
;
706 void ASTStmtWriter::VisitCharacterLiteral(CharacterLiteral
*E
) {
708 Record
.push_back(E
->getValue());
709 Record
.AddSourceLocation(E
->getLocation());
710 Record
.push_back(E
->getKind());
712 AbbrevToUse
= Writer
.getCharacterLiteralAbbrev();
714 Code
= serialization::EXPR_CHARACTER_LITERAL
;
717 void ASTStmtWriter::VisitParenExpr(ParenExpr
*E
) {
719 Record
.AddSourceLocation(E
->getLParen());
720 Record
.AddSourceLocation(E
->getRParen());
721 Record
.AddStmt(E
->getSubExpr());
722 Code
= serialization::EXPR_PAREN
;
725 void ASTStmtWriter::VisitParenListExpr(ParenListExpr
*E
) {
727 Record
.push_back(E
->getNumExprs());
728 for (auto *SubStmt
: E
->exprs())
729 Record
.AddStmt(SubStmt
);
730 Record
.AddSourceLocation(E
->getLParenLoc());
731 Record
.AddSourceLocation(E
->getRParenLoc());
732 Code
= serialization::EXPR_PAREN_LIST
;
735 void ASTStmtWriter::VisitUnaryOperator(UnaryOperator
*E
) {
737 bool HasFPFeatures
= E
->hasStoredFPFeatures();
738 // Write this first for easy access when deserializing, as they affect the
739 // size of the UnaryOperator.
740 Record
.push_back(HasFPFeatures
);
741 Record
.AddStmt(E
->getSubExpr());
742 Record
.push_back(E
->getOpcode()); // FIXME: stable encoding
743 Record
.AddSourceLocation(E
->getOperatorLoc());
744 Record
.push_back(E
->canOverflow());
746 Record
.push_back(E
->getStoredFPFeatures().getAsOpaqueInt());
747 Code
= serialization::EXPR_UNARY_OPERATOR
;
750 void ASTStmtWriter::VisitOffsetOfExpr(OffsetOfExpr
*E
) {
752 Record
.push_back(E
->getNumComponents());
753 Record
.push_back(E
->getNumExpressions());
754 Record
.AddSourceLocation(E
->getOperatorLoc());
755 Record
.AddSourceLocation(E
->getRParenLoc());
756 Record
.AddTypeSourceInfo(E
->getTypeSourceInfo());
757 for (unsigned I
= 0, N
= E
->getNumComponents(); I
!= N
; ++I
) {
758 const OffsetOfNode
&ON
= E
->getComponent(I
);
759 Record
.push_back(ON
.getKind()); // FIXME: Stable encoding
760 Record
.AddSourceLocation(ON
.getSourceRange().getBegin());
761 Record
.AddSourceLocation(ON
.getSourceRange().getEnd());
762 switch (ON
.getKind()) {
763 case OffsetOfNode::Array
:
764 Record
.push_back(ON
.getArrayExprIndex());
767 case OffsetOfNode::Field
:
768 Record
.AddDeclRef(ON
.getField());
771 case OffsetOfNode::Identifier
:
772 Record
.AddIdentifierRef(ON
.getFieldName());
775 case OffsetOfNode::Base
:
776 Record
.AddCXXBaseSpecifier(*ON
.getBase());
780 for (unsigned I
= 0, N
= E
->getNumExpressions(); I
!= N
; ++I
)
781 Record
.AddStmt(E
->getIndexExpr(I
));
782 Code
= serialization::EXPR_OFFSETOF
;
785 void ASTStmtWriter::VisitUnaryExprOrTypeTraitExpr(UnaryExprOrTypeTraitExpr
*E
) {
787 Record
.push_back(E
->getKind());
788 if (E
->isArgumentType())
789 Record
.AddTypeSourceInfo(E
->getArgumentTypeInfo());
792 Record
.AddStmt(E
->getArgumentExpr());
794 Record
.AddSourceLocation(E
->getOperatorLoc());
795 Record
.AddSourceLocation(E
->getRParenLoc());
796 Code
= serialization::EXPR_SIZEOF_ALIGN_OF
;
799 void ASTStmtWriter::VisitArraySubscriptExpr(ArraySubscriptExpr
*E
) {
801 Record
.AddStmt(E
->getLHS());
802 Record
.AddStmt(E
->getRHS());
803 Record
.AddSourceLocation(E
->getRBracketLoc());
804 Code
= serialization::EXPR_ARRAY_SUBSCRIPT
;
807 void ASTStmtWriter::VisitMatrixSubscriptExpr(MatrixSubscriptExpr
*E
) {
809 Record
.AddStmt(E
->getBase());
810 Record
.AddStmt(E
->getRowIdx());
811 Record
.AddStmt(E
->getColumnIdx());
812 Record
.AddSourceLocation(E
->getRBracketLoc());
813 Code
= serialization::EXPR_ARRAY_SUBSCRIPT
;
816 void ASTStmtWriter::VisitOMPArraySectionExpr(OMPArraySectionExpr
*E
) {
818 Record
.AddStmt(E
->getBase());
819 Record
.AddStmt(E
->getLowerBound());
820 Record
.AddStmt(E
->getLength());
821 Record
.AddStmt(E
->getStride());
822 Record
.AddSourceLocation(E
->getColonLocFirst());
823 Record
.AddSourceLocation(E
->getColonLocSecond());
824 Record
.AddSourceLocation(E
->getRBracketLoc());
825 Code
= serialization::EXPR_OMP_ARRAY_SECTION
;
828 void ASTStmtWriter::VisitOMPArrayShapingExpr(OMPArrayShapingExpr
*E
) {
830 Record
.push_back(E
->getDimensions().size());
831 Record
.AddStmt(E
->getBase());
832 for (Expr
*Dim
: E
->getDimensions())
834 for (SourceRange SR
: E
->getBracketsRanges())
835 Record
.AddSourceRange(SR
);
836 Record
.AddSourceLocation(E
->getLParenLoc());
837 Record
.AddSourceLocation(E
->getRParenLoc());
838 Code
= serialization::EXPR_OMP_ARRAY_SHAPING
;
841 void ASTStmtWriter::VisitOMPIteratorExpr(OMPIteratorExpr
*E
) {
843 Record
.push_back(E
->numOfIterators());
844 Record
.AddSourceLocation(E
->getIteratorKwLoc());
845 Record
.AddSourceLocation(E
->getLParenLoc());
846 Record
.AddSourceLocation(E
->getRParenLoc());
847 for (unsigned I
= 0, End
= E
->numOfIterators(); I
< End
; ++I
) {
848 Record
.AddDeclRef(E
->getIteratorDecl(I
));
849 Record
.AddSourceLocation(E
->getAssignLoc(I
));
850 OMPIteratorExpr::IteratorRange Range
= E
->getIteratorRange(I
);
851 Record
.AddStmt(Range
.Begin
);
852 Record
.AddStmt(Range
.End
);
853 Record
.AddStmt(Range
.Step
);
854 Record
.AddSourceLocation(E
->getColonLoc(I
));
856 Record
.AddSourceLocation(E
->getSecondColonLoc(I
));
858 OMPIteratorHelperData
&HD
= E
->getHelper(I
);
859 Record
.AddDeclRef(HD
.CounterVD
);
860 Record
.AddStmt(HD
.Upper
);
861 Record
.AddStmt(HD
.Update
);
862 Record
.AddStmt(HD
.CounterUpdate
);
864 Code
= serialization::EXPR_OMP_ITERATOR
;
867 void ASTStmtWriter::VisitCallExpr(CallExpr
*E
) {
869 Record
.push_back(E
->getNumArgs());
870 Record
.push_back(E
->hasStoredFPFeatures());
871 Record
.AddSourceLocation(E
->getRParenLoc());
872 Record
.AddStmt(E
->getCallee());
873 for (CallExpr::arg_iterator Arg
= E
->arg_begin(), ArgEnd
= E
->arg_end();
874 Arg
!= ArgEnd
; ++Arg
)
875 Record
.AddStmt(*Arg
);
876 Record
.push_back(static_cast<unsigned>(E
->getADLCallKind()));
877 if (E
->hasStoredFPFeatures())
878 Record
.push_back(E
->getFPFeatures().getAsOpaqueInt());
879 Code
= serialization::EXPR_CALL
;
882 void ASTStmtWriter::VisitRecoveryExpr(RecoveryExpr
*E
) {
884 Record
.push_back(std::distance(E
->children().begin(), E
->children().end()));
885 Record
.AddSourceLocation(E
->getBeginLoc());
886 Record
.AddSourceLocation(E
->getEndLoc());
887 for (Stmt
*Child
: E
->children())
888 Record
.AddStmt(Child
);
889 Code
= serialization::EXPR_RECOVERY
;
892 void ASTStmtWriter::VisitMemberExpr(MemberExpr
*E
) {
895 bool HasQualifier
= E
->hasQualifier();
897 E
->hasQualifierOrFoundDecl() &&
898 (E
->getFoundDecl().getDecl() != E
->getMemberDecl() ||
899 E
->getFoundDecl().getAccess() != E
->getMemberDecl()->getAccess());
900 bool HasTemplateInfo
= E
->hasTemplateKWAndArgsInfo();
901 unsigned NumTemplateArgs
= E
->getNumTemplateArgs();
903 // Write these first for easy access when deserializing, as they affect the
904 // size of the MemberExpr.
905 Record
.push_back(HasQualifier
);
906 Record
.push_back(HasFoundDecl
);
907 Record
.push_back(HasTemplateInfo
);
908 Record
.push_back(NumTemplateArgs
);
910 Record
.AddStmt(E
->getBase());
911 Record
.AddDeclRef(E
->getMemberDecl());
912 Record
.AddDeclarationNameLoc(E
->MemberDNLoc
,
913 E
->getMemberDecl()->getDeclName());
914 Record
.AddSourceLocation(E
->getMemberLoc());
915 Record
.push_back(E
->isArrow());
916 Record
.push_back(E
->hadMultipleCandidates());
917 Record
.push_back(E
->isNonOdrUse());
918 Record
.AddSourceLocation(E
->getOperatorLoc());
921 DeclAccessPair FoundDecl
= E
->getFoundDecl();
922 Record
.AddDeclRef(FoundDecl
.getDecl());
923 Record
.push_back(FoundDecl
.getAccess());
927 Record
.AddNestedNameSpecifierLoc(E
->getQualifierLoc());
930 AddTemplateKWAndArgsInfo(*E
->getTrailingObjects
<ASTTemplateKWAndArgsInfo
>(),
931 E
->getTrailingObjects
<TemplateArgumentLoc
>());
933 Code
= serialization::EXPR_MEMBER
;
936 void ASTStmtWriter::VisitObjCIsaExpr(ObjCIsaExpr
*E
) {
938 Record
.AddStmt(E
->getBase());
939 Record
.AddSourceLocation(E
->getIsaMemberLoc());
940 Record
.AddSourceLocation(E
->getOpLoc());
941 Record
.push_back(E
->isArrow());
942 Code
= serialization::EXPR_OBJC_ISA
;
946 VisitObjCIndirectCopyRestoreExpr(ObjCIndirectCopyRestoreExpr
*E
) {
948 Record
.AddStmt(E
->getSubExpr());
949 Record
.push_back(E
->shouldCopy());
950 Code
= serialization::EXPR_OBJC_INDIRECT_COPY_RESTORE
;
953 void ASTStmtWriter::VisitObjCBridgedCastExpr(ObjCBridgedCastExpr
*E
) {
954 VisitExplicitCastExpr(E
);
955 Record
.AddSourceLocation(E
->getLParenLoc());
956 Record
.AddSourceLocation(E
->getBridgeKeywordLoc());
957 Record
.push_back(E
->getBridgeKind()); // FIXME: Stable encoding
958 Code
= serialization::EXPR_OBJC_BRIDGED_CAST
;
961 void ASTStmtWriter::VisitCastExpr(CastExpr
*E
) {
963 Record
.push_back(E
->path_size());
964 Record
.push_back(E
->hasStoredFPFeatures());
965 Record
.AddStmt(E
->getSubExpr());
966 Record
.push_back(E
->getCastKind()); // FIXME: stable encoding
968 for (CastExpr::path_iterator
969 PI
= E
->path_begin(), PE
= E
->path_end(); PI
!= PE
; ++PI
)
970 Record
.AddCXXBaseSpecifier(**PI
);
972 if (E
->hasStoredFPFeatures())
973 Record
.push_back(E
->getFPFeatures().getAsOpaqueInt());
976 void ASTStmtWriter::VisitBinaryOperator(BinaryOperator
*E
) {
978 bool HasFPFeatures
= E
->hasStoredFPFeatures();
979 // Write this first for easy access when deserializing, as they affect the
980 // size of the UnaryOperator.
981 Record
.push_back(HasFPFeatures
);
982 Record
.push_back(E
->getOpcode()); // FIXME: stable encoding
983 Record
.AddStmt(E
->getLHS());
984 Record
.AddStmt(E
->getRHS());
985 Record
.AddSourceLocation(E
->getOperatorLoc());
987 Record
.push_back(E
->getStoredFPFeatures().getAsOpaqueInt());
988 Code
= serialization::EXPR_BINARY_OPERATOR
;
991 void ASTStmtWriter::VisitCompoundAssignOperator(CompoundAssignOperator
*E
) {
992 VisitBinaryOperator(E
);
993 Record
.AddTypeRef(E
->getComputationLHSType());
994 Record
.AddTypeRef(E
->getComputationResultType());
995 Code
= serialization::EXPR_COMPOUND_ASSIGN_OPERATOR
;
998 void ASTStmtWriter::VisitConditionalOperator(ConditionalOperator
*E
) {
1000 Record
.AddStmt(E
->getCond());
1001 Record
.AddStmt(E
->getLHS());
1002 Record
.AddStmt(E
->getRHS());
1003 Record
.AddSourceLocation(E
->getQuestionLoc());
1004 Record
.AddSourceLocation(E
->getColonLoc());
1005 Code
= serialization::EXPR_CONDITIONAL_OPERATOR
;
1009 ASTStmtWriter::VisitBinaryConditionalOperator(BinaryConditionalOperator
*E
) {
1011 Record
.AddStmt(E
->getOpaqueValue());
1012 Record
.AddStmt(E
->getCommon());
1013 Record
.AddStmt(E
->getCond());
1014 Record
.AddStmt(E
->getTrueExpr());
1015 Record
.AddStmt(E
->getFalseExpr());
1016 Record
.AddSourceLocation(E
->getQuestionLoc());
1017 Record
.AddSourceLocation(E
->getColonLoc());
1018 Code
= serialization::EXPR_BINARY_CONDITIONAL_OPERATOR
;
1021 void ASTStmtWriter::VisitImplicitCastExpr(ImplicitCastExpr
*E
) {
1023 Record
.push_back(E
->isPartOfExplicitCast());
1025 if (E
->path_size() == 0 && !E
->hasStoredFPFeatures())
1026 AbbrevToUse
= Writer
.getExprImplicitCastAbbrev();
1028 Code
= serialization::EXPR_IMPLICIT_CAST
;
1031 void ASTStmtWriter::VisitExplicitCastExpr(ExplicitCastExpr
*E
) {
1033 Record
.AddTypeSourceInfo(E
->getTypeInfoAsWritten());
1036 void ASTStmtWriter::VisitCStyleCastExpr(CStyleCastExpr
*E
) {
1037 VisitExplicitCastExpr(E
);
1038 Record
.AddSourceLocation(E
->getLParenLoc());
1039 Record
.AddSourceLocation(E
->getRParenLoc());
1040 Code
= serialization::EXPR_CSTYLE_CAST
;
1043 void ASTStmtWriter::VisitCompoundLiteralExpr(CompoundLiteralExpr
*E
) {
1045 Record
.AddSourceLocation(E
->getLParenLoc());
1046 Record
.AddTypeSourceInfo(E
->getTypeSourceInfo());
1047 Record
.AddStmt(E
->getInitializer());
1048 Record
.push_back(E
->isFileScope());
1049 Code
= serialization::EXPR_COMPOUND_LITERAL
;
1052 void ASTStmtWriter::VisitExtVectorElementExpr(ExtVectorElementExpr
*E
) {
1054 Record
.AddStmt(E
->getBase());
1055 Record
.AddIdentifierRef(&E
->getAccessor());
1056 Record
.AddSourceLocation(E
->getAccessorLoc());
1057 Code
= serialization::EXPR_EXT_VECTOR_ELEMENT
;
1060 void ASTStmtWriter::VisitInitListExpr(InitListExpr
*E
) {
1062 // NOTE: only add the (possibly null) syntactic form.
1063 // No need to serialize the isSemanticForm flag and the semantic form.
1064 Record
.AddStmt(E
->getSyntacticForm());
1065 Record
.AddSourceLocation(E
->getLBraceLoc());
1066 Record
.AddSourceLocation(E
->getRBraceLoc());
1067 bool isArrayFiller
= E
->ArrayFillerOrUnionFieldInit
.is
<Expr
*>();
1068 Record
.push_back(isArrayFiller
);
1070 Record
.AddStmt(E
->getArrayFiller());
1072 Record
.AddDeclRef(E
->getInitializedFieldInUnion());
1073 Record
.push_back(E
->hadArrayRangeDesignator());
1074 Record
.push_back(E
->getNumInits());
1075 if (isArrayFiller
) {
1076 // ArrayFiller may have filled "holes" due to designated initializer.
1077 // Replace them by 0 to indicate that the filler goes in that place.
1078 Expr
*filler
= E
->getArrayFiller();
1079 for (unsigned I
= 0, N
= E
->getNumInits(); I
!= N
; ++I
)
1080 Record
.AddStmt(E
->getInit(I
) != filler
? E
->getInit(I
) : nullptr);
1082 for (unsigned I
= 0, N
= E
->getNumInits(); I
!= N
; ++I
)
1083 Record
.AddStmt(E
->getInit(I
));
1085 Code
= serialization::EXPR_INIT_LIST
;
1088 void ASTStmtWriter::VisitDesignatedInitExpr(DesignatedInitExpr
*E
) {
1090 Record
.push_back(E
->getNumSubExprs());
1091 for (unsigned I
= 0, N
= E
->getNumSubExprs(); I
!= N
; ++I
)
1092 Record
.AddStmt(E
->getSubExpr(I
));
1093 Record
.AddSourceLocation(E
->getEqualOrColonLoc());
1094 Record
.push_back(E
->usesGNUSyntax());
1095 for (const DesignatedInitExpr::Designator
&D
: E
->designators()) {
1096 if (D
.isFieldDesignator()) {
1097 if (FieldDecl
*Field
= D
.getFieldDecl()) {
1098 Record
.push_back(serialization::DESIG_FIELD_DECL
);
1099 Record
.AddDeclRef(Field
);
1101 Record
.push_back(serialization::DESIG_FIELD_NAME
);
1102 Record
.AddIdentifierRef(D
.getFieldName());
1104 Record
.AddSourceLocation(D
.getDotLoc());
1105 Record
.AddSourceLocation(D
.getFieldLoc());
1106 } else if (D
.isArrayDesignator()) {
1107 Record
.push_back(serialization::DESIG_ARRAY
);
1108 Record
.push_back(D
.getArrayIndex());
1109 Record
.AddSourceLocation(D
.getLBracketLoc());
1110 Record
.AddSourceLocation(D
.getRBracketLoc());
1112 assert(D
.isArrayRangeDesignator() && "Unknown designator");
1113 Record
.push_back(serialization::DESIG_ARRAY_RANGE
);
1114 Record
.push_back(D
.getArrayIndex());
1115 Record
.AddSourceLocation(D
.getLBracketLoc());
1116 Record
.AddSourceLocation(D
.getEllipsisLoc());
1117 Record
.AddSourceLocation(D
.getRBracketLoc());
1120 Code
= serialization::EXPR_DESIGNATED_INIT
;
1123 void ASTStmtWriter::VisitDesignatedInitUpdateExpr(DesignatedInitUpdateExpr
*E
) {
1125 Record
.AddStmt(E
->getBase());
1126 Record
.AddStmt(E
->getUpdater());
1127 Code
= serialization::EXPR_DESIGNATED_INIT_UPDATE
;
1130 void ASTStmtWriter::VisitNoInitExpr(NoInitExpr
*E
) {
1132 Code
= serialization::EXPR_NO_INIT
;
1135 void ASTStmtWriter::VisitArrayInitLoopExpr(ArrayInitLoopExpr
*E
) {
1137 Record
.AddStmt(E
->SubExprs
[0]);
1138 Record
.AddStmt(E
->SubExprs
[1]);
1139 Code
= serialization::EXPR_ARRAY_INIT_LOOP
;
1142 void ASTStmtWriter::VisitArrayInitIndexExpr(ArrayInitIndexExpr
*E
) {
1144 Code
= serialization::EXPR_ARRAY_INIT_INDEX
;
1147 void ASTStmtWriter::VisitImplicitValueInitExpr(ImplicitValueInitExpr
*E
) {
1149 Code
= serialization::EXPR_IMPLICIT_VALUE_INIT
;
1152 void ASTStmtWriter::VisitVAArgExpr(VAArgExpr
*E
) {
1154 Record
.AddStmt(E
->getSubExpr());
1155 Record
.AddTypeSourceInfo(E
->getWrittenTypeInfo());
1156 Record
.AddSourceLocation(E
->getBuiltinLoc());
1157 Record
.AddSourceLocation(E
->getRParenLoc());
1158 Record
.push_back(E
->isMicrosoftABI());
1159 Code
= serialization::EXPR_VA_ARG
;
1162 void ASTStmtWriter::VisitSourceLocExpr(SourceLocExpr
*E
) {
1164 Record
.AddDeclRef(cast_or_null
<Decl
>(E
->getParentContext()));
1165 Record
.AddSourceLocation(E
->getBeginLoc());
1166 Record
.AddSourceLocation(E
->getEndLoc());
1167 Record
.push_back(E
->getIdentKind());
1168 Code
= serialization::EXPR_SOURCE_LOC
;
1171 void ASTStmtWriter::VisitAddrLabelExpr(AddrLabelExpr
*E
) {
1173 Record
.AddSourceLocation(E
->getAmpAmpLoc());
1174 Record
.AddSourceLocation(E
->getLabelLoc());
1175 Record
.AddDeclRef(E
->getLabel());
1176 Code
= serialization::EXPR_ADDR_LABEL
;
1179 void ASTStmtWriter::VisitStmtExpr(StmtExpr
*E
) {
1181 Record
.AddStmt(E
->getSubStmt());
1182 Record
.AddSourceLocation(E
->getLParenLoc());
1183 Record
.AddSourceLocation(E
->getRParenLoc());
1184 Record
.push_back(E
->getTemplateDepth());
1185 Code
= serialization::EXPR_STMT
;
1188 void ASTStmtWriter::VisitChooseExpr(ChooseExpr
*E
) {
1190 Record
.AddStmt(E
->getCond());
1191 Record
.AddStmt(E
->getLHS());
1192 Record
.AddStmt(E
->getRHS());
1193 Record
.AddSourceLocation(E
->getBuiltinLoc());
1194 Record
.AddSourceLocation(E
->getRParenLoc());
1195 Record
.push_back(E
->isConditionDependent() ? false : E
->isConditionTrue());
1196 Code
= serialization::EXPR_CHOOSE
;
1199 void ASTStmtWriter::VisitGNUNullExpr(GNUNullExpr
*E
) {
1201 Record
.AddSourceLocation(E
->getTokenLocation());
1202 Code
= serialization::EXPR_GNU_NULL
;
1205 void ASTStmtWriter::VisitShuffleVectorExpr(ShuffleVectorExpr
*E
) {
1207 Record
.push_back(E
->getNumSubExprs());
1208 for (unsigned I
= 0, N
= E
->getNumSubExprs(); I
!= N
; ++I
)
1209 Record
.AddStmt(E
->getExpr(I
));
1210 Record
.AddSourceLocation(E
->getBuiltinLoc());
1211 Record
.AddSourceLocation(E
->getRParenLoc());
1212 Code
= serialization::EXPR_SHUFFLE_VECTOR
;
1215 void ASTStmtWriter::VisitConvertVectorExpr(ConvertVectorExpr
*E
) {
1217 Record
.AddSourceLocation(E
->getBuiltinLoc());
1218 Record
.AddSourceLocation(E
->getRParenLoc());
1219 Record
.AddTypeSourceInfo(E
->getTypeSourceInfo());
1220 Record
.AddStmt(E
->getSrcExpr());
1221 Code
= serialization::EXPR_CONVERT_VECTOR
;
1224 void ASTStmtWriter::VisitBlockExpr(BlockExpr
*E
) {
1226 Record
.AddDeclRef(E
->getBlockDecl());
1227 Code
= serialization::EXPR_BLOCK
;
1230 void ASTStmtWriter::VisitGenericSelectionExpr(GenericSelectionExpr
*E
) {
1233 Record
.push_back(E
->getNumAssocs());
1234 Record
.push_back(E
->isExprPredicate());
1235 Record
.push_back(E
->ResultIndex
);
1236 Record
.AddSourceLocation(E
->getGenericLoc());
1237 Record
.AddSourceLocation(E
->getDefaultLoc());
1238 Record
.AddSourceLocation(E
->getRParenLoc());
1240 Stmt
**Stmts
= E
->getTrailingObjects
<Stmt
*>();
1241 // Add 1 to account for the controlling expression which is the first
1242 // expression in the trailing array of Stmt *. This is not needed for
1243 // the trailing array of TypeSourceInfo *.
1244 for (unsigned I
= 0, N
= E
->getNumAssocs() + 1; I
< N
; ++I
)
1245 Record
.AddStmt(Stmts
[I
]);
1247 TypeSourceInfo
**TSIs
= E
->getTrailingObjects
<TypeSourceInfo
*>();
1248 for (unsigned I
= 0, N
= E
->getNumAssocs(); I
< N
; ++I
)
1249 Record
.AddTypeSourceInfo(TSIs
[I
]);
1251 Code
= serialization::EXPR_GENERIC_SELECTION
;
1254 void ASTStmtWriter::VisitPseudoObjectExpr(PseudoObjectExpr
*E
) {
1256 Record
.push_back(E
->getNumSemanticExprs());
1258 // Push the result index. Currently, this needs to exactly match
1259 // the encoding used internally for ResultIndex.
1260 unsigned result
= E
->getResultExprIndex();
1261 result
= (result
== PseudoObjectExpr::NoResult
? 0 : result
+ 1);
1262 Record
.push_back(result
);
1264 Record
.AddStmt(E
->getSyntacticForm());
1265 for (PseudoObjectExpr::semantics_iterator
1266 i
= E
->semantics_begin(), e
= E
->semantics_end(); i
!= e
; ++i
) {
1269 Code
= serialization::EXPR_PSEUDO_OBJECT
;
1272 void ASTStmtWriter::VisitAtomicExpr(AtomicExpr
*E
) {
1274 Record
.push_back(E
->getOp());
1275 for (unsigned I
= 0, N
= E
->getNumSubExprs(); I
!= N
; ++I
)
1276 Record
.AddStmt(E
->getSubExprs()[I
]);
1277 Record
.AddSourceLocation(E
->getBuiltinLoc());
1278 Record
.AddSourceLocation(E
->getRParenLoc());
1279 Code
= serialization::EXPR_ATOMIC
;
1282 //===----------------------------------------------------------------------===//
1283 // Objective-C Expressions and Statements.
1284 //===----------------------------------------------------------------------===//
1286 void ASTStmtWriter::VisitObjCStringLiteral(ObjCStringLiteral
*E
) {
1288 Record
.AddStmt(E
->getString());
1289 Record
.AddSourceLocation(E
->getAtLoc());
1290 Code
= serialization::EXPR_OBJC_STRING_LITERAL
;
1293 void ASTStmtWriter::VisitObjCBoxedExpr(ObjCBoxedExpr
*E
) {
1295 Record
.AddStmt(E
->getSubExpr());
1296 Record
.AddDeclRef(E
->getBoxingMethod());
1297 Record
.AddSourceRange(E
->getSourceRange());
1298 Code
= serialization::EXPR_OBJC_BOXED_EXPRESSION
;
1301 void ASTStmtWriter::VisitObjCArrayLiteral(ObjCArrayLiteral
*E
) {
1303 Record
.push_back(E
->getNumElements());
1304 for (unsigned i
= 0; i
< E
->getNumElements(); i
++)
1305 Record
.AddStmt(E
->getElement(i
));
1306 Record
.AddDeclRef(E
->getArrayWithObjectsMethod());
1307 Record
.AddSourceRange(E
->getSourceRange());
1308 Code
= serialization::EXPR_OBJC_ARRAY_LITERAL
;
1311 void ASTStmtWriter::VisitObjCDictionaryLiteral(ObjCDictionaryLiteral
*E
) {
1313 Record
.push_back(E
->getNumElements());
1314 Record
.push_back(E
->HasPackExpansions
);
1315 for (unsigned i
= 0; i
< E
->getNumElements(); i
++) {
1316 ObjCDictionaryElement Element
= E
->getKeyValueElement(i
);
1317 Record
.AddStmt(Element
.Key
);
1318 Record
.AddStmt(Element
.Value
);
1319 if (E
->HasPackExpansions
) {
1320 Record
.AddSourceLocation(Element
.EllipsisLoc
);
1321 unsigned NumExpansions
= 0;
1322 if (Element
.NumExpansions
)
1323 NumExpansions
= *Element
.NumExpansions
+ 1;
1324 Record
.push_back(NumExpansions
);
1328 Record
.AddDeclRef(E
->getDictWithObjectsMethod());
1329 Record
.AddSourceRange(E
->getSourceRange());
1330 Code
= serialization::EXPR_OBJC_DICTIONARY_LITERAL
;
1333 void ASTStmtWriter::VisitObjCEncodeExpr(ObjCEncodeExpr
*E
) {
1335 Record
.AddTypeSourceInfo(E
->getEncodedTypeSourceInfo());
1336 Record
.AddSourceLocation(E
->getAtLoc());
1337 Record
.AddSourceLocation(E
->getRParenLoc());
1338 Code
= serialization::EXPR_OBJC_ENCODE
;
1341 void ASTStmtWriter::VisitObjCSelectorExpr(ObjCSelectorExpr
*E
) {
1343 Record
.AddSelectorRef(E
->getSelector());
1344 Record
.AddSourceLocation(E
->getAtLoc());
1345 Record
.AddSourceLocation(E
->getRParenLoc());
1346 Code
= serialization::EXPR_OBJC_SELECTOR_EXPR
;
1349 void ASTStmtWriter::VisitObjCProtocolExpr(ObjCProtocolExpr
*E
) {
1351 Record
.AddDeclRef(E
->getProtocol());
1352 Record
.AddSourceLocation(E
->getAtLoc());
1353 Record
.AddSourceLocation(E
->ProtoLoc
);
1354 Record
.AddSourceLocation(E
->getRParenLoc());
1355 Code
= serialization::EXPR_OBJC_PROTOCOL_EXPR
;
1358 void ASTStmtWriter::VisitObjCIvarRefExpr(ObjCIvarRefExpr
*E
) {
1360 Record
.AddDeclRef(E
->getDecl());
1361 Record
.AddSourceLocation(E
->getLocation());
1362 Record
.AddSourceLocation(E
->getOpLoc());
1363 Record
.AddStmt(E
->getBase());
1364 Record
.push_back(E
->isArrow());
1365 Record
.push_back(E
->isFreeIvar());
1366 Code
= serialization::EXPR_OBJC_IVAR_REF_EXPR
;
1369 void ASTStmtWriter::VisitObjCPropertyRefExpr(ObjCPropertyRefExpr
*E
) {
1371 Record
.push_back(E
->SetterAndMethodRefFlags
.getInt());
1372 Record
.push_back(E
->isImplicitProperty());
1373 if (E
->isImplicitProperty()) {
1374 Record
.AddDeclRef(E
->getImplicitPropertyGetter());
1375 Record
.AddDeclRef(E
->getImplicitPropertySetter());
1377 Record
.AddDeclRef(E
->getExplicitProperty());
1379 Record
.AddSourceLocation(E
->getLocation());
1380 Record
.AddSourceLocation(E
->getReceiverLocation());
1381 if (E
->isObjectReceiver()) {
1382 Record
.push_back(0);
1383 Record
.AddStmt(E
->getBase());
1384 } else if (E
->isSuperReceiver()) {
1385 Record
.push_back(1);
1386 Record
.AddTypeRef(E
->getSuperReceiverType());
1388 Record
.push_back(2);
1389 Record
.AddDeclRef(E
->getClassReceiver());
1392 Code
= serialization::EXPR_OBJC_PROPERTY_REF_EXPR
;
1395 void ASTStmtWriter::VisitObjCSubscriptRefExpr(ObjCSubscriptRefExpr
*E
) {
1397 Record
.AddSourceLocation(E
->getRBracket());
1398 Record
.AddStmt(E
->getBaseExpr());
1399 Record
.AddStmt(E
->getKeyExpr());
1400 Record
.AddDeclRef(E
->getAtIndexMethodDecl());
1401 Record
.AddDeclRef(E
->setAtIndexMethodDecl());
1403 Code
= serialization::EXPR_OBJC_SUBSCRIPT_REF_EXPR
;
1406 void ASTStmtWriter::VisitObjCMessageExpr(ObjCMessageExpr
*E
) {
1408 Record
.push_back(E
->getNumArgs());
1409 Record
.push_back(E
->getNumStoredSelLocs());
1410 Record
.push_back(E
->SelLocsKind
);
1411 Record
.push_back(E
->isDelegateInitCall());
1412 Record
.push_back(E
->IsImplicit
);
1413 Record
.push_back((unsigned)E
->getReceiverKind()); // FIXME: stable encoding
1414 switch (E
->getReceiverKind()) {
1415 case ObjCMessageExpr::Instance
:
1416 Record
.AddStmt(E
->getInstanceReceiver());
1419 case ObjCMessageExpr::Class
:
1420 Record
.AddTypeSourceInfo(E
->getClassReceiverTypeInfo());
1423 case ObjCMessageExpr::SuperClass
:
1424 case ObjCMessageExpr::SuperInstance
:
1425 Record
.AddTypeRef(E
->getSuperType());
1426 Record
.AddSourceLocation(E
->getSuperLoc());
1430 if (E
->getMethodDecl()) {
1431 Record
.push_back(1);
1432 Record
.AddDeclRef(E
->getMethodDecl());
1434 Record
.push_back(0);
1435 Record
.AddSelectorRef(E
->getSelector());
1438 Record
.AddSourceLocation(E
->getLeftLoc());
1439 Record
.AddSourceLocation(E
->getRightLoc());
1441 for (CallExpr::arg_iterator Arg
= E
->arg_begin(), ArgEnd
= E
->arg_end();
1442 Arg
!= ArgEnd
; ++Arg
)
1443 Record
.AddStmt(*Arg
);
1445 SourceLocation
*Locs
= E
->getStoredSelLocs();
1446 for (unsigned i
= 0, e
= E
->getNumStoredSelLocs(); i
!= e
; ++i
)
1447 Record
.AddSourceLocation(Locs
[i
]);
1449 Code
= serialization::EXPR_OBJC_MESSAGE_EXPR
;
1452 void ASTStmtWriter::VisitObjCForCollectionStmt(ObjCForCollectionStmt
*S
) {
1454 Record
.AddStmt(S
->getElement());
1455 Record
.AddStmt(S
->getCollection());
1456 Record
.AddStmt(S
->getBody());
1457 Record
.AddSourceLocation(S
->getForLoc());
1458 Record
.AddSourceLocation(S
->getRParenLoc());
1459 Code
= serialization::STMT_OBJC_FOR_COLLECTION
;
1462 void ASTStmtWriter::VisitObjCAtCatchStmt(ObjCAtCatchStmt
*S
) {
1464 Record
.AddStmt(S
->getCatchBody());
1465 Record
.AddDeclRef(S
->getCatchParamDecl());
1466 Record
.AddSourceLocation(S
->getAtCatchLoc());
1467 Record
.AddSourceLocation(S
->getRParenLoc());
1468 Code
= serialization::STMT_OBJC_CATCH
;
1471 void ASTStmtWriter::VisitObjCAtFinallyStmt(ObjCAtFinallyStmt
*S
) {
1473 Record
.AddStmt(S
->getFinallyBody());
1474 Record
.AddSourceLocation(S
->getAtFinallyLoc());
1475 Code
= serialization::STMT_OBJC_FINALLY
;
1478 void ASTStmtWriter::VisitObjCAutoreleasePoolStmt(ObjCAutoreleasePoolStmt
*S
) {
1479 VisitStmt(S
); // FIXME: no test coverage.
1480 Record
.AddStmt(S
->getSubStmt());
1481 Record
.AddSourceLocation(S
->getAtLoc());
1482 Code
= serialization::STMT_OBJC_AUTORELEASE_POOL
;
1485 void ASTStmtWriter::VisitObjCAtTryStmt(ObjCAtTryStmt
*S
) {
1487 Record
.push_back(S
->getNumCatchStmts());
1488 Record
.push_back(S
->getFinallyStmt() != nullptr);
1489 Record
.AddStmt(S
->getTryBody());
1490 for (ObjCAtCatchStmt
*C
: S
->catch_stmts())
1492 if (S
->getFinallyStmt())
1493 Record
.AddStmt(S
->getFinallyStmt());
1494 Record
.AddSourceLocation(S
->getAtTryLoc());
1495 Code
= serialization::STMT_OBJC_AT_TRY
;
1498 void ASTStmtWriter::VisitObjCAtSynchronizedStmt(ObjCAtSynchronizedStmt
*S
) {
1499 VisitStmt(S
); // FIXME: no test coverage.
1500 Record
.AddStmt(S
->getSynchExpr());
1501 Record
.AddStmt(S
->getSynchBody());
1502 Record
.AddSourceLocation(S
->getAtSynchronizedLoc());
1503 Code
= serialization::STMT_OBJC_AT_SYNCHRONIZED
;
1506 void ASTStmtWriter::VisitObjCAtThrowStmt(ObjCAtThrowStmt
*S
) {
1507 VisitStmt(S
); // FIXME: no test coverage.
1508 Record
.AddStmt(S
->getThrowExpr());
1509 Record
.AddSourceLocation(S
->getThrowLoc());
1510 Code
= serialization::STMT_OBJC_AT_THROW
;
1513 void ASTStmtWriter::VisitObjCBoolLiteralExpr(ObjCBoolLiteralExpr
*E
) {
1515 Record
.push_back(E
->getValue());
1516 Record
.AddSourceLocation(E
->getLocation());
1517 Code
= serialization::EXPR_OBJC_BOOL_LITERAL
;
1520 void ASTStmtWriter::VisitObjCAvailabilityCheckExpr(ObjCAvailabilityCheckExpr
*E
) {
1522 Record
.AddSourceRange(E
->getSourceRange());
1523 Record
.AddVersionTuple(E
->getVersion());
1524 Code
= serialization::EXPR_OBJC_AVAILABILITY_CHECK
;
1527 //===----------------------------------------------------------------------===//
1528 // C++ Expressions and Statements.
1529 //===----------------------------------------------------------------------===//
1531 void ASTStmtWriter::VisitCXXCatchStmt(CXXCatchStmt
*S
) {
1533 Record
.AddSourceLocation(S
->getCatchLoc());
1534 Record
.AddDeclRef(S
->getExceptionDecl());
1535 Record
.AddStmt(S
->getHandlerBlock());
1536 Code
= serialization::STMT_CXX_CATCH
;
1539 void ASTStmtWriter::VisitCXXTryStmt(CXXTryStmt
*S
) {
1541 Record
.push_back(S
->getNumHandlers());
1542 Record
.AddSourceLocation(S
->getTryLoc());
1543 Record
.AddStmt(S
->getTryBlock());
1544 for (unsigned i
= 0, e
= S
->getNumHandlers(); i
!= e
; ++i
)
1545 Record
.AddStmt(S
->getHandler(i
));
1546 Code
= serialization::STMT_CXX_TRY
;
1549 void ASTStmtWriter::VisitCXXForRangeStmt(CXXForRangeStmt
*S
) {
1551 Record
.AddSourceLocation(S
->getForLoc());
1552 Record
.AddSourceLocation(S
->getCoawaitLoc());
1553 Record
.AddSourceLocation(S
->getColonLoc());
1554 Record
.AddSourceLocation(S
->getRParenLoc());
1555 Record
.AddStmt(S
->getInit());
1556 Record
.AddStmt(S
->getRangeStmt());
1557 Record
.AddStmt(S
->getBeginStmt());
1558 Record
.AddStmt(S
->getEndStmt());
1559 Record
.AddStmt(S
->getCond());
1560 Record
.AddStmt(S
->getInc());
1561 Record
.AddStmt(S
->getLoopVarStmt());
1562 Record
.AddStmt(S
->getBody());
1563 Code
= serialization::STMT_CXX_FOR_RANGE
;
1566 void ASTStmtWriter::VisitMSDependentExistsStmt(MSDependentExistsStmt
*S
) {
1568 Record
.AddSourceLocation(S
->getKeywordLoc());
1569 Record
.push_back(S
->isIfExists());
1570 Record
.AddNestedNameSpecifierLoc(S
->getQualifierLoc());
1571 Record
.AddDeclarationNameInfo(S
->getNameInfo());
1572 Record
.AddStmt(S
->getSubStmt());
1573 Code
= serialization::STMT_MS_DEPENDENT_EXISTS
;
1576 void ASTStmtWriter::VisitCXXOperatorCallExpr(CXXOperatorCallExpr
*E
) {
1578 Record
.push_back(E
->getOperator());
1579 Record
.AddSourceRange(E
->Range
);
1580 Code
= serialization::EXPR_CXX_OPERATOR_CALL
;
1583 void ASTStmtWriter::VisitCXXMemberCallExpr(CXXMemberCallExpr
*E
) {
1585 Code
= serialization::EXPR_CXX_MEMBER_CALL
;
1588 void ASTStmtWriter::VisitCXXRewrittenBinaryOperator(
1589 CXXRewrittenBinaryOperator
*E
) {
1591 Record
.push_back(E
->isReversed());
1592 Record
.AddStmt(E
->getSemanticForm());
1593 Code
= serialization::EXPR_CXX_REWRITTEN_BINARY_OPERATOR
;
1596 void ASTStmtWriter::VisitCXXConstructExpr(CXXConstructExpr
*E
) {
1599 Record
.push_back(E
->getNumArgs());
1600 Record
.push_back(E
->isElidable());
1601 Record
.push_back(E
->hadMultipleCandidates());
1602 Record
.push_back(E
->isListInitialization());
1603 Record
.push_back(E
->isStdInitListInitialization());
1604 Record
.push_back(E
->requiresZeroInitialization());
1605 Record
.push_back(E
->getConstructionKind()); // FIXME: stable encoding
1606 Record
.push_back(E
->isImmediateEscalating());
1607 Record
.AddSourceLocation(E
->getLocation());
1608 Record
.AddDeclRef(E
->getConstructor());
1609 Record
.AddSourceRange(E
->getParenOrBraceRange());
1611 for (unsigned I
= 0, N
= E
->getNumArgs(); I
!= N
; ++I
)
1612 Record
.AddStmt(E
->getArg(I
));
1614 Code
= serialization::EXPR_CXX_CONSTRUCT
;
1617 void ASTStmtWriter::VisitCXXInheritedCtorInitExpr(CXXInheritedCtorInitExpr
*E
) {
1619 Record
.AddDeclRef(E
->getConstructor());
1620 Record
.AddSourceLocation(E
->getLocation());
1621 Record
.push_back(E
->constructsVBase());
1622 Record
.push_back(E
->inheritedFromVBase());
1623 Code
= serialization::EXPR_CXX_INHERITED_CTOR_INIT
;
1626 void ASTStmtWriter::VisitCXXTemporaryObjectExpr(CXXTemporaryObjectExpr
*E
) {
1627 VisitCXXConstructExpr(E
);
1628 Record
.AddTypeSourceInfo(E
->getTypeSourceInfo());
1629 Code
= serialization::EXPR_CXX_TEMPORARY_OBJECT
;
1632 void ASTStmtWriter::VisitLambdaExpr(LambdaExpr
*E
) {
1634 Record
.push_back(E
->LambdaExprBits
.NumCaptures
);
1635 Record
.AddSourceRange(E
->IntroducerRange
);
1636 Record
.push_back(E
->LambdaExprBits
.CaptureDefault
); // FIXME: stable encoding
1637 Record
.AddSourceLocation(E
->CaptureDefaultLoc
);
1638 Record
.push_back(E
->LambdaExprBits
.ExplicitParams
);
1639 Record
.push_back(E
->LambdaExprBits
.ExplicitResultType
);
1640 Record
.AddSourceLocation(E
->ClosingBrace
);
1642 // Add capture initializers.
1643 for (LambdaExpr::capture_init_iterator C
= E
->capture_init_begin(),
1644 CEnd
= E
->capture_init_end();
1649 // Don't serialize the body. It belongs to the call operator declaration.
1650 // LambdaExpr only stores a copy of the Stmt *.
1652 Code
= serialization::EXPR_LAMBDA
;
1655 void ASTStmtWriter::VisitCXXStdInitializerListExpr(CXXStdInitializerListExpr
*E
) {
1657 Record
.AddStmt(E
->getSubExpr());
1658 Code
= serialization::EXPR_CXX_STD_INITIALIZER_LIST
;
1661 void ASTStmtWriter::VisitCXXNamedCastExpr(CXXNamedCastExpr
*E
) {
1662 VisitExplicitCastExpr(E
);
1663 Record
.AddSourceRange(SourceRange(E
->getOperatorLoc(), E
->getRParenLoc()));
1664 Record
.AddSourceRange(E
->getAngleBrackets());
1667 void ASTStmtWriter::VisitCXXStaticCastExpr(CXXStaticCastExpr
*E
) {
1668 VisitCXXNamedCastExpr(E
);
1669 Code
= serialization::EXPR_CXX_STATIC_CAST
;
1672 void ASTStmtWriter::VisitCXXDynamicCastExpr(CXXDynamicCastExpr
*E
) {
1673 VisitCXXNamedCastExpr(E
);
1674 Code
= serialization::EXPR_CXX_DYNAMIC_CAST
;
1677 void ASTStmtWriter::VisitCXXReinterpretCastExpr(CXXReinterpretCastExpr
*E
) {
1678 VisitCXXNamedCastExpr(E
);
1679 Code
= serialization::EXPR_CXX_REINTERPRET_CAST
;
1682 void ASTStmtWriter::VisitCXXConstCastExpr(CXXConstCastExpr
*E
) {
1683 VisitCXXNamedCastExpr(E
);
1684 Code
= serialization::EXPR_CXX_CONST_CAST
;
1687 void ASTStmtWriter::VisitCXXAddrspaceCastExpr(CXXAddrspaceCastExpr
*E
) {
1688 VisitCXXNamedCastExpr(E
);
1689 Code
= serialization::EXPR_CXX_ADDRSPACE_CAST
;
1692 void ASTStmtWriter::VisitCXXFunctionalCastExpr(CXXFunctionalCastExpr
*E
) {
1693 VisitExplicitCastExpr(E
);
1694 Record
.AddSourceLocation(E
->getLParenLoc());
1695 Record
.AddSourceLocation(E
->getRParenLoc());
1696 Code
= serialization::EXPR_CXX_FUNCTIONAL_CAST
;
1699 void ASTStmtWriter::VisitBuiltinBitCastExpr(BuiltinBitCastExpr
*E
) {
1700 VisitExplicitCastExpr(E
);
1701 Record
.AddSourceLocation(E
->getBeginLoc());
1702 Record
.AddSourceLocation(E
->getEndLoc());
1703 Code
= serialization::EXPR_BUILTIN_BIT_CAST
;
1706 void ASTStmtWriter::VisitUserDefinedLiteral(UserDefinedLiteral
*E
) {
1708 Record
.AddSourceLocation(E
->UDSuffixLoc
);
1709 Code
= serialization::EXPR_USER_DEFINED_LITERAL
;
1712 void ASTStmtWriter::VisitCXXBoolLiteralExpr(CXXBoolLiteralExpr
*E
) {
1714 Record
.push_back(E
->getValue());
1715 Record
.AddSourceLocation(E
->getLocation());
1716 Code
= serialization::EXPR_CXX_BOOL_LITERAL
;
1719 void ASTStmtWriter::VisitCXXNullPtrLiteralExpr(CXXNullPtrLiteralExpr
*E
) {
1721 Record
.AddSourceLocation(E
->getLocation());
1722 Code
= serialization::EXPR_CXX_NULL_PTR_LITERAL
;
1725 void ASTStmtWriter::VisitCXXTypeidExpr(CXXTypeidExpr
*E
) {
1727 Record
.AddSourceRange(E
->getSourceRange());
1728 if (E
->isTypeOperand()) {
1729 Record
.AddTypeSourceInfo(E
->getTypeOperandSourceInfo());
1730 Code
= serialization::EXPR_CXX_TYPEID_TYPE
;
1732 Record
.AddStmt(E
->getExprOperand());
1733 Code
= serialization::EXPR_CXX_TYPEID_EXPR
;
1737 void ASTStmtWriter::VisitCXXThisExpr(CXXThisExpr
*E
) {
1739 Record
.AddSourceLocation(E
->getLocation());
1740 Record
.push_back(E
->isImplicit());
1741 Code
= serialization::EXPR_CXX_THIS
;
1744 void ASTStmtWriter::VisitCXXThrowExpr(CXXThrowExpr
*E
) {
1746 Record
.AddSourceLocation(E
->getThrowLoc());
1747 Record
.AddStmt(E
->getSubExpr());
1748 Record
.push_back(E
->isThrownVariableInScope());
1749 Code
= serialization::EXPR_CXX_THROW
;
1752 void ASTStmtWriter::VisitCXXDefaultArgExpr(CXXDefaultArgExpr
*E
) {
1754 Record
.AddDeclRef(E
->getParam());
1755 Record
.AddDeclRef(cast_or_null
<Decl
>(E
->getUsedContext()));
1756 Record
.AddSourceLocation(E
->getUsedLocation());
1757 Record
.push_back(E
->hasRewrittenInit());
1758 if (E
->hasRewrittenInit())
1759 Record
.AddStmt(E
->getRewrittenExpr());
1760 Code
= serialization::EXPR_CXX_DEFAULT_ARG
;
1763 void ASTStmtWriter::VisitCXXDefaultInitExpr(CXXDefaultInitExpr
*E
) {
1765 Record
.push_back(E
->hasRewrittenInit());
1766 Record
.AddDeclRef(E
->getField());
1767 Record
.AddDeclRef(cast_or_null
<Decl
>(E
->getUsedContext()));
1768 Record
.AddSourceLocation(E
->getExprLoc());
1769 if (E
->hasRewrittenInit())
1770 Record
.AddStmt(E
->getRewrittenExpr());
1771 Code
= serialization::EXPR_CXX_DEFAULT_INIT
;
1774 void ASTStmtWriter::VisitCXXBindTemporaryExpr(CXXBindTemporaryExpr
*E
) {
1776 Record
.AddCXXTemporary(E
->getTemporary());
1777 Record
.AddStmt(E
->getSubExpr());
1778 Code
= serialization::EXPR_CXX_BIND_TEMPORARY
;
1781 void ASTStmtWriter::VisitCXXScalarValueInitExpr(CXXScalarValueInitExpr
*E
) {
1783 Record
.AddTypeSourceInfo(E
->getTypeSourceInfo());
1784 Record
.AddSourceLocation(E
->getRParenLoc());
1785 Code
= serialization::EXPR_CXX_SCALAR_VALUE_INIT
;
1788 void ASTStmtWriter::VisitCXXNewExpr(CXXNewExpr
*E
) {
1791 Record
.push_back(E
->isArray());
1792 Record
.push_back(E
->hasInitializer());
1793 Record
.push_back(E
->getNumPlacementArgs());
1794 Record
.push_back(E
->isParenTypeId());
1796 Record
.push_back(E
->isGlobalNew());
1797 Record
.push_back(E
->passAlignment());
1798 Record
.push_back(E
->doesUsualArrayDeleteWantSize());
1799 Record
.push_back(E
->CXXNewExprBits
.StoredInitializationStyle
);
1801 Record
.AddDeclRef(E
->getOperatorNew());
1802 Record
.AddDeclRef(E
->getOperatorDelete());
1803 Record
.AddTypeSourceInfo(E
->getAllocatedTypeSourceInfo());
1804 if (E
->isParenTypeId())
1805 Record
.AddSourceRange(E
->getTypeIdParens());
1806 Record
.AddSourceRange(E
->getSourceRange());
1807 Record
.AddSourceRange(E
->getDirectInitRange());
1809 for (CXXNewExpr::arg_iterator I
= E
->raw_arg_begin(), N
= E
->raw_arg_end();
1813 Code
= serialization::EXPR_CXX_NEW
;
1816 void ASTStmtWriter::VisitCXXDeleteExpr(CXXDeleteExpr
*E
) {
1818 Record
.push_back(E
->isGlobalDelete());
1819 Record
.push_back(E
->isArrayForm());
1820 Record
.push_back(E
->isArrayFormAsWritten());
1821 Record
.push_back(E
->doesUsualArrayDeleteWantSize());
1822 Record
.AddDeclRef(E
->getOperatorDelete());
1823 Record
.AddStmt(E
->getArgument());
1824 Record
.AddSourceLocation(E
->getBeginLoc());
1826 Code
= serialization::EXPR_CXX_DELETE
;
1829 void ASTStmtWriter::VisitCXXPseudoDestructorExpr(CXXPseudoDestructorExpr
*E
) {
1832 Record
.AddStmt(E
->getBase());
1833 Record
.push_back(E
->isArrow());
1834 Record
.AddSourceLocation(E
->getOperatorLoc());
1835 Record
.AddNestedNameSpecifierLoc(E
->getQualifierLoc());
1836 Record
.AddTypeSourceInfo(E
->getScopeTypeInfo());
1837 Record
.AddSourceLocation(E
->getColonColonLoc());
1838 Record
.AddSourceLocation(E
->getTildeLoc());
1840 // PseudoDestructorTypeStorage.
1841 Record
.AddIdentifierRef(E
->getDestroyedTypeIdentifier());
1842 if (E
->getDestroyedTypeIdentifier())
1843 Record
.AddSourceLocation(E
->getDestroyedTypeLoc());
1845 Record
.AddTypeSourceInfo(E
->getDestroyedTypeInfo());
1847 Code
= serialization::EXPR_CXX_PSEUDO_DESTRUCTOR
;
1850 void ASTStmtWriter::VisitExprWithCleanups(ExprWithCleanups
*E
) {
1852 Record
.push_back(E
->getNumObjects());
1853 for (auto &Obj
: E
->getObjects()) {
1854 if (auto *BD
= Obj
.dyn_cast
<BlockDecl
*>()) {
1855 Record
.push_back(serialization::COK_Block
);
1856 Record
.AddDeclRef(BD
);
1857 } else if (auto *CLE
= Obj
.dyn_cast
<CompoundLiteralExpr
*>()) {
1858 Record
.push_back(serialization::COK_CompoundLiteral
);
1859 Record
.AddStmt(CLE
);
1863 Record
.push_back(E
->cleanupsHaveSideEffects());
1864 Record
.AddStmt(E
->getSubExpr());
1865 Code
= serialization::EXPR_EXPR_WITH_CLEANUPS
;
1868 void ASTStmtWriter::VisitCXXDependentScopeMemberExpr(
1869 CXXDependentScopeMemberExpr
*E
) {
1872 // Don't emit anything here (or if you do you will have to update
1873 // the corresponding deserialization function).
1875 Record
.push_back(E
->hasTemplateKWAndArgsInfo());
1876 Record
.push_back(E
->getNumTemplateArgs());
1877 Record
.push_back(E
->hasFirstQualifierFoundInScope());
1879 if (E
->hasTemplateKWAndArgsInfo()) {
1880 const ASTTemplateKWAndArgsInfo
&ArgInfo
=
1881 *E
->getTrailingObjects
<ASTTemplateKWAndArgsInfo
>();
1882 AddTemplateKWAndArgsInfo(ArgInfo
,
1883 E
->getTrailingObjects
<TemplateArgumentLoc
>());
1886 Record
.push_back(E
->isArrow());
1887 Record
.AddSourceLocation(E
->getOperatorLoc());
1888 Record
.AddTypeRef(E
->getBaseType());
1889 Record
.AddNestedNameSpecifierLoc(E
->getQualifierLoc());
1890 if (!E
->isImplicitAccess())
1891 Record
.AddStmt(E
->getBase());
1893 Record
.AddStmt(nullptr);
1895 if (E
->hasFirstQualifierFoundInScope())
1896 Record
.AddDeclRef(E
->getFirstQualifierFoundInScope());
1898 Record
.AddDeclarationNameInfo(E
->MemberNameInfo
);
1899 Code
= serialization::EXPR_CXX_DEPENDENT_SCOPE_MEMBER
;
1903 ASTStmtWriter::VisitDependentScopeDeclRefExpr(DependentScopeDeclRefExpr
*E
) {
1906 // Don't emit anything here, HasTemplateKWAndArgsInfo must be
1909 Record
.push_back(E
->DependentScopeDeclRefExprBits
.HasTemplateKWAndArgsInfo
);
1910 if (E
->DependentScopeDeclRefExprBits
.HasTemplateKWAndArgsInfo
) {
1911 const ASTTemplateKWAndArgsInfo
&ArgInfo
=
1912 *E
->getTrailingObjects
<ASTTemplateKWAndArgsInfo
>();
1913 Record
.push_back(ArgInfo
.NumTemplateArgs
);
1914 AddTemplateKWAndArgsInfo(ArgInfo
,
1915 E
->getTrailingObjects
<TemplateArgumentLoc
>());
1918 Record
.AddNestedNameSpecifierLoc(E
->getQualifierLoc());
1919 Record
.AddDeclarationNameInfo(E
->NameInfo
);
1920 Code
= serialization::EXPR_CXX_DEPENDENT_SCOPE_DECL_REF
;
1924 ASTStmtWriter::VisitCXXUnresolvedConstructExpr(CXXUnresolvedConstructExpr
*E
) {
1926 Record
.push_back(E
->getNumArgs());
1927 for (CXXUnresolvedConstructExpr::arg_iterator
1928 ArgI
= E
->arg_begin(), ArgE
= E
->arg_end(); ArgI
!= ArgE
; ++ArgI
)
1929 Record
.AddStmt(*ArgI
);
1930 Record
.AddTypeSourceInfo(E
->getTypeSourceInfo());
1931 Record
.AddSourceLocation(E
->getLParenLoc());
1932 Record
.AddSourceLocation(E
->getRParenLoc());
1933 Record
.push_back(E
->isListInitialization());
1934 Code
= serialization::EXPR_CXX_UNRESOLVED_CONSTRUCT
;
1937 void ASTStmtWriter::VisitOverloadExpr(OverloadExpr
*E
) {
1940 Record
.push_back(E
->getNumDecls());
1941 Record
.push_back(E
->hasTemplateKWAndArgsInfo());
1942 if (E
->hasTemplateKWAndArgsInfo()) {
1943 const ASTTemplateKWAndArgsInfo
&ArgInfo
=
1944 *E
->getTrailingASTTemplateKWAndArgsInfo();
1945 Record
.push_back(ArgInfo
.NumTemplateArgs
);
1946 AddTemplateKWAndArgsInfo(ArgInfo
, E
->getTrailingTemplateArgumentLoc());
1949 for (OverloadExpr::decls_iterator OvI
= E
->decls_begin(),
1950 OvE
= E
->decls_end();
1951 OvI
!= OvE
; ++OvI
) {
1952 Record
.AddDeclRef(OvI
.getDecl());
1953 Record
.push_back(OvI
.getAccess());
1956 Record
.AddDeclarationNameInfo(E
->getNameInfo());
1957 Record
.AddNestedNameSpecifierLoc(E
->getQualifierLoc());
1960 void ASTStmtWriter::VisitUnresolvedMemberExpr(UnresolvedMemberExpr
*E
) {
1961 VisitOverloadExpr(E
);
1962 Record
.push_back(E
->isArrow());
1963 Record
.push_back(E
->hasUnresolvedUsing());
1964 Record
.AddStmt(!E
->isImplicitAccess() ? E
->getBase() : nullptr);
1965 Record
.AddTypeRef(E
->getBaseType());
1966 Record
.AddSourceLocation(E
->getOperatorLoc());
1967 Code
= serialization::EXPR_CXX_UNRESOLVED_MEMBER
;
1970 void ASTStmtWriter::VisitUnresolvedLookupExpr(UnresolvedLookupExpr
*E
) {
1971 VisitOverloadExpr(E
);
1972 Record
.push_back(E
->requiresADL());
1973 Record
.push_back(E
->isOverloaded());
1974 Record
.AddDeclRef(E
->getNamingClass());
1975 Code
= serialization::EXPR_CXX_UNRESOLVED_LOOKUP
;
1978 void ASTStmtWriter::VisitTypeTraitExpr(TypeTraitExpr
*E
) {
1980 Record
.push_back(E
->TypeTraitExprBits
.NumArgs
);
1981 Record
.push_back(E
->TypeTraitExprBits
.Kind
); // FIXME: Stable encoding
1982 Record
.push_back(E
->TypeTraitExprBits
.Value
);
1983 Record
.AddSourceRange(E
->getSourceRange());
1984 for (unsigned I
= 0, N
= E
->getNumArgs(); I
!= N
; ++I
)
1985 Record
.AddTypeSourceInfo(E
->getArg(I
));
1986 Code
= serialization::EXPR_TYPE_TRAIT
;
1989 void ASTStmtWriter::VisitArrayTypeTraitExpr(ArrayTypeTraitExpr
*E
) {
1991 Record
.push_back(E
->getTrait());
1992 Record
.push_back(E
->getValue());
1993 Record
.AddSourceRange(E
->getSourceRange());
1994 Record
.AddTypeSourceInfo(E
->getQueriedTypeSourceInfo());
1995 Record
.AddStmt(E
->getDimensionExpression());
1996 Code
= serialization::EXPR_ARRAY_TYPE_TRAIT
;
1999 void ASTStmtWriter::VisitExpressionTraitExpr(ExpressionTraitExpr
*E
) {
2001 Record
.push_back(E
->getTrait());
2002 Record
.push_back(E
->getValue());
2003 Record
.AddSourceRange(E
->getSourceRange());
2004 Record
.AddStmt(E
->getQueriedExpression());
2005 Code
= serialization::EXPR_CXX_EXPRESSION_TRAIT
;
2008 void ASTStmtWriter::VisitCXXNoexceptExpr(CXXNoexceptExpr
*E
) {
2010 Record
.push_back(E
->getValue());
2011 Record
.AddSourceRange(E
->getSourceRange());
2012 Record
.AddStmt(E
->getOperand());
2013 Code
= serialization::EXPR_CXX_NOEXCEPT
;
2016 void ASTStmtWriter::VisitPackExpansionExpr(PackExpansionExpr
*E
) {
2018 Record
.AddSourceLocation(E
->getEllipsisLoc());
2019 Record
.push_back(E
->NumExpansions
);
2020 Record
.AddStmt(E
->getPattern());
2021 Code
= serialization::EXPR_PACK_EXPANSION
;
2024 void ASTStmtWriter::VisitSizeOfPackExpr(SizeOfPackExpr
*E
) {
2026 Record
.push_back(E
->isPartiallySubstituted() ? E
->getPartialArguments().size()
2028 Record
.AddSourceLocation(E
->OperatorLoc
);
2029 Record
.AddSourceLocation(E
->PackLoc
);
2030 Record
.AddSourceLocation(E
->RParenLoc
);
2031 Record
.AddDeclRef(E
->Pack
);
2032 if (E
->isPartiallySubstituted()) {
2033 for (const auto &TA
: E
->getPartialArguments())
2034 Record
.AddTemplateArgument(TA
);
2035 } else if (!E
->isValueDependent()) {
2036 Record
.push_back(E
->getPackLength());
2038 Code
= serialization::EXPR_SIZEOF_PACK
;
2041 void ASTStmtWriter::VisitSubstNonTypeTemplateParmExpr(
2042 SubstNonTypeTemplateParmExpr
*E
) {
2044 Record
.AddDeclRef(E
->getAssociatedDecl());
2045 Record
.push_back(E
->isReferenceParameter());
2046 Record
.push_back(E
->getIndex());
2047 if (auto PackIndex
= E
->getPackIndex())
2048 Record
.push_back(*PackIndex
+ 1);
2050 Record
.push_back(0);
2051 Record
.AddSourceLocation(E
->getNameLoc());
2052 Record
.AddStmt(E
->getReplacement());
2053 Code
= serialization::EXPR_SUBST_NON_TYPE_TEMPLATE_PARM
;
2056 void ASTStmtWriter::VisitSubstNonTypeTemplateParmPackExpr(
2057 SubstNonTypeTemplateParmPackExpr
*E
) {
2059 Record
.AddDeclRef(E
->getAssociatedDecl());
2060 Record
.push_back(E
->getIndex());
2061 Record
.AddTemplateArgument(E
->getArgumentPack());
2062 Record
.AddSourceLocation(E
->getParameterPackLocation());
2063 Code
= serialization::EXPR_SUBST_NON_TYPE_TEMPLATE_PARM_PACK
;
2066 void ASTStmtWriter::VisitFunctionParmPackExpr(FunctionParmPackExpr
*E
) {
2068 Record
.push_back(E
->getNumExpansions());
2069 Record
.AddDeclRef(E
->getParameterPack());
2070 Record
.AddSourceLocation(E
->getParameterPackLocation());
2071 for (FunctionParmPackExpr::iterator I
= E
->begin(), End
= E
->end();
2073 Record
.AddDeclRef(*I
);
2074 Code
= serialization::EXPR_FUNCTION_PARM_PACK
;
2077 void ASTStmtWriter::VisitMaterializeTemporaryExpr(MaterializeTemporaryExpr
*E
) {
2079 Record
.push_back(static_cast<bool>(E
->getLifetimeExtendedTemporaryDecl()));
2080 if (E
->getLifetimeExtendedTemporaryDecl())
2081 Record
.AddDeclRef(E
->getLifetimeExtendedTemporaryDecl());
2083 Record
.AddStmt(E
->getSubExpr());
2084 Code
= serialization::EXPR_MATERIALIZE_TEMPORARY
;
2087 void ASTStmtWriter::VisitCXXFoldExpr(CXXFoldExpr
*E
) {
2089 Record
.AddSourceLocation(E
->LParenLoc
);
2090 Record
.AddSourceLocation(E
->EllipsisLoc
);
2091 Record
.AddSourceLocation(E
->RParenLoc
);
2092 Record
.push_back(E
->NumExpansions
);
2093 Record
.AddStmt(E
->SubExprs
[0]);
2094 Record
.AddStmt(E
->SubExprs
[1]);
2095 Record
.AddStmt(E
->SubExprs
[2]);
2096 Record
.push_back(E
->Opcode
);
2097 Code
= serialization::EXPR_CXX_FOLD
;
2100 void ASTStmtWriter::VisitCXXParenListInitExpr(CXXParenListInitExpr
*E
) {
2102 ArrayRef
<Expr
*> InitExprs
= E
->getInitExprs();
2103 Record
.push_back(InitExprs
.size());
2104 Record
.push_back(E
->getUserSpecifiedInitExprs().size());
2105 Record
.AddSourceLocation(E
->getInitLoc());
2106 Record
.AddSourceLocation(E
->getBeginLoc());
2107 Record
.AddSourceLocation(E
->getEndLoc());
2108 for (Expr
*InitExpr
: E
->getInitExprs())
2109 Record
.AddStmt(InitExpr
);
2110 Expr
*ArrayFiller
= E
->getArrayFiller();
2111 FieldDecl
*UnionField
= E
->getInitializedFieldInUnion();
2112 bool HasArrayFillerOrUnionDecl
= ArrayFiller
|| UnionField
;
2113 Record
.push_back(HasArrayFillerOrUnionDecl
);
2114 if (HasArrayFillerOrUnionDecl
) {
2115 Record
.push_back(static_cast<bool>(ArrayFiller
));
2117 Record
.AddStmt(ArrayFiller
);
2119 Record
.AddDeclRef(UnionField
);
2121 Code
= serialization::EXPR_CXX_PAREN_LIST_INIT
;
2124 void ASTStmtWriter::VisitOpaqueValueExpr(OpaqueValueExpr
*E
) {
2126 Record
.AddStmt(E
->getSourceExpr());
2127 Record
.AddSourceLocation(E
->getLocation());
2128 Record
.push_back(E
->isUnique());
2129 Code
= serialization::EXPR_OPAQUE_VALUE
;
2132 void ASTStmtWriter::VisitTypoExpr(TypoExpr
*E
) {
2134 // TODO: Figure out sane writer behavior for a TypoExpr, if necessary
2135 llvm_unreachable("Cannot write TypoExpr nodes");
2138 //===----------------------------------------------------------------------===//
2139 // CUDA Expressions and Statements.
2140 //===----------------------------------------------------------------------===//
2142 void ASTStmtWriter::VisitCUDAKernelCallExpr(CUDAKernelCallExpr
*E
) {
2144 Record
.AddStmt(E
->getConfig());
2145 Code
= serialization::EXPR_CUDA_KERNEL_CALL
;
2148 //===----------------------------------------------------------------------===//
2149 // OpenCL Expressions and Statements.
2150 //===----------------------------------------------------------------------===//
2151 void ASTStmtWriter::VisitAsTypeExpr(AsTypeExpr
*E
) {
2153 Record
.AddSourceLocation(E
->getBuiltinLoc());
2154 Record
.AddSourceLocation(E
->getRParenLoc());
2155 Record
.AddStmt(E
->getSrcExpr());
2156 Code
= serialization::EXPR_ASTYPE
;
2159 //===----------------------------------------------------------------------===//
2160 // Microsoft Expressions and Statements.
2161 //===----------------------------------------------------------------------===//
2162 void ASTStmtWriter::VisitMSPropertyRefExpr(MSPropertyRefExpr
*E
) {
2164 Record
.push_back(E
->isArrow());
2165 Record
.AddStmt(E
->getBaseExpr());
2166 Record
.AddNestedNameSpecifierLoc(E
->getQualifierLoc());
2167 Record
.AddSourceLocation(E
->getMemberLoc());
2168 Record
.AddDeclRef(E
->getPropertyDecl());
2169 Code
= serialization::EXPR_CXX_PROPERTY_REF_EXPR
;
2172 void ASTStmtWriter::VisitMSPropertySubscriptExpr(MSPropertySubscriptExpr
*E
) {
2174 Record
.AddStmt(E
->getBase());
2175 Record
.AddStmt(E
->getIdx());
2176 Record
.AddSourceLocation(E
->getRBracketLoc());
2177 Code
= serialization::EXPR_CXX_PROPERTY_SUBSCRIPT_EXPR
;
2180 void ASTStmtWriter::VisitCXXUuidofExpr(CXXUuidofExpr
*E
) {
2182 Record
.AddSourceRange(E
->getSourceRange());
2183 Record
.AddDeclRef(E
->getGuidDecl());
2184 if (E
->isTypeOperand()) {
2185 Record
.AddTypeSourceInfo(E
->getTypeOperandSourceInfo());
2186 Code
= serialization::EXPR_CXX_UUIDOF_TYPE
;
2188 Record
.AddStmt(E
->getExprOperand());
2189 Code
= serialization::EXPR_CXX_UUIDOF_EXPR
;
2193 void ASTStmtWriter::VisitSEHExceptStmt(SEHExceptStmt
*S
) {
2195 Record
.AddSourceLocation(S
->getExceptLoc());
2196 Record
.AddStmt(S
->getFilterExpr());
2197 Record
.AddStmt(S
->getBlock());
2198 Code
= serialization::STMT_SEH_EXCEPT
;
2201 void ASTStmtWriter::VisitSEHFinallyStmt(SEHFinallyStmt
*S
) {
2203 Record
.AddSourceLocation(S
->getFinallyLoc());
2204 Record
.AddStmt(S
->getBlock());
2205 Code
= serialization::STMT_SEH_FINALLY
;
2208 void ASTStmtWriter::VisitSEHTryStmt(SEHTryStmt
*S
) {
2210 Record
.push_back(S
->getIsCXXTry());
2211 Record
.AddSourceLocation(S
->getTryLoc());
2212 Record
.AddStmt(S
->getTryBlock());
2213 Record
.AddStmt(S
->getHandler());
2214 Code
= serialization::STMT_SEH_TRY
;
2217 void ASTStmtWriter::VisitSEHLeaveStmt(SEHLeaveStmt
*S
) {
2219 Record
.AddSourceLocation(S
->getLeaveLoc());
2220 Code
= serialization::STMT_SEH_LEAVE
;
2223 //===----------------------------------------------------------------------===//
2224 // OpenMP Directives.
2225 //===----------------------------------------------------------------------===//
2227 void ASTStmtWriter::VisitOMPCanonicalLoop(OMPCanonicalLoop
*S
) {
2229 for (Stmt
*SubStmt
: S
->SubStmts
)
2230 Record
.AddStmt(SubStmt
);
2231 Code
= serialization::STMT_OMP_CANONICAL_LOOP
;
2234 void ASTStmtWriter::VisitOMPExecutableDirective(OMPExecutableDirective
*E
) {
2235 Record
.writeOMPChildren(E
->Data
);
2236 Record
.AddSourceLocation(E
->getBeginLoc());
2237 Record
.AddSourceLocation(E
->getEndLoc());
2240 void ASTStmtWriter::VisitOMPLoopBasedDirective(OMPLoopBasedDirective
*D
) {
2242 Record
.writeUInt32(D
->getLoopsNumber());
2243 VisitOMPExecutableDirective(D
);
2246 void ASTStmtWriter::VisitOMPLoopDirective(OMPLoopDirective
*D
) {
2247 VisitOMPLoopBasedDirective(D
);
2250 void ASTStmtWriter::VisitOMPMetaDirective(OMPMetaDirective
*D
) {
2252 Record
.push_back(D
->getNumClauses());
2253 VisitOMPExecutableDirective(D
);
2254 Code
= serialization::STMT_OMP_META_DIRECTIVE
;
2257 void ASTStmtWriter::VisitOMPParallelDirective(OMPParallelDirective
*D
) {
2259 VisitOMPExecutableDirective(D
);
2260 Record
.writeBool(D
->hasCancel());
2261 Code
= serialization::STMT_OMP_PARALLEL_DIRECTIVE
;
2264 void ASTStmtWriter::VisitOMPSimdDirective(OMPSimdDirective
*D
) {
2265 VisitOMPLoopDirective(D
);
2266 Code
= serialization::STMT_OMP_SIMD_DIRECTIVE
;
2269 void ASTStmtWriter::VisitOMPLoopTransformationDirective(
2270 OMPLoopTransformationDirective
*D
) {
2271 VisitOMPLoopBasedDirective(D
);
2272 Record
.writeUInt32(D
->getNumGeneratedLoops());
2275 void ASTStmtWriter::VisitOMPTileDirective(OMPTileDirective
*D
) {
2276 VisitOMPLoopTransformationDirective(D
);
2277 Code
= serialization::STMT_OMP_TILE_DIRECTIVE
;
2280 void ASTStmtWriter::VisitOMPUnrollDirective(OMPUnrollDirective
*D
) {
2281 VisitOMPLoopTransformationDirective(D
);
2282 Code
= serialization::STMT_OMP_UNROLL_DIRECTIVE
;
2285 void ASTStmtWriter::VisitOMPForDirective(OMPForDirective
*D
) {
2286 VisitOMPLoopDirective(D
);
2287 Record
.writeBool(D
->hasCancel());
2288 Code
= serialization::STMT_OMP_FOR_DIRECTIVE
;
2291 void ASTStmtWriter::VisitOMPForSimdDirective(OMPForSimdDirective
*D
) {
2292 VisitOMPLoopDirective(D
);
2293 Code
= serialization::STMT_OMP_FOR_SIMD_DIRECTIVE
;
2296 void ASTStmtWriter::VisitOMPSectionsDirective(OMPSectionsDirective
*D
) {
2298 VisitOMPExecutableDirective(D
);
2299 Record
.writeBool(D
->hasCancel());
2300 Code
= serialization::STMT_OMP_SECTIONS_DIRECTIVE
;
2303 void ASTStmtWriter::VisitOMPSectionDirective(OMPSectionDirective
*D
) {
2305 VisitOMPExecutableDirective(D
);
2306 Record
.writeBool(D
->hasCancel());
2307 Code
= serialization::STMT_OMP_SECTION_DIRECTIVE
;
2310 void ASTStmtWriter::VisitOMPSingleDirective(OMPSingleDirective
*D
) {
2312 VisitOMPExecutableDirective(D
);
2313 Code
= serialization::STMT_OMP_SINGLE_DIRECTIVE
;
2316 void ASTStmtWriter::VisitOMPMasterDirective(OMPMasterDirective
*D
) {
2318 VisitOMPExecutableDirective(D
);
2319 Code
= serialization::STMT_OMP_MASTER_DIRECTIVE
;
2322 void ASTStmtWriter::VisitOMPCriticalDirective(OMPCriticalDirective
*D
) {
2324 VisitOMPExecutableDirective(D
);
2325 Record
.AddDeclarationNameInfo(D
->getDirectiveName());
2326 Code
= serialization::STMT_OMP_CRITICAL_DIRECTIVE
;
2329 void ASTStmtWriter::VisitOMPParallelForDirective(OMPParallelForDirective
*D
) {
2330 VisitOMPLoopDirective(D
);
2331 Record
.writeBool(D
->hasCancel());
2332 Code
= serialization::STMT_OMP_PARALLEL_FOR_DIRECTIVE
;
2335 void ASTStmtWriter::VisitOMPParallelForSimdDirective(
2336 OMPParallelForSimdDirective
*D
) {
2337 VisitOMPLoopDirective(D
);
2338 Code
= serialization::STMT_OMP_PARALLEL_FOR_SIMD_DIRECTIVE
;
2341 void ASTStmtWriter::VisitOMPParallelMasterDirective(
2342 OMPParallelMasterDirective
*D
) {
2344 VisitOMPExecutableDirective(D
);
2345 Code
= serialization::STMT_OMP_PARALLEL_MASTER_DIRECTIVE
;
2348 void ASTStmtWriter::VisitOMPParallelMaskedDirective(
2349 OMPParallelMaskedDirective
*D
) {
2351 VisitOMPExecutableDirective(D
);
2352 Code
= serialization::STMT_OMP_PARALLEL_MASKED_DIRECTIVE
;
2355 void ASTStmtWriter::VisitOMPParallelSectionsDirective(
2356 OMPParallelSectionsDirective
*D
) {
2358 VisitOMPExecutableDirective(D
);
2359 Record
.writeBool(D
->hasCancel());
2360 Code
= serialization::STMT_OMP_PARALLEL_SECTIONS_DIRECTIVE
;
2363 void ASTStmtWriter::VisitOMPTaskDirective(OMPTaskDirective
*D
) {
2365 VisitOMPExecutableDirective(D
);
2366 Record
.writeBool(D
->hasCancel());
2367 Code
= serialization::STMT_OMP_TASK_DIRECTIVE
;
2370 void ASTStmtWriter::VisitOMPAtomicDirective(OMPAtomicDirective
*D
) {
2372 VisitOMPExecutableDirective(D
);
2373 Record
.writeBool(D
->isXLHSInRHSPart());
2374 Record
.writeBool(D
->isPostfixUpdate());
2375 Record
.writeBool(D
->isFailOnly());
2376 Code
= serialization::STMT_OMP_ATOMIC_DIRECTIVE
;
2379 void ASTStmtWriter::VisitOMPTargetDirective(OMPTargetDirective
*D
) {
2381 VisitOMPExecutableDirective(D
);
2382 Code
= serialization::STMT_OMP_TARGET_DIRECTIVE
;
2385 void ASTStmtWriter::VisitOMPTargetDataDirective(OMPTargetDataDirective
*D
) {
2387 VisitOMPExecutableDirective(D
);
2388 Code
= serialization::STMT_OMP_TARGET_DATA_DIRECTIVE
;
2391 void ASTStmtWriter::VisitOMPTargetEnterDataDirective(
2392 OMPTargetEnterDataDirective
*D
) {
2394 VisitOMPExecutableDirective(D
);
2395 Code
= serialization::STMT_OMP_TARGET_ENTER_DATA_DIRECTIVE
;
2398 void ASTStmtWriter::VisitOMPTargetExitDataDirective(
2399 OMPTargetExitDataDirective
*D
) {
2401 VisitOMPExecutableDirective(D
);
2402 Code
= serialization::STMT_OMP_TARGET_EXIT_DATA_DIRECTIVE
;
2405 void ASTStmtWriter::VisitOMPTargetParallelDirective(
2406 OMPTargetParallelDirective
*D
) {
2408 VisitOMPExecutableDirective(D
);
2409 Record
.writeBool(D
->hasCancel());
2410 Code
= serialization::STMT_OMP_TARGET_PARALLEL_DIRECTIVE
;
2413 void ASTStmtWriter::VisitOMPTargetParallelForDirective(
2414 OMPTargetParallelForDirective
*D
) {
2415 VisitOMPLoopDirective(D
);
2416 Record
.writeBool(D
->hasCancel());
2417 Code
= serialization::STMT_OMP_TARGET_PARALLEL_FOR_DIRECTIVE
;
2420 void ASTStmtWriter::VisitOMPTaskyieldDirective(OMPTaskyieldDirective
*D
) {
2422 VisitOMPExecutableDirective(D
);
2423 Code
= serialization::STMT_OMP_TASKYIELD_DIRECTIVE
;
2426 void ASTStmtWriter::VisitOMPBarrierDirective(OMPBarrierDirective
*D
) {
2428 VisitOMPExecutableDirective(D
);
2429 Code
= serialization::STMT_OMP_BARRIER_DIRECTIVE
;
2432 void ASTStmtWriter::VisitOMPTaskwaitDirective(OMPTaskwaitDirective
*D
) {
2434 Record
.push_back(D
->getNumClauses());
2435 VisitOMPExecutableDirective(D
);
2436 Code
= serialization::STMT_OMP_TASKWAIT_DIRECTIVE
;
2439 void ASTStmtWriter::VisitOMPErrorDirective(OMPErrorDirective
*D
) {
2441 Record
.push_back(D
->getNumClauses());
2442 VisitOMPExecutableDirective(D
);
2443 Code
= serialization::STMT_OMP_ERROR_DIRECTIVE
;
2446 void ASTStmtWriter::VisitOMPTaskgroupDirective(OMPTaskgroupDirective
*D
) {
2448 VisitOMPExecutableDirective(D
);
2449 Code
= serialization::STMT_OMP_TASKGROUP_DIRECTIVE
;
2452 void ASTStmtWriter::VisitOMPFlushDirective(OMPFlushDirective
*D
) {
2454 VisitOMPExecutableDirective(D
);
2455 Code
= serialization::STMT_OMP_FLUSH_DIRECTIVE
;
2458 void ASTStmtWriter::VisitOMPDepobjDirective(OMPDepobjDirective
*D
) {
2460 VisitOMPExecutableDirective(D
);
2461 Code
= serialization::STMT_OMP_DEPOBJ_DIRECTIVE
;
2464 void ASTStmtWriter::VisitOMPScanDirective(OMPScanDirective
*D
) {
2466 VisitOMPExecutableDirective(D
);
2467 Code
= serialization::STMT_OMP_SCAN_DIRECTIVE
;
2470 void ASTStmtWriter::VisitOMPOrderedDirective(OMPOrderedDirective
*D
) {
2472 VisitOMPExecutableDirective(D
);
2473 Code
= serialization::STMT_OMP_ORDERED_DIRECTIVE
;
2476 void ASTStmtWriter::VisitOMPTeamsDirective(OMPTeamsDirective
*D
) {
2478 VisitOMPExecutableDirective(D
);
2479 Code
= serialization::STMT_OMP_TEAMS_DIRECTIVE
;
2482 void ASTStmtWriter::VisitOMPCancellationPointDirective(
2483 OMPCancellationPointDirective
*D
) {
2485 VisitOMPExecutableDirective(D
);
2486 Record
.writeEnum(D
->getCancelRegion());
2487 Code
= serialization::STMT_OMP_CANCELLATION_POINT_DIRECTIVE
;
2490 void ASTStmtWriter::VisitOMPCancelDirective(OMPCancelDirective
*D
) {
2492 VisitOMPExecutableDirective(D
);
2493 Record
.writeEnum(D
->getCancelRegion());
2494 Code
= serialization::STMT_OMP_CANCEL_DIRECTIVE
;
2497 void ASTStmtWriter::VisitOMPTaskLoopDirective(OMPTaskLoopDirective
*D
) {
2498 VisitOMPLoopDirective(D
);
2499 Record
.writeBool(D
->hasCancel());
2500 Code
= serialization::STMT_OMP_TASKLOOP_DIRECTIVE
;
2503 void ASTStmtWriter::VisitOMPTaskLoopSimdDirective(OMPTaskLoopSimdDirective
*D
) {
2504 VisitOMPLoopDirective(D
);
2505 Code
= serialization::STMT_OMP_TASKLOOP_SIMD_DIRECTIVE
;
2508 void ASTStmtWriter::VisitOMPMasterTaskLoopDirective(
2509 OMPMasterTaskLoopDirective
*D
) {
2510 VisitOMPLoopDirective(D
);
2511 Record
.writeBool(D
->hasCancel());
2512 Code
= serialization::STMT_OMP_MASTER_TASKLOOP_DIRECTIVE
;
2515 void ASTStmtWriter::VisitOMPMaskedTaskLoopDirective(
2516 OMPMaskedTaskLoopDirective
*D
) {
2517 VisitOMPLoopDirective(D
);
2518 Record
.writeBool(D
->hasCancel());
2519 Code
= serialization::STMT_OMP_MASKED_TASKLOOP_DIRECTIVE
;
2522 void ASTStmtWriter::VisitOMPMasterTaskLoopSimdDirective(
2523 OMPMasterTaskLoopSimdDirective
*D
) {
2524 VisitOMPLoopDirective(D
);
2525 Code
= serialization::STMT_OMP_MASTER_TASKLOOP_SIMD_DIRECTIVE
;
2528 void ASTStmtWriter::VisitOMPMaskedTaskLoopSimdDirective(
2529 OMPMaskedTaskLoopSimdDirective
*D
) {
2530 VisitOMPLoopDirective(D
);
2531 Code
= serialization::STMT_OMP_MASKED_TASKLOOP_SIMD_DIRECTIVE
;
2534 void ASTStmtWriter::VisitOMPParallelMasterTaskLoopDirective(
2535 OMPParallelMasterTaskLoopDirective
*D
) {
2536 VisitOMPLoopDirective(D
);
2537 Record
.writeBool(D
->hasCancel());
2538 Code
= serialization::STMT_OMP_PARALLEL_MASTER_TASKLOOP_DIRECTIVE
;
2541 void ASTStmtWriter::VisitOMPParallelMaskedTaskLoopDirective(
2542 OMPParallelMaskedTaskLoopDirective
*D
) {
2543 VisitOMPLoopDirective(D
);
2544 Record
.writeBool(D
->hasCancel());
2545 Code
= serialization::STMT_OMP_PARALLEL_MASKED_TASKLOOP_DIRECTIVE
;
2548 void ASTStmtWriter::VisitOMPParallelMasterTaskLoopSimdDirective(
2549 OMPParallelMasterTaskLoopSimdDirective
*D
) {
2550 VisitOMPLoopDirective(D
);
2551 Code
= serialization::STMT_OMP_PARALLEL_MASTER_TASKLOOP_SIMD_DIRECTIVE
;
2554 void ASTStmtWriter::VisitOMPParallelMaskedTaskLoopSimdDirective(
2555 OMPParallelMaskedTaskLoopSimdDirective
*D
) {
2556 VisitOMPLoopDirective(D
);
2557 Code
= serialization::STMT_OMP_PARALLEL_MASKED_TASKLOOP_SIMD_DIRECTIVE
;
2560 void ASTStmtWriter::VisitOMPDistributeDirective(OMPDistributeDirective
*D
) {
2561 VisitOMPLoopDirective(D
);
2562 Code
= serialization::STMT_OMP_DISTRIBUTE_DIRECTIVE
;
2565 void ASTStmtWriter::VisitOMPTargetUpdateDirective(OMPTargetUpdateDirective
*D
) {
2567 VisitOMPExecutableDirective(D
);
2568 Code
= serialization::STMT_OMP_TARGET_UPDATE_DIRECTIVE
;
2571 void ASTStmtWriter::VisitOMPDistributeParallelForDirective(
2572 OMPDistributeParallelForDirective
*D
) {
2573 VisitOMPLoopDirective(D
);
2574 Record
.writeBool(D
->hasCancel());
2575 Code
= serialization::STMT_OMP_DISTRIBUTE_PARALLEL_FOR_DIRECTIVE
;
2578 void ASTStmtWriter::VisitOMPDistributeParallelForSimdDirective(
2579 OMPDistributeParallelForSimdDirective
*D
) {
2580 VisitOMPLoopDirective(D
);
2581 Code
= serialization::STMT_OMP_DISTRIBUTE_PARALLEL_FOR_SIMD_DIRECTIVE
;
2584 void ASTStmtWriter::VisitOMPDistributeSimdDirective(
2585 OMPDistributeSimdDirective
*D
) {
2586 VisitOMPLoopDirective(D
);
2587 Code
= serialization::STMT_OMP_DISTRIBUTE_SIMD_DIRECTIVE
;
2590 void ASTStmtWriter::VisitOMPTargetParallelForSimdDirective(
2591 OMPTargetParallelForSimdDirective
*D
) {
2592 VisitOMPLoopDirective(D
);
2593 Code
= serialization::STMT_OMP_TARGET_PARALLEL_FOR_SIMD_DIRECTIVE
;
2596 void ASTStmtWriter::VisitOMPTargetSimdDirective(OMPTargetSimdDirective
*D
) {
2597 VisitOMPLoopDirective(D
);
2598 Code
= serialization::STMT_OMP_TARGET_SIMD_DIRECTIVE
;
2601 void ASTStmtWriter::VisitOMPTeamsDistributeDirective(
2602 OMPTeamsDistributeDirective
*D
) {
2603 VisitOMPLoopDirective(D
);
2604 Code
= serialization::STMT_OMP_TEAMS_DISTRIBUTE_DIRECTIVE
;
2607 void ASTStmtWriter::VisitOMPTeamsDistributeSimdDirective(
2608 OMPTeamsDistributeSimdDirective
*D
) {
2609 VisitOMPLoopDirective(D
);
2610 Code
= serialization::STMT_OMP_TEAMS_DISTRIBUTE_SIMD_DIRECTIVE
;
2613 void ASTStmtWriter::VisitOMPTeamsDistributeParallelForSimdDirective(
2614 OMPTeamsDistributeParallelForSimdDirective
*D
) {
2615 VisitOMPLoopDirective(D
);
2616 Code
= serialization::STMT_OMP_TEAMS_DISTRIBUTE_PARALLEL_FOR_SIMD_DIRECTIVE
;
2619 void ASTStmtWriter::VisitOMPTeamsDistributeParallelForDirective(
2620 OMPTeamsDistributeParallelForDirective
*D
) {
2621 VisitOMPLoopDirective(D
);
2622 Record
.writeBool(D
->hasCancel());
2623 Code
= serialization::STMT_OMP_TEAMS_DISTRIBUTE_PARALLEL_FOR_DIRECTIVE
;
2626 void ASTStmtWriter::VisitOMPTargetTeamsDirective(OMPTargetTeamsDirective
*D
) {
2628 VisitOMPExecutableDirective(D
);
2629 Code
= serialization::STMT_OMP_TARGET_TEAMS_DIRECTIVE
;
2632 void ASTStmtWriter::VisitOMPTargetTeamsDistributeDirective(
2633 OMPTargetTeamsDistributeDirective
*D
) {
2634 VisitOMPLoopDirective(D
);
2635 Code
= serialization::STMT_OMP_TARGET_TEAMS_DISTRIBUTE_DIRECTIVE
;
2638 void ASTStmtWriter::VisitOMPTargetTeamsDistributeParallelForDirective(
2639 OMPTargetTeamsDistributeParallelForDirective
*D
) {
2640 VisitOMPLoopDirective(D
);
2641 Record
.writeBool(D
->hasCancel());
2642 Code
= serialization::STMT_OMP_TARGET_TEAMS_DISTRIBUTE_PARALLEL_FOR_DIRECTIVE
;
2645 void ASTStmtWriter::VisitOMPTargetTeamsDistributeParallelForSimdDirective(
2646 OMPTargetTeamsDistributeParallelForSimdDirective
*D
) {
2647 VisitOMPLoopDirective(D
);
2648 Code
= serialization::
2649 STMT_OMP_TARGET_TEAMS_DISTRIBUTE_PARALLEL_FOR_SIMD_DIRECTIVE
;
2652 void ASTStmtWriter::VisitOMPTargetTeamsDistributeSimdDirective(
2653 OMPTargetTeamsDistributeSimdDirective
*D
) {
2654 VisitOMPLoopDirective(D
);
2655 Code
= serialization::STMT_OMP_TARGET_TEAMS_DISTRIBUTE_SIMD_DIRECTIVE
;
2658 void ASTStmtWriter::VisitOMPInteropDirective(OMPInteropDirective
*D
) {
2660 VisitOMPExecutableDirective(D
);
2661 Code
= serialization::STMT_OMP_INTEROP_DIRECTIVE
;
2664 void ASTStmtWriter::VisitOMPDispatchDirective(OMPDispatchDirective
*D
) {
2666 VisitOMPExecutableDirective(D
);
2667 Record
.AddSourceLocation(D
->getTargetCallLoc());
2668 Code
= serialization::STMT_OMP_DISPATCH_DIRECTIVE
;
2671 void ASTStmtWriter::VisitOMPMaskedDirective(OMPMaskedDirective
*D
) {
2673 VisitOMPExecutableDirective(D
);
2674 Code
= serialization::STMT_OMP_MASKED_DIRECTIVE
;
2677 void ASTStmtWriter::VisitOMPGenericLoopDirective(OMPGenericLoopDirective
*D
) {
2678 VisitOMPLoopDirective(D
);
2679 Code
= serialization::STMT_OMP_GENERIC_LOOP_DIRECTIVE
;
2682 void ASTStmtWriter::VisitOMPTeamsGenericLoopDirective(
2683 OMPTeamsGenericLoopDirective
*D
) {
2684 VisitOMPLoopDirective(D
);
2685 Code
= serialization::STMT_OMP_TEAMS_GENERIC_LOOP_DIRECTIVE
;
2688 void ASTStmtWriter::VisitOMPTargetTeamsGenericLoopDirective(
2689 OMPTargetTeamsGenericLoopDirective
*D
) {
2690 VisitOMPLoopDirective(D
);
2691 Code
= serialization::STMT_OMP_TARGET_TEAMS_GENERIC_LOOP_DIRECTIVE
;
2694 void ASTStmtWriter::VisitOMPParallelGenericLoopDirective(
2695 OMPParallelGenericLoopDirective
*D
) {
2696 VisitOMPLoopDirective(D
);
2697 Code
= serialization::STMT_OMP_PARALLEL_GENERIC_LOOP_DIRECTIVE
;
2700 void ASTStmtWriter::VisitOMPTargetParallelGenericLoopDirective(
2701 OMPTargetParallelGenericLoopDirective
*D
) {
2702 VisitOMPLoopDirective(D
);
2703 Code
= serialization::STMT_OMP_TARGET_PARALLEL_GENERIC_LOOP_DIRECTIVE
;
2706 //===----------------------------------------------------------------------===//
2707 // ASTWriter Implementation
2708 //===----------------------------------------------------------------------===//
2710 unsigned ASTWriter::RecordSwitchCaseID(SwitchCase
*S
) {
2711 assert(!SwitchCaseIDs
.contains(S
) && "SwitchCase recorded twice");
2712 unsigned NextID
= SwitchCaseIDs
.size();
2713 SwitchCaseIDs
[S
] = NextID
;
2717 unsigned ASTWriter::getSwitchCaseID(SwitchCase
*S
) {
2718 assert(SwitchCaseIDs
.contains(S
) && "SwitchCase hasn't been seen yet");
2719 return SwitchCaseIDs
[S
];
2722 void ASTWriter::ClearSwitchCaseIDs() {
2723 SwitchCaseIDs
.clear();
2726 /// Write the given substatement or subexpression to the
2728 void ASTWriter::WriteSubStmt(Stmt
*S
) {
2730 ASTStmtWriter
Writer(*this, Record
);
2734 Stream
.EmitRecord(serialization::STMT_NULL_PTR
, Record
);
2738 llvm::DenseMap
<Stmt
*, uint64_t>::iterator I
= SubStmtEntries
.find(S
);
2739 if (I
!= SubStmtEntries
.end()) {
2740 Record
.push_back(I
->second
);
2741 Stream
.EmitRecord(serialization::STMT_REF_PTR
, Record
);
2746 assert(!ParentStmts
.count(S
) && "There is a Stmt cycle!");
2748 struct ParentStmtInserterRAII
{
2750 llvm::DenseSet
<Stmt
*> &ParentStmts
;
2752 ParentStmtInserterRAII(Stmt
*S
, llvm::DenseSet
<Stmt
*> &ParentStmts
)
2753 : S(S
), ParentStmts(ParentStmts
) {
2754 ParentStmts
.insert(S
);
2756 ~ParentStmtInserterRAII() {
2757 ParentStmts
.erase(S
);
2761 ParentStmtInserterRAII
ParentStmtInserter(S
, ParentStmts
);
2766 uint64_t Offset
= Writer
.Emit();
2767 SubStmtEntries
[S
] = Offset
;
2770 /// Flush all of the statements that have been added to the
2771 /// queue via AddStmt().
2772 void ASTRecordWriter::FlushStmts() {
2773 // We expect to be the only consumer of the two temporary statement maps,
2774 // assert that they are empty.
2775 assert(Writer
->SubStmtEntries
.empty() && "unexpected entries in sub-stmt map");
2776 assert(Writer
->ParentStmts
.empty() && "unexpected entries in parent stmt map");
2778 for (unsigned I
= 0, N
= StmtsToEmit
.size(); I
!= N
; ++I
) {
2779 Writer
->WriteSubStmt(StmtsToEmit
[I
]);
2781 assert(N
== StmtsToEmit
.size() && "record modified while being written!");
2783 // Note that we are at the end of a full expression. Any
2784 // expression records that follow this one are part of a different
2786 Writer
->Stream
.EmitRecord(serialization::STMT_STOP
, ArrayRef
<uint32_t>());
2788 Writer
->SubStmtEntries
.clear();
2789 Writer
->ParentStmts
.clear();
2792 StmtsToEmit
.clear();
2795 void ASTRecordWriter::FlushSubStmts() {
2796 // For a nested statement, write out the substatements in reverse order (so
2797 // that a simple stack machine can be used when loading), and don't emit a
2798 // STMT_STOP after each one.
2799 for (unsigned I
= 0, N
= StmtsToEmit
.size(); I
!= N
; ++I
) {
2800 Writer
->WriteSubStmt(StmtsToEmit
[N
- I
- 1]);
2801 assert(N
== StmtsToEmit
.size() && "record modified while being written!");
2804 StmtsToEmit
.clear();