1 //===- ASTReaderStmt.cpp - Stmt/Expr Deserialization ----------------------===//
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
10 // Statement/expression deserialization. This implements the
11 // ASTReader::ReadStmt method.
13 //===----------------------------------------------------------------------===//
15 #include "clang/Serialization/ASTReader.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/Bitcode/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 friend class OMPClauseReader;
72 ASTRecordReader &Record;
73 llvm::BitstreamCursor &DeclsCursor;
75 SourceLocation ReadSourceLocation() {
76 return Record.readSourceLocation();
79 SourceRange ReadSourceRange() {
80 return Record.readSourceRange();
83 std::string ReadString() {
84 return Record.readString();
87 TypeSourceInfo *GetTypeSourceInfo() {
88 return Record.getTypeSourceInfo();
92 return Record.readDecl();
97 return Record.readDeclAs<T>();
100 void ReadDeclarationNameLoc(DeclarationNameLoc &DNLoc,
101 DeclarationName Name) {
102 Record.readDeclarationNameLoc(DNLoc, Name);
105 void ReadDeclarationNameInfo(DeclarationNameInfo &NameInfo) {
106 Record.readDeclarationNameInfo(NameInfo);
110 ASTStmtReader(ASTRecordReader &Record, llvm::BitstreamCursor &Cursor)
111 : Record(Record), DeclsCursor(Cursor) {}
113 /// The number of record fields required for the Stmt class
115 static const unsigned NumStmtFields = 0;
117 /// The number of record fields required for the Expr class
119 static const unsigned NumExprFields = NumStmtFields + 7;
121 /// Read and initialize a ExplicitTemplateArgumentList structure.
122 void ReadTemplateKWAndArgsInfo(ASTTemplateKWAndArgsInfo &Args,
123 TemplateArgumentLoc *ArgsLocArray,
124 unsigned NumTemplateArgs);
126 /// Read and initialize a ExplicitTemplateArgumentList structure.
127 void ReadExplicitTemplateArgumentList(ASTTemplateArgumentListInfo &ArgList,
128 unsigned NumTemplateArgs);
130 void VisitStmt(Stmt *S);
131 #define STMT(Type, Base) \
132 void Visit##Type(Type *);
133 #include "clang/AST/StmtNodes.inc"
138 void ASTStmtReader::ReadTemplateKWAndArgsInfo(ASTTemplateKWAndArgsInfo &Args,
139 TemplateArgumentLoc *ArgsLocArray,
140 unsigned NumTemplateArgs) {
141 SourceLocation TemplateKWLoc = ReadSourceLocation();
142 TemplateArgumentListInfo ArgInfo;
143 ArgInfo.setLAngleLoc(ReadSourceLocation());
144 ArgInfo.setRAngleLoc(ReadSourceLocation());
145 for (unsigned i = 0; i != NumTemplateArgs; ++i)
146 ArgInfo.addArgument(Record.readTemplateArgumentLoc());
147 Args.initializeFrom(TemplateKWLoc, ArgInfo, ArgsLocArray);
150 void ASTStmtReader::VisitStmt(Stmt *S) {
151 assert(Record.getIdx() == NumStmtFields && "Incorrect statement field count");
154 void ASTStmtReader::VisitNullStmt(NullStmt *S) {
156 S->setSemiLoc(ReadSourceLocation());
157 S->HasLeadingEmptyMacro = Record.readInt();
160 void ASTStmtReader::VisitCompoundStmt(CompoundStmt *S) {
162 SmallVector<Stmt *, 16> Stmts;
163 unsigned NumStmts = Record.readInt();
165 Stmts.push_back(Record.readSubStmt());
167 S->LBraceLoc = ReadSourceLocation();
168 S->RBraceLoc = ReadSourceLocation();
171 void ASTStmtReader::VisitSwitchCase(SwitchCase *S) {
173 Record.recordSwitchCaseID(S, Record.readInt());
174 S->setKeywordLoc(ReadSourceLocation());
175 S->setColonLoc(ReadSourceLocation());
178 void ASTStmtReader::VisitCaseStmt(CaseStmt *S) {
180 S->setLHS(Record.readSubExpr());
181 S->setRHS(Record.readSubExpr());
182 S->setSubStmt(Record.readSubStmt());
183 S->setEllipsisLoc(ReadSourceLocation());
186 void ASTStmtReader::VisitDefaultStmt(DefaultStmt *S) {
188 S->setSubStmt(Record.readSubStmt());
191 void ASTStmtReader::VisitLabelStmt(LabelStmt *S) {
193 auto *LD = ReadDeclAs<LabelDecl>();
196 S->setSubStmt(Record.readSubStmt());
197 S->setIdentLoc(ReadSourceLocation());
200 void ASTStmtReader::VisitAttributedStmt(AttributedStmt *S) {
202 uint64_t NumAttrs = Record.readInt();
204 Record.readAttributes(Attrs);
206 assert(NumAttrs == S->NumAttrs);
207 assert(NumAttrs == Attrs.size());
208 std::copy(Attrs.begin(), Attrs.end(), S->getAttrArrayPtr());
209 S->SubStmt = Record.readSubStmt();
210 S->AttrLoc = ReadSourceLocation();
213 void ASTStmtReader::VisitIfStmt(IfStmt *S) {
215 S->setConstexpr(Record.readInt());
216 S->setInit(Record.readSubStmt());
217 S->setConditionVariable(Record.getContext(), ReadDeclAs<VarDecl>());
218 S->setCond(Record.readSubExpr());
219 S->setThen(Record.readSubStmt());
220 S->setElse(Record.readSubStmt());
221 S->setIfLoc(ReadSourceLocation());
222 S->setElseLoc(ReadSourceLocation());
225 void ASTStmtReader::VisitSwitchStmt(SwitchStmt *S) {
227 S->setInit(Record.readSubStmt());
228 S->setConditionVariable(Record.getContext(), ReadDeclAs<VarDecl>());
229 S->setCond(Record.readSubExpr());
230 S->setBody(Record.readSubStmt());
231 S->setSwitchLoc(ReadSourceLocation());
232 if (Record.readInt())
233 S->setAllEnumCasesCovered();
235 SwitchCase *PrevSC = nullptr;
236 for (auto E = Record.size(); Record.getIdx() != E; ) {
237 SwitchCase *SC = Record.getSwitchCaseWithID(Record.readInt());
239 PrevSC->setNextSwitchCase(SC);
241 S->setSwitchCaseList(SC);
247 void ASTStmtReader::VisitWhileStmt(WhileStmt *S) {
249 S->setConditionVariable(Record.getContext(), ReadDeclAs<VarDecl>());
251 S->setCond(Record.readSubExpr());
252 S->setBody(Record.readSubStmt());
253 S->setWhileLoc(ReadSourceLocation());
256 void ASTStmtReader::VisitDoStmt(DoStmt *S) {
258 S->setCond(Record.readSubExpr());
259 S->setBody(Record.readSubStmt());
260 S->setDoLoc(ReadSourceLocation());
261 S->setWhileLoc(ReadSourceLocation());
262 S->setRParenLoc(ReadSourceLocation());
265 void ASTStmtReader::VisitForStmt(ForStmt *S) {
267 S->setInit(Record.readSubStmt());
268 S->setCond(Record.readSubExpr());
269 S->setConditionVariable(Record.getContext(), ReadDeclAs<VarDecl>());
270 S->setInc(Record.readSubExpr());
271 S->setBody(Record.readSubStmt());
272 S->setForLoc(ReadSourceLocation());
273 S->setLParenLoc(ReadSourceLocation());
274 S->setRParenLoc(ReadSourceLocation());
277 void ASTStmtReader::VisitGotoStmt(GotoStmt *S) {
279 S->setLabel(ReadDeclAs<LabelDecl>());
280 S->setGotoLoc(ReadSourceLocation());
281 S->setLabelLoc(ReadSourceLocation());
284 void ASTStmtReader::VisitIndirectGotoStmt(IndirectGotoStmt *S) {
286 S->setGotoLoc(ReadSourceLocation());
287 S->setStarLoc(ReadSourceLocation());
288 S->setTarget(Record.readSubExpr());
291 void ASTStmtReader::VisitContinueStmt(ContinueStmt *S) {
293 S->setContinueLoc(ReadSourceLocation());
296 void ASTStmtReader::VisitBreakStmt(BreakStmt *S) {
298 S->setBreakLoc(ReadSourceLocation());
301 void ASTStmtReader::VisitReturnStmt(ReturnStmt *S) {
303 S->setRetValue(Record.readSubExpr());
304 S->setReturnLoc(ReadSourceLocation());
305 S->setNRVOCandidate(ReadDeclAs<VarDecl>());
308 void ASTStmtReader::VisitDeclStmt(DeclStmt *S) {
310 S->setStartLoc(ReadSourceLocation());
311 S->setEndLoc(ReadSourceLocation());
313 if (Record.size() - Record.getIdx() == 1) {
314 // Single declaration
315 S->setDeclGroup(DeclGroupRef(ReadDecl()));
317 SmallVector<Decl *, 16> Decls;
318 int N = Record.size() - Record.getIdx();
320 for (int I = 0; I < N; ++I)
321 Decls.push_back(ReadDecl());
322 S->setDeclGroup(DeclGroupRef(DeclGroup::Create(Record.getContext(),
328 void ASTStmtReader::VisitAsmStmt(AsmStmt *S) {
330 S->NumOutputs = Record.readInt();
331 S->NumInputs = Record.readInt();
332 S->NumClobbers = Record.readInt();
333 S->setAsmLoc(ReadSourceLocation());
334 S->setVolatile(Record.readInt());
335 S->setSimple(Record.readInt());
338 void ASTStmtReader::VisitGCCAsmStmt(GCCAsmStmt *S) {
340 S->setRParenLoc(ReadSourceLocation());
341 S->setAsmString(cast_or_null<StringLiteral>(Record.readSubStmt()));
343 unsigned NumOutputs = S->getNumOutputs();
344 unsigned NumInputs = S->getNumInputs();
345 unsigned NumClobbers = S->getNumClobbers();
347 // Outputs and inputs
348 SmallVector<IdentifierInfo *, 16> Names;
349 SmallVector<StringLiteral*, 16> Constraints;
350 SmallVector<Stmt*, 16> Exprs;
351 for (unsigned I = 0, N = NumOutputs + NumInputs; I != N; ++I) {
352 Names.push_back(Record.getIdentifierInfo());
353 Constraints.push_back(cast_or_null<StringLiteral>(Record.readSubStmt()));
354 Exprs.push_back(Record.readSubStmt());
358 SmallVector<StringLiteral*, 16> Clobbers;
359 for (unsigned I = 0; I != NumClobbers; ++I)
360 Clobbers.push_back(cast_or_null<StringLiteral>(Record.readSubStmt()));
362 S->setOutputsAndInputsAndClobbers(Record.getContext(),
363 Names.data(), Constraints.data(),
364 Exprs.data(), NumOutputs, NumInputs,
365 Clobbers.data(), NumClobbers);
368 void ASTStmtReader::VisitMSAsmStmt(MSAsmStmt *S) {
370 S->LBraceLoc = ReadSourceLocation();
371 S->EndLoc = ReadSourceLocation();
372 S->NumAsmToks = Record.readInt();
373 std::string AsmStr = ReadString();
376 SmallVector<Token, 16> AsmToks;
377 AsmToks.reserve(S->NumAsmToks);
378 for (unsigned i = 0, e = S->NumAsmToks; i != e; ++i) {
379 AsmToks.push_back(Record.readToken());
382 // The calls to reserve() for the FooData vectors are mandatory to
383 // prevent dead StringRefs in the Foo vectors.
385 // Read the clobbers.
386 SmallVector<std::string, 16> ClobbersData;
387 SmallVector<StringRef, 16> Clobbers;
388 ClobbersData.reserve(S->NumClobbers);
389 Clobbers.reserve(S->NumClobbers);
390 for (unsigned i = 0, e = S->NumClobbers; i != e; ++i) {
391 ClobbersData.push_back(ReadString());
392 Clobbers.push_back(ClobbersData.back());
395 // Read the operands.
396 unsigned NumOperands = S->NumOutputs + S->NumInputs;
397 SmallVector<Expr*, 16> Exprs;
398 SmallVector<std::string, 16> ConstraintsData;
399 SmallVector<StringRef, 16> Constraints;
400 Exprs.reserve(NumOperands);
401 ConstraintsData.reserve(NumOperands);
402 Constraints.reserve(NumOperands);
403 for (unsigned i = 0; i != NumOperands; ++i) {
404 Exprs.push_back(cast<Expr>(Record.readSubStmt()));
405 ConstraintsData.push_back(ReadString());
406 Constraints.push_back(ConstraintsData.back());
409 S->initialize(Record.getContext(), AsmStr, AsmToks,
410 Constraints, Exprs, Clobbers);
413 void ASTStmtReader::VisitCoroutineBodyStmt(CoroutineBodyStmt *S) {
415 assert(Record.peekInt() == S->NumParams);
417 auto *StoredStmts = S->getStoredStmts();
419 i < CoroutineBodyStmt::SubStmt::FirstParamMove + S->NumParams; ++i)
420 StoredStmts[i] = Record.readSubStmt();
423 void ASTStmtReader::VisitCoreturnStmt(CoreturnStmt *S) {
425 S->CoreturnLoc = Record.readSourceLocation();
426 for (auto &SubStmt: S->SubStmts)
427 SubStmt = Record.readSubStmt();
428 S->IsImplicit = Record.readInt() != 0;
431 void ASTStmtReader::VisitCoawaitExpr(CoawaitExpr *E) {
433 E->KeywordLoc = ReadSourceLocation();
434 for (auto &SubExpr: E->SubExprs)
435 SubExpr = Record.readSubStmt();
436 E->OpaqueValue = cast_or_null<OpaqueValueExpr>(Record.readSubStmt());
437 E->setIsImplicit(Record.readInt() != 0);
440 void ASTStmtReader::VisitCoyieldExpr(CoyieldExpr *E) {
442 E->KeywordLoc = ReadSourceLocation();
443 for (auto &SubExpr: E->SubExprs)
444 SubExpr = Record.readSubStmt();
445 E->OpaqueValue = cast_or_null<OpaqueValueExpr>(Record.readSubStmt());
448 void ASTStmtReader::VisitDependentCoawaitExpr(DependentCoawaitExpr *E) {
450 E->KeywordLoc = ReadSourceLocation();
451 for (auto &SubExpr: E->SubExprs)
452 SubExpr = Record.readSubStmt();
455 void ASTStmtReader::VisitCapturedStmt(CapturedStmt *S) {
458 S->setCapturedDecl(ReadDeclAs<CapturedDecl>());
459 S->setCapturedRegionKind(static_cast<CapturedRegionKind>(Record.readInt()));
460 S->setCapturedRecordDecl(ReadDeclAs<RecordDecl>());
463 for (CapturedStmt::capture_init_iterator I = S->capture_init_begin(),
464 E = S->capture_init_end();
466 *I = Record.readSubExpr();
469 S->setCapturedStmt(Record.readSubStmt());
470 S->getCapturedDecl()->setBody(S->getCapturedStmt());
473 for (auto &I : S->captures()) {
474 I.VarAndKind.setPointer(ReadDeclAs<VarDecl>());
476 static_cast<CapturedStmt::VariableCaptureKind>(Record.readInt()));
477 I.Loc = ReadSourceLocation();
481 void ASTStmtReader::VisitExpr(Expr *E) {
483 E->setType(Record.readType());
484 E->setTypeDependent(Record.readInt());
485 E->setValueDependent(Record.readInt());
486 E->setInstantiationDependent(Record.readInt());
487 E->ExprBits.ContainsUnexpandedParameterPack = Record.readInt();
488 E->setValueKind(static_cast<ExprValueKind>(Record.readInt()));
489 E->setObjectKind(static_cast<ExprObjectKind>(Record.readInt()));
490 assert(Record.getIdx() == NumExprFields &&
491 "Incorrect expression field count");
494 void ASTStmtReader::VisitPredefinedExpr(PredefinedExpr *E) {
496 E->setLocation(ReadSourceLocation());
497 E->Type = (PredefinedExpr::IdentType)Record.readInt();
498 E->FnName = cast_or_null<StringLiteral>(Record.readSubExpr());
501 void ASTStmtReader::VisitDeclRefExpr(DeclRefExpr *E) {
504 E->DeclRefExprBits.HasQualifier = Record.readInt();
505 E->DeclRefExprBits.HasFoundDecl = Record.readInt();
506 E->DeclRefExprBits.HasTemplateKWAndArgsInfo = Record.readInt();
507 E->DeclRefExprBits.HadMultipleCandidates = Record.readInt();
508 E->DeclRefExprBits.RefersToEnclosingVariableOrCapture = Record.readInt();
509 unsigned NumTemplateArgs = 0;
510 if (E->hasTemplateKWAndArgsInfo())
511 NumTemplateArgs = Record.readInt();
513 if (E->hasQualifier())
514 new (E->getTrailingObjects<NestedNameSpecifierLoc>())
515 NestedNameSpecifierLoc(Record.readNestedNameSpecifierLoc());
517 if (E->hasFoundDecl())
518 *E->getTrailingObjects<NamedDecl *>() = ReadDeclAs<NamedDecl>();
520 if (E->hasTemplateKWAndArgsInfo())
521 ReadTemplateKWAndArgsInfo(
522 *E->getTrailingObjects<ASTTemplateKWAndArgsInfo>(),
523 E->getTrailingObjects<TemplateArgumentLoc>(), NumTemplateArgs);
525 E->setDecl(ReadDeclAs<ValueDecl>());
526 E->setLocation(ReadSourceLocation());
527 ReadDeclarationNameLoc(E->DNLoc, E->getDecl()->getDeclName());
530 void ASTStmtReader::VisitIntegerLiteral(IntegerLiteral *E) {
532 E->setLocation(ReadSourceLocation());
533 E->setValue(Record.getContext(), Record.readAPInt());
536 void ASTStmtReader::VisitFixedPointLiteral(FixedPointLiteral *E) {
538 E->setLocation(ReadSourceLocation());
539 E->setValue(Record.getContext(), Record.readAPInt());
542 void ASTStmtReader::VisitFloatingLiteral(FloatingLiteral *E) {
544 E->setRawSemantics(static_cast<Stmt::APFloatSemantics>(Record.readInt()));
545 E->setExact(Record.readInt());
546 E->setValue(Record.getContext(), Record.readAPFloat(E->getSemantics()));
547 E->setLocation(ReadSourceLocation());
550 void ASTStmtReader::VisitImaginaryLiteral(ImaginaryLiteral *E) {
552 E->setSubExpr(Record.readSubExpr());
555 void ASTStmtReader::VisitStringLiteral(StringLiteral *E) {
557 unsigned Len = Record.readInt();
558 assert(Record.peekInt() == E->getNumConcatenated() &&
559 "Wrong number of concatenated tokens!");
561 auto kind = static_cast<StringLiteral::StringKind>(Record.readInt());
562 bool isPascal = Record.readInt();
565 auto B = &Record.peekInt();
566 SmallString<16> Str(B, B + Len);
567 E->setString(Record.getContext(), Str, kind, isPascal);
568 Record.skipInts(Len);
570 // Read source locations
571 for (unsigned I = 0, N = E->getNumConcatenated(); I != N; ++I)
572 E->setStrTokenLoc(I, ReadSourceLocation());
575 void ASTStmtReader::VisitCharacterLiteral(CharacterLiteral *E) {
577 E->setValue(Record.readInt());
578 E->setLocation(ReadSourceLocation());
579 E->setKind(static_cast<CharacterLiteral::CharacterKind>(Record.readInt()));
582 void ASTStmtReader::VisitParenExpr(ParenExpr *E) {
584 E->setLParen(ReadSourceLocation());
585 E->setRParen(ReadSourceLocation());
586 E->setSubExpr(Record.readSubExpr());
589 void ASTStmtReader::VisitParenListExpr(ParenListExpr *E) {
591 unsigned NumExprs = Record.readInt();
592 E->Exprs = new (Record.getContext()) Stmt*[NumExprs];
593 for (unsigned i = 0; i != NumExprs; ++i)
594 E->Exprs[i] = Record.readSubStmt();
595 E->NumExprs = NumExprs;
596 E->LParenLoc = ReadSourceLocation();
597 E->RParenLoc = ReadSourceLocation();
600 void ASTStmtReader::VisitUnaryOperator(UnaryOperator *E) {
602 E->setSubExpr(Record.readSubExpr());
603 E->setOpcode((UnaryOperator::Opcode)Record.readInt());
604 E->setOperatorLoc(ReadSourceLocation());
605 E->setCanOverflow(Record.readInt());
608 void ASTStmtReader::VisitOffsetOfExpr(OffsetOfExpr *E) {
610 assert(E->getNumComponents() == Record.peekInt());
612 assert(E->getNumExpressions() == Record.peekInt());
614 E->setOperatorLoc(ReadSourceLocation());
615 E->setRParenLoc(ReadSourceLocation());
616 E->setTypeSourceInfo(GetTypeSourceInfo());
617 for (unsigned I = 0, N = E->getNumComponents(); I != N; ++I) {
618 auto Kind = static_cast<OffsetOfNode::Kind>(Record.readInt());
619 SourceLocation Start = ReadSourceLocation();
620 SourceLocation End = ReadSourceLocation();
622 case OffsetOfNode::Array:
623 E->setComponent(I, OffsetOfNode(Start, Record.readInt(), End));
626 case OffsetOfNode::Field:
628 I, OffsetOfNode(Start, ReadDeclAs<FieldDecl>(), End));
631 case OffsetOfNode::Identifier:
634 OffsetOfNode(Start, Record.getIdentifierInfo(), End));
637 case OffsetOfNode::Base: {
638 auto *Base = new (Record.getContext()) CXXBaseSpecifier();
639 *Base = Record.readCXXBaseSpecifier();
640 E->setComponent(I, OffsetOfNode(Base));
646 for (unsigned I = 0, N = E->getNumExpressions(); I != N; ++I)
647 E->setIndexExpr(I, Record.readSubExpr());
650 void ASTStmtReader::VisitUnaryExprOrTypeTraitExpr(UnaryExprOrTypeTraitExpr *E) {
652 E->setKind(static_cast<UnaryExprOrTypeTrait>(Record.readInt()));
653 if (Record.peekInt() == 0) {
654 E->setArgument(Record.readSubExpr());
657 E->setArgument(GetTypeSourceInfo());
659 E->setOperatorLoc(ReadSourceLocation());
660 E->setRParenLoc(ReadSourceLocation());
663 void ASTStmtReader::VisitArraySubscriptExpr(ArraySubscriptExpr *E) {
665 E->setLHS(Record.readSubExpr());
666 E->setRHS(Record.readSubExpr());
667 E->setRBracketLoc(ReadSourceLocation());
670 void ASTStmtReader::VisitOMPArraySectionExpr(OMPArraySectionExpr *E) {
672 E->setBase(Record.readSubExpr());
673 E->setLowerBound(Record.readSubExpr());
674 E->setLength(Record.readSubExpr());
675 E->setColonLoc(ReadSourceLocation());
676 E->setRBracketLoc(ReadSourceLocation());
679 void ASTStmtReader::VisitCallExpr(CallExpr *E) {
681 E->setNumArgs(Record.getContext(), Record.readInt());
682 E->setRParenLoc(ReadSourceLocation());
683 E->setCallee(Record.readSubExpr());
684 for (unsigned I = 0, N = E->getNumArgs(); I != N; ++I)
685 E->setArg(I, Record.readSubExpr());
688 void ASTStmtReader::VisitCXXMemberCallExpr(CXXMemberCallExpr *E) {
692 void ASTStmtReader::VisitMemberExpr(MemberExpr *E) {
693 // Don't call VisitExpr, this is fully initialized at creation.
694 assert(E->getStmtClass() == Stmt::MemberExprClass &&
695 "It's a subclass, we must advance Idx!");
698 void ASTStmtReader::VisitObjCIsaExpr(ObjCIsaExpr *E) {
700 E->setBase(Record.readSubExpr());
701 E->setIsaMemberLoc(ReadSourceLocation());
702 E->setOpLoc(ReadSourceLocation());
703 E->setArrow(Record.readInt());
707 VisitObjCIndirectCopyRestoreExpr(ObjCIndirectCopyRestoreExpr *E) {
709 E->Operand = Record.readSubExpr();
710 E->setShouldCopy(Record.readInt());
713 void ASTStmtReader::VisitObjCBridgedCastExpr(ObjCBridgedCastExpr *E) {
714 VisitExplicitCastExpr(E);
715 E->LParenLoc = ReadSourceLocation();
716 E->BridgeKeywordLoc = ReadSourceLocation();
717 E->Kind = Record.readInt();
720 void ASTStmtReader::VisitCastExpr(CastExpr *E) {
722 unsigned NumBaseSpecs = Record.readInt();
723 assert(NumBaseSpecs == E->path_size());
724 E->setSubExpr(Record.readSubExpr());
725 E->setCastKind((CastKind)Record.readInt());
726 CastExpr::path_iterator BaseI = E->path_begin();
727 while (NumBaseSpecs--) {
728 auto *BaseSpec = new (Record.getContext()) CXXBaseSpecifier;
729 *BaseSpec = Record.readCXXBaseSpecifier();
734 void ASTStmtReader::VisitBinaryOperator(BinaryOperator *E) {
736 E->setLHS(Record.readSubExpr());
737 E->setRHS(Record.readSubExpr());
738 E->setOpcode((BinaryOperator::Opcode)Record.readInt());
739 E->setOperatorLoc(ReadSourceLocation());
740 E->setFPFeatures(FPOptions(Record.readInt()));
743 void ASTStmtReader::VisitCompoundAssignOperator(CompoundAssignOperator *E) {
744 VisitBinaryOperator(E);
745 E->setComputationLHSType(Record.readType());
746 E->setComputationResultType(Record.readType());
749 void ASTStmtReader::VisitConditionalOperator(ConditionalOperator *E) {
751 E->SubExprs[ConditionalOperator::COND] = Record.readSubExpr();
752 E->SubExprs[ConditionalOperator::LHS] = Record.readSubExpr();
753 E->SubExprs[ConditionalOperator::RHS] = Record.readSubExpr();
754 E->QuestionLoc = ReadSourceLocation();
755 E->ColonLoc = ReadSourceLocation();
759 ASTStmtReader::VisitBinaryConditionalOperator(BinaryConditionalOperator *E) {
761 E->OpaqueValue = cast<OpaqueValueExpr>(Record.readSubExpr());
762 E->SubExprs[BinaryConditionalOperator::COMMON] = Record.readSubExpr();
763 E->SubExprs[BinaryConditionalOperator::COND] = Record.readSubExpr();
764 E->SubExprs[BinaryConditionalOperator::LHS] = Record.readSubExpr();
765 E->SubExprs[BinaryConditionalOperator::RHS] = Record.readSubExpr();
766 E->QuestionLoc = ReadSourceLocation();
767 E->ColonLoc = ReadSourceLocation();
770 void ASTStmtReader::VisitImplicitCastExpr(ImplicitCastExpr *E) {
772 E->setIsPartOfExplicitCast(Record.readInt());
775 void ASTStmtReader::VisitExplicitCastExpr(ExplicitCastExpr *E) {
777 E->setTypeInfoAsWritten(GetTypeSourceInfo());
780 void ASTStmtReader::VisitCStyleCastExpr(CStyleCastExpr *E) {
781 VisitExplicitCastExpr(E);
782 E->setLParenLoc(ReadSourceLocation());
783 E->setRParenLoc(ReadSourceLocation());
786 void ASTStmtReader::VisitCompoundLiteralExpr(CompoundLiteralExpr *E) {
788 E->setLParenLoc(ReadSourceLocation());
789 E->setTypeSourceInfo(GetTypeSourceInfo());
790 E->setInitializer(Record.readSubExpr());
791 E->setFileScope(Record.readInt());
794 void ASTStmtReader::VisitExtVectorElementExpr(ExtVectorElementExpr *E) {
796 E->setBase(Record.readSubExpr());
797 E->setAccessor(Record.getIdentifierInfo());
798 E->setAccessorLoc(ReadSourceLocation());
801 void ASTStmtReader::VisitInitListExpr(InitListExpr *E) {
803 if (auto *SyntForm = cast_or_null<InitListExpr>(Record.readSubStmt()))
804 E->setSyntacticForm(SyntForm);
805 E->setLBraceLoc(ReadSourceLocation());
806 E->setRBraceLoc(ReadSourceLocation());
807 bool isArrayFiller = Record.readInt();
808 Expr *filler = nullptr;
810 filler = Record.readSubExpr();
811 E->ArrayFillerOrUnionFieldInit = filler;
813 E->ArrayFillerOrUnionFieldInit = ReadDeclAs<FieldDecl>();
814 E->sawArrayRangeDesignator(Record.readInt());
815 unsigned NumInits = Record.readInt();
816 E->reserveInits(Record.getContext(), NumInits);
818 for (unsigned I = 0; I != NumInits; ++I) {
819 Expr *init = Record.readSubExpr();
820 E->updateInit(Record.getContext(), I, init ? init : filler);
823 for (unsigned I = 0; I != NumInits; ++I)
824 E->updateInit(Record.getContext(), I, Record.readSubExpr());
828 void ASTStmtReader::VisitDesignatedInitExpr(DesignatedInitExpr *E) {
829 using Designator = DesignatedInitExpr::Designator;
832 unsigned NumSubExprs = Record.readInt();
833 assert(NumSubExprs == E->getNumSubExprs() && "Wrong number of subexprs");
834 for (unsigned I = 0; I != NumSubExprs; ++I)
835 E->setSubExpr(I, Record.readSubExpr());
836 E->setEqualOrColonLoc(ReadSourceLocation());
837 E->setGNUSyntax(Record.readInt());
839 SmallVector<Designator, 4> Designators;
840 while (Record.getIdx() < Record.size()) {
841 switch ((DesignatorTypes)Record.readInt()) {
842 case DESIG_FIELD_DECL: {
843 auto *Field = ReadDeclAs<FieldDecl>();
844 SourceLocation DotLoc = ReadSourceLocation();
845 SourceLocation FieldLoc = ReadSourceLocation();
846 Designators.push_back(Designator(Field->getIdentifier(), DotLoc,
848 Designators.back().setField(Field);
852 case DESIG_FIELD_NAME: {
853 const IdentifierInfo *Name = Record.getIdentifierInfo();
854 SourceLocation DotLoc = ReadSourceLocation();
855 SourceLocation FieldLoc = ReadSourceLocation();
856 Designators.push_back(Designator(Name, DotLoc, FieldLoc));
861 unsigned Index = Record.readInt();
862 SourceLocation LBracketLoc = ReadSourceLocation();
863 SourceLocation RBracketLoc = ReadSourceLocation();
864 Designators.push_back(Designator(Index, LBracketLoc, RBracketLoc));
868 case DESIG_ARRAY_RANGE: {
869 unsigned Index = Record.readInt();
870 SourceLocation LBracketLoc = ReadSourceLocation();
871 SourceLocation EllipsisLoc = ReadSourceLocation();
872 SourceLocation RBracketLoc = ReadSourceLocation();
873 Designators.push_back(Designator(Index, LBracketLoc, EllipsisLoc,
879 E->setDesignators(Record.getContext(),
880 Designators.data(), Designators.size());
883 void ASTStmtReader::VisitDesignatedInitUpdateExpr(DesignatedInitUpdateExpr *E) {
885 E->setBase(Record.readSubExpr());
886 E->setUpdater(Record.readSubExpr());
889 void ASTStmtReader::VisitNoInitExpr(NoInitExpr *E) {
893 void ASTStmtReader::VisitArrayInitLoopExpr(ArrayInitLoopExpr *E) {
895 E->SubExprs[0] = Record.readSubExpr();
896 E->SubExprs[1] = Record.readSubExpr();
899 void ASTStmtReader::VisitArrayInitIndexExpr(ArrayInitIndexExpr *E) {
903 void ASTStmtReader::VisitImplicitValueInitExpr(ImplicitValueInitExpr *E) {
907 void ASTStmtReader::VisitVAArgExpr(VAArgExpr *E) {
909 E->setSubExpr(Record.readSubExpr());
910 E->setWrittenTypeInfo(GetTypeSourceInfo());
911 E->setBuiltinLoc(ReadSourceLocation());
912 E->setRParenLoc(ReadSourceLocation());
913 E->setIsMicrosoftABI(Record.readInt());
916 void ASTStmtReader::VisitAddrLabelExpr(AddrLabelExpr *E) {
918 E->setAmpAmpLoc(ReadSourceLocation());
919 E->setLabelLoc(ReadSourceLocation());
920 E->setLabel(ReadDeclAs<LabelDecl>());
923 void ASTStmtReader::VisitStmtExpr(StmtExpr *E) {
925 E->setLParenLoc(ReadSourceLocation());
926 E->setRParenLoc(ReadSourceLocation());
927 E->setSubStmt(cast_or_null<CompoundStmt>(Record.readSubStmt()));
930 void ASTStmtReader::VisitChooseExpr(ChooseExpr *E) {
932 E->setCond(Record.readSubExpr());
933 E->setLHS(Record.readSubExpr());
934 E->setRHS(Record.readSubExpr());
935 E->setBuiltinLoc(ReadSourceLocation());
936 E->setRParenLoc(ReadSourceLocation());
937 E->setIsConditionTrue(Record.readInt());
940 void ASTStmtReader::VisitGNUNullExpr(GNUNullExpr *E) {
942 E->setTokenLocation(ReadSourceLocation());
945 void ASTStmtReader::VisitShuffleVectorExpr(ShuffleVectorExpr *E) {
947 SmallVector<Expr *, 16> Exprs;
948 unsigned NumExprs = Record.readInt();
950 Exprs.push_back(Record.readSubExpr());
951 E->setExprs(Record.getContext(), Exprs);
952 E->setBuiltinLoc(ReadSourceLocation());
953 E->setRParenLoc(ReadSourceLocation());
956 void ASTStmtReader::VisitConvertVectorExpr(ConvertVectorExpr *E) {
958 E->BuiltinLoc = ReadSourceLocation();
959 E->RParenLoc = ReadSourceLocation();
960 E->TInfo = GetTypeSourceInfo();
961 E->SrcExpr = Record.readSubExpr();
964 void ASTStmtReader::VisitBlockExpr(BlockExpr *E) {
966 E->setBlockDecl(ReadDeclAs<BlockDecl>());
969 void ASTStmtReader::VisitGenericSelectionExpr(GenericSelectionExpr *E) {
971 E->NumAssocs = Record.readInt();
972 E->AssocTypes = new (Record.getContext()) TypeSourceInfo*[E->NumAssocs];
974 new(Record.getContext()) Stmt*[GenericSelectionExpr::END_EXPR+E->NumAssocs];
976 E->SubExprs[GenericSelectionExpr::CONTROLLING] = Record.readSubExpr();
977 for (unsigned I = 0, N = E->getNumAssocs(); I != N; ++I) {
978 E->AssocTypes[I] = GetTypeSourceInfo();
979 E->SubExprs[GenericSelectionExpr::END_EXPR+I] = Record.readSubExpr();
981 E->ResultIndex = Record.readInt();
983 E->GenericLoc = ReadSourceLocation();
984 E->DefaultLoc = ReadSourceLocation();
985 E->RParenLoc = ReadSourceLocation();
988 void ASTStmtReader::VisitPseudoObjectExpr(PseudoObjectExpr *E) {
990 unsigned numSemanticExprs = Record.readInt();
991 assert(numSemanticExprs + 1 == E->PseudoObjectExprBits.NumSubExprs);
992 E->PseudoObjectExprBits.ResultIndex = Record.readInt();
994 // Read the syntactic expression.
995 E->getSubExprsBuffer()[0] = Record.readSubExpr();
997 // Read all the semantic expressions.
998 for (unsigned i = 0; i != numSemanticExprs; ++i) {
999 Expr *subExpr = Record.readSubExpr();
1000 E->getSubExprsBuffer()[i+1] = subExpr;
1004 void ASTStmtReader::VisitAtomicExpr(AtomicExpr *E) {
1006 E->Op = AtomicExpr::AtomicOp(Record.readInt());
1007 E->NumSubExprs = AtomicExpr::getNumSubExprs(E->Op);
1008 for (unsigned I = 0; I != E->NumSubExprs; ++I)
1009 E->SubExprs[I] = Record.readSubExpr();
1010 E->BuiltinLoc = ReadSourceLocation();
1011 E->RParenLoc = ReadSourceLocation();
1014 //===----------------------------------------------------------------------===//
1015 // Objective-C Expressions and Statements
1017 void ASTStmtReader::VisitObjCStringLiteral(ObjCStringLiteral *E) {
1019 E->setString(cast<StringLiteral>(Record.readSubStmt()));
1020 E->setAtLoc(ReadSourceLocation());
1023 void ASTStmtReader::VisitObjCBoxedExpr(ObjCBoxedExpr *E) {
1025 // could be one of several IntegerLiteral, FloatLiteral, etc.
1026 E->SubExpr = Record.readSubStmt();
1027 E->BoxingMethod = ReadDeclAs<ObjCMethodDecl>();
1028 E->Range = ReadSourceRange();
1031 void ASTStmtReader::VisitObjCArrayLiteral(ObjCArrayLiteral *E) {
1033 unsigned NumElements = Record.readInt();
1034 assert(NumElements == E->getNumElements() && "Wrong number of elements");
1035 Expr **Elements = E->getElements();
1036 for (unsigned I = 0, N = NumElements; I != N; ++I)
1037 Elements[I] = Record.readSubExpr();
1038 E->ArrayWithObjectsMethod = ReadDeclAs<ObjCMethodDecl>();
1039 E->Range = ReadSourceRange();
1042 void ASTStmtReader::VisitObjCDictionaryLiteral(ObjCDictionaryLiteral *E) {
1044 unsigned NumElements = Record.readInt();
1045 assert(NumElements == E->getNumElements() && "Wrong number of elements");
1046 bool HasPackExpansions = Record.readInt();
1047 assert(HasPackExpansions == E->HasPackExpansions &&"Pack expansion mismatch");
1049 E->getTrailingObjects<ObjCDictionaryLiteral::KeyValuePair>();
1051 E->getTrailingObjects<ObjCDictionaryLiteral::ExpansionData>();
1052 for (unsigned I = 0; I != NumElements; ++I) {
1053 KeyValues[I].Key = Record.readSubExpr();
1054 KeyValues[I].Value = Record.readSubExpr();
1055 if (HasPackExpansions) {
1056 Expansions[I].EllipsisLoc = ReadSourceLocation();
1057 Expansions[I].NumExpansionsPlusOne = Record.readInt();
1060 E->DictWithObjectsMethod = ReadDeclAs<ObjCMethodDecl>();
1061 E->Range = ReadSourceRange();
1064 void ASTStmtReader::VisitObjCEncodeExpr(ObjCEncodeExpr *E) {
1066 E->setEncodedTypeSourceInfo(GetTypeSourceInfo());
1067 E->setAtLoc(ReadSourceLocation());
1068 E->setRParenLoc(ReadSourceLocation());
1071 void ASTStmtReader::VisitObjCSelectorExpr(ObjCSelectorExpr *E) {
1073 E->setSelector(Record.readSelector());
1074 E->setAtLoc(ReadSourceLocation());
1075 E->setRParenLoc(ReadSourceLocation());
1078 void ASTStmtReader::VisitObjCProtocolExpr(ObjCProtocolExpr *E) {
1080 E->setProtocol(ReadDeclAs<ObjCProtocolDecl>());
1081 E->setAtLoc(ReadSourceLocation());
1082 E->ProtoLoc = ReadSourceLocation();
1083 E->setRParenLoc(ReadSourceLocation());
1086 void ASTStmtReader::VisitObjCIvarRefExpr(ObjCIvarRefExpr *E) {
1088 E->setDecl(ReadDeclAs<ObjCIvarDecl>());
1089 E->setLocation(ReadSourceLocation());
1090 E->setOpLoc(ReadSourceLocation());
1091 E->setBase(Record.readSubExpr());
1092 E->setIsArrow(Record.readInt());
1093 E->setIsFreeIvar(Record.readInt());
1096 void ASTStmtReader::VisitObjCPropertyRefExpr(ObjCPropertyRefExpr *E) {
1098 unsigned MethodRefFlags = Record.readInt();
1099 bool Implicit = Record.readInt() != 0;
1101 auto *Getter = ReadDeclAs<ObjCMethodDecl>();
1102 auto *Setter = ReadDeclAs<ObjCMethodDecl>();
1103 E->setImplicitProperty(Getter, Setter, MethodRefFlags);
1105 E->setExplicitProperty(ReadDeclAs<ObjCPropertyDecl>(), MethodRefFlags);
1107 E->setLocation(ReadSourceLocation());
1108 E->setReceiverLocation(ReadSourceLocation());
1109 switch (Record.readInt()) {
1111 E->setBase(Record.readSubExpr());
1114 E->setSuperReceiver(Record.readType());
1117 E->setClassReceiver(ReadDeclAs<ObjCInterfaceDecl>());
1122 void ASTStmtReader::VisitObjCSubscriptRefExpr(ObjCSubscriptRefExpr *E) {
1124 E->setRBracket(ReadSourceLocation());
1125 E->setBaseExpr(Record.readSubExpr());
1126 E->setKeyExpr(Record.readSubExpr());
1127 E->GetAtIndexMethodDecl = ReadDeclAs<ObjCMethodDecl>();
1128 E->SetAtIndexMethodDecl = ReadDeclAs<ObjCMethodDecl>();
1131 void ASTStmtReader::VisitObjCMessageExpr(ObjCMessageExpr *E) {
1133 assert(Record.peekInt() == E->getNumArgs());
1135 unsigned NumStoredSelLocs = Record.readInt();
1136 E->SelLocsKind = Record.readInt();
1137 E->setDelegateInitCall(Record.readInt());
1138 E->IsImplicit = Record.readInt();
1139 auto Kind = static_cast<ObjCMessageExpr::ReceiverKind>(Record.readInt());
1141 case ObjCMessageExpr::Instance:
1142 E->setInstanceReceiver(Record.readSubExpr());
1145 case ObjCMessageExpr::Class:
1146 E->setClassReceiver(GetTypeSourceInfo());
1149 case ObjCMessageExpr::SuperClass:
1150 case ObjCMessageExpr::SuperInstance: {
1151 QualType T = Record.readType();
1152 SourceLocation SuperLoc = ReadSourceLocation();
1153 E->setSuper(SuperLoc, T, Kind == ObjCMessageExpr::SuperInstance);
1158 assert(Kind == E->getReceiverKind());
1160 if (Record.readInt())
1161 E->setMethodDecl(ReadDeclAs<ObjCMethodDecl>());
1163 E->setSelector(Record.readSelector());
1165 E->LBracLoc = ReadSourceLocation();
1166 E->RBracLoc = ReadSourceLocation();
1168 for (unsigned I = 0, N = E->getNumArgs(); I != N; ++I)
1169 E->setArg(I, Record.readSubExpr());
1171 SourceLocation *Locs = E->getStoredSelLocs();
1172 for (unsigned I = 0; I != NumStoredSelLocs; ++I)
1173 Locs[I] = ReadSourceLocation();
1176 void ASTStmtReader::VisitObjCForCollectionStmt(ObjCForCollectionStmt *S) {
1178 S->setElement(Record.readSubStmt());
1179 S->setCollection(Record.readSubExpr());
1180 S->setBody(Record.readSubStmt());
1181 S->setForLoc(ReadSourceLocation());
1182 S->setRParenLoc(ReadSourceLocation());
1185 void ASTStmtReader::VisitObjCAtCatchStmt(ObjCAtCatchStmt *S) {
1187 S->setCatchBody(Record.readSubStmt());
1188 S->setCatchParamDecl(ReadDeclAs<VarDecl>());
1189 S->setAtCatchLoc(ReadSourceLocation());
1190 S->setRParenLoc(ReadSourceLocation());
1193 void ASTStmtReader::VisitObjCAtFinallyStmt(ObjCAtFinallyStmt *S) {
1195 S->setFinallyBody(Record.readSubStmt());
1196 S->setAtFinallyLoc(ReadSourceLocation());
1199 void ASTStmtReader::VisitObjCAutoreleasePoolStmt(ObjCAutoreleasePoolStmt *S) {
1201 S->setSubStmt(Record.readSubStmt());
1202 S->setAtLoc(ReadSourceLocation());
1205 void ASTStmtReader::VisitObjCAtTryStmt(ObjCAtTryStmt *S) {
1207 assert(Record.peekInt() == S->getNumCatchStmts());
1209 bool HasFinally = Record.readInt();
1210 S->setTryBody(Record.readSubStmt());
1211 for (unsigned I = 0, N = S->getNumCatchStmts(); I != N; ++I)
1212 S->setCatchStmt(I, cast_or_null<ObjCAtCatchStmt>(Record.readSubStmt()));
1215 S->setFinallyStmt(Record.readSubStmt());
1216 S->setAtTryLoc(ReadSourceLocation());
1219 void ASTStmtReader::VisitObjCAtSynchronizedStmt(ObjCAtSynchronizedStmt *S) {
1221 S->setSynchExpr(Record.readSubStmt());
1222 S->setSynchBody(Record.readSubStmt());
1223 S->setAtSynchronizedLoc(ReadSourceLocation());
1226 void ASTStmtReader::VisitObjCAtThrowStmt(ObjCAtThrowStmt *S) {
1228 S->setThrowExpr(Record.readSubStmt());
1229 S->setThrowLoc(ReadSourceLocation());
1232 void ASTStmtReader::VisitObjCBoolLiteralExpr(ObjCBoolLiteralExpr *E) {
1234 E->setValue(Record.readInt());
1235 E->setLocation(ReadSourceLocation());
1238 void ASTStmtReader::VisitObjCAvailabilityCheckExpr(ObjCAvailabilityCheckExpr *E) {
1240 SourceRange R = Record.readSourceRange();
1241 E->AtLoc = R.getBegin();
1242 E->RParen = R.getEnd();
1243 E->VersionToCheck = Record.readVersionTuple();
1246 //===----------------------------------------------------------------------===//
1247 // C++ Expressions and Statements
1248 //===----------------------------------------------------------------------===//
1250 void ASTStmtReader::VisitCXXCatchStmt(CXXCatchStmt *S) {
1252 S->CatchLoc = ReadSourceLocation();
1253 S->ExceptionDecl = ReadDeclAs<VarDecl>();
1254 S->HandlerBlock = Record.readSubStmt();
1257 void ASTStmtReader::VisitCXXTryStmt(CXXTryStmt *S) {
1259 assert(Record.peekInt() == S->getNumHandlers() && "NumStmtFields is wrong ?");
1261 S->TryLoc = ReadSourceLocation();
1262 S->getStmts()[0] = Record.readSubStmt();
1263 for (unsigned i = 0, e = S->getNumHandlers(); i != e; ++i)
1264 S->getStmts()[i + 1] = Record.readSubStmt();
1267 void ASTStmtReader::VisitCXXForRangeStmt(CXXForRangeStmt *S) {
1269 S->ForLoc = ReadSourceLocation();
1270 S->CoawaitLoc = ReadSourceLocation();
1271 S->ColonLoc = ReadSourceLocation();
1272 S->RParenLoc = ReadSourceLocation();
1273 S->setRangeStmt(Record.readSubStmt());
1274 S->setBeginStmt(Record.readSubStmt());
1275 S->setEndStmt(Record.readSubStmt());
1276 S->setCond(Record.readSubExpr());
1277 S->setInc(Record.readSubExpr());
1278 S->setLoopVarStmt(Record.readSubStmt());
1279 S->setBody(Record.readSubStmt());
1282 void ASTStmtReader::VisitMSDependentExistsStmt(MSDependentExistsStmt *S) {
1284 S->KeywordLoc = ReadSourceLocation();
1285 S->IsIfExists = Record.readInt();
1286 S->QualifierLoc = Record.readNestedNameSpecifierLoc();
1287 ReadDeclarationNameInfo(S->NameInfo);
1288 S->SubStmt = Record.readSubStmt();
1291 void ASTStmtReader::VisitCXXOperatorCallExpr(CXXOperatorCallExpr *E) {
1293 E->Operator = (OverloadedOperatorKind)Record.readInt();
1294 E->Range = Record.readSourceRange();
1295 E->setFPFeatures(FPOptions(Record.readInt()));
1298 void ASTStmtReader::VisitCXXConstructExpr(CXXConstructExpr *E) {
1300 E->NumArgs = Record.readInt();
1302 E->Args = new (Record.getContext()) Stmt*[E->NumArgs];
1303 for (unsigned I = 0, N = E->getNumArgs(); I != N; ++I)
1304 E->setArg(I, Record.readSubExpr());
1305 E->setConstructor(ReadDeclAs<CXXConstructorDecl>());
1306 E->setLocation(ReadSourceLocation());
1307 E->setElidable(Record.readInt());
1308 E->setHadMultipleCandidates(Record.readInt());
1309 E->setListInitialization(Record.readInt());
1310 E->setStdInitListInitialization(Record.readInt());
1311 E->setRequiresZeroInitialization(Record.readInt());
1312 E->setConstructionKind((CXXConstructExpr::ConstructionKind)Record.readInt());
1313 E->ParenOrBraceRange = ReadSourceRange();
1316 void ASTStmtReader::VisitCXXInheritedCtorInitExpr(CXXInheritedCtorInitExpr *E) {
1318 E->Constructor = ReadDeclAs<CXXConstructorDecl>();
1319 E->Loc = ReadSourceLocation();
1320 E->ConstructsVirtualBase = Record.readInt();
1321 E->InheritedFromVirtualBase = Record.readInt();
1324 void ASTStmtReader::VisitCXXTemporaryObjectExpr(CXXTemporaryObjectExpr *E) {
1325 VisitCXXConstructExpr(E);
1326 E->Type = GetTypeSourceInfo();
1329 void ASTStmtReader::VisitLambdaExpr(LambdaExpr *E) {
1331 unsigned NumCaptures = Record.readInt();
1332 assert(NumCaptures == E->NumCaptures);(void)NumCaptures;
1333 E->IntroducerRange = ReadSourceRange();
1334 E->CaptureDefault = static_cast<LambdaCaptureDefault>(Record.readInt());
1335 E->CaptureDefaultLoc = ReadSourceLocation();
1336 E->ExplicitParams = Record.readInt();
1337 E->ExplicitResultType = Record.readInt();
1338 E->ClosingBrace = ReadSourceLocation();
1340 // Read capture initializers.
1341 for (LambdaExpr::capture_init_iterator C = E->capture_init_begin(),
1342 CEnd = E->capture_init_end();
1344 *C = Record.readSubExpr();
1348 ASTStmtReader::VisitCXXStdInitializerListExpr(CXXStdInitializerListExpr *E) {
1350 E->SubExpr = Record.readSubExpr();
1353 void ASTStmtReader::VisitCXXNamedCastExpr(CXXNamedCastExpr *E) {
1354 VisitExplicitCastExpr(E);
1355 SourceRange R = ReadSourceRange();
1356 E->Loc = R.getBegin();
1357 E->RParenLoc = R.getEnd();
1358 R = ReadSourceRange();
1359 E->AngleBrackets = R;
1362 void ASTStmtReader::VisitCXXStaticCastExpr(CXXStaticCastExpr *E) {
1363 return VisitCXXNamedCastExpr(E);
1366 void ASTStmtReader::VisitCXXDynamicCastExpr(CXXDynamicCastExpr *E) {
1367 return VisitCXXNamedCastExpr(E);
1370 void ASTStmtReader::VisitCXXReinterpretCastExpr(CXXReinterpretCastExpr *E) {
1371 return VisitCXXNamedCastExpr(E);
1374 void ASTStmtReader::VisitCXXConstCastExpr(CXXConstCastExpr *E) {
1375 return VisitCXXNamedCastExpr(E);
1378 void ASTStmtReader::VisitCXXFunctionalCastExpr(CXXFunctionalCastExpr *E) {
1379 VisitExplicitCastExpr(E);
1380 E->setLParenLoc(ReadSourceLocation());
1381 E->setRParenLoc(ReadSourceLocation());
1384 void ASTStmtReader::VisitUserDefinedLiteral(UserDefinedLiteral *E) {
1386 E->UDSuffixLoc = ReadSourceLocation();
1389 void ASTStmtReader::VisitCXXBoolLiteralExpr(CXXBoolLiteralExpr *E) {
1391 E->setValue(Record.readInt());
1392 E->setLocation(ReadSourceLocation());
1395 void ASTStmtReader::VisitCXXNullPtrLiteralExpr(CXXNullPtrLiteralExpr *E) {
1397 E->setLocation(ReadSourceLocation());
1400 void ASTStmtReader::VisitCXXTypeidExpr(CXXTypeidExpr *E) {
1402 E->setSourceRange(ReadSourceRange());
1403 if (E->isTypeOperand()) { // typeid(int)
1404 E->setTypeOperandSourceInfo(
1405 GetTypeSourceInfo());
1410 E->setExprOperand(Record.readSubExpr());
1413 void ASTStmtReader::VisitCXXThisExpr(CXXThisExpr *E) {
1415 E->setLocation(ReadSourceLocation());
1416 E->setImplicit(Record.readInt());
1419 void ASTStmtReader::VisitCXXThrowExpr(CXXThrowExpr *E) {
1421 E->ThrowLoc = ReadSourceLocation();
1422 E->Op = Record.readSubExpr();
1423 E->IsThrownVariableInScope = Record.readInt();
1426 void ASTStmtReader::VisitCXXDefaultArgExpr(CXXDefaultArgExpr *E) {
1428 E->Param = ReadDeclAs<ParmVarDecl>();
1429 E->Loc = ReadSourceLocation();
1432 void ASTStmtReader::VisitCXXDefaultInitExpr(CXXDefaultInitExpr *E) {
1434 E->Field = ReadDeclAs<FieldDecl>();
1435 E->Loc = ReadSourceLocation();
1438 void ASTStmtReader::VisitCXXBindTemporaryExpr(CXXBindTemporaryExpr *E) {
1440 E->setTemporary(Record.readCXXTemporary());
1441 E->setSubExpr(Record.readSubExpr());
1444 void ASTStmtReader::VisitCXXScalarValueInitExpr(CXXScalarValueInitExpr *E) {
1446 E->TypeInfo = GetTypeSourceInfo();
1447 E->RParenLoc = ReadSourceLocation();
1450 void ASTStmtReader::VisitCXXNewExpr(CXXNewExpr *E) {
1452 E->GlobalNew = Record.readInt();
1453 bool isArray = Record.readInt();
1454 E->PassAlignment = Record.readInt();
1455 E->UsualArrayDeleteWantsSize = Record.readInt();
1456 unsigned NumPlacementArgs = Record.readInt();
1457 E->StoredInitializationStyle = Record.readInt();
1458 E->setOperatorNew(ReadDeclAs<FunctionDecl>());
1459 E->setOperatorDelete(ReadDeclAs<FunctionDecl>());
1460 E->AllocatedTypeInfo = GetTypeSourceInfo();
1461 E->TypeIdParens = ReadSourceRange();
1462 E->Range = ReadSourceRange();
1463 E->DirectInitRange = ReadSourceRange();
1465 E->AllocateArgsArray(Record.getContext(), isArray, NumPlacementArgs,
1466 E->StoredInitializationStyle != 0);
1468 // Install all the subexpressions.
1469 for (CXXNewExpr::raw_arg_iterator I = E->raw_arg_begin(),e = E->raw_arg_end();
1471 *I = Record.readSubStmt();
1474 void ASTStmtReader::VisitCXXDeleteExpr(CXXDeleteExpr *E) {
1476 E->GlobalDelete = Record.readInt();
1477 E->ArrayForm = Record.readInt();
1478 E->ArrayFormAsWritten = Record.readInt();
1479 E->UsualArrayDeleteWantsSize = Record.readInt();
1480 E->OperatorDelete = ReadDeclAs<FunctionDecl>();
1481 E->Argument = Record.readSubExpr();
1482 E->Loc = ReadSourceLocation();
1485 void ASTStmtReader::VisitCXXPseudoDestructorExpr(CXXPseudoDestructorExpr *E) {
1488 E->Base = Record.readSubExpr();
1489 E->IsArrow = Record.readInt();
1490 E->OperatorLoc = ReadSourceLocation();
1491 E->QualifierLoc = Record.readNestedNameSpecifierLoc();
1492 E->ScopeType = GetTypeSourceInfo();
1493 E->ColonColonLoc = ReadSourceLocation();
1494 E->TildeLoc = ReadSourceLocation();
1496 IdentifierInfo *II = Record.getIdentifierInfo();
1498 E->setDestroyedType(II, ReadSourceLocation());
1500 E->setDestroyedType(GetTypeSourceInfo());
1503 void ASTStmtReader::VisitExprWithCleanups(ExprWithCleanups *E) {
1506 unsigned NumObjects = Record.readInt();
1507 assert(NumObjects == E->getNumObjects());
1508 for (unsigned i = 0; i != NumObjects; ++i)
1509 E->getTrailingObjects<BlockDecl *>()[i] =
1510 ReadDeclAs<BlockDecl>();
1512 E->ExprWithCleanupsBits.CleanupsHaveSideEffects = Record.readInt();
1513 E->SubExpr = Record.readSubExpr();
1517 ASTStmtReader::VisitCXXDependentScopeMemberExpr(CXXDependentScopeMemberExpr *E){
1520 if (Record.readInt()) // HasTemplateKWAndArgsInfo
1521 ReadTemplateKWAndArgsInfo(
1522 *E->getTrailingObjects<ASTTemplateKWAndArgsInfo>(),
1523 E->getTrailingObjects<TemplateArgumentLoc>(),
1524 /*NumTemplateArgs=*/Record.readInt());
1526 E->Base = Record.readSubExpr();
1527 E->BaseType = Record.readType();
1528 E->IsArrow = Record.readInt();
1529 E->OperatorLoc = ReadSourceLocation();
1530 E->QualifierLoc = Record.readNestedNameSpecifierLoc();
1531 E->FirstQualifierFoundInScope = ReadDeclAs<NamedDecl>();
1532 ReadDeclarationNameInfo(E->MemberNameInfo);
1536 ASTStmtReader::VisitDependentScopeDeclRefExpr(DependentScopeDeclRefExpr *E) {
1539 if (Record.readInt()) // HasTemplateKWAndArgsInfo
1540 ReadTemplateKWAndArgsInfo(
1541 *E->getTrailingObjects<ASTTemplateKWAndArgsInfo>(),
1542 E->getTrailingObjects<TemplateArgumentLoc>(),
1543 /*NumTemplateArgs=*/Record.readInt());
1545 E->QualifierLoc = Record.readNestedNameSpecifierLoc();
1546 ReadDeclarationNameInfo(E->NameInfo);
1550 ASTStmtReader::VisitCXXUnresolvedConstructExpr(CXXUnresolvedConstructExpr *E) {
1552 assert(Record.peekInt() == E->arg_size() &&
1553 "Read wrong record during creation ?");
1555 for (unsigned I = 0, N = E->arg_size(); I != N; ++I)
1556 E->setArg(I, Record.readSubExpr());
1557 E->Type = GetTypeSourceInfo();
1558 E->setLParenLoc(ReadSourceLocation());
1559 E->setRParenLoc(ReadSourceLocation());
1562 void ASTStmtReader::VisitOverloadExpr(OverloadExpr *E) {
1565 if (Record.readInt()) // HasTemplateKWAndArgsInfo
1566 ReadTemplateKWAndArgsInfo(*E->getTrailingASTTemplateKWAndArgsInfo(),
1567 E->getTrailingTemplateArgumentLoc(),
1568 /*NumTemplateArgs=*/Record.readInt());
1570 unsigned NumDecls = Record.readInt();
1571 UnresolvedSet<8> Decls;
1572 for (unsigned i = 0; i != NumDecls; ++i) {
1573 auto *D = ReadDeclAs<NamedDecl>();
1574 auto AS = (AccessSpecifier)Record.readInt();
1575 Decls.addDecl(D, AS);
1577 E->initializeResults(Record.getContext(), Decls.begin(), Decls.end());
1579 ReadDeclarationNameInfo(E->NameInfo);
1580 E->QualifierLoc = Record.readNestedNameSpecifierLoc();
1583 void ASTStmtReader::VisitUnresolvedMemberExpr(UnresolvedMemberExpr *E) {
1584 VisitOverloadExpr(E);
1585 E->IsArrow = Record.readInt();
1586 E->HasUnresolvedUsing = Record.readInt();
1587 E->Base = Record.readSubExpr();
1588 E->BaseType = Record.readType();
1589 E->OperatorLoc = ReadSourceLocation();
1592 void ASTStmtReader::VisitUnresolvedLookupExpr(UnresolvedLookupExpr *E) {
1593 VisitOverloadExpr(E);
1594 E->RequiresADL = Record.readInt();
1595 E->Overloaded = Record.readInt();
1596 E->NamingClass = ReadDeclAs<CXXRecordDecl>();
1599 void ASTStmtReader::VisitTypeTraitExpr(TypeTraitExpr *E) {
1601 E->TypeTraitExprBits.NumArgs = Record.readInt();
1602 E->TypeTraitExprBits.Kind = Record.readInt();
1603 E->TypeTraitExprBits.Value = Record.readInt();
1604 SourceRange Range = ReadSourceRange();
1605 E->Loc = Range.getBegin();
1606 E->RParenLoc = Range.getEnd();
1608 auto **Args = E->getTrailingObjects<TypeSourceInfo *>();
1609 for (unsigned I = 0, N = E->getNumArgs(); I != N; ++I)
1610 Args[I] = GetTypeSourceInfo();
1613 void ASTStmtReader::VisitArrayTypeTraitExpr(ArrayTypeTraitExpr *E) {
1615 E->ATT = (ArrayTypeTrait)Record.readInt();
1616 E->Value = (unsigned int)Record.readInt();
1617 SourceRange Range = ReadSourceRange();
1618 E->Loc = Range.getBegin();
1619 E->RParen = Range.getEnd();
1620 E->QueriedType = GetTypeSourceInfo();
1621 E->Dimension = Record.readSubExpr();
1624 void ASTStmtReader::VisitExpressionTraitExpr(ExpressionTraitExpr *E) {
1626 E->ET = (ExpressionTrait)Record.readInt();
1627 E->Value = (bool)Record.readInt();
1628 SourceRange Range = ReadSourceRange();
1629 E->QueriedExpression = Record.readSubExpr();
1630 E->Loc = Range.getBegin();
1631 E->RParen = Range.getEnd();
1634 void ASTStmtReader::VisitCXXNoexceptExpr(CXXNoexceptExpr *E) {
1636 E->Value = (bool)Record.readInt();
1637 E->Range = ReadSourceRange();
1638 E->Operand = Record.readSubExpr();
1641 void ASTStmtReader::VisitPackExpansionExpr(PackExpansionExpr *E) {
1643 E->EllipsisLoc = ReadSourceLocation();
1644 E->NumExpansions = Record.readInt();
1645 E->Pattern = Record.readSubExpr();
1648 void ASTStmtReader::VisitSizeOfPackExpr(SizeOfPackExpr *E) {
1650 unsigned NumPartialArgs = Record.readInt();
1651 E->OperatorLoc = ReadSourceLocation();
1652 E->PackLoc = ReadSourceLocation();
1653 E->RParenLoc = ReadSourceLocation();
1654 E->Pack = Record.readDeclAs<NamedDecl>();
1655 if (E->isPartiallySubstituted()) {
1656 assert(E->Length == NumPartialArgs);
1657 for (auto *I = E->getTrailingObjects<TemplateArgument>(),
1658 *E = I + NumPartialArgs;
1660 new (I) TemplateArgument(Record.readTemplateArgument());
1661 } else if (!E->isValueDependent()) {
1662 E->Length = Record.readInt();
1666 void ASTStmtReader::VisitSubstNonTypeTemplateParmExpr(
1667 SubstNonTypeTemplateParmExpr *E) {
1669 E->Param = ReadDeclAs<NonTypeTemplateParmDecl>();
1670 E->NameLoc = ReadSourceLocation();
1671 E->Replacement = Record.readSubExpr();
1674 void ASTStmtReader::VisitSubstNonTypeTemplateParmPackExpr(
1675 SubstNonTypeTemplateParmPackExpr *E) {
1677 E->Param = ReadDeclAs<NonTypeTemplateParmDecl>();
1678 TemplateArgument ArgPack = Record.readTemplateArgument();
1679 if (ArgPack.getKind() != TemplateArgument::Pack)
1682 E->Arguments = ArgPack.pack_begin();
1683 E->NumArguments = ArgPack.pack_size();
1684 E->NameLoc = ReadSourceLocation();
1687 void ASTStmtReader::VisitFunctionParmPackExpr(FunctionParmPackExpr *E) {
1689 E->NumParameters = Record.readInt();
1690 E->ParamPack = ReadDeclAs<ParmVarDecl>();
1691 E->NameLoc = ReadSourceLocation();
1692 auto **Parms = E->getTrailingObjects<ParmVarDecl *>();
1693 for (unsigned i = 0, n = E->NumParameters; i != n; ++i)
1694 Parms[i] = ReadDeclAs<ParmVarDecl>();
1697 void ASTStmtReader::VisitMaterializeTemporaryExpr(MaterializeTemporaryExpr *E) {
1699 E->State = Record.readSubExpr();
1700 auto *VD = ReadDeclAs<ValueDecl>();
1701 unsigned ManglingNumber = Record.readInt();
1702 E->setExtendingDecl(VD, ManglingNumber);
1705 void ASTStmtReader::VisitCXXFoldExpr(CXXFoldExpr *E) {
1707 E->LParenLoc = ReadSourceLocation();
1708 E->EllipsisLoc = ReadSourceLocation();
1709 E->RParenLoc = ReadSourceLocation();
1710 E->SubExprs[0] = Record.readSubExpr();
1711 E->SubExprs[1] = Record.readSubExpr();
1712 E->Opcode = (BinaryOperatorKind)Record.readInt();
1715 void ASTStmtReader::VisitOpaqueValueExpr(OpaqueValueExpr *E) {
1717 E->SourceExpr = Record.readSubExpr();
1718 E->Loc = ReadSourceLocation();
1719 E->setIsUnique(Record.readInt());
1722 void ASTStmtReader::VisitTypoExpr(TypoExpr *E) {
1723 llvm_unreachable("Cannot read TypoExpr nodes");
1726 //===----------------------------------------------------------------------===//
1727 // Microsoft Expressions and Statements
1728 //===----------------------------------------------------------------------===//
1729 void ASTStmtReader::VisitMSPropertyRefExpr(MSPropertyRefExpr *E) {
1731 E->IsArrow = (Record.readInt() != 0);
1732 E->BaseExpr = Record.readSubExpr();
1733 E->QualifierLoc = Record.readNestedNameSpecifierLoc();
1734 E->MemberLoc = ReadSourceLocation();
1735 E->TheDecl = ReadDeclAs<MSPropertyDecl>();
1738 void ASTStmtReader::VisitMSPropertySubscriptExpr(MSPropertySubscriptExpr *E) {
1740 E->setBase(Record.readSubExpr());
1741 E->setIdx(Record.readSubExpr());
1742 E->setRBracketLoc(ReadSourceLocation());
1745 void ASTStmtReader::VisitCXXUuidofExpr(CXXUuidofExpr *E) {
1747 E->setSourceRange(ReadSourceRange());
1748 std::string UuidStr = ReadString();
1749 E->setUuidStr(StringRef(UuidStr).copy(Record.getContext()));
1750 if (E->isTypeOperand()) { // __uuidof(ComType)
1751 E->setTypeOperandSourceInfo(
1752 GetTypeSourceInfo());
1757 E->setExprOperand(Record.readSubExpr());
1760 void ASTStmtReader::VisitSEHLeaveStmt(SEHLeaveStmt *S) {
1762 S->setLeaveLoc(ReadSourceLocation());
1765 void ASTStmtReader::VisitSEHExceptStmt(SEHExceptStmt *S) {
1767 S->Loc = ReadSourceLocation();
1768 S->Children[SEHExceptStmt::FILTER_EXPR] = Record.readSubStmt();
1769 S->Children[SEHExceptStmt::BLOCK] = Record.readSubStmt();
1772 void ASTStmtReader::VisitSEHFinallyStmt(SEHFinallyStmt *S) {
1774 S->Loc = ReadSourceLocation();
1775 S->Block = Record.readSubStmt();
1778 void ASTStmtReader::VisitSEHTryStmt(SEHTryStmt *S) {
1780 S->IsCXXTry = Record.readInt();
1781 S->TryLoc = ReadSourceLocation();
1782 S->Children[SEHTryStmt::TRY] = Record.readSubStmt();
1783 S->Children[SEHTryStmt::HANDLER] = Record.readSubStmt();
1786 //===----------------------------------------------------------------------===//
1787 // CUDA Expressions and Statements
1788 //===----------------------------------------------------------------------===//
1790 void ASTStmtReader::VisitCUDAKernelCallExpr(CUDAKernelCallExpr *E) {
1792 E->setConfig(cast<CallExpr>(Record.readSubExpr()));
1795 //===----------------------------------------------------------------------===//
1796 // OpenCL Expressions and Statements.
1797 //===----------------------------------------------------------------------===//
1798 void ASTStmtReader::VisitAsTypeExpr(AsTypeExpr *E) {
1800 E->BuiltinLoc = ReadSourceLocation();
1801 E->RParenLoc = ReadSourceLocation();
1802 E->SrcExpr = Record.readSubExpr();
1805 //===----------------------------------------------------------------------===//
1807 //===----------------------------------------------------------------------===//
1811 class OMPClauseReader : public OMPClauseVisitor<OMPClauseReader> {
1812 ASTStmtReader *Reader;
1813 ASTContext &Context;
1816 OMPClauseReader(ASTStmtReader *R, ASTRecordReader &Record)
1817 : Reader(R), Context(Record.getContext()) {}
1819 #define OPENMP_CLAUSE(Name, Class) void Visit##Class(Class *C);
1820 #include "clang/Basic/OpenMPKinds.def"
1821 OMPClause *readClause();
1822 void VisitOMPClauseWithPreInit(OMPClauseWithPreInit *C);
1823 void VisitOMPClauseWithPostUpdate(OMPClauseWithPostUpdate *C);
1826 } // namespace clang
1828 OMPClause *OMPClauseReader::readClause() {
1830 switch (Reader->Record.readInt()) {
1832 C = new (Context) OMPIfClause();
1835 C = new (Context) OMPFinalClause();
1837 case OMPC_num_threads:
1838 C = new (Context) OMPNumThreadsClause();
1841 C = new (Context) OMPSafelenClause();
1844 C = new (Context) OMPSimdlenClause();
1847 C = new (Context) OMPCollapseClause();
1850 C = new (Context) OMPDefaultClause();
1852 case OMPC_proc_bind:
1853 C = new (Context) OMPProcBindClause();
1856 C = new (Context) OMPScheduleClause();
1859 C = OMPOrderedClause::CreateEmpty(Context, Reader->Record.readInt());
1862 C = new (Context) OMPNowaitClause();
1865 C = new (Context) OMPUntiedClause();
1867 case OMPC_mergeable:
1868 C = new (Context) OMPMergeableClause();
1871 C = new (Context) OMPReadClause();
1874 C = new (Context) OMPWriteClause();
1877 C = new (Context) OMPUpdateClause();
1880 C = new (Context) OMPCaptureClause();
1883 C = new (Context) OMPSeqCstClause();
1886 C = new (Context) OMPThreadsClause();
1889 C = new (Context) OMPSIMDClause();
1892 C = new (Context) OMPNogroupClause();
1895 C = OMPPrivateClause::CreateEmpty(Context, Reader->Record.readInt());
1897 case OMPC_firstprivate:
1898 C = OMPFirstprivateClause::CreateEmpty(Context, Reader->Record.readInt());
1900 case OMPC_lastprivate:
1901 C = OMPLastprivateClause::CreateEmpty(Context, Reader->Record.readInt());
1904 C = OMPSharedClause::CreateEmpty(Context, Reader->Record.readInt());
1906 case OMPC_reduction:
1907 C = OMPReductionClause::CreateEmpty(Context, Reader->Record.readInt());
1909 case OMPC_task_reduction:
1910 C = OMPTaskReductionClause::CreateEmpty(Context, Reader->Record.readInt());
1912 case OMPC_in_reduction:
1913 C = OMPInReductionClause::CreateEmpty(Context, Reader->Record.readInt());
1916 C = OMPLinearClause::CreateEmpty(Context, Reader->Record.readInt());
1919 C = OMPAlignedClause::CreateEmpty(Context, Reader->Record.readInt());
1922 C = OMPCopyinClause::CreateEmpty(Context, Reader->Record.readInt());
1924 case OMPC_copyprivate:
1925 C = OMPCopyprivateClause::CreateEmpty(Context, Reader->Record.readInt());
1928 C = OMPFlushClause::CreateEmpty(Context, Reader->Record.readInt());
1931 unsigned NumVars = Reader->Record.readInt();
1932 unsigned NumLoops = Reader->Record.readInt();
1933 C = OMPDependClause::CreateEmpty(Context, NumVars, NumLoops);
1937 C = new (Context) OMPDeviceClause();
1940 unsigned NumVars = Reader->Record.readInt();
1941 unsigned NumDeclarations = Reader->Record.readInt();
1942 unsigned NumLists = Reader->Record.readInt();
1943 unsigned NumComponents = Reader->Record.readInt();
1944 C = OMPMapClause::CreateEmpty(Context, NumVars, NumDeclarations, NumLists,
1948 case OMPC_num_teams:
1949 C = new (Context) OMPNumTeamsClause();
1951 case OMPC_thread_limit:
1952 C = new (Context) OMPThreadLimitClause();
1955 C = new (Context) OMPPriorityClause();
1957 case OMPC_grainsize:
1958 C = new (Context) OMPGrainsizeClause();
1960 case OMPC_num_tasks:
1961 C = new (Context) OMPNumTasksClause();
1964 C = new (Context) OMPHintClause();
1966 case OMPC_dist_schedule:
1967 C = new (Context) OMPDistScheduleClause();
1969 case OMPC_defaultmap:
1970 C = new (Context) OMPDefaultmapClause();
1973 unsigned NumVars = Reader->Record.readInt();
1974 unsigned NumDeclarations = Reader->Record.readInt();
1975 unsigned NumLists = Reader->Record.readInt();
1976 unsigned NumComponents = Reader->Record.readInt();
1977 C = OMPToClause::CreateEmpty(Context, NumVars, NumDeclarations, NumLists,
1982 unsigned NumVars = Reader->Record.readInt();
1983 unsigned NumDeclarations = Reader->Record.readInt();
1984 unsigned NumLists = Reader->Record.readInt();
1985 unsigned NumComponents = Reader->Record.readInt();
1986 C = OMPFromClause::CreateEmpty(Context, NumVars, NumDeclarations, NumLists,
1990 case OMPC_use_device_ptr: {
1991 unsigned NumVars = Reader->Record.readInt();
1992 unsigned NumDeclarations = Reader->Record.readInt();
1993 unsigned NumLists = Reader->Record.readInt();
1994 unsigned NumComponents = Reader->Record.readInt();
1995 C = OMPUseDevicePtrClause::CreateEmpty(Context, NumVars, NumDeclarations,
1996 NumLists, NumComponents);
1999 case OMPC_is_device_ptr: {
2000 unsigned NumVars = Reader->Record.readInt();
2001 unsigned NumDeclarations = Reader->Record.readInt();
2002 unsigned NumLists = Reader->Record.readInt();
2003 unsigned NumComponents = Reader->Record.readInt();
2004 C = OMPIsDevicePtrClause::CreateEmpty(Context, NumVars, NumDeclarations,
2005 NumLists, NumComponents);
2010 C->setLocStart(Reader->ReadSourceLocation());
2011 C->setLocEnd(Reader->ReadSourceLocation());
2016 void OMPClauseReader::VisitOMPClauseWithPreInit(OMPClauseWithPreInit *C) {
2017 C->setPreInitStmt(Reader->Record.readSubStmt(),
2018 static_cast<OpenMPDirectiveKind>(Reader->Record.readInt()));
2021 void OMPClauseReader::VisitOMPClauseWithPostUpdate(OMPClauseWithPostUpdate *C) {
2022 VisitOMPClauseWithPreInit(C);
2023 C->setPostUpdateExpr(Reader->Record.readSubExpr());
2026 void OMPClauseReader::VisitOMPIfClause(OMPIfClause *C) {
2027 VisitOMPClauseWithPreInit(C);
2028 C->setNameModifier(static_cast<OpenMPDirectiveKind>(Reader->Record.readInt()));
2029 C->setNameModifierLoc(Reader->ReadSourceLocation());
2030 C->setColonLoc(Reader->ReadSourceLocation());
2031 C->setCondition(Reader->Record.readSubExpr());
2032 C->setLParenLoc(Reader->ReadSourceLocation());
2035 void OMPClauseReader::VisitOMPFinalClause(OMPFinalClause *C) {
2036 C->setCondition(Reader->Record.readSubExpr());
2037 C->setLParenLoc(Reader->ReadSourceLocation());
2040 void OMPClauseReader::VisitOMPNumThreadsClause(OMPNumThreadsClause *C) {
2041 VisitOMPClauseWithPreInit(C);
2042 C->setNumThreads(Reader->Record.readSubExpr());
2043 C->setLParenLoc(Reader->ReadSourceLocation());
2046 void OMPClauseReader::VisitOMPSafelenClause(OMPSafelenClause *C) {
2047 C->setSafelen(Reader->Record.readSubExpr());
2048 C->setLParenLoc(Reader->ReadSourceLocation());
2051 void OMPClauseReader::VisitOMPSimdlenClause(OMPSimdlenClause *C) {
2052 C->setSimdlen(Reader->Record.readSubExpr());
2053 C->setLParenLoc(Reader->ReadSourceLocation());
2056 void OMPClauseReader::VisitOMPCollapseClause(OMPCollapseClause *C) {
2057 C->setNumForLoops(Reader->Record.readSubExpr());
2058 C->setLParenLoc(Reader->ReadSourceLocation());
2061 void OMPClauseReader::VisitOMPDefaultClause(OMPDefaultClause *C) {
2063 static_cast<OpenMPDefaultClauseKind>(Reader->Record.readInt()));
2064 C->setLParenLoc(Reader->ReadSourceLocation());
2065 C->setDefaultKindKwLoc(Reader->ReadSourceLocation());
2068 void OMPClauseReader::VisitOMPProcBindClause(OMPProcBindClause *C) {
2070 static_cast<OpenMPProcBindClauseKind>(Reader->Record.readInt()));
2071 C->setLParenLoc(Reader->ReadSourceLocation());
2072 C->setProcBindKindKwLoc(Reader->ReadSourceLocation());
2075 void OMPClauseReader::VisitOMPScheduleClause(OMPScheduleClause *C) {
2076 VisitOMPClauseWithPreInit(C);
2078 static_cast<OpenMPScheduleClauseKind>(Reader->Record.readInt()));
2079 C->setFirstScheduleModifier(
2080 static_cast<OpenMPScheduleClauseModifier>(Reader->Record.readInt()));
2081 C->setSecondScheduleModifier(
2082 static_cast<OpenMPScheduleClauseModifier>(Reader->Record.readInt()));
2083 C->setChunkSize(Reader->Record.readSubExpr());
2084 C->setLParenLoc(Reader->ReadSourceLocation());
2085 C->setFirstScheduleModifierLoc(Reader->ReadSourceLocation());
2086 C->setSecondScheduleModifierLoc(Reader->ReadSourceLocation());
2087 C->setScheduleKindLoc(Reader->ReadSourceLocation());
2088 C->setCommaLoc(Reader->ReadSourceLocation());
2091 void OMPClauseReader::VisitOMPOrderedClause(OMPOrderedClause *C) {
2092 C->setNumForLoops(Reader->Record.readSubExpr());
2093 for (unsigned I = 0, E = C->NumberOfLoops; I < E; ++I)
2094 C->setLoopNumIterations(I, Reader->Record.readSubExpr());
2095 for (unsigned I = 0, E = C->NumberOfLoops; I < E; ++I)
2096 C->setLoopCounter(I, Reader->Record.readSubExpr());
2097 C->setLParenLoc(Reader->ReadSourceLocation());
2100 void OMPClauseReader::VisitOMPNowaitClause(OMPNowaitClause *) {}
2102 void OMPClauseReader::VisitOMPUntiedClause(OMPUntiedClause *) {}
2104 void OMPClauseReader::VisitOMPMergeableClause(OMPMergeableClause *) {}
2106 void OMPClauseReader::VisitOMPReadClause(OMPReadClause *) {}
2108 void OMPClauseReader::VisitOMPWriteClause(OMPWriteClause *) {}
2110 void OMPClauseReader::VisitOMPUpdateClause(OMPUpdateClause *) {}
2112 void OMPClauseReader::VisitOMPCaptureClause(OMPCaptureClause *) {}
2114 void OMPClauseReader::VisitOMPSeqCstClause(OMPSeqCstClause *) {}
2116 void OMPClauseReader::VisitOMPThreadsClause(OMPThreadsClause *) {}
2118 void OMPClauseReader::VisitOMPSIMDClause(OMPSIMDClause *) {}
2120 void OMPClauseReader::VisitOMPNogroupClause(OMPNogroupClause *) {}
2122 void OMPClauseReader::VisitOMPPrivateClause(OMPPrivateClause *C) {
2123 C->setLParenLoc(Reader->ReadSourceLocation());
2124 unsigned NumVars = C->varlist_size();
2125 SmallVector<Expr *, 16> Vars;
2126 Vars.reserve(NumVars);
2127 for (unsigned i = 0; i != NumVars; ++i)
2128 Vars.push_back(Reader->Record.readSubExpr());
2129 C->setVarRefs(Vars);
2131 for (unsigned i = 0; i != NumVars; ++i)
2132 Vars.push_back(Reader->Record.readSubExpr());
2133 C->setPrivateCopies(Vars);
2136 void OMPClauseReader::VisitOMPFirstprivateClause(OMPFirstprivateClause *C) {
2137 VisitOMPClauseWithPreInit(C);
2138 C->setLParenLoc(Reader->ReadSourceLocation());
2139 unsigned NumVars = C->varlist_size();
2140 SmallVector<Expr *, 16> Vars;
2141 Vars.reserve(NumVars);
2142 for (unsigned i = 0; i != NumVars; ++i)
2143 Vars.push_back(Reader->Record.readSubExpr());
2144 C->setVarRefs(Vars);
2146 for (unsigned i = 0; i != NumVars; ++i)
2147 Vars.push_back(Reader->Record.readSubExpr());
2148 C->setPrivateCopies(Vars);
2150 for (unsigned i = 0; i != NumVars; ++i)
2151 Vars.push_back(Reader->Record.readSubExpr());
2155 void OMPClauseReader::VisitOMPLastprivateClause(OMPLastprivateClause *C) {
2156 VisitOMPClauseWithPostUpdate(C);
2157 C->setLParenLoc(Reader->ReadSourceLocation());
2158 unsigned NumVars = C->varlist_size();
2159 SmallVector<Expr *, 16> Vars;
2160 Vars.reserve(NumVars);
2161 for (unsigned i = 0; i != NumVars; ++i)
2162 Vars.push_back(Reader->Record.readSubExpr());
2163 C->setVarRefs(Vars);
2165 for (unsigned i = 0; i != NumVars; ++i)
2166 Vars.push_back(Reader->Record.readSubExpr());
2167 C->setPrivateCopies(Vars);
2169 for (unsigned i = 0; i != NumVars; ++i)
2170 Vars.push_back(Reader->Record.readSubExpr());
2171 C->setSourceExprs(Vars);
2173 for (unsigned i = 0; i != NumVars; ++i)
2174 Vars.push_back(Reader->Record.readSubExpr());
2175 C->setDestinationExprs(Vars);
2177 for (unsigned i = 0; i != NumVars; ++i)
2178 Vars.push_back(Reader->Record.readSubExpr());
2179 C->setAssignmentOps(Vars);
2182 void OMPClauseReader::VisitOMPSharedClause(OMPSharedClause *C) {
2183 C->setLParenLoc(Reader->ReadSourceLocation());
2184 unsigned NumVars = C->varlist_size();
2185 SmallVector<Expr *, 16> Vars;
2186 Vars.reserve(NumVars);
2187 for (unsigned i = 0; i != NumVars; ++i)
2188 Vars.push_back(Reader->Record.readSubExpr());
2189 C->setVarRefs(Vars);
2192 void OMPClauseReader::VisitOMPReductionClause(OMPReductionClause *C) {
2193 VisitOMPClauseWithPostUpdate(C);
2194 C->setLParenLoc(Reader->ReadSourceLocation());
2195 C->setColonLoc(Reader->ReadSourceLocation());
2196 NestedNameSpecifierLoc NNSL = Reader->Record.readNestedNameSpecifierLoc();
2197 DeclarationNameInfo DNI;
2198 Reader->ReadDeclarationNameInfo(DNI);
2199 C->setQualifierLoc(NNSL);
2200 C->setNameInfo(DNI);
2202 unsigned NumVars = C->varlist_size();
2203 SmallVector<Expr *, 16> Vars;
2204 Vars.reserve(NumVars);
2205 for (unsigned i = 0; i != NumVars; ++i)
2206 Vars.push_back(Reader->Record.readSubExpr());
2207 C->setVarRefs(Vars);
2209 for (unsigned i = 0; i != NumVars; ++i)
2210 Vars.push_back(Reader->Record.readSubExpr());
2211 C->setPrivates(Vars);
2213 for (unsigned i = 0; i != NumVars; ++i)
2214 Vars.push_back(Reader->Record.readSubExpr());
2215 C->setLHSExprs(Vars);
2217 for (unsigned i = 0; i != NumVars; ++i)
2218 Vars.push_back(Reader->Record.readSubExpr());
2219 C->setRHSExprs(Vars);
2221 for (unsigned i = 0; i != NumVars; ++i)
2222 Vars.push_back(Reader->Record.readSubExpr());
2223 C->setReductionOps(Vars);
2226 void OMPClauseReader::VisitOMPTaskReductionClause(OMPTaskReductionClause *C) {
2227 VisitOMPClauseWithPostUpdate(C);
2228 C->setLParenLoc(Reader->ReadSourceLocation());
2229 C->setColonLoc(Reader->ReadSourceLocation());
2230 NestedNameSpecifierLoc NNSL = Reader->Record.readNestedNameSpecifierLoc();
2231 DeclarationNameInfo DNI;
2232 Reader->ReadDeclarationNameInfo(DNI);
2233 C->setQualifierLoc(NNSL);
2234 C->setNameInfo(DNI);
2236 unsigned NumVars = C->varlist_size();
2237 SmallVector<Expr *, 16> Vars;
2238 Vars.reserve(NumVars);
2239 for (unsigned I = 0; I != NumVars; ++I)
2240 Vars.push_back(Reader->Record.readSubExpr());
2241 C->setVarRefs(Vars);
2243 for (unsigned I = 0; I != NumVars; ++I)
2244 Vars.push_back(Reader->Record.readSubExpr());
2245 C->setPrivates(Vars);
2247 for (unsigned I = 0; I != NumVars; ++I)
2248 Vars.push_back(Reader->Record.readSubExpr());
2249 C->setLHSExprs(Vars);
2251 for (unsigned I = 0; I != NumVars; ++I)
2252 Vars.push_back(Reader->Record.readSubExpr());
2253 C->setRHSExprs(Vars);
2255 for (unsigned I = 0; I != NumVars; ++I)
2256 Vars.push_back(Reader->Record.readSubExpr());
2257 C->setReductionOps(Vars);
2260 void OMPClauseReader::VisitOMPInReductionClause(OMPInReductionClause *C) {
2261 VisitOMPClauseWithPostUpdate(C);
2262 C->setLParenLoc(Reader->ReadSourceLocation());
2263 C->setColonLoc(Reader->ReadSourceLocation());
2264 NestedNameSpecifierLoc NNSL = Reader->Record.readNestedNameSpecifierLoc();
2265 DeclarationNameInfo DNI;
2266 Reader->ReadDeclarationNameInfo(DNI);
2267 C->setQualifierLoc(NNSL);
2268 C->setNameInfo(DNI);
2270 unsigned NumVars = C->varlist_size();
2271 SmallVector<Expr *, 16> Vars;
2272 Vars.reserve(NumVars);
2273 for (unsigned I = 0; I != NumVars; ++I)
2274 Vars.push_back(Reader->Record.readSubExpr());
2275 C->setVarRefs(Vars);
2277 for (unsigned I = 0; I != NumVars; ++I)
2278 Vars.push_back(Reader->Record.readSubExpr());
2279 C->setPrivates(Vars);
2281 for (unsigned I = 0; I != NumVars; ++I)
2282 Vars.push_back(Reader->Record.readSubExpr());
2283 C->setLHSExprs(Vars);
2285 for (unsigned I = 0; I != NumVars; ++I)
2286 Vars.push_back(Reader->Record.readSubExpr());
2287 C->setRHSExprs(Vars);
2289 for (unsigned I = 0; I != NumVars; ++I)
2290 Vars.push_back(Reader->Record.readSubExpr());
2291 C->setReductionOps(Vars);
2293 for (unsigned I = 0; I != NumVars; ++I)
2294 Vars.push_back(Reader->Record.readSubExpr());
2295 C->setTaskgroupDescriptors(Vars);
2298 void OMPClauseReader::VisitOMPLinearClause(OMPLinearClause *C) {
2299 VisitOMPClauseWithPostUpdate(C);
2300 C->setLParenLoc(Reader->ReadSourceLocation());
2301 C->setColonLoc(Reader->ReadSourceLocation());
2302 C->setModifier(static_cast<OpenMPLinearClauseKind>(Reader->Record.readInt()));
2303 C->setModifierLoc(Reader->ReadSourceLocation());
2304 unsigned NumVars = C->varlist_size();
2305 SmallVector<Expr *, 16> Vars;
2306 Vars.reserve(NumVars);
2307 for (unsigned i = 0; i != NumVars; ++i)
2308 Vars.push_back(Reader->Record.readSubExpr());
2309 C->setVarRefs(Vars);
2311 for (unsigned i = 0; i != NumVars; ++i)
2312 Vars.push_back(Reader->Record.readSubExpr());
2313 C->setPrivates(Vars);
2315 for (unsigned i = 0; i != NumVars; ++i)
2316 Vars.push_back(Reader->Record.readSubExpr());
2319 for (unsigned i = 0; i != NumVars; ++i)
2320 Vars.push_back(Reader->Record.readSubExpr());
2321 C->setUpdates(Vars);
2323 for (unsigned i = 0; i != NumVars; ++i)
2324 Vars.push_back(Reader->Record.readSubExpr());
2326 C->setStep(Reader->Record.readSubExpr());
2327 C->setCalcStep(Reader->Record.readSubExpr());
2330 void OMPClauseReader::VisitOMPAlignedClause(OMPAlignedClause *C) {
2331 C->setLParenLoc(Reader->ReadSourceLocation());
2332 C->setColonLoc(Reader->ReadSourceLocation());
2333 unsigned NumVars = C->varlist_size();
2334 SmallVector<Expr *, 16> Vars;
2335 Vars.reserve(NumVars);
2336 for (unsigned i = 0; i != NumVars; ++i)
2337 Vars.push_back(Reader->Record.readSubExpr());
2338 C->setVarRefs(Vars);
2339 C->setAlignment(Reader->Record.readSubExpr());
2342 void OMPClauseReader::VisitOMPCopyinClause(OMPCopyinClause *C) {
2343 C->setLParenLoc(Reader->ReadSourceLocation());
2344 unsigned NumVars = C->varlist_size();
2345 SmallVector<Expr *, 16> Exprs;
2346 Exprs.reserve(NumVars);
2347 for (unsigned i = 0; i != NumVars; ++i)
2348 Exprs.push_back(Reader->Record.readSubExpr());
2349 C->setVarRefs(Exprs);
2351 for (unsigned i = 0; i != NumVars; ++i)
2352 Exprs.push_back(Reader->Record.readSubExpr());
2353 C->setSourceExprs(Exprs);
2355 for (unsigned i = 0; i != NumVars; ++i)
2356 Exprs.push_back(Reader->Record.readSubExpr());
2357 C->setDestinationExprs(Exprs);
2359 for (unsigned i = 0; i != NumVars; ++i)
2360 Exprs.push_back(Reader->Record.readSubExpr());
2361 C->setAssignmentOps(Exprs);
2364 void OMPClauseReader::VisitOMPCopyprivateClause(OMPCopyprivateClause *C) {
2365 C->setLParenLoc(Reader->ReadSourceLocation());
2366 unsigned NumVars = C->varlist_size();
2367 SmallVector<Expr *, 16> Exprs;
2368 Exprs.reserve(NumVars);
2369 for (unsigned i = 0; i != NumVars; ++i)
2370 Exprs.push_back(Reader->Record.readSubExpr());
2371 C->setVarRefs(Exprs);
2373 for (unsigned i = 0; i != NumVars; ++i)
2374 Exprs.push_back(Reader->Record.readSubExpr());
2375 C->setSourceExprs(Exprs);
2377 for (unsigned i = 0; i != NumVars; ++i)
2378 Exprs.push_back(Reader->Record.readSubExpr());
2379 C->setDestinationExprs(Exprs);
2381 for (unsigned i = 0; i != NumVars; ++i)
2382 Exprs.push_back(Reader->Record.readSubExpr());
2383 C->setAssignmentOps(Exprs);
2386 void OMPClauseReader::VisitOMPFlushClause(OMPFlushClause *C) {
2387 C->setLParenLoc(Reader->ReadSourceLocation());
2388 unsigned NumVars = C->varlist_size();
2389 SmallVector<Expr *, 16> Vars;
2390 Vars.reserve(NumVars);
2391 for (unsigned i = 0; i != NumVars; ++i)
2392 Vars.push_back(Reader->Record.readSubExpr());
2393 C->setVarRefs(Vars);
2396 void OMPClauseReader::VisitOMPDependClause(OMPDependClause *C) {
2397 C->setLParenLoc(Reader->ReadSourceLocation());
2398 C->setDependencyKind(
2399 static_cast<OpenMPDependClauseKind>(Reader->Record.readInt()));
2400 C->setDependencyLoc(Reader->ReadSourceLocation());
2401 C->setColonLoc(Reader->ReadSourceLocation());
2402 unsigned NumVars = C->varlist_size();
2403 SmallVector<Expr *, 16> Vars;
2404 Vars.reserve(NumVars);
2405 for (unsigned I = 0; I != NumVars; ++I)
2406 Vars.push_back(Reader->Record.readSubExpr());
2407 C->setVarRefs(Vars);
2408 for (unsigned I = 0, E = C->getNumLoops(); I < E; ++I)
2409 C->setLoopData(I, Reader->Record.readSubExpr());
2412 void OMPClauseReader::VisitOMPDeviceClause(OMPDeviceClause *C) {
2413 VisitOMPClauseWithPreInit(C);
2414 C->setDevice(Reader->Record.readSubExpr());
2415 C->setLParenLoc(Reader->ReadSourceLocation());
2418 void OMPClauseReader::VisitOMPMapClause(OMPMapClause *C) {
2419 C->setLParenLoc(Reader->ReadSourceLocation());
2420 C->setMapTypeModifier(
2421 static_cast<OpenMPMapClauseKind>(Reader->Record.readInt()));
2423 static_cast<OpenMPMapClauseKind>(Reader->Record.readInt()));
2424 C->setMapLoc(Reader->ReadSourceLocation());
2425 C->setColonLoc(Reader->ReadSourceLocation());
2426 auto NumVars = C->varlist_size();
2427 auto UniqueDecls = C->getUniqueDeclarationsNum();
2428 auto TotalLists = C->getTotalComponentListNum();
2429 auto TotalComponents = C->getTotalComponentsNum();
2431 SmallVector<Expr *, 16> Vars;
2432 Vars.reserve(NumVars);
2433 for (unsigned i = 0; i != NumVars; ++i)
2434 Vars.push_back(Reader->Record.readSubExpr());
2435 C->setVarRefs(Vars);
2437 SmallVector<ValueDecl *, 16> Decls;
2438 Decls.reserve(UniqueDecls);
2439 for (unsigned i = 0; i < UniqueDecls; ++i)
2440 Decls.push_back(Reader->Record.readDeclAs<ValueDecl>());
2441 C->setUniqueDecls(Decls);
2443 SmallVector<unsigned, 16> ListsPerDecl;
2444 ListsPerDecl.reserve(UniqueDecls);
2445 for (unsigned i = 0; i < UniqueDecls; ++i)
2446 ListsPerDecl.push_back(Reader->Record.readInt());
2447 C->setDeclNumLists(ListsPerDecl);
2449 SmallVector<unsigned, 32> ListSizes;
2450 ListSizes.reserve(TotalLists);
2451 for (unsigned i = 0; i < TotalLists; ++i)
2452 ListSizes.push_back(Reader->Record.readInt());
2453 C->setComponentListSizes(ListSizes);
2455 SmallVector<OMPClauseMappableExprCommon::MappableComponent, 32> Components;
2456 Components.reserve(TotalComponents);
2457 for (unsigned i = 0; i < TotalComponents; ++i) {
2458 Expr *AssociatedExpr = Reader->Record.readSubExpr();
2459 auto *AssociatedDecl = Reader->Record.readDeclAs<ValueDecl>();
2460 Components.push_back(OMPClauseMappableExprCommon::MappableComponent(
2461 AssociatedExpr, AssociatedDecl));
2463 C->setComponents(Components, ListSizes);
2466 void OMPClauseReader::VisitOMPNumTeamsClause(OMPNumTeamsClause *C) {
2467 VisitOMPClauseWithPreInit(C);
2468 C->setNumTeams(Reader->Record.readSubExpr());
2469 C->setLParenLoc(Reader->ReadSourceLocation());
2472 void OMPClauseReader::VisitOMPThreadLimitClause(OMPThreadLimitClause *C) {
2473 VisitOMPClauseWithPreInit(C);
2474 C->setThreadLimit(Reader->Record.readSubExpr());
2475 C->setLParenLoc(Reader->ReadSourceLocation());
2478 void OMPClauseReader::VisitOMPPriorityClause(OMPPriorityClause *C) {
2479 C->setPriority(Reader->Record.readSubExpr());
2480 C->setLParenLoc(Reader->ReadSourceLocation());
2483 void OMPClauseReader::VisitOMPGrainsizeClause(OMPGrainsizeClause *C) {
2484 C->setGrainsize(Reader->Record.readSubExpr());
2485 C->setLParenLoc(Reader->ReadSourceLocation());
2488 void OMPClauseReader::VisitOMPNumTasksClause(OMPNumTasksClause *C) {
2489 C->setNumTasks(Reader->Record.readSubExpr());
2490 C->setLParenLoc(Reader->ReadSourceLocation());
2493 void OMPClauseReader::VisitOMPHintClause(OMPHintClause *C) {
2494 C->setHint(Reader->Record.readSubExpr());
2495 C->setLParenLoc(Reader->ReadSourceLocation());
2498 void OMPClauseReader::VisitOMPDistScheduleClause(OMPDistScheduleClause *C) {
2499 VisitOMPClauseWithPreInit(C);
2500 C->setDistScheduleKind(
2501 static_cast<OpenMPDistScheduleClauseKind>(Reader->Record.readInt()));
2502 C->setChunkSize(Reader->Record.readSubExpr());
2503 C->setLParenLoc(Reader->ReadSourceLocation());
2504 C->setDistScheduleKindLoc(Reader->ReadSourceLocation());
2505 C->setCommaLoc(Reader->ReadSourceLocation());
2508 void OMPClauseReader::VisitOMPDefaultmapClause(OMPDefaultmapClause *C) {
2509 C->setDefaultmapKind(
2510 static_cast<OpenMPDefaultmapClauseKind>(Reader->Record.readInt()));
2511 C->setDefaultmapModifier(
2512 static_cast<OpenMPDefaultmapClauseModifier>(Reader->Record.readInt()));
2513 C->setLParenLoc(Reader->ReadSourceLocation());
2514 C->setDefaultmapModifierLoc(Reader->ReadSourceLocation());
2515 C->setDefaultmapKindLoc(Reader->ReadSourceLocation());
2518 void OMPClauseReader::VisitOMPToClause(OMPToClause *C) {
2519 C->setLParenLoc(Reader->ReadSourceLocation());
2520 auto NumVars = C->varlist_size();
2521 auto UniqueDecls = C->getUniqueDeclarationsNum();
2522 auto TotalLists = C->getTotalComponentListNum();
2523 auto TotalComponents = C->getTotalComponentsNum();
2525 SmallVector<Expr *, 16> Vars;
2526 Vars.reserve(NumVars);
2527 for (unsigned i = 0; i != NumVars; ++i)
2528 Vars.push_back(Reader->Record.readSubExpr());
2529 C->setVarRefs(Vars);
2531 SmallVector<ValueDecl *, 16> Decls;
2532 Decls.reserve(UniqueDecls);
2533 for (unsigned i = 0; i < UniqueDecls; ++i)
2534 Decls.push_back(Reader->Record.readDeclAs<ValueDecl>());
2535 C->setUniqueDecls(Decls);
2537 SmallVector<unsigned, 16> ListsPerDecl;
2538 ListsPerDecl.reserve(UniqueDecls);
2539 for (unsigned i = 0; i < UniqueDecls; ++i)
2540 ListsPerDecl.push_back(Reader->Record.readInt());
2541 C->setDeclNumLists(ListsPerDecl);
2543 SmallVector<unsigned, 32> ListSizes;
2544 ListSizes.reserve(TotalLists);
2545 for (unsigned i = 0; i < TotalLists; ++i)
2546 ListSizes.push_back(Reader->Record.readInt());
2547 C->setComponentListSizes(ListSizes);
2549 SmallVector<OMPClauseMappableExprCommon::MappableComponent, 32> Components;
2550 Components.reserve(TotalComponents);
2551 for (unsigned i = 0; i < TotalComponents; ++i) {
2552 Expr *AssociatedExpr = Reader->Record.readSubExpr();
2553 auto *AssociatedDecl = Reader->Record.readDeclAs<ValueDecl>();
2554 Components.push_back(OMPClauseMappableExprCommon::MappableComponent(
2555 AssociatedExpr, AssociatedDecl));
2557 C->setComponents(Components, ListSizes);
2560 void OMPClauseReader::VisitOMPFromClause(OMPFromClause *C) {
2561 C->setLParenLoc(Reader->ReadSourceLocation());
2562 auto NumVars = C->varlist_size();
2563 auto UniqueDecls = C->getUniqueDeclarationsNum();
2564 auto TotalLists = C->getTotalComponentListNum();
2565 auto TotalComponents = C->getTotalComponentsNum();
2567 SmallVector<Expr *, 16> Vars;
2568 Vars.reserve(NumVars);
2569 for (unsigned i = 0; i != NumVars; ++i)
2570 Vars.push_back(Reader->Record.readSubExpr());
2571 C->setVarRefs(Vars);
2573 SmallVector<ValueDecl *, 16> Decls;
2574 Decls.reserve(UniqueDecls);
2575 for (unsigned i = 0; i < UniqueDecls; ++i)
2576 Decls.push_back(Reader->Record.readDeclAs<ValueDecl>());
2577 C->setUniqueDecls(Decls);
2579 SmallVector<unsigned, 16> ListsPerDecl;
2580 ListsPerDecl.reserve(UniqueDecls);
2581 for (unsigned i = 0; i < UniqueDecls; ++i)
2582 ListsPerDecl.push_back(Reader->Record.readInt());
2583 C->setDeclNumLists(ListsPerDecl);
2585 SmallVector<unsigned, 32> ListSizes;
2586 ListSizes.reserve(TotalLists);
2587 for (unsigned i = 0; i < TotalLists; ++i)
2588 ListSizes.push_back(Reader->Record.readInt());
2589 C->setComponentListSizes(ListSizes);
2591 SmallVector<OMPClauseMappableExprCommon::MappableComponent, 32> Components;
2592 Components.reserve(TotalComponents);
2593 for (unsigned i = 0; i < TotalComponents; ++i) {
2594 Expr *AssociatedExpr = Reader->Record.readSubExpr();
2595 auto *AssociatedDecl = Reader->Record.readDeclAs<ValueDecl>();
2596 Components.push_back(OMPClauseMappableExprCommon::MappableComponent(
2597 AssociatedExpr, AssociatedDecl));
2599 C->setComponents(Components, ListSizes);
2602 void OMPClauseReader::VisitOMPUseDevicePtrClause(OMPUseDevicePtrClause *C) {
2603 C->setLParenLoc(Reader->ReadSourceLocation());
2604 auto NumVars = C->varlist_size();
2605 auto UniqueDecls = C->getUniqueDeclarationsNum();
2606 auto TotalLists = C->getTotalComponentListNum();
2607 auto TotalComponents = C->getTotalComponentsNum();
2609 SmallVector<Expr *, 16> Vars;
2610 Vars.reserve(NumVars);
2611 for (unsigned i = 0; i != NumVars; ++i)
2612 Vars.push_back(Reader->Record.readSubExpr());
2613 C->setVarRefs(Vars);
2615 for (unsigned i = 0; i != NumVars; ++i)
2616 Vars.push_back(Reader->Record.readSubExpr());
2617 C->setPrivateCopies(Vars);
2619 for (unsigned i = 0; i != NumVars; ++i)
2620 Vars.push_back(Reader->Record.readSubExpr());
2623 SmallVector<ValueDecl *, 16> Decls;
2624 Decls.reserve(UniqueDecls);
2625 for (unsigned i = 0; i < UniqueDecls; ++i)
2626 Decls.push_back(Reader->Record.readDeclAs<ValueDecl>());
2627 C->setUniqueDecls(Decls);
2629 SmallVector<unsigned, 16> ListsPerDecl;
2630 ListsPerDecl.reserve(UniqueDecls);
2631 for (unsigned i = 0; i < UniqueDecls; ++i)
2632 ListsPerDecl.push_back(Reader->Record.readInt());
2633 C->setDeclNumLists(ListsPerDecl);
2635 SmallVector<unsigned, 32> ListSizes;
2636 ListSizes.reserve(TotalLists);
2637 for (unsigned i = 0; i < TotalLists; ++i)
2638 ListSizes.push_back(Reader->Record.readInt());
2639 C->setComponentListSizes(ListSizes);
2641 SmallVector<OMPClauseMappableExprCommon::MappableComponent, 32> Components;
2642 Components.reserve(TotalComponents);
2643 for (unsigned i = 0; i < TotalComponents; ++i) {
2644 Expr *AssociatedExpr = Reader->Record.readSubExpr();
2645 auto *AssociatedDecl = Reader->Record.readDeclAs<ValueDecl>();
2646 Components.push_back(OMPClauseMappableExprCommon::MappableComponent(
2647 AssociatedExpr, AssociatedDecl));
2649 C->setComponents(Components, ListSizes);
2652 void OMPClauseReader::VisitOMPIsDevicePtrClause(OMPIsDevicePtrClause *C) {
2653 C->setLParenLoc(Reader->ReadSourceLocation());
2654 auto NumVars = C->varlist_size();
2655 auto UniqueDecls = C->getUniqueDeclarationsNum();
2656 auto TotalLists = C->getTotalComponentListNum();
2657 auto TotalComponents = C->getTotalComponentsNum();
2659 SmallVector<Expr *, 16> Vars;
2660 Vars.reserve(NumVars);
2661 for (unsigned i = 0; i != NumVars; ++i)
2662 Vars.push_back(Reader->Record.readSubExpr());
2663 C->setVarRefs(Vars);
2666 SmallVector<ValueDecl *, 16> Decls;
2667 Decls.reserve(UniqueDecls);
2668 for (unsigned i = 0; i < UniqueDecls; ++i)
2669 Decls.push_back(Reader->Record.readDeclAs<ValueDecl>());
2670 C->setUniqueDecls(Decls);
2672 SmallVector<unsigned, 16> ListsPerDecl;
2673 ListsPerDecl.reserve(UniqueDecls);
2674 for (unsigned i = 0; i < UniqueDecls; ++i)
2675 ListsPerDecl.push_back(Reader->Record.readInt());
2676 C->setDeclNumLists(ListsPerDecl);
2678 SmallVector<unsigned, 32> ListSizes;
2679 ListSizes.reserve(TotalLists);
2680 for (unsigned i = 0; i < TotalLists; ++i)
2681 ListSizes.push_back(Reader->Record.readInt());
2682 C->setComponentListSizes(ListSizes);
2684 SmallVector<OMPClauseMappableExprCommon::MappableComponent, 32> Components;
2685 Components.reserve(TotalComponents);
2686 for (unsigned i = 0; i < TotalComponents; ++i) {
2687 Expr *AssociatedExpr = Reader->Record.readSubExpr();
2688 auto *AssociatedDecl = Reader->Record.readDeclAs<ValueDecl>();
2689 Components.push_back(OMPClauseMappableExprCommon::MappableComponent(
2690 AssociatedExpr, AssociatedDecl));
2692 C->setComponents(Components, ListSizes);
2695 //===----------------------------------------------------------------------===//
2696 // OpenMP Directives.
2697 //===----------------------------------------------------------------------===//
2699 void ASTStmtReader::VisitOMPExecutableDirective(OMPExecutableDirective *E) {
2700 E->setLocStart(ReadSourceLocation());
2701 E->setLocEnd(ReadSourceLocation());
2702 OMPClauseReader ClauseReader(this, Record);
2703 SmallVector<OMPClause *, 5> Clauses;
2704 for (unsigned i = 0; i < E->getNumClauses(); ++i)
2705 Clauses.push_back(ClauseReader.readClause());
2706 E->setClauses(Clauses);
2707 if (E->hasAssociatedStmt())
2708 E->setAssociatedStmt(Record.readSubStmt());
2711 void ASTStmtReader::VisitOMPLoopDirective(OMPLoopDirective *D) {
2713 // Two fields (NumClauses and CollapsedNum) were read in ReadStmtFromStream.
2715 VisitOMPExecutableDirective(D);
2716 D->setIterationVariable(Record.readSubExpr());
2717 D->setLastIteration(Record.readSubExpr());
2718 D->setCalcLastIteration(Record.readSubExpr());
2719 D->setPreCond(Record.readSubExpr());
2720 D->setCond(Record.readSubExpr());
2721 D->setInit(Record.readSubExpr());
2722 D->setInc(Record.readSubExpr());
2723 D->setPreInits(Record.readSubStmt());
2724 if (isOpenMPWorksharingDirective(D->getDirectiveKind()) ||
2725 isOpenMPTaskLoopDirective(D->getDirectiveKind()) ||
2726 isOpenMPDistributeDirective(D->getDirectiveKind())) {
2727 D->setIsLastIterVariable(Record.readSubExpr());
2728 D->setLowerBoundVariable(Record.readSubExpr());
2729 D->setUpperBoundVariable(Record.readSubExpr());
2730 D->setStrideVariable(Record.readSubExpr());
2731 D->setEnsureUpperBound(Record.readSubExpr());
2732 D->setNextLowerBound(Record.readSubExpr());
2733 D->setNextUpperBound(Record.readSubExpr());
2734 D->setNumIterations(Record.readSubExpr());
2736 if (isOpenMPLoopBoundSharingDirective(D->getDirectiveKind())) {
2737 D->setPrevLowerBoundVariable(Record.readSubExpr());
2738 D->setPrevUpperBoundVariable(Record.readSubExpr());
2739 D->setDistInc(Record.readSubExpr());
2740 D->setPrevEnsureUpperBound(Record.readSubExpr());
2741 D->setCombinedLowerBoundVariable(Record.readSubExpr());
2742 D->setCombinedUpperBoundVariable(Record.readSubExpr());
2743 D->setCombinedEnsureUpperBound(Record.readSubExpr());
2744 D->setCombinedInit(Record.readSubExpr());
2745 D->setCombinedCond(Record.readSubExpr());
2746 D->setCombinedNextLowerBound(Record.readSubExpr());
2747 D->setCombinedNextUpperBound(Record.readSubExpr());
2749 SmallVector<Expr *, 4> Sub;
2750 unsigned CollapsedNum = D->getCollapsedNumber();
2751 Sub.reserve(CollapsedNum);
2752 for (unsigned i = 0; i < CollapsedNum; ++i)
2753 Sub.push_back(Record.readSubExpr());
2754 D->setCounters(Sub);
2756 for (unsigned i = 0; i < CollapsedNum; ++i)
2757 Sub.push_back(Record.readSubExpr());
2758 D->setPrivateCounters(Sub);
2760 for (unsigned i = 0; i < CollapsedNum; ++i)
2761 Sub.push_back(Record.readSubExpr());
2764 for (unsigned i = 0; i < CollapsedNum; ++i)
2765 Sub.push_back(Record.readSubExpr());
2768 for (unsigned i = 0; i < CollapsedNum; ++i)
2769 Sub.push_back(Record.readSubExpr());
2773 void ASTStmtReader::VisitOMPParallelDirective(OMPParallelDirective *D) {
2775 // The NumClauses field was read in ReadStmtFromStream.
2777 VisitOMPExecutableDirective(D);
2778 D->setHasCancel(Record.readInt());
2781 void ASTStmtReader::VisitOMPSimdDirective(OMPSimdDirective *D) {
2782 VisitOMPLoopDirective(D);
2785 void ASTStmtReader::VisitOMPForDirective(OMPForDirective *D) {
2786 VisitOMPLoopDirective(D);
2787 D->setHasCancel(Record.readInt());
2790 void ASTStmtReader::VisitOMPForSimdDirective(OMPForSimdDirective *D) {
2791 VisitOMPLoopDirective(D);
2794 void ASTStmtReader::VisitOMPSectionsDirective(OMPSectionsDirective *D) {
2796 // The NumClauses field was read in ReadStmtFromStream.
2798 VisitOMPExecutableDirective(D);
2799 D->setHasCancel(Record.readInt());
2802 void ASTStmtReader::VisitOMPSectionDirective(OMPSectionDirective *D) {
2804 VisitOMPExecutableDirective(D);
2805 D->setHasCancel(Record.readInt());
2808 void ASTStmtReader::VisitOMPSingleDirective(OMPSingleDirective *D) {
2810 // The NumClauses field was read in ReadStmtFromStream.
2812 VisitOMPExecutableDirective(D);
2815 void ASTStmtReader::VisitOMPMasterDirective(OMPMasterDirective *D) {
2817 VisitOMPExecutableDirective(D);
2820 void ASTStmtReader::VisitOMPCriticalDirective(OMPCriticalDirective *D) {
2822 // The NumClauses field was read in ReadStmtFromStream.
2824 VisitOMPExecutableDirective(D);
2825 ReadDeclarationNameInfo(D->DirName);
2828 void ASTStmtReader::VisitOMPParallelForDirective(OMPParallelForDirective *D) {
2829 VisitOMPLoopDirective(D);
2830 D->setHasCancel(Record.readInt());
2833 void ASTStmtReader::VisitOMPParallelForSimdDirective(
2834 OMPParallelForSimdDirective *D) {
2835 VisitOMPLoopDirective(D);
2838 void ASTStmtReader::VisitOMPParallelSectionsDirective(
2839 OMPParallelSectionsDirective *D) {
2841 // The NumClauses field was read in ReadStmtFromStream.
2843 VisitOMPExecutableDirective(D);
2844 D->setHasCancel(Record.readInt());
2847 void ASTStmtReader::VisitOMPTaskDirective(OMPTaskDirective *D) {
2849 // The NumClauses field was read in ReadStmtFromStream.
2851 VisitOMPExecutableDirective(D);
2852 D->setHasCancel(Record.readInt());
2855 void ASTStmtReader::VisitOMPTaskyieldDirective(OMPTaskyieldDirective *D) {
2857 VisitOMPExecutableDirective(D);
2860 void ASTStmtReader::VisitOMPBarrierDirective(OMPBarrierDirective *D) {
2862 VisitOMPExecutableDirective(D);
2865 void ASTStmtReader::VisitOMPTaskwaitDirective(OMPTaskwaitDirective *D) {
2867 VisitOMPExecutableDirective(D);
2870 void ASTStmtReader::VisitOMPTaskgroupDirective(OMPTaskgroupDirective *D) {
2872 // The NumClauses field was read in ReadStmtFromStream.
2874 VisitOMPExecutableDirective(D);
2875 D->setReductionRef(Record.readSubExpr());
2878 void ASTStmtReader::VisitOMPFlushDirective(OMPFlushDirective *D) {
2880 // The NumClauses field was read in ReadStmtFromStream.
2882 VisitOMPExecutableDirective(D);
2885 void ASTStmtReader::VisitOMPOrderedDirective(OMPOrderedDirective *D) {
2887 // The NumClauses field was read in ReadStmtFromStream.
2889 VisitOMPExecutableDirective(D);
2892 void ASTStmtReader::VisitOMPAtomicDirective(OMPAtomicDirective *D) {
2894 // The NumClauses field was read in ReadStmtFromStream.
2896 VisitOMPExecutableDirective(D);
2897 D->setX(Record.readSubExpr());
2898 D->setV(Record.readSubExpr());
2899 D->setExpr(Record.readSubExpr());
2900 D->setUpdateExpr(Record.readSubExpr());
2901 D->IsXLHSInRHSPart = Record.readInt() != 0;
2902 D->IsPostfixUpdate = Record.readInt() != 0;
2905 void ASTStmtReader::VisitOMPTargetDirective(OMPTargetDirective *D) {
2907 // The NumClauses field was read in ReadStmtFromStream.
2909 VisitOMPExecutableDirective(D);
2912 void ASTStmtReader::VisitOMPTargetDataDirective(OMPTargetDataDirective *D) {
2915 VisitOMPExecutableDirective(D);
2918 void ASTStmtReader::VisitOMPTargetEnterDataDirective(
2919 OMPTargetEnterDataDirective *D) {
2922 VisitOMPExecutableDirective(D);
2925 void ASTStmtReader::VisitOMPTargetExitDataDirective(
2926 OMPTargetExitDataDirective *D) {
2929 VisitOMPExecutableDirective(D);
2932 void ASTStmtReader::VisitOMPTargetParallelDirective(
2933 OMPTargetParallelDirective *D) {
2936 VisitOMPExecutableDirective(D);
2939 void ASTStmtReader::VisitOMPTargetParallelForDirective(
2940 OMPTargetParallelForDirective *D) {
2941 VisitOMPLoopDirective(D);
2942 D->setHasCancel(Record.readInt());
2945 void ASTStmtReader::VisitOMPTeamsDirective(OMPTeamsDirective *D) {
2947 // The NumClauses field was read in ReadStmtFromStream.
2949 VisitOMPExecutableDirective(D);
2952 void ASTStmtReader::VisitOMPCancellationPointDirective(
2953 OMPCancellationPointDirective *D) {
2955 VisitOMPExecutableDirective(D);
2956 D->setCancelRegion(static_cast<OpenMPDirectiveKind>(Record.readInt()));
2959 void ASTStmtReader::VisitOMPCancelDirective(OMPCancelDirective *D) {
2961 // The NumClauses field was read in ReadStmtFromStream.
2963 VisitOMPExecutableDirective(D);
2964 D->setCancelRegion(static_cast<OpenMPDirectiveKind>(Record.readInt()));
2967 void ASTStmtReader::VisitOMPTaskLoopDirective(OMPTaskLoopDirective *D) {
2968 VisitOMPLoopDirective(D);
2971 void ASTStmtReader::VisitOMPTaskLoopSimdDirective(OMPTaskLoopSimdDirective *D) {
2972 VisitOMPLoopDirective(D);
2975 void ASTStmtReader::VisitOMPDistributeDirective(OMPDistributeDirective *D) {
2976 VisitOMPLoopDirective(D);
2979 void ASTStmtReader::VisitOMPTargetUpdateDirective(OMPTargetUpdateDirective *D) {
2982 VisitOMPExecutableDirective(D);
2985 void ASTStmtReader::VisitOMPDistributeParallelForDirective(
2986 OMPDistributeParallelForDirective *D) {
2987 VisitOMPLoopDirective(D);
2988 D->setHasCancel(Record.readInt());
2991 void ASTStmtReader::VisitOMPDistributeParallelForSimdDirective(
2992 OMPDistributeParallelForSimdDirective *D) {
2993 VisitOMPLoopDirective(D);
2996 void ASTStmtReader::VisitOMPDistributeSimdDirective(
2997 OMPDistributeSimdDirective *D) {
2998 VisitOMPLoopDirective(D);
3001 void ASTStmtReader::VisitOMPTargetParallelForSimdDirective(
3002 OMPTargetParallelForSimdDirective *D) {
3003 VisitOMPLoopDirective(D);
3006 void ASTStmtReader::VisitOMPTargetSimdDirective(OMPTargetSimdDirective *D) {
3007 VisitOMPLoopDirective(D);
3010 void ASTStmtReader::VisitOMPTeamsDistributeDirective(
3011 OMPTeamsDistributeDirective *D) {
3012 VisitOMPLoopDirective(D);
3015 void ASTStmtReader::VisitOMPTeamsDistributeSimdDirective(
3016 OMPTeamsDistributeSimdDirective *D) {
3017 VisitOMPLoopDirective(D);
3020 void ASTStmtReader::VisitOMPTeamsDistributeParallelForSimdDirective(
3021 OMPTeamsDistributeParallelForSimdDirective *D) {
3022 VisitOMPLoopDirective(D);
3025 void ASTStmtReader::VisitOMPTeamsDistributeParallelForDirective(
3026 OMPTeamsDistributeParallelForDirective *D) {
3027 VisitOMPLoopDirective(D);
3028 D->setHasCancel(Record.readInt());
3031 void ASTStmtReader::VisitOMPTargetTeamsDirective(OMPTargetTeamsDirective *D) {
3033 // The NumClauses field was read in ReadStmtFromStream.
3035 VisitOMPExecutableDirective(D);
3038 void ASTStmtReader::VisitOMPTargetTeamsDistributeDirective(
3039 OMPTargetTeamsDistributeDirective *D) {
3040 VisitOMPLoopDirective(D);
3043 void ASTStmtReader::VisitOMPTargetTeamsDistributeParallelForDirective(
3044 OMPTargetTeamsDistributeParallelForDirective *D) {
3045 VisitOMPLoopDirective(D);
3046 D->setHasCancel(Record.readInt());
3049 void ASTStmtReader::VisitOMPTargetTeamsDistributeParallelForSimdDirective(
3050 OMPTargetTeamsDistributeParallelForSimdDirective *D) {
3051 VisitOMPLoopDirective(D);
3054 void ASTStmtReader::VisitOMPTargetTeamsDistributeSimdDirective(
3055 OMPTargetTeamsDistributeSimdDirective *D) {
3056 VisitOMPLoopDirective(D);
3059 //===----------------------------------------------------------------------===//
3060 // ASTReader Implementation
3061 //===----------------------------------------------------------------------===//
3063 Stmt *ASTReader::ReadStmt(ModuleFile &F) {
3064 switch (ReadingKind) {
3066 llvm_unreachable("should not call this when not reading anything");
3069 return ReadStmtFromStream(F);
3071 return ReadSubStmt();
3074 llvm_unreachable("ReadingKind not set ?");
3077 Expr *ASTReader::ReadExpr(ModuleFile &F) {
3078 return cast_or_null<Expr>(ReadStmt(F));
3081 Expr *ASTReader::ReadSubExpr() {
3082 return cast_or_null<Expr>(ReadSubStmt());
3085 // Within the bitstream, expressions are stored in Reverse Polish
3086 // Notation, with each of the subexpressions preceding the
3087 // expression they are stored in. Subexpressions are stored from last to first.
3088 // To evaluate expressions, we continue reading expressions and placing them on
3089 // the stack, with expressions having operands removing those operands from the
3090 // stack. Evaluation terminates when we see a STMT_STOP record, and
3091 // the single remaining expression on the stack is our result.
3092 Stmt *ASTReader::ReadStmtFromStream(ModuleFile &F) {
3093 ReadingKindTracker ReadingKind(Read_Stmt, *this);
3094 llvm::BitstreamCursor &Cursor = F.DeclsCursor;
3096 // Map of offset to previously deserialized stmt. The offset points
3097 // just after the stmt record.
3098 llvm::DenseMap<uint64_t, Stmt *> StmtEntries;
3101 unsigned PrevNumStmts = StmtStack.size();
3104 ASTRecordReader Record(*this, F);
3105 ASTStmtReader Reader(Record, Cursor);
3106 Stmt::EmptyShell Empty;
3109 llvm::BitstreamEntry Entry = Cursor.advanceSkippingSubblocks();
3111 switch (Entry.Kind) {
3112 case llvm::BitstreamEntry::SubBlock: // Handled for us already.
3113 case llvm::BitstreamEntry::Error:
3114 Error("malformed block record in AST file");
3116 case llvm::BitstreamEntry::EndBlock:
3118 case llvm::BitstreamEntry::Record:
3119 // The interesting case.
3123 ASTContext &Context = getContext();
3125 bool Finished = false;
3126 bool IsStmtReference = false;
3127 switch ((StmtCode)Record.readRecord(Cursor, Entry.ID)) {
3133 IsStmtReference = true;
3134 assert(StmtEntries.find(Record[0]) != StmtEntries.end() &&
3135 "No stmt was recorded for this offset reference!");
3136 S = StmtEntries[Record.readInt()];
3144 S = new (Context) NullStmt(Empty);
3148 S = CompoundStmt::CreateEmpty(
3149 Context, /*NumStmts=*/Record[ASTStmtReader::NumStmtFields]);
3153 S = new (Context) CaseStmt(Empty);
3157 S = new (Context) DefaultStmt(Empty);
3161 S = new (Context) LabelStmt(Empty);
3164 case STMT_ATTRIBUTED:
3165 S = AttributedStmt::CreateEmpty(
3167 /*NumAttrs*/Record[ASTStmtReader::NumStmtFields]);
3171 S = new (Context) IfStmt(Empty);
3175 S = new (Context) SwitchStmt(Empty);
3179 S = new (Context) WhileStmt(Empty);
3183 S = new (Context) DoStmt(Empty);
3187 S = new (Context) ForStmt(Empty);
3191 S = new (Context) GotoStmt(Empty);
3194 case STMT_INDIRECT_GOTO:
3195 S = new (Context) IndirectGotoStmt(Empty);
3199 S = new (Context) ContinueStmt(Empty);
3203 S = new (Context) BreakStmt(Empty);
3207 S = new (Context) ReturnStmt(Empty);
3211 S = new (Context) DeclStmt(Empty);
3215 S = new (Context) GCCAsmStmt(Empty);
3219 S = new (Context) MSAsmStmt(Empty);
3223 S = CapturedStmt::CreateDeserialized(Context,
3224 Record[ASTStmtReader::NumStmtFields]);
3227 case EXPR_PREDEFINED:
3228 S = new (Context) PredefinedExpr(Empty);
3232 S = DeclRefExpr::CreateEmpty(
3234 /*HasQualifier=*/Record[ASTStmtReader::NumExprFields],
3235 /*HasFoundDecl=*/Record[ASTStmtReader::NumExprFields + 1],
3236 /*HasTemplateKWAndArgsInfo=*/Record[ASTStmtReader::NumExprFields + 2],
3237 /*NumTemplateArgs=*/Record[ASTStmtReader::NumExprFields + 2] ?
3238 Record[ASTStmtReader::NumExprFields + 5] : 0);
3241 case EXPR_INTEGER_LITERAL:
3242 S = IntegerLiteral::Create(Context, Empty);
3245 case EXPR_FLOATING_LITERAL:
3246 S = FloatingLiteral::Create(Context, Empty);
3249 case EXPR_IMAGINARY_LITERAL:
3250 S = new (Context) ImaginaryLiteral(Empty);
3253 case EXPR_STRING_LITERAL:
3254 S = StringLiteral::CreateEmpty(Context,
3255 Record[ASTStmtReader::NumExprFields + 1]);
3258 case EXPR_CHARACTER_LITERAL:
3259 S = new (Context) CharacterLiteral(Empty);
3263 S = new (Context) ParenExpr(Empty);
3266 case EXPR_PAREN_LIST:
3267 S = new (Context) ParenListExpr(Empty);
3270 case EXPR_UNARY_OPERATOR:
3271 S = new (Context) UnaryOperator(Empty);
3275 S = OffsetOfExpr::CreateEmpty(Context,
3276 Record[ASTStmtReader::NumExprFields],
3277 Record[ASTStmtReader::NumExprFields + 1]);
3280 case EXPR_SIZEOF_ALIGN_OF:
3281 S = new (Context) UnaryExprOrTypeTraitExpr(Empty);
3284 case EXPR_ARRAY_SUBSCRIPT:
3285 S = new (Context) ArraySubscriptExpr(Empty);
3288 case EXPR_OMP_ARRAY_SECTION:
3289 S = new (Context) OMPArraySectionExpr(Empty);
3293 S = new (Context) CallExpr(Context, Stmt::CallExprClass, Empty);
3297 // We load everything here and fully initialize it at creation.
3298 // That way we can use MemberExpr::Create and don't have to duplicate its
3299 // logic with a MemberExpr::CreateEmpty.
3301 assert(Record.getIdx() == 0);
3302 NestedNameSpecifierLoc QualifierLoc;
3303 if (Record.readInt()) { // HasQualifier.
3304 QualifierLoc = Record.readNestedNameSpecifierLoc();
3307 SourceLocation TemplateKWLoc;
3308 TemplateArgumentListInfo ArgInfo;
3309 bool HasTemplateKWAndArgsInfo = Record.readInt();
3310 if (HasTemplateKWAndArgsInfo) {
3311 TemplateKWLoc = Record.readSourceLocation();
3312 unsigned NumTemplateArgs = Record.readInt();
3313 ArgInfo.setLAngleLoc(Record.readSourceLocation());
3314 ArgInfo.setRAngleLoc(Record.readSourceLocation());
3315 for (unsigned i = 0; i != NumTemplateArgs; ++i)
3316 ArgInfo.addArgument(Record.readTemplateArgumentLoc());
3319 bool HadMultipleCandidates = Record.readInt();
3321 auto *FoundD = Record.readDeclAs<NamedDecl>();
3322 auto AS = (AccessSpecifier)Record.readInt();
3323 DeclAccessPair FoundDecl = DeclAccessPair::make(FoundD, AS);
3325 QualType T = Record.readType();
3326 auto VK = static_cast<ExprValueKind>(Record.readInt());
3327 auto OK = static_cast<ExprObjectKind>(Record.readInt());
3328 Expr *Base = ReadSubExpr();
3329 auto *MemberD = Record.readDeclAs<ValueDecl>();
3330 SourceLocation MemberLoc = Record.readSourceLocation();
3331 DeclarationNameInfo MemberNameInfo(MemberD->getDeclName(), MemberLoc);
3332 bool IsArrow = Record.readInt();
3333 SourceLocation OperatorLoc = Record.readSourceLocation();
3335 S = MemberExpr::Create(Context, Base, IsArrow, OperatorLoc, QualifierLoc,
3336 TemplateKWLoc, MemberD, FoundDecl, MemberNameInfo,
3337 HasTemplateKWAndArgsInfo ? &ArgInfo : nullptr, T,
3339 Record.readDeclarationNameLoc(cast<MemberExpr>(S)->MemberDNLoc,
3340 MemberD->getDeclName());
3341 if (HadMultipleCandidates)
3342 cast<MemberExpr>(S)->setHadMultipleCandidates(true);
3346 case EXPR_BINARY_OPERATOR:
3347 S = new (Context) BinaryOperator(Empty);
3350 case EXPR_COMPOUND_ASSIGN_OPERATOR:
3351 S = new (Context) CompoundAssignOperator(Empty);
3354 case EXPR_CONDITIONAL_OPERATOR:
3355 S = new (Context) ConditionalOperator(Empty);
3358 case EXPR_BINARY_CONDITIONAL_OPERATOR:
3359 S = new (Context) BinaryConditionalOperator(Empty);
3362 case EXPR_IMPLICIT_CAST:
3363 S = ImplicitCastExpr::CreateEmpty(Context,
3364 /*PathSize*/ Record[ASTStmtReader::NumExprFields]);
3367 case EXPR_CSTYLE_CAST:
3368 S = CStyleCastExpr::CreateEmpty(Context,
3369 /*PathSize*/ Record[ASTStmtReader::NumExprFields]);
3372 case EXPR_COMPOUND_LITERAL:
3373 S = new (Context) CompoundLiteralExpr(Empty);
3376 case EXPR_EXT_VECTOR_ELEMENT:
3377 S = new (Context) ExtVectorElementExpr(Empty);
3380 case EXPR_INIT_LIST:
3381 S = new (Context) InitListExpr(Empty);
3384 case EXPR_DESIGNATED_INIT:
3385 S = DesignatedInitExpr::CreateEmpty(Context,
3386 Record[ASTStmtReader::NumExprFields] - 1);
3390 case EXPR_DESIGNATED_INIT_UPDATE:
3391 S = new (Context) DesignatedInitUpdateExpr(Empty);
3394 case EXPR_IMPLICIT_VALUE_INIT:
3395 S = new (Context) ImplicitValueInitExpr(Empty);
3399 S = new (Context) NoInitExpr(Empty);
3402 case EXPR_ARRAY_INIT_LOOP:
3403 S = new (Context) ArrayInitLoopExpr(Empty);
3406 case EXPR_ARRAY_INIT_INDEX:
3407 S = new (Context) ArrayInitIndexExpr(Empty);
3411 S = new (Context) VAArgExpr(Empty);
3414 case EXPR_ADDR_LABEL:
3415 S = new (Context) AddrLabelExpr(Empty);
3419 S = new (Context) StmtExpr(Empty);
3423 S = new (Context) ChooseExpr(Empty);
3427 S = new (Context) GNUNullExpr(Empty);
3430 case EXPR_SHUFFLE_VECTOR:
3431 S = new (Context) ShuffleVectorExpr(Empty);
3434 case EXPR_CONVERT_VECTOR:
3435 S = new (Context) ConvertVectorExpr(Empty);
3439 S = new (Context) BlockExpr(Empty);
3442 case EXPR_GENERIC_SELECTION:
3443 S = new (Context) GenericSelectionExpr(Empty);
3446 case EXPR_OBJC_STRING_LITERAL:
3447 S = new (Context) ObjCStringLiteral(Empty);
3450 case EXPR_OBJC_BOXED_EXPRESSION:
3451 S = new (Context) ObjCBoxedExpr(Empty);
3454 case EXPR_OBJC_ARRAY_LITERAL:
3455 S = ObjCArrayLiteral::CreateEmpty(Context,
3456 Record[ASTStmtReader::NumExprFields]);
3459 case EXPR_OBJC_DICTIONARY_LITERAL:
3460 S = ObjCDictionaryLiteral::CreateEmpty(Context,
3461 Record[ASTStmtReader::NumExprFields],
3462 Record[ASTStmtReader::NumExprFields + 1]);
3465 case EXPR_OBJC_ENCODE:
3466 S = new (Context) ObjCEncodeExpr(Empty);
3469 case EXPR_OBJC_SELECTOR_EXPR:
3470 S = new (Context) ObjCSelectorExpr(Empty);
3473 case EXPR_OBJC_PROTOCOL_EXPR:
3474 S = new (Context) ObjCProtocolExpr(Empty);
3477 case EXPR_OBJC_IVAR_REF_EXPR:
3478 S = new (Context) ObjCIvarRefExpr(Empty);
3481 case EXPR_OBJC_PROPERTY_REF_EXPR:
3482 S = new (Context) ObjCPropertyRefExpr(Empty);
3485 case EXPR_OBJC_SUBSCRIPT_REF_EXPR:
3486 S = new (Context) ObjCSubscriptRefExpr(Empty);
3489 case EXPR_OBJC_KVC_REF_EXPR:
3490 llvm_unreachable("mismatching AST file");
3492 case EXPR_OBJC_MESSAGE_EXPR:
3493 S = ObjCMessageExpr::CreateEmpty(Context,
3494 Record[ASTStmtReader::NumExprFields],
3495 Record[ASTStmtReader::NumExprFields + 1]);
3499 S = new (Context) ObjCIsaExpr(Empty);
3502 case EXPR_OBJC_INDIRECT_COPY_RESTORE:
3503 S = new (Context) ObjCIndirectCopyRestoreExpr(Empty);
3506 case EXPR_OBJC_BRIDGED_CAST:
3507 S = new (Context) ObjCBridgedCastExpr(Empty);
3510 case STMT_OBJC_FOR_COLLECTION:
3511 S = new (Context) ObjCForCollectionStmt(Empty);
3514 case STMT_OBJC_CATCH:
3515 S = new (Context) ObjCAtCatchStmt(Empty);
3518 case STMT_OBJC_FINALLY:
3519 S = new (Context) ObjCAtFinallyStmt(Empty);
3522 case STMT_OBJC_AT_TRY:
3523 S = ObjCAtTryStmt::CreateEmpty(Context,
3524 Record[ASTStmtReader::NumStmtFields],
3525 Record[ASTStmtReader::NumStmtFields + 1]);
3528 case STMT_OBJC_AT_SYNCHRONIZED:
3529 S = new (Context) ObjCAtSynchronizedStmt(Empty);
3532 case STMT_OBJC_AT_THROW:
3533 S = new (Context) ObjCAtThrowStmt(Empty);
3536 case STMT_OBJC_AUTORELEASE_POOL:
3537 S = new (Context) ObjCAutoreleasePoolStmt(Empty);
3540 case EXPR_OBJC_BOOL_LITERAL:
3541 S = new (Context) ObjCBoolLiteralExpr(Empty);
3544 case EXPR_OBJC_AVAILABILITY_CHECK:
3545 S = new (Context) ObjCAvailabilityCheckExpr(Empty);
3548 case STMT_SEH_LEAVE:
3549 S = new (Context) SEHLeaveStmt(Empty);
3552 case STMT_SEH_EXCEPT:
3553 S = new (Context) SEHExceptStmt(Empty);
3556 case STMT_SEH_FINALLY:
3557 S = new (Context) SEHFinallyStmt(Empty);
3561 S = new (Context) SEHTryStmt(Empty);
3564 case STMT_CXX_CATCH:
3565 S = new (Context) CXXCatchStmt(Empty);
3569 S = CXXTryStmt::Create(Context, Empty,
3570 /*NumHandlers=*/Record[ASTStmtReader::NumStmtFields]);
3573 case STMT_CXX_FOR_RANGE:
3574 S = new (Context) CXXForRangeStmt(Empty);
3577 case STMT_MS_DEPENDENT_EXISTS:
3578 S = new (Context) MSDependentExistsStmt(SourceLocation(), true,
3579 NestedNameSpecifierLoc(),
3580 DeclarationNameInfo(),
3584 case STMT_OMP_PARALLEL_DIRECTIVE:
3586 OMPParallelDirective::CreateEmpty(Context,
3587 Record[ASTStmtReader::NumStmtFields],
3591 case STMT_OMP_SIMD_DIRECTIVE: {
3592 unsigned NumClauses = Record[ASTStmtReader::NumStmtFields];
3593 unsigned CollapsedNum = Record[ASTStmtReader::NumStmtFields + 1];
3594 S = OMPSimdDirective::CreateEmpty(Context, NumClauses,
3595 CollapsedNum, Empty);
3599 case STMT_OMP_FOR_DIRECTIVE: {
3600 unsigned NumClauses = Record[ASTStmtReader::NumStmtFields];
3601 unsigned CollapsedNum = Record[ASTStmtReader::NumStmtFields + 1];
3602 S = OMPForDirective::CreateEmpty(Context, NumClauses, CollapsedNum,
3607 case STMT_OMP_FOR_SIMD_DIRECTIVE: {
3608 unsigned NumClauses = Record[ASTStmtReader::NumStmtFields];
3609 unsigned CollapsedNum = Record[ASTStmtReader::NumStmtFields + 1];
3610 S = OMPForSimdDirective::CreateEmpty(Context, NumClauses, CollapsedNum,
3615 case STMT_OMP_SECTIONS_DIRECTIVE:
3616 S = OMPSectionsDirective::CreateEmpty(
3617 Context, Record[ASTStmtReader::NumStmtFields], Empty);
3620 case STMT_OMP_SECTION_DIRECTIVE:
3621 S = OMPSectionDirective::CreateEmpty(Context, Empty);
3624 case STMT_OMP_SINGLE_DIRECTIVE:
3625 S = OMPSingleDirective::CreateEmpty(
3626 Context, Record[ASTStmtReader::NumStmtFields], Empty);
3629 case STMT_OMP_MASTER_DIRECTIVE:
3630 S = OMPMasterDirective::CreateEmpty(Context, Empty);
3633 case STMT_OMP_CRITICAL_DIRECTIVE:
3634 S = OMPCriticalDirective::CreateEmpty(
3635 Context, Record[ASTStmtReader::NumStmtFields], Empty);
3638 case STMT_OMP_PARALLEL_FOR_DIRECTIVE: {
3639 unsigned NumClauses = Record[ASTStmtReader::NumStmtFields];
3640 unsigned CollapsedNum = Record[ASTStmtReader::NumStmtFields + 1];
3641 S = OMPParallelForDirective::CreateEmpty(Context, NumClauses,
3642 CollapsedNum, Empty);
3646 case STMT_OMP_PARALLEL_FOR_SIMD_DIRECTIVE: {
3647 unsigned NumClauses = Record[ASTStmtReader::NumStmtFields];
3648 unsigned CollapsedNum = Record[ASTStmtReader::NumStmtFields + 1];
3649 S = OMPParallelForSimdDirective::CreateEmpty(Context, NumClauses,
3650 CollapsedNum, Empty);
3654 case STMT_OMP_PARALLEL_SECTIONS_DIRECTIVE:
3655 S = OMPParallelSectionsDirective::CreateEmpty(
3656 Context, Record[ASTStmtReader::NumStmtFields], Empty);
3659 case STMT_OMP_TASK_DIRECTIVE:
3660 S = OMPTaskDirective::CreateEmpty(
3661 Context, Record[ASTStmtReader::NumStmtFields], Empty);
3664 case STMT_OMP_TASKYIELD_DIRECTIVE:
3665 S = OMPTaskyieldDirective::CreateEmpty(Context, Empty);
3668 case STMT_OMP_BARRIER_DIRECTIVE:
3669 S = OMPBarrierDirective::CreateEmpty(Context, Empty);
3672 case STMT_OMP_TASKWAIT_DIRECTIVE:
3673 S = OMPTaskwaitDirective::CreateEmpty(Context, Empty);
3676 case STMT_OMP_TASKGROUP_DIRECTIVE:
3677 S = OMPTaskgroupDirective::CreateEmpty(
3678 Context, Record[ASTStmtReader::NumStmtFields], Empty);
3681 case STMT_OMP_FLUSH_DIRECTIVE:
3682 S = OMPFlushDirective::CreateEmpty(
3683 Context, Record[ASTStmtReader::NumStmtFields], Empty);
3686 case STMT_OMP_ORDERED_DIRECTIVE:
3687 S = OMPOrderedDirective::CreateEmpty(
3688 Context, Record[ASTStmtReader::NumStmtFields], Empty);
3691 case STMT_OMP_ATOMIC_DIRECTIVE:
3692 S = OMPAtomicDirective::CreateEmpty(
3693 Context, Record[ASTStmtReader::NumStmtFields], Empty);
3696 case STMT_OMP_TARGET_DIRECTIVE:
3697 S = OMPTargetDirective::CreateEmpty(
3698 Context, Record[ASTStmtReader::NumStmtFields], Empty);
3701 case STMT_OMP_TARGET_DATA_DIRECTIVE:
3702 S = OMPTargetDataDirective::CreateEmpty(
3703 Context, Record[ASTStmtReader::NumStmtFields], Empty);
3706 case STMT_OMP_TARGET_ENTER_DATA_DIRECTIVE:
3707 S = OMPTargetEnterDataDirective::CreateEmpty(
3708 Context, Record[ASTStmtReader::NumStmtFields], Empty);
3711 case STMT_OMP_TARGET_EXIT_DATA_DIRECTIVE:
3712 S = OMPTargetExitDataDirective::CreateEmpty(
3713 Context, Record[ASTStmtReader::NumStmtFields], Empty);
3716 case STMT_OMP_TARGET_PARALLEL_DIRECTIVE:
3717 S = OMPTargetParallelDirective::CreateEmpty(
3718 Context, Record[ASTStmtReader::NumStmtFields], Empty);
3721 case STMT_OMP_TARGET_PARALLEL_FOR_DIRECTIVE: {
3722 unsigned NumClauses = Record[ASTStmtReader::NumStmtFields];
3723 unsigned CollapsedNum = Record[ASTStmtReader::NumStmtFields + 1];
3724 S = OMPTargetParallelForDirective::CreateEmpty(Context, NumClauses,
3725 CollapsedNum, Empty);
3729 case STMT_OMP_TARGET_UPDATE_DIRECTIVE:
3730 S = OMPTargetUpdateDirective::CreateEmpty(
3731 Context, Record[ASTStmtReader::NumStmtFields], Empty);
3734 case STMT_OMP_TEAMS_DIRECTIVE:
3735 S = OMPTeamsDirective::CreateEmpty(
3736 Context, Record[ASTStmtReader::NumStmtFields], Empty);
3739 case STMT_OMP_CANCELLATION_POINT_DIRECTIVE:
3740 S = OMPCancellationPointDirective::CreateEmpty(Context, Empty);
3743 case STMT_OMP_CANCEL_DIRECTIVE:
3744 S = OMPCancelDirective::CreateEmpty(
3745 Context, Record[ASTStmtReader::NumStmtFields], Empty);
3748 case STMT_OMP_TASKLOOP_DIRECTIVE: {
3749 unsigned NumClauses = Record[ASTStmtReader::NumStmtFields];
3750 unsigned CollapsedNum = Record[ASTStmtReader::NumStmtFields + 1];
3751 S = OMPTaskLoopDirective::CreateEmpty(Context, NumClauses, CollapsedNum,
3756 case STMT_OMP_TASKLOOP_SIMD_DIRECTIVE: {
3757 unsigned NumClauses = Record[ASTStmtReader::NumStmtFields];
3758 unsigned CollapsedNum = Record[ASTStmtReader::NumStmtFields + 1];
3759 S = OMPTaskLoopSimdDirective::CreateEmpty(Context, NumClauses,
3760 CollapsedNum, Empty);
3764 case STMT_OMP_DISTRIBUTE_DIRECTIVE: {
3765 unsigned NumClauses = Record[ASTStmtReader::NumStmtFields];
3766 unsigned CollapsedNum = Record[ASTStmtReader::NumStmtFields + 1];
3767 S = OMPDistributeDirective::CreateEmpty(Context, NumClauses, CollapsedNum,
3772 case STMT_OMP_DISTRIBUTE_PARALLEL_FOR_DIRECTIVE: {
3773 unsigned NumClauses = Record[ASTStmtReader::NumStmtFields];
3774 unsigned CollapsedNum = Record[ASTStmtReader::NumStmtFields + 1];
3775 S = OMPDistributeParallelForDirective::CreateEmpty(Context, NumClauses,
3776 CollapsedNum, Empty);
3780 case STMT_OMP_DISTRIBUTE_PARALLEL_FOR_SIMD_DIRECTIVE: {
3781 unsigned NumClauses = Record[ASTStmtReader::NumStmtFields];
3782 unsigned CollapsedNum = Record[ASTStmtReader::NumStmtFields + 1];
3783 S = OMPDistributeParallelForSimdDirective::CreateEmpty(Context, NumClauses,
3789 case STMT_OMP_DISTRIBUTE_SIMD_DIRECTIVE: {
3790 unsigned NumClauses = Record[ASTStmtReader::NumStmtFields];
3791 unsigned CollapsedNum = Record[ASTStmtReader::NumStmtFields + 1];
3792 S = OMPDistributeSimdDirective::CreateEmpty(Context, NumClauses,
3793 CollapsedNum, Empty);
3797 case STMT_OMP_TARGET_PARALLEL_FOR_SIMD_DIRECTIVE: {
3798 unsigned NumClauses = Record[ASTStmtReader::NumStmtFields];
3799 unsigned CollapsedNum = Record[ASTStmtReader::NumStmtFields + 1];
3800 S = OMPTargetParallelForSimdDirective::CreateEmpty(Context, NumClauses,
3801 CollapsedNum, Empty);
3805 case STMT_OMP_TARGET_SIMD_DIRECTIVE: {
3806 auto NumClauses = Record[ASTStmtReader::NumStmtFields];
3807 auto CollapsedNum = Record[ASTStmtReader::NumStmtFields + 1];
3808 S = OMPTargetSimdDirective::CreateEmpty(Context, NumClauses, CollapsedNum,
3813 case STMT_OMP_TEAMS_DISTRIBUTE_DIRECTIVE: {
3814 auto NumClauses = Record[ASTStmtReader::NumStmtFields];
3815 auto CollapsedNum = Record[ASTStmtReader::NumStmtFields + 1];
3816 S = OMPTeamsDistributeDirective::CreateEmpty(Context, NumClauses,
3817 CollapsedNum, Empty);
3821 case STMT_OMP_TEAMS_DISTRIBUTE_SIMD_DIRECTIVE: {
3822 unsigned NumClauses = Record[ASTStmtReader::NumStmtFields];
3823 unsigned CollapsedNum = Record[ASTStmtReader::NumStmtFields + 1];
3824 S = OMPTeamsDistributeSimdDirective::CreateEmpty(Context, NumClauses,
3825 CollapsedNum, Empty);
3829 case STMT_OMP_TEAMS_DISTRIBUTE_PARALLEL_FOR_SIMD_DIRECTIVE: {
3830 auto NumClauses = Record[ASTStmtReader::NumStmtFields];
3831 auto CollapsedNum = Record[ASTStmtReader::NumStmtFields + 1];
3832 S = OMPTeamsDistributeParallelForSimdDirective::CreateEmpty(
3833 Context, NumClauses, CollapsedNum, Empty);
3837 case STMT_OMP_TEAMS_DISTRIBUTE_PARALLEL_FOR_DIRECTIVE: {
3838 auto NumClauses = Record[ASTStmtReader::NumStmtFields];
3839 auto CollapsedNum = Record[ASTStmtReader::NumStmtFields + 1];
3840 S = OMPTeamsDistributeParallelForDirective::CreateEmpty(
3841 Context, NumClauses, CollapsedNum, Empty);
3845 case STMT_OMP_TARGET_TEAMS_DIRECTIVE:
3846 S = OMPTargetTeamsDirective::CreateEmpty(
3847 Context, Record[ASTStmtReader::NumStmtFields], Empty);
3850 case STMT_OMP_TARGET_TEAMS_DISTRIBUTE_DIRECTIVE: {
3851 auto NumClauses = Record[ASTStmtReader::NumStmtFields];
3852 auto CollapsedNum = Record[ASTStmtReader::NumStmtFields + 1];
3853 S = OMPTargetTeamsDistributeDirective::CreateEmpty(Context, NumClauses,
3854 CollapsedNum, Empty);
3858 case STMT_OMP_TARGET_TEAMS_DISTRIBUTE_PARALLEL_FOR_DIRECTIVE: {
3859 auto NumClauses = Record[ASTStmtReader::NumStmtFields];
3860 auto CollapsedNum = Record[ASTStmtReader::NumStmtFields + 1];
3861 S = OMPTargetTeamsDistributeParallelForDirective::CreateEmpty(
3862 Context, NumClauses, CollapsedNum, Empty);
3866 case STMT_OMP_TARGET_TEAMS_DISTRIBUTE_PARALLEL_FOR_SIMD_DIRECTIVE: {
3867 auto NumClauses = Record[ASTStmtReader::NumStmtFields];
3868 auto CollapsedNum = Record[ASTStmtReader::NumStmtFields + 1];
3869 S = OMPTargetTeamsDistributeParallelForSimdDirective::CreateEmpty(
3870 Context, NumClauses, CollapsedNum, Empty);
3874 case STMT_OMP_TARGET_TEAMS_DISTRIBUTE_SIMD_DIRECTIVE: {
3875 auto NumClauses = Record[ASTStmtReader::NumStmtFields];
3876 auto CollapsedNum = Record[ASTStmtReader::NumStmtFields + 1];
3877 S = OMPTargetTeamsDistributeSimdDirective::CreateEmpty(
3878 Context, NumClauses, CollapsedNum, Empty);
3882 case EXPR_CXX_OPERATOR_CALL:
3883 S = new (Context) CXXOperatorCallExpr(Context, Empty);
3886 case EXPR_CXX_MEMBER_CALL:
3887 S = new (Context) CXXMemberCallExpr(Context, Empty);
3890 case EXPR_CXX_CONSTRUCT:
3891 S = new (Context) CXXConstructExpr(Empty);
3894 case EXPR_CXX_INHERITED_CTOR_INIT:
3895 S = new (Context) CXXInheritedCtorInitExpr(Empty);
3898 case EXPR_CXX_TEMPORARY_OBJECT:
3899 S = new (Context) CXXTemporaryObjectExpr(Empty);
3902 case EXPR_CXX_STATIC_CAST:
3903 S = CXXStaticCastExpr::CreateEmpty(Context,
3904 /*PathSize*/ Record[ASTStmtReader::NumExprFields]);
3907 case EXPR_CXX_DYNAMIC_CAST:
3908 S = CXXDynamicCastExpr::CreateEmpty(Context,
3909 /*PathSize*/ Record[ASTStmtReader::NumExprFields]);
3912 case EXPR_CXX_REINTERPRET_CAST:
3913 S = CXXReinterpretCastExpr::CreateEmpty(Context,
3914 /*PathSize*/ Record[ASTStmtReader::NumExprFields]);
3917 case EXPR_CXX_CONST_CAST:
3918 S = CXXConstCastExpr::CreateEmpty(Context);
3921 case EXPR_CXX_FUNCTIONAL_CAST:
3922 S = CXXFunctionalCastExpr::CreateEmpty(Context,
3923 /*PathSize*/ Record[ASTStmtReader::NumExprFields]);
3926 case EXPR_USER_DEFINED_LITERAL:
3927 S = new (Context) UserDefinedLiteral(Context, Empty);
3930 case EXPR_CXX_STD_INITIALIZER_LIST:
3931 S = new (Context) CXXStdInitializerListExpr(Empty);
3934 case EXPR_CXX_BOOL_LITERAL:
3935 S = new (Context) CXXBoolLiteralExpr(Empty);
3938 case EXPR_CXX_NULL_PTR_LITERAL:
3939 S = new (Context) CXXNullPtrLiteralExpr(Empty);
3942 case EXPR_CXX_TYPEID_EXPR:
3943 S = new (Context) CXXTypeidExpr(Empty, true);
3946 case EXPR_CXX_TYPEID_TYPE:
3947 S = new (Context) CXXTypeidExpr(Empty, false);
3950 case EXPR_CXX_UUIDOF_EXPR:
3951 S = new (Context) CXXUuidofExpr(Empty, true);
3954 case EXPR_CXX_PROPERTY_REF_EXPR:
3955 S = new (Context) MSPropertyRefExpr(Empty);
3958 case EXPR_CXX_PROPERTY_SUBSCRIPT_EXPR:
3959 S = new (Context) MSPropertySubscriptExpr(Empty);
3962 case EXPR_CXX_UUIDOF_TYPE:
3963 S = new (Context) CXXUuidofExpr(Empty, false);
3967 S = new (Context) CXXThisExpr(Empty);
3970 case EXPR_CXX_THROW:
3971 S = new (Context) CXXThrowExpr(Empty);
3974 case EXPR_CXX_DEFAULT_ARG:
3975 S = new (Context) CXXDefaultArgExpr(Empty);
3978 case EXPR_CXX_DEFAULT_INIT:
3979 S = new (Context) CXXDefaultInitExpr(Empty);
3982 case EXPR_CXX_BIND_TEMPORARY:
3983 S = new (Context) CXXBindTemporaryExpr(Empty);
3986 case EXPR_CXX_SCALAR_VALUE_INIT:
3987 S = new (Context) CXXScalarValueInitExpr(Empty);
3991 S = new (Context) CXXNewExpr(Empty);
3994 case EXPR_CXX_DELETE:
3995 S = new (Context) CXXDeleteExpr(Empty);
3998 case EXPR_CXX_PSEUDO_DESTRUCTOR:
3999 S = new (Context) CXXPseudoDestructorExpr(Empty);
4002 case EXPR_EXPR_WITH_CLEANUPS:
4003 S = ExprWithCleanups::Create(Context, Empty,
4004 Record[ASTStmtReader::NumExprFields]);
4007 case EXPR_CXX_DEPENDENT_SCOPE_MEMBER:
4008 S = CXXDependentScopeMemberExpr::CreateEmpty(Context,
4009 /*HasTemplateKWAndArgsInfo=*/Record[ASTStmtReader::NumExprFields],
4010 /*NumTemplateArgs=*/Record[ASTStmtReader::NumExprFields]
4011 ? Record[ASTStmtReader::NumExprFields + 1]
4015 case EXPR_CXX_DEPENDENT_SCOPE_DECL_REF:
4016 S = DependentScopeDeclRefExpr::CreateEmpty(Context,
4017 /*HasTemplateKWAndArgsInfo=*/Record[ASTStmtReader::NumExprFields],
4018 /*NumTemplateArgs=*/Record[ASTStmtReader::NumExprFields]
4019 ? Record[ASTStmtReader::NumExprFields + 1]
4023 case EXPR_CXX_UNRESOLVED_CONSTRUCT:
4024 S = CXXUnresolvedConstructExpr::CreateEmpty(Context,
4025 /*NumArgs=*/Record[ASTStmtReader::NumExprFields]);
4028 case EXPR_CXX_UNRESOLVED_MEMBER:
4029 S = UnresolvedMemberExpr::CreateEmpty(Context,
4030 /*HasTemplateKWAndArgsInfo=*/Record[ASTStmtReader::NumExprFields],
4031 /*NumTemplateArgs=*/Record[ASTStmtReader::NumExprFields]
4032 ? Record[ASTStmtReader::NumExprFields + 1]
4036 case EXPR_CXX_UNRESOLVED_LOOKUP:
4037 S = UnresolvedLookupExpr::CreateEmpty(Context,
4038 /*HasTemplateKWAndArgsInfo=*/Record[ASTStmtReader::NumExprFields],
4039 /*NumTemplateArgs=*/Record[ASTStmtReader::NumExprFields]
4040 ? Record[ASTStmtReader::NumExprFields + 1]
4044 case EXPR_TYPE_TRAIT:
4045 S = TypeTraitExpr::CreateDeserialized(Context,
4046 Record[ASTStmtReader::NumExprFields]);
4049 case EXPR_ARRAY_TYPE_TRAIT:
4050 S = new (Context) ArrayTypeTraitExpr(Empty);
4053 case EXPR_CXX_EXPRESSION_TRAIT:
4054 S = new (Context) ExpressionTraitExpr(Empty);
4057 case EXPR_CXX_NOEXCEPT:
4058 S = new (Context) CXXNoexceptExpr(Empty);
4061 case EXPR_PACK_EXPANSION:
4062 S = new (Context) PackExpansionExpr(Empty);
4065 case EXPR_SIZEOF_PACK:
4066 S = SizeOfPackExpr::CreateDeserialized(
4068 /*NumPartialArgs=*/Record[ASTStmtReader::NumExprFields]);
4071 case EXPR_SUBST_NON_TYPE_TEMPLATE_PARM:
4072 S = new (Context) SubstNonTypeTemplateParmExpr(Empty);
4075 case EXPR_SUBST_NON_TYPE_TEMPLATE_PARM_PACK:
4076 S = new (Context) SubstNonTypeTemplateParmPackExpr(Empty);
4079 case EXPR_FUNCTION_PARM_PACK:
4080 S = FunctionParmPackExpr::CreateEmpty(Context,
4081 Record[ASTStmtReader::NumExprFields]);
4084 case EXPR_MATERIALIZE_TEMPORARY:
4085 S = new (Context) MaterializeTemporaryExpr(Empty);
4089 S = new (Context) CXXFoldExpr(Empty);
4092 case EXPR_OPAQUE_VALUE:
4093 S = new (Context) OpaqueValueExpr(Empty);
4096 case EXPR_CUDA_KERNEL_CALL:
4097 S = new (Context) CUDAKernelCallExpr(Context, Empty);
4101 S = new (Context) AsTypeExpr(Empty);
4104 case EXPR_PSEUDO_OBJECT: {
4105 unsigned numSemanticExprs = Record[ASTStmtReader::NumExprFields];
4106 S = PseudoObjectExpr::Create(Context, Empty, numSemanticExprs);
4111 S = new (Context) AtomicExpr(Empty);
4115 unsigned NumCaptures = Record[ASTStmtReader::NumExprFields];
4116 S = LambdaExpr::CreateDeserialized(Context, NumCaptures);
4120 case STMT_COROUTINE_BODY: {
4121 unsigned NumParams = Record[ASTStmtReader::NumStmtFields];
4122 S = CoroutineBodyStmt::Create(Context, Empty, NumParams);
4127 S = new (Context) CoreturnStmt(Empty);
4131 S = new (Context) CoawaitExpr(Empty);
4135 S = new (Context) CoyieldExpr(Empty);
4138 case EXPR_DEPENDENT_COAWAIT:
4139 S = new (Context) DependentCoawaitExpr(Empty);
4143 // We hit a STMT_STOP, so we're done with this expression.
4147 ++NumStatementsRead;
4149 if (S && !IsStmtReference) {
4151 StmtEntries[Cursor.GetCurrentBitNo()] = S;
4154 assert(Record.getIdx() == Record.size() &&
4155 "Invalid deserialization of statement");
4156 StmtStack.push_back(S);
4159 assert(StmtStack.size() > PrevNumStmts && "Read too many sub-stmts!");
4160 assert(StmtStack.size() == PrevNumStmts + 1 && "Extra expressions on stack!");
4161 return StmtStack.pop_back_val();