Douglas Gregor | 5c193b9 | 2009-07-28 00:33:38 +0000 | [diff] [blame] | 1 | //===---- StmtProfile.cpp - Profile implementation for Stmt ASTs ----------===// |
| 2 | // |
| 3 | // The LLVM Compiler Infrastructure |
| 4 | // |
| 5 | // This file is distributed under the University of Illinois Open Source |
| 6 | // License. See LICENSE.TXT for details. |
| 7 | // |
| 8 | //===----------------------------------------------------------------------===// |
| 9 | // |
| 10 | // This file implements the Stmt::Profile method, which builds a unique bit |
Douglas Gregor | 32615a1 | 2009-07-28 16:39:25 +0000 | [diff] [blame] | 11 | // representation that identifies a statement/expression. |
Douglas Gregor | 5c193b9 | 2009-07-28 00:33:38 +0000 | [diff] [blame] | 12 | // |
| 13 | //===----------------------------------------------------------------------===// |
| 14 | #include "clang/AST/ASTContext.h" |
Douglas Gregor | a709509 | 2009-07-28 14:44:31 +0000 | [diff] [blame] | 15 | #include "clang/AST/DeclCXX.h" |
| 16 | #include "clang/AST/DeclObjC.h" |
Douglas Gregor | 5c193b9 | 2009-07-28 00:33:38 +0000 | [diff] [blame] | 17 | #include "clang/AST/DeclTemplate.h" |
| 18 | #include "clang/AST/Expr.h" |
| 19 | #include "clang/AST/ExprCXX.h" |
| 20 | #include "clang/AST/ExprObjC.h" |
Alexey Bataev | 1a3320e | 2015-08-25 14:24:04 +0000 | [diff] [blame] | 21 | #include "clang/AST/ExprOpenMP.h" |
Richard Trieu | 639d7b6 | 2017-02-22 22:22:42 +0000 | [diff] [blame] | 22 | #include "clang/AST/ODRHash.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)); |
Douglas Gregor | 4488259 | 2009-07-28 15:27:13 +0000 | [diff] [blame] | 325 | } |
| 326 | |
Chad Rosier | 3250302 | 2012-06-11 20:47:18 +0000 | [diff] [blame] | 327 | void StmtProfiler::VisitMSAsmStmt(const MSAsmStmt *S) { |
| 328 | // FIXME: Implement MS style inline asm statement profiler. |
| 329 | VisitStmt(S); |
| 330 | } |
| 331 | |
Chandler Carruth | 631abd9 | 2011-06-16 06:47:06 +0000 | [diff] [blame] | 332 | void StmtProfiler::VisitCXXCatchStmt(const CXXCatchStmt *S) { |
Douglas Gregor | 4488259 | 2009-07-28 15:27:13 +0000 | [diff] [blame] | 333 | VisitStmt(S); |
| 334 | VisitType(S->getCaughtType()); |
| 335 | } |
| 336 | |
Chandler Carruth | 631abd9 | 2011-06-16 06:47:06 +0000 | [diff] [blame] | 337 | void StmtProfiler::VisitCXXTryStmt(const CXXTryStmt *S) { |
Douglas Gregor | 4488259 | 2009-07-28 15:27:13 +0000 | [diff] [blame] | 338 | VisitStmt(S); |
| 339 | } |
| 340 | |
Chandler Carruth | 631abd9 | 2011-06-16 06:47:06 +0000 | [diff] [blame] | 341 | void StmtProfiler::VisitCXXForRangeStmt(const CXXForRangeStmt *S) { |
Richard Smith | 02e85f3 | 2011-04-14 22:09:26 +0000 | [diff] [blame] | 342 | VisitStmt(S); |
| 343 | } |
| 344 | |
Douglas Gregor | deb4a2be | 2011-10-25 01:33:02 +0000 | [diff] [blame] | 345 | void StmtProfiler::VisitMSDependentExistsStmt(const MSDependentExistsStmt *S) { |
| 346 | VisitStmt(S); |
| 347 | ID.AddBoolean(S->isIfExists()); |
| 348 | VisitNestedNameSpecifier(S->getQualifierLoc().getNestedNameSpecifier()); |
| 349 | VisitName(S->getNameInfo().getName()); |
| 350 | } |
| 351 | |
Chandler Carruth | 631abd9 | 2011-06-16 06:47:06 +0000 | [diff] [blame] | 352 | void StmtProfiler::VisitSEHTryStmt(const SEHTryStmt *S) { |
John Wiegley | 1c0675e | 2011-04-28 01:08:34 +0000 | [diff] [blame] | 353 | VisitStmt(S); |
| 354 | } |
| 355 | |
Chandler Carruth | 631abd9 | 2011-06-16 06:47:06 +0000 | [diff] [blame] | 356 | void StmtProfiler::VisitSEHFinallyStmt(const SEHFinallyStmt *S) { |
John Wiegley | 1c0675e | 2011-04-28 01:08:34 +0000 | [diff] [blame] | 357 | VisitStmt(S); |
| 358 | } |
| 359 | |
Chandler Carruth | 631abd9 | 2011-06-16 06:47:06 +0000 | [diff] [blame] | 360 | void StmtProfiler::VisitSEHExceptStmt(const SEHExceptStmt *S) { |
John Wiegley | 1c0675e | 2011-04-28 01:08:34 +0000 | [diff] [blame] | 361 | VisitStmt(S); |
| 362 | } |
| 363 | |
Nico Weber | 9b98207 | 2014-07-07 00:12:30 +0000 | [diff] [blame] | 364 | void StmtProfiler::VisitSEHLeaveStmt(const SEHLeaveStmt *S) { |
| 365 | VisitStmt(S); |
| 366 | } |
| 367 | |
Tareq A. Siraj | 24110cc | 2013-04-16 18:53:08 +0000 | [diff] [blame] | 368 | void StmtProfiler::VisitCapturedStmt(const CapturedStmt *S) { |
| 369 | VisitStmt(S); |
| 370 | } |
| 371 | |
Chandler Carruth | 631abd9 | 2011-06-16 06:47:06 +0000 | [diff] [blame] | 372 | void StmtProfiler::VisitObjCForCollectionStmt(const ObjCForCollectionStmt *S) { |
Douglas Gregor | 4488259 | 2009-07-28 15:27:13 +0000 | [diff] [blame] | 373 | VisitStmt(S); |
| 374 | } |
| 375 | |
Chandler Carruth | 631abd9 | 2011-06-16 06:47:06 +0000 | [diff] [blame] | 376 | void StmtProfiler::VisitObjCAtCatchStmt(const ObjCAtCatchStmt *S) { |
Douglas Gregor | 4488259 | 2009-07-28 15:27:13 +0000 | [diff] [blame] | 377 | VisitStmt(S); |
| 378 | ID.AddBoolean(S->hasEllipsis()); |
| 379 | if (S->getCatchParamDecl()) |
| 380 | VisitType(S->getCatchParamDecl()->getType()); |
| 381 | } |
| 382 | |
Chandler Carruth | 631abd9 | 2011-06-16 06:47:06 +0000 | [diff] [blame] | 383 | void StmtProfiler::VisitObjCAtFinallyStmt(const ObjCAtFinallyStmt *S) { |
Douglas Gregor | 4488259 | 2009-07-28 15:27:13 +0000 | [diff] [blame] | 384 | VisitStmt(S); |
| 385 | } |
| 386 | |
Chandler Carruth | 631abd9 | 2011-06-16 06:47:06 +0000 | [diff] [blame] | 387 | void StmtProfiler::VisitObjCAtTryStmt(const ObjCAtTryStmt *S) { |
Douglas Gregor | 4488259 | 2009-07-28 15:27:13 +0000 | [diff] [blame] | 388 | VisitStmt(S); |
| 389 | } |
| 390 | |
Chandler Carruth | 631abd9 | 2011-06-16 06:47:06 +0000 | [diff] [blame] | 391 | void |
| 392 | StmtProfiler::VisitObjCAtSynchronizedStmt(const ObjCAtSynchronizedStmt *S) { |
Douglas Gregor | 4488259 | 2009-07-28 15:27:13 +0000 | [diff] [blame] | 393 | VisitStmt(S); |
| 394 | } |
| 395 | |
Chandler Carruth | 631abd9 | 2011-06-16 06:47:06 +0000 | [diff] [blame] | 396 | void StmtProfiler::VisitObjCAtThrowStmt(const ObjCAtThrowStmt *S) { |
Douglas Gregor | 4488259 | 2009-07-28 15:27:13 +0000 | [diff] [blame] | 397 | VisitStmt(S); |
| 398 | } |
| 399 | |
Chandler Carruth | 631abd9 | 2011-06-16 06:47:06 +0000 | [diff] [blame] | 400 | void |
| 401 | StmtProfiler::VisitObjCAutoreleasePoolStmt(const ObjCAutoreleasePoolStmt *S) { |
John McCall | 31168b0 | 2011-06-15 23:02:42 +0000 | [diff] [blame] | 402 | VisitStmt(S); |
| 403 | } |
| 404 | |
Alexey Bataev | 5ec3eb1 | 2013-07-19 03:13:43 +0000 | [diff] [blame] | 405 | namespace { |
| 406 | class OMPClauseProfiler : public ConstOMPClauseVisitor<OMPClauseProfiler> { |
| 407 | StmtProfiler *Profiler; |
Adrian Prantl | 9fc8faf | 2018-05-09 01:00:01 +0000 | [diff] [blame] | 408 | /// Process clauses with list of variables. |
Alexey Bataev | 756c196 | 2013-09-24 03:17:45 +0000 | [diff] [blame] | 409 | template <typename T> |
| 410 | void VisitOMPClauseList(T *Node); |
NAKAMURA Takumi | aa13f94 | 2015-12-09 07:52:46 +0000 | [diff] [blame] | 411 | |
Alexey Bataev | 5ec3eb1 | 2013-07-19 03:13:43 +0000 | [diff] [blame] | 412 | public: |
| 413 | OMPClauseProfiler(StmtProfiler *P) : Profiler(P) { } |
| 414 | #define OPENMP_CLAUSE(Name, Class) \ |
| 415 | void Visit##Class(const Class *C); |
| 416 | #include "clang/Basic/OpenMPKinds.def" |
Alexey Bataev | 3392d76 | 2016-02-16 11:18:12 +0000 | [diff] [blame] | 417 | void VistOMPClauseWithPreInit(const OMPClauseWithPreInit *C); |
Alexey Bataev | 005248a | 2016-02-25 05:25:57 +0000 | [diff] [blame] | 418 | void VistOMPClauseWithPostUpdate(const OMPClauseWithPostUpdate *C); |
Alexey Bataev | 5ec3eb1 | 2013-07-19 03:13:43 +0000 | [diff] [blame] | 419 | }; |
| 420 | |
Alexey Bataev | 3392d76 | 2016-02-16 11:18:12 +0000 | [diff] [blame] | 421 | void OMPClauseProfiler::VistOMPClauseWithPreInit( |
| 422 | const OMPClauseWithPreInit *C) { |
| 423 | if (auto *S = C->getPreInitStmt()) |
| 424 | Profiler->VisitStmt(S); |
| 425 | } |
| 426 | |
Alexey Bataev | 005248a | 2016-02-25 05:25:57 +0000 | [diff] [blame] | 427 | void OMPClauseProfiler::VistOMPClauseWithPostUpdate( |
| 428 | const OMPClauseWithPostUpdate *C) { |
Alexey Bataev | 37e594c | 2016-03-04 07:21:16 +0000 | [diff] [blame] | 429 | VistOMPClauseWithPreInit(C); |
Alexey Bataev | 005248a | 2016-02-25 05:25:57 +0000 | [diff] [blame] | 430 | if (auto *E = C->getPostUpdateExpr()) |
| 431 | Profiler->VisitStmt(E); |
| 432 | } |
| 433 | |
Alexey Bataev | aadd52e | 2014-02-13 05:29:23 +0000 | [diff] [blame] | 434 | void OMPClauseProfiler::VisitOMPIfClause(const OMPIfClause *C) { |
Arpith Chacko Jacob | fe4890a | 2017-01-18 20:40:48 +0000 | [diff] [blame] | 435 | VistOMPClauseWithPreInit(C); |
Alexey Bataev | aadd52e | 2014-02-13 05:29:23 +0000 | [diff] [blame] | 436 | if (C->getCondition()) |
| 437 | Profiler->VisitStmt(C->getCondition()); |
| 438 | } |
| 439 | |
Alexey Bataev | 3778b60 | 2014-07-17 07:32:53 +0000 | [diff] [blame] | 440 | void OMPClauseProfiler::VisitOMPFinalClause(const OMPFinalClause *C) { |
| 441 | if (C->getCondition()) |
| 442 | Profiler->VisitStmt(C->getCondition()); |
| 443 | } |
| 444 | |
Alexey Bataev | 568a833 | 2014-03-06 06:15:19 +0000 | [diff] [blame] | 445 | void OMPClauseProfiler::VisitOMPNumThreadsClause(const OMPNumThreadsClause *C) { |
Arpith Chacko Jacob | 33c849a | 2017-01-25 00:57:16 +0000 | [diff] [blame] | 446 | VistOMPClauseWithPreInit(C); |
Alexey Bataev | 568a833 | 2014-03-06 06:15:19 +0000 | [diff] [blame] | 447 | if (C->getNumThreads()) |
| 448 | Profiler->VisitStmt(C->getNumThreads()); |
| 449 | } |
| 450 | |
Alexey Bataev | 62c87d2 | 2014-03-21 04:51:18 +0000 | [diff] [blame] | 451 | void OMPClauseProfiler::VisitOMPSafelenClause(const OMPSafelenClause *C) { |
| 452 | if (C->getSafelen()) |
| 453 | Profiler->VisitStmt(C->getSafelen()); |
| 454 | } |
| 455 | |
Alexey Bataev | 66b15b5 | 2015-08-21 11:14:16 +0000 | [diff] [blame] | 456 | void OMPClauseProfiler::VisitOMPSimdlenClause(const OMPSimdlenClause *C) { |
| 457 | if (C->getSimdlen()) |
| 458 | Profiler->VisitStmt(C->getSimdlen()); |
| 459 | } |
| 460 | |
Alexander Musman | 8bd31e6 | 2014-05-27 15:12:19 +0000 | [diff] [blame] | 461 | void OMPClauseProfiler::VisitOMPCollapseClause(const OMPCollapseClause *C) { |
| 462 | if (C->getNumForLoops()) |
| 463 | Profiler->VisitStmt(C->getNumForLoops()); |
| 464 | } |
| 465 | |
Alexey Bataev | 5ec3eb1 | 2013-07-19 03:13:43 +0000 | [diff] [blame] | 466 | void OMPClauseProfiler::VisitOMPDefaultClause(const OMPDefaultClause *C) { } |
Alexey Bataev | 756c196 | 2013-09-24 03:17:45 +0000 | [diff] [blame] | 467 | |
Alexey Bataev | bcbadb6 | 2014-05-06 06:04:14 +0000 | [diff] [blame] | 468 | void OMPClauseProfiler::VisitOMPProcBindClause(const OMPProcBindClause *C) { } |
| 469 | |
Kelvin Li | 1408f91 | 2018-09-26 04:28:39 +0000 | [diff] [blame] | 470 | void OMPClauseProfiler::VisitOMPUnifiedAddressClause( |
| 471 | const OMPUnifiedAddressClause *C) {} |
| 472 | |
Patrick Lyster | 4a370b9 | 2018-10-01 13:47:43 +0000 | [diff] [blame] | 473 | void OMPClauseProfiler::VisitOMPUnifiedSharedMemoryClause( |
| 474 | const OMPUnifiedSharedMemoryClause *C) {} |
| 475 | |
Patrick Lyster | 6bdf63b | 2018-10-03 20:07:58 +0000 | [diff] [blame] | 476 | void OMPClauseProfiler::VisitOMPReverseOffloadClause( |
| 477 | const OMPReverseOffloadClause *C) {} |
| 478 | |
Patrick Lyster | 3fe9e39 | 2018-10-11 14:41:10 +0000 | [diff] [blame] | 479 | void OMPClauseProfiler::VisitOMPDynamicAllocatorsClause( |
| 480 | const OMPDynamicAllocatorsClause *C) {} |
| 481 | |
Patrick Lyster | 7a2a27c | 2018-11-02 12:18:11 +0000 | [diff] [blame] | 482 | void OMPClauseProfiler::VisitOMPAtomicDefaultMemOrderClause( |
| 483 | const OMPAtomicDefaultMemOrderClause *C) {} |
| 484 | |
Alexey Bataev | 56dafe8 | 2014-06-20 07:16:17 +0000 | [diff] [blame] | 485 | void OMPClauseProfiler::VisitOMPScheduleClause(const OMPScheduleClause *C) { |
Alexey Bataev | 3392d76 | 2016-02-16 11:18:12 +0000 | [diff] [blame] | 486 | VistOMPClauseWithPreInit(C); |
| 487 | if (auto *S = C->getChunkSize()) |
| 488 | Profiler->VisitStmt(S); |
Alexey Bataev | 56dafe8 | 2014-06-20 07:16:17 +0000 | [diff] [blame] | 489 | } |
| 490 | |
Alexey Bataev | 10e775f | 2015-07-30 11:36:16 +0000 | [diff] [blame] | 491 | void OMPClauseProfiler::VisitOMPOrderedClause(const OMPOrderedClause *C) { |
| 492 | if (auto *Num = C->getNumForLoops()) |
| 493 | Profiler->VisitStmt(Num); |
| 494 | } |
Alexey Bataev | 142e1fc | 2014-06-20 09:44:06 +0000 | [diff] [blame] | 495 | |
Alexey Bataev | 236070f | 2014-06-20 11:19:47 +0000 | [diff] [blame] | 496 | void OMPClauseProfiler::VisitOMPNowaitClause(const OMPNowaitClause *) {} |
| 497 | |
Alexey Bataev | 7aea99a | 2014-07-17 12:19:31 +0000 | [diff] [blame] | 498 | void OMPClauseProfiler::VisitOMPUntiedClause(const OMPUntiedClause *) {} |
| 499 | |
Alexey Bataev | 74ba3a5 | 2014-07-17 12:47:03 +0000 | [diff] [blame] | 500 | void OMPClauseProfiler::VisitOMPMergeableClause(const OMPMergeableClause *) {} |
| 501 | |
Alexey Bataev | f98b00c | 2014-07-23 02:27:21 +0000 | [diff] [blame] | 502 | void OMPClauseProfiler::VisitOMPReadClause(const OMPReadClause *) {} |
| 503 | |
Alexey Bataev | dea4761 | 2014-07-23 07:46:59 +0000 | [diff] [blame] | 504 | void OMPClauseProfiler::VisitOMPWriteClause(const OMPWriteClause *) {} |
| 505 | |
Alexey Bataev | 67a4f22 | 2014-07-23 10:25:33 +0000 | [diff] [blame] | 506 | void OMPClauseProfiler::VisitOMPUpdateClause(const OMPUpdateClause *) {} |
| 507 | |
Alexey Bataev | 459dec0 | 2014-07-24 06:46:57 +0000 | [diff] [blame] | 508 | void OMPClauseProfiler::VisitOMPCaptureClause(const OMPCaptureClause *) {} |
| 509 | |
Alexey Bataev | 82bad8b | 2014-07-24 08:55:34 +0000 | [diff] [blame] | 510 | void OMPClauseProfiler::VisitOMPSeqCstClause(const OMPSeqCstClause *) {} |
| 511 | |
Alexey Bataev | 346265e | 2015-09-25 10:37:12 +0000 | [diff] [blame] | 512 | void OMPClauseProfiler::VisitOMPThreadsClause(const OMPThreadsClause *) {} |
| 513 | |
Alexey Bataev | d14d1e6 | 2015-09-28 06:39:35 +0000 | [diff] [blame] | 514 | void OMPClauseProfiler::VisitOMPSIMDClause(const OMPSIMDClause *) {} |
| 515 | |
Alexey Bataev | b825de1 | 2015-12-07 10:51:44 +0000 | [diff] [blame] | 516 | void OMPClauseProfiler::VisitOMPNogroupClause(const OMPNogroupClause *) {} |
| 517 | |
Alexey Bataev | 756c196 | 2013-09-24 03:17:45 +0000 | [diff] [blame] | 518 | template<typename T> |
| 519 | void OMPClauseProfiler::VisitOMPClauseList(T *Node) { |
Alexey Bataev | 03b340a | 2014-10-21 03:16:40 +0000 | [diff] [blame] | 520 | for (auto *E : Node->varlists()) { |
Richard Trieu | 6a77a1c | 2016-06-10 04:52:09 +0000 | [diff] [blame] | 521 | if (E) |
| 522 | Profiler->VisitStmt(E); |
Alexey Bataev | 03b340a | 2014-10-21 03:16:40 +0000 | [diff] [blame] | 523 | } |
Alexey Bataev | 756c196 | 2013-09-24 03:17:45 +0000 | [diff] [blame] | 524 | } |
Alexey Bataev | 5ec3eb1 | 2013-07-19 03:13:43 +0000 | [diff] [blame] | 525 | |
| 526 | void OMPClauseProfiler::VisitOMPPrivateClause(const OMPPrivateClause *C) { |
Alexey Bataev | 756c196 | 2013-09-24 03:17:45 +0000 | [diff] [blame] | 527 | VisitOMPClauseList(C); |
Alexey Bataev | 03b340a | 2014-10-21 03:16:40 +0000 | [diff] [blame] | 528 | for (auto *E : C->private_copies()) { |
Richard Trieu | 6a77a1c | 2016-06-10 04:52:09 +0000 | [diff] [blame] | 529 | if (E) |
| 530 | Profiler->VisitStmt(E); |
Alexey Bataev | 03b340a | 2014-10-21 03:16:40 +0000 | [diff] [blame] | 531 | } |
Alexey Bataev | 5ec3eb1 | 2013-07-19 03:13:43 +0000 | [diff] [blame] | 532 | } |
Alexey Bataev | 4a5bb77 | 2014-10-08 14:01:46 +0000 | [diff] [blame] | 533 | void |
| 534 | OMPClauseProfiler::VisitOMPFirstprivateClause(const OMPFirstprivateClause *C) { |
Alexey Bataev | d5af8e4 | 2013-10-01 05:32:34 +0000 | [diff] [blame] | 535 | VisitOMPClauseList(C); |
Alexey Bataev | 417089f | 2016-02-17 13:19:37 +0000 | [diff] [blame] | 536 | VistOMPClauseWithPreInit(C); |
Alexey Bataev | 4a5bb77 | 2014-10-08 14:01:46 +0000 | [diff] [blame] | 537 | for (auto *E : C->private_copies()) { |
Richard Trieu | 6a77a1c | 2016-06-10 04:52:09 +0000 | [diff] [blame] | 538 | if (E) |
| 539 | Profiler->VisitStmt(E); |
Alexey Bataev | 4a5bb77 | 2014-10-08 14:01:46 +0000 | [diff] [blame] | 540 | } |
| 541 | for (auto *E : C->inits()) { |
Richard Trieu | 6a77a1c | 2016-06-10 04:52:09 +0000 | [diff] [blame] | 542 | if (E) |
| 543 | Profiler->VisitStmt(E); |
Alexey Bataev | 4a5bb77 | 2014-10-08 14:01:46 +0000 | [diff] [blame] | 544 | } |
Alexey Bataev | d5af8e4 | 2013-10-01 05:32:34 +0000 | [diff] [blame] | 545 | } |
Alexander Musman | 1bb328c | 2014-06-04 13:06:39 +0000 | [diff] [blame] | 546 | void |
| 547 | OMPClauseProfiler::VisitOMPLastprivateClause(const OMPLastprivateClause *C) { |
| 548 | VisitOMPClauseList(C); |
Alexey Bataev | 005248a | 2016-02-25 05:25:57 +0000 | [diff] [blame] | 549 | VistOMPClauseWithPostUpdate(C); |
Alexey Bataev | 38e8953 | 2015-04-16 04:54:05 +0000 | [diff] [blame] | 550 | for (auto *E : C->source_exprs()) { |
Richard Trieu | 6a77a1c | 2016-06-10 04:52:09 +0000 | [diff] [blame] | 551 | if (E) |
| 552 | Profiler->VisitStmt(E); |
Alexey Bataev | 38e8953 | 2015-04-16 04:54:05 +0000 | [diff] [blame] | 553 | } |
| 554 | for (auto *E : C->destination_exprs()) { |
Richard Trieu | 6a77a1c | 2016-06-10 04:52:09 +0000 | [diff] [blame] | 555 | if (E) |
| 556 | Profiler->VisitStmt(E); |
Alexey Bataev | 38e8953 | 2015-04-16 04:54:05 +0000 | [diff] [blame] | 557 | } |
| 558 | for (auto *E : C->assignment_ops()) { |
Richard Trieu | 6a77a1c | 2016-06-10 04:52:09 +0000 | [diff] [blame] | 559 | if (E) |
| 560 | Profiler->VisitStmt(E); |
Alexey Bataev | 38e8953 | 2015-04-16 04:54:05 +0000 | [diff] [blame] | 561 | } |
Alexander Musman | 1bb328c | 2014-06-04 13:06:39 +0000 | [diff] [blame] | 562 | } |
Alexey Bataev | 758e55e | 2013-09-06 18:03:48 +0000 | [diff] [blame] | 563 | void OMPClauseProfiler::VisitOMPSharedClause(const OMPSharedClause *C) { |
Alexey Bataev | 756c196 | 2013-09-24 03:17:45 +0000 | [diff] [blame] | 564 | VisitOMPClauseList(C); |
Alexey Bataev | 758e55e | 2013-09-06 18:03:48 +0000 | [diff] [blame] | 565 | } |
Alexey Bataev | c5e0258 | 2014-06-16 07:08:35 +0000 | [diff] [blame] | 566 | void OMPClauseProfiler::VisitOMPReductionClause( |
| 567 | const OMPReductionClause *C) { |
| 568 | Profiler->VisitNestedNameSpecifier( |
| 569 | C->getQualifierLoc().getNestedNameSpecifier()); |
| 570 | Profiler->VisitName(C->getNameInfo().getName()); |
| 571 | VisitOMPClauseList(C); |
Alexey Bataev | 6120507 | 2016-03-02 04:57:40 +0000 | [diff] [blame] | 572 | VistOMPClauseWithPostUpdate(C); |
Alexey Bataev | f24e7b1 | 2015-10-08 09:10:53 +0000 | [diff] [blame] | 573 | for (auto *E : C->privates()) { |
Richard Trieu | 6a77a1c | 2016-06-10 04:52:09 +0000 | [diff] [blame] | 574 | if (E) |
| 575 | Profiler->VisitStmt(E); |
Alexey Bataev | f24e7b1 | 2015-10-08 09:10:53 +0000 | [diff] [blame] | 576 | } |
Alexey Bataev | 794ba0d | 2015-04-10 10:43:45 +0000 | [diff] [blame] | 577 | for (auto *E : C->lhs_exprs()) { |
Richard Trieu | 6a77a1c | 2016-06-10 04:52:09 +0000 | [diff] [blame] | 578 | if (E) |
| 579 | Profiler->VisitStmt(E); |
Alexey Bataev | 794ba0d | 2015-04-10 10:43:45 +0000 | [diff] [blame] | 580 | } |
| 581 | for (auto *E : C->rhs_exprs()) { |
Richard Trieu | 6a77a1c | 2016-06-10 04:52:09 +0000 | [diff] [blame] | 582 | if (E) |
| 583 | Profiler->VisitStmt(E); |
Alexey Bataev | 794ba0d | 2015-04-10 10:43:45 +0000 | [diff] [blame] | 584 | } |
| 585 | for (auto *E : C->reduction_ops()) { |
Richard Trieu | 6a77a1c | 2016-06-10 04:52:09 +0000 | [diff] [blame] | 586 | if (E) |
| 587 | Profiler->VisitStmt(E); |
Alexey Bataev | 794ba0d | 2015-04-10 10:43:45 +0000 | [diff] [blame] | 588 | } |
Alexey Bataev | c5e0258 | 2014-06-16 07:08:35 +0000 | [diff] [blame] | 589 | } |
Alexey Bataev | 169d96a | 2017-07-18 20:17:46 +0000 | [diff] [blame] | 590 | void OMPClauseProfiler::VisitOMPTaskReductionClause( |
| 591 | const OMPTaskReductionClause *C) { |
| 592 | Profiler->VisitNestedNameSpecifier( |
| 593 | C->getQualifierLoc().getNestedNameSpecifier()); |
| 594 | Profiler->VisitName(C->getNameInfo().getName()); |
| 595 | VisitOMPClauseList(C); |
| 596 | VistOMPClauseWithPostUpdate(C); |
| 597 | for (auto *E : C->privates()) { |
| 598 | if (E) |
| 599 | Profiler->VisitStmt(E); |
| 600 | } |
| 601 | for (auto *E : C->lhs_exprs()) { |
| 602 | if (E) |
| 603 | Profiler->VisitStmt(E); |
| 604 | } |
| 605 | for (auto *E : C->rhs_exprs()) { |
| 606 | if (E) |
| 607 | Profiler->VisitStmt(E); |
| 608 | } |
| 609 | for (auto *E : C->reduction_ops()) { |
| 610 | if (E) |
| 611 | Profiler->VisitStmt(E); |
| 612 | } |
| 613 | } |
Alexey Bataev | fa312f3 | 2017-07-21 18:48:21 +0000 | [diff] [blame] | 614 | void OMPClauseProfiler::VisitOMPInReductionClause( |
| 615 | const OMPInReductionClause *C) { |
| 616 | Profiler->VisitNestedNameSpecifier( |
| 617 | C->getQualifierLoc().getNestedNameSpecifier()); |
| 618 | Profiler->VisitName(C->getNameInfo().getName()); |
| 619 | VisitOMPClauseList(C); |
| 620 | VistOMPClauseWithPostUpdate(C); |
| 621 | for (auto *E : C->privates()) { |
| 622 | if (E) |
| 623 | Profiler->VisitStmt(E); |
| 624 | } |
| 625 | for (auto *E : C->lhs_exprs()) { |
| 626 | if (E) |
| 627 | Profiler->VisitStmt(E); |
| 628 | } |
| 629 | for (auto *E : C->rhs_exprs()) { |
| 630 | if (E) |
| 631 | Profiler->VisitStmt(E); |
| 632 | } |
| 633 | for (auto *E : C->reduction_ops()) { |
| 634 | if (E) |
| 635 | Profiler->VisitStmt(E); |
| 636 | } |
Alexey Bataev | 88202be | 2017-07-27 13:20:36 +0000 | [diff] [blame] | 637 | for (auto *E : C->taskgroup_descriptors()) { |
| 638 | if (E) |
| 639 | Profiler->VisitStmt(E); |
| 640 | } |
Alexey Bataev | fa312f3 | 2017-07-21 18:48:21 +0000 | [diff] [blame] | 641 | } |
Alexander Musman | 8dba664 | 2014-04-22 13:09:42 +0000 | [diff] [blame] | 642 | void OMPClauseProfiler::VisitOMPLinearClause(const OMPLinearClause *C) { |
| 643 | VisitOMPClauseList(C); |
Alexey Bataev | 78849fb | 2016-03-09 09:49:00 +0000 | [diff] [blame] | 644 | VistOMPClauseWithPostUpdate(C); |
Alexey Bataev | bd9fec1 | 2015-08-18 06:47:21 +0000 | [diff] [blame] | 645 | for (auto *E : C->privates()) { |
Richard Trieu | 6a77a1c | 2016-06-10 04:52:09 +0000 | [diff] [blame] | 646 | if (E) |
| 647 | Profiler->VisitStmt(E); |
Alexey Bataev | bd9fec1 | 2015-08-18 06:47:21 +0000 | [diff] [blame] | 648 | } |
Alexander Musman | 3276a27 | 2015-03-21 10:12:56 +0000 | [diff] [blame] | 649 | for (auto *E : C->inits()) { |
Richard Trieu | 6a77a1c | 2016-06-10 04:52:09 +0000 | [diff] [blame] | 650 | if (E) |
| 651 | Profiler->VisitStmt(E); |
Alexander Musman | 3276a27 | 2015-03-21 10:12:56 +0000 | [diff] [blame] | 652 | } |
| 653 | for (auto *E : C->updates()) { |
Richard Trieu | 6a77a1c | 2016-06-10 04:52:09 +0000 | [diff] [blame] | 654 | if (E) |
| 655 | Profiler->VisitStmt(E); |
Alexander Musman | 3276a27 | 2015-03-21 10:12:56 +0000 | [diff] [blame] | 656 | } |
| 657 | for (auto *E : C->finals()) { |
Richard Trieu | 6a77a1c | 2016-06-10 04:52:09 +0000 | [diff] [blame] | 658 | if (E) |
| 659 | Profiler->VisitStmt(E); |
Alexander Musman | 3276a27 | 2015-03-21 10:12:56 +0000 | [diff] [blame] | 660 | } |
Richard Trieu | 6a77a1c | 2016-06-10 04:52:09 +0000 | [diff] [blame] | 661 | if (C->getStep()) |
| 662 | Profiler->VisitStmt(C->getStep()); |
| 663 | if (C->getCalcStep()) |
| 664 | Profiler->VisitStmt(C->getCalcStep()); |
Alexander Musman | 8dba664 | 2014-04-22 13:09:42 +0000 | [diff] [blame] | 665 | } |
Alexander Musman | f0d76e7 | 2014-05-29 14:36:25 +0000 | [diff] [blame] | 666 | void OMPClauseProfiler::VisitOMPAlignedClause(const OMPAlignedClause *C) { |
| 667 | VisitOMPClauseList(C); |
Richard Trieu | 6a77a1c | 2016-06-10 04:52:09 +0000 | [diff] [blame] | 668 | if (C->getAlignment()) |
| 669 | Profiler->VisitStmt(C->getAlignment()); |
Alexander Musman | f0d76e7 | 2014-05-29 14:36:25 +0000 | [diff] [blame] | 670 | } |
Alexey Bataev | d48bcd8 | 2014-03-31 03:36:38 +0000 | [diff] [blame] | 671 | void OMPClauseProfiler::VisitOMPCopyinClause(const OMPCopyinClause *C) { |
| 672 | VisitOMPClauseList(C); |
Alexey Bataev | f56f98c | 2015-04-16 05:39:01 +0000 | [diff] [blame] | 673 | for (auto *E : C->source_exprs()) { |
Richard Trieu | 6a77a1c | 2016-06-10 04:52:09 +0000 | [diff] [blame] | 674 | if (E) |
| 675 | Profiler->VisitStmt(E); |
Alexey Bataev | f56f98c | 2015-04-16 05:39:01 +0000 | [diff] [blame] | 676 | } |
| 677 | for (auto *E : C->destination_exprs()) { |
Richard Trieu | 6a77a1c | 2016-06-10 04:52:09 +0000 | [diff] [blame] | 678 | if (E) |
| 679 | Profiler->VisitStmt(E); |
Alexey Bataev | f56f98c | 2015-04-16 05:39:01 +0000 | [diff] [blame] | 680 | } |
| 681 | for (auto *E : C->assignment_ops()) { |
Richard Trieu | 6a77a1c | 2016-06-10 04:52:09 +0000 | [diff] [blame] | 682 | if (E) |
| 683 | Profiler->VisitStmt(E); |
Alexey Bataev | f56f98c | 2015-04-16 05:39:01 +0000 | [diff] [blame] | 684 | } |
Alexey Bataev | d48bcd8 | 2014-03-31 03:36:38 +0000 | [diff] [blame] | 685 | } |
Alexey Bataev | bae9a79 | 2014-06-27 10:37:06 +0000 | [diff] [blame] | 686 | void |
| 687 | OMPClauseProfiler::VisitOMPCopyprivateClause(const OMPCopyprivateClause *C) { |
| 688 | VisitOMPClauseList(C); |
Alexey Bataev | a63048e | 2015-03-23 06:18:07 +0000 | [diff] [blame] | 689 | for (auto *E : C->source_exprs()) { |
Richard Trieu | 6a77a1c | 2016-06-10 04:52:09 +0000 | [diff] [blame] | 690 | if (E) |
| 691 | Profiler->VisitStmt(E); |
Alexey Bataev | a63048e | 2015-03-23 06:18:07 +0000 | [diff] [blame] | 692 | } |
| 693 | for (auto *E : C->destination_exprs()) { |
Richard Trieu | 6a77a1c | 2016-06-10 04:52:09 +0000 | [diff] [blame] | 694 | if (E) |
| 695 | Profiler->VisitStmt(E); |
Alexey Bataev | a63048e | 2015-03-23 06:18:07 +0000 | [diff] [blame] | 696 | } |
| 697 | for (auto *E : C->assignment_ops()) { |
Richard Trieu | 6a77a1c | 2016-06-10 04:52:09 +0000 | [diff] [blame] | 698 | if (E) |
| 699 | Profiler->VisitStmt(E); |
Alexey Bataev | a63048e | 2015-03-23 06:18:07 +0000 | [diff] [blame] | 700 | } |
Alexey Bataev | bae9a79 | 2014-06-27 10:37:06 +0000 | [diff] [blame] | 701 | } |
Alexey Bataev | 6125da9 | 2014-07-21 11:26:11 +0000 | [diff] [blame] | 702 | void OMPClauseProfiler::VisitOMPFlushClause(const OMPFlushClause *C) { |
| 703 | VisitOMPClauseList(C); |
| 704 | } |
Alexey Bataev | 1c2cfbc | 2015-06-23 14:25:19 +0000 | [diff] [blame] | 705 | void OMPClauseProfiler::VisitOMPDependClause(const OMPDependClause *C) { |
| 706 | VisitOMPClauseList(C); |
| 707 | } |
Michael Wong | e710d54 | 2015-08-07 16:16:36 +0000 | [diff] [blame] | 708 | void OMPClauseProfiler::VisitOMPDeviceClause(const OMPDeviceClause *C) { |
Richard Trieu | 6a77a1c | 2016-06-10 04:52:09 +0000 | [diff] [blame] | 709 | if (C->getDevice()) |
| 710 | Profiler->VisitStmt(C->getDevice()); |
Michael Wong | e710d54 | 2015-08-07 16:16:36 +0000 | [diff] [blame] | 711 | } |
Kelvin Li | 0bff7af | 2015-11-23 05:32:03 +0000 | [diff] [blame] | 712 | void OMPClauseProfiler::VisitOMPMapClause(const OMPMapClause *C) { |
| 713 | VisitOMPClauseList(C); |
| 714 | } |
Kelvin Li | 099bb8c | 2015-11-24 20:50:12 +0000 | [diff] [blame] | 715 | void OMPClauseProfiler::VisitOMPNumTeamsClause(const OMPNumTeamsClause *C) { |
Arpith Chacko Jacob | bc12634 | 2017-01-25 11:28:18 +0000 | [diff] [blame] | 716 | VistOMPClauseWithPreInit(C); |
Richard Trieu | 6a77a1c | 2016-06-10 04:52:09 +0000 | [diff] [blame] | 717 | if (C->getNumTeams()) |
| 718 | Profiler->VisitStmt(C->getNumTeams()); |
Kelvin Li | 099bb8c | 2015-11-24 20:50:12 +0000 | [diff] [blame] | 719 | } |
Kelvin Li | a15fb1a | 2015-11-27 18:47:36 +0000 | [diff] [blame] | 720 | void OMPClauseProfiler::VisitOMPThreadLimitClause( |
| 721 | const OMPThreadLimitClause *C) { |
Arpith Chacko Jacob | 7ecc0b7 | 2017-01-25 11:44:35 +0000 | [diff] [blame] | 722 | VistOMPClauseWithPreInit(C); |
Richard Trieu | 6a77a1c | 2016-06-10 04:52:09 +0000 | [diff] [blame] | 723 | if (C->getThreadLimit()) |
| 724 | Profiler->VisitStmt(C->getThreadLimit()); |
Kelvin Li | a15fb1a | 2015-11-27 18:47:36 +0000 | [diff] [blame] | 725 | } |
Alexey Bataev | a056935 | 2015-12-01 10:17:31 +0000 | [diff] [blame] | 726 | void OMPClauseProfiler::VisitOMPPriorityClause(const OMPPriorityClause *C) { |
Richard Trieu | 6a77a1c | 2016-06-10 04:52:09 +0000 | [diff] [blame] | 727 | if (C->getPriority()) |
| 728 | Profiler->VisitStmt(C->getPriority()); |
Alexey Bataev | a056935 | 2015-12-01 10:17:31 +0000 | [diff] [blame] | 729 | } |
Alexey Bataev | 1fd4aed | 2015-12-07 12:52:51 +0000 | [diff] [blame] | 730 | void OMPClauseProfiler::VisitOMPGrainsizeClause(const OMPGrainsizeClause *C) { |
Richard Trieu | 6a77a1c | 2016-06-10 04:52:09 +0000 | [diff] [blame] | 731 | if (C->getGrainsize()) |
| 732 | Profiler->VisitStmt(C->getGrainsize()); |
Alexey Bataev | 1fd4aed | 2015-12-07 12:52:51 +0000 | [diff] [blame] | 733 | } |
Alexey Bataev | 382967a | 2015-12-08 12:06:20 +0000 | [diff] [blame] | 734 | void OMPClauseProfiler::VisitOMPNumTasksClause(const OMPNumTasksClause *C) { |
Richard Trieu | 6a77a1c | 2016-06-10 04:52:09 +0000 | [diff] [blame] | 735 | if (C->getNumTasks()) |
| 736 | Profiler->VisitStmt(C->getNumTasks()); |
Alexey Bataev | 382967a | 2015-12-08 12:06:20 +0000 | [diff] [blame] | 737 | } |
Alexey Bataev | 28c7541 | 2015-12-15 08:19:24 +0000 | [diff] [blame] | 738 | void OMPClauseProfiler::VisitOMPHintClause(const OMPHintClause *C) { |
Richard Trieu | 6a77a1c | 2016-06-10 04:52:09 +0000 | [diff] [blame] | 739 | if (C->getHint()) |
| 740 | Profiler->VisitStmt(C->getHint()); |
Alexey Bataev | 28c7541 | 2015-12-15 08:19:24 +0000 | [diff] [blame] | 741 | } |
Samuel Antao | 661c090 | 2016-05-26 17:39:58 +0000 | [diff] [blame] | 742 | void OMPClauseProfiler::VisitOMPToClause(const OMPToClause *C) { |
| 743 | VisitOMPClauseList(C); |
| 744 | } |
Samuel Antao | ec172c6 | 2016-05-26 17:49:04 +0000 | [diff] [blame] | 745 | void OMPClauseProfiler::VisitOMPFromClause(const OMPFromClause *C) { |
| 746 | VisitOMPClauseList(C); |
| 747 | } |
Carlo Bertolli | 2404b17 | 2016-07-13 15:37:16 +0000 | [diff] [blame] | 748 | void OMPClauseProfiler::VisitOMPUseDevicePtrClause( |
| 749 | const OMPUseDevicePtrClause *C) { |
| 750 | VisitOMPClauseList(C); |
| 751 | } |
Carlo Bertolli | 70594e9 | 2016-07-13 17:16:49 +0000 | [diff] [blame] | 752 | void OMPClauseProfiler::VisitOMPIsDevicePtrClause( |
| 753 | const OMPIsDevicePtrClause *C) { |
| 754 | VisitOMPClauseList(C); |
| 755 | } |
Alexander Kornienko | ab9db51 | 2015-06-22 23:07:51 +0000 | [diff] [blame] | 756 | } |
Alexey Bataev | 5ec3eb1 | 2013-07-19 03:13:43 +0000 | [diff] [blame] | 757 | |
| 758 | void |
Alexey Bataev | 1b59ab5 | 2014-02-27 08:29:12 +0000 | [diff] [blame] | 759 | StmtProfiler::VisitOMPExecutableDirective(const OMPExecutableDirective *S) { |
Alexey Bataev | 5ec3eb1 | 2013-07-19 03:13:43 +0000 | [diff] [blame] | 760 | VisitStmt(S); |
| 761 | OMPClauseProfiler P(this); |
| 762 | ArrayRef<OMPClause *> Clauses = S->clauses(); |
| 763 | for (ArrayRef<OMPClause *>::iterator I = Clauses.begin(), E = Clauses.end(); |
| 764 | I != E; ++I) |
| 765 | if (*I) |
| 766 | P.Visit(*I); |
| 767 | } |
| 768 | |
Alexander Musman | 3aaab66 | 2014-08-19 11:27:13 +0000 | [diff] [blame] | 769 | void StmtProfiler::VisitOMPLoopDirective(const OMPLoopDirective *S) { |
| 770 | VisitOMPExecutableDirective(S); |
| 771 | } |
| 772 | |
Alexey Bataev | 1b59ab5 | 2014-02-27 08:29:12 +0000 | [diff] [blame] | 773 | void StmtProfiler::VisitOMPParallelDirective(const OMPParallelDirective *S) { |
| 774 | VisitOMPExecutableDirective(S); |
| 775 | } |
| 776 | |
| 777 | void StmtProfiler::VisitOMPSimdDirective(const OMPSimdDirective *S) { |
Alexander Musman | 3aaab66 | 2014-08-19 11:27:13 +0000 | [diff] [blame] | 778 | VisitOMPLoopDirective(S); |
Alexey Bataev | 1b59ab5 | 2014-02-27 08:29:12 +0000 | [diff] [blame] | 779 | } |
| 780 | |
Alexey Bataev | f29276e | 2014-06-18 04:14:57 +0000 | [diff] [blame] | 781 | void StmtProfiler::VisitOMPForDirective(const OMPForDirective *S) { |
Alexander Musman | 3aaab66 | 2014-08-19 11:27:13 +0000 | [diff] [blame] | 782 | VisitOMPLoopDirective(S); |
Alexey Bataev | f29276e | 2014-06-18 04:14:57 +0000 | [diff] [blame] | 783 | } |
| 784 | |
Alexander Musman | f82886e | 2014-09-18 05:12:34 +0000 | [diff] [blame] | 785 | void StmtProfiler::VisitOMPForSimdDirective(const OMPForSimdDirective *S) { |
| 786 | VisitOMPLoopDirective(S); |
| 787 | } |
| 788 | |
Alexey Bataev | d3f8dd2 | 2014-06-25 11:44:49 +0000 | [diff] [blame] | 789 | void StmtProfiler::VisitOMPSectionsDirective(const OMPSectionsDirective *S) { |
| 790 | VisitOMPExecutableDirective(S); |
| 791 | } |
| 792 | |
Alexey Bataev | 1e0498a | 2014-06-26 08:21:58 +0000 | [diff] [blame] | 793 | void StmtProfiler::VisitOMPSectionDirective(const OMPSectionDirective *S) { |
| 794 | VisitOMPExecutableDirective(S); |
| 795 | } |
| 796 | |
Alexey Bataev | d1e40fb | 2014-06-26 12:05:45 +0000 | [diff] [blame] | 797 | void StmtProfiler::VisitOMPSingleDirective(const OMPSingleDirective *S) { |
| 798 | VisitOMPExecutableDirective(S); |
| 799 | } |
| 800 | |
Alexander Musman | 80c2289 | 2014-07-17 08:54:58 +0000 | [diff] [blame] | 801 | void StmtProfiler::VisitOMPMasterDirective(const OMPMasterDirective *S) { |
| 802 | VisitOMPExecutableDirective(S); |
| 803 | } |
| 804 | |
Alexander Musman | d9ed09f | 2014-07-21 09:42:05 +0000 | [diff] [blame] | 805 | void StmtProfiler::VisitOMPCriticalDirective(const OMPCriticalDirective *S) { |
| 806 | VisitOMPExecutableDirective(S); |
| 807 | VisitName(S->getDirectiveName().getName()); |
| 808 | } |
| 809 | |
Alexey Bataev | 4acb859 | 2014-07-07 13:01:15 +0000 | [diff] [blame] | 810 | void |
| 811 | StmtProfiler::VisitOMPParallelForDirective(const OMPParallelForDirective *S) { |
Alexander Musman | 3aaab66 | 2014-08-19 11:27:13 +0000 | [diff] [blame] | 812 | VisitOMPLoopDirective(S); |
Alexey Bataev | 4acb859 | 2014-07-07 13:01:15 +0000 | [diff] [blame] | 813 | } |
| 814 | |
Alexander Musman | e4e893b | 2014-09-23 09:33:00 +0000 | [diff] [blame] | 815 | void StmtProfiler::VisitOMPParallelForSimdDirective( |
| 816 | const OMPParallelForSimdDirective *S) { |
| 817 | VisitOMPLoopDirective(S); |
| 818 | } |
| 819 | |
Alexey Bataev | 84d0b3e | 2014-07-08 08:12:03 +0000 | [diff] [blame] | 820 | void StmtProfiler::VisitOMPParallelSectionsDirective( |
| 821 | const OMPParallelSectionsDirective *S) { |
| 822 | VisitOMPExecutableDirective(S); |
| 823 | } |
| 824 | |
Alexey Bataev | 9c2e8ee | 2014-07-11 11:25:16 +0000 | [diff] [blame] | 825 | void StmtProfiler::VisitOMPTaskDirective(const OMPTaskDirective *S) { |
| 826 | VisitOMPExecutableDirective(S); |
| 827 | } |
| 828 | |
Alexey Bataev | 68446b7 | 2014-07-18 07:47:19 +0000 | [diff] [blame] | 829 | void StmtProfiler::VisitOMPTaskyieldDirective(const OMPTaskyieldDirective *S) { |
| 830 | VisitOMPExecutableDirective(S); |
| 831 | } |
| 832 | |
Alexey Bataev | 4d1dfea | 2014-07-18 09:11:51 +0000 | [diff] [blame] | 833 | void StmtProfiler::VisitOMPBarrierDirective(const OMPBarrierDirective *S) { |
| 834 | VisitOMPExecutableDirective(S); |
| 835 | } |
| 836 | |
Alexey Bataev | 2df347a | 2014-07-18 10:17:07 +0000 | [diff] [blame] | 837 | void StmtProfiler::VisitOMPTaskwaitDirective(const OMPTaskwaitDirective *S) { |
| 838 | VisitOMPExecutableDirective(S); |
| 839 | } |
| 840 | |
Alexey Bataev | c30dd2d | 2015-06-18 12:14:09 +0000 | [diff] [blame] | 841 | void StmtProfiler::VisitOMPTaskgroupDirective(const OMPTaskgroupDirective *S) { |
| 842 | VisitOMPExecutableDirective(S); |
Alexey Bataev | 3b1b895 | 2017-07-25 15:53:26 +0000 | [diff] [blame] | 843 | if (const Expr *E = S->getReductionRef()) |
| 844 | VisitStmt(E); |
Alexey Bataev | c30dd2d | 2015-06-18 12:14:09 +0000 | [diff] [blame] | 845 | } |
| 846 | |
Alexey Bataev | 6125da9 | 2014-07-21 11:26:11 +0000 | [diff] [blame] | 847 | void StmtProfiler::VisitOMPFlushDirective(const OMPFlushDirective *S) { |
| 848 | VisitOMPExecutableDirective(S); |
| 849 | } |
| 850 | |
Alexey Bataev | 9fb6e64 | 2014-07-22 06:45:04 +0000 | [diff] [blame] | 851 | void StmtProfiler::VisitOMPOrderedDirective(const OMPOrderedDirective *S) { |
| 852 | VisitOMPExecutableDirective(S); |
| 853 | } |
| 854 | |
Alexey Bataev | 0162e45 | 2014-07-22 10:10:35 +0000 | [diff] [blame] | 855 | void StmtProfiler::VisitOMPAtomicDirective(const OMPAtomicDirective *S) { |
| 856 | VisitOMPExecutableDirective(S); |
| 857 | } |
| 858 | |
Alexey Bataev | 0bd520b | 2014-09-19 08:19:49 +0000 | [diff] [blame] | 859 | void StmtProfiler::VisitOMPTargetDirective(const OMPTargetDirective *S) { |
| 860 | VisitOMPExecutableDirective(S); |
| 861 | } |
| 862 | |
Michael Wong | 65f367f | 2015-07-21 13:44:28 +0000 | [diff] [blame] | 863 | void StmtProfiler::VisitOMPTargetDataDirective(const OMPTargetDataDirective *S) { |
| 864 | VisitOMPExecutableDirective(S); |
| 865 | } |
| 866 | |
Samuel Antao | df67fc4 | 2016-01-19 19:15:56 +0000 | [diff] [blame] | 867 | void StmtProfiler::VisitOMPTargetEnterDataDirective( |
| 868 | const OMPTargetEnterDataDirective *S) { |
| 869 | VisitOMPExecutableDirective(S); |
| 870 | } |
| 871 | |
Samuel Antao | 7259076 | 2016-01-19 20:04:50 +0000 | [diff] [blame] | 872 | void StmtProfiler::VisitOMPTargetExitDataDirective( |
| 873 | const OMPTargetExitDataDirective *S) { |
| 874 | VisitOMPExecutableDirective(S); |
| 875 | } |
| 876 | |
Arpith Chacko Jacob | e955b3d | 2016-01-26 18:48:41 +0000 | [diff] [blame] | 877 | void StmtProfiler::VisitOMPTargetParallelDirective( |
| 878 | const OMPTargetParallelDirective *S) { |
| 879 | VisitOMPExecutableDirective(S); |
| 880 | } |
| 881 | |
Arpith Chacko Jacob | 05bebb5 | 2016-02-03 15:46:42 +0000 | [diff] [blame] | 882 | void StmtProfiler::VisitOMPTargetParallelForDirective( |
| 883 | const OMPTargetParallelForDirective *S) { |
| 884 | VisitOMPExecutableDirective(S); |
| 885 | } |
| 886 | |
Alexey Bataev | 13314bf | 2014-10-09 04:18:56 +0000 | [diff] [blame] | 887 | void StmtProfiler::VisitOMPTeamsDirective(const OMPTeamsDirective *S) { |
| 888 | VisitOMPExecutableDirective(S); |
| 889 | } |
| 890 | |
Alexey Bataev | 6d4ed05 | 2015-07-01 06:57:41 +0000 | [diff] [blame] | 891 | void StmtProfiler::VisitOMPCancellationPointDirective( |
| 892 | const OMPCancellationPointDirective *S) { |
| 893 | VisitOMPExecutableDirective(S); |
| 894 | } |
| 895 | |
Alexey Bataev | 8090987 | 2015-07-02 11:25:17 +0000 | [diff] [blame] | 896 | void StmtProfiler::VisitOMPCancelDirective(const OMPCancelDirective *S) { |
| 897 | VisitOMPExecutableDirective(S); |
| 898 | } |
| 899 | |
Alexey Bataev | 49f6e78 | 2015-12-01 04:18:41 +0000 | [diff] [blame] | 900 | void StmtProfiler::VisitOMPTaskLoopDirective(const OMPTaskLoopDirective *S) { |
| 901 | VisitOMPLoopDirective(S); |
| 902 | } |
| 903 | |
Alexey Bataev | 0a6ed84 | 2015-12-03 09:40:15 +0000 | [diff] [blame] | 904 | void StmtProfiler::VisitOMPTaskLoopSimdDirective( |
| 905 | const OMPTaskLoopSimdDirective *S) { |
| 906 | VisitOMPLoopDirective(S); |
| 907 | } |
| 908 | |
Carlo Bertolli | 6200a3d | 2015-12-14 14:51:25 +0000 | [diff] [blame] | 909 | void StmtProfiler::VisitOMPDistributeDirective( |
| 910 | const OMPDistributeDirective *S) { |
| 911 | VisitOMPLoopDirective(S); |
| 912 | } |
| 913 | |
Carlo Bertolli | b4adf55 | 2016-01-15 18:50:31 +0000 | [diff] [blame] | 914 | void OMPClauseProfiler::VisitOMPDistScheduleClause( |
| 915 | const OMPDistScheduleClause *C) { |
Alexey Bataev | 3392d76 | 2016-02-16 11:18:12 +0000 | [diff] [blame] | 916 | VistOMPClauseWithPreInit(C); |
| 917 | if (auto *S = C->getChunkSize()) |
| 918 | Profiler->VisitStmt(S); |
Carlo Bertolli | b4adf55 | 2016-01-15 18:50:31 +0000 | [diff] [blame] | 919 | } |
| 920 | |
Arpith Chacko Jacob | 3cf8904 | 2016-01-26 16:37:23 +0000 | [diff] [blame] | 921 | void OMPClauseProfiler::VisitOMPDefaultmapClause(const OMPDefaultmapClause *) {} |
| 922 | |
Samuel Antao | 686c70c | 2016-05-26 17:30:50 +0000 | [diff] [blame] | 923 | void StmtProfiler::VisitOMPTargetUpdateDirective( |
| 924 | const OMPTargetUpdateDirective *S) { |
| 925 | VisitOMPExecutableDirective(S); |
| 926 | } |
| 927 | |
Carlo Bertolli | 9925f15 | 2016-06-27 14:55:37 +0000 | [diff] [blame] | 928 | void StmtProfiler::VisitOMPDistributeParallelForDirective( |
| 929 | const OMPDistributeParallelForDirective *S) { |
| 930 | VisitOMPLoopDirective(S); |
| 931 | } |
| 932 | |
Kelvin Li | 4a39add | 2016-07-05 05:00:15 +0000 | [diff] [blame] | 933 | void StmtProfiler::VisitOMPDistributeParallelForSimdDirective( |
| 934 | const OMPDistributeParallelForSimdDirective *S) { |
| 935 | VisitOMPLoopDirective(S); |
| 936 | } |
| 937 | |
Kelvin Li | 787f3fc | 2016-07-06 04:45:38 +0000 | [diff] [blame] | 938 | void StmtProfiler::VisitOMPDistributeSimdDirective( |
| 939 | const OMPDistributeSimdDirective *S) { |
| 940 | VisitOMPLoopDirective(S); |
| 941 | } |
| 942 | |
Kelvin Li | a579b91 | 2016-07-14 02:54:56 +0000 | [diff] [blame] | 943 | void StmtProfiler::VisitOMPTargetParallelForSimdDirective( |
| 944 | const OMPTargetParallelForSimdDirective *S) { |
| 945 | VisitOMPLoopDirective(S); |
| 946 | } |
| 947 | |
Kelvin Li | 986330c | 2016-07-20 22:57:10 +0000 | [diff] [blame] | 948 | void StmtProfiler::VisitOMPTargetSimdDirective( |
| 949 | const OMPTargetSimdDirective *S) { |
| 950 | VisitOMPLoopDirective(S); |
| 951 | } |
| 952 | |
Kelvin Li | 0253287 | 2016-08-05 14:37:37 +0000 | [diff] [blame] | 953 | void StmtProfiler::VisitOMPTeamsDistributeDirective( |
| 954 | const OMPTeamsDistributeDirective *S) { |
| 955 | VisitOMPLoopDirective(S); |
| 956 | } |
| 957 | |
Kelvin Li | 4e325f7 | 2016-10-25 12:50:55 +0000 | [diff] [blame] | 958 | void StmtProfiler::VisitOMPTeamsDistributeSimdDirective( |
| 959 | const OMPTeamsDistributeSimdDirective *S) { |
| 960 | VisitOMPLoopDirective(S); |
| 961 | } |
| 962 | |
Kelvin Li | 579e41c | 2016-11-30 23:51:03 +0000 | [diff] [blame] | 963 | void StmtProfiler::VisitOMPTeamsDistributeParallelForSimdDirective( |
| 964 | const OMPTeamsDistributeParallelForSimdDirective *S) { |
| 965 | VisitOMPLoopDirective(S); |
| 966 | } |
| 967 | |
Kelvin Li | 7ade93f | 2016-12-09 03:24:30 +0000 | [diff] [blame] | 968 | void StmtProfiler::VisitOMPTeamsDistributeParallelForDirective( |
| 969 | const OMPTeamsDistributeParallelForDirective *S) { |
| 970 | VisitOMPLoopDirective(S); |
| 971 | } |
| 972 | |
Kelvin Li | bf594a5 | 2016-12-17 05:48:59 +0000 | [diff] [blame] | 973 | void StmtProfiler::VisitOMPTargetTeamsDirective( |
| 974 | const OMPTargetTeamsDirective *S) { |
| 975 | VisitOMPExecutableDirective(S); |
| 976 | } |
| 977 | |
Kelvin Li | 83c451e | 2016-12-25 04:52:54 +0000 | [diff] [blame] | 978 | void StmtProfiler::VisitOMPTargetTeamsDistributeDirective( |
| 979 | const OMPTargetTeamsDistributeDirective *S) { |
| 980 | VisitOMPLoopDirective(S); |
| 981 | } |
| 982 | |
Kelvin Li | 80e8f56 | 2016-12-29 22:16:30 +0000 | [diff] [blame] | 983 | void StmtProfiler::VisitOMPTargetTeamsDistributeParallelForDirective( |
| 984 | const OMPTargetTeamsDistributeParallelForDirective *S) { |
| 985 | VisitOMPLoopDirective(S); |
| 986 | } |
| 987 | |
Kelvin Li | 1851df5 | 2017-01-03 05:23:48 +0000 | [diff] [blame] | 988 | void StmtProfiler::VisitOMPTargetTeamsDistributeParallelForSimdDirective( |
| 989 | const OMPTargetTeamsDistributeParallelForSimdDirective *S) { |
| 990 | VisitOMPLoopDirective(S); |
| 991 | } |
| 992 | |
Kelvin Li | da68118 | 2017-01-10 18:08:18 +0000 | [diff] [blame] | 993 | void StmtProfiler::VisitOMPTargetTeamsDistributeSimdDirective( |
| 994 | const OMPTargetTeamsDistributeSimdDirective *S) { |
| 995 | VisitOMPLoopDirective(S); |
| 996 | } |
| 997 | |
Chandler Carruth | 631abd9 | 2011-06-16 06:47:06 +0000 | [diff] [blame] | 998 | void StmtProfiler::VisitExpr(const Expr *S) { |
Douglas Gregor | 5c193b9 | 2009-07-28 00:33:38 +0000 | [diff] [blame] | 999 | VisitStmt(S); |
| 1000 | } |
| 1001 | |
Bill Wendling | 7c44da2 | 2018-10-31 03:48:47 +0000 | [diff] [blame] | 1002 | void StmtProfiler::VisitConstantExpr(const ConstantExpr *S) { |
| 1003 | VisitExpr(S); |
| 1004 | } |
| 1005 | |
Chandler Carruth | 631abd9 | 2011-06-16 06:47:06 +0000 | [diff] [blame] | 1006 | void StmtProfiler::VisitDeclRefExpr(const DeclRefExpr *S) { |
Douglas Gregor | 5c193b9 | 2009-07-28 00:33:38 +0000 | [diff] [blame] | 1007 | VisitExpr(S); |
Douglas Gregor | f5b160f | 2010-07-13 08:37:11 +0000 | [diff] [blame] | 1008 | if (!Canonical) |
| 1009 | VisitNestedNameSpecifier(S->getQualifier()); |
Douglas Gregor | 5c193b9 | 2009-07-28 00:33:38 +0000 | [diff] [blame] | 1010 | VisitDecl(S->getDecl()); |
Richard Trieu | 4d06bef | 2018-02-13 19:53:40 +0000 | [diff] [blame] | 1011 | if (!Canonical) { |
| 1012 | ID.AddBoolean(S->hasExplicitTemplateArgs()); |
| 1013 | if (S->hasExplicitTemplateArgs()) |
| 1014 | VisitTemplateArguments(S->getTemplateArgs(), S->getNumTemplateArgs()); |
| 1015 | } |
Douglas Gregor | 5c193b9 | 2009-07-28 00:33:38 +0000 | [diff] [blame] | 1016 | } |
| 1017 | |
Chandler Carruth | 631abd9 | 2011-06-16 06:47:06 +0000 | [diff] [blame] | 1018 | void StmtProfiler::VisitPredefinedExpr(const PredefinedExpr *S) { |
Douglas Gregor | 5c193b9 | 2009-07-28 00:33:38 +0000 | [diff] [blame] | 1019 | VisitExpr(S); |
Bruno Ricci | 17ff026 | 2018-10-27 19:21:19 +0000 | [diff] [blame] | 1020 | ID.AddInteger(S->getIdentKind()); |
Douglas Gregor | 5c193b9 | 2009-07-28 00:33:38 +0000 | [diff] [blame] | 1021 | } |
| 1022 | |
Chandler Carruth | 631abd9 | 2011-06-16 06:47:06 +0000 | [diff] [blame] | 1023 | void StmtProfiler::VisitIntegerLiteral(const IntegerLiteral *S) { |
Douglas Gregor | 5c193b9 | 2009-07-28 00:33:38 +0000 | [diff] [blame] | 1024 | VisitExpr(S); |
| 1025 | S->getValue().Profile(ID); |
Richard Smith | e9f130c | 2014-11-20 03:37:32 +0000 | [diff] [blame] | 1026 | ID.AddInteger(S->getType()->castAs<BuiltinType>()->getKind()); |
Douglas Gregor | 5c193b9 | 2009-07-28 00:33:38 +0000 | [diff] [blame] | 1027 | } |
| 1028 | |
Leonard Chan | db01c3a | 2018-06-20 17:19:40 +0000 | [diff] [blame] | 1029 | void StmtProfiler::VisitFixedPointLiteral(const FixedPointLiteral *S) { |
| 1030 | VisitExpr(S); |
| 1031 | S->getValue().Profile(ID); |
| 1032 | ID.AddInteger(S->getType()->castAs<BuiltinType>()->getKind()); |
| 1033 | } |
| 1034 | |
Chandler Carruth | 631abd9 | 2011-06-16 06:47:06 +0000 | [diff] [blame] | 1035 | void StmtProfiler::VisitCharacterLiteral(const CharacterLiteral *S) { |
Douglas Gregor | 5c193b9 | 2009-07-28 00:33:38 +0000 | [diff] [blame] | 1036 | VisitExpr(S); |
Douglas Gregor | fb65e59 | 2011-07-27 05:40:30 +0000 | [diff] [blame] | 1037 | ID.AddInteger(S->getKind()); |
Douglas Gregor | 5c193b9 | 2009-07-28 00:33:38 +0000 | [diff] [blame] | 1038 | ID.AddInteger(S->getValue()); |
| 1039 | } |
| 1040 | |
Chandler Carruth | 631abd9 | 2011-06-16 06:47:06 +0000 | [diff] [blame] | 1041 | void StmtProfiler::VisitFloatingLiteral(const FloatingLiteral *S) { |
Douglas Gregor | 5c193b9 | 2009-07-28 00:33:38 +0000 | [diff] [blame] | 1042 | VisitExpr(S); |
| 1043 | S->getValue().Profile(ID); |
| 1044 | ID.AddBoolean(S->isExact()); |
Richard Smith | e9f130c | 2014-11-20 03:37:32 +0000 | [diff] [blame] | 1045 | ID.AddInteger(S->getType()->castAs<BuiltinType>()->getKind()); |
Douglas Gregor | 5c193b9 | 2009-07-28 00:33:38 +0000 | [diff] [blame] | 1046 | } |
| 1047 | |
Chandler Carruth | 631abd9 | 2011-06-16 06:47:06 +0000 | [diff] [blame] | 1048 | void StmtProfiler::VisitImaginaryLiteral(const ImaginaryLiteral *S) { |
Douglas Gregor | 5c193b9 | 2009-07-28 00:33:38 +0000 | [diff] [blame] | 1049 | VisitExpr(S); |
| 1050 | } |
| 1051 | |
Chandler Carruth | 631abd9 | 2011-06-16 06:47:06 +0000 | [diff] [blame] | 1052 | void StmtProfiler::VisitStringLiteral(const StringLiteral *S) { |
Douglas Gregor | 5c193b9 | 2009-07-28 00:33:38 +0000 | [diff] [blame] | 1053 | VisitExpr(S); |
Douglas Gregor | 9d0eb8f | 2011-11-02 17:26:05 +0000 | [diff] [blame] | 1054 | ID.AddString(S->getBytes()); |
Douglas Gregor | fb65e59 | 2011-07-27 05:40:30 +0000 | [diff] [blame] | 1055 | ID.AddInteger(S->getKind()); |
Douglas Gregor | 5c193b9 | 2009-07-28 00:33:38 +0000 | [diff] [blame] | 1056 | } |
| 1057 | |
Chandler Carruth | 631abd9 | 2011-06-16 06:47:06 +0000 | [diff] [blame] | 1058 | void StmtProfiler::VisitParenExpr(const ParenExpr *S) { |
Douglas Gregor | 5c193b9 | 2009-07-28 00:33:38 +0000 | [diff] [blame] | 1059 | VisitExpr(S); |
| 1060 | } |
| 1061 | |
Chandler Carruth | 631abd9 | 2011-06-16 06:47:06 +0000 | [diff] [blame] | 1062 | void StmtProfiler::VisitParenListExpr(const ParenListExpr *S) { |
Nate Begeman | 5ec4b31 | 2009-08-10 23:49:36 +0000 | [diff] [blame] | 1063 | VisitExpr(S); |
| 1064 | } |
| 1065 | |
Chandler Carruth | 631abd9 | 2011-06-16 06:47:06 +0000 | [diff] [blame] | 1066 | void StmtProfiler::VisitUnaryOperator(const UnaryOperator *S) { |
Douglas Gregor | 5c193b9 | 2009-07-28 00:33:38 +0000 | [diff] [blame] | 1067 | VisitExpr(S); |
| 1068 | ID.AddInteger(S->getOpcode()); |
| 1069 | } |
| 1070 | |
Chandler Carruth | 631abd9 | 2011-06-16 06:47:06 +0000 | [diff] [blame] | 1071 | void StmtProfiler::VisitOffsetOfExpr(const OffsetOfExpr *S) { |
Douglas Gregor | 882211c | 2010-04-28 22:16:22 +0000 | [diff] [blame] | 1072 | VisitType(S->getTypeSourceInfo()->getType()); |
| 1073 | unsigned n = S->getNumComponents(); |
| 1074 | for (unsigned i = 0; i < n; ++i) { |
James Y Knight | 7281c35 | 2015-12-29 22:31:18 +0000 | [diff] [blame] | 1075 | const OffsetOfNode &ON = S->getComponent(i); |
Douglas Gregor | 882211c | 2010-04-28 22:16:22 +0000 | [diff] [blame] | 1076 | ID.AddInteger(ON.getKind()); |
| 1077 | switch (ON.getKind()) { |
James Y Knight | 7281c35 | 2015-12-29 22:31:18 +0000 | [diff] [blame] | 1078 | case OffsetOfNode::Array: |
Douglas Gregor | 882211c | 2010-04-28 22:16:22 +0000 | [diff] [blame] | 1079 | // Expressions handled below. |
| 1080 | break; |
| 1081 | |
James Y Knight | 7281c35 | 2015-12-29 22:31:18 +0000 | [diff] [blame] | 1082 | case OffsetOfNode::Field: |
Douglas Gregor | 882211c | 2010-04-28 22:16:22 +0000 | [diff] [blame] | 1083 | VisitDecl(ON.getField()); |
| 1084 | break; |
| 1085 | |
James Y Knight | 7281c35 | 2015-12-29 22:31:18 +0000 | [diff] [blame] | 1086 | case OffsetOfNode::Identifier: |
Richard Trieu | 639d7b6 | 2017-02-22 22:22:42 +0000 | [diff] [blame] | 1087 | VisitIdentifierInfo(ON.getFieldName()); |
Douglas Gregor | 882211c | 2010-04-28 22:16:22 +0000 | [diff] [blame] | 1088 | break; |
James Y Knight | 7281c35 | 2015-12-29 22:31:18 +0000 | [diff] [blame] | 1089 | |
| 1090 | case OffsetOfNode::Base: |
Douglas Gregor | d170206 | 2010-04-29 00:18:15 +0000 | [diff] [blame] | 1091 | // These nodes are implicit, and therefore don't need profiling. |
| 1092 | break; |
Douglas Gregor | 882211c | 2010-04-28 22:16:22 +0000 | [diff] [blame] | 1093 | } |
| 1094 | } |
Richard Trieu | 639d7b6 | 2017-02-22 22:22:42 +0000 | [diff] [blame] | 1095 | |
Douglas Gregor | 882211c | 2010-04-28 22:16:22 +0000 | [diff] [blame] | 1096 | VisitExpr(S); |
| 1097 | } |
| 1098 | |
Chandler Carruth | 631abd9 | 2011-06-16 06:47:06 +0000 | [diff] [blame] | 1099 | void |
| 1100 | StmtProfiler::VisitUnaryExprOrTypeTraitExpr(const UnaryExprOrTypeTraitExpr *S) { |
Douglas Gregor | 5c193b9 | 2009-07-28 00:33:38 +0000 | [diff] [blame] | 1101 | VisitExpr(S); |
Peter Collingbourne | e190dee | 2011-03-11 19:24:49 +0000 | [diff] [blame] | 1102 | ID.AddInteger(S->getKind()); |
Douglas Gregor | 5c193b9 | 2009-07-28 00:33:38 +0000 | [diff] [blame] | 1103 | if (S->isArgumentType()) |
| 1104 | VisitType(S->getArgumentType()); |
| 1105 | } |
| 1106 | |
Chandler Carruth | 631abd9 | 2011-06-16 06:47:06 +0000 | [diff] [blame] | 1107 | void StmtProfiler::VisitArraySubscriptExpr(const ArraySubscriptExpr *S) { |
Douglas Gregor | 5c193b9 | 2009-07-28 00:33:38 +0000 | [diff] [blame] | 1108 | VisitExpr(S); |
| 1109 | } |
| 1110 | |
Alexey Bataev | 1a3320e | 2015-08-25 14:24:04 +0000 | [diff] [blame] | 1111 | void StmtProfiler::VisitOMPArraySectionExpr(const OMPArraySectionExpr *S) { |
| 1112 | VisitExpr(S); |
| 1113 | } |
| 1114 | |
Chandler Carruth | 631abd9 | 2011-06-16 06:47:06 +0000 | [diff] [blame] | 1115 | void StmtProfiler::VisitCallExpr(const CallExpr *S) { |
Douglas Gregor | 5c193b9 | 2009-07-28 00:33:38 +0000 | [diff] [blame] | 1116 | VisitExpr(S); |
| 1117 | } |
| 1118 | |
Chandler Carruth | 631abd9 | 2011-06-16 06:47:06 +0000 | [diff] [blame] | 1119 | void StmtProfiler::VisitMemberExpr(const MemberExpr *S) { |
Douglas Gregor | 5c193b9 | 2009-07-28 00:33:38 +0000 | [diff] [blame] | 1120 | VisitExpr(S); |
| 1121 | VisitDecl(S->getMemberDecl()); |
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 | ID.AddBoolean(S->isArrow()); |
| 1125 | } |
| 1126 | |
Chandler Carruth | 631abd9 | 2011-06-16 06:47:06 +0000 | [diff] [blame] | 1127 | void StmtProfiler::VisitCompoundLiteralExpr(const CompoundLiteralExpr *S) { |
Douglas Gregor | 5c193b9 | 2009-07-28 00:33:38 +0000 | [diff] [blame] | 1128 | VisitExpr(S); |
| 1129 | ID.AddBoolean(S->isFileScope()); |
| 1130 | } |
| 1131 | |
Chandler Carruth | 631abd9 | 2011-06-16 06:47:06 +0000 | [diff] [blame] | 1132 | void StmtProfiler::VisitCastExpr(const CastExpr *S) { |
Douglas Gregor | 5c193b9 | 2009-07-28 00:33:38 +0000 | [diff] [blame] | 1133 | VisitExpr(S); |
| 1134 | } |
| 1135 | |
Chandler Carruth | 631abd9 | 2011-06-16 06:47:06 +0000 | [diff] [blame] | 1136 | void StmtProfiler::VisitImplicitCastExpr(const ImplicitCastExpr *S) { |
Douglas Gregor | 5c193b9 | 2009-07-28 00:33:38 +0000 | [diff] [blame] | 1137 | VisitCastExpr(S); |
John McCall | 2536c6d | 2010-08-25 10:28:54 +0000 | [diff] [blame] | 1138 | ID.AddInteger(S->getValueKind()); |
Douglas Gregor | 5c193b9 | 2009-07-28 00:33:38 +0000 | [diff] [blame] | 1139 | } |
| 1140 | |
Chandler Carruth | 631abd9 | 2011-06-16 06:47:06 +0000 | [diff] [blame] | 1141 | void StmtProfiler::VisitExplicitCastExpr(const ExplicitCastExpr *S) { |
Douglas Gregor | 5c193b9 | 2009-07-28 00:33:38 +0000 | [diff] [blame] | 1142 | VisitCastExpr(S); |
| 1143 | VisitType(S->getTypeAsWritten()); |
| 1144 | } |
| 1145 | |
Chandler Carruth | 631abd9 | 2011-06-16 06:47:06 +0000 | [diff] [blame] | 1146 | void StmtProfiler::VisitCStyleCastExpr(const CStyleCastExpr *S) { |
Douglas Gregor | 5c193b9 | 2009-07-28 00:33:38 +0000 | [diff] [blame] | 1147 | VisitExplicitCastExpr(S); |
| 1148 | } |
| 1149 | |
Chandler Carruth | 631abd9 | 2011-06-16 06:47:06 +0000 | [diff] [blame] | 1150 | void StmtProfiler::VisitBinaryOperator(const BinaryOperator *S) { |
Douglas Gregor | 5c193b9 | 2009-07-28 00:33:38 +0000 | [diff] [blame] | 1151 | VisitExpr(S); |
| 1152 | ID.AddInteger(S->getOpcode()); |
| 1153 | } |
| 1154 | |
Chandler Carruth | 631abd9 | 2011-06-16 06:47:06 +0000 | [diff] [blame] | 1155 | void |
| 1156 | StmtProfiler::VisitCompoundAssignOperator(const CompoundAssignOperator *S) { |
Douglas Gregor | 5c193b9 | 2009-07-28 00:33:38 +0000 | [diff] [blame] | 1157 | VisitBinaryOperator(S); |
| 1158 | } |
| 1159 | |
Chandler Carruth | 631abd9 | 2011-06-16 06:47:06 +0000 | [diff] [blame] | 1160 | void StmtProfiler::VisitConditionalOperator(const ConditionalOperator *S) { |
Douglas Gregor | 5c193b9 | 2009-07-28 00:33:38 +0000 | [diff] [blame] | 1161 | VisitExpr(S); |
| 1162 | } |
| 1163 | |
Chandler Carruth | 631abd9 | 2011-06-16 06:47:06 +0000 | [diff] [blame] | 1164 | void StmtProfiler::VisitBinaryConditionalOperator( |
Chandler Carruth | cf5f43c | 2011-06-21 23:26:32 +0000 | [diff] [blame] | 1165 | const BinaryConditionalOperator *S) { |
John McCall | c07a0c7 | 2011-02-17 10:25:35 +0000 | [diff] [blame] | 1166 | VisitExpr(S); |
| 1167 | } |
| 1168 | |
Chandler Carruth | 631abd9 | 2011-06-16 06:47:06 +0000 | [diff] [blame] | 1169 | void StmtProfiler::VisitAddrLabelExpr(const AddrLabelExpr *S) { |
Douglas Gregor | 5c193b9 | 2009-07-28 00:33:38 +0000 | [diff] [blame] | 1170 | VisitExpr(S); |
Chris Lattner | c8e630e | 2011-02-17 07:39:24 +0000 | [diff] [blame] | 1171 | VisitDecl(S->getLabel()); |
Douglas Gregor | 5c193b9 | 2009-07-28 00:33:38 +0000 | [diff] [blame] | 1172 | } |
| 1173 | |
Chandler Carruth | 631abd9 | 2011-06-16 06:47:06 +0000 | [diff] [blame] | 1174 | void StmtProfiler::VisitStmtExpr(const StmtExpr *S) { |
Douglas Gregor | 5c193b9 | 2009-07-28 00:33:38 +0000 | [diff] [blame] | 1175 | VisitExpr(S); |
| 1176 | } |
| 1177 | |
Chandler Carruth | 631abd9 | 2011-06-16 06:47:06 +0000 | [diff] [blame] | 1178 | void StmtProfiler::VisitShuffleVectorExpr(const ShuffleVectorExpr *S) { |
Douglas Gregor | 5c193b9 | 2009-07-28 00:33:38 +0000 | [diff] [blame] | 1179 | VisitExpr(S); |
| 1180 | } |
| 1181 | |
Hal Finkel | c4d7c82 | 2013-09-18 03:29:45 +0000 | [diff] [blame] | 1182 | void StmtProfiler::VisitConvertVectorExpr(const ConvertVectorExpr *S) { |
| 1183 | VisitExpr(S); |
| 1184 | } |
| 1185 | |
Chandler Carruth | 631abd9 | 2011-06-16 06:47:06 +0000 | [diff] [blame] | 1186 | void StmtProfiler::VisitChooseExpr(const ChooseExpr *S) { |
Douglas Gregor | 5c193b9 | 2009-07-28 00:33:38 +0000 | [diff] [blame] | 1187 | VisitExpr(S); |
| 1188 | } |
| 1189 | |
Chandler Carruth | 631abd9 | 2011-06-16 06:47:06 +0000 | [diff] [blame] | 1190 | void StmtProfiler::VisitGNUNullExpr(const GNUNullExpr *S) { |
Douglas Gregor | 5c193b9 | 2009-07-28 00:33:38 +0000 | [diff] [blame] | 1191 | VisitExpr(S); |
| 1192 | } |
| 1193 | |
Chandler Carruth | 631abd9 | 2011-06-16 06:47:06 +0000 | [diff] [blame] | 1194 | void StmtProfiler::VisitVAArgExpr(const VAArgExpr *S) { |
Douglas Gregor | 0004417 | 2009-07-29 16:09:57 +0000 | [diff] [blame] | 1195 | VisitExpr(S); |
| 1196 | } |
| 1197 | |
Chandler Carruth | 631abd9 | 2011-06-16 06:47:06 +0000 | [diff] [blame] | 1198 | void StmtProfiler::VisitInitListExpr(const InitListExpr *S) { |
Douglas Gregor | 5c193b9 | 2009-07-28 00:33:38 +0000 | [diff] [blame] | 1199 | if (S->getSyntacticForm()) { |
| 1200 | VisitInitListExpr(S->getSyntacticForm()); |
| 1201 | return; |
| 1202 | } |
Mike Stump | 11289f4 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 1203 | |
Douglas Gregor | 5c193b9 | 2009-07-28 00:33:38 +0000 | [diff] [blame] | 1204 | VisitExpr(S); |
| 1205 | } |
| 1206 | |
Chandler Carruth | 631abd9 | 2011-06-16 06:47:06 +0000 | [diff] [blame] | 1207 | void StmtProfiler::VisitDesignatedInitExpr(const DesignatedInitExpr *S) { |
Douglas Gregor | 5c193b9 | 2009-07-28 00:33:38 +0000 | [diff] [blame] | 1208 | VisitExpr(S); |
| 1209 | ID.AddBoolean(S->usesGNUSyntax()); |
David Majnemer | f7e3609 | 2016-06-23 00:15:04 +0000 | [diff] [blame] | 1210 | for (const DesignatedInitExpr::Designator &D : S->designators()) { |
| 1211 | if (D.isFieldDesignator()) { |
Douglas Gregor | 5c193b9 | 2009-07-28 00:33:38 +0000 | [diff] [blame] | 1212 | ID.AddInteger(0); |
David Majnemer | f7e3609 | 2016-06-23 00:15:04 +0000 | [diff] [blame] | 1213 | VisitName(D.getFieldName()); |
Douglas Gregor | 5c193b9 | 2009-07-28 00:33:38 +0000 | [diff] [blame] | 1214 | continue; |
| 1215 | } |
Mike Stump | 11289f4 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 1216 | |
David Majnemer | f7e3609 | 2016-06-23 00:15:04 +0000 | [diff] [blame] | 1217 | if (D.isArrayDesignator()) { |
Douglas Gregor | 5c193b9 | 2009-07-28 00:33:38 +0000 | [diff] [blame] | 1218 | ID.AddInteger(1); |
| 1219 | } else { |
David Majnemer | f7e3609 | 2016-06-23 00:15:04 +0000 | [diff] [blame] | 1220 | assert(D.isArrayRangeDesignator()); |
Douglas Gregor | 5c193b9 | 2009-07-28 00:33:38 +0000 | [diff] [blame] | 1221 | ID.AddInteger(2); |
| 1222 | } |
David Majnemer | f7e3609 | 2016-06-23 00:15:04 +0000 | [diff] [blame] | 1223 | ID.AddInteger(D.getFirstExprIndex()); |
Douglas Gregor | 5c193b9 | 2009-07-28 00:33:38 +0000 | [diff] [blame] | 1224 | } |
| 1225 | } |
| 1226 | |
Yunzhong Gao | cb77930 | 2015-06-10 00:27:52 +0000 | [diff] [blame] | 1227 | // Seems that if VisitInitListExpr() only works on the syntactic form of an |
| 1228 | // InitListExpr, then a DesignatedInitUpdateExpr is not encountered. |
| 1229 | void StmtProfiler::VisitDesignatedInitUpdateExpr( |
| 1230 | const DesignatedInitUpdateExpr *S) { |
| 1231 | llvm_unreachable("Unexpected DesignatedInitUpdateExpr in syntactic form of " |
| 1232 | "initializer"); |
| 1233 | } |
| 1234 | |
Richard Smith | 410306b | 2016-12-12 02:53:20 +0000 | [diff] [blame] | 1235 | void StmtProfiler::VisitArrayInitLoopExpr(const ArrayInitLoopExpr *S) { |
| 1236 | VisitExpr(S); |
| 1237 | } |
| 1238 | |
| 1239 | void StmtProfiler::VisitArrayInitIndexExpr(const ArrayInitIndexExpr *S) { |
| 1240 | VisitExpr(S); |
| 1241 | } |
| 1242 | |
Yunzhong Gao | cb77930 | 2015-06-10 00:27:52 +0000 | [diff] [blame] | 1243 | void StmtProfiler::VisitNoInitExpr(const NoInitExpr *S) { |
| 1244 | llvm_unreachable("Unexpected NoInitExpr in syntactic form of initializer"); |
| 1245 | } |
| 1246 | |
Chandler Carruth | 631abd9 | 2011-06-16 06:47:06 +0000 | [diff] [blame] | 1247 | void StmtProfiler::VisitImplicitValueInitExpr(const ImplicitValueInitExpr *S) { |
Douglas Gregor | 5c193b9 | 2009-07-28 00:33:38 +0000 | [diff] [blame] | 1248 | VisitExpr(S); |
| 1249 | } |
| 1250 | |
Chandler Carruth | 631abd9 | 2011-06-16 06:47:06 +0000 | [diff] [blame] | 1251 | void StmtProfiler::VisitExtVectorElementExpr(const ExtVectorElementExpr *S) { |
Douglas Gregor | 5c193b9 | 2009-07-28 00:33:38 +0000 | [diff] [blame] | 1252 | VisitExpr(S); |
| 1253 | VisitName(&S->getAccessor()); |
| 1254 | } |
| 1255 | |
Chandler Carruth | 631abd9 | 2011-06-16 06:47:06 +0000 | [diff] [blame] | 1256 | void StmtProfiler::VisitBlockExpr(const BlockExpr *S) { |
Douglas Gregor | 5c193b9 | 2009-07-28 00:33:38 +0000 | [diff] [blame] | 1257 | VisitExpr(S); |
| 1258 | VisitDecl(S->getBlockDecl()); |
| 1259 | } |
| 1260 | |
Chandler Carruth | 631abd9 | 2011-06-16 06:47:06 +0000 | [diff] [blame] | 1261 | void StmtProfiler::VisitGenericSelectionExpr(const GenericSelectionExpr *S) { |
Peter Collingbourne | 9114759 | 2011-04-15 00:35:48 +0000 | [diff] [blame] | 1262 | VisitExpr(S); |
| 1263 | for (unsigned i = 0; i != S->getNumAssocs(); ++i) { |
| 1264 | QualType T = S->getAssocType(i); |
| 1265 | if (T.isNull()) |
Craig Topper | 36250ad | 2014-05-12 05:36:57 +0000 | [diff] [blame] | 1266 | ID.AddPointer(nullptr); |
Peter Collingbourne | 9114759 | 2011-04-15 00:35:48 +0000 | [diff] [blame] | 1267 | else |
| 1268 | VisitType(T); |
| 1269 | VisitExpr(S->getAssocExpr(i)); |
| 1270 | } |
| 1271 | } |
| 1272 | |
John McCall | fe96e0b | 2011-11-06 09:01:30 +0000 | [diff] [blame] | 1273 | void StmtProfiler::VisitPseudoObjectExpr(const PseudoObjectExpr *S) { |
| 1274 | VisitExpr(S); |
| 1275 | for (PseudoObjectExpr::const_semantics_iterator |
| 1276 | i = S->semantics_begin(), e = S->semantics_end(); i != e; ++i) |
| 1277 | // Normally, we would not profile the source expressions of OVEs. |
| 1278 | if (const OpaqueValueExpr *OVE = dyn_cast<OpaqueValueExpr>(*i)) |
| 1279 | Visit(OVE->getSourceExpr()); |
| 1280 | } |
| 1281 | |
Eli Friedman | df14b3a | 2011-10-11 02:20:01 +0000 | [diff] [blame] | 1282 | void StmtProfiler::VisitAtomicExpr(const AtomicExpr *S) { |
| 1283 | VisitExpr(S); |
Eli Friedman | 4b72fdd | 2011-10-14 20:59:01 +0000 | [diff] [blame] | 1284 | ID.AddInteger(S->getOp()); |
Eli Friedman | df14b3a | 2011-10-11 02:20:01 +0000 | [diff] [blame] | 1285 | } |
| 1286 | |
Chandler Carruth | 631abd9 | 2011-06-16 06:47:06 +0000 | [diff] [blame] | 1287 | static Stmt::StmtClass DecodeOperatorCall(const CXXOperatorCallExpr *S, |
John McCall | e302792 | 2010-08-25 11:45:40 +0000 | [diff] [blame] | 1288 | UnaryOperatorKind &UnaryOp, |
| 1289 | BinaryOperatorKind &BinaryOp) { |
Douglas Gregor | e9ceb31 | 2010-05-19 04:13:23 +0000 | [diff] [blame] | 1290 | switch (S->getOperator()) { |
| 1291 | case OO_None: |
| 1292 | case OO_New: |
| 1293 | case OO_Delete: |
| 1294 | case OO_Array_New: |
| 1295 | case OO_Array_Delete: |
| 1296 | case OO_Arrow: |
| 1297 | case OO_Call: |
| 1298 | case OO_Conditional: |
| 1299 | case NUM_OVERLOADED_OPERATORS: |
| 1300 | llvm_unreachable("Invalid operator call kind"); |
Fangrui Song | 6907ce2 | 2018-07-30 19:24:48 +0000 | [diff] [blame] | 1301 | |
Douglas Gregor | e9ceb31 | 2010-05-19 04:13:23 +0000 | [diff] [blame] | 1302 | case OO_Plus: |
| 1303 | if (S->getNumArgs() == 1) { |
John McCall | e302792 | 2010-08-25 11:45:40 +0000 | [diff] [blame] | 1304 | UnaryOp = UO_Plus; |
Douglas Gregor | e9ceb31 | 2010-05-19 04:13:23 +0000 | [diff] [blame] | 1305 | return Stmt::UnaryOperatorClass; |
| 1306 | } |
Fangrui Song | 6907ce2 | 2018-07-30 19:24:48 +0000 | [diff] [blame] | 1307 | |
John McCall | e302792 | 2010-08-25 11:45:40 +0000 | [diff] [blame] | 1308 | BinaryOp = BO_Add; |
Douglas Gregor | e9ceb31 | 2010-05-19 04:13:23 +0000 | [diff] [blame] | 1309 | return Stmt::BinaryOperatorClass; |
Fangrui Song | 6907ce2 | 2018-07-30 19:24:48 +0000 | [diff] [blame] | 1310 | |
Douglas Gregor | e9ceb31 | 2010-05-19 04:13:23 +0000 | [diff] [blame] | 1311 | case OO_Minus: |
| 1312 | if (S->getNumArgs() == 1) { |
John McCall | e302792 | 2010-08-25 11:45:40 +0000 | [diff] [blame] | 1313 | UnaryOp = UO_Minus; |
Douglas Gregor | e9ceb31 | 2010-05-19 04:13:23 +0000 | [diff] [blame] | 1314 | return Stmt::UnaryOperatorClass; |
| 1315 | } |
Fangrui Song | 6907ce2 | 2018-07-30 19:24:48 +0000 | [diff] [blame] | 1316 | |
John McCall | e302792 | 2010-08-25 11:45:40 +0000 | [diff] [blame] | 1317 | BinaryOp = BO_Sub; |
Douglas Gregor | e9ceb31 | 2010-05-19 04:13:23 +0000 | [diff] [blame] | 1318 | return Stmt::BinaryOperatorClass; |
| 1319 | |
| 1320 | case OO_Star: |
| 1321 | if (S->getNumArgs() == 1) { |
Richard Smith | f15acc5 | 2014-06-05 22:43:40 +0000 | [diff] [blame] | 1322 | UnaryOp = UO_Deref; |
Douglas Gregor | e9ceb31 | 2010-05-19 04:13:23 +0000 | [diff] [blame] | 1323 | return Stmt::UnaryOperatorClass; |
| 1324 | } |
Fangrui Song | 6907ce2 | 2018-07-30 19:24:48 +0000 | [diff] [blame] | 1325 | |
Richard Smith | f15acc5 | 2014-06-05 22:43:40 +0000 | [diff] [blame] | 1326 | BinaryOp = BO_Mul; |
Douglas Gregor | e9ceb31 | 2010-05-19 04:13:23 +0000 | [diff] [blame] | 1327 | return Stmt::BinaryOperatorClass; |
| 1328 | |
| 1329 | case OO_Slash: |
John McCall | e302792 | 2010-08-25 11:45:40 +0000 | [diff] [blame] | 1330 | BinaryOp = BO_Div; |
Douglas Gregor | e9ceb31 | 2010-05-19 04:13:23 +0000 | [diff] [blame] | 1331 | return Stmt::BinaryOperatorClass; |
Fangrui Song | 6907ce2 | 2018-07-30 19:24:48 +0000 | [diff] [blame] | 1332 | |
Douglas Gregor | e9ceb31 | 2010-05-19 04:13:23 +0000 | [diff] [blame] | 1333 | case OO_Percent: |
John McCall | e302792 | 2010-08-25 11:45:40 +0000 | [diff] [blame] | 1334 | BinaryOp = BO_Rem; |
Douglas Gregor | e9ceb31 | 2010-05-19 04:13:23 +0000 | [diff] [blame] | 1335 | return Stmt::BinaryOperatorClass; |
| 1336 | |
| 1337 | case OO_Caret: |
John McCall | e302792 | 2010-08-25 11:45:40 +0000 | [diff] [blame] | 1338 | BinaryOp = BO_Xor; |
Douglas Gregor | e9ceb31 | 2010-05-19 04:13:23 +0000 | [diff] [blame] | 1339 | return Stmt::BinaryOperatorClass; |
| 1340 | |
| 1341 | case OO_Amp: |
| 1342 | if (S->getNumArgs() == 1) { |
John McCall | e302792 | 2010-08-25 11:45:40 +0000 | [diff] [blame] | 1343 | UnaryOp = UO_AddrOf; |
Douglas Gregor | e9ceb31 | 2010-05-19 04:13:23 +0000 | [diff] [blame] | 1344 | return Stmt::UnaryOperatorClass; |
| 1345 | } |
Fangrui Song | 6907ce2 | 2018-07-30 19:24:48 +0000 | [diff] [blame] | 1346 | |
John McCall | e302792 | 2010-08-25 11:45:40 +0000 | [diff] [blame] | 1347 | BinaryOp = BO_And; |
Douglas Gregor | e9ceb31 | 2010-05-19 04:13:23 +0000 | [diff] [blame] | 1348 | return Stmt::BinaryOperatorClass; |
Fangrui Song | 6907ce2 | 2018-07-30 19:24:48 +0000 | [diff] [blame] | 1349 | |
Douglas Gregor | e9ceb31 | 2010-05-19 04:13:23 +0000 | [diff] [blame] | 1350 | case OO_Pipe: |
John McCall | e302792 | 2010-08-25 11:45:40 +0000 | [diff] [blame] | 1351 | BinaryOp = BO_Or; |
Douglas Gregor | e9ceb31 | 2010-05-19 04:13:23 +0000 | [diff] [blame] | 1352 | return Stmt::BinaryOperatorClass; |
| 1353 | |
| 1354 | case OO_Tilde: |
John McCall | e302792 | 2010-08-25 11:45:40 +0000 | [diff] [blame] | 1355 | UnaryOp = UO_Not; |
Douglas Gregor | e9ceb31 | 2010-05-19 04:13:23 +0000 | [diff] [blame] | 1356 | return Stmt::UnaryOperatorClass; |
| 1357 | |
| 1358 | case OO_Exclaim: |
John McCall | e302792 | 2010-08-25 11:45:40 +0000 | [diff] [blame] | 1359 | UnaryOp = UO_LNot; |
Douglas Gregor | e9ceb31 | 2010-05-19 04:13:23 +0000 | [diff] [blame] | 1360 | return Stmt::UnaryOperatorClass; |
| 1361 | |
| 1362 | case OO_Equal: |
John McCall | e302792 | 2010-08-25 11:45:40 +0000 | [diff] [blame] | 1363 | BinaryOp = BO_Assign; |
Douglas Gregor | e9ceb31 | 2010-05-19 04:13:23 +0000 | [diff] [blame] | 1364 | return Stmt::BinaryOperatorClass; |
| 1365 | |
| 1366 | case OO_Less: |
John McCall | e302792 | 2010-08-25 11:45:40 +0000 | [diff] [blame] | 1367 | BinaryOp = BO_LT; |
Douglas Gregor | e9ceb31 | 2010-05-19 04:13:23 +0000 | [diff] [blame] | 1368 | return Stmt::BinaryOperatorClass; |
| 1369 | |
| 1370 | case OO_Greater: |
John McCall | e302792 | 2010-08-25 11:45:40 +0000 | [diff] [blame] | 1371 | BinaryOp = BO_GT; |
Douglas Gregor | e9ceb31 | 2010-05-19 04:13:23 +0000 | [diff] [blame] | 1372 | return Stmt::BinaryOperatorClass; |
Fangrui Song | 6907ce2 | 2018-07-30 19:24:48 +0000 | [diff] [blame] | 1373 | |
Douglas Gregor | e9ceb31 | 2010-05-19 04:13:23 +0000 | [diff] [blame] | 1374 | case OO_PlusEqual: |
John McCall | e302792 | 2010-08-25 11:45:40 +0000 | [diff] [blame] | 1375 | BinaryOp = BO_AddAssign; |
Douglas Gregor | e9ceb31 | 2010-05-19 04:13:23 +0000 | [diff] [blame] | 1376 | return Stmt::CompoundAssignOperatorClass; |
| 1377 | |
| 1378 | case OO_MinusEqual: |
John McCall | e302792 | 2010-08-25 11:45:40 +0000 | [diff] [blame] | 1379 | BinaryOp = BO_SubAssign; |
Douglas Gregor | e9ceb31 | 2010-05-19 04:13:23 +0000 | [diff] [blame] | 1380 | return Stmt::CompoundAssignOperatorClass; |
| 1381 | |
| 1382 | case OO_StarEqual: |
John McCall | e302792 | 2010-08-25 11:45:40 +0000 | [diff] [blame] | 1383 | BinaryOp = BO_MulAssign; |
Douglas Gregor | e9ceb31 | 2010-05-19 04:13:23 +0000 | [diff] [blame] | 1384 | return Stmt::CompoundAssignOperatorClass; |
| 1385 | |
| 1386 | case OO_SlashEqual: |
John McCall | e302792 | 2010-08-25 11:45:40 +0000 | [diff] [blame] | 1387 | BinaryOp = BO_DivAssign; |
Douglas Gregor | e9ceb31 | 2010-05-19 04:13:23 +0000 | [diff] [blame] | 1388 | return Stmt::CompoundAssignOperatorClass; |
| 1389 | |
| 1390 | case OO_PercentEqual: |
John McCall | e302792 | 2010-08-25 11:45:40 +0000 | [diff] [blame] | 1391 | BinaryOp = BO_RemAssign; |
Douglas Gregor | e9ceb31 | 2010-05-19 04:13:23 +0000 | [diff] [blame] | 1392 | return Stmt::CompoundAssignOperatorClass; |
| 1393 | |
| 1394 | case OO_CaretEqual: |
John McCall | e302792 | 2010-08-25 11:45:40 +0000 | [diff] [blame] | 1395 | BinaryOp = BO_XorAssign; |
Douglas Gregor | e9ceb31 | 2010-05-19 04:13:23 +0000 | [diff] [blame] | 1396 | return Stmt::CompoundAssignOperatorClass; |
Fangrui Song | 6907ce2 | 2018-07-30 19:24:48 +0000 | [diff] [blame] | 1397 | |
Douglas Gregor | e9ceb31 | 2010-05-19 04:13:23 +0000 | [diff] [blame] | 1398 | case OO_AmpEqual: |
John McCall | e302792 | 2010-08-25 11:45:40 +0000 | [diff] [blame] | 1399 | BinaryOp = BO_AndAssign; |
Douglas Gregor | e9ceb31 | 2010-05-19 04:13:23 +0000 | [diff] [blame] | 1400 | return Stmt::CompoundAssignOperatorClass; |
Fangrui Song | 6907ce2 | 2018-07-30 19:24:48 +0000 | [diff] [blame] | 1401 | |
Douglas Gregor | e9ceb31 | 2010-05-19 04:13:23 +0000 | [diff] [blame] | 1402 | case OO_PipeEqual: |
John McCall | e302792 | 2010-08-25 11:45:40 +0000 | [diff] [blame] | 1403 | BinaryOp = BO_OrAssign; |
Douglas Gregor | e9ceb31 | 2010-05-19 04:13:23 +0000 | [diff] [blame] | 1404 | return Stmt::CompoundAssignOperatorClass; |
Fangrui Song | 6907ce2 | 2018-07-30 19:24:48 +0000 | [diff] [blame] | 1405 | |
Douglas Gregor | e9ceb31 | 2010-05-19 04:13:23 +0000 | [diff] [blame] | 1406 | case OO_LessLess: |
John McCall | e302792 | 2010-08-25 11:45:40 +0000 | [diff] [blame] | 1407 | BinaryOp = BO_Shl; |
Douglas Gregor | e9ceb31 | 2010-05-19 04:13:23 +0000 | [diff] [blame] | 1408 | return Stmt::BinaryOperatorClass; |
Fangrui Song | 6907ce2 | 2018-07-30 19:24:48 +0000 | [diff] [blame] | 1409 | |
Douglas Gregor | e9ceb31 | 2010-05-19 04:13:23 +0000 | [diff] [blame] | 1410 | case OO_GreaterGreater: |
John McCall | e302792 | 2010-08-25 11:45:40 +0000 | [diff] [blame] | 1411 | BinaryOp = BO_Shr; |
Douglas Gregor | e9ceb31 | 2010-05-19 04:13:23 +0000 | [diff] [blame] | 1412 | return Stmt::BinaryOperatorClass; |
| 1413 | |
| 1414 | case OO_LessLessEqual: |
John McCall | e302792 | 2010-08-25 11:45:40 +0000 | [diff] [blame] | 1415 | BinaryOp = BO_ShlAssign; |
Douglas Gregor | e9ceb31 | 2010-05-19 04:13:23 +0000 | [diff] [blame] | 1416 | return Stmt::CompoundAssignOperatorClass; |
Fangrui Song | 6907ce2 | 2018-07-30 19:24:48 +0000 | [diff] [blame] | 1417 | |
Douglas Gregor | e9ceb31 | 2010-05-19 04:13:23 +0000 | [diff] [blame] | 1418 | case OO_GreaterGreaterEqual: |
John McCall | e302792 | 2010-08-25 11:45:40 +0000 | [diff] [blame] | 1419 | BinaryOp = BO_ShrAssign; |
Douglas Gregor | e9ceb31 | 2010-05-19 04:13:23 +0000 | [diff] [blame] | 1420 | return Stmt::CompoundAssignOperatorClass; |
| 1421 | |
| 1422 | case OO_EqualEqual: |
John McCall | e302792 | 2010-08-25 11:45:40 +0000 | [diff] [blame] | 1423 | BinaryOp = BO_EQ; |
Douglas Gregor | e9ceb31 | 2010-05-19 04:13:23 +0000 | [diff] [blame] | 1424 | return Stmt::BinaryOperatorClass; |
Fangrui Song | 6907ce2 | 2018-07-30 19:24:48 +0000 | [diff] [blame] | 1425 | |
Douglas Gregor | e9ceb31 | 2010-05-19 04:13:23 +0000 | [diff] [blame] | 1426 | case OO_ExclaimEqual: |
John McCall | e302792 | 2010-08-25 11:45:40 +0000 | [diff] [blame] | 1427 | BinaryOp = BO_NE; |
Douglas Gregor | e9ceb31 | 2010-05-19 04:13:23 +0000 | [diff] [blame] | 1428 | return Stmt::BinaryOperatorClass; |
Fangrui Song | 6907ce2 | 2018-07-30 19:24:48 +0000 | [diff] [blame] | 1429 | |
Douglas Gregor | e9ceb31 | 2010-05-19 04:13:23 +0000 | [diff] [blame] | 1430 | case OO_LessEqual: |
John McCall | e302792 | 2010-08-25 11:45:40 +0000 | [diff] [blame] | 1431 | BinaryOp = BO_LE; |
Douglas Gregor | e9ceb31 | 2010-05-19 04:13:23 +0000 | [diff] [blame] | 1432 | return Stmt::BinaryOperatorClass; |
Fangrui Song | 6907ce2 | 2018-07-30 19:24:48 +0000 | [diff] [blame] | 1433 | |
Douglas Gregor | e9ceb31 | 2010-05-19 04:13:23 +0000 | [diff] [blame] | 1434 | case OO_GreaterEqual: |
John McCall | e302792 | 2010-08-25 11:45:40 +0000 | [diff] [blame] | 1435 | BinaryOp = BO_GE; |
Douglas Gregor | e9ceb31 | 2010-05-19 04:13:23 +0000 | [diff] [blame] | 1436 | return Stmt::BinaryOperatorClass; |
Richard Smith | d30b23d | 2017-12-01 02:13:10 +0000 | [diff] [blame] | 1437 | |
| 1438 | case OO_Spaceship: |
| 1439 | // FIXME: Update this once we support <=> expressions. |
| 1440 | llvm_unreachable("<=> expressions not supported yet"); |
Fangrui Song | 6907ce2 | 2018-07-30 19:24:48 +0000 | [diff] [blame] | 1441 | |
Douglas Gregor | e9ceb31 | 2010-05-19 04:13:23 +0000 | [diff] [blame] | 1442 | case OO_AmpAmp: |
John McCall | e302792 | 2010-08-25 11:45:40 +0000 | [diff] [blame] | 1443 | BinaryOp = BO_LAnd; |
Douglas Gregor | e9ceb31 | 2010-05-19 04:13:23 +0000 | [diff] [blame] | 1444 | return Stmt::BinaryOperatorClass; |
Fangrui Song | 6907ce2 | 2018-07-30 19:24:48 +0000 | [diff] [blame] | 1445 | |
Douglas Gregor | e9ceb31 | 2010-05-19 04:13:23 +0000 | [diff] [blame] | 1446 | case OO_PipePipe: |
John McCall | e302792 | 2010-08-25 11:45:40 +0000 | [diff] [blame] | 1447 | BinaryOp = BO_LOr; |
Douglas Gregor | e9ceb31 | 2010-05-19 04:13:23 +0000 | [diff] [blame] | 1448 | return Stmt::BinaryOperatorClass; |
| 1449 | |
| 1450 | case OO_PlusPlus: |
Fangrui Song | 6907ce2 | 2018-07-30 19:24:48 +0000 | [diff] [blame] | 1451 | UnaryOp = S->getNumArgs() == 1? UO_PreInc |
John McCall | e302792 | 2010-08-25 11:45:40 +0000 | [diff] [blame] | 1452 | : UO_PostInc; |
Douglas Gregor | e9ceb31 | 2010-05-19 04:13:23 +0000 | [diff] [blame] | 1453 | return Stmt::UnaryOperatorClass; |
| 1454 | |
| 1455 | case OO_MinusMinus: |
John McCall | e302792 | 2010-08-25 11:45:40 +0000 | [diff] [blame] | 1456 | UnaryOp = S->getNumArgs() == 1? UO_PreDec |
| 1457 | : UO_PostDec; |
Douglas Gregor | e9ceb31 | 2010-05-19 04:13:23 +0000 | [diff] [blame] | 1458 | return Stmt::UnaryOperatorClass; |
| 1459 | |
| 1460 | case OO_Comma: |
John McCall | e302792 | 2010-08-25 11:45:40 +0000 | [diff] [blame] | 1461 | BinaryOp = BO_Comma; |
Douglas Gregor | e9ceb31 | 2010-05-19 04:13:23 +0000 | [diff] [blame] | 1462 | return Stmt::BinaryOperatorClass; |
| 1463 | |
Douglas Gregor | e9ceb31 | 2010-05-19 04:13:23 +0000 | [diff] [blame] | 1464 | case OO_ArrowStar: |
John McCall | e302792 | 2010-08-25 11:45:40 +0000 | [diff] [blame] | 1465 | BinaryOp = BO_PtrMemI; |
Douglas Gregor | e9ceb31 | 2010-05-19 04:13:23 +0000 | [diff] [blame] | 1466 | return Stmt::BinaryOperatorClass; |
Fangrui Song | 6907ce2 | 2018-07-30 19:24:48 +0000 | [diff] [blame] | 1467 | |
Douglas Gregor | e9ceb31 | 2010-05-19 04:13:23 +0000 | [diff] [blame] | 1468 | case OO_Subscript: |
| 1469 | return Stmt::ArraySubscriptExprClass; |
Richard Smith | 6fff5c4 | 2018-07-31 00:47:41 +0000 | [diff] [blame] | 1470 | |
| 1471 | case OO_Coawait: |
| 1472 | UnaryOp = UO_Coawait; |
| 1473 | return Stmt::UnaryOperatorClass; |
Douglas Gregor | e9ceb31 | 2010-05-19 04:13:23 +0000 | [diff] [blame] | 1474 | } |
Fangrui Song | 6907ce2 | 2018-07-30 19:24:48 +0000 | [diff] [blame] | 1475 | |
Douglas Gregor | e9ceb31 | 2010-05-19 04:13:23 +0000 | [diff] [blame] | 1476 | llvm_unreachable("Invalid overloaded operator expression"); |
| 1477 | } |
Richard Smith | f15acc5 | 2014-06-05 22:43:40 +0000 | [diff] [blame] | 1478 | |
Reid Kleckner | e257e18 | 2017-10-13 16:18:32 +0000 | [diff] [blame] | 1479 | #if defined(_MSC_VER) && !defined(__clang__) |
Nico Weber | f56f446 | 2017-07-24 16:54:11 +0000 | [diff] [blame] | 1480 | #if _MSC_VER == 1911 |
| 1481 | // Work around https://developercommunity.visualstudio.com/content/problem/84002/clang-cl-when-built-with-vc-2017-crashes-cause-vc.html |
| 1482 | // MSVC 2017 update 3 miscompiles this function, and a clang built with it |
| 1483 | // will crash in stage 2 of a bootstrap build. |
| 1484 | #pragma optimize("", off) |
| 1485 | #endif |
| 1486 | #endif |
| 1487 | |
Chandler Carruth | 631abd9 | 2011-06-16 06:47:06 +0000 | [diff] [blame] | 1488 | void StmtProfiler::VisitCXXOperatorCallExpr(const CXXOperatorCallExpr *S) { |
Douglas Gregor | e9ceb31 | 2010-05-19 04:13:23 +0000 | [diff] [blame] | 1489 | if (S->isTypeDependent()) { |
| 1490 | // Type-dependent operator calls are profiled like their underlying |
| 1491 | // syntactic operator. |
Richard Smith | bac0a0d | 2016-10-24 18:47:04 +0000 | [diff] [blame] | 1492 | // |
| 1493 | // An operator call to operator-> is always implicit, so just skip it. The |
| 1494 | // enclosing MemberExpr will profile the actual member access. |
| 1495 | if (S->getOperator() == OO_Arrow) |
| 1496 | return Visit(S->getArg(0)); |
| 1497 | |
John McCall | e302792 | 2010-08-25 11:45:40 +0000 | [diff] [blame] | 1498 | UnaryOperatorKind UnaryOp = UO_Extension; |
| 1499 | BinaryOperatorKind BinaryOp = BO_Comma; |
Douglas Gregor | e9ceb31 | 2010-05-19 04:13:23 +0000 | [diff] [blame] | 1500 | Stmt::StmtClass SC = DecodeOperatorCall(S, UnaryOp, BinaryOp); |
Richard Smith | f15acc5 | 2014-06-05 22:43:40 +0000 | [diff] [blame] | 1501 | |
Douglas Gregor | e9ceb31 | 2010-05-19 04:13:23 +0000 | [diff] [blame] | 1502 | ID.AddInteger(SC); |
| 1503 | for (unsigned I = 0, N = S->getNumArgs(); I != N; ++I) |
| 1504 | Visit(S->getArg(I)); |
| 1505 | if (SC == Stmt::UnaryOperatorClass) |
| 1506 | ID.AddInteger(UnaryOp); |
Fangrui Song | 6907ce2 | 2018-07-30 19:24:48 +0000 | [diff] [blame] | 1507 | else if (SC == Stmt::BinaryOperatorClass || |
Douglas Gregor | e9ceb31 | 2010-05-19 04:13:23 +0000 | [diff] [blame] | 1508 | SC == Stmt::CompoundAssignOperatorClass) |
| 1509 | ID.AddInteger(BinaryOp); |
| 1510 | else |
| 1511 | assert(SC == Stmt::ArraySubscriptExprClass); |
Richard Smith | f15acc5 | 2014-06-05 22:43:40 +0000 | [diff] [blame] | 1512 | |
Douglas Gregor | e9ceb31 | 2010-05-19 04:13:23 +0000 | [diff] [blame] | 1513 | return; |
| 1514 | } |
Richard Smith | f15acc5 | 2014-06-05 22:43:40 +0000 | [diff] [blame] | 1515 | |
Douglas Gregor | 5c193b9 | 2009-07-28 00:33:38 +0000 | [diff] [blame] | 1516 | VisitCallExpr(S); |
| 1517 | ID.AddInteger(S->getOperator()); |
| 1518 | } |
| 1519 | |
Reid Kleckner | e257e18 | 2017-10-13 16:18:32 +0000 | [diff] [blame] | 1520 | #if defined(_MSC_VER) && !defined(__clang__) |
Nico Weber | f56f446 | 2017-07-24 16:54:11 +0000 | [diff] [blame] | 1521 | #if _MSC_VER == 1911 |
| 1522 | #pragma optimize("", on) |
| 1523 | #endif |
| 1524 | #endif |
| 1525 | |
Chandler Carruth | 631abd9 | 2011-06-16 06:47:06 +0000 | [diff] [blame] | 1526 | void StmtProfiler::VisitCXXMemberCallExpr(const CXXMemberCallExpr *S) { |
Douglas Gregor | 5c193b9 | 2009-07-28 00:33:38 +0000 | [diff] [blame] | 1527 | VisitCallExpr(S); |
| 1528 | } |
| 1529 | |
Chandler Carruth | 631abd9 | 2011-06-16 06:47:06 +0000 | [diff] [blame] | 1530 | void StmtProfiler::VisitCUDAKernelCallExpr(const CUDAKernelCallExpr *S) { |
Peter Collingbourne | 41f8546 | 2011-02-09 21:07:24 +0000 | [diff] [blame] | 1531 | VisitCallExpr(S); |
| 1532 | } |
| 1533 | |
Chandler Carruth | 631abd9 | 2011-06-16 06:47:06 +0000 | [diff] [blame] | 1534 | void StmtProfiler::VisitAsTypeExpr(const AsTypeExpr *S) { |
Tanya Lattner | 55808c1 | 2011-06-04 00:47:47 +0000 | [diff] [blame] | 1535 | VisitExpr(S); |
| 1536 | } |
| 1537 | |
Chandler Carruth | 631abd9 | 2011-06-16 06:47:06 +0000 | [diff] [blame] | 1538 | void StmtProfiler::VisitCXXNamedCastExpr(const CXXNamedCastExpr *S) { |
Douglas Gregor | 5c193b9 | 2009-07-28 00:33:38 +0000 | [diff] [blame] | 1539 | VisitExplicitCastExpr(S); |
| 1540 | } |
| 1541 | |
Chandler Carruth | 631abd9 | 2011-06-16 06:47:06 +0000 | [diff] [blame] | 1542 | void StmtProfiler::VisitCXXStaticCastExpr(const CXXStaticCastExpr *S) { |
Douglas Gregor | 5c193b9 | 2009-07-28 00:33:38 +0000 | [diff] [blame] | 1543 | VisitCXXNamedCastExpr(S); |
| 1544 | } |
| 1545 | |
Chandler Carruth | 631abd9 | 2011-06-16 06:47:06 +0000 | [diff] [blame] | 1546 | void StmtProfiler::VisitCXXDynamicCastExpr(const CXXDynamicCastExpr *S) { |
Douglas Gregor | 5c193b9 | 2009-07-28 00:33:38 +0000 | [diff] [blame] | 1547 | VisitCXXNamedCastExpr(S); |
| 1548 | } |
| 1549 | |
Chandler Carruth | 631abd9 | 2011-06-16 06:47:06 +0000 | [diff] [blame] | 1550 | void |
| 1551 | StmtProfiler::VisitCXXReinterpretCastExpr(const CXXReinterpretCastExpr *S) { |
Douglas Gregor | 5c193b9 | 2009-07-28 00:33:38 +0000 | [diff] [blame] | 1552 | VisitCXXNamedCastExpr(S); |
| 1553 | } |
| 1554 | |
Chandler Carruth | 631abd9 | 2011-06-16 06:47:06 +0000 | [diff] [blame] | 1555 | void StmtProfiler::VisitCXXConstCastExpr(const CXXConstCastExpr *S) { |
Douglas Gregor | 5c193b9 | 2009-07-28 00:33:38 +0000 | [diff] [blame] | 1556 | VisitCXXNamedCastExpr(S); |
| 1557 | } |
| 1558 | |
Richard Smith | c67fdd4 | 2012-03-07 08:35:16 +0000 | [diff] [blame] | 1559 | void StmtProfiler::VisitUserDefinedLiteral(const UserDefinedLiteral *S) { |
| 1560 | VisitCallExpr(S); |
| 1561 | } |
| 1562 | |
Chandler Carruth | 631abd9 | 2011-06-16 06:47:06 +0000 | [diff] [blame] | 1563 | void StmtProfiler::VisitCXXBoolLiteralExpr(const CXXBoolLiteralExpr *S) { |
Douglas Gregor | 5c193b9 | 2009-07-28 00:33:38 +0000 | [diff] [blame] | 1564 | VisitExpr(S); |
| 1565 | ID.AddBoolean(S->getValue()); |
| 1566 | } |
| 1567 | |
Chandler Carruth | 631abd9 | 2011-06-16 06:47:06 +0000 | [diff] [blame] | 1568 | void StmtProfiler::VisitCXXNullPtrLiteralExpr(const CXXNullPtrLiteralExpr *S) { |
Douglas Gregor | 0004417 | 2009-07-29 16:09:57 +0000 | [diff] [blame] | 1569 | VisitExpr(S); |
| 1570 | } |
| 1571 | |
Richard Smith | cc1b96d | 2013-06-12 22:31:48 +0000 | [diff] [blame] | 1572 | void StmtProfiler::VisitCXXStdInitializerListExpr( |
| 1573 | const CXXStdInitializerListExpr *S) { |
| 1574 | VisitExpr(S); |
| 1575 | } |
| 1576 | |
Chandler Carruth | 631abd9 | 2011-06-16 06:47:06 +0000 | [diff] [blame] | 1577 | void StmtProfiler::VisitCXXTypeidExpr(const CXXTypeidExpr *S) { |
Douglas Gregor | 5c193b9 | 2009-07-28 00:33:38 +0000 | [diff] [blame] | 1578 | VisitExpr(S); |
| 1579 | if (S->isTypeOperand()) |
David Majnemer | 143c55e | 2013-09-27 07:04:31 +0000 | [diff] [blame] | 1580 | VisitType(S->getTypeOperandSourceInfo()->getType()); |
Douglas Gregor | 5c193b9 | 2009-07-28 00:33:38 +0000 | [diff] [blame] | 1581 | } |
| 1582 | |
Chandler Carruth | 631abd9 | 2011-06-16 06:47:06 +0000 | [diff] [blame] | 1583 | void StmtProfiler::VisitCXXUuidofExpr(const CXXUuidofExpr *S) { |
Francois Pichet | 9f4f207 | 2010-09-08 12:20:18 +0000 | [diff] [blame] | 1584 | VisitExpr(S); |
| 1585 | if (S->isTypeOperand()) |
David Majnemer | 143c55e | 2013-09-27 07:04:31 +0000 | [diff] [blame] | 1586 | VisitType(S->getTypeOperandSourceInfo()->getType()); |
Francois Pichet | 9f4f207 | 2010-09-08 12:20:18 +0000 | [diff] [blame] | 1587 | } |
| 1588 | |
John McCall | 5e77d76 | 2013-04-16 07:28:30 +0000 | [diff] [blame] | 1589 | void StmtProfiler::VisitMSPropertyRefExpr(const MSPropertyRefExpr *S) { |
| 1590 | VisitExpr(S); |
| 1591 | VisitDecl(S->getPropertyDecl()); |
| 1592 | } |
| 1593 | |
Alexey Bataev | f763027 | 2015-11-25 12:01:00 +0000 | [diff] [blame] | 1594 | void StmtProfiler::VisitMSPropertySubscriptExpr( |
| 1595 | const MSPropertySubscriptExpr *S) { |
| 1596 | VisitExpr(S); |
| 1597 | } |
| 1598 | |
Chandler Carruth | 631abd9 | 2011-06-16 06:47:06 +0000 | [diff] [blame] | 1599 | void StmtProfiler::VisitCXXThisExpr(const CXXThisExpr *S) { |
Douglas Gregor | 5c193b9 | 2009-07-28 00:33:38 +0000 | [diff] [blame] | 1600 | VisitExpr(S); |
Douglas Gregor | 3024f07 | 2012-04-16 07:05:22 +0000 | [diff] [blame] | 1601 | ID.AddBoolean(S->isImplicit()); |
Douglas Gregor | 5c193b9 | 2009-07-28 00:33:38 +0000 | [diff] [blame] | 1602 | } |
| 1603 | |
Chandler Carruth | 631abd9 | 2011-06-16 06:47:06 +0000 | [diff] [blame] | 1604 | void StmtProfiler::VisitCXXThrowExpr(const CXXThrowExpr *S) { |
Douglas Gregor | 5c193b9 | 2009-07-28 00:33:38 +0000 | [diff] [blame] | 1605 | VisitExpr(S); |
| 1606 | } |
| 1607 | |
Chandler Carruth | 631abd9 | 2011-06-16 06:47:06 +0000 | [diff] [blame] | 1608 | void StmtProfiler::VisitCXXDefaultArgExpr(const CXXDefaultArgExpr *S) { |
Douglas Gregor | 5c193b9 | 2009-07-28 00:33:38 +0000 | [diff] [blame] | 1609 | VisitExpr(S); |
| 1610 | VisitDecl(S->getParam()); |
| 1611 | } |
| 1612 | |
Richard Smith | 852c9db | 2013-04-20 22:23:05 +0000 | [diff] [blame] | 1613 | void StmtProfiler::VisitCXXDefaultInitExpr(const CXXDefaultInitExpr *S) { |
| 1614 | VisitExpr(S); |
| 1615 | VisitDecl(S->getField()); |
| 1616 | } |
| 1617 | |
Chandler Carruth | 631abd9 | 2011-06-16 06:47:06 +0000 | [diff] [blame] | 1618 | void StmtProfiler::VisitCXXBindTemporaryExpr(const CXXBindTemporaryExpr *S) { |
Douglas Gregor | 5c193b9 | 2009-07-28 00:33:38 +0000 | [diff] [blame] | 1619 | VisitExpr(S); |
| 1620 | VisitDecl( |
| 1621 | const_cast<CXXDestructorDecl *>(S->getTemporary()->getDestructor())); |
| 1622 | } |
| 1623 | |
Chandler Carruth | 631abd9 | 2011-06-16 06:47:06 +0000 | [diff] [blame] | 1624 | void StmtProfiler::VisitCXXConstructExpr(const CXXConstructExpr *S) { |
Douglas Gregor | 5c193b9 | 2009-07-28 00:33:38 +0000 | [diff] [blame] | 1625 | VisitExpr(S); |
| 1626 | VisitDecl(S->getConstructor()); |
| 1627 | ID.AddBoolean(S->isElidable()); |
| 1628 | } |
| 1629 | |
Richard Smith | 5179eb7 | 2016-06-28 19:03:57 +0000 | [diff] [blame] | 1630 | void StmtProfiler::VisitCXXInheritedCtorInitExpr( |
| 1631 | const CXXInheritedCtorInitExpr *S) { |
| 1632 | VisitExpr(S); |
| 1633 | VisitDecl(S->getConstructor()); |
| 1634 | } |
| 1635 | |
Chandler Carruth | 631abd9 | 2011-06-16 06:47:06 +0000 | [diff] [blame] | 1636 | void StmtProfiler::VisitCXXFunctionalCastExpr(const CXXFunctionalCastExpr *S) { |
Douglas Gregor | 5c193b9 | 2009-07-28 00:33:38 +0000 | [diff] [blame] | 1637 | VisitExplicitCastExpr(S); |
| 1638 | } |
| 1639 | |
Chandler Carruth | 631abd9 | 2011-06-16 06:47:06 +0000 | [diff] [blame] | 1640 | void |
| 1641 | StmtProfiler::VisitCXXTemporaryObjectExpr(const CXXTemporaryObjectExpr *S) { |
Douglas Gregor | 5c193b9 | 2009-07-28 00:33:38 +0000 | [diff] [blame] | 1642 | VisitCXXConstructExpr(S); |
| 1643 | } |
| 1644 | |
Chandler Carruth | 631abd9 | 2011-06-16 06:47:06 +0000 | [diff] [blame] | 1645 | void |
Douglas Gregor | e31e606 | 2012-02-07 10:09:13 +0000 | [diff] [blame] | 1646 | StmtProfiler::VisitLambdaExpr(const LambdaExpr *S) { |
| 1647 | VisitExpr(S); |
| 1648 | for (LambdaExpr::capture_iterator C = S->explicit_capture_begin(), |
| 1649 | CEnd = S->explicit_capture_end(); |
| 1650 | C != CEnd; ++C) { |
Richard Trieu | 931638e | 2017-11-11 00:54:25 +0000 | [diff] [blame] | 1651 | if (C->capturesVLAType()) |
| 1652 | continue; |
| 1653 | |
Douglas Gregor | e31e606 | 2012-02-07 10:09:13 +0000 | [diff] [blame] | 1654 | ID.AddInteger(C->getCaptureKind()); |
Richard Smith | ba71c08 | 2013-05-16 06:20:58 +0000 | [diff] [blame] | 1655 | switch (C->getCaptureKind()) { |
Faisal Vali | dc6b596 | 2016-03-21 09:25:37 +0000 | [diff] [blame] | 1656 | case LCK_StarThis: |
Richard Smith | ba71c08 | 2013-05-16 06:20:58 +0000 | [diff] [blame] | 1657 | case LCK_This: |
| 1658 | break; |
| 1659 | case LCK_ByRef: |
| 1660 | case LCK_ByCopy: |
Douglas Gregor | e31e606 | 2012-02-07 10:09:13 +0000 | [diff] [blame] | 1661 | VisitDecl(C->getCapturedVar()); |
| 1662 | ID.AddBoolean(C->isPackExpansion()); |
Richard Smith | ba71c08 | 2013-05-16 06:20:58 +0000 | [diff] [blame] | 1663 | break; |
Alexey Bataev | 39c81e2 | 2014-08-28 04:28:19 +0000 | [diff] [blame] | 1664 | case LCK_VLAType: |
| 1665 | llvm_unreachable("VLA type in explicit captures."); |
Douglas Gregor | e31e606 | 2012-02-07 10:09:13 +0000 | [diff] [blame] | 1666 | } |
| 1667 | } |
| 1668 | // Note: If we actually needed to be able to match lambda |
| 1669 | // expressions, we would have to consider parameters and return type |
| 1670 | // here, among other things. |
| 1671 | VisitStmt(S->getBody()); |
| 1672 | } |
| 1673 | |
| 1674 | void |
Chandler Carruth | 631abd9 | 2011-06-16 06:47:06 +0000 | [diff] [blame] | 1675 | StmtProfiler::VisitCXXScalarValueInitExpr(const CXXScalarValueInitExpr *S) { |
Douglas Gregor | 5c193b9 | 2009-07-28 00:33:38 +0000 | [diff] [blame] | 1676 | VisitExpr(S); |
| 1677 | } |
| 1678 | |
Chandler Carruth | 631abd9 | 2011-06-16 06:47:06 +0000 | [diff] [blame] | 1679 | void StmtProfiler::VisitCXXDeleteExpr(const CXXDeleteExpr *S) { |
Douglas Gregor | 5c193b9 | 2009-07-28 00:33:38 +0000 | [diff] [blame] | 1680 | VisitExpr(S); |
| 1681 | ID.AddBoolean(S->isGlobalDelete()); |
| 1682 | ID.AddBoolean(S->isArrayForm()); |
| 1683 | VisitDecl(S->getOperatorDelete()); |
| 1684 | } |
| 1685 | |
Chandler Carruth | 631abd9 | 2011-06-16 06:47:06 +0000 | [diff] [blame] | 1686 | void StmtProfiler::VisitCXXNewExpr(const CXXNewExpr *S) { |
Douglas Gregor | 5c193b9 | 2009-07-28 00:33:38 +0000 | [diff] [blame] | 1687 | VisitExpr(S); |
| 1688 | VisitType(S->getAllocatedType()); |
| 1689 | VisitDecl(S->getOperatorNew()); |
| 1690 | VisitDecl(S->getOperatorDelete()); |
Douglas Gregor | 5c193b9 | 2009-07-28 00:33:38 +0000 | [diff] [blame] | 1691 | ID.AddBoolean(S->isArray()); |
| 1692 | ID.AddInteger(S->getNumPlacementArgs()); |
| 1693 | ID.AddBoolean(S->isGlobalNew()); |
| 1694 | ID.AddBoolean(S->isParenTypeId()); |
Sebastian Redl | 6047f07 | 2012-02-16 12:22:20 +0000 | [diff] [blame] | 1695 | ID.AddInteger(S->getInitializationStyle()); |
Douglas Gregor | 5c193b9 | 2009-07-28 00:33:38 +0000 | [diff] [blame] | 1696 | } |
| 1697 | |
Chandler Carruth | 631abd9 | 2011-06-16 06:47:06 +0000 | [diff] [blame] | 1698 | void |
| 1699 | StmtProfiler::VisitCXXPseudoDestructorExpr(const CXXPseudoDestructorExpr *S) { |
Douglas Gregor | ad8a336 | 2009-09-04 17:36:40 +0000 | [diff] [blame] | 1700 | VisitExpr(S); |
| 1701 | ID.AddBoolean(S->isArrow()); |
| 1702 | VisitNestedNameSpecifier(S->getQualifier()); |
Craig Topper | 36250ad | 2014-05-12 05:36:57 +0000 | [diff] [blame] | 1703 | ID.AddBoolean(S->getScopeTypeInfo() != nullptr); |
Eli Friedman | 8564139 | 2013-08-09 23:37:05 +0000 | [diff] [blame] | 1704 | if (S->getScopeTypeInfo()) |
| 1705 | VisitType(S->getScopeTypeInfo()->getType()); |
Craig Topper | 36250ad | 2014-05-12 05:36:57 +0000 | [diff] [blame] | 1706 | ID.AddBoolean(S->getDestroyedTypeInfo() != nullptr); |
Eli Friedman | 8564139 | 2013-08-09 23:37:05 +0000 | [diff] [blame] | 1707 | if (S->getDestroyedTypeInfo()) |
| 1708 | VisitType(S->getDestroyedType()); |
| 1709 | else |
Richard Trieu | 639d7b6 | 2017-02-22 22:22:42 +0000 | [diff] [blame] | 1710 | VisitIdentifierInfo(S->getDestroyedTypeIdentifier()); |
Douglas Gregor | ad8a336 | 2009-09-04 17:36:40 +0000 | [diff] [blame] | 1711 | } |
| 1712 | |
Chandler Carruth | 631abd9 | 2011-06-16 06:47:06 +0000 | [diff] [blame] | 1713 | void StmtProfiler::VisitOverloadExpr(const OverloadExpr *S) { |
Argyrios Kyrtzidis | b482eb8 | 2010-08-15 20:53:20 +0000 | [diff] [blame] | 1714 | VisitExpr(S); |
John McCall | e66edc1 | 2009-11-24 19:00:30 +0000 | [diff] [blame] | 1715 | VisitNestedNameSpecifier(S->getQualifier()); |
Richard Trieu | f65efae | 2018-02-22 05:32:25 +0000 | [diff] [blame] | 1716 | VisitName(S->getName(), /*TreatAsDecl*/ true); |
John McCall | e66edc1 | 2009-11-24 19:00:30 +0000 | [diff] [blame] | 1717 | ID.AddBoolean(S->hasExplicitTemplateArgs()); |
| 1718 | if (S->hasExplicitTemplateArgs()) |
James Y Knight | 04ec5bf | 2015-12-24 02:59:37 +0000 | [diff] [blame] | 1719 | VisitTemplateArguments(S->getTemplateArgs(), S->getNumTemplateArgs()); |
Argyrios Kyrtzidis | f450545 | 2010-08-15 01:15:38 +0000 | [diff] [blame] | 1720 | } |
| 1721 | |
| 1722 | void |
Chandler Carruth | 631abd9 | 2011-06-16 06:47:06 +0000 | [diff] [blame] | 1723 | StmtProfiler::VisitUnresolvedLookupExpr(const UnresolvedLookupExpr *S) { |
Argyrios Kyrtzidis | f450545 | 2010-08-15 01:15:38 +0000 | [diff] [blame] | 1724 | VisitOverloadExpr(S); |
Douglas Gregor | 5c193b9 | 2009-07-28 00:33:38 +0000 | [diff] [blame] | 1725 | } |
| 1726 | |
Douglas Gregor | 29c42f2 | 2012-02-24 07:38:34 +0000 | [diff] [blame] | 1727 | void StmtProfiler::VisitTypeTraitExpr(const TypeTraitExpr *S) { |
| 1728 | VisitExpr(S); |
| 1729 | ID.AddInteger(S->getTrait()); |
| 1730 | ID.AddInteger(S->getNumArgs()); |
| 1731 | for (unsigned I = 0, N = S->getNumArgs(); I != N; ++I) |
| 1732 | VisitType(S->getArg(I)->getType()); |
| 1733 | } |
| 1734 | |
Chandler Carruth | 631abd9 | 2011-06-16 06:47:06 +0000 | [diff] [blame] | 1735 | void StmtProfiler::VisitArrayTypeTraitExpr(const ArrayTypeTraitExpr *S) { |
John Wiegley | 6242b6a | 2011-04-28 00:16:57 +0000 | [diff] [blame] | 1736 | VisitExpr(S); |
| 1737 | ID.AddInteger(S->getTrait()); |
| 1738 | VisitType(S->getQueriedType()); |
| 1739 | } |
| 1740 | |
Chandler Carruth | 631abd9 | 2011-06-16 06:47:06 +0000 | [diff] [blame] | 1741 | void StmtProfiler::VisitExpressionTraitExpr(const ExpressionTraitExpr *S) { |
John Wiegley | f9f6584 | 2011-04-25 06:54:41 +0000 | [diff] [blame] | 1742 | VisitExpr(S); |
| 1743 | ID.AddInteger(S->getTrait()); |
| 1744 | VisitExpr(S->getQueriedExpression()); |
| 1745 | } |
| 1746 | |
Chandler Carruth | 631abd9 | 2011-06-16 06:47:06 +0000 | [diff] [blame] | 1747 | void StmtProfiler::VisitDependentScopeDeclRefExpr( |
| 1748 | const DependentScopeDeclRefExpr *S) { |
Douglas Gregor | 5c193b9 | 2009-07-28 00:33:38 +0000 | [diff] [blame] | 1749 | VisitExpr(S); |
| 1750 | VisitName(S->getDeclName()); |
| 1751 | VisitNestedNameSpecifier(S->getQualifier()); |
John McCall | e66edc1 | 2009-11-24 19:00:30 +0000 | [diff] [blame] | 1752 | ID.AddBoolean(S->hasExplicitTemplateArgs()); |
| 1753 | if (S->hasExplicitTemplateArgs()) |
| 1754 | VisitTemplateArguments(S->getTemplateArgs(), S->getNumTemplateArgs()); |
Douglas Gregor | 5c193b9 | 2009-07-28 00:33:38 +0000 | [diff] [blame] | 1755 | } |
| 1756 | |
Chandler Carruth | 631abd9 | 2011-06-16 06:47:06 +0000 | [diff] [blame] | 1757 | void StmtProfiler::VisitExprWithCleanups(const ExprWithCleanups *S) { |
Douglas Gregor | a709509 | 2009-07-28 14:44:31 +0000 | [diff] [blame] | 1758 | VisitExpr(S); |
Douglas Gregor | a709509 | 2009-07-28 14:44:31 +0000 | [diff] [blame] | 1759 | } |
| 1760 | |
Chandler Carruth | 631abd9 | 2011-06-16 06:47:06 +0000 | [diff] [blame] | 1761 | void StmtProfiler::VisitCXXUnresolvedConstructExpr( |
| 1762 | const CXXUnresolvedConstructExpr *S) { |
Douglas Gregor | a709509 | 2009-07-28 14:44:31 +0000 | [diff] [blame] | 1763 | VisitExpr(S); |
| 1764 | VisitType(S->getTypeAsWritten()); |
Richard Smith | 39eca9b | 2017-08-23 22:12:08 +0000 | [diff] [blame] | 1765 | ID.AddInteger(S->isListInitialization()); |
Douglas Gregor | a709509 | 2009-07-28 14:44:31 +0000 | [diff] [blame] | 1766 | } |
| 1767 | |
Chandler Carruth | 631abd9 | 2011-06-16 06:47:06 +0000 | [diff] [blame] | 1768 | void StmtProfiler::VisitCXXDependentScopeMemberExpr( |
| 1769 | const CXXDependentScopeMemberExpr *S) { |
John McCall | 2d74de9 | 2009-12-01 22:10:20 +0000 | [diff] [blame] | 1770 | ID.AddBoolean(S->isImplicitAccess()); |
| 1771 | if (!S->isImplicitAccess()) { |
| 1772 | VisitExpr(S); |
| 1773 | ID.AddBoolean(S->isArrow()); |
| 1774 | } |
Douglas Gregor | c26e0f6 | 2009-09-03 16:14:30 +0000 | [diff] [blame] | 1775 | VisitNestedNameSpecifier(S->getQualifier()); |
Douglas Gregor | a709509 | 2009-07-28 14:44:31 +0000 | [diff] [blame] | 1776 | VisitName(S->getMember()); |
John McCall | 2d74de9 | 2009-12-01 22:10:20 +0000 | [diff] [blame] | 1777 | ID.AddBoolean(S->hasExplicitTemplateArgs()); |
| 1778 | if (S->hasExplicitTemplateArgs()) |
John McCall | 10eae18 | 2009-11-30 22:42:35 +0000 | [diff] [blame] | 1779 | VisitTemplateArguments(S->getTemplateArgs(), S->getNumTemplateArgs()); |
| 1780 | } |
| 1781 | |
Chandler Carruth | 631abd9 | 2011-06-16 06:47:06 +0000 | [diff] [blame] | 1782 | void StmtProfiler::VisitUnresolvedMemberExpr(const UnresolvedMemberExpr *S) { |
John McCall | 2d74de9 | 2009-12-01 22:10:20 +0000 | [diff] [blame] | 1783 | ID.AddBoolean(S->isImplicitAccess()); |
| 1784 | if (!S->isImplicitAccess()) { |
| 1785 | VisitExpr(S); |
| 1786 | ID.AddBoolean(S->isArrow()); |
| 1787 | } |
John McCall | 10eae18 | 2009-11-30 22:42:35 +0000 | [diff] [blame] | 1788 | VisitNestedNameSpecifier(S->getQualifier()); |
| 1789 | VisitName(S->getMemberName()); |
| 1790 | ID.AddBoolean(S->hasExplicitTemplateArgs()); |
| 1791 | if (S->hasExplicitTemplateArgs()) |
| 1792 | VisitTemplateArguments(S->getTemplateArgs(), S->getNumTemplateArgs()); |
Douglas Gregor | a709509 | 2009-07-28 14:44:31 +0000 | [diff] [blame] | 1793 | } |
| 1794 | |
Chandler Carruth | 631abd9 | 2011-06-16 06:47:06 +0000 | [diff] [blame] | 1795 | void StmtProfiler::VisitCXXNoexceptExpr(const CXXNoexceptExpr *S) { |
Sebastian Redl | 4202c0f | 2010-09-10 20:55:43 +0000 | [diff] [blame] | 1796 | VisitExpr(S); |
| 1797 | } |
| 1798 | |
Chandler Carruth | 631abd9 | 2011-06-16 06:47:06 +0000 | [diff] [blame] | 1799 | void StmtProfiler::VisitPackExpansionExpr(const PackExpansionExpr *S) { |
Douglas Gregor | e8e9dd6 | 2011-01-03 17:17:50 +0000 | [diff] [blame] | 1800 | VisitExpr(S); |
| 1801 | } |
| 1802 | |
Chandler Carruth | 631abd9 | 2011-06-16 06:47:06 +0000 | [diff] [blame] | 1803 | void StmtProfiler::VisitSizeOfPackExpr(const SizeOfPackExpr *S) { |
Douglas Gregor | 820ba7b | 2011-01-04 17:33:58 +0000 | [diff] [blame] | 1804 | VisitExpr(S); |
| 1805 | VisitDecl(S->getPack()); |
Richard Smith | d784e68 | 2015-09-23 21:41:42 +0000 | [diff] [blame] | 1806 | if (S->isPartiallySubstituted()) { |
| 1807 | auto Args = S->getPartialArguments(); |
| 1808 | ID.AddInteger(Args.size()); |
| 1809 | for (const auto &TA : Args) |
| 1810 | VisitTemplateArgument(TA); |
| 1811 | } else { |
| 1812 | ID.AddInteger(0); |
| 1813 | } |
Douglas Gregor | 820ba7b | 2011-01-04 17:33:58 +0000 | [diff] [blame] | 1814 | } |
| 1815 | |
Douglas Gregor | cdbc539 | 2011-01-15 01:15:58 +0000 | [diff] [blame] | 1816 | void StmtProfiler::VisitSubstNonTypeTemplateParmPackExpr( |
Chandler Carruth | 631abd9 | 2011-06-16 06:47:06 +0000 | [diff] [blame] | 1817 | const SubstNonTypeTemplateParmPackExpr *S) { |
Douglas Gregor | cdbc539 | 2011-01-15 01:15:58 +0000 | [diff] [blame] | 1818 | VisitExpr(S); |
| 1819 | VisitDecl(S->getParameterPack()); |
| 1820 | VisitTemplateArgument(S->getArgumentPack()); |
| 1821 | } |
| 1822 | |
John McCall | 7c454bb | 2011-07-15 05:09:51 +0000 | [diff] [blame] | 1823 | void StmtProfiler::VisitSubstNonTypeTemplateParmExpr( |
| 1824 | const SubstNonTypeTemplateParmExpr *E) { |
| 1825 | // Profile exactly as the replacement expression. |
| 1826 | Visit(E->getReplacement()); |
| 1827 | } |
| 1828 | |
Richard Smith | b15fe3a | 2012-09-12 00:56:43 +0000 | [diff] [blame] | 1829 | void StmtProfiler::VisitFunctionParmPackExpr(const FunctionParmPackExpr *S) { |
| 1830 | VisitExpr(S); |
| 1831 | VisitDecl(S->getParameterPack()); |
| 1832 | ID.AddInteger(S->getNumExpansions()); |
| 1833 | for (FunctionParmPackExpr::iterator I = S->begin(), E = S->end(); I != E; ++I) |
| 1834 | VisitDecl(*I); |
| 1835 | } |
| 1836 | |
Douglas Gregor | fe31481 | 2011-06-21 17:03:29 +0000 | [diff] [blame] | 1837 | void StmtProfiler::VisitMaterializeTemporaryExpr( |
| 1838 | const MaterializeTemporaryExpr *S) { |
| 1839 | VisitExpr(S); |
| 1840 | } |
| 1841 | |
Richard Smith | 0f0af19 | 2014-11-08 05:07:16 +0000 | [diff] [blame] | 1842 | void StmtProfiler::VisitCXXFoldExpr(const CXXFoldExpr *S) { |
| 1843 | VisitExpr(S); |
| 1844 | ID.AddInteger(S->getOperator()); |
| 1845 | } |
| 1846 | |
Richard Smith | 9f690bd | 2015-10-27 06:02:45 +0000 | [diff] [blame] | 1847 | void StmtProfiler::VisitCoroutineBodyStmt(const CoroutineBodyStmt *S) { |
| 1848 | VisitStmt(S); |
| 1849 | } |
| 1850 | |
| 1851 | void StmtProfiler::VisitCoreturnStmt(const CoreturnStmt *S) { |
| 1852 | VisitStmt(S); |
| 1853 | } |
| 1854 | |
| 1855 | void StmtProfiler::VisitCoawaitExpr(const CoawaitExpr *S) { |
| 1856 | VisitExpr(S); |
| 1857 | } |
| 1858 | |
Eric Fiselier | 20f25cb | 2017-03-06 23:38:15 +0000 | [diff] [blame] | 1859 | void StmtProfiler::VisitDependentCoawaitExpr(const DependentCoawaitExpr *S) { |
| 1860 | VisitExpr(S); |
| 1861 | } |
| 1862 | |
Richard Smith | 9f690bd | 2015-10-27 06:02:45 +0000 | [diff] [blame] | 1863 | void StmtProfiler::VisitCoyieldExpr(const CoyieldExpr *S) { |
| 1864 | VisitExpr(S); |
| 1865 | } |
| 1866 | |
Chandler Carruth | 631abd9 | 2011-06-16 06:47:06 +0000 | [diff] [blame] | 1867 | void StmtProfiler::VisitOpaqueValueExpr(const OpaqueValueExpr *E) { |
Fangrui Song | 6907ce2 | 2018-07-30 19:24:48 +0000 | [diff] [blame] | 1868 | VisitExpr(E); |
John McCall | 8d69a21 | 2010-11-15 23:31:06 +0000 | [diff] [blame] | 1869 | } |
| 1870 | |
Kaelyn Takata | e1f49d5 | 2014-10-27 18:07:20 +0000 | [diff] [blame] | 1871 | void StmtProfiler::VisitTypoExpr(const TypoExpr *E) { |
| 1872 | VisitExpr(E); |
| 1873 | } |
| 1874 | |
Chandler Carruth | 631abd9 | 2011-06-16 06:47:06 +0000 | [diff] [blame] | 1875 | void StmtProfiler::VisitObjCStringLiteral(const ObjCStringLiteral *S) { |
Douglas Gregor | a709509 | 2009-07-28 14:44:31 +0000 | [diff] [blame] | 1876 | VisitExpr(S); |
| 1877 | } |
| 1878 | |
Patrick Beard | 0caa394 | 2012-04-19 00:25:12 +0000 | [diff] [blame] | 1879 | void StmtProfiler::VisitObjCBoxedExpr(const ObjCBoxedExpr *E) { |
Ted Kremenek | e65b086 | 2012-03-06 20:05:56 +0000 | [diff] [blame] | 1880 | VisitExpr(E); |
| 1881 | } |
| 1882 | |
| 1883 | void StmtProfiler::VisitObjCArrayLiteral(const ObjCArrayLiteral *E) { |
| 1884 | VisitExpr(E); |
| 1885 | } |
| 1886 | |
| 1887 | void StmtProfiler::VisitObjCDictionaryLiteral(const ObjCDictionaryLiteral *E) { |
| 1888 | VisitExpr(E); |
| 1889 | } |
| 1890 | |
Chandler Carruth | 631abd9 | 2011-06-16 06:47:06 +0000 | [diff] [blame] | 1891 | void StmtProfiler::VisitObjCEncodeExpr(const ObjCEncodeExpr *S) { |
Douglas Gregor | a709509 | 2009-07-28 14:44:31 +0000 | [diff] [blame] | 1892 | VisitExpr(S); |
| 1893 | VisitType(S->getEncodedType()); |
| 1894 | } |
| 1895 | |
Chandler Carruth | 631abd9 | 2011-06-16 06:47:06 +0000 | [diff] [blame] | 1896 | void StmtProfiler::VisitObjCSelectorExpr(const ObjCSelectorExpr *S) { |
Douglas Gregor | a709509 | 2009-07-28 14:44:31 +0000 | [diff] [blame] | 1897 | VisitExpr(S); |
| 1898 | VisitName(S->getSelector()); |
| 1899 | } |
| 1900 | |
Chandler Carruth | 631abd9 | 2011-06-16 06:47:06 +0000 | [diff] [blame] | 1901 | void StmtProfiler::VisitObjCProtocolExpr(const ObjCProtocolExpr *S) { |
Douglas Gregor | a709509 | 2009-07-28 14:44:31 +0000 | [diff] [blame] | 1902 | VisitExpr(S); |
| 1903 | VisitDecl(S->getProtocol()); |
| 1904 | } |
| 1905 | |
Chandler Carruth | 631abd9 | 2011-06-16 06:47:06 +0000 | [diff] [blame] | 1906 | void StmtProfiler::VisitObjCIvarRefExpr(const ObjCIvarRefExpr *S) { |
Douglas Gregor | a709509 | 2009-07-28 14:44:31 +0000 | [diff] [blame] | 1907 | VisitExpr(S); |
| 1908 | VisitDecl(S->getDecl()); |
| 1909 | ID.AddBoolean(S->isArrow()); |
| 1910 | ID.AddBoolean(S->isFreeIvar()); |
| 1911 | } |
| 1912 | |
Chandler Carruth | 631abd9 | 2011-06-16 06:47:06 +0000 | [diff] [blame] | 1913 | void StmtProfiler::VisitObjCPropertyRefExpr(const ObjCPropertyRefExpr *S) { |
Douglas Gregor | a709509 | 2009-07-28 14:44:31 +0000 | [diff] [blame] | 1914 | VisitExpr(S); |
John McCall | b7bd14f | 2010-12-02 01:19:52 +0000 | [diff] [blame] | 1915 | if (S->isImplicitProperty()) { |
| 1916 | VisitDecl(S->getImplicitPropertyGetter()); |
| 1917 | VisitDecl(S->getImplicitPropertySetter()); |
| 1918 | } else { |
| 1919 | VisitDecl(S->getExplicitProperty()); |
Fariborz Jahanian | 681c075 | 2010-10-14 16:04:05 +0000 | [diff] [blame] | 1920 | } |
Fariborz Jahanian | 681c075 | 2010-10-14 16:04:05 +0000 | [diff] [blame] | 1921 | if (S->isSuperReceiver()) { |
| 1922 | ID.AddBoolean(S->isSuperReceiver()); |
John McCall | b7bd14f | 2010-12-02 01:19:52 +0000 | [diff] [blame] | 1923 | VisitType(S->getSuperReceiverType()); |
Fariborz Jahanian | 681c075 | 2010-10-14 16:04:05 +0000 | [diff] [blame] | 1924 | } |
Douglas Gregor | a709509 | 2009-07-28 14:44:31 +0000 | [diff] [blame] | 1925 | } |
| 1926 | |
Ted Kremenek | e65b086 | 2012-03-06 20:05:56 +0000 | [diff] [blame] | 1927 | void StmtProfiler::VisitObjCSubscriptRefExpr(const ObjCSubscriptRefExpr *S) { |
| 1928 | VisitExpr(S); |
| 1929 | VisitDecl(S->getAtIndexMethodDecl()); |
| 1930 | VisitDecl(S->setAtIndexMethodDecl()); |
| 1931 | } |
| 1932 | |
Chandler Carruth | 631abd9 | 2011-06-16 06:47:06 +0000 | [diff] [blame] | 1933 | void StmtProfiler::VisitObjCMessageExpr(const ObjCMessageExpr *S) { |
Douglas Gregor | a709509 | 2009-07-28 14:44:31 +0000 | [diff] [blame] | 1934 | VisitExpr(S); |
| 1935 | VisitName(S->getSelector()); |
| 1936 | VisitDecl(S->getMethodDecl()); |
| 1937 | } |
| 1938 | |
Chandler Carruth | 631abd9 | 2011-06-16 06:47:06 +0000 | [diff] [blame] | 1939 | void StmtProfiler::VisitObjCIsaExpr(const ObjCIsaExpr *S) { |
Douglas Gregor | a709509 | 2009-07-28 14:44:31 +0000 | [diff] [blame] | 1940 | VisitExpr(S); |
| 1941 | ID.AddBoolean(S->isArrow()); |
| 1942 | } |
| 1943 | |
Ted Kremenek | e65b086 | 2012-03-06 20:05:56 +0000 | [diff] [blame] | 1944 | void StmtProfiler::VisitObjCBoolLiteralExpr(const ObjCBoolLiteralExpr *S) { |
| 1945 | VisitExpr(S); |
| 1946 | ID.AddBoolean(S->getValue()); |
| 1947 | } |
| 1948 | |
Chandler Carruth | 631abd9 | 2011-06-16 06:47:06 +0000 | [diff] [blame] | 1949 | void StmtProfiler::VisitObjCIndirectCopyRestoreExpr( |
| 1950 | const ObjCIndirectCopyRestoreExpr *S) { |
John McCall | 31168b0 | 2011-06-15 23:02:42 +0000 | [diff] [blame] | 1951 | VisitExpr(S); |
| 1952 | ID.AddBoolean(S->shouldCopy()); |
| 1953 | } |
| 1954 | |
Chandler Carruth | 631abd9 | 2011-06-16 06:47:06 +0000 | [diff] [blame] | 1955 | void StmtProfiler::VisitObjCBridgedCastExpr(const ObjCBridgedCastExpr *S) { |
John McCall | 31168b0 | 2011-06-15 23:02:42 +0000 | [diff] [blame] | 1956 | VisitExplicitCastExpr(S); |
| 1957 | ID.AddBoolean(S->getBridgeKind()); |
| 1958 | } |
| 1959 | |
Erik Pilkington | 29099de | 2016-07-16 00:35:23 +0000 | [diff] [blame] | 1960 | void StmtProfiler::VisitObjCAvailabilityCheckExpr( |
| 1961 | const ObjCAvailabilityCheckExpr *S) { |
| 1962 | VisitExpr(S); |
| 1963 | } |
| 1964 | |
John McCall | 0ad1666 | 2009-10-29 08:12:44 +0000 | [diff] [blame] | 1965 | void StmtProfiler::VisitTemplateArguments(const TemplateArgumentLoc *Args, |
Douglas Gregor | 5c193b9 | 2009-07-28 00:33:38 +0000 | [diff] [blame] | 1966 | unsigned NumArgs) { |
| 1967 | ID.AddInteger(NumArgs); |
John McCall | 0ad1666 | 2009-10-29 08:12:44 +0000 | [diff] [blame] | 1968 | for (unsigned I = 0; I != NumArgs; ++I) |
| 1969 | VisitTemplateArgument(Args[I].getArgument()); |
| 1970 | } |
Mike Stump | 11289f4 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 1971 | |
John McCall | 0ad1666 | 2009-10-29 08:12:44 +0000 | [diff] [blame] | 1972 | void StmtProfiler::VisitTemplateArgument(const TemplateArgument &Arg) { |
| 1973 | // Mostly repetitive with TemplateArgument::Profile! |
| 1974 | ID.AddInteger(Arg.getKind()); |
| 1975 | switch (Arg.getKind()) { |
| 1976 | case TemplateArgument::Null: |
| 1977 | break; |
Mike Stump | 11289f4 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 1978 | |
John McCall | 0ad1666 | 2009-10-29 08:12:44 +0000 | [diff] [blame] | 1979 | case TemplateArgument::Type: |
| 1980 | VisitType(Arg.getAsType()); |
| 1981 | break; |
Mike Stump | 11289f4 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 1982 | |
Douglas Gregor | 9167f8b | 2009-11-11 01:00:40 +0000 | [diff] [blame] | 1983 | case TemplateArgument::Template: |
Douglas Gregor | e4ff4b5 | 2011-01-05 18:58:31 +0000 | [diff] [blame] | 1984 | case TemplateArgument::TemplateExpansion: |
| 1985 | VisitTemplateName(Arg.getAsTemplateOrTemplatePattern()); |
Douglas Gregor | 9167f8b | 2009-11-11 01:00:40 +0000 | [diff] [blame] | 1986 | break; |
Fangrui Song | 6907ce2 | 2018-07-30 19:24:48 +0000 | [diff] [blame] | 1987 | |
John McCall | 0ad1666 | 2009-10-29 08:12:44 +0000 | [diff] [blame] | 1988 | case TemplateArgument::Declaration: |
| 1989 | VisitDecl(Arg.getAsDecl()); |
| 1990 | break; |
Mike Stump | 11289f4 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 1991 | |
Eli Friedman | b826a00 | 2012-09-26 02:36:12 +0000 | [diff] [blame] | 1992 | case TemplateArgument::NullPtr: |
| 1993 | VisitType(Arg.getNullPtrType()); |
| 1994 | break; |
| 1995 | |
John McCall | 0ad1666 | 2009-10-29 08:12:44 +0000 | [diff] [blame] | 1996 | case TemplateArgument::Integral: |
Benjamin Kramer | 6003ad5 | 2012-06-07 15:09:51 +0000 | [diff] [blame] | 1997 | Arg.getAsIntegral().Profile(ID); |
John McCall | 0ad1666 | 2009-10-29 08:12:44 +0000 | [diff] [blame] | 1998 | VisitType(Arg.getIntegralType()); |
| 1999 | break; |
Mike Stump | 11289f4 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 2000 | |
John McCall | 0ad1666 | 2009-10-29 08:12:44 +0000 | [diff] [blame] | 2001 | case TemplateArgument::Expression: |
| 2002 | Visit(Arg.getAsExpr()); |
| 2003 | break; |
Mike Stump | 11289f4 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 2004 | |
John McCall | 0ad1666 | 2009-10-29 08:12:44 +0000 | [diff] [blame] | 2005 | case TemplateArgument::Pack: |
Aaron Ballman | 2a89e85 | 2014-07-15 21:32:31 +0000 | [diff] [blame] | 2006 | for (const auto &P : Arg.pack_elements()) |
| 2007 | VisitTemplateArgument(P); |
John McCall | 0ad1666 | 2009-10-29 08:12:44 +0000 | [diff] [blame] | 2008 | break; |
Douglas Gregor | 5c193b9 | 2009-07-28 00:33:38 +0000 | [diff] [blame] | 2009 | } |
| 2010 | } |
| 2011 | |
Jay Foad | 39c7980 | 2011-01-12 09:06:06 +0000 | [diff] [blame] | 2012 | void Stmt::Profile(llvm::FoldingSetNodeID &ID, const ASTContext &Context, |
Chandler Carruth | 631abd9 | 2011-06-16 06:47:06 +0000 | [diff] [blame] | 2013 | bool Canonical) const { |
Richard Trieu | 639d7b6 | 2017-02-22 22:22:42 +0000 | [diff] [blame] | 2014 | StmtProfilerWithPointers Profiler(ID, Context, Canonical); |
| 2015 | Profiler.Visit(this); |
| 2016 | } |
| 2017 | |
| 2018 | void Stmt::ProcessODRHash(llvm::FoldingSetNodeID &ID, |
| 2019 | class ODRHash &Hash) const { |
| 2020 | StmtProfilerWithoutPointers Profiler(ID, Hash); |
Douglas Gregor | 5c193b9 | 2009-07-28 00:33:38 +0000 | [diff] [blame] | 2021 | Profiler.Visit(this); |
| 2022 | } |