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