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::VisitArraySubscriptExpr(ArraySubscriptExpr *E) {
739 E->setLHS(Record.readSubExpr());
740 E->setRHS(Record.readSubExpr());
741 E->setRBracketLoc(ReadSourceLocation());
744 void ASTStmtReader::VisitOMPArraySectionExpr(OMPArraySectionExpr *E) {
746 E->setBase(Record.readSubExpr());
747 E->setLowerBound(Record.readSubExpr());
748 E->setLength(Record.readSubExpr());
749 E->setColonLoc(ReadSourceLocation());
750 E->setRBracketLoc(ReadSourceLocation());
753 void ASTStmtReader::VisitCallExpr(CallExpr *E) {
755 unsigned NumArgs = Record.readInt();
756 assert((NumArgs == E->getNumArgs()) && "Wrong NumArgs!");
757 E->setRParenLoc(ReadSourceLocation());
758 E->setCallee(Record.readSubExpr());
759 for (unsigned I = 0; I != NumArgs; ++I)
760 E->setArg(I, Record.readSubExpr());
761 E->setADLCallKind(static_cast<CallExpr::ADLCallKind>(Record.readInt()));
764 void ASTStmtReader::VisitCXXMemberCallExpr(CXXMemberCallExpr *E) {
768 void ASTStmtReader::VisitMemberExpr(MemberExpr *E) {
771 bool HasQualifier = Record.readInt();
772 bool HasFoundDecl = Record.readInt();
773 bool HasTemplateInfo = Record.readInt();
774 unsigned NumTemplateArgs = Record.readInt();
776 E->Base = Record.readSubExpr();
777 E->MemberDecl = Record.readDeclAs<ValueDecl>();
778 Record.readDeclarationNameLoc(E->MemberDNLoc, E->MemberDecl->getDeclName());
779 E->MemberLoc = Record.readSourceLocation();
780 E->MemberExprBits.IsArrow = Record.readInt();
781 E->MemberExprBits.HasQualifierOrFoundDecl = HasQualifier || HasFoundDecl;
782 E->MemberExprBits.HasTemplateKWAndArgsInfo = HasTemplateInfo;
783 E->MemberExprBits.HadMultipleCandidates = Record.readInt();
784 E->MemberExprBits.NonOdrUseReason = Record.readInt();
785 E->MemberExprBits.OperatorLoc = Record.readSourceLocation();
787 if (HasQualifier || HasFoundDecl) {
788 DeclAccessPair FoundDecl;
790 auto *FoundD = Record.readDeclAs<NamedDecl>();
791 auto AS = (AccessSpecifier)Record.readInt();
792 FoundDecl = DeclAccessPair::make(FoundD, AS);
794 FoundDecl = DeclAccessPair::make(E->MemberDecl,
795 E->MemberDecl->getAccess());
797 E->getTrailingObjects<MemberExprNameQualifier>()->FoundDecl = FoundDecl;
799 NestedNameSpecifierLoc QualifierLoc;
801 QualifierLoc = Record.readNestedNameSpecifierLoc();
802 E->getTrailingObjects<MemberExprNameQualifier>()->QualifierLoc =
807 ReadTemplateKWAndArgsInfo(
808 *E->getTrailingObjects<ASTTemplateKWAndArgsInfo>(),
809 E->getTrailingObjects<TemplateArgumentLoc>(), NumTemplateArgs);
812 void ASTStmtReader::VisitObjCIsaExpr(ObjCIsaExpr *E) {
814 E->setBase(Record.readSubExpr());
815 E->setIsaMemberLoc(ReadSourceLocation());
816 E->setOpLoc(ReadSourceLocation());
817 E->setArrow(Record.readInt());
821 VisitObjCIndirectCopyRestoreExpr(ObjCIndirectCopyRestoreExpr *E) {
823 E->Operand = Record.readSubExpr();
824 E->setShouldCopy(Record.readInt());
827 void ASTStmtReader::VisitObjCBridgedCastExpr(ObjCBridgedCastExpr *E) {
828 VisitExplicitCastExpr(E);
829 E->LParenLoc = ReadSourceLocation();
830 E->BridgeKeywordLoc = ReadSourceLocation();
831 E->Kind = Record.readInt();
834 void ASTStmtReader::VisitCastExpr(CastExpr *E) {
836 unsigned NumBaseSpecs = Record.readInt();
837 assert(NumBaseSpecs == E->path_size());
838 E->setSubExpr(Record.readSubExpr());
839 E->setCastKind((CastKind)Record.readInt());
840 CastExpr::path_iterator BaseI = E->path_begin();
841 while (NumBaseSpecs--) {
842 auto *BaseSpec = new (Record.getContext()) CXXBaseSpecifier;
843 *BaseSpec = Record.readCXXBaseSpecifier();
848 void ASTStmtReader::VisitBinaryOperator(BinaryOperator *E) {
850 E->setLHS(Record.readSubExpr());
851 E->setRHS(Record.readSubExpr());
852 E->setOpcode((BinaryOperator::Opcode)Record.readInt());
853 E->setOperatorLoc(ReadSourceLocation());
854 E->setFPFeatures(FPOptions(Record.readInt()));
857 void ASTStmtReader::VisitCompoundAssignOperator(CompoundAssignOperator *E) {
858 VisitBinaryOperator(E);
859 E->setComputationLHSType(Record.readType());
860 E->setComputationResultType(Record.readType());
863 void ASTStmtReader::VisitConditionalOperator(ConditionalOperator *E) {
865 E->SubExprs[ConditionalOperator::COND] = Record.readSubExpr();
866 E->SubExprs[ConditionalOperator::LHS] = Record.readSubExpr();
867 E->SubExprs[ConditionalOperator::RHS] = Record.readSubExpr();
868 E->QuestionLoc = ReadSourceLocation();
869 E->ColonLoc = ReadSourceLocation();
873 ASTStmtReader::VisitBinaryConditionalOperator(BinaryConditionalOperator *E) {
875 E->OpaqueValue = cast<OpaqueValueExpr>(Record.readSubExpr());
876 E->SubExprs[BinaryConditionalOperator::COMMON] = Record.readSubExpr();
877 E->SubExprs[BinaryConditionalOperator::COND] = Record.readSubExpr();
878 E->SubExprs[BinaryConditionalOperator::LHS] = Record.readSubExpr();
879 E->SubExprs[BinaryConditionalOperator::RHS] = Record.readSubExpr();
880 E->QuestionLoc = ReadSourceLocation();
881 E->ColonLoc = ReadSourceLocation();
884 void ASTStmtReader::VisitImplicitCastExpr(ImplicitCastExpr *E) {
886 E->setIsPartOfExplicitCast(Record.readInt());
889 void ASTStmtReader::VisitExplicitCastExpr(ExplicitCastExpr *E) {
891 E->setTypeInfoAsWritten(GetTypeSourceInfo());
894 void ASTStmtReader::VisitCStyleCastExpr(CStyleCastExpr *E) {
895 VisitExplicitCastExpr(E);
896 E->setLParenLoc(ReadSourceLocation());
897 E->setRParenLoc(ReadSourceLocation());
900 void ASTStmtReader::VisitCompoundLiteralExpr(CompoundLiteralExpr *E) {
902 E->setLParenLoc(ReadSourceLocation());
903 E->setTypeSourceInfo(GetTypeSourceInfo());
904 E->setInitializer(Record.readSubExpr());
905 E->setFileScope(Record.readInt());
908 void ASTStmtReader::VisitExtVectorElementExpr(ExtVectorElementExpr *E) {
910 E->setBase(Record.readSubExpr());
911 E->setAccessor(Record.getIdentifierInfo());
912 E->setAccessorLoc(ReadSourceLocation());
915 void ASTStmtReader::VisitInitListExpr(InitListExpr *E) {
917 if (auto *SyntForm = cast_or_null<InitListExpr>(Record.readSubStmt()))
918 E->setSyntacticForm(SyntForm);
919 E->setLBraceLoc(ReadSourceLocation());
920 E->setRBraceLoc(ReadSourceLocation());
921 bool isArrayFiller = Record.readInt();
922 Expr *filler = nullptr;
924 filler = Record.readSubExpr();
925 E->ArrayFillerOrUnionFieldInit = filler;
927 E->ArrayFillerOrUnionFieldInit = ReadDeclAs<FieldDecl>();
928 E->sawArrayRangeDesignator(Record.readInt());
929 unsigned NumInits = Record.readInt();
930 E->reserveInits(Record.getContext(), NumInits);
932 for (unsigned I = 0; I != NumInits; ++I) {
933 Expr *init = Record.readSubExpr();
934 E->updateInit(Record.getContext(), I, init ? init : filler);
937 for (unsigned I = 0; I != NumInits; ++I)
938 E->updateInit(Record.getContext(), I, Record.readSubExpr());
942 void ASTStmtReader::VisitDesignatedInitExpr(DesignatedInitExpr *E) {
943 using Designator = DesignatedInitExpr::Designator;
946 unsigned NumSubExprs = Record.readInt();
947 assert(NumSubExprs == E->getNumSubExprs() && "Wrong number of subexprs");
948 for (unsigned I = 0; I != NumSubExprs; ++I)
949 E->setSubExpr(I, Record.readSubExpr());
950 E->setEqualOrColonLoc(ReadSourceLocation());
951 E->setGNUSyntax(Record.readInt());
953 SmallVector<Designator, 4> Designators;
954 while (Record.getIdx() < Record.size()) {
955 switch ((DesignatorTypes)Record.readInt()) {
956 case DESIG_FIELD_DECL: {
957 auto *Field = ReadDeclAs<FieldDecl>();
958 SourceLocation DotLoc = ReadSourceLocation();
959 SourceLocation FieldLoc = ReadSourceLocation();
960 Designators.push_back(Designator(Field->getIdentifier(), DotLoc,
962 Designators.back().setField(Field);
966 case DESIG_FIELD_NAME: {
967 const IdentifierInfo *Name = Record.getIdentifierInfo();
968 SourceLocation DotLoc = ReadSourceLocation();
969 SourceLocation FieldLoc = ReadSourceLocation();
970 Designators.push_back(Designator(Name, DotLoc, FieldLoc));
975 unsigned Index = Record.readInt();
976 SourceLocation LBracketLoc = ReadSourceLocation();
977 SourceLocation RBracketLoc = ReadSourceLocation();
978 Designators.push_back(Designator(Index, LBracketLoc, RBracketLoc));
982 case DESIG_ARRAY_RANGE: {
983 unsigned Index = Record.readInt();
984 SourceLocation LBracketLoc = ReadSourceLocation();
985 SourceLocation EllipsisLoc = ReadSourceLocation();
986 SourceLocation RBracketLoc = ReadSourceLocation();
987 Designators.push_back(Designator(Index, LBracketLoc, EllipsisLoc,
993 E->setDesignators(Record.getContext(),
994 Designators.data(), Designators.size());
997 void ASTStmtReader::VisitDesignatedInitUpdateExpr(DesignatedInitUpdateExpr *E) {
999 E->setBase(Record.readSubExpr());
1000 E->setUpdater(Record.readSubExpr());
1003 void ASTStmtReader::VisitNoInitExpr(NoInitExpr *E) {
1007 void ASTStmtReader::VisitArrayInitLoopExpr(ArrayInitLoopExpr *E) {
1009 E->SubExprs[0] = Record.readSubExpr();
1010 E->SubExprs[1] = Record.readSubExpr();
1013 void ASTStmtReader::VisitArrayInitIndexExpr(ArrayInitIndexExpr *E) {
1017 void ASTStmtReader::VisitImplicitValueInitExpr(ImplicitValueInitExpr *E) {
1021 void ASTStmtReader::VisitVAArgExpr(VAArgExpr *E) {
1023 E->setSubExpr(Record.readSubExpr());
1024 E->setWrittenTypeInfo(GetTypeSourceInfo());
1025 E->setBuiltinLoc(ReadSourceLocation());
1026 E->setRParenLoc(ReadSourceLocation());
1027 E->setIsMicrosoftABI(Record.readInt());
1030 void ASTStmtReader::VisitSourceLocExpr(SourceLocExpr *E) {
1032 E->ParentContext = ReadDeclAs<DeclContext>();
1033 E->BuiltinLoc = ReadSourceLocation();
1034 E->RParenLoc = ReadSourceLocation();
1035 E->SourceLocExprBits.Kind =
1036 static_cast<SourceLocExpr::IdentKind>(Record.readInt());
1039 void ASTStmtReader::VisitAddrLabelExpr(AddrLabelExpr *E) {
1041 E->setAmpAmpLoc(ReadSourceLocation());
1042 E->setLabelLoc(ReadSourceLocation());
1043 E->setLabel(ReadDeclAs<LabelDecl>());
1046 void ASTStmtReader::VisitStmtExpr(StmtExpr *E) {
1048 E->setLParenLoc(ReadSourceLocation());
1049 E->setRParenLoc(ReadSourceLocation());
1050 E->setSubStmt(cast_or_null<CompoundStmt>(Record.readSubStmt()));
1053 void ASTStmtReader::VisitChooseExpr(ChooseExpr *E) {
1055 E->setCond(Record.readSubExpr());
1056 E->setLHS(Record.readSubExpr());
1057 E->setRHS(Record.readSubExpr());
1058 E->setBuiltinLoc(ReadSourceLocation());
1059 E->setRParenLoc(ReadSourceLocation());
1060 E->setIsConditionTrue(Record.readInt());
1063 void ASTStmtReader::VisitGNUNullExpr(GNUNullExpr *E) {
1065 E->setTokenLocation(ReadSourceLocation());
1068 void ASTStmtReader::VisitShuffleVectorExpr(ShuffleVectorExpr *E) {
1070 SmallVector<Expr *, 16> Exprs;
1071 unsigned NumExprs = Record.readInt();
1073 Exprs.push_back(Record.readSubExpr());
1074 E->setExprs(Record.getContext(), Exprs);
1075 E->setBuiltinLoc(ReadSourceLocation());
1076 E->setRParenLoc(ReadSourceLocation());
1079 void ASTStmtReader::VisitConvertVectorExpr(ConvertVectorExpr *E) {
1081 E->BuiltinLoc = ReadSourceLocation();
1082 E->RParenLoc = ReadSourceLocation();
1083 E->TInfo = GetTypeSourceInfo();
1084 E->SrcExpr = Record.readSubExpr();
1087 void ASTStmtReader::VisitBlockExpr(BlockExpr *E) {
1089 E->setBlockDecl(ReadDeclAs<BlockDecl>());
1092 void ASTStmtReader::VisitGenericSelectionExpr(GenericSelectionExpr *E) {
1095 unsigned NumAssocs = Record.readInt();
1096 assert(NumAssocs == E->getNumAssocs() && "Wrong NumAssocs!");
1097 E->ResultIndex = Record.readInt();
1098 E->GenericSelectionExprBits.GenericLoc = ReadSourceLocation();
1099 E->DefaultLoc = ReadSourceLocation();
1100 E->RParenLoc = ReadSourceLocation();
1102 Stmt **Stmts = E->getTrailingObjects<Stmt *>();
1103 // Add 1 to account for the controlling expression which is the first
1104 // expression in the trailing array of Stmt *. This is not needed for
1105 // the trailing array of TypeSourceInfo *.
1106 for (unsigned I = 0, N = NumAssocs + 1; I < N; ++I)
1107 Stmts[I] = Record.readSubExpr();
1109 TypeSourceInfo **TSIs = E->getTrailingObjects<TypeSourceInfo *>();
1110 for (unsigned I = 0, N = NumAssocs; I < N; ++I)
1111 TSIs[I] = GetTypeSourceInfo();
1114 void ASTStmtReader::VisitPseudoObjectExpr(PseudoObjectExpr *E) {
1116 unsigned numSemanticExprs = Record.readInt();
1117 assert(numSemanticExprs + 1 == E->PseudoObjectExprBits.NumSubExprs);
1118 E->PseudoObjectExprBits.ResultIndex = Record.readInt();
1120 // Read the syntactic expression.
1121 E->getSubExprsBuffer()[0] = Record.readSubExpr();
1123 // Read all the semantic expressions.
1124 for (unsigned i = 0; i != numSemanticExprs; ++i) {
1125 Expr *subExpr = Record.readSubExpr();
1126 E->getSubExprsBuffer()[i+1] = subExpr;
1130 void ASTStmtReader::VisitAtomicExpr(AtomicExpr *E) {
1132 E->Op = AtomicExpr::AtomicOp(Record.readInt());
1133 E->NumSubExprs = AtomicExpr::getNumSubExprs(E->Op);
1134 for (unsigned I = 0; I != E->NumSubExprs; ++I)
1135 E->SubExprs[I] = Record.readSubExpr();
1136 E->BuiltinLoc = ReadSourceLocation();
1137 E->RParenLoc = ReadSourceLocation();
1140 //===----------------------------------------------------------------------===//
1141 // Objective-C Expressions and Statements
1143 void ASTStmtReader::VisitObjCStringLiteral(ObjCStringLiteral *E) {
1145 E->setString(cast<StringLiteral>(Record.readSubStmt()));
1146 E->setAtLoc(ReadSourceLocation());
1149 void ASTStmtReader::VisitObjCBoxedExpr(ObjCBoxedExpr *E) {
1151 // could be one of several IntegerLiteral, FloatLiteral, etc.
1152 E->SubExpr = Record.readSubStmt();
1153 E->BoxingMethod = ReadDeclAs<ObjCMethodDecl>();
1154 E->Range = ReadSourceRange();
1157 void ASTStmtReader::VisitObjCArrayLiteral(ObjCArrayLiteral *E) {
1159 unsigned NumElements = Record.readInt();
1160 assert(NumElements == E->getNumElements() && "Wrong number of elements");
1161 Expr **Elements = E->getElements();
1162 for (unsigned I = 0, N = NumElements; I != N; ++I)
1163 Elements[I] = Record.readSubExpr();
1164 E->ArrayWithObjectsMethod = ReadDeclAs<ObjCMethodDecl>();
1165 E->Range = ReadSourceRange();
1168 void ASTStmtReader::VisitObjCDictionaryLiteral(ObjCDictionaryLiteral *E) {
1170 unsigned NumElements = Record.readInt();
1171 assert(NumElements == E->getNumElements() && "Wrong number of elements");
1172 bool HasPackExpansions = Record.readInt();
1173 assert(HasPackExpansions == E->HasPackExpansions &&"Pack expansion mismatch");
1175 E->getTrailingObjects<ObjCDictionaryLiteral::KeyValuePair>();
1177 E->getTrailingObjects<ObjCDictionaryLiteral::ExpansionData>();
1178 for (unsigned I = 0; I != NumElements; ++I) {
1179 KeyValues[I].Key = Record.readSubExpr();
1180 KeyValues[I].Value = Record.readSubExpr();
1181 if (HasPackExpansions) {
1182 Expansions[I].EllipsisLoc = ReadSourceLocation();
1183 Expansions[I].NumExpansionsPlusOne = Record.readInt();
1186 E->DictWithObjectsMethod = ReadDeclAs<ObjCMethodDecl>();
1187 E->Range = ReadSourceRange();
1190 void ASTStmtReader::VisitObjCEncodeExpr(ObjCEncodeExpr *E) {
1192 E->setEncodedTypeSourceInfo(GetTypeSourceInfo());
1193 E->setAtLoc(ReadSourceLocation());
1194 E->setRParenLoc(ReadSourceLocation());
1197 void ASTStmtReader::VisitObjCSelectorExpr(ObjCSelectorExpr *E) {
1199 E->setSelector(Record.readSelector());
1200 E->setAtLoc(ReadSourceLocation());
1201 E->setRParenLoc(ReadSourceLocation());
1204 void ASTStmtReader::VisitObjCProtocolExpr(ObjCProtocolExpr *E) {
1206 E->setProtocol(ReadDeclAs<ObjCProtocolDecl>());
1207 E->setAtLoc(ReadSourceLocation());
1208 E->ProtoLoc = ReadSourceLocation();
1209 E->setRParenLoc(ReadSourceLocation());
1212 void ASTStmtReader::VisitObjCIvarRefExpr(ObjCIvarRefExpr *E) {
1214 E->setDecl(ReadDeclAs<ObjCIvarDecl>());
1215 E->setLocation(ReadSourceLocation());
1216 E->setOpLoc(ReadSourceLocation());
1217 E->setBase(Record.readSubExpr());
1218 E->setIsArrow(Record.readInt());
1219 E->setIsFreeIvar(Record.readInt());
1222 void ASTStmtReader::VisitObjCPropertyRefExpr(ObjCPropertyRefExpr *E) {
1224 unsigned MethodRefFlags = Record.readInt();
1225 bool Implicit = Record.readInt() != 0;
1227 auto *Getter = ReadDeclAs<ObjCMethodDecl>();
1228 auto *Setter = ReadDeclAs<ObjCMethodDecl>();
1229 E->setImplicitProperty(Getter, Setter, MethodRefFlags);
1231 E->setExplicitProperty(ReadDeclAs<ObjCPropertyDecl>(), MethodRefFlags);
1233 E->setLocation(ReadSourceLocation());
1234 E->setReceiverLocation(ReadSourceLocation());
1235 switch (Record.readInt()) {
1237 E->setBase(Record.readSubExpr());
1240 E->setSuperReceiver(Record.readType());
1243 E->setClassReceiver(ReadDeclAs<ObjCInterfaceDecl>());
1248 void ASTStmtReader::VisitObjCSubscriptRefExpr(ObjCSubscriptRefExpr *E) {
1250 E->setRBracket(ReadSourceLocation());
1251 E->setBaseExpr(Record.readSubExpr());
1252 E->setKeyExpr(Record.readSubExpr());
1253 E->GetAtIndexMethodDecl = ReadDeclAs<ObjCMethodDecl>();
1254 E->SetAtIndexMethodDecl = ReadDeclAs<ObjCMethodDecl>();
1257 void ASTStmtReader::VisitObjCMessageExpr(ObjCMessageExpr *E) {
1259 assert(Record.peekInt() == E->getNumArgs());
1261 unsigned NumStoredSelLocs = Record.readInt();
1262 E->SelLocsKind = Record.readInt();
1263 E->setDelegateInitCall(Record.readInt());
1264 E->IsImplicit = Record.readInt();
1265 auto Kind = static_cast<ObjCMessageExpr::ReceiverKind>(Record.readInt());
1267 case ObjCMessageExpr::Instance:
1268 E->setInstanceReceiver(Record.readSubExpr());
1271 case ObjCMessageExpr::Class:
1272 E->setClassReceiver(GetTypeSourceInfo());
1275 case ObjCMessageExpr::SuperClass:
1276 case ObjCMessageExpr::SuperInstance: {
1277 QualType T = Record.readType();
1278 SourceLocation SuperLoc = ReadSourceLocation();
1279 E->setSuper(SuperLoc, T, Kind == ObjCMessageExpr::SuperInstance);
1284 assert(Kind == E->getReceiverKind());
1286 if (Record.readInt())
1287 E->setMethodDecl(ReadDeclAs<ObjCMethodDecl>());
1289 E->setSelector(Record.readSelector());
1291 E->LBracLoc = ReadSourceLocation();
1292 E->RBracLoc = ReadSourceLocation();
1294 for (unsigned I = 0, N = E->getNumArgs(); I != N; ++I)
1295 E->setArg(I, Record.readSubExpr());
1297 SourceLocation *Locs = E->getStoredSelLocs();
1298 for (unsigned I = 0; I != NumStoredSelLocs; ++I)
1299 Locs[I] = ReadSourceLocation();
1302 void ASTStmtReader::VisitObjCForCollectionStmt(ObjCForCollectionStmt *S) {
1304 S->setElement(Record.readSubStmt());
1305 S->setCollection(Record.readSubExpr());
1306 S->setBody(Record.readSubStmt());
1307 S->setForLoc(ReadSourceLocation());
1308 S->setRParenLoc(ReadSourceLocation());
1311 void ASTStmtReader::VisitObjCAtCatchStmt(ObjCAtCatchStmt *S) {
1313 S->setCatchBody(Record.readSubStmt());
1314 S->setCatchParamDecl(ReadDeclAs<VarDecl>());
1315 S->setAtCatchLoc(ReadSourceLocation());
1316 S->setRParenLoc(ReadSourceLocation());
1319 void ASTStmtReader::VisitObjCAtFinallyStmt(ObjCAtFinallyStmt *S) {
1321 S->setFinallyBody(Record.readSubStmt());
1322 S->setAtFinallyLoc(ReadSourceLocation());
1325 void ASTStmtReader::VisitObjCAutoreleasePoolStmt(ObjCAutoreleasePoolStmt *S) {
1326 VisitStmt(S); // FIXME: no test coverage.
1327 S->setSubStmt(Record.readSubStmt());
1328 S->setAtLoc(ReadSourceLocation());
1331 void ASTStmtReader::VisitObjCAtTryStmt(ObjCAtTryStmt *S) {
1333 assert(Record.peekInt() == S->getNumCatchStmts());
1335 bool HasFinally = Record.readInt();
1336 S->setTryBody(Record.readSubStmt());
1337 for (unsigned I = 0, N = S->getNumCatchStmts(); I != N; ++I)
1338 S->setCatchStmt(I, cast_or_null<ObjCAtCatchStmt>(Record.readSubStmt()));
1341 S->setFinallyStmt(Record.readSubStmt());
1342 S->setAtTryLoc(ReadSourceLocation());
1345 void ASTStmtReader::VisitObjCAtSynchronizedStmt(ObjCAtSynchronizedStmt *S) {
1346 VisitStmt(S); // FIXME: no test coverage.
1347 S->setSynchExpr(Record.readSubStmt());
1348 S->setSynchBody(Record.readSubStmt());
1349 S->setAtSynchronizedLoc(ReadSourceLocation());
1352 void ASTStmtReader::VisitObjCAtThrowStmt(ObjCAtThrowStmt *S) {
1353 VisitStmt(S); // FIXME: no test coverage.
1354 S->setThrowExpr(Record.readSubStmt());
1355 S->setThrowLoc(ReadSourceLocation());
1358 void ASTStmtReader::VisitObjCBoolLiteralExpr(ObjCBoolLiteralExpr *E) {
1360 E->setValue(Record.readInt());
1361 E->setLocation(ReadSourceLocation());
1364 void ASTStmtReader::VisitObjCAvailabilityCheckExpr(ObjCAvailabilityCheckExpr *E) {
1366 SourceRange R = Record.readSourceRange();
1367 E->AtLoc = R.getBegin();
1368 E->RParen = R.getEnd();
1369 E->VersionToCheck = Record.readVersionTuple();
1372 //===----------------------------------------------------------------------===//
1373 // C++ Expressions and Statements
1374 //===----------------------------------------------------------------------===//
1376 void ASTStmtReader::VisitCXXCatchStmt(CXXCatchStmt *S) {
1378 S->CatchLoc = ReadSourceLocation();
1379 S->ExceptionDecl = ReadDeclAs<VarDecl>();
1380 S->HandlerBlock = Record.readSubStmt();
1383 void ASTStmtReader::VisitCXXTryStmt(CXXTryStmt *S) {
1385 assert(Record.peekInt() == S->getNumHandlers() && "NumStmtFields is wrong ?");
1387 S->TryLoc = ReadSourceLocation();
1388 S->getStmts()[0] = Record.readSubStmt();
1389 for (unsigned i = 0, e = S->getNumHandlers(); i != e; ++i)
1390 S->getStmts()[i + 1] = Record.readSubStmt();
1393 void ASTStmtReader::VisitCXXForRangeStmt(CXXForRangeStmt *S) {
1395 S->ForLoc = ReadSourceLocation();
1396 S->CoawaitLoc = ReadSourceLocation();
1397 S->ColonLoc = ReadSourceLocation();
1398 S->RParenLoc = ReadSourceLocation();
1399 S->setInit(Record.readSubStmt());
1400 S->setRangeStmt(Record.readSubStmt());
1401 S->setBeginStmt(Record.readSubStmt());
1402 S->setEndStmt(Record.readSubStmt());
1403 S->setCond(Record.readSubExpr());
1404 S->setInc(Record.readSubExpr());
1405 S->setLoopVarStmt(Record.readSubStmt());
1406 S->setBody(Record.readSubStmt());
1409 void ASTStmtReader::VisitMSDependentExistsStmt(MSDependentExistsStmt *S) {
1411 S->KeywordLoc = ReadSourceLocation();
1412 S->IsIfExists = Record.readInt();
1413 S->QualifierLoc = Record.readNestedNameSpecifierLoc();
1414 ReadDeclarationNameInfo(S->NameInfo);
1415 S->SubStmt = Record.readSubStmt();
1418 void ASTStmtReader::VisitCXXOperatorCallExpr(CXXOperatorCallExpr *E) {
1420 E->CXXOperatorCallExprBits.OperatorKind = Record.readInt();
1421 E->CXXOperatorCallExprBits.FPFeatures = Record.readInt();
1422 E->Range = Record.readSourceRange();
1425 void ASTStmtReader::VisitCXXConstructExpr(CXXConstructExpr *E) {
1428 unsigned NumArgs = Record.readInt();
1429 assert((NumArgs == E->getNumArgs()) && "Wrong NumArgs!");
1431 E->CXXConstructExprBits.Elidable = Record.readInt();
1432 E->CXXConstructExprBits.HadMultipleCandidates = Record.readInt();
1433 E->CXXConstructExprBits.ListInitialization = Record.readInt();
1434 E->CXXConstructExprBits.StdInitListInitialization = Record.readInt();
1435 E->CXXConstructExprBits.ZeroInitialization = Record.readInt();
1436 E->CXXConstructExprBits.ConstructionKind = Record.readInt();
1437 E->CXXConstructExprBits.Loc = ReadSourceLocation();
1438 E->Constructor = ReadDeclAs<CXXConstructorDecl>();
1439 E->ParenOrBraceRange = ReadSourceRange();
1441 for (unsigned I = 0; I != NumArgs; ++I)
1442 E->setArg(I, Record.readSubExpr());
1445 void ASTStmtReader::VisitCXXInheritedCtorInitExpr(CXXInheritedCtorInitExpr *E) {
1447 E->Constructor = ReadDeclAs<CXXConstructorDecl>();
1448 E->Loc = ReadSourceLocation();
1449 E->ConstructsVirtualBase = Record.readInt();
1450 E->InheritedFromVirtualBase = Record.readInt();
1453 void ASTStmtReader::VisitCXXTemporaryObjectExpr(CXXTemporaryObjectExpr *E) {
1454 VisitCXXConstructExpr(E);
1455 E->TSI = GetTypeSourceInfo();
1458 void ASTStmtReader::VisitLambdaExpr(LambdaExpr *E) {
1460 unsigned NumCaptures = Record.readInt();
1461 assert(NumCaptures == E->NumCaptures);(void)NumCaptures;
1462 E->IntroducerRange = ReadSourceRange();
1463 E->CaptureDefault = static_cast<LambdaCaptureDefault>(Record.readInt());
1464 E->CaptureDefaultLoc = ReadSourceLocation();
1465 E->ExplicitParams = Record.readInt();
1466 E->ExplicitResultType = Record.readInt();
1467 E->ClosingBrace = ReadSourceLocation();
1469 // Read capture initializers.
1470 for (LambdaExpr::capture_init_iterator C = E->capture_init_begin(),
1471 CEnd = E->capture_init_end();
1473 *C = Record.readSubExpr();
1477 ASTStmtReader::VisitCXXStdInitializerListExpr(CXXStdInitializerListExpr *E) {
1479 E->SubExpr = Record.readSubExpr();
1482 void ASTStmtReader::VisitCXXNamedCastExpr(CXXNamedCastExpr *E) {
1483 VisitExplicitCastExpr(E);
1484 SourceRange R = ReadSourceRange();
1485 E->Loc = R.getBegin();
1486 E->RParenLoc = R.getEnd();
1487 R = ReadSourceRange();
1488 E->AngleBrackets = R;
1491 void ASTStmtReader::VisitCXXStaticCastExpr(CXXStaticCastExpr *E) {
1492 return VisitCXXNamedCastExpr(E);
1495 void ASTStmtReader::VisitCXXDynamicCastExpr(CXXDynamicCastExpr *E) {
1496 return VisitCXXNamedCastExpr(E);
1499 void ASTStmtReader::VisitCXXReinterpretCastExpr(CXXReinterpretCastExpr *E) {
1500 return VisitCXXNamedCastExpr(E);
1503 void ASTStmtReader::VisitCXXConstCastExpr(CXXConstCastExpr *E) {
1504 return VisitCXXNamedCastExpr(E);
1507 void ASTStmtReader::VisitCXXFunctionalCastExpr(CXXFunctionalCastExpr *E) {
1508 VisitExplicitCastExpr(E);
1509 E->setLParenLoc(ReadSourceLocation());
1510 E->setRParenLoc(ReadSourceLocation());
1513 void ASTStmtReader::VisitBuiltinBitCastExpr(BuiltinBitCastExpr *E) {
1514 VisitExplicitCastExpr(E);
1515 E->KWLoc = ReadSourceLocation();
1516 E->RParenLoc = ReadSourceLocation();
1519 void ASTStmtReader::VisitUserDefinedLiteral(UserDefinedLiteral *E) {
1521 E->UDSuffixLoc = ReadSourceLocation();
1524 void ASTStmtReader::VisitCXXBoolLiteralExpr(CXXBoolLiteralExpr *E) {
1526 E->setValue(Record.readInt());
1527 E->setLocation(ReadSourceLocation());
1530 void ASTStmtReader::VisitCXXNullPtrLiteralExpr(CXXNullPtrLiteralExpr *E) {
1532 E->setLocation(ReadSourceLocation());
1535 void ASTStmtReader::VisitCXXTypeidExpr(CXXTypeidExpr *E) {
1537 E->setSourceRange(ReadSourceRange());
1538 if (E->isTypeOperand()) { // typeid(int)
1539 E->setTypeOperandSourceInfo(
1540 GetTypeSourceInfo());
1545 E->setExprOperand(Record.readSubExpr());
1548 void ASTStmtReader::VisitCXXThisExpr(CXXThisExpr *E) {
1550 E->setLocation(ReadSourceLocation());
1551 E->setImplicit(Record.readInt());
1554 void ASTStmtReader::VisitCXXThrowExpr(CXXThrowExpr *E) {
1556 E->CXXThrowExprBits.ThrowLoc = ReadSourceLocation();
1557 E->Operand = Record.readSubExpr();
1558 E->CXXThrowExprBits.IsThrownVariableInScope = Record.readInt();
1561 void ASTStmtReader::VisitCXXDefaultArgExpr(CXXDefaultArgExpr *E) {
1563 E->Param = ReadDeclAs<ParmVarDecl>();
1564 E->UsedContext = ReadDeclAs<DeclContext>();
1565 E->CXXDefaultArgExprBits.Loc = ReadSourceLocation();
1568 void ASTStmtReader::VisitCXXDefaultInitExpr(CXXDefaultInitExpr *E) {
1570 E->Field = ReadDeclAs<FieldDecl>();
1571 E->UsedContext = ReadDeclAs<DeclContext>();
1572 E->CXXDefaultInitExprBits.Loc = ReadSourceLocation();
1575 void ASTStmtReader::VisitCXXBindTemporaryExpr(CXXBindTemporaryExpr *E) {
1577 E->setTemporary(Record.readCXXTemporary());
1578 E->setSubExpr(Record.readSubExpr());
1581 void ASTStmtReader::VisitCXXScalarValueInitExpr(CXXScalarValueInitExpr *E) {
1583 E->TypeInfo = GetTypeSourceInfo();
1584 E->CXXScalarValueInitExprBits.RParenLoc = ReadSourceLocation();
1587 void ASTStmtReader::VisitCXXNewExpr(CXXNewExpr *E) {
1590 bool IsArray = Record.readInt();
1591 bool HasInit = Record.readInt();
1592 unsigned NumPlacementArgs = Record.readInt();
1593 bool IsParenTypeId = Record.readInt();
1595 E->CXXNewExprBits.IsGlobalNew = Record.readInt();
1596 E->CXXNewExprBits.ShouldPassAlignment = Record.readInt();
1597 E->CXXNewExprBits.UsualArrayDeleteWantsSize = Record.readInt();
1598 E->CXXNewExprBits.StoredInitializationStyle = Record.readInt();
1600 assert((IsArray == E->isArray()) && "Wrong IsArray!");
1601 assert((HasInit == E->hasInitializer()) && "Wrong HasInit!");
1602 assert((NumPlacementArgs == E->getNumPlacementArgs()) &&
1603 "Wrong NumPlacementArgs!");
1604 assert((IsParenTypeId == E->isParenTypeId()) && "Wrong IsParenTypeId!");
1607 (void)NumPlacementArgs;
1609 E->setOperatorNew(ReadDeclAs<FunctionDecl>());
1610 E->setOperatorDelete(ReadDeclAs<FunctionDecl>());
1611 E->AllocatedTypeInfo = GetTypeSourceInfo();
1613 E->getTrailingObjects<SourceRange>()[0] = ReadSourceRange();
1614 E->Range = ReadSourceRange();
1615 E->DirectInitRange = ReadSourceRange();
1617 // Install all the subexpressions.
1618 for (CXXNewExpr::raw_arg_iterator I = E->raw_arg_begin(),
1619 N = E->raw_arg_end();
1621 *I = Record.readSubStmt();
1624 void ASTStmtReader::VisitCXXDeleteExpr(CXXDeleteExpr *E) {
1626 E->CXXDeleteExprBits.GlobalDelete = Record.readInt();
1627 E->CXXDeleteExprBits.ArrayForm = Record.readInt();
1628 E->CXXDeleteExprBits.ArrayFormAsWritten = Record.readInt();
1629 E->CXXDeleteExprBits.UsualArrayDeleteWantsSize = Record.readInt();
1630 E->OperatorDelete = ReadDeclAs<FunctionDecl>();
1631 E->Argument = Record.readSubExpr();
1632 E->CXXDeleteExprBits.Loc = ReadSourceLocation();
1635 void ASTStmtReader::VisitCXXPseudoDestructorExpr(CXXPseudoDestructorExpr *E) {
1638 E->Base = Record.readSubExpr();
1639 E->IsArrow = Record.readInt();
1640 E->OperatorLoc = ReadSourceLocation();
1641 E->QualifierLoc = Record.readNestedNameSpecifierLoc();
1642 E->ScopeType = GetTypeSourceInfo();
1643 E->ColonColonLoc = ReadSourceLocation();
1644 E->TildeLoc = ReadSourceLocation();
1646 IdentifierInfo *II = Record.getIdentifierInfo();
1648 E->setDestroyedType(II, ReadSourceLocation());
1650 E->setDestroyedType(GetTypeSourceInfo());
1653 void ASTStmtReader::VisitExprWithCleanups(ExprWithCleanups *E) {
1656 unsigned NumObjects = Record.readInt();
1657 assert(NumObjects == E->getNumObjects());
1658 for (unsigned i = 0; i != NumObjects; ++i)
1659 E->getTrailingObjects<BlockDecl *>()[i] =
1660 ReadDeclAs<BlockDecl>();
1662 E->ExprWithCleanupsBits.CleanupsHaveSideEffects = Record.readInt();
1663 E->SubExpr = Record.readSubExpr();
1666 void ASTStmtReader::VisitCXXDependentScopeMemberExpr(
1667 CXXDependentScopeMemberExpr *E) {
1670 bool HasTemplateKWAndArgsInfo = Record.readInt();
1671 unsigned NumTemplateArgs = Record.readInt();
1672 bool HasFirstQualifierFoundInScope = Record.readInt();
1674 assert((HasTemplateKWAndArgsInfo == E->hasTemplateKWAndArgsInfo()) &&
1675 "Wrong HasTemplateKWAndArgsInfo!");
1677 (HasFirstQualifierFoundInScope == E->hasFirstQualifierFoundInScope()) &&
1678 "Wrong HasFirstQualifierFoundInScope!");
1680 if (HasTemplateKWAndArgsInfo)
1681 ReadTemplateKWAndArgsInfo(
1682 *E->getTrailingObjects<ASTTemplateKWAndArgsInfo>(),
1683 E->getTrailingObjects<TemplateArgumentLoc>(), NumTemplateArgs);
1685 assert((NumTemplateArgs == E->getNumTemplateArgs()) &&
1686 "Wrong NumTemplateArgs!");
1688 E->CXXDependentScopeMemberExprBits.IsArrow = Record.readInt();
1689 E->CXXDependentScopeMemberExprBits.OperatorLoc = ReadSourceLocation();
1690 E->BaseType = Record.readType();
1691 E->QualifierLoc = Record.readNestedNameSpecifierLoc();
1692 E->Base = Record.readSubExpr();
1694 if (HasFirstQualifierFoundInScope)
1695 *E->getTrailingObjects<NamedDecl *>() = ReadDeclAs<NamedDecl>();
1697 ReadDeclarationNameInfo(E->MemberNameInfo);
1701 ASTStmtReader::VisitDependentScopeDeclRefExpr(DependentScopeDeclRefExpr *E) {
1704 if (Record.readInt()) // HasTemplateKWAndArgsInfo
1705 ReadTemplateKWAndArgsInfo(
1706 *E->getTrailingObjects<ASTTemplateKWAndArgsInfo>(),
1707 E->getTrailingObjects<TemplateArgumentLoc>(),
1708 /*NumTemplateArgs=*/Record.readInt());
1710 E->QualifierLoc = Record.readNestedNameSpecifierLoc();
1711 ReadDeclarationNameInfo(E->NameInfo);
1715 ASTStmtReader::VisitCXXUnresolvedConstructExpr(CXXUnresolvedConstructExpr *E) {
1717 assert(Record.peekInt() == E->arg_size() &&
1718 "Read wrong record during creation ?");
1720 for (unsigned I = 0, N = E->arg_size(); I != N; ++I)
1721 E->setArg(I, Record.readSubExpr());
1722 E->TSI = GetTypeSourceInfo();
1723 E->setLParenLoc(ReadSourceLocation());
1724 E->setRParenLoc(ReadSourceLocation());
1727 void ASTStmtReader::VisitOverloadExpr(OverloadExpr *E) {
1730 unsigned NumResults = Record.readInt();
1731 bool HasTemplateKWAndArgsInfo = Record.readInt();
1732 assert((E->getNumDecls() == NumResults) && "Wrong NumResults!");
1733 assert((E->hasTemplateKWAndArgsInfo() == HasTemplateKWAndArgsInfo) &&
1734 "Wrong HasTemplateKWAndArgsInfo!");
1736 if (HasTemplateKWAndArgsInfo) {
1737 unsigned NumTemplateArgs = Record.readInt();
1738 ReadTemplateKWAndArgsInfo(*E->getTrailingASTTemplateKWAndArgsInfo(),
1739 E->getTrailingTemplateArgumentLoc(),
1741 assert((E->getNumTemplateArgs() == NumTemplateArgs) &&
1742 "Wrong NumTemplateArgs!");
1745 UnresolvedSet<8> Decls;
1746 for (unsigned I = 0; I != NumResults; ++I) {
1747 auto *D = ReadDeclAs<NamedDecl>();
1748 auto AS = (AccessSpecifier)Record.readInt();
1749 Decls.addDecl(D, AS);
1752 DeclAccessPair *Results = E->getTrailingResults();
1753 UnresolvedSetIterator Iter = Decls.begin();
1754 for (unsigned I = 0; I != NumResults; ++I) {
1755 Results[I] = (Iter + I).getPair();
1758 ReadDeclarationNameInfo(E->NameInfo);
1759 E->QualifierLoc = Record.readNestedNameSpecifierLoc();
1762 void ASTStmtReader::VisitUnresolvedMemberExpr(UnresolvedMemberExpr *E) {
1763 VisitOverloadExpr(E);
1764 E->UnresolvedMemberExprBits.IsArrow = Record.readInt();
1765 E->UnresolvedMemberExprBits.HasUnresolvedUsing = Record.readInt();
1766 E->Base = Record.readSubExpr();
1767 E->BaseType = Record.readType();
1768 E->OperatorLoc = ReadSourceLocation();
1771 void ASTStmtReader::VisitUnresolvedLookupExpr(UnresolvedLookupExpr *E) {
1772 VisitOverloadExpr(E);
1773 E->UnresolvedLookupExprBits.RequiresADL = Record.readInt();
1774 E->UnresolvedLookupExprBits.Overloaded = Record.readInt();
1775 E->NamingClass = ReadDeclAs<CXXRecordDecl>();
1778 void ASTStmtReader::VisitTypeTraitExpr(TypeTraitExpr *E) {
1780 E->TypeTraitExprBits.NumArgs = Record.readInt();
1781 E->TypeTraitExprBits.Kind = Record.readInt();
1782 E->TypeTraitExprBits.Value = Record.readInt();
1783 SourceRange Range = ReadSourceRange();
1784 E->Loc = Range.getBegin();
1785 E->RParenLoc = Range.getEnd();
1787 auto **Args = E->getTrailingObjects<TypeSourceInfo *>();
1788 for (unsigned I = 0, N = E->getNumArgs(); I != N; ++I)
1789 Args[I] = GetTypeSourceInfo();
1792 void ASTStmtReader::VisitArrayTypeTraitExpr(ArrayTypeTraitExpr *E) {
1794 E->ATT = (ArrayTypeTrait)Record.readInt();
1795 E->Value = (unsigned int)Record.readInt();
1796 SourceRange Range = ReadSourceRange();
1797 E->Loc = Range.getBegin();
1798 E->RParen = Range.getEnd();
1799 E->QueriedType = GetTypeSourceInfo();
1800 E->Dimension = Record.readSubExpr();
1803 void ASTStmtReader::VisitExpressionTraitExpr(ExpressionTraitExpr *E) {
1805 E->ET = (ExpressionTrait)Record.readInt();
1806 E->Value = (bool)Record.readInt();
1807 SourceRange Range = ReadSourceRange();
1808 E->QueriedExpression = Record.readSubExpr();
1809 E->Loc = Range.getBegin();
1810 E->RParen = Range.getEnd();
1813 void ASTStmtReader::VisitCXXNoexceptExpr(CXXNoexceptExpr *E) {
1815 E->CXXNoexceptExprBits.Value = Record.readInt();
1816 E->Range = ReadSourceRange();
1817 E->Operand = Record.readSubExpr();
1820 void ASTStmtReader::VisitPackExpansionExpr(PackExpansionExpr *E) {
1822 E->EllipsisLoc = ReadSourceLocation();
1823 E->NumExpansions = Record.readInt();
1824 E->Pattern = Record.readSubExpr();
1827 void ASTStmtReader::VisitSizeOfPackExpr(SizeOfPackExpr *E) {
1829 unsigned NumPartialArgs = Record.readInt();
1830 E->OperatorLoc = ReadSourceLocation();
1831 E->PackLoc = ReadSourceLocation();
1832 E->RParenLoc = ReadSourceLocation();
1833 E->Pack = Record.readDeclAs<NamedDecl>();
1834 if (E->isPartiallySubstituted()) {
1835 assert(E->Length == NumPartialArgs);
1836 for (auto *I = E->getTrailingObjects<TemplateArgument>(),
1837 *E = I + NumPartialArgs;
1839 new (I) TemplateArgument(Record.readTemplateArgument());
1840 } else if (!E->isValueDependent()) {
1841 E->Length = Record.readInt();
1845 void ASTStmtReader::VisitSubstNonTypeTemplateParmExpr(
1846 SubstNonTypeTemplateParmExpr *E) {
1848 E->Param = ReadDeclAs<NonTypeTemplateParmDecl>();
1849 E->SubstNonTypeTemplateParmExprBits.NameLoc = ReadSourceLocation();
1850 E->Replacement = Record.readSubExpr();
1853 void ASTStmtReader::VisitSubstNonTypeTemplateParmPackExpr(
1854 SubstNonTypeTemplateParmPackExpr *E) {
1856 E->Param = ReadDeclAs<NonTypeTemplateParmDecl>();
1857 TemplateArgument ArgPack = Record.readTemplateArgument();
1858 if (ArgPack.getKind() != TemplateArgument::Pack)
1861 E->Arguments = ArgPack.pack_begin();
1862 E->NumArguments = ArgPack.pack_size();
1863 E->NameLoc = ReadSourceLocation();
1866 void ASTStmtReader::VisitFunctionParmPackExpr(FunctionParmPackExpr *E) {
1868 E->NumParameters = Record.readInt();
1869 E->ParamPack = ReadDeclAs<ParmVarDecl>();
1870 E->NameLoc = ReadSourceLocation();
1871 auto **Parms = E->getTrailingObjects<VarDecl *>();
1872 for (unsigned i = 0, n = E->NumParameters; i != n; ++i)
1873 Parms[i] = ReadDeclAs<VarDecl>();
1876 void ASTStmtReader::VisitMaterializeTemporaryExpr(MaterializeTemporaryExpr *E) {
1878 E->State = Record.readSubExpr();
1879 auto *VD = ReadDeclAs<ValueDecl>();
1880 unsigned ManglingNumber = Record.readInt();
1881 E->setExtendingDecl(VD, ManglingNumber);
1884 void ASTStmtReader::VisitCXXFoldExpr(CXXFoldExpr *E) {
1886 E->LParenLoc = ReadSourceLocation();
1887 E->EllipsisLoc = ReadSourceLocation();
1888 E->RParenLoc = ReadSourceLocation();
1889 E->NumExpansions = Record.readInt();
1890 E->SubExprs[0] = Record.readSubExpr();
1891 E->SubExprs[1] = Record.readSubExpr();
1892 E->Opcode = (BinaryOperatorKind)Record.readInt();
1895 void ASTStmtReader::VisitOpaqueValueExpr(OpaqueValueExpr *E) {
1897 E->SourceExpr = Record.readSubExpr();
1898 E->OpaqueValueExprBits.Loc = ReadSourceLocation();
1899 E->setIsUnique(Record.readInt());
1902 void ASTStmtReader::VisitTypoExpr(TypoExpr *E) {
1903 llvm_unreachable("Cannot read TypoExpr nodes");
1906 //===----------------------------------------------------------------------===//
1907 // Microsoft Expressions and Statements
1908 //===----------------------------------------------------------------------===//
1909 void ASTStmtReader::VisitMSPropertyRefExpr(MSPropertyRefExpr *E) {
1911 E->IsArrow = (Record.readInt() != 0);
1912 E->BaseExpr = Record.readSubExpr();
1913 E->QualifierLoc = Record.readNestedNameSpecifierLoc();
1914 E->MemberLoc = ReadSourceLocation();
1915 E->TheDecl = ReadDeclAs<MSPropertyDecl>();
1918 void ASTStmtReader::VisitMSPropertySubscriptExpr(MSPropertySubscriptExpr *E) {
1920 E->setBase(Record.readSubExpr());
1921 E->setIdx(Record.readSubExpr());
1922 E->setRBracketLoc(ReadSourceLocation());
1925 void ASTStmtReader::VisitCXXUuidofExpr(CXXUuidofExpr *E) {
1927 E->setSourceRange(ReadSourceRange());
1928 std::string UuidStr = ReadString();
1929 E->setUuidStr(StringRef(UuidStr).copy(Record.getContext()));
1930 if (E->isTypeOperand()) { // __uuidof(ComType)
1931 E->setTypeOperandSourceInfo(
1932 GetTypeSourceInfo());
1937 E->setExprOperand(Record.readSubExpr());
1940 void ASTStmtReader::VisitSEHLeaveStmt(SEHLeaveStmt *S) {
1942 S->setLeaveLoc(ReadSourceLocation());
1945 void ASTStmtReader::VisitSEHExceptStmt(SEHExceptStmt *S) {
1947 S->Loc = ReadSourceLocation();
1948 S->Children[SEHExceptStmt::FILTER_EXPR] = Record.readSubStmt();
1949 S->Children[SEHExceptStmt::BLOCK] = Record.readSubStmt();
1952 void ASTStmtReader::VisitSEHFinallyStmt(SEHFinallyStmt *S) {
1954 S->Loc = ReadSourceLocation();
1955 S->Block = Record.readSubStmt();
1958 void ASTStmtReader::VisitSEHTryStmt(SEHTryStmt *S) {
1960 S->IsCXXTry = Record.readInt();
1961 S->TryLoc = ReadSourceLocation();
1962 S->Children[SEHTryStmt::TRY] = Record.readSubStmt();
1963 S->Children[SEHTryStmt::HANDLER] = Record.readSubStmt();
1966 //===----------------------------------------------------------------------===//
1967 // CUDA Expressions and Statements
1968 //===----------------------------------------------------------------------===//
1970 void ASTStmtReader::VisitCUDAKernelCallExpr(CUDAKernelCallExpr *E) {
1972 E->setPreArg(CUDAKernelCallExpr::CONFIG, Record.readSubExpr());
1975 //===----------------------------------------------------------------------===//
1976 // OpenCL Expressions and Statements.
1977 //===----------------------------------------------------------------------===//
1978 void ASTStmtReader::VisitAsTypeExpr(AsTypeExpr *E) {
1980 E->BuiltinLoc = ReadSourceLocation();
1981 E->RParenLoc = ReadSourceLocation();
1982 E->SrcExpr = Record.readSubExpr();
1985 //===----------------------------------------------------------------------===//
1986 // OpenMP Directives.
1987 //===----------------------------------------------------------------------===//
1989 void ASTStmtReader::VisitOMPExecutableDirective(OMPExecutableDirective *E) {
1990 E->setLocStart(ReadSourceLocation());
1991 E->setLocEnd(ReadSourceLocation());
1992 OMPClauseReader ClauseReader(Record);
1993 SmallVector<OMPClause *, 5> Clauses;
1994 for (unsigned i = 0; i < E->getNumClauses(); ++i)
1995 Clauses.push_back(ClauseReader.readClause());
1996 E->setClauses(Clauses);
1997 if (E->hasAssociatedStmt())
1998 E->setAssociatedStmt(Record.readSubStmt());
2001 void ASTStmtReader::VisitOMPLoopDirective(OMPLoopDirective *D) {
2003 // Two fields (NumClauses and CollapsedNum) were read in ReadStmtFromStream.
2005 VisitOMPExecutableDirective(D);
2006 D->setIterationVariable(Record.readSubExpr());
2007 D->setLastIteration(Record.readSubExpr());
2008 D->setCalcLastIteration(Record.readSubExpr());
2009 D->setPreCond(Record.readSubExpr());
2010 D->setCond(Record.readSubExpr());
2011 D->setInit(Record.readSubExpr());
2012 D->setInc(Record.readSubExpr());
2013 D->setPreInits(Record.readSubStmt());
2014 if (isOpenMPWorksharingDirective(D->getDirectiveKind()) ||
2015 isOpenMPTaskLoopDirective(D->getDirectiveKind()) ||
2016 isOpenMPDistributeDirective(D->getDirectiveKind())) {
2017 D->setIsLastIterVariable(Record.readSubExpr());
2018 D->setLowerBoundVariable(Record.readSubExpr());
2019 D->setUpperBoundVariable(Record.readSubExpr());
2020 D->setStrideVariable(Record.readSubExpr());
2021 D->setEnsureUpperBound(Record.readSubExpr());
2022 D->setNextLowerBound(Record.readSubExpr());
2023 D->setNextUpperBound(Record.readSubExpr());
2024 D->setNumIterations(Record.readSubExpr());
2026 if (isOpenMPLoopBoundSharingDirective(D->getDirectiveKind())) {
2027 D->setPrevLowerBoundVariable(Record.readSubExpr());
2028 D->setPrevUpperBoundVariable(Record.readSubExpr());
2029 D->setDistInc(Record.readSubExpr());
2030 D->setPrevEnsureUpperBound(Record.readSubExpr());
2031 D->setCombinedLowerBoundVariable(Record.readSubExpr());
2032 D->setCombinedUpperBoundVariable(Record.readSubExpr());
2033 D->setCombinedEnsureUpperBound(Record.readSubExpr());
2034 D->setCombinedInit(Record.readSubExpr());
2035 D->setCombinedCond(Record.readSubExpr());
2036 D->setCombinedNextLowerBound(Record.readSubExpr());
2037 D->setCombinedNextUpperBound(Record.readSubExpr());
2038 D->setCombinedDistCond(Record.readSubExpr());
2039 D->setCombinedParForInDistCond(Record.readSubExpr());
2041 SmallVector<Expr *, 4> Sub;
2042 unsigned CollapsedNum = D->getCollapsedNumber();
2043 Sub.reserve(CollapsedNum);
2044 for (unsigned i = 0; i < CollapsedNum; ++i)
2045 Sub.push_back(Record.readSubExpr());
2046 D->setCounters(Sub);
2048 for (unsigned i = 0; i < CollapsedNum; ++i)
2049 Sub.push_back(Record.readSubExpr());
2050 D->setPrivateCounters(Sub);
2052 for (unsigned i = 0; i < CollapsedNum; ++i)
2053 Sub.push_back(Record.readSubExpr());
2056 for (unsigned i = 0; i < CollapsedNum; ++i)
2057 Sub.push_back(Record.readSubExpr());
2060 for (unsigned i = 0; i < CollapsedNum; ++i)
2061 Sub.push_back(Record.readSubExpr());
2065 void ASTStmtReader::VisitOMPParallelDirective(OMPParallelDirective *D) {
2067 // The NumClauses field was read in ReadStmtFromStream.
2069 VisitOMPExecutableDirective(D);
2070 D->setHasCancel(Record.readInt());
2073 void ASTStmtReader::VisitOMPSimdDirective(OMPSimdDirective *D) {
2074 VisitOMPLoopDirective(D);
2077 void ASTStmtReader::VisitOMPForDirective(OMPForDirective *D) {
2078 VisitOMPLoopDirective(D);
2079 D->setHasCancel(Record.readInt());
2082 void ASTStmtReader::VisitOMPForSimdDirective(OMPForSimdDirective *D) {
2083 VisitOMPLoopDirective(D);
2086 void ASTStmtReader::VisitOMPSectionsDirective(OMPSectionsDirective *D) {
2088 // The NumClauses field was read in ReadStmtFromStream.
2090 VisitOMPExecutableDirective(D);
2091 D->setHasCancel(Record.readInt());
2094 void ASTStmtReader::VisitOMPSectionDirective(OMPSectionDirective *D) {
2096 VisitOMPExecutableDirective(D);
2097 D->setHasCancel(Record.readInt());
2100 void ASTStmtReader::VisitOMPSingleDirective(OMPSingleDirective *D) {
2102 // The NumClauses field was read in ReadStmtFromStream.
2104 VisitOMPExecutableDirective(D);
2107 void ASTStmtReader::VisitOMPMasterDirective(OMPMasterDirective *D) {
2109 VisitOMPExecutableDirective(D);
2112 void ASTStmtReader::VisitOMPCriticalDirective(OMPCriticalDirective *D) {
2114 // The NumClauses field was read in ReadStmtFromStream.
2116 VisitOMPExecutableDirective(D);
2117 ReadDeclarationNameInfo(D->DirName);
2120 void ASTStmtReader::VisitOMPParallelForDirective(OMPParallelForDirective *D) {
2121 VisitOMPLoopDirective(D);
2122 D->setHasCancel(Record.readInt());
2125 void ASTStmtReader::VisitOMPParallelForSimdDirective(
2126 OMPParallelForSimdDirective *D) {
2127 VisitOMPLoopDirective(D);
2130 void ASTStmtReader::VisitOMPParallelSectionsDirective(
2131 OMPParallelSectionsDirective *D) {
2133 // The NumClauses field was read in ReadStmtFromStream.
2135 VisitOMPExecutableDirective(D);
2136 D->setHasCancel(Record.readInt());
2139 void ASTStmtReader::VisitOMPTaskDirective(OMPTaskDirective *D) {
2141 // The NumClauses field was read in ReadStmtFromStream.
2143 VisitOMPExecutableDirective(D);
2144 D->setHasCancel(Record.readInt());
2147 void ASTStmtReader::VisitOMPTaskyieldDirective(OMPTaskyieldDirective *D) {
2149 VisitOMPExecutableDirective(D);
2152 void ASTStmtReader::VisitOMPBarrierDirective(OMPBarrierDirective *D) {
2154 VisitOMPExecutableDirective(D);
2157 void ASTStmtReader::VisitOMPTaskwaitDirective(OMPTaskwaitDirective *D) {
2159 VisitOMPExecutableDirective(D);
2162 void ASTStmtReader::VisitOMPTaskgroupDirective(OMPTaskgroupDirective *D) {
2164 // The NumClauses field was read in ReadStmtFromStream.
2166 VisitOMPExecutableDirective(D);
2167 D->setReductionRef(Record.readSubExpr());
2170 void ASTStmtReader::VisitOMPFlushDirective(OMPFlushDirective *D) {
2172 // The NumClauses field was read in ReadStmtFromStream.
2174 VisitOMPExecutableDirective(D);
2177 void ASTStmtReader::VisitOMPOrderedDirective(OMPOrderedDirective *D) {
2179 // The NumClauses field was read in ReadStmtFromStream.
2181 VisitOMPExecutableDirective(D);
2184 void ASTStmtReader::VisitOMPAtomicDirective(OMPAtomicDirective *D) {
2186 // The NumClauses field was read in ReadStmtFromStream.
2188 VisitOMPExecutableDirective(D);
2189 D->setX(Record.readSubExpr());
2190 D->setV(Record.readSubExpr());
2191 D->setExpr(Record.readSubExpr());
2192 D->setUpdateExpr(Record.readSubExpr());
2193 D->IsXLHSInRHSPart = Record.readInt() != 0;
2194 D->IsPostfixUpdate = Record.readInt() != 0;
2197 void ASTStmtReader::VisitOMPTargetDirective(OMPTargetDirective *D) {
2199 // The NumClauses field was read in ReadStmtFromStream.
2201 VisitOMPExecutableDirective(D);
2204 void ASTStmtReader::VisitOMPTargetDataDirective(OMPTargetDataDirective *D) {
2207 VisitOMPExecutableDirective(D);
2210 void ASTStmtReader::VisitOMPTargetEnterDataDirective(
2211 OMPTargetEnterDataDirective *D) {
2214 VisitOMPExecutableDirective(D);
2217 void ASTStmtReader::VisitOMPTargetExitDataDirective(
2218 OMPTargetExitDataDirective *D) {
2221 VisitOMPExecutableDirective(D);
2224 void ASTStmtReader::VisitOMPTargetParallelDirective(
2225 OMPTargetParallelDirective *D) {
2228 VisitOMPExecutableDirective(D);
2231 void ASTStmtReader::VisitOMPTargetParallelForDirective(
2232 OMPTargetParallelForDirective *D) {
2233 VisitOMPLoopDirective(D);
2234 D->setHasCancel(Record.readInt());
2237 void ASTStmtReader::VisitOMPTeamsDirective(OMPTeamsDirective *D) {
2239 // The NumClauses field was read in ReadStmtFromStream.
2241 VisitOMPExecutableDirective(D);
2244 void ASTStmtReader::VisitOMPCancellationPointDirective(
2245 OMPCancellationPointDirective *D) {
2247 VisitOMPExecutableDirective(D);
2248 D->setCancelRegion(static_cast<OpenMPDirectiveKind>(Record.readInt()));
2251 void ASTStmtReader::VisitOMPCancelDirective(OMPCancelDirective *D) {
2253 // The NumClauses field was read in ReadStmtFromStream.
2255 VisitOMPExecutableDirective(D);
2256 D->setCancelRegion(static_cast<OpenMPDirectiveKind>(Record.readInt()));
2259 void ASTStmtReader::VisitOMPTaskLoopDirective(OMPTaskLoopDirective *D) {
2260 VisitOMPLoopDirective(D);
2263 void ASTStmtReader::VisitOMPTaskLoopSimdDirective(OMPTaskLoopSimdDirective *D) {
2264 VisitOMPLoopDirective(D);
2267 void ASTStmtReader::VisitOMPDistributeDirective(OMPDistributeDirective *D) {
2268 VisitOMPLoopDirective(D);
2271 void ASTStmtReader::VisitOMPTargetUpdateDirective(OMPTargetUpdateDirective *D) {
2274 VisitOMPExecutableDirective(D);
2277 void ASTStmtReader::VisitOMPDistributeParallelForDirective(
2278 OMPDistributeParallelForDirective *D) {
2279 VisitOMPLoopDirective(D);
2280 D->setHasCancel(Record.readInt());
2283 void ASTStmtReader::VisitOMPDistributeParallelForSimdDirective(
2284 OMPDistributeParallelForSimdDirective *D) {
2285 VisitOMPLoopDirective(D);
2288 void ASTStmtReader::VisitOMPDistributeSimdDirective(
2289 OMPDistributeSimdDirective *D) {
2290 VisitOMPLoopDirective(D);
2293 void ASTStmtReader::VisitOMPTargetParallelForSimdDirective(
2294 OMPTargetParallelForSimdDirective *D) {
2295 VisitOMPLoopDirective(D);
2298 void ASTStmtReader::VisitOMPTargetSimdDirective(OMPTargetSimdDirective *D) {
2299 VisitOMPLoopDirective(D);
2302 void ASTStmtReader::VisitOMPTeamsDistributeDirective(
2303 OMPTeamsDistributeDirective *D) {
2304 VisitOMPLoopDirective(D);
2307 void ASTStmtReader::VisitOMPTeamsDistributeSimdDirective(
2308 OMPTeamsDistributeSimdDirective *D) {
2309 VisitOMPLoopDirective(D);
2312 void ASTStmtReader::VisitOMPTeamsDistributeParallelForSimdDirective(
2313 OMPTeamsDistributeParallelForSimdDirective *D) {
2314 VisitOMPLoopDirective(D);
2317 void ASTStmtReader::VisitOMPTeamsDistributeParallelForDirective(
2318 OMPTeamsDistributeParallelForDirective *D) {
2319 VisitOMPLoopDirective(D);
2320 D->setHasCancel(Record.readInt());
2323 void ASTStmtReader::VisitOMPTargetTeamsDirective(OMPTargetTeamsDirective *D) {
2325 // The NumClauses field was read in ReadStmtFromStream.
2327 VisitOMPExecutableDirective(D);
2330 void ASTStmtReader::VisitOMPTargetTeamsDistributeDirective(
2331 OMPTargetTeamsDistributeDirective *D) {
2332 VisitOMPLoopDirective(D);
2335 void ASTStmtReader::VisitOMPTargetTeamsDistributeParallelForDirective(
2336 OMPTargetTeamsDistributeParallelForDirective *D) {
2337 VisitOMPLoopDirective(D);
2338 D->setHasCancel(Record.readInt());
2341 void ASTStmtReader::VisitOMPTargetTeamsDistributeParallelForSimdDirective(
2342 OMPTargetTeamsDistributeParallelForSimdDirective *D) {
2343 VisitOMPLoopDirective(D);
2346 void ASTStmtReader::VisitOMPTargetTeamsDistributeSimdDirective(
2347 OMPTargetTeamsDistributeSimdDirective *D) {
2348 VisitOMPLoopDirective(D);
2351 //===----------------------------------------------------------------------===//
2352 // ASTReader Implementation
2353 //===----------------------------------------------------------------------===//
2355 Stmt *ASTReader::ReadStmt(ModuleFile &F) {
2356 switch (ReadingKind) {
2358 llvm_unreachable("should not call this when not reading anything");
2361 return ReadStmtFromStream(F);
2363 return ReadSubStmt();
2366 llvm_unreachable("ReadingKind not set ?");
2369 Expr *ASTReader::ReadExpr(ModuleFile &F) {
2370 return cast_or_null<Expr>(ReadStmt(F));
2373 Expr *ASTReader::ReadSubExpr() {
2374 return cast_or_null<Expr>(ReadSubStmt());
2377 // Within the bitstream, expressions are stored in Reverse Polish
2378 // Notation, with each of the subexpressions preceding the
2379 // expression they are stored in. Subexpressions are stored from last to first.
2380 // To evaluate expressions, we continue reading expressions and placing them on
2381 // the stack, with expressions having operands removing those operands from the
2382 // stack. Evaluation terminates when we see a STMT_STOP record, and
2383 // the single remaining expression on the stack is our result.
2384 Stmt *ASTReader::ReadStmtFromStream(ModuleFile &F) {
2385 ReadingKindTracker ReadingKind(Read_Stmt, *this);
2386 llvm::BitstreamCursor &Cursor = F.DeclsCursor;
2388 // Map of offset to previously deserialized stmt. The offset points
2389 // just after the stmt record.
2390 llvm::DenseMap<uint64_t, Stmt *> StmtEntries;
2393 unsigned PrevNumStmts = StmtStack.size();
2396 ASTRecordReader Record(*this, F);
2397 ASTStmtReader Reader(Record, Cursor);
2398 Stmt::EmptyShell Empty;
2401 llvm::Expected<llvm::BitstreamEntry> MaybeEntry =
2402 Cursor.advanceSkippingSubblocks();
2404 Error(toString(MaybeEntry.takeError()));
2407 llvm::BitstreamEntry Entry = MaybeEntry.get();
2409 switch (Entry.Kind) {
2410 case llvm::BitstreamEntry::SubBlock: // Handled for us already.
2411 case llvm::BitstreamEntry::Error:
2412 Error("malformed block record in AST file");
2414 case llvm::BitstreamEntry::EndBlock:
2416 case llvm::BitstreamEntry::Record:
2417 // The interesting case.
2421 ASTContext &Context = getContext();
2423 bool Finished = false;
2424 bool IsStmtReference = false;
2425 Expected<unsigned> MaybeStmtCode = Record.readRecord(Cursor, Entry.ID);
2426 if (!MaybeStmtCode) {
2427 Error(toString(MaybeStmtCode.takeError()));
2430 switch ((StmtCode)MaybeStmtCode.get()) {
2436 IsStmtReference = true;
2437 assert(StmtEntries.find(Record[0]) != StmtEntries.end() &&
2438 "No stmt was recorded for this offset reference!");
2439 S = StmtEntries[Record.readInt()];
2447 S = new (Context) NullStmt(Empty);
2451 S = CompoundStmt::CreateEmpty(
2452 Context, /*NumStmts=*/Record[ASTStmtReader::NumStmtFields]);
2456 S = CaseStmt::CreateEmpty(
2458 /*CaseStmtIsGNURange*/ Record[ASTStmtReader::NumStmtFields + 3]);
2462 S = new (Context) DefaultStmt(Empty);
2466 S = new (Context) LabelStmt(Empty);
2469 case STMT_ATTRIBUTED:
2470 S = AttributedStmt::CreateEmpty(
2472 /*NumAttrs*/Record[ASTStmtReader::NumStmtFields]);
2476 S = IfStmt::CreateEmpty(
2478 /* HasElse=*/Record[ASTStmtReader::NumStmtFields + 1],
2479 /* HasVar=*/Record[ASTStmtReader::NumStmtFields + 2],
2480 /* HasInit=*/Record[ASTStmtReader::NumStmtFields + 3]);
2484 S = SwitchStmt::CreateEmpty(
2486 /* HasInit=*/Record[ASTStmtReader::NumStmtFields],
2487 /* HasVar=*/Record[ASTStmtReader::NumStmtFields + 1]);
2491 S = WhileStmt::CreateEmpty(
2493 /* HasVar=*/Record[ASTStmtReader::NumStmtFields]);
2497 S = new (Context) DoStmt(Empty);
2501 S = new (Context) ForStmt(Empty);
2505 S = new (Context) GotoStmt(Empty);
2508 case STMT_INDIRECT_GOTO:
2509 S = new (Context) IndirectGotoStmt(Empty);
2513 S = new (Context) ContinueStmt(Empty);
2517 S = new (Context) BreakStmt(Empty);
2521 S = ReturnStmt::CreateEmpty(
2522 Context, /* HasNRVOCandidate=*/Record[ASTStmtReader::NumStmtFields]);
2526 S = new (Context) DeclStmt(Empty);
2530 S = new (Context) GCCAsmStmt(Empty);
2534 S = new (Context) MSAsmStmt(Empty);
2538 S = CapturedStmt::CreateDeserialized(
2539 Context, Record[ASTStmtReader::NumStmtFields]);
2543 S = ConstantExpr::CreateEmpty(
2545 static_cast<ConstantExpr::ResultStorageKind>(
2546 Record[ASTStmtReader::NumExprFields]),
2550 case EXPR_PREDEFINED:
2551 S = PredefinedExpr::CreateEmpty(
2553 /*HasFunctionName*/ Record[ASTStmtReader::NumExprFields]);
2557 S = DeclRefExpr::CreateEmpty(
2559 /*HasQualifier=*/Record[ASTStmtReader::NumExprFields],
2560 /*HasFoundDecl=*/Record[ASTStmtReader::NumExprFields + 1],
2561 /*HasTemplateKWAndArgsInfo=*/Record[ASTStmtReader::NumExprFields + 2],
2562 /*NumTemplateArgs=*/Record[ASTStmtReader::NumExprFields + 2] ?
2563 Record[ASTStmtReader::NumExprFields + 6] : 0);
2566 case EXPR_INTEGER_LITERAL:
2567 S = IntegerLiteral::Create(Context, Empty);
2570 case EXPR_FLOATING_LITERAL:
2571 S = FloatingLiteral::Create(Context, Empty);
2574 case EXPR_IMAGINARY_LITERAL:
2575 S = new (Context) ImaginaryLiteral(Empty);
2578 case EXPR_STRING_LITERAL:
2579 S = StringLiteral::CreateEmpty(
2581 /* NumConcatenated=*/Record[ASTStmtReader::NumExprFields],
2582 /* Length=*/Record[ASTStmtReader::NumExprFields + 1],
2583 /* CharByteWidth=*/Record[ASTStmtReader::NumExprFields + 2]);
2586 case EXPR_CHARACTER_LITERAL:
2587 S = new (Context) CharacterLiteral(Empty);
2591 S = new (Context) ParenExpr(Empty);
2594 case EXPR_PAREN_LIST:
2595 S = ParenListExpr::CreateEmpty(
2597 /* NumExprs=*/Record[ASTStmtReader::NumExprFields]);
2600 case EXPR_UNARY_OPERATOR:
2601 S = new (Context) UnaryOperator(Empty);
2605 S = OffsetOfExpr::CreateEmpty(Context,
2606 Record[ASTStmtReader::NumExprFields],
2607 Record[ASTStmtReader::NumExprFields + 1]);
2610 case EXPR_SIZEOF_ALIGN_OF:
2611 S = new (Context) UnaryExprOrTypeTraitExpr(Empty);
2614 case EXPR_ARRAY_SUBSCRIPT:
2615 S = new (Context) ArraySubscriptExpr(Empty);
2618 case EXPR_OMP_ARRAY_SECTION:
2619 S = new (Context) OMPArraySectionExpr(Empty);
2623 S = CallExpr::CreateEmpty(
2624 Context, /*NumArgs=*/Record[ASTStmtReader::NumExprFields], Empty);
2628 S = MemberExpr::CreateEmpty(Context, Record[ASTStmtReader::NumExprFields],
2629 Record[ASTStmtReader::NumExprFields + 1],
2630 Record[ASTStmtReader::NumExprFields + 2],
2631 Record[ASTStmtReader::NumExprFields + 3]);
2634 case EXPR_BINARY_OPERATOR:
2635 S = new (Context) BinaryOperator(Empty);
2638 case EXPR_COMPOUND_ASSIGN_OPERATOR:
2639 S = new (Context) CompoundAssignOperator(Empty);
2642 case EXPR_CONDITIONAL_OPERATOR:
2643 S = new (Context) ConditionalOperator(Empty);
2646 case EXPR_BINARY_CONDITIONAL_OPERATOR:
2647 S = new (Context) BinaryConditionalOperator(Empty);
2650 case EXPR_IMPLICIT_CAST:
2651 S = ImplicitCastExpr::CreateEmpty(Context,
2652 /*PathSize*/ Record[ASTStmtReader::NumExprFields]);
2655 case EXPR_CSTYLE_CAST:
2656 S = CStyleCastExpr::CreateEmpty(Context,
2657 /*PathSize*/ Record[ASTStmtReader::NumExprFields]);
2660 case EXPR_COMPOUND_LITERAL:
2661 S = new (Context) CompoundLiteralExpr(Empty);
2664 case EXPR_EXT_VECTOR_ELEMENT:
2665 S = new (Context) ExtVectorElementExpr(Empty);
2668 case EXPR_INIT_LIST:
2669 S = new (Context) InitListExpr(Empty);
2672 case EXPR_DESIGNATED_INIT:
2673 S = DesignatedInitExpr::CreateEmpty(Context,
2674 Record[ASTStmtReader::NumExprFields] - 1);
2678 case EXPR_DESIGNATED_INIT_UPDATE:
2679 S = new (Context) DesignatedInitUpdateExpr(Empty);
2682 case EXPR_IMPLICIT_VALUE_INIT:
2683 S = new (Context) ImplicitValueInitExpr(Empty);
2687 S = new (Context) NoInitExpr(Empty);
2690 case EXPR_ARRAY_INIT_LOOP:
2691 S = new (Context) ArrayInitLoopExpr(Empty);
2694 case EXPR_ARRAY_INIT_INDEX:
2695 S = new (Context) ArrayInitIndexExpr(Empty);
2699 S = new (Context) VAArgExpr(Empty);
2702 case EXPR_SOURCE_LOC:
2703 S = new (Context) SourceLocExpr(Empty);
2706 case EXPR_ADDR_LABEL:
2707 S = new (Context) AddrLabelExpr(Empty);
2711 S = new (Context) StmtExpr(Empty);
2715 S = new (Context) ChooseExpr(Empty);
2719 S = new (Context) GNUNullExpr(Empty);
2722 case EXPR_SHUFFLE_VECTOR:
2723 S = new (Context) ShuffleVectorExpr(Empty);
2726 case EXPR_CONVERT_VECTOR:
2727 S = new (Context) ConvertVectorExpr(Empty);
2731 S = new (Context) BlockExpr(Empty);
2734 case EXPR_GENERIC_SELECTION:
2735 S = GenericSelectionExpr::CreateEmpty(
2737 /*NumAssocs=*/Record[ASTStmtReader::NumExprFields]);
2740 case EXPR_OBJC_STRING_LITERAL:
2741 S = new (Context) ObjCStringLiteral(Empty);
2744 case EXPR_OBJC_BOXED_EXPRESSION:
2745 S = new (Context) ObjCBoxedExpr(Empty);
2748 case EXPR_OBJC_ARRAY_LITERAL:
2749 S = ObjCArrayLiteral::CreateEmpty(Context,
2750 Record[ASTStmtReader::NumExprFields]);
2753 case EXPR_OBJC_DICTIONARY_LITERAL:
2754 S = ObjCDictionaryLiteral::CreateEmpty(Context,
2755 Record[ASTStmtReader::NumExprFields],
2756 Record[ASTStmtReader::NumExprFields + 1]);
2759 case EXPR_OBJC_ENCODE:
2760 S = new (Context) ObjCEncodeExpr(Empty);
2763 case EXPR_OBJC_SELECTOR_EXPR:
2764 S = new (Context) ObjCSelectorExpr(Empty);
2767 case EXPR_OBJC_PROTOCOL_EXPR:
2768 S = new (Context) ObjCProtocolExpr(Empty);
2771 case EXPR_OBJC_IVAR_REF_EXPR:
2772 S = new (Context) ObjCIvarRefExpr(Empty);
2775 case EXPR_OBJC_PROPERTY_REF_EXPR:
2776 S = new (Context) ObjCPropertyRefExpr(Empty);
2779 case EXPR_OBJC_SUBSCRIPT_REF_EXPR:
2780 S = new (Context) ObjCSubscriptRefExpr(Empty);
2783 case EXPR_OBJC_KVC_REF_EXPR:
2784 llvm_unreachable("mismatching AST file");
2786 case EXPR_OBJC_MESSAGE_EXPR:
2787 S = ObjCMessageExpr::CreateEmpty(Context,
2788 Record[ASTStmtReader::NumExprFields],
2789 Record[ASTStmtReader::NumExprFields + 1]);
2793 S = new (Context) ObjCIsaExpr(Empty);
2796 case EXPR_OBJC_INDIRECT_COPY_RESTORE:
2797 S = new (Context) ObjCIndirectCopyRestoreExpr(Empty);
2800 case EXPR_OBJC_BRIDGED_CAST:
2801 S = new (Context) ObjCBridgedCastExpr(Empty);
2804 case STMT_OBJC_FOR_COLLECTION:
2805 S = new (Context) ObjCForCollectionStmt(Empty);
2808 case STMT_OBJC_CATCH:
2809 S = new (Context) ObjCAtCatchStmt(Empty);
2812 case STMT_OBJC_FINALLY:
2813 S = new (Context) ObjCAtFinallyStmt(Empty);
2816 case STMT_OBJC_AT_TRY:
2817 S = ObjCAtTryStmt::CreateEmpty(Context,
2818 Record[ASTStmtReader::NumStmtFields],
2819 Record[ASTStmtReader::NumStmtFields + 1]);
2822 case STMT_OBJC_AT_SYNCHRONIZED:
2823 S = new (Context) ObjCAtSynchronizedStmt(Empty);
2826 case STMT_OBJC_AT_THROW:
2827 S = new (Context) ObjCAtThrowStmt(Empty);
2830 case STMT_OBJC_AUTORELEASE_POOL:
2831 S = new (Context) ObjCAutoreleasePoolStmt(Empty);
2834 case EXPR_OBJC_BOOL_LITERAL:
2835 S = new (Context) ObjCBoolLiteralExpr(Empty);
2838 case EXPR_OBJC_AVAILABILITY_CHECK:
2839 S = new (Context) ObjCAvailabilityCheckExpr(Empty);
2842 case STMT_SEH_LEAVE:
2843 S = new (Context) SEHLeaveStmt(Empty);
2846 case STMT_SEH_EXCEPT:
2847 S = new (Context) SEHExceptStmt(Empty);
2850 case STMT_SEH_FINALLY:
2851 S = new (Context) SEHFinallyStmt(Empty);
2855 S = new (Context) SEHTryStmt(Empty);
2858 case STMT_CXX_CATCH:
2859 S = new (Context) CXXCatchStmt(Empty);
2863 S = CXXTryStmt::Create(Context, Empty,
2864 /*numHandlers=*/Record[ASTStmtReader::NumStmtFields]);
2867 case STMT_CXX_FOR_RANGE:
2868 S = new (Context) CXXForRangeStmt(Empty);
2871 case STMT_MS_DEPENDENT_EXISTS:
2872 S = new (Context) MSDependentExistsStmt(SourceLocation(), true,
2873 NestedNameSpecifierLoc(),
2874 DeclarationNameInfo(),
2878 case STMT_OMP_PARALLEL_DIRECTIVE:
2880 OMPParallelDirective::CreateEmpty(Context,
2881 Record[ASTStmtReader::NumStmtFields],
2885 case STMT_OMP_SIMD_DIRECTIVE: {
2886 unsigned NumClauses = Record[ASTStmtReader::NumStmtFields];
2887 unsigned CollapsedNum = Record[ASTStmtReader::NumStmtFields + 1];
2888 S = OMPSimdDirective::CreateEmpty(Context, NumClauses,
2889 CollapsedNum, Empty);
2893 case STMT_OMP_FOR_DIRECTIVE: {
2894 unsigned NumClauses = Record[ASTStmtReader::NumStmtFields];
2895 unsigned CollapsedNum = Record[ASTStmtReader::NumStmtFields + 1];
2896 S = OMPForDirective::CreateEmpty(Context, NumClauses, CollapsedNum,
2901 case STMT_OMP_FOR_SIMD_DIRECTIVE: {
2902 unsigned NumClauses = Record[ASTStmtReader::NumStmtFields];
2903 unsigned CollapsedNum = Record[ASTStmtReader::NumStmtFields + 1];
2904 S = OMPForSimdDirective::CreateEmpty(Context, NumClauses, CollapsedNum,
2909 case STMT_OMP_SECTIONS_DIRECTIVE:
2910 S = OMPSectionsDirective::CreateEmpty(
2911 Context, Record[ASTStmtReader::NumStmtFields], Empty);
2914 case STMT_OMP_SECTION_DIRECTIVE:
2915 S = OMPSectionDirective::CreateEmpty(Context, Empty);
2918 case STMT_OMP_SINGLE_DIRECTIVE:
2919 S = OMPSingleDirective::CreateEmpty(
2920 Context, Record[ASTStmtReader::NumStmtFields], Empty);
2923 case STMT_OMP_MASTER_DIRECTIVE:
2924 S = OMPMasterDirective::CreateEmpty(Context, Empty);
2927 case STMT_OMP_CRITICAL_DIRECTIVE:
2928 S = OMPCriticalDirective::CreateEmpty(
2929 Context, Record[ASTStmtReader::NumStmtFields], Empty);
2932 case STMT_OMP_PARALLEL_FOR_DIRECTIVE: {
2933 unsigned NumClauses = Record[ASTStmtReader::NumStmtFields];
2934 unsigned CollapsedNum = Record[ASTStmtReader::NumStmtFields + 1];
2935 S = OMPParallelForDirective::CreateEmpty(Context, NumClauses,
2936 CollapsedNum, Empty);
2940 case STMT_OMP_PARALLEL_FOR_SIMD_DIRECTIVE: {
2941 unsigned NumClauses = Record[ASTStmtReader::NumStmtFields];
2942 unsigned CollapsedNum = Record[ASTStmtReader::NumStmtFields + 1];
2943 S = OMPParallelForSimdDirective::CreateEmpty(Context, NumClauses,
2944 CollapsedNum, Empty);
2948 case STMT_OMP_PARALLEL_SECTIONS_DIRECTIVE:
2949 S = OMPParallelSectionsDirective::CreateEmpty(
2950 Context, Record[ASTStmtReader::NumStmtFields], Empty);
2953 case STMT_OMP_TASK_DIRECTIVE:
2954 S = OMPTaskDirective::CreateEmpty(
2955 Context, Record[ASTStmtReader::NumStmtFields], Empty);
2958 case STMT_OMP_TASKYIELD_DIRECTIVE:
2959 S = OMPTaskyieldDirective::CreateEmpty(Context, Empty);
2962 case STMT_OMP_BARRIER_DIRECTIVE:
2963 S = OMPBarrierDirective::CreateEmpty(Context, Empty);
2966 case STMT_OMP_TASKWAIT_DIRECTIVE:
2967 S = OMPTaskwaitDirective::CreateEmpty(Context, Empty);
2970 case STMT_OMP_TASKGROUP_DIRECTIVE:
2971 S = OMPTaskgroupDirective::CreateEmpty(
2972 Context, Record[ASTStmtReader::NumStmtFields], Empty);
2975 case STMT_OMP_FLUSH_DIRECTIVE:
2976 S = OMPFlushDirective::CreateEmpty(
2977 Context, Record[ASTStmtReader::NumStmtFields], Empty);
2980 case STMT_OMP_ORDERED_DIRECTIVE:
2981 S = OMPOrderedDirective::CreateEmpty(
2982 Context, Record[ASTStmtReader::NumStmtFields], Empty);
2985 case STMT_OMP_ATOMIC_DIRECTIVE:
2986 S = OMPAtomicDirective::CreateEmpty(
2987 Context, Record[ASTStmtReader::NumStmtFields], Empty);
2990 case STMT_OMP_TARGET_DIRECTIVE:
2991 S = OMPTargetDirective::CreateEmpty(
2992 Context, Record[ASTStmtReader::NumStmtFields], Empty);
2995 case STMT_OMP_TARGET_DATA_DIRECTIVE:
2996 S = OMPTargetDataDirective::CreateEmpty(
2997 Context, Record[ASTStmtReader::NumStmtFields], Empty);
3000 case STMT_OMP_TARGET_ENTER_DATA_DIRECTIVE:
3001 S = OMPTargetEnterDataDirective::CreateEmpty(
3002 Context, Record[ASTStmtReader::NumStmtFields], Empty);
3005 case STMT_OMP_TARGET_EXIT_DATA_DIRECTIVE:
3006 S = OMPTargetExitDataDirective::CreateEmpty(
3007 Context, Record[ASTStmtReader::NumStmtFields], Empty);
3010 case STMT_OMP_TARGET_PARALLEL_DIRECTIVE:
3011 S = OMPTargetParallelDirective::CreateEmpty(
3012 Context, Record[ASTStmtReader::NumStmtFields], Empty);
3015 case STMT_OMP_TARGET_PARALLEL_FOR_DIRECTIVE: {
3016 unsigned NumClauses = Record[ASTStmtReader::NumStmtFields];
3017 unsigned CollapsedNum = Record[ASTStmtReader::NumStmtFields + 1];
3018 S = OMPTargetParallelForDirective::CreateEmpty(Context, NumClauses,
3019 CollapsedNum, Empty);
3023 case STMT_OMP_TARGET_UPDATE_DIRECTIVE:
3024 S = OMPTargetUpdateDirective::CreateEmpty(
3025 Context, Record[ASTStmtReader::NumStmtFields], Empty);
3028 case STMT_OMP_TEAMS_DIRECTIVE:
3029 S = OMPTeamsDirective::CreateEmpty(
3030 Context, Record[ASTStmtReader::NumStmtFields], Empty);
3033 case STMT_OMP_CANCELLATION_POINT_DIRECTIVE:
3034 S = OMPCancellationPointDirective::CreateEmpty(Context, Empty);
3037 case STMT_OMP_CANCEL_DIRECTIVE:
3038 S = OMPCancelDirective::CreateEmpty(
3039 Context, Record[ASTStmtReader::NumStmtFields], Empty);
3042 case STMT_OMP_TASKLOOP_DIRECTIVE: {
3043 unsigned NumClauses = Record[ASTStmtReader::NumStmtFields];
3044 unsigned CollapsedNum = Record[ASTStmtReader::NumStmtFields + 1];
3045 S = OMPTaskLoopDirective::CreateEmpty(Context, NumClauses, CollapsedNum,
3050 case STMT_OMP_TASKLOOP_SIMD_DIRECTIVE: {
3051 unsigned NumClauses = Record[ASTStmtReader::NumStmtFields];
3052 unsigned CollapsedNum = Record[ASTStmtReader::NumStmtFields + 1];
3053 S = OMPTaskLoopSimdDirective::CreateEmpty(Context, NumClauses,
3054 CollapsedNum, Empty);
3058 case STMT_OMP_DISTRIBUTE_DIRECTIVE: {
3059 unsigned NumClauses = Record[ASTStmtReader::NumStmtFields];
3060 unsigned CollapsedNum = Record[ASTStmtReader::NumStmtFields + 1];
3061 S = OMPDistributeDirective::CreateEmpty(Context, NumClauses, CollapsedNum,
3066 case STMT_OMP_DISTRIBUTE_PARALLEL_FOR_DIRECTIVE: {
3067 unsigned NumClauses = Record[ASTStmtReader::NumStmtFields];
3068 unsigned CollapsedNum = Record[ASTStmtReader::NumStmtFields + 1];
3069 S = OMPDistributeParallelForDirective::CreateEmpty(Context, NumClauses,
3070 CollapsedNum, Empty);
3074 case STMT_OMP_DISTRIBUTE_PARALLEL_FOR_SIMD_DIRECTIVE: {
3075 unsigned NumClauses = Record[ASTStmtReader::NumStmtFields];
3076 unsigned CollapsedNum = Record[ASTStmtReader::NumStmtFields + 1];
3077 S = OMPDistributeParallelForSimdDirective::CreateEmpty(Context, NumClauses,
3083 case STMT_OMP_DISTRIBUTE_SIMD_DIRECTIVE: {
3084 unsigned NumClauses = Record[ASTStmtReader::NumStmtFields];
3085 unsigned CollapsedNum = Record[ASTStmtReader::NumStmtFields + 1];
3086 S = OMPDistributeSimdDirective::CreateEmpty(Context, NumClauses,
3087 CollapsedNum, Empty);
3091 case STMT_OMP_TARGET_PARALLEL_FOR_SIMD_DIRECTIVE: {
3092 unsigned NumClauses = Record[ASTStmtReader::NumStmtFields];
3093 unsigned CollapsedNum = Record[ASTStmtReader::NumStmtFields + 1];
3094 S = OMPTargetParallelForSimdDirective::CreateEmpty(Context, NumClauses,
3095 CollapsedNum, Empty);
3099 case STMT_OMP_TARGET_SIMD_DIRECTIVE: {
3100 auto NumClauses = Record[ASTStmtReader::NumStmtFields];
3101 auto CollapsedNum = Record[ASTStmtReader::NumStmtFields + 1];
3102 S = OMPTargetSimdDirective::CreateEmpty(Context, NumClauses, CollapsedNum,
3107 case STMT_OMP_TEAMS_DISTRIBUTE_DIRECTIVE: {
3108 auto NumClauses = Record[ASTStmtReader::NumStmtFields];
3109 auto CollapsedNum = Record[ASTStmtReader::NumStmtFields + 1];
3110 S = OMPTeamsDistributeDirective::CreateEmpty(Context, NumClauses,
3111 CollapsedNum, Empty);
3115 case STMT_OMP_TEAMS_DISTRIBUTE_SIMD_DIRECTIVE: {
3116 unsigned NumClauses = Record[ASTStmtReader::NumStmtFields];
3117 unsigned CollapsedNum = Record[ASTStmtReader::NumStmtFields + 1];
3118 S = OMPTeamsDistributeSimdDirective::CreateEmpty(Context, NumClauses,
3119 CollapsedNum, Empty);
3123 case STMT_OMP_TEAMS_DISTRIBUTE_PARALLEL_FOR_SIMD_DIRECTIVE: {
3124 auto NumClauses = Record[ASTStmtReader::NumStmtFields];
3125 auto CollapsedNum = Record[ASTStmtReader::NumStmtFields + 1];
3126 S = OMPTeamsDistributeParallelForSimdDirective::CreateEmpty(
3127 Context, NumClauses, CollapsedNum, Empty);
3131 case STMT_OMP_TEAMS_DISTRIBUTE_PARALLEL_FOR_DIRECTIVE: {
3132 auto NumClauses = Record[ASTStmtReader::NumStmtFields];
3133 auto CollapsedNum = Record[ASTStmtReader::NumStmtFields + 1];
3134 S = OMPTeamsDistributeParallelForDirective::CreateEmpty(
3135 Context, NumClauses, CollapsedNum, Empty);
3139 case STMT_OMP_TARGET_TEAMS_DIRECTIVE:
3140 S = OMPTargetTeamsDirective::CreateEmpty(
3141 Context, Record[ASTStmtReader::NumStmtFields], Empty);
3144 case STMT_OMP_TARGET_TEAMS_DISTRIBUTE_DIRECTIVE: {
3145 auto NumClauses = Record[ASTStmtReader::NumStmtFields];
3146 auto CollapsedNum = Record[ASTStmtReader::NumStmtFields + 1];
3147 S = OMPTargetTeamsDistributeDirective::CreateEmpty(Context, NumClauses,
3148 CollapsedNum, Empty);
3152 case STMT_OMP_TARGET_TEAMS_DISTRIBUTE_PARALLEL_FOR_DIRECTIVE: {
3153 auto NumClauses = Record[ASTStmtReader::NumStmtFields];
3154 auto CollapsedNum = Record[ASTStmtReader::NumStmtFields + 1];
3155 S = OMPTargetTeamsDistributeParallelForDirective::CreateEmpty(
3156 Context, NumClauses, CollapsedNum, Empty);
3160 case STMT_OMP_TARGET_TEAMS_DISTRIBUTE_PARALLEL_FOR_SIMD_DIRECTIVE: {
3161 auto NumClauses = Record[ASTStmtReader::NumStmtFields];
3162 auto CollapsedNum = Record[ASTStmtReader::NumStmtFields + 1];
3163 S = OMPTargetTeamsDistributeParallelForSimdDirective::CreateEmpty(
3164 Context, NumClauses, CollapsedNum, Empty);
3168 case STMT_OMP_TARGET_TEAMS_DISTRIBUTE_SIMD_DIRECTIVE: {
3169 auto NumClauses = Record[ASTStmtReader::NumStmtFields];
3170 auto CollapsedNum = Record[ASTStmtReader::NumStmtFields + 1];
3171 S = OMPTargetTeamsDistributeSimdDirective::CreateEmpty(
3172 Context, NumClauses, CollapsedNum, Empty);
3176 case EXPR_CXX_OPERATOR_CALL:
3177 S = CXXOperatorCallExpr::CreateEmpty(
3178 Context, /*NumArgs=*/Record[ASTStmtReader::NumExprFields], Empty);
3181 case EXPR_CXX_MEMBER_CALL:
3182 S = CXXMemberCallExpr::CreateEmpty(
3183 Context, /*NumArgs=*/Record[ASTStmtReader::NumExprFields], Empty);
3186 case EXPR_CXX_CONSTRUCT:
3187 S = CXXConstructExpr::CreateEmpty(
3189 /* NumArgs=*/Record[ASTStmtReader::NumExprFields]);
3192 case EXPR_CXX_INHERITED_CTOR_INIT:
3193 S = new (Context) CXXInheritedCtorInitExpr(Empty);
3196 case EXPR_CXX_TEMPORARY_OBJECT:
3197 S = CXXTemporaryObjectExpr::CreateEmpty(
3199 /* NumArgs=*/Record[ASTStmtReader::NumExprFields]);
3202 case EXPR_CXX_STATIC_CAST:
3203 S = CXXStaticCastExpr::CreateEmpty(Context,
3204 /*PathSize*/ Record[ASTStmtReader::NumExprFields]);
3207 case EXPR_CXX_DYNAMIC_CAST:
3208 S = CXXDynamicCastExpr::CreateEmpty(Context,
3209 /*PathSize*/ Record[ASTStmtReader::NumExprFields]);
3212 case EXPR_CXX_REINTERPRET_CAST:
3213 S = CXXReinterpretCastExpr::CreateEmpty(Context,
3214 /*PathSize*/ Record[ASTStmtReader::NumExprFields]);
3217 case EXPR_CXX_CONST_CAST:
3218 S = CXXConstCastExpr::CreateEmpty(Context);
3221 case EXPR_CXX_FUNCTIONAL_CAST:
3222 S = CXXFunctionalCastExpr::CreateEmpty(Context,
3223 /*PathSize*/ Record[ASTStmtReader::NumExprFields]);
3226 case EXPR_USER_DEFINED_LITERAL:
3227 S = UserDefinedLiteral::CreateEmpty(
3228 Context, /*NumArgs=*/Record[ASTStmtReader::NumExprFields], Empty);
3231 case EXPR_CXX_STD_INITIALIZER_LIST:
3232 S = new (Context) CXXStdInitializerListExpr(Empty);
3235 case EXPR_CXX_BOOL_LITERAL:
3236 S = new (Context) CXXBoolLiteralExpr(Empty);
3239 case EXPR_CXX_NULL_PTR_LITERAL:
3240 S = new (Context) CXXNullPtrLiteralExpr(Empty);
3243 case EXPR_CXX_TYPEID_EXPR:
3244 S = new (Context) CXXTypeidExpr(Empty, true);
3247 case EXPR_CXX_TYPEID_TYPE:
3248 S = new (Context) CXXTypeidExpr(Empty, false);
3251 case EXPR_CXX_UUIDOF_EXPR:
3252 S = new (Context) CXXUuidofExpr(Empty, true);
3255 case EXPR_CXX_PROPERTY_REF_EXPR:
3256 S = new (Context) MSPropertyRefExpr(Empty);
3259 case EXPR_CXX_PROPERTY_SUBSCRIPT_EXPR:
3260 S = new (Context) MSPropertySubscriptExpr(Empty);
3263 case EXPR_CXX_UUIDOF_TYPE:
3264 S = new (Context) CXXUuidofExpr(Empty, false);
3268 S = new (Context) CXXThisExpr(Empty);
3271 case EXPR_CXX_THROW:
3272 S = new (Context) CXXThrowExpr(Empty);
3275 case EXPR_CXX_DEFAULT_ARG:
3276 S = new (Context) CXXDefaultArgExpr(Empty);
3279 case EXPR_CXX_DEFAULT_INIT:
3280 S = new (Context) CXXDefaultInitExpr(Empty);
3283 case EXPR_CXX_BIND_TEMPORARY:
3284 S = new (Context) CXXBindTemporaryExpr(Empty);
3287 case EXPR_CXX_SCALAR_VALUE_INIT:
3288 S = new (Context) CXXScalarValueInitExpr(Empty);
3292 S = CXXNewExpr::CreateEmpty(
3294 /*IsArray=*/Record[ASTStmtReader::NumExprFields],
3295 /*HasInit=*/Record[ASTStmtReader::NumExprFields + 1],
3296 /*NumPlacementArgs=*/Record[ASTStmtReader::NumExprFields + 2],
3297 /*IsParenTypeId=*/Record[ASTStmtReader::NumExprFields + 3]);
3300 case EXPR_CXX_DELETE:
3301 S = new (Context) CXXDeleteExpr(Empty);
3304 case EXPR_CXX_PSEUDO_DESTRUCTOR:
3305 S = new (Context) CXXPseudoDestructorExpr(Empty);
3308 case EXPR_EXPR_WITH_CLEANUPS:
3309 S = ExprWithCleanups::Create(Context, Empty,
3310 Record[ASTStmtReader::NumExprFields]);
3313 case EXPR_CXX_DEPENDENT_SCOPE_MEMBER:
3314 S = CXXDependentScopeMemberExpr::CreateEmpty(
3316 /*HasTemplateKWAndArgsInfo=*/Record[ASTStmtReader::NumExprFields],
3317 /*NumTemplateArgs=*/Record[ASTStmtReader::NumExprFields + 1],
3318 /*HasFirstQualifierFoundInScope=*/
3319 Record[ASTStmtReader::NumExprFields + 2]);
3322 case EXPR_CXX_DEPENDENT_SCOPE_DECL_REF:
3323 S = DependentScopeDeclRefExpr::CreateEmpty(Context,
3324 /*HasTemplateKWAndArgsInfo=*/Record[ASTStmtReader::NumExprFields],
3325 /*NumTemplateArgs=*/Record[ASTStmtReader::NumExprFields]
3326 ? Record[ASTStmtReader::NumExprFields + 1]
3330 case EXPR_CXX_UNRESOLVED_CONSTRUCT:
3331 S = CXXUnresolvedConstructExpr::CreateEmpty(Context,
3332 /*NumArgs=*/Record[ASTStmtReader::NumExprFields]);
3335 case EXPR_CXX_UNRESOLVED_MEMBER:
3336 S = UnresolvedMemberExpr::CreateEmpty(
3338 /*NumResults=*/Record[ASTStmtReader::NumExprFields],
3339 /*HasTemplateKWAndArgsInfo=*/Record[ASTStmtReader::NumExprFields + 1],
3340 /*NumTemplateArgs=*/
3341 Record[ASTStmtReader::NumExprFields + 1]
3342 ? Record[ASTStmtReader::NumExprFields + 2]
3346 case EXPR_CXX_UNRESOLVED_LOOKUP:
3347 S = UnresolvedLookupExpr::CreateEmpty(
3349 /*NumResults=*/Record[ASTStmtReader::NumExprFields],
3350 /*HasTemplateKWAndArgsInfo=*/Record[ASTStmtReader::NumExprFields + 1],
3351 /*NumTemplateArgs=*/
3352 Record[ASTStmtReader::NumExprFields + 1]
3353 ? Record[ASTStmtReader::NumExprFields + 2]
3357 case EXPR_TYPE_TRAIT:
3358 S = TypeTraitExpr::CreateDeserialized(Context,
3359 Record[ASTStmtReader::NumExprFields]);
3362 case EXPR_ARRAY_TYPE_TRAIT:
3363 S = new (Context) ArrayTypeTraitExpr(Empty);
3366 case EXPR_CXX_EXPRESSION_TRAIT:
3367 S = new (Context) ExpressionTraitExpr(Empty);
3370 case EXPR_CXX_NOEXCEPT:
3371 S = new (Context) CXXNoexceptExpr(Empty);
3374 case EXPR_PACK_EXPANSION:
3375 S = new (Context) PackExpansionExpr(Empty);
3378 case EXPR_SIZEOF_PACK:
3379 S = SizeOfPackExpr::CreateDeserialized(
3381 /*NumPartialArgs=*/Record[ASTStmtReader::NumExprFields]);
3384 case EXPR_SUBST_NON_TYPE_TEMPLATE_PARM:
3385 S = new (Context) SubstNonTypeTemplateParmExpr(Empty);
3388 case EXPR_SUBST_NON_TYPE_TEMPLATE_PARM_PACK:
3389 S = new (Context) SubstNonTypeTemplateParmPackExpr(Empty);
3392 case EXPR_FUNCTION_PARM_PACK:
3393 S = FunctionParmPackExpr::CreateEmpty(Context,
3394 Record[ASTStmtReader::NumExprFields]);
3397 case EXPR_MATERIALIZE_TEMPORARY:
3398 S = new (Context) MaterializeTemporaryExpr(Empty);
3402 S = new (Context) CXXFoldExpr(Empty);
3405 case EXPR_OPAQUE_VALUE:
3406 S = new (Context) OpaqueValueExpr(Empty);
3409 case EXPR_CUDA_KERNEL_CALL:
3410 S = CUDAKernelCallExpr::CreateEmpty(
3411 Context, /*NumArgs=*/Record[ASTStmtReader::NumExprFields], Empty);
3415 S = new (Context) AsTypeExpr(Empty);
3418 case EXPR_PSEUDO_OBJECT: {
3419 unsigned numSemanticExprs = Record[ASTStmtReader::NumExprFields];
3420 S = PseudoObjectExpr::Create(Context, Empty, numSemanticExprs);
3425 S = new (Context) AtomicExpr(Empty);
3429 unsigned NumCaptures = Record[ASTStmtReader::NumExprFields];
3430 S = LambdaExpr::CreateDeserialized(Context, NumCaptures);
3434 case STMT_COROUTINE_BODY: {
3435 unsigned NumParams = Record[ASTStmtReader::NumStmtFields];
3436 S = CoroutineBodyStmt::Create(Context, Empty, NumParams);
3441 S = new (Context) CoreturnStmt(Empty);
3445 S = new (Context) CoawaitExpr(Empty);
3449 S = new (Context) CoyieldExpr(Empty);
3452 case EXPR_DEPENDENT_COAWAIT:
3453 S = new (Context) DependentCoawaitExpr(Empty);
3457 // We hit a STMT_STOP, so we're done with this expression.
3461 ++NumStatementsRead;
3463 if (S && !IsStmtReference) {
3465 StmtEntries[Cursor.GetCurrentBitNo()] = S;
3468 assert(Record.getIdx() == Record.size() &&
3469 "Invalid deserialization of statement");
3470 StmtStack.push_back(S);
3473 assert(StmtStack.size() > PrevNumStmts && "Read too many sub-stmts!");
3474 assert(StmtStack.size() == PrevNumStmts + 1 && "Extra expressions on stack!");
3475 return StmtStack.pop_back_val();