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/ASTConcept.h"
15 #include "clang/AST/ASTContext.h"
16 #include "clang/AST/DeclCXX.h"
17 #include "clang/AST/DeclObjC.h"
18 #include "clang/AST/DeclTemplate.h"
19 #include "clang/AST/ExprOpenMP.h"
20 #include "clang/AST/StmtVisitor.h"
21 #include "clang/Lex/Token.h"
22 #include "clang/Sema/DeclSpec.h"
23 #include "clang/Serialization/ASTRecordWriter.h"
24 #include "llvm/Bitstream/BitstreamWriter.h"
25 using namespace clang
;
27 //===----------------------------------------------------------------------===//
28 // Statement/expression serialization
29 //===----------------------------------------------------------------------===//
33 class ASTStmtWriter
: public StmtVisitor
<ASTStmtWriter
, void> {
35 ASTRecordWriter Record
;
37 serialization::StmtCode Code
;
41 ASTStmtWriter(ASTWriter
&Writer
, ASTWriter::RecordData
&Record
)
42 : Writer(Writer
), Record(Writer
, Record
),
43 Code(serialization::STMT_NULL_PTR
), AbbrevToUse(0) {}
45 ASTStmtWriter(const ASTStmtWriter
&) = delete;
46 ASTStmtWriter
&operator=(const ASTStmtWriter
&) = delete;
49 assert(Code
!= serialization::STMT_NULL_PTR
&&
50 "unhandled sub-statement writing AST file");
51 return Record
.EmitStmt(Code
, AbbrevToUse
);
54 void AddTemplateKWAndArgsInfo(const ASTTemplateKWAndArgsInfo
&ArgInfo
,
55 const TemplateArgumentLoc
*Args
);
57 void VisitStmt(Stmt
*S
);
58 #define STMT(Type, Base) \
59 void Visit##Type(Type *);
60 #include "clang/AST/StmtNodes.inc"
64 void ASTStmtWriter::AddTemplateKWAndArgsInfo(
65 const ASTTemplateKWAndArgsInfo
&ArgInfo
, const TemplateArgumentLoc
*Args
) {
66 Record
.AddSourceLocation(ArgInfo
.TemplateKWLoc
);
67 Record
.AddSourceLocation(ArgInfo
.LAngleLoc
);
68 Record
.AddSourceLocation(ArgInfo
.RAngleLoc
);
69 for (unsigned i
= 0; i
!= ArgInfo
.NumTemplateArgs
; ++i
)
70 Record
.AddTemplateArgumentLoc(Args
[i
]);
73 void ASTStmtWriter::VisitStmt(Stmt
*S
) {
76 void ASTStmtWriter::VisitNullStmt(NullStmt
*S
) {
78 Record
.AddSourceLocation(S
->getSemiLoc());
79 Record
.push_back(S
->NullStmtBits
.HasLeadingEmptyMacro
);
80 Code
= serialization::STMT_NULL
;
83 void ASTStmtWriter::VisitCompoundStmt(CompoundStmt
*S
) {
85 Record
.push_back(S
->size());
86 Record
.push_back(S
->hasStoredFPFeatures());
87 for (auto *CS
: S
->body())
89 if (S
->hasStoredFPFeatures())
90 Record
.push_back(S
->getStoredFPFeatures().getAsOpaqueInt());
91 Record
.AddSourceLocation(S
->getLBracLoc());
92 Record
.AddSourceLocation(S
->getRBracLoc());
93 Code
= serialization::STMT_COMPOUND
;
96 void ASTStmtWriter::VisitSwitchCase(SwitchCase
*S
) {
98 Record
.push_back(Writer
.getSwitchCaseID(S
));
99 Record
.AddSourceLocation(S
->getKeywordLoc());
100 Record
.AddSourceLocation(S
->getColonLoc());
103 void ASTStmtWriter::VisitCaseStmt(CaseStmt
*S
) {
105 Record
.push_back(S
->caseStmtIsGNURange());
106 Record
.AddStmt(S
->getLHS());
107 Record
.AddStmt(S
->getSubStmt());
108 if (S
->caseStmtIsGNURange()) {
109 Record
.AddStmt(S
->getRHS());
110 Record
.AddSourceLocation(S
->getEllipsisLoc());
112 Code
= serialization::STMT_CASE
;
115 void ASTStmtWriter::VisitDefaultStmt(DefaultStmt
*S
) {
117 Record
.AddStmt(S
->getSubStmt());
118 Code
= serialization::STMT_DEFAULT
;
121 void ASTStmtWriter::VisitLabelStmt(LabelStmt
*S
) {
123 Record
.push_back(S
->isSideEntry());
124 Record
.AddDeclRef(S
->getDecl());
125 Record
.AddStmt(S
->getSubStmt());
126 Record
.AddSourceLocation(S
->getIdentLoc());
127 Code
= serialization::STMT_LABEL
;
130 void ASTStmtWriter::VisitAttributedStmt(AttributedStmt
*S
) {
132 Record
.push_back(S
->getAttrs().size());
133 Record
.AddAttributes(S
->getAttrs());
134 Record
.AddStmt(S
->getSubStmt());
135 Record
.AddSourceLocation(S
->getAttrLoc());
136 Code
= serialization::STMT_ATTRIBUTED
;
139 void ASTStmtWriter::VisitIfStmt(IfStmt
*S
) {
142 bool HasElse
= S
->getElse() != nullptr;
143 bool HasVar
= S
->getConditionVariableDeclStmt() != nullptr;
144 bool HasInit
= S
->getInit() != nullptr;
146 Record
.push_back(HasElse
);
147 Record
.push_back(HasVar
);
148 Record
.push_back(HasInit
);
149 Record
.push_back(static_cast<uint64_t>(S
->getStatementKind()));
150 Record
.AddStmt(S
->getCond());
151 Record
.AddStmt(S
->getThen());
153 Record
.AddStmt(S
->getElse());
155 Record
.AddStmt(S
->getConditionVariableDeclStmt());
157 Record
.AddStmt(S
->getInit());
159 Record
.AddSourceLocation(S
->getIfLoc());
160 Record
.AddSourceLocation(S
->getLParenLoc());
161 Record
.AddSourceLocation(S
->getRParenLoc());
163 Record
.AddSourceLocation(S
->getElseLoc());
165 Code
= serialization::STMT_IF
;
168 void ASTStmtWriter::VisitSwitchStmt(SwitchStmt
*S
) {
171 bool HasInit
= S
->getInit() != nullptr;
172 bool HasVar
= S
->getConditionVariableDeclStmt() != nullptr;
173 Record
.push_back(HasInit
);
174 Record
.push_back(HasVar
);
175 Record
.push_back(S
->isAllEnumCasesCovered());
177 Record
.AddStmt(S
->getCond());
178 Record
.AddStmt(S
->getBody());
180 Record
.AddStmt(S
->getInit());
182 Record
.AddStmt(S
->getConditionVariableDeclStmt());
184 Record
.AddSourceLocation(S
->getSwitchLoc());
185 Record
.AddSourceLocation(S
->getLParenLoc());
186 Record
.AddSourceLocation(S
->getRParenLoc());
188 for (SwitchCase
*SC
= S
->getSwitchCaseList(); SC
;
189 SC
= SC
->getNextSwitchCase())
190 Record
.push_back(Writer
.RecordSwitchCaseID(SC
));
191 Code
= serialization::STMT_SWITCH
;
194 void ASTStmtWriter::VisitWhileStmt(WhileStmt
*S
) {
197 bool HasVar
= S
->getConditionVariableDeclStmt() != nullptr;
198 Record
.push_back(HasVar
);
200 Record
.AddStmt(S
->getCond());
201 Record
.AddStmt(S
->getBody());
203 Record
.AddStmt(S
->getConditionVariableDeclStmt());
205 Record
.AddSourceLocation(S
->getWhileLoc());
206 Record
.AddSourceLocation(S
->getLParenLoc());
207 Record
.AddSourceLocation(S
->getRParenLoc());
208 Code
= serialization::STMT_WHILE
;
211 void ASTStmtWriter::VisitDoStmt(DoStmt
*S
) {
213 Record
.AddStmt(S
->getCond());
214 Record
.AddStmt(S
->getBody());
215 Record
.AddSourceLocation(S
->getDoLoc());
216 Record
.AddSourceLocation(S
->getWhileLoc());
217 Record
.AddSourceLocation(S
->getRParenLoc());
218 Code
= serialization::STMT_DO
;
221 void ASTStmtWriter::VisitForStmt(ForStmt
*S
) {
223 Record
.AddStmt(S
->getInit());
224 Record
.AddStmt(S
->getCond());
225 Record
.AddStmt(S
->getConditionVariableDeclStmt());
226 Record
.AddStmt(S
->getInc());
227 Record
.AddStmt(S
->getBody());
228 Record
.AddSourceLocation(S
->getForLoc());
229 Record
.AddSourceLocation(S
->getLParenLoc());
230 Record
.AddSourceLocation(S
->getRParenLoc());
231 Code
= serialization::STMT_FOR
;
234 void ASTStmtWriter::VisitGotoStmt(GotoStmt
*S
) {
236 Record
.AddDeclRef(S
->getLabel());
237 Record
.AddSourceLocation(S
->getGotoLoc());
238 Record
.AddSourceLocation(S
->getLabelLoc());
239 Code
= serialization::STMT_GOTO
;
242 void ASTStmtWriter::VisitIndirectGotoStmt(IndirectGotoStmt
*S
) {
244 Record
.AddSourceLocation(S
->getGotoLoc());
245 Record
.AddSourceLocation(S
->getStarLoc());
246 Record
.AddStmt(S
->getTarget());
247 Code
= serialization::STMT_INDIRECT_GOTO
;
250 void ASTStmtWriter::VisitContinueStmt(ContinueStmt
*S
) {
252 Record
.AddSourceLocation(S
->getContinueLoc());
253 Code
= serialization::STMT_CONTINUE
;
256 void ASTStmtWriter::VisitBreakStmt(BreakStmt
*S
) {
258 Record
.AddSourceLocation(S
->getBreakLoc());
259 Code
= serialization::STMT_BREAK
;
262 void ASTStmtWriter::VisitReturnStmt(ReturnStmt
*S
) {
265 bool HasNRVOCandidate
= S
->getNRVOCandidate() != nullptr;
266 Record
.push_back(HasNRVOCandidate
);
268 Record
.AddStmt(S
->getRetValue());
269 if (HasNRVOCandidate
)
270 Record
.AddDeclRef(S
->getNRVOCandidate());
272 Record
.AddSourceLocation(S
->getReturnLoc());
273 Code
= serialization::STMT_RETURN
;
276 void ASTStmtWriter::VisitDeclStmt(DeclStmt
*S
) {
278 Record
.AddSourceLocation(S
->getBeginLoc());
279 Record
.AddSourceLocation(S
->getEndLoc());
280 DeclGroupRef DG
= S
->getDeclGroup();
281 for (DeclGroupRef::iterator D
= DG
.begin(), DEnd
= DG
.end(); D
!= DEnd
; ++D
)
282 Record
.AddDeclRef(*D
);
283 Code
= serialization::STMT_DECL
;
286 void ASTStmtWriter::VisitAsmStmt(AsmStmt
*S
) {
288 Record
.push_back(S
->getNumOutputs());
289 Record
.push_back(S
->getNumInputs());
290 Record
.push_back(S
->getNumClobbers());
291 Record
.AddSourceLocation(S
->getAsmLoc());
292 Record
.push_back(S
->isVolatile());
293 Record
.push_back(S
->isSimple());
296 void ASTStmtWriter::VisitGCCAsmStmt(GCCAsmStmt
*S
) {
298 Record
.push_back(S
->getNumLabels());
299 Record
.AddSourceLocation(S
->getRParenLoc());
300 Record
.AddStmt(S
->getAsmString());
303 for (unsigned I
= 0, N
= S
->getNumOutputs(); I
!= N
; ++I
) {
304 Record
.AddIdentifierRef(S
->getOutputIdentifier(I
));
305 Record
.AddStmt(S
->getOutputConstraintLiteral(I
));
306 Record
.AddStmt(S
->getOutputExpr(I
));
310 for (unsigned I
= 0, N
= S
->getNumInputs(); I
!= N
; ++I
) {
311 Record
.AddIdentifierRef(S
->getInputIdentifier(I
));
312 Record
.AddStmt(S
->getInputConstraintLiteral(I
));
313 Record
.AddStmt(S
->getInputExpr(I
));
317 for (unsigned I
= 0, N
= S
->getNumClobbers(); I
!= N
; ++I
)
318 Record
.AddStmt(S
->getClobberStringLiteral(I
));
321 for (unsigned I
= 0, N
= S
->getNumLabels(); I
!= N
; ++I
) {
322 Record
.AddIdentifierRef(S
->getLabelIdentifier(I
));
323 Record
.AddStmt(S
->getLabelExpr(I
));
326 Code
= serialization::STMT_GCCASM
;
329 void ASTStmtWriter::VisitMSAsmStmt(MSAsmStmt
*S
) {
331 Record
.AddSourceLocation(S
->getLBraceLoc());
332 Record
.AddSourceLocation(S
->getEndLoc());
333 Record
.push_back(S
->getNumAsmToks());
334 Record
.AddString(S
->getAsmString());
337 for (unsigned I
= 0, N
= S
->getNumAsmToks(); I
!= N
; ++I
) {
338 // FIXME: Move this to ASTRecordWriter?
339 Writer
.AddToken(S
->getAsmToks()[I
], Record
.getRecordData());
343 for (unsigned I
= 0, N
= S
->getNumClobbers(); I
!= N
; ++I
) {
344 Record
.AddString(S
->getClobber(I
));
348 for (unsigned I
= 0, N
= S
->getNumOutputs(); I
!= N
; ++I
) {
349 Record
.AddStmt(S
->getOutputExpr(I
));
350 Record
.AddString(S
->getOutputConstraint(I
));
354 for (unsigned I
= 0, N
= S
->getNumInputs(); I
!= N
; ++I
) {
355 Record
.AddStmt(S
->getInputExpr(I
));
356 Record
.AddString(S
->getInputConstraint(I
));
359 Code
= serialization::STMT_MSASM
;
362 void ASTStmtWriter::VisitCoroutineBodyStmt(CoroutineBodyStmt
*CoroStmt
) {
364 Record
.push_back(CoroStmt
->getParamMoves().size());
365 for (Stmt
*S
: CoroStmt
->children())
367 Code
= serialization::STMT_COROUTINE_BODY
;
370 void ASTStmtWriter::VisitCoreturnStmt(CoreturnStmt
*S
) {
372 Record
.AddSourceLocation(S
->getKeywordLoc());
373 Record
.AddStmt(S
->getOperand());
374 Record
.AddStmt(S
->getPromiseCall());
375 Record
.push_back(S
->isImplicit());
376 Code
= serialization::STMT_CORETURN
;
379 void ASTStmtWriter::VisitCoroutineSuspendExpr(CoroutineSuspendExpr
*E
) {
381 Record
.AddSourceLocation(E
->getKeywordLoc());
382 for (Stmt
*S
: E
->children())
384 Record
.AddStmt(E
->getOpaqueValue());
387 void ASTStmtWriter::VisitCoawaitExpr(CoawaitExpr
*E
) {
388 VisitCoroutineSuspendExpr(E
);
389 Record
.push_back(E
->isImplicit());
390 Code
= serialization::EXPR_COAWAIT
;
393 void ASTStmtWriter::VisitCoyieldExpr(CoyieldExpr
*E
) {
394 VisitCoroutineSuspendExpr(E
);
395 Code
= serialization::EXPR_COYIELD
;
398 void ASTStmtWriter::VisitDependentCoawaitExpr(DependentCoawaitExpr
*E
) {
400 Record
.AddSourceLocation(E
->getKeywordLoc());
401 for (Stmt
*S
: E
->children())
403 Code
= serialization::EXPR_DEPENDENT_COAWAIT
;
407 addConstraintSatisfaction(ASTRecordWriter
&Record
,
408 const ASTConstraintSatisfaction
&Satisfaction
) {
409 Record
.push_back(Satisfaction
.IsSatisfied
);
410 Record
.push_back(Satisfaction
.ContainsErrors
);
411 if (!Satisfaction
.IsSatisfied
) {
412 Record
.push_back(Satisfaction
.NumRecords
);
413 for (const auto &DetailRecord
: Satisfaction
) {
414 Record
.AddStmt(const_cast<Expr
*>(DetailRecord
.first
));
415 auto *E
= DetailRecord
.second
.dyn_cast
<Expr
*>();
416 Record
.push_back(E
== nullptr);
420 auto *Diag
= DetailRecord
.second
.get
<std::pair
<SourceLocation
,
422 Record
.AddSourceLocation(Diag
->first
);
423 Record
.AddString(Diag
->second
);
430 addSubstitutionDiagnostic(
431 ASTRecordWriter
&Record
,
432 const concepts::Requirement::SubstitutionDiagnostic
*D
) {
433 Record
.AddString(D
->SubstitutedEntity
);
434 Record
.AddSourceLocation(D
->DiagLoc
);
435 Record
.AddString(D
->DiagMessage
);
438 void ASTStmtWriter::VisitConceptSpecializationExpr(
439 ConceptSpecializationExpr
*E
) {
441 Record
.AddDeclRef(E
->getSpecializationDecl());
442 const ConceptReference
*CR
= E
->getConceptReference();
443 Record
.push_back(CR
!= nullptr);
445 Record
.AddConceptReference(CR
);
446 if (!E
->isValueDependent())
447 addConstraintSatisfaction(Record
, E
->getSatisfaction());
449 Code
= serialization::EXPR_CONCEPT_SPECIALIZATION
;
452 void ASTStmtWriter::VisitRequiresExpr(RequiresExpr
*E
) {
454 Record
.push_back(E
->getLocalParameters().size());
455 Record
.push_back(E
->getRequirements().size());
456 Record
.AddSourceLocation(E
->RequiresExprBits
.RequiresKWLoc
);
457 Record
.push_back(E
->RequiresExprBits
.IsSatisfied
);
458 Record
.AddDeclRef(E
->getBody());
459 for (ParmVarDecl
*P
: E
->getLocalParameters())
460 Record
.AddDeclRef(P
);
461 for (concepts::Requirement
*R
: E
->getRequirements()) {
462 if (auto *TypeReq
= dyn_cast
<concepts::TypeRequirement
>(R
)) {
463 Record
.push_back(concepts::Requirement::RK_Type
);
464 Record
.push_back(TypeReq
->Status
);
465 if (TypeReq
->Status
== concepts::TypeRequirement::SS_SubstitutionFailure
)
466 addSubstitutionDiagnostic(Record
, TypeReq
->getSubstitutionDiagnostic());
468 Record
.AddTypeSourceInfo(TypeReq
->getType());
469 } else if (auto *ExprReq
= dyn_cast
<concepts::ExprRequirement
>(R
)) {
470 Record
.push_back(ExprReq
->getKind());
471 Record
.push_back(ExprReq
->Status
);
472 if (ExprReq
->isExprSubstitutionFailure()) {
473 addSubstitutionDiagnostic(Record
,
474 ExprReq
->Value
.get
<concepts::Requirement::SubstitutionDiagnostic
*>());
476 Record
.AddStmt(ExprReq
->Value
.get
<Expr
*>());
477 if (ExprReq
->getKind() == concepts::Requirement::RK_Compound
) {
478 Record
.AddSourceLocation(ExprReq
->NoexceptLoc
);
479 const auto &RetReq
= ExprReq
->getReturnTypeRequirement();
480 if (RetReq
.isSubstitutionFailure()) {
482 addSubstitutionDiagnostic(Record
, RetReq
.getSubstitutionDiagnostic());
483 } else if (RetReq
.isTypeConstraint()) {
485 Record
.AddTemplateParameterList(
486 RetReq
.getTypeConstraintTemplateParameterList());
487 if (ExprReq
->Status
>=
488 concepts::ExprRequirement::SS_ConstraintsNotSatisfied
)
490 ExprReq
->getReturnTypeRequirementSubstitutedConstraintExpr());
492 assert(RetReq
.isEmpty());
497 auto *NestedReq
= cast
<concepts::NestedRequirement
>(R
);
498 Record
.push_back(concepts::Requirement::RK_Nested
);
499 Record
.push_back(NestedReq
->hasInvalidConstraint());
500 if (NestedReq
->hasInvalidConstraint()) {
501 Record
.AddString(NestedReq
->getInvalidConstraintEntity());
502 addConstraintSatisfaction(Record
, *NestedReq
->Satisfaction
);
504 Record
.AddStmt(NestedReq
->getConstraintExpr());
505 if (!NestedReq
->isDependent())
506 addConstraintSatisfaction(Record
, *NestedReq
->Satisfaction
);
510 Record
.AddSourceLocation(E
->getLParenLoc());
511 Record
.AddSourceLocation(E
->getRParenLoc());
512 Record
.AddSourceLocation(E
->getEndLoc());
514 Code
= serialization::EXPR_REQUIRES
;
518 void ASTStmtWriter::VisitCapturedStmt(CapturedStmt
*S
) {
521 Record
.push_back(std::distance(S
->capture_begin(), S
->capture_end()));
523 // CapturedDecl and captured region kind
524 Record
.AddDeclRef(S
->getCapturedDecl());
525 Record
.push_back(S
->getCapturedRegionKind());
527 Record
.AddDeclRef(S
->getCapturedRecordDecl());
530 for (auto *I
: S
->capture_inits())
534 Record
.AddStmt(S
->getCapturedStmt());
537 for (const auto &I
: S
->captures()) {
538 if (I
.capturesThis() || I
.capturesVariableArrayType())
539 Record
.AddDeclRef(nullptr);
541 Record
.AddDeclRef(I
.getCapturedVar());
542 Record
.push_back(I
.getCaptureKind());
543 Record
.AddSourceLocation(I
.getLocation());
546 Code
= serialization::STMT_CAPTURED
;
549 void ASTStmtWriter::VisitExpr(Expr
*E
) {
551 Record
.AddTypeRef(E
->getType());
552 Record
.push_back(E
->getDependence());
553 Record
.push_back(E
->getValueKind());
554 Record
.push_back(E
->getObjectKind());
557 void ASTStmtWriter::VisitConstantExpr(ConstantExpr
*E
) {
559 Record
.push_back(E
->ConstantExprBits
.ResultKind
);
561 Record
.push_back(E
->ConstantExprBits
.APValueKind
);
562 Record
.push_back(E
->ConstantExprBits
.IsUnsigned
);
563 Record
.push_back(E
->ConstantExprBits
.BitWidth
);
564 // HasCleanup not serialized since we can just query the APValue.
565 Record
.push_back(E
->ConstantExprBits
.IsImmediateInvocation
);
567 switch (E
->ConstantExprBits
.ResultKind
) {
568 case ConstantExpr::RSK_None
:
570 case ConstantExpr::RSK_Int64
:
571 Record
.push_back(E
->Int64Result());
573 case ConstantExpr::RSK_APValue
:
574 Record
.AddAPValue(E
->APValueResult());
577 llvm_unreachable("unexpected ResultKind!");
580 Record
.AddStmt(E
->getSubExpr());
581 Code
= serialization::EXPR_CONSTANT
;
584 void ASTStmtWriter::VisitSYCLUniqueStableNameExpr(SYCLUniqueStableNameExpr
*E
) {
587 Record
.AddSourceLocation(E
->getLocation());
588 Record
.AddSourceLocation(E
->getLParenLocation());
589 Record
.AddSourceLocation(E
->getRParenLocation());
590 Record
.AddTypeSourceInfo(E
->getTypeSourceInfo());
592 Code
= serialization::EXPR_SYCL_UNIQUE_STABLE_NAME
;
595 void ASTStmtWriter::VisitPredefinedExpr(PredefinedExpr
*E
) {
598 bool HasFunctionName
= E
->getFunctionName() != nullptr;
599 Record
.push_back(HasFunctionName
);
600 Record
.push_back(E
->getIdentKind()); // FIXME: stable encoding
601 Record
.push_back(E
->isTransparent());
602 Record
.AddSourceLocation(E
->getLocation());
604 Record
.AddStmt(E
->getFunctionName());
605 Code
= serialization::EXPR_PREDEFINED
;
608 void ASTStmtWriter::VisitDeclRefExpr(DeclRefExpr
*E
) {
611 Record
.push_back(E
->hasQualifier());
612 Record
.push_back(E
->getDecl() != E
->getFoundDecl());
613 Record
.push_back(E
->hasTemplateKWAndArgsInfo());
614 Record
.push_back(E
->hadMultipleCandidates());
615 Record
.push_back(E
->refersToEnclosingVariableOrCapture());
616 Record
.push_back(E
->isNonOdrUse());
617 Record
.push_back(E
->isImmediateEscalating());
619 if (E
->hasTemplateKWAndArgsInfo()) {
620 unsigned NumTemplateArgs
= E
->getNumTemplateArgs();
621 Record
.push_back(NumTemplateArgs
);
624 DeclarationName::NameKind nk
= (E
->getDecl()->getDeclName().getNameKind());
626 if ((!E
->hasTemplateKWAndArgsInfo()) && (!E
->hasQualifier()) &&
627 (E
->getDecl() == E
->getFoundDecl()) &&
628 nk
== DeclarationName::Identifier
&&
629 !E
->refersToEnclosingVariableOrCapture() && !E
->isNonOdrUse() &&
630 !E
->isImmediateEscalating()) {
631 AbbrevToUse
= Writer
.getDeclRefExprAbbrev();
634 if (E
->hasQualifier())
635 Record
.AddNestedNameSpecifierLoc(E
->getQualifierLoc());
637 if (E
->getDecl() != E
->getFoundDecl())
638 Record
.AddDeclRef(E
->getFoundDecl());
640 if (E
->hasTemplateKWAndArgsInfo())
641 AddTemplateKWAndArgsInfo(*E
->getTrailingObjects
<ASTTemplateKWAndArgsInfo
>(),
642 E
->getTrailingObjects
<TemplateArgumentLoc
>());
644 Record
.AddDeclRef(E
->getDecl());
645 Record
.AddSourceLocation(E
->getLocation());
646 Record
.AddDeclarationNameLoc(E
->DNLoc
, E
->getDecl()->getDeclName());
647 Code
= serialization::EXPR_DECL_REF
;
650 void ASTStmtWriter::VisitIntegerLiteral(IntegerLiteral
*E
) {
652 Record
.AddSourceLocation(E
->getLocation());
653 Record
.AddAPInt(E
->getValue());
655 if (E
->getValue().getBitWidth() == 32) {
656 AbbrevToUse
= Writer
.getIntegerLiteralAbbrev();
659 Code
= serialization::EXPR_INTEGER_LITERAL
;
662 void ASTStmtWriter::VisitFixedPointLiteral(FixedPointLiteral
*E
) {
664 Record
.AddSourceLocation(E
->getLocation());
665 Record
.push_back(E
->getScale());
666 Record
.AddAPInt(E
->getValue());
667 Code
= serialization::EXPR_FIXEDPOINT_LITERAL
;
670 void ASTStmtWriter::VisitFloatingLiteral(FloatingLiteral
*E
) {
672 Record
.push_back(E
->getRawSemantics());
673 Record
.push_back(E
->isExact());
674 Record
.AddAPFloat(E
->getValue());
675 Record
.AddSourceLocation(E
->getLocation());
676 Code
= serialization::EXPR_FLOATING_LITERAL
;
679 void ASTStmtWriter::VisitImaginaryLiteral(ImaginaryLiteral
*E
) {
681 Record
.AddStmt(E
->getSubExpr());
682 Code
= serialization::EXPR_IMAGINARY_LITERAL
;
685 void ASTStmtWriter::VisitStringLiteral(StringLiteral
*E
) {
688 // Store the various bits of data of StringLiteral.
689 Record
.push_back(E
->getNumConcatenated());
690 Record
.push_back(E
->getLength());
691 Record
.push_back(E
->getCharByteWidth());
692 Record
.push_back(E
->getKind());
693 Record
.push_back(E
->isPascal());
695 // Store the trailing array of SourceLocation.
696 for (unsigned I
= 0, N
= E
->getNumConcatenated(); I
!= N
; ++I
)
697 Record
.AddSourceLocation(E
->getStrTokenLoc(I
));
699 // Store the trailing array of char holding the string data.
700 StringRef StrData
= E
->getBytes();
701 for (unsigned I
= 0, N
= E
->getByteLength(); I
!= N
; ++I
)
702 Record
.push_back(StrData
[I
]);
704 Code
= serialization::EXPR_STRING_LITERAL
;
707 void ASTStmtWriter::VisitCharacterLiteral(CharacterLiteral
*E
) {
709 Record
.push_back(E
->getValue());
710 Record
.AddSourceLocation(E
->getLocation());
711 Record
.push_back(E
->getKind());
713 AbbrevToUse
= Writer
.getCharacterLiteralAbbrev();
715 Code
= serialization::EXPR_CHARACTER_LITERAL
;
718 void ASTStmtWriter::VisitParenExpr(ParenExpr
*E
) {
720 Record
.AddSourceLocation(E
->getLParen());
721 Record
.AddSourceLocation(E
->getRParen());
722 Record
.AddStmt(E
->getSubExpr());
723 Code
= serialization::EXPR_PAREN
;
726 void ASTStmtWriter::VisitParenListExpr(ParenListExpr
*E
) {
728 Record
.push_back(E
->getNumExprs());
729 for (auto *SubStmt
: E
->exprs())
730 Record
.AddStmt(SubStmt
);
731 Record
.AddSourceLocation(E
->getLParenLoc());
732 Record
.AddSourceLocation(E
->getRParenLoc());
733 Code
= serialization::EXPR_PAREN_LIST
;
736 void ASTStmtWriter::VisitUnaryOperator(UnaryOperator
*E
) {
738 bool HasFPFeatures
= E
->hasStoredFPFeatures();
739 // Write this first for easy access when deserializing, as they affect the
740 // size of the UnaryOperator.
741 Record
.push_back(HasFPFeatures
);
742 Record
.AddStmt(E
->getSubExpr());
743 Record
.push_back(E
->getOpcode()); // FIXME: stable encoding
744 Record
.AddSourceLocation(E
->getOperatorLoc());
745 Record
.push_back(E
->canOverflow());
747 Record
.push_back(E
->getStoredFPFeatures().getAsOpaqueInt());
748 Code
= serialization::EXPR_UNARY_OPERATOR
;
751 void ASTStmtWriter::VisitOffsetOfExpr(OffsetOfExpr
*E
) {
753 Record
.push_back(E
->getNumComponents());
754 Record
.push_back(E
->getNumExpressions());
755 Record
.AddSourceLocation(E
->getOperatorLoc());
756 Record
.AddSourceLocation(E
->getRParenLoc());
757 Record
.AddTypeSourceInfo(E
->getTypeSourceInfo());
758 for (unsigned I
= 0, N
= E
->getNumComponents(); I
!= N
; ++I
) {
759 const OffsetOfNode
&ON
= E
->getComponent(I
);
760 Record
.push_back(ON
.getKind()); // FIXME: Stable encoding
761 Record
.AddSourceLocation(ON
.getSourceRange().getBegin());
762 Record
.AddSourceLocation(ON
.getSourceRange().getEnd());
763 switch (ON
.getKind()) {
764 case OffsetOfNode::Array
:
765 Record
.push_back(ON
.getArrayExprIndex());
768 case OffsetOfNode::Field
:
769 Record
.AddDeclRef(ON
.getField());
772 case OffsetOfNode::Identifier
:
773 Record
.AddIdentifierRef(ON
.getFieldName());
776 case OffsetOfNode::Base
:
777 Record
.AddCXXBaseSpecifier(*ON
.getBase());
781 for (unsigned I
= 0, N
= E
->getNumExpressions(); I
!= N
; ++I
)
782 Record
.AddStmt(E
->getIndexExpr(I
));
783 Code
= serialization::EXPR_OFFSETOF
;
786 void ASTStmtWriter::VisitUnaryExprOrTypeTraitExpr(UnaryExprOrTypeTraitExpr
*E
) {
788 Record
.push_back(E
->getKind());
789 if (E
->isArgumentType())
790 Record
.AddTypeSourceInfo(E
->getArgumentTypeInfo());
793 Record
.AddStmt(E
->getArgumentExpr());
795 Record
.AddSourceLocation(E
->getOperatorLoc());
796 Record
.AddSourceLocation(E
->getRParenLoc());
797 Code
= serialization::EXPR_SIZEOF_ALIGN_OF
;
800 void ASTStmtWriter::VisitArraySubscriptExpr(ArraySubscriptExpr
*E
) {
802 Record
.AddStmt(E
->getLHS());
803 Record
.AddStmt(E
->getRHS());
804 Record
.AddSourceLocation(E
->getRBracketLoc());
805 Code
= serialization::EXPR_ARRAY_SUBSCRIPT
;
808 void ASTStmtWriter::VisitMatrixSubscriptExpr(MatrixSubscriptExpr
*E
) {
810 Record
.AddStmt(E
->getBase());
811 Record
.AddStmt(E
->getRowIdx());
812 Record
.AddStmt(E
->getColumnIdx());
813 Record
.AddSourceLocation(E
->getRBracketLoc());
814 Code
= serialization::EXPR_ARRAY_SUBSCRIPT
;
817 void ASTStmtWriter::VisitOMPArraySectionExpr(OMPArraySectionExpr
*E
) {
819 Record
.AddStmt(E
->getBase());
820 Record
.AddStmt(E
->getLowerBound());
821 Record
.AddStmt(E
->getLength());
822 Record
.AddStmt(E
->getStride());
823 Record
.AddSourceLocation(E
->getColonLocFirst());
824 Record
.AddSourceLocation(E
->getColonLocSecond());
825 Record
.AddSourceLocation(E
->getRBracketLoc());
826 Code
= serialization::EXPR_OMP_ARRAY_SECTION
;
829 void ASTStmtWriter::VisitOMPArrayShapingExpr(OMPArrayShapingExpr
*E
) {
831 Record
.push_back(E
->getDimensions().size());
832 Record
.AddStmt(E
->getBase());
833 for (Expr
*Dim
: E
->getDimensions())
835 for (SourceRange SR
: E
->getBracketsRanges())
836 Record
.AddSourceRange(SR
);
837 Record
.AddSourceLocation(E
->getLParenLoc());
838 Record
.AddSourceLocation(E
->getRParenLoc());
839 Code
= serialization::EXPR_OMP_ARRAY_SHAPING
;
842 void ASTStmtWriter::VisitOMPIteratorExpr(OMPIteratorExpr
*E
) {
844 Record
.push_back(E
->numOfIterators());
845 Record
.AddSourceLocation(E
->getIteratorKwLoc());
846 Record
.AddSourceLocation(E
->getLParenLoc());
847 Record
.AddSourceLocation(E
->getRParenLoc());
848 for (unsigned I
= 0, End
= E
->numOfIterators(); I
< End
; ++I
) {
849 Record
.AddDeclRef(E
->getIteratorDecl(I
));
850 Record
.AddSourceLocation(E
->getAssignLoc(I
));
851 OMPIteratorExpr::IteratorRange Range
= E
->getIteratorRange(I
);
852 Record
.AddStmt(Range
.Begin
);
853 Record
.AddStmt(Range
.End
);
854 Record
.AddStmt(Range
.Step
);
855 Record
.AddSourceLocation(E
->getColonLoc(I
));
857 Record
.AddSourceLocation(E
->getSecondColonLoc(I
));
859 OMPIteratorHelperData
&HD
= E
->getHelper(I
);
860 Record
.AddDeclRef(HD
.CounterVD
);
861 Record
.AddStmt(HD
.Upper
);
862 Record
.AddStmt(HD
.Update
);
863 Record
.AddStmt(HD
.CounterUpdate
);
865 Code
= serialization::EXPR_OMP_ITERATOR
;
868 void ASTStmtWriter::VisitCallExpr(CallExpr
*E
) {
870 Record
.push_back(E
->getNumArgs());
871 Record
.push_back(E
->hasStoredFPFeatures());
872 Record
.AddSourceLocation(E
->getRParenLoc());
873 Record
.AddStmt(E
->getCallee());
874 for (CallExpr::arg_iterator Arg
= E
->arg_begin(), ArgEnd
= E
->arg_end();
875 Arg
!= ArgEnd
; ++Arg
)
876 Record
.AddStmt(*Arg
);
877 Record
.push_back(static_cast<unsigned>(E
->getADLCallKind()));
878 if (E
->hasStoredFPFeatures())
879 Record
.push_back(E
->getFPFeatures().getAsOpaqueInt());
880 Code
= serialization::EXPR_CALL
;
883 void ASTStmtWriter::VisitRecoveryExpr(RecoveryExpr
*E
) {
885 Record
.push_back(std::distance(E
->children().begin(), E
->children().end()));
886 Record
.AddSourceLocation(E
->getBeginLoc());
887 Record
.AddSourceLocation(E
->getEndLoc());
888 for (Stmt
*Child
: E
->children())
889 Record
.AddStmt(Child
);
890 Code
= serialization::EXPR_RECOVERY
;
893 void ASTStmtWriter::VisitMemberExpr(MemberExpr
*E
) {
896 bool HasQualifier
= E
->hasQualifier();
898 E
->hasQualifierOrFoundDecl() &&
899 (E
->getFoundDecl().getDecl() != E
->getMemberDecl() ||
900 E
->getFoundDecl().getAccess() != E
->getMemberDecl()->getAccess());
901 bool HasTemplateInfo
= E
->hasTemplateKWAndArgsInfo();
902 unsigned NumTemplateArgs
= E
->getNumTemplateArgs();
904 // Write these first for easy access when deserializing, as they affect the
905 // size of the MemberExpr.
906 Record
.push_back(HasQualifier
);
907 Record
.push_back(HasFoundDecl
);
908 Record
.push_back(HasTemplateInfo
);
909 Record
.push_back(NumTemplateArgs
);
911 Record
.AddStmt(E
->getBase());
912 Record
.AddDeclRef(E
->getMemberDecl());
913 Record
.AddDeclarationNameLoc(E
->MemberDNLoc
,
914 E
->getMemberDecl()->getDeclName());
915 Record
.AddSourceLocation(E
->getMemberLoc());
916 Record
.push_back(E
->isArrow());
917 Record
.push_back(E
->hadMultipleCandidates());
918 Record
.push_back(E
->isNonOdrUse());
919 Record
.AddSourceLocation(E
->getOperatorLoc());
922 DeclAccessPair FoundDecl
= E
->getFoundDecl();
923 Record
.AddDeclRef(FoundDecl
.getDecl());
924 Record
.push_back(FoundDecl
.getAccess());
928 Record
.AddNestedNameSpecifierLoc(E
->getQualifierLoc());
931 AddTemplateKWAndArgsInfo(*E
->getTrailingObjects
<ASTTemplateKWAndArgsInfo
>(),
932 E
->getTrailingObjects
<TemplateArgumentLoc
>());
934 Code
= serialization::EXPR_MEMBER
;
937 void ASTStmtWriter::VisitObjCIsaExpr(ObjCIsaExpr
*E
) {
939 Record
.AddStmt(E
->getBase());
940 Record
.AddSourceLocation(E
->getIsaMemberLoc());
941 Record
.AddSourceLocation(E
->getOpLoc());
942 Record
.push_back(E
->isArrow());
943 Code
= serialization::EXPR_OBJC_ISA
;
947 VisitObjCIndirectCopyRestoreExpr(ObjCIndirectCopyRestoreExpr
*E
) {
949 Record
.AddStmt(E
->getSubExpr());
950 Record
.push_back(E
->shouldCopy());
951 Code
= serialization::EXPR_OBJC_INDIRECT_COPY_RESTORE
;
954 void ASTStmtWriter::VisitObjCBridgedCastExpr(ObjCBridgedCastExpr
*E
) {
955 VisitExplicitCastExpr(E
);
956 Record
.AddSourceLocation(E
->getLParenLoc());
957 Record
.AddSourceLocation(E
->getBridgeKeywordLoc());
958 Record
.push_back(E
->getBridgeKind()); // FIXME: Stable encoding
959 Code
= serialization::EXPR_OBJC_BRIDGED_CAST
;
962 void ASTStmtWriter::VisitCastExpr(CastExpr
*E
) {
964 Record
.push_back(E
->path_size());
965 Record
.push_back(E
->hasStoredFPFeatures());
966 Record
.AddStmt(E
->getSubExpr());
967 Record
.push_back(E
->getCastKind()); // FIXME: stable encoding
969 for (CastExpr::path_iterator
970 PI
= E
->path_begin(), PE
= E
->path_end(); PI
!= PE
; ++PI
)
971 Record
.AddCXXBaseSpecifier(**PI
);
973 if (E
->hasStoredFPFeatures())
974 Record
.push_back(E
->getFPFeatures().getAsOpaqueInt());
977 void ASTStmtWriter::VisitBinaryOperator(BinaryOperator
*E
) {
979 bool HasFPFeatures
= E
->hasStoredFPFeatures();
980 // Write this first for easy access when deserializing, as they affect the
981 // size of the UnaryOperator.
982 Record
.push_back(HasFPFeatures
);
983 Record
.push_back(E
->getOpcode()); // FIXME: stable encoding
984 Record
.AddStmt(E
->getLHS());
985 Record
.AddStmt(E
->getRHS());
986 Record
.AddSourceLocation(E
->getOperatorLoc());
988 Record
.push_back(E
->getStoredFPFeatures().getAsOpaqueInt());
989 Code
= serialization::EXPR_BINARY_OPERATOR
;
992 void ASTStmtWriter::VisitCompoundAssignOperator(CompoundAssignOperator
*E
) {
993 VisitBinaryOperator(E
);
994 Record
.AddTypeRef(E
->getComputationLHSType());
995 Record
.AddTypeRef(E
->getComputationResultType());
996 Code
= serialization::EXPR_COMPOUND_ASSIGN_OPERATOR
;
999 void ASTStmtWriter::VisitConditionalOperator(ConditionalOperator
*E
) {
1001 Record
.AddStmt(E
->getCond());
1002 Record
.AddStmt(E
->getLHS());
1003 Record
.AddStmt(E
->getRHS());
1004 Record
.AddSourceLocation(E
->getQuestionLoc());
1005 Record
.AddSourceLocation(E
->getColonLoc());
1006 Code
= serialization::EXPR_CONDITIONAL_OPERATOR
;
1010 ASTStmtWriter::VisitBinaryConditionalOperator(BinaryConditionalOperator
*E
) {
1012 Record
.AddStmt(E
->getOpaqueValue());
1013 Record
.AddStmt(E
->getCommon());
1014 Record
.AddStmt(E
->getCond());
1015 Record
.AddStmt(E
->getTrueExpr());
1016 Record
.AddStmt(E
->getFalseExpr());
1017 Record
.AddSourceLocation(E
->getQuestionLoc());
1018 Record
.AddSourceLocation(E
->getColonLoc());
1019 Code
= serialization::EXPR_BINARY_CONDITIONAL_OPERATOR
;
1022 void ASTStmtWriter::VisitImplicitCastExpr(ImplicitCastExpr
*E
) {
1024 Record
.push_back(E
->isPartOfExplicitCast());
1026 if (E
->path_size() == 0 && !E
->hasStoredFPFeatures())
1027 AbbrevToUse
= Writer
.getExprImplicitCastAbbrev();
1029 Code
= serialization::EXPR_IMPLICIT_CAST
;
1032 void ASTStmtWriter::VisitExplicitCastExpr(ExplicitCastExpr
*E
) {
1034 Record
.AddTypeSourceInfo(E
->getTypeInfoAsWritten());
1037 void ASTStmtWriter::VisitCStyleCastExpr(CStyleCastExpr
*E
) {
1038 VisitExplicitCastExpr(E
);
1039 Record
.AddSourceLocation(E
->getLParenLoc());
1040 Record
.AddSourceLocation(E
->getRParenLoc());
1041 Code
= serialization::EXPR_CSTYLE_CAST
;
1044 void ASTStmtWriter::VisitCompoundLiteralExpr(CompoundLiteralExpr
*E
) {
1046 Record
.AddSourceLocation(E
->getLParenLoc());
1047 Record
.AddTypeSourceInfo(E
->getTypeSourceInfo());
1048 Record
.AddStmt(E
->getInitializer());
1049 Record
.push_back(E
->isFileScope());
1050 Code
= serialization::EXPR_COMPOUND_LITERAL
;
1053 void ASTStmtWriter::VisitExtVectorElementExpr(ExtVectorElementExpr
*E
) {
1055 Record
.AddStmt(E
->getBase());
1056 Record
.AddIdentifierRef(&E
->getAccessor());
1057 Record
.AddSourceLocation(E
->getAccessorLoc());
1058 Code
= serialization::EXPR_EXT_VECTOR_ELEMENT
;
1061 void ASTStmtWriter::VisitInitListExpr(InitListExpr
*E
) {
1063 // NOTE: only add the (possibly null) syntactic form.
1064 // No need to serialize the isSemanticForm flag and the semantic form.
1065 Record
.AddStmt(E
->getSyntacticForm());
1066 Record
.AddSourceLocation(E
->getLBraceLoc());
1067 Record
.AddSourceLocation(E
->getRBraceLoc());
1068 bool isArrayFiller
= E
->ArrayFillerOrUnionFieldInit
.is
<Expr
*>();
1069 Record
.push_back(isArrayFiller
);
1071 Record
.AddStmt(E
->getArrayFiller());
1073 Record
.AddDeclRef(E
->getInitializedFieldInUnion());
1074 Record
.push_back(E
->hadArrayRangeDesignator());
1075 Record
.push_back(E
->getNumInits());
1076 if (isArrayFiller
) {
1077 // ArrayFiller may have filled "holes" due to designated initializer.
1078 // Replace them by 0 to indicate that the filler goes in that place.
1079 Expr
*filler
= E
->getArrayFiller();
1080 for (unsigned I
= 0, N
= E
->getNumInits(); I
!= N
; ++I
)
1081 Record
.AddStmt(E
->getInit(I
) != filler
? E
->getInit(I
) : nullptr);
1083 for (unsigned I
= 0, N
= E
->getNumInits(); I
!= N
; ++I
)
1084 Record
.AddStmt(E
->getInit(I
));
1086 Code
= serialization::EXPR_INIT_LIST
;
1089 void ASTStmtWriter::VisitDesignatedInitExpr(DesignatedInitExpr
*E
) {
1091 Record
.push_back(E
->getNumSubExprs());
1092 for (unsigned I
= 0, N
= E
->getNumSubExprs(); I
!= N
; ++I
)
1093 Record
.AddStmt(E
->getSubExpr(I
));
1094 Record
.AddSourceLocation(E
->getEqualOrColonLoc());
1095 Record
.push_back(E
->usesGNUSyntax());
1096 for (const DesignatedInitExpr::Designator
&D
: E
->designators()) {
1097 if (D
.isFieldDesignator()) {
1098 if (FieldDecl
*Field
= D
.getFieldDecl()) {
1099 Record
.push_back(serialization::DESIG_FIELD_DECL
);
1100 Record
.AddDeclRef(Field
);
1102 Record
.push_back(serialization::DESIG_FIELD_NAME
);
1103 Record
.AddIdentifierRef(D
.getFieldName());
1105 Record
.AddSourceLocation(D
.getDotLoc());
1106 Record
.AddSourceLocation(D
.getFieldLoc());
1107 } else if (D
.isArrayDesignator()) {
1108 Record
.push_back(serialization::DESIG_ARRAY
);
1109 Record
.push_back(D
.getArrayIndex());
1110 Record
.AddSourceLocation(D
.getLBracketLoc());
1111 Record
.AddSourceLocation(D
.getRBracketLoc());
1113 assert(D
.isArrayRangeDesignator() && "Unknown designator");
1114 Record
.push_back(serialization::DESIG_ARRAY_RANGE
);
1115 Record
.push_back(D
.getArrayIndex());
1116 Record
.AddSourceLocation(D
.getLBracketLoc());
1117 Record
.AddSourceLocation(D
.getEllipsisLoc());
1118 Record
.AddSourceLocation(D
.getRBracketLoc());
1121 Code
= serialization::EXPR_DESIGNATED_INIT
;
1124 void ASTStmtWriter::VisitDesignatedInitUpdateExpr(DesignatedInitUpdateExpr
*E
) {
1126 Record
.AddStmt(E
->getBase());
1127 Record
.AddStmt(E
->getUpdater());
1128 Code
= serialization::EXPR_DESIGNATED_INIT_UPDATE
;
1131 void ASTStmtWriter::VisitNoInitExpr(NoInitExpr
*E
) {
1133 Code
= serialization::EXPR_NO_INIT
;
1136 void ASTStmtWriter::VisitArrayInitLoopExpr(ArrayInitLoopExpr
*E
) {
1138 Record
.AddStmt(E
->SubExprs
[0]);
1139 Record
.AddStmt(E
->SubExprs
[1]);
1140 Code
= serialization::EXPR_ARRAY_INIT_LOOP
;
1143 void ASTStmtWriter::VisitArrayInitIndexExpr(ArrayInitIndexExpr
*E
) {
1145 Code
= serialization::EXPR_ARRAY_INIT_INDEX
;
1148 void ASTStmtWriter::VisitImplicitValueInitExpr(ImplicitValueInitExpr
*E
) {
1150 Code
= serialization::EXPR_IMPLICIT_VALUE_INIT
;
1153 void ASTStmtWriter::VisitVAArgExpr(VAArgExpr
*E
) {
1155 Record
.AddStmt(E
->getSubExpr());
1156 Record
.AddTypeSourceInfo(E
->getWrittenTypeInfo());
1157 Record
.AddSourceLocation(E
->getBuiltinLoc());
1158 Record
.AddSourceLocation(E
->getRParenLoc());
1159 Record
.push_back(E
->isMicrosoftABI());
1160 Code
= serialization::EXPR_VA_ARG
;
1163 void ASTStmtWriter::VisitSourceLocExpr(SourceLocExpr
*E
) {
1165 Record
.AddDeclRef(cast_or_null
<Decl
>(E
->getParentContext()));
1166 Record
.AddSourceLocation(E
->getBeginLoc());
1167 Record
.AddSourceLocation(E
->getEndLoc());
1168 Record
.push_back(E
->getIdentKind());
1169 Code
= serialization::EXPR_SOURCE_LOC
;
1172 void ASTStmtWriter::VisitAddrLabelExpr(AddrLabelExpr
*E
) {
1174 Record
.AddSourceLocation(E
->getAmpAmpLoc());
1175 Record
.AddSourceLocation(E
->getLabelLoc());
1176 Record
.AddDeclRef(E
->getLabel());
1177 Code
= serialization::EXPR_ADDR_LABEL
;
1180 void ASTStmtWriter::VisitStmtExpr(StmtExpr
*E
) {
1182 Record
.AddStmt(E
->getSubStmt());
1183 Record
.AddSourceLocation(E
->getLParenLoc());
1184 Record
.AddSourceLocation(E
->getRParenLoc());
1185 Record
.push_back(E
->getTemplateDepth());
1186 Code
= serialization::EXPR_STMT
;
1189 void ASTStmtWriter::VisitChooseExpr(ChooseExpr
*E
) {
1191 Record
.AddStmt(E
->getCond());
1192 Record
.AddStmt(E
->getLHS());
1193 Record
.AddStmt(E
->getRHS());
1194 Record
.AddSourceLocation(E
->getBuiltinLoc());
1195 Record
.AddSourceLocation(E
->getRParenLoc());
1196 Record
.push_back(E
->isConditionDependent() ? false : E
->isConditionTrue());
1197 Code
= serialization::EXPR_CHOOSE
;
1200 void ASTStmtWriter::VisitGNUNullExpr(GNUNullExpr
*E
) {
1202 Record
.AddSourceLocation(E
->getTokenLocation());
1203 Code
= serialization::EXPR_GNU_NULL
;
1206 void ASTStmtWriter::VisitShuffleVectorExpr(ShuffleVectorExpr
*E
) {
1208 Record
.push_back(E
->getNumSubExprs());
1209 for (unsigned I
= 0, N
= E
->getNumSubExprs(); I
!= N
; ++I
)
1210 Record
.AddStmt(E
->getExpr(I
));
1211 Record
.AddSourceLocation(E
->getBuiltinLoc());
1212 Record
.AddSourceLocation(E
->getRParenLoc());
1213 Code
= serialization::EXPR_SHUFFLE_VECTOR
;
1216 void ASTStmtWriter::VisitConvertVectorExpr(ConvertVectorExpr
*E
) {
1218 Record
.AddSourceLocation(E
->getBuiltinLoc());
1219 Record
.AddSourceLocation(E
->getRParenLoc());
1220 Record
.AddTypeSourceInfo(E
->getTypeSourceInfo());
1221 Record
.AddStmt(E
->getSrcExpr());
1222 Code
= serialization::EXPR_CONVERT_VECTOR
;
1225 void ASTStmtWriter::VisitBlockExpr(BlockExpr
*E
) {
1227 Record
.AddDeclRef(E
->getBlockDecl());
1228 Code
= serialization::EXPR_BLOCK
;
1231 void ASTStmtWriter::VisitGenericSelectionExpr(GenericSelectionExpr
*E
) {
1234 Record
.push_back(E
->getNumAssocs());
1235 Record
.push_back(E
->isExprPredicate());
1236 Record
.push_back(E
->ResultIndex
);
1237 Record
.AddSourceLocation(E
->getGenericLoc());
1238 Record
.AddSourceLocation(E
->getDefaultLoc());
1239 Record
.AddSourceLocation(E
->getRParenLoc());
1241 Stmt
**Stmts
= E
->getTrailingObjects
<Stmt
*>();
1242 // Add 1 to account for the controlling expression which is the first
1243 // expression in the trailing array of Stmt *. This is not needed for
1244 // the trailing array of TypeSourceInfo *.
1245 for (unsigned I
= 0, N
= E
->getNumAssocs() + 1; I
< N
; ++I
)
1246 Record
.AddStmt(Stmts
[I
]);
1248 TypeSourceInfo
**TSIs
= E
->getTrailingObjects
<TypeSourceInfo
*>();
1249 for (unsigned I
= 0, N
= E
->getNumAssocs(); I
< N
; ++I
)
1250 Record
.AddTypeSourceInfo(TSIs
[I
]);
1252 Code
= serialization::EXPR_GENERIC_SELECTION
;
1255 void ASTStmtWriter::VisitPseudoObjectExpr(PseudoObjectExpr
*E
) {
1257 Record
.push_back(E
->getNumSemanticExprs());
1259 // Push the result index. Currently, this needs to exactly match
1260 // the encoding used internally for ResultIndex.
1261 unsigned result
= E
->getResultExprIndex();
1262 result
= (result
== PseudoObjectExpr::NoResult
? 0 : result
+ 1);
1263 Record
.push_back(result
);
1265 Record
.AddStmt(E
->getSyntacticForm());
1266 for (PseudoObjectExpr::semantics_iterator
1267 i
= E
->semantics_begin(), e
= E
->semantics_end(); i
!= e
; ++i
) {
1270 Code
= serialization::EXPR_PSEUDO_OBJECT
;
1273 void ASTStmtWriter::VisitAtomicExpr(AtomicExpr
*E
) {
1275 Record
.push_back(E
->getOp());
1276 for (unsigned I
= 0, N
= E
->getNumSubExprs(); I
!= N
; ++I
)
1277 Record
.AddStmt(E
->getSubExprs()[I
]);
1278 Record
.AddSourceLocation(E
->getBuiltinLoc());
1279 Record
.AddSourceLocation(E
->getRParenLoc());
1280 Code
= serialization::EXPR_ATOMIC
;
1283 //===----------------------------------------------------------------------===//
1284 // Objective-C Expressions and Statements.
1285 //===----------------------------------------------------------------------===//
1287 void ASTStmtWriter::VisitObjCStringLiteral(ObjCStringLiteral
*E
) {
1289 Record
.AddStmt(E
->getString());
1290 Record
.AddSourceLocation(E
->getAtLoc());
1291 Code
= serialization::EXPR_OBJC_STRING_LITERAL
;
1294 void ASTStmtWriter::VisitObjCBoxedExpr(ObjCBoxedExpr
*E
) {
1296 Record
.AddStmt(E
->getSubExpr());
1297 Record
.AddDeclRef(E
->getBoxingMethod());
1298 Record
.AddSourceRange(E
->getSourceRange());
1299 Code
= serialization::EXPR_OBJC_BOXED_EXPRESSION
;
1302 void ASTStmtWriter::VisitObjCArrayLiteral(ObjCArrayLiteral
*E
) {
1304 Record
.push_back(E
->getNumElements());
1305 for (unsigned i
= 0; i
< E
->getNumElements(); i
++)
1306 Record
.AddStmt(E
->getElement(i
));
1307 Record
.AddDeclRef(E
->getArrayWithObjectsMethod());
1308 Record
.AddSourceRange(E
->getSourceRange());
1309 Code
= serialization::EXPR_OBJC_ARRAY_LITERAL
;
1312 void ASTStmtWriter::VisitObjCDictionaryLiteral(ObjCDictionaryLiteral
*E
) {
1314 Record
.push_back(E
->getNumElements());
1315 Record
.push_back(E
->HasPackExpansions
);
1316 for (unsigned i
= 0; i
< E
->getNumElements(); i
++) {
1317 ObjCDictionaryElement Element
= E
->getKeyValueElement(i
);
1318 Record
.AddStmt(Element
.Key
);
1319 Record
.AddStmt(Element
.Value
);
1320 if (E
->HasPackExpansions
) {
1321 Record
.AddSourceLocation(Element
.EllipsisLoc
);
1322 unsigned NumExpansions
= 0;
1323 if (Element
.NumExpansions
)
1324 NumExpansions
= *Element
.NumExpansions
+ 1;
1325 Record
.push_back(NumExpansions
);
1329 Record
.AddDeclRef(E
->getDictWithObjectsMethod());
1330 Record
.AddSourceRange(E
->getSourceRange());
1331 Code
= serialization::EXPR_OBJC_DICTIONARY_LITERAL
;
1334 void ASTStmtWriter::VisitObjCEncodeExpr(ObjCEncodeExpr
*E
) {
1336 Record
.AddTypeSourceInfo(E
->getEncodedTypeSourceInfo());
1337 Record
.AddSourceLocation(E
->getAtLoc());
1338 Record
.AddSourceLocation(E
->getRParenLoc());
1339 Code
= serialization::EXPR_OBJC_ENCODE
;
1342 void ASTStmtWriter::VisitObjCSelectorExpr(ObjCSelectorExpr
*E
) {
1344 Record
.AddSelectorRef(E
->getSelector());
1345 Record
.AddSourceLocation(E
->getAtLoc());
1346 Record
.AddSourceLocation(E
->getRParenLoc());
1347 Code
= serialization::EXPR_OBJC_SELECTOR_EXPR
;
1350 void ASTStmtWriter::VisitObjCProtocolExpr(ObjCProtocolExpr
*E
) {
1352 Record
.AddDeclRef(E
->getProtocol());
1353 Record
.AddSourceLocation(E
->getAtLoc());
1354 Record
.AddSourceLocation(E
->ProtoLoc
);
1355 Record
.AddSourceLocation(E
->getRParenLoc());
1356 Code
= serialization::EXPR_OBJC_PROTOCOL_EXPR
;
1359 void ASTStmtWriter::VisitObjCIvarRefExpr(ObjCIvarRefExpr
*E
) {
1361 Record
.AddDeclRef(E
->getDecl());
1362 Record
.AddSourceLocation(E
->getLocation());
1363 Record
.AddSourceLocation(E
->getOpLoc());
1364 Record
.AddStmt(E
->getBase());
1365 Record
.push_back(E
->isArrow());
1366 Record
.push_back(E
->isFreeIvar());
1367 Code
= serialization::EXPR_OBJC_IVAR_REF_EXPR
;
1370 void ASTStmtWriter::VisitObjCPropertyRefExpr(ObjCPropertyRefExpr
*E
) {
1372 Record
.push_back(E
->SetterAndMethodRefFlags
.getInt());
1373 Record
.push_back(E
->isImplicitProperty());
1374 if (E
->isImplicitProperty()) {
1375 Record
.AddDeclRef(E
->getImplicitPropertyGetter());
1376 Record
.AddDeclRef(E
->getImplicitPropertySetter());
1378 Record
.AddDeclRef(E
->getExplicitProperty());
1380 Record
.AddSourceLocation(E
->getLocation());
1381 Record
.AddSourceLocation(E
->getReceiverLocation());
1382 if (E
->isObjectReceiver()) {
1383 Record
.push_back(0);
1384 Record
.AddStmt(E
->getBase());
1385 } else if (E
->isSuperReceiver()) {
1386 Record
.push_back(1);
1387 Record
.AddTypeRef(E
->getSuperReceiverType());
1389 Record
.push_back(2);
1390 Record
.AddDeclRef(E
->getClassReceiver());
1393 Code
= serialization::EXPR_OBJC_PROPERTY_REF_EXPR
;
1396 void ASTStmtWriter::VisitObjCSubscriptRefExpr(ObjCSubscriptRefExpr
*E
) {
1398 Record
.AddSourceLocation(E
->getRBracket());
1399 Record
.AddStmt(E
->getBaseExpr());
1400 Record
.AddStmt(E
->getKeyExpr());
1401 Record
.AddDeclRef(E
->getAtIndexMethodDecl());
1402 Record
.AddDeclRef(E
->setAtIndexMethodDecl());
1404 Code
= serialization::EXPR_OBJC_SUBSCRIPT_REF_EXPR
;
1407 void ASTStmtWriter::VisitObjCMessageExpr(ObjCMessageExpr
*E
) {
1409 Record
.push_back(E
->getNumArgs());
1410 Record
.push_back(E
->getNumStoredSelLocs());
1411 Record
.push_back(E
->SelLocsKind
);
1412 Record
.push_back(E
->isDelegateInitCall());
1413 Record
.push_back(E
->IsImplicit
);
1414 Record
.push_back((unsigned)E
->getReceiverKind()); // FIXME: stable encoding
1415 switch (E
->getReceiverKind()) {
1416 case ObjCMessageExpr::Instance
:
1417 Record
.AddStmt(E
->getInstanceReceiver());
1420 case ObjCMessageExpr::Class
:
1421 Record
.AddTypeSourceInfo(E
->getClassReceiverTypeInfo());
1424 case ObjCMessageExpr::SuperClass
:
1425 case ObjCMessageExpr::SuperInstance
:
1426 Record
.AddTypeRef(E
->getSuperType());
1427 Record
.AddSourceLocation(E
->getSuperLoc());
1431 if (E
->getMethodDecl()) {
1432 Record
.push_back(1);
1433 Record
.AddDeclRef(E
->getMethodDecl());
1435 Record
.push_back(0);
1436 Record
.AddSelectorRef(E
->getSelector());
1439 Record
.AddSourceLocation(E
->getLeftLoc());
1440 Record
.AddSourceLocation(E
->getRightLoc());
1442 for (CallExpr::arg_iterator Arg
= E
->arg_begin(), ArgEnd
= E
->arg_end();
1443 Arg
!= ArgEnd
; ++Arg
)
1444 Record
.AddStmt(*Arg
);
1446 SourceLocation
*Locs
= E
->getStoredSelLocs();
1447 for (unsigned i
= 0, e
= E
->getNumStoredSelLocs(); i
!= e
; ++i
)
1448 Record
.AddSourceLocation(Locs
[i
]);
1450 Code
= serialization::EXPR_OBJC_MESSAGE_EXPR
;
1453 void ASTStmtWriter::VisitObjCForCollectionStmt(ObjCForCollectionStmt
*S
) {
1455 Record
.AddStmt(S
->getElement());
1456 Record
.AddStmt(S
->getCollection());
1457 Record
.AddStmt(S
->getBody());
1458 Record
.AddSourceLocation(S
->getForLoc());
1459 Record
.AddSourceLocation(S
->getRParenLoc());
1460 Code
= serialization::STMT_OBJC_FOR_COLLECTION
;
1463 void ASTStmtWriter::VisitObjCAtCatchStmt(ObjCAtCatchStmt
*S
) {
1465 Record
.AddStmt(S
->getCatchBody());
1466 Record
.AddDeclRef(S
->getCatchParamDecl());
1467 Record
.AddSourceLocation(S
->getAtCatchLoc());
1468 Record
.AddSourceLocation(S
->getRParenLoc());
1469 Code
= serialization::STMT_OBJC_CATCH
;
1472 void ASTStmtWriter::VisitObjCAtFinallyStmt(ObjCAtFinallyStmt
*S
) {
1474 Record
.AddStmt(S
->getFinallyBody());
1475 Record
.AddSourceLocation(S
->getAtFinallyLoc());
1476 Code
= serialization::STMT_OBJC_FINALLY
;
1479 void ASTStmtWriter::VisitObjCAutoreleasePoolStmt(ObjCAutoreleasePoolStmt
*S
) {
1480 VisitStmt(S
); // FIXME: no test coverage.
1481 Record
.AddStmt(S
->getSubStmt());
1482 Record
.AddSourceLocation(S
->getAtLoc());
1483 Code
= serialization::STMT_OBJC_AUTORELEASE_POOL
;
1486 void ASTStmtWriter::VisitObjCAtTryStmt(ObjCAtTryStmt
*S
) {
1488 Record
.push_back(S
->getNumCatchStmts());
1489 Record
.push_back(S
->getFinallyStmt() != nullptr);
1490 Record
.AddStmt(S
->getTryBody());
1491 for (ObjCAtCatchStmt
*C
: S
->catch_stmts())
1493 if (S
->getFinallyStmt())
1494 Record
.AddStmt(S
->getFinallyStmt());
1495 Record
.AddSourceLocation(S
->getAtTryLoc());
1496 Code
= serialization::STMT_OBJC_AT_TRY
;
1499 void ASTStmtWriter::VisitObjCAtSynchronizedStmt(ObjCAtSynchronizedStmt
*S
) {
1500 VisitStmt(S
); // FIXME: no test coverage.
1501 Record
.AddStmt(S
->getSynchExpr());
1502 Record
.AddStmt(S
->getSynchBody());
1503 Record
.AddSourceLocation(S
->getAtSynchronizedLoc());
1504 Code
= serialization::STMT_OBJC_AT_SYNCHRONIZED
;
1507 void ASTStmtWriter::VisitObjCAtThrowStmt(ObjCAtThrowStmt
*S
) {
1508 VisitStmt(S
); // FIXME: no test coverage.
1509 Record
.AddStmt(S
->getThrowExpr());
1510 Record
.AddSourceLocation(S
->getThrowLoc());
1511 Code
= serialization::STMT_OBJC_AT_THROW
;
1514 void ASTStmtWriter::VisitObjCBoolLiteralExpr(ObjCBoolLiteralExpr
*E
) {
1516 Record
.push_back(E
->getValue());
1517 Record
.AddSourceLocation(E
->getLocation());
1518 Code
= serialization::EXPR_OBJC_BOOL_LITERAL
;
1521 void ASTStmtWriter::VisitObjCAvailabilityCheckExpr(ObjCAvailabilityCheckExpr
*E
) {
1523 Record
.AddSourceRange(E
->getSourceRange());
1524 Record
.AddVersionTuple(E
->getVersion());
1525 Code
= serialization::EXPR_OBJC_AVAILABILITY_CHECK
;
1528 //===----------------------------------------------------------------------===//
1529 // C++ Expressions and Statements.
1530 //===----------------------------------------------------------------------===//
1532 void ASTStmtWriter::VisitCXXCatchStmt(CXXCatchStmt
*S
) {
1534 Record
.AddSourceLocation(S
->getCatchLoc());
1535 Record
.AddDeclRef(S
->getExceptionDecl());
1536 Record
.AddStmt(S
->getHandlerBlock());
1537 Code
= serialization::STMT_CXX_CATCH
;
1540 void ASTStmtWriter::VisitCXXTryStmt(CXXTryStmt
*S
) {
1542 Record
.push_back(S
->getNumHandlers());
1543 Record
.AddSourceLocation(S
->getTryLoc());
1544 Record
.AddStmt(S
->getTryBlock());
1545 for (unsigned i
= 0, e
= S
->getNumHandlers(); i
!= e
; ++i
)
1546 Record
.AddStmt(S
->getHandler(i
));
1547 Code
= serialization::STMT_CXX_TRY
;
1550 void ASTStmtWriter::VisitCXXForRangeStmt(CXXForRangeStmt
*S
) {
1552 Record
.AddSourceLocation(S
->getForLoc());
1553 Record
.AddSourceLocation(S
->getCoawaitLoc());
1554 Record
.AddSourceLocation(S
->getColonLoc());
1555 Record
.AddSourceLocation(S
->getRParenLoc());
1556 Record
.AddStmt(S
->getInit());
1557 Record
.AddStmt(S
->getRangeStmt());
1558 Record
.AddStmt(S
->getBeginStmt());
1559 Record
.AddStmt(S
->getEndStmt());
1560 Record
.AddStmt(S
->getCond());
1561 Record
.AddStmt(S
->getInc());
1562 Record
.AddStmt(S
->getLoopVarStmt());
1563 Record
.AddStmt(S
->getBody());
1564 Code
= serialization::STMT_CXX_FOR_RANGE
;
1567 void ASTStmtWriter::VisitMSDependentExistsStmt(MSDependentExistsStmt
*S
) {
1569 Record
.AddSourceLocation(S
->getKeywordLoc());
1570 Record
.push_back(S
->isIfExists());
1571 Record
.AddNestedNameSpecifierLoc(S
->getQualifierLoc());
1572 Record
.AddDeclarationNameInfo(S
->getNameInfo());
1573 Record
.AddStmt(S
->getSubStmt());
1574 Code
= serialization::STMT_MS_DEPENDENT_EXISTS
;
1577 void ASTStmtWriter::VisitCXXOperatorCallExpr(CXXOperatorCallExpr
*E
) {
1579 Record
.push_back(E
->getOperator());
1580 Record
.AddSourceRange(E
->Range
);
1581 Code
= serialization::EXPR_CXX_OPERATOR_CALL
;
1584 void ASTStmtWriter::VisitCXXMemberCallExpr(CXXMemberCallExpr
*E
) {
1586 Code
= serialization::EXPR_CXX_MEMBER_CALL
;
1589 void ASTStmtWriter::VisitCXXRewrittenBinaryOperator(
1590 CXXRewrittenBinaryOperator
*E
) {
1592 Record
.push_back(E
->isReversed());
1593 Record
.AddStmt(E
->getSemanticForm());
1594 Code
= serialization::EXPR_CXX_REWRITTEN_BINARY_OPERATOR
;
1597 void ASTStmtWriter::VisitCXXConstructExpr(CXXConstructExpr
*E
) {
1600 Record
.push_back(E
->getNumArgs());
1601 Record
.push_back(E
->isElidable());
1602 Record
.push_back(E
->hadMultipleCandidates());
1603 Record
.push_back(E
->isListInitialization());
1604 Record
.push_back(E
->isStdInitListInitialization());
1605 Record
.push_back(E
->requiresZeroInitialization());
1606 Record
.push_back(E
->getConstructionKind()); // FIXME: stable encoding
1607 Record
.push_back(E
->isImmediateEscalating());
1608 Record
.AddSourceLocation(E
->getLocation());
1609 Record
.AddDeclRef(E
->getConstructor());
1610 Record
.AddSourceRange(E
->getParenOrBraceRange());
1612 for (unsigned I
= 0, N
= E
->getNumArgs(); I
!= N
; ++I
)
1613 Record
.AddStmt(E
->getArg(I
));
1615 Code
= serialization::EXPR_CXX_CONSTRUCT
;
1618 void ASTStmtWriter::VisitCXXInheritedCtorInitExpr(CXXInheritedCtorInitExpr
*E
) {
1620 Record
.AddDeclRef(E
->getConstructor());
1621 Record
.AddSourceLocation(E
->getLocation());
1622 Record
.push_back(E
->constructsVBase());
1623 Record
.push_back(E
->inheritedFromVBase());
1624 Code
= serialization::EXPR_CXX_INHERITED_CTOR_INIT
;
1627 void ASTStmtWriter::VisitCXXTemporaryObjectExpr(CXXTemporaryObjectExpr
*E
) {
1628 VisitCXXConstructExpr(E
);
1629 Record
.AddTypeSourceInfo(E
->getTypeSourceInfo());
1630 Code
= serialization::EXPR_CXX_TEMPORARY_OBJECT
;
1633 void ASTStmtWriter::VisitLambdaExpr(LambdaExpr
*E
) {
1635 Record
.push_back(E
->LambdaExprBits
.NumCaptures
);
1636 Record
.AddSourceRange(E
->IntroducerRange
);
1637 Record
.push_back(E
->LambdaExprBits
.CaptureDefault
); // FIXME: stable encoding
1638 Record
.AddSourceLocation(E
->CaptureDefaultLoc
);
1639 Record
.push_back(E
->LambdaExprBits
.ExplicitParams
);
1640 Record
.push_back(E
->LambdaExprBits
.ExplicitResultType
);
1641 Record
.AddSourceLocation(E
->ClosingBrace
);
1643 // Add capture initializers.
1644 for (LambdaExpr::capture_init_iterator C
= E
->capture_init_begin(),
1645 CEnd
= E
->capture_init_end();
1650 // Don't serialize the body. It belongs to the call operator declaration.
1651 // LambdaExpr only stores a copy of the Stmt *.
1653 Code
= serialization::EXPR_LAMBDA
;
1656 void ASTStmtWriter::VisitCXXStdInitializerListExpr(CXXStdInitializerListExpr
*E
) {
1658 Record
.AddStmt(E
->getSubExpr());
1659 Code
= serialization::EXPR_CXX_STD_INITIALIZER_LIST
;
1662 void ASTStmtWriter::VisitCXXNamedCastExpr(CXXNamedCastExpr
*E
) {
1663 VisitExplicitCastExpr(E
);
1664 Record
.AddSourceRange(SourceRange(E
->getOperatorLoc(), E
->getRParenLoc()));
1665 Record
.AddSourceRange(E
->getAngleBrackets());
1668 void ASTStmtWriter::VisitCXXStaticCastExpr(CXXStaticCastExpr
*E
) {
1669 VisitCXXNamedCastExpr(E
);
1670 Code
= serialization::EXPR_CXX_STATIC_CAST
;
1673 void ASTStmtWriter::VisitCXXDynamicCastExpr(CXXDynamicCastExpr
*E
) {
1674 VisitCXXNamedCastExpr(E
);
1675 Code
= serialization::EXPR_CXX_DYNAMIC_CAST
;
1678 void ASTStmtWriter::VisitCXXReinterpretCastExpr(CXXReinterpretCastExpr
*E
) {
1679 VisitCXXNamedCastExpr(E
);
1680 Code
= serialization::EXPR_CXX_REINTERPRET_CAST
;
1683 void ASTStmtWriter::VisitCXXConstCastExpr(CXXConstCastExpr
*E
) {
1684 VisitCXXNamedCastExpr(E
);
1685 Code
= serialization::EXPR_CXX_CONST_CAST
;
1688 void ASTStmtWriter::VisitCXXAddrspaceCastExpr(CXXAddrspaceCastExpr
*E
) {
1689 VisitCXXNamedCastExpr(E
);
1690 Code
= serialization::EXPR_CXX_ADDRSPACE_CAST
;
1693 void ASTStmtWriter::VisitCXXFunctionalCastExpr(CXXFunctionalCastExpr
*E
) {
1694 VisitExplicitCastExpr(E
);
1695 Record
.AddSourceLocation(E
->getLParenLoc());
1696 Record
.AddSourceLocation(E
->getRParenLoc());
1697 Code
= serialization::EXPR_CXX_FUNCTIONAL_CAST
;
1700 void ASTStmtWriter::VisitBuiltinBitCastExpr(BuiltinBitCastExpr
*E
) {
1701 VisitExplicitCastExpr(E
);
1702 Record
.AddSourceLocation(E
->getBeginLoc());
1703 Record
.AddSourceLocation(E
->getEndLoc());
1704 Code
= serialization::EXPR_BUILTIN_BIT_CAST
;
1707 void ASTStmtWriter::VisitUserDefinedLiteral(UserDefinedLiteral
*E
) {
1709 Record
.AddSourceLocation(E
->UDSuffixLoc
);
1710 Code
= serialization::EXPR_USER_DEFINED_LITERAL
;
1713 void ASTStmtWriter::VisitCXXBoolLiteralExpr(CXXBoolLiteralExpr
*E
) {
1715 Record
.push_back(E
->getValue());
1716 Record
.AddSourceLocation(E
->getLocation());
1717 Code
= serialization::EXPR_CXX_BOOL_LITERAL
;
1720 void ASTStmtWriter::VisitCXXNullPtrLiteralExpr(CXXNullPtrLiteralExpr
*E
) {
1722 Record
.AddSourceLocation(E
->getLocation());
1723 Code
= serialization::EXPR_CXX_NULL_PTR_LITERAL
;
1726 void ASTStmtWriter::VisitCXXTypeidExpr(CXXTypeidExpr
*E
) {
1728 Record
.AddSourceRange(E
->getSourceRange());
1729 if (E
->isTypeOperand()) {
1730 Record
.AddTypeSourceInfo(E
->getTypeOperandSourceInfo());
1731 Code
= serialization::EXPR_CXX_TYPEID_TYPE
;
1733 Record
.AddStmt(E
->getExprOperand());
1734 Code
= serialization::EXPR_CXX_TYPEID_EXPR
;
1738 void ASTStmtWriter::VisitCXXThisExpr(CXXThisExpr
*E
) {
1740 Record
.AddSourceLocation(E
->getLocation());
1741 Record
.push_back(E
->isImplicit());
1742 Code
= serialization::EXPR_CXX_THIS
;
1745 void ASTStmtWriter::VisitCXXThrowExpr(CXXThrowExpr
*E
) {
1747 Record
.AddSourceLocation(E
->getThrowLoc());
1748 Record
.AddStmt(E
->getSubExpr());
1749 Record
.push_back(E
->isThrownVariableInScope());
1750 Code
= serialization::EXPR_CXX_THROW
;
1753 void ASTStmtWriter::VisitCXXDefaultArgExpr(CXXDefaultArgExpr
*E
) {
1755 Record
.AddDeclRef(E
->getParam());
1756 Record
.AddDeclRef(cast_or_null
<Decl
>(E
->getUsedContext()));
1757 Record
.AddSourceLocation(E
->getUsedLocation());
1758 Record
.push_back(E
->hasRewrittenInit());
1759 if (E
->hasRewrittenInit())
1760 Record
.AddStmt(E
->getRewrittenExpr());
1761 Code
= serialization::EXPR_CXX_DEFAULT_ARG
;
1764 void ASTStmtWriter::VisitCXXDefaultInitExpr(CXXDefaultInitExpr
*E
) {
1766 Record
.push_back(E
->hasRewrittenInit());
1767 Record
.AddDeclRef(E
->getField());
1768 Record
.AddDeclRef(cast_or_null
<Decl
>(E
->getUsedContext()));
1769 Record
.AddSourceLocation(E
->getExprLoc());
1770 if (E
->hasRewrittenInit())
1771 Record
.AddStmt(E
->getRewrittenExpr());
1772 Code
= serialization::EXPR_CXX_DEFAULT_INIT
;
1775 void ASTStmtWriter::VisitCXXBindTemporaryExpr(CXXBindTemporaryExpr
*E
) {
1777 Record
.AddCXXTemporary(E
->getTemporary());
1778 Record
.AddStmt(E
->getSubExpr());
1779 Code
= serialization::EXPR_CXX_BIND_TEMPORARY
;
1782 void ASTStmtWriter::VisitCXXScalarValueInitExpr(CXXScalarValueInitExpr
*E
) {
1784 Record
.AddTypeSourceInfo(E
->getTypeSourceInfo());
1785 Record
.AddSourceLocation(E
->getRParenLoc());
1786 Code
= serialization::EXPR_CXX_SCALAR_VALUE_INIT
;
1789 void ASTStmtWriter::VisitCXXNewExpr(CXXNewExpr
*E
) {
1792 Record
.push_back(E
->isArray());
1793 Record
.push_back(E
->hasInitializer());
1794 Record
.push_back(E
->getNumPlacementArgs());
1795 Record
.push_back(E
->isParenTypeId());
1797 Record
.push_back(E
->isGlobalNew());
1798 Record
.push_back(E
->passAlignment());
1799 Record
.push_back(E
->doesUsualArrayDeleteWantSize());
1800 Record
.push_back(E
->CXXNewExprBits
.StoredInitializationStyle
);
1802 Record
.AddDeclRef(E
->getOperatorNew());
1803 Record
.AddDeclRef(E
->getOperatorDelete());
1804 Record
.AddTypeSourceInfo(E
->getAllocatedTypeSourceInfo());
1805 if (E
->isParenTypeId())
1806 Record
.AddSourceRange(E
->getTypeIdParens());
1807 Record
.AddSourceRange(E
->getSourceRange());
1808 Record
.AddSourceRange(E
->getDirectInitRange());
1810 for (CXXNewExpr::arg_iterator I
= E
->raw_arg_begin(), N
= E
->raw_arg_end();
1814 Code
= serialization::EXPR_CXX_NEW
;
1817 void ASTStmtWriter::VisitCXXDeleteExpr(CXXDeleteExpr
*E
) {
1819 Record
.push_back(E
->isGlobalDelete());
1820 Record
.push_back(E
->isArrayForm());
1821 Record
.push_back(E
->isArrayFormAsWritten());
1822 Record
.push_back(E
->doesUsualArrayDeleteWantSize());
1823 Record
.AddDeclRef(E
->getOperatorDelete());
1824 Record
.AddStmt(E
->getArgument());
1825 Record
.AddSourceLocation(E
->getBeginLoc());
1827 Code
= serialization::EXPR_CXX_DELETE
;
1830 void ASTStmtWriter::VisitCXXPseudoDestructorExpr(CXXPseudoDestructorExpr
*E
) {
1833 Record
.AddStmt(E
->getBase());
1834 Record
.push_back(E
->isArrow());
1835 Record
.AddSourceLocation(E
->getOperatorLoc());
1836 Record
.AddNestedNameSpecifierLoc(E
->getQualifierLoc());
1837 Record
.AddTypeSourceInfo(E
->getScopeTypeInfo());
1838 Record
.AddSourceLocation(E
->getColonColonLoc());
1839 Record
.AddSourceLocation(E
->getTildeLoc());
1841 // PseudoDestructorTypeStorage.
1842 Record
.AddIdentifierRef(E
->getDestroyedTypeIdentifier());
1843 if (E
->getDestroyedTypeIdentifier())
1844 Record
.AddSourceLocation(E
->getDestroyedTypeLoc());
1846 Record
.AddTypeSourceInfo(E
->getDestroyedTypeInfo());
1848 Code
= serialization::EXPR_CXX_PSEUDO_DESTRUCTOR
;
1851 void ASTStmtWriter::VisitExprWithCleanups(ExprWithCleanups
*E
) {
1853 Record
.push_back(E
->getNumObjects());
1854 for (auto &Obj
: E
->getObjects()) {
1855 if (auto *BD
= Obj
.dyn_cast
<BlockDecl
*>()) {
1856 Record
.push_back(serialization::COK_Block
);
1857 Record
.AddDeclRef(BD
);
1858 } else if (auto *CLE
= Obj
.dyn_cast
<CompoundLiteralExpr
*>()) {
1859 Record
.push_back(serialization::COK_CompoundLiteral
);
1860 Record
.AddStmt(CLE
);
1864 Record
.push_back(E
->cleanupsHaveSideEffects());
1865 Record
.AddStmt(E
->getSubExpr());
1866 Code
= serialization::EXPR_EXPR_WITH_CLEANUPS
;
1869 void ASTStmtWriter::VisitCXXDependentScopeMemberExpr(
1870 CXXDependentScopeMemberExpr
*E
) {
1873 // Don't emit anything here (or if you do you will have to update
1874 // the corresponding deserialization function).
1876 Record
.push_back(E
->hasTemplateKWAndArgsInfo());
1877 Record
.push_back(E
->getNumTemplateArgs());
1878 Record
.push_back(E
->hasFirstQualifierFoundInScope());
1880 if (E
->hasTemplateKWAndArgsInfo()) {
1881 const ASTTemplateKWAndArgsInfo
&ArgInfo
=
1882 *E
->getTrailingObjects
<ASTTemplateKWAndArgsInfo
>();
1883 AddTemplateKWAndArgsInfo(ArgInfo
,
1884 E
->getTrailingObjects
<TemplateArgumentLoc
>());
1887 Record
.push_back(E
->isArrow());
1888 Record
.AddSourceLocation(E
->getOperatorLoc());
1889 Record
.AddTypeRef(E
->getBaseType());
1890 Record
.AddNestedNameSpecifierLoc(E
->getQualifierLoc());
1891 if (!E
->isImplicitAccess())
1892 Record
.AddStmt(E
->getBase());
1894 Record
.AddStmt(nullptr);
1896 if (E
->hasFirstQualifierFoundInScope())
1897 Record
.AddDeclRef(E
->getFirstQualifierFoundInScope());
1899 Record
.AddDeclarationNameInfo(E
->MemberNameInfo
);
1900 Code
= serialization::EXPR_CXX_DEPENDENT_SCOPE_MEMBER
;
1904 ASTStmtWriter::VisitDependentScopeDeclRefExpr(DependentScopeDeclRefExpr
*E
) {
1907 // Don't emit anything here, HasTemplateKWAndArgsInfo must be
1910 Record
.push_back(E
->DependentScopeDeclRefExprBits
.HasTemplateKWAndArgsInfo
);
1911 if (E
->DependentScopeDeclRefExprBits
.HasTemplateKWAndArgsInfo
) {
1912 const ASTTemplateKWAndArgsInfo
&ArgInfo
=
1913 *E
->getTrailingObjects
<ASTTemplateKWAndArgsInfo
>();
1914 Record
.push_back(ArgInfo
.NumTemplateArgs
);
1915 AddTemplateKWAndArgsInfo(ArgInfo
,
1916 E
->getTrailingObjects
<TemplateArgumentLoc
>());
1919 Record
.AddNestedNameSpecifierLoc(E
->getQualifierLoc());
1920 Record
.AddDeclarationNameInfo(E
->NameInfo
);
1921 Code
= serialization::EXPR_CXX_DEPENDENT_SCOPE_DECL_REF
;
1925 ASTStmtWriter::VisitCXXUnresolvedConstructExpr(CXXUnresolvedConstructExpr
*E
) {
1927 Record
.push_back(E
->getNumArgs());
1928 for (CXXUnresolvedConstructExpr::arg_iterator
1929 ArgI
= E
->arg_begin(), ArgE
= E
->arg_end(); ArgI
!= ArgE
; ++ArgI
)
1930 Record
.AddStmt(*ArgI
);
1931 Record
.AddTypeSourceInfo(E
->getTypeSourceInfo());
1932 Record
.AddSourceLocation(E
->getLParenLoc());
1933 Record
.AddSourceLocation(E
->getRParenLoc());
1934 Record
.push_back(E
->isListInitialization());
1935 Code
= serialization::EXPR_CXX_UNRESOLVED_CONSTRUCT
;
1938 void ASTStmtWriter::VisitOverloadExpr(OverloadExpr
*E
) {
1941 Record
.push_back(E
->getNumDecls());
1942 Record
.push_back(E
->hasTemplateKWAndArgsInfo());
1943 if (E
->hasTemplateKWAndArgsInfo()) {
1944 const ASTTemplateKWAndArgsInfo
&ArgInfo
=
1945 *E
->getTrailingASTTemplateKWAndArgsInfo();
1946 Record
.push_back(ArgInfo
.NumTemplateArgs
);
1947 AddTemplateKWAndArgsInfo(ArgInfo
, E
->getTrailingTemplateArgumentLoc());
1950 for (OverloadExpr::decls_iterator OvI
= E
->decls_begin(),
1951 OvE
= E
->decls_end();
1952 OvI
!= OvE
; ++OvI
) {
1953 Record
.AddDeclRef(OvI
.getDecl());
1954 Record
.push_back(OvI
.getAccess());
1957 Record
.AddDeclarationNameInfo(E
->getNameInfo());
1958 Record
.AddNestedNameSpecifierLoc(E
->getQualifierLoc());
1961 void ASTStmtWriter::VisitUnresolvedMemberExpr(UnresolvedMemberExpr
*E
) {
1962 VisitOverloadExpr(E
);
1963 Record
.push_back(E
->isArrow());
1964 Record
.push_back(E
->hasUnresolvedUsing());
1965 Record
.AddStmt(!E
->isImplicitAccess() ? E
->getBase() : nullptr);
1966 Record
.AddTypeRef(E
->getBaseType());
1967 Record
.AddSourceLocation(E
->getOperatorLoc());
1968 Code
= serialization::EXPR_CXX_UNRESOLVED_MEMBER
;
1971 void ASTStmtWriter::VisitUnresolvedLookupExpr(UnresolvedLookupExpr
*E
) {
1972 VisitOverloadExpr(E
);
1973 Record
.push_back(E
->requiresADL());
1974 Record
.push_back(E
->isOverloaded());
1975 Record
.AddDeclRef(E
->getNamingClass());
1976 Code
= serialization::EXPR_CXX_UNRESOLVED_LOOKUP
;
1979 void ASTStmtWriter::VisitTypeTraitExpr(TypeTraitExpr
*E
) {
1981 Record
.push_back(E
->TypeTraitExprBits
.NumArgs
);
1982 Record
.push_back(E
->TypeTraitExprBits
.Kind
); // FIXME: Stable encoding
1983 Record
.push_back(E
->TypeTraitExprBits
.Value
);
1984 Record
.AddSourceRange(E
->getSourceRange());
1985 for (unsigned I
= 0, N
= E
->getNumArgs(); I
!= N
; ++I
)
1986 Record
.AddTypeSourceInfo(E
->getArg(I
));
1987 Code
= serialization::EXPR_TYPE_TRAIT
;
1990 void ASTStmtWriter::VisitArrayTypeTraitExpr(ArrayTypeTraitExpr
*E
) {
1992 Record
.push_back(E
->getTrait());
1993 Record
.push_back(E
->getValue());
1994 Record
.AddSourceRange(E
->getSourceRange());
1995 Record
.AddTypeSourceInfo(E
->getQueriedTypeSourceInfo());
1996 Record
.AddStmt(E
->getDimensionExpression());
1997 Code
= serialization::EXPR_ARRAY_TYPE_TRAIT
;
2000 void ASTStmtWriter::VisitExpressionTraitExpr(ExpressionTraitExpr
*E
) {
2002 Record
.push_back(E
->getTrait());
2003 Record
.push_back(E
->getValue());
2004 Record
.AddSourceRange(E
->getSourceRange());
2005 Record
.AddStmt(E
->getQueriedExpression());
2006 Code
= serialization::EXPR_CXX_EXPRESSION_TRAIT
;
2009 void ASTStmtWriter::VisitCXXNoexceptExpr(CXXNoexceptExpr
*E
) {
2011 Record
.push_back(E
->getValue());
2012 Record
.AddSourceRange(E
->getSourceRange());
2013 Record
.AddStmt(E
->getOperand());
2014 Code
= serialization::EXPR_CXX_NOEXCEPT
;
2017 void ASTStmtWriter::VisitPackExpansionExpr(PackExpansionExpr
*E
) {
2019 Record
.AddSourceLocation(E
->getEllipsisLoc());
2020 Record
.push_back(E
->NumExpansions
);
2021 Record
.AddStmt(E
->getPattern());
2022 Code
= serialization::EXPR_PACK_EXPANSION
;
2025 void ASTStmtWriter::VisitSizeOfPackExpr(SizeOfPackExpr
*E
) {
2027 Record
.push_back(E
->isPartiallySubstituted() ? E
->getPartialArguments().size()
2029 Record
.AddSourceLocation(E
->OperatorLoc
);
2030 Record
.AddSourceLocation(E
->PackLoc
);
2031 Record
.AddSourceLocation(E
->RParenLoc
);
2032 Record
.AddDeclRef(E
->Pack
);
2033 if (E
->isPartiallySubstituted()) {
2034 for (const auto &TA
: E
->getPartialArguments())
2035 Record
.AddTemplateArgument(TA
);
2036 } else if (!E
->isValueDependent()) {
2037 Record
.push_back(E
->getPackLength());
2039 Code
= serialization::EXPR_SIZEOF_PACK
;
2042 void ASTStmtWriter::VisitSubstNonTypeTemplateParmExpr(
2043 SubstNonTypeTemplateParmExpr
*E
) {
2045 Record
.AddDeclRef(E
->getAssociatedDecl());
2046 Record
.push_back(E
->isReferenceParameter());
2047 Record
.push_back(E
->getIndex());
2048 if (auto PackIndex
= E
->getPackIndex())
2049 Record
.push_back(*PackIndex
+ 1);
2051 Record
.push_back(0);
2052 Record
.AddSourceLocation(E
->getNameLoc());
2053 Record
.AddStmt(E
->getReplacement());
2054 Code
= serialization::EXPR_SUBST_NON_TYPE_TEMPLATE_PARM
;
2057 void ASTStmtWriter::VisitSubstNonTypeTemplateParmPackExpr(
2058 SubstNonTypeTemplateParmPackExpr
*E
) {
2060 Record
.AddDeclRef(E
->getAssociatedDecl());
2061 Record
.push_back(E
->getIndex());
2062 Record
.AddTemplateArgument(E
->getArgumentPack());
2063 Record
.AddSourceLocation(E
->getParameterPackLocation());
2064 Code
= serialization::EXPR_SUBST_NON_TYPE_TEMPLATE_PARM_PACK
;
2067 void ASTStmtWriter::VisitFunctionParmPackExpr(FunctionParmPackExpr
*E
) {
2069 Record
.push_back(E
->getNumExpansions());
2070 Record
.AddDeclRef(E
->getParameterPack());
2071 Record
.AddSourceLocation(E
->getParameterPackLocation());
2072 for (FunctionParmPackExpr::iterator I
= E
->begin(), End
= E
->end();
2074 Record
.AddDeclRef(*I
);
2075 Code
= serialization::EXPR_FUNCTION_PARM_PACK
;
2078 void ASTStmtWriter::VisitMaterializeTemporaryExpr(MaterializeTemporaryExpr
*E
) {
2080 Record
.push_back(static_cast<bool>(E
->getLifetimeExtendedTemporaryDecl()));
2081 if (E
->getLifetimeExtendedTemporaryDecl())
2082 Record
.AddDeclRef(E
->getLifetimeExtendedTemporaryDecl());
2084 Record
.AddStmt(E
->getSubExpr());
2085 Code
= serialization::EXPR_MATERIALIZE_TEMPORARY
;
2088 void ASTStmtWriter::VisitCXXFoldExpr(CXXFoldExpr
*E
) {
2090 Record
.AddSourceLocation(E
->LParenLoc
);
2091 Record
.AddSourceLocation(E
->EllipsisLoc
);
2092 Record
.AddSourceLocation(E
->RParenLoc
);
2093 Record
.push_back(E
->NumExpansions
);
2094 Record
.AddStmt(E
->SubExprs
[0]);
2095 Record
.AddStmt(E
->SubExprs
[1]);
2096 Record
.AddStmt(E
->SubExprs
[2]);
2097 Record
.push_back(E
->Opcode
);
2098 Code
= serialization::EXPR_CXX_FOLD
;
2101 void ASTStmtWriter::VisitCXXParenListInitExpr(CXXParenListInitExpr
*E
) {
2103 ArrayRef
<Expr
*> InitExprs
= E
->getInitExprs();
2104 Record
.push_back(InitExprs
.size());
2105 Record
.push_back(E
->getUserSpecifiedInitExprs().size());
2106 Record
.AddSourceLocation(E
->getInitLoc());
2107 Record
.AddSourceLocation(E
->getBeginLoc());
2108 Record
.AddSourceLocation(E
->getEndLoc());
2109 for (Expr
*InitExpr
: E
->getInitExprs())
2110 Record
.AddStmt(InitExpr
);
2111 Expr
*ArrayFiller
= E
->getArrayFiller();
2112 FieldDecl
*UnionField
= E
->getInitializedFieldInUnion();
2113 bool HasArrayFillerOrUnionDecl
= ArrayFiller
|| UnionField
;
2114 Record
.push_back(HasArrayFillerOrUnionDecl
);
2115 if (HasArrayFillerOrUnionDecl
) {
2116 Record
.push_back(static_cast<bool>(ArrayFiller
));
2118 Record
.AddStmt(ArrayFiller
);
2120 Record
.AddDeclRef(UnionField
);
2122 Code
= serialization::EXPR_CXX_PAREN_LIST_INIT
;
2125 void ASTStmtWriter::VisitOpaqueValueExpr(OpaqueValueExpr
*E
) {
2127 Record
.AddStmt(E
->getSourceExpr());
2128 Record
.AddSourceLocation(E
->getLocation());
2129 Record
.push_back(E
->isUnique());
2130 Code
= serialization::EXPR_OPAQUE_VALUE
;
2133 void ASTStmtWriter::VisitTypoExpr(TypoExpr
*E
) {
2135 // TODO: Figure out sane writer behavior for a TypoExpr, if necessary
2136 llvm_unreachable("Cannot write TypoExpr nodes");
2139 //===----------------------------------------------------------------------===//
2140 // CUDA Expressions and Statements.
2141 //===----------------------------------------------------------------------===//
2143 void ASTStmtWriter::VisitCUDAKernelCallExpr(CUDAKernelCallExpr
*E
) {
2145 Record
.AddStmt(E
->getConfig());
2146 Code
= serialization::EXPR_CUDA_KERNEL_CALL
;
2149 //===----------------------------------------------------------------------===//
2150 // OpenCL Expressions and Statements.
2151 //===----------------------------------------------------------------------===//
2152 void ASTStmtWriter::VisitAsTypeExpr(AsTypeExpr
*E
) {
2154 Record
.AddSourceLocation(E
->getBuiltinLoc());
2155 Record
.AddSourceLocation(E
->getRParenLoc());
2156 Record
.AddStmt(E
->getSrcExpr());
2157 Code
= serialization::EXPR_ASTYPE
;
2160 //===----------------------------------------------------------------------===//
2161 // Microsoft Expressions and Statements.
2162 //===----------------------------------------------------------------------===//
2163 void ASTStmtWriter::VisitMSPropertyRefExpr(MSPropertyRefExpr
*E
) {
2165 Record
.push_back(E
->isArrow());
2166 Record
.AddStmt(E
->getBaseExpr());
2167 Record
.AddNestedNameSpecifierLoc(E
->getQualifierLoc());
2168 Record
.AddSourceLocation(E
->getMemberLoc());
2169 Record
.AddDeclRef(E
->getPropertyDecl());
2170 Code
= serialization::EXPR_CXX_PROPERTY_REF_EXPR
;
2173 void ASTStmtWriter::VisitMSPropertySubscriptExpr(MSPropertySubscriptExpr
*E
) {
2175 Record
.AddStmt(E
->getBase());
2176 Record
.AddStmt(E
->getIdx());
2177 Record
.AddSourceLocation(E
->getRBracketLoc());
2178 Code
= serialization::EXPR_CXX_PROPERTY_SUBSCRIPT_EXPR
;
2181 void ASTStmtWriter::VisitCXXUuidofExpr(CXXUuidofExpr
*E
) {
2183 Record
.AddSourceRange(E
->getSourceRange());
2184 Record
.AddDeclRef(E
->getGuidDecl());
2185 if (E
->isTypeOperand()) {
2186 Record
.AddTypeSourceInfo(E
->getTypeOperandSourceInfo());
2187 Code
= serialization::EXPR_CXX_UUIDOF_TYPE
;
2189 Record
.AddStmt(E
->getExprOperand());
2190 Code
= serialization::EXPR_CXX_UUIDOF_EXPR
;
2194 void ASTStmtWriter::VisitSEHExceptStmt(SEHExceptStmt
*S
) {
2196 Record
.AddSourceLocation(S
->getExceptLoc());
2197 Record
.AddStmt(S
->getFilterExpr());
2198 Record
.AddStmt(S
->getBlock());
2199 Code
= serialization::STMT_SEH_EXCEPT
;
2202 void ASTStmtWriter::VisitSEHFinallyStmt(SEHFinallyStmt
*S
) {
2204 Record
.AddSourceLocation(S
->getFinallyLoc());
2205 Record
.AddStmt(S
->getBlock());
2206 Code
= serialization::STMT_SEH_FINALLY
;
2209 void ASTStmtWriter::VisitSEHTryStmt(SEHTryStmt
*S
) {
2211 Record
.push_back(S
->getIsCXXTry());
2212 Record
.AddSourceLocation(S
->getTryLoc());
2213 Record
.AddStmt(S
->getTryBlock());
2214 Record
.AddStmt(S
->getHandler());
2215 Code
= serialization::STMT_SEH_TRY
;
2218 void ASTStmtWriter::VisitSEHLeaveStmt(SEHLeaveStmt
*S
) {
2220 Record
.AddSourceLocation(S
->getLeaveLoc());
2221 Code
= serialization::STMT_SEH_LEAVE
;
2224 //===----------------------------------------------------------------------===//
2225 // OpenMP Directives.
2226 //===----------------------------------------------------------------------===//
2228 void ASTStmtWriter::VisitOMPCanonicalLoop(OMPCanonicalLoop
*S
) {
2230 for (Stmt
*SubStmt
: S
->SubStmts
)
2231 Record
.AddStmt(SubStmt
);
2232 Code
= serialization::STMT_OMP_CANONICAL_LOOP
;
2235 void ASTStmtWriter::VisitOMPExecutableDirective(OMPExecutableDirective
*E
) {
2236 Record
.writeOMPChildren(E
->Data
);
2237 Record
.AddSourceLocation(E
->getBeginLoc());
2238 Record
.AddSourceLocation(E
->getEndLoc());
2239 Record
.writeEnum(E
->getMappedDirective());
2242 void ASTStmtWriter::VisitOMPLoopBasedDirective(OMPLoopBasedDirective
*D
) {
2244 Record
.writeUInt32(D
->getLoopsNumber());
2245 VisitOMPExecutableDirective(D
);
2248 void ASTStmtWriter::VisitOMPLoopDirective(OMPLoopDirective
*D
) {
2249 VisitOMPLoopBasedDirective(D
);
2252 void ASTStmtWriter::VisitOMPMetaDirective(OMPMetaDirective
*D
) {
2254 Record
.push_back(D
->getNumClauses());
2255 VisitOMPExecutableDirective(D
);
2256 Code
= serialization::STMT_OMP_META_DIRECTIVE
;
2259 void ASTStmtWriter::VisitOMPParallelDirective(OMPParallelDirective
*D
) {
2261 VisitOMPExecutableDirective(D
);
2262 Record
.writeBool(D
->hasCancel());
2263 Code
= serialization::STMT_OMP_PARALLEL_DIRECTIVE
;
2266 void ASTStmtWriter::VisitOMPSimdDirective(OMPSimdDirective
*D
) {
2267 VisitOMPLoopDirective(D
);
2268 Code
= serialization::STMT_OMP_SIMD_DIRECTIVE
;
2271 void ASTStmtWriter::VisitOMPLoopTransformationDirective(
2272 OMPLoopTransformationDirective
*D
) {
2273 VisitOMPLoopBasedDirective(D
);
2274 Record
.writeUInt32(D
->getNumGeneratedLoops());
2277 void ASTStmtWriter::VisitOMPTileDirective(OMPTileDirective
*D
) {
2278 VisitOMPLoopTransformationDirective(D
);
2279 Code
= serialization::STMT_OMP_TILE_DIRECTIVE
;
2282 void ASTStmtWriter::VisitOMPUnrollDirective(OMPUnrollDirective
*D
) {
2283 VisitOMPLoopTransformationDirective(D
);
2284 Code
= serialization::STMT_OMP_UNROLL_DIRECTIVE
;
2287 void ASTStmtWriter::VisitOMPForDirective(OMPForDirective
*D
) {
2288 VisitOMPLoopDirective(D
);
2289 Record
.writeBool(D
->hasCancel());
2290 Code
= serialization::STMT_OMP_FOR_DIRECTIVE
;
2293 void ASTStmtWriter::VisitOMPForSimdDirective(OMPForSimdDirective
*D
) {
2294 VisitOMPLoopDirective(D
);
2295 Code
= serialization::STMT_OMP_FOR_SIMD_DIRECTIVE
;
2298 void ASTStmtWriter::VisitOMPSectionsDirective(OMPSectionsDirective
*D
) {
2300 VisitOMPExecutableDirective(D
);
2301 Record
.writeBool(D
->hasCancel());
2302 Code
= serialization::STMT_OMP_SECTIONS_DIRECTIVE
;
2305 void ASTStmtWriter::VisitOMPSectionDirective(OMPSectionDirective
*D
) {
2307 VisitOMPExecutableDirective(D
);
2308 Record
.writeBool(D
->hasCancel());
2309 Code
= serialization::STMT_OMP_SECTION_DIRECTIVE
;
2312 void ASTStmtWriter::VisitOMPScopeDirective(OMPScopeDirective
*D
) {
2314 VisitOMPExecutableDirective(D
);
2315 Code
= serialization::STMT_OMP_SCOPE_DIRECTIVE
;
2318 void ASTStmtWriter::VisitOMPSingleDirective(OMPSingleDirective
*D
) {
2320 VisitOMPExecutableDirective(D
);
2321 Code
= serialization::STMT_OMP_SINGLE_DIRECTIVE
;
2324 void ASTStmtWriter::VisitOMPMasterDirective(OMPMasterDirective
*D
) {
2326 VisitOMPExecutableDirective(D
);
2327 Code
= serialization::STMT_OMP_MASTER_DIRECTIVE
;
2330 void ASTStmtWriter::VisitOMPCriticalDirective(OMPCriticalDirective
*D
) {
2332 VisitOMPExecutableDirective(D
);
2333 Record
.AddDeclarationNameInfo(D
->getDirectiveName());
2334 Code
= serialization::STMT_OMP_CRITICAL_DIRECTIVE
;
2337 void ASTStmtWriter::VisitOMPParallelForDirective(OMPParallelForDirective
*D
) {
2338 VisitOMPLoopDirective(D
);
2339 Record
.writeBool(D
->hasCancel());
2340 Code
= serialization::STMT_OMP_PARALLEL_FOR_DIRECTIVE
;
2343 void ASTStmtWriter::VisitOMPParallelForSimdDirective(
2344 OMPParallelForSimdDirective
*D
) {
2345 VisitOMPLoopDirective(D
);
2346 Code
= serialization::STMT_OMP_PARALLEL_FOR_SIMD_DIRECTIVE
;
2349 void ASTStmtWriter::VisitOMPParallelMasterDirective(
2350 OMPParallelMasterDirective
*D
) {
2352 VisitOMPExecutableDirective(D
);
2353 Code
= serialization::STMT_OMP_PARALLEL_MASTER_DIRECTIVE
;
2356 void ASTStmtWriter::VisitOMPParallelMaskedDirective(
2357 OMPParallelMaskedDirective
*D
) {
2359 VisitOMPExecutableDirective(D
);
2360 Code
= serialization::STMT_OMP_PARALLEL_MASKED_DIRECTIVE
;
2363 void ASTStmtWriter::VisitOMPParallelSectionsDirective(
2364 OMPParallelSectionsDirective
*D
) {
2366 VisitOMPExecutableDirective(D
);
2367 Record
.writeBool(D
->hasCancel());
2368 Code
= serialization::STMT_OMP_PARALLEL_SECTIONS_DIRECTIVE
;
2371 void ASTStmtWriter::VisitOMPTaskDirective(OMPTaskDirective
*D
) {
2373 VisitOMPExecutableDirective(D
);
2374 Record
.writeBool(D
->hasCancel());
2375 Code
= serialization::STMT_OMP_TASK_DIRECTIVE
;
2378 void ASTStmtWriter::VisitOMPAtomicDirective(OMPAtomicDirective
*D
) {
2380 VisitOMPExecutableDirective(D
);
2381 Record
.writeBool(D
->isXLHSInRHSPart());
2382 Record
.writeBool(D
->isPostfixUpdate());
2383 Record
.writeBool(D
->isFailOnly());
2384 Code
= serialization::STMT_OMP_ATOMIC_DIRECTIVE
;
2387 void ASTStmtWriter::VisitOMPTargetDirective(OMPTargetDirective
*D
) {
2389 VisitOMPExecutableDirective(D
);
2390 Code
= serialization::STMT_OMP_TARGET_DIRECTIVE
;
2393 void ASTStmtWriter::VisitOMPTargetDataDirective(OMPTargetDataDirective
*D
) {
2395 VisitOMPExecutableDirective(D
);
2396 Code
= serialization::STMT_OMP_TARGET_DATA_DIRECTIVE
;
2399 void ASTStmtWriter::VisitOMPTargetEnterDataDirective(
2400 OMPTargetEnterDataDirective
*D
) {
2402 VisitOMPExecutableDirective(D
);
2403 Code
= serialization::STMT_OMP_TARGET_ENTER_DATA_DIRECTIVE
;
2406 void ASTStmtWriter::VisitOMPTargetExitDataDirective(
2407 OMPTargetExitDataDirective
*D
) {
2409 VisitOMPExecutableDirective(D
);
2410 Code
= serialization::STMT_OMP_TARGET_EXIT_DATA_DIRECTIVE
;
2413 void ASTStmtWriter::VisitOMPTargetParallelDirective(
2414 OMPTargetParallelDirective
*D
) {
2416 VisitOMPExecutableDirective(D
);
2417 Record
.writeBool(D
->hasCancel());
2418 Code
= serialization::STMT_OMP_TARGET_PARALLEL_DIRECTIVE
;
2421 void ASTStmtWriter::VisitOMPTargetParallelForDirective(
2422 OMPTargetParallelForDirective
*D
) {
2423 VisitOMPLoopDirective(D
);
2424 Record
.writeBool(D
->hasCancel());
2425 Code
= serialization::STMT_OMP_TARGET_PARALLEL_FOR_DIRECTIVE
;
2428 void ASTStmtWriter::VisitOMPTaskyieldDirective(OMPTaskyieldDirective
*D
) {
2430 VisitOMPExecutableDirective(D
);
2431 Code
= serialization::STMT_OMP_TASKYIELD_DIRECTIVE
;
2434 void ASTStmtWriter::VisitOMPBarrierDirective(OMPBarrierDirective
*D
) {
2436 VisitOMPExecutableDirective(D
);
2437 Code
= serialization::STMT_OMP_BARRIER_DIRECTIVE
;
2440 void ASTStmtWriter::VisitOMPTaskwaitDirective(OMPTaskwaitDirective
*D
) {
2442 Record
.push_back(D
->getNumClauses());
2443 VisitOMPExecutableDirective(D
);
2444 Code
= serialization::STMT_OMP_TASKWAIT_DIRECTIVE
;
2447 void ASTStmtWriter::VisitOMPErrorDirective(OMPErrorDirective
*D
) {
2449 Record
.push_back(D
->getNumClauses());
2450 VisitOMPExecutableDirective(D
);
2451 Code
= serialization::STMT_OMP_ERROR_DIRECTIVE
;
2454 void ASTStmtWriter::VisitOMPTaskgroupDirective(OMPTaskgroupDirective
*D
) {
2456 VisitOMPExecutableDirective(D
);
2457 Code
= serialization::STMT_OMP_TASKGROUP_DIRECTIVE
;
2460 void ASTStmtWriter::VisitOMPFlushDirective(OMPFlushDirective
*D
) {
2462 VisitOMPExecutableDirective(D
);
2463 Code
= serialization::STMT_OMP_FLUSH_DIRECTIVE
;
2466 void ASTStmtWriter::VisitOMPDepobjDirective(OMPDepobjDirective
*D
) {
2468 VisitOMPExecutableDirective(D
);
2469 Code
= serialization::STMT_OMP_DEPOBJ_DIRECTIVE
;
2472 void ASTStmtWriter::VisitOMPScanDirective(OMPScanDirective
*D
) {
2474 VisitOMPExecutableDirective(D
);
2475 Code
= serialization::STMT_OMP_SCAN_DIRECTIVE
;
2478 void ASTStmtWriter::VisitOMPOrderedDirective(OMPOrderedDirective
*D
) {
2480 VisitOMPExecutableDirective(D
);
2481 Code
= serialization::STMT_OMP_ORDERED_DIRECTIVE
;
2484 void ASTStmtWriter::VisitOMPTeamsDirective(OMPTeamsDirective
*D
) {
2486 VisitOMPExecutableDirective(D
);
2487 Code
= serialization::STMT_OMP_TEAMS_DIRECTIVE
;
2490 void ASTStmtWriter::VisitOMPCancellationPointDirective(
2491 OMPCancellationPointDirective
*D
) {
2493 VisitOMPExecutableDirective(D
);
2494 Record
.writeEnum(D
->getCancelRegion());
2495 Code
= serialization::STMT_OMP_CANCELLATION_POINT_DIRECTIVE
;
2498 void ASTStmtWriter::VisitOMPCancelDirective(OMPCancelDirective
*D
) {
2500 VisitOMPExecutableDirective(D
);
2501 Record
.writeEnum(D
->getCancelRegion());
2502 Code
= serialization::STMT_OMP_CANCEL_DIRECTIVE
;
2505 void ASTStmtWriter::VisitOMPTaskLoopDirective(OMPTaskLoopDirective
*D
) {
2506 VisitOMPLoopDirective(D
);
2507 Record
.writeBool(D
->hasCancel());
2508 Code
= serialization::STMT_OMP_TASKLOOP_DIRECTIVE
;
2511 void ASTStmtWriter::VisitOMPTaskLoopSimdDirective(OMPTaskLoopSimdDirective
*D
) {
2512 VisitOMPLoopDirective(D
);
2513 Code
= serialization::STMT_OMP_TASKLOOP_SIMD_DIRECTIVE
;
2516 void ASTStmtWriter::VisitOMPMasterTaskLoopDirective(
2517 OMPMasterTaskLoopDirective
*D
) {
2518 VisitOMPLoopDirective(D
);
2519 Record
.writeBool(D
->hasCancel());
2520 Code
= serialization::STMT_OMP_MASTER_TASKLOOP_DIRECTIVE
;
2523 void ASTStmtWriter::VisitOMPMaskedTaskLoopDirective(
2524 OMPMaskedTaskLoopDirective
*D
) {
2525 VisitOMPLoopDirective(D
);
2526 Record
.writeBool(D
->hasCancel());
2527 Code
= serialization::STMT_OMP_MASKED_TASKLOOP_DIRECTIVE
;
2530 void ASTStmtWriter::VisitOMPMasterTaskLoopSimdDirective(
2531 OMPMasterTaskLoopSimdDirective
*D
) {
2532 VisitOMPLoopDirective(D
);
2533 Code
= serialization::STMT_OMP_MASTER_TASKLOOP_SIMD_DIRECTIVE
;
2536 void ASTStmtWriter::VisitOMPMaskedTaskLoopSimdDirective(
2537 OMPMaskedTaskLoopSimdDirective
*D
) {
2538 VisitOMPLoopDirective(D
);
2539 Code
= serialization::STMT_OMP_MASKED_TASKLOOP_SIMD_DIRECTIVE
;
2542 void ASTStmtWriter::VisitOMPParallelMasterTaskLoopDirective(
2543 OMPParallelMasterTaskLoopDirective
*D
) {
2544 VisitOMPLoopDirective(D
);
2545 Record
.writeBool(D
->hasCancel());
2546 Code
= serialization::STMT_OMP_PARALLEL_MASTER_TASKLOOP_DIRECTIVE
;
2549 void ASTStmtWriter::VisitOMPParallelMaskedTaskLoopDirective(
2550 OMPParallelMaskedTaskLoopDirective
*D
) {
2551 VisitOMPLoopDirective(D
);
2552 Record
.writeBool(D
->hasCancel());
2553 Code
= serialization::STMT_OMP_PARALLEL_MASKED_TASKLOOP_DIRECTIVE
;
2556 void ASTStmtWriter::VisitOMPParallelMasterTaskLoopSimdDirective(
2557 OMPParallelMasterTaskLoopSimdDirective
*D
) {
2558 VisitOMPLoopDirective(D
);
2559 Code
= serialization::STMT_OMP_PARALLEL_MASTER_TASKLOOP_SIMD_DIRECTIVE
;
2562 void ASTStmtWriter::VisitOMPParallelMaskedTaskLoopSimdDirective(
2563 OMPParallelMaskedTaskLoopSimdDirective
*D
) {
2564 VisitOMPLoopDirective(D
);
2565 Code
= serialization::STMT_OMP_PARALLEL_MASKED_TASKLOOP_SIMD_DIRECTIVE
;
2568 void ASTStmtWriter::VisitOMPDistributeDirective(OMPDistributeDirective
*D
) {
2569 VisitOMPLoopDirective(D
);
2570 Code
= serialization::STMT_OMP_DISTRIBUTE_DIRECTIVE
;
2573 void ASTStmtWriter::VisitOMPTargetUpdateDirective(OMPTargetUpdateDirective
*D
) {
2575 VisitOMPExecutableDirective(D
);
2576 Code
= serialization::STMT_OMP_TARGET_UPDATE_DIRECTIVE
;
2579 void ASTStmtWriter::VisitOMPDistributeParallelForDirective(
2580 OMPDistributeParallelForDirective
*D
) {
2581 VisitOMPLoopDirective(D
);
2582 Record
.writeBool(D
->hasCancel());
2583 Code
= serialization::STMT_OMP_DISTRIBUTE_PARALLEL_FOR_DIRECTIVE
;
2586 void ASTStmtWriter::VisitOMPDistributeParallelForSimdDirective(
2587 OMPDistributeParallelForSimdDirective
*D
) {
2588 VisitOMPLoopDirective(D
);
2589 Code
= serialization::STMT_OMP_DISTRIBUTE_PARALLEL_FOR_SIMD_DIRECTIVE
;
2592 void ASTStmtWriter::VisitOMPDistributeSimdDirective(
2593 OMPDistributeSimdDirective
*D
) {
2594 VisitOMPLoopDirective(D
);
2595 Code
= serialization::STMT_OMP_DISTRIBUTE_SIMD_DIRECTIVE
;
2598 void ASTStmtWriter::VisitOMPTargetParallelForSimdDirective(
2599 OMPTargetParallelForSimdDirective
*D
) {
2600 VisitOMPLoopDirective(D
);
2601 Code
= serialization::STMT_OMP_TARGET_PARALLEL_FOR_SIMD_DIRECTIVE
;
2604 void ASTStmtWriter::VisitOMPTargetSimdDirective(OMPTargetSimdDirective
*D
) {
2605 VisitOMPLoopDirective(D
);
2606 Code
= serialization::STMT_OMP_TARGET_SIMD_DIRECTIVE
;
2609 void ASTStmtWriter::VisitOMPTeamsDistributeDirective(
2610 OMPTeamsDistributeDirective
*D
) {
2611 VisitOMPLoopDirective(D
);
2612 Code
= serialization::STMT_OMP_TEAMS_DISTRIBUTE_DIRECTIVE
;
2615 void ASTStmtWriter::VisitOMPTeamsDistributeSimdDirective(
2616 OMPTeamsDistributeSimdDirective
*D
) {
2617 VisitOMPLoopDirective(D
);
2618 Code
= serialization::STMT_OMP_TEAMS_DISTRIBUTE_SIMD_DIRECTIVE
;
2621 void ASTStmtWriter::VisitOMPTeamsDistributeParallelForSimdDirective(
2622 OMPTeamsDistributeParallelForSimdDirective
*D
) {
2623 VisitOMPLoopDirective(D
);
2624 Code
= serialization::STMT_OMP_TEAMS_DISTRIBUTE_PARALLEL_FOR_SIMD_DIRECTIVE
;
2627 void ASTStmtWriter::VisitOMPTeamsDistributeParallelForDirective(
2628 OMPTeamsDistributeParallelForDirective
*D
) {
2629 VisitOMPLoopDirective(D
);
2630 Record
.writeBool(D
->hasCancel());
2631 Code
= serialization::STMT_OMP_TEAMS_DISTRIBUTE_PARALLEL_FOR_DIRECTIVE
;
2634 void ASTStmtWriter::VisitOMPTargetTeamsDirective(OMPTargetTeamsDirective
*D
) {
2636 VisitOMPExecutableDirective(D
);
2637 Code
= serialization::STMT_OMP_TARGET_TEAMS_DIRECTIVE
;
2640 void ASTStmtWriter::VisitOMPTargetTeamsDistributeDirective(
2641 OMPTargetTeamsDistributeDirective
*D
) {
2642 VisitOMPLoopDirective(D
);
2643 Code
= serialization::STMT_OMP_TARGET_TEAMS_DISTRIBUTE_DIRECTIVE
;
2646 void ASTStmtWriter::VisitOMPTargetTeamsDistributeParallelForDirective(
2647 OMPTargetTeamsDistributeParallelForDirective
*D
) {
2648 VisitOMPLoopDirective(D
);
2649 Record
.writeBool(D
->hasCancel());
2650 Code
= serialization::STMT_OMP_TARGET_TEAMS_DISTRIBUTE_PARALLEL_FOR_DIRECTIVE
;
2653 void ASTStmtWriter::VisitOMPTargetTeamsDistributeParallelForSimdDirective(
2654 OMPTargetTeamsDistributeParallelForSimdDirective
*D
) {
2655 VisitOMPLoopDirective(D
);
2656 Code
= serialization::
2657 STMT_OMP_TARGET_TEAMS_DISTRIBUTE_PARALLEL_FOR_SIMD_DIRECTIVE
;
2660 void ASTStmtWriter::VisitOMPTargetTeamsDistributeSimdDirective(
2661 OMPTargetTeamsDistributeSimdDirective
*D
) {
2662 VisitOMPLoopDirective(D
);
2663 Code
= serialization::STMT_OMP_TARGET_TEAMS_DISTRIBUTE_SIMD_DIRECTIVE
;
2666 void ASTStmtWriter::VisitOMPInteropDirective(OMPInteropDirective
*D
) {
2668 VisitOMPExecutableDirective(D
);
2669 Code
= serialization::STMT_OMP_INTEROP_DIRECTIVE
;
2672 void ASTStmtWriter::VisitOMPDispatchDirective(OMPDispatchDirective
*D
) {
2674 VisitOMPExecutableDirective(D
);
2675 Record
.AddSourceLocation(D
->getTargetCallLoc());
2676 Code
= serialization::STMT_OMP_DISPATCH_DIRECTIVE
;
2679 void ASTStmtWriter::VisitOMPMaskedDirective(OMPMaskedDirective
*D
) {
2681 VisitOMPExecutableDirective(D
);
2682 Code
= serialization::STMT_OMP_MASKED_DIRECTIVE
;
2685 void ASTStmtWriter::VisitOMPGenericLoopDirective(OMPGenericLoopDirective
*D
) {
2686 VisitOMPLoopDirective(D
);
2687 Code
= serialization::STMT_OMP_GENERIC_LOOP_DIRECTIVE
;
2690 void ASTStmtWriter::VisitOMPTeamsGenericLoopDirective(
2691 OMPTeamsGenericLoopDirective
*D
) {
2692 VisitOMPLoopDirective(D
);
2693 Code
= serialization::STMT_OMP_TEAMS_GENERIC_LOOP_DIRECTIVE
;
2696 void ASTStmtWriter::VisitOMPTargetTeamsGenericLoopDirective(
2697 OMPTargetTeamsGenericLoopDirective
*D
) {
2698 VisitOMPLoopDirective(D
);
2699 Code
= serialization::STMT_OMP_TARGET_TEAMS_GENERIC_LOOP_DIRECTIVE
;
2702 void ASTStmtWriter::VisitOMPParallelGenericLoopDirective(
2703 OMPParallelGenericLoopDirective
*D
) {
2704 VisitOMPLoopDirective(D
);
2705 Code
= serialization::STMT_OMP_PARALLEL_GENERIC_LOOP_DIRECTIVE
;
2708 void ASTStmtWriter::VisitOMPTargetParallelGenericLoopDirective(
2709 OMPTargetParallelGenericLoopDirective
*D
) {
2710 VisitOMPLoopDirective(D
);
2711 Code
= serialization::STMT_OMP_TARGET_PARALLEL_GENERIC_LOOP_DIRECTIVE
;
2714 //===----------------------------------------------------------------------===//
2715 // ASTWriter Implementation
2716 //===----------------------------------------------------------------------===//
2718 unsigned ASTWriter::RecordSwitchCaseID(SwitchCase
*S
) {
2719 assert(!SwitchCaseIDs
.contains(S
) && "SwitchCase recorded twice");
2720 unsigned NextID
= SwitchCaseIDs
.size();
2721 SwitchCaseIDs
[S
] = NextID
;
2725 unsigned ASTWriter::getSwitchCaseID(SwitchCase
*S
) {
2726 assert(SwitchCaseIDs
.contains(S
) && "SwitchCase hasn't been seen yet");
2727 return SwitchCaseIDs
[S
];
2730 void ASTWriter::ClearSwitchCaseIDs() {
2731 SwitchCaseIDs
.clear();
2734 /// Write the given substatement or subexpression to the
2736 void ASTWriter::WriteSubStmt(Stmt
*S
) {
2738 ASTStmtWriter
Writer(*this, Record
);
2742 Stream
.EmitRecord(serialization::STMT_NULL_PTR
, Record
);
2746 llvm::DenseMap
<Stmt
*, uint64_t>::iterator I
= SubStmtEntries
.find(S
);
2747 if (I
!= SubStmtEntries
.end()) {
2748 Record
.push_back(I
->second
);
2749 Stream
.EmitRecord(serialization::STMT_REF_PTR
, Record
);
2754 assert(!ParentStmts
.count(S
) && "There is a Stmt cycle!");
2756 struct ParentStmtInserterRAII
{
2758 llvm::DenseSet
<Stmt
*> &ParentStmts
;
2760 ParentStmtInserterRAII(Stmt
*S
, llvm::DenseSet
<Stmt
*> &ParentStmts
)
2761 : S(S
), ParentStmts(ParentStmts
) {
2762 ParentStmts
.insert(S
);
2764 ~ParentStmtInserterRAII() {
2765 ParentStmts
.erase(S
);
2769 ParentStmtInserterRAII
ParentStmtInserter(S
, ParentStmts
);
2774 uint64_t Offset
= Writer
.Emit();
2775 SubStmtEntries
[S
] = Offset
;
2778 /// Flush all of the statements that have been added to the
2779 /// queue via AddStmt().
2780 void ASTRecordWriter::FlushStmts() {
2781 // We expect to be the only consumer of the two temporary statement maps,
2782 // assert that they are empty.
2783 assert(Writer
->SubStmtEntries
.empty() && "unexpected entries in sub-stmt map");
2784 assert(Writer
->ParentStmts
.empty() && "unexpected entries in parent stmt map");
2786 for (unsigned I
= 0, N
= StmtsToEmit
.size(); I
!= N
; ++I
) {
2787 Writer
->WriteSubStmt(StmtsToEmit
[I
]);
2789 assert(N
== StmtsToEmit
.size() && "record modified while being written!");
2791 // Note that we are at the end of a full expression. Any
2792 // expression records that follow this one are part of a different
2794 Writer
->Stream
.EmitRecord(serialization::STMT_STOP
, ArrayRef
<uint32_t>());
2796 Writer
->SubStmtEntries
.clear();
2797 Writer
->ParentStmts
.clear();
2800 StmtsToEmit
.clear();
2803 void ASTRecordWriter::FlushSubStmts() {
2804 // For a nested statement, write out the substatements in reverse order (so
2805 // that a simple stack machine can be used when loading), and don't emit a
2806 // STMT_STOP after each one.
2807 for (unsigned I
= 0, N
= StmtsToEmit
.size(); I
!= N
; ++I
) {
2808 Writer
->WriteSubStmt(StmtsToEmit
[N
- I
- 1]);
2809 assert(N
== StmtsToEmit
.size() && "record modified while being written!");
2812 StmtsToEmit
.clear();