1 //===- ASTReaderStmt.cpp - Stmt/Expr Deserialization ----------------------===// 2 // 3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. 4 // See https://llvm.org/LICENSE.txt for license information. 5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 6 // 7 //===----------------------------------------------------------------------===// 8 // 9 // Statement/expression deserialization. This implements the 10 // ASTReader::ReadStmt method. 11 // 12 //===----------------------------------------------------------------------===// 13 14 #include "clang/Serialization/ASTReader.h" 15 #include "clang/AST/ASTContext.h" 16 #include "clang/AST/AttrIterator.h" 17 #include "clang/AST/Decl.h" 18 #include "clang/AST/DeclAccessPair.h" 19 #include "clang/AST/DeclCXX.h" 20 #include "clang/AST/DeclGroup.h" 21 #include "clang/AST/DeclObjC.h" 22 #include "clang/AST/DeclTemplate.h" 23 #include "clang/AST/DeclarationName.h" 24 #include "clang/AST/Expr.h" 25 #include "clang/AST/ExprCXX.h" 26 #include "clang/AST/ExprObjC.h" 27 #include "clang/AST/ExprOpenMP.h" 28 #include "clang/AST/NestedNameSpecifier.h" 29 #include "clang/AST/OpenMPClause.h" 30 #include "clang/AST/OperationKinds.h" 31 #include "clang/AST/Stmt.h" 32 #include "clang/AST/StmtCXX.h" 33 #include "clang/AST/StmtObjC.h" 34 #include "clang/AST/StmtOpenMP.h" 35 #include "clang/AST/StmtVisitor.h" 36 #include "clang/AST/TemplateBase.h" 37 #include "clang/AST/Type.h" 38 #include "clang/AST/UnresolvedSet.h" 39 #include "clang/Basic/CapturedStmt.h" 40 #include "clang/Basic/ExpressionTraits.h" 41 #include "clang/Basic/LLVM.h" 42 #include "clang/Basic/Lambda.h" 43 #include "clang/Basic/LangOptions.h" 44 #include "clang/Basic/OpenMPKinds.h" 45 #include "clang/Basic/OperatorKinds.h" 46 #include "clang/Basic/SourceLocation.h" 47 #include "clang/Basic/Specifiers.h" 48 #include "clang/Basic/TypeTraits.h" 49 #include "clang/Lex/Token.h" 50 #include "clang/Serialization/ASTBitCodes.h" 51 #include "llvm/ADT/DenseMap.h" 52 #include "llvm/ADT/SmallString.h" 53 #include "llvm/ADT/SmallVector.h" 54 #include "llvm/ADT/StringRef.h" 55 #include "llvm/Bitcode/BitstreamReader.h" 56 #include "llvm/Support/Casting.h" 57 #include "llvm/Support/ErrorHandling.h" 58 #include <algorithm> 59 #include <cassert> 60 #include <cstdint> 61 #include <string> 62 63 using namespace clang; 64 using namespace serialization; 65 66 namespace clang { 67 68 class ASTStmtReader : public StmtVisitor<ASTStmtReader> { 69 friend class OMPClauseReader; 70 71 ASTRecordReader &Record; 72 llvm::BitstreamCursor &DeclsCursor; 73 74 SourceLocation ReadSourceLocation() { 75 return Record.readSourceLocation(); 76 } 77 78 SourceRange ReadSourceRange() { 79 return Record.readSourceRange(); 80 } 81 82 std::string ReadString() { 83 return Record.readString(); 84 } 85 86 TypeSourceInfo *GetTypeSourceInfo() { 87 return Record.getTypeSourceInfo(); 88 } 89 90 Decl *ReadDecl() { 91 return Record.readDecl(); 92 } 93 94 template<typename T> 95 T *ReadDeclAs() { 96 return Record.readDeclAs<T>(); 97 } 98 99 void ReadDeclarationNameLoc(DeclarationNameLoc &DNLoc, 100 DeclarationName Name) { 101 Record.readDeclarationNameLoc(DNLoc, Name); 102 } 103 104 void ReadDeclarationNameInfo(DeclarationNameInfo &NameInfo) { 105 Record.readDeclarationNameInfo(NameInfo); 106 } 107 108 public: 109 ASTStmtReader(ASTRecordReader &Record, llvm::BitstreamCursor &Cursor) 110 : Record(Record), DeclsCursor(Cursor) {} 111 112 /// The number of record fields required for the Stmt class 113 /// itself. 114 static const unsigned NumStmtFields = 1; 115 116 /// The number of record fields required for the Expr class 117 /// itself. 118 static const unsigned NumExprFields = NumStmtFields + 7; 119 120 /// Read and initialize a ExplicitTemplateArgumentList structure. 121 void ReadTemplateKWAndArgsInfo(ASTTemplateKWAndArgsInfo &Args, 122 TemplateArgumentLoc *ArgsLocArray, 123 unsigned NumTemplateArgs); 124 125 /// Read and initialize a ExplicitTemplateArgumentList structure. 126 void ReadExplicitTemplateArgumentList(ASTTemplateArgumentListInfo &ArgList, 127 unsigned NumTemplateArgs); 128 129 void VisitStmt(Stmt *S); 130 #define STMT(Type, Base) \ 131 void Visit##Type(Type *); 132 #include "clang/AST/StmtNodes.inc" 133 }; 134 135 } // namespace clang 136 137 void ASTStmtReader::ReadTemplateKWAndArgsInfo(ASTTemplateKWAndArgsInfo &Args, 138 TemplateArgumentLoc *ArgsLocArray, 139 unsigned NumTemplateArgs) { 140 SourceLocation TemplateKWLoc = ReadSourceLocation(); 141 TemplateArgumentListInfo ArgInfo; 142 ArgInfo.setLAngleLoc(ReadSourceLocation()); 143 ArgInfo.setRAngleLoc(ReadSourceLocation()); 144 for (unsigned i = 0; i != NumTemplateArgs; ++i) 145 ArgInfo.addArgument(Record.readTemplateArgumentLoc()); 146 Args.initializeFrom(TemplateKWLoc, ArgInfo, ArgsLocArray); 147 } 148 149 void ASTStmtReader::VisitStmt(Stmt *S) { 150 S->setIsOMPStructuredBlock(Record.readInt()); 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 1027 unsigned NumAssocs = Record.readInt(); 1028 assert(NumAssocs == E->getNumAssocs() && "Wrong NumAssocs!"); 1029 E->ResultIndex = Record.readInt(); 1030 E->GenericSelectionExprBits.GenericLoc = ReadSourceLocation(); 1031 E->DefaultLoc = ReadSourceLocation(); 1032 E->RParenLoc = ReadSourceLocation(); 1033 1034 Stmt **Stmts = E->getTrailingObjects<Stmt *>(); 1035 // Add 1 to account for the controlling expression which is the first 1036 // expression in the trailing array of Stmt *. This is not needed for 1037 // the trailing array of TypeSourceInfo *. 1038 for (unsigned I = 0, N = NumAssocs + 1; I < N; ++I) 1039 Stmts[I] = Record.readSubExpr(); 1040 1041 TypeSourceInfo **TSIs = E->getTrailingObjects<TypeSourceInfo *>(); 1042 for (unsigned I = 0, N = NumAssocs; I < N; ++I) 1043 TSIs[I] = GetTypeSourceInfo(); 1044 } 1045 1046 void ASTStmtReader::VisitPseudoObjectExpr(PseudoObjectExpr *E) { 1047 VisitExpr(E); 1048 unsigned numSemanticExprs = Record.readInt(); 1049 assert(numSemanticExprs + 1 == E->PseudoObjectExprBits.NumSubExprs); 1050 E->PseudoObjectExprBits.ResultIndex = Record.readInt(); 1051 1052 // Read the syntactic expression. 1053 E->getSubExprsBuffer()[0] = Record.readSubExpr(); 1054 1055 // Read all the semantic expressions. 1056 for (unsigned i = 0; i != numSemanticExprs; ++i) { 1057 Expr *subExpr = Record.readSubExpr(); 1058 E->getSubExprsBuffer()[i+1] = subExpr; 1059 } 1060 } 1061 1062 void ASTStmtReader::VisitAtomicExpr(AtomicExpr *E) { 1063 VisitExpr(E); 1064 E->Op = AtomicExpr::AtomicOp(Record.readInt()); 1065 E->NumSubExprs = AtomicExpr::getNumSubExprs(E->Op); 1066 for (unsigned I = 0; I != E->NumSubExprs; ++I) 1067 E->SubExprs[I] = Record.readSubExpr(); 1068 E->BuiltinLoc = ReadSourceLocation(); 1069 E->RParenLoc = ReadSourceLocation(); 1070 } 1071 1072 //===----------------------------------------------------------------------===// 1073 // Objective-C Expressions and Statements 1074 1075 void ASTStmtReader::VisitObjCStringLiteral(ObjCStringLiteral *E) { 1076 VisitExpr(E); 1077 E->setString(cast<StringLiteral>(Record.readSubStmt())); 1078 E->setAtLoc(ReadSourceLocation()); 1079 } 1080 1081 void ASTStmtReader::VisitObjCBoxedExpr(ObjCBoxedExpr *E) { 1082 VisitExpr(E); 1083 // could be one of several IntegerLiteral, FloatLiteral, etc. 1084 E->SubExpr = Record.readSubStmt(); 1085 E->BoxingMethod = ReadDeclAs<ObjCMethodDecl>(); 1086 E->Range = ReadSourceRange(); 1087 } 1088 1089 void ASTStmtReader::VisitObjCArrayLiteral(ObjCArrayLiteral *E) { 1090 VisitExpr(E); 1091 unsigned NumElements = Record.readInt(); 1092 assert(NumElements == E->getNumElements() && "Wrong number of elements"); 1093 Expr **Elements = E->getElements(); 1094 for (unsigned I = 0, N = NumElements; I != N; ++I) 1095 Elements[I] = Record.readSubExpr(); 1096 E->ArrayWithObjectsMethod = ReadDeclAs<ObjCMethodDecl>(); 1097 E->Range = ReadSourceRange(); 1098 } 1099 1100 void ASTStmtReader::VisitObjCDictionaryLiteral(ObjCDictionaryLiteral *E) { 1101 VisitExpr(E); 1102 unsigned NumElements = Record.readInt(); 1103 assert(NumElements == E->getNumElements() && "Wrong number of elements"); 1104 bool HasPackExpansions = Record.readInt(); 1105 assert(HasPackExpansions == E->HasPackExpansions &&"Pack expansion mismatch"); 1106 auto *KeyValues = 1107 E->getTrailingObjects<ObjCDictionaryLiteral::KeyValuePair>(); 1108 auto *Expansions = 1109 E->getTrailingObjects<ObjCDictionaryLiteral::ExpansionData>(); 1110 for (unsigned I = 0; I != NumElements; ++I) { 1111 KeyValues[I].Key = Record.readSubExpr(); 1112 KeyValues[I].Value = Record.readSubExpr(); 1113 if (HasPackExpansions) { 1114 Expansions[I].EllipsisLoc = ReadSourceLocation(); 1115 Expansions[I].NumExpansionsPlusOne = Record.readInt(); 1116 } 1117 } 1118 E->DictWithObjectsMethod = ReadDeclAs<ObjCMethodDecl>(); 1119 E->Range = ReadSourceRange(); 1120 } 1121 1122 void ASTStmtReader::VisitObjCEncodeExpr(ObjCEncodeExpr *E) { 1123 VisitExpr(E); 1124 E->setEncodedTypeSourceInfo(GetTypeSourceInfo()); 1125 E->setAtLoc(ReadSourceLocation()); 1126 E->setRParenLoc(ReadSourceLocation()); 1127 } 1128 1129 void ASTStmtReader::VisitObjCSelectorExpr(ObjCSelectorExpr *E) { 1130 VisitExpr(E); 1131 E->setSelector(Record.readSelector()); 1132 E->setAtLoc(ReadSourceLocation()); 1133 E->setRParenLoc(ReadSourceLocation()); 1134 } 1135 1136 void ASTStmtReader::VisitObjCProtocolExpr(ObjCProtocolExpr *E) { 1137 VisitExpr(E); 1138 E->setProtocol(ReadDeclAs<ObjCProtocolDecl>()); 1139 E->setAtLoc(ReadSourceLocation()); 1140 E->ProtoLoc = ReadSourceLocation(); 1141 E->setRParenLoc(ReadSourceLocation()); 1142 } 1143 1144 void ASTStmtReader::VisitObjCIvarRefExpr(ObjCIvarRefExpr *E) { 1145 VisitExpr(E); 1146 E->setDecl(ReadDeclAs<ObjCIvarDecl>()); 1147 E->setLocation(ReadSourceLocation()); 1148 E->setOpLoc(ReadSourceLocation()); 1149 E->setBase(Record.readSubExpr()); 1150 E->setIsArrow(Record.readInt()); 1151 E->setIsFreeIvar(Record.readInt()); 1152 } 1153 1154 void ASTStmtReader::VisitObjCPropertyRefExpr(ObjCPropertyRefExpr *E) { 1155 VisitExpr(E); 1156 unsigned MethodRefFlags = Record.readInt(); 1157 bool Implicit = Record.readInt() != 0; 1158 if (Implicit) { 1159 auto *Getter = ReadDeclAs<ObjCMethodDecl>(); 1160 auto *Setter = ReadDeclAs<ObjCMethodDecl>(); 1161 E->setImplicitProperty(Getter, Setter, MethodRefFlags); 1162 } else { 1163 E->setExplicitProperty(ReadDeclAs<ObjCPropertyDecl>(), MethodRefFlags); 1164 } 1165 E->setLocation(ReadSourceLocation()); 1166 E->setReceiverLocation(ReadSourceLocation()); 1167 switch (Record.readInt()) { 1168 case 0: 1169 E->setBase(Record.readSubExpr()); 1170 break; 1171 case 1: 1172 E->setSuperReceiver(Record.readType()); 1173 break; 1174 case 2: 1175 E->setClassReceiver(ReadDeclAs<ObjCInterfaceDecl>()); 1176 break; 1177 } 1178 } 1179 1180 void ASTStmtReader::VisitObjCSubscriptRefExpr(ObjCSubscriptRefExpr *E) { 1181 VisitExpr(E); 1182 E->setRBracket(ReadSourceLocation()); 1183 E->setBaseExpr(Record.readSubExpr()); 1184 E->setKeyExpr(Record.readSubExpr()); 1185 E->GetAtIndexMethodDecl = ReadDeclAs<ObjCMethodDecl>(); 1186 E->SetAtIndexMethodDecl = ReadDeclAs<ObjCMethodDecl>(); 1187 } 1188 1189 void ASTStmtReader::VisitObjCMessageExpr(ObjCMessageExpr *E) { 1190 VisitExpr(E); 1191 assert(Record.peekInt() == E->getNumArgs()); 1192 Record.skipInts(1); 1193 unsigned NumStoredSelLocs = Record.readInt(); 1194 E->SelLocsKind = Record.readInt(); 1195 E->setDelegateInitCall(Record.readInt()); 1196 E->IsImplicit = Record.readInt(); 1197 auto Kind = static_cast<ObjCMessageExpr::ReceiverKind>(Record.readInt()); 1198 switch (Kind) { 1199 case ObjCMessageExpr::Instance: 1200 E->setInstanceReceiver(Record.readSubExpr()); 1201 break; 1202 1203 case ObjCMessageExpr::Class: 1204 E->setClassReceiver(GetTypeSourceInfo()); 1205 break; 1206 1207 case ObjCMessageExpr::SuperClass: 1208 case ObjCMessageExpr::SuperInstance: { 1209 QualType T = Record.readType(); 1210 SourceLocation SuperLoc = ReadSourceLocation(); 1211 E->setSuper(SuperLoc, T, Kind == ObjCMessageExpr::SuperInstance); 1212 break; 1213 } 1214 } 1215 1216 assert(Kind == E->getReceiverKind()); 1217 1218 if (Record.readInt()) 1219 E->setMethodDecl(ReadDeclAs<ObjCMethodDecl>()); 1220 else 1221 E->setSelector(Record.readSelector()); 1222 1223 E->LBracLoc = ReadSourceLocation(); 1224 E->RBracLoc = ReadSourceLocation(); 1225 1226 for (unsigned I = 0, N = E->getNumArgs(); I != N; ++I) 1227 E->setArg(I, Record.readSubExpr()); 1228 1229 SourceLocation *Locs = E->getStoredSelLocs(); 1230 for (unsigned I = 0; I != NumStoredSelLocs; ++I) 1231 Locs[I] = ReadSourceLocation(); 1232 } 1233 1234 void ASTStmtReader::VisitObjCForCollectionStmt(ObjCForCollectionStmt *S) { 1235 VisitStmt(S); 1236 S->setElement(Record.readSubStmt()); 1237 S->setCollection(Record.readSubExpr()); 1238 S->setBody(Record.readSubStmt()); 1239 S->setForLoc(ReadSourceLocation()); 1240 S->setRParenLoc(ReadSourceLocation()); 1241 } 1242 1243 void ASTStmtReader::VisitObjCAtCatchStmt(ObjCAtCatchStmt *S) { 1244 VisitStmt(S); 1245 S->setCatchBody(Record.readSubStmt()); 1246 S->setCatchParamDecl(ReadDeclAs<VarDecl>()); 1247 S->setAtCatchLoc(ReadSourceLocation()); 1248 S->setRParenLoc(ReadSourceLocation()); 1249 } 1250 1251 void ASTStmtReader::VisitObjCAtFinallyStmt(ObjCAtFinallyStmt *S) { 1252 VisitStmt(S); 1253 S->setFinallyBody(Record.readSubStmt()); 1254 S->setAtFinallyLoc(ReadSourceLocation()); 1255 } 1256 1257 void ASTStmtReader::VisitObjCAutoreleasePoolStmt(ObjCAutoreleasePoolStmt *S) { 1258 VisitStmt(S); // FIXME: no test coverage. 1259 S->setSubStmt(Record.readSubStmt()); 1260 S->setAtLoc(ReadSourceLocation()); 1261 } 1262 1263 void ASTStmtReader::VisitObjCAtTryStmt(ObjCAtTryStmt *S) { 1264 VisitStmt(S); 1265 assert(Record.peekInt() == S->getNumCatchStmts()); 1266 Record.skipInts(1); 1267 bool HasFinally = Record.readInt(); 1268 S->setTryBody(Record.readSubStmt()); 1269 for (unsigned I = 0, N = S->getNumCatchStmts(); I != N; ++I) 1270 S->setCatchStmt(I, cast_or_null<ObjCAtCatchStmt>(Record.readSubStmt())); 1271 1272 if (HasFinally) 1273 S->setFinallyStmt(Record.readSubStmt()); 1274 S->setAtTryLoc(ReadSourceLocation()); 1275 } 1276 1277 void ASTStmtReader::VisitObjCAtSynchronizedStmt(ObjCAtSynchronizedStmt *S) { 1278 VisitStmt(S); // FIXME: no test coverage. 1279 S->setSynchExpr(Record.readSubStmt()); 1280 S->setSynchBody(Record.readSubStmt()); 1281 S->setAtSynchronizedLoc(ReadSourceLocation()); 1282 } 1283 1284 void ASTStmtReader::VisitObjCAtThrowStmt(ObjCAtThrowStmt *S) { 1285 VisitStmt(S); // FIXME: no test coverage. 1286 S->setThrowExpr(Record.readSubStmt()); 1287 S->setThrowLoc(ReadSourceLocation()); 1288 } 1289 1290 void ASTStmtReader::VisitObjCBoolLiteralExpr(ObjCBoolLiteralExpr *E) { 1291 VisitExpr(E); 1292 E->setValue(Record.readInt()); 1293 E->setLocation(ReadSourceLocation()); 1294 } 1295 1296 void ASTStmtReader::VisitObjCAvailabilityCheckExpr(ObjCAvailabilityCheckExpr *E) { 1297 VisitExpr(E); 1298 SourceRange R = Record.readSourceRange(); 1299 E->AtLoc = R.getBegin(); 1300 E->RParen = R.getEnd(); 1301 E->VersionToCheck = Record.readVersionTuple(); 1302 } 1303 1304 //===----------------------------------------------------------------------===// 1305 // C++ Expressions and Statements 1306 //===----------------------------------------------------------------------===// 1307 1308 void ASTStmtReader::VisitCXXCatchStmt(CXXCatchStmt *S) { 1309 VisitStmt(S); 1310 S->CatchLoc = ReadSourceLocation(); 1311 S->ExceptionDecl = ReadDeclAs<VarDecl>(); 1312 S->HandlerBlock = Record.readSubStmt(); 1313 } 1314 1315 void ASTStmtReader::VisitCXXTryStmt(CXXTryStmt *S) { 1316 VisitStmt(S); 1317 assert(Record.peekInt() == S->getNumHandlers() && "NumStmtFields is wrong ?"); 1318 Record.skipInts(1); 1319 S->TryLoc = ReadSourceLocation(); 1320 S->getStmts()[0] = Record.readSubStmt(); 1321 for (unsigned i = 0, e = S->getNumHandlers(); i != e; ++i) 1322 S->getStmts()[i + 1] = Record.readSubStmt(); 1323 } 1324 1325 void ASTStmtReader::VisitCXXForRangeStmt(CXXForRangeStmt *S) { 1326 VisitStmt(S); 1327 S->ForLoc = ReadSourceLocation(); 1328 S->CoawaitLoc = ReadSourceLocation(); 1329 S->ColonLoc = ReadSourceLocation(); 1330 S->RParenLoc = ReadSourceLocation(); 1331 S->setInit(Record.readSubStmt()); 1332 S->setRangeStmt(Record.readSubStmt()); 1333 S->setBeginStmt(Record.readSubStmt()); 1334 S->setEndStmt(Record.readSubStmt()); 1335 S->setCond(Record.readSubExpr()); 1336 S->setInc(Record.readSubExpr()); 1337 S->setLoopVarStmt(Record.readSubStmt()); 1338 S->setBody(Record.readSubStmt()); 1339 } 1340 1341 void ASTStmtReader::VisitMSDependentExistsStmt(MSDependentExistsStmt *S) { 1342 VisitStmt(S); 1343 S->KeywordLoc = ReadSourceLocation(); 1344 S->IsIfExists = Record.readInt(); 1345 S->QualifierLoc = Record.readNestedNameSpecifierLoc(); 1346 ReadDeclarationNameInfo(S->NameInfo); 1347 S->SubStmt = Record.readSubStmt(); 1348 } 1349 1350 void ASTStmtReader::VisitCXXOperatorCallExpr(CXXOperatorCallExpr *E) { 1351 VisitCallExpr(E); 1352 E->CXXOperatorCallExprBits.OperatorKind = Record.readInt(); 1353 E->CXXOperatorCallExprBits.FPFeatures = Record.readInt(); 1354 E->Range = Record.readSourceRange(); 1355 } 1356 1357 void ASTStmtReader::VisitCXXConstructExpr(CXXConstructExpr *E) { 1358 VisitExpr(E); 1359 1360 unsigned NumArgs = Record.readInt(); 1361 assert((NumArgs == E->getNumArgs()) && "Wrong NumArgs!"); 1362 1363 E->CXXConstructExprBits.Elidable = Record.readInt(); 1364 E->CXXConstructExprBits.HadMultipleCandidates = Record.readInt(); 1365 E->CXXConstructExprBits.ListInitialization = Record.readInt(); 1366 E->CXXConstructExprBits.StdInitListInitialization = Record.readInt(); 1367 E->CXXConstructExprBits.ZeroInitialization = Record.readInt(); 1368 E->CXXConstructExprBits.ConstructionKind = Record.readInt(); 1369 E->CXXConstructExprBits.Loc = ReadSourceLocation(); 1370 E->Constructor = ReadDeclAs<CXXConstructorDecl>(); 1371 E->ParenOrBraceRange = ReadSourceRange(); 1372 1373 for (unsigned I = 0; I != NumArgs; ++I) 1374 E->setArg(I, Record.readSubExpr()); 1375 } 1376 1377 void ASTStmtReader::VisitCXXInheritedCtorInitExpr(CXXInheritedCtorInitExpr *E) { 1378 VisitExpr(E); 1379 E->Constructor = ReadDeclAs<CXXConstructorDecl>(); 1380 E->Loc = ReadSourceLocation(); 1381 E->ConstructsVirtualBase = Record.readInt(); 1382 E->InheritedFromVirtualBase = Record.readInt(); 1383 } 1384 1385 void ASTStmtReader::VisitCXXTemporaryObjectExpr(CXXTemporaryObjectExpr *E) { 1386 VisitCXXConstructExpr(E); 1387 E->TSI = GetTypeSourceInfo(); 1388 } 1389 1390 void ASTStmtReader::VisitLambdaExpr(LambdaExpr *E) { 1391 VisitExpr(E); 1392 unsigned NumCaptures = Record.readInt(); 1393 assert(NumCaptures == E->NumCaptures);(void)NumCaptures; 1394 E->IntroducerRange = ReadSourceRange(); 1395 E->CaptureDefault = static_cast<LambdaCaptureDefault>(Record.readInt()); 1396 E->CaptureDefaultLoc = ReadSourceLocation(); 1397 E->ExplicitParams = Record.readInt(); 1398 E->ExplicitResultType = Record.readInt(); 1399 E->ClosingBrace = ReadSourceLocation(); 1400 1401 // Read capture initializers. 1402 for (LambdaExpr::capture_init_iterator C = E->capture_init_begin(), 1403 CEnd = E->capture_init_end(); 1404 C != CEnd; ++C) 1405 *C = Record.readSubExpr(); 1406 } 1407 1408 void 1409 ASTStmtReader::VisitCXXStdInitializerListExpr(CXXStdInitializerListExpr *E) { 1410 VisitExpr(E); 1411 E->SubExpr = Record.readSubExpr(); 1412 } 1413 1414 void ASTStmtReader::VisitCXXNamedCastExpr(CXXNamedCastExpr *E) { 1415 VisitExplicitCastExpr(E); 1416 SourceRange R = ReadSourceRange(); 1417 E->Loc = R.getBegin(); 1418 E->RParenLoc = R.getEnd(); 1419 R = ReadSourceRange(); 1420 E->AngleBrackets = R; 1421 } 1422 1423 void ASTStmtReader::VisitCXXStaticCastExpr(CXXStaticCastExpr *E) { 1424 return VisitCXXNamedCastExpr(E); 1425 } 1426 1427 void ASTStmtReader::VisitCXXDynamicCastExpr(CXXDynamicCastExpr *E) { 1428 return VisitCXXNamedCastExpr(E); 1429 } 1430 1431 void ASTStmtReader::VisitCXXReinterpretCastExpr(CXXReinterpretCastExpr *E) { 1432 return VisitCXXNamedCastExpr(E); 1433 } 1434 1435 void ASTStmtReader::VisitCXXConstCastExpr(CXXConstCastExpr *E) { 1436 return VisitCXXNamedCastExpr(E); 1437 } 1438 1439 void ASTStmtReader::VisitCXXFunctionalCastExpr(CXXFunctionalCastExpr *E) { 1440 VisitExplicitCastExpr(E); 1441 E->setLParenLoc(ReadSourceLocation()); 1442 E->setRParenLoc(ReadSourceLocation()); 1443 } 1444 1445 void ASTStmtReader::VisitUserDefinedLiteral(UserDefinedLiteral *E) { 1446 VisitCallExpr(E); 1447 E->UDSuffixLoc = ReadSourceLocation(); 1448 } 1449 1450 void ASTStmtReader::VisitCXXBoolLiteralExpr(CXXBoolLiteralExpr *E) { 1451 VisitExpr(E); 1452 E->setValue(Record.readInt()); 1453 E->setLocation(ReadSourceLocation()); 1454 } 1455 1456 void ASTStmtReader::VisitCXXNullPtrLiteralExpr(CXXNullPtrLiteralExpr *E) { 1457 VisitExpr(E); 1458 E->setLocation(ReadSourceLocation()); 1459 } 1460 1461 void ASTStmtReader::VisitCXXTypeidExpr(CXXTypeidExpr *E) { 1462 VisitExpr(E); 1463 E->setSourceRange(ReadSourceRange()); 1464 if (E->isTypeOperand()) { // typeid(int) 1465 E->setTypeOperandSourceInfo( 1466 GetTypeSourceInfo()); 1467 return; 1468 } 1469 1470 // typeid(42+2) 1471 E->setExprOperand(Record.readSubExpr()); 1472 } 1473 1474 void ASTStmtReader::VisitCXXThisExpr(CXXThisExpr *E) { 1475 VisitExpr(E); 1476 E->setLocation(ReadSourceLocation()); 1477 E->setImplicit(Record.readInt()); 1478 } 1479 1480 void ASTStmtReader::VisitCXXThrowExpr(CXXThrowExpr *E) { 1481 VisitExpr(E); 1482 E->CXXThrowExprBits.ThrowLoc = ReadSourceLocation(); 1483 E->Operand = Record.readSubExpr(); 1484 E->CXXThrowExprBits.IsThrownVariableInScope = Record.readInt(); 1485 } 1486 1487 void ASTStmtReader::VisitCXXDefaultArgExpr(CXXDefaultArgExpr *E) { 1488 VisitExpr(E); 1489 E->Param = ReadDeclAs<ParmVarDecl>(); 1490 E->CXXDefaultArgExprBits.Loc = ReadSourceLocation(); 1491 } 1492 1493 void ASTStmtReader::VisitCXXDefaultInitExpr(CXXDefaultInitExpr *E) { 1494 VisitExpr(E); 1495 E->Field = ReadDeclAs<FieldDecl>(); 1496 E->CXXDefaultInitExprBits.Loc = ReadSourceLocation(); 1497 } 1498 1499 void ASTStmtReader::VisitCXXBindTemporaryExpr(CXXBindTemporaryExpr *E) { 1500 VisitExpr(E); 1501 E->setTemporary(Record.readCXXTemporary()); 1502 E->setSubExpr(Record.readSubExpr()); 1503 } 1504 1505 void ASTStmtReader::VisitCXXScalarValueInitExpr(CXXScalarValueInitExpr *E) { 1506 VisitExpr(E); 1507 E->TypeInfo = GetTypeSourceInfo(); 1508 E->CXXScalarValueInitExprBits.RParenLoc = ReadSourceLocation(); 1509 } 1510 1511 void ASTStmtReader::VisitCXXNewExpr(CXXNewExpr *E) { 1512 VisitExpr(E); 1513 1514 bool IsArray = Record.readInt(); 1515 bool HasInit = Record.readInt(); 1516 unsigned NumPlacementArgs = Record.readInt(); 1517 bool IsParenTypeId = Record.readInt(); 1518 1519 E->CXXNewExprBits.IsGlobalNew = Record.readInt(); 1520 E->CXXNewExprBits.ShouldPassAlignment = Record.readInt(); 1521 E->CXXNewExprBits.UsualArrayDeleteWantsSize = Record.readInt(); 1522 E->CXXNewExprBits.StoredInitializationStyle = Record.readInt(); 1523 1524 assert((IsArray == E->isArray()) && "Wrong IsArray!"); 1525 assert((HasInit == E->hasInitializer()) && "Wrong HasInit!"); 1526 assert((NumPlacementArgs == E->getNumPlacementArgs()) && 1527 "Wrong NumPlacementArgs!"); 1528 assert((IsParenTypeId == E->isParenTypeId()) && "Wrong IsParenTypeId!"); 1529 (void)IsArray; 1530 (void)HasInit; 1531 (void)NumPlacementArgs; 1532 1533 E->setOperatorNew(ReadDeclAs<FunctionDecl>()); 1534 E->setOperatorDelete(ReadDeclAs<FunctionDecl>()); 1535 E->AllocatedTypeInfo = GetTypeSourceInfo(); 1536 if (IsParenTypeId) 1537 E->getTrailingObjects<SourceRange>()[0] = ReadSourceRange(); 1538 E->Range = ReadSourceRange(); 1539 E->DirectInitRange = ReadSourceRange(); 1540 1541 // Install all the subexpressions. 1542 for (CXXNewExpr::raw_arg_iterator I = E->raw_arg_begin(), 1543 N = E->raw_arg_end(); 1544 I != N; ++I) 1545 *I = Record.readSubStmt(); 1546 } 1547 1548 void ASTStmtReader::VisitCXXDeleteExpr(CXXDeleteExpr *E) { 1549 VisitExpr(E); 1550 E->CXXDeleteExprBits.GlobalDelete = Record.readInt(); 1551 E->CXXDeleteExprBits.ArrayForm = Record.readInt(); 1552 E->CXXDeleteExprBits.ArrayFormAsWritten = Record.readInt(); 1553 E->CXXDeleteExprBits.UsualArrayDeleteWantsSize = Record.readInt(); 1554 E->OperatorDelete = ReadDeclAs<FunctionDecl>(); 1555 E->Argument = Record.readSubExpr(); 1556 E->CXXDeleteExprBits.Loc = ReadSourceLocation(); 1557 } 1558 1559 void ASTStmtReader::VisitCXXPseudoDestructorExpr(CXXPseudoDestructorExpr *E) { 1560 VisitExpr(E); 1561 1562 E->Base = Record.readSubExpr(); 1563 E->IsArrow = Record.readInt(); 1564 E->OperatorLoc = ReadSourceLocation(); 1565 E->QualifierLoc = Record.readNestedNameSpecifierLoc(); 1566 E->ScopeType = GetTypeSourceInfo(); 1567 E->ColonColonLoc = ReadSourceLocation(); 1568 E->TildeLoc = ReadSourceLocation(); 1569 1570 IdentifierInfo *II = Record.getIdentifierInfo(); 1571 if (II) 1572 E->setDestroyedType(II, ReadSourceLocation()); 1573 else 1574 E->setDestroyedType(GetTypeSourceInfo()); 1575 } 1576 1577 void ASTStmtReader::VisitExprWithCleanups(ExprWithCleanups *E) { 1578 VisitExpr(E); 1579 1580 unsigned NumObjects = Record.readInt(); 1581 assert(NumObjects == E->getNumObjects()); 1582 for (unsigned i = 0; i != NumObjects; ++i) 1583 E->getTrailingObjects<BlockDecl *>()[i] = 1584 ReadDeclAs<BlockDecl>(); 1585 1586 E->ExprWithCleanupsBits.CleanupsHaveSideEffects = Record.readInt(); 1587 E->SubExpr = Record.readSubExpr(); 1588 } 1589 1590 void ASTStmtReader::VisitCXXDependentScopeMemberExpr( 1591 CXXDependentScopeMemberExpr *E) { 1592 VisitExpr(E); 1593 1594 bool HasTemplateKWAndArgsInfo = Record.readInt(); 1595 unsigned NumTemplateArgs = Record.readInt(); 1596 bool HasFirstQualifierFoundInScope = Record.readInt(); 1597 1598 assert((HasTemplateKWAndArgsInfo == E->hasTemplateKWAndArgsInfo()) && 1599 "Wrong HasTemplateKWAndArgsInfo!"); 1600 assert( 1601 (HasFirstQualifierFoundInScope == E->hasFirstQualifierFoundInScope()) && 1602 "Wrong HasFirstQualifierFoundInScope!"); 1603 1604 if (HasTemplateKWAndArgsInfo) 1605 ReadTemplateKWAndArgsInfo( 1606 *E->getTrailingObjects<ASTTemplateKWAndArgsInfo>(), 1607 E->getTrailingObjects<TemplateArgumentLoc>(), NumTemplateArgs); 1608 1609 assert((NumTemplateArgs == E->getNumTemplateArgs()) && 1610 "Wrong NumTemplateArgs!"); 1611 1612 E->CXXDependentScopeMemberExprBits.IsArrow = Record.readInt(); 1613 E->CXXDependentScopeMemberExprBits.OperatorLoc = ReadSourceLocation(); 1614 E->BaseType = Record.readType(); 1615 E->QualifierLoc = Record.readNestedNameSpecifierLoc(); 1616 E->Base = Record.readSubExpr(); 1617 1618 if (HasFirstQualifierFoundInScope) 1619 *E->getTrailingObjects<NamedDecl *>() = ReadDeclAs<NamedDecl>(); 1620 1621 ReadDeclarationNameInfo(E->MemberNameInfo); 1622 } 1623 1624 void 1625 ASTStmtReader::VisitDependentScopeDeclRefExpr(DependentScopeDeclRefExpr *E) { 1626 VisitExpr(E); 1627 1628 if (Record.readInt()) // HasTemplateKWAndArgsInfo 1629 ReadTemplateKWAndArgsInfo( 1630 *E->getTrailingObjects<ASTTemplateKWAndArgsInfo>(), 1631 E->getTrailingObjects<TemplateArgumentLoc>(), 1632 /*NumTemplateArgs=*/Record.readInt()); 1633 1634 E->QualifierLoc = Record.readNestedNameSpecifierLoc(); 1635 ReadDeclarationNameInfo(E->NameInfo); 1636 } 1637 1638 void 1639 ASTStmtReader::VisitCXXUnresolvedConstructExpr(CXXUnresolvedConstructExpr *E) { 1640 VisitExpr(E); 1641 assert(Record.peekInt() == E->arg_size() && 1642 "Read wrong record during creation ?"); 1643 Record.skipInts(1); 1644 for (unsigned I = 0, N = E->arg_size(); I != N; ++I) 1645 E->setArg(I, Record.readSubExpr()); 1646 E->TSI = GetTypeSourceInfo(); 1647 E->setLParenLoc(ReadSourceLocation()); 1648 E->setRParenLoc(ReadSourceLocation()); 1649 } 1650 1651 void ASTStmtReader::VisitOverloadExpr(OverloadExpr *E) { 1652 VisitExpr(E); 1653 1654 unsigned NumResults = Record.readInt(); 1655 bool HasTemplateKWAndArgsInfo = Record.readInt(); 1656 assert((E->getNumDecls() == NumResults) && "Wrong NumResults!"); 1657 assert((E->hasTemplateKWAndArgsInfo() == HasTemplateKWAndArgsInfo) && 1658 "Wrong HasTemplateKWAndArgsInfo!"); 1659 1660 if (HasTemplateKWAndArgsInfo) { 1661 unsigned NumTemplateArgs = Record.readInt(); 1662 ReadTemplateKWAndArgsInfo(*E->getTrailingASTTemplateKWAndArgsInfo(), 1663 E->getTrailingTemplateArgumentLoc(), 1664 NumTemplateArgs); 1665 assert((E->getNumTemplateArgs() == NumTemplateArgs) && 1666 "Wrong NumTemplateArgs!"); 1667 } 1668 1669 UnresolvedSet<8> Decls; 1670 for (unsigned I = 0; I != NumResults; ++I) { 1671 auto *D = ReadDeclAs<NamedDecl>(); 1672 auto AS = (AccessSpecifier)Record.readInt(); 1673 Decls.addDecl(D, AS); 1674 } 1675 1676 DeclAccessPair *Results = E->getTrailingResults(); 1677 UnresolvedSetIterator Iter = Decls.begin(); 1678 for (unsigned I = 0; I != NumResults; ++I) { 1679 Results[I] = (Iter + I).getPair(); 1680 } 1681 1682 ReadDeclarationNameInfo(E->NameInfo); 1683 E->QualifierLoc = Record.readNestedNameSpecifierLoc(); 1684 } 1685 1686 void ASTStmtReader::VisitUnresolvedMemberExpr(UnresolvedMemberExpr *E) { 1687 VisitOverloadExpr(E); 1688 E->UnresolvedMemberExprBits.IsArrow = Record.readInt(); 1689 E->UnresolvedMemberExprBits.HasUnresolvedUsing = Record.readInt(); 1690 E->Base = Record.readSubExpr(); 1691 E->BaseType = Record.readType(); 1692 E->OperatorLoc = ReadSourceLocation(); 1693 } 1694 1695 void ASTStmtReader::VisitUnresolvedLookupExpr(UnresolvedLookupExpr *E) { 1696 VisitOverloadExpr(E); 1697 E->UnresolvedLookupExprBits.RequiresADL = Record.readInt(); 1698 E->UnresolvedLookupExprBits.Overloaded = Record.readInt(); 1699 E->NamingClass = ReadDeclAs<CXXRecordDecl>(); 1700 } 1701 1702 void ASTStmtReader::VisitTypeTraitExpr(TypeTraitExpr *E) { 1703 VisitExpr(E); 1704 E->TypeTraitExprBits.NumArgs = Record.readInt(); 1705 E->TypeTraitExprBits.Kind = Record.readInt(); 1706 E->TypeTraitExprBits.Value = Record.readInt(); 1707 SourceRange Range = ReadSourceRange(); 1708 E->Loc = Range.getBegin(); 1709 E->RParenLoc = Range.getEnd(); 1710 1711 auto **Args = E->getTrailingObjects<TypeSourceInfo *>(); 1712 for (unsigned I = 0, N = E->getNumArgs(); I != N; ++I) 1713 Args[I] = GetTypeSourceInfo(); 1714 } 1715 1716 void ASTStmtReader::VisitArrayTypeTraitExpr(ArrayTypeTraitExpr *E) { 1717 VisitExpr(E); 1718 E->ATT = (ArrayTypeTrait)Record.readInt(); 1719 E->Value = (unsigned int)Record.readInt(); 1720 SourceRange Range = ReadSourceRange(); 1721 E->Loc = Range.getBegin(); 1722 E->RParen = Range.getEnd(); 1723 E->QueriedType = GetTypeSourceInfo(); 1724 E->Dimension = Record.readSubExpr(); 1725 } 1726 1727 void ASTStmtReader::VisitExpressionTraitExpr(ExpressionTraitExpr *E) { 1728 VisitExpr(E); 1729 E->ET = (ExpressionTrait)Record.readInt(); 1730 E->Value = (bool)Record.readInt(); 1731 SourceRange Range = ReadSourceRange(); 1732 E->QueriedExpression = Record.readSubExpr(); 1733 E->Loc = Range.getBegin(); 1734 E->RParen = Range.getEnd(); 1735 } 1736 1737 void ASTStmtReader::VisitCXXNoexceptExpr(CXXNoexceptExpr *E) { 1738 VisitExpr(E); 1739 E->CXXNoexceptExprBits.Value = Record.readInt(); 1740 E->Range = ReadSourceRange(); 1741 E->Operand = Record.readSubExpr(); 1742 } 1743 1744 void ASTStmtReader::VisitPackExpansionExpr(PackExpansionExpr *E) { 1745 VisitExpr(E); 1746 E->EllipsisLoc = ReadSourceLocation(); 1747 E->NumExpansions = Record.readInt(); 1748 E->Pattern = Record.readSubExpr(); 1749 } 1750 1751 void ASTStmtReader::VisitSizeOfPackExpr(SizeOfPackExpr *E) { 1752 VisitExpr(E); 1753 unsigned NumPartialArgs = Record.readInt(); 1754 E->OperatorLoc = ReadSourceLocation(); 1755 E->PackLoc = ReadSourceLocation(); 1756 E->RParenLoc = ReadSourceLocation(); 1757 E->Pack = Record.readDeclAs<NamedDecl>(); 1758 if (E->isPartiallySubstituted()) { 1759 assert(E->Length == NumPartialArgs); 1760 for (auto *I = E->getTrailingObjects<TemplateArgument>(), 1761 *E = I + NumPartialArgs; 1762 I != E; ++I) 1763 new (I) TemplateArgument(Record.readTemplateArgument()); 1764 } else if (!E->isValueDependent()) { 1765 E->Length = Record.readInt(); 1766 } 1767 } 1768 1769 void ASTStmtReader::VisitSubstNonTypeTemplateParmExpr( 1770 SubstNonTypeTemplateParmExpr *E) { 1771 VisitExpr(E); 1772 E->Param = ReadDeclAs<NonTypeTemplateParmDecl>(); 1773 E->SubstNonTypeTemplateParmExprBits.NameLoc = ReadSourceLocation(); 1774 E->Replacement = Record.readSubExpr(); 1775 } 1776 1777 void ASTStmtReader::VisitSubstNonTypeTemplateParmPackExpr( 1778 SubstNonTypeTemplateParmPackExpr *E) { 1779 VisitExpr(E); 1780 E->Param = ReadDeclAs<NonTypeTemplateParmDecl>(); 1781 TemplateArgument ArgPack = Record.readTemplateArgument(); 1782 if (ArgPack.getKind() != TemplateArgument::Pack) 1783 return; 1784 1785 E->Arguments = ArgPack.pack_begin(); 1786 E->NumArguments = ArgPack.pack_size(); 1787 E->NameLoc = ReadSourceLocation(); 1788 } 1789 1790 void ASTStmtReader::VisitFunctionParmPackExpr(FunctionParmPackExpr *E) { 1791 VisitExpr(E); 1792 E->NumParameters = Record.readInt(); 1793 E->ParamPack = ReadDeclAs<ParmVarDecl>(); 1794 E->NameLoc = ReadSourceLocation(); 1795 auto **Parms = E->getTrailingObjects<ParmVarDecl *>(); 1796 for (unsigned i = 0, n = E->NumParameters; i != n; ++i) 1797 Parms[i] = ReadDeclAs<ParmVarDecl>(); 1798 } 1799 1800 void ASTStmtReader::VisitMaterializeTemporaryExpr(MaterializeTemporaryExpr *E) { 1801 VisitExpr(E); 1802 E->State = Record.readSubExpr(); 1803 auto *VD = ReadDeclAs<ValueDecl>(); 1804 unsigned ManglingNumber = Record.readInt(); 1805 E->setExtendingDecl(VD, ManglingNumber); 1806 } 1807 1808 void ASTStmtReader::VisitCXXFoldExpr(CXXFoldExpr *E) { 1809 VisitExpr(E); 1810 E->LParenLoc = ReadSourceLocation(); 1811 E->EllipsisLoc = ReadSourceLocation(); 1812 E->RParenLoc = ReadSourceLocation(); 1813 E->SubExprs[0] = Record.readSubExpr(); 1814 E->SubExprs[1] = Record.readSubExpr(); 1815 E->Opcode = (BinaryOperatorKind)Record.readInt(); 1816 } 1817 1818 void ASTStmtReader::VisitOpaqueValueExpr(OpaqueValueExpr *E) { 1819 VisitExpr(E); 1820 E->SourceExpr = Record.readSubExpr(); 1821 E->OpaqueValueExprBits.Loc = ReadSourceLocation(); 1822 E->setIsUnique(Record.readInt()); 1823 } 1824 1825 void ASTStmtReader::VisitTypoExpr(TypoExpr *E) { 1826 llvm_unreachable("Cannot read TypoExpr nodes"); 1827 } 1828 1829 //===----------------------------------------------------------------------===// 1830 // Microsoft Expressions and Statements 1831 //===----------------------------------------------------------------------===// 1832 void ASTStmtReader::VisitMSPropertyRefExpr(MSPropertyRefExpr *E) { 1833 VisitExpr(E); 1834 E->IsArrow = (Record.readInt() != 0); 1835 E->BaseExpr = Record.readSubExpr(); 1836 E->QualifierLoc = Record.readNestedNameSpecifierLoc(); 1837 E->MemberLoc = ReadSourceLocation(); 1838 E->TheDecl = ReadDeclAs<MSPropertyDecl>(); 1839 } 1840 1841 void ASTStmtReader::VisitMSPropertySubscriptExpr(MSPropertySubscriptExpr *E) { 1842 VisitExpr(E); 1843 E->setBase(Record.readSubExpr()); 1844 E->setIdx(Record.readSubExpr()); 1845 E->setRBracketLoc(ReadSourceLocation()); 1846 } 1847 1848 void ASTStmtReader::VisitCXXUuidofExpr(CXXUuidofExpr *E) { 1849 VisitExpr(E); 1850 E->setSourceRange(ReadSourceRange()); 1851 std::string UuidStr = ReadString(); 1852 E->setUuidStr(StringRef(UuidStr).copy(Record.getContext())); 1853 if (E->isTypeOperand()) { // __uuidof(ComType) 1854 E->setTypeOperandSourceInfo( 1855 GetTypeSourceInfo()); 1856 return; 1857 } 1858 1859 // __uuidof(expr) 1860 E->setExprOperand(Record.readSubExpr()); 1861 } 1862 1863 void ASTStmtReader::VisitSEHLeaveStmt(SEHLeaveStmt *S) { 1864 VisitStmt(S); 1865 S->setLeaveLoc(ReadSourceLocation()); 1866 } 1867 1868 void ASTStmtReader::VisitSEHExceptStmt(SEHExceptStmt *S) { 1869 VisitStmt(S); 1870 S->Loc = ReadSourceLocation(); 1871 S->Children[SEHExceptStmt::FILTER_EXPR] = Record.readSubStmt(); 1872 S->Children[SEHExceptStmt::BLOCK] = Record.readSubStmt(); 1873 } 1874 1875 void ASTStmtReader::VisitSEHFinallyStmt(SEHFinallyStmt *S) { 1876 VisitStmt(S); 1877 S->Loc = ReadSourceLocation(); 1878 S->Block = Record.readSubStmt(); 1879 } 1880 1881 void ASTStmtReader::VisitSEHTryStmt(SEHTryStmt *S) { 1882 VisitStmt(S); 1883 S->IsCXXTry = Record.readInt(); 1884 S->TryLoc = ReadSourceLocation(); 1885 S->Children[SEHTryStmt::TRY] = Record.readSubStmt(); 1886 S->Children[SEHTryStmt::HANDLER] = Record.readSubStmt(); 1887 } 1888 1889 //===----------------------------------------------------------------------===// 1890 // CUDA Expressions and Statements 1891 //===----------------------------------------------------------------------===// 1892 1893 void ASTStmtReader::VisitCUDAKernelCallExpr(CUDAKernelCallExpr *E) { 1894 VisitCallExpr(E); 1895 E->setConfig(cast<CallExpr>(Record.readSubExpr())); 1896 } 1897 1898 //===----------------------------------------------------------------------===// 1899 // OpenCL Expressions and Statements. 1900 //===----------------------------------------------------------------------===// 1901 void ASTStmtReader::VisitAsTypeExpr(AsTypeExpr *E) { 1902 VisitExpr(E); 1903 E->BuiltinLoc = ReadSourceLocation(); 1904 E->RParenLoc = ReadSourceLocation(); 1905 E->SrcExpr = Record.readSubExpr(); 1906 } 1907 1908 //===----------------------------------------------------------------------===// 1909 // OpenMP Directives. 1910 //===----------------------------------------------------------------------===// 1911 1912 void ASTStmtReader::VisitOMPExecutableDirective(OMPExecutableDirective *E) { 1913 E->setLocStart(ReadSourceLocation()); 1914 E->setLocEnd(ReadSourceLocation()); 1915 OMPClauseReader ClauseReader(Record); 1916 SmallVector<OMPClause *, 5> Clauses; 1917 for (unsigned i = 0; i < E->getNumClauses(); ++i) 1918 Clauses.push_back(ClauseReader.readClause()); 1919 E->setClauses(Clauses); 1920 if (E->hasAssociatedStmt()) 1921 E->setAssociatedStmt(Record.readSubStmt()); 1922 } 1923 1924 void ASTStmtReader::VisitOMPLoopDirective(OMPLoopDirective *D) { 1925 VisitStmt(D); 1926 // Two fields (NumClauses and CollapsedNum) were read in ReadStmtFromStream. 1927 Record.skipInts(2); 1928 VisitOMPExecutableDirective(D); 1929 D->setIterationVariable(Record.readSubExpr()); 1930 D->setLastIteration(Record.readSubExpr()); 1931 D->setCalcLastIteration(Record.readSubExpr()); 1932 D->setPreCond(Record.readSubExpr()); 1933 D->setCond(Record.readSubExpr()); 1934 D->setInit(Record.readSubExpr()); 1935 D->setInc(Record.readSubExpr()); 1936 D->setPreInits(Record.readSubStmt()); 1937 if (isOpenMPWorksharingDirective(D->getDirectiveKind()) || 1938 isOpenMPTaskLoopDirective(D->getDirectiveKind()) || 1939 isOpenMPDistributeDirective(D->getDirectiveKind())) { 1940 D->setIsLastIterVariable(Record.readSubExpr()); 1941 D->setLowerBoundVariable(Record.readSubExpr()); 1942 D->setUpperBoundVariable(Record.readSubExpr()); 1943 D->setStrideVariable(Record.readSubExpr()); 1944 D->setEnsureUpperBound(Record.readSubExpr()); 1945 D->setNextLowerBound(Record.readSubExpr()); 1946 D->setNextUpperBound(Record.readSubExpr()); 1947 D->setNumIterations(Record.readSubExpr()); 1948 } 1949 if (isOpenMPLoopBoundSharingDirective(D->getDirectiveKind())) { 1950 D->setPrevLowerBoundVariable(Record.readSubExpr()); 1951 D->setPrevUpperBoundVariable(Record.readSubExpr()); 1952 D->setDistInc(Record.readSubExpr()); 1953 D->setPrevEnsureUpperBound(Record.readSubExpr()); 1954 D->setCombinedLowerBoundVariable(Record.readSubExpr()); 1955 D->setCombinedUpperBoundVariable(Record.readSubExpr()); 1956 D->setCombinedEnsureUpperBound(Record.readSubExpr()); 1957 D->setCombinedInit(Record.readSubExpr()); 1958 D->setCombinedCond(Record.readSubExpr()); 1959 D->setCombinedNextLowerBound(Record.readSubExpr()); 1960 D->setCombinedNextUpperBound(Record.readSubExpr()); 1961 D->setCombinedDistCond(Record.readSubExpr()); 1962 D->setCombinedParForInDistCond(Record.readSubExpr()); 1963 } 1964 SmallVector<Expr *, 4> Sub; 1965 unsigned CollapsedNum = D->getCollapsedNumber(); 1966 Sub.reserve(CollapsedNum); 1967 for (unsigned i = 0; i < CollapsedNum; ++i) 1968 Sub.push_back(Record.readSubExpr()); 1969 D->setCounters(Sub); 1970 Sub.clear(); 1971 for (unsigned i = 0; i < CollapsedNum; ++i) 1972 Sub.push_back(Record.readSubExpr()); 1973 D->setPrivateCounters(Sub); 1974 Sub.clear(); 1975 for (unsigned i = 0; i < CollapsedNum; ++i) 1976 Sub.push_back(Record.readSubExpr()); 1977 D->setInits(Sub); 1978 Sub.clear(); 1979 for (unsigned i = 0; i < CollapsedNum; ++i) 1980 Sub.push_back(Record.readSubExpr()); 1981 D->setUpdates(Sub); 1982 Sub.clear(); 1983 for (unsigned i = 0; i < CollapsedNum; ++i) 1984 Sub.push_back(Record.readSubExpr()); 1985 D->setFinals(Sub); 1986 } 1987 1988 void ASTStmtReader::VisitOMPParallelDirective(OMPParallelDirective *D) { 1989 VisitStmt(D); 1990 // The NumClauses field was read in ReadStmtFromStream. 1991 Record.skipInts(1); 1992 VisitOMPExecutableDirective(D); 1993 D->setHasCancel(Record.readInt()); 1994 } 1995 1996 void ASTStmtReader::VisitOMPSimdDirective(OMPSimdDirective *D) { 1997 VisitOMPLoopDirective(D); 1998 } 1999 2000 void ASTStmtReader::VisitOMPForDirective(OMPForDirective *D) { 2001 VisitOMPLoopDirective(D); 2002 D->setHasCancel(Record.readInt()); 2003 } 2004 2005 void ASTStmtReader::VisitOMPForSimdDirective(OMPForSimdDirective *D) { 2006 VisitOMPLoopDirective(D); 2007 } 2008 2009 void ASTStmtReader::VisitOMPSectionsDirective(OMPSectionsDirective *D) { 2010 VisitStmt(D); 2011 // The NumClauses field was read in ReadStmtFromStream. 2012 Record.skipInts(1); 2013 VisitOMPExecutableDirective(D); 2014 D->setHasCancel(Record.readInt()); 2015 } 2016 2017 void ASTStmtReader::VisitOMPSectionDirective(OMPSectionDirective *D) { 2018 VisitStmt(D); 2019 VisitOMPExecutableDirective(D); 2020 D->setHasCancel(Record.readInt()); 2021 } 2022 2023 void ASTStmtReader::VisitOMPSingleDirective(OMPSingleDirective *D) { 2024 VisitStmt(D); 2025 // The NumClauses field was read in ReadStmtFromStream. 2026 Record.skipInts(1); 2027 VisitOMPExecutableDirective(D); 2028 } 2029 2030 void ASTStmtReader::VisitOMPMasterDirective(OMPMasterDirective *D) { 2031 VisitStmt(D); 2032 VisitOMPExecutableDirective(D); 2033 } 2034 2035 void ASTStmtReader::VisitOMPCriticalDirective(OMPCriticalDirective *D) { 2036 VisitStmt(D); 2037 // The NumClauses field was read in ReadStmtFromStream. 2038 Record.skipInts(1); 2039 VisitOMPExecutableDirective(D); 2040 ReadDeclarationNameInfo(D->DirName); 2041 } 2042 2043 void ASTStmtReader::VisitOMPParallelForDirective(OMPParallelForDirective *D) { 2044 VisitOMPLoopDirective(D); 2045 D->setHasCancel(Record.readInt()); 2046 } 2047 2048 void ASTStmtReader::VisitOMPParallelForSimdDirective( 2049 OMPParallelForSimdDirective *D) { 2050 VisitOMPLoopDirective(D); 2051 } 2052 2053 void ASTStmtReader::VisitOMPParallelSectionsDirective( 2054 OMPParallelSectionsDirective *D) { 2055 VisitStmt(D); 2056 // The NumClauses field was read in ReadStmtFromStream. 2057 Record.skipInts(1); 2058 VisitOMPExecutableDirective(D); 2059 D->setHasCancel(Record.readInt()); 2060 } 2061 2062 void ASTStmtReader::VisitOMPTaskDirective(OMPTaskDirective *D) { 2063 VisitStmt(D); 2064 // The NumClauses field was read in ReadStmtFromStream. 2065 Record.skipInts(1); 2066 VisitOMPExecutableDirective(D); 2067 D->setHasCancel(Record.readInt()); 2068 } 2069 2070 void ASTStmtReader::VisitOMPTaskyieldDirective(OMPTaskyieldDirective *D) { 2071 VisitStmt(D); 2072 VisitOMPExecutableDirective(D); 2073 } 2074 2075 void ASTStmtReader::VisitOMPBarrierDirective(OMPBarrierDirective *D) { 2076 VisitStmt(D); 2077 VisitOMPExecutableDirective(D); 2078 } 2079 2080 void ASTStmtReader::VisitOMPTaskwaitDirective(OMPTaskwaitDirective *D) { 2081 VisitStmt(D); 2082 VisitOMPExecutableDirective(D); 2083 } 2084 2085 void ASTStmtReader::VisitOMPTaskgroupDirective(OMPTaskgroupDirective *D) { 2086 VisitStmt(D); 2087 // The NumClauses field was read in ReadStmtFromStream. 2088 Record.skipInts(1); 2089 VisitOMPExecutableDirective(D); 2090 D->setReductionRef(Record.readSubExpr()); 2091 } 2092 2093 void ASTStmtReader::VisitOMPFlushDirective(OMPFlushDirective *D) { 2094 VisitStmt(D); 2095 // The NumClauses field was read in ReadStmtFromStream. 2096 Record.skipInts(1); 2097 VisitOMPExecutableDirective(D); 2098 } 2099 2100 void ASTStmtReader::VisitOMPOrderedDirective(OMPOrderedDirective *D) { 2101 VisitStmt(D); 2102 // The NumClauses field was read in ReadStmtFromStream. 2103 Record.skipInts(1); 2104 VisitOMPExecutableDirective(D); 2105 } 2106 2107 void ASTStmtReader::VisitOMPAtomicDirective(OMPAtomicDirective *D) { 2108 VisitStmt(D); 2109 // The NumClauses field was read in ReadStmtFromStream. 2110 Record.skipInts(1); 2111 VisitOMPExecutableDirective(D); 2112 D->setX(Record.readSubExpr()); 2113 D->setV(Record.readSubExpr()); 2114 D->setExpr(Record.readSubExpr()); 2115 D->setUpdateExpr(Record.readSubExpr()); 2116 D->IsXLHSInRHSPart = Record.readInt() != 0; 2117 D->IsPostfixUpdate = Record.readInt() != 0; 2118 } 2119 2120 void ASTStmtReader::VisitOMPTargetDirective(OMPTargetDirective *D) { 2121 VisitStmt(D); 2122 // The NumClauses field was read in ReadStmtFromStream. 2123 Record.skipInts(1); 2124 VisitOMPExecutableDirective(D); 2125 } 2126 2127 void ASTStmtReader::VisitOMPTargetDataDirective(OMPTargetDataDirective *D) { 2128 VisitStmt(D); 2129 Record.skipInts(1); 2130 VisitOMPExecutableDirective(D); 2131 } 2132 2133 void ASTStmtReader::VisitOMPTargetEnterDataDirective( 2134 OMPTargetEnterDataDirective *D) { 2135 VisitStmt(D); 2136 Record.skipInts(1); 2137 VisitOMPExecutableDirective(D); 2138 } 2139 2140 void ASTStmtReader::VisitOMPTargetExitDataDirective( 2141 OMPTargetExitDataDirective *D) { 2142 VisitStmt(D); 2143 Record.skipInts(1); 2144 VisitOMPExecutableDirective(D); 2145 } 2146 2147 void ASTStmtReader::VisitOMPTargetParallelDirective( 2148 OMPTargetParallelDirective *D) { 2149 VisitStmt(D); 2150 Record.skipInts(1); 2151 VisitOMPExecutableDirective(D); 2152 } 2153 2154 void ASTStmtReader::VisitOMPTargetParallelForDirective( 2155 OMPTargetParallelForDirective *D) { 2156 VisitOMPLoopDirective(D); 2157 D->setHasCancel(Record.readInt()); 2158 } 2159 2160 void ASTStmtReader::VisitOMPTeamsDirective(OMPTeamsDirective *D) { 2161 VisitStmt(D); 2162 // The NumClauses field was read in ReadStmtFromStream. 2163 Record.skipInts(1); 2164 VisitOMPExecutableDirective(D); 2165 } 2166 2167 void ASTStmtReader::VisitOMPCancellationPointDirective( 2168 OMPCancellationPointDirective *D) { 2169 VisitStmt(D); 2170 VisitOMPExecutableDirective(D); 2171 D->setCancelRegion(static_cast<OpenMPDirectiveKind>(Record.readInt())); 2172 } 2173 2174 void ASTStmtReader::VisitOMPCancelDirective(OMPCancelDirective *D) { 2175 VisitStmt(D); 2176 // The NumClauses field was read in ReadStmtFromStream. 2177 Record.skipInts(1); 2178 VisitOMPExecutableDirective(D); 2179 D->setCancelRegion(static_cast<OpenMPDirectiveKind>(Record.readInt())); 2180 } 2181 2182 void ASTStmtReader::VisitOMPTaskLoopDirective(OMPTaskLoopDirective *D) { 2183 VisitOMPLoopDirective(D); 2184 } 2185 2186 void ASTStmtReader::VisitOMPTaskLoopSimdDirective(OMPTaskLoopSimdDirective *D) { 2187 VisitOMPLoopDirective(D); 2188 } 2189 2190 void ASTStmtReader::VisitOMPDistributeDirective(OMPDistributeDirective *D) { 2191 VisitOMPLoopDirective(D); 2192 } 2193 2194 void ASTStmtReader::VisitOMPTargetUpdateDirective(OMPTargetUpdateDirective *D) { 2195 VisitStmt(D); 2196 Record.skipInts(1); 2197 VisitOMPExecutableDirective(D); 2198 } 2199 2200 void ASTStmtReader::VisitOMPDistributeParallelForDirective( 2201 OMPDistributeParallelForDirective *D) { 2202 VisitOMPLoopDirective(D); 2203 D->setHasCancel(Record.readInt()); 2204 } 2205 2206 void ASTStmtReader::VisitOMPDistributeParallelForSimdDirective( 2207 OMPDistributeParallelForSimdDirective *D) { 2208 VisitOMPLoopDirective(D); 2209 } 2210 2211 void ASTStmtReader::VisitOMPDistributeSimdDirective( 2212 OMPDistributeSimdDirective *D) { 2213 VisitOMPLoopDirective(D); 2214 } 2215 2216 void ASTStmtReader::VisitOMPTargetParallelForSimdDirective( 2217 OMPTargetParallelForSimdDirective *D) { 2218 VisitOMPLoopDirective(D); 2219 } 2220 2221 void ASTStmtReader::VisitOMPTargetSimdDirective(OMPTargetSimdDirective *D) { 2222 VisitOMPLoopDirective(D); 2223 } 2224 2225 void ASTStmtReader::VisitOMPTeamsDistributeDirective( 2226 OMPTeamsDistributeDirective *D) { 2227 VisitOMPLoopDirective(D); 2228 } 2229 2230 void ASTStmtReader::VisitOMPTeamsDistributeSimdDirective( 2231 OMPTeamsDistributeSimdDirective *D) { 2232 VisitOMPLoopDirective(D); 2233 } 2234 2235 void ASTStmtReader::VisitOMPTeamsDistributeParallelForSimdDirective( 2236 OMPTeamsDistributeParallelForSimdDirective *D) { 2237 VisitOMPLoopDirective(D); 2238 } 2239 2240 void ASTStmtReader::VisitOMPTeamsDistributeParallelForDirective( 2241 OMPTeamsDistributeParallelForDirective *D) { 2242 VisitOMPLoopDirective(D); 2243 D->setHasCancel(Record.readInt()); 2244 } 2245 2246 void ASTStmtReader::VisitOMPTargetTeamsDirective(OMPTargetTeamsDirective *D) { 2247 VisitStmt(D); 2248 // The NumClauses field was read in ReadStmtFromStream. 2249 Record.skipInts(1); 2250 VisitOMPExecutableDirective(D); 2251 } 2252 2253 void ASTStmtReader::VisitOMPTargetTeamsDistributeDirective( 2254 OMPTargetTeamsDistributeDirective *D) { 2255 VisitOMPLoopDirective(D); 2256 } 2257 2258 void ASTStmtReader::VisitOMPTargetTeamsDistributeParallelForDirective( 2259 OMPTargetTeamsDistributeParallelForDirective *D) { 2260 VisitOMPLoopDirective(D); 2261 D->setHasCancel(Record.readInt()); 2262 } 2263 2264 void ASTStmtReader::VisitOMPTargetTeamsDistributeParallelForSimdDirective( 2265 OMPTargetTeamsDistributeParallelForSimdDirective *D) { 2266 VisitOMPLoopDirective(D); 2267 } 2268 2269 void ASTStmtReader::VisitOMPTargetTeamsDistributeSimdDirective( 2270 OMPTargetTeamsDistributeSimdDirective *D) { 2271 VisitOMPLoopDirective(D); 2272 } 2273 2274 //===----------------------------------------------------------------------===// 2275 // ASTReader Implementation 2276 //===----------------------------------------------------------------------===// 2277 2278 Stmt *ASTReader::ReadStmt(ModuleFile &F) { 2279 switch (ReadingKind) { 2280 case Read_None: 2281 llvm_unreachable("should not call this when not reading anything"); 2282 case Read_Decl: 2283 case Read_Type: 2284 return ReadStmtFromStream(F); 2285 case Read_Stmt: 2286 return ReadSubStmt(); 2287 } 2288 2289 llvm_unreachable("ReadingKind not set ?"); 2290 } 2291 2292 Expr *ASTReader::ReadExpr(ModuleFile &F) { 2293 return cast_or_null<Expr>(ReadStmt(F)); 2294 } 2295 2296 Expr *ASTReader::ReadSubExpr() { 2297 return cast_or_null<Expr>(ReadSubStmt()); 2298 } 2299 2300 // Within the bitstream, expressions are stored in Reverse Polish 2301 // Notation, with each of the subexpressions preceding the 2302 // expression they are stored in. Subexpressions are stored from last to first. 2303 // To evaluate expressions, we continue reading expressions and placing them on 2304 // the stack, with expressions having operands removing those operands from the 2305 // stack. Evaluation terminates when we see a STMT_STOP record, and 2306 // the single remaining expression on the stack is our result. 2307 Stmt *ASTReader::ReadStmtFromStream(ModuleFile &F) { 2308 ReadingKindTracker ReadingKind(Read_Stmt, *this); 2309 llvm::BitstreamCursor &Cursor = F.DeclsCursor; 2310 2311 // Map of offset to previously deserialized stmt. The offset points 2312 // just after the stmt record. 2313 llvm::DenseMap<uint64_t, Stmt *> StmtEntries; 2314 2315 #ifndef NDEBUG 2316 unsigned PrevNumStmts = StmtStack.size(); 2317 #endif 2318 2319 ASTRecordReader Record(*this, F); 2320 ASTStmtReader Reader(Record, Cursor); 2321 Stmt::EmptyShell Empty; 2322 2323 while (true) { 2324 llvm::BitstreamEntry Entry = Cursor.advanceSkippingSubblocks(); 2325 2326 switch (Entry.Kind) { 2327 case llvm::BitstreamEntry::SubBlock: // Handled for us already. 2328 case llvm::BitstreamEntry::Error: 2329 Error("malformed block record in AST file"); 2330 return nullptr; 2331 case llvm::BitstreamEntry::EndBlock: 2332 goto Done; 2333 case llvm::BitstreamEntry::Record: 2334 // The interesting case. 2335 break; 2336 } 2337 2338 ASTContext &Context = getContext(); 2339 Stmt *S = nullptr; 2340 bool Finished = false; 2341 bool IsStmtReference = false; 2342 switch ((StmtCode)Record.readRecord(Cursor, Entry.ID)) { 2343 case STMT_STOP: 2344 Finished = true; 2345 break; 2346 2347 case STMT_REF_PTR: 2348 IsStmtReference = true; 2349 assert(StmtEntries.find(Record[0]) != StmtEntries.end() && 2350 "No stmt was recorded for this offset reference!"); 2351 S = StmtEntries[Record.readInt()]; 2352 break; 2353 2354 case STMT_NULL_PTR: 2355 S = nullptr; 2356 break; 2357 2358 case STMT_NULL: 2359 S = new (Context) NullStmt(Empty); 2360 break; 2361 2362 case STMT_COMPOUND: 2363 S = CompoundStmt::CreateEmpty( 2364 Context, /*NumStmts=*/Record[ASTStmtReader::NumStmtFields]); 2365 break; 2366 2367 case STMT_CASE: 2368 S = CaseStmt::CreateEmpty( 2369 Context, 2370 /*CaseStmtIsGNURange*/ Record[ASTStmtReader::NumStmtFields + 3]); 2371 break; 2372 2373 case STMT_DEFAULT: 2374 S = new (Context) DefaultStmt(Empty); 2375 break; 2376 2377 case STMT_LABEL: 2378 S = new (Context) LabelStmt(Empty); 2379 break; 2380 2381 case STMT_ATTRIBUTED: 2382 S = AttributedStmt::CreateEmpty( 2383 Context, 2384 /*NumAttrs*/Record[ASTStmtReader::NumStmtFields]); 2385 break; 2386 2387 case STMT_IF: 2388 S = IfStmt::CreateEmpty( 2389 Context, 2390 /* HasElse=*/Record[ASTStmtReader::NumStmtFields + 1], 2391 /* HasVar=*/Record[ASTStmtReader::NumStmtFields + 2], 2392 /* HasInit=*/Record[ASTStmtReader::NumStmtFields + 3]); 2393 break; 2394 2395 case STMT_SWITCH: 2396 S = SwitchStmt::CreateEmpty( 2397 Context, 2398 /* HasInit=*/Record[ASTStmtReader::NumStmtFields], 2399 /* HasVar=*/Record[ASTStmtReader::NumStmtFields + 1]); 2400 break; 2401 2402 case STMT_WHILE: 2403 S = WhileStmt::CreateEmpty( 2404 Context, 2405 /* HasVar=*/Record[ASTStmtReader::NumStmtFields]); 2406 break; 2407 2408 case STMT_DO: 2409 S = new (Context) DoStmt(Empty); 2410 break; 2411 2412 case STMT_FOR: 2413 S = new (Context) ForStmt(Empty); 2414 break; 2415 2416 case STMT_GOTO: 2417 S = new (Context) GotoStmt(Empty); 2418 break; 2419 2420 case STMT_INDIRECT_GOTO: 2421 S = new (Context) IndirectGotoStmt(Empty); 2422 break; 2423 2424 case STMT_CONTINUE: 2425 S = new (Context) ContinueStmt(Empty); 2426 break; 2427 2428 case STMT_BREAK: 2429 S = new (Context) BreakStmt(Empty); 2430 break; 2431 2432 case STMT_RETURN: 2433 S = ReturnStmt::CreateEmpty( 2434 Context, /* HasNRVOCandidate=*/Record[ASTStmtReader::NumStmtFields]); 2435 break; 2436 2437 case STMT_DECL: 2438 S = new (Context) DeclStmt(Empty); 2439 break; 2440 2441 case STMT_GCCASM: 2442 S = new (Context) GCCAsmStmt(Empty); 2443 break; 2444 2445 case STMT_MSASM: 2446 S = new (Context) MSAsmStmt(Empty); 2447 break; 2448 2449 case STMT_CAPTURED: 2450 S = CapturedStmt::CreateDeserialized( 2451 Context, Record[ASTStmtReader::NumStmtFields]); 2452 break; 2453 2454 case EXPR_CONSTANT: 2455 S = new (Context) ConstantExpr(Empty); 2456 break; 2457 2458 case EXPR_PREDEFINED: 2459 S = PredefinedExpr::CreateEmpty( 2460 Context, 2461 /*HasFunctionName*/ Record[ASTStmtReader::NumExprFields]); 2462 break; 2463 2464 case EXPR_DECL_REF: 2465 S = DeclRefExpr::CreateEmpty( 2466 Context, 2467 /*HasQualifier=*/Record[ASTStmtReader::NumExprFields], 2468 /*HasFoundDecl=*/Record[ASTStmtReader::NumExprFields + 1], 2469 /*HasTemplateKWAndArgsInfo=*/Record[ASTStmtReader::NumExprFields + 2], 2470 /*NumTemplateArgs=*/Record[ASTStmtReader::NumExprFields + 2] ? 2471 Record[ASTStmtReader::NumExprFields + 5] : 0); 2472 break; 2473 2474 case EXPR_INTEGER_LITERAL: 2475 S = IntegerLiteral::Create(Context, Empty); 2476 break; 2477 2478 case EXPR_FLOATING_LITERAL: 2479 S = FloatingLiteral::Create(Context, Empty); 2480 break; 2481 2482 case EXPR_IMAGINARY_LITERAL: 2483 S = new (Context) ImaginaryLiteral(Empty); 2484 break; 2485 2486 case EXPR_STRING_LITERAL: 2487 S = StringLiteral::CreateEmpty( 2488 Context, 2489 /* NumConcatenated=*/Record[ASTStmtReader::NumExprFields], 2490 /* Length=*/Record[ASTStmtReader::NumExprFields + 1], 2491 /* CharByteWidth=*/Record[ASTStmtReader::NumExprFields + 2]); 2492 break; 2493 2494 case EXPR_CHARACTER_LITERAL: 2495 S = new (Context) CharacterLiteral(Empty); 2496 break; 2497 2498 case EXPR_PAREN: 2499 S = new (Context) ParenExpr(Empty); 2500 break; 2501 2502 case EXPR_PAREN_LIST: 2503 S = ParenListExpr::CreateEmpty( 2504 Context, 2505 /* NumExprs=*/Record[ASTStmtReader::NumExprFields]); 2506 break; 2507 2508 case EXPR_UNARY_OPERATOR: 2509 S = new (Context) UnaryOperator(Empty); 2510 break; 2511 2512 case EXPR_OFFSETOF: 2513 S = OffsetOfExpr::CreateEmpty(Context, 2514 Record[ASTStmtReader::NumExprFields], 2515 Record[ASTStmtReader::NumExprFields + 1]); 2516 break; 2517 2518 case EXPR_SIZEOF_ALIGN_OF: 2519 S = new (Context) UnaryExprOrTypeTraitExpr(Empty); 2520 break; 2521 2522 case EXPR_ARRAY_SUBSCRIPT: 2523 S = new (Context) ArraySubscriptExpr(Empty); 2524 break; 2525 2526 case EXPR_OMP_ARRAY_SECTION: 2527 S = new (Context) OMPArraySectionExpr(Empty); 2528 break; 2529 2530 case EXPR_CALL: 2531 S = CallExpr::CreateEmpty( 2532 Context, /*NumArgs=*/Record[ASTStmtReader::NumExprFields], Empty); 2533 break; 2534 2535 case EXPR_MEMBER: { 2536 // We load everything here and fully initialize it at creation. 2537 // That way we can use MemberExpr::Create and don't have to duplicate its 2538 // logic with a MemberExpr::CreateEmpty. 2539 2540 assert(Record.getIdx() == 0); 2541 NestedNameSpecifierLoc QualifierLoc; 2542 if (Record.readInt()) { // HasQualifier. 2543 QualifierLoc = Record.readNestedNameSpecifierLoc(); 2544 } 2545 2546 SourceLocation TemplateKWLoc; 2547 TemplateArgumentListInfo ArgInfo; 2548 bool HasTemplateKWAndArgsInfo = Record.readInt(); 2549 if (HasTemplateKWAndArgsInfo) { 2550 TemplateKWLoc = Record.readSourceLocation(); 2551 unsigned NumTemplateArgs = Record.readInt(); 2552 ArgInfo.setLAngleLoc(Record.readSourceLocation()); 2553 ArgInfo.setRAngleLoc(Record.readSourceLocation()); 2554 for (unsigned i = 0; i != NumTemplateArgs; ++i) 2555 ArgInfo.addArgument(Record.readTemplateArgumentLoc()); 2556 } 2557 2558 bool HadMultipleCandidates = Record.readInt(); 2559 2560 auto *FoundD = Record.readDeclAs<NamedDecl>(); 2561 auto AS = (AccessSpecifier)Record.readInt(); 2562 DeclAccessPair FoundDecl = DeclAccessPair::make(FoundD, AS); 2563 2564 QualType T = Record.readType(); 2565 auto VK = static_cast<ExprValueKind>(Record.readInt()); 2566 auto OK = static_cast<ExprObjectKind>(Record.readInt()); 2567 Expr *Base = ReadSubExpr(); 2568 auto *MemberD = Record.readDeclAs<ValueDecl>(); 2569 SourceLocation MemberLoc = Record.readSourceLocation(); 2570 DeclarationNameInfo MemberNameInfo(MemberD->getDeclName(), MemberLoc); 2571 bool IsArrow = Record.readInt(); 2572 SourceLocation OperatorLoc = Record.readSourceLocation(); 2573 2574 S = MemberExpr::Create(Context, Base, IsArrow, OperatorLoc, QualifierLoc, 2575 TemplateKWLoc, MemberD, FoundDecl, MemberNameInfo, 2576 HasTemplateKWAndArgsInfo ? &ArgInfo : nullptr, T, 2577 VK, OK); 2578 Record.readDeclarationNameLoc(cast<MemberExpr>(S)->MemberDNLoc, 2579 MemberD->getDeclName()); 2580 if (HadMultipleCandidates) 2581 cast<MemberExpr>(S)->setHadMultipleCandidates(true); 2582 break; 2583 } 2584 2585 case EXPR_BINARY_OPERATOR: 2586 S = new (Context) BinaryOperator(Empty); 2587 break; 2588 2589 case EXPR_COMPOUND_ASSIGN_OPERATOR: 2590 S = new (Context) CompoundAssignOperator(Empty); 2591 break; 2592 2593 case EXPR_CONDITIONAL_OPERATOR: 2594 S = new (Context) ConditionalOperator(Empty); 2595 break; 2596 2597 case EXPR_BINARY_CONDITIONAL_OPERATOR: 2598 S = new (Context) BinaryConditionalOperator(Empty); 2599 break; 2600 2601 case EXPR_IMPLICIT_CAST: 2602 S = ImplicitCastExpr::CreateEmpty(Context, 2603 /*PathSize*/ Record[ASTStmtReader::NumExprFields]); 2604 break; 2605 2606 case EXPR_CSTYLE_CAST: 2607 S = CStyleCastExpr::CreateEmpty(Context, 2608 /*PathSize*/ Record[ASTStmtReader::NumExprFields]); 2609 break; 2610 2611 case EXPR_COMPOUND_LITERAL: 2612 S = new (Context) CompoundLiteralExpr(Empty); 2613 break; 2614 2615 case EXPR_EXT_VECTOR_ELEMENT: 2616 S = new (Context) ExtVectorElementExpr(Empty); 2617 break; 2618 2619 case EXPR_INIT_LIST: 2620 S = new (Context) InitListExpr(Empty); 2621 break; 2622 2623 case EXPR_DESIGNATED_INIT: 2624 S = DesignatedInitExpr::CreateEmpty(Context, 2625 Record[ASTStmtReader::NumExprFields] - 1); 2626 2627 break; 2628 2629 case EXPR_DESIGNATED_INIT_UPDATE: 2630 S = new (Context) DesignatedInitUpdateExpr(Empty); 2631 break; 2632 2633 case EXPR_IMPLICIT_VALUE_INIT: 2634 S = new (Context) ImplicitValueInitExpr(Empty); 2635 break; 2636 2637 case EXPR_NO_INIT: 2638 S = new (Context) NoInitExpr(Empty); 2639 break; 2640 2641 case EXPR_ARRAY_INIT_LOOP: 2642 S = new (Context) ArrayInitLoopExpr(Empty); 2643 break; 2644 2645 case EXPR_ARRAY_INIT_INDEX: 2646 S = new (Context) ArrayInitIndexExpr(Empty); 2647 break; 2648 2649 case EXPR_VA_ARG: 2650 S = new (Context) VAArgExpr(Empty); 2651 break; 2652 2653 case EXPR_ADDR_LABEL: 2654 S = new (Context) AddrLabelExpr(Empty); 2655 break; 2656 2657 case EXPR_STMT: 2658 S = new (Context) StmtExpr(Empty); 2659 break; 2660 2661 case EXPR_CHOOSE: 2662 S = new (Context) ChooseExpr(Empty); 2663 break; 2664 2665 case EXPR_GNU_NULL: 2666 S = new (Context) GNUNullExpr(Empty); 2667 break; 2668 2669 case EXPR_SHUFFLE_VECTOR: 2670 S = new (Context) ShuffleVectorExpr(Empty); 2671 break; 2672 2673 case EXPR_CONVERT_VECTOR: 2674 S = new (Context) ConvertVectorExpr(Empty); 2675 break; 2676 2677 case EXPR_BLOCK: 2678 S = new (Context) BlockExpr(Empty); 2679 break; 2680 2681 case EXPR_GENERIC_SELECTION: 2682 S = GenericSelectionExpr::CreateEmpty( 2683 Context, 2684 /*NumAssocs=*/Record[ASTStmtReader::NumExprFields]); 2685 break; 2686 2687 case EXPR_OBJC_STRING_LITERAL: 2688 S = new (Context) ObjCStringLiteral(Empty); 2689 break; 2690 2691 case EXPR_OBJC_BOXED_EXPRESSION: 2692 S = new (Context) ObjCBoxedExpr(Empty); 2693 break; 2694 2695 case EXPR_OBJC_ARRAY_LITERAL: 2696 S = ObjCArrayLiteral::CreateEmpty(Context, 2697 Record[ASTStmtReader::NumExprFields]); 2698 break; 2699 2700 case EXPR_OBJC_DICTIONARY_LITERAL: 2701 S = ObjCDictionaryLiteral::CreateEmpty(Context, 2702 Record[ASTStmtReader::NumExprFields], 2703 Record[ASTStmtReader::NumExprFields + 1]); 2704 break; 2705 2706 case EXPR_OBJC_ENCODE: 2707 S = new (Context) ObjCEncodeExpr(Empty); 2708 break; 2709 2710 case EXPR_OBJC_SELECTOR_EXPR: 2711 S = new (Context) ObjCSelectorExpr(Empty); 2712 break; 2713 2714 case EXPR_OBJC_PROTOCOL_EXPR: 2715 S = new (Context) ObjCProtocolExpr(Empty); 2716 break; 2717 2718 case EXPR_OBJC_IVAR_REF_EXPR: 2719 S = new (Context) ObjCIvarRefExpr(Empty); 2720 break; 2721 2722 case EXPR_OBJC_PROPERTY_REF_EXPR: 2723 S = new (Context) ObjCPropertyRefExpr(Empty); 2724 break; 2725 2726 case EXPR_OBJC_SUBSCRIPT_REF_EXPR: 2727 S = new (Context) ObjCSubscriptRefExpr(Empty); 2728 break; 2729 2730 case EXPR_OBJC_KVC_REF_EXPR: 2731 llvm_unreachable("mismatching AST file"); 2732 2733 case EXPR_OBJC_MESSAGE_EXPR: 2734 S = ObjCMessageExpr::CreateEmpty(Context, 2735 Record[ASTStmtReader::NumExprFields], 2736 Record[ASTStmtReader::NumExprFields + 1]); 2737 break; 2738 2739 case EXPR_OBJC_ISA: 2740 S = new (Context) ObjCIsaExpr(Empty); 2741 break; 2742 2743 case EXPR_OBJC_INDIRECT_COPY_RESTORE: 2744 S = new (Context) ObjCIndirectCopyRestoreExpr(Empty); 2745 break; 2746 2747 case EXPR_OBJC_BRIDGED_CAST: 2748 S = new (Context) ObjCBridgedCastExpr(Empty); 2749 break; 2750 2751 case STMT_OBJC_FOR_COLLECTION: 2752 S = new (Context) ObjCForCollectionStmt(Empty); 2753 break; 2754 2755 case STMT_OBJC_CATCH: 2756 S = new (Context) ObjCAtCatchStmt(Empty); 2757 break; 2758 2759 case STMT_OBJC_FINALLY: 2760 S = new (Context) ObjCAtFinallyStmt(Empty); 2761 break; 2762 2763 case STMT_OBJC_AT_TRY: 2764 S = ObjCAtTryStmt::CreateEmpty(Context, 2765 Record[ASTStmtReader::NumStmtFields], 2766 Record[ASTStmtReader::NumStmtFields + 1]); 2767 break; 2768 2769 case STMT_OBJC_AT_SYNCHRONIZED: 2770 S = new (Context) ObjCAtSynchronizedStmt(Empty); 2771 break; 2772 2773 case STMT_OBJC_AT_THROW: 2774 S = new (Context) ObjCAtThrowStmt(Empty); 2775 break; 2776 2777 case STMT_OBJC_AUTORELEASE_POOL: 2778 S = new (Context) ObjCAutoreleasePoolStmt(Empty); 2779 break; 2780 2781 case EXPR_OBJC_BOOL_LITERAL: 2782 S = new (Context) ObjCBoolLiteralExpr(Empty); 2783 break; 2784 2785 case EXPR_OBJC_AVAILABILITY_CHECK: 2786 S = new (Context) ObjCAvailabilityCheckExpr(Empty); 2787 break; 2788 2789 case STMT_SEH_LEAVE: 2790 S = new (Context) SEHLeaveStmt(Empty); 2791 break; 2792 2793 case STMT_SEH_EXCEPT: 2794 S = new (Context) SEHExceptStmt(Empty); 2795 break; 2796 2797 case STMT_SEH_FINALLY: 2798 S = new (Context) SEHFinallyStmt(Empty); 2799 break; 2800 2801 case STMT_SEH_TRY: 2802 S = new (Context) SEHTryStmt(Empty); 2803 break; 2804 2805 case STMT_CXX_CATCH: 2806 S = new (Context) CXXCatchStmt(Empty); 2807 break; 2808 2809 case STMT_CXX_TRY: 2810 S = CXXTryStmt::Create(Context, Empty, 2811 /*NumHandlers=*/Record[ASTStmtReader::NumStmtFields]); 2812 break; 2813 2814 case STMT_CXX_FOR_RANGE: 2815 S = new (Context) CXXForRangeStmt(Empty); 2816 break; 2817 2818 case STMT_MS_DEPENDENT_EXISTS: 2819 S = new (Context) MSDependentExistsStmt(SourceLocation(), true, 2820 NestedNameSpecifierLoc(), 2821 DeclarationNameInfo(), 2822 nullptr); 2823 break; 2824 2825 case STMT_OMP_PARALLEL_DIRECTIVE: 2826 S = 2827 OMPParallelDirective::CreateEmpty(Context, 2828 Record[ASTStmtReader::NumStmtFields], 2829 Empty); 2830 break; 2831 2832 case STMT_OMP_SIMD_DIRECTIVE: { 2833 unsigned NumClauses = Record[ASTStmtReader::NumStmtFields]; 2834 unsigned CollapsedNum = Record[ASTStmtReader::NumStmtFields + 1]; 2835 S = OMPSimdDirective::CreateEmpty(Context, NumClauses, 2836 CollapsedNum, Empty); 2837 break; 2838 } 2839 2840 case STMT_OMP_FOR_DIRECTIVE: { 2841 unsigned NumClauses = Record[ASTStmtReader::NumStmtFields]; 2842 unsigned CollapsedNum = Record[ASTStmtReader::NumStmtFields + 1]; 2843 S = OMPForDirective::CreateEmpty(Context, NumClauses, CollapsedNum, 2844 Empty); 2845 break; 2846 } 2847 2848 case STMT_OMP_FOR_SIMD_DIRECTIVE: { 2849 unsigned NumClauses = Record[ASTStmtReader::NumStmtFields]; 2850 unsigned CollapsedNum = Record[ASTStmtReader::NumStmtFields + 1]; 2851 S = OMPForSimdDirective::CreateEmpty(Context, NumClauses, CollapsedNum, 2852 Empty); 2853 break; 2854 } 2855 2856 case STMT_OMP_SECTIONS_DIRECTIVE: 2857 S = OMPSectionsDirective::CreateEmpty( 2858 Context, Record[ASTStmtReader::NumStmtFields], Empty); 2859 break; 2860 2861 case STMT_OMP_SECTION_DIRECTIVE: 2862 S = OMPSectionDirective::CreateEmpty(Context, Empty); 2863 break; 2864 2865 case STMT_OMP_SINGLE_DIRECTIVE: 2866 S = OMPSingleDirective::CreateEmpty( 2867 Context, Record[ASTStmtReader::NumStmtFields], Empty); 2868 break; 2869 2870 case STMT_OMP_MASTER_DIRECTIVE: 2871 S = OMPMasterDirective::CreateEmpty(Context, Empty); 2872 break; 2873 2874 case STMT_OMP_CRITICAL_DIRECTIVE: 2875 S = OMPCriticalDirective::CreateEmpty( 2876 Context, Record[ASTStmtReader::NumStmtFields], Empty); 2877 break; 2878 2879 case STMT_OMP_PARALLEL_FOR_DIRECTIVE: { 2880 unsigned NumClauses = Record[ASTStmtReader::NumStmtFields]; 2881 unsigned CollapsedNum = Record[ASTStmtReader::NumStmtFields + 1]; 2882 S = OMPParallelForDirective::CreateEmpty(Context, NumClauses, 2883 CollapsedNum, Empty); 2884 break; 2885 } 2886 2887 case STMT_OMP_PARALLEL_FOR_SIMD_DIRECTIVE: { 2888 unsigned NumClauses = Record[ASTStmtReader::NumStmtFields]; 2889 unsigned CollapsedNum = Record[ASTStmtReader::NumStmtFields + 1]; 2890 S = OMPParallelForSimdDirective::CreateEmpty(Context, NumClauses, 2891 CollapsedNum, Empty); 2892 break; 2893 } 2894 2895 case STMT_OMP_PARALLEL_SECTIONS_DIRECTIVE: 2896 S = OMPParallelSectionsDirective::CreateEmpty( 2897 Context, Record[ASTStmtReader::NumStmtFields], Empty); 2898 break; 2899 2900 case STMT_OMP_TASK_DIRECTIVE: 2901 S = OMPTaskDirective::CreateEmpty( 2902 Context, Record[ASTStmtReader::NumStmtFields], Empty); 2903 break; 2904 2905 case STMT_OMP_TASKYIELD_DIRECTIVE: 2906 S = OMPTaskyieldDirective::CreateEmpty(Context, Empty); 2907 break; 2908 2909 case STMT_OMP_BARRIER_DIRECTIVE: 2910 S = OMPBarrierDirective::CreateEmpty(Context, Empty); 2911 break; 2912 2913 case STMT_OMP_TASKWAIT_DIRECTIVE: 2914 S = OMPTaskwaitDirective::CreateEmpty(Context, Empty); 2915 break; 2916 2917 case STMT_OMP_TASKGROUP_DIRECTIVE: 2918 S = OMPTaskgroupDirective::CreateEmpty( 2919 Context, Record[ASTStmtReader::NumStmtFields], Empty); 2920 break; 2921 2922 case STMT_OMP_FLUSH_DIRECTIVE: 2923 S = OMPFlushDirective::CreateEmpty( 2924 Context, Record[ASTStmtReader::NumStmtFields], Empty); 2925 break; 2926 2927 case STMT_OMP_ORDERED_DIRECTIVE: 2928 S = OMPOrderedDirective::CreateEmpty( 2929 Context, Record[ASTStmtReader::NumStmtFields], Empty); 2930 break; 2931 2932 case STMT_OMP_ATOMIC_DIRECTIVE: 2933 S = OMPAtomicDirective::CreateEmpty( 2934 Context, Record[ASTStmtReader::NumStmtFields], Empty); 2935 break; 2936 2937 case STMT_OMP_TARGET_DIRECTIVE: 2938 S = OMPTargetDirective::CreateEmpty( 2939 Context, Record[ASTStmtReader::NumStmtFields], Empty); 2940 break; 2941 2942 case STMT_OMP_TARGET_DATA_DIRECTIVE: 2943 S = OMPTargetDataDirective::CreateEmpty( 2944 Context, Record[ASTStmtReader::NumStmtFields], Empty); 2945 break; 2946 2947 case STMT_OMP_TARGET_ENTER_DATA_DIRECTIVE: 2948 S = OMPTargetEnterDataDirective::CreateEmpty( 2949 Context, Record[ASTStmtReader::NumStmtFields], Empty); 2950 break; 2951 2952 case STMT_OMP_TARGET_EXIT_DATA_DIRECTIVE: 2953 S = OMPTargetExitDataDirective::CreateEmpty( 2954 Context, Record[ASTStmtReader::NumStmtFields], Empty); 2955 break; 2956 2957 case STMT_OMP_TARGET_PARALLEL_DIRECTIVE: 2958 S = OMPTargetParallelDirective::CreateEmpty( 2959 Context, Record[ASTStmtReader::NumStmtFields], Empty); 2960 break; 2961 2962 case STMT_OMP_TARGET_PARALLEL_FOR_DIRECTIVE: { 2963 unsigned NumClauses = Record[ASTStmtReader::NumStmtFields]; 2964 unsigned CollapsedNum = Record[ASTStmtReader::NumStmtFields + 1]; 2965 S = OMPTargetParallelForDirective::CreateEmpty(Context, NumClauses, 2966 CollapsedNum, Empty); 2967 break; 2968 } 2969 2970 case STMT_OMP_TARGET_UPDATE_DIRECTIVE: 2971 S = OMPTargetUpdateDirective::CreateEmpty( 2972 Context, Record[ASTStmtReader::NumStmtFields], Empty); 2973 break; 2974 2975 case STMT_OMP_TEAMS_DIRECTIVE: 2976 S = OMPTeamsDirective::CreateEmpty( 2977 Context, Record[ASTStmtReader::NumStmtFields], Empty); 2978 break; 2979 2980 case STMT_OMP_CANCELLATION_POINT_DIRECTIVE: 2981 S = OMPCancellationPointDirective::CreateEmpty(Context, Empty); 2982 break; 2983 2984 case STMT_OMP_CANCEL_DIRECTIVE: 2985 S = OMPCancelDirective::CreateEmpty( 2986 Context, Record[ASTStmtReader::NumStmtFields], Empty); 2987 break; 2988 2989 case STMT_OMP_TASKLOOP_DIRECTIVE: { 2990 unsigned NumClauses = Record[ASTStmtReader::NumStmtFields]; 2991 unsigned CollapsedNum = Record[ASTStmtReader::NumStmtFields + 1]; 2992 S = OMPTaskLoopDirective::CreateEmpty(Context, NumClauses, CollapsedNum, 2993 Empty); 2994 break; 2995 } 2996 2997 case STMT_OMP_TASKLOOP_SIMD_DIRECTIVE: { 2998 unsigned NumClauses = Record[ASTStmtReader::NumStmtFields]; 2999 unsigned CollapsedNum = Record[ASTStmtReader::NumStmtFields + 1]; 3000 S = OMPTaskLoopSimdDirective::CreateEmpty(Context, NumClauses, 3001 CollapsedNum, Empty); 3002 break; 3003 } 3004 3005 case STMT_OMP_DISTRIBUTE_DIRECTIVE: { 3006 unsigned NumClauses = Record[ASTStmtReader::NumStmtFields]; 3007 unsigned CollapsedNum = Record[ASTStmtReader::NumStmtFields + 1]; 3008 S = OMPDistributeDirective::CreateEmpty(Context, NumClauses, CollapsedNum, 3009 Empty); 3010 break; 3011 } 3012 3013 case STMT_OMP_DISTRIBUTE_PARALLEL_FOR_DIRECTIVE: { 3014 unsigned NumClauses = Record[ASTStmtReader::NumStmtFields]; 3015 unsigned CollapsedNum = Record[ASTStmtReader::NumStmtFields + 1]; 3016 S = OMPDistributeParallelForDirective::CreateEmpty(Context, NumClauses, 3017 CollapsedNum, Empty); 3018 break; 3019 } 3020 3021 case STMT_OMP_DISTRIBUTE_PARALLEL_FOR_SIMD_DIRECTIVE: { 3022 unsigned NumClauses = Record[ASTStmtReader::NumStmtFields]; 3023 unsigned CollapsedNum = Record[ASTStmtReader::NumStmtFields + 1]; 3024 S = OMPDistributeParallelForSimdDirective::CreateEmpty(Context, NumClauses, 3025 CollapsedNum, 3026 Empty); 3027 break; 3028 } 3029 3030 case STMT_OMP_DISTRIBUTE_SIMD_DIRECTIVE: { 3031 unsigned NumClauses = Record[ASTStmtReader::NumStmtFields]; 3032 unsigned CollapsedNum = Record[ASTStmtReader::NumStmtFields + 1]; 3033 S = OMPDistributeSimdDirective::CreateEmpty(Context, NumClauses, 3034 CollapsedNum, Empty); 3035 break; 3036 } 3037 3038 case STMT_OMP_TARGET_PARALLEL_FOR_SIMD_DIRECTIVE: { 3039 unsigned NumClauses = Record[ASTStmtReader::NumStmtFields]; 3040 unsigned CollapsedNum = Record[ASTStmtReader::NumStmtFields + 1]; 3041 S = OMPTargetParallelForSimdDirective::CreateEmpty(Context, NumClauses, 3042 CollapsedNum, Empty); 3043 break; 3044 } 3045 3046 case STMT_OMP_TARGET_SIMD_DIRECTIVE: { 3047 auto NumClauses = Record[ASTStmtReader::NumStmtFields]; 3048 auto CollapsedNum = Record[ASTStmtReader::NumStmtFields + 1]; 3049 S = OMPTargetSimdDirective::CreateEmpty(Context, NumClauses, CollapsedNum, 3050 Empty); 3051 break; 3052 } 3053 3054 case STMT_OMP_TEAMS_DISTRIBUTE_DIRECTIVE: { 3055 auto NumClauses = Record[ASTStmtReader::NumStmtFields]; 3056 auto CollapsedNum = Record[ASTStmtReader::NumStmtFields + 1]; 3057 S = OMPTeamsDistributeDirective::CreateEmpty(Context, NumClauses, 3058 CollapsedNum, Empty); 3059 break; 3060 } 3061 3062 case STMT_OMP_TEAMS_DISTRIBUTE_SIMD_DIRECTIVE: { 3063 unsigned NumClauses = Record[ASTStmtReader::NumStmtFields]; 3064 unsigned CollapsedNum = Record[ASTStmtReader::NumStmtFields + 1]; 3065 S = OMPTeamsDistributeSimdDirective::CreateEmpty(Context, NumClauses, 3066 CollapsedNum, Empty); 3067 break; 3068 } 3069 3070 case STMT_OMP_TEAMS_DISTRIBUTE_PARALLEL_FOR_SIMD_DIRECTIVE: { 3071 auto NumClauses = Record[ASTStmtReader::NumStmtFields]; 3072 auto CollapsedNum = Record[ASTStmtReader::NumStmtFields + 1]; 3073 S = OMPTeamsDistributeParallelForSimdDirective::CreateEmpty( 3074 Context, NumClauses, CollapsedNum, Empty); 3075 break; 3076 } 3077 3078 case STMT_OMP_TEAMS_DISTRIBUTE_PARALLEL_FOR_DIRECTIVE: { 3079 auto NumClauses = Record[ASTStmtReader::NumStmtFields]; 3080 auto CollapsedNum = Record[ASTStmtReader::NumStmtFields + 1]; 3081 S = OMPTeamsDistributeParallelForDirective::CreateEmpty( 3082 Context, NumClauses, CollapsedNum, Empty); 3083 break; 3084 } 3085 3086 case STMT_OMP_TARGET_TEAMS_DIRECTIVE: 3087 S = OMPTargetTeamsDirective::CreateEmpty( 3088 Context, Record[ASTStmtReader::NumStmtFields], Empty); 3089 break; 3090 3091 case STMT_OMP_TARGET_TEAMS_DISTRIBUTE_DIRECTIVE: { 3092 auto NumClauses = Record[ASTStmtReader::NumStmtFields]; 3093 auto CollapsedNum = Record[ASTStmtReader::NumStmtFields + 1]; 3094 S = OMPTargetTeamsDistributeDirective::CreateEmpty(Context, NumClauses, 3095 CollapsedNum, Empty); 3096 break; 3097 } 3098 3099 case STMT_OMP_TARGET_TEAMS_DISTRIBUTE_PARALLEL_FOR_DIRECTIVE: { 3100 auto NumClauses = Record[ASTStmtReader::NumStmtFields]; 3101 auto CollapsedNum = Record[ASTStmtReader::NumStmtFields + 1]; 3102 S = OMPTargetTeamsDistributeParallelForDirective::CreateEmpty( 3103 Context, NumClauses, CollapsedNum, Empty); 3104 break; 3105 } 3106 3107 case STMT_OMP_TARGET_TEAMS_DISTRIBUTE_PARALLEL_FOR_SIMD_DIRECTIVE: { 3108 auto NumClauses = Record[ASTStmtReader::NumStmtFields]; 3109 auto CollapsedNum = Record[ASTStmtReader::NumStmtFields + 1]; 3110 S = OMPTargetTeamsDistributeParallelForSimdDirective::CreateEmpty( 3111 Context, NumClauses, CollapsedNum, Empty); 3112 break; 3113 } 3114 3115 case STMT_OMP_TARGET_TEAMS_DISTRIBUTE_SIMD_DIRECTIVE: { 3116 auto NumClauses = Record[ASTStmtReader::NumStmtFields]; 3117 auto CollapsedNum = Record[ASTStmtReader::NumStmtFields + 1]; 3118 S = OMPTargetTeamsDistributeSimdDirective::CreateEmpty( 3119 Context, NumClauses, CollapsedNum, Empty); 3120 break; 3121 } 3122 3123 case EXPR_CXX_OPERATOR_CALL: 3124 S = CXXOperatorCallExpr::CreateEmpty( 3125 Context, /*NumArgs=*/Record[ASTStmtReader::NumExprFields], Empty); 3126 break; 3127 3128 case EXPR_CXX_MEMBER_CALL: 3129 S = CXXMemberCallExpr::CreateEmpty( 3130 Context, /*NumArgs=*/Record[ASTStmtReader::NumExprFields], Empty); 3131 break; 3132 3133 case EXPR_CXX_CONSTRUCT: 3134 S = CXXConstructExpr::CreateEmpty( 3135 Context, 3136 /* NumArgs=*/Record[ASTStmtReader::NumExprFields]); 3137 break; 3138 3139 case EXPR_CXX_INHERITED_CTOR_INIT: 3140 S = new (Context) CXXInheritedCtorInitExpr(Empty); 3141 break; 3142 3143 case EXPR_CXX_TEMPORARY_OBJECT: 3144 S = CXXTemporaryObjectExpr::CreateEmpty( 3145 Context, 3146 /* NumArgs=*/Record[ASTStmtReader::NumExprFields]); 3147 break; 3148 3149 case EXPR_CXX_STATIC_CAST: 3150 S = CXXStaticCastExpr::CreateEmpty(Context, 3151 /*PathSize*/ Record[ASTStmtReader::NumExprFields]); 3152 break; 3153 3154 case EXPR_CXX_DYNAMIC_CAST: 3155 S = CXXDynamicCastExpr::CreateEmpty(Context, 3156 /*PathSize*/ Record[ASTStmtReader::NumExprFields]); 3157 break; 3158 3159 case EXPR_CXX_REINTERPRET_CAST: 3160 S = CXXReinterpretCastExpr::CreateEmpty(Context, 3161 /*PathSize*/ Record[ASTStmtReader::NumExprFields]); 3162 break; 3163 3164 case EXPR_CXX_CONST_CAST: 3165 S = CXXConstCastExpr::CreateEmpty(Context); 3166 break; 3167 3168 case EXPR_CXX_FUNCTIONAL_CAST: 3169 S = CXXFunctionalCastExpr::CreateEmpty(Context, 3170 /*PathSize*/ Record[ASTStmtReader::NumExprFields]); 3171 break; 3172 3173 case EXPR_USER_DEFINED_LITERAL: 3174 S = UserDefinedLiteral::CreateEmpty( 3175 Context, /*NumArgs=*/Record[ASTStmtReader::NumExprFields], Empty); 3176 break; 3177 3178 case EXPR_CXX_STD_INITIALIZER_LIST: 3179 S = new (Context) CXXStdInitializerListExpr(Empty); 3180 break; 3181 3182 case EXPR_CXX_BOOL_LITERAL: 3183 S = new (Context) CXXBoolLiteralExpr(Empty); 3184 break; 3185 3186 case EXPR_CXX_NULL_PTR_LITERAL: 3187 S = new (Context) CXXNullPtrLiteralExpr(Empty); 3188 break; 3189 3190 case EXPR_CXX_TYPEID_EXPR: 3191 S = new (Context) CXXTypeidExpr(Empty, true); 3192 break; 3193 3194 case EXPR_CXX_TYPEID_TYPE: 3195 S = new (Context) CXXTypeidExpr(Empty, false); 3196 break; 3197 3198 case EXPR_CXX_UUIDOF_EXPR: 3199 S = new (Context) CXXUuidofExpr(Empty, true); 3200 break; 3201 3202 case EXPR_CXX_PROPERTY_REF_EXPR: 3203 S = new (Context) MSPropertyRefExpr(Empty); 3204 break; 3205 3206 case EXPR_CXX_PROPERTY_SUBSCRIPT_EXPR: 3207 S = new (Context) MSPropertySubscriptExpr(Empty); 3208 break; 3209 3210 case EXPR_CXX_UUIDOF_TYPE: 3211 S = new (Context) CXXUuidofExpr(Empty, false); 3212 break; 3213 3214 case EXPR_CXX_THIS: 3215 S = new (Context) CXXThisExpr(Empty); 3216 break; 3217 3218 case EXPR_CXX_THROW: 3219 S = new (Context) CXXThrowExpr(Empty); 3220 break; 3221 3222 case EXPR_CXX_DEFAULT_ARG: 3223 S = new (Context) CXXDefaultArgExpr(Empty); 3224 break; 3225 3226 case EXPR_CXX_DEFAULT_INIT: 3227 S = new (Context) CXXDefaultInitExpr(Empty); 3228 break; 3229 3230 case EXPR_CXX_BIND_TEMPORARY: 3231 S = new (Context) CXXBindTemporaryExpr(Empty); 3232 break; 3233 3234 case EXPR_CXX_SCALAR_VALUE_INIT: 3235 S = new (Context) CXXScalarValueInitExpr(Empty); 3236 break; 3237 3238 case EXPR_CXX_NEW: 3239 S = CXXNewExpr::CreateEmpty( 3240 Context, 3241 /*IsArray=*/Record[ASTStmtReader::NumExprFields], 3242 /*HasInit=*/Record[ASTStmtReader::NumExprFields + 1], 3243 /*NumPlacementArgs=*/Record[ASTStmtReader::NumExprFields + 2], 3244 /*IsParenTypeId=*/Record[ASTStmtReader::NumExprFields + 3]); 3245 break; 3246 3247 case EXPR_CXX_DELETE: 3248 S = new (Context) CXXDeleteExpr(Empty); 3249 break; 3250 3251 case EXPR_CXX_PSEUDO_DESTRUCTOR: 3252 S = new (Context) CXXPseudoDestructorExpr(Empty); 3253 break; 3254 3255 case EXPR_EXPR_WITH_CLEANUPS: 3256 S = ExprWithCleanups::Create(Context, Empty, 3257 Record[ASTStmtReader::NumExprFields]); 3258 break; 3259 3260 case EXPR_CXX_DEPENDENT_SCOPE_MEMBER: 3261 S = CXXDependentScopeMemberExpr::CreateEmpty( 3262 Context, 3263 /*HasTemplateKWAndArgsInfo=*/Record[ASTStmtReader::NumExprFields], 3264 /*NumTemplateArgs=*/Record[ASTStmtReader::NumExprFields + 1], 3265 /*HasFirstQualifierFoundInScope=*/ 3266 Record[ASTStmtReader::NumExprFields + 2]); 3267 break; 3268 3269 case EXPR_CXX_DEPENDENT_SCOPE_DECL_REF: 3270 S = DependentScopeDeclRefExpr::CreateEmpty(Context, 3271 /*HasTemplateKWAndArgsInfo=*/Record[ASTStmtReader::NumExprFields], 3272 /*NumTemplateArgs=*/Record[ASTStmtReader::NumExprFields] 3273 ? Record[ASTStmtReader::NumExprFields + 1] 3274 : 0); 3275 break; 3276 3277 case EXPR_CXX_UNRESOLVED_CONSTRUCT: 3278 S = CXXUnresolvedConstructExpr::CreateEmpty(Context, 3279 /*NumArgs=*/Record[ASTStmtReader::NumExprFields]); 3280 break; 3281 3282 case EXPR_CXX_UNRESOLVED_MEMBER: 3283 S = UnresolvedMemberExpr::CreateEmpty( 3284 Context, 3285 /*NumResults=*/Record[ASTStmtReader::NumExprFields], 3286 /*HasTemplateKWAndArgsInfo=*/Record[ASTStmtReader::NumExprFields + 1], 3287 /*NumTemplateArgs=*/ 3288 Record[ASTStmtReader::NumExprFields + 1] 3289 ? Record[ASTStmtReader::NumExprFields + 2] 3290 : 0); 3291 break; 3292 3293 case EXPR_CXX_UNRESOLVED_LOOKUP: 3294 S = UnresolvedLookupExpr::CreateEmpty( 3295 Context, 3296 /*NumResults=*/Record[ASTStmtReader::NumExprFields], 3297 /*HasTemplateKWAndArgsInfo=*/Record[ASTStmtReader::NumExprFields + 1], 3298 /*NumTemplateArgs=*/ 3299 Record[ASTStmtReader::NumExprFields + 1] 3300 ? Record[ASTStmtReader::NumExprFields + 2] 3301 : 0); 3302 break; 3303 3304 case EXPR_TYPE_TRAIT: 3305 S = TypeTraitExpr::CreateDeserialized(Context, 3306 Record[ASTStmtReader::NumExprFields]); 3307 break; 3308 3309 case EXPR_ARRAY_TYPE_TRAIT: 3310 S = new (Context) ArrayTypeTraitExpr(Empty); 3311 break; 3312 3313 case EXPR_CXX_EXPRESSION_TRAIT: 3314 S = new (Context) ExpressionTraitExpr(Empty); 3315 break; 3316 3317 case EXPR_CXX_NOEXCEPT: 3318 S = new (Context) CXXNoexceptExpr(Empty); 3319 break; 3320 3321 case EXPR_PACK_EXPANSION: 3322 S = new (Context) PackExpansionExpr(Empty); 3323 break; 3324 3325 case EXPR_SIZEOF_PACK: 3326 S = SizeOfPackExpr::CreateDeserialized( 3327 Context, 3328 /*NumPartialArgs=*/Record[ASTStmtReader::NumExprFields]); 3329 break; 3330 3331 case EXPR_SUBST_NON_TYPE_TEMPLATE_PARM: 3332 S = new (Context) SubstNonTypeTemplateParmExpr(Empty); 3333 break; 3334 3335 case EXPR_SUBST_NON_TYPE_TEMPLATE_PARM_PACK: 3336 S = new (Context) SubstNonTypeTemplateParmPackExpr(Empty); 3337 break; 3338 3339 case EXPR_FUNCTION_PARM_PACK: 3340 S = FunctionParmPackExpr::CreateEmpty(Context, 3341 Record[ASTStmtReader::NumExprFields]); 3342 break; 3343 3344 case EXPR_MATERIALIZE_TEMPORARY: 3345 S = new (Context) MaterializeTemporaryExpr(Empty); 3346 break; 3347 3348 case EXPR_CXX_FOLD: 3349 S = new (Context) CXXFoldExpr(Empty); 3350 break; 3351 3352 case EXPR_OPAQUE_VALUE: 3353 S = new (Context) OpaqueValueExpr(Empty); 3354 break; 3355 3356 case EXPR_CUDA_KERNEL_CALL: 3357 S = CUDAKernelCallExpr::CreateEmpty( 3358 Context, /*NumArgs=*/Record[ASTStmtReader::NumExprFields], Empty); 3359 break; 3360 3361 case EXPR_ASTYPE: 3362 S = new (Context) AsTypeExpr(Empty); 3363 break; 3364 3365 case EXPR_PSEUDO_OBJECT: { 3366 unsigned numSemanticExprs = Record[ASTStmtReader::NumExprFields]; 3367 S = PseudoObjectExpr::Create(Context, Empty, numSemanticExprs); 3368 break; 3369 } 3370 3371 case EXPR_ATOMIC: 3372 S = new (Context) AtomicExpr(Empty); 3373 break; 3374 3375 case EXPR_LAMBDA: { 3376 unsigned NumCaptures = Record[ASTStmtReader::NumExprFields]; 3377 S = LambdaExpr::CreateDeserialized(Context, NumCaptures); 3378 break; 3379 } 3380 3381 case STMT_COROUTINE_BODY: { 3382 unsigned NumParams = Record[ASTStmtReader::NumStmtFields]; 3383 S = CoroutineBodyStmt::Create(Context, Empty, NumParams); 3384 break; 3385 } 3386 3387 case STMT_CORETURN: 3388 S = new (Context) CoreturnStmt(Empty); 3389 break; 3390 3391 case EXPR_COAWAIT: 3392 S = new (Context) CoawaitExpr(Empty); 3393 break; 3394 3395 case EXPR_COYIELD: 3396 S = new (Context) CoyieldExpr(Empty); 3397 break; 3398 3399 case EXPR_DEPENDENT_COAWAIT: 3400 S = new (Context) DependentCoawaitExpr(Empty); 3401 break; 3402 } 3403 3404 // We hit a STMT_STOP, so we're done with this expression. 3405 if (Finished) 3406 break; 3407 3408 ++NumStatementsRead; 3409 3410 if (S && !IsStmtReference) { 3411 Reader.Visit(S); 3412 StmtEntries[Cursor.GetCurrentBitNo()] = S; 3413 } 3414 3415 assert(Record.getIdx() == Record.size() && 3416 "Invalid deserialization of statement"); 3417 StmtStack.push_back(S); 3418 } 3419 Done: 3420 assert(StmtStack.size() > PrevNumStmts && "Read too many sub-stmts!"); 3421 assert(StmtStack.size() == PrevNumStmts + 1 && "Extra expressions on stack!"); 3422 return StmtStack.pop_back_val(); 3423 } 3424