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