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