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