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