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