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