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" |
Douglas Gregor | 5c193b9 | 2009-07-28 00:33:38 +0000 | [diff] [blame] | 22 | #include "clang/AST/StmtVisitor.h" |
| 23 | #include "llvm/ADT/FoldingSet.h" |
Douglas Gregor | 5c193b9 | 2009-07-28 00:33:38 +0000 | [diff] [blame] | 24 | using namespace clang; |
| 25 | |
| 26 | namespace { |
Chandler Carruth | 631abd9 | 2011-06-16 06:47:06 +0000 | [diff] [blame] | 27 | class StmtProfiler : public ConstStmtVisitor<StmtProfiler> { |
Douglas Gregor | 5c193b9 | 2009-07-28 00:33:38 +0000 | [diff] [blame] | 28 | llvm::FoldingSetNodeID &ID; |
Jay Foad | 39c7980 | 2011-01-12 09:06:06 +0000 | [diff] [blame] | 29 | const ASTContext &Context; |
Douglas Gregor | 5c193b9 | 2009-07-28 00:33:38 +0000 | [diff] [blame] | 30 | bool Canonical; |
Mike Stump | 11289f4 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 31 | |
Douglas Gregor | 5c193b9 | 2009-07-28 00:33:38 +0000 | [diff] [blame] | 32 | public: |
Jay Foad | 39c7980 | 2011-01-12 09:06:06 +0000 | [diff] [blame] | 33 | StmtProfiler(llvm::FoldingSetNodeID &ID, const ASTContext &Context, |
Mike Stump | 11289f4 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 34 | bool Canonical) |
Douglas Gregor | 5c193b9 | 2009-07-28 00:33:38 +0000 | [diff] [blame] | 35 | : ID(ID), Context(Context), Canonical(Canonical) { } |
Mike Stump | 11289f4 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 36 | |
Chandler Carruth | 631abd9 | 2011-06-16 06:47:06 +0000 | [diff] [blame] | 37 | void VisitStmt(const Stmt *S); |
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 | #define STMT(Node, Base) void Visit##Node(const Node *S); |
Alexis Hunt | 656bb31 | 2010-05-05 15:24:00 +0000 | [diff] [blame] | 40 | #include "clang/AST/StmtNodes.inc" |
Mike Stump | 11289f4 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 41 | |
Douglas Gregor | 5c193b9 | 2009-07-28 00:33:38 +0000 | [diff] [blame] | 42 | /// \brief Visit a declaration that is referenced within an expression |
| 43 | /// or statement. |
Chandler Carruth | 631abd9 | 2011-06-16 06:47:06 +0000 | [diff] [blame] | 44 | void VisitDecl(const Decl *D); |
Mike Stump | 11289f4 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 45 | |
| 46 | /// \brief Visit a type that is referenced within an expression or |
Douglas Gregor | 5c193b9 | 2009-07-28 00:33:38 +0000 | [diff] [blame] | 47 | /// statement. |
| 48 | void VisitType(QualType T); |
Mike Stump | 11289f4 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 49 | |
Douglas Gregor | 5c193b9 | 2009-07-28 00:33:38 +0000 | [diff] [blame] | 50 | /// \brief Visit a name that occurs within an expression or statement. |
| 51 | void VisitName(DeclarationName Name); |
Mike Stump | 11289f4 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 52 | |
Douglas Gregor | 5c193b9 | 2009-07-28 00:33:38 +0000 | [diff] [blame] | 53 | /// \brief Visit a nested-name-specifier that occurs within an expression |
| 54 | /// or statement. |
| 55 | void VisitNestedNameSpecifier(NestedNameSpecifier *NNS); |
Mike Stump | 11289f4 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 56 | |
Douglas Gregor | 5c193b9 | 2009-07-28 00:33:38 +0000 | [diff] [blame] | 57 | /// \brief Visit a template name that occurs within an expression or |
| 58 | /// statement. |
| 59 | void VisitTemplateName(TemplateName Name); |
Mike Stump | 11289f4 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 60 | |
Douglas Gregor | 5c193b9 | 2009-07-28 00:33:38 +0000 | [diff] [blame] | 61 | /// \brief Visit template arguments that occur within an expression or |
| 62 | /// statement. |
Chandler Carruth | 631abd9 | 2011-06-16 06:47:06 +0000 | [diff] [blame] | 63 | void VisitTemplateArguments(const TemplateArgumentLoc *Args, |
| 64 | unsigned NumArgs); |
John McCall | 0ad1666 | 2009-10-29 08:12:44 +0000 | [diff] [blame] | 65 | |
| 66 | /// \brief Visit a single template argument. |
| 67 | void VisitTemplateArgument(const TemplateArgument &Arg); |
Douglas Gregor | 5c193b9 | 2009-07-28 00:33:38 +0000 | [diff] [blame] | 68 | }; |
Alexander Kornienko | ab9db51 | 2015-06-22 23:07:51 +0000 | [diff] [blame] | 69 | } |
Douglas Gregor | 5c193b9 | 2009-07-28 00:33:38 +0000 | [diff] [blame] | 70 | |
Chandler Carruth | 631abd9 | 2011-06-16 06:47:06 +0000 | [diff] [blame] | 71 | void StmtProfiler::VisitStmt(const Stmt *S) { |
Richard Trieu | 6a77a1c | 2016-06-10 04:52:09 +0000 | [diff] [blame] | 72 | assert(S && "Requires non-null Stmt pointer"); |
Douglas Gregor | 5c193b9 | 2009-07-28 00:33:38 +0000 | [diff] [blame] | 73 | ID.AddInteger(S->getStmtClass()); |
Benjamin Kramer | 642f173 | 2015-07-02 21:03:14 +0000 | [diff] [blame] | 74 | for (const Stmt *SubStmt : S->children()) { |
| 75 | if (SubStmt) |
| 76 | Visit(SubStmt); |
Peter Collingbourne | cdb9f30 | 2012-03-01 16:34:31 +0000 | [diff] [blame] | 77 | else |
| 78 | ID.AddInteger(0); |
| 79 | } |
Douglas Gregor | 5c193b9 | 2009-07-28 00:33:38 +0000 | [diff] [blame] | 80 | } |
| 81 | |
Chandler Carruth | 631abd9 | 2011-06-16 06:47:06 +0000 | [diff] [blame] | 82 | void StmtProfiler::VisitDeclStmt(const DeclStmt *S) { |
Douglas Gregor | 4488259 | 2009-07-28 15:27:13 +0000 | [diff] [blame] | 83 | VisitStmt(S); |
Aaron Ballman | 535bbcc | 2014-03-14 17:01:24 +0000 | [diff] [blame] | 84 | for (const auto *D : S->decls()) |
| 85 | VisitDecl(D); |
Douglas Gregor | 4488259 | 2009-07-28 15:27:13 +0000 | [diff] [blame] | 86 | } |
| 87 | |
Chandler Carruth | 631abd9 | 2011-06-16 06:47:06 +0000 | [diff] [blame] | 88 | void StmtProfiler::VisitNullStmt(const NullStmt *S) { |
Douglas Gregor | 4488259 | 2009-07-28 15:27:13 +0000 | [diff] [blame] | 89 | VisitStmt(S); |
| 90 | } |
| 91 | |
Chandler Carruth | 631abd9 | 2011-06-16 06:47:06 +0000 | [diff] [blame] | 92 | void StmtProfiler::VisitCompoundStmt(const CompoundStmt *S) { |
Douglas Gregor | 4488259 | 2009-07-28 15:27:13 +0000 | [diff] [blame] | 93 | VisitStmt(S); |
| 94 | } |
| 95 | |
Chandler Carruth | 631abd9 | 2011-06-16 06:47:06 +0000 | [diff] [blame] | 96 | void StmtProfiler::VisitCaseStmt(const CaseStmt *S) { |
Douglas Gregor | 4488259 | 2009-07-28 15:27:13 +0000 | [diff] [blame] | 97 | VisitStmt(S); |
| 98 | } |
| 99 | |
Chandler Carruth | 631abd9 | 2011-06-16 06:47:06 +0000 | [diff] [blame] | 100 | void StmtProfiler::VisitDefaultStmt(const DefaultStmt *S) { |
Douglas Gregor | 4488259 | 2009-07-28 15:27:13 +0000 | [diff] [blame] | 101 | VisitStmt(S); |
| 102 | } |
| 103 | |
Chandler Carruth | 631abd9 | 2011-06-16 06:47:06 +0000 | [diff] [blame] | 104 | void StmtProfiler::VisitLabelStmt(const LabelStmt *S) { |
Douglas Gregor | 4488259 | 2009-07-28 15:27:13 +0000 | [diff] [blame] | 105 | VisitStmt(S); |
Chris Lattner | c8e630e | 2011-02-17 07:39:24 +0000 | [diff] [blame] | 106 | VisitDecl(S->getDecl()); |
Douglas Gregor | 4488259 | 2009-07-28 15:27:13 +0000 | [diff] [blame] | 107 | } |
| 108 | |
Richard Smith | c202b28 | 2012-04-14 00:33:13 +0000 | [diff] [blame] | 109 | void StmtProfiler::VisitAttributedStmt(const AttributedStmt *S) { |
| 110 | VisitStmt(S); |
| 111 | // TODO: maybe visit attributes? |
| 112 | } |
| 113 | |
Chandler Carruth | 631abd9 | 2011-06-16 06:47:06 +0000 | [diff] [blame] | 114 | void StmtProfiler::VisitIfStmt(const IfStmt *S) { |
Douglas Gregor | 4488259 | 2009-07-28 15:27:13 +0000 | [diff] [blame] | 115 | VisitStmt(S); |
Douglas Gregor | 7bab5ff | 2009-11-25 00:27:52 +0000 | [diff] [blame] | 116 | VisitDecl(S->getConditionVariable()); |
Douglas Gregor | 4488259 | 2009-07-28 15:27:13 +0000 | [diff] [blame] | 117 | } |
| 118 | |
Chandler Carruth | 631abd9 | 2011-06-16 06:47:06 +0000 | [diff] [blame] | 119 | void StmtProfiler::VisitSwitchStmt(const SwitchStmt *S) { |
Douglas Gregor | 0004417 | 2009-07-29 16:09:57 +0000 | [diff] [blame] | 120 | VisitStmt(S); |
Douglas Gregor | 7bab5ff | 2009-11-25 00:27:52 +0000 | [diff] [blame] | 121 | VisitDecl(S->getConditionVariable()); |
Douglas Gregor | 0004417 | 2009-07-29 16:09:57 +0000 | [diff] [blame] | 122 | } |
| 123 | |
Chandler Carruth | 631abd9 | 2011-06-16 06:47:06 +0000 | [diff] [blame] | 124 | void StmtProfiler::VisitWhileStmt(const WhileStmt *S) { |
Douglas Gregor | 4488259 | 2009-07-28 15:27:13 +0000 | [diff] [blame] | 125 | VisitStmt(S); |
Douglas Gregor | 7bab5ff | 2009-11-25 00:27:52 +0000 | [diff] [blame] | 126 | VisitDecl(S->getConditionVariable()); |
Douglas Gregor | 4488259 | 2009-07-28 15:27:13 +0000 | [diff] [blame] | 127 | } |
| 128 | |
Chandler Carruth | 631abd9 | 2011-06-16 06:47:06 +0000 | [diff] [blame] | 129 | void StmtProfiler::VisitDoStmt(const DoStmt *S) { |
Douglas Gregor | 4488259 | 2009-07-28 15:27:13 +0000 | [diff] [blame] | 130 | VisitStmt(S); |
| 131 | } |
| 132 | |
Chandler Carruth | 631abd9 | 2011-06-16 06:47:06 +0000 | [diff] [blame] | 133 | void StmtProfiler::VisitForStmt(const ForStmt *S) { |
Douglas Gregor | 4488259 | 2009-07-28 15:27:13 +0000 | [diff] [blame] | 134 | VisitStmt(S); |
| 135 | } |
| 136 | |
Chandler Carruth | 631abd9 | 2011-06-16 06:47:06 +0000 | [diff] [blame] | 137 | void StmtProfiler::VisitGotoStmt(const GotoStmt *S) { |
Douglas Gregor | 4488259 | 2009-07-28 15:27:13 +0000 | [diff] [blame] | 138 | VisitStmt(S); |
Chris Lattner | c8e630e | 2011-02-17 07:39:24 +0000 | [diff] [blame] | 139 | VisitDecl(S->getLabel()); |
Douglas Gregor | 4488259 | 2009-07-28 15:27:13 +0000 | [diff] [blame] | 140 | } |
| 141 | |
Chandler Carruth | 631abd9 | 2011-06-16 06:47:06 +0000 | [diff] [blame] | 142 | void StmtProfiler::VisitIndirectGotoStmt(const IndirectGotoStmt *S) { |
Douglas Gregor | 4488259 | 2009-07-28 15:27:13 +0000 | [diff] [blame] | 143 | VisitStmt(S); |
| 144 | } |
| 145 | |
Chandler Carruth | 631abd9 | 2011-06-16 06:47:06 +0000 | [diff] [blame] | 146 | void StmtProfiler::VisitContinueStmt(const ContinueStmt *S) { |
Douglas Gregor | 4488259 | 2009-07-28 15:27:13 +0000 | [diff] [blame] | 147 | VisitStmt(S); |
| 148 | } |
| 149 | |
Chandler Carruth | 631abd9 | 2011-06-16 06:47:06 +0000 | [diff] [blame] | 150 | void StmtProfiler::VisitBreakStmt(const BreakStmt *S) { |
Douglas Gregor | 4488259 | 2009-07-28 15:27:13 +0000 | [diff] [blame] | 151 | VisitStmt(S); |
| 152 | } |
| 153 | |
Chandler Carruth | 631abd9 | 2011-06-16 06:47:06 +0000 | [diff] [blame] | 154 | void StmtProfiler::VisitReturnStmt(const ReturnStmt *S) { |
Douglas Gregor | 4488259 | 2009-07-28 15:27:13 +0000 | [diff] [blame] | 155 | VisitStmt(S); |
| 156 | } |
| 157 | |
Chad Rosier | de70e0e | 2012-08-25 00:11:56 +0000 | [diff] [blame] | 158 | void StmtProfiler::VisitGCCAsmStmt(const GCCAsmStmt *S) { |
Douglas Gregor | 4488259 | 2009-07-28 15:27:13 +0000 | [diff] [blame] | 159 | VisitStmt(S); |
| 160 | ID.AddBoolean(S->isVolatile()); |
| 161 | ID.AddBoolean(S->isSimple()); |
| 162 | VisitStringLiteral(S->getAsmString()); |
| 163 | ID.AddInteger(S->getNumOutputs()); |
| 164 | for (unsigned I = 0, N = S->getNumOutputs(); I != N; ++I) { |
| 165 | ID.AddString(S->getOutputName(I)); |
| 166 | VisitStringLiteral(S->getOutputConstraintLiteral(I)); |
| 167 | } |
| 168 | ID.AddInteger(S->getNumInputs()); |
| 169 | for (unsigned I = 0, N = S->getNumInputs(); I != N; ++I) { |
| 170 | ID.AddString(S->getInputName(I)); |
| 171 | VisitStringLiteral(S->getInputConstraintLiteral(I)); |
| 172 | } |
| 173 | ID.AddInteger(S->getNumClobbers()); |
| 174 | for (unsigned I = 0, N = S->getNumClobbers(); I != N; ++I) |
Chad Rosier | d9fb09a | 2012-08-27 23:28:41 +0000 | [diff] [blame] | 175 | VisitStringLiteral(S->getClobberStringLiteral(I)); |
Douglas Gregor | 4488259 | 2009-07-28 15:27:13 +0000 | [diff] [blame] | 176 | } |
| 177 | |
Chad Rosier | 3250302 | 2012-06-11 20:47:18 +0000 | [diff] [blame] | 178 | void StmtProfiler::VisitMSAsmStmt(const MSAsmStmt *S) { |
| 179 | // FIXME: Implement MS style inline asm statement profiler. |
| 180 | VisitStmt(S); |
| 181 | } |
| 182 | |
Chandler Carruth | 631abd9 | 2011-06-16 06:47:06 +0000 | [diff] [blame] | 183 | void StmtProfiler::VisitCXXCatchStmt(const CXXCatchStmt *S) { |
Douglas Gregor | 4488259 | 2009-07-28 15:27:13 +0000 | [diff] [blame] | 184 | VisitStmt(S); |
| 185 | VisitType(S->getCaughtType()); |
| 186 | } |
| 187 | |
Chandler Carruth | 631abd9 | 2011-06-16 06:47:06 +0000 | [diff] [blame] | 188 | void StmtProfiler::VisitCXXTryStmt(const CXXTryStmt *S) { |
Douglas Gregor | 4488259 | 2009-07-28 15:27:13 +0000 | [diff] [blame] | 189 | VisitStmt(S); |
| 190 | } |
| 191 | |
Chandler Carruth | 631abd9 | 2011-06-16 06:47:06 +0000 | [diff] [blame] | 192 | void StmtProfiler::VisitCXXForRangeStmt(const CXXForRangeStmt *S) { |
Richard Smith | 02e85f3 | 2011-04-14 22:09:26 +0000 | [diff] [blame] | 193 | VisitStmt(S); |
| 194 | } |
| 195 | |
Douglas Gregor | deb4a2be | 2011-10-25 01:33:02 +0000 | [diff] [blame] | 196 | void StmtProfiler::VisitMSDependentExistsStmt(const MSDependentExistsStmt *S) { |
| 197 | VisitStmt(S); |
| 198 | ID.AddBoolean(S->isIfExists()); |
| 199 | VisitNestedNameSpecifier(S->getQualifierLoc().getNestedNameSpecifier()); |
| 200 | VisitName(S->getNameInfo().getName()); |
| 201 | } |
| 202 | |
Chandler Carruth | 631abd9 | 2011-06-16 06:47:06 +0000 | [diff] [blame] | 203 | void StmtProfiler::VisitSEHTryStmt(const SEHTryStmt *S) { |
John Wiegley | 1c0675e | 2011-04-28 01:08:34 +0000 | [diff] [blame] | 204 | VisitStmt(S); |
| 205 | } |
| 206 | |
Chandler Carruth | 631abd9 | 2011-06-16 06:47:06 +0000 | [diff] [blame] | 207 | void StmtProfiler::VisitSEHFinallyStmt(const SEHFinallyStmt *S) { |
John Wiegley | 1c0675e | 2011-04-28 01:08:34 +0000 | [diff] [blame] | 208 | VisitStmt(S); |
| 209 | } |
| 210 | |
Chandler Carruth | 631abd9 | 2011-06-16 06:47:06 +0000 | [diff] [blame] | 211 | void StmtProfiler::VisitSEHExceptStmt(const SEHExceptStmt *S) { |
John Wiegley | 1c0675e | 2011-04-28 01:08:34 +0000 | [diff] [blame] | 212 | VisitStmt(S); |
| 213 | } |
| 214 | |
Nico Weber | 9b98207 | 2014-07-07 00:12:30 +0000 | [diff] [blame] | 215 | void StmtProfiler::VisitSEHLeaveStmt(const SEHLeaveStmt *S) { |
| 216 | VisitStmt(S); |
| 217 | } |
| 218 | |
Tareq A. Siraj | 24110cc | 2013-04-16 18:53:08 +0000 | [diff] [blame] | 219 | void StmtProfiler::VisitCapturedStmt(const CapturedStmt *S) { |
| 220 | VisitStmt(S); |
| 221 | } |
| 222 | |
Chandler Carruth | 631abd9 | 2011-06-16 06:47:06 +0000 | [diff] [blame] | 223 | void StmtProfiler::VisitObjCForCollectionStmt(const ObjCForCollectionStmt *S) { |
Douglas Gregor | 4488259 | 2009-07-28 15:27:13 +0000 | [diff] [blame] | 224 | VisitStmt(S); |
| 225 | } |
| 226 | |
Chandler Carruth | 631abd9 | 2011-06-16 06:47:06 +0000 | [diff] [blame] | 227 | void StmtProfiler::VisitObjCAtCatchStmt(const ObjCAtCatchStmt *S) { |
Douglas Gregor | 4488259 | 2009-07-28 15:27:13 +0000 | [diff] [blame] | 228 | VisitStmt(S); |
| 229 | ID.AddBoolean(S->hasEllipsis()); |
| 230 | if (S->getCatchParamDecl()) |
| 231 | VisitType(S->getCatchParamDecl()->getType()); |
| 232 | } |
| 233 | |
Chandler Carruth | 631abd9 | 2011-06-16 06:47:06 +0000 | [diff] [blame] | 234 | void StmtProfiler::VisitObjCAtFinallyStmt(const ObjCAtFinallyStmt *S) { |
Douglas Gregor | 4488259 | 2009-07-28 15:27:13 +0000 | [diff] [blame] | 235 | VisitStmt(S); |
| 236 | } |
| 237 | |
Chandler Carruth | 631abd9 | 2011-06-16 06:47:06 +0000 | [diff] [blame] | 238 | void StmtProfiler::VisitObjCAtTryStmt(const ObjCAtTryStmt *S) { |
Douglas Gregor | 4488259 | 2009-07-28 15:27:13 +0000 | [diff] [blame] | 239 | VisitStmt(S); |
| 240 | } |
| 241 | |
Chandler Carruth | 631abd9 | 2011-06-16 06:47:06 +0000 | [diff] [blame] | 242 | void |
| 243 | StmtProfiler::VisitObjCAtSynchronizedStmt(const ObjCAtSynchronizedStmt *S) { |
Douglas Gregor | 4488259 | 2009-07-28 15:27:13 +0000 | [diff] [blame] | 244 | VisitStmt(S); |
| 245 | } |
| 246 | |
Chandler Carruth | 631abd9 | 2011-06-16 06:47:06 +0000 | [diff] [blame] | 247 | void StmtProfiler::VisitObjCAtThrowStmt(const ObjCAtThrowStmt *S) { |
Douglas Gregor | 4488259 | 2009-07-28 15:27:13 +0000 | [diff] [blame] | 248 | VisitStmt(S); |
| 249 | } |
| 250 | |
Chandler Carruth | 631abd9 | 2011-06-16 06:47:06 +0000 | [diff] [blame] | 251 | void |
| 252 | StmtProfiler::VisitObjCAutoreleasePoolStmt(const ObjCAutoreleasePoolStmt *S) { |
John McCall | 31168b0 | 2011-06-15 23:02:42 +0000 | [diff] [blame] | 253 | VisitStmt(S); |
| 254 | } |
| 255 | |
Alexey Bataev | 5ec3eb1 | 2013-07-19 03:13:43 +0000 | [diff] [blame] | 256 | namespace { |
| 257 | class OMPClauseProfiler : public ConstOMPClauseVisitor<OMPClauseProfiler> { |
| 258 | StmtProfiler *Profiler; |
Alexey Bataev | 756c196 | 2013-09-24 03:17:45 +0000 | [diff] [blame] | 259 | /// \brief Process clauses with list of variables. |
| 260 | template <typename T> |
| 261 | void VisitOMPClauseList(T *Node); |
NAKAMURA Takumi | aa13f94 | 2015-12-09 07:52:46 +0000 | [diff] [blame] | 262 | |
Alexey Bataev | 5ec3eb1 | 2013-07-19 03:13:43 +0000 | [diff] [blame] | 263 | public: |
| 264 | OMPClauseProfiler(StmtProfiler *P) : Profiler(P) { } |
| 265 | #define OPENMP_CLAUSE(Name, Class) \ |
| 266 | void Visit##Class(const Class *C); |
| 267 | #include "clang/Basic/OpenMPKinds.def" |
Alexey Bataev | 3392d76 | 2016-02-16 11:18:12 +0000 | [diff] [blame] | 268 | void VistOMPClauseWithPreInit(const OMPClauseWithPreInit *C); |
Alexey Bataev | 005248a | 2016-02-25 05:25:57 +0000 | [diff] [blame] | 269 | void VistOMPClauseWithPostUpdate(const OMPClauseWithPostUpdate *C); |
Alexey Bataev | 5ec3eb1 | 2013-07-19 03:13:43 +0000 | [diff] [blame] | 270 | }; |
| 271 | |
Alexey Bataev | 3392d76 | 2016-02-16 11:18:12 +0000 | [diff] [blame] | 272 | void OMPClauseProfiler::VistOMPClauseWithPreInit( |
| 273 | const OMPClauseWithPreInit *C) { |
| 274 | if (auto *S = C->getPreInitStmt()) |
| 275 | Profiler->VisitStmt(S); |
| 276 | } |
| 277 | |
Alexey Bataev | 005248a | 2016-02-25 05:25:57 +0000 | [diff] [blame] | 278 | void OMPClauseProfiler::VistOMPClauseWithPostUpdate( |
| 279 | const OMPClauseWithPostUpdate *C) { |
Alexey Bataev | 37e594c | 2016-03-04 07:21:16 +0000 | [diff] [blame] | 280 | VistOMPClauseWithPreInit(C); |
Alexey Bataev | 005248a | 2016-02-25 05:25:57 +0000 | [diff] [blame] | 281 | if (auto *E = C->getPostUpdateExpr()) |
| 282 | Profiler->VisitStmt(E); |
| 283 | } |
| 284 | |
Alexey Bataev | aadd52e | 2014-02-13 05:29:23 +0000 | [diff] [blame] | 285 | void OMPClauseProfiler::VisitOMPIfClause(const OMPIfClause *C) { |
Arpith Chacko Jacob | fe4890a | 2017-01-18 20:40:48 +0000 | [diff] [blame] | 286 | VistOMPClauseWithPreInit(C); |
Alexey Bataev | aadd52e | 2014-02-13 05:29:23 +0000 | [diff] [blame] | 287 | if (C->getCondition()) |
| 288 | Profiler->VisitStmt(C->getCondition()); |
| 289 | } |
| 290 | |
Alexey Bataev | 3778b60 | 2014-07-17 07:32:53 +0000 | [diff] [blame] | 291 | void OMPClauseProfiler::VisitOMPFinalClause(const OMPFinalClause *C) { |
| 292 | if (C->getCondition()) |
| 293 | Profiler->VisitStmt(C->getCondition()); |
| 294 | } |
| 295 | |
Alexey Bataev | 568a833 | 2014-03-06 06:15:19 +0000 | [diff] [blame] | 296 | void OMPClauseProfiler::VisitOMPNumThreadsClause(const OMPNumThreadsClause *C) { |
Arpith Chacko Jacob | 33c849a | 2017-01-25 00:57:16 +0000 | [diff] [blame] | 297 | VistOMPClauseWithPreInit(C); |
Alexey Bataev | 568a833 | 2014-03-06 06:15:19 +0000 | [diff] [blame] | 298 | if (C->getNumThreads()) |
| 299 | Profiler->VisitStmt(C->getNumThreads()); |
| 300 | } |
| 301 | |
Alexey Bataev | 62c87d2 | 2014-03-21 04:51:18 +0000 | [diff] [blame] | 302 | void OMPClauseProfiler::VisitOMPSafelenClause(const OMPSafelenClause *C) { |
| 303 | if (C->getSafelen()) |
| 304 | Profiler->VisitStmt(C->getSafelen()); |
| 305 | } |
| 306 | |
Alexey Bataev | 66b15b5 | 2015-08-21 11:14:16 +0000 | [diff] [blame] | 307 | void OMPClauseProfiler::VisitOMPSimdlenClause(const OMPSimdlenClause *C) { |
| 308 | if (C->getSimdlen()) |
| 309 | Profiler->VisitStmt(C->getSimdlen()); |
| 310 | } |
| 311 | |
Alexander Musman | 8bd31e6 | 2014-05-27 15:12:19 +0000 | [diff] [blame] | 312 | void OMPClauseProfiler::VisitOMPCollapseClause(const OMPCollapseClause *C) { |
| 313 | if (C->getNumForLoops()) |
| 314 | Profiler->VisitStmt(C->getNumForLoops()); |
| 315 | } |
| 316 | |
Alexey Bataev | 5ec3eb1 | 2013-07-19 03:13:43 +0000 | [diff] [blame] | 317 | void OMPClauseProfiler::VisitOMPDefaultClause(const OMPDefaultClause *C) { } |
Alexey Bataev | 756c196 | 2013-09-24 03:17:45 +0000 | [diff] [blame] | 318 | |
Alexey Bataev | bcbadb6 | 2014-05-06 06:04:14 +0000 | [diff] [blame] | 319 | void OMPClauseProfiler::VisitOMPProcBindClause(const OMPProcBindClause *C) { } |
| 320 | |
Alexey Bataev | 56dafe8 | 2014-06-20 07:16:17 +0000 | [diff] [blame] | 321 | void OMPClauseProfiler::VisitOMPScheduleClause(const OMPScheduleClause *C) { |
Alexey Bataev | 3392d76 | 2016-02-16 11:18:12 +0000 | [diff] [blame] | 322 | VistOMPClauseWithPreInit(C); |
| 323 | if (auto *S = C->getChunkSize()) |
| 324 | Profiler->VisitStmt(S); |
Alexey Bataev | 56dafe8 | 2014-06-20 07:16:17 +0000 | [diff] [blame] | 325 | } |
| 326 | |
Alexey Bataev | 10e775f | 2015-07-30 11:36:16 +0000 | [diff] [blame] | 327 | void OMPClauseProfiler::VisitOMPOrderedClause(const OMPOrderedClause *C) { |
| 328 | if (auto *Num = C->getNumForLoops()) |
| 329 | Profiler->VisitStmt(Num); |
| 330 | } |
Alexey Bataev | 142e1fc | 2014-06-20 09:44:06 +0000 | [diff] [blame] | 331 | |
Alexey Bataev | 236070f | 2014-06-20 11:19:47 +0000 | [diff] [blame] | 332 | void OMPClauseProfiler::VisitOMPNowaitClause(const OMPNowaitClause *) {} |
| 333 | |
Alexey Bataev | 7aea99a | 2014-07-17 12:19:31 +0000 | [diff] [blame] | 334 | void OMPClauseProfiler::VisitOMPUntiedClause(const OMPUntiedClause *) {} |
| 335 | |
Alexey Bataev | 74ba3a5 | 2014-07-17 12:47:03 +0000 | [diff] [blame] | 336 | void OMPClauseProfiler::VisitOMPMergeableClause(const OMPMergeableClause *) {} |
| 337 | |
Alexey Bataev | f98b00c | 2014-07-23 02:27:21 +0000 | [diff] [blame] | 338 | void OMPClauseProfiler::VisitOMPReadClause(const OMPReadClause *) {} |
| 339 | |
Alexey Bataev | dea4761 | 2014-07-23 07:46:59 +0000 | [diff] [blame] | 340 | void OMPClauseProfiler::VisitOMPWriteClause(const OMPWriteClause *) {} |
| 341 | |
Alexey Bataev | 67a4f22 | 2014-07-23 10:25:33 +0000 | [diff] [blame] | 342 | void OMPClauseProfiler::VisitOMPUpdateClause(const OMPUpdateClause *) {} |
| 343 | |
Alexey Bataev | 459dec0 | 2014-07-24 06:46:57 +0000 | [diff] [blame] | 344 | void OMPClauseProfiler::VisitOMPCaptureClause(const OMPCaptureClause *) {} |
| 345 | |
Alexey Bataev | 82bad8b | 2014-07-24 08:55:34 +0000 | [diff] [blame] | 346 | void OMPClauseProfiler::VisitOMPSeqCstClause(const OMPSeqCstClause *) {} |
| 347 | |
Alexey Bataev | 346265e | 2015-09-25 10:37:12 +0000 | [diff] [blame] | 348 | void OMPClauseProfiler::VisitOMPThreadsClause(const OMPThreadsClause *) {} |
| 349 | |
Alexey Bataev | d14d1e6 | 2015-09-28 06:39:35 +0000 | [diff] [blame] | 350 | void OMPClauseProfiler::VisitOMPSIMDClause(const OMPSIMDClause *) {} |
| 351 | |
Alexey Bataev | b825de1 | 2015-12-07 10:51:44 +0000 | [diff] [blame] | 352 | void OMPClauseProfiler::VisitOMPNogroupClause(const OMPNogroupClause *) {} |
| 353 | |
Alexey Bataev | 756c196 | 2013-09-24 03:17:45 +0000 | [diff] [blame] | 354 | template<typename T> |
| 355 | void OMPClauseProfiler::VisitOMPClauseList(T *Node) { |
Alexey Bataev | 03b340a | 2014-10-21 03:16:40 +0000 | [diff] [blame] | 356 | for (auto *E : Node->varlists()) { |
Richard Trieu | 6a77a1c | 2016-06-10 04:52:09 +0000 | [diff] [blame] | 357 | if (E) |
| 358 | Profiler->VisitStmt(E); |
Alexey Bataev | 03b340a | 2014-10-21 03:16:40 +0000 | [diff] [blame] | 359 | } |
Alexey Bataev | 756c196 | 2013-09-24 03:17:45 +0000 | [diff] [blame] | 360 | } |
Alexey Bataev | 5ec3eb1 | 2013-07-19 03:13:43 +0000 | [diff] [blame] | 361 | |
| 362 | void OMPClauseProfiler::VisitOMPPrivateClause(const OMPPrivateClause *C) { |
Alexey Bataev | 756c196 | 2013-09-24 03:17:45 +0000 | [diff] [blame] | 363 | VisitOMPClauseList(C); |
Alexey Bataev | 03b340a | 2014-10-21 03:16:40 +0000 | [diff] [blame] | 364 | for (auto *E : C->private_copies()) { |
Richard Trieu | 6a77a1c | 2016-06-10 04:52:09 +0000 | [diff] [blame] | 365 | if (E) |
| 366 | Profiler->VisitStmt(E); |
Alexey Bataev | 03b340a | 2014-10-21 03:16:40 +0000 | [diff] [blame] | 367 | } |
Alexey Bataev | 5ec3eb1 | 2013-07-19 03:13:43 +0000 | [diff] [blame] | 368 | } |
Alexey Bataev | 4a5bb77 | 2014-10-08 14:01:46 +0000 | [diff] [blame] | 369 | void |
| 370 | OMPClauseProfiler::VisitOMPFirstprivateClause(const OMPFirstprivateClause *C) { |
Alexey Bataev | d5af8e4 | 2013-10-01 05:32:34 +0000 | [diff] [blame] | 371 | VisitOMPClauseList(C); |
Alexey Bataev | 417089f | 2016-02-17 13:19:37 +0000 | [diff] [blame] | 372 | VistOMPClauseWithPreInit(C); |
Alexey Bataev | 4a5bb77 | 2014-10-08 14:01:46 +0000 | [diff] [blame] | 373 | for (auto *E : C->private_copies()) { |
Richard Trieu | 6a77a1c | 2016-06-10 04:52:09 +0000 | [diff] [blame] | 374 | if (E) |
| 375 | Profiler->VisitStmt(E); |
Alexey Bataev | 4a5bb77 | 2014-10-08 14:01:46 +0000 | [diff] [blame] | 376 | } |
| 377 | for (auto *E : C->inits()) { |
Richard Trieu | 6a77a1c | 2016-06-10 04:52:09 +0000 | [diff] [blame] | 378 | if (E) |
| 379 | Profiler->VisitStmt(E); |
Alexey Bataev | 4a5bb77 | 2014-10-08 14:01:46 +0000 | [diff] [blame] | 380 | } |
Alexey Bataev | d5af8e4 | 2013-10-01 05:32:34 +0000 | [diff] [blame] | 381 | } |
Alexander Musman | 1bb328c | 2014-06-04 13:06:39 +0000 | [diff] [blame] | 382 | void |
| 383 | OMPClauseProfiler::VisitOMPLastprivateClause(const OMPLastprivateClause *C) { |
| 384 | VisitOMPClauseList(C); |
Alexey Bataev | 005248a | 2016-02-25 05:25:57 +0000 | [diff] [blame] | 385 | VistOMPClauseWithPostUpdate(C); |
Alexey Bataev | 38e8953 | 2015-04-16 04:54:05 +0000 | [diff] [blame] | 386 | for (auto *E : C->source_exprs()) { |
Richard Trieu | 6a77a1c | 2016-06-10 04:52:09 +0000 | [diff] [blame] | 387 | if (E) |
| 388 | Profiler->VisitStmt(E); |
Alexey Bataev | 38e8953 | 2015-04-16 04:54:05 +0000 | [diff] [blame] | 389 | } |
| 390 | for (auto *E : C->destination_exprs()) { |
Richard Trieu | 6a77a1c | 2016-06-10 04:52:09 +0000 | [diff] [blame] | 391 | if (E) |
| 392 | Profiler->VisitStmt(E); |
Alexey Bataev | 38e8953 | 2015-04-16 04:54:05 +0000 | [diff] [blame] | 393 | } |
| 394 | for (auto *E : C->assignment_ops()) { |
Richard Trieu | 6a77a1c | 2016-06-10 04:52:09 +0000 | [diff] [blame] | 395 | if (E) |
| 396 | Profiler->VisitStmt(E); |
Alexey Bataev | 38e8953 | 2015-04-16 04:54:05 +0000 | [diff] [blame] | 397 | } |
Alexander Musman | 1bb328c | 2014-06-04 13:06:39 +0000 | [diff] [blame] | 398 | } |
Alexey Bataev | 758e55e | 2013-09-06 18:03:48 +0000 | [diff] [blame] | 399 | void OMPClauseProfiler::VisitOMPSharedClause(const OMPSharedClause *C) { |
Alexey Bataev | 756c196 | 2013-09-24 03:17:45 +0000 | [diff] [blame] | 400 | VisitOMPClauseList(C); |
Alexey Bataev | 758e55e | 2013-09-06 18:03:48 +0000 | [diff] [blame] | 401 | } |
Alexey Bataev | c5e0258 | 2014-06-16 07:08:35 +0000 | [diff] [blame] | 402 | void OMPClauseProfiler::VisitOMPReductionClause( |
| 403 | const OMPReductionClause *C) { |
| 404 | Profiler->VisitNestedNameSpecifier( |
| 405 | C->getQualifierLoc().getNestedNameSpecifier()); |
| 406 | Profiler->VisitName(C->getNameInfo().getName()); |
| 407 | VisitOMPClauseList(C); |
Alexey Bataev | 6120507 | 2016-03-02 04:57:40 +0000 | [diff] [blame] | 408 | VistOMPClauseWithPostUpdate(C); |
Alexey Bataev | f24e7b1 | 2015-10-08 09:10:53 +0000 | [diff] [blame] | 409 | for (auto *E : C->privates()) { |
Richard Trieu | 6a77a1c | 2016-06-10 04:52:09 +0000 | [diff] [blame] | 410 | if (E) |
| 411 | Profiler->VisitStmt(E); |
Alexey Bataev | f24e7b1 | 2015-10-08 09:10:53 +0000 | [diff] [blame] | 412 | } |
Alexey Bataev | 794ba0d | 2015-04-10 10:43:45 +0000 | [diff] [blame] | 413 | for (auto *E : C->lhs_exprs()) { |
Richard Trieu | 6a77a1c | 2016-06-10 04:52:09 +0000 | [diff] [blame] | 414 | if (E) |
| 415 | Profiler->VisitStmt(E); |
Alexey Bataev | 794ba0d | 2015-04-10 10:43:45 +0000 | [diff] [blame] | 416 | } |
| 417 | for (auto *E : C->rhs_exprs()) { |
Richard Trieu | 6a77a1c | 2016-06-10 04:52:09 +0000 | [diff] [blame] | 418 | if (E) |
| 419 | Profiler->VisitStmt(E); |
Alexey Bataev | 794ba0d | 2015-04-10 10:43:45 +0000 | [diff] [blame] | 420 | } |
| 421 | for (auto *E : C->reduction_ops()) { |
Richard Trieu | 6a77a1c | 2016-06-10 04:52:09 +0000 | [diff] [blame] | 422 | if (E) |
| 423 | Profiler->VisitStmt(E); |
Alexey Bataev | 794ba0d | 2015-04-10 10:43:45 +0000 | [diff] [blame] | 424 | } |
Alexey Bataev | c5e0258 | 2014-06-16 07:08:35 +0000 | [diff] [blame] | 425 | } |
Alexander Musman | 8dba664 | 2014-04-22 13:09:42 +0000 | [diff] [blame] | 426 | void OMPClauseProfiler::VisitOMPLinearClause(const OMPLinearClause *C) { |
| 427 | VisitOMPClauseList(C); |
Alexey Bataev | 78849fb | 2016-03-09 09:49:00 +0000 | [diff] [blame] | 428 | VistOMPClauseWithPostUpdate(C); |
Alexey Bataev | bd9fec1 | 2015-08-18 06:47:21 +0000 | [diff] [blame] | 429 | for (auto *E : C->privates()) { |
Richard Trieu | 6a77a1c | 2016-06-10 04:52:09 +0000 | [diff] [blame] | 430 | if (E) |
| 431 | Profiler->VisitStmt(E); |
Alexey Bataev | bd9fec1 | 2015-08-18 06:47:21 +0000 | [diff] [blame] | 432 | } |
Alexander Musman | 3276a27 | 2015-03-21 10:12:56 +0000 | [diff] [blame] | 433 | for (auto *E : C->inits()) { |
Richard Trieu | 6a77a1c | 2016-06-10 04:52:09 +0000 | [diff] [blame] | 434 | if (E) |
| 435 | Profiler->VisitStmt(E); |
Alexander Musman | 3276a27 | 2015-03-21 10:12:56 +0000 | [diff] [blame] | 436 | } |
| 437 | for (auto *E : C->updates()) { |
Richard Trieu | 6a77a1c | 2016-06-10 04:52:09 +0000 | [diff] [blame] | 438 | if (E) |
| 439 | Profiler->VisitStmt(E); |
Alexander Musman | 3276a27 | 2015-03-21 10:12:56 +0000 | [diff] [blame] | 440 | } |
| 441 | for (auto *E : C->finals()) { |
Richard Trieu | 6a77a1c | 2016-06-10 04:52:09 +0000 | [diff] [blame] | 442 | if (E) |
| 443 | Profiler->VisitStmt(E); |
Alexander Musman | 3276a27 | 2015-03-21 10:12:56 +0000 | [diff] [blame] | 444 | } |
Richard Trieu | 6a77a1c | 2016-06-10 04:52:09 +0000 | [diff] [blame] | 445 | if (C->getStep()) |
| 446 | Profiler->VisitStmt(C->getStep()); |
| 447 | if (C->getCalcStep()) |
| 448 | Profiler->VisitStmt(C->getCalcStep()); |
Alexander Musman | 8dba664 | 2014-04-22 13:09:42 +0000 | [diff] [blame] | 449 | } |
Alexander Musman | f0d76e7 | 2014-05-29 14:36:25 +0000 | [diff] [blame] | 450 | void OMPClauseProfiler::VisitOMPAlignedClause(const OMPAlignedClause *C) { |
| 451 | VisitOMPClauseList(C); |
Richard Trieu | 6a77a1c | 2016-06-10 04:52:09 +0000 | [diff] [blame] | 452 | if (C->getAlignment()) |
| 453 | Profiler->VisitStmt(C->getAlignment()); |
Alexander Musman | f0d76e7 | 2014-05-29 14:36:25 +0000 | [diff] [blame] | 454 | } |
Alexey Bataev | d48bcd8 | 2014-03-31 03:36:38 +0000 | [diff] [blame] | 455 | void OMPClauseProfiler::VisitOMPCopyinClause(const OMPCopyinClause *C) { |
| 456 | VisitOMPClauseList(C); |
Alexey Bataev | f56f98c | 2015-04-16 05:39:01 +0000 | [diff] [blame] | 457 | for (auto *E : C->source_exprs()) { |
Richard Trieu | 6a77a1c | 2016-06-10 04:52:09 +0000 | [diff] [blame] | 458 | if (E) |
| 459 | Profiler->VisitStmt(E); |
Alexey Bataev | f56f98c | 2015-04-16 05:39:01 +0000 | [diff] [blame] | 460 | } |
| 461 | for (auto *E : C->destination_exprs()) { |
Richard Trieu | 6a77a1c | 2016-06-10 04:52:09 +0000 | [diff] [blame] | 462 | if (E) |
| 463 | Profiler->VisitStmt(E); |
Alexey Bataev | f56f98c | 2015-04-16 05:39:01 +0000 | [diff] [blame] | 464 | } |
| 465 | for (auto *E : C->assignment_ops()) { |
Richard Trieu | 6a77a1c | 2016-06-10 04:52:09 +0000 | [diff] [blame] | 466 | if (E) |
| 467 | Profiler->VisitStmt(E); |
Alexey Bataev | f56f98c | 2015-04-16 05:39:01 +0000 | [diff] [blame] | 468 | } |
Alexey Bataev | d48bcd8 | 2014-03-31 03:36:38 +0000 | [diff] [blame] | 469 | } |
Alexey Bataev | bae9a79 | 2014-06-27 10:37:06 +0000 | [diff] [blame] | 470 | void |
| 471 | OMPClauseProfiler::VisitOMPCopyprivateClause(const OMPCopyprivateClause *C) { |
| 472 | VisitOMPClauseList(C); |
Alexey Bataev | a63048e | 2015-03-23 06:18:07 +0000 | [diff] [blame] | 473 | for (auto *E : C->source_exprs()) { |
Richard Trieu | 6a77a1c | 2016-06-10 04:52:09 +0000 | [diff] [blame] | 474 | if (E) |
| 475 | Profiler->VisitStmt(E); |
Alexey Bataev | a63048e | 2015-03-23 06:18:07 +0000 | [diff] [blame] | 476 | } |
| 477 | for (auto *E : C->destination_exprs()) { |
Richard Trieu | 6a77a1c | 2016-06-10 04:52:09 +0000 | [diff] [blame] | 478 | if (E) |
| 479 | Profiler->VisitStmt(E); |
Alexey Bataev | a63048e | 2015-03-23 06:18:07 +0000 | [diff] [blame] | 480 | } |
| 481 | for (auto *E : C->assignment_ops()) { |
Richard Trieu | 6a77a1c | 2016-06-10 04:52:09 +0000 | [diff] [blame] | 482 | if (E) |
| 483 | Profiler->VisitStmt(E); |
Alexey Bataev | a63048e | 2015-03-23 06:18:07 +0000 | [diff] [blame] | 484 | } |
Alexey Bataev | bae9a79 | 2014-06-27 10:37:06 +0000 | [diff] [blame] | 485 | } |
Alexey Bataev | 6125da9 | 2014-07-21 11:26:11 +0000 | [diff] [blame] | 486 | void OMPClauseProfiler::VisitOMPFlushClause(const OMPFlushClause *C) { |
| 487 | VisitOMPClauseList(C); |
| 488 | } |
Alexey Bataev | 1c2cfbc | 2015-06-23 14:25:19 +0000 | [diff] [blame] | 489 | void OMPClauseProfiler::VisitOMPDependClause(const OMPDependClause *C) { |
| 490 | VisitOMPClauseList(C); |
| 491 | } |
Michael Wong | e710d54 | 2015-08-07 16:16:36 +0000 | [diff] [blame] | 492 | void OMPClauseProfiler::VisitOMPDeviceClause(const OMPDeviceClause *C) { |
Richard Trieu | 6a77a1c | 2016-06-10 04:52:09 +0000 | [diff] [blame] | 493 | if (C->getDevice()) |
| 494 | Profiler->VisitStmt(C->getDevice()); |
Michael Wong | e710d54 | 2015-08-07 16:16:36 +0000 | [diff] [blame] | 495 | } |
Kelvin Li | 0bff7af | 2015-11-23 05:32:03 +0000 | [diff] [blame] | 496 | void OMPClauseProfiler::VisitOMPMapClause(const OMPMapClause *C) { |
| 497 | VisitOMPClauseList(C); |
| 498 | } |
Kelvin Li | 099bb8c | 2015-11-24 20:50:12 +0000 | [diff] [blame] | 499 | void OMPClauseProfiler::VisitOMPNumTeamsClause(const OMPNumTeamsClause *C) { |
Arpith Chacko Jacob | bc12634 | 2017-01-25 11:28:18 +0000 | [diff] [blame^] | 500 | VistOMPClauseWithPreInit(C); |
Richard Trieu | 6a77a1c | 2016-06-10 04:52:09 +0000 | [diff] [blame] | 501 | if (C->getNumTeams()) |
| 502 | Profiler->VisitStmt(C->getNumTeams()); |
Kelvin Li | 099bb8c | 2015-11-24 20:50:12 +0000 | [diff] [blame] | 503 | } |
Kelvin Li | a15fb1a | 2015-11-27 18:47:36 +0000 | [diff] [blame] | 504 | void OMPClauseProfiler::VisitOMPThreadLimitClause( |
| 505 | const OMPThreadLimitClause *C) { |
Richard Trieu | 6a77a1c | 2016-06-10 04:52:09 +0000 | [diff] [blame] | 506 | if (C->getThreadLimit()) |
| 507 | Profiler->VisitStmt(C->getThreadLimit()); |
Kelvin Li | a15fb1a | 2015-11-27 18:47:36 +0000 | [diff] [blame] | 508 | } |
Alexey Bataev | a056935 | 2015-12-01 10:17:31 +0000 | [diff] [blame] | 509 | void OMPClauseProfiler::VisitOMPPriorityClause(const OMPPriorityClause *C) { |
Richard Trieu | 6a77a1c | 2016-06-10 04:52:09 +0000 | [diff] [blame] | 510 | if (C->getPriority()) |
| 511 | Profiler->VisitStmt(C->getPriority()); |
Alexey Bataev | a056935 | 2015-12-01 10:17:31 +0000 | [diff] [blame] | 512 | } |
Alexey Bataev | 1fd4aed | 2015-12-07 12:52:51 +0000 | [diff] [blame] | 513 | void OMPClauseProfiler::VisitOMPGrainsizeClause(const OMPGrainsizeClause *C) { |
Richard Trieu | 6a77a1c | 2016-06-10 04:52:09 +0000 | [diff] [blame] | 514 | if (C->getGrainsize()) |
| 515 | Profiler->VisitStmt(C->getGrainsize()); |
Alexey Bataev | 1fd4aed | 2015-12-07 12:52:51 +0000 | [diff] [blame] | 516 | } |
Alexey Bataev | 382967a | 2015-12-08 12:06:20 +0000 | [diff] [blame] | 517 | void OMPClauseProfiler::VisitOMPNumTasksClause(const OMPNumTasksClause *C) { |
Richard Trieu | 6a77a1c | 2016-06-10 04:52:09 +0000 | [diff] [blame] | 518 | if (C->getNumTasks()) |
| 519 | Profiler->VisitStmt(C->getNumTasks()); |
Alexey Bataev | 382967a | 2015-12-08 12:06:20 +0000 | [diff] [blame] | 520 | } |
Alexey Bataev | 28c7541 | 2015-12-15 08:19:24 +0000 | [diff] [blame] | 521 | void OMPClauseProfiler::VisitOMPHintClause(const OMPHintClause *C) { |
Richard Trieu | 6a77a1c | 2016-06-10 04:52:09 +0000 | [diff] [blame] | 522 | if (C->getHint()) |
| 523 | Profiler->VisitStmt(C->getHint()); |
Alexey Bataev | 28c7541 | 2015-12-15 08:19:24 +0000 | [diff] [blame] | 524 | } |
Samuel Antao | 661c090 | 2016-05-26 17:39:58 +0000 | [diff] [blame] | 525 | void OMPClauseProfiler::VisitOMPToClause(const OMPToClause *C) { |
| 526 | VisitOMPClauseList(C); |
| 527 | } |
Samuel Antao | ec172c6 | 2016-05-26 17:49:04 +0000 | [diff] [blame] | 528 | void OMPClauseProfiler::VisitOMPFromClause(const OMPFromClause *C) { |
| 529 | VisitOMPClauseList(C); |
| 530 | } |
Carlo Bertolli | 2404b17 | 2016-07-13 15:37:16 +0000 | [diff] [blame] | 531 | void OMPClauseProfiler::VisitOMPUseDevicePtrClause( |
| 532 | const OMPUseDevicePtrClause *C) { |
| 533 | VisitOMPClauseList(C); |
| 534 | } |
Carlo Bertolli | 70594e9 | 2016-07-13 17:16:49 +0000 | [diff] [blame] | 535 | void OMPClauseProfiler::VisitOMPIsDevicePtrClause( |
| 536 | const OMPIsDevicePtrClause *C) { |
| 537 | VisitOMPClauseList(C); |
| 538 | } |
Alexander Kornienko | ab9db51 | 2015-06-22 23:07:51 +0000 | [diff] [blame] | 539 | } |
Alexey Bataev | 5ec3eb1 | 2013-07-19 03:13:43 +0000 | [diff] [blame] | 540 | |
| 541 | void |
Alexey Bataev | 1b59ab5 | 2014-02-27 08:29:12 +0000 | [diff] [blame] | 542 | StmtProfiler::VisitOMPExecutableDirective(const OMPExecutableDirective *S) { |
Alexey Bataev | 5ec3eb1 | 2013-07-19 03:13:43 +0000 | [diff] [blame] | 543 | VisitStmt(S); |
| 544 | OMPClauseProfiler P(this); |
| 545 | ArrayRef<OMPClause *> Clauses = S->clauses(); |
| 546 | for (ArrayRef<OMPClause *>::iterator I = Clauses.begin(), E = Clauses.end(); |
| 547 | I != E; ++I) |
| 548 | if (*I) |
| 549 | P.Visit(*I); |
| 550 | } |
| 551 | |
Alexander Musman | 3aaab66 | 2014-08-19 11:27:13 +0000 | [diff] [blame] | 552 | void StmtProfiler::VisitOMPLoopDirective(const OMPLoopDirective *S) { |
| 553 | VisitOMPExecutableDirective(S); |
| 554 | } |
| 555 | |
Alexey Bataev | 1b59ab5 | 2014-02-27 08:29:12 +0000 | [diff] [blame] | 556 | void StmtProfiler::VisitOMPParallelDirective(const OMPParallelDirective *S) { |
| 557 | VisitOMPExecutableDirective(S); |
| 558 | } |
| 559 | |
| 560 | void StmtProfiler::VisitOMPSimdDirective(const OMPSimdDirective *S) { |
Alexander Musman | 3aaab66 | 2014-08-19 11:27:13 +0000 | [diff] [blame] | 561 | VisitOMPLoopDirective(S); |
Alexey Bataev | 1b59ab5 | 2014-02-27 08:29:12 +0000 | [diff] [blame] | 562 | } |
| 563 | |
Alexey Bataev | f29276e | 2014-06-18 04:14:57 +0000 | [diff] [blame] | 564 | void StmtProfiler::VisitOMPForDirective(const OMPForDirective *S) { |
Alexander Musman | 3aaab66 | 2014-08-19 11:27:13 +0000 | [diff] [blame] | 565 | VisitOMPLoopDirective(S); |
Alexey Bataev | f29276e | 2014-06-18 04:14:57 +0000 | [diff] [blame] | 566 | } |
| 567 | |
Alexander Musman | f82886e | 2014-09-18 05:12:34 +0000 | [diff] [blame] | 568 | void StmtProfiler::VisitOMPForSimdDirective(const OMPForSimdDirective *S) { |
| 569 | VisitOMPLoopDirective(S); |
| 570 | } |
| 571 | |
Alexey Bataev | d3f8dd2 | 2014-06-25 11:44:49 +0000 | [diff] [blame] | 572 | void StmtProfiler::VisitOMPSectionsDirective(const OMPSectionsDirective *S) { |
| 573 | VisitOMPExecutableDirective(S); |
| 574 | } |
| 575 | |
Alexey Bataev | 1e0498a | 2014-06-26 08:21:58 +0000 | [diff] [blame] | 576 | void StmtProfiler::VisitOMPSectionDirective(const OMPSectionDirective *S) { |
| 577 | VisitOMPExecutableDirective(S); |
| 578 | } |
| 579 | |
Alexey Bataev | d1e40fb | 2014-06-26 12:05:45 +0000 | [diff] [blame] | 580 | void StmtProfiler::VisitOMPSingleDirective(const OMPSingleDirective *S) { |
| 581 | VisitOMPExecutableDirective(S); |
| 582 | } |
| 583 | |
Alexander Musman | 80c2289 | 2014-07-17 08:54:58 +0000 | [diff] [blame] | 584 | void StmtProfiler::VisitOMPMasterDirective(const OMPMasterDirective *S) { |
| 585 | VisitOMPExecutableDirective(S); |
| 586 | } |
| 587 | |
Alexander Musman | d9ed09f | 2014-07-21 09:42:05 +0000 | [diff] [blame] | 588 | void StmtProfiler::VisitOMPCriticalDirective(const OMPCriticalDirective *S) { |
| 589 | VisitOMPExecutableDirective(S); |
| 590 | VisitName(S->getDirectiveName().getName()); |
| 591 | } |
| 592 | |
Alexey Bataev | 4acb859 | 2014-07-07 13:01:15 +0000 | [diff] [blame] | 593 | void |
| 594 | StmtProfiler::VisitOMPParallelForDirective(const OMPParallelForDirective *S) { |
Alexander Musman | 3aaab66 | 2014-08-19 11:27:13 +0000 | [diff] [blame] | 595 | VisitOMPLoopDirective(S); |
Alexey Bataev | 4acb859 | 2014-07-07 13:01:15 +0000 | [diff] [blame] | 596 | } |
| 597 | |
Alexander Musman | e4e893b | 2014-09-23 09:33:00 +0000 | [diff] [blame] | 598 | void StmtProfiler::VisitOMPParallelForSimdDirective( |
| 599 | const OMPParallelForSimdDirective *S) { |
| 600 | VisitOMPLoopDirective(S); |
| 601 | } |
| 602 | |
Alexey Bataev | 84d0b3e | 2014-07-08 08:12:03 +0000 | [diff] [blame] | 603 | void StmtProfiler::VisitOMPParallelSectionsDirective( |
| 604 | const OMPParallelSectionsDirective *S) { |
| 605 | VisitOMPExecutableDirective(S); |
| 606 | } |
| 607 | |
Alexey Bataev | 9c2e8ee | 2014-07-11 11:25:16 +0000 | [diff] [blame] | 608 | void StmtProfiler::VisitOMPTaskDirective(const OMPTaskDirective *S) { |
| 609 | VisitOMPExecutableDirective(S); |
| 610 | } |
| 611 | |
Alexey Bataev | 68446b7 | 2014-07-18 07:47:19 +0000 | [diff] [blame] | 612 | void StmtProfiler::VisitOMPTaskyieldDirective(const OMPTaskyieldDirective *S) { |
| 613 | VisitOMPExecutableDirective(S); |
| 614 | } |
| 615 | |
Alexey Bataev | 4d1dfea | 2014-07-18 09:11:51 +0000 | [diff] [blame] | 616 | void StmtProfiler::VisitOMPBarrierDirective(const OMPBarrierDirective *S) { |
| 617 | VisitOMPExecutableDirective(S); |
| 618 | } |
| 619 | |
Alexey Bataev | 2df347a | 2014-07-18 10:17:07 +0000 | [diff] [blame] | 620 | void StmtProfiler::VisitOMPTaskwaitDirective(const OMPTaskwaitDirective *S) { |
| 621 | VisitOMPExecutableDirective(S); |
| 622 | } |
| 623 | |
Alexey Bataev | c30dd2d | 2015-06-18 12:14:09 +0000 | [diff] [blame] | 624 | void StmtProfiler::VisitOMPTaskgroupDirective(const OMPTaskgroupDirective *S) { |
| 625 | VisitOMPExecutableDirective(S); |
| 626 | } |
| 627 | |
Alexey Bataev | 6125da9 | 2014-07-21 11:26:11 +0000 | [diff] [blame] | 628 | void StmtProfiler::VisitOMPFlushDirective(const OMPFlushDirective *S) { |
| 629 | VisitOMPExecutableDirective(S); |
| 630 | } |
| 631 | |
Alexey Bataev | 9fb6e64 | 2014-07-22 06:45:04 +0000 | [diff] [blame] | 632 | void StmtProfiler::VisitOMPOrderedDirective(const OMPOrderedDirective *S) { |
| 633 | VisitOMPExecutableDirective(S); |
| 634 | } |
| 635 | |
Alexey Bataev | 0162e45 | 2014-07-22 10:10:35 +0000 | [diff] [blame] | 636 | void StmtProfiler::VisitOMPAtomicDirective(const OMPAtomicDirective *S) { |
| 637 | VisitOMPExecutableDirective(S); |
| 638 | } |
| 639 | |
Alexey Bataev | 0bd520b | 2014-09-19 08:19:49 +0000 | [diff] [blame] | 640 | void StmtProfiler::VisitOMPTargetDirective(const OMPTargetDirective *S) { |
| 641 | VisitOMPExecutableDirective(S); |
| 642 | } |
| 643 | |
Michael Wong | 65f367f | 2015-07-21 13:44:28 +0000 | [diff] [blame] | 644 | void StmtProfiler::VisitOMPTargetDataDirective(const OMPTargetDataDirective *S) { |
| 645 | VisitOMPExecutableDirective(S); |
| 646 | } |
| 647 | |
Samuel Antao | df67fc4 | 2016-01-19 19:15:56 +0000 | [diff] [blame] | 648 | void StmtProfiler::VisitOMPTargetEnterDataDirective( |
| 649 | const OMPTargetEnterDataDirective *S) { |
| 650 | VisitOMPExecutableDirective(S); |
| 651 | } |
| 652 | |
Samuel Antao | 7259076 | 2016-01-19 20:04:50 +0000 | [diff] [blame] | 653 | void StmtProfiler::VisitOMPTargetExitDataDirective( |
| 654 | const OMPTargetExitDataDirective *S) { |
| 655 | VisitOMPExecutableDirective(S); |
| 656 | } |
| 657 | |
Arpith Chacko Jacob | e955b3d | 2016-01-26 18:48:41 +0000 | [diff] [blame] | 658 | void StmtProfiler::VisitOMPTargetParallelDirective( |
| 659 | const OMPTargetParallelDirective *S) { |
| 660 | VisitOMPExecutableDirective(S); |
| 661 | } |
| 662 | |
Arpith Chacko Jacob | 05bebb5 | 2016-02-03 15:46:42 +0000 | [diff] [blame] | 663 | void StmtProfiler::VisitOMPTargetParallelForDirective( |
| 664 | const OMPTargetParallelForDirective *S) { |
| 665 | VisitOMPExecutableDirective(S); |
| 666 | } |
| 667 | |
Alexey Bataev | 13314bf | 2014-10-09 04:18:56 +0000 | [diff] [blame] | 668 | void StmtProfiler::VisitOMPTeamsDirective(const OMPTeamsDirective *S) { |
| 669 | VisitOMPExecutableDirective(S); |
| 670 | } |
| 671 | |
Alexey Bataev | 6d4ed05 | 2015-07-01 06:57:41 +0000 | [diff] [blame] | 672 | void StmtProfiler::VisitOMPCancellationPointDirective( |
| 673 | const OMPCancellationPointDirective *S) { |
| 674 | VisitOMPExecutableDirective(S); |
| 675 | } |
| 676 | |
Alexey Bataev | 8090987 | 2015-07-02 11:25:17 +0000 | [diff] [blame] | 677 | void StmtProfiler::VisitOMPCancelDirective(const OMPCancelDirective *S) { |
| 678 | VisitOMPExecutableDirective(S); |
| 679 | } |
| 680 | |
Alexey Bataev | 49f6e78 | 2015-12-01 04:18:41 +0000 | [diff] [blame] | 681 | void StmtProfiler::VisitOMPTaskLoopDirective(const OMPTaskLoopDirective *S) { |
| 682 | VisitOMPLoopDirective(S); |
| 683 | } |
| 684 | |
Alexey Bataev | 0a6ed84 | 2015-12-03 09:40:15 +0000 | [diff] [blame] | 685 | void StmtProfiler::VisitOMPTaskLoopSimdDirective( |
| 686 | const OMPTaskLoopSimdDirective *S) { |
| 687 | VisitOMPLoopDirective(S); |
| 688 | } |
| 689 | |
Carlo Bertolli | 6200a3d | 2015-12-14 14:51:25 +0000 | [diff] [blame] | 690 | void StmtProfiler::VisitOMPDistributeDirective( |
| 691 | const OMPDistributeDirective *S) { |
| 692 | VisitOMPLoopDirective(S); |
| 693 | } |
| 694 | |
Carlo Bertolli | b4adf55 | 2016-01-15 18:50:31 +0000 | [diff] [blame] | 695 | void OMPClauseProfiler::VisitOMPDistScheduleClause( |
| 696 | const OMPDistScheduleClause *C) { |
Alexey Bataev | 3392d76 | 2016-02-16 11:18:12 +0000 | [diff] [blame] | 697 | VistOMPClauseWithPreInit(C); |
| 698 | if (auto *S = C->getChunkSize()) |
| 699 | Profiler->VisitStmt(S); |
Carlo Bertolli | b4adf55 | 2016-01-15 18:50:31 +0000 | [diff] [blame] | 700 | } |
| 701 | |
Arpith Chacko Jacob | 3cf8904 | 2016-01-26 16:37:23 +0000 | [diff] [blame] | 702 | void OMPClauseProfiler::VisitOMPDefaultmapClause(const OMPDefaultmapClause *) {} |
| 703 | |
Samuel Antao | 686c70c | 2016-05-26 17:30:50 +0000 | [diff] [blame] | 704 | void StmtProfiler::VisitOMPTargetUpdateDirective( |
| 705 | const OMPTargetUpdateDirective *S) { |
| 706 | VisitOMPExecutableDirective(S); |
| 707 | } |
| 708 | |
Carlo Bertolli | 9925f15 | 2016-06-27 14:55:37 +0000 | [diff] [blame] | 709 | void StmtProfiler::VisitOMPDistributeParallelForDirective( |
| 710 | const OMPDistributeParallelForDirective *S) { |
| 711 | VisitOMPLoopDirective(S); |
| 712 | } |
| 713 | |
Kelvin Li | 4a39add | 2016-07-05 05:00:15 +0000 | [diff] [blame] | 714 | void StmtProfiler::VisitOMPDistributeParallelForSimdDirective( |
| 715 | const OMPDistributeParallelForSimdDirective *S) { |
| 716 | VisitOMPLoopDirective(S); |
| 717 | } |
| 718 | |
Kelvin Li | 787f3fc | 2016-07-06 04:45:38 +0000 | [diff] [blame] | 719 | void StmtProfiler::VisitOMPDistributeSimdDirective( |
| 720 | const OMPDistributeSimdDirective *S) { |
| 721 | VisitOMPLoopDirective(S); |
| 722 | } |
| 723 | |
Kelvin Li | a579b91 | 2016-07-14 02:54:56 +0000 | [diff] [blame] | 724 | void StmtProfiler::VisitOMPTargetParallelForSimdDirective( |
| 725 | const OMPTargetParallelForSimdDirective *S) { |
| 726 | VisitOMPLoopDirective(S); |
| 727 | } |
| 728 | |
Kelvin Li | 986330c | 2016-07-20 22:57:10 +0000 | [diff] [blame] | 729 | void StmtProfiler::VisitOMPTargetSimdDirective( |
| 730 | const OMPTargetSimdDirective *S) { |
| 731 | VisitOMPLoopDirective(S); |
| 732 | } |
| 733 | |
Kelvin Li | 0253287 | 2016-08-05 14:37:37 +0000 | [diff] [blame] | 734 | void StmtProfiler::VisitOMPTeamsDistributeDirective( |
| 735 | const OMPTeamsDistributeDirective *S) { |
| 736 | VisitOMPLoopDirective(S); |
| 737 | } |
| 738 | |
Kelvin Li | 4e325f7 | 2016-10-25 12:50:55 +0000 | [diff] [blame] | 739 | void StmtProfiler::VisitOMPTeamsDistributeSimdDirective( |
| 740 | const OMPTeamsDistributeSimdDirective *S) { |
| 741 | VisitOMPLoopDirective(S); |
| 742 | } |
| 743 | |
Kelvin Li | 579e41c | 2016-11-30 23:51:03 +0000 | [diff] [blame] | 744 | void StmtProfiler::VisitOMPTeamsDistributeParallelForSimdDirective( |
| 745 | const OMPTeamsDistributeParallelForSimdDirective *S) { |
| 746 | VisitOMPLoopDirective(S); |
| 747 | } |
| 748 | |
Kelvin Li | 7ade93f | 2016-12-09 03:24:30 +0000 | [diff] [blame] | 749 | void StmtProfiler::VisitOMPTeamsDistributeParallelForDirective( |
| 750 | const OMPTeamsDistributeParallelForDirective *S) { |
| 751 | VisitOMPLoopDirective(S); |
| 752 | } |
| 753 | |
Kelvin Li | bf594a5 | 2016-12-17 05:48:59 +0000 | [diff] [blame] | 754 | void StmtProfiler::VisitOMPTargetTeamsDirective( |
| 755 | const OMPTargetTeamsDirective *S) { |
| 756 | VisitOMPExecutableDirective(S); |
| 757 | } |
| 758 | |
Kelvin Li | 83c451e | 2016-12-25 04:52:54 +0000 | [diff] [blame] | 759 | void StmtProfiler::VisitOMPTargetTeamsDistributeDirective( |
| 760 | const OMPTargetTeamsDistributeDirective *S) { |
| 761 | VisitOMPLoopDirective(S); |
| 762 | } |
| 763 | |
Kelvin Li | 80e8f56 | 2016-12-29 22:16:30 +0000 | [diff] [blame] | 764 | void StmtProfiler::VisitOMPTargetTeamsDistributeParallelForDirective( |
| 765 | const OMPTargetTeamsDistributeParallelForDirective *S) { |
| 766 | VisitOMPLoopDirective(S); |
| 767 | } |
| 768 | |
Kelvin Li | 1851df5 | 2017-01-03 05:23:48 +0000 | [diff] [blame] | 769 | void StmtProfiler::VisitOMPTargetTeamsDistributeParallelForSimdDirective( |
| 770 | const OMPTargetTeamsDistributeParallelForSimdDirective *S) { |
| 771 | VisitOMPLoopDirective(S); |
| 772 | } |
| 773 | |
Kelvin Li | da68118 | 2017-01-10 18:08:18 +0000 | [diff] [blame] | 774 | void StmtProfiler::VisitOMPTargetTeamsDistributeSimdDirective( |
| 775 | const OMPTargetTeamsDistributeSimdDirective *S) { |
| 776 | VisitOMPLoopDirective(S); |
| 777 | } |
| 778 | |
Chandler Carruth | 631abd9 | 2011-06-16 06:47:06 +0000 | [diff] [blame] | 779 | void StmtProfiler::VisitExpr(const Expr *S) { |
Douglas Gregor | 5c193b9 | 2009-07-28 00:33:38 +0000 | [diff] [blame] | 780 | VisitStmt(S); |
| 781 | } |
| 782 | |
Chandler Carruth | 631abd9 | 2011-06-16 06:47:06 +0000 | [diff] [blame] | 783 | void StmtProfiler::VisitDeclRefExpr(const DeclRefExpr *S) { |
Douglas Gregor | 5c193b9 | 2009-07-28 00:33:38 +0000 | [diff] [blame] | 784 | VisitExpr(S); |
Douglas Gregor | f5b160f | 2010-07-13 08:37:11 +0000 | [diff] [blame] | 785 | if (!Canonical) |
| 786 | VisitNestedNameSpecifier(S->getQualifier()); |
Douglas Gregor | 5c193b9 | 2009-07-28 00:33:38 +0000 | [diff] [blame] | 787 | VisitDecl(S->getDecl()); |
Douglas Gregor | f5b160f | 2010-07-13 08:37:11 +0000 | [diff] [blame] | 788 | if (!Canonical) |
| 789 | VisitTemplateArguments(S->getTemplateArgs(), S->getNumTemplateArgs()); |
Douglas Gregor | 5c193b9 | 2009-07-28 00:33:38 +0000 | [diff] [blame] | 790 | } |
| 791 | |
Chandler Carruth | 631abd9 | 2011-06-16 06:47:06 +0000 | [diff] [blame] | 792 | void StmtProfiler::VisitPredefinedExpr(const PredefinedExpr *S) { |
Douglas Gregor | 5c193b9 | 2009-07-28 00:33:38 +0000 | [diff] [blame] | 793 | VisitExpr(S); |
| 794 | ID.AddInteger(S->getIdentType()); |
| 795 | } |
| 796 | |
Chandler Carruth | 631abd9 | 2011-06-16 06:47:06 +0000 | [diff] [blame] | 797 | void StmtProfiler::VisitIntegerLiteral(const IntegerLiteral *S) { |
Douglas Gregor | 5c193b9 | 2009-07-28 00:33:38 +0000 | [diff] [blame] | 798 | VisitExpr(S); |
| 799 | S->getValue().Profile(ID); |
Richard Smith | e9f130c | 2014-11-20 03:37:32 +0000 | [diff] [blame] | 800 | ID.AddInteger(S->getType()->castAs<BuiltinType>()->getKind()); |
Douglas Gregor | 5c193b9 | 2009-07-28 00:33:38 +0000 | [diff] [blame] | 801 | } |
| 802 | |
Chandler Carruth | 631abd9 | 2011-06-16 06:47:06 +0000 | [diff] [blame] | 803 | void StmtProfiler::VisitCharacterLiteral(const CharacterLiteral *S) { |
Douglas Gregor | 5c193b9 | 2009-07-28 00:33:38 +0000 | [diff] [blame] | 804 | VisitExpr(S); |
Douglas Gregor | fb65e59 | 2011-07-27 05:40:30 +0000 | [diff] [blame] | 805 | ID.AddInteger(S->getKind()); |
Douglas Gregor | 5c193b9 | 2009-07-28 00:33:38 +0000 | [diff] [blame] | 806 | ID.AddInteger(S->getValue()); |
| 807 | } |
| 808 | |
Chandler Carruth | 631abd9 | 2011-06-16 06:47:06 +0000 | [diff] [blame] | 809 | void StmtProfiler::VisitFloatingLiteral(const FloatingLiteral *S) { |
Douglas Gregor | 5c193b9 | 2009-07-28 00:33:38 +0000 | [diff] [blame] | 810 | VisitExpr(S); |
| 811 | S->getValue().Profile(ID); |
| 812 | ID.AddBoolean(S->isExact()); |
Richard Smith | e9f130c | 2014-11-20 03:37:32 +0000 | [diff] [blame] | 813 | ID.AddInteger(S->getType()->castAs<BuiltinType>()->getKind()); |
Douglas Gregor | 5c193b9 | 2009-07-28 00:33:38 +0000 | [diff] [blame] | 814 | } |
| 815 | |
Chandler Carruth | 631abd9 | 2011-06-16 06:47:06 +0000 | [diff] [blame] | 816 | void StmtProfiler::VisitImaginaryLiteral(const ImaginaryLiteral *S) { |
Douglas Gregor | 5c193b9 | 2009-07-28 00:33:38 +0000 | [diff] [blame] | 817 | VisitExpr(S); |
| 818 | } |
| 819 | |
Chandler Carruth | 631abd9 | 2011-06-16 06:47:06 +0000 | [diff] [blame] | 820 | void StmtProfiler::VisitStringLiteral(const StringLiteral *S) { |
Douglas Gregor | 5c193b9 | 2009-07-28 00:33:38 +0000 | [diff] [blame] | 821 | VisitExpr(S); |
Douglas Gregor | 9d0eb8f | 2011-11-02 17:26:05 +0000 | [diff] [blame] | 822 | ID.AddString(S->getBytes()); |
Douglas Gregor | fb65e59 | 2011-07-27 05:40:30 +0000 | [diff] [blame] | 823 | ID.AddInteger(S->getKind()); |
Douglas Gregor | 5c193b9 | 2009-07-28 00:33:38 +0000 | [diff] [blame] | 824 | } |
| 825 | |
Chandler Carruth | 631abd9 | 2011-06-16 06:47:06 +0000 | [diff] [blame] | 826 | void StmtProfiler::VisitParenExpr(const ParenExpr *S) { |
Douglas Gregor | 5c193b9 | 2009-07-28 00:33:38 +0000 | [diff] [blame] | 827 | VisitExpr(S); |
| 828 | } |
| 829 | |
Chandler Carruth | 631abd9 | 2011-06-16 06:47:06 +0000 | [diff] [blame] | 830 | void StmtProfiler::VisitParenListExpr(const ParenListExpr *S) { |
Nate Begeman | 5ec4b31 | 2009-08-10 23:49:36 +0000 | [diff] [blame] | 831 | VisitExpr(S); |
| 832 | } |
| 833 | |
Chandler Carruth | 631abd9 | 2011-06-16 06:47:06 +0000 | [diff] [blame] | 834 | void StmtProfiler::VisitUnaryOperator(const UnaryOperator *S) { |
Douglas Gregor | 5c193b9 | 2009-07-28 00:33:38 +0000 | [diff] [blame] | 835 | VisitExpr(S); |
| 836 | ID.AddInteger(S->getOpcode()); |
| 837 | } |
| 838 | |
Chandler Carruth | 631abd9 | 2011-06-16 06:47:06 +0000 | [diff] [blame] | 839 | void StmtProfiler::VisitOffsetOfExpr(const OffsetOfExpr *S) { |
Douglas Gregor | 882211c | 2010-04-28 22:16:22 +0000 | [diff] [blame] | 840 | VisitType(S->getTypeSourceInfo()->getType()); |
| 841 | unsigned n = S->getNumComponents(); |
| 842 | for (unsigned i = 0; i < n; ++i) { |
James Y Knight | 7281c35 | 2015-12-29 22:31:18 +0000 | [diff] [blame] | 843 | const OffsetOfNode &ON = S->getComponent(i); |
Douglas Gregor | 882211c | 2010-04-28 22:16:22 +0000 | [diff] [blame] | 844 | ID.AddInteger(ON.getKind()); |
| 845 | switch (ON.getKind()) { |
James Y Knight | 7281c35 | 2015-12-29 22:31:18 +0000 | [diff] [blame] | 846 | case OffsetOfNode::Array: |
Douglas Gregor | 882211c | 2010-04-28 22:16:22 +0000 | [diff] [blame] | 847 | // Expressions handled below. |
| 848 | break; |
| 849 | |
James Y Knight | 7281c35 | 2015-12-29 22:31:18 +0000 | [diff] [blame] | 850 | case OffsetOfNode::Field: |
Douglas Gregor | 882211c | 2010-04-28 22:16:22 +0000 | [diff] [blame] | 851 | VisitDecl(ON.getField()); |
| 852 | break; |
| 853 | |
James Y Knight | 7281c35 | 2015-12-29 22:31:18 +0000 | [diff] [blame] | 854 | case OffsetOfNode::Identifier: |
Douglas Gregor | 882211c | 2010-04-28 22:16:22 +0000 | [diff] [blame] | 855 | ID.AddPointer(ON.getFieldName()); |
| 856 | break; |
James Y Knight | 7281c35 | 2015-12-29 22:31:18 +0000 | [diff] [blame] | 857 | |
| 858 | case OffsetOfNode::Base: |
Douglas Gregor | d170206 | 2010-04-29 00:18:15 +0000 | [diff] [blame] | 859 | // These nodes are implicit, and therefore don't need profiling. |
| 860 | break; |
Douglas Gregor | 882211c | 2010-04-28 22:16:22 +0000 | [diff] [blame] | 861 | } |
| 862 | } |
Alexis Hunt | a8136cc | 2010-05-05 15:23:54 +0000 | [diff] [blame] | 863 | |
Douglas Gregor | 882211c | 2010-04-28 22:16:22 +0000 | [diff] [blame] | 864 | VisitExpr(S); |
| 865 | } |
| 866 | |
Chandler Carruth | 631abd9 | 2011-06-16 06:47:06 +0000 | [diff] [blame] | 867 | void |
| 868 | StmtProfiler::VisitUnaryExprOrTypeTraitExpr(const UnaryExprOrTypeTraitExpr *S) { |
Douglas Gregor | 5c193b9 | 2009-07-28 00:33:38 +0000 | [diff] [blame] | 869 | VisitExpr(S); |
Peter Collingbourne | e190dee | 2011-03-11 19:24:49 +0000 | [diff] [blame] | 870 | ID.AddInteger(S->getKind()); |
Douglas Gregor | 5c193b9 | 2009-07-28 00:33:38 +0000 | [diff] [blame] | 871 | if (S->isArgumentType()) |
| 872 | VisitType(S->getArgumentType()); |
| 873 | } |
| 874 | |
Chandler Carruth | 631abd9 | 2011-06-16 06:47:06 +0000 | [diff] [blame] | 875 | void StmtProfiler::VisitArraySubscriptExpr(const ArraySubscriptExpr *S) { |
Douglas Gregor | 5c193b9 | 2009-07-28 00:33:38 +0000 | [diff] [blame] | 876 | VisitExpr(S); |
| 877 | } |
| 878 | |
Alexey Bataev | 1a3320e | 2015-08-25 14:24:04 +0000 | [diff] [blame] | 879 | void StmtProfiler::VisitOMPArraySectionExpr(const OMPArraySectionExpr *S) { |
| 880 | VisitExpr(S); |
| 881 | } |
| 882 | |
Chandler Carruth | 631abd9 | 2011-06-16 06:47:06 +0000 | [diff] [blame] | 883 | void StmtProfiler::VisitCallExpr(const CallExpr *S) { |
Douglas Gregor | 5c193b9 | 2009-07-28 00:33:38 +0000 | [diff] [blame] | 884 | VisitExpr(S); |
| 885 | } |
| 886 | |
Chandler Carruth | 631abd9 | 2011-06-16 06:47:06 +0000 | [diff] [blame] | 887 | void StmtProfiler::VisitMemberExpr(const MemberExpr *S) { |
Douglas Gregor | 5c193b9 | 2009-07-28 00:33:38 +0000 | [diff] [blame] | 888 | VisitExpr(S); |
| 889 | VisitDecl(S->getMemberDecl()); |
Douglas Gregor | f5b160f | 2010-07-13 08:37:11 +0000 | [diff] [blame] | 890 | if (!Canonical) |
| 891 | VisitNestedNameSpecifier(S->getQualifier()); |
Douglas Gregor | 5c193b9 | 2009-07-28 00:33:38 +0000 | [diff] [blame] | 892 | ID.AddBoolean(S->isArrow()); |
| 893 | } |
| 894 | |
Chandler Carruth | 631abd9 | 2011-06-16 06:47:06 +0000 | [diff] [blame] | 895 | void StmtProfiler::VisitCompoundLiteralExpr(const CompoundLiteralExpr *S) { |
Douglas Gregor | 5c193b9 | 2009-07-28 00:33:38 +0000 | [diff] [blame] | 896 | VisitExpr(S); |
| 897 | ID.AddBoolean(S->isFileScope()); |
| 898 | } |
| 899 | |
Chandler Carruth | 631abd9 | 2011-06-16 06:47:06 +0000 | [diff] [blame] | 900 | void StmtProfiler::VisitCastExpr(const CastExpr *S) { |
Douglas Gregor | 5c193b9 | 2009-07-28 00:33:38 +0000 | [diff] [blame] | 901 | VisitExpr(S); |
| 902 | } |
| 903 | |
Chandler Carruth | 631abd9 | 2011-06-16 06:47:06 +0000 | [diff] [blame] | 904 | void StmtProfiler::VisitImplicitCastExpr(const ImplicitCastExpr *S) { |
Douglas Gregor | 5c193b9 | 2009-07-28 00:33:38 +0000 | [diff] [blame] | 905 | VisitCastExpr(S); |
John McCall | 2536c6d | 2010-08-25 10:28:54 +0000 | [diff] [blame] | 906 | ID.AddInteger(S->getValueKind()); |
Douglas Gregor | 5c193b9 | 2009-07-28 00:33:38 +0000 | [diff] [blame] | 907 | } |
| 908 | |
Chandler Carruth | 631abd9 | 2011-06-16 06:47:06 +0000 | [diff] [blame] | 909 | void StmtProfiler::VisitExplicitCastExpr(const ExplicitCastExpr *S) { |
Douglas Gregor | 5c193b9 | 2009-07-28 00:33:38 +0000 | [diff] [blame] | 910 | VisitCastExpr(S); |
| 911 | VisitType(S->getTypeAsWritten()); |
| 912 | } |
| 913 | |
Chandler Carruth | 631abd9 | 2011-06-16 06:47:06 +0000 | [diff] [blame] | 914 | void StmtProfiler::VisitCStyleCastExpr(const CStyleCastExpr *S) { |
Douglas Gregor | 5c193b9 | 2009-07-28 00:33:38 +0000 | [diff] [blame] | 915 | VisitExplicitCastExpr(S); |
| 916 | } |
| 917 | |
Chandler Carruth | 631abd9 | 2011-06-16 06:47:06 +0000 | [diff] [blame] | 918 | void StmtProfiler::VisitBinaryOperator(const BinaryOperator *S) { |
Douglas Gregor | 5c193b9 | 2009-07-28 00:33:38 +0000 | [diff] [blame] | 919 | VisitExpr(S); |
| 920 | ID.AddInteger(S->getOpcode()); |
| 921 | } |
| 922 | |
Chandler Carruth | 631abd9 | 2011-06-16 06:47:06 +0000 | [diff] [blame] | 923 | void |
| 924 | StmtProfiler::VisitCompoundAssignOperator(const CompoundAssignOperator *S) { |
Douglas Gregor | 5c193b9 | 2009-07-28 00:33:38 +0000 | [diff] [blame] | 925 | VisitBinaryOperator(S); |
| 926 | } |
| 927 | |
Chandler Carruth | 631abd9 | 2011-06-16 06:47:06 +0000 | [diff] [blame] | 928 | void StmtProfiler::VisitConditionalOperator(const ConditionalOperator *S) { |
Douglas Gregor | 5c193b9 | 2009-07-28 00:33:38 +0000 | [diff] [blame] | 929 | VisitExpr(S); |
| 930 | } |
| 931 | |
Chandler Carruth | 631abd9 | 2011-06-16 06:47:06 +0000 | [diff] [blame] | 932 | void StmtProfiler::VisitBinaryConditionalOperator( |
Chandler Carruth | cf5f43c | 2011-06-21 23:26:32 +0000 | [diff] [blame] | 933 | const BinaryConditionalOperator *S) { |
John McCall | c07a0c7 | 2011-02-17 10:25:35 +0000 | [diff] [blame] | 934 | VisitExpr(S); |
| 935 | } |
| 936 | |
Chandler Carruth | 631abd9 | 2011-06-16 06:47:06 +0000 | [diff] [blame] | 937 | void StmtProfiler::VisitAddrLabelExpr(const AddrLabelExpr *S) { |
Douglas Gregor | 5c193b9 | 2009-07-28 00:33:38 +0000 | [diff] [blame] | 938 | VisitExpr(S); |
Chris Lattner | c8e630e | 2011-02-17 07:39:24 +0000 | [diff] [blame] | 939 | VisitDecl(S->getLabel()); |
Douglas Gregor | 5c193b9 | 2009-07-28 00:33:38 +0000 | [diff] [blame] | 940 | } |
| 941 | |
Chandler Carruth | 631abd9 | 2011-06-16 06:47:06 +0000 | [diff] [blame] | 942 | void StmtProfiler::VisitStmtExpr(const StmtExpr *S) { |
Douglas Gregor | 5c193b9 | 2009-07-28 00:33:38 +0000 | [diff] [blame] | 943 | VisitExpr(S); |
| 944 | } |
| 945 | |
Chandler Carruth | 631abd9 | 2011-06-16 06:47:06 +0000 | [diff] [blame] | 946 | void StmtProfiler::VisitShuffleVectorExpr(const ShuffleVectorExpr *S) { |
Douglas Gregor | 5c193b9 | 2009-07-28 00:33:38 +0000 | [diff] [blame] | 947 | VisitExpr(S); |
| 948 | } |
| 949 | |
Hal Finkel | c4d7c82 | 2013-09-18 03:29:45 +0000 | [diff] [blame] | 950 | void StmtProfiler::VisitConvertVectorExpr(const ConvertVectorExpr *S) { |
| 951 | VisitExpr(S); |
| 952 | } |
| 953 | |
Chandler Carruth | 631abd9 | 2011-06-16 06:47:06 +0000 | [diff] [blame] | 954 | void StmtProfiler::VisitChooseExpr(const ChooseExpr *S) { |
Douglas Gregor | 5c193b9 | 2009-07-28 00:33:38 +0000 | [diff] [blame] | 955 | VisitExpr(S); |
| 956 | } |
| 957 | |
Chandler Carruth | 631abd9 | 2011-06-16 06:47:06 +0000 | [diff] [blame] | 958 | void StmtProfiler::VisitGNUNullExpr(const GNUNullExpr *S) { |
Douglas Gregor | 5c193b9 | 2009-07-28 00:33:38 +0000 | [diff] [blame] | 959 | VisitExpr(S); |
| 960 | } |
| 961 | |
Chandler Carruth | 631abd9 | 2011-06-16 06:47:06 +0000 | [diff] [blame] | 962 | void StmtProfiler::VisitVAArgExpr(const VAArgExpr *S) { |
Douglas Gregor | 0004417 | 2009-07-29 16:09:57 +0000 | [diff] [blame] | 963 | VisitExpr(S); |
| 964 | } |
| 965 | |
Chandler Carruth | 631abd9 | 2011-06-16 06:47:06 +0000 | [diff] [blame] | 966 | void StmtProfiler::VisitInitListExpr(const InitListExpr *S) { |
Douglas Gregor | 5c193b9 | 2009-07-28 00:33:38 +0000 | [diff] [blame] | 967 | if (S->getSyntacticForm()) { |
| 968 | VisitInitListExpr(S->getSyntacticForm()); |
| 969 | return; |
| 970 | } |
Mike Stump | 11289f4 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 971 | |
Douglas Gregor | 5c193b9 | 2009-07-28 00:33:38 +0000 | [diff] [blame] | 972 | VisitExpr(S); |
| 973 | } |
| 974 | |
Chandler Carruth | 631abd9 | 2011-06-16 06:47:06 +0000 | [diff] [blame] | 975 | void StmtProfiler::VisitDesignatedInitExpr(const DesignatedInitExpr *S) { |
Douglas Gregor | 5c193b9 | 2009-07-28 00:33:38 +0000 | [diff] [blame] | 976 | VisitExpr(S); |
| 977 | ID.AddBoolean(S->usesGNUSyntax()); |
David Majnemer | f7e3609 | 2016-06-23 00:15:04 +0000 | [diff] [blame] | 978 | for (const DesignatedInitExpr::Designator &D : S->designators()) { |
| 979 | if (D.isFieldDesignator()) { |
Douglas Gregor | 5c193b9 | 2009-07-28 00:33:38 +0000 | [diff] [blame] | 980 | ID.AddInteger(0); |
David Majnemer | f7e3609 | 2016-06-23 00:15:04 +0000 | [diff] [blame] | 981 | VisitName(D.getFieldName()); |
Douglas Gregor | 5c193b9 | 2009-07-28 00:33:38 +0000 | [diff] [blame] | 982 | continue; |
| 983 | } |
Mike Stump | 11289f4 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 984 | |
David Majnemer | f7e3609 | 2016-06-23 00:15:04 +0000 | [diff] [blame] | 985 | if (D.isArrayDesignator()) { |
Douglas Gregor | 5c193b9 | 2009-07-28 00:33:38 +0000 | [diff] [blame] | 986 | ID.AddInteger(1); |
| 987 | } else { |
David Majnemer | f7e3609 | 2016-06-23 00:15:04 +0000 | [diff] [blame] | 988 | assert(D.isArrayRangeDesignator()); |
Douglas Gregor | 5c193b9 | 2009-07-28 00:33:38 +0000 | [diff] [blame] | 989 | ID.AddInteger(2); |
| 990 | } |
David Majnemer | f7e3609 | 2016-06-23 00:15:04 +0000 | [diff] [blame] | 991 | ID.AddInteger(D.getFirstExprIndex()); |
Douglas Gregor | 5c193b9 | 2009-07-28 00:33:38 +0000 | [diff] [blame] | 992 | } |
| 993 | } |
| 994 | |
Yunzhong Gao | cb77930 | 2015-06-10 00:27:52 +0000 | [diff] [blame] | 995 | // Seems that if VisitInitListExpr() only works on the syntactic form of an |
| 996 | // InitListExpr, then a DesignatedInitUpdateExpr is not encountered. |
| 997 | void StmtProfiler::VisitDesignatedInitUpdateExpr( |
| 998 | const DesignatedInitUpdateExpr *S) { |
| 999 | llvm_unreachable("Unexpected DesignatedInitUpdateExpr in syntactic form of " |
| 1000 | "initializer"); |
| 1001 | } |
| 1002 | |
Richard Smith | 410306b | 2016-12-12 02:53:20 +0000 | [diff] [blame] | 1003 | void StmtProfiler::VisitArrayInitLoopExpr(const ArrayInitLoopExpr *S) { |
| 1004 | VisitExpr(S); |
| 1005 | } |
| 1006 | |
| 1007 | void StmtProfiler::VisitArrayInitIndexExpr(const ArrayInitIndexExpr *S) { |
| 1008 | VisitExpr(S); |
| 1009 | } |
| 1010 | |
Yunzhong Gao | cb77930 | 2015-06-10 00:27:52 +0000 | [diff] [blame] | 1011 | void StmtProfiler::VisitNoInitExpr(const NoInitExpr *S) { |
| 1012 | llvm_unreachable("Unexpected NoInitExpr in syntactic form of initializer"); |
| 1013 | } |
| 1014 | |
Chandler Carruth | 631abd9 | 2011-06-16 06:47:06 +0000 | [diff] [blame] | 1015 | void StmtProfiler::VisitImplicitValueInitExpr(const ImplicitValueInitExpr *S) { |
Douglas Gregor | 5c193b9 | 2009-07-28 00:33:38 +0000 | [diff] [blame] | 1016 | VisitExpr(S); |
| 1017 | } |
| 1018 | |
Chandler Carruth | 631abd9 | 2011-06-16 06:47:06 +0000 | [diff] [blame] | 1019 | void StmtProfiler::VisitExtVectorElementExpr(const ExtVectorElementExpr *S) { |
Douglas Gregor | 5c193b9 | 2009-07-28 00:33:38 +0000 | [diff] [blame] | 1020 | VisitExpr(S); |
| 1021 | VisitName(&S->getAccessor()); |
| 1022 | } |
| 1023 | |
Chandler Carruth | 631abd9 | 2011-06-16 06:47:06 +0000 | [diff] [blame] | 1024 | void StmtProfiler::VisitBlockExpr(const BlockExpr *S) { |
Douglas Gregor | 5c193b9 | 2009-07-28 00:33:38 +0000 | [diff] [blame] | 1025 | VisitExpr(S); |
| 1026 | VisitDecl(S->getBlockDecl()); |
| 1027 | } |
| 1028 | |
Chandler Carruth | 631abd9 | 2011-06-16 06:47:06 +0000 | [diff] [blame] | 1029 | void StmtProfiler::VisitGenericSelectionExpr(const GenericSelectionExpr *S) { |
Peter Collingbourne | 9114759 | 2011-04-15 00:35:48 +0000 | [diff] [blame] | 1030 | VisitExpr(S); |
| 1031 | for (unsigned i = 0; i != S->getNumAssocs(); ++i) { |
| 1032 | QualType T = S->getAssocType(i); |
| 1033 | if (T.isNull()) |
Craig Topper | 36250ad | 2014-05-12 05:36:57 +0000 | [diff] [blame] | 1034 | ID.AddPointer(nullptr); |
Peter Collingbourne | 9114759 | 2011-04-15 00:35:48 +0000 | [diff] [blame] | 1035 | else |
| 1036 | VisitType(T); |
| 1037 | VisitExpr(S->getAssocExpr(i)); |
| 1038 | } |
| 1039 | } |
| 1040 | |
John McCall | fe96e0b | 2011-11-06 09:01:30 +0000 | [diff] [blame] | 1041 | void StmtProfiler::VisitPseudoObjectExpr(const PseudoObjectExpr *S) { |
| 1042 | VisitExpr(S); |
| 1043 | for (PseudoObjectExpr::const_semantics_iterator |
| 1044 | i = S->semantics_begin(), e = S->semantics_end(); i != e; ++i) |
| 1045 | // Normally, we would not profile the source expressions of OVEs. |
| 1046 | if (const OpaqueValueExpr *OVE = dyn_cast<OpaqueValueExpr>(*i)) |
| 1047 | Visit(OVE->getSourceExpr()); |
| 1048 | } |
| 1049 | |
Eli Friedman | df14b3a | 2011-10-11 02:20:01 +0000 | [diff] [blame] | 1050 | void StmtProfiler::VisitAtomicExpr(const AtomicExpr *S) { |
| 1051 | VisitExpr(S); |
Eli Friedman | 4b72fdd | 2011-10-14 20:59:01 +0000 | [diff] [blame] | 1052 | ID.AddInteger(S->getOp()); |
Eli Friedman | df14b3a | 2011-10-11 02:20:01 +0000 | [diff] [blame] | 1053 | } |
| 1054 | |
Chandler Carruth | 631abd9 | 2011-06-16 06:47:06 +0000 | [diff] [blame] | 1055 | static Stmt::StmtClass DecodeOperatorCall(const CXXOperatorCallExpr *S, |
John McCall | e302792 | 2010-08-25 11:45:40 +0000 | [diff] [blame] | 1056 | UnaryOperatorKind &UnaryOp, |
| 1057 | BinaryOperatorKind &BinaryOp) { |
Douglas Gregor | e9ceb31 | 2010-05-19 04:13:23 +0000 | [diff] [blame] | 1058 | switch (S->getOperator()) { |
| 1059 | case OO_None: |
| 1060 | case OO_New: |
| 1061 | case OO_Delete: |
| 1062 | case OO_Array_New: |
| 1063 | case OO_Array_Delete: |
| 1064 | case OO_Arrow: |
| 1065 | case OO_Call: |
| 1066 | case OO_Conditional: |
Richard Smith | 9be594e | 2015-10-22 05:12:22 +0000 | [diff] [blame] | 1067 | case OO_Coawait: |
Douglas Gregor | e9ceb31 | 2010-05-19 04:13:23 +0000 | [diff] [blame] | 1068 | case NUM_OVERLOADED_OPERATORS: |
| 1069 | llvm_unreachable("Invalid operator call kind"); |
Douglas Gregor | e9ceb31 | 2010-05-19 04:13:23 +0000 | [diff] [blame] | 1070 | |
| 1071 | case OO_Plus: |
| 1072 | if (S->getNumArgs() == 1) { |
John McCall | e302792 | 2010-08-25 11:45:40 +0000 | [diff] [blame] | 1073 | UnaryOp = UO_Plus; |
Douglas Gregor | e9ceb31 | 2010-05-19 04:13:23 +0000 | [diff] [blame] | 1074 | return Stmt::UnaryOperatorClass; |
| 1075 | } |
| 1076 | |
John McCall | e302792 | 2010-08-25 11:45:40 +0000 | [diff] [blame] | 1077 | BinaryOp = BO_Add; |
Douglas Gregor | e9ceb31 | 2010-05-19 04:13:23 +0000 | [diff] [blame] | 1078 | return Stmt::BinaryOperatorClass; |
| 1079 | |
| 1080 | case OO_Minus: |
| 1081 | if (S->getNumArgs() == 1) { |
John McCall | e302792 | 2010-08-25 11:45:40 +0000 | [diff] [blame] | 1082 | UnaryOp = UO_Minus; |
Douglas Gregor | e9ceb31 | 2010-05-19 04:13:23 +0000 | [diff] [blame] | 1083 | return Stmt::UnaryOperatorClass; |
| 1084 | } |
| 1085 | |
John McCall | e302792 | 2010-08-25 11:45:40 +0000 | [diff] [blame] | 1086 | BinaryOp = BO_Sub; |
Douglas Gregor | e9ceb31 | 2010-05-19 04:13:23 +0000 | [diff] [blame] | 1087 | return Stmt::BinaryOperatorClass; |
| 1088 | |
| 1089 | case OO_Star: |
| 1090 | if (S->getNumArgs() == 1) { |
Richard Smith | f15acc5 | 2014-06-05 22:43:40 +0000 | [diff] [blame] | 1091 | UnaryOp = UO_Deref; |
Douglas Gregor | e9ceb31 | 2010-05-19 04:13:23 +0000 | [diff] [blame] | 1092 | return Stmt::UnaryOperatorClass; |
| 1093 | } |
| 1094 | |
Richard Smith | f15acc5 | 2014-06-05 22:43:40 +0000 | [diff] [blame] | 1095 | BinaryOp = BO_Mul; |
Douglas Gregor | e9ceb31 | 2010-05-19 04:13:23 +0000 | [diff] [blame] | 1096 | return Stmt::BinaryOperatorClass; |
| 1097 | |
| 1098 | case OO_Slash: |
John McCall | e302792 | 2010-08-25 11:45:40 +0000 | [diff] [blame] | 1099 | BinaryOp = BO_Div; |
Douglas Gregor | e9ceb31 | 2010-05-19 04:13:23 +0000 | [diff] [blame] | 1100 | return Stmt::BinaryOperatorClass; |
| 1101 | |
| 1102 | case OO_Percent: |
John McCall | e302792 | 2010-08-25 11:45:40 +0000 | [diff] [blame] | 1103 | BinaryOp = BO_Rem; |
Douglas Gregor | e9ceb31 | 2010-05-19 04:13:23 +0000 | [diff] [blame] | 1104 | return Stmt::BinaryOperatorClass; |
| 1105 | |
| 1106 | case OO_Caret: |
John McCall | e302792 | 2010-08-25 11:45:40 +0000 | [diff] [blame] | 1107 | BinaryOp = BO_Xor; |
Douglas Gregor | e9ceb31 | 2010-05-19 04:13:23 +0000 | [diff] [blame] | 1108 | return Stmt::BinaryOperatorClass; |
| 1109 | |
| 1110 | case OO_Amp: |
| 1111 | if (S->getNumArgs() == 1) { |
John McCall | e302792 | 2010-08-25 11:45:40 +0000 | [diff] [blame] | 1112 | UnaryOp = UO_AddrOf; |
Douglas Gregor | e9ceb31 | 2010-05-19 04:13:23 +0000 | [diff] [blame] | 1113 | return Stmt::UnaryOperatorClass; |
| 1114 | } |
| 1115 | |
John McCall | e302792 | 2010-08-25 11:45:40 +0000 | [diff] [blame] | 1116 | BinaryOp = BO_And; |
Douglas Gregor | e9ceb31 | 2010-05-19 04:13:23 +0000 | [diff] [blame] | 1117 | return Stmt::BinaryOperatorClass; |
| 1118 | |
| 1119 | case OO_Pipe: |
John McCall | e302792 | 2010-08-25 11:45:40 +0000 | [diff] [blame] | 1120 | BinaryOp = BO_Or; |
Douglas Gregor | e9ceb31 | 2010-05-19 04:13:23 +0000 | [diff] [blame] | 1121 | return Stmt::BinaryOperatorClass; |
| 1122 | |
| 1123 | case OO_Tilde: |
John McCall | e302792 | 2010-08-25 11:45:40 +0000 | [diff] [blame] | 1124 | UnaryOp = UO_Not; |
Douglas Gregor | e9ceb31 | 2010-05-19 04:13:23 +0000 | [diff] [blame] | 1125 | return Stmt::UnaryOperatorClass; |
| 1126 | |
| 1127 | case OO_Exclaim: |
John McCall | e302792 | 2010-08-25 11:45:40 +0000 | [diff] [blame] | 1128 | UnaryOp = UO_LNot; |
Douglas Gregor | e9ceb31 | 2010-05-19 04:13:23 +0000 | [diff] [blame] | 1129 | return Stmt::UnaryOperatorClass; |
| 1130 | |
| 1131 | case OO_Equal: |
John McCall | e302792 | 2010-08-25 11:45:40 +0000 | [diff] [blame] | 1132 | BinaryOp = BO_Assign; |
Douglas Gregor | e9ceb31 | 2010-05-19 04:13:23 +0000 | [diff] [blame] | 1133 | return Stmt::BinaryOperatorClass; |
| 1134 | |
| 1135 | case OO_Less: |
John McCall | e302792 | 2010-08-25 11:45:40 +0000 | [diff] [blame] | 1136 | BinaryOp = BO_LT; |
Douglas Gregor | e9ceb31 | 2010-05-19 04:13:23 +0000 | [diff] [blame] | 1137 | return Stmt::BinaryOperatorClass; |
| 1138 | |
| 1139 | case OO_Greater: |
John McCall | e302792 | 2010-08-25 11:45:40 +0000 | [diff] [blame] | 1140 | BinaryOp = BO_GT; |
Douglas Gregor | e9ceb31 | 2010-05-19 04:13:23 +0000 | [diff] [blame] | 1141 | return Stmt::BinaryOperatorClass; |
| 1142 | |
| 1143 | case OO_PlusEqual: |
John McCall | e302792 | 2010-08-25 11:45:40 +0000 | [diff] [blame] | 1144 | BinaryOp = BO_AddAssign; |
Douglas Gregor | e9ceb31 | 2010-05-19 04:13:23 +0000 | [diff] [blame] | 1145 | return Stmt::CompoundAssignOperatorClass; |
| 1146 | |
| 1147 | case OO_MinusEqual: |
John McCall | e302792 | 2010-08-25 11:45:40 +0000 | [diff] [blame] | 1148 | BinaryOp = BO_SubAssign; |
Douglas Gregor | e9ceb31 | 2010-05-19 04:13:23 +0000 | [diff] [blame] | 1149 | return Stmt::CompoundAssignOperatorClass; |
| 1150 | |
| 1151 | case OO_StarEqual: |
John McCall | e302792 | 2010-08-25 11:45:40 +0000 | [diff] [blame] | 1152 | BinaryOp = BO_MulAssign; |
Douglas Gregor | e9ceb31 | 2010-05-19 04:13:23 +0000 | [diff] [blame] | 1153 | return Stmt::CompoundAssignOperatorClass; |
| 1154 | |
| 1155 | case OO_SlashEqual: |
John McCall | e302792 | 2010-08-25 11:45:40 +0000 | [diff] [blame] | 1156 | BinaryOp = BO_DivAssign; |
Douglas Gregor | e9ceb31 | 2010-05-19 04:13:23 +0000 | [diff] [blame] | 1157 | return Stmt::CompoundAssignOperatorClass; |
| 1158 | |
| 1159 | case OO_PercentEqual: |
John McCall | e302792 | 2010-08-25 11:45:40 +0000 | [diff] [blame] | 1160 | BinaryOp = BO_RemAssign; |
Douglas Gregor | e9ceb31 | 2010-05-19 04:13:23 +0000 | [diff] [blame] | 1161 | return Stmt::CompoundAssignOperatorClass; |
| 1162 | |
| 1163 | case OO_CaretEqual: |
John McCall | e302792 | 2010-08-25 11:45:40 +0000 | [diff] [blame] | 1164 | BinaryOp = BO_XorAssign; |
Douglas Gregor | e9ceb31 | 2010-05-19 04:13:23 +0000 | [diff] [blame] | 1165 | return Stmt::CompoundAssignOperatorClass; |
| 1166 | |
| 1167 | case OO_AmpEqual: |
John McCall | e302792 | 2010-08-25 11:45:40 +0000 | [diff] [blame] | 1168 | BinaryOp = BO_AndAssign; |
Douglas Gregor | e9ceb31 | 2010-05-19 04:13:23 +0000 | [diff] [blame] | 1169 | return Stmt::CompoundAssignOperatorClass; |
| 1170 | |
| 1171 | case OO_PipeEqual: |
John McCall | e302792 | 2010-08-25 11:45:40 +0000 | [diff] [blame] | 1172 | BinaryOp = BO_OrAssign; |
Douglas Gregor | e9ceb31 | 2010-05-19 04:13:23 +0000 | [diff] [blame] | 1173 | return Stmt::CompoundAssignOperatorClass; |
| 1174 | |
| 1175 | case OO_LessLess: |
John McCall | e302792 | 2010-08-25 11:45:40 +0000 | [diff] [blame] | 1176 | BinaryOp = BO_Shl; |
Douglas Gregor | e9ceb31 | 2010-05-19 04:13:23 +0000 | [diff] [blame] | 1177 | return Stmt::BinaryOperatorClass; |
| 1178 | |
| 1179 | case OO_GreaterGreater: |
John McCall | e302792 | 2010-08-25 11:45:40 +0000 | [diff] [blame] | 1180 | BinaryOp = BO_Shr; |
Douglas Gregor | e9ceb31 | 2010-05-19 04:13:23 +0000 | [diff] [blame] | 1181 | return Stmt::BinaryOperatorClass; |
| 1182 | |
| 1183 | case OO_LessLessEqual: |
John McCall | e302792 | 2010-08-25 11:45:40 +0000 | [diff] [blame] | 1184 | BinaryOp = BO_ShlAssign; |
Douglas Gregor | e9ceb31 | 2010-05-19 04:13:23 +0000 | [diff] [blame] | 1185 | return Stmt::CompoundAssignOperatorClass; |
| 1186 | |
| 1187 | case OO_GreaterGreaterEqual: |
John McCall | e302792 | 2010-08-25 11:45:40 +0000 | [diff] [blame] | 1188 | BinaryOp = BO_ShrAssign; |
Douglas Gregor | e9ceb31 | 2010-05-19 04:13:23 +0000 | [diff] [blame] | 1189 | return Stmt::CompoundAssignOperatorClass; |
| 1190 | |
| 1191 | case OO_EqualEqual: |
John McCall | e302792 | 2010-08-25 11:45:40 +0000 | [diff] [blame] | 1192 | BinaryOp = BO_EQ; |
Douglas Gregor | e9ceb31 | 2010-05-19 04:13:23 +0000 | [diff] [blame] | 1193 | return Stmt::BinaryOperatorClass; |
| 1194 | |
| 1195 | case OO_ExclaimEqual: |
John McCall | e302792 | 2010-08-25 11:45:40 +0000 | [diff] [blame] | 1196 | BinaryOp = BO_NE; |
Douglas Gregor | e9ceb31 | 2010-05-19 04:13:23 +0000 | [diff] [blame] | 1197 | return Stmt::BinaryOperatorClass; |
| 1198 | |
| 1199 | case OO_LessEqual: |
John McCall | e302792 | 2010-08-25 11:45:40 +0000 | [diff] [blame] | 1200 | BinaryOp = BO_LE; |
Douglas Gregor | e9ceb31 | 2010-05-19 04:13:23 +0000 | [diff] [blame] | 1201 | return Stmt::BinaryOperatorClass; |
| 1202 | |
| 1203 | case OO_GreaterEqual: |
John McCall | e302792 | 2010-08-25 11:45:40 +0000 | [diff] [blame] | 1204 | BinaryOp = BO_GE; |
Douglas Gregor | e9ceb31 | 2010-05-19 04:13:23 +0000 | [diff] [blame] | 1205 | return Stmt::BinaryOperatorClass; |
| 1206 | |
| 1207 | case OO_AmpAmp: |
John McCall | e302792 | 2010-08-25 11:45:40 +0000 | [diff] [blame] | 1208 | BinaryOp = BO_LAnd; |
Douglas Gregor | e9ceb31 | 2010-05-19 04:13:23 +0000 | [diff] [blame] | 1209 | return Stmt::BinaryOperatorClass; |
| 1210 | |
| 1211 | case OO_PipePipe: |
John McCall | e302792 | 2010-08-25 11:45:40 +0000 | [diff] [blame] | 1212 | BinaryOp = BO_LOr; |
Douglas Gregor | e9ceb31 | 2010-05-19 04:13:23 +0000 | [diff] [blame] | 1213 | return Stmt::BinaryOperatorClass; |
| 1214 | |
| 1215 | case OO_PlusPlus: |
John McCall | e302792 | 2010-08-25 11:45:40 +0000 | [diff] [blame] | 1216 | UnaryOp = S->getNumArgs() == 1? UO_PreInc |
| 1217 | : UO_PostInc; |
Douglas Gregor | e9ceb31 | 2010-05-19 04:13:23 +0000 | [diff] [blame] | 1218 | return Stmt::UnaryOperatorClass; |
| 1219 | |
| 1220 | case OO_MinusMinus: |
John McCall | e302792 | 2010-08-25 11:45:40 +0000 | [diff] [blame] | 1221 | UnaryOp = S->getNumArgs() == 1? UO_PreDec |
| 1222 | : UO_PostDec; |
Douglas Gregor | e9ceb31 | 2010-05-19 04:13:23 +0000 | [diff] [blame] | 1223 | return Stmt::UnaryOperatorClass; |
| 1224 | |
| 1225 | case OO_Comma: |
John McCall | e302792 | 2010-08-25 11:45:40 +0000 | [diff] [blame] | 1226 | BinaryOp = BO_Comma; |
Douglas Gregor | e9ceb31 | 2010-05-19 04:13:23 +0000 | [diff] [blame] | 1227 | return Stmt::BinaryOperatorClass; |
| 1228 | |
Douglas Gregor | e9ceb31 | 2010-05-19 04:13:23 +0000 | [diff] [blame] | 1229 | case OO_ArrowStar: |
John McCall | e302792 | 2010-08-25 11:45:40 +0000 | [diff] [blame] | 1230 | BinaryOp = BO_PtrMemI; |
Douglas Gregor | e9ceb31 | 2010-05-19 04:13:23 +0000 | [diff] [blame] | 1231 | return Stmt::BinaryOperatorClass; |
| 1232 | |
| 1233 | case OO_Subscript: |
| 1234 | return Stmt::ArraySubscriptExprClass; |
| 1235 | } |
| 1236 | |
| 1237 | llvm_unreachable("Invalid overloaded operator expression"); |
| 1238 | } |
Richard Smith | f15acc5 | 2014-06-05 22:43:40 +0000 | [diff] [blame] | 1239 | |
Chandler Carruth | 631abd9 | 2011-06-16 06:47:06 +0000 | [diff] [blame] | 1240 | void StmtProfiler::VisitCXXOperatorCallExpr(const CXXOperatorCallExpr *S) { |
Douglas Gregor | e9ceb31 | 2010-05-19 04:13:23 +0000 | [diff] [blame] | 1241 | if (S->isTypeDependent()) { |
| 1242 | // Type-dependent operator calls are profiled like their underlying |
| 1243 | // syntactic operator. |
Richard Smith | bac0a0d | 2016-10-24 18:47:04 +0000 | [diff] [blame] | 1244 | // |
| 1245 | // An operator call to operator-> is always implicit, so just skip it. The |
| 1246 | // enclosing MemberExpr will profile the actual member access. |
| 1247 | if (S->getOperator() == OO_Arrow) |
| 1248 | return Visit(S->getArg(0)); |
| 1249 | |
John McCall | e302792 | 2010-08-25 11:45:40 +0000 | [diff] [blame] | 1250 | UnaryOperatorKind UnaryOp = UO_Extension; |
| 1251 | BinaryOperatorKind BinaryOp = BO_Comma; |
Douglas Gregor | e9ceb31 | 2010-05-19 04:13:23 +0000 | [diff] [blame] | 1252 | Stmt::StmtClass SC = DecodeOperatorCall(S, UnaryOp, BinaryOp); |
Richard Smith | f15acc5 | 2014-06-05 22:43:40 +0000 | [diff] [blame] | 1253 | |
Douglas Gregor | e9ceb31 | 2010-05-19 04:13:23 +0000 | [diff] [blame] | 1254 | ID.AddInteger(SC); |
| 1255 | for (unsigned I = 0, N = S->getNumArgs(); I != N; ++I) |
| 1256 | Visit(S->getArg(I)); |
| 1257 | if (SC == Stmt::UnaryOperatorClass) |
| 1258 | ID.AddInteger(UnaryOp); |
| 1259 | else if (SC == Stmt::BinaryOperatorClass || |
| 1260 | SC == Stmt::CompoundAssignOperatorClass) |
| 1261 | ID.AddInteger(BinaryOp); |
| 1262 | else |
| 1263 | assert(SC == Stmt::ArraySubscriptExprClass); |
Richard Smith | f15acc5 | 2014-06-05 22:43:40 +0000 | [diff] [blame] | 1264 | |
Douglas Gregor | e9ceb31 | 2010-05-19 04:13:23 +0000 | [diff] [blame] | 1265 | return; |
| 1266 | } |
Richard Smith | f15acc5 | 2014-06-05 22:43:40 +0000 | [diff] [blame] | 1267 | |
Douglas Gregor | 5c193b9 | 2009-07-28 00:33:38 +0000 | [diff] [blame] | 1268 | VisitCallExpr(S); |
| 1269 | ID.AddInteger(S->getOperator()); |
| 1270 | } |
| 1271 | |
Chandler Carruth | 631abd9 | 2011-06-16 06:47:06 +0000 | [diff] [blame] | 1272 | void StmtProfiler::VisitCXXMemberCallExpr(const CXXMemberCallExpr *S) { |
Douglas Gregor | 5c193b9 | 2009-07-28 00:33:38 +0000 | [diff] [blame] | 1273 | VisitCallExpr(S); |
| 1274 | } |
| 1275 | |
Chandler Carruth | 631abd9 | 2011-06-16 06:47:06 +0000 | [diff] [blame] | 1276 | void StmtProfiler::VisitCUDAKernelCallExpr(const CUDAKernelCallExpr *S) { |
Peter Collingbourne | 41f8546 | 2011-02-09 21:07:24 +0000 | [diff] [blame] | 1277 | VisitCallExpr(S); |
| 1278 | } |
| 1279 | |
Chandler Carruth | 631abd9 | 2011-06-16 06:47:06 +0000 | [diff] [blame] | 1280 | void StmtProfiler::VisitAsTypeExpr(const AsTypeExpr *S) { |
Tanya Lattner | 55808c1 | 2011-06-04 00:47:47 +0000 | [diff] [blame] | 1281 | VisitExpr(S); |
| 1282 | } |
| 1283 | |
Chandler Carruth | 631abd9 | 2011-06-16 06:47:06 +0000 | [diff] [blame] | 1284 | void StmtProfiler::VisitCXXNamedCastExpr(const CXXNamedCastExpr *S) { |
Douglas Gregor | 5c193b9 | 2009-07-28 00:33:38 +0000 | [diff] [blame] | 1285 | VisitExplicitCastExpr(S); |
| 1286 | } |
| 1287 | |
Chandler Carruth | 631abd9 | 2011-06-16 06:47:06 +0000 | [diff] [blame] | 1288 | void StmtProfiler::VisitCXXStaticCastExpr(const CXXStaticCastExpr *S) { |
Douglas Gregor | 5c193b9 | 2009-07-28 00:33:38 +0000 | [diff] [blame] | 1289 | VisitCXXNamedCastExpr(S); |
| 1290 | } |
| 1291 | |
Chandler Carruth | 631abd9 | 2011-06-16 06:47:06 +0000 | [diff] [blame] | 1292 | void StmtProfiler::VisitCXXDynamicCastExpr(const CXXDynamicCastExpr *S) { |
Douglas Gregor | 5c193b9 | 2009-07-28 00:33:38 +0000 | [diff] [blame] | 1293 | VisitCXXNamedCastExpr(S); |
| 1294 | } |
| 1295 | |
Chandler Carruth | 631abd9 | 2011-06-16 06:47:06 +0000 | [diff] [blame] | 1296 | void |
| 1297 | StmtProfiler::VisitCXXReinterpretCastExpr(const CXXReinterpretCastExpr *S) { |
Douglas Gregor | 5c193b9 | 2009-07-28 00:33:38 +0000 | [diff] [blame] | 1298 | VisitCXXNamedCastExpr(S); |
| 1299 | } |
| 1300 | |
Chandler Carruth | 631abd9 | 2011-06-16 06:47:06 +0000 | [diff] [blame] | 1301 | void StmtProfiler::VisitCXXConstCastExpr(const CXXConstCastExpr *S) { |
Douglas Gregor | 5c193b9 | 2009-07-28 00:33:38 +0000 | [diff] [blame] | 1302 | VisitCXXNamedCastExpr(S); |
| 1303 | } |
| 1304 | |
Richard Smith | c67fdd4 | 2012-03-07 08:35:16 +0000 | [diff] [blame] | 1305 | void StmtProfiler::VisitUserDefinedLiteral(const UserDefinedLiteral *S) { |
| 1306 | VisitCallExpr(S); |
| 1307 | } |
| 1308 | |
Chandler Carruth | 631abd9 | 2011-06-16 06:47:06 +0000 | [diff] [blame] | 1309 | void StmtProfiler::VisitCXXBoolLiteralExpr(const CXXBoolLiteralExpr *S) { |
Douglas Gregor | 5c193b9 | 2009-07-28 00:33:38 +0000 | [diff] [blame] | 1310 | VisitExpr(S); |
| 1311 | ID.AddBoolean(S->getValue()); |
| 1312 | } |
| 1313 | |
Chandler Carruth | 631abd9 | 2011-06-16 06:47:06 +0000 | [diff] [blame] | 1314 | void StmtProfiler::VisitCXXNullPtrLiteralExpr(const CXXNullPtrLiteralExpr *S) { |
Douglas Gregor | 0004417 | 2009-07-29 16:09:57 +0000 | [diff] [blame] | 1315 | VisitExpr(S); |
| 1316 | } |
| 1317 | |
Richard Smith | cc1b96d | 2013-06-12 22:31:48 +0000 | [diff] [blame] | 1318 | void StmtProfiler::VisitCXXStdInitializerListExpr( |
| 1319 | const CXXStdInitializerListExpr *S) { |
| 1320 | VisitExpr(S); |
| 1321 | } |
| 1322 | |
Chandler Carruth | 631abd9 | 2011-06-16 06:47:06 +0000 | [diff] [blame] | 1323 | void StmtProfiler::VisitCXXTypeidExpr(const CXXTypeidExpr *S) { |
Douglas Gregor | 5c193b9 | 2009-07-28 00:33:38 +0000 | [diff] [blame] | 1324 | VisitExpr(S); |
| 1325 | if (S->isTypeOperand()) |
David Majnemer | 143c55e | 2013-09-27 07:04:31 +0000 | [diff] [blame] | 1326 | VisitType(S->getTypeOperandSourceInfo()->getType()); |
Douglas Gregor | 5c193b9 | 2009-07-28 00:33:38 +0000 | [diff] [blame] | 1327 | } |
| 1328 | |
Chandler Carruth | 631abd9 | 2011-06-16 06:47:06 +0000 | [diff] [blame] | 1329 | void StmtProfiler::VisitCXXUuidofExpr(const CXXUuidofExpr *S) { |
Francois Pichet | 9f4f207 | 2010-09-08 12:20:18 +0000 | [diff] [blame] | 1330 | VisitExpr(S); |
| 1331 | if (S->isTypeOperand()) |
David Majnemer | 143c55e | 2013-09-27 07:04:31 +0000 | [diff] [blame] | 1332 | VisitType(S->getTypeOperandSourceInfo()->getType()); |
Francois Pichet | 9f4f207 | 2010-09-08 12:20:18 +0000 | [diff] [blame] | 1333 | } |
| 1334 | |
John McCall | 5e77d76 | 2013-04-16 07:28:30 +0000 | [diff] [blame] | 1335 | void StmtProfiler::VisitMSPropertyRefExpr(const MSPropertyRefExpr *S) { |
| 1336 | VisitExpr(S); |
| 1337 | VisitDecl(S->getPropertyDecl()); |
| 1338 | } |
| 1339 | |
Alexey Bataev | f763027 | 2015-11-25 12:01:00 +0000 | [diff] [blame] | 1340 | void StmtProfiler::VisitMSPropertySubscriptExpr( |
| 1341 | const MSPropertySubscriptExpr *S) { |
| 1342 | VisitExpr(S); |
| 1343 | } |
| 1344 | |
Chandler Carruth | 631abd9 | 2011-06-16 06:47:06 +0000 | [diff] [blame] | 1345 | void StmtProfiler::VisitCXXThisExpr(const CXXThisExpr *S) { |
Douglas Gregor | 5c193b9 | 2009-07-28 00:33:38 +0000 | [diff] [blame] | 1346 | VisitExpr(S); |
Douglas Gregor | 3024f07 | 2012-04-16 07:05:22 +0000 | [diff] [blame] | 1347 | ID.AddBoolean(S->isImplicit()); |
Douglas Gregor | 5c193b9 | 2009-07-28 00:33:38 +0000 | [diff] [blame] | 1348 | } |
| 1349 | |
Chandler Carruth | 631abd9 | 2011-06-16 06:47:06 +0000 | [diff] [blame] | 1350 | void StmtProfiler::VisitCXXThrowExpr(const CXXThrowExpr *S) { |
Douglas Gregor | 5c193b9 | 2009-07-28 00:33:38 +0000 | [diff] [blame] | 1351 | VisitExpr(S); |
| 1352 | } |
| 1353 | |
Chandler Carruth | 631abd9 | 2011-06-16 06:47:06 +0000 | [diff] [blame] | 1354 | void StmtProfiler::VisitCXXDefaultArgExpr(const CXXDefaultArgExpr *S) { |
Douglas Gregor | 5c193b9 | 2009-07-28 00:33:38 +0000 | [diff] [blame] | 1355 | VisitExpr(S); |
| 1356 | VisitDecl(S->getParam()); |
| 1357 | } |
| 1358 | |
Richard Smith | 852c9db | 2013-04-20 22:23:05 +0000 | [diff] [blame] | 1359 | void StmtProfiler::VisitCXXDefaultInitExpr(const CXXDefaultInitExpr *S) { |
| 1360 | VisitExpr(S); |
| 1361 | VisitDecl(S->getField()); |
| 1362 | } |
| 1363 | |
Chandler Carruth | 631abd9 | 2011-06-16 06:47:06 +0000 | [diff] [blame] | 1364 | void StmtProfiler::VisitCXXBindTemporaryExpr(const CXXBindTemporaryExpr *S) { |
Douglas Gregor | 5c193b9 | 2009-07-28 00:33:38 +0000 | [diff] [blame] | 1365 | VisitExpr(S); |
| 1366 | VisitDecl( |
| 1367 | const_cast<CXXDestructorDecl *>(S->getTemporary()->getDestructor())); |
| 1368 | } |
| 1369 | |
Chandler Carruth | 631abd9 | 2011-06-16 06:47:06 +0000 | [diff] [blame] | 1370 | void StmtProfiler::VisitCXXConstructExpr(const CXXConstructExpr *S) { |
Douglas Gregor | 5c193b9 | 2009-07-28 00:33:38 +0000 | [diff] [blame] | 1371 | VisitExpr(S); |
| 1372 | VisitDecl(S->getConstructor()); |
| 1373 | ID.AddBoolean(S->isElidable()); |
| 1374 | } |
| 1375 | |
Richard Smith | 5179eb7 | 2016-06-28 19:03:57 +0000 | [diff] [blame] | 1376 | void StmtProfiler::VisitCXXInheritedCtorInitExpr( |
| 1377 | const CXXInheritedCtorInitExpr *S) { |
| 1378 | VisitExpr(S); |
| 1379 | VisitDecl(S->getConstructor()); |
| 1380 | } |
| 1381 | |
Chandler Carruth | 631abd9 | 2011-06-16 06:47:06 +0000 | [diff] [blame] | 1382 | void StmtProfiler::VisitCXXFunctionalCastExpr(const CXXFunctionalCastExpr *S) { |
Douglas Gregor | 5c193b9 | 2009-07-28 00:33:38 +0000 | [diff] [blame] | 1383 | VisitExplicitCastExpr(S); |
| 1384 | } |
| 1385 | |
Chandler Carruth | 631abd9 | 2011-06-16 06:47:06 +0000 | [diff] [blame] | 1386 | void |
| 1387 | StmtProfiler::VisitCXXTemporaryObjectExpr(const CXXTemporaryObjectExpr *S) { |
Douglas Gregor | 5c193b9 | 2009-07-28 00:33:38 +0000 | [diff] [blame] | 1388 | VisitCXXConstructExpr(S); |
| 1389 | } |
| 1390 | |
Chandler Carruth | 631abd9 | 2011-06-16 06:47:06 +0000 | [diff] [blame] | 1391 | void |
Douglas Gregor | e31e606 | 2012-02-07 10:09:13 +0000 | [diff] [blame] | 1392 | StmtProfiler::VisitLambdaExpr(const LambdaExpr *S) { |
| 1393 | VisitExpr(S); |
| 1394 | for (LambdaExpr::capture_iterator C = S->explicit_capture_begin(), |
| 1395 | CEnd = S->explicit_capture_end(); |
| 1396 | C != CEnd; ++C) { |
| 1397 | ID.AddInteger(C->getCaptureKind()); |
Richard Smith | ba71c08 | 2013-05-16 06:20:58 +0000 | [diff] [blame] | 1398 | switch (C->getCaptureKind()) { |
Faisal Vali | dc6b596 | 2016-03-21 09:25:37 +0000 | [diff] [blame] | 1399 | case LCK_StarThis: |
Richard Smith | ba71c08 | 2013-05-16 06:20:58 +0000 | [diff] [blame] | 1400 | case LCK_This: |
| 1401 | break; |
| 1402 | case LCK_ByRef: |
| 1403 | case LCK_ByCopy: |
Douglas Gregor | e31e606 | 2012-02-07 10:09:13 +0000 | [diff] [blame] | 1404 | VisitDecl(C->getCapturedVar()); |
| 1405 | ID.AddBoolean(C->isPackExpansion()); |
Richard Smith | ba71c08 | 2013-05-16 06:20:58 +0000 | [diff] [blame] | 1406 | break; |
Alexey Bataev | 39c81e2 | 2014-08-28 04:28:19 +0000 | [diff] [blame] | 1407 | case LCK_VLAType: |
| 1408 | llvm_unreachable("VLA type in explicit captures."); |
Douglas Gregor | e31e606 | 2012-02-07 10:09:13 +0000 | [diff] [blame] | 1409 | } |
| 1410 | } |
| 1411 | // Note: If we actually needed to be able to match lambda |
| 1412 | // expressions, we would have to consider parameters and return type |
| 1413 | // here, among other things. |
| 1414 | VisitStmt(S->getBody()); |
| 1415 | } |
| 1416 | |
| 1417 | void |
Chandler Carruth | 631abd9 | 2011-06-16 06:47:06 +0000 | [diff] [blame] | 1418 | StmtProfiler::VisitCXXScalarValueInitExpr(const CXXScalarValueInitExpr *S) { |
Douglas Gregor | 5c193b9 | 2009-07-28 00:33:38 +0000 | [diff] [blame] | 1419 | VisitExpr(S); |
| 1420 | } |
| 1421 | |
Chandler Carruth | 631abd9 | 2011-06-16 06:47:06 +0000 | [diff] [blame] | 1422 | void StmtProfiler::VisitCXXDeleteExpr(const CXXDeleteExpr *S) { |
Douglas Gregor | 5c193b9 | 2009-07-28 00:33:38 +0000 | [diff] [blame] | 1423 | VisitExpr(S); |
| 1424 | ID.AddBoolean(S->isGlobalDelete()); |
| 1425 | ID.AddBoolean(S->isArrayForm()); |
| 1426 | VisitDecl(S->getOperatorDelete()); |
| 1427 | } |
| 1428 | |
Chandler Carruth | 631abd9 | 2011-06-16 06:47:06 +0000 | [diff] [blame] | 1429 | void StmtProfiler::VisitCXXNewExpr(const CXXNewExpr *S) { |
Douglas Gregor | 5c193b9 | 2009-07-28 00:33:38 +0000 | [diff] [blame] | 1430 | VisitExpr(S); |
| 1431 | VisitType(S->getAllocatedType()); |
| 1432 | VisitDecl(S->getOperatorNew()); |
| 1433 | VisitDecl(S->getOperatorDelete()); |
Douglas Gregor | 5c193b9 | 2009-07-28 00:33:38 +0000 | [diff] [blame] | 1434 | ID.AddBoolean(S->isArray()); |
| 1435 | ID.AddInteger(S->getNumPlacementArgs()); |
| 1436 | ID.AddBoolean(S->isGlobalNew()); |
| 1437 | ID.AddBoolean(S->isParenTypeId()); |
Sebastian Redl | 6047f07 | 2012-02-16 12:22:20 +0000 | [diff] [blame] | 1438 | ID.AddInteger(S->getInitializationStyle()); |
Douglas Gregor | 5c193b9 | 2009-07-28 00:33:38 +0000 | [diff] [blame] | 1439 | } |
| 1440 | |
Chandler Carruth | 631abd9 | 2011-06-16 06:47:06 +0000 | [diff] [blame] | 1441 | void |
| 1442 | StmtProfiler::VisitCXXPseudoDestructorExpr(const CXXPseudoDestructorExpr *S) { |
Douglas Gregor | ad8a336 | 2009-09-04 17:36:40 +0000 | [diff] [blame] | 1443 | VisitExpr(S); |
| 1444 | ID.AddBoolean(S->isArrow()); |
| 1445 | VisitNestedNameSpecifier(S->getQualifier()); |
Craig Topper | 36250ad | 2014-05-12 05:36:57 +0000 | [diff] [blame] | 1446 | ID.AddBoolean(S->getScopeTypeInfo() != nullptr); |
Eli Friedman | 8564139 | 2013-08-09 23:37:05 +0000 | [diff] [blame] | 1447 | if (S->getScopeTypeInfo()) |
| 1448 | VisitType(S->getScopeTypeInfo()->getType()); |
Craig Topper | 36250ad | 2014-05-12 05:36:57 +0000 | [diff] [blame] | 1449 | ID.AddBoolean(S->getDestroyedTypeInfo() != nullptr); |
Eli Friedman | 8564139 | 2013-08-09 23:37:05 +0000 | [diff] [blame] | 1450 | if (S->getDestroyedTypeInfo()) |
| 1451 | VisitType(S->getDestroyedType()); |
| 1452 | else |
| 1453 | ID.AddPointer(S->getDestroyedTypeIdentifier()); |
Douglas Gregor | ad8a336 | 2009-09-04 17:36:40 +0000 | [diff] [blame] | 1454 | } |
| 1455 | |
Chandler Carruth | 631abd9 | 2011-06-16 06:47:06 +0000 | [diff] [blame] | 1456 | void StmtProfiler::VisitOverloadExpr(const OverloadExpr *S) { |
Argyrios Kyrtzidis | b482eb8 | 2010-08-15 20:53:20 +0000 | [diff] [blame] | 1457 | VisitExpr(S); |
John McCall | e66edc1 | 2009-11-24 19:00:30 +0000 | [diff] [blame] | 1458 | VisitNestedNameSpecifier(S->getQualifier()); |
Douglas Gregor | 5c193b9 | 2009-07-28 00:33:38 +0000 | [diff] [blame] | 1459 | VisitName(S->getName()); |
John McCall | e66edc1 | 2009-11-24 19:00:30 +0000 | [diff] [blame] | 1460 | ID.AddBoolean(S->hasExplicitTemplateArgs()); |
| 1461 | if (S->hasExplicitTemplateArgs()) |
James Y Knight | 04ec5bf | 2015-12-24 02:59:37 +0000 | [diff] [blame] | 1462 | VisitTemplateArguments(S->getTemplateArgs(), S->getNumTemplateArgs()); |
Argyrios Kyrtzidis | f450545 | 2010-08-15 01:15:38 +0000 | [diff] [blame] | 1463 | } |
| 1464 | |
| 1465 | void |
Chandler Carruth | 631abd9 | 2011-06-16 06:47:06 +0000 | [diff] [blame] | 1466 | StmtProfiler::VisitUnresolvedLookupExpr(const UnresolvedLookupExpr *S) { |
Argyrios Kyrtzidis | f450545 | 2010-08-15 01:15:38 +0000 | [diff] [blame] | 1467 | VisitOverloadExpr(S); |
Douglas Gregor | 5c193b9 | 2009-07-28 00:33:38 +0000 | [diff] [blame] | 1468 | } |
| 1469 | |
Douglas Gregor | 29c42f2 | 2012-02-24 07:38:34 +0000 | [diff] [blame] | 1470 | void StmtProfiler::VisitTypeTraitExpr(const TypeTraitExpr *S) { |
| 1471 | VisitExpr(S); |
| 1472 | ID.AddInteger(S->getTrait()); |
| 1473 | ID.AddInteger(S->getNumArgs()); |
| 1474 | for (unsigned I = 0, N = S->getNumArgs(); I != N; ++I) |
| 1475 | VisitType(S->getArg(I)->getType()); |
| 1476 | } |
| 1477 | |
Chandler Carruth | 631abd9 | 2011-06-16 06:47:06 +0000 | [diff] [blame] | 1478 | void StmtProfiler::VisitArrayTypeTraitExpr(const ArrayTypeTraitExpr *S) { |
John Wiegley | 6242b6a | 2011-04-28 00:16:57 +0000 | [diff] [blame] | 1479 | VisitExpr(S); |
| 1480 | ID.AddInteger(S->getTrait()); |
| 1481 | VisitType(S->getQueriedType()); |
| 1482 | } |
| 1483 | |
Chandler Carruth | 631abd9 | 2011-06-16 06:47:06 +0000 | [diff] [blame] | 1484 | void StmtProfiler::VisitExpressionTraitExpr(const ExpressionTraitExpr *S) { |
John Wiegley | f9f6584 | 2011-04-25 06:54:41 +0000 | [diff] [blame] | 1485 | VisitExpr(S); |
| 1486 | ID.AddInteger(S->getTrait()); |
| 1487 | VisitExpr(S->getQueriedExpression()); |
| 1488 | } |
| 1489 | |
Chandler Carruth | 631abd9 | 2011-06-16 06:47:06 +0000 | [diff] [blame] | 1490 | void StmtProfiler::VisitDependentScopeDeclRefExpr( |
| 1491 | const DependentScopeDeclRefExpr *S) { |
Douglas Gregor | 5c193b9 | 2009-07-28 00:33:38 +0000 | [diff] [blame] | 1492 | VisitExpr(S); |
| 1493 | VisitName(S->getDeclName()); |
| 1494 | VisitNestedNameSpecifier(S->getQualifier()); |
John McCall | e66edc1 | 2009-11-24 19:00:30 +0000 | [diff] [blame] | 1495 | ID.AddBoolean(S->hasExplicitTemplateArgs()); |
| 1496 | if (S->hasExplicitTemplateArgs()) |
| 1497 | VisitTemplateArguments(S->getTemplateArgs(), S->getNumTemplateArgs()); |
Douglas Gregor | 5c193b9 | 2009-07-28 00:33:38 +0000 | [diff] [blame] | 1498 | } |
| 1499 | |
Chandler Carruth | 631abd9 | 2011-06-16 06:47:06 +0000 | [diff] [blame] | 1500 | void StmtProfiler::VisitExprWithCleanups(const ExprWithCleanups *S) { |
Douglas Gregor | a709509 | 2009-07-28 14:44:31 +0000 | [diff] [blame] | 1501 | VisitExpr(S); |
Douglas Gregor | a709509 | 2009-07-28 14:44:31 +0000 | [diff] [blame] | 1502 | } |
| 1503 | |
Chandler Carruth | 631abd9 | 2011-06-16 06:47:06 +0000 | [diff] [blame] | 1504 | void StmtProfiler::VisitCXXUnresolvedConstructExpr( |
| 1505 | const CXXUnresolvedConstructExpr *S) { |
Douglas Gregor | a709509 | 2009-07-28 14:44:31 +0000 | [diff] [blame] | 1506 | VisitExpr(S); |
| 1507 | VisitType(S->getTypeAsWritten()); |
| 1508 | } |
| 1509 | |
Chandler Carruth | 631abd9 | 2011-06-16 06:47:06 +0000 | [diff] [blame] | 1510 | void StmtProfiler::VisitCXXDependentScopeMemberExpr( |
| 1511 | const CXXDependentScopeMemberExpr *S) { |
John McCall | 2d74de9 | 2009-12-01 22:10:20 +0000 | [diff] [blame] | 1512 | ID.AddBoolean(S->isImplicitAccess()); |
| 1513 | if (!S->isImplicitAccess()) { |
| 1514 | VisitExpr(S); |
| 1515 | ID.AddBoolean(S->isArrow()); |
| 1516 | } |
Douglas Gregor | c26e0f6 | 2009-09-03 16:14:30 +0000 | [diff] [blame] | 1517 | VisitNestedNameSpecifier(S->getQualifier()); |
Douglas Gregor | a709509 | 2009-07-28 14:44:31 +0000 | [diff] [blame] | 1518 | VisitName(S->getMember()); |
John McCall | 2d74de9 | 2009-12-01 22:10:20 +0000 | [diff] [blame] | 1519 | ID.AddBoolean(S->hasExplicitTemplateArgs()); |
| 1520 | if (S->hasExplicitTemplateArgs()) |
John McCall | 10eae18 | 2009-11-30 22:42:35 +0000 | [diff] [blame] | 1521 | VisitTemplateArguments(S->getTemplateArgs(), S->getNumTemplateArgs()); |
| 1522 | } |
| 1523 | |
Chandler Carruth | 631abd9 | 2011-06-16 06:47:06 +0000 | [diff] [blame] | 1524 | void StmtProfiler::VisitUnresolvedMemberExpr(const UnresolvedMemberExpr *S) { |
John McCall | 2d74de9 | 2009-12-01 22:10:20 +0000 | [diff] [blame] | 1525 | ID.AddBoolean(S->isImplicitAccess()); |
| 1526 | if (!S->isImplicitAccess()) { |
| 1527 | VisitExpr(S); |
| 1528 | ID.AddBoolean(S->isArrow()); |
| 1529 | } |
John McCall | 10eae18 | 2009-11-30 22:42:35 +0000 | [diff] [blame] | 1530 | VisitNestedNameSpecifier(S->getQualifier()); |
| 1531 | VisitName(S->getMemberName()); |
| 1532 | ID.AddBoolean(S->hasExplicitTemplateArgs()); |
| 1533 | if (S->hasExplicitTemplateArgs()) |
| 1534 | VisitTemplateArguments(S->getTemplateArgs(), S->getNumTemplateArgs()); |
Douglas Gregor | a709509 | 2009-07-28 14:44:31 +0000 | [diff] [blame] | 1535 | } |
| 1536 | |
Chandler Carruth | 631abd9 | 2011-06-16 06:47:06 +0000 | [diff] [blame] | 1537 | void StmtProfiler::VisitCXXNoexceptExpr(const CXXNoexceptExpr *S) { |
Sebastian Redl | 4202c0f | 2010-09-10 20:55:43 +0000 | [diff] [blame] | 1538 | VisitExpr(S); |
| 1539 | } |
| 1540 | |
Chandler Carruth | 631abd9 | 2011-06-16 06:47:06 +0000 | [diff] [blame] | 1541 | void StmtProfiler::VisitPackExpansionExpr(const PackExpansionExpr *S) { |
Douglas Gregor | e8e9dd6 | 2011-01-03 17:17:50 +0000 | [diff] [blame] | 1542 | VisitExpr(S); |
| 1543 | } |
| 1544 | |
Chandler Carruth | 631abd9 | 2011-06-16 06:47:06 +0000 | [diff] [blame] | 1545 | void StmtProfiler::VisitSizeOfPackExpr(const SizeOfPackExpr *S) { |
Douglas Gregor | 820ba7b | 2011-01-04 17:33:58 +0000 | [diff] [blame] | 1546 | VisitExpr(S); |
| 1547 | VisitDecl(S->getPack()); |
Richard Smith | d784e68 | 2015-09-23 21:41:42 +0000 | [diff] [blame] | 1548 | if (S->isPartiallySubstituted()) { |
| 1549 | auto Args = S->getPartialArguments(); |
| 1550 | ID.AddInteger(Args.size()); |
| 1551 | for (const auto &TA : Args) |
| 1552 | VisitTemplateArgument(TA); |
| 1553 | } else { |
| 1554 | ID.AddInteger(0); |
| 1555 | } |
Douglas Gregor | 820ba7b | 2011-01-04 17:33:58 +0000 | [diff] [blame] | 1556 | } |
| 1557 | |
Douglas Gregor | cdbc539 | 2011-01-15 01:15:58 +0000 | [diff] [blame] | 1558 | void StmtProfiler::VisitSubstNonTypeTemplateParmPackExpr( |
Chandler Carruth | 631abd9 | 2011-06-16 06:47:06 +0000 | [diff] [blame] | 1559 | const SubstNonTypeTemplateParmPackExpr *S) { |
Douglas Gregor | cdbc539 | 2011-01-15 01:15:58 +0000 | [diff] [blame] | 1560 | VisitExpr(S); |
| 1561 | VisitDecl(S->getParameterPack()); |
| 1562 | VisitTemplateArgument(S->getArgumentPack()); |
| 1563 | } |
| 1564 | |
John McCall | 7c454bb | 2011-07-15 05:09:51 +0000 | [diff] [blame] | 1565 | void StmtProfiler::VisitSubstNonTypeTemplateParmExpr( |
| 1566 | const SubstNonTypeTemplateParmExpr *E) { |
| 1567 | // Profile exactly as the replacement expression. |
| 1568 | Visit(E->getReplacement()); |
| 1569 | } |
| 1570 | |
Richard Smith | b15fe3a | 2012-09-12 00:56:43 +0000 | [diff] [blame] | 1571 | void StmtProfiler::VisitFunctionParmPackExpr(const FunctionParmPackExpr *S) { |
| 1572 | VisitExpr(S); |
| 1573 | VisitDecl(S->getParameterPack()); |
| 1574 | ID.AddInteger(S->getNumExpansions()); |
| 1575 | for (FunctionParmPackExpr::iterator I = S->begin(), E = S->end(); I != E; ++I) |
| 1576 | VisitDecl(*I); |
| 1577 | } |
| 1578 | |
Douglas Gregor | fe31481 | 2011-06-21 17:03:29 +0000 | [diff] [blame] | 1579 | void StmtProfiler::VisitMaterializeTemporaryExpr( |
| 1580 | const MaterializeTemporaryExpr *S) { |
| 1581 | VisitExpr(S); |
| 1582 | } |
| 1583 | |
Richard Smith | 0f0af19 | 2014-11-08 05:07:16 +0000 | [diff] [blame] | 1584 | void StmtProfiler::VisitCXXFoldExpr(const CXXFoldExpr *S) { |
| 1585 | VisitExpr(S); |
| 1586 | ID.AddInteger(S->getOperator()); |
| 1587 | } |
| 1588 | |
Richard Smith | 9f690bd | 2015-10-27 06:02:45 +0000 | [diff] [blame] | 1589 | void StmtProfiler::VisitCoroutineBodyStmt(const CoroutineBodyStmt *S) { |
| 1590 | VisitStmt(S); |
| 1591 | } |
| 1592 | |
| 1593 | void StmtProfiler::VisitCoreturnStmt(const CoreturnStmt *S) { |
| 1594 | VisitStmt(S); |
| 1595 | } |
| 1596 | |
| 1597 | void StmtProfiler::VisitCoawaitExpr(const CoawaitExpr *S) { |
| 1598 | VisitExpr(S); |
| 1599 | } |
| 1600 | |
| 1601 | void StmtProfiler::VisitCoyieldExpr(const CoyieldExpr *S) { |
| 1602 | VisitExpr(S); |
| 1603 | } |
| 1604 | |
Chandler Carruth | 631abd9 | 2011-06-16 06:47:06 +0000 | [diff] [blame] | 1605 | void StmtProfiler::VisitOpaqueValueExpr(const OpaqueValueExpr *E) { |
John McCall | 8d69a21 | 2010-11-15 23:31:06 +0000 | [diff] [blame] | 1606 | VisitExpr(E); |
| 1607 | } |
| 1608 | |
Kaelyn Takata | e1f49d5 | 2014-10-27 18:07:20 +0000 | [diff] [blame] | 1609 | void StmtProfiler::VisitTypoExpr(const TypoExpr *E) { |
| 1610 | VisitExpr(E); |
| 1611 | } |
| 1612 | |
Chandler Carruth | 631abd9 | 2011-06-16 06:47:06 +0000 | [diff] [blame] | 1613 | void StmtProfiler::VisitObjCStringLiteral(const ObjCStringLiteral *S) { |
Douglas Gregor | a709509 | 2009-07-28 14:44:31 +0000 | [diff] [blame] | 1614 | VisitExpr(S); |
| 1615 | } |
| 1616 | |
Patrick Beard | 0caa394 | 2012-04-19 00:25:12 +0000 | [diff] [blame] | 1617 | void StmtProfiler::VisitObjCBoxedExpr(const ObjCBoxedExpr *E) { |
Ted Kremenek | e65b086 | 2012-03-06 20:05:56 +0000 | [diff] [blame] | 1618 | VisitExpr(E); |
| 1619 | } |
| 1620 | |
| 1621 | void StmtProfiler::VisitObjCArrayLiteral(const ObjCArrayLiteral *E) { |
| 1622 | VisitExpr(E); |
| 1623 | } |
| 1624 | |
| 1625 | void StmtProfiler::VisitObjCDictionaryLiteral(const ObjCDictionaryLiteral *E) { |
| 1626 | VisitExpr(E); |
| 1627 | } |
| 1628 | |
Chandler Carruth | 631abd9 | 2011-06-16 06:47:06 +0000 | [diff] [blame] | 1629 | void StmtProfiler::VisitObjCEncodeExpr(const ObjCEncodeExpr *S) { |
Douglas Gregor | a709509 | 2009-07-28 14:44:31 +0000 | [diff] [blame] | 1630 | VisitExpr(S); |
| 1631 | VisitType(S->getEncodedType()); |
| 1632 | } |
| 1633 | |
Chandler Carruth | 631abd9 | 2011-06-16 06:47:06 +0000 | [diff] [blame] | 1634 | void StmtProfiler::VisitObjCSelectorExpr(const ObjCSelectorExpr *S) { |
Douglas Gregor | a709509 | 2009-07-28 14:44:31 +0000 | [diff] [blame] | 1635 | VisitExpr(S); |
| 1636 | VisitName(S->getSelector()); |
| 1637 | } |
| 1638 | |
Chandler Carruth | 631abd9 | 2011-06-16 06:47:06 +0000 | [diff] [blame] | 1639 | void StmtProfiler::VisitObjCProtocolExpr(const ObjCProtocolExpr *S) { |
Douglas Gregor | a709509 | 2009-07-28 14:44:31 +0000 | [diff] [blame] | 1640 | VisitExpr(S); |
| 1641 | VisitDecl(S->getProtocol()); |
| 1642 | } |
| 1643 | |
Chandler Carruth | 631abd9 | 2011-06-16 06:47:06 +0000 | [diff] [blame] | 1644 | void StmtProfiler::VisitObjCIvarRefExpr(const ObjCIvarRefExpr *S) { |
Douglas Gregor | a709509 | 2009-07-28 14:44:31 +0000 | [diff] [blame] | 1645 | VisitExpr(S); |
| 1646 | VisitDecl(S->getDecl()); |
| 1647 | ID.AddBoolean(S->isArrow()); |
| 1648 | ID.AddBoolean(S->isFreeIvar()); |
| 1649 | } |
| 1650 | |
Chandler Carruth | 631abd9 | 2011-06-16 06:47:06 +0000 | [diff] [blame] | 1651 | void StmtProfiler::VisitObjCPropertyRefExpr(const ObjCPropertyRefExpr *S) { |
Douglas Gregor | a709509 | 2009-07-28 14:44:31 +0000 | [diff] [blame] | 1652 | VisitExpr(S); |
John McCall | b7bd14f | 2010-12-02 01:19:52 +0000 | [diff] [blame] | 1653 | if (S->isImplicitProperty()) { |
| 1654 | VisitDecl(S->getImplicitPropertyGetter()); |
| 1655 | VisitDecl(S->getImplicitPropertySetter()); |
| 1656 | } else { |
| 1657 | VisitDecl(S->getExplicitProperty()); |
Fariborz Jahanian | 681c075 | 2010-10-14 16:04:05 +0000 | [diff] [blame] | 1658 | } |
Fariborz Jahanian | 681c075 | 2010-10-14 16:04:05 +0000 | [diff] [blame] | 1659 | if (S->isSuperReceiver()) { |
| 1660 | ID.AddBoolean(S->isSuperReceiver()); |
John McCall | b7bd14f | 2010-12-02 01:19:52 +0000 | [diff] [blame] | 1661 | VisitType(S->getSuperReceiverType()); |
Fariborz Jahanian | 681c075 | 2010-10-14 16:04:05 +0000 | [diff] [blame] | 1662 | } |
Douglas Gregor | a709509 | 2009-07-28 14:44:31 +0000 | [diff] [blame] | 1663 | } |
| 1664 | |
Ted Kremenek | e65b086 | 2012-03-06 20:05:56 +0000 | [diff] [blame] | 1665 | void StmtProfiler::VisitObjCSubscriptRefExpr(const ObjCSubscriptRefExpr *S) { |
| 1666 | VisitExpr(S); |
| 1667 | VisitDecl(S->getAtIndexMethodDecl()); |
| 1668 | VisitDecl(S->setAtIndexMethodDecl()); |
| 1669 | } |
| 1670 | |
Chandler Carruth | 631abd9 | 2011-06-16 06:47:06 +0000 | [diff] [blame] | 1671 | void StmtProfiler::VisitObjCMessageExpr(const ObjCMessageExpr *S) { |
Douglas Gregor | a709509 | 2009-07-28 14:44:31 +0000 | [diff] [blame] | 1672 | VisitExpr(S); |
| 1673 | VisitName(S->getSelector()); |
| 1674 | VisitDecl(S->getMethodDecl()); |
| 1675 | } |
| 1676 | |
Chandler Carruth | 631abd9 | 2011-06-16 06:47:06 +0000 | [diff] [blame] | 1677 | void StmtProfiler::VisitObjCIsaExpr(const ObjCIsaExpr *S) { |
Douglas Gregor | a709509 | 2009-07-28 14:44:31 +0000 | [diff] [blame] | 1678 | VisitExpr(S); |
| 1679 | ID.AddBoolean(S->isArrow()); |
| 1680 | } |
| 1681 | |
Ted Kremenek | e65b086 | 2012-03-06 20:05:56 +0000 | [diff] [blame] | 1682 | void StmtProfiler::VisitObjCBoolLiteralExpr(const ObjCBoolLiteralExpr *S) { |
| 1683 | VisitExpr(S); |
| 1684 | ID.AddBoolean(S->getValue()); |
| 1685 | } |
| 1686 | |
Chandler Carruth | 631abd9 | 2011-06-16 06:47:06 +0000 | [diff] [blame] | 1687 | void StmtProfiler::VisitObjCIndirectCopyRestoreExpr( |
| 1688 | const ObjCIndirectCopyRestoreExpr *S) { |
John McCall | 31168b0 | 2011-06-15 23:02:42 +0000 | [diff] [blame] | 1689 | VisitExpr(S); |
| 1690 | ID.AddBoolean(S->shouldCopy()); |
| 1691 | } |
| 1692 | |
Chandler Carruth | 631abd9 | 2011-06-16 06:47:06 +0000 | [diff] [blame] | 1693 | void StmtProfiler::VisitObjCBridgedCastExpr(const ObjCBridgedCastExpr *S) { |
John McCall | 31168b0 | 2011-06-15 23:02:42 +0000 | [diff] [blame] | 1694 | VisitExplicitCastExpr(S); |
| 1695 | ID.AddBoolean(S->getBridgeKind()); |
| 1696 | } |
| 1697 | |
Erik Pilkington | 29099de | 2016-07-16 00:35:23 +0000 | [diff] [blame] | 1698 | void StmtProfiler::VisitObjCAvailabilityCheckExpr( |
| 1699 | const ObjCAvailabilityCheckExpr *S) { |
| 1700 | VisitExpr(S); |
| 1701 | } |
| 1702 | |
Chandler Carruth | 631abd9 | 2011-06-16 06:47:06 +0000 | [diff] [blame] | 1703 | void StmtProfiler::VisitDecl(const Decl *D) { |
Douglas Gregor | 7031712 | 2009-07-31 15:45:02 +0000 | [diff] [blame] | 1704 | ID.AddInteger(D? D->getKind() : 0); |
Mike Stump | 11289f4 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 1705 | |
Douglas Gregor | a5dd9f8 | 2009-07-30 23:18:24 +0000 | [diff] [blame] | 1706 | if (Canonical && D) { |
Chandler Carruth | 631abd9 | 2011-06-16 06:47:06 +0000 | [diff] [blame] | 1707 | if (const NonTypeTemplateParmDecl *NTTP = |
| 1708 | dyn_cast<NonTypeTemplateParmDecl>(D)) { |
Douglas Gregor | d9aedfa | 2009-07-28 15:32:17 +0000 | [diff] [blame] | 1709 | ID.AddInteger(NTTP->getDepth()); |
| 1710 | ID.AddInteger(NTTP->getIndex()); |
Douglas Gregor | f550077 | 2011-01-05 15:48:55 +0000 | [diff] [blame] | 1711 | ID.AddBoolean(NTTP->isParameterPack()); |
Douglas Gregor | 0004417 | 2009-07-29 16:09:57 +0000 | [diff] [blame] | 1712 | VisitType(NTTP->getType()); |
Douglas Gregor | 5c193b9 | 2009-07-28 00:33:38 +0000 | [diff] [blame] | 1713 | return; |
| 1714 | } |
Mike Stump | 11289f4 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 1715 | |
Chandler Carruth | 631abd9 | 2011-06-16 06:47:06 +0000 | [diff] [blame] | 1716 | if (const ParmVarDecl *Parm = dyn_cast<ParmVarDecl>(D)) { |
John McCall | 8fb0d9d | 2011-05-01 22:35:37 +0000 | [diff] [blame] | 1717 | // The Itanium C++ ABI uses the type, scope depth, and scope |
| 1718 | // index of a parameter when mangling expressions that involve |
| 1719 | // function parameters, so we will use the parameter's type for |
| 1720 | // establishing function parameter identity. That way, our |
| 1721 | // definition of "equivalent" (per C++ [temp.over.link]) is at |
| 1722 | // least as strong as the definition of "equivalent" used for |
| 1723 | // name mangling. |
Douglas Gregor | 7031712 | 2009-07-31 15:45:02 +0000 | [diff] [blame] | 1724 | VisitType(Parm->getType()); |
John McCall | 8fb0d9d | 2011-05-01 22:35:37 +0000 | [diff] [blame] | 1725 | ID.AddInteger(Parm->getFunctionScopeDepth()); |
| 1726 | ID.AddInteger(Parm->getFunctionScopeIndex()); |
Douglas Gregor | 7031712 | 2009-07-31 15:45:02 +0000 | [diff] [blame] | 1727 | return; |
| 1728 | } |
Mike Stump | 11289f4 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 1729 | |
Richard Smith | d9a1cd8 | 2012-04-02 18:53:24 +0000 | [diff] [blame] | 1730 | if (const TemplateTypeParmDecl *TTP = |
| 1731 | dyn_cast<TemplateTypeParmDecl>(D)) { |
| 1732 | ID.AddInteger(TTP->getDepth()); |
| 1733 | ID.AddInteger(TTP->getIndex()); |
| 1734 | ID.AddBoolean(TTP->isParameterPack()); |
| 1735 | return; |
| 1736 | } |
| 1737 | |
Chandler Carruth | 631abd9 | 2011-06-16 06:47:06 +0000 | [diff] [blame] | 1738 | if (const TemplateTemplateParmDecl *TTP = |
| 1739 | dyn_cast<TemplateTemplateParmDecl>(D)) { |
Douglas Gregor | c97f09f | 2009-07-31 15:46:56 +0000 | [diff] [blame] | 1740 | ID.AddInteger(TTP->getDepth()); |
| 1741 | ID.AddInteger(TTP->getIndex()); |
Douglas Gregor | f550077 | 2011-01-05 15:48:55 +0000 | [diff] [blame] | 1742 | ID.AddBoolean(TTP->isParameterPack()); |
Douglas Gregor | c97f09f | 2009-07-31 15:46:56 +0000 | [diff] [blame] | 1743 | return; |
| 1744 | } |
Douglas Gregor | 5c193b9 | 2009-07-28 00:33:38 +0000 | [diff] [blame] | 1745 | } |
Mike Stump | 11289f4 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 1746 | |
Craig Topper | 36250ad | 2014-05-12 05:36:57 +0000 | [diff] [blame] | 1747 | ID.AddPointer(D? D->getCanonicalDecl() : nullptr); |
Douglas Gregor | d9aedfa | 2009-07-28 15:32:17 +0000 | [diff] [blame] | 1748 | } |
| 1749 | |
| 1750 | void StmtProfiler::VisitType(QualType T) { |
| 1751 | if (Canonical) |
| 1752 | T = Context.getCanonicalType(T); |
Mike Stump | 11289f4 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 1753 | |
Douglas Gregor | 5c193b9 | 2009-07-28 00:33:38 +0000 | [diff] [blame] | 1754 | ID.AddPointer(T.getAsOpaquePtr()); |
| 1755 | } |
| 1756 | |
| 1757 | void StmtProfiler::VisitName(DeclarationName Name) { |
| 1758 | ID.AddPointer(Name.getAsOpaquePtr()); |
| 1759 | } |
| 1760 | |
| 1761 | void StmtProfiler::VisitNestedNameSpecifier(NestedNameSpecifier *NNS) { |
| 1762 | if (Canonical) |
| 1763 | NNS = Context.getCanonicalNestedNameSpecifier(NNS); |
| 1764 | ID.AddPointer(NNS); |
| 1765 | } |
| 1766 | |
| 1767 | void StmtProfiler::VisitTemplateName(TemplateName Name) { |
| 1768 | if (Canonical) |
| 1769 | Name = Context.getCanonicalTemplateName(Name); |
Mike Stump | 11289f4 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 1770 | |
Douglas Gregor | 5c193b9 | 2009-07-28 00:33:38 +0000 | [diff] [blame] | 1771 | Name.Profile(ID); |
| 1772 | } |
| 1773 | |
John McCall | 0ad1666 | 2009-10-29 08:12:44 +0000 | [diff] [blame] | 1774 | void StmtProfiler::VisitTemplateArguments(const TemplateArgumentLoc *Args, |
Douglas Gregor | 5c193b9 | 2009-07-28 00:33:38 +0000 | [diff] [blame] | 1775 | unsigned NumArgs) { |
| 1776 | ID.AddInteger(NumArgs); |
John McCall | 0ad1666 | 2009-10-29 08:12:44 +0000 | [diff] [blame] | 1777 | for (unsigned I = 0; I != NumArgs; ++I) |
| 1778 | VisitTemplateArgument(Args[I].getArgument()); |
| 1779 | } |
Mike Stump | 11289f4 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 1780 | |
John McCall | 0ad1666 | 2009-10-29 08:12:44 +0000 | [diff] [blame] | 1781 | void StmtProfiler::VisitTemplateArgument(const TemplateArgument &Arg) { |
| 1782 | // Mostly repetitive with TemplateArgument::Profile! |
| 1783 | ID.AddInteger(Arg.getKind()); |
| 1784 | switch (Arg.getKind()) { |
| 1785 | case TemplateArgument::Null: |
| 1786 | break; |
Mike Stump | 11289f4 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 1787 | |
John McCall | 0ad1666 | 2009-10-29 08:12:44 +0000 | [diff] [blame] | 1788 | case TemplateArgument::Type: |
| 1789 | VisitType(Arg.getAsType()); |
| 1790 | break; |
Mike Stump | 11289f4 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 1791 | |
Douglas Gregor | 9167f8b | 2009-11-11 01:00:40 +0000 | [diff] [blame] | 1792 | case TemplateArgument::Template: |
Douglas Gregor | e4ff4b5 | 2011-01-05 18:58:31 +0000 | [diff] [blame] | 1793 | case TemplateArgument::TemplateExpansion: |
| 1794 | VisitTemplateName(Arg.getAsTemplateOrTemplatePattern()); |
Douglas Gregor | 9167f8b | 2009-11-11 01:00:40 +0000 | [diff] [blame] | 1795 | break; |
Alexis Hunt | a8136cc | 2010-05-05 15:23:54 +0000 | [diff] [blame] | 1796 | |
John McCall | 0ad1666 | 2009-10-29 08:12:44 +0000 | [diff] [blame] | 1797 | case TemplateArgument::Declaration: |
| 1798 | VisitDecl(Arg.getAsDecl()); |
| 1799 | break; |
Mike Stump | 11289f4 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 1800 | |
Eli Friedman | b826a00 | 2012-09-26 02:36:12 +0000 | [diff] [blame] | 1801 | case TemplateArgument::NullPtr: |
| 1802 | VisitType(Arg.getNullPtrType()); |
| 1803 | break; |
| 1804 | |
John McCall | 0ad1666 | 2009-10-29 08:12:44 +0000 | [diff] [blame] | 1805 | case TemplateArgument::Integral: |
Benjamin Kramer | 6003ad5 | 2012-06-07 15:09:51 +0000 | [diff] [blame] | 1806 | Arg.getAsIntegral().Profile(ID); |
John McCall | 0ad1666 | 2009-10-29 08:12:44 +0000 | [diff] [blame] | 1807 | VisitType(Arg.getIntegralType()); |
| 1808 | break; |
Mike Stump | 11289f4 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 1809 | |
John McCall | 0ad1666 | 2009-10-29 08:12:44 +0000 | [diff] [blame] | 1810 | case TemplateArgument::Expression: |
| 1811 | Visit(Arg.getAsExpr()); |
| 1812 | break; |
Mike Stump | 11289f4 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 1813 | |
John McCall | 0ad1666 | 2009-10-29 08:12:44 +0000 | [diff] [blame] | 1814 | case TemplateArgument::Pack: |
Aaron Ballman | 2a89e85 | 2014-07-15 21:32:31 +0000 | [diff] [blame] | 1815 | for (const auto &P : Arg.pack_elements()) |
| 1816 | VisitTemplateArgument(P); |
John McCall | 0ad1666 | 2009-10-29 08:12:44 +0000 | [diff] [blame] | 1817 | break; |
Douglas Gregor | 5c193b9 | 2009-07-28 00:33:38 +0000 | [diff] [blame] | 1818 | } |
| 1819 | } |
| 1820 | |
Jay Foad | 39c7980 | 2011-01-12 09:06:06 +0000 | [diff] [blame] | 1821 | void Stmt::Profile(llvm::FoldingSetNodeID &ID, const ASTContext &Context, |
Chandler Carruth | 631abd9 | 2011-06-16 06:47:06 +0000 | [diff] [blame] | 1822 | bool Canonical) const { |
Douglas Gregor | 5c193b9 | 2009-07-28 00:33:38 +0000 | [diff] [blame] | 1823 | StmtProfiler Profiler(ID, Context, Canonical); |
| 1824 | Profiler.Visit(this); |
| 1825 | } |