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