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());
122 S->setStmts(Record.getContext(), Stmts);
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) {
370 // FIXME: Implement coroutine serialization.
371 llvm_unreachable("unimplemented");
374 void ASTStmtReader::VisitCoreturnStmt(CoreturnStmt *S) {
375 // FIXME: Implement coroutine serialization.
376 llvm_unreachable("unimplemented");
379 void ASTStmtReader::VisitCoawaitExpr(CoawaitExpr *S) {
380 // FIXME: Implement coroutine serialization.
381 llvm_unreachable("unimplemented");
384 void ASTStmtReader::VisitDependentCoawaitExpr(DependentCoawaitExpr *S) {
385 // FIXME: Implement coroutine serialization.
386 llvm_unreachable("unimplemented");
389 void ASTStmtReader::VisitCoyieldExpr(CoyieldExpr *S) {
390 // FIXME: Implement coroutine serialization.
391 llvm_unreachable("unimplemented");
394 void ASTStmtReader::VisitCapturedStmt(CapturedStmt *S) {
397 S->setCapturedDecl(ReadDeclAs<CapturedDecl>());
398 S->setCapturedRegionKind(static_cast<CapturedRegionKind>(Record.readInt()));
399 S->setCapturedRecordDecl(ReadDeclAs<RecordDecl>());
402 for (CapturedStmt::capture_init_iterator I = S->capture_init_begin(),
403 E = S->capture_init_end();
405 *I = Record.readSubExpr();
408 S->setCapturedStmt(Record.readSubStmt());
409 S->getCapturedDecl()->setBody(S->getCapturedStmt());
412 for (auto &I : S->captures()) {
413 I.VarAndKind.setPointer(ReadDeclAs<VarDecl>());
415 static_cast<CapturedStmt::VariableCaptureKind>(Record.readInt()));
416 I.Loc = ReadSourceLocation();
420 void ASTStmtReader::VisitExpr(Expr *E) {
422 E->setType(Record.readType());
423 E->setTypeDependent(Record.readInt());
424 E->setValueDependent(Record.readInt());
425 E->setInstantiationDependent(Record.readInt());
426 E->ExprBits.ContainsUnexpandedParameterPack = Record.readInt();
427 E->setValueKind(static_cast<ExprValueKind>(Record.readInt()));
428 E->setObjectKind(static_cast<ExprObjectKind>(Record.readInt()));
429 assert(Record.getIdx() == NumExprFields &&
430 "Incorrect expression field count");
433 void ASTStmtReader::VisitPredefinedExpr(PredefinedExpr *E) {
435 E->setLocation(ReadSourceLocation());
436 E->Type = (PredefinedExpr::IdentType)Record.readInt();
437 E->FnName = cast_or_null<StringLiteral>(Record.readSubExpr());
440 void ASTStmtReader::VisitDeclRefExpr(DeclRefExpr *E) {
443 E->DeclRefExprBits.HasQualifier = Record.readInt();
444 E->DeclRefExprBits.HasFoundDecl = Record.readInt();
445 E->DeclRefExprBits.HasTemplateKWAndArgsInfo = Record.readInt();
446 E->DeclRefExprBits.HadMultipleCandidates = Record.readInt();
447 E->DeclRefExprBits.RefersToEnclosingVariableOrCapture = Record.readInt();
448 unsigned NumTemplateArgs = 0;
449 if (E->hasTemplateKWAndArgsInfo())
450 NumTemplateArgs = Record.readInt();
452 if (E->hasQualifier())
453 new (E->getTrailingObjects<NestedNameSpecifierLoc>())
454 NestedNameSpecifierLoc(Record.readNestedNameSpecifierLoc());
456 if (E->hasFoundDecl())
457 *E->getTrailingObjects<NamedDecl *>() = ReadDeclAs<NamedDecl>();
459 if (E->hasTemplateKWAndArgsInfo())
460 ReadTemplateKWAndArgsInfo(
461 *E->getTrailingObjects<ASTTemplateKWAndArgsInfo>(),
462 E->getTrailingObjects<TemplateArgumentLoc>(), NumTemplateArgs);
464 E->setDecl(ReadDeclAs<ValueDecl>());
465 E->setLocation(ReadSourceLocation());
466 ReadDeclarationNameLoc(E->DNLoc, E->getDecl()->getDeclName());
469 void ASTStmtReader::VisitIntegerLiteral(IntegerLiteral *E) {
471 E->setLocation(ReadSourceLocation());
472 E->setValue(Record.getContext(), Record.readAPInt());
475 void ASTStmtReader::VisitFloatingLiteral(FloatingLiteral *E) {
477 E->setRawSemantics(static_cast<Stmt::APFloatSemantics>(Record.readInt()));
478 E->setExact(Record.readInt());
479 E->setValue(Record.getContext(), Record.readAPFloat(E->getSemantics()));
480 E->setLocation(ReadSourceLocation());
483 void ASTStmtReader::VisitImaginaryLiteral(ImaginaryLiteral *E) {
485 E->setSubExpr(Record.readSubExpr());
488 void ASTStmtReader::VisitStringLiteral(StringLiteral *E) {
490 unsigned Len = Record.readInt();
491 assert(Record.peekInt() == E->getNumConcatenated() &&
492 "Wrong number of concatenated tokens!");
494 StringLiteral::StringKind kind =
495 static_cast<StringLiteral::StringKind>(Record.readInt());
496 bool isPascal = Record.readInt();
499 auto B = &Record.peekInt();
500 SmallString<16> Str(B, B + Len);
501 E->setString(Record.getContext(), Str, kind, isPascal);
502 Record.skipInts(Len);
504 // Read source locations
505 for (unsigned I = 0, N = E->getNumConcatenated(); I != N; ++I)
506 E->setStrTokenLoc(I, ReadSourceLocation());
509 void ASTStmtReader::VisitCharacterLiteral(CharacterLiteral *E) {
511 E->setValue(Record.readInt());
512 E->setLocation(ReadSourceLocation());
513 E->setKind(static_cast<CharacterLiteral::CharacterKind>(Record.readInt()));
516 void ASTStmtReader::VisitParenExpr(ParenExpr *E) {
518 E->setLParen(ReadSourceLocation());
519 E->setRParen(ReadSourceLocation());
520 E->setSubExpr(Record.readSubExpr());
523 void ASTStmtReader::VisitParenListExpr(ParenListExpr *E) {
525 unsigned NumExprs = Record.readInt();
526 E->Exprs = new (Record.getContext()) Stmt*[NumExprs];
527 for (unsigned i = 0; i != NumExprs; ++i)
528 E->Exprs[i] = Record.readSubStmt();
529 E->NumExprs = NumExprs;
530 E->LParenLoc = ReadSourceLocation();
531 E->RParenLoc = ReadSourceLocation();
534 void ASTStmtReader::VisitUnaryOperator(UnaryOperator *E) {
536 E->setSubExpr(Record.readSubExpr());
537 E->setOpcode((UnaryOperator::Opcode)Record.readInt());
538 E->setOperatorLoc(ReadSourceLocation());
541 void ASTStmtReader::VisitOffsetOfExpr(OffsetOfExpr *E) {
543 assert(E->getNumComponents() == Record.peekInt());
545 assert(E->getNumExpressions() == Record.peekInt());
547 E->setOperatorLoc(ReadSourceLocation());
548 E->setRParenLoc(ReadSourceLocation());
549 E->setTypeSourceInfo(GetTypeSourceInfo());
550 for (unsigned I = 0, N = E->getNumComponents(); I != N; ++I) {
551 OffsetOfNode::Kind Kind = static_cast<OffsetOfNode::Kind>(Record.readInt());
552 SourceLocation Start = ReadSourceLocation();
553 SourceLocation End = ReadSourceLocation();
555 case OffsetOfNode::Array:
556 E->setComponent(I, OffsetOfNode(Start, Record.readInt(), End));
559 case OffsetOfNode::Field:
561 I, OffsetOfNode(Start, ReadDeclAs<FieldDecl>(), End));
564 case OffsetOfNode::Identifier:
567 OffsetOfNode(Start, Record.getIdentifierInfo(), End));
570 case OffsetOfNode::Base: {
571 CXXBaseSpecifier *Base = new (Record.getContext()) CXXBaseSpecifier();
572 *Base = Record.readCXXBaseSpecifier();
573 E->setComponent(I, OffsetOfNode(Base));
579 for (unsigned I = 0, N = E->getNumExpressions(); I != N; ++I)
580 E->setIndexExpr(I, Record.readSubExpr());
583 void ASTStmtReader::VisitUnaryExprOrTypeTraitExpr(UnaryExprOrTypeTraitExpr *E) {
585 E->setKind(static_cast<UnaryExprOrTypeTrait>(Record.readInt()));
586 if (Record.peekInt() == 0) {
587 E->setArgument(Record.readSubExpr());
590 E->setArgument(GetTypeSourceInfo());
592 E->setOperatorLoc(ReadSourceLocation());
593 E->setRParenLoc(ReadSourceLocation());
596 void ASTStmtReader::VisitArraySubscriptExpr(ArraySubscriptExpr *E) {
598 E->setLHS(Record.readSubExpr());
599 E->setRHS(Record.readSubExpr());
600 E->setRBracketLoc(ReadSourceLocation());
603 void ASTStmtReader::VisitOMPArraySectionExpr(OMPArraySectionExpr *E) {
605 E->setBase(Record.readSubExpr());
606 E->setLowerBound(Record.readSubExpr());
607 E->setLength(Record.readSubExpr());
608 E->setColonLoc(ReadSourceLocation());
609 E->setRBracketLoc(ReadSourceLocation());
612 void ASTStmtReader::VisitCallExpr(CallExpr *E) {
614 E->setNumArgs(Record.getContext(), Record.readInt());
615 E->setRParenLoc(ReadSourceLocation());
616 E->setCallee(Record.readSubExpr());
617 for (unsigned I = 0, N = E->getNumArgs(); I != N; ++I)
618 E->setArg(I, Record.readSubExpr());
621 void ASTStmtReader::VisitCXXMemberCallExpr(CXXMemberCallExpr *E) {
625 void ASTStmtReader::VisitMemberExpr(MemberExpr *E) {
626 // Don't call VisitExpr, this is fully initialized at creation.
627 assert(E->getStmtClass() == Stmt::MemberExprClass &&
628 "It's a subclass, we must advance Idx!");
631 void ASTStmtReader::VisitObjCIsaExpr(ObjCIsaExpr *E) {
633 E->setBase(Record.readSubExpr());
634 E->setIsaMemberLoc(ReadSourceLocation());
635 E->setOpLoc(ReadSourceLocation());
636 E->setArrow(Record.readInt());
640 VisitObjCIndirectCopyRestoreExpr(ObjCIndirectCopyRestoreExpr *E) {
642 E->Operand = Record.readSubExpr();
643 E->setShouldCopy(Record.readInt());
646 void ASTStmtReader::VisitObjCBridgedCastExpr(ObjCBridgedCastExpr *E) {
647 VisitExplicitCastExpr(E);
648 E->LParenLoc = ReadSourceLocation();
649 E->BridgeKeywordLoc = ReadSourceLocation();
650 E->Kind = Record.readInt();
653 void ASTStmtReader::VisitCastExpr(CastExpr *E) {
655 unsigned NumBaseSpecs = Record.readInt();
656 assert(NumBaseSpecs == E->path_size());
657 E->setSubExpr(Record.readSubExpr());
658 E->setCastKind((CastKind)Record.readInt());
659 CastExpr::path_iterator BaseI = E->path_begin();
660 while (NumBaseSpecs--) {
661 CXXBaseSpecifier *BaseSpec = new (Record.getContext()) CXXBaseSpecifier;
662 *BaseSpec = Record.readCXXBaseSpecifier();
667 void ASTStmtReader::VisitBinaryOperator(BinaryOperator *E) {
669 E->setLHS(Record.readSubExpr());
670 E->setRHS(Record.readSubExpr());
671 E->setOpcode((BinaryOperator::Opcode)Record.readInt());
672 E->setOperatorLoc(ReadSourceLocation());
673 E->setFPFeatures(FPOptions(Record.readInt()));
676 void ASTStmtReader::VisitCompoundAssignOperator(CompoundAssignOperator *E) {
677 VisitBinaryOperator(E);
678 E->setComputationLHSType(Record.readType());
679 E->setComputationResultType(Record.readType());
682 void ASTStmtReader::VisitConditionalOperator(ConditionalOperator *E) {
684 E->SubExprs[ConditionalOperator::COND] = Record.readSubExpr();
685 E->SubExprs[ConditionalOperator::LHS] = Record.readSubExpr();
686 E->SubExprs[ConditionalOperator::RHS] = Record.readSubExpr();
687 E->QuestionLoc = ReadSourceLocation();
688 E->ColonLoc = ReadSourceLocation();
692 ASTStmtReader::VisitBinaryConditionalOperator(BinaryConditionalOperator *E) {
694 E->OpaqueValue = cast<OpaqueValueExpr>(Record.readSubExpr());
695 E->SubExprs[BinaryConditionalOperator::COMMON] = Record.readSubExpr();
696 E->SubExprs[BinaryConditionalOperator::COND] = Record.readSubExpr();
697 E->SubExprs[BinaryConditionalOperator::LHS] = Record.readSubExpr();
698 E->SubExprs[BinaryConditionalOperator::RHS] = Record.readSubExpr();
699 E->QuestionLoc = ReadSourceLocation();
700 E->ColonLoc = ReadSourceLocation();
703 void ASTStmtReader::VisitImplicitCastExpr(ImplicitCastExpr *E) {
707 void ASTStmtReader::VisitExplicitCastExpr(ExplicitCastExpr *E) {
709 E->setTypeInfoAsWritten(GetTypeSourceInfo());
712 void ASTStmtReader::VisitCStyleCastExpr(CStyleCastExpr *E) {
713 VisitExplicitCastExpr(E);
714 E->setLParenLoc(ReadSourceLocation());
715 E->setRParenLoc(ReadSourceLocation());
718 void ASTStmtReader::VisitCompoundLiteralExpr(CompoundLiteralExpr *E) {
720 E->setLParenLoc(ReadSourceLocation());
721 E->setTypeSourceInfo(GetTypeSourceInfo());
722 E->setInitializer(Record.readSubExpr());
723 E->setFileScope(Record.readInt());
726 void ASTStmtReader::VisitExtVectorElementExpr(ExtVectorElementExpr *E) {
728 E->setBase(Record.readSubExpr());
729 E->setAccessor(Record.getIdentifierInfo());
730 E->setAccessorLoc(ReadSourceLocation());
733 void ASTStmtReader::VisitInitListExpr(InitListExpr *E) {
735 if (InitListExpr *SyntForm = cast_or_null<InitListExpr>(Record.readSubStmt()))
736 E->setSyntacticForm(SyntForm);
737 E->setLBraceLoc(ReadSourceLocation());
738 E->setRBraceLoc(ReadSourceLocation());
739 bool isArrayFiller = Record.readInt();
740 Expr *filler = nullptr;
742 filler = Record.readSubExpr();
743 E->ArrayFillerOrUnionFieldInit = filler;
745 E->ArrayFillerOrUnionFieldInit = ReadDeclAs<FieldDecl>();
746 E->sawArrayRangeDesignator(Record.readInt());
747 unsigned NumInits = Record.readInt();
748 E->reserveInits(Record.getContext(), NumInits);
750 for (unsigned I = 0; I != NumInits; ++I) {
751 Expr *init = Record.readSubExpr();
752 E->updateInit(Record.getContext(), I, init ? init : filler);
755 for (unsigned I = 0; I != NumInits; ++I)
756 E->updateInit(Record.getContext(), I, Record.readSubExpr());
760 void ASTStmtReader::VisitDesignatedInitExpr(DesignatedInitExpr *E) {
761 typedef DesignatedInitExpr::Designator Designator;
764 unsigned NumSubExprs = Record.readInt();
765 assert(NumSubExprs == E->getNumSubExprs() && "Wrong number of subexprs");
766 for (unsigned I = 0; I != NumSubExprs; ++I)
767 E->setSubExpr(I, Record.readSubExpr());
768 E->setEqualOrColonLoc(ReadSourceLocation());
769 E->setGNUSyntax(Record.readInt());
771 SmallVector<Designator, 4> Designators;
772 while (Record.getIdx() < Record.size()) {
773 switch ((DesignatorTypes)Record.readInt()) {
774 case DESIG_FIELD_DECL: {
775 FieldDecl *Field = ReadDeclAs<FieldDecl>();
776 SourceLocation DotLoc = ReadSourceLocation();
777 SourceLocation FieldLoc = ReadSourceLocation();
778 Designators.push_back(Designator(Field->getIdentifier(), DotLoc,
780 Designators.back().setField(Field);
784 case DESIG_FIELD_NAME: {
785 const IdentifierInfo *Name = Record.getIdentifierInfo();
786 SourceLocation DotLoc = ReadSourceLocation();
787 SourceLocation FieldLoc = ReadSourceLocation();
788 Designators.push_back(Designator(Name, DotLoc, FieldLoc));
793 unsigned Index = Record.readInt();
794 SourceLocation LBracketLoc = ReadSourceLocation();
795 SourceLocation RBracketLoc = ReadSourceLocation();
796 Designators.push_back(Designator(Index, LBracketLoc, RBracketLoc));
800 case DESIG_ARRAY_RANGE: {
801 unsigned Index = Record.readInt();
802 SourceLocation LBracketLoc = ReadSourceLocation();
803 SourceLocation EllipsisLoc = ReadSourceLocation();
804 SourceLocation RBracketLoc = ReadSourceLocation();
805 Designators.push_back(Designator(Index, LBracketLoc, EllipsisLoc,
811 E->setDesignators(Record.getContext(),
812 Designators.data(), Designators.size());
815 void ASTStmtReader::VisitDesignatedInitUpdateExpr(DesignatedInitUpdateExpr *E) {
817 E->setBase(Record.readSubExpr());
818 E->setUpdater(Record.readSubExpr());
821 void ASTStmtReader::VisitNoInitExpr(NoInitExpr *E) {
825 void ASTStmtReader::VisitArrayInitLoopExpr(ArrayInitLoopExpr *E) {
827 E->SubExprs[0] = Record.readSubExpr();
828 E->SubExprs[1] = Record.readSubExpr();
831 void ASTStmtReader::VisitArrayInitIndexExpr(ArrayInitIndexExpr *E) {
835 void ASTStmtReader::VisitImplicitValueInitExpr(ImplicitValueInitExpr *E) {
839 void ASTStmtReader::VisitVAArgExpr(VAArgExpr *E) {
841 E->setSubExpr(Record.readSubExpr());
842 E->setWrittenTypeInfo(GetTypeSourceInfo());
843 E->setBuiltinLoc(ReadSourceLocation());
844 E->setRParenLoc(ReadSourceLocation());
845 E->setIsMicrosoftABI(Record.readInt());
848 void ASTStmtReader::VisitAddrLabelExpr(AddrLabelExpr *E) {
850 E->setAmpAmpLoc(ReadSourceLocation());
851 E->setLabelLoc(ReadSourceLocation());
852 E->setLabel(ReadDeclAs<LabelDecl>());
855 void ASTStmtReader::VisitStmtExpr(StmtExpr *E) {
857 E->setLParenLoc(ReadSourceLocation());
858 E->setRParenLoc(ReadSourceLocation());
859 E->setSubStmt(cast_or_null<CompoundStmt>(Record.readSubStmt()));
862 void ASTStmtReader::VisitChooseExpr(ChooseExpr *E) {
864 E->setCond(Record.readSubExpr());
865 E->setLHS(Record.readSubExpr());
866 E->setRHS(Record.readSubExpr());
867 E->setBuiltinLoc(ReadSourceLocation());
868 E->setRParenLoc(ReadSourceLocation());
869 E->setIsConditionTrue(Record.readInt());
872 void ASTStmtReader::VisitGNUNullExpr(GNUNullExpr *E) {
874 E->setTokenLocation(ReadSourceLocation());
877 void ASTStmtReader::VisitShuffleVectorExpr(ShuffleVectorExpr *E) {
879 SmallVector<Expr *, 16> Exprs;
880 unsigned NumExprs = Record.readInt();
882 Exprs.push_back(Record.readSubExpr());
883 E->setExprs(Record.getContext(), Exprs);
884 E->setBuiltinLoc(ReadSourceLocation());
885 E->setRParenLoc(ReadSourceLocation());
888 void ASTStmtReader::VisitConvertVectorExpr(ConvertVectorExpr *E) {
890 E->BuiltinLoc = ReadSourceLocation();
891 E->RParenLoc = ReadSourceLocation();
892 E->TInfo = GetTypeSourceInfo();
893 E->SrcExpr = Record.readSubExpr();
896 void ASTStmtReader::VisitBlockExpr(BlockExpr *E) {
898 E->setBlockDecl(ReadDeclAs<BlockDecl>());
901 void ASTStmtReader::VisitGenericSelectionExpr(GenericSelectionExpr *E) {
903 E->NumAssocs = Record.readInt();
904 E->AssocTypes = new (Record.getContext()) TypeSourceInfo*[E->NumAssocs];
906 new(Record.getContext()) Stmt*[GenericSelectionExpr::END_EXPR+E->NumAssocs];
908 E->SubExprs[GenericSelectionExpr::CONTROLLING] = Record.readSubExpr();
909 for (unsigned I = 0, N = E->getNumAssocs(); I != N; ++I) {
910 E->AssocTypes[I] = GetTypeSourceInfo();
911 E->SubExprs[GenericSelectionExpr::END_EXPR+I] = Record.readSubExpr();
913 E->ResultIndex = Record.readInt();
915 E->GenericLoc = ReadSourceLocation();
916 E->DefaultLoc = ReadSourceLocation();
917 E->RParenLoc = ReadSourceLocation();
920 void ASTStmtReader::VisitPseudoObjectExpr(PseudoObjectExpr *E) {
922 unsigned numSemanticExprs = Record.readInt();
923 assert(numSemanticExprs + 1 == E->PseudoObjectExprBits.NumSubExprs);
924 E->PseudoObjectExprBits.ResultIndex = Record.readInt();
926 // Read the syntactic expression.
927 E->getSubExprsBuffer()[0] = Record.readSubExpr();
929 // Read all the semantic expressions.
930 for (unsigned i = 0; i != numSemanticExprs; ++i) {
931 Expr *subExpr = Record.readSubExpr();
932 E->getSubExprsBuffer()[i+1] = subExpr;
936 void ASTStmtReader::VisitAtomicExpr(AtomicExpr *E) {
938 E->Op = AtomicExpr::AtomicOp(Record.readInt());
939 E->NumSubExprs = AtomicExpr::getNumSubExprs(E->Op);
940 for (unsigned I = 0; I != E->NumSubExprs; ++I)
941 E->SubExprs[I] = Record.readSubExpr();
942 E->BuiltinLoc = ReadSourceLocation();
943 E->RParenLoc = ReadSourceLocation();
946 //===----------------------------------------------------------------------===//
947 // Objective-C Expressions and Statements
949 void ASTStmtReader::VisitObjCStringLiteral(ObjCStringLiteral *E) {
951 E->setString(cast<StringLiteral>(Record.readSubStmt()));
952 E->setAtLoc(ReadSourceLocation());
955 void ASTStmtReader::VisitObjCBoxedExpr(ObjCBoxedExpr *E) {
957 // could be one of several IntegerLiteral, FloatLiteral, etc.
958 E->SubExpr = Record.readSubStmt();
959 E->BoxingMethod = ReadDeclAs<ObjCMethodDecl>();
960 E->Range = ReadSourceRange();
963 void ASTStmtReader::VisitObjCArrayLiteral(ObjCArrayLiteral *E) {
965 unsigned NumElements = Record.readInt();
966 assert(NumElements == E->getNumElements() && "Wrong number of elements");
967 Expr **Elements = E->getElements();
968 for (unsigned I = 0, N = NumElements; I != N; ++I)
969 Elements[I] = Record.readSubExpr();
970 E->ArrayWithObjectsMethod = ReadDeclAs<ObjCMethodDecl>();
971 E->Range = ReadSourceRange();
974 void ASTStmtReader::VisitObjCDictionaryLiteral(ObjCDictionaryLiteral *E) {
976 unsigned NumElements = Record.readInt();
977 assert(NumElements == E->getNumElements() && "Wrong number of elements");
978 bool HasPackExpansions = Record.readInt();
979 assert(HasPackExpansions == E->HasPackExpansions &&"Pack expansion mismatch");
980 ObjCDictionaryLiteral::KeyValuePair *KeyValues =
981 E->getTrailingObjects<ObjCDictionaryLiteral::KeyValuePair>();
982 ObjCDictionaryLiteral::ExpansionData *Expansions =
983 E->getTrailingObjects<ObjCDictionaryLiteral::ExpansionData>();
984 for (unsigned I = 0; I != NumElements; ++I) {
985 KeyValues[I].Key = Record.readSubExpr();
986 KeyValues[I].Value = Record.readSubExpr();
987 if (HasPackExpansions) {
988 Expansions[I].EllipsisLoc = ReadSourceLocation();
989 Expansions[I].NumExpansionsPlusOne = Record.readInt();
992 E->DictWithObjectsMethod = ReadDeclAs<ObjCMethodDecl>();
993 E->Range = ReadSourceRange();
996 void ASTStmtReader::VisitObjCEncodeExpr(ObjCEncodeExpr *E) {
998 E->setEncodedTypeSourceInfo(GetTypeSourceInfo());
999 E->setAtLoc(ReadSourceLocation());
1000 E->setRParenLoc(ReadSourceLocation());
1003 void ASTStmtReader::VisitObjCSelectorExpr(ObjCSelectorExpr *E) {
1005 E->setSelector(Record.readSelector());
1006 E->setAtLoc(ReadSourceLocation());
1007 E->setRParenLoc(ReadSourceLocation());
1010 void ASTStmtReader::VisitObjCProtocolExpr(ObjCProtocolExpr *E) {
1012 E->setProtocol(ReadDeclAs<ObjCProtocolDecl>());
1013 E->setAtLoc(ReadSourceLocation());
1014 E->ProtoLoc = ReadSourceLocation();
1015 E->setRParenLoc(ReadSourceLocation());
1018 void ASTStmtReader::VisitObjCIvarRefExpr(ObjCIvarRefExpr *E) {
1020 E->setDecl(ReadDeclAs<ObjCIvarDecl>());
1021 E->setLocation(ReadSourceLocation());
1022 E->setOpLoc(ReadSourceLocation());
1023 E->setBase(Record.readSubExpr());
1024 E->setIsArrow(Record.readInt());
1025 E->setIsFreeIvar(Record.readInt());
1028 void ASTStmtReader::VisitObjCPropertyRefExpr(ObjCPropertyRefExpr *E) {
1030 unsigned MethodRefFlags = Record.readInt();
1031 bool Implicit = Record.readInt() != 0;
1033 ObjCMethodDecl *Getter = ReadDeclAs<ObjCMethodDecl>();
1034 ObjCMethodDecl *Setter = ReadDeclAs<ObjCMethodDecl>();
1035 E->setImplicitProperty(Getter, Setter, MethodRefFlags);
1037 E->setExplicitProperty(ReadDeclAs<ObjCPropertyDecl>(), MethodRefFlags);
1039 E->setLocation(ReadSourceLocation());
1040 E->setReceiverLocation(ReadSourceLocation());
1041 switch (Record.readInt()) {
1043 E->setBase(Record.readSubExpr());
1046 E->setSuperReceiver(Record.readType());
1049 E->setClassReceiver(ReadDeclAs<ObjCInterfaceDecl>());
1054 void ASTStmtReader::VisitObjCSubscriptRefExpr(ObjCSubscriptRefExpr *E) {
1056 E->setRBracket(ReadSourceLocation());
1057 E->setBaseExpr(Record.readSubExpr());
1058 E->setKeyExpr(Record.readSubExpr());
1059 E->GetAtIndexMethodDecl = ReadDeclAs<ObjCMethodDecl>();
1060 E->SetAtIndexMethodDecl = ReadDeclAs<ObjCMethodDecl>();
1063 void ASTStmtReader::VisitObjCMessageExpr(ObjCMessageExpr *E) {
1065 assert(Record.peekInt() == E->getNumArgs());
1067 unsigned NumStoredSelLocs = Record.readInt();
1068 E->SelLocsKind = Record.readInt();
1069 E->setDelegateInitCall(Record.readInt());
1070 E->IsImplicit = Record.readInt();
1071 ObjCMessageExpr::ReceiverKind Kind
1072 = static_cast<ObjCMessageExpr::ReceiverKind>(Record.readInt());
1074 case ObjCMessageExpr::Instance:
1075 E->setInstanceReceiver(Record.readSubExpr());
1078 case ObjCMessageExpr::Class:
1079 E->setClassReceiver(GetTypeSourceInfo());
1082 case ObjCMessageExpr::SuperClass:
1083 case ObjCMessageExpr::SuperInstance: {
1084 QualType T = Record.readType();
1085 SourceLocation SuperLoc = ReadSourceLocation();
1086 E->setSuper(SuperLoc, T, Kind == ObjCMessageExpr::SuperInstance);
1091 assert(Kind == E->getReceiverKind());
1093 if (Record.readInt())
1094 E->setMethodDecl(ReadDeclAs<ObjCMethodDecl>());
1096 E->setSelector(Record.readSelector());
1098 E->LBracLoc = ReadSourceLocation();
1099 E->RBracLoc = ReadSourceLocation();
1101 for (unsigned I = 0, N = E->getNumArgs(); I != N; ++I)
1102 E->setArg(I, Record.readSubExpr());
1104 SourceLocation *Locs = E->getStoredSelLocs();
1105 for (unsigned I = 0; I != NumStoredSelLocs; ++I)
1106 Locs[I] = ReadSourceLocation();
1109 void ASTStmtReader::VisitObjCForCollectionStmt(ObjCForCollectionStmt *S) {
1111 S->setElement(Record.readSubStmt());
1112 S->setCollection(Record.readSubExpr());
1113 S->setBody(Record.readSubStmt());
1114 S->setForLoc(ReadSourceLocation());
1115 S->setRParenLoc(ReadSourceLocation());
1118 void ASTStmtReader::VisitObjCAtCatchStmt(ObjCAtCatchStmt *S) {
1120 S->setCatchBody(Record.readSubStmt());
1121 S->setCatchParamDecl(ReadDeclAs<VarDecl>());
1122 S->setAtCatchLoc(ReadSourceLocation());
1123 S->setRParenLoc(ReadSourceLocation());
1126 void ASTStmtReader::VisitObjCAtFinallyStmt(ObjCAtFinallyStmt *S) {
1128 S->setFinallyBody(Record.readSubStmt());
1129 S->setAtFinallyLoc(ReadSourceLocation());
1132 void ASTStmtReader::VisitObjCAutoreleasePoolStmt(ObjCAutoreleasePoolStmt *S) {
1134 S->setSubStmt(Record.readSubStmt());
1135 S->setAtLoc(ReadSourceLocation());
1138 void ASTStmtReader::VisitObjCAtTryStmt(ObjCAtTryStmt *S) {
1140 assert(Record.peekInt() == S->getNumCatchStmts());
1142 bool HasFinally = Record.readInt();
1143 S->setTryBody(Record.readSubStmt());
1144 for (unsigned I = 0, N = S->getNumCatchStmts(); I != N; ++I)
1145 S->setCatchStmt(I, cast_or_null<ObjCAtCatchStmt>(Record.readSubStmt()));
1148 S->setFinallyStmt(Record.readSubStmt());
1149 S->setAtTryLoc(ReadSourceLocation());
1152 void ASTStmtReader::VisitObjCAtSynchronizedStmt(ObjCAtSynchronizedStmt *S) {
1154 S->setSynchExpr(Record.readSubStmt());
1155 S->setSynchBody(Record.readSubStmt());
1156 S->setAtSynchronizedLoc(ReadSourceLocation());
1159 void ASTStmtReader::VisitObjCAtThrowStmt(ObjCAtThrowStmt *S) {
1161 S->setThrowExpr(Record.readSubStmt());
1162 S->setThrowLoc(ReadSourceLocation());
1165 void ASTStmtReader::VisitObjCBoolLiteralExpr(ObjCBoolLiteralExpr *E) {
1167 E->setValue(Record.readInt());
1168 E->setLocation(ReadSourceLocation());
1171 void ASTStmtReader::VisitObjCAvailabilityCheckExpr(ObjCAvailabilityCheckExpr *E) {
1173 SourceRange R = Record.readSourceRange();
1174 E->AtLoc = R.getBegin();
1175 E->RParen = R.getEnd();
1176 E->VersionToCheck = Record.readVersionTuple();
1179 //===----------------------------------------------------------------------===//
1180 // C++ Expressions and Statements
1181 //===----------------------------------------------------------------------===//
1183 void ASTStmtReader::VisitCXXCatchStmt(CXXCatchStmt *S) {
1185 S->CatchLoc = ReadSourceLocation();
1186 S->ExceptionDecl = ReadDeclAs<VarDecl>();
1187 S->HandlerBlock = Record.readSubStmt();
1190 void ASTStmtReader::VisitCXXTryStmt(CXXTryStmt *S) {
1192 assert(Record.peekInt() == S->getNumHandlers() && "NumStmtFields is wrong ?");
1194 S->TryLoc = ReadSourceLocation();
1195 S->getStmts()[0] = Record.readSubStmt();
1196 for (unsigned i = 0, e = S->getNumHandlers(); i != e; ++i)
1197 S->getStmts()[i + 1] = Record.readSubStmt();
1200 void ASTStmtReader::VisitCXXForRangeStmt(CXXForRangeStmt *S) {
1202 S->ForLoc = ReadSourceLocation();
1203 S->CoawaitLoc = ReadSourceLocation();
1204 S->ColonLoc = ReadSourceLocation();
1205 S->RParenLoc = ReadSourceLocation();
1206 S->setRangeStmt(Record.readSubStmt());
1207 S->setBeginStmt(Record.readSubStmt());
1208 S->setEndStmt(Record.readSubStmt());
1209 S->setCond(Record.readSubExpr());
1210 S->setInc(Record.readSubExpr());
1211 S->setLoopVarStmt(Record.readSubStmt());
1212 S->setBody(Record.readSubStmt());
1215 void ASTStmtReader::VisitMSDependentExistsStmt(MSDependentExistsStmt *S) {
1217 S->KeywordLoc = ReadSourceLocation();
1218 S->IsIfExists = Record.readInt();
1219 S->QualifierLoc = Record.readNestedNameSpecifierLoc();
1220 ReadDeclarationNameInfo(S->NameInfo);
1221 S->SubStmt = Record.readSubStmt();
1224 void ASTStmtReader::VisitCXXOperatorCallExpr(CXXOperatorCallExpr *E) {
1226 E->Operator = (OverloadedOperatorKind)Record.readInt();
1227 E->Range = Record.readSourceRange();
1228 E->setFPFeatures(FPOptions(Record.readInt()));
1231 void ASTStmtReader::VisitCXXConstructExpr(CXXConstructExpr *E) {
1233 E->NumArgs = Record.readInt();
1235 E->Args = new (Record.getContext()) Stmt*[E->NumArgs];
1236 for (unsigned I = 0, N = E->getNumArgs(); I != N; ++I)
1237 E->setArg(I, Record.readSubExpr());
1238 E->setConstructor(ReadDeclAs<CXXConstructorDecl>());
1239 E->setLocation(ReadSourceLocation());
1240 E->setElidable(Record.readInt());
1241 E->setHadMultipleCandidates(Record.readInt());
1242 E->setListInitialization(Record.readInt());
1243 E->setStdInitListInitialization(Record.readInt());
1244 E->setRequiresZeroInitialization(Record.readInt());
1245 E->setConstructionKind((CXXConstructExpr::ConstructionKind)Record.readInt());
1246 E->ParenOrBraceRange = ReadSourceRange();
1249 void ASTStmtReader::VisitCXXInheritedCtorInitExpr(CXXInheritedCtorInitExpr *E) {
1251 E->Constructor = ReadDeclAs<CXXConstructorDecl>();
1252 E->Loc = ReadSourceLocation();
1253 E->ConstructsVirtualBase = Record.readInt();
1254 E->InheritedFromVirtualBase = Record.readInt();
1257 void ASTStmtReader::VisitCXXTemporaryObjectExpr(CXXTemporaryObjectExpr *E) {
1258 VisitCXXConstructExpr(E);
1259 E->Type = GetTypeSourceInfo();
1262 void ASTStmtReader::VisitLambdaExpr(LambdaExpr *E) {
1264 unsigned NumCaptures = Record.readInt();
1265 assert(NumCaptures == E->NumCaptures);(void)NumCaptures;
1266 E->IntroducerRange = ReadSourceRange();
1267 E->CaptureDefault = static_cast<LambdaCaptureDefault>(Record.readInt());
1268 E->CaptureDefaultLoc = ReadSourceLocation();
1269 E->ExplicitParams = Record.readInt();
1270 E->ExplicitResultType = Record.readInt();
1271 E->ClosingBrace = ReadSourceLocation();
1273 // Read capture initializers.
1274 for (LambdaExpr::capture_init_iterator C = E->capture_init_begin(),
1275 CEnd = E->capture_init_end();
1277 *C = Record.readSubExpr();
1281 ASTStmtReader::VisitCXXStdInitializerListExpr(CXXStdInitializerListExpr *E) {
1283 E->SubExpr = Record.readSubExpr();
1286 void ASTStmtReader::VisitCXXNamedCastExpr(CXXNamedCastExpr *E) {
1287 VisitExplicitCastExpr(E);
1288 SourceRange R = ReadSourceRange();
1289 E->Loc = R.getBegin();
1290 E->RParenLoc = R.getEnd();
1291 R = ReadSourceRange();
1292 E->AngleBrackets = R;
1295 void ASTStmtReader::VisitCXXStaticCastExpr(CXXStaticCastExpr *E) {
1296 return VisitCXXNamedCastExpr(E);
1299 void ASTStmtReader::VisitCXXDynamicCastExpr(CXXDynamicCastExpr *E) {
1300 return VisitCXXNamedCastExpr(E);
1303 void ASTStmtReader::VisitCXXReinterpretCastExpr(CXXReinterpretCastExpr *E) {
1304 return VisitCXXNamedCastExpr(E);
1307 void ASTStmtReader::VisitCXXConstCastExpr(CXXConstCastExpr *E) {
1308 return VisitCXXNamedCastExpr(E);
1311 void ASTStmtReader::VisitCXXFunctionalCastExpr(CXXFunctionalCastExpr *E) {
1312 VisitExplicitCastExpr(E);
1313 E->setLParenLoc(ReadSourceLocation());
1314 E->setRParenLoc(ReadSourceLocation());
1317 void ASTStmtReader::VisitUserDefinedLiteral(UserDefinedLiteral *E) {
1319 E->UDSuffixLoc = ReadSourceLocation();
1322 void ASTStmtReader::VisitCXXBoolLiteralExpr(CXXBoolLiteralExpr *E) {
1324 E->setValue(Record.readInt());
1325 E->setLocation(ReadSourceLocation());
1328 void ASTStmtReader::VisitCXXNullPtrLiteralExpr(CXXNullPtrLiteralExpr *E) {
1330 E->setLocation(ReadSourceLocation());
1333 void ASTStmtReader::VisitCXXTypeidExpr(CXXTypeidExpr *E) {
1335 E->setSourceRange(ReadSourceRange());
1336 if (E->isTypeOperand()) { // typeid(int)
1337 E->setTypeOperandSourceInfo(
1338 GetTypeSourceInfo());
1343 E->setExprOperand(Record.readSubExpr());
1346 void ASTStmtReader::VisitCXXThisExpr(CXXThisExpr *E) {
1348 E->setLocation(ReadSourceLocation());
1349 E->setImplicit(Record.readInt());
1352 void ASTStmtReader::VisitCXXThrowExpr(CXXThrowExpr *E) {
1354 E->ThrowLoc = ReadSourceLocation();
1355 E->Op = Record.readSubExpr();
1356 E->IsThrownVariableInScope = Record.readInt();
1359 void ASTStmtReader::VisitCXXDefaultArgExpr(CXXDefaultArgExpr *E) {
1361 E->Param = ReadDeclAs<ParmVarDecl>();
1362 E->Loc = ReadSourceLocation();
1365 void ASTStmtReader::VisitCXXDefaultInitExpr(CXXDefaultInitExpr *E) {
1367 E->Field = ReadDeclAs<FieldDecl>();
1368 E->Loc = ReadSourceLocation();
1371 void ASTStmtReader::VisitCXXBindTemporaryExpr(CXXBindTemporaryExpr *E) {
1373 E->setTemporary(Record.readCXXTemporary());
1374 E->setSubExpr(Record.readSubExpr());
1377 void ASTStmtReader::VisitCXXScalarValueInitExpr(CXXScalarValueInitExpr *E) {
1379 E->TypeInfo = GetTypeSourceInfo();
1380 E->RParenLoc = ReadSourceLocation();
1383 void ASTStmtReader::VisitCXXNewExpr(CXXNewExpr *E) {
1385 E->GlobalNew = Record.readInt();
1386 bool isArray = Record.readInt();
1387 E->PassAlignment = Record.readInt();
1388 E->UsualArrayDeleteWantsSize = Record.readInt();
1389 unsigned NumPlacementArgs = Record.readInt();
1390 E->StoredInitializationStyle = Record.readInt();
1391 E->setOperatorNew(ReadDeclAs<FunctionDecl>());
1392 E->setOperatorDelete(ReadDeclAs<FunctionDecl>());
1393 E->AllocatedTypeInfo = GetTypeSourceInfo();
1394 E->TypeIdParens = ReadSourceRange();
1395 E->Range = ReadSourceRange();
1396 E->DirectInitRange = ReadSourceRange();
1398 E->AllocateArgsArray(Record.getContext(), isArray, NumPlacementArgs,
1399 E->StoredInitializationStyle != 0);
1401 // Install all the subexpressions.
1402 for (CXXNewExpr::raw_arg_iterator I = E->raw_arg_begin(),e = E->raw_arg_end();
1404 *I = Record.readSubStmt();
1407 void ASTStmtReader::VisitCXXDeleteExpr(CXXDeleteExpr *E) {
1409 E->GlobalDelete = Record.readInt();
1410 E->ArrayForm = Record.readInt();
1411 E->ArrayFormAsWritten = Record.readInt();
1412 E->UsualArrayDeleteWantsSize = Record.readInt();
1413 E->OperatorDelete = ReadDeclAs<FunctionDecl>();
1414 E->Argument = Record.readSubExpr();
1415 E->Loc = ReadSourceLocation();
1418 void ASTStmtReader::VisitCXXPseudoDestructorExpr(CXXPseudoDestructorExpr *E) {
1421 E->Base = Record.readSubExpr();
1422 E->IsArrow = Record.readInt();
1423 E->OperatorLoc = ReadSourceLocation();
1424 E->QualifierLoc = Record.readNestedNameSpecifierLoc();
1425 E->ScopeType = GetTypeSourceInfo();
1426 E->ColonColonLoc = ReadSourceLocation();
1427 E->TildeLoc = ReadSourceLocation();
1429 IdentifierInfo *II = Record.getIdentifierInfo();
1431 E->setDestroyedType(II, ReadSourceLocation());
1433 E->setDestroyedType(GetTypeSourceInfo());
1436 void ASTStmtReader::VisitExprWithCleanups(ExprWithCleanups *E) {
1439 unsigned NumObjects = Record.readInt();
1440 assert(NumObjects == E->getNumObjects());
1441 for (unsigned i = 0; i != NumObjects; ++i)
1442 E->getTrailingObjects<BlockDecl *>()[i] =
1443 ReadDeclAs<BlockDecl>();
1445 E->ExprWithCleanupsBits.CleanupsHaveSideEffects = Record.readInt();
1446 E->SubExpr = Record.readSubExpr();
1450 ASTStmtReader::VisitCXXDependentScopeMemberExpr(CXXDependentScopeMemberExpr *E){
1453 if (Record.readInt()) // HasTemplateKWAndArgsInfo
1454 ReadTemplateKWAndArgsInfo(
1455 *E->getTrailingObjects<ASTTemplateKWAndArgsInfo>(),
1456 E->getTrailingObjects<TemplateArgumentLoc>(),
1457 /*NumTemplateArgs=*/Record.readInt());
1459 E->Base = Record.readSubExpr();
1460 E->BaseType = Record.readType();
1461 E->IsArrow = Record.readInt();
1462 E->OperatorLoc = ReadSourceLocation();
1463 E->QualifierLoc = Record.readNestedNameSpecifierLoc();
1464 E->FirstQualifierFoundInScope = ReadDeclAs<NamedDecl>();
1465 ReadDeclarationNameInfo(E->MemberNameInfo);
1469 ASTStmtReader::VisitDependentScopeDeclRefExpr(DependentScopeDeclRefExpr *E) {
1472 if (Record.readInt()) // HasTemplateKWAndArgsInfo
1473 ReadTemplateKWAndArgsInfo(
1474 *E->getTrailingObjects<ASTTemplateKWAndArgsInfo>(),
1475 E->getTrailingObjects<TemplateArgumentLoc>(),
1476 /*NumTemplateArgs=*/Record.readInt());
1478 E->QualifierLoc = Record.readNestedNameSpecifierLoc();
1479 ReadDeclarationNameInfo(E->NameInfo);
1483 ASTStmtReader::VisitCXXUnresolvedConstructExpr(CXXUnresolvedConstructExpr *E) {
1485 assert(Record.peekInt() == E->arg_size() &&
1486 "Read wrong record during creation ?");
1488 for (unsigned I = 0, N = E->arg_size(); I != N; ++I)
1489 E->setArg(I, Record.readSubExpr());
1490 E->Type = GetTypeSourceInfo();
1491 E->setLParenLoc(ReadSourceLocation());
1492 E->setRParenLoc(ReadSourceLocation());
1495 void ASTStmtReader::VisitOverloadExpr(OverloadExpr *E) {
1498 if (Record.readInt()) // HasTemplateKWAndArgsInfo
1499 ReadTemplateKWAndArgsInfo(*E->getTrailingASTTemplateKWAndArgsInfo(),
1500 E->getTrailingTemplateArgumentLoc(),
1501 /*NumTemplateArgs=*/Record.readInt());
1503 unsigned NumDecls = Record.readInt();
1504 UnresolvedSet<8> Decls;
1505 for (unsigned i = 0; i != NumDecls; ++i) {
1506 NamedDecl *D = ReadDeclAs<NamedDecl>();
1507 AccessSpecifier AS = (AccessSpecifier)Record.readInt();
1508 Decls.addDecl(D, AS);
1510 E->initializeResults(Record.getContext(), Decls.begin(), Decls.end());
1512 ReadDeclarationNameInfo(E->NameInfo);
1513 E->QualifierLoc = Record.readNestedNameSpecifierLoc();
1516 void ASTStmtReader::VisitUnresolvedMemberExpr(UnresolvedMemberExpr *E) {
1517 VisitOverloadExpr(E);
1518 E->IsArrow = Record.readInt();
1519 E->HasUnresolvedUsing = Record.readInt();
1520 E->Base = Record.readSubExpr();
1521 E->BaseType = Record.readType();
1522 E->OperatorLoc = ReadSourceLocation();
1525 void ASTStmtReader::VisitUnresolvedLookupExpr(UnresolvedLookupExpr *E) {
1526 VisitOverloadExpr(E);
1527 E->RequiresADL = Record.readInt();
1528 E->Overloaded = Record.readInt();
1529 E->NamingClass = ReadDeclAs<CXXRecordDecl>();
1532 void ASTStmtReader::VisitTypeTraitExpr(TypeTraitExpr *E) {
1534 E->TypeTraitExprBits.NumArgs = Record.readInt();
1535 E->TypeTraitExprBits.Kind = Record.readInt();
1536 E->TypeTraitExprBits.Value = Record.readInt();
1537 SourceRange Range = ReadSourceRange();
1538 E->Loc = Range.getBegin();
1539 E->RParenLoc = Range.getEnd();
1541 TypeSourceInfo **Args = E->getTrailingObjects<TypeSourceInfo *>();
1542 for (unsigned I = 0, N = E->getNumArgs(); I != N; ++I)
1543 Args[I] = GetTypeSourceInfo();
1546 void ASTStmtReader::VisitArrayTypeTraitExpr(ArrayTypeTraitExpr *E) {
1548 E->ATT = (ArrayTypeTrait)Record.readInt();
1549 E->Value = (unsigned int)Record.readInt();
1550 SourceRange Range = ReadSourceRange();
1551 E->Loc = Range.getBegin();
1552 E->RParen = Range.getEnd();
1553 E->QueriedType = GetTypeSourceInfo();
1554 E->Dimension = Record.readSubExpr();
1557 void ASTStmtReader::VisitExpressionTraitExpr(ExpressionTraitExpr *E) {
1559 E->ET = (ExpressionTrait)Record.readInt();
1560 E->Value = (bool)Record.readInt();
1561 SourceRange Range = ReadSourceRange();
1562 E->QueriedExpression = Record.readSubExpr();
1563 E->Loc = Range.getBegin();
1564 E->RParen = Range.getEnd();
1567 void ASTStmtReader::VisitCXXNoexceptExpr(CXXNoexceptExpr *E) {
1569 E->Value = (bool)Record.readInt();
1570 E->Range = ReadSourceRange();
1571 E->Operand = Record.readSubExpr();
1574 void ASTStmtReader::VisitPackExpansionExpr(PackExpansionExpr *E) {
1576 E->EllipsisLoc = ReadSourceLocation();
1577 E->NumExpansions = Record.readInt();
1578 E->Pattern = Record.readSubExpr();
1581 void ASTStmtReader::VisitSizeOfPackExpr(SizeOfPackExpr *E) {
1583 unsigned NumPartialArgs = Record.readInt();
1584 E->OperatorLoc = ReadSourceLocation();
1585 E->PackLoc = ReadSourceLocation();
1586 E->RParenLoc = ReadSourceLocation();
1587 E->Pack = Record.readDeclAs<NamedDecl>();
1588 if (E->isPartiallySubstituted()) {
1589 assert(E->Length == NumPartialArgs);
1590 for (auto *I = E->getTrailingObjects<TemplateArgument>(),
1591 *E = I + NumPartialArgs;
1593 new (I) TemplateArgument(Record.readTemplateArgument());
1594 } else if (!E->isValueDependent()) {
1595 E->Length = Record.readInt();
1599 void ASTStmtReader::VisitSubstNonTypeTemplateParmExpr(
1600 SubstNonTypeTemplateParmExpr *E) {
1602 E->Param = ReadDeclAs<NonTypeTemplateParmDecl>();
1603 E->NameLoc = ReadSourceLocation();
1604 E->Replacement = Record.readSubExpr();
1607 void ASTStmtReader::VisitSubstNonTypeTemplateParmPackExpr(
1608 SubstNonTypeTemplateParmPackExpr *E) {
1610 E->Param = ReadDeclAs<NonTypeTemplateParmDecl>();
1611 TemplateArgument ArgPack = Record.readTemplateArgument();
1612 if (ArgPack.getKind() != TemplateArgument::Pack)
1615 E->Arguments = ArgPack.pack_begin();
1616 E->NumArguments = ArgPack.pack_size();
1617 E->NameLoc = ReadSourceLocation();
1620 void ASTStmtReader::VisitFunctionParmPackExpr(FunctionParmPackExpr *E) {
1622 E->NumParameters = Record.readInt();
1623 E->ParamPack = ReadDeclAs<ParmVarDecl>();
1624 E->NameLoc = ReadSourceLocation();
1625 ParmVarDecl **Parms = E->getTrailingObjects<ParmVarDecl *>();
1626 for (unsigned i = 0, n = E->NumParameters; i != n; ++i)
1627 Parms[i] = ReadDeclAs<ParmVarDecl>();
1630 void ASTStmtReader::VisitMaterializeTemporaryExpr(MaterializeTemporaryExpr *E) {
1632 E->State = Record.readSubExpr();
1633 auto VD = ReadDeclAs<ValueDecl>();
1634 unsigned ManglingNumber = Record.readInt();
1635 E->setExtendingDecl(VD, ManglingNumber);
1638 void ASTStmtReader::VisitCXXFoldExpr(CXXFoldExpr *E) {
1640 E->LParenLoc = ReadSourceLocation();
1641 E->EllipsisLoc = ReadSourceLocation();
1642 E->RParenLoc = ReadSourceLocation();
1643 E->SubExprs[0] = Record.readSubExpr();
1644 E->SubExprs[1] = Record.readSubExpr();
1645 E->Opcode = (BinaryOperatorKind)Record.readInt();
1648 void ASTStmtReader::VisitOpaqueValueExpr(OpaqueValueExpr *E) {
1650 E->SourceExpr = Record.readSubExpr();
1651 E->Loc = ReadSourceLocation();
1654 void ASTStmtReader::VisitTypoExpr(TypoExpr *E) {
1655 llvm_unreachable("Cannot read TypoExpr nodes");
1658 //===----------------------------------------------------------------------===//
1659 // Microsoft Expressions and Statements
1660 //===----------------------------------------------------------------------===//
1661 void ASTStmtReader::VisitMSPropertyRefExpr(MSPropertyRefExpr *E) {
1663 E->IsArrow = (Record.readInt() != 0);
1664 E->BaseExpr = Record.readSubExpr();
1665 E->QualifierLoc = Record.readNestedNameSpecifierLoc();
1666 E->MemberLoc = ReadSourceLocation();
1667 E->TheDecl = ReadDeclAs<MSPropertyDecl>();
1670 void ASTStmtReader::VisitMSPropertySubscriptExpr(MSPropertySubscriptExpr *E) {
1672 E->setBase(Record.readSubExpr());
1673 E->setIdx(Record.readSubExpr());
1674 E->setRBracketLoc(ReadSourceLocation());
1677 void ASTStmtReader::VisitCXXUuidofExpr(CXXUuidofExpr *E) {
1679 E->setSourceRange(ReadSourceRange());
1680 std::string UuidStr = ReadString();
1681 E->setUuidStr(StringRef(UuidStr).copy(Record.getContext()));
1682 if (E->isTypeOperand()) { // __uuidof(ComType)
1683 E->setTypeOperandSourceInfo(
1684 GetTypeSourceInfo());
1689 E->setExprOperand(Record.readSubExpr());
1692 void ASTStmtReader::VisitSEHLeaveStmt(SEHLeaveStmt *S) {
1694 S->setLeaveLoc(ReadSourceLocation());
1697 void ASTStmtReader::VisitSEHExceptStmt(SEHExceptStmt *S) {
1699 S->Loc = ReadSourceLocation();
1700 S->Children[SEHExceptStmt::FILTER_EXPR] = Record.readSubStmt();
1701 S->Children[SEHExceptStmt::BLOCK] = Record.readSubStmt();
1704 void ASTStmtReader::VisitSEHFinallyStmt(SEHFinallyStmt *S) {
1706 S->Loc = ReadSourceLocation();
1707 S->Block = Record.readSubStmt();
1710 void ASTStmtReader::VisitSEHTryStmt(SEHTryStmt *S) {
1712 S->IsCXXTry = Record.readInt();
1713 S->TryLoc = ReadSourceLocation();
1714 S->Children[SEHTryStmt::TRY] = Record.readSubStmt();
1715 S->Children[SEHTryStmt::HANDLER] = Record.readSubStmt();
1718 //===----------------------------------------------------------------------===//
1719 // CUDA Expressions and Statements
1720 //===----------------------------------------------------------------------===//
1722 void ASTStmtReader::VisitCUDAKernelCallExpr(CUDAKernelCallExpr *E) {
1724 E->setConfig(cast<CallExpr>(Record.readSubExpr()));
1727 //===----------------------------------------------------------------------===//
1728 // OpenCL Expressions and Statements.
1729 //===----------------------------------------------------------------------===//
1730 void ASTStmtReader::VisitAsTypeExpr(AsTypeExpr *E) {
1732 E->BuiltinLoc = ReadSourceLocation();
1733 E->RParenLoc = ReadSourceLocation();
1734 E->SrcExpr = Record.readSubExpr();
1737 //===----------------------------------------------------------------------===//
1739 //===----------------------------------------------------------------------===//
1742 class OMPClauseReader : public OMPClauseVisitor<OMPClauseReader> {
1743 ASTStmtReader *Reader;
1744 ASTContext &Context;
1746 OMPClauseReader(ASTStmtReader *R, ASTRecordReader &Record)
1747 : Reader(R), Context(Record.getContext()) {}
1748 #define OPENMP_CLAUSE(Name, Class) void Visit##Class(Class *C);
1749 #include "clang/Basic/OpenMPKinds.def"
1750 OMPClause *readClause();
1751 void VisitOMPClauseWithPreInit(OMPClauseWithPreInit *C);
1752 void VisitOMPClauseWithPostUpdate(OMPClauseWithPostUpdate *C);
1756 OMPClause *OMPClauseReader::readClause() {
1758 switch (Reader->Record.readInt()) {
1760 C = new (Context) OMPIfClause();
1763 C = new (Context) OMPFinalClause();
1765 case OMPC_num_threads:
1766 C = new (Context) OMPNumThreadsClause();
1769 C = new (Context) OMPSafelenClause();
1772 C = new (Context) OMPSimdlenClause();
1775 C = new (Context) OMPCollapseClause();
1778 C = new (Context) OMPDefaultClause();
1780 case OMPC_proc_bind:
1781 C = new (Context) OMPProcBindClause();
1784 C = new (Context) OMPScheduleClause();
1787 C = new (Context) OMPOrderedClause();
1790 C = new (Context) OMPNowaitClause();
1793 C = new (Context) OMPUntiedClause();
1795 case OMPC_mergeable:
1796 C = new (Context) OMPMergeableClause();
1799 C = new (Context) OMPReadClause();
1802 C = new (Context) OMPWriteClause();
1805 C = new (Context) OMPUpdateClause();
1808 C = new (Context) OMPCaptureClause();
1811 C = new (Context) OMPSeqCstClause();
1814 C = new (Context) OMPThreadsClause();
1817 C = new (Context) OMPSIMDClause();
1820 C = new (Context) OMPNogroupClause();
1823 C = OMPPrivateClause::CreateEmpty(Context, Reader->Record.readInt());
1825 case OMPC_firstprivate:
1826 C = OMPFirstprivateClause::CreateEmpty(Context, Reader->Record.readInt());
1828 case OMPC_lastprivate:
1829 C = OMPLastprivateClause::CreateEmpty(Context, Reader->Record.readInt());
1832 C = OMPSharedClause::CreateEmpty(Context, Reader->Record.readInt());
1834 case OMPC_reduction:
1835 C = OMPReductionClause::CreateEmpty(Context, Reader->Record.readInt());
1838 C = OMPLinearClause::CreateEmpty(Context, Reader->Record.readInt());
1841 C = OMPAlignedClause::CreateEmpty(Context, Reader->Record.readInt());
1844 C = OMPCopyinClause::CreateEmpty(Context, Reader->Record.readInt());
1846 case OMPC_copyprivate:
1847 C = OMPCopyprivateClause::CreateEmpty(Context, Reader->Record.readInt());
1850 C = OMPFlushClause::CreateEmpty(Context, Reader->Record.readInt());
1853 C = OMPDependClause::CreateEmpty(Context, Reader->Record.readInt());
1856 C = new (Context) OMPDeviceClause();
1859 unsigned NumVars = Reader->Record.readInt();
1860 unsigned NumDeclarations = Reader->Record.readInt();
1861 unsigned NumLists = Reader->Record.readInt();
1862 unsigned NumComponents = Reader->Record.readInt();
1863 C = OMPMapClause::CreateEmpty(Context, NumVars, NumDeclarations, NumLists,
1867 case OMPC_num_teams:
1868 C = new (Context) OMPNumTeamsClause();
1870 case OMPC_thread_limit:
1871 C = new (Context) OMPThreadLimitClause();
1874 C = new (Context) OMPPriorityClause();
1876 case OMPC_grainsize:
1877 C = new (Context) OMPGrainsizeClause();
1879 case OMPC_num_tasks:
1880 C = new (Context) OMPNumTasksClause();
1883 C = new (Context) OMPHintClause();
1885 case OMPC_dist_schedule:
1886 C = new (Context) OMPDistScheduleClause();
1888 case OMPC_defaultmap:
1889 C = new (Context) OMPDefaultmapClause();
1892 unsigned NumVars = Reader->Record.readInt();
1893 unsigned NumDeclarations = Reader->Record.readInt();
1894 unsigned NumLists = Reader->Record.readInt();
1895 unsigned NumComponents = Reader->Record.readInt();
1896 C = OMPToClause::CreateEmpty(Context, NumVars, NumDeclarations, NumLists,
1901 unsigned NumVars = Reader->Record.readInt();
1902 unsigned NumDeclarations = Reader->Record.readInt();
1903 unsigned NumLists = Reader->Record.readInt();
1904 unsigned NumComponents = Reader->Record.readInt();
1905 C = OMPFromClause::CreateEmpty(Context, NumVars, NumDeclarations, NumLists,
1909 case OMPC_use_device_ptr: {
1910 unsigned NumVars = Reader->Record.readInt();
1911 unsigned NumDeclarations = Reader->Record.readInt();
1912 unsigned NumLists = Reader->Record.readInt();
1913 unsigned NumComponents = Reader->Record.readInt();
1914 C = OMPUseDevicePtrClause::CreateEmpty(Context, NumVars, NumDeclarations,
1915 NumLists, NumComponents);
1918 case OMPC_is_device_ptr: {
1919 unsigned NumVars = Reader->Record.readInt();
1920 unsigned NumDeclarations = Reader->Record.readInt();
1921 unsigned NumLists = Reader->Record.readInt();
1922 unsigned NumComponents = Reader->Record.readInt();
1923 C = OMPIsDevicePtrClause::CreateEmpty(Context, NumVars, NumDeclarations,
1924 NumLists, NumComponents);
1929 C->setLocStart(Reader->ReadSourceLocation());
1930 C->setLocEnd(Reader->ReadSourceLocation());
1935 void OMPClauseReader::VisitOMPClauseWithPreInit(OMPClauseWithPreInit *C) {
1936 C->setPreInitStmt(Reader->Record.readSubStmt(),
1937 static_cast<OpenMPDirectiveKind>(Reader->Record.readInt()));
1940 void OMPClauseReader::VisitOMPClauseWithPostUpdate(OMPClauseWithPostUpdate *C) {
1941 VisitOMPClauseWithPreInit(C);
1942 C->setPostUpdateExpr(Reader->Record.readSubExpr());
1945 void OMPClauseReader::VisitOMPIfClause(OMPIfClause *C) {
1946 VisitOMPClauseWithPreInit(C);
1947 C->setNameModifier(static_cast<OpenMPDirectiveKind>(Reader->Record.readInt()));
1948 C->setNameModifierLoc(Reader->ReadSourceLocation());
1949 C->setColonLoc(Reader->ReadSourceLocation());
1950 C->setCondition(Reader->Record.readSubExpr());
1951 C->setLParenLoc(Reader->ReadSourceLocation());
1954 void OMPClauseReader::VisitOMPFinalClause(OMPFinalClause *C) {
1955 C->setCondition(Reader->Record.readSubExpr());
1956 C->setLParenLoc(Reader->ReadSourceLocation());
1959 void OMPClauseReader::VisitOMPNumThreadsClause(OMPNumThreadsClause *C) {
1960 VisitOMPClauseWithPreInit(C);
1961 C->setNumThreads(Reader->Record.readSubExpr());
1962 C->setLParenLoc(Reader->ReadSourceLocation());
1965 void OMPClauseReader::VisitOMPSafelenClause(OMPSafelenClause *C) {
1966 C->setSafelen(Reader->Record.readSubExpr());
1967 C->setLParenLoc(Reader->ReadSourceLocation());
1970 void OMPClauseReader::VisitOMPSimdlenClause(OMPSimdlenClause *C) {
1971 C->setSimdlen(Reader->Record.readSubExpr());
1972 C->setLParenLoc(Reader->ReadSourceLocation());
1975 void OMPClauseReader::VisitOMPCollapseClause(OMPCollapseClause *C) {
1976 C->setNumForLoops(Reader->Record.readSubExpr());
1977 C->setLParenLoc(Reader->ReadSourceLocation());
1980 void OMPClauseReader::VisitOMPDefaultClause(OMPDefaultClause *C) {
1982 static_cast<OpenMPDefaultClauseKind>(Reader->Record.readInt()));
1983 C->setLParenLoc(Reader->ReadSourceLocation());
1984 C->setDefaultKindKwLoc(Reader->ReadSourceLocation());
1987 void OMPClauseReader::VisitOMPProcBindClause(OMPProcBindClause *C) {
1989 static_cast<OpenMPProcBindClauseKind>(Reader->Record.readInt()));
1990 C->setLParenLoc(Reader->ReadSourceLocation());
1991 C->setProcBindKindKwLoc(Reader->ReadSourceLocation());
1994 void OMPClauseReader::VisitOMPScheduleClause(OMPScheduleClause *C) {
1995 VisitOMPClauseWithPreInit(C);
1997 static_cast<OpenMPScheduleClauseKind>(Reader->Record.readInt()));
1998 C->setFirstScheduleModifier(
1999 static_cast<OpenMPScheduleClauseModifier>(Reader->Record.readInt()));
2000 C->setSecondScheduleModifier(
2001 static_cast<OpenMPScheduleClauseModifier>(Reader->Record.readInt()));
2002 C->setChunkSize(Reader->Record.readSubExpr());
2003 C->setLParenLoc(Reader->ReadSourceLocation());
2004 C->setFirstScheduleModifierLoc(Reader->ReadSourceLocation());
2005 C->setSecondScheduleModifierLoc(Reader->ReadSourceLocation());
2006 C->setScheduleKindLoc(Reader->ReadSourceLocation());
2007 C->setCommaLoc(Reader->ReadSourceLocation());
2010 void OMPClauseReader::VisitOMPOrderedClause(OMPOrderedClause *C) {
2011 C->setNumForLoops(Reader->Record.readSubExpr());
2012 C->setLParenLoc(Reader->ReadSourceLocation());
2015 void OMPClauseReader::VisitOMPNowaitClause(OMPNowaitClause *) {}
2017 void OMPClauseReader::VisitOMPUntiedClause(OMPUntiedClause *) {}
2019 void OMPClauseReader::VisitOMPMergeableClause(OMPMergeableClause *) {}
2021 void OMPClauseReader::VisitOMPReadClause(OMPReadClause *) {}
2023 void OMPClauseReader::VisitOMPWriteClause(OMPWriteClause *) {}
2025 void OMPClauseReader::VisitOMPUpdateClause(OMPUpdateClause *) {}
2027 void OMPClauseReader::VisitOMPCaptureClause(OMPCaptureClause *) {}
2029 void OMPClauseReader::VisitOMPSeqCstClause(OMPSeqCstClause *) {}
2031 void OMPClauseReader::VisitOMPThreadsClause(OMPThreadsClause *) {}
2033 void OMPClauseReader::VisitOMPSIMDClause(OMPSIMDClause *) {}
2035 void OMPClauseReader::VisitOMPNogroupClause(OMPNogroupClause *) {}
2037 void OMPClauseReader::VisitOMPPrivateClause(OMPPrivateClause *C) {
2038 C->setLParenLoc(Reader->ReadSourceLocation());
2039 unsigned NumVars = C->varlist_size();
2040 SmallVector<Expr *, 16> Vars;
2041 Vars.reserve(NumVars);
2042 for (unsigned i = 0; i != NumVars; ++i)
2043 Vars.push_back(Reader->Record.readSubExpr());
2044 C->setVarRefs(Vars);
2046 for (unsigned i = 0; i != NumVars; ++i)
2047 Vars.push_back(Reader->Record.readSubExpr());
2048 C->setPrivateCopies(Vars);
2051 void OMPClauseReader::VisitOMPFirstprivateClause(OMPFirstprivateClause *C) {
2052 VisitOMPClauseWithPreInit(C);
2053 C->setLParenLoc(Reader->ReadSourceLocation());
2054 unsigned NumVars = C->varlist_size();
2055 SmallVector<Expr *, 16> Vars;
2056 Vars.reserve(NumVars);
2057 for (unsigned i = 0; i != NumVars; ++i)
2058 Vars.push_back(Reader->Record.readSubExpr());
2059 C->setVarRefs(Vars);
2061 for (unsigned i = 0; i != NumVars; ++i)
2062 Vars.push_back(Reader->Record.readSubExpr());
2063 C->setPrivateCopies(Vars);
2065 for (unsigned i = 0; i != NumVars; ++i)
2066 Vars.push_back(Reader->Record.readSubExpr());
2070 void OMPClauseReader::VisitOMPLastprivateClause(OMPLastprivateClause *C) {
2071 VisitOMPClauseWithPostUpdate(C);
2072 C->setLParenLoc(Reader->ReadSourceLocation());
2073 unsigned NumVars = C->varlist_size();
2074 SmallVector<Expr *, 16> Vars;
2075 Vars.reserve(NumVars);
2076 for (unsigned i = 0; i != NumVars; ++i)
2077 Vars.push_back(Reader->Record.readSubExpr());
2078 C->setVarRefs(Vars);
2080 for (unsigned i = 0; i != NumVars; ++i)
2081 Vars.push_back(Reader->Record.readSubExpr());
2082 C->setPrivateCopies(Vars);
2084 for (unsigned i = 0; i != NumVars; ++i)
2085 Vars.push_back(Reader->Record.readSubExpr());
2086 C->setSourceExprs(Vars);
2088 for (unsigned i = 0; i != NumVars; ++i)
2089 Vars.push_back(Reader->Record.readSubExpr());
2090 C->setDestinationExprs(Vars);
2092 for (unsigned i = 0; i != NumVars; ++i)
2093 Vars.push_back(Reader->Record.readSubExpr());
2094 C->setAssignmentOps(Vars);
2097 void OMPClauseReader::VisitOMPSharedClause(OMPSharedClause *C) {
2098 C->setLParenLoc(Reader->ReadSourceLocation());
2099 unsigned NumVars = C->varlist_size();
2100 SmallVector<Expr *, 16> Vars;
2101 Vars.reserve(NumVars);
2102 for (unsigned i = 0; i != NumVars; ++i)
2103 Vars.push_back(Reader->Record.readSubExpr());
2104 C->setVarRefs(Vars);
2107 void OMPClauseReader::VisitOMPReductionClause(OMPReductionClause *C) {
2108 VisitOMPClauseWithPostUpdate(C);
2109 C->setLParenLoc(Reader->ReadSourceLocation());
2110 C->setColonLoc(Reader->ReadSourceLocation());
2111 NestedNameSpecifierLoc NNSL = Reader->Record.readNestedNameSpecifierLoc();
2112 DeclarationNameInfo DNI;
2113 Reader->ReadDeclarationNameInfo(DNI);
2114 C->setQualifierLoc(NNSL);
2115 C->setNameInfo(DNI);
2117 unsigned NumVars = C->varlist_size();
2118 SmallVector<Expr *, 16> Vars;
2119 Vars.reserve(NumVars);
2120 for (unsigned i = 0; i != NumVars; ++i)
2121 Vars.push_back(Reader->Record.readSubExpr());
2122 C->setVarRefs(Vars);
2124 for (unsigned i = 0; i != NumVars; ++i)
2125 Vars.push_back(Reader->Record.readSubExpr());
2126 C->setPrivates(Vars);
2128 for (unsigned i = 0; i != NumVars; ++i)
2129 Vars.push_back(Reader->Record.readSubExpr());
2130 C->setLHSExprs(Vars);
2132 for (unsigned i = 0; i != NumVars; ++i)
2133 Vars.push_back(Reader->Record.readSubExpr());
2134 C->setRHSExprs(Vars);
2136 for (unsigned i = 0; i != NumVars; ++i)
2137 Vars.push_back(Reader->Record.readSubExpr());
2138 C->setReductionOps(Vars);
2141 void OMPClauseReader::VisitOMPLinearClause(OMPLinearClause *C) {
2142 VisitOMPClauseWithPostUpdate(C);
2143 C->setLParenLoc(Reader->ReadSourceLocation());
2144 C->setColonLoc(Reader->ReadSourceLocation());
2145 C->setModifier(static_cast<OpenMPLinearClauseKind>(Reader->Record.readInt()));
2146 C->setModifierLoc(Reader->ReadSourceLocation());
2147 unsigned NumVars = C->varlist_size();
2148 SmallVector<Expr *, 16> Vars;
2149 Vars.reserve(NumVars);
2150 for (unsigned i = 0; i != NumVars; ++i)
2151 Vars.push_back(Reader->Record.readSubExpr());
2152 C->setVarRefs(Vars);
2154 for (unsigned i = 0; i != NumVars; ++i)
2155 Vars.push_back(Reader->Record.readSubExpr());
2156 C->setPrivates(Vars);
2158 for (unsigned i = 0; i != NumVars; ++i)
2159 Vars.push_back(Reader->Record.readSubExpr());
2162 for (unsigned i = 0; i != NumVars; ++i)
2163 Vars.push_back(Reader->Record.readSubExpr());
2164 C->setUpdates(Vars);
2166 for (unsigned i = 0; i != NumVars; ++i)
2167 Vars.push_back(Reader->Record.readSubExpr());
2169 C->setStep(Reader->Record.readSubExpr());
2170 C->setCalcStep(Reader->Record.readSubExpr());
2173 void OMPClauseReader::VisitOMPAlignedClause(OMPAlignedClause *C) {
2174 C->setLParenLoc(Reader->ReadSourceLocation());
2175 C->setColonLoc(Reader->ReadSourceLocation());
2176 unsigned NumVars = C->varlist_size();
2177 SmallVector<Expr *, 16> Vars;
2178 Vars.reserve(NumVars);
2179 for (unsigned i = 0; i != NumVars; ++i)
2180 Vars.push_back(Reader->Record.readSubExpr());
2181 C->setVarRefs(Vars);
2182 C->setAlignment(Reader->Record.readSubExpr());
2185 void OMPClauseReader::VisitOMPCopyinClause(OMPCopyinClause *C) {
2186 C->setLParenLoc(Reader->ReadSourceLocation());
2187 unsigned NumVars = C->varlist_size();
2188 SmallVector<Expr *, 16> Exprs;
2189 Exprs.reserve(NumVars);
2190 for (unsigned i = 0; i != NumVars; ++i)
2191 Exprs.push_back(Reader->Record.readSubExpr());
2192 C->setVarRefs(Exprs);
2194 for (unsigned i = 0; i != NumVars; ++i)
2195 Exprs.push_back(Reader->Record.readSubExpr());
2196 C->setSourceExprs(Exprs);
2198 for (unsigned i = 0; i != NumVars; ++i)
2199 Exprs.push_back(Reader->Record.readSubExpr());
2200 C->setDestinationExprs(Exprs);
2202 for (unsigned i = 0; i != NumVars; ++i)
2203 Exprs.push_back(Reader->Record.readSubExpr());
2204 C->setAssignmentOps(Exprs);
2207 void OMPClauseReader::VisitOMPCopyprivateClause(OMPCopyprivateClause *C) {
2208 C->setLParenLoc(Reader->ReadSourceLocation());
2209 unsigned NumVars = C->varlist_size();
2210 SmallVector<Expr *, 16> Exprs;
2211 Exprs.reserve(NumVars);
2212 for (unsigned i = 0; i != NumVars; ++i)
2213 Exprs.push_back(Reader->Record.readSubExpr());
2214 C->setVarRefs(Exprs);
2216 for (unsigned i = 0; i != NumVars; ++i)
2217 Exprs.push_back(Reader->Record.readSubExpr());
2218 C->setSourceExprs(Exprs);
2220 for (unsigned i = 0; i != NumVars; ++i)
2221 Exprs.push_back(Reader->Record.readSubExpr());
2222 C->setDestinationExprs(Exprs);
2224 for (unsigned i = 0; i != NumVars; ++i)
2225 Exprs.push_back(Reader->Record.readSubExpr());
2226 C->setAssignmentOps(Exprs);
2229 void OMPClauseReader::VisitOMPFlushClause(OMPFlushClause *C) {
2230 C->setLParenLoc(Reader->ReadSourceLocation());
2231 unsigned NumVars = C->varlist_size();
2232 SmallVector<Expr *, 16> Vars;
2233 Vars.reserve(NumVars);
2234 for (unsigned i = 0; i != NumVars; ++i)
2235 Vars.push_back(Reader->Record.readSubExpr());
2236 C->setVarRefs(Vars);
2239 void OMPClauseReader::VisitOMPDependClause(OMPDependClause *C) {
2240 C->setLParenLoc(Reader->ReadSourceLocation());
2241 C->setDependencyKind(
2242 static_cast<OpenMPDependClauseKind>(Reader->Record.readInt()));
2243 C->setDependencyLoc(Reader->ReadSourceLocation());
2244 C->setColonLoc(Reader->ReadSourceLocation());
2245 unsigned NumVars = C->varlist_size();
2246 SmallVector<Expr *, 16> Vars;
2247 Vars.reserve(NumVars);
2248 for (unsigned i = 0; i != NumVars; ++i)
2249 Vars.push_back(Reader->Record.readSubExpr());
2250 C->setVarRefs(Vars);
2251 C->setCounterValue(Reader->Record.readSubExpr());
2254 void OMPClauseReader::VisitOMPDeviceClause(OMPDeviceClause *C) {
2255 C->setDevice(Reader->Record.readSubExpr());
2256 C->setLParenLoc(Reader->ReadSourceLocation());
2259 void OMPClauseReader::VisitOMPMapClause(OMPMapClause *C) {
2260 C->setLParenLoc(Reader->ReadSourceLocation());
2261 C->setMapTypeModifier(
2262 static_cast<OpenMPMapClauseKind>(Reader->Record.readInt()));
2264 static_cast<OpenMPMapClauseKind>(Reader->Record.readInt()));
2265 C->setMapLoc(Reader->ReadSourceLocation());
2266 C->setColonLoc(Reader->ReadSourceLocation());
2267 auto NumVars = C->varlist_size();
2268 auto UniqueDecls = C->getUniqueDeclarationsNum();
2269 auto TotalLists = C->getTotalComponentListNum();
2270 auto TotalComponents = C->getTotalComponentsNum();
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);
2278 SmallVector<ValueDecl *, 16> Decls;
2279 Decls.reserve(UniqueDecls);
2280 for (unsigned i = 0; i < UniqueDecls; ++i)
2281 Decls.push_back(Reader->Record.readDeclAs<ValueDecl>());
2282 C->setUniqueDecls(Decls);
2284 SmallVector<unsigned, 16> ListsPerDecl;
2285 ListsPerDecl.reserve(UniqueDecls);
2286 for (unsigned i = 0; i < UniqueDecls; ++i)
2287 ListsPerDecl.push_back(Reader->Record.readInt());
2288 C->setDeclNumLists(ListsPerDecl);
2290 SmallVector<unsigned, 32> ListSizes;
2291 ListSizes.reserve(TotalLists);
2292 for (unsigned i = 0; i < TotalLists; ++i)
2293 ListSizes.push_back(Reader->Record.readInt());
2294 C->setComponentListSizes(ListSizes);
2296 SmallVector<OMPClauseMappableExprCommon::MappableComponent, 32> Components;
2297 Components.reserve(TotalComponents);
2298 for (unsigned i = 0; i < TotalComponents; ++i) {
2299 Expr *AssociatedExpr = Reader->Record.readSubExpr();
2300 ValueDecl *AssociatedDecl = Reader->Record.readDeclAs<ValueDecl>();
2301 Components.push_back(OMPClauseMappableExprCommon::MappableComponent(
2302 AssociatedExpr, AssociatedDecl));
2304 C->setComponents(Components, ListSizes);
2307 void OMPClauseReader::VisitOMPNumTeamsClause(OMPNumTeamsClause *C) {
2308 VisitOMPClauseWithPreInit(C);
2309 C->setNumTeams(Reader->Record.readSubExpr());
2310 C->setLParenLoc(Reader->ReadSourceLocation());
2313 void OMPClauseReader::VisitOMPThreadLimitClause(OMPThreadLimitClause *C) {
2314 VisitOMPClauseWithPreInit(C);
2315 C->setThreadLimit(Reader->Record.readSubExpr());
2316 C->setLParenLoc(Reader->ReadSourceLocation());
2319 void OMPClauseReader::VisitOMPPriorityClause(OMPPriorityClause *C) {
2320 C->setPriority(Reader->Record.readSubExpr());
2321 C->setLParenLoc(Reader->ReadSourceLocation());
2324 void OMPClauseReader::VisitOMPGrainsizeClause(OMPGrainsizeClause *C) {
2325 C->setGrainsize(Reader->Record.readSubExpr());
2326 C->setLParenLoc(Reader->ReadSourceLocation());
2329 void OMPClauseReader::VisitOMPNumTasksClause(OMPNumTasksClause *C) {
2330 C->setNumTasks(Reader->Record.readSubExpr());
2331 C->setLParenLoc(Reader->ReadSourceLocation());
2334 void OMPClauseReader::VisitOMPHintClause(OMPHintClause *C) {
2335 C->setHint(Reader->Record.readSubExpr());
2336 C->setLParenLoc(Reader->ReadSourceLocation());
2339 void OMPClauseReader::VisitOMPDistScheduleClause(OMPDistScheduleClause *C) {
2340 VisitOMPClauseWithPreInit(C);
2341 C->setDistScheduleKind(
2342 static_cast<OpenMPDistScheduleClauseKind>(Reader->Record.readInt()));
2343 C->setChunkSize(Reader->Record.readSubExpr());
2344 C->setLParenLoc(Reader->ReadSourceLocation());
2345 C->setDistScheduleKindLoc(Reader->ReadSourceLocation());
2346 C->setCommaLoc(Reader->ReadSourceLocation());
2349 void OMPClauseReader::VisitOMPDefaultmapClause(OMPDefaultmapClause *C) {
2350 C->setDefaultmapKind(
2351 static_cast<OpenMPDefaultmapClauseKind>(Reader->Record.readInt()));
2352 C->setDefaultmapModifier(
2353 static_cast<OpenMPDefaultmapClauseModifier>(Reader->Record.readInt()));
2354 C->setLParenLoc(Reader->ReadSourceLocation());
2355 C->setDefaultmapModifierLoc(Reader->ReadSourceLocation());
2356 C->setDefaultmapKindLoc(Reader->ReadSourceLocation());
2359 void OMPClauseReader::VisitOMPToClause(OMPToClause *C) {
2360 C->setLParenLoc(Reader->ReadSourceLocation());
2361 auto NumVars = C->varlist_size();
2362 auto UniqueDecls = C->getUniqueDeclarationsNum();
2363 auto TotalLists = C->getTotalComponentListNum();
2364 auto TotalComponents = C->getTotalComponentsNum();
2366 SmallVector<Expr *, 16> Vars;
2367 Vars.reserve(NumVars);
2368 for (unsigned i = 0; i != NumVars; ++i)
2369 Vars.push_back(Reader->Record.readSubExpr());
2370 C->setVarRefs(Vars);
2372 SmallVector<ValueDecl *, 16> Decls;
2373 Decls.reserve(UniqueDecls);
2374 for (unsigned i = 0; i < UniqueDecls; ++i)
2375 Decls.push_back(Reader->Record.readDeclAs<ValueDecl>());
2376 C->setUniqueDecls(Decls);
2378 SmallVector<unsigned, 16> ListsPerDecl;
2379 ListsPerDecl.reserve(UniqueDecls);
2380 for (unsigned i = 0; i < UniqueDecls; ++i)
2381 ListsPerDecl.push_back(Reader->Record.readInt());
2382 C->setDeclNumLists(ListsPerDecl);
2384 SmallVector<unsigned, 32> ListSizes;
2385 ListSizes.reserve(TotalLists);
2386 for (unsigned i = 0; i < TotalLists; ++i)
2387 ListSizes.push_back(Reader->Record.readInt());
2388 C->setComponentListSizes(ListSizes);
2390 SmallVector<OMPClauseMappableExprCommon::MappableComponent, 32> Components;
2391 Components.reserve(TotalComponents);
2392 for (unsigned i = 0; i < TotalComponents; ++i) {
2393 Expr *AssociatedExpr = Reader->Record.readSubExpr();
2394 ValueDecl *AssociatedDecl = Reader->Record.readDeclAs<ValueDecl>();
2395 Components.push_back(OMPClauseMappableExprCommon::MappableComponent(
2396 AssociatedExpr, AssociatedDecl));
2398 C->setComponents(Components, ListSizes);
2401 void OMPClauseReader::VisitOMPFromClause(OMPFromClause *C) {
2402 C->setLParenLoc(Reader->ReadSourceLocation());
2403 auto NumVars = C->varlist_size();
2404 auto UniqueDecls = C->getUniqueDeclarationsNum();
2405 auto TotalLists = C->getTotalComponentListNum();
2406 auto TotalComponents = C->getTotalComponentsNum();
2408 SmallVector<Expr *, 16> Vars;
2409 Vars.reserve(NumVars);
2410 for (unsigned i = 0; i != NumVars; ++i)
2411 Vars.push_back(Reader->Record.readSubExpr());
2412 C->setVarRefs(Vars);
2414 SmallVector<ValueDecl *, 16> Decls;
2415 Decls.reserve(UniqueDecls);
2416 for (unsigned i = 0; i < UniqueDecls; ++i)
2417 Decls.push_back(Reader->Record.readDeclAs<ValueDecl>());
2418 C->setUniqueDecls(Decls);
2420 SmallVector<unsigned, 16> ListsPerDecl;
2421 ListsPerDecl.reserve(UniqueDecls);
2422 for (unsigned i = 0; i < UniqueDecls; ++i)
2423 ListsPerDecl.push_back(Reader->Record.readInt());
2424 C->setDeclNumLists(ListsPerDecl);
2426 SmallVector<unsigned, 32> ListSizes;
2427 ListSizes.reserve(TotalLists);
2428 for (unsigned i = 0; i < TotalLists; ++i)
2429 ListSizes.push_back(Reader->Record.readInt());
2430 C->setComponentListSizes(ListSizes);
2432 SmallVector<OMPClauseMappableExprCommon::MappableComponent, 32> Components;
2433 Components.reserve(TotalComponents);
2434 for (unsigned i = 0; i < TotalComponents; ++i) {
2435 Expr *AssociatedExpr = Reader->Record.readSubExpr();
2436 ValueDecl *AssociatedDecl = Reader->Record.readDeclAs<ValueDecl>();
2437 Components.push_back(OMPClauseMappableExprCommon::MappableComponent(
2438 AssociatedExpr, AssociatedDecl));
2440 C->setComponents(Components, ListSizes);
2443 void OMPClauseReader::VisitOMPUseDevicePtrClause(OMPUseDevicePtrClause *C) {
2444 C->setLParenLoc(Reader->ReadSourceLocation());
2445 auto NumVars = C->varlist_size();
2446 auto UniqueDecls = C->getUniqueDeclarationsNum();
2447 auto TotalLists = C->getTotalComponentListNum();
2448 auto TotalComponents = C->getTotalComponentsNum();
2450 SmallVector<Expr *, 16> Vars;
2451 Vars.reserve(NumVars);
2452 for (unsigned i = 0; i != NumVars; ++i)
2453 Vars.push_back(Reader->Record.readSubExpr());
2454 C->setVarRefs(Vars);
2456 for (unsigned i = 0; i != NumVars; ++i)
2457 Vars.push_back(Reader->Record.readSubExpr());
2458 C->setPrivateCopies(Vars);
2460 for (unsigned i = 0; i != NumVars; ++i)
2461 Vars.push_back(Reader->Record.readSubExpr());
2464 SmallVector<ValueDecl *, 16> Decls;
2465 Decls.reserve(UniqueDecls);
2466 for (unsigned i = 0; i < UniqueDecls; ++i)
2467 Decls.push_back(Reader->Record.readDeclAs<ValueDecl>());
2468 C->setUniqueDecls(Decls);
2470 SmallVector<unsigned, 16> ListsPerDecl;
2471 ListsPerDecl.reserve(UniqueDecls);
2472 for (unsigned i = 0; i < UniqueDecls; ++i)
2473 ListsPerDecl.push_back(Reader->Record.readInt());
2474 C->setDeclNumLists(ListsPerDecl);
2476 SmallVector<unsigned, 32> ListSizes;
2477 ListSizes.reserve(TotalLists);
2478 for (unsigned i = 0; i < TotalLists; ++i)
2479 ListSizes.push_back(Reader->Record.readInt());
2480 C->setComponentListSizes(ListSizes);
2482 SmallVector<OMPClauseMappableExprCommon::MappableComponent, 32> Components;
2483 Components.reserve(TotalComponents);
2484 for (unsigned i = 0; i < TotalComponents; ++i) {
2485 Expr *AssociatedExpr = Reader->Record.readSubExpr();
2486 ValueDecl *AssociatedDecl = Reader->Record.readDeclAs<ValueDecl>();
2487 Components.push_back(OMPClauseMappableExprCommon::MappableComponent(
2488 AssociatedExpr, AssociatedDecl));
2490 C->setComponents(Components, ListSizes);
2493 void OMPClauseReader::VisitOMPIsDevicePtrClause(OMPIsDevicePtrClause *C) {
2494 C->setLParenLoc(Reader->ReadSourceLocation());
2495 auto NumVars = C->varlist_size();
2496 auto UniqueDecls = C->getUniqueDeclarationsNum();
2497 auto TotalLists = C->getTotalComponentListNum();
2498 auto TotalComponents = C->getTotalComponentsNum();
2500 SmallVector<Expr *, 16> Vars;
2501 Vars.reserve(NumVars);
2502 for (unsigned i = 0; i != NumVars; ++i)
2503 Vars.push_back(Reader->Record.readSubExpr());
2504 C->setVarRefs(Vars);
2507 SmallVector<ValueDecl *, 16> Decls;
2508 Decls.reserve(UniqueDecls);
2509 for (unsigned i = 0; i < UniqueDecls; ++i)
2510 Decls.push_back(Reader->Record.readDeclAs<ValueDecl>());
2511 C->setUniqueDecls(Decls);
2513 SmallVector<unsigned, 16> ListsPerDecl;
2514 ListsPerDecl.reserve(UniqueDecls);
2515 for (unsigned i = 0; i < UniqueDecls; ++i)
2516 ListsPerDecl.push_back(Reader->Record.readInt());
2517 C->setDeclNumLists(ListsPerDecl);
2519 SmallVector<unsigned, 32> ListSizes;
2520 ListSizes.reserve(TotalLists);
2521 for (unsigned i = 0; i < TotalLists; ++i)
2522 ListSizes.push_back(Reader->Record.readInt());
2523 C->setComponentListSizes(ListSizes);
2525 SmallVector<OMPClauseMappableExprCommon::MappableComponent, 32> Components;
2526 Components.reserve(TotalComponents);
2527 for (unsigned i = 0; i < TotalComponents; ++i) {
2528 Expr *AssociatedExpr = Reader->Record.readSubExpr();
2529 ValueDecl *AssociatedDecl = Reader->Record.readDeclAs<ValueDecl>();
2530 Components.push_back(OMPClauseMappableExprCommon::MappableComponent(
2531 AssociatedExpr, AssociatedDecl));
2533 C->setComponents(Components, ListSizes);
2536 //===----------------------------------------------------------------------===//
2537 // OpenMP Directives.
2538 //===----------------------------------------------------------------------===//
2539 void ASTStmtReader::VisitOMPExecutableDirective(OMPExecutableDirective *E) {
2540 E->setLocStart(ReadSourceLocation());
2541 E->setLocEnd(ReadSourceLocation());
2542 OMPClauseReader ClauseReader(this, Record);
2543 SmallVector<OMPClause *, 5> Clauses;
2544 for (unsigned i = 0; i < E->getNumClauses(); ++i)
2545 Clauses.push_back(ClauseReader.readClause());
2546 E->setClauses(Clauses);
2547 if (E->hasAssociatedStmt())
2548 E->setAssociatedStmt(Record.readSubStmt());
2551 void ASTStmtReader::VisitOMPLoopDirective(OMPLoopDirective *D) {
2553 // Two fields (NumClauses and CollapsedNum) were read in ReadStmtFromStream.
2555 VisitOMPExecutableDirective(D);
2556 D->setIterationVariable(Record.readSubExpr());
2557 D->setLastIteration(Record.readSubExpr());
2558 D->setCalcLastIteration(Record.readSubExpr());
2559 D->setPreCond(Record.readSubExpr());
2560 D->setCond(Record.readSubExpr());
2561 D->setInit(Record.readSubExpr());
2562 D->setInc(Record.readSubExpr());
2563 D->setPreInits(Record.readSubStmt());
2564 if (isOpenMPWorksharingDirective(D->getDirectiveKind()) ||
2565 isOpenMPTaskLoopDirective(D->getDirectiveKind()) ||
2566 isOpenMPDistributeDirective(D->getDirectiveKind())) {
2567 D->setIsLastIterVariable(Record.readSubExpr());
2568 D->setLowerBoundVariable(Record.readSubExpr());
2569 D->setUpperBoundVariable(Record.readSubExpr());
2570 D->setStrideVariable(Record.readSubExpr());
2571 D->setEnsureUpperBound(Record.readSubExpr());
2572 D->setNextLowerBound(Record.readSubExpr());
2573 D->setNextUpperBound(Record.readSubExpr());
2574 D->setNumIterations(Record.readSubExpr());
2576 if (isOpenMPLoopBoundSharingDirective(D->getDirectiveKind())) {
2577 D->setPrevLowerBoundVariable(Record.readSubExpr());
2578 D->setPrevUpperBoundVariable(Record.readSubExpr());
2579 D->setDistInc(Record.readSubExpr());
2580 D->setPrevEnsureUpperBound(Record.readSubExpr());
2581 D->setCombinedLowerBoundVariable(Record.readSubExpr());
2582 D->setCombinedUpperBoundVariable(Record.readSubExpr());
2583 D->setCombinedEnsureUpperBound(Record.readSubExpr());
2584 D->setCombinedInit(Record.readSubExpr());
2585 D->setCombinedCond(Record.readSubExpr());
2586 D->setCombinedNextLowerBound(Record.readSubExpr());
2587 D->setCombinedNextUpperBound(Record.readSubExpr());
2589 SmallVector<Expr *, 4> Sub;
2590 unsigned CollapsedNum = D->getCollapsedNumber();
2591 Sub.reserve(CollapsedNum);
2592 for (unsigned i = 0; i < CollapsedNum; ++i)
2593 Sub.push_back(Record.readSubExpr());
2594 D->setCounters(Sub);
2596 for (unsigned i = 0; i < CollapsedNum; ++i)
2597 Sub.push_back(Record.readSubExpr());
2598 D->setPrivateCounters(Sub);
2600 for (unsigned i = 0; i < CollapsedNum; ++i)
2601 Sub.push_back(Record.readSubExpr());
2604 for (unsigned i = 0; i < CollapsedNum; ++i)
2605 Sub.push_back(Record.readSubExpr());
2608 for (unsigned i = 0; i < CollapsedNum; ++i)
2609 Sub.push_back(Record.readSubExpr());
2613 void ASTStmtReader::VisitOMPParallelDirective(OMPParallelDirective *D) {
2615 // The NumClauses field was read in ReadStmtFromStream.
2617 VisitOMPExecutableDirective(D);
2618 D->setHasCancel(Record.readInt());
2621 void ASTStmtReader::VisitOMPSimdDirective(OMPSimdDirective *D) {
2622 VisitOMPLoopDirective(D);
2625 void ASTStmtReader::VisitOMPForDirective(OMPForDirective *D) {
2626 VisitOMPLoopDirective(D);
2627 D->setHasCancel(Record.readInt());
2630 void ASTStmtReader::VisitOMPForSimdDirective(OMPForSimdDirective *D) {
2631 VisitOMPLoopDirective(D);
2634 void ASTStmtReader::VisitOMPSectionsDirective(OMPSectionsDirective *D) {
2636 // The NumClauses field was read in ReadStmtFromStream.
2638 VisitOMPExecutableDirective(D);
2639 D->setHasCancel(Record.readInt());
2642 void ASTStmtReader::VisitOMPSectionDirective(OMPSectionDirective *D) {
2644 VisitOMPExecutableDirective(D);
2645 D->setHasCancel(Record.readInt());
2648 void ASTStmtReader::VisitOMPSingleDirective(OMPSingleDirective *D) {
2650 // The NumClauses field was read in ReadStmtFromStream.
2652 VisitOMPExecutableDirective(D);
2655 void ASTStmtReader::VisitOMPMasterDirective(OMPMasterDirective *D) {
2657 VisitOMPExecutableDirective(D);
2660 void ASTStmtReader::VisitOMPCriticalDirective(OMPCriticalDirective *D) {
2662 // The NumClauses field was read in ReadStmtFromStream.
2664 VisitOMPExecutableDirective(D);
2665 ReadDeclarationNameInfo(D->DirName);
2668 void ASTStmtReader::VisitOMPParallelForDirective(OMPParallelForDirective *D) {
2669 VisitOMPLoopDirective(D);
2670 D->setHasCancel(Record.readInt());
2673 void ASTStmtReader::VisitOMPParallelForSimdDirective(
2674 OMPParallelForSimdDirective *D) {
2675 VisitOMPLoopDirective(D);
2678 void ASTStmtReader::VisitOMPParallelSectionsDirective(
2679 OMPParallelSectionsDirective *D) {
2681 // The NumClauses field was read in ReadStmtFromStream.
2683 VisitOMPExecutableDirective(D);
2684 D->setHasCancel(Record.readInt());
2687 void ASTStmtReader::VisitOMPTaskDirective(OMPTaskDirective *D) {
2689 // The NumClauses field was read in ReadStmtFromStream.
2691 VisitOMPExecutableDirective(D);
2692 D->setHasCancel(Record.readInt());
2695 void ASTStmtReader::VisitOMPTaskyieldDirective(OMPTaskyieldDirective *D) {
2697 VisitOMPExecutableDirective(D);
2700 void ASTStmtReader::VisitOMPBarrierDirective(OMPBarrierDirective *D) {
2702 VisitOMPExecutableDirective(D);
2705 void ASTStmtReader::VisitOMPTaskwaitDirective(OMPTaskwaitDirective *D) {
2707 VisitOMPExecutableDirective(D);
2710 void ASTStmtReader::VisitOMPTaskgroupDirective(OMPTaskgroupDirective *D) {
2712 VisitOMPExecutableDirective(D);
2715 void ASTStmtReader::VisitOMPFlushDirective(OMPFlushDirective *D) {
2717 // The NumClauses field was read in ReadStmtFromStream.
2719 VisitOMPExecutableDirective(D);
2722 void ASTStmtReader::VisitOMPOrderedDirective(OMPOrderedDirective *D) {
2724 // The NumClauses field was read in ReadStmtFromStream.
2726 VisitOMPExecutableDirective(D);
2729 void ASTStmtReader::VisitOMPAtomicDirective(OMPAtomicDirective *D) {
2731 // The NumClauses field was read in ReadStmtFromStream.
2733 VisitOMPExecutableDirective(D);
2734 D->setX(Record.readSubExpr());
2735 D->setV(Record.readSubExpr());
2736 D->setExpr(Record.readSubExpr());
2737 D->setUpdateExpr(Record.readSubExpr());
2738 D->IsXLHSInRHSPart = Record.readInt() != 0;
2739 D->IsPostfixUpdate = Record.readInt() != 0;
2742 void ASTStmtReader::VisitOMPTargetDirective(OMPTargetDirective *D) {
2744 // The NumClauses field was read in ReadStmtFromStream.
2746 VisitOMPExecutableDirective(D);
2749 void ASTStmtReader::VisitOMPTargetDataDirective(OMPTargetDataDirective *D) {
2752 VisitOMPExecutableDirective(D);
2755 void ASTStmtReader::VisitOMPTargetEnterDataDirective(
2756 OMPTargetEnterDataDirective *D) {
2759 VisitOMPExecutableDirective(D);
2762 void ASTStmtReader::VisitOMPTargetExitDataDirective(
2763 OMPTargetExitDataDirective *D) {
2766 VisitOMPExecutableDirective(D);
2769 void ASTStmtReader::VisitOMPTargetParallelDirective(
2770 OMPTargetParallelDirective *D) {
2773 VisitOMPExecutableDirective(D);
2776 void ASTStmtReader::VisitOMPTargetParallelForDirective(
2777 OMPTargetParallelForDirective *D) {
2778 VisitOMPLoopDirective(D);
2779 D->setHasCancel(Record.readInt());
2782 void ASTStmtReader::VisitOMPTeamsDirective(OMPTeamsDirective *D) {
2784 // The NumClauses field was read in ReadStmtFromStream.
2786 VisitOMPExecutableDirective(D);
2789 void ASTStmtReader::VisitOMPCancellationPointDirective(
2790 OMPCancellationPointDirective *D) {
2792 VisitOMPExecutableDirective(D);
2793 D->setCancelRegion(static_cast<OpenMPDirectiveKind>(Record.readInt()));
2796 void ASTStmtReader::VisitOMPCancelDirective(OMPCancelDirective *D) {
2798 // The NumClauses field was read in ReadStmtFromStream.
2800 VisitOMPExecutableDirective(D);
2801 D->setCancelRegion(static_cast<OpenMPDirectiveKind>(Record.readInt()));
2804 void ASTStmtReader::VisitOMPTaskLoopDirective(OMPTaskLoopDirective *D) {
2805 VisitOMPLoopDirective(D);
2808 void ASTStmtReader::VisitOMPTaskLoopSimdDirective(OMPTaskLoopSimdDirective *D) {
2809 VisitOMPLoopDirective(D);
2812 void ASTStmtReader::VisitOMPDistributeDirective(OMPDistributeDirective *D) {
2813 VisitOMPLoopDirective(D);
2816 void ASTStmtReader::VisitOMPTargetUpdateDirective(OMPTargetUpdateDirective *D) {
2819 VisitOMPExecutableDirective(D);
2821 void ASTStmtReader::VisitOMPDistributeParallelForDirective(
2822 OMPDistributeParallelForDirective *D) {
2823 VisitOMPLoopDirective(D);
2826 void ASTStmtReader::VisitOMPDistributeParallelForSimdDirective(
2827 OMPDistributeParallelForSimdDirective *D) {
2828 VisitOMPLoopDirective(D);
2831 void ASTStmtReader::VisitOMPDistributeSimdDirective(
2832 OMPDistributeSimdDirective *D) {
2833 VisitOMPLoopDirective(D);
2836 void ASTStmtReader::VisitOMPTargetParallelForSimdDirective(
2837 OMPTargetParallelForSimdDirective *D) {
2838 VisitOMPLoopDirective(D);
2841 void ASTStmtReader::VisitOMPTargetSimdDirective(OMPTargetSimdDirective *D) {
2842 VisitOMPLoopDirective(D);
2845 void ASTStmtReader::VisitOMPTeamsDistributeDirective(
2846 OMPTeamsDistributeDirective *D) {
2847 VisitOMPLoopDirective(D);
2850 void ASTStmtReader::VisitOMPTeamsDistributeSimdDirective(
2851 OMPTeamsDistributeSimdDirective *D) {
2852 VisitOMPLoopDirective(D);
2855 void ASTStmtReader::VisitOMPTeamsDistributeParallelForSimdDirective(
2856 OMPTeamsDistributeParallelForSimdDirective *D) {
2857 VisitOMPLoopDirective(D);
2860 void ASTStmtReader::VisitOMPTeamsDistributeParallelForDirective(
2861 OMPTeamsDistributeParallelForDirective *D) {
2862 VisitOMPLoopDirective(D);
2865 void ASTStmtReader::VisitOMPTargetTeamsDirective(OMPTargetTeamsDirective *D) {
2867 // The NumClauses field was read in ReadStmtFromStream.
2869 VisitOMPExecutableDirective(D);
2872 void ASTStmtReader::VisitOMPTargetTeamsDistributeDirective(
2873 OMPTargetTeamsDistributeDirective *D) {
2874 VisitOMPLoopDirective(D);
2877 void ASTStmtReader::VisitOMPTargetTeamsDistributeParallelForDirective(
2878 OMPTargetTeamsDistributeParallelForDirective *D) {
2879 VisitOMPLoopDirective(D);
2882 void ASTStmtReader::VisitOMPTargetTeamsDistributeParallelForSimdDirective(
2883 OMPTargetTeamsDistributeParallelForSimdDirective *D) {
2884 VisitOMPLoopDirective(D);
2887 void ASTStmtReader::VisitOMPTargetTeamsDistributeSimdDirective(
2888 OMPTargetTeamsDistributeSimdDirective *D) {
2889 VisitOMPLoopDirective(D);
2892 //===----------------------------------------------------------------------===//
2893 // ASTReader Implementation
2894 //===----------------------------------------------------------------------===//
2896 Stmt *ASTReader::ReadStmt(ModuleFile &F) {
2897 switch (ReadingKind) {
2899 llvm_unreachable("should not call this when not reading anything");
2902 return ReadStmtFromStream(F);
2904 return ReadSubStmt();
2907 llvm_unreachable("ReadingKind not set ?");
2910 Expr *ASTReader::ReadExpr(ModuleFile &F) {
2911 return cast_or_null<Expr>(ReadStmt(F));
2914 Expr *ASTReader::ReadSubExpr() {
2915 return cast_or_null<Expr>(ReadSubStmt());
2918 // Within the bitstream, expressions are stored in Reverse Polish
2919 // Notation, with each of the subexpressions preceding the
2920 // expression they are stored in. Subexpressions are stored from last to first.
2921 // To evaluate expressions, we continue reading expressions and placing them on
2922 // the stack, with expressions having operands removing those operands from the
2923 // stack. Evaluation terminates when we see a STMT_STOP record, and
2924 // the single remaining expression on the stack is our result.
2925 Stmt *ASTReader::ReadStmtFromStream(ModuleFile &F) {
2927 ReadingKindTracker ReadingKind(Read_Stmt, *this);
2928 llvm::BitstreamCursor &Cursor = F.DeclsCursor;
2930 // Map of offset to previously deserialized stmt. The offset points
2931 // just after the stmt record.
2932 llvm::DenseMap<uint64_t, Stmt *> StmtEntries;
2935 unsigned PrevNumStmts = StmtStack.size();
2938 ASTRecordReader Record(*this, F);
2939 ASTStmtReader Reader(Record, Cursor);
2940 Stmt::EmptyShell Empty;
2943 llvm::BitstreamEntry Entry = Cursor.advanceSkippingSubblocks();
2945 switch (Entry.Kind) {
2946 case llvm::BitstreamEntry::SubBlock: // Handled for us already.
2947 case llvm::BitstreamEntry::Error:
2948 Error("malformed block record in AST file");
2950 case llvm::BitstreamEntry::EndBlock:
2952 case llvm::BitstreamEntry::Record:
2953 // The interesting case.
2958 bool Finished = false;
2959 bool IsStmtReference = false;
2960 switch ((StmtCode)Record.readRecord(Cursor, Entry.ID)) {
2966 IsStmtReference = true;
2967 assert(StmtEntries.find(Record[0]) != StmtEntries.end() &&
2968 "No stmt was recorded for this offset reference!");
2969 S = StmtEntries[Record.readInt()];
2977 S = new (Context) NullStmt(Empty);
2981 S = new (Context) CompoundStmt(Empty);
2985 S = new (Context) CaseStmt(Empty);
2989 S = new (Context) DefaultStmt(Empty);
2993 S = new (Context) LabelStmt(Empty);
2996 case STMT_ATTRIBUTED:
2997 S = AttributedStmt::CreateEmpty(
2999 /*NumAttrs*/Record[ASTStmtReader::NumStmtFields]);
3003 S = new (Context) IfStmt(Empty);
3007 S = new (Context) SwitchStmt(Empty);
3011 S = new (Context) WhileStmt(Empty);
3015 S = new (Context) DoStmt(Empty);
3019 S = new (Context) ForStmt(Empty);
3023 S = new (Context) GotoStmt(Empty);
3026 case STMT_INDIRECT_GOTO:
3027 S = new (Context) IndirectGotoStmt(Empty);
3031 S = new (Context) ContinueStmt(Empty);
3035 S = new (Context) BreakStmt(Empty);
3039 S = new (Context) ReturnStmt(Empty);
3043 S = new (Context) DeclStmt(Empty);
3047 S = new (Context) GCCAsmStmt(Empty);
3051 S = new (Context) MSAsmStmt(Empty);
3055 S = CapturedStmt::CreateDeserialized(Context,
3056 Record[ASTStmtReader::NumStmtFields]);
3059 case EXPR_PREDEFINED:
3060 S = new (Context) PredefinedExpr(Empty);
3064 S = DeclRefExpr::CreateEmpty(
3066 /*HasQualifier=*/Record[ASTStmtReader::NumExprFields],
3067 /*HasFoundDecl=*/Record[ASTStmtReader::NumExprFields + 1],
3068 /*HasTemplateKWAndArgsInfo=*/Record[ASTStmtReader::NumExprFields + 2],
3069 /*NumTemplateArgs=*/Record[ASTStmtReader::NumExprFields + 2] ?
3070 Record[ASTStmtReader::NumExprFields + 5] : 0);
3073 case EXPR_INTEGER_LITERAL:
3074 S = IntegerLiteral::Create(Context, Empty);
3077 case EXPR_FLOATING_LITERAL:
3078 S = FloatingLiteral::Create(Context, Empty);
3081 case EXPR_IMAGINARY_LITERAL:
3082 S = new (Context) ImaginaryLiteral(Empty);
3085 case EXPR_STRING_LITERAL:
3086 S = StringLiteral::CreateEmpty(Context,
3087 Record[ASTStmtReader::NumExprFields + 1]);
3090 case EXPR_CHARACTER_LITERAL:
3091 S = new (Context) CharacterLiteral(Empty);
3095 S = new (Context) ParenExpr(Empty);
3098 case EXPR_PAREN_LIST:
3099 S = new (Context) ParenListExpr(Empty);
3102 case EXPR_UNARY_OPERATOR:
3103 S = new (Context) UnaryOperator(Empty);
3107 S = OffsetOfExpr::CreateEmpty(Context,
3108 Record[ASTStmtReader::NumExprFields],
3109 Record[ASTStmtReader::NumExprFields + 1]);
3112 case EXPR_SIZEOF_ALIGN_OF:
3113 S = new (Context) UnaryExprOrTypeTraitExpr(Empty);
3116 case EXPR_ARRAY_SUBSCRIPT:
3117 S = new (Context) ArraySubscriptExpr(Empty);
3120 case EXPR_OMP_ARRAY_SECTION:
3121 S = new (Context) OMPArraySectionExpr(Empty);
3125 S = new (Context) CallExpr(Context, Stmt::CallExprClass, Empty);
3129 // We load everything here and fully initialize it at creation.
3130 // That way we can use MemberExpr::Create and don't have to duplicate its
3131 // logic with a MemberExpr::CreateEmpty.
3133 assert(Record.getIdx() == 0);
3134 NestedNameSpecifierLoc QualifierLoc;
3135 if (Record.readInt()) { // HasQualifier.
3136 QualifierLoc = Record.readNestedNameSpecifierLoc();
3139 SourceLocation TemplateKWLoc;
3140 TemplateArgumentListInfo ArgInfo;
3141 bool HasTemplateKWAndArgsInfo = Record.readInt();
3142 if (HasTemplateKWAndArgsInfo) {
3143 TemplateKWLoc = Record.readSourceLocation();
3144 unsigned NumTemplateArgs = Record.readInt();
3145 ArgInfo.setLAngleLoc(Record.readSourceLocation());
3146 ArgInfo.setRAngleLoc(Record.readSourceLocation());
3147 for (unsigned i = 0; i != NumTemplateArgs; ++i)
3148 ArgInfo.addArgument(Record.readTemplateArgumentLoc());
3151 bool HadMultipleCandidates = Record.readInt();
3153 NamedDecl *FoundD = Record.readDeclAs<NamedDecl>();
3154 AccessSpecifier AS = (AccessSpecifier)Record.readInt();
3155 DeclAccessPair FoundDecl = DeclAccessPair::make(FoundD, AS);
3157 QualType T = Record.readType();
3158 ExprValueKind VK = static_cast<ExprValueKind>(Record.readInt());
3159 ExprObjectKind OK = static_cast<ExprObjectKind>(Record.readInt());
3160 Expr *Base = ReadSubExpr();
3161 ValueDecl *MemberD = Record.readDeclAs<ValueDecl>();
3162 SourceLocation MemberLoc = Record.readSourceLocation();
3163 DeclarationNameInfo MemberNameInfo(MemberD->getDeclName(), MemberLoc);
3164 bool IsArrow = Record.readInt();
3165 SourceLocation OperatorLoc = Record.readSourceLocation();
3167 S = MemberExpr::Create(Context, Base, IsArrow, OperatorLoc, QualifierLoc,
3168 TemplateKWLoc, MemberD, FoundDecl, MemberNameInfo,
3169 HasTemplateKWAndArgsInfo ? &ArgInfo : nullptr, T,
3171 Record.readDeclarationNameLoc(cast<MemberExpr>(S)->MemberDNLoc,
3172 MemberD->getDeclName());
3173 if (HadMultipleCandidates)
3174 cast<MemberExpr>(S)->setHadMultipleCandidates(true);
3178 case EXPR_BINARY_OPERATOR:
3179 S = new (Context) BinaryOperator(Empty);
3182 case EXPR_COMPOUND_ASSIGN_OPERATOR:
3183 S = new (Context) CompoundAssignOperator(Empty);
3186 case EXPR_CONDITIONAL_OPERATOR:
3187 S = new (Context) ConditionalOperator(Empty);
3190 case EXPR_BINARY_CONDITIONAL_OPERATOR:
3191 S = new (Context) BinaryConditionalOperator(Empty);
3194 case EXPR_IMPLICIT_CAST:
3195 S = ImplicitCastExpr::CreateEmpty(Context,
3196 /*PathSize*/ Record[ASTStmtReader::NumExprFields]);
3199 case EXPR_CSTYLE_CAST:
3200 S = CStyleCastExpr::CreateEmpty(Context,
3201 /*PathSize*/ Record[ASTStmtReader::NumExprFields]);
3204 case EXPR_COMPOUND_LITERAL:
3205 S = new (Context) CompoundLiteralExpr(Empty);
3208 case EXPR_EXT_VECTOR_ELEMENT:
3209 S = new (Context) ExtVectorElementExpr(Empty);
3212 case EXPR_INIT_LIST:
3213 S = new (Context) InitListExpr(Empty);
3216 case EXPR_DESIGNATED_INIT:
3217 S = DesignatedInitExpr::CreateEmpty(Context,
3218 Record[ASTStmtReader::NumExprFields] - 1);
3222 case EXPR_DESIGNATED_INIT_UPDATE:
3223 S = new (Context) DesignatedInitUpdateExpr(Empty);
3226 case EXPR_IMPLICIT_VALUE_INIT:
3227 S = new (Context) ImplicitValueInitExpr(Empty);
3231 S = new (Context) NoInitExpr(Empty);
3234 case EXPR_ARRAY_INIT_LOOP:
3235 S = new (Context) ArrayInitLoopExpr(Empty);
3238 case EXPR_ARRAY_INIT_INDEX:
3239 S = new (Context) ArrayInitIndexExpr(Empty);
3243 S = new (Context) VAArgExpr(Empty);
3246 case EXPR_ADDR_LABEL:
3247 S = new (Context) AddrLabelExpr(Empty);
3251 S = new (Context) StmtExpr(Empty);
3255 S = new (Context) ChooseExpr(Empty);
3259 S = new (Context) GNUNullExpr(Empty);
3262 case EXPR_SHUFFLE_VECTOR:
3263 S = new (Context) ShuffleVectorExpr(Empty);
3266 case EXPR_CONVERT_VECTOR:
3267 S = new (Context) ConvertVectorExpr(Empty);
3271 S = new (Context) BlockExpr(Empty);
3274 case EXPR_GENERIC_SELECTION:
3275 S = new (Context) GenericSelectionExpr(Empty);
3278 case EXPR_OBJC_STRING_LITERAL:
3279 S = new (Context) ObjCStringLiteral(Empty);
3281 case EXPR_OBJC_BOXED_EXPRESSION:
3282 S = new (Context) ObjCBoxedExpr(Empty);
3284 case EXPR_OBJC_ARRAY_LITERAL:
3285 S = ObjCArrayLiteral::CreateEmpty(Context,
3286 Record[ASTStmtReader::NumExprFields]);
3288 case EXPR_OBJC_DICTIONARY_LITERAL:
3289 S = ObjCDictionaryLiteral::CreateEmpty(Context,
3290 Record[ASTStmtReader::NumExprFields],
3291 Record[ASTStmtReader::NumExprFields + 1]);
3293 case EXPR_OBJC_ENCODE:
3294 S = new (Context) ObjCEncodeExpr(Empty);
3296 case EXPR_OBJC_SELECTOR_EXPR:
3297 S = new (Context) ObjCSelectorExpr(Empty);
3299 case EXPR_OBJC_PROTOCOL_EXPR:
3300 S = new (Context) ObjCProtocolExpr(Empty);
3302 case EXPR_OBJC_IVAR_REF_EXPR:
3303 S = new (Context) ObjCIvarRefExpr(Empty);
3305 case EXPR_OBJC_PROPERTY_REF_EXPR:
3306 S = new (Context) ObjCPropertyRefExpr(Empty);
3308 case EXPR_OBJC_SUBSCRIPT_REF_EXPR:
3309 S = new (Context) ObjCSubscriptRefExpr(Empty);
3311 case EXPR_OBJC_KVC_REF_EXPR:
3312 llvm_unreachable("mismatching AST file");
3313 case EXPR_OBJC_MESSAGE_EXPR:
3314 S = ObjCMessageExpr::CreateEmpty(Context,
3315 Record[ASTStmtReader::NumExprFields],
3316 Record[ASTStmtReader::NumExprFields + 1]);
3319 S = new (Context) ObjCIsaExpr(Empty);
3321 case EXPR_OBJC_INDIRECT_COPY_RESTORE:
3322 S = new (Context) ObjCIndirectCopyRestoreExpr(Empty);
3324 case EXPR_OBJC_BRIDGED_CAST:
3325 S = new (Context) ObjCBridgedCastExpr(Empty);
3327 case STMT_OBJC_FOR_COLLECTION:
3328 S = new (Context) ObjCForCollectionStmt(Empty);
3330 case STMT_OBJC_CATCH:
3331 S = new (Context) ObjCAtCatchStmt(Empty);
3333 case STMT_OBJC_FINALLY:
3334 S = new (Context) ObjCAtFinallyStmt(Empty);
3336 case STMT_OBJC_AT_TRY:
3337 S = ObjCAtTryStmt::CreateEmpty(Context,
3338 Record[ASTStmtReader::NumStmtFields],
3339 Record[ASTStmtReader::NumStmtFields + 1]);
3341 case STMT_OBJC_AT_SYNCHRONIZED:
3342 S = new (Context) ObjCAtSynchronizedStmt(Empty);
3344 case STMT_OBJC_AT_THROW:
3345 S = new (Context) ObjCAtThrowStmt(Empty);
3347 case STMT_OBJC_AUTORELEASE_POOL:
3348 S = new (Context) ObjCAutoreleasePoolStmt(Empty);
3350 case EXPR_OBJC_BOOL_LITERAL:
3351 S = new (Context) ObjCBoolLiteralExpr(Empty);
3353 case EXPR_OBJC_AVAILABILITY_CHECK:
3354 S = new (Context) ObjCAvailabilityCheckExpr(Empty);
3356 case STMT_SEH_LEAVE:
3357 S = new (Context) SEHLeaveStmt(Empty);
3359 case STMT_SEH_EXCEPT:
3360 S = new (Context) SEHExceptStmt(Empty);
3362 case STMT_SEH_FINALLY:
3363 S = new (Context) SEHFinallyStmt(Empty);
3366 S = new (Context) SEHTryStmt(Empty);
3368 case STMT_CXX_CATCH:
3369 S = new (Context) CXXCatchStmt(Empty);
3373 S = CXXTryStmt::Create(Context, Empty,
3374 /*NumHandlers=*/Record[ASTStmtReader::NumStmtFields]);
3377 case STMT_CXX_FOR_RANGE:
3378 S = new (Context) CXXForRangeStmt(Empty);
3381 case STMT_MS_DEPENDENT_EXISTS:
3382 S = new (Context) MSDependentExistsStmt(SourceLocation(), true,
3383 NestedNameSpecifierLoc(),
3384 DeclarationNameInfo(),
3388 case STMT_OMP_PARALLEL_DIRECTIVE:
3390 OMPParallelDirective::CreateEmpty(Context,
3391 Record[ASTStmtReader::NumStmtFields],
3395 case STMT_OMP_SIMD_DIRECTIVE: {
3396 unsigned NumClauses = Record[ASTStmtReader::NumStmtFields];
3397 unsigned CollapsedNum = Record[ASTStmtReader::NumStmtFields + 1];
3398 S = OMPSimdDirective::CreateEmpty(Context, NumClauses,
3399 CollapsedNum, Empty);
3403 case STMT_OMP_FOR_DIRECTIVE: {
3404 unsigned NumClauses = Record[ASTStmtReader::NumStmtFields];
3405 unsigned CollapsedNum = Record[ASTStmtReader::NumStmtFields + 1];
3406 S = OMPForDirective::CreateEmpty(Context, NumClauses, CollapsedNum,
3411 case STMT_OMP_FOR_SIMD_DIRECTIVE: {
3412 unsigned NumClauses = Record[ASTStmtReader::NumStmtFields];
3413 unsigned CollapsedNum = Record[ASTStmtReader::NumStmtFields + 1];
3414 S = OMPForSimdDirective::CreateEmpty(Context, NumClauses, CollapsedNum,
3419 case STMT_OMP_SECTIONS_DIRECTIVE:
3420 S = OMPSectionsDirective::CreateEmpty(
3421 Context, Record[ASTStmtReader::NumStmtFields], Empty);
3424 case STMT_OMP_SECTION_DIRECTIVE:
3425 S = OMPSectionDirective::CreateEmpty(Context, Empty);
3428 case STMT_OMP_SINGLE_DIRECTIVE:
3429 S = OMPSingleDirective::CreateEmpty(
3430 Context, Record[ASTStmtReader::NumStmtFields], Empty);
3433 case STMT_OMP_MASTER_DIRECTIVE:
3434 S = OMPMasterDirective::CreateEmpty(Context, Empty);
3437 case STMT_OMP_CRITICAL_DIRECTIVE:
3438 S = OMPCriticalDirective::CreateEmpty(
3439 Context, Record[ASTStmtReader::NumStmtFields], Empty);
3442 case STMT_OMP_PARALLEL_FOR_DIRECTIVE: {
3443 unsigned NumClauses = Record[ASTStmtReader::NumStmtFields];
3444 unsigned CollapsedNum = Record[ASTStmtReader::NumStmtFields + 1];
3445 S = OMPParallelForDirective::CreateEmpty(Context, NumClauses,
3446 CollapsedNum, Empty);
3450 case STMT_OMP_PARALLEL_FOR_SIMD_DIRECTIVE: {
3451 unsigned NumClauses = Record[ASTStmtReader::NumStmtFields];
3452 unsigned CollapsedNum = Record[ASTStmtReader::NumStmtFields + 1];
3453 S = OMPParallelForSimdDirective::CreateEmpty(Context, NumClauses,
3454 CollapsedNum, Empty);
3458 case STMT_OMP_PARALLEL_SECTIONS_DIRECTIVE:
3459 S = OMPParallelSectionsDirective::CreateEmpty(
3460 Context, Record[ASTStmtReader::NumStmtFields], Empty);
3463 case STMT_OMP_TASK_DIRECTIVE:
3464 S = OMPTaskDirective::CreateEmpty(
3465 Context, Record[ASTStmtReader::NumStmtFields], Empty);
3468 case STMT_OMP_TASKYIELD_DIRECTIVE:
3469 S = OMPTaskyieldDirective::CreateEmpty(Context, Empty);
3472 case STMT_OMP_BARRIER_DIRECTIVE:
3473 S = OMPBarrierDirective::CreateEmpty(Context, Empty);
3476 case STMT_OMP_TASKWAIT_DIRECTIVE:
3477 S = OMPTaskwaitDirective::CreateEmpty(Context, Empty);
3480 case STMT_OMP_TASKGROUP_DIRECTIVE:
3481 S = OMPTaskgroupDirective::CreateEmpty(Context, Empty);
3484 case STMT_OMP_FLUSH_DIRECTIVE:
3485 S = OMPFlushDirective::CreateEmpty(
3486 Context, Record[ASTStmtReader::NumStmtFields], Empty);
3489 case STMT_OMP_ORDERED_DIRECTIVE:
3490 S = OMPOrderedDirective::CreateEmpty(
3491 Context, Record[ASTStmtReader::NumStmtFields], Empty);
3494 case STMT_OMP_ATOMIC_DIRECTIVE:
3495 S = OMPAtomicDirective::CreateEmpty(
3496 Context, Record[ASTStmtReader::NumStmtFields], Empty);
3499 case STMT_OMP_TARGET_DIRECTIVE:
3500 S = OMPTargetDirective::CreateEmpty(
3501 Context, Record[ASTStmtReader::NumStmtFields], Empty);
3504 case STMT_OMP_TARGET_DATA_DIRECTIVE:
3505 S = OMPTargetDataDirective::CreateEmpty(
3506 Context, Record[ASTStmtReader::NumStmtFields], Empty);
3509 case STMT_OMP_TARGET_ENTER_DATA_DIRECTIVE:
3510 S = OMPTargetEnterDataDirective::CreateEmpty(
3511 Context, Record[ASTStmtReader::NumStmtFields], Empty);
3514 case STMT_OMP_TARGET_EXIT_DATA_DIRECTIVE:
3515 S = OMPTargetExitDataDirective::CreateEmpty(
3516 Context, Record[ASTStmtReader::NumStmtFields], Empty);
3519 case STMT_OMP_TARGET_PARALLEL_DIRECTIVE:
3520 S = OMPTargetParallelDirective::CreateEmpty(
3521 Context, Record[ASTStmtReader::NumStmtFields], Empty);
3524 case STMT_OMP_TARGET_PARALLEL_FOR_DIRECTIVE: {
3525 unsigned NumClauses = Record[ASTStmtReader::NumStmtFields];
3526 unsigned CollapsedNum = Record[ASTStmtReader::NumStmtFields + 1];
3527 S = OMPTargetParallelForDirective::CreateEmpty(Context, NumClauses,
3528 CollapsedNum, Empty);
3532 case STMT_OMP_TARGET_UPDATE_DIRECTIVE:
3533 S = OMPTargetUpdateDirective::CreateEmpty(
3534 Context, Record[ASTStmtReader::NumStmtFields], Empty);
3537 case STMT_OMP_TEAMS_DIRECTIVE:
3538 S = OMPTeamsDirective::CreateEmpty(
3539 Context, Record[ASTStmtReader::NumStmtFields], Empty);
3542 case STMT_OMP_CANCELLATION_POINT_DIRECTIVE:
3543 S = OMPCancellationPointDirective::CreateEmpty(Context, Empty);
3546 case STMT_OMP_CANCEL_DIRECTIVE:
3547 S = OMPCancelDirective::CreateEmpty(
3548 Context, Record[ASTStmtReader::NumStmtFields], Empty);
3551 case STMT_OMP_TASKLOOP_DIRECTIVE: {
3552 unsigned NumClauses = Record[ASTStmtReader::NumStmtFields];
3553 unsigned CollapsedNum = Record[ASTStmtReader::NumStmtFields + 1];
3554 S = OMPTaskLoopDirective::CreateEmpty(Context, NumClauses, CollapsedNum,
3559 case STMT_OMP_TASKLOOP_SIMD_DIRECTIVE: {
3560 unsigned NumClauses = Record[ASTStmtReader::NumStmtFields];
3561 unsigned CollapsedNum = Record[ASTStmtReader::NumStmtFields + 1];
3562 S = OMPTaskLoopSimdDirective::CreateEmpty(Context, NumClauses,
3563 CollapsedNum, Empty);
3567 case STMT_OMP_DISTRIBUTE_DIRECTIVE: {
3568 unsigned NumClauses = Record[ASTStmtReader::NumStmtFields];
3569 unsigned CollapsedNum = Record[ASTStmtReader::NumStmtFields + 1];
3570 S = OMPDistributeDirective::CreateEmpty(Context, NumClauses, CollapsedNum,
3575 case STMT_OMP_DISTRIBUTE_PARALLEL_FOR_DIRECTIVE: {
3576 unsigned NumClauses = Record[ASTStmtReader::NumStmtFields];
3577 unsigned CollapsedNum = Record[ASTStmtReader::NumStmtFields + 1];
3578 S = OMPDistributeParallelForDirective::CreateEmpty(Context, NumClauses,
3579 CollapsedNum, Empty);
3583 case STMT_OMP_DISTRIBUTE_PARALLEL_FOR_SIMD_DIRECTIVE: {
3584 unsigned NumClauses = Record[ASTStmtReader::NumStmtFields];
3585 unsigned CollapsedNum = Record[ASTStmtReader::NumStmtFields + 1];
3586 S = OMPDistributeParallelForSimdDirective::CreateEmpty(Context, NumClauses,
3592 case STMT_OMP_DISTRIBUTE_SIMD_DIRECTIVE: {
3593 unsigned NumClauses = Record[ASTStmtReader::NumStmtFields];
3594 unsigned CollapsedNum = Record[ASTStmtReader::NumStmtFields + 1];
3595 S = OMPDistributeSimdDirective::CreateEmpty(Context, NumClauses,
3596 CollapsedNum, Empty);
3600 case STMT_OMP_TARGET_PARALLEL_FOR_SIMD_DIRECTIVE: {
3601 unsigned NumClauses = Record[ASTStmtReader::NumStmtFields];
3602 unsigned CollapsedNum = Record[ASTStmtReader::NumStmtFields + 1];
3603 S = OMPTargetParallelForSimdDirective::CreateEmpty(Context, NumClauses,
3604 CollapsedNum, Empty);
3608 case STMT_OMP_TARGET_SIMD_DIRECTIVE: {
3609 auto NumClauses = Record[ASTStmtReader::NumStmtFields];
3610 auto CollapsedNum = Record[ASTStmtReader::NumStmtFields + 1];
3611 S = OMPTargetSimdDirective::CreateEmpty(Context, NumClauses, CollapsedNum,
3616 case STMT_OMP_TEAMS_DISTRIBUTE_DIRECTIVE: {
3617 auto NumClauses = Record[ASTStmtReader::NumStmtFields];
3618 auto CollapsedNum = Record[ASTStmtReader::NumStmtFields + 1];
3619 S = OMPTeamsDistributeDirective::CreateEmpty(Context, NumClauses,
3620 CollapsedNum, Empty);
3624 case STMT_OMP_TEAMS_DISTRIBUTE_SIMD_DIRECTIVE: {
3625 unsigned NumClauses = Record[ASTStmtReader::NumStmtFields];
3626 unsigned CollapsedNum = Record[ASTStmtReader::NumStmtFields + 1];
3627 S = OMPTeamsDistributeSimdDirective::CreateEmpty(Context, NumClauses,
3628 CollapsedNum, Empty);
3632 case STMT_OMP_TEAMS_DISTRIBUTE_PARALLEL_FOR_SIMD_DIRECTIVE: {
3633 auto NumClauses = Record[ASTStmtReader::NumStmtFields];
3634 auto CollapsedNum = Record[ASTStmtReader::NumStmtFields + 1];
3635 S = OMPTeamsDistributeParallelForSimdDirective::CreateEmpty(
3636 Context, NumClauses, CollapsedNum, Empty);
3640 case STMT_OMP_TEAMS_DISTRIBUTE_PARALLEL_FOR_DIRECTIVE: {
3641 auto NumClauses = Record[ASTStmtReader::NumStmtFields];
3642 auto CollapsedNum = Record[ASTStmtReader::NumStmtFields + 1];
3643 S = OMPTeamsDistributeParallelForDirective::CreateEmpty(
3644 Context, NumClauses, CollapsedNum, Empty);
3648 case STMT_OMP_TARGET_TEAMS_DIRECTIVE: {
3649 S = OMPTargetTeamsDirective::CreateEmpty(
3650 Context, Record[ASTStmtReader::NumStmtFields], Empty);
3654 case STMT_OMP_TARGET_TEAMS_DISTRIBUTE_DIRECTIVE: {
3655 auto NumClauses = Record[ASTStmtReader::NumStmtFields];
3656 auto CollapsedNum = Record[ASTStmtReader::NumStmtFields + 1];
3657 S = OMPTargetTeamsDistributeDirective::CreateEmpty(Context, NumClauses,
3658 CollapsedNum, Empty);
3662 case STMT_OMP_TARGET_TEAMS_DISTRIBUTE_PARALLEL_FOR_DIRECTIVE: {
3663 auto NumClauses = Record[ASTStmtReader::NumStmtFields];
3664 auto CollapsedNum = Record[ASTStmtReader::NumStmtFields + 1];
3665 S = OMPTargetTeamsDistributeParallelForDirective::CreateEmpty(
3666 Context, NumClauses, CollapsedNum, Empty);
3670 case STMT_OMP_TARGET_TEAMS_DISTRIBUTE_PARALLEL_FOR_SIMD_DIRECTIVE: {
3671 auto NumClauses = Record[ASTStmtReader::NumStmtFields];
3672 auto CollapsedNum = Record[ASTStmtReader::NumStmtFields + 1];
3673 S = OMPTargetTeamsDistributeParallelForSimdDirective::CreateEmpty(
3674 Context, NumClauses, CollapsedNum, Empty);
3678 case STMT_OMP_TARGET_TEAMS_DISTRIBUTE_SIMD_DIRECTIVE: {
3679 auto NumClauses = Record[ASTStmtReader::NumStmtFields];
3680 auto CollapsedNum = Record[ASTStmtReader::NumStmtFields + 1];
3681 S = OMPTargetTeamsDistributeSimdDirective::CreateEmpty(
3682 Context, NumClauses, CollapsedNum, Empty);
3686 case EXPR_CXX_OPERATOR_CALL:
3687 S = new (Context) CXXOperatorCallExpr(Context, Empty);
3690 case EXPR_CXX_MEMBER_CALL:
3691 S = new (Context) CXXMemberCallExpr(Context, Empty);
3694 case EXPR_CXX_CONSTRUCT:
3695 S = new (Context) CXXConstructExpr(Empty);
3698 case EXPR_CXX_INHERITED_CTOR_INIT:
3699 S = new (Context) CXXInheritedCtorInitExpr(Empty);
3702 case EXPR_CXX_TEMPORARY_OBJECT:
3703 S = new (Context) CXXTemporaryObjectExpr(Empty);
3706 case EXPR_CXX_STATIC_CAST:
3707 S = CXXStaticCastExpr::CreateEmpty(Context,
3708 /*PathSize*/ Record[ASTStmtReader::NumExprFields]);
3711 case EXPR_CXX_DYNAMIC_CAST:
3712 S = CXXDynamicCastExpr::CreateEmpty(Context,
3713 /*PathSize*/ Record[ASTStmtReader::NumExprFields]);
3716 case EXPR_CXX_REINTERPRET_CAST:
3717 S = CXXReinterpretCastExpr::CreateEmpty(Context,
3718 /*PathSize*/ Record[ASTStmtReader::NumExprFields]);
3721 case EXPR_CXX_CONST_CAST:
3722 S = CXXConstCastExpr::CreateEmpty(Context);
3725 case EXPR_CXX_FUNCTIONAL_CAST:
3726 S = CXXFunctionalCastExpr::CreateEmpty(Context,
3727 /*PathSize*/ Record[ASTStmtReader::NumExprFields]);
3730 case EXPR_USER_DEFINED_LITERAL:
3731 S = new (Context) UserDefinedLiteral(Context, Empty);
3734 case EXPR_CXX_STD_INITIALIZER_LIST:
3735 S = new (Context) CXXStdInitializerListExpr(Empty);
3738 case EXPR_CXX_BOOL_LITERAL:
3739 S = new (Context) CXXBoolLiteralExpr(Empty);
3742 case EXPR_CXX_NULL_PTR_LITERAL:
3743 S = new (Context) CXXNullPtrLiteralExpr(Empty);
3745 case EXPR_CXX_TYPEID_EXPR:
3746 S = new (Context) CXXTypeidExpr(Empty, true);
3748 case EXPR_CXX_TYPEID_TYPE:
3749 S = new (Context) CXXTypeidExpr(Empty, false);
3751 case EXPR_CXX_UUIDOF_EXPR:
3752 S = new (Context) CXXUuidofExpr(Empty, true);
3754 case EXPR_CXX_PROPERTY_REF_EXPR:
3755 S = new (Context) MSPropertyRefExpr(Empty);
3757 case EXPR_CXX_PROPERTY_SUBSCRIPT_EXPR:
3758 S = new (Context) MSPropertySubscriptExpr(Empty);
3760 case EXPR_CXX_UUIDOF_TYPE:
3761 S = new (Context) CXXUuidofExpr(Empty, false);
3764 S = new (Context) CXXThisExpr(Empty);
3766 case EXPR_CXX_THROW:
3767 S = new (Context) CXXThrowExpr(Empty);
3769 case EXPR_CXX_DEFAULT_ARG:
3770 S = new (Context) CXXDefaultArgExpr(Empty);
3772 case EXPR_CXX_DEFAULT_INIT:
3773 S = new (Context) CXXDefaultInitExpr(Empty);
3775 case EXPR_CXX_BIND_TEMPORARY:
3776 S = new (Context) CXXBindTemporaryExpr(Empty);
3779 case EXPR_CXX_SCALAR_VALUE_INIT:
3780 S = new (Context) CXXScalarValueInitExpr(Empty);
3783 S = new (Context) CXXNewExpr(Empty);
3785 case EXPR_CXX_DELETE:
3786 S = new (Context) CXXDeleteExpr(Empty);
3788 case EXPR_CXX_PSEUDO_DESTRUCTOR:
3789 S = new (Context) CXXPseudoDestructorExpr(Empty);
3792 case EXPR_EXPR_WITH_CLEANUPS:
3793 S = ExprWithCleanups::Create(Context, Empty,
3794 Record[ASTStmtReader::NumExprFields]);
3797 case EXPR_CXX_DEPENDENT_SCOPE_MEMBER:
3798 S = CXXDependentScopeMemberExpr::CreateEmpty(Context,
3799 /*HasTemplateKWAndArgsInfo=*/Record[ASTStmtReader::NumExprFields],
3800 /*NumTemplateArgs=*/Record[ASTStmtReader::NumExprFields]
3801 ? Record[ASTStmtReader::NumExprFields + 1]
3805 case EXPR_CXX_DEPENDENT_SCOPE_DECL_REF:
3806 S = DependentScopeDeclRefExpr::CreateEmpty(Context,
3807 /*HasTemplateKWAndArgsInfo=*/Record[ASTStmtReader::NumExprFields],
3808 /*NumTemplateArgs=*/Record[ASTStmtReader::NumExprFields]
3809 ? Record[ASTStmtReader::NumExprFields + 1]
3813 case EXPR_CXX_UNRESOLVED_CONSTRUCT:
3814 S = CXXUnresolvedConstructExpr::CreateEmpty(Context,
3815 /*NumArgs=*/Record[ASTStmtReader::NumExprFields]);
3818 case EXPR_CXX_UNRESOLVED_MEMBER:
3819 S = UnresolvedMemberExpr::CreateEmpty(Context,
3820 /*HasTemplateKWAndArgsInfo=*/Record[ASTStmtReader::NumExprFields],
3821 /*NumTemplateArgs=*/Record[ASTStmtReader::NumExprFields]
3822 ? Record[ASTStmtReader::NumExprFields + 1]
3826 case EXPR_CXX_UNRESOLVED_LOOKUP:
3827 S = UnresolvedLookupExpr::CreateEmpty(Context,
3828 /*HasTemplateKWAndArgsInfo=*/Record[ASTStmtReader::NumExprFields],
3829 /*NumTemplateArgs=*/Record[ASTStmtReader::NumExprFields]
3830 ? Record[ASTStmtReader::NumExprFields + 1]
3834 case EXPR_TYPE_TRAIT:
3835 S = TypeTraitExpr::CreateDeserialized(Context,
3836 Record[ASTStmtReader::NumExprFields]);
3839 case EXPR_ARRAY_TYPE_TRAIT:
3840 S = new (Context) ArrayTypeTraitExpr(Empty);
3843 case EXPR_CXX_EXPRESSION_TRAIT:
3844 S = new (Context) ExpressionTraitExpr(Empty);
3847 case EXPR_CXX_NOEXCEPT:
3848 S = new (Context) CXXNoexceptExpr(Empty);
3851 case EXPR_PACK_EXPANSION:
3852 S = new (Context) PackExpansionExpr(Empty);
3855 case EXPR_SIZEOF_PACK:
3856 S = SizeOfPackExpr::CreateDeserialized(
3858 /*NumPartialArgs=*/Record[ASTStmtReader::NumExprFields]);
3861 case EXPR_SUBST_NON_TYPE_TEMPLATE_PARM:
3862 S = new (Context) SubstNonTypeTemplateParmExpr(Empty);
3865 case EXPR_SUBST_NON_TYPE_TEMPLATE_PARM_PACK:
3866 S = new (Context) SubstNonTypeTemplateParmPackExpr(Empty);
3869 case EXPR_FUNCTION_PARM_PACK:
3870 S = FunctionParmPackExpr::CreateEmpty(Context,
3871 Record[ASTStmtReader::NumExprFields]);
3874 case EXPR_MATERIALIZE_TEMPORARY:
3875 S = new (Context) MaterializeTemporaryExpr(Empty);
3879 S = new (Context) CXXFoldExpr(Empty);
3882 case EXPR_OPAQUE_VALUE:
3883 S = new (Context) OpaqueValueExpr(Empty);
3886 case EXPR_CUDA_KERNEL_CALL:
3887 S = new (Context) CUDAKernelCallExpr(Context, Empty);
3891 S = new (Context) AsTypeExpr(Empty);
3894 case EXPR_PSEUDO_OBJECT: {
3895 unsigned numSemanticExprs = Record[ASTStmtReader::NumExprFields];
3896 S = PseudoObjectExpr::Create(Context, Empty, numSemanticExprs);
3901 S = new (Context) AtomicExpr(Empty);
3905 unsigned NumCaptures = Record[ASTStmtReader::NumExprFields];
3906 S = LambdaExpr::CreateDeserialized(Context, NumCaptures);
3911 // We hit a STMT_STOP, so we're done with this expression.
3915 ++NumStatementsRead;
3917 if (S && !IsStmtReference) {
3919 StmtEntries[Cursor.GetCurrentBitNo()] = S;
3922 assert(Record.getIdx() == Record.size() &&
3923 "Invalid deserialization of statement");
3924 StmtStack.push_back(S);
3927 assert(StmtStack.size() > PrevNumStmts && "Read too many sub-stmts!");
3928 assert(StmtStack.size() == PrevNumStmts + 1 && "Extra expressions on stack!");
3929 return StmtStack.pop_back_val();