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