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