10b57cec5SDimitry Andric //===---- StmtProfile.cpp - Profile implementation for Stmt ASTs ----------===// 20b57cec5SDimitry Andric // 30b57cec5SDimitry Andric // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. 40b57cec5SDimitry Andric // See https://llvm.org/LICENSE.txt for license information. 50b57cec5SDimitry Andric // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 60b57cec5SDimitry Andric // 70b57cec5SDimitry Andric //===----------------------------------------------------------------------===// 80b57cec5SDimitry Andric // 90b57cec5SDimitry Andric // This file implements the Stmt::Profile method, which builds a unique bit 100b57cec5SDimitry Andric // representation that identifies a statement/expression. 110b57cec5SDimitry Andric // 120b57cec5SDimitry Andric //===----------------------------------------------------------------------===// 130b57cec5SDimitry Andric #include "clang/AST/ASTContext.h" 140b57cec5SDimitry Andric #include "clang/AST/DeclCXX.h" 150b57cec5SDimitry Andric #include "clang/AST/DeclObjC.h" 160b57cec5SDimitry Andric #include "clang/AST/DeclTemplate.h" 170b57cec5SDimitry Andric #include "clang/AST/Expr.h" 180b57cec5SDimitry Andric #include "clang/AST/ExprCXX.h" 190b57cec5SDimitry Andric #include "clang/AST/ExprObjC.h" 200b57cec5SDimitry Andric #include "clang/AST/ExprOpenMP.h" 210b57cec5SDimitry Andric #include "clang/AST/ODRHash.h" 225ffd83dbSDimitry Andric #include "clang/AST/OpenMPClause.h" 230b57cec5SDimitry Andric #include "clang/AST/StmtVisitor.h" 240b57cec5SDimitry Andric #include "llvm/ADT/FoldingSet.h" 250b57cec5SDimitry Andric using namespace clang; 260b57cec5SDimitry Andric 270b57cec5SDimitry Andric namespace { 280b57cec5SDimitry Andric class StmtProfiler : public ConstStmtVisitor<StmtProfiler> { 290b57cec5SDimitry Andric protected: 300b57cec5SDimitry Andric llvm::FoldingSetNodeID &ID; 310b57cec5SDimitry Andric bool Canonical; 3206c3fb27SDimitry Andric bool ProfileLambdaExpr; 330b57cec5SDimitry Andric 340b57cec5SDimitry Andric public: 3506c3fb27SDimitry Andric StmtProfiler(llvm::FoldingSetNodeID &ID, bool Canonical, 3606c3fb27SDimitry Andric bool ProfileLambdaExpr) 3706c3fb27SDimitry Andric : ID(ID), Canonical(Canonical), ProfileLambdaExpr(ProfileLambdaExpr) {} 380b57cec5SDimitry Andric 390b57cec5SDimitry Andric virtual ~StmtProfiler() {} 400b57cec5SDimitry Andric 410b57cec5SDimitry Andric void VisitStmt(const Stmt *S); 420b57cec5SDimitry Andric 4381ad6265SDimitry Andric void VisitStmtNoChildren(const Stmt *S) { 4481ad6265SDimitry Andric HandleStmtClass(S->getStmtClass()); 4581ad6265SDimitry Andric } 4681ad6265SDimitry Andric 470b57cec5SDimitry Andric virtual void HandleStmtClass(Stmt::StmtClass SC) = 0; 480b57cec5SDimitry Andric 490b57cec5SDimitry Andric #define STMT(Node, Base) void Visit##Node(const Node *S); 500b57cec5SDimitry Andric #include "clang/AST/StmtNodes.inc" 510b57cec5SDimitry Andric 520b57cec5SDimitry Andric /// Visit a declaration that is referenced within an expression 530b57cec5SDimitry Andric /// or statement. 540b57cec5SDimitry Andric virtual void VisitDecl(const Decl *D) = 0; 550b57cec5SDimitry Andric 560b57cec5SDimitry Andric /// Visit a type that is referenced within an expression or 570b57cec5SDimitry Andric /// statement. 580b57cec5SDimitry Andric virtual void VisitType(QualType T) = 0; 590b57cec5SDimitry Andric 600b57cec5SDimitry Andric /// Visit a name that occurs within an expression or statement. 610b57cec5SDimitry Andric virtual void VisitName(DeclarationName Name, bool TreatAsDecl = false) = 0; 620b57cec5SDimitry Andric 630b57cec5SDimitry Andric /// Visit identifiers that are not in Decl's or Type's. 64*0fca6ea1SDimitry Andric virtual void VisitIdentifierInfo(const IdentifierInfo *II) = 0; 650b57cec5SDimitry Andric 660b57cec5SDimitry Andric /// Visit a nested-name-specifier that occurs within an expression 670b57cec5SDimitry Andric /// or statement. 680b57cec5SDimitry Andric virtual void VisitNestedNameSpecifier(NestedNameSpecifier *NNS) = 0; 690b57cec5SDimitry Andric 700b57cec5SDimitry Andric /// Visit a template name that occurs within an expression or 710b57cec5SDimitry Andric /// statement. 720b57cec5SDimitry Andric virtual void VisitTemplateName(TemplateName Name) = 0; 730b57cec5SDimitry Andric 740b57cec5SDimitry Andric /// Visit template arguments that occur within an expression or 750b57cec5SDimitry Andric /// statement. 760b57cec5SDimitry Andric void VisitTemplateArguments(const TemplateArgumentLoc *Args, 770b57cec5SDimitry Andric unsigned NumArgs); 780b57cec5SDimitry Andric 790b57cec5SDimitry Andric /// Visit a single template argument. 800b57cec5SDimitry Andric void VisitTemplateArgument(const TemplateArgument &Arg); 810b57cec5SDimitry Andric }; 820b57cec5SDimitry Andric 830b57cec5SDimitry Andric class StmtProfilerWithPointers : public StmtProfiler { 840b57cec5SDimitry Andric const ASTContext &Context; 850b57cec5SDimitry Andric 860b57cec5SDimitry Andric public: 870b57cec5SDimitry Andric StmtProfilerWithPointers(llvm::FoldingSetNodeID &ID, 8806c3fb27SDimitry Andric const ASTContext &Context, bool Canonical, 8906c3fb27SDimitry Andric bool ProfileLambdaExpr) 9006c3fb27SDimitry Andric : StmtProfiler(ID, Canonical, ProfileLambdaExpr), Context(Context) {} 9106c3fb27SDimitry Andric 920b57cec5SDimitry Andric private: 930b57cec5SDimitry Andric void HandleStmtClass(Stmt::StmtClass SC) override { 940b57cec5SDimitry Andric ID.AddInteger(SC); 950b57cec5SDimitry Andric } 960b57cec5SDimitry Andric 970b57cec5SDimitry Andric void VisitDecl(const Decl *D) override { 980b57cec5SDimitry Andric ID.AddInteger(D ? D->getKind() : 0); 990b57cec5SDimitry Andric 1000b57cec5SDimitry Andric if (Canonical && D) { 1010b57cec5SDimitry Andric if (const NonTypeTemplateParmDecl *NTTP = 1020b57cec5SDimitry Andric dyn_cast<NonTypeTemplateParmDecl>(D)) { 1030b57cec5SDimitry Andric ID.AddInteger(NTTP->getDepth()); 1040b57cec5SDimitry Andric ID.AddInteger(NTTP->getIndex()); 1050b57cec5SDimitry Andric ID.AddBoolean(NTTP->isParameterPack()); 10606c3fb27SDimitry Andric // C++20 [temp.over.link]p6: 10706c3fb27SDimitry Andric // Two template-parameters are equivalent under the following 10806c3fb27SDimitry Andric // conditions: [...] if they declare non-type template parameters, 10906c3fb27SDimitry Andric // they have equivalent types ignoring the use of type-constraints 11006c3fb27SDimitry Andric // for placeholder types 11106c3fb27SDimitry Andric // 11206c3fb27SDimitry Andric // TODO: Why do we need to include the type in the profile? It's not 11306c3fb27SDimitry Andric // part of the mangling. 11406c3fb27SDimitry Andric VisitType(Context.getUnconstrainedType(NTTP->getType())); 1150b57cec5SDimitry Andric return; 1160b57cec5SDimitry Andric } 1170b57cec5SDimitry Andric 1180b57cec5SDimitry Andric if (const ParmVarDecl *Parm = dyn_cast<ParmVarDecl>(D)) { 1190b57cec5SDimitry Andric // The Itanium C++ ABI uses the type, scope depth, and scope 1200b57cec5SDimitry Andric // index of a parameter when mangling expressions that involve 1210b57cec5SDimitry Andric // function parameters, so we will use the parameter's type for 1220b57cec5SDimitry Andric // establishing function parameter identity. That way, our 1230b57cec5SDimitry Andric // definition of "equivalent" (per C++ [temp.over.link]) is at 1240b57cec5SDimitry Andric // least as strong as the definition of "equivalent" used for 1250b57cec5SDimitry Andric // name mangling. 12606c3fb27SDimitry Andric // 12706c3fb27SDimitry Andric // TODO: The Itanium C++ ABI only uses the top-level cv-qualifiers, 12806c3fb27SDimitry Andric // not the entirety of the type. 1290b57cec5SDimitry Andric VisitType(Parm->getType()); 1300b57cec5SDimitry Andric ID.AddInteger(Parm->getFunctionScopeDepth()); 1310b57cec5SDimitry Andric ID.AddInteger(Parm->getFunctionScopeIndex()); 1320b57cec5SDimitry Andric return; 1330b57cec5SDimitry Andric } 1340b57cec5SDimitry Andric 1350b57cec5SDimitry Andric if (const TemplateTypeParmDecl *TTP = 1360b57cec5SDimitry Andric dyn_cast<TemplateTypeParmDecl>(D)) { 1370b57cec5SDimitry Andric ID.AddInteger(TTP->getDepth()); 1380b57cec5SDimitry Andric ID.AddInteger(TTP->getIndex()); 1390b57cec5SDimitry Andric ID.AddBoolean(TTP->isParameterPack()); 1400b57cec5SDimitry Andric return; 1410b57cec5SDimitry Andric } 1420b57cec5SDimitry Andric 1430b57cec5SDimitry Andric if (const TemplateTemplateParmDecl *TTP = 1440b57cec5SDimitry Andric dyn_cast<TemplateTemplateParmDecl>(D)) { 1450b57cec5SDimitry Andric ID.AddInteger(TTP->getDepth()); 1460b57cec5SDimitry Andric ID.AddInteger(TTP->getIndex()); 1470b57cec5SDimitry Andric ID.AddBoolean(TTP->isParameterPack()); 1480b57cec5SDimitry Andric return; 1490b57cec5SDimitry Andric } 1500b57cec5SDimitry Andric } 1510b57cec5SDimitry Andric 1520b57cec5SDimitry Andric ID.AddPointer(D ? D->getCanonicalDecl() : nullptr); 1530b57cec5SDimitry Andric } 1540b57cec5SDimitry Andric 1550b57cec5SDimitry Andric void VisitType(QualType T) override { 1560b57cec5SDimitry Andric if (Canonical && !T.isNull()) 1570b57cec5SDimitry Andric T = Context.getCanonicalType(T); 1580b57cec5SDimitry Andric 1590b57cec5SDimitry Andric ID.AddPointer(T.getAsOpaquePtr()); 1600b57cec5SDimitry Andric } 1610b57cec5SDimitry Andric 1620b57cec5SDimitry Andric void VisitName(DeclarationName Name, bool /*TreatAsDecl*/) override { 1630b57cec5SDimitry Andric ID.AddPointer(Name.getAsOpaquePtr()); 1640b57cec5SDimitry Andric } 1650b57cec5SDimitry Andric 166*0fca6ea1SDimitry Andric void VisitIdentifierInfo(const IdentifierInfo *II) override { 1670b57cec5SDimitry Andric ID.AddPointer(II); 1680b57cec5SDimitry Andric } 1690b57cec5SDimitry Andric 1700b57cec5SDimitry Andric void VisitNestedNameSpecifier(NestedNameSpecifier *NNS) override { 1710b57cec5SDimitry Andric if (Canonical) 1720b57cec5SDimitry Andric NNS = Context.getCanonicalNestedNameSpecifier(NNS); 1730b57cec5SDimitry Andric ID.AddPointer(NNS); 1740b57cec5SDimitry Andric } 1750b57cec5SDimitry Andric 1760b57cec5SDimitry Andric void VisitTemplateName(TemplateName Name) override { 1770b57cec5SDimitry Andric if (Canonical) 1780b57cec5SDimitry Andric Name = Context.getCanonicalTemplateName(Name); 1790b57cec5SDimitry Andric 1800b57cec5SDimitry Andric Name.Profile(ID); 1810b57cec5SDimitry Andric } 1820b57cec5SDimitry Andric }; 1830b57cec5SDimitry Andric 1840b57cec5SDimitry Andric class StmtProfilerWithoutPointers : public StmtProfiler { 1850b57cec5SDimitry Andric ODRHash &Hash; 1860b57cec5SDimitry Andric public: 1870b57cec5SDimitry Andric StmtProfilerWithoutPointers(llvm::FoldingSetNodeID &ID, ODRHash &Hash) 18806c3fb27SDimitry Andric : StmtProfiler(ID, /*Canonical=*/false, /*ProfileLambdaExpr=*/false), 18906c3fb27SDimitry Andric Hash(Hash) {} 1900b57cec5SDimitry Andric 1910b57cec5SDimitry Andric private: 1920b57cec5SDimitry Andric void HandleStmtClass(Stmt::StmtClass SC) override { 1930b57cec5SDimitry Andric if (SC == Stmt::UnresolvedLookupExprClass) { 1940b57cec5SDimitry Andric // Pretend that the name looked up is a Decl due to how templates 1950b57cec5SDimitry Andric // handle some Decl lookups. 1960b57cec5SDimitry Andric ID.AddInteger(Stmt::DeclRefExprClass); 1970b57cec5SDimitry Andric } else { 1980b57cec5SDimitry Andric ID.AddInteger(SC); 1990b57cec5SDimitry Andric } 2000b57cec5SDimitry Andric } 2010b57cec5SDimitry Andric 2020b57cec5SDimitry Andric void VisitType(QualType T) override { 2030b57cec5SDimitry Andric Hash.AddQualType(T); 2040b57cec5SDimitry Andric } 2050b57cec5SDimitry Andric 2060b57cec5SDimitry Andric void VisitName(DeclarationName Name, bool TreatAsDecl) override { 2070b57cec5SDimitry Andric if (TreatAsDecl) { 2080b57cec5SDimitry Andric // A Decl can be null, so each Decl is preceded by a boolean to 2090b57cec5SDimitry Andric // store its nullness. Add a boolean here to match. 2100b57cec5SDimitry Andric ID.AddBoolean(true); 2110b57cec5SDimitry Andric } 2120b57cec5SDimitry Andric Hash.AddDeclarationName(Name, TreatAsDecl); 2130b57cec5SDimitry Andric } 214*0fca6ea1SDimitry Andric void VisitIdentifierInfo(const IdentifierInfo *II) override { 2150b57cec5SDimitry Andric ID.AddBoolean(II); 2160b57cec5SDimitry Andric if (II) { 2170b57cec5SDimitry Andric Hash.AddIdentifierInfo(II); 2180b57cec5SDimitry Andric } 2190b57cec5SDimitry Andric } 2200b57cec5SDimitry Andric void VisitDecl(const Decl *D) override { 2210b57cec5SDimitry Andric ID.AddBoolean(D); 2220b57cec5SDimitry Andric if (D) { 2230b57cec5SDimitry Andric Hash.AddDecl(D); 2240b57cec5SDimitry Andric } 2250b57cec5SDimitry Andric } 2260b57cec5SDimitry Andric void VisitTemplateName(TemplateName Name) override { 2270b57cec5SDimitry Andric Hash.AddTemplateName(Name); 2280b57cec5SDimitry Andric } 2290b57cec5SDimitry Andric void VisitNestedNameSpecifier(NestedNameSpecifier *NNS) override { 2300b57cec5SDimitry Andric ID.AddBoolean(NNS); 2310b57cec5SDimitry Andric if (NNS) { 2320b57cec5SDimitry Andric Hash.AddNestedNameSpecifier(NNS); 2330b57cec5SDimitry Andric } 2340b57cec5SDimitry Andric } 2350b57cec5SDimitry Andric }; 2360b57cec5SDimitry Andric } 2370b57cec5SDimitry Andric 2380b57cec5SDimitry Andric void StmtProfiler::VisitStmt(const Stmt *S) { 2390b57cec5SDimitry Andric assert(S && "Requires non-null Stmt pointer"); 2400b57cec5SDimitry Andric 24181ad6265SDimitry Andric VisitStmtNoChildren(S); 2420b57cec5SDimitry Andric 2430b57cec5SDimitry Andric for (const Stmt *SubStmt : S->children()) { 2440b57cec5SDimitry Andric if (SubStmt) 2450b57cec5SDimitry Andric Visit(SubStmt); 2460b57cec5SDimitry Andric else 2470b57cec5SDimitry Andric ID.AddInteger(0); 2480b57cec5SDimitry Andric } 2490b57cec5SDimitry Andric } 2500b57cec5SDimitry Andric 2510b57cec5SDimitry Andric void StmtProfiler::VisitDeclStmt(const DeclStmt *S) { 2520b57cec5SDimitry Andric VisitStmt(S); 2530b57cec5SDimitry Andric for (const auto *D : S->decls()) 2540b57cec5SDimitry Andric VisitDecl(D); 2550b57cec5SDimitry Andric } 2560b57cec5SDimitry Andric 2570b57cec5SDimitry Andric void StmtProfiler::VisitNullStmt(const NullStmt *S) { 2580b57cec5SDimitry Andric VisitStmt(S); 2590b57cec5SDimitry Andric } 2600b57cec5SDimitry Andric 2610b57cec5SDimitry Andric void StmtProfiler::VisitCompoundStmt(const CompoundStmt *S) { 2620b57cec5SDimitry Andric VisitStmt(S); 2630b57cec5SDimitry Andric } 2640b57cec5SDimitry Andric 2650b57cec5SDimitry Andric void StmtProfiler::VisitCaseStmt(const CaseStmt *S) { 2660b57cec5SDimitry Andric VisitStmt(S); 2670b57cec5SDimitry Andric } 2680b57cec5SDimitry Andric 2690b57cec5SDimitry Andric void StmtProfiler::VisitDefaultStmt(const DefaultStmt *S) { 2700b57cec5SDimitry Andric VisitStmt(S); 2710b57cec5SDimitry Andric } 2720b57cec5SDimitry Andric 2730b57cec5SDimitry Andric void StmtProfiler::VisitLabelStmt(const LabelStmt *S) { 2740b57cec5SDimitry Andric VisitStmt(S); 2750b57cec5SDimitry Andric VisitDecl(S->getDecl()); 2760b57cec5SDimitry Andric } 2770b57cec5SDimitry Andric 2780b57cec5SDimitry Andric void StmtProfiler::VisitAttributedStmt(const AttributedStmt *S) { 2790b57cec5SDimitry Andric VisitStmt(S); 2800b57cec5SDimitry Andric // TODO: maybe visit attributes? 2810b57cec5SDimitry Andric } 2820b57cec5SDimitry Andric 2830b57cec5SDimitry Andric void StmtProfiler::VisitIfStmt(const IfStmt *S) { 2840b57cec5SDimitry Andric VisitStmt(S); 2850b57cec5SDimitry Andric VisitDecl(S->getConditionVariable()); 2860b57cec5SDimitry Andric } 2870b57cec5SDimitry Andric 2880b57cec5SDimitry Andric void StmtProfiler::VisitSwitchStmt(const SwitchStmt *S) { 2890b57cec5SDimitry Andric VisitStmt(S); 2900b57cec5SDimitry Andric VisitDecl(S->getConditionVariable()); 2910b57cec5SDimitry Andric } 2920b57cec5SDimitry Andric 2930b57cec5SDimitry Andric void StmtProfiler::VisitWhileStmt(const WhileStmt *S) { 2940b57cec5SDimitry Andric VisitStmt(S); 2950b57cec5SDimitry Andric VisitDecl(S->getConditionVariable()); 2960b57cec5SDimitry Andric } 2970b57cec5SDimitry Andric 2980b57cec5SDimitry Andric void StmtProfiler::VisitDoStmt(const DoStmt *S) { 2990b57cec5SDimitry Andric VisitStmt(S); 3000b57cec5SDimitry Andric } 3010b57cec5SDimitry Andric 3020b57cec5SDimitry Andric void StmtProfiler::VisitForStmt(const ForStmt *S) { 3030b57cec5SDimitry Andric VisitStmt(S); 3040b57cec5SDimitry Andric } 3050b57cec5SDimitry Andric 3060b57cec5SDimitry Andric void StmtProfiler::VisitGotoStmt(const GotoStmt *S) { 3070b57cec5SDimitry Andric VisitStmt(S); 3080b57cec5SDimitry Andric VisitDecl(S->getLabel()); 3090b57cec5SDimitry Andric } 3100b57cec5SDimitry Andric 3110b57cec5SDimitry Andric void StmtProfiler::VisitIndirectGotoStmt(const IndirectGotoStmt *S) { 3120b57cec5SDimitry Andric VisitStmt(S); 3130b57cec5SDimitry Andric } 3140b57cec5SDimitry Andric 3150b57cec5SDimitry Andric void StmtProfiler::VisitContinueStmt(const ContinueStmt *S) { 3160b57cec5SDimitry Andric VisitStmt(S); 3170b57cec5SDimitry Andric } 3180b57cec5SDimitry Andric 3190b57cec5SDimitry Andric void StmtProfiler::VisitBreakStmt(const BreakStmt *S) { 3200b57cec5SDimitry Andric VisitStmt(S); 3210b57cec5SDimitry Andric } 3220b57cec5SDimitry Andric 3230b57cec5SDimitry Andric void StmtProfiler::VisitReturnStmt(const ReturnStmt *S) { 3240b57cec5SDimitry Andric VisitStmt(S); 3250b57cec5SDimitry Andric } 3260b57cec5SDimitry Andric 3270b57cec5SDimitry Andric void StmtProfiler::VisitGCCAsmStmt(const GCCAsmStmt *S) { 3280b57cec5SDimitry Andric VisitStmt(S); 3290b57cec5SDimitry Andric ID.AddBoolean(S->isVolatile()); 3300b57cec5SDimitry Andric ID.AddBoolean(S->isSimple()); 3310b57cec5SDimitry Andric VisitStringLiteral(S->getAsmString()); 3320b57cec5SDimitry Andric ID.AddInteger(S->getNumOutputs()); 3330b57cec5SDimitry Andric for (unsigned I = 0, N = S->getNumOutputs(); I != N; ++I) { 3340b57cec5SDimitry Andric ID.AddString(S->getOutputName(I)); 3350b57cec5SDimitry Andric VisitStringLiteral(S->getOutputConstraintLiteral(I)); 3360b57cec5SDimitry Andric } 3370b57cec5SDimitry Andric ID.AddInteger(S->getNumInputs()); 3380b57cec5SDimitry Andric for (unsigned I = 0, N = S->getNumInputs(); I != N; ++I) { 3390b57cec5SDimitry Andric ID.AddString(S->getInputName(I)); 3400b57cec5SDimitry Andric VisitStringLiteral(S->getInputConstraintLiteral(I)); 3410b57cec5SDimitry Andric } 3420b57cec5SDimitry Andric ID.AddInteger(S->getNumClobbers()); 3430b57cec5SDimitry Andric for (unsigned I = 0, N = S->getNumClobbers(); I != N; ++I) 3440b57cec5SDimitry Andric VisitStringLiteral(S->getClobberStringLiteral(I)); 3450b57cec5SDimitry Andric ID.AddInteger(S->getNumLabels()); 3460b57cec5SDimitry Andric for (auto *L : S->labels()) 3470b57cec5SDimitry Andric VisitDecl(L->getLabel()); 3480b57cec5SDimitry Andric } 3490b57cec5SDimitry Andric 3500b57cec5SDimitry Andric void StmtProfiler::VisitMSAsmStmt(const MSAsmStmt *S) { 3510b57cec5SDimitry Andric // FIXME: Implement MS style inline asm statement profiler. 3520b57cec5SDimitry Andric VisitStmt(S); 3530b57cec5SDimitry Andric } 3540b57cec5SDimitry Andric 3550b57cec5SDimitry Andric void StmtProfiler::VisitCXXCatchStmt(const CXXCatchStmt *S) { 3560b57cec5SDimitry Andric VisitStmt(S); 3570b57cec5SDimitry Andric VisitType(S->getCaughtType()); 3580b57cec5SDimitry Andric } 3590b57cec5SDimitry Andric 3600b57cec5SDimitry Andric void StmtProfiler::VisitCXXTryStmt(const CXXTryStmt *S) { 3610b57cec5SDimitry Andric VisitStmt(S); 3620b57cec5SDimitry Andric } 3630b57cec5SDimitry Andric 3640b57cec5SDimitry Andric void StmtProfiler::VisitCXXForRangeStmt(const CXXForRangeStmt *S) { 3650b57cec5SDimitry Andric VisitStmt(S); 3660b57cec5SDimitry Andric } 3670b57cec5SDimitry Andric 3680b57cec5SDimitry Andric void StmtProfiler::VisitMSDependentExistsStmt(const MSDependentExistsStmt *S) { 3690b57cec5SDimitry Andric VisitStmt(S); 3700b57cec5SDimitry Andric ID.AddBoolean(S->isIfExists()); 3710b57cec5SDimitry Andric VisitNestedNameSpecifier(S->getQualifierLoc().getNestedNameSpecifier()); 3720b57cec5SDimitry Andric VisitName(S->getNameInfo().getName()); 3730b57cec5SDimitry Andric } 3740b57cec5SDimitry Andric 3750b57cec5SDimitry Andric void StmtProfiler::VisitSEHTryStmt(const SEHTryStmt *S) { 3760b57cec5SDimitry Andric VisitStmt(S); 3770b57cec5SDimitry Andric } 3780b57cec5SDimitry Andric 3790b57cec5SDimitry Andric void StmtProfiler::VisitSEHFinallyStmt(const SEHFinallyStmt *S) { 3800b57cec5SDimitry Andric VisitStmt(S); 3810b57cec5SDimitry Andric } 3820b57cec5SDimitry Andric 3830b57cec5SDimitry Andric void StmtProfiler::VisitSEHExceptStmt(const SEHExceptStmt *S) { 3840b57cec5SDimitry Andric VisitStmt(S); 3850b57cec5SDimitry Andric } 3860b57cec5SDimitry Andric 3870b57cec5SDimitry Andric void StmtProfiler::VisitSEHLeaveStmt(const SEHLeaveStmt *S) { 3880b57cec5SDimitry Andric VisitStmt(S); 3890b57cec5SDimitry Andric } 3900b57cec5SDimitry Andric 3910b57cec5SDimitry Andric void StmtProfiler::VisitCapturedStmt(const CapturedStmt *S) { 3920b57cec5SDimitry Andric VisitStmt(S); 3930b57cec5SDimitry Andric } 3940b57cec5SDimitry Andric 3950b57cec5SDimitry Andric void StmtProfiler::VisitObjCForCollectionStmt(const ObjCForCollectionStmt *S) { 3960b57cec5SDimitry Andric VisitStmt(S); 3970b57cec5SDimitry Andric } 3980b57cec5SDimitry Andric 3990b57cec5SDimitry Andric void StmtProfiler::VisitObjCAtCatchStmt(const ObjCAtCatchStmt *S) { 4000b57cec5SDimitry Andric VisitStmt(S); 4010b57cec5SDimitry Andric ID.AddBoolean(S->hasEllipsis()); 4020b57cec5SDimitry Andric if (S->getCatchParamDecl()) 4030b57cec5SDimitry Andric VisitType(S->getCatchParamDecl()->getType()); 4040b57cec5SDimitry Andric } 4050b57cec5SDimitry Andric 4060b57cec5SDimitry Andric void StmtProfiler::VisitObjCAtFinallyStmt(const ObjCAtFinallyStmt *S) { 4070b57cec5SDimitry Andric VisitStmt(S); 4080b57cec5SDimitry Andric } 4090b57cec5SDimitry Andric 4100b57cec5SDimitry Andric void StmtProfiler::VisitObjCAtTryStmt(const ObjCAtTryStmt *S) { 4110b57cec5SDimitry Andric VisitStmt(S); 4120b57cec5SDimitry Andric } 4130b57cec5SDimitry Andric 4140b57cec5SDimitry Andric void 4150b57cec5SDimitry Andric StmtProfiler::VisitObjCAtSynchronizedStmt(const ObjCAtSynchronizedStmt *S) { 4160b57cec5SDimitry Andric VisitStmt(S); 4170b57cec5SDimitry Andric } 4180b57cec5SDimitry Andric 4190b57cec5SDimitry Andric void StmtProfiler::VisitObjCAtThrowStmt(const ObjCAtThrowStmt *S) { 4200b57cec5SDimitry Andric VisitStmt(S); 4210b57cec5SDimitry Andric } 4220b57cec5SDimitry Andric 4230b57cec5SDimitry Andric void 4240b57cec5SDimitry Andric StmtProfiler::VisitObjCAutoreleasePoolStmt(const ObjCAutoreleasePoolStmt *S) { 4250b57cec5SDimitry Andric VisitStmt(S); 4260b57cec5SDimitry Andric } 4270b57cec5SDimitry Andric 4280b57cec5SDimitry Andric namespace { 4290b57cec5SDimitry Andric class OMPClauseProfiler : public ConstOMPClauseVisitor<OMPClauseProfiler> { 4300b57cec5SDimitry Andric StmtProfiler *Profiler; 4310b57cec5SDimitry Andric /// Process clauses with list of variables. 4320b57cec5SDimitry Andric template <typename T> 4330b57cec5SDimitry Andric void VisitOMPClauseList(T *Node); 4340b57cec5SDimitry Andric 4350b57cec5SDimitry Andric public: 4360b57cec5SDimitry Andric OMPClauseProfiler(StmtProfiler *P) : Profiler(P) { } 437e8d8bef9SDimitry Andric #define GEN_CLANG_CLAUSE_CLASS 438e8d8bef9SDimitry Andric #define CLAUSE_CLASS(Enum, Str, Class) void Visit##Class(const Class *C); 439e8d8bef9SDimitry Andric #include "llvm/Frontend/OpenMP/OMP.inc" 4400b57cec5SDimitry Andric void VistOMPClauseWithPreInit(const OMPClauseWithPreInit *C); 4410b57cec5SDimitry Andric void VistOMPClauseWithPostUpdate(const OMPClauseWithPostUpdate *C); 4420b57cec5SDimitry Andric }; 4430b57cec5SDimitry Andric 4440b57cec5SDimitry Andric void OMPClauseProfiler::VistOMPClauseWithPreInit( 4450b57cec5SDimitry Andric const OMPClauseWithPreInit *C) { 4460b57cec5SDimitry Andric if (auto *S = C->getPreInitStmt()) 4470b57cec5SDimitry Andric Profiler->VisitStmt(S); 4480b57cec5SDimitry Andric } 4490b57cec5SDimitry Andric 4500b57cec5SDimitry Andric void OMPClauseProfiler::VistOMPClauseWithPostUpdate( 4510b57cec5SDimitry Andric const OMPClauseWithPostUpdate *C) { 4520b57cec5SDimitry Andric VistOMPClauseWithPreInit(C); 4530b57cec5SDimitry Andric if (auto *E = C->getPostUpdateExpr()) 4540b57cec5SDimitry Andric Profiler->VisitStmt(E); 4550b57cec5SDimitry Andric } 4560b57cec5SDimitry Andric 4570b57cec5SDimitry Andric void OMPClauseProfiler::VisitOMPIfClause(const OMPIfClause *C) { 4580b57cec5SDimitry Andric VistOMPClauseWithPreInit(C); 4590b57cec5SDimitry Andric if (C->getCondition()) 4600b57cec5SDimitry Andric Profiler->VisitStmt(C->getCondition()); 4610b57cec5SDimitry Andric } 4620b57cec5SDimitry Andric 4630b57cec5SDimitry Andric void OMPClauseProfiler::VisitOMPFinalClause(const OMPFinalClause *C) { 464a7dea167SDimitry Andric VistOMPClauseWithPreInit(C); 4650b57cec5SDimitry Andric if (C->getCondition()) 4660b57cec5SDimitry Andric Profiler->VisitStmt(C->getCondition()); 4670b57cec5SDimitry Andric } 4680b57cec5SDimitry Andric 4690b57cec5SDimitry Andric void OMPClauseProfiler::VisitOMPNumThreadsClause(const OMPNumThreadsClause *C) { 4700b57cec5SDimitry Andric VistOMPClauseWithPreInit(C); 4710b57cec5SDimitry Andric if (C->getNumThreads()) 4720b57cec5SDimitry Andric Profiler->VisitStmt(C->getNumThreads()); 4730b57cec5SDimitry Andric } 4740b57cec5SDimitry Andric 475349cc55cSDimitry Andric void OMPClauseProfiler::VisitOMPAlignClause(const OMPAlignClause *C) { 476349cc55cSDimitry Andric if (C->getAlignment()) 477349cc55cSDimitry Andric Profiler->VisitStmt(C->getAlignment()); 478349cc55cSDimitry Andric } 479349cc55cSDimitry Andric 4800b57cec5SDimitry Andric void OMPClauseProfiler::VisitOMPSafelenClause(const OMPSafelenClause *C) { 4810b57cec5SDimitry Andric if (C->getSafelen()) 4820b57cec5SDimitry Andric Profiler->VisitStmt(C->getSafelen()); 4830b57cec5SDimitry Andric } 4840b57cec5SDimitry Andric 4850b57cec5SDimitry Andric void OMPClauseProfiler::VisitOMPSimdlenClause(const OMPSimdlenClause *C) { 4860b57cec5SDimitry Andric if (C->getSimdlen()) 4870b57cec5SDimitry Andric Profiler->VisitStmt(C->getSimdlen()); 4880b57cec5SDimitry Andric } 4890b57cec5SDimitry Andric 490fe6060f1SDimitry Andric void OMPClauseProfiler::VisitOMPSizesClause(const OMPSizesClause *C) { 491bdd1243dSDimitry Andric for (auto *E : C->getSizesRefs()) 492fe6060f1SDimitry Andric if (E) 493fe6060f1SDimitry Andric Profiler->VisitExpr(E); 494fe6060f1SDimitry Andric } 495fe6060f1SDimitry Andric 496fe6060f1SDimitry Andric void OMPClauseProfiler::VisitOMPFullClause(const OMPFullClause *C) {} 497fe6060f1SDimitry Andric 498fe6060f1SDimitry Andric void OMPClauseProfiler::VisitOMPPartialClause(const OMPPartialClause *C) { 499fe6060f1SDimitry Andric if (const Expr *Factor = C->getFactor()) 500fe6060f1SDimitry Andric Profiler->VisitExpr(Factor); 501fe6060f1SDimitry Andric } 502fe6060f1SDimitry Andric 5030b57cec5SDimitry Andric void OMPClauseProfiler::VisitOMPAllocatorClause(const OMPAllocatorClause *C) { 5040b57cec5SDimitry Andric if (C->getAllocator()) 5050b57cec5SDimitry Andric Profiler->VisitStmt(C->getAllocator()); 5060b57cec5SDimitry Andric } 5070b57cec5SDimitry Andric 5080b57cec5SDimitry Andric void OMPClauseProfiler::VisitOMPCollapseClause(const OMPCollapseClause *C) { 5090b57cec5SDimitry Andric if (C->getNumForLoops()) 5100b57cec5SDimitry Andric Profiler->VisitStmt(C->getNumForLoops()); 5110b57cec5SDimitry Andric } 5120b57cec5SDimitry Andric 5135ffd83dbSDimitry Andric void OMPClauseProfiler::VisitOMPDetachClause(const OMPDetachClause *C) { 5145ffd83dbSDimitry Andric if (Expr *Evt = C->getEventHandler()) 5155ffd83dbSDimitry Andric Profiler->VisitStmt(Evt); 5165ffd83dbSDimitry Andric } 5175ffd83dbSDimitry Andric 518fe6060f1SDimitry Andric void OMPClauseProfiler::VisitOMPNovariantsClause(const OMPNovariantsClause *C) { 519fe6060f1SDimitry Andric VistOMPClauseWithPreInit(C); 520fe6060f1SDimitry Andric if (C->getCondition()) 521fe6060f1SDimitry Andric Profiler->VisitStmt(C->getCondition()); 522fe6060f1SDimitry Andric } 523fe6060f1SDimitry Andric 524fe6060f1SDimitry Andric void OMPClauseProfiler::VisitOMPNocontextClause(const OMPNocontextClause *C) { 525fe6060f1SDimitry Andric VistOMPClauseWithPreInit(C); 526fe6060f1SDimitry Andric if (C->getCondition()) 527fe6060f1SDimitry Andric Profiler->VisitStmt(C->getCondition()); 528fe6060f1SDimitry Andric } 529fe6060f1SDimitry Andric 5300b57cec5SDimitry Andric void OMPClauseProfiler::VisitOMPDefaultClause(const OMPDefaultClause *C) { } 5310b57cec5SDimitry Andric 5320b57cec5SDimitry Andric void OMPClauseProfiler::VisitOMPProcBindClause(const OMPProcBindClause *C) { } 5330b57cec5SDimitry Andric 5340b57cec5SDimitry Andric void OMPClauseProfiler::VisitOMPUnifiedAddressClause( 5350b57cec5SDimitry Andric const OMPUnifiedAddressClause *C) {} 5360b57cec5SDimitry Andric 5370b57cec5SDimitry Andric void OMPClauseProfiler::VisitOMPUnifiedSharedMemoryClause( 5380b57cec5SDimitry Andric const OMPUnifiedSharedMemoryClause *C) {} 5390b57cec5SDimitry Andric 5400b57cec5SDimitry Andric void OMPClauseProfiler::VisitOMPReverseOffloadClause( 5410b57cec5SDimitry Andric const OMPReverseOffloadClause *C) {} 5420b57cec5SDimitry Andric 5430b57cec5SDimitry Andric void OMPClauseProfiler::VisitOMPDynamicAllocatorsClause( 5440b57cec5SDimitry Andric const OMPDynamicAllocatorsClause *C) {} 5450b57cec5SDimitry Andric 5460b57cec5SDimitry Andric void OMPClauseProfiler::VisitOMPAtomicDefaultMemOrderClause( 5470b57cec5SDimitry Andric const OMPAtomicDefaultMemOrderClause *C) {} 5480b57cec5SDimitry Andric 549bdd1243dSDimitry Andric void OMPClauseProfiler::VisitOMPAtClause(const OMPAtClause *C) {} 550bdd1243dSDimitry Andric 551bdd1243dSDimitry Andric void OMPClauseProfiler::VisitOMPSeverityClause(const OMPSeverityClause *C) {} 552bdd1243dSDimitry Andric 553bdd1243dSDimitry Andric void OMPClauseProfiler::VisitOMPMessageClause(const OMPMessageClause *C) { 554bdd1243dSDimitry Andric if (C->getMessageString()) 555bdd1243dSDimitry Andric Profiler->VisitStmt(C->getMessageString()); 556bdd1243dSDimitry Andric } 557bdd1243dSDimitry Andric 5580b57cec5SDimitry Andric void OMPClauseProfiler::VisitOMPScheduleClause(const OMPScheduleClause *C) { 5590b57cec5SDimitry Andric VistOMPClauseWithPreInit(C); 5600b57cec5SDimitry Andric if (auto *S = C->getChunkSize()) 5610b57cec5SDimitry Andric Profiler->VisitStmt(S); 5620b57cec5SDimitry Andric } 5630b57cec5SDimitry Andric 5640b57cec5SDimitry Andric void OMPClauseProfiler::VisitOMPOrderedClause(const OMPOrderedClause *C) { 5650b57cec5SDimitry Andric if (auto *Num = C->getNumForLoops()) 5660b57cec5SDimitry Andric Profiler->VisitStmt(Num); 5670b57cec5SDimitry Andric } 5680b57cec5SDimitry Andric 5690b57cec5SDimitry Andric void OMPClauseProfiler::VisitOMPNowaitClause(const OMPNowaitClause *) {} 5700b57cec5SDimitry Andric 5710b57cec5SDimitry Andric void OMPClauseProfiler::VisitOMPUntiedClause(const OMPUntiedClause *) {} 5720b57cec5SDimitry Andric 5730b57cec5SDimitry Andric void OMPClauseProfiler::VisitOMPMergeableClause(const OMPMergeableClause *) {} 5740b57cec5SDimitry Andric 5750b57cec5SDimitry Andric void OMPClauseProfiler::VisitOMPReadClause(const OMPReadClause *) {} 5760b57cec5SDimitry Andric 5770b57cec5SDimitry Andric void OMPClauseProfiler::VisitOMPWriteClause(const OMPWriteClause *) {} 5780b57cec5SDimitry Andric 5790b57cec5SDimitry Andric void OMPClauseProfiler::VisitOMPUpdateClause(const OMPUpdateClause *) {} 5800b57cec5SDimitry Andric 5810b57cec5SDimitry Andric void OMPClauseProfiler::VisitOMPCaptureClause(const OMPCaptureClause *) {} 5820b57cec5SDimitry Andric 5830eae32dcSDimitry Andric void OMPClauseProfiler::VisitOMPCompareClause(const OMPCompareClause *) {} 5840eae32dcSDimitry Andric 5855f757f3fSDimitry Andric void OMPClauseProfiler::VisitOMPFailClause(const OMPFailClause *) {} 5865f757f3fSDimitry Andric 5870b57cec5SDimitry Andric void OMPClauseProfiler::VisitOMPSeqCstClause(const OMPSeqCstClause *) {} 5880b57cec5SDimitry Andric 5895ffd83dbSDimitry Andric void OMPClauseProfiler::VisitOMPAcqRelClause(const OMPAcqRelClause *) {} 5905ffd83dbSDimitry Andric 5915ffd83dbSDimitry Andric void OMPClauseProfiler::VisitOMPAcquireClause(const OMPAcquireClause *) {} 5925ffd83dbSDimitry Andric 5935ffd83dbSDimitry Andric void OMPClauseProfiler::VisitOMPReleaseClause(const OMPReleaseClause *) {} 5945ffd83dbSDimitry Andric 5955ffd83dbSDimitry Andric void OMPClauseProfiler::VisitOMPRelaxedClause(const OMPRelaxedClause *) {} 5965ffd83dbSDimitry Andric 597*0fca6ea1SDimitry Andric void OMPClauseProfiler::VisitOMPWeakClause(const OMPWeakClause *) {} 598*0fca6ea1SDimitry Andric 5990b57cec5SDimitry Andric void OMPClauseProfiler::VisitOMPThreadsClause(const OMPThreadsClause *) {} 6000b57cec5SDimitry Andric 6010b57cec5SDimitry Andric void OMPClauseProfiler::VisitOMPSIMDClause(const OMPSIMDClause *) {} 6020b57cec5SDimitry Andric 6030b57cec5SDimitry Andric void OMPClauseProfiler::VisitOMPNogroupClause(const OMPNogroupClause *) {} 6040b57cec5SDimitry Andric 605fe6060f1SDimitry Andric void OMPClauseProfiler::VisitOMPInitClause(const OMPInitClause *C) { 606fe6060f1SDimitry Andric VisitOMPClauseList(C); 607fe6060f1SDimitry Andric } 608fe6060f1SDimitry Andric 609fe6060f1SDimitry Andric void OMPClauseProfiler::VisitOMPUseClause(const OMPUseClause *C) { 610fe6060f1SDimitry Andric if (C->getInteropVar()) 611fe6060f1SDimitry Andric Profiler->VisitStmt(C->getInteropVar()); 612fe6060f1SDimitry Andric } 613fe6060f1SDimitry Andric 614fe6060f1SDimitry Andric void OMPClauseProfiler::VisitOMPDestroyClause(const OMPDestroyClause *C) { 615fe6060f1SDimitry Andric if (C->getInteropVar()) 616fe6060f1SDimitry Andric Profiler->VisitStmt(C->getInteropVar()); 617fe6060f1SDimitry Andric } 618fe6060f1SDimitry Andric 619fe6060f1SDimitry Andric void OMPClauseProfiler::VisitOMPFilterClause(const OMPFilterClause *C) { 620fe6060f1SDimitry Andric VistOMPClauseWithPreInit(C); 621fe6060f1SDimitry Andric if (C->getThreadID()) 622fe6060f1SDimitry Andric Profiler->VisitStmt(C->getThreadID()); 623fe6060f1SDimitry Andric } 6245ffd83dbSDimitry Andric 6250b57cec5SDimitry Andric template<typename T> 6260b57cec5SDimitry Andric void OMPClauseProfiler::VisitOMPClauseList(T *Node) { 6270b57cec5SDimitry Andric for (auto *E : Node->varlists()) { 6280b57cec5SDimitry Andric if (E) 6290b57cec5SDimitry Andric Profiler->VisitStmt(E); 6300b57cec5SDimitry Andric } 6310b57cec5SDimitry Andric } 6320b57cec5SDimitry Andric 6330b57cec5SDimitry Andric void OMPClauseProfiler::VisitOMPPrivateClause(const OMPPrivateClause *C) { 6340b57cec5SDimitry Andric VisitOMPClauseList(C); 6350b57cec5SDimitry Andric for (auto *E : C->private_copies()) { 6360b57cec5SDimitry Andric if (E) 6370b57cec5SDimitry Andric Profiler->VisitStmt(E); 6380b57cec5SDimitry Andric } 6390b57cec5SDimitry Andric } 6400b57cec5SDimitry Andric void 6410b57cec5SDimitry Andric OMPClauseProfiler::VisitOMPFirstprivateClause(const OMPFirstprivateClause *C) { 6420b57cec5SDimitry Andric VisitOMPClauseList(C); 6430b57cec5SDimitry Andric VistOMPClauseWithPreInit(C); 6440b57cec5SDimitry Andric for (auto *E : C->private_copies()) { 6450b57cec5SDimitry Andric if (E) 6460b57cec5SDimitry Andric Profiler->VisitStmt(E); 6470b57cec5SDimitry Andric } 6480b57cec5SDimitry Andric for (auto *E : C->inits()) { 6490b57cec5SDimitry Andric if (E) 6500b57cec5SDimitry Andric Profiler->VisitStmt(E); 6510b57cec5SDimitry Andric } 6520b57cec5SDimitry Andric } 6530b57cec5SDimitry Andric void 6540b57cec5SDimitry Andric OMPClauseProfiler::VisitOMPLastprivateClause(const OMPLastprivateClause *C) { 6550b57cec5SDimitry Andric VisitOMPClauseList(C); 6560b57cec5SDimitry Andric VistOMPClauseWithPostUpdate(C); 6570b57cec5SDimitry Andric for (auto *E : C->source_exprs()) { 6580b57cec5SDimitry Andric if (E) 6590b57cec5SDimitry Andric Profiler->VisitStmt(E); 6600b57cec5SDimitry Andric } 6610b57cec5SDimitry Andric for (auto *E : C->destination_exprs()) { 6620b57cec5SDimitry Andric if (E) 6630b57cec5SDimitry Andric Profiler->VisitStmt(E); 6640b57cec5SDimitry Andric } 6650b57cec5SDimitry Andric for (auto *E : C->assignment_ops()) { 6660b57cec5SDimitry Andric if (E) 6670b57cec5SDimitry Andric Profiler->VisitStmt(E); 6680b57cec5SDimitry Andric } 6690b57cec5SDimitry Andric } 6700b57cec5SDimitry Andric void OMPClauseProfiler::VisitOMPSharedClause(const OMPSharedClause *C) { 6710b57cec5SDimitry Andric VisitOMPClauseList(C); 6720b57cec5SDimitry Andric } 6730b57cec5SDimitry Andric void OMPClauseProfiler::VisitOMPReductionClause( 6740b57cec5SDimitry Andric const OMPReductionClause *C) { 6750b57cec5SDimitry Andric Profiler->VisitNestedNameSpecifier( 6760b57cec5SDimitry Andric C->getQualifierLoc().getNestedNameSpecifier()); 6770b57cec5SDimitry Andric Profiler->VisitName(C->getNameInfo().getName()); 6780b57cec5SDimitry Andric VisitOMPClauseList(C); 6790b57cec5SDimitry Andric VistOMPClauseWithPostUpdate(C); 6800b57cec5SDimitry Andric for (auto *E : C->privates()) { 6810b57cec5SDimitry Andric if (E) 6820b57cec5SDimitry Andric Profiler->VisitStmt(E); 6830b57cec5SDimitry Andric } 6840b57cec5SDimitry Andric for (auto *E : C->lhs_exprs()) { 6850b57cec5SDimitry Andric if (E) 6860b57cec5SDimitry Andric Profiler->VisitStmt(E); 6870b57cec5SDimitry Andric } 6880b57cec5SDimitry Andric for (auto *E : C->rhs_exprs()) { 6890b57cec5SDimitry Andric if (E) 6900b57cec5SDimitry Andric Profiler->VisitStmt(E); 6910b57cec5SDimitry Andric } 6920b57cec5SDimitry Andric for (auto *E : C->reduction_ops()) { 6930b57cec5SDimitry Andric if (E) 6940b57cec5SDimitry Andric Profiler->VisitStmt(E); 6950b57cec5SDimitry Andric } 6965ffd83dbSDimitry Andric if (C->getModifier() == clang::OMPC_REDUCTION_inscan) { 6975ffd83dbSDimitry Andric for (auto *E : C->copy_ops()) { 6985ffd83dbSDimitry Andric if (E) 6995ffd83dbSDimitry Andric Profiler->VisitStmt(E); 7005ffd83dbSDimitry Andric } 7015ffd83dbSDimitry Andric for (auto *E : C->copy_array_temps()) { 7025ffd83dbSDimitry Andric if (E) 7035ffd83dbSDimitry Andric Profiler->VisitStmt(E); 7045ffd83dbSDimitry Andric } 7055ffd83dbSDimitry Andric for (auto *E : C->copy_array_elems()) { 7065ffd83dbSDimitry Andric if (E) 7075ffd83dbSDimitry Andric Profiler->VisitStmt(E); 7085ffd83dbSDimitry Andric } 7095ffd83dbSDimitry Andric } 7100b57cec5SDimitry Andric } 7110b57cec5SDimitry Andric void OMPClauseProfiler::VisitOMPTaskReductionClause( 7120b57cec5SDimitry Andric const OMPTaskReductionClause *C) { 7130b57cec5SDimitry Andric Profiler->VisitNestedNameSpecifier( 7140b57cec5SDimitry Andric C->getQualifierLoc().getNestedNameSpecifier()); 7150b57cec5SDimitry Andric Profiler->VisitName(C->getNameInfo().getName()); 7160b57cec5SDimitry Andric VisitOMPClauseList(C); 7170b57cec5SDimitry Andric VistOMPClauseWithPostUpdate(C); 7180b57cec5SDimitry Andric for (auto *E : C->privates()) { 7190b57cec5SDimitry Andric if (E) 7200b57cec5SDimitry Andric Profiler->VisitStmt(E); 7210b57cec5SDimitry Andric } 7220b57cec5SDimitry Andric for (auto *E : C->lhs_exprs()) { 7230b57cec5SDimitry Andric if (E) 7240b57cec5SDimitry Andric Profiler->VisitStmt(E); 7250b57cec5SDimitry Andric } 7260b57cec5SDimitry Andric for (auto *E : C->rhs_exprs()) { 7270b57cec5SDimitry Andric if (E) 7280b57cec5SDimitry Andric Profiler->VisitStmt(E); 7290b57cec5SDimitry Andric } 7300b57cec5SDimitry Andric for (auto *E : C->reduction_ops()) { 7310b57cec5SDimitry Andric if (E) 7320b57cec5SDimitry Andric Profiler->VisitStmt(E); 7330b57cec5SDimitry Andric } 7340b57cec5SDimitry Andric } 7350b57cec5SDimitry Andric void OMPClauseProfiler::VisitOMPInReductionClause( 7360b57cec5SDimitry Andric const OMPInReductionClause *C) { 7370b57cec5SDimitry Andric Profiler->VisitNestedNameSpecifier( 7380b57cec5SDimitry Andric C->getQualifierLoc().getNestedNameSpecifier()); 7390b57cec5SDimitry Andric Profiler->VisitName(C->getNameInfo().getName()); 7400b57cec5SDimitry Andric VisitOMPClauseList(C); 7410b57cec5SDimitry Andric VistOMPClauseWithPostUpdate(C); 7420b57cec5SDimitry Andric for (auto *E : C->privates()) { 7430b57cec5SDimitry Andric if (E) 7440b57cec5SDimitry Andric Profiler->VisitStmt(E); 7450b57cec5SDimitry Andric } 7460b57cec5SDimitry Andric for (auto *E : C->lhs_exprs()) { 7470b57cec5SDimitry Andric if (E) 7480b57cec5SDimitry Andric Profiler->VisitStmt(E); 7490b57cec5SDimitry Andric } 7500b57cec5SDimitry Andric for (auto *E : C->rhs_exprs()) { 7510b57cec5SDimitry Andric if (E) 7520b57cec5SDimitry Andric Profiler->VisitStmt(E); 7530b57cec5SDimitry Andric } 7540b57cec5SDimitry Andric for (auto *E : C->reduction_ops()) { 7550b57cec5SDimitry Andric if (E) 7560b57cec5SDimitry Andric Profiler->VisitStmt(E); 7570b57cec5SDimitry Andric } 7580b57cec5SDimitry Andric for (auto *E : C->taskgroup_descriptors()) { 7590b57cec5SDimitry Andric if (E) 7600b57cec5SDimitry Andric Profiler->VisitStmt(E); 7610b57cec5SDimitry Andric } 7620b57cec5SDimitry Andric } 7630b57cec5SDimitry Andric void OMPClauseProfiler::VisitOMPLinearClause(const OMPLinearClause *C) { 7640b57cec5SDimitry Andric VisitOMPClauseList(C); 7650b57cec5SDimitry Andric VistOMPClauseWithPostUpdate(C); 7660b57cec5SDimitry Andric for (auto *E : C->privates()) { 7670b57cec5SDimitry Andric if (E) 7680b57cec5SDimitry Andric Profiler->VisitStmt(E); 7690b57cec5SDimitry Andric } 7700b57cec5SDimitry Andric for (auto *E : C->inits()) { 7710b57cec5SDimitry Andric if (E) 7720b57cec5SDimitry Andric Profiler->VisitStmt(E); 7730b57cec5SDimitry Andric } 7740b57cec5SDimitry Andric for (auto *E : C->updates()) { 7750b57cec5SDimitry Andric if (E) 7760b57cec5SDimitry Andric Profiler->VisitStmt(E); 7770b57cec5SDimitry Andric } 7780b57cec5SDimitry Andric for (auto *E : C->finals()) { 7790b57cec5SDimitry Andric if (E) 7800b57cec5SDimitry Andric Profiler->VisitStmt(E); 7810b57cec5SDimitry Andric } 7820b57cec5SDimitry Andric if (C->getStep()) 7830b57cec5SDimitry Andric Profiler->VisitStmt(C->getStep()); 7840b57cec5SDimitry Andric if (C->getCalcStep()) 7850b57cec5SDimitry Andric Profiler->VisitStmt(C->getCalcStep()); 7860b57cec5SDimitry Andric } 7870b57cec5SDimitry Andric void OMPClauseProfiler::VisitOMPAlignedClause(const OMPAlignedClause *C) { 7880b57cec5SDimitry Andric VisitOMPClauseList(C); 7890b57cec5SDimitry Andric if (C->getAlignment()) 7900b57cec5SDimitry Andric Profiler->VisitStmt(C->getAlignment()); 7910b57cec5SDimitry Andric } 7920b57cec5SDimitry Andric void OMPClauseProfiler::VisitOMPCopyinClause(const OMPCopyinClause *C) { 7930b57cec5SDimitry Andric VisitOMPClauseList(C); 7940b57cec5SDimitry Andric for (auto *E : C->source_exprs()) { 7950b57cec5SDimitry Andric if (E) 7960b57cec5SDimitry Andric Profiler->VisitStmt(E); 7970b57cec5SDimitry Andric } 7980b57cec5SDimitry Andric for (auto *E : C->destination_exprs()) { 7990b57cec5SDimitry Andric if (E) 8000b57cec5SDimitry Andric Profiler->VisitStmt(E); 8010b57cec5SDimitry Andric } 8020b57cec5SDimitry Andric for (auto *E : C->assignment_ops()) { 8030b57cec5SDimitry Andric if (E) 8040b57cec5SDimitry Andric Profiler->VisitStmt(E); 8050b57cec5SDimitry Andric } 8060b57cec5SDimitry Andric } 8070b57cec5SDimitry Andric void 8080b57cec5SDimitry Andric OMPClauseProfiler::VisitOMPCopyprivateClause(const OMPCopyprivateClause *C) { 8090b57cec5SDimitry Andric VisitOMPClauseList(C); 8100b57cec5SDimitry Andric for (auto *E : C->source_exprs()) { 8110b57cec5SDimitry Andric if (E) 8120b57cec5SDimitry Andric Profiler->VisitStmt(E); 8130b57cec5SDimitry Andric } 8140b57cec5SDimitry Andric for (auto *E : C->destination_exprs()) { 8150b57cec5SDimitry Andric if (E) 8160b57cec5SDimitry Andric Profiler->VisitStmt(E); 8170b57cec5SDimitry Andric } 8180b57cec5SDimitry Andric for (auto *E : C->assignment_ops()) { 8190b57cec5SDimitry Andric if (E) 8200b57cec5SDimitry Andric Profiler->VisitStmt(E); 8210b57cec5SDimitry Andric } 8220b57cec5SDimitry Andric } 8230b57cec5SDimitry Andric void OMPClauseProfiler::VisitOMPFlushClause(const OMPFlushClause *C) { 8240b57cec5SDimitry Andric VisitOMPClauseList(C); 8250b57cec5SDimitry Andric } 8265ffd83dbSDimitry Andric void OMPClauseProfiler::VisitOMPDepobjClause(const OMPDepobjClause *C) { 8275ffd83dbSDimitry Andric if (const Expr *Depobj = C->getDepobj()) 8285ffd83dbSDimitry Andric Profiler->VisitStmt(Depobj); 8295ffd83dbSDimitry Andric } 8300b57cec5SDimitry Andric void OMPClauseProfiler::VisitOMPDependClause(const OMPDependClause *C) { 8310b57cec5SDimitry Andric VisitOMPClauseList(C); 8320b57cec5SDimitry Andric } 8330b57cec5SDimitry Andric void OMPClauseProfiler::VisitOMPDeviceClause(const OMPDeviceClause *C) { 8340b57cec5SDimitry Andric if (C->getDevice()) 8350b57cec5SDimitry Andric Profiler->VisitStmt(C->getDevice()); 8360b57cec5SDimitry Andric } 8370b57cec5SDimitry Andric void OMPClauseProfiler::VisitOMPMapClause(const OMPMapClause *C) { 8380b57cec5SDimitry Andric VisitOMPClauseList(C); 8390b57cec5SDimitry Andric } 8400b57cec5SDimitry Andric void OMPClauseProfiler::VisitOMPAllocateClause(const OMPAllocateClause *C) { 8410b57cec5SDimitry Andric if (Expr *Allocator = C->getAllocator()) 8420b57cec5SDimitry Andric Profiler->VisitStmt(Allocator); 8430b57cec5SDimitry Andric VisitOMPClauseList(C); 8440b57cec5SDimitry Andric } 8450b57cec5SDimitry Andric void OMPClauseProfiler::VisitOMPNumTeamsClause(const OMPNumTeamsClause *C) { 8460b57cec5SDimitry Andric VistOMPClauseWithPreInit(C); 8470b57cec5SDimitry Andric if (C->getNumTeams()) 8480b57cec5SDimitry Andric Profiler->VisitStmt(C->getNumTeams()); 8490b57cec5SDimitry Andric } 8500b57cec5SDimitry Andric void OMPClauseProfiler::VisitOMPThreadLimitClause( 8510b57cec5SDimitry Andric const OMPThreadLimitClause *C) { 8520b57cec5SDimitry Andric VistOMPClauseWithPreInit(C); 8530b57cec5SDimitry Andric if (C->getThreadLimit()) 8540b57cec5SDimitry Andric Profiler->VisitStmt(C->getThreadLimit()); 8550b57cec5SDimitry Andric } 8560b57cec5SDimitry Andric void OMPClauseProfiler::VisitOMPPriorityClause(const OMPPriorityClause *C) { 857a7dea167SDimitry Andric VistOMPClauseWithPreInit(C); 8580b57cec5SDimitry Andric if (C->getPriority()) 8590b57cec5SDimitry Andric Profiler->VisitStmt(C->getPriority()); 8600b57cec5SDimitry Andric } 8610b57cec5SDimitry Andric void OMPClauseProfiler::VisitOMPGrainsizeClause(const OMPGrainsizeClause *C) { 862a7dea167SDimitry Andric VistOMPClauseWithPreInit(C); 8630b57cec5SDimitry Andric if (C->getGrainsize()) 8640b57cec5SDimitry Andric Profiler->VisitStmt(C->getGrainsize()); 8650b57cec5SDimitry Andric } 8660b57cec5SDimitry Andric void OMPClauseProfiler::VisitOMPNumTasksClause(const OMPNumTasksClause *C) { 867a7dea167SDimitry Andric VistOMPClauseWithPreInit(C); 8680b57cec5SDimitry Andric if (C->getNumTasks()) 8690b57cec5SDimitry Andric Profiler->VisitStmt(C->getNumTasks()); 8700b57cec5SDimitry Andric } 8710b57cec5SDimitry Andric void OMPClauseProfiler::VisitOMPHintClause(const OMPHintClause *C) { 8720b57cec5SDimitry Andric if (C->getHint()) 8730b57cec5SDimitry Andric Profiler->VisitStmt(C->getHint()); 8740b57cec5SDimitry Andric } 8750b57cec5SDimitry Andric void OMPClauseProfiler::VisitOMPToClause(const OMPToClause *C) { 8760b57cec5SDimitry Andric VisitOMPClauseList(C); 8770b57cec5SDimitry Andric } 8780b57cec5SDimitry Andric void OMPClauseProfiler::VisitOMPFromClause(const OMPFromClause *C) { 8790b57cec5SDimitry Andric VisitOMPClauseList(C); 8800b57cec5SDimitry Andric } 8810b57cec5SDimitry Andric void OMPClauseProfiler::VisitOMPUseDevicePtrClause( 8820b57cec5SDimitry Andric const OMPUseDevicePtrClause *C) { 8830b57cec5SDimitry Andric VisitOMPClauseList(C); 8840b57cec5SDimitry Andric } 8855ffd83dbSDimitry Andric void OMPClauseProfiler::VisitOMPUseDeviceAddrClause( 8865ffd83dbSDimitry Andric const OMPUseDeviceAddrClause *C) { 8875ffd83dbSDimitry Andric VisitOMPClauseList(C); 8885ffd83dbSDimitry Andric } 8890b57cec5SDimitry Andric void OMPClauseProfiler::VisitOMPIsDevicePtrClause( 8900b57cec5SDimitry Andric const OMPIsDevicePtrClause *C) { 8910b57cec5SDimitry Andric VisitOMPClauseList(C); 8920b57cec5SDimitry Andric } 89381ad6265SDimitry Andric void OMPClauseProfiler::VisitOMPHasDeviceAddrClause( 89481ad6265SDimitry Andric const OMPHasDeviceAddrClause *C) { 89581ad6265SDimitry Andric VisitOMPClauseList(C); 89681ad6265SDimitry Andric } 897480093f4SDimitry Andric void OMPClauseProfiler::VisitOMPNontemporalClause( 898480093f4SDimitry Andric const OMPNontemporalClause *C) { 899480093f4SDimitry Andric VisitOMPClauseList(C); 900480093f4SDimitry Andric for (auto *E : C->private_refs()) 901480093f4SDimitry Andric Profiler->VisitStmt(E); 9020b57cec5SDimitry Andric } 9035ffd83dbSDimitry Andric void OMPClauseProfiler::VisitOMPInclusiveClause(const OMPInclusiveClause *C) { 9045ffd83dbSDimitry Andric VisitOMPClauseList(C); 9055ffd83dbSDimitry Andric } 9065ffd83dbSDimitry Andric void OMPClauseProfiler::VisitOMPExclusiveClause(const OMPExclusiveClause *C) { 9075ffd83dbSDimitry Andric VisitOMPClauseList(C); 9085ffd83dbSDimitry Andric } 9095ffd83dbSDimitry Andric void OMPClauseProfiler::VisitOMPUsesAllocatorsClause( 9105ffd83dbSDimitry Andric const OMPUsesAllocatorsClause *C) { 9115ffd83dbSDimitry Andric for (unsigned I = 0, E = C->getNumberOfAllocators(); I < E; ++I) { 9125ffd83dbSDimitry Andric OMPUsesAllocatorsClause::Data D = C->getAllocatorData(I); 9135ffd83dbSDimitry Andric Profiler->VisitStmt(D.Allocator); 9145ffd83dbSDimitry Andric if (D.AllocatorTraits) 9155ffd83dbSDimitry Andric Profiler->VisitStmt(D.AllocatorTraits); 9165ffd83dbSDimitry Andric } 9175ffd83dbSDimitry Andric } 9185ffd83dbSDimitry Andric void OMPClauseProfiler::VisitOMPAffinityClause(const OMPAffinityClause *C) { 9195ffd83dbSDimitry Andric if (const Expr *Modifier = C->getModifier()) 9205ffd83dbSDimitry Andric Profiler->VisitStmt(Modifier); 9215ffd83dbSDimitry Andric for (const Expr *E : C->varlists()) 9225ffd83dbSDimitry Andric Profiler->VisitStmt(E); 9235ffd83dbSDimitry Andric } 9245ffd83dbSDimitry Andric void OMPClauseProfiler::VisitOMPOrderClause(const OMPOrderClause *C) {} 925349cc55cSDimitry Andric void OMPClauseProfiler::VisitOMPBindClause(const OMPBindClause *C) {} 926bdd1243dSDimitry Andric void OMPClauseProfiler::VisitOMPXDynCGroupMemClause( 927bdd1243dSDimitry Andric const OMPXDynCGroupMemClause *C) { 928bdd1243dSDimitry Andric VistOMPClauseWithPreInit(C); 929bdd1243dSDimitry Andric if (Expr *Size = C->getSize()) 930bdd1243dSDimitry Andric Profiler->VisitStmt(Size); 931bdd1243dSDimitry Andric } 93206c3fb27SDimitry Andric void OMPClauseProfiler::VisitOMPDoacrossClause(const OMPDoacrossClause *C) { 93306c3fb27SDimitry Andric VisitOMPClauseList(C); 93406c3fb27SDimitry Andric } 9355f757f3fSDimitry Andric void OMPClauseProfiler::VisitOMPXAttributeClause(const OMPXAttributeClause *C) { 9365f757f3fSDimitry Andric } 9375f757f3fSDimitry Andric void OMPClauseProfiler::VisitOMPXBareClause(const OMPXBareClause *C) {} 938480093f4SDimitry Andric } // namespace 9390b57cec5SDimitry Andric 9400b57cec5SDimitry Andric void 9410b57cec5SDimitry Andric StmtProfiler::VisitOMPExecutableDirective(const OMPExecutableDirective *S) { 9420b57cec5SDimitry Andric VisitStmt(S); 9430b57cec5SDimitry Andric OMPClauseProfiler P(this); 9440b57cec5SDimitry Andric ArrayRef<OMPClause *> Clauses = S->clauses(); 9450b57cec5SDimitry Andric for (ArrayRef<OMPClause *>::iterator I = Clauses.begin(), E = Clauses.end(); 9460b57cec5SDimitry Andric I != E; ++I) 9470b57cec5SDimitry Andric if (*I) 9480b57cec5SDimitry Andric P.Visit(*I); 9490b57cec5SDimitry Andric } 9500b57cec5SDimitry Andric 951fe6060f1SDimitry Andric void StmtProfiler::VisitOMPCanonicalLoop(const OMPCanonicalLoop *L) { 952fe6060f1SDimitry Andric VisitStmt(L); 953fe6060f1SDimitry Andric } 954fe6060f1SDimitry Andric 955fe6060f1SDimitry Andric void StmtProfiler::VisitOMPLoopBasedDirective(const OMPLoopBasedDirective *S) { 9560b57cec5SDimitry Andric VisitOMPExecutableDirective(S); 9570b57cec5SDimitry Andric } 9580b57cec5SDimitry Andric 959fe6060f1SDimitry Andric void StmtProfiler::VisitOMPLoopDirective(const OMPLoopDirective *S) { 960fe6060f1SDimitry Andric VisitOMPLoopBasedDirective(S); 961fe6060f1SDimitry Andric } 962fe6060f1SDimitry Andric 963349cc55cSDimitry Andric void StmtProfiler::VisitOMPMetaDirective(const OMPMetaDirective *S) { 964349cc55cSDimitry Andric VisitOMPExecutableDirective(S); 965349cc55cSDimitry Andric } 966349cc55cSDimitry Andric 9670b57cec5SDimitry Andric void StmtProfiler::VisitOMPParallelDirective(const OMPParallelDirective *S) { 9680b57cec5SDimitry Andric VisitOMPExecutableDirective(S); 9690b57cec5SDimitry Andric } 9700b57cec5SDimitry Andric 9710b57cec5SDimitry Andric void StmtProfiler::VisitOMPSimdDirective(const OMPSimdDirective *S) { 9720b57cec5SDimitry Andric VisitOMPLoopDirective(S); 9730b57cec5SDimitry Andric } 9740b57cec5SDimitry Andric 975349cc55cSDimitry Andric void StmtProfiler::VisitOMPLoopTransformationDirective( 976349cc55cSDimitry Andric const OMPLoopTransformationDirective *S) { 977fe6060f1SDimitry Andric VisitOMPLoopBasedDirective(S); 978fe6060f1SDimitry Andric } 979fe6060f1SDimitry Andric 980349cc55cSDimitry Andric void StmtProfiler::VisitOMPTileDirective(const OMPTileDirective *S) { 981349cc55cSDimitry Andric VisitOMPLoopTransformationDirective(S); 982349cc55cSDimitry Andric } 983349cc55cSDimitry Andric 984fe6060f1SDimitry Andric void StmtProfiler::VisitOMPUnrollDirective(const OMPUnrollDirective *S) { 985349cc55cSDimitry Andric VisitOMPLoopTransformationDirective(S); 986fe6060f1SDimitry Andric } 987fe6060f1SDimitry Andric 988*0fca6ea1SDimitry Andric void StmtProfiler::VisitOMPReverseDirective(const OMPReverseDirective *S) { 989*0fca6ea1SDimitry Andric VisitOMPLoopTransformationDirective(S); 990*0fca6ea1SDimitry Andric } 991*0fca6ea1SDimitry Andric 992*0fca6ea1SDimitry Andric void StmtProfiler::VisitOMPInterchangeDirective( 993*0fca6ea1SDimitry Andric const OMPInterchangeDirective *S) { 994*0fca6ea1SDimitry Andric VisitOMPLoopTransformationDirective(S); 995*0fca6ea1SDimitry Andric } 996*0fca6ea1SDimitry Andric 9970b57cec5SDimitry Andric void StmtProfiler::VisitOMPForDirective(const OMPForDirective *S) { 9980b57cec5SDimitry Andric VisitOMPLoopDirective(S); 9990b57cec5SDimitry Andric } 10000b57cec5SDimitry Andric 10010b57cec5SDimitry Andric void StmtProfiler::VisitOMPForSimdDirective(const OMPForSimdDirective *S) { 10020b57cec5SDimitry Andric VisitOMPLoopDirective(S); 10030b57cec5SDimitry Andric } 10040b57cec5SDimitry Andric 10050b57cec5SDimitry Andric void StmtProfiler::VisitOMPSectionsDirective(const OMPSectionsDirective *S) { 10060b57cec5SDimitry Andric VisitOMPExecutableDirective(S); 10070b57cec5SDimitry Andric } 10080b57cec5SDimitry Andric 10090b57cec5SDimitry Andric void StmtProfiler::VisitOMPSectionDirective(const OMPSectionDirective *S) { 10100b57cec5SDimitry Andric VisitOMPExecutableDirective(S); 10110b57cec5SDimitry Andric } 10120b57cec5SDimitry Andric 10135f757f3fSDimitry Andric void StmtProfiler::VisitOMPScopeDirective(const OMPScopeDirective *S) { 10145f757f3fSDimitry Andric VisitOMPExecutableDirective(S); 10155f757f3fSDimitry Andric } 10165f757f3fSDimitry Andric 10170b57cec5SDimitry Andric void StmtProfiler::VisitOMPSingleDirective(const OMPSingleDirective *S) { 10180b57cec5SDimitry Andric VisitOMPExecutableDirective(S); 10190b57cec5SDimitry Andric } 10200b57cec5SDimitry Andric 10210b57cec5SDimitry Andric void StmtProfiler::VisitOMPMasterDirective(const OMPMasterDirective *S) { 10220b57cec5SDimitry Andric VisitOMPExecutableDirective(S); 10230b57cec5SDimitry Andric } 10240b57cec5SDimitry Andric 10250b57cec5SDimitry Andric void StmtProfiler::VisitOMPCriticalDirective(const OMPCriticalDirective *S) { 10260b57cec5SDimitry Andric VisitOMPExecutableDirective(S); 10270b57cec5SDimitry Andric VisitName(S->getDirectiveName().getName()); 10280b57cec5SDimitry Andric } 10290b57cec5SDimitry Andric 10300b57cec5SDimitry Andric void 10310b57cec5SDimitry Andric StmtProfiler::VisitOMPParallelForDirective(const OMPParallelForDirective *S) { 10320b57cec5SDimitry Andric VisitOMPLoopDirective(S); 10330b57cec5SDimitry Andric } 10340b57cec5SDimitry Andric 10350b57cec5SDimitry Andric void StmtProfiler::VisitOMPParallelForSimdDirective( 10360b57cec5SDimitry Andric const OMPParallelForSimdDirective *S) { 10370b57cec5SDimitry Andric VisitOMPLoopDirective(S); 10380b57cec5SDimitry Andric } 10390b57cec5SDimitry Andric 1040480093f4SDimitry Andric void StmtProfiler::VisitOMPParallelMasterDirective( 1041480093f4SDimitry Andric const OMPParallelMasterDirective *S) { 1042480093f4SDimitry Andric VisitOMPExecutableDirective(S); 1043480093f4SDimitry Andric } 1044480093f4SDimitry Andric 104581ad6265SDimitry Andric void StmtProfiler::VisitOMPParallelMaskedDirective( 104681ad6265SDimitry Andric const OMPParallelMaskedDirective *S) { 104781ad6265SDimitry Andric VisitOMPExecutableDirective(S); 104881ad6265SDimitry Andric } 104981ad6265SDimitry Andric 10500b57cec5SDimitry Andric void StmtProfiler::VisitOMPParallelSectionsDirective( 10510b57cec5SDimitry Andric const OMPParallelSectionsDirective *S) { 10520b57cec5SDimitry Andric VisitOMPExecutableDirective(S); 10530b57cec5SDimitry Andric } 10540b57cec5SDimitry Andric 10550b57cec5SDimitry Andric void StmtProfiler::VisitOMPTaskDirective(const OMPTaskDirective *S) { 10560b57cec5SDimitry Andric VisitOMPExecutableDirective(S); 10570b57cec5SDimitry Andric } 10580b57cec5SDimitry Andric 10590b57cec5SDimitry Andric void StmtProfiler::VisitOMPTaskyieldDirective(const OMPTaskyieldDirective *S) { 10600b57cec5SDimitry Andric VisitOMPExecutableDirective(S); 10610b57cec5SDimitry Andric } 10620b57cec5SDimitry Andric 10630b57cec5SDimitry Andric void StmtProfiler::VisitOMPBarrierDirective(const OMPBarrierDirective *S) { 10640b57cec5SDimitry Andric VisitOMPExecutableDirective(S); 10650b57cec5SDimitry Andric } 10660b57cec5SDimitry Andric 10670b57cec5SDimitry Andric void StmtProfiler::VisitOMPTaskwaitDirective(const OMPTaskwaitDirective *S) { 10680b57cec5SDimitry Andric VisitOMPExecutableDirective(S); 10690b57cec5SDimitry Andric } 10700b57cec5SDimitry Andric 1071bdd1243dSDimitry Andric void StmtProfiler::VisitOMPErrorDirective(const OMPErrorDirective *S) { 1072bdd1243dSDimitry Andric VisitOMPExecutableDirective(S); 1073bdd1243dSDimitry Andric } 10740b57cec5SDimitry Andric void StmtProfiler::VisitOMPTaskgroupDirective(const OMPTaskgroupDirective *S) { 10750b57cec5SDimitry Andric VisitOMPExecutableDirective(S); 10760b57cec5SDimitry Andric if (const Expr *E = S->getReductionRef()) 10770b57cec5SDimitry Andric VisitStmt(E); 10780b57cec5SDimitry Andric } 10790b57cec5SDimitry Andric 10800b57cec5SDimitry Andric void StmtProfiler::VisitOMPFlushDirective(const OMPFlushDirective *S) { 10810b57cec5SDimitry Andric VisitOMPExecutableDirective(S); 10820b57cec5SDimitry Andric } 10830b57cec5SDimitry Andric 10845ffd83dbSDimitry Andric void StmtProfiler::VisitOMPDepobjDirective(const OMPDepobjDirective *S) { 10855ffd83dbSDimitry Andric VisitOMPExecutableDirective(S); 10865ffd83dbSDimitry Andric } 10875ffd83dbSDimitry Andric 10885ffd83dbSDimitry Andric void StmtProfiler::VisitOMPScanDirective(const OMPScanDirective *S) { 10895ffd83dbSDimitry Andric VisitOMPExecutableDirective(S); 10905ffd83dbSDimitry Andric } 10915ffd83dbSDimitry Andric 10920b57cec5SDimitry Andric void StmtProfiler::VisitOMPOrderedDirective(const OMPOrderedDirective *S) { 10930b57cec5SDimitry Andric VisitOMPExecutableDirective(S); 10940b57cec5SDimitry Andric } 10950b57cec5SDimitry Andric 10960b57cec5SDimitry Andric void StmtProfiler::VisitOMPAtomicDirective(const OMPAtomicDirective *S) { 10970b57cec5SDimitry Andric VisitOMPExecutableDirective(S); 10980b57cec5SDimitry Andric } 10990b57cec5SDimitry Andric 11000b57cec5SDimitry Andric void StmtProfiler::VisitOMPTargetDirective(const OMPTargetDirective *S) { 11010b57cec5SDimitry Andric VisitOMPExecutableDirective(S); 11020b57cec5SDimitry Andric } 11030b57cec5SDimitry Andric 11040b57cec5SDimitry Andric void StmtProfiler::VisitOMPTargetDataDirective(const OMPTargetDataDirective *S) { 11050b57cec5SDimitry Andric VisitOMPExecutableDirective(S); 11060b57cec5SDimitry Andric } 11070b57cec5SDimitry Andric 11080b57cec5SDimitry Andric void StmtProfiler::VisitOMPTargetEnterDataDirective( 11090b57cec5SDimitry Andric const OMPTargetEnterDataDirective *S) { 11100b57cec5SDimitry Andric VisitOMPExecutableDirective(S); 11110b57cec5SDimitry Andric } 11120b57cec5SDimitry Andric 11130b57cec5SDimitry Andric void StmtProfiler::VisitOMPTargetExitDataDirective( 11140b57cec5SDimitry Andric const OMPTargetExitDataDirective *S) { 11150b57cec5SDimitry Andric VisitOMPExecutableDirective(S); 11160b57cec5SDimitry Andric } 11170b57cec5SDimitry Andric 11180b57cec5SDimitry Andric void StmtProfiler::VisitOMPTargetParallelDirective( 11190b57cec5SDimitry Andric const OMPTargetParallelDirective *S) { 11200b57cec5SDimitry Andric VisitOMPExecutableDirective(S); 11210b57cec5SDimitry Andric } 11220b57cec5SDimitry Andric 11230b57cec5SDimitry Andric void StmtProfiler::VisitOMPTargetParallelForDirective( 11240b57cec5SDimitry Andric const OMPTargetParallelForDirective *S) { 11250b57cec5SDimitry Andric VisitOMPExecutableDirective(S); 11260b57cec5SDimitry Andric } 11270b57cec5SDimitry Andric 11280b57cec5SDimitry Andric void StmtProfiler::VisitOMPTeamsDirective(const OMPTeamsDirective *S) { 11290b57cec5SDimitry Andric VisitOMPExecutableDirective(S); 11300b57cec5SDimitry Andric } 11310b57cec5SDimitry Andric 11320b57cec5SDimitry Andric void StmtProfiler::VisitOMPCancellationPointDirective( 11330b57cec5SDimitry Andric const OMPCancellationPointDirective *S) { 11340b57cec5SDimitry Andric VisitOMPExecutableDirective(S); 11350b57cec5SDimitry Andric } 11360b57cec5SDimitry Andric 11370b57cec5SDimitry Andric void StmtProfiler::VisitOMPCancelDirective(const OMPCancelDirective *S) { 11380b57cec5SDimitry Andric VisitOMPExecutableDirective(S); 11390b57cec5SDimitry Andric } 11400b57cec5SDimitry Andric 11410b57cec5SDimitry Andric void StmtProfiler::VisitOMPTaskLoopDirective(const OMPTaskLoopDirective *S) { 11420b57cec5SDimitry Andric VisitOMPLoopDirective(S); 11430b57cec5SDimitry Andric } 11440b57cec5SDimitry Andric 11450b57cec5SDimitry Andric void StmtProfiler::VisitOMPTaskLoopSimdDirective( 11460b57cec5SDimitry Andric const OMPTaskLoopSimdDirective *S) { 11470b57cec5SDimitry Andric VisitOMPLoopDirective(S); 11480b57cec5SDimitry Andric } 11490b57cec5SDimitry Andric 1150a7dea167SDimitry Andric void StmtProfiler::VisitOMPMasterTaskLoopDirective( 1151a7dea167SDimitry Andric const OMPMasterTaskLoopDirective *S) { 1152a7dea167SDimitry Andric VisitOMPLoopDirective(S); 1153a7dea167SDimitry Andric } 1154a7dea167SDimitry Andric 115581ad6265SDimitry Andric void StmtProfiler::VisitOMPMaskedTaskLoopDirective( 115681ad6265SDimitry Andric const OMPMaskedTaskLoopDirective *S) { 115781ad6265SDimitry Andric VisitOMPLoopDirective(S); 115881ad6265SDimitry Andric } 115981ad6265SDimitry Andric 1160a7dea167SDimitry Andric void StmtProfiler::VisitOMPMasterTaskLoopSimdDirective( 1161a7dea167SDimitry Andric const OMPMasterTaskLoopSimdDirective *S) { 1162a7dea167SDimitry Andric VisitOMPLoopDirective(S); 1163a7dea167SDimitry Andric } 1164a7dea167SDimitry Andric 116581ad6265SDimitry Andric void StmtProfiler::VisitOMPMaskedTaskLoopSimdDirective( 116681ad6265SDimitry Andric const OMPMaskedTaskLoopSimdDirective *S) { 116781ad6265SDimitry Andric VisitOMPLoopDirective(S); 116881ad6265SDimitry Andric } 116981ad6265SDimitry Andric 1170a7dea167SDimitry Andric void StmtProfiler::VisitOMPParallelMasterTaskLoopDirective( 1171a7dea167SDimitry Andric const OMPParallelMasterTaskLoopDirective *S) { 1172a7dea167SDimitry Andric VisitOMPLoopDirective(S); 1173a7dea167SDimitry Andric } 1174a7dea167SDimitry Andric 117581ad6265SDimitry Andric void StmtProfiler::VisitOMPParallelMaskedTaskLoopDirective( 117681ad6265SDimitry Andric const OMPParallelMaskedTaskLoopDirective *S) { 117781ad6265SDimitry Andric VisitOMPLoopDirective(S); 117881ad6265SDimitry Andric } 117981ad6265SDimitry Andric 1180480093f4SDimitry Andric void StmtProfiler::VisitOMPParallelMasterTaskLoopSimdDirective( 1181480093f4SDimitry Andric const OMPParallelMasterTaskLoopSimdDirective *S) { 1182480093f4SDimitry Andric VisitOMPLoopDirective(S); 1183480093f4SDimitry Andric } 1184480093f4SDimitry Andric 118581ad6265SDimitry Andric void StmtProfiler::VisitOMPParallelMaskedTaskLoopSimdDirective( 118681ad6265SDimitry Andric const OMPParallelMaskedTaskLoopSimdDirective *S) { 118781ad6265SDimitry Andric VisitOMPLoopDirective(S); 118881ad6265SDimitry Andric } 118981ad6265SDimitry Andric 11900b57cec5SDimitry Andric void StmtProfiler::VisitOMPDistributeDirective( 11910b57cec5SDimitry Andric const OMPDistributeDirective *S) { 11920b57cec5SDimitry Andric VisitOMPLoopDirective(S); 11930b57cec5SDimitry Andric } 11940b57cec5SDimitry Andric 11950b57cec5SDimitry Andric void OMPClauseProfiler::VisitOMPDistScheduleClause( 11960b57cec5SDimitry Andric const OMPDistScheduleClause *C) { 11970b57cec5SDimitry Andric VistOMPClauseWithPreInit(C); 11980b57cec5SDimitry Andric if (auto *S = C->getChunkSize()) 11990b57cec5SDimitry Andric Profiler->VisitStmt(S); 12000b57cec5SDimitry Andric } 12010b57cec5SDimitry Andric 12020b57cec5SDimitry Andric void OMPClauseProfiler::VisitOMPDefaultmapClause(const OMPDefaultmapClause *) {} 12030b57cec5SDimitry Andric 12040b57cec5SDimitry Andric void StmtProfiler::VisitOMPTargetUpdateDirective( 12050b57cec5SDimitry Andric const OMPTargetUpdateDirective *S) { 12060b57cec5SDimitry Andric VisitOMPExecutableDirective(S); 12070b57cec5SDimitry Andric } 12080b57cec5SDimitry Andric 12090b57cec5SDimitry Andric void StmtProfiler::VisitOMPDistributeParallelForDirective( 12100b57cec5SDimitry Andric const OMPDistributeParallelForDirective *S) { 12110b57cec5SDimitry Andric VisitOMPLoopDirective(S); 12120b57cec5SDimitry Andric } 12130b57cec5SDimitry Andric 12140b57cec5SDimitry Andric void StmtProfiler::VisitOMPDistributeParallelForSimdDirective( 12150b57cec5SDimitry Andric const OMPDistributeParallelForSimdDirective *S) { 12160b57cec5SDimitry Andric VisitOMPLoopDirective(S); 12170b57cec5SDimitry Andric } 12180b57cec5SDimitry Andric 12190b57cec5SDimitry Andric void StmtProfiler::VisitOMPDistributeSimdDirective( 12200b57cec5SDimitry Andric const OMPDistributeSimdDirective *S) { 12210b57cec5SDimitry Andric VisitOMPLoopDirective(S); 12220b57cec5SDimitry Andric } 12230b57cec5SDimitry Andric 12240b57cec5SDimitry Andric void StmtProfiler::VisitOMPTargetParallelForSimdDirective( 12250b57cec5SDimitry Andric const OMPTargetParallelForSimdDirective *S) { 12260b57cec5SDimitry Andric VisitOMPLoopDirective(S); 12270b57cec5SDimitry Andric } 12280b57cec5SDimitry Andric 12290b57cec5SDimitry Andric void StmtProfiler::VisitOMPTargetSimdDirective( 12300b57cec5SDimitry Andric const OMPTargetSimdDirective *S) { 12310b57cec5SDimitry Andric VisitOMPLoopDirective(S); 12320b57cec5SDimitry Andric } 12330b57cec5SDimitry Andric 12340b57cec5SDimitry Andric void StmtProfiler::VisitOMPTeamsDistributeDirective( 12350b57cec5SDimitry Andric const OMPTeamsDistributeDirective *S) { 12360b57cec5SDimitry Andric VisitOMPLoopDirective(S); 12370b57cec5SDimitry Andric } 12380b57cec5SDimitry Andric 12390b57cec5SDimitry Andric void StmtProfiler::VisitOMPTeamsDistributeSimdDirective( 12400b57cec5SDimitry Andric const OMPTeamsDistributeSimdDirective *S) { 12410b57cec5SDimitry Andric VisitOMPLoopDirective(S); 12420b57cec5SDimitry Andric } 12430b57cec5SDimitry Andric 12440b57cec5SDimitry Andric void StmtProfiler::VisitOMPTeamsDistributeParallelForSimdDirective( 12450b57cec5SDimitry Andric const OMPTeamsDistributeParallelForSimdDirective *S) { 12460b57cec5SDimitry Andric VisitOMPLoopDirective(S); 12470b57cec5SDimitry Andric } 12480b57cec5SDimitry Andric 12490b57cec5SDimitry Andric void StmtProfiler::VisitOMPTeamsDistributeParallelForDirective( 12500b57cec5SDimitry Andric const OMPTeamsDistributeParallelForDirective *S) { 12510b57cec5SDimitry Andric VisitOMPLoopDirective(S); 12520b57cec5SDimitry Andric } 12530b57cec5SDimitry Andric 12540b57cec5SDimitry Andric void StmtProfiler::VisitOMPTargetTeamsDirective( 12550b57cec5SDimitry Andric const OMPTargetTeamsDirective *S) { 12560b57cec5SDimitry Andric VisitOMPExecutableDirective(S); 12570b57cec5SDimitry Andric } 12580b57cec5SDimitry Andric 12590b57cec5SDimitry Andric void StmtProfiler::VisitOMPTargetTeamsDistributeDirective( 12600b57cec5SDimitry Andric const OMPTargetTeamsDistributeDirective *S) { 12610b57cec5SDimitry Andric VisitOMPLoopDirective(S); 12620b57cec5SDimitry Andric } 12630b57cec5SDimitry Andric 12640b57cec5SDimitry Andric void StmtProfiler::VisitOMPTargetTeamsDistributeParallelForDirective( 12650b57cec5SDimitry Andric const OMPTargetTeamsDistributeParallelForDirective *S) { 12660b57cec5SDimitry Andric VisitOMPLoopDirective(S); 12670b57cec5SDimitry Andric } 12680b57cec5SDimitry Andric 12690b57cec5SDimitry Andric void StmtProfiler::VisitOMPTargetTeamsDistributeParallelForSimdDirective( 12700b57cec5SDimitry Andric const OMPTargetTeamsDistributeParallelForSimdDirective *S) { 12710b57cec5SDimitry Andric VisitOMPLoopDirective(S); 12720b57cec5SDimitry Andric } 12730b57cec5SDimitry Andric 12740b57cec5SDimitry Andric void StmtProfiler::VisitOMPTargetTeamsDistributeSimdDirective( 12750b57cec5SDimitry Andric const OMPTargetTeamsDistributeSimdDirective *S) { 12760b57cec5SDimitry Andric VisitOMPLoopDirective(S); 12770b57cec5SDimitry Andric } 12780b57cec5SDimitry Andric 1279fe6060f1SDimitry Andric void StmtProfiler::VisitOMPInteropDirective(const OMPInteropDirective *S) { 1280fe6060f1SDimitry Andric VisitOMPExecutableDirective(S); 1281fe6060f1SDimitry Andric } 1282fe6060f1SDimitry Andric 1283fe6060f1SDimitry Andric void StmtProfiler::VisitOMPDispatchDirective(const OMPDispatchDirective *S) { 1284fe6060f1SDimitry Andric VisitOMPExecutableDirective(S); 1285fe6060f1SDimitry Andric } 1286fe6060f1SDimitry Andric 1287fe6060f1SDimitry Andric void StmtProfiler::VisitOMPMaskedDirective(const OMPMaskedDirective *S) { 1288fe6060f1SDimitry Andric VisitOMPExecutableDirective(S); 1289fe6060f1SDimitry Andric } 1290fe6060f1SDimitry Andric 1291349cc55cSDimitry Andric void StmtProfiler::VisitOMPGenericLoopDirective( 1292349cc55cSDimitry Andric const OMPGenericLoopDirective *S) { 1293349cc55cSDimitry Andric VisitOMPLoopDirective(S); 1294349cc55cSDimitry Andric } 1295349cc55cSDimitry Andric 129681ad6265SDimitry Andric void StmtProfiler::VisitOMPTeamsGenericLoopDirective( 129781ad6265SDimitry Andric const OMPTeamsGenericLoopDirective *S) { 129881ad6265SDimitry Andric VisitOMPLoopDirective(S); 129981ad6265SDimitry Andric } 130081ad6265SDimitry Andric 130181ad6265SDimitry Andric void StmtProfiler::VisitOMPTargetTeamsGenericLoopDirective( 130281ad6265SDimitry Andric const OMPTargetTeamsGenericLoopDirective *S) { 130381ad6265SDimitry Andric VisitOMPLoopDirective(S); 130481ad6265SDimitry Andric } 130581ad6265SDimitry Andric 130681ad6265SDimitry Andric void StmtProfiler::VisitOMPParallelGenericLoopDirective( 130781ad6265SDimitry Andric const OMPParallelGenericLoopDirective *S) { 130881ad6265SDimitry Andric VisitOMPLoopDirective(S); 130981ad6265SDimitry Andric } 131081ad6265SDimitry Andric 131181ad6265SDimitry Andric void StmtProfiler::VisitOMPTargetParallelGenericLoopDirective( 131281ad6265SDimitry Andric const OMPTargetParallelGenericLoopDirective *S) { 131381ad6265SDimitry Andric VisitOMPLoopDirective(S); 131481ad6265SDimitry Andric } 131581ad6265SDimitry Andric 13160b57cec5SDimitry Andric void StmtProfiler::VisitExpr(const Expr *S) { 13170b57cec5SDimitry Andric VisitStmt(S); 13180b57cec5SDimitry Andric } 13190b57cec5SDimitry Andric 13200b57cec5SDimitry Andric void StmtProfiler::VisitConstantExpr(const ConstantExpr *S) { 13210b57cec5SDimitry Andric VisitExpr(S); 13220b57cec5SDimitry Andric } 13230b57cec5SDimitry Andric 13240b57cec5SDimitry Andric void StmtProfiler::VisitDeclRefExpr(const DeclRefExpr *S) { 13250b57cec5SDimitry Andric VisitExpr(S); 13260b57cec5SDimitry Andric if (!Canonical) 13270b57cec5SDimitry Andric VisitNestedNameSpecifier(S->getQualifier()); 13280b57cec5SDimitry Andric VisitDecl(S->getDecl()); 13290b57cec5SDimitry Andric if (!Canonical) { 13300b57cec5SDimitry Andric ID.AddBoolean(S->hasExplicitTemplateArgs()); 13310b57cec5SDimitry Andric if (S->hasExplicitTemplateArgs()) 13320b57cec5SDimitry Andric VisitTemplateArguments(S->getTemplateArgs(), S->getNumTemplateArgs()); 13330b57cec5SDimitry Andric } 13340b57cec5SDimitry Andric } 13350b57cec5SDimitry Andric 1336fe6060f1SDimitry Andric void StmtProfiler::VisitSYCLUniqueStableNameExpr( 1337fe6060f1SDimitry Andric const SYCLUniqueStableNameExpr *S) { 1338fe6060f1SDimitry Andric VisitExpr(S); 1339fe6060f1SDimitry Andric VisitType(S->getTypeSourceInfo()->getType()); 1340fe6060f1SDimitry Andric } 1341fe6060f1SDimitry Andric 13420b57cec5SDimitry Andric void StmtProfiler::VisitPredefinedExpr(const PredefinedExpr *S) { 13430b57cec5SDimitry Andric VisitExpr(S); 13445f757f3fSDimitry Andric ID.AddInteger(llvm::to_underlying(S->getIdentKind())); 13450b57cec5SDimitry Andric } 13460b57cec5SDimitry Andric 13470b57cec5SDimitry Andric void StmtProfiler::VisitIntegerLiteral(const IntegerLiteral *S) { 13480b57cec5SDimitry Andric VisitExpr(S); 13490b57cec5SDimitry Andric S->getValue().Profile(ID); 13505f757f3fSDimitry Andric 13515f757f3fSDimitry Andric QualType T = S->getType(); 13525f757f3fSDimitry Andric if (Canonical) 13535f757f3fSDimitry Andric T = T.getCanonicalType(); 13545f757f3fSDimitry Andric ID.AddInteger(T->getTypeClass()); 13555f757f3fSDimitry Andric if (auto BitIntT = T->getAs<BitIntType>()) 13565f757f3fSDimitry Andric BitIntT->Profile(ID); 13575f757f3fSDimitry Andric else 13585f757f3fSDimitry Andric ID.AddInteger(T->castAs<BuiltinType>()->getKind()); 13590b57cec5SDimitry Andric } 13600b57cec5SDimitry Andric 13610b57cec5SDimitry Andric void StmtProfiler::VisitFixedPointLiteral(const FixedPointLiteral *S) { 13620b57cec5SDimitry Andric VisitExpr(S); 13630b57cec5SDimitry Andric S->getValue().Profile(ID); 13640b57cec5SDimitry Andric ID.AddInteger(S->getType()->castAs<BuiltinType>()->getKind()); 13650b57cec5SDimitry Andric } 13660b57cec5SDimitry Andric 13670b57cec5SDimitry Andric void StmtProfiler::VisitCharacterLiteral(const CharacterLiteral *S) { 13680b57cec5SDimitry Andric VisitExpr(S); 13695f757f3fSDimitry Andric ID.AddInteger(llvm::to_underlying(S->getKind())); 13700b57cec5SDimitry Andric ID.AddInteger(S->getValue()); 13710b57cec5SDimitry Andric } 13720b57cec5SDimitry Andric 13730b57cec5SDimitry Andric void StmtProfiler::VisitFloatingLiteral(const FloatingLiteral *S) { 13740b57cec5SDimitry Andric VisitExpr(S); 13750b57cec5SDimitry Andric S->getValue().Profile(ID); 13760b57cec5SDimitry Andric ID.AddBoolean(S->isExact()); 13770b57cec5SDimitry Andric ID.AddInteger(S->getType()->castAs<BuiltinType>()->getKind()); 13780b57cec5SDimitry Andric } 13790b57cec5SDimitry Andric 13800b57cec5SDimitry Andric void StmtProfiler::VisitImaginaryLiteral(const ImaginaryLiteral *S) { 13810b57cec5SDimitry Andric VisitExpr(S); 13820b57cec5SDimitry Andric } 13830b57cec5SDimitry Andric 13840b57cec5SDimitry Andric void StmtProfiler::VisitStringLiteral(const StringLiteral *S) { 13850b57cec5SDimitry Andric VisitExpr(S); 13860b57cec5SDimitry Andric ID.AddString(S->getBytes()); 13875f757f3fSDimitry Andric ID.AddInteger(llvm::to_underlying(S->getKind())); 13880b57cec5SDimitry Andric } 13890b57cec5SDimitry Andric 13900b57cec5SDimitry Andric void StmtProfiler::VisitParenExpr(const ParenExpr *S) { 13910b57cec5SDimitry Andric VisitExpr(S); 13920b57cec5SDimitry Andric } 13930b57cec5SDimitry Andric 13940b57cec5SDimitry Andric void StmtProfiler::VisitParenListExpr(const ParenListExpr *S) { 13950b57cec5SDimitry Andric VisitExpr(S); 13960b57cec5SDimitry Andric } 13970b57cec5SDimitry Andric 13980b57cec5SDimitry Andric void StmtProfiler::VisitUnaryOperator(const UnaryOperator *S) { 13990b57cec5SDimitry Andric VisitExpr(S); 14000b57cec5SDimitry Andric ID.AddInteger(S->getOpcode()); 14010b57cec5SDimitry Andric } 14020b57cec5SDimitry Andric 14030b57cec5SDimitry Andric void StmtProfiler::VisitOffsetOfExpr(const OffsetOfExpr *S) { 14040b57cec5SDimitry Andric VisitType(S->getTypeSourceInfo()->getType()); 14050b57cec5SDimitry Andric unsigned n = S->getNumComponents(); 14060b57cec5SDimitry Andric for (unsigned i = 0; i < n; ++i) { 14070b57cec5SDimitry Andric const OffsetOfNode &ON = S->getComponent(i); 14080b57cec5SDimitry Andric ID.AddInteger(ON.getKind()); 14090b57cec5SDimitry Andric switch (ON.getKind()) { 14100b57cec5SDimitry Andric case OffsetOfNode::Array: 14110b57cec5SDimitry Andric // Expressions handled below. 14120b57cec5SDimitry Andric break; 14130b57cec5SDimitry Andric 14140b57cec5SDimitry Andric case OffsetOfNode::Field: 14150b57cec5SDimitry Andric VisitDecl(ON.getField()); 14160b57cec5SDimitry Andric break; 14170b57cec5SDimitry Andric 14180b57cec5SDimitry Andric case OffsetOfNode::Identifier: 14190b57cec5SDimitry Andric VisitIdentifierInfo(ON.getFieldName()); 14200b57cec5SDimitry Andric break; 14210b57cec5SDimitry Andric 14220b57cec5SDimitry Andric case OffsetOfNode::Base: 14230b57cec5SDimitry Andric // These nodes are implicit, and therefore don't need profiling. 14240b57cec5SDimitry Andric break; 14250b57cec5SDimitry Andric } 14260b57cec5SDimitry Andric } 14270b57cec5SDimitry Andric 14280b57cec5SDimitry Andric VisitExpr(S); 14290b57cec5SDimitry Andric } 14300b57cec5SDimitry Andric 14310b57cec5SDimitry Andric void 14320b57cec5SDimitry Andric StmtProfiler::VisitUnaryExprOrTypeTraitExpr(const UnaryExprOrTypeTraitExpr *S) { 14330b57cec5SDimitry Andric VisitExpr(S); 14340b57cec5SDimitry Andric ID.AddInteger(S->getKind()); 14350b57cec5SDimitry Andric if (S->isArgumentType()) 14360b57cec5SDimitry Andric VisitType(S->getArgumentType()); 14370b57cec5SDimitry Andric } 14380b57cec5SDimitry Andric 14390b57cec5SDimitry Andric void StmtProfiler::VisitArraySubscriptExpr(const ArraySubscriptExpr *S) { 14400b57cec5SDimitry Andric VisitExpr(S); 14410b57cec5SDimitry Andric } 14420b57cec5SDimitry Andric 14435ffd83dbSDimitry Andric void StmtProfiler::VisitMatrixSubscriptExpr(const MatrixSubscriptExpr *S) { 14445ffd83dbSDimitry Andric VisitExpr(S); 14455ffd83dbSDimitry Andric } 14465ffd83dbSDimitry Andric 1447*0fca6ea1SDimitry Andric void StmtProfiler::VisitArraySectionExpr(const ArraySectionExpr *S) { 14480b57cec5SDimitry Andric VisitExpr(S); 14490b57cec5SDimitry Andric } 14500b57cec5SDimitry Andric 14515ffd83dbSDimitry Andric void StmtProfiler::VisitOMPArrayShapingExpr(const OMPArrayShapingExpr *S) { 14525ffd83dbSDimitry Andric VisitExpr(S); 14535ffd83dbSDimitry Andric } 14545ffd83dbSDimitry Andric 14555ffd83dbSDimitry Andric void StmtProfiler::VisitOMPIteratorExpr(const OMPIteratorExpr *S) { 14565ffd83dbSDimitry Andric VisitExpr(S); 14575ffd83dbSDimitry Andric for (unsigned I = 0, E = S->numOfIterators(); I < E; ++I) 14585ffd83dbSDimitry Andric VisitDecl(S->getIteratorDecl(I)); 14595ffd83dbSDimitry Andric } 14605ffd83dbSDimitry Andric 14610b57cec5SDimitry Andric void StmtProfiler::VisitCallExpr(const CallExpr *S) { 14620b57cec5SDimitry Andric VisitExpr(S); 14630b57cec5SDimitry Andric } 14640b57cec5SDimitry Andric 14650b57cec5SDimitry Andric void StmtProfiler::VisitMemberExpr(const MemberExpr *S) { 14660b57cec5SDimitry Andric VisitExpr(S); 14670b57cec5SDimitry Andric VisitDecl(S->getMemberDecl()); 14680b57cec5SDimitry Andric if (!Canonical) 14690b57cec5SDimitry Andric VisitNestedNameSpecifier(S->getQualifier()); 14700b57cec5SDimitry Andric ID.AddBoolean(S->isArrow()); 14710b57cec5SDimitry Andric } 14720b57cec5SDimitry Andric 14730b57cec5SDimitry Andric void StmtProfiler::VisitCompoundLiteralExpr(const CompoundLiteralExpr *S) { 14740b57cec5SDimitry Andric VisitExpr(S); 14750b57cec5SDimitry Andric ID.AddBoolean(S->isFileScope()); 14760b57cec5SDimitry Andric } 14770b57cec5SDimitry Andric 14780b57cec5SDimitry Andric void StmtProfiler::VisitCastExpr(const CastExpr *S) { 14790b57cec5SDimitry Andric VisitExpr(S); 14800b57cec5SDimitry Andric } 14810b57cec5SDimitry Andric 14820b57cec5SDimitry Andric void StmtProfiler::VisitImplicitCastExpr(const ImplicitCastExpr *S) { 14830b57cec5SDimitry Andric VisitCastExpr(S); 14840b57cec5SDimitry Andric ID.AddInteger(S->getValueKind()); 14850b57cec5SDimitry Andric } 14860b57cec5SDimitry Andric 14870b57cec5SDimitry Andric void StmtProfiler::VisitExplicitCastExpr(const ExplicitCastExpr *S) { 14880b57cec5SDimitry Andric VisitCastExpr(S); 14890b57cec5SDimitry Andric VisitType(S->getTypeAsWritten()); 14900b57cec5SDimitry Andric } 14910b57cec5SDimitry Andric 14920b57cec5SDimitry Andric void StmtProfiler::VisitCStyleCastExpr(const CStyleCastExpr *S) { 14930b57cec5SDimitry Andric VisitExplicitCastExpr(S); 14940b57cec5SDimitry Andric } 14950b57cec5SDimitry Andric 14960b57cec5SDimitry Andric void StmtProfiler::VisitBinaryOperator(const BinaryOperator *S) { 14970b57cec5SDimitry Andric VisitExpr(S); 14980b57cec5SDimitry Andric ID.AddInteger(S->getOpcode()); 14990b57cec5SDimitry Andric } 15000b57cec5SDimitry Andric 15010b57cec5SDimitry Andric void 15020b57cec5SDimitry Andric StmtProfiler::VisitCompoundAssignOperator(const CompoundAssignOperator *S) { 15030b57cec5SDimitry Andric VisitBinaryOperator(S); 15040b57cec5SDimitry Andric } 15050b57cec5SDimitry Andric 15060b57cec5SDimitry Andric void StmtProfiler::VisitConditionalOperator(const ConditionalOperator *S) { 15070b57cec5SDimitry Andric VisitExpr(S); 15080b57cec5SDimitry Andric } 15090b57cec5SDimitry Andric 15100b57cec5SDimitry Andric void StmtProfiler::VisitBinaryConditionalOperator( 15110b57cec5SDimitry Andric const BinaryConditionalOperator *S) { 15120b57cec5SDimitry Andric VisitExpr(S); 15130b57cec5SDimitry Andric } 15140b57cec5SDimitry Andric 15150b57cec5SDimitry Andric void StmtProfiler::VisitAddrLabelExpr(const AddrLabelExpr *S) { 15160b57cec5SDimitry Andric VisitExpr(S); 15170b57cec5SDimitry Andric VisitDecl(S->getLabel()); 15180b57cec5SDimitry Andric } 15190b57cec5SDimitry Andric 15200b57cec5SDimitry Andric void StmtProfiler::VisitStmtExpr(const StmtExpr *S) { 15210b57cec5SDimitry Andric VisitExpr(S); 15220b57cec5SDimitry Andric } 15230b57cec5SDimitry Andric 15240b57cec5SDimitry Andric void StmtProfiler::VisitShuffleVectorExpr(const ShuffleVectorExpr *S) { 15250b57cec5SDimitry Andric VisitExpr(S); 15260b57cec5SDimitry Andric } 15270b57cec5SDimitry Andric 15280b57cec5SDimitry Andric void StmtProfiler::VisitConvertVectorExpr(const ConvertVectorExpr *S) { 15290b57cec5SDimitry Andric VisitExpr(S); 15300b57cec5SDimitry Andric } 15310b57cec5SDimitry Andric 15320b57cec5SDimitry Andric void StmtProfiler::VisitChooseExpr(const ChooseExpr *S) { 15330b57cec5SDimitry Andric VisitExpr(S); 15340b57cec5SDimitry Andric } 15350b57cec5SDimitry Andric 15360b57cec5SDimitry Andric void StmtProfiler::VisitGNUNullExpr(const GNUNullExpr *S) { 15370b57cec5SDimitry Andric VisitExpr(S); 15380b57cec5SDimitry Andric } 15390b57cec5SDimitry Andric 15400b57cec5SDimitry Andric void StmtProfiler::VisitVAArgExpr(const VAArgExpr *S) { 15410b57cec5SDimitry Andric VisitExpr(S); 15420b57cec5SDimitry Andric } 15430b57cec5SDimitry Andric 15440b57cec5SDimitry Andric void StmtProfiler::VisitInitListExpr(const InitListExpr *S) { 15450b57cec5SDimitry Andric if (S->getSyntacticForm()) { 15460b57cec5SDimitry Andric VisitInitListExpr(S->getSyntacticForm()); 15470b57cec5SDimitry Andric return; 15480b57cec5SDimitry Andric } 15490b57cec5SDimitry Andric 15500b57cec5SDimitry Andric VisitExpr(S); 15510b57cec5SDimitry Andric } 15520b57cec5SDimitry Andric 15530b57cec5SDimitry Andric void StmtProfiler::VisitDesignatedInitExpr(const DesignatedInitExpr *S) { 15540b57cec5SDimitry Andric VisitExpr(S); 15550b57cec5SDimitry Andric ID.AddBoolean(S->usesGNUSyntax()); 15560b57cec5SDimitry Andric for (const DesignatedInitExpr::Designator &D : S->designators()) { 15570b57cec5SDimitry Andric if (D.isFieldDesignator()) { 15580b57cec5SDimitry Andric ID.AddInteger(0); 15590b57cec5SDimitry Andric VisitName(D.getFieldName()); 15600b57cec5SDimitry Andric continue; 15610b57cec5SDimitry Andric } 15620b57cec5SDimitry Andric 15630b57cec5SDimitry Andric if (D.isArrayDesignator()) { 15640b57cec5SDimitry Andric ID.AddInteger(1); 15650b57cec5SDimitry Andric } else { 15660b57cec5SDimitry Andric assert(D.isArrayRangeDesignator()); 15670b57cec5SDimitry Andric ID.AddInteger(2); 15680b57cec5SDimitry Andric } 156906c3fb27SDimitry Andric ID.AddInteger(D.getArrayIndex()); 15700b57cec5SDimitry Andric } 15710b57cec5SDimitry Andric } 15720b57cec5SDimitry Andric 15730b57cec5SDimitry Andric // Seems that if VisitInitListExpr() only works on the syntactic form of an 15740b57cec5SDimitry Andric // InitListExpr, then a DesignatedInitUpdateExpr is not encountered. 15750b57cec5SDimitry Andric void StmtProfiler::VisitDesignatedInitUpdateExpr( 15760b57cec5SDimitry Andric const DesignatedInitUpdateExpr *S) { 15770b57cec5SDimitry Andric llvm_unreachable("Unexpected DesignatedInitUpdateExpr in syntactic form of " 15780b57cec5SDimitry Andric "initializer"); 15790b57cec5SDimitry Andric } 15800b57cec5SDimitry Andric 15810b57cec5SDimitry Andric void StmtProfiler::VisitArrayInitLoopExpr(const ArrayInitLoopExpr *S) { 15820b57cec5SDimitry Andric VisitExpr(S); 15830b57cec5SDimitry Andric } 15840b57cec5SDimitry Andric 15850b57cec5SDimitry Andric void StmtProfiler::VisitArrayInitIndexExpr(const ArrayInitIndexExpr *S) { 15860b57cec5SDimitry Andric VisitExpr(S); 15870b57cec5SDimitry Andric } 15880b57cec5SDimitry Andric 15890b57cec5SDimitry Andric void StmtProfiler::VisitNoInitExpr(const NoInitExpr *S) { 15900b57cec5SDimitry Andric llvm_unreachable("Unexpected NoInitExpr in syntactic form of initializer"); 15910b57cec5SDimitry Andric } 15920b57cec5SDimitry Andric 15930b57cec5SDimitry Andric void StmtProfiler::VisitImplicitValueInitExpr(const ImplicitValueInitExpr *S) { 15940b57cec5SDimitry Andric VisitExpr(S); 15950b57cec5SDimitry Andric } 15960b57cec5SDimitry Andric 15970b57cec5SDimitry Andric void StmtProfiler::VisitExtVectorElementExpr(const ExtVectorElementExpr *S) { 15980b57cec5SDimitry Andric VisitExpr(S); 15990b57cec5SDimitry Andric VisitName(&S->getAccessor()); 16000b57cec5SDimitry Andric } 16010b57cec5SDimitry Andric 16020b57cec5SDimitry Andric void StmtProfiler::VisitBlockExpr(const BlockExpr *S) { 16030b57cec5SDimitry Andric VisitExpr(S); 16040b57cec5SDimitry Andric VisitDecl(S->getBlockDecl()); 16050b57cec5SDimitry Andric } 16060b57cec5SDimitry Andric 16070b57cec5SDimitry Andric void StmtProfiler::VisitGenericSelectionExpr(const GenericSelectionExpr *S) { 16080b57cec5SDimitry Andric VisitExpr(S); 1609480093f4SDimitry Andric for (const GenericSelectionExpr::ConstAssociation Assoc : 16100b57cec5SDimitry Andric S->associations()) { 16110b57cec5SDimitry Andric QualType T = Assoc.getType(); 16120b57cec5SDimitry Andric if (T.isNull()) 16130b57cec5SDimitry Andric ID.AddPointer(nullptr); 16140b57cec5SDimitry Andric else 16150b57cec5SDimitry Andric VisitType(T); 16160b57cec5SDimitry Andric VisitExpr(Assoc.getAssociationExpr()); 16170b57cec5SDimitry Andric } 16180b57cec5SDimitry Andric } 16190b57cec5SDimitry Andric 16200b57cec5SDimitry Andric void StmtProfiler::VisitPseudoObjectExpr(const PseudoObjectExpr *S) { 16210b57cec5SDimitry Andric VisitExpr(S); 16220b57cec5SDimitry Andric for (PseudoObjectExpr::const_semantics_iterator 16230b57cec5SDimitry Andric i = S->semantics_begin(), e = S->semantics_end(); i != e; ++i) 16240b57cec5SDimitry Andric // Normally, we would not profile the source expressions of OVEs. 16250b57cec5SDimitry Andric if (const OpaqueValueExpr *OVE = dyn_cast<OpaqueValueExpr>(*i)) 16260b57cec5SDimitry Andric Visit(OVE->getSourceExpr()); 16270b57cec5SDimitry Andric } 16280b57cec5SDimitry Andric 16290b57cec5SDimitry Andric void StmtProfiler::VisitAtomicExpr(const AtomicExpr *S) { 16300b57cec5SDimitry Andric VisitExpr(S); 16310b57cec5SDimitry Andric ID.AddInteger(S->getOp()); 16320b57cec5SDimitry Andric } 16330b57cec5SDimitry Andric 1634a7dea167SDimitry Andric void StmtProfiler::VisitConceptSpecializationExpr( 1635a7dea167SDimitry Andric const ConceptSpecializationExpr *S) { 1636a7dea167SDimitry Andric VisitExpr(S); 163755e4f9d5SDimitry Andric VisitDecl(S->getNamedConcept()); 163855e4f9d5SDimitry Andric for (const TemplateArgument &Arg : S->getTemplateArguments()) 163955e4f9d5SDimitry Andric VisitTemplateArgument(Arg); 164055e4f9d5SDimitry Andric } 164155e4f9d5SDimitry Andric 164255e4f9d5SDimitry Andric void StmtProfiler::VisitRequiresExpr(const RequiresExpr *S) { 164355e4f9d5SDimitry Andric VisitExpr(S); 164455e4f9d5SDimitry Andric ID.AddInteger(S->getLocalParameters().size()); 164555e4f9d5SDimitry Andric for (ParmVarDecl *LocalParam : S->getLocalParameters()) 164655e4f9d5SDimitry Andric VisitDecl(LocalParam); 164755e4f9d5SDimitry Andric ID.AddInteger(S->getRequirements().size()); 164855e4f9d5SDimitry Andric for (concepts::Requirement *Req : S->getRequirements()) { 164955e4f9d5SDimitry Andric if (auto *TypeReq = dyn_cast<concepts::TypeRequirement>(Req)) { 165055e4f9d5SDimitry Andric ID.AddInteger(concepts::Requirement::RK_Type); 165155e4f9d5SDimitry Andric ID.AddBoolean(TypeReq->isSubstitutionFailure()); 165255e4f9d5SDimitry Andric if (!TypeReq->isSubstitutionFailure()) 165355e4f9d5SDimitry Andric VisitType(TypeReq->getType()->getType()); 165455e4f9d5SDimitry Andric } else if (auto *ExprReq = dyn_cast<concepts::ExprRequirement>(Req)) { 165555e4f9d5SDimitry Andric ID.AddInteger(concepts::Requirement::RK_Compound); 165655e4f9d5SDimitry Andric ID.AddBoolean(ExprReq->isExprSubstitutionFailure()); 165755e4f9d5SDimitry Andric if (!ExprReq->isExprSubstitutionFailure()) 165855e4f9d5SDimitry Andric Visit(ExprReq->getExpr()); 165955e4f9d5SDimitry Andric // C++2a [expr.prim.req.compound]p1 Example: 166055e4f9d5SDimitry Andric // [...] The compound-requirement in C1 requires that x++ is a valid 166155e4f9d5SDimitry Andric // expression. It is equivalent to the simple-requirement x++; [...] 166255e4f9d5SDimitry Andric // We therefore do not profile isSimple() here. 166355e4f9d5SDimitry Andric ID.AddBoolean(ExprReq->getNoexceptLoc().isValid()); 166455e4f9d5SDimitry Andric const concepts::ExprRequirement::ReturnTypeRequirement &RetReq = 166555e4f9d5SDimitry Andric ExprReq->getReturnTypeRequirement(); 166655e4f9d5SDimitry Andric if (RetReq.isEmpty()) { 166755e4f9d5SDimitry Andric ID.AddInteger(0); 166855e4f9d5SDimitry Andric } else if (RetReq.isTypeConstraint()) { 166955e4f9d5SDimitry Andric ID.AddInteger(1); 167055e4f9d5SDimitry Andric Visit(RetReq.getTypeConstraint()->getImmediatelyDeclaredConstraint()); 167155e4f9d5SDimitry Andric } else { 167255e4f9d5SDimitry Andric assert(RetReq.isSubstitutionFailure()); 167355e4f9d5SDimitry Andric ID.AddInteger(2); 167455e4f9d5SDimitry Andric } 167555e4f9d5SDimitry Andric } else { 167655e4f9d5SDimitry Andric ID.AddInteger(concepts::Requirement::RK_Nested); 167755e4f9d5SDimitry Andric auto *NestedReq = cast<concepts::NestedRequirement>(Req); 1678bdd1243dSDimitry Andric ID.AddBoolean(NestedReq->hasInvalidConstraint()); 1679bdd1243dSDimitry Andric if (!NestedReq->hasInvalidConstraint()) 168055e4f9d5SDimitry Andric Visit(NestedReq->getConstraintExpr()); 168155e4f9d5SDimitry Andric } 168255e4f9d5SDimitry Andric } 1683a7dea167SDimitry Andric } 1684a7dea167SDimitry Andric 16850b57cec5SDimitry Andric static Stmt::StmtClass DecodeOperatorCall(const CXXOperatorCallExpr *S, 16860b57cec5SDimitry Andric UnaryOperatorKind &UnaryOp, 168706c3fb27SDimitry Andric BinaryOperatorKind &BinaryOp, 168806c3fb27SDimitry Andric unsigned &NumArgs) { 16890b57cec5SDimitry Andric switch (S->getOperator()) { 16900b57cec5SDimitry Andric case OO_None: 16910b57cec5SDimitry Andric case OO_New: 16920b57cec5SDimitry Andric case OO_Delete: 16930b57cec5SDimitry Andric case OO_Array_New: 16940b57cec5SDimitry Andric case OO_Array_Delete: 16950b57cec5SDimitry Andric case OO_Arrow: 16960b57cec5SDimitry Andric case OO_Conditional: 16970b57cec5SDimitry Andric case NUM_OVERLOADED_OPERATORS: 16980b57cec5SDimitry Andric llvm_unreachable("Invalid operator call kind"); 16990b57cec5SDimitry Andric 17000b57cec5SDimitry Andric case OO_Plus: 170106c3fb27SDimitry Andric if (NumArgs == 1) { 17020b57cec5SDimitry Andric UnaryOp = UO_Plus; 17030b57cec5SDimitry Andric return Stmt::UnaryOperatorClass; 17040b57cec5SDimitry Andric } 17050b57cec5SDimitry Andric 17060b57cec5SDimitry Andric BinaryOp = BO_Add; 17070b57cec5SDimitry Andric return Stmt::BinaryOperatorClass; 17080b57cec5SDimitry Andric 17090b57cec5SDimitry Andric case OO_Minus: 171006c3fb27SDimitry Andric if (NumArgs == 1) { 17110b57cec5SDimitry Andric UnaryOp = UO_Minus; 17120b57cec5SDimitry Andric return Stmt::UnaryOperatorClass; 17130b57cec5SDimitry Andric } 17140b57cec5SDimitry Andric 17150b57cec5SDimitry Andric BinaryOp = BO_Sub; 17160b57cec5SDimitry Andric return Stmt::BinaryOperatorClass; 17170b57cec5SDimitry Andric 17180b57cec5SDimitry Andric case OO_Star: 171906c3fb27SDimitry Andric if (NumArgs == 1) { 17200b57cec5SDimitry Andric UnaryOp = UO_Deref; 17210b57cec5SDimitry Andric return Stmt::UnaryOperatorClass; 17220b57cec5SDimitry Andric } 17230b57cec5SDimitry Andric 17240b57cec5SDimitry Andric BinaryOp = BO_Mul; 17250b57cec5SDimitry Andric return Stmt::BinaryOperatorClass; 17260b57cec5SDimitry Andric 17270b57cec5SDimitry Andric case OO_Slash: 17280b57cec5SDimitry Andric BinaryOp = BO_Div; 17290b57cec5SDimitry Andric return Stmt::BinaryOperatorClass; 17300b57cec5SDimitry Andric 17310b57cec5SDimitry Andric case OO_Percent: 17320b57cec5SDimitry Andric BinaryOp = BO_Rem; 17330b57cec5SDimitry Andric return Stmt::BinaryOperatorClass; 17340b57cec5SDimitry Andric 17350b57cec5SDimitry Andric case OO_Caret: 17360b57cec5SDimitry Andric BinaryOp = BO_Xor; 17370b57cec5SDimitry Andric return Stmt::BinaryOperatorClass; 17380b57cec5SDimitry Andric 17390b57cec5SDimitry Andric case OO_Amp: 174006c3fb27SDimitry Andric if (NumArgs == 1) { 17410b57cec5SDimitry Andric UnaryOp = UO_AddrOf; 17420b57cec5SDimitry Andric return Stmt::UnaryOperatorClass; 17430b57cec5SDimitry Andric } 17440b57cec5SDimitry Andric 17450b57cec5SDimitry Andric BinaryOp = BO_And; 17460b57cec5SDimitry Andric return Stmt::BinaryOperatorClass; 17470b57cec5SDimitry Andric 17480b57cec5SDimitry Andric case OO_Pipe: 17490b57cec5SDimitry Andric BinaryOp = BO_Or; 17500b57cec5SDimitry Andric return Stmt::BinaryOperatorClass; 17510b57cec5SDimitry Andric 17520b57cec5SDimitry Andric case OO_Tilde: 17530b57cec5SDimitry Andric UnaryOp = UO_Not; 17540b57cec5SDimitry Andric return Stmt::UnaryOperatorClass; 17550b57cec5SDimitry Andric 17560b57cec5SDimitry Andric case OO_Exclaim: 17570b57cec5SDimitry Andric UnaryOp = UO_LNot; 17580b57cec5SDimitry Andric return Stmt::UnaryOperatorClass; 17590b57cec5SDimitry Andric 17600b57cec5SDimitry Andric case OO_Equal: 17610b57cec5SDimitry Andric BinaryOp = BO_Assign; 17620b57cec5SDimitry Andric return Stmt::BinaryOperatorClass; 17630b57cec5SDimitry Andric 17640b57cec5SDimitry Andric case OO_Less: 17650b57cec5SDimitry Andric BinaryOp = BO_LT; 17660b57cec5SDimitry Andric return Stmt::BinaryOperatorClass; 17670b57cec5SDimitry Andric 17680b57cec5SDimitry Andric case OO_Greater: 17690b57cec5SDimitry Andric BinaryOp = BO_GT; 17700b57cec5SDimitry Andric return Stmt::BinaryOperatorClass; 17710b57cec5SDimitry Andric 17720b57cec5SDimitry Andric case OO_PlusEqual: 17730b57cec5SDimitry Andric BinaryOp = BO_AddAssign; 17740b57cec5SDimitry Andric return Stmt::CompoundAssignOperatorClass; 17750b57cec5SDimitry Andric 17760b57cec5SDimitry Andric case OO_MinusEqual: 17770b57cec5SDimitry Andric BinaryOp = BO_SubAssign; 17780b57cec5SDimitry Andric return Stmt::CompoundAssignOperatorClass; 17790b57cec5SDimitry Andric 17800b57cec5SDimitry Andric case OO_StarEqual: 17810b57cec5SDimitry Andric BinaryOp = BO_MulAssign; 17820b57cec5SDimitry Andric return Stmt::CompoundAssignOperatorClass; 17830b57cec5SDimitry Andric 17840b57cec5SDimitry Andric case OO_SlashEqual: 17850b57cec5SDimitry Andric BinaryOp = BO_DivAssign; 17860b57cec5SDimitry Andric return Stmt::CompoundAssignOperatorClass; 17870b57cec5SDimitry Andric 17880b57cec5SDimitry Andric case OO_PercentEqual: 17890b57cec5SDimitry Andric BinaryOp = BO_RemAssign; 17900b57cec5SDimitry Andric return Stmt::CompoundAssignOperatorClass; 17910b57cec5SDimitry Andric 17920b57cec5SDimitry Andric case OO_CaretEqual: 17930b57cec5SDimitry Andric BinaryOp = BO_XorAssign; 17940b57cec5SDimitry Andric return Stmt::CompoundAssignOperatorClass; 17950b57cec5SDimitry Andric 17960b57cec5SDimitry Andric case OO_AmpEqual: 17970b57cec5SDimitry Andric BinaryOp = BO_AndAssign; 17980b57cec5SDimitry Andric return Stmt::CompoundAssignOperatorClass; 17990b57cec5SDimitry Andric 18000b57cec5SDimitry Andric case OO_PipeEqual: 18010b57cec5SDimitry Andric BinaryOp = BO_OrAssign; 18020b57cec5SDimitry Andric return Stmt::CompoundAssignOperatorClass; 18030b57cec5SDimitry Andric 18040b57cec5SDimitry Andric case OO_LessLess: 18050b57cec5SDimitry Andric BinaryOp = BO_Shl; 18060b57cec5SDimitry Andric return Stmt::BinaryOperatorClass; 18070b57cec5SDimitry Andric 18080b57cec5SDimitry Andric case OO_GreaterGreater: 18090b57cec5SDimitry Andric BinaryOp = BO_Shr; 18100b57cec5SDimitry Andric return Stmt::BinaryOperatorClass; 18110b57cec5SDimitry Andric 18120b57cec5SDimitry Andric case OO_LessLessEqual: 18130b57cec5SDimitry Andric BinaryOp = BO_ShlAssign; 18140b57cec5SDimitry Andric return Stmt::CompoundAssignOperatorClass; 18150b57cec5SDimitry Andric 18160b57cec5SDimitry Andric case OO_GreaterGreaterEqual: 18170b57cec5SDimitry Andric BinaryOp = BO_ShrAssign; 18180b57cec5SDimitry Andric return Stmt::CompoundAssignOperatorClass; 18190b57cec5SDimitry Andric 18200b57cec5SDimitry Andric case OO_EqualEqual: 18210b57cec5SDimitry Andric BinaryOp = BO_EQ; 18220b57cec5SDimitry Andric return Stmt::BinaryOperatorClass; 18230b57cec5SDimitry Andric 18240b57cec5SDimitry Andric case OO_ExclaimEqual: 18250b57cec5SDimitry Andric BinaryOp = BO_NE; 18260b57cec5SDimitry Andric return Stmt::BinaryOperatorClass; 18270b57cec5SDimitry Andric 18280b57cec5SDimitry Andric case OO_LessEqual: 18290b57cec5SDimitry Andric BinaryOp = BO_LE; 18300b57cec5SDimitry Andric return Stmt::BinaryOperatorClass; 18310b57cec5SDimitry Andric 18320b57cec5SDimitry Andric case OO_GreaterEqual: 18330b57cec5SDimitry Andric BinaryOp = BO_GE; 18340b57cec5SDimitry Andric return Stmt::BinaryOperatorClass; 18350b57cec5SDimitry Andric 18360b57cec5SDimitry Andric case OO_Spaceship: 183713138422SDimitry Andric BinaryOp = BO_Cmp; 183813138422SDimitry Andric return Stmt::BinaryOperatorClass; 18390b57cec5SDimitry Andric 18400b57cec5SDimitry Andric case OO_AmpAmp: 18410b57cec5SDimitry Andric BinaryOp = BO_LAnd; 18420b57cec5SDimitry Andric return Stmt::BinaryOperatorClass; 18430b57cec5SDimitry Andric 18440b57cec5SDimitry Andric case OO_PipePipe: 18450b57cec5SDimitry Andric BinaryOp = BO_LOr; 18460b57cec5SDimitry Andric return Stmt::BinaryOperatorClass; 18470b57cec5SDimitry Andric 18480b57cec5SDimitry Andric case OO_PlusPlus: 184906c3fb27SDimitry Andric UnaryOp = NumArgs == 1 ? UO_PreInc : UO_PostInc; 185006c3fb27SDimitry Andric NumArgs = 1; 18510b57cec5SDimitry Andric return Stmt::UnaryOperatorClass; 18520b57cec5SDimitry Andric 18530b57cec5SDimitry Andric case OO_MinusMinus: 185406c3fb27SDimitry Andric UnaryOp = NumArgs == 1 ? UO_PreDec : UO_PostDec; 185506c3fb27SDimitry Andric NumArgs = 1; 18560b57cec5SDimitry Andric return Stmt::UnaryOperatorClass; 18570b57cec5SDimitry Andric 18580b57cec5SDimitry Andric case OO_Comma: 18590b57cec5SDimitry Andric BinaryOp = BO_Comma; 18600b57cec5SDimitry Andric return Stmt::BinaryOperatorClass; 18610b57cec5SDimitry Andric 18620b57cec5SDimitry Andric case OO_ArrowStar: 18630b57cec5SDimitry Andric BinaryOp = BO_PtrMemI; 18640b57cec5SDimitry Andric return Stmt::BinaryOperatorClass; 18650b57cec5SDimitry Andric 18660b57cec5SDimitry Andric case OO_Subscript: 18670b57cec5SDimitry Andric return Stmt::ArraySubscriptExprClass; 18680b57cec5SDimitry Andric 18695ffd83dbSDimitry Andric case OO_Call: 18705ffd83dbSDimitry Andric return Stmt::CallExprClass; 18715ffd83dbSDimitry Andric 18720b57cec5SDimitry Andric case OO_Coawait: 18730b57cec5SDimitry Andric UnaryOp = UO_Coawait; 18740b57cec5SDimitry Andric return Stmt::UnaryOperatorClass; 18750b57cec5SDimitry Andric } 18760b57cec5SDimitry Andric 18770b57cec5SDimitry Andric llvm_unreachable("Invalid overloaded operator expression"); 18780b57cec5SDimitry Andric } 18790b57cec5SDimitry Andric 18800b57cec5SDimitry Andric #if defined(_MSC_VER) && !defined(__clang__) 18810b57cec5SDimitry Andric #if _MSC_VER == 1911 18820b57cec5SDimitry Andric // Work around https://developercommunity.visualstudio.com/content/problem/84002/clang-cl-when-built-with-vc-2017-crashes-cause-vc.html 18830b57cec5SDimitry Andric // MSVC 2017 update 3 miscompiles this function, and a clang built with it 18840b57cec5SDimitry Andric // will crash in stage 2 of a bootstrap build. 18850b57cec5SDimitry Andric #pragma optimize("", off) 18860b57cec5SDimitry Andric #endif 18870b57cec5SDimitry Andric #endif 18880b57cec5SDimitry Andric 18890b57cec5SDimitry Andric void StmtProfiler::VisitCXXOperatorCallExpr(const CXXOperatorCallExpr *S) { 18900b57cec5SDimitry Andric if (S->isTypeDependent()) { 18910b57cec5SDimitry Andric // Type-dependent operator calls are profiled like their underlying 18920b57cec5SDimitry Andric // syntactic operator. 18930b57cec5SDimitry Andric // 18940b57cec5SDimitry Andric // An operator call to operator-> is always implicit, so just skip it. The 18950b57cec5SDimitry Andric // enclosing MemberExpr will profile the actual member access. 18960b57cec5SDimitry Andric if (S->getOperator() == OO_Arrow) 18970b57cec5SDimitry Andric return Visit(S->getArg(0)); 18980b57cec5SDimitry Andric 18990b57cec5SDimitry Andric UnaryOperatorKind UnaryOp = UO_Extension; 19000b57cec5SDimitry Andric BinaryOperatorKind BinaryOp = BO_Comma; 190106c3fb27SDimitry Andric unsigned NumArgs = S->getNumArgs(); 190206c3fb27SDimitry Andric Stmt::StmtClass SC = DecodeOperatorCall(S, UnaryOp, BinaryOp, NumArgs); 19030b57cec5SDimitry Andric 19040b57cec5SDimitry Andric ID.AddInteger(SC); 190506c3fb27SDimitry Andric for (unsigned I = 0; I != NumArgs; ++I) 19060b57cec5SDimitry Andric Visit(S->getArg(I)); 19070b57cec5SDimitry Andric if (SC == Stmt::UnaryOperatorClass) 19080b57cec5SDimitry Andric ID.AddInteger(UnaryOp); 19090b57cec5SDimitry Andric else if (SC == Stmt::BinaryOperatorClass || 19100b57cec5SDimitry Andric SC == Stmt::CompoundAssignOperatorClass) 19110b57cec5SDimitry Andric ID.AddInteger(BinaryOp); 19120b57cec5SDimitry Andric else 19135ffd83dbSDimitry Andric assert(SC == Stmt::ArraySubscriptExprClass || SC == Stmt::CallExprClass); 19140b57cec5SDimitry Andric 19150b57cec5SDimitry Andric return; 19160b57cec5SDimitry Andric } 19170b57cec5SDimitry Andric 19180b57cec5SDimitry Andric VisitCallExpr(S); 19190b57cec5SDimitry Andric ID.AddInteger(S->getOperator()); 19200b57cec5SDimitry Andric } 19210b57cec5SDimitry Andric 1922a7dea167SDimitry Andric void StmtProfiler::VisitCXXRewrittenBinaryOperator( 1923a7dea167SDimitry Andric const CXXRewrittenBinaryOperator *S) { 1924a7dea167SDimitry Andric // If a rewritten operator were ever to be type-dependent, we should profile 1925a7dea167SDimitry Andric // it following its syntactic operator. 1926a7dea167SDimitry Andric assert(!S->isTypeDependent() && 1927a7dea167SDimitry Andric "resolved rewritten operator should never be type-dependent"); 1928a7dea167SDimitry Andric ID.AddBoolean(S->isReversed()); 1929a7dea167SDimitry Andric VisitExpr(S->getSemanticForm()); 1930a7dea167SDimitry Andric } 1931a7dea167SDimitry Andric 19320b57cec5SDimitry Andric #if defined(_MSC_VER) && !defined(__clang__) 19330b57cec5SDimitry Andric #if _MSC_VER == 1911 19340b57cec5SDimitry Andric #pragma optimize("", on) 19350b57cec5SDimitry Andric #endif 19360b57cec5SDimitry Andric #endif 19370b57cec5SDimitry Andric 19380b57cec5SDimitry Andric void StmtProfiler::VisitCXXMemberCallExpr(const CXXMemberCallExpr *S) { 19390b57cec5SDimitry Andric VisitCallExpr(S); 19400b57cec5SDimitry Andric } 19410b57cec5SDimitry Andric 19420b57cec5SDimitry Andric void StmtProfiler::VisitCUDAKernelCallExpr(const CUDAKernelCallExpr *S) { 19430b57cec5SDimitry Andric VisitCallExpr(S); 19440b57cec5SDimitry Andric } 19450b57cec5SDimitry Andric 19460b57cec5SDimitry Andric void StmtProfiler::VisitAsTypeExpr(const AsTypeExpr *S) { 19470b57cec5SDimitry Andric VisitExpr(S); 19480b57cec5SDimitry Andric } 19490b57cec5SDimitry Andric 19500b57cec5SDimitry Andric void StmtProfiler::VisitCXXNamedCastExpr(const CXXNamedCastExpr *S) { 19510b57cec5SDimitry Andric VisitExplicitCastExpr(S); 19520b57cec5SDimitry Andric } 19530b57cec5SDimitry Andric 19540b57cec5SDimitry Andric void StmtProfiler::VisitCXXStaticCastExpr(const CXXStaticCastExpr *S) { 19550b57cec5SDimitry Andric VisitCXXNamedCastExpr(S); 19560b57cec5SDimitry Andric } 19570b57cec5SDimitry Andric 19580b57cec5SDimitry Andric void StmtProfiler::VisitCXXDynamicCastExpr(const CXXDynamicCastExpr *S) { 19590b57cec5SDimitry Andric VisitCXXNamedCastExpr(S); 19600b57cec5SDimitry Andric } 19610b57cec5SDimitry Andric 19620b57cec5SDimitry Andric void 19630b57cec5SDimitry Andric StmtProfiler::VisitCXXReinterpretCastExpr(const CXXReinterpretCastExpr *S) { 19640b57cec5SDimitry Andric VisitCXXNamedCastExpr(S); 19650b57cec5SDimitry Andric } 19660b57cec5SDimitry Andric 19670b57cec5SDimitry Andric void StmtProfiler::VisitCXXConstCastExpr(const CXXConstCastExpr *S) { 19680b57cec5SDimitry Andric VisitCXXNamedCastExpr(S); 19690b57cec5SDimitry Andric } 19700b57cec5SDimitry Andric 19710b57cec5SDimitry Andric void StmtProfiler::VisitBuiltinBitCastExpr(const BuiltinBitCastExpr *S) { 19720b57cec5SDimitry Andric VisitExpr(S); 19730b57cec5SDimitry Andric VisitType(S->getTypeInfoAsWritten()->getType()); 19740b57cec5SDimitry Andric } 19750b57cec5SDimitry Andric 19765ffd83dbSDimitry Andric void StmtProfiler::VisitCXXAddrspaceCastExpr(const CXXAddrspaceCastExpr *S) { 19775ffd83dbSDimitry Andric VisitCXXNamedCastExpr(S); 19785ffd83dbSDimitry Andric } 19795ffd83dbSDimitry Andric 19800b57cec5SDimitry Andric void StmtProfiler::VisitUserDefinedLiteral(const UserDefinedLiteral *S) { 19810b57cec5SDimitry Andric VisitCallExpr(S); 19820b57cec5SDimitry Andric } 19830b57cec5SDimitry Andric 19840b57cec5SDimitry Andric void StmtProfiler::VisitCXXBoolLiteralExpr(const CXXBoolLiteralExpr *S) { 19850b57cec5SDimitry Andric VisitExpr(S); 19860b57cec5SDimitry Andric ID.AddBoolean(S->getValue()); 19870b57cec5SDimitry Andric } 19880b57cec5SDimitry Andric 19890b57cec5SDimitry Andric void StmtProfiler::VisitCXXNullPtrLiteralExpr(const CXXNullPtrLiteralExpr *S) { 19900b57cec5SDimitry Andric VisitExpr(S); 19910b57cec5SDimitry Andric } 19920b57cec5SDimitry Andric 19930b57cec5SDimitry Andric void StmtProfiler::VisitCXXStdInitializerListExpr( 19940b57cec5SDimitry Andric const CXXStdInitializerListExpr *S) { 19950b57cec5SDimitry Andric VisitExpr(S); 19960b57cec5SDimitry Andric } 19970b57cec5SDimitry Andric 19980b57cec5SDimitry Andric void StmtProfiler::VisitCXXTypeidExpr(const CXXTypeidExpr *S) { 19990b57cec5SDimitry Andric VisitExpr(S); 20000b57cec5SDimitry Andric if (S->isTypeOperand()) 20010b57cec5SDimitry Andric VisitType(S->getTypeOperandSourceInfo()->getType()); 20020b57cec5SDimitry Andric } 20030b57cec5SDimitry Andric 20040b57cec5SDimitry Andric void StmtProfiler::VisitCXXUuidofExpr(const CXXUuidofExpr *S) { 20050b57cec5SDimitry Andric VisitExpr(S); 20060b57cec5SDimitry Andric if (S->isTypeOperand()) 20070b57cec5SDimitry Andric VisitType(S->getTypeOperandSourceInfo()->getType()); 20080b57cec5SDimitry Andric } 20090b57cec5SDimitry Andric 20100b57cec5SDimitry Andric void StmtProfiler::VisitMSPropertyRefExpr(const MSPropertyRefExpr *S) { 20110b57cec5SDimitry Andric VisitExpr(S); 20120b57cec5SDimitry Andric VisitDecl(S->getPropertyDecl()); 20130b57cec5SDimitry Andric } 20140b57cec5SDimitry Andric 20150b57cec5SDimitry Andric void StmtProfiler::VisitMSPropertySubscriptExpr( 20160b57cec5SDimitry Andric const MSPropertySubscriptExpr *S) { 20170b57cec5SDimitry Andric VisitExpr(S); 20180b57cec5SDimitry Andric } 20190b57cec5SDimitry Andric 20200b57cec5SDimitry Andric void StmtProfiler::VisitCXXThisExpr(const CXXThisExpr *S) { 20210b57cec5SDimitry Andric VisitExpr(S); 20220b57cec5SDimitry Andric ID.AddBoolean(S->isImplicit()); 2023*0fca6ea1SDimitry Andric ID.AddBoolean(S->isCapturedByCopyInLambdaWithExplicitObjectParameter()); 20240b57cec5SDimitry Andric } 20250b57cec5SDimitry Andric 20260b57cec5SDimitry Andric void StmtProfiler::VisitCXXThrowExpr(const CXXThrowExpr *S) { 20270b57cec5SDimitry Andric VisitExpr(S); 20280b57cec5SDimitry Andric } 20290b57cec5SDimitry Andric 20300b57cec5SDimitry Andric void StmtProfiler::VisitCXXDefaultArgExpr(const CXXDefaultArgExpr *S) { 20310b57cec5SDimitry Andric VisitExpr(S); 20320b57cec5SDimitry Andric VisitDecl(S->getParam()); 20330b57cec5SDimitry Andric } 20340b57cec5SDimitry Andric 20350b57cec5SDimitry Andric void StmtProfiler::VisitCXXDefaultInitExpr(const CXXDefaultInitExpr *S) { 20360b57cec5SDimitry Andric VisitExpr(S); 20370b57cec5SDimitry Andric VisitDecl(S->getField()); 20380b57cec5SDimitry Andric } 20390b57cec5SDimitry Andric 20400b57cec5SDimitry Andric void StmtProfiler::VisitCXXBindTemporaryExpr(const CXXBindTemporaryExpr *S) { 20410b57cec5SDimitry Andric VisitExpr(S); 20420b57cec5SDimitry Andric VisitDecl( 20430b57cec5SDimitry Andric const_cast<CXXDestructorDecl *>(S->getTemporary()->getDestructor())); 20440b57cec5SDimitry Andric } 20450b57cec5SDimitry Andric 20460b57cec5SDimitry Andric void StmtProfiler::VisitCXXConstructExpr(const CXXConstructExpr *S) { 20470b57cec5SDimitry Andric VisitExpr(S); 20480b57cec5SDimitry Andric VisitDecl(S->getConstructor()); 20490b57cec5SDimitry Andric ID.AddBoolean(S->isElidable()); 20500b57cec5SDimitry Andric } 20510b57cec5SDimitry Andric 20520b57cec5SDimitry Andric void StmtProfiler::VisitCXXInheritedCtorInitExpr( 20530b57cec5SDimitry Andric const CXXInheritedCtorInitExpr *S) { 20540b57cec5SDimitry Andric VisitExpr(S); 20550b57cec5SDimitry Andric VisitDecl(S->getConstructor()); 20560b57cec5SDimitry Andric } 20570b57cec5SDimitry Andric 20580b57cec5SDimitry Andric void StmtProfiler::VisitCXXFunctionalCastExpr(const CXXFunctionalCastExpr *S) { 20590b57cec5SDimitry Andric VisitExplicitCastExpr(S); 20600b57cec5SDimitry Andric } 20610b57cec5SDimitry Andric 20620b57cec5SDimitry Andric void 20630b57cec5SDimitry Andric StmtProfiler::VisitCXXTemporaryObjectExpr(const CXXTemporaryObjectExpr *S) { 20640b57cec5SDimitry Andric VisitCXXConstructExpr(S); 20650b57cec5SDimitry Andric } 20660b57cec5SDimitry Andric 20670b57cec5SDimitry Andric void 20680b57cec5SDimitry Andric StmtProfiler::VisitLambdaExpr(const LambdaExpr *S) { 206906c3fb27SDimitry Andric if (!ProfileLambdaExpr) { 207081ad6265SDimitry Andric // Do not recursively visit the children of this expression. Profiling the 207181ad6265SDimitry Andric // body would result in unnecessary work, and is not safe to do during 207281ad6265SDimitry Andric // deserialization. 207381ad6265SDimitry Andric VisitStmtNoChildren(S); 207481ad6265SDimitry Andric 2075349cc55cSDimitry Andric // C++20 [temp.over.link]p5: 2076349cc55cSDimitry Andric // Two lambda-expressions are never considered equivalent. 2077349cc55cSDimitry Andric VisitDecl(S->getLambdaClass()); 207806c3fb27SDimitry Andric 207906c3fb27SDimitry Andric return; 208006c3fb27SDimitry Andric } 208106c3fb27SDimitry Andric 208206c3fb27SDimitry Andric CXXRecordDecl *Lambda = S->getLambdaClass(); 208306c3fb27SDimitry Andric for (const auto &Capture : Lambda->captures()) { 208406c3fb27SDimitry Andric ID.AddInteger(Capture.getCaptureKind()); 208506c3fb27SDimitry Andric if (Capture.capturesVariable()) 208606c3fb27SDimitry Andric VisitDecl(Capture.getCapturedVar()); 208706c3fb27SDimitry Andric } 2088*0fca6ea1SDimitry Andric 2089*0fca6ea1SDimitry Andric // Profiling the body of the lambda may be dangerous during deserialization. 2090*0fca6ea1SDimitry Andric // So we'd like only to profile the signature here. 2091*0fca6ea1SDimitry Andric ODRHash Hasher; 2092*0fca6ea1SDimitry Andric // FIXME: We can't get the operator call easily by 2093*0fca6ea1SDimitry Andric // `CXXRecordDecl::getLambdaCallOperator()` if we're in deserialization. 2094*0fca6ea1SDimitry Andric // So we have to do something raw here. 2095*0fca6ea1SDimitry Andric for (auto *SubDecl : Lambda->decls()) { 2096*0fca6ea1SDimitry Andric FunctionDecl *Call = nullptr; 2097*0fca6ea1SDimitry Andric if (auto *FTD = dyn_cast<FunctionTemplateDecl>(SubDecl)) 2098*0fca6ea1SDimitry Andric Call = FTD->getTemplatedDecl(); 2099*0fca6ea1SDimitry Andric else if (auto *FD = dyn_cast<FunctionDecl>(SubDecl)) 2100*0fca6ea1SDimitry Andric Call = FD; 2101*0fca6ea1SDimitry Andric 2102*0fca6ea1SDimitry Andric if (!Call) 2103*0fca6ea1SDimitry Andric continue; 2104*0fca6ea1SDimitry Andric 2105*0fca6ea1SDimitry Andric Hasher.AddFunctionDecl(Call, /*SkipBody=*/true); 2106*0fca6ea1SDimitry Andric } 2107*0fca6ea1SDimitry Andric ID.AddInteger(Hasher.CalculateHash()); 21080b57cec5SDimitry Andric } 21090b57cec5SDimitry Andric 21100b57cec5SDimitry Andric void 21110b57cec5SDimitry Andric StmtProfiler::VisitCXXScalarValueInitExpr(const CXXScalarValueInitExpr *S) { 21120b57cec5SDimitry Andric VisitExpr(S); 21130b57cec5SDimitry Andric } 21140b57cec5SDimitry Andric 21150b57cec5SDimitry Andric void StmtProfiler::VisitCXXDeleteExpr(const CXXDeleteExpr *S) { 21160b57cec5SDimitry Andric VisitExpr(S); 21170b57cec5SDimitry Andric ID.AddBoolean(S->isGlobalDelete()); 21180b57cec5SDimitry Andric ID.AddBoolean(S->isArrayForm()); 21190b57cec5SDimitry Andric VisitDecl(S->getOperatorDelete()); 21200b57cec5SDimitry Andric } 21210b57cec5SDimitry Andric 21220b57cec5SDimitry Andric void StmtProfiler::VisitCXXNewExpr(const CXXNewExpr *S) { 21230b57cec5SDimitry Andric VisitExpr(S); 21240b57cec5SDimitry Andric VisitType(S->getAllocatedType()); 21250b57cec5SDimitry Andric VisitDecl(S->getOperatorNew()); 21260b57cec5SDimitry Andric VisitDecl(S->getOperatorDelete()); 21270b57cec5SDimitry Andric ID.AddBoolean(S->isArray()); 21280b57cec5SDimitry Andric ID.AddInteger(S->getNumPlacementArgs()); 21290b57cec5SDimitry Andric ID.AddBoolean(S->isGlobalNew()); 21300b57cec5SDimitry Andric ID.AddBoolean(S->isParenTypeId()); 21315f757f3fSDimitry Andric ID.AddInteger(llvm::to_underlying(S->getInitializationStyle())); 21320b57cec5SDimitry Andric } 21330b57cec5SDimitry Andric 21340b57cec5SDimitry Andric void 21350b57cec5SDimitry Andric StmtProfiler::VisitCXXPseudoDestructorExpr(const CXXPseudoDestructorExpr *S) { 21360b57cec5SDimitry Andric VisitExpr(S); 21370b57cec5SDimitry Andric ID.AddBoolean(S->isArrow()); 21380b57cec5SDimitry Andric VisitNestedNameSpecifier(S->getQualifier()); 21390b57cec5SDimitry Andric ID.AddBoolean(S->getScopeTypeInfo() != nullptr); 21400b57cec5SDimitry Andric if (S->getScopeTypeInfo()) 21410b57cec5SDimitry Andric VisitType(S->getScopeTypeInfo()->getType()); 21420b57cec5SDimitry Andric ID.AddBoolean(S->getDestroyedTypeInfo() != nullptr); 21430b57cec5SDimitry Andric if (S->getDestroyedTypeInfo()) 21440b57cec5SDimitry Andric VisitType(S->getDestroyedType()); 21450b57cec5SDimitry Andric else 21460b57cec5SDimitry Andric VisitIdentifierInfo(S->getDestroyedTypeIdentifier()); 21470b57cec5SDimitry Andric } 21480b57cec5SDimitry Andric 21490b57cec5SDimitry Andric void StmtProfiler::VisitOverloadExpr(const OverloadExpr *S) { 21500b57cec5SDimitry Andric VisitExpr(S); 21510b57cec5SDimitry Andric VisitNestedNameSpecifier(S->getQualifier()); 21520b57cec5SDimitry Andric VisitName(S->getName(), /*TreatAsDecl*/ true); 21530b57cec5SDimitry Andric ID.AddBoolean(S->hasExplicitTemplateArgs()); 21540b57cec5SDimitry Andric if (S->hasExplicitTemplateArgs()) 21550b57cec5SDimitry Andric VisitTemplateArguments(S->getTemplateArgs(), S->getNumTemplateArgs()); 21560b57cec5SDimitry Andric } 21570b57cec5SDimitry Andric 21580b57cec5SDimitry Andric void 21590b57cec5SDimitry Andric StmtProfiler::VisitUnresolvedLookupExpr(const UnresolvedLookupExpr *S) { 21600b57cec5SDimitry Andric VisitOverloadExpr(S); 21610b57cec5SDimitry Andric } 21620b57cec5SDimitry Andric 21630b57cec5SDimitry Andric void StmtProfiler::VisitTypeTraitExpr(const TypeTraitExpr *S) { 21640b57cec5SDimitry Andric VisitExpr(S); 21650b57cec5SDimitry Andric ID.AddInteger(S->getTrait()); 21660b57cec5SDimitry Andric ID.AddInteger(S->getNumArgs()); 21670b57cec5SDimitry Andric for (unsigned I = 0, N = S->getNumArgs(); I != N; ++I) 21680b57cec5SDimitry Andric VisitType(S->getArg(I)->getType()); 21690b57cec5SDimitry Andric } 21700b57cec5SDimitry Andric 21710b57cec5SDimitry Andric void StmtProfiler::VisitArrayTypeTraitExpr(const ArrayTypeTraitExpr *S) { 21720b57cec5SDimitry Andric VisitExpr(S); 21730b57cec5SDimitry Andric ID.AddInteger(S->getTrait()); 21740b57cec5SDimitry Andric VisitType(S->getQueriedType()); 21750b57cec5SDimitry Andric } 21760b57cec5SDimitry Andric 21770b57cec5SDimitry Andric void StmtProfiler::VisitExpressionTraitExpr(const ExpressionTraitExpr *S) { 21780b57cec5SDimitry Andric VisitExpr(S); 21790b57cec5SDimitry Andric ID.AddInteger(S->getTrait()); 21800b57cec5SDimitry Andric VisitExpr(S->getQueriedExpression()); 21810b57cec5SDimitry Andric } 21820b57cec5SDimitry Andric 21830b57cec5SDimitry Andric void StmtProfiler::VisitDependentScopeDeclRefExpr( 21840b57cec5SDimitry Andric const DependentScopeDeclRefExpr *S) { 21850b57cec5SDimitry Andric VisitExpr(S); 21860b57cec5SDimitry Andric VisitName(S->getDeclName()); 21870b57cec5SDimitry Andric VisitNestedNameSpecifier(S->getQualifier()); 21880b57cec5SDimitry Andric ID.AddBoolean(S->hasExplicitTemplateArgs()); 21890b57cec5SDimitry Andric if (S->hasExplicitTemplateArgs()) 21900b57cec5SDimitry Andric VisitTemplateArguments(S->getTemplateArgs(), S->getNumTemplateArgs()); 21910b57cec5SDimitry Andric } 21920b57cec5SDimitry Andric 21930b57cec5SDimitry Andric void StmtProfiler::VisitExprWithCleanups(const ExprWithCleanups *S) { 21940b57cec5SDimitry Andric VisitExpr(S); 21950b57cec5SDimitry Andric } 21960b57cec5SDimitry Andric 21970b57cec5SDimitry Andric void StmtProfiler::VisitCXXUnresolvedConstructExpr( 21980b57cec5SDimitry Andric const CXXUnresolvedConstructExpr *S) { 21990b57cec5SDimitry Andric VisitExpr(S); 22000b57cec5SDimitry Andric VisitType(S->getTypeAsWritten()); 22010b57cec5SDimitry Andric ID.AddInteger(S->isListInitialization()); 22020b57cec5SDimitry Andric } 22030b57cec5SDimitry Andric 22040b57cec5SDimitry Andric void StmtProfiler::VisitCXXDependentScopeMemberExpr( 22050b57cec5SDimitry Andric const CXXDependentScopeMemberExpr *S) { 22060b57cec5SDimitry Andric ID.AddBoolean(S->isImplicitAccess()); 22070b57cec5SDimitry Andric if (!S->isImplicitAccess()) { 22080b57cec5SDimitry Andric VisitExpr(S); 22090b57cec5SDimitry Andric ID.AddBoolean(S->isArrow()); 22100b57cec5SDimitry Andric } 22110b57cec5SDimitry Andric VisitNestedNameSpecifier(S->getQualifier()); 22120b57cec5SDimitry Andric VisitName(S->getMember()); 22130b57cec5SDimitry Andric ID.AddBoolean(S->hasExplicitTemplateArgs()); 22140b57cec5SDimitry Andric if (S->hasExplicitTemplateArgs()) 22150b57cec5SDimitry Andric VisitTemplateArguments(S->getTemplateArgs(), S->getNumTemplateArgs()); 22160b57cec5SDimitry Andric } 22170b57cec5SDimitry Andric 22180b57cec5SDimitry Andric void StmtProfiler::VisitUnresolvedMemberExpr(const UnresolvedMemberExpr *S) { 22190b57cec5SDimitry Andric ID.AddBoolean(S->isImplicitAccess()); 22200b57cec5SDimitry Andric if (!S->isImplicitAccess()) { 22210b57cec5SDimitry Andric VisitExpr(S); 22220b57cec5SDimitry Andric ID.AddBoolean(S->isArrow()); 22230b57cec5SDimitry Andric } 22240b57cec5SDimitry Andric VisitNestedNameSpecifier(S->getQualifier()); 22250b57cec5SDimitry Andric VisitName(S->getMemberName()); 22260b57cec5SDimitry Andric ID.AddBoolean(S->hasExplicitTemplateArgs()); 22270b57cec5SDimitry Andric if (S->hasExplicitTemplateArgs()) 22280b57cec5SDimitry Andric VisitTemplateArguments(S->getTemplateArgs(), S->getNumTemplateArgs()); 22290b57cec5SDimitry Andric } 22300b57cec5SDimitry Andric 22310b57cec5SDimitry Andric void StmtProfiler::VisitCXXNoexceptExpr(const CXXNoexceptExpr *S) { 22320b57cec5SDimitry Andric VisitExpr(S); 22330b57cec5SDimitry Andric } 22340b57cec5SDimitry Andric 22350b57cec5SDimitry Andric void StmtProfiler::VisitPackExpansionExpr(const PackExpansionExpr *S) { 22360b57cec5SDimitry Andric VisitExpr(S); 22370b57cec5SDimitry Andric } 22380b57cec5SDimitry Andric 22390b57cec5SDimitry Andric void StmtProfiler::VisitSizeOfPackExpr(const SizeOfPackExpr *S) { 22400b57cec5SDimitry Andric VisitExpr(S); 22410b57cec5SDimitry Andric VisitDecl(S->getPack()); 22420b57cec5SDimitry Andric if (S->isPartiallySubstituted()) { 22430b57cec5SDimitry Andric auto Args = S->getPartialArguments(); 22440b57cec5SDimitry Andric ID.AddInteger(Args.size()); 22450b57cec5SDimitry Andric for (const auto &TA : Args) 22460b57cec5SDimitry Andric VisitTemplateArgument(TA); 22470b57cec5SDimitry Andric } else { 22480b57cec5SDimitry Andric ID.AddInteger(0); 22490b57cec5SDimitry Andric } 22500b57cec5SDimitry Andric } 22510b57cec5SDimitry Andric 2252*0fca6ea1SDimitry Andric void StmtProfiler::VisitPackIndexingExpr(const PackIndexingExpr *E) { 2253*0fca6ea1SDimitry Andric VisitExpr(E); 2254*0fca6ea1SDimitry Andric VisitExpr(E->getPackIdExpression()); 2255*0fca6ea1SDimitry Andric VisitExpr(E->getIndexExpr()); 2256*0fca6ea1SDimitry Andric } 2257*0fca6ea1SDimitry Andric 22580b57cec5SDimitry Andric void StmtProfiler::VisitSubstNonTypeTemplateParmPackExpr( 22590b57cec5SDimitry Andric const SubstNonTypeTemplateParmPackExpr *S) { 22600b57cec5SDimitry Andric VisitExpr(S); 22610b57cec5SDimitry Andric VisitDecl(S->getParameterPack()); 22620b57cec5SDimitry Andric VisitTemplateArgument(S->getArgumentPack()); 22630b57cec5SDimitry Andric } 22640b57cec5SDimitry Andric 22650b57cec5SDimitry Andric void StmtProfiler::VisitSubstNonTypeTemplateParmExpr( 22660b57cec5SDimitry Andric const SubstNonTypeTemplateParmExpr *E) { 22670b57cec5SDimitry Andric // Profile exactly as the replacement expression. 22680b57cec5SDimitry Andric Visit(E->getReplacement()); 22690b57cec5SDimitry Andric } 22700b57cec5SDimitry Andric 22710b57cec5SDimitry Andric void StmtProfiler::VisitFunctionParmPackExpr(const FunctionParmPackExpr *S) { 22720b57cec5SDimitry Andric VisitExpr(S); 22730b57cec5SDimitry Andric VisitDecl(S->getParameterPack()); 22740b57cec5SDimitry Andric ID.AddInteger(S->getNumExpansions()); 22750b57cec5SDimitry Andric for (FunctionParmPackExpr::iterator I = S->begin(), E = S->end(); I != E; ++I) 22760b57cec5SDimitry Andric VisitDecl(*I); 22770b57cec5SDimitry Andric } 22780b57cec5SDimitry Andric 22790b57cec5SDimitry Andric void StmtProfiler::VisitMaterializeTemporaryExpr( 22800b57cec5SDimitry Andric const MaterializeTemporaryExpr *S) { 22810b57cec5SDimitry Andric VisitExpr(S); 22820b57cec5SDimitry Andric } 22830b57cec5SDimitry Andric 22840b57cec5SDimitry Andric void StmtProfiler::VisitCXXFoldExpr(const CXXFoldExpr *S) { 22850b57cec5SDimitry Andric VisitExpr(S); 22860b57cec5SDimitry Andric ID.AddInteger(S->getOperator()); 22870b57cec5SDimitry Andric } 22880b57cec5SDimitry Andric 2289bdd1243dSDimitry Andric void StmtProfiler::VisitCXXParenListInitExpr(const CXXParenListInitExpr *S) { 2290bdd1243dSDimitry Andric VisitExpr(S); 2291bdd1243dSDimitry Andric } 2292bdd1243dSDimitry Andric 22930b57cec5SDimitry Andric void StmtProfiler::VisitCoroutineBodyStmt(const CoroutineBodyStmt *S) { 22940b57cec5SDimitry Andric VisitStmt(S); 22950b57cec5SDimitry Andric } 22960b57cec5SDimitry Andric 22970b57cec5SDimitry Andric void StmtProfiler::VisitCoreturnStmt(const CoreturnStmt *S) { 22980b57cec5SDimitry Andric VisitStmt(S); 22990b57cec5SDimitry Andric } 23000b57cec5SDimitry Andric 23010b57cec5SDimitry Andric void StmtProfiler::VisitCoawaitExpr(const CoawaitExpr *S) { 23020b57cec5SDimitry Andric VisitExpr(S); 23030b57cec5SDimitry Andric } 23040b57cec5SDimitry Andric 23050b57cec5SDimitry Andric void StmtProfiler::VisitDependentCoawaitExpr(const DependentCoawaitExpr *S) { 23060b57cec5SDimitry Andric VisitExpr(S); 23070b57cec5SDimitry Andric } 23080b57cec5SDimitry Andric 23090b57cec5SDimitry Andric void StmtProfiler::VisitCoyieldExpr(const CoyieldExpr *S) { 23100b57cec5SDimitry Andric VisitExpr(S); 23110b57cec5SDimitry Andric } 23120b57cec5SDimitry Andric 23130b57cec5SDimitry Andric void StmtProfiler::VisitOpaqueValueExpr(const OpaqueValueExpr *E) { 23140b57cec5SDimitry Andric VisitExpr(E); 23150b57cec5SDimitry Andric } 23160b57cec5SDimitry Andric 23170b57cec5SDimitry Andric void StmtProfiler::VisitTypoExpr(const TypoExpr *E) { 23180b57cec5SDimitry Andric VisitExpr(E); 23190b57cec5SDimitry Andric } 23200b57cec5SDimitry Andric 23210b57cec5SDimitry Andric void StmtProfiler::VisitSourceLocExpr(const SourceLocExpr *E) { 23220b57cec5SDimitry Andric VisitExpr(E); 23230b57cec5SDimitry Andric } 23240b57cec5SDimitry Andric 2325*0fca6ea1SDimitry Andric void StmtProfiler::VisitEmbedExpr(const EmbedExpr *E) { VisitExpr(E); } 2326*0fca6ea1SDimitry Andric 23275ffd83dbSDimitry Andric void StmtProfiler::VisitRecoveryExpr(const RecoveryExpr *E) { VisitExpr(E); } 23285ffd83dbSDimitry Andric 23290b57cec5SDimitry Andric void StmtProfiler::VisitObjCStringLiteral(const ObjCStringLiteral *S) { 23300b57cec5SDimitry Andric VisitExpr(S); 23310b57cec5SDimitry Andric } 23320b57cec5SDimitry Andric 23330b57cec5SDimitry Andric void StmtProfiler::VisitObjCBoxedExpr(const ObjCBoxedExpr *E) { 23340b57cec5SDimitry Andric VisitExpr(E); 23350b57cec5SDimitry Andric } 23360b57cec5SDimitry Andric 23370b57cec5SDimitry Andric void StmtProfiler::VisitObjCArrayLiteral(const ObjCArrayLiteral *E) { 23380b57cec5SDimitry Andric VisitExpr(E); 23390b57cec5SDimitry Andric } 23400b57cec5SDimitry Andric 23410b57cec5SDimitry Andric void StmtProfiler::VisitObjCDictionaryLiteral(const ObjCDictionaryLiteral *E) { 23420b57cec5SDimitry Andric VisitExpr(E); 23430b57cec5SDimitry Andric } 23440b57cec5SDimitry Andric 23450b57cec5SDimitry Andric void StmtProfiler::VisitObjCEncodeExpr(const ObjCEncodeExpr *S) { 23460b57cec5SDimitry Andric VisitExpr(S); 23470b57cec5SDimitry Andric VisitType(S->getEncodedType()); 23480b57cec5SDimitry Andric } 23490b57cec5SDimitry Andric 23500b57cec5SDimitry Andric void StmtProfiler::VisitObjCSelectorExpr(const ObjCSelectorExpr *S) { 23510b57cec5SDimitry Andric VisitExpr(S); 23520b57cec5SDimitry Andric VisitName(S->getSelector()); 23530b57cec5SDimitry Andric } 23540b57cec5SDimitry Andric 23550b57cec5SDimitry Andric void StmtProfiler::VisitObjCProtocolExpr(const ObjCProtocolExpr *S) { 23560b57cec5SDimitry Andric VisitExpr(S); 23570b57cec5SDimitry Andric VisitDecl(S->getProtocol()); 23580b57cec5SDimitry Andric } 23590b57cec5SDimitry Andric 23600b57cec5SDimitry Andric void StmtProfiler::VisitObjCIvarRefExpr(const ObjCIvarRefExpr *S) { 23610b57cec5SDimitry Andric VisitExpr(S); 23620b57cec5SDimitry Andric VisitDecl(S->getDecl()); 23630b57cec5SDimitry Andric ID.AddBoolean(S->isArrow()); 23640b57cec5SDimitry Andric ID.AddBoolean(S->isFreeIvar()); 23650b57cec5SDimitry Andric } 23660b57cec5SDimitry Andric 23670b57cec5SDimitry Andric void StmtProfiler::VisitObjCPropertyRefExpr(const ObjCPropertyRefExpr *S) { 23680b57cec5SDimitry Andric VisitExpr(S); 23690b57cec5SDimitry Andric if (S->isImplicitProperty()) { 23700b57cec5SDimitry Andric VisitDecl(S->getImplicitPropertyGetter()); 23710b57cec5SDimitry Andric VisitDecl(S->getImplicitPropertySetter()); 23720b57cec5SDimitry Andric } else { 23730b57cec5SDimitry Andric VisitDecl(S->getExplicitProperty()); 23740b57cec5SDimitry Andric } 23750b57cec5SDimitry Andric if (S->isSuperReceiver()) { 23760b57cec5SDimitry Andric ID.AddBoolean(S->isSuperReceiver()); 23770b57cec5SDimitry Andric VisitType(S->getSuperReceiverType()); 23780b57cec5SDimitry Andric } 23790b57cec5SDimitry Andric } 23800b57cec5SDimitry Andric 23810b57cec5SDimitry Andric void StmtProfiler::VisitObjCSubscriptRefExpr(const ObjCSubscriptRefExpr *S) { 23820b57cec5SDimitry Andric VisitExpr(S); 23830b57cec5SDimitry Andric VisitDecl(S->getAtIndexMethodDecl()); 23840b57cec5SDimitry Andric VisitDecl(S->setAtIndexMethodDecl()); 23850b57cec5SDimitry Andric } 23860b57cec5SDimitry Andric 23870b57cec5SDimitry Andric void StmtProfiler::VisitObjCMessageExpr(const ObjCMessageExpr *S) { 23880b57cec5SDimitry Andric VisitExpr(S); 23890b57cec5SDimitry Andric VisitName(S->getSelector()); 23900b57cec5SDimitry Andric VisitDecl(S->getMethodDecl()); 23910b57cec5SDimitry Andric } 23920b57cec5SDimitry Andric 23930b57cec5SDimitry Andric void StmtProfiler::VisitObjCIsaExpr(const ObjCIsaExpr *S) { 23940b57cec5SDimitry Andric VisitExpr(S); 23950b57cec5SDimitry Andric ID.AddBoolean(S->isArrow()); 23960b57cec5SDimitry Andric } 23970b57cec5SDimitry Andric 23980b57cec5SDimitry Andric void StmtProfiler::VisitObjCBoolLiteralExpr(const ObjCBoolLiteralExpr *S) { 23990b57cec5SDimitry Andric VisitExpr(S); 24000b57cec5SDimitry Andric ID.AddBoolean(S->getValue()); 24010b57cec5SDimitry Andric } 24020b57cec5SDimitry Andric 24030b57cec5SDimitry Andric void StmtProfiler::VisitObjCIndirectCopyRestoreExpr( 24040b57cec5SDimitry Andric const ObjCIndirectCopyRestoreExpr *S) { 24050b57cec5SDimitry Andric VisitExpr(S); 24060b57cec5SDimitry Andric ID.AddBoolean(S->shouldCopy()); 24070b57cec5SDimitry Andric } 24080b57cec5SDimitry Andric 24090b57cec5SDimitry Andric void StmtProfiler::VisitObjCBridgedCastExpr(const ObjCBridgedCastExpr *S) { 24100b57cec5SDimitry Andric VisitExplicitCastExpr(S); 24110b57cec5SDimitry Andric ID.AddBoolean(S->getBridgeKind()); 24120b57cec5SDimitry Andric } 24130b57cec5SDimitry Andric 24140b57cec5SDimitry Andric void StmtProfiler::VisitObjCAvailabilityCheckExpr( 24150b57cec5SDimitry Andric const ObjCAvailabilityCheckExpr *S) { 24160b57cec5SDimitry Andric VisitExpr(S); 24170b57cec5SDimitry Andric } 24180b57cec5SDimitry Andric 24190b57cec5SDimitry Andric void StmtProfiler::VisitTemplateArguments(const TemplateArgumentLoc *Args, 24200b57cec5SDimitry Andric unsigned NumArgs) { 24210b57cec5SDimitry Andric ID.AddInteger(NumArgs); 24220b57cec5SDimitry Andric for (unsigned I = 0; I != NumArgs; ++I) 24230b57cec5SDimitry Andric VisitTemplateArgument(Args[I].getArgument()); 24240b57cec5SDimitry Andric } 24250b57cec5SDimitry Andric 24260b57cec5SDimitry Andric void StmtProfiler::VisitTemplateArgument(const TemplateArgument &Arg) { 24270b57cec5SDimitry Andric // Mostly repetitive with TemplateArgument::Profile! 24280b57cec5SDimitry Andric ID.AddInteger(Arg.getKind()); 24290b57cec5SDimitry Andric switch (Arg.getKind()) { 24300b57cec5SDimitry Andric case TemplateArgument::Null: 24310b57cec5SDimitry Andric break; 24320b57cec5SDimitry Andric 24330b57cec5SDimitry Andric case TemplateArgument::Type: 24340b57cec5SDimitry Andric VisitType(Arg.getAsType()); 24350b57cec5SDimitry Andric break; 24360b57cec5SDimitry Andric 24370b57cec5SDimitry Andric case TemplateArgument::Template: 24380b57cec5SDimitry Andric case TemplateArgument::TemplateExpansion: 24390b57cec5SDimitry Andric VisitTemplateName(Arg.getAsTemplateOrTemplatePattern()); 24400b57cec5SDimitry Andric break; 24410b57cec5SDimitry Andric 24420b57cec5SDimitry Andric case TemplateArgument::Declaration: 2443e8d8bef9SDimitry Andric VisitType(Arg.getParamTypeForDecl()); 2444e8d8bef9SDimitry Andric // FIXME: Do we need to recursively decompose template parameter objects? 24450b57cec5SDimitry Andric VisitDecl(Arg.getAsDecl()); 24460b57cec5SDimitry Andric break; 24470b57cec5SDimitry Andric 24480b57cec5SDimitry Andric case TemplateArgument::NullPtr: 24490b57cec5SDimitry Andric VisitType(Arg.getNullPtrType()); 24500b57cec5SDimitry Andric break; 24510b57cec5SDimitry Andric 24520b57cec5SDimitry Andric case TemplateArgument::Integral: 24530b57cec5SDimitry Andric VisitType(Arg.getIntegralType()); 2454e8d8bef9SDimitry Andric Arg.getAsIntegral().Profile(ID); 24550b57cec5SDimitry Andric break; 24560b57cec5SDimitry Andric 24577a6dacacSDimitry Andric case TemplateArgument::StructuralValue: 24587a6dacacSDimitry Andric VisitType(Arg.getStructuralValueType()); 24597a6dacacSDimitry Andric // FIXME: Do we need to recursively decompose this ourselves? 24607a6dacacSDimitry Andric Arg.getAsStructuralValue().Profile(ID); 24617a6dacacSDimitry Andric break; 24627a6dacacSDimitry Andric 24630b57cec5SDimitry Andric case TemplateArgument::Expression: 24640b57cec5SDimitry Andric Visit(Arg.getAsExpr()); 24650b57cec5SDimitry Andric break; 24660b57cec5SDimitry Andric 24670b57cec5SDimitry Andric case TemplateArgument::Pack: 24680b57cec5SDimitry Andric for (const auto &P : Arg.pack_elements()) 24690b57cec5SDimitry Andric VisitTemplateArgument(P); 24700b57cec5SDimitry Andric break; 24710b57cec5SDimitry Andric } 24720b57cec5SDimitry Andric } 24730b57cec5SDimitry Andric 2474*0fca6ea1SDimitry Andric namespace { 2475*0fca6ea1SDimitry Andric class OpenACCClauseProfiler 2476*0fca6ea1SDimitry Andric : public OpenACCClauseVisitor<OpenACCClauseProfiler> { 2477*0fca6ea1SDimitry Andric StmtProfiler &Profiler; 2478*0fca6ea1SDimitry Andric 2479*0fca6ea1SDimitry Andric public: 2480*0fca6ea1SDimitry Andric OpenACCClauseProfiler(StmtProfiler &P) : Profiler(P) {} 2481*0fca6ea1SDimitry Andric 2482*0fca6ea1SDimitry Andric void VisitOpenACCClauseList(ArrayRef<const OpenACCClause *> Clauses) { 2483*0fca6ea1SDimitry Andric for (const OpenACCClause *Clause : Clauses) { 2484*0fca6ea1SDimitry Andric // TODO OpenACC: When we have clauses with expressions, we should 2485*0fca6ea1SDimitry Andric // profile them too. 2486*0fca6ea1SDimitry Andric Visit(Clause); 2487*0fca6ea1SDimitry Andric } 2488*0fca6ea1SDimitry Andric } 2489*0fca6ea1SDimitry Andric 2490*0fca6ea1SDimitry Andric #define VISIT_CLAUSE(CLAUSE_NAME) \ 2491*0fca6ea1SDimitry Andric void Visit##CLAUSE_NAME##Clause(const OpenACC##CLAUSE_NAME##Clause &Clause); 2492*0fca6ea1SDimitry Andric 2493*0fca6ea1SDimitry Andric #include "clang/Basic/OpenACCClauses.def" 2494*0fca6ea1SDimitry Andric }; 2495*0fca6ea1SDimitry Andric 2496*0fca6ea1SDimitry Andric /// Nothing to do here, there are no sub-statements. 2497*0fca6ea1SDimitry Andric void OpenACCClauseProfiler::VisitDefaultClause( 2498*0fca6ea1SDimitry Andric const OpenACCDefaultClause &Clause) {} 2499*0fca6ea1SDimitry Andric 2500*0fca6ea1SDimitry Andric void OpenACCClauseProfiler::VisitIfClause(const OpenACCIfClause &Clause) { 2501*0fca6ea1SDimitry Andric assert(Clause.hasConditionExpr() && 2502*0fca6ea1SDimitry Andric "if clause requires a valid condition expr"); 2503*0fca6ea1SDimitry Andric Profiler.VisitStmt(Clause.getConditionExpr()); 2504*0fca6ea1SDimitry Andric } 2505*0fca6ea1SDimitry Andric 2506*0fca6ea1SDimitry Andric void OpenACCClauseProfiler::VisitCopyClause(const OpenACCCopyClause &Clause) { 2507*0fca6ea1SDimitry Andric for (auto *E : Clause.getVarList()) 2508*0fca6ea1SDimitry Andric Profiler.VisitStmt(E); 2509*0fca6ea1SDimitry Andric } 2510*0fca6ea1SDimitry Andric void OpenACCClauseProfiler::VisitCopyInClause( 2511*0fca6ea1SDimitry Andric const OpenACCCopyInClause &Clause) { 2512*0fca6ea1SDimitry Andric for (auto *E : Clause.getVarList()) 2513*0fca6ea1SDimitry Andric Profiler.VisitStmt(E); 2514*0fca6ea1SDimitry Andric } 2515*0fca6ea1SDimitry Andric 2516*0fca6ea1SDimitry Andric void OpenACCClauseProfiler::VisitCopyOutClause( 2517*0fca6ea1SDimitry Andric const OpenACCCopyOutClause &Clause) { 2518*0fca6ea1SDimitry Andric for (auto *E : Clause.getVarList()) 2519*0fca6ea1SDimitry Andric Profiler.VisitStmt(E); 2520*0fca6ea1SDimitry Andric } 2521*0fca6ea1SDimitry Andric 2522*0fca6ea1SDimitry Andric void OpenACCClauseProfiler::VisitCreateClause( 2523*0fca6ea1SDimitry Andric const OpenACCCreateClause &Clause) { 2524*0fca6ea1SDimitry Andric for (auto *E : Clause.getVarList()) 2525*0fca6ea1SDimitry Andric Profiler.VisitStmt(E); 2526*0fca6ea1SDimitry Andric } 2527*0fca6ea1SDimitry Andric 2528*0fca6ea1SDimitry Andric void OpenACCClauseProfiler::VisitSelfClause(const OpenACCSelfClause &Clause) { 2529*0fca6ea1SDimitry Andric if (Clause.hasConditionExpr()) 2530*0fca6ea1SDimitry Andric Profiler.VisitStmt(Clause.getConditionExpr()); 2531*0fca6ea1SDimitry Andric } 2532*0fca6ea1SDimitry Andric 2533*0fca6ea1SDimitry Andric void OpenACCClauseProfiler::VisitNumGangsClause( 2534*0fca6ea1SDimitry Andric const OpenACCNumGangsClause &Clause) { 2535*0fca6ea1SDimitry Andric for (auto *E : Clause.getIntExprs()) 2536*0fca6ea1SDimitry Andric Profiler.VisitStmt(E); 2537*0fca6ea1SDimitry Andric } 2538*0fca6ea1SDimitry Andric 2539*0fca6ea1SDimitry Andric void OpenACCClauseProfiler::VisitNumWorkersClause( 2540*0fca6ea1SDimitry Andric const OpenACCNumWorkersClause &Clause) { 2541*0fca6ea1SDimitry Andric assert(Clause.hasIntExpr() && "num_workers clause requires a valid int expr"); 2542*0fca6ea1SDimitry Andric Profiler.VisitStmt(Clause.getIntExpr()); 2543*0fca6ea1SDimitry Andric } 2544*0fca6ea1SDimitry Andric 2545*0fca6ea1SDimitry Andric void OpenACCClauseProfiler::VisitPrivateClause( 2546*0fca6ea1SDimitry Andric const OpenACCPrivateClause &Clause) { 2547*0fca6ea1SDimitry Andric for (auto *E : Clause.getVarList()) 2548*0fca6ea1SDimitry Andric Profiler.VisitStmt(E); 2549*0fca6ea1SDimitry Andric } 2550*0fca6ea1SDimitry Andric 2551*0fca6ea1SDimitry Andric void OpenACCClauseProfiler::VisitFirstPrivateClause( 2552*0fca6ea1SDimitry Andric const OpenACCFirstPrivateClause &Clause) { 2553*0fca6ea1SDimitry Andric for (auto *E : Clause.getVarList()) 2554*0fca6ea1SDimitry Andric Profiler.VisitStmt(E); 2555*0fca6ea1SDimitry Andric } 2556*0fca6ea1SDimitry Andric 2557*0fca6ea1SDimitry Andric void OpenACCClauseProfiler::VisitAttachClause( 2558*0fca6ea1SDimitry Andric const OpenACCAttachClause &Clause) { 2559*0fca6ea1SDimitry Andric for (auto *E : Clause.getVarList()) 2560*0fca6ea1SDimitry Andric Profiler.VisitStmt(E); 2561*0fca6ea1SDimitry Andric } 2562*0fca6ea1SDimitry Andric 2563*0fca6ea1SDimitry Andric void OpenACCClauseProfiler::VisitDevicePtrClause( 2564*0fca6ea1SDimitry Andric const OpenACCDevicePtrClause &Clause) { 2565*0fca6ea1SDimitry Andric for (auto *E : Clause.getVarList()) 2566*0fca6ea1SDimitry Andric Profiler.VisitStmt(E); 2567*0fca6ea1SDimitry Andric } 2568*0fca6ea1SDimitry Andric 2569*0fca6ea1SDimitry Andric void OpenACCClauseProfiler::VisitNoCreateClause( 2570*0fca6ea1SDimitry Andric const OpenACCNoCreateClause &Clause) { 2571*0fca6ea1SDimitry Andric for (auto *E : Clause.getVarList()) 2572*0fca6ea1SDimitry Andric Profiler.VisitStmt(E); 2573*0fca6ea1SDimitry Andric } 2574*0fca6ea1SDimitry Andric 2575*0fca6ea1SDimitry Andric void OpenACCClauseProfiler::VisitPresentClause( 2576*0fca6ea1SDimitry Andric const OpenACCPresentClause &Clause) { 2577*0fca6ea1SDimitry Andric for (auto *E : Clause.getVarList()) 2578*0fca6ea1SDimitry Andric Profiler.VisitStmt(E); 2579*0fca6ea1SDimitry Andric } 2580*0fca6ea1SDimitry Andric 2581*0fca6ea1SDimitry Andric void OpenACCClauseProfiler::VisitVectorLengthClause( 2582*0fca6ea1SDimitry Andric const OpenACCVectorLengthClause &Clause) { 2583*0fca6ea1SDimitry Andric assert(Clause.hasIntExpr() && 2584*0fca6ea1SDimitry Andric "vector_length clause requires a valid int expr"); 2585*0fca6ea1SDimitry Andric Profiler.VisitStmt(Clause.getIntExpr()); 2586*0fca6ea1SDimitry Andric } 2587*0fca6ea1SDimitry Andric 2588*0fca6ea1SDimitry Andric void OpenACCClauseProfiler::VisitAsyncClause(const OpenACCAsyncClause &Clause) { 2589*0fca6ea1SDimitry Andric if (Clause.hasIntExpr()) 2590*0fca6ea1SDimitry Andric Profiler.VisitStmt(Clause.getIntExpr()); 2591*0fca6ea1SDimitry Andric } 2592*0fca6ea1SDimitry Andric 2593*0fca6ea1SDimitry Andric void OpenACCClauseProfiler::VisitWaitClause(const OpenACCWaitClause &Clause) { 2594*0fca6ea1SDimitry Andric if (Clause.hasDevNumExpr()) 2595*0fca6ea1SDimitry Andric Profiler.VisitStmt(Clause.getDevNumExpr()); 2596*0fca6ea1SDimitry Andric for (auto *E : Clause.getQueueIdExprs()) 2597*0fca6ea1SDimitry Andric Profiler.VisitStmt(E); 2598*0fca6ea1SDimitry Andric } 2599*0fca6ea1SDimitry Andric /// Nothing to do here, there are no sub-statements. 2600*0fca6ea1SDimitry Andric void OpenACCClauseProfiler::VisitDeviceTypeClause( 2601*0fca6ea1SDimitry Andric const OpenACCDeviceTypeClause &Clause) {} 2602*0fca6ea1SDimitry Andric 2603*0fca6ea1SDimitry Andric void OpenACCClauseProfiler::VisitAutoClause(const OpenACCAutoClause &Clause) {} 2604*0fca6ea1SDimitry Andric 2605*0fca6ea1SDimitry Andric void OpenACCClauseProfiler::VisitIndependentClause( 2606*0fca6ea1SDimitry Andric const OpenACCIndependentClause &Clause) {} 2607*0fca6ea1SDimitry Andric 2608*0fca6ea1SDimitry Andric void OpenACCClauseProfiler::VisitSeqClause(const OpenACCSeqClause &Clause) {} 2609*0fca6ea1SDimitry Andric 2610*0fca6ea1SDimitry Andric void OpenACCClauseProfiler::VisitReductionClause( 2611*0fca6ea1SDimitry Andric const OpenACCReductionClause &Clause) { 2612*0fca6ea1SDimitry Andric for (auto *E : Clause.getVarList()) 2613*0fca6ea1SDimitry Andric Profiler.VisitStmt(E); 2614*0fca6ea1SDimitry Andric } 2615*0fca6ea1SDimitry Andric } // namespace 2616*0fca6ea1SDimitry Andric 2617*0fca6ea1SDimitry Andric void StmtProfiler::VisitOpenACCComputeConstruct( 2618*0fca6ea1SDimitry Andric const OpenACCComputeConstruct *S) { 2619*0fca6ea1SDimitry Andric // VisitStmt handles children, so the AssociatedStmt is handled. 2620*0fca6ea1SDimitry Andric VisitStmt(S); 2621*0fca6ea1SDimitry Andric 2622*0fca6ea1SDimitry Andric OpenACCClauseProfiler P{*this}; 2623*0fca6ea1SDimitry Andric P.VisitOpenACCClauseList(S->clauses()); 2624*0fca6ea1SDimitry Andric } 2625*0fca6ea1SDimitry Andric 2626*0fca6ea1SDimitry Andric void StmtProfiler::VisitOpenACCLoopConstruct(const OpenACCLoopConstruct *S) { 2627*0fca6ea1SDimitry Andric // VisitStmt handles children, so the Loop is handled. 2628*0fca6ea1SDimitry Andric VisitStmt(S); 2629*0fca6ea1SDimitry Andric 2630*0fca6ea1SDimitry Andric OpenACCClauseProfiler P{*this}; 2631*0fca6ea1SDimitry Andric P.VisitOpenACCClauseList(S->clauses()); 2632*0fca6ea1SDimitry Andric } 2633*0fca6ea1SDimitry Andric 26340b57cec5SDimitry Andric void Stmt::Profile(llvm::FoldingSetNodeID &ID, const ASTContext &Context, 263506c3fb27SDimitry Andric bool Canonical, bool ProfileLambdaExpr) const { 263606c3fb27SDimitry Andric StmtProfilerWithPointers Profiler(ID, Context, Canonical, ProfileLambdaExpr); 26370b57cec5SDimitry Andric Profiler.Visit(this); 26380b57cec5SDimitry Andric } 26390b57cec5SDimitry Andric 26400b57cec5SDimitry Andric void Stmt::ProcessODRHash(llvm::FoldingSetNodeID &ID, 26410b57cec5SDimitry Andric class ODRHash &Hash) const { 26420b57cec5SDimitry Andric StmtProfilerWithoutPointers Profiler(ID, Hash); 26430b57cec5SDimitry Andric Profiler.Visit(this); 26440b57cec5SDimitry Andric } 2645