1 //===- ASTReaderStmt.cpp - Stmt/Expr Deserialization ----------------------===//
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 //===----------------------------------------------------------------------===//
9 // Statement/expression deserialization. This implements the
10 // ASTReader::ReadStmt method.
12 //===----------------------------------------------------------------------===//
14 #include "clang/AST/ASTConcept.h"
15 #include "clang/AST/ASTContext.h"
16 #include "clang/AST/AttrIterator.h"
17 #include "clang/AST/Decl.h"
18 #include "clang/AST/DeclAccessPair.h"
19 #include "clang/AST/DeclCXX.h"
20 #include "clang/AST/DeclGroup.h"
21 #include "clang/AST/DeclObjC.h"
22 #include "clang/AST/DeclTemplate.h"
23 #include "clang/AST/DeclarationName.h"
24 #include "clang/AST/DependenceFlags.h"
25 #include "clang/AST/Expr.h"
26 #include "clang/AST/ExprCXX.h"
27 #include "clang/AST/ExprObjC.h"
28 #include "clang/AST/ExprOpenMP.h"
29 #include "clang/AST/NestedNameSpecifier.h"
30 #include "clang/AST/OpenMPClause.h"
31 #include "clang/AST/OperationKinds.h"
32 #include "clang/AST/Stmt.h"
33 #include "clang/AST/StmtCXX.h"
34 #include "clang/AST/StmtObjC.h"
35 #include "clang/AST/StmtOpenMP.h"
36 #include "clang/AST/StmtVisitor.h"
37 #include "clang/AST/TemplateBase.h"
38 #include "clang/AST/Type.h"
39 #include "clang/AST/UnresolvedSet.h"
40 #include "clang/Basic/CapturedStmt.h"
41 #include "clang/Basic/ExpressionTraits.h"
42 #include "clang/Basic/LLVM.h"
43 #include "clang/Basic/Lambda.h"
44 #include "clang/Basic/LangOptions.h"
45 #include "clang/Basic/OpenMPKinds.h"
46 #include "clang/Basic/OperatorKinds.h"
47 #include "clang/Basic/SourceLocation.h"
48 #include "clang/Basic/Specifiers.h"
49 #include "clang/Basic/TypeTraits.h"
50 #include "clang/Lex/Token.h"
51 #include "clang/Serialization/ASTBitCodes.h"
52 #include "clang/Serialization/ASTRecordReader.h"
53 #include "llvm/ADT/BitmaskEnum.h"
54 #include "llvm/ADT/DenseMap.h"
55 #include "llvm/ADT/SmallString.h"
56 #include "llvm/ADT/SmallVector.h"
57 #include "llvm/ADT/StringRef.h"
58 #include "llvm/Bitstream/BitstreamReader.h"
59 #include "llvm/Support/Casting.h"
60 #include "llvm/Support/ErrorHandling.h"
67 using namespace clang
;
68 using namespace serialization
;
72 class ASTStmtReader
: public StmtVisitor
<ASTStmtReader
> {
73 ASTRecordReader
&Record
;
74 llvm::BitstreamCursor
&DeclsCursor
;
76 SourceLocation
readSourceLocation() {
77 return Record
.readSourceLocation();
80 SourceRange
readSourceRange() {
81 return Record
.readSourceRange();
84 std::string
readString() {
85 return Record
.readString();
88 TypeSourceInfo
*readTypeSourceInfo() {
89 return Record
.readTypeSourceInfo();
93 return Record
.readDecl();
98 return Record
.readDeclAs
<T
>();
102 ASTStmtReader(ASTRecordReader
&Record
, llvm::BitstreamCursor
&Cursor
)
103 : Record(Record
), DeclsCursor(Cursor
) {}
105 /// The number of record fields required for the Stmt class
107 static const unsigned NumStmtFields
= 0;
109 /// The number of record fields required for the Expr class
111 static const unsigned NumExprFields
= NumStmtFields
+ 4;
113 /// Read and initialize a ExplicitTemplateArgumentList structure.
114 void ReadTemplateKWAndArgsInfo(ASTTemplateKWAndArgsInfo
&Args
,
115 TemplateArgumentLoc
*ArgsLocArray
,
116 unsigned NumTemplateArgs
);
118 void VisitStmt(Stmt
*S
);
119 #define STMT(Type, Base) \
120 void Visit##Type(Type *);
121 #include "clang/AST/StmtNodes.inc"
126 void ASTStmtReader::ReadTemplateKWAndArgsInfo(ASTTemplateKWAndArgsInfo
&Args
,
127 TemplateArgumentLoc
*ArgsLocArray
,
128 unsigned NumTemplateArgs
) {
129 SourceLocation TemplateKWLoc
= readSourceLocation();
130 TemplateArgumentListInfo ArgInfo
;
131 ArgInfo
.setLAngleLoc(readSourceLocation());
132 ArgInfo
.setRAngleLoc(readSourceLocation());
133 for (unsigned i
= 0; i
!= NumTemplateArgs
; ++i
)
134 ArgInfo
.addArgument(Record
.readTemplateArgumentLoc());
135 Args
.initializeFrom(TemplateKWLoc
, ArgInfo
, ArgsLocArray
);
138 void ASTStmtReader::VisitStmt(Stmt
*S
) {
139 assert(Record
.getIdx() == NumStmtFields
&& "Incorrect statement field count");
142 void ASTStmtReader::VisitNullStmt(NullStmt
*S
) {
144 S
->setSemiLoc(readSourceLocation());
145 S
->NullStmtBits
.HasLeadingEmptyMacro
= Record
.readInt();
148 void ASTStmtReader::VisitCompoundStmt(CompoundStmt
*S
) {
150 SmallVector
<Stmt
*, 16> Stmts
;
151 unsigned NumStmts
= Record
.readInt();
152 unsigned HasFPFeatures
= Record
.readInt();
153 assert(S
->hasStoredFPFeatures() == HasFPFeatures
);
155 Stmts
.push_back(Record
.readSubStmt());
158 S
->setStoredFPFeatures(
159 FPOptionsOverride::getFromOpaqueInt(Record
.readInt()));
160 S
->LBraceLoc
= readSourceLocation();
161 S
->RBraceLoc
= readSourceLocation();
164 void ASTStmtReader::VisitSwitchCase(SwitchCase
*S
) {
166 Record
.recordSwitchCaseID(S
, Record
.readInt());
167 S
->setKeywordLoc(readSourceLocation());
168 S
->setColonLoc(readSourceLocation());
171 void ASTStmtReader::VisitCaseStmt(CaseStmt
*S
) {
173 bool CaseStmtIsGNURange
= Record
.readInt();
174 S
->setLHS(Record
.readSubExpr());
175 S
->setSubStmt(Record
.readSubStmt());
176 if (CaseStmtIsGNURange
) {
177 S
->setRHS(Record
.readSubExpr());
178 S
->setEllipsisLoc(readSourceLocation());
182 void ASTStmtReader::VisitDefaultStmt(DefaultStmt
*S
) {
184 S
->setSubStmt(Record
.readSubStmt());
187 void ASTStmtReader::VisitLabelStmt(LabelStmt
*S
) {
189 bool IsSideEntry
= Record
.readInt();
190 auto *LD
= readDeclAs
<LabelDecl
>();
193 S
->setSubStmt(Record
.readSubStmt());
194 S
->setIdentLoc(readSourceLocation());
195 S
->setSideEntry(IsSideEntry
);
198 void ASTStmtReader::VisitAttributedStmt(AttributedStmt
*S
) {
200 // NumAttrs in AttributedStmt is set when creating an empty
201 // AttributedStmt in AttributedStmt::CreateEmpty, since it is needed
202 // to allocate the right amount of space for the trailing Attr *.
203 uint64_t NumAttrs
= Record
.readInt();
205 Record
.readAttributes(Attrs
);
207 assert(NumAttrs
== S
->AttributedStmtBits
.NumAttrs
);
208 assert(NumAttrs
== Attrs
.size());
209 std::copy(Attrs
.begin(), Attrs
.end(), S
->getAttrArrayPtr());
210 S
->SubStmt
= Record
.readSubStmt();
211 S
->AttributedStmtBits
.AttrLoc
= readSourceLocation();
214 void ASTStmtReader::VisitIfStmt(IfStmt
*S
) {
217 bool HasElse
= Record
.readInt();
218 bool HasVar
= Record
.readInt();
219 bool HasInit
= Record
.readInt();
221 S
->setStatementKind(static_cast<IfStatementKind
>(Record
.readInt()));
222 S
->setCond(Record
.readSubExpr());
223 S
->setThen(Record
.readSubStmt());
225 S
->setElse(Record
.readSubStmt());
227 S
->setConditionVariableDeclStmt(cast
<DeclStmt
>(Record
.readSubStmt()));
229 S
->setInit(Record
.readSubStmt());
231 S
->setIfLoc(readSourceLocation());
232 S
->setLParenLoc(readSourceLocation());
233 S
->setRParenLoc(readSourceLocation());
235 S
->setElseLoc(readSourceLocation());
238 void ASTStmtReader::VisitSwitchStmt(SwitchStmt
*S
) {
241 bool HasInit
= Record
.readInt();
242 bool HasVar
= Record
.readInt();
243 bool AllEnumCasesCovered
= Record
.readInt();
244 if (AllEnumCasesCovered
)
245 S
->setAllEnumCasesCovered();
247 S
->setCond(Record
.readSubExpr());
248 S
->setBody(Record
.readSubStmt());
250 S
->setInit(Record
.readSubStmt());
252 S
->setConditionVariableDeclStmt(cast
<DeclStmt
>(Record
.readSubStmt()));
254 S
->setSwitchLoc(readSourceLocation());
255 S
->setLParenLoc(readSourceLocation());
256 S
->setRParenLoc(readSourceLocation());
258 SwitchCase
*PrevSC
= nullptr;
259 for (auto E
= Record
.size(); Record
.getIdx() != E
; ) {
260 SwitchCase
*SC
= Record
.getSwitchCaseWithID(Record
.readInt());
262 PrevSC
->setNextSwitchCase(SC
);
264 S
->setSwitchCaseList(SC
);
270 void ASTStmtReader::VisitWhileStmt(WhileStmt
*S
) {
273 bool HasVar
= Record
.readInt();
275 S
->setCond(Record
.readSubExpr());
276 S
->setBody(Record
.readSubStmt());
278 S
->setConditionVariableDeclStmt(cast
<DeclStmt
>(Record
.readSubStmt()));
280 S
->setWhileLoc(readSourceLocation());
281 S
->setLParenLoc(readSourceLocation());
282 S
->setRParenLoc(readSourceLocation());
285 void ASTStmtReader::VisitDoStmt(DoStmt
*S
) {
287 S
->setCond(Record
.readSubExpr());
288 S
->setBody(Record
.readSubStmt());
289 S
->setDoLoc(readSourceLocation());
290 S
->setWhileLoc(readSourceLocation());
291 S
->setRParenLoc(readSourceLocation());
294 void ASTStmtReader::VisitForStmt(ForStmt
*S
) {
296 S
->setInit(Record
.readSubStmt());
297 S
->setCond(Record
.readSubExpr());
298 S
->setConditionVariableDeclStmt(cast_or_null
<DeclStmt
>(Record
.readSubStmt()));
299 S
->setInc(Record
.readSubExpr());
300 S
->setBody(Record
.readSubStmt());
301 S
->setForLoc(readSourceLocation());
302 S
->setLParenLoc(readSourceLocation());
303 S
->setRParenLoc(readSourceLocation());
306 void ASTStmtReader::VisitGotoStmt(GotoStmt
*S
) {
308 S
->setLabel(readDeclAs
<LabelDecl
>());
309 S
->setGotoLoc(readSourceLocation());
310 S
->setLabelLoc(readSourceLocation());
313 void ASTStmtReader::VisitIndirectGotoStmt(IndirectGotoStmt
*S
) {
315 S
->setGotoLoc(readSourceLocation());
316 S
->setStarLoc(readSourceLocation());
317 S
->setTarget(Record
.readSubExpr());
320 void ASTStmtReader::VisitContinueStmt(ContinueStmt
*S
) {
322 S
->setContinueLoc(readSourceLocation());
325 void ASTStmtReader::VisitBreakStmt(BreakStmt
*S
) {
327 S
->setBreakLoc(readSourceLocation());
330 void ASTStmtReader::VisitReturnStmt(ReturnStmt
*S
) {
333 bool HasNRVOCandidate
= Record
.readInt();
335 S
->setRetValue(Record
.readSubExpr());
336 if (HasNRVOCandidate
)
337 S
->setNRVOCandidate(readDeclAs
<VarDecl
>());
339 S
->setReturnLoc(readSourceLocation());
342 void ASTStmtReader::VisitDeclStmt(DeclStmt
*S
) {
344 S
->setStartLoc(readSourceLocation());
345 S
->setEndLoc(readSourceLocation());
347 if (Record
.size() - Record
.getIdx() == 1) {
348 // Single declaration
349 S
->setDeclGroup(DeclGroupRef(readDecl()));
351 SmallVector
<Decl
*, 16> Decls
;
352 int N
= Record
.size() - Record
.getIdx();
354 for (int I
= 0; I
< N
; ++I
)
355 Decls
.push_back(readDecl());
356 S
->setDeclGroup(DeclGroupRef(DeclGroup::Create(Record
.getContext(),
362 void ASTStmtReader::VisitAsmStmt(AsmStmt
*S
) {
364 S
->NumOutputs
= Record
.readInt();
365 S
->NumInputs
= Record
.readInt();
366 S
->NumClobbers
= Record
.readInt();
367 S
->setAsmLoc(readSourceLocation());
368 S
->setVolatile(Record
.readInt());
369 S
->setSimple(Record
.readInt());
372 void ASTStmtReader::VisitGCCAsmStmt(GCCAsmStmt
*S
) {
374 S
->NumLabels
= Record
.readInt();
375 S
->setRParenLoc(readSourceLocation());
376 S
->setAsmString(cast_or_null
<StringLiteral
>(Record
.readSubStmt()));
378 unsigned NumOutputs
= S
->getNumOutputs();
379 unsigned NumInputs
= S
->getNumInputs();
380 unsigned NumClobbers
= S
->getNumClobbers();
381 unsigned NumLabels
= S
->getNumLabels();
383 // Outputs and inputs
384 SmallVector
<IdentifierInfo
*, 16> Names
;
385 SmallVector
<StringLiteral
*, 16> Constraints
;
386 SmallVector
<Stmt
*, 16> Exprs
;
387 for (unsigned I
= 0, N
= NumOutputs
+ NumInputs
; I
!= N
; ++I
) {
388 Names
.push_back(Record
.readIdentifier());
389 Constraints
.push_back(cast_or_null
<StringLiteral
>(Record
.readSubStmt()));
390 Exprs
.push_back(Record
.readSubStmt());
394 SmallVector
<StringLiteral
*, 16> Clobbers
;
395 for (unsigned I
= 0; I
!= NumClobbers
; ++I
)
396 Clobbers
.push_back(cast_or_null
<StringLiteral
>(Record
.readSubStmt()));
399 for (unsigned I
= 0, N
= NumLabels
; I
!= N
; ++I
) {
400 Names
.push_back(Record
.readIdentifier());
401 Exprs
.push_back(Record
.readSubStmt());
404 S
->setOutputsAndInputsAndClobbers(Record
.getContext(),
405 Names
.data(), Constraints
.data(),
406 Exprs
.data(), NumOutputs
, NumInputs
,
408 Clobbers
.data(), NumClobbers
);
411 void ASTStmtReader::VisitMSAsmStmt(MSAsmStmt
*S
) {
413 S
->LBraceLoc
= readSourceLocation();
414 S
->EndLoc
= readSourceLocation();
415 S
->NumAsmToks
= Record
.readInt();
416 std::string AsmStr
= readString();
419 SmallVector
<Token
, 16> AsmToks
;
420 AsmToks
.reserve(S
->NumAsmToks
);
421 for (unsigned i
= 0, e
= S
->NumAsmToks
; i
!= e
; ++i
) {
422 AsmToks
.push_back(Record
.readToken());
425 // The calls to reserve() for the FooData vectors are mandatory to
426 // prevent dead StringRefs in the Foo vectors.
428 // Read the clobbers.
429 SmallVector
<std::string
, 16> ClobbersData
;
430 SmallVector
<StringRef
, 16> Clobbers
;
431 ClobbersData
.reserve(S
->NumClobbers
);
432 Clobbers
.reserve(S
->NumClobbers
);
433 for (unsigned i
= 0, e
= S
->NumClobbers
; i
!= e
; ++i
) {
434 ClobbersData
.push_back(readString());
435 Clobbers
.push_back(ClobbersData
.back());
438 // Read the operands.
439 unsigned NumOperands
= S
->NumOutputs
+ S
->NumInputs
;
440 SmallVector
<Expr
*, 16> Exprs
;
441 SmallVector
<std::string
, 16> ConstraintsData
;
442 SmallVector
<StringRef
, 16> Constraints
;
443 Exprs
.reserve(NumOperands
);
444 ConstraintsData
.reserve(NumOperands
);
445 Constraints
.reserve(NumOperands
);
446 for (unsigned i
= 0; i
!= NumOperands
; ++i
) {
447 Exprs
.push_back(cast
<Expr
>(Record
.readSubStmt()));
448 ConstraintsData
.push_back(readString());
449 Constraints
.push_back(ConstraintsData
.back());
452 S
->initialize(Record
.getContext(), AsmStr
, AsmToks
,
453 Constraints
, Exprs
, Clobbers
);
456 void ASTStmtReader::VisitCoroutineBodyStmt(CoroutineBodyStmt
*S
) {
458 assert(Record
.peekInt() == S
->NumParams
);
460 auto *StoredStmts
= S
->getStoredStmts();
462 i
< CoroutineBodyStmt::SubStmt::FirstParamMove
+ S
->NumParams
; ++i
)
463 StoredStmts
[i
] = Record
.readSubStmt();
466 void ASTStmtReader::VisitCoreturnStmt(CoreturnStmt
*S
) {
468 S
->CoreturnLoc
= Record
.readSourceLocation();
469 for (auto &SubStmt
: S
->SubStmts
)
470 SubStmt
= Record
.readSubStmt();
471 S
->IsImplicit
= Record
.readInt() != 0;
474 void ASTStmtReader::VisitCoawaitExpr(CoawaitExpr
*E
) {
476 E
->KeywordLoc
= readSourceLocation();
477 for (auto &SubExpr
: E
->SubExprs
)
478 SubExpr
= Record
.readSubStmt();
479 E
->OpaqueValue
= cast_or_null
<OpaqueValueExpr
>(Record
.readSubStmt());
480 E
->setIsImplicit(Record
.readInt() != 0);
483 void ASTStmtReader::VisitCoyieldExpr(CoyieldExpr
*E
) {
485 E
->KeywordLoc
= readSourceLocation();
486 for (auto &SubExpr
: E
->SubExprs
)
487 SubExpr
= Record
.readSubStmt();
488 E
->OpaqueValue
= cast_or_null
<OpaqueValueExpr
>(Record
.readSubStmt());
491 void ASTStmtReader::VisitDependentCoawaitExpr(DependentCoawaitExpr
*E
) {
493 E
->KeywordLoc
= readSourceLocation();
494 for (auto &SubExpr
: E
->SubExprs
)
495 SubExpr
= Record
.readSubStmt();
498 void ASTStmtReader::VisitCapturedStmt(CapturedStmt
*S
) {
501 S
->setCapturedDecl(readDeclAs
<CapturedDecl
>());
502 S
->setCapturedRegionKind(static_cast<CapturedRegionKind
>(Record
.readInt()));
503 S
->setCapturedRecordDecl(readDeclAs
<RecordDecl
>());
506 for (CapturedStmt::capture_init_iterator I
= S
->capture_init_begin(),
507 E
= S
->capture_init_end();
509 *I
= Record
.readSubExpr();
512 S
->setCapturedStmt(Record
.readSubStmt());
513 S
->getCapturedDecl()->setBody(S
->getCapturedStmt());
516 for (auto &I
: S
->captures()) {
517 I
.VarAndKind
.setPointer(readDeclAs
<VarDecl
>());
519 static_cast<CapturedStmt::VariableCaptureKind
>(Record
.readInt()));
520 I
.Loc
= readSourceLocation();
524 void ASTStmtReader::VisitExpr(Expr
*E
) {
526 E
->setType(Record
.readType());
527 E
->setDependence(static_cast<ExprDependence
>(Record
.readInt()));
528 E
->setValueKind(static_cast<ExprValueKind
>(Record
.readInt()));
529 E
->setObjectKind(static_cast<ExprObjectKind
>(Record
.readInt()));
530 assert(Record
.getIdx() == NumExprFields
&&
531 "Incorrect expression field count");
534 void ASTStmtReader::VisitConstantExpr(ConstantExpr
*E
) {
537 auto StorageKind
= Record
.readInt();
538 assert(E
->ConstantExprBits
.ResultKind
== StorageKind
&& "Wrong ResultKind!");
540 E
->ConstantExprBits
.APValueKind
= Record
.readInt();
541 E
->ConstantExprBits
.IsUnsigned
= Record
.readInt();
542 E
->ConstantExprBits
.BitWidth
= Record
.readInt();
543 E
->ConstantExprBits
.HasCleanup
= false; // Not serialized, see below.
544 E
->ConstantExprBits
.IsImmediateInvocation
= Record
.readInt();
546 switch (StorageKind
) {
547 case ConstantExpr::RSK_None
:
550 case ConstantExpr::RSK_Int64
:
551 E
->Int64Result() = Record
.readInt();
554 case ConstantExpr::RSK_APValue
:
555 E
->APValueResult() = Record
.readAPValue();
556 if (E
->APValueResult().needsCleanup()) {
557 E
->ConstantExprBits
.HasCleanup
= true;
558 Record
.getContext().addDestruction(&E
->APValueResult());
562 llvm_unreachable("unexpected ResultKind!");
565 E
->setSubExpr(Record
.readSubExpr());
568 void ASTStmtReader::VisitSYCLUniqueStableNameExpr(SYCLUniqueStableNameExpr
*E
) {
571 E
->setLocation(readSourceLocation());
572 E
->setLParenLocation(readSourceLocation());
573 E
->setRParenLocation(readSourceLocation());
575 E
->setTypeSourceInfo(Record
.readTypeSourceInfo());
578 void ASTStmtReader::VisitPredefinedExpr(PredefinedExpr
*E
) {
580 bool HasFunctionName
= Record
.readInt();
581 E
->PredefinedExprBits
.HasFunctionName
= HasFunctionName
;
582 E
->PredefinedExprBits
.Kind
= Record
.readInt();
583 E
->PredefinedExprBits
.IsTransparent
= Record
.readInt();
584 E
->setLocation(readSourceLocation());
586 E
->setFunctionName(cast
<StringLiteral
>(Record
.readSubExpr()));
589 void ASTStmtReader::VisitDeclRefExpr(DeclRefExpr
*E
) {
592 E
->DeclRefExprBits
.HasQualifier
= Record
.readInt();
593 E
->DeclRefExprBits
.HasFoundDecl
= Record
.readInt();
594 E
->DeclRefExprBits
.HasTemplateKWAndArgsInfo
= Record
.readInt();
595 E
->DeclRefExprBits
.HadMultipleCandidates
= Record
.readInt();
596 E
->DeclRefExprBits
.RefersToEnclosingVariableOrCapture
= Record
.readInt();
597 E
->DeclRefExprBits
.NonOdrUseReason
= Record
.readInt();
598 E
->DeclRefExprBits
.IsImmediateEscalating
= Record
.readInt();
599 unsigned NumTemplateArgs
= 0;
600 if (E
->hasTemplateKWAndArgsInfo())
601 NumTemplateArgs
= Record
.readInt();
603 if (E
->hasQualifier())
604 new (E
->getTrailingObjects
<NestedNameSpecifierLoc
>())
605 NestedNameSpecifierLoc(Record
.readNestedNameSpecifierLoc());
607 if (E
->hasFoundDecl())
608 *E
->getTrailingObjects
<NamedDecl
*>() = readDeclAs
<NamedDecl
>();
610 if (E
->hasTemplateKWAndArgsInfo())
611 ReadTemplateKWAndArgsInfo(
612 *E
->getTrailingObjects
<ASTTemplateKWAndArgsInfo
>(),
613 E
->getTrailingObjects
<TemplateArgumentLoc
>(), NumTemplateArgs
);
615 E
->D
= readDeclAs
<ValueDecl
>();
616 E
->setLocation(readSourceLocation());
617 E
->DNLoc
= Record
.readDeclarationNameLoc(E
->getDecl()->getDeclName());
620 void ASTStmtReader::VisitIntegerLiteral(IntegerLiteral
*E
) {
622 E
->setLocation(readSourceLocation());
623 E
->setValue(Record
.getContext(), Record
.readAPInt());
626 void ASTStmtReader::VisitFixedPointLiteral(FixedPointLiteral
*E
) {
628 E
->setLocation(readSourceLocation());
629 E
->setScale(Record
.readInt());
630 E
->setValue(Record
.getContext(), Record
.readAPInt());
633 void ASTStmtReader::VisitFloatingLiteral(FloatingLiteral
*E
) {
636 static_cast<llvm::APFloatBase::Semantics
>(Record
.readInt()));
637 E
->setExact(Record
.readInt());
638 E
->setValue(Record
.getContext(), Record
.readAPFloat(E
->getSemantics()));
639 E
->setLocation(readSourceLocation());
642 void ASTStmtReader::VisitImaginaryLiteral(ImaginaryLiteral
*E
) {
644 E
->setSubExpr(Record
.readSubExpr());
647 void ASTStmtReader::VisitStringLiteral(StringLiteral
*E
) {
650 // NumConcatenated, Length and CharByteWidth are set by the empty
651 // ctor since they are needed to allocate storage for the trailing objects.
652 unsigned NumConcatenated
= Record
.readInt();
653 unsigned Length
= Record
.readInt();
654 unsigned CharByteWidth
= Record
.readInt();
655 assert((NumConcatenated
== E
->getNumConcatenated()) &&
656 "Wrong number of concatenated tokens!");
657 assert((Length
== E
->getLength()) && "Wrong Length!");
658 assert((CharByteWidth
== E
->getCharByteWidth()) && "Wrong character width!");
659 E
->StringLiteralBits
.Kind
= Record
.readInt();
660 E
->StringLiteralBits
.IsPascal
= Record
.readInt();
662 // The character width is originally computed via mapCharByteWidth.
663 // Check that the deserialized character width is consistant with the result
664 // of calling mapCharByteWidth.
665 assert((CharByteWidth
==
666 StringLiteral::mapCharByteWidth(Record
.getContext().getTargetInfo(),
668 "Wrong character width!");
670 // Deserialize the trailing array of SourceLocation.
671 for (unsigned I
= 0; I
< NumConcatenated
; ++I
)
672 E
->setStrTokenLoc(I
, readSourceLocation());
674 // Deserialize the trailing array of char holding the string data.
675 char *StrData
= E
->getStrDataAsChar();
676 for (unsigned I
= 0; I
< Length
* CharByteWidth
; ++I
)
677 StrData
[I
] = Record
.readInt();
680 void ASTStmtReader::VisitCharacterLiteral(CharacterLiteral
*E
) {
682 E
->setValue(Record
.readInt());
683 E
->setLocation(readSourceLocation());
684 E
->setKind(static_cast<CharacterLiteral::CharacterKind
>(Record
.readInt()));
687 void ASTStmtReader::VisitParenExpr(ParenExpr
*E
) {
689 E
->setLParen(readSourceLocation());
690 E
->setRParen(readSourceLocation());
691 E
->setSubExpr(Record
.readSubExpr());
694 void ASTStmtReader::VisitParenListExpr(ParenListExpr
*E
) {
696 unsigned NumExprs
= Record
.readInt();
697 assert((NumExprs
== E
->getNumExprs()) && "Wrong NumExprs!");
698 for (unsigned I
= 0; I
!= NumExprs
; ++I
)
699 E
->getTrailingObjects
<Stmt
*>()[I
] = Record
.readSubStmt();
700 E
->LParenLoc
= readSourceLocation();
701 E
->RParenLoc
= readSourceLocation();
704 void ASTStmtReader::VisitUnaryOperator(UnaryOperator
*E
) {
706 bool hasFP_Features
= Record
.readInt();
707 assert(hasFP_Features
== E
->hasStoredFPFeatures());
708 E
->setSubExpr(Record
.readSubExpr());
709 E
->setOpcode((UnaryOperator::Opcode
)Record
.readInt());
710 E
->setOperatorLoc(readSourceLocation());
711 E
->setCanOverflow(Record
.readInt());
713 E
->setStoredFPFeatures(
714 FPOptionsOverride::getFromOpaqueInt(Record
.readInt()));
717 void ASTStmtReader::VisitOffsetOfExpr(OffsetOfExpr
*E
) {
719 assert(E
->getNumComponents() == Record
.peekInt());
721 assert(E
->getNumExpressions() == Record
.peekInt());
723 E
->setOperatorLoc(readSourceLocation());
724 E
->setRParenLoc(readSourceLocation());
725 E
->setTypeSourceInfo(readTypeSourceInfo());
726 for (unsigned I
= 0, N
= E
->getNumComponents(); I
!= N
; ++I
) {
727 auto Kind
= static_cast<OffsetOfNode::Kind
>(Record
.readInt());
728 SourceLocation Start
= readSourceLocation();
729 SourceLocation End
= readSourceLocation();
731 case OffsetOfNode::Array
:
732 E
->setComponent(I
, OffsetOfNode(Start
, Record
.readInt(), End
));
735 case OffsetOfNode::Field
:
737 I
, OffsetOfNode(Start
, readDeclAs
<FieldDecl
>(), End
));
740 case OffsetOfNode::Identifier
:
743 OffsetOfNode(Start
, Record
.readIdentifier(), End
));
746 case OffsetOfNode::Base
: {
747 auto *Base
= new (Record
.getContext()) CXXBaseSpecifier();
748 *Base
= Record
.readCXXBaseSpecifier();
749 E
->setComponent(I
, OffsetOfNode(Base
));
755 for (unsigned I
= 0, N
= E
->getNumExpressions(); I
!= N
; ++I
)
756 E
->setIndexExpr(I
, Record
.readSubExpr());
759 void ASTStmtReader::VisitUnaryExprOrTypeTraitExpr(UnaryExprOrTypeTraitExpr
*E
) {
761 E
->setKind(static_cast<UnaryExprOrTypeTrait
>(Record
.readInt()));
762 if (Record
.peekInt() == 0) {
763 E
->setArgument(Record
.readSubExpr());
766 E
->setArgument(readTypeSourceInfo());
768 E
->setOperatorLoc(readSourceLocation());
769 E
->setRParenLoc(readSourceLocation());
772 static ConstraintSatisfaction
773 readConstraintSatisfaction(ASTRecordReader
&Record
) {
774 ConstraintSatisfaction Satisfaction
;
775 Satisfaction
.IsSatisfied
= Record
.readInt();
776 Satisfaction
.ContainsErrors
= Record
.readInt();
777 if (!Satisfaction
.IsSatisfied
) {
778 unsigned NumDetailRecords
= Record
.readInt();
779 for (unsigned i
= 0; i
!= NumDetailRecords
; ++i
) {
780 Expr
*ConstraintExpr
= Record
.readExpr();
781 if (/* IsDiagnostic */Record
.readInt()) {
782 SourceLocation DiagLocation
= Record
.readSourceLocation();
783 std::string DiagMessage
= Record
.readString();
784 Satisfaction
.Details
.emplace_back(
785 ConstraintExpr
, new (Record
.getContext())
786 ConstraintSatisfaction::SubstitutionDiagnostic
{
787 DiagLocation
, DiagMessage
});
789 Satisfaction
.Details
.emplace_back(ConstraintExpr
, Record
.readExpr());
795 void ASTStmtReader::VisitConceptSpecializationExpr(
796 ConceptSpecializationExpr
*E
) {
798 E
->NestedNameSpec
= Record
.readNestedNameSpecifierLoc();
799 E
->TemplateKWLoc
= Record
.readSourceLocation();
800 E
->ConceptName
= Record
.readDeclarationNameInfo();
801 E
->NamedConcept
= readDeclAs
<ConceptDecl
>();
802 E
->FoundDecl
= Record
.readDeclAs
<NamedDecl
>();
803 E
->SpecDecl
= Record
.readDeclAs
<ImplicitConceptSpecializationDecl
>();
804 E
->ArgsAsWritten
= Record
.readASTTemplateArgumentListInfo();
805 E
->Satisfaction
= E
->isValueDependent() ? nullptr :
806 ASTConstraintSatisfaction::Create(Record
.getContext(),
807 readConstraintSatisfaction(Record
));
810 static concepts::Requirement::SubstitutionDiagnostic
*
811 readSubstitutionDiagnostic(ASTRecordReader
&Record
) {
812 std::string SubstitutedEntity
= Record
.readString();
813 SourceLocation DiagLoc
= Record
.readSourceLocation();
814 std::string DiagMessage
= Record
.readString();
815 return new (Record
.getContext())
816 concepts::Requirement::SubstitutionDiagnostic
{SubstitutedEntity
, DiagLoc
,
820 void ASTStmtReader::VisitRequiresExpr(RequiresExpr
*E
) {
822 unsigned NumLocalParameters
= Record
.readInt();
823 unsigned NumRequirements
= Record
.readInt();
824 E
->RequiresExprBits
.RequiresKWLoc
= Record
.readSourceLocation();
825 E
->RequiresExprBits
.IsSatisfied
= Record
.readInt();
826 E
->Body
= Record
.readDeclAs
<RequiresExprBodyDecl
>();
827 llvm::SmallVector
<ParmVarDecl
*, 4> LocalParameters
;
828 for (unsigned i
= 0; i
< NumLocalParameters
; ++i
)
829 LocalParameters
.push_back(cast
<ParmVarDecl
>(Record
.readDecl()));
830 std::copy(LocalParameters
.begin(), LocalParameters
.end(),
831 E
->getTrailingObjects
<ParmVarDecl
*>());
832 llvm::SmallVector
<concepts::Requirement
*, 4> Requirements
;
833 for (unsigned i
= 0; i
< NumRequirements
; ++i
) {
835 static_cast<concepts::Requirement::RequirementKind
>(Record
.readInt());
836 concepts::Requirement
*R
= nullptr;
838 case concepts::Requirement::RK_Type
: {
840 static_cast<concepts::TypeRequirement::SatisfactionStatus
>(
842 if (Status
== concepts::TypeRequirement::SS_SubstitutionFailure
)
843 R
= new (Record
.getContext())
844 concepts::TypeRequirement(readSubstitutionDiagnostic(Record
));
846 R
= new (Record
.getContext())
847 concepts::TypeRequirement(Record
.readTypeSourceInfo());
849 case concepts::Requirement::RK_Simple
:
850 case concepts::Requirement::RK_Compound
: {
852 static_cast<concepts::ExprRequirement::SatisfactionStatus
>(
854 llvm::PointerUnion
<concepts::Requirement::SubstitutionDiagnostic
*,
856 if (Status
== concepts::ExprRequirement::SS_ExprSubstitutionFailure
) {
857 E
= readSubstitutionDiagnostic(Record
);
859 E
= Record
.readExpr();
861 std::optional
<concepts::ExprRequirement::ReturnTypeRequirement
> Req
;
862 ConceptSpecializationExpr
*SubstitutedConstraintExpr
= nullptr;
863 SourceLocation NoexceptLoc
;
864 if (RK
== concepts::Requirement::RK_Simple
) {
867 NoexceptLoc
= Record
.readSourceLocation();
868 switch (/* returnTypeRequirementKind */Record
.readInt()) {
870 // No return type requirement.
875 TemplateParameterList
*TPL
= Record
.readTemplateParameterList();
877 concepts::ExprRequirement::SS_ConstraintsNotSatisfied
)
878 SubstitutedConstraintExpr
=
879 cast
<ConceptSpecializationExpr
>(Record
.readExpr());
883 // Substitution failure
884 Req
.emplace(readSubstitutionDiagnostic(Record
));
888 if (Expr
*Ex
= E
.dyn_cast
<Expr
*>())
889 R
= new (Record
.getContext()) concepts::ExprRequirement(
890 Ex
, RK
== concepts::Requirement::RK_Simple
, NoexceptLoc
,
891 std::move(*Req
), Status
, SubstitutedConstraintExpr
);
893 R
= new (Record
.getContext()) concepts::ExprRequirement(
894 E
.get
<concepts::Requirement::SubstitutionDiagnostic
*>(),
895 RK
== concepts::Requirement::RK_Simple
, NoexceptLoc
,
898 case concepts::Requirement::RK_Nested
: {
899 bool HasInvalidConstraint
= Record
.readInt();
900 if (HasInvalidConstraint
) {
901 std::string InvalidConstraint
= Record
.readString();
902 char *InvalidConstraintBuf
=
903 new (Record
.getContext()) char[InvalidConstraint
.size()];
904 std::copy(InvalidConstraint
.begin(), InvalidConstraint
.end(),
905 InvalidConstraintBuf
);
906 R
= new (Record
.getContext()) concepts::NestedRequirement(
908 StringRef(InvalidConstraintBuf
, InvalidConstraint
.size()),
909 readConstraintSatisfaction(Record
));
912 Expr
*E
= Record
.readExpr();
913 if (E
->isInstantiationDependent())
914 R
= new (Record
.getContext()) concepts::NestedRequirement(E
);
916 R
= new (Record
.getContext())
917 concepts::NestedRequirement(Record
.getContext(), E
,
918 readConstraintSatisfaction(Record
));
923 Requirements
.push_back(R
);
925 std::copy(Requirements
.begin(), Requirements
.end(),
926 E
->getTrailingObjects
<concepts::Requirement
*>());
927 E
->RBraceLoc
= Record
.readSourceLocation();
930 void ASTStmtReader::VisitArraySubscriptExpr(ArraySubscriptExpr
*E
) {
932 E
->setLHS(Record
.readSubExpr());
933 E
->setRHS(Record
.readSubExpr());
934 E
->setRBracketLoc(readSourceLocation());
937 void ASTStmtReader::VisitMatrixSubscriptExpr(MatrixSubscriptExpr
*E
) {
939 E
->setBase(Record
.readSubExpr());
940 E
->setRowIdx(Record
.readSubExpr());
941 E
->setColumnIdx(Record
.readSubExpr());
942 E
->setRBracketLoc(readSourceLocation());
945 void ASTStmtReader::VisitOMPArraySectionExpr(OMPArraySectionExpr
*E
) {
947 E
->setBase(Record
.readSubExpr());
948 E
->setLowerBound(Record
.readSubExpr());
949 E
->setLength(Record
.readSubExpr());
950 E
->setStride(Record
.readSubExpr());
951 E
->setColonLocFirst(readSourceLocation());
952 E
->setColonLocSecond(readSourceLocation());
953 E
->setRBracketLoc(readSourceLocation());
956 void ASTStmtReader::VisitOMPArrayShapingExpr(OMPArrayShapingExpr
*E
) {
958 unsigned NumDims
= Record
.readInt();
959 E
->setBase(Record
.readSubExpr());
960 SmallVector
<Expr
*, 4> Dims(NumDims
);
961 for (unsigned I
= 0; I
< NumDims
; ++I
)
962 Dims
[I
] = Record
.readSubExpr();
963 E
->setDimensions(Dims
);
964 SmallVector
<SourceRange
, 4> SRs(NumDims
);
965 for (unsigned I
= 0; I
< NumDims
; ++I
)
966 SRs
[I
] = readSourceRange();
967 E
->setBracketsRanges(SRs
);
968 E
->setLParenLoc(readSourceLocation());
969 E
->setRParenLoc(readSourceLocation());
972 void ASTStmtReader::VisitOMPIteratorExpr(OMPIteratorExpr
*E
) {
974 unsigned NumIters
= Record
.readInt();
975 E
->setIteratorKwLoc(readSourceLocation());
976 E
->setLParenLoc(readSourceLocation());
977 E
->setRParenLoc(readSourceLocation());
978 for (unsigned I
= 0; I
< NumIters
; ++I
) {
979 E
->setIteratorDeclaration(I
, Record
.readDeclRef());
980 E
->setAssignmentLoc(I
, readSourceLocation());
981 Expr
*Begin
= Record
.readSubExpr();
982 Expr
*End
= Record
.readSubExpr();
983 Expr
*Step
= Record
.readSubExpr();
984 SourceLocation ColonLoc
= readSourceLocation();
985 SourceLocation SecColonLoc
;
987 SecColonLoc
= readSourceLocation();
988 E
->setIteratorRange(I
, Begin
, ColonLoc
, End
, SecColonLoc
, Step
);
989 // Deserialize helpers
990 OMPIteratorHelperData HD
;
991 HD
.CounterVD
= cast_or_null
<VarDecl
>(Record
.readDeclRef());
992 HD
.Upper
= Record
.readSubExpr();
993 HD
.Update
= Record
.readSubExpr();
994 HD
.CounterUpdate
= Record
.readSubExpr();
999 void ASTStmtReader::VisitCallExpr(CallExpr
*E
) {
1001 unsigned NumArgs
= Record
.readInt();
1002 bool HasFPFeatures
= Record
.readInt();
1003 assert((NumArgs
== E
->getNumArgs()) && "Wrong NumArgs!");
1004 E
->setRParenLoc(readSourceLocation());
1005 E
->setCallee(Record
.readSubExpr());
1006 for (unsigned I
= 0; I
!= NumArgs
; ++I
)
1007 E
->setArg(I
, Record
.readSubExpr());
1008 E
->setADLCallKind(static_cast<CallExpr::ADLCallKind
>(Record
.readInt()));
1010 E
->setStoredFPFeatures(
1011 FPOptionsOverride::getFromOpaqueInt(Record
.readInt()));
1014 void ASTStmtReader::VisitCXXMemberCallExpr(CXXMemberCallExpr
*E
) {
1018 void ASTStmtReader::VisitMemberExpr(MemberExpr
*E
) {
1021 bool HasQualifier
= Record
.readInt();
1022 bool HasFoundDecl
= Record
.readInt();
1023 bool HasTemplateInfo
= Record
.readInt();
1024 unsigned NumTemplateArgs
= Record
.readInt();
1026 E
->Base
= Record
.readSubExpr();
1027 E
->MemberDecl
= Record
.readDeclAs
<ValueDecl
>();
1028 E
->MemberDNLoc
= Record
.readDeclarationNameLoc(E
->MemberDecl
->getDeclName());
1029 E
->MemberLoc
= Record
.readSourceLocation();
1030 E
->MemberExprBits
.IsArrow
= Record
.readInt();
1031 E
->MemberExprBits
.HasQualifierOrFoundDecl
= HasQualifier
|| HasFoundDecl
;
1032 E
->MemberExprBits
.HasTemplateKWAndArgsInfo
= HasTemplateInfo
;
1033 E
->MemberExprBits
.HadMultipleCandidates
= Record
.readInt();
1034 E
->MemberExprBits
.NonOdrUseReason
= Record
.readInt();
1035 E
->MemberExprBits
.OperatorLoc
= Record
.readSourceLocation();
1037 if (HasQualifier
|| HasFoundDecl
) {
1038 DeclAccessPair FoundDecl
;
1040 auto *FoundD
= Record
.readDeclAs
<NamedDecl
>();
1041 auto AS
= (AccessSpecifier
)Record
.readInt();
1042 FoundDecl
= DeclAccessPair::make(FoundD
, AS
);
1044 FoundDecl
= DeclAccessPair::make(E
->MemberDecl
,
1045 E
->MemberDecl
->getAccess());
1047 E
->getTrailingObjects
<MemberExprNameQualifier
>()->FoundDecl
= FoundDecl
;
1049 NestedNameSpecifierLoc QualifierLoc
;
1051 QualifierLoc
= Record
.readNestedNameSpecifierLoc();
1052 E
->getTrailingObjects
<MemberExprNameQualifier
>()->QualifierLoc
=
1056 if (HasTemplateInfo
)
1057 ReadTemplateKWAndArgsInfo(
1058 *E
->getTrailingObjects
<ASTTemplateKWAndArgsInfo
>(),
1059 E
->getTrailingObjects
<TemplateArgumentLoc
>(), NumTemplateArgs
);
1062 void ASTStmtReader::VisitObjCIsaExpr(ObjCIsaExpr
*E
) {
1064 E
->setBase(Record
.readSubExpr());
1065 E
->setIsaMemberLoc(readSourceLocation());
1066 E
->setOpLoc(readSourceLocation());
1067 E
->setArrow(Record
.readInt());
1070 void ASTStmtReader::
1071 VisitObjCIndirectCopyRestoreExpr(ObjCIndirectCopyRestoreExpr
*E
) {
1073 E
->Operand
= Record
.readSubExpr();
1074 E
->setShouldCopy(Record
.readInt());
1077 void ASTStmtReader::VisitObjCBridgedCastExpr(ObjCBridgedCastExpr
*E
) {
1078 VisitExplicitCastExpr(E
);
1079 E
->LParenLoc
= readSourceLocation();
1080 E
->BridgeKeywordLoc
= readSourceLocation();
1081 E
->Kind
= Record
.readInt();
1084 void ASTStmtReader::VisitCastExpr(CastExpr
*E
) {
1086 unsigned NumBaseSpecs
= Record
.readInt();
1087 assert(NumBaseSpecs
== E
->path_size());
1088 unsigned HasFPFeatures
= Record
.readInt();
1089 assert(E
->hasStoredFPFeatures() == HasFPFeatures
);
1090 E
->setSubExpr(Record
.readSubExpr());
1091 E
->setCastKind((CastKind
)Record
.readInt());
1092 CastExpr::path_iterator BaseI
= E
->path_begin();
1093 while (NumBaseSpecs
--) {
1094 auto *BaseSpec
= new (Record
.getContext()) CXXBaseSpecifier
;
1095 *BaseSpec
= Record
.readCXXBaseSpecifier();
1096 *BaseI
++ = BaseSpec
;
1099 *E
->getTrailingFPFeatures() =
1100 FPOptionsOverride::getFromOpaqueInt(Record
.readInt());
1103 void ASTStmtReader::VisitBinaryOperator(BinaryOperator
*E
) {
1104 bool hasFP_Features
;
1106 E
->setHasStoredFPFeatures(hasFP_Features
= Record
.readInt());
1107 E
->setOpcode((BinaryOperator::Opcode
)Record
.readInt());
1108 E
->setLHS(Record
.readSubExpr());
1109 E
->setRHS(Record
.readSubExpr());
1110 E
->setOperatorLoc(readSourceLocation());
1112 E
->setStoredFPFeatures(
1113 FPOptionsOverride::getFromOpaqueInt(Record
.readInt()));
1116 void ASTStmtReader::VisitCompoundAssignOperator(CompoundAssignOperator
*E
) {
1117 VisitBinaryOperator(E
);
1118 E
->setComputationLHSType(Record
.readType());
1119 E
->setComputationResultType(Record
.readType());
1122 void ASTStmtReader::VisitConditionalOperator(ConditionalOperator
*E
) {
1124 E
->SubExprs
[ConditionalOperator::COND
] = Record
.readSubExpr();
1125 E
->SubExprs
[ConditionalOperator::LHS
] = Record
.readSubExpr();
1126 E
->SubExprs
[ConditionalOperator::RHS
] = Record
.readSubExpr();
1127 E
->QuestionLoc
= readSourceLocation();
1128 E
->ColonLoc
= readSourceLocation();
1132 ASTStmtReader::VisitBinaryConditionalOperator(BinaryConditionalOperator
*E
) {
1134 E
->OpaqueValue
= cast
<OpaqueValueExpr
>(Record
.readSubExpr());
1135 E
->SubExprs
[BinaryConditionalOperator::COMMON
] = Record
.readSubExpr();
1136 E
->SubExprs
[BinaryConditionalOperator::COND
] = Record
.readSubExpr();
1137 E
->SubExprs
[BinaryConditionalOperator::LHS
] = Record
.readSubExpr();
1138 E
->SubExprs
[BinaryConditionalOperator::RHS
] = Record
.readSubExpr();
1139 E
->QuestionLoc
= readSourceLocation();
1140 E
->ColonLoc
= readSourceLocation();
1143 void ASTStmtReader::VisitImplicitCastExpr(ImplicitCastExpr
*E
) {
1145 E
->setIsPartOfExplicitCast(Record
.readInt());
1148 void ASTStmtReader::VisitExplicitCastExpr(ExplicitCastExpr
*E
) {
1150 E
->setTypeInfoAsWritten(readTypeSourceInfo());
1153 void ASTStmtReader::VisitCStyleCastExpr(CStyleCastExpr
*E
) {
1154 VisitExplicitCastExpr(E
);
1155 E
->setLParenLoc(readSourceLocation());
1156 E
->setRParenLoc(readSourceLocation());
1159 void ASTStmtReader::VisitCompoundLiteralExpr(CompoundLiteralExpr
*E
) {
1161 E
->setLParenLoc(readSourceLocation());
1162 E
->setTypeSourceInfo(readTypeSourceInfo());
1163 E
->setInitializer(Record
.readSubExpr());
1164 E
->setFileScope(Record
.readInt());
1167 void ASTStmtReader::VisitExtVectorElementExpr(ExtVectorElementExpr
*E
) {
1169 E
->setBase(Record
.readSubExpr());
1170 E
->setAccessor(Record
.readIdentifier());
1171 E
->setAccessorLoc(readSourceLocation());
1174 void ASTStmtReader::VisitInitListExpr(InitListExpr
*E
) {
1176 if (auto *SyntForm
= cast_or_null
<InitListExpr
>(Record
.readSubStmt()))
1177 E
->setSyntacticForm(SyntForm
);
1178 E
->setLBraceLoc(readSourceLocation());
1179 E
->setRBraceLoc(readSourceLocation());
1180 bool isArrayFiller
= Record
.readInt();
1181 Expr
*filler
= nullptr;
1182 if (isArrayFiller
) {
1183 filler
= Record
.readSubExpr();
1184 E
->ArrayFillerOrUnionFieldInit
= filler
;
1186 E
->ArrayFillerOrUnionFieldInit
= readDeclAs
<FieldDecl
>();
1187 E
->sawArrayRangeDesignator(Record
.readInt());
1188 unsigned NumInits
= Record
.readInt();
1189 E
->reserveInits(Record
.getContext(), NumInits
);
1190 if (isArrayFiller
) {
1191 for (unsigned I
= 0; I
!= NumInits
; ++I
) {
1192 Expr
*init
= Record
.readSubExpr();
1193 E
->updateInit(Record
.getContext(), I
, init
? init
: filler
);
1196 for (unsigned I
= 0; I
!= NumInits
; ++I
)
1197 E
->updateInit(Record
.getContext(), I
, Record
.readSubExpr());
1201 void ASTStmtReader::VisitDesignatedInitExpr(DesignatedInitExpr
*E
) {
1202 using Designator
= DesignatedInitExpr::Designator
;
1205 unsigned NumSubExprs
= Record
.readInt();
1206 assert(NumSubExprs
== E
->getNumSubExprs() && "Wrong number of subexprs");
1207 for (unsigned I
= 0; I
!= NumSubExprs
; ++I
)
1208 E
->setSubExpr(I
, Record
.readSubExpr());
1209 E
->setEqualOrColonLoc(readSourceLocation());
1210 E
->setGNUSyntax(Record
.readInt());
1212 SmallVector
<Designator
, 4> Designators
;
1213 while (Record
.getIdx() < Record
.size()) {
1214 switch ((DesignatorTypes
)Record
.readInt()) {
1215 case DESIG_FIELD_DECL
: {
1216 auto *Field
= readDeclAs
<FieldDecl
>();
1217 SourceLocation DotLoc
= readSourceLocation();
1218 SourceLocation FieldLoc
= readSourceLocation();
1219 Designators
.push_back(Designator::CreateFieldDesignator(
1220 Field
->getIdentifier(), DotLoc
, FieldLoc
));
1221 Designators
.back().setFieldDecl(Field
);
1225 case DESIG_FIELD_NAME
: {
1226 const IdentifierInfo
*Name
= Record
.readIdentifier();
1227 SourceLocation DotLoc
= readSourceLocation();
1228 SourceLocation FieldLoc
= readSourceLocation();
1229 Designators
.push_back(Designator::CreateFieldDesignator(Name
, DotLoc
,
1235 unsigned Index
= Record
.readInt();
1236 SourceLocation LBracketLoc
= readSourceLocation();
1237 SourceLocation RBracketLoc
= readSourceLocation();
1238 Designators
.push_back(Designator::CreateArrayDesignator(Index
,
1244 case DESIG_ARRAY_RANGE
: {
1245 unsigned Index
= Record
.readInt();
1246 SourceLocation LBracketLoc
= readSourceLocation();
1247 SourceLocation EllipsisLoc
= readSourceLocation();
1248 SourceLocation RBracketLoc
= readSourceLocation();
1249 Designators
.push_back(Designator::CreateArrayRangeDesignator(
1250 Index
, LBracketLoc
, EllipsisLoc
, RBracketLoc
));
1255 E
->setDesignators(Record
.getContext(),
1256 Designators
.data(), Designators
.size());
1259 void ASTStmtReader::VisitDesignatedInitUpdateExpr(DesignatedInitUpdateExpr
*E
) {
1261 E
->setBase(Record
.readSubExpr());
1262 E
->setUpdater(Record
.readSubExpr());
1265 void ASTStmtReader::VisitNoInitExpr(NoInitExpr
*E
) {
1269 void ASTStmtReader::VisitArrayInitLoopExpr(ArrayInitLoopExpr
*E
) {
1271 E
->SubExprs
[0] = Record
.readSubExpr();
1272 E
->SubExprs
[1] = Record
.readSubExpr();
1275 void ASTStmtReader::VisitArrayInitIndexExpr(ArrayInitIndexExpr
*E
) {
1279 void ASTStmtReader::VisitImplicitValueInitExpr(ImplicitValueInitExpr
*E
) {
1283 void ASTStmtReader::VisitVAArgExpr(VAArgExpr
*E
) {
1285 E
->setSubExpr(Record
.readSubExpr());
1286 E
->setWrittenTypeInfo(readTypeSourceInfo());
1287 E
->setBuiltinLoc(readSourceLocation());
1288 E
->setRParenLoc(readSourceLocation());
1289 E
->setIsMicrosoftABI(Record
.readInt());
1292 void ASTStmtReader::VisitSourceLocExpr(SourceLocExpr
*E
) {
1294 E
->ParentContext
= readDeclAs
<DeclContext
>();
1295 E
->BuiltinLoc
= readSourceLocation();
1296 E
->RParenLoc
= readSourceLocation();
1297 E
->SourceLocExprBits
.Kind
=
1298 static_cast<SourceLocExpr::IdentKind
>(Record
.readInt());
1301 void ASTStmtReader::VisitAddrLabelExpr(AddrLabelExpr
*E
) {
1303 E
->setAmpAmpLoc(readSourceLocation());
1304 E
->setLabelLoc(readSourceLocation());
1305 E
->setLabel(readDeclAs
<LabelDecl
>());
1308 void ASTStmtReader::VisitStmtExpr(StmtExpr
*E
) {
1310 E
->setLParenLoc(readSourceLocation());
1311 E
->setRParenLoc(readSourceLocation());
1312 E
->setSubStmt(cast_or_null
<CompoundStmt
>(Record
.readSubStmt()));
1313 E
->StmtExprBits
.TemplateDepth
= Record
.readInt();
1316 void ASTStmtReader::VisitChooseExpr(ChooseExpr
*E
) {
1318 E
->setCond(Record
.readSubExpr());
1319 E
->setLHS(Record
.readSubExpr());
1320 E
->setRHS(Record
.readSubExpr());
1321 E
->setBuiltinLoc(readSourceLocation());
1322 E
->setRParenLoc(readSourceLocation());
1323 E
->setIsConditionTrue(Record
.readInt());
1326 void ASTStmtReader::VisitGNUNullExpr(GNUNullExpr
*E
) {
1328 E
->setTokenLocation(readSourceLocation());
1331 void ASTStmtReader::VisitShuffleVectorExpr(ShuffleVectorExpr
*E
) {
1333 SmallVector
<Expr
*, 16> Exprs
;
1334 unsigned NumExprs
= Record
.readInt();
1336 Exprs
.push_back(Record
.readSubExpr());
1337 E
->setExprs(Record
.getContext(), Exprs
);
1338 E
->setBuiltinLoc(readSourceLocation());
1339 E
->setRParenLoc(readSourceLocation());
1342 void ASTStmtReader::VisitConvertVectorExpr(ConvertVectorExpr
*E
) {
1344 E
->BuiltinLoc
= readSourceLocation();
1345 E
->RParenLoc
= readSourceLocation();
1346 E
->TInfo
= readTypeSourceInfo();
1347 E
->SrcExpr
= Record
.readSubExpr();
1350 void ASTStmtReader::VisitBlockExpr(BlockExpr
*E
) {
1352 E
->setBlockDecl(readDeclAs
<BlockDecl
>());
1355 void ASTStmtReader::VisitGenericSelectionExpr(GenericSelectionExpr
*E
) {
1358 unsigned NumAssocs
= Record
.readInt();
1359 assert(NumAssocs
== E
->getNumAssocs() && "Wrong NumAssocs!");
1360 E
->IsExprPredicate
= Record
.readInt();
1361 E
->ResultIndex
= Record
.readInt();
1362 E
->GenericSelectionExprBits
.GenericLoc
= readSourceLocation();
1363 E
->DefaultLoc
= readSourceLocation();
1364 E
->RParenLoc
= readSourceLocation();
1366 Stmt
**Stmts
= E
->getTrailingObjects
<Stmt
*>();
1367 // Add 1 to account for the controlling expression which is the first
1368 // expression in the trailing array of Stmt *. This is not needed for
1369 // the trailing array of TypeSourceInfo *.
1370 for (unsigned I
= 0, N
= NumAssocs
+ 1; I
< N
; ++I
)
1371 Stmts
[I
] = Record
.readSubExpr();
1373 TypeSourceInfo
**TSIs
= E
->getTrailingObjects
<TypeSourceInfo
*>();
1374 for (unsigned I
= 0, N
= NumAssocs
; I
< N
; ++I
)
1375 TSIs
[I
] = readTypeSourceInfo();
1378 void ASTStmtReader::VisitPseudoObjectExpr(PseudoObjectExpr
*E
) {
1380 unsigned numSemanticExprs
= Record
.readInt();
1381 assert(numSemanticExprs
+ 1 == E
->PseudoObjectExprBits
.NumSubExprs
);
1382 E
->PseudoObjectExprBits
.ResultIndex
= Record
.readInt();
1384 // Read the syntactic expression.
1385 E
->getSubExprsBuffer()[0] = Record
.readSubExpr();
1387 // Read all the semantic expressions.
1388 for (unsigned i
= 0; i
!= numSemanticExprs
; ++i
) {
1389 Expr
*subExpr
= Record
.readSubExpr();
1390 E
->getSubExprsBuffer()[i
+1] = subExpr
;
1394 void ASTStmtReader::VisitAtomicExpr(AtomicExpr
*E
) {
1396 E
->Op
= AtomicExpr::AtomicOp(Record
.readInt());
1397 E
->NumSubExprs
= AtomicExpr::getNumSubExprs(E
->Op
);
1398 for (unsigned I
= 0; I
!= E
->NumSubExprs
; ++I
)
1399 E
->SubExprs
[I
] = Record
.readSubExpr();
1400 E
->BuiltinLoc
= readSourceLocation();
1401 E
->RParenLoc
= readSourceLocation();
1404 //===----------------------------------------------------------------------===//
1405 // Objective-C Expressions and Statements
1407 void ASTStmtReader::VisitObjCStringLiteral(ObjCStringLiteral
*E
) {
1409 E
->setString(cast
<StringLiteral
>(Record
.readSubStmt()));
1410 E
->setAtLoc(readSourceLocation());
1413 void ASTStmtReader::VisitObjCBoxedExpr(ObjCBoxedExpr
*E
) {
1415 // could be one of several IntegerLiteral, FloatLiteral, etc.
1416 E
->SubExpr
= Record
.readSubStmt();
1417 E
->BoxingMethod
= readDeclAs
<ObjCMethodDecl
>();
1418 E
->Range
= readSourceRange();
1421 void ASTStmtReader::VisitObjCArrayLiteral(ObjCArrayLiteral
*E
) {
1423 unsigned NumElements
= Record
.readInt();
1424 assert(NumElements
== E
->getNumElements() && "Wrong number of elements");
1425 Expr
**Elements
= E
->getElements();
1426 for (unsigned I
= 0, N
= NumElements
; I
!= N
; ++I
)
1427 Elements
[I
] = Record
.readSubExpr();
1428 E
->ArrayWithObjectsMethod
= readDeclAs
<ObjCMethodDecl
>();
1429 E
->Range
= readSourceRange();
1432 void ASTStmtReader::VisitObjCDictionaryLiteral(ObjCDictionaryLiteral
*E
) {
1434 unsigned NumElements
= Record
.readInt();
1435 assert(NumElements
== E
->getNumElements() && "Wrong number of elements");
1436 bool HasPackExpansions
= Record
.readInt();
1437 assert(HasPackExpansions
== E
->HasPackExpansions
&&"Pack expansion mismatch");
1439 E
->getTrailingObjects
<ObjCDictionaryLiteral::KeyValuePair
>();
1441 E
->getTrailingObjects
<ObjCDictionaryLiteral::ExpansionData
>();
1442 for (unsigned I
= 0; I
!= NumElements
; ++I
) {
1443 KeyValues
[I
].Key
= Record
.readSubExpr();
1444 KeyValues
[I
].Value
= Record
.readSubExpr();
1445 if (HasPackExpansions
) {
1446 Expansions
[I
].EllipsisLoc
= readSourceLocation();
1447 Expansions
[I
].NumExpansionsPlusOne
= Record
.readInt();
1450 E
->DictWithObjectsMethod
= readDeclAs
<ObjCMethodDecl
>();
1451 E
->Range
= readSourceRange();
1454 void ASTStmtReader::VisitObjCEncodeExpr(ObjCEncodeExpr
*E
) {
1456 E
->setEncodedTypeSourceInfo(readTypeSourceInfo());
1457 E
->setAtLoc(readSourceLocation());
1458 E
->setRParenLoc(readSourceLocation());
1461 void ASTStmtReader::VisitObjCSelectorExpr(ObjCSelectorExpr
*E
) {
1463 E
->setSelector(Record
.readSelector());
1464 E
->setAtLoc(readSourceLocation());
1465 E
->setRParenLoc(readSourceLocation());
1468 void ASTStmtReader::VisitObjCProtocolExpr(ObjCProtocolExpr
*E
) {
1470 E
->setProtocol(readDeclAs
<ObjCProtocolDecl
>());
1471 E
->setAtLoc(readSourceLocation());
1472 E
->ProtoLoc
= readSourceLocation();
1473 E
->setRParenLoc(readSourceLocation());
1476 void ASTStmtReader::VisitObjCIvarRefExpr(ObjCIvarRefExpr
*E
) {
1478 E
->setDecl(readDeclAs
<ObjCIvarDecl
>());
1479 E
->setLocation(readSourceLocation());
1480 E
->setOpLoc(readSourceLocation());
1481 E
->setBase(Record
.readSubExpr());
1482 E
->setIsArrow(Record
.readInt());
1483 E
->setIsFreeIvar(Record
.readInt());
1486 void ASTStmtReader::VisitObjCPropertyRefExpr(ObjCPropertyRefExpr
*E
) {
1488 unsigned MethodRefFlags
= Record
.readInt();
1489 bool Implicit
= Record
.readInt() != 0;
1491 auto *Getter
= readDeclAs
<ObjCMethodDecl
>();
1492 auto *Setter
= readDeclAs
<ObjCMethodDecl
>();
1493 E
->setImplicitProperty(Getter
, Setter
, MethodRefFlags
);
1495 E
->setExplicitProperty(readDeclAs
<ObjCPropertyDecl
>(), MethodRefFlags
);
1497 E
->setLocation(readSourceLocation());
1498 E
->setReceiverLocation(readSourceLocation());
1499 switch (Record
.readInt()) {
1501 E
->setBase(Record
.readSubExpr());
1504 E
->setSuperReceiver(Record
.readType());
1507 E
->setClassReceiver(readDeclAs
<ObjCInterfaceDecl
>());
1512 void ASTStmtReader::VisitObjCSubscriptRefExpr(ObjCSubscriptRefExpr
*E
) {
1514 E
->setRBracket(readSourceLocation());
1515 E
->setBaseExpr(Record
.readSubExpr());
1516 E
->setKeyExpr(Record
.readSubExpr());
1517 E
->GetAtIndexMethodDecl
= readDeclAs
<ObjCMethodDecl
>();
1518 E
->SetAtIndexMethodDecl
= readDeclAs
<ObjCMethodDecl
>();
1521 void ASTStmtReader::VisitObjCMessageExpr(ObjCMessageExpr
*E
) {
1523 assert(Record
.peekInt() == E
->getNumArgs());
1525 unsigned NumStoredSelLocs
= Record
.readInt();
1526 E
->SelLocsKind
= Record
.readInt();
1527 E
->setDelegateInitCall(Record
.readInt());
1528 E
->IsImplicit
= Record
.readInt();
1529 auto Kind
= static_cast<ObjCMessageExpr::ReceiverKind
>(Record
.readInt());
1531 case ObjCMessageExpr::Instance
:
1532 E
->setInstanceReceiver(Record
.readSubExpr());
1535 case ObjCMessageExpr::Class
:
1536 E
->setClassReceiver(readTypeSourceInfo());
1539 case ObjCMessageExpr::SuperClass
:
1540 case ObjCMessageExpr::SuperInstance
: {
1541 QualType T
= Record
.readType();
1542 SourceLocation SuperLoc
= readSourceLocation();
1543 E
->setSuper(SuperLoc
, T
, Kind
== ObjCMessageExpr::SuperInstance
);
1548 assert(Kind
== E
->getReceiverKind());
1550 if (Record
.readInt())
1551 E
->setMethodDecl(readDeclAs
<ObjCMethodDecl
>());
1553 E
->setSelector(Record
.readSelector());
1555 E
->LBracLoc
= readSourceLocation();
1556 E
->RBracLoc
= readSourceLocation();
1558 for (unsigned I
= 0, N
= E
->getNumArgs(); I
!= N
; ++I
)
1559 E
->setArg(I
, Record
.readSubExpr());
1561 SourceLocation
*Locs
= E
->getStoredSelLocs();
1562 for (unsigned I
= 0; I
!= NumStoredSelLocs
; ++I
)
1563 Locs
[I
] = readSourceLocation();
1566 void ASTStmtReader::VisitObjCForCollectionStmt(ObjCForCollectionStmt
*S
) {
1568 S
->setElement(Record
.readSubStmt());
1569 S
->setCollection(Record
.readSubExpr());
1570 S
->setBody(Record
.readSubStmt());
1571 S
->setForLoc(readSourceLocation());
1572 S
->setRParenLoc(readSourceLocation());
1575 void ASTStmtReader::VisitObjCAtCatchStmt(ObjCAtCatchStmt
*S
) {
1577 S
->setCatchBody(Record
.readSubStmt());
1578 S
->setCatchParamDecl(readDeclAs
<VarDecl
>());
1579 S
->setAtCatchLoc(readSourceLocation());
1580 S
->setRParenLoc(readSourceLocation());
1583 void ASTStmtReader::VisitObjCAtFinallyStmt(ObjCAtFinallyStmt
*S
) {
1585 S
->setFinallyBody(Record
.readSubStmt());
1586 S
->setAtFinallyLoc(readSourceLocation());
1589 void ASTStmtReader::VisitObjCAutoreleasePoolStmt(ObjCAutoreleasePoolStmt
*S
) {
1590 VisitStmt(S
); // FIXME: no test coverage.
1591 S
->setSubStmt(Record
.readSubStmt());
1592 S
->setAtLoc(readSourceLocation());
1595 void ASTStmtReader::VisitObjCAtTryStmt(ObjCAtTryStmt
*S
) {
1597 assert(Record
.peekInt() == S
->getNumCatchStmts());
1599 bool HasFinally
= Record
.readInt();
1600 S
->setTryBody(Record
.readSubStmt());
1601 for (unsigned I
= 0, N
= S
->getNumCatchStmts(); I
!= N
; ++I
)
1602 S
->setCatchStmt(I
, cast_or_null
<ObjCAtCatchStmt
>(Record
.readSubStmt()));
1605 S
->setFinallyStmt(Record
.readSubStmt());
1606 S
->setAtTryLoc(readSourceLocation());
1609 void ASTStmtReader::VisitObjCAtSynchronizedStmt(ObjCAtSynchronizedStmt
*S
) {
1610 VisitStmt(S
); // FIXME: no test coverage.
1611 S
->setSynchExpr(Record
.readSubStmt());
1612 S
->setSynchBody(Record
.readSubStmt());
1613 S
->setAtSynchronizedLoc(readSourceLocation());
1616 void ASTStmtReader::VisitObjCAtThrowStmt(ObjCAtThrowStmt
*S
) {
1617 VisitStmt(S
); // FIXME: no test coverage.
1618 S
->setThrowExpr(Record
.readSubStmt());
1619 S
->setThrowLoc(readSourceLocation());
1622 void ASTStmtReader::VisitObjCBoolLiteralExpr(ObjCBoolLiteralExpr
*E
) {
1624 E
->setValue(Record
.readInt());
1625 E
->setLocation(readSourceLocation());
1628 void ASTStmtReader::VisitObjCAvailabilityCheckExpr(ObjCAvailabilityCheckExpr
*E
) {
1630 SourceRange R
= Record
.readSourceRange();
1631 E
->AtLoc
= R
.getBegin();
1632 E
->RParen
= R
.getEnd();
1633 E
->VersionToCheck
= Record
.readVersionTuple();
1636 //===----------------------------------------------------------------------===//
1637 // C++ Expressions and Statements
1638 //===----------------------------------------------------------------------===//
1640 void ASTStmtReader::VisitCXXCatchStmt(CXXCatchStmt
*S
) {
1642 S
->CatchLoc
= readSourceLocation();
1643 S
->ExceptionDecl
= readDeclAs
<VarDecl
>();
1644 S
->HandlerBlock
= Record
.readSubStmt();
1647 void ASTStmtReader::VisitCXXTryStmt(CXXTryStmt
*S
) {
1649 assert(Record
.peekInt() == S
->getNumHandlers() && "NumStmtFields is wrong ?");
1651 S
->TryLoc
= readSourceLocation();
1652 S
->getStmts()[0] = Record
.readSubStmt();
1653 for (unsigned i
= 0, e
= S
->getNumHandlers(); i
!= e
; ++i
)
1654 S
->getStmts()[i
+ 1] = Record
.readSubStmt();
1657 void ASTStmtReader::VisitCXXForRangeStmt(CXXForRangeStmt
*S
) {
1659 S
->ForLoc
= readSourceLocation();
1660 S
->CoawaitLoc
= readSourceLocation();
1661 S
->ColonLoc
= readSourceLocation();
1662 S
->RParenLoc
= readSourceLocation();
1663 S
->setInit(Record
.readSubStmt());
1664 S
->setRangeStmt(Record
.readSubStmt());
1665 S
->setBeginStmt(Record
.readSubStmt());
1666 S
->setEndStmt(Record
.readSubStmt());
1667 S
->setCond(Record
.readSubExpr());
1668 S
->setInc(Record
.readSubExpr());
1669 S
->setLoopVarStmt(Record
.readSubStmt());
1670 S
->setBody(Record
.readSubStmt());
1673 void ASTStmtReader::VisitMSDependentExistsStmt(MSDependentExistsStmt
*S
) {
1675 S
->KeywordLoc
= readSourceLocation();
1676 S
->IsIfExists
= Record
.readInt();
1677 S
->QualifierLoc
= Record
.readNestedNameSpecifierLoc();
1678 S
->NameInfo
= Record
.readDeclarationNameInfo();
1679 S
->SubStmt
= Record
.readSubStmt();
1682 void ASTStmtReader::VisitCXXOperatorCallExpr(CXXOperatorCallExpr
*E
) {
1684 E
->CXXOperatorCallExprBits
.OperatorKind
= Record
.readInt();
1685 E
->Range
= Record
.readSourceRange();
1688 void ASTStmtReader::VisitCXXRewrittenBinaryOperator(
1689 CXXRewrittenBinaryOperator
*E
) {
1691 E
->CXXRewrittenBinaryOperatorBits
.IsReversed
= Record
.readInt();
1692 E
->SemanticForm
= Record
.readSubExpr();
1695 void ASTStmtReader::VisitCXXConstructExpr(CXXConstructExpr
*E
) {
1698 unsigned NumArgs
= Record
.readInt();
1699 assert((NumArgs
== E
->getNumArgs()) && "Wrong NumArgs!");
1701 E
->CXXConstructExprBits
.Elidable
= Record
.readInt();
1702 E
->CXXConstructExprBits
.HadMultipleCandidates
= Record
.readInt();
1703 E
->CXXConstructExprBits
.ListInitialization
= Record
.readInt();
1704 E
->CXXConstructExprBits
.StdInitListInitialization
= Record
.readInt();
1705 E
->CXXConstructExprBits
.ZeroInitialization
= Record
.readInt();
1706 E
->CXXConstructExprBits
.ConstructionKind
= Record
.readInt();
1707 E
->CXXConstructExprBits
.IsImmediateEscalating
= Record
.readInt();
1708 E
->CXXConstructExprBits
.Loc
= readSourceLocation();
1709 E
->Constructor
= readDeclAs
<CXXConstructorDecl
>();
1710 E
->ParenOrBraceRange
= readSourceRange();
1712 for (unsigned I
= 0; I
!= NumArgs
; ++I
)
1713 E
->setArg(I
, Record
.readSubExpr());
1716 void ASTStmtReader::VisitCXXInheritedCtorInitExpr(CXXInheritedCtorInitExpr
*E
) {
1718 E
->Constructor
= readDeclAs
<CXXConstructorDecl
>();
1719 E
->Loc
= readSourceLocation();
1720 E
->ConstructsVirtualBase
= Record
.readInt();
1721 E
->InheritedFromVirtualBase
= Record
.readInt();
1724 void ASTStmtReader::VisitCXXTemporaryObjectExpr(CXXTemporaryObjectExpr
*E
) {
1725 VisitCXXConstructExpr(E
);
1726 E
->TSI
= readTypeSourceInfo();
1729 void ASTStmtReader::VisitLambdaExpr(LambdaExpr
*E
) {
1731 unsigned NumCaptures
= Record
.readInt();
1733 assert(NumCaptures
== E
->LambdaExprBits
.NumCaptures
);
1734 E
->IntroducerRange
= readSourceRange();
1735 E
->LambdaExprBits
.CaptureDefault
= Record
.readInt();
1736 E
->CaptureDefaultLoc
= readSourceLocation();
1737 E
->LambdaExprBits
.ExplicitParams
= Record
.readInt();
1738 E
->LambdaExprBits
.ExplicitResultType
= Record
.readInt();
1739 E
->ClosingBrace
= readSourceLocation();
1741 // Read capture initializers.
1742 for (LambdaExpr::capture_init_iterator C
= E
->capture_init_begin(),
1743 CEnd
= E
->capture_init_end();
1745 *C
= Record
.readSubExpr();
1747 // The body will be lazily deserialized when needed from the call operator
1752 ASTStmtReader::VisitCXXStdInitializerListExpr(CXXStdInitializerListExpr
*E
) {
1754 E
->SubExpr
= Record
.readSubExpr();
1757 void ASTStmtReader::VisitCXXNamedCastExpr(CXXNamedCastExpr
*E
) {
1758 VisitExplicitCastExpr(E
);
1759 SourceRange R
= readSourceRange();
1760 E
->Loc
= R
.getBegin();
1761 E
->RParenLoc
= R
.getEnd();
1762 R
= readSourceRange();
1763 E
->AngleBrackets
= R
;
1766 void ASTStmtReader::VisitCXXStaticCastExpr(CXXStaticCastExpr
*E
) {
1767 return VisitCXXNamedCastExpr(E
);
1770 void ASTStmtReader::VisitCXXDynamicCastExpr(CXXDynamicCastExpr
*E
) {
1771 return VisitCXXNamedCastExpr(E
);
1774 void ASTStmtReader::VisitCXXReinterpretCastExpr(CXXReinterpretCastExpr
*E
) {
1775 return VisitCXXNamedCastExpr(E
);
1778 void ASTStmtReader::VisitCXXAddrspaceCastExpr(CXXAddrspaceCastExpr
*E
) {
1779 return VisitCXXNamedCastExpr(E
);
1782 void ASTStmtReader::VisitCXXConstCastExpr(CXXConstCastExpr
*E
) {
1783 return VisitCXXNamedCastExpr(E
);
1786 void ASTStmtReader::VisitCXXFunctionalCastExpr(CXXFunctionalCastExpr
*E
) {
1787 VisitExplicitCastExpr(E
);
1788 E
->setLParenLoc(readSourceLocation());
1789 E
->setRParenLoc(readSourceLocation());
1792 void ASTStmtReader::VisitBuiltinBitCastExpr(BuiltinBitCastExpr
*E
) {
1793 VisitExplicitCastExpr(E
);
1794 E
->KWLoc
= readSourceLocation();
1795 E
->RParenLoc
= readSourceLocation();
1798 void ASTStmtReader::VisitUserDefinedLiteral(UserDefinedLiteral
*E
) {
1800 E
->UDSuffixLoc
= readSourceLocation();
1803 void ASTStmtReader::VisitCXXBoolLiteralExpr(CXXBoolLiteralExpr
*E
) {
1805 E
->setValue(Record
.readInt());
1806 E
->setLocation(readSourceLocation());
1809 void ASTStmtReader::VisitCXXNullPtrLiteralExpr(CXXNullPtrLiteralExpr
*E
) {
1811 E
->setLocation(readSourceLocation());
1814 void ASTStmtReader::VisitCXXTypeidExpr(CXXTypeidExpr
*E
) {
1816 E
->setSourceRange(readSourceRange());
1817 if (E
->isTypeOperand())
1818 E
->Operand
= readTypeSourceInfo();
1820 E
->Operand
= Record
.readSubExpr();
1823 void ASTStmtReader::VisitCXXThisExpr(CXXThisExpr
*E
) {
1825 E
->setLocation(readSourceLocation());
1826 E
->setImplicit(Record
.readInt());
1829 void ASTStmtReader::VisitCXXThrowExpr(CXXThrowExpr
*E
) {
1831 E
->CXXThrowExprBits
.ThrowLoc
= readSourceLocation();
1832 E
->Operand
= Record
.readSubExpr();
1833 E
->CXXThrowExprBits
.IsThrownVariableInScope
= Record
.readInt();
1836 void ASTStmtReader::VisitCXXDefaultArgExpr(CXXDefaultArgExpr
*E
) {
1838 E
->Param
= readDeclAs
<ParmVarDecl
>();
1839 E
->UsedContext
= readDeclAs
<DeclContext
>();
1840 E
->CXXDefaultArgExprBits
.Loc
= readSourceLocation();
1841 E
->CXXDefaultArgExprBits
.HasRewrittenInit
= Record
.readInt();
1842 if (E
->CXXDefaultArgExprBits
.HasRewrittenInit
)
1843 *E
->getTrailingObjects
<Expr
*>() = Record
.readSubExpr();
1846 void ASTStmtReader::VisitCXXDefaultInitExpr(CXXDefaultInitExpr
*E
) {
1848 E
->CXXDefaultInitExprBits
.HasRewrittenInit
= Record
.readInt();
1849 E
->Field
= readDeclAs
<FieldDecl
>();
1850 E
->UsedContext
= readDeclAs
<DeclContext
>();
1851 E
->CXXDefaultInitExprBits
.Loc
= readSourceLocation();
1852 if (E
->CXXDefaultInitExprBits
.HasRewrittenInit
)
1853 *E
->getTrailingObjects
<Expr
*>() = Record
.readSubExpr();
1856 void ASTStmtReader::VisitCXXBindTemporaryExpr(CXXBindTemporaryExpr
*E
) {
1858 E
->setTemporary(Record
.readCXXTemporary());
1859 E
->setSubExpr(Record
.readSubExpr());
1862 void ASTStmtReader::VisitCXXScalarValueInitExpr(CXXScalarValueInitExpr
*E
) {
1864 E
->TypeInfo
= readTypeSourceInfo();
1865 E
->CXXScalarValueInitExprBits
.RParenLoc
= readSourceLocation();
1868 void ASTStmtReader::VisitCXXNewExpr(CXXNewExpr
*E
) {
1871 bool IsArray
= Record
.readInt();
1872 bool HasInit
= Record
.readInt();
1873 unsigned NumPlacementArgs
= Record
.readInt();
1874 bool IsParenTypeId
= Record
.readInt();
1876 E
->CXXNewExprBits
.IsGlobalNew
= Record
.readInt();
1877 E
->CXXNewExprBits
.ShouldPassAlignment
= Record
.readInt();
1878 E
->CXXNewExprBits
.UsualArrayDeleteWantsSize
= Record
.readInt();
1879 E
->CXXNewExprBits
.StoredInitializationStyle
= Record
.readInt();
1881 assert((IsArray
== E
->isArray()) && "Wrong IsArray!");
1882 assert((HasInit
== E
->hasInitializer()) && "Wrong HasInit!");
1883 assert((NumPlacementArgs
== E
->getNumPlacementArgs()) &&
1884 "Wrong NumPlacementArgs!");
1885 assert((IsParenTypeId
== E
->isParenTypeId()) && "Wrong IsParenTypeId!");
1888 (void)NumPlacementArgs
;
1890 E
->setOperatorNew(readDeclAs
<FunctionDecl
>());
1891 E
->setOperatorDelete(readDeclAs
<FunctionDecl
>());
1892 E
->AllocatedTypeInfo
= readTypeSourceInfo();
1894 E
->getTrailingObjects
<SourceRange
>()[0] = readSourceRange();
1895 E
->Range
= readSourceRange();
1896 E
->DirectInitRange
= readSourceRange();
1898 // Install all the subexpressions.
1899 for (CXXNewExpr::raw_arg_iterator I
= E
->raw_arg_begin(),
1900 N
= E
->raw_arg_end();
1902 *I
= Record
.readSubStmt();
1905 void ASTStmtReader::VisitCXXDeleteExpr(CXXDeleteExpr
*E
) {
1907 E
->CXXDeleteExprBits
.GlobalDelete
= Record
.readInt();
1908 E
->CXXDeleteExprBits
.ArrayForm
= Record
.readInt();
1909 E
->CXXDeleteExprBits
.ArrayFormAsWritten
= Record
.readInt();
1910 E
->CXXDeleteExprBits
.UsualArrayDeleteWantsSize
= Record
.readInt();
1911 E
->OperatorDelete
= readDeclAs
<FunctionDecl
>();
1912 E
->Argument
= Record
.readSubExpr();
1913 E
->CXXDeleteExprBits
.Loc
= readSourceLocation();
1916 void ASTStmtReader::VisitCXXPseudoDestructorExpr(CXXPseudoDestructorExpr
*E
) {
1919 E
->Base
= Record
.readSubExpr();
1920 E
->IsArrow
= Record
.readInt();
1921 E
->OperatorLoc
= readSourceLocation();
1922 E
->QualifierLoc
= Record
.readNestedNameSpecifierLoc();
1923 E
->ScopeType
= readTypeSourceInfo();
1924 E
->ColonColonLoc
= readSourceLocation();
1925 E
->TildeLoc
= readSourceLocation();
1927 IdentifierInfo
*II
= Record
.readIdentifier();
1929 E
->setDestroyedType(II
, readSourceLocation());
1931 E
->setDestroyedType(readTypeSourceInfo());
1934 void ASTStmtReader::VisitExprWithCleanups(ExprWithCleanups
*E
) {
1937 unsigned NumObjects
= Record
.readInt();
1938 assert(NumObjects
== E
->getNumObjects());
1939 for (unsigned i
= 0; i
!= NumObjects
; ++i
) {
1940 unsigned CleanupKind
= Record
.readInt();
1941 ExprWithCleanups::CleanupObject Obj
;
1942 if (CleanupKind
== COK_Block
)
1943 Obj
= readDeclAs
<BlockDecl
>();
1944 else if (CleanupKind
== COK_CompoundLiteral
)
1945 Obj
= cast
<CompoundLiteralExpr
>(Record
.readSubExpr());
1947 llvm_unreachable("unexpected cleanup object type");
1948 E
->getTrailingObjects
<ExprWithCleanups::CleanupObject
>()[i
] = Obj
;
1951 E
->ExprWithCleanupsBits
.CleanupsHaveSideEffects
= Record
.readInt();
1952 E
->SubExpr
= Record
.readSubExpr();
1955 void ASTStmtReader::VisitCXXDependentScopeMemberExpr(
1956 CXXDependentScopeMemberExpr
*E
) {
1959 bool HasTemplateKWAndArgsInfo
= Record
.readInt();
1960 unsigned NumTemplateArgs
= Record
.readInt();
1961 bool HasFirstQualifierFoundInScope
= Record
.readInt();
1963 assert((HasTemplateKWAndArgsInfo
== E
->hasTemplateKWAndArgsInfo()) &&
1964 "Wrong HasTemplateKWAndArgsInfo!");
1966 (HasFirstQualifierFoundInScope
== E
->hasFirstQualifierFoundInScope()) &&
1967 "Wrong HasFirstQualifierFoundInScope!");
1969 if (HasTemplateKWAndArgsInfo
)
1970 ReadTemplateKWAndArgsInfo(
1971 *E
->getTrailingObjects
<ASTTemplateKWAndArgsInfo
>(),
1972 E
->getTrailingObjects
<TemplateArgumentLoc
>(), NumTemplateArgs
);
1974 assert((NumTemplateArgs
== E
->getNumTemplateArgs()) &&
1975 "Wrong NumTemplateArgs!");
1977 E
->CXXDependentScopeMemberExprBits
.IsArrow
= Record
.readInt();
1978 E
->CXXDependentScopeMemberExprBits
.OperatorLoc
= readSourceLocation();
1979 E
->BaseType
= Record
.readType();
1980 E
->QualifierLoc
= Record
.readNestedNameSpecifierLoc();
1981 E
->Base
= Record
.readSubExpr();
1983 if (HasFirstQualifierFoundInScope
)
1984 *E
->getTrailingObjects
<NamedDecl
*>() = readDeclAs
<NamedDecl
>();
1986 E
->MemberNameInfo
= Record
.readDeclarationNameInfo();
1990 ASTStmtReader::VisitDependentScopeDeclRefExpr(DependentScopeDeclRefExpr
*E
) {
1993 if (Record
.readInt()) // HasTemplateKWAndArgsInfo
1994 ReadTemplateKWAndArgsInfo(
1995 *E
->getTrailingObjects
<ASTTemplateKWAndArgsInfo
>(),
1996 E
->getTrailingObjects
<TemplateArgumentLoc
>(),
1997 /*NumTemplateArgs=*/Record
.readInt());
1999 E
->QualifierLoc
= Record
.readNestedNameSpecifierLoc();
2000 E
->NameInfo
= Record
.readDeclarationNameInfo();
2004 ASTStmtReader::VisitCXXUnresolvedConstructExpr(CXXUnresolvedConstructExpr
*E
) {
2006 assert(Record
.peekInt() == E
->getNumArgs() &&
2007 "Read wrong record during creation ?");
2009 for (unsigned I
= 0, N
= E
->getNumArgs(); I
!= N
; ++I
)
2010 E
->setArg(I
, Record
.readSubExpr());
2011 E
->TypeAndInitForm
.setPointer(readTypeSourceInfo());
2012 E
->setLParenLoc(readSourceLocation());
2013 E
->setRParenLoc(readSourceLocation());
2014 E
->TypeAndInitForm
.setInt(Record
.readInt());
2017 void ASTStmtReader::VisitOverloadExpr(OverloadExpr
*E
) {
2020 unsigned NumResults
= Record
.readInt();
2021 bool HasTemplateKWAndArgsInfo
= Record
.readInt();
2022 assert((E
->getNumDecls() == NumResults
) && "Wrong NumResults!");
2023 assert((E
->hasTemplateKWAndArgsInfo() == HasTemplateKWAndArgsInfo
) &&
2024 "Wrong HasTemplateKWAndArgsInfo!");
2026 if (HasTemplateKWAndArgsInfo
) {
2027 unsigned NumTemplateArgs
= Record
.readInt();
2028 ReadTemplateKWAndArgsInfo(*E
->getTrailingASTTemplateKWAndArgsInfo(),
2029 E
->getTrailingTemplateArgumentLoc(),
2031 assert((E
->getNumTemplateArgs() == NumTemplateArgs
) &&
2032 "Wrong NumTemplateArgs!");
2035 UnresolvedSet
<8> Decls
;
2036 for (unsigned I
= 0; I
!= NumResults
; ++I
) {
2037 auto *D
= readDeclAs
<NamedDecl
>();
2038 auto AS
= (AccessSpecifier
)Record
.readInt();
2039 Decls
.addDecl(D
, AS
);
2042 DeclAccessPair
*Results
= E
->getTrailingResults();
2043 UnresolvedSetIterator Iter
= Decls
.begin();
2044 for (unsigned I
= 0; I
!= NumResults
; ++I
) {
2045 Results
[I
] = (Iter
+ I
).getPair();
2048 E
->NameInfo
= Record
.readDeclarationNameInfo();
2049 E
->QualifierLoc
= Record
.readNestedNameSpecifierLoc();
2052 void ASTStmtReader::VisitUnresolvedMemberExpr(UnresolvedMemberExpr
*E
) {
2053 VisitOverloadExpr(E
);
2054 E
->UnresolvedMemberExprBits
.IsArrow
= Record
.readInt();
2055 E
->UnresolvedMemberExprBits
.HasUnresolvedUsing
= Record
.readInt();
2056 E
->Base
= Record
.readSubExpr();
2057 E
->BaseType
= Record
.readType();
2058 E
->OperatorLoc
= readSourceLocation();
2061 void ASTStmtReader::VisitUnresolvedLookupExpr(UnresolvedLookupExpr
*E
) {
2062 VisitOverloadExpr(E
);
2063 E
->UnresolvedLookupExprBits
.RequiresADL
= Record
.readInt();
2064 E
->UnresolvedLookupExprBits
.Overloaded
= Record
.readInt();
2065 E
->NamingClass
= readDeclAs
<CXXRecordDecl
>();
2068 void ASTStmtReader::VisitTypeTraitExpr(TypeTraitExpr
*E
) {
2070 E
->TypeTraitExprBits
.NumArgs
= Record
.readInt();
2071 E
->TypeTraitExprBits
.Kind
= Record
.readInt();
2072 E
->TypeTraitExprBits
.Value
= Record
.readInt();
2073 SourceRange Range
= readSourceRange();
2074 E
->Loc
= Range
.getBegin();
2075 E
->RParenLoc
= Range
.getEnd();
2077 auto **Args
= E
->getTrailingObjects
<TypeSourceInfo
*>();
2078 for (unsigned I
= 0, N
= E
->getNumArgs(); I
!= N
; ++I
)
2079 Args
[I
] = readTypeSourceInfo();
2082 void ASTStmtReader::VisitArrayTypeTraitExpr(ArrayTypeTraitExpr
*E
) {
2084 E
->ATT
= (ArrayTypeTrait
)Record
.readInt();
2085 E
->Value
= (unsigned int)Record
.readInt();
2086 SourceRange Range
= readSourceRange();
2087 E
->Loc
= Range
.getBegin();
2088 E
->RParen
= Range
.getEnd();
2089 E
->QueriedType
= readTypeSourceInfo();
2090 E
->Dimension
= Record
.readSubExpr();
2093 void ASTStmtReader::VisitExpressionTraitExpr(ExpressionTraitExpr
*E
) {
2095 E
->ET
= (ExpressionTrait
)Record
.readInt();
2096 E
->Value
= (bool)Record
.readInt();
2097 SourceRange Range
= readSourceRange();
2098 E
->QueriedExpression
= Record
.readSubExpr();
2099 E
->Loc
= Range
.getBegin();
2100 E
->RParen
= Range
.getEnd();
2103 void ASTStmtReader::VisitCXXNoexceptExpr(CXXNoexceptExpr
*E
) {
2105 E
->CXXNoexceptExprBits
.Value
= Record
.readInt();
2106 E
->Range
= readSourceRange();
2107 E
->Operand
= Record
.readSubExpr();
2110 void ASTStmtReader::VisitPackExpansionExpr(PackExpansionExpr
*E
) {
2112 E
->EllipsisLoc
= readSourceLocation();
2113 E
->NumExpansions
= Record
.readInt();
2114 E
->Pattern
= Record
.readSubExpr();
2117 void ASTStmtReader::VisitSizeOfPackExpr(SizeOfPackExpr
*E
) {
2119 unsigned NumPartialArgs
= Record
.readInt();
2120 E
->OperatorLoc
= readSourceLocation();
2121 E
->PackLoc
= readSourceLocation();
2122 E
->RParenLoc
= readSourceLocation();
2123 E
->Pack
= Record
.readDeclAs
<NamedDecl
>();
2124 if (E
->isPartiallySubstituted()) {
2125 assert(E
->Length
== NumPartialArgs
);
2126 for (auto *I
= E
->getTrailingObjects
<TemplateArgument
>(),
2127 *E
= I
+ NumPartialArgs
;
2129 new (I
) TemplateArgument(Record
.readTemplateArgument());
2130 } else if (!E
->isValueDependent()) {
2131 E
->Length
= Record
.readInt();
2135 void ASTStmtReader::VisitSubstNonTypeTemplateParmExpr(
2136 SubstNonTypeTemplateParmExpr
*E
) {
2138 E
->AssociatedDeclAndRef
.setPointer(readDeclAs
<Decl
>());
2139 E
->AssociatedDeclAndRef
.setInt(Record
.readInt());
2140 E
->Index
= Record
.readInt();
2141 E
->PackIndex
= Record
.readInt();
2142 E
->SubstNonTypeTemplateParmExprBits
.NameLoc
= readSourceLocation();
2143 E
->Replacement
= Record
.readSubExpr();
2146 void ASTStmtReader::VisitSubstNonTypeTemplateParmPackExpr(
2147 SubstNonTypeTemplateParmPackExpr
*E
) {
2149 E
->AssociatedDecl
= readDeclAs
<Decl
>();
2150 E
->Index
= Record
.readInt();
2151 TemplateArgument ArgPack
= Record
.readTemplateArgument();
2152 if (ArgPack
.getKind() != TemplateArgument::Pack
)
2155 E
->Arguments
= ArgPack
.pack_begin();
2156 E
->NumArguments
= ArgPack
.pack_size();
2157 E
->NameLoc
= readSourceLocation();
2160 void ASTStmtReader::VisitFunctionParmPackExpr(FunctionParmPackExpr
*E
) {
2162 E
->NumParameters
= Record
.readInt();
2163 E
->ParamPack
= readDeclAs
<ParmVarDecl
>();
2164 E
->NameLoc
= readSourceLocation();
2165 auto **Parms
= E
->getTrailingObjects
<VarDecl
*>();
2166 for (unsigned i
= 0, n
= E
->NumParameters
; i
!= n
; ++i
)
2167 Parms
[i
] = readDeclAs
<VarDecl
>();
2170 void ASTStmtReader::VisitMaterializeTemporaryExpr(MaterializeTemporaryExpr
*E
) {
2172 bool HasMaterialzedDecl
= Record
.readInt();
2173 if (HasMaterialzedDecl
)
2174 E
->State
= cast
<LifetimeExtendedTemporaryDecl
>(Record
.readDecl());
2176 E
->State
= Record
.readSubExpr();
2179 void ASTStmtReader::VisitCXXFoldExpr(CXXFoldExpr
*E
) {
2181 E
->LParenLoc
= readSourceLocation();
2182 E
->EllipsisLoc
= readSourceLocation();
2183 E
->RParenLoc
= readSourceLocation();
2184 E
->NumExpansions
= Record
.readInt();
2185 E
->SubExprs
[0] = Record
.readSubExpr();
2186 E
->SubExprs
[1] = Record
.readSubExpr();
2187 E
->SubExprs
[2] = Record
.readSubExpr();
2188 E
->Opcode
= (BinaryOperatorKind
)Record
.readInt();
2191 void ASTStmtReader::VisitCXXParenListInitExpr(CXXParenListInitExpr
*E
) {
2193 unsigned ExpectedNumExprs
= Record
.readInt();
2194 assert(E
->NumExprs
== ExpectedNumExprs
&&
2195 "expected number of expressions does not equal the actual number of "
2196 "serialized expressions.");
2197 E
->NumUserSpecifiedExprs
= Record
.readInt();
2198 E
->InitLoc
= readSourceLocation();
2199 E
->LParenLoc
= readSourceLocation();
2200 E
->RParenLoc
= readSourceLocation();
2201 for (unsigned I
= 0; I
< ExpectedNumExprs
; I
++)
2202 E
->getTrailingObjects
<Expr
*>()[I
] = Record
.readSubExpr();
2204 bool HasArrayFillerOrUnionDecl
= Record
.readBool();
2205 if (HasArrayFillerOrUnionDecl
) {
2206 bool HasArrayFiller
= Record
.readBool();
2207 if (HasArrayFiller
) {
2208 E
->setArrayFiller(Record
.readSubExpr());
2210 E
->setInitializedFieldInUnion(readDeclAs
<FieldDecl
>());
2213 E
->updateDependence();
2216 void ASTStmtReader::VisitOpaqueValueExpr(OpaqueValueExpr
*E
) {
2218 E
->SourceExpr
= Record
.readSubExpr();
2219 E
->OpaqueValueExprBits
.Loc
= readSourceLocation();
2220 E
->setIsUnique(Record
.readInt());
2223 void ASTStmtReader::VisitTypoExpr(TypoExpr
*E
) {
2224 llvm_unreachable("Cannot read TypoExpr nodes");
2227 void ASTStmtReader::VisitRecoveryExpr(RecoveryExpr
*E
) {
2229 unsigned NumArgs
= Record
.readInt();
2230 E
->BeginLoc
= readSourceLocation();
2231 E
->EndLoc
= readSourceLocation();
2232 assert((NumArgs
+ 0LL ==
2233 std::distance(E
->children().begin(), E
->children().end())) &&
2236 for (Stmt
*&Child
: E
->children())
2237 Child
= Record
.readSubStmt();
2240 //===----------------------------------------------------------------------===//
2241 // Microsoft Expressions and Statements
2242 //===----------------------------------------------------------------------===//
2243 void ASTStmtReader::VisitMSPropertyRefExpr(MSPropertyRefExpr
*E
) {
2245 E
->IsArrow
= (Record
.readInt() != 0);
2246 E
->BaseExpr
= Record
.readSubExpr();
2247 E
->QualifierLoc
= Record
.readNestedNameSpecifierLoc();
2248 E
->MemberLoc
= readSourceLocation();
2249 E
->TheDecl
= readDeclAs
<MSPropertyDecl
>();
2252 void ASTStmtReader::VisitMSPropertySubscriptExpr(MSPropertySubscriptExpr
*E
) {
2254 E
->setBase(Record
.readSubExpr());
2255 E
->setIdx(Record
.readSubExpr());
2256 E
->setRBracketLoc(readSourceLocation());
2259 void ASTStmtReader::VisitCXXUuidofExpr(CXXUuidofExpr
*E
) {
2261 E
->setSourceRange(readSourceRange());
2262 E
->Guid
= readDeclAs
<MSGuidDecl
>();
2263 if (E
->isTypeOperand())
2264 E
->Operand
= readTypeSourceInfo();
2266 E
->Operand
= Record
.readSubExpr();
2269 void ASTStmtReader::VisitSEHLeaveStmt(SEHLeaveStmt
*S
) {
2271 S
->setLeaveLoc(readSourceLocation());
2274 void ASTStmtReader::VisitSEHExceptStmt(SEHExceptStmt
*S
) {
2276 S
->Loc
= readSourceLocation();
2277 S
->Children
[SEHExceptStmt::FILTER_EXPR
] = Record
.readSubStmt();
2278 S
->Children
[SEHExceptStmt::BLOCK
] = Record
.readSubStmt();
2281 void ASTStmtReader::VisitSEHFinallyStmt(SEHFinallyStmt
*S
) {
2283 S
->Loc
= readSourceLocation();
2284 S
->Block
= Record
.readSubStmt();
2287 void ASTStmtReader::VisitSEHTryStmt(SEHTryStmt
*S
) {
2289 S
->IsCXXTry
= Record
.readInt();
2290 S
->TryLoc
= readSourceLocation();
2291 S
->Children
[SEHTryStmt::TRY
] = Record
.readSubStmt();
2292 S
->Children
[SEHTryStmt::HANDLER
] = Record
.readSubStmt();
2295 //===----------------------------------------------------------------------===//
2296 // CUDA Expressions and Statements
2297 //===----------------------------------------------------------------------===//
2299 void ASTStmtReader::VisitCUDAKernelCallExpr(CUDAKernelCallExpr
*E
) {
2301 E
->setPreArg(CUDAKernelCallExpr::CONFIG
, Record
.readSubExpr());
2304 //===----------------------------------------------------------------------===//
2305 // OpenCL Expressions and Statements.
2306 //===----------------------------------------------------------------------===//
2307 void ASTStmtReader::VisitAsTypeExpr(AsTypeExpr
*E
) {
2309 E
->BuiltinLoc
= readSourceLocation();
2310 E
->RParenLoc
= readSourceLocation();
2311 E
->SrcExpr
= Record
.readSubExpr();
2314 //===----------------------------------------------------------------------===//
2315 // OpenMP Directives.
2316 //===----------------------------------------------------------------------===//
2318 void ASTStmtReader::VisitOMPCanonicalLoop(OMPCanonicalLoop
*S
) {
2320 for (Stmt
*&SubStmt
: S
->SubStmts
)
2321 SubStmt
= Record
.readSubStmt();
2324 void ASTStmtReader::VisitOMPExecutableDirective(OMPExecutableDirective
*E
) {
2325 Record
.readOMPChildren(E
->Data
);
2326 E
->setLocStart(readSourceLocation());
2327 E
->setLocEnd(readSourceLocation());
2328 E
->setMappedDirective(Record
.readEnum
<OpenMPDirectiveKind
>());
2331 void ASTStmtReader::VisitOMPLoopBasedDirective(OMPLoopBasedDirective
*D
) {
2333 // Field CollapsedNum was read in ReadStmtFromStream.
2335 VisitOMPExecutableDirective(D
);
2338 void ASTStmtReader::VisitOMPLoopDirective(OMPLoopDirective
*D
) {
2339 VisitOMPLoopBasedDirective(D
);
2342 void ASTStmtReader::VisitOMPMetaDirective(OMPMetaDirective
*D
) {
2344 // The NumClauses field was read in ReadStmtFromStream.
2346 VisitOMPExecutableDirective(D
);
2349 void ASTStmtReader::VisitOMPParallelDirective(OMPParallelDirective
*D
) {
2351 VisitOMPExecutableDirective(D
);
2352 D
->setHasCancel(Record
.readBool());
2355 void ASTStmtReader::VisitOMPSimdDirective(OMPSimdDirective
*D
) {
2356 VisitOMPLoopDirective(D
);
2359 void ASTStmtReader::VisitOMPLoopTransformationDirective(
2360 OMPLoopTransformationDirective
*D
) {
2361 VisitOMPLoopBasedDirective(D
);
2362 D
->setNumGeneratedLoops(Record
.readUInt32());
2365 void ASTStmtReader::VisitOMPTileDirective(OMPTileDirective
*D
) {
2366 VisitOMPLoopTransformationDirective(D
);
2369 void ASTStmtReader::VisitOMPUnrollDirective(OMPUnrollDirective
*D
) {
2370 VisitOMPLoopTransformationDirective(D
);
2373 void ASTStmtReader::VisitOMPForDirective(OMPForDirective
*D
) {
2374 VisitOMPLoopDirective(D
);
2375 D
->setHasCancel(Record
.readBool());
2378 void ASTStmtReader::VisitOMPForSimdDirective(OMPForSimdDirective
*D
) {
2379 VisitOMPLoopDirective(D
);
2382 void ASTStmtReader::VisitOMPSectionsDirective(OMPSectionsDirective
*D
) {
2384 VisitOMPExecutableDirective(D
);
2385 D
->setHasCancel(Record
.readBool());
2388 void ASTStmtReader::VisitOMPSectionDirective(OMPSectionDirective
*D
) {
2390 VisitOMPExecutableDirective(D
);
2391 D
->setHasCancel(Record
.readBool());
2394 void ASTStmtReader::VisitOMPScopeDirective(OMPScopeDirective
*D
) {
2396 VisitOMPExecutableDirective(D
);
2399 void ASTStmtReader::VisitOMPSingleDirective(OMPSingleDirective
*D
) {
2401 VisitOMPExecutableDirective(D
);
2404 void ASTStmtReader::VisitOMPMasterDirective(OMPMasterDirective
*D
) {
2406 VisitOMPExecutableDirective(D
);
2409 void ASTStmtReader::VisitOMPCriticalDirective(OMPCriticalDirective
*D
) {
2411 VisitOMPExecutableDirective(D
);
2412 D
->DirName
= Record
.readDeclarationNameInfo();
2415 void ASTStmtReader::VisitOMPParallelForDirective(OMPParallelForDirective
*D
) {
2416 VisitOMPLoopDirective(D
);
2417 D
->setHasCancel(Record
.readBool());
2420 void ASTStmtReader::VisitOMPParallelForSimdDirective(
2421 OMPParallelForSimdDirective
*D
) {
2422 VisitOMPLoopDirective(D
);
2425 void ASTStmtReader::VisitOMPParallelMasterDirective(
2426 OMPParallelMasterDirective
*D
) {
2428 VisitOMPExecutableDirective(D
);
2431 void ASTStmtReader::VisitOMPParallelMaskedDirective(
2432 OMPParallelMaskedDirective
*D
) {
2434 VisitOMPExecutableDirective(D
);
2437 void ASTStmtReader::VisitOMPParallelSectionsDirective(
2438 OMPParallelSectionsDirective
*D
) {
2440 VisitOMPExecutableDirective(D
);
2441 D
->setHasCancel(Record
.readBool());
2444 void ASTStmtReader::VisitOMPTaskDirective(OMPTaskDirective
*D
) {
2446 VisitOMPExecutableDirective(D
);
2447 D
->setHasCancel(Record
.readBool());
2450 void ASTStmtReader::VisitOMPTaskyieldDirective(OMPTaskyieldDirective
*D
) {
2452 VisitOMPExecutableDirective(D
);
2455 void ASTStmtReader::VisitOMPBarrierDirective(OMPBarrierDirective
*D
) {
2457 VisitOMPExecutableDirective(D
);
2460 void ASTStmtReader::VisitOMPTaskwaitDirective(OMPTaskwaitDirective
*D
) {
2462 // The NumClauses field was read in ReadStmtFromStream.
2464 VisitOMPExecutableDirective(D
);
2467 void ASTStmtReader::VisitOMPErrorDirective(OMPErrorDirective
*D
) {
2469 // The NumClauses field was read in ReadStmtFromStream.
2471 VisitOMPExecutableDirective(D
);
2474 void ASTStmtReader::VisitOMPTaskgroupDirective(OMPTaskgroupDirective
*D
) {
2476 VisitOMPExecutableDirective(D
);
2479 void ASTStmtReader::VisitOMPFlushDirective(OMPFlushDirective
*D
) {
2481 VisitOMPExecutableDirective(D
);
2484 void ASTStmtReader::VisitOMPDepobjDirective(OMPDepobjDirective
*D
) {
2486 VisitOMPExecutableDirective(D
);
2489 void ASTStmtReader::VisitOMPScanDirective(OMPScanDirective
*D
) {
2491 VisitOMPExecutableDirective(D
);
2494 void ASTStmtReader::VisitOMPOrderedDirective(OMPOrderedDirective
*D
) {
2496 VisitOMPExecutableDirective(D
);
2499 void ASTStmtReader::VisitOMPAtomicDirective(OMPAtomicDirective
*D
) {
2501 VisitOMPExecutableDirective(D
);
2502 D
->Flags
.IsXLHSInRHSPart
= Record
.readBool() ? 1 : 0;
2503 D
->Flags
.IsPostfixUpdate
= Record
.readBool() ? 1 : 0;
2504 D
->Flags
.IsFailOnly
= Record
.readBool() ? 1 : 0;
2507 void ASTStmtReader::VisitOMPTargetDirective(OMPTargetDirective
*D
) {
2509 VisitOMPExecutableDirective(D
);
2512 void ASTStmtReader::VisitOMPTargetDataDirective(OMPTargetDataDirective
*D
) {
2514 VisitOMPExecutableDirective(D
);
2517 void ASTStmtReader::VisitOMPTargetEnterDataDirective(
2518 OMPTargetEnterDataDirective
*D
) {
2520 VisitOMPExecutableDirective(D
);
2523 void ASTStmtReader::VisitOMPTargetExitDataDirective(
2524 OMPTargetExitDataDirective
*D
) {
2526 VisitOMPExecutableDirective(D
);
2529 void ASTStmtReader::VisitOMPTargetParallelDirective(
2530 OMPTargetParallelDirective
*D
) {
2532 VisitOMPExecutableDirective(D
);
2533 D
->setHasCancel(Record
.readBool());
2536 void ASTStmtReader::VisitOMPTargetParallelForDirective(
2537 OMPTargetParallelForDirective
*D
) {
2538 VisitOMPLoopDirective(D
);
2539 D
->setHasCancel(Record
.readBool());
2542 void ASTStmtReader::VisitOMPTeamsDirective(OMPTeamsDirective
*D
) {
2544 VisitOMPExecutableDirective(D
);
2547 void ASTStmtReader::VisitOMPCancellationPointDirective(
2548 OMPCancellationPointDirective
*D
) {
2550 VisitOMPExecutableDirective(D
);
2551 D
->setCancelRegion(Record
.readEnum
<OpenMPDirectiveKind
>());
2554 void ASTStmtReader::VisitOMPCancelDirective(OMPCancelDirective
*D
) {
2556 VisitOMPExecutableDirective(D
);
2557 D
->setCancelRegion(Record
.readEnum
<OpenMPDirectiveKind
>());
2560 void ASTStmtReader::VisitOMPTaskLoopDirective(OMPTaskLoopDirective
*D
) {
2561 VisitOMPLoopDirective(D
);
2562 D
->setHasCancel(Record
.readBool());
2565 void ASTStmtReader::VisitOMPTaskLoopSimdDirective(OMPTaskLoopSimdDirective
*D
) {
2566 VisitOMPLoopDirective(D
);
2569 void ASTStmtReader::VisitOMPMasterTaskLoopDirective(
2570 OMPMasterTaskLoopDirective
*D
) {
2571 VisitOMPLoopDirective(D
);
2572 D
->setHasCancel(Record
.readBool());
2575 void ASTStmtReader::VisitOMPMaskedTaskLoopDirective(
2576 OMPMaskedTaskLoopDirective
*D
) {
2577 VisitOMPLoopDirective(D
);
2578 D
->setHasCancel(Record
.readBool());
2581 void ASTStmtReader::VisitOMPMasterTaskLoopSimdDirective(
2582 OMPMasterTaskLoopSimdDirective
*D
) {
2583 VisitOMPLoopDirective(D
);
2586 void ASTStmtReader::VisitOMPMaskedTaskLoopSimdDirective(
2587 OMPMaskedTaskLoopSimdDirective
*D
) {
2588 VisitOMPLoopDirective(D
);
2591 void ASTStmtReader::VisitOMPParallelMasterTaskLoopDirective(
2592 OMPParallelMasterTaskLoopDirective
*D
) {
2593 VisitOMPLoopDirective(D
);
2594 D
->setHasCancel(Record
.readBool());
2597 void ASTStmtReader::VisitOMPParallelMaskedTaskLoopDirective(
2598 OMPParallelMaskedTaskLoopDirective
*D
) {
2599 VisitOMPLoopDirective(D
);
2600 D
->setHasCancel(Record
.readBool());
2603 void ASTStmtReader::VisitOMPParallelMasterTaskLoopSimdDirective(
2604 OMPParallelMasterTaskLoopSimdDirective
*D
) {
2605 VisitOMPLoopDirective(D
);
2608 void ASTStmtReader::VisitOMPParallelMaskedTaskLoopSimdDirective(
2609 OMPParallelMaskedTaskLoopSimdDirective
*D
) {
2610 VisitOMPLoopDirective(D
);
2613 void ASTStmtReader::VisitOMPDistributeDirective(OMPDistributeDirective
*D
) {
2614 VisitOMPLoopDirective(D
);
2617 void ASTStmtReader::VisitOMPTargetUpdateDirective(OMPTargetUpdateDirective
*D
) {
2619 VisitOMPExecutableDirective(D
);
2622 void ASTStmtReader::VisitOMPDistributeParallelForDirective(
2623 OMPDistributeParallelForDirective
*D
) {
2624 VisitOMPLoopDirective(D
);
2625 D
->setHasCancel(Record
.readBool());
2628 void ASTStmtReader::VisitOMPDistributeParallelForSimdDirective(
2629 OMPDistributeParallelForSimdDirective
*D
) {
2630 VisitOMPLoopDirective(D
);
2633 void ASTStmtReader::VisitOMPDistributeSimdDirective(
2634 OMPDistributeSimdDirective
*D
) {
2635 VisitOMPLoopDirective(D
);
2638 void ASTStmtReader::VisitOMPTargetParallelForSimdDirective(
2639 OMPTargetParallelForSimdDirective
*D
) {
2640 VisitOMPLoopDirective(D
);
2643 void ASTStmtReader::VisitOMPTargetSimdDirective(OMPTargetSimdDirective
*D
) {
2644 VisitOMPLoopDirective(D
);
2647 void ASTStmtReader::VisitOMPTeamsDistributeDirective(
2648 OMPTeamsDistributeDirective
*D
) {
2649 VisitOMPLoopDirective(D
);
2652 void ASTStmtReader::VisitOMPTeamsDistributeSimdDirective(
2653 OMPTeamsDistributeSimdDirective
*D
) {
2654 VisitOMPLoopDirective(D
);
2657 void ASTStmtReader::VisitOMPTeamsDistributeParallelForSimdDirective(
2658 OMPTeamsDistributeParallelForSimdDirective
*D
) {
2659 VisitOMPLoopDirective(D
);
2662 void ASTStmtReader::VisitOMPTeamsDistributeParallelForDirective(
2663 OMPTeamsDistributeParallelForDirective
*D
) {
2664 VisitOMPLoopDirective(D
);
2665 D
->setHasCancel(Record
.readBool());
2668 void ASTStmtReader::VisitOMPTargetTeamsDirective(OMPTargetTeamsDirective
*D
) {
2670 VisitOMPExecutableDirective(D
);
2673 void ASTStmtReader::VisitOMPTargetTeamsDistributeDirective(
2674 OMPTargetTeamsDistributeDirective
*D
) {
2675 VisitOMPLoopDirective(D
);
2678 void ASTStmtReader::VisitOMPTargetTeamsDistributeParallelForDirective(
2679 OMPTargetTeamsDistributeParallelForDirective
*D
) {
2680 VisitOMPLoopDirective(D
);
2681 D
->setHasCancel(Record
.readBool());
2684 void ASTStmtReader::VisitOMPTargetTeamsDistributeParallelForSimdDirective(
2685 OMPTargetTeamsDistributeParallelForSimdDirective
*D
) {
2686 VisitOMPLoopDirective(D
);
2689 void ASTStmtReader::VisitOMPTargetTeamsDistributeSimdDirective(
2690 OMPTargetTeamsDistributeSimdDirective
*D
) {
2691 VisitOMPLoopDirective(D
);
2694 void ASTStmtReader::VisitOMPInteropDirective(OMPInteropDirective
*D
) {
2696 VisitOMPExecutableDirective(D
);
2699 void ASTStmtReader::VisitOMPDispatchDirective(OMPDispatchDirective
*D
) {
2701 VisitOMPExecutableDirective(D
);
2702 D
->setTargetCallLoc(Record
.readSourceLocation());
2705 void ASTStmtReader::VisitOMPMaskedDirective(OMPMaskedDirective
*D
) {
2707 VisitOMPExecutableDirective(D
);
2710 void ASTStmtReader::VisitOMPGenericLoopDirective(OMPGenericLoopDirective
*D
) {
2711 VisitOMPLoopDirective(D
);
2714 void ASTStmtReader::VisitOMPTeamsGenericLoopDirective(
2715 OMPTeamsGenericLoopDirective
*D
) {
2716 VisitOMPLoopDirective(D
);
2719 void ASTStmtReader::VisitOMPTargetTeamsGenericLoopDirective(
2720 OMPTargetTeamsGenericLoopDirective
*D
) {
2721 VisitOMPLoopDirective(D
);
2724 void ASTStmtReader::VisitOMPParallelGenericLoopDirective(
2725 OMPParallelGenericLoopDirective
*D
) {
2726 VisitOMPLoopDirective(D
);
2729 void ASTStmtReader::VisitOMPTargetParallelGenericLoopDirective(
2730 OMPTargetParallelGenericLoopDirective
*D
) {
2731 VisitOMPLoopDirective(D
);
2734 //===----------------------------------------------------------------------===//
2735 // ASTReader Implementation
2736 //===----------------------------------------------------------------------===//
2738 Stmt
*ASTReader::ReadStmt(ModuleFile
&F
) {
2739 switch (ReadingKind
) {
2741 llvm_unreachable("should not call this when not reading anything");
2744 return ReadStmtFromStream(F
);
2746 return ReadSubStmt();
2749 llvm_unreachable("ReadingKind not set ?");
2752 Expr
*ASTReader::ReadExpr(ModuleFile
&F
) {
2753 return cast_or_null
<Expr
>(ReadStmt(F
));
2756 Expr
*ASTReader::ReadSubExpr() {
2757 return cast_or_null
<Expr
>(ReadSubStmt());
2760 // Within the bitstream, expressions are stored in Reverse Polish
2761 // Notation, with each of the subexpressions preceding the
2762 // expression they are stored in. Subexpressions are stored from last to first.
2763 // To evaluate expressions, we continue reading expressions and placing them on
2764 // the stack, with expressions having operands removing those operands from the
2765 // stack. Evaluation terminates when we see a STMT_STOP record, and
2766 // the single remaining expression on the stack is our result.
2767 Stmt
*ASTReader::ReadStmtFromStream(ModuleFile
&F
) {
2768 ReadingKindTracker
ReadingKind(Read_Stmt
, *this);
2769 llvm::BitstreamCursor
&Cursor
= F
.DeclsCursor
;
2771 // Map of offset to previously deserialized stmt. The offset points
2772 // just after the stmt record.
2773 llvm::DenseMap
<uint64_t, Stmt
*> StmtEntries
;
2776 unsigned PrevNumStmts
= StmtStack
.size();
2779 ASTRecordReader
Record(*this, F
);
2780 ASTStmtReader
Reader(Record
, Cursor
);
2781 Stmt::EmptyShell Empty
;
2784 llvm::Expected
<llvm::BitstreamEntry
> MaybeEntry
=
2785 Cursor
.advanceSkippingSubblocks();
2787 Error(toString(MaybeEntry
.takeError()));
2790 llvm::BitstreamEntry Entry
= MaybeEntry
.get();
2792 switch (Entry
.Kind
) {
2793 case llvm::BitstreamEntry::SubBlock
: // Handled for us already.
2794 case llvm::BitstreamEntry::Error
:
2795 Error("malformed block record in AST file");
2797 case llvm::BitstreamEntry::EndBlock
:
2799 case llvm::BitstreamEntry::Record
:
2800 // The interesting case.
2804 ASTContext
&Context
= getContext();
2806 bool Finished
= false;
2807 bool IsStmtReference
= false;
2808 Expected
<unsigned> MaybeStmtCode
= Record
.readRecord(Cursor
, Entry
.ID
);
2809 if (!MaybeStmtCode
) {
2810 Error(toString(MaybeStmtCode
.takeError()));
2813 switch ((StmtCode
)MaybeStmtCode
.get()) {
2819 IsStmtReference
= true;
2820 assert(StmtEntries
.contains(Record
[0]) &&
2821 "No stmt was recorded for this offset reference!");
2822 S
= StmtEntries
[Record
.readInt()];
2830 S
= new (Context
) NullStmt(Empty
);
2834 S
= CompoundStmt::CreateEmpty(
2835 Context
, /*NumStmts=*/Record
[ASTStmtReader::NumStmtFields
],
2836 /*HasFPFeatures=*/Record
[ASTStmtReader::NumStmtFields
+ 1]);
2840 S
= CaseStmt::CreateEmpty(
2842 /*CaseStmtIsGNURange*/ Record
[ASTStmtReader::NumStmtFields
+ 3]);
2846 S
= new (Context
) DefaultStmt(Empty
);
2850 S
= new (Context
) LabelStmt(Empty
);
2853 case STMT_ATTRIBUTED
:
2854 S
= AttributedStmt::CreateEmpty(
2856 /*NumAttrs*/Record
[ASTStmtReader::NumStmtFields
]);
2860 S
= IfStmt::CreateEmpty(
2862 /* HasElse=*/Record
[ASTStmtReader::NumStmtFields
],
2863 /* HasVar=*/Record
[ASTStmtReader::NumStmtFields
+ 1],
2864 /* HasInit=*/Record
[ASTStmtReader::NumStmtFields
+ 2]);
2868 S
= SwitchStmt::CreateEmpty(
2870 /* HasInit=*/Record
[ASTStmtReader::NumStmtFields
],
2871 /* HasVar=*/Record
[ASTStmtReader::NumStmtFields
+ 1]);
2875 S
= WhileStmt::CreateEmpty(
2877 /* HasVar=*/Record
[ASTStmtReader::NumStmtFields
]);
2881 S
= new (Context
) DoStmt(Empty
);
2885 S
= new (Context
) ForStmt(Empty
);
2889 S
= new (Context
) GotoStmt(Empty
);
2892 case STMT_INDIRECT_GOTO
:
2893 S
= new (Context
) IndirectGotoStmt(Empty
);
2897 S
= new (Context
) ContinueStmt(Empty
);
2901 S
= new (Context
) BreakStmt(Empty
);
2905 S
= ReturnStmt::CreateEmpty(
2906 Context
, /* HasNRVOCandidate=*/Record
[ASTStmtReader::NumStmtFields
]);
2910 S
= new (Context
) DeclStmt(Empty
);
2914 S
= new (Context
) GCCAsmStmt(Empty
);
2918 S
= new (Context
) MSAsmStmt(Empty
);
2922 S
= CapturedStmt::CreateDeserialized(
2923 Context
, Record
[ASTStmtReader::NumStmtFields
]);
2927 S
= ConstantExpr::CreateEmpty(
2928 Context
, static_cast<ConstantExpr::ResultStorageKind
>(
2929 /*StorageKind=*/Record
[ASTStmtReader::NumExprFields
]));
2932 case EXPR_SYCL_UNIQUE_STABLE_NAME
:
2933 S
= SYCLUniqueStableNameExpr::CreateEmpty(Context
);
2936 case EXPR_PREDEFINED
:
2937 S
= PredefinedExpr::CreateEmpty(
2939 /*HasFunctionName*/ Record
[ASTStmtReader::NumExprFields
]);
2943 S
= DeclRefExpr::CreateEmpty(
2945 /*HasQualifier=*/Record
[ASTStmtReader::NumExprFields
],
2946 /*HasFoundDecl=*/Record
[ASTStmtReader::NumExprFields
+ 1],
2947 /*HasTemplateKWAndArgsInfo=*/Record
[ASTStmtReader::NumExprFields
+ 2],
2948 /*NumTemplateArgs=*/
2949 Record
[ASTStmtReader::NumExprFields
+ 2]
2950 ? Record
[ASTStmtReader::NumExprFields
+ 7]
2954 case EXPR_INTEGER_LITERAL
:
2955 S
= IntegerLiteral::Create(Context
, Empty
);
2958 case EXPR_FIXEDPOINT_LITERAL
:
2959 S
= FixedPointLiteral::Create(Context
, Empty
);
2962 case EXPR_FLOATING_LITERAL
:
2963 S
= FloatingLiteral::Create(Context
, Empty
);
2966 case EXPR_IMAGINARY_LITERAL
:
2967 S
= new (Context
) ImaginaryLiteral(Empty
);
2970 case EXPR_STRING_LITERAL
:
2971 S
= StringLiteral::CreateEmpty(
2973 /* NumConcatenated=*/Record
[ASTStmtReader::NumExprFields
],
2974 /* Length=*/Record
[ASTStmtReader::NumExprFields
+ 1],
2975 /* CharByteWidth=*/Record
[ASTStmtReader::NumExprFields
+ 2]);
2978 case EXPR_CHARACTER_LITERAL
:
2979 S
= new (Context
) CharacterLiteral(Empty
);
2983 S
= new (Context
) ParenExpr(Empty
);
2986 case EXPR_PAREN_LIST
:
2987 S
= ParenListExpr::CreateEmpty(
2989 /* NumExprs=*/Record
[ASTStmtReader::NumExprFields
]);
2992 case EXPR_UNARY_OPERATOR
:
2993 S
= UnaryOperator::CreateEmpty(Context
,
2994 Record
[ASTStmtReader::NumExprFields
]);
2998 S
= OffsetOfExpr::CreateEmpty(Context
,
2999 Record
[ASTStmtReader::NumExprFields
],
3000 Record
[ASTStmtReader::NumExprFields
+ 1]);
3003 case EXPR_SIZEOF_ALIGN_OF
:
3004 S
= new (Context
) UnaryExprOrTypeTraitExpr(Empty
);
3007 case EXPR_ARRAY_SUBSCRIPT
:
3008 S
= new (Context
) ArraySubscriptExpr(Empty
);
3011 case EXPR_MATRIX_SUBSCRIPT
:
3012 S
= new (Context
) MatrixSubscriptExpr(Empty
);
3015 case EXPR_OMP_ARRAY_SECTION
:
3016 S
= new (Context
) OMPArraySectionExpr(Empty
);
3019 case EXPR_OMP_ARRAY_SHAPING
:
3020 S
= OMPArrayShapingExpr::CreateEmpty(
3021 Context
, Record
[ASTStmtReader::NumExprFields
]);
3024 case EXPR_OMP_ITERATOR
:
3025 S
= OMPIteratorExpr::CreateEmpty(Context
,
3026 Record
[ASTStmtReader::NumExprFields
]);
3030 S
= CallExpr::CreateEmpty(
3031 Context
, /*NumArgs=*/Record
[ASTStmtReader::NumExprFields
],
3032 /*HasFPFeatures=*/Record
[ASTStmtReader::NumExprFields
+ 1], Empty
);
3036 S
= RecoveryExpr::CreateEmpty(
3037 Context
, /*NumArgs=*/Record
[ASTStmtReader::NumExprFields
]);
3041 S
= MemberExpr::CreateEmpty(Context
, Record
[ASTStmtReader::NumExprFields
],
3042 Record
[ASTStmtReader::NumExprFields
+ 1],
3043 Record
[ASTStmtReader::NumExprFields
+ 2],
3044 Record
[ASTStmtReader::NumExprFields
+ 3]);
3047 case EXPR_BINARY_OPERATOR
:
3048 S
= BinaryOperator::CreateEmpty(Context
,
3049 Record
[ASTStmtReader::NumExprFields
]);
3052 case EXPR_COMPOUND_ASSIGN_OPERATOR
:
3053 S
= CompoundAssignOperator::CreateEmpty(
3054 Context
, Record
[ASTStmtReader::NumExprFields
]);
3057 case EXPR_CONDITIONAL_OPERATOR
:
3058 S
= new (Context
) ConditionalOperator(Empty
);
3061 case EXPR_BINARY_CONDITIONAL_OPERATOR
:
3062 S
= new (Context
) BinaryConditionalOperator(Empty
);
3065 case EXPR_IMPLICIT_CAST
:
3066 S
= ImplicitCastExpr::CreateEmpty(
3068 /*PathSize*/ Record
[ASTStmtReader::NumExprFields
],
3069 /*HasFPFeatures*/ Record
[ASTStmtReader::NumExprFields
+ 1]);
3072 case EXPR_CSTYLE_CAST
:
3073 S
= CStyleCastExpr::CreateEmpty(
3075 /*PathSize*/ Record
[ASTStmtReader::NumExprFields
],
3076 /*HasFPFeatures*/ Record
[ASTStmtReader::NumExprFields
+ 1]);
3079 case EXPR_COMPOUND_LITERAL
:
3080 S
= new (Context
) CompoundLiteralExpr(Empty
);
3083 case EXPR_EXT_VECTOR_ELEMENT
:
3084 S
= new (Context
) ExtVectorElementExpr(Empty
);
3087 case EXPR_INIT_LIST
:
3088 S
= new (Context
) InitListExpr(Empty
);
3091 case EXPR_DESIGNATED_INIT
:
3092 S
= DesignatedInitExpr::CreateEmpty(Context
,
3093 Record
[ASTStmtReader::NumExprFields
] - 1);
3097 case EXPR_DESIGNATED_INIT_UPDATE
:
3098 S
= new (Context
) DesignatedInitUpdateExpr(Empty
);
3101 case EXPR_IMPLICIT_VALUE_INIT
:
3102 S
= new (Context
) ImplicitValueInitExpr(Empty
);
3106 S
= new (Context
) NoInitExpr(Empty
);
3109 case EXPR_ARRAY_INIT_LOOP
:
3110 S
= new (Context
) ArrayInitLoopExpr(Empty
);
3113 case EXPR_ARRAY_INIT_INDEX
:
3114 S
= new (Context
) ArrayInitIndexExpr(Empty
);
3118 S
= new (Context
) VAArgExpr(Empty
);
3121 case EXPR_SOURCE_LOC
:
3122 S
= new (Context
) SourceLocExpr(Empty
);
3125 case EXPR_ADDR_LABEL
:
3126 S
= new (Context
) AddrLabelExpr(Empty
);
3130 S
= new (Context
) StmtExpr(Empty
);
3134 S
= new (Context
) ChooseExpr(Empty
);
3138 S
= new (Context
) GNUNullExpr(Empty
);
3141 case EXPR_SHUFFLE_VECTOR
:
3142 S
= new (Context
) ShuffleVectorExpr(Empty
);
3145 case EXPR_CONVERT_VECTOR
:
3146 S
= new (Context
) ConvertVectorExpr(Empty
);
3150 S
= new (Context
) BlockExpr(Empty
);
3153 case EXPR_GENERIC_SELECTION
:
3154 S
= GenericSelectionExpr::CreateEmpty(
3156 /*NumAssocs=*/Record
[ASTStmtReader::NumExprFields
]);
3159 case EXPR_OBJC_STRING_LITERAL
:
3160 S
= new (Context
) ObjCStringLiteral(Empty
);
3163 case EXPR_OBJC_BOXED_EXPRESSION
:
3164 S
= new (Context
) ObjCBoxedExpr(Empty
);
3167 case EXPR_OBJC_ARRAY_LITERAL
:
3168 S
= ObjCArrayLiteral::CreateEmpty(Context
,
3169 Record
[ASTStmtReader::NumExprFields
]);
3172 case EXPR_OBJC_DICTIONARY_LITERAL
:
3173 S
= ObjCDictionaryLiteral::CreateEmpty(Context
,
3174 Record
[ASTStmtReader::NumExprFields
],
3175 Record
[ASTStmtReader::NumExprFields
+ 1]);
3178 case EXPR_OBJC_ENCODE
:
3179 S
= new (Context
) ObjCEncodeExpr(Empty
);
3182 case EXPR_OBJC_SELECTOR_EXPR
:
3183 S
= new (Context
) ObjCSelectorExpr(Empty
);
3186 case EXPR_OBJC_PROTOCOL_EXPR
:
3187 S
= new (Context
) ObjCProtocolExpr(Empty
);
3190 case EXPR_OBJC_IVAR_REF_EXPR
:
3191 S
= new (Context
) ObjCIvarRefExpr(Empty
);
3194 case EXPR_OBJC_PROPERTY_REF_EXPR
:
3195 S
= new (Context
) ObjCPropertyRefExpr(Empty
);
3198 case EXPR_OBJC_SUBSCRIPT_REF_EXPR
:
3199 S
= new (Context
) ObjCSubscriptRefExpr(Empty
);
3202 case EXPR_OBJC_KVC_REF_EXPR
:
3203 llvm_unreachable("mismatching AST file");
3205 case EXPR_OBJC_MESSAGE_EXPR
:
3206 S
= ObjCMessageExpr::CreateEmpty(Context
,
3207 Record
[ASTStmtReader::NumExprFields
],
3208 Record
[ASTStmtReader::NumExprFields
+ 1]);
3212 S
= new (Context
) ObjCIsaExpr(Empty
);
3215 case EXPR_OBJC_INDIRECT_COPY_RESTORE
:
3216 S
= new (Context
) ObjCIndirectCopyRestoreExpr(Empty
);
3219 case EXPR_OBJC_BRIDGED_CAST
:
3220 S
= new (Context
) ObjCBridgedCastExpr(Empty
);
3223 case STMT_OBJC_FOR_COLLECTION
:
3224 S
= new (Context
) ObjCForCollectionStmt(Empty
);
3227 case STMT_OBJC_CATCH
:
3228 S
= new (Context
) ObjCAtCatchStmt(Empty
);
3231 case STMT_OBJC_FINALLY
:
3232 S
= new (Context
) ObjCAtFinallyStmt(Empty
);
3235 case STMT_OBJC_AT_TRY
:
3236 S
= ObjCAtTryStmt::CreateEmpty(Context
,
3237 Record
[ASTStmtReader::NumStmtFields
],
3238 Record
[ASTStmtReader::NumStmtFields
+ 1]);
3241 case STMT_OBJC_AT_SYNCHRONIZED
:
3242 S
= new (Context
) ObjCAtSynchronizedStmt(Empty
);
3245 case STMT_OBJC_AT_THROW
:
3246 S
= new (Context
) ObjCAtThrowStmt(Empty
);
3249 case STMT_OBJC_AUTORELEASE_POOL
:
3250 S
= new (Context
) ObjCAutoreleasePoolStmt(Empty
);
3253 case EXPR_OBJC_BOOL_LITERAL
:
3254 S
= new (Context
) ObjCBoolLiteralExpr(Empty
);
3257 case EXPR_OBJC_AVAILABILITY_CHECK
:
3258 S
= new (Context
) ObjCAvailabilityCheckExpr(Empty
);
3261 case STMT_SEH_LEAVE
:
3262 S
= new (Context
) SEHLeaveStmt(Empty
);
3265 case STMT_SEH_EXCEPT
:
3266 S
= new (Context
) SEHExceptStmt(Empty
);
3269 case STMT_SEH_FINALLY
:
3270 S
= new (Context
) SEHFinallyStmt(Empty
);
3274 S
= new (Context
) SEHTryStmt(Empty
);
3277 case STMT_CXX_CATCH
:
3278 S
= new (Context
) CXXCatchStmt(Empty
);
3282 S
= CXXTryStmt::Create(Context
, Empty
,
3283 /*numHandlers=*/Record
[ASTStmtReader::NumStmtFields
]);
3286 case STMT_CXX_FOR_RANGE
:
3287 S
= new (Context
) CXXForRangeStmt(Empty
);
3290 case STMT_MS_DEPENDENT_EXISTS
:
3291 S
= new (Context
) MSDependentExistsStmt(SourceLocation(), true,
3292 NestedNameSpecifierLoc(),
3293 DeclarationNameInfo(),
3297 case STMT_OMP_CANONICAL_LOOP
:
3298 S
= OMPCanonicalLoop::createEmpty(Context
);
3301 case STMT_OMP_META_DIRECTIVE
:
3302 S
= OMPMetaDirective::CreateEmpty(
3303 Context
, Record
[ASTStmtReader::NumStmtFields
], Empty
);
3306 case STMT_OMP_PARALLEL_DIRECTIVE
:
3308 OMPParallelDirective::CreateEmpty(Context
,
3309 Record
[ASTStmtReader::NumStmtFields
],
3313 case STMT_OMP_SIMD_DIRECTIVE
: {
3314 unsigned CollapsedNum
= Record
[ASTStmtReader::NumStmtFields
];
3315 unsigned NumClauses
= Record
[ASTStmtReader::NumStmtFields
+ 1];
3316 S
= OMPSimdDirective::CreateEmpty(Context
, NumClauses
,
3317 CollapsedNum
, Empty
);
3321 case STMT_OMP_TILE_DIRECTIVE
: {
3322 unsigned NumLoops
= Record
[ASTStmtReader::NumStmtFields
];
3323 unsigned NumClauses
= Record
[ASTStmtReader::NumStmtFields
+ 1];
3324 S
= OMPTileDirective::CreateEmpty(Context
, NumClauses
, NumLoops
);
3328 case STMT_OMP_UNROLL_DIRECTIVE
: {
3329 assert(Record
[ASTStmtReader::NumStmtFields
] == 1 && "Unroll directive accepts only a single loop");
3330 unsigned NumClauses
= Record
[ASTStmtReader::NumStmtFields
+ 1];
3331 S
= OMPUnrollDirective::CreateEmpty(Context
, NumClauses
);
3335 case STMT_OMP_FOR_DIRECTIVE
: {
3336 unsigned CollapsedNum
= Record
[ASTStmtReader::NumStmtFields
];
3337 unsigned NumClauses
= Record
[ASTStmtReader::NumStmtFields
+ 1];
3338 S
= OMPForDirective::CreateEmpty(Context
, NumClauses
, CollapsedNum
,
3343 case STMT_OMP_FOR_SIMD_DIRECTIVE
: {
3344 unsigned CollapsedNum
= Record
[ASTStmtReader::NumStmtFields
];
3345 unsigned NumClauses
= Record
[ASTStmtReader::NumStmtFields
+ 1];
3346 S
= OMPForSimdDirective::CreateEmpty(Context
, NumClauses
, CollapsedNum
,
3351 case STMT_OMP_SECTIONS_DIRECTIVE
:
3352 S
= OMPSectionsDirective::CreateEmpty(
3353 Context
, Record
[ASTStmtReader::NumStmtFields
], Empty
);
3356 case STMT_OMP_SECTION_DIRECTIVE
:
3357 S
= OMPSectionDirective::CreateEmpty(Context
, Empty
);
3360 case STMT_OMP_SCOPE_DIRECTIVE
:
3361 S
= OMPScopeDirective::CreateEmpty(
3362 Context
, Record
[ASTStmtReader::NumStmtFields
], Empty
);
3365 case STMT_OMP_SINGLE_DIRECTIVE
:
3366 S
= OMPSingleDirective::CreateEmpty(
3367 Context
, Record
[ASTStmtReader::NumStmtFields
], Empty
);
3370 case STMT_OMP_MASTER_DIRECTIVE
:
3371 S
= OMPMasterDirective::CreateEmpty(Context
, Empty
);
3374 case STMT_OMP_CRITICAL_DIRECTIVE
:
3375 S
= OMPCriticalDirective::CreateEmpty(
3376 Context
, Record
[ASTStmtReader::NumStmtFields
], Empty
);
3379 case STMT_OMP_PARALLEL_FOR_DIRECTIVE
: {
3380 unsigned CollapsedNum
= Record
[ASTStmtReader::NumStmtFields
];
3381 unsigned NumClauses
= Record
[ASTStmtReader::NumStmtFields
+ 1];
3382 S
= OMPParallelForDirective::CreateEmpty(Context
, NumClauses
,
3383 CollapsedNum
, Empty
);
3387 case STMT_OMP_PARALLEL_FOR_SIMD_DIRECTIVE
: {
3388 unsigned CollapsedNum
= Record
[ASTStmtReader::NumStmtFields
];
3389 unsigned NumClauses
= Record
[ASTStmtReader::NumStmtFields
+ 1];
3390 S
= OMPParallelForSimdDirective::CreateEmpty(Context
, NumClauses
,
3391 CollapsedNum
, Empty
);
3395 case STMT_OMP_PARALLEL_MASTER_DIRECTIVE
:
3396 S
= OMPParallelMasterDirective::CreateEmpty(
3397 Context
, Record
[ASTStmtReader::NumStmtFields
], Empty
);
3400 case STMT_OMP_PARALLEL_MASKED_DIRECTIVE
:
3401 S
= OMPParallelMaskedDirective::CreateEmpty(
3402 Context
, Record
[ASTStmtReader::NumStmtFields
], Empty
);
3405 case STMT_OMP_PARALLEL_SECTIONS_DIRECTIVE
:
3406 S
= OMPParallelSectionsDirective::CreateEmpty(
3407 Context
, Record
[ASTStmtReader::NumStmtFields
], Empty
);
3410 case STMT_OMP_TASK_DIRECTIVE
:
3411 S
= OMPTaskDirective::CreateEmpty(
3412 Context
, Record
[ASTStmtReader::NumStmtFields
], Empty
);
3415 case STMT_OMP_TASKYIELD_DIRECTIVE
:
3416 S
= OMPTaskyieldDirective::CreateEmpty(Context
, Empty
);
3419 case STMT_OMP_BARRIER_DIRECTIVE
:
3420 S
= OMPBarrierDirective::CreateEmpty(Context
, Empty
);
3423 case STMT_OMP_TASKWAIT_DIRECTIVE
:
3424 S
= OMPTaskwaitDirective::CreateEmpty(
3425 Context
, Record
[ASTStmtReader::NumStmtFields
], Empty
);
3428 case STMT_OMP_ERROR_DIRECTIVE
:
3429 S
= OMPErrorDirective::CreateEmpty(
3430 Context
, Record
[ASTStmtReader::NumStmtFields
], Empty
);
3433 case STMT_OMP_TASKGROUP_DIRECTIVE
:
3434 S
= OMPTaskgroupDirective::CreateEmpty(
3435 Context
, Record
[ASTStmtReader::NumStmtFields
], Empty
);
3438 case STMT_OMP_FLUSH_DIRECTIVE
:
3439 S
= OMPFlushDirective::CreateEmpty(
3440 Context
, Record
[ASTStmtReader::NumStmtFields
], Empty
);
3443 case STMT_OMP_DEPOBJ_DIRECTIVE
:
3444 S
= OMPDepobjDirective::CreateEmpty(
3445 Context
, Record
[ASTStmtReader::NumStmtFields
], Empty
);
3448 case STMT_OMP_SCAN_DIRECTIVE
:
3449 S
= OMPScanDirective::CreateEmpty(
3450 Context
, Record
[ASTStmtReader::NumStmtFields
], Empty
);
3453 case STMT_OMP_ORDERED_DIRECTIVE
: {
3454 unsigned NumClauses
= Record
[ASTStmtReader::NumStmtFields
];
3455 bool HasAssociatedStmt
= Record
[ASTStmtReader::NumStmtFields
+ 2];
3456 S
= OMPOrderedDirective::CreateEmpty(Context
, NumClauses
,
3457 !HasAssociatedStmt
, Empty
);
3461 case STMT_OMP_ATOMIC_DIRECTIVE
:
3462 S
= OMPAtomicDirective::CreateEmpty(
3463 Context
, Record
[ASTStmtReader::NumStmtFields
], Empty
);
3466 case STMT_OMP_TARGET_DIRECTIVE
:
3467 S
= OMPTargetDirective::CreateEmpty(
3468 Context
, Record
[ASTStmtReader::NumStmtFields
], Empty
);
3471 case STMT_OMP_TARGET_DATA_DIRECTIVE
:
3472 S
= OMPTargetDataDirective::CreateEmpty(
3473 Context
, Record
[ASTStmtReader::NumStmtFields
], Empty
);
3476 case STMT_OMP_TARGET_ENTER_DATA_DIRECTIVE
:
3477 S
= OMPTargetEnterDataDirective::CreateEmpty(
3478 Context
, Record
[ASTStmtReader::NumStmtFields
], Empty
);
3481 case STMT_OMP_TARGET_EXIT_DATA_DIRECTIVE
:
3482 S
= OMPTargetExitDataDirective::CreateEmpty(
3483 Context
, Record
[ASTStmtReader::NumStmtFields
], Empty
);
3486 case STMT_OMP_TARGET_PARALLEL_DIRECTIVE
:
3487 S
= OMPTargetParallelDirective::CreateEmpty(
3488 Context
, Record
[ASTStmtReader::NumStmtFields
], Empty
);
3491 case STMT_OMP_TARGET_PARALLEL_FOR_DIRECTIVE
: {
3492 unsigned CollapsedNum
= Record
[ASTStmtReader::NumStmtFields
];
3493 unsigned NumClauses
= Record
[ASTStmtReader::NumStmtFields
+ 1];
3494 S
= OMPTargetParallelForDirective::CreateEmpty(Context
, NumClauses
,
3495 CollapsedNum
, Empty
);
3499 case STMT_OMP_TARGET_UPDATE_DIRECTIVE
:
3500 S
= OMPTargetUpdateDirective::CreateEmpty(
3501 Context
, Record
[ASTStmtReader::NumStmtFields
], Empty
);
3504 case STMT_OMP_TEAMS_DIRECTIVE
:
3505 S
= OMPTeamsDirective::CreateEmpty(
3506 Context
, Record
[ASTStmtReader::NumStmtFields
], Empty
);
3509 case STMT_OMP_CANCELLATION_POINT_DIRECTIVE
:
3510 S
= OMPCancellationPointDirective::CreateEmpty(Context
, Empty
);
3513 case STMT_OMP_CANCEL_DIRECTIVE
:
3514 S
= OMPCancelDirective::CreateEmpty(
3515 Context
, Record
[ASTStmtReader::NumStmtFields
], Empty
);
3518 case STMT_OMP_TASKLOOP_DIRECTIVE
: {
3519 unsigned CollapsedNum
= Record
[ASTStmtReader::NumStmtFields
];
3520 unsigned NumClauses
= Record
[ASTStmtReader::NumStmtFields
+ 1];
3521 S
= OMPTaskLoopDirective::CreateEmpty(Context
, NumClauses
, CollapsedNum
,
3526 case STMT_OMP_TASKLOOP_SIMD_DIRECTIVE
: {
3527 unsigned CollapsedNum
= Record
[ASTStmtReader::NumStmtFields
];
3528 unsigned NumClauses
= Record
[ASTStmtReader::NumStmtFields
+ 1];
3529 S
= OMPTaskLoopSimdDirective::CreateEmpty(Context
, NumClauses
,
3530 CollapsedNum
, Empty
);
3534 case STMT_OMP_MASTER_TASKLOOP_DIRECTIVE
: {
3535 unsigned CollapsedNum
= Record
[ASTStmtReader::NumStmtFields
];
3536 unsigned NumClauses
= Record
[ASTStmtReader::NumStmtFields
+ 1];
3537 S
= OMPMasterTaskLoopDirective::CreateEmpty(Context
, NumClauses
,
3538 CollapsedNum
, Empty
);
3542 case STMT_OMP_MASKED_TASKLOOP_DIRECTIVE
: {
3543 unsigned CollapsedNum
= Record
[ASTStmtReader::NumStmtFields
];
3544 unsigned NumClauses
= Record
[ASTStmtReader::NumStmtFields
+ 1];
3545 S
= OMPMaskedTaskLoopDirective::CreateEmpty(Context
, NumClauses
,
3546 CollapsedNum
, Empty
);
3550 case STMT_OMP_MASTER_TASKLOOP_SIMD_DIRECTIVE
: {
3551 unsigned CollapsedNum
= Record
[ASTStmtReader::NumStmtFields
];
3552 unsigned NumClauses
= Record
[ASTStmtReader::NumStmtFields
+ 1];
3553 S
= OMPMasterTaskLoopSimdDirective::CreateEmpty(Context
, NumClauses
,
3554 CollapsedNum
, Empty
);
3558 case STMT_OMP_MASKED_TASKLOOP_SIMD_DIRECTIVE
: {
3559 unsigned CollapsedNum
= Record
[ASTStmtReader::NumStmtFields
];
3560 unsigned NumClauses
= Record
[ASTStmtReader::NumStmtFields
+ 1];
3561 S
= OMPMaskedTaskLoopSimdDirective::CreateEmpty(Context
, NumClauses
,
3562 CollapsedNum
, Empty
);
3566 case STMT_OMP_PARALLEL_MASTER_TASKLOOP_DIRECTIVE
: {
3567 unsigned CollapsedNum
= Record
[ASTStmtReader::NumStmtFields
];
3568 unsigned NumClauses
= Record
[ASTStmtReader::NumStmtFields
+ 1];
3569 S
= OMPParallelMasterTaskLoopDirective::CreateEmpty(Context
, NumClauses
,
3570 CollapsedNum
, Empty
);
3574 case STMT_OMP_PARALLEL_MASKED_TASKLOOP_DIRECTIVE
: {
3575 unsigned CollapsedNum
= Record
[ASTStmtReader::NumStmtFields
];
3576 unsigned NumClauses
= Record
[ASTStmtReader::NumStmtFields
+ 1];
3577 S
= OMPParallelMaskedTaskLoopDirective::CreateEmpty(Context
, NumClauses
,
3578 CollapsedNum
, Empty
);
3582 case STMT_OMP_PARALLEL_MASTER_TASKLOOP_SIMD_DIRECTIVE
: {
3583 unsigned CollapsedNum
= Record
[ASTStmtReader::NumStmtFields
];
3584 unsigned NumClauses
= Record
[ASTStmtReader::NumStmtFields
+ 1];
3585 S
= OMPParallelMasterTaskLoopSimdDirective::CreateEmpty(
3586 Context
, NumClauses
, CollapsedNum
, Empty
);
3590 case STMT_OMP_PARALLEL_MASKED_TASKLOOP_SIMD_DIRECTIVE
: {
3591 unsigned CollapsedNum
= Record
[ASTStmtReader::NumStmtFields
];
3592 unsigned NumClauses
= Record
[ASTStmtReader::NumStmtFields
+ 1];
3593 S
= OMPParallelMaskedTaskLoopSimdDirective::CreateEmpty(
3594 Context
, NumClauses
, CollapsedNum
, Empty
);
3598 case STMT_OMP_DISTRIBUTE_DIRECTIVE
: {
3599 unsigned CollapsedNum
= Record
[ASTStmtReader::NumStmtFields
];
3600 unsigned NumClauses
= Record
[ASTStmtReader::NumStmtFields
+ 1];
3601 S
= OMPDistributeDirective::CreateEmpty(Context
, NumClauses
, CollapsedNum
,
3606 case STMT_OMP_DISTRIBUTE_PARALLEL_FOR_DIRECTIVE
: {
3607 unsigned CollapsedNum
= Record
[ASTStmtReader::NumStmtFields
];
3608 unsigned NumClauses
= Record
[ASTStmtReader::NumStmtFields
+ 1];
3609 S
= OMPDistributeParallelForDirective::CreateEmpty(Context
, NumClauses
,
3610 CollapsedNum
, Empty
);
3614 case STMT_OMP_DISTRIBUTE_PARALLEL_FOR_SIMD_DIRECTIVE
: {
3615 unsigned CollapsedNum
= Record
[ASTStmtReader::NumStmtFields
];
3616 unsigned NumClauses
= Record
[ASTStmtReader::NumStmtFields
+ 1];
3617 S
= OMPDistributeParallelForSimdDirective::CreateEmpty(Context
, NumClauses
,
3623 case STMT_OMP_DISTRIBUTE_SIMD_DIRECTIVE
: {
3624 unsigned CollapsedNum
= Record
[ASTStmtReader::NumStmtFields
];
3625 unsigned NumClauses
= Record
[ASTStmtReader::NumStmtFields
+ 1];
3626 S
= OMPDistributeSimdDirective::CreateEmpty(Context
, NumClauses
,
3627 CollapsedNum
, Empty
);
3631 case STMT_OMP_TARGET_PARALLEL_FOR_SIMD_DIRECTIVE
: {
3632 unsigned CollapsedNum
= Record
[ASTStmtReader::NumStmtFields
];
3633 unsigned NumClauses
= Record
[ASTStmtReader::NumStmtFields
+ 1];
3634 S
= OMPTargetParallelForSimdDirective::CreateEmpty(Context
, NumClauses
,
3635 CollapsedNum
, Empty
);
3639 case STMT_OMP_TARGET_SIMD_DIRECTIVE
: {
3640 unsigned CollapsedNum
= Record
[ASTStmtReader::NumStmtFields
];
3641 unsigned NumClauses
= Record
[ASTStmtReader::NumStmtFields
+ 1];
3642 S
= OMPTargetSimdDirective::CreateEmpty(Context
, NumClauses
, CollapsedNum
,
3647 case STMT_OMP_TEAMS_DISTRIBUTE_DIRECTIVE
: {
3648 unsigned CollapsedNum
= Record
[ASTStmtReader::NumStmtFields
];
3649 unsigned NumClauses
= Record
[ASTStmtReader::NumStmtFields
+ 1];
3650 S
= OMPTeamsDistributeDirective::CreateEmpty(Context
, NumClauses
,
3651 CollapsedNum
, Empty
);
3655 case STMT_OMP_TEAMS_DISTRIBUTE_SIMD_DIRECTIVE
: {
3656 unsigned CollapsedNum
= Record
[ASTStmtReader::NumStmtFields
];
3657 unsigned NumClauses
= Record
[ASTStmtReader::NumStmtFields
+ 1];
3658 S
= OMPTeamsDistributeSimdDirective::CreateEmpty(Context
, NumClauses
,
3659 CollapsedNum
, Empty
);
3663 case STMT_OMP_TEAMS_DISTRIBUTE_PARALLEL_FOR_SIMD_DIRECTIVE
: {
3664 unsigned CollapsedNum
= Record
[ASTStmtReader::NumStmtFields
];
3665 unsigned NumClauses
= Record
[ASTStmtReader::NumStmtFields
+ 1];
3666 S
= OMPTeamsDistributeParallelForSimdDirective::CreateEmpty(
3667 Context
, NumClauses
, CollapsedNum
, Empty
);
3671 case STMT_OMP_TEAMS_DISTRIBUTE_PARALLEL_FOR_DIRECTIVE
: {
3672 unsigned CollapsedNum
= Record
[ASTStmtReader::NumStmtFields
];
3673 unsigned NumClauses
= Record
[ASTStmtReader::NumStmtFields
+ 1];
3674 S
= OMPTeamsDistributeParallelForDirective::CreateEmpty(
3675 Context
, NumClauses
, CollapsedNum
, Empty
);
3679 case STMT_OMP_TARGET_TEAMS_DIRECTIVE
:
3680 S
= OMPTargetTeamsDirective::CreateEmpty(
3681 Context
, Record
[ASTStmtReader::NumStmtFields
], Empty
);
3684 case STMT_OMP_TARGET_TEAMS_DISTRIBUTE_DIRECTIVE
: {
3685 unsigned CollapsedNum
= Record
[ASTStmtReader::NumStmtFields
];
3686 unsigned NumClauses
= Record
[ASTStmtReader::NumStmtFields
+ 1];
3687 S
= OMPTargetTeamsDistributeDirective::CreateEmpty(Context
, NumClauses
,
3688 CollapsedNum
, Empty
);
3692 case STMT_OMP_TARGET_TEAMS_DISTRIBUTE_PARALLEL_FOR_DIRECTIVE
: {
3693 unsigned CollapsedNum
= Record
[ASTStmtReader::NumStmtFields
];
3694 unsigned NumClauses
= Record
[ASTStmtReader::NumStmtFields
+ 1];
3695 S
= OMPTargetTeamsDistributeParallelForDirective::CreateEmpty(
3696 Context
, NumClauses
, CollapsedNum
, Empty
);
3700 case STMT_OMP_TARGET_TEAMS_DISTRIBUTE_PARALLEL_FOR_SIMD_DIRECTIVE
: {
3701 unsigned CollapsedNum
= Record
[ASTStmtReader::NumStmtFields
];
3702 unsigned NumClauses
= Record
[ASTStmtReader::NumStmtFields
+ 1];
3703 S
= OMPTargetTeamsDistributeParallelForSimdDirective::CreateEmpty(
3704 Context
, NumClauses
, CollapsedNum
, Empty
);
3708 case STMT_OMP_TARGET_TEAMS_DISTRIBUTE_SIMD_DIRECTIVE
: {
3709 unsigned CollapsedNum
= Record
[ASTStmtReader::NumStmtFields
];
3710 unsigned NumClauses
= Record
[ASTStmtReader::NumStmtFields
+ 1];
3711 S
= OMPTargetTeamsDistributeSimdDirective::CreateEmpty(
3712 Context
, NumClauses
, CollapsedNum
, Empty
);
3716 case STMT_OMP_INTEROP_DIRECTIVE
:
3717 S
= OMPInteropDirective::CreateEmpty(
3718 Context
, Record
[ASTStmtReader::NumStmtFields
], Empty
);
3721 case STMT_OMP_DISPATCH_DIRECTIVE
:
3722 S
= OMPDispatchDirective::CreateEmpty(
3723 Context
, Record
[ASTStmtReader::NumStmtFields
], Empty
);
3726 case STMT_OMP_MASKED_DIRECTIVE
:
3727 S
= OMPMaskedDirective::CreateEmpty(
3728 Context
, Record
[ASTStmtReader::NumStmtFields
], Empty
);
3731 case STMT_OMP_GENERIC_LOOP_DIRECTIVE
: {
3732 unsigned CollapsedNum
= Record
[ASTStmtReader::NumStmtFields
];
3733 unsigned NumClauses
= Record
[ASTStmtReader::NumStmtFields
+ 1];
3734 S
= OMPGenericLoopDirective::CreateEmpty(Context
, NumClauses
,
3735 CollapsedNum
, Empty
);
3739 case STMT_OMP_TEAMS_GENERIC_LOOP_DIRECTIVE
: {
3740 unsigned CollapsedNum
= Record
[ASTStmtReader::NumStmtFields
];
3741 unsigned NumClauses
= Record
[ASTStmtReader::NumStmtFields
+ 1];
3742 S
= OMPTeamsGenericLoopDirective::CreateEmpty(Context
, NumClauses
,
3743 CollapsedNum
, Empty
);
3747 case STMT_OMP_TARGET_TEAMS_GENERIC_LOOP_DIRECTIVE
: {
3748 unsigned CollapsedNum
= Record
[ASTStmtReader::NumStmtFields
];
3749 unsigned NumClauses
= Record
[ASTStmtReader::NumStmtFields
+ 1];
3750 S
= OMPTargetTeamsGenericLoopDirective::CreateEmpty(Context
, NumClauses
,
3751 CollapsedNum
, Empty
);
3755 case STMT_OMP_PARALLEL_GENERIC_LOOP_DIRECTIVE
: {
3756 unsigned CollapsedNum
= Record
[ASTStmtReader::NumStmtFields
];
3757 unsigned NumClauses
= Record
[ASTStmtReader::NumStmtFields
+ 1];
3758 S
= OMPParallelGenericLoopDirective::CreateEmpty(Context
, NumClauses
,
3759 CollapsedNum
, Empty
);
3763 case STMT_OMP_TARGET_PARALLEL_GENERIC_LOOP_DIRECTIVE
: {
3764 unsigned CollapsedNum
= Record
[ASTStmtReader::NumStmtFields
];
3765 unsigned NumClauses
= Record
[ASTStmtReader::NumStmtFields
+ 1];
3766 S
= OMPTargetParallelGenericLoopDirective::CreateEmpty(
3767 Context
, NumClauses
, CollapsedNum
, Empty
);
3771 case EXPR_CXX_OPERATOR_CALL
:
3772 S
= CXXOperatorCallExpr::CreateEmpty(
3773 Context
, /*NumArgs=*/Record
[ASTStmtReader::NumExprFields
],
3774 /*HasFPFeatures=*/Record
[ASTStmtReader::NumExprFields
+ 1], Empty
);
3777 case EXPR_CXX_MEMBER_CALL
:
3778 S
= CXXMemberCallExpr::CreateEmpty(
3779 Context
, /*NumArgs=*/Record
[ASTStmtReader::NumExprFields
],
3780 /*HasFPFeatures=*/Record
[ASTStmtReader::NumExprFields
+ 1], Empty
);
3783 case EXPR_CXX_REWRITTEN_BINARY_OPERATOR
:
3784 S
= new (Context
) CXXRewrittenBinaryOperator(Empty
);
3787 case EXPR_CXX_CONSTRUCT
:
3788 S
= CXXConstructExpr::CreateEmpty(
3790 /* NumArgs=*/Record
[ASTStmtReader::NumExprFields
]);
3793 case EXPR_CXX_INHERITED_CTOR_INIT
:
3794 S
= new (Context
) CXXInheritedCtorInitExpr(Empty
);
3797 case EXPR_CXX_TEMPORARY_OBJECT
:
3798 S
= CXXTemporaryObjectExpr::CreateEmpty(
3800 /* NumArgs=*/Record
[ASTStmtReader::NumExprFields
]);
3803 case EXPR_CXX_STATIC_CAST
:
3804 S
= CXXStaticCastExpr::CreateEmpty(
3806 /*PathSize*/ Record
[ASTStmtReader::NumExprFields
],
3807 /*HasFPFeatures*/ Record
[ASTStmtReader::NumExprFields
+ 1]);
3810 case EXPR_CXX_DYNAMIC_CAST
:
3811 S
= CXXDynamicCastExpr::CreateEmpty(Context
,
3812 /*PathSize*/ Record
[ASTStmtReader::NumExprFields
]);
3815 case EXPR_CXX_REINTERPRET_CAST
:
3816 S
= CXXReinterpretCastExpr::CreateEmpty(Context
,
3817 /*PathSize*/ Record
[ASTStmtReader::NumExprFields
]);
3820 case EXPR_CXX_CONST_CAST
:
3821 S
= CXXConstCastExpr::CreateEmpty(Context
);
3824 case EXPR_CXX_ADDRSPACE_CAST
:
3825 S
= CXXAddrspaceCastExpr::CreateEmpty(Context
);
3828 case EXPR_CXX_FUNCTIONAL_CAST
:
3829 S
= CXXFunctionalCastExpr::CreateEmpty(
3831 /*PathSize*/ Record
[ASTStmtReader::NumExprFields
],
3832 /*HasFPFeatures*/ Record
[ASTStmtReader::NumExprFields
+ 1]);
3835 case EXPR_BUILTIN_BIT_CAST
:
3836 assert(Record
[ASTStmtReader::NumExprFields
] == 0 && "Wrong PathSize!");
3837 S
= new (Context
) BuiltinBitCastExpr(Empty
);
3840 case EXPR_USER_DEFINED_LITERAL
:
3841 S
= UserDefinedLiteral::CreateEmpty(
3842 Context
, /*NumArgs=*/Record
[ASTStmtReader::NumExprFields
],
3843 /*HasFPFeatures=*/Record
[ASTStmtReader::NumExprFields
+ 1], Empty
);
3846 case EXPR_CXX_STD_INITIALIZER_LIST
:
3847 S
= new (Context
) CXXStdInitializerListExpr(Empty
);
3850 case EXPR_CXX_BOOL_LITERAL
:
3851 S
= new (Context
) CXXBoolLiteralExpr(Empty
);
3854 case EXPR_CXX_NULL_PTR_LITERAL
:
3855 S
= new (Context
) CXXNullPtrLiteralExpr(Empty
);
3858 case EXPR_CXX_TYPEID_EXPR
:
3859 S
= new (Context
) CXXTypeidExpr(Empty
, true);
3862 case EXPR_CXX_TYPEID_TYPE
:
3863 S
= new (Context
) CXXTypeidExpr(Empty
, false);
3866 case EXPR_CXX_UUIDOF_EXPR
:
3867 S
= new (Context
) CXXUuidofExpr(Empty
, true);
3870 case EXPR_CXX_PROPERTY_REF_EXPR
:
3871 S
= new (Context
) MSPropertyRefExpr(Empty
);
3874 case EXPR_CXX_PROPERTY_SUBSCRIPT_EXPR
:
3875 S
= new (Context
) MSPropertySubscriptExpr(Empty
);
3878 case EXPR_CXX_UUIDOF_TYPE
:
3879 S
= new (Context
) CXXUuidofExpr(Empty
, false);
3883 S
= new (Context
) CXXThisExpr(Empty
);
3886 case EXPR_CXX_THROW
:
3887 S
= new (Context
) CXXThrowExpr(Empty
);
3890 case EXPR_CXX_DEFAULT_ARG
:
3891 S
= CXXDefaultArgExpr::CreateEmpty(
3892 Context
, /*HasRewrittenInit=*/Record
[ASTStmtReader::NumExprFields
]);
3895 case EXPR_CXX_DEFAULT_INIT
:
3896 S
= CXXDefaultInitExpr::CreateEmpty(
3897 Context
, /*HasRewrittenInit=*/Record
[ASTStmtReader::NumExprFields
]);
3900 case EXPR_CXX_BIND_TEMPORARY
:
3901 S
= new (Context
) CXXBindTemporaryExpr(Empty
);
3904 case EXPR_CXX_SCALAR_VALUE_INIT
:
3905 S
= new (Context
) CXXScalarValueInitExpr(Empty
);
3909 S
= CXXNewExpr::CreateEmpty(
3911 /*IsArray=*/Record
[ASTStmtReader::NumExprFields
],
3912 /*HasInit=*/Record
[ASTStmtReader::NumExprFields
+ 1],
3913 /*NumPlacementArgs=*/Record
[ASTStmtReader::NumExprFields
+ 2],
3914 /*IsParenTypeId=*/Record
[ASTStmtReader::NumExprFields
+ 3]);
3917 case EXPR_CXX_DELETE
:
3918 S
= new (Context
) CXXDeleteExpr(Empty
);
3921 case EXPR_CXX_PSEUDO_DESTRUCTOR
:
3922 S
= new (Context
) CXXPseudoDestructorExpr(Empty
);
3925 case EXPR_EXPR_WITH_CLEANUPS
:
3926 S
= ExprWithCleanups::Create(Context
, Empty
,
3927 Record
[ASTStmtReader::NumExprFields
]);
3930 case EXPR_CXX_DEPENDENT_SCOPE_MEMBER
:
3931 S
= CXXDependentScopeMemberExpr::CreateEmpty(
3933 /*HasTemplateKWAndArgsInfo=*/Record
[ASTStmtReader::NumExprFields
],
3934 /*NumTemplateArgs=*/Record
[ASTStmtReader::NumExprFields
+ 1],
3935 /*HasFirstQualifierFoundInScope=*/
3936 Record
[ASTStmtReader::NumExprFields
+ 2]);
3939 case EXPR_CXX_DEPENDENT_SCOPE_DECL_REF
:
3940 S
= DependentScopeDeclRefExpr::CreateEmpty(Context
,
3941 /*HasTemplateKWAndArgsInfo=*/Record
[ASTStmtReader::NumExprFields
],
3942 /*NumTemplateArgs=*/Record
[ASTStmtReader::NumExprFields
]
3943 ? Record
[ASTStmtReader::NumExprFields
+ 1]
3947 case EXPR_CXX_UNRESOLVED_CONSTRUCT
:
3948 S
= CXXUnresolvedConstructExpr::CreateEmpty(Context
,
3949 /*NumArgs=*/Record
[ASTStmtReader::NumExprFields
]);
3952 case EXPR_CXX_UNRESOLVED_MEMBER
:
3953 S
= UnresolvedMemberExpr::CreateEmpty(
3955 /*NumResults=*/Record
[ASTStmtReader::NumExprFields
],
3956 /*HasTemplateKWAndArgsInfo=*/Record
[ASTStmtReader::NumExprFields
+ 1],
3957 /*NumTemplateArgs=*/
3958 Record
[ASTStmtReader::NumExprFields
+ 1]
3959 ? Record
[ASTStmtReader::NumExprFields
+ 2]
3963 case EXPR_CXX_UNRESOLVED_LOOKUP
:
3964 S
= UnresolvedLookupExpr::CreateEmpty(
3966 /*NumResults=*/Record
[ASTStmtReader::NumExprFields
],
3967 /*HasTemplateKWAndArgsInfo=*/Record
[ASTStmtReader::NumExprFields
+ 1],
3968 /*NumTemplateArgs=*/
3969 Record
[ASTStmtReader::NumExprFields
+ 1]
3970 ? Record
[ASTStmtReader::NumExprFields
+ 2]
3974 case EXPR_TYPE_TRAIT
:
3975 S
= TypeTraitExpr::CreateDeserialized(Context
,
3976 Record
[ASTStmtReader::NumExprFields
]);
3979 case EXPR_ARRAY_TYPE_TRAIT
:
3980 S
= new (Context
) ArrayTypeTraitExpr(Empty
);
3983 case EXPR_CXX_EXPRESSION_TRAIT
:
3984 S
= new (Context
) ExpressionTraitExpr(Empty
);
3987 case EXPR_CXX_NOEXCEPT
:
3988 S
= new (Context
) CXXNoexceptExpr(Empty
);
3991 case EXPR_PACK_EXPANSION
:
3992 S
= new (Context
) PackExpansionExpr(Empty
);
3995 case EXPR_SIZEOF_PACK
:
3996 S
= SizeOfPackExpr::CreateDeserialized(
3998 /*NumPartialArgs=*/Record
[ASTStmtReader::NumExprFields
]);
4001 case EXPR_SUBST_NON_TYPE_TEMPLATE_PARM
:
4002 S
= new (Context
) SubstNonTypeTemplateParmExpr(Empty
);
4005 case EXPR_SUBST_NON_TYPE_TEMPLATE_PARM_PACK
:
4006 S
= new (Context
) SubstNonTypeTemplateParmPackExpr(Empty
);
4009 case EXPR_FUNCTION_PARM_PACK
:
4010 S
= FunctionParmPackExpr::CreateEmpty(Context
,
4011 Record
[ASTStmtReader::NumExprFields
]);
4014 case EXPR_MATERIALIZE_TEMPORARY
:
4015 S
= new (Context
) MaterializeTemporaryExpr(Empty
);
4019 S
= new (Context
) CXXFoldExpr(Empty
);
4022 case EXPR_CXX_PAREN_LIST_INIT
:
4023 S
= CXXParenListInitExpr::CreateEmpty(
4024 Context
, /*numExprs=*/Record
[ASTStmtReader::NumExprFields
], Empty
);
4027 case EXPR_OPAQUE_VALUE
:
4028 S
= new (Context
) OpaqueValueExpr(Empty
);
4031 case EXPR_CUDA_KERNEL_CALL
:
4032 S
= CUDAKernelCallExpr::CreateEmpty(
4033 Context
, /*NumArgs=*/Record
[ASTStmtReader::NumExprFields
],
4034 /*HasFPFeatures=*/Record
[ASTStmtReader::NumExprFields
+ 1], Empty
);
4038 S
= new (Context
) AsTypeExpr(Empty
);
4041 case EXPR_PSEUDO_OBJECT
: {
4042 unsigned numSemanticExprs
= Record
[ASTStmtReader::NumExprFields
];
4043 S
= PseudoObjectExpr::Create(Context
, Empty
, numSemanticExprs
);
4048 S
= new (Context
) AtomicExpr(Empty
);
4052 unsigned NumCaptures
= Record
[ASTStmtReader::NumExprFields
];
4053 S
= LambdaExpr::CreateDeserialized(Context
, NumCaptures
);
4057 case STMT_COROUTINE_BODY
: {
4058 unsigned NumParams
= Record
[ASTStmtReader::NumStmtFields
];
4059 S
= CoroutineBodyStmt::Create(Context
, Empty
, NumParams
);
4064 S
= new (Context
) CoreturnStmt(Empty
);
4068 S
= new (Context
) CoawaitExpr(Empty
);
4072 S
= new (Context
) CoyieldExpr(Empty
);
4075 case EXPR_DEPENDENT_COAWAIT
:
4076 S
= new (Context
) DependentCoawaitExpr(Empty
);
4079 case EXPR_CONCEPT_SPECIALIZATION
: {
4080 S
= new (Context
) ConceptSpecializationExpr(Empty
);
4085 unsigned numLocalParameters
= Record
[ASTStmtReader::NumExprFields
];
4086 unsigned numRequirement
= Record
[ASTStmtReader::NumExprFields
+ 1];
4087 S
= RequiresExpr::Create(Context
, Empty
, numLocalParameters
,
4092 // We hit a STMT_STOP, so we're done with this expression.
4096 ++NumStatementsRead
;
4098 if (S
&& !IsStmtReference
) {
4100 StmtEntries
[Cursor
.GetCurrentBitNo()] = S
;
4103 assert(Record
.getIdx() == Record
.size() &&
4104 "Invalid deserialization of statement");
4105 StmtStack
.push_back(S
);
4108 assert(StmtStack
.size() > PrevNumStmts
&& "Read too many sub-stmts!");
4109 assert(StmtStack
.size() == PrevNumStmts
+ 1 && "Extra expressions on stack!");
4110 return StmtStack
.pop_back_val();