1 //===---- StmtProfile.cpp - Profile implementation for Stmt ASTs ----------===// 2 // 3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. 4 // See https://llvm.org/LICENSE.txt for license information. 5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 6 // 7 //===----------------------------------------------------------------------===// 8 // 9 // This file implements the Stmt::Profile method, which builds a unique bit 10 // representation that identifies a statement/expression. 11 // 12 //===----------------------------------------------------------------------===// 13 #include "clang/AST/ASTContext.h" 14 #include "clang/AST/DeclCXX.h" 15 #include "clang/AST/DeclObjC.h" 16 #include "clang/AST/DeclTemplate.h" 17 #include "clang/AST/Expr.h" 18 #include "clang/AST/ExprCXX.h" 19 #include "clang/AST/ExprObjC.h" 20 #include "clang/AST/ExprOpenMP.h" 21 #include "clang/AST/ODRHash.h" 22 #include "clang/AST/OpenMPClause.h" 23 #include "clang/AST/StmtVisitor.h" 24 #include "llvm/ADT/FoldingSet.h" 25 using namespace clang; 26 27 namespace { 28 class StmtProfiler : public ConstStmtVisitor<StmtProfiler> { 29 protected: 30 llvm::FoldingSetNodeID &ID; 31 bool Canonical; 32 bool ProfileLambdaExpr; 33 34 public: 35 StmtProfiler(llvm::FoldingSetNodeID &ID, bool Canonical, 36 bool ProfileLambdaExpr) 37 : ID(ID), Canonical(Canonical), ProfileLambdaExpr(ProfileLambdaExpr) {} 38 39 virtual ~StmtProfiler() {} 40 41 void VisitStmt(const Stmt *S); 42 43 void VisitStmtNoChildren(const Stmt *S) { 44 HandleStmtClass(S->getStmtClass()); 45 } 46 47 virtual void HandleStmtClass(Stmt::StmtClass SC) = 0; 48 49 #define STMT(Node, Base) void Visit##Node(const Node *S); 50 #include "clang/AST/StmtNodes.inc" 51 52 /// Visit a declaration that is referenced within an expression 53 /// or statement. 54 virtual void VisitDecl(const Decl *D) = 0; 55 56 /// Visit a type that is referenced within an expression or 57 /// statement. 58 virtual void VisitType(QualType T) = 0; 59 60 /// Visit a name that occurs within an expression or statement. 61 virtual void VisitName(DeclarationName Name, bool TreatAsDecl = false) = 0; 62 63 /// Visit identifiers that are not in Decl's or Type's. 64 virtual void VisitIdentifierInfo(IdentifierInfo *II) = 0; 65 66 /// Visit a nested-name-specifier that occurs within an expression 67 /// or statement. 68 virtual void VisitNestedNameSpecifier(NestedNameSpecifier *NNS) = 0; 69 70 /// Visit a template name that occurs within an expression or 71 /// statement. 72 virtual void VisitTemplateName(TemplateName Name) = 0; 73 74 /// Visit template arguments that occur within an expression or 75 /// statement. 76 void VisitTemplateArguments(const TemplateArgumentLoc *Args, 77 unsigned NumArgs); 78 79 /// Visit a single template argument. 80 void VisitTemplateArgument(const TemplateArgument &Arg); 81 }; 82 83 class StmtProfilerWithPointers : public StmtProfiler { 84 const ASTContext &Context; 85 86 public: 87 StmtProfilerWithPointers(llvm::FoldingSetNodeID &ID, 88 const ASTContext &Context, bool Canonical, 89 bool ProfileLambdaExpr) 90 : StmtProfiler(ID, Canonical, ProfileLambdaExpr), Context(Context) {} 91 92 private: 93 void HandleStmtClass(Stmt::StmtClass SC) override { 94 ID.AddInteger(SC); 95 } 96 97 void VisitDecl(const Decl *D) override { 98 ID.AddInteger(D ? D->getKind() : 0); 99 100 if (Canonical && D) { 101 if (const NonTypeTemplateParmDecl *NTTP = 102 dyn_cast<NonTypeTemplateParmDecl>(D)) { 103 ID.AddInteger(NTTP->getDepth()); 104 ID.AddInteger(NTTP->getIndex()); 105 ID.AddBoolean(NTTP->isParameterPack()); 106 // C++20 [temp.over.link]p6: 107 // Two template-parameters are equivalent under the following 108 // conditions: [...] if they declare non-type template parameters, 109 // they have equivalent types ignoring the use of type-constraints 110 // for placeholder types 111 // 112 // TODO: Why do we need to include the type in the profile? It's not 113 // part of the mangling. 114 VisitType(Context.getUnconstrainedType(NTTP->getType())); 115 return; 116 } 117 118 if (const ParmVarDecl *Parm = dyn_cast<ParmVarDecl>(D)) { 119 // The Itanium C++ ABI uses the type, scope depth, and scope 120 // index of a parameter when mangling expressions that involve 121 // function parameters, so we will use the parameter's type for 122 // establishing function parameter identity. That way, our 123 // definition of "equivalent" (per C++ [temp.over.link]) is at 124 // least as strong as the definition of "equivalent" used for 125 // name mangling. 126 // 127 // TODO: The Itanium C++ ABI only uses the top-level cv-qualifiers, 128 // not the entirety of the type. 129 VisitType(Parm->getType()); 130 ID.AddInteger(Parm->getFunctionScopeDepth()); 131 ID.AddInteger(Parm->getFunctionScopeIndex()); 132 return; 133 } 134 135 if (const TemplateTypeParmDecl *TTP = 136 dyn_cast<TemplateTypeParmDecl>(D)) { 137 ID.AddInteger(TTP->getDepth()); 138 ID.AddInteger(TTP->getIndex()); 139 ID.AddBoolean(TTP->isParameterPack()); 140 return; 141 } 142 143 if (const TemplateTemplateParmDecl *TTP = 144 dyn_cast<TemplateTemplateParmDecl>(D)) { 145 ID.AddInteger(TTP->getDepth()); 146 ID.AddInteger(TTP->getIndex()); 147 ID.AddBoolean(TTP->isParameterPack()); 148 return; 149 } 150 } 151 152 ID.AddPointer(D ? D->getCanonicalDecl() : nullptr); 153 } 154 155 void VisitType(QualType T) override { 156 if (Canonical && !T.isNull()) 157 T = Context.getCanonicalType(T); 158 159 ID.AddPointer(T.getAsOpaquePtr()); 160 } 161 162 void VisitName(DeclarationName Name, bool /*TreatAsDecl*/) override { 163 ID.AddPointer(Name.getAsOpaquePtr()); 164 } 165 166 void VisitIdentifierInfo(IdentifierInfo *II) override { 167 ID.AddPointer(II); 168 } 169 170 void VisitNestedNameSpecifier(NestedNameSpecifier *NNS) override { 171 if (Canonical) 172 NNS = Context.getCanonicalNestedNameSpecifier(NNS); 173 ID.AddPointer(NNS); 174 } 175 176 void VisitTemplateName(TemplateName Name) override { 177 if (Canonical) 178 Name = Context.getCanonicalTemplateName(Name); 179 180 Name.Profile(ID); 181 } 182 }; 183 184 class StmtProfilerWithoutPointers : public StmtProfiler { 185 ODRHash &Hash; 186 public: 187 StmtProfilerWithoutPointers(llvm::FoldingSetNodeID &ID, ODRHash &Hash) 188 : StmtProfiler(ID, /*Canonical=*/false, /*ProfileLambdaExpr=*/false), 189 Hash(Hash) {} 190 191 private: 192 void HandleStmtClass(Stmt::StmtClass SC) override { 193 if (SC == Stmt::UnresolvedLookupExprClass) { 194 // Pretend that the name looked up is a Decl due to how templates 195 // handle some Decl lookups. 196 ID.AddInteger(Stmt::DeclRefExprClass); 197 } else { 198 ID.AddInteger(SC); 199 } 200 } 201 202 void VisitType(QualType T) override { 203 Hash.AddQualType(T); 204 } 205 206 void VisitName(DeclarationName Name, bool TreatAsDecl) override { 207 if (TreatAsDecl) { 208 // A Decl can be null, so each Decl is preceded by a boolean to 209 // store its nullness. Add a boolean here to match. 210 ID.AddBoolean(true); 211 } 212 Hash.AddDeclarationName(Name, TreatAsDecl); 213 } 214 void VisitIdentifierInfo(IdentifierInfo *II) override { 215 ID.AddBoolean(II); 216 if (II) { 217 Hash.AddIdentifierInfo(II); 218 } 219 } 220 void VisitDecl(const Decl *D) override { 221 ID.AddBoolean(D); 222 if (D) { 223 Hash.AddDecl(D); 224 } 225 } 226 void VisitTemplateName(TemplateName Name) override { 227 Hash.AddTemplateName(Name); 228 } 229 void VisitNestedNameSpecifier(NestedNameSpecifier *NNS) override { 230 ID.AddBoolean(NNS); 231 if (NNS) { 232 Hash.AddNestedNameSpecifier(NNS); 233 } 234 } 235 }; 236 } 237 238 void StmtProfiler::VisitStmt(const Stmt *S) { 239 assert(S && "Requires non-null Stmt pointer"); 240 241 VisitStmtNoChildren(S); 242 243 for (const Stmt *SubStmt : S->children()) { 244 if (SubStmt) 245 Visit(SubStmt); 246 else 247 ID.AddInteger(0); 248 } 249 } 250 251 void StmtProfiler::VisitDeclStmt(const DeclStmt *S) { 252 VisitStmt(S); 253 for (const auto *D : S->decls()) 254 VisitDecl(D); 255 } 256 257 void StmtProfiler::VisitNullStmt(const NullStmt *S) { 258 VisitStmt(S); 259 } 260 261 void StmtProfiler::VisitCompoundStmt(const CompoundStmt *S) { 262 VisitStmt(S); 263 } 264 265 void StmtProfiler::VisitCaseStmt(const CaseStmt *S) { 266 VisitStmt(S); 267 } 268 269 void StmtProfiler::VisitDefaultStmt(const DefaultStmt *S) { 270 VisitStmt(S); 271 } 272 273 void StmtProfiler::VisitLabelStmt(const LabelStmt *S) { 274 VisitStmt(S); 275 VisitDecl(S->getDecl()); 276 } 277 278 void StmtProfiler::VisitAttributedStmt(const AttributedStmt *S) { 279 VisitStmt(S); 280 // TODO: maybe visit attributes? 281 } 282 283 void StmtProfiler::VisitIfStmt(const IfStmt *S) { 284 VisitStmt(S); 285 VisitDecl(S->getConditionVariable()); 286 } 287 288 void StmtProfiler::VisitSwitchStmt(const SwitchStmt *S) { 289 VisitStmt(S); 290 VisitDecl(S->getConditionVariable()); 291 } 292 293 void StmtProfiler::VisitWhileStmt(const WhileStmt *S) { 294 VisitStmt(S); 295 VisitDecl(S->getConditionVariable()); 296 } 297 298 void StmtProfiler::VisitDoStmt(const DoStmt *S) { 299 VisitStmt(S); 300 } 301 302 void StmtProfiler::VisitForStmt(const ForStmt *S) { 303 VisitStmt(S); 304 } 305 306 void StmtProfiler::VisitGotoStmt(const GotoStmt *S) { 307 VisitStmt(S); 308 VisitDecl(S->getLabel()); 309 } 310 311 void StmtProfiler::VisitIndirectGotoStmt(const IndirectGotoStmt *S) { 312 VisitStmt(S); 313 } 314 315 void StmtProfiler::VisitContinueStmt(const ContinueStmt *S) { 316 VisitStmt(S); 317 } 318 319 void StmtProfiler::VisitBreakStmt(const BreakStmt *S) { 320 VisitStmt(S); 321 } 322 323 void StmtProfiler::VisitReturnStmt(const ReturnStmt *S) { 324 VisitStmt(S); 325 } 326 327 void StmtProfiler::VisitGCCAsmStmt(const GCCAsmStmt *S) { 328 VisitStmt(S); 329 ID.AddBoolean(S->isVolatile()); 330 ID.AddBoolean(S->isSimple()); 331 VisitStringLiteral(S->getAsmString()); 332 ID.AddInteger(S->getNumOutputs()); 333 for (unsigned I = 0, N = S->getNumOutputs(); I != N; ++I) { 334 ID.AddString(S->getOutputName(I)); 335 VisitStringLiteral(S->getOutputConstraintLiteral(I)); 336 } 337 ID.AddInteger(S->getNumInputs()); 338 for (unsigned I = 0, N = S->getNumInputs(); I != N; ++I) { 339 ID.AddString(S->getInputName(I)); 340 VisitStringLiteral(S->getInputConstraintLiteral(I)); 341 } 342 ID.AddInteger(S->getNumClobbers()); 343 for (unsigned I = 0, N = S->getNumClobbers(); I != N; ++I) 344 VisitStringLiteral(S->getClobberStringLiteral(I)); 345 ID.AddInteger(S->getNumLabels()); 346 for (auto *L : S->labels()) 347 VisitDecl(L->getLabel()); 348 } 349 350 void StmtProfiler::VisitMSAsmStmt(const MSAsmStmt *S) { 351 // FIXME: Implement MS style inline asm statement profiler. 352 VisitStmt(S); 353 } 354 355 void StmtProfiler::VisitCXXCatchStmt(const CXXCatchStmt *S) { 356 VisitStmt(S); 357 VisitType(S->getCaughtType()); 358 } 359 360 void StmtProfiler::VisitCXXTryStmt(const CXXTryStmt *S) { 361 VisitStmt(S); 362 } 363 364 void StmtProfiler::VisitCXXForRangeStmt(const CXXForRangeStmt *S) { 365 VisitStmt(S); 366 } 367 368 void StmtProfiler::VisitMSDependentExistsStmt(const MSDependentExistsStmt *S) { 369 VisitStmt(S); 370 ID.AddBoolean(S->isIfExists()); 371 VisitNestedNameSpecifier(S->getQualifierLoc().getNestedNameSpecifier()); 372 VisitName(S->getNameInfo().getName()); 373 } 374 375 void StmtProfiler::VisitSEHTryStmt(const SEHTryStmt *S) { 376 VisitStmt(S); 377 } 378 379 void StmtProfiler::VisitSEHFinallyStmt(const SEHFinallyStmt *S) { 380 VisitStmt(S); 381 } 382 383 void StmtProfiler::VisitSEHExceptStmt(const SEHExceptStmt *S) { 384 VisitStmt(S); 385 } 386 387 void StmtProfiler::VisitSEHLeaveStmt(const SEHLeaveStmt *S) { 388 VisitStmt(S); 389 } 390 391 void StmtProfiler::VisitCapturedStmt(const CapturedStmt *S) { 392 VisitStmt(S); 393 } 394 395 void StmtProfiler::VisitObjCForCollectionStmt(const ObjCForCollectionStmt *S) { 396 VisitStmt(S); 397 } 398 399 void StmtProfiler::VisitObjCAtCatchStmt(const ObjCAtCatchStmt *S) { 400 VisitStmt(S); 401 ID.AddBoolean(S->hasEllipsis()); 402 if (S->getCatchParamDecl()) 403 VisitType(S->getCatchParamDecl()->getType()); 404 } 405 406 void StmtProfiler::VisitObjCAtFinallyStmt(const ObjCAtFinallyStmt *S) { 407 VisitStmt(S); 408 } 409 410 void StmtProfiler::VisitObjCAtTryStmt(const ObjCAtTryStmt *S) { 411 VisitStmt(S); 412 } 413 414 void 415 StmtProfiler::VisitObjCAtSynchronizedStmt(const ObjCAtSynchronizedStmt *S) { 416 VisitStmt(S); 417 } 418 419 void StmtProfiler::VisitObjCAtThrowStmt(const ObjCAtThrowStmt *S) { 420 VisitStmt(S); 421 } 422 423 void 424 StmtProfiler::VisitObjCAutoreleasePoolStmt(const ObjCAutoreleasePoolStmt *S) { 425 VisitStmt(S); 426 } 427 428 namespace { 429 class OMPClauseProfiler : public ConstOMPClauseVisitor<OMPClauseProfiler> { 430 StmtProfiler *Profiler; 431 /// Process clauses with list of variables. 432 template <typename T> 433 void VisitOMPClauseList(T *Node); 434 435 public: 436 OMPClauseProfiler(StmtProfiler *P) : Profiler(P) { } 437 #define GEN_CLANG_CLAUSE_CLASS 438 #define CLAUSE_CLASS(Enum, Str, Class) void Visit##Class(const Class *C); 439 #include "llvm/Frontend/OpenMP/OMP.inc" 440 void VistOMPClauseWithPreInit(const OMPClauseWithPreInit *C); 441 void VistOMPClauseWithPostUpdate(const OMPClauseWithPostUpdate *C); 442 }; 443 444 void OMPClauseProfiler::VistOMPClauseWithPreInit( 445 const OMPClauseWithPreInit *C) { 446 if (auto *S = C->getPreInitStmt()) 447 Profiler->VisitStmt(S); 448 } 449 450 void OMPClauseProfiler::VistOMPClauseWithPostUpdate( 451 const OMPClauseWithPostUpdate *C) { 452 VistOMPClauseWithPreInit(C); 453 if (auto *E = C->getPostUpdateExpr()) 454 Profiler->VisitStmt(E); 455 } 456 457 void OMPClauseProfiler::VisitOMPIfClause(const OMPIfClause *C) { 458 VistOMPClauseWithPreInit(C); 459 if (C->getCondition()) 460 Profiler->VisitStmt(C->getCondition()); 461 } 462 463 void OMPClauseProfiler::VisitOMPFinalClause(const OMPFinalClause *C) { 464 VistOMPClauseWithPreInit(C); 465 if (C->getCondition()) 466 Profiler->VisitStmt(C->getCondition()); 467 } 468 469 void OMPClauseProfiler::VisitOMPNumThreadsClause(const OMPNumThreadsClause *C) { 470 VistOMPClauseWithPreInit(C); 471 if (C->getNumThreads()) 472 Profiler->VisitStmt(C->getNumThreads()); 473 } 474 475 void OMPClauseProfiler::VisitOMPAlignClause(const OMPAlignClause *C) { 476 if (C->getAlignment()) 477 Profiler->VisitStmt(C->getAlignment()); 478 } 479 480 void OMPClauseProfiler::VisitOMPSafelenClause(const OMPSafelenClause *C) { 481 if (C->getSafelen()) 482 Profiler->VisitStmt(C->getSafelen()); 483 } 484 485 void OMPClauseProfiler::VisitOMPSimdlenClause(const OMPSimdlenClause *C) { 486 if (C->getSimdlen()) 487 Profiler->VisitStmt(C->getSimdlen()); 488 } 489 490 void OMPClauseProfiler::VisitOMPSizesClause(const OMPSizesClause *C) { 491 for (auto *E : C->getSizesRefs()) 492 if (E) 493 Profiler->VisitExpr(E); 494 } 495 496 void OMPClauseProfiler::VisitOMPFullClause(const OMPFullClause *C) {} 497 498 void OMPClauseProfiler::VisitOMPPartialClause(const OMPPartialClause *C) { 499 if (const Expr *Factor = C->getFactor()) 500 Profiler->VisitExpr(Factor); 501 } 502 503 void OMPClauseProfiler::VisitOMPAllocatorClause(const OMPAllocatorClause *C) { 504 if (C->getAllocator()) 505 Profiler->VisitStmt(C->getAllocator()); 506 } 507 508 void OMPClauseProfiler::VisitOMPCollapseClause(const OMPCollapseClause *C) { 509 if (C->getNumForLoops()) 510 Profiler->VisitStmt(C->getNumForLoops()); 511 } 512 513 void OMPClauseProfiler::VisitOMPDetachClause(const OMPDetachClause *C) { 514 if (Expr *Evt = C->getEventHandler()) 515 Profiler->VisitStmt(Evt); 516 } 517 518 void OMPClauseProfiler::VisitOMPNovariantsClause(const OMPNovariantsClause *C) { 519 VistOMPClauseWithPreInit(C); 520 if (C->getCondition()) 521 Profiler->VisitStmt(C->getCondition()); 522 } 523 524 void OMPClauseProfiler::VisitOMPNocontextClause(const OMPNocontextClause *C) { 525 VistOMPClauseWithPreInit(C); 526 if (C->getCondition()) 527 Profiler->VisitStmt(C->getCondition()); 528 } 529 530 void OMPClauseProfiler::VisitOMPDefaultClause(const OMPDefaultClause *C) { } 531 532 void OMPClauseProfiler::VisitOMPProcBindClause(const OMPProcBindClause *C) { } 533 534 void OMPClauseProfiler::VisitOMPUnifiedAddressClause( 535 const OMPUnifiedAddressClause *C) {} 536 537 void OMPClauseProfiler::VisitOMPUnifiedSharedMemoryClause( 538 const OMPUnifiedSharedMemoryClause *C) {} 539 540 void OMPClauseProfiler::VisitOMPReverseOffloadClause( 541 const OMPReverseOffloadClause *C) {} 542 543 void OMPClauseProfiler::VisitOMPDynamicAllocatorsClause( 544 const OMPDynamicAllocatorsClause *C) {} 545 546 void OMPClauseProfiler::VisitOMPAtomicDefaultMemOrderClause( 547 const OMPAtomicDefaultMemOrderClause *C) {} 548 549 void OMPClauseProfiler::VisitOMPAtClause(const OMPAtClause *C) {} 550 551 void OMPClauseProfiler::VisitOMPSeverityClause(const OMPSeverityClause *C) {} 552 553 void OMPClauseProfiler::VisitOMPMessageClause(const OMPMessageClause *C) { 554 if (C->getMessageString()) 555 Profiler->VisitStmt(C->getMessageString()); 556 } 557 558 void OMPClauseProfiler::VisitOMPScheduleClause(const OMPScheduleClause *C) { 559 VistOMPClauseWithPreInit(C); 560 if (auto *S = C->getChunkSize()) 561 Profiler->VisitStmt(S); 562 } 563 564 void OMPClauseProfiler::VisitOMPOrderedClause(const OMPOrderedClause *C) { 565 if (auto *Num = C->getNumForLoops()) 566 Profiler->VisitStmt(Num); 567 } 568 569 void OMPClauseProfiler::VisitOMPNowaitClause(const OMPNowaitClause *) {} 570 571 void OMPClauseProfiler::VisitOMPUntiedClause(const OMPUntiedClause *) {} 572 573 void OMPClauseProfiler::VisitOMPMergeableClause(const OMPMergeableClause *) {} 574 575 void OMPClauseProfiler::VisitOMPReadClause(const OMPReadClause *) {} 576 577 void OMPClauseProfiler::VisitOMPWriteClause(const OMPWriteClause *) {} 578 579 void OMPClauseProfiler::VisitOMPUpdateClause(const OMPUpdateClause *) {} 580 581 void OMPClauseProfiler::VisitOMPCaptureClause(const OMPCaptureClause *) {} 582 583 void OMPClauseProfiler::VisitOMPCompareClause(const OMPCompareClause *) {} 584 585 void OMPClauseProfiler::VisitOMPFailClause(const OMPFailClause *) {} 586 587 void OMPClauseProfiler::VisitOMPSeqCstClause(const OMPSeqCstClause *) {} 588 589 void OMPClauseProfiler::VisitOMPAcqRelClause(const OMPAcqRelClause *) {} 590 591 void OMPClauseProfiler::VisitOMPAcquireClause(const OMPAcquireClause *) {} 592 593 void OMPClauseProfiler::VisitOMPReleaseClause(const OMPReleaseClause *) {} 594 595 void OMPClauseProfiler::VisitOMPRelaxedClause(const OMPRelaxedClause *) {} 596 597 void OMPClauseProfiler::VisitOMPThreadsClause(const OMPThreadsClause *) {} 598 599 void OMPClauseProfiler::VisitOMPSIMDClause(const OMPSIMDClause *) {} 600 601 void OMPClauseProfiler::VisitOMPNogroupClause(const OMPNogroupClause *) {} 602 603 void OMPClauseProfiler::VisitOMPInitClause(const OMPInitClause *C) { 604 VisitOMPClauseList(C); 605 } 606 607 void OMPClauseProfiler::VisitOMPUseClause(const OMPUseClause *C) { 608 if (C->getInteropVar()) 609 Profiler->VisitStmt(C->getInteropVar()); 610 } 611 612 void OMPClauseProfiler::VisitOMPDestroyClause(const OMPDestroyClause *C) { 613 if (C->getInteropVar()) 614 Profiler->VisitStmt(C->getInteropVar()); 615 } 616 617 void OMPClauseProfiler::VisitOMPFilterClause(const OMPFilterClause *C) { 618 VistOMPClauseWithPreInit(C); 619 if (C->getThreadID()) 620 Profiler->VisitStmt(C->getThreadID()); 621 } 622 623 template<typename T> 624 void OMPClauseProfiler::VisitOMPClauseList(T *Node) { 625 for (auto *E : Node->varlists()) { 626 if (E) 627 Profiler->VisitStmt(E); 628 } 629 } 630 631 void OMPClauseProfiler::VisitOMPPrivateClause(const OMPPrivateClause *C) { 632 VisitOMPClauseList(C); 633 for (auto *E : C->private_copies()) { 634 if (E) 635 Profiler->VisitStmt(E); 636 } 637 } 638 void 639 OMPClauseProfiler::VisitOMPFirstprivateClause(const OMPFirstprivateClause *C) { 640 VisitOMPClauseList(C); 641 VistOMPClauseWithPreInit(C); 642 for (auto *E : C->private_copies()) { 643 if (E) 644 Profiler->VisitStmt(E); 645 } 646 for (auto *E : C->inits()) { 647 if (E) 648 Profiler->VisitStmt(E); 649 } 650 } 651 void 652 OMPClauseProfiler::VisitOMPLastprivateClause(const OMPLastprivateClause *C) { 653 VisitOMPClauseList(C); 654 VistOMPClauseWithPostUpdate(C); 655 for (auto *E : C->source_exprs()) { 656 if (E) 657 Profiler->VisitStmt(E); 658 } 659 for (auto *E : C->destination_exprs()) { 660 if (E) 661 Profiler->VisitStmt(E); 662 } 663 for (auto *E : C->assignment_ops()) { 664 if (E) 665 Profiler->VisitStmt(E); 666 } 667 } 668 void OMPClauseProfiler::VisitOMPSharedClause(const OMPSharedClause *C) { 669 VisitOMPClauseList(C); 670 } 671 void OMPClauseProfiler::VisitOMPReductionClause( 672 const OMPReductionClause *C) { 673 Profiler->VisitNestedNameSpecifier( 674 C->getQualifierLoc().getNestedNameSpecifier()); 675 Profiler->VisitName(C->getNameInfo().getName()); 676 VisitOMPClauseList(C); 677 VistOMPClauseWithPostUpdate(C); 678 for (auto *E : C->privates()) { 679 if (E) 680 Profiler->VisitStmt(E); 681 } 682 for (auto *E : C->lhs_exprs()) { 683 if (E) 684 Profiler->VisitStmt(E); 685 } 686 for (auto *E : C->rhs_exprs()) { 687 if (E) 688 Profiler->VisitStmt(E); 689 } 690 for (auto *E : C->reduction_ops()) { 691 if (E) 692 Profiler->VisitStmt(E); 693 } 694 if (C->getModifier() == clang::OMPC_REDUCTION_inscan) { 695 for (auto *E : C->copy_ops()) { 696 if (E) 697 Profiler->VisitStmt(E); 698 } 699 for (auto *E : C->copy_array_temps()) { 700 if (E) 701 Profiler->VisitStmt(E); 702 } 703 for (auto *E : C->copy_array_elems()) { 704 if (E) 705 Profiler->VisitStmt(E); 706 } 707 } 708 } 709 void OMPClauseProfiler::VisitOMPTaskReductionClause( 710 const OMPTaskReductionClause *C) { 711 Profiler->VisitNestedNameSpecifier( 712 C->getQualifierLoc().getNestedNameSpecifier()); 713 Profiler->VisitName(C->getNameInfo().getName()); 714 VisitOMPClauseList(C); 715 VistOMPClauseWithPostUpdate(C); 716 for (auto *E : C->privates()) { 717 if (E) 718 Profiler->VisitStmt(E); 719 } 720 for (auto *E : C->lhs_exprs()) { 721 if (E) 722 Profiler->VisitStmt(E); 723 } 724 for (auto *E : C->rhs_exprs()) { 725 if (E) 726 Profiler->VisitStmt(E); 727 } 728 for (auto *E : C->reduction_ops()) { 729 if (E) 730 Profiler->VisitStmt(E); 731 } 732 } 733 void OMPClauseProfiler::VisitOMPInReductionClause( 734 const OMPInReductionClause *C) { 735 Profiler->VisitNestedNameSpecifier( 736 C->getQualifierLoc().getNestedNameSpecifier()); 737 Profiler->VisitName(C->getNameInfo().getName()); 738 VisitOMPClauseList(C); 739 VistOMPClauseWithPostUpdate(C); 740 for (auto *E : C->privates()) { 741 if (E) 742 Profiler->VisitStmt(E); 743 } 744 for (auto *E : C->lhs_exprs()) { 745 if (E) 746 Profiler->VisitStmt(E); 747 } 748 for (auto *E : C->rhs_exprs()) { 749 if (E) 750 Profiler->VisitStmt(E); 751 } 752 for (auto *E : C->reduction_ops()) { 753 if (E) 754 Profiler->VisitStmt(E); 755 } 756 for (auto *E : C->taskgroup_descriptors()) { 757 if (E) 758 Profiler->VisitStmt(E); 759 } 760 } 761 void OMPClauseProfiler::VisitOMPLinearClause(const OMPLinearClause *C) { 762 VisitOMPClauseList(C); 763 VistOMPClauseWithPostUpdate(C); 764 for (auto *E : C->privates()) { 765 if (E) 766 Profiler->VisitStmt(E); 767 } 768 for (auto *E : C->inits()) { 769 if (E) 770 Profiler->VisitStmt(E); 771 } 772 for (auto *E : C->updates()) { 773 if (E) 774 Profiler->VisitStmt(E); 775 } 776 for (auto *E : C->finals()) { 777 if (E) 778 Profiler->VisitStmt(E); 779 } 780 if (C->getStep()) 781 Profiler->VisitStmt(C->getStep()); 782 if (C->getCalcStep()) 783 Profiler->VisitStmt(C->getCalcStep()); 784 } 785 void OMPClauseProfiler::VisitOMPAlignedClause(const OMPAlignedClause *C) { 786 VisitOMPClauseList(C); 787 if (C->getAlignment()) 788 Profiler->VisitStmt(C->getAlignment()); 789 } 790 void OMPClauseProfiler::VisitOMPCopyinClause(const OMPCopyinClause *C) { 791 VisitOMPClauseList(C); 792 for (auto *E : C->source_exprs()) { 793 if (E) 794 Profiler->VisitStmt(E); 795 } 796 for (auto *E : C->destination_exprs()) { 797 if (E) 798 Profiler->VisitStmt(E); 799 } 800 for (auto *E : C->assignment_ops()) { 801 if (E) 802 Profiler->VisitStmt(E); 803 } 804 } 805 void 806 OMPClauseProfiler::VisitOMPCopyprivateClause(const OMPCopyprivateClause *C) { 807 VisitOMPClauseList(C); 808 for (auto *E : C->source_exprs()) { 809 if (E) 810 Profiler->VisitStmt(E); 811 } 812 for (auto *E : C->destination_exprs()) { 813 if (E) 814 Profiler->VisitStmt(E); 815 } 816 for (auto *E : C->assignment_ops()) { 817 if (E) 818 Profiler->VisitStmt(E); 819 } 820 } 821 void OMPClauseProfiler::VisitOMPFlushClause(const OMPFlushClause *C) { 822 VisitOMPClauseList(C); 823 } 824 void OMPClauseProfiler::VisitOMPDepobjClause(const OMPDepobjClause *C) { 825 if (const Expr *Depobj = C->getDepobj()) 826 Profiler->VisitStmt(Depobj); 827 } 828 void OMPClauseProfiler::VisitOMPDependClause(const OMPDependClause *C) { 829 VisitOMPClauseList(C); 830 } 831 void OMPClauseProfiler::VisitOMPDeviceClause(const OMPDeviceClause *C) { 832 if (C->getDevice()) 833 Profiler->VisitStmt(C->getDevice()); 834 } 835 void OMPClauseProfiler::VisitOMPMapClause(const OMPMapClause *C) { 836 VisitOMPClauseList(C); 837 } 838 void OMPClauseProfiler::VisitOMPAllocateClause(const OMPAllocateClause *C) { 839 if (Expr *Allocator = C->getAllocator()) 840 Profiler->VisitStmt(Allocator); 841 VisitOMPClauseList(C); 842 } 843 void OMPClauseProfiler::VisitOMPNumTeamsClause(const OMPNumTeamsClause *C) { 844 VistOMPClauseWithPreInit(C); 845 if (C->getNumTeams()) 846 Profiler->VisitStmt(C->getNumTeams()); 847 } 848 void OMPClauseProfiler::VisitOMPThreadLimitClause( 849 const OMPThreadLimitClause *C) { 850 VistOMPClauseWithPreInit(C); 851 if (C->getThreadLimit()) 852 Profiler->VisitStmt(C->getThreadLimit()); 853 } 854 void OMPClauseProfiler::VisitOMPPriorityClause(const OMPPriorityClause *C) { 855 VistOMPClauseWithPreInit(C); 856 if (C->getPriority()) 857 Profiler->VisitStmt(C->getPriority()); 858 } 859 void OMPClauseProfiler::VisitOMPGrainsizeClause(const OMPGrainsizeClause *C) { 860 VistOMPClauseWithPreInit(C); 861 if (C->getGrainsize()) 862 Profiler->VisitStmt(C->getGrainsize()); 863 } 864 void OMPClauseProfiler::VisitOMPNumTasksClause(const OMPNumTasksClause *C) { 865 VistOMPClauseWithPreInit(C); 866 if (C->getNumTasks()) 867 Profiler->VisitStmt(C->getNumTasks()); 868 } 869 void OMPClauseProfiler::VisitOMPHintClause(const OMPHintClause *C) { 870 if (C->getHint()) 871 Profiler->VisitStmt(C->getHint()); 872 } 873 void OMPClauseProfiler::VisitOMPToClause(const OMPToClause *C) { 874 VisitOMPClauseList(C); 875 } 876 void OMPClauseProfiler::VisitOMPFromClause(const OMPFromClause *C) { 877 VisitOMPClauseList(C); 878 } 879 void OMPClauseProfiler::VisitOMPUseDevicePtrClause( 880 const OMPUseDevicePtrClause *C) { 881 VisitOMPClauseList(C); 882 } 883 void OMPClauseProfiler::VisitOMPUseDeviceAddrClause( 884 const OMPUseDeviceAddrClause *C) { 885 VisitOMPClauseList(C); 886 } 887 void OMPClauseProfiler::VisitOMPIsDevicePtrClause( 888 const OMPIsDevicePtrClause *C) { 889 VisitOMPClauseList(C); 890 } 891 void OMPClauseProfiler::VisitOMPHasDeviceAddrClause( 892 const OMPHasDeviceAddrClause *C) { 893 VisitOMPClauseList(C); 894 } 895 void OMPClauseProfiler::VisitOMPNontemporalClause( 896 const OMPNontemporalClause *C) { 897 VisitOMPClauseList(C); 898 for (auto *E : C->private_refs()) 899 Profiler->VisitStmt(E); 900 } 901 void OMPClauseProfiler::VisitOMPInclusiveClause(const OMPInclusiveClause *C) { 902 VisitOMPClauseList(C); 903 } 904 void OMPClauseProfiler::VisitOMPExclusiveClause(const OMPExclusiveClause *C) { 905 VisitOMPClauseList(C); 906 } 907 void OMPClauseProfiler::VisitOMPUsesAllocatorsClause( 908 const OMPUsesAllocatorsClause *C) { 909 for (unsigned I = 0, E = C->getNumberOfAllocators(); I < E; ++I) { 910 OMPUsesAllocatorsClause::Data D = C->getAllocatorData(I); 911 Profiler->VisitStmt(D.Allocator); 912 if (D.AllocatorTraits) 913 Profiler->VisitStmt(D.AllocatorTraits); 914 } 915 } 916 void OMPClauseProfiler::VisitOMPAffinityClause(const OMPAffinityClause *C) { 917 if (const Expr *Modifier = C->getModifier()) 918 Profiler->VisitStmt(Modifier); 919 for (const Expr *E : C->varlists()) 920 Profiler->VisitStmt(E); 921 } 922 void OMPClauseProfiler::VisitOMPOrderClause(const OMPOrderClause *C) {} 923 void OMPClauseProfiler::VisitOMPBindClause(const OMPBindClause *C) {} 924 void OMPClauseProfiler::VisitOMPXDynCGroupMemClause( 925 const OMPXDynCGroupMemClause *C) { 926 VistOMPClauseWithPreInit(C); 927 if (Expr *Size = C->getSize()) 928 Profiler->VisitStmt(Size); 929 } 930 void OMPClauseProfiler::VisitOMPDoacrossClause(const OMPDoacrossClause *C) { 931 VisitOMPClauseList(C); 932 } 933 void OMPClauseProfiler::VisitOMPXAttributeClause(const OMPXAttributeClause *C) { 934 } 935 void OMPClauseProfiler::VisitOMPXBareClause(const OMPXBareClause *C) {} 936 } // namespace 937 938 void 939 StmtProfiler::VisitOMPExecutableDirective(const OMPExecutableDirective *S) { 940 VisitStmt(S); 941 OMPClauseProfiler P(this); 942 ArrayRef<OMPClause *> Clauses = S->clauses(); 943 for (ArrayRef<OMPClause *>::iterator I = Clauses.begin(), E = Clauses.end(); 944 I != E; ++I) 945 if (*I) 946 P.Visit(*I); 947 } 948 949 void StmtProfiler::VisitOMPCanonicalLoop(const OMPCanonicalLoop *L) { 950 VisitStmt(L); 951 } 952 953 void StmtProfiler::VisitOMPLoopBasedDirective(const OMPLoopBasedDirective *S) { 954 VisitOMPExecutableDirective(S); 955 } 956 957 void StmtProfiler::VisitOMPLoopDirective(const OMPLoopDirective *S) { 958 VisitOMPLoopBasedDirective(S); 959 } 960 961 void StmtProfiler::VisitOMPMetaDirective(const OMPMetaDirective *S) { 962 VisitOMPExecutableDirective(S); 963 } 964 965 void StmtProfiler::VisitOMPParallelDirective(const OMPParallelDirective *S) { 966 VisitOMPExecutableDirective(S); 967 } 968 969 void StmtProfiler::VisitOMPSimdDirective(const OMPSimdDirective *S) { 970 VisitOMPLoopDirective(S); 971 } 972 973 void StmtProfiler::VisitOMPLoopTransformationDirective( 974 const OMPLoopTransformationDirective *S) { 975 VisitOMPLoopBasedDirective(S); 976 } 977 978 void StmtProfiler::VisitOMPTileDirective(const OMPTileDirective *S) { 979 VisitOMPLoopTransformationDirective(S); 980 } 981 982 void StmtProfiler::VisitOMPUnrollDirective(const OMPUnrollDirective *S) { 983 VisitOMPLoopTransformationDirective(S); 984 } 985 986 void StmtProfiler::VisitOMPForDirective(const OMPForDirective *S) { 987 VisitOMPLoopDirective(S); 988 } 989 990 void StmtProfiler::VisitOMPForSimdDirective(const OMPForSimdDirective *S) { 991 VisitOMPLoopDirective(S); 992 } 993 994 void StmtProfiler::VisitOMPSectionsDirective(const OMPSectionsDirective *S) { 995 VisitOMPExecutableDirective(S); 996 } 997 998 void StmtProfiler::VisitOMPSectionDirective(const OMPSectionDirective *S) { 999 VisitOMPExecutableDirective(S); 1000 } 1001 1002 void StmtProfiler::VisitOMPScopeDirective(const OMPScopeDirective *S) { 1003 VisitOMPExecutableDirective(S); 1004 } 1005 1006 void StmtProfiler::VisitOMPSingleDirective(const OMPSingleDirective *S) { 1007 VisitOMPExecutableDirective(S); 1008 } 1009 1010 void StmtProfiler::VisitOMPMasterDirective(const OMPMasterDirective *S) { 1011 VisitOMPExecutableDirective(S); 1012 } 1013 1014 void StmtProfiler::VisitOMPCriticalDirective(const OMPCriticalDirective *S) { 1015 VisitOMPExecutableDirective(S); 1016 VisitName(S->getDirectiveName().getName()); 1017 } 1018 1019 void 1020 StmtProfiler::VisitOMPParallelForDirective(const OMPParallelForDirective *S) { 1021 VisitOMPLoopDirective(S); 1022 } 1023 1024 void StmtProfiler::VisitOMPParallelForSimdDirective( 1025 const OMPParallelForSimdDirective *S) { 1026 VisitOMPLoopDirective(S); 1027 } 1028 1029 void StmtProfiler::VisitOMPParallelMasterDirective( 1030 const OMPParallelMasterDirective *S) { 1031 VisitOMPExecutableDirective(S); 1032 } 1033 1034 void StmtProfiler::VisitOMPParallelMaskedDirective( 1035 const OMPParallelMaskedDirective *S) { 1036 VisitOMPExecutableDirective(S); 1037 } 1038 1039 void StmtProfiler::VisitOMPParallelSectionsDirective( 1040 const OMPParallelSectionsDirective *S) { 1041 VisitOMPExecutableDirective(S); 1042 } 1043 1044 void StmtProfiler::VisitOMPTaskDirective(const OMPTaskDirective *S) { 1045 VisitOMPExecutableDirective(S); 1046 } 1047 1048 void StmtProfiler::VisitOMPTaskyieldDirective(const OMPTaskyieldDirective *S) { 1049 VisitOMPExecutableDirective(S); 1050 } 1051 1052 void StmtProfiler::VisitOMPBarrierDirective(const OMPBarrierDirective *S) { 1053 VisitOMPExecutableDirective(S); 1054 } 1055 1056 void StmtProfiler::VisitOMPTaskwaitDirective(const OMPTaskwaitDirective *S) { 1057 VisitOMPExecutableDirective(S); 1058 } 1059 1060 void StmtProfiler::VisitOMPErrorDirective(const OMPErrorDirective *S) { 1061 VisitOMPExecutableDirective(S); 1062 } 1063 void StmtProfiler::VisitOMPTaskgroupDirective(const OMPTaskgroupDirective *S) { 1064 VisitOMPExecutableDirective(S); 1065 if (const Expr *E = S->getReductionRef()) 1066 VisitStmt(E); 1067 } 1068 1069 void StmtProfiler::VisitOMPFlushDirective(const OMPFlushDirective *S) { 1070 VisitOMPExecutableDirective(S); 1071 } 1072 1073 void StmtProfiler::VisitOMPDepobjDirective(const OMPDepobjDirective *S) { 1074 VisitOMPExecutableDirective(S); 1075 } 1076 1077 void StmtProfiler::VisitOMPScanDirective(const OMPScanDirective *S) { 1078 VisitOMPExecutableDirective(S); 1079 } 1080 1081 void StmtProfiler::VisitOMPOrderedDirective(const OMPOrderedDirective *S) { 1082 VisitOMPExecutableDirective(S); 1083 } 1084 1085 void StmtProfiler::VisitOMPAtomicDirective(const OMPAtomicDirective *S) { 1086 VisitOMPExecutableDirective(S); 1087 } 1088 1089 void StmtProfiler::VisitOMPTargetDirective(const OMPTargetDirective *S) { 1090 VisitOMPExecutableDirective(S); 1091 } 1092 1093 void StmtProfiler::VisitOMPTargetDataDirective(const OMPTargetDataDirective *S) { 1094 VisitOMPExecutableDirective(S); 1095 } 1096 1097 void StmtProfiler::VisitOMPTargetEnterDataDirective( 1098 const OMPTargetEnterDataDirective *S) { 1099 VisitOMPExecutableDirective(S); 1100 } 1101 1102 void StmtProfiler::VisitOMPTargetExitDataDirective( 1103 const OMPTargetExitDataDirective *S) { 1104 VisitOMPExecutableDirective(S); 1105 } 1106 1107 void StmtProfiler::VisitOMPTargetParallelDirective( 1108 const OMPTargetParallelDirective *S) { 1109 VisitOMPExecutableDirective(S); 1110 } 1111 1112 void StmtProfiler::VisitOMPTargetParallelForDirective( 1113 const OMPTargetParallelForDirective *S) { 1114 VisitOMPExecutableDirective(S); 1115 } 1116 1117 void StmtProfiler::VisitOMPTeamsDirective(const OMPTeamsDirective *S) { 1118 VisitOMPExecutableDirective(S); 1119 } 1120 1121 void StmtProfiler::VisitOMPCancellationPointDirective( 1122 const OMPCancellationPointDirective *S) { 1123 VisitOMPExecutableDirective(S); 1124 } 1125 1126 void StmtProfiler::VisitOMPCancelDirective(const OMPCancelDirective *S) { 1127 VisitOMPExecutableDirective(S); 1128 } 1129 1130 void StmtProfiler::VisitOMPTaskLoopDirective(const OMPTaskLoopDirective *S) { 1131 VisitOMPLoopDirective(S); 1132 } 1133 1134 void StmtProfiler::VisitOMPTaskLoopSimdDirective( 1135 const OMPTaskLoopSimdDirective *S) { 1136 VisitOMPLoopDirective(S); 1137 } 1138 1139 void StmtProfiler::VisitOMPMasterTaskLoopDirective( 1140 const OMPMasterTaskLoopDirective *S) { 1141 VisitOMPLoopDirective(S); 1142 } 1143 1144 void StmtProfiler::VisitOMPMaskedTaskLoopDirective( 1145 const OMPMaskedTaskLoopDirective *S) { 1146 VisitOMPLoopDirective(S); 1147 } 1148 1149 void StmtProfiler::VisitOMPMasterTaskLoopSimdDirective( 1150 const OMPMasterTaskLoopSimdDirective *S) { 1151 VisitOMPLoopDirective(S); 1152 } 1153 1154 void StmtProfiler::VisitOMPMaskedTaskLoopSimdDirective( 1155 const OMPMaskedTaskLoopSimdDirective *S) { 1156 VisitOMPLoopDirective(S); 1157 } 1158 1159 void StmtProfiler::VisitOMPParallelMasterTaskLoopDirective( 1160 const OMPParallelMasterTaskLoopDirective *S) { 1161 VisitOMPLoopDirective(S); 1162 } 1163 1164 void StmtProfiler::VisitOMPParallelMaskedTaskLoopDirective( 1165 const OMPParallelMaskedTaskLoopDirective *S) { 1166 VisitOMPLoopDirective(S); 1167 } 1168 1169 void StmtProfiler::VisitOMPParallelMasterTaskLoopSimdDirective( 1170 const OMPParallelMasterTaskLoopSimdDirective *S) { 1171 VisitOMPLoopDirective(S); 1172 } 1173 1174 void StmtProfiler::VisitOMPParallelMaskedTaskLoopSimdDirective( 1175 const OMPParallelMaskedTaskLoopSimdDirective *S) { 1176 VisitOMPLoopDirective(S); 1177 } 1178 1179 void StmtProfiler::VisitOMPDistributeDirective( 1180 const OMPDistributeDirective *S) { 1181 VisitOMPLoopDirective(S); 1182 } 1183 1184 void OMPClauseProfiler::VisitOMPDistScheduleClause( 1185 const OMPDistScheduleClause *C) { 1186 VistOMPClauseWithPreInit(C); 1187 if (auto *S = C->getChunkSize()) 1188 Profiler->VisitStmt(S); 1189 } 1190 1191 void OMPClauseProfiler::VisitOMPDefaultmapClause(const OMPDefaultmapClause *) {} 1192 1193 void StmtProfiler::VisitOMPTargetUpdateDirective( 1194 const OMPTargetUpdateDirective *S) { 1195 VisitOMPExecutableDirective(S); 1196 } 1197 1198 void StmtProfiler::VisitOMPDistributeParallelForDirective( 1199 const OMPDistributeParallelForDirective *S) { 1200 VisitOMPLoopDirective(S); 1201 } 1202 1203 void StmtProfiler::VisitOMPDistributeParallelForSimdDirective( 1204 const OMPDistributeParallelForSimdDirective *S) { 1205 VisitOMPLoopDirective(S); 1206 } 1207 1208 void StmtProfiler::VisitOMPDistributeSimdDirective( 1209 const OMPDistributeSimdDirective *S) { 1210 VisitOMPLoopDirective(S); 1211 } 1212 1213 void StmtProfiler::VisitOMPTargetParallelForSimdDirective( 1214 const OMPTargetParallelForSimdDirective *S) { 1215 VisitOMPLoopDirective(S); 1216 } 1217 1218 void StmtProfiler::VisitOMPTargetSimdDirective( 1219 const OMPTargetSimdDirective *S) { 1220 VisitOMPLoopDirective(S); 1221 } 1222 1223 void StmtProfiler::VisitOMPTeamsDistributeDirective( 1224 const OMPTeamsDistributeDirective *S) { 1225 VisitOMPLoopDirective(S); 1226 } 1227 1228 void StmtProfiler::VisitOMPTeamsDistributeSimdDirective( 1229 const OMPTeamsDistributeSimdDirective *S) { 1230 VisitOMPLoopDirective(S); 1231 } 1232 1233 void StmtProfiler::VisitOMPTeamsDistributeParallelForSimdDirective( 1234 const OMPTeamsDistributeParallelForSimdDirective *S) { 1235 VisitOMPLoopDirective(S); 1236 } 1237 1238 void StmtProfiler::VisitOMPTeamsDistributeParallelForDirective( 1239 const OMPTeamsDistributeParallelForDirective *S) { 1240 VisitOMPLoopDirective(S); 1241 } 1242 1243 void StmtProfiler::VisitOMPTargetTeamsDirective( 1244 const OMPTargetTeamsDirective *S) { 1245 VisitOMPExecutableDirective(S); 1246 } 1247 1248 void StmtProfiler::VisitOMPTargetTeamsDistributeDirective( 1249 const OMPTargetTeamsDistributeDirective *S) { 1250 VisitOMPLoopDirective(S); 1251 } 1252 1253 void StmtProfiler::VisitOMPTargetTeamsDistributeParallelForDirective( 1254 const OMPTargetTeamsDistributeParallelForDirective *S) { 1255 VisitOMPLoopDirective(S); 1256 } 1257 1258 void StmtProfiler::VisitOMPTargetTeamsDistributeParallelForSimdDirective( 1259 const OMPTargetTeamsDistributeParallelForSimdDirective *S) { 1260 VisitOMPLoopDirective(S); 1261 } 1262 1263 void StmtProfiler::VisitOMPTargetTeamsDistributeSimdDirective( 1264 const OMPTargetTeamsDistributeSimdDirective *S) { 1265 VisitOMPLoopDirective(S); 1266 } 1267 1268 void StmtProfiler::VisitOMPInteropDirective(const OMPInteropDirective *S) { 1269 VisitOMPExecutableDirective(S); 1270 } 1271 1272 void StmtProfiler::VisitOMPDispatchDirective(const OMPDispatchDirective *S) { 1273 VisitOMPExecutableDirective(S); 1274 } 1275 1276 void StmtProfiler::VisitOMPMaskedDirective(const OMPMaskedDirective *S) { 1277 VisitOMPExecutableDirective(S); 1278 } 1279 1280 void StmtProfiler::VisitOMPGenericLoopDirective( 1281 const OMPGenericLoopDirective *S) { 1282 VisitOMPLoopDirective(S); 1283 } 1284 1285 void StmtProfiler::VisitOMPTeamsGenericLoopDirective( 1286 const OMPTeamsGenericLoopDirective *S) { 1287 VisitOMPLoopDirective(S); 1288 } 1289 1290 void StmtProfiler::VisitOMPTargetTeamsGenericLoopDirective( 1291 const OMPTargetTeamsGenericLoopDirective *S) { 1292 VisitOMPLoopDirective(S); 1293 } 1294 1295 void StmtProfiler::VisitOMPParallelGenericLoopDirective( 1296 const OMPParallelGenericLoopDirective *S) { 1297 VisitOMPLoopDirective(S); 1298 } 1299 1300 void StmtProfiler::VisitOMPTargetParallelGenericLoopDirective( 1301 const OMPTargetParallelGenericLoopDirective *S) { 1302 VisitOMPLoopDirective(S); 1303 } 1304 1305 void StmtProfiler::VisitExpr(const Expr *S) { 1306 VisitStmt(S); 1307 } 1308 1309 void StmtProfiler::VisitConstantExpr(const ConstantExpr *S) { 1310 VisitExpr(S); 1311 } 1312 1313 void StmtProfiler::VisitDeclRefExpr(const DeclRefExpr *S) { 1314 VisitExpr(S); 1315 if (!Canonical) 1316 VisitNestedNameSpecifier(S->getQualifier()); 1317 VisitDecl(S->getDecl()); 1318 if (!Canonical) { 1319 ID.AddBoolean(S->hasExplicitTemplateArgs()); 1320 if (S->hasExplicitTemplateArgs()) 1321 VisitTemplateArguments(S->getTemplateArgs(), S->getNumTemplateArgs()); 1322 } 1323 } 1324 1325 void StmtProfiler::VisitSYCLUniqueStableNameExpr( 1326 const SYCLUniqueStableNameExpr *S) { 1327 VisitExpr(S); 1328 VisitType(S->getTypeSourceInfo()->getType()); 1329 } 1330 1331 void StmtProfiler::VisitPredefinedExpr(const PredefinedExpr *S) { 1332 VisitExpr(S); 1333 ID.AddInteger(llvm::to_underlying(S->getIdentKind())); 1334 } 1335 1336 void StmtProfiler::VisitIntegerLiteral(const IntegerLiteral *S) { 1337 VisitExpr(S); 1338 S->getValue().Profile(ID); 1339 1340 QualType T = S->getType(); 1341 if (Canonical) 1342 T = T.getCanonicalType(); 1343 ID.AddInteger(T->getTypeClass()); 1344 if (auto BitIntT = T->getAs<BitIntType>()) 1345 BitIntT->Profile(ID); 1346 else 1347 ID.AddInteger(T->castAs<BuiltinType>()->getKind()); 1348 } 1349 1350 void StmtProfiler::VisitFixedPointLiteral(const FixedPointLiteral *S) { 1351 VisitExpr(S); 1352 S->getValue().Profile(ID); 1353 ID.AddInteger(S->getType()->castAs<BuiltinType>()->getKind()); 1354 } 1355 1356 void StmtProfiler::VisitCharacterLiteral(const CharacterLiteral *S) { 1357 VisitExpr(S); 1358 ID.AddInteger(llvm::to_underlying(S->getKind())); 1359 ID.AddInteger(S->getValue()); 1360 } 1361 1362 void StmtProfiler::VisitFloatingLiteral(const FloatingLiteral *S) { 1363 VisitExpr(S); 1364 S->getValue().Profile(ID); 1365 ID.AddBoolean(S->isExact()); 1366 ID.AddInteger(S->getType()->castAs<BuiltinType>()->getKind()); 1367 } 1368 1369 void StmtProfiler::VisitImaginaryLiteral(const ImaginaryLiteral *S) { 1370 VisitExpr(S); 1371 } 1372 1373 void StmtProfiler::VisitStringLiteral(const StringLiteral *S) { 1374 VisitExpr(S); 1375 ID.AddString(S->getBytes()); 1376 ID.AddInteger(llvm::to_underlying(S->getKind())); 1377 } 1378 1379 void StmtProfiler::VisitParenExpr(const ParenExpr *S) { 1380 VisitExpr(S); 1381 } 1382 1383 void StmtProfiler::VisitParenListExpr(const ParenListExpr *S) { 1384 VisitExpr(S); 1385 } 1386 1387 void StmtProfiler::VisitUnaryOperator(const UnaryOperator *S) { 1388 VisitExpr(S); 1389 ID.AddInteger(S->getOpcode()); 1390 } 1391 1392 void StmtProfiler::VisitOffsetOfExpr(const OffsetOfExpr *S) { 1393 VisitType(S->getTypeSourceInfo()->getType()); 1394 unsigned n = S->getNumComponents(); 1395 for (unsigned i = 0; i < n; ++i) { 1396 const OffsetOfNode &ON = S->getComponent(i); 1397 ID.AddInteger(ON.getKind()); 1398 switch (ON.getKind()) { 1399 case OffsetOfNode::Array: 1400 // Expressions handled below. 1401 break; 1402 1403 case OffsetOfNode::Field: 1404 VisitDecl(ON.getField()); 1405 break; 1406 1407 case OffsetOfNode::Identifier: 1408 VisitIdentifierInfo(ON.getFieldName()); 1409 break; 1410 1411 case OffsetOfNode::Base: 1412 // These nodes are implicit, and therefore don't need profiling. 1413 break; 1414 } 1415 } 1416 1417 VisitExpr(S); 1418 } 1419 1420 void 1421 StmtProfiler::VisitUnaryExprOrTypeTraitExpr(const UnaryExprOrTypeTraitExpr *S) { 1422 VisitExpr(S); 1423 ID.AddInteger(S->getKind()); 1424 if (S->isArgumentType()) 1425 VisitType(S->getArgumentType()); 1426 } 1427 1428 void StmtProfiler::VisitArraySubscriptExpr(const ArraySubscriptExpr *S) { 1429 VisitExpr(S); 1430 } 1431 1432 void StmtProfiler::VisitMatrixSubscriptExpr(const MatrixSubscriptExpr *S) { 1433 VisitExpr(S); 1434 } 1435 1436 void StmtProfiler::VisitOMPArraySectionExpr(const OMPArraySectionExpr *S) { 1437 VisitExpr(S); 1438 } 1439 1440 void StmtProfiler::VisitOMPArrayShapingExpr(const OMPArrayShapingExpr *S) { 1441 VisitExpr(S); 1442 } 1443 1444 void StmtProfiler::VisitOMPIteratorExpr(const OMPIteratorExpr *S) { 1445 VisitExpr(S); 1446 for (unsigned I = 0, E = S->numOfIterators(); I < E; ++I) 1447 VisitDecl(S->getIteratorDecl(I)); 1448 } 1449 1450 void StmtProfiler::VisitCallExpr(const CallExpr *S) { 1451 VisitExpr(S); 1452 } 1453 1454 void StmtProfiler::VisitMemberExpr(const MemberExpr *S) { 1455 VisitExpr(S); 1456 VisitDecl(S->getMemberDecl()); 1457 if (!Canonical) 1458 VisitNestedNameSpecifier(S->getQualifier()); 1459 ID.AddBoolean(S->isArrow()); 1460 } 1461 1462 void StmtProfiler::VisitCompoundLiteralExpr(const CompoundLiteralExpr *S) { 1463 VisitExpr(S); 1464 ID.AddBoolean(S->isFileScope()); 1465 } 1466 1467 void StmtProfiler::VisitCastExpr(const CastExpr *S) { 1468 VisitExpr(S); 1469 } 1470 1471 void StmtProfiler::VisitImplicitCastExpr(const ImplicitCastExpr *S) { 1472 VisitCastExpr(S); 1473 ID.AddInteger(S->getValueKind()); 1474 } 1475 1476 void StmtProfiler::VisitExplicitCastExpr(const ExplicitCastExpr *S) { 1477 VisitCastExpr(S); 1478 VisitType(S->getTypeAsWritten()); 1479 } 1480 1481 void StmtProfiler::VisitCStyleCastExpr(const CStyleCastExpr *S) { 1482 VisitExplicitCastExpr(S); 1483 } 1484 1485 void StmtProfiler::VisitBinaryOperator(const BinaryOperator *S) { 1486 VisitExpr(S); 1487 ID.AddInteger(S->getOpcode()); 1488 } 1489 1490 void 1491 StmtProfiler::VisitCompoundAssignOperator(const CompoundAssignOperator *S) { 1492 VisitBinaryOperator(S); 1493 } 1494 1495 void StmtProfiler::VisitConditionalOperator(const ConditionalOperator *S) { 1496 VisitExpr(S); 1497 } 1498 1499 void StmtProfiler::VisitBinaryConditionalOperator( 1500 const BinaryConditionalOperator *S) { 1501 VisitExpr(S); 1502 } 1503 1504 void StmtProfiler::VisitAddrLabelExpr(const AddrLabelExpr *S) { 1505 VisitExpr(S); 1506 VisitDecl(S->getLabel()); 1507 } 1508 1509 void StmtProfiler::VisitStmtExpr(const StmtExpr *S) { 1510 VisitExpr(S); 1511 } 1512 1513 void StmtProfiler::VisitShuffleVectorExpr(const ShuffleVectorExpr *S) { 1514 VisitExpr(S); 1515 } 1516 1517 void StmtProfiler::VisitConvertVectorExpr(const ConvertVectorExpr *S) { 1518 VisitExpr(S); 1519 } 1520 1521 void StmtProfiler::VisitChooseExpr(const ChooseExpr *S) { 1522 VisitExpr(S); 1523 } 1524 1525 void StmtProfiler::VisitGNUNullExpr(const GNUNullExpr *S) { 1526 VisitExpr(S); 1527 } 1528 1529 void StmtProfiler::VisitVAArgExpr(const VAArgExpr *S) { 1530 VisitExpr(S); 1531 } 1532 1533 void StmtProfiler::VisitInitListExpr(const InitListExpr *S) { 1534 if (S->getSyntacticForm()) { 1535 VisitInitListExpr(S->getSyntacticForm()); 1536 return; 1537 } 1538 1539 VisitExpr(S); 1540 } 1541 1542 void StmtProfiler::VisitDesignatedInitExpr(const DesignatedInitExpr *S) { 1543 VisitExpr(S); 1544 ID.AddBoolean(S->usesGNUSyntax()); 1545 for (const DesignatedInitExpr::Designator &D : S->designators()) { 1546 if (D.isFieldDesignator()) { 1547 ID.AddInteger(0); 1548 VisitName(D.getFieldName()); 1549 continue; 1550 } 1551 1552 if (D.isArrayDesignator()) { 1553 ID.AddInteger(1); 1554 } else { 1555 assert(D.isArrayRangeDesignator()); 1556 ID.AddInteger(2); 1557 } 1558 ID.AddInteger(D.getArrayIndex()); 1559 } 1560 } 1561 1562 // Seems that if VisitInitListExpr() only works on the syntactic form of an 1563 // InitListExpr, then a DesignatedInitUpdateExpr is not encountered. 1564 void StmtProfiler::VisitDesignatedInitUpdateExpr( 1565 const DesignatedInitUpdateExpr *S) { 1566 llvm_unreachable("Unexpected DesignatedInitUpdateExpr in syntactic form of " 1567 "initializer"); 1568 } 1569 1570 void StmtProfiler::VisitArrayInitLoopExpr(const ArrayInitLoopExpr *S) { 1571 VisitExpr(S); 1572 } 1573 1574 void StmtProfiler::VisitArrayInitIndexExpr(const ArrayInitIndexExpr *S) { 1575 VisitExpr(S); 1576 } 1577 1578 void StmtProfiler::VisitNoInitExpr(const NoInitExpr *S) { 1579 llvm_unreachable("Unexpected NoInitExpr in syntactic form of initializer"); 1580 } 1581 1582 void StmtProfiler::VisitImplicitValueInitExpr(const ImplicitValueInitExpr *S) { 1583 VisitExpr(S); 1584 } 1585 1586 void StmtProfiler::VisitExtVectorElementExpr(const ExtVectorElementExpr *S) { 1587 VisitExpr(S); 1588 VisitName(&S->getAccessor()); 1589 } 1590 1591 void StmtProfiler::VisitBlockExpr(const BlockExpr *S) { 1592 VisitExpr(S); 1593 VisitDecl(S->getBlockDecl()); 1594 } 1595 1596 void StmtProfiler::VisitGenericSelectionExpr(const GenericSelectionExpr *S) { 1597 VisitExpr(S); 1598 for (const GenericSelectionExpr::ConstAssociation Assoc : 1599 S->associations()) { 1600 QualType T = Assoc.getType(); 1601 if (T.isNull()) 1602 ID.AddPointer(nullptr); 1603 else 1604 VisitType(T); 1605 VisitExpr(Assoc.getAssociationExpr()); 1606 } 1607 } 1608 1609 void StmtProfiler::VisitPseudoObjectExpr(const PseudoObjectExpr *S) { 1610 VisitExpr(S); 1611 for (PseudoObjectExpr::const_semantics_iterator 1612 i = S->semantics_begin(), e = S->semantics_end(); i != e; ++i) 1613 // Normally, we would not profile the source expressions of OVEs. 1614 if (const OpaqueValueExpr *OVE = dyn_cast<OpaqueValueExpr>(*i)) 1615 Visit(OVE->getSourceExpr()); 1616 } 1617 1618 void StmtProfiler::VisitAtomicExpr(const AtomicExpr *S) { 1619 VisitExpr(S); 1620 ID.AddInteger(S->getOp()); 1621 } 1622 1623 void StmtProfiler::VisitConceptSpecializationExpr( 1624 const ConceptSpecializationExpr *S) { 1625 VisitExpr(S); 1626 VisitDecl(S->getNamedConcept()); 1627 for (const TemplateArgument &Arg : S->getTemplateArguments()) 1628 VisitTemplateArgument(Arg); 1629 } 1630 1631 void StmtProfiler::VisitRequiresExpr(const RequiresExpr *S) { 1632 VisitExpr(S); 1633 ID.AddInteger(S->getLocalParameters().size()); 1634 for (ParmVarDecl *LocalParam : S->getLocalParameters()) 1635 VisitDecl(LocalParam); 1636 ID.AddInteger(S->getRequirements().size()); 1637 for (concepts::Requirement *Req : S->getRequirements()) { 1638 if (auto *TypeReq = dyn_cast<concepts::TypeRequirement>(Req)) { 1639 ID.AddInteger(concepts::Requirement::RK_Type); 1640 ID.AddBoolean(TypeReq->isSubstitutionFailure()); 1641 if (!TypeReq->isSubstitutionFailure()) 1642 VisitType(TypeReq->getType()->getType()); 1643 } else if (auto *ExprReq = dyn_cast<concepts::ExprRequirement>(Req)) { 1644 ID.AddInteger(concepts::Requirement::RK_Compound); 1645 ID.AddBoolean(ExprReq->isExprSubstitutionFailure()); 1646 if (!ExprReq->isExprSubstitutionFailure()) 1647 Visit(ExprReq->getExpr()); 1648 // C++2a [expr.prim.req.compound]p1 Example: 1649 // [...] The compound-requirement in C1 requires that x++ is a valid 1650 // expression. It is equivalent to the simple-requirement x++; [...] 1651 // We therefore do not profile isSimple() here. 1652 ID.AddBoolean(ExprReq->getNoexceptLoc().isValid()); 1653 const concepts::ExprRequirement::ReturnTypeRequirement &RetReq = 1654 ExprReq->getReturnTypeRequirement(); 1655 if (RetReq.isEmpty()) { 1656 ID.AddInteger(0); 1657 } else if (RetReq.isTypeConstraint()) { 1658 ID.AddInteger(1); 1659 Visit(RetReq.getTypeConstraint()->getImmediatelyDeclaredConstraint()); 1660 } else { 1661 assert(RetReq.isSubstitutionFailure()); 1662 ID.AddInteger(2); 1663 } 1664 } else { 1665 ID.AddInteger(concepts::Requirement::RK_Nested); 1666 auto *NestedReq = cast<concepts::NestedRequirement>(Req); 1667 ID.AddBoolean(NestedReq->hasInvalidConstraint()); 1668 if (!NestedReq->hasInvalidConstraint()) 1669 Visit(NestedReq->getConstraintExpr()); 1670 } 1671 } 1672 } 1673 1674 static Stmt::StmtClass DecodeOperatorCall(const CXXOperatorCallExpr *S, 1675 UnaryOperatorKind &UnaryOp, 1676 BinaryOperatorKind &BinaryOp, 1677 unsigned &NumArgs) { 1678 switch (S->getOperator()) { 1679 case OO_None: 1680 case OO_New: 1681 case OO_Delete: 1682 case OO_Array_New: 1683 case OO_Array_Delete: 1684 case OO_Arrow: 1685 case OO_Conditional: 1686 case NUM_OVERLOADED_OPERATORS: 1687 llvm_unreachable("Invalid operator call kind"); 1688 1689 case OO_Plus: 1690 if (NumArgs == 1) { 1691 UnaryOp = UO_Plus; 1692 return Stmt::UnaryOperatorClass; 1693 } 1694 1695 BinaryOp = BO_Add; 1696 return Stmt::BinaryOperatorClass; 1697 1698 case OO_Minus: 1699 if (NumArgs == 1) { 1700 UnaryOp = UO_Minus; 1701 return Stmt::UnaryOperatorClass; 1702 } 1703 1704 BinaryOp = BO_Sub; 1705 return Stmt::BinaryOperatorClass; 1706 1707 case OO_Star: 1708 if (NumArgs == 1) { 1709 UnaryOp = UO_Deref; 1710 return Stmt::UnaryOperatorClass; 1711 } 1712 1713 BinaryOp = BO_Mul; 1714 return Stmt::BinaryOperatorClass; 1715 1716 case OO_Slash: 1717 BinaryOp = BO_Div; 1718 return Stmt::BinaryOperatorClass; 1719 1720 case OO_Percent: 1721 BinaryOp = BO_Rem; 1722 return Stmt::BinaryOperatorClass; 1723 1724 case OO_Caret: 1725 BinaryOp = BO_Xor; 1726 return Stmt::BinaryOperatorClass; 1727 1728 case OO_Amp: 1729 if (NumArgs == 1) { 1730 UnaryOp = UO_AddrOf; 1731 return Stmt::UnaryOperatorClass; 1732 } 1733 1734 BinaryOp = BO_And; 1735 return Stmt::BinaryOperatorClass; 1736 1737 case OO_Pipe: 1738 BinaryOp = BO_Or; 1739 return Stmt::BinaryOperatorClass; 1740 1741 case OO_Tilde: 1742 UnaryOp = UO_Not; 1743 return Stmt::UnaryOperatorClass; 1744 1745 case OO_Exclaim: 1746 UnaryOp = UO_LNot; 1747 return Stmt::UnaryOperatorClass; 1748 1749 case OO_Equal: 1750 BinaryOp = BO_Assign; 1751 return Stmt::BinaryOperatorClass; 1752 1753 case OO_Less: 1754 BinaryOp = BO_LT; 1755 return Stmt::BinaryOperatorClass; 1756 1757 case OO_Greater: 1758 BinaryOp = BO_GT; 1759 return Stmt::BinaryOperatorClass; 1760 1761 case OO_PlusEqual: 1762 BinaryOp = BO_AddAssign; 1763 return Stmt::CompoundAssignOperatorClass; 1764 1765 case OO_MinusEqual: 1766 BinaryOp = BO_SubAssign; 1767 return Stmt::CompoundAssignOperatorClass; 1768 1769 case OO_StarEqual: 1770 BinaryOp = BO_MulAssign; 1771 return Stmt::CompoundAssignOperatorClass; 1772 1773 case OO_SlashEqual: 1774 BinaryOp = BO_DivAssign; 1775 return Stmt::CompoundAssignOperatorClass; 1776 1777 case OO_PercentEqual: 1778 BinaryOp = BO_RemAssign; 1779 return Stmt::CompoundAssignOperatorClass; 1780 1781 case OO_CaretEqual: 1782 BinaryOp = BO_XorAssign; 1783 return Stmt::CompoundAssignOperatorClass; 1784 1785 case OO_AmpEqual: 1786 BinaryOp = BO_AndAssign; 1787 return Stmt::CompoundAssignOperatorClass; 1788 1789 case OO_PipeEqual: 1790 BinaryOp = BO_OrAssign; 1791 return Stmt::CompoundAssignOperatorClass; 1792 1793 case OO_LessLess: 1794 BinaryOp = BO_Shl; 1795 return Stmt::BinaryOperatorClass; 1796 1797 case OO_GreaterGreater: 1798 BinaryOp = BO_Shr; 1799 return Stmt::BinaryOperatorClass; 1800 1801 case OO_LessLessEqual: 1802 BinaryOp = BO_ShlAssign; 1803 return Stmt::CompoundAssignOperatorClass; 1804 1805 case OO_GreaterGreaterEqual: 1806 BinaryOp = BO_ShrAssign; 1807 return Stmt::CompoundAssignOperatorClass; 1808 1809 case OO_EqualEqual: 1810 BinaryOp = BO_EQ; 1811 return Stmt::BinaryOperatorClass; 1812 1813 case OO_ExclaimEqual: 1814 BinaryOp = BO_NE; 1815 return Stmt::BinaryOperatorClass; 1816 1817 case OO_LessEqual: 1818 BinaryOp = BO_LE; 1819 return Stmt::BinaryOperatorClass; 1820 1821 case OO_GreaterEqual: 1822 BinaryOp = BO_GE; 1823 return Stmt::BinaryOperatorClass; 1824 1825 case OO_Spaceship: 1826 BinaryOp = BO_Cmp; 1827 return Stmt::BinaryOperatorClass; 1828 1829 case OO_AmpAmp: 1830 BinaryOp = BO_LAnd; 1831 return Stmt::BinaryOperatorClass; 1832 1833 case OO_PipePipe: 1834 BinaryOp = BO_LOr; 1835 return Stmt::BinaryOperatorClass; 1836 1837 case OO_PlusPlus: 1838 UnaryOp = NumArgs == 1 ? UO_PreInc : UO_PostInc; 1839 NumArgs = 1; 1840 return Stmt::UnaryOperatorClass; 1841 1842 case OO_MinusMinus: 1843 UnaryOp = NumArgs == 1 ? UO_PreDec : UO_PostDec; 1844 NumArgs = 1; 1845 return Stmt::UnaryOperatorClass; 1846 1847 case OO_Comma: 1848 BinaryOp = BO_Comma; 1849 return Stmt::BinaryOperatorClass; 1850 1851 case OO_ArrowStar: 1852 BinaryOp = BO_PtrMemI; 1853 return Stmt::BinaryOperatorClass; 1854 1855 case OO_Subscript: 1856 return Stmt::ArraySubscriptExprClass; 1857 1858 case OO_Call: 1859 return Stmt::CallExprClass; 1860 1861 case OO_Coawait: 1862 UnaryOp = UO_Coawait; 1863 return Stmt::UnaryOperatorClass; 1864 } 1865 1866 llvm_unreachable("Invalid overloaded operator expression"); 1867 } 1868 1869 #if defined(_MSC_VER) && !defined(__clang__) 1870 #if _MSC_VER == 1911 1871 // Work around https://developercommunity.visualstudio.com/content/problem/84002/clang-cl-when-built-with-vc-2017-crashes-cause-vc.html 1872 // MSVC 2017 update 3 miscompiles this function, and a clang built with it 1873 // will crash in stage 2 of a bootstrap build. 1874 #pragma optimize("", off) 1875 #endif 1876 #endif 1877 1878 void StmtProfiler::VisitCXXOperatorCallExpr(const CXXOperatorCallExpr *S) { 1879 if (S->isTypeDependent()) { 1880 // Type-dependent operator calls are profiled like their underlying 1881 // syntactic operator. 1882 // 1883 // An operator call to operator-> is always implicit, so just skip it. The 1884 // enclosing MemberExpr will profile the actual member access. 1885 if (S->getOperator() == OO_Arrow) 1886 return Visit(S->getArg(0)); 1887 1888 UnaryOperatorKind UnaryOp = UO_Extension; 1889 BinaryOperatorKind BinaryOp = BO_Comma; 1890 unsigned NumArgs = S->getNumArgs(); 1891 Stmt::StmtClass SC = DecodeOperatorCall(S, UnaryOp, BinaryOp, NumArgs); 1892 1893 ID.AddInteger(SC); 1894 for (unsigned I = 0; I != NumArgs; ++I) 1895 Visit(S->getArg(I)); 1896 if (SC == Stmt::UnaryOperatorClass) 1897 ID.AddInteger(UnaryOp); 1898 else if (SC == Stmt::BinaryOperatorClass || 1899 SC == Stmt::CompoundAssignOperatorClass) 1900 ID.AddInteger(BinaryOp); 1901 else 1902 assert(SC == Stmt::ArraySubscriptExprClass || SC == Stmt::CallExprClass); 1903 1904 return; 1905 } 1906 1907 VisitCallExpr(S); 1908 ID.AddInteger(S->getOperator()); 1909 } 1910 1911 void StmtProfiler::VisitCXXRewrittenBinaryOperator( 1912 const CXXRewrittenBinaryOperator *S) { 1913 // If a rewritten operator were ever to be type-dependent, we should profile 1914 // it following its syntactic operator. 1915 assert(!S->isTypeDependent() && 1916 "resolved rewritten operator should never be type-dependent"); 1917 ID.AddBoolean(S->isReversed()); 1918 VisitExpr(S->getSemanticForm()); 1919 } 1920 1921 #if defined(_MSC_VER) && !defined(__clang__) 1922 #if _MSC_VER == 1911 1923 #pragma optimize("", on) 1924 #endif 1925 #endif 1926 1927 void StmtProfiler::VisitCXXMemberCallExpr(const CXXMemberCallExpr *S) { 1928 VisitCallExpr(S); 1929 } 1930 1931 void StmtProfiler::VisitCUDAKernelCallExpr(const CUDAKernelCallExpr *S) { 1932 VisitCallExpr(S); 1933 } 1934 1935 void StmtProfiler::VisitAsTypeExpr(const AsTypeExpr *S) { 1936 VisitExpr(S); 1937 } 1938 1939 void StmtProfiler::VisitCXXNamedCastExpr(const CXXNamedCastExpr *S) { 1940 VisitExplicitCastExpr(S); 1941 } 1942 1943 void StmtProfiler::VisitCXXStaticCastExpr(const CXXStaticCastExpr *S) { 1944 VisitCXXNamedCastExpr(S); 1945 } 1946 1947 void StmtProfiler::VisitCXXDynamicCastExpr(const CXXDynamicCastExpr *S) { 1948 VisitCXXNamedCastExpr(S); 1949 } 1950 1951 void 1952 StmtProfiler::VisitCXXReinterpretCastExpr(const CXXReinterpretCastExpr *S) { 1953 VisitCXXNamedCastExpr(S); 1954 } 1955 1956 void StmtProfiler::VisitCXXConstCastExpr(const CXXConstCastExpr *S) { 1957 VisitCXXNamedCastExpr(S); 1958 } 1959 1960 void StmtProfiler::VisitBuiltinBitCastExpr(const BuiltinBitCastExpr *S) { 1961 VisitExpr(S); 1962 VisitType(S->getTypeInfoAsWritten()->getType()); 1963 } 1964 1965 void StmtProfiler::VisitCXXAddrspaceCastExpr(const CXXAddrspaceCastExpr *S) { 1966 VisitCXXNamedCastExpr(S); 1967 } 1968 1969 void StmtProfiler::VisitUserDefinedLiteral(const UserDefinedLiteral *S) { 1970 VisitCallExpr(S); 1971 } 1972 1973 void StmtProfiler::VisitCXXBoolLiteralExpr(const CXXBoolLiteralExpr *S) { 1974 VisitExpr(S); 1975 ID.AddBoolean(S->getValue()); 1976 } 1977 1978 void StmtProfiler::VisitCXXNullPtrLiteralExpr(const CXXNullPtrLiteralExpr *S) { 1979 VisitExpr(S); 1980 } 1981 1982 void StmtProfiler::VisitCXXStdInitializerListExpr( 1983 const CXXStdInitializerListExpr *S) { 1984 VisitExpr(S); 1985 } 1986 1987 void StmtProfiler::VisitCXXTypeidExpr(const CXXTypeidExpr *S) { 1988 VisitExpr(S); 1989 if (S->isTypeOperand()) 1990 VisitType(S->getTypeOperandSourceInfo()->getType()); 1991 } 1992 1993 void StmtProfiler::VisitCXXUuidofExpr(const CXXUuidofExpr *S) { 1994 VisitExpr(S); 1995 if (S->isTypeOperand()) 1996 VisitType(S->getTypeOperandSourceInfo()->getType()); 1997 } 1998 1999 void StmtProfiler::VisitMSPropertyRefExpr(const MSPropertyRefExpr *S) { 2000 VisitExpr(S); 2001 VisitDecl(S->getPropertyDecl()); 2002 } 2003 2004 void StmtProfiler::VisitMSPropertySubscriptExpr( 2005 const MSPropertySubscriptExpr *S) { 2006 VisitExpr(S); 2007 } 2008 2009 void StmtProfiler::VisitCXXThisExpr(const CXXThisExpr *S) { 2010 VisitExpr(S); 2011 ID.AddBoolean(S->isImplicit()); 2012 } 2013 2014 void StmtProfiler::VisitCXXThrowExpr(const CXXThrowExpr *S) { 2015 VisitExpr(S); 2016 } 2017 2018 void StmtProfiler::VisitCXXDefaultArgExpr(const CXXDefaultArgExpr *S) { 2019 VisitExpr(S); 2020 VisitDecl(S->getParam()); 2021 } 2022 2023 void StmtProfiler::VisitCXXDefaultInitExpr(const CXXDefaultInitExpr *S) { 2024 VisitExpr(S); 2025 VisitDecl(S->getField()); 2026 } 2027 2028 void StmtProfiler::VisitCXXBindTemporaryExpr(const CXXBindTemporaryExpr *S) { 2029 VisitExpr(S); 2030 VisitDecl( 2031 const_cast<CXXDestructorDecl *>(S->getTemporary()->getDestructor())); 2032 } 2033 2034 void StmtProfiler::VisitCXXConstructExpr(const CXXConstructExpr *S) { 2035 VisitExpr(S); 2036 VisitDecl(S->getConstructor()); 2037 ID.AddBoolean(S->isElidable()); 2038 } 2039 2040 void StmtProfiler::VisitCXXInheritedCtorInitExpr( 2041 const CXXInheritedCtorInitExpr *S) { 2042 VisitExpr(S); 2043 VisitDecl(S->getConstructor()); 2044 } 2045 2046 void StmtProfiler::VisitCXXFunctionalCastExpr(const CXXFunctionalCastExpr *S) { 2047 VisitExplicitCastExpr(S); 2048 } 2049 2050 void 2051 StmtProfiler::VisitCXXTemporaryObjectExpr(const CXXTemporaryObjectExpr *S) { 2052 VisitCXXConstructExpr(S); 2053 } 2054 2055 void 2056 StmtProfiler::VisitLambdaExpr(const LambdaExpr *S) { 2057 if (!ProfileLambdaExpr) { 2058 // Do not recursively visit the children of this expression. Profiling the 2059 // body would result in unnecessary work, and is not safe to do during 2060 // deserialization. 2061 VisitStmtNoChildren(S); 2062 2063 // C++20 [temp.over.link]p5: 2064 // Two lambda-expressions are never considered equivalent. 2065 VisitDecl(S->getLambdaClass()); 2066 2067 return; 2068 } 2069 2070 CXXRecordDecl *Lambda = S->getLambdaClass(); 2071 ID.AddInteger(Lambda->getODRHash()); 2072 2073 for (const auto &Capture : Lambda->captures()) { 2074 ID.AddInteger(Capture.getCaptureKind()); 2075 if (Capture.capturesVariable()) 2076 VisitDecl(Capture.getCapturedVar()); 2077 } 2078 } 2079 2080 void 2081 StmtProfiler::VisitCXXScalarValueInitExpr(const CXXScalarValueInitExpr *S) { 2082 VisitExpr(S); 2083 } 2084 2085 void StmtProfiler::VisitCXXDeleteExpr(const CXXDeleteExpr *S) { 2086 VisitExpr(S); 2087 ID.AddBoolean(S->isGlobalDelete()); 2088 ID.AddBoolean(S->isArrayForm()); 2089 VisitDecl(S->getOperatorDelete()); 2090 } 2091 2092 void StmtProfiler::VisitCXXNewExpr(const CXXNewExpr *S) { 2093 VisitExpr(S); 2094 VisitType(S->getAllocatedType()); 2095 VisitDecl(S->getOperatorNew()); 2096 VisitDecl(S->getOperatorDelete()); 2097 ID.AddBoolean(S->isArray()); 2098 ID.AddInteger(S->getNumPlacementArgs()); 2099 ID.AddBoolean(S->isGlobalNew()); 2100 ID.AddBoolean(S->isParenTypeId()); 2101 ID.AddInteger(llvm::to_underlying(S->getInitializationStyle())); 2102 } 2103 2104 void 2105 StmtProfiler::VisitCXXPseudoDestructorExpr(const CXXPseudoDestructorExpr *S) { 2106 VisitExpr(S); 2107 ID.AddBoolean(S->isArrow()); 2108 VisitNestedNameSpecifier(S->getQualifier()); 2109 ID.AddBoolean(S->getScopeTypeInfo() != nullptr); 2110 if (S->getScopeTypeInfo()) 2111 VisitType(S->getScopeTypeInfo()->getType()); 2112 ID.AddBoolean(S->getDestroyedTypeInfo() != nullptr); 2113 if (S->getDestroyedTypeInfo()) 2114 VisitType(S->getDestroyedType()); 2115 else 2116 VisitIdentifierInfo(S->getDestroyedTypeIdentifier()); 2117 } 2118 2119 void StmtProfiler::VisitOverloadExpr(const OverloadExpr *S) { 2120 VisitExpr(S); 2121 VisitNestedNameSpecifier(S->getQualifier()); 2122 VisitName(S->getName(), /*TreatAsDecl*/ true); 2123 ID.AddBoolean(S->hasExplicitTemplateArgs()); 2124 if (S->hasExplicitTemplateArgs()) 2125 VisitTemplateArguments(S->getTemplateArgs(), S->getNumTemplateArgs()); 2126 } 2127 2128 void 2129 StmtProfiler::VisitUnresolvedLookupExpr(const UnresolvedLookupExpr *S) { 2130 VisitOverloadExpr(S); 2131 } 2132 2133 void StmtProfiler::VisitTypeTraitExpr(const TypeTraitExpr *S) { 2134 VisitExpr(S); 2135 ID.AddInteger(S->getTrait()); 2136 ID.AddInteger(S->getNumArgs()); 2137 for (unsigned I = 0, N = S->getNumArgs(); I != N; ++I) 2138 VisitType(S->getArg(I)->getType()); 2139 } 2140 2141 void StmtProfiler::VisitArrayTypeTraitExpr(const ArrayTypeTraitExpr *S) { 2142 VisitExpr(S); 2143 ID.AddInteger(S->getTrait()); 2144 VisitType(S->getQueriedType()); 2145 } 2146 2147 void StmtProfiler::VisitExpressionTraitExpr(const ExpressionTraitExpr *S) { 2148 VisitExpr(S); 2149 ID.AddInteger(S->getTrait()); 2150 VisitExpr(S->getQueriedExpression()); 2151 } 2152 2153 void StmtProfiler::VisitDependentScopeDeclRefExpr( 2154 const DependentScopeDeclRefExpr *S) { 2155 VisitExpr(S); 2156 VisitName(S->getDeclName()); 2157 VisitNestedNameSpecifier(S->getQualifier()); 2158 ID.AddBoolean(S->hasExplicitTemplateArgs()); 2159 if (S->hasExplicitTemplateArgs()) 2160 VisitTemplateArguments(S->getTemplateArgs(), S->getNumTemplateArgs()); 2161 } 2162 2163 void StmtProfiler::VisitExprWithCleanups(const ExprWithCleanups *S) { 2164 VisitExpr(S); 2165 } 2166 2167 void StmtProfiler::VisitCXXUnresolvedConstructExpr( 2168 const CXXUnresolvedConstructExpr *S) { 2169 VisitExpr(S); 2170 VisitType(S->getTypeAsWritten()); 2171 ID.AddInteger(S->isListInitialization()); 2172 } 2173 2174 void StmtProfiler::VisitCXXDependentScopeMemberExpr( 2175 const CXXDependentScopeMemberExpr *S) { 2176 ID.AddBoolean(S->isImplicitAccess()); 2177 if (!S->isImplicitAccess()) { 2178 VisitExpr(S); 2179 ID.AddBoolean(S->isArrow()); 2180 } 2181 VisitNestedNameSpecifier(S->getQualifier()); 2182 VisitName(S->getMember()); 2183 ID.AddBoolean(S->hasExplicitTemplateArgs()); 2184 if (S->hasExplicitTemplateArgs()) 2185 VisitTemplateArguments(S->getTemplateArgs(), S->getNumTemplateArgs()); 2186 } 2187 2188 void StmtProfiler::VisitUnresolvedMemberExpr(const UnresolvedMemberExpr *S) { 2189 ID.AddBoolean(S->isImplicitAccess()); 2190 if (!S->isImplicitAccess()) { 2191 VisitExpr(S); 2192 ID.AddBoolean(S->isArrow()); 2193 } 2194 VisitNestedNameSpecifier(S->getQualifier()); 2195 VisitName(S->getMemberName()); 2196 ID.AddBoolean(S->hasExplicitTemplateArgs()); 2197 if (S->hasExplicitTemplateArgs()) 2198 VisitTemplateArguments(S->getTemplateArgs(), S->getNumTemplateArgs()); 2199 } 2200 2201 void StmtProfiler::VisitCXXNoexceptExpr(const CXXNoexceptExpr *S) { 2202 VisitExpr(S); 2203 } 2204 2205 void StmtProfiler::VisitPackExpansionExpr(const PackExpansionExpr *S) { 2206 VisitExpr(S); 2207 } 2208 2209 void StmtProfiler::VisitSizeOfPackExpr(const SizeOfPackExpr *S) { 2210 VisitExpr(S); 2211 VisitDecl(S->getPack()); 2212 if (S->isPartiallySubstituted()) { 2213 auto Args = S->getPartialArguments(); 2214 ID.AddInteger(Args.size()); 2215 for (const auto &TA : Args) 2216 VisitTemplateArgument(TA); 2217 } else { 2218 ID.AddInteger(0); 2219 } 2220 } 2221 2222 void StmtProfiler::VisitSubstNonTypeTemplateParmPackExpr( 2223 const SubstNonTypeTemplateParmPackExpr *S) { 2224 VisitExpr(S); 2225 VisitDecl(S->getParameterPack()); 2226 VisitTemplateArgument(S->getArgumentPack()); 2227 } 2228 2229 void StmtProfiler::VisitSubstNonTypeTemplateParmExpr( 2230 const SubstNonTypeTemplateParmExpr *E) { 2231 // Profile exactly as the replacement expression. 2232 Visit(E->getReplacement()); 2233 } 2234 2235 void StmtProfiler::VisitFunctionParmPackExpr(const FunctionParmPackExpr *S) { 2236 VisitExpr(S); 2237 VisitDecl(S->getParameterPack()); 2238 ID.AddInteger(S->getNumExpansions()); 2239 for (FunctionParmPackExpr::iterator I = S->begin(), E = S->end(); I != E; ++I) 2240 VisitDecl(*I); 2241 } 2242 2243 void StmtProfiler::VisitMaterializeTemporaryExpr( 2244 const MaterializeTemporaryExpr *S) { 2245 VisitExpr(S); 2246 } 2247 2248 void StmtProfiler::VisitCXXFoldExpr(const CXXFoldExpr *S) { 2249 VisitExpr(S); 2250 ID.AddInteger(S->getOperator()); 2251 } 2252 2253 void StmtProfiler::VisitCXXParenListInitExpr(const CXXParenListInitExpr *S) { 2254 VisitExpr(S); 2255 } 2256 2257 void StmtProfiler::VisitCoroutineBodyStmt(const CoroutineBodyStmt *S) { 2258 VisitStmt(S); 2259 } 2260 2261 void StmtProfiler::VisitCoreturnStmt(const CoreturnStmt *S) { 2262 VisitStmt(S); 2263 } 2264 2265 void StmtProfiler::VisitCoawaitExpr(const CoawaitExpr *S) { 2266 VisitExpr(S); 2267 } 2268 2269 void StmtProfiler::VisitDependentCoawaitExpr(const DependentCoawaitExpr *S) { 2270 VisitExpr(S); 2271 } 2272 2273 void StmtProfiler::VisitCoyieldExpr(const CoyieldExpr *S) { 2274 VisitExpr(S); 2275 } 2276 2277 void StmtProfiler::VisitOpaqueValueExpr(const OpaqueValueExpr *E) { 2278 VisitExpr(E); 2279 } 2280 2281 void StmtProfiler::VisitTypoExpr(const TypoExpr *E) { 2282 VisitExpr(E); 2283 } 2284 2285 void StmtProfiler::VisitSourceLocExpr(const SourceLocExpr *E) { 2286 VisitExpr(E); 2287 } 2288 2289 void StmtProfiler::VisitRecoveryExpr(const RecoveryExpr *E) { VisitExpr(E); } 2290 2291 void StmtProfiler::VisitObjCStringLiteral(const ObjCStringLiteral *S) { 2292 VisitExpr(S); 2293 } 2294 2295 void StmtProfiler::VisitObjCBoxedExpr(const ObjCBoxedExpr *E) { 2296 VisitExpr(E); 2297 } 2298 2299 void StmtProfiler::VisitObjCArrayLiteral(const ObjCArrayLiteral *E) { 2300 VisitExpr(E); 2301 } 2302 2303 void StmtProfiler::VisitObjCDictionaryLiteral(const ObjCDictionaryLiteral *E) { 2304 VisitExpr(E); 2305 } 2306 2307 void StmtProfiler::VisitObjCEncodeExpr(const ObjCEncodeExpr *S) { 2308 VisitExpr(S); 2309 VisitType(S->getEncodedType()); 2310 } 2311 2312 void StmtProfiler::VisitObjCSelectorExpr(const ObjCSelectorExpr *S) { 2313 VisitExpr(S); 2314 VisitName(S->getSelector()); 2315 } 2316 2317 void StmtProfiler::VisitObjCProtocolExpr(const ObjCProtocolExpr *S) { 2318 VisitExpr(S); 2319 VisitDecl(S->getProtocol()); 2320 } 2321 2322 void StmtProfiler::VisitObjCIvarRefExpr(const ObjCIvarRefExpr *S) { 2323 VisitExpr(S); 2324 VisitDecl(S->getDecl()); 2325 ID.AddBoolean(S->isArrow()); 2326 ID.AddBoolean(S->isFreeIvar()); 2327 } 2328 2329 void StmtProfiler::VisitObjCPropertyRefExpr(const ObjCPropertyRefExpr *S) { 2330 VisitExpr(S); 2331 if (S->isImplicitProperty()) { 2332 VisitDecl(S->getImplicitPropertyGetter()); 2333 VisitDecl(S->getImplicitPropertySetter()); 2334 } else { 2335 VisitDecl(S->getExplicitProperty()); 2336 } 2337 if (S->isSuperReceiver()) { 2338 ID.AddBoolean(S->isSuperReceiver()); 2339 VisitType(S->getSuperReceiverType()); 2340 } 2341 } 2342 2343 void StmtProfiler::VisitObjCSubscriptRefExpr(const ObjCSubscriptRefExpr *S) { 2344 VisitExpr(S); 2345 VisitDecl(S->getAtIndexMethodDecl()); 2346 VisitDecl(S->setAtIndexMethodDecl()); 2347 } 2348 2349 void StmtProfiler::VisitObjCMessageExpr(const ObjCMessageExpr *S) { 2350 VisitExpr(S); 2351 VisitName(S->getSelector()); 2352 VisitDecl(S->getMethodDecl()); 2353 } 2354 2355 void StmtProfiler::VisitObjCIsaExpr(const ObjCIsaExpr *S) { 2356 VisitExpr(S); 2357 ID.AddBoolean(S->isArrow()); 2358 } 2359 2360 void StmtProfiler::VisitObjCBoolLiteralExpr(const ObjCBoolLiteralExpr *S) { 2361 VisitExpr(S); 2362 ID.AddBoolean(S->getValue()); 2363 } 2364 2365 void StmtProfiler::VisitObjCIndirectCopyRestoreExpr( 2366 const ObjCIndirectCopyRestoreExpr *S) { 2367 VisitExpr(S); 2368 ID.AddBoolean(S->shouldCopy()); 2369 } 2370 2371 void StmtProfiler::VisitObjCBridgedCastExpr(const ObjCBridgedCastExpr *S) { 2372 VisitExplicitCastExpr(S); 2373 ID.AddBoolean(S->getBridgeKind()); 2374 } 2375 2376 void StmtProfiler::VisitObjCAvailabilityCheckExpr( 2377 const ObjCAvailabilityCheckExpr *S) { 2378 VisitExpr(S); 2379 } 2380 2381 void StmtProfiler::VisitTemplateArguments(const TemplateArgumentLoc *Args, 2382 unsigned NumArgs) { 2383 ID.AddInteger(NumArgs); 2384 for (unsigned I = 0; I != NumArgs; ++I) 2385 VisitTemplateArgument(Args[I].getArgument()); 2386 } 2387 2388 void StmtProfiler::VisitTemplateArgument(const TemplateArgument &Arg) { 2389 // Mostly repetitive with TemplateArgument::Profile! 2390 ID.AddInteger(Arg.getKind()); 2391 switch (Arg.getKind()) { 2392 case TemplateArgument::Null: 2393 break; 2394 2395 case TemplateArgument::Type: 2396 VisitType(Arg.getAsType()); 2397 break; 2398 2399 case TemplateArgument::Template: 2400 case TemplateArgument::TemplateExpansion: 2401 VisitTemplateName(Arg.getAsTemplateOrTemplatePattern()); 2402 break; 2403 2404 case TemplateArgument::Declaration: 2405 VisitType(Arg.getParamTypeForDecl()); 2406 // FIXME: Do we need to recursively decompose template parameter objects? 2407 VisitDecl(Arg.getAsDecl()); 2408 break; 2409 2410 case TemplateArgument::NullPtr: 2411 VisitType(Arg.getNullPtrType()); 2412 break; 2413 2414 case TemplateArgument::Integral: 2415 VisitType(Arg.getIntegralType()); 2416 Arg.getAsIntegral().Profile(ID); 2417 break; 2418 2419 case TemplateArgument::StructuralValue: 2420 VisitType(Arg.getStructuralValueType()); 2421 // FIXME: Do we need to recursively decompose this ourselves? 2422 Arg.getAsStructuralValue().Profile(ID); 2423 break; 2424 2425 case TemplateArgument::Expression: 2426 Visit(Arg.getAsExpr()); 2427 break; 2428 2429 case TemplateArgument::Pack: 2430 for (const auto &P : Arg.pack_elements()) 2431 VisitTemplateArgument(P); 2432 break; 2433 } 2434 } 2435 2436 void Stmt::Profile(llvm::FoldingSetNodeID &ID, const ASTContext &Context, 2437 bool Canonical, bool ProfileLambdaExpr) const { 2438 StmtProfilerWithPointers Profiler(ID, Context, Canonical, ProfileLambdaExpr); 2439 Profiler.Visit(this); 2440 } 2441 2442 void Stmt::ProcessODRHash(llvm::FoldingSetNodeID &ID, 2443 class ODRHash &Hash) const { 2444 StmtProfilerWithoutPointers Profiler(ID, Hash); 2445 Profiler.Visit(this); 2446 } 2447