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