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