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