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 E->setIsUnique(Record.readInt()); 1671 } 1672 1673 void ASTStmtReader::VisitTypoExpr(TypoExpr *E) { 1674 llvm_unreachable("Cannot read TypoExpr nodes"); 1675 } 1676 1677 //===----------------------------------------------------------------------===// 1678 // Microsoft Expressions and Statements 1679 //===----------------------------------------------------------------------===// 1680 void ASTStmtReader::VisitMSPropertyRefExpr(MSPropertyRefExpr *E) { 1681 VisitExpr(E); 1682 E->IsArrow = (Record.readInt() != 0); 1683 E->BaseExpr = Record.readSubExpr(); 1684 E->QualifierLoc = Record.readNestedNameSpecifierLoc(); 1685 E->MemberLoc = ReadSourceLocation(); 1686 E->TheDecl = ReadDeclAs<MSPropertyDecl>(); 1687 } 1688 1689 void ASTStmtReader::VisitMSPropertySubscriptExpr(MSPropertySubscriptExpr *E) { 1690 VisitExpr(E); 1691 E->setBase(Record.readSubExpr()); 1692 E->setIdx(Record.readSubExpr()); 1693 E->setRBracketLoc(ReadSourceLocation()); 1694 } 1695 1696 void ASTStmtReader::VisitCXXUuidofExpr(CXXUuidofExpr *E) { 1697 VisitExpr(E); 1698 E->setSourceRange(ReadSourceRange()); 1699 std::string UuidStr = ReadString(); 1700 E->setUuidStr(StringRef(UuidStr).copy(Record.getContext())); 1701 if (E->isTypeOperand()) { // __uuidof(ComType) 1702 E->setTypeOperandSourceInfo( 1703 GetTypeSourceInfo()); 1704 return; 1705 } 1706 1707 // __uuidof(expr) 1708 E->setExprOperand(Record.readSubExpr()); 1709 } 1710 1711 void ASTStmtReader::VisitSEHLeaveStmt(SEHLeaveStmt *S) { 1712 VisitStmt(S); 1713 S->setLeaveLoc(ReadSourceLocation()); 1714 } 1715 1716 void ASTStmtReader::VisitSEHExceptStmt(SEHExceptStmt *S) { 1717 VisitStmt(S); 1718 S->Loc = ReadSourceLocation(); 1719 S->Children[SEHExceptStmt::FILTER_EXPR] = Record.readSubStmt(); 1720 S->Children[SEHExceptStmt::BLOCK] = Record.readSubStmt(); 1721 } 1722 1723 void ASTStmtReader::VisitSEHFinallyStmt(SEHFinallyStmt *S) { 1724 VisitStmt(S); 1725 S->Loc = ReadSourceLocation(); 1726 S->Block = Record.readSubStmt(); 1727 } 1728 1729 void ASTStmtReader::VisitSEHTryStmt(SEHTryStmt *S) { 1730 VisitStmt(S); 1731 S->IsCXXTry = Record.readInt(); 1732 S->TryLoc = ReadSourceLocation(); 1733 S->Children[SEHTryStmt::TRY] = Record.readSubStmt(); 1734 S->Children[SEHTryStmt::HANDLER] = Record.readSubStmt(); 1735 } 1736 1737 //===----------------------------------------------------------------------===// 1738 // CUDA Expressions and Statements 1739 //===----------------------------------------------------------------------===// 1740 1741 void ASTStmtReader::VisitCUDAKernelCallExpr(CUDAKernelCallExpr *E) { 1742 VisitCallExpr(E); 1743 E->setConfig(cast<CallExpr>(Record.readSubExpr())); 1744 } 1745 1746 //===----------------------------------------------------------------------===// 1747 // OpenCL Expressions and Statements. 1748 //===----------------------------------------------------------------------===// 1749 void ASTStmtReader::VisitAsTypeExpr(AsTypeExpr *E) { 1750 VisitExpr(E); 1751 E->BuiltinLoc = ReadSourceLocation(); 1752 E->RParenLoc = ReadSourceLocation(); 1753 E->SrcExpr = Record.readSubExpr(); 1754 } 1755 1756 //===----------------------------------------------------------------------===// 1757 // OpenMP Clauses. 1758 //===----------------------------------------------------------------------===// 1759 1760 namespace clang { 1761 class OMPClauseReader : public OMPClauseVisitor<OMPClauseReader> { 1762 ASTStmtReader *Reader; 1763 ASTContext &Context; 1764 public: 1765 OMPClauseReader(ASTStmtReader *R, ASTRecordReader &Record) 1766 : Reader(R), Context(Record.getContext()) {} 1767 #define OPENMP_CLAUSE(Name, Class) void Visit##Class(Class *C); 1768 #include "clang/Basic/OpenMPKinds.def" 1769 OMPClause *readClause(); 1770 void VisitOMPClauseWithPreInit(OMPClauseWithPreInit *C); 1771 void VisitOMPClauseWithPostUpdate(OMPClauseWithPostUpdate *C); 1772 }; 1773 } 1774 1775 OMPClause *OMPClauseReader::readClause() { 1776 OMPClause *C; 1777 switch (Reader->Record.readInt()) { 1778 case OMPC_if: 1779 C = new (Context) OMPIfClause(); 1780 break; 1781 case OMPC_final: 1782 C = new (Context) OMPFinalClause(); 1783 break; 1784 case OMPC_num_threads: 1785 C = new (Context) OMPNumThreadsClause(); 1786 break; 1787 case OMPC_safelen: 1788 C = new (Context) OMPSafelenClause(); 1789 break; 1790 case OMPC_simdlen: 1791 C = new (Context) OMPSimdlenClause(); 1792 break; 1793 case OMPC_collapse: 1794 C = new (Context) OMPCollapseClause(); 1795 break; 1796 case OMPC_default: 1797 C = new (Context) OMPDefaultClause(); 1798 break; 1799 case OMPC_proc_bind: 1800 C = new (Context) OMPProcBindClause(); 1801 break; 1802 case OMPC_schedule: 1803 C = new (Context) OMPScheduleClause(); 1804 break; 1805 case OMPC_ordered: 1806 C = new (Context) OMPOrderedClause(); 1807 break; 1808 case OMPC_nowait: 1809 C = new (Context) OMPNowaitClause(); 1810 break; 1811 case OMPC_untied: 1812 C = new (Context) OMPUntiedClause(); 1813 break; 1814 case OMPC_mergeable: 1815 C = new (Context) OMPMergeableClause(); 1816 break; 1817 case OMPC_read: 1818 C = new (Context) OMPReadClause(); 1819 break; 1820 case OMPC_write: 1821 C = new (Context) OMPWriteClause(); 1822 break; 1823 case OMPC_update: 1824 C = new (Context) OMPUpdateClause(); 1825 break; 1826 case OMPC_capture: 1827 C = new (Context) OMPCaptureClause(); 1828 break; 1829 case OMPC_seq_cst: 1830 C = new (Context) OMPSeqCstClause(); 1831 break; 1832 case OMPC_threads: 1833 C = new (Context) OMPThreadsClause(); 1834 break; 1835 case OMPC_simd: 1836 C = new (Context) OMPSIMDClause(); 1837 break; 1838 case OMPC_nogroup: 1839 C = new (Context) OMPNogroupClause(); 1840 break; 1841 case OMPC_private: 1842 C = OMPPrivateClause::CreateEmpty(Context, Reader->Record.readInt()); 1843 break; 1844 case OMPC_firstprivate: 1845 C = OMPFirstprivateClause::CreateEmpty(Context, Reader->Record.readInt()); 1846 break; 1847 case OMPC_lastprivate: 1848 C = OMPLastprivateClause::CreateEmpty(Context, Reader->Record.readInt()); 1849 break; 1850 case OMPC_shared: 1851 C = OMPSharedClause::CreateEmpty(Context, Reader->Record.readInt()); 1852 break; 1853 case OMPC_reduction: 1854 C = OMPReductionClause::CreateEmpty(Context, Reader->Record.readInt()); 1855 break; 1856 case OMPC_task_reduction: 1857 C = OMPTaskReductionClause::CreateEmpty(Context, Reader->Record.readInt()); 1858 break; 1859 case OMPC_in_reduction: 1860 C = OMPInReductionClause::CreateEmpty(Context, Reader->Record.readInt()); 1861 break; 1862 case OMPC_linear: 1863 C = OMPLinearClause::CreateEmpty(Context, Reader->Record.readInt()); 1864 break; 1865 case OMPC_aligned: 1866 C = OMPAlignedClause::CreateEmpty(Context, Reader->Record.readInt()); 1867 break; 1868 case OMPC_copyin: 1869 C = OMPCopyinClause::CreateEmpty(Context, Reader->Record.readInt()); 1870 break; 1871 case OMPC_copyprivate: 1872 C = OMPCopyprivateClause::CreateEmpty(Context, Reader->Record.readInt()); 1873 break; 1874 case OMPC_flush: 1875 C = OMPFlushClause::CreateEmpty(Context, Reader->Record.readInt()); 1876 break; 1877 case OMPC_depend: 1878 C = OMPDependClause::CreateEmpty(Context, Reader->Record.readInt()); 1879 break; 1880 case OMPC_device: 1881 C = new (Context) OMPDeviceClause(); 1882 break; 1883 case OMPC_map: { 1884 unsigned NumVars = Reader->Record.readInt(); 1885 unsigned NumDeclarations = Reader->Record.readInt(); 1886 unsigned NumLists = Reader->Record.readInt(); 1887 unsigned NumComponents = Reader->Record.readInt(); 1888 C = OMPMapClause::CreateEmpty(Context, NumVars, NumDeclarations, NumLists, 1889 NumComponents); 1890 break; 1891 } 1892 case OMPC_num_teams: 1893 C = new (Context) OMPNumTeamsClause(); 1894 break; 1895 case OMPC_thread_limit: 1896 C = new (Context) OMPThreadLimitClause(); 1897 break; 1898 case OMPC_priority: 1899 C = new (Context) OMPPriorityClause(); 1900 break; 1901 case OMPC_grainsize: 1902 C = new (Context) OMPGrainsizeClause(); 1903 break; 1904 case OMPC_num_tasks: 1905 C = new (Context) OMPNumTasksClause(); 1906 break; 1907 case OMPC_hint: 1908 C = new (Context) OMPHintClause(); 1909 break; 1910 case OMPC_dist_schedule: 1911 C = new (Context) OMPDistScheduleClause(); 1912 break; 1913 case OMPC_defaultmap: 1914 C = new (Context) OMPDefaultmapClause(); 1915 break; 1916 case OMPC_to: { 1917 unsigned NumVars = Reader->Record.readInt(); 1918 unsigned NumDeclarations = Reader->Record.readInt(); 1919 unsigned NumLists = Reader->Record.readInt(); 1920 unsigned NumComponents = Reader->Record.readInt(); 1921 C = OMPToClause::CreateEmpty(Context, NumVars, NumDeclarations, NumLists, 1922 NumComponents); 1923 break; 1924 } 1925 case OMPC_from: { 1926 unsigned NumVars = Reader->Record.readInt(); 1927 unsigned NumDeclarations = Reader->Record.readInt(); 1928 unsigned NumLists = Reader->Record.readInt(); 1929 unsigned NumComponents = Reader->Record.readInt(); 1930 C = OMPFromClause::CreateEmpty(Context, NumVars, NumDeclarations, NumLists, 1931 NumComponents); 1932 break; 1933 } 1934 case OMPC_use_device_ptr: { 1935 unsigned NumVars = Reader->Record.readInt(); 1936 unsigned NumDeclarations = Reader->Record.readInt(); 1937 unsigned NumLists = Reader->Record.readInt(); 1938 unsigned NumComponents = Reader->Record.readInt(); 1939 C = OMPUseDevicePtrClause::CreateEmpty(Context, NumVars, NumDeclarations, 1940 NumLists, NumComponents); 1941 break; 1942 } 1943 case OMPC_is_device_ptr: { 1944 unsigned NumVars = Reader->Record.readInt(); 1945 unsigned NumDeclarations = Reader->Record.readInt(); 1946 unsigned NumLists = Reader->Record.readInt(); 1947 unsigned NumComponents = Reader->Record.readInt(); 1948 C = OMPIsDevicePtrClause::CreateEmpty(Context, NumVars, NumDeclarations, 1949 NumLists, NumComponents); 1950 break; 1951 } 1952 } 1953 Visit(C); 1954 C->setLocStart(Reader->ReadSourceLocation()); 1955 C->setLocEnd(Reader->ReadSourceLocation()); 1956 1957 return C; 1958 } 1959 1960 void OMPClauseReader::VisitOMPClauseWithPreInit(OMPClauseWithPreInit *C) { 1961 C->setPreInitStmt(Reader->Record.readSubStmt(), 1962 static_cast<OpenMPDirectiveKind>(Reader->Record.readInt())); 1963 } 1964 1965 void OMPClauseReader::VisitOMPClauseWithPostUpdate(OMPClauseWithPostUpdate *C) { 1966 VisitOMPClauseWithPreInit(C); 1967 C->setPostUpdateExpr(Reader->Record.readSubExpr()); 1968 } 1969 1970 void OMPClauseReader::VisitOMPIfClause(OMPIfClause *C) { 1971 VisitOMPClauseWithPreInit(C); 1972 C->setNameModifier(static_cast<OpenMPDirectiveKind>(Reader->Record.readInt())); 1973 C->setNameModifierLoc(Reader->ReadSourceLocation()); 1974 C->setColonLoc(Reader->ReadSourceLocation()); 1975 C->setCondition(Reader->Record.readSubExpr()); 1976 C->setLParenLoc(Reader->ReadSourceLocation()); 1977 } 1978 1979 void OMPClauseReader::VisitOMPFinalClause(OMPFinalClause *C) { 1980 C->setCondition(Reader->Record.readSubExpr()); 1981 C->setLParenLoc(Reader->ReadSourceLocation()); 1982 } 1983 1984 void OMPClauseReader::VisitOMPNumThreadsClause(OMPNumThreadsClause *C) { 1985 VisitOMPClauseWithPreInit(C); 1986 C->setNumThreads(Reader->Record.readSubExpr()); 1987 C->setLParenLoc(Reader->ReadSourceLocation()); 1988 } 1989 1990 void OMPClauseReader::VisitOMPSafelenClause(OMPSafelenClause *C) { 1991 C->setSafelen(Reader->Record.readSubExpr()); 1992 C->setLParenLoc(Reader->ReadSourceLocation()); 1993 } 1994 1995 void OMPClauseReader::VisitOMPSimdlenClause(OMPSimdlenClause *C) { 1996 C->setSimdlen(Reader->Record.readSubExpr()); 1997 C->setLParenLoc(Reader->ReadSourceLocation()); 1998 } 1999 2000 void OMPClauseReader::VisitOMPCollapseClause(OMPCollapseClause *C) { 2001 C->setNumForLoops(Reader->Record.readSubExpr()); 2002 C->setLParenLoc(Reader->ReadSourceLocation()); 2003 } 2004 2005 void OMPClauseReader::VisitOMPDefaultClause(OMPDefaultClause *C) { 2006 C->setDefaultKind( 2007 static_cast<OpenMPDefaultClauseKind>(Reader->Record.readInt())); 2008 C->setLParenLoc(Reader->ReadSourceLocation()); 2009 C->setDefaultKindKwLoc(Reader->ReadSourceLocation()); 2010 } 2011 2012 void OMPClauseReader::VisitOMPProcBindClause(OMPProcBindClause *C) { 2013 C->setProcBindKind( 2014 static_cast<OpenMPProcBindClauseKind>(Reader->Record.readInt())); 2015 C->setLParenLoc(Reader->ReadSourceLocation()); 2016 C->setProcBindKindKwLoc(Reader->ReadSourceLocation()); 2017 } 2018 2019 void OMPClauseReader::VisitOMPScheduleClause(OMPScheduleClause *C) { 2020 VisitOMPClauseWithPreInit(C); 2021 C->setScheduleKind( 2022 static_cast<OpenMPScheduleClauseKind>(Reader->Record.readInt())); 2023 C->setFirstScheduleModifier( 2024 static_cast<OpenMPScheduleClauseModifier>(Reader->Record.readInt())); 2025 C->setSecondScheduleModifier( 2026 static_cast<OpenMPScheduleClauseModifier>(Reader->Record.readInt())); 2027 C->setChunkSize(Reader->Record.readSubExpr()); 2028 C->setLParenLoc(Reader->ReadSourceLocation()); 2029 C->setFirstScheduleModifierLoc(Reader->ReadSourceLocation()); 2030 C->setSecondScheduleModifierLoc(Reader->ReadSourceLocation()); 2031 C->setScheduleKindLoc(Reader->ReadSourceLocation()); 2032 C->setCommaLoc(Reader->ReadSourceLocation()); 2033 } 2034 2035 void OMPClauseReader::VisitOMPOrderedClause(OMPOrderedClause *C) { 2036 C->setNumForLoops(Reader->Record.readSubExpr()); 2037 C->setLParenLoc(Reader->ReadSourceLocation()); 2038 } 2039 2040 void OMPClauseReader::VisitOMPNowaitClause(OMPNowaitClause *) {} 2041 2042 void OMPClauseReader::VisitOMPUntiedClause(OMPUntiedClause *) {} 2043 2044 void OMPClauseReader::VisitOMPMergeableClause(OMPMergeableClause *) {} 2045 2046 void OMPClauseReader::VisitOMPReadClause(OMPReadClause *) {} 2047 2048 void OMPClauseReader::VisitOMPWriteClause(OMPWriteClause *) {} 2049 2050 void OMPClauseReader::VisitOMPUpdateClause(OMPUpdateClause *) {} 2051 2052 void OMPClauseReader::VisitOMPCaptureClause(OMPCaptureClause *) {} 2053 2054 void OMPClauseReader::VisitOMPSeqCstClause(OMPSeqCstClause *) {} 2055 2056 void OMPClauseReader::VisitOMPThreadsClause(OMPThreadsClause *) {} 2057 2058 void OMPClauseReader::VisitOMPSIMDClause(OMPSIMDClause *) {} 2059 2060 void OMPClauseReader::VisitOMPNogroupClause(OMPNogroupClause *) {} 2061 2062 void OMPClauseReader::VisitOMPPrivateClause(OMPPrivateClause *C) { 2063 C->setLParenLoc(Reader->ReadSourceLocation()); 2064 unsigned NumVars = C->varlist_size(); 2065 SmallVector<Expr *, 16> Vars; 2066 Vars.reserve(NumVars); 2067 for (unsigned i = 0; i != NumVars; ++i) 2068 Vars.push_back(Reader->Record.readSubExpr()); 2069 C->setVarRefs(Vars); 2070 Vars.clear(); 2071 for (unsigned i = 0; i != NumVars; ++i) 2072 Vars.push_back(Reader->Record.readSubExpr()); 2073 C->setPrivateCopies(Vars); 2074 } 2075 2076 void OMPClauseReader::VisitOMPFirstprivateClause(OMPFirstprivateClause *C) { 2077 VisitOMPClauseWithPreInit(C); 2078 C->setLParenLoc(Reader->ReadSourceLocation()); 2079 unsigned NumVars = C->varlist_size(); 2080 SmallVector<Expr *, 16> Vars; 2081 Vars.reserve(NumVars); 2082 for (unsigned i = 0; i != NumVars; ++i) 2083 Vars.push_back(Reader->Record.readSubExpr()); 2084 C->setVarRefs(Vars); 2085 Vars.clear(); 2086 for (unsigned i = 0; i != NumVars; ++i) 2087 Vars.push_back(Reader->Record.readSubExpr()); 2088 C->setPrivateCopies(Vars); 2089 Vars.clear(); 2090 for (unsigned i = 0; i != NumVars; ++i) 2091 Vars.push_back(Reader->Record.readSubExpr()); 2092 C->setInits(Vars); 2093 } 2094 2095 void OMPClauseReader::VisitOMPLastprivateClause(OMPLastprivateClause *C) { 2096 VisitOMPClauseWithPostUpdate(C); 2097 C->setLParenLoc(Reader->ReadSourceLocation()); 2098 unsigned NumVars = C->varlist_size(); 2099 SmallVector<Expr *, 16> Vars; 2100 Vars.reserve(NumVars); 2101 for (unsigned i = 0; i != NumVars; ++i) 2102 Vars.push_back(Reader->Record.readSubExpr()); 2103 C->setVarRefs(Vars); 2104 Vars.clear(); 2105 for (unsigned i = 0; i != NumVars; ++i) 2106 Vars.push_back(Reader->Record.readSubExpr()); 2107 C->setPrivateCopies(Vars); 2108 Vars.clear(); 2109 for (unsigned i = 0; i != NumVars; ++i) 2110 Vars.push_back(Reader->Record.readSubExpr()); 2111 C->setSourceExprs(Vars); 2112 Vars.clear(); 2113 for (unsigned i = 0; i != NumVars; ++i) 2114 Vars.push_back(Reader->Record.readSubExpr()); 2115 C->setDestinationExprs(Vars); 2116 Vars.clear(); 2117 for (unsigned i = 0; i != NumVars; ++i) 2118 Vars.push_back(Reader->Record.readSubExpr()); 2119 C->setAssignmentOps(Vars); 2120 } 2121 2122 void OMPClauseReader::VisitOMPSharedClause(OMPSharedClause *C) { 2123 C->setLParenLoc(Reader->ReadSourceLocation()); 2124 unsigned NumVars = C->varlist_size(); 2125 SmallVector<Expr *, 16> Vars; 2126 Vars.reserve(NumVars); 2127 for (unsigned i = 0; i != NumVars; ++i) 2128 Vars.push_back(Reader->Record.readSubExpr()); 2129 C->setVarRefs(Vars); 2130 } 2131 2132 void OMPClauseReader::VisitOMPReductionClause(OMPReductionClause *C) { 2133 VisitOMPClauseWithPostUpdate(C); 2134 C->setLParenLoc(Reader->ReadSourceLocation()); 2135 C->setColonLoc(Reader->ReadSourceLocation()); 2136 NestedNameSpecifierLoc NNSL = Reader->Record.readNestedNameSpecifierLoc(); 2137 DeclarationNameInfo DNI; 2138 Reader->ReadDeclarationNameInfo(DNI); 2139 C->setQualifierLoc(NNSL); 2140 C->setNameInfo(DNI); 2141 2142 unsigned NumVars = C->varlist_size(); 2143 SmallVector<Expr *, 16> Vars; 2144 Vars.reserve(NumVars); 2145 for (unsigned i = 0; i != NumVars; ++i) 2146 Vars.push_back(Reader->Record.readSubExpr()); 2147 C->setVarRefs(Vars); 2148 Vars.clear(); 2149 for (unsigned i = 0; i != NumVars; ++i) 2150 Vars.push_back(Reader->Record.readSubExpr()); 2151 C->setPrivates(Vars); 2152 Vars.clear(); 2153 for (unsigned i = 0; i != NumVars; ++i) 2154 Vars.push_back(Reader->Record.readSubExpr()); 2155 C->setLHSExprs(Vars); 2156 Vars.clear(); 2157 for (unsigned i = 0; i != NumVars; ++i) 2158 Vars.push_back(Reader->Record.readSubExpr()); 2159 C->setRHSExprs(Vars); 2160 Vars.clear(); 2161 for (unsigned i = 0; i != NumVars; ++i) 2162 Vars.push_back(Reader->Record.readSubExpr()); 2163 C->setReductionOps(Vars); 2164 } 2165 2166 void OMPClauseReader::VisitOMPTaskReductionClause(OMPTaskReductionClause *C) { 2167 VisitOMPClauseWithPostUpdate(C); 2168 C->setLParenLoc(Reader->ReadSourceLocation()); 2169 C->setColonLoc(Reader->ReadSourceLocation()); 2170 NestedNameSpecifierLoc NNSL = Reader->Record.readNestedNameSpecifierLoc(); 2171 DeclarationNameInfo DNI; 2172 Reader->ReadDeclarationNameInfo(DNI); 2173 C->setQualifierLoc(NNSL); 2174 C->setNameInfo(DNI); 2175 2176 unsigned NumVars = C->varlist_size(); 2177 SmallVector<Expr *, 16> Vars; 2178 Vars.reserve(NumVars); 2179 for (unsigned I = 0; I != NumVars; ++I) 2180 Vars.push_back(Reader->Record.readSubExpr()); 2181 C->setVarRefs(Vars); 2182 Vars.clear(); 2183 for (unsigned I = 0; I != NumVars; ++I) 2184 Vars.push_back(Reader->Record.readSubExpr()); 2185 C->setPrivates(Vars); 2186 Vars.clear(); 2187 for (unsigned I = 0; I != NumVars; ++I) 2188 Vars.push_back(Reader->Record.readSubExpr()); 2189 C->setLHSExprs(Vars); 2190 Vars.clear(); 2191 for (unsigned I = 0; I != NumVars; ++I) 2192 Vars.push_back(Reader->Record.readSubExpr()); 2193 C->setRHSExprs(Vars); 2194 Vars.clear(); 2195 for (unsigned I = 0; I != NumVars; ++I) 2196 Vars.push_back(Reader->Record.readSubExpr()); 2197 C->setReductionOps(Vars); 2198 } 2199 2200 void OMPClauseReader::VisitOMPInReductionClause(OMPInReductionClause *C) { 2201 VisitOMPClauseWithPostUpdate(C); 2202 C->setLParenLoc(Reader->ReadSourceLocation()); 2203 C->setColonLoc(Reader->ReadSourceLocation()); 2204 NestedNameSpecifierLoc NNSL = Reader->Record.readNestedNameSpecifierLoc(); 2205 DeclarationNameInfo DNI; 2206 Reader->ReadDeclarationNameInfo(DNI); 2207 C->setQualifierLoc(NNSL); 2208 C->setNameInfo(DNI); 2209 2210 unsigned NumVars = C->varlist_size(); 2211 SmallVector<Expr *, 16> Vars; 2212 Vars.reserve(NumVars); 2213 for (unsigned I = 0; I != NumVars; ++I) 2214 Vars.push_back(Reader->Record.readSubExpr()); 2215 C->setVarRefs(Vars); 2216 Vars.clear(); 2217 for (unsigned I = 0; I != NumVars; ++I) 2218 Vars.push_back(Reader->Record.readSubExpr()); 2219 C->setPrivates(Vars); 2220 Vars.clear(); 2221 for (unsigned I = 0; I != NumVars; ++I) 2222 Vars.push_back(Reader->Record.readSubExpr()); 2223 C->setLHSExprs(Vars); 2224 Vars.clear(); 2225 for (unsigned I = 0; I != NumVars; ++I) 2226 Vars.push_back(Reader->Record.readSubExpr()); 2227 C->setRHSExprs(Vars); 2228 Vars.clear(); 2229 for (unsigned I = 0; I != NumVars; ++I) 2230 Vars.push_back(Reader->Record.readSubExpr()); 2231 C->setReductionOps(Vars); 2232 Vars.clear(); 2233 for (unsigned I = 0; I != NumVars; ++I) 2234 Vars.push_back(Reader->Record.readSubExpr()); 2235 C->setTaskgroupDescriptors(Vars); 2236 } 2237 2238 void OMPClauseReader::VisitOMPLinearClause(OMPLinearClause *C) { 2239 VisitOMPClauseWithPostUpdate(C); 2240 C->setLParenLoc(Reader->ReadSourceLocation()); 2241 C->setColonLoc(Reader->ReadSourceLocation()); 2242 C->setModifier(static_cast<OpenMPLinearClauseKind>(Reader->Record.readInt())); 2243 C->setModifierLoc(Reader->ReadSourceLocation()); 2244 unsigned NumVars = C->varlist_size(); 2245 SmallVector<Expr *, 16> Vars; 2246 Vars.reserve(NumVars); 2247 for (unsigned i = 0; i != NumVars; ++i) 2248 Vars.push_back(Reader->Record.readSubExpr()); 2249 C->setVarRefs(Vars); 2250 Vars.clear(); 2251 for (unsigned i = 0; i != NumVars; ++i) 2252 Vars.push_back(Reader->Record.readSubExpr()); 2253 C->setPrivates(Vars); 2254 Vars.clear(); 2255 for (unsigned i = 0; i != NumVars; ++i) 2256 Vars.push_back(Reader->Record.readSubExpr()); 2257 C->setInits(Vars); 2258 Vars.clear(); 2259 for (unsigned i = 0; i != NumVars; ++i) 2260 Vars.push_back(Reader->Record.readSubExpr()); 2261 C->setUpdates(Vars); 2262 Vars.clear(); 2263 for (unsigned i = 0; i != NumVars; ++i) 2264 Vars.push_back(Reader->Record.readSubExpr()); 2265 C->setFinals(Vars); 2266 C->setStep(Reader->Record.readSubExpr()); 2267 C->setCalcStep(Reader->Record.readSubExpr()); 2268 } 2269 2270 void OMPClauseReader::VisitOMPAlignedClause(OMPAlignedClause *C) { 2271 C->setLParenLoc(Reader->ReadSourceLocation()); 2272 C->setColonLoc(Reader->ReadSourceLocation()); 2273 unsigned NumVars = C->varlist_size(); 2274 SmallVector<Expr *, 16> Vars; 2275 Vars.reserve(NumVars); 2276 for (unsigned i = 0; i != NumVars; ++i) 2277 Vars.push_back(Reader->Record.readSubExpr()); 2278 C->setVarRefs(Vars); 2279 C->setAlignment(Reader->Record.readSubExpr()); 2280 } 2281 2282 void OMPClauseReader::VisitOMPCopyinClause(OMPCopyinClause *C) { 2283 C->setLParenLoc(Reader->ReadSourceLocation()); 2284 unsigned NumVars = C->varlist_size(); 2285 SmallVector<Expr *, 16> Exprs; 2286 Exprs.reserve(NumVars); 2287 for (unsigned i = 0; i != NumVars; ++i) 2288 Exprs.push_back(Reader->Record.readSubExpr()); 2289 C->setVarRefs(Exprs); 2290 Exprs.clear(); 2291 for (unsigned i = 0; i != NumVars; ++i) 2292 Exprs.push_back(Reader->Record.readSubExpr()); 2293 C->setSourceExprs(Exprs); 2294 Exprs.clear(); 2295 for (unsigned i = 0; i != NumVars; ++i) 2296 Exprs.push_back(Reader->Record.readSubExpr()); 2297 C->setDestinationExprs(Exprs); 2298 Exprs.clear(); 2299 for (unsigned i = 0; i != NumVars; ++i) 2300 Exprs.push_back(Reader->Record.readSubExpr()); 2301 C->setAssignmentOps(Exprs); 2302 } 2303 2304 void OMPClauseReader::VisitOMPCopyprivateClause(OMPCopyprivateClause *C) { 2305 C->setLParenLoc(Reader->ReadSourceLocation()); 2306 unsigned NumVars = C->varlist_size(); 2307 SmallVector<Expr *, 16> Exprs; 2308 Exprs.reserve(NumVars); 2309 for (unsigned i = 0; i != NumVars; ++i) 2310 Exprs.push_back(Reader->Record.readSubExpr()); 2311 C->setVarRefs(Exprs); 2312 Exprs.clear(); 2313 for (unsigned i = 0; i != NumVars; ++i) 2314 Exprs.push_back(Reader->Record.readSubExpr()); 2315 C->setSourceExprs(Exprs); 2316 Exprs.clear(); 2317 for (unsigned i = 0; i != NumVars; ++i) 2318 Exprs.push_back(Reader->Record.readSubExpr()); 2319 C->setDestinationExprs(Exprs); 2320 Exprs.clear(); 2321 for (unsigned i = 0; i != NumVars; ++i) 2322 Exprs.push_back(Reader->Record.readSubExpr()); 2323 C->setAssignmentOps(Exprs); 2324 } 2325 2326 void OMPClauseReader::VisitOMPFlushClause(OMPFlushClause *C) { 2327 C->setLParenLoc(Reader->ReadSourceLocation()); 2328 unsigned NumVars = C->varlist_size(); 2329 SmallVector<Expr *, 16> Vars; 2330 Vars.reserve(NumVars); 2331 for (unsigned i = 0; i != NumVars; ++i) 2332 Vars.push_back(Reader->Record.readSubExpr()); 2333 C->setVarRefs(Vars); 2334 } 2335 2336 void OMPClauseReader::VisitOMPDependClause(OMPDependClause *C) { 2337 C->setLParenLoc(Reader->ReadSourceLocation()); 2338 C->setDependencyKind( 2339 static_cast<OpenMPDependClauseKind>(Reader->Record.readInt())); 2340 C->setDependencyLoc(Reader->ReadSourceLocation()); 2341 C->setColonLoc(Reader->ReadSourceLocation()); 2342 unsigned NumVars = C->varlist_size(); 2343 SmallVector<Expr *, 16> Vars; 2344 Vars.reserve(NumVars); 2345 for (unsigned i = 0; i != NumVars; ++i) 2346 Vars.push_back(Reader->Record.readSubExpr()); 2347 C->setVarRefs(Vars); 2348 C->setCounterValue(Reader->Record.readSubExpr()); 2349 } 2350 2351 void OMPClauseReader::VisitOMPDeviceClause(OMPDeviceClause *C) { 2352 VisitOMPClauseWithPreInit(C); 2353 C->setDevice(Reader->Record.readSubExpr()); 2354 C->setLParenLoc(Reader->ReadSourceLocation()); 2355 } 2356 2357 void OMPClauseReader::VisitOMPMapClause(OMPMapClause *C) { 2358 C->setLParenLoc(Reader->ReadSourceLocation()); 2359 C->setMapTypeModifier( 2360 static_cast<OpenMPMapClauseKind>(Reader->Record.readInt())); 2361 C->setMapType( 2362 static_cast<OpenMPMapClauseKind>(Reader->Record.readInt())); 2363 C->setMapLoc(Reader->ReadSourceLocation()); 2364 C->setColonLoc(Reader->ReadSourceLocation()); 2365 auto NumVars = C->varlist_size(); 2366 auto UniqueDecls = C->getUniqueDeclarationsNum(); 2367 auto TotalLists = C->getTotalComponentListNum(); 2368 auto TotalComponents = C->getTotalComponentsNum(); 2369 2370 SmallVector<Expr *, 16> Vars; 2371 Vars.reserve(NumVars); 2372 for (unsigned i = 0; i != NumVars; ++i) 2373 Vars.push_back(Reader->Record.readSubExpr()); 2374 C->setVarRefs(Vars); 2375 2376 SmallVector<ValueDecl *, 16> Decls; 2377 Decls.reserve(UniqueDecls); 2378 for (unsigned i = 0; i < UniqueDecls; ++i) 2379 Decls.push_back(Reader->Record.readDeclAs<ValueDecl>()); 2380 C->setUniqueDecls(Decls); 2381 2382 SmallVector<unsigned, 16> ListsPerDecl; 2383 ListsPerDecl.reserve(UniqueDecls); 2384 for (unsigned i = 0; i < UniqueDecls; ++i) 2385 ListsPerDecl.push_back(Reader->Record.readInt()); 2386 C->setDeclNumLists(ListsPerDecl); 2387 2388 SmallVector<unsigned, 32> ListSizes; 2389 ListSizes.reserve(TotalLists); 2390 for (unsigned i = 0; i < TotalLists; ++i) 2391 ListSizes.push_back(Reader->Record.readInt()); 2392 C->setComponentListSizes(ListSizes); 2393 2394 SmallVector<OMPClauseMappableExprCommon::MappableComponent, 32> Components; 2395 Components.reserve(TotalComponents); 2396 for (unsigned i = 0; i < TotalComponents; ++i) { 2397 Expr *AssociatedExpr = Reader->Record.readSubExpr(); 2398 ValueDecl *AssociatedDecl = Reader->Record.readDeclAs<ValueDecl>(); 2399 Components.push_back(OMPClauseMappableExprCommon::MappableComponent( 2400 AssociatedExpr, AssociatedDecl)); 2401 } 2402 C->setComponents(Components, ListSizes); 2403 } 2404 2405 void OMPClauseReader::VisitOMPNumTeamsClause(OMPNumTeamsClause *C) { 2406 VisitOMPClauseWithPreInit(C); 2407 C->setNumTeams(Reader->Record.readSubExpr()); 2408 C->setLParenLoc(Reader->ReadSourceLocation()); 2409 } 2410 2411 void OMPClauseReader::VisitOMPThreadLimitClause(OMPThreadLimitClause *C) { 2412 VisitOMPClauseWithPreInit(C); 2413 C->setThreadLimit(Reader->Record.readSubExpr()); 2414 C->setLParenLoc(Reader->ReadSourceLocation()); 2415 } 2416 2417 void OMPClauseReader::VisitOMPPriorityClause(OMPPriorityClause *C) { 2418 C->setPriority(Reader->Record.readSubExpr()); 2419 C->setLParenLoc(Reader->ReadSourceLocation()); 2420 } 2421 2422 void OMPClauseReader::VisitOMPGrainsizeClause(OMPGrainsizeClause *C) { 2423 C->setGrainsize(Reader->Record.readSubExpr()); 2424 C->setLParenLoc(Reader->ReadSourceLocation()); 2425 } 2426 2427 void OMPClauseReader::VisitOMPNumTasksClause(OMPNumTasksClause *C) { 2428 C->setNumTasks(Reader->Record.readSubExpr()); 2429 C->setLParenLoc(Reader->ReadSourceLocation()); 2430 } 2431 2432 void OMPClauseReader::VisitOMPHintClause(OMPHintClause *C) { 2433 C->setHint(Reader->Record.readSubExpr()); 2434 C->setLParenLoc(Reader->ReadSourceLocation()); 2435 } 2436 2437 void OMPClauseReader::VisitOMPDistScheduleClause(OMPDistScheduleClause *C) { 2438 VisitOMPClauseWithPreInit(C); 2439 C->setDistScheduleKind( 2440 static_cast<OpenMPDistScheduleClauseKind>(Reader->Record.readInt())); 2441 C->setChunkSize(Reader->Record.readSubExpr()); 2442 C->setLParenLoc(Reader->ReadSourceLocation()); 2443 C->setDistScheduleKindLoc(Reader->ReadSourceLocation()); 2444 C->setCommaLoc(Reader->ReadSourceLocation()); 2445 } 2446 2447 void OMPClauseReader::VisitOMPDefaultmapClause(OMPDefaultmapClause *C) { 2448 C->setDefaultmapKind( 2449 static_cast<OpenMPDefaultmapClauseKind>(Reader->Record.readInt())); 2450 C->setDefaultmapModifier( 2451 static_cast<OpenMPDefaultmapClauseModifier>(Reader->Record.readInt())); 2452 C->setLParenLoc(Reader->ReadSourceLocation()); 2453 C->setDefaultmapModifierLoc(Reader->ReadSourceLocation()); 2454 C->setDefaultmapKindLoc(Reader->ReadSourceLocation()); 2455 } 2456 2457 void OMPClauseReader::VisitOMPToClause(OMPToClause *C) { 2458 C->setLParenLoc(Reader->ReadSourceLocation()); 2459 auto NumVars = C->varlist_size(); 2460 auto UniqueDecls = C->getUniqueDeclarationsNum(); 2461 auto TotalLists = C->getTotalComponentListNum(); 2462 auto TotalComponents = C->getTotalComponentsNum(); 2463 2464 SmallVector<Expr *, 16> Vars; 2465 Vars.reserve(NumVars); 2466 for (unsigned i = 0; i != NumVars; ++i) 2467 Vars.push_back(Reader->Record.readSubExpr()); 2468 C->setVarRefs(Vars); 2469 2470 SmallVector<ValueDecl *, 16> Decls; 2471 Decls.reserve(UniqueDecls); 2472 for (unsigned i = 0; i < UniqueDecls; ++i) 2473 Decls.push_back(Reader->Record.readDeclAs<ValueDecl>()); 2474 C->setUniqueDecls(Decls); 2475 2476 SmallVector<unsigned, 16> ListsPerDecl; 2477 ListsPerDecl.reserve(UniqueDecls); 2478 for (unsigned i = 0; i < UniqueDecls; ++i) 2479 ListsPerDecl.push_back(Reader->Record.readInt()); 2480 C->setDeclNumLists(ListsPerDecl); 2481 2482 SmallVector<unsigned, 32> ListSizes; 2483 ListSizes.reserve(TotalLists); 2484 for (unsigned i = 0; i < TotalLists; ++i) 2485 ListSizes.push_back(Reader->Record.readInt()); 2486 C->setComponentListSizes(ListSizes); 2487 2488 SmallVector<OMPClauseMappableExprCommon::MappableComponent, 32> Components; 2489 Components.reserve(TotalComponents); 2490 for (unsigned i = 0; i < TotalComponents; ++i) { 2491 Expr *AssociatedExpr = Reader->Record.readSubExpr(); 2492 ValueDecl *AssociatedDecl = Reader->Record.readDeclAs<ValueDecl>(); 2493 Components.push_back(OMPClauseMappableExprCommon::MappableComponent( 2494 AssociatedExpr, AssociatedDecl)); 2495 } 2496 C->setComponents(Components, ListSizes); 2497 } 2498 2499 void OMPClauseReader::VisitOMPFromClause(OMPFromClause *C) { 2500 C->setLParenLoc(Reader->ReadSourceLocation()); 2501 auto NumVars = C->varlist_size(); 2502 auto UniqueDecls = C->getUniqueDeclarationsNum(); 2503 auto TotalLists = C->getTotalComponentListNum(); 2504 auto TotalComponents = C->getTotalComponentsNum(); 2505 2506 SmallVector<Expr *, 16> Vars; 2507 Vars.reserve(NumVars); 2508 for (unsigned i = 0; i != NumVars; ++i) 2509 Vars.push_back(Reader->Record.readSubExpr()); 2510 C->setVarRefs(Vars); 2511 2512 SmallVector<ValueDecl *, 16> Decls; 2513 Decls.reserve(UniqueDecls); 2514 for (unsigned i = 0; i < UniqueDecls; ++i) 2515 Decls.push_back(Reader->Record.readDeclAs<ValueDecl>()); 2516 C->setUniqueDecls(Decls); 2517 2518 SmallVector<unsigned, 16> ListsPerDecl; 2519 ListsPerDecl.reserve(UniqueDecls); 2520 for (unsigned i = 0; i < UniqueDecls; ++i) 2521 ListsPerDecl.push_back(Reader->Record.readInt()); 2522 C->setDeclNumLists(ListsPerDecl); 2523 2524 SmallVector<unsigned, 32> ListSizes; 2525 ListSizes.reserve(TotalLists); 2526 for (unsigned i = 0; i < TotalLists; ++i) 2527 ListSizes.push_back(Reader->Record.readInt()); 2528 C->setComponentListSizes(ListSizes); 2529 2530 SmallVector<OMPClauseMappableExprCommon::MappableComponent, 32> Components; 2531 Components.reserve(TotalComponents); 2532 for (unsigned i = 0; i < TotalComponents; ++i) { 2533 Expr *AssociatedExpr = Reader->Record.readSubExpr(); 2534 ValueDecl *AssociatedDecl = Reader->Record.readDeclAs<ValueDecl>(); 2535 Components.push_back(OMPClauseMappableExprCommon::MappableComponent( 2536 AssociatedExpr, AssociatedDecl)); 2537 } 2538 C->setComponents(Components, ListSizes); 2539 } 2540 2541 void OMPClauseReader::VisitOMPUseDevicePtrClause(OMPUseDevicePtrClause *C) { 2542 C->setLParenLoc(Reader->ReadSourceLocation()); 2543 auto NumVars = C->varlist_size(); 2544 auto UniqueDecls = C->getUniqueDeclarationsNum(); 2545 auto TotalLists = C->getTotalComponentListNum(); 2546 auto TotalComponents = C->getTotalComponentsNum(); 2547 2548 SmallVector<Expr *, 16> Vars; 2549 Vars.reserve(NumVars); 2550 for (unsigned i = 0; i != NumVars; ++i) 2551 Vars.push_back(Reader->Record.readSubExpr()); 2552 C->setVarRefs(Vars); 2553 Vars.clear(); 2554 for (unsigned i = 0; i != NumVars; ++i) 2555 Vars.push_back(Reader->Record.readSubExpr()); 2556 C->setPrivateCopies(Vars); 2557 Vars.clear(); 2558 for (unsigned i = 0; i != NumVars; ++i) 2559 Vars.push_back(Reader->Record.readSubExpr()); 2560 C->setInits(Vars); 2561 2562 SmallVector<ValueDecl *, 16> Decls; 2563 Decls.reserve(UniqueDecls); 2564 for (unsigned i = 0; i < UniqueDecls; ++i) 2565 Decls.push_back(Reader->Record.readDeclAs<ValueDecl>()); 2566 C->setUniqueDecls(Decls); 2567 2568 SmallVector<unsigned, 16> ListsPerDecl; 2569 ListsPerDecl.reserve(UniqueDecls); 2570 for (unsigned i = 0; i < UniqueDecls; ++i) 2571 ListsPerDecl.push_back(Reader->Record.readInt()); 2572 C->setDeclNumLists(ListsPerDecl); 2573 2574 SmallVector<unsigned, 32> ListSizes; 2575 ListSizes.reserve(TotalLists); 2576 for (unsigned i = 0; i < TotalLists; ++i) 2577 ListSizes.push_back(Reader->Record.readInt()); 2578 C->setComponentListSizes(ListSizes); 2579 2580 SmallVector<OMPClauseMappableExprCommon::MappableComponent, 32> Components; 2581 Components.reserve(TotalComponents); 2582 for (unsigned i = 0; i < TotalComponents; ++i) { 2583 Expr *AssociatedExpr = Reader->Record.readSubExpr(); 2584 ValueDecl *AssociatedDecl = Reader->Record.readDeclAs<ValueDecl>(); 2585 Components.push_back(OMPClauseMappableExprCommon::MappableComponent( 2586 AssociatedExpr, AssociatedDecl)); 2587 } 2588 C->setComponents(Components, ListSizes); 2589 } 2590 2591 void OMPClauseReader::VisitOMPIsDevicePtrClause(OMPIsDevicePtrClause *C) { 2592 C->setLParenLoc(Reader->ReadSourceLocation()); 2593 auto NumVars = C->varlist_size(); 2594 auto UniqueDecls = C->getUniqueDeclarationsNum(); 2595 auto TotalLists = C->getTotalComponentListNum(); 2596 auto TotalComponents = C->getTotalComponentsNum(); 2597 2598 SmallVector<Expr *, 16> Vars; 2599 Vars.reserve(NumVars); 2600 for (unsigned i = 0; i != NumVars; ++i) 2601 Vars.push_back(Reader->Record.readSubExpr()); 2602 C->setVarRefs(Vars); 2603 Vars.clear(); 2604 2605 SmallVector<ValueDecl *, 16> Decls; 2606 Decls.reserve(UniqueDecls); 2607 for (unsigned i = 0; i < UniqueDecls; ++i) 2608 Decls.push_back(Reader->Record.readDeclAs<ValueDecl>()); 2609 C->setUniqueDecls(Decls); 2610 2611 SmallVector<unsigned, 16> ListsPerDecl; 2612 ListsPerDecl.reserve(UniqueDecls); 2613 for (unsigned i = 0; i < UniqueDecls; ++i) 2614 ListsPerDecl.push_back(Reader->Record.readInt()); 2615 C->setDeclNumLists(ListsPerDecl); 2616 2617 SmallVector<unsigned, 32> ListSizes; 2618 ListSizes.reserve(TotalLists); 2619 for (unsigned i = 0; i < TotalLists; ++i) 2620 ListSizes.push_back(Reader->Record.readInt()); 2621 C->setComponentListSizes(ListSizes); 2622 2623 SmallVector<OMPClauseMappableExprCommon::MappableComponent, 32> Components; 2624 Components.reserve(TotalComponents); 2625 for (unsigned i = 0; i < TotalComponents; ++i) { 2626 Expr *AssociatedExpr = Reader->Record.readSubExpr(); 2627 ValueDecl *AssociatedDecl = Reader->Record.readDeclAs<ValueDecl>(); 2628 Components.push_back(OMPClauseMappableExprCommon::MappableComponent( 2629 AssociatedExpr, AssociatedDecl)); 2630 } 2631 C->setComponents(Components, ListSizes); 2632 } 2633 2634 //===----------------------------------------------------------------------===// 2635 // OpenMP Directives. 2636 //===----------------------------------------------------------------------===// 2637 void ASTStmtReader::VisitOMPExecutableDirective(OMPExecutableDirective *E) { 2638 E->setLocStart(ReadSourceLocation()); 2639 E->setLocEnd(ReadSourceLocation()); 2640 OMPClauseReader ClauseReader(this, Record); 2641 SmallVector<OMPClause *, 5> Clauses; 2642 for (unsigned i = 0; i < E->getNumClauses(); ++i) 2643 Clauses.push_back(ClauseReader.readClause()); 2644 E->setClauses(Clauses); 2645 if (E->hasAssociatedStmt()) 2646 E->setAssociatedStmt(Record.readSubStmt()); 2647 } 2648 2649 void ASTStmtReader::VisitOMPLoopDirective(OMPLoopDirective *D) { 2650 VisitStmt(D); 2651 // Two fields (NumClauses and CollapsedNum) were read in ReadStmtFromStream. 2652 Record.skipInts(2); 2653 VisitOMPExecutableDirective(D); 2654 D->setIterationVariable(Record.readSubExpr()); 2655 D->setLastIteration(Record.readSubExpr()); 2656 D->setCalcLastIteration(Record.readSubExpr()); 2657 D->setPreCond(Record.readSubExpr()); 2658 D->setCond(Record.readSubExpr()); 2659 D->setInit(Record.readSubExpr()); 2660 D->setInc(Record.readSubExpr()); 2661 D->setPreInits(Record.readSubStmt()); 2662 if (isOpenMPWorksharingDirective(D->getDirectiveKind()) || 2663 isOpenMPTaskLoopDirective(D->getDirectiveKind()) || 2664 isOpenMPDistributeDirective(D->getDirectiveKind())) { 2665 D->setIsLastIterVariable(Record.readSubExpr()); 2666 D->setLowerBoundVariable(Record.readSubExpr()); 2667 D->setUpperBoundVariable(Record.readSubExpr()); 2668 D->setStrideVariable(Record.readSubExpr()); 2669 D->setEnsureUpperBound(Record.readSubExpr()); 2670 D->setNextLowerBound(Record.readSubExpr()); 2671 D->setNextUpperBound(Record.readSubExpr()); 2672 D->setNumIterations(Record.readSubExpr()); 2673 } 2674 if (isOpenMPLoopBoundSharingDirective(D->getDirectiveKind())) { 2675 D->setPrevLowerBoundVariable(Record.readSubExpr()); 2676 D->setPrevUpperBoundVariable(Record.readSubExpr()); 2677 D->setDistInc(Record.readSubExpr()); 2678 D->setPrevEnsureUpperBound(Record.readSubExpr()); 2679 D->setCombinedLowerBoundVariable(Record.readSubExpr()); 2680 D->setCombinedUpperBoundVariable(Record.readSubExpr()); 2681 D->setCombinedEnsureUpperBound(Record.readSubExpr()); 2682 D->setCombinedInit(Record.readSubExpr()); 2683 D->setCombinedCond(Record.readSubExpr()); 2684 D->setCombinedNextLowerBound(Record.readSubExpr()); 2685 D->setCombinedNextUpperBound(Record.readSubExpr()); 2686 } 2687 SmallVector<Expr *, 4> Sub; 2688 unsigned CollapsedNum = D->getCollapsedNumber(); 2689 Sub.reserve(CollapsedNum); 2690 for (unsigned i = 0; i < CollapsedNum; ++i) 2691 Sub.push_back(Record.readSubExpr()); 2692 D->setCounters(Sub); 2693 Sub.clear(); 2694 for (unsigned i = 0; i < CollapsedNum; ++i) 2695 Sub.push_back(Record.readSubExpr()); 2696 D->setPrivateCounters(Sub); 2697 Sub.clear(); 2698 for (unsigned i = 0; i < CollapsedNum; ++i) 2699 Sub.push_back(Record.readSubExpr()); 2700 D->setInits(Sub); 2701 Sub.clear(); 2702 for (unsigned i = 0; i < CollapsedNum; ++i) 2703 Sub.push_back(Record.readSubExpr()); 2704 D->setUpdates(Sub); 2705 Sub.clear(); 2706 for (unsigned i = 0; i < CollapsedNum; ++i) 2707 Sub.push_back(Record.readSubExpr()); 2708 D->setFinals(Sub); 2709 } 2710 2711 void ASTStmtReader::VisitOMPParallelDirective(OMPParallelDirective *D) { 2712 VisitStmt(D); 2713 // The NumClauses field was read in ReadStmtFromStream. 2714 Record.skipInts(1); 2715 VisitOMPExecutableDirective(D); 2716 D->setHasCancel(Record.readInt()); 2717 } 2718 2719 void ASTStmtReader::VisitOMPSimdDirective(OMPSimdDirective *D) { 2720 VisitOMPLoopDirective(D); 2721 } 2722 2723 void ASTStmtReader::VisitOMPForDirective(OMPForDirective *D) { 2724 VisitOMPLoopDirective(D); 2725 D->setHasCancel(Record.readInt()); 2726 } 2727 2728 void ASTStmtReader::VisitOMPForSimdDirective(OMPForSimdDirective *D) { 2729 VisitOMPLoopDirective(D); 2730 } 2731 2732 void ASTStmtReader::VisitOMPSectionsDirective(OMPSectionsDirective *D) { 2733 VisitStmt(D); 2734 // The NumClauses field was read in ReadStmtFromStream. 2735 Record.skipInts(1); 2736 VisitOMPExecutableDirective(D); 2737 D->setHasCancel(Record.readInt()); 2738 } 2739 2740 void ASTStmtReader::VisitOMPSectionDirective(OMPSectionDirective *D) { 2741 VisitStmt(D); 2742 VisitOMPExecutableDirective(D); 2743 D->setHasCancel(Record.readInt()); 2744 } 2745 2746 void ASTStmtReader::VisitOMPSingleDirective(OMPSingleDirective *D) { 2747 VisitStmt(D); 2748 // The NumClauses field was read in ReadStmtFromStream. 2749 Record.skipInts(1); 2750 VisitOMPExecutableDirective(D); 2751 } 2752 2753 void ASTStmtReader::VisitOMPMasterDirective(OMPMasterDirective *D) { 2754 VisitStmt(D); 2755 VisitOMPExecutableDirective(D); 2756 } 2757 2758 void ASTStmtReader::VisitOMPCriticalDirective(OMPCriticalDirective *D) { 2759 VisitStmt(D); 2760 // The NumClauses field was read in ReadStmtFromStream. 2761 Record.skipInts(1); 2762 VisitOMPExecutableDirective(D); 2763 ReadDeclarationNameInfo(D->DirName); 2764 } 2765 2766 void ASTStmtReader::VisitOMPParallelForDirective(OMPParallelForDirective *D) { 2767 VisitOMPLoopDirective(D); 2768 D->setHasCancel(Record.readInt()); 2769 } 2770 2771 void ASTStmtReader::VisitOMPParallelForSimdDirective( 2772 OMPParallelForSimdDirective *D) { 2773 VisitOMPLoopDirective(D); 2774 } 2775 2776 void ASTStmtReader::VisitOMPParallelSectionsDirective( 2777 OMPParallelSectionsDirective *D) { 2778 VisitStmt(D); 2779 // The NumClauses field was read in ReadStmtFromStream. 2780 Record.skipInts(1); 2781 VisitOMPExecutableDirective(D); 2782 D->setHasCancel(Record.readInt()); 2783 } 2784 2785 void ASTStmtReader::VisitOMPTaskDirective(OMPTaskDirective *D) { 2786 VisitStmt(D); 2787 // The NumClauses field was read in ReadStmtFromStream. 2788 Record.skipInts(1); 2789 VisitOMPExecutableDirective(D); 2790 D->setHasCancel(Record.readInt()); 2791 } 2792 2793 void ASTStmtReader::VisitOMPTaskyieldDirective(OMPTaskyieldDirective *D) { 2794 VisitStmt(D); 2795 VisitOMPExecutableDirective(D); 2796 } 2797 2798 void ASTStmtReader::VisitOMPBarrierDirective(OMPBarrierDirective *D) { 2799 VisitStmt(D); 2800 VisitOMPExecutableDirective(D); 2801 } 2802 2803 void ASTStmtReader::VisitOMPTaskwaitDirective(OMPTaskwaitDirective *D) { 2804 VisitStmt(D); 2805 VisitOMPExecutableDirective(D); 2806 } 2807 2808 void ASTStmtReader::VisitOMPTaskgroupDirective(OMPTaskgroupDirective *D) { 2809 VisitStmt(D); 2810 // The NumClauses field was read in ReadStmtFromStream. 2811 Record.skipInts(1); 2812 VisitOMPExecutableDirective(D); 2813 D->setReductionRef(Record.readSubExpr()); 2814 } 2815 2816 void ASTStmtReader::VisitOMPFlushDirective(OMPFlushDirective *D) { 2817 VisitStmt(D); 2818 // The NumClauses field was read in ReadStmtFromStream. 2819 Record.skipInts(1); 2820 VisitOMPExecutableDirective(D); 2821 } 2822 2823 void ASTStmtReader::VisitOMPOrderedDirective(OMPOrderedDirective *D) { 2824 VisitStmt(D); 2825 // The NumClauses field was read in ReadStmtFromStream. 2826 Record.skipInts(1); 2827 VisitOMPExecutableDirective(D); 2828 } 2829 2830 void ASTStmtReader::VisitOMPAtomicDirective(OMPAtomicDirective *D) { 2831 VisitStmt(D); 2832 // The NumClauses field was read in ReadStmtFromStream. 2833 Record.skipInts(1); 2834 VisitOMPExecutableDirective(D); 2835 D->setX(Record.readSubExpr()); 2836 D->setV(Record.readSubExpr()); 2837 D->setExpr(Record.readSubExpr()); 2838 D->setUpdateExpr(Record.readSubExpr()); 2839 D->IsXLHSInRHSPart = Record.readInt() != 0; 2840 D->IsPostfixUpdate = Record.readInt() != 0; 2841 } 2842 2843 void ASTStmtReader::VisitOMPTargetDirective(OMPTargetDirective *D) { 2844 VisitStmt(D); 2845 // The NumClauses field was read in ReadStmtFromStream. 2846 Record.skipInts(1); 2847 VisitOMPExecutableDirective(D); 2848 } 2849 2850 void ASTStmtReader::VisitOMPTargetDataDirective(OMPTargetDataDirective *D) { 2851 VisitStmt(D); 2852 Record.skipInts(1); 2853 VisitOMPExecutableDirective(D); 2854 } 2855 2856 void ASTStmtReader::VisitOMPTargetEnterDataDirective( 2857 OMPTargetEnterDataDirective *D) { 2858 VisitStmt(D); 2859 Record.skipInts(1); 2860 VisitOMPExecutableDirective(D); 2861 } 2862 2863 void ASTStmtReader::VisitOMPTargetExitDataDirective( 2864 OMPTargetExitDataDirective *D) { 2865 VisitStmt(D); 2866 Record.skipInts(1); 2867 VisitOMPExecutableDirective(D); 2868 } 2869 2870 void ASTStmtReader::VisitOMPTargetParallelDirective( 2871 OMPTargetParallelDirective *D) { 2872 VisitStmt(D); 2873 Record.skipInts(1); 2874 VisitOMPExecutableDirective(D); 2875 } 2876 2877 void ASTStmtReader::VisitOMPTargetParallelForDirective( 2878 OMPTargetParallelForDirective *D) { 2879 VisitOMPLoopDirective(D); 2880 D->setHasCancel(Record.readInt()); 2881 } 2882 2883 void ASTStmtReader::VisitOMPTeamsDirective(OMPTeamsDirective *D) { 2884 VisitStmt(D); 2885 // The NumClauses field was read in ReadStmtFromStream. 2886 Record.skipInts(1); 2887 VisitOMPExecutableDirective(D); 2888 } 2889 2890 void ASTStmtReader::VisitOMPCancellationPointDirective( 2891 OMPCancellationPointDirective *D) { 2892 VisitStmt(D); 2893 VisitOMPExecutableDirective(D); 2894 D->setCancelRegion(static_cast<OpenMPDirectiveKind>(Record.readInt())); 2895 } 2896 2897 void ASTStmtReader::VisitOMPCancelDirective(OMPCancelDirective *D) { 2898 VisitStmt(D); 2899 // The NumClauses field was read in ReadStmtFromStream. 2900 Record.skipInts(1); 2901 VisitOMPExecutableDirective(D); 2902 D->setCancelRegion(static_cast<OpenMPDirectiveKind>(Record.readInt())); 2903 } 2904 2905 void ASTStmtReader::VisitOMPTaskLoopDirective(OMPTaskLoopDirective *D) { 2906 VisitOMPLoopDirective(D); 2907 } 2908 2909 void ASTStmtReader::VisitOMPTaskLoopSimdDirective(OMPTaskLoopSimdDirective *D) { 2910 VisitOMPLoopDirective(D); 2911 } 2912 2913 void ASTStmtReader::VisitOMPDistributeDirective(OMPDistributeDirective *D) { 2914 VisitOMPLoopDirective(D); 2915 } 2916 2917 void ASTStmtReader::VisitOMPTargetUpdateDirective(OMPTargetUpdateDirective *D) { 2918 VisitStmt(D); 2919 Record.skipInts(1); 2920 VisitOMPExecutableDirective(D); 2921 } 2922 void ASTStmtReader::VisitOMPDistributeParallelForDirective( 2923 OMPDistributeParallelForDirective *D) { 2924 VisitOMPLoopDirective(D); 2925 D->setHasCancel(Record.readInt()); 2926 } 2927 2928 void ASTStmtReader::VisitOMPDistributeParallelForSimdDirective( 2929 OMPDistributeParallelForSimdDirective *D) { 2930 VisitOMPLoopDirective(D); 2931 } 2932 2933 void ASTStmtReader::VisitOMPDistributeSimdDirective( 2934 OMPDistributeSimdDirective *D) { 2935 VisitOMPLoopDirective(D); 2936 } 2937 2938 void ASTStmtReader::VisitOMPTargetParallelForSimdDirective( 2939 OMPTargetParallelForSimdDirective *D) { 2940 VisitOMPLoopDirective(D); 2941 } 2942 2943 void ASTStmtReader::VisitOMPTargetSimdDirective(OMPTargetSimdDirective *D) { 2944 VisitOMPLoopDirective(D); 2945 } 2946 2947 void ASTStmtReader::VisitOMPTeamsDistributeDirective( 2948 OMPTeamsDistributeDirective *D) { 2949 VisitOMPLoopDirective(D); 2950 } 2951 2952 void ASTStmtReader::VisitOMPTeamsDistributeSimdDirective( 2953 OMPTeamsDistributeSimdDirective *D) { 2954 VisitOMPLoopDirective(D); 2955 } 2956 2957 void ASTStmtReader::VisitOMPTeamsDistributeParallelForSimdDirective( 2958 OMPTeamsDistributeParallelForSimdDirective *D) { 2959 VisitOMPLoopDirective(D); 2960 } 2961 2962 void ASTStmtReader::VisitOMPTeamsDistributeParallelForDirective( 2963 OMPTeamsDistributeParallelForDirective *D) { 2964 VisitOMPLoopDirective(D); 2965 D->setHasCancel(Record.readInt()); 2966 } 2967 2968 void ASTStmtReader::VisitOMPTargetTeamsDirective(OMPTargetTeamsDirective *D) { 2969 VisitStmt(D); 2970 // The NumClauses field was read in ReadStmtFromStream. 2971 Record.skipInts(1); 2972 VisitOMPExecutableDirective(D); 2973 } 2974 2975 void ASTStmtReader::VisitOMPTargetTeamsDistributeDirective( 2976 OMPTargetTeamsDistributeDirective *D) { 2977 VisitOMPLoopDirective(D); 2978 } 2979 2980 void ASTStmtReader::VisitOMPTargetTeamsDistributeParallelForDirective( 2981 OMPTargetTeamsDistributeParallelForDirective *D) { 2982 VisitOMPLoopDirective(D); 2983 D->setHasCancel(Record.readInt()); 2984 } 2985 2986 void ASTStmtReader::VisitOMPTargetTeamsDistributeParallelForSimdDirective( 2987 OMPTargetTeamsDistributeParallelForSimdDirective *D) { 2988 VisitOMPLoopDirective(D); 2989 } 2990 2991 void ASTStmtReader::VisitOMPTargetTeamsDistributeSimdDirective( 2992 OMPTargetTeamsDistributeSimdDirective *D) { 2993 VisitOMPLoopDirective(D); 2994 } 2995 2996 //===----------------------------------------------------------------------===// 2997 // ASTReader Implementation 2998 //===----------------------------------------------------------------------===// 2999 3000 Stmt *ASTReader::ReadStmt(ModuleFile &F) { 3001 switch (ReadingKind) { 3002 case Read_None: 3003 llvm_unreachable("should not call this when not reading anything"); 3004 case Read_Decl: 3005 case Read_Type: 3006 return ReadStmtFromStream(F); 3007 case Read_Stmt: 3008 return ReadSubStmt(); 3009 } 3010 3011 llvm_unreachable("ReadingKind not set ?"); 3012 } 3013 3014 Expr *ASTReader::ReadExpr(ModuleFile &F) { 3015 return cast_or_null<Expr>(ReadStmt(F)); 3016 } 3017 3018 Expr *ASTReader::ReadSubExpr() { 3019 return cast_or_null<Expr>(ReadSubStmt()); 3020 } 3021 3022 // Within the bitstream, expressions are stored in Reverse Polish 3023 // Notation, with each of the subexpressions preceding the 3024 // expression they are stored in. Subexpressions are stored from last to first. 3025 // To evaluate expressions, we continue reading expressions and placing them on 3026 // the stack, with expressions having operands removing those operands from the 3027 // stack. Evaluation terminates when we see a STMT_STOP record, and 3028 // the single remaining expression on the stack is our result. 3029 Stmt *ASTReader::ReadStmtFromStream(ModuleFile &F) { 3030 3031 ReadingKindTracker ReadingKind(Read_Stmt, *this); 3032 llvm::BitstreamCursor &Cursor = F.DeclsCursor; 3033 3034 // Map of offset to previously deserialized stmt. The offset points 3035 // just after the stmt record. 3036 llvm::DenseMap<uint64_t, Stmt *> StmtEntries; 3037 3038 #ifndef NDEBUG 3039 unsigned PrevNumStmts = StmtStack.size(); 3040 #endif 3041 3042 ASTRecordReader Record(*this, F); 3043 ASTStmtReader Reader(Record, Cursor); 3044 Stmt::EmptyShell Empty; 3045 3046 while (true) { 3047 llvm::BitstreamEntry Entry = Cursor.advanceSkippingSubblocks(); 3048 3049 switch (Entry.Kind) { 3050 case llvm::BitstreamEntry::SubBlock: // Handled for us already. 3051 case llvm::BitstreamEntry::Error: 3052 Error("malformed block record in AST file"); 3053 return nullptr; 3054 case llvm::BitstreamEntry::EndBlock: 3055 goto Done; 3056 case llvm::BitstreamEntry::Record: 3057 // The interesting case. 3058 break; 3059 } 3060 3061 ASTContext &Context = getContext(); 3062 Stmt *S = nullptr; 3063 bool Finished = false; 3064 bool IsStmtReference = false; 3065 switch ((StmtCode)Record.readRecord(Cursor, Entry.ID)) { 3066 case STMT_STOP: 3067 Finished = true; 3068 break; 3069 3070 case STMT_REF_PTR: 3071 IsStmtReference = true; 3072 assert(StmtEntries.find(Record[0]) != StmtEntries.end() && 3073 "No stmt was recorded for this offset reference!"); 3074 S = StmtEntries[Record.readInt()]; 3075 break; 3076 3077 case STMT_NULL_PTR: 3078 S = nullptr; 3079 break; 3080 3081 case STMT_NULL: 3082 S = new (Context) NullStmt(Empty); 3083 break; 3084 3085 case STMT_COMPOUND: 3086 S = CompoundStmt::CreateEmpty( 3087 Context, /*NumStmts=*/Record[ASTStmtReader::NumStmtFields]); 3088 break; 3089 3090 case STMT_CASE: 3091 S = new (Context) CaseStmt(Empty); 3092 break; 3093 3094 case STMT_DEFAULT: 3095 S = new (Context) DefaultStmt(Empty); 3096 break; 3097 3098 case STMT_LABEL: 3099 S = new (Context) LabelStmt(Empty); 3100 break; 3101 3102 case STMT_ATTRIBUTED: 3103 S = AttributedStmt::CreateEmpty( 3104 Context, 3105 /*NumAttrs*/Record[ASTStmtReader::NumStmtFields]); 3106 break; 3107 3108 case STMT_IF: 3109 S = new (Context) IfStmt(Empty); 3110 break; 3111 3112 case STMT_SWITCH: 3113 S = new (Context) SwitchStmt(Empty); 3114 break; 3115 3116 case STMT_WHILE: 3117 S = new (Context) WhileStmt(Empty); 3118 break; 3119 3120 case STMT_DO: 3121 S = new (Context) DoStmt(Empty); 3122 break; 3123 3124 case STMT_FOR: 3125 S = new (Context) ForStmt(Empty); 3126 break; 3127 3128 case STMT_GOTO: 3129 S = new (Context) GotoStmt(Empty); 3130 break; 3131 3132 case STMT_INDIRECT_GOTO: 3133 S = new (Context) IndirectGotoStmt(Empty); 3134 break; 3135 3136 case STMT_CONTINUE: 3137 S = new (Context) ContinueStmt(Empty); 3138 break; 3139 3140 case STMT_BREAK: 3141 S = new (Context) BreakStmt(Empty); 3142 break; 3143 3144 case STMT_RETURN: 3145 S = new (Context) ReturnStmt(Empty); 3146 break; 3147 3148 case STMT_DECL: 3149 S = new (Context) DeclStmt(Empty); 3150 break; 3151 3152 case STMT_GCCASM: 3153 S = new (Context) GCCAsmStmt(Empty); 3154 break; 3155 3156 case STMT_MSASM: 3157 S = new (Context) MSAsmStmt(Empty); 3158 break; 3159 3160 case STMT_CAPTURED: 3161 S = CapturedStmt::CreateDeserialized(Context, 3162 Record[ASTStmtReader::NumStmtFields]); 3163 break; 3164 3165 case EXPR_PREDEFINED: 3166 S = new (Context) PredefinedExpr(Empty); 3167 break; 3168 3169 case EXPR_DECL_REF: 3170 S = DeclRefExpr::CreateEmpty( 3171 Context, 3172 /*HasQualifier=*/Record[ASTStmtReader::NumExprFields], 3173 /*HasFoundDecl=*/Record[ASTStmtReader::NumExprFields + 1], 3174 /*HasTemplateKWAndArgsInfo=*/Record[ASTStmtReader::NumExprFields + 2], 3175 /*NumTemplateArgs=*/Record[ASTStmtReader::NumExprFields + 2] ? 3176 Record[ASTStmtReader::NumExprFields + 5] : 0); 3177 break; 3178 3179 case EXPR_INTEGER_LITERAL: 3180 S = IntegerLiteral::Create(Context, Empty); 3181 break; 3182 3183 case EXPR_FLOATING_LITERAL: 3184 S = FloatingLiteral::Create(Context, Empty); 3185 break; 3186 3187 case EXPR_IMAGINARY_LITERAL: 3188 S = new (Context) ImaginaryLiteral(Empty); 3189 break; 3190 3191 case EXPR_STRING_LITERAL: 3192 S = StringLiteral::CreateEmpty(Context, 3193 Record[ASTStmtReader::NumExprFields + 1]); 3194 break; 3195 3196 case EXPR_CHARACTER_LITERAL: 3197 S = new (Context) CharacterLiteral(Empty); 3198 break; 3199 3200 case EXPR_PAREN: 3201 S = new (Context) ParenExpr(Empty); 3202 break; 3203 3204 case EXPR_PAREN_LIST: 3205 S = new (Context) ParenListExpr(Empty); 3206 break; 3207 3208 case EXPR_UNARY_OPERATOR: 3209 S = new (Context) UnaryOperator(Empty); 3210 break; 3211 3212 case EXPR_OFFSETOF: 3213 S = OffsetOfExpr::CreateEmpty(Context, 3214 Record[ASTStmtReader::NumExprFields], 3215 Record[ASTStmtReader::NumExprFields + 1]); 3216 break; 3217 3218 case EXPR_SIZEOF_ALIGN_OF: 3219 S = new (Context) UnaryExprOrTypeTraitExpr(Empty); 3220 break; 3221 3222 case EXPR_ARRAY_SUBSCRIPT: 3223 S = new (Context) ArraySubscriptExpr(Empty); 3224 break; 3225 3226 case EXPR_OMP_ARRAY_SECTION: 3227 S = new (Context) OMPArraySectionExpr(Empty); 3228 break; 3229 3230 case EXPR_CALL: 3231 S = new (Context) CallExpr(Context, Stmt::CallExprClass, Empty); 3232 break; 3233 3234 case EXPR_MEMBER: { 3235 // We load everything here and fully initialize it at creation. 3236 // That way we can use MemberExpr::Create and don't have to duplicate its 3237 // logic with a MemberExpr::CreateEmpty. 3238 3239 assert(Record.getIdx() == 0); 3240 NestedNameSpecifierLoc QualifierLoc; 3241 if (Record.readInt()) { // HasQualifier. 3242 QualifierLoc = Record.readNestedNameSpecifierLoc(); 3243 } 3244 3245 SourceLocation TemplateKWLoc; 3246 TemplateArgumentListInfo ArgInfo; 3247 bool HasTemplateKWAndArgsInfo = Record.readInt(); 3248 if (HasTemplateKWAndArgsInfo) { 3249 TemplateKWLoc = Record.readSourceLocation(); 3250 unsigned NumTemplateArgs = Record.readInt(); 3251 ArgInfo.setLAngleLoc(Record.readSourceLocation()); 3252 ArgInfo.setRAngleLoc(Record.readSourceLocation()); 3253 for (unsigned i = 0; i != NumTemplateArgs; ++i) 3254 ArgInfo.addArgument(Record.readTemplateArgumentLoc()); 3255 } 3256 3257 bool HadMultipleCandidates = Record.readInt(); 3258 3259 NamedDecl *FoundD = Record.readDeclAs<NamedDecl>(); 3260 AccessSpecifier AS = (AccessSpecifier)Record.readInt(); 3261 DeclAccessPair FoundDecl = DeclAccessPair::make(FoundD, AS); 3262 3263 QualType T = Record.readType(); 3264 ExprValueKind VK = static_cast<ExprValueKind>(Record.readInt()); 3265 ExprObjectKind OK = static_cast<ExprObjectKind>(Record.readInt()); 3266 Expr *Base = ReadSubExpr(); 3267 ValueDecl *MemberD = Record.readDeclAs<ValueDecl>(); 3268 SourceLocation MemberLoc = Record.readSourceLocation(); 3269 DeclarationNameInfo MemberNameInfo(MemberD->getDeclName(), MemberLoc); 3270 bool IsArrow = Record.readInt(); 3271 SourceLocation OperatorLoc = Record.readSourceLocation(); 3272 3273 S = MemberExpr::Create(Context, Base, IsArrow, OperatorLoc, QualifierLoc, 3274 TemplateKWLoc, MemberD, FoundDecl, MemberNameInfo, 3275 HasTemplateKWAndArgsInfo ? &ArgInfo : nullptr, T, 3276 VK, OK); 3277 Record.readDeclarationNameLoc(cast<MemberExpr>(S)->MemberDNLoc, 3278 MemberD->getDeclName()); 3279 if (HadMultipleCandidates) 3280 cast<MemberExpr>(S)->setHadMultipleCandidates(true); 3281 break; 3282 } 3283 3284 case EXPR_BINARY_OPERATOR: 3285 S = new (Context) BinaryOperator(Empty); 3286 break; 3287 3288 case EXPR_COMPOUND_ASSIGN_OPERATOR: 3289 S = new (Context) CompoundAssignOperator(Empty); 3290 break; 3291 3292 case EXPR_CONDITIONAL_OPERATOR: 3293 S = new (Context) ConditionalOperator(Empty); 3294 break; 3295 3296 case EXPR_BINARY_CONDITIONAL_OPERATOR: 3297 S = new (Context) BinaryConditionalOperator(Empty); 3298 break; 3299 3300 case EXPR_IMPLICIT_CAST: 3301 S = ImplicitCastExpr::CreateEmpty(Context, 3302 /*PathSize*/ Record[ASTStmtReader::NumExprFields]); 3303 break; 3304 3305 case EXPR_CSTYLE_CAST: 3306 S = CStyleCastExpr::CreateEmpty(Context, 3307 /*PathSize*/ Record[ASTStmtReader::NumExprFields]); 3308 break; 3309 3310 case EXPR_COMPOUND_LITERAL: 3311 S = new (Context) CompoundLiteralExpr(Empty); 3312 break; 3313 3314 case EXPR_EXT_VECTOR_ELEMENT: 3315 S = new (Context) ExtVectorElementExpr(Empty); 3316 break; 3317 3318 case EXPR_INIT_LIST: 3319 S = new (Context) InitListExpr(Empty); 3320 break; 3321 3322 case EXPR_DESIGNATED_INIT: 3323 S = DesignatedInitExpr::CreateEmpty(Context, 3324 Record[ASTStmtReader::NumExprFields] - 1); 3325 3326 break; 3327 3328 case EXPR_DESIGNATED_INIT_UPDATE: 3329 S = new (Context) DesignatedInitUpdateExpr(Empty); 3330 break; 3331 3332 case EXPR_IMPLICIT_VALUE_INIT: 3333 S = new (Context) ImplicitValueInitExpr(Empty); 3334 break; 3335 3336 case EXPR_NO_INIT: 3337 S = new (Context) NoInitExpr(Empty); 3338 break; 3339 3340 case EXPR_ARRAY_INIT_LOOP: 3341 S = new (Context) ArrayInitLoopExpr(Empty); 3342 break; 3343 3344 case EXPR_ARRAY_INIT_INDEX: 3345 S = new (Context) ArrayInitIndexExpr(Empty); 3346 break; 3347 3348 case EXPR_VA_ARG: 3349 S = new (Context) VAArgExpr(Empty); 3350 break; 3351 3352 case EXPR_ADDR_LABEL: 3353 S = new (Context) AddrLabelExpr(Empty); 3354 break; 3355 3356 case EXPR_STMT: 3357 S = new (Context) StmtExpr(Empty); 3358 break; 3359 3360 case EXPR_CHOOSE: 3361 S = new (Context) ChooseExpr(Empty); 3362 break; 3363 3364 case EXPR_GNU_NULL: 3365 S = new (Context) GNUNullExpr(Empty); 3366 break; 3367 3368 case EXPR_SHUFFLE_VECTOR: 3369 S = new (Context) ShuffleVectorExpr(Empty); 3370 break; 3371 3372 case EXPR_CONVERT_VECTOR: 3373 S = new (Context) ConvertVectorExpr(Empty); 3374 break; 3375 3376 case EXPR_BLOCK: 3377 S = new (Context) BlockExpr(Empty); 3378 break; 3379 3380 case EXPR_GENERIC_SELECTION: 3381 S = new (Context) GenericSelectionExpr(Empty); 3382 break; 3383 3384 case EXPR_OBJC_STRING_LITERAL: 3385 S = new (Context) ObjCStringLiteral(Empty); 3386 break; 3387 case EXPR_OBJC_BOXED_EXPRESSION: 3388 S = new (Context) ObjCBoxedExpr(Empty); 3389 break; 3390 case EXPR_OBJC_ARRAY_LITERAL: 3391 S = ObjCArrayLiteral::CreateEmpty(Context, 3392 Record[ASTStmtReader::NumExprFields]); 3393 break; 3394 case EXPR_OBJC_DICTIONARY_LITERAL: 3395 S = ObjCDictionaryLiteral::CreateEmpty(Context, 3396 Record[ASTStmtReader::NumExprFields], 3397 Record[ASTStmtReader::NumExprFields + 1]); 3398 break; 3399 case EXPR_OBJC_ENCODE: 3400 S = new (Context) ObjCEncodeExpr(Empty); 3401 break; 3402 case EXPR_OBJC_SELECTOR_EXPR: 3403 S = new (Context) ObjCSelectorExpr(Empty); 3404 break; 3405 case EXPR_OBJC_PROTOCOL_EXPR: 3406 S = new (Context) ObjCProtocolExpr(Empty); 3407 break; 3408 case EXPR_OBJC_IVAR_REF_EXPR: 3409 S = new (Context) ObjCIvarRefExpr(Empty); 3410 break; 3411 case EXPR_OBJC_PROPERTY_REF_EXPR: 3412 S = new (Context) ObjCPropertyRefExpr(Empty); 3413 break; 3414 case EXPR_OBJC_SUBSCRIPT_REF_EXPR: 3415 S = new (Context) ObjCSubscriptRefExpr(Empty); 3416 break; 3417 case EXPR_OBJC_KVC_REF_EXPR: 3418 llvm_unreachable("mismatching AST file"); 3419 case EXPR_OBJC_MESSAGE_EXPR: 3420 S = ObjCMessageExpr::CreateEmpty(Context, 3421 Record[ASTStmtReader::NumExprFields], 3422 Record[ASTStmtReader::NumExprFields + 1]); 3423 break; 3424 case EXPR_OBJC_ISA: 3425 S = new (Context) ObjCIsaExpr(Empty); 3426 break; 3427 case EXPR_OBJC_INDIRECT_COPY_RESTORE: 3428 S = new (Context) ObjCIndirectCopyRestoreExpr(Empty); 3429 break; 3430 case EXPR_OBJC_BRIDGED_CAST: 3431 S = new (Context) ObjCBridgedCastExpr(Empty); 3432 break; 3433 case STMT_OBJC_FOR_COLLECTION: 3434 S = new (Context) ObjCForCollectionStmt(Empty); 3435 break; 3436 case STMT_OBJC_CATCH: 3437 S = new (Context) ObjCAtCatchStmt(Empty); 3438 break; 3439 case STMT_OBJC_FINALLY: 3440 S = new (Context) ObjCAtFinallyStmt(Empty); 3441 break; 3442 case STMT_OBJC_AT_TRY: 3443 S = ObjCAtTryStmt::CreateEmpty(Context, 3444 Record[ASTStmtReader::NumStmtFields], 3445 Record[ASTStmtReader::NumStmtFields + 1]); 3446 break; 3447 case STMT_OBJC_AT_SYNCHRONIZED: 3448 S = new (Context) ObjCAtSynchronizedStmt(Empty); 3449 break; 3450 case STMT_OBJC_AT_THROW: 3451 S = new (Context) ObjCAtThrowStmt(Empty); 3452 break; 3453 case STMT_OBJC_AUTORELEASE_POOL: 3454 S = new (Context) ObjCAutoreleasePoolStmt(Empty); 3455 break; 3456 case EXPR_OBJC_BOOL_LITERAL: 3457 S = new (Context) ObjCBoolLiteralExpr(Empty); 3458 break; 3459 case EXPR_OBJC_AVAILABILITY_CHECK: 3460 S = new (Context) ObjCAvailabilityCheckExpr(Empty); 3461 break; 3462 case STMT_SEH_LEAVE: 3463 S = new (Context) SEHLeaveStmt(Empty); 3464 break; 3465 case STMT_SEH_EXCEPT: 3466 S = new (Context) SEHExceptStmt(Empty); 3467 break; 3468 case STMT_SEH_FINALLY: 3469 S = new (Context) SEHFinallyStmt(Empty); 3470 break; 3471 case STMT_SEH_TRY: 3472 S = new (Context) SEHTryStmt(Empty); 3473 break; 3474 case STMT_CXX_CATCH: 3475 S = new (Context) CXXCatchStmt(Empty); 3476 break; 3477 3478 case STMT_CXX_TRY: 3479 S = CXXTryStmt::Create(Context, Empty, 3480 /*NumHandlers=*/Record[ASTStmtReader::NumStmtFields]); 3481 break; 3482 3483 case STMT_CXX_FOR_RANGE: 3484 S = new (Context) CXXForRangeStmt(Empty); 3485 break; 3486 3487 case STMT_MS_DEPENDENT_EXISTS: 3488 S = new (Context) MSDependentExistsStmt(SourceLocation(), true, 3489 NestedNameSpecifierLoc(), 3490 DeclarationNameInfo(), 3491 nullptr); 3492 break; 3493 3494 case STMT_OMP_PARALLEL_DIRECTIVE: 3495 S = 3496 OMPParallelDirective::CreateEmpty(Context, 3497 Record[ASTStmtReader::NumStmtFields], 3498 Empty); 3499 break; 3500 3501 case STMT_OMP_SIMD_DIRECTIVE: { 3502 unsigned NumClauses = Record[ASTStmtReader::NumStmtFields]; 3503 unsigned CollapsedNum = Record[ASTStmtReader::NumStmtFields + 1]; 3504 S = OMPSimdDirective::CreateEmpty(Context, NumClauses, 3505 CollapsedNum, Empty); 3506 break; 3507 } 3508 3509 case STMT_OMP_FOR_DIRECTIVE: { 3510 unsigned NumClauses = Record[ASTStmtReader::NumStmtFields]; 3511 unsigned CollapsedNum = Record[ASTStmtReader::NumStmtFields + 1]; 3512 S = OMPForDirective::CreateEmpty(Context, NumClauses, CollapsedNum, 3513 Empty); 3514 break; 3515 } 3516 3517 case STMT_OMP_FOR_SIMD_DIRECTIVE: { 3518 unsigned NumClauses = Record[ASTStmtReader::NumStmtFields]; 3519 unsigned CollapsedNum = Record[ASTStmtReader::NumStmtFields + 1]; 3520 S = OMPForSimdDirective::CreateEmpty(Context, NumClauses, CollapsedNum, 3521 Empty); 3522 break; 3523 } 3524 3525 case STMT_OMP_SECTIONS_DIRECTIVE: 3526 S = OMPSectionsDirective::CreateEmpty( 3527 Context, Record[ASTStmtReader::NumStmtFields], Empty); 3528 break; 3529 3530 case STMT_OMP_SECTION_DIRECTIVE: 3531 S = OMPSectionDirective::CreateEmpty(Context, Empty); 3532 break; 3533 3534 case STMT_OMP_SINGLE_DIRECTIVE: 3535 S = OMPSingleDirective::CreateEmpty( 3536 Context, Record[ASTStmtReader::NumStmtFields], Empty); 3537 break; 3538 3539 case STMT_OMP_MASTER_DIRECTIVE: 3540 S = OMPMasterDirective::CreateEmpty(Context, Empty); 3541 break; 3542 3543 case STMT_OMP_CRITICAL_DIRECTIVE: 3544 S = OMPCriticalDirective::CreateEmpty( 3545 Context, Record[ASTStmtReader::NumStmtFields], Empty); 3546 break; 3547 3548 case STMT_OMP_PARALLEL_FOR_DIRECTIVE: { 3549 unsigned NumClauses = Record[ASTStmtReader::NumStmtFields]; 3550 unsigned CollapsedNum = Record[ASTStmtReader::NumStmtFields + 1]; 3551 S = OMPParallelForDirective::CreateEmpty(Context, NumClauses, 3552 CollapsedNum, Empty); 3553 break; 3554 } 3555 3556 case STMT_OMP_PARALLEL_FOR_SIMD_DIRECTIVE: { 3557 unsigned NumClauses = Record[ASTStmtReader::NumStmtFields]; 3558 unsigned CollapsedNum = Record[ASTStmtReader::NumStmtFields + 1]; 3559 S = OMPParallelForSimdDirective::CreateEmpty(Context, NumClauses, 3560 CollapsedNum, Empty); 3561 break; 3562 } 3563 3564 case STMT_OMP_PARALLEL_SECTIONS_DIRECTIVE: 3565 S = OMPParallelSectionsDirective::CreateEmpty( 3566 Context, Record[ASTStmtReader::NumStmtFields], Empty); 3567 break; 3568 3569 case STMT_OMP_TASK_DIRECTIVE: 3570 S = OMPTaskDirective::CreateEmpty( 3571 Context, Record[ASTStmtReader::NumStmtFields], Empty); 3572 break; 3573 3574 case STMT_OMP_TASKYIELD_DIRECTIVE: 3575 S = OMPTaskyieldDirective::CreateEmpty(Context, Empty); 3576 break; 3577 3578 case STMT_OMP_BARRIER_DIRECTIVE: 3579 S = OMPBarrierDirective::CreateEmpty(Context, Empty); 3580 break; 3581 3582 case STMT_OMP_TASKWAIT_DIRECTIVE: 3583 S = OMPTaskwaitDirective::CreateEmpty(Context, Empty); 3584 break; 3585 3586 case STMT_OMP_TASKGROUP_DIRECTIVE: 3587 S = OMPTaskgroupDirective::CreateEmpty( 3588 Context, Record[ASTStmtReader::NumStmtFields], Empty); 3589 break; 3590 3591 case STMT_OMP_FLUSH_DIRECTIVE: 3592 S = OMPFlushDirective::CreateEmpty( 3593 Context, Record[ASTStmtReader::NumStmtFields], Empty); 3594 break; 3595 3596 case STMT_OMP_ORDERED_DIRECTIVE: 3597 S = OMPOrderedDirective::CreateEmpty( 3598 Context, Record[ASTStmtReader::NumStmtFields], Empty); 3599 break; 3600 3601 case STMT_OMP_ATOMIC_DIRECTIVE: 3602 S = OMPAtomicDirective::CreateEmpty( 3603 Context, Record[ASTStmtReader::NumStmtFields], Empty); 3604 break; 3605 3606 case STMT_OMP_TARGET_DIRECTIVE: 3607 S = OMPTargetDirective::CreateEmpty( 3608 Context, Record[ASTStmtReader::NumStmtFields], Empty); 3609 break; 3610 3611 case STMT_OMP_TARGET_DATA_DIRECTIVE: 3612 S = OMPTargetDataDirective::CreateEmpty( 3613 Context, Record[ASTStmtReader::NumStmtFields], Empty); 3614 break; 3615 3616 case STMT_OMP_TARGET_ENTER_DATA_DIRECTIVE: 3617 S = OMPTargetEnterDataDirective::CreateEmpty( 3618 Context, Record[ASTStmtReader::NumStmtFields], Empty); 3619 break; 3620 3621 case STMT_OMP_TARGET_EXIT_DATA_DIRECTIVE: 3622 S = OMPTargetExitDataDirective::CreateEmpty( 3623 Context, Record[ASTStmtReader::NumStmtFields], Empty); 3624 break; 3625 3626 case STMT_OMP_TARGET_PARALLEL_DIRECTIVE: 3627 S = OMPTargetParallelDirective::CreateEmpty( 3628 Context, Record[ASTStmtReader::NumStmtFields], Empty); 3629 break; 3630 3631 case STMT_OMP_TARGET_PARALLEL_FOR_DIRECTIVE: { 3632 unsigned NumClauses = Record[ASTStmtReader::NumStmtFields]; 3633 unsigned CollapsedNum = Record[ASTStmtReader::NumStmtFields + 1]; 3634 S = OMPTargetParallelForDirective::CreateEmpty(Context, NumClauses, 3635 CollapsedNum, Empty); 3636 break; 3637 } 3638 3639 case STMT_OMP_TARGET_UPDATE_DIRECTIVE: 3640 S = OMPTargetUpdateDirective::CreateEmpty( 3641 Context, Record[ASTStmtReader::NumStmtFields], Empty); 3642 break; 3643 3644 case STMT_OMP_TEAMS_DIRECTIVE: 3645 S = OMPTeamsDirective::CreateEmpty( 3646 Context, Record[ASTStmtReader::NumStmtFields], Empty); 3647 break; 3648 3649 case STMT_OMP_CANCELLATION_POINT_DIRECTIVE: 3650 S = OMPCancellationPointDirective::CreateEmpty(Context, Empty); 3651 break; 3652 3653 case STMT_OMP_CANCEL_DIRECTIVE: 3654 S = OMPCancelDirective::CreateEmpty( 3655 Context, Record[ASTStmtReader::NumStmtFields], Empty); 3656 break; 3657 3658 case STMT_OMP_TASKLOOP_DIRECTIVE: { 3659 unsigned NumClauses = Record[ASTStmtReader::NumStmtFields]; 3660 unsigned CollapsedNum = Record[ASTStmtReader::NumStmtFields + 1]; 3661 S = OMPTaskLoopDirective::CreateEmpty(Context, NumClauses, CollapsedNum, 3662 Empty); 3663 break; 3664 } 3665 3666 case STMT_OMP_TASKLOOP_SIMD_DIRECTIVE: { 3667 unsigned NumClauses = Record[ASTStmtReader::NumStmtFields]; 3668 unsigned CollapsedNum = Record[ASTStmtReader::NumStmtFields + 1]; 3669 S = OMPTaskLoopSimdDirective::CreateEmpty(Context, NumClauses, 3670 CollapsedNum, Empty); 3671 break; 3672 } 3673 3674 case STMT_OMP_DISTRIBUTE_DIRECTIVE: { 3675 unsigned NumClauses = Record[ASTStmtReader::NumStmtFields]; 3676 unsigned CollapsedNum = Record[ASTStmtReader::NumStmtFields + 1]; 3677 S = OMPDistributeDirective::CreateEmpty(Context, NumClauses, CollapsedNum, 3678 Empty); 3679 break; 3680 } 3681 3682 case STMT_OMP_DISTRIBUTE_PARALLEL_FOR_DIRECTIVE: { 3683 unsigned NumClauses = Record[ASTStmtReader::NumStmtFields]; 3684 unsigned CollapsedNum = Record[ASTStmtReader::NumStmtFields + 1]; 3685 S = OMPDistributeParallelForDirective::CreateEmpty(Context, NumClauses, 3686 CollapsedNum, Empty); 3687 break; 3688 } 3689 3690 case STMT_OMP_DISTRIBUTE_PARALLEL_FOR_SIMD_DIRECTIVE: { 3691 unsigned NumClauses = Record[ASTStmtReader::NumStmtFields]; 3692 unsigned CollapsedNum = Record[ASTStmtReader::NumStmtFields + 1]; 3693 S = OMPDistributeParallelForSimdDirective::CreateEmpty(Context, NumClauses, 3694 CollapsedNum, 3695 Empty); 3696 break; 3697 } 3698 3699 case STMT_OMP_DISTRIBUTE_SIMD_DIRECTIVE: { 3700 unsigned NumClauses = Record[ASTStmtReader::NumStmtFields]; 3701 unsigned CollapsedNum = Record[ASTStmtReader::NumStmtFields + 1]; 3702 S = OMPDistributeSimdDirective::CreateEmpty(Context, NumClauses, 3703 CollapsedNum, Empty); 3704 break; 3705 } 3706 3707 case STMT_OMP_TARGET_PARALLEL_FOR_SIMD_DIRECTIVE: { 3708 unsigned NumClauses = Record[ASTStmtReader::NumStmtFields]; 3709 unsigned CollapsedNum = Record[ASTStmtReader::NumStmtFields + 1]; 3710 S = OMPTargetParallelForSimdDirective::CreateEmpty(Context, NumClauses, 3711 CollapsedNum, Empty); 3712 break; 3713 } 3714 3715 case STMT_OMP_TARGET_SIMD_DIRECTIVE: { 3716 auto NumClauses = Record[ASTStmtReader::NumStmtFields]; 3717 auto CollapsedNum = Record[ASTStmtReader::NumStmtFields + 1]; 3718 S = OMPTargetSimdDirective::CreateEmpty(Context, NumClauses, CollapsedNum, 3719 Empty); 3720 break; 3721 } 3722 3723 case STMT_OMP_TEAMS_DISTRIBUTE_DIRECTIVE: { 3724 auto NumClauses = Record[ASTStmtReader::NumStmtFields]; 3725 auto CollapsedNum = Record[ASTStmtReader::NumStmtFields + 1]; 3726 S = OMPTeamsDistributeDirective::CreateEmpty(Context, NumClauses, 3727 CollapsedNum, Empty); 3728 break; 3729 } 3730 3731 case STMT_OMP_TEAMS_DISTRIBUTE_SIMD_DIRECTIVE: { 3732 unsigned NumClauses = Record[ASTStmtReader::NumStmtFields]; 3733 unsigned CollapsedNum = Record[ASTStmtReader::NumStmtFields + 1]; 3734 S = OMPTeamsDistributeSimdDirective::CreateEmpty(Context, NumClauses, 3735 CollapsedNum, Empty); 3736 break; 3737 } 3738 3739 case STMT_OMP_TEAMS_DISTRIBUTE_PARALLEL_FOR_SIMD_DIRECTIVE: { 3740 auto NumClauses = Record[ASTStmtReader::NumStmtFields]; 3741 auto CollapsedNum = Record[ASTStmtReader::NumStmtFields + 1]; 3742 S = OMPTeamsDistributeParallelForSimdDirective::CreateEmpty( 3743 Context, NumClauses, CollapsedNum, Empty); 3744 break; 3745 } 3746 3747 case STMT_OMP_TEAMS_DISTRIBUTE_PARALLEL_FOR_DIRECTIVE: { 3748 auto NumClauses = Record[ASTStmtReader::NumStmtFields]; 3749 auto CollapsedNum = Record[ASTStmtReader::NumStmtFields + 1]; 3750 S = OMPTeamsDistributeParallelForDirective::CreateEmpty( 3751 Context, NumClauses, CollapsedNum, Empty); 3752 break; 3753 } 3754 3755 case STMT_OMP_TARGET_TEAMS_DIRECTIVE: { 3756 S = OMPTargetTeamsDirective::CreateEmpty( 3757 Context, Record[ASTStmtReader::NumStmtFields], Empty); 3758 break; 3759 } 3760 3761 case STMT_OMP_TARGET_TEAMS_DISTRIBUTE_DIRECTIVE: { 3762 auto NumClauses = Record[ASTStmtReader::NumStmtFields]; 3763 auto CollapsedNum = Record[ASTStmtReader::NumStmtFields + 1]; 3764 S = OMPTargetTeamsDistributeDirective::CreateEmpty(Context, NumClauses, 3765 CollapsedNum, Empty); 3766 break; 3767 } 3768 3769 case STMT_OMP_TARGET_TEAMS_DISTRIBUTE_PARALLEL_FOR_DIRECTIVE: { 3770 auto NumClauses = Record[ASTStmtReader::NumStmtFields]; 3771 auto CollapsedNum = Record[ASTStmtReader::NumStmtFields + 1]; 3772 S = OMPTargetTeamsDistributeParallelForDirective::CreateEmpty( 3773 Context, NumClauses, CollapsedNum, Empty); 3774 break; 3775 } 3776 3777 case STMT_OMP_TARGET_TEAMS_DISTRIBUTE_PARALLEL_FOR_SIMD_DIRECTIVE: { 3778 auto NumClauses = Record[ASTStmtReader::NumStmtFields]; 3779 auto CollapsedNum = Record[ASTStmtReader::NumStmtFields + 1]; 3780 S = OMPTargetTeamsDistributeParallelForSimdDirective::CreateEmpty( 3781 Context, NumClauses, CollapsedNum, Empty); 3782 break; 3783 } 3784 3785 case STMT_OMP_TARGET_TEAMS_DISTRIBUTE_SIMD_DIRECTIVE: { 3786 auto NumClauses = Record[ASTStmtReader::NumStmtFields]; 3787 auto CollapsedNum = Record[ASTStmtReader::NumStmtFields + 1]; 3788 S = OMPTargetTeamsDistributeSimdDirective::CreateEmpty( 3789 Context, NumClauses, CollapsedNum, Empty); 3790 break; 3791 } 3792 3793 case EXPR_CXX_OPERATOR_CALL: 3794 S = new (Context) CXXOperatorCallExpr(Context, Empty); 3795 break; 3796 3797 case EXPR_CXX_MEMBER_CALL: 3798 S = new (Context) CXXMemberCallExpr(Context, Empty); 3799 break; 3800 3801 case EXPR_CXX_CONSTRUCT: 3802 S = new (Context) CXXConstructExpr(Empty); 3803 break; 3804 3805 case EXPR_CXX_INHERITED_CTOR_INIT: 3806 S = new (Context) CXXInheritedCtorInitExpr(Empty); 3807 break; 3808 3809 case EXPR_CXX_TEMPORARY_OBJECT: 3810 S = new (Context) CXXTemporaryObjectExpr(Empty); 3811 break; 3812 3813 case EXPR_CXX_STATIC_CAST: 3814 S = CXXStaticCastExpr::CreateEmpty(Context, 3815 /*PathSize*/ Record[ASTStmtReader::NumExprFields]); 3816 break; 3817 3818 case EXPR_CXX_DYNAMIC_CAST: 3819 S = CXXDynamicCastExpr::CreateEmpty(Context, 3820 /*PathSize*/ Record[ASTStmtReader::NumExprFields]); 3821 break; 3822 3823 case EXPR_CXX_REINTERPRET_CAST: 3824 S = CXXReinterpretCastExpr::CreateEmpty(Context, 3825 /*PathSize*/ Record[ASTStmtReader::NumExprFields]); 3826 break; 3827 3828 case EXPR_CXX_CONST_CAST: 3829 S = CXXConstCastExpr::CreateEmpty(Context); 3830 break; 3831 3832 case EXPR_CXX_FUNCTIONAL_CAST: 3833 S = CXXFunctionalCastExpr::CreateEmpty(Context, 3834 /*PathSize*/ Record[ASTStmtReader::NumExprFields]); 3835 break; 3836 3837 case EXPR_USER_DEFINED_LITERAL: 3838 S = new (Context) UserDefinedLiteral(Context, Empty); 3839 break; 3840 3841 case EXPR_CXX_STD_INITIALIZER_LIST: 3842 S = new (Context) CXXStdInitializerListExpr(Empty); 3843 break; 3844 3845 case EXPR_CXX_BOOL_LITERAL: 3846 S = new (Context) CXXBoolLiteralExpr(Empty); 3847 break; 3848 3849 case EXPR_CXX_NULL_PTR_LITERAL: 3850 S = new (Context) CXXNullPtrLiteralExpr(Empty); 3851 break; 3852 case EXPR_CXX_TYPEID_EXPR: 3853 S = new (Context) CXXTypeidExpr(Empty, true); 3854 break; 3855 case EXPR_CXX_TYPEID_TYPE: 3856 S = new (Context) CXXTypeidExpr(Empty, false); 3857 break; 3858 case EXPR_CXX_UUIDOF_EXPR: 3859 S = new (Context) CXXUuidofExpr(Empty, true); 3860 break; 3861 case EXPR_CXX_PROPERTY_REF_EXPR: 3862 S = new (Context) MSPropertyRefExpr(Empty); 3863 break; 3864 case EXPR_CXX_PROPERTY_SUBSCRIPT_EXPR: 3865 S = new (Context) MSPropertySubscriptExpr(Empty); 3866 break; 3867 case EXPR_CXX_UUIDOF_TYPE: 3868 S = new (Context) CXXUuidofExpr(Empty, false); 3869 break; 3870 case EXPR_CXX_THIS: 3871 S = new (Context) CXXThisExpr(Empty); 3872 break; 3873 case EXPR_CXX_THROW: 3874 S = new (Context) CXXThrowExpr(Empty); 3875 break; 3876 case EXPR_CXX_DEFAULT_ARG: 3877 S = new (Context) CXXDefaultArgExpr(Empty); 3878 break; 3879 case EXPR_CXX_DEFAULT_INIT: 3880 S = new (Context) CXXDefaultInitExpr(Empty); 3881 break; 3882 case EXPR_CXX_BIND_TEMPORARY: 3883 S = new (Context) CXXBindTemporaryExpr(Empty); 3884 break; 3885 3886 case EXPR_CXX_SCALAR_VALUE_INIT: 3887 S = new (Context) CXXScalarValueInitExpr(Empty); 3888 break; 3889 case EXPR_CXX_NEW: 3890 S = new (Context) CXXNewExpr(Empty); 3891 break; 3892 case EXPR_CXX_DELETE: 3893 S = new (Context) CXXDeleteExpr(Empty); 3894 break; 3895 case EXPR_CXX_PSEUDO_DESTRUCTOR: 3896 S = new (Context) CXXPseudoDestructorExpr(Empty); 3897 break; 3898 3899 case EXPR_EXPR_WITH_CLEANUPS: 3900 S = ExprWithCleanups::Create(Context, Empty, 3901 Record[ASTStmtReader::NumExprFields]); 3902 break; 3903 3904 case EXPR_CXX_DEPENDENT_SCOPE_MEMBER: 3905 S = CXXDependentScopeMemberExpr::CreateEmpty(Context, 3906 /*HasTemplateKWAndArgsInfo=*/Record[ASTStmtReader::NumExprFields], 3907 /*NumTemplateArgs=*/Record[ASTStmtReader::NumExprFields] 3908 ? Record[ASTStmtReader::NumExprFields + 1] 3909 : 0); 3910 break; 3911 3912 case EXPR_CXX_DEPENDENT_SCOPE_DECL_REF: 3913 S = DependentScopeDeclRefExpr::CreateEmpty(Context, 3914 /*HasTemplateKWAndArgsInfo=*/Record[ASTStmtReader::NumExprFields], 3915 /*NumTemplateArgs=*/Record[ASTStmtReader::NumExprFields] 3916 ? Record[ASTStmtReader::NumExprFields + 1] 3917 : 0); 3918 break; 3919 3920 case EXPR_CXX_UNRESOLVED_CONSTRUCT: 3921 S = CXXUnresolvedConstructExpr::CreateEmpty(Context, 3922 /*NumArgs=*/Record[ASTStmtReader::NumExprFields]); 3923 break; 3924 3925 case EXPR_CXX_UNRESOLVED_MEMBER: 3926 S = UnresolvedMemberExpr::CreateEmpty(Context, 3927 /*HasTemplateKWAndArgsInfo=*/Record[ASTStmtReader::NumExprFields], 3928 /*NumTemplateArgs=*/Record[ASTStmtReader::NumExprFields] 3929 ? Record[ASTStmtReader::NumExprFields + 1] 3930 : 0); 3931 break; 3932 3933 case EXPR_CXX_UNRESOLVED_LOOKUP: 3934 S = UnresolvedLookupExpr::CreateEmpty(Context, 3935 /*HasTemplateKWAndArgsInfo=*/Record[ASTStmtReader::NumExprFields], 3936 /*NumTemplateArgs=*/Record[ASTStmtReader::NumExprFields] 3937 ? Record[ASTStmtReader::NumExprFields + 1] 3938 : 0); 3939 break; 3940 3941 case EXPR_TYPE_TRAIT: 3942 S = TypeTraitExpr::CreateDeserialized(Context, 3943 Record[ASTStmtReader::NumExprFields]); 3944 break; 3945 3946 case EXPR_ARRAY_TYPE_TRAIT: 3947 S = new (Context) ArrayTypeTraitExpr(Empty); 3948 break; 3949 3950 case EXPR_CXX_EXPRESSION_TRAIT: 3951 S = new (Context) ExpressionTraitExpr(Empty); 3952 break; 3953 3954 case EXPR_CXX_NOEXCEPT: 3955 S = new (Context) CXXNoexceptExpr(Empty); 3956 break; 3957 3958 case EXPR_PACK_EXPANSION: 3959 S = new (Context) PackExpansionExpr(Empty); 3960 break; 3961 3962 case EXPR_SIZEOF_PACK: 3963 S = SizeOfPackExpr::CreateDeserialized( 3964 Context, 3965 /*NumPartialArgs=*/Record[ASTStmtReader::NumExprFields]); 3966 break; 3967 3968 case EXPR_SUBST_NON_TYPE_TEMPLATE_PARM: 3969 S = new (Context) SubstNonTypeTemplateParmExpr(Empty); 3970 break; 3971 3972 case EXPR_SUBST_NON_TYPE_TEMPLATE_PARM_PACK: 3973 S = new (Context) SubstNonTypeTemplateParmPackExpr(Empty); 3974 break; 3975 3976 case EXPR_FUNCTION_PARM_PACK: 3977 S = FunctionParmPackExpr::CreateEmpty(Context, 3978 Record[ASTStmtReader::NumExprFields]); 3979 break; 3980 3981 case EXPR_MATERIALIZE_TEMPORARY: 3982 S = new (Context) MaterializeTemporaryExpr(Empty); 3983 break; 3984 3985 case EXPR_CXX_FOLD: 3986 S = new (Context) CXXFoldExpr(Empty); 3987 break; 3988 3989 case EXPR_OPAQUE_VALUE: 3990 S = new (Context) OpaqueValueExpr(Empty); 3991 break; 3992 3993 case EXPR_CUDA_KERNEL_CALL: 3994 S = new (Context) CUDAKernelCallExpr(Context, Empty); 3995 break; 3996 3997 case EXPR_ASTYPE: 3998 S = new (Context) AsTypeExpr(Empty); 3999 break; 4000 4001 case EXPR_PSEUDO_OBJECT: { 4002 unsigned numSemanticExprs = Record[ASTStmtReader::NumExprFields]; 4003 S = PseudoObjectExpr::Create(Context, Empty, numSemanticExprs); 4004 break; 4005 } 4006 4007 case EXPR_ATOMIC: 4008 S = new (Context) AtomicExpr(Empty); 4009 break; 4010 4011 case EXPR_LAMBDA: { 4012 unsigned NumCaptures = Record[ASTStmtReader::NumExprFields]; 4013 S = LambdaExpr::CreateDeserialized(Context, NumCaptures); 4014 break; 4015 } 4016 4017 case STMT_COROUTINE_BODY: { 4018 unsigned NumParams = Record[ASTStmtReader::NumStmtFields]; 4019 S = CoroutineBodyStmt::Create(Context, Empty, NumParams); 4020 break; 4021 } 4022 4023 case STMT_CORETURN: 4024 S = new (Context) CoreturnStmt(Empty); 4025 break; 4026 4027 case EXPR_COAWAIT: 4028 S = new (Context) CoawaitExpr(Empty); 4029 break; 4030 4031 case EXPR_COYIELD: 4032 S = new (Context) CoyieldExpr(Empty); 4033 break; 4034 4035 case EXPR_DEPENDENT_COAWAIT: 4036 S = new (Context) DependentCoawaitExpr(Empty); 4037 break; 4038 4039 } 4040 4041 // We hit a STMT_STOP, so we're done with this expression. 4042 if (Finished) 4043 break; 4044 4045 ++NumStatementsRead; 4046 4047 if (S && !IsStmtReference) { 4048 Reader.Visit(S); 4049 StmtEntries[Cursor.GetCurrentBitNo()] = S; 4050 } 4051 4052 assert(Record.getIdx() == Record.size() && 4053 "Invalid deserialization of statement"); 4054 StmtStack.push_back(S); 4055 } 4056 Done: 4057 assert(StmtStack.size() > PrevNumStmts && "Read too many sub-stmts!"); 4058 assert(StmtStack.size() == PrevNumStmts + 1 && "Extra expressions on stack!"); 4059 return StmtStack.pop_back_val(); 4060 } 4061