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());
2330 void ASTStmtReader::VisitOMPLoopBasedDirective(OMPLoopBasedDirective
*D
) {
2332 // Field CollapsedNum was read in ReadStmtFromStream.
2334 VisitOMPExecutableDirective(D
);
2337 void ASTStmtReader::VisitOMPLoopDirective(OMPLoopDirective
*D
) {
2338 VisitOMPLoopBasedDirective(D
);
2341 void ASTStmtReader::VisitOMPMetaDirective(OMPMetaDirective
*D
) {
2343 // The NumClauses field was read in ReadStmtFromStream.
2345 VisitOMPExecutableDirective(D
);
2348 void ASTStmtReader::VisitOMPParallelDirective(OMPParallelDirective
*D
) {
2350 VisitOMPExecutableDirective(D
);
2351 D
->setHasCancel(Record
.readBool());
2354 void ASTStmtReader::VisitOMPSimdDirective(OMPSimdDirective
*D
) {
2355 VisitOMPLoopDirective(D
);
2358 void ASTStmtReader::VisitOMPLoopTransformationDirective(
2359 OMPLoopTransformationDirective
*D
) {
2360 VisitOMPLoopBasedDirective(D
);
2361 D
->setNumGeneratedLoops(Record
.readUInt32());
2364 void ASTStmtReader::VisitOMPTileDirective(OMPTileDirective
*D
) {
2365 VisitOMPLoopTransformationDirective(D
);
2368 void ASTStmtReader::VisitOMPUnrollDirective(OMPUnrollDirective
*D
) {
2369 VisitOMPLoopTransformationDirective(D
);
2372 void ASTStmtReader::VisitOMPForDirective(OMPForDirective
*D
) {
2373 VisitOMPLoopDirective(D
);
2374 D
->setHasCancel(Record
.readBool());
2377 void ASTStmtReader::VisitOMPForSimdDirective(OMPForSimdDirective
*D
) {
2378 VisitOMPLoopDirective(D
);
2381 void ASTStmtReader::VisitOMPSectionsDirective(OMPSectionsDirective
*D
) {
2383 VisitOMPExecutableDirective(D
);
2384 D
->setHasCancel(Record
.readBool());
2387 void ASTStmtReader::VisitOMPSectionDirective(OMPSectionDirective
*D
) {
2389 VisitOMPExecutableDirective(D
);
2390 D
->setHasCancel(Record
.readBool());
2393 void ASTStmtReader::VisitOMPSingleDirective(OMPSingleDirective
*D
) {
2395 VisitOMPExecutableDirective(D
);
2398 void ASTStmtReader::VisitOMPMasterDirective(OMPMasterDirective
*D
) {
2400 VisitOMPExecutableDirective(D
);
2403 void ASTStmtReader::VisitOMPCriticalDirective(OMPCriticalDirective
*D
) {
2405 VisitOMPExecutableDirective(D
);
2406 D
->DirName
= Record
.readDeclarationNameInfo();
2409 void ASTStmtReader::VisitOMPParallelForDirective(OMPParallelForDirective
*D
) {
2410 VisitOMPLoopDirective(D
);
2411 D
->setHasCancel(Record
.readBool());
2414 void ASTStmtReader::VisitOMPParallelForSimdDirective(
2415 OMPParallelForSimdDirective
*D
) {
2416 VisitOMPLoopDirective(D
);
2419 void ASTStmtReader::VisitOMPParallelMasterDirective(
2420 OMPParallelMasterDirective
*D
) {
2422 VisitOMPExecutableDirective(D
);
2425 void ASTStmtReader::VisitOMPParallelMaskedDirective(
2426 OMPParallelMaskedDirective
*D
) {
2428 VisitOMPExecutableDirective(D
);
2431 void ASTStmtReader::VisitOMPParallelSectionsDirective(
2432 OMPParallelSectionsDirective
*D
) {
2434 VisitOMPExecutableDirective(D
);
2435 D
->setHasCancel(Record
.readBool());
2438 void ASTStmtReader::VisitOMPTaskDirective(OMPTaskDirective
*D
) {
2440 VisitOMPExecutableDirective(D
);
2441 D
->setHasCancel(Record
.readBool());
2444 void ASTStmtReader::VisitOMPTaskyieldDirective(OMPTaskyieldDirective
*D
) {
2446 VisitOMPExecutableDirective(D
);
2449 void ASTStmtReader::VisitOMPBarrierDirective(OMPBarrierDirective
*D
) {
2451 VisitOMPExecutableDirective(D
);
2454 void ASTStmtReader::VisitOMPTaskwaitDirective(OMPTaskwaitDirective
*D
) {
2456 // The NumClauses field was read in ReadStmtFromStream.
2458 VisitOMPExecutableDirective(D
);
2461 void ASTStmtReader::VisitOMPErrorDirective(OMPErrorDirective
*D
) {
2463 // The NumClauses field was read in ReadStmtFromStream.
2465 VisitOMPExecutableDirective(D
);
2468 void ASTStmtReader::VisitOMPTaskgroupDirective(OMPTaskgroupDirective
*D
) {
2470 VisitOMPExecutableDirective(D
);
2473 void ASTStmtReader::VisitOMPFlushDirective(OMPFlushDirective
*D
) {
2475 VisitOMPExecutableDirective(D
);
2478 void ASTStmtReader::VisitOMPDepobjDirective(OMPDepobjDirective
*D
) {
2480 VisitOMPExecutableDirective(D
);
2483 void ASTStmtReader::VisitOMPScanDirective(OMPScanDirective
*D
) {
2485 VisitOMPExecutableDirective(D
);
2488 void ASTStmtReader::VisitOMPOrderedDirective(OMPOrderedDirective
*D
) {
2490 VisitOMPExecutableDirective(D
);
2493 void ASTStmtReader::VisitOMPAtomicDirective(OMPAtomicDirective
*D
) {
2495 VisitOMPExecutableDirective(D
);
2496 D
->Flags
.IsXLHSInRHSPart
= Record
.readBool() ? 1 : 0;
2497 D
->Flags
.IsPostfixUpdate
= Record
.readBool() ? 1 : 0;
2498 D
->Flags
.IsFailOnly
= Record
.readBool() ? 1 : 0;
2501 void ASTStmtReader::VisitOMPTargetDirective(OMPTargetDirective
*D
) {
2503 VisitOMPExecutableDirective(D
);
2506 void ASTStmtReader::VisitOMPTargetDataDirective(OMPTargetDataDirective
*D
) {
2508 VisitOMPExecutableDirective(D
);
2511 void ASTStmtReader::VisitOMPTargetEnterDataDirective(
2512 OMPTargetEnterDataDirective
*D
) {
2514 VisitOMPExecutableDirective(D
);
2517 void ASTStmtReader::VisitOMPTargetExitDataDirective(
2518 OMPTargetExitDataDirective
*D
) {
2520 VisitOMPExecutableDirective(D
);
2523 void ASTStmtReader::VisitOMPTargetParallelDirective(
2524 OMPTargetParallelDirective
*D
) {
2526 VisitOMPExecutableDirective(D
);
2527 D
->setHasCancel(Record
.readBool());
2530 void ASTStmtReader::VisitOMPTargetParallelForDirective(
2531 OMPTargetParallelForDirective
*D
) {
2532 VisitOMPLoopDirective(D
);
2533 D
->setHasCancel(Record
.readBool());
2536 void ASTStmtReader::VisitOMPTeamsDirective(OMPTeamsDirective
*D
) {
2538 VisitOMPExecutableDirective(D
);
2541 void ASTStmtReader::VisitOMPCancellationPointDirective(
2542 OMPCancellationPointDirective
*D
) {
2544 VisitOMPExecutableDirective(D
);
2545 D
->setCancelRegion(Record
.readEnum
<OpenMPDirectiveKind
>());
2548 void ASTStmtReader::VisitOMPCancelDirective(OMPCancelDirective
*D
) {
2550 VisitOMPExecutableDirective(D
);
2551 D
->setCancelRegion(Record
.readEnum
<OpenMPDirectiveKind
>());
2554 void ASTStmtReader::VisitOMPTaskLoopDirective(OMPTaskLoopDirective
*D
) {
2555 VisitOMPLoopDirective(D
);
2556 D
->setHasCancel(Record
.readBool());
2559 void ASTStmtReader::VisitOMPTaskLoopSimdDirective(OMPTaskLoopSimdDirective
*D
) {
2560 VisitOMPLoopDirective(D
);
2563 void ASTStmtReader::VisitOMPMasterTaskLoopDirective(
2564 OMPMasterTaskLoopDirective
*D
) {
2565 VisitOMPLoopDirective(D
);
2566 D
->setHasCancel(Record
.readBool());
2569 void ASTStmtReader::VisitOMPMaskedTaskLoopDirective(
2570 OMPMaskedTaskLoopDirective
*D
) {
2571 VisitOMPLoopDirective(D
);
2572 D
->setHasCancel(Record
.readBool());
2575 void ASTStmtReader::VisitOMPMasterTaskLoopSimdDirective(
2576 OMPMasterTaskLoopSimdDirective
*D
) {
2577 VisitOMPLoopDirective(D
);
2580 void ASTStmtReader::VisitOMPMaskedTaskLoopSimdDirective(
2581 OMPMaskedTaskLoopSimdDirective
*D
) {
2582 VisitOMPLoopDirective(D
);
2585 void ASTStmtReader::VisitOMPParallelMasterTaskLoopDirective(
2586 OMPParallelMasterTaskLoopDirective
*D
) {
2587 VisitOMPLoopDirective(D
);
2588 D
->setHasCancel(Record
.readBool());
2591 void ASTStmtReader::VisitOMPParallelMaskedTaskLoopDirective(
2592 OMPParallelMaskedTaskLoopDirective
*D
) {
2593 VisitOMPLoopDirective(D
);
2594 D
->setHasCancel(Record
.readBool());
2597 void ASTStmtReader::VisitOMPParallelMasterTaskLoopSimdDirective(
2598 OMPParallelMasterTaskLoopSimdDirective
*D
) {
2599 VisitOMPLoopDirective(D
);
2602 void ASTStmtReader::VisitOMPParallelMaskedTaskLoopSimdDirective(
2603 OMPParallelMaskedTaskLoopSimdDirective
*D
) {
2604 VisitOMPLoopDirective(D
);
2607 void ASTStmtReader::VisitOMPDistributeDirective(OMPDistributeDirective
*D
) {
2608 VisitOMPLoopDirective(D
);
2611 void ASTStmtReader::VisitOMPTargetUpdateDirective(OMPTargetUpdateDirective
*D
) {
2613 VisitOMPExecutableDirective(D
);
2616 void ASTStmtReader::VisitOMPDistributeParallelForDirective(
2617 OMPDistributeParallelForDirective
*D
) {
2618 VisitOMPLoopDirective(D
);
2619 D
->setHasCancel(Record
.readBool());
2622 void ASTStmtReader::VisitOMPDistributeParallelForSimdDirective(
2623 OMPDistributeParallelForSimdDirective
*D
) {
2624 VisitOMPLoopDirective(D
);
2627 void ASTStmtReader::VisitOMPDistributeSimdDirective(
2628 OMPDistributeSimdDirective
*D
) {
2629 VisitOMPLoopDirective(D
);
2632 void ASTStmtReader::VisitOMPTargetParallelForSimdDirective(
2633 OMPTargetParallelForSimdDirective
*D
) {
2634 VisitOMPLoopDirective(D
);
2637 void ASTStmtReader::VisitOMPTargetSimdDirective(OMPTargetSimdDirective
*D
) {
2638 VisitOMPLoopDirective(D
);
2641 void ASTStmtReader::VisitOMPTeamsDistributeDirective(
2642 OMPTeamsDistributeDirective
*D
) {
2643 VisitOMPLoopDirective(D
);
2646 void ASTStmtReader::VisitOMPTeamsDistributeSimdDirective(
2647 OMPTeamsDistributeSimdDirective
*D
) {
2648 VisitOMPLoopDirective(D
);
2651 void ASTStmtReader::VisitOMPTeamsDistributeParallelForSimdDirective(
2652 OMPTeamsDistributeParallelForSimdDirective
*D
) {
2653 VisitOMPLoopDirective(D
);
2656 void ASTStmtReader::VisitOMPTeamsDistributeParallelForDirective(
2657 OMPTeamsDistributeParallelForDirective
*D
) {
2658 VisitOMPLoopDirective(D
);
2659 D
->setHasCancel(Record
.readBool());
2662 void ASTStmtReader::VisitOMPTargetTeamsDirective(OMPTargetTeamsDirective
*D
) {
2664 VisitOMPExecutableDirective(D
);
2667 void ASTStmtReader::VisitOMPTargetTeamsDistributeDirective(
2668 OMPTargetTeamsDistributeDirective
*D
) {
2669 VisitOMPLoopDirective(D
);
2672 void ASTStmtReader::VisitOMPTargetTeamsDistributeParallelForDirective(
2673 OMPTargetTeamsDistributeParallelForDirective
*D
) {
2674 VisitOMPLoopDirective(D
);
2675 D
->setHasCancel(Record
.readBool());
2678 void ASTStmtReader::VisitOMPTargetTeamsDistributeParallelForSimdDirective(
2679 OMPTargetTeamsDistributeParallelForSimdDirective
*D
) {
2680 VisitOMPLoopDirective(D
);
2683 void ASTStmtReader::VisitOMPTargetTeamsDistributeSimdDirective(
2684 OMPTargetTeamsDistributeSimdDirective
*D
) {
2685 VisitOMPLoopDirective(D
);
2688 void ASTStmtReader::VisitOMPInteropDirective(OMPInteropDirective
*D
) {
2690 VisitOMPExecutableDirective(D
);
2693 void ASTStmtReader::VisitOMPDispatchDirective(OMPDispatchDirective
*D
) {
2695 VisitOMPExecutableDirective(D
);
2696 D
->setTargetCallLoc(Record
.readSourceLocation());
2699 void ASTStmtReader::VisitOMPMaskedDirective(OMPMaskedDirective
*D
) {
2701 VisitOMPExecutableDirective(D
);
2704 void ASTStmtReader::VisitOMPGenericLoopDirective(OMPGenericLoopDirective
*D
) {
2705 VisitOMPLoopDirective(D
);
2708 void ASTStmtReader::VisitOMPTeamsGenericLoopDirective(
2709 OMPTeamsGenericLoopDirective
*D
) {
2710 VisitOMPLoopDirective(D
);
2713 void ASTStmtReader::VisitOMPTargetTeamsGenericLoopDirective(
2714 OMPTargetTeamsGenericLoopDirective
*D
) {
2715 VisitOMPLoopDirective(D
);
2718 void ASTStmtReader::VisitOMPParallelGenericLoopDirective(
2719 OMPParallelGenericLoopDirective
*D
) {
2720 VisitOMPLoopDirective(D
);
2723 void ASTStmtReader::VisitOMPTargetParallelGenericLoopDirective(
2724 OMPTargetParallelGenericLoopDirective
*D
) {
2725 VisitOMPLoopDirective(D
);
2728 //===----------------------------------------------------------------------===//
2729 // ASTReader Implementation
2730 //===----------------------------------------------------------------------===//
2732 Stmt
*ASTReader::ReadStmt(ModuleFile
&F
) {
2733 switch (ReadingKind
) {
2735 llvm_unreachable("should not call this when not reading anything");
2738 return ReadStmtFromStream(F
);
2740 return ReadSubStmt();
2743 llvm_unreachable("ReadingKind not set ?");
2746 Expr
*ASTReader::ReadExpr(ModuleFile
&F
) {
2747 return cast_or_null
<Expr
>(ReadStmt(F
));
2750 Expr
*ASTReader::ReadSubExpr() {
2751 return cast_or_null
<Expr
>(ReadSubStmt());
2754 // Within the bitstream, expressions are stored in Reverse Polish
2755 // Notation, with each of the subexpressions preceding the
2756 // expression they are stored in. Subexpressions are stored from last to first.
2757 // To evaluate expressions, we continue reading expressions and placing them on
2758 // the stack, with expressions having operands removing those operands from the
2759 // stack. Evaluation terminates when we see a STMT_STOP record, and
2760 // the single remaining expression on the stack is our result.
2761 Stmt
*ASTReader::ReadStmtFromStream(ModuleFile
&F
) {
2762 ReadingKindTracker
ReadingKind(Read_Stmt
, *this);
2763 llvm::BitstreamCursor
&Cursor
= F
.DeclsCursor
;
2765 // Map of offset to previously deserialized stmt. The offset points
2766 // just after the stmt record.
2767 llvm::DenseMap
<uint64_t, Stmt
*> StmtEntries
;
2770 unsigned PrevNumStmts
= StmtStack
.size();
2773 ASTRecordReader
Record(*this, F
);
2774 ASTStmtReader
Reader(Record
, Cursor
);
2775 Stmt::EmptyShell Empty
;
2778 llvm::Expected
<llvm::BitstreamEntry
> MaybeEntry
=
2779 Cursor
.advanceSkippingSubblocks();
2781 Error(toString(MaybeEntry
.takeError()));
2784 llvm::BitstreamEntry Entry
= MaybeEntry
.get();
2786 switch (Entry
.Kind
) {
2787 case llvm::BitstreamEntry::SubBlock
: // Handled for us already.
2788 case llvm::BitstreamEntry::Error
:
2789 Error("malformed block record in AST file");
2791 case llvm::BitstreamEntry::EndBlock
:
2793 case llvm::BitstreamEntry::Record
:
2794 // The interesting case.
2798 ASTContext
&Context
= getContext();
2800 bool Finished
= false;
2801 bool IsStmtReference
= false;
2802 Expected
<unsigned> MaybeStmtCode
= Record
.readRecord(Cursor
, Entry
.ID
);
2803 if (!MaybeStmtCode
) {
2804 Error(toString(MaybeStmtCode
.takeError()));
2807 switch ((StmtCode
)MaybeStmtCode
.get()) {
2813 IsStmtReference
= true;
2814 assert(StmtEntries
.contains(Record
[0]) &&
2815 "No stmt was recorded for this offset reference!");
2816 S
= StmtEntries
[Record
.readInt()];
2824 S
= new (Context
) NullStmt(Empty
);
2828 S
= CompoundStmt::CreateEmpty(
2829 Context
, /*NumStmts=*/Record
[ASTStmtReader::NumStmtFields
],
2830 /*HasFPFeatures=*/Record
[ASTStmtReader::NumStmtFields
+ 1]);
2834 S
= CaseStmt::CreateEmpty(
2836 /*CaseStmtIsGNURange*/ Record
[ASTStmtReader::NumStmtFields
+ 3]);
2840 S
= new (Context
) DefaultStmt(Empty
);
2844 S
= new (Context
) LabelStmt(Empty
);
2847 case STMT_ATTRIBUTED
:
2848 S
= AttributedStmt::CreateEmpty(
2850 /*NumAttrs*/Record
[ASTStmtReader::NumStmtFields
]);
2854 S
= IfStmt::CreateEmpty(
2856 /* HasElse=*/Record
[ASTStmtReader::NumStmtFields
],
2857 /* HasVar=*/Record
[ASTStmtReader::NumStmtFields
+ 1],
2858 /* HasInit=*/Record
[ASTStmtReader::NumStmtFields
+ 2]);
2862 S
= SwitchStmt::CreateEmpty(
2864 /* HasInit=*/Record
[ASTStmtReader::NumStmtFields
],
2865 /* HasVar=*/Record
[ASTStmtReader::NumStmtFields
+ 1]);
2869 S
= WhileStmt::CreateEmpty(
2871 /* HasVar=*/Record
[ASTStmtReader::NumStmtFields
]);
2875 S
= new (Context
) DoStmt(Empty
);
2879 S
= new (Context
) ForStmt(Empty
);
2883 S
= new (Context
) GotoStmt(Empty
);
2886 case STMT_INDIRECT_GOTO
:
2887 S
= new (Context
) IndirectGotoStmt(Empty
);
2891 S
= new (Context
) ContinueStmt(Empty
);
2895 S
= new (Context
) BreakStmt(Empty
);
2899 S
= ReturnStmt::CreateEmpty(
2900 Context
, /* HasNRVOCandidate=*/Record
[ASTStmtReader::NumStmtFields
]);
2904 S
= new (Context
) DeclStmt(Empty
);
2908 S
= new (Context
) GCCAsmStmt(Empty
);
2912 S
= new (Context
) MSAsmStmt(Empty
);
2916 S
= CapturedStmt::CreateDeserialized(
2917 Context
, Record
[ASTStmtReader::NumStmtFields
]);
2921 S
= ConstantExpr::CreateEmpty(
2922 Context
, static_cast<ConstantExpr::ResultStorageKind
>(
2923 /*StorageKind=*/Record
[ASTStmtReader::NumExprFields
]));
2926 case EXPR_SYCL_UNIQUE_STABLE_NAME
:
2927 S
= SYCLUniqueStableNameExpr::CreateEmpty(Context
);
2930 case EXPR_PREDEFINED
:
2931 S
= PredefinedExpr::CreateEmpty(
2933 /*HasFunctionName*/ Record
[ASTStmtReader::NumExprFields
]);
2937 S
= DeclRefExpr::CreateEmpty(
2939 /*HasQualifier=*/Record
[ASTStmtReader::NumExprFields
],
2940 /*HasFoundDecl=*/Record
[ASTStmtReader::NumExprFields
+ 1],
2941 /*HasTemplateKWAndArgsInfo=*/Record
[ASTStmtReader::NumExprFields
+ 2],
2942 /*NumTemplateArgs=*/
2943 Record
[ASTStmtReader::NumExprFields
+ 2]
2944 ? Record
[ASTStmtReader::NumExprFields
+ 7]
2948 case EXPR_INTEGER_LITERAL
:
2949 S
= IntegerLiteral::Create(Context
, Empty
);
2952 case EXPR_FIXEDPOINT_LITERAL
:
2953 S
= FixedPointLiteral::Create(Context
, Empty
);
2956 case EXPR_FLOATING_LITERAL
:
2957 S
= FloatingLiteral::Create(Context
, Empty
);
2960 case EXPR_IMAGINARY_LITERAL
:
2961 S
= new (Context
) ImaginaryLiteral(Empty
);
2964 case EXPR_STRING_LITERAL
:
2965 S
= StringLiteral::CreateEmpty(
2967 /* NumConcatenated=*/Record
[ASTStmtReader::NumExprFields
],
2968 /* Length=*/Record
[ASTStmtReader::NumExprFields
+ 1],
2969 /* CharByteWidth=*/Record
[ASTStmtReader::NumExprFields
+ 2]);
2972 case EXPR_CHARACTER_LITERAL
:
2973 S
= new (Context
) CharacterLiteral(Empty
);
2977 S
= new (Context
) ParenExpr(Empty
);
2980 case EXPR_PAREN_LIST
:
2981 S
= ParenListExpr::CreateEmpty(
2983 /* NumExprs=*/Record
[ASTStmtReader::NumExprFields
]);
2986 case EXPR_UNARY_OPERATOR
:
2987 S
= UnaryOperator::CreateEmpty(Context
,
2988 Record
[ASTStmtReader::NumExprFields
]);
2992 S
= OffsetOfExpr::CreateEmpty(Context
,
2993 Record
[ASTStmtReader::NumExprFields
],
2994 Record
[ASTStmtReader::NumExprFields
+ 1]);
2997 case EXPR_SIZEOF_ALIGN_OF
:
2998 S
= new (Context
) UnaryExprOrTypeTraitExpr(Empty
);
3001 case EXPR_ARRAY_SUBSCRIPT
:
3002 S
= new (Context
) ArraySubscriptExpr(Empty
);
3005 case EXPR_MATRIX_SUBSCRIPT
:
3006 S
= new (Context
) MatrixSubscriptExpr(Empty
);
3009 case EXPR_OMP_ARRAY_SECTION
:
3010 S
= new (Context
) OMPArraySectionExpr(Empty
);
3013 case EXPR_OMP_ARRAY_SHAPING
:
3014 S
= OMPArrayShapingExpr::CreateEmpty(
3015 Context
, Record
[ASTStmtReader::NumExprFields
]);
3018 case EXPR_OMP_ITERATOR
:
3019 S
= OMPIteratorExpr::CreateEmpty(Context
,
3020 Record
[ASTStmtReader::NumExprFields
]);
3024 S
= CallExpr::CreateEmpty(
3025 Context
, /*NumArgs=*/Record
[ASTStmtReader::NumExprFields
],
3026 /*HasFPFeatures=*/Record
[ASTStmtReader::NumExprFields
+ 1], Empty
);
3030 S
= RecoveryExpr::CreateEmpty(
3031 Context
, /*NumArgs=*/Record
[ASTStmtReader::NumExprFields
]);
3035 S
= MemberExpr::CreateEmpty(Context
, Record
[ASTStmtReader::NumExprFields
],
3036 Record
[ASTStmtReader::NumExprFields
+ 1],
3037 Record
[ASTStmtReader::NumExprFields
+ 2],
3038 Record
[ASTStmtReader::NumExprFields
+ 3]);
3041 case EXPR_BINARY_OPERATOR
:
3042 S
= BinaryOperator::CreateEmpty(Context
,
3043 Record
[ASTStmtReader::NumExprFields
]);
3046 case EXPR_COMPOUND_ASSIGN_OPERATOR
:
3047 S
= CompoundAssignOperator::CreateEmpty(
3048 Context
, Record
[ASTStmtReader::NumExprFields
]);
3051 case EXPR_CONDITIONAL_OPERATOR
:
3052 S
= new (Context
) ConditionalOperator(Empty
);
3055 case EXPR_BINARY_CONDITIONAL_OPERATOR
:
3056 S
= new (Context
) BinaryConditionalOperator(Empty
);
3059 case EXPR_IMPLICIT_CAST
:
3060 S
= ImplicitCastExpr::CreateEmpty(
3062 /*PathSize*/ Record
[ASTStmtReader::NumExprFields
],
3063 /*HasFPFeatures*/ Record
[ASTStmtReader::NumExprFields
+ 1]);
3066 case EXPR_CSTYLE_CAST
:
3067 S
= CStyleCastExpr::CreateEmpty(
3069 /*PathSize*/ Record
[ASTStmtReader::NumExprFields
],
3070 /*HasFPFeatures*/ Record
[ASTStmtReader::NumExprFields
+ 1]);
3073 case EXPR_COMPOUND_LITERAL
:
3074 S
= new (Context
) CompoundLiteralExpr(Empty
);
3077 case EXPR_EXT_VECTOR_ELEMENT
:
3078 S
= new (Context
) ExtVectorElementExpr(Empty
);
3081 case EXPR_INIT_LIST
:
3082 S
= new (Context
) InitListExpr(Empty
);
3085 case EXPR_DESIGNATED_INIT
:
3086 S
= DesignatedInitExpr::CreateEmpty(Context
,
3087 Record
[ASTStmtReader::NumExprFields
] - 1);
3091 case EXPR_DESIGNATED_INIT_UPDATE
:
3092 S
= new (Context
) DesignatedInitUpdateExpr(Empty
);
3095 case EXPR_IMPLICIT_VALUE_INIT
:
3096 S
= new (Context
) ImplicitValueInitExpr(Empty
);
3100 S
= new (Context
) NoInitExpr(Empty
);
3103 case EXPR_ARRAY_INIT_LOOP
:
3104 S
= new (Context
) ArrayInitLoopExpr(Empty
);
3107 case EXPR_ARRAY_INIT_INDEX
:
3108 S
= new (Context
) ArrayInitIndexExpr(Empty
);
3112 S
= new (Context
) VAArgExpr(Empty
);
3115 case EXPR_SOURCE_LOC
:
3116 S
= new (Context
) SourceLocExpr(Empty
);
3119 case EXPR_ADDR_LABEL
:
3120 S
= new (Context
) AddrLabelExpr(Empty
);
3124 S
= new (Context
) StmtExpr(Empty
);
3128 S
= new (Context
) ChooseExpr(Empty
);
3132 S
= new (Context
) GNUNullExpr(Empty
);
3135 case EXPR_SHUFFLE_VECTOR
:
3136 S
= new (Context
) ShuffleVectorExpr(Empty
);
3139 case EXPR_CONVERT_VECTOR
:
3140 S
= new (Context
) ConvertVectorExpr(Empty
);
3144 S
= new (Context
) BlockExpr(Empty
);
3147 case EXPR_GENERIC_SELECTION
:
3148 S
= GenericSelectionExpr::CreateEmpty(
3150 /*NumAssocs=*/Record
[ASTStmtReader::NumExprFields
]);
3153 case EXPR_OBJC_STRING_LITERAL
:
3154 S
= new (Context
) ObjCStringLiteral(Empty
);
3157 case EXPR_OBJC_BOXED_EXPRESSION
:
3158 S
= new (Context
) ObjCBoxedExpr(Empty
);
3161 case EXPR_OBJC_ARRAY_LITERAL
:
3162 S
= ObjCArrayLiteral::CreateEmpty(Context
,
3163 Record
[ASTStmtReader::NumExprFields
]);
3166 case EXPR_OBJC_DICTIONARY_LITERAL
:
3167 S
= ObjCDictionaryLiteral::CreateEmpty(Context
,
3168 Record
[ASTStmtReader::NumExprFields
],
3169 Record
[ASTStmtReader::NumExprFields
+ 1]);
3172 case EXPR_OBJC_ENCODE
:
3173 S
= new (Context
) ObjCEncodeExpr(Empty
);
3176 case EXPR_OBJC_SELECTOR_EXPR
:
3177 S
= new (Context
) ObjCSelectorExpr(Empty
);
3180 case EXPR_OBJC_PROTOCOL_EXPR
:
3181 S
= new (Context
) ObjCProtocolExpr(Empty
);
3184 case EXPR_OBJC_IVAR_REF_EXPR
:
3185 S
= new (Context
) ObjCIvarRefExpr(Empty
);
3188 case EXPR_OBJC_PROPERTY_REF_EXPR
:
3189 S
= new (Context
) ObjCPropertyRefExpr(Empty
);
3192 case EXPR_OBJC_SUBSCRIPT_REF_EXPR
:
3193 S
= new (Context
) ObjCSubscriptRefExpr(Empty
);
3196 case EXPR_OBJC_KVC_REF_EXPR
:
3197 llvm_unreachable("mismatching AST file");
3199 case EXPR_OBJC_MESSAGE_EXPR
:
3200 S
= ObjCMessageExpr::CreateEmpty(Context
,
3201 Record
[ASTStmtReader::NumExprFields
],
3202 Record
[ASTStmtReader::NumExprFields
+ 1]);
3206 S
= new (Context
) ObjCIsaExpr(Empty
);
3209 case EXPR_OBJC_INDIRECT_COPY_RESTORE
:
3210 S
= new (Context
) ObjCIndirectCopyRestoreExpr(Empty
);
3213 case EXPR_OBJC_BRIDGED_CAST
:
3214 S
= new (Context
) ObjCBridgedCastExpr(Empty
);
3217 case STMT_OBJC_FOR_COLLECTION
:
3218 S
= new (Context
) ObjCForCollectionStmt(Empty
);
3221 case STMT_OBJC_CATCH
:
3222 S
= new (Context
) ObjCAtCatchStmt(Empty
);
3225 case STMT_OBJC_FINALLY
:
3226 S
= new (Context
) ObjCAtFinallyStmt(Empty
);
3229 case STMT_OBJC_AT_TRY
:
3230 S
= ObjCAtTryStmt::CreateEmpty(Context
,
3231 Record
[ASTStmtReader::NumStmtFields
],
3232 Record
[ASTStmtReader::NumStmtFields
+ 1]);
3235 case STMT_OBJC_AT_SYNCHRONIZED
:
3236 S
= new (Context
) ObjCAtSynchronizedStmt(Empty
);
3239 case STMT_OBJC_AT_THROW
:
3240 S
= new (Context
) ObjCAtThrowStmt(Empty
);
3243 case STMT_OBJC_AUTORELEASE_POOL
:
3244 S
= new (Context
) ObjCAutoreleasePoolStmt(Empty
);
3247 case EXPR_OBJC_BOOL_LITERAL
:
3248 S
= new (Context
) ObjCBoolLiteralExpr(Empty
);
3251 case EXPR_OBJC_AVAILABILITY_CHECK
:
3252 S
= new (Context
) ObjCAvailabilityCheckExpr(Empty
);
3255 case STMT_SEH_LEAVE
:
3256 S
= new (Context
) SEHLeaveStmt(Empty
);
3259 case STMT_SEH_EXCEPT
:
3260 S
= new (Context
) SEHExceptStmt(Empty
);
3263 case STMT_SEH_FINALLY
:
3264 S
= new (Context
) SEHFinallyStmt(Empty
);
3268 S
= new (Context
) SEHTryStmt(Empty
);
3271 case STMT_CXX_CATCH
:
3272 S
= new (Context
) CXXCatchStmt(Empty
);
3276 S
= CXXTryStmt::Create(Context
, Empty
,
3277 /*numHandlers=*/Record
[ASTStmtReader::NumStmtFields
]);
3280 case STMT_CXX_FOR_RANGE
:
3281 S
= new (Context
) CXXForRangeStmt(Empty
);
3284 case STMT_MS_DEPENDENT_EXISTS
:
3285 S
= new (Context
) MSDependentExistsStmt(SourceLocation(), true,
3286 NestedNameSpecifierLoc(),
3287 DeclarationNameInfo(),
3291 case STMT_OMP_CANONICAL_LOOP
:
3292 S
= OMPCanonicalLoop::createEmpty(Context
);
3295 case STMT_OMP_META_DIRECTIVE
:
3296 S
= OMPMetaDirective::CreateEmpty(
3297 Context
, Record
[ASTStmtReader::NumStmtFields
], Empty
);
3300 case STMT_OMP_PARALLEL_DIRECTIVE
:
3302 OMPParallelDirective::CreateEmpty(Context
,
3303 Record
[ASTStmtReader::NumStmtFields
],
3307 case STMT_OMP_SIMD_DIRECTIVE
: {
3308 unsigned CollapsedNum
= Record
[ASTStmtReader::NumStmtFields
];
3309 unsigned NumClauses
= Record
[ASTStmtReader::NumStmtFields
+ 1];
3310 S
= OMPSimdDirective::CreateEmpty(Context
, NumClauses
,
3311 CollapsedNum
, Empty
);
3315 case STMT_OMP_TILE_DIRECTIVE
: {
3316 unsigned NumLoops
= Record
[ASTStmtReader::NumStmtFields
];
3317 unsigned NumClauses
= Record
[ASTStmtReader::NumStmtFields
+ 1];
3318 S
= OMPTileDirective::CreateEmpty(Context
, NumClauses
, NumLoops
);
3322 case STMT_OMP_UNROLL_DIRECTIVE
: {
3323 assert(Record
[ASTStmtReader::NumStmtFields
] == 1 && "Unroll directive accepts only a single loop");
3324 unsigned NumClauses
= Record
[ASTStmtReader::NumStmtFields
+ 1];
3325 S
= OMPUnrollDirective::CreateEmpty(Context
, NumClauses
);
3329 case STMT_OMP_FOR_DIRECTIVE
: {
3330 unsigned CollapsedNum
= Record
[ASTStmtReader::NumStmtFields
];
3331 unsigned NumClauses
= Record
[ASTStmtReader::NumStmtFields
+ 1];
3332 S
= OMPForDirective::CreateEmpty(Context
, NumClauses
, CollapsedNum
,
3337 case STMT_OMP_FOR_SIMD_DIRECTIVE
: {
3338 unsigned CollapsedNum
= Record
[ASTStmtReader::NumStmtFields
];
3339 unsigned NumClauses
= Record
[ASTStmtReader::NumStmtFields
+ 1];
3340 S
= OMPForSimdDirective::CreateEmpty(Context
, NumClauses
, CollapsedNum
,
3345 case STMT_OMP_SECTIONS_DIRECTIVE
:
3346 S
= OMPSectionsDirective::CreateEmpty(
3347 Context
, Record
[ASTStmtReader::NumStmtFields
], Empty
);
3350 case STMT_OMP_SECTION_DIRECTIVE
:
3351 S
= OMPSectionDirective::CreateEmpty(Context
, Empty
);
3354 case STMT_OMP_SINGLE_DIRECTIVE
:
3355 S
= OMPSingleDirective::CreateEmpty(
3356 Context
, Record
[ASTStmtReader::NumStmtFields
], Empty
);
3359 case STMT_OMP_MASTER_DIRECTIVE
:
3360 S
= OMPMasterDirective::CreateEmpty(Context
, Empty
);
3363 case STMT_OMP_CRITICAL_DIRECTIVE
:
3364 S
= OMPCriticalDirective::CreateEmpty(
3365 Context
, Record
[ASTStmtReader::NumStmtFields
], Empty
);
3368 case STMT_OMP_PARALLEL_FOR_DIRECTIVE
: {
3369 unsigned CollapsedNum
= Record
[ASTStmtReader::NumStmtFields
];
3370 unsigned NumClauses
= Record
[ASTStmtReader::NumStmtFields
+ 1];
3371 S
= OMPParallelForDirective::CreateEmpty(Context
, NumClauses
,
3372 CollapsedNum
, Empty
);
3376 case STMT_OMP_PARALLEL_FOR_SIMD_DIRECTIVE
: {
3377 unsigned CollapsedNum
= Record
[ASTStmtReader::NumStmtFields
];
3378 unsigned NumClauses
= Record
[ASTStmtReader::NumStmtFields
+ 1];
3379 S
= OMPParallelForSimdDirective::CreateEmpty(Context
, NumClauses
,
3380 CollapsedNum
, Empty
);
3384 case STMT_OMP_PARALLEL_MASTER_DIRECTIVE
:
3385 S
= OMPParallelMasterDirective::CreateEmpty(
3386 Context
, Record
[ASTStmtReader::NumStmtFields
], Empty
);
3389 case STMT_OMP_PARALLEL_MASKED_DIRECTIVE
:
3390 S
= OMPParallelMaskedDirective::CreateEmpty(
3391 Context
, Record
[ASTStmtReader::NumStmtFields
], Empty
);
3394 case STMT_OMP_PARALLEL_SECTIONS_DIRECTIVE
:
3395 S
= OMPParallelSectionsDirective::CreateEmpty(
3396 Context
, Record
[ASTStmtReader::NumStmtFields
], Empty
);
3399 case STMT_OMP_TASK_DIRECTIVE
:
3400 S
= OMPTaskDirective::CreateEmpty(
3401 Context
, Record
[ASTStmtReader::NumStmtFields
], Empty
);
3404 case STMT_OMP_TASKYIELD_DIRECTIVE
:
3405 S
= OMPTaskyieldDirective::CreateEmpty(Context
, Empty
);
3408 case STMT_OMP_BARRIER_DIRECTIVE
:
3409 S
= OMPBarrierDirective::CreateEmpty(Context
, Empty
);
3412 case STMT_OMP_TASKWAIT_DIRECTIVE
:
3413 S
= OMPTaskwaitDirective::CreateEmpty(
3414 Context
, Record
[ASTStmtReader::NumStmtFields
], Empty
);
3417 case STMT_OMP_ERROR_DIRECTIVE
:
3418 S
= OMPErrorDirective::CreateEmpty(
3419 Context
, Record
[ASTStmtReader::NumStmtFields
], Empty
);
3422 case STMT_OMP_TASKGROUP_DIRECTIVE
:
3423 S
= OMPTaskgroupDirective::CreateEmpty(
3424 Context
, Record
[ASTStmtReader::NumStmtFields
], Empty
);
3427 case STMT_OMP_FLUSH_DIRECTIVE
:
3428 S
= OMPFlushDirective::CreateEmpty(
3429 Context
, Record
[ASTStmtReader::NumStmtFields
], Empty
);
3432 case STMT_OMP_DEPOBJ_DIRECTIVE
:
3433 S
= OMPDepobjDirective::CreateEmpty(
3434 Context
, Record
[ASTStmtReader::NumStmtFields
], Empty
);
3437 case STMT_OMP_SCAN_DIRECTIVE
:
3438 S
= OMPScanDirective::CreateEmpty(
3439 Context
, Record
[ASTStmtReader::NumStmtFields
], Empty
);
3442 case STMT_OMP_ORDERED_DIRECTIVE
: {
3443 unsigned NumClauses
= Record
[ASTStmtReader::NumStmtFields
];
3444 bool HasAssociatedStmt
= Record
[ASTStmtReader::NumStmtFields
+ 2];
3445 S
= OMPOrderedDirective::CreateEmpty(Context
, NumClauses
,
3446 !HasAssociatedStmt
, Empty
);
3450 case STMT_OMP_ATOMIC_DIRECTIVE
:
3451 S
= OMPAtomicDirective::CreateEmpty(
3452 Context
, Record
[ASTStmtReader::NumStmtFields
], Empty
);
3455 case STMT_OMP_TARGET_DIRECTIVE
:
3456 S
= OMPTargetDirective::CreateEmpty(
3457 Context
, Record
[ASTStmtReader::NumStmtFields
], Empty
);
3460 case STMT_OMP_TARGET_DATA_DIRECTIVE
:
3461 S
= OMPTargetDataDirective::CreateEmpty(
3462 Context
, Record
[ASTStmtReader::NumStmtFields
], Empty
);
3465 case STMT_OMP_TARGET_ENTER_DATA_DIRECTIVE
:
3466 S
= OMPTargetEnterDataDirective::CreateEmpty(
3467 Context
, Record
[ASTStmtReader::NumStmtFields
], Empty
);
3470 case STMT_OMP_TARGET_EXIT_DATA_DIRECTIVE
:
3471 S
= OMPTargetExitDataDirective::CreateEmpty(
3472 Context
, Record
[ASTStmtReader::NumStmtFields
], Empty
);
3475 case STMT_OMP_TARGET_PARALLEL_DIRECTIVE
:
3476 S
= OMPTargetParallelDirective::CreateEmpty(
3477 Context
, Record
[ASTStmtReader::NumStmtFields
], Empty
);
3480 case STMT_OMP_TARGET_PARALLEL_FOR_DIRECTIVE
: {
3481 unsigned CollapsedNum
= Record
[ASTStmtReader::NumStmtFields
];
3482 unsigned NumClauses
= Record
[ASTStmtReader::NumStmtFields
+ 1];
3483 S
= OMPTargetParallelForDirective::CreateEmpty(Context
, NumClauses
,
3484 CollapsedNum
, Empty
);
3488 case STMT_OMP_TARGET_UPDATE_DIRECTIVE
:
3489 S
= OMPTargetUpdateDirective::CreateEmpty(
3490 Context
, Record
[ASTStmtReader::NumStmtFields
], Empty
);
3493 case STMT_OMP_TEAMS_DIRECTIVE
:
3494 S
= OMPTeamsDirective::CreateEmpty(
3495 Context
, Record
[ASTStmtReader::NumStmtFields
], Empty
);
3498 case STMT_OMP_CANCELLATION_POINT_DIRECTIVE
:
3499 S
= OMPCancellationPointDirective::CreateEmpty(Context
, Empty
);
3502 case STMT_OMP_CANCEL_DIRECTIVE
:
3503 S
= OMPCancelDirective::CreateEmpty(
3504 Context
, Record
[ASTStmtReader::NumStmtFields
], Empty
);
3507 case STMT_OMP_TASKLOOP_DIRECTIVE
: {
3508 unsigned CollapsedNum
= Record
[ASTStmtReader::NumStmtFields
];
3509 unsigned NumClauses
= Record
[ASTStmtReader::NumStmtFields
+ 1];
3510 S
= OMPTaskLoopDirective::CreateEmpty(Context
, NumClauses
, CollapsedNum
,
3515 case STMT_OMP_TASKLOOP_SIMD_DIRECTIVE
: {
3516 unsigned CollapsedNum
= Record
[ASTStmtReader::NumStmtFields
];
3517 unsigned NumClauses
= Record
[ASTStmtReader::NumStmtFields
+ 1];
3518 S
= OMPTaskLoopSimdDirective::CreateEmpty(Context
, NumClauses
,
3519 CollapsedNum
, Empty
);
3523 case STMT_OMP_MASTER_TASKLOOP_DIRECTIVE
: {
3524 unsigned CollapsedNum
= Record
[ASTStmtReader::NumStmtFields
];
3525 unsigned NumClauses
= Record
[ASTStmtReader::NumStmtFields
+ 1];
3526 S
= OMPMasterTaskLoopDirective::CreateEmpty(Context
, NumClauses
,
3527 CollapsedNum
, Empty
);
3531 case STMT_OMP_MASKED_TASKLOOP_DIRECTIVE
: {
3532 unsigned CollapsedNum
= Record
[ASTStmtReader::NumStmtFields
];
3533 unsigned NumClauses
= Record
[ASTStmtReader::NumStmtFields
+ 1];
3534 S
= OMPMaskedTaskLoopDirective::CreateEmpty(Context
, NumClauses
,
3535 CollapsedNum
, Empty
);
3539 case STMT_OMP_MASTER_TASKLOOP_SIMD_DIRECTIVE
: {
3540 unsigned CollapsedNum
= Record
[ASTStmtReader::NumStmtFields
];
3541 unsigned NumClauses
= Record
[ASTStmtReader::NumStmtFields
+ 1];
3542 S
= OMPMasterTaskLoopSimdDirective::CreateEmpty(Context
, NumClauses
,
3543 CollapsedNum
, Empty
);
3547 case STMT_OMP_MASKED_TASKLOOP_SIMD_DIRECTIVE
: {
3548 unsigned CollapsedNum
= Record
[ASTStmtReader::NumStmtFields
];
3549 unsigned NumClauses
= Record
[ASTStmtReader::NumStmtFields
+ 1];
3550 S
= OMPMaskedTaskLoopSimdDirective::CreateEmpty(Context
, NumClauses
,
3551 CollapsedNum
, Empty
);
3555 case STMT_OMP_PARALLEL_MASTER_TASKLOOP_DIRECTIVE
: {
3556 unsigned CollapsedNum
= Record
[ASTStmtReader::NumStmtFields
];
3557 unsigned NumClauses
= Record
[ASTStmtReader::NumStmtFields
+ 1];
3558 S
= OMPParallelMasterTaskLoopDirective::CreateEmpty(Context
, NumClauses
,
3559 CollapsedNum
, Empty
);
3563 case STMT_OMP_PARALLEL_MASKED_TASKLOOP_DIRECTIVE
: {
3564 unsigned CollapsedNum
= Record
[ASTStmtReader::NumStmtFields
];
3565 unsigned NumClauses
= Record
[ASTStmtReader::NumStmtFields
+ 1];
3566 S
= OMPParallelMaskedTaskLoopDirective::CreateEmpty(Context
, NumClauses
,
3567 CollapsedNum
, Empty
);
3571 case STMT_OMP_PARALLEL_MASTER_TASKLOOP_SIMD_DIRECTIVE
: {
3572 unsigned CollapsedNum
= Record
[ASTStmtReader::NumStmtFields
];
3573 unsigned NumClauses
= Record
[ASTStmtReader::NumStmtFields
+ 1];
3574 S
= OMPParallelMasterTaskLoopSimdDirective::CreateEmpty(
3575 Context
, NumClauses
, CollapsedNum
, Empty
);
3579 case STMT_OMP_PARALLEL_MASKED_TASKLOOP_SIMD_DIRECTIVE
: {
3580 unsigned CollapsedNum
= Record
[ASTStmtReader::NumStmtFields
];
3581 unsigned NumClauses
= Record
[ASTStmtReader::NumStmtFields
+ 1];
3582 S
= OMPParallelMaskedTaskLoopSimdDirective::CreateEmpty(
3583 Context
, NumClauses
, CollapsedNum
, Empty
);
3587 case STMT_OMP_DISTRIBUTE_DIRECTIVE
: {
3588 unsigned CollapsedNum
= Record
[ASTStmtReader::NumStmtFields
];
3589 unsigned NumClauses
= Record
[ASTStmtReader::NumStmtFields
+ 1];
3590 S
= OMPDistributeDirective::CreateEmpty(Context
, NumClauses
, CollapsedNum
,
3595 case STMT_OMP_DISTRIBUTE_PARALLEL_FOR_DIRECTIVE
: {
3596 unsigned CollapsedNum
= Record
[ASTStmtReader::NumStmtFields
];
3597 unsigned NumClauses
= Record
[ASTStmtReader::NumStmtFields
+ 1];
3598 S
= OMPDistributeParallelForDirective::CreateEmpty(Context
, NumClauses
,
3599 CollapsedNum
, Empty
);
3603 case STMT_OMP_DISTRIBUTE_PARALLEL_FOR_SIMD_DIRECTIVE
: {
3604 unsigned CollapsedNum
= Record
[ASTStmtReader::NumStmtFields
];
3605 unsigned NumClauses
= Record
[ASTStmtReader::NumStmtFields
+ 1];
3606 S
= OMPDistributeParallelForSimdDirective::CreateEmpty(Context
, NumClauses
,
3612 case STMT_OMP_DISTRIBUTE_SIMD_DIRECTIVE
: {
3613 unsigned CollapsedNum
= Record
[ASTStmtReader::NumStmtFields
];
3614 unsigned NumClauses
= Record
[ASTStmtReader::NumStmtFields
+ 1];
3615 S
= OMPDistributeSimdDirective::CreateEmpty(Context
, NumClauses
,
3616 CollapsedNum
, Empty
);
3620 case STMT_OMP_TARGET_PARALLEL_FOR_SIMD_DIRECTIVE
: {
3621 unsigned CollapsedNum
= Record
[ASTStmtReader::NumStmtFields
];
3622 unsigned NumClauses
= Record
[ASTStmtReader::NumStmtFields
+ 1];
3623 S
= OMPTargetParallelForSimdDirective::CreateEmpty(Context
, NumClauses
,
3624 CollapsedNum
, Empty
);
3628 case STMT_OMP_TARGET_SIMD_DIRECTIVE
: {
3629 unsigned CollapsedNum
= Record
[ASTStmtReader::NumStmtFields
];
3630 unsigned NumClauses
= Record
[ASTStmtReader::NumStmtFields
+ 1];
3631 S
= OMPTargetSimdDirective::CreateEmpty(Context
, NumClauses
, CollapsedNum
,
3636 case STMT_OMP_TEAMS_DISTRIBUTE_DIRECTIVE
: {
3637 unsigned CollapsedNum
= Record
[ASTStmtReader::NumStmtFields
];
3638 unsigned NumClauses
= Record
[ASTStmtReader::NumStmtFields
+ 1];
3639 S
= OMPTeamsDistributeDirective::CreateEmpty(Context
, NumClauses
,
3640 CollapsedNum
, Empty
);
3644 case STMT_OMP_TEAMS_DISTRIBUTE_SIMD_DIRECTIVE
: {
3645 unsigned CollapsedNum
= Record
[ASTStmtReader::NumStmtFields
];
3646 unsigned NumClauses
= Record
[ASTStmtReader::NumStmtFields
+ 1];
3647 S
= OMPTeamsDistributeSimdDirective::CreateEmpty(Context
, NumClauses
,
3648 CollapsedNum
, Empty
);
3652 case STMT_OMP_TEAMS_DISTRIBUTE_PARALLEL_FOR_SIMD_DIRECTIVE
: {
3653 unsigned CollapsedNum
= Record
[ASTStmtReader::NumStmtFields
];
3654 unsigned NumClauses
= Record
[ASTStmtReader::NumStmtFields
+ 1];
3655 S
= OMPTeamsDistributeParallelForSimdDirective::CreateEmpty(
3656 Context
, NumClauses
, CollapsedNum
, Empty
);
3660 case STMT_OMP_TEAMS_DISTRIBUTE_PARALLEL_FOR_DIRECTIVE
: {
3661 unsigned CollapsedNum
= Record
[ASTStmtReader::NumStmtFields
];
3662 unsigned NumClauses
= Record
[ASTStmtReader::NumStmtFields
+ 1];
3663 S
= OMPTeamsDistributeParallelForDirective::CreateEmpty(
3664 Context
, NumClauses
, CollapsedNum
, Empty
);
3668 case STMT_OMP_TARGET_TEAMS_DIRECTIVE
:
3669 S
= OMPTargetTeamsDirective::CreateEmpty(
3670 Context
, Record
[ASTStmtReader::NumStmtFields
], Empty
);
3673 case STMT_OMP_TARGET_TEAMS_DISTRIBUTE_DIRECTIVE
: {
3674 unsigned CollapsedNum
= Record
[ASTStmtReader::NumStmtFields
];
3675 unsigned NumClauses
= Record
[ASTStmtReader::NumStmtFields
+ 1];
3676 S
= OMPTargetTeamsDistributeDirective::CreateEmpty(Context
, NumClauses
,
3677 CollapsedNum
, Empty
);
3681 case STMT_OMP_TARGET_TEAMS_DISTRIBUTE_PARALLEL_FOR_DIRECTIVE
: {
3682 unsigned CollapsedNum
= Record
[ASTStmtReader::NumStmtFields
];
3683 unsigned NumClauses
= Record
[ASTStmtReader::NumStmtFields
+ 1];
3684 S
= OMPTargetTeamsDistributeParallelForDirective::CreateEmpty(
3685 Context
, NumClauses
, CollapsedNum
, Empty
);
3689 case STMT_OMP_TARGET_TEAMS_DISTRIBUTE_PARALLEL_FOR_SIMD_DIRECTIVE
: {
3690 unsigned CollapsedNum
= Record
[ASTStmtReader::NumStmtFields
];
3691 unsigned NumClauses
= Record
[ASTStmtReader::NumStmtFields
+ 1];
3692 S
= OMPTargetTeamsDistributeParallelForSimdDirective::CreateEmpty(
3693 Context
, NumClauses
, CollapsedNum
, Empty
);
3697 case STMT_OMP_TARGET_TEAMS_DISTRIBUTE_SIMD_DIRECTIVE
: {
3698 unsigned CollapsedNum
= Record
[ASTStmtReader::NumStmtFields
];
3699 unsigned NumClauses
= Record
[ASTStmtReader::NumStmtFields
+ 1];
3700 S
= OMPTargetTeamsDistributeSimdDirective::CreateEmpty(
3701 Context
, NumClauses
, CollapsedNum
, Empty
);
3705 case STMT_OMP_INTEROP_DIRECTIVE
:
3706 S
= OMPInteropDirective::CreateEmpty(
3707 Context
, Record
[ASTStmtReader::NumStmtFields
], Empty
);
3710 case STMT_OMP_DISPATCH_DIRECTIVE
:
3711 S
= OMPDispatchDirective::CreateEmpty(
3712 Context
, Record
[ASTStmtReader::NumStmtFields
], Empty
);
3715 case STMT_OMP_MASKED_DIRECTIVE
:
3716 S
= OMPMaskedDirective::CreateEmpty(
3717 Context
, Record
[ASTStmtReader::NumStmtFields
], Empty
);
3720 case STMT_OMP_GENERIC_LOOP_DIRECTIVE
: {
3721 unsigned CollapsedNum
= Record
[ASTStmtReader::NumStmtFields
];
3722 unsigned NumClauses
= Record
[ASTStmtReader::NumStmtFields
+ 1];
3723 S
= OMPGenericLoopDirective::CreateEmpty(Context
, NumClauses
,
3724 CollapsedNum
, Empty
);
3728 case STMT_OMP_TEAMS_GENERIC_LOOP_DIRECTIVE
: {
3729 unsigned CollapsedNum
= Record
[ASTStmtReader::NumStmtFields
];
3730 unsigned NumClauses
= Record
[ASTStmtReader::NumStmtFields
+ 1];
3731 S
= OMPTeamsGenericLoopDirective::CreateEmpty(Context
, NumClauses
,
3732 CollapsedNum
, Empty
);
3736 case STMT_OMP_TARGET_TEAMS_GENERIC_LOOP_DIRECTIVE
: {
3737 unsigned CollapsedNum
= Record
[ASTStmtReader::NumStmtFields
];
3738 unsigned NumClauses
= Record
[ASTStmtReader::NumStmtFields
+ 1];
3739 S
= OMPTargetTeamsGenericLoopDirective::CreateEmpty(Context
, NumClauses
,
3740 CollapsedNum
, Empty
);
3744 case STMT_OMP_PARALLEL_GENERIC_LOOP_DIRECTIVE
: {
3745 unsigned CollapsedNum
= Record
[ASTStmtReader::NumStmtFields
];
3746 unsigned NumClauses
= Record
[ASTStmtReader::NumStmtFields
+ 1];
3747 S
= OMPParallelGenericLoopDirective::CreateEmpty(Context
, NumClauses
,
3748 CollapsedNum
, Empty
);
3752 case STMT_OMP_TARGET_PARALLEL_GENERIC_LOOP_DIRECTIVE
: {
3753 unsigned CollapsedNum
= Record
[ASTStmtReader::NumStmtFields
];
3754 unsigned NumClauses
= Record
[ASTStmtReader::NumStmtFields
+ 1];
3755 S
= OMPTargetParallelGenericLoopDirective::CreateEmpty(
3756 Context
, NumClauses
, CollapsedNum
, Empty
);
3760 case EXPR_CXX_OPERATOR_CALL
:
3761 S
= CXXOperatorCallExpr::CreateEmpty(
3762 Context
, /*NumArgs=*/Record
[ASTStmtReader::NumExprFields
],
3763 /*HasFPFeatures=*/Record
[ASTStmtReader::NumExprFields
+ 1], Empty
);
3766 case EXPR_CXX_MEMBER_CALL
:
3767 S
= CXXMemberCallExpr::CreateEmpty(
3768 Context
, /*NumArgs=*/Record
[ASTStmtReader::NumExprFields
],
3769 /*HasFPFeatures=*/Record
[ASTStmtReader::NumExprFields
+ 1], Empty
);
3772 case EXPR_CXX_REWRITTEN_BINARY_OPERATOR
:
3773 S
= new (Context
) CXXRewrittenBinaryOperator(Empty
);
3776 case EXPR_CXX_CONSTRUCT
:
3777 S
= CXXConstructExpr::CreateEmpty(
3779 /* NumArgs=*/Record
[ASTStmtReader::NumExprFields
]);
3782 case EXPR_CXX_INHERITED_CTOR_INIT
:
3783 S
= new (Context
) CXXInheritedCtorInitExpr(Empty
);
3786 case EXPR_CXX_TEMPORARY_OBJECT
:
3787 S
= CXXTemporaryObjectExpr::CreateEmpty(
3789 /* NumArgs=*/Record
[ASTStmtReader::NumExprFields
]);
3792 case EXPR_CXX_STATIC_CAST
:
3793 S
= CXXStaticCastExpr::CreateEmpty(
3795 /*PathSize*/ Record
[ASTStmtReader::NumExprFields
],
3796 /*HasFPFeatures*/ Record
[ASTStmtReader::NumExprFields
+ 1]);
3799 case EXPR_CXX_DYNAMIC_CAST
:
3800 S
= CXXDynamicCastExpr::CreateEmpty(Context
,
3801 /*PathSize*/ Record
[ASTStmtReader::NumExprFields
]);
3804 case EXPR_CXX_REINTERPRET_CAST
:
3805 S
= CXXReinterpretCastExpr::CreateEmpty(Context
,
3806 /*PathSize*/ Record
[ASTStmtReader::NumExprFields
]);
3809 case EXPR_CXX_CONST_CAST
:
3810 S
= CXXConstCastExpr::CreateEmpty(Context
);
3813 case EXPR_CXX_ADDRSPACE_CAST
:
3814 S
= CXXAddrspaceCastExpr::CreateEmpty(Context
);
3817 case EXPR_CXX_FUNCTIONAL_CAST
:
3818 S
= CXXFunctionalCastExpr::CreateEmpty(
3820 /*PathSize*/ Record
[ASTStmtReader::NumExprFields
],
3821 /*HasFPFeatures*/ Record
[ASTStmtReader::NumExprFields
+ 1]);
3824 case EXPR_BUILTIN_BIT_CAST
:
3825 assert(Record
[ASTStmtReader::NumExprFields
] == 0 && "Wrong PathSize!");
3826 S
= new (Context
) BuiltinBitCastExpr(Empty
);
3829 case EXPR_USER_DEFINED_LITERAL
:
3830 S
= UserDefinedLiteral::CreateEmpty(
3831 Context
, /*NumArgs=*/Record
[ASTStmtReader::NumExprFields
],
3832 /*HasFPFeatures=*/Record
[ASTStmtReader::NumExprFields
+ 1], Empty
);
3835 case EXPR_CXX_STD_INITIALIZER_LIST
:
3836 S
= new (Context
) CXXStdInitializerListExpr(Empty
);
3839 case EXPR_CXX_BOOL_LITERAL
:
3840 S
= new (Context
) CXXBoolLiteralExpr(Empty
);
3843 case EXPR_CXX_NULL_PTR_LITERAL
:
3844 S
= new (Context
) CXXNullPtrLiteralExpr(Empty
);
3847 case EXPR_CXX_TYPEID_EXPR
:
3848 S
= new (Context
) CXXTypeidExpr(Empty
, true);
3851 case EXPR_CXX_TYPEID_TYPE
:
3852 S
= new (Context
) CXXTypeidExpr(Empty
, false);
3855 case EXPR_CXX_UUIDOF_EXPR
:
3856 S
= new (Context
) CXXUuidofExpr(Empty
, true);
3859 case EXPR_CXX_PROPERTY_REF_EXPR
:
3860 S
= new (Context
) MSPropertyRefExpr(Empty
);
3863 case EXPR_CXX_PROPERTY_SUBSCRIPT_EXPR
:
3864 S
= new (Context
) MSPropertySubscriptExpr(Empty
);
3867 case EXPR_CXX_UUIDOF_TYPE
:
3868 S
= new (Context
) CXXUuidofExpr(Empty
, false);
3872 S
= new (Context
) CXXThisExpr(Empty
);
3875 case EXPR_CXX_THROW
:
3876 S
= new (Context
) CXXThrowExpr(Empty
);
3879 case EXPR_CXX_DEFAULT_ARG
:
3880 S
= CXXDefaultArgExpr::CreateEmpty(
3881 Context
, /*HasRewrittenInit=*/Record
[ASTStmtReader::NumExprFields
]);
3884 case EXPR_CXX_DEFAULT_INIT
:
3885 S
= CXXDefaultInitExpr::CreateEmpty(
3886 Context
, /*HasRewrittenInit=*/Record
[ASTStmtReader::NumExprFields
]);
3889 case EXPR_CXX_BIND_TEMPORARY
:
3890 S
= new (Context
) CXXBindTemporaryExpr(Empty
);
3893 case EXPR_CXX_SCALAR_VALUE_INIT
:
3894 S
= new (Context
) CXXScalarValueInitExpr(Empty
);
3898 S
= CXXNewExpr::CreateEmpty(
3900 /*IsArray=*/Record
[ASTStmtReader::NumExprFields
],
3901 /*HasInit=*/Record
[ASTStmtReader::NumExprFields
+ 1],
3902 /*NumPlacementArgs=*/Record
[ASTStmtReader::NumExprFields
+ 2],
3903 /*IsParenTypeId=*/Record
[ASTStmtReader::NumExprFields
+ 3]);
3906 case EXPR_CXX_DELETE
:
3907 S
= new (Context
) CXXDeleteExpr(Empty
);
3910 case EXPR_CXX_PSEUDO_DESTRUCTOR
:
3911 S
= new (Context
) CXXPseudoDestructorExpr(Empty
);
3914 case EXPR_EXPR_WITH_CLEANUPS
:
3915 S
= ExprWithCleanups::Create(Context
, Empty
,
3916 Record
[ASTStmtReader::NumExprFields
]);
3919 case EXPR_CXX_DEPENDENT_SCOPE_MEMBER
:
3920 S
= CXXDependentScopeMemberExpr::CreateEmpty(
3922 /*HasTemplateKWAndArgsInfo=*/Record
[ASTStmtReader::NumExprFields
],
3923 /*NumTemplateArgs=*/Record
[ASTStmtReader::NumExprFields
+ 1],
3924 /*HasFirstQualifierFoundInScope=*/
3925 Record
[ASTStmtReader::NumExprFields
+ 2]);
3928 case EXPR_CXX_DEPENDENT_SCOPE_DECL_REF
:
3929 S
= DependentScopeDeclRefExpr::CreateEmpty(Context
,
3930 /*HasTemplateKWAndArgsInfo=*/Record
[ASTStmtReader::NumExprFields
],
3931 /*NumTemplateArgs=*/Record
[ASTStmtReader::NumExprFields
]
3932 ? Record
[ASTStmtReader::NumExprFields
+ 1]
3936 case EXPR_CXX_UNRESOLVED_CONSTRUCT
:
3937 S
= CXXUnresolvedConstructExpr::CreateEmpty(Context
,
3938 /*NumArgs=*/Record
[ASTStmtReader::NumExprFields
]);
3941 case EXPR_CXX_UNRESOLVED_MEMBER
:
3942 S
= UnresolvedMemberExpr::CreateEmpty(
3944 /*NumResults=*/Record
[ASTStmtReader::NumExprFields
],
3945 /*HasTemplateKWAndArgsInfo=*/Record
[ASTStmtReader::NumExprFields
+ 1],
3946 /*NumTemplateArgs=*/
3947 Record
[ASTStmtReader::NumExprFields
+ 1]
3948 ? Record
[ASTStmtReader::NumExprFields
+ 2]
3952 case EXPR_CXX_UNRESOLVED_LOOKUP
:
3953 S
= UnresolvedLookupExpr::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_TYPE_TRAIT
:
3964 S
= TypeTraitExpr::CreateDeserialized(Context
,
3965 Record
[ASTStmtReader::NumExprFields
]);
3968 case EXPR_ARRAY_TYPE_TRAIT
:
3969 S
= new (Context
) ArrayTypeTraitExpr(Empty
);
3972 case EXPR_CXX_EXPRESSION_TRAIT
:
3973 S
= new (Context
) ExpressionTraitExpr(Empty
);
3976 case EXPR_CXX_NOEXCEPT
:
3977 S
= new (Context
) CXXNoexceptExpr(Empty
);
3980 case EXPR_PACK_EXPANSION
:
3981 S
= new (Context
) PackExpansionExpr(Empty
);
3984 case EXPR_SIZEOF_PACK
:
3985 S
= SizeOfPackExpr::CreateDeserialized(
3987 /*NumPartialArgs=*/Record
[ASTStmtReader::NumExprFields
]);
3990 case EXPR_SUBST_NON_TYPE_TEMPLATE_PARM
:
3991 S
= new (Context
) SubstNonTypeTemplateParmExpr(Empty
);
3994 case EXPR_SUBST_NON_TYPE_TEMPLATE_PARM_PACK
:
3995 S
= new (Context
) SubstNonTypeTemplateParmPackExpr(Empty
);
3998 case EXPR_FUNCTION_PARM_PACK
:
3999 S
= FunctionParmPackExpr::CreateEmpty(Context
,
4000 Record
[ASTStmtReader::NumExprFields
]);
4003 case EXPR_MATERIALIZE_TEMPORARY
:
4004 S
= new (Context
) MaterializeTemporaryExpr(Empty
);
4008 S
= new (Context
) CXXFoldExpr(Empty
);
4011 case EXPR_CXX_PAREN_LIST_INIT
:
4012 S
= CXXParenListInitExpr::CreateEmpty(
4013 Context
, /*numExprs=*/Record
[ASTStmtReader::NumExprFields
], Empty
);
4016 case EXPR_OPAQUE_VALUE
:
4017 S
= new (Context
) OpaqueValueExpr(Empty
);
4020 case EXPR_CUDA_KERNEL_CALL
:
4021 S
= CUDAKernelCallExpr::CreateEmpty(
4022 Context
, /*NumArgs=*/Record
[ASTStmtReader::NumExprFields
],
4023 /*HasFPFeatures=*/Record
[ASTStmtReader::NumExprFields
+ 1], Empty
);
4027 S
= new (Context
) AsTypeExpr(Empty
);
4030 case EXPR_PSEUDO_OBJECT
: {
4031 unsigned numSemanticExprs
= Record
[ASTStmtReader::NumExprFields
];
4032 S
= PseudoObjectExpr::Create(Context
, Empty
, numSemanticExprs
);
4037 S
= new (Context
) AtomicExpr(Empty
);
4041 unsigned NumCaptures
= Record
[ASTStmtReader::NumExprFields
];
4042 S
= LambdaExpr::CreateDeserialized(Context
, NumCaptures
);
4046 case STMT_COROUTINE_BODY
: {
4047 unsigned NumParams
= Record
[ASTStmtReader::NumStmtFields
];
4048 S
= CoroutineBodyStmt::Create(Context
, Empty
, NumParams
);
4053 S
= new (Context
) CoreturnStmt(Empty
);
4057 S
= new (Context
) CoawaitExpr(Empty
);
4061 S
= new (Context
) CoyieldExpr(Empty
);
4064 case EXPR_DEPENDENT_COAWAIT
:
4065 S
= new (Context
) DependentCoawaitExpr(Empty
);
4068 case EXPR_CONCEPT_SPECIALIZATION
: {
4069 S
= new (Context
) ConceptSpecializationExpr(Empty
);
4074 unsigned numLocalParameters
= Record
[ASTStmtReader::NumExprFields
];
4075 unsigned numRequirement
= Record
[ASTStmtReader::NumExprFields
+ 1];
4076 S
= RequiresExpr::Create(Context
, Empty
, numLocalParameters
,
4081 // We hit a STMT_STOP, so we're done with this expression.
4085 ++NumStatementsRead
;
4087 if (S
&& !IsStmtReference
) {
4089 StmtEntries
[Cursor
.GetCurrentBitNo()] = S
;
4092 assert(Record
.getIdx() == Record
.size() &&
4093 "Invalid deserialization of statement");
4094 StmtStack
.push_back(S
);
4097 assert(StmtStack
.size() > PrevNumStmts
&& "Read too many sub-stmts!");
4098 assert(StmtStack
.size() == PrevNumStmts
+ 1 && "Extra expressions on stack!");
4099 return StmtStack
.pop_back_val();