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