1 //===--- ASTReaderStmt.cpp - Stmt/Expr Deserialization ----------*- C++ -*-===// 2 // 3 // The LLVM Compiler Infrastructure 4 // 5 // This file is distributed under the University of Illinois Open Source 6 // License. See LICENSE.TXT for details. 7 // 8 //===----------------------------------------------------------------------===// 9 // 10 // Statement/expression deserialization. This implements the 11 // ASTReader::ReadStmt method. 12 // 13 //===----------------------------------------------------------------------===// 14 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; 24 25 namespace clang { 26 27 class ASTStmtReader : public StmtVisitor<ASTStmtReader> { 28 friend class OMPClauseReader; 29 30 ASTRecordReader &Record; 31 llvm::BitstreamCursor &DeclsCursor; 32 33 SourceLocation ReadSourceLocation() { 34 return Record.readSourceLocation(); 35 } 36 37 SourceRange ReadSourceRange() { 38 return Record.readSourceRange(); 39 } 40 41 std::string ReadString() { 42 return Record.readString(); 43 } 44 45 TypeSourceInfo *GetTypeSourceInfo() { 46 return Record.getTypeSourceInfo(); 47 } 48 49 Decl *ReadDecl() { 50 return Record.readDecl(); 51 } 52 53 template<typename T> 54 T *ReadDeclAs() { 55 return Record.readDeclAs<T>(); 56 } 57 58 void ReadDeclarationNameLoc(DeclarationNameLoc &DNLoc, 59 DeclarationName Name) { 60 Record.readDeclarationNameLoc(DNLoc, Name); 61 } 62 63 void ReadDeclarationNameInfo(DeclarationNameInfo &NameInfo) { 64 Record.readDeclarationNameInfo(NameInfo); 65 } 66 67 public: 68 ASTStmtReader(ASTRecordReader &Record, llvm::BitstreamCursor &Cursor) 69 : Record(Record), DeclsCursor(Cursor) {} 70 71 /// \brief The number of record fields required for the Stmt class 72 /// itself. 73 static const unsigned NumStmtFields = 0; 74 75 /// \brief The number of record fields required for the Expr class 76 /// itself. 77 static const unsigned NumExprFields = NumStmtFields + 7; 78 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); 86 87 void VisitStmt(Stmt *S); 88 #define STMT(Type, Base) \ 89 void Visit##Type(Type *); 90 #include "clang/AST/StmtNodes.inc" 91 }; 92 } 93 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); 104 } 105 106 void ASTStmtReader::VisitStmt(Stmt *S) { 107 assert(Record.getIdx() == NumStmtFields && "Incorrect statement field count"); 108 } 109 110 void ASTStmtReader::VisitNullStmt(NullStmt *S) { 111 VisitStmt(S); 112 S->setSemiLoc(ReadSourceLocation()); 113 S->HasLeadingEmptyMacro = Record.readInt(); 114 } 115 116 void ASTStmtReader::VisitCompoundStmt(CompoundStmt *S) { 117 VisitStmt(S); 118 SmallVector<Stmt *, 16> Stmts; 119 unsigned NumStmts = Record.readInt(); 120 while (NumStmts--) 121 Stmts.push_back(Record.readSubStmt()); 122 S->setStmts(Stmts); 123 S->LBraceLoc = ReadSourceLocation(); 124 S->RBraceLoc = ReadSourceLocation(); 125 } 126 127 void ASTStmtReader::VisitSwitchCase(SwitchCase *S) { 128 VisitStmt(S); 129 Record.recordSwitchCaseID(S, Record.readInt()); 130 S->setKeywordLoc(ReadSourceLocation()); 131 S->setColonLoc(ReadSourceLocation()); 132 } 133 134 void ASTStmtReader::VisitCaseStmt(CaseStmt *S) { 135 VisitSwitchCase(S); 136 S->setLHS(Record.readSubExpr()); 137 S->setRHS(Record.readSubExpr()); 138 S->setSubStmt(Record.readSubStmt()); 139 S->setEllipsisLoc(ReadSourceLocation()); 140 } 141 142 void ASTStmtReader::VisitDefaultStmt(DefaultStmt *S) { 143 VisitSwitchCase(S); 144 S->setSubStmt(Record.readSubStmt()); 145 } 146 147 void ASTStmtReader::VisitLabelStmt(LabelStmt *S) { 148 VisitStmt(S); 149 LabelDecl *LD = ReadDeclAs<LabelDecl>(); 150 LD->setStmt(S); 151 S->setDecl(LD); 152 S->setSubStmt(Record.readSubStmt()); 153 S->setIdentLoc(ReadSourceLocation()); 154 } 155 156 void ASTStmtReader::VisitAttributedStmt(AttributedStmt *S) { 157 VisitStmt(S); 158 uint64_t NumAttrs = Record.readInt(); 159 AttrVec Attrs; 160 Record.readAttributes(Attrs); 161 (void)NumAttrs; 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(); 167 } 168 169 void ASTStmtReader::VisitIfStmt(IfStmt *S) { 170 VisitStmt(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()); 179 } 180 181 void ASTStmtReader::VisitSwitchStmt(SwitchStmt *S) { 182 VisitStmt(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(); 190 191 SwitchCase *PrevSC = nullptr; 192 for (auto E = Record.size(); Record.getIdx() != E; ) { 193 SwitchCase *SC = Record.getSwitchCaseWithID(Record.readInt()); 194 if (PrevSC) 195 PrevSC->setNextSwitchCase(SC); 196 else 197 S->setSwitchCaseList(SC); 198 199 PrevSC = SC; 200 } 201 } 202 203 void ASTStmtReader::VisitWhileStmt(WhileStmt *S) { 204 VisitStmt(S); 205 S->setConditionVariable(Record.getContext(), ReadDeclAs<VarDecl>()); 206 207 S->setCond(Record.readSubExpr()); 208 S->setBody(Record.readSubStmt()); 209 S->setWhileLoc(ReadSourceLocation()); 210 } 211 212 void ASTStmtReader::VisitDoStmt(DoStmt *S) { 213 VisitStmt(S); 214 S->setCond(Record.readSubExpr()); 215 S->setBody(Record.readSubStmt()); 216 S->setDoLoc(ReadSourceLocation()); 217 S->setWhileLoc(ReadSourceLocation()); 218 S->setRParenLoc(ReadSourceLocation()); 219 } 220 221 void ASTStmtReader::VisitForStmt(ForStmt *S) { 222 VisitStmt(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()); 231 } 232 233 void ASTStmtReader::VisitGotoStmt(GotoStmt *S) { 234 VisitStmt(S); 235 S->setLabel(ReadDeclAs<LabelDecl>()); 236 S->setGotoLoc(ReadSourceLocation()); 237 S->setLabelLoc(ReadSourceLocation()); 238 } 239 240 void ASTStmtReader::VisitIndirectGotoStmt(IndirectGotoStmt *S) { 241 VisitStmt(S); 242 S->setGotoLoc(ReadSourceLocation()); 243 S->setStarLoc(ReadSourceLocation()); 244 S->setTarget(Record.readSubExpr()); 245 } 246 247 void ASTStmtReader::VisitContinueStmt(ContinueStmt *S) { 248 VisitStmt(S); 249 S->setContinueLoc(ReadSourceLocation()); 250 } 251 252 void ASTStmtReader::VisitBreakStmt(BreakStmt *S) { 253 VisitStmt(S); 254 S->setBreakLoc(ReadSourceLocation()); 255 } 256 257 void ASTStmtReader::VisitReturnStmt(ReturnStmt *S) { 258 VisitStmt(S); 259 S->setRetValue(Record.readSubExpr()); 260 S->setReturnLoc(ReadSourceLocation()); 261 S->setNRVOCandidate(ReadDeclAs<VarDecl>()); 262 } 263 264 void ASTStmtReader::VisitDeclStmt(DeclStmt *S) { 265 VisitStmt(S); 266 S->setStartLoc(ReadSourceLocation()); 267 S->setEndLoc(ReadSourceLocation()); 268 269 if (Record.size() - Record.getIdx() == 1) { 270 // Single declaration 271 S->setDeclGroup(DeclGroupRef(ReadDecl())); 272 } else { 273 SmallVector<Decl *, 16> Decls; 274 int N = Record.size() - Record.getIdx(); 275 Decls.reserve(N); 276 for (int I = 0; I < N; ++I) 277 Decls.push_back(ReadDecl()); 278 S->setDeclGroup(DeclGroupRef(DeclGroup::Create(Record.getContext(), 279 Decls.data(), 280 Decls.size()))); 281 } 282 } 283 284 void ASTStmtReader::VisitAsmStmt(AsmStmt *S) { 285 VisitStmt(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()); 292 } 293 294 void ASTStmtReader::VisitGCCAsmStmt(GCCAsmStmt *S) { 295 VisitAsmStmt(S); 296 S->setRParenLoc(ReadSourceLocation()); 297 S->setAsmString(cast_or_null<StringLiteral>(Record.readSubStmt())); 298 299 unsigned NumOutputs = S->getNumOutputs(); 300 unsigned NumInputs = S->getNumInputs(); 301 unsigned NumClobbers = S->getNumClobbers(); 302 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()); 311 } 312 313 // Constraints 314 SmallVector<StringLiteral*, 16> Clobbers; 315 for (unsigned I = 0; I != NumClobbers; ++I) 316 Clobbers.push_back(cast_or_null<StringLiteral>(Record.readSubStmt())); 317 318 S->setOutputsAndInputsAndClobbers(Record.getContext(), 319 Names.data(), Constraints.data(), 320 Exprs.data(), NumOutputs, NumInputs, 321 Clobbers.data(), NumClobbers); 322 } 323 324 void ASTStmtReader::VisitMSAsmStmt(MSAsmStmt *S) { 325 VisitAsmStmt(S); 326 S->LBraceLoc = ReadSourceLocation(); 327 S->EndLoc = ReadSourceLocation(); 328 S->NumAsmToks = Record.readInt(); 329 std::string AsmStr = ReadString(); 330 331 // Read the tokens. 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()); 336 } 337 338 // The calls to reserve() for the FooData vectors are mandatory to 339 // prevent dead StringRefs in the Foo vectors. 340 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()); 349 } 350 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()); 363 } 364 365 S->initialize(Record.getContext(), AsmStr, AsmToks, 366 Constraints, Exprs, Clobbers); 367 } 368 369 void ASTStmtReader::VisitCoroutineBodyStmt(CoroutineBodyStmt *S) { 370 VisitStmt(S); 371 assert(Record.peekInt() == S->NumParams); 372 Record.skipInts(1); 373 auto *StoredStmts = S->getStoredStmts(); 374 for (unsigned i = 0; 375 i < CoroutineBodyStmt::SubStmt::FirstParamMove + S->NumParams; ++i) 376 StoredStmts[i] = Record.readSubStmt(); 377 } 378 379 void ASTStmtReader::VisitCoreturnStmt(CoreturnStmt *S) { 380 VisitStmt(S); 381 S->CoreturnLoc = Record.readSourceLocation(); 382 for (auto &SubStmt: S->SubStmts) 383 SubStmt = Record.readSubStmt(); 384 S->IsImplicit = Record.readInt() != 0; 385 } 386 387 void ASTStmtReader::VisitCoawaitExpr(CoawaitExpr *E) { 388 VisitExpr(E); 389 E->KeywordLoc = ReadSourceLocation(); 390 for (auto &SubExpr: E->SubExprs) 391 SubExpr = Record.readSubStmt(); 392 E->OpaqueValue = cast_or_null<OpaqueValueExpr>(Record.readSubStmt()); 393 E->setIsImplicit(Record.readInt() != 0); 394 } 395 396 void ASTStmtReader::VisitCoyieldExpr(CoyieldExpr *E) { 397 VisitExpr(E); 398 E->KeywordLoc = ReadSourceLocation(); 399 for (auto &SubExpr: E->SubExprs) 400 SubExpr = Record.readSubStmt(); 401 E->OpaqueValue = cast_or_null<OpaqueValueExpr>(Record.readSubStmt()); 402 } 403 404 void ASTStmtReader::VisitDependentCoawaitExpr(DependentCoawaitExpr *E) { 405 VisitExpr(E); 406 E->KeywordLoc = ReadSourceLocation(); 407 for (auto &SubExpr: E->SubExprs) 408 SubExpr = Record.readSubStmt(); 409 } 410 411 void ASTStmtReader::VisitCapturedStmt(CapturedStmt *S) { 412 VisitStmt(S); 413 Record.skipInts(1); 414 S->setCapturedDecl(ReadDeclAs<CapturedDecl>()); 415 S->setCapturedRegionKind(static_cast<CapturedRegionKind>(Record.readInt())); 416 S->setCapturedRecordDecl(ReadDeclAs<RecordDecl>()); 417 418 // Capture inits 419 for (CapturedStmt::capture_init_iterator I = S->capture_init_begin(), 420 E = S->capture_init_end(); 421 I != E; ++I) 422 *I = Record.readSubExpr(); 423 424 // Body 425 S->setCapturedStmt(Record.readSubStmt()); 426 S->getCapturedDecl()->setBody(S->getCapturedStmt()); 427 428 // Captures 429 for (auto &I : S->captures()) { 430 I.VarAndKind.setPointer(ReadDeclAs<VarDecl>()); 431 I.VarAndKind.setInt( 432 static_cast<CapturedStmt::VariableCaptureKind>(Record.readInt())); 433 I.Loc = ReadSourceLocation(); 434 } 435 } 436 437 void ASTStmtReader::VisitExpr(Expr *E) { 438 VisitStmt(E); 439 E->setType(Record.readType()); 440 E->setTypeDependent(Record.readInt()); 441 E->setValueDependent(Record.readInt()); 442 E->setInstantiationDependent(Record.readInt()); 443 E->ExprBits.ContainsUnexpandedParameterPack = Record.readInt(); 444 E->setValueKind(static_cast<ExprValueKind>(Record.readInt())); 445 E->setObjectKind(static_cast<ExprObjectKind>(Record.readInt())); 446 assert(Record.getIdx() == NumExprFields && 447 "Incorrect expression field count"); 448 } 449 450 void ASTStmtReader::VisitPredefinedExpr(PredefinedExpr *E) { 451 VisitExpr(E); 452 E->setLocation(ReadSourceLocation()); 453 E->Type = (PredefinedExpr::IdentType)Record.readInt(); 454 E->FnName = cast_or_null<StringLiteral>(Record.readSubExpr()); 455 } 456 457 void ASTStmtReader::VisitDeclRefExpr(DeclRefExpr *E) { 458 VisitExpr(E); 459 460 E->DeclRefExprBits.HasQualifier = Record.readInt(); 461 E->DeclRefExprBits.HasFoundDecl = Record.readInt(); 462 E->DeclRefExprBits.HasTemplateKWAndArgsInfo = Record.readInt(); 463 E->DeclRefExprBits.HadMultipleCandidates = Record.readInt(); 464 E->DeclRefExprBits.RefersToEnclosingVariableOrCapture = Record.readInt(); 465 unsigned NumTemplateArgs = 0; 466 if (E->hasTemplateKWAndArgsInfo()) 467 NumTemplateArgs = Record.readInt(); 468 469 if (E->hasQualifier()) 470 new (E->getTrailingObjects<NestedNameSpecifierLoc>()) 471 NestedNameSpecifierLoc(Record.readNestedNameSpecifierLoc()); 472 473 if (E->hasFoundDecl()) 474 *E->getTrailingObjects<NamedDecl *>() = ReadDeclAs<NamedDecl>(); 475 476 if (E->hasTemplateKWAndArgsInfo()) 477 ReadTemplateKWAndArgsInfo( 478 *E->getTrailingObjects<ASTTemplateKWAndArgsInfo>(), 479 E->getTrailingObjects<TemplateArgumentLoc>(), NumTemplateArgs); 480 481 E->setDecl(ReadDeclAs<ValueDecl>()); 482 E->setLocation(ReadSourceLocation()); 483 ReadDeclarationNameLoc(E->DNLoc, E->getDecl()->getDeclName()); 484 } 485 486 void ASTStmtReader::VisitIntegerLiteral(IntegerLiteral *E) { 487 VisitExpr(E); 488 E->setLocation(ReadSourceLocation()); 489 E->setValue(Record.getContext(), Record.readAPInt()); 490 } 491 492 void ASTStmtReader::VisitFloatingLiteral(FloatingLiteral *E) { 493 VisitExpr(E); 494 E->setRawSemantics(static_cast<Stmt::APFloatSemantics>(Record.readInt())); 495 E->setExact(Record.readInt()); 496 E->setValue(Record.getContext(), Record.readAPFloat(E->getSemantics())); 497 E->setLocation(ReadSourceLocation()); 498 } 499 500 void ASTStmtReader::VisitImaginaryLiteral(ImaginaryLiteral *E) { 501 VisitExpr(E); 502 E->setSubExpr(Record.readSubExpr()); 503 } 504 505 void ASTStmtReader::VisitStringLiteral(StringLiteral *E) { 506 VisitExpr(E); 507 unsigned Len = Record.readInt(); 508 assert(Record.peekInt() == E->getNumConcatenated() && 509 "Wrong number of concatenated tokens!"); 510 Record.skipInts(1); 511 StringLiteral::StringKind kind = 512 static_cast<StringLiteral::StringKind>(Record.readInt()); 513 bool isPascal = Record.readInt(); 514 515 // Read string data 516 auto B = &Record.peekInt(); 517 SmallString<16> Str(B, B + Len); 518 E->setString(Record.getContext(), Str, kind, isPascal); 519 Record.skipInts(Len); 520 521 // Read source locations 522 for (unsigned I = 0, N = E->getNumConcatenated(); I != N; ++I) 523 E->setStrTokenLoc(I, ReadSourceLocation()); 524 } 525 526 void ASTStmtReader::VisitCharacterLiteral(CharacterLiteral *E) { 527 VisitExpr(E); 528 E->setValue(Record.readInt()); 529 E->setLocation(ReadSourceLocation()); 530 E->setKind(static_cast<CharacterLiteral::CharacterKind>(Record.readInt())); 531 } 532 533 void ASTStmtReader::VisitParenExpr(ParenExpr *E) { 534 VisitExpr(E); 535 E->setLParen(ReadSourceLocation()); 536 E->setRParen(ReadSourceLocation()); 537 E->setSubExpr(Record.readSubExpr()); 538 } 539 540 void ASTStmtReader::VisitParenListExpr(ParenListExpr *E) { 541 VisitExpr(E); 542 unsigned NumExprs = Record.readInt(); 543 E->Exprs = new (Record.getContext()) Stmt*[NumExprs]; 544 for (unsigned i = 0; i != NumExprs; ++i) 545 E->Exprs[i] = Record.readSubStmt(); 546 E->NumExprs = NumExprs; 547 E->LParenLoc = ReadSourceLocation(); 548 E->RParenLoc = ReadSourceLocation(); 549 } 550 551 void ASTStmtReader::VisitUnaryOperator(UnaryOperator *E) { 552 VisitExpr(E); 553 E->setSubExpr(Record.readSubExpr()); 554 E->setOpcode((UnaryOperator::Opcode)Record.readInt()); 555 E->setOperatorLoc(ReadSourceLocation()); 556 E->setCanOverflow(Record.readInt()); 557 } 558 559 void ASTStmtReader::VisitOffsetOfExpr(OffsetOfExpr *E) { 560 VisitExpr(E); 561 assert(E->getNumComponents() == Record.peekInt()); 562 Record.skipInts(1); 563 assert(E->getNumExpressions() == Record.peekInt()); 564 Record.skipInts(1); 565 E->setOperatorLoc(ReadSourceLocation()); 566 E->setRParenLoc(ReadSourceLocation()); 567 E->setTypeSourceInfo(GetTypeSourceInfo()); 568 for (unsigned I = 0, N = E->getNumComponents(); I != N; ++I) { 569 OffsetOfNode::Kind Kind = static_cast<OffsetOfNode::Kind>(Record.readInt()); 570 SourceLocation Start = ReadSourceLocation(); 571 SourceLocation End = ReadSourceLocation(); 572 switch (Kind) { 573 case OffsetOfNode::Array: 574 E->setComponent(I, OffsetOfNode(Start, Record.readInt(), End)); 575 break; 576 577 case OffsetOfNode::Field: 578 E->setComponent( 579 I, OffsetOfNode(Start, ReadDeclAs<FieldDecl>(), End)); 580 break; 581 582 case OffsetOfNode::Identifier: 583 E->setComponent( 584 I, 585 OffsetOfNode(Start, Record.getIdentifierInfo(), End)); 586 break; 587 588 case OffsetOfNode::Base: { 589 CXXBaseSpecifier *Base = new (Record.getContext()) CXXBaseSpecifier(); 590 *Base = Record.readCXXBaseSpecifier(); 591 E->setComponent(I, OffsetOfNode(Base)); 592 break; 593 } 594 } 595 } 596 597 for (unsigned I = 0, N = E->getNumExpressions(); I != N; ++I) 598 E->setIndexExpr(I, Record.readSubExpr()); 599 } 600 601 void ASTStmtReader::VisitUnaryExprOrTypeTraitExpr(UnaryExprOrTypeTraitExpr *E) { 602 VisitExpr(E); 603 E->setKind(static_cast<UnaryExprOrTypeTrait>(Record.readInt())); 604 if (Record.peekInt() == 0) { 605 E->setArgument(Record.readSubExpr()); 606 Record.skipInts(1); 607 } else { 608 E->setArgument(GetTypeSourceInfo()); 609 } 610 E->setOperatorLoc(ReadSourceLocation()); 611 E->setRParenLoc(ReadSourceLocation()); 612 } 613 614 void ASTStmtReader::VisitArraySubscriptExpr(ArraySubscriptExpr *E) { 615 VisitExpr(E); 616 E->setLHS(Record.readSubExpr()); 617 E->setRHS(Record.readSubExpr()); 618 E->setRBracketLoc(ReadSourceLocation()); 619 } 620 621 void ASTStmtReader::VisitOMPArraySectionExpr(OMPArraySectionExpr *E) { 622 VisitExpr(E); 623 E->setBase(Record.readSubExpr()); 624 E->setLowerBound(Record.readSubExpr()); 625 E->setLength(Record.readSubExpr()); 626 E->setColonLoc(ReadSourceLocation()); 627 E->setRBracketLoc(ReadSourceLocation()); 628 } 629 630 void ASTStmtReader::VisitCallExpr(CallExpr *E) { 631 VisitExpr(E); 632 E->setNumArgs(Record.getContext(), Record.readInt()); 633 E->setRParenLoc(ReadSourceLocation()); 634 E->setCallee(Record.readSubExpr()); 635 for (unsigned I = 0, N = E->getNumArgs(); I != N; ++I) 636 E->setArg(I, Record.readSubExpr()); 637 } 638 639 void ASTStmtReader::VisitCXXMemberCallExpr(CXXMemberCallExpr *E) { 640 VisitCallExpr(E); 641 } 642 643 void ASTStmtReader::VisitMemberExpr(MemberExpr *E) { 644 // Don't call VisitExpr, this is fully initialized at creation. 645 assert(E->getStmtClass() == Stmt::MemberExprClass && 646 "It's a subclass, we must advance Idx!"); 647 } 648 649 void ASTStmtReader::VisitObjCIsaExpr(ObjCIsaExpr *E) { 650 VisitExpr(E); 651 E->setBase(Record.readSubExpr()); 652 E->setIsaMemberLoc(ReadSourceLocation()); 653 E->setOpLoc(ReadSourceLocation()); 654 E->setArrow(Record.readInt()); 655 } 656 657 void ASTStmtReader:: 658 VisitObjCIndirectCopyRestoreExpr(ObjCIndirectCopyRestoreExpr *E) { 659 VisitExpr(E); 660 E->Operand = Record.readSubExpr(); 661 E->setShouldCopy(Record.readInt()); 662 } 663 664 void ASTStmtReader::VisitObjCBridgedCastExpr(ObjCBridgedCastExpr *E) { 665 VisitExplicitCastExpr(E); 666 E->LParenLoc = ReadSourceLocation(); 667 E->BridgeKeywordLoc = ReadSourceLocation(); 668 E->Kind = Record.readInt(); 669 } 670 671 void ASTStmtReader::VisitCastExpr(CastExpr *E) { 672 VisitExpr(E); 673 unsigned NumBaseSpecs = Record.readInt(); 674 assert(NumBaseSpecs == E->path_size()); 675 E->setSubExpr(Record.readSubExpr()); 676 E->setCastKind((CastKind)Record.readInt()); 677 CastExpr::path_iterator BaseI = E->path_begin(); 678 while (NumBaseSpecs--) { 679 CXXBaseSpecifier *BaseSpec = new (Record.getContext()) CXXBaseSpecifier; 680 *BaseSpec = Record.readCXXBaseSpecifier(); 681 *BaseI++ = BaseSpec; 682 } 683 } 684 685 void ASTStmtReader::VisitBinaryOperator(BinaryOperator *E) { 686 VisitExpr(E); 687 E->setLHS(Record.readSubExpr()); 688 E->setRHS(Record.readSubExpr()); 689 E->setOpcode((BinaryOperator::Opcode)Record.readInt()); 690 E->setOperatorLoc(ReadSourceLocation()); 691 E->setFPFeatures(FPOptions(Record.readInt())); 692 } 693 694 void ASTStmtReader::VisitCompoundAssignOperator(CompoundAssignOperator *E) { 695 VisitBinaryOperator(E); 696 E->setComputationLHSType(Record.readType()); 697 E->setComputationResultType(Record.readType()); 698 } 699 700 void ASTStmtReader::VisitConditionalOperator(ConditionalOperator *E) { 701 VisitExpr(E); 702 E->SubExprs[ConditionalOperator::COND] = Record.readSubExpr(); 703 E->SubExprs[ConditionalOperator::LHS] = Record.readSubExpr(); 704 E->SubExprs[ConditionalOperator::RHS] = Record.readSubExpr(); 705 E->QuestionLoc = ReadSourceLocation(); 706 E->ColonLoc = ReadSourceLocation(); 707 } 708 709 void 710 ASTStmtReader::VisitBinaryConditionalOperator(BinaryConditionalOperator *E) { 711 VisitExpr(E); 712 E->OpaqueValue = cast<OpaqueValueExpr>(Record.readSubExpr()); 713 E->SubExprs[BinaryConditionalOperator::COMMON] = Record.readSubExpr(); 714 E->SubExprs[BinaryConditionalOperator::COND] = Record.readSubExpr(); 715 E->SubExprs[BinaryConditionalOperator::LHS] = Record.readSubExpr(); 716 E->SubExprs[BinaryConditionalOperator::RHS] = Record.readSubExpr(); 717 E->QuestionLoc = ReadSourceLocation(); 718 E->ColonLoc = ReadSourceLocation(); 719 } 720 721 void ASTStmtReader::VisitImplicitCastExpr(ImplicitCastExpr *E) { 722 VisitCastExpr(E); 723 } 724 725 void ASTStmtReader::VisitExplicitCastExpr(ExplicitCastExpr *E) { 726 VisitCastExpr(E); 727 E->setTypeInfoAsWritten(GetTypeSourceInfo()); 728 } 729 730 void ASTStmtReader::VisitCStyleCastExpr(CStyleCastExpr *E) { 731 VisitExplicitCastExpr(E); 732 E->setLParenLoc(ReadSourceLocation()); 733 E->setRParenLoc(ReadSourceLocation()); 734 } 735 736 void ASTStmtReader::VisitCompoundLiteralExpr(CompoundLiteralExpr *E) { 737 VisitExpr(E); 738 E->setLParenLoc(ReadSourceLocation()); 739 E->setTypeSourceInfo(GetTypeSourceInfo()); 740 E->setInitializer(Record.readSubExpr()); 741 E->setFileScope(Record.readInt()); 742 } 743 744 void ASTStmtReader::VisitExtVectorElementExpr(ExtVectorElementExpr *E) { 745 VisitExpr(E); 746 E->setBase(Record.readSubExpr()); 747 E->setAccessor(Record.getIdentifierInfo()); 748 E->setAccessorLoc(ReadSourceLocation()); 749 } 750 751 void ASTStmtReader::VisitInitListExpr(InitListExpr *E) { 752 VisitExpr(E); 753 if (InitListExpr *SyntForm = cast_or_null<InitListExpr>(Record.readSubStmt())) 754 E->setSyntacticForm(SyntForm); 755 E->setLBraceLoc(ReadSourceLocation()); 756 E->setRBraceLoc(ReadSourceLocation()); 757 bool isArrayFiller = Record.readInt(); 758 Expr *filler = nullptr; 759 if (isArrayFiller) { 760 filler = Record.readSubExpr(); 761 E->ArrayFillerOrUnionFieldInit = filler; 762 } else 763 E->ArrayFillerOrUnionFieldInit = ReadDeclAs<FieldDecl>(); 764 E->sawArrayRangeDesignator(Record.readInt()); 765 unsigned NumInits = Record.readInt(); 766 E->reserveInits(Record.getContext(), NumInits); 767 if (isArrayFiller) { 768 for (unsigned I = 0; I != NumInits; ++I) { 769 Expr *init = Record.readSubExpr(); 770 E->updateInit(Record.getContext(), I, init ? init : filler); 771 } 772 } else { 773 for (unsigned I = 0; I != NumInits; ++I) 774 E->updateInit(Record.getContext(), I, Record.readSubExpr()); 775 } 776 } 777 778 void ASTStmtReader::VisitDesignatedInitExpr(DesignatedInitExpr *E) { 779 typedef DesignatedInitExpr::Designator Designator; 780 781 VisitExpr(E); 782 unsigned NumSubExprs = Record.readInt(); 783 assert(NumSubExprs == E->getNumSubExprs() && "Wrong number of subexprs"); 784 for (unsigned I = 0; I != NumSubExprs; ++I) 785 E->setSubExpr(I, Record.readSubExpr()); 786 E->setEqualOrColonLoc(ReadSourceLocation()); 787 E->setGNUSyntax(Record.readInt()); 788 789 SmallVector<Designator, 4> Designators; 790 while (Record.getIdx() < Record.size()) { 791 switch ((DesignatorTypes)Record.readInt()) { 792 case DESIG_FIELD_DECL: { 793 FieldDecl *Field = ReadDeclAs<FieldDecl>(); 794 SourceLocation DotLoc = ReadSourceLocation(); 795 SourceLocation FieldLoc = ReadSourceLocation(); 796 Designators.push_back(Designator(Field->getIdentifier(), DotLoc, 797 FieldLoc)); 798 Designators.back().setField(Field); 799 break; 800 } 801 802 case DESIG_FIELD_NAME: { 803 const IdentifierInfo *Name = Record.getIdentifierInfo(); 804 SourceLocation DotLoc = ReadSourceLocation(); 805 SourceLocation FieldLoc = ReadSourceLocation(); 806 Designators.push_back(Designator(Name, DotLoc, FieldLoc)); 807 break; 808 } 809 810 case DESIG_ARRAY: { 811 unsigned Index = Record.readInt(); 812 SourceLocation LBracketLoc = ReadSourceLocation(); 813 SourceLocation RBracketLoc = ReadSourceLocation(); 814 Designators.push_back(Designator(Index, LBracketLoc, RBracketLoc)); 815 break; 816 } 817 818 case DESIG_ARRAY_RANGE: { 819 unsigned Index = Record.readInt(); 820 SourceLocation LBracketLoc = ReadSourceLocation(); 821 SourceLocation EllipsisLoc = ReadSourceLocation(); 822 SourceLocation RBracketLoc = ReadSourceLocation(); 823 Designators.push_back(Designator(Index, LBracketLoc, EllipsisLoc, 824 RBracketLoc)); 825 break; 826 } 827 } 828 } 829 E->setDesignators(Record.getContext(), 830 Designators.data(), Designators.size()); 831 } 832 833 void ASTStmtReader::VisitDesignatedInitUpdateExpr(DesignatedInitUpdateExpr *E) { 834 VisitExpr(E); 835 E->setBase(Record.readSubExpr()); 836 E->setUpdater(Record.readSubExpr()); 837 } 838 839 void ASTStmtReader::VisitNoInitExpr(NoInitExpr *E) { 840 VisitExpr(E); 841 } 842 843 void ASTStmtReader::VisitArrayInitLoopExpr(ArrayInitLoopExpr *E) { 844 VisitExpr(E); 845 E->SubExprs[0] = Record.readSubExpr(); 846 E->SubExprs[1] = Record.readSubExpr(); 847 } 848 849 void ASTStmtReader::VisitArrayInitIndexExpr(ArrayInitIndexExpr *E) { 850 VisitExpr(E); 851 } 852 853 void ASTStmtReader::VisitImplicitValueInitExpr(ImplicitValueInitExpr *E) { 854 VisitExpr(E); 855 } 856 857 void ASTStmtReader::VisitVAArgExpr(VAArgExpr *E) { 858 VisitExpr(E); 859 E->setSubExpr(Record.readSubExpr()); 860 E->setWrittenTypeInfo(GetTypeSourceInfo()); 861 E->setBuiltinLoc(ReadSourceLocation()); 862 E->setRParenLoc(ReadSourceLocation()); 863 E->setIsMicrosoftABI(Record.readInt()); 864 } 865 866 void ASTStmtReader::VisitAddrLabelExpr(AddrLabelExpr *E) { 867 VisitExpr(E); 868 E->setAmpAmpLoc(ReadSourceLocation()); 869 E->setLabelLoc(ReadSourceLocation()); 870 E->setLabel(ReadDeclAs<LabelDecl>()); 871 } 872 873 void ASTStmtReader::VisitStmtExpr(StmtExpr *E) { 874 VisitExpr(E); 875 E->setLParenLoc(ReadSourceLocation()); 876 E->setRParenLoc(ReadSourceLocation()); 877 E->setSubStmt(cast_or_null<CompoundStmt>(Record.readSubStmt())); 878 } 879 880 void ASTStmtReader::VisitChooseExpr(ChooseExpr *E) { 881 VisitExpr(E); 882 E->setCond(Record.readSubExpr()); 883 E->setLHS(Record.readSubExpr()); 884 E->setRHS(Record.readSubExpr()); 885 E->setBuiltinLoc(ReadSourceLocation()); 886 E->setRParenLoc(ReadSourceLocation()); 887 E->setIsConditionTrue(Record.readInt()); 888 } 889 890 void ASTStmtReader::VisitGNUNullExpr(GNUNullExpr *E) { 891 VisitExpr(E); 892 E->setTokenLocation(ReadSourceLocation()); 893 } 894 895 void ASTStmtReader::VisitShuffleVectorExpr(ShuffleVectorExpr *E) { 896 VisitExpr(E); 897 SmallVector<Expr *, 16> Exprs; 898 unsigned NumExprs = Record.readInt(); 899 while (NumExprs--) 900 Exprs.push_back(Record.readSubExpr()); 901 E->setExprs(Record.getContext(), Exprs); 902 E->setBuiltinLoc(ReadSourceLocation()); 903 E->setRParenLoc(ReadSourceLocation()); 904 } 905 906 void ASTStmtReader::VisitConvertVectorExpr(ConvertVectorExpr *E) { 907 VisitExpr(E); 908 E->BuiltinLoc = ReadSourceLocation(); 909 E->RParenLoc = ReadSourceLocation(); 910 E->TInfo = GetTypeSourceInfo(); 911 E->SrcExpr = Record.readSubExpr(); 912 } 913 914 void ASTStmtReader::VisitBlockExpr(BlockExpr *E) { 915 VisitExpr(E); 916 E->setBlockDecl(ReadDeclAs<BlockDecl>()); 917 } 918 919 void ASTStmtReader::VisitGenericSelectionExpr(GenericSelectionExpr *E) { 920 VisitExpr(E); 921 E->NumAssocs = Record.readInt(); 922 E->AssocTypes = new (Record.getContext()) TypeSourceInfo*[E->NumAssocs]; 923 E->SubExprs = 924 new(Record.getContext()) Stmt*[GenericSelectionExpr::END_EXPR+E->NumAssocs]; 925 926 E->SubExprs[GenericSelectionExpr::CONTROLLING] = Record.readSubExpr(); 927 for (unsigned I = 0, N = E->getNumAssocs(); I != N; ++I) { 928 E->AssocTypes[I] = GetTypeSourceInfo(); 929 E->SubExprs[GenericSelectionExpr::END_EXPR+I] = Record.readSubExpr(); 930 } 931 E->ResultIndex = Record.readInt(); 932 933 E->GenericLoc = ReadSourceLocation(); 934 E->DefaultLoc = ReadSourceLocation(); 935 E->RParenLoc = ReadSourceLocation(); 936 } 937 938 void ASTStmtReader::VisitPseudoObjectExpr(PseudoObjectExpr *E) { 939 VisitExpr(E); 940 unsigned numSemanticExprs = Record.readInt(); 941 assert(numSemanticExprs + 1 == E->PseudoObjectExprBits.NumSubExprs); 942 E->PseudoObjectExprBits.ResultIndex = Record.readInt(); 943 944 // Read the syntactic expression. 945 E->getSubExprsBuffer()[0] = Record.readSubExpr(); 946 947 // Read all the semantic expressions. 948 for (unsigned i = 0; i != numSemanticExprs; ++i) { 949 Expr *subExpr = Record.readSubExpr(); 950 E->getSubExprsBuffer()[i+1] = subExpr; 951 } 952 } 953 954 void ASTStmtReader::VisitAtomicExpr(AtomicExpr *E) { 955 VisitExpr(E); 956 E->Op = AtomicExpr::AtomicOp(Record.readInt()); 957 E->NumSubExprs = AtomicExpr::getNumSubExprs(E->Op); 958 for (unsigned I = 0; I != E->NumSubExprs; ++I) 959 E->SubExprs[I] = Record.readSubExpr(); 960 E->BuiltinLoc = ReadSourceLocation(); 961 E->RParenLoc = ReadSourceLocation(); 962 } 963 964 //===----------------------------------------------------------------------===// 965 // Objective-C Expressions and Statements 966 967 void ASTStmtReader::VisitObjCStringLiteral(ObjCStringLiteral *E) { 968 VisitExpr(E); 969 E->setString(cast<StringLiteral>(Record.readSubStmt())); 970 E->setAtLoc(ReadSourceLocation()); 971 } 972 973 void ASTStmtReader::VisitObjCBoxedExpr(ObjCBoxedExpr *E) { 974 VisitExpr(E); 975 // could be one of several IntegerLiteral, FloatLiteral, etc. 976 E->SubExpr = Record.readSubStmt(); 977 E->BoxingMethod = ReadDeclAs<ObjCMethodDecl>(); 978 E->Range = ReadSourceRange(); 979 } 980 981 void ASTStmtReader::VisitObjCArrayLiteral(ObjCArrayLiteral *E) { 982 VisitExpr(E); 983 unsigned NumElements = Record.readInt(); 984 assert(NumElements == E->getNumElements() && "Wrong number of elements"); 985 Expr **Elements = E->getElements(); 986 for (unsigned I = 0, N = NumElements; I != N; ++I) 987 Elements[I] = Record.readSubExpr(); 988 E->ArrayWithObjectsMethod = ReadDeclAs<ObjCMethodDecl>(); 989 E->Range = ReadSourceRange(); 990 } 991 992 void ASTStmtReader::VisitObjCDictionaryLiteral(ObjCDictionaryLiteral *E) { 993 VisitExpr(E); 994 unsigned NumElements = Record.readInt(); 995 assert(NumElements == E->getNumElements() && "Wrong number of elements"); 996 bool HasPackExpansions = Record.readInt(); 997 assert(HasPackExpansions == E->HasPackExpansions &&"Pack expansion mismatch"); 998 ObjCDictionaryLiteral::KeyValuePair *KeyValues = 999 E->getTrailingObjects<ObjCDictionaryLiteral::KeyValuePair>(); 1000 ObjCDictionaryLiteral::ExpansionData *Expansions = 1001 E->getTrailingObjects<ObjCDictionaryLiteral::ExpansionData>(); 1002 for (unsigned I = 0; I != NumElements; ++I) { 1003 KeyValues[I].Key = Record.readSubExpr(); 1004 KeyValues[I].Value = Record.readSubExpr(); 1005 if (HasPackExpansions) { 1006 Expansions[I].EllipsisLoc = ReadSourceLocation(); 1007 Expansions[I].NumExpansionsPlusOne = Record.readInt(); 1008 } 1009 } 1010 E->DictWithObjectsMethod = ReadDeclAs<ObjCMethodDecl>(); 1011 E->Range = ReadSourceRange(); 1012 } 1013 1014 void ASTStmtReader::VisitObjCEncodeExpr(ObjCEncodeExpr *E) { 1015 VisitExpr(E); 1016 E->setEncodedTypeSourceInfo(GetTypeSourceInfo()); 1017 E->setAtLoc(ReadSourceLocation()); 1018 E->setRParenLoc(ReadSourceLocation()); 1019 } 1020 1021 void ASTStmtReader::VisitObjCSelectorExpr(ObjCSelectorExpr *E) { 1022 VisitExpr(E); 1023 E->setSelector(Record.readSelector()); 1024 E->setAtLoc(ReadSourceLocation()); 1025 E->setRParenLoc(ReadSourceLocation()); 1026 } 1027 1028 void ASTStmtReader::VisitObjCProtocolExpr(ObjCProtocolExpr *E) { 1029 VisitExpr(E); 1030 E->setProtocol(ReadDeclAs<ObjCProtocolDecl>()); 1031 E->setAtLoc(ReadSourceLocation()); 1032 E->ProtoLoc = ReadSourceLocation(); 1033 E->setRParenLoc(ReadSourceLocation()); 1034 } 1035 1036 void ASTStmtReader::VisitObjCIvarRefExpr(ObjCIvarRefExpr *E) { 1037 VisitExpr(E); 1038 E->setDecl(ReadDeclAs<ObjCIvarDecl>()); 1039 E->setLocation(ReadSourceLocation()); 1040 E->setOpLoc(ReadSourceLocation()); 1041 E->setBase(Record.readSubExpr()); 1042 E->setIsArrow(Record.readInt()); 1043 E->setIsFreeIvar(Record.readInt()); 1044 } 1045 1046 void ASTStmtReader::VisitObjCPropertyRefExpr(ObjCPropertyRefExpr *E) { 1047 VisitExpr(E); 1048 unsigned MethodRefFlags = Record.readInt(); 1049 bool Implicit = Record.readInt() != 0; 1050 if (Implicit) { 1051 ObjCMethodDecl *Getter = ReadDeclAs<ObjCMethodDecl>(); 1052 ObjCMethodDecl *Setter = ReadDeclAs<ObjCMethodDecl>(); 1053 E->setImplicitProperty(Getter, Setter, MethodRefFlags); 1054 } else { 1055 E->setExplicitProperty(ReadDeclAs<ObjCPropertyDecl>(), MethodRefFlags); 1056 } 1057 E->setLocation(ReadSourceLocation()); 1058 E->setReceiverLocation(ReadSourceLocation()); 1059 switch (Record.readInt()) { 1060 case 0: 1061 E->setBase(Record.readSubExpr()); 1062 break; 1063 case 1: 1064 E->setSuperReceiver(Record.readType()); 1065 break; 1066 case 2: 1067 E->setClassReceiver(ReadDeclAs<ObjCInterfaceDecl>()); 1068 break; 1069 } 1070 } 1071 1072 void ASTStmtReader::VisitObjCSubscriptRefExpr(ObjCSubscriptRefExpr *E) { 1073 VisitExpr(E); 1074 E->setRBracket(ReadSourceLocation()); 1075 E->setBaseExpr(Record.readSubExpr()); 1076 E->setKeyExpr(Record.readSubExpr()); 1077 E->GetAtIndexMethodDecl = ReadDeclAs<ObjCMethodDecl>(); 1078 E->SetAtIndexMethodDecl = ReadDeclAs<ObjCMethodDecl>(); 1079 } 1080 1081 void ASTStmtReader::VisitObjCMessageExpr(ObjCMessageExpr *E) { 1082 VisitExpr(E); 1083 assert(Record.peekInt() == E->getNumArgs()); 1084 Record.skipInts(1); 1085 unsigned NumStoredSelLocs = Record.readInt(); 1086 E->SelLocsKind = Record.readInt(); 1087 E->setDelegateInitCall(Record.readInt()); 1088 E->IsImplicit = Record.readInt(); 1089 ObjCMessageExpr::ReceiverKind Kind 1090 = static_cast<ObjCMessageExpr::ReceiverKind>(Record.readInt()); 1091 switch (Kind) { 1092 case ObjCMessageExpr::Instance: 1093 E->setInstanceReceiver(Record.readSubExpr()); 1094 break; 1095 1096 case ObjCMessageExpr::Class: 1097 E->setClassReceiver(GetTypeSourceInfo()); 1098 break; 1099 1100 case ObjCMessageExpr::SuperClass: 1101 case ObjCMessageExpr::SuperInstance: { 1102 QualType T = Record.readType(); 1103 SourceLocation SuperLoc = ReadSourceLocation(); 1104 E->setSuper(SuperLoc, T, Kind == ObjCMessageExpr::SuperInstance); 1105 break; 1106 } 1107 } 1108 1109 assert(Kind == E->getReceiverKind()); 1110 1111 if (Record.readInt()) 1112 E->setMethodDecl(ReadDeclAs<ObjCMethodDecl>()); 1113 else 1114 E->setSelector(Record.readSelector()); 1115 1116 E->LBracLoc = ReadSourceLocation(); 1117 E->RBracLoc = ReadSourceLocation(); 1118 1119 for (unsigned I = 0, N = E->getNumArgs(); I != N; ++I) 1120 E->setArg(I, Record.readSubExpr()); 1121 1122 SourceLocation *Locs = E->getStoredSelLocs(); 1123 for (unsigned I = 0; I != NumStoredSelLocs; ++I) 1124 Locs[I] = ReadSourceLocation(); 1125 } 1126 1127 void ASTStmtReader::VisitObjCForCollectionStmt(ObjCForCollectionStmt *S) { 1128 VisitStmt(S); 1129 S->setElement(Record.readSubStmt()); 1130 S->setCollection(Record.readSubExpr()); 1131 S->setBody(Record.readSubStmt()); 1132 S->setForLoc(ReadSourceLocation()); 1133 S->setRParenLoc(ReadSourceLocation()); 1134 } 1135 1136 void ASTStmtReader::VisitObjCAtCatchStmt(ObjCAtCatchStmt *S) { 1137 VisitStmt(S); 1138 S->setCatchBody(Record.readSubStmt()); 1139 S->setCatchParamDecl(ReadDeclAs<VarDecl>()); 1140 S->setAtCatchLoc(ReadSourceLocation()); 1141 S->setRParenLoc(ReadSourceLocation()); 1142 } 1143 1144 void ASTStmtReader::VisitObjCAtFinallyStmt(ObjCAtFinallyStmt *S) { 1145 VisitStmt(S); 1146 S->setFinallyBody(Record.readSubStmt()); 1147 S->setAtFinallyLoc(ReadSourceLocation()); 1148 } 1149 1150 void ASTStmtReader::VisitObjCAutoreleasePoolStmt(ObjCAutoreleasePoolStmt *S) { 1151 VisitStmt(S); 1152 S->setSubStmt(Record.readSubStmt()); 1153 S->setAtLoc(ReadSourceLocation()); 1154 } 1155 1156 void ASTStmtReader::VisitObjCAtTryStmt(ObjCAtTryStmt *S) { 1157 VisitStmt(S); 1158 assert(Record.peekInt() == S->getNumCatchStmts()); 1159 Record.skipInts(1); 1160 bool HasFinally = Record.readInt(); 1161 S->setTryBody(Record.readSubStmt()); 1162 for (unsigned I = 0, N = S->getNumCatchStmts(); I != N; ++I) 1163 S->setCatchStmt(I, cast_or_null<ObjCAtCatchStmt>(Record.readSubStmt())); 1164 1165 if (HasFinally) 1166 S->setFinallyStmt(Record.readSubStmt()); 1167 S->setAtTryLoc(ReadSourceLocation()); 1168 } 1169 1170 void ASTStmtReader::VisitObjCAtSynchronizedStmt(ObjCAtSynchronizedStmt *S) { 1171 VisitStmt(S); 1172 S->setSynchExpr(Record.readSubStmt()); 1173 S->setSynchBody(Record.readSubStmt()); 1174 S->setAtSynchronizedLoc(ReadSourceLocation()); 1175 } 1176 1177 void ASTStmtReader::VisitObjCAtThrowStmt(ObjCAtThrowStmt *S) { 1178 VisitStmt(S); 1179 S->setThrowExpr(Record.readSubStmt()); 1180 S->setThrowLoc(ReadSourceLocation()); 1181 } 1182 1183 void ASTStmtReader::VisitObjCBoolLiteralExpr(ObjCBoolLiteralExpr *E) { 1184 VisitExpr(E); 1185 E->setValue(Record.readInt()); 1186 E->setLocation(ReadSourceLocation()); 1187 } 1188 1189 void ASTStmtReader::VisitObjCAvailabilityCheckExpr(ObjCAvailabilityCheckExpr *E) { 1190 VisitExpr(E); 1191 SourceRange R = Record.readSourceRange(); 1192 E->AtLoc = R.getBegin(); 1193 E->RParen = R.getEnd(); 1194 E->VersionToCheck = Record.readVersionTuple(); 1195 } 1196 1197 //===----------------------------------------------------------------------===// 1198 // C++ Expressions and Statements 1199 //===----------------------------------------------------------------------===// 1200 1201 void ASTStmtReader::VisitCXXCatchStmt(CXXCatchStmt *S) { 1202 VisitStmt(S); 1203 S->CatchLoc = ReadSourceLocation(); 1204 S->ExceptionDecl = ReadDeclAs<VarDecl>(); 1205 S->HandlerBlock = Record.readSubStmt(); 1206 } 1207 1208 void ASTStmtReader::VisitCXXTryStmt(CXXTryStmt *S) { 1209 VisitStmt(S); 1210 assert(Record.peekInt() == S->getNumHandlers() && "NumStmtFields is wrong ?"); 1211 Record.skipInts(1); 1212 S->TryLoc = ReadSourceLocation(); 1213 S->getStmts()[0] = Record.readSubStmt(); 1214 for (unsigned i = 0, e = S->getNumHandlers(); i != e; ++i) 1215 S->getStmts()[i + 1] = Record.readSubStmt(); 1216 } 1217 1218 void ASTStmtReader::VisitCXXForRangeStmt(CXXForRangeStmt *S) { 1219 VisitStmt(S); 1220 S->ForLoc = ReadSourceLocation(); 1221 S->CoawaitLoc = ReadSourceLocation(); 1222 S->ColonLoc = ReadSourceLocation(); 1223 S->RParenLoc = ReadSourceLocation(); 1224 S->setRangeStmt(Record.readSubStmt()); 1225 S->setBeginStmt(Record.readSubStmt()); 1226 S->setEndStmt(Record.readSubStmt()); 1227 S->setCond(Record.readSubExpr()); 1228 S->setInc(Record.readSubExpr()); 1229 S->setLoopVarStmt(Record.readSubStmt()); 1230 S->setBody(Record.readSubStmt()); 1231 } 1232 1233 void ASTStmtReader::VisitMSDependentExistsStmt(MSDependentExistsStmt *S) { 1234 VisitStmt(S); 1235 S->KeywordLoc = ReadSourceLocation(); 1236 S->IsIfExists = Record.readInt(); 1237 S->QualifierLoc = Record.readNestedNameSpecifierLoc(); 1238 ReadDeclarationNameInfo(S->NameInfo); 1239 S->SubStmt = Record.readSubStmt(); 1240 } 1241 1242 void ASTStmtReader::VisitCXXOperatorCallExpr(CXXOperatorCallExpr *E) { 1243 VisitCallExpr(E); 1244 E->Operator = (OverloadedOperatorKind)Record.readInt(); 1245 E->Range = Record.readSourceRange(); 1246 E->setFPFeatures(FPOptions(Record.readInt())); 1247 } 1248 1249 void ASTStmtReader::VisitCXXConstructExpr(CXXConstructExpr *E) { 1250 VisitExpr(E); 1251 E->NumArgs = Record.readInt(); 1252 if (E->NumArgs) 1253 E->Args = new (Record.getContext()) Stmt*[E->NumArgs]; 1254 for (unsigned I = 0, N = E->getNumArgs(); I != N; ++I) 1255 E->setArg(I, Record.readSubExpr()); 1256 E->setConstructor(ReadDeclAs<CXXConstructorDecl>()); 1257 E->setLocation(ReadSourceLocation()); 1258 E->setElidable(Record.readInt()); 1259 E->setHadMultipleCandidates(Record.readInt()); 1260 E->setListInitialization(Record.readInt()); 1261 E->setStdInitListInitialization(Record.readInt()); 1262 E->setRequiresZeroInitialization(Record.readInt()); 1263 E->setConstructionKind((CXXConstructExpr::ConstructionKind)Record.readInt()); 1264 E->ParenOrBraceRange = ReadSourceRange(); 1265 } 1266 1267 void ASTStmtReader::VisitCXXInheritedCtorInitExpr(CXXInheritedCtorInitExpr *E) { 1268 VisitExpr(E); 1269 E->Constructor = ReadDeclAs<CXXConstructorDecl>(); 1270 E->Loc = ReadSourceLocation(); 1271 E->ConstructsVirtualBase = Record.readInt(); 1272 E->InheritedFromVirtualBase = Record.readInt(); 1273 } 1274 1275 void ASTStmtReader::VisitCXXTemporaryObjectExpr(CXXTemporaryObjectExpr *E) { 1276 VisitCXXConstructExpr(E); 1277 E->Type = GetTypeSourceInfo(); 1278 } 1279 1280 void ASTStmtReader::VisitLambdaExpr(LambdaExpr *E) { 1281 VisitExpr(E); 1282 unsigned NumCaptures = Record.readInt(); 1283 assert(NumCaptures == E->NumCaptures);(void)NumCaptures; 1284 E->IntroducerRange = ReadSourceRange(); 1285 E->CaptureDefault = static_cast<LambdaCaptureDefault>(Record.readInt()); 1286 E->CaptureDefaultLoc = ReadSourceLocation(); 1287 E->ExplicitParams = Record.readInt(); 1288 E->ExplicitResultType = Record.readInt(); 1289 E->ClosingBrace = ReadSourceLocation(); 1290 1291 // Read capture initializers. 1292 for (LambdaExpr::capture_init_iterator C = E->capture_init_begin(), 1293 CEnd = E->capture_init_end(); 1294 C != CEnd; ++C) 1295 *C = Record.readSubExpr(); 1296 } 1297 1298 void 1299 ASTStmtReader::VisitCXXStdInitializerListExpr(CXXStdInitializerListExpr *E) { 1300 VisitExpr(E); 1301 E->SubExpr = Record.readSubExpr(); 1302 } 1303 1304 void ASTStmtReader::VisitCXXNamedCastExpr(CXXNamedCastExpr *E) { 1305 VisitExplicitCastExpr(E); 1306 SourceRange R = ReadSourceRange(); 1307 E->Loc = R.getBegin(); 1308 E->RParenLoc = R.getEnd(); 1309 R = ReadSourceRange(); 1310 E->AngleBrackets = R; 1311 } 1312 1313 void ASTStmtReader::VisitCXXStaticCastExpr(CXXStaticCastExpr *E) { 1314 return VisitCXXNamedCastExpr(E); 1315 } 1316 1317 void ASTStmtReader::VisitCXXDynamicCastExpr(CXXDynamicCastExpr *E) { 1318 return VisitCXXNamedCastExpr(E); 1319 } 1320 1321 void ASTStmtReader::VisitCXXReinterpretCastExpr(CXXReinterpretCastExpr *E) { 1322 return VisitCXXNamedCastExpr(E); 1323 } 1324 1325 void ASTStmtReader::VisitCXXConstCastExpr(CXXConstCastExpr *E) { 1326 return VisitCXXNamedCastExpr(E); 1327 } 1328 1329 void ASTStmtReader::VisitCXXFunctionalCastExpr(CXXFunctionalCastExpr *E) { 1330 VisitExplicitCastExpr(E); 1331 E->setLParenLoc(ReadSourceLocation()); 1332 E->setRParenLoc(ReadSourceLocation()); 1333 } 1334 1335 void ASTStmtReader::VisitUserDefinedLiteral(UserDefinedLiteral *E) { 1336 VisitCallExpr(E); 1337 E->UDSuffixLoc = ReadSourceLocation(); 1338 } 1339 1340 void ASTStmtReader::VisitCXXBoolLiteralExpr(CXXBoolLiteralExpr *E) { 1341 VisitExpr(E); 1342 E->setValue(Record.readInt()); 1343 E->setLocation(ReadSourceLocation()); 1344 } 1345 1346 void ASTStmtReader::VisitCXXNullPtrLiteralExpr(CXXNullPtrLiteralExpr *E) { 1347 VisitExpr(E); 1348 E->setLocation(ReadSourceLocation()); 1349 } 1350 1351 void ASTStmtReader::VisitCXXTypeidExpr(CXXTypeidExpr *E) { 1352 VisitExpr(E); 1353 E->setSourceRange(ReadSourceRange()); 1354 if (E->isTypeOperand()) { // typeid(int) 1355 E->setTypeOperandSourceInfo( 1356 GetTypeSourceInfo()); 1357 return; 1358 } 1359 1360 // typeid(42+2) 1361 E->setExprOperand(Record.readSubExpr()); 1362 } 1363 1364 void ASTStmtReader::VisitCXXThisExpr(CXXThisExpr *E) { 1365 VisitExpr(E); 1366 E->setLocation(ReadSourceLocation()); 1367 E->setImplicit(Record.readInt()); 1368 } 1369 1370 void ASTStmtReader::VisitCXXThrowExpr(CXXThrowExpr *E) { 1371 VisitExpr(E); 1372 E->ThrowLoc = ReadSourceLocation(); 1373 E->Op = Record.readSubExpr(); 1374 E->IsThrownVariableInScope = Record.readInt(); 1375 } 1376 1377 void ASTStmtReader::VisitCXXDefaultArgExpr(CXXDefaultArgExpr *E) { 1378 VisitExpr(E); 1379 E->Param = ReadDeclAs<ParmVarDecl>(); 1380 E->Loc = ReadSourceLocation(); 1381 } 1382 1383 void ASTStmtReader::VisitCXXDefaultInitExpr(CXXDefaultInitExpr *E) { 1384 VisitExpr(E); 1385 E->Field = ReadDeclAs<FieldDecl>(); 1386 E->Loc = ReadSourceLocation(); 1387 } 1388 1389 void ASTStmtReader::VisitCXXBindTemporaryExpr(CXXBindTemporaryExpr *E) { 1390 VisitExpr(E); 1391 E->setTemporary(Record.readCXXTemporary()); 1392 E->setSubExpr(Record.readSubExpr()); 1393 } 1394 1395 void ASTStmtReader::VisitCXXScalarValueInitExpr(CXXScalarValueInitExpr *E) { 1396 VisitExpr(E); 1397 E->TypeInfo = GetTypeSourceInfo(); 1398 E->RParenLoc = ReadSourceLocation(); 1399 } 1400 1401 void ASTStmtReader::VisitCXXNewExpr(CXXNewExpr *E) { 1402 VisitExpr(E); 1403 E->GlobalNew = Record.readInt(); 1404 bool isArray = Record.readInt(); 1405 E->PassAlignment = Record.readInt(); 1406 E->UsualArrayDeleteWantsSize = Record.readInt(); 1407 unsigned NumPlacementArgs = Record.readInt(); 1408 E->StoredInitializationStyle = Record.readInt(); 1409 E->setOperatorNew(ReadDeclAs<FunctionDecl>()); 1410 E->setOperatorDelete(ReadDeclAs<FunctionDecl>()); 1411 E->AllocatedTypeInfo = GetTypeSourceInfo(); 1412 E->TypeIdParens = ReadSourceRange(); 1413 E->Range = ReadSourceRange(); 1414 E->DirectInitRange = ReadSourceRange(); 1415 1416 E->AllocateArgsArray(Record.getContext(), isArray, NumPlacementArgs, 1417 E->StoredInitializationStyle != 0); 1418 1419 // Install all the subexpressions. 1420 for (CXXNewExpr::raw_arg_iterator I = E->raw_arg_begin(),e = E->raw_arg_end(); 1421 I != e; ++I) 1422 *I = Record.readSubStmt(); 1423 } 1424 1425 void ASTStmtReader::VisitCXXDeleteExpr(CXXDeleteExpr *E) { 1426 VisitExpr(E); 1427 E->GlobalDelete = Record.readInt(); 1428 E->ArrayForm = Record.readInt(); 1429 E->ArrayFormAsWritten = Record.readInt(); 1430 E->UsualArrayDeleteWantsSize = Record.readInt(); 1431 E->OperatorDelete = ReadDeclAs<FunctionDecl>(); 1432 E->Argument = Record.readSubExpr(); 1433 E->Loc = ReadSourceLocation(); 1434 } 1435 1436 void ASTStmtReader::VisitCXXPseudoDestructorExpr(CXXPseudoDestructorExpr *E) { 1437 VisitExpr(E); 1438 1439 E->Base = Record.readSubExpr(); 1440 E->IsArrow = Record.readInt(); 1441 E->OperatorLoc = ReadSourceLocation(); 1442 E->QualifierLoc = Record.readNestedNameSpecifierLoc(); 1443 E->ScopeType = GetTypeSourceInfo(); 1444 E->ColonColonLoc = ReadSourceLocation(); 1445 E->TildeLoc = ReadSourceLocation(); 1446 1447 IdentifierInfo *II = Record.getIdentifierInfo(); 1448 if (II) 1449 E->setDestroyedType(II, ReadSourceLocation()); 1450 else 1451 E->setDestroyedType(GetTypeSourceInfo()); 1452 } 1453 1454 void ASTStmtReader::VisitExprWithCleanups(ExprWithCleanups *E) { 1455 VisitExpr(E); 1456 1457 unsigned NumObjects = Record.readInt(); 1458 assert(NumObjects == E->getNumObjects()); 1459 for (unsigned i = 0; i != NumObjects; ++i) 1460 E->getTrailingObjects<BlockDecl *>()[i] = 1461 ReadDeclAs<BlockDecl>(); 1462 1463 E->ExprWithCleanupsBits.CleanupsHaveSideEffects = Record.readInt(); 1464 E->SubExpr = Record.readSubExpr(); 1465 } 1466 1467 void 1468 ASTStmtReader::VisitCXXDependentScopeMemberExpr(CXXDependentScopeMemberExpr *E){ 1469 VisitExpr(E); 1470 1471 if (Record.readInt()) // HasTemplateKWAndArgsInfo 1472 ReadTemplateKWAndArgsInfo( 1473 *E->getTrailingObjects<ASTTemplateKWAndArgsInfo>(), 1474 E->getTrailingObjects<TemplateArgumentLoc>(), 1475 /*NumTemplateArgs=*/Record.readInt()); 1476 1477 E->Base = Record.readSubExpr(); 1478 E->BaseType = Record.readType(); 1479 E->IsArrow = Record.readInt(); 1480 E->OperatorLoc = ReadSourceLocation(); 1481 E->QualifierLoc = Record.readNestedNameSpecifierLoc(); 1482 E->FirstQualifierFoundInScope = ReadDeclAs<NamedDecl>(); 1483 ReadDeclarationNameInfo(E->MemberNameInfo); 1484 } 1485 1486 void 1487 ASTStmtReader::VisitDependentScopeDeclRefExpr(DependentScopeDeclRefExpr *E) { 1488 VisitExpr(E); 1489 1490 if (Record.readInt()) // HasTemplateKWAndArgsInfo 1491 ReadTemplateKWAndArgsInfo( 1492 *E->getTrailingObjects<ASTTemplateKWAndArgsInfo>(), 1493 E->getTrailingObjects<TemplateArgumentLoc>(), 1494 /*NumTemplateArgs=*/Record.readInt()); 1495 1496 E->QualifierLoc = Record.readNestedNameSpecifierLoc(); 1497 ReadDeclarationNameInfo(E->NameInfo); 1498 } 1499 1500 void 1501 ASTStmtReader::VisitCXXUnresolvedConstructExpr(CXXUnresolvedConstructExpr *E) { 1502 VisitExpr(E); 1503 assert(Record.peekInt() == E->arg_size() && 1504 "Read wrong record during creation ?"); 1505 Record.skipInts(1); 1506 for (unsigned I = 0, N = E->arg_size(); I != N; ++I) 1507 E->setArg(I, Record.readSubExpr()); 1508 E->Type = GetTypeSourceInfo(); 1509 E->setLParenLoc(ReadSourceLocation()); 1510 E->setRParenLoc(ReadSourceLocation()); 1511 } 1512 1513 void ASTStmtReader::VisitOverloadExpr(OverloadExpr *E) { 1514 VisitExpr(E); 1515 1516 if (Record.readInt()) // HasTemplateKWAndArgsInfo 1517 ReadTemplateKWAndArgsInfo(*E->getTrailingASTTemplateKWAndArgsInfo(), 1518 E->getTrailingTemplateArgumentLoc(), 1519 /*NumTemplateArgs=*/Record.readInt()); 1520 1521 unsigned NumDecls = Record.readInt(); 1522 UnresolvedSet<8> Decls; 1523 for (unsigned i = 0; i != NumDecls; ++i) { 1524 NamedDecl *D = ReadDeclAs<NamedDecl>(); 1525 AccessSpecifier AS = (AccessSpecifier)Record.readInt(); 1526 Decls.addDecl(D, AS); 1527 } 1528 E->initializeResults(Record.getContext(), Decls.begin(), Decls.end()); 1529 1530 ReadDeclarationNameInfo(E->NameInfo); 1531 E->QualifierLoc = Record.readNestedNameSpecifierLoc(); 1532 } 1533 1534 void ASTStmtReader::VisitUnresolvedMemberExpr(UnresolvedMemberExpr *E) { 1535 VisitOverloadExpr(E); 1536 E->IsArrow = Record.readInt(); 1537 E->HasUnresolvedUsing = Record.readInt(); 1538 E->Base = Record.readSubExpr(); 1539 E->BaseType = Record.readType(); 1540 E->OperatorLoc = ReadSourceLocation(); 1541 } 1542 1543 void ASTStmtReader::VisitUnresolvedLookupExpr(UnresolvedLookupExpr *E) { 1544 VisitOverloadExpr(E); 1545 E->RequiresADL = Record.readInt(); 1546 E->Overloaded = Record.readInt(); 1547 E->NamingClass = ReadDeclAs<CXXRecordDecl>(); 1548 } 1549 1550 void ASTStmtReader::VisitTypeTraitExpr(TypeTraitExpr *E) { 1551 VisitExpr(E); 1552 E->TypeTraitExprBits.NumArgs = Record.readInt(); 1553 E->TypeTraitExprBits.Kind = Record.readInt(); 1554 E->TypeTraitExprBits.Value = Record.readInt(); 1555 SourceRange Range = ReadSourceRange(); 1556 E->Loc = Range.getBegin(); 1557 E->RParenLoc = Range.getEnd(); 1558 1559 TypeSourceInfo **Args = E->getTrailingObjects<TypeSourceInfo *>(); 1560 for (unsigned I = 0, N = E->getNumArgs(); I != N; ++I) 1561 Args[I] = GetTypeSourceInfo(); 1562 } 1563 1564 void ASTStmtReader::VisitArrayTypeTraitExpr(ArrayTypeTraitExpr *E) { 1565 VisitExpr(E); 1566 E->ATT = (ArrayTypeTrait)Record.readInt(); 1567 E->Value = (unsigned int)Record.readInt(); 1568 SourceRange Range = ReadSourceRange(); 1569 E->Loc = Range.getBegin(); 1570 E->RParen = Range.getEnd(); 1571 E->QueriedType = GetTypeSourceInfo(); 1572 E->Dimension = Record.readSubExpr(); 1573 } 1574 1575 void ASTStmtReader::VisitExpressionTraitExpr(ExpressionTraitExpr *E) { 1576 VisitExpr(E); 1577 E->ET = (ExpressionTrait)Record.readInt(); 1578 E->Value = (bool)Record.readInt(); 1579 SourceRange Range = ReadSourceRange(); 1580 E->QueriedExpression = Record.readSubExpr(); 1581 E->Loc = Range.getBegin(); 1582 E->RParen = Range.getEnd(); 1583 } 1584 1585 void ASTStmtReader::VisitCXXNoexceptExpr(CXXNoexceptExpr *E) { 1586 VisitExpr(E); 1587 E->Value = (bool)Record.readInt(); 1588 E->Range = ReadSourceRange(); 1589 E->Operand = Record.readSubExpr(); 1590 } 1591 1592 void ASTStmtReader::VisitPackExpansionExpr(PackExpansionExpr *E) { 1593 VisitExpr(E); 1594 E->EllipsisLoc = ReadSourceLocation(); 1595 E->NumExpansions = Record.readInt(); 1596 E->Pattern = Record.readSubExpr(); 1597 } 1598 1599 void ASTStmtReader::VisitSizeOfPackExpr(SizeOfPackExpr *E) { 1600 VisitExpr(E); 1601 unsigned NumPartialArgs = Record.readInt(); 1602 E->OperatorLoc = ReadSourceLocation(); 1603 E->PackLoc = ReadSourceLocation(); 1604 E->RParenLoc = ReadSourceLocation(); 1605 E->Pack = Record.readDeclAs<NamedDecl>(); 1606 if (E->isPartiallySubstituted()) { 1607 assert(E->Length == NumPartialArgs); 1608 for (auto *I = E->getTrailingObjects<TemplateArgument>(), 1609 *E = I + NumPartialArgs; 1610 I != E; ++I) 1611 new (I) TemplateArgument(Record.readTemplateArgument()); 1612 } else if (!E->isValueDependent()) { 1613 E->Length = Record.readInt(); 1614 } 1615 } 1616 1617 void ASTStmtReader::VisitSubstNonTypeTemplateParmExpr( 1618 SubstNonTypeTemplateParmExpr *E) { 1619 VisitExpr(E); 1620 E->Param = ReadDeclAs<NonTypeTemplateParmDecl>(); 1621 E->NameLoc = ReadSourceLocation(); 1622 E->Replacement = Record.readSubExpr(); 1623 } 1624 1625 void ASTStmtReader::VisitSubstNonTypeTemplateParmPackExpr( 1626 SubstNonTypeTemplateParmPackExpr *E) { 1627 VisitExpr(E); 1628 E->Param = ReadDeclAs<NonTypeTemplateParmDecl>(); 1629 TemplateArgument ArgPack = Record.readTemplateArgument(); 1630 if (ArgPack.getKind() != TemplateArgument::Pack) 1631 return; 1632 1633 E->Arguments = ArgPack.pack_begin(); 1634 E->NumArguments = ArgPack.pack_size(); 1635 E->NameLoc = ReadSourceLocation(); 1636 } 1637 1638 void ASTStmtReader::VisitFunctionParmPackExpr(FunctionParmPackExpr *E) { 1639 VisitExpr(E); 1640 E->NumParameters = Record.readInt(); 1641 E->ParamPack = ReadDeclAs<ParmVarDecl>(); 1642 E->NameLoc = ReadSourceLocation(); 1643 ParmVarDecl **Parms = E->getTrailingObjects<ParmVarDecl *>(); 1644 for (unsigned i = 0, n = E->NumParameters; i != n; ++i) 1645 Parms[i] = ReadDeclAs<ParmVarDecl>(); 1646 } 1647 1648 void ASTStmtReader::VisitMaterializeTemporaryExpr(MaterializeTemporaryExpr *E) { 1649 VisitExpr(E); 1650 E->State = Record.readSubExpr(); 1651 auto VD = ReadDeclAs<ValueDecl>(); 1652 unsigned ManglingNumber = Record.readInt(); 1653 E->setExtendingDecl(VD, ManglingNumber); 1654 } 1655 1656 void ASTStmtReader::VisitCXXFoldExpr(CXXFoldExpr *E) { 1657 VisitExpr(E); 1658 E->LParenLoc = ReadSourceLocation(); 1659 E->EllipsisLoc = ReadSourceLocation(); 1660 E->RParenLoc = ReadSourceLocation(); 1661 E->SubExprs[0] = Record.readSubExpr(); 1662 E->SubExprs[1] = Record.readSubExpr(); 1663 E->Opcode = (BinaryOperatorKind)Record.readInt(); 1664 } 1665 1666 void ASTStmtReader::VisitOpaqueValueExpr(OpaqueValueExpr *E) { 1667 VisitExpr(E); 1668 E->SourceExpr = Record.readSubExpr(); 1669 E->Loc = ReadSourceLocation(); 1670 } 1671 1672 void ASTStmtReader::VisitTypoExpr(TypoExpr *E) { 1673 llvm_unreachable("Cannot read TypoExpr nodes"); 1674 } 1675 1676 //===----------------------------------------------------------------------===// 1677 // Microsoft Expressions and Statements 1678 //===----------------------------------------------------------------------===// 1679 void ASTStmtReader::VisitMSPropertyRefExpr(MSPropertyRefExpr *E) { 1680 VisitExpr(E); 1681 E->IsArrow = (Record.readInt() != 0); 1682 E->BaseExpr = Record.readSubExpr(); 1683 E->QualifierLoc = Record.readNestedNameSpecifierLoc(); 1684 E->MemberLoc = ReadSourceLocation(); 1685 E->TheDecl = ReadDeclAs<MSPropertyDecl>(); 1686 } 1687 1688 void ASTStmtReader::VisitMSPropertySubscriptExpr(MSPropertySubscriptExpr *E) { 1689 VisitExpr(E); 1690 E->setBase(Record.readSubExpr()); 1691 E->setIdx(Record.readSubExpr()); 1692 E->setRBracketLoc(ReadSourceLocation()); 1693 } 1694 1695 void ASTStmtReader::VisitCXXUuidofExpr(CXXUuidofExpr *E) { 1696 VisitExpr(E); 1697 E->setSourceRange(ReadSourceRange()); 1698 std::string UuidStr = ReadString(); 1699 E->setUuidStr(StringRef(UuidStr).copy(Record.getContext())); 1700 if (E->isTypeOperand()) { // __uuidof(ComType) 1701 E->setTypeOperandSourceInfo( 1702 GetTypeSourceInfo()); 1703 return; 1704 } 1705 1706 // __uuidof(expr) 1707 E->setExprOperand(Record.readSubExpr()); 1708 } 1709 1710 void ASTStmtReader::VisitSEHLeaveStmt(SEHLeaveStmt *S) { 1711 VisitStmt(S); 1712 S->setLeaveLoc(ReadSourceLocation()); 1713 } 1714 1715 void ASTStmtReader::VisitSEHExceptStmt(SEHExceptStmt *S) { 1716 VisitStmt(S); 1717 S->Loc = ReadSourceLocation(); 1718 S->Children[SEHExceptStmt::FILTER_EXPR] = Record.readSubStmt(); 1719 S->Children[SEHExceptStmt::BLOCK] = Record.readSubStmt(); 1720 } 1721 1722 void ASTStmtReader::VisitSEHFinallyStmt(SEHFinallyStmt *S) { 1723 VisitStmt(S); 1724 S->Loc = ReadSourceLocation(); 1725 S->Block = Record.readSubStmt(); 1726 } 1727 1728 void ASTStmtReader::VisitSEHTryStmt(SEHTryStmt *S) { 1729 VisitStmt(S); 1730 S->IsCXXTry = Record.readInt(); 1731 S->TryLoc = ReadSourceLocation(); 1732 S->Children[SEHTryStmt::TRY] = Record.readSubStmt(); 1733 S->Children[SEHTryStmt::HANDLER] = Record.readSubStmt(); 1734 } 1735 1736 //===----------------------------------------------------------------------===// 1737 // CUDA Expressions and Statements 1738 //===----------------------------------------------------------------------===// 1739 1740 void ASTStmtReader::VisitCUDAKernelCallExpr(CUDAKernelCallExpr *E) { 1741 VisitCallExpr(E); 1742 E->setConfig(cast<CallExpr>(Record.readSubExpr())); 1743 } 1744 1745 //===----------------------------------------------------------------------===// 1746 // OpenCL Expressions and Statements. 1747 //===----------------------------------------------------------------------===// 1748 void ASTStmtReader::VisitAsTypeExpr(AsTypeExpr *E) { 1749 VisitExpr(E); 1750 E->BuiltinLoc = ReadSourceLocation(); 1751 E->RParenLoc = ReadSourceLocation(); 1752 E->SrcExpr = Record.readSubExpr(); 1753 } 1754 1755 //===----------------------------------------------------------------------===// 1756 // OpenMP Clauses. 1757 //===----------------------------------------------------------------------===// 1758 1759 namespace clang { 1760 class OMPClauseReader : public OMPClauseVisitor<OMPClauseReader> { 1761 ASTStmtReader *Reader; 1762 ASTContext &Context; 1763 public: 1764 OMPClauseReader(ASTStmtReader *R, ASTRecordReader &Record) 1765 : Reader(R), Context(Record.getContext()) {} 1766 #define OPENMP_CLAUSE(Name, Class) void Visit##Class(Class *C); 1767 #include "clang/Basic/OpenMPKinds.def" 1768 OMPClause *readClause(); 1769 void VisitOMPClauseWithPreInit(OMPClauseWithPreInit *C); 1770 void VisitOMPClauseWithPostUpdate(OMPClauseWithPostUpdate *C); 1771 }; 1772 } 1773 1774 OMPClause *OMPClauseReader::readClause() { 1775 OMPClause *C; 1776 switch (Reader->Record.readInt()) { 1777 case OMPC_if: 1778 C = new (Context) OMPIfClause(); 1779 break; 1780 case OMPC_final: 1781 C = new (Context) OMPFinalClause(); 1782 break; 1783 case OMPC_num_threads: 1784 C = new (Context) OMPNumThreadsClause(); 1785 break; 1786 case OMPC_safelen: 1787 C = new (Context) OMPSafelenClause(); 1788 break; 1789 case OMPC_simdlen: 1790 C = new (Context) OMPSimdlenClause(); 1791 break; 1792 case OMPC_collapse: 1793 C = new (Context) OMPCollapseClause(); 1794 break; 1795 case OMPC_default: 1796 C = new (Context) OMPDefaultClause(); 1797 break; 1798 case OMPC_proc_bind: 1799 C = new (Context) OMPProcBindClause(); 1800 break; 1801 case OMPC_schedule: 1802 C = new (Context) OMPScheduleClause(); 1803 break; 1804 case OMPC_ordered: 1805 C = new (Context) OMPOrderedClause(); 1806 break; 1807 case OMPC_nowait: 1808 C = new (Context) OMPNowaitClause(); 1809 break; 1810 case OMPC_untied: 1811 C = new (Context) OMPUntiedClause(); 1812 break; 1813 case OMPC_mergeable: 1814 C = new (Context) OMPMergeableClause(); 1815 break; 1816 case OMPC_read: 1817 C = new (Context) OMPReadClause(); 1818 break; 1819 case OMPC_write: 1820 C = new (Context) OMPWriteClause(); 1821 break; 1822 case OMPC_update: 1823 C = new (Context) OMPUpdateClause(); 1824 break; 1825 case OMPC_capture: 1826 C = new (Context) OMPCaptureClause(); 1827 break; 1828 case OMPC_seq_cst: 1829 C = new (Context) OMPSeqCstClause(); 1830 break; 1831 case OMPC_threads: 1832 C = new (Context) OMPThreadsClause(); 1833 break; 1834 case OMPC_simd: 1835 C = new (Context) OMPSIMDClause(); 1836 break; 1837 case OMPC_nogroup: 1838 C = new (Context) OMPNogroupClause(); 1839 break; 1840 case OMPC_private: 1841 C = OMPPrivateClause::CreateEmpty(Context, Reader->Record.readInt()); 1842 break; 1843 case OMPC_firstprivate: 1844 C = OMPFirstprivateClause::CreateEmpty(Context, Reader->Record.readInt()); 1845 break; 1846 case OMPC_lastprivate: 1847 C = OMPLastprivateClause::CreateEmpty(Context, Reader->Record.readInt()); 1848 break; 1849 case OMPC_shared: 1850 C = OMPSharedClause::CreateEmpty(Context, Reader->Record.readInt()); 1851 break; 1852 case OMPC_reduction: 1853 C = OMPReductionClause::CreateEmpty(Context, Reader->Record.readInt()); 1854 break; 1855 case OMPC_task_reduction: 1856 C = OMPTaskReductionClause::CreateEmpty(Context, Reader->Record.readInt()); 1857 break; 1858 case OMPC_in_reduction: 1859 C = OMPInReductionClause::CreateEmpty(Context, Reader->Record.readInt()); 1860 break; 1861 case OMPC_linear: 1862 C = OMPLinearClause::CreateEmpty(Context, Reader->Record.readInt()); 1863 break; 1864 case OMPC_aligned: 1865 C = OMPAlignedClause::CreateEmpty(Context, Reader->Record.readInt()); 1866 break; 1867 case OMPC_copyin: 1868 C = OMPCopyinClause::CreateEmpty(Context, Reader->Record.readInt()); 1869 break; 1870 case OMPC_copyprivate: 1871 C = OMPCopyprivateClause::CreateEmpty(Context, Reader->Record.readInt()); 1872 break; 1873 case OMPC_flush: 1874 C = OMPFlushClause::CreateEmpty(Context, Reader->Record.readInt()); 1875 break; 1876 case OMPC_depend: 1877 C = OMPDependClause::CreateEmpty(Context, Reader->Record.readInt()); 1878 break; 1879 case OMPC_device: 1880 C = new (Context) OMPDeviceClause(); 1881 break; 1882 case OMPC_map: { 1883 unsigned NumVars = Reader->Record.readInt(); 1884 unsigned NumDeclarations = Reader->Record.readInt(); 1885 unsigned NumLists = Reader->Record.readInt(); 1886 unsigned NumComponents = Reader->Record.readInt(); 1887 C = OMPMapClause::CreateEmpty(Context, NumVars, NumDeclarations, NumLists, 1888 NumComponents); 1889 break; 1890 } 1891 case OMPC_num_teams: 1892 C = new (Context) OMPNumTeamsClause(); 1893 break; 1894 case OMPC_thread_limit: 1895 C = new (Context) OMPThreadLimitClause(); 1896 break; 1897 case OMPC_priority: 1898 C = new (Context) OMPPriorityClause(); 1899 break; 1900 case OMPC_grainsize: 1901 C = new (Context) OMPGrainsizeClause(); 1902 break; 1903 case OMPC_num_tasks: 1904 C = new (Context) OMPNumTasksClause(); 1905 break; 1906 case OMPC_hint: 1907 C = new (Context) OMPHintClause(); 1908 break; 1909 case OMPC_dist_schedule: 1910 C = new (Context) OMPDistScheduleClause(); 1911 break; 1912 case OMPC_defaultmap: 1913 C = new (Context) OMPDefaultmapClause(); 1914 break; 1915 case OMPC_to: { 1916 unsigned NumVars = Reader->Record.readInt(); 1917 unsigned NumDeclarations = Reader->Record.readInt(); 1918 unsigned NumLists = Reader->Record.readInt(); 1919 unsigned NumComponents = Reader->Record.readInt(); 1920 C = OMPToClause::CreateEmpty(Context, NumVars, NumDeclarations, NumLists, 1921 NumComponents); 1922 break; 1923 } 1924 case OMPC_from: { 1925 unsigned NumVars = Reader->Record.readInt(); 1926 unsigned NumDeclarations = Reader->Record.readInt(); 1927 unsigned NumLists = Reader->Record.readInt(); 1928 unsigned NumComponents = Reader->Record.readInt(); 1929 C = OMPFromClause::CreateEmpty(Context, NumVars, NumDeclarations, NumLists, 1930 NumComponents); 1931 break; 1932 } 1933 case OMPC_use_device_ptr: { 1934 unsigned NumVars = Reader->Record.readInt(); 1935 unsigned NumDeclarations = Reader->Record.readInt(); 1936 unsigned NumLists = Reader->Record.readInt(); 1937 unsigned NumComponents = Reader->Record.readInt(); 1938 C = OMPUseDevicePtrClause::CreateEmpty(Context, NumVars, NumDeclarations, 1939 NumLists, NumComponents); 1940 break; 1941 } 1942 case OMPC_is_device_ptr: { 1943 unsigned NumVars = Reader->Record.readInt(); 1944 unsigned NumDeclarations = Reader->Record.readInt(); 1945 unsigned NumLists = Reader->Record.readInt(); 1946 unsigned NumComponents = Reader->Record.readInt(); 1947 C = OMPIsDevicePtrClause::CreateEmpty(Context, NumVars, NumDeclarations, 1948 NumLists, NumComponents); 1949 break; 1950 } 1951 } 1952 Visit(C); 1953 C->setLocStart(Reader->ReadSourceLocation()); 1954 C->setLocEnd(Reader->ReadSourceLocation()); 1955 1956 return C; 1957 } 1958 1959 void OMPClauseReader::VisitOMPClauseWithPreInit(OMPClauseWithPreInit *C) { 1960 C->setPreInitStmt(Reader->Record.readSubStmt(), 1961 static_cast<OpenMPDirectiveKind>(Reader->Record.readInt())); 1962 } 1963 1964 void OMPClauseReader::VisitOMPClauseWithPostUpdate(OMPClauseWithPostUpdate *C) { 1965 VisitOMPClauseWithPreInit(C); 1966 C->setPostUpdateExpr(Reader->Record.readSubExpr()); 1967 } 1968 1969 void OMPClauseReader::VisitOMPIfClause(OMPIfClause *C) { 1970 VisitOMPClauseWithPreInit(C); 1971 C->setNameModifier(static_cast<OpenMPDirectiveKind>(Reader->Record.readInt())); 1972 C->setNameModifierLoc(Reader->ReadSourceLocation()); 1973 C->setColonLoc(Reader->ReadSourceLocation()); 1974 C->setCondition(Reader->Record.readSubExpr()); 1975 C->setLParenLoc(Reader->ReadSourceLocation()); 1976 } 1977 1978 void OMPClauseReader::VisitOMPFinalClause(OMPFinalClause *C) { 1979 C->setCondition(Reader->Record.readSubExpr()); 1980 C->setLParenLoc(Reader->ReadSourceLocation()); 1981 } 1982 1983 void OMPClauseReader::VisitOMPNumThreadsClause(OMPNumThreadsClause *C) { 1984 VisitOMPClauseWithPreInit(C); 1985 C->setNumThreads(Reader->Record.readSubExpr()); 1986 C->setLParenLoc(Reader->ReadSourceLocation()); 1987 } 1988 1989 void OMPClauseReader::VisitOMPSafelenClause(OMPSafelenClause *C) { 1990 C->setSafelen(Reader->Record.readSubExpr()); 1991 C->setLParenLoc(Reader->ReadSourceLocation()); 1992 } 1993 1994 void OMPClauseReader::VisitOMPSimdlenClause(OMPSimdlenClause *C) { 1995 C->setSimdlen(Reader->Record.readSubExpr()); 1996 C->setLParenLoc(Reader->ReadSourceLocation()); 1997 } 1998 1999 void OMPClauseReader::VisitOMPCollapseClause(OMPCollapseClause *C) { 2000 C->setNumForLoops(Reader->Record.readSubExpr()); 2001 C->setLParenLoc(Reader->ReadSourceLocation()); 2002 } 2003 2004 void OMPClauseReader::VisitOMPDefaultClause(OMPDefaultClause *C) { 2005 C->setDefaultKind( 2006 static_cast<OpenMPDefaultClauseKind>(Reader->Record.readInt())); 2007 C->setLParenLoc(Reader->ReadSourceLocation()); 2008 C->setDefaultKindKwLoc(Reader->ReadSourceLocation()); 2009 } 2010 2011 void OMPClauseReader::VisitOMPProcBindClause(OMPProcBindClause *C) { 2012 C->setProcBindKind( 2013 static_cast<OpenMPProcBindClauseKind>(Reader->Record.readInt())); 2014 C->setLParenLoc(Reader->ReadSourceLocation()); 2015 C->setProcBindKindKwLoc(Reader->ReadSourceLocation()); 2016 } 2017 2018 void OMPClauseReader::VisitOMPScheduleClause(OMPScheduleClause *C) { 2019 VisitOMPClauseWithPreInit(C); 2020 C->setScheduleKind( 2021 static_cast<OpenMPScheduleClauseKind>(Reader->Record.readInt())); 2022 C->setFirstScheduleModifier( 2023 static_cast<OpenMPScheduleClauseModifier>(Reader->Record.readInt())); 2024 C->setSecondScheduleModifier( 2025 static_cast<OpenMPScheduleClauseModifier>(Reader->Record.readInt())); 2026 C->setChunkSize(Reader->Record.readSubExpr()); 2027 C->setLParenLoc(Reader->ReadSourceLocation()); 2028 C->setFirstScheduleModifierLoc(Reader->ReadSourceLocation()); 2029 C->setSecondScheduleModifierLoc(Reader->ReadSourceLocation()); 2030 C->setScheduleKindLoc(Reader->ReadSourceLocation()); 2031 C->setCommaLoc(Reader->ReadSourceLocation()); 2032 } 2033 2034 void OMPClauseReader::VisitOMPOrderedClause(OMPOrderedClause *C) { 2035 C->setNumForLoops(Reader->Record.readSubExpr()); 2036 C->setLParenLoc(Reader->ReadSourceLocation()); 2037 } 2038 2039 void OMPClauseReader::VisitOMPNowaitClause(OMPNowaitClause *) {} 2040 2041 void OMPClauseReader::VisitOMPUntiedClause(OMPUntiedClause *) {} 2042 2043 void OMPClauseReader::VisitOMPMergeableClause(OMPMergeableClause *) {} 2044 2045 void OMPClauseReader::VisitOMPReadClause(OMPReadClause *) {} 2046 2047 void OMPClauseReader::VisitOMPWriteClause(OMPWriteClause *) {} 2048 2049 void OMPClauseReader::VisitOMPUpdateClause(OMPUpdateClause *) {} 2050 2051 void OMPClauseReader::VisitOMPCaptureClause(OMPCaptureClause *) {} 2052 2053 void OMPClauseReader::VisitOMPSeqCstClause(OMPSeqCstClause *) {} 2054 2055 void OMPClauseReader::VisitOMPThreadsClause(OMPThreadsClause *) {} 2056 2057 void OMPClauseReader::VisitOMPSIMDClause(OMPSIMDClause *) {} 2058 2059 void OMPClauseReader::VisitOMPNogroupClause(OMPNogroupClause *) {} 2060 2061 void OMPClauseReader::VisitOMPPrivateClause(OMPPrivateClause *C) { 2062 C->setLParenLoc(Reader->ReadSourceLocation()); 2063 unsigned NumVars = C->varlist_size(); 2064 SmallVector<Expr *, 16> Vars; 2065 Vars.reserve(NumVars); 2066 for (unsigned i = 0; i != NumVars; ++i) 2067 Vars.push_back(Reader->Record.readSubExpr()); 2068 C->setVarRefs(Vars); 2069 Vars.clear(); 2070 for (unsigned i = 0; i != NumVars; ++i) 2071 Vars.push_back(Reader->Record.readSubExpr()); 2072 C->setPrivateCopies(Vars); 2073 } 2074 2075 void OMPClauseReader::VisitOMPFirstprivateClause(OMPFirstprivateClause *C) { 2076 VisitOMPClauseWithPreInit(C); 2077 C->setLParenLoc(Reader->ReadSourceLocation()); 2078 unsigned NumVars = C->varlist_size(); 2079 SmallVector<Expr *, 16> Vars; 2080 Vars.reserve(NumVars); 2081 for (unsigned i = 0; i != NumVars; ++i) 2082 Vars.push_back(Reader->Record.readSubExpr()); 2083 C->setVarRefs(Vars); 2084 Vars.clear(); 2085 for (unsigned i = 0; i != NumVars; ++i) 2086 Vars.push_back(Reader->Record.readSubExpr()); 2087 C->setPrivateCopies(Vars); 2088 Vars.clear(); 2089 for (unsigned i = 0; i != NumVars; ++i) 2090 Vars.push_back(Reader->Record.readSubExpr()); 2091 C->setInits(Vars); 2092 } 2093 2094 void OMPClauseReader::VisitOMPLastprivateClause(OMPLastprivateClause *C) { 2095 VisitOMPClauseWithPostUpdate(C); 2096 C->setLParenLoc(Reader->ReadSourceLocation()); 2097 unsigned NumVars = C->varlist_size(); 2098 SmallVector<Expr *, 16> Vars; 2099 Vars.reserve(NumVars); 2100 for (unsigned i = 0; i != NumVars; ++i) 2101 Vars.push_back(Reader->Record.readSubExpr()); 2102 C->setVarRefs(Vars); 2103 Vars.clear(); 2104 for (unsigned i = 0; i != NumVars; ++i) 2105 Vars.push_back(Reader->Record.readSubExpr()); 2106 C->setPrivateCopies(Vars); 2107 Vars.clear(); 2108 for (unsigned i = 0; i != NumVars; ++i) 2109 Vars.push_back(Reader->Record.readSubExpr()); 2110 C->setSourceExprs(Vars); 2111 Vars.clear(); 2112 for (unsigned i = 0; i != NumVars; ++i) 2113 Vars.push_back(Reader->Record.readSubExpr()); 2114 C->setDestinationExprs(Vars); 2115 Vars.clear(); 2116 for (unsigned i = 0; i != NumVars; ++i) 2117 Vars.push_back(Reader->Record.readSubExpr()); 2118 C->setAssignmentOps(Vars); 2119 } 2120 2121 void OMPClauseReader::VisitOMPSharedClause(OMPSharedClause *C) { 2122 C->setLParenLoc(Reader->ReadSourceLocation()); 2123 unsigned NumVars = C->varlist_size(); 2124 SmallVector<Expr *, 16> Vars; 2125 Vars.reserve(NumVars); 2126 for (unsigned i = 0; i != NumVars; ++i) 2127 Vars.push_back(Reader->Record.readSubExpr()); 2128 C->setVarRefs(Vars); 2129 } 2130 2131 void OMPClauseReader::VisitOMPReductionClause(OMPReductionClause *C) { 2132 VisitOMPClauseWithPostUpdate(C); 2133 C->setLParenLoc(Reader->ReadSourceLocation()); 2134 C->setColonLoc(Reader->ReadSourceLocation()); 2135 NestedNameSpecifierLoc NNSL = Reader->Record.readNestedNameSpecifierLoc(); 2136 DeclarationNameInfo DNI; 2137 Reader->ReadDeclarationNameInfo(DNI); 2138 C->setQualifierLoc(NNSL); 2139 C->setNameInfo(DNI); 2140 2141 unsigned NumVars = C->varlist_size(); 2142 SmallVector<Expr *, 16> Vars; 2143 Vars.reserve(NumVars); 2144 for (unsigned i = 0; i != NumVars; ++i) 2145 Vars.push_back(Reader->Record.readSubExpr()); 2146 C->setVarRefs(Vars); 2147 Vars.clear(); 2148 for (unsigned i = 0; i != NumVars; ++i) 2149 Vars.push_back(Reader->Record.readSubExpr()); 2150 C->setPrivates(Vars); 2151 Vars.clear(); 2152 for (unsigned i = 0; i != NumVars; ++i) 2153 Vars.push_back(Reader->Record.readSubExpr()); 2154 C->setLHSExprs(Vars); 2155 Vars.clear(); 2156 for (unsigned i = 0; i != NumVars; ++i) 2157 Vars.push_back(Reader->Record.readSubExpr()); 2158 C->setRHSExprs(Vars); 2159 Vars.clear(); 2160 for (unsigned i = 0; i != NumVars; ++i) 2161 Vars.push_back(Reader->Record.readSubExpr()); 2162 C->setReductionOps(Vars); 2163 } 2164 2165 void OMPClauseReader::VisitOMPTaskReductionClause(OMPTaskReductionClause *C) { 2166 VisitOMPClauseWithPostUpdate(C); 2167 C->setLParenLoc(Reader->ReadSourceLocation()); 2168 C->setColonLoc(Reader->ReadSourceLocation()); 2169 NestedNameSpecifierLoc NNSL = Reader->Record.readNestedNameSpecifierLoc(); 2170 DeclarationNameInfo DNI; 2171 Reader->ReadDeclarationNameInfo(DNI); 2172 C->setQualifierLoc(NNSL); 2173 C->setNameInfo(DNI); 2174 2175 unsigned NumVars = C->varlist_size(); 2176 SmallVector<Expr *, 16> Vars; 2177 Vars.reserve(NumVars); 2178 for (unsigned I = 0; I != NumVars; ++I) 2179 Vars.push_back(Reader->Record.readSubExpr()); 2180 C->setVarRefs(Vars); 2181 Vars.clear(); 2182 for (unsigned I = 0; I != NumVars; ++I) 2183 Vars.push_back(Reader->Record.readSubExpr()); 2184 C->setPrivates(Vars); 2185 Vars.clear(); 2186 for (unsigned I = 0; I != NumVars; ++I) 2187 Vars.push_back(Reader->Record.readSubExpr()); 2188 C->setLHSExprs(Vars); 2189 Vars.clear(); 2190 for (unsigned I = 0; I != NumVars; ++I) 2191 Vars.push_back(Reader->Record.readSubExpr()); 2192 C->setRHSExprs(Vars); 2193 Vars.clear(); 2194 for (unsigned I = 0; I != NumVars; ++I) 2195 Vars.push_back(Reader->Record.readSubExpr()); 2196 C->setReductionOps(Vars); 2197 } 2198 2199 void OMPClauseReader::VisitOMPInReductionClause(OMPInReductionClause *C) { 2200 VisitOMPClauseWithPostUpdate(C); 2201 C->setLParenLoc(Reader->ReadSourceLocation()); 2202 C->setColonLoc(Reader->ReadSourceLocation()); 2203 NestedNameSpecifierLoc NNSL = Reader->Record.readNestedNameSpecifierLoc(); 2204 DeclarationNameInfo DNI; 2205 Reader->ReadDeclarationNameInfo(DNI); 2206 C->setQualifierLoc(NNSL); 2207 C->setNameInfo(DNI); 2208 2209 unsigned NumVars = C->varlist_size(); 2210 SmallVector<Expr *, 16> Vars; 2211 Vars.reserve(NumVars); 2212 for (unsigned I = 0; I != NumVars; ++I) 2213 Vars.push_back(Reader->Record.readSubExpr()); 2214 C->setVarRefs(Vars); 2215 Vars.clear(); 2216 for (unsigned I = 0; I != NumVars; ++I) 2217 Vars.push_back(Reader->Record.readSubExpr()); 2218 C->setPrivates(Vars); 2219 Vars.clear(); 2220 for (unsigned I = 0; I != NumVars; ++I) 2221 Vars.push_back(Reader->Record.readSubExpr()); 2222 C->setLHSExprs(Vars); 2223 Vars.clear(); 2224 for (unsigned I = 0; I != NumVars; ++I) 2225 Vars.push_back(Reader->Record.readSubExpr()); 2226 C->setRHSExprs(Vars); 2227 Vars.clear(); 2228 for (unsigned I = 0; I != NumVars; ++I) 2229 Vars.push_back(Reader->Record.readSubExpr()); 2230 C->setReductionOps(Vars); 2231 Vars.clear(); 2232 for (unsigned I = 0; I != NumVars; ++I) 2233 Vars.push_back(Reader->Record.readSubExpr()); 2234 C->setTaskgroupDescriptors(Vars); 2235 } 2236 2237 void OMPClauseReader::VisitOMPLinearClause(OMPLinearClause *C) { 2238 VisitOMPClauseWithPostUpdate(C); 2239 C->setLParenLoc(Reader->ReadSourceLocation()); 2240 C->setColonLoc(Reader->ReadSourceLocation()); 2241 C->setModifier(static_cast<OpenMPLinearClauseKind>(Reader->Record.readInt())); 2242 C->setModifierLoc(Reader->ReadSourceLocation()); 2243 unsigned NumVars = C->varlist_size(); 2244 SmallVector<Expr *, 16> Vars; 2245 Vars.reserve(NumVars); 2246 for (unsigned i = 0; i != NumVars; ++i) 2247 Vars.push_back(Reader->Record.readSubExpr()); 2248 C->setVarRefs(Vars); 2249 Vars.clear(); 2250 for (unsigned i = 0; i != NumVars; ++i) 2251 Vars.push_back(Reader->Record.readSubExpr()); 2252 C->setPrivates(Vars); 2253 Vars.clear(); 2254 for (unsigned i = 0; i != NumVars; ++i) 2255 Vars.push_back(Reader->Record.readSubExpr()); 2256 C->setInits(Vars); 2257 Vars.clear(); 2258 for (unsigned i = 0; i != NumVars; ++i) 2259 Vars.push_back(Reader->Record.readSubExpr()); 2260 C->setUpdates(Vars); 2261 Vars.clear(); 2262 for (unsigned i = 0; i != NumVars; ++i) 2263 Vars.push_back(Reader->Record.readSubExpr()); 2264 C->setFinals(Vars); 2265 C->setStep(Reader->Record.readSubExpr()); 2266 C->setCalcStep(Reader->Record.readSubExpr()); 2267 } 2268 2269 void OMPClauseReader::VisitOMPAlignedClause(OMPAlignedClause *C) { 2270 C->setLParenLoc(Reader->ReadSourceLocation()); 2271 C->setColonLoc(Reader->ReadSourceLocation()); 2272 unsigned NumVars = C->varlist_size(); 2273 SmallVector<Expr *, 16> Vars; 2274 Vars.reserve(NumVars); 2275 for (unsigned i = 0; i != NumVars; ++i) 2276 Vars.push_back(Reader->Record.readSubExpr()); 2277 C->setVarRefs(Vars); 2278 C->setAlignment(Reader->Record.readSubExpr()); 2279 } 2280 2281 void OMPClauseReader::VisitOMPCopyinClause(OMPCopyinClause *C) { 2282 C->setLParenLoc(Reader->ReadSourceLocation()); 2283 unsigned NumVars = C->varlist_size(); 2284 SmallVector<Expr *, 16> Exprs; 2285 Exprs.reserve(NumVars); 2286 for (unsigned i = 0; i != NumVars; ++i) 2287 Exprs.push_back(Reader->Record.readSubExpr()); 2288 C->setVarRefs(Exprs); 2289 Exprs.clear(); 2290 for (unsigned i = 0; i != NumVars; ++i) 2291 Exprs.push_back(Reader->Record.readSubExpr()); 2292 C->setSourceExprs(Exprs); 2293 Exprs.clear(); 2294 for (unsigned i = 0; i != NumVars; ++i) 2295 Exprs.push_back(Reader->Record.readSubExpr()); 2296 C->setDestinationExprs(Exprs); 2297 Exprs.clear(); 2298 for (unsigned i = 0; i != NumVars; ++i) 2299 Exprs.push_back(Reader->Record.readSubExpr()); 2300 C->setAssignmentOps(Exprs); 2301 } 2302 2303 void OMPClauseReader::VisitOMPCopyprivateClause(OMPCopyprivateClause *C) { 2304 C->setLParenLoc(Reader->ReadSourceLocation()); 2305 unsigned NumVars = C->varlist_size(); 2306 SmallVector<Expr *, 16> Exprs; 2307 Exprs.reserve(NumVars); 2308 for (unsigned i = 0; i != NumVars; ++i) 2309 Exprs.push_back(Reader->Record.readSubExpr()); 2310 C->setVarRefs(Exprs); 2311 Exprs.clear(); 2312 for (unsigned i = 0; i != NumVars; ++i) 2313 Exprs.push_back(Reader->Record.readSubExpr()); 2314 C->setSourceExprs(Exprs); 2315 Exprs.clear(); 2316 for (unsigned i = 0; i != NumVars; ++i) 2317 Exprs.push_back(Reader->Record.readSubExpr()); 2318 C->setDestinationExprs(Exprs); 2319 Exprs.clear(); 2320 for (unsigned i = 0; i != NumVars; ++i) 2321 Exprs.push_back(Reader->Record.readSubExpr()); 2322 C->setAssignmentOps(Exprs); 2323 } 2324 2325 void OMPClauseReader::VisitOMPFlushClause(OMPFlushClause *C) { 2326 C->setLParenLoc(Reader->ReadSourceLocation()); 2327 unsigned NumVars = C->varlist_size(); 2328 SmallVector<Expr *, 16> Vars; 2329 Vars.reserve(NumVars); 2330 for (unsigned i = 0; i != NumVars; ++i) 2331 Vars.push_back(Reader->Record.readSubExpr()); 2332 C->setVarRefs(Vars); 2333 } 2334 2335 void OMPClauseReader::VisitOMPDependClause(OMPDependClause *C) { 2336 C->setLParenLoc(Reader->ReadSourceLocation()); 2337 C->setDependencyKind( 2338 static_cast<OpenMPDependClauseKind>(Reader->Record.readInt())); 2339 C->setDependencyLoc(Reader->ReadSourceLocation()); 2340 C->setColonLoc(Reader->ReadSourceLocation()); 2341 unsigned NumVars = C->varlist_size(); 2342 SmallVector<Expr *, 16> Vars; 2343 Vars.reserve(NumVars); 2344 for (unsigned i = 0; i != NumVars; ++i) 2345 Vars.push_back(Reader->Record.readSubExpr()); 2346 C->setVarRefs(Vars); 2347 C->setCounterValue(Reader->Record.readSubExpr()); 2348 } 2349 2350 void OMPClauseReader::VisitOMPDeviceClause(OMPDeviceClause *C) { 2351 VisitOMPClauseWithPreInit(C); 2352 C->setDevice(Reader->Record.readSubExpr()); 2353 C->setLParenLoc(Reader->ReadSourceLocation()); 2354 } 2355 2356 void OMPClauseReader::VisitOMPMapClause(OMPMapClause *C) { 2357 C->setLParenLoc(Reader->ReadSourceLocation()); 2358 C->setMapTypeModifier( 2359 static_cast<OpenMPMapClauseKind>(Reader->Record.readInt())); 2360 C->setMapType( 2361 static_cast<OpenMPMapClauseKind>(Reader->Record.readInt())); 2362 C->setMapLoc(Reader->ReadSourceLocation()); 2363 C->setColonLoc(Reader->ReadSourceLocation()); 2364 auto NumVars = C->varlist_size(); 2365 auto UniqueDecls = C->getUniqueDeclarationsNum(); 2366 auto TotalLists = C->getTotalComponentListNum(); 2367 auto TotalComponents = C->getTotalComponentsNum(); 2368 2369 SmallVector<Expr *, 16> Vars; 2370 Vars.reserve(NumVars); 2371 for (unsigned i = 0; i != NumVars; ++i) 2372 Vars.push_back(Reader->Record.readSubExpr()); 2373 C->setVarRefs(Vars); 2374 2375 SmallVector<ValueDecl *, 16> Decls; 2376 Decls.reserve(UniqueDecls); 2377 for (unsigned i = 0; i < UniqueDecls; ++i) 2378 Decls.push_back(Reader->Record.readDeclAs<ValueDecl>()); 2379 C->setUniqueDecls(Decls); 2380 2381 SmallVector<unsigned, 16> ListsPerDecl; 2382 ListsPerDecl.reserve(UniqueDecls); 2383 for (unsigned i = 0; i < UniqueDecls; ++i) 2384 ListsPerDecl.push_back(Reader->Record.readInt()); 2385 C->setDeclNumLists(ListsPerDecl); 2386 2387 SmallVector<unsigned, 32> ListSizes; 2388 ListSizes.reserve(TotalLists); 2389 for (unsigned i = 0; i < TotalLists; ++i) 2390 ListSizes.push_back(Reader->Record.readInt()); 2391 C->setComponentListSizes(ListSizes); 2392 2393 SmallVector<OMPClauseMappableExprCommon::MappableComponent, 32> Components; 2394 Components.reserve(TotalComponents); 2395 for (unsigned i = 0; i < TotalComponents; ++i) { 2396 Expr *AssociatedExpr = Reader->Record.readSubExpr(); 2397 ValueDecl *AssociatedDecl = Reader->Record.readDeclAs<ValueDecl>(); 2398 Components.push_back(OMPClauseMappableExprCommon::MappableComponent( 2399 AssociatedExpr, AssociatedDecl)); 2400 } 2401 C->setComponents(Components, ListSizes); 2402 } 2403 2404 void OMPClauseReader::VisitOMPNumTeamsClause(OMPNumTeamsClause *C) { 2405 VisitOMPClauseWithPreInit(C); 2406 C->setNumTeams(Reader->Record.readSubExpr()); 2407 C->setLParenLoc(Reader->ReadSourceLocation()); 2408 } 2409 2410 void OMPClauseReader::VisitOMPThreadLimitClause(OMPThreadLimitClause *C) { 2411 VisitOMPClauseWithPreInit(C); 2412 C->setThreadLimit(Reader->Record.readSubExpr()); 2413 C->setLParenLoc(Reader->ReadSourceLocation()); 2414 } 2415 2416 void OMPClauseReader::VisitOMPPriorityClause(OMPPriorityClause *C) { 2417 C->setPriority(Reader->Record.readSubExpr()); 2418 C->setLParenLoc(Reader->ReadSourceLocation()); 2419 } 2420 2421 void OMPClauseReader::VisitOMPGrainsizeClause(OMPGrainsizeClause *C) { 2422 C->setGrainsize(Reader->Record.readSubExpr()); 2423 C->setLParenLoc(Reader->ReadSourceLocation()); 2424 } 2425 2426 void OMPClauseReader::VisitOMPNumTasksClause(OMPNumTasksClause *C) { 2427 C->setNumTasks(Reader->Record.readSubExpr()); 2428 C->setLParenLoc(Reader->ReadSourceLocation()); 2429 } 2430 2431 void OMPClauseReader::VisitOMPHintClause(OMPHintClause *C) { 2432 C->setHint(Reader->Record.readSubExpr()); 2433 C->setLParenLoc(Reader->ReadSourceLocation()); 2434 } 2435 2436 void OMPClauseReader::VisitOMPDistScheduleClause(OMPDistScheduleClause *C) { 2437 VisitOMPClauseWithPreInit(C); 2438 C->setDistScheduleKind( 2439 static_cast<OpenMPDistScheduleClauseKind>(Reader->Record.readInt())); 2440 C->setChunkSize(Reader->Record.readSubExpr()); 2441 C->setLParenLoc(Reader->ReadSourceLocation()); 2442 C->setDistScheduleKindLoc(Reader->ReadSourceLocation()); 2443 C->setCommaLoc(Reader->ReadSourceLocation()); 2444 } 2445 2446 void OMPClauseReader::VisitOMPDefaultmapClause(OMPDefaultmapClause *C) { 2447 C->setDefaultmapKind( 2448 static_cast<OpenMPDefaultmapClauseKind>(Reader->Record.readInt())); 2449 C->setDefaultmapModifier( 2450 static_cast<OpenMPDefaultmapClauseModifier>(Reader->Record.readInt())); 2451 C->setLParenLoc(Reader->ReadSourceLocation()); 2452 C->setDefaultmapModifierLoc(Reader->ReadSourceLocation()); 2453 C->setDefaultmapKindLoc(Reader->ReadSourceLocation()); 2454 } 2455 2456 void OMPClauseReader::VisitOMPToClause(OMPToClause *C) { 2457 C->setLParenLoc(Reader->ReadSourceLocation()); 2458 auto NumVars = C->varlist_size(); 2459 auto UniqueDecls = C->getUniqueDeclarationsNum(); 2460 auto TotalLists = C->getTotalComponentListNum(); 2461 auto TotalComponents = C->getTotalComponentsNum(); 2462 2463 SmallVector<Expr *, 16> Vars; 2464 Vars.reserve(NumVars); 2465 for (unsigned i = 0; i != NumVars; ++i) 2466 Vars.push_back(Reader->Record.readSubExpr()); 2467 C->setVarRefs(Vars); 2468 2469 SmallVector<ValueDecl *, 16> Decls; 2470 Decls.reserve(UniqueDecls); 2471 for (unsigned i = 0; i < UniqueDecls; ++i) 2472 Decls.push_back(Reader->Record.readDeclAs<ValueDecl>()); 2473 C->setUniqueDecls(Decls); 2474 2475 SmallVector<unsigned, 16> ListsPerDecl; 2476 ListsPerDecl.reserve(UniqueDecls); 2477 for (unsigned i = 0; i < UniqueDecls; ++i) 2478 ListsPerDecl.push_back(Reader->Record.readInt()); 2479 C->setDeclNumLists(ListsPerDecl); 2480 2481 SmallVector<unsigned, 32> ListSizes; 2482 ListSizes.reserve(TotalLists); 2483 for (unsigned i = 0; i < TotalLists; ++i) 2484 ListSizes.push_back(Reader->Record.readInt()); 2485 C->setComponentListSizes(ListSizes); 2486 2487 SmallVector<OMPClauseMappableExprCommon::MappableComponent, 32> Components; 2488 Components.reserve(TotalComponents); 2489 for (unsigned i = 0; i < TotalComponents; ++i) { 2490 Expr *AssociatedExpr = Reader->Record.readSubExpr(); 2491 ValueDecl *AssociatedDecl = Reader->Record.readDeclAs<ValueDecl>(); 2492 Components.push_back(OMPClauseMappableExprCommon::MappableComponent( 2493 AssociatedExpr, AssociatedDecl)); 2494 } 2495 C->setComponents(Components, ListSizes); 2496 } 2497 2498 void OMPClauseReader::VisitOMPFromClause(OMPFromClause *C) { 2499 C->setLParenLoc(Reader->ReadSourceLocation()); 2500 auto NumVars = C->varlist_size(); 2501 auto UniqueDecls = C->getUniqueDeclarationsNum(); 2502 auto TotalLists = C->getTotalComponentListNum(); 2503 auto TotalComponents = C->getTotalComponentsNum(); 2504 2505 SmallVector<Expr *, 16> Vars; 2506 Vars.reserve(NumVars); 2507 for (unsigned i = 0; i != NumVars; ++i) 2508 Vars.push_back(Reader->Record.readSubExpr()); 2509 C->setVarRefs(Vars); 2510 2511 SmallVector<ValueDecl *, 16> Decls; 2512 Decls.reserve(UniqueDecls); 2513 for (unsigned i = 0; i < UniqueDecls; ++i) 2514 Decls.push_back(Reader->Record.readDeclAs<ValueDecl>()); 2515 C->setUniqueDecls(Decls); 2516 2517 SmallVector<unsigned, 16> ListsPerDecl; 2518 ListsPerDecl.reserve(UniqueDecls); 2519 for (unsigned i = 0; i < UniqueDecls; ++i) 2520 ListsPerDecl.push_back(Reader->Record.readInt()); 2521 C->setDeclNumLists(ListsPerDecl); 2522 2523 SmallVector<unsigned, 32> ListSizes; 2524 ListSizes.reserve(TotalLists); 2525 for (unsigned i = 0; i < TotalLists; ++i) 2526 ListSizes.push_back(Reader->Record.readInt()); 2527 C->setComponentListSizes(ListSizes); 2528 2529 SmallVector<OMPClauseMappableExprCommon::MappableComponent, 32> Components; 2530 Components.reserve(TotalComponents); 2531 for (unsigned i = 0; i < TotalComponents; ++i) { 2532 Expr *AssociatedExpr = Reader->Record.readSubExpr(); 2533 ValueDecl *AssociatedDecl = Reader->Record.readDeclAs<ValueDecl>(); 2534 Components.push_back(OMPClauseMappableExprCommon::MappableComponent( 2535 AssociatedExpr, AssociatedDecl)); 2536 } 2537 C->setComponents(Components, ListSizes); 2538 } 2539 2540 void OMPClauseReader::VisitOMPUseDevicePtrClause(OMPUseDevicePtrClause *C) { 2541 C->setLParenLoc(Reader->ReadSourceLocation()); 2542 auto NumVars = C->varlist_size(); 2543 auto UniqueDecls = C->getUniqueDeclarationsNum(); 2544 auto TotalLists = C->getTotalComponentListNum(); 2545 auto TotalComponents = C->getTotalComponentsNum(); 2546 2547 SmallVector<Expr *, 16> Vars; 2548 Vars.reserve(NumVars); 2549 for (unsigned i = 0; i != NumVars; ++i) 2550 Vars.push_back(Reader->Record.readSubExpr()); 2551 C->setVarRefs(Vars); 2552 Vars.clear(); 2553 for (unsigned i = 0; i != NumVars; ++i) 2554 Vars.push_back(Reader->Record.readSubExpr()); 2555 C->setPrivateCopies(Vars); 2556 Vars.clear(); 2557 for (unsigned i = 0; i != NumVars; ++i) 2558 Vars.push_back(Reader->Record.readSubExpr()); 2559 C->setInits(Vars); 2560 2561 SmallVector<ValueDecl *, 16> Decls; 2562 Decls.reserve(UniqueDecls); 2563 for (unsigned i = 0; i < UniqueDecls; ++i) 2564 Decls.push_back(Reader->Record.readDeclAs<ValueDecl>()); 2565 C->setUniqueDecls(Decls); 2566 2567 SmallVector<unsigned, 16> ListsPerDecl; 2568 ListsPerDecl.reserve(UniqueDecls); 2569 for (unsigned i = 0; i < UniqueDecls; ++i) 2570 ListsPerDecl.push_back(Reader->Record.readInt()); 2571 C->setDeclNumLists(ListsPerDecl); 2572 2573 SmallVector<unsigned, 32> ListSizes; 2574 ListSizes.reserve(TotalLists); 2575 for (unsigned i = 0; i < TotalLists; ++i) 2576 ListSizes.push_back(Reader->Record.readInt()); 2577 C->setComponentListSizes(ListSizes); 2578 2579 SmallVector<OMPClauseMappableExprCommon::MappableComponent, 32> Components; 2580 Components.reserve(TotalComponents); 2581 for (unsigned i = 0; i < TotalComponents; ++i) { 2582 Expr *AssociatedExpr = Reader->Record.readSubExpr(); 2583 ValueDecl *AssociatedDecl = Reader->Record.readDeclAs<ValueDecl>(); 2584 Components.push_back(OMPClauseMappableExprCommon::MappableComponent( 2585 AssociatedExpr, AssociatedDecl)); 2586 } 2587 C->setComponents(Components, ListSizes); 2588 } 2589 2590 void OMPClauseReader::VisitOMPIsDevicePtrClause(OMPIsDevicePtrClause *C) { 2591 C->setLParenLoc(Reader->ReadSourceLocation()); 2592 auto NumVars = C->varlist_size(); 2593 auto UniqueDecls = C->getUniqueDeclarationsNum(); 2594 auto TotalLists = C->getTotalComponentListNum(); 2595 auto TotalComponents = C->getTotalComponentsNum(); 2596 2597 SmallVector<Expr *, 16> Vars; 2598 Vars.reserve(NumVars); 2599 for (unsigned i = 0; i != NumVars; ++i) 2600 Vars.push_back(Reader->Record.readSubExpr()); 2601 C->setVarRefs(Vars); 2602 Vars.clear(); 2603 2604 SmallVector<ValueDecl *, 16> Decls; 2605 Decls.reserve(UniqueDecls); 2606 for (unsigned i = 0; i < UniqueDecls; ++i) 2607 Decls.push_back(Reader->Record.readDeclAs<ValueDecl>()); 2608 C->setUniqueDecls(Decls); 2609 2610 SmallVector<unsigned, 16> ListsPerDecl; 2611 ListsPerDecl.reserve(UniqueDecls); 2612 for (unsigned i = 0; i < UniqueDecls; ++i) 2613 ListsPerDecl.push_back(Reader->Record.readInt()); 2614 C->setDeclNumLists(ListsPerDecl); 2615 2616 SmallVector<unsigned, 32> ListSizes; 2617 ListSizes.reserve(TotalLists); 2618 for (unsigned i = 0; i < TotalLists; ++i) 2619 ListSizes.push_back(Reader->Record.readInt()); 2620 C->setComponentListSizes(ListSizes); 2621 2622 SmallVector<OMPClauseMappableExprCommon::MappableComponent, 32> Components; 2623 Components.reserve(TotalComponents); 2624 for (unsigned i = 0; i < TotalComponents; ++i) { 2625 Expr *AssociatedExpr = Reader->Record.readSubExpr(); 2626 ValueDecl *AssociatedDecl = Reader->Record.readDeclAs<ValueDecl>(); 2627 Components.push_back(OMPClauseMappableExprCommon::MappableComponent( 2628 AssociatedExpr, AssociatedDecl)); 2629 } 2630 C->setComponents(Components, ListSizes); 2631 } 2632 2633 //===----------------------------------------------------------------------===// 2634 // OpenMP Directives. 2635 //===----------------------------------------------------------------------===// 2636 void ASTStmtReader::VisitOMPExecutableDirective(OMPExecutableDirective *E) { 2637 E->setLocStart(ReadSourceLocation()); 2638 E->setLocEnd(ReadSourceLocation()); 2639 OMPClauseReader ClauseReader(this, Record); 2640 SmallVector<OMPClause *, 5> Clauses; 2641 for (unsigned i = 0; i < E->getNumClauses(); ++i) 2642 Clauses.push_back(ClauseReader.readClause()); 2643 E->setClauses(Clauses); 2644 if (E->hasAssociatedStmt()) 2645 E->setAssociatedStmt(Record.readSubStmt()); 2646 } 2647 2648 void ASTStmtReader::VisitOMPLoopDirective(OMPLoopDirective *D) { 2649 VisitStmt(D); 2650 // Two fields (NumClauses and CollapsedNum) were read in ReadStmtFromStream. 2651 Record.skipInts(2); 2652 VisitOMPExecutableDirective(D); 2653 D->setIterationVariable(Record.readSubExpr()); 2654 D->setLastIteration(Record.readSubExpr()); 2655 D->setCalcLastIteration(Record.readSubExpr()); 2656 D->setPreCond(Record.readSubExpr()); 2657 D->setCond(Record.readSubExpr()); 2658 D->setInit(Record.readSubExpr()); 2659 D->setInc(Record.readSubExpr()); 2660 D->setPreInits(Record.readSubStmt()); 2661 if (isOpenMPWorksharingDirective(D->getDirectiveKind()) || 2662 isOpenMPTaskLoopDirective(D->getDirectiveKind()) || 2663 isOpenMPDistributeDirective(D->getDirectiveKind())) { 2664 D->setIsLastIterVariable(Record.readSubExpr()); 2665 D->setLowerBoundVariable(Record.readSubExpr()); 2666 D->setUpperBoundVariable(Record.readSubExpr()); 2667 D->setStrideVariable(Record.readSubExpr()); 2668 D->setEnsureUpperBound(Record.readSubExpr()); 2669 D->setNextLowerBound(Record.readSubExpr()); 2670 D->setNextUpperBound(Record.readSubExpr()); 2671 D->setNumIterations(Record.readSubExpr()); 2672 } 2673 if (isOpenMPLoopBoundSharingDirective(D->getDirectiveKind())) { 2674 D->setPrevLowerBoundVariable(Record.readSubExpr()); 2675 D->setPrevUpperBoundVariable(Record.readSubExpr()); 2676 D->setDistInc(Record.readSubExpr()); 2677 D->setPrevEnsureUpperBound(Record.readSubExpr()); 2678 D->setCombinedLowerBoundVariable(Record.readSubExpr()); 2679 D->setCombinedUpperBoundVariable(Record.readSubExpr()); 2680 D->setCombinedEnsureUpperBound(Record.readSubExpr()); 2681 D->setCombinedInit(Record.readSubExpr()); 2682 D->setCombinedCond(Record.readSubExpr()); 2683 D->setCombinedNextLowerBound(Record.readSubExpr()); 2684 D->setCombinedNextUpperBound(Record.readSubExpr()); 2685 } 2686 SmallVector<Expr *, 4> Sub; 2687 unsigned CollapsedNum = D->getCollapsedNumber(); 2688 Sub.reserve(CollapsedNum); 2689 for (unsigned i = 0; i < CollapsedNum; ++i) 2690 Sub.push_back(Record.readSubExpr()); 2691 D->setCounters(Sub); 2692 Sub.clear(); 2693 for (unsigned i = 0; i < CollapsedNum; ++i) 2694 Sub.push_back(Record.readSubExpr()); 2695 D->setPrivateCounters(Sub); 2696 Sub.clear(); 2697 for (unsigned i = 0; i < CollapsedNum; ++i) 2698 Sub.push_back(Record.readSubExpr()); 2699 D->setInits(Sub); 2700 Sub.clear(); 2701 for (unsigned i = 0; i < CollapsedNum; ++i) 2702 Sub.push_back(Record.readSubExpr()); 2703 D->setUpdates(Sub); 2704 Sub.clear(); 2705 for (unsigned i = 0; i < CollapsedNum; ++i) 2706 Sub.push_back(Record.readSubExpr()); 2707 D->setFinals(Sub); 2708 } 2709 2710 void ASTStmtReader::VisitOMPParallelDirective(OMPParallelDirective *D) { 2711 VisitStmt(D); 2712 // The NumClauses field was read in ReadStmtFromStream. 2713 Record.skipInts(1); 2714 VisitOMPExecutableDirective(D); 2715 D->setHasCancel(Record.readInt()); 2716 } 2717 2718 void ASTStmtReader::VisitOMPSimdDirective(OMPSimdDirective *D) { 2719 VisitOMPLoopDirective(D); 2720 } 2721 2722 void ASTStmtReader::VisitOMPForDirective(OMPForDirective *D) { 2723 VisitOMPLoopDirective(D); 2724 D->setHasCancel(Record.readInt()); 2725 } 2726 2727 void ASTStmtReader::VisitOMPForSimdDirective(OMPForSimdDirective *D) { 2728 VisitOMPLoopDirective(D); 2729 } 2730 2731 void ASTStmtReader::VisitOMPSectionsDirective(OMPSectionsDirective *D) { 2732 VisitStmt(D); 2733 // The NumClauses field was read in ReadStmtFromStream. 2734 Record.skipInts(1); 2735 VisitOMPExecutableDirective(D); 2736 D->setHasCancel(Record.readInt()); 2737 } 2738 2739 void ASTStmtReader::VisitOMPSectionDirective(OMPSectionDirective *D) { 2740 VisitStmt(D); 2741 VisitOMPExecutableDirective(D); 2742 D->setHasCancel(Record.readInt()); 2743 } 2744 2745 void ASTStmtReader::VisitOMPSingleDirective(OMPSingleDirective *D) { 2746 VisitStmt(D); 2747 // The NumClauses field was read in ReadStmtFromStream. 2748 Record.skipInts(1); 2749 VisitOMPExecutableDirective(D); 2750 } 2751 2752 void ASTStmtReader::VisitOMPMasterDirective(OMPMasterDirective *D) { 2753 VisitStmt(D); 2754 VisitOMPExecutableDirective(D); 2755 } 2756 2757 void ASTStmtReader::VisitOMPCriticalDirective(OMPCriticalDirective *D) { 2758 VisitStmt(D); 2759 // The NumClauses field was read in ReadStmtFromStream. 2760 Record.skipInts(1); 2761 VisitOMPExecutableDirective(D); 2762 ReadDeclarationNameInfo(D->DirName); 2763 } 2764 2765 void ASTStmtReader::VisitOMPParallelForDirective(OMPParallelForDirective *D) { 2766 VisitOMPLoopDirective(D); 2767 D->setHasCancel(Record.readInt()); 2768 } 2769 2770 void ASTStmtReader::VisitOMPParallelForSimdDirective( 2771 OMPParallelForSimdDirective *D) { 2772 VisitOMPLoopDirective(D); 2773 } 2774 2775 void ASTStmtReader::VisitOMPParallelSectionsDirective( 2776 OMPParallelSectionsDirective *D) { 2777 VisitStmt(D); 2778 // The NumClauses field was read in ReadStmtFromStream. 2779 Record.skipInts(1); 2780 VisitOMPExecutableDirective(D); 2781 D->setHasCancel(Record.readInt()); 2782 } 2783 2784 void ASTStmtReader::VisitOMPTaskDirective(OMPTaskDirective *D) { 2785 VisitStmt(D); 2786 // The NumClauses field was read in ReadStmtFromStream. 2787 Record.skipInts(1); 2788 VisitOMPExecutableDirective(D); 2789 D->setHasCancel(Record.readInt()); 2790 } 2791 2792 void ASTStmtReader::VisitOMPTaskyieldDirective(OMPTaskyieldDirective *D) { 2793 VisitStmt(D); 2794 VisitOMPExecutableDirective(D); 2795 } 2796 2797 void ASTStmtReader::VisitOMPBarrierDirective(OMPBarrierDirective *D) { 2798 VisitStmt(D); 2799 VisitOMPExecutableDirective(D); 2800 } 2801 2802 void ASTStmtReader::VisitOMPTaskwaitDirective(OMPTaskwaitDirective *D) { 2803 VisitStmt(D); 2804 VisitOMPExecutableDirective(D); 2805 } 2806 2807 void ASTStmtReader::VisitOMPTaskgroupDirective(OMPTaskgroupDirective *D) { 2808 VisitStmt(D); 2809 // The NumClauses field was read in ReadStmtFromStream. 2810 Record.skipInts(1); 2811 VisitOMPExecutableDirective(D); 2812 D->setReductionRef(Record.readSubExpr()); 2813 } 2814 2815 void ASTStmtReader::VisitOMPFlushDirective(OMPFlushDirective *D) { 2816 VisitStmt(D); 2817 // The NumClauses field was read in ReadStmtFromStream. 2818 Record.skipInts(1); 2819 VisitOMPExecutableDirective(D); 2820 } 2821 2822 void ASTStmtReader::VisitOMPOrderedDirective(OMPOrderedDirective *D) { 2823 VisitStmt(D); 2824 // The NumClauses field was read in ReadStmtFromStream. 2825 Record.skipInts(1); 2826 VisitOMPExecutableDirective(D); 2827 } 2828 2829 void ASTStmtReader::VisitOMPAtomicDirective(OMPAtomicDirective *D) { 2830 VisitStmt(D); 2831 // The NumClauses field was read in ReadStmtFromStream. 2832 Record.skipInts(1); 2833 VisitOMPExecutableDirective(D); 2834 D->setX(Record.readSubExpr()); 2835 D->setV(Record.readSubExpr()); 2836 D->setExpr(Record.readSubExpr()); 2837 D->setUpdateExpr(Record.readSubExpr()); 2838 D->IsXLHSInRHSPart = Record.readInt() != 0; 2839 D->IsPostfixUpdate = Record.readInt() != 0; 2840 } 2841 2842 void ASTStmtReader::VisitOMPTargetDirective(OMPTargetDirective *D) { 2843 VisitStmt(D); 2844 // The NumClauses field was read in ReadStmtFromStream. 2845 Record.skipInts(1); 2846 VisitOMPExecutableDirective(D); 2847 } 2848 2849 void ASTStmtReader::VisitOMPTargetDataDirective(OMPTargetDataDirective *D) { 2850 VisitStmt(D); 2851 Record.skipInts(1); 2852 VisitOMPExecutableDirective(D); 2853 } 2854 2855 void ASTStmtReader::VisitOMPTargetEnterDataDirective( 2856 OMPTargetEnterDataDirective *D) { 2857 VisitStmt(D); 2858 Record.skipInts(1); 2859 VisitOMPExecutableDirective(D); 2860 } 2861 2862 void ASTStmtReader::VisitOMPTargetExitDataDirective( 2863 OMPTargetExitDataDirective *D) { 2864 VisitStmt(D); 2865 Record.skipInts(1); 2866 VisitOMPExecutableDirective(D); 2867 } 2868 2869 void ASTStmtReader::VisitOMPTargetParallelDirective( 2870 OMPTargetParallelDirective *D) { 2871 VisitStmt(D); 2872 Record.skipInts(1); 2873 VisitOMPExecutableDirective(D); 2874 } 2875 2876 void ASTStmtReader::VisitOMPTargetParallelForDirective( 2877 OMPTargetParallelForDirective *D) { 2878 VisitOMPLoopDirective(D); 2879 D->setHasCancel(Record.readInt()); 2880 } 2881 2882 void ASTStmtReader::VisitOMPTeamsDirective(OMPTeamsDirective *D) { 2883 VisitStmt(D); 2884 // The NumClauses field was read in ReadStmtFromStream. 2885 Record.skipInts(1); 2886 VisitOMPExecutableDirective(D); 2887 } 2888 2889 void ASTStmtReader::VisitOMPCancellationPointDirective( 2890 OMPCancellationPointDirective *D) { 2891 VisitStmt(D); 2892 VisitOMPExecutableDirective(D); 2893 D->setCancelRegion(static_cast<OpenMPDirectiveKind>(Record.readInt())); 2894 } 2895 2896 void ASTStmtReader::VisitOMPCancelDirective(OMPCancelDirective *D) { 2897 VisitStmt(D); 2898 // The NumClauses field was read in ReadStmtFromStream. 2899 Record.skipInts(1); 2900 VisitOMPExecutableDirective(D); 2901 D->setCancelRegion(static_cast<OpenMPDirectiveKind>(Record.readInt())); 2902 } 2903 2904 void ASTStmtReader::VisitOMPTaskLoopDirective(OMPTaskLoopDirective *D) { 2905 VisitOMPLoopDirective(D); 2906 } 2907 2908 void ASTStmtReader::VisitOMPTaskLoopSimdDirective(OMPTaskLoopSimdDirective *D) { 2909 VisitOMPLoopDirective(D); 2910 } 2911 2912 void ASTStmtReader::VisitOMPDistributeDirective(OMPDistributeDirective *D) { 2913 VisitOMPLoopDirective(D); 2914 } 2915 2916 void ASTStmtReader::VisitOMPTargetUpdateDirective(OMPTargetUpdateDirective *D) { 2917 VisitStmt(D); 2918 Record.skipInts(1); 2919 VisitOMPExecutableDirective(D); 2920 } 2921 void ASTStmtReader::VisitOMPDistributeParallelForDirective( 2922 OMPDistributeParallelForDirective *D) { 2923 VisitOMPLoopDirective(D); 2924 D->setHasCancel(Record.readInt()); 2925 } 2926 2927 void ASTStmtReader::VisitOMPDistributeParallelForSimdDirective( 2928 OMPDistributeParallelForSimdDirective *D) { 2929 VisitOMPLoopDirective(D); 2930 } 2931 2932 void ASTStmtReader::VisitOMPDistributeSimdDirective( 2933 OMPDistributeSimdDirective *D) { 2934 VisitOMPLoopDirective(D); 2935 } 2936 2937 void ASTStmtReader::VisitOMPTargetParallelForSimdDirective( 2938 OMPTargetParallelForSimdDirective *D) { 2939 VisitOMPLoopDirective(D); 2940 } 2941 2942 void ASTStmtReader::VisitOMPTargetSimdDirective(OMPTargetSimdDirective *D) { 2943 VisitOMPLoopDirective(D); 2944 } 2945 2946 void ASTStmtReader::VisitOMPTeamsDistributeDirective( 2947 OMPTeamsDistributeDirective *D) { 2948 VisitOMPLoopDirective(D); 2949 } 2950 2951 void ASTStmtReader::VisitOMPTeamsDistributeSimdDirective( 2952 OMPTeamsDistributeSimdDirective *D) { 2953 VisitOMPLoopDirective(D); 2954 } 2955 2956 void ASTStmtReader::VisitOMPTeamsDistributeParallelForSimdDirective( 2957 OMPTeamsDistributeParallelForSimdDirective *D) { 2958 VisitOMPLoopDirective(D); 2959 } 2960 2961 void ASTStmtReader::VisitOMPTeamsDistributeParallelForDirective( 2962 OMPTeamsDistributeParallelForDirective *D) { 2963 VisitOMPLoopDirective(D); 2964 D->setHasCancel(Record.readInt()); 2965 } 2966 2967 void ASTStmtReader::VisitOMPTargetTeamsDirective(OMPTargetTeamsDirective *D) { 2968 VisitStmt(D); 2969 // The NumClauses field was read in ReadStmtFromStream. 2970 Record.skipInts(1); 2971 VisitOMPExecutableDirective(D); 2972 } 2973 2974 void ASTStmtReader::VisitOMPTargetTeamsDistributeDirective( 2975 OMPTargetTeamsDistributeDirective *D) { 2976 VisitOMPLoopDirective(D); 2977 } 2978 2979 void ASTStmtReader::VisitOMPTargetTeamsDistributeParallelForDirective( 2980 OMPTargetTeamsDistributeParallelForDirective *D) { 2981 VisitOMPLoopDirective(D); 2982 D->setHasCancel(Record.readInt()); 2983 } 2984 2985 void ASTStmtReader::VisitOMPTargetTeamsDistributeParallelForSimdDirective( 2986 OMPTargetTeamsDistributeParallelForSimdDirective *D) { 2987 VisitOMPLoopDirective(D); 2988 } 2989 2990 void ASTStmtReader::VisitOMPTargetTeamsDistributeSimdDirective( 2991 OMPTargetTeamsDistributeSimdDirective *D) { 2992 VisitOMPLoopDirective(D); 2993 } 2994 2995 //===----------------------------------------------------------------------===// 2996 // ASTReader Implementation 2997 //===----------------------------------------------------------------------===// 2998 2999 Stmt *ASTReader::ReadStmt(ModuleFile &F) { 3000 switch (ReadingKind) { 3001 case Read_None: 3002 llvm_unreachable("should not call this when not reading anything"); 3003 case Read_Decl: 3004 case Read_Type: 3005 return ReadStmtFromStream(F); 3006 case Read_Stmt: 3007 return ReadSubStmt(); 3008 } 3009 3010 llvm_unreachable("ReadingKind not set ?"); 3011 } 3012 3013 Expr *ASTReader::ReadExpr(ModuleFile &F) { 3014 return cast_or_null<Expr>(ReadStmt(F)); 3015 } 3016 3017 Expr *ASTReader::ReadSubExpr() { 3018 return cast_or_null<Expr>(ReadSubStmt()); 3019 } 3020 3021 // Within the bitstream, expressions are stored in Reverse Polish 3022 // Notation, with each of the subexpressions preceding the 3023 // expression they are stored in. Subexpressions are stored from last to first. 3024 // To evaluate expressions, we continue reading expressions and placing them on 3025 // the stack, with expressions having operands removing those operands from the 3026 // stack. Evaluation terminates when we see a STMT_STOP record, and 3027 // the single remaining expression on the stack is our result. 3028 Stmt *ASTReader::ReadStmtFromStream(ModuleFile &F) { 3029 3030 ReadingKindTracker ReadingKind(Read_Stmt, *this); 3031 llvm::BitstreamCursor &Cursor = F.DeclsCursor; 3032 3033 // Map of offset to previously deserialized stmt. The offset points 3034 // just after the stmt record. 3035 llvm::DenseMap<uint64_t, Stmt *> StmtEntries; 3036 3037 #ifndef NDEBUG 3038 unsigned PrevNumStmts = StmtStack.size(); 3039 #endif 3040 3041 ASTRecordReader Record(*this, F); 3042 ASTStmtReader Reader(Record, Cursor); 3043 Stmt::EmptyShell Empty; 3044 3045 while (true) { 3046 llvm::BitstreamEntry Entry = Cursor.advanceSkippingSubblocks(); 3047 3048 switch (Entry.Kind) { 3049 case llvm::BitstreamEntry::SubBlock: // Handled for us already. 3050 case llvm::BitstreamEntry::Error: 3051 Error("malformed block record in AST file"); 3052 return nullptr; 3053 case llvm::BitstreamEntry::EndBlock: 3054 goto Done; 3055 case llvm::BitstreamEntry::Record: 3056 // The interesting case. 3057 break; 3058 } 3059 3060 ASTContext &Context = getContext(); 3061 Stmt *S = nullptr; 3062 bool Finished = false; 3063 bool IsStmtReference = false; 3064 switch ((StmtCode)Record.readRecord(Cursor, Entry.ID)) { 3065 case STMT_STOP: 3066 Finished = true; 3067 break; 3068 3069 case STMT_REF_PTR: 3070 IsStmtReference = true; 3071 assert(StmtEntries.find(Record[0]) != StmtEntries.end() && 3072 "No stmt was recorded for this offset reference!"); 3073 S = StmtEntries[Record.readInt()]; 3074 break; 3075 3076 case STMT_NULL_PTR: 3077 S = nullptr; 3078 break; 3079 3080 case STMT_NULL: 3081 S = new (Context) NullStmt(Empty); 3082 break; 3083 3084 case STMT_COMPOUND: 3085 S = CompoundStmt::CreateEmpty( 3086 Context, /*NumStmts=*/Record[ASTStmtReader::NumStmtFields]); 3087 break; 3088 3089 case STMT_CASE: 3090 S = new (Context) CaseStmt(Empty); 3091 break; 3092 3093 case STMT_DEFAULT: 3094 S = new (Context) DefaultStmt(Empty); 3095 break; 3096 3097 case STMT_LABEL: 3098 S = new (Context) LabelStmt(Empty); 3099 break; 3100 3101 case STMT_ATTRIBUTED: 3102 S = AttributedStmt::CreateEmpty( 3103 Context, 3104 /*NumAttrs*/Record[ASTStmtReader::NumStmtFields]); 3105 break; 3106 3107 case STMT_IF: 3108 S = new (Context) IfStmt(Empty); 3109 break; 3110 3111 case STMT_SWITCH: 3112 S = new (Context) SwitchStmt(Empty); 3113 break; 3114 3115 case STMT_WHILE: 3116 S = new (Context) WhileStmt(Empty); 3117 break; 3118 3119 case STMT_DO: 3120 S = new (Context) DoStmt(Empty); 3121 break; 3122 3123 case STMT_FOR: 3124 S = new (Context) ForStmt(Empty); 3125 break; 3126 3127 case STMT_GOTO: 3128 S = new (Context) GotoStmt(Empty); 3129 break; 3130 3131 case STMT_INDIRECT_GOTO: 3132 S = new (Context) IndirectGotoStmt(Empty); 3133 break; 3134 3135 case STMT_CONTINUE: 3136 S = new (Context) ContinueStmt(Empty); 3137 break; 3138 3139 case STMT_BREAK: 3140 S = new (Context) BreakStmt(Empty); 3141 break; 3142 3143 case STMT_RETURN: 3144 S = new (Context) ReturnStmt(Empty); 3145 break; 3146 3147 case STMT_DECL: 3148 S = new (Context) DeclStmt(Empty); 3149 break; 3150 3151 case STMT_GCCASM: 3152 S = new (Context) GCCAsmStmt(Empty); 3153 break; 3154 3155 case STMT_MSASM: 3156 S = new (Context) MSAsmStmt(Empty); 3157 break; 3158 3159 case STMT_CAPTURED: 3160 S = CapturedStmt::CreateDeserialized(Context, 3161 Record[ASTStmtReader::NumStmtFields]); 3162 break; 3163 3164 case EXPR_PREDEFINED: 3165 S = new (Context) PredefinedExpr(Empty); 3166 break; 3167 3168 case EXPR_DECL_REF: 3169 S = DeclRefExpr::CreateEmpty( 3170 Context, 3171 /*HasQualifier=*/Record[ASTStmtReader::NumExprFields], 3172 /*HasFoundDecl=*/Record[ASTStmtReader::NumExprFields + 1], 3173 /*HasTemplateKWAndArgsInfo=*/Record[ASTStmtReader::NumExprFields + 2], 3174 /*NumTemplateArgs=*/Record[ASTStmtReader::NumExprFields + 2] ? 3175 Record[ASTStmtReader::NumExprFields + 5] : 0); 3176 break; 3177 3178 case EXPR_INTEGER_LITERAL: 3179 S = IntegerLiteral::Create(Context, Empty); 3180 break; 3181 3182 case EXPR_FLOATING_LITERAL: 3183 S = FloatingLiteral::Create(Context, Empty); 3184 break; 3185 3186 case EXPR_IMAGINARY_LITERAL: 3187 S = new (Context) ImaginaryLiteral(Empty); 3188 break; 3189 3190 case EXPR_STRING_LITERAL: 3191 S = StringLiteral::CreateEmpty(Context, 3192 Record[ASTStmtReader::NumExprFields + 1]); 3193 break; 3194 3195 case EXPR_CHARACTER_LITERAL: 3196 S = new (Context) CharacterLiteral(Empty); 3197 break; 3198 3199 case EXPR_PAREN: 3200 S = new (Context) ParenExpr(Empty); 3201 break; 3202 3203 case EXPR_PAREN_LIST: 3204 S = new (Context) ParenListExpr(Empty); 3205 break; 3206 3207 case EXPR_UNARY_OPERATOR: 3208 S = new (Context) UnaryOperator(Empty); 3209 break; 3210 3211 case EXPR_OFFSETOF: 3212 S = OffsetOfExpr::CreateEmpty(Context, 3213 Record[ASTStmtReader::NumExprFields], 3214 Record[ASTStmtReader::NumExprFields + 1]); 3215 break; 3216 3217 case EXPR_SIZEOF_ALIGN_OF: 3218 S = new (Context) UnaryExprOrTypeTraitExpr(Empty); 3219 break; 3220 3221 case EXPR_ARRAY_SUBSCRIPT: 3222 S = new (Context) ArraySubscriptExpr(Empty); 3223 break; 3224 3225 case EXPR_OMP_ARRAY_SECTION: 3226 S = new (Context) OMPArraySectionExpr(Empty); 3227 break; 3228 3229 case EXPR_CALL: 3230 S = new (Context) CallExpr(Context, Stmt::CallExprClass, Empty); 3231 break; 3232 3233 case EXPR_MEMBER: { 3234 // We load everything here and fully initialize it at creation. 3235 // That way we can use MemberExpr::Create and don't have to duplicate its 3236 // logic with a MemberExpr::CreateEmpty. 3237 3238 assert(Record.getIdx() == 0); 3239 NestedNameSpecifierLoc QualifierLoc; 3240 if (Record.readInt()) { // HasQualifier. 3241 QualifierLoc = Record.readNestedNameSpecifierLoc(); 3242 } 3243 3244 SourceLocation TemplateKWLoc; 3245 TemplateArgumentListInfo ArgInfo; 3246 bool HasTemplateKWAndArgsInfo = Record.readInt(); 3247 if (HasTemplateKWAndArgsInfo) { 3248 TemplateKWLoc = Record.readSourceLocation(); 3249 unsigned NumTemplateArgs = Record.readInt(); 3250 ArgInfo.setLAngleLoc(Record.readSourceLocation()); 3251 ArgInfo.setRAngleLoc(Record.readSourceLocation()); 3252 for (unsigned i = 0; i != NumTemplateArgs; ++i) 3253 ArgInfo.addArgument(Record.readTemplateArgumentLoc()); 3254 } 3255 3256 bool HadMultipleCandidates = Record.readInt(); 3257 3258 NamedDecl *FoundD = Record.readDeclAs<NamedDecl>(); 3259 AccessSpecifier AS = (AccessSpecifier)Record.readInt(); 3260 DeclAccessPair FoundDecl = DeclAccessPair::make(FoundD, AS); 3261 3262 QualType T = Record.readType(); 3263 ExprValueKind VK = static_cast<ExprValueKind>(Record.readInt()); 3264 ExprObjectKind OK = static_cast<ExprObjectKind>(Record.readInt()); 3265 Expr *Base = ReadSubExpr(); 3266 ValueDecl *MemberD = Record.readDeclAs<ValueDecl>(); 3267 SourceLocation MemberLoc = Record.readSourceLocation(); 3268 DeclarationNameInfo MemberNameInfo(MemberD->getDeclName(), MemberLoc); 3269 bool IsArrow = Record.readInt(); 3270 SourceLocation OperatorLoc = Record.readSourceLocation(); 3271 3272 S = MemberExpr::Create(Context, Base, IsArrow, OperatorLoc, QualifierLoc, 3273 TemplateKWLoc, MemberD, FoundDecl, MemberNameInfo, 3274 HasTemplateKWAndArgsInfo ? &ArgInfo : nullptr, T, 3275 VK, OK); 3276 Record.readDeclarationNameLoc(cast<MemberExpr>(S)->MemberDNLoc, 3277 MemberD->getDeclName()); 3278 if (HadMultipleCandidates) 3279 cast<MemberExpr>(S)->setHadMultipleCandidates(true); 3280 break; 3281 } 3282 3283 case EXPR_BINARY_OPERATOR: 3284 S = new (Context) BinaryOperator(Empty); 3285 break; 3286 3287 case EXPR_COMPOUND_ASSIGN_OPERATOR: 3288 S = new (Context) CompoundAssignOperator(Empty); 3289 break; 3290 3291 case EXPR_CONDITIONAL_OPERATOR: 3292 S = new (Context) ConditionalOperator(Empty); 3293 break; 3294 3295 case EXPR_BINARY_CONDITIONAL_OPERATOR: 3296 S = new (Context) BinaryConditionalOperator(Empty); 3297 break; 3298 3299 case EXPR_IMPLICIT_CAST: 3300 S = ImplicitCastExpr::CreateEmpty(Context, 3301 /*PathSize*/ Record[ASTStmtReader::NumExprFields]); 3302 break; 3303 3304 case EXPR_CSTYLE_CAST: 3305 S = CStyleCastExpr::CreateEmpty(Context, 3306 /*PathSize*/ Record[ASTStmtReader::NumExprFields]); 3307 break; 3308 3309 case EXPR_COMPOUND_LITERAL: 3310 S = new (Context) CompoundLiteralExpr(Empty); 3311 break; 3312 3313 case EXPR_EXT_VECTOR_ELEMENT: 3314 S = new (Context) ExtVectorElementExpr(Empty); 3315 break; 3316 3317 case EXPR_INIT_LIST: 3318 S = new (Context) InitListExpr(Empty); 3319 break; 3320 3321 case EXPR_DESIGNATED_INIT: 3322 S = DesignatedInitExpr::CreateEmpty(Context, 3323 Record[ASTStmtReader::NumExprFields] - 1); 3324 3325 break; 3326 3327 case EXPR_DESIGNATED_INIT_UPDATE: 3328 S = new (Context) DesignatedInitUpdateExpr(Empty); 3329 break; 3330 3331 case EXPR_IMPLICIT_VALUE_INIT: 3332 S = new (Context) ImplicitValueInitExpr(Empty); 3333 break; 3334 3335 case EXPR_NO_INIT: 3336 S = new (Context) NoInitExpr(Empty); 3337 break; 3338 3339 case EXPR_ARRAY_INIT_LOOP: 3340 S = new (Context) ArrayInitLoopExpr(Empty); 3341 break; 3342 3343 case EXPR_ARRAY_INIT_INDEX: 3344 S = new (Context) ArrayInitIndexExpr(Empty); 3345 break; 3346 3347 case EXPR_VA_ARG: 3348 S = new (Context) VAArgExpr(Empty); 3349 break; 3350 3351 case EXPR_ADDR_LABEL: 3352 S = new (Context) AddrLabelExpr(Empty); 3353 break; 3354 3355 case EXPR_STMT: 3356 S = new (Context) StmtExpr(Empty); 3357 break; 3358 3359 case EXPR_CHOOSE: 3360 S = new (Context) ChooseExpr(Empty); 3361 break; 3362 3363 case EXPR_GNU_NULL: 3364 S = new (Context) GNUNullExpr(Empty); 3365 break; 3366 3367 case EXPR_SHUFFLE_VECTOR: 3368 S = new (Context) ShuffleVectorExpr(Empty); 3369 break; 3370 3371 case EXPR_CONVERT_VECTOR: 3372 S = new (Context) ConvertVectorExpr(Empty); 3373 break; 3374 3375 case EXPR_BLOCK: 3376 S = new (Context) BlockExpr(Empty); 3377 break; 3378 3379 case EXPR_GENERIC_SELECTION: 3380 S = new (Context) GenericSelectionExpr(Empty); 3381 break; 3382 3383 case EXPR_OBJC_STRING_LITERAL: 3384 S = new (Context) ObjCStringLiteral(Empty); 3385 break; 3386 case EXPR_OBJC_BOXED_EXPRESSION: 3387 S = new (Context) ObjCBoxedExpr(Empty); 3388 break; 3389 case EXPR_OBJC_ARRAY_LITERAL: 3390 S = ObjCArrayLiteral::CreateEmpty(Context, 3391 Record[ASTStmtReader::NumExprFields]); 3392 break; 3393 case EXPR_OBJC_DICTIONARY_LITERAL: 3394 S = ObjCDictionaryLiteral::CreateEmpty(Context, 3395 Record[ASTStmtReader::NumExprFields], 3396 Record[ASTStmtReader::NumExprFields + 1]); 3397 break; 3398 case EXPR_OBJC_ENCODE: 3399 S = new (Context) ObjCEncodeExpr(Empty); 3400 break; 3401 case EXPR_OBJC_SELECTOR_EXPR: 3402 S = new (Context) ObjCSelectorExpr(Empty); 3403 break; 3404 case EXPR_OBJC_PROTOCOL_EXPR: 3405 S = new (Context) ObjCProtocolExpr(Empty); 3406 break; 3407 case EXPR_OBJC_IVAR_REF_EXPR: 3408 S = new (Context) ObjCIvarRefExpr(Empty); 3409 break; 3410 case EXPR_OBJC_PROPERTY_REF_EXPR: 3411 S = new (Context) ObjCPropertyRefExpr(Empty); 3412 break; 3413 case EXPR_OBJC_SUBSCRIPT_REF_EXPR: 3414 S = new (Context) ObjCSubscriptRefExpr(Empty); 3415 break; 3416 case EXPR_OBJC_KVC_REF_EXPR: 3417 llvm_unreachable("mismatching AST file"); 3418 case EXPR_OBJC_MESSAGE_EXPR: 3419 S = ObjCMessageExpr::CreateEmpty(Context, 3420 Record[ASTStmtReader::NumExprFields], 3421 Record[ASTStmtReader::NumExprFields + 1]); 3422 break; 3423 case EXPR_OBJC_ISA: 3424 S = new (Context) ObjCIsaExpr(Empty); 3425 break; 3426 case EXPR_OBJC_INDIRECT_COPY_RESTORE: 3427 S = new (Context) ObjCIndirectCopyRestoreExpr(Empty); 3428 break; 3429 case EXPR_OBJC_BRIDGED_CAST: 3430 S = new (Context) ObjCBridgedCastExpr(Empty); 3431 break; 3432 case STMT_OBJC_FOR_COLLECTION: 3433 S = new (Context) ObjCForCollectionStmt(Empty); 3434 break; 3435 case STMT_OBJC_CATCH: 3436 S = new (Context) ObjCAtCatchStmt(Empty); 3437 break; 3438 case STMT_OBJC_FINALLY: 3439 S = new (Context) ObjCAtFinallyStmt(Empty); 3440 break; 3441 case STMT_OBJC_AT_TRY: 3442 S = ObjCAtTryStmt::CreateEmpty(Context, 3443 Record[ASTStmtReader::NumStmtFields], 3444 Record[ASTStmtReader::NumStmtFields + 1]); 3445 break; 3446 case STMT_OBJC_AT_SYNCHRONIZED: 3447 S = new (Context) ObjCAtSynchronizedStmt(Empty); 3448 break; 3449 case STMT_OBJC_AT_THROW: 3450 S = new (Context) ObjCAtThrowStmt(Empty); 3451 break; 3452 case STMT_OBJC_AUTORELEASE_POOL: 3453 S = new (Context) ObjCAutoreleasePoolStmt(Empty); 3454 break; 3455 case EXPR_OBJC_BOOL_LITERAL: 3456 S = new (Context) ObjCBoolLiteralExpr(Empty); 3457 break; 3458 case EXPR_OBJC_AVAILABILITY_CHECK: 3459 S = new (Context) ObjCAvailabilityCheckExpr(Empty); 3460 break; 3461 case STMT_SEH_LEAVE: 3462 S = new (Context) SEHLeaveStmt(Empty); 3463 break; 3464 case STMT_SEH_EXCEPT: 3465 S = new (Context) SEHExceptStmt(Empty); 3466 break; 3467 case STMT_SEH_FINALLY: 3468 S = new (Context) SEHFinallyStmt(Empty); 3469 break; 3470 case STMT_SEH_TRY: 3471 S = new (Context) SEHTryStmt(Empty); 3472 break; 3473 case STMT_CXX_CATCH: 3474 S = new (Context) CXXCatchStmt(Empty); 3475 break; 3476 3477 case STMT_CXX_TRY: 3478 S = CXXTryStmt::Create(Context, Empty, 3479 /*NumHandlers=*/Record[ASTStmtReader::NumStmtFields]); 3480 break; 3481 3482 case STMT_CXX_FOR_RANGE: 3483 S = new (Context) CXXForRangeStmt(Empty); 3484 break; 3485 3486 case STMT_MS_DEPENDENT_EXISTS: 3487 S = new (Context) MSDependentExistsStmt(SourceLocation(), true, 3488 NestedNameSpecifierLoc(), 3489 DeclarationNameInfo(), 3490 nullptr); 3491 break; 3492 3493 case STMT_OMP_PARALLEL_DIRECTIVE: 3494 S = 3495 OMPParallelDirective::CreateEmpty(Context, 3496 Record[ASTStmtReader::NumStmtFields], 3497 Empty); 3498 break; 3499 3500 case STMT_OMP_SIMD_DIRECTIVE: { 3501 unsigned NumClauses = Record[ASTStmtReader::NumStmtFields]; 3502 unsigned CollapsedNum = Record[ASTStmtReader::NumStmtFields + 1]; 3503 S = OMPSimdDirective::CreateEmpty(Context, NumClauses, 3504 CollapsedNum, Empty); 3505 break; 3506 } 3507 3508 case STMT_OMP_FOR_DIRECTIVE: { 3509 unsigned NumClauses = Record[ASTStmtReader::NumStmtFields]; 3510 unsigned CollapsedNum = Record[ASTStmtReader::NumStmtFields + 1]; 3511 S = OMPForDirective::CreateEmpty(Context, NumClauses, CollapsedNum, 3512 Empty); 3513 break; 3514 } 3515 3516 case STMT_OMP_FOR_SIMD_DIRECTIVE: { 3517 unsigned NumClauses = Record[ASTStmtReader::NumStmtFields]; 3518 unsigned CollapsedNum = Record[ASTStmtReader::NumStmtFields + 1]; 3519 S = OMPForSimdDirective::CreateEmpty(Context, NumClauses, CollapsedNum, 3520 Empty); 3521 break; 3522 } 3523 3524 case STMT_OMP_SECTIONS_DIRECTIVE: 3525 S = OMPSectionsDirective::CreateEmpty( 3526 Context, Record[ASTStmtReader::NumStmtFields], Empty); 3527 break; 3528 3529 case STMT_OMP_SECTION_DIRECTIVE: 3530 S = OMPSectionDirective::CreateEmpty(Context, Empty); 3531 break; 3532 3533 case STMT_OMP_SINGLE_DIRECTIVE: 3534 S = OMPSingleDirective::CreateEmpty( 3535 Context, Record[ASTStmtReader::NumStmtFields], Empty); 3536 break; 3537 3538 case STMT_OMP_MASTER_DIRECTIVE: 3539 S = OMPMasterDirective::CreateEmpty(Context, Empty); 3540 break; 3541 3542 case STMT_OMP_CRITICAL_DIRECTIVE: 3543 S = OMPCriticalDirective::CreateEmpty( 3544 Context, Record[ASTStmtReader::NumStmtFields], Empty); 3545 break; 3546 3547 case STMT_OMP_PARALLEL_FOR_DIRECTIVE: { 3548 unsigned NumClauses = Record[ASTStmtReader::NumStmtFields]; 3549 unsigned CollapsedNum = Record[ASTStmtReader::NumStmtFields + 1]; 3550 S = OMPParallelForDirective::CreateEmpty(Context, NumClauses, 3551 CollapsedNum, Empty); 3552 break; 3553 } 3554 3555 case STMT_OMP_PARALLEL_FOR_SIMD_DIRECTIVE: { 3556 unsigned NumClauses = Record[ASTStmtReader::NumStmtFields]; 3557 unsigned CollapsedNum = Record[ASTStmtReader::NumStmtFields + 1]; 3558 S = OMPParallelForSimdDirective::CreateEmpty(Context, NumClauses, 3559 CollapsedNum, Empty); 3560 break; 3561 } 3562 3563 case STMT_OMP_PARALLEL_SECTIONS_DIRECTIVE: 3564 S = OMPParallelSectionsDirective::CreateEmpty( 3565 Context, Record[ASTStmtReader::NumStmtFields], Empty); 3566 break; 3567 3568 case STMT_OMP_TASK_DIRECTIVE: 3569 S = OMPTaskDirective::CreateEmpty( 3570 Context, Record[ASTStmtReader::NumStmtFields], Empty); 3571 break; 3572 3573 case STMT_OMP_TASKYIELD_DIRECTIVE: 3574 S = OMPTaskyieldDirective::CreateEmpty(Context, Empty); 3575 break; 3576 3577 case STMT_OMP_BARRIER_DIRECTIVE: 3578 S = OMPBarrierDirective::CreateEmpty(Context, Empty); 3579 break; 3580 3581 case STMT_OMP_TASKWAIT_DIRECTIVE: 3582 S = OMPTaskwaitDirective::CreateEmpty(Context, Empty); 3583 break; 3584 3585 case STMT_OMP_TASKGROUP_DIRECTIVE: 3586 S = OMPTaskgroupDirective::CreateEmpty( 3587 Context, Record[ASTStmtReader::NumStmtFields], Empty); 3588 break; 3589 3590 case STMT_OMP_FLUSH_DIRECTIVE: 3591 S = OMPFlushDirective::CreateEmpty( 3592 Context, Record[ASTStmtReader::NumStmtFields], Empty); 3593 break; 3594 3595 case STMT_OMP_ORDERED_DIRECTIVE: 3596 S = OMPOrderedDirective::CreateEmpty( 3597 Context, Record[ASTStmtReader::NumStmtFields], Empty); 3598 break; 3599 3600 case STMT_OMP_ATOMIC_DIRECTIVE: 3601 S = OMPAtomicDirective::CreateEmpty( 3602 Context, Record[ASTStmtReader::NumStmtFields], Empty); 3603 break; 3604 3605 case STMT_OMP_TARGET_DIRECTIVE: 3606 S = OMPTargetDirective::CreateEmpty( 3607 Context, Record[ASTStmtReader::NumStmtFields], Empty); 3608 break; 3609 3610 case STMT_OMP_TARGET_DATA_DIRECTIVE: 3611 S = OMPTargetDataDirective::CreateEmpty( 3612 Context, Record[ASTStmtReader::NumStmtFields], Empty); 3613 break; 3614 3615 case STMT_OMP_TARGET_ENTER_DATA_DIRECTIVE: 3616 S = OMPTargetEnterDataDirective::CreateEmpty( 3617 Context, Record[ASTStmtReader::NumStmtFields], Empty); 3618 break; 3619 3620 case STMT_OMP_TARGET_EXIT_DATA_DIRECTIVE: 3621 S = OMPTargetExitDataDirective::CreateEmpty( 3622 Context, Record[ASTStmtReader::NumStmtFields], Empty); 3623 break; 3624 3625 case STMT_OMP_TARGET_PARALLEL_DIRECTIVE: 3626 S = OMPTargetParallelDirective::CreateEmpty( 3627 Context, Record[ASTStmtReader::NumStmtFields], Empty); 3628 break; 3629 3630 case STMT_OMP_TARGET_PARALLEL_FOR_DIRECTIVE: { 3631 unsigned NumClauses = Record[ASTStmtReader::NumStmtFields]; 3632 unsigned CollapsedNum = Record[ASTStmtReader::NumStmtFields + 1]; 3633 S = OMPTargetParallelForDirective::CreateEmpty(Context, NumClauses, 3634 CollapsedNum, Empty); 3635 break; 3636 } 3637 3638 case STMT_OMP_TARGET_UPDATE_DIRECTIVE: 3639 S = OMPTargetUpdateDirective::CreateEmpty( 3640 Context, Record[ASTStmtReader::NumStmtFields], Empty); 3641 break; 3642 3643 case STMT_OMP_TEAMS_DIRECTIVE: 3644 S = OMPTeamsDirective::CreateEmpty( 3645 Context, Record[ASTStmtReader::NumStmtFields], Empty); 3646 break; 3647 3648 case STMT_OMP_CANCELLATION_POINT_DIRECTIVE: 3649 S = OMPCancellationPointDirective::CreateEmpty(Context, Empty); 3650 break; 3651 3652 case STMT_OMP_CANCEL_DIRECTIVE: 3653 S = OMPCancelDirective::CreateEmpty( 3654 Context, Record[ASTStmtReader::NumStmtFields], Empty); 3655 break; 3656 3657 case STMT_OMP_TASKLOOP_DIRECTIVE: { 3658 unsigned NumClauses = Record[ASTStmtReader::NumStmtFields]; 3659 unsigned CollapsedNum = Record[ASTStmtReader::NumStmtFields + 1]; 3660 S = OMPTaskLoopDirective::CreateEmpty(Context, NumClauses, CollapsedNum, 3661 Empty); 3662 break; 3663 } 3664 3665 case STMT_OMP_TASKLOOP_SIMD_DIRECTIVE: { 3666 unsigned NumClauses = Record[ASTStmtReader::NumStmtFields]; 3667 unsigned CollapsedNum = Record[ASTStmtReader::NumStmtFields + 1]; 3668 S = OMPTaskLoopSimdDirective::CreateEmpty(Context, NumClauses, 3669 CollapsedNum, Empty); 3670 break; 3671 } 3672 3673 case STMT_OMP_DISTRIBUTE_DIRECTIVE: { 3674 unsigned NumClauses = Record[ASTStmtReader::NumStmtFields]; 3675 unsigned CollapsedNum = Record[ASTStmtReader::NumStmtFields + 1]; 3676 S = OMPDistributeDirective::CreateEmpty(Context, NumClauses, CollapsedNum, 3677 Empty); 3678 break; 3679 } 3680 3681 case STMT_OMP_DISTRIBUTE_PARALLEL_FOR_DIRECTIVE: { 3682 unsigned NumClauses = Record[ASTStmtReader::NumStmtFields]; 3683 unsigned CollapsedNum = Record[ASTStmtReader::NumStmtFields + 1]; 3684 S = OMPDistributeParallelForDirective::CreateEmpty(Context, NumClauses, 3685 CollapsedNum, Empty); 3686 break; 3687 } 3688 3689 case STMT_OMP_DISTRIBUTE_PARALLEL_FOR_SIMD_DIRECTIVE: { 3690 unsigned NumClauses = Record[ASTStmtReader::NumStmtFields]; 3691 unsigned CollapsedNum = Record[ASTStmtReader::NumStmtFields + 1]; 3692 S = OMPDistributeParallelForSimdDirective::CreateEmpty(Context, NumClauses, 3693 CollapsedNum, 3694 Empty); 3695 break; 3696 } 3697 3698 case STMT_OMP_DISTRIBUTE_SIMD_DIRECTIVE: { 3699 unsigned NumClauses = Record[ASTStmtReader::NumStmtFields]; 3700 unsigned CollapsedNum = Record[ASTStmtReader::NumStmtFields + 1]; 3701 S = OMPDistributeSimdDirective::CreateEmpty(Context, NumClauses, 3702 CollapsedNum, Empty); 3703 break; 3704 } 3705 3706 case STMT_OMP_TARGET_PARALLEL_FOR_SIMD_DIRECTIVE: { 3707 unsigned NumClauses = Record[ASTStmtReader::NumStmtFields]; 3708 unsigned CollapsedNum = Record[ASTStmtReader::NumStmtFields + 1]; 3709 S = OMPTargetParallelForSimdDirective::CreateEmpty(Context, NumClauses, 3710 CollapsedNum, Empty); 3711 break; 3712 } 3713 3714 case STMT_OMP_TARGET_SIMD_DIRECTIVE: { 3715 auto NumClauses = Record[ASTStmtReader::NumStmtFields]; 3716 auto CollapsedNum = Record[ASTStmtReader::NumStmtFields + 1]; 3717 S = OMPTargetSimdDirective::CreateEmpty(Context, NumClauses, CollapsedNum, 3718 Empty); 3719 break; 3720 } 3721 3722 case STMT_OMP_TEAMS_DISTRIBUTE_DIRECTIVE: { 3723 auto NumClauses = Record[ASTStmtReader::NumStmtFields]; 3724 auto CollapsedNum = Record[ASTStmtReader::NumStmtFields + 1]; 3725 S = OMPTeamsDistributeDirective::CreateEmpty(Context, NumClauses, 3726 CollapsedNum, Empty); 3727 break; 3728 } 3729 3730 case STMT_OMP_TEAMS_DISTRIBUTE_SIMD_DIRECTIVE: { 3731 unsigned NumClauses = Record[ASTStmtReader::NumStmtFields]; 3732 unsigned CollapsedNum = Record[ASTStmtReader::NumStmtFields + 1]; 3733 S = OMPTeamsDistributeSimdDirective::CreateEmpty(Context, NumClauses, 3734 CollapsedNum, Empty); 3735 break; 3736 } 3737 3738 case STMT_OMP_TEAMS_DISTRIBUTE_PARALLEL_FOR_SIMD_DIRECTIVE: { 3739 auto NumClauses = Record[ASTStmtReader::NumStmtFields]; 3740 auto CollapsedNum = Record[ASTStmtReader::NumStmtFields + 1]; 3741 S = OMPTeamsDistributeParallelForSimdDirective::CreateEmpty( 3742 Context, NumClauses, CollapsedNum, Empty); 3743 break; 3744 } 3745 3746 case STMT_OMP_TEAMS_DISTRIBUTE_PARALLEL_FOR_DIRECTIVE: { 3747 auto NumClauses = Record[ASTStmtReader::NumStmtFields]; 3748 auto CollapsedNum = Record[ASTStmtReader::NumStmtFields + 1]; 3749 S = OMPTeamsDistributeParallelForDirective::CreateEmpty( 3750 Context, NumClauses, CollapsedNum, Empty); 3751 break; 3752 } 3753 3754 case STMT_OMP_TARGET_TEAMS_DIRECTIVE: { 3755 S = OMPTargetTeamsDirective::CreateEmpty( 3756 Context, Record[ASTStmtReader::NumStmtFields], Empty); 3757 break; 3758 } 3759 3760 case STMT_OMP_TARGET_TEAMS_DISTRIBUTE_DIRECTIVE: { 3761 auto NumClauses = Record[ASTStmtReader::NumStmtFields]; 3762 auto CollapsedNum = Record[ASTStmtReader::NumStmtFields + 1]; 3763 S = OMPTargetTeamsDistributeDirective::CreateEmpty(Context, NumClauses, 3764 CollapsedNum, Empty); 3765 break; 3766 } 3767 3768 case STMT_OMP_TARGET_TEAMS_DISTRIBUTE_PARALLEL_FOR_DIRECTIVE: { 3769 auto NumClauses = Record[ASTStmtReader::NumStmtFields]; 3770 auto CollapsedNum = Record[ASTStmtReader::NumStmtFields + 1]; 3771 S = OMPTargetTeamsDistributeParallelForDirective::CreateEmpty( 3772 Context, NumClauses, CollapsedNum, Empty); 3773 break; 3774 } 3775 3776 case STMT_OMP_TARGET_TEAMS_DISTRIBUTE_PARALLEL_FOR_SIMD_DIRECTIVE: { 3777 auto NumClauses = Record[ASTStmtReader::NumStmtFields]; 3778 auto CollapsedNum = Record[ASTStmtReader::NumStmtFields + 1]; 3779 S = OMPTargetTeamsDistributeParallelForSimdDirective::CreateEmpty( 3780 Context, NumClauses, CollapsedNum, Empty); 3781 break; 3782 } 3783 3784 case STMT_OMP_TARGET_TEAMS_DISTRIBUTE_SIMD_DIRECTIVE: { 3785 auto NumClauses = Record[ASTStmtReader::NumStmtFields]; 3786 auto CollapsedNum = Record[ASTStmtReader::NumStmtFields + 1]; 3787 S = OMPTargetTeamsDistributeSimdDirective::CreateEmpty( 3788 Context, NumClauses, CollapsedNum, Empty); 3789 break; 3790 } 3791 3792 case EXPR_CXX_OPERATOR_CALL: 3793 S = new (Context) CXXOperatorCallExpr(Context, Empty); 3794 break; 3795 3796 case EXPR_CXX_MEMBER_CALL: 3797 S = new (Context) CXXMemberCallExpr(Context, Empty); 3798 break; 3799 3800 case EXPR_CXX_CONSTRUCT: 3801 S = new (Context) CXXConstructExpr(Empty); 3802 break; 3803 3804 case EXPR_CXX_INHERITED_CTOR_INIT: 3805 S = new (Context) CXXInheritedCtorInitExpr(Empty); 3806 break; 3807 3808 case EXPR_CXX_TEMPORARY_OBJECT: 3809 S = new (Context) CXXTemporaryObjectExpr(Empty); 3810 break; 3811 3812 case EXPR_CXX_STATIC_CAST: 3813 S = CXXStaticCastExpr::CreateEmpty(Context, 3814 /*PathSize*/ Record[ASTStmtReader::NumExprFields]); 3815 break; 3816 3817 case EXPR_CXX_DYNAMIC_CAST: 3818 S = CXXDynamicCastExpr::CreateEmpty(Context, 3819 /*PathSize*/ Record[ASTStmtReader::NumExprFields]); 3820 break; 3821 3822 case EXPR_CXX_REINTERPRET_CAST: 3823 S = CXXReinterpretCastExpr::CreateEmpty(Context, 3824 /*PathSize*/ Record[ASTStmtReader::NumExprFields]); 3825 break; 3826 3827 case EXPR_CXX_CONST_CAST: 3828 S = CXXConstCastExpr::CreateEmpty(Context); 3829 break; 3830 3831 case EXPR_CXX_FUNCTIONAL_CAST: 3832 S = CXXFunctionalCastExpr::CreateEmpty(Context, 3833 /*PathSize*/ Record[ASTStmtReader::NumExprFields]); 3834 break; 3835 3836 case EXPR_USER_DEFINED_LITERAL: 3837 S = new (Context) UserDefinedLiteral(Context, Empty); 3838 break; 3839 3840 case EXPR_CXX_STD_INITIALIZER_LIST: 3841 S = new (Context) CXXStdInitializerListExpr(Empty); 3842 break; 3843 3844 case EXPR_CXX_BOOL_LITERAL: 3845 S = new (Context) CXXBoolLiteralExpr(Empty); 3846 break; 3847 3848 case EXPR_CXX_NULL_PTR_LITERAL: 3849 S = new (Context) CXXNullPtrLiteralExpr(Empty); 3850 break; 3851 case EXPR_CXX_TYPEID_EXPR: 3852 S = new (Context) CXXTypeidExpr(Empty, true); 3853 break; 3854 case EXPR_CXX_TYPEID_TYPE: 3855 S = new (Context) CXXTypeidExpr(Empty, false); 3856 break; 3857 case EXPR_CXX_UUIDOF_EXPR: 3858 S = new (Context) CXXUuidofExpr(Empty, true); 3859 break; 3860 case EXPR_CXX_PROPERTY_REF_EXPR: 3861 S = new (Context) MSPropertyRefExpr(Empty); 3862 break; 3863 case EXPR_CXX_PROPERTY_SUBSCRIPT_EXPR: 3864 S = new (Context) MSPropertySubscriptExpr(Empty); 3865 break; 3866 case EXPR_CXX_UUIDOF_TYPE: 3867 S = new (Context) CXXUuidofExpr(Empty, false); 3868 break; 3869 case EXPR_CXX_THIS: 3870 S = new (Context) CXXThisExpr(Empty); 3871 break; 3872 case EXPR_CXX_THROW: 3873 S = new (Context) CXXThrowExpr(Empty); 3874 break; 3875 case EXPR_CXX_DEFAULT_ARG: 3876 S = new (Context) CXXDefaultArgExpr(Empty); 3877 break; 3878 case EXPR_CXX_DEFAULT_INIT: 3879 S = new (Context) CXXDefaultInitExpr(Empty); 3880 break; 3881 case EXPR_CXX_BIND_TEMPORARY: 3882 S = new (Context) CXXBindTemporaryExpr(Empty); 3883 break; 3884 3885 case EXPR_CXX_SCALAR_VALUE_INIT: 3886 S = new (Context) CXXScalarValueInitExpr(Empty); 3887 break; 3888 case EXPR_CXX_NEW: 3889 S = new (Context) CXXNewExpr(Empty); 3890 break; 3891 case EXPR_CXX_DELETE: 3892 S = new (Context) CXXDeleteExpr(Empty); 3893 break; 3894 case EXPR_CXX_PSEUDO_DESTRUCTOR: 3895 S = new (Context) CXXPseudoDestructorExpr(Empty); 3896 break; 3897 3898 case EXPR_EXPR_WITH_CLEANUPS: 3899 S = ExprWithCleanups::Create(Context, Empty, 3900 Record[ASTStmtReader::NumExprFields]); 3901 break; 3902 3903 case EXPR_CXX_DEPENDENT_SCOPE_MEMBER: 3904 S = CXXDependentScopeMemberExpr::CreateEmpty(Context, 3905 /*HasTemplateKWAndArgsInfo=*/Record[ASTStmtReader::NumExprFields], 3906 /*NumTemplateArgs=*/Record[ASTStmtReader::NumExprFields] 3907 ? Record[ASTStmtReader::NumExprFields + 1] 3908 : 0); 3909 break; 3910 3911 case EXPR_CXX_DEPENDENT_SCOPE_DECL_REF: 3912 S = DependentScopeDeclRefExpr::CreateEmpty(Context, 3913 /*HasTemplateKWAndArgsInfo=*/Record[ASTStmtReader::NumExprFields], 3914 /*NumTemplateArgs=*/Record[ASTStmtReader::NumExprFields] 3915 ? Record[ASTStmtReader::NumExprFields + 1] 3916 : 0); 3917 break; 3918 3919 case EXPR_CXX_UNRESOLVED_CONSTRUCT: 3920 S = CXXUnresolvedConstructExpr::CreateEmpty(Context, 3921 /*NumArgs=*/Record[ASTStmtReader::NumExprFields]); 3922 break; 3923 3924 case EXPR_CXX_UNRESOLVED_MEMBER: 3925 S = UnresolvedMemberExpr::CreateEmpty(Context, 3926 /*HasTemplateKWAndArgsInfo=*/Record[ASTStmtReader::NumExprFields], 3927 /*NumTemplateArgs=*/Record[ASTStmtReader::NumExprFields] 3928 ? Record[ASTStmtReader::NumExprFields + 1] 3929 : 0); 3930 break; 3931 3932 case EXPR_CXX_UNRESOLVED_LOOKUP: 3933 S = UnresolvedLookupExpr::CreateEmpty(Context, 3934 /*HasTemplateKWAndArgsInfo=*/Record[ASTStmtReader::NumExprFields], 3935 /*NumTemplateArgs=*/Record[ASTStmtReader::NumExprFields] 3936 ? Record[ASTStmtReader::NumExprFields + 1] 3937 : 0); 3938 break; 3939 3940 case EXPR_TYPE_TRAIT: 3941 S = TypeTraitExpr::CreateDeserialized(Context, 3942 Record[ASTStmtReader::NumExprFields]); 3943 break; 3944 3945 case EXPR_ARRAY_TYPE_TRAIT: 3946 S = new (Context) ArrayTypeTraitExpr(Empty); 3947 break; 3948 3949 case EXPR_CXX_EXPRESSION_TRAIT: 3950 S = new (Context) ExpressionTraitExpr(Empty); 3951 break; 3952 3953 case EXPR_CXX_NOEXCEPT: 3954 S = new (Context) CXXNoexceptExpr(Empty); 3955 break; 3956 3957 case EXPR_PACK_EXPANSION: 3958 S = new (Context) PackExpansionExpr(Empty); 3959 break; 3960 3961 case EXPR_SIZEOF_PACK: 3962 S = SizeOfPackExpr::CreateDeserialized( 3963 Context, 3964 /*NumPartialArgs=*/Record[ASTStmtReader::NumExprFields]); 3965 break; 3966 3967 case EXPR_SUBST_NON_TYPE_TEMPLATE_PARM: 3968 S = new (Context) SubstNonTypeTemplateParmExpr(Empty); 3969 break; 3970 3971 case EXPR_SUBST_NON_TYPE_TEMPLATE_PARM_PACK: 3972 S = new (Context) SubstNonTypeTemplateParmPackExpr(Empty); 3973 break; 3974 3975 case EXPR_FUNCTION_PARM_PACK: 3976 S = FunctionParmPackExpr::CreateEmpty(Context, 3977 Record[ASTStmtReader::NumExprFields]); 3978 break; 3979 3980 case EXPR_MATERIALIZE_TEMPORARY: 3981 S = new (Context) MaterializeTemporaryExpr(Empty); 3982 break; 3983 3984 case EXPR_CXX_FOLD: 3985 S = new (Context) CXXFoldExpr(Empty); 3986 break; 3987 3988 case EXPR_OPAQUE_VALUE: 3989 S = new (Context) OpaqueValueExpr(Empty); 3990 break; 3991 3992 case EXPR_CUDA_KERNEL_CALL: 3993 S = new (Context) CUDAKernelCallExpr(Context, Empty); 3994 break; 3995 3996 case EXPR_ASTYPE: 3997 S = new (Context) AsTypeExpr(Empty); 3998 break; 3999 4000 case EXPR_PSEUDO_OBJECT: { 4001 unsigned numSemanticExprs = Record[ASTStmtReader::NumExprFields]; 4002 S = PseudoObjectExpr::Create(Context, Empty, numSemanticExprs); 4003 break; 4004 } 4005 4006 case EXPR_ATOMIC: 4007 S = new (Context) AtomicExpr(Empty); 4008 break; 4009 4010 case EXPR_LAMBDA: { 4011 unsigned NumCaptures = Record[ASTStmtReader::NumExprFields]; 4012 S = LambdaExpr::CreateDeserialized(Context, NumCaptures); 4013 break; 4014 } 4015 4016 case STMT_COROUTINE_BODY: { 4017 unsigned NumParams = Record[ASTStmtReader::NumStmtFields]; 4018 S = CoroutineBodyStmt::Create(Context, Empty, NumParams); 4019 break; 4020 } 4021 4022 case STMT_CORETURN: 4023 S = new (Context) CoreturnStmt(Empty); 4024 break; 4025 4026 case EXPR_COAWAIT: 4027 S = new (Context) CoawaitExpr(Empty); 4028 break; 4029 4030 case EXPR_COYIELD: 4031 S = new (Context) CoyieldExpr(Empty); 4032 break; 4033 4034 case EXPR_DEPENDENT_COAWAIT: 4035 S = new (Context) DependentCoawaitExpr(Empty); 4036 break; 4037 4038 } 4039 4040 // We hit a STMT_STOP, so we're done with this expression. 4041 if (Finished) 4042 break; 4043 4044 ++NumStatementsRead; 4045 4046 if (S && !IsStmtReference) { 4047 Reader.Visit(S); 4048 StmtEntries[Cursor.GetCurrentBitNo()] = S; 4049 } 4050 4051 assert(Record.getIdx() == Record.size() && 4052 "Invalid deserialization of statement"); 4053 StmtStack.push_back(S); 4054 } 4055 Done: 4056 assert(StmtStack.size() > PrevNumStmts && "Read too many sub-stmts!"); 4057 assert(StmtStack.size() == PrevNumStmts + 1 && "Extra expressions on stack!"); 4058 return StmtStack.pop_back_val(); 4059 } 4060