1 //===--- ASTReaderStmt.cpp - Stmt/Expr Deserialization ----------*- C++ -*-===//
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/DeclCXX.h"
18 #include "clang/AST/DeclTemplate.h"
19 #include "clang/AST/StmtVisitor.h"
20 #include "clang/Lex/Token.h"
21 #include "llvm/ADT/SmallString.h"
22 using namespace clang;
23 using namespace clang::serialization;
27 class ASTStmtReader : public StmtVisitor<ASTStmtReader> {
28 friend class OMPClauseReader;
30 ASTRecordReader &Record;
31 llvm::BitstreamCursor &DeclsCursor;
33 SourceLocation ReadSourceLocation() {
34 return Record.readSourceLocation();
37 SourceRange ReadSourceRange() {
38 return Record.readSourceRange();
41 std::string ReadString() {
42 return Record.readString();
45 TypeSourceInfo *GetTypeSourceInfo() {
46 return Record.getTypeSourceInfo();
50 return Record.readDecl();
55 return Record.readDeclAs<T>();
58 void ReadDeclarationNameLoc(DeclarationNameLoc &DNLoc,
59 DeclarationName Name) {
60 Record.readDeclarationNameLoc(DNLoc, Name);
63 void ReadDeclarationNameInfo(DeclarationNameInfo &NameInfo) {
64 Record.readDeclarationNameInfo(NameInfo);
68 ASTStmtReader(ASTRecordReader &Record, llvm::BitstreamCursor &Cursor)
69 : Record(Record), DeclsCursor(Cursor) {}
71 /// \brief The number of record fields required for the Stmt class
73 static const unsigned NumStmtFields = 0;
75 /// \brief The number of record fields required for the Expr class
77 static const unsigned NumExprFields = NumStmtFields + 7;
79 /// \brief Read and initialize a ExplicitTemplateArgumentList structure.
80 void ReadTemplateKWAndArgsInfo(ASTTemplateKWAndArgsInfo &Args,
81 TemplateArgumentLoc *ArgsLocArray,
82 unsigned NumTemplateArgs);
83 /// \brief Read and initialize a ExplicitTemplateArgumentList structure.
84 void ReadExplicitTemplateArgumentList(ASTTemplateArgumentListInfo &ArgList,
85 unsigned NumTemplateArgs);
87 void VisitStmt(Stmt *S);
88 #define STMT(Type, Base) \
89 void Visit##Type(Type *);
90 #include "clang/AST/StmtNodes.inc"
94 void ASTStmtReader::ReadTemplateKWAndArgsInfo(ASTTemplateKWAndArgsInfo &Args,
95 TemplateArgumentLoc *ArgsLocArray,
96 unsigned NumTemplateArgs) {
97 SourceLocation TemplateKWLoc = ReadSourceLocation();
98 TemplateArgumentListInfo ArgInfo;
99 ArgInfo.setLAngleLoc(ReadSourceLocation());
100 ArgInfo.setRAngleLoc(ReadSourceLocation());
101 for (unsigned i = 0; i != NumTemplateArgs; ++i)
102 ArgInfo.addArgument(Record.readTemplateArgumentLoc());
103 Args.initializeFrom(TemplateKWLoc, ArgInfo, ArgsLocArray);
106 void ASTStmtReader::VisitStmt(Stmt *S) {
107 assert(Record.getIdx() == NumStmtFields && "Incorrect statement field count");
110 void ASTStmtReader::VisitNullStmt(NullStmt *S) {
112 S->setSemiLoc(ReadSourceLocation());
113 S->HasLeadingEmptyMacro = Record.readInt();
116 void ASTStmtReader::VisitCompoundStmt(CompoundStmt *S) {
118 SmallVector<Stmt *, 16> Stmts;
119 unsigned NumStmts = Record.readInt();
121 Stmts.push_back(Record.readSubStmt());
123 S->LBraceLoc = ReadSourceLocation();
124 S->RBraceLoc = ReadSourceLocation();
127 void ASTStmtReader::VisitSwitchCase(SwitchCase *S) {
129 Record.recordSwitchCaseID(S, Record.readInt());
130 S->setKeywordLoc(ReadSourceLocation());
131 S->setColonLoc(ReadSourceLocation());
134 void ASTStmtReader::VisitCaseStmt(CaseStmt *S) {
136 S->setLHS(Record.readSubExpr());
137 S->setRHS(Record.readSubExpr());
138 S->setSubStmt(Record.readSubStmt());
139 S->setEllipsisLoc(ReadSourceLocation());
142 void ASTStmtReader::VisitDefaultStmt(DefaultStmt *S) {
144 S->setSubStmt(Record.readSubStmt());
147 void ASTStmtReader::VisitLabelStmt(LabelStmt *S) {
149 LabelDecl *LD = ReadDeclAs<LabelDecl>();
152 S->setSubStmt(Record.readSubStmt());
153 S->setIdentLoc(ReadSourceLocation());
156 void ASTStmtReader::VisitAttributedStmt(AttributedStmt *S) {
158 uint64_t NumAttrs = Record.readInt();
160 Record.readAttributes(Attrs);
162 assert(NumAttrs == S->NumAttrs);
163 assert(NumAttrs == Attrs.size());
164 std::copy(Attrs.begin(), Attrs.end(), S->getAttrArrayPtr());
165 S->SubStmt = Record.readSubStmt();
166 S->AttrLoc = ReadSourceLocation();
169 void ASTStmtReader::VisitIfStmt(IfStmt *S) {
171 S->setConstexpr(Record.readInt());
172 S->setInit(Record.readSubStmt());
173 S->setConditionVariable(Record.getContext(), ReadDeclAs<VarDecl>());
174 S->setCond(Record.readSubExpr());
175 S->setThen(Record.readSubStmt());
176 S->setElse(Record.readSubStmt());
177 S->setIfLoc(ReadSourceLocation());
178 S->setElseLoc(ReadSourceLocation());
181 void ASTStmtReader::VisitSwitchStmt(SwitchStmt *S) {
183 S->setInit(Record.readSubStmt());
184 S->setConditionVariable(Record.getContext(), ReadDeclAs<VarDecl>());
185 S->setCond(Record.readSubExpr());
186 S->setBody(Record.readSubStmt());
187 S->setSwitchLoc(ReadSourceLocation());
188 if (Record.readInt())
189 S->setAllEnumCasesCovered();
191 SwitchCase *PrevSC = nullptr;
192 for (auto E = Record.size(); Record.getIdx() != E; ) {
193 SwitchCase *SC = Record.getSwitchCaseWithID(Record.readInt());
195 PrevSC->setNextSwitchCase(SC);
197 S->setSwitchCaseList(SC);
203 void ASTStmtReader::VisitWhileStmt(WhileStmt *S) {
205 S->setConditionVariable(Record.getContext(), ReadDeclAs<VarDecl>());
207 S->setCond(Record.readSubExpr());
208 S->setBody(Record.readSubStmt());
209 S->setWhileLoc(ReadSourceLocation());
212 void ASTStmtReader::VisitDoStmt(DoStmt *S) {
214 S->setCond(Record.readSubExpr());
215 S->setBody(Record.readSubStmt());
216 S->setDoLoc(ReadSourceLocation());
217 S->setWhileLoc(ReadSourceLocation());
218 S->setRParenLoc(ReadSourceLocation());
221 void ASTStmtReader::VisitForStmt(ForStmt *S) {
223 S->setInit(Record.readSubStmt());
224 S->setCond(Record.readSubExpr());
225 S->setConditionVariable(Record.getContext(), ReadDeclAs<VarDecl>());
226 S->setInc(Record.readSubExpr());
227 S->setBody(Record.readSubStmt());
228 S->setForLoc(ReadSourceLocation());
229 S->setLParenLoc(ReadSourceLocation());
230 S->setRParenLoc(ReadSourceLocation());
233 void ASTStmtReader::VisitGotoStmt(GotoStmt *S) {
235 S->setLabel(ReadDeclAs<LabelDecl>());
236 S->setGotoLoc(ReadSourceLocation());
237 S->setLabelLoc(ReadSourceLocation());
240 void ASTStmtReader::VisitIndirectGotoStmt(IndirectGotoStmt *S) {
242 S->setGotoLoc(ReadSourceLocation());
243 S->setStarLoc(ReadSourceLocation());
244 S->setTarget(Record.readSubExpr());
247 void ASTStmtReader::VisitContinueStmt(ContinueStmt *S) {
249 S->setContinueLoc(ReadSourceLocation());
252 void ASTStmtReader::VisitBreakStmt(BreakStmt *S) {
254 S->setBreakLoc(ReadSourceLocation());
257 void ASTStmtReader::VisitReturnStmt(ReturnStmt *S) {
259 S->setRetValue(Record.readSubExpr());
260 S->setReturnLoc(ReadSourceLocation());
261 S->setNRVOCandidate(ReadDeclAs<VarDecl>());
264 void ASTStmtReader::VisitDeclStmt(DeclStmt *S) {
266 S->setStartLoc(ReadSourceLocation());
267 S->setEndLoc(ReadSourceLocation());
269 if (Record.size() - Record.getIdx() == 1) {
270 // Single declaration
271 S->setDeclGroup(DeclGroupRef(ReadDecl()));
273 SmallVector<Decl *, 16> Decls;
274 int N = Record.size() - Record.getIdx();
276 for (int I = 0; I < N; ++I)
277 Decls.push_back(ReadDecl());
278 S->setDeclGroup(DeclGroupRef(DeclGroup::Create(Record.getContext(),
284 void ASTStmtReader::VisitAsmStmt(AsmStmt *S) {
286 S->NumOutputs = Record.readInt();
287 S->NumInputs = Record.readInt();
288 S->NumClobbers = Record.readInt();
289 S->setAsmLoc(ReadSourceLocation());
290 S->setVolatile(Record.readInt());
291 S->setSimple(Record.readInt());
294 void ASTStmtReader::VisitGCCAsmStmt(GCCAsmStmt *S) {
296 S->setRParenLoc(ReadSourceLocation());
297 S->setAsmString(cast_or_null<StringLiteral>(Record.readSubStmt()));
299 unsigned NumOutputs = S->getNumOutputs();
300 unsigned NumInputs = S->getNumInputs();
301 unsigned NumClobbers = S->getNumClobbers();
303 // Outputs and inputs
304 SmallVector<IdentifierInfo *, 16> Names;
305 SmallVector<StringLiteral*, 16> Constraints;
306 SmallVector<Stmt*, 16> Exprs;
307 for (unsigned I = 0, N = NumOutputs + NumInputs; I != N; ++I) {
308 Names.push_back(Record.getIdentifierInfo());
309 Constraints.push_back(cast_or_null<StringLiteral>(Record.readSubStmt()));
310 Exprs.push_back(Record.readSubStmt());
314 SmallVector<StringLiteral*, 16> Clobbers;
315 for (unsigned I = 0; I != NumClobbers; ++I)
316 Clobbers.push_back(cast_or_null<StringLiteral>(Record.readSubStmt()));
318 S->setOutputsAndInputsAndClobbers(Record.getContext(),
319 Names.data(), Constraints.data(),
320 Exprs.data(), NumOutputs, NumInputs,
321 Clobbers.data(), NumClobbers);
324 void ASTStmtReader::VisitMSAsmStmt(MSAsmStmt *S) {
326 S->LBraceLoc = ReadSourceLocation();
327 S->EndLoc = ReadSourceLocation();
328 S->NumAsmToks = Record.readInt();
329 std::string AsmStr = ReadString();
332 SmallVector<Token, 16> AsmToks;
333 AsmToks.reserve(S->NumAsmToks);
334 for (unsigned i = 0, e = S->NumAsmToks; i != e; ++i) {
335 AsmToks.push_back(Record.readToken());
338 // The calls to reserve() for the FooData vectors are mandatory to
339 // prevent dead StringRefs in the Foo vectors.
341 // Read the clobbers.
342 SmallVector<std::string, 16> ClobbersData;
343 SmallVector<StringRef, 16> Clobbers;
344 ClobbersData.reserve(S->NumClobbers);
345 Clobbers.reserve(S->NumClobbers);
346 for (unsigned i = 0, e = S->NumClobbers; i != e; ++i) {
347 ClobbersData.push_back(ReadString());
348 Clobbers.push_back(ClobbersData.back());
351 // Read the operands.
352 unsigned NumOperands = S->NumOutputs + S->NumInputs;
353 SmallVector<Expr*, 16> Exprs;
354 SmallVector<std::string, 16> ConstraintsData;
355 SmallVector<StringRef, 16> Constraints;
356 Exprs.reserve(NumOperands);
357 ConstraintsData.reserve(NumOperands);
358 Constraints.reserve(NumOperands);
359 for (unsigned i = 0; i != NumOperands; ++i) {
360 Exprs.push_back(cast<Expr>(Record.readSubStmt()));
361 ConstraintsData.push_back(ReadString());
362 Constraints.push_back(ConstraintsData.back());
365 S->initialize(Record.getContext(), AsmStr, AsmToks,
366 Constraints, Exprs, Clobbers);
369 void ASTStmtReader::VisitCoroutineBodyStmt(CoroutineBodyStmt *S) {
371 assert(Record.peekInt() == S->NumParams);
373 auto *StoredStmts = S->getStoredStmts();
375 i < CoroutineBodyStmt::SubStmt::FirstParamMove + S->NumParams; ++i)
376 StoredStmts[i] = Record.readSubStmt();
379 void ASTStmtReader::VisitCoreturnStmt(CoreturnStmt *S) {
381 S->CoreturnLoc = Record.readSourceLocation();
382 for (auto &SubStmt: S->SubStmts)
383 SubStmt = Record.readSubStmt();
384 S->IsImplicit = Record.readInt() != 0;
387 void ASTStmtReader::VisitCoawaitExpr(CoawaitExpr *E) {
389 E->KeywordLoc = ReadSourceLocation();
390 for (auto &SubExpr: E->SubExprs)
391 SubExpr = Record.readSubStmt();
392 E->OpaqueValue = cast_or_null<OpaqueValueExpr>(Record.readSubStmt());
393 E->setIsImplicit(Record.readInt() != 0);
396 void ASTStmtReader::VisitCoyieldExpr(CoyieldExpr *E) {
398 E->KeywordLoc = ReadSourceLocation();
399 for (auto &SubExpr: E->SubExprs)
400 SubExpr = Record.readSubStmt();
401 E->OpaqueValue = cast_or_null<OpaqueValueExpr>(Record.readSubStmt());
404 void ASTStmtReader::VisitDependentCoawaitExpr(DependentCoawaitExpr *E) {
406 E->KeywordLoc = ReadSourceLocation();
407 for (auto &SubExpr: E->SubExprs)
408 SubExpr = Record.readSubStmt();
411 void ASTStmtReader::VisitCapturedStmt(CapturedStmt *S) {
414 S->setCapturedDecl(ReadDeclAs<CapturedDecl>());
415 S->setCapturedRegionKind(static_cast<CapturedRegionKind>(Record.readInt()));
416 S->setCapturedRecordDecl(ReadDeclAs<RecordDecl>());
419 for (CapturedStmt::capture_init_iterator I = S->capture_init_begin(),
420 E = S->capture_init_end();
422 *I = Record.readSubExpr();
425 S->setCapturedStmt(Record.readSubStmt());
426 S->getCapturedDecl()->setBody(S->getCapturedStmt());
429 for (auto &I : S->captures()) {
430 I.VarAndKind.setPointer(ReadDeclAs<VarDecl>());
432 static_cast<CapturedStmt::VariableCaptureKind>(Record.readInt()));
433 I.Loc = ReadSourceLocation();
437 void ASTStmtReader::VisitExpr(Expr *E) {
439 E->setType(Record.readType());
440 E->setTypeDependent(Record.readInt());
441 E->setValueDependent(Record.readInt());
442 E->setInstantiationDependent(Record.readInt());
443 E->ExprBits.ContainsUnexpandedParameterPack = Record.readInt();
444 E->setValueKind(static_cast<ExprValueKind>(Record.readInt()));
445 E->setObjectKind(static_cast<ExprObjectKind>(Record.readInt()));
446 assert(Record.getIdx() == NumExprFields &&
447 "Incorrect expression field count");
450 void ASTStmtReader::VisitPredefinedExpr(PredefinedExpr *E) {
452 E->setLocation(ReadSourceLocation());
453 E->Type = (PredefinedExpr::IdentType)Record.readInt();
454 E->FnName = cast_or_null<StringLiteral>(Record.readSubExpr());
457 void ASTStmtReader::VisitDeclRefExpr(DeclRefExpr *E) {
460 E->DeclRefExprBits.HasQualifier = Record.readInt();
461 E->DeclRefExprBits.HasFoundDecl = Record.readInt();
462 E->DeclRefExprBits.HasTemplateKWAndArgsInfo = Record.readInt();
463 E->DeclRefExprBits.HadMultipleCandidates = Record.readInt();
464 E->DeclRefExprBits.RefersToEnclosingVariableOrCapture = Record.readInt();
465 unsigned NumTemplateArgs = 0;
466 if (E->hasTemplateKWAndArgsInfo())
467 NumTemplateArgs = Record.readInt();
469 if (E->hasQualifier())
470 new (E->getTrailingObjects<NestedNameSpecifierLoc>())
471 NestedNameSpecifierLoc(Record.readNestedNameSpecifierLoc());
473 if (E->hasFoundDecl())
474 *E->getTrailingObjects<NamedDecl *>() = ReadDeclAs<NamedDecl>();
476 if (E->hasTemplateKWAndArgsInfo())
477 ReadTemplateKWAndArgsInfo(
478 *E->getTrailingObjects<ASTTemplateKWAndArgsInfo>(),
479 E->getTrailingObjects<TemplateArgumentLoc>(), NumTemplateArgs);
481 E->setDecl(ReadDeclAs<ValueDecl>());
482 E->setLocation(ReadSourceLocation());
483 ReadDeclarationNameLoc(E->DNLoc, E->getDecl()->getDeclName());
486 void ASTStmtReader::VisitIntegerLiteral(IntegerLiteral *E) {
488 E->setLocation(ReadSourceLocation());
489 E->setValue(Record.getContext(), Record.readAPInt());
492 void ASTStmtReader::VisitFloatingLiteral(FloatingLiteral *E) {
494 E->setRawSemantics(static_cast<Stmt::APFloatSemantics>(Record.readInt()));
495 E->setExact(Record.readInt());
496 E->setValue(Record.getContext(), Record.readAPFloat(E->getSemantics()));
497 E->setLocation(ReadSourceLocation());
500 void ASTStmtReader::VisitImaginaryLiteral(ImaginaryLiteral *E) {
502 E->setSubExpr(Record.readSubExpr());
505 void ASTStmtReader::VisitStringLiteral(StringLiteral *E) {
507 unsigned Len = Record.readInt();
508 assert(Record.peekInt() == E->getNumConcatenated() &&
509 "Wrong number of concatenated tokens!");
511 StringLiteral::StringKind kind =
512 static_cast<StringLiteral::StringKind>(Record.readInt());
513 bool isPascal = Record.readInt();
516 auto B = &Record.peekInt();
517 SmallString<16> Str(B, B + Len);
518 E->setString(Record.getContext(), Str, kind, isPascal);
519 Record.skipInts(Len);
521 // Read source locations
522 for (unsigned I = 0, N = E->getNumConcatenated(); I != N; ++I)
523 E->setStrTokenLoc(I, ReadSourceLocation());
526 void ASTStmtReader::VisitCharacterLiteral(CharacterLiteral *E) {
528 E->setValue(Record.readInt());
529 E->setLocation(ReadSourceLocation());
530 E->setKind(static_cast<CharacterLiteral::CharacterKind>(Record.readInt()));
533 void ASTStmtReader::VisitParenExpr(ParenExpr *E) {
535 E->setLParen(ReadSourceLocation());
536 E->setRParen(ReadSourceLocation());
537 E->setSubExpr(Record.readSubExpr());
540 void ASTStmtReader::VisitParenListExpr(ParenListExpr *E) {
542 unsigned NumExprs = Record.readInt();
543 E->Exprs = new (Record.getContext()) Stmt*[NumExprs];
544 for (unsigned i = 0; i != NumExprs; ++i)
545 E->Exprs[i] = Record.readSubStmt();
546 E->NumExprs = NumExprs;
547 E->LParenLoc = ReadSourceLocation();
548 E->RParenLoc = ReadSourceLocation();
551 void ASTStmtReader::VisitUnaryOperator(UnaryOperator *E) {
553 E->setSubExpr(Record.readSubExpr());
554 E->setOpcode((UnaryOperator::Opcode)Record.readInt());
555 E->setOperatorLoc(ReadSourceLocation());
558 void ASTStmtReader::VisitOffsetOfExpr(OffsetOfExpr *E) {
560 assert(E->getNumComponents() == Record.peekInt());
562 assert(E->getNumExpressions() == Record.peekInt());
564 E->setOperatorLoc(ReadSourceLocation());
565 E->setRParenLoc(ReadSourceLocation());
566 E->setTypeSourceInfo(GetTypeSourceInfo());
567 for (unsigned I = 0, N = E->getNumComponents(); I != N; ++I) {
568 OffsetOfNode::Kind Kind = static_cast<OffsetOfNode::Kind>(Record.readInt());
569 SourceLocation Start = ReadSourceLocation();
570 SourceLocation End = ReadSourceLocation();
572 case OffsetOfNode::Array:
573 E->setComponent(I, OffsetOfNode(Start, Record.readInt(), End));
576 case OffsetOfNode::Field:
578 I, OffsetOfNode(Start, ReadDeclAs<FieldDecl>(), End));
581 case OffsetOfNode::Identifier:
584 OffsetOfNode(Start, Record.getIdentifierInfo(), End));
587 case OffsetOfNode::Base: {
588 CXXBaseSpecifier *Base = new (Record.getContext()) CXXBaseSpecifier();
589 *Base = Record.readCXXBaseSpecifier();
590 E->setComponent(I, OffsetOfNode(Base));
596 for (unsigned I = 0, N = E->getNumExpressions(); I != N; ++I)
597 E->setIndexExpr(I, Record.readSubExpr());
600 void ASTStmtReader::VisitUnaryExprOrTypeTraitExpr(UnaryExprOrTypeTraitExpr *E) {
602 E->setKind(static_cast<UnaryExprOrTypeTrait>(Record.readInt()));
603 if (Record.peekInt() == 0) {
604 E->setArgument(Record.readSubExpr());
607 E->setArgument(GetTypeSourceInfo());
609 E->setOperatorLoc(ReadSourceLocation());
610 E->setRParenLoc(ReadSourceLocation());
613 void ASTStmtReader::VisitArraySubscriptExpr(ArraySubscriptExpr *E) {
615 E->setLHS(Record.readSubExpr());
616 E->setRHS(Record.readSubExpr());
617 E->setRBracketLoc(ReadSourceLocation());
620 void ASTStmtReader::VisitOMPArraySectionExpr(OMPArraySectionExpr *E) {
622 E->setBase(Record.readSubExpr());
623 E->setLowerBound(Record.readSubExpr());
624 E->setLength(Record.readSubExpr());
625 E->setColonLoc(ReadSourceLocation());
626 E->setRBracketLoc(ReadSourceLocation());
629 void ASTStmtReader::VisitCallExpr(CallExpr *E) {
631 E->setNumArgs(Record.getContext(), Record.readInt());
632 E->setRParenLoc(ReadSourceLocation());
633 E->setCallee(Record.readSubExpr());
634 for (unsigned I = 0, N = E->getNumArgs(); I != N; ++I)
635 E->setArg(I, Record.readSubExpr());
638 void ASTStmtReader::VisitCXXMemberCallExpr(CXXMemberCallExpr *E) {
642 void ASTStmtReader::VisitMemberExpr(MemberExpr *E) {
643 // Don't call VisitExpr, this is fully initialized at creation.
644 assert(E->getStmtClass() == Stmt::MemberExprClass &&
645 "It's a subclass, we must advance Idx!");
648 void ASTStmtReader::VisitObjCIsaExpr(ObjCIsaExpr *E) {
650 E->setBase(Record.readSubExpr());
651 E->setIsaMemberLoc(ReadSourceLocation());
652 E->setOpLoc(ReadSourceLocation());
653 E->setArrow(Record.readInt());
657 VisitObjCIndirectCopyRestoreExpr(ObjCIndirectCopyRestoreExpr *E) {
659 E->Operand = Record.readSubExpr();
660 E->setShouldCopy(Record.readInt());
663 void ASTStmtReader::VisitObjCBridgedCastExpr(ObjCBridgedCastExpr *E) {
664 VisitExplicitCastExpr(E);
665 E->LParenLoc = ReadSourceLocation();
666 E->BridgeKeywordLoc = ReadSourceLocation();
667 E->Kind = Record.readInt();
670 void ASTStmtReader::VisitCastExpr(CastExpr *E) {
672 unsigned NumBaseSpecs = Record.readInt();
673 assert(NumBaseSpecs == E->path_size());
674 E->setSubExpr(Record.readSubExpr());
675 E->setCastKind((CastKind)Record.readInt());
676 CastExpr::path_iterator BaseI = E->path_begin();
677 while (NumBaseSpecs--) {
678 CXXBaseSpecifier *BaseSpec = new (Record.getContext()) CXXBaseSpecifier;
679 *BaseSpec = Record.readCXXBaseSpecifier();
684 void ASTStmtReader::VisitBinaryOperator(BinaryOperator *E) {
686 E->setLHS(Record.readSubExpr());
687 E->setRHS(Record.readSubExpr());
688 E->setOpcode((BinaryOperator::Opcode)Record.readInt());
689 E->setOperatorLoc(ReadSourceLocation());
690 E->setFPFeatures(FPOptions(Record.readInt()));
693 void ASTStmtReader::VisitCompoundAssignOperator(CompoundAssignOperator *E) {
694 VisitBinaryOperator(E);
695 E->setComputationLHSType(Record.readType());
696 E->setComputationResultType(Record.readType());
699 void ASTStmtReader::VisitConditionalOperator(ConditionalOperator *E) {
701 E->SubExprs[ConditionalOperator::COND] = Record.readSubExpr();
702 E->SubExprs[ConditionalOperator::LHS] = Record.readSubExpr();
703 E->SubExprs[ConditionalOperator::RHS] = Record.readSubExpr();
704 E->QuestionLoc = ReadSourceLocation();
705 E->ColonLoc = ReadSourceLocation();
709 ASTStmtReader::VisitBinaryConditionalOperator(BinaryConditionalOperator *E) {
711 E->OpaqueValue = cast<OpaqueValueExpr>(Record.readSubExpr());
712 E->SubExprs[BinaryConditionalOperator::COMMON] = Record.readSubExpr();
713 E->SubExprs[BinaryConditionalOperator::COND] = Record.readSubExpr();
714 E->SubExprs[BinaryConditionalOperator::LHS] = Record.readSubExpr();
715 E->SubExprs[BinaryConditionalOperator::RHS] = Record.readSubExpr();
716 E->QuestionLoc = ReadSourceLocation();
717 E->ColonLoc = ReadSourceLocation();
720 void ASTStmtReader::VisitImplicitCastExpr(ImplicitCastExpr *E) {
724 void ASTStmtReader::VisitExplicitCastExpr(ExplicitCastExpr *E) {
726 E->setTypeInfoAsWritten(GetTypeSourceInfo());
729 void ASTStmtReader::VisitCStyleCastExpr(CStyleCastExpr *E) {
730 VisitExplicitCastExpr(E);
731 E->setLParenLoc(ReadSourceLocation());
732 E->setRParenLoc(ReadSourceLocation());
735 void ASTStmtReader::VisitCompoundLiteralExpr(CompoundLiteralExpr *E) {
737 E->setLParenLoc(ReadSourceLocation());
738 E->setTypeSourceInfo(GetTypeSourceInfo());
739 E->setInitializer(Record.readSubExpr());
740 E->setFileScope(Record.readInt());
743 void ASTStmtReader::VisitExtVectorElementExpr(ExtVectorElementExpr *E) {
745 E->setBase(Record.readSubExpr());
746 E->setAccessor(Record.getIdentifierInfo());
747 E->setAccessorLoc(ReadSourceLocation());
750 void ASTStmtReader::VisitInitListExpr(InitListExpr *E) {
752 if (InitListExpr *SyntForm = cast_or_null<InitListExpr>(Record.readSubStmt()))
753 E->setSyntacticForm(SyntForm);
754 E->setLBraceLoc(ReadSourceLocation());
755 E->setRBraceLoc(ReadSourceLocation());
756 bool isArrayFiller = Record.readInt();
757 Expr *filler = nullptr;
759 filler = Record.readSubExpr();
760 E->ArrayFillerOrUnionFieldInit = filler;
762 E->ArrayFillerOrUnionFieldInit = ReadDeclAs<FieldDecl>();
763 E->sawArrayRangeDesignator(Record.readInt());
764 unsigned NumInits = Record.readInt();
765 E->reserveInits(Record.getContext(), NumInits);
767 for (unsigned I = 0; I != NumInits; ++I) {
768 Expr *init = Record.readSubExpr();
769 E->updateInit(Record.getContext(), I, init ? init : filler);
772 for (unsigned I = 0; I != NumInits; ++I)
773 E->updateInit(Record.getContext(), I, Record.readSubExpr());
777 void ASTStmtReader::VisitDesignatedInitExpr(DesignatedInitExpr *E) {
778 typedef DesignatedInitExpr::Designator Designator;
781 unsigned NumSubExprs = Record.readInt();
782 assert(NumSubExprs == E->getNumSubExprs() && "Wrong number of subexprs");
783 for (unsigned I = 0; I != NumSubExprs; ++I)
784 E->setSubExpr(I, Record.readSubExpr());
785 E->setEqualOrColonLoc(ReadSourceLocation());
786 E->setGNUSyntax(Record.readInt());
788 SmallVector<Designator, 4> Designators;
789 while (Record.getIdx() < Record.size()) {
790 switch ((DesignatorTypes)Record.readInt()) {
791 case DESIG_FIELD_DECL: {
792 FieldDecl *Field = ReadDeclAs<FieldDecl>();
793 SourceLocation DotLoc = ReadSourceLocation();
794 SourceLocation FieldLoc = ReadSourceLocation();
795 Designators.push_back(Designator(Field->getIdentifier(), DotLoc,
797 Designators.back().setField(Field);
801 case DESIG_FIELD_NAME: {
802 const IdentifierInfo *Name = Record.getIdentifierInfo();
803 SourceLocation DotLoc = ReadSourceLocation();
804 SourceLocation FieldLoc = ReadSourceLocation();
805 Designators.push_back(Designator(Name, DotLoc, FieldLoc));
810 unsigned Index = Record.readInt();
811 SourceLocation LBracketLoc = ReadSourceLocation();
812 SourceLocation RBracketLoc = ReadSourceLocation();
813 Designators.push_back(Designator(Index, LBracketLoc, RBracketLoc));
817 case DESIG_ARRAY_RANGE: {
818 unsigned Index = Record.readInt();
819 SourceLocation LBracketLoc = ReadSourceLocation();
820 SourceLocation EllipsisLoc = ReadSourceLocation();
821 SourceLocation RBracketLoc = ReadSourceLocation();
822 Designators.push_back(Designator(Index, LBracketLoc, EllipsisLoc,
828 E->setDesignators(Record.getContext(),
829 Designators.data(), Designators.size());
832 void ASTStmtReader::VisitDesignatedInitUpdateExpr(DesignatedInitUpdateExpr *E) {
834 E->setBase(Record.readSubExpr());
835 E->setUpdater(Record.readSubExpr());
838 void ASTStmtReader::VisitNoInitExpr(NoInitExpr *E) {
842 void ASTStmtReader::VisitArrayInitLoopExpr(ArrayInitLoopExpr *E) {
844 E->SubExprs[0] = Record.readSubExpr();
845 E->SubExprs[1] = Record.readSubExpr();
848 void ASTStmtReader::VisitArrayInitIndexExpr(ArrayInitIndexExpr *E) {
852 void ASTStmtReader::VisitImplicitValueInitExpr(ImplicitValueInitExpr *E) {
856 void ASTStmtReader::VisitVAArgExpr(VAArgExpr *E) {
858 E->setSubExpr(Record.readSubExpr());
859 E->setWrittenTypeInfo(GetTypeSourceInfo());
860 E->setBuiltinLoc(ReadSourceLocation());
861 E->setRParenLoc(ReadSourceLocation());
862 E->setIsMicrosoftABI(Record.readInt());
865 void ASTStmtReader::VisitAddrLabelExpr(AddrLabelExpr *E) {
867 E->setAmpAmpLoc(ReadSourceLocation());
868 E->setLabelLoc(ReadSourceLocation());
869 E->setLabel(ReadDeclAs<LabelDecl>());
872 void ASTStmtReader::VisitStmtExpr(StmtExpr *E) {
874 E->setLParenLoc(ReadSourceLocation());
875 E->setRParenLoc(ReadSourceLocation());
876 E->setSubStmt(cast_or_null<CompoundStmt>(Record.readSubStmt()));
879 void ASTStmtReader::VisitChooseExpr(ChooseExpr *E) {
881 E->setCond(Record.readSubExpr());
882 E->setLHS(Record.readSubExpr());
883 E->setRHS(Record.readSubExpr());
884 E->setBuiltinLoc(ReadSourceLocation());
885 E->setRParenLoc(ReadSourceLocation());
886 E->setIsConditionTrue(Record.readInt());
889 void ASTStmtReader::VisitGNUNullExpr(GNUNullExpr *E) {
891 E->setTokenLocation(ReadSourceLocation());
894 void ASTStmtReader::VisitShuffleVectorExpr(ShuffleVectorExpr *E) {
896 SmallVector<Expr *, 16> Exprs;
897 unsigned NumExprs = Record.readInt();
899 Exprs.push_back(Record.readSubExpr());
900 E->setExprs(Record.getContext(), Exprs);
901 E->setBuiltinLoc(ReadSourceLocation());
902 E->setRParenLoc(ReadSourceLocation());
905 void ASTStmtReader::VisitConvertVectorExpr(ConvertVectorExpr *E) {
907 E->BuiltinLoc = ReadSourceLocation();
908 E->RParenLoc = ReadSourceLocation();
909 E->TInfo = GetTypeSourceInfo();
910 E->SrcExpr = Record.readSubExpr();
913 void ASTStmtReader::VisitBlockExpr(BlockExpr *E) {
915 E->setBlockDecl(ReadDeclAs<BlockDecl>());
918 void ASTStmtReader::VisitGenericSelectionExpr(GenericSelectionExpr *E) {
920 E->NumAssocs = Record.readInt();
921 E->AssocTypes = new (Record.getContext()) TypeSourceInfo*[E->NumAssocs];
923 new(Record.getContext()) Stmt*[GenericSelectionExpr::END_EXPR+E->NumAssocs];
925 E->SubExprs[GenericSelectionExpr::CONTROLLING] = Record.readSubExpr();
926 for (unsigned I = 0, N = E->getNumAssocs(); I != N; ++I) {
927 E->AssocTypes[I] = GetTypeSourceInfo();
928 E->SubExprs[GenericSelectionExpr::END_EXPR+I] = Record.readSubExpr();
930 E->ResultIndex = Record.readInt();
932 E->GenericLoc = ReadSourceLocation();
933 E->DefaultLoc = ReadSourceLocation();
934 E->RParenLoc = ReadSourceLocation();
937 void ASTStmtReader::VisitPseudoObjectExpr(PseudoObjectExpr *E) {
939 unsigned numSemanticExprs = Record.readInt();
940 assert(numSemanticExprs + 1 == E->PseudoObjectExprBits.NumSubExprs);
941 E->PseudoObjectExprBits.ResultIndex = Record.readInt();
943 // Read the syntactic expression.
944 E->getSubExprsBuffer()[0] = Record.readSubExpr();
946 // Read all the semantic expressions.
947 for (unsigned i = 0; i != numSemanticExprs; ++i) {
948 Expr *subExpr = Record.readSubExpr();
949 E->getSubExprsBuffer()[i+1] = subExpr;
953 void ASTStmtReader::VisitAtomicExpr(AtomicExpr *E) {
955 E->Op = AtomicExpr::AtomicOp(Record.readInt());
956 E->NumSubExprs = AtomicExpr::getNumSubExprs(E->Op);
957 for (unsigned I = 0; I != E->NumSubExprs; ++I)
958 E->SubExprs[I] = Record.readSubExpr();
959 E->BuiltinLoc = ReadSourceLocation();
960 E->RParenLoc = ReadSourceLocation();
963 //===----------------------------------------------------------------------===//
964 // Objective-C Expressions and Statements
966 void ASTStmtReader::VisitObjCStringLiteral(ObjCStringLiteral *E) {
968 E->setString(cast<StringLiteral>(Record.readSubStmt()));
969 E->setAtLoc(ReadSourceLocation());
972 void ASTStmtReader::VisitObjCBoxedExpr(ObjCBoxedExpr *E) {
974 // could be one of several IntegerLiteral, FloatLiteral, etc.
975 E->SubExpr = Record.readSubStmt();
976 E->BoxingMethod = ReadDeclAs<ObjCMethodDecl>();
977 E->Range = ReadSourceRange();
980 void ASTStmtReader::VisitObjCArrayLiteral(ObjCArrayLiteral *E) {
982 unsigned NumElements = Record.readInt();
983 assert(NumElements == E->getNumElements() && "Wrong number of elements");
984 Expr **Elements = E->getElements();
985 for (unsigned I = 0, N = NumElements; I != N; ++I)
986 Elements[I] = Record.readSubExpr();
987 E->ArrayWithObjectsMethod = ReadDeclAs<ObjCMethodDecl>();
988 E->Range = ReadSourceRange();
991 void ASTStmtReader::VisitObjCDictionaryLiteral(ObjCDictionaryLiteral *E) {
993 unsigned NumElements = Record.readInt();
994 assert(NumElements == E->getNumElements() && "Wrong number of elements");
995 bool HasPackExpansions = Record.readInt();
996 assert(HasPackExpansions == E->HasPackExpansions &&"Pack expansion mismatch");
997 ObjCDictionaryLiteral::KeyValuePair *KeyValues =
998 E->getTrailingObjects<ObjCDictionaryLiteral::KeyValuePair>();
999 ObjCDictionaryLiteral::ExpansionData *Expansions =
1000 E->getTrailingObjects<ObjCDictionaryLiteral::ExpansionData>();
1001 for (unsigned I = 0; I != NumElements; ++I) {
1002 KeyValues[I].Key = Record.readSubExpr();
1003 KeyValues[I].Value = Record.readSubExpr();
1004 if (HasPackExpansions) {
1005 Expansions[I].EllipsisLoc = ReadSourceLocation();
1006 Expansions[I].NumExpansionsPlusOne = Record.readInt();
1009 E->DictWithObjectsMethod = ReadDeclAs<ObjCMethodDecl>();
1010 E->Range = ReadSourceRange();
1013 void ASTStmtReader::VisitObjCEncodeExpr(ObjCEncodeExpr *E) {
1015 E->setEncodedTypeSourceInfo(GetTypeSourceInfo());
1016 E->setAtLoc(ReadSourceLocation());
1017 E->setRParenLoc(ReadSourceLocation());
1020 void ASTStmtReader::VisitObjCSelectorExpr(ObjCSelectorExpr *E) {
1022 E->setSelector(Record.readSelector());
1023 E->setAtLoc(ReadSourceLocation());
1024 E->setRParenLoc(ReadSourceLocation());
1027 void ASTStmtReader::VisitObjCProtocolExpr(ObjCProtocolExpr *E) {
1029 E->setProtocol(ReadDeclAs<ObjCProtocolDecl>());
1030 E->setAtLoc(ReadSourceLocation());
1031 E->ProtoLoc = ReadSourceLocation();
1032 E->setRParenLoc(ReadSourceLocation());
1035 void ASTStmtReader::VisitObjCIvarRefExpr(ObjCIvarRefExpr *E) {
1037 E->setDecl(ReadDeclAs<ObjCIvarDecl>());
1038 E->setLocation(ReadSourceLocation());
1039 E->setOpLoc(ReadSourceLocation());
1040 E->setBase(Record.readSubExpr());
1041 E->setIsArrow(Record.readInt());
1042 E->setIsFreeIvar(Record.readInt());
1045 void ASTStmtReader::VisitObjCPropertyRefExpr(ObjCPropertyRefExpr *E) {
1047 unsigned MethodRefFlags = Record.readInt();
1048 bool Implicit = Record.readInt() != 0;
1050 ObjCMethodDecl *Getter = ReadDeclAs<ObjCMethodDecl>();
1051 ObjCMethodDecl *Setter = ReadDeclAs<ObjCMethodDecl>();
1052 E->setImplicitProperty(Getter, Setter, MethodRefFlags);
1054 E->setExplicitProperty(ReadDeclAs<ObjCPropertyDecl>(), MethodRefFlags);
1056 E->setLocation(ReadSourceLocation());
1057 E->setReceiverLocation(ReadSourceLocation());
1058 switch (Record.readInt()) {
1060 E->setBase(Record.readSubExpr());
1063 E->setSuperReceiver(Record.readType());
1066 E->setClassReceiver(ReadDeclAs<ObjCInterfaceDecl>());
1071 void ASTStmtReader::VisitObjCSubscriptRefExpr(ObjCSubscriptRefExpr *E) {
1073 E->setRBracket(ReadSourceLocation());
1074 E->setBaseExpr(Record.readSubExpr());
1075 E->setKeyExpr(Record.readSubExpr());
1076 E->GetAtIndexMethodDecl = ReadDeclAs<ObjCMethodDecl>();
1077 E->SetAtIndexMethodDecl = ReadDeclAs<ObjCMethodDecl>();
1080 void ASTStmtReader::VisitObjCMessageExpr(ObjCMessageExpr *E) {
1082 assert(Record.peekInt() == E->getNumArgs());
1084 unsigned NumStoredSelLocs = Record.readInt();
1085 E->SelLocsKind = Record.readInt();
1086 E->setDelegateInitCall(Record.readInt());
1087 E->IsImplicit = Record.readInt();
1088 ObjCMessageExpr::ReceiverKind Kind
1089 = static_cast<ObjCMessageExpr::ReceiverKind>(Record.readInt());
1091 case ObjCMessageExpr::Instance:
1092 E->setInstanceReceiver(Record.readSubExpr());
1095 case ObjCMessageExpr::Class:
1096 E->setClassReceiver(GetTypeSourceInfo());
1099 case ObjCMessageExpr::SuperClass:
1100 case ObjCMessageExpr::SuperInstance: {
1101 QualType T = Record.readType();
1102 SourceLocation SuperLoc = ReadSourceLocation();
1103 E->setSuper(SuperLoc, T, Kind == ObjCMessageExpr::SuperInstance);
1108 assert(Kind == E->getReceiverKind());
1110 if (Record.readInt())
1111 E->setMethodDecl(ReadDeclAs<ObjCMethodDecl>());
1113 E->setSelector(Record.readSelector());
1115 E->LBracLoc = ReadSourceLocation();
1116 E->RBracLoc = ReadSourceLocation();
1118 for (unsigned I = 0, N = E->getNumArgs(); I != N; ++I)
1119 E->setArg(I, Record.readSubExpr());
1121 SourceLocation *Locs = E->getStoredSelLocs();
1122 for (unsigned I = 0; I != NumStoredSelLocs; ++I)
1123 Locs[I] = ReadSourceLocation();
1126 void ASTStmtReader::VisitObjCForCollectionStmt(ObjCForCollectionStmt *S) {
1128 S->setElement(Record.readSubStmt());
1129 S->setCollection(Record.readSubExpr());
1130 S->setBody(Record.readSubStmt());
1131 S->setForLoc(ReadSourceLocation());
1132 S->setRParenLoc(ReadSourceLocation());
1135 void ASTStmtReader::VisitObjCAtCatchStmt(ObjCAtCatchStmt *S) {
1137 S->setCatchBody(Record.readSubStmt());
1138 S->setCatchParamDecl(ReadDeclAs<VarDecl>());
1139 S->setAtCatchLoc(ReadSourceLocation());
1140 S->setRParenLoc(ReadSourceLocation());
1143 void ASTStmtReader::VisitObjCAtFinallyStmt(ObjCAtFinallyStmt *S) {
1145 S->setFinallyBody(Record.readSubStmt());
1146 S->setAtFinallyLoc(ReadSourceLocation());
1149 void ASTStmtReader::VisitObjCAutoreleasePoolStmt(ObjCAutoreleasePoolStmt *S) {
1151 S->setSubStmt(Record.readSubStmt());
1152 S->setAtLoc(ReadSourceLocation());
1155 void ASTStmtReader::VisitObjCAtTryStmt(ObjCAtTryStmt *S) {
1157 assert(Record.peekInt() == S->getNumCatchStmts());
1159 bool HasFinally = Record.readInt();
1160 S->setTryBody(Record.readSubStmt());
1161 for (unsigned I = 0, N = S->getNumCatchStmts(); I != N; ++I)
1162 S->setCatchStmt(I, cast_or_null<ObjCAtCatchStmt>(Record.readSubStmt()));
1165 S->setFinallyStmt(Record.readSubStmt());
1166 S->setAtTryLoc(ReadSourceLocation());
1169 void ASTStmtReader::VisitObjCAtSynchronizedStmt(ObjCAtSynchronizedStmt *S) {
1171 S->setSynchExpr(Record.readSubStmt());
1172 S->setSynchBody(Record.readSubStmt());
1173 S->setAtSynchronizedLoc(ReadSourceLocation());
1176 void ASTStmtReader::VisitObjCAtThrowStmt(ObjCAtThrowStmt *S) {
1178 S->setThrowExpr(Record.readSubStmt());
1179 S->setThrowLoc(ReadSourceLocation());
1182 void ASTStmtReader::VisitObjCBoolLiteralExpr(ObjCBoolLiteralExpr *E) {
1184 E->setValue(Record.readInt());
1185 E->setLocation(ReadSourceLocation());
1188 void ASTStmtReader::VisitObjCAvailabilityCheckExpr(ObjCAvailabilityCheckExpr *E) {
1190 SourceRange R = Record.readSourceRange();
1191 E->AtLoc = R.getBegin();
1192 E->RParen = R.getEnd();
1193 E->VersionToCheck = Record.readVersionTuple();
1196 //===----------------------------------------------------------------------===//
1197 // C++ Expressions and Statements
1198 //===----------------------------------------------------------------------===//
1200 void ASTStmtReader::VisitCXXCatchStmt(CXXCatchStmt *S) {
1202 S->CatchLoc = ReadSourceLocation();
1203 S->ExceptionDecl = ReadDeclAs<VarDecl>();
1204 S->HandlerBlock = Record.readSubStmt();
1207 void ASTStmtReader::VisitCXXTryStmt(CXXTryStmt *S) {
1209 assert(Record.peekInt() == S->getNumHandlers() && "NumStmtFields is wrong ?");
1211 S->TryLoc = ReadSourceLocation();
1212 S->getStmts()[0] = Record.readSubStmt();
1213 for (unsigned i = 0, e = S->getNumHandlers(); i != e; ++i)
1214 S->getStmts()[i + 1] = Record.readSubStmt();
1217 void ASTStmtReader::VisitCXXForRangeStmt(CXXForRangeStmt *S) {
1219 S->ForLoc = ReadSourceLocation();
1220 S->CoawaitLoc = ReadSourceLocation();
1221 S->ColonLoc = ReadSourceLocation();
1222 S->RParenLoc = ReadSourceLocation();
1223 S->setRangeStmt(Record.readSubStmt());
1224 S->setBeginStmt(Record.readSubStmt());
1225 S->setEndStmt(Record.readSubStmt());
1226 S->setCond(Record.readSubExpr());
1227 S->setInc(Record.readSubExpr());
1228 S->setLoopVarStmt(Record.readSubStmt());
1229 S->setBody(Record.readSubStmt());
1232 void ASTStmtReader::VisitMSDependentExistsStmt(MSDependentExistsStmt *S) {
1234 S->KeywordLoc = ReadSourceLocation();
1235 S->IsIfExists = Record.readInt();
1236 S->QualifierLoc = Record.readNestedNameSpecifierLoc();
1237 ReadDeclarationNameInfo(S->NameInfo);
1238 S->SubStmt = Record.readSubStmt();
1241 void ASTStmtReader::VisitCXXOperatorCallExpr(CXXOperatorCallExpr *E) {
1243 E->Operator = (OverloadedOperatorKind)Record.readInt();
1244 E->Range = Record.readSourceRange();
1245 E->setFPFeatures(FPOptions(Record.readInt()));
1248 void ASTStmtReader::VisitCXXConstructExpr(CXXConstructExpr *E) {
1250 E->NumArgs = Record.readInt();
1252 E->Args = new (Record.getContext()) Stmt*[E->NumArgs];
1253 for (unsigned I = 0, N = E->getNumArgs(); I != N; ++I)
1254 E->setArg(I, Record.readSubExpr());
1255 E->setConstructor(ReadDeclAs<CXXConstructorDecl>());
1256 E->setLocation(ReadSourceLocation());
1257 E->setElidable(Record.readInt());
1258 E->setHadMultipleCandidates(Record.readInt());
1259 E->setListInitialization(Record.readInt());
1260 E->setStdInitListInitialization(Record.readInt());
1261 E->setRequiresZeroInitialization(Record.readInt());
1262 E->setConstructionKind((CXXConstructExpr::ConstructionKind)Record.readInt());
1263 E->ParenOrBraceRange = ReadSourceRange();
1266 void ASTStmtReader::VisitCXXInheritedCtorInitExpr(CXXInheritedCtorInitExpr *E) {
1268 E->Constructor = ReadDeclAs<CXXConstructorDecl>();
1269 E->Loc = ReadSourceLocation();
1270 E->ConstructsVirtualBase = Record.readInt();
1271 E->InheritedFromVirtualBase = Record.readInt();
1274 void ASTStmtReader::VisitCXXTemporaryObjectExpr(CXXTemporaryObjectExpr *E) {
1275 VisitCXXConstructExpr(E);
1276 E->Type = GetTypeSourceInfo();
1279 void ASTStmtReader::VisitLambdaExpr(LambdaExpr *E) {
1281 unsigned NumCaptures = Record.readInt();
1282 assert(NumCaptures == E->NumCaptures);(void)NumCaptures;
1283 E->IntroducerRange = ReadSourceRange();
1284 E->CaptureDefault = static_cast<LambdaCaptureDefault>(Record.readInt());
1285 E->CaptureDefaultLoc = ReadSourceLocation();
1286 E->ExplicitParams = Record.readInt();
1287 E->ExplicitResultType = Record.readInt();
1288 E->ClosingBrace = ReadSourceLocation();
1290 // Read capture initializers.
1291 for (LambdaExpr::capture_init_iterator C = E->capture_init_begin(),
1292 CEnd = E->capture_init_end();
1294 *C = Record.readSubExpr();
1298 ASTStmtReader::VisitCXXStdInitializerListExpr(CXXStdInitializerListExpr *E) {
1300 E->SubExpr = Record.readSubExpr();
1303 void ASTStmtReader::VisitCXXNamedCastExpr(CXXNamedCastExpr *E) {
1304 VisitExplicitCastExpr(E);
1305 SourceRange R = ReadSourceRange();
1306 E->Loc = R.getBegin();
1307 E->RParenLoc = R.getEnd();
1308 R = ReadSourceRange();
1309 E->AngleBrackets = R;
1312 void ASTStmtReader::VisitCXXStaticCastExpr(CXXStaticCastExpr *E) {
1313 return VisitCXXNamedCastExpr(E);
1316 void ASTStmtReader::VisitCXXDynamicCastExpr(CXXDynamicCastExpr *E) {
1317 return VisitCXXNamedCastExpr(E);
1320 void ASTStmtReader::VisitCXXReinterpretCastExpr(CXXReinterpretCastExpr *E) {
1321 return VisitCXXNamedCastExpr(E);
1324 void ASTStmtReader::VisitCXXConstCastExpr(CXXConstCastExpr *E) {
1325 return VisitCXXNamedCastExpr(E);
1328 void ASTStmtReader::VisitCXXFunctionalCastExpr(CXXFunctionalCastExpr *E) {
1329 VisitExplicitCastExpr(E);
1330 E->setLParenLoc(ReadSourceLocation());
1331 E->setRParenLoc(ReadSourceLocation());
1334 void ASTStmtReader::VisitUserDefinedLiteral(UserDefinedLiteral *E) {
1336 E->UDSuffixLoc = ReadSourceLocation();
1339 void ASTStmtReader::VisitCXXBoolLiteralExpr(CXXBoolLiteralExpr *E) {
1341 E->setValue(Record.readInt());
1342 E->setLocation(ReadSourceLocation());
1345 void ASTStmtReader::VisitCXXNullPtrLiteralExpr(CXXNullPtrLiteralExpr *E) {
1347 E->setLocation(ReadSourceLocation());
1350 void ASTStmtReader::VisitCXXTypeidExpr(CXXTypeidExpr *E) {
1352 E->setSourceRange(ReadSourceRange());
1353 if (E->isTypeOperand()) { // typeid(int)
1354 E->setTypeOperandSourceInfo(
1355 GetTypeSourceInfo());
1360 E->setExprOperand(Record.readSubExpr());
1363 void ASTStmtReader::VisitCXXThisExpr(CXXThisExpr *E) {
1365 E->setLocation(ReadSourceLocation());
1366 E->setImplicit(Record.readInt());
1369 void ASTStmtReader::VisitCXXThrowExpr(CXXThrowExpr *E) {
1371 E->ThrowLoc = ReadSourceLocation();
1372 E->Op = Record.readSubExpr();
1373 E->IsThrownVariableInScope = Record.readInt();
1376 void ASTStmtReader::VisitCXXDefaultArgExpr(CXXDefaultArgExpr *E) {
1378 E->Param = ReadDeclAs<ParmVarDecl>();
1379 E->Loc = ReadSourceLocation();
1382 void ASTStmtReader::VisitCXXDefaultInitExpr(CXXDefaultInitExpr *E) {
1384 E->Field = ReadDeclAs<FieldDecl>();
1385 E->Loc = ReadSourceLocation();
1388 void ASTStmtReader::VisitCXXBindTemporaryExpr(CXXBindTemporaryExpr *E) {
1390 E->setTemporary(Record.readCXXTemporary());
1391 E->setSubExpr(Record.readSubExpr());
1394 void ASTStmtReader::VisitCXXScalarValueInitExpr(CXXScalarValueInitExpr *E) {
1396 E->TypeInfo = GetTypeSourceInfo();
1397 E->RParenLoc = ReadSourceLocation();
1400 void ASTStmtReader::VisitCXXNewExpr(CXXNewExpr *E) {
1402 E->GlobalNew = Record.readInt();
1403 bool isArray = Record.readInt();
1404 E->PassAlignment = Record.readInt();
1405 E->UsualArrayDeleteWantsSize = Record.readInt();
1406 unsigned NumPlacementArgs = Record.readInt();
1407 E->StoredInitializationStyle = Record.readInt();
1408 E->setOperatorNew(ReadDeclAs<FunctionDecl>());
1409 E->setOperatorDelete(ReadDeclAs<FunctionDecl>());
1410 E->AllocatedTypeInfo = GetTypeSourceInfo();
1411 E->TypeIdParens = ReadSourceRange();
1412 E->Range = ReadSourceRange();
1413 E->DirectInitRange = ReadSourceRange();
1415 E->AllocateArgsArray(Record.getContext(), isArray, NumPlacementArgs,
1416 E->StoredInitializationStyle != 0);
1418 // Install all the subexpressions.
1419 for (CXXNewExpr::raw_arg_iterator I = E->raw_arg_begin(),e = E->raw_arg_end();
1421 *I = Record.readSubStmt();
1424 void ASTStmtReader::VisitCXXDeleteExpr(CXXDeleteExpr *E) {
1426 E->GlobalDelete = Record.readInt();
1427 E->ArrayForm = Record.readInt();
1428 E->ArrayFormAsWritten = Record.readInt();
1429 E->UsualArrayDeleteWantsSize = Record.readInt();
1430 E->OperatorDelete = ReadDeclAs<FunctionDecl>();
1431 E->Argument = Record.readSubExpr();
1432 E->Loc = ReadSourceLocation();
1435 void ASTStmtReader::VisitCXXPseudoDestructorExpr(CXXPseudoDestructorExpr *E) {
1438 E->Base = Record.readSubExpr();
1439 E->IsArrow = Record.readInt();
1440 E->OperatorLoc = ReadSourceLocation();
1441 E->QualifierLoc = Record.readNestedNameSpecifierLoc();
1442 E->ScopeType = GetTypeSourceInfo();
1443 E->ColonColonLoc = ReadSourceLocation();
1444 E->TildeLoc = ReadSourceLocation();
1446 IdentifierInfo *II = Record.getIdentifierInfo();
1448 E->setDestroyedType(II, ReadSourceLocation());
1450 E->setDestroyedType(GetTypeSourceInfo());
1453 void ASTStmtReader::VisitExprWithCleanups(ExprWithCleanups *E) {
1456 unsigned NumObjects = Record.readInt();
1457 assert(NumObjects == E->getNumObjects());
1458 for (unsigned i = 0; i != NumObjects; ++i)
1459 E->getTrailingObjects<BlockDecl *>()[i] =
1460 ReadDeclAs<BlockDecl>();
1462 E->ExprWithCleanupsBits.CleanupsHaveSideEffects = Record.readInt();
1463 E->SubExpr = Record.readSubExpr();
1467 ASTStmtReader::VisitCXXDependentScopeMemberExpr(CXXDependentScopeMemberExpr *E){
1470 if (Record.readInt()) // HasTemplateKWAndArgsInfo
1471 ReadTemplateKWAndArgsInfo(
1472 *E->getTrailingObjects<ASTTemplateKWAndArgsInfo>(),
1473 E->getTrailingObjects<TemplateArgumentLoc>(),
1474 /*NumTemplateArgs=*/Record.readInt());
1476 E->Base = Record.readSubExpr();
1477 E->BaseType = Record.readType();
1478 E->IsArrow = Record.readInt();
1479 E->OperatorLoc = ReadSourceLocation();
1480 E->QualifierLoc = Record.readNestedNameSpecifierLoc();
1481 E->FirstQualifierFoundInScope = ReadDeclAs<NamedDecl>();
1482 ReadDeclarationNameInfo(E->MemberNameInfo);
1486 ASTStmtReader::VisitDependentScopeDeclRefExpr(DependentScopeDeclRefExpr *E) {
1489 if (Record.readInt()) // HasTemplateKWAndArgsInfo
1490 ReadTemplateKWAndArgsInfo(
1491 *E->getTrailingObjects<ASTTemplateKWAndArgsInfo>(),
1492 E->getTrailingObjects<TemplateArgumentLoc>(),
1493 /*NumTemplateArgs=*/Record.readInt());
1495 E->QualifierLoc = Record.readNestedNameSpecifierLoc();
1496 ReadDeclarationNameInfo(E->NameInfo);
1500 ASTStmtReader::VisitCXXUnresolvedConstructExpr(CXXUnresolvedConstructExpr *E) {
1502 assert(Record.peekInt() == E->arg_size() &&
1503 "Read wrong record during creation ?");
1505 for (unsigned I = 0, N = E->arg_size(); I != N; ++I)
1506 E->setArg(I, Record.readSubExpr());
1507 E->Type = GetTypeSourceInfo();
1508 E->setLParenLoc(ReadSourceLocation());
1509 E->setRParenLoc(ReadSourceLocation());
1512 void ASTStmtReader::VisitOverloadExpr(OverloadExpr *E) {
1515 if (Record.readInt()) // HasTemplateKWAndArgsInfo
1516 ReadTemplateKWAndArgsInfo(*E->getTrailingASTTemplateKWAndArgsInfo(),
1517 E->getTrailingTemplateArgumentLoc(),
1518 /*NumTemplateArgs=*/Record.readInt());
1520 unsigned NumDecls = Record.readInt();
1521 UnresolvedSet<8> Decls;
1522 for (unsigned i = 0; i != NumDecls; ++i) {
1523 NamedDecl *D = ReadDeclAs<NamedDecl>();
1524 AccessSpecifier AS = (AccessSpecifier)Record.readInt();
1525 Decls.addDecl(D, AS);
1527 E->initializeResults(Record.getContext(), Decls.begin(), Decls.end());
1529 ReadDeclarationNameInfo(E->NameInfo);
1530 E->QualifierLoc = Record.readNestedNameSpecifierLoc();
1533 void ASTStmtReader::VisitUnresolvedMemberExpr(UnresolvedMemberExpr *E) {
1534 VisitOverloadExpr(E);
1535 E->IsArrow = Record.readInt();
1536 E->HasUnresolvedUsing = Record.readInt();
1537 E->Base = Record.readSubExpr();
1538 E->BaseType = Record.readType();
1539 E->OperatorLoc = ReadSourceLocation();
1542 void ASTStmtReader::VisitUnresolvedLookupExpr(UnresolvedLookupExpr *E) {
1543 VisitOverloadExpr(E);
1544 E->RequiresADL = Record.readInt();
1545 E->Overloaded = Record.readInt();
1546 E->NamingClass = ReadDeclAs<CXXRecordDecl>();
1549 void ASTStmtReader::VisitTypeTraitExpr(TypeTraitExpr *E) {
1551 E->TypeTraitExprBits.NumArgs = Record.readInt();
1552 E->TypeTraitExprBits.Kind = Record.readInt();
1553 E->TypeTraitExprBits.Value = Record.readInt();
1554 SourceRange Range = ReadSourceRange();
1555 E->Loc = Range.getBegin();
1556 E->RParenLoc = Range.getEnd();
1558 TypeSourceInfo **Args = E->getTrailingObjects<TypeSourceInfo *>();
1559 for (unsigned I = 0, N = E->getNumArgs(); I != N; ++I)
1560 Args[I] = GetTypeSourceInfo();
1563 void ASTStmtReader::VisitArrayTypeTraitExpr(ArrayTypeTraitExpr *E) {
1565 E->ATT = (ArrayTypeTrait)Record.readInt();
1566 E->Value = (unsigned int)Record.readInt();
1567 SourceRange Range = ReadSourceRange();
1568 E->Loc = Range.getBegin();
1569 E->RParen = Range.getEnd();
1570 E->QueriedType = GetTypeSourceInfo();
1571 E->Dimension = Record.readSubExpr();
1574 void ASTStmtReader::VisitExpressionTraitExpr(ExpressionTraitExpr *E) {
1576 E->ET = (ExpressionTrait)Record.readInt();
1577 E->Value = (bool)Record.readInt();
1578 SourceRange Range = ReadSourceRange();
1579 E->QueriedExpression = Record.readSubExpr();
1580 E->Loc = Range.getBegin();
1581 E->RParen = Range.getEnd();
1584 void ASTStmtReader::VisitCXXNoexceptExpr(CXXNoexceptExpr *E) {
1586 E->Value = (bool)Record.readInt();
1587 E->Range = ReadSourceRange();
1588 E->Operand = Record.readSubExpr();
1591 void ASTStmtReader::VisitPackExpansionExpr(PackExpansionExpr *E) {
1593 E->EllipsisLoc = ReadSourceLocation();
1594 E->NumExpansions = Record.readInt();
1595 E->Pattern = Record.readSubExpr();
1598 void ASTStmtReader::VisitSizeOfPackExpr(SizeOfPackExpr *E) {
1600 unsigned NumPartialArgs = Record.readInt();
1601 E->OperatorLoc = ReadSourceLocation();
1602 E->PackLoc = ReadSourceLocation();
1603 E->RParenLoc = ReadSourceLocation();
1604 E->Pack = Record.readDeclAs<NamedDecl>();
1605 if (E->isPartiallySubstituted()) {
1606 assert(E->Length == NumPartialArgs);
1607 for (auto *I = E->getTrailingObjects<TemplateArgument>(),
1608 *E = I + NumPartialArgs;
1610 new (I) TemplateArgument(Record.readTemplateArgument());
1611 } else if (!E->isValueDependent()) {
1612 E->Length = Record.readInt();
1616 void ASTStmtReader::VisitSubstNonTypeTemplateParmExpr(
1617 SubstNonTypeTemplateParmExpr *E) {
1619 E->Param = ReadDeclAs<NonTypeTemplateParmDecl>();
1620 E->NameLoc = ReadSourceLocation();
1621 E->Replacement = Record.readSubExpr();
1624 void ASTStmtReader::VisitSubstNonTypeTemplateParmPackExpr(
1625 SubstNonTypeTemplateParmPackExpr *E) {
1627 E->Param = ReadDeclAs<NonTypeTemplateParmDecl>();
1628 TemplateArgument ArgPack = Record.readTemplateArgument();
1629 if (ArgPack.getKind() != TemplateArgument::Pack)
1632 E->Arguments = ArgPack.pack_begin();
1633 E->NumArguments = ArgPack.pack_size();
1634 E->NameLoc = ReadSourceLocation();
1637 void ASTStmtReader::VisitFunctionParmPackExpr(FunctionParmPackExpr *E) {
1639 E->NumParameters = Record.readInt();
1640 E->ParamPack = ReadDeclAs<ParmVarDecl>();
1641 E->NameLoc = ReadSourceLocation();
1642 ParmVarDecl **Parms = E->getTrailingObjects<ParmVarDecl *>();
1643 for (unsigned i = 0, n = E->NumParameters; i != n; ++i)
1644 Parms[i] = ReadDeclAs<ParmVarDecl>();
1647 void ASTStmtReader::VisitMaterializeTemporaryExpr(MaterializeTemporaryExpr *E) {
1649 E->State = Record.readSubExpr();
1650 auto VD = ReadDeclAs<ValueDecl>();
1651 unsigned ManglingNumber = Record.readInt();
1652 E->setExtendingDecl(VD, ManglingNumber);
1655 void ASTStmtReader::VisitCXXFoldExpr(CXXFoldExpr *E) {
1657 E->LParenLoc = ReadSourceLocation();
1658 E->EllipsisLoc = ReadSourceLocation();
1659 E->RParenLoc = ReadSourceLocation();
1660 E->SubExprs[0] = Record.readSubExpr();
1661 E->SubExprs[1] = Record.readSubExpr();
1662 E->Opcode = (BinaryOperatorKind)Record.readInt();
1665 void ASTStmtReader::VisitOpaqueValueExpr(OpaqueValueExpr *E) {
1667 E->SourceExpr = Record.readSubExpr();
1668 E->Loc = ReadSourceLocation();
1671 void ASTStmtReader::VisitTypoExpr(TypoExpr *E) {
1672 llvm_unreachable("Cannot read TypoExpr nodes");
1675 //===----------------------------------------------------------------------===//
1676 // Microsoft Expressions and Statements
1677 //===----------------------------------------------------------------------===//
1678 void ASTStmtReader::VisitMSPropertyRefExpr(MSPropertyRefExpr *E) {
1680 E->IsArrow = (Record.readInt() != 0);
1681 E->BaseExpr = Record.readSubExpr();
1682 E->QualifierLoc = Record.readNestedNameSpecifierLoc();
1683 E->MemberLoc = ReadSourceLocation();
1684 E->TheDecl = ReadDeclAs<MSPropertyDecl>();
1687 void ASTStmtReader::VisitMSPropertySubscriptExpr(MSPropertySubscriptExpr *E) {
1689 E->setBase(Record.readSubExpr());
1690 E->setIdx(Record.readSubExpr());
1691 E->setRBracketLoc(ReadSourceLocation());
1694 void ASTStmtReader::VisitCXXUuidofExpr(CXXUuidofExpr *E) {
1696 E->setSourceRange(ReadSourceRange());
1697 std::string UuidStr = ReadString();
1698 E->setUuidStr(StringRef(UuidStr).copy(Record.getContext()));
1699 if (E->isTypeOperand()) { // __uuidof(ComType)
1700 E->setTypeOperandSourceInfo(
1701 GetTypeSourceInfo());
1706 E->setExprOperand(Record.readSubExpr());
1709 void ASTStmtReader::VisitSEHLeaveStmt(SEHLeaveStmt *S) {
1711 S->setLeaveLoc(ReadSourceLocation());
1714 void ASTStmtReader::VisitSEHExceptStmt(SEHExceptStmt *S) {
1716 S->Loc = ReadSourceLocation();
1717 S->Children[SEHExceptStmt::FILTER_EXPR] = Record.readSubStmt();
1718 S->Children[SEHExceptStmt::BLOCK] = Record.readSubStmt();
1721 void ASTStmtReader::VisitSEHFinallyStmt(SEHFinallyStmt *S) {
1723 S->Loc = ReadSourceLocation();
1724 S->Block = Record.readSubStmt();
1727 void ASTStmtReader::VisitSEHTryStmt(SEHTryStmt *S) {
1729 S->IsCXXTry = Record.readInt();
1730 S->TryLoc = ReadSourceLocation();
1731 S->Children[SEHTryStmt::TRY] = Record.readSubStmt();
1732 S->Children[SEHTryStmt::HANDLER] = Record.readSubStmt();
1735 //===----------------------------------------------------------------------===//
1736 // CUDA Expressions and Statements
1737 //===----------------------------------------------------------------------===//
1739 void ASTStmtReader::VisitCUDAKernelCallExpr(CUDAKernelCallExpr *E) {
1741 E->setConfig(cast<CallExpr>(Record.readSubExpr()));
1744 //===----------------------------------------------------------------------===//
1745 // OpenCL Expressions and Statements.
1746 //===----------------------------------------------------------------------===//
1747 void ASTStmtReader::VisitAsTypeExpr(AsTypeExpr *E) {
1749 E->BuiltinLoc = ReadSourceLocation();
1750 E->RParenLoc = ReadSourceLocation();
1751 E->SrcExpr = Record.readSubExpr();
1754 //===----------------------------------------------------------------------===//
1756 //===----------------------------------------------------------------------===//
1759 class OMPClauseReader : public OMPClauseVisitor<OMPClauseReader> {
1760 ASTStmtReader *Reader;
1761 ASTContext &Context;
1763 OMPClauseReader(ASTStmtReader *R, ASTRecordReader &Record)
1764 : Reader(R), Context(Record.getContext()) {}
1765 #define OPENMP_CLAUSE(Name, Class) void Visit##Class(Class *C);
1766 #include "clang/Basic/OpenMPKinds.def"
1767 OMPClause *readClause();
1768 void VisitOMPClauseWithPreInit(OMPClauseWithPreInit *C);
1769 void VisitOMPClauseWithPostUpdate(OMPClauseWithPostUpdate *C);
1773 OMPClause *OMPClauseReader::readClause() {
1775 switch (Reader->Record.readInt()) {
1777 C = new (Context) OMPIfClause();
1780 C = new (Context) OMPFinalClause();
1782 case OMPC_num_threads:
1783 C = new (Context) OMPNumThreadsClause();
1786 C = new (Context) OMPSafelenClause();
1789 C = new (Context) OMPSimdlenClause();
1792 C = new (Context) OMPCollapseClause();
1795 C = new (Context) OMPDefaultClause();
1797 case OMPC_proc_bind:
1798 C = new (Context) OMPProcBindClause();
1801 C = new (Context) OMPScheduleClause();
1804 C = new (Context) OMPOrderedClause();
1807 C = new (Context) OMPNowaitClause();
1810 C = new (Context) OMPUntiedClause();
1812 case OMPC_mergeable:
1813 C = new (Context) OMPMergeableClause();
1816 C = new (Context) OMPReadClause();
1819 C = new (Context) OMPWriteClause();
1822 C = new (Context) OMPUpdateClause();
1825 C = new (Context) OMPCaptureClause();
1828 C = new (Context) OMPSeqCstClause();
1831 C = new (Context) OMPThreadsClause();
1834 C = new (Context) OMPSIMDClause();
1837 C = new (Context) OMPNogroupClause();
1840 C = OMPPrivateClause::CreateEmpty(Context, Reader->Record.readInt());
1842 case OMPC_firstprivate:
1843 C = OMPFirstprivateClause::CreateEmpty(Context, Reader->Record.readInt());
1845 case OMPC_lastprivate:
1846 C = OMPLastprivateClause::CreateEmpty(Context, Reader->Record.readInt());
1849 C = OMPSharedClause::CreateEmpty(Context, Reader->Record.readInt());
1851 case OMPC_reduction:
1852 C = OMPReductionClause::CreateEmpty(Context, Reader->Record.readInt());
1854 case OMPC_task_reduction:
1855 C = OMPTaskReductionClause::CreateEmpty(Context, Reader->Record.readInt());
1857 case OMPC_in_reduction:
1858 C = OMPInReductionClause::CreateEmpty(Context, Reader->Record.readInt());
1861 C = OMPLinearClause::CreateEmpty(Context, Reader->Record.readInt());
1864 C = OMPAlignedClause::CreateEmpty(Context, Reader->Record.readInt());
1867 C = OMPCopyinClause::CreateEmpty(Context, Reader->Record.readInt());
1869 case OMPC_copyprivate:
1870 C = OMPCopyprivateClause::CreateEmpty(Context, Reader->Record.readInt());
1873 C = OMPFlushClause::CreateEmpty(Context, Reader->Record.readInt());
1876 C = OMPDependClause::CreateEmpty(Context, Reader->Record.readInt());
1879 C = new (Context) OMPDeviceClause();
1882 unsigned NumVars = Reader->Record.readInt();
1883 unsigned NumDeclarations = Reader->Record.readInt();
1884 unsigned NumLists = Reader->Record.readInt();
1885 unsigned NumComponents = Reader->Record.readInt();
1886 C = OMPMapClause::CreateEmpty(Context, NumVars, NumDeclarations, NumLists,
1890 case OMPC_num_teams:
1891 C = new (Context) OMPNumTeamsClause();
1893 case OMPC_thread_limit:
1894 C = new (Context) OMPThreadLimitClause();
1897 C = new (Context) OMPPriorityClause();
1899 case OMPC_grainsize:
1900 C = new (Context) OMPGrainsizeClause();
1902 case OMPC_num_tasks:
1903 C = new (Context) OMPNumTasksClause();
1906 C = new (Context) OMPHintClause();
1908 case OMPC_dist_schedule:
1909 C = new (Context) OMPDistScheduleClause();
1911 case OMPC_defaultmap:
1912 C = new (Context) OMPDefaultmapClause();
1915 unsigned NumVars = Reader->Record.readInt();
1916 unsigned NumDeclarations = Reader->Record.readInt();
1917 unsigned NumLists = Reader->Record.readInt();
1918 unsigned NumComponents = Reader->Record.readInt();
1919 C = OMPToClause::CreateEmpty(Context, NumVars, NumDeclarations, NumLists,
1924 unsigned NumVars = Reader->Record.readInt();
1925 unsigned NumDeclarations = Reader->Record.readInt();
1926 unsigned NumLists = Reader->Record.readInt();
1927 unsigned NumComponents = Reader->Record.readInt();
1928 C = OMPFromClause::CreateEmpty(Context, NumVars, NumDeclarations, NumLists,
1932 case OMPC_use_device_ptr: {
1933 unsigned NumVars = Reader->Record.readInt();
1934 unsigned NumDeclarations = Reader->Record.readInt();
1935 unsigned NumLists = Reader->Record.readInt();
1936 unsigned NumComponents = Reader->Record.readInt();
1937 C = OMPUseDevicePtrClause::CreateEmpty(Context, NumVars, NumDeclarations,
1938 NumLists, NumComponents);
1941 case OMPC_is_device_ptr: {
1942 unsigned NumVars = Reader->Record.readInt();
1943 unsigned NumDeclarations = Reader->Record.readInt();
1944 unsigned NumLists = Reader->Record.readInt();
1945 unsigned NumComponents = Reader->Record.readInt();
1946 C = OMPIsDevicePtrClause::CreateEmpty(Context, NumVars, NumDeclarations,
1947 NumLists, NumComponents);
1952 C->setLocStart(Reader->ReadSourceLocation());
1953 C->setLocEnd(Reader->ReadSourceLocation());
1958 void OMPClauseReader::VisitOMPClauseWithPreInit(OMPClauseWithPreInit *C) {
1959 C->setPreInitStmt(Reader->Record.readSubStmt(),
1960 static_cast<OpenMPDirectiveKind>(Reader->Record.readInt()));
1963 void OMPClauseReader::VisitOMPClauseWithPostUpdate(OMPClauseWithPostUpdate *C) {
1964 VisitOMPClauseWithPreInit(C);
1965 C->setPostUpdateExpr(Reader->Record.readSubExpr());
1968 void OMPClauseReader::VisitOMPIfClause(OMPIfClause *C) {
1969 VisitOMPClauseWithPreInit(C);
1970 C->setNameModifier(static_cast<OpenMPDirectiveKind>(Reader->Record.readInt()));
1971 C->setNameModifierLoc(Reader->ReadSourceLocation());
1972 C->setColonLoc(Reader->ReadSourceLocation());
1973 C->setCondition(Reader->Record.readSubExpr());
1974 C->setLParenLoc(Reader->ReadSourceLocation());
1977 void OMPClauseReader::VisitOMPFinalClause(OMPFinalClause *C) {
1978 C->setCondition(Reader->Record.readSubExpr());
1979 C->setLParenLoc(Reader->ReadSourceLocation());
1982 void OMPClauseReader::VisitOMPNumThreadsClause(OMPNumThreadsClause *C) {
1983 VisitOMPClauseWithPreInit(C);
1984 C->setNumThreads(Reader->Record.readSubExpr());
1985 C->setLParenLoc(Reader->ReadSourceLocation());
1988 void OMPClauseReader::VisitOMPSafelenClause(OMPSafelenClause *C) {
1989 C->setSafelen(Reader->Record.readSubExpr());
1990 C->setLParenLoc(Reader->ReadSourceLocation());
1993 void OMPClauseReader::VisitOMPSimdlenClause(OMPSimdlenClause *C) {
1994 C->setSimdlen(Reader->Record.readSubExpr());
1995 C->setLParenLoc(Reader->ReadSourceLocation());
1998 void OMPClauseReader::VisitOMPCollapseClause(OMPCollapseClause *C) {
1999 C->setNumForLoops(Reader->Record.readSubExpr());
2000 C->setLParenLoc(Reader->ReadSourceLocation());
2003 void OMPClauseReader::VisitOMPDefaultClause(OMPDefaultClause *C) {
2005 static_cast<OpenMPDefaultClauseKind>(Reader->Record.readInt()));
2006 C->setLParenLoc(Reader->ReadSourceLocation());
2007 C->setDefaultKindKwLoc(Reader->ReadSourceLocation());
2010 void OMPClauseReader::VisitOMPProcBindClause(OMPProcBindClause *C) {
2012 static_cast<OpenMPProcBindClauseKind>(Reader->Record.readInt()));
2013 C->setLParenLoc(Reader->ReadSourceLocation());
2014 C->setProcBindKindKwLoc(Reader->ReadSourceLocation());
2017 void OMPClauseReader::VisitOMPScheduleClause(OMPScheduleClause *C) {
2018 VisitOMPClauseWithPreInit(C);
2020 static_cast<OpenMPScheduleClauseKind>(Reader->Record.readInt()));
2021 C->setFirstScheduleModifier(
2022 static_cast<OpenMPScheduleClauseModifier>(Reader->Record.readInt()));
2023 C->setSecondScheduleModifier(
2024 static_cast<OpenMPScheduleClauseModifier>(Reader->Record.readInt()));
2025 C->setChunkSize(Reader->Record.readSubExpr());
2026 C->setLParenLoc(Reader->ReadSourceLocation());
2027 C->setFirstScheduleModifierLoc(Reader->ReadSourceLocation());
2028 C->setSecondScheduleModifierLoc(Reader->ReadSourceLocation());
2029 C->setScheduleKindLoc(Reader->ReadSourceLocation());
2030 C->setCommaLoc(Reader->ReadSourceLocation());
2033 void OMPClauseReader::VisitOMPOrderedClause(OMPOrderedClause *C) {
2034 C->setNumForLoops(Reader->Record.readSubExpr());
2035 C->setLParenLoc(Reader->ReadSourceLocation());
2038 void OMPClauseReader::VisitOMPNowaitClause(OMPNowaitClause *) {}
2040 void OMPClauseReader::VisitOMPUntiedClause(OMPUntiedClause *) {}
2042 void OMPClauseReader::VisitOMPMergeableClause(OMPMergeableClause *) {}
2044 void OMPClauseReader::VisitOMPReadClause(OMPReadClause *) {}
2046 void OMPClauseReader::VisitOMPWriteClause(OMPWriteClause *) {}
2048 void OMPClauseReader::VisitOMPUpdateClause(OMPUpdateClause *) {}
2050 void OMPClauseReader::VisitOMPCaptureClause(OMPCaptureClause *) {}
2052 void OMPClauseReader::VisitOMPSeqCstClause(OMPSeqCstClause *) {}
2054 void OMPClauseReader::VisitOMPThreadsClause(OMPThreadsClause *) {}
2056 void OMPClauseReader::VisitOMPSIMDClause(OMPSIMDClause *) {}
2058 void OMPClauseReader::VisitOMPNogroupClause(OMPNogroupClause *) {}
2060 void OMPClauseReader::VisitOMPPrivateClause(OMPPrivateClause *C) {
2061 C->setLParenLoc(Reader->ReadSourceLocation());
2062 unsigned NumVars = C->varlist_size();
2063 SmallVector<Expr *, 16> Vars;
2064 Vars.reserve(NumVars);
2065 for (unsigned i = 0; i != NumVars; ++i)
2066 Vars.push_back(Reader->Record.readSubExpr());
2067 C->setVarRefs(Vars);
2069 for (unsigned i = 0; i != NumVars; ++i)
2070 Vars.push_back(Reader->Record.readSubExpr());
2071 C->setPrivateCopies(Vars);
2074 void OMPClauseReader::VisitOMPFirstprivateClause(OMPFirstprivateClause *C) {
2075 VisitOMPClauseWithPreInit(C);
2076 C->setLParenLoc(Reader->ReadSourceLocation());
2077 unsigned NumVars = C->varlist_size();
2078 SmallVector<Expr *, 16> Vars;
2079 Vars.reserve(NumVars);
2080 for (unsigned i = 0; i != NumVars; ++i)
2081 Vars.push_back(Reader->Record.readSubExpr());
2082 C->setVarRefs(Vars);
2084 for (unsigned i = 0; i != NumVars; ++i)
2085 Vars.push_back(Reader->Record.readSubExpr());
2086 C->setPrivateCopies(Vars);
2088 for (unsigned i = 0; i != NumVars; ++i)
2089 Vars.push_back(Reader->Record.readSubExpr());
2093 void OMPClauseReader::VisitOMPLastprivateClause(OMPLastprivateClause *C) {
2094 VisitOMPClauseWithPostUpdate(C);
2095 C->setLParenLoc(Reader->ReadSourceLocation());
2096 unsigned NumVars = C->varlist_size();
2097 SmallVector<Expr *, 16> Vars;
2098 Vars.reserve(NumVars);
2099 for (unsigned i = 0; i != NumVars; ++i)
2100 Vars.push_back(Reader->Record.readSubExpr());
2101 C->setVarRefs(Vars);
2103 for (unsigned i = 0; i != NumVars; ++i)
2104 Vars.push_back(Reader->Record.readSubExpr());
2105 C->setPrivateCopies(Vars);
2107 for (unsigned i = 0; i != NumVars; ++i)
2108 Vars.push_back(Reader->Record.readSubExpr());
2109 C->setSourceExprs(Vars);
2111 for (unsigned i = 0; i != NumVars; ++i)
2112 Vars.push_back(Reader->Record.readSubExpr());
2113 C->setDestinationExprs(Vars);
2115 for (unsigned i = 0; i != NumVars; ++i)
2116 Vars.push_back(Reader->Record.readSubExpr());
2117 C->setAssignmentOps(Vars);
2120 void OMPClauseReader::VisitOMPSharedClause(OMPSharedClause *C) {
2121 C->setLParenLoc(Reader->ReadSourceLocation());
2122 unsigned NumVars = C->varlist_size();
2123 SmallVector<Expr *, 16> Vars;
2124 Vars.reserve(NumVars);
2125 for (unsigned i = 0; i != NumVars; ++i)
2126 Vars.push_back(Reader->Record.readSubExpr());
2127 C->setVarRefs(Vars);
2130 void OMPClauseReader::VisitOMPReductionClause(OMPReductionClause *C) {
2131 VisitOMPClauseWithPostUpdate(C);
2132 C->setLParenLoc(Reader->ReadSourceLocation());
2133 C->setColonLoc(Reader->ReadSourceLocation());
2134 NestedNameSpecifierLoc NNSL = Reader->Record.readNestedNameSpecifierLoc();
2135 DeclarationNameInfo DNI;
2136 Reader->ReadDeclarationNameInfo(DNI);
2137 C->setQualifierLoc(NNSL);
2138 C->setNameInfo(DNI);
2140 unsigned NumVars = C->varlist_size();
2141 SmallVector<Expr *, 16> Vars;
2142 Vars.reserve(NumVars);
2143 for (unsigned i = 0; i != NumVars; ++i)
2144 Vars.push_back(Reader->Record.readSubExpr());
2145 C->setVarRefs(Vars);
2147 for (unsigned i = 0; i != NumVars; ++i)
2148 Vars.push_back(Reader->Record.readSubExpr());
2149 C->setPrivates(Vars);
2151 for (unsigned i = 0; i != NumVars; ++i)
2152 Vars.push_back(Reader->Record.readSubExpr());
2153 C->setLHSExprs(Vars);
2155 for (unsigned i = 0; i != NumVars; ++i)
2156 Vars.push_back(Reader->Record.readSubExpr());
2157 C->setRHSExprs(Vars);
2159 for (unsigned i = 0; i != NumVars; ++i)
2160 Vars.push_back(Reader->Record.readSubExpr());
2161 C->setReductionOps(Vars);
2164 void OMPClauseReader::VisitOMPTaskReductionClause(OMPTaskReductionClause *C) {
2165 VisitOMPClauseWithPostUpdate(C);
2166 C->setLParenLoc(Reader->ReadSourceLocation());
2167 C->setColonLoc(Reader->ReadSourceLocation());
2168 NestedNameSpecifierLoc NNSL = Reader->Record.readNestedNameSpecifierLoc();
2169 DeclarationNameInfo DNI;
2170 Reader->ReadDeclarationNameInfo(DNI);
2171 C->setQualifierLoc(NNSL);
2172 C->setNameInfo(DNI);
2174 unsigned NumVars = C->varlist_size();
2175 SmallVector<Expr *, 16> Vars;
2176 Vars.reserve(NumVars);
2177 for (unsigned I = 0; I != NumVars; ++I)
2178 Vars.push_back(Reader->Record.readSubExpr());
2179 C->setVarRefs(Vars);
2181 for (unsigned I = 0; I != NumVars; ++I)
2182 Vars.push_back(Reader->Record.readSubExpr());
2183 C->setPrivates(Vars);
2185 for (unsigned I = 0; I != NumVars; ++I)
2186 Vars.push_back(Reader->Record.readSubExpr());
2187 C->setLHSExprs(Vars);
2189 for (unsigned I = 0; I != NumVars; ++I)
2190 Vars.push_back(Reader->Record.readSubExpr());
2191 C->setRHSExprs(Vars);
2193 for (unsigned I = 0; I != NumVars; ++I)
2194 Vars.push_back(Reader->Record.readSubExpr());
2195 C->setReductionOps(Vars);
2198 void OMPClauseReader::VisitOMPInReductionClause(OMPInReductionClause *C) {
2199 VisitOMPClauseWithPostUpdate(C);
2200 C->setLParenLoc(Reader->ReadSourceLocation());
2201 C->setColonLoc(Reader->ReadSourceLocation());
2202 NestedNameSpecifierLoc NNSL = Reader->Record.readNestedNameSpecifierLoc();
2203 DeclarationNameInfo DNI;
2204 Reader->ReadDeclarationNameInfo(DNI);
2205 C->setQualifierLoc(NNSL);
2206 C->setNameInfo(DNI);
2208 unsigned NumVars = C->varlist_size();
2209 SmallVector<Expr *, 16> Vars;
2210 Vars.reserve(NumVars);
2211 for (unsigned I = 0; I != NumVars; ++I)
2212 Vars.push_back(Reader->Record.readSubExpr());
2213 C->setVarRefs(Vars);
2215 for (unsigned I = 0; I != NumVars; ++I)
2216 Vars.push_back(Reader->Record.readSubExpr());
2217 C->setPrivates(Vars);
2219 for (unsigned I = 0; I != NumVars; ++I)
2220 Vars.push_back(Reader->Record.readSubExpr());
2221 C->setLHSExprs(Vars);
2223 for (unsigned I = 0; I != NumVars; ++I)
2224 Vars.push_back(Reader->Record.readSubExpr());
2225 C->setRHSExprs(Vars);
2227 for (unsigned I = 0; I != NumVars; ++I)
2228 Vars.push_back(Reader->Record.readSubExpr());
2229 C->setReductionOps(Vars);
2231 for (unsigned I = 0; I != NumVars; ++I)
2232 Vars.push_back(Reader->Record.readSubExpr());
2233 C->setTaskgroupDescriptors(Vars);
2236 void OMPClauseReader::VisitOMPLinearClause(OMPLinearClause *C) {
2237 VisitOMPClauseWithPostUpdate(C);
2238 C->setLParenLoc(Reader->ReadSourceLocation());
2239 C->setColonLoc(Reader->ReadSourceLocation());
2240 C->setModifier(static_cast<OpenMPLinearClauseKind>(Reader->Record.readInt()));
2241 C->setModifierLoc(Reader->ReadSourceLocation());
2242 unsigned NumVars = C->varlist_size();
2243 SmallVector<Expr *, 16> Vars;
2244 Vars.reserve(NumVars);
2245 for (unsigned i = 0; i != NumVars; ++i)
2246 Vars.push_back(Reader->Record.readSubExpr());
2247 C->setVarRefs(Vars);
2249 for (unsigned i = 0; i != NumVars; ++i)
2250 Vars.push_back(Reader->Record.readSubExpr());
2251 C->setPrivates(Vars);
2253 for (unsigned i = 0; i != NumVars; ++i)
2254 Vars.push_back(Reader->Record.readSubExpr());
2257 for (unsigned i = 0; i != NumVars; ++i)
2258 Vars.push_back(Reader->Record.readSubExpr());
2259 C->setUpdates(Vars);
2261 for (unsigned i = 0; i != NumVars; ++i)
2262 Vars.push_back(Reader->Record.readSubExpr());
2264 C->setStep(Reader->Record.readSubExpr());
2265 C->setCalcStep(Reader->Record.readSubExpr());
2268 void OMPClauseReader::VisitOMPAlignedClause(OMPAlignedClause *C) {
2269 C->setLParenLoc(Reader->ReadSourceLocation());
2270 C->setColonLoc(Reader->ReadSourceLocation());
2271 unsigned NumVars = C->varlist_size();
2272 SmallVector<Expr *, 16> Vars;
2273 Vars.reserve(NumVars);
2274 for (unsigned i = 0; i != NumVars; ++i)
2275 Vars.push_back(Reader->Record.readSubExpr());
2276 C->setVarRefs(Vars);
2277 C->setAlignment(Reader->Record.readSubExpr());
2280 void OMPClauseReader::VisitOMPCopyinClause(OMPCopyinClause *C) {
2281 C->setLParenLoc(Reader->ReadSourceLocation());
2282 unsigned NumVars = C->varlist_size();
2283 SmallVector<Expr *, 16> Exprs;
2284 Exprs.reserve(NumVars);
2285 for (unsigned i = 0; i != NumVars; ++i)
2286 Exprs.push_back(Reader->Record.readSubExpr());
2287 C->setVarRefs(Exprs);
2289 for (unsigned i = 0; i != NumVars; ++i)
2290 Exprs.push_back(Reader->Record.readSubExpr());
2291 C->setSourceExprs(Exprs);
2293 for (unsigned i = 0; i != NumVars; ++i)
2294 Exprs.push_back(Reader->Record.readSubExpr());
2295 C->setDestinationExprs(Exprs);
2297 for (unsigned i = 0; i != NumVars; ++i)
2298 Exprs.push_back(Reader->Record.readSubExpr());
2299 C->setAssignmentOps(Exprs);
2302 void OMPClauseReader::VisitOMPCopyprivateClause(OMPCopyprivateClause *C) {
2303 C->setLParenLoc(Reader->ReadSourceLocation());
2304 unsigned NumVars = C->varlist_size();
2305 SmallVector<Expr *, 16> Exprs;
2306 Exprs.reserve(NumVars);
2307 for (unsigned i = 0; i != NumVars; ++i)
2308 Exprs.push_back(Reader->Record.readSubExpr());
2309 C->setVarRefs(Exprs);
2311 for (unsigned i = 0; i != NumVars; ++i)
2312 Exprs.push_back(Reader->Record.readSubExpr());
2313 C->setSourceExprs(Exprs);
2315 for (unsigned i = 0; i != NumVars; ++i)
2316 Exprs.push_back(Reader->Record.readSubExpr());
2317 C->setDestinationExprs(Exprs);
2319 for (unsigned i = 0; i != NumVars; ++i)
2320 Exprs.push_back(Reader->Record.readSubExpr());
2321 C->setAssignmentOps(Exprs);
2324 void OMPClauseReader::VisitOMPFlushClause(OMPFlushClause *C) {
2325 C->setLParenLoc(Reader->ReadSourceLocation());
2326 unsigned NumVars = C->varlist_size();
2327 SmallVector<Expr *, 16> Vars;
2328 Vars.reserve(NumVars);
2329 for (unsigned i = 0; i != NumVars; ++i)
2330 Vars.push_back(Reader->Record.readSubExpr());
2331 C->setVarRefs(Vars);
2334 void OMPClauseReader::VisitOMPDependClause(OMPDependClause *C) {
2335 C->setLParenLoc(Reader->ReadSourceLocation());
2336 C->setDependencyKind(
2337 static_cast<OpenMPDependClauseKind>(Reader->Record.readInt()));
2338 C->setDependencyLoc(Reader->ReadSourceLocation());
2339 C->setColonLoc(Reader->ReadSourceLocation());
2340 unsigned NumVars = C->varlist_size();
2341 SmallVector<Expr *, 16> Vars;
2342 Vars.reserve(NumVars);
2343 for (unsigned i = 0; i != NumVars; ++i)
2344 Vars.push_back(Reader->Record.readSubExpr());
2345 C->setVarRefs(Vars);
2346 C->setCounterValue(Reader->Record.readSubExpr());
2349 void OMPClauseReader::VisitOMPDeviceClause(OMPDeviceClause *C) {
2350 VisitOMPClauseWithPreInit(C);
2351 C->setDevice(Reader->Record.readSubExpr());
2352 C->setLParenLoc(Reader->ReadSourceLocation());
2355 void OMPClauseReader::VisitOMPMapClause(OMPMapClause *C) {
2356 C->setLParenLoc(Reader->ReadSourceLocation());
2357 C->setMapTypeModifier(
2358 static_cast<OpenMPMapClauseKind>(Reader->Record.readInt()));
2360 static_cast<OpenMPMapClauseKind>(Reader->Record.readInt()));
2361 C->setMapLoc(Reader->ReadSourceLocation());
2362 C->setColonLoc(Reader->ReadSourceLocation());
2363 auto NumVars = C->varlist_size();
2364 auto UniqueDecls = C->getUniqueDeclarationsNum();
2365 auto TotalLists = C->getTotalComponentListNum();
2366 auto TotalComponents = C->getTotalComponentsNum();
2368 SmallVector<Expr *, 16> Vars;
2369 Vars.reserve(NumVars);
2370 for (unsigned i = 0; i != NumVars; ++i)
2371 Vars.push_back(Reader->Record.readSubExpr());
2372 C->setVarRefs(Vars);
2374 SmallVector<ValueDecl *, 16> Decls;
2375 Decls.reserve(UniqueDecls);
2376 for (unsigned i = 0; i < UniqueDecls; ++i)
2377 Decls.push_back(Reader->Record.readDeclAs<ValueDecl>());
2378 C->setUniqueDecls(Decls);
2380 SmallVector<unsigned, 16> ListsPerDecl;
2381 ListsPerDecl.reserve(UniqueDecls);
2382 for (unsigned i = 0; i < UniqueDecls; ++i)
2383 ListsPerDecl.push_back(Reader->Record.readInt());
2384 C->setDeclNumLists(ListsPerDecl);
2386 SmallVector<unsigned, 32> ListSizes;
2387 ListSizes.reserve(TotalLists);
2388 for (unsigned i = 0; i < TotalLists; ++i)
2389 ListSizes.push_back(Reader->Record.readInt());
2390 C->setComponentListSizes(ListSizes);
2392 SmallVector<OMPClauseMappableExprCommon::MappableComponent, 32> Components;
2393 Components.reserve(TotalComponents);
2394 for (unsigned i = 0; i < TotalComponents; ++i) {
2395 Expr *AssociatedExpr = Reader->Record.readSubExpr();
2396 ValueDecl *AssociatedDecl = Reader->Record.readDeclAs<ValueDecl>();
2397 Components.push_back(OMPClauseMappableExprCommon::MappableComponent(
2398 AssociatedExpr, AssociatedDecl));
2400 C->setComponents(Components, ListSizes);
2403 void OMPClauseReader::VisitOMPNumTeamsClause(OMPNumTeamsClause *C) {
2404 VisitOMPClauseWithPreInit(C);
2405 C->setNumTeams(Reader->Record.readSubExpr());
2406 C->setLParenLoc(Reader->ReadSourceLocation());
2409 void OMPClauseReader::VisitOMPThreadLimitClause(OMPThreadLimitClause *C) {
2410 VisitOMPClauseWithPreInit(C);
2411 C->setThreadLimit(Reader->Record.readSubExpr());
2412 C->setLParenLoc(Reader->ReadSourceLocation());
2415 void OMPClauseReader::VisitOMPPriorityClause(OMPPriorityClause *C) {
2416 C->setPriority(Reader->Record.readSubExpr());
2417 C->setLParenLoc(Reader->ReadSourceLocation());
2420 void OMPClauseReader::VisitOMPGrainsizeClause(OMPGrainsizeClause *C) {
2421 C->setGrainsize(Reader->Record.readSubExpr());
2422 C->setLParenLoc(Reader->ReadSourceLocation());
2425 void OMPClauseReader::VisitOMPNumTasksClause(OMPNumTasksClause *C) {
2426 C->setNumTasks(Reader->Record.readSubExpr());
2427 C->setLParenLoc(Reader->ReadSourceLocation());
2430 void OMPClauseReader::VisitOMPHintClause(OMPHintClause *C) {
2431 C->setHint(Reader->Record.readSubExpr());
2432 C->setLParenLoc(Reader->ReadSourceLocation());
2435 void OMPClauseReader::VisitOMPDistScheduleClause(OMPDistScheduleClause *C) {
2436 VisitOMPClauseWithPreInit(C);
2437 C->setDistScheduleKind(
2438 static_cast<OpenMPDistScheduleClauseKind>(Reader->Record.readInt()));
2439 C->setChunkSize(Reader->Record.readSubExpr());
2440 C->setLParenLoc(Reader->ReadSourceLocation());
2441 C->setDistScheduleKindLoc(Reader->ReadSourceLocation());
2442 C->setCommaLoc(Reader->ReadSourceLocation());
2445 void OMPClauseReader::VisitOMPDefaultmapClause(OMPDefaultmapClause *C) {
2446 C->setDefaultmapKind(
2447 static_cast<OpenMPDefaultmapClauseKind>(Reader->Record.readInt()));
2448 C->setDefaultmapModifier(
2449 static_cast<OpenMPDefaultmapClauseModifier>(Reader->Record.readInt()));
2450 C->setLParenLoc(Reader->ReadSourceLocation());
2451 C->setDefaultmapModifierLoc(Reader->ReadSourceLocation());
2452 C->setDefaultmapKindLoc(Reader->ReadSourceLocation());
2455 void OMPClauseReader::VisitOMPToClause(OMPToClause *C) {
2456 C->setLParenLoc(Reader->ReadSourceLocation());
2457 auto NumVars = C->varlist_size();
2458 auto UniqueDecls = C->getUniqueDeclarationsNum();
2459 auto TotalLists = C->getTotalComponentListNum();
2460 auto TotalComponents = C->getTotalComponentsNum();
2462 SmallVector<Expr *, 16> Vars;
2463 Vars.reserve(NumVars);
2464 for (unsigned i = 0; i != NumVars; ++i)
2465 Vars.push_back(Reader->Record.readSubExpr());
2466 C->setVarRefs(Vars);
2468 SmallVector<ValueDecl *, 16> Decls;
2469 Decls.reserve(UniqueDecls);
2470 for (unsigned i = 0; i < UniqueDecls; ++i)
2471 Decls.push_back(Reader->Record.readDeclAs<ValueDecl>());
2472 C->setUniqueDecls(Decls);
2474 SmallVector<unsigned, 16> ListsPerDecl;
2475 ListsPerDecl.reserve(UniqueDecls);
2476 for (unsigned i = 0; i < UniqueDecls; ++i)
2477 ListsPerDecl.push_back(Reader->Record.readInt());
2478 C->setDeclNumLists(ListsPerDecl);
2480 SmallVector<unsigned, 32> ListSizes;
2481 ListSizes.reserve(TotalLists);
2482 for (unsigned i = 0; i < TotalLists; ++i)
2483 ListSizes.push_back(Reader->Record.readInt());
2484 C->setComponentListSizes(ListSizes);
2486 SmallVector<OMPClauseMappableExprCommon::MappableComponent, 32> Components;
2487 Components.reserve(TotalComponents);
2488 for (unsigned i = 0; i < TotalComponents; ++i) {
2489 Expr *AssociatedExpr = Reader->Record.readSubExpr();
2490 ValueDecl *AssociatedDecl = Reader->Record.readDeclAs<ValueDecl>();
2491 Components.push_back(OMPClauseMappableExprCommon::MappableComponent(
2492 AssociatedExpr, AssociatedDecl));
2494 C->setComponents(Components, ListSizes);
2497 void OMPClauseReader::VisitOMPFromClause(OMPFromClause *C) {
2498 C->setLParenLoc(Reader->ReadSourceLocation());
2499 auto NumVars = C->varlist_size();
2500 auto UniqueDecls = C->getUniqueDeclarationsNum();
2501 auto TotalLists = C->getTotalComponentListNum();
2502 auto TotalComponents = C->getTotalComponentsNum();
2504 SmallVector<Expr *, 16> Vars;
2505 Vars.reserve(NumVars);
2506 for (unsigned i = 0; i != NumVars; ++i)
2507 Vars.push_back(Reader->Record.readSubExpr());
2508 C->setVarRefs(Vars);
2510 SmallVector<ValueDecl *, 16> Decls;
2511 Decls.reserve(UniqueDecls);
2512 for (unsigned i = 0; i < UniqueDecls; ++i)
2513 Decls.push_back(Reader->Record.readDeclAs<ValueDecl>());
2514 C->setUniqueDecls(Decls);
2516 SmallVector<unsigned, 16> ListsPerDecl;
2517 ListsPerDecl.reserve(UniqueDecls);
2518 for (unsigned i = 0; i < UniqueDecls; ++i)
2519 ListsPerDecl.push_back(Reader->Record.readInt());
2520 C->setDeclNumLists(ListsPerDecl);
2522 SmallVector<unsigned, 32> ListSizes;
2523 ListSizes.reserve(TotalLists);
2524 for (unsigned i = 0; i < TotalLists; ++i)
2525 ListSizes.push_back(Reader->Record.readInt());
2526 C->setComponentListSizes(ListSizes);
2528 SmallVector<OMPClauseMappableExprCommon::MappableComponent, 32> Components;
2529 Components.reserve(TotalComponents);
2530 for (unsigned i = 0; i < TotalComponents; ++i) {
2531 Expr *AssociatedExpr = Reader->Record.readSubExpr();
2532 ValueDecl *AssociatedDecl = Reader->Record.readDeclAs<ValueDecl>();
2533 Components.push_back(OMPClauseMappableExprCommon::MappableComponent(
2534 AssociatedExpr, AssociatedDecl));
2536 C->setComponents(Components, ListSizes);
2539 void OMPClauseReader::VisitOMPUseDevicePtrClause(OMPUseDevicePtrClause *C) {
2540 C->setLParenLoc(Reader->ReadSourceLocation());
2541 auto NumVars = C->varlist_size();
2542 auto UniqueDecls = C->getUniqueDeclarationsNum();
2543 auto TotalLists = C->getTotalComponentListNum();
2544 auto TotalComponents = C->getTotalComponentsNum();
2546 SmallVector<Expr *, 16> Vars;
2547 Vars.reserve(NumVars);
2548 for (unsigned i = 0; i != NumVars; ++i)
2549 Vars.push_back(Reader->Record.readSubExpr());
2550 C->setVarRefs(Vars);
2552 for (unsigned i = 0; i != NumVars; ++i)
2553 Vars.push_back(Reader->Record.readSubExpr());
2554 C->setPrivateCopies(Vars);
2556 for (unsigned i = 0; i != NumVars; ++i)
2557 Vars.push_back(Reader->Record.readSubExpr());
2560 SmallVector<ValueDecl *, 16> Decls;
2561 Decls.reserve(UniqueDecls);
2562 for (unsigned i = 0; i < UniqueDecls; ++i)
2563 Decls.push_back(Reader->Record.readDeclAs<ValueDecl>());
2564 C->setUniqueDecls(Decls);
2566 SmallVector<unsigned, 16> ListsPerDecl;
2567 ListsPerDecl.reserve(UniqueDecls);
2568 for (unsigned i = 0; i < UniqueDecls; ++i)
2569 ListsPerDecl.push_back(Reader->Record.readInt());
2570 C->setDeclNumLists(ListsPerDecl);
2572 SmallVector<unsigned, 32> ListSizes;
2573 ListSizes.reserve(TotalLists);
2574 for (unsigned i = 0; i < TotalLists; ++i)
2575 ListSizes.push_back(Reader->Record.readInt());
2576 C->setComponentListSizes(ListSizes);
2578 SmallVector<OMPClauseMappableExprCommon::MappableComponent, 32> Components;
2579 Components.reserve(TotalComponents);
2580 for (unsigned i = 0; i < TotalComponents; ++i) {
2581 Expr *AssociatedExpr = Reader->Record.readSubExpr();
2582 ValueDecl *AssociatedDecl = Reader->Record.readDeclAs<ValueDecl>();
2583 Components.push_back(OMPClauseMappableExprCommon::MappableComponent(
2584 AssociatedExpr, AssociatedDecl));
2586 C->setComponents(Components, ListSizes);
2589 void OMPClauseReader::VisitOMPIsDevicePtrClause(OMPIsDevicePtrClause *C) {
2590 C->setLParenLoc(Reader->ReadSourceLocation());
2591 auto NumVars = C->varlist_size();
2592 auto UniqueDecls = C->getUniqueDeclarationsNum();
2593 auto TotalLists = C->getTotalComponentListNum();
2594 auto TotalComponents = C->getTotalComponentsNum();
2596 SmallVector<Expr *, 16> Vars;
2597 Vars.reserve(NumVars);
2598 for (unsigned i = 0; i != NumVars; ++i)
2599 Vars.push_back(Reader->Record.readSubExpr());
2600 C->setVarRefs(Vars);
2603 SmallVector<ValueDecl *, 16> Decls;
2604 Decls.reserve(UniqueDecls);
2605 for (unsigned i = 0; i < UniqueDecls; ++i)
2606 Decls.push_back(Reader->Record.readDeclAs<ValueDecl>());
2607 C->setUniqueDecls(Decls);
2609 SmallVector<unsigned, 16> ListsPerDecl;
2610 ListsPerDecl.reserve(UniqueDecls);
2611 for (unsigned i = 0; i < UniqueDecls; ++i)
2612 ListsPerDecl.push_back(Reader->Record.readInt());
2613 C->setDeclNumLists(ListsPerDecl);
2615 SmallVector<unsigned, 32> ListSizes;
2616 ListSizes.reserve(TotalLists);
2617 for (unsigned i = 0; i < TotalLists; ++i)
2618 ListSizes.push_back(Reader->Record.readInt());
2619 C->setComponentListSizes(ListSizes);
2621 SmallVector<OMPClauseMappableExprCommon::MappableComponent, 32> Components;
2622 Components.reserve(TotalComponents);
2623 for (unsigned i = 0; i < TotalComponents; ++i) {
2624 Expr *AssociatedExpr = Reader->Record.readSubExpr();
2625 ValueDecl *AssociatedDecl = Reader->Record.readDeclAs<ValueDecl>();
2626 Components.push_back(OMPClauseMappableExprCommon::MappableComponent(
2627 AssociatedExpr, AssociatedDecl));
2629 C->setComponents(Components, ListSizes);
2632 //===----------------------------------------------------------------------===//
2633 // OpenMP Directives.
2634 //===----------------------------------------------------------------------===//
2635 void ASTStmtReader::VisitOMPExecutableDirective(OMPExecutableDirective *E) {
2636 E->setLocStart(ReadSourceLocation());
2637 E->setLocEnd(ReadSourceLocation());
2638 OMPClauseReader ClauseReader(this, Record);
2639 SmallVector<OMPClause *, 5> Clauses;
2640 for (unsigned i = 0; i < E->getNumClauses(); ++i)
2641 Clauses.push_back(ClauseReader.readClause());
2642 E->setClauses(Clauses);
2643 if (E->hasAssociatedStmt())
2644 E->setAssociatedStmt(Record.readSubStmt());
2647 void ASTStmtReader::VisitOMPLoopDirective(OMPLoopDirective *D) {
2649 // Two fields (NumClauses and CollapsedNum) were read in ReadStmtFromStream.
2651 VisitOMPExecutableDirective(D);
2652 D->setIterationVariable(Record.readSubExpr());
2653 D->setLastIteration(Record.readSubExpr());
2654 D->setCalcLastIteration(Record.readSubExpr());
2655 D->setPreCond(Record.readSubExpr());
2656 D->setCond(Record.readSubExpr());
2657 D->setInit(Record.readSubExpr());
2658 D->setInc(Record.readSubExpr());
2659 D->setPreInits(Record.readSubStmt());
2660 if (isOpenMPWorksharingDirective(D->getDirectiveKind()) ||
2661 isOpenMPTaskLoopDirective(D->getDirectiveKind()) ||
2662 isOpenMPDistributeDirective(D->getDirectiveKind())) {
2663 D->setIsLastIterVariable(Record.readSubExpr());
2664 D->setLowerBoundVariable(Record.readSubExpr());
2665 D->setUpperBoundVariable(Record.readSubExpr());
2666 D->setStrideVariable(Record.readSubExpr());
2667 D->setEnsureUpperBound(Record.readSubExpr());
2668 D->setNextLowerBound(Record.readSubExpr());
2669 D->setNextUpperBound(Record.readSubExpr());
2670 D->setNumIterations(Record.readSubExpr());
2672 if (isOpenMPLoopBoundSharingDirective(D->getDirectiveKind())) {
2673 D->setPrevLowerBoundVariable(Record.readSubExpr());
2674 D->setPrevUpperBoundVariable(Record.readSubExpr());
2675 D->setDistInc(Record.readSubExpr());
2676 D->setPrevEnsureUpperBound(Record.readSubExpr());
2677 D->setCombinedLowerBoundVariable(Record.readSubExpr());
2678 D->setCombinedUpperBoundVariable(Record.readSubExpr());
2679 D->setCombinedEnsureUpperBound(Record.readSubExpr());
2680 D->setCombinedInit(Record.readSubExpr());
2681 D->setCombinedCond(Record.readSubExpr());
2682 D->setCombinedNextLowerBound(Record.readSubExpr());
2683 D->setCombinedNextUpperBound(Record.readSubExpr());
2685 SmallVector<Expr *, 4> Sub;
2686 unsigned CollapsedNum = D->getCollapsedNumber();
2687 Sub.reserve(CollapsedNum);
2688 for (unsigned i = 0; i < CollapsedNum; ++i)
2689 Sub.push_back(Record.readSubExpr());
2690 D->setCounters(Sub);
2692 for (unsigned i = 0; i < CollapsedNum; ++i)
2693 Sub.push_back(Record.readSubExpr());
2694 D->setPrivateCounters(Sub);
2696 for (unsigned i = 0; i < CollapsedNum; ++i)
2697 Sub.push_back(Record.readSubExpr());
2700 for (unsigned i = 0; i < CollapsedNum; ++i)
2701 Sub.push_back(Record.readSubExpr());
2704 for (unsigned i = 0; i < CollapsedNum; ++i)
2705 Sub.push_back(Record.readSubExpr());
2709 void ASTStmtReader::VisitOMPParallelDirective(OMPParallelDirective *D) {
2711 // The NumClauses field was read in ReadStmtFromStream.
2713 VisitOMPExecutableDirective(D);
2714 D->setHasCancel(Record.readInt());
2717 void ASTStmtReader::VisitOMPSimdDirective(OMPSimdDirective *D) {
2718 VisitOMPLoopDirective(D);
2721 void ASTStmtReader::VisitOMPForDirective(OMPForDirective *D) {
2722 VisitOMPLoopDirective(D);
2723 D->setHasCancel(Record.readInt());
2726 void ASTStmtReader::VisitOMPForSimdDirective(OMPForSimdDirective *D) {
2727 VisitOMPLoopDirective(D);
2730 void ASTStmtReader::VisitOMPSectionsDirective(OMPSectionsDirective *D) {
2732 // The NumClauses field was read in ReadStmtFromStream.
2734 VisitOMPExecutableDirective(D);
2735 D->setHasCancel(Record.readInt());
2738 void ASTStmtReader::VisitOMPSectionDirective(OMPSectionDirective *D) {
2740 VisitOMPExecutableDirective(D);
2741 D->setHasCancel(Record.readInt());
2744 void ASTStmtReader::VisitOMPSingleDirective(OMPSingleDirective *D) {
2746 // The NumClauses field was read in ReadStmtFromStream.
2748 VisitOMPExecutableDirective(D);
2751 void ASTStmtReader::VisitOMPMasterDirective(OMPMasterDirective *D) {
2753 VisitOMPExecutableDirective(D);
2756 void ASTStmtReader::VisitOMPCriticalDirective(OMPCriticalDirective *D) {
2758 // The NumClauses field was read in ReadStmtFromStream.
2760 VisitOMPExecutableDirective(D);
2761 ReadDeclarationNameInfo(D->DirName);
2764 void ASTStmtReader::VisitOMPParallelForDirective(OMPParallelForDirective *D) {
2765 VisitOMPLoopDirective(D);
2766 D->setHasCancel(Record.readInt());
2769 void ASTStmtReader::VisitOMPParallelForSimdDirective(
2770 OMPParallelForSimdDirective *D) {
2771 VisitOMPLoopDirective(D);
2774 void ASTStmtReader::VisitOMPParallelSectionsDirective(
2775 OMPParallelSectionsDirective *D) {
2777 // The NumClauses field was read in ReadStmtFromStream.
2779 VisitOMPExecutableDirective(D);
2780 D->setHasCancel(Record.readInt());
2783 void ASTStmtReader::VisitOMPTaskDirective(OMPTaskDirective *D) {
2785 // The NumClauses field was read in ReadStmtFromStream.
2787 VisitOMPExecutableDirective(D);
2788 D->setHasCancel(Record.readInt());
2791 void ASTStmtReader::VisitOMPTaskyieldDirective(OMPTaskyieldDirective *D) {
2793 VisitOMPExecutableDirective(D);
2796 void ASTStmtReader::VisitOMPBarrierDirective(OMPBarrierDirective *D) {
2798 VisitOMPExecutableDirective(D);
2801 void ASTStmtReader::VisitOMPTaskwaitDirective(OMPTaskwaitDirective *D) {
2803 VisitOMPExecutableDirective(D);
2806 void ASTStmtReader::VisitOMPTaskgroupDirective(OMPTaskgroupDirective *D) {
2808 // The NumClauses field was read in ReadStmtFromStream.
2810 VisitOMPExecutableDirective(D);
2811 D->setReductionRef(Record.readSubExpr());
2814 void ASTStmtReader::VisitOMPFlushDirective(OMPFlushDirective *D) {
2816 // The NumClauses field was read in ReadStmtFromStream.
2818 VisitOMPExecutableDirective(D);
2821 void ASTStmtReader::VisitOMPOrderedDirective(OMPOrderedDirective *D) {
2823 // The NumClauses field was read in ReadStmtFromStream.
2825 VisitOMPExecutableDirective(D);
2828 void ASTStmtReader::VisitOMPAtomicDirective(OMPAtomicDirective *D) {
2830 // The NumClauses field was read in ReadStmtFromStream.
2832 VisitOMPExecutableDirective(D);
2833 D->setX(Record.readSubExpr());
2834 D->setV(Record.readSubExpr());
2835 D->setExpr(Record.readSubExpr());
2836 D->setUpdateExpr(Record.readSubExpr());
2837 D->IsXLHSInRHSPart = Record.readInt() != 0;
2838 D->IsPostfixUpdate = Record.readInt() != 0;
2841 void ASTStmtReader::VisitOMPTargetDirective(OMPTargetDirective *D) {
2843 // The NumClauses field was read in ReadStmtFromStream.
2845 VisitOMPExecutableDirective(D);
2848 void ASTStmtReader::VisitOMPTargetDataDirective(OMPTargetDataDirective *D) {
2851 VisitOMPExecutableDirective(D);
2854 void ASTStmtReader::VisitOMPTargetEnterDataDirective(
2855 OMPTargetEnterDataDirective *D) {
2858 VisitOMPExecutableDirective(D);
2861 void ASTStmtReader::VisitOMPTargetExitDataDirective(
2862 OMPTargetExitDataDirective *D) {
2865 VisitOMPExecutableDirective(D);
2868 void ASTStmtReader::VisitOMPTargetParallelDirective(
2869 OMPTargetParallelDirective *D) {
2872 VisitOMPExecutableDirective(D);
2875 void ASTStmtReader::VisitOMPTargetParallelForDirective(
2876 OMPTargetParallelForDirective *D) {
2877 VisitOMPLoopDirective(D);
2878 D->setHasCancel(Record.readInt());
2881 void ASTStmtReader::VisitOMPTeamsDirective(OMPTeamsDirective *D) {
2883 // The NumClauses field was read in ReadStmtFromStream.
2885 VisitOMPExecutableDirective(D);
2888 void ASTStmtReader::VisitOMPCancellationPointDirective(
2889 OMPCancellationPointDirective *D) {
2891 VisitOMPExecutableDirective(D);
2892 D->setCancelRegion(static_cast<OpenMPDirectiveKind>(Record.readInt()));
2895 void ASTStmtReader::VisitOMPCancelDirective(OMPCancelDirective *D) {
2897 // The NumClauses field was read in ReadStmtFromStream.
2899 VisitOMPExecutableDirective(D);
2900 D->setCancelRegion(static_cast<OpenMPDirectiveKind>(Record.readInt()));
2903 void ASTStmtReader::VisitOMPTaskLoopDirective(OMPTaskLoopDirective *D) {
2904 VisitOMPLoopDirective(D);
2907 void ASTStmtReader::VisitOMPTaskLoopSimdDirective(OMPTaskLoopSimdDirective *D) {
2908 VisitOMPLoopDirective(D);
2911 void ASTStmtReader::VisitOMPDistributeDirective(OMPDistributeDirective *D) {
2912 VisitOMPLoopDirective(D);
2915 void ASTStmtReader::VisitOMPTargetUpdateDirective(OMPTargetUpdateDirective *D) {
2918 VisitOMPExecutableDirective(D);
2920 void ASTStmtReader::VisitOMPDistributeParallelForDirective(
2921 OMPDistributeParallelForDirective *D) {
2922 VisitOMPLoopDirective(D);
2923 D->setHasCancel(Record.readInt());
2926 void ASTStmtReader::VisitOMPDistributeParallelForSimdDirective(
2927 OMPDistributeParallelForSimdDirective *D) {
2928 VisitOMPLoopDirective(D);
2931 void ASTStmtReader::VisitOMPDistributeSimdDirective(
2932 OMPDistributeSimdDirective *D) {
2933 VisitOMPLoopDirective(D);
2936 void ASTStmtReader::VisitOMPTargetParallelForSimdDirective(
2937 OMPTargetParallelForSimdDirective *D) {
2938 VisitOMPLoopDirective(D);
2941 void ASTStmtReader::VisitOMPTargetSimdDirective(OMPTargetSimdDirective *D) {
2942 VisitOMPLoopDirective(D);
2945 void ASTStmtReader::VisitOMPTeamsDistributeDirective(
2946 OMPTeamsDistributeDirective *D) {
2947 VisitOMPLoopDirective(D);
2950 void ASTStmtReader::VisitOMPTeamsDistributeSimdDirective(
2951 OMPTeamsDistributeSimdDirective *D) {
2952 VisitOMPLoopDirective(D);
2955 void ASTStmtReader::VisitOMPTeamsDistributeParallelForSimdDirective(
2956 OMPTeamsDistributeParallelForSimdDirective *D) {
2957 VisitOMPLoopDirective(D);
2960 void ASTStmtReader::VisitOMPTeamsDistributeParallelForDirective(
2961 OMPTeamsDistributeParallelForDirective *D) {
2962 VisitOMPLoopDirective(D);
2963 D->setHasCancel(Record.readInt());
2966 void ASTStmtReader::VisitOMPTargetTeamsDirective(OMPTargetTeamsDirective *D) {
2968 // The NumClauses field was read in ReadStmtFromStream.
2970 VisitOMPExecutableDirective(D);
2973 void ASTStmtReader::VisitOMPTargetTeamsDistributeDirective(
2974 OMPTargetTeamsDistributeDirective *D) {
2975 VisitOMPLoopDirective(D);
2978 void ASTStmtReader::VisitOMPTargetTeamsDistributeParallelForDirective(
2979 OMPTargetTeamsDistributeParallelForDirective *D) {
2980 VisitOMPLoopDirective(D);
2981 D->setHasCancel(Record.readInt());
2984 void ASTStmtReader::VisitOMPTargetTeamsDistributeParallelForSimdDirective(
2985 OMPTargetTeamsDistributeParallelForSimdDirective *D) {
2986 VisitOMPLoopDirective(D);
2989 void ASTStmtReader::VisitOMPTargetTeamsDistributeSimdDirective(
2990 OMPTargetTeamsDistributeSimdDirective *D) {
2991 VisitOMPLoopDirective(D);
2994 //===----------------------------------------------------------------------===//
2995 // ASTReader Implementation
2996 //===----------------------------------------------------------------------===//
2998 Stmt *ASTReader::ReadStmt(ModuleFile &F) {
2999 switch (ReadingKind) {
3001 llvm_unreachable("should not call this when not reading anything");
3004 return ReadStmtFromStream(F);
3006 return ReadSubStmt();
3009 llvm_unreachable("ReadingKind not set ?");
3012 Expr *ASTReader::ReadExpr(ModuleFile &F) {
3013 return cast_or_null<Expr>(ReadStmt(F));
3016 Expr *ASTReader::ReadSubExpr() {
3017 return cast_or_null<Expr>(ReadSubStmt());
3020 // Within the bitstream, expressions are stored in Reverse Polish
3021 // Notation, with each of the subexpressions preceding the
3022 // expression they are stored in. Subexpressions are stored from last to first.
3023 // To evaluate expressions, we continue reading expressions and placing them on
3024 // the stack, with expressions having operands removing those operands from the
3025 // stack. Evaluation terminates when we see a STMT_STOP record, and
3026 // the single remaining expression on the stack is our result.
3027 Stmt *ASTReader::ReadStmtFromStream(ModuleFile &F) {
3029 ReadingKindTracker ReadingKind(Read_Stmt, *this);
3030 llvm::BitstreamCursor &Cursor = F.DeclsCursor;
3032 // Map of offset to previously deserialized stmt. The offset points
3033 // just after the stmt record.
3034 llvm::DenseMap<uint64_t, Stmt *> StmtEntries;
3037 unsigned PrevNumStmts = StmtStack.size();
3040 ASTRecordReader Record(*this, F);
3041 ASTStmtReader Reader(Record, Cursor);
3042 Stmt::EmptyShell Empty;
3045 llvm::BitstreamEntry Entry = Cursor.advanceSkippingSubblocks();
3047 switch (Entry.Kind) {
3048 case llvm::BitstreamEntry::SubBlock: // Handled for us already.
3049 case llvm::BitstreamEntry::Error:
3050 Error("malformed block record in AST file");
3052 case llvm::BitstreamEntry::EndBlock:
3054 case llvm::BitstreamEntry::Record:
3055 // The interesting case.
3059 ASTContext &Context = getContext();
3061 bool Finished = false;
3062 bool IsStmtReference = false;
3063 switch ((StmtCode)Record.readRecord(Cursor, Entry.ID)) {
3069 IsStmtReference = true;
3070 assert(StmtEntries.find(Record[0]) != StmtEntries.end() &&
3071 "No stmt was recorded for this offset reference!");
3072 S = StmtEntries[Record.readInt()];
3080 S = new (Context) NullStmt(Empty);
3084 S = CompoundStmt::CreateEmpty(
3085 Context, /*NumStmts=*/Record[ASTStmtReader::NumStmtFields]);
3089 S = new (Context) CaseStmt(Empty);
3093 S = new (Context) DefaultStmt(Empty);
3097 S = new (Context) LabelStmt(Empty);
3100 case STMT_ATTRIBUTED:
3101 S = AttributedStmt::CreateEmpty(
3103 /*NumAttrs*/Record[ASTStmtReader::NumStmtFields]);
3107 S = new (Context) IfStmt(Empty);
3111 S = new (Context) SwitchStmt(Empty);
3115 S = new (Context) WhileStmt(Empty);
3119 S = new (Context) DoStmt(Empty);
3123 S = new (Context) ForStmt(Empty);
3127 S = new (Context) GotoStmt(Empty);
3130 case STMT_INDIRECT_GOTO:
3131 S = new (Context) IndirectGotoStmt(Empty);
3135 S = new (Context) ContinueStmt(Empty);
3139 S = new (Context) BreakStmt(Empty);
3143 S = new (Context) ReturnStmt(Empty);
3147 S = new (Context) DeclStmt(Empty);
3151 S = new (Context) GCCAsmStmt(Empty);
3155 S = new (Context) MSAsmStmt(Empty);
3159 S = CapturedStmt::CreateDeserialized(Context,
3160 Record[ASTStmtReader::NumStmtFields]);
3163 case EXPR_PREDEFINED:
3164 S = new (Context) PredefinedExpr(Empty);
3168 S = DeclRefExpr::CreateEmpty(
3170 /*HasQualifier=*/Record[ASTStmtReader::NumExprFields],
3171 /*HasFoundDecl=*/Record[ASTStmtReader::NumExprFields + 1],
3172 /*HasTemplateKWAndArgsInfo=*/Record[ASTStmtReader::NumExprFields + 2],
3173 /*NumTemplateArgs=*/Record[ASTStmtReader::NumExprFields + 2] ?
3174 Record[ASTStmtReader::NumExprFields + 5] : 0);
3177 case EXPR_INTEGER_LITERAL:
3178 S = IntegerLiteral::Create(Context, Empty);
3181 case EXPR_FLOATING_LITERAL:
3182 S = FloatingLiteral::Create(Context, Empty);
3185 case EXPR_IMAGINARY_LITERAL:
3186 S = new (Context) ImaginaryLiteral(Empty);
3189 case EXPR_STRING_LITERAL:
3190 S = StringLiteral::CreateEmpty(Context,
3191 Record[ASTStmtReader::NumExprFields + 1]);
3194 case EXPR_CHARACTER_LITERAL:
3195 S = new (Context) CharacterLiteral(Empty);
3199 S = new (Context) ParenExpr(Empty);
3202 case EXPR_PAREN_LIST:
3203 S = new (Context) ParenListExpr(Empty);
3206 case EXPR_UNARY_OPERATOR:
3207 S = new (Context) UnaryOperator(Empty);
3211 S = OffsetOfExpr::CreateEmpty(Context,
3212 Record[ASTStmtReader::NumExprFields],
3213 Record[ASTStmtReader::NumExprFields + 1]);
3216 case EXPR_SIZEOF_ALIGN_OF:
3217 S = new (Context) UnaryExprOrTypeTraitExpr(Empty);
3220 case EXPR_ARRAY_SUBSCRIPT:
3221 S = new (Context) ArraySubscriptExpr(Empty);
3224 case EXPR_OMP_ARRAY_SECTION:
3225 S = new (Context) OMPArraySectionExpr(Empty);
3229 S = new (Context) CallExpr(Context, Stmt::CallExprClass, Empty);
3233 // We load everything here and fully initialize it at creation.
3234 // That way we can use MemberExpr::Create and don't have to duplicate its
3235 // logic with a MemberExpr::CreateEmpty.
3237 assert(Record.getIdx() == 0);
3238 NestedNameSpecifierLoc QualifierLoc;
3239 if (Record.readInt()) { // HasQualifier.
3240 QualifierLoc = Record.readNestedNameSpecifierLoc();
3243 SourceLocation TemplateKWLoc;
3244 TemplateArgumentListInfo ArgInfo;
3245 bool HasTemplateKWAndArgsInfo = Record.readInt();
3246 if (HasTemplateKWAndArgsInfo) {
3247 TemplateKWLoc = Record.readSourceLocation();
3248 unsigned NumTemplateArgs = Record.readInt();
3249 ArgInfo.setLAngleLoc(Record.readSourceLocation());
3250 ArgInfo.setRAngleLoc(Record.readSourceLocation());
3251 for (unsigned i = 0; i != NumTemplateArgs; ++i)
3252 ArgInfo.addArgument(Record.readTemplateArgumentLoc());
3255 bool HadMultipleCandidates = Record.readInt();
3257 NamedDecl *FoundD = Record.readDeclAs<NamedDecl>();
3258 AccessSpecifier AS = (AccessSpecifier)Record.readInt();
3259 DeclAccessPair FoundDecl = DeclAccessPair::make(FoundD, AS);
3261 QualType T = Record.readType();
3262 ExprValueKind VK = static_cast<ExprValueKind>(Record.readInt());
3263 ExprObjectKind OK = static_cast<ExprObjectKind>(Record.readInt());
3264 Expr *Base = ReadSubExpr();
3265 ValueDecl *MemberD = Record.readDeclAs<ValueDecl>();
3266 SourceLocation MemberLoc = Record.readSourceLocation();
3267 DeclarationNameInfo MemberNameInfo(MemberD->getDeclName(), MemberLoc);
3268 bool IsArrow = Record.readInt();
3269 SourceLocation OperatorLoc = Record.readSourceLocation();
3271 S = MemberExpr::Create(Context, Base, IsArrow, OperatorLoc, QualifierLoc,
3272 TemplateKWLoc, MemberD, FoundDecl, MemberNameInfo,
3273 HasTemplateKWAndArgsInfo ? &ArgInfo : nullptr, T,
3275 Record.readDeclarationNameLoc(cast<MemberExpr>(S)->MemberDNLoc,
3276 MemberD->getDeclName());
3277 if (HadMultipleCandidates)
3278 cast<MemberExpr>(S)->setHadMultipleCandidates(true);
3282 case EXPR_BINARY_OPERATOR:
3283 S = new (Context) BinaryOperator(Empty);
3286 case EXPR_COMPOUND_ASSIGN_OPERATOR:
3287 S = new (Context) CompoundAssignOperator(Empty);
3290 case EXPR_CONDITIONAL_OPERATOR:
3291 S = new (Context) ConditionalOperator(Empty);
3294 case EXPR_BINARY_CONDITIONAL_OPERATOR:
3295 S = new (Context) BinaryConditionalOperator(Empty);
3298 case EXPR_IMPLICIT_CAST:
3299 S = ImplicitCastExpr::CreateEmpty(Context,
3300 /*PathSize*/ Record[ASTStmtReader::NumExprFields]);
3303 case EXPR_CSTYLE_CAST:
3304 S = CStyleCastExpr::CreateEmpty(Context,
3305 /*PathSize*/ Record[ASTStmtReader::NumExprFields]);
3308 case EXPR_COMPOUND_LITERAL:
3309 S = new (Context) CompoundLiteralExpr(Empty);
3312 case EXPR_EXT_VECTOR_ELEMENT:
3313 S = new (Context) ExtVectorElementExpr(Empty);
3316 case EXPR_INIT_LIST:
3317 S = new (Context) InitListExpr(Empty);
3320 case EXPR_DESIGNATED_INIT:
3321 S = DesignatedInitExpr::CreateEmpty(Context,
3322 Record[ASTStmtReader::NumExprFields] - 1);
3326 case EXPR_DESIGNATED_INIT_UPDATE:
3327 S = new (Context) DesignatedInitUpdateExpr(Empty);
3330 case EXPR_IMPLICIT_VALUE_INIT:
3331 S = new (Context) ImplicitValueInitExpr(Empty);
3335 S = new (Context) NoInitExpr(Empty);
3338 case EXPR_ARRAY_INIT_LOOP:
3339 S = new (Context) ArrayInitLoopExpr(Empty);
3342 case EXPR_ARRAY_INIT_INDEX:
3343 S = new (Context) ArrayInitIndexExpr(Empty);
3347 S = new (Context) VAArgExpr(Empty);
3350 case EXPR_ADDR_LABEL:
3351 S = new (Context) AddrLabelExpr(Empty);
3355 S = new (Context) StmtExpr(Empty);
3359 S = new (Context) ChooseExpr(Empty);
3363 S = new (Context) GNUNullExpr(Empty);
3366 case EXPR_SHUFFLE_VECTOR:
3367 S = new (Context) ShuffleVectorExpr(Empty);
3370 case EXPR_CONVERT_VECTOR:
3371 S = new (Context) ConvertVectorExpr(Empty);
3375 S = new (Context) BlockExpr(Empty);
3378 case EXPR_GENERIC_SELECTION:
3379 S = new (Context) GenericSelectionExpr(Empty);
3382 case EXPR_OBJC_STRING_LITERAL:
3383 S = new (Context) ObjCStringLiteral(Empty);
3385 case EXPR_OBJC_BOXED_EXPRESSION:
3386 S = new (Context) ObjCBoxedExpr(Empty);
3388 case EXPR_OBJC_ARRAY_LITERAL:
3389 S = ObjCArrayLiteral::CreateEmpty(Context,
3390 Record[ASTStmtReader::NumExprFields]);
3392 case EXPR_OBJC_DICTIONARY_LITERAL:
3393 S = ObjCDictionaryLiteral::CreateEmpty(Context,
3394 Record[ASTStmtReader::NumExprFields],
3395 Record[ASTStmtReader::NumExprFields + 1]);
3397 case EXPR_OBJC_ENCODE:
3398 S = new (Context) ObjCEncodeExpr(Empty);
3400 case EXPR_OBJC_SELECTOR_EXPR:
3401 S = new (Context) ObjCSelectorExpr(Empty);
3403 case EXPR_OBJC_PROTOCOL_EXPR:
3404 S = new (Context) ObjCProtocolExpr(Empty);
3406 case EXPR_OBJC_IVAR_REF_EXPR:
3407 S = new (Context) ObjCIvarRefExpr(Empty);
3409 case EXPR_OBJC_PROPERTY_REF_EXPR:
3410 S = new (Context) ObjCPropertyRefExpr(Empty);
3412 case EXPR_OBJC_SUBSCRIPT_REF_EXPR:
3413 S = new (Context) ObjCSubscriptRefExpr(Empty);
3415 case EXPR_OBJC_KVC_REF_EXPR:
3416 llvm_unreachable("mismatching AST file");
3417 case EXPR_OBJC_MESSAGE_EXPR:
3418 S = ObjCMessageExpr::CreateEmpty(Context,
3419 Record[ASTStmtReader::NumExprFields],
3420 Record[ASTStmtReader::NumExprFields + 1]);
3423 S = new (Context) ObjCIsaExpr(Empty);
3425 case EXPR_OBJC_INDIRECT_COPY_RESTORE:
3426 S = new (Context) ObjCIndirectCopyRestoreExpr(Empty);
3428 case EXPR_OBJC_BRIDGED_CAST:
3429 S = new (Context) ObjCBridgedCastExpr(Empty);
3431 case STMT_OBJC_FOR_COLLECTION:
3432 S = new (Context) ObjCForCollectionStmt(Empty);
3434 case STMT_OBJC_CATCH:
3435 S = new (Context) ObjCAtCatchStmt(Empty);
3437 case STMT_OBJC_FINALLY:
3438 S = new (Context) ObjCAtFinallyStmt(Empty);
3440 case STMT_OBJC_AT_TRY:
3441 S = ObjCAtTryStmt::CreateEmpty(Context,
3442 Record[ASTStmtReader::NumStmtFields],
3443 Record[ASTStmtReader::NumStmtFields + 1]);
3445 case STMT_OBJC_AT_SYNCHRONIZED:
3446 S = new (Context) ObjCAtSynchronizedStmt(Empty);
3448 case STMT_OBJC_AT_THROW:
3449 S = new (Context) ObjCAtThrowStmt(Empty);
3451 case STMT_OBJC_AUTORELEASE_POOL:
3452 S = new (Context) ObjCAutoreleasePoolStmt(Empty);
3454 case EXPR_OBJC_BOOL_LITERAL:
3455 S = new (Context) ObjCBoolLiteralExpr(Empty);
3457 case EXPR_OBJC_AVAILABILITY_CHECK:
3458 S = new (Context) ObjCAvailabilityCheckExpr(Empty);
3460 case STMT_SEH_LEAVE:
3461 S = new (Context) SEHLeaveStmt(Empty);
3463 case STMT_SEH_EXCEPT:
3464 S = new (Context) SEHExceptStmt(Empty);
3466 case STMT_SEH_FINALLY:
3467 S = new (Context) SEHFinallyStmt(Empty);
3470 S = new (Context) SEHTryStmt(Empty);
3472 case STMT_CXX_CATCH:
3473 S = new (Context) CXXCatchStmt(Empty);
3477 S = CXXTryStmt::Create(Context, Empty,
3478 /*NumHandlers=*/Record[ASTStmtReader::NumStmtFields]);
3481 case STMT_CXX_FOR_RANGE:
3482 S = new (Context) CXXForRangeStmt(Empty);
3485 case STMT_MS_DEPENDENT_EXISTS:
3486 S = new (Context) MSDependentExistsStmt(SourceLocation(), true,
3487 NestedNameSpecifierLoc(),
3488 DeclarationNameInfo(),
3492 case STMT_OMP_PARALLEL_DIRECTIVE:
3494 OMPParallelDirective::CreateEmpty(Context,
3495 Record[ASTStmtReader::NumStmtFields],
3499 case STMT_OMP_SIMD_DIRECTIVE: {
3500 unsigned NumClauses = Record[ASTStmtReader::NumStmtFields];
3501 unsigned CollapsedNum = Record[ASTStmtReader::NumStmtFields + 1];
3502 S = OMPSimdDirective::CreateEmpty(Context, NumClauses,
3503 CollapsedNum, Empty);
3507 case STMT_OMP_FOR_DIRECTIVE: {
3508 unsigned NumClauses = Record[ASTStmtReader::NumStmtFields];
3509 unsigned CollapsedNum = Record[ASTStmtReader::NumStmtFields + 1];
3510 S = OMPForDirective::CreateEmpty(Context, NumClauses, CollapsedNum,
3515 case STMT_OMP_FOR_SIMD_DIRECTIVE: {
3516 unsigned NumClauses = Record[ASTStmtReader::NumStmtFields];
3517 unsigned CollapsedNum = Record[ASTStmtReader::NumStmtFields + 1];
3518 S = OMPForSimdDirective::CreateEmpty(Context, NumClauses, CollapsedNum,
3523 case STMT_OMP_SECTIONS_DIRECTIVE:
3524 S = OMPSectionsDirective::CreateEmpty(
3525 Context, Record[ASTStmtReader::NumStmtFields], Empty);
3528 case STMT_OMP_SECTION_DIRECTIVE:
3529 S = OMPSectionDirective::CreateEmpty(Context, Empty);
3532 case STMT_OMP_SINGLE_DIRECTIVE:
3533 S = OMPSingleDirective::CreateEmpty(
3534 Context, Record[ASTStmtReader::NumStmtFields], Empty);
3537 case STMT_OMP_MASTER_DIRECTIVE:
3538 S = OMPMasterDirective::CreateEmpty(Context, Empty);
3541 case STMT_OMP_CRITICAL_DIRECTIVE:
3542 S = OMPCriticalDirective::CreateEmpty(
3543 Context, Record[ASTStmtReader::NumStmtFields], Empty);
3546 case STMT_OMP_PARALLEL_FOR_DIRECTIVE: {
3547 unsigned NumClauses = Record[ASTStmtReader::NumStmtFields];
3548 unsigned CollapsedNum = Record[ASTStmtReader::NumStmtFields + 1];
3549 S = OMPParallelForDirective::CreateEmpty(Context, NumClauses,
3550 CollapsedNum, Empty);
3554 case STMT_OMP_PARALLEL_FOR_SIMD_DIRECTIVE: {
3555 unsigned NumClauses = Record[ASTStmtReader::NumStmtFields];
3556 unsigned CollapsedNum = Record[ASTStmtReader::NumStmtFields + 1];
3557 S = OMPParallelForSimdDirective::CreateEmpty(Context, NumClauses,
3558 CollapsedNum, Empty);
3562 case STMT_OMP_PARALLEL_SECTIONS_DIRECTIVE:
3563 S = OMPParallelSectionsDirective::CreateEmpty(
3564 Context, Record[ASTStmtReader::NumStmtFields], Empty);
3567 case STMT_OMP_TASK_DIRECTIVE:
3568 S = OMPTaskDirective::CreateEmpty(
3569 Context, Record[ASTStmtReader::NumStmtFields], Empty);
3572 case STMT_OMP_TASKYIELD_DIRECTIVE:
3573 S = OMPTaskyieldDirective::CreateEmpty(Context, Empty);
3576 case STMT_OMP_BARRIER_DIRECTIVE:
3577 S = OMPBarrierDirective::CreateEmpty(Context, Empty);
3580 case STMT_OMP_TASKWAIT_DIRECTIVE:
3581 S = OMPTaskwaitDirective::CreateEmpty(Context, Empty);
3584 case STMT_OMP_TASKGROUP_DIRECTIVE:
3585 S = OMPTaskgroupDirective::CreateEmpty(
3586 Context, Record[ASTStmtReader::NumStmtFields], Empty);
3589 case STMT_OMP_FLUSH_DIRECTIVE:
3590 S = OMPFlushDirective::CreateEmpty(
3591 Context, Record[ASTStmtReader::NumStmtFields], Empty);
3594 case STMT_OMP_ORDERED_DIRECTIVE:
3595 S = OMPOrderedDirective::CreateEmpty(
3596 Context, Record[ASTStmtReader::NumStmtFields], Empty);
3599 case STMT_OMP_ATOMIC_DIRECTIVE:
3600 S = OMPAtomicDirective::CreateEmpty(
3601 Context, Record[ASTStmtReader::NumStmtFields], Empty);
3604 case STMT_OMP_TARGET_DIRECTIVE:
3605 S = OMPTargetDirective::CreateEmpty(
3606 Context, Record[ASTStmtReader::NumStmtFields], Empty);
3609 case STMT_OMP_TARGET_DATA_DIRECTIVE:
3610 S = OMPTargetDataDirective::CreateEmpty(
3611 Context, Record[ASTStmtReader::NumStmtFields], Empty);
3614 case STMT_OMP_TARGET_ENTER_DATA_DIRECTIVE:
3615 S = OMPTargetEnterDataDirective::CreateEmpty(
3616 Context, Record[ASTStmtReader::NumStmtFields], Empty);
3619 case STMT_OMP_TARGET_EXIT_DATA_DIRECTIVE:
3620 S = OMPTargetExitDataDirective::CreateEmpty(
3621 Context, Record[ASTStmtReader::NumStmtFields], Empty);
3624 case STMT_OMP_TARGET_PARALLEL_DIRECTIVE:
3625 S = OMPTargetParallelDirective::CreateEmpty(
3626 Context, Record[ASTStmtReader::NumStmtFields], Empty);
3629 case STMT_OMP_TARGET_PARALLEL_FOR_DIRECTIVE: {
3630 unsigned NumClauses = Record[ASTStmtReader::NumStmtFields];
3631 unsigned CollapsedNum = Record[ASTStmtReader::NumStmtFields + 1];
3632 S = OMPTargetParallelForDirective::CreateEmpty(Context, NumClauses,
3633 CollapsedNum, Empty);
3637 case STMT_OMP_TARGET_UPDATE_DIRECTIVE:
3638 S = OMPTargetUpdateDirective::CreateEmpty(
3639 Context, Record[ASTStmtReader::NumStmtFields], Empty);
3642 case STMT_OMP_TEAMS_DIRECTIVE:
3643 S = OMPTeamsDirective::CreateEmpty(
3644 Context, Record[ASTStmtReader::NumStmtFields], Empty);
3647 case STMT_OMP_CANCELLATION_POINT_DIRECTIVE:
3648 S = OMPCancellationPointDirective::CreateEmpty(Context, Empty);
3651 case STMT_OMP_CANCEL_DIRECTIVE:
3652 S = OMPCancelDirective::CreateEmpty(
3653 Context, Record[ASTStmtReader::NumStmtFields], Empty);
3656 case STMT_OMP_TASKLOOP_DIRECTIVE: {
3657 unsigned NumClauses = Record[ASTStmtReader::NumStmtFields];
3658 unsigned CollapsedNum = Record[ASTStmtReader::NumStmtFields + 1];
3659 S = OMPTaskLoopDirective::CreateEmpty(Context, NumClauses, CollapsedNum,
3664 case STMT_OMP_TASKLOOP_SIMD_DIRECTIVE: {
3665 unsigned NumClauses = Record[ASTStmtReader::NumStmtFields];
3666 unsigned CollapsedNum = Record[ASTStmtReader::NumStmtFields + 1];
3667 S = OMPTaskLoopSimdDirective::CreateEmpty(Context, NumClauses,
3668 CollapsedNum, Empty);
3672 case STMT_OMP_DISTRIBUTE_DIRECTIVE: {
3673 unsigned NumClauses = Record[ASTStmtReader::NumStmtFields];
3674 unsigned CollapsedNum = Record[ASTStmtReader::NumStmtFields + 1];
3675 S = OMPDistributeDirective::CreateEmpty(Context, NumClauses, CollapsedNum,
3680 case STMT_OMP_DISTRIBUTE_PARALLEL_FOR_DIRECTIVE: {
3681 unsigned NumClauses = Record[ASTStmtReader::NumStmtFields];
3682 unsigned CollapsedNum = Record[ASTStmtReader::NumStmtFields + 1];
3683 S = OMPDistributeParallelForDirective::CreateEmpty(Context, NumClauses,
3684 CollapsedNum, Empty);
3688 case STMT_OMP_DISTRIBUTE_PARALLEL_FOR_SIMD_DIRECTIVE: {
3689 unsigned NumClauses = Record[ASTStmtReader::NumStmtFields];
3690 unsigned CollapsedNum = Record[ASTStmtReader::NumStmtFields + 1];
3691 S = OMPDistributeParallelForSimdDirective::CreateEmpty(Context, NumClauses,
3697 case STMT_OMP_DISTRIBUTE_SIMD_DIRECTIVE: {
3698 unsigned NumClauses = Record[ASTStmtReader::NumStmtFields];
3699 unsigned CollapsedNum = Record[ASTStmtReader::NumStmtFields + 1];
3700 S = OMPDistributeSimdDirective::CreateEmpty(Context, NumClauses,
3701 CollapsedNum, Empty);
3705 case STMT_OMP_TARGET_PARALLEL_FOR_SIMD_DIRECTIVE: {
3706 unsigned NumClauses = Record[ASTStmtReader::NumStmtFields];
3707 unsigned CollapsedNum = Record[ASTStmtReader::NumStmtFields + 1];
3708 S = OMPTargetParallelForSimdDirective::CreateEmpty(Context, NumClauses,
3709 CollapsedNum, Empty);
3713 case STMT_OMP_TARGET_SIMD_DIRECTIVE: {
3714 auto NumClauses = Record[ASTStmtReader::NumStmtFields];
3715 auto CollapsedNum = Record[ASTStmtReader::NumStmtFields + 1];
3716 S = OMPTargetSimdDirective::CreateEmpty(Context, NumClauses, CollapsedNum,
3721 case STMT_OMP_TEAMS_DISTRIBUTE_DIRECTIVE: {
3722 auto NumClauses = Record[ASTStmtReader::NumStmtFields];
3723 auto CollapsedNum = Record[ASTStmtReader::NumStmtFields + 1];
3724 S = OMPTeamsDistributeDirective::CreateEmpty(Context, NumClauses,
3725 CollapsedNum, Empty);
3729 case STMT_OMP_TEAMS_DISTRIBUTE_SIMD_DIRECTIVE: {
3730 unsigned NumClauses = Record[ASTStmtReader::NumStmtFields];
3731 unsigned CollapsedNum = Record[ASTStmtReader::NumStmtFields + 1];
3732 S = OMPTeamsDistributeSimdDirective::CreateEmpty(Context, NumClauses,
3733 CollapsedNum, Empty);
3737 case STMT_OMP_TEAMS_DISTRIBUTE_PARALLEL_FOR_SIMD_DIRECTIVE: {
3738 auto NumClauses = Record[ASTStmtReader::NumStmtFields];
3739 auto CollapsedNum = Record[ASTStmtReader::NumStmtFields + 1];
3740 S = OMPTeamsDistributeParallelForSimdDirective::CreateEmpty(
3741 Context, NumClauses, CollapsedNum, Empty);
3745 case STMT_OMP_TEAMS_DISTRIBUTE_PARALLEL_FOR_DIRECTIVE: {
3746 auto NumClauses = Record[ASTStmtReader::NumStmtFields];
3747 auto CollapsedNum = Record[ASTStmtReader::NumStmtFields + 1];
3748 S = OMPTeamsDistributeParallelForDirective::CreateEmpty(
3749 Context, NumClauses, CollapsedNum, Empty);
3753 case STMT_OMP_TARGET_TEAMS_DIRECTIVE: {
3754 S = OMPTargetTeamsDirective::CreateEmpty(
3755 Context, Record[ASTStmtReader::NumStmtFields], Empty);
3759 case STMT_OMP_TARGET_TEAMS_DISTRIBUTE_DIRECTIVE: {
3760 auto NumClauses = Record[ASTStmtReader::NumStmtFields];
3761 auto CollapsedNum = Record[ASTStmtReader::NumStmtFields + 1];
3762 S = OMPTargetTeamsDistributeDirective::CreateEmpty(Context, NumClauses,
3763 CollapsedNum, Empty);
3767 case STMT_OMP_TARGET_TEAMS_DISTRIBUTE_PARALLEL_FOR_DIRECTIVE: {
3768 auto NumClauses = Record[ASTStmtReader::NumStmtFields];
3769 auto CollapsedNum = Record[ASTStmtReader::NumStmtFields + 1];
3770 S = OMPTargetTeamsDistributeParallelForDirective::CreateEmpty(
3771 Context, NumClauses, CollapsedNum, Empty);
3775 case STMT_OMP_TARGET_TEAMS_DISTRIBUTE_PARALLEL_FOR_SIMD_DIRECTIVE: {
3776 auto NumClauses = Record[ASTStmtReader::NumStmtFields];
3777 auto CollapsedNum = Record[ASTStmtReader::NumStmtFields + 1];
3778 S = OMPTargetTeamsDistributeParallelForSimdDirective::CreateEmpty(
3779 Context, NumClauses, CollapsedNum, Empty);
3783 case STMT_OMP_TARGET_TEAMS_DISTRIBUTE_SIMD_DIRECTIVE: {
3784 auto NumClauses = Record[ASTStmtReader::NumStmtFields];
3785 auto CollapsedNum = Record[ASTStmtReader::NumStmtFields + 1];
3786 S = OMPTargetTeamsDistributeSimdDirective::CreateEmpty(
3787 Context, NumClauses, CollapsedNum, Empty);
3791 case EXPR_CXX_OPERATOR_CALL:
3792 S = new (Context) CXXOperatorCallExpr(Context, Empty);
3795 case EXPR_CXX_MEMBER_CALL:
3796 S = new (Context) CXXMemberCallExpr(Context, Empty);
3799 case EXPR_CXX_CONSTRUCT:
3800 S = new (Context) CXXConstructExpr(Empty);
3803 case EXPR_CXX_INHERITED_CTOR_INIT:
3804 S = new (Context) CXXInheritedCtorInitExpr(Empty);
3807 case EXPR_CXX_TEMPORARY_OBJECT:
3808 S = new (Context) CXXTemporaryObjectExpr(Empty);
3811 case EXPR_CXX_STATIC_CAST:
3812 S = CXXStaticCastExpr::CreateEmpty(Context,
3813 /*PathSize*/ Record[ASTStmtReader::NumExprFields]);
3816 case EXPR_CXX_DYNAMIC_CAST:
3817 S = CXXDynamicCastExpr::CreateEmpty(Context,
3818 /*PathSize*/ Record[ASTStmtReader::NumExprFields]);
3821 case EXPR_CXX_REINTERPRET_CAST:
3822 S = CXXReinterpretCastExpr::CreateEmpty(Context,
3823 /*PathSize*/ Record[ASTStmtReader::NumExprFields]);
3826 case EXPR_CXX_CONST_CAST:
3827 S = CXXConstCastExpr::CreateEmpty(Context);
3830 case EXPR_CXX_FUNCTIONAL_CAST:
3831 S = CXXFunctionalCastExpr::CreateEmpty(Context,
3832 /*PathSize*/ Record[ASTStmtReader::NumExprFields]);
3835 case EXPR_USER_DEFINED_LITERAL:
3836 S = new (Context) UserDefinedLiteral(Context, Empty);
3839 case EXPR_CXX_STD_INITIALIZER_LIST:
3840 S = new (Context) CXXStdInitializerListExpr(Empty);
3843 case EXPR_CXX_BOOL_LITERAL:
3844 S = new (Context) CXXBoolLiteralExpr(Empty);
3847 case EXPR_CXX_NULL_PTR_LITERAL:
3848 S = new (Context) CXXNullPtrLiteralExpr(Empty);
3850 case EXPR_CXX_TYPEID_EXPR:
3851 S = new (Context) CXXTypeidExpr(Empty, true);
3853 case EXPR_CXX_TYPEID_TYPE:
3854 S = new (Context) CXXTypeidExpr(Empty, false);
3856 case EXPR_CXX_UUIDOF_EXPR:
3857 S = new (Context) CXXUuidofExpr(Empty, true);
3859 case EXPR_CXX_PROPERTY_REF_EXPR:
3860 S = new (Context) MSPropertyRefExpr(Empty);
3862 case EXPR_CXX_PROPERTY_SUBSCRIPT_EXPR:
3863 S = new (Context) MSPropertySubscriptExpr(Empty);
3865 case EXPR_CXX_UUIDOF_TYPE:
3866 S = new (Context) CXXUuidofExpr(Empty, false);
3869 S = new (Context) CXXThisExpr(Empty);
3871 case EXPR_CXX_THROW:
3872 S = new (Context) CXXThrowExpr(Empty);
3874 case EXPR_CXX_DEFAULT_ARG:
3875 S = new (Context) CXXDefaultArgExpr(Empty);
3877 case EXPR_CXX_DEFAULT_INIT:
3878 S = new (Context) CXXDefaultInitExpr(Empty);
3880 case EXPR_CXX_BIND_TEMPORARY:
3881 S = new (Context) CXXBindTemporaryExpr(Empty);
3884 case EXPR_CXX_SCALAR_VALUE_INIT:
3885 S = new (Context) CXXScalarValueInitExpr(Empty);
3888 S = new (Context) CXXNewExpr(Empty);
3890 case EXPR_CXX_DELETE:
3891 S = new (Context) CXXDeleteExpr(Empty);
3893 case EXPR_CXX_PSEUDO_DESTRUCTOR:
3894 S = new (Context) CXXPseudoDestructorExpr(Empty);
3897 case EXPR_EXPR_WITH_CLEANUPS:
3898 S = ExprWithCleanups::Create(Context, Empty,
3899 Record[ASTStmtReader::NumExprFields]);
3902 case EXPR_CXX_DEPENDENT_SCOPE_MEMBER:
3903 S = CXXDependentScopeMemberExpr::CreateEmpty(Context,
3904 /*HasTemplateKWAndArgsInfo=*/Record[ASTStmtReader::NumExprFields],
3905 /*NumTemplateArgs=*/Record[ASTStmtReader::NumExprFields]
3906 ? Record[ASTStmtReader::NumExprFields + 1]
3910 case EXPR_CXX_DEPENDENT_SCOPE_DECL_REF:
3911 S = DependentScopeDeclRefExpr::CreateEmpty(Context,
3912 /*HasTemplateKWAndArgsInfo=*/Record[ASTStmtReader::NumExprFields],
3913 /*NumTemplateArgs=*/Record[ASTStmtReader::NumExprFields]
3914 ? Record[ASTStmtReader::NumExprFields + 1]
3918 case EXPR_CXX_UNRESOLVED_CONSTRUCT:
3919 S = CXXUnresolvedConstructExpr::CreateEmpty(Context,
3920 /*NumArgs=*/Record[ASTStmtReader::NumExprFields]);
3923 case EXPR_CXX_UNRESOLVED_MEMBER:
3924 S = UnresolvedMemberExpr::CreateEmpty(Context,
3925 /*HasTemplateKWAndArgsInfo=*/Record[ASTStmtReader::NumExprFields],
3926 /*NumTemplateArgs=*/Record[ASTStmtReader::NumExprFields]
3927 ? Record[ASTStmtReader::NumExprFields + 1]
3931 case EXPR_CXX_UNRESOLVED_LOOKUP:
3932 S = UnresolvedLookupExpr::CreateEmpty(Context,
3933 /*HasTemplateKWAndArgsInfo=*/Record[ASTStmtReader::NumExprFields],
3934 /*NumTemplateArgs=*/Record[ASTStmtReader::NumExprFields]
3935 ? Record[ASTStmtReader::NumExprFields + 1]
3939 case EXPR_TYPE_TRAIT:
3940 S = TypeTraitExpr::CreateDeserialized(Context,
3941 Record[ASTStmtReader::NumExprFields]);
3944 case EXPR_ARRAY_TYPE_TRAIT:
3945 S = new (Context) ArrayTypeTraitExpr(Empty);
3948 case EXPR_CXX_EXPRESSION_TRAIT:
3949 S = new (Context) ExpressionTraitExpr(Empty);
3952 case EXPR_CXX_NOEXCEPT:
3953 S = new (Context) CXXNoexceptExpr(Empty);
3956 case EXPR_PACK_EXPANSION:
3957 S = new (Context) PackExpansionExpr(Empty);
3960 case EXPR_SIZEOF_PACK:
3961 S = SizeOfPackExpr::CreateDeserialized(
3963 /*NumPartialArgs=*/Record[ASTStmtReader::NumExprFields]);
3966 case EXPR_SUBST_NON_TYPE_TEMPLATE_PARM:
3967 S = new (Context) SubstNonTypeTemplateParmExpr(Empty);
3970 case EXPR_SUBST_NON_TYPE_TEMPLATE_PARM_PACK:
3971 S = new (Context) SubstNonTypeTemplateParmPackExpr(Empty);
3974 case EXPR_FUNCTION_PARM_PACK:
3975 S = FunctionParmPackExpr::CreateEmpty(Context,
3976 Record[ASTStmtReader::NumExprFields]);
3979 case EXPR_MATERIALIZE_TEMPORARY:
3980 S = new (Context) MaterializeTemporaryExpr(Empty);
3984 S = new (Context) CXXFoldExpr(Empty);
3987 case EXPR_OPAQUE_VALUE:
3988 S = new (Context) OpaqueValueExpr(Empty);
3991 case EXPR_CUDA_KERNEL_CALL:
3992 S = new (Context) CUDAKernelCallExpr(Context, Empty);
3996 S = new (Context) AsTypeExpr(Empty);
3999 case EXPR_PSEUDO_OBJECT: {
4000 unsigned numSemanticExprs = Record[ASTStmtReader::NumExprFields];
4001 S = PseudoObjectExpr::Create(Context, Empty, numSemanticExprs);
4006 S = new (Context) AtomicExpr(Empty);
4010 unsigned NumCaptures = Record[ASTStmtReader::NumExprFields];
4011 S = LambdaExpr::CreateDeserialized(Context, NumCaptures);
4015 case STMT_COROUTINE_BODY: {
4016 unsigned NumParams = Record[ASTStmtReader::NumStmtFields];
4017 S = CoroutineBodyStmt::Create(Context, Empty, NumParams);
4022 S = new (Context) CoreturnStmt(Empty);
4026 S = new (Context) CoawaitExpr(Empty);
4030 S = new (Context) CoyieldExpr(Empty);
4033 case EXPR_DEPENDENT_COAWAIT:
4034 S = new (Context) DependentCoawaitExpr(Empty);
4039 // We hit a STMT_STOP, so we're done with this expression.
4043 ++NumStatementsRead;
4045 if (S && !IsStmtReference) {
4047 StmtEntries[Cursor.GetCurrentBitNo()] = S;
4050 assert(Record.getIdx() == Record.size() &&
4051 "Invalid deserialization of statement");
4052 StmtStack.push_back(S);
4055 assert(StmtStack.size() > PrevNumStmts && "Read too many sub-stmts!");
4056 assert(StmtStack.size() == PrevNumStmts + 1 && "Extra expressions on stack!");
4057 return StmtStack.pop_back_val();