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