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