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 E
->DeclRefExprBits
.CapturedByCopyInLambdaWithExplicitObjectParameter
= false;
600 unsigned NumTemplateArgs
= 0;
601 if (E
->hasTemplateKWAndArgsInfo())
602 NumTemplateArgs
= Record
.readInt();
604 if (E
->hasQualifier())
605 new (E
->getTrailingObjects
<NestedNameSpecifierLoc
>())
606 NestedNameSpecifierLoc(Record
.readNestedNameSpecifierLoc());
608 if (E
->hasFoundDecl())
609 *E
->getTrailingObjects
<NamedDecl
*>() = readDeclAs
<NamedDecl
>();
611 if (E
->hasTemplateKWAndArgsInfo())
612 ReadTemplateKWAndArgsInfo(
613 *E
->getTrailingObjects
<ASTTemplateKWAndArgsInfo
>(),
614 E
->getTrailingObjects
<TemplateArgumentLoc
>(), NumTemplateArgs
);
616 E
->D
= readDeclAs
<ValueDecl
>();
617 E
->setLocation(readSourceLocation());
618 E
->DNLoc
= Record
.readDeclarationNameLoc(E
->getDecl()->getDeclName());
621 void ASTStmtReader::VisitIntegerLiteral(IntegerLiteral
*E
) {
623 E
->setLocation(readSourceLocation());
624 E
->setValue(Record
.getContext(), Record
.readAPInt());
627 void ASTStmtReader::VisitFixedPointLiteral(FixedPointLiteral
*E
) {
629 E
->setLocation(readSourceLocation());
630 E
->setScale(Record
.readInt());
631 E
->setValue(Record
.getContext(), Record
.readAPInt());
634 void ASTStmtReader::VisitFloatingLiteral(FloatingLiteral
*E
) {
637 static_cast<llvm::APFloatBase::Semantics
>(Record
.readInt()));
638 E
->setExact(Record
.readInt());
639 E
->setValue(Record
.getContext(), Record
.readAPFloat(E
->getSemantics()));
640 E
->setLocation(readSourceLocation());
643 void ASTStmtReader::VisitImaginaryLiteral(ImaginaryLiteral
*E
) {
645 E
->setSubExpr(Record
.readSubExpr());
648 void ASTStmtReader::VisitStringLiteral(StringLiteral
*E
) {
651 // NumConcatenated, Length and CharByteWidth are set by the empty
652 // ctor since they are needed to allocate storage for the trailing objects.
653 unsigned NumConcatenated
= Record
.readInt();
654 unsigned Length
= Record
.readInt();
655 unsigned CharByteWidth
= Record
.readInt();
656 assert((NumConcatenated
== E
->getNumConcatenated()) &&
657 "Wrong number of concatenated tokens!");
658 assert((Length
== E
->getLength()) && "Wrong Length!");
659 assert((CharByteWidth
== E
->getCharByteWidth()) && "Wrong character width!");
660 E
->StringLiteralBits
.Kind
= Record
.readInt();
661 E
->StringLiteralBits
.IsPascal
= Record
.readInt();
663 // The character width is originally computed via mapCharByteWidth.
664 // Check that the deserialized character width is consistant with the result
665 // of calling mapCharByteWidth.
666 assert((CharByteWidth
==
667 StringLiteral::mapCharByteWidth(Record
.getContext().getTargetInfo(),
669 "Wrong character width!");
671 // Deserialize the trailing array of SourceLocation.
672 for (unsigned I
= 0; I
< NumConcatenated
; ++I
)
673 E
->setStrTokenLoc(I
, readSourceLocation());
675 // Deserialize the trailing array of char holding the string data.
676 char *StrData
= E
->getStrDataAsChar();
677 for (unsigned I
= 0; I
< Length
* CharByteWidth
; ++I
)
678 StrData
[I
] = Record
.readInt();
681 void ASTStmtReader::VisitCharacterLiteral(CharacterLiteral
*E
) {
683 E
->setValue(Record
.readInt());
684 E
->setLocation(readSourceLocation());
685 E
->setKind(static_cast<CharacterLiteral::CharacterKind
>(Record
.readInt()));
688 void ASTStmtReader::VisitParenExpr(ParenExpr
*E
) {
690 E
->setLParen(readSourceLocation());
691 E
->setRParen(readSourceLocation());
692 E
->setSubExpr(Record
.readSubExpr());
695 void ASTStmtReader::VisitParenListExpr(ParenListExpr
*E
) {
697 unsigned NumExprs
= Record
.readInt();
698 assert((NumExprs
== E
->getNumExprs()) && "Wrong NumExprs!");
699 for (unsigned I
= 0; I
!= NumExprs
; ++I
)
700 E
->getTrailingObjects
<Stmt
*>()[I
] = Record
.readSubStmt();
701 E
->LParenLoc
= readSourceLocation();
702 E
->RParenLoc
= readSourceLocation();
705 void ASTStmtReader::VisitUnaryOperator(UnaryOperator
*E
) {
707 bool hasFP_Features
= Record
.readInt();
708 assert(hasFP_Features
== E
->hasStoredFPFeatures());
709 E
->setSubExpr(Record
.readSubExpr());
710 E
->setOpcode((UnaryOperator::Opcode
)Record
.readInt());
711 E
->setOperatorLoc(readSourceLocation());
712 E
->setCanOverflow(Record
.readInt());
714 E
->setStoredFPFeatures(
715 FPOptionsOverride::getFromOpaqueInt(Record
.readInt()));
718 void ASTStmtReader::VisitOffsetOfExpr(OffsetOfExpr
*E
) {
720 assert(E
->getNumComponents() == Record
.peekInt());
722 assert(E
->getNumExpressions() == Record
.peekInt());
724 E
->setOperatorLoc(readSourceLocation());
725 E
->setRParenLoc(readSourceLocation());
726 E
->setTypeSourceInfo(readTypeSourceInfo());
727 for (unsigned I
= 0, N
= E
->getNumComponents(); I
!= N
; ++I
) {
728 auto Kind
= static_cast<OffsetOfNode::Kind
>(Record
.readInt());
729 SourceLocation Start
= readSourceLocation();
730 SourceLocation End
= readSourceLocation();
732 case OffsetOfNode::Array
:
733 E
->setComponent(I
, OffsetOfNode(Start
, Record
.readInt(), End
));
736 case OffsetOfNode::Field
:
738 I
, OffsetOfNode(Start
, readDeclAs
<FieldDecl
>(), End
));
741 case OffsetOfNode::Identifier
:
744 OffsetOfNode(Start
, Record
.readIdentifier(), End
));
747 case OffsetOfNode::Base
: {
748 auto *Base
= new (Record
.getContext()) CXXBaseSpecifier();
749 *Base
= Record
.readCXXBaseSpecifier();
750 E
->setComponent(I
, OffsetOfNode(Base
));
756 for (unsigned I
= 0, N
= E
->getNumExpressions(); I
!= N
; ++I
)
757 E
->setIndexExpr(I
, Record
.readSubExpr());
760 void ASTStmtReader::VisitUnaryExprOrTypeTraitExpr(UnaryExprOrTypeTraitExpr
*E
) {
762 E
->setKind(static_cast<UnaryExprOrTypeTrait
>(Record
.readInt()));
763 if (Record
.peekInt() == 0) {
764 E
->setArgument(Record
.readSubExpr());
767 E
->setArgument(readTypeSourceInfo());
769 E
->setOperatorLoc(readSourceLocation());
770 E
->setRParenLoc(readSourceLocation());
773 static ConstraintSatisfaction
774 readConstraintSatisfaction(ASTRecordReader
&Record
) {
775 ConstraintSatisfaction Satisfaction
;
776 Satisfaction
.IsSatisfied
= Record
.readInt();
777 Satisfaction
.ContainsErrors
= Record
.readInt();
778 if (!Satisfaction
.IsSatisfied
) {
779 unsigned NumDetailRecords
= Record
.readInt();
780 for (unsigned i
= 0; i
!= NumDetailRecords
; ++i
) {
781 Expr
*ConstraintExpr
= Record
.readExpr();
782 if (/* IsDiagnostic */Record
.readInt()) {
783 SourceLocation DiagLocation
= Record
.readSourceLocation();
784 std::string DiagMessage
= Record
.readString();
785 Satisfaction
.Details
.emplace_back(
786 ConstraintExpr
, new (Record
.getContext())
787 ConstraintSatisfaction::SubstitutionDiagnostic
{
788 DiagLocation
, DiagMessage
});
790 Satisfaction
.Details
.emplace_back(ConstraintExpr
, Record
.readExpr());
796 void ASTStmtReader::VisitConceptSpecializationExpr(
797 ConceptSpecializationExpr
*E
) {
799 E
->SpecDecl
= Record
.readDeclAs
<ImplicitConceptSpecializationDecl
>();
800 if (Record
.readBool())
801 E
->ConceptRef
= Record
.readConceptReference();
802 E
->Satisfaction
= E
->isValueDependent() ? nullptr :
803 ASTConstraintSatisfaction::Create(Record
.getContext(),
804 readConstraintSatisfaction(Record
));
807 static concepts::Requirement::SubstitutionDiagnostic
*
808 readSubstitutionDiagnostic(ASTRecordReader
&Record
) {
809 std::string SubstitutedEntity
= Record
.readString();
810 SourceLocation DiagLoc
= Record
.readSourceLocation();
811 std::string DiagMessage
= Record
.readString();
812 return new (Record
.getContext())
813 concepts::Requirement::SubstitutionDiagnostic
{SubstitutedEntity
, DiagLoc
,
817 void ASTStmtReader::VisitRequiresExpr(RequiresExpr
*E
) {
819 unsigned NumLocalParameters
= Record
.readInt();
820 unsigned NumRequirements
= Record
.readInt();
821 E
->RequiresExprBits
.RequiresKWLoc
= Record
.readSourceLocation();
822 E
->RequiresExprBits
.IsSatisfied
= Record
.readInt();
823 E
->Body
= Record
.readDeclAs
<RequiresExprBodyDecl
>();
824 llvm::SmallVector
<ParmVarDecl
*, 4> LocalParameters
;
825 for (unsigned i
= 0; i
< NumLocalParameters
; ++i
)
826 LocalParameters
.push_back(cast
<ParmVarDecl
>(Record
.readDecl()));
827 std::copy(LocalParameters
.begin(), LocalParameters
.end(),
828 E
->getTrailingObjects
<ParmVarDecl
*>());
829 llvm::SmallVector
<concepts::Requirement
*, 4> Requirements
;
830 for (unsigned i
= 0; i
< NumRequirements
; ++i
) {
832 static_cast<concepts::Requirement::RequirementKind
>(Record
.readInt());
833 concepts::Requirement
*R
= nullptr;
835 case concepts::Requirement::RK_Type
: {
837 static_cast<concepts::TypeRequirement::SatisfactionStatus
>(
839 if (Status
== concepts::TypeRequirement::SS_SubstitutionFailure
)
840 R
= new (Record
.getContext())
841 concepts::TypeRequirement(readSubstitutionDiagnostic(Record
));
843 R
= new (Record
.getContext())
844 concepts::TypeRequirement(Record
.readTypeSourceInfo());
846 case concepts::Requirement::RK_Simple
:
847 case concepts::Requirement::RK_Compound
: {
849 static_cast<concepts::ExprRequirement::SatisfactionStatus
>(
851 llvm::PointerUnion
<concepts::Requirement::SubstitutionDiagnostic
*,
853 if (Status
== concepts::ExprRequirement::SS_ExprSubstitutionFailure
) {
854 E
= readSubstitutionDiagnostic(Record
);
856 E
= Record
.readExpr();
858 std::optional
<concepts::ExprRequirement::ReturnTypeRequirement
> Req
;
859 ConceptSpecializationExpr
*SubstitutedConstraintExpr
= nullptr;
860 SourceLocation NoexceptLoc
;
861 if (RK
== concepts::Requirement::RK_Simple
) {
864 NoexceptLoc
= Record
.readSourceLocation();
865 switch (/* returnTypeRequirementKind */Record
.readInt()) {
867 // No return type requirement.
872 TemplateParameterList
*TPL
= Record
.readTemplateParameterList();
874 concepts::ExprRequirement::SS_ConstraintsNotSatisfied
)
875 SubstitutedConstraintExpr
=
876 cast
<ConceptSpecializationExpr
>(Record
.readExpr());
880 // Substitution failure
881 Req
.emplace(readSubstitutionDiagnostic(Record
));
885 if (Expr
*Ex
= E
.dyn_cast
<Expr
*>())
886 R
= new (Record
.getContext()) concepts::ExprRequirement(
887 Ex
, RK
== concepts::Requirement::RK_Simple
, NoexceptLoc
,
888 std::move(*Req
), Status
, SubstitutedConstraintExpr
);
890 R
= new (Record
.getContext()) concepts::ExprRequirement(
891 E
.get
<concepts::Requirement::SubstitutionDiagnostic
*>(),
892 RK
== concepts::Requirement::RK_Simple
, NoexceptLoc
,
895 case concepts::Requirement::RK_Nested
: {
896 bool HasInvalidConstraint
= Record
.readInt();
897 if (HasInvalidConstraint
) {
898 std::string InvalidConstraint
= Record
.readString();
899 char *InvalidConstraintBuf
=
900 new (Record
.getContext()) char[InvalidConstraint
.size()];
901 std::copy(InvalidConstraint
.begin(), InvalidConstraint
.end(),
902 InvalidConstraintBuf
);
903 R
= new (Record
.getContext()) concepts::NestedRequirement(
905 StringRef(InvalidConstraintBuf
, InvalidConstraint
.size()),
906 readConstraintSatisfaction(Record
));
909 Expr
*E
= Record
.readExpr();
910 if (E
->isInstantiationDependent())
911 R
= new (Record
.getContext()) concepts::NestedRequirement(E
);
913 R
= new (Record
.getContext())
914 concepts::NestedRequirement(Record
.getContext(), E
,
915 readConstraintSatisfaction(Record
));
920 Requirements
.push_back(R
);
922 std::copy(Requirements
.begin(), Requirements
.end(),
923 E
->getTrailingObjects
<concepts::Requirement
*>());
924 E
->LParenLoc
= Record
.readSourceLocation();
925 E
->RParenLoc
= Record
.readSourceLocation();
926 E
->RBraceLoc
= Record
.readSourceLocation();
929 void ASTStmtReader::VisitArraySubscriptExpr(ArraySubscriptExpr
*E
) {
931 E
->setLHS(Record
.readSubExpr());
932 E
->setRHS(Record
.readSubExpr());
933 E
->setRBracketLoc(readSourceLocation());
936 void ASTStmtReader::VisitMatrixSubscriptExpr(MatrixSubscriptExpr
*E
) {
938 E
->setBase(Record
.readSubExpr());
939 E
->setRowIdx(Record
.readSubExpr());
940 E
->setColumnIdx(Record
.readSubExpr());
941 E
->setRBracketLoc(readSourceLocation());
944 void ASTStmtReader::VisitOMPArraySectionExpr(OMPArraySectionExpr
*E
) {
946 E
->setBase(Record
.readSubExpr());
947 E
->setLowerBound(Record
.readSubExpr());
948 E
->setLength(Record
.readSubExpr());
949 E
->setStride(Record
.readSubExpr());
950 E
->setColonLocFirst(readSourceLocation());
951 E
->setColonLocSecond(readSourceLocation());
952 E
->setRBracketLoc(readSourceLocation());
955 void ASTStmtReader::VisitOMPArrayShapingExpr(OMPArrayShapingExpr
*E
) {
957 unsigned NumDims
= Record
.readInt();
958 E
->setBase(Record
.readSubExpr());
959 SmallVector
<Expr
*, 4> Dims(NumDims
);
960 for (unsigned I
= 0; I
< NumDims
; ++I
)
961 Dims
[I
] = Record
.readSubExpr();
962 E
->setDimensions(Dims
);
963 SmallVector
<SourceRange
, 4> SRs(NumDims
);
964 for (unsigned I
= 0; I
< NumDims
; ++I
)
965 SRs
[I
] = readSourceRange();
966 E
->setBracketsRanges(SRs
);
967 E
->setLParenLoc(readSourceLocation());
968 E
->setRParenLoc(readSourceLocation());
971 void ASTStmtReader::VisitOMPIteratorExpr(OMPIteratorExpr
*E
) {
973 unsigned NumIters
= Record
.readInt();
974 E
->setIteratorKwLoc(readSourceLocation());
975 E
->setLParenLoc(readSourceLocation());
976 E
->setRParenLoc(readSourceLocation());
977 for (unsigned I
= 0; I
< NumIters
; ++I
) {
978 E
->setIteratorDeclaration(I
, Record
.readDeclRef());
979 E
->setAssignmentLoc(I
, readSourceLocation());
980 Expr
*Begin
= Record
.readSubExpr();
981 Expr
*End
= Record
.readSubExpr();
982 Expr
*Step
= Record
.readSubExpr();
983 SourceLocation ColonLoc
= readSourceLocation();
984 SourceLocation SecColonLoc
;
986 SecColonLoc
= readSourceLocation();
987 E
->setIteratorRange(I
, Begin
, ColonLoc
, End
, SecColonLoc
, Step
);
988 // Deserialize helpers
989 OMPIteratorHelperData HD
;
990 HD
.CounterVD
= cast_or_null
<VarDecl
>(Record
.readDeclRef());
991 HD
.Upper
= Record
.readSubExpr();
992 HD
.Update
= Record
.readSubExpr();
993 HD
.CounterUpdate
= Record
.readSubExpr();
998 void ASTStmtReader::VisitCallExpr(CallExpr
*E
) {
1000 unsigned NumArgs
= Record
.readInt();
1001 bool HasFPFeatures
= Record
.readInt();
1002 assert((NumArgs
== E
->getNumArgs()) && "Wrong NumArgs!");
1003 E
->setRParenLoc(readSourceLocation());
1004 E
->setCallee(Record
.readSubExpr());
1005 for (unsigned I
= 0; I
!= NumArgs
; ++I
)
1006 E
->setArg(I
, Record
.readSubExpr());
1007 E
->setADLCallKind(static_cast<CallExpr::ADLCallKind
>(Record
.readInt()));
1009 E
->setStoredFPFeatures(
1010 FPOptionsOverride::getFromOpaqueInt(Record
.readInt()));
1013 void ASTStmtReader::VisitCXXMemberCallExpr(CXXMemberCallExpr
*E
) {
1017 void ASTStmtReader::VisitMemberExpr(MemberExpr
*E
) {
1020 bool HasQualifier
= Record
.readInt();
1021 bool HasFoundDecl
= Record
.readInt();
1022 bool HasTemplateInfo
= Record
.readInt();
1023 unsigned NumTemplateArgs
= Record
.readInt();
1025 E
->Base
= Record
.readSubExpr();
1026 E
->MemberDecl
= Record
.readDeclAs
<ValueDecl
>();
1027 E
->MemberDNLoc
= Record
.readDeclarationNameLoc(E
->MemberDecl
->getDeclName());
1028 E
->MemberLoc
= Record
.readSourceLocation();
1029 E
->MemberExprBits
.IsArrow
= Record
.readInt();
1030 E
->MemberExprBits
.HasQualifierOrFoundDecl
= HasQualifier
|| HasFoundDecl
;
1031 E
->MemberExprBits
.HasTemplateKWAndArgsInfo
= HasTemplateInfo
;
1032 E
->MemberExprBits
.HadMultipleCandidates
= Record
.readInt();
1033 E
->MemberExprBits
.NonOdrUseReason
= Record
.readInt();
1034 E
->MemberExprBits
.OperatorLoc
= Record
.readSourceLocation();
1036 if (HasQualifier
|| HasFoundDecl
) {
1037 DeclAccessPair FoundDecl
;
1039 auto *FoundD
= Record
.readDeclAs
<NamedDecl
>();
1040 auto AS
= (AccessSpecifier
)Record
.readInt();
1041 FoundDecl
= DeclAccessPair::make(FoundD
, AS
);
1043 FoundDecl
= DeclAccessPair::make(E
->MemberDecl
,
1044 E
->MemberDecl
->getAccess());
1046 E
->getTrailingObjects
<MemberExprNameQualifier
>()->FoundDecl
= FoundDecl
;
1048 NestedNameSpecifierLoc QualifierLoc
;
1050 QualifierLoc
= Record
.readNestedNameSpecifierLoc();
1051 E
->getTrailingObjects
<MemberExprNameQualifier
>()->QualifierLoc
=
1055 if (HasTemplateInfo
)
1056 ReadTemplateKWAndArgsInfo(
1057 *E
->getTrailingObjects
<ASTTemplateKWAndArgsInfo
>(),
1058 E
->getTrailingObjects
<TemplateArgumentLoc
>(), NumTemplateArgs
);
1061 void ASTStmtReader::VisitObjCIsaExpr(ObjCIsaExpr
*E
) {
1063 E
->setBase(Record
.readSubExpr());
1064 E
->setIsaMemberLoc(readSourceLocation());
1065 E
->setOpLoc(readSourceLocation());
1066 E
->setArrow(Record
.readInt());
1069 void ASTStmtReader::
1070 VisitObjCIndirectCopyRestoreExpr(ObjCIndirectCopyRestoreExpr
*E
) {
1072 E
->Operand
= Record
.readSubExpr();
1073 E
->setShouldCopy(Record
.readInt());
1076 void ASTStmtReader::VisitObjCBridgedCastExpr(ObjCBridgedCastExpr
*E
) {
1077 VisitExplicitCastExpr(E
);
1078 E
->LParenLoc
= readSourceLocation();
1079 E
->BridgeKeywordLoc
= readSourceLocation();
1080 E
->Kind
= Record
.readInt();
1083 void ASTStmtReader::VisitCastExpr(CastExpr
*E
) {
1085 unsigned NumBaseSpecs
= Record
.readInt();
1086 assert(NumBaseSpecs
== E
->path_size());
1087 unsigned HasFPFeatures
= Record
.readInt();
1088 assert(E
->hasStoredFPFeatures() == HasFPFeatures
);
1089 E
->setSubExpr(Record
.readSubExpr());
1090 E
->setCastKind((CastKind
)Record
.readInt());
1091 CastExpr::path_iterator BaseI
= E
->path_begin();
1092 while (NumBaseSpecs
--) {
1093 auto *BaseSpec
= new (Record
.getContext()) CXXBaseSpecifier
;
1094 *BaseSpec
= Record
.readCXXBaseSpecifier();
1095 *BaseI
++ = BaseSpec
;
1098 *E
->getTrailingFPFeatures() =
1099 FPOptionsOverride::getFromOpaqueInt(Record
.readInt());
1102 void ASTStmtReader::VisitBinaryOperator(BinaryOperator
*E
) {
1103 bool hasFP_Features
;
1105 E
->setHasStoredFPFeatures(hasFP_Features
= Record
.readInt());
1106 E
->setOpcode((BinaryOperator::Opcode
)Record
.readInt());
1107 E
->setLHS(Record
.readSubExpr());
1108 E
->setRHS(Record
.readSubExpr());
1109 E
->setOperatorLoc(readSourceLocation());
1111 E
->setStoredFPFeatures(
1112 FPOptionsOverride::getFromOpaqueInt(Record
.readInt()));
1115 void ASTStmtReader::VisitCompoundAssignOperator(CompoundAssignOperator
*E
) {
1116 VisitBinaryOperator(E
);
1117 E
->setComputationLHSType(Record
.readType());
1118 E
->setComputationResultType(Record
.readType());
1121 void ASTStmtReader::VisitConditionalOperator(ConditionalOperator
*E
) {
1123 E
->SubExprs
[ConditionalOperator::COND
] = Record
.readSubExpr();
1124 E
->SubExprs
[ConditionalOperator::LHS
] = Record
.readSubExpr();
1125 E
->SubExprs
[ConditionalOperator::RHS
] = Record
.readSubExpr();
1126 E
->QuestionLoc
= readSourceLocation();
1127 E
->ColonLoc
= readSourceLocation();
1131 ASTStmtReader::VisitBinaryConditionalOperator(BinaryConditionalOperator
*E
) {
1133 E
->OpaqueValue
= cast
<OpaqueValueExpr
>(Record
.readSubExpr());
1134 E
->SubExprs
[BinaryConditionalOperator::COMMON
] = Record
.readSubExpr();
1135 E
->SubExprs
[BinaryConditionalOperator::COND
] = Record
.readSubExpr();
1136 E
->SubExprs
[BinaryConditionalOperator::LHS
] = Record
.readSubExpr();
1137 E
->SubExprs
[BinaryConditionalOperator::RHS
] = Record
.readSubExpr();
1138 E
->QuestionLoc
= readSourceLocation();
1139 E
->ColonLoc
= readSourceLocation();
1142 void ASTStmtReader::VisitImplicitCastExpr(ImplicitCastExpr
*E
) {
1144 E
->setIsPartOfExplicitCast(Record
.readInt());
1147 void ASTStmtReader::VisitExplicitCastExpr(ExplicitCastExpr
*E
) {
1149 E
->setTypeInfoAsWritten(readTypeSourceInfo());
1152 void ASTStmtReader::VisitCStyleCastExpr(CStyleCastExpr
*E
) {
1153 VisitExplicitCastExpr(E
);
1154 E
->setLParenLoc(readSourceLocation());
1155 E
->setRParenLoc(readSourceLocation());
1158 void ASTStmtReader::VisitCompoundLiteralExpr(CompoundLiteralExpr
*E
) {
1160 E
->setLParenLoc(readSourceLocation());
1161 E
->setTypeSourceInfo(readTypeSourceInfo());
1162 E
->setInitializer(Record
.readSubExpr());
1163 E
->setFileScope(Record
.readInt());
1166 void ASTStmtReader::VisitExtVectorElementExpr(ExtVectorElementExpr
*E
) {
1168 E
->setBase(Record
.readSubExpr());
1169 E
->setAccessor(Record
.readIdentifier());
1170 E
->setAccessorLoc(readSourceLocation());
1173 void ASTStmtReader::VisitInitListExpr(InitListExpr
*E
) {
1175 if (auto *SyntForm
= cast_or_null
<InitListExpr
>(Record
.readSubStmt()))
1176 E
->setSyntacticForm(SyntForm
);
1177 E
->setLBraceLoc(readSourceLocation());
1178 E
->setRBraceLoc(readSourceLocation());
1179 bool isArrayFiller
= Record
.readInt();
1180 Expr
*filler
= nullptr;
1181 if (isArrayFiller
) {
1182 filler
= Record
.readSubExpr();
1183 E
->ArrayFillerOrUnionFieldInit
= filler
;
1185 E
->ArrayFillerOrUnionFieldInit
= readDeclAs
<FieldDecl
>();
1186 E
->sawArrayRangeDesignator(Record
.readInt());
1187 unsigned NumInits
= Record
.readInt();
1188 E
->reserveInits(Record
.getContext(), NumInits
);
1189 if (isArrayFiller
) {
1190 for (unsigned I
= 0; I
!= NumInits
; ++I
) {
1191 Expr
*init
= Record
.readSubExpr();
1192 E
->updateInit(Record
.getContext(), I
, init
? init
: filler
);
1195 for (unsigned I
= 0; I
!= NumInits
; ++I
)
1196 E
->updateInit(Record
.getContext(), I
, Record
.readSubExpr());
1200 void ASTStmtReader::VisitDesignatedInitExpr(DesignatedInitExpr
*E
) {
1201 using Designator
= DesignatedInitExpr::Designator
;
1204 unsigned NumSubExprs
= Record
.readInt();
1205 assert(NumSubExprs
== E
->getNumSubExprs() && "Wrong number of subexprs");
1206 for (unsigned I
= 0; I
!= NumSubExprs
; ++I
)
1207 E
->setSubExpr(I
, Record
.readSubExpr());
1208 E
->setEqualOrColonLoc(readSourceLocation());
1209 E
->setGNUSyntax(Record
.readInt());
1211 SmallVector
<Designator
, 4> Designators
;
1212 while (Record
.getIdx() < Record
.size()) {
1213 switch ((DesignatorTypes
)Record
.readInt()) {
1214 case DESIG_FIELD_DECL
: {
1215 auto *Field
= readDeclAs
<FieldDecl
>();
1216 SourceLocation DotLoc
= readSourceLocation();
1217 SourceLocation FieldLoc
= readSourceLocation();
1218 Designators
.push_back(Designator::CreateFieldDesignator(
1219 Field
->getIdentifier(), DotLoc
, FieldLoc
));
1220 Designators
.back().setFieldDecl(Field
);
1224 case DESIG_FIELD_NAME
: {
1225 const IdentifierInfo
*Name
= Record
.readIdentifier();
1226 SourceLocation DotLoc
= readSourceLocation();
1227 SourceLocation FieldLoc
= readSourceLocation();
1228 Designators
.push_back(Designator::CreateFieldDesignator(Name
, DotLoc
,
1234 unsigned Index
= Record
.readInt();
1235 SourceLocation LBracketLoc
= readSourceLocation();
1236 SourceLocation RBracketLoc
= readSourceLocation();
1237 Designators
.push_back(Designator::CreateArrayDesignator(Index
,
1243 case DESIG_ARRAY_RANGE
: {
1244 unsigned Index
= Record
.readInt();
1245 SourceLocation LBracketLoc
= readSourceLocation();
1246 SourceLocation EllipsisLoc
= readSourceLocation();
1247 SourceLocation RBracketLoc
= readSourceLocation();
1248 Designators
.push_back(Designator::CreateArrayRangeDesignator(
1249 Index
, LBracketLoc
, EllipsisLoc
, RBracketLoc
));
1254 E
->setDesignators(Record
.getContext(),
1255 Designators
.data(), Designators
.size());
1258 void ASTStmtReader::VisitDesignatedInitUpdateExpr(DesignatedInitUpdateExpr
*E
) {
1260 E
->setBase(Record
.readSubExpr());
1261 E
->setUpdater(Record
.readSubExpr());
1264 void ASTStmtReader::VisitNoInitExpr(NoInitExpr
*E
) {
1268 void ASTStmtReader::VisitArrayInitLoopExpr(ArrayInitLoopExpr
*E
) {
1270 E
->SubExprs
[0] = Record
.readSubExpr();
1271 E
->SubExprs
[1] = Record
.readSubExpr();
1274 void ASTStmtReader::VisitArrayInitIndexExpr(ArrayInitIndexExpr
*E
) {
1278 void ASTStmtReader::VisitImplicitValueInitExpr(ImplicitValueInitExpr
*E
) {
1282 void ASTStmtReader::VisitVAArgExpr(VAArgExpr
*E
) {
1284 E
->setSubExpr(Record
.readSubExpr());
1285 E
->setWrittenTypeInfo(readTypeSourceInfo());
1286 E
->setBuiltinLoc(readSourceLocation());
1287 E
->setRParenLoc(readSourceLocation());
1288 E
->setIsMicrosoftABI(Record
.readInt());
1291 void ASTStmtReader::VisitSourceLocExpr(SourceLocExpr
*E
) {
1293 E
->ParentContext
= readDeclAs
<DeclContext
>();
1294 E
->BuiltinLoc
= readSourceLocation();
1295 E
->RParenLoc
= readSourceLocation();
1296 E
->SourceLocExprBits
.Kind
=
1297 static_cast<SourceLocExpr::IdentKind
>(Record
.readInt());
1300 void ASTStmtReader::VisitAddrLabelExpr(AddrLabelExpr
*E
) {
1302 E
->setAmpAmpLoc(readSourceLocation());
1303 E
->setLabelLoc(readSourceLocation());
1304 E
->setLabel(readDeclAs
<LabelDecl
>());
1307 void ASTStmtReader::VisitStmtExpr(StmtExpr
*E
) {
1309 E
->setLParenLoc(readSourceLocation());
1310 E
->setRParenLoc(readSourceLocation());
1311 E
->setSubStmt(cast_or_null
<CompoundStmt
>(Record
.readSubStmt()));
1312 E
->StmtExprBits
.TemplateDepth
= Record
.readInt();
1315 void ASTStmtReader::VisitChooseExpr(ChooseExpr
*E
) {
1317 E
->setCond(Record
.readSubExpr());
1318 E
->setLHS(Record
.readSubExpr());
1319 E
->setRHS(Record
.readSubExpr());
1320 E
->setBuiltinLoc(readSourceLocation());
1321 E
->setRParenLoc(readSourceLocation());
1322 E
->setIsConditionTrue(Record
.readInt());
1325 void ASTStmtReader::VisitGNUNullExpr(GNUNullExpr
*E
) {
1327 E
->setTokenLocation(readSourceLocation());
1330 void ASTStmtReader::VisitShuffleVectorExpr(ShuffleVectorExpr
*E
) {
1332 SmallVector
<Expr
*, 16> Exprs
;
1333 unsigned NumExprs
= Record
.readInt();
1335 Exprs
.push_back(Record
.readSubExpr());
1336 E
->setExprs(Record
.getContext(), Exprs
);
1337 E
->setBuiltinLoc(readSourceLocation());
1338 E
->setRParenLoc(readSourceLocation());
1341 void ASTStmtReader::VisitConvertVectorExpr(ConvertVectorExpr
*E
) {
1343 E
->BuiltinLoc
= readSourceLocation();
1344 E
->RParenLoc
= readSourceLocation();
1345 E
->TInfo
= readTypeSourceInfo();
1346 E
->SrcExpr
= Record
.readSubExpr();
1349 void ASTStmtReader::VisitBlockExpr(BlockExpr
*E
) {
1351 E
->setBlockDecl(readDeclAs
<BlockDecl
>());
1354 void ASTStmtReader::VisitGenericSelectionExpr(GenericSelectionExpr
*E
) {
1357 unsigned NumAssocs
= Record
.readInt();
1358 assert(NumAssocs
== E
->getNumAssocs() && "Wrong NumAssocs!");
1359 E
->IsExprPredicate
= Record
.readInt();
1360 E
->ResultIndex
= Record
.readInt();
1361 E
->GenericSelectionExprBits
.GenericLoc
= readSourceLocation();
1362 E
->DefaultLoc
= readSourceLocation();
1363 E
->RParenLoc
= readSourceLocation();
1365 Stmt
**Stmts
= E
->getTrailingObjects
<Stmt
*>();
1366 // Add 1 to account for the controlling expression which is the first
1367 // expression in the trailing array of Stmt *. This is not needed for
1368 // the trailing array of TypeSourceInfo *.
1369 for (unsigned I
= 0, N
= NumAssocs
+ 1; I
< N
; ++I
)
1370 Stmts
[I
] = Record
.readSubExpr();
1372 TypeSourceInfo
**TSIs
= E
->getTrailingObjects
<TypeSourceInfo
*>();
1373 for (unsigned I
= 0, N
= NumAssocs
; I
< N
; ++I
)
1374 TSIs
[I
] = readTypeSourceInfo();
1377 void ASTStmtReader::VisitPseudoObjectExpr(PseudoObjectExpr
*E
) {
1379 unsigned numSemanticExprs
= Record
.readInt();
1380 assert(numSemanticExprs
+ 1 == E
->PseudoObjectExprBits
.NumSubExprs
);
1381 E
->PseudoObjectExprBits
.ResultIndex
= Record
.readInt();
1383 // Read the syntactic expression.
1384 E
->getSubExprsBuffer()[0] = Record
.readSubExpr();
1386 // Read all the semantic expressions.
1387 for (unsigned i
= 0; i
!= numSemanticExprs
; ++i
) {
1388 Expr
*subExpr
= Record
.readSubExpr();
1389 E
->getSubExprsBuffer()[i
+1] = subExpr
;
1393 void ASTStmtReader::VisitAtomicExpr(AtomicExpr
*E
) {
1395 E
->Op
= AtomicExpr::AtomicOp(Record
.readInt());
1396 E
->NumSubExprs
= AtomicExpr::getNumSubExprs(E
->Op
);
1397 for (unsigned I
= 0; I
!= E
->NumSubExprs
; ++I
)
1398 E
->SubExprs
[I
] = Record
.readSubExpr();
1399 E
->BuiltinLoc
= readSourceLocation();
1400 E
->RParenLoc
= readSourceLocation();
1403 //===----------------------------------------------------------------------===//
1404 // Objective-C Expressions and Statements
1406 void ASTStmtReader::VisitObjCStringLiteral(ObjCStringLiteral
*E
) {
1408 E
->setString(cast
<StringLiteral
>(Record
.readSubStmt()));
1409 E
->setAtLoc(readSourceLocation());
1412 void ASTStmtReader::VisitObjCBoxedExpr(ObjCBoxedExpr
*E
) {
1414 // could be one of several IntegerLiteral, FloatLiteral, etc.
1415 E
->SubExpr
= Record
.readSubStmt();
1416 E
->BoxingMethod
= readDeclAs
<ObjCMethodDecl
>();
1417 E
->Range
= readSourceRange();
1420 void ASTStmtReader::VisitObjCArrayLiteral(ObjCArrayLiteral
*E
) {
1422 unsigned NumElements
= Record
.readInt();
1423 assert(NumElements
== E
->getNumElements() && "Wrong number of elements");
1424 Expr
**Elements
= E
->getElements();
1425 for (unsigned I
= 0, N
= NumElements
; I
!= N
; ++I
)
1426 Elements
[I
] = Record
.readSubExpr();
1427 E
->ArrayWithObjectsMethod
= readDeclAs
<ObjCMethodDecl
>();
1428 E
->Range
= readSourceRange();
1431 void ASTStmtReader::VisitObjCDictionaryLiteral(ObjCDictionaryLiteral
*E
) {
1433 unsigned NumElements
= Record
.readInt();
1434 assert(NumElements
== E
->getNumElements() && "Wrong number of elements");
1435 bool HasPackExpansions
= Record
.readInt();
1436 assert(HasPackExpansions
== E
->HasPackExpansions
&&"Pack expansion mismatch");
1438 E
->getTrailingObjects
<ObjCDictionaryLiteral::KeyValuePair
>();
1440 E
->getTrailingObjects
<ObjCDictionaryLiteral::ExpansionData
>();
1441 for (unsigned I
= 0; I
!= NumElements
; ++I
) {
1442 KeyValues
[I
].Key
= Record
.readSubExpr();
1443 KeyValues
[I
].Value
= Record
.readSubExpr();
1444 if (HasPackExpansions
) {
1445 Expansions
[I
].EllipsisLoc
= readSourceLocation();
1446 Expansions
[I
].NumExpansionsPlusOne
= Record
.readInt();
1449 E
->DictWithObjectsMethod
= readDeclAs
<ObjCMethodDecl
>();
1450 E
->Range
= readSourceRange();
1453 void ASTStmtReader::VisitObjCEncodeExpr(ObjCEncodeExpr
*E
) {
1455 E
->setEncodedTypeSourceInfo(readTypeSourceInfo());
1456 E
->setAtLoc(readSourceLocation());
1457 E
->setRParenLoc(readSourceLocation());
1460 void ASTStmtReader::VisitObjCSelectorExpr(ObjCSelectorExpr
*E
) {
1462 E
->setSelector(Record
.readSelector());
1463 E
->setAtLoc(readSourceLocation());
1464 E
->setRParenLoc(readSourceLocation());
1467 void ASTStmtReader::VisitObjCProtocolExpr(ObjCProtocolExpr
*E
) {
1469 E
->setProtocol(readDeclAs
<ObjCProtocolDecl
>());
1470 E
->setAtLoc(readSourceLocation());
1471 E
->ProtoLoc
= readSourceLocation();
1472 E
->setRParenLoc(readSourceLocation());
1475 void ASTStmtReader::VisitObjCIvarRefExpr(ObjCIvarRefExpr
*E
) {
1477 E
->setDecl(readDeclAs
<ObjCIvarDecl
>());
1478 E
->setLocation(readSourceLocation());
1479 E
->setOpLoc(readSourceLocation());
1480 E
->setBase(Record
.readSubExpr());
1481 E
->setIsArrow(Record
.readInt());
1482 E
->setIsFreeIvar(Record
.readInt());
1485 void ASTStmtReader::VisitObjCPropertyRefExpr(ObjCPropertyRefExpr
*E
) {
1487 unsigned MethodRefFlags
= Record
.readInt();
1488 bool Implicit
= Record
.readInt() != 0;
1490 auto *Getter
= readDeclAs
<ObjCMethodDecl
>();
1491 auto *Setter
= readDeclAs
<ObjCMethodDecl
>();
1492 E
->setImplicitProperty(Getter
, Setter
, MethodRefFlags
);
1494 E
->setExplicitProperty(readDeclAs
<ObjCPropertyDecl
>(), MethodRefFlags
);
1496 E
->setLocation(readSourceLocation());
1497 E
->setReceiverLocation(readSourceLocation());
1498 switch (Record
.readInt()) {
1500 E
->setBase(Record
.readSubExpr());
1503 E
->setSuperReceiver(Record
.readType());
1506 E
->setClassReceiver(readDeclAs
<ObjCInterfaceDecl
>());
1511 void ASTStmtReader::VisitObjCSubscriptRefExpr(ObjCSubscriptRefExpr
*E
) {
1513 E
->setRBracket(readSourceLocation());
1514 E
->setBaseExpr(Record
.readSubExpr());
1515 E
->setKeyExpr(Record
.readSubExpr());
1516 E
->GetAtIndexMethodDecl
= readDeclAs
<ObjCMethodDecl
>();
1517 E
->SetAtIndexMethodDecl
= readDeclAs
<ObjCMethodDecl
>();
1520 void ASTStmtReader::VisitObjCMessageExpr(ObjCMessageExpr
*E
) {
1522 assert(Record
.peekInt() == E
->getNumArgs());
1524 unsigned NumStoredSelLocs
= Record
.readInt();
1525 E
->SelLocsKind
= Record
.readInt();
1526 E
->setDelegateInitCall(Record
.readInt());
1527 E
->IsImplicit
= Record
.readInt();
1528 auto Kind
= static_cast<ObjCMessageExpr::ReceiverKind
>(Record
.readInt());
1530 case ObjCMessageExpr::Instance
:
1531 E
->setInstanceReceiver(Record
.readSubExpr());
1534 case ObjCMessageExpr::Class
:
1535 E
->setClassReceiver(readTypeSourceInfo());
1538 case ObjCMessageExpr::SuperClass
:
1539 case ObjCMessageExpr::SuperInstance
: {
1540 QualType T
= Record
.readType();
1541 SourceLocation SuperLoc
= readSourceLocation();
1542 E
->setSuper(SuperLoc
, T
, Kind
== ObjCMessageExpr::SuperInstance
);
1547 assert(Kind
== E
->getReceiverKind());
1549 if (Record
.readInt())
1550 E
->setMethodDecl(readDeclAs
<ObjCMethodDecl
>());
1552 E
->setSelector(Record
.readSelector());
1554 E
->LBracLoc
= readSourceLocation();
1555 E
->RBracLoc
= readSourceLocation();
1557 for (unsigned I
= 0, N
= E
->getNumArgs(); I
!= N
; ++I
)
1558 E
->setArg(I
, Record
.readSubExpr());
1560 SourceLocation
*Locs
= E
->getStoredSelLocs();
1561 for (unsigned I
= 0; I
!= NumStoredSelLocs
; ++I
)
1562 Locs
[I
] = readSourceLocation();
1565 void ASTStmtReader::VisitObjCForCollectionStmt(ObjCForCollectionStmt
*S
) {
1567 S
->setElement(Record
.readSubStmt());
1568 S
->setCollection(Record
.readSubExpr());
1569 S
->setBody(Record
.readSubStmt());
1570 S
->setForLoc(readSourceLocation());
1571 S
->setRParenLoc(readSourceLocation());
1574 void ASTStmtReader::VisitObjCAtCatchStmt(ObjCAtCatchStmt
*S
) {
1576 S
->setCatchBody(Record
.readSubStmt());
1577 S
->setCatchParamDecl(readDeclAs
<VarDecl
>());
1578 S
->setAtCatchLoc(readSourceLocation());
1579 S
->setRParenLoc(readSourceLocation());
1582 void ASTStmtReader::VisitObjCAtFinallyStmt(ObjCAtFinallyStmt
*S
) {
1584 S
->setFinallyBody(Record
.readSubStmt());
1585 S
->setAtFinallyLoc(readSourceLocation());
1588 void ASTStmtReader::VisitObjCAutoreleasePoolStmt(ObjCAutoreleasePoolStmt
*S
) {
1589 VisitStmt(S
); // FIXME: no test coverage.
1590 S
->setSubStmt(Record
.readSubStmt());
1591 S
->setAtLoc(readSourceLocation());
1594 void ASTStmtReader::VisitObjCAtTryStmt(ObjCAtTryStmt
*S
) {
1596 assert(Record
.peekInt() == S
->getNumCatchStmts());
1598 bool HasFinally
= Record
.readInt();
1599 S
->setTryBody(Record
.readSubStmt());
1600 for (unsigned I
= 0, N
= S
->getNumCatchStmts(); I
!= N
; ++I
)
1601 S
->setCatchStmt(I
, cast_or_null
<ObjCAtCatchStmt
>(Record
.readSubStmt()));
1604 S
->setFinallyStmt(Record
.readSubStmt());
1605 S
->setAtTryLoc(readSourceLocation());
1608 void ASTStmtReader::VisitObjCAtSynchronizedStmt(ObjCAtSynchronizedStmt
*S
) {
1609 VisitStmt(S
); // FIXME: no test coverage.
1610 S
->setSynchExpr(Record
.readSubStmt());
1611 S
->setSynchBody(Record
.readSubStmt());
1612 S
->setAtSynchronizedLoc(readSourceLocation());
1615 void ASTStmtReader::VisitObjCAtThrowStmt(ObjCAtThrowStmt
*S
) {
1616 VisitStmt(S
); // FIXME: no test coverage.
1617 S
->setThrowExpr(Record
.readSubStmt());
1618 S
->setThrowLoc(readSourceLocation());
1621 void ASTStmtReader::VisitObjCBoolLiteralExpr(ObjCBoolLiteralExpr
*E
) {
1623 E
->setValue(Record
.readInt());
1624 E
->setLocation(readSourceLocation());
1627 void ASTStmtReader::VisitObjCAvailabilityCheckExpr(ObjCAvailabilityCheckExpr
*E
) {
1629 SourceRange R
= Record
.readSourceRange();
1630 E
->AtLoc
= R
.getBegin();
1631 E
->RParen
= R
.getEnd();
1632 E
->VersionToCheck
= Record
.readVersionTuple();
1635 //===----------------------------------------------------------------------===//
1636 // C++ Expressions and Statements
1637 //===----------------------------------------------------------------------===//
1639 void ASTStmtReader::VisitCXXCatchStmt(CXXCatchStmt
*S
) {
1641 S
->CatchLoc
= readSourceLocation();
1642 S
->ExceptionDecl
= readDeclAs
<VarDecl
>();
1643 S
->HandlerBlock
= Record
.readSubStmt();
1646 void ASTStmtReader::VisitCXXTryStmt(CXXTryStmt
*S
) {
1648 assert(Record
.peekInt() == S
->getNumHandlers() && "NumStmtFields is wrong ?");
1650 S
->TryLoc
= readSourceLocation();
1651 S
->getStmts()[0] = Record
.readSubStmt();
1652 for (unsigned i
= 0, e
= S
->getNumHandlers(); i
!= e
; ++i
)
1653 S
->getStmts()[i
+ 1] = Record
.readSubStmt();
1656 void ASTStmtReader::VisitCXXForRangeStmt(CXXForRangeStmt
*S
) {
1658 S
->ForLoc
= readSourceLocation();
1659 S
->CoawaitLoc
= readSourceLocation();
1660 S
->ColonLoc
= readSourceLocation();
1661 S
->RParenLoc
= readSourceLocation();
1662 S
->setInit(Record
.readSubStmt());
1663 S
->setRangeStmt(Record
.readSubStmt());
1664 S
->setBeginStmt(Record
.readSubStmt());
1665 S
->setEndStmt(Record
.readSubStmt());
1666 S
->setCond(Record
.readSubExpr());
1667 S
->setInc(Record
.readSubExpr());
1668 S
->setLoopVarStmt(Record
.readSubStmt());
1669 S
->setBody(Record
.readSubStmt());
1672 void ASTStmtReader::VisitMSDependentExistsStmt(MSDependentExistsStmt
*S
) {
1674 S
->KeywordLoc
= readSourceLocation();
1675 S
->IsIfExists
= Record
.readInt();
1676 S
->QualifierLoc
= Record
.readNestedNameSpecifierLoc();
1677 S
->NameInfo
= Record
.readDeclarationNameInfo();
1678 S
->SubStmt
= Record
.readSubStmt();
1681 void ASTStmtReader::VisitCXXOperatorCallExpr(CXXOperatorCallExpr
*E
) {
1683 E
->CXXOperatorCallExprBits
.OperatorKind
= Record
.readInt();
1684 E
->Range
= Record
.readSourceRange();
1687 void ASTStmtReader::VisitCXXRewrittenBinaryOperator(
1688 CXXRewrittenBinaryOperator
*E
) {
1690 E
->CXXRewrittenBinaryOperatorBits
.IsReversed
= Record
.readInt();
1691 E
->SemanticForm
= Record
.readSubExpr();
1694 void ASTStmtReader::VisitCXXConstructExpr(CXXConstructExpr
*E
) {
1697 unsigned NumArgs
= Record
.readInt();
1698 assert((NumArgs
== E
->getNumArgs()) && "Wrong NumArgs!");
1700 E
->CXXConstructExprBits
.Elidable
= Record
.readInt();
1701 E
->CXXConstructExprBits
.HadMultipleCandidates
= Record
.readInt();
1702 E
->CXXConstructExprBits
.ListInitialization
= Record
.readInt();
1703 E
->CXXConstructExprBits
.StdInitListInitialization
= Record
.readInt();
1704 E
->CXXConstructExprBits
.ZeroInitialization
= Record
.readInt();
1705 E
->CXXConstructExprBits
.ConstructionKind
= Record
.readInt();
1706 E
->CXXConstructExprBits
.IsImmediateEscalating
= Record
.readInt();
1707 E
->CXXConstructExprBits
.Loc
= readSourceLocation();
1708 E
->Constructor
= readDeclAs
<CXXConstructorDecl
>();
1709 E
->ParenOrBraceRange
= readSourceRange();
1711 for (unsigned I
= 0; I
!= NumArgs
; ++I
)
1712 E
->setArg(I
, Record
.readSubExpr());
1715 void ASTStmtReader::VisitCXXInheritedCtorInitExpr(CXXInheritedCtorInitExpr
*E
) {
1717 E
->Constructor
= readDeclAs
<CXXConstructorDecl
>();
1718 E
->Loc
= readSourceLocation();
1719 E
->ConstructsVirtualBase
= Record
.readInt();
1720 E
->InheritedFromVirtualBase
= Record
.readInt();
1723 void ASTStmtReader::VisitCXXTemporaryObjectExpr(CXXTemporaryObjectExpr
*E
) {
1724 VisitCXXConstructExpr(E
);
1725 E
->TSI
= readTypeSourceInfo();
1728 void ASTStmtReader::VisitLambdaExpr(LambdaExpr
*E
) {
1730 unsigned NumCaptures
= Record
.readInt();
1732 assert(NumCaptures
== E
->LambdaExprBits
.NumCaptures
);
1733 E
->IntroducerRange
= readSourceRange();
1734 E
->LambdaExprBits
.CaptureDefault
= Record
.readInt();
1735 E
->CaptureDefaultLoc
= readSourceLocation();
1736 E
->LambdaExprBits
.ExplicitParams
= Record
.readInt();
1737 E
->LambdaExprBits
.ExplicitResultType
= Record
.readInt();
1738 E
->ClosingBrace
= readSourceLocation();
1740 // Read capture initializers.
1741 for (LambdaExpr::capture_init_iterator C
= E
->capture_init_begin(),
1742 CEnd
= E
->capture_init_end();
1744 *C
= Record
.readSubExpr();
1746 // The body will be lazily deserialized when needed from the call operator
1751 ASTStmtReader::VisitCXXStdInitializerListExpr(CXXStdInitializerListExpr
*E
) {
1753 E
->SubExpr
= Record
.readSubExpr();
1756 void ASTStmtReader::VisitCXXNamedCastExpr(CXXNamedCastExpr
*E
) {
1757 VisitExplicitCastExpr(E
);
1758 SourceRange R
= readSourceRange();
1759 E
->Loc
= R
.getBegin();
1760 E
->RParenLoc
= R
.getEnd();
1761 R
= readSourceRange();
1762 E
->AngleBrackets
= R
;
1765 void ASTStmtReader::VisitCXXStaticCastExpr(CXXStaticCastExpr
*E
) {
1766 return VisitCXXNamedCastExpr(E
);
1769 void ASTStmtReader::VisitCXXDynamicCastExpr(CXXDynamicCastExpr
*E
) {
1770 return VisitCXXNamedCastExpr(E
);
1773 void ASTStmtReader::VisitCXXReinterpretCastExpr(CXXReinterpretCastExpr
*E
) {
1774 return VisitCXXNamedCastExpr(E
);
1777 void ASTStmtReader::VisitCXXAddrspaceCastExpr(CXXAddrspaceCastExpr
*E
) {
1778 return VisitCXXNamedCastExpr(E
);
1781 void ASTStmtReader::VisitCXXConstCastExpr(CXXConstCastExpr
*E
) {
1782 return VisitCXXNamedCastExpr(E
);
1785 void ASTStmtReader::VisitCXXFunctionalCastExpr(CXXFunctionalCastExpr
*E
) {
1786 VisitExplicitCastExpr(E
);
1787 E
->setLParenLoc(readSourceLocation());
1788 E
->setRParenLoc(readSourceLocation());
1791 void ASTStmtReader::VisitBuiltinBitCastExpr(BuiltinBitCastExpr
*E
) {
1792 VisitExplicitCastExpr(E
);
1793 E
->KWLoc
= readSourceLocation();
1794 E
->RParenLoc
= readSourceLocation();
1797 void ASTStmtReader::VisitUserDefinedLiteral(UserDefinedLiteral
*E
) {
1799 E
->UDSuffixLoc
= readSourceLocation();
1802 void ASTStmtReader::VisitCXXBoolLiteralExpr(CXXBoolLiteralExpr
*E
) {
1804 E
->setValue(Record
.readInt());
1805 E
->setLocation(readSourceLocation());
1808 void ASTStmtReader::VisitCXXNullPtrLiteralExpr(CXXNullPtrLiteralExpr
*E
) {
1810 E
->setLocation(readSourceLocation());
1813 void ASTStmtReader::VisitCXXTypeidExpr(CXXTypeidExpr
*E
) {
1815 E
->setSourceRange(readSourceRange());
1816 if (E
->isTypeOperand())
1817 E
->Operand
= readTypeSourceInfo();
1819 E
->Operand
= Record
.readSubExpr();
1822 void ASTStmtReader::VisitCXXThisExpr(CXXThisExpr
*E
) {
1824 E
->setLocation(readSourceLocation());
1825 E
->setImplicit(Record
.readInt());
1828 void ASTStmtReader::VisitCXXThrowExpr(CXXThrowExpr
*E
) {
1830 E
->CXXThrowExprBits
.ThrowLoc
= readSourceLocation();
1831 E
->Operand
= Record
.readSubExpr();
1832 E
->CXXThrowExprBits
.IsThrownVariableInScope
= Record
.readInt();
1835 void ASTStmtReader::VisitCXXDefaultArgExpr(CXXDefaultArgExpr
*E
) {
1837 E
->Param
= readDeclAs
<ParmVarDecl
>();
1838 E
->UsedContext
= readDeclAs
<DeclContext
>();
1839 E
->CXXDefaultArgExprBits
.Loc
= readSourceLocation();
1840 E
->CXXDefaultArgExprBits
.HasRewrittenInit
= Record
.readInt();
1841 if (E
->CXXDefaultArgExprBits
.HasRewrittenInit
)
1842 *E
->getTrailingObjects
<Expr
*>() = Record
.readSubExpr();
1845 void ASTStmtReader::VisitCXXDefaultInitExpr(CXXDefaultInitExpr
*E
) {
1847 E
->CXXDefaultInitExprBits
.HasRewrittenInit
= Record
.readInt();
1848 E
->Field
= readDeclAs
<FieldDecl
>();
1849 E
->UsedContext
= readDeclAs
<DeclContext
>();
1850 E
->CXXDefaultInitExprBits
.Loc
= readSourceLocation();
1851 if (E
->CXXDefaultInitExprBits
.HasRewrittenInit
)
1852 *E
->getTrailingObjects
<Expr
*>() = Record
.readSubExpr();
1855 void ASTStmtReader::VisitCXXBindTemporaryExpr(CXXBindTemporaryExpr
*E
) {
1857 E
->setTemporary(Record
.readCXXTemporary());
1858 E
->setSubExpr(Record
.readSubExpr());
1861 void ASTStmtReader::VisitCXXScalarValueInitExpr(CXXScalarValueInitExpr
*E
) {
1863 E
->TypeInfo
= readTypeSourceInfo();
1864 E
->CXXScalarValueInitExprBits
.RParenLoc
= readSourceLocation();
1867 void ASTStmtReader::VisitCXXNewExpr(CXXNewExpr
*E
) {
1870 bool IsArray
= Record
.readInt();
1871 bool HasInit
= Record
.readInt();
1872 unsigned NumPlacementArgs
= Record
.readInt();
1873 bool IsParenTypeId
= Record
.readInt();
1875 E
->CXXNewExprBits
.IsGlobalNew
= Record
.readInt();
1876 E
->CXXNewExprBits
.ShouldPassAlignment
= Record
.readInt();
1877 E
->CXXNewExprBits
.UsualArrayDeleteWantsSize
= Record
.readInt();
1878 E
->CXXNewExprBits
.StoredInitializationStyle
= Record
.readInt();
1880 assert((IsArray
== E
->isArray()) && "Wrong IsArray!");
1881 assert((HasInit
== E
->hasInitializer()) && "Wrong HasInit!");
1882 assert((NumPlacementArgs
== E
->getNumPlacementArgs()) &&
1883 "Wrong NumPlacementArgs!");
1884 assert((IsParenTypeId
== E
->isParenTypeId()) && "Wrong IsParenTypeId!");
1887 (void)NumPlacementArgs
;
1889 E
->setOperatorNew(readDeclAs
<FunctionDecl
>());
1890 E
->setOperatorDelete(readDeclAs
<FunctionDecl
>());
1891 E
->AllocatedTypeInfo
= readTypeSourceInfo();
1893 E
->getTrailingObjects
<SourceRange
>()[0] = readSourceRange();
1894 E
->Range
= readSourceRange();
1895 E
->DirectInitRange
= readSourceRange();
1897 // Install all the subexpressions.
1898 for (CXXNewExpr::raw_arg_iterator I
= E
->raw_arg_begin(),
1899 N
= E
->raw_arg_end();
1901 *I
= Record
.readSubStmt();
1904 void ASTStmtReader::VisitCXXDeleteExpr(CXXDeleteExpr
*E
) {
1906 E
->CXXDeleteExprBits
.GlobalDelete
= Record
.readInt();
1907 E
->CXXDeleteExprBits
.ArrayForm
= Record
.readInt();
1908 E
->CXXDeleteExprBits
.ArrayFormAsWritten
= Record
.readInt();
1909 E
->CXXDeleteExprBits
.UsualArrayDeleteWantsSize
= Record
.readInt();
1910 E
->OperatorDelete
= readDeclAs
<FunctionDecl
>();
1911 E
->Argument
= Record
.readSubExpr();
1912 E
->CXXDeleteExprBits
.Loc
= readSourceLocation();
1915 void ASTStmtReader::VisitCXXPseudoDestructorExpr(CXXPseudoDestructorExpr
*E
) {
1918 E
->Base
= Record
.readSubExpr();
1919 E
->IsArrow
= Record
.readInt();
1920 E
->OperatorLoc
= readSourceLocation();
1921 E
->QualifierLoc
= Record
.readNestedNameSpecifierLoc();
1922 E
->ScopeType
= readTypeSourceInfo();
1923 E
->ColonColonLoc
= readSourceLocation();
1924 E
->TildeLoc
= readSourceLocation();
1926 IdentifierInfo
*II
= Record
.readIdentifier();
1928 E
->setDestroyedType(II
, readSourceLocation());
1930 E
->setDestroyedType(readTypeSourceInfo());
1933 void ASTStmtReader::VisitExprWithCleanups(ExprWithCleanups
*E
) {
1936 unsigned NumObjects
= Record
.readInt();
1937 assert(NumObjects
== E
->getNumObjects());
1938 for (unsigned i
= 0; i
!= NumObjects
; ++i
) {
1939 unsigned CleanupKind
= Record
.readInt();
1940 ExprWithCleanups::CleanupObject Obj
;
1941 if (CleanupKind
== COK_Block
)
1942 Obj
= readDeclAs
<BlockDecl
>();
1943 else if (CleanupKind
== COK_CompoundLiteral
)
1944 Obj
= cast
<CompoundLiteralExpr
>(Record
.readSubExpr());
1946 llvm_unreachable("unexpected cleanup object type");
1947 E
->getTrailingObjects
<ExprWithCleanups::CleanupObject
>()[i
] = Obj
;
1950 E
->ExprWithCleanupsBits
.CleanupsHaveSideEffects
= Record
.readInt();
1951 E
->SubExpr
= Record
.readSubExpr();
1954 void ASTStmtReader::VisitCXXDependentScopeMemberExpr(
1955 CXXDependentScopeMemberExpr
*E
) {
1958 bool HasTemplateKWAndArgsInfo
= Record
.readInt();
1959 unsigned NumTemplateArgs
= Record
.readInt();
1960 bool HasFirstQualifierFoundInScope
= Record
.readInt();
1962 assert((HasTemplateKWAndArgsInfo
== E
->hasTemplateKWAndArgsInfo()) &&
1963 "Wrong HasTemplateKWAndArgsInfo!");
1965 (HasFirstQualifierFoundInScope
== E
->hasFirstQualifierFoundInScope()) &&
1966 "Wrong HasFirstQualifierFoundInScope!");
1968 if (HasTemplateKWAndArgsInfo
)
1969 ReadTemplateKWAndArgsInfo(
1970 *E
->getTrailingObjects
<ASTTemplateKWAndArgsInfo
>(),
1971 E
->getTrailingObjects
<TemplateArgumentLoc
>(), NumTemplateArgs
);
1973 assert((NumTemplateArgs
== E
->getNumTemplateArgs()) &&
1974 "Wrong NumTemplateArgs!");
1976 E
->CXXDependentScopeMemberExprBits
.IsArrow
= Record
.readInt();
1977 E
->CXXDependentScopeMemberExprBits
.OperatorLoc
= readSourceLocation();
1978 E
->BaseType
= Record
.readType();
1979 E
->QualifierLoc
= Record
.readNestedNameSpecifierLoc();
1980 E
->Base
= Record
.readSubExpr();
1982 if (HasFirstQualifierFoundInScope
)
1983 *E
->getTrailingObjects
<NamedDecl
*>() = readDeclAs
<NamedDecl
>();
1985 E
->MemberNameInfo
= Record
.readDeclarationNameInfo();
1989 ASTStmtReader::VisitDependentScopeDeclRefExpr(DependentScopeDeclRefExpr
*E
) {
1992 if (Record
.readInt()) // HasTemplateKWAndArgsInfo
1993 ReadTemplateKWAndArgsInfo(
1994 *E
->getTrailingObjects
<ASTTemplateKWAndArgsInfo
>(),
1995 E
->getTrailingObjects
<TemplateArgumentLoc
>(),
1996 /*NumTemplateArgs=*/Record
.readInt());
1998 E
->QualifierLoc
= Record
.readNestedNameSpecifierLoc();
1999 E
->NameInfo
= Record
.readDeclarationNameInfo();
2003 ASTStmtReader::VisitCXXUnresolvedConstructExpr(CXXUnresolvedConstructExpr
*E
) {
2005 assert(Record
.peekInt() == E
->getNumArgs() &&
2006 "Read wrong record during creation ?");
2008 for (unsigned I
= 0, N
= E
->getNumArgs(); I
!= N
; ++I
)
2009 E
->setArg(I
, Record
.readSubExpr());
2010 E
->TypeAndInitForm
.setPointer(readTypeSourceInfo());
2011 E
->setLParenLoc(readSourceLocation());
2012 E
->setRParenLoc(readSourceLocation());
2013 E
->TypeAndInitForm
.setInt(Record
.readInt());
2016 void ASTStmtReader::VisitOverloadExpr(OverloadExpr
*E
) {
2019 unsigned NumResults
= Record
.readInt();
2020 bool HasTemplateKWAndArgsInfo
= Record
.readInt();
2021 assert((E
->getNumDecls() == NumResults
) && "Wrong NumResults!");
2022 assert((E
->hasTemplateKWAndArgsInfo() == HasTemplateKWAndArgsInfo
) &&
2023 "Wrong HasTemplateKWAndArgsInfo!");
2025 if (HasTemplateKWAndArgsInfo
) {
2026 unsigned NumTemplateArgs
= Record
.readInt();
2027 ReadTemplateKWAndArgsInfo(*E
->getTrailingASTTemplateKWAndArgsInfo(),
2028 E
->getTrailingTemplateArgumentLoc(),
2030 assert((E
->getNumTemplateArgs() == NumTemplateArgs
) &&
2031 "Wrong NumTemplateArgs!");
2034 UnresolvedSet
<8> Decls
;
2035 for (unsigned I
= 0; I
!= NumResults
; ++I
) {
2036 auto *D
= readDeclAs
<NamedDecl
>();
2037 auto AS
= (AccessSpecifier
)Record
.readInt();
2038 Decls
.addDecl(D
, AS
);
2041 DeclAccessPair
*Results
= E
->getTrailingResults();
2042 UnresolvedSetIterator Iter
= Decls
.begin();
2043 for (unsigned I
= 0; I
!= NumResults
; ++I
) {
2044 Results
[I
] = (Iter
+ I
).getPair();
2047 E
->NameInfo
= Record
.readDeclarationNameInfo();
2048 E
->QualifierLoc
= Record
.readNestedNameSpecifierLoc();
2051 void ASTStmtReader::VisitUnresolvedMemberExpr(UnresolvedMemberExpr
*E
) {
2052 VisitOverloadExpr(E
);
2053 E
->UnresolvedMemberExprBits
.IsArrow
= Record
.readInt();
2054 E
->UnresolvedMemberExprBits
.HasUnresolvedUsing
= Record
.readInt();
2055 E
->Base
= Record
.readSubExpr();
2056 E
->BaseType
= Record
.readType();
2057 E
->OperatorLoc
= readSourceLocation();
2060 void ASTStmtReader::VisitUnresolvedLookupExpr(UnresolvedLookupExpr
*E
) {
2061 VisitOverloadExpr(E
);
2062 E
->UnresolvedLookupExprBits
.RequiresADL
= Record
.readInt();
2063 E
->UnresolvedLookupExprBits
.Overloaded
= Record
.readInt();
2064 E
->NamingClass
= readDeclAs
<CXXRecordDecl
>();
2067 void ASTStmtReader::VisitTypeTraitExpr(TypeTraitExpr
*E
) {
2069 E
->TypeTraitExprBits
.NumArgs
= Record
.readInt();
2070 E
->TypeTraitExprBits
.Kind
= Record
.readInt();
2071 E
->TypeTraitExprBits
.Value
= Record
.readInt();
2072 SourceRange Range
= readSourceRange();
2073 E
->Loc
= Range
.getBegin();
2074 E
->RParenLoc
= Range
.getEnd();
2076 auto **Args
= E
->getTrailingObjects
<TypeSourceInfo
*>();
2077 for (unsigned I
= 0, N
= E
->getNumArgs(); I
!= N
; ++I
)
2078 Args
[I
] = readTypeSourceInfo();
2081 void ASTStmtReader::VisitArrayTypeTraitExpr(ArrayTypeTraitExpr
*E
) {
2083 E
->ATT
= (ArrayTypeTrait
)Record
.readInt();
2084 E
->Value
= (unsigned int)Record
.readInt();
2085 SourceRange Range
= readSourceRange();
2086 E
->Loc
= Range
.getBegin();
2087 E
->RParen
= Range
.getEnd();
2088 E
->QueriedType
= readTypeSourceInfo();
2089 E
->Dimension
= Record
.readSubExpr();
2092 void ASTStmtReader::VisitExpressionTraitExpr(ExpressionTraitExpr
*E
) {
2094 E
->ET
= (ExpressionTrait
)Record
.readInt();
2095 E
->Value
= (bool)Record
.readInt();
2096 SourceRange Range
= readSourceRange();
2097 E
->QueriedExpression
= Record
.readSubExpr();
2098 E
->Loc
= Range
.getBegin();
2099 E
->RParen
= Range
.getEnd();
2102 void ASTStmtReader::VisitCXXNoexceptExpr(CXXNoexceptExpr
*E
) {
2104 E
->CXXNoexceptExprBits
.Value
= Record
.readInt();
2105 E
->Range
= readSourceRange();
2106 E
->Operand
= Record
.readSubExpr();
2109 void ASTStmtReader::VisitPackExpansionExpr(PackExpansionExpr
*E
) {
2111 E
->EllipsisLoc
= readSourceLocation();
2112 E
->NumExpansions
= Record
.readInt();
2113 E
->Pattern
= Record
.readSubExpr();
2116 void ASTStmtReader::VisitSizeOfPackExpr(SizeOfPackExpr
*E
) {
2118 unsigned NumPartialArgs
= Record
.readInt();
2119 E
->OperatorLoc
= readSourceLocation();
2120 E
->PackLoc
= readSourceLocation();
2121 E
->RParenLoc
= readSourceLocation();
2122 E
->Pack
= Record
.readDeclAs
<NamedDecl
>();
2123 if (E
->isPartiallySubstituted()) {
2124 assert(E
->Length
== NumPartialArgs
);
2125 for (auto *I
= E
->getTrailingObjects
<TemplateArgument
>(),
2126 *E
= I
+ NumPartialArgs
;
2128 new (I
) TemplateArgument(Record
.readTemplateArgument());
2129 } else if (!E
->isValueDependent()) {
2130 E
->Length
= Record
.readInt();
2134 void ASTStmtReader::VisitSubstNonTypeTemplateParmExpr(
2135 SubstNonTypeTemplateParmExpr
*E
) {
2137 E
->AssociatedDeclAndRef
.setPointer(readDeclAs
<Decl
>());
2138 E
->AssociatedDeclAndRef
.setInt(Record
.readInt());
2139 E
->Index
= Record
.readInt();
2140 E
->PackIndex
= Record
.readInt();
2141 E
->SubstNonTypeTemplateParmExprBits
.NameLoc
= readSourceLocation();
2142 E
->Replacement
= Record
.readSubExpr();
2145 void ASTStmtReader::VisitSubstNonTypeTemplateParmPackExpr(
2146 SubstNonTypeTemplateParmPackExpr
*E
) {
2148 E
->AssociatedDecl
= readDeclAs
<Decl
>();
2149 E
->Index
= Record
.readInt();
2150 TemplateArgument ArgPack
= Record
.readTemplateArgument();
2151 if (ArgPack
.getKind() != TemplateArgument::Pack
)
2154 E
->Arguments
= ArgPack
.pack_begin();
2155 E
->NumArguments
= ArgPack
.pack_size();
2156 E
->NameLoc
= readSourceLocation();
2159 void ASTStmtReader::VisitFunctionParmPackExpr(FunctionParmPackExpr
*E
) {
2161 E
->NumParameters
= Record
.readInt();
2162 E
->ParamPack
= readDeclAs
<ParmVarDecl
>();
2163 E
->NameLoc
= readSourceLocation();
2164 auto **Parms
= E
->getTrailingObjects
<VarDecl
*>();
2165 for (unsigned i
= 0, n
= E
->NumParameters
; i
!= n
; ++i
)
2166 Parms
[i
] = readDeclAs
<VarDecl
>();
2169 void ASTStmtReader::VisitMaterializeTemporaryExpr(MaterializeTemporaryExpr
*E
) {
2171 bool HasMaterialzedDecl
= Record
.readInt();
2172 if (HasMaterialzedDecl
)
2173 E
->State
= cast
<LifetimeExtendedTemporaryDecl
>(Record
.readDecl());
2175 E
->State
= Record
.readSubExpr();
2178 void ASTStmtReader::VisitCXXFoldExpr(CXXFoldExpr
*E
) {
2180 E
->LParenLoc
= readSourceLocation();
2181 E
->EllipsisLoc
= readSourceLocation();
2182 E
->RParenLoc
= readSourceLocation();
2183 E
->NumExpansions
= Record
.readInt();
2184 E
->SubExprs
[0] = Record
.readSubExpr();
2185 E
->SubExprs
[1] = Record
.readSubExpr();
2186 E
->SubExprs
[2] = Record
.readSubExpr();
2187 E
->Opcode
= (BinaryOperatorKind
)Record
.readInt();
2190 void ASTStmtReader::VisitCXXParenListInitExpr(CXXParenListInitExpr
*E
) {
2192 unsigned ExpectedNumExprs
= Record
.readInt();
2193 assert(E
->NumExprs
== ExpectedNumExprs
&&
2194 "expected number of expressions does not equal the actual number of "
2195 "serialized expressions.");
2196 E
->NumUserSpecifiedExprs
= Record
.readInt();
2197 E
->InitLoc
= readSourceLocation();
2198 E
->LParenLoc
= readSourceLocation();
2199 E
->RParenLoc
= readSourceLocation();
2200 for (unsigned I
= 0; I
< ExpectedNumExprs
; I
++)
2201 E
->getTrailingObjects
<Expr
*>()[I
] = Record
.readSubExpr();
2203 bool HasArrayFillerOrUnionDecl
= Record
.readBool();
2204 if (HasArrayFillerOrUnionDecl
) {
2205 bool HasArrayFiller
= Record
.readBool();
2206 if (HasArrayFiller
) {
2207 E
->setArrayFiller(Record
.readSubExpr());
2209 E
->setInitializedFieldInUnion(readDeclAs
<FieldDecl
>());
2212 E
->updateDependence();
2215 void ASTStmtReader::VisitOpaqueValueExpr(OpaqueValueExpr
*E
) {
2217 E
->SourceExpr
= Record
.readSubExpr();
2218 E
->OpaqueValueExprBits
.Loc
= readSourceLocation();
2219 E
->setIsUnique(Record
.readInt());
2222 void ASTStmtReader::VisitTypoExpr(TypoExpr
*E
) {
2223 llvm_unreachable("Cannot read TypoExpr nodes");
2226 void ASTStmtReader::VisitRecoveryExpr(RecoveryExpr
*E
) {
2228 unsigned NumArgs
= Record
.readInt();
2229 E
->BeginLoc
= readSourceLocation();
2230 E
->EndLoc
= readSourceLocation();
2231 assert((NumArgs
+ 0LL ==
2232 std::distance(E
->children().begin(), E
->children().end())) &&
2235 for (Stmt
*&Child
: E
->children())
2236 Child
= Record
.readSubStmt();
2239 //===----------------------------------------------------------------------===//
2240 // Microsoft Expressions and Statements
2241 //===----------------------------------------------------------------------===//
2242 void ASTStmtReader::VisitMSPropertyRefExpr(MSPropertyRefExpr
*E
) {
2244 E
->IsArrow
= (Record
.readInt() != 0);
2245 E
->BaseExpr
= Record
.readSubExpr();
2246 E
->QualifierLoc
= Record
.readNestedNameSpecifierLoc();
2247 E
->MemberLoc
= readSourceLocation();
2248 E
->TheDecl
= readDeclAs
<MSPropertyDecl
>();
2251 void ASTStmtReader::VisitMSPropertySubscriptExpr(MSPropertySubscriptExpr
*E
) {
2253 E
->setBase(Record
.readSubExpr());
2254 E
->setIdx(Record
.readSubExpr());
2255 E
->setRBracketLoc(readSourceLocation());
2258 void ASTStmtReader::VisitCXXUuidofExpr(CXXUuidofExpr
*E
) {
2260 E
->setSourceRange(readSourceRange());
2261 E
->Guid
= readDeclAs
<MSGuidDecl
>();
2262 if (E
->isTypeOperand())
2263 E
->Operand
= readTypeSourceInfo();
2265 E
->Operand
= Record
.readSubExpr();
2268 void ASTStmtReader::VisitSEHLeaveStmt(SEHLeaveStmt
*S
) {
2270 S
->setLeaveLoc(readSourceLocation());
2273 void ASTStmtReader::VisitSEHExceptStmt(SEHExceptStmt
*S
) {
2275 S
->Loc
= readSourceLocation();
2276 S
->Children
[SEHExceptStmt::FILTER_EXPR
] = Record
.readSubStmt();
2277 S
->Children
[SEHExceptStmt::BLOCK
] = Record
.readSubStmt();
2280 void ASTStmtReader::VisitSEHFinallyStmt(SEHFinallyStmt
*S
) {
2282 S
->Loc
= readSourceLocation();
2283 S
->Block
= Record
.readSubStmt();
2286 void ASTStmtReader::VisitSEHTryStmt(SEHTryStmt
*S
) {
2288 S
->IsCXXTry
= Record
.readInt();
2289 S
->TryLoc
= readSourceLocation();
2290 S
->Children
[SEHTryStmt::TRY
] = Record
.readSubStmt();
2291 S
->Children
[SEHTryStmt::HANDLER
] = Record
.readSubStmt();
2294 //===----------------------------------------------------------------------===//
2295 // CUDA Expressions and Statements
2296 //===----------------------------------------------------------------------===//
2298 void ASTStmtReader::VisitCUDAKernelCallExpr(CUDAKernelCallExpr
*E
) {
2300 E
->setPreArg(CUDAKernelCallExpr::CONFIG
, Record
.readSubExpr());
2303 //===----------------------------------------------------------------------===//
2304 // OpenCL Expressions and Statements.
2305 //===----------------------------------------------------------------------===//
2306 void ASTStmtReader::VisitAsTypeExpr(AsTypeExpr
*E
) {
2308 E
->BuiltinLoc
= readSourceLocation();
2309 E
->RParenLoc
= readSourceLocation();
2310 E
->SrcExpr
= Record
.readSubExpr();
2313 //===----------------------------------------------------------------------===//
2314 // OpenMP Directives.
2315 //===----------------------------------------------------------------------===//
2317 void ASTStmtReader::VisitOMPCanonicalLoop(OMPCanonicalLoop
*S
) {
2319 for (Stmt
*&SubStmt
: S
->SubStmts
)
2320 SubStmt
= Record
.readSubStmt();
2323 void ASTStmtReader::VisitOMPExecutableDirective(OMPExecutableDirective
*E
) {
2324 Record
.readOMPChildren(E
->Data
);
2325 E
->setLocStart(readSourceLocation());
2326 E
->setLocEnd(readSourceLocation());
2327 E
->setMappedDirective(Record
.readEnum
<OpenMPDirectiveKind
>());
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::VisitOMPScopeDirective(OMPScopeDirective
*D
) {
2395 VisitOMPExecutableDirective(D
);
2398 void ASTStmtReader::VisitOMPSingleDirective(OMPSingleDirective
*D
) {
2400 VisitOMPExecutableDirective(D
);
2403 void ASTStmtReader::VisitOMPMasterDirective(OMPMasterDirective
*D
) {
2405 VisitOMPExecutableDirective(D
);
2408 void ASTStmtReader::VisitOMPCriticalDirective(OMPCriticalDirective
*D
) {
2410 VisitOMPExecutableDirective(D
);
2411 D
->DirName
= Record
.readDeclarationNameInfo();
2414 void ASTStmtReader::VisitOMPParallelForDirective(OMPParallelForDirective
*D
) {
2415 VisitOMPLoopDirective(D
);
2416 D
->setHasCancel(Record
.readBool());
2419 void ASTStmtReader::VisitOMPParallelForSimdDirective(
2420 OMPParallelForSimdDirective
*D
) {
2421 VisitOMPLoopDirective(D
);
2424 void ASTStmtReader::VisitOMPParallelMasterDirective(
2425 OMPParallelMasterDirective
*D
) {
2427 VisitOMPExecutableDirective(D
);
2430 void ASTStmtReader::VisitOMPParallelMaskedDirective(
2431 OMPParallelMaskedDirective
*D
) {
2433 VisitOMPExecutableDirective(D
);
2436 void ASTStmtReader::VisitOMPParallelSectionsDirective(
2437 OMPParallelSectionsDirective
*D
) {
2439 VisitOMPExecutableDirective(D
);
2440 D
->setHasCancel(Record
.readBool());
2443 void ASTStmtReader::VisitOMPTaskDirective(OMPTaskDirective
*D
) {
2445 VisitOMPExecutableDirective(D
);
2446 D
->setHasCancel(Record
.readBool());
2449 void ASTStmtReader::VisitOMPTaskyieldDirective(OMPTaskyieldDirective
*D
) {
2451 VisitOMPExecutableDirective(D
);
2454 void ASTStmtReader::VisitOMPBarrierDirective(OMPBarrierDirective
*D
) {
2456 VisitOMPExecutableDirective(D
);
2459 void ASTStmtReader::VisitOMPTaskwaitDirective(OMPTaskwaitDirective
*D
) {
2461 // The NumClauses field was read in ReadStmtFromStream.
2463 VisitOMPExecutableDirective(D
);
2466 void ASTStmtReader::VisitOMPErrorDirective(OMPErrorDirective
*D
) {
2468 // The NumClauses field was read in ReadStmtFromStream.
2470 VisitOMPExecutableDirective(D
);
2473 void ASTStmtReader::VisitOMPTaskgroupDirective(OMPTaskgroupDirective
*D
) {
2475 VisitOMPExecutableDirective(D
);
2478 void ASTStmtReader::VisitOMPFlushDirective(OMPFlushDirective
*D
) {
2480 VisitOMPExecutableDirective(D
);
2483 void ASTStmtReader::VisitOMPDepobjDirective(OMPDepobjDirective
*D
) {
2485 VisitOMPExecutableDirective(D
);
2488 void ASTStmtReader::VisitOMPScanDirective(OMPScanDirective
*D
) {
2490 VisitOMPExecutableDirective(D
);
2493 void ASTStmtReader::VisitOMPOrderedDirective(OMPOrderedDirective
*D
) {
2495 VisitOMPExecutableDirective(D
);
2498 void ASTStmtReader::VisitOMPAtomicDirective(OMPAtomicDirective
*D
) {
2500 VisitOMPExecutableDirective(D
);
2501 D
->Flags
.IsXLHSInRHSPart
= Record
.readBool() ? 1 : 0;
2502 D
->Flags
.IsPostfixUpdate
= Record
.readBool() ? 1 : 0;
2503 D
->Flags
.IsFailOnly
= Record
.readBool() ? 1 : 0;
2506 void ASTStmtReader::VisitOMPTargetDirective(OMPTargetDirective
*D
) {
2508 VisitOMPExecutableDirective(D
);
2511 void ASTStmtReader::VisitOMPTargetDataDirective(OMPTargetDataDirective
*D
) {
2513 VisitOMPExecutableDirective(D
);
2516 void ASTStmtReader::VisitOMPTargetEnterDataDirective(
2517 OMPTargetEnterDataDirective
*D
) {
2519 VisitOMPExecutableDirective(D
);
2522 void ASTStmtReader::VisitOMPTargetExitDataDirective(
2523 OMPTargetExitDataDirective
*D
) {
2525 VisitOMPExecutableDirective(D
);
2528 void ASTStmtReader::VisitOMPTargetParallelDirective(
2529 OMPTargetParallelDirective
*D
) {
2531 VisitOMPExecutableDirective(D
);
2532 D
->setHasCancel(Record
.readBool());
2535 void ASTStmtReader::VisitOMPTargetParallelForDirective(
2536 OMPTargetParallelForDirective
*D
) {
2537 VisitOMPLoopDirective(D
);
2538 D
->setHasCancel(Record
.readBool());
2541 void ASTStmtReader::VisitOMPTeamsDirective(OMPTeamsDirective
*D
) {
2543 VisitOMPExecutableDirective(D
);
2546 void ASTStmtReader::VisitOMPCancellationPointDirective(
2547 OMPCancellationPointDirective
*D
) {
2549 VisitOMPExecutableDirective(D
);
2550 D
->setCancelRegion(Record
.readEnum
<OpenMPDirectiveKind
>());
2553 void ASTStmtReader::VisitOMPCancelDirective(OMPCancelDirective
*D
) {
2555 VisitOMPExecutableDirective(D
);
2556 D
->setCancelRegion(Record
.readEnum
<OpenMPDirectiveKind
>());
2559 void ASTStmtReader::VisitOMPTaskLoopDirective(OMPTaskLoopDirective
*D
) {
2560 VisitOMPLoopDirective(D
);
2561 D
->setHasCancel(Record
.readBool());
2564 void ASTStmtReader::VisitOMPTaskLoopSimdDirective(OMPTaskLoopSimdDirective
*D
) {
2565 VisitOMPLoopDirective(D
);
2568 void ASTStmtReader::VisitOMPMasterTaskLoopDirective(
2569 OMPMasterTaskLoopDirective
*D
) {
2570 VisitOMPLoopDirective(D
);
2571 D
->setHasCancel(Record
.readBool());
2574 void ASTStmtReader::VisitOMPMaskedTaskLoopDirective(
2575 OMPMaskedTaskLoopDirective
*D
) {
2576 VisitOMPLoopDirective(D
);
2577 D
->setHasCancel(Record
.readBool());
2580 void ASTStmtReader::VisitOMPMasterTaskLoopSimdDirective(
2581 OMPMasterTaskLoopSimdDirective
*D
) {
2582 VisitOMPLoopDirective(D
);
2585 void ASTStmtReader::VisitOMPMaskedTaskLoopSimdDirective(
2586 OMPMaskedTaskLoopSimdDirective
*D
) {
2587 VisitOMPLoopDirective(D
);
2590 void ASTStmtReader::VisitOMPParallelMasterTaskLoopDirective(
2591 OMPParallelMasterTaskLoopDirective
*D
) {
2592 VisitOMPLoopDirective(D
);
2593 D
->setHasCancel(Record
.readBool());
2596 void ASTStmtReader::VisitOMPParallelMaskedTaskLoopDirective(
2597 OMPParallelMaskedTaskLoopDirective
*D
) {
2598 VisitOMPLoopDirective(D
);
2599 D
->setHasCancel(Record
.readBool());
2602 void ASTStmtReader::VisitOMPParallelMasterTaskLoopSimdDirective(
2603 OMPParallelMasterTaskLoopSimdDirective
*D
) {
2604 VisitOMPLoopDirective(D
);
2607 void ASTStmtReader::VisitOMPParallelMaskedTaskLoopSimdDirective(
2608 OMPParallelMaskedTaskLoopSimdDirective
*D
) {
2609 VisitOMPLoopDirective(D
);
2612 void ASTStmtReader::VisitOMPDistributeDirective(OMPDistributeDirective
*D
) {
2613 VisitOMPLoopDirective(D
);
2616 void ASTStmtReader::VisitOMPTargetUpdateDirective(OMPTargetUpdateDirective
*D
) {
2618 VisitOMPExecutableDirective(D
);
2621 void ASTStmtReader::VisitOMPDistributeParallelForDirective(
2622 OMPDistributeParallelForDirective
*D
) {
2623 VisitOMPLoopDirective(D
);
2624 D
->setHasCancel(Record
.readBool());
2627 void ASTStmtReader::VisitOMPDistributeParallelForSimdDirective(
2628 OMPDistributeParallelForSimdDirective
*D
) {
2629 VisitOMPLoopDirective(D
);
2632 void ASTStmtReader::VisitOMPDistributeSimdDirective(
2633 OMPDistributeSimdDirective
*D
) {
2634 VisitOMPLoopDirective(D
);
2637 void ASTStmtReader::VisitOMPTargetParallelForSimdDirective(
2638 OMPTargetParallelForSimdDirective
*D
) {
2639 VisitOMPLoopDirective(D
);
2642 void ASTStmtReader::VisitOMPTargetSimdDirective(OMPTargetSimdDirective
*D
) {
2643 VisitOMPLoopDirective(D
);
2646 void ASTStmtReader::VisitOMPTeamsDistributeDirective(
2647 OMPTeamsDistributeDirective
*D
) {
2648 VisitOMPLoopDirective(D
);
2651 void ASTStmtReader::VisitOMPTeamsDistributeSimdDirective(
2652 OMPTeamsDistributeSimdDirective
*D
) {
2653 VisitOMPLoopDirective(D
);
2656 void ASTStmtReader::VisitOMPTeamsDistributeParallelForSimdDirective(
2657 OMPTeamsDistributeParallelForSimdDirective
*D
) {
2658 VisitOMPLoopDirective(D
);
2661 void ASTStmtReader::VisitOMPTeamsDistributeParallelForDirective(
2662 OMPTeamsDistributeParallelForDirective
*D
) {
2663 VisitOMPLoopDirective(D
);
2664 D
->setHasCancel(Record
.readBool());
2667 void ASTStmtReader::VisitOMPTargetTeamsDirective(OMPTargetTeamsDirective
*D
) {
2669 VisitOMPExecutableDirective(D
);
2672 void ASTStmtReader::VisitOMPTargetTeamsDistributeDirective(
2673 OMPTargetTeamsDistributeDirective
*D
) {
2674 VisitOMPLoopDirective(D
);
2677 void ASTStmtReader::VisitOMPTargetTeamsDistributeParallelForDirective(
2678 OMPTargetTeamsDistributeParallelForDirective
*D
) {
2679 VisitOMPLoopDirective(D
);
2680 D
->setHasCancel(Record
.readBool());
2683 void ASTStmtReader::VisitOMPTargetTeamsDistributeParallelForSimdDirective(
2684 OMPTargetTeamsDistributeParallelForSimdDirective
*D
) {
2685 VisitOMPLoopDirective(D
);
2688 void ASTStmtReader::VisitOMPTargetTeamsDistributeSimdDirective(
2689 OMPTargetTeamsDistributeSimdDirective
*D
) {
2690 VisitOMPLoopDirective(D
);
2693 void ASTStmtReader::VisitOMPInteropDirective(OMPInteropDirective
*D
) {
2695 VisitOMPExecutableDirective(D
);
2698 void ASTStmtReader::VisitOMPDispatchDirective(OMPDispatchDirective
*D
) {
2700 VisitOMPExecutableDirective(D
);
2701 D
->setTargetCallLoc(Record
.readSourceLocation());
2704 void ASTStmtReader::VisitOMPMaskedDirective(OMPMaskedDirective
*D
) {
2706 VisitOMPExecutableDirective(D
);
2709 void ASTStmtReader::VisitOMPGenericLoopDirective(OMPGenericLoopDirective
*D
) {
2710 VisitOMPLoopDirective(D
);
2713 void ASTStmtReader::VisitOMPTeamsGenericLoopDirective(
2714 OMPTeamsGenericLoopDirective
*D
) {
2715 VisitOMPLoopDirective(D
);
2718 void ASTStmtReader::VisitOMPTargetTeamsGenericLoopDirective(
2719 OMPTargetTeamsGenericLoopDirective
*D
) {
2720 VisitOMPLoopDirective(D
);
2723 void ASTStmtReader::VisitOMPParallelGenericLoopDirective(
2724 OMPParallelGenericLoopDirective
*D
) {
2725 VisitOMPLoopDirective(D
);
2728 void ASTStmtReader::VisitOMPTargetParallelGenericLoopDirective(
2729 OMPTargetParallelGenericLoopDirective
*D
) {
2730 VisitOMPLoopDirective(D
);
2733 //===----------------------------------------------------------------------===//
2734 // ASTReader Implementation
2735 //===----------------------------------------------------------------------===//
2737 Stmt
*ASTReader::ReadStmt(ModuleFile
&F
) {
2738 switch (ReadingKind
) {
2740 llvm_unreachable("should not call this when not reading anything");
2743 return ReadStmtFromStream(F
);
2745 return ReadSubStmt();
2748 llvm_unreachable("ReadingKind not set ?");
2751 Expr
*ASTReader::ReadExpr(ModuleFile
&F
) {
2752 return cast_or_null
<Expr
>(ReadStmt(F
));
2755 Expr
*ASTReader::ReadSubExpr() {
2756 return cast_or_null
<Expr
>(ReadSubStmt());
2759 // Within the bitstream, expressions are stored in Reverse Polish
2760 // Notation, with each of the subexpressions preceding the
2761 // expression they are stored in. Subexpressions are stored from last to first.
2762 // To evaluate expressions, we continue reading expressions and placing them on
2763 // the stack, with expressions having operands removing those operands from the
2764 // stack. Evaluation terminates when we see a STMT_STOP record, and
2765 // the single remaining expression on the stack is our result.
2766 Stmt
*ASTReader::ReadStmtFromStream(ModuleFile
&F
) {
2767 ReadingKindTracker
ReadingKind(Read_Stmt
, *this);
2768 llvm::BitstreamCursor
&Cursor
= F
.DeclsCursor
;
2770 // Map of offset to previously deserialized stmt. The offset points
2771 // just after the stmt record.
2772 llvm::DenseMap
<uint64_t, Stmt
*> StmtEntries
;
2775 unsigned PrevNumStmts
= StmtStack
.size();
2778 ASTRecordReader
Record(*this, F
);
2779 ASTStmtReader
Reader(Record
, Cursor
);
2780 Stmt::EmptyShell Empty
;
2783 llvm::Expected
<llvm::BitstreamEntry
> MaybeEntry
=
2784 Cursor
.advanceSkippingSubblocks();
2786 Error(toString(MaybeEntry
.takeError()));
2789 llvm::BitstreamEntry Entry
= MaybeEntry
.get();
2791 switch (Entry
.Kind
) {
2792 case llvm::BitstreamEntry::SubBlock
: // Handled for us already.
2793 case llvm::BitstreamEntry::Error
:
2794 Error("malformed block record in AST file");
2796 case llvm::BitstreamEntry::EndBlock
:
2798 case llvm::BitstreamEntry::Record
:
2799 // The interesting case.
2803 ASTContext
&Context
= getContext();
2805 bool Finished
= false;
2806 bool IsStmtReference
= false;
2807 Expected
<unsigned> MaybeStmtCode
= Record
.readRecord(Cursor
, Entry
.ID
);
2808 if (!MaybeStmtCode
) {
2809 Error(toString(MaybeStmtCode
.takeError()));
2812 switch ((StmtCode
)MaybeStmtCode
.get()) {
2818 IsStmtReference
= true;
2819 assert(StmtEntries
.contains(Record
[0]) &&
2820 "No stmt was recorded for this offset reference!");
2821 S
= StmtEntries
[Record
.readInt()];
2829 S
= new (Context
) NullStmt(Empty
);
2833 S
= CompoundStmt::CreateEmpty(
2834 Context
, /*NumStmts=*/Record
[ASTStmtReader::NumStmtFields
],
2835 /*HasFPFeatures=*/Record
[ASTStmtReader::NumStmtFields
+ 1]);
2839 S
= CaseStmt::CreateEmpty(
2841 /*CaseStmtIsGNURange*/ Record
[ASTStmtReader::NumStmtFields
+ 3]);
2845 S
= new (Context
) DefaultStmt(Empty
);
2849 S
= new (Context
) LabelStmt(Empty
);
2852 case STMT_ATTRIBUTED
:
2853 S
= AttributedStmt::CreateEmpty(
2855 /*NumAttrs*/Record
[ASTStmtReader::NumStmtFields
]);
2859 S
= IfStmt::CreateEmpty(
2861 /* HasElse=*/Record
[ASTStmtReader::NumStmtFields
],
2862 /* HasVar=*/Record
[ASTStmtReader::NumStmtFields
+ 1],
2863 /* HasInit=*/Record
[ASTStmtReader::NumStmtFields
+ 2]);
2867 S
= SwitchStmt::CreateEmpty(
2869 /* HasInit=*/Record
[ASTStmtReader::NumStmtFields
],
2870 /* HasVar=*/Record
[ASTStmtReader::NumStmtFields
+ 1]);
2874 S
= WhileStmt::CreateEmpty(
2876 /* HasVar=*/Record
[ASTStmtReader::NumStmtFields
]);
2880 S
= new (Context
) DoStmt(Empty
);
2884 S
= new (Context
) ForStmt(Empty
);
2888 S
= new (Context
) GotoStmt(Empty
);
2891 case STMT_INDIRECT_GOTO
:
2892 S
= new (Context
) IndirectGotoStmt(Empty
);
2896 S
= new (Context
) ContinueStmt(Empty
);
2900 S
= new (Context
) BreakStmt(Empty
);
2904 S
= ReturnStmt::CreateEmpty(
2905 Context
, /* HasNRVOCandidate=*/Record
[ASTStmtReader::NumStmtFields
]);
2909 S
= new (Context
) DeclStmt(Empty
);
2913 S
= new (Context
) GCCAsmStmt(Empty
);
2917 S
= new (Context
) MSAsmStmt(Empty
);
2921 S
= CapturedStmt::CreateDeserialized(
2922 Context
, Record
[ASTStmtReader::NumStmtFields
]);
2926 S
= ConstantExpr::CreateEmpty(
2927 Context
, static_cast<ConstantExpr::ResultStorageKind
>(
2928 /*StorageKind=*/Record
[ASTStmtReader::NumExprFields
]));
2931 case EXPR_SYCL_UNIQUE_STABLE_NAME
:
2932 S
= SYCLUniqueStableNameExpr::CreateEmpty(Context
);
2935 case EXPR_PREDEFINED
:
2936 S
= PredefinedExpr::CreateEmpty(
2938 /*HasFunctionName*/ Record
[ASTStmtReader::NumExprFields
]);
2942 S
= DeclRefExpr::CreateEmpty(
2944 /*HasQualifier=*/Record
[ASTStmtReader::NumExprFields
],
2945 /*HasFoundDecl=*/Record
[ASTStmtReader::NumExprFields
+ 1],
2946 /*HasTemplateKWAndArgsInfo=*/Record
[ASTStmtReader::NumExprFields
+ 2],
2947 /*NumTemplateArgs=*/
2948 Record
[ASTStmtReader::NumExprFields
+ 2]
2949 ? Record
[ASTStmtReader::NumExprFields
+ 7]
2953 case EXPR_INTEGER_LITERAL
:
2954 S
= IntegerLiteral::Create(Context
, Empty
);
2957 case EXPR_FIXEDPOINT_LITERAL
:
2958 S
= FixedPointLiteral::Create(Context
, Empty
);
2961 case EXPR_FLOATING_LITERAL
:
2962 S
= FloatingLiteral::Create(Context
, Empty
);
2965 case EXPR_IMAGINARY_LITERAL
:
2966 S
= new (Context
) ImaginaryLiteral(Empty
);
2969 case EXPR_STRING_LITERAL
:
2970 S
= StringLiteral::CreateEmpty(
2972 /* NumConcatenated=*/Record
[ASTStmtReader::NumExprFields
],
2973 /* Length=*/Record
[ASTStmtReader::NumExprFields
+ 1],
2974 /* CharByteWidth=*/Record
[ASTStmtReader::NumExprFields
+ 2]);
2977 case EXPR_CHARACTER_LITERAL
:
2978 S
= new (Context
) CharacterLiteral(Empty
);
2982 S
= new (Context
) ParenExpr(Empty
);
2985 case EXPR_PAREN_LIST
:
2986 S
= ParenListExpr::CreateEmpty(
2988 /* NumExprs=*/Record
[ASTStmtReader::NumExprFields
]);
2991 case EXPR_UNARY_OPERATOR
:
2992 S
= UnaryOperator::CreateEmpty(Context
,
2993 Record
[ASTStmtReader::NumExprFields
]);
2997 S
= OffsetOfExpr::CreateEmpty(Context
,
2998 Record
[ASTStmtReader::NumExprFields
],
2999 Record
[ASTStmtReader::NumExprFields
+ 1]);
3002 case EXPR_SIZEOF_ALIGN_OF
:
3003 S
= new (Context
) UnaryExprOrTypeTraitExpr(Empty
);
3006 case EXPR_ARRAY_SUBSCRIPT
:
3007 S
= new (Context
) ArraySubscriptExpr(Empty
);
3010 case EXPR_MATRIX_SUBSCRIPT
:
3011 S
= new (Context
) MatrixSubscriptExpr(Empty
);
3014 case EXPR_OMP_ARRAY_SECTION
:
3015 S
= new (Context
) OMPArraySectionExpr(Empty
);
3018 case EXPR_OMP_ARRAY_SHAPING
:
3019 S
= OMPArrayShapingExpr::CreateEmpty(
3020 Context
, Record
[ASTStmtReader::NumExprFields
]);
3023 case EXPR_OMP_ITERATOR
:
3024 S
= OMPIteratorExpr::CreateEmpty(Context
,
3025 Record
[ASTStmtReader::NumExprFields
]);
3029 S
= CallExpr::CreateEmpty(
3030 Context
, /*NumArgs=*/Record
[ASTStmtReader::NumExprFields
],
3031 /*HasFPFeatures=*/Record
[ASTStmtReader::NumExprFields
+ 1], Empty
);
3035 S
= RecoveryExpr::CreateEmpty(
3036 Context
, /*NumArgs=*/Record
[ASTStmtReader::NumExprFields
]);
3040 S
= MemberExpr::CreateEmpty(Context
, Record
[ASTStmtReader::NumExprFields
],
3041 Record
[ASTStmtReader::NumExprFields
+ 1],
3042 Record
[ASTStmtReader::NumExprFields
+ 2],
3043 Record
[ASTStmtReader::NumExprFields
+ 3]);
3046 case EXPR_BINARY_OPERATOR
:
3047 S
= BinaryOperator::CreateEmpty(Context
,
3048 Record
[ASTStmtReader::NumExprFields
]);
3051 case EXPR_COMPOUND_ASSIGN_OPERATOR
:
3052 S
= CompoundAssignOperator::CreateEmpty(
3053 Context
, Record
[ASTStmtReader::NumExprFields
]);
3056 case EXPR_CONDITIONAL_OPERATOR
:
3057 S
= new (Context
) ConditionalOperator(Empty
);
3060 case EXPR_BINARY_CONDITIONAL_OPERATOR
:
3061 S
= new (Context
) BinaryConditionalOperator(Empty
);
3064 case EXPR_IMPLICIT_CAST
:
3065 S
= ImplicitCastExpr::CreateEmpty(
3067 /*PathSize*/ Record
[ASTStmtReader::NumExprFields
],
3068 /*HasFPFeatures*/ Record
[ASTStmtReader::NumExprFields
+ 1]);
3071 case EXPR_CSTYLE_CAST
:
3072 S
= CStyleCastExpr::CreateEmpty(
3074 /*PathSize*/ Record
[ASTStmtReader::NumExprFields
],
3075 /*HasFPFeatures*/ Record
[ASTStmtReader::NumExprFields
+ 1]);
3078 case EXPR_COMPOUND_LITERAL
:
3079 S
= new (Context
) CompoundLiteralExpr(Empty
);
3082 case EXPR_EXT_VECTOR_ELEMENT
:
3083 S
= new (Context
) ExtVectorElementExpr(Empty
);
3086 case EXPR_INIT_LIST
:
3087 S
= new (Context
) InitListExpr(Empty
);
3090 case EXPR_DESIGNATED_INIT
:
3091 S
= DesignatedInitExpr::CreateEmpty(Context
,
3092 Record
[ASTStmtReader::NumExprFields
] - 1);
3096 case EXPR_DESIGNATED_INIT_UPDATE
:
3097 S
= new (Context
) DesignatedInitUpdateExpr(Empty
);
3100 case EXPR_IMPLICIT_VALUE_INIT
:
3101 S
= new (Context
) ImplicitValueInitExpr(Empty
);
3105 S
= new (Context
) NoInitExpr(Empty
);
3108 case EXPR_ARRAY_INIT_LOOP
:
3109 S
= new (Context
) ArrayInitLoopExpr(Empty
);
3112 case EXPR_ARRAY_INIT_INDEX
:
3113 S
= new (Context
) ArrayInitIndexExpr(Empty
);
3117 S
= new (Context
) VAArgExpr(Empty
);
3120 case EXPR_SOURCE_LOC
:
3121 S
= new (Context
) SourceLocExpr(Empty
);
3124 case EXPR_ADDR_LABEL
:
3125 S
= new (Context
) AddrLabelExpr(Empty
);
3129 S
= new (Context
) StmtExpr(Empty
);
3133 S
= new (Context
) ChooseExpr(Empty
);
3137 S
= new (Context
) GNUNullExpr(Empty
);
3140 case EXPR_SHUFFLE_VECTOR
:
3141 S
= new (Context
) ShuffleVectorExpr(Empty
);
3144 case EXPR_CONVERT_VECTOR
:
3145 S
= new (Context
) ConvertVectorExpr(Empty
);
3149 S
= new (Context
) BlockExpr(Empty
);
3152 case EXPR_GENERIC_SELECTION
:
3153 S
= GenericSelectionExpr::CreateEmpty(
3155 /*NumAssocs=*/Record
[ASTStmtReader::NumExprFields
]);
3158 case EXPR_OBJC_STRING_LITERAL
:
3159 S
= new (Context
) ObjCStringLiteral(Empty
);
3162 case EXPR_OBJC_BOXED_EXPRESSION
:
3163 S
= new (Context
) ObjCBoxedExpr(Empty
);
3166 case EXPR_OBJC_ARRAY_LITERAL
:
3167 S
= ObjCArrayLiteral::CreateEmpty(Context
,
3168 Record
[ASTStmtReader::NumExprFields
]);
3171 case EXPR_OBJC_DICTIONARY_LITERAL
:
3172 S
= ObjCDictionaryLiteral::CreateEmpty(Context
,
3173 Record
[ASTStmtReader::NumExprFields
],
3174 Record
[ASTStmtReader::NumExprFields
+ 1]);
3177 case EXPR_OBJC_ENCODE
:
3178 S
= new (Context
) ObjCEncodeExpr(Empty
);
3181 case EXPR_OBJC_SELECTOR_EXPR
:
3182 S
= new (Context
) ObjCSelectorExpr(Empty
);
3185 case EXPR_OBJC_PROTOCOL_EXPR
:
3186 S
= new (Context
) ObjCProtocolExpr(Empty
);
3189 case EXPR_OBJC_IVAR_REF_EXPR
:
3190 S
= new (Context
) ObjCIvarRefExpr(Empty
);
3193 case EXPR_OBJC_PROPERTY_REF_EXPR
:
3194 S
= new (Context
) ObjCPropertyRefExpr(Empty
);
3197 case EXPR_OBJC_SUBSCRIPT_REF_EXPR
:
3198 S
= new (Context
) ObjCSubscriptRefExpr(Empty
);
3201 case EXPR_OBJC_KVC_REF_EXPR
:
3202 llvm_unreachable("mismatching AST file");
3204 case EXPR_OBJC_MESSAGE_EXPR
:
3205 S
= ObjCMessageExpr::CreateEmpty(Context
,
3206 Record
[ASTStmtReader::NumExprFields
],
3207 Record
[ASTStmtReader::NumExprFields
+ 1]);
3211 S
= new (Context
) ObjCIsaExpr(Empty
);
3214 case EXPR_OBJC_INDIRECT_COPY_RESTORE
:
3215 S
= new (Context
) ObjCIndirectCopyRestoreExpr(Empty
);
3218 case EXPR_OBJC_BRIDGED_CAST
:
3219 S
= new (Context
) ObjCBridgedCastExpr(Empty
);
3222 case STMT_OBJC_FOR_COLLECTION
:
3223 S
= new (Context
) ObjCForCollectionStmt(Empty
);
3226 case STMT_OBJC_CATCH
:
3227 S
= new (Context
) ObjCAtCatchStmt(Empty
);
3230 case STMT_OBJC_FINALLY
:
3231 S
= new (Context
) ObjCAtFinallyStmt(Empty
);
3234 case STMT_OBJC_AT_TRY
:
3235 S
= ObjCAtTryStmt::CreateEmpty(Context
,
3236 Record
[ASTStmtReader::NumStmtFields
],
3237 Record
[ASTStmtReader::NumStmtFields
+ 1]);
3240 case STMT_OBJC_AT_SYNCHRONIZED
:
3241 S
= new (Context
) ObjCAtSynchronizedStmt(Empty
);
3244 case STMT_OBJC_AT_THROW
:
3245 S
= new (Context
) ObjCAtThrowStmt(Empty
);
3248 case STMT_OBJC_AUTORELEASE_POOL
:
3249 S
= new (Context
) ObjCAutoreleasePoolStmt(Empty
);
3252 case EXPR_OBJC_BOOL_LITERAL
:
3253 S
= new (Context
) ObjCBoolLiteralExpr(Empty
);
3256 case EXPR_OBJC_AVAILABILITY_CHECK
:
3257 S
= new (Context
) ObjCAvailabilityCheckExpr(Empty
);
3260 case STMT_SEH_LEAVE
:
3261 S
= new (Context
) SEHLeaveStmt(Empty
);
3264 case STMT_SEH_EXCEPT
:
3265 S
= new (Context
) SEHExceptStmt(Empty
);
3268 case STMT_SEH_FINALLY
:
3269 S
= new (Context
) SEHFinallyStmt(Empty
);
3273 S
= new (Context
) SEHTryStmt(Empty
);
3276 case STMT_CXX_CATCH
:
3277 S
= new (Context
) CXXCatchStmt(Empty
);
3281 S
= CXXTryStmt::Create(Context
, Empty
,
3282 /*numHandlers=*/Record
[ASTStmtReader::NumStmtFields
]);
3285 case STMT_CXX_FOR_RANGE
:
3286 S
= new (Context
) CXXForRangeStmt(Empty
);
3289 case STMT_MS_DEPENDENT_EXISTS
:
3290 S
= new (Context
) MSDependentExistsStmt(SourceLocation(), true,
3291 NestedNameSpecifierLoc(),
3292 DeclarationNameInfo(),
3296 case STMT_OMP_CANONICAL_LOOP
:
3297 S
= OMPCanonicalLoop::createEmpty(Context
);
3300 case STMT_OMP_META_DIRECTIVE
:
3301 S
= OMPMetaDirective::CreateEmpty(
3302 Context
, Record
[ASTStmtReader::NumStmtFields
], Empty
);
3305 case STMT_OMP_PARALLEL_DIRECTIVE
:
3307 OMPParallelDirective::CreateEmpty(Context
,
3308 Record
[ASTStmtReader::NumStmtFields
],
3312 case STMT_OMP_SIMD_DIRECTIVE
: {
3313 unsigned CollapsedNum
= Record
[ASTStmtReader::NumStmtFields
];
3314 unsigned NumClauses
= Record
[ASTStmtReader::NumStmtFields
+ 1];
3315 S
= OMPSimdDirective::CreateEmpty(Context
, NumClauses
,
3316 CollapsedNum
, Empty
);
3320 case STMT_OMP_TILE_DIRECTIVE
: {
3321 unsigned NumLoops
= Record
[ASTStmtReader::NumStmtFields
];
3322 unsigned NumClauses
= Record
[ASTStmtReader::NumStmtFields
+ 1];
3323 S
= OMPTileDirective::CreateEmpty(Context
, NumClauses
, NumLoops
);
3327 case STMT_OMP_UNROLL_DIRECTIVE
: {
3328 assert(Record
[ASTStmtReader::NumStmtFields
] == 1 && "Unroll directive accepts only a single loop");
3329 unsigned NumClauses
= Record
[ASTStmtReader::NumStmtFields
+ 1];
3330 S
= OMPUnrollDirective::CreateEmpty(Context
, NumClauses
);
3334 case STMT_OMP_FOR_DIRECTIVE
: {
3335 unsigned CollapsedNum
= Record
[ASTStmtReader::NumStmtFields
];
3336 unsigned NumClauses
= Record
[ASTStmtReader::NumStmtFields
+ 1];
3337 S
= OMPForDirective::CreateEmpty(Context
, NumClauses
, CollapsedNum
,
3342 case STMT_OMP_FOR_SIMD_DIRECTIVE
: {
3343 unsigned CollapsedNum
= Record
[ASTStmtReader::NumStmtFields
];
3344 unsigned NumClauses
= Record
[ASTStmtReader::NumStmtFields
+ 1];
3345 S
= OMPForSimdDirective::CreateEmpty(Context
, NumClauses
, CollapsedNum
,
3350 case STMT_OMP_SECTIONS_DIRECTIVE
:
3351 S
= OMPSectionsDirective::CreateEmpty(
3352 Context
, Record
[ASTStmtReader::NumStmtFields
], Empty
);
3355 case STMT_OMP_SECTION_DIRECTIVE
:
3356 S
= OMPSectionDirective::CreateEmpty(Context
, Empty
);
3359 case STMT_OMP_SCOPE_DIRECTIVE
:
3360 S
= OMPScopeDirective::CreateEmpty(
3361 Context
, Record
[ASTStmtReader::NumStmtFields
], Empty
);
3364 case STMT_OMP_SINGLE_DIRECTIVE
:
3365 S
= OMPSingleDirective::CreateEmpty(
3366 Context
, Record
[ASTStmtReader::NumStmtFields
], Empty
);
3369 case STMT_OMP_MASTER_DIRECTIVE
:
3370 S
= OMPMasterDirective::CreateEmpty(Context
, Empty
);
3373 case STMT_OMP_CRITICAL_DIRECTIVE
:
3374 S
= OMPCriticalDirective::CreateEmpty(
3375 Context
, Record
[ASTStmtReader::NumStmtFields
], Empty
);
3378 case STMT_OMP_PARALLEL_FOR_DIRECTIVE
: {
3379 unsigned CollapsedNum
= Record
[ASTStmtReader::NumStmtFields
];
3380 unsigned NumClauses
= Record
[ASTStmtReader::NumStmtFields
+ 1];
3381 S
= OMPParallelForDirective::CreateEmpty(Context
, NumClauses
,
3382 CollapsedNum
, Empty
);
3386 case STMT_OMP_PARALLEL_FOR_SIMD_DIRECTIVE
: {
3387 unsigned CollapsedNum
= Record
[ASTStmtReader::NumStmtFields
];
3388 unsigned NumClauses
= Record
[ASTStmtReader::NumStmtFields
+ 1];
3389 S
= OMPParallelForSimdDirective::CreateEmpty(Context
, NumClauses
,
3390 CollapsedNum
, Empty
);
3394 case STMT_OMP_PARALLEL_MASTER_DIRECTIVE
:
3395 S
= OMPParallelMasterDirective::CreateEmpty(
3396 Context
, Record
[ASTStmtReader::NumStmtFields
], Empty
);
3399 case STMT_OMP_PARALLEL_MASKED_DIRECTIVE
:
3400 S
= OMPParallelMaskedDirective::CreateEmpty(
3401 Context
, Record
[ASTStmtReader::NumStmtFields
], Empty
);
3404 case STMT_OMP_PARALLEL_SECTIONS_DIRECTIVE
:
3405 S
= OMPParallelSectionsDirective::CreateEmpty(
3406 Context
, Record
[ASTStmtReader::NumStmtFields
], Empty
);
3409 case STMT_OMP_TASK_DIRECTIVE
:
3410 S
= OMPTaskDirective::CreateEmpty(
3411 Context
, Record
[ASTStmtReader::NumStmtFields
], Empty
);
3414 case STMT_OMP_TASKYIELD_DIRECTIVE
:
3415 S
= OMPTaskyieldDirective::CreateEmpty(Context
, Empty
);
3418 case STMT_OMP_BARRIER_DIRECTIVE
:
3419 S
= OMPBarrierDirective::CreateEmpty(Context
, Empty
);
3422 case STMT_OMP_TASKWAIT_DIRECTIVE
:
3423 S
= OMPTaskwaitDirective::CreateEmpty(
3424 Context
, Record
[ASTStmtReader::NumStmtFields
], Empty
);
3427 case STMT_OMP_ERROR_DIRECTIVE
:
3428 S
= OMPErrorDirective::CreateEmpty(
3429 Context
, Record
[ASTStmtReader::NumStmtFields
], Empty
);
3432 case STMT_OMP_TASKGROUP_DIRECTIVE
:
3433 S
= OMPTaskgroupDirective::CreateEmpty(
3434 Context
, Record
[ASTStmtReader::NumStmtFields
], Empty
);
3437 case STMT_OMP_FLUSH_DIRECTIVE
:
3438 S
= OMPFlushDirective::CreateEmpty(
3439 Context
, Record
[ASTStmtReader::NumStmtFields
], Empty
);
3442 case STMT_OMP_DEPOBJ_DIRECTIVE
:
3443 S
= OMPDepobjDirective::CreateEmpty(
3444 Context
, Record
[ASTStmtReader::NumStmtFields
], Empty
);
3447 case STMT_OMP_SCAN_DIRECTIVE
:
3448 S
= OMPScanDirective::CreateEmpty(
3449 Context
, Record
[ASTStmtReader::NumStmtFields
], Empty
);
3452 case STMT_OMP_ORDERED_DIRECTIVE
: {
3453 unsigned NumClauses
= Record
[ASTStmtReader::NumStmtFields
];
3454 bool HasAssociatedStmt
= Record
[ASTStmtReader::NumStmtFields
+ 2];
3455 S
= OMPOrderedDirective::CreateEmpty(Context
, NumClauses
,
3456 !HasAssociatedStmt
, Empty
);
3460 case STMT_OMP_ATOMIC_DIRECTIVE
:
3461 S
= OMPAtomicDirective::CreateEmpty(
3462 Context
, Record
[ASTStmtReader::NumStmtFields
], Empty
);
3465 case STMT_OMP_TARGET_DIRECTIVE
:
3466 S
= OMPTargetDirective::CreateEmpty(
3467 Context
, Record
[ASTStmtReader::NumStmtFields
], Empty
);
3470 case STMT_OMP_TARGET_DATA_DIRECTIVE
:
3471 S
= OMPTargetDataDirective::CreateEmpty(
3472 Context
, Record
[ASTStmtReader::NumStmtFields
], Empty
);
3475 case STMT_OMP_TARGET_ENTER_DATA_DIRECTIVE
:
3476 S
= OMPTargetEnterDataDirective::CreateEmpty(
3477 Context
, Record
[ASTStmtReader::NumStmtFields
], Empty
);
3480 case STMT_OMP_TARGET_EXIT_DATA_DIRECTIVE
:
3481 S
= OMPTargetExitDataDirective::CreateEmpty(
3482 Context
, Record
[ASTStmtReader::NumStmtFields
], Empty
);
3485 case STMT_OMP_TARGET_PARALLEL_DIRECTIVE
:
3486 S
= OMPTargetParallelDirective::CreateEmpty(
3487 Context
, Record
[ASTStmtReader::NumStmtFields
], Empty
);
3490 case STMT_OMP_TARGET_PARALLEL_FOR_DIRECTIVE
: {
3491 unsigned CollapsedNum
= Record
[ASTStmtReader::NumStmtFields
];
3492 unsigned NumClauses
= Record
[ASTStmtReader::NumStmtFields
+ 1];
3493 S
= OMPTargetParallelForDirective::CreateEmpty(Context
, NumClauses
,
3494 CollapsedNum
, Empty
);
3498 case STMT_OMP_TARGET_UPDATE_DIRECTIVE
:
3499 S
= OMPTargetUpdateDirective::CreateEmpty(
3500 Context
, Record
[ASTStmtReader::NumStmtFields
], Empty
);
3503 case STMT_OMP_TEAMS_DIRECTIVE
:
3504 S
= OMPTeamsDirective::CreateEmpty(
3505 Context
, Record
[ASTStmtReader::NumStmtFields
], Empty
);
3508 case STMT_OMP_CANCELLATION_POINT_DIRECTIVE
:
3509 S
= OMPCancellationPointDirective::CreateEmpty(Context
, Empty
);
3512 case STMT_OMP_CANCEL_DIRECTIVE
:
3513 S
= OMPCancelDirective::CreateEmpty(
3514 Context
, Record
[ASTStmtReader::NumStmtFields
], Empty
);
3517 case STMT_OMP_TASKLOOP_DIRECTIVE
: {
3518 unsigned CollapsedNum
= Record
[ASTStmtReader::NumStmtFields
];
3519 unsigned NumClauses
= Record
[ASTStmtReader::NumStmtFields
+ 1];
3520 S
= OMPTaskLoopDirective::CreateEmpty(Context
, NumClauses
, CollapsedNum
,
3525 case STMT_OMP_TASKLOOP_SIMD_DIRECTIVE
: {
3526 unsigned CollapsedNum
= Record
[ASTStmtReader::NumStmtFields
];
3527 unsigned NumClauses
= Record
[ASTStmtReader::NumStmtFields
+ 1];
3528 S
= OMPTaskLoopSimdDirective::CreateEmpty(Context
, NumClauses
,
3529 CollapsedNum
, Empty
);
3533 case STMT_OMP_MASTER_TASKLOOP_DIRECTIVE
: {
3534 unsigned CollapsedNum
= Record
[ASTStmtReader::NumStmtFields
];
3535 unsigned NumClauses
= Record
[ASTStmtReader::NumStmtFields
+ 1];
3536 S
= OMPMasterTaskLoopDirective::CreateEmpty(Context
, NumClauses
,
3537 CollapsedNum
, Empty
);
3541 case STMT_OMP_MASKED_TASKLOOP_DIRECTIVE
: {
3542 unsigned CollapsedNum
= Record
[ASTStmtReader::NumStmtFields
];
3543 unsigned NumClauses
= Record
[ASTStmtReader::NumStmtFields
+ 1];
3544 S
= OMPMaskedTaskLoopDirective::CreateEmpty(Context
, NumClauses
,
3545 CollapsedNum
, Empty
);
3549 case STMT_OMP_MASTER_TASKLOOP_SIMD_DIRECTIVE
: {
3550 unsigned CollapsedNum
= Record
[ASTStmtReader::NumStmtFields
];
3551 unsigned NumClauses
= Record
[ASTStmtReader::NumStmtFields
+ 1];
3552 S
= OMPMasterTaskLoopSimdDirective::CreateEmpty(Context
, NumClauses
,
3553 CollapsedNum
, Empty
);
3557 case STMT_OMP_MASKED_TASKLOOP_SIMD_DIRECTIVE
: {
3558 unsigned CollapsedNum
= Record
[ASTStmtReader::NumStmtFields
];
3559 unsigned NumClauses
= Record
[ASTStmtReader::NumStmtFields
+ 1];
3560 S
= OMPMaskedTaskLoopSimdDirective::CreateEmpty(Context
, NumClauses
,
3561 CollapsedNum
, Empty
);
3565 case STMT_OMP_PARALLEL_MASTER_TASKLOOP_DIRECTIVE
: {
3566 unsigned CollapsedNum
= Record
[ASTStmtReader::NumStmtFields
];
3567 unsigned NumClauses
= Record
[ASTStmtReader::NumStmtFields
+ 1];
3568 S
= OMPParallelMasterTaskLoopDirective::CreateEmpty(Context
, NumClauses
,
3569 CollapsedNum
, Empty
);
3573 case STMT_OMP_PARALLEL_MASKED_TASKLOOP_DIRECTIVE
: {
3574 unsigned CollapsedNum
= Record
[ASTStmtReader::NumStmtFields
];
3575 unsigned NumClauses
= Record
[ASTStmtReader::NumStmtFields
+ 1];
3576 S
= OMPParallelMaskedTaskLoopDirective::CreateEmpty(Context
, NumClauses
,
3577 CollapsedNum
, Empty
);
3581 case STMT_OMP_PARALLEL_MASTER_TASKLOOP_SIMD_DIRECTIVE
: {
3582 unsigned CollapsedNum
= Record
[ASTStmtReader::NumStmtFields
];
3583 unsigned NumClauses
= Record
[ASTStmtReader::NumStmtFields
+ 1];
3584 S
= OMPParallelMasterTaskLoopSimdDirective::CreateEmpty(
3585 Context
, NumClauses
, CollapsedNum
, Empty
);
3589 case STMT_OMP_PARALLEL_MASKED_TASKLOOP_SIMD_DIRECTIVE
: {
3590 unsigned CollapsedNum
= Record
[ASTStmtReader::NumStmtFields
];
3591 unsigned NumClauses
= Record
[ASTStmtReader::NumStmtFields
+ 1];
3592 S
= OMPParallelMaskedTaskLoopSimdDirective::CreateEmpty(
3593 Context
, NumClauses
, CollapsedNum
, Empty
);
3597 case STMT_OMP_DISTRIBUTE_DIRECTIVE
: {
3598 unsigned CollapsedNum
= Record
[ASTStmtReader::NumStmtFields
];
3599 unsigned NumClauses
= Record
[ASTStmtReader::NumStmtFields
+ 1];
3600 S
= OMPDistributeDirective::CreateEmpty(Context
, NumClauses
, CollapsedNum
,
3605 case STMT_OMP_DISTRIBUTE_PARALLEL_FOR_DIRECTIVE
: {
3606 unsigned CollapsedNum
= Record
[ASTStmtReader::NumStmtFields
];
3607 unsigned NumClauses
= Record
[ASTStmtReader::NumStmtFields
+ 1];
3608 S
= OMPDistributeParallelForDirective::CreateEmpty(Context
, NumClauses
,
3609 CollapsedNum
, Empty
);
3613 case STMT_OMP_DISTRIBUTE_PARALLEL_FOR_SIMD_DIRECTIVE
: {
3614 unsigned CollapsedNum
= Record
[ASTStmtReader::NumStmtFields
];
3615 unsigned NumClauses
= Record
[ASTStmtReader::NumStmtFields
+ 1];
3616 S
= OMPDistributeParallelForSimdDirective::CreateEmpty(Context
, NumClauses
,
3622 case STMT_OMP_DISTRIBUTE_SIMD_DIRECTIVE
: {
3623 unsigned CollapsedNum
= Record
[ASTStmtReader::NumStmtFields
];
3624 unsigned NumClauses
= Record
[ASTStmtReader::NumStmtFields
+ 1];
3625 S
= OMPDistributeSimdDirective::CreateEmpty(Context
, NumClauses
,
3626 CollapsedNum
, Empty
);
3630 case STMT_OMP_TARGET_PARALLEL_FOR_SIMD_DIRECTIVE
: {
3631 unsigned CollapsedNum
= Record
[ASTStmtReader::NumStmtFields
];
3632 unsigned NumClauses
= Record
[ASTStmtReader::NumStmtFields
+ 1];
3633 S
= OMPTargetParallelForSimdDirective::CreateEmpty(Context
, NumClauses
,
3634 CollapsedNum
, Empty
);
3638 case STMT_OMP_TARGET_SIMD_DIRECTIVE
: {
3639 unsigned CollapsedNum
= Record
[ASTStmtReader::NumStmtFields
];
3640 unsigned NumClauses
= Record
[ASTStmtReader::NumStmtFields
+ 1];
3641 S
= OMPTargetSimdDirective::CreateEmpty(Context
, NumClauses
, CollapsedNum
,
3646 case STMT_OMP_TEAMS_DISTRIBUTE_DIRECTIVE
: {
3647 unsigned CollapsedNum
= Record
[ASTStmtReader::NumStmtFields
];
3648 unsigned NumClauses
= Record
[ASTStmtReader::NumStmtFields
+ 1];
3649 S
= OMPTeamsDistributeDirective::CreateEmpty(Context
, NumClauses
,
3650 CollapsedNum
, Empty
);
3654 case STMT_OMP_TEAMS_DISTRIBUTE_SIMD_DIRECTIVE
: {
3655 unsigned CollapsedNum
= Record
[ASTStmtReader::NumStmtFields
];
3656 unsigned NumClauses
= Record
[ASTStmtReader::NumStmtFields
+ 1];
3657 S
= OMPTeamsDistributeSimdDirective::CreateEmpty(Context
, NumClauses
,
3658 CollapsedNum
, Empty
);
3662 case STMT_OMP_TEAMS_DISTRIBUTE_PARALLEL_FOR_SIMD_DIRECTIVE
: {
3663 unsigned CollapsedNum
= Record
[ASTStmtReader::NumStmtFields
];
3664 unsigned NumClauses
= Record
[ASTStmtReader::NumStmtFields
+ 1];
3665 S
= OMPTeamsDistributeParallelForSimdDirective::CreateEmpty(
3666 Context
, NumClauses
, CollapsedNum
, Empty
);
3670 case STMT_OMP_TEAMS_DISTRIBUTE_PARALLEL_FOR_DIRECTIVE
: {
3671 unsigned CollapsedNum
= Record
[ASTStmtReader::NumStmtFields
];
3672 unsigned NumClauses
= Record
[ASTStmtReader::NumStmtFields
+ 1];
3673 S
= OMPTeamsDistributeParallelForDirective::CreateEmpty(
3674 Context
, NumClauses
, CollapsedNum
, Empty
);
3678 case STMT_OMP_TARGET_TEAMS_DIRECTIVE
:
3679 S
= OMPTargetTeamsDirective::CreateEmpty(
3680 Context
, Record
[ASTStmtReader::NumStmtFields
], Empty
);
3683 case STMT_OMP_TARGET_TEAMS_DISTRIBUTE_DIRECTIVE
: {
3684 unsigned CollapsedNum
= Record
[ASTStmtReader::NumStmtFields
];
3685 unsigned NumClauses
= Record
[ASTStmtReader::NumStmtFields
+ 1];
3686 S
= OMPTargetTeamsDistributeDirective::CreateEmpty(Context
, NumClauses
,
3687 CollapsedNum
, Empty
);
3691 case STMT_OMP_TARGET_TEAMS_DISTRIBUTE_PARALLEL_FOR_DIRECTIVE
: {
3692 unsigned CollapsedNum
= Record
[ASTStmtReader::NumStmtFields
];
3693 unsigned NumClauses
= Record
[ASTStmtReader::NumStmtFields
+ 1];
3694 S
= OMPTargetTeamsDistributeParallelForDirective::CreateEmpty(
3695 Context
, NumClauses
, CollapsedNum
, Empty
);
3699 case STMT_OMP_TARGET_TEAMS_DISTRIBUTE_PARALLEL_FOR_SIMD_DIRECTIVE
: {
3700 unsigned CollapsedNum
= Record
[ASTStmtReader::NumStmtFields
];
3701 unsigned NumClauses
= Record
[ASTStmtReader::NumStmtFields
+ 1];
3702 S
= OMPTargetTeamsDistributeParallelForSimdDirective::CreateEmpty(
3703 Context
, NumClauses
, CollapsedNum
, Empty
);
3707 case STMT_OMP_TARGET_TEAMS_DISTRIBUTE_SIMD_DIRECTIVE
: {
3708 unsigned CollapsedNum
= Record
[ASTStmtReader::NumStmtFields
];
3709 unsigned NumClauses
= Record
[ASTStmtReader::NumStmtFields
+ 1];
3710 S
= OMPTargetTeamsDistributeSimdDirective::CreateEmpty(
3711 Context
, NumClauses
, CollapsedNum
, Empty
);
3715 case STMT_OMP_INTEROP_DIRECTIVE
:
3716 S
= OMPInteropDirective::CreateEmpty(
3717 Context
, Record
[ASTStmtReader::NumStmtFields
], Empty
);
3720 case STMT_OMP_DISPATCH_DIRECTIVE
:
3721 S
= OMPDispatchDirective::CreateEmpty(
3722 Context
, Record
[ASTStmtReader::NumStmtFields
], Empty
);
3725 case STMT_OMP_MASKED_DIRECTIVE
:
3726 S
= OMPMaskedDirective::CreateEmpty(
3727 Context
, Record
[ASTStmtReader::NumStmtFields
], Empty
);
3730 case STMT_OMP_GENERIC_LOOP_DIRECTIVE
: {
3731 unsigned CollapsedNum
= Record
[ASTStmtReader::NumStmtFields
];
3732 unsigned NumClauses
= Record
[ASTStmtReader::NumStmtFields
+ 1];
3733 S
= OMPGenericLoopDirective::CreateEmpty(Context
, NumClauses
,
3734 CollapsedNum
, Empty
);
3738 case STMT_OMP_TEAMS_GENERIC_LOOP_DIRECTIVE
: {
3739 unsigned CollapsedNum
= Record
[ASTStmtReader::NumStmtFields
];
3740 unsigned NumClauses
= Record
[ASTStmtReader::NumStmtFields
+ 1];
3741 S
= OMPTeamsGenericLoopDirective::CreateEmpty(Context
, NumClauses
,
3742 CollapsedNum
, Empty
);
3746 case STMT_OMP_TARGET_TEAMS_GENERIC_LOOP_DIRECTIVE
: {
3747 unsigned CollapsedNum
= Record
[ASTStmtReader::NumStmtFields
];
3748 unsigned NumClauses
= Record
[ASTStmtReader::NumStmtFields
+ 1];
3749 S
= OMPTargetTeamsGenericLoopDirective::CreateEmpty(Context
, NumClauses
,
3750 CollapsedNum
, Empty
);
3754 case STMT_OMP_PARALLEL_GENERIC_LOOP_DIRECTIVE
: {
3755 unsigned CollapsedNum
= Record
[ASTStmtReader::NumStmtFields
];
3756 unsigned NumClauses
= Record
[ASTStmtReader::NumStmtFields
+ 1];
3757 S
= OMPParallelGenericLoopDirective::CreateEmpty(Context
, NumClauses
,
3758 CollapsedNum
, Empty
);
3762 case STMT_OMP_TARGET_PARALLEL_GENERIC_LOOP_DIRECTIVE
: {
3763 unsigned CollapsedNum
= Record
[ASTStmtReader::NumStmtFields
];
3764 unsigned NumClauses
= Record
[ASTStmtReader::NumStmtFields
+ 1];
3765 S
= OMPTargetParallelGenericLoopDirective::CreateEmpty(
3766 Context
, NumClauses
, CollapsedNum
, Empty
);
3770 case EXPR_CXX_OPERATOR_CALL
:
3771 S
= CXXOperatorCallExpr::CreateEmpty(
3772 Context
, /*NumArgs=*/Record
[ASTStmtReader::NumExprFields
],
3773 /*HasFPFeatures=*/Record
[ASTStmtReader::NumExprFields
+ 1], Empty
);
3776 case EXPR_CXX_MEMBER_CALL
:
3777 S
= CXXMemberCallExpr::CreateEmpty(
3778 Context
, /*NumArgs=*/Record
[ASTStmtReader::NumExprFields
],
3779 /*HasFPFeatures=*/Record
[ASTStmtReader::NumExprFields
+ 1], Empty
);
3782 case EXPR_CXX_REWRITTEN_BINARY_OPERATOR
:
3783 S
= new (Context
) CXXRewrittenBinaryOperator(Empty
);
3786 case EXPR_CXX_CONSTRUCT
:
3787 S
= CXXConstructExpr::CreateEmpty(
3789 /* NumArgs=*/Record
[ASTStmtReader::NumExprFields
]);
3792 case EXPR_CXX_INHERITED_CTOR_INIT
:
3793 S
= new (Context
) CXXInheritedCtorInitExpr(Empty
);
3796 case EXPR_CXX_TEMPORARY_OBJECT
:
3797 S
= CXXTemporaryObjectExpr::CreateEmpty(
3799 /* NumArgs=*/Record
[ASTStmtReader::NumExprFields
]);
3802 case EXPR_CXX_STATIC_CAST
:
3803 S
= CXXStaticCastExpr::CreateEmpty(
3805 /*PathSize*/ Record
[ASTStmtReader::NumExprFields
],
3806 /*HasFPFeatures*/ Record
[ASTStmtReader::NumExprFields
+ 1]);
3809 case EXPR_CXX_DYNAMIC_CAST
:
3810 S
= CXXDynamicCastExpr::CreateEmpty(Context
,
3811 /*PathSize*/ Record
[ASTStmtReader::NumExprFields
]);
3814 case EXPR_CXX_REINTERPRET_CAST
:
3815 S
= CXXReinterpretCastExpr::CreateEmpty(Context
,
3816 /*PathSize*/ Record
[ASTStmtReader::NumExprFields
]);
3819 case EXPR_CXX_CONST_CAST
:
3820 S
= CXXConstCastExpr::CreateEmpty(Context
);
3823 case EXPR_CXX_ADDRSPACE_CAST
:
3824 S
= CXXAddrspaceCastExpr::CreateEmpty(Context
);
3827 case EXPR_CXX_FUNCTIONAL_CAST
:
3828 S
= CXXFunctionalCastExpr::CreateEmpty(
3830 /*PathSize*/ Record
[ASTStmtReader::NumExprFields
],
3831 /*HasFPFeatures*/ Record
[ASTStmtReader::NumExprFields
+ 1]);
3834 case EXPR_BUILTIN_BIT_CAST
:
3835 assert(Record
[ASTStmtReader::NumExprFields
] == 0 && "Wrong PathSize!");
3836 S
= new (Context
) BuiltinBitCastExpr(Empty
);
3839 case EXPR_USER_DEFINED_LITERAL
:
3840 S
= UserDefinedLiteral::CreateEmpty(
3841 Context
, /*NumArgs=*/Record
[ASTStmtReader::NumExprFields
],
3842 /*HasFPFeatures=*/Record
[ASTStmtReader::NumExprFields
+ 1], Empty
);
3845 case EXPR_CXX_STD_INITIALIZER_LIST
:
3846 S
= new (Context
) CXXStdInitializerListExpr(Empty
);
3849 case EXPR_CXX_BOOL_LITERAL
:
3850 S
= new (Context
) CXXBoolLiteralExpr(Empty
);
3853 case EXPR_CXX_NULL_PTR_LITERAL
:
3854 S
= new (Context
) CXXNullPtrLiteralExpr(Empty
);
3857 case EXPR_CXX_TYPEID_EXPR
:
3858 S
= new (Context
) CXXTypeidExpr(Empty
, true);
3861 case EXPR_CXX_TYPEID_TYPE
:
3862 S
= new (Context
) CXXTypeidExpr(Empty
, false);
3865 case EXPR_CXX_UUIDOF_EXPR
:
3866 S
= new (Context
) CXXUuidofExpr(Empty
, true);
3869 case EXPR_CXX_PROPERTY_REF_EXPR
:
3870 S
= new (Context
) MSPropertyRefExpr(Empty
);
3873 case EXPR_CXX_PROPERTY_SUBSCRIPT_EXPR
:
3874 S
= new (Context
) MSPropertySubscriptExpr(Empty
);
3877 case EXPR_CXX_UUIDOF_TYPE
:
3878 S
= new (Context
) CXXUuidofExpr(Empty
, false);
3882 S
= CXXThisExpr::CreateEmpty(Context
);
3885 case EXPR_CXX_THROW
:
3886 S
= new (Context
) CXXThrowExpr(Empty
);
3889 case EXPR_CXX_DEFAULT_ARG
:
3890 S
= CXXDefaultArgExpr::CreateEmpty(
3891 Context
, /*HasRewrittenInit=*/Record
[ASTStmtReader::NumExprFields
]);
3894 case EXPR_CXX_DEFAULT_INIT
:
3895 S
= CXXDefaultInitExpr::CreateEmpty(
3896 Context
, /*HasRewrittenInit=*/Record
[ASTStmtReader::NumExprFields
]);
3899 case EXPR_CXX_BIND_TEMPORARY
:
3900 S
= new (Context
) CXXBindTemporaryExpr(Empty
);
3903 case EXPR_CXX_SCALAR_VALUE_INIT
:
3904 S
= new (Context
) CXXScalarValueInitExpr(Empty
);
3908 S
= CXXNewExpr::CreateEmpty(
3910 /*IsArray=*/Record
[ASTStmtReader::NumExprFields
],
3911 /*HasInit=*/Record
[ASTStmtReader::NumExprFields
+ 1],
3912 /*NumPlacementArgs=*/Record
[ASTStmtReader::NumExprFields
+ 2],
3913 /*IsParenTypeId=*/Record
[ASTStmtReader::NumExprFields
+ 3]);
3916 case EXPR_CXX_DELETE
:
3917 S
= new (Context
) CXXDeleteExpr(Empty
);
3920 case EXPR_CXX_PSEUDO_DESTRUCTOR
:
3921 S
= new (Context
) CXXPseudoDestructorExpr(Empty
);
3924 case EXPR_EXPR_WITH_CLEANUPS
:
3925 S
= ExprWithCleanups::Create(Context
, Empty
,
3926 Record
[ASTStmtReader::NumExprFields
]);
3929 case EXPR_CXX_DEPENDENT_SCOPE_MEMBER
:
3930 S
= CXXDependentScopeMemberExpr::CreateEmpty(
3932 /*HasTemplateKWAndArgsInfo=*/Record
[ASTStmtReader::NumExprFields
],
3933 /*NumTemplateArgs=*/Record
[ASTStmtReader::NumExprFields
+ 1],
3934 /*HasFirstQualifierFoundInScope=*/
3935 Record
[ASTStmtReader::NumExprFields
+ 2]);
3938 case EXPR_CXX_DEPENDENT_SCOPE_DECL_REF
:
3939 S
= DependentScopeDeclRefExpr::CreateEmpty(Context
,
3940 /*HasTemplateKWAndArgsInfo=*/Record
[ASTStmtReader::NumExprFields
],
3941 /*NumTemplateArgs=*/Record
[ASTStmtReader::NumExprFields
]
3942 ? Record
[ASTStmtReader::NumExprFields
+ 1]
3946 case EXPR_CXX_UNRESOLVED_CONSTRUCT
:
3947 S
= CXXUnresolvedConstructExpr::CreateEmpty(Context
,
3948 /*NumArgs=*/Record
[ASTStmtReader::NumExprFields
]);
3951 case EXPR_CXX_UNRESOLVED_MEMBER
:
3952 S
= UnresolvedMemberExpr::CreateEmpty(
3954 /*NumResults=*/Record
[ASTStmtReader::NumExprFields
],
3955 /*HasTemplateKWAndArgsInfo=*/Record
[ASTStmtReader::NumExprFields
+ 1],
3956 /*NumTemplateArgs=*/
3957 Record
[ASTStmtReader::NumExprFields
+ 1]
3958 ? Record
[ASTStmtReader::NumExprFields
+ 2]
3962 case EXPR_CXX_UNRESOLVED_LOOKUP
:
3963 S
= UnresolvedLookupExpr::CreateEmpty(
3965 /*NumResults=*/Record
[ASTStmtReader::NumExprFields
],
3966 /*HasTemplateKWAndArgsInfo=*/Record
[ASTStmtReader::NumExprFields
+ 1],
3967 /*NumTemplateArgs=*/
3968 Record
[ASTStmtReader::NumExprFields
+ 1]
3969 ? Record
[ASTStmtReader::NumExprFields
+ 2]
3973 case EXPR_TYPE_TRAIT
:
3974 S
= TypeTraitExpr::CreateDeserialized(Context
,
3975 Record
[ASTStmtReader::NumExprFields
]);
3978 case EXPR_ARRAY_TYPE_TRAIT
:
3979 S
= new (Context
) ArrayTypeTraitExpr(Empty
);
3982 case EXPR_CXX_EXPRESSION_TRAIT
:
3983 S
= new (Context
) ExpressionTraitExpr(Empty
);
3986 case EXPR_CXX_NOEXCEPT
:
3987 S
= new (Context
) CXXNoexceptExpr(Empty
);
3990 case EXPR_PACK_EXPANSION
:
3991 S
= new (Context
) PackExpansionExpr(Empty
);
3994 case EXPR_SIZEOF_PACK
:
3995 S
= SizeOfPackExpr::CreateDeserialized(
3997 /*NumPartialArgs=*/Record
[ASTStmtReader::NumExprFields
]);
4000 case EXPR_SUBST_NON_TYPE_TEMPLATE_PARM
:
4001 S
= new (Context
) SubstNonTypeTemplateParmExpr(Empty
);
4004 case EXPR_SUBST_NON_TYPE_TEMPLATE_PARM_PACK
:
4005 S
= new (Context
) SubstNonTypeTemplateParmPackExpr(Empty
);
4008 case EXPR_FUNCTION_PARM_PACK
:
4009 S
= FunctionParmPackExpr::CreateEmpty(Context
,
4010 Record
[ASTStmtReader::NumExprFields
]);
4013 case EXPR_MATERIALIZE_TEMPORARY
:
4014 S
= new (Context
) MaterializeTemporaryExpr(Empty
);
4018 S
= new (Context
) CXXFoldExpr(Empty
);
4021 case EXPR_CXX_PAREN_LIST_INIT
:
4022 S
= CXXParenListInitExpr::CreateEmpty(
4023 Context
, /*numExprs=*/Record
[ASTStmtReader::NumExprFields
], Empty
);
4026 case EXPR_OPAQUE_VALUE
:
4027 S
= new (Context
) OpaqueValueExpr(Empty
);
4030 case EXPR_CUDA_KERNEL_CALL
:
4031 S
= CUDAKernelCallExpr::CreateEmpty(
4032 Context
, /*NumArgs=*/Record
[ASTStmtReader::NumExprFields
],
4033 /*HasFPFeatures=*/Record
[ASTStmtReader::NumExprFields
+ 1], Empty
);
4037 S
= new (Context
) AsTypeExpr(Empty
);
4040 case EXPR_PSEUDO_OBJECT
: {
4041 unsigned numSemanticExprs
= Record
[ASTStmtReader::NumExprFields
];
4042 S
= PseudoObjectExpr::Create(Context
, Empty
, numSemanticExprs
);
4047 S
= new (Context
) AtomicExpr(Empty
);
4051 unsigned NumCaptures
= Record
[ASTStmtReader::NumExprFields
];
4052 S
= LambdaExpr::CreateDeserialized(Context
, NumCaptures
);
4056 case STMT_COROUTINE_BODY
: {
4057 unsigned NumParams
= Record
[ASTStmtReader::NumStmtFields
];
4058 S
= CoroutineBodyStmt::Create(Context
, Empty
, NumParams
);
4063 S
= new (Context
) CoreturnStmt(Empty
);
4067 S
= new (Context
) CoawaitExpr(Empty
);
4071 S
= new (Context
) CoyieldExpr(Empty
);
4074 case EXPR_DEPENDENT_COAWAIT
:
4075 S
= new (Context
) DependentCoawaitExpr(Empty
);
4078 case EXPR_CONCEPT_SPECIALIZATION
: {
4079 S
= new (Context
) ConceptSpecializationExpr(Empty
);
4084 unsigned numLocalParameters
= Record
[ASTStmtReader::NumExprFields
];
4085 unsigned numRequirement
= Record
[ASTStmtReader::NumExprFields
+ 1];
4086 S
= RequiresExpr::Create(Context
, Empty
, numLocalParameters
,
4091 // We hit a STMT_STOP, so we're done with this expression.
4095 ++NumStatementsRead
;
4097 if (S
&& !IsStmtReference
) {
4099 StmtEntries
[Cursor
.GetCurrentBitNo()] = S
;
4102 assert(Record
.getIdx() == Record
.size() &&
4103 "Invalid deserialization of statement");
4104 StmtStack
.push_back(S
);
4107 assert(StmtStack
.size() > PrevNumStmts
&& "Read too many sub-stmts!");
4108 assert(StmtStack
.size() == PrevNumStmts
+ 1 && "Extra expressions on stack!");
4109 return StmtStack
.pop_back_val();