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