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