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/ASTRecordReader.h"
15 #include "clang/AST/ASTConcept.h"
16 #include "clang/AST/ASTContext.h"
17 #include "clang/AST/AttrIterator.h"
18 #include "clang/AST/Decl.h"
19 #include "clang/AST/DeclAccessPair.h"
20 #include "clang/AST/DeclCXX.h"
21 #include "clang/AST/DeclGroup.h"
22 #include "clang/AST/DeclObjC.h"
23 #include "clang/AST/DeclTemplate.h"
24 #include "clang/AST/DeclarationName.h"
25 #include "clang/AST/Expr.h"
26 #include "clang/AST/ExprCXX.h"
27 #include "clang/AST/ExprObjC.h"
28 #include "clang/AST/ExprOpenMP.h"
29 #include "clang/AST/NestedNameSpecifier.h"
30 #include "clang/AST/OpenMPClause.h"
31 #include "clang/AST/OperationKinds.h"
32 #include "clang/AST/Stmt.h"
33 #include "clang/AST/StmtCXX.h"
34 #include "clang/AST/StmtObjC.h"
35 #include "clang/AST/StmtOpenMP.h"
36 #include "clang/AST/StmtVisitor.h"
37 #include "clang/AST/TemplateBase.h"
38 #include "clang/AST/Type.h"
39 #include "clang/AST/UnresolvedSet.h"
40 #include "clang/Basic/CapturedStmt.h"
41 #include "clang/Basic/ExpressionTraits.h"
42 #include "clang/Basic/LLVM.h"
43 #include "clang/Basic/Lambda.h"
44 #include "clang/Basic/LangOptions.h"
45 #include "clang/Basic/OpenMPKinds.h"
46 #include "clang/Basic/OperatorKinds.h"
47 #include "clang/Basic/SourceLocation.h"
48 #include "clang/Basic/Specifiers.h"
49 #include "clang/Basic/TypeTraits.h"
50 #include "clang/Lex/Token.h"
51 #include "clang/Serialization/ASTBitCodes.h"
52 #include "llvm/ADT/DenseMap.h"
53 #include "llvm/ADT/SmallString.h"
54 #include "llvm/ADT/SmallVector.h"
55 #include "llvm/ADT/StringRef.h"
56 #include "llvm/Bitstream/BitstreamReader.h"
57 #include "llvm/Support/Casting.h"
58 #include "llvm/Support/ErrorHandling.h"
64 using namespace clang;
65 using namespace serialization;
69 class ASTStmtReader : public StmtVisitor<ASTStmtReader> {
70 ASTRecordReader &Record;
71 llvm::BitstreamCursor &DeclsCursor;
73 SourceLocation readSourceLocation() {
74 return Record.readSourceLocation();
77 SourceRange readSourceRange() {
78 return Record.readSourceRange();
81 std::string readString() {
82 return Record.readString();
85 TypeSourceInfo *readTypeSourceInfo() {
86 return Record.readTypeSourceInfo();
90 return Record.readDecl();
95 return Record.readDeclAs<T>();
99 ASTStmtReader(ASTRecordReader &Record, llvm::BitstreamCursor &Cursor)
100 : Record(Record), DeclsCursor(Cursor) {}
102 /// The number of record fields required for the Stmt class
104 static const unsigned NumStmtFields = 1;
106 /// The number of record fields required for the Expr class
108 static const unsigned NumExprFields = NumStmtFields + 7;
110 /// Read and initialize a ExplicitTemplateArgumentList structure.
111 void ReadTemplateKWAndArgsInfo(ASTTemplateKWAndArgsInfo &Args,
112 TemplateArgumentLoc *ArgsLocArray,
113 unsigned NumTemplateArgs);
115 /// Read and initialize a ExplicitTemplateArgumentList structure.
116 void ReadExplicitTemplateArgumentList(ASTTemplateArgumentListInfo &ArgList,
117 unsigned NumTemplateArgs);
119 void VisitStmt(Stmt *S);
120 #define STMT(Type, Base) \
121 void Visit##Type(Type *);
122 #include "clang/AST/StmtNodes.inc"
127 void ASTStmtReader::ReadTemplateKWAndArgsInfo(ASTTemplateKWAndArgsInfo &Args,
128 TemplateArgumentLoc *ArgsLocArray,
129 unsigned NumTemplateArgs) {
130 SourceLocation TemplateKWLoc = readSourceLocation();
131 TemplateArgumentListInfo ArgInfo;
132 ArgInfo.setLAngleLoc(readSourceLocation());
133 ArgInfo.setRAngleLoc(readSourceLocation());
134 for (unsigned i = 0; i != NumTemplateArgs; ++i)
135 ArgInfo.addArgument(Record.readTemplateArgumentLoc());
136 Args.initializeFrom(TemplateKWLoc, ArgInfo, ArgsLocArray);
139 void ASTStmtReader::VisitStmt(Stmt *S) {
140 S->setIsOMPStructuredBlock(Record.readInt());
141 assert(Record.getIdx() == NumStmtFields && "Incorrect statement field count");
144 void ASTStmtReader::VisitNullStmt(NullStmt *S) {
146 S->setSemiLoc(readSourceLocation());
147 S->NullStmtBits.HasLeadingEmptyMacro = Record.readInt();
150 void ASTStmtReader::VisitCompoundStmt(CompoundStmt *S) {
152 SmallVector<Stmt *, 16> Stmts;
153 unsigned NumStmts = Record.readInt();
155 Stmts.push_back(Record.readSubStmt());
157 S->CompoundStmtBits.LBraceLoc = readSourceLocation();
158 S->RBraceLoc = readSourceLocation();
161 void ASTStmtReader::VisitSwitchCase(SwitchCase *S) {
163 Record.recordSwitchCaseID(S, Record.readInt());
164 S->setKeywordLoc(readSourceLocation());
165 S->setColonLoc(readSourceLocation());
168 void ASTStmtReader::VisitCaseStmt(CaseStmt *S) {
170 bool CaseStmtIsGNURange = Record.readInt();
171 S->setLHS(Record.readSubExpr());
172 S->setSubStmt(Record.readSubStmt());
173 if (CaseStmtIsGNURange) {
174 S->setRHS(Record.readSubExpr());
175 S->setEllipsisLoc(readSourceLocation());
179 void ASTStmtReader::VisitDefaultStmt(DefaultStmt *S) {
181 S->setSubStmt(Record.readSubStmt());
184 void ASTStmtReader::VisitLabelStmt(LabelStmt *S) {
186 auto *LD = readDeclAs<LabelDecl>();
189 S->setSubStmt(Record.readSubStmt());
190 S->setIdentLoc(readSourceLocation());
193 void ASTStmtReader::VisitAttributedStmt(AttributedStmt *S) {
195 // NumAttrs in AttributedStmt is set when creating an empty
196 // AttributedStmt in AttributedStmt::CreateEmpty, since it is needed
197 // to allocate the right amount of space for the trailing Attr *.
198 uint64_t NumAttrs = Record.readInt();
200 Record.readAttributes(Attrs);
202 assert(NumAttrs == S->AttributedStmtBits.NumAttrs);
203 assert(NumAttrs == Attrs.size());
204 std::copy(Attrs.begin(), Attrs.end(), S->getAttrArrayPtr());
205 S->SubStmt = Record.readSubStmt();
206 S->AttributedStmtBits.AttrLoc = readSourceLocation();
209 void ASTStmtReader::VisitIfStmt(IfStmt *S) {
212 S->setConstexpr(Record.readInt());
213 bool HasElse = Record.readInt();
214 bool HasVar = Record.readInt();
215 bool HasInit = Record.readInt();
217 S->setCond(Record.readSubExpr());
218 S->setThen(Record.readSubStmt());
220 S->setElse(Record.readSubStmt());
222 S->setConditionVariable(Record.getContext(), readDeclAs<VarDecl>());
224 S->setInit(Record.readSubStmt());
226 S->setIfLoc(readSourceLocation());
228 S->setElseLoc(readSourceLocation());
231 void ASTStmtReader::VisitSwitchStmt(SwitchStmt *S) {
234 bool HasInit = Record.readInt();
235 bool HasVar = Record.readInt();
236 bool AllEnumCasesCovered = Record.readInt();
237 if (AllEnumCasesCovered)
238 S->setAllEnumCasesCovered();
240 S->setCond(Record.readSubExpr());
241 S->setBody(Record.readSubStmt());
243 S->setInit(Record.readSubStmt());
245 S->setConditionVariable(Record.getContext(), readDeclAs<VarDecl>());
247 S->setSwitchLoc(readSourceLocation());
249 SwitchCase *PrevSC = nullptr;
250 for (auto E = Record.size(); Record.getIdx() != E; ) {
251 SwitchCase *SC = Record.getSwitchCaseWithID(Record.readInt());
253 PrevSC->setNextSwitchCase(SC);
255 S->setSwitchCaseList(SC);
261 void ASTStmtReader::VisitWhileStmt(WhileStmt *S) {
264 bool HasVar = Record.readInt();
266 S->setCond(Record.readSubExpr());
267 S->setBody(Record.readSubStmt());
269 S->setConditionVariable(Record.getContext(), readDeclAs<VarDecl>());
271 S->setWhileLoc(readSourceLocation());
274 void ASTStmtReader::VisitDoStmt(DoStmt *S) {
276 S->setCond(Record.readSubExpr());
277 S->setBody(Record.readSubStmt());
278 S->setDoLoc(readSourceLocation());
279 S->setWhileLoc(readSourceLocation());
280 S->setRParenLoc(readSourceLocation());
283 void ASTStmtReader::VisitForStmt(ForStmt *S) {
285 S->setInit(Record.readSubStmt());
286 S->setCond(Record.readSubExpr());
287 S->setConditionVariable(Record.getContext(), readDeclAs<VarDecl>());
288 S->setInc(Record.readSubExpr());
289 S->setBody(Record.readSubStmt());
290 S->setForLoc(readSourceLocation());
291 S->setLParenLoc(readSourceLocation());
292 S->setRParenLoc(readSourceLocation());
295 void ASTStmtReader::VisitGotoStmt(GotoStmt *S) {
297 S->setLabel(readDeclAs<LabelDecl>());
298 S->setGotoLoc(readSourceLocation());
299 S->setLabelLoc(readSourceLocation());
302 void ASTStmtReader::VisitIndirectGotoStmt(IndirectGotoStmt *S) {
304 S->setGotoLoc(readSourceLocation());
305 S->setStarLoc(readSourceLocation());
306 S->setTarget(Record.readSubExpr());
309 void ASTStmtReader::VisitContinueStmt(ContinueStmt *S) {
311 S->setContinueLoc(readSourceLocation());
314 void ASTStmtReader::VisitBreakStmt(BreakStmt *S) {
316 S->setBreakLoc(readSourceLocation());
319 void ASTStmtReader::VisitReturnStmt(ReturnStmt *S) {
322 bool HasNRVOCandidate = Record.readInt();
324 S->setRetValue(Record.readSubExpr());
325 if (HasNRVOCandidate)
326 S->setNRVOCandidate(readDeclAs<VarDecl>());
328 S->setReturnLoc(readSourceLocation());
331 void ASTStmtReader::VisitDeclStmt(DeclStmt *S) {
333 S->setStartLoc(readSourceLocation());
334 S->setEndLoc(readSourceLocation());
336 if (Record.size() - Record.getIdx() == 1) {
337 // Single declaration
338 S->setDeclGroup(DeclGroupRef(readDecl()));
340 SmallVector<Decl *, 16> Decls;
341 int N = Record.size() - Record.getIdx();
343 for (int I = 0; I < N; ++I)
344 Decls.push_back(readDecl());
345 S->setDeclGroup(DeclGroupRef(DeclGroup::Create(Record.getContext(),
351 void ASTStmtReader::VisitAsmStmt(AsmStmt *S) {
353 S->NumOutputs = Record.readInt();
354 S->NumInputs = Record.readInt();
355 S->NumClobbers = Record.readInt();
356 S->setAsmLoc(readSourceLocation());
357 S->setVolatile(Record.readInt());
358 S->setSimple(Record.readInt());
361 void ASTStmtReader::VisitGCCAsmStmt(GCCAsmStmt *S) {
363 S->NumLabels = Record.readInt();
364 S->setRParenLoc(readSourceLocation());
365 S->setAsmString(cast_or_null<StringLiteral>(Record.readSubStmt()));
367 unsigned NumOutputs = S->getNumOutputs();
368 unsigned NumInputs = S->getNumInputs();
369 unsigned NumClobbers = S->getNumClobbers();
370 unsigned NumLabels = S->getNumLabels();
372 // Outputs and inputs
373 SmallVector<IdentifierInfo *, 16> Names;
374 SmallVector<StringLiteral*, 16> Constraints;
375 SmallVector<Stmt*, 16> Exprs;
376 for (unsigned I = 0, N = NumOutputs + NumInputs; I != N; ++I) {
377 Names.push_back(Record.readIdentifier());
378 Constraints.push_back(cast_or_null<StringLiteral>(Record.readSubStmt()));
379 Exprs.push_back(Record.readSubStmt());
383 SmallVector<StringLiteral*, 16> Clobbers;
384 for (unsigned I = 0; I != NumClobbers; ++I)
385 Clobbers.push_back(cast_or_null<StringLiteral>(Record.readSubStmt()));
388 for (unsigned I = 0, N = NumLabels; I != N; ++I)
389 Exprs.push_back(Record.readSubStmt());
391 S->setOutputsAndInputsAndClobbers(Record.getContext(),
392 Names.data(), Constraints.data(),
393 Exprs.data(), NumOutputs, NumInputs,
395 Clobbers.data(), NumClobbers);
398 void ASTStmtReader::VisitMSAsmStmt(MSAsmStmt *S) {
400 S->LBraceLoc = readSourceLocation();
401 S->EndLoc = readSourceLocation();
402 S->NumAsmToks = Record.readInt();
403 std::string AsmStr = readString();
406 SmallVector<Token, 16> AsmToks;
407 AsmToks.reserve(S->NumAsmToks);
408 for (unsigned i = 0, e = S->NumAsmToks; i != e; ++i) {
409 AsmToks.push_back(Record.readToken());
412 // The calls to reserve() for the FooData vectors are mandatory to
413 // prevent dead StringRefs in the Foo vectors.
415 // Read the clobbers.
416 SmallVector<std::string, 16> ClobbersData;
417 SmallVector<StringRef, 16> Clobbers;
418 ClobbersData.reserve(S->NumClobbers);
419 Clobbers.reserve(S->NumClobbers);
420 for (unsigned i = 0, e = S->NumClobbers; i != e; ++i) {
421 ClobbersData.push_back(readString());
422 Clobbers.push_back(ClobbersData.back());
425 // Read the operands.
426 unsigned NumOperands = S->NumOutputs + S->NumInputs;
427 SmallVector<Expr*, 16> Exprs;
428 SmallVector<std::string, 16> ConstraintsData;
429 SmallVector<StringRef, 16> Constraints;
430 Exprs.reserve(NumOperands);
431 ConstraintsData.reserve(NumOperands);
432 Constraints.reserve(NumOperands);
433 for (unsigned i = 0; i != NumOperands; ++i) {
434 Exprs.push_back(cast<Expr>(Record.readSubStmt()));
435 ConstraintsData.push_back(readString());
436 Constraints.push_back(ConstraintsData.back());
439 S->initialize(Record.getContext(), AsmStr, AsmToks,
440 Constraints, Exprs, Clobbers);
443 void ASTStmtReader::VisitCoroutineBodyStmt(CoroutineBodyStmt *S) {
445 assert(Record.peekInt() == S->NumParams);
447 auto *StoredStmts = S->getStoredStmts();
449 i < CoroutineBodyStmt::SubStmt::FirstParamMove + S->NumParams; ++i)
450 StoredStmts[i] = Record.readSubStmt();
453 void ASTStmtReader::VisitCoreturnStmt(CoreturnStmt *S) {
455 S->CoreturnLoc = Record.readSourceLocation();
456 for (auto &SubStmt: S->SubStmts)
457 SubStmt = Record.readSubStmt();
458 S->IsImplicit = Record.readInt() != 0;
461 void ASTStmtReader::VisitCoawaitExpr(CoawaitExpr *E) {
463 E->KeywordLoc = readSourceLocation();
464 for (auto &SubExpr: E->SubExprs)
465 SubExpr = Record.readSubStmt();
466 E->OpaqueValue = cast_or_null<OpaqueValueExpr>(Record.readSubStmt());
467 E->setIsImplicit(Record.readInt() != 0);
470 void ASTStmtReader::VisitCoyieldExpr(CoyieldExpr *E) {
472 E->KeywordLoc = readSourceLocation();
473 for (auto &SubExpr: E->SubExprs)
474 SubExpr = Record.readSubStmt();
475 E->OpaqueValue = cast_or_null<OpaqueValueExpr>(Record.readSubStmt());
478 void ASTStmtReader::VisitDependentCoawaitExpr(DependentCoawaitExpr *E) {
480 E->KeywordLoc = readSourceLocation();
481 for (auto &SubExpr: E->SubExprs)
482 SubExpr = Record.readSubStmt();
485 void ASTStmtReader::VisitCapturedStmt(CapturedStmt *S) {
488 S->setCapturedDecl(readDeclAs<CapturedDecl>());
489 S->setCapturedRegionKind(static_cast<CapturedRegionKind>(Record.readInt()));
490 S->setCapturedRecordDecl(readDeclAs<RecordDecl>());
493 for (CapturedStmt::capture_init_iterator I = S->capture_init_begin(),
494 E = S->capture_init_end();
496 *I = Record.readSubExpr();
499 S->setCapturedStmt(Record.readSubStmt());
500 S->getCapturedDecl()->setBody(S->getCapturedStmt());
503 for (auto &I : S->captures()) {
504 I.VarAndKind.setPointer(readDeclAs<VarDecl>());
506 static_cast<CapturedStmt::VariableCaptureKind>(Record.readInt()));
507 I.Loc = readSourceLocation();
511 void ASTStmtReader::VisitExpr(Expr *E) {
513 E->setType(Record.readType());
514 E->setTypeDependent(Record.readInt());
515 E->setValueDependent(Record.readInt());
516 E->setInstantiationDependent(Record.readInt());
517 E->ExprBits.ContainsUnexpandedParameterPack = Record.readInt();
518 E->setValueKind(static_cast<ExprValueKind>(Record.readInt()));
519 E->setObjectKind(static_cast<ExprObjectKind>(Record.readInt()));
520 assert(Record.getIdx() == NumExprFields &&
521 "Incorrect expression field count");
524 void ASTStmtReader::VisitConstantExpr(ConstantExpr *E) {
526 E->ConstantExprBits.ResultKind = Record.readInt();
527 switch (E->ConstantExprBits.ResultKind) {
528 case ConstantExpr::RSK_Int64: {
529 E->Int64Result() = Record.readInt();
530 uint64_t tmp = Record.readInt();
531 E->ConstantExprBits.IsUnsigned = tmp & 0x1;
532 E->ConstantExprBits.BitWidth = tmp >> 1;
535 case ConstantExpr::RSK_APValue:
536 E->APValueResult() = Record.readAPValue();
538 E->setSubExpr(Record.readSubExpr());
541 void ASTStmtReader::VisitPredefinedExpr(PredefinedExpr *E) {
543 bool HasFunctionName = Record.readInt();
544 E->PredefinedExprBits.HasFunctionName = HasFunctionName;
545 E->PredefinedExprBits.Kind = Record.readInt();
546 E->setLocation(readSourceLocation());
548 E->setFunctionName(cast<StringLiteral>(Record.readSubExpr()));
551 void ASTStmtReader::VisitDeclRefExpr(DeclRefExpr *E) {
554 E->DeclRefExprBits.HasQualifier = Record.readInt();
555 E->DeclRefExprBits.HasFoundDecl = Record.readInt();
556 E->DeclRefExprBits.HasTemplateKWAndArgsInfo = Record.readInt();
557 E->DeclRefExprBits.HadMultipleCandidates = Record.readInt();
558 E->DeclRefExprBits.RefersToEnclosingVariableOrCapture = Record.readInt();
559 E->DeclRefExprBits.NonOdrUseReason = Record.readInt();
560 unsigned NumTemplateArgs = 0;
561 if (E->hasTemplateKWAndArgsInfo())
562 NumTemplateArgs = Record.readInt();
564 if (E->hasQualifier())
565 new (E->getTrailingObjects<NestedNameSpecifierLoc>())
566 NestedNameSpecifierLoc(Record.readNestedNameSpecifierLoc());
568 if (E->hasFoundDecl())
569 *E->getTrailingObjects<NamedDecl *>() = readDeclAs<NamedDecl>();
571 if (E->hasTemplateKWAndArgsInfo())
572 ReadTemplateKWAndArgsInfo(
573 *E->getTrailingObjects<ASTTemplateKWAndArgsInfo>(),
574 E->getTrailingObjects<TemplateArgumentLoc>(), NumTemplateArgs);
576 E->setDecl(readDeclAs<ValueDecl>());
577 E->setLocation(readSourceLocation());
578 E->DNLoc = Record.readDeclarationNameLoc(E->getDecl()->getDeclName());
581 void ASTStmtReader::VisitIntegerLiteral(IntegerLiteral *E) {
583 E->setLocation(readSourceLocation());
584 E->setValue(Record.getContext(), Record.readAPInt());
587 void ASTStmtReader::VisitFixedPointLiteral(FixedPointLiteral *E) {
589 E->setLocation(readSourceLocation());
590 E->setValue(Record.getContext(), Record.readAPInt());
593 void ASTStmtReader::VisitFloatingLiteral(FloatingLiteral *E) {
596 static_cast<llvm::APFloatBase::Semantics>(Record.readInt()));
597 E->setExact(Record.readInt());
598 E->setValue(Record.getContext(), Record.readAPFloat(E->getSemantics()));
599 E->setLocation(readSourceLocation());
602 void ASTStmtReader::VisitImaginaryLiteral(ImaginaryLiteral *E) {
604 E->setSubExpr(Record.readSubExpr());
607 void ASTStmtReader::VisitStringLiteral(StringLiteral *E) {
610 // NumConcatenated, Length and CharByteWidth are set by the empty
611 // ctor since they are needed to allocate storage for the trailing objects.
612 unsigned NumConcatenated = Record.readInt();
613 unsigned Length = Record.readInt();
614 unsigned CharByteWidth = Record.readInt();
615 assert((NumConcatenated == E->getNumConcatenated()) &&
616 "Wrong number of concatenated tokens!");
617 assert((Length == E->getLength()) && "Wrong Length!");
618 assert((CharByteWidth == E->getCharByteWidth()) && "Wrong character width!");
619 E->StringLiteralBits.Kind = Record.readInt();
620 E->StringLiteralBits.IsPascal = Record.readInt();
622 // The character width is originally computed via mapCharByteWidth.
623 // Check that the deserialized character width is consistant with the result
624 // of calling mapCharByteWidth.
625 assert((CharByteWidth ==
626 StringLiteral::mapCharByteWidth(Record.getContext().getTargetInfo(),
628 "Wrong character width!");
630 // Deserialize the trailing array of SourceLocation.
631 for (unsigned I = 0; I < NumConcatenated; ++I)
632 E->setStrTokenLoc(I, readSourceLocation());
634 // Deserialize the trailing array of char holding the string data.
635 char *StrData = E->getStrDataAsChar();
636 for (unsigned I = 0; I < Length * CharByteWidth; ++I)
637 StrData[I] = Record.readInt();
640 void ASTStmtReader::VisitCharacterLiteral(CharacterLiteral *E) {
642 E->setValue(Record.readInt());
643 E->setLocation(readSourceLocation());
644 E->setKind(static_cast<CharacterLiteral::CharacterKind>(Record.readInt()));
647 void ASTStmtReader::VisitParenExpr(ParenExpr *E) {
649 E->setLParen(readSourceLocation());
650 E->setRParen(readSourceLocation());
651 E->setSubExpr(Record.readSubExpr());
654 void ASTStmtReader::VisitParenListExpr(ParenListExpr *E) {
656 unsigned NumExprs = Record.readInt();
657 assert((NumExprs == E->getNumExprs()) && "Wrong NumExprs!");
658 for (unsigned I = 0; I != NumExprs; ++I)
659 E->getTrailingObjects<Stmt *>()[I] = Record.readSubStmt();
660 E->LParenLoc = readSourceLocation();
661 E->RParenLoc = readSourceLocation();
664 void ASTStmtReader::VisitUnaryOperator(UnaryOperator *E) {
666 E->setSubExpr(Record.readSubExpr());
667 E->setOpcode((UnaryOperator::Opcode)Record.readInt());
668 E->setOperatorLoc(readSourceLocation());
669 E->setCanOverflow(Record.readInt());
672 void ASTStmtReader::VisitOffsetOfExpr(OffsetOfExpr *E) {
674 assert(E->getNumComponents() == Record.peekInt());
676 assert(E->getNumExpressions() == Record.peekInt());
678 E->setOperatorLoc(readSourceLocation());
679 E->setRParenLoc(readSourceLocation());
680 E->setTypeSourceInfo(readTypeSourceInfo());
681 for (unsigned I = 0, N = E->getNumComponents(); I != N; ++I) {
682 auto Kind = static_cast<OffsetOfNode::Kind>(Record.readInt());
683 SourceLocation Start = readSourceLocation();
684 SourceLocation End = readSourceLocation();
686 case OffsetOfNode::Array:
687 E->setComponent(I, OffsetOfNode(Start, Record.readInt(), End));
690 case OffsetOfNode::Field:
692 I, OffsetOfNode(Start, readDeclAs<FieldDecl>(), End));
695 case OffsetOfNode::Identifier:
698 OffsetOfNode(Start, Record.readIdentifier(), End));
701 case OffsetOfNode::Base: {
702 auto *Base = new (Record.getContext()) CXXBaseSpecifier();
703 *Base = Record.readCXXBaseSpecifier();
704 E->setComponent(I, OffsetOfNode(Base));
710 for (unsigned I = 0, N = E->getNumExpressions(); I != N; ++I)
711 E->setIndexExpr(I, Record.readSubExpr());
714 void ASTStmtReader::VisitUnaryExprOrTypeTraitExpr(UnaryExprOrTypeTraitExpr *E) {
716 E->setKind(static_cast<UnaryExprOrTypeTrait>(Record.readInt()));
717 if (Record.peekInt() == 0) {
718 E->setArgument(Record.readSubExpr());
721 E->setArgument(readTypeSourceInfo());
723 E->setOperatorLoc(readSourceLocation());
724 E->setRParenLoc(readSourceLocation());
727 static ConstraintSatisfaction
728 readConstraintSatisfaction(ASTRecordReader &Record) {
729 ConstraintSatisfaction Satisfaction;
730 Satisfaction.IsSatisfied = Record.readInt();
731 if (!Satisfaction.IsSatisfied) {
732 unsigned NumDetailRecords = Record.readInt();
733 for (unsigned i = 0; i != NumDetailRecords; ++i) {
734 Expr *ConstraintExpr = Record.readExpr();
735 if (bool IsDiagnostic = Record.readInt()) {
736 SourceLocation DiagLocation = Record.readSourceLocation();
737 std::string DiagMessage = Record.readString();
738 Satisfaction.Details.emplace_back(
739 ConstraintExpr, new (Record.getContext())
740 ConstraintSatisfaction::SubstitutionDiagnostic{
741 DiagLocation, DiagMessage});
743 Satisfaction.Details.emplace_back(ConstraintExpr, Record.readExpr());
749 void ASTStmtReader::VisitConceptSpecializationExpr(
750 ConceptSpecializationExpr *E) {
752 unsigned NumTemplateArgs = Record.readInt();
753 E->NestedNameSpec = Record.readNestedNameSpecifierLoc();
754 E->TemplateKWLoc = Record.readSourceLocation();
755 E->ConceptName = Record.readDeclarationNameInfo();
756 E->NamedConcept = readDeclAs<ConceptDecl>();
757 E->FoundDecl = Record.readDeclAs<NamedDecl>();
758 E->ArgsAsWritten = Record.readASTTemplateArgumentListInfo();
759 llvm::SmallVector<TemplateArgument, 4> Args;
760 for (unsigned I = 0; I < NumTemplateArgs; ++I)
761 Args.push_back(Record.readTemplateArgument());
762 E->setTemplateArguments(Args);
763 E->Satisfaction = E->isValueDependent() ? nullptr :
764 ASTConstraintSatisfaction::Create(Record.getContext(),
765 readConstraintSatisfaction(Record));
768 static concepts::Requirement::SubstitutionDiagnostic *
769 readSubstitutionDiagnostic(ASTRecordReader &Record) {
770 std::string SubstitutedEntity = Record.readString();
771 SourceLocation DiagLoc = Record.readSourceLocation();
772 std::string DiagMessage = Record.readString();
773 return new (Record.getContext())
774 concepts::Requirement::SubstitutionDiagnostic{SubstitutedEntity, DiagLoc,
778 void ASTStmtReader::VisitRequiresExpr(RequiresExpr *E) {
780 unsigned NumLocalParameters = Record.readInt();
781 unsigned NumRequirements = Record.readInt();
782 E->RequiresExprBits.RequiresKWLoc = Record.readSourceLocation();
783 E->RequiresExprBits.IsSatisfied = Record.readInt();
784 E->Body = Record.readDeclAs<RequiresExprBodyDecl>();
785 llvm::SmallVector<ParmVarDecl *, 4> LocalParameters;
786 for (unsigned i = 0; i < NumLocalParameters; ++i)
787 LocalParameters.push_back(cast<ParmVarDecl>(Record.readDecl()));
788 std::copy(LocalParameters.begin(), LocalParameters.end(),
789 E->getTrailingObjects<ParmVarDecl *>());
790 llvm::SmallVector<concepts::Requirement *, 4> Requirements;
791 for (unsigned i = 0; i < NumRequirements; ++i) {
793 static_cast<concepts::Requirement::RequirementKind>(Record.readInt());
794 concepts::Requirement *R = nullptr;
796 case concepts::Requirement::RK_Type: {
798 static_cast<concepts::TypeRequirement::SatisfactionStatus>(
800 if (Status == concepts::TypeRequirement::SS_SubstitutionFailure)
801 R = new (Record.getContext())
802 concepts::TypeRequirement(readSubstitutionDiagnostic(Record));
804 R = new (Record.getContext())
805 concepts::TypeRequirement(Record.readTypeSourceInfo());
807 case concepts::Requirement::RK_Simple:
808 case concepts::Requirement::RK_Compound: {
810 static_cast<concepts::ExprRequirement::SatisfactionStatus>(
812 llvm::PointerUnion<concepts::Requirement::SubstitutionDiagnostic *,
814 if (Status == concepts::ExprRequirement::SS_ExprSubstitutionFailure) {
815 E = readSubstitutionDiagnostic(Record);
817 E = Record.readExpr();
819 llvm::Optional<concepts::ExprRequirement::ReturnTypeRequirement> Req;
820 ConceptSpecializationExpr *SubstitutedConstraintExpr = nullptr;
821 SourceLocation NoexceptLoc;
822 if (RK == concepts::Requirement::RK_Simple) {
825 NoexceptLoc = Record.readSourceLocation();
826 switch (auto returnTypeRequirementKind = Record.readInt()) {
828 // No return type requirement.
833 TemplateParameterList *TPL = Record.readTemplateParameterList();
835 concepts::ExprRequirement::SS_ConstraintsNotSatisfied)
836 SubstitutedConstraintExpr =
837 cast<ConceptSpecializationExpr>(Record.readExpr());
841 // Substitution failure
842 Req.emplace(readSubstitutionDiagnostic(Record));
846 if (Expr *Ex = E.dyn_cast<Expr *>())
847 R = new (Record.getContext()) concepts::ExprRequirement(
848 Ex, RK == concepts::Requirement::RK_Simple, NoexceptLoc,
849 std::move(*Req), Status, SubstitutedConstraintExpr);
851 R = new (Record.getContext()) concepts::ExprRequirement(
852 E.get<concepts::Requirement::SubstitutionDiagnostic *>(),
853 RK == concepts::Requirement::RK_Simple, NoexceptLoc,
856 case concepts::Requirement::RK_Nested: {
857 if (bool IsSubstitutionDiagnostic = Record.readInt()) {
858 R = new (Record.getContext()) concepts::NestedRequirement(
859 readSubstitutionDiagnostic(Record));
862 Expr *E = Record.readExpr();
863 if (E->isInstantiationDependent())
864 R = new (Record.getContext()) concepts::NestedRequirement(E);
866 R = new (Record.getContext())
867 concepts::NestedRequirement(Record.getContext(), E,
868 readConstraintSatisfaction(Record));
873 Requirements.push_back(R);
875 std::copy(Requirements.begin(), Requirements.end(),
876 E->getTrailingObjects<concepts::Requirement *>());
877 E->RBraceLoc = Record.readSourceLocation();
880 void ASTStmtReader::VisitArraySubscriptExpr(ArraySubscriptExpr *E) {
882 E->setLHS(Record.readSubExpr());
883 E->setRHS(Record.readSubExpr());
884 E->setRBracketLoc(readSourceLocation());
887 void ASTStmtReader::VisitOMPArraySectionExpr(OMPArraySectionExpr *E) {
889 E->setBase(Record.readSubExpr());
890 E->setLowerBound(Record.readSubExpr());
891 E->setLength(Record.readSubExpr());
892 E->setColonLoc(readSourceLocation());
893 E->setRBracketLoc(readSourceLocation());
896 void ASTStmtReader::VisitCallExpr(CallExpr *E) {
898 unsigned NumArgs = Record.readInt();
899 assert((NumArgs == E->getNumArgs()) && "Wrong NumArgs!");
900 E->setRParenLoc(readSourceLocation());
901 E->setCallee(Record.readSubExpr());
902 for (unsigned I = 0; I != NumArgs; ++I)
903 E->setArg(I, Record.readSubExpr());
904 E->setADLCallKind(static_cast<CallExpr::ADLCallKind>(Record.readInt()));
907 void ASTStmtReader::VisitCXXMemberCallExpr(CXXMemberCallExpr *E) {
911 void ASTStmtReader::VisitMemberExpr(MemberExpr *E) {
914 bool HasQualifier = Record.readInt();
915 bool HasFoundDecl = Record.readInt();
916 bool HasTemplateInfo = Record.readInt();
917 unsigned NumTemplateArgs = Record.readInt();
919 E->Base = Record.readSubExpr();
920 E->MemberDecl = Record.readDeclAs<ValueDecl>();
921 E->MemberDNLoc = Record.readDeclarationNameLoc(E->MemberDecl->getDeclName());
922 E->MemberLoc = Record.readSourceLocation();
923 E->MemberExprBits.IsArrow = Record.readInt();
924 E->MemberExprBits.HasQualifierOrFoundDecl = HasQualifier || HasFoundDecl;
925 E->MemberExprBits.HasTemplateKWAndArgsInfo = HasTemplateInfo;
926 E->MemberExprBits.HadMultipleCandidates = Record.readInt();
927 E->MemberExprBits.NonOdrUseReason = Record.readInt();
928 E->MemberExprBits.OperatorLoc = Record.readSourceLocation();
930 if (HasQualifier || HasFoundDecl) {
931 DeclAccessPair FoundDecl;
933 auto *FoundD = Record.readDeclAs<NamedDecl>();
934 auto AS = (AccessSpecifier)Record.readInt();
935 FoundDecl = DeclAccessPair::make(FoundD, AS);
937 FoundDecl = DeclAccessPair::make(E->MemberDecl,
938 E->MemberDecl->getAccess());
940 E->getTrailingObjects<MemberExprNameQualifier>()->FoundDecl = FoundDecl;
942 NestedNameSpecifierLoc QualifierLoc;
944 QualifierLoc = Record.readNestedNameSpecifierLoc();
945 E->getTrailingObjects<MemberExprNameQualifier>()->QualifierLoc =
950 ReadTemplateKWAndArgsInfo(
951 *E->getTrailingObjects<ASTTemplateKWAndArgsInfo>(),
952 E->getTrailingObjects<TemplateArgumentLoc>(), NumTemplateArgs);
955 void ASTStmtReader::VisitObjCIsaExpr(ObjCIsaExpr *E) {
957 E->setBase(Record.readSubExpr());
958 E->setIsaMemberLoc(readSourceLocation());
959 E->setOpLoc(readSourceLocation());
960 E->setArrow(Record.readInt());
964 VisitObjCIndirectCopyRestoreExpr(ObjCIndirectCopyRestoreExpr *E) {
966 E->Operand = Record.readSubExpr();
967 E->setShouldCopy(Record.readInt());
970 void ASTStmtReader::VisitObjCBridgedCastExpr(ObjCBridgedCastExpr *E) {
971 VisitExplicitCastExpr(E);
972 E->LParenLoc = readSourceLocation();
973 E->BridgeKeywordLoc = readSourceLocation();
974 E->Kind = Record.readInt();
977 void ASTStmtReader::VisitCastExpr(CastExpr *E) {
979 unsigned NumBaseSpecs = Record.readInt();
980 assert(NumBaseSpecs == E->path_size());
981 E->setSubExpr(Record.readSubExpr());
982 E->setCastKind((CastKind)Record.readInt());
983 CastExpr::path_iterator BaseI = E->path_begin();
984 while (NumBaseSpecs--) {
985 auto *BaseSpec = new (Record.getContext()) CXXBaseSpecifier;
986 *BaseSpec = Record.readCXXBaseSpecifier();
991 void ASTStmtReader::VisitBinaryOperator(BinaryOperator *E) {
993 E->setLHS(Record.readSubExpr());
994 E->setRHS(Record.readSubExpr());
995 E->setOpcode((BinaryOperator::Opcode)Record.readInt());
996 E->setOperatorLoc(readSourceLocation());
997 E->setFPFeatures(FPOptions(Record.readInt()));
1000 void ASTStmtReader::VisitCompoundAssignOperator(CompoundAssignOperator *E) {
1001 VisitBinaryOperator(E);
1002 E->setComputationLHSType(Record.readType());
1003 E->setComputationResultType(Record.readType());
1006 void ASTStmtReader::VisitConditionalOperator(ConditionalOperator *E) {
1008 E->SubExprs[ConditionalOperator::COND] = Record.readSubExpr();
1009 E->SubExprs[ConditionalOperator::LHS] = Record.readSubExpr();
1010 E->SubExprs[ConditionalOperator::RHS] = Record.readSubExpr();
1011 E->QuestionLoc = readSourceLocation();
1012 E->ColonLoc = readSourceLocation();
1016 ASTStmtReader::VisitBinaryConditionalOperator(BinaryConditionalOperator *E) {
1018 E->OpaqueValue = cast<OpaqueValueExpr>(Record.readSubExpr());
1019 E->SubExprs[BinaryConditionalOperator::COMMON] = Record.readSubExpr();
1020 E->SubExprs[BinaryConditionalOperator::COND] = Record.readSubExpr();
1021 E->SubExprs[BinaryConditionalOperator::LHS] = Record.readSubExpr();
1022 E->SubExprs[BinaryConditionalOperator::RHS] = Record.readSubExpr();
1023 E->QuestionLoc = readSourceLocation();
1024 E->ColonLoc = readSourceLocation();
1027 void ASTStmtReader::VisitImplicitCastExpr(ImplicitCastExpr *E) {
1029 E->setIsPartOfExplicitCast(Record.readInt());
1032 void ASTStmtReader::VisitExplicitCastExpr(ExplicitCastExpr *E) {
1034 E->setTypeInfoAsWritten(readTypeSourceInfo());
1037 void ASTStmtReader::VisitCStyleCastExpr(CStyleCastExpr *E) {
1038 VisitExplicitCastExpr(E);
1039 E->setLParenLoc(readSourceLocation());
1040 E->setRParenLoc(readSourceLocation());
1043 void ASTStmtReader::VisitCompoundLiteralExpr(CompoundLiteralExpr *E) {
1045 E->setLParenLoc(readSourceLocation());
1046 E->setTypeSourceInfo(readTypeSourceInfo());
1047 E->setInitializer(Record.readSubExpr());
1048 E->setFileScope(Record.readInt());
1051 void ASTStmtReader::VisitExtVectorElementExpr(ExtVectorElementExpr *E) {
1053 E->setBase(Record.readSubExpr());
1054 E->setAccessor(Record.readIdentifier());
1055 E->setAccessorLoc(readSourceLocation());
1058 void ASTStmtReader::VisitInitListExpr(InitListExpr *E) {
1060 if (auto *SyntForm = cast_or_null<InitListExpr>(Record.readSubStmt()))
1061 E->setSyntacticForm(SyntForm);
1062 E->setLBraceLoc(readSourceLocation());
1063 E->setRBraceLoc(readSourceLocation());
1064 bool isArrayFiller = Record.readInt();
1065 Expr *filler = nullptr;
1066 if (isArrayFiller) {
1067 filler = Record.readSubExpr();
1068 E->ArrayFillerOrUnionFieldInit = filler;
1070 E->ArrayFillerOrUnionFieldInit = readDeclAs<FieldDecl>();
1071 E->sawArrayRangeDesignator(Record.readInt());
1072 unsigned NumInits = Record.readInt();
1073 E->reserveInits(Record.getContext(), NumInits);
1074 if (isArrayFiller) {
1075 for (unsigned I = 0; I != NumInits; ++I) {
1076 Expr *init = Record.readSubExpr();
1077 E->updateInit(Record.getContext(), I, init ? init : filler);
1080 for (unsigned I = 0; I != NumInits; ++I)
1081 E->updateInit(Record.getContext(), I, Record.readSubExpr());
1085 void ASTStmtReader::VisitDesignatedInitExpr(DesignatedInitExpr *E) {
1086 using Designator = DesignatedInitExpr::Designator;
1089 unsigned NumSubExprs = Record.readInt();
1090 assert(NumSubExprs == E->getNumSubExprs() && "Wrong number of subexprs");
1091 for (unsigned I = 0; I != NumSubExprs; ++I)
1092 E->setSubExpr(I, Record.readSubExpr());
1093 E->setEqualOrColonLoc(readSourceLocation());
1094 E->setGNUSyntax(Record.readInt());
1096 SmallVector<Designator, 4> Designators;
1097 while (Record.getIdx() < Record.size()) {
1098 switch ((DesignatorTypes)Record.readInt()) {
1099 case DESIG_FIELD_DECL: {
1100 auto *Field = readDeclAs<FieldDecl>();
1101 SourceLocation DotLoc = readSourceLocation();
1102 SourceLocation FieldLoc = readSourceLocation();
1103 Designators.push_back(Designator(Field->getIdentifier(), DotLoc,
1105 Designators.back().setField(Field);
1109 case DESIG_FIELD_NAME: {
1110 const IdentifierInfo *Name = Record.readIdentifier();
1111 SourceLocation DotLoc = readSourceLocation();
1112 SourceLocation FieldLoc = readSourceLocation();
1113 Designators.push_back(Designator(Name, DotLoc, FieldLoc));
1118 unsigned Index = Record.readInt();
1119 SourceLocation LBracketLoc = readSourceLocation();
1120 SourceLocation RBracketLoc = readSourceLocation();
1121 Designators.push_back(Designator(Index, LBracketLoc, RBracketLoc));
1125 case DESIG_ARRAY_RANGE: {
1126 unsigned Index = Record.readInt();
1127 SourceLocation LBracketLoc = readSourceLocation();
1128 SourceLocation EllipsisLoc = readSourceLocation();
1129 SourceLocation RBracketLoc = readSourceLocation();
1130 Designators.push_back(Designator(Index, LBracketLoc, EllipsisLoc,
1136 E->setDesignators(Record.getContext(),
1137 Designators.data(), Designators.size());
1140 void ASTStmtReader::VisitDesignatedInitUpdateExpr(DesignatedInitUpdateExpr *E) {
1142 E->setBase(Record.readSubExpr());
1143 E->setUpdater(Record.readSubExpr());
1146 void ASTStmtReader::VisitNoInitExpr(NoInitExpr *E) {
1150 void ASTStmtReader::VisitArrayInitLoopExpr(ArrayInitLoopExpr *E) {
1152 E->SubExprs[0] = Record.readSubExpr();
1153 E->SubExprs[1] = Record.readSubExpr();
1156 void ASTStmtReader::VisitArrayInitIndexExpr(ArrayInitIndexExpr *E) {
1160 void ASTStmtReader::VisitImplicitValueInitExpr(ImplicitValueInitExpr *E) {
1164 void ASTStmtReader::VisitVAArgExpr(VAArgExpr *E) {
1166 E->setSubExpr(Record.readSubExpr());
1167 E->setWrittenTypeInfo(readTypeSourceInfo());
1168 E->setBuiltinLoc(readSourceLocation());
1169 E->setRParenLoc(readSourceLocation());
1170 E->setIsMicrosoftABI(Record.readInt());
1173 void ASTStmtReader::VisitSourceLocExpr(SourceLocExpr *E) {
1175 E->ParentContext = readDeclAs<DeclContext>();
1176 E->BuiltinLoc = readSourceLocation();
1177 E->RParenLoc = readSourceLocation();
1178 E->SourceLocExprBits.Kind =
1179 static_cast<SourceLocExpr::IdentKind>(Record.readInt());
1182 void ASTStmtReader::VisitAddrLabelExpr(AddrLabelExpr *E) {
1184 E->setAmpAmpLoc(readSourceLocation());
1185 E->setLabelLoc(readSourceLocation());
1186 E->setLabel(readDeclAs<LabelDecl>());
1189 void ASTStmtReader::VisitStmtExpr(StmtExpr *E) {
1191 E->setLParenLoc(readSourceLocation());
1192 E->setRParenLoc(readSourceLocation());
1193 E->setSubStmt(cast_or_null<CompoundStmt>(Record.readSubStmt()));
1194 E->StmtExprBits.TemplateDepth = Record.readInt();
1197 void ASTStmtReader::VisitChooseExpr(ChooseExpr *E) {
1199 E->setCond(Record.readSubExpr());
1200 E->setLHS(Record.readSubExpr());
1201 E->setRHS(Record.readSubExpr());
1202 E->setBuiltinLoc(readSourceLocation());
1203 E->setRParenLoc(readSourceLocation());
1204 E->setIsConditionTrue(Record.readInt());
1207 void ASTStmtReader::VisitGNUNullExpr(GNUNullExpr *E) {
1209 E->setTokenLocation(readSourceLocation());
1212 void ASTStmtReader::VisitShuffleVectorExpr(ShuffleVectorExpr *E) {
1214 SmallVector<Expr *, 16> Exprs;
1215 unsigned NumExprs = Record.readInt();
1217 Exprs.push_back(Record.readSubExpr());
1218 E->setExprs(Record.getContext(), Exprs);
1219 E->setBuiltinLoc(readSourceLocation());
1220 E->setRParenLoc(readSourceLocation());
1223 void ASTStmtReader::VisitConvertVectorExpr(ConvertVectorExpr *E) {
1225 E->BuiltinLoc = readSourceLocation();
1226 E->RParenLoc = readSourceLocation();
1227 E->TInfo = readTypeSourceInfo();
1228 E->SrcExpr = Record.readSubExpr();
1231 void ASTStmtReader::VisitBlockExpr(BlockExpr *E) {
1233 E->setBlockDecl(readDeclAs<BlockDecl>());
1236 void ASTStmtReader::VisitGenericSelectionExpr(GenericSelectionExpr *E) {
1239 unsigned NumAssocs = Record.readInt();
1240 assert(NumAssocs == E->getNumAssocs() && "Wrong NumAssocs!");
1241 E->ResultIndex = Record.readInt();
1242 E->GenericSelectionExprBits.GenericLoc = readSourceLocation();
1243 E->DefaultLoc = readSourceLocation();
1244 E->RParenLoc = readSourceLocation();
1246 Stmt **Stmts = E->getTrailingObjects<Stmt *>();
1247 // Add 1 to account for the controlling expression which is the first
1248 // expression in the trailing array of Stmt *. This is not needed for
1249 // the trailing array of TypeSourceInfo *.
1250 for (unsigned I = 0, N = NumAssocs + 1; I < N; ++I)
1251 Stmts[I] = Record.readSubExpr();
1253 TypeSourceInfo **TSIs = E->getTrailingObjects<TypeSourceInfo *>();
1254 for (unsigned I = 0, N = NumAssocs; I < N; ++I)
1255 TSIs[I] = readTypeSourceInfo();
1258 void ASTStmtReader::VisitPseudoObjectExpr(PseudoObjectExpr *E) {
1260 unsigned numSemanticExprs = Record.readInt();
1261 assert(numSemanticExprs + 1 == E->PseudoObjectExprBits.NumSubExprs);
1262 E->PseudoObjectExprBits.ResultIndex = Record.readInt();
1264 // Read the syntactic expression.
1265 E->getSubExprsBuffer()[0] = Record.readSubExpr();
1267 // Read all the semantic expressions.
1268 for (unsigned i = 0; i != numSemanticExprs; ++i) {
1269 Expr *subExpr = Record.readSubExpr();
1270 E->getSubExprsBuffer()[i+1] = subExpr;
1274 void ASTStmtReader::VisitAtomicExpr(AtomicExpr *E) {
1276 E->Op = AtomicExpr::AtomicOp(Record.readInt());
1277 E->NumSubExprs = AtomicExpr::getNumSubExprs(E->Op);
1278 for (unsigned I = 0; I != E->NumSubExprs; ++I)
1279 E->SubExprs[I] = Record.readSubExpr();
1280 E->BuiltinLoc = readSourceLocation();
1281 E->RParenLoc = readSourceLocation();
1284 //===----------------------------------------------------------------------===//
1285 // Objective-C Expressions and Statements
1287 void ASTStmtReader::VisitObjCStringLiteral(ObjCStringLiteral *E) {
1289 E->setString(cast<StringLiteral>(Record.readSubStmt()));
1290 E->setAtLoc(readSourceLocation());
1293 void ASTStmtReader::VisitObjCBoxedExpr(ObjCBoxedExpr *E) {
1295 // could be one of several IntegerLiteral, FloatLiteral, etc.
1296 E->SubExpr = Record.readSubStmt();
1297 E->BoxingMethod = readDeclAs<ObjCMethodDecl>();
1298 E->Range = readSourceRange();
1301 void ASTStmtReader::VisitObjCArrayLiteral(ObjCArrayLiteral *E) {
1303 unsigned NumElements = Record.readInt();
1304 assert(NumElements == E->getNumElements() && "Wrong number of elements");
1305 Expr **Elements = E->getElements();
1306 for (unsigned I = 0, N = NumElements; I != N; ++I)
1307 Elements[I] = Record.readSubExpr();
1308 E->ArrayWithObjectsMethod = readDeclAs<ObjCMethodDecl>();
1309 E->Range = readSourceRange();
1312 void ASTStmtReader::VisitObjCDictionaryLiteral(ObjCDictionaryLiteral *E) {
1314 unsigned NumElements = Record.readInt();
1315 assert(NumElements == E->getNumElements() && "Wrong number of elements");
1316 bool HasPackExpansions = Record.readInt();
1317 assert(HasPackExpansions == E->HasPackExpansions &&"Pack expansion mismatch");
1319 E->getTrailingObjects<ObjCDictionaryLiteral::KeyValuePair>();
1321 E->getTrailingObjects<ObjCDictionaryLiteral::ExpansionData>();
1322 for (unsigned I = 0; I != NumElements; ++I) {
1323 KeyValues[I].Key = Record.readSubExpr();
1324 KeyValues[I].Value = Record.readSubExpr();
1325 if (HasPackExpansions) {
1326 Expansions[I].EllipsisLoc = readSourceLocation();
1327 Expansions[I].NumExpansionsPlusOne = Record.readInt();
1330 E->DictWithObjectsMethod = readDeclAs<ObjCMethodDecl>();
1331 E->Range = readSourceRange();
1334 void ASTStmtReader::VisitObjCEncodeExpr(ObjCEncodeExpr *E) {
1336 E->setEncodedTypeSourceInfo(readTypeSourceInfo());
1337 E->setAtLoc(readSourceLocation());
1338 E->setRParenLoc(readSourceLocation());
1341 void ASTStmtReader::VisitObjCSelectorExpr(ObjCSelectorExpr *E) {
1343 E->setSelector(Record.readSelector());
1344 E->setAtLoc(readSourceLocation());
1345 E->setRParenLoc(readSourceLocation());
1348 void ASTStmtReader::VisitObjCProtocolExpr(ObjCProtocolExpr *E) {
1350 E->setProtocol(readDeclAs<ObjCProtocolDecl>());
1351 E->setAtLoc(readSourceLocation());
1352 E->ProtoLoc = readSourceLocation();
1353 E->setRParenLoc(readSourceLocation());
1356 void ASTStmtReader::VisitObjCIvarRefExpr(ObjCIvarRefExpr *E) {
1358 E->setDecl(readDeclAs<ObjCIvarDecl>());
1359 E->setLocation(readSourceLocation());
1360 E->setOpLoc(readSourceLocation());
1361 E->setBase(Record.readSubExpr());
1362 E->setIsArrow(Record.readInt());
1363 E->setIsFreeIvar(Record.readInt());
1366 void ASTStmtReader::VisitObjCPropertyRefExpr(ObjCPropertyRefExpr *E) {
1368 unsigned MethodRefFlags = Record.readInt();
1369 bool Implicit = Record.readInt() != 0;
1371 auto *Getter = readDeclAs<ObjCMethodDecl>();
1372 auto *Setter = readDeclAs<ObjCMethodDecl>();
1373 E->setImplicitProperty(Getter, Setter, MethodRefFlags);
1375 E->setExplicitProperty(readDeclAs<ObjCPropertyDecl>(), MethodRefFlags);
1377 E->setLocation(readSourceLocation());
1378 E->setReceiverLocation(readSourceLocation());
1379 switch (Record.readInt()) {
1381 E->setBase(Record.readSubExpr());
1384 E->setSuperReceiver(Record.readType());
1387 E->setClassReceiver(readDeclAs<ObjCInterfaceDecl>());
1392 void ASTStmtReader::VisitObjCSubscriptRefExpr(ObjCSubscriptRefExpr *E) {
1394 E->setRBracket(readSourceLocation());
1395 E->setBaseExpr(Record.readSubExpr());
1396 E->setKeyExpr(Record.readSubExpr());
1397 E->GetAtIndexMethodDecl = readDeclAs<ObjCMethodDecl>();
1398 E->SetAtIndexMethodDecl = readDeclAs<ObjCMethodDecl>();
1401 void ASTStmtReader::VisitObjCMessageExpr(ObjCMessageExpr *E) {
1403 assert(Record.peekInt() == E->getNumArgs());
1405 unsigned NumStoredSelLocs = Record.readInt();
1406 E->SelLocsKind = Record.readInt();
1407 E->setDelegateInitCall(Record.readInt());
1408 E->IsImplicit = Record.readInt();
1409 auto Kind = static_cast<ObjCMessageExpr::ReceiverKind>(Record.readInt());
1411 case ObjCMessageExpr::Instance:
1412 E->setInstanceReceiver(Record.readSubExpr());
1415 case ObjCMessageExpr::Class:
1416 E->setClassReceiver(readTypeSourceInfo());
1419 case ObjCMessageExpr::SuperClass:
1420 case ObjCMessageExpr::SuperInstance: {
1421 QualType T = Record.readType();
1422 SourceLocation SuperLoc = readSourceLocation();
1423 E->setSuper(SuperLoc, T, Kind == ObjCMessageExpr::SuperInstance);
1428 assert(Kind == E->getReceiverKind());
1430 if (Record.readInt())
1431 E->setMethodDecl(readDeclAs<ObjCMethodDecl>());
1433 E->setSelector(Record.readSelector());
1435 E->LBracLoc = readSourceLocation();
1436 E->RBracLoc = readSourceLocation();
1438 for (unsigned I = 0, N = E->getNumArgs(); I != N; ++I)
1439 E->setArg(I, Record.readSubExpr());
1441 SourceLocation *Locs = E->getStoredSelLocs();
1442 for (unsigned I = 0; I != NumStoredSelLocs; ++I)
1443 Locs[I] = readSourceLocation();
1446 void ASTStmtReader::VisitObjCForCollectionStmt(ObjCForCollectionStmt *S) {
1448 S->setElement(Record.readSubStmt());
1449 S->setCollection(Record.readSubExpr());
1450 S->setBody(Record.readSubStmt());
1451 S->setForLoc(readSourceLocation());
1452 S->setRParenLoc(readSourceLocation());
1455 void ASTStmtReader::VisitObjCAtCatchStmt(ObjCAtCatchStmt *S) {
1457 S->setCatchBody(Record.readSubStmt());
1458 S->setCatchParamDecl(readDeclAs<VarDecl>());
1459 S->setAtCatchLoc(readSourceLocation());
1460 S->setRParenLoc(readSourceLocation());
1463 void ASTStmtReader::VisitObjCAtFinallyStmt(ObjCAtFinallyStmt *S) {
1465 S->setFinallyBody(Record.readSubStmt());
1466 S->setAtFinallyLoc(readSourceLocation());
1469 void ASTStmtReader::VisitObjCAutoreleasePoolStmt(ObjCAutoreleasePoolStmt *S) {
1470 VisitStmt(S); // FIXME: no test coverage.
1471 S->setSubStmt(Record.readSubStmt());
1472 S->setAtLoc(readSourceLocation());
1475 void ASTStmtReader::VisitObjCAtTryStmt(ObjCAtTryStmt *S) {
1477 assert(Record.peekInt() == S->getNumCatchStmts());
1479 bool HasFinally = Record.readInt();
1480 S->setTryBody(Record.readSubStmt());
1481 for (unsigned I = 0, N = S->getNumCatchStmts(); I != N; ++I)
1482 S->setCatchStmt(I, cast_or_null<ObjCAtCatchStmt>(Record.readSubStmt()));
1485 S->setFinallyStmt(Record.readSubStmt());
1486 S->setAtTryLoc(readSourceLocation());
1489 void ASTStmtReader::VisitObjCAtSynchronizedStmt(ObjCAtSynchronizedStmt *S) {
1490 VisitStmt(S); // FIXME: no test coverage.
1491 S->setSynchExpr(Record.readSubStmt());
1492 S->setSynchBody(Record.readSubStmt());
1493 S->setAtSynchronizedLoc(readSourceLocation());
1496 void ASTStmtReader::VisitObjCAtThrowStmt(ObjCAtThrowStmt *S) {
1497 VisitStmt(S); // FIXME: no test coverage.
1498 S->setThrowExpr(Record.readSubStmt());
1499 S->setThrowLoc(readSourceLocation());
1502 void ASTStmtReader::VisitObjCBoolLiteralExpr(ObjCBoolLiteralExpr *E) {
1504 E->setValue(Record.readInt());
1505 E->setLocation(readSourceLocation());
1508 void ASTStmtReader::VisitObjCAvailabilityCheckExpr(ObjCAvailabilityCheckExpr *E) {
1510 SourceRange R = Record.readSourceRange();
1511 E->AtLoc = R.getBegin();
1512 E->RParen = R.getEnd();
1513 E->VersionToCheck = Record.readVersionTuple();
1516 //===----------------------------------------------------------------------===//
1517 // C++ Expressions and Statements
1518 //===----------------------------------------------------------------------===//
1520 void ASTStmtReader::VisitCXXCatchStmt(CXXCatchStmt *S) {
1522 S->CatchLoc = readSourceLocation();
1523 S->ExceptionDecl = readDeclAs<VarDecl>();
1524 S->HandlerBlock = Record.readSubStmt();
1527 void ASTStmtReader::VisitCXXTryStmt(CXXTryStmt *S) {
1529 assert(Record.peekInt() == S->getNumHandlers() && "NumStmtFields is wrong ?");
1531 S->TryLoc = readSourceLocation();
1532 S->getStmts()[0] = Record.readSubStmt();
1533 for (unsigned i = 0, e = S->getNumHandlers(); i != e; ++i)
1534 S->getStmts()[i + 1] = Record.readSubStmt();
1537 void ASTStmtReader::VisitCXXForRangeStmt(CXXForRangeStmt *S) {
1539 S->ForLoc = readSourceLocation();
1540 S->CoawaitLoc = readSourceLocation();
1541 S->ColonLoc = readSourceLocation();
1542 S->RParenLoc = readSourceLocation();
1543 S->setInit(Record.readSubStmt());
1544 S->setRangeStmt(Record.readSubStmt());
1545 S->setBeginStmt(Record.readSubStmt());
1546 S->setEndStmt(Record.readSubStmt());
1547 S->setCond(Record.readSubExpr());
1548 S->setInc(Record.readSubExpr());
1549 S->setLoopVarStmt(Record.readSubStmt());
1550 S->setBody(Record.readSubStmt());
1553 void ASTStmtReader::VisitMSDependentExistsStmt(MSDependentExistsStmt *S) {
1555 S->KeywordLoc = readSourceLocation();
1556 S->IsIfExists = Record.readInt();
1557 S->QualifierLoc = Record.readNestedNameSpecifierLoc();
1558 S->NameInfo = Record.readDeclarationNameInfo();
1559 S->SubStmt = Record.readSubStmt();
1562 void ASTStmtReader::VisitCXXOperatorCallExpr(CXXOperatorCallExpr *E) {
1564 E->CXXOperatorCallExprBits.OperatorKind = Record.readInt();
1565 E->CXXOperatorCallExprBits.FPFeatures = Record.readInt();
1566 E->Range = Record.readSourceRange();
1569 void ASTStmtReader::VisitCXXRewrittenBinaryOperator(
1570 CXXRewrittenBinaryOperator *E) {
1572 E->CXXRewrittenBinaryOperatorBits.IsReversed = Record.readInt();
1573 E->SemanticForm = Record.readSubExpr();
1576 void ASTStmtReader::VisitCXXConstructExpr(CXXConstructExpr *E) {
1579 unsigned NumArgs = Record.readInt();
1580 assert((NumArgs == E->getNumArgs()) && "Wrong NumArgs!");
1582 E->CXXConstructExprBits.Elidable = Record.readInt();
1583 E->CXXConstructExprBits.HadMultipleCandidates = Record.readInt();
1584 E->CXXConstructExprBits.ListInitialization = Record.readInt();
1585 E->CXXConstructExprBits.StdInitListInitialization = Record.readInt();
1586 E->CXXConstructExprBits.ZeroInitialization = Record.readInt();
1587 E->CXXConstructExprBits.ConstructionKind = Record.readInt();
1588 E->CXXConstructExprBits.Loc = readSourceLocation();
1589 E->Constructor = readDeclAs<CXXConstructorDecl>();
1590 E->ParenOrBraceRange = readSourceRange();
1592 for (unsigned I = 0; I != NumArgs; ++I)
1593 E->setArg(I, Record.readSubExpr());
1596 void ASTStmtReader::VisitCXXInheritedCtorInitExpr(CXXInheritedCtorInitExpr *E) {
1598 E->Constructor = readDeclAs<CXXConstructorDecl>();
1599 E->Loc = readSourceLocation();
1600 E->ConstructsVirtualBase = Record.readInt();
1601 E->InheritedFromVirtualBase = Record.readInt();
1604 void ASTStmtReader::VisitCXXTemporaryObjectExpr(CXXTemporaryObjectExpr *E) {
1605 VisitCXXConstructExpr(E);
1606 E->TSI = readTypeSourceInfo();
1609 void ASTStmtReader::VisitLambdaExpr(LambdaExpr *E) {
1611 unsigned NumCaptures = Record.readInt();
1612 assert(NumCaptures == E->NumCaptures);(void)NumCaptures;
1613 E->IntroducerRange = readSourceRange();
1614 E->CaptureDefault = static_cast<LambdaCaptureDefault>(Record.readInt());
1615 E->CaptureDefaultLoc = readSourceLocation();
1616 E->ExplicitParams = Record.readInt();
1617 E->ExplicitResultType = Record.readInt();
1618 E->ClosingBrace = readSourceLocation();
1620 // Read capture initializers.
1621 for (LambdaExpr::capture_init_iterator C = E->capture_init_begin(),
1622 CEnd = E->capture_init_end();
1624 *C = Record.readSubExpr();
1628 ASTStmtReader::VisitCXXStdInitializerListExpr(CXXStdInitializerListExpr *E) {
1630 E->SubExpr = Record.readSubExpr();
1633 void ASTStmtReader::VisitCXXNamedCastExpr(CXXNamedCastExpr *E) {
1634 VisitExplicitCastExpr(E);
1635 SourceRange R = readSourceRange();
1636 E->Loc = R.getBegin();
1637 E->RParenLoc = R.getEnd();
1638 R = readSourceRange();
1639 E->AngleBrackets = R;
1642 void ASTStmtReader::VisitCXXStaticCastExpr(CXXStaticCastExpr *E) {
1643 return VisitCXXNamedCastExpr(E);
1646 void ASTStmtReader::VisitCXXDynamicCastExpr(CXXDynamicCastExpr *E) {
1647 return VisitCXXNamedCastExpr(E);
1650 void ASTStmtReader::VisitCXXReinterpretCastExpr(CXXReinterpretCastExpr *E) {
1651 return VisitCXXNamedCastExpr(E);
1654 void ASTStmtReader::VisitCXXConstCastExpr(CXXConstCastExpr *E) {
1655 return VisitCXXNamedCastExpr(E);
1658 void ASTStmtReader::VisitCXXFunctionalCastExpr(CXXFunctionalCastExpr *E) {
1659 VisitExplicitCastExpr(E);
1660 E->setLParenLoc(readSourceLocation());
1661 E->setRParenLoc(readSourceLocation());
1664 void ASTStmtReader::VisitBuiltinBitCastExpr(BuiltinBitCastExpr *E) {
1665 VisitExplicitCastExpr(E);
1666 E->KWLoc = readSourceLocation();
1667 E->RParenLoc = readSourceLocation();
1670 void ASTStmtReader::VisitUserDefinedLiteral(UserDefinedLiteral *E) {
1672 E->UDSuffixLoc = readSourceLocation();
1675 void ASTStmtReader::VisitCXXBoolLiteralExpr(CXXBoolLiteralExpr *E) {
1677 E->setValue(Record.readInt());
1678 E->setLocation(readSourceLocation());
1681 void ASTStmtReader::VisitCXXNullPtrLiteralExpr(CXXNullPtrLiteralExpr *E) {
1683 E->setLocation(readSourceLocation());
1686 void ASTStmtReader::VisitCXXTypeidExpr(CXXTypeidExpr *E) {
1688 E->setSourceRange(readSourceRange());
1689 if (E->isTypeOperand()) { // typeid(int)
1690 E->setTypeOperandSourceInfo(
1691 readTypeSourceInfo());
1696 E->setExprOperand(Record.readSubExpr());
1699 void ASTStmtReader::VisitCXXThisExpr(CXXThisExpr *E) {
1701 E->setLocation(readSourceLocation());
1702 E->setImplicit(Record.readInt());
1705 void ASTStmtReader::VisitCXXThrowExpr(CXXThrowExpr *E) {
1707 E->CXXThrowExprBits.ThrowLoc = readSourceLocation();
1708 E->Operand = Record.readSubExpr();
1709 E->CXXThrowExprBits.IsThrownVariableInScope = Record.readInt();
1712 void ASTStmtReader::VisitCXXDefaultArgExpr(CXXDefaultArgExpr *E) {
1714 E->Param = readDeclAs<ParmVarDecl>();
1715 E->UsedContext = readDeclAs<DeclContext>();
1716 E->CXXDefaultArgExprBits.Loc = readSourceLocation();
1719 void ASTStmtReader::VisitCXXDefaultInitExpr(CXXDefaultInitExpr *E) {
1721 E->Field = readDeclAs<FieldDecl>();
1722 E->UsedContext = readDeclAs<DeclContext>();
1723 E->CXXDefaultInitExprBits.Loc = readSourceLocation();
1726 void ASTStmtReader::VisitCXXBindTemporaryExpr(CXXBindTemporaryExpr *E) {
1728 E->setTemporary(Record.readCXXTemporary());
1729 E->setSubExpr(Record.readSubExpr());
1732 void ASTStmtReader::VisitCXXScalarValueInitExpr(CXXScalarValueInitExpr *E) {
1734 E->TypeInfo = readTypeSourceInfo();
1735 E->CXXScalarValueInitExprBits.RParenLoc = readSourceLocation();
1738 void ASTStmtReader::VisitCXXNewExpr(CXXNewExpr *E) {
1741 bool IsArray = Record.readInt();
1742 bool HasInit = Record.readInt();
1743 unsigned NumPlacementArgs = Record.readInt();
1744 bool IsParenTypeId = Record.readInt();
1746 E->CXXNewExprBits.IsGlobalNew = Record.readInt();
1747 E->CXXNewExprBits.ShouldPassAlignment = Record.readInt();
1748 E->CXXNewExprBits.UsualArrayDeleteWantsSize = Record.readInt();
1749 E->CXXNewExprBits.StoredInitializationStyle = Record.readInt();
1751 assert((IsArray == E->isArray()) && "Wrong IsArray!");
1752 assert((HasInit == E->hasInitializer()) && "Wrong HasInit!");
1753 assert((NumPlacementArgs == E->getNumPlacementArgs()) &&
1754 "Wrong NumPlacementArgs!");
1755 assert((IsParenTypeId == E->isParenTypeId()) && "Wrong IsParenTypeId!");
1758 (void)NumPlacementArgs;
1760 E->setOperatorNew(readDeclAs<FunctionDecl>());
1761 E->setOperatorDelete(readDeclAs<FunctionDecl>());
1762 E->AllocatedTypeInfo = readTypeSourceInfo();
1764 E->getTrailingObjects<SourceRange>()[0] = readSourceRange();
1765 E->Range = readSourceRange();
1766 E->DirectInitRange = readSourceRange();
1768 // Install all the subexpressions.
1769 for (CXXNewExpr::raw_arg_iterator I = E->raw_arg_begin(),
1770 N = E->raw_arg_end();
1772 *I = Record.readSubStmt();
1775 void ASTStmtReader::VisitCXXDeleteExpr(CXXDeleteExpr *E) {
1777 E->CXXDeleteExprBits.GlobalDelete = Record.readInt();
1778 E->CXXDeleteExprBits.ArrayForm = Record.readInt();
1779 E->CXXDeleteExprBits.ArrayFormAsWritten = Record.readInt();
1780 E->CXXDeleteExprBits.UsualArrayDeleteWantsSize = Record.readInt();
1781 E->OperatorDelete = readDeclAs<FunctionDecl>();
1782 E->Argument = Record.readSubExpr();
1783 E->CXXDeleteExprBits.Loc = readSourceLocation();
1786 void ASTStmtReader::VisitCXXPseudoDestructorExpr(CXXPseudoDestructorExpr *E) {
1789 E->Base = Record.readSubExpr();
1790 E->IsArrow = Record.readInt();
1791 E->OperatorLoc = readSourceLocation();
1792 E->QualifierLoc = Record.readNestedNameSpecifierLoc();
1793 E->ScopeType = readTypeSourceInfo();
1794 E->ColonColonLoc = readSourceLocation();
1795 E->TildeLoc = readSourceLocation();
1797 IdentifierInfo *II = Record.readIdentifier();
1799 E->setDestroyedType(II, readSourceLocation());
1801 E->setDestroyedType(readTypeSourceInfo());
1804 void ASTStmtReader::VisitExprWithCleanups(ExprWithCleanups *E) {
1807 unsigned NumObjects = Record.readInt();
1808 assert(NumObjects == E->getNumObjects());
1809 for (unsigned i = 0; i != NumObjects; ++i)
1810 E->getTrailingObjects<BlockDecl *>()[i] =
1811 readDeclAs<BlockDecl>();
1813 E->ExprWithCleanupsBits.CleanupsHaveSideEffects = Record.readInt();
1814 E->SubExpr = Record.readSubExpr();
1817 void ASTStmtReader::VisitCXXDependentScopeMemberExpr(
1818 CXXDependentScopeMemberExpr *E) {
1821 bool HasTemplateKWAndArgsInfo = Record.readInt();
1822 unsigned NumTemplateArgs = Record.readInt();
1823 bool HasFirstQualifierFoundInScope = Record.readInt();
1825 assert((HasTemplateKWAndArgsInfo == E->hasTemplateKWAndArgsInfo()) &&
1826 "Wrong HasTemplateKWAndArgsInfo!");
1828 (HasFirstQualifierFoundInScope == E->hasFirstQualifierFoundInScope()) &&
1829 "Wrong HasFirstQualifierFoundInScope!");
1831 if (HasTemplateKWAndArgsInfo)
1832 ReadTemplateKWAndArgsInfo(
1833 *E->getTrailingObjects<ASTTemplateKWAndArgsInfo>(),
1834 E->getTrailingObjects<TemplateArgumentLoc>(), NumTemplateArgs);
1836 assert((NumTemplateArgs == E->getNumTemplateArgs()) &&
1837 "Wrong NumTemplateArgs!");
1839 E->CXXDependentScopeMemberExprBits.IsArrow = Record.readInt();
1840 E->CXXDependentScopeMemberExprBits.OperatorLoc = readSourceLocation();
1841 E->BaseType = Record.readType();
1842 E->QualifierLoc = Record.readNestedNameSpecifierLoc();
1843 E->Base = Record.readSubExpr();
1845 if (HasFirstQualifierFoundInScope)
1846 *E->getTrailingObjects<NamedDecl *>() = readDeclAs<NamedDecl>();
1848 E->MemberNameInfo = Record.readDeclarationNameInfo();
1852 ASTStmtReader::VisitDependentScopeDeclRefExpr(DependentScopeDeclRefExpr *E) {
1855 if (Record.readInt()) // HasTemplateKWAndArgsInfo
1856 ReadTemplateKWAndArgsInfo(
1857 *E->getTrailingObjects<ASTTemplateKWAndArgsInfo>(),
1858 E->getTrailingObjects<TemplateArgumentLoc>(),
1859 /*NumTemplateArgs=*/Record.readInt());
1861 E->QualifierLoc = Record.readNestedNameSpecifierLoc();
1862 E->NameInfo = Record.readDeclarationNameInfo();
1866 ASTStmtReader::VisitCXXUnresolvedConstructExpr(CXXUnresolvedConstructExpr *E) {
1868 assert(Record.peekInt() == E->arg_size() &&
1869 "Read wrong record during creation ?");
1871 for (unsigned I = 0, N = E->arg_size(); I != N; ++I)
1872 E->setArg(I, Record.readSubExpr());
1873 E->TSI = readTypeSourceInfo();
1874 E->setLParenLoc(readSourceLocation());
1875 E->setRParenLoc(readSourceLocation());
1878 void ASTStmtReader::VisitOverloadExpr(OverloadExpr *E) {
1881 unsigned NumResults = Record.readInt();
1882 bool HasTemplateKWAndArgsInfo = Record.readInt();
1883 assert((E->getNumDecls() == NumResults) && "Wrong NumResults!");
1884 assert((E->hasTemplateKWAndArgsInfo() == HasTemplateKWAndArgsInfo) &&
1885 "Wrong HasTemplateKWAndArgsInfo!");
1887 if (HasTemplateKWAndArgsInfo) {
1888 unsigned NumTemplateArgs = Record.readInt();
1889 ReadTemplateKWAndArgsInfo(*E->getTrailingASTTemplateKWAndArgsInfo(),
1890 E->getTrailingTemplateArgumentLoc(),
1892 assert((E->getNumTemplateArgs() == NumTemplateArgs) &&
1893 "Wrong NumTemplateArgs!");
1896 UnresolvedSet<8> Decls;
1897 for (unsigned I = 0; I != NumResults; ++I) {
1898 auto *D = readDeclAs<NamedDecl>();
1899 auto AS = (AccessSpecifier)Record.readInt();
1900 Decls.addDecl(D, AS);
1903 DeclAccessPair *Results = E->getTrailingResults();
1904 UnresolvedSetIterator Iter = Decls.begin();
1905 for (unsigned I = 0; I != NumResults; ++I) {
1906 Results[I] = (Iter + I).getPair();
1909 E->NameInfo = Record.readDeclarationNameInfo();
1910 E->QualifierLoc = Record.readNestedNameSpecifierLoc();
1913 void ASTStmtReader::VisitUnresolvedMemberExpr(UnresolvedMemberExpr *E) {
1914 VisitOverloadExpr(E);
1915 E->UnresolvedMemberExprBits.IsArrow = Record.readInt();
1916 E->UnresolvedMemberExprBits.HasUnresolvedUsing = Record.readInt();
1917 E->Base = Record.readSubExpr();
1918 E->BaseType = Record.readType();
1919 E->OperatorLoc = readSourceLocation();
1922 void ASTStmtReader::VisitUnresolvedLookupExpr(UnresolvedLookupExpr *E) {
1923 VisitOverloadExpr(E);
1924 E->UnresolvedLookupExprBits.RequiresADL = Record.readInt();
1925 E->UnresolvedLookupExprBits.Overloaded = Record.readInt();
1926 E->NamingClass = readDeclAs<CXXRecordDecl>();
1929 void ASTStmtReader::VisitTypeTraitExpr(TypeTraitExpr *E) {
1931 E->TypeTraitExprBits.NumArgs = Record.readInt();
1932 E->TypeTraitExprBits.Kind = Record.readInt();
1933 E->TypeTraitExprBits.Value = Record.readInt();
1934 SourceRange Range = readSourceRange();
1935 E->Loc = Range.getBegin();
1936 E->RParenLoc = Range.getEnd();
1938 auto **Args = E->getTrailingObjects<TypeSourceInfo *>();
1939 for (unsigned I = 0, N = E->getNumArgs(); I != N; ++I)
1940 Args[I] = readTypeSourceInfo();
1943 void ASTStmtReader::VisitArrayTypeTraitExpr(ArrayTypeTraitExpr *E) {
1945 E->ATT = (ArrayTypeTrait)Record.readInt();
1946 E->Value = (unsigned int)Record.readInt();
1947 SourceRange Range = readSourceRange();
1948 E->Loc = Range.getBegin();
1949 E->RParen = Range.getEnd();
1950 E->QueriedType = readTypeSourceInfo();
1951 E->Dimension = Record.readSubExpr();
1954 void ASTStmtReader::VisitExpressionTraitExpr(ExpressionTraitExpr *E) {
1956 E->ET = (ExpressionTrait)Record.readInt();
1957 E->Value = (bool)Record.readInt();
1958 SourceRange Range = readSourceRange();
1959 E->QueriedExpression = Record.readSubExpr();
1960 E->Loc = Range.getBegin();
1961 E->RParen = Range.getEnd();
1964 void ASTStmtReader::VisitCXXNoexceptExpr(CXXNoexceptExpr *E) {
1966 E->CXXNoexceptExprBits.Value = Record.readInt();
1967 E->Range = readSourceRange();
1968 E->Operand = Record.readSubExpr();
1971 void ASTStmtReader::VisitPackExpansionExpr(PackExpansionExpr *E) {
1973 E->EllipsisLoc = readSourceLocation();
1974 E->NumExpansions = Record.readInt();
1975 E->Pattern = Record.readSubExpr();
1978 void ASTStmtReader::VisitSizeOfPackExpr(SizeOfPackExpr *E) {
1980 unsigned NumPartialArgs = Record.readInt();
1981 E->OperatorLoc = readSourceLocation();
1982 E->PackLoc = readSourceLocation();
1983 E->RParenLoc = readSourceLocation();
1984 E->Pack = Record.readDeclAs<NamedDecl>();
1985 if (E->isPartiallySubstituted()) {
1986 assert(E->Length == NumPartialArgs);
1987 for (auto *I = E->getTrailingObjects<TemplateArgument>(),
1988 *E = I + NumPartialArgs;
1990 new (I) TemplateArgument(Record.readTemplateArgument());
1991 } else if (!E->isValueDependent()) {
1992 E->Length = Record.readInt();
1996 void ASTStmtReader::VisitSubstNonTypeTemplateParmExpr(
1997 SubstNonTypeTemplateParmExpr *E) {
1999 E->Param = readDeclAs<NonTypeTemplateParmDecl>();
2000 E->SubstNonTypeTemplateParmExprBits.NameLoc = readSourceLocation();
2001 E->Replacement = Record.readSubExpr();
2004 void ASTStmtReader::VisitSubstNonTypeTemplateParmPackExpr(
2005 SubstNonTypeTemplateParmPackExpr *E) {
2007 E->Param = readDeclAs<NonTypeTemplateParmDecl>();
2008 TemplateArgument ArgPack = Record.readTemplateArgument();
2009 if (ArgPack.getKind() != TemplateArgument::Pack)
2012 E->Arguments = ArgPack.pack_begin();
2013 E->NumArguments = ArgPack.pack_size();
2014 E->NameLoc = readSourceLocation();
2017 void ASTStmtReader::VisitFunctionParmPackExpr(FunctionParmPackExpr *E) {
2019 E->NumParameters = Record.readInt();
2020 E->ParamPack = readDeclAs<ParmVarDecl>();
2021 E->NameLoc = readSourceLocation();
2022 auto **Parms = E->getTrailingObjects<VarDecl *>();
2023 for (unsigned i = 0, n = E->NumParameters; i != n; ++i)
2024 Parms[i] = readDeclAs<VarDecl>();
2027 void ASTStmtReader::VisitMaterializeTemporaryExpr(MaterializeTemporaryExpr *E) {
2029 bool HasMaterialzedDecl = Record.readInt();
2030 if (HasMaterialzedDecl)
2031 E->State = cast<LifetimeExtendedTemporaryDecl>(Record.readDecl());
2033 E->State = Record.readSubExpr();
2036 void ASTStmtReader::VisitCXXFoldExpr(CXXFoldExpr *E) {
2038 E->LParenLoc = readSourceLocation();
2039 E->EllipsisLoc = readSourceLocation();
2040 E->RParenLoc = readSourceLocation();
2041 E->NumExpansions = Record.readInt();
2042 E->SubExprs[0] = Record.readSubExpr();
2043 E->SubExprs[1] = Record.readSubExpr();
2044 E->Opcode = (BinaryOperatorKind)Record.readInt();
2047 void ASTStmtReader::VisitOpaqueValueExpr(OpaqueValueExpr *E) {
2049 E->SourceExpr = Record.readSubExpr();
2050 E->OpaqueValueExprBits.Loc = readSourceLocation();
2051 E->setIsUnique(Record.readInt());
2054 void ASTStmtReader::VisitTypoExpr(TypoExpr *E) {
2055 llvm_unreachable("Cannot read TypoExpr nodes");
2058 //===----------------------------------------------------------------------===//
2059 // Microsoft Expressions and Statements
2060 //===----------------------------------------------------------------------===//
2061 void ASTStmtReader::VisitMSPropertyRefExpr(MSPropertyRefExpr *E) {
2063 E->IsArrow = (Record.readInt() != 0);
2064 E->BaseExpr = Record.readSubExpr();
2065 E->QualifierLoc = Record.readNestedNameSpecifierLoc();
2066 E->MemberLoc = readSourceLocation();
2067 E->TheDecl = readDeclAs<MSPropertyDecl>();
2070 void ASTStmtReader::VisitMSPropertySubscriptExpr(MSPropertySubscriptExpr *E) {
2072 E->setBase(Record.readSubExpr());
2073 E->setIdx(Record.readSubExpr());
2074 E->setRBracketLoc(readSourceLocation());
2077 void ASTStmtReader::VisitCXXUuidofExpr(CXXUuidofExpr *E) {
2079 E->setSourceRange(readSourceRange());
2080 std::string UuidStr = readString();
2081 E->setUuidStr(StringRef(UuidStr).copy(Record.getContext()));
2082 if (E->isTypeOperand()) { // __uuidof(ComType)
2083 E->setTypeOperandSourceInfo(
2084 readTypeSourceInfo());
2089 E->setExprOperand(Record.readSubExpr());
2092 void ASTStmtReader::VisitSEHLeaveStmt(SEHLeaveStmt *S) {
2094 S->setLeaveLoc(readSourceLocation());
2097 void ASTStmtReader::VisitSEHExceptStmt(SEHExceptStmt *S) {
2099 S->Loc = readSourceLocation();
2100 S->Children[SEHExceptStmt::FILTER_EXPR] = Record.readSubStmt();
2101 S->Children[SEHExceptStmt::BLOCK] = Record.readSubStmt();
2104 void ASTStmtReader::VisitSEHFinallyStmt(SEHFinallyStmt *S) {
2106 S->Loc = readSourceLocation();
2107 S->Block = Record.readSubStmt();
2110 void ASTStmtReader::VisitSEHTryStmt(SEHTryStmt *S) {
2112 S->IsCXXTry = Record.readInt();
2113 S->TryLoc = readSourceLocation();
2114 S->Children[SEHTryStmt::TRY] = Record.readSubStmt();
2115 S->Children[SEHTryStmt::HANDLER] = Record.readSubStmt();
2118 //===----------------------------------------------------------------------===//
2119 // CUDA Expressions and Statements
2120 //===----------------------------------------------------------------------===//
2122 void ASTStmtReader::VisitCUDAKernelCallExpr(CUDAKernelCallExpr *E) {
2124 E->setPreArg(CUDAKernelCallExpr::CONFIG, Record.readSubExpr());
2127 //===----------------------------------------------------------------------===//
2128 // OpenCL Expressions and Statements.
2129 //===----------------------------------------------------------------------===//
2130 void ASTStmtReader::VisitAsTypeExpr(AsTypeExpr *E) {
2132 E->BuiltinLoc = readSourceLocation();
2133 E->RParenLoc = readSourceLocation();
2134 E->SrcExpr = Record.readSubExpr();
2137 //===----------------------------------------------------------------------===//
2138 // OpenMP Directives.
2139 //===----------------------------------------------------------------------===//
2141 void ASTStmtReader::VisitOMPExecutableDirective(OMPExecutableDirective *E) {
2142 E->setLocStart(readSourceLocation());
2143 E->setLocEnd(readSourceLocation());
2144 SmallVector<OMPClause *, 5> Clauses;
2145 for (unsigned i = 0; i < E->getNumClauses(); ++i)
2146 Clauses.push_back(Record.readOMPClause());
2147 E->setClauses(Clauses);
2148 if (E->hasAssociatedStmt())
2149 E->setAssociatedStmt(Record.readSubStmt());
2152 void ASTStmtReader::VisitOMPLoopDirective(OMPLoopDirective *D) {
2154 // Two fields (NumClauses and CollapsedNum) were read in ReadStmtFromStream.
2156 VisitOMPExecutableDirective(D);
2157 D->setIterationVariable(Record.readSubExpr());
2158 D->setLastIteration(Record.readSubExpr());
2159 D->setCalcLastIteration(Record.readSubExpr());
2160 D->setPreCond(Record.readSubExpr());
2161 D->setCond(Record.readSubExpr());
2162 D->setInit(Record.readSubExpr());
2163 D->setInc(Record.readSubExpr());
2164 D->setPreInits(Record.readSubStmt());
2165 if (isOpenMPWorksharingDirective(D->getDirectiveKind()) ||
2166 isOpenMPTaskLoopDirective(D->getDirectiveKind()) ||
2167 isOpenMPDistributeDirective(D->getDirectiveKind())) {
2168 D->setIsLastIterVariable(Record.readSubExpr());
2169 D->setLowerBoundVariable(Record.readSubExpr());
2170 D->setUpperBoundVariable(Record.readSubExpr());
2171 D->setStrideVariable(Record.readSubExpr());
2172 D->setEnsureUpperBound(Record.readSubExpr());
2173 D->setNextLowerBound(Record.readSubExpr());
2174 D->setNextUpperBound(Record.readSubExpr());
2175 D->setNumIterations(Record.readSubExpr());
2177 if (isOpenMPLoopBoundSharingDirective(D->getDirectiveKind())) {
2178 D->setPrevLowerBoundVariable(Record.readSubExpr());
2179 D->setPrevUpperBoundVariable(Record.readSubExpr());
2180 D->setDistInc(Record.readSubExpr());
2181 D->setPrevEnsureUpperBound(Record.readSubExpr());
2182 D->setCombinedLowerBoundVariable(Record.readSubExpr());
2183 D->setCombinedUpperBoundVariable(Record.readSubExpr());
2184 D->setCombinedEnsureUpperBound(Record.readSubExpr());
2185 D->setCombinedInit(Record.readSubExpr());
2186 D->setCombinedCond(Record.readSubExpr());
2187 D->setCombinedNextLowerBound(Record.readSubExpr());
2188 D->setCombinedNextUpperBound(Record.readSubExpr());
2189 D->setCombinedDistCond(Record.readSubExpr());
2190 D->setCombinedParForInDistCond(Record.readSubExpr());
2192 SmallVector<Expr *, 4> Sub;
2193 unsigned CollapsedNum = D->getCollapsedNumber();
2194 Sub.reserve(CollapsedNum);
2195 for (unsigned i = 0; i < CollapsedNum; ++i)
2196 Sub.push_back(Record.readSubExpr());
2197 D->setCounters(Sub);
2199 for (unsigned i = 0; i < CollapsedNum; ++i)
2200 Sub.push_back(Record.readSubExpr());
2201 D->setPrivateCounters(Sub);
2203 for (unsigned i = 0; i < CollapsedNum; ++i)
2204 Sub.push_back(Record.readSubExpr());
2207 for (unsigned i = 0; i < CollapsedNum; ++i)
2208 Sub.push_back(Record.readSubExpr());
2211 for (unsigned i = 0; i < CollapsedNum; ++i)
2212 Sub.push_back(Record.readSubExpr());
2215 for (unsigned i = 0; i < CollapsedNum; ++i)
2216 Sub.push_back(Record.readSubExpr());
2217 D->setDependentCounters(Sub);
2219 for (unsigned i = 0; i < CollapsedNum; ++i)
2220 Sub.push_back(Record.readSubExpr());
2221 D->setDependentInits(Sub);
2223 for (unsigned i = 0; i < CollapsedNum; ++i)
2224 Sub.push_back(Record.readSubExpr());
2225 D->setFinalsConditions(Sub);
2228 void ASTStmtReader::VisitOMPParallelDirective(OMPParallelDirective *D) {
2230 // The NumClauses field was read in ReadStmtFromStream.
2232 VisitOMPExecutableDirective(D);
2233 D->setHasCancel(Record.readInt());
2236 void ASTStmtReader::VisitOMPSimdDirective(OMPSimdDirective *D) {
2237 VisitOMPLoopDirective(D);
2240 void ASTStmtReader::VisitOMPForDirective(OMPForDirective *D) {
2241 VisitOMPLoopDirective(D);
2242 D->setHasCancel(Record.readInt());
2245 void ASTStmtReader::VisitOMPForSimdDirective(OMPForSimdDirective *D) {
2246 VisitOMPLoopDirective(D);
2249 void ASTStmtReader::VisitOMPSectionsDirective(OMPSectionsDirective *D) {
2251 // The NumClauses field was read in ReadStmtFromStream.
2253 VisitOMPExecutableDirective(D);
2254 D->setHasCancel(Record.readInt());
2257 void ASTStmtReader::VisitOMPSectionDirective(OMPSectionDirective *D) {
2259 VisitOMPExecutableDirective(D);
2260 D->setHasCancel(Record.readInt());
2263 void ASTStmtReader::VisitOMPSingleDirective(OMPSingleDirective *D) {
2265 // The NumClauses field was read in ReadStmtFromStream.
2267 VisitOMPExecutableDirective(D);
2270 void ASTStmtReader::VisitOMPMasterDirective(OMPMasterDirective *D) {
2272 VisitOMPExecutableDirective(D);
2275 void ASTStmtReader::VisitOMPCriticalDirective(OMPCriticalDirective *D) {
2277 // The NumClauses field was read in ReadStmtFromStream.
2279 VisitOMPExecutableDirective(D);
2280 D->DirName = Record.readDeclarationNameInfo();
2283 void ASTStmtReader::VisitOMPParallelForDirective(OMPParallelForDirective *D) {
2284 VisitOMPLoopDirective(D);
2285 D->setHasCancel(Record.readInt());
2288 void ASTStmtReader::VisitOMPParallelForSimdDirective(
2289 OMPParallelForSimdDirective *D) {
2290 VisitOMPLoopDirective(D);
2293 void ASTStmtReader::VisitOMPParallelMasterDirective(
2294 OMPParallelMasterDirective *D) {
2296 // The NumClauses field was read in ReadStmtFromStream.
2298 VisitOMPExecutableDirective(D);
2301 void ASTStmtReader::VisitOMPParallelSectionsDirective(
2302 OMPParallelSectionsDirective *D) {
2304 // The NumClauses field was read in ReadStmtFromStream.
2306 VisitOMPExecutableDirective(D);
2307 D->setHasCancel(Record.readInt());
2310 void ASTStmtReader::VisitOMPTaskDirective(OMPTaskDirective *D) {
2312 // The NumClauses field was read in ReadStmtFromStream.
2314 VisitOMPExecutableDirective(D);
2315 D->setHasCancel(Record.readInt());
2318 void ASTStmtReader::VisitOMPTaskyieldDirective(OMPTaskyieldDirective *D) {
2320 VisitOMPExecutableDirective(D);
2323 void ASTStmtReader::VisitOMPBarrierDirective(OMPBarrierDirective *D) {
2325 VisitOMPExecutableDirective(D);
2328 void ASTStmtReader::VisitOMPTaskwaitDirective(OMPTaskwaitDirective *D) {
2330 VisitOMPExecutableDirective(D);
2333 void ASTStmtReader::VisitOMPTaskgroupDirective(OMPTaskgroupDirective *D) {
2335 // The NumClauses field was read in ReadStmtFromStream.
2337 VisitOMPExecutableDirective(D);
2338 D->setReductionRef(Record.readSubExpr());
2341 void ASTStmtReader::VisitOMPFlushDirective(OMPFlushDirective *D) {
2343 // The NumClauses field was read in ReadStmtFromStream.
2345 VisitOMPExecutableDirective(D);
2348 void ASTStmtReader::VisitOMPOrderedDirective(OMPOrderedDirective *D) {
2350 // The NumClauses field was read in ReadStmtFromStream.
2352 VisitOMPExecutableDirective(D);
2355 void ASTStmtReader::VisitOMPAtomicDirective(OMPAtomicDirective *D) {
2357 // The NumClauses field was read in ReadStmtFromStream.
2359 VisitOMPExecutableDirective(D);
2360 D->setX(Record.readSubExpr());
2361 D->setV(Record.readSubExpr());
2362 D->setExpr(Record.readSubExpr());
2363 D->setUpdateExpr(Record.readSubExpr());
2364 D->IsXLHSInRHSPart = Record.readInt() != 0;
2365 D->IsPostfixUpdate = Record.readInt() != 0;
2368 void ASTStmtReader::VisitOMPTargetDirective(OMPTargetDirective *D) {
2370 // The NumClauses field was read in ReadStmtFromStream.
2372 VisitOMPExecutableDirective(D);
2375 void ASTStmtReader::VisitOMPTargetDataDirective(OMPTargetDataDirective *D) {
2378 VisitOMPExecutableDirective(D);
2381 void ASTStmtReader::VisitOMPTargetEnterDataDirective(
2382 OMPTargetEnterDataDirective *D) {
2385 VisitOMPExecutableDirective(D);
2388 void ASTStmtReader::VisitOMPTargetExitDataDirective(
2389 OMPTargetExitDataDirective *D) {
2392 VisitOMPExecutableDirective(D);
2395 void ASTStmtReader::VisitOMPTargetParallelDirective(
2396 OMPTargetParallelDirective *D) {
2399 VisitOMPExecutableDirective(D);
2402 void ASTStmtReader::VisitOMPTargetParallelForDirective(
2403 OMPTargetParallelForDirective *D) {
2404 VisitOMPLoopDirective(D);
2405 D->setHasCancel(Record.readInt());
2408 void ASTStmtReader::VisitOMPTeamsDirective(OMPTeamsDirective *D) {
2410 // The NumClauses field was read in ReadStmtFromStream.
2412 VisitOMPExecutableDirective(D);
2415 void ASTStmtReader::VisitOMPCancellationPointDirective(
2416 OMPCancellationPointDirective *D) {
2418 VisitOMPExecutableDirective(D);
2419 D->setCancelRegion(static_cast<OpenMPDirectiveKind>(Record.readInt()));
2422 void ASTStmtReader::VisitOMPCancelDirective(OMPCancelDirective *D) {
2424 // The NumClauses field was read in ReadStmtFromStream.
2426 VisitOMPExecutableDirective(D);
2427 D->setCancelRegion(static_cast<OpenMPDirectiveKind>(Record.readInt()));
2430 void ASTStmtReader::VisitOMPTaskLoopDirective(OMPTaskLoopDirective *D) {
2431 VisitOMPLoopDirective(D);
2434 void ASTStmtReader::VisitOMPTaskLoopSimdDirective(OMPTaskLoopSimdDirective *D) {
2435 VisitOMPLoopDirective(D);
2438 void ASTStmtReader::VisitOMPMasterTaskLoopDirective(
2439 OMPMasterTaskLoopDirective *D) {
2440 VisitOMPLoopDirective(D);
2443 void ASTStmtReader::VisitOMPMasterTaskLoopSimdDirective(
2444 OMPMasterTaskLoopSimdDirective *D) {
2445 VisitOMPLoopDirective(D);
2448 void ASTStmtReader::VisitOMPParallelMasterTaskLoopDirective(
2449 OMPParallelMasterTaskLoopDirective *D) {
2450 VisitOMPLoopDirective(D);
2453 void ASTStmtReader::VisitOMPParallelMasterTaskLoopSimdDirective(
2454 OMPParallelMasterTaskLoopSimdDirective *D) {
2455 VisitOMPLoopDirective(D);
2458 void ASTStmtReader::VisitOMPDistributeDirective(OMPDistributeDirective *D) {
2459 VisitOMPLoopDirective(D);
2462 void ASTStmtReader::VisitOMPTargetUpdateDirective(OMPTargetUpdateDirective *D) {
2465 VisitOMPExecutableDirective(D);
2468 void ASTStmtReader::VisitOMPDistributeParallelForDirective(
2469 OMPDistributeParallelForDirective *D) {
2470 VisitOMPLoopDirective(D);
2471 D->setHasCancel(Record.readInt());
2474 void ASTStmtReader::VisitOMPDistributeParallelForSimdDirective(
2475 OMPDistributeParallelForSimdDirective *D) {
2476 VisitOMPLoopDirective(D);
2479 void ASTStmtReader::VisitOMPDistributeSimdDirective(
2480 OMPDistributeSimdDirective *D) {
2481 VisitOMPLoopDirective(D);
2484 void ASTStmtReader::VisitOMPTargetParallelForSimdDirective(
2485 OMPTargetParallelForSimdDirective *D) {
2486 VisitOMPLoopDirective(D);
2489 void ASTStmtReader::VisitOMPTargetSimdDirective(OMPTargetSimdDirective *D) {
2490 VisitOMPLoopDirective(D);
2493 void ASTStmtReader::VisitOMPTeamsDistributeDirective(
2494 OMPTeamsDistributeDirective *D) {
2495 VisitOMPLoopDirective(D);
2498 void ASTStmtReader::VisitOMPTeamsDistributeSimdDirective(
2499 OMPTeamsDistributeSimdDirective *D) {
2500 VisitOMPLoopDirective(D);
2503 void ASTStmtReader::VisitOMPTeamsDistributeParallelForSimdDirective(
2504 OMPTeamsDistributeParallelForSimdDirective *D) {
2505 VisitOMPLoopDirective(D);
2508 void ASTStmtReader::VisitOMPTeamsDistributeParallelForDirective(
2509 OMPTeamsDistributeParallelForDirective *D) {
2510 VisitOMPLoopDirective(D);
2511 D->setHasCancel(Record.readInt());
2514 void ASTStmtReader::VisitOMPTargetTeamsDirective(OMPTargetTeamsDirective *D) {
2516 // The NumClauses field was read in ReadStmtFromStream.
2518 VisitOMPExecutableDirective(D);
2521 void ASTStmtReader::VisitOMPTargetTeamsDistributeDirective(
2522 OMPTargetTeamsDistributeDirective *D) {
2523 VisitOMPLoopDirective(D);
2526 void ASTStmtReader::VisitOMPTargetTeamsDistributeParallelForDirective(
2527 OMPTargetTeamsDistributeParallelForDirective *D) {
2528 VisitOMPLoopDirective(D);
2529 D->setHasCancel(Record.readInt());
2532 void ASTStmtReader::VisitOMPTargetTeamsDistributeParallelForSimdDirective(
2533 OMPTargetTeamsDistributeParallelForSimdDirective *D) {
2534 VisitOMPLoopDirective(D);
2537 void ASTStmtReader::VisitOMPTargetTeamsDistributeSimdDirective(
2538 OMPTargetTeamsDistributeSimdDirective *D) {
2539 VisitOMPLoopDirective(D);
2542 //===----------------------------------------------------------------------===//
2543 // ASTReader Implementation
2544 //===----------------------------------------------------------------------===//
2546 Stmt *ASTReader::ReadStmt(ModuleFile &F) {
2547 switch (ReadingKind) {
2549 llvm_unreachable("should not call this when not reading anything");
2552 return ReadStmtFromStream(F);
2554 return ReadSubStmt();
2557 llvm_unreachable("ReadingKind not set ?");
2560 Expr *ASTReader::ReadExpr(ModuleFile &F) {
2561 return cast_or_null<Expr>(ReadStmt(F));
2564 Expr *ASTReader::ReadSubExpr() {
2565 return cast_or_null<Expr>(ReadSubStmt());
2568 // Within the bitstream, expressions are stored in Reverse Polish
2569 // Notation, with each of the subexpressions preceding the
2570 // expression they are stored in. Subexpressions are stored from last to first.
2571 // To evaluate expressions, we continue reading expressions and placing them on
2572 // the stack, with expressions having operands removing those operands from the
2573 // stack. Evaluation terminates when we see a STMT_STOP record, and
2574 // the single remaining expression on the stack is our result.
2575 Stmt *ASTReader::ReadStmtFromStream(ModuleFile &F) {
2576 ReadingKindTracker ReadingKind(Read_Stmt, *this);
2577 llvm::BitstreamCursor &Cursor = F.DeclsCursor;
2579 // Map of offset to previously deserialized stmt. The offset points
2580 // just after the stmt record.
2581 llvm::DenseMap<uint64_t, Stmt *> StmtEntries;
2584 unsigned PrevNumStmts = StmtStack.size();
2587 ASTRecordReader Record(*this, F);
2588 ASTStmtReader Reader(Record, Cursor);
2589 Stmt::EmptyShell Empty;
2592 llvm::Expected<llvm::BitstreamEntry> MaybeEntry =
2593 Cursor.advanceSkippingSubblocks();
2595 Error(toString(MaybeEntry.takeError()));
2598 llvm::BitstreamEntry Entry = MaybeEntry.get();
2600 switch (Entry.Kind) {
2601 case llvm::BitstreamEntry::SubBlock: // Handled for us already.
2602 case llvm::BitstreamEntry::Error:
2603 Error("malformed block record in AST file");
2605 case llvm::BitstreamEntry::EndBlock:
2607 case llvm::BitstreamEntry::Record:
2608 // The interesting case.
2612 ASTContext &Context = getContext();
2614 bool Finished = false;
2615 bool IsStmtReference = false;
2616 Expected<unsigned> MaybeStmtCode = Record.readRecord(Cursor, Entry.ID);
2617 if (!MaybeStmtCode) {
2618 Error(toString(MaybeStmtCode.takeError()));
2621 switch ((StmtCode)MaybeStmtCode.get()) {
2627 IsStmtReference = true;
2628 assert(StmtEntries.find(Record[0]) != StmtEntries.end() &&
2629 "No stmt was recorded for this offset reference!");
2630 S = StmtEntries[Record.readInt()];
2638 S = new (Context) NullStmt(Empty);
2642 S = CompoundStmt::CreateEmpty(
2643 Context, /*NumStmts=*/Record[ASTStmtReader::NumStmtFields]);
2647 S = CaseStmt::CreateEmpty(
2649 /*CaseStmtIsGNURange*/ Record[ASTStmtReader::NumStmtFields + 3]);
2653 S = new (Context) DefaultStmt(Empty);
2657 S = new (Context) LabelStmt(Empty);
2660 case STMT_ATTRIBUTED:
2661 S = AttributedStmt::CreateEmpty(
2663 /*NumAttrs*/Record[ASTStmtReader::NumStmtFields]);
2667 S = IfStmt::CreateEmpty(
2669 /* HasElse=*/Record[ASTStmtReader::NumStmtFields + 1],
2670 /* HasVar=*/Record[ASTStmtReader::NumStmtFields + 2],
2671 /* HasInit=*/Record[ASTStmtReader::NumStmtFields + 3]);
2675 S = SwitchStmt::CreateEmpty(
2677 /* HasInit=*/Record[ASTStmtReader::NumStmtFields],
2678 /* HasVar=*/Record[ASTStmtReader::NumStmtFields + 1]);
2682 S = WhileStmt::CreateEmpty(
2684 /* HasVar=*/Record[ASTStmtReader::NumStmtFields]);
2688 S = new (Context) DoStmt(Empty);
2692 S = new (Context) ForStmt(Empty);
2696 S = new (Context) GotoStmt(Empty);
2699 case STMT_INDIRECT_GOTO:
2700 S = new (Context) IndirectGotoStmt(Empty);
2704 S = new (Context) ContinueStmt(Empty);
2708 S = new (Context) BreakStmt(Empty);
2712 S = ReturnStmt::CreateEmpty(
2713 Context, /* HasNRVOCandidate=*/Record[ASTStmtReader::NumStmtFields]);
2717 S = new (Context) DeclStmt(Empty);
2721 S = new (Context) GCCAsmStmt(Empty);
2725 S = new (Context) MSAsmStmt(Empty);
2729 S = CapturedStmt::CreateDeserialized(
2730 Context, Record[ASTStmtReader::NumStmtFields]);
2734 S = ConstantExpr::CreateEmpty(
2736 static_cast<ConstantExpr::ResultStorageKind>(
2737 Record[ASTStmtReader::NumExprFields]),
2741 case EXPR_PREDEFINED:
2742 S = PredefinedExpr::CreateEmpty(
2744 /*HasFunctionName*/ Record[ASTStmtReader::NumExprFields]);
2748 S = DeclRefExpr::CreateEmpty(
2750 /*HasQualifier=*/Record[ASTStmtReader::NumExprFields],
2751 /*HasFoundDecl=*/Record[ASTStmtReader::NumExprFields + 1],
2752 /*HasTemplateKWAndArgsInfo=*/Record[ASTStmtReader::NumExprFields + 2],
2753 /*NumTemplateArgs=*/Record[ASTStmtReader::NumExprFields + 2] ?
2754 Record[ASTStmtReader::NumExprFields + 6] : 0);
2757 case EXPR_INTEGER_LITERAL:
2758 S = IntegerLiteral::Create(Context, Empty);
2761 case EXPR_FLOATING_LITERAL:
2762 S = FloatingLiteral::Create(Context, Empty);
2765 case EXPR_IMAGINARY_LITERAL:
2766 S = new (Context) ImaginaryLiteral(Empty);
2769 case EXPR_STRING_LITERAL:
2770 S = StringLiteral::CreateEmpty(
2772 /* NumConcatenated=*/Record[ASTStmtReader::NumExprFields],
2773 /* Length=*/Record[ASTStmtReader::NumExprFields + 1],
2774 /* CharByteWidth=*/Record[ASTStmtReader::NumExprFields + 2]);
2777 case EXPR_CHARACTER_LITERAL:
2778 S = new (Context) CharacterLiteral(Empty);
2782 S = new (Context) ParenExpr(Empty);
2785 case EXPR_PAREN_LIST:
2786 S = ParenListExpr::CreateEmpty(
2788 /* NumExprs=*/Record[ASTStmtReader::NumExprFields]);
2791 case EXPR_UNARY_OPERATOR:
2792 S = new (Context) UnaryOperator(Empty);
2796 S = OffsetOfExpr::CreateEmpty(Context,
2797 Record[ASTStmtReader::NumExprFields],
2798 Record[ASTStmtReader::NumExprFields + 1]);
2801 case EXPR_SIZEOF_ALIGN_OF:
2802 S = new (Context) UnaryExprOrTypeTraitExpr(Empty);
2805 case EXPR_ARRAY_SUBSCRIPT:
2806 S = new (Context) ArraySubscriptExpr(Empty);
2809 case EXPR_OMP_ARRAY_SECTION:
2810 S = new (Context) OMPArraySectionExpr(Empty);
2814 S = CallExpr::CreateEmpty(
2815 Context, /*NumArgs=*/Record[ASTStmtReader::NumExprFields], Empty);
2819 S = MemberExpr::CreateEmpty(Context, Record[ASTStmtReader::NumExprFields],
2820 Record[ASTStmtReader::NumExprFields + 1],
2821 Record[ASTStmtReader::NumExprFields + 2],
2822 Record[ASTStmtReader::NumExprFields + 3]);
2825 case EXPR_BINARY_OPERATOR:
2826 S = new (Context) BinaryOperator(Empty);
2829 case EXPR_COMPOUND_ASSIGN_OPERATOR:
2830 S = new (Context) CompoundAssignOperator(Empty);
2833 case EXPR_CONDITIONAL_OPERATOR:
2834 S = new (Context) ConditionalOperator(Empty);
2837 case EXPR_BINARY_CONDITIONAL_OPERATOR:
2838 S = new (Context) BinaryConditionalOperator(Empty);
2841 case EXPR_IMPLICIT_CAST:
2842 S = ImplicitCastExpr::CreateEmpty(Context,
2843 /*PathSize*/ Record[ASTStmtReader::NumExprFields]);
2846 case EXPR_CSTYLE_CAST:
2847 S = CStyleCastExpr::CreateEmpty(Context,
2848 /*PathSize*/ Record[ASTStmtReader::NumExprFields]);
2851 case EXPR_COMPOUND_LITERAL:
2852 S = new (Context) CompoundLiteralExpr(Empty);
2855 case EXPR_EXT_VECTOR_ELEMENT:
2856 S = new (Context) ExtVectorElementExpr(Empty);
2859 case EXPR_INIT_LIST:
2860 S = new (Context) InitListExpr(Empty);
2863 case EXPR_DESIGNATED_INIT:
2864 S = DesignatedInitExpr::CreateEmpty(Context,
2865 Record[ASTStmtReader::NumExprFields] - 1);
2869 case EXPR_DESIGNATED_INIT_UPDATE:
2870 S = new (Context) DesignatedInitUpdateExpr(Empty);
2873 case EXPR_IMPLICIT_VALUE_INIT:
2874 S = new (Context) ImplicitValueInitExpr(Empty);
2878 S = new (Context) NoInitExpr(Empty);
2881 case EXPR_ARRAY_INIT_LOOP:
2882 S = new (Context) ArrayInitLoopExpr(Empty);
2885 case EXPR_ARRAY_INIT_INDEX:
2886 S = new (Context) ArrayInitIndexExpr(Empty);
2890 S = new (Context) VAArgExpr(Empty);
2893 case EXPR_SOURCE_LOC:
2894 S = new (Context) SourceLocExpr(Empty);
2897 case EXPR_ADDR_LABEL:
2898 S = new (Context) AddrLabelExpr(Empty);
2902 S = new (Context) StmtExpr(Empty);
2906 S = new (Context) ChooseExpr(Empty);
2910 S = new (Context) GNUNullExpr(Empty);
2913 case EXPR_SHUFFLE_VECTOR:
2914 S = new (Context) ShuffleVectorExpr(Empty);
2917 case EXPR_CONVERT_VECTOR:
2918 S = new (Context) ConvertVectorExpr(Empty);
2922 S = new (Context) BlockExpr(Empty);
2925 case EXPR_GENERIC_SELECTION:
2926 S = GenericSelectionExpr::CreateEmpty(
2928 /*NumAssocs=*/Record[ASTStmtReader::NumExprFields]);
2931 case EXPR_OBJC_STRING_LITERAL:
2932 S = new (Context) ObjCStringLiteral(Empty);
2935 case EXPR_OBJC_BOXED_EXPRESSION:
2936 S = new (Context) ObjCBoxedExpr(Empty);
2939 case EXPR_OBJC_ARRAY_LITERAL:
2940 S = ObjCArrayLiteral::CreateEmpty(Context,
2941 Record[ASTStmtReader::NumExprFields]);
2944 case EXPR_OBJC_DICTIONARY_LITERAL:
2945 S = ObjCDictionaryLiteral::CreateEmpty(Context,
2946 Record[ASTStmtReader::NumExprFields],
2947 Record[ASTStmtReader::NumExprFields + 1]);
2950 case EXPR_OBJC_ENCODE:
2951 S = new (Context) ObjCEncodeExpr(Empty);
2954 case EXPR_OBJC_SELECTOR_EXPR:
2955 S = new (Context) ObjCSelectorExpr(Empty);
2958 case EXPR_OBJC_PROTOCOL_EXPR:
2959 S = new (Context) ObjCProtocolExpr(Empty);
2962 case EXPR_OBJC_IVAR_REF_EXPR:
2963 S = new (Context) ObjCIvarRefExpr(Empty);
2966 case EXPR_OBJC_PROPERTY_REF_EXPR:
2967 S = new (Context) ObjCPropertyRefExpr(Empty);
2970 case EXPR_OBJC_SUBSCRIPT_REF_EXPR:
2971 S = new (Context) ObjCSubscriptRefExpr(Empty);
2974 case EXPR_OBJC_KVC_REF_EXPR:
2975 llvm_unreachable("mismatching AST file");
2977 case EXPR_OBJC_MESSAGE_EXPR:
2978 S = ObjCMessageExpr::CreateEmpty(Context,
2979 Record[ASTStmtReader::NumExprFields],
2980 Record[ASTStmtReader::NumExprFields + 1]);
2984 S = new (Context) ObjCIsaExpr(Empty);
2987 case EXPR_OBJC_INDIRECT_COPY_RESTORE:
2988 S = new (Context) ObjCIndirectCopyRestoreExpr(Empty);
2991 case EXPR_OBJC_BRIDGED_CAST:
2992 S = new (Context) ObjCBridgedCastExpr(Empty);
2995 case STMT_OBJC_FOR_COLLECTION:
2996 S = new (Context) ObjCForCollectionStmt(Empty);
2999 case STMT_OBJC_CATCH:
3000 S = new (Context) ObjCAtCatchStmt(Empty);
3003 case STMT_OBJC_FINALLY:
3004 S = new (Context) ObjCAtFinallyStmt(Empty);
3007 case STMT_OBJC_AT_TRY:
3008 S = ObjCAtTryStmt::CreateEmpty(Context,
3009 Record[ASTStmtReader::NumStmtFields],
3010 Record[ASTStmtReader::NumStmtFields + 1]);
3013 case STMT_OBJC_AT_SYNCHRONIZED:
3014 S = new (Context) ObjCAtSynchronizedStmt(Empty);
3017 case STMT_OBJC_AT_THROW:
3018 S = new (Context) ObjCAtThrowStmt(Empty);
3021 case STMT_OBJC_AUTORELEASE_POOL:
3022 S = new (Context) ObjCAutoreleasePoolStmt(Empty);
3025 case EXPR_OBJC_BOOL_LITERAL:
3026 S = new (Context) ObjCBoolLiteralExpr(Empty);
3029 case EXPR_OBJC_AVAILABILITY_CHECK:
3030 S = new (Context) ObjCAvailabilityCheckExpr(Empty);
3033 case STMT_SEH_LEAVE:
3034 S = new (Context) SEHLeaveStmt(Empty);
3037 case STMT_SEH_EXCEPT:
3038 S = new (Context) SEHExceptStmt(Empty);
3041 case STMT_SEH_FINALLY:
3042 S = new (Context) SEHFinallyStmt(Empty);
3046 S = new (Context) SEHTryStmt(Empty);
3049 case STMT_CXX_CATCH:
3050 S = new (Context) CXXCatchStmt(Empty);
3054 S = CXXTryStmt::Create(Context, Empty,
3055 /*numHandlers=*/Record[ASTStmtReader::NumStmtFields]);
3058 case STMT_CXX_FOR_RANGE:
3059 S = new (Context) CXXForRangeStmt(Empty);
3062 case STMT_MS_DEPENDENT_EXISTS:
3063 S = new (Context) MSDependentExistsStmt(SourceLocation(), true,
3064 NestedNameSpecifierLoc(),
3065 DeclarationNameInfo(),
3069 case STMT_OMP_PARALLEL_DIRECTIVE:
3071 OMPParallelDirective::CreateEmpty(Context,
3072 Record[ASTStmtReader::NumStmtFields],
3076 case STMT_OMP_SIMD_DIRECTIVE: {
3077 unsigned NumClauses = Record[ASTStmtReader::NumStmtFields];
3078 unsigned CollapsedNum = Record[ASTStmtReader::NumStmtFields + 1];
3079 S = OMPSimdDirective::CreateEmpty(Context, NumClauses,
3080 CollapsedNum, Empty);
3084 case STMT_OMP_FOR_DIRECTIVE: {
3085 unsigned NumClauses = Record[ASTStmtReader::NumStmtFields];
3086 unsigned CollapsedNum = Record[ASTStmtReader::NumStmtFields + 1];
3087 S = OMPForDirective::CreateEmpty(Context, NumClauses, CollapsedNum,
3092 case STMT_OMP_FOR_SIMD_DIRECTIVE: {
3093 unsigned NumClauses = Record[ASTStmtReader::NumStmtFields];
3094 unsigned CollapsedNum = Record[ASTStmtReader::NumStmtFields + 1];
3095 S = OMPForSimdDirective::CreateEmpty(Context, NumClauses, CollapsedNum,
3100 case STMT_OMP_SECTIONS_DIRECTIVE:
3101 S = OMPSectionsDirective::CreateEmpty(
3102 Context, Record[ASTStmtReader::NumStmtFields], Empty);
3105 case STMT_OMP_SECTION_DIRECTIVE:
3106 S = OMPSectionDirective::CreateEmpty(Context, Empty);
3109 case STMT_OMP_SINGLE_DIRECTIVE:
3110 S = OMPSingleDirective::CreateEmpty(
3111 Context, Record[ASTStmtReader::NumStmtFields], Empty);
3114 case STMT_OMP_MASTER_DIRECTIVE:
3115 S = OMPMasterDirective::CreateEmpty(Context, Empty);
3118 case STMT_OMP_CRITICAL_DIRECTIVE:
3119 S = OMPCriticalDirective::CreateEmpty(
3120 Context, Record[ASTStmtReader::NumStmtFields], Empty);
3123 case STMT_OMP_PARALLEL_FOR_DIRECTIVE: {
3124 unsigned NumClauses = Record[ASTStmtReader::NumStmtFields];
3125 unsigned CollapsedNum = Record[ASTStmtReader::NumStmtFields + 1];
3126 S = OMPParallelForDirective::CreateEmpty(Context, NumClauses,
3127 CollapsedNum, Empty);
3131 case STMT_OMP_PARALLEL_FOR_SIMD_DIRECTIVE: {
3132 unsigned NumClauses = Record[ASTStmtReader::NumStmtFields];
3133 unsigned CollapsedNum = Record[ASTStmtReader::NumStmtFields + 1];
3134 S = OMPParallelForSimdDirective::CreateEmpty(Context, NumClauses,
3135 CollapsedNum, Empty);
3139 case STMT_OMP_PARALLEL_MASTER_DIRECTIVE:
3140 S = OMPParallelMasterDirective::CreateEmpty(
3141 Context, Record[ASTStmtReader::NumStmtFields], Empty);
3144 case STMT_OMP_PARALLEL_SECTIONS_DIRECTIVE:
3145 S = OMPParallelSectionsDirective::CreateEmpty(
3146 Context, Record[ASTStmtReader::NumStmtFields], Empty);
3149 case STMT_OMP_TASK_DIRECTIVE:
3150 S = OMPTaskDirective::CreateEmpty(
3151 Context, Record[ASTStmtReader::NumStmtFields], Empty);
3154 case STMT_OMP_TASKYIELD_DIRECTIVE:
3155 S = OMPTaskyieldDirective::CreateEmpty(Context, Empty);
3158 case STMT_OMP_BARRIER_DIRECTIVE:
3159 S = OMPBarrierDirective::CreateEmpty(Context, Empty);
3162 case STMT_OMP_TASKWAIT_DIRECTIVE:
3163 S = OMPTaskwaitDirective::CreateEmpty(Context, Empty);
3166 case STMT_OMP_TASKGROUP_DIRECTIVE:
3167 S = OMPTaskgroupDirective::CreateEmpty(
3168 Context, Record[ASTStmtReader::NumStmtFields], Empty);
3171 case STMT_OMP_FLUSH_DIRECTIVE:
3172 S = OMPFlushDirective::CreateEmpty(
3173 Context, Record[ASTStmtReader::NumStmtFields], Empty);
3176 case STMT_OMP_ORDERED_DIRECTIVE:
3177 S = OMPOrderedDirective::CreateEmpty(
3178 Context, Record[ASTStmtReader::NumStmtFields], Empty);
3181 case STMT_OMP_ATOMIC_DIRECTIVE:
3182 S = OMPAtomicDirective::CreateEmpty(
3183 Context, Record[ASTStmtReader::NumStmtFields], Empty);
3186 case STMT_OMP_TARGET_DIRECTIVE:
3187 S = OMPTargetDirective::CreateEmpty(
3188 Context, Record[ASTStmtReader::NumStmtFields], Empty);
3191 case STMT_OMP_TARGET_DATA_DIRECTIVE:
3192 S = OMPTargetDataDirective::CreateEmpty(
3193 Context, Record[ASTStmtReader::NumStmtFields], Empty);
3196 case STMT_OMP_TARGET_ENTER_DATA_DIRECTIVE:
3197 S = OMPTargetEnterDataDirective::CreateEmpty(
3198 Context, Record[ASTStmtReader::NumStmtFields], Empty);
3201 case STMT_OMP_TARGET_EXIT_DATA_DIRECTIVE:
3202 S = OMPTargetExitDataDirective::CreateEmpty(
3203 Context, Record[ASTStmtReader::NumStmtFields], Empty);
3206 case STMT_OMP_TARGET_PARALLEL_DIRECTIVE:
3207 S = OMPTargetParallelDirective::CreateEmpty(
3208 Context, Record[ASTStmtReader::NumStmtFields], Empty);
3211 case STMT_OMP_TARGET_PARALLEL_FOR_DIRECTIVE: {
3212 unsigned NumClauses = Record[ASTStmtReader::NumStmtFields];
3213 unsigned CollapsedNum = Record[ASTStmtReader::NumStmtFields + 1];
3214 S = OMPTargetParallelForDirective::CreateEmpty(Context, NumClauses,
3215 CollapsedNum, Empty);
3219 case STMT_OMP_TARGET_UPDATE_DIRECTIVE:
3220 S = OMPTargetUpdateDirective::CreateEmpty(
3221 Context, Record[ASTStmtReader::NumStmtFields], Empty);
3224 case STMT_OMP_TEAMS_DIRECTIVE:
3225 S = OMPTeamsDirective::CreateEmpty(
3226 Context, Record[ASTStmtReader::NumStmtFields], Empty);
3229 case STMT_OMP_CANCELLATION_POINT_DIRECTIVE:
3230 S = OMPCancellationPointDirective::CreateEmpty(Context, Empty);
3233 case STMT_OMP_CANCEL_DIRECTIVE:
3234 S = OMPCancelDirective::CreateEmpty(
3235 Context, Record[ASTStmtReader::NumStmtFields], Empty);
3238 case STMT_OMP_TASKLOOP_DIRECTIVE: {
3239 unsigned NumClauses = Record[ASTStmtReader::NumStmtFields];
3240 unsigned CollapsedNum = Record[ASTStmtReader::NumStmtFields + 1];
3241 S = OMPTaskLoopDirective::CreateEmpty(Context, NumClauses, CollapsedNum,
3246 case STMT_OMP_TASKLOOP_SIMD_DIRECTIVE: {
3247 unsigned NumClauses = Record[ASTStmtReader::NumStmtFields];
3248 unsigned CollapsedNum = Record[ASTStmtReader::NumStmtFields + 1];
3249 S = OMPTaskLoopSimdDirective::CreateEmpty(Context, NumClauses,
3250 CollapsedNum, Empty);
3254 case STMT_OMP_MASTER_TASKLOOP_DIRECTIVE: {
3255 unsigned NumClauses = Record[ASTStmtReader::NumStmtFields];
3256 unsigned CollapsedNum = Record[ASTStmtReader::NumStmtFields + 1];
3257 S = OMPMasterTaskLoopDirective::CreateEmpty(Context, NumClauses,
3258 CollapsedNum, Empty);
3262 case STMT_OMP_MASTER_TASKLOOP_SIMD_DIRECTIVE: {
3263 unsigned NumClauses = Record[ASTStmtReader::NumStmtFields];
3264 unsigned CollapsedNum = Record[ASTStmtReader::NumStmtFields + 1];
3265 S = OMPMasterTaskLoopSimdDirective::CreateEmpty(Context, NumClauses,
3266 CollapsedNum, Empty);
3270 case STMT_OMP_PARALLEL_MASTER_TASKLOOP_DIRECTIVE: {
3271 unsigned NumClauses = Record[ASTStmtReader::NumStmtFields];
3272 unsigned CollapsedNum = Record[ASTStmtReader::NumStmtFields + 1];
3273 S = OMPParallelMasterTaskLoopDirective::CreateEmpty(Context, NumClauses,
3274 CollapsedNum, Empty);
3278 case STMT_OMP_PARALLEL_MASTER_TASKLOOP_SIMD_DIRECTIVE: {
3279 unsigned NumClauses = Record[ASTStmtReader::NumStmtFields];
3280 unsigned CollapsedNum = Record[ASTStmtReader::NumStmtFields + 1];
3281 S = OMPParallelMasterTaskLoopSimdDirective::CreateEmpty(
3282 Context, NumClauses, CollapsedNum, Empty);
3286 case STMT_OMP_DISTRIBUTE_DIRECTIVE: {
3287 unsigned NumClauses = Record[ASTStmtReader::NumStmtFields];
3288 unsigned CollapsedNum = Record[ASTStmtReader::NumStmtFields + 1];
3289 S = OMPDistributeDirective::CreateEmpty(Context, NumClauses, CollapsedNum,
3294 case STMT_OMP_DISTRIBUTE_PARALLEL_FOR_DIRECTIVE: {
3295 unsigned NumClauses = Record[ASTStmtReader::NumStmtFields];
3296 unsigned CollapsedNum = Record[ASTStmtReader::NumStmtFields + 1];
3297 S = OMPDistributeParallelForDirective::CreateEmpty(Context, NumClauses,
3298 CollapsedNum, Empty);
3302 case STMT_OMP_DISTRIBUTE_PARALLEL_FOR_SIMD_DIRECTIVE: {
3303 unsigned NumClauses = Record[ASTStmtReader::NumStmtFields];
3304 unsigned CollapsedNum = Record[ASTStmtReader::NumStmtFields + 1];
3305 S = OMPDistributeParallelForSimdDirective::CreateEmpty(Context, NumClauses,
3311 case STMT_OMP_DISTRIBUTE_SIMD_DIRECTIVE: {
3312 unsigned NumClauses = Record[ASTStmtReader::NumStmtFields];
3313 unsigned CollapsedNum = Record[ASTStmtReader::NumStmtFields + 1];
3314 S = OMPDistributeSimdDirective::CreateEmpty(Context, NumClauses,
3315 CollapsedNum, Empty);
3319 case STMT_OMP_TARGET_PARALLEL_FOR_SIMD_DIRECTIVE: {
3320 unsigned NumClauses = Record[ASTStmtReader::NumStmtFields];
3321 unsigned CollapsedNum = Record[ASTStmtReader::NumStmtFields + 1];
3322 S = OMPTargetParallelForSimdDirective::CreateEmpty(Context, NumClauses,
3323 CollapsedNum, Empty);
3327 case STMT_OMP_TARGET_SIMD_DIRECTIVE: {
3328 auto NumClauses = Record[ASTStmtReader::NumStmtFields];
3329 auto CollapsedNum = Record[ASTStmtReader::NumStmtFields + 1];
3330 S = OMPTargetSimdDirective::CreateEmpty(Context, NumClauses, CollapsedNum,
3335 case STMT_OMP_TEAMS_DISTRIBUTE_DIRECTIVE: {
3336 auto NumClauses = Record[ASTStmtReader::NumStmtFields];
3337 auto CollapsedNum = Record[ASTStmtReader::NumStmtFields + 1];
3338 S = OMPTeamsDistributeDirective::CreateEmpty(Context, NumClauses,
3339 CollapsedNum, Empty);
3343 case STMT_OMP_TEAMS_DISTRIBUTE_SIMD_DIRECTIVE: {
3344 unsigned NumClauses = Record[ASTStmtReader::NumStmtFields];
3345 unsigned CollapsedNum = Record[ASTStmtReader::NumStmtFields + 1];
3346 S = OMPTeamsDistributeSimdDirective::CreateEmpty(Context, NumClauses,
3347 CollapsedNum, Empty);
3351 case STMT_OMP_TEAMS_DISTRIBUTE_PARALLEL_FOR_SIMD_DIRECTIVE: {
3352 auto NumClauses = Record[ASTStmtReader::NumStmtFields];
3353 auto CollapsedNum = Record[ASTStmtReader::NumStmtFields + 1];
3354 S = OMPTeamsDistributeParallelForSimdDirective::CreateEmpty(
3355 Context, NumClauses, CollapsedNum, Empty);
3359 case STMT_OMP_TEAMS_DISTRIBUTE_PARALLEL_FOR_DIRECTIVE: {
3360 auto NumClauses = Record[ASTStmtReader::NumStmtFields];
3361 auto CollapsedNum = Record[ASTStmtReader::NumStmtFields + 1];
3362 S = OMPTeamsDistributeParallelForDirective::CreateEmpty(
3363 Context, NumClauses, CollapsedNum, Empty);
3367 case STMT_OMP_TARGET_TEAMS_DIRECTIVE:
3368 S = OMPTargetTeamsDirective::CreateEmpty(
3369 Context, Record[ASTStmtReader::NumStmtFields], Empty);
3372 case STMT_OMP_TARGET_TEAMS_DISTRIBUTE_DIRECTIVE: {
3373 auto NumClauses = Record[ASTStmtReader::NumStmtFields];
3374 auto CollapsedNum = Record[ASTStmtReader::NumStmtFields + 1];
3375 S = OMPTargetTeamsDistributeDirective::CreateEmpty(Context, NumClauses,
3376 CollapsedNum, Empty);
3380 case STMT_OMP_TARGET_TEAMS_DISTRIBUTE_PARALLEL_FOR_DIRECTIVE: {
3381 auto NumClauses = Record[ASTStmtReader::NumStmtFields];
3382 auto CollapsedNum = Record[ASTStmtReader::NumStmtFields + 1];
3383 S = OMPTargetTeamsDistributeParallelForDirective::CreateEmpty(
3384 Context, NumClauses, CollapsedNum, Empty);
3388 case STMT_OMP_TARGET_TEAMS_DISTRIBUTE_PARALLEL_FOR_SIMD_DIRECTIVE: {
3389 auto NumClauses = Record[ASTStmtReader::NumStmtFields];
3390 auto CollapsedNum = Record[ASTStmtReader::NumStmtFields + 1];
3391 S = OMPTargetTeamsDistributeParallelForSimdDirective::CreateEmpty(
3392 Context, NumClauses, CollapsedNum, Empty);
3396 case STMT_OMP_TARGET_TEAMS_DISTRIBUTE_SIMD_DIRECTIVE: {
3397 auto NumClauses = Record[ASTStmtReader::NumStmtFields];
3398 auto CollapsedNum = Record[ASTStmtReader::NumStmtFields + 1];
3399 S = OMPTargetTeamsDistributeSimdDirective::CreateEmpty(
3400 Context, NumClauses, CollapsedNum, Empty);
3404 case EXPR_CXX_OPERATOR_CALL:
3405 S = CXXOperatorCallExpr::CreateEmpty(
3406 Context, /*NumArgs=*/Record[ASTStmtReader::NumExprFields], Empty);
3409 case EXPR_CXX_MEMBER_CALL:
3410 S = CXXMemberCallExpr::CreateEmpty(
3411 Context, /*NumArgs=*/Record[ASTStmtReader::NumExprFields], Empty);
3414 case EXPR_CXX_REWRITTEN_BINARY_OPERATOR:
3415 S = new (Context) CXXRewrittenBinaryOperator(Empty);
3418 case EXPR_CXX_CONSTRUCT:
3419 S = CXXConstructExpr::CreateEmpty(
3421 /* NumArgs=*/Record[ASTStmtReader::NumExprFields]);
3424 case EXPR_CXX_INHERITED_CTOR_INIT:
3425 S = new (Context) CXXInheritedCtorInitExpr(Empty);
3428 case EXPR_CXX_TEMPORARY_OBJECT:
3429 S = CXXTemporaryObjectExpr::CreateEmpty(
3431 /* NumArgs=*/Record[ASTStmtReader::NumExprFields]);
3434 case EXPR_CXX_STATIC_CAST:
3435 S = CXXStaticCastExpr::CreateEmpty(Context,
3436 /*PathSize*/ Record[ASTStmtReader::NumExprFields]);
3439 case EXPR_CXX_DYNAMIC_CAST:
3440 S = CXXDynamicCastExpr::CreateEmpty(Context,
3441 /*PathSize*/ Record[ASTStmtReader::NumExprFields]);
3444 case EXPR_CXX_REINTERPRET_CAST:
3445 S = CXXReinterpretCastExpr::CreateEmpty(Context,
3446 /*PathSize*/ Record[ASTStmtReader::NumExprFields]);
3449 case EXPR_CXX_CONST_CAST:
3450 S = CXXConstCastExpr::CreateEmpty(Context);
3453 case EXPR_CXX_FUNCTIONAL_CAST:
3454 S = CXXFunctionalCastExpr::CreateEmpty(Context,
3455 /*PathSize*/ Record[ASTStmtReader::NumExprFields]);
3458 case EXPR_USER_DEFINED_LITERAL:
3459 S = UserDefinedLiteral::CreateEmpty(
3460 Context, /*NumArgs=*/Record[ASTStmtReader::NumExprFields], Empty);
3463 case EXPR_CXX_STD_INITIALIZER_LIST:
3464 S = new (Context) CXXStdInitializerListExpr(Empty);
3467 case EXPR_CXX_BOOL_LITERAL:
3468 S = new (Context) CXXBoolLiteralExpr(Empty);
3471 case EXPR_CXX_NULL_PTR_LITERAL:
3472 S = new (Context) CXXNullPtrLiteralExpr(Empty);
3475 case EXPR_CXX_TYPEID_EXPR:
3476 S = new (Context) CXXTypeidExpr(Empty, true);
3479 case EXPR_CXX_TYPEID_TYPE:
3480 S = new (Context) CXXTypeidExpr(Empty, false);
3483 case EXPR_CXX_UUIDOF_EXPR:
3484 S = new (Context) CXXUuidofExpr(Empty, true);
3487 case EXPR_CXX_PROPERTY_REF_EXPR:
3488 S = new (Context) MSPropertyRefExpr(Empty);
3491 case EXPR_CXX_PROPERTY_SUBSCRIPT_EXPR:
3492 S = new (Context) MSPropertySubscriptExpr(Empty);
3495 case EXPR_CXX_UUIDOF_TYPE:
3496 S = new (Context) CXXUuidofExpr(Empty, false);
3500 S = new (Context) CXXThisExpr(Empty);
3503 case EXPR_CXX_THROW:
3504 S = new (Context) CXXThrowExpr(Empty);
3507 case EXPR_CXX_DEFAULT_ARG:
3508 S = new (Context) CXXDefaultArgExpr(Empty);
3511 case EXPR_CXX_DEFAULT_INIT:
3512 S = new (Context) CXXDefaultInitExpr(Empty);
3515 case EXPR_CXX_BIND_TEMPORARY:
3516 S = new (Context) CXXBindTemporaryExpr(Empty);
3519 case EXPR_CXX_SCALAR_VALUE_INIT:
3520 S = new (Context) CXXScalarValueInitExpr(Empty);
3524 S = CXXNewExpr::CreateEmpty(
3526 /*IsArray=*/Record[ASTStmtReader::NumExprFields],
3527 /*HasInit=*/Record[ASTStmtReader::NumExprFields + 1],
3528 /*NumPlacementArgs=*/Record[ASTStmtReader::NumExprFields + 2],
3529 /*IsParenTypeId=*/Record[ASTStmtReader::NumExprFields + 3]);
3532 case EXPR_CXX_DELETE:
3533 S = new (Context) CXXDeleteExpr(Empty);
3536 case EXPR_CXX_PSEUDO_DESTRUCTOR:
3537 S = new (Context) CXXPseudoDestructorExpr(Empty);
3540 case EXPR_EXPR_WITH_CLEANUPS:
3541 S = ExprWithCleanups::Create(Context, Empty,
3542 Record[ASTStmtReader::NumExprFields]);
3545 case EXPR_CXX_DEPENDENT_SCOPE_MEMBER:
3546 S = CXXDependentScopeMemberExpr::CreateEmpty(
3548 /*HasTemplateKWAndArgsInfo=*/Record[ASTStmtReader::NumExprFields],
3549 /*NumTemplateArgs=*/Record[ASTStmtReader::NumExprFields + 1],
3550 /*HasFirstQualifierFoundInScope=*/
3551 Record[ASTStmtReader::NumExprFields + 2]);
3554 case EXPR_CXX_DEPENDENT_SCOPE_DECL_REF:
3555 S = DependentScopeDeclRefExpr::CreateEmpty(Context,
3556 /*HasTemplateKWAndArgsInfo=*/Record[ASTStmtReader::NumExprFields],
3557 /*NumTemplateArgs=*/Record[ASTStmtReader::NumExprFields]
3558 ? Record[ASTStmtReader::NumExprFields + 1]
3562 case EXPR_CXX_UNRESOLVED_CONSTRUCT:
3563 S = CXXUnresolvedConstructExpr::CreateEmpty(Context,
3564 /*NumArgs=*/Record[ASTStmtReader::NumExprFields]);
3567 case EXPR_CXX_UNRESOLVED_MEMBER:
3568 S = UnresolvedMemberExpr::CreateEmpty(
3570 /*NumResults=*/Record[ASTStmtReader::NumExprFields],
3571 /*HasTemplateKWAndArgsInfo=*/Record[ASTStmtReader::NumExprFields + 1],
3572 /*NumTemplateArgs=*/
3573 Record[ASTStmtReader::NumExprFields + 1]
3574 ? Record[ASTStmtReader::NumExprFields + 2]
3578 case EXPR_CXX_UNRESOLVED_LOOKUP:
3579 S = UnresolvedLookupExpr::CreateEmpty(
3581 /*NumResults=*/Record[ASTStmtReader::NumExprFields],
3582 /*HasTemplateKWAndArgsInfo=*/Record[ASTStmtReader::NumExprFields + 1],
3583 /*NumTemplateArgs=*/
3584 Record[ASTStmtReader::NumExprFields + 1]
3585 ? Record[ASTStmtReader::NumExprFields + 2]
3589 case EXPR_TYPE_TRAIT:
3590 S = TypeTraitExpr::CreateDeserialized(Context,
3591 Record[ASTStmtReader::NumExprFields]);
3594 case EXPR_ARRAY_TYPE_TRAIT:
3595 S = new (Context) ArrayTypeTraitExpr(Empty);
3598 case EXPR_CXX_EXPRESSION_TRAIT:
3599 S = new (Context) ExpressionTraitExpr(Empty);
3602 case EXPR_CXX_NOEXCEPT:
3603 S = new (Context) CXXNoexceptExpr(Empty);
3606 case EXPR_PACK_EXPANSION:
3607 S = new (Context) PackExpansionExpr(Empty);
3610 case EXPR_SIZEOF_PACK:
3611 S = SizeOfPackExpr::CreateDeserialized(
3613 /*NumPartialArgs=*/Record[ASTStmtReader::NumExprFields]);
3616 case EXPR_SUBST_NON_TYPE_TEMPLATE_PARM:
3617 S = new (Context) SubstNonTypeTemplateParmExpr(Empty);
3620 case EXPR_SUBST_NON_TYPE_TEMPLATE_PARM_PACK:
3621 S = new (Context) SubstNonTypeTemplateParmPackExpr(Empty);
3624 case EXPR_FUNCTION_PARM_PACK:
3625 S = FunctionParmPackExpr::CreateEmpty(Context,
3626 Record[ASTStmtReader::NumExprFields]);
3629 case EXPR_MATERIALIZE_TEMPORARY:
3630 S = new (Context) MaterializeTemporaryExpr(Empty);
3634 S = new (Context) CXXFoldExpr(Empty);
3637 case EXPR_OPAQUE_VALUE:
3638 S = new (Context) OpaqueValueExpr(Empty);
3641 case EXPR_CUDA_KERNEL_CALL:
3642 S = CUDAKernelCallExpr::CreateEmpty(
3643 Context, /*NumArgs=*/Record[ASTStmtReader::NumExprFields], Empty);
3647 S = new (Context) AsTypeExpr(Empty);
3650 case EXPR_PSEUDO_OBJECT: {
3651 unsigned numSemanticExprs = Record[ASTStmtReader::NumExprFields];
3652 S = PseudoObjectExpr::Create(Context, Empty, numSemanticExprs);
3657 S = new (Context) AtomicExpr(Empty);
3661 unsigned NumCaptures = Record[ASTStmtReader::NumExprFields];
3662 S = LambdaExpr::CreateDeserialized(Context, NumCaptures);
3666 case STMT_COROUTINE_BODY: {
3667 unsigned NumParams = Record[ASTStmtReader::NumStmtFields];
3668 S = CoroutineBodyStmt::Create(Context, Empty, NumParams);
3673 S = new (Context) CoreturnStmt(Empty);
3677 S = new (Context) CoawaitExpr(Empty);
3681 S = new (Context) CoyieldExpr(Empty);
3684 case EXPR_DEPENDENT_COAWAIT:
3685 S = new (Context) DependentCoawaitExpr(Empty);
3688 case EXPR_CONCEPT_SPECIALIZATION: {
3689 unsigned numTemplateArgs = Record[ASTStmtReader::NumExprFields];
3690 S = ConceptSpecializationExpr::Create(Context, Empty, numTemplateArgs);
3695 unsigned numLocalParameters = Record[ASTStmtReader::NumExprFields];
3696 unsigned numRequirement = Record[ASTStmtReader::NumExprFields + 1];
3697 S = RequiresExpr::Create(Context, Empty, numLocalParameters,
3702 // We hit a STMT_STOP, so we're done with this expression.
3706 ++NumStatementsRead;
3708 if (S && !IsStmtReference) {
3710 StmtEntries[Cursor.GetCurrentBitNo()] = S;
3713 assert(Record.getIdx() == Record.size() &&
3714 "Invalid deserialization of statement");
3715 StmtStack.push_back(S);
3718 assert(StmtStack.size() > PrevNumStmts && "Read too many sub-stmts!");
3719 assert(StmtStack.size() == PrevNumStmts + 1 && "Extra expressions on stack!");
3720 return StmtStack.pop_back_val();