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/Serialization/ASTReader.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/Expr.h"
25 #include "clang/AST/ExprCXX.h"
26 #include "clang/AST/ExprObjC.h"
27 #include "clang/AST/ExprOpenMP.h"
28 #include "clang/AST/NestedNameSpecifier.h"
29 #include "clang/AST/OpenMPClause.h"
30 #include "clang/AST/OperationKinds.h"
31 #include "clang/AST/Stmt.h"
32 #include "clang/AST/StmtCXX.h"
33 #include "clang/AST/StmtObjC.h"
34 #include "clang/AST/StmtOpenMP.h"
35 #include "clang/AST/StmtVisitor.h"
36 #include "clang/AST/TemplateBase.h"
37 #include "clang/AST/Type.h"
38 #include "clang/AST/UnresolvedSet.h"
39 #include "clang/Basic/CapturedStmt.h"
40 #include "clang/Basic/ExpressionTraits.h"
41 #include "clang/Basic/LLVM.h"
42 #include "clang/Basic/Lambda.h"
43 #include "clang/Basic/LangOptions.h"
44 #include "clang/Basic/OpenMPKinds.h"
45 #include "clang/Basic/OperatorKinds.h"
46 #include "clang/Basic/SourceLocation.h"
47 #include "clang/Basic/Specifiers.h"
48 #include "clang/Basic/TypeTraits.h"
49 #include "clang/Lex/Token.h"
50 #include "clang/Serialization/ASTBitCodes.h"
51 #include "llvm/ADT/DenseMap.h"
52 #include "llvm/ADT/SmallString.h"
53 #include "llvm/ADT/SmallVector.h"
54 #include "llvm/ADT/StringRef.h"
55 #include "llvm/Bitstream/BitstreamReader.h"
56 #include "llvm/Support/Casting.h"
57 #include "llvm/Support/ErrorHandling.h"
63 using namespace clang;
64 using namespace serialization;
68 class ASTStmtReader : public StmtVisitor<ASTStmtReader> {
69 friend class OMPClauseReader;
71 ASTRecordReader &Record;
72 llvm::BitstreamCursor &DeclsCursor;
74 SourceLocation ReadSourceLocation() {
75 return Record.readSourceLocation();
78 SourceRange ReadSourceRange() {
79 return Record.readSourceRange();
82 std::string ReadString() {
83 return Record.readString();
86 TypeSourceInfo *GetTypeSourceInfo() {
87 return Record.getTypeSourceInfo();
91 return Record.readDecl();
96 return Record.readDeclAs<T>();
99 void ReadDeclarationNameLoc(DeclarationNameLoc &DNLoc,
100 DeclarationName Name) {
101 Record.readDeclarationNameLoc(DNLoc, Name);
104 void ReadDeclarationNameInfo(DeclarationNameInfo &NameInfo) {
105 Record.readDeclarationNameInfo(NameInfo);
109 ASTStmtReader(ASTRecordReader &Record, llvm::BitstreamCursor &Cursor)
110 : Record(Record), DeclsCursor(Cursor) {}
112 /// The number of record fields required for the Stmt class
114 static const unsigned NumStmtFields = 1;
116 /// The number of record fields required for the Expr class
118 static const unsigned NumExprFields = NumStmtFields + 7;
120 /// Read and initialize a ExplicitTemplateArgumentList structure.
121 void ReadTemplateKWAndArgsInfo(ASTTemplateKWAndArgsInfo &Args,
122 TemplateArgumentLoc *ArgsLocArray,
123 unsigned NumTemplateArgs);
125 /// Read and initialize a ExplicitTemplateArgumentList structure.
126 void ReadExplicitTemplateArgumentList(ASTTemplateArgumentListInfo &ArgList,
127 unsigned NumTemplateArgs);
129 void VisitStmt(Stmt *S);
130 #define STMT(Type, Base) \
131 void Visit##Type(Type *);
132 #include "clang/AST/StmtNodes.inc"
137 void ASTStmtReader::ReadTemplateKWAndArgsInfo(ASTTemplateKWAndArgsInfo &Args,
138 TemplateArgumentLoc *ArgsLocArray,
139 unsigned NumTemplateArgs) {
140 SourceLocation TemplateKWLoc = ReadSourceLocation();
141 TemplateArgumentListInfo ArgInfo;
142 ArgInfo.setLAngleLoc(ReadSourceLocation());
143 ArgInfo.setRAngleLoc(ReadSourceLocation());
144 for (unsigned i = 0; i != NumTemplateArgs; ++i)
145 ArgInfo.addArgument(Record.readTemplateArgumentLoc());
146 Args.initializeFrom(TemplateKWLoc, ArgInfo, ArgsLocArray);
149 void ASTStmtReader::VisitStmt(Stmt *S) {
150 S->setIsOMPStructuredBlock(Record.readInt());
151 assert(Record.getIdx() == NumStmtFields && "Incorrect statement field count");
154 void ASTStmtReader::VisitNullStmt(NullStmt *S) {
156 S->setSemiLoc(ReadSourceLocation());
157 S->NullStmtBits.HasLeadingEmptyMacro = Record.readInt();
160 void ASTStmtReader::VisitCompoundStmt(CompoundStmt *S) {
162 SmallVector<Stmt *, 16> Stmts;
163 unsigned NumStmts = Record.readInt();
165 Stmts.push_back(Record.readSubStmt());
167 S->CompoundStmtBits.LBraceLoc = ReadSourceLocation();
168 S->RBraceLoc = ReadSourceLocation();
171 void ASTStmtReader::VisitSwitchCase(SwitchCase *S) {
173 Record.recordSwitchCaseID(S, Record.readInt());
174 S->setKeywordLoc(ReadSourceLocation());
175 S->setColonLoc(ReadSourceLocation());
178 void ASTStmtReader::VisitCaseStmt(CaseStmt *S) {
180 bool CaseStmtIsGNURange = Record.readInt();
181 S->setLHS(Record.readSubExpr());
182 S->setSubStmt(Record.readSubStmt());
183 if (CaseStmtIsGNURange) {
184 S->setRHS(Record.readSubExpr());
185 S->setEllipsisLoc(ReadSourceLocation());
189 void ASTStmtReader::VisitDefaultStmt(DefaultStmt *S) {
191 S->setSubStmt(Record.readSubStmt());
194 void ASTStmtReader::VisitLabelStmt(LabelStmt *S) {
196 auto *LD = ReadDeclAs<LabelDecl>();
199 S->setSubStmt(Record.readSubStmt());
200 S->setIdentLoc(ReadSourceLocation());
203 void ASTStmtReader::VisitAttributedStmt(AttributedStmt *S) {
205 // NumAttrs in AttributedStmt is set when creating an empty
206 // AttributedStmt in AttributedStmt::CreateEmpty, since it is needed
207 // to allocate the right amount of space for the trailing Attr *.
208 uint64_t NumAttrs = Record.readInt();
210 Record.readAttributes(Attrs);
212 assert(NumAttrs == S->AttributedStmtBits.NumAttrs);
213 assert(NumAttrs == Attrs.size());
214 std::copy(Attrs.begin(), Attrs.end(), S->getAttrArrayPtr());
215 S->SubStmt = Record.readSubStmt();
216 S->AttributedStmtBits.AttrLoc = ReadSourceLocation();
219 void ASTStmtReader::VisitIfStmt(IfStmt *S) {
222 S->setConstexpr(Record.readInt());
223 bool HasElse = Record.readInt();
224 bool HasVar = Record.readInt();
225 bool HasInit = Record.readInt();
227 S->setCond(Record.readSubExpr());
228 S->setThen(Record.readSubStmt());
230 S->setElse(Record.readSubStmt());
232 S->setConditionVariable(Record.getContext(), ReadDeclAs<VarDecl>());
234 S->setInit(Record.readSubStmt());
236 S->setIfLoc(ReadSourceLocation());
238 S->setElseLoc(ReadSourceLocation());
241 void ASTStmtReader::VisitSwitchStmt(SwitchStmt *S) {
244 bool HasInit = Record.readInt();
245 bool HasVar = Record.readInt();
246 bool AllEnumCasesCovered = Record.readInt();
247 if (AllEnumCasesCovered)
248 S->setAllEnumCasesCovered();
250 S->setCond(Record.readSubExpr());
251 S->setBody(Record.readSubStmt());
253 S->setInit(Record.readSubStmt());
255 S->setConditionVariable(Record.getContext(), ReadDeclAs<VarDecl>());
257 S->setSwitchLoc(ReadSourceLocation());
259 SwitchCase *PrevSC = nullptr;
260 for (auto E = Record.size(); Record.getIdx() != E; ) {
261 SwitchCase *SC = Record.getSwitchCaseWithID(Record.readInt());
263 PrevSC->setNextSwitchCase(SC);
265 S->setSwitchCaseList(SC);
271 void ASTStmtReader::VisitWhileStmt(WhileStmt *S) {
274 bool HasVar = Record.readInt();
276 S->setCond(Record.readSubExpr());
277 S->setBody(Record.readSubStmt());
279 S->setConditionVariable(Record.getContext(), ReadDeclAs<VarDecl>());
281 S->setWhileLoc(ReadSourceLocation());
284 void ASTStmtReader::VisitDoStmt(DoStmt *S) {
286 S->setCond(Record.readSubExpr());
287 S->setBody(Record.readSubStmt());
288 S->setDoLoc(ReadSourceLocation());
289 S->setWhileLoc(ReadSourceLocation());
290 S->setRParenLoc(ReadSourceLocation());
293 void ASTStmtReader::VisitForStmt(ForStmt *S) {
295 S->setInit(Record.readSubStmt());
296 S->setCond(Record.readSubExpr());
297 S->setConditionVariable(Record.getContext(), ReadDeclAs<VarDecl>());
298 S->setInc(Record.readSubExpr());
299 S->setBody(Record.readSubStmt());
300 S->setForLoc(ReadSourceLocation());
301 S->setLParenLoc(ReadSourceLocation());
302 S->setRParenLoc(ReadSourceLocation());
305 void ASTStmtReader::VisitGotoStmt(GotoStmt *S) {
307 S->setLabel(ReadDeclAs<LabelDecl>());
308 S->setGotoLoc(ReadSourceLocation());
309 S->setLabelLoc(ReadSourceLocation());
312 void ASTStmtReader::VisitIndirectGotoStmt(IndirectGotoStmt *S) {
314 S->setGotoLoc(ReadSourceLocation());
315 S->setStarLoc(ReadSourceLocation());
316 S->setTarget(Record.readSubExpr());
319 void ASTStmtReader::VisitContinueStmt(ContinueStmt *S) {
321 S->setContinueLoc(ReadSourceLocation());
324 void ASTStmtReader::VisitBreakStmt(BreakStmt *S) {
326 S->setBreakLoc(ReadSourceLocation());
329 void ASTStmtReader::VisitReturnStmt(ReturnStmt *S) {
332 bool HasNRVOCandidate = Record.readInt();
334 S->setRetValue(Record.readSubExpr());
335 if (HasNRVOCandidate)
336 S->setNRVOCandidate(ReadDeclAs<VarDecl>());
338 S->setReturnLoc(ReadSourceLocation());
341 void ASTStmtReader::VisitDeclStmt(DeclStmt *S) {
343 S->setStartLoc(ReadSourceLocation());
344 S->setEndLoc(ReadSourceLocation());
346 if (Record.size() - Record.getIdx() == 1) {
347 // Single declaration
348 S->setDeclGroup(DeclGroupRef(ReadDecl()));
350 SmallVector<Decl *, 16> Decls;
351 int N = Record.size() - Record.getIdx();
353 for (int I = 0; I < N; ++I)
354 Decls.push_back(ReadDecl());
355 S->setDeclGroup(DeclGroupRef(DeclGroup::Create(Record.getContext(),
361 void ASTStmtReader::VisitAsmStmt(AsmStmt *S) {
363 S->NumOutputs = Record.readInt();
364 S->NumInputs = Record.readInt();
365 S->NumClobbers = Record.readInt();
366 S->setAsmLoc(ReadSourceLocation());
367 S->setVolatile(Record.readInt());
368 S->setSimple(Record.readInt());
371 void ASTStmtReader::VisitGCCAsmStmt(GCCAsmStmt *S) {
373 S->NumLabels = Record.readInt();
374 S->setRParenLoc(ReadSourceLocation());
375 S->setAsmString(cast_or_null<StringLiteral>(Record.readSubStmt()));
377 unsigned NumOutputs = S->getNumOutputs();
378 unsigned NumInputs = S->getNumInputs();
379 unsigned NumClobbers = S->getNumClobbers();
380 unsigned NumLabels = S->getNumLabels();
382 // Outputs and inputs
383 SmallVector<IdentifierInfo *, 16> Names;
384 SmallVector<StringLiteral*, 16> Constraints;
385 SmallVector<Stmt*, 16> Exprs;
386 for (unsigned I = 0, N = NumOutputs + NumInputs; I != N; ++I) {
387 Names.push_back(Record.getIdentifierInfo());
388 Constraints.push_back(cast_or_null<StringLiteral>(Record.readSubStmt()));
389 Exprs.push_back(Record.readSubStmt());
393 SmallVector<StringLiteral*, 16> Clobbers;
394 for (unsigned I = 0; I != NumClobbers; ++I)
395 Clobbers.push_back(cast_or_null<StringLiteral>(Record.readSubStmt()));
398 for (unsigned I = 0, N = NumLabels; I != N; ++I)
399 Exprs.push_back(Record.readSubStmt());
401 S->setOutputsAndInputsAndClobbers(Record.getContext(),
402 Names.data(), Constraints.data(),
403 Exprs.data(), NumOutputs, NumInputs,
405 Clobbers.data(), NumClobbers);
408 void ASTStmtReader::VisitMSAsmStmt(MSAsmStmt *S) {
410 S->LBraceLoc = ReadSourceLocation();
411 S->EndLoc = ReadSourceLocation();
412 S->NumAsmToks = Record.readInt();
413 std::string AsmStr = ReadString();
416 SmallVector<Token, 16> AsmToks;
417 AsmToks.reserve(S->NumAsmToks);
418 for (unsigned i = 0, e = S->NumAsmToks; i != e; ++i) {
419 AsmToks.push_back(Record.readToken());
422 // The calls to reserve() for the FooData vectors are mandatory to
423 // prevent dead StringRefs in the Foo vectors.
425 // Read the clobbers.
426 SmallVector<std::string, 16> ClobbersData;
427 SmallVector<StringRef, 16> Clobbers;
428 ClobbersData.reserve(S->NumClobbers);
429 Clobbers.reserve(S->NumClobbers);
430 for (unsigned i = 0, e = S->NumClobbers; i != e; ++i) {
431 ClobbersData.push_back(ReadString());
432 Clobbers.push_back(ClobbersData.back());
435 // Read the operands.
436 unsigned NumOperands = S->NumOutputs + S->NumInputs;
437 SmallVector<Expr*, 16> Exprs;
438 SmallVector<std::string, 16> ConstraintsData;
439 SmallVector<StringRef, 16> Constraints;
440 Exprs.reserve(NumOperands);
441 ConstraintsData.reserve(NumOperands);
442 Constraints.reserve(NumOperands);
443 for (unsigned i = 0; i != NumOperands; ++i) {
444 Exprs.push_back(cast<Expr>(Record.readSubStmt()));
445 ConstraintsData.push_back(ReadString());
446 Constraints.push_back(ConstraintsData.back());
449 S->initialize(Record.getContext(), AsmStr, AsmToks,
450 Constraints, Exprs, Clobbers);
453 void ASTStmtReader::VisitCoroutineBodyStmt(CoroutineBodyStmt *S) {
455 assert(Record.peekInt() == S->NumParams);
457 auto *StoredStmts = S->getStoredStmts();
459 i < CoroutineBodyStmt::SubStmt::FirstParamMove + S->NumParams; ++i)
460 StoredStmts[i] = Record.readSubStmt();
463 void ASTStmtReader::VisitCoreturnStmt(CoreturnStmt *S) {
465 S->CoreturnLoc = Record.readSourceLocation();
466 for (auto &SubStmt: S->SubStmts)
467 SubStmt = Record.readSubStmt();
468 S->IsImplicit = Record.readInt() != 0;
471 void ASTStmtReader::VisitCoawaitExpr(CoawaitExpr *E) {
473 E->KeywordLoc = ReadSourceLocation();
474 for (auto &SubExpr: E->SubExprs)
475 SubExpr = Record.readSubStmt();
476 E->OpaqueValue = cast_or_null<OpaqueValueExpr>(Record.readSubStmt());
477 E->setIsImplicit(Record.readInt() != 0);
480 void ASTStmtReader::VisitCoyieldExpr(CoyieldExpr *E) {
482 E->KeywordLoc = ReadSourceLocation();
483 for (auto &SubExpr: E->SubExprs)
484 SubExpr = Record.readSubStmt();
485 E->OpaqueValue = cast_or_null<OpaqueValueExpr>(Record.readSubStmt());
488 void ASTStmtReader::VisitDependentCoawaitExpr(DependentCoawaitExpr *E) {
490 E->KeywordLoc = ReadSourceLocation();
491 for (auto &SubExpr: E->SubExprs)
492 SubExpr = Record.readSubStmt();
495 void ASTStmtReader::VisitCapturedStmt(CapturedStmt *S) {
498 S->setCapturedDecl(ReadDeclAs<CapturedDecl>());
499 S->setCapturedRegionKind(static_cast<CapturedRegionKind>(Record.readInt()));
500 S->setCapturedRecordDecl(ReadDeclAs<RecordDecl>());
503 for (CapturedStmt::capture_init_iterator I = S->capture_init_begin(),
504 E = S->capture_init_end();
506 *I = Record.readSubExpr();
509 S->setCapturedStmt(Record.readSubStmt());
510 S->getCapturedDecl()->setBody(S->getCapturedStmt());
513 for (auto &I : S->captures()) {
514 I.VarAndKind.setPointer(ReadDeclAs<VarDecl>());
516 static_cast<CapturedStmt::VariableCaptureKind>(Record.readInt()));
517 I.Loc = ReadSourceLocation();
521 void ASTStmtReader::VisitExpr(Expr *E) {
523 E->setType(Record.readType());
524 E->setTypeDependent(Record.readInt());
525 E->setValueDependent(Record.readInt());
526 E->setInstantiationDependent(Record.readInt());
527 E->ExprBits.ContainsUnexpandedParameterPack = 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) {
536 E->ConstantExprBits.ResultKind = Record.readInt();
537 switch (E->ConstantExprBits.ResultKind) {
538 case ConstantExpr::RSK_Int64: {
539 E->Int64Result() = Record.readInt();
540 uint64_t tmp = Record.readInt();
541 E->ConstantExprBits.IsUnsigned = tmp & 0x1;
542 E->ConstantExprBits.BitWidth = tmp >> 1;
545 case ConstantExpr::RSK_APValue:
546 E->APValueResult() = Record.readAPValue();
548 E->setSubExpr(Record.readSubExpr());
551 void ASTStmtReader::VisitPredefinedExpr(PredefinedExpr *E) {
553 bool HasFunctionName = Record.readInt();
554 E->PredefinedExprBits.HasFunctionName = HasFunctionName;
555 E->PredefinedExprBits.Kind = Record.readInt();
556 E->setLocation(ReadSourceLocation());
558 E->setFunctionName(cast<StringLiteral>(Record.readSubExpr()));
561 void ASTStmtReader::VisitDeclRefExpr(DeclRefExpr *E) {
564 E->DeclRefExprBits.HasQualifier = Record.readInt();
565 E->DeclRefExprBits.HasFoundDecl = Record.readInt();
566 E->DeclRefExprBits.HasTemplateKWAndArgsInfo = Record.readInt();
567 E->DeclRefExprBits.HadMultipleCandidates = Record.readInt();
568 E->DeclRefExprBits.RefersToEnclosingVariableOrCapture = Record.readInt();
569 E->DeclRefExprBits.NonOdrUseReason = Record.readInt();
570 unsigned NumTemplateArgs = 0;
571 if (E->hasTemplateKWAndArgsInfo())
572 NumTemplateArgs = Record.readInt();
574 if (E->hasQualifier())
575 new (E->getTrailingObjects<NestedNameSpecifierLoc>())
576 NestedNameSpecifierLoc(Record.readNestedNameSpecifierLoc());
578 if (E->hasFoundDecl())
579 *E->getTrailingObjects<NamedDecl *>() = ReadDeclAs<NamedDecl>();
581 if (E->hasTemplateKWAndArgsInfo())
582 ReadTemplateKWAndArgsInfo(
583 *E->getTrailingObjects<ASTTemplateKWAndArgsInfo>(),
584 E->getTrailingObjects<TemplateArgumentLoc>(), NumTemplateArgs);
586 E->setDecl(ReadDeclAs<ValueDecl>());
587 E->setLocation(ReadSourceLocation());
588 ReadDeclarationNameLoc(E->DNLoc, E->getDecl()->getDeclName());
591 void ASTStmtReader::VisitIntegerLiteral(IntegerLiteral *E) {
593 E->setLocation(ReadSourceLocation());
594 E->setValue(Record.getContext(), Record.readAPInt());
597 void ASTStmtReader::VisitFixedPointLiteral(FixedPointLiteral *E) {
599 E->setLocation(ReadSourceLocation());
600 E->setValue(Record.getContext(), Record.readAPInt());
603 void ASTStmtReader::VisitFloatingLiteral(FloatingLiteral *E) {
606 static_cast<llvm::APFloatBase::Semantics>(Record.readInt()));
607 E->setExact(Record.readInt());
608 E->setValue(Record.getContext(), Record.readAPFloat(E->getSemantics()));
609 E->setLocation(ReadSourceLocation());
612 void ASTStmtReader::VisitImaginaryLiteral(ImaginaryLiteral *E) {
614 E->setSubExpr(Record.readSubExpr());
617 void ASTStmtReader::VisitStringLiteral(StringLiteral *E) {
620 // NumConcatenated, Length and CharByteWidth are set by the empty
621 // ctor since they are needed to allocate storage for the trailing objects.
622 unsigned NumConcatenated = Record.readInt();
623 unsigned Length = Record.readInt();
624 unsigned CharByteWidth = Record.readInt();
625 assert((NumConcatenated == E->getNumConcatenated()) &&
626 "Wrong number of concatenated tokens!");
627 assert((Length == E->getLength()) && "Wrong Length!");
628 assert((CharByteWidth == E->getCharByteWidth()) && "Wrong character width!");
629 E->StringLiteralBits.Kind = Record.readInt();
630 E->StringLiteralBits.IsPascal = Record.readInt();
632 // The character width is originally computed via mapCharByteWidth.
633 // Check that the deserialized character width is consistant with the result
634 // of calling mapCharByteWidth.
635 assert((CharByteWidth ==
636 StringLiteral::mapCharByteWidth(Record.getContext().getTargetInfo(),
638 "Wrong character width!");
640 // Deserialize the trailing array of SourceLocation.
641 for (unsigned I = 0; I < NumConcatenated; ++I)
642 E->setStrTokenLoc(I, ReadSourceLocation());
644 // Deserialize the trailing array of char holding the string data.
645 char *StrData = E->getStrDataAsChar();
646 for (unsigned I = 0; I < Length * CharByteWidth; ++I)
647 StrData[I] = Record.readInt();
650 void ASTStmtReader::VisitCharacterLiteral(CharacterLiteral *E) {
652 E->setValue(Record.readInt());
653 E->setLocation(ReadSourceLocation());
654 E->setKind(static_cast<CharacterLiteral::CharacterKind>(Record.readInt()));
657 void ASTStmtReader::VisitParenExpr(ParenExpr *E) {
659 E->setLParen(ReadSourceLocation());
660 E->setRParen(ReadSourceLocation());
661 E->setSubExpr(Record.readSubExpr());
664 void ASTStmtReader::VisitParenListExpr(ParenListExpr *E) {
666 unsigned NumExprs = Record.readInt();
667 assert((NumExprs == E->getNumExprs()) && "Wrong NumExprs!");
668 for (unsigned I = 0; I != NumExprs; ++I)
669 E->getTrailingObjects<Stmt *>()[I] = Record.readSubStmt();
670 E->LParenLoc = ReadSourceLocation();
671 E->RParenLoc = ReadSourceLocation();
674 void ASTStmtReader::VisitUnaryOperator(UnaryOperator *E) {
676 E->setSubExpr(Record.readSubExpr());
677 E->setOpcode((UnaryOperator::Opcode)Record.readInt());
678 E->setOperatorLoc(ReadSourceLocation());
679 E->setCanOverflow(Record.readInt());
682 void ASTStmtReader::VisitOffsetOfExpr(OffsetOfExpr *E) {
684 assert(E->getNumComponents() == Record.peekInt());
686 assert(E->getNumExpressions() == Record.peekInt());
688 E->setOperatorLoc(ReadSourceLocation());
689 E->setRParenLoc(ReadSourceLocation());
690 E->setTypeSourceInfo(GetTypeSourceInfo());
691 for (unsigned I = 0, N = E->getNumComponents(); I != N; ++I) {
692 auto Kind = static_cast<OffsetOfNode::Kind>(Record.readInt());
693 SourceLocation Start = ReadSourceLocation();
694 SourceLocation End = ReadSourceLocation();
696 case OffsetOfNode::Array:
697 E->setComponent(I, OffsetOfNode(Start, Record.readInt(), End));
700 case OffsetOfNode::Field:
702 I, OffsetOfNode(Start, ReadDeclAs<FieldDecl>(), End));
705 case OffsetOfNode::Identifier:
708 OffsetOfNode(Start, Record.getIdentifierInfo(), End));
711 case OffsetOfNode::Base: {
712 auto *Base = new (Record.getContext()) CXXBaseSpecifier();
713 *Base = Record.readCXXBaseSpecifier();
714 E->setComponent(I, OffsetOfNode(Base));
720 for (unsigned I = 0, N = E->getNumExpressions(); I != N; ++I)
721 E->setIndexExpr(I, Record.readSubExpr());
724 void ASTStmtReader::VisitUnaryExprOrTypeTraitExpr(UnaryExprOrTypeTraitExpr *E) {
726 E->setKind(static_cast<UnaryExprOrTypeTrait>(Record.readInt()));
727 if (Record.peekInt() == 0) {
728 E->setArgument(Record.readSubExpr());
731 E->setArgument(GetTypeSourceInfo());
733 E->setOperatorLoc(ReadSourceLocation());
734 E->setRParenLoc(ReadSourceLocation());
737 void ASTStmtReader::VisitConceptSpecializationExpr(
738 ConceptSpecializationExpr *E) {
740 unsigned NumTemplateArgs = Record.readInt();
741 E->NestedNameSpec = Record.readNestedNameSpecifierLoc();
742 E->TemplateKWLoc = Record.readSourceLocation();
743 E->ConceptNameLoc = Record.readSourceLocation();
744 E->FoundDecl = ReadDeclAs<NamedDecl>();
745 E->NamedConcept.setPointer(ReadDeclAs<ConceptDecl>());
746 const ASTTemplateArgumentListInfo *ArgsAsWritten =
747 Record.readASTTemplateArgumentListInfo();
748 llvm::SmallVector<TemplateArgument, 4> Args;
749 for (unsigned I = 0; I < NumTemplateArgs; ++I)
750 Args.push_back(Record.readTemplateArgument());
751 E->setTemplateArguments(ArgsAsWritten, Args);
752 E->NamedConcept.setInt(Record.readInt() == 1);
755 void ASTStmtReader::VisitArraySubscriptExpr(ArraySubscriptExpr *E) {
757 E->setLHS(Record.readSubExpr());
758 E->setRHS(Record.readSubExpr());
759 E->setRBracketLoc(ReadSourceLocation());
762 void ASTStmtReader::VisitOMPArraySectionExpr(OMPArraySectionExpr *E) {
764 E->setBase(Record.readSubExpr());
765 E->setLowerBound(Record.readSubExpr());
766 E->setLength(Record.readSubExpr());
767 E->setColonLoc(ReadSourceLocation());
768 E->setRBracketLoc(ReadSourceLocation());
771 void ASTStmtReader::VisitCallExpr(CallExpr *E) {
773 unsigned NumArgs = Record.readInt();
774 assert((NumArgs == E->getNumArgs()) && "Wrong NumArgs!");
775 E->setRParenLoc(ReadSourceLocation());
776 E->setCallee(Record.readSubExpr());
777 for (unsigned I = 0; I != NumArgs; ++I)
778 E->setArg(I, Record.readSubExpr());
779 E->setADLCallKind(static_cast<CallExpr::ADLCallKind>(Record.readInt()));
782 void ASTStmtReader::VisitCXXMemberCallExpr(CXXMemberCallExpr *E) {
786 void ASTStmtReader::VisitMemberExpr(MemberExpr *E) {
789 bool HasQualifier = Record.readInt();
790 bool HasFoundDecl = Record.readInt();
791 bool HasTemplateInfo = Record.readInt();
792 unsigned NumTemplateArgs = Record.readInt();
794 E->Base = Record.readSubExpr();
795 E->MemberDecl = Record.readDeclAs<ValueDecl>();
796 Record.readDeclarationNameLoc(E->MemberDNLoc, E->MemberDecl->getDeclName());
797 E->MemberLoc = Record.readSourceLocation();
798 E->MemberExprBits.IsArrow = Record.readInt();
799 E->MemberExprBits.HasQualifierOrFoundDecl = HasQualifier || HasFoundDecl;
800 E->MemberExprBits.HasTemplateKWAndArgsInfo = HasTemplateInfo;
801 E->MemberExprBits.HadMultipleCandidates = Record.readInt();
802 E->MemberExprBits.NonOdrUseReason = Record.readInt();
803 E->MemberExprBits.OperatorLoc = Record.readSourceLocation();
805 if (HasQualifier || HasFoundDecl) {
806 DeclAccessPair FoundDecl;
808 auto *FoundD = Record.readDeclAs<NamedDecl>();
809 auto AS = (AccessSpecifier)Record.readInt();
810 FoundDecl = DeclAccessPair::make(FoundD, AS);
812 FoundDecl = DeclAccessPair::make(E->MemberDecl,
813 E->MemberDecl->getAccess());
815 E->getTrailingObjects<MemberExprNameQualifier>()->FoundDecl = FoundDecl;
817 NestedNameSpecifierLoc QualifierLoc;
819 QualifierLoc = Record.readNestedNameSpecifierLoc();
820 E->getTrailingObjects<MemberExprNameQualifier>()->QualifierLoc =
825 ReadTemplateKWAndArgsInfo(
826 *E->getTrailingObjects<ASTTemplateKWAndArgsInfo>(),
827 E->getTrailingObjects<TemplateArgumentLoc>(), NumTemplateArgs);
830 void ASTStmtReader::VisitObjCIsaExpr(ObjCIsaExpr *E) {
832 E->setBase(Record.readSubExpr());
833 E->setIsaMemberLoc(ReadSourceLocation());
834 E->setOpLoc(ReadSourceLocation());
835 E->setArrow(Record.readInt());
839 VisitObjCIndirectCopyRestoreExpr(ObjCIndirectCopyRestoreExpr *E) {
841 E->Operand = Record.readSubExpr();
842 E->setShouldCopy(Record.readInt());
845 void ASTStmtReader::VisitObjCBridgedCastExpr(ObjCBridgedCastExpr *E) {
846 VisitExplicitCastExpr(E);
847 E->LParenLoc = ReadSourceLocation();
848 E->BridgeKeywordLoc = ReadSourceLocation();
849 E->Kind = Record.readInt();
852 void ASTStmtReader::VisitCastExpr(CastExpr *E) {
854 unsigned NumBaseSpecs = Record.readInt();
855 assert(NumBaseSpecs == E->path_size());
856 E->setSubExpr(Record.readSubExpr());
857 E->setCastKind((CastKind)Record.readInt());
858 CastExpr::path_iterator BaseI = E->path_begin();
859 while (NumBaseSpecs--) {
860 auto *BaseSpec = new (Record.getContext()) CXXBaseSpecifier;
861 *BaseSpec = Record.readCXXBaseSpecifier();
866 void ASTStmtReader::VisitBinaryOperator(BinaryOperator *E) {
868 E->setLHS(Record.readSubExpr());
869 E->setRHS(Record.readSubExpr());
870 E->setOpcode((BinaryOperator::Opcode)Record.readInt());
871 E->setOperatorLoc(ReadSourceLocation());
872 E->setFPFeatures(FPOptions(Record.readInt()));
875 void ASTStmtReader::VisitCompoundAssignOperator(CompoundAssignOperator *E) {
876 VisitBinaryOperator(E);
877 E->setComputationLHSType(Record.readType());
878 E->setComputationResultType(Record.readType());
881 void ASTStmtReader::VisitConditionalOperator(ConditionalOperator *E) {
883 E->SubExprs[ConditionalOperator::COND] = Record.readSubExpr();
884 E->SubExprs[ConditionalOperator::LHS] = Record.readSubExpr();
885 E->SubExprs[ConditionalOperator::RHS] = Record.readSubExpr();
886 E->QuestionLoc = ReadSourceLocation();
887 E->ColonLoc = ReadSourceLocation();
891 ASTStmtReader::VisitBinaryConditionalOperator(BinaryConditionalOperator *E) {
893 E->OpaqueValue = cast<OpaqueValueExpr>(Record.readSubExpr());
894 E->SubExprs[BinaryConditionalOperator::COMMON] = Record.readSubExpr();
895 E->SubExprs[BinaryConditionalOperator::COND] = Record.readSubExpr();
896 E->SubExprs[BinaryConditionalOperator::LHS] = Record.readSubExpr();
897 E->SubExprs[BinaryConditionalOperator::RHS] = Record.readSubExpr();
898 E->QuestionLoc = ReadSourceLocation();
899 E->ColonLoc = ReadSourceLocation();
902 void ASTStmtReader::VisitImplicitCastExpr(ImplicitCastExpr *E) {
904 E->setIsPartOfExplicitCast(Record.readInt());
907 void ASTStmtReader::VisitExplicitCastExpr(ExplicitCastExpr *E) {
909 E->setTypeInfoAsWritten(GetTypeSourceInfo());
912 void ASTStmtReader::VisitCStyleCastExpr(CStyleCastExpr *E) {
913 VisitExplicitCastExpr(E);
914 E->setLParenLoc(ReadSourceLocation());
915 E->setRParenLoc(ReadSourceLocation());
918 void ASTStmtReader::VisitCompoundLiteralExpr(CompoundLiteralExpr *E) {
920 E->setLParenLoc(ReadSourceLocation());
921 E->setTypeSourceInfo(GetTypeSourceInfo());
922 E->setInitializer(Record.readSubExpr());
923 E->setFileScope(Record.readInt());
926 void ASTStmtReader::VisitExtVectorElementExpr(ExtVectorElementExpr *E) {
928 E->setBase(Record.readSubExpr());
929 E->setAccessor(Record.getIdentifierInfo());
930 E->setAccessorLoc(ReadSourceLocation());
933 void ASTStmtReader::VisitInitListExpr(InitListExpr *E) {
935 if (auto *SyntForm = cast_or_null<InitListExpr>(Record.readSubStmt()))
936 E->setSyntacticForm(SyntForm);
937 E->setLBraceLoc(ReadSourceLocation());
938 E->setRBraceLoc(ReadSourceLocation());
939 bool isArrayFiller = Record.readInt();
940 Expr *filler = nullptr;
942 filler = Record.readSubExpr();
943 E->ArrayFillerOrUnionFieldInit = filler;
945 E->ArrayFillerOrUnionFieldInit = ReadDeclAs<FieldDecl>();
946 E->sawArrayRangeDesignator(Record.readInt());
947 unsigned NumInits = Record.readInt();
948 E->reserveInits(Record.getContext(), NumInits);
950 for (unsigned I = 0; I != NumInits; ++I) {
951 Expr *init = Record.readSubExpr();
952 E->updateInit(Record.getContext(), I, init ? init : filler);
955 for (unsigned I = 0; I != NumInits; ++I)
956 E->updateInit(Record.getContext(), I, Record.readSubExpr());
960 void ASTStmtReader::VisitDesignatedInitExpr(DesignatedInitExpr *E) {
961 using Designator = DesignatedInitExpr::Designator;
964 unsigned NumSubExprs = Record.readInt();
965 assert(NumSubExprs == E->getNumSubExprs() && "Wrong number of subexprs");
966 for (unsigned I = 0; I != NumSubExprs; ++I)
967 E->setSubExpr(I, Record.readSubExpr());
968 E->setEqualOrColonLoc(ReadSourceLocation());
969 E->setGNUSyntax(Record.readInt());
971 SmallVector<Designator, 4> Designators;
972 while (Record.getIdx() < Record.size()) {
973 switch ((DesignatorTypes)Record.readInt()) {
974 case DESIG_FIELD_DECL: {
975 auto *Field = ReadDeclAs<FieldDecl>();
976 SourceLocation DotLoc = ReadSourceLocation();
977 SourceLocation FieldLoc = ReadSourceLocation();
978 Designators.push_back(Designator(Field->getIdentifier(), DotLoc,
980 Designators.back().setField(Field);
984 case DESIG_FIELD_NAME: {
985 const IdentifierInfo *Name = Record.getIdentifierInfo();
986 SourceLocation DotLoc = ReadSourceLocation();
987 SourceLocation FieldLoc = ReadSourceLocation();
988 Designators.push_back(Designator(Name, DotLoc, FieldLoc));
993 unsigned Index = Record.readInt();
994 SourceLocation LBracketLoc = ReadSourceLocation();
995 SourceLocation RBracketLoc = ReadSourceLocation();
996 Designators.push_back(Designator(Index, LBracketLoc, RBracketLoc));
1000 case DESIG_ARRAY_RANGE: {
1001 unsigned Index = Record.readInt();
1002 SourceLocation LBracketLoc = ReadSourceLocation();
1003 SourceLocation EllipsisLoc = ReadSourceLocation();
1004 SourceLocation RBracketLoc = ReadSourceLocation();
1005 Designators.push_back(Designator(Index, LBracketLoc, EllipsisLoc,
1011 E->setDesignators(Record.getContext(),
1012 Designators.data(), Designators.size());
1015 void ASTStmtReader::VisitDesignatedInitUpdateExpr(DesignatedInitUpdateExpr *E) {
1017 E->setBase(Record.readSubExpr());
1018 E->setUpdater(Record.readSubExpr());
1021 void ASTStmtReader::VisitNoInitExpr(NoInitExpr *E) {
1025 void ASTStmtReader::VisitArrayInitLoopExpr(ArrayInitLoopExpr *E) {
1027 E->SubExprs[0] = Record.readSubExpr();
1028 E->SubExprs[1] = Record.readSubExpr();
1031 void ASTStmtReader::VisitArrayInitIndexExpr(ArrayInitIndexExpr *E) {
1035 void ASTStmtReader::VisitImplicitValueInitExpr(ImplicitValueInitExpr *E) {
1039 void ASTStmtReader::VisitVAArgExpr(VAArgExpr *E) {
1041 E->setSubExpr(Record.readSubExpr());
1042 E->setWrittenTypeInfo(GetTypeSourceInfo());
1043 E->setBuiltinLoc(ReadSourceLocation());
1044 E->setRParenLoc(ReadSourceLocation());
1045 E->setIsMicrosoftABI(Record.readInt());
1048 void ASTStmtReader::VisitSourceLocExpr(SourceLocExpr *E) {
1050 E->ParentContext = ReadDeclAs<DeclContext>();
1051 E->BuiltinLoc = ReadSourceLocation();
1052 E->RParenLoc = ReadSourceLocation();
1053 E->SourceLocExprBits.Kind =
1054 static_cast<SourceLocExpr::IdentKind>(Record.readInt());
1057 void ASTStmtReader::VisitAddrLabelExpr(AddrLabelExpr *E) {
1059 E->setAmpAmpLoc(ReadSourceLocation());
1060 E->setLabelLoc(ReadSourceLocation());
1061 E->setLabel(ReadDeclAs<LabelDecl>());
1064 void ASTStmtReader::VisitStmtExpr(StmtExpr *E) {
1066 E->setLParenLoc(ReadSourceLocation());
1067 E->setRParenLoc(ReadSourceLocation());
1068 E->setSubStmt(cast_or_null<CompoundStmt>(Record.readSubStmt()));
1071 void ASTStmtReader::VisitChooseExpr(ChooseExpr *E) {
1073 E->setCond(Record.readSubExpr());
1074 E->setLHS(Record.readSubExpr());
1075 E->setRHS(Record.readSubExpr());
1076 E->setBuiltinLoc(ReadSourceLocation());
1077 E->setRParenLoc(ReadSourceLocation());
1078 E->setIsConditionTrue(Record.readInt());
1081 void ASTStmtReader::VisitGNUNullExpr(GNUNullExpr *E) {
1083 E->setTokenLocation(ReadSourceLocation());
1086 void ASTStmtReader::VisitShuffleVectorExpr(ShuffleVectorExpr *E) {
1088 SmallVector<Expr *, 16> Exprs;
1089 unsigned NumExprs = Record.readInt();
1091 Exprs.push_back(Record.readSubExpr());
1092 E->setExprs(Record.getContext(), Exprs);
1093 E->setBuiltinLoc(ReadSourceLocation());
1094 E->setRParenLoc(ReadSourceLocation());
1097 void ASTStmtReader::VisitConvertVectorExpr(ConvertVectorExpr *E) {
1099 E->BuiltinLoc = ReadSourceLocation();
1100 E->RParenLoc = ReadSourceLocation();
1101 E->TInfo = GetTypeSourceInfo();
1102 E->SrcExpr = Record.readSubExpr();
1105 void ASTStmtReader::VisitBlockExpr(BlockExpr *E) {
1107 E->setBlockDecl(ReadDeclAs<BlockDecl>());
1110 void ASTStmtReader::VisitGenericSelectionExpr(GenericSelectionExpr *E) {
1113 unsigned NumAssocs = Record.readInt();
1114 assert(NumAssocs == E->getNumAssocs() && "Wrong NumAssocs!");
1115 E->ResultIndex = Record.readInt();
1116 E->GenericSelectionExprBits.GenericLoc = ReadSourceLocation();
1117 E->DefaultLoc = ReadSourceLocation();
1118 E->RParenLoc = ReadSourceLocation();
1120 Stmt **Stmts = E->getTrailingObjects<Stmt *>();
1121 // Add 1 to account for the controlling expression which is the first
1122 // expression in the trailing array of Stmt *. This is not needed for
1123 // the trailing array of TypeSourceInfo *.
1124 for (unsigned I = 0, N = NumAssocs + 1; I < N; ++I)
1125 Stmts[I] = Record.readSubExpr();
1127 TypeSourceInfo **TSIs = E->getTrailingObjects<TypeSourceInfo *>();
1128 for (unsigned I = 0, N = NumAssocs; I < N; ++I)
1129 TSIs[I] = GetTypeSourceInfo();
1132 void ASTStmtReader::VisitPseudoObjectExpr(PseudoObjectExpr *E) {
1134 unsigned numSemanticExprs = Record.readInt();
1135 assert(numSemanticExprs + 1 == E->PseudoObjectExprBits.NumSubExprs);
1136 E->PseudoObjectExprBits.ResultIndex = Record.readInt();
1138 // Read the syntactic expression.
1139 E->getSubExprsBuffer()[0] = Record.readSubExpr();
1141 // Read all the semantic expressions.
1142 for (unsigned i = 0; i != numSemanticExprs; ++i) {
1143 Expr *subExpr = Record.readSubExpr();
1144 E->getSubExprsBuffer()[i+1] = subExpr;
1148 void ASTStmtReader::VisitAtomicExpr(AtomicExpr *E) {
1150 E->Op = AtomicExpr::AtomicOp(Record.readInt());
1151 E->NumSubExprs = AtomicExpr::getNumSubExprs(E->Op);
1152 for (unsigned I = 0; I != E->NumSubExprs; ++I)
1153 E->SubExprs[I] = Record.readSubExpr();
1154 E->BuiltinLoc = ReadSourceLocation();
1155 E->RParenLoc = ReadSourceLocation();
1158 //===----------------------------------------------------------------------===//
1159 // Objective-C Expressions and Statements
1161 void ASTStmtReader::VisitObjCStringLiteral(ObjCStringLiteral *E) {
1163 E->setString(cast<StringLiteral>(Record.readSubStmt()));
1164 E->setAtLoc(ReadSourceLocation());
1167 void ASTStmtReader::VisitObjCBoxedExpr(ObjCBoxedExpr *E) {
1169 // could be one of several IntegerLiteral, FloatLiteral, etc.
1170 E->SubExpr = Record.readSubStmt();
1171 E->BoxingMethod = ReadDeclAs<ObjCMethodDecl>();
1172 E->Range = ReadSourceRange();
1175 void ASTStmtReader::VisitObjCArrayLiteral(ObjCArrayLiteral *E) {
1177 unsigned NumElements = Record.readInt();
1178 assert(NumElements == E->getNumElements() && "Wrong number of elements");
1179 Expr **Elements = E->getElements();
1180 for (unsigned I = 0, N = NumElements; I != N; ++I)
1181 Elements[I] = Record.readSubExpr();
1182 E->ArrayWithObjectsMethod = ReadDeclAs<ObjCMethodDecl>();
1183 E->Range = ReadSourceRange();
1186 void ASTStmtReader::VisitObjCDictionaryLiteral(ObjCDictionaryLiteral *E) {
1188 unsigned NumElements = Record.readInt();
1189 assert(NumElements == E->getNumElements() && "Wrong number of elements");
1190 bool HasPackExpansions = Record.readInt();
1191 assert(HasPackExpansions == E->HasPackExpansions &&"Pack expansion mismatch");
1193 E->getTrailingObjects<ObjCDictionaryLiteral::KeyValuePair>();
1195 E->getTrailingObjects<ObjCDictionaryLiteral::ExpansionData>();
1196 for (unsigned I = 0; I != NumElements; ++I) {
1197 KeyValues[I].Key = Record.readSubExpr();
1198 KeyValues[I].Value = Record.readSubExpr();
1199 if (HasPackExpansions) {
1200 Expansions[I].EllipsisLoc = ReadSourceLocation();
1201 Expansions[I].NumExpansionsPlusOne = Record.readInt();
1204 E->DictWithObjectsMethod = ReadDeclAs<ObjCMethodDecl>();
1205 E->Range = ReadSourceRange();
1208 void ASTStmtReader::VisitObjCEncodeExpr(ObjCEncodeExpr *E) {
1210 E->setEncodedTypeSourceInfo(GetTypeSourceInfo());
1211 E->setAtLoc(ReadSourceLocation());
1212 E->setRParenLoc(ReadSourceLocation());
1215 void ASTStmtReader::VisitObjCSelectorExpr(ObjCSelectorExpr *E) {
1217 E->setSelector(Record.readSelector());
1218 E->setAtLoc(ReadSourceLocation());
1219 E->setRParenLoc(ReadSourceLocation());
1222 void ASTStmtReader::VisitObjCProtocolExpr(ObjCProtocolExpr *E) {
1224 E->setProtocol(ReadDeclAs<ObjCProtocolDecl>());
1225 E->setAtLoc(ReadSourceLocation());
1226 E->ProtoLoc = ReadSourceLocation();
1227 E->setRParenLoc(ReadSourceLocation());
1230 void ASTStmtReader::VisitObjCIvarRefExpr(ObjCIvarRefExpr *E) {
1232 E->setDecl(ReadDeclAs<ObjCIvarDecl>());
1233 E->setLocation(ReadSourceLocation());
1234 E->setOpLoc(ReadSourceLocation());
1235 E->setBase(Record.readSubExpr());
1236 E->setIsArrow(Record.readInt());
1237 E->setIsFreeIvar(Record.readInt());
1240 void ASTStmtReader::VisitObjCPropertyRefExpr(ObjCPropertyRefExpr *E) {
1242 unsigned MethodRefFlags = Record.readInt();
1243 bool Implicit = Record.readInt() != 0;
1245 auto *Getter = ReadDeclAs<ObjCMethodDecl>();
1246 auto *Setter = ReadDeclAs<ObjCMethodDecl>();
1247 E->setImplicitProperty(Getter, Setter, MethodRefFlags);
1249 E->setExplicitProperty(ReadDeclAs<ObjCPropertyDecl>(), MethodRefFlags);
1251 E->setLocation(ReadSourceLocation());
1252 E->setReceiverLocation(ReadSourceLocation());
1253 switch (Record.readInt()) {
1255 E->setBase(Record.readSubExpr());
1258 E->setSuperReceiver(Record.readType());
1261 E->setClassReceiver(ReadDeclAs<ObjCInterfaceDecl>());
1266 void ASTStmtReader::VisitObjCSubscriptRefExpr(ObjCSubscriptRefExpr *E) {
1268 E->setRBracket(ReadSourceLocation());
1269 E->setBaseExpr(Record.readSubExpr());
1270 E->setKeyExpr(Record.readSubExpr());
1271 E->GetAtIndexMethodDecl = ReadDeclAs<ObjCMethodDecl>();
1272 E->SetAtIndexMethodDecl = ReadDeclAs<ObjCMethodDecl>();
1275 void ASTStmtReader::VisitObjCMessageExpr(ObjCMessageExpr *E) {
1277 assert(Record.peekInt() == E->getNumArgs());
1279 unsigned NumStoredSelLocs = Record.readInt();
1280 E->SelLocsKind = Record.readInt();
1281 E->setDelegateInitCall(Record.readInt());
1282 E->IsImplicit = Record.readInt();
1283 auto Kind = static_cast<ObjCMessageExpr::ReceiverKind>(Record.readInt());
1285 case ObjCMessageExpr::Instance:
1286 E->setInstanceReceiver(Record.readSubExpr());
1289 case ObjCMessageExpr::Class:
1290 E->setClassReceiver(GetTypeSourceInfo());
1293 case ObjCMessageExpr::SuperClass:
1294 case ObjCMessageExpr::SuperInstance: {
1295 QualType T = Record.readType();
1296 SourceLocation SuperLoc = ReadSourceLocation();
1297 E->setSuper(SuperLoc, T, Kind == ObjCMessageExpr::SuperInstance);
1302 assert(Kind == E->getReceiverKind());
1304 if (Record.readInt())
1305 E->setMethodDecl(ReadDeclAs<ObjCMethodDecl>());
1307 E->setSelector(Record.readSelector());
1309 E->LBracLoc = ReadSourceLocation();
1310 E->RBracLoc = ReadSourceLocation();
1312 for (unsigned I = 0, N = E->getNumArgs(); I != N; ++I)
1313 E->setArg(I, Record.readSubExpr());
1315 SourceLocation *Locs = E->getStoredSelLocs();
1316 for (unsigned I = 0; I != NumStoredSelLocs; ++I)
1317 Locs[I] = ReadSourceLocation();
1320 void ASTStmtReader::VisitObjCForCollectionStmt(ObjCForCollectionStmt *S) {
1322 S->setElement(Record.readSubStmt());
1323 S->setCollection(Record.readSubExpr());
1324 S->setBody(Record.readSubStmt());
1325 S->setForLoc(ReadSourceLocation());
1326 S->setRParenLoc(ReadSourceLocation());
1329 void ASTStmtReader::VisitObjCAtCatchStmt(ObjCAtCatchStmt *S) {
1331 S->setCatchBody(Record.readSubStmt());
1332 S->setCatchParamDecl(ReadDeclAs<VarDecl>());
1333 S->setAtCatchLoc(ReadSourceLocation());
1334 S->setRParenLoc(ReadSourceLocation());
1337 void ASTStmtReader::VisitObjCAtFinallyStmt(ObjCAtFinallyStmt *S) {
1339 S->setFinallyBody(Record.readSubStmt());
1340 S->setAtFinallyLoc(ReadSourceLocation());
1343 void ASTStmtReader::VisitObjCAutoreleasePoolStmt(ObjCAutoreleasePoolStmt *S) {
1344 VisitStmt(S); // FIXME: no test coverage.
1345 S->setSubStmt(Record.readSubStmt());
1346 S->setAtLoc(ReadSourceLocation());
1349 void ASTStmtReader::VisitObjCAtTryStmt(ObjCAtTryStmt *S) {
1351 assert(Record.peekInt() == S->getNumCatchStmts());
1353 bool HasFinally = Record.readInt();
1354 S->setTryBody(Record.readSubStmt());
1355 for (unsigned I = 0, N = S->getNumCatchStmts(); I != N; ++I)
1356 S->setCatchStmt(I, cast_or_null<ObjCAtCatchStmt>(Record.readSubStmt()));
1359 S->setFinallyStmt(Record.readSubStmt());
1360 S->setAtTryLoc(ReadSourceLocation());
1363 void ASTStmtReader::VisitObjCAtSynchronizedStmt(ObjCAtSynchronizedStmt *S) {
1364 VisitStmt(S); // FIXME: no test coverage.
1365 S->setSynchExpr(Record.readSubStmt());
1366 S->setSynchBody(Record.readSubStmt());
1367 S->setAtSynchronizedLoc(ReadSourceLocation());
1370 void ASTStmtReader::VisitObjCAtThrowStmt(ObjCAtThrowStmt *S) {
1371 VisitStmt(S); // FIXME: no test coverage.
1372 S->setThrowExpr(Record.readSubStmt());
1373 S->setThrowLoc(ReadSourceLocation());
1376 void ASTStmtReader::VisitObjCBoolLiteralExpr(ObjCBoolLiteralExpr *E) {
1378 E->setValue(Record.readInt());
1379 E->setLocation(ReadSourceLocation());
1382 void ASTStmtReader::VisitObjCAvailabilityCheckExpr(ObjCAvailabilityCheckExpr *E) {
1384 SourceRange R = Record.readSourceRange();
1385 E->AtLoc = R.getBegin();
1386 E->RParen = R.getEnd();
1387 E->VersionToCheck = Record.readVersionTuple();
1390 //===----------------------------------------------------------------------===//
1391 // C++ Expressions and Statements
1392 //===----------------------------------------------------------------------===//
1394 void ASTStmtReader::VisitCXXCatchStmt(CXXCatchStmt *S) {
1396 S->CatchLoc = ReadSourceLocation();
1397 S->ExceptionDecl = ReadDeclAs<VarDecl>();
1398 S->HandlerBlock = Record.readSubStmt();
1401 void ASTStmtReader::VisitCXXTryStmt(CXXTryStmt *S) {
1403 assert(Record.peekInt() == S->getNumHandlers() && "NumStmtFields is wrong ?");
1405 S->TryLoc = ReadSourceLocation();
1406 S->getStmts()[0] = Record.readSubStmt();
1407 for (unsigned i = 0, e = S->getNumHandlers(); i != e; ++i)
1408 S->getStmts()[i + 1] = Record.readSubStmt();
1411 void ASTStmtReader::VisitCXXForRangeStmt(CXXForRangeStmt *S) {
1413 S->ForLoc = ReadSourceLocation();
1414 S->CoawaitLoc = ReadSourceLocation();
1415 S->ColonLoc = ReadSourceLocation();
1416 S->RParenLoc = ReadSourceLocation();
1417 S->setInit(Record.readSubStmt());
1418 S->setRangeStmt(Record.readSubStmt());
1419 S->setBeginStmt(Record.readSubStmt());
1420 S->setEndStmt(Record.readSubStmt());
1421 S->setCond(Record.readSubExpr());
1422 S->setInc(Record.readSubExpr());
1423 S->setLoopVarStmt(Record.readSubStmt());
1424 S->setBody(Record.readSubStmt());
1427 void ASTStmtReader::VisitMSDependentExistsStmt(MSDependentExistsStmt *S) {
1429 S->KeywordLoc = ReadSourceLocation();
1430 S->IsIfExists = Record.readInt();
1431 S->QualifierLoc = Record.readNestedNameSpecifierLoc();
1432 ReadDeclarationNameInfo(S->NameInfo);
1433 S->SubStmt = Record.readSubStmt();
1436 void ASTStmtReader::VisitCXXOperatorCallExpr(CXXOperatorCallExpr *E) {
1438 E->CXXOperatorCallExprBits.OperatorKind = Record.readInt();
1439 E->CXXOperatorCallExprBits.FPFeatures = Record.readInt();
1440 E->Range = Record.readSourceRange();
1443 void ASTStmtReader::VisitCXXRewrittenBinaryOperator(
1444 CXXRewrittenBinaryOperator *E) {
1446 E->CXXRewrittenBinaryOperatorBits.IsReversed = Record.readInt();
1447 E->SemanticForm = Record.readSubExpr();
1450 void ASTStmtReader::VisitCXXConstructExpr(CXXConstructExpr *E) {
1453 unsigned NumArgs = Record.readInt();
1454 assert((NumArgs == E->getNumArgs()) && "Wrong NumArgs!");
1456 E->CXXConstructExprBits.Elidable = Record.readInt();
1457 E->CXXConstructExprBits.HadMultipleCandidates = Record.readInt();
1458 E->CXXConstructExprBits.ListInitialization = Record.readInt();
1459 E->CXXConstructExprBits.StdInitListInitialization = Record.readInt();
1460 E->CXXConstructExprBits.ZeroInitialization = Record.readInt();
1461 E->CXXConstructExprBits.ConstructionKind = Record.readInt();
1462 E->CXXConstructExprBits.Loc = ReadSourceLocation();
1463 E->Constructor = ReadDeclAs<CXXConstructorDecl>();
1464 E->ParenOrBraceRange = ReadSourceRange();
1466 for (unsigned I = 0; I != NumArgs; ++I)
1467 E->setArg(I, Record.readSubExpr());
1470 void ASTStmtReader::VisitCXXInheritedCtorInitExpr(CXXInheritedCtorInitExpr *E) {
1472 E->Constructor = ReadDeclAs<CXXConstructorDecl>();
1473 E->Loc = ReadSourceLocation();
1474 E->ConstructsVirtualBase = Record.readInt();
1475 E->InheritedFromVirtualBase = Record.readInt();
1478 void ASTStmtReader::VisitCXXTemporaryObjectExpr(CXXTemporaryObjectExpr *E) {
1479 VisitCXXConstructExpr(E);
1480 E->TSI = GetTypeSourceInfo();
1483 void ASTStmtReader::VisitLambdaExpr(LambdaExpr *E) {
1485 unsigned NumCaptures = Record.readInt();
1486 assert(NumCaptures == E->NumCaptures);(void)NumCaptures;
1487 E->IntroducerRange = ReadSourceRange();
1488 E->CaptureDefault = static_cast<LambdaCaptureDefault>(Record.readInt());
1489 E->CaptureDefaultLoc = ReadSourceLocation();
1490 E->ExplicitParams = Record.readInt();
1491 E->ExplicitResultType = Record.readInt();
1492 E->ClosingBrace = ReadSourceLocation();
1494 // Read capture initializers.
1495 for (LambdaExpr::capture_init_iterator C = E->capture_init_begin(),
1496 CEnd = E->capture_init_end();
1498 *C = Record.readSubExpr();
1502 ASTStmtReader::VisitCXXStdInitializerListExpr(CXXStdInitializerListExpr *E) {
1504 E->SubExpr = Record.readSubExpr();
1507 void ASTStmtReader::VisitCXXNamedCastExpr(CXXNamedCastExpr *E) {
1508 VisitExplicitCastExpr(E);
1509 SourceRange R = ReadSourceRange();
1510 E->Loc = R.getBegin();
1511 E->RParenLoc = R.getEnd();
1512 R = ReadSourceRange();
1513 E->AngleBrackets = R;
1516 void ASTStmtReader::VisitCXXStaticCastExpr(CXXStaticCastExpr *E) {
1517 return VisitCXXNamedCastExpr(E);
1520 void ASTStmtReader::VisitCXXDynamicCastExpr(CXXDynamicCastExpr *E) {
1521 return VisitCXXNamedCastExpr(E);
1524 void ASTStmtReader::VisitCXXReinterpretCastExpr(CXXReinterpretCastExpr *E) {
1525 return VisitCXXNamedCastExpr(E);
1528 void ASTStmtReader::VisitCXXConstCastExpr(CXXConstCastExpr *E) {
1529 return VisitCXXNamedCastExpr(E);
1532 void ASTStmtReader::VisitCXXFunctionalCastExpr(CXXFunctionalCastExpr *E) {
1533 VisitExplicitCastExpr(E);
1534 E->setLParenLoc(ReadSourceLocation());
1535 E->setRParenLoc(ReadSourceLocation());
1538 void ASTStmtReader::VisitBuiltinBitCastExpr(BuiltinBitCastExpr *E) {
1539 VisitExplicitCastExpr(E);
1540 E->KWLoc = ReadSourceLocation();
1541 E->RParenLoc = ReadSourceLocation();
1544 void ASTStmtReader::VisitUserDefinedLiteral(UserDefinedLiteral *E) {
1546 E->UDSuffixLoc = ReadSourceLocation();
1549 void ASTStmtReader::VisitCXXBoolLiteralExpr(CXXBoolLiteralExpr *E) {
1551 E->setValue(Record.readInt());
1552 E->setLocation(ReadSourceLocation());
1555 void ASTStmtReader::VisitCXXNullPtrLiteralExpr(CXXNullPtrLiteralExpr *E) {
1557 E->setLocation(ReadSourceLocation());
1560 void ASTStmtReader::VisitCXXTypeidExpr(CXXTypeidExpr *E) {
1562 E->setSourceRange(ReadSourceRange());
1563 if (E->isTypeOperand()) { // typeid(int)
1564 E->setTypeOperandSourceInfo(
1565 GetTypeSourceInfo());
1570 E->setExprOperand(Record.readSubExpr());
1573 void ASTStmtReader::VisitCXXThisExpr(CXXThisExpr *E) {
1575 E->setLocation(ReadSourceLocation());
1576 E->setImplicit(Record.readInt());
1579 void ASTStmtReader::VisitCXXThrowExpr(CXXThrowExpr *E) {
1581 E->CXXThrowExprBits.ThrowLoc = ReadSourceLocation();
1582 E->Operand = Record.readSubExpr();
1583 E->CXXThrowExprBits.IsThrownVariableInScope = Record.readInt();
1586 void ASTStmtReader::VisitCXXDefaultArgExpr(CXXDefaultArgExpr *E) {
1588 E->Param = ReadDeclAs<ParmVarDecl>();
1589 E->UsedContext = ReadDeclAs<DeclContext>();
1590 E->CXXDefaultArgExprBits.Loc = ReadSourceLocation();
1593 void ASTStmtReader::VisitCXXDefaultInitExpr(CXXDefaultInitExpr *E) {
1595 E->Field = ReadDeclAs<FieldDecl>();
1596 E->UsedContext = ReadDeclAs<DeclContext>();
1597 E->CXXDefaultInitExprBits.Loc = ReadSourceLocation();
1600 void ASTStmtReader::VisitCXXBindTemporaryExpr(CXXBindTemporaryExpr *E) {
1602 E->setTemporary(Record.readCXXTemporary());
1603 E->setSubExpr(Record.readSubExpr());
1606 void ASTStmtReader::VisitCXXScalarValueInitExpr(CXXScalarValueInitExpr *E) {
1608 E->TypeInfo = GetTypeSourceInfo();
1609 E->CXXScalarValueInitExprBits.RParenLoc = ReadSourceLocation();
1612 void ASTStmtReader::VisitCXXNewExpr(CXXNewExpr *E) {
1615 bool IsArray = Record.readInt();
1616 bool HasInit = Record.readInt();
1617 unsigned NumPlacementArgs = Record.readInt();
1618 bool IsParenTypeId = Record.readInt();
1620 E->CXXNewExprBits.IsGlobalNew = Record.readInt();
1621 E->CXXNewExprBits.ShouldPassAlignment = Record.readInt();
1622 E->CXXNewExprBits.UsualArrayDeleteWantsSize = Record.readInt();
1623 E->CXXNewExprBits.StoredInitializationStyle = Record.readInt();
1625 assert((IsArray == E->isArray()) && "Wrong IsArray!");
1626 assert((HasInit == E->hasInitializer()) && "Wrong HasInit!");
1627 assert((NumPlacementArgs == E->getNumPlacementArgs()) &&
1628 "Wrong NumPlacementArgs!");
1629 assert((IsParenTypeId == E->isParenTypeId()) && "Wrong IsParenTypeId!");
1632 (void)NumPlacementArgs;
1634 E->setOperatorNew(ReadDeclAs<FunctionDecl>());
1635 E->setOperatorDelete(ReadDeclAs<FunctionDecl>());
1636 E->AllocatedTypeInfo = GetTypeSourceInfo();
1638 E->getTrailingObjects<SourceRange>()[0] = ReadSourceRange();
1639 E->Range = ReadSourceRange();
1640 E->DirectInitRange = ReadSourceRange();
1642 // Install all the subexpressions.
1643 for (CXXNewExpr::raw_arg_iterator I = E->raw_arg_begin(),
1644 N = E->raw_arg_end();
1646 *I = Record.readSubStmt();
1649 void ASTStmtReader::VisitCXXDeleteExpr(CXXDeleteExpr *E) {
1651 E->CXXDeleteExprBits.GlobalDelete = Record.readInt();
1652 E->CXXDeleteExprBits.ArrayForm = Record.readInt();
1653 E->CXXDeleteExprBits.ArrayFormAsWritten = Record.readInt();
1654 E->CXXDeleteExprBits.UsualArrayDeleteWantsSize = Record.readInt();
1655 E->OperatorDelete = ReadDeclAs<FunctionDecl>();
1656 E->Argument = Record.readSubExpr();
1657 E->CXXDeleteExprBits.Loc = ReadSourceLocation();
1660 void ASTStmtReader::VisitCXXPseudoDestructorExpr(CXXPseudoDestructorExpr *E) {
1663 E->Base = Record.readSubExpr();
1664 E->IsArrow = Record.readInt();
1665 E->OperatorLoc = ReadSourceLocation();
1666 E->QualifierLoc = Record.readNestedNameSpecifierLoc();
1667 E->ScopeType = GetTypeSourceInfo();
1668 E->ColonColonLoc = ReadSourceLocation();
1669 E->TildeLoc = ReadSourceLocation();
1671 IdentifierInfo *II = Record.getIdentifierInfo();
1673 E->setDestroyedType(II, ReadSourceLocation());
1675 E->setDestroyedType(GetTypeSourceInfo());
1678 void ASTStmtReader::VisitExprWithCleanups(ExprWithCleanups *E) {
1681 unsigned NumObjects = Record.readInt();
1682 assert(NumObjects == E->getNumObjects());
1683 for (unsigned i = 0; i != NumObjects; ++i)
1684 E->getTrailingObjects<BlockDecl *>()[i] =
1685 ReadDeclAs<BlockDecl>();
1687 E->ExprWithCleanupsBits.CleanupsHaveSideEffects = Record.readInt();
1688 E->SubExpr = Record.readSubExpr();
1691 void ASTStmtReader::VisitCXXDependentScopeMemberExpr(
1692 CXXDependentScopeMemberExpr *E) {
1695 bool HasTemplateKWAndArgsInfo = Record.readInt();
1696 unsigned NumTemplateArgs = Record.readInt();
1697 bool HasFirstQualifierFoundInScope = Record.readInt();
1699 assert((HasTemplateKWAndArgsInfo == E->hasTemplateKWAndArgsInfo()) &&
1700 "Wrong HasTemplateKWAndArgsInfo!");
1702 (HasFirstQualifierFoundInScope == E->hasFirstQualifierFoundInScope()) &&
1703 "Wrong HasFirstQualifierFoundInScope!");
1705 if (HasTemplateKWAndArgsInfo)
1706 ReadTemplateKWAndArgsInfo(
1707 *E->getTrailingObjects<ASTTemplateKWAndArgsInfo>(),
1708 E->getTrailingObjects<TemplateArgumentLoc>(), NumTemplateArgs);
1710 assert((NumTemplateArgs == E->getNumTemplateArgs()) &&
1711 "Wrong NumTemplateArgs!");
1713 E->CXXDependentScopeMemberExprBits.IsArrow = Record.readInt();
1714 E->CXXDependentScopeMemberExprBits.OperatorLoc = ReadSourceLocation();
1715 E->BaseType = Record.readType();
1716 E->QualifierLoc = Record.readNestedNameSpecifierLoc();
1717 E->Base = Record.readSubExpr();
1719 if (HasFirstQualifierFoundInScope)
1720 *E->getTrailingObjects<NamedDecl *>() = ReadDeclAs<NamedDecl>();
1722 ReadDeclarationNameInfo(E->MemberNameInfo);
1726 ASTStmtReader::VisitDependentScopeDeclRefExpr(DependentScopeDeclRefExpr *E) {
1729 if (Record.readInt()) // HasTemplateKWAndArgsInfo
1730 ReadTemplateKWAndArgsInfo(
1731 *E->getTrailingObjects<ASTTemplateKWAndArgsInfo>(),
1732 E->getTrailingObjects<TemplateArgumentLoc>(),
1733 /*NumTemplateArgs=*/Record.readInt());
1735 E->QualifierLoc = Record.readNestedNameSpecifierLoc();
1736 ReadDeclarationNameInfo(E->NameInfo);
1740 ASTStmtReader::VisitCXXUnresolvedConstructExpr(CXXUnresolvedConstructExpr *E) {
1742 assert(Record.peekInt() == E->arg_size() &&
1743 "Read wrong record during creation ?");
1745 for (unsigned I = 0, N = E->arg_size(); I != N; ++I)
1746 E->setArg(I, Record.readSubExpr());
1747 E->TSI = GetTypeSourceInfo();
1748 E->setLParenLoc(ReadSourceLocation());
1749 E->setRParenLoc(ReadSourceLocation());
1752 void ASTStmtReader::VisitOverloadExpr(OverloadExpr *E) {
1755 unsigned NumResults = Record.readInt();
1756 bool HasTemplateKWAndArgsInfo = Record.readInt();
1757 assert((E->getNumDecls() == NumResults) && "Wrong NumResults!");
1758 assert((E->hasTemplateKWAndArgsInfo() == HasTemplateKWAndArgsInfo) &&
1759 "Wrong HasTemplateKWAndArgsInfo!");
1761 if (HasTemplateKWAndArgsInfo) {
1762 unsigned NumTemplateArgs = Record.readInt();
1763 ReadTemplateKWAndArgsInfo(*E->getTrailingASTTemplateKWAndArgsInfo(),
1764 E->getTrailingTemplateArgumentLoc(),
1766 assert((E->getNumTemplateArgs() == NumTemplateArgs) &&
1767 "Wrong NumTemplateArgs!");
1770 UnresolvedSet<8> Decls;
1771 for (unsigned I = 0; I != NumResults; ++I) {
1772 auto *D = ReadDeclAs<NamedDecl>();
1773 auto AS = (AccessSpecifier)Record.readInt();
1774 Decls.addDecl(D, AS);
1777 DeclAccessPair *Results = E->getTrailingResults();
1778 UnresolvedSetIterator Iter = Decls.begin();
1779 for (unsigned I = 0; I != NumResults; ++I) {
1780 Results[I] = (Iter + I).getPair();
1783 ReadDeclarationNameInfo(E->NameInfo);
1784 E->QualifierLoc = Record.readNestedNameSpecifierLoc();
1787 void ASTStmtReader::VisitUnresolvedMemberExpr(UnresolvedMemberExpr *E) {
1788 VisitOverloadExpr(E);
1789 E->UnresolvedMemberExprBits.IsArrow = Record.readInt();
1790 E->UnresolvedMemberExprBits.HasUnresolvedUsing = Record.readInt();
1791 E->Base = Record.readSubExpr();
1792 E->BaseType = Record.readType();
1793 E->OperatorLoc = ReadSourceLocation();
1796 void ASTStmtReader::VisitUnresolvedLookupExpr(UnresolvedLookupExpr *E) {
1797 VisitOverloadExpr(E);
1798 E->UnresolvedLookupExprBits.RequiresADL = Record.readInt();
1799 E->UnresolvedLookupExprBits.Overloaded = Record.readInt();
1800 E->NamingClass = ReadDeclAs<CXXRecordDecl>();
1803 void ASTStmtReader::VisitTypeTraitExpr(TypeTraitExpr *E) {
1805 E->TypeTraitExprBits.NumArgs = Record.readInt();
1806 E->TypeTraitExprBits.Kind = Record.readInt();
1807 E->TypeTraitExprBits.Value = Record.readInt();
1808 SourceRange Range = ReadSourceRange();
1809 E->Loc = Range.getBegin();
1810 E->RParenLoc = Range.getEnd();
1812 auto **Args = E->getTrailingObjects<TypeSourceInfo *>();
1813 for (unsigned I = 0, N = E->getNumArgs(); I != N; ++I)
1814 Args[I] = GetTypeSourceInfo();
1817 void ASTStmtReader::VisitArrayTypeTraitExpr(ArrayTypeTraitExpr *E) {
1819 E->ATT = (ArrayTypeTrait)Record.readInt();
1820 E->Value = (unsigned int)Record.readInt();
1821 SourceRange Range = ReadSourceRange();
1822 E->Loc = Range.getBegin();
1823 E->RParen = Range.getEnd();
1824 E->QueriedType = GetTypeSourceInfo();
1825 E->Dimension = Record.readSubExpr();
1828 void ASTStmtReader::VisitExpressionTraitExpr(ExpressionTraitExpr *E) {
1830 E->ET = (ExpressionTrait)Record.readInt();
1831 E->Value = (bool)Record.readInt();
1832 SourceRange Range = ReadSourceRange();
1833 E->QueriedExpression = Record.readSubExpr();
1834 E->Loc = Range.getBegin();
1835 E->RParen = Range.getEnd();
1838 void ASTStmtReader::VisitCXXNoexceptExpr(CXXNoexceptExpr *E) {
1840 E->CXXNoexceptExprBits.Value = Record.readInt();
1841 E->Range = ReadSourceRange();
1842 E->Operand = Record.readSubExpr();
1845 void ASTStmtReader::VisitPackExpansionExpr(PackExpansionExpr *E) {
1847 E->EllipsisLoc = ReadSourceLocation();
1848 E->NumExpansions = Record.readInt();
1849 E->Pattern = Record.readSubExpr();
1852 void ASTStmtReader::VisitSizeOfPackExpr(SizeOfPackExpr *E) {
1854 unsigned NumPartialArgs = Record.readInt();
1855 E->OperatorLoc = ReadSourceLocation();
1856 E->PackLoc = ReadSourceLocation();
1857 E->RParenLoc = ReadSourceLocation();
1858 E->Pack = Record.readDeclAs<NamedDecl>();
1859 if (E->isPartiallySubstituted()) {
1860 assert(E->Length == NumPartialArgs);
1861 for (auto *I = E->getTrailingObjects<TemplateArgument>(),
1862 *E = I + NumPartialArgs;
1864 new (I) TemplateArgument(Record.readTemplateArgument());
1865 } else if (!E->isValueDependent()) {
1866 E->Length = Record.readInt();
1870 void ASTStmtReader::VisitSubstNonTypeTemplateParmExpr(
1871 SubstNonTypeTemplateParmExpr *E) {
1873 E->Param = ReadDeclAs<NonTypeTemplateParmDecl>();
1874 E->SubstNonTypeTemplateParmExprBits.NameLoc = ReadSourceLocation();
1875 E->Replacement = Record.readSubExpr();
1878 void ASTStmtReader::VisitSubstNonTypeTemplateParmPackExpr(
1879 SubstNonTypeTemplateParmPackExpr *E) {
1881 E->Param = ReadDeclAs<NonTypeTemplateParmDecl>();
1882 TemplateArgument ArgPack = Record.readTemplateArgument();
1883 if (ArgPack.getKind() != TemplateArgument::Pack)
1886 E->Arguments = ArgPack.pack_begin();
1887 E->NumArguments = ArgPack.pack_size();
1888 E->NameLoc = ReadSourceLocation();
1891 void ASTStmtReader::VisitFunctionParmPackExpr(FunctionParmPackExpr *E) {
1893 E->NumParameters = Record.readInt();
1894 E->ParamPack = ReadDeclAs<ParmVarDecl>();
1895 E->NameLoc = ReadSourceLocation();
1896 auto **Parms = E->getTrailingObjects<VarDecl *>();
1897 for (unsigned i = 0, n = E->NumParameters; i != n; ++i)
1898 Parms[i] = ReadDeclAs<VarDecl>();
1901 void ASTStmtReader::VisitMaterializeTemporaryExpr(MaterializeTemporaryExpr *E) {
1903 E->State = Record.readSubExpr();
1904 auto *VD = ReadDeclAs<ValueDecl>();
1905 unsigned ManglingNumber = Record.readInt();
1906 E->setExtendingDecl(VD, ManglingNumber);
1909 void ASTStmtReader::VisitCXXFoldExpr(CXXFoldExpr *E) {
1911 E->LParenLoc = ReadSourceLocation();
1912 E->EllipsisLoc = ReadSourceLocation();
1913 E->RParenLoc = ReadSourceLocation();
1914 E->NumExpansions = Record.readInt();
1915 E->SubExprs[0] = Record.readSubExpr();
1916 E->SubExprs[1] = Record.readSubExpr();
1917 E->Opcode = (BinaryOperatorKind)Record.readInt();
1920 void ASTStmtReader::VisitOpaqueValueExpr(OpaqueValueExpr *E) {
1922 E->SourceExpr = Record.readSubExpr();
1923 E->OpaqueValueExprBits.Loc = ReadSourceLocation();
1924 E->setIsUnique(Record.readInt());
1927 void ASTStmtReader::VisitTypoExpr(TypoExpr *E) {
1928 llvm_unreachable("Cannot read TypoExpr nodes");
1931 //===----------------------------------------------------------------------===//
1932 // Microsoft Expressions and Statements
1933 //===----------------------------------------------------------------------===//
1934 void ASTStmtReader::VisitMSPropertyRefExpr(MSPropertyRefExpr *E) {
1936 E->IsArrow = (Record.readInt() != 0);
1937 E->BaseExpr = Record.readSubExpr();
1938 E->QualifierLoc = Record.readNestedNameSpecifierLoc();
1939 E->MemberLoc = ReadSourceLocation();
1940 E->TheDecl = ReadDeclAs<MSPropertyDecl>();
1943 void ASTStmtReader::VisitMSPropertySubscriptExpr(MSPropertySubscriptExpr *E) {
1945 E->setBase(Record.readSubExpr());
1946 E->setIdx(Record.readSubExpr());
1947 E->setRBracketLoc(ReadSourceLocation());
1950 void ASTStmtReader::VisitCXXUuidofExpr(CXXUuidofExpr *E) {
1952 E->setSourceRange(ReadSourceRange());
1953 std::string UuidStr = ReadString();
1954 E->setUuidStr(StringRef(UuidStr).copy(Record.getContext()));
1955 if (E->isTypeOperand()) { // __uuidof(ComType)
1956 E->setTypeOperandSourceInfo(
1957 GetTypeSourceInfo());
1962 E->setExprOperand(Record.readSubExpr());
1965 void ASTStmtReader::VisitSEHLeaveStmt(SEHLeaveStmt *S) {
1967 S->setLeaveLoc(ReadSourceLocation());
1970 void ASTStmtReader::VisitSEHExceptStmt(SEHExceptStmt *S) {
1972 S->Loc = ReadSourceLocation();
1973 S->Children[SEHExceptStmt::FILTER_EXPR] = Record.readSubStmt();
1974 S->Children[SEHExceptStmt::BLOCK] = Record.readSubStmt();
1977 void ASTStmtReader::VisitSEHFinallyStmt(SEHFinallyStmt *S) {
1979 S->Loc = ReadSourceLocation();
1980 S->Block = Record.readSubStmt();
1983 void ASTStmtReader::VisitSEHTryStmt(SEHTryStmt *S) {
1985 S->IsCXXTry = Record.readInt();
1986 S->TryLoc = ReadSourceLocation();
1987 S->Children[SEHTryStmt::TRY] = Record.readSubStmt();
1988 S->Children[SEHTryStmt::HANDLER] = Record.readSubStmt();
1991 //===----------------------------------------------------------------------===//
1992 // CUDA Expressions and Statements
1993 //===----------------------------------------------------------------------===//
1995 void ASTStmtReader::VisitCUDAKernelCallExpr(CUDAKernelCallExpr *E) {
1997 E->setPreArg(CUDAKernelCallExpr::CONFIG, Record.readSubExpr());
2000 //===----------------------------------------------------------------------===//
2001 // OpenCL Expressions and Statements.
2002 //===----------------------------------------------------------------------===//
2003 void ASTStmtReader::VisitAsTypeExpr(AsTypeExpr *E) {
2005 E->BuiltinLoc = ReadSourceLocation();
2006 E->RParenLoc = ReadSourceLocation();
2007 E->SrcExpr = Record.readSubExpr();
2010 //===----------------------------------------------------------------------===//
2011 // OpenMP Directives.
2012 //===----------------------------------------------------------------------===//
2014 void ASTStmtReader::VisitOMPExecutableDirective(OMPExecutableDirective *E) {
2015 E->setLocStart(ReadSourceLocation());
2016 E->setLocEnd(ReadSourceLocation());
2017 OMPClauseReader ClauseReader(Record);
2018 SmallVector<OMPClause *, 5> Clauses;
2019 for (unsigned i = 0; i < E->getNumClauses(); ++i)
2020 Clauses.push_back(ClauseReader.readClause());
2021 E->setClauses(Clauses);
2022 if (E->hasAssociatedStmt())
2023 E->setAssociatedStmt(Record.readSubStmt());
2026 void ASTStmtReader::VisitOMPLoopDirective(OMPLoopDirective *D) {
2028 // Two fields (NumClauses and CollapsedNum) were read in ReadStmtFromStream.
2030 VisitOMPExecutableDirective(D);
2031 D->setIterationVariable(Record.readSubExpr());
2032 D->setLastIteration(Record.readSubExpr());
2033 D->setCalcLastIteration(Record.readSubExpr());
2034 D->setPreCond(Record.readSubExpr());
2035 D->setCond(Record.readSubExpr());
2036 D->setInit(Record.readSubExpr());
2037 D->setInc(Record.readSubExpr());
2038 D->setPreInits(Record.readSubStmt());
2039 if (isOpenMPWorksharingDirective(D->getDirectiveKind()) ||
2040 isOpenMPTaskLoopDirective(D->getDirectiveKind()) ||
2041 isOpenMPDistributeDirective(D->getDirectiveKind())) {
2042 D->setIsLastIterVariable(Record.readSubExpr());
2043 D->setLowerBoundVariable(Record.readSubExpr());
2044 D->setUpperBoundVariable(Record.readSubExpr());
2045 D->setStrideVariable(Record.readSubExpr());
2046 D->setEnsureUpperBound(Record.readSubExpr());
2047 D->setNextLowerBound(Record.readSubExpr());
2048 D->setNextUpperBound(Record.readSubExpr());
2049 D->setNumIterations(Record.readSubExpr());
2051 if (isOpenMPLoopBoundSharingDirective(D->getDirectiveKind())) {
2052 D->setPrevLowerBoundVariable(Record.readSubExpr());
2053 D->setPrevUpperBoundVariable(Record.readSubExpr());
2054 D->setDistInc(Record.readSubExpr());
2055 D->setPrevEnsureUpperBound(Record.readSubExpr());
2056 D->setCombinedLowerBoundVariable(Record.readSubExpr());
2057 D->setCombinedUpperBoundVariable(Record.readSubExpr());
2058 D->setCombinedEnsureUpperBound(Record.readSubExpr());
2059 D->setCombinedInit(Record.readSubExpr());
2060 D->setCombinedCond(Record.readSubExpr());
2061 D->setCombinedNextLowerBound(Record.readSubExpr());
2062 D->setCombinedNextUpperBound(Record.readSubExpr());
2063 D->setCombinedDistCond(Record.readSubExpr());
2064 D->setCombinedParForInDistCond(Record.readSubExpr());
2066 SmallVector<Expr *, 4> Sub;
2067 unsigned CollapsedNum = D->getCollapsedNumber();
2068 Sub.reserve(CollapsedNum);
2069 for (unsigned i = 0; i < CollapsedNum; ++i)
2070 Sub.push_back(Record.readSubExpr());
2071 D->setCounters(Sub);
2073 for (unsigned i = 0; i < CollapsedNum; ++i)
2074 Sub.push_back(Record.readSubExpr());
2075 D->setPrivateCounters(Sub);
2077 for (unsigned i = 0; i < CollapsedNum; ++i)
2078 Sub.push_back(Record.readSubExpr());
2081 for (unsigned i = 0; i < CollapsedNum; ++i)
2082 Sub.push_back(Record.readSubExpr());
2085 for (unsigned i = 0; i < CollapsedNum; ++i)
2086 Sub.push_back(Record.readSubExpr());
2089 for (unsigned i = 0; i < CollapsedNum; ++i)
2090 Sub.push_back(Record.readSubExpr());
2091 D->setDependentCounters(Sub);
2093 for (unsigned i = 0; i < CollapsedNum; ++i)
2094 Sub.push_back(Record.readSubExpr());
2095 D->setDependentInits(Sub);
2097 for (unsigned i = 0; i < CollapsedNum; ++i)
2098 Sub.push_back(Record.readSubExpr());
2099 D->setFinalsConditions(Sub);
2102 void ASTStmtReader::VisitOMPParallelDirective(OMPParallelDirective *D) {
2104 // The NumClauses field was read in ReadStmtFromStream.
2106 VisitOMPExecutableDirective(D);
2107 D->setHasCancel(Record.readInt());
2110 void ASTStmtReader::VisitOMPSimdDirective(OMPSimdDirective *D) {
2111 VisitOMPLoopDirective(D);
2114 void ASTStmtReader::VisitOMPForDirective(OMPForDirective *D) {
2115 VisitOMPLoopDirective(D);
2116 D->setHasCancel(Record.readInt());
2119 void ASTStmtReader::VisitOMPForSimdDirective(OMPForSimdDirective *D) {
2120 VisitOMPLoopDirective(D);
2123 void ASTStmtReader::VisitOMPSectionsDirective(OMPSectionsDirective *D) {
2125 // The NumClauses field was read in ReadStmtFromStream.
2127 VisitOMPExecutableDirective(D);
2128 D->setHasCancel(Record.readInt());
2131 void ASTStmtReader::VisitOMPSectionDirective(OMPSectionDirective *D) {
2133 VisitOMPExecutableDirective(D);
2134 D->setHasCancel(Record.readInt());
2137 void ASTStmtReader::VisitOMPSingleDirective(OMPSingleDirective *D) {
2139 // The NumClauses field was read in ReadStmtFromStream.
2141 VisitOMPExecutableDirective(D);
2144 void ASTStmtReader::VisitOMPMasterDirective(OMPMasterDirective *D) {
2146 VisitOMPExecutableDirective(D);
2149 void ASTStmtReader::VisitOMPCriticalDirective(OMPCriticalDirective *D) {
2151 // The NumClauses field was read in ReadStmtFromStream.
2153 VisitOMPExecutableDirective(D);
2154 ReadDeclarationNameInfo(D->DirName);
2157 void ASTStmtReader::VisitOMPParallelForDirective(OMPParallelForDirective *D) {
2158 VisitOMPLoopDirective(D);
2159 D->setHasCancel(Record.readInt());
2162 void ASTStmtReader::VisitOMPParallelForSimdDirective(
2163 OMPParallelForSimdDirective *D) {
2164 VisitOMPLoopDirective(D);
2167 void ASTStmtReader::VisitOMPParallelSectionsDirective(
2168 OMPParallelSectionsDirective *D) {
2170 // The NumClauses field was read in ReadStmtFromStream.
2172 VisitOMPExecutableDirective(D);
2173 D->setHasCancel(Record.readInt());
2176 void ASTStmtReader::VisitOMPTaskDirective(OMPTaskDirective *D) {
2178 // The NumClauses field was read in ReadStmtFromStream.
2180 VisitOMPExecutableDirective(D);
2181 D->setHasCancel(Record.readInt());
2184 void ASTStmtReader::VisitOMPTaskyieldDirective(OMPTaskyieldDirective *D) {
2186 VisitOMPExecutableDirective(D);
2189 void ASTStmtReader::VisitOMPBarrierDirective(OMPBarrierDirective *D) {
2191 VisitOMPExecutableDirective(D);
2194 void ASTStmtReader::VisitOMPTaskwaitDirective(OMPTaskwaitDirective *D) {
2196 VisitOMPExecutableDirective(D);
2199 void ASTStmtReader::VisitOMPTaskgroupDirective(OMPTaskgroupDirective *D) {
2201 // The NumClauses field was read in ReadStmtFromStream.
2203 VisitOMPExecutableDirective(D);
2204 D->setReductionRef(Record.readSubExpr());
2207 void ASTStmtReader::VisitOMPFlushDirective(OMPFlushDirective *D) {
2209 // The NumClauses field was read in ReadStmtFromStream.
2211 VisitOMPExecutableDirective(D);
2214 void ASTStmtReader::VisitOMPOrderedDirective(OMPOrderedDirective *D) {
2216 // The NumClauses field was read in ReadStmtFromStream.
2218 VisitOMPExecutableDirective(D);
2221 void ASTStmtReader::VisitOMPAtomicDirective(OMPAtomicDirective *D) {
2223 // The NumClauses field was read in ReadStmtFromStream.
2225 VisitOMPExecutableDirective(D);
2226 D->setX(Record.readSubExpr());
2227 D->setV(Record.readSubExpr());
2228 D->setExpr(Record.readSubExpr());
2229 D->setUpdateExpr(Record.readSubExpr());
2230 D->IsXLHSInRHSPart = Record.readInt() != 0;
2231 D->IsPostfixUpdate = Record.readInt() != 0;
2234 void ASTStmtReader::VisitOMPTargetDirective(OMPTargetDirective *D) {
2236 // The NumClauses field was read in ReadStmtFromStream.
2238 VisitOMPExecutableDirective(D);
2241 void ASTStmtReader::VisitOMPTargetDataDirective(OMPTargetDataDirective *D) {
2244 VisitOMPExecutableDirective(D);
2247 void ASTStmtReader::VisitOMPTargetEnterDataDirective(
2248 OMPTargetEnterDataDirective *D) {
2251 VisitOMPExecutableDirective(D);
2254 void ASTStmtReader::VisitOMPTargetExitDataDirective(
2255 OMPTargetExitDataDirective *D) {
2258 VisitOMPExecutableDirective(D);
2261 void ASTStmtReader::VisitOMPTargetParallelDirective(
2262 OMPTargetParallelDirective *D) {
2265 VisitOMPExecutableDirective(D);
2268 void ASTStmtReader::VisitOMPTargetParallelForDirective(
2269 OMPTargetParallelForDirective *D) {
2270 VisitOMPLoopDirective(D);
2271 D->setHasCancel(Record.readInt());
2274 void ASTStmtReader::VisitOMPTeamsDirective(OMPTeamsDirective *D) {
2276 // The NumClauses field was read in ReadStmtFromStream.
2278 VisitOMPExecutableDirective(D);
2281 void ASTStmtReader::VisitOMPCancellationPointDirective(
2282 OMPCancellationPointDirective *D) {
2284 VisitOMPExecutableDirective(D);
2285 D->setCancelRegion(static_cast<OpenMPDirectiveKind>(Record.readInt()));
2288 void ASTStmtReader::VisitOMPCancelDirective(OMPCancelDirective *D) {
2290 // The NumClauses field was read in ReadStmtFromStream.
2292 VisitOMPExecutableDirective(D);
2293 D->setCancelRegion(static_cast<OpenMPDirectiveKind>(Record.readInt()));
2296 void ASTStmtReader::VisitOMPTaskLoopDirective(OMPTaskLoopDirective *D) {
2297 VisitOMPLoopDirective(D);
2300 void ASTStmtReader::VisitOMPTaskLoopSimdDirective(OMPTaskLoopSimdDirective *D) {
2301 VisitOMPLoopDirective(D);
2304 void ASTStmtReader::VisitOMPMasterTaskLoopDirective(
2305 OMPMasterTaskLoopDirective *D) {
2306 VisitOMPLoopDirective(D);
2309 void ASTStmtReader::VisitOMPMasterTaskLoopSimdDirective(
2310 OMPMasterTaskLoopSimdDirective *D) {
2311 VisitOMPLoopDirective(D);
2314 void ASTStmtReader::VisitOMPParallelMasterTaskLoopDirective(
2315 OMPParallelMasterTaskLoopDirective *D) {
2316 VisitOMPLoopDirective(D);
2319 void ASTStmtReader::VisitOMPDistributeDirective(OMPDistributeDirective *D) {
2320 VisitOMPLoopDirective(D);
2323 void ASTStmtReader::VisitOMPTargetUpdateDirective(OMPTargetUpdateDirective *D) {
2326 VisitOMPExecutableDirective(D);
2329 void ASTStmtReader::VisitOMPDistributeParallelForDirective(
2330 OMPDistributeParallelForDirective *D) {
2331 VisitOMPLoopDirective(D);
2332 D->setHasCancel(Record.readInt());
2335 void ASTStmtReader::VisitOMPDistributeParallelForSimdDirective(
2336 OMPDistributeParallelForSimdDirective *D) {
2337 VisitOMPLoopDirective(D);
2340 void ASTStmtReader::VisitOMPDistributeSimdDirective(
2341 OMPDistributeSimdDirective *D) {
2342 VisitOMPLoopDirective(D);
2345 void ASTStmtReader::VisitOMPTargetParallelForSimdDirective(
2346 OMPTargetParallelForSimdDirective *D) {
2347 VisitOMPLoopDirective(D);
2350 void ASTStmtReader::VisitOMPTargetSimdDirective(OMPTargetSimdDirective *D) {
2351 VisitOMPLoopDirective(D);
2354 void ASTStmtReader::VisitOMPTeamsDistributeDirective(
2355 OMPTeamsDistributeDirective *D) {
2356 VisitOMPLoopDirective(D);
2359 void ASTStmtReader::VisitOMPTeamsDistributeSimdDirective(
2360 OMPTeamsDistributeSimdDirective *D) {
2361 VisitOMPLoopDirective(D);
2364 void ASTStmtReader::VisitOMPTeamsDistributeParallelForSimdDirective(
2365 OMPTeamsDistributeParallelForSimdDirective *D) {
2366 VisitOMPLoopDirective(D);
2369 void ASTStmtReader::VisitOMPTeamsDistributeParallelForDirective(
2370 OMPTeamsDistributeParallelForDirective *D) {
2371 VisitOMPLoopDirective(D);
2372 D->setHasCancel(Record.readInt());
2375 void ASTStmtReader::VisitOMPTargetTeamsDirective(OMPTargetTeamsDirective *D) {
2377 // The NumClauses field was read in ReadStmtFromStream.
2379 VisitOMPExecutableDirective(D);
2382 void ASTStmtReader::VisitOMPTargetTeamsDistributeDirective(
2383 OMPTargetTeamsDistributeDirective *D) {
2384 VisitOMPLoopDirective(D);
2387 void ASTStmtReader::VisitOMPTargetTeamsDistributeParallelForDirective(
2388 OMPTargetTeamsDistributeParallelForDirective *D) {
2389 VisitOMPLoopDirective(D);
2390 D->setHasCancel(Record.readInt());
2393 void ASTStmtReader::VisitOMPTargetTeamsDistributeParallelForSimdDirective(
2394 OMPTargetTeamsDistributeParallelForSimdDirective *D) {
2395 VisitOMPLoopDirective(D);
2398 void ASTStmtReader::VisitOMPTargetTeamsDistributeSimdDirective(
2399 OMPTargetTeamsDistributeSimdDirective *D) {
2400 VisitOMPLoopDirective(D);
2403 //===----------------------------------------------------------------------===//
2404 // ASTReader Implementation
2405 //===----------------------------------------------------------------------===//
2407 Stmt *ASTReader::ReadStmt(ModuleFile &F) {
2408 switch (ReadingKind) {
2410 llvm_unreachable("should not call this when not reading anything");
2413 return ReadStmtFromStream(F);
2415 return ReadSubStmt();
2418 llvm_unreachable("ReadingKind not set ?");
2421 Expr *ASTReader::ReadExpr(ModuleFile &F) {
2422 return cast_or_null<Expr>(ReadStmt(F));
2425 Expr *ASTReader::ReadSubExpr() {
2426 return cast_or_null<Expr>(ReadSubStmt());
2429 // Within the bitstream, expressions are stored in Reverse Polish
2430 // Notation, with each of the subexpressions preceding the
2431 // expression they are stored in. Subexpressions are stored from last to first.
2432 // To evaluate expressions, we continue reading expressions and placing them on
2433 // the stack, with expressions having operands removing those operands from the
2434 // stack. Evaluation terminates when we see a STMT_STOP record, and
2435 // the single remaining expression on the stack is our result.
2436 Stmt *ASTReader::ReadStmtFromStream(ModuleFile &F) {
2437 ReadingKindTracker ReadingKind(Read_Stmt, *this);
2438 llvm::BitstreamCursor &Cursor = F.DeclsCursor;
2440 // Map of offset to previously deserialized stmt. The offset points
2441 // just after the stmt record.
2442 llvm::DenseMap<uint64_t, Stmt *> StmtEntries;
2445 unsigned PrevNumStmts = StmtStack.size();
2448 ASTRecordReader Record(*this, F);
2449 ASTStmtReader Reader(Record, Cursor);
2450 Stmt::EmptyShell Empty;
2453 llvm::Expected<llvm::BitstreamEntry> MaybeEntry =
2454 Cursor.advanceSkippingSubblocks();
2456 Error(toString(MaybeEntry.takeError()));
2459 llvm::BitstreamEntry Entry = MaybeEntry.get();
2461 switch (Entry.Kind) {
2462 case llvm::BitstreamEntry::SubBlock: // Handled for us already.
2463 case llvm::BitstreamEntry::Error:
2464 Error("malformed block record in AST file");
2466 case llvm::BitstreamEntry::EndBlock:
2468 case llvm::BitstreamEntry::Record:
2469 // The interesting case.
2473 ASTContext &Context = getContext();
2475 bool Finished = false;
2476 bool IsStmtReference = false;
2477 Expected<unsigned> MaybeStmtCode = Record.readRecord(Cursor, Entry.ID);
2478 if (!MaybeStmtCode) {
2479 Error(toString(MaybeStmtCode.takeError()));
2482 switch ((StmtCode)MaybeStmtCode.get()) {
2488 IsStmtReference = true;
2489 assert(StmtEntries.find(Record[0]) != StmtEntries.end() &&
2490 "No stmt was recorded for this offset reference!");
2491 S = StmtEntries[Record.readInt()];
2499 S = new (Context) NullStmt(Empty);
2503 S = CompoundStmt::CreateEmpty(
2504 Context, /*NumStmts=*/Record[ASTStmtReader::NumStmtFields]);
2508 S = CaseStmt::CreateEmpty(
2510 /*CaseStmtIsGNURange*/ Record[ASTStmtReader::NumStmtFields + 3]);
2514 S = new (Context) DefaultStmt(Empty);
2518 S = new (Context) LabelStmt(Empty);
2521 case STMT_ATTRIBUTED:
2522 S = AttributedStmt::CreateEmpty(
2524 /*NumAttrs*/Record[ASTStmtReader::NumStmtFields]);
2528 S = IfStmt::CreateEmpty(
2530 /* HasElse=*/Record[ASTStmtReader::NumStmtFields + 1],
2531 /* HasVar=*/Record[ASTStmtReader::NumStmtFields + 2],
2532 /* HasInit=*/Record[ASTStmtReader::NumStmtFields + 3]);
2536 S = SwitchStmt::CreateEmpty(
2538 /* HasInit=*/Record[ASTStmtReader::NumStmtFields],
2539 /* HasVar=*/Record[ASTStmtReader::NumStmtFields + 1]);
2543 S = WhileStmt::CreateEmpty(
2545 /* HasVar=*/Record[ASTStmtReader::NumStmtFields]);
2549 S = new (Context) DoStmt(Empty);
2553 S = new (Context) ForStmt(Empty);
2557 S = new (Context) GotoStmt(Empty);
2560 case STMT_INDIRECT_GOTO:
2561 S = new (Context) IndirectGotoStmt(Empty);
2565 S = new (Context) ContinueStmt(Empty);
2569 S = new (Context) BreakStmt(Empty);
2573 S = ReturnStmt::CreateEmpty(
2574 Context, /* HasNRVOCandidate=*/Record[ASTStmtReader::NumStmtFields]);
2578 S = new (Context) DeclStmt(Empty);
2582 S = new (Context) GCCAsmStmt(Empty);
2586 S = new (Context) MSAsmStmt(Empty);
2590 S = CapturedStmt::CreateDeserialized(
2591 Context, Record[ASTStmtReader::NumStmtFields]);
2595 S = ConstantExpr::CreateEmpty(
2597 static_cast<ConstantExpr::ResultStorageKind>(
2598 Record[ASTStmtReader::NumExprFields]),
2602 case EXPR_PREDEFINED:
2603 S = PredefinedExpr::CreateEmpty(
2605 /*HasFunctionName*/ Record[ASTStmtReader::NumExprFields]);
2609 S = DeclRefExpr::CreateEmpty(
2611 /*HasQualifier=*/Record[ASTStmtReader::NumExprFields],
2612 /*HasFoundDecl=*/Record[ASTStmtReader::NumExprFields + 1],
2613 /*HasTemplateKWAndArgsInfo=*/Record[ASTStmtReader::NumExprFields + 2],
2614 /*NumTemplateArgs=*/Record[ASTStmtReader::NumExprFields + 2] ?
2615 Record[ASTStmtReader::NumExprFields + 6] : 0);
2618 case EXPR_INTEGER_LITERAL:
2619 S = IntegerLiteral::Create(Context, Empty);
2622 case EXPR_FLOATING_LITERAL:
2623 S = FloatingLiteral::Create(Context, Empty);
2626 case EXPR_IMAGINARY_LITERAL:
2627 S = new (Context) ImaginaryLiteral(Empty);
2630 case EXPR_STRING_LITERAL:
2631 S = StringLiteral::CreateEmpty(
2633 /* NumConcatenated=*/Record[ASTStmtReader::NumExprFields],
2634 /* Length=*/Record[ASTStmtReader::NumExprFields + 1],
2635 /* CharByteWidth=*/Record[ASTStmtReader::NumExprFields + 2]);
2638 case EXPR_CHARACTER_LITERAL:
2639 S = new (Context) CharacterLiteral(Empty);
2643 S = new (Context) ParenExpr(Empty);
2646 case EXPR_PAREN_LIST:
2647 S = ParenListExpr::CreateEmpty(
2649 /* NumExprs=*/Record[ASTStmtReader::NumExprFields]);
2652 case EXPR_UNARY_OPERATOR:
2653 S = new (Context) UnaryOperator(Empty);
2657 S = OffsetOfExpr::CreateEmpty(Context,
2658 Record[ASTStmtReader::NumExprFields],
2659 Record[ASTStmtReader::NumExprFields + 1]);
2662 case EXPR_SIZEOF_ALIGN_OF:
2663 S = new (Context) UnaryExprOrTypeTraitExpr(Empty);
2666 case EXPR_ARRAY_SUBSCRIPT:
2667 S = new (Context) ArraySubscriptExpr(Empty);
2670 case EXPR_OMP_ARRAY_SECTION:
2671 S = new (Context) OMPArraySectionExpr(Empty);
2675 S = CallExpr::CreateEmpty(
2676 Context, /*NumArgs=*/Record[ASTStmtReader::NumExprFields], Empty);
2680 S = MemberExpr::CreateEmpty(Context, Record[ASTStmtReader::NumExprFields],
2681 Record[ASTStmtReader::NumExprFields + 1],
2682 Record[ASTStmtReader::NumExprFields + 2],
2683 Record[ASTStmtReader::NumExprFields + 3]);
2686 case EXPR_BINARY_OPERATOR:
2687 S = new (Context) BinaryOperator(Empty);
2690 case EXPR_COMPOUND_ASSIGN_OPERATOR:
2691 S = new (Context) CompoundAssignOperator(Empty);
2694 case EXPR_CONDITIONAL_OPERATOR:
2695 S = new (Context) ConditionalOperator(Empty);
2698 case EXPR_BINARY_CONDITIONAL_OPERATOR:
2699 S = new (Context) BinaryConditionalOperator(Empty);
2702 case EXPR_IMPLICIT_CAST:
2703 S = ImplicitCastExpr::CreateEmpty(Context,
2704 /*PathSize*/ Record[ASTStmtReader::NumExprFields]);
2707 case EXPR_CSTYLE_CAST:
2708 S = CStyleCastExpr::CreateEmpty(Context,
2709 /*PathSize*/ Record[ASTStmtReader::NumExprFields]);
2712 case EXPR_COMPOUND_LITERAL:
2713 S = new (Context) CompoundLiteralExpr(Empty);
2716 case EXPR_EXT_VECTOR_ELEMENT:
2717 S = new (Context) ExtVectorElementExpr(Empty);
2720 case EXPR_INIT_LIST:
2721 S = new (Context) InitListExpr(Empty);
2724 case EXPR_DESIGNATED_INIT:
2725 S = DesignatedInitExpr::CreateEmpty(Context,
2726 Record[ASTStmtReader::NumExprFields] - 1);
2730 case EXPR_DESIGNATED_INIT_UPDATE:
2731 S = new (Context) DesignatedInitUpdateExpr(Empty);
2734 case EXPR_IMPLICIT_VALUE_INIT:
2735 S = new (Context) ImplicitValueInitExpr(Empty);
2739 S = new (Context) NoInitExpr(Empty);
2742 case EXPR_ARRAY_INIT_LOOP:
2743 S = new (Context) ArrayInitLoopExpr(Empty);
2746 case EXPR_ARRAY_INIT_INDEX:
2747 S = new (Context) ArrayInitIndexExpr(Empty);
2751 S = new (Context) VAArgExpr(Empty);
2754 case EXPR_SOURCE_LOC:
2755 S = new (Context) SourceLocExpr(Empty);
2758 case EXPR_ADDR_LABEL:
2759 S = new (Context) AddrLabelExpr(Empty);
2763 S = new (Context) StmtExpr(Empty);
2767 S = new (Context) ChooseExpr(Empty);
2771 S = new (Context) GNUNullExpr(Empty);
2774 case EXPR_SHUFFLE_VECTOR:
2775 S = new (Context) ShuffleVectorExpr(Empty);
2778 case EXPR_CONVERT_VECTOR:
2779 S = new (Context) ConvertVectorExpr(Empty);
2783 S = new (Context) BlockExpr(Empty);
2786 case EXPR_GENERIC_SELECTION:
2787 S = GenericSelectionExpr::CreateEmpty(
2789 /*NumAssocs=*/Record[ASTStmtReader::NumExprFields]);
2792 case EXPR_OBJC_STRING_LITERAL:
2793 S = new (Context) ObjCStringLiteral(Empty);
2796 case EXPR_OBJC_BOXED_EXPRESSION:
2797 S = new (Context) ObjCBoxedExpr(Empty);
2800 case EXPR_OBJC_ARRAY_LITERAL:
2801 S = ObjCArrayLiteral::CreateEmpty(Context,
2802 Record[ASTStmtReader::NumExprFields]);
2805 case EXPR_OBJC_DICTIONARY_LITERAL:
2806 S = ObjCDictionaryLiteral::CreateEmpty(Context,
2807 Record[ASTStmtReader::NumExprFields],
2808 Record[ASTStmtReader::NumExprFields + 1]);
2811 case EXPR_OBJC_ENCODE:
2812 S = new (Context) ObjCEncodeExpr(Empty);
2815 case EXPR_OBJC_SELECTOR_EXPR:
2816 S = new (Context) ObjCSelectorExpr(Empty);
2819 case EXPR_OBJC_PROTOCOL_EXPR:
2820 S = new (Context) ObjCProtocolExpr(Empty);
2823 case EXPR_OBJC_IVAR_REF_EXPR:
2824 S = new (Context) ObjCIvarRefExpr(Empty);
2827 case EXPR_OBJC_PROPERTY_REF_EXPR:
2828 S = new (Context) ObjCPropertyRefExpr(Empty);
2831 case EXPR_OBJC_SUBSCRIPT_REF_EXPR:
2832 S = new (Context) ObjCSubscriptRefExpr(Empty);
2835 case EXPR_OBJC_KVC_REF_EXPR:
2836 llvm_unreachable("mismatching AST file");
2838 case EXPR_OBJC_MESSAGE_EXPR:
2839 S = ObjCMessageExpr::CreateEmpty(Context,
2840 Record[ASTStmtReader::NumExprFields],
2841 Record[ASTStmtReader::NumExprFields + 1]);
2845 S = new (Context) ObjCIsaExpr(Empty);
2848 case EXPR_OBJC_INDIRECT_COPY_RESTORE:
2849 S = new (Context) ObjCIndirectCopyRestoreExpr(Empty);
2852 case EXPR_OBJC_BRIDGED_CAST:
2853 S = new (Context) ObjCBridgedCastExpr(Empty);
2856 case STMT_OBJC_FOR_COLLECTION:
2857 S = new (Context) ObjCForCollectionStmt(Empty);
2860 case STMT_OBJC_CATCH:
2861 S = new (Context) ObjCAtCatchStmt(Empty);
2864 case STMT_OBJC_FINALLY:
2865 S = new (Context) ObjCAtFinallyStmt(Empty);
2868 case STMT_OBJC_AT_TRY:
2869 S = ObjCAtTryStmt::CreateEmpty(Context,
2870 Record[ASTStmtReader::NumStmtFields],
2871 Record[ASTStmtReader::NumStmtFields + 1]);
2874 case STMT_OBJC_AT_SYNCHRONIZED:
2875 S = new (Context) ObjCAtSynchronizedStmt(Empty);
2878 case STMT_OBJC_AT_THROW:
2879 S = new (Context) ObjCAtThrowStmt(Empty);
2882 case STMT_OBJC_AUTORELEASE_POOL:
2883 S = new (Context) ObjCAutoreleasePoolStmt(Empty);
2886 case EXPR_OBJC_BOOL_LITERAL:
2887 S = new (Context) ObjCBoolLiteralExpr(Empty);
2890 case EXPR_OBJC_AVAILABILITY_CHECK:
2891 S = new (Context) ObjCAvailabilityCheckExpr(Empty);
2894 case STMT_SEH_LEAVE:
2895 S = new (Context) SEHLeaveStmt(Empty);
2898 case STMT_SEH_EXCEPT:
2899 S = new (Context) SEHExceptStmt(Empty);
2902 case STMT_SEH_FINALLY:
2903 S = new (Context) SEHFinallyStmt(Empty);
2907 S = new (Context) SEHTryStmt(Empty);
2910 case STMT_CXX_CATCH:
2911 S = new (Context) CXXCatchStmt(Empty);
2915 S = CXXTryStmt::Create(Context, Empty,
2916 /*numHandlers=*/Record[ASTStmtReader::NumStmtFields]);
2919 case STMT_CXX_FOR_RANGE:
2920 S = new (Context) CXXForRangeStmt(Empty);
2923 case STMT_MS_DEPENDENT_EXISTS:
2924 S = new (Context) MSDependentExistsStmt(SourceLocation(), true,
2925 NestedNameSpecifierLoc(),
2926 DeclarationNameInfo(),
2930 case STMT_OMP_PARALLEL_DIRECTIVE:
2932 OMPParallelDirective::CreateEmpty(Context,
2933 Record[ASTStmtReader::NumStmtFields],
2937 case STMT_OMP_SIMD_DIRECTIVE: {
2938 unsigned NumClauses = Record[ASTStmtReader::NumStmtFields];
2939 unsigned CollapsedNum = Record[ASTStmtReader::NumStmtFields + 1];
2940 S = OMPSimdDirective::CreateEmpty(Context, NumClauses,
2941 CollapsedNum, Empty);
2945 case STMT_OMP_FOR_DIRECTIVE: {
2946 unsigned NumClauses = Record[ASTStmtReader::NumStmtFields];
2947 unsigned CollapsedNum = Record[ASTStmtReader::NumStmtFields + 1];
2948 S = OMPForDirective::CreateEmpty(Context, NumClauses, CollapsedNum,
2953 case STMT_OMP_FOR_SIMD_DIRECTIVE: {
2954 unsigned NumClauses = Record[ASTStmtReader::NumStmtFields];
2955 unsigned CollapsedNum = Record[ASTStmtReader::NumStmtFields + 1];
2956 S = OMPForSimdDirective::CreateEmpty(Context, NumClauses, CollapsedNum,
2961 case STMT_OMP_SECTIONS_DIRECTIVE:
2962 S = OMPSectionsDirective::CreateEmpty(
2963 Context, Record[ASTStmtReader::NumStmtFields], Empty);
2966 case STMT_OMP_SECTION_DIRECTIVE:
2967 S = OMPSectionDirective::CreateEmpty(Context, Empty);
2970 case STMT_OMP_SINGLE_DIRECTIVE:
2971 S = OMPSingleDirective::CreateEmpty(
2972 Context, Record[ASTStmtReader::NumStmtFields], Empty);
2975 case STMT_OMP_MASTER_DIRECTIVE:
2976 S = OMPMasterDirective::CreateEmpty(Context, Empty);
2979 case STMT_OMP_CRITICAL_DIRECTIVE:
2980 S = OMPCriticalDirective::CreateEmpty(
2981 Context, Record[ASTStmtReader::NumStmtFields], Empty);
2984 case STMT_OMP_PARALLEL_FOR_DIRECTIVE: {
2985 unsigned NumClauses = Record[ASTStmtReader::NumStmtFields];
2986 unsigned CollapsedNum = Record[ASTStmtReader::NumStmtFields + 1];
2987 S = OMPParallelForDirective::CreateEmpty(Context, NumClauses,
2988 CollapsedNum, Empty);
2992 case STMT_OMP_PARALLEL_FOR_SIMD_DIRECTIVE: {
2993 unsigned NumClauses = Record[ASTStmtReader::NumStmtFields];
2994 unsigned CollapsedNum = Record[ASTStmtReader::NumStmtFields + 1];
2995 S = OMPParallelForSimdDirective::CreateEmpty(Context, NumClauses,
2996 CollapsedNum, Empty);
3000 case STMT_OMP_PARALLEL_SECTIONS_DIRECTIVE:
3001 S = OMPParallelSectionsDirective::CreateEmpty(
3002 Context, Record[ASTStmtReader::NumStmtFields], Empty);
3005 case STMT_OMP_TASK_DIRECTIVE:
3006 S = OMPTaskDirective::CreateEmpty(
3007 Context, Record[ASTStmtReader::NumStmtFields], Empty);
3010 case STMT_OMP_TASKYIELD_DIRECTIVE:
3011 S = OMPTaskyieldDirective::CreateEmpty(Context, Empty);
3014 case STMT_OMP_BARRIER_DIRECTIVE:
3015 S = OMPBarrierDirective::CreateEmpty(Context, Empty);
3018 case STMT_OMP_TASKWAIT_DIRECTIVE:
3019 S = OMPTaskwaitDirective::CreateEmpty(Context, Empty);
3022 case STMT_OMP_TASKGROUP_DIRECTIVE:
3023 S = OMPTaskgroupDirective::CreateEmpty(
3024 Context, Record[ASTStmtReader::NumStmtFields], Empty);
3027 case STMT_OMP_FLUSH_DIRECTIVE:
3028 S = OMPFlushDirective::CreateEmpty(
3029 Context, Record[ASTStmtReader::NumStmtFields], Empty);
3032 case STMT_OMP_ORDERED_DIRECTIVE:
3033 S = OMPOrderedDirective::CreateEmpty(
3034 Context, Record[ASTStmtReader::NumStmtFields], Empty);
3037 case STMT_OMP_ATOMIC_DIRECTIVE:
3038 S = OMPAtomicDirective::CreateEmpty(
3039 Context, Record[ASTStmtReader::NumStmtFields], Empty);
3042 case STMT_OMP_TARGET_DIRECTIVE:
3043 S = OMPTargetDirective::CreateEmpty(
3044 Context, Record[ASTStmtReader::NumStmtFields], Empty);
3047 case STMT_OMP_TARGET_DATA_DIRECTIVE:
3048 S = OMPTargetDataDirective::CreateEmpty(
3049 Context, Record[ASTStmtReader::NumStmtFields], Empty);
3052 case STMT_OMP_TARGET_ENTER_DATA_DIRECTIVE:
3053 S = OMPTargetEnterDataDirective::CreateEmpty(
3054 Context, Record[ASTStmtReader::NumStmtFields], Empty);
3057 case STMT_OMP_TARGET_EXIT_DATA_DIRECTIVE:
3058 S = OMPTargetExitDataDirective::CreateEmpty(
3059 Context, Record[ASTStmtReader::NumStmtFields], Empty);
3062 case STMT_OMP_TARGET_PARALLEL_DIRECTIVE:
3063 S = OMPTargetParallelDirective::CreateEmpty(
3064 Context, Record[ASTStmtReader::NumStmtFields], Empty);
3067 case STMT_OMP_TARGET_PARALLEL_FOR_DIRECTIVE: {
3068 unsigned NumClauses = Record[ASTStmtReader::NumStmtFields];
3069 unsigned CollapsedNum = Record[ASTStmtReader::NumStmtFields + 1];
3070 S = OMPTargetParallelForDirective::CreateEmpty(Context, NumClauses,
3071 CollapsedNum, Empty);
3075 case STMT_OMP_TARGET_UPDATE_DIRECTIVE:
3076 S = OMPTargetUpdateDirective::CreateEmpty(
3077 Context, Record[ASTStmtReader::NumStmtFields], Empty);
3080 case STMT_OMP_TEAMS_DIRECTIVE:
3081 S = OMPTeamsDirective::CreateEmpty(
3082 Context, Record[ASTStmtReader::NumStmtFields], Empty);
3085 case STMT_OMP_CANCELLATION_POINT_DIRECTIVE:
3086 S = OMPCancellationPointDirective::CreateEmpty(Context, Empty);
3089 case STMT_OMP_CANCEL_DIRECTIVE:
3090 S = OMPCancelDirective::CreateEmpty(
3091 Context, Record[ASTStmtReader::NumStmtFields], Empty);
3094 case STMT_OMP_TASKLOOP_DIRECTIVE: {
3095 unsigned NumClauses = Record[ASTStmtReader::NumStmtFields];
3096 unsigned CollapsedNum = Record[ASTStmtReader::NumStmtFields + 1];
3097 S = OMPTaskLoopDirective::CreateEmpty(Context, NumClauses, CollapsedNum,
3102 case STMT_OMP_TASKLOOP_SIMD_DIRECTIVE: {
3103 unsigned NumClauses = Record[ASTStmtReader::NumStmtFields];
3104 unsigned CollapsedNum = Record[ASTStmtReader::NumStmtFields + 1];
3105 S = OMPTaskLoopSimdDirective::CreateEmpty(Context, NumClauses,
3106 CollapsedNum, Empty);
3110 case STMT_OMP_MASTER_TASKLOOP_DIRECTIVE: {
3111 unsigned NumClauses = Record[ASTStmtReader::NumStmtFields];
3112 unsigned CollapsedNum = Record[ASTStmtReader::NumStmtFields + 1];
3113 S = OMPMasterTaskLoopDirective::CreateEmpty(Context, NumClauses,
3114 CollapsedNum, Empty);
3118 case STMT_OMP_MASTER_TASKLOOP_SIMD_DIRECTIVE: {
3119 unsigned NumClauses = Record[ASTStmtReader::NumStmtFields];
3120 unsigned CollapsedNum = Record[ASTStmtReader::NumStmtFields + 1];
3121 S = OMPMasterTaskLoopSimdDirective::CreateEmpty(Context, NumClauses,
3122 CollapsedNum, Empty);
3126 case STMT_OMP_PARALLEL_MASTER_TASKLOOP_DIRECTIVE: {
3127 unsigned NumClauses = Record[ASTStmtReader::NumStmtFields];
3128 unsigned CollapsedNum = Record[ASTStmtReader::NumStmtFields + 1];
3129 S = OMPParallelMasterTaskLoopDirective::CreateEmpty(Context, NumClauses,
3130 CollapsedNum, Empty);
3134 case STMT_OMP_DISTRIBUTE_DIRECTIVE: {
3135 unsigned NumClauses = Record[ASTStmtReader::NumStmtFields];
3136 unsigned CollapsedNum = Record[ASTStmtReader::NumStmtFields + 1];
3137 S = OMPDistributeDirective::CreateEmpty(Context, NumClauses, CollapsedNum,
3142 case STMT_OMP_DISTRIBUTE_PARALLEL_FOR_DIRECTIVE: {
3143 unsigned NumClauses = Record[ASTStmtReader::NumStmtFields];
3144 unsigned CollapsedNum = Record[ASTStmtReader::NumStmtFields + 1];
3145 S = OMPDistributeParallelForDirective::CreateEmpty(Context, NumClauses,
3146 CollapsedNum, Empty);
3150 case STMT_OMP_DISTRIBUTE_PARALLEL_FOR_SIMD_DIRECTIVE: {
3151 unsigned NumClauses = Record[ASTStmtReader::NumStmtFields];
3152 unsigned CollapsedNum = Record[ASTStmtReader::NumStmtFields + 1];
3153 S = OMPDistributeParallelForSimdDirective::CreateEmpty(Context, NumClauses,
3159 case STMT_OMP_DISTRIBUTE_SIMD_DIRECTIVE: {
3160 unsigned NumClauses = Record[ASTStmtReader::NumStmtFields];
3161 unsigned CollapsedNum = Record[ASTStmtReader::NumStmtFields + 1];
3162 S = OMPDistributeSimdDirective::CreateEmpty(Context, NumClauses,
3163 CollapsedNum, Empty);
3167 case STMT_OMP_TARGET_PARALLEL_FOR_SIMD_DIRECTIVE: {
3168 unsigned NumClauses = Record[ASTStmtReader::NumStmtFields];
3169 unsigned CollapsedNum = Record[ASTStmtReader::NumStmtFields + 1];
3170 S = OMPTargetParallelForSimdDirective::CreateEmpty(Context, NumClauses,
3171 CollapsedNum, Empty);
3175 case STMT_OMP_TARGET_SIMD_DIRECTIVE: {
3176 auto NumClauses = Record[ASTStmtReader::NumStmtFields];
3177 auto CollapsedNum = Record[ASTStmtReader::NumStmtFields + 1];
3178 S = OMPTargetSimdDirective::CreateEmpty(Context, NumClauses, CollapsedNum,
3183 case STMT_OMP_TEAMS_DISTRIBUTE_DIRECTIVE: {
3184 auto NumClauses = Record[ASTStmtReader::NumStmtFields];
3185 auto CollapsedNum = Record[ASTStmtReader::NumStmtFields + 1];
3186 S = OMPTeamsDistributeDirective::CreateEmpty(Context, NumClauses,
3187 CollapsedNum, Empty);
3191 case STMT_OMP_TEAMS_DISTRIBUTE_SIMD_DIRECTIVE: {
3192 unsigned NumClauses = Record[ASTStmtReader::NumStmtFields];
3193 unsigned CollapsedNum = Record[ASTStmtReader::NumStmtFields + 1];
3194 S = OMPTeamsDistributeSimdDirective::CreateEmpty(Context, NumClauses,
3195 CollapsedNum, Empty);
3199 case STMT_OMP_TEAMS_DISTRIBUTE_PARALLEL_FOR_SIMD_DIRECTIVE: {
3200 auto NumClauses = Record[ASTStmtReader::NumStmtFields];
3201 auto CollapsedNum = Record[ASTStmtReader::NumStmtFields + 1];
3202 S = OMPTeamsDistributeParallelForSimdDirective::CreateEmpty(
3203 Context, NumClauses, CollapsedNum, Empty);
3207 case STMT_OMP_TEAMS_DISTRIBUTE_PARALLEL_FOR_DIRECTIVE: {
3208 auto NumClauses = Record[ASTStmtReader::NumStmtFields];
3209 auto CollapsedNum = Record[ASTStmtReader::NumStmtFields + 1];
3210 S = OMPTeamsDistributeParallelForDirective::CreateEmpty(
3211 Context, NumClauses, CollapsedNum, Empty);
3215 case STMT_OMP_TARGET_TEAMS_DIRECTIVE:
3216 S = OMPTargetTeamsDirective::CreateEmpty(
3217 Context, Record[ASTStmtReader::NumStmtFields], Empty);
3220 case STMT_OMP_TARGET_TEAMS_DISTRIBUTE_DIRECTIVE: {
3221 auto NumClauses = Record[ASTStmtReader::NumStmtFields];
3222 auto CollapsedNum = Record[ASTStmtReader::NumStmtFields + 1];
3223 S = OMPTargetTeamsDistributeDirective::CreateEmpty(Context, NumClauses,
3224 CollapsedNum, Empty);
3228 case STMT_OMP_TARGET_TEAMS_DISTRIBUTE_PARALLEL_FOR_DIRECTIVE: {
3229 auto NumClauses = Record[ASTStmtReader::NumStmtFields];
3230 auto CollapsedNum = Record[ASTStmtReader::NumStmtFields + 1];
3231 S = OMPTargetTeamsDistributeParallelForDirective::CreateEmpty(
3232 Context, NumClauses, CollapsedNum, Empty);
3236 case STMT_OMP_TARGET_TEAMS_DISTRIBUTE_PARALLEL_FOR_SIMD_DIRECTIVE: {
3237 auto NumClauses = Record[ASTStmtReader::NumStmtFields];
3238 auto CollapsedNum = Record[ASTStmtReader::NumStmtFields + 1];
3239 S = OMPTargetTeamsDistributeParallelForSimdDirective::CreateEmpty(
3240 Context, NumClauses, CollapsedNum, Empty);
3244 case STMT_OMP_TARGET_TEAMS_DISTRIBUTE_SIMD_DIRECTIVE: {
3245 auto NumClauses = Record[ASTStmtReader::NumStmtFields];
3246 auto CollapsedNum = Record[ASTStmtReader::NumStmtFields + 1];
3247 S = OMPTargetTeamsDistributeSimdDirective::CreateEmpty(
3248 Context, NumClauses, CollapsedNum, Empty);
3252 case EXPR_CXX_OPERATOR_CALL:
3253 S = CXXOperatorCallExpr::CreateEmpty(
3254 Context, /*NumArgs=*/Record[ASTStmtReader::NumExprFields], Empty);
3257 case EXPR_CXX_MEMBER_CALL:
3258 S = CXXMemberCallExpr::CreateEmpty(
3259 Context, /*NumArgs=*/Record[ASTStmtReader::NumExprFields], Empty);
3262 case EXPR_CXX_REWRITTEN_BINARY_OPERATOR:
3263 S = new (Context) CXXRewrittenBinaryOperator(Empty);
3266 case EXPR_CXX_CONSTRUCT:
3267 S = CXXConstructExpr::CreateEmpty(
3269 /* NumArgs=*/Record[ASTStmtReader::NumExprFields]);
3272 case EXPR_CXX_INHERITED_CTOR_INIT:
3273 S = new (Context) CXXInheritedCtorInitExpr(Empty);
3276 case EXPR_CXX_TEMPORARY_OBJECT:
3277 S = CXXTemporaryObjectExpr::CreateEmpty(
3279 /* NumArgs=*/Record[ASTStmtReader::NumExprFields]);
3282 case EXPR_CXX_STATIC_CAST:
3283 S = CXXStaticCastExpr::CreateEmpty(Context,
3284 /*PathSize*/ Record[ASTStmtReader::NumExprFields]);
3287 case EXPR_CXX_DYNAMIC_CAST:
3288 S = CXXDynamicCastExpr::CreateEmpty(Context,
3289 /*PathSize*/ Record[ASTStmtReader::NumExprFields]);
3292 case EXPR_CXX_REINTERPRET_CAST:
3293 S = CXXReinterpretCastExpr::CreateEmpty(Context,
3294 /*PathSize*/ Record[ASTStmtReader::NumExprFields]);
3297 case EXPR_CXX_CONST_CAST:
3298 S = CXXConstCastExpr::CreateEmpty(Context);
3301 case EXPR_CXX_FUNCTIONAL_CAST:
3302 S = CXXFunctionalCastExpr::CreateEmpty(Context,
3303 /*PathSize*/ Record[ASTStmtReader::NumExprFields]);
3306 case EXPR_USER_DEFINED_LITERAL:
3307 S = UserDefinedLiteral::CreateEmpty(
3308 Context, /*NumArgs=*/Record[ASTStmtReader::NumExprFields], Empty);
3311 case EXPR_CXX_STD_INITIALIZER_LIST:
3312 S = new (Context) CXXStdInitializerListExpr(Empty);
3315 case EXPR_CXX_BOOL_LITERAL:
3316 S = new (Context) CXXBoolLiteralExpr(Empty);
3319 case EXPR_CXX_NULL_PTR_LITERAL:
3320 S = new (Context) CXXNullPtrLiteralExpr(Empty);
3323 case EXPR_CXX_TYPEID_EXPR:
3324 S = new (Context) CXXTypeidExpr(Empty, true);
3327 case EXPR_CXX_TYPEID_TYPE:
3328 S = new (Context) CXXTypeidExpr(Empty, false);
3331 case EXPR_CXX_UUIDOF_EXPR:
3332 S = new (Context) CXXUuidofExpr(Empty, true);
3335 case EXPR_CXX_PROPERTY_REF_EXPR:
3336 S = new (Context) MSPropertyRefExpr(Empty);
3339 case EXPR_CXX_PROPERTY_SUBSCRIPT_EXPR:
3340 S = new (Context) MSPropertySubscriptExpr(Empty);
3343 case EXPR_CXX_UUIDOF_TYPE:
3344 S = new (Context) CXXUuidofExpr(Empty, false);
3348 S = new (Context) CXXThisExpr(Empty);
3351 case EXPR_CXX_THROW:
3352 S = new (Context) CXXThrowExpr(Empty);
3355 case EXPR_CXX_DEFAULT_ARG:
3356 S = new (Context) CXXDefaultArgExpr(Empty);
3359 case EXPR_CXX_DEFAULT_INIT:
3360 S = new (Context) CXXDefaultInitExpr(Empty);
3363 case EXPR_CXX_BIND_TEMPORARY:
3364 S = new (Context) CXXBindTemporaryExpr(Empty);
3367 case EXPR_CXX_SCALAR_VALUE_INIT:
3368 S = new (Context) CXXScalarValueInitExpr(Empty);
3372 S = CXXNewExpr::CreateEmpty(
3374 /*IsArray=*/Record[ASTStmtReader::NumExprFields],
3375 /*HasInit=*/Record[ASTStmtReader::NumExprFields + 1],
3376 /*NumPlacementArgs=*/Record[ASTStmtReader::NumExprFields + 2],
3377 /*IsParenTypeId=*/Record[ASTStmtReader::NumExprFields + 3]);
3380 case EXPR_CXX_DELETE:
3381 S = new (Context) CXXDeleteExpr(Empty);
3384 case EXPR_CXX_PSEUDO_DESTRUCTOR:
3385 S = new (Context) CXXPseudoDestructorExpr(Empty);
3388 case EXPR_EXPR_WITH_CLEANUPS:
3389 S = ExprWithCleanups::Create(Context, Empty,
3390 Record[ASTStmtReader::NumExprFields]);
3393 case EXPR_CXX_DEPENDENT_SCOPE_MEMBER:
3394 S = CXXDependentScopeMemberExpr::CreateEmpty(
3396 /*HasTemplateKWAndArgsInfo=*/Record[ASTStmtReader::NumExprFields],
3397 /*NumTemplateArgs=*/Record[ASTStmtReader::NumExprFields + 1],
3398 /*HasFirstQualifierFoundInScope=*/
3399 Record[ASTStmtReader::NumExprFields + 2]);
3402 case EXPR_CXX_DEPENDENT_SCOPE_DECL_REF:
3403 S = DependentScopeDeclRefExpr::CreateEmpty(Context,
3404 /*HasTemplateKWAndArgsInfo=*/Record[ASTStmtReader::NumExprFields],
3405 /*NumTemplateArgs=*/Record[ASTStmtReader::NumExprFields]
3406 ? Record[ASTStmtReader::NumExprFields + 1]
3410 case EXPR_CXX_UNRESOLVED_CONSTRUCT:
3411 S = CXXUnresolvedConstructExpr::CreateEmpty(Context,
3412 /*NumArgs=*/Record[ASTStmtReader::NumExprFields]);
3415 case EXPR_CXX_UNRESOLVED_MEMBER:
3416 S = UnresolvedMemberExpr::CreateEmpty(
3418 /*NumResults=*/Record[ASTStmtReader::NumExprFields],
3419 /*HasTemplateKWAndArgsInfo=*/Record[ASTStmtReader::NumExprFields + 1],
3420 /*NumTemplateArgs=*/
3421 Record[ASTStmtReader::NumExprFields + 1]
3422 ? Record[ASTStmtReader::NumExprFields + 2]
3426 case EXPR_CXX_UNRESOLVED_LOOKUP:
3427 S = UnresolvedLookupExpr::CreateEmpty(
3429 /*NumResults=*/Record[ASTStmtReader::NumExprFields],
3430 /*HasTemplateKWAndArgsInfo=*/Record[ASTStmtReader::NumExprFields + 1],
3431 /*NumTemplateArgs=*/
3432 Record[ASTStmtReader::NumExprFields + 1]
3433 ? Record[ASTStmtReader::NumExprFields + 2]
3437 case EXPR_TYPE_TRAIT:
3438 S = TypeTraitExpr::CreateDeserialized(Context,
3439 Record[ASTStmtReader::NumExprFields]);
3442 case EXPR_ARRAY_TYPE_TRAIT:
3443 S = new (Context) ArrayTypeTraitExpr(Empty);
3446 case EXPR_CXX_EXPRESSION_TRAIT:
3447 S = new (Context) ExpressionTraitExpr(Empty);
3450 case EXPR_CXX_NOEXCEPT:
3451 S = new (Context) CXXNoexceptExpr(Empty);
3454 case EXPR_PACK_EXPANSION:
3455 S = new (Context) PackExpansionExpr(Empty);
3458 case EXPR_SIZEOF_PACK:
3459 S = SizeOfPackExpr::CreateDeserialized(
3461 /*NumPartialArgs=*/Record[ASTStmtReader::NumExprFields]);
3464 case EXPR_SUBST_NON_TYPE_TEMPLATE_PARM:
3465 S = new (Context) SubstNonTypeTemplateParmExpr(Empty);
3468 case EXPR_SUBST_NON_TYPE_TEMPLATE_PARM_PACK:
3469 S = new (Context) SubstNonTypeTemplateParmPackExpr(Empty);
3472 case EXPR_FUNCTION_PARM_PACK:
3473 S = FunctionParmPackExpr::CreateEmpty(Context,
3474 Record[ASTStmtReader::NumExprFields]);
3477 case EXPR_MATERIALIZE_TEMPORARY:
3478 S = new (Context) MaterializeTemporaryExpr(Empty);
3482 S = new (Context) CXXFoldExpr(Empty);
3485 case EXPR_OPAQUE_VALUE:
3486 S = new (Context) OpaqueValueExpr(Empty);
3489 case EXPR_CUDA_KERNEL_CALL:
3490 S = CUDAKernelCallExpr::CreateEmpty(
3491 Context, /*NumArgs=*/Record[ASTStmtReader::NumExprFields], Empty);
3495 S = new (Context) AsTypeExpr(Empty);
3498 case EXPR_PSEUDO_OBJECT: {
3499 unsigned numSemanticExprs = Record[ASTStmtReader::NumExprFields];
3500 S = PseudoObjectExpr::Create(Context, Empty, numSemanticExprs);
3505 S = new (Context) AtomicExpr(Empty);
3509 unsigned NumCaptures = Record[ASTStmtReader::NumExprFields];
3510 S = LambdaExpr::CreateDeserialized(Context, NumCaptures);
3514 case STMT_COROUTINE_BODY: {
3515 unsigned NumParams = Record[ASTStmtReader::NumStmtFields];
3516 S = CoroutineBodyStmt::Create(Context, Empty, NumParams);
3521 S = new (Context) CoreturnStmt(Empty);
3525 S = new (Context) CoawaitExpr(Empty);
3529 S = new (Context) CoyieldExpr(Empty);
3532 case EXPR_DEPENDENT_COAWAIT:
3533 S = new (Context) DependentCoawaitExpr(Empty);
3536 case EXPR_CONCEPT_SPECIALIZATION:
3537 unsigned numTemplateArgs = Record[ASTStmtReader::NumExprFields];
3538 S = ConceptSpecializationExpr::Create(Context, Empty, numTemplateArgs);
3543 // We hit a STMT_STOP, so we're done with this expression.
3547 ++NumStatementsRead;
3549 if (S && !IsStmtReference) {
3551 StmtEntries[Cursor.GetCurrentBitNo()] = S;
3554 assert(Record.getIdx() == Record.size() &&
3555 "Invalid deserialization of statement");
3556 StmtStack.push_back(S);
3559 assert(StmtStack.size() > PrevNumStmts && "Read too many sub-stmts!");
3560 assert(StmtStack.size() == PrevNumStmts + 1 && "Extra expressions on stack!");
3561 return StmtStack.pop_back_val();