Douglas Gregor | 41ef0c3 | 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 | 00aa3a6 | 2009-07-28 16:39:25 +0000 | [diff] [blame] | 11 | // representation that identifies a statement/expression. |
Douglas Gregor | 41ef0c3 | 2009-07-28 00:33:38 +0000 | [diff] [blame] | 12 | // |
| 13 | //===----------------------------------------------------------------------===// |
| 14 | #include "clang/AST/ASTContext.h" |
Douglas Gregor | 071f4eb | 2009-07-28 14:44:31 +0000 | [diff] [blame] | 15 | #include "clang/AST/DeclCXX.h" |
| 16 | #include "clang/AST/DeclObjC.h" |
Douglas Gregor | 41ef0c3 | 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 | 41ef0c3 | 2009-07-28 00:33:38 +0000 | [diff] [blame] | 23 | using namespace clang; |
| 24 | |
| 25 | namespace { |
Chandler Carruth | b113824 | 2011-06-16 06:47:06 +0000 | [diff] [blame] | 26 | class StmtProfiler : public ConstStmtVisitor<StmtProfiler> { |
Douglas Gregor | 41ef0c3 | 2009-07-28 00:33:38 +0000 | [diff] [blame] | 27 | llvm::FoldingSetNodeID &ID; |
Jay Foad | 4ba2a17 | 2011-01-12 09:06:06 +0000 | [diff] [blame] | 28 | const ASTContext &Context; |
Douglas Gregor | 41ef0c3 | 2009-07-28 00:33:38 +0000 | [diff] [blame] | 29 | bool Canonical; |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 30 | |
Douglas Gregor | 41ef0c3 | 2009-07-28 00:33:38 +0000 | [diff] [blame] | 31 | public: |
Jay Foad | 4ba2a17 | 2011-01-12 09:06:06 +0000 | [diff] [blame] | 32 | StmtProfiler(llvm::FoldingSetNodeID &ID, const ASTContext &Context, |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 33 | bool Canonical) |
Douglas Gregor | 41ef0c3 | 2009-07-28 00:33:38 +0000 | [diff] [blame] | 34 | : ID(ID), Context(Context), Canonical(Canonical) { } |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 35 | |
Chandler Carruth | b113824 | 2011-06-16 06:47:06 +0000 | [diff] [blame] | 36 | void VisitStmt(const Stmt *S); |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 37 | |
Chandler Carruth | b113824 | 2011-06-16 06:47:06 +0000 | [diff] [blame] | 38 | #define STMT(Node, Base) void Visit##Node(const Node *S); |
Sean Hunt | 4bfe196 | 2010-05-05 15:24:00 +0000 | [diff] [blame] | 39 | #include "clang/AST/StmtNodes.inc" |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 40 | |
Douglas Gregor | 41ef0c3 | 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 | b113824 | 2011-06-16 06:47:06 +0000 | [diff] [blame] | 43 | void VisitDecl(const Decl *D); |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 44 | |
| 45 | /// \brief Visit a type that is referenced within an expression or |
Douglas Gregor | 41ef0c3 | 2009-07-28 00:33:38 +0000 | [diff] [blame] | 46 | /// statement. |
| 47 | void VisitType(QualType T); |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 48 | |
Douglas Gregor | 41ef0c3 | 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 | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 51 | |
Douglas Gregor | 41ef0c3 | 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 | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 55 | |
Douglas Gregor | 41ef0c3 | 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 | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 59 | |
Douglas Gregor | 41ef0c3 | 2009-07-28 00:33:38 +0000 | [diff] [blame] | 60 | /// \brief Visit template arguments that occur within an expression or |
| 61 | /// statement. |
Chandler Carruth | b113824 | 2011-06-16 06:47:06 +0000 | [diff] [blame] | 62 | void VisitTemplateArguments(const TemplateArgumentLoc *Args, |
| 63 | unsigned NumArgs); |
John McCall | 833ca99 | 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 | 41ef0c3 | 2009-07-28 00:33:38 +0000 | [diff] [blame] | 67 | }; |
| 68 | } |
| 69 | |
Chandler Carruth | b113824 | 2011-06-16 06:47:06 +0000 | [diff] [blame] | 70 | void StmtProfiler::VisitStmt(const Stmt *S) { |
Douglas Gregor | 41ef0c3 | 2009-07-28 00:33:38 +0000 | [diff] [blame] | 71 | ID.AddInteger(S->getStmtClass()); |
Peter Collingbourne | dca1761 | 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 | 41ef0c3 | 2009-07-28 00:33:38 +0000 | [diff] [blame] | 78 | } |
| 79 | |
Chandler Carruth | b113824 | 2011-06-16 06:47:06 +0000 | [diff] [blame] | 80 | void StmtProfiler::VisitDeclStmt(const DeclStmt *S) { |
Douglas Gregor | 3fe81fc | 2009-07-28 15:27:13 +0000 | [diff] [blame] | 81 | VisitStmt(S); |
Chandler Carruth | b113824 | 2011-06-16 06:47:06 +0000 | [diff] [blame] | 82 | for (DeclStmt::const_decl_iterator D = S->decl_begin(), DEnd = S->decl_end(); |
Douglas Gregor | 3fe81fc | 2009-07-28 15:27:13 +0000 | [diff] [blame] | 83 | D != DEnd; ++D) |
| 84 | VisitDecl(*D); |
| 85 | } |
| 86 | |
Chandler Carruth | b113824 | 2011-06-16 06:47:06 +0000 | [diff] [blame] | 87 | void StmtProfiler::VisitNullStmt(const NullStmt *S) { |
Douglas Gregor | 3fe81fc | 2009-07-28 15:27:13 +0000 | [diff] [blame] | 88 | VisitStmt(S); |
| 89 | } |
| 90 | |
Chandler Carruth | b113824 | 2011-06-16 06:47:06 +0000 | [diff] [blame] | 91 | void StmtProfiler::VisitCompoundStmt(const CompoundStmt *S) { |
Douglas Gregor | 3fe81fc | 2009-07-28 15:27:13 +0000 | [diff] [blame] | 92 | VisitStmt(S); |
| 93 | } |
| 94 | |
Chandler Carruth | b113824 | 2011-06-16 06:47:06 +0000 | [diff] [blame] | 95 | void StmtProfiler::VisitSwitchCase(const SwitchCase *S) { |
Douglas Gregor | 3fe81fc | 2009-07-28 15:27:13 +0000 | [diff] [blame] | 96 | VisitStmt(S); |
| 97 | } |
| 98 | |
Chandler Carruth | b113824 | 2011-06-16 06:47:06 +0000 | [diff] [blame] | 99 | void StmtProfiler::VisitCaseStmt(const CaseStmt *S) { |
Douglas Gregor | 3fe81fc | 2009-07-28 15:27:13 +0000 | [diff] [blame] | 100 | VisitStmt(S); |
| 101 | } |
| 102 | |
Chandler Carruth | b113824 | 2011-06-16 06:47:06 +0000 | [diff] [blame] | 103 | void StmtProfiler::VisitDefaultStmt(const DefaultStmt *S) { |
Douglas Gregor | 3fe81fc | 2009-07-28 15:27:13 +0000 | [diff] [blame] | 104 | VisitStmt(S); |
| 105 | } |
| 106 | |
Chandler Carruth | b113824 | 2011-06-16 06:47:06 +0000 | [diff] [blame] | 107 | void StmtProfiler::VisitLabelStmt(const LabelStmt *S) { |
Douglas Gregor | 3fe81fc | 2009-07-28 15:27:13 +0000 | [diff] [blame] | 108 | VisitStmt(S); |
Chris Lattner | ad8dcf4 | 2011-02-17 07:39:24 +0000 | [diff] [blame] | 109 | VisitDecl(S->getDecl()); |
Douglas Gregor | 3fe81fc | 2009-07-28 15:27:13 +0000 | [diff] [blame] | 110 | } |
| 111 | |
Richard Smith | 534986f | 2012-04-14 00:33:13 +0000 | [diff] [blame] | 112 | void StmtProfiler::VisitAttributedStmt(const AttributedStmt *S) { |
| 113 | VisitStmt(S); |
| 114 | // TODO: maybe visit attributes? |
| 115 | } |
| 116 | |
Chandler Carruth | b113824 | 2011-06-16 06:47:06 +0000 | [diff] [blame] | 117 | void StmtProfiler::VisitIfStmt(const IfStmt *S) { |
Douglas Gregor | 3fe81fc | 2009-07-28 15:27:13 +0000 | [diff] [blame] | 118 | VisitStmt(S); |
Douglas Gregor | 99e9b4d | 2009-11-25 00:27:52 +0000 | [diff] [blame] | 119 | VisitDecl(S->getConditionVariable()); |
Douglas Gregor | 3fe81fc | 2009-07-28 15:27:13 +0000 | [diff] [blame] | 120 | } |
| 121 | |
Chandler Carruth | b113824 | 2011-06-16 06:47:06 +0000 | [diff] [blame] | 122 | void StmtProfiler::VisitSwitchStmt(const SwitchStmt *S) { |
Douglas Gregor | 828e226 | 2009-07-29 16:09:57 +0000 | [diff] [blame] | 123 | VisitStmt(S); |
Douglas Gregor | 99e9b4d | 2009-11-25 00:27:52 +0000 | [diff] [blame] | 124 | VisitDecl(S->getConditionVariable()); |
Douglas Gregor | 828e226 | 2009-07-29 16:09:57 +0000 | [diff] [blame] | 125 | } |
| 126 | |
Chandler Carruth | b113824 | 2011-06-16 06:47:06 +0000 | [diff] [blame] | 127 | void StmtProfiler::VisitWhileStmt(const WhileStmt *S) { |
Douglas Gregor | 3fe81fc | 2009-07-28 15:27:13 +0000 | [diff] [blame] | 128 | VisitStmt(S); |
Douglas Gregor | 99e9b4d | 2009-11-25 00:27:52 +0000 | [diff] [blame] | 129 | VisitDecl(S->getConditionVariable()); |
Douglas Gregor | 3fe81fc | 2009-07-28 15:27:13 +0000 | [diff] [blame] | 130 | } |
| 131 | |
Chandler Carruth | b113824 | 2011-06-16 06:47:06 +0000 | [diff] [blame] | 132 | void StmtProfiler::VisitDoStmt(const DoStmt *S) { |
Douglas Gregor | 3fe81fc | 2009-07-28 15:27:13 +0000 | [diff] [blame] | 133 | VisitStmt(S); |
| 134 | } |
| 135 | |
Chandler Carruth | b113824 | 2011-06-16 06:47:06 +0000 | [diff] [blame] | 136 | void StmtProfiler::VisitForStmt(const ForStmt *S) { |
Douglas Gregor | 3fe81fc | 2009-07-28 15:27:13 +0000 | [diff] [blame] | 137 | VisitStmt(S); |
| 138 | } |
| 139 | |
Chandler Carruth | b113824 | 2011-06-16 06:47:06 +0000 | [diff] [blame] | 140 | void StmtProfiler::VisitGotoStmt(const GotoStmt *S) { |
Douglas Gregor | 3fe81fc | 2009-07-28 15:27:13 +0000 | [diff] [blame] | 141 | VisitStmt(S); |
Chris Lattner | ad8dcf4 | 2011-02-17 07:39:24 +0000 | [diff] [blame] | 142 | VisitDecl(S->getLabel()); |
Douglas Gregor | 3fe81fc | 2009-07-28 15:27:13 +0000 | [diff] [blame] | 143 | } |
| 144 | |
Chandler Carruth | b113824 | 2011-06-16 06:47:06 +0000 | [diff] [blame] | 145 | void StmtProfiler::VisitIndirectGotoStmt(const IndirectGotoStmt *S) { |
Douglas Gregor | 3fe81fc | 2009-07-28 15:27:13 +0000 | [diff] [blame] | 146 | VisitStmt(S); |
| 147 | } |
| 148 | |
Chandler Carruth | b113824 | 2011-06-16 06:47:06 +0000 | [diff] [blame] | 149 | void StmtProfiler::VisitContinueStmt(const ContinueStmt *S) { |
Douglas Gregor | 3fe81fc | 2009-07-28 15:27:13 +0000 | [diff] [blame] | 150 | VisitStmt(S); |
| 151 | } |
| 152 | |
Chandler Carruth | b113824 | 2011-06-16 06:47:06 +0000 | [diff] [blame] | 153 | void StmtProfiler::VisitBreakStmt(const BreakStmt *S) { |
Douglas Gregor | 3fe81fc | 2009-07-28 15:27:13 +0000 | [diff] [blame] | 154 | VisitStmt(S); |
| 155 | } |
| 156 | |
Chandler Carruth | b113824 | 2011-06-16 06:47:06 +0000 | [diff] [blame] | 157 | void StmtProfiler::VisitReturnStmt(const ReturnStmt *S) { |
Douglas Gregor | 3fe81fc | 2009-07-28 15:27:13 +0000 | [diff] [blame] | 158 | VisitStmt(S); |
| 159 | } |
| 160 | |
Chad Rosier | df5faf5 | 2012-08-25 00:11:56 +0000 | [diff] [blame] | 161 | void StmtProfiler::VisitGCCAsmStmt(const GCCAsmStmt *S) { |
Douglas Gregor | 3fe81fc | 2009-07-28 15:27:13 +0000 | [diff] [blame] | 162 | VisitStmt(S); |
| 163 | ID.AddBoolean(S->isVolatile()); |
| 164 | ID.AddBoolean(S->isSimple()); |
| 165 | VisitStringLiteral(S->getAsmString()); |
| 166 | ID.AddInteger(S->getNumOutputs()); |
| 167 | for (unsigned I = 0, N = S->getNumOutputs(); I != N; ++I) { |
| 168 | ID.AddString(S->getOutputName(I)); |
| 169 | VisitStringLiteral(S->getOutputConstraintLiteral(I)); |
| 170 | } |
| 171 | ID.AddInteger(S->getNumInputs()); |
| 172 | for (unsigned I = 0, N = S->getNumInputs(); I != N; ++I) { |
| 173 | ID.AddString(S->getInputName(I)); |
| 174 | VisitStringLiteral(S->getInputConstraintLiteral(I)); |
| 175 | } |
| 176 | ID.AddInteger(S->getNumClobbers()); |
| 177 | for (unsigned I = 0, N = S->getNumClobbers(); I != N; ++I) |
Chad Rosier | 5c7f594 | 2012-08-27 23:28:41 +0000 | [diff] [blame] | 178 | VisitStringLiteral(S->getClobberStringLiteral(I)); |
Douglas Gregor | 3fe81fc | 2009-07-28 15:27:13 +0000 | [diff] [blame] | 179 | } |
| 180 | |
Chad Rosier | 8cd64b4 | 2012-06-11 20:47:18 +0000 | [diff] [blame] | 181 | void StmtProfiler::VisitMSAsmStmt(const MSAsmStmt *S) { |
| 182 | // FIXME: Implement MS style inline asm statement profiler. |
| 183 | VisitStmt(S); |
| 184 | } |
| 185 | |
Chandler Carruth | b113824 | 2011-06-16 06:47:06 +0000 | [diff] [blame] | 186 | void StmtProfiler::VisitCXXCatchStmt(const CXXCatchStmt *S) { |
Douglas Gregor | 3fe81fc | 2009-07-28 15:27:13 +0000 | [diff] [blame] | 187 | VisitStmt(S); |
| 188 | VisitType(S->getCaughtType()); |
| 189 | } |
| 190 | |
Chandler Carruth | b113824 | 2011-06-16 06:47:06 +0000 | [diff] [blame] | 191 | void StmtProfiler::VisitCXXTryStmt(const CXXTryStmt *S) { |
Douglas Gregor | 3fe81fc | 2009-07-28 15:27:13 +0000 | [diff] [blame] | 192 | VisitStmt(S); |
| 193 | } |
| 194 | |
Chandler Carruth | b113824 | 2011-06-16 06:47:06 +0000 | [diff] [blame] | 195 | void StmtProfiler::VisitCXXForRangeStmt(const CXXForRangeStmt *S) { |
Richard Smith | ad762fc | 2011-04-14 22:09:26 +0000 | [diff] [blame] | 196 | VisitStmt(S); |
| 197 | } |
| 198 | |
Douglas Gregor | ba0513d | 2011-10-25 01:33:02 +0000 | [diff] [blame] | 199 | void StmtProfiler::VisitMSDependentExistsStmt(const MSDependentExistsStmt *S) { |
| 200 | VisitStmt(S); |
| 201 | ID.AddBoolean(S->isIfExists()); |
| 202 | VisitNestedNameSpecifier(S->getQualifierLoc().getNestedNameSpecifier()); |
| 203 | VisitName(S->getNameInfo().getName()); |
| 204 | } |
| 205 | |
Chandler Carruth | b113824 | 2011-06-16 06:47:06 +0000 | [diff] [blame] | 206 | void StmtProfiler::VisitSEHTryStmt(const SEHTryStmt *S) { |
John Wiegley | 28bbe4b | 2011-04-28 01:08:34 +0000 | [diff] [blame] | 207 | VisitStmt(S); |
| 208 | } |
| 209 | |
Chandler Carruth | b113824 | 2011-06-16 06:47:06 +0000 | [diff] [blame] | 210 | void StmtProfiler::VisitSEHFinallyStmt(const SEHFinallyStmt *S) { |
John Wiegley | 28bbe4b | 2011-04-28 01:08:34 +0000 | [diff] [blame] | 211 | VisitStmt(S); |
| 212 | } |
| 213 | |
Chandler Carruth | b113824 | 2011-06-16 06:47:06 +0000 | [diff] [blame] | 214 | void StmtProfiler::VisitSEHExceptStmt(const SEHExceptStmt *S) { |
John Wiegley | 28bbe4b | 2011-04-28 01:08:34 +0000 | [diff] [blame] | 215 | VisitStmt(S); |
| 216 | } |
| 217 | |
Tareq A. Siraj | 051303c | 2013-04-16 18:53:08 +0000 | [diff] [blame] | 218 | void StmtProfiler::VisitCapturedStmt(const CapturedStmt *S) { |
| 219 | VisitStmt(S); |
| 220 | } |
| 221 | |
Chandler Carruth | b113824 | 2011-06-16 06:47:06 +0000 | [diff] [blame] | 222 | void StmtProfiler::VisitObjCForCollectionStmt(const ObjCForCollectionStmt *S) { |
Douglas Gregor | 3fe81fc | 2009-07-28 15:27:13 +0000 | [diff] [blame] | 223 | VisitStmt(S); |
| 224 | } |
| 225 | |
Chandler Carruth | b113824 | 2011-06-16 06:47:06 +0000 | [diff] [blame] | 226 | void StmtProfiler::VisitObjCAtCatchStmt(const ObjCAtCatchStmt *S) { |
Douglas Gregor | 3fe81fc | 2009-07-28 15:27:13 +0000 | [diff] [blame] | 227 | VisitStmt(S); |
| 228 | ID.AddBoolean(S->hasEllipsis()); |
| 229 | if (S->getCatchParamDecl()) |
| 230 | VisitType(S->getCatchParamDecl()->getType()); |
| 231 | } |
| 232 | |
Chandler Carruth | b113824 | 2011-06-16 06:47:06 +0000 | [diff] [blame] | 233 | void StmtProfiler::VisitObjCAtFinallyStmt(const ObjCAtFinallyStmt *S) { |
Douglas Gregor | 3fe81fc | 2009-07-28 15:27:13 +0000 | [diff] [blame] | 234 | VisitStmt(S); |
| 235 | } |
| 236 | |
Chandler Carruth | b113824 | 2011-06-16 06:47:06 +0000 | [diff] [blame] | 237 | void StmtProfiler::VisitObjCAtTryStmt(const ObjCAtTryStmt *S) { |
Douglas Gregor | 3fe81fc | 2009-07-28 15:27:13 +0000 | [diff] [blame] | 238 | VisitStmt(S); |
| 239 | } |
| 240 | |
Chandler Carruth | b113824 | 2011-06-16 06:47:06 +0000 | [diff] [blame] | 241 | void |
| 242 | StmtProfiler::VisitObjCAtSynchronizedStmt(const ObjCAtSynchronizedStmt *S) { |
Douglas Gregor | 3fe81fc | 2009-07-28 15:27:13 +0000 | [diff] [blame] | 243 | VisitStmt(S); |
| 244 | } |
| 245 | |
Chandler Carruth | b113824 | 2011-06-16 06:47:06 +0000 | [diff] [blame] | 246 | void StmtProfiler::VisitObjCAtThrowStmt(const ObjCAtThrowStmt *S) { |
Douglas Gregor | 3fe81fc | 2009-07-28 15:27:13 +0000 | [diff] [blame] | 247 | VisitStmt(S); |
| 248 | } |
| 249 | |
Chandler Carruth | b113824 | 2011-06-16 06:47:06 +0000 | [diff] [blame] | 250 | void |
| 251 | StmtProfiler::VisitObjCAutoreleasePoolStmt(const ObjCAutoreleasePoolStmt *S) { |
John McCall | f85e193 | 2011-06-15 23:02:42 +0000 | [diff] [blame] | 252 | VisitStmt(S); |
| 253 | } |
| 254 | |
Alexey Bataev | 4fa7eab | 2013-07-19 03:13:43 +0000 | [diff] [blame^] | 255 | namespace { |
| 256 | class OMPClauseProfiler : public ConstOMPClauseVisitor<OMPClauseProfiler> { |
| 257 | StmtProfiler *Profiler; |
| 258 | public: |
| 259 | OMPClauseProfiler(StmtProfiler *P) : Profiler(P) { } |
| 260 | #define OPENMP_CLAUSE(Name, Class) \ |
| 261 | void Visit##Class(const Class *C); |
| 262 | #include "clang/Basic/OpenMPKinds.def" |
| 263 | }; |
| 264 | |
| 265 | void OMPClauseProfiler::VisitOMPDefaultClause(const OMPDefaultClause *C) { } |
| 266 | #define PROCESS_OMP_CLAUSE_LIST(Class, Node) \ |
| 267 | for (OMPVarList<Class>::varlist_const_iterator I = Node->varlist_begin(), \ |
| 268 | E = Node->varlist_end(); \ |
| 269 | I != E; ++I) \ |
| 270 | Profiler->VisitStmt(*I); |
| 271 | |
| 272 | void OMPClauseProfiler::VisitOMPPrivateClause(const OMPPrivateClause *C) { |
| 273 | PROCESS_OMP_CLAUSE_LIST(OMPPrivateClause, C) |
| 274 | } |
| 275 | #undef PROCESS_OMP_CLAUSE_LIST |
| 276 | } |
| 277 | |
| 278 | void |
| 279 | StmtProfiler::VisitOMPParallelDirective(const OMPParallelDirective *S) { |
| 280 | VisitStmt(S); |
| 281 | OMPClauseProfiler P(this); |
| 282 | ArrayRef<OMPClause *> Clauses = S->clauses(); |
| 283 | for (ArrayRef<OMPClause *>::iterator I = Clauses.begin(), E = Clauses.end(); |
| 284 | I != E; ++I) |
| 285 | if (*I) |
| 286 | P.Visit(*I); |
| 287 | } |
| 288 | |
Chandler Carruth | b113824 | 2011-06-16 06:47:06 +0000 | [diff] [blame] | 289 | void StmtProfiler::VisitExpr(const Expr *S) { |
Douglas Gregor | 41ef0c3 | 2009-07-28 00:33:38 +0000 | [diff] [blame] | 290 | VisitStmt(S); |
| 291 | } |
| 292 | |
Chandler Carruth | b113824 | 2011-06-16 06:47:06 +0000 | [diff] [blame] | 293 | void StmtProfiler::VisitDeclRefExpr(const DeclRefExpr *S) { |
Douglas Gregor | 41ef0c3 | 2009-07-28 00:33:38 +0000 | [diff] [blame] | 294 | VisitExpr(S); |
Douglas Gregor | 218f47f | 2010-07-13 08:37:11 +0000 | [diff] [blame] | 295 | if (!Canonical) |
| 296 | VisitNestedNameSpecifier(S->getQualifier()); |
Douglas Gregor | 41ef0c3 | 2009-07-28 00:33:38 +0000 | [diff] [blame] | 297 | VisitDecl(S->getDecl()); |
Douglas Gregor | 218f47f | 2010-07-13 08:37:11 +0000 | [diff] [blame] | 298 | if (!Canonical) |
| 299 | VisitTemplateArguments(S->getTemplateArgs(), S->getNumTemplateArgs()); |
Douglas Gregor | 41ef0c3 | 2009-07-28 00:33:38 +0000 | [diff] [blame] | 300 | } |
| 301 | |
Chandler Carruth | b113824 | 2011-06-16 06:47:06 +0000 | [diff] [blame] | 302 | void StmtProfiler::VisitPredefinedExpr(const PredefinedExpr *S) { |
Douglas Gregor | 41ef0c3 | 2009-07-28 00:33:38 +0000 | [diff] [blame] | 303 | VisitExpr(S); |
| 304 | ID.AddInteger(S->getIdentType()); |
| 305 | } |
| 306 | |
Chandler Carruth | b113824 | 2011-06-16 06:47:06 +0000 | [diff] [blame] | 307 | void StmtProfiler::VisitIntegerLiteral(const IntegerLiteral *S) { |
Douglas Gregor | 41ef0c3 | 2009-07-28 00:33:38 +0000 | [diff] [blame] | 308 | VisitExpr(S); |
| 309 | S->getValue().Profile(ID); |
| 310 | } |
| 311 | |
Chandler Carruth | b113824 | 2011-06-16 06:47:06 +0000 | [diff] [blame] | 312 | void StmtProfiler::VisitCharacterLiteral(const CharacterLiteral *S) { |
Douglas Gregor | 41ef0c3 | 2009-07-28 00:33:38 +0000 | [diff] [blame] | 313 | VisitExpr(S); |
Douglas Gregor | 5cee119 | 2011-07-27 05:40:30 +0000 | [diff] [blame] | 314 | ID.AddInteger(S->getKind()); |
Douglas Gregor | 41ef0c3 | 2009-07-28 00:33:38 +0000 | [diff] [blame] | 315 | ID.AddInteger(S->getValue()); |
| 316 | } |
| 317 | |
Chandler Carruth | b113824 | 2011-06-16 06:47:06 +0000 | [diff] [blame] | 318 | void StmtProfiler::VisitFloatingLiteral(const FloatingLiteral *S) { |
Douglas Gregor | 41ef0c3 | 2009-07-28 00:33:38 +0000 | [diff] [blame] | 319 | VisitExpr(S); |
| 320 | S->getValue().Profile(ID); |
| 321 | ID.AddBoolean(S->isExact()); |
| 322 | } |
| 323 | |
Chandler Carruth | b113824 | 2011-06-16 06:47:06 +0000 | [diff] [blame] | 324 | void StmtProfiler::VisitImaginaryLiteral(const ImaginaryLiteral *S) { |
Douglas Gregor | 41ef0c3 | 2009-07-28 00:33:38 +0000 | [diff] [blame] | 325 | VisitExpr(S); |
| 326 | } |
| 327 | |
Chandler Carruth | b113824 | 2011-06-16 06:47:06 +0000 | [diff] [blame] | 328 | void StmtProfiler::VisitStringLiteral(const StringLiteral *S) { |
Douglas Gregor | 41ef0c3 | 2009-07-28 00:33:38 +0000 | [diff] [blame] | 329 | VisitExpr(S); |
Douglas Gregor | 38738fc | 2011-11-02 17:26:05 +0000 | [diff] [blame] | 330 | ID.AddString(S->getBytes()); |
Douglas Gregor | 5cee119 | 2011-07-27 05:40:30 +0000 | [diff] [blame] | 331 | ID.AddInteger(S->getKind()); |
Douglas Gregor | 41ef0c3 | 2009-07-28 00:33:38 +0000 | [diff] [blame] | 332 | } |
| 333 | |
Chandler Carruth | b113824 | 2011-06-16 06:47:06 +0000 | [diff] [blame] | 334 | void StmtProfiler::VisitParenExpr(const ParenExpr *S) { |
Douglas Gregor | 41ef0c3 | 2009-07-28 00:33:38 +0000 | [diff] [blame] | 335 | VisitExpr(S); |
| 336 | } |
| 337 | |
Chandler Carruth | b113824 | 2011-06-16 06:47:06 +0000 | [diff] [blame] | 338 | void StmtProfiler::VisitParenListExpr(const ParenListExpr *S) { |
Nate Begeman | 2ef13e5 | 2009-08-10 23:49:36 +0000 | [diff] [blame] | 339 | VisitExpr(S); |
| 340 | } |
| 341 | |
Chandler Carruth | b113824 | 2011-06-16 06:47:06 +0000 | [diff] [blame] | 342 | void StmtProfiler::VisitUnaryOperator(const UnaryOperator *S) { |
Douglas Gregor | 41ef0c3 | 2009-07-28 00:33:38 +0000 | [diff] [blame] | 343 | VisitExpr(S); |
| 344 | ID.AddInteger(S->getOpcode()); |
| 345 | } |
| 346 | |
Chandler Carruth | b113824 | 2011-06-16 06:47:06 +0000 | [diff] [blame] | 347 | void StmtProfiler::VisitOffsetOfExpr(const OffsetOfExpr *S) { |
Douglas Gregor | 8ecdb65 | 2010-04-28 22:16:22 +0000 | [diff] [blame] | 348 | VisitType(S->getTypeSourceInfo()->getType()); |
| 349 | unsigned n = S->getNumComponents(); |
| 350 | for (unsigned i = 0; i < n; ++i) { |
| 351 | const OffsetOfExpr::OffsetOfNode& ON = S->getComponent(i); |
| 352 | ID.AddInteger(ON.getKind()); |
| 353 | switch (ON.getKind()) { |
| 354 | case OffsetOfExpr::OffsetOfNode::Array: |
| 355 | // Expressions handled below. |
| 356 | break; |
| 357 | |
| 358 | case OffsetOfExpr::OffsetOfNode::Field: |
| 359 | VisitDecl(ON.getField()); |
| 360 | break; |
| 361 | |
| 362 | case OffsetOfExpr::OffsetOfNode::Identifier: |
| 363 | ID.AddPointer(ON.getFieldName()); |
| 364 | break; |
Sean Hunt | c302113 | 2010-05-05 15:23:54 +0000 | [diff] [blame] | 365 | |
Douglas Gregor | cc8a5d5 | 2010-04-29 00:18:15 +0000 | [diff] [blame] | 366 | case OffsetOfExpr::OffsetOfNode::Base: |
| 367 | // These nodes are implicit, and therefore don't need profiling. |
| 368 | break; |
Douglas Gregor | 8ecdb65 | 2010-04-28 22:16:22 +0000 | [diff] [blame] | 369 | } |
| 370 | } |
Sean Hunt | c302113 | 2010-05-05 15:23:54 +0000 | [diff] [blame] | 371 | |
Douglas Gregor | 8ecdb65 | 2010-04-28 22:16:22 +0000 | [diff] [blame] | 372 | VisitExpr(S); |
| 373 | } |
| 374 | |
Chandler Carruth | b113824 | 2011-06-16 06:47:06 +0000 | [diff] [blame] | 375 | void |
| 376 | StmtProfiler::VisitUnaryExprOrTypeTraitExpr(const UnaryExprOrTypeTraitExpr *S) { |
Douglas Gregor | 41ef0c3 | 2009-07-28 00:33:38 +0000 | [diff] [blame] | 377 | VisitExpr(S); |
Peter Collingbourne | f4e3cfb | 2011-03-11 19:24:49 +0000 | [diff] [blame] | 378 | ID.AddInteger(S->getKind()); |
Douglas Gregor | 41ef0c3 | 2009-07-28 00:33:38 +0000 | [diff] [blame] | 379 | if (S->isArgumentType()) |
| 380 | VisitType(S->getArgumentType()); |
| 381 | } |
| 382 | |
Chandler Carruth | b113824 | 2011-06-16 06:47:06 +0000 | [diff] [blame] | 383 | void StmtProfiler::VisitArraySubscriptExpr(const ArraySubscriptExpr *S) { |
Douglas Gregor | 41ef0c3 | 2009-07-28 00:33:38 +0000 | [diff] [blame] | 384 | VisitExpr(S); |
| 385 | } |
| 386 | |
Chandler Carruth | b113824 | 2011-06-16 06:47:06 +0000 | [diff] [blame] | 387 | void StmtProfiler::VisitCallExpr(const CallExpr *S) { |
Douglas Gregor | 41ef0c3 | 2009-07-28 00:33:38 +0000 | [diff] [blame] | 388 | VisitExpr(S); |
| 389 | } |
| 390 | |
Chandler Carruth | b113824 | 2011-06-16 06:47:06 +0000 | [diff] [blame] | 391 | void StmtProfiler::VisitMemberExpr(const MemberExpr *S) { |
Douglas Gregor | 41ef0c3 | 2009-07-28 00:33:38 +0000 | [diff] [blame] | 392 | VisitExpr(S); |
| 393 | VisitDecl(S->getMemberDecl()); |
Douglas Gregor | 218f47f | 2010-07-13 08:37:11 +0000 | [diff] [blame] | 394 | if (!Canonical) |
| 395 | VisitNestedNameSpecifier(S->getQualifier()); |
Douglas Gregor | 41ef0c3 | 2009-07-28 00:33:38 +0000 | [diff] [blame] | 396 | ID.AddBoolean(S->isArrow()); |
| 397 | } |
| 398 | |
Chandler Carruth | b113824 | 2011-06-16 06:47:06 +0000 | [diff] [blame] | 399 | void StmtProfiler::VisitCompoundLiteralExpr(const CompoundLiteralExpr *S) { |
Douglas Gregor | 41ef0c3 | 2009-07-28 00:33:38 +0000 | [diff] [blame] | 400 | VisitExpr(S); |
| 401 | ID.AddBoolean(S->isFileScope()); |
| 402 | } |
| 403 | |
Chandler Carruth | b113824 | 2011-06-16 06:47:06 +0000 | [diff] [blame] | 404 | void StmtProfiler::VisitCastExpr(const CastExpr *S) { |
Douglas Gregor | 41ef0c3 | 2009-07-28 00:33:38 +0000 | [diff] [blame] | 405 | VisitExpr(S); |
| 406 | } |
| 407 | |
Chandler Carruth | b113824 | 2011-06-16 06:47:06 +0000 | [diff] [blame] | 408 | void StmtProfiler::VisitImplicitCastExpr(const ImplicitCastExpr *S) { |
Douglas Gregor | 41ef0c3 | 2009-07-28 00:33:38 +0000 | [diff] [blame] | 409 | VisitCastExpr(S); |
John McCall | 5baba9d | 2010-08-25 10:28:54 +0000 | [diff] [blame] | 410 | ID.AddInteger(S->getValueKind()); |
Douglas Gregor | 41ef0c3 | 2009-07-28 00:33:38 +0000 | [diff] [blame] | 411 | } |
| 412 | |
Chandler Carruth | b113824 | 2011-06-16 06:47:06 +0000 | [diff] [blame] | 413 | void StmtProfiler::VisitExplicitCastExpr(const ExplicitCastExpr *S) { |
Douglas Gregor | 41ef0c3 | 2009-07-28 00:33:38 +0000 | [diff] [blame] | 414 | VisitCastExpr(S); |
| 415 | VisitType(S->getTypeAsWritten()); |
| 416 | } |
| 417 | |
Chandler Carruth | b113824 | 2011-06-16 06:47:06 +0000 | [diff] [blame] | 418 | void StmtProfiler::VisitCStyleCastExpr(const CStyleCastExpr *S) { |
Douglas Gregor | 41ef0c3 | 2009-07-28 00:33:38 +0000 | [diff] [blame] | 419 | VisitExplicitCastExpr(S); |
| 420 | } |
| 421 | |
Chandler Carruth | b113824 | 2011-06-16 06:47:06 +0000 | [diff] [blame] | 422 | void StmtProfiler::VisitBinaryOperator(const BinaryOperator *S) { |
Douglas Gregor | 41ef0c3 | 2009-07-28 00:33:38 +0000 | [diff] [blame] | 423 | VisitExpr(S); |
| 424 | ID.AddInteger(S->getOpcode()); |
| 425 | } |
| 426 | |
Chandler Carruth | b113824 | 2011-06-16 06:47:06 +0000 | [diff] [blame] | 427 | void |
| 428 | StmtProfiler::VisitCompoundAssignOperator(const CompoundAssignOperator *S) { |
Douglas Gregor | 41ef0c3 | 2009-07-28 00:33:38 +0000 | [diff] [blame] | 429 | VisitBinaryOperator(S); |
| 430 | } |
| 431 | |
Chandler Carruth | b113824 | 2011-06-16 06:47:06 +0000 | [diff] [blame] | 432 | void StmtProfiler::VisitConditionalOperator(const ConditionalOperator *S) { |
Douglas Gregor | 41ef0c3 | 2009-07-28 00:33:38 +0000 | [diff] [blame] | 433 | VisitExpr(S); |
| 434 | } |
| 435 | |
Chandler Carruth | b113824 | 2011-06-16 06:47:06 +0000 | [diff] [blame] | 436 | void StmtProfiler::VisitBinaryConditionalOperator( |
Chandler Carruth | 0894976 | 2011-06-21 23:26:32 +0000 | [diff] [blame] | 437 | const BinaryConditionalOperator *S) { |
John McCall | 56ca35d | 2011-02-17 10:25:35 +0000 | [diff] [blame] | 438 | VisitExpr(S); |
| 439 | } |
| 440 | |
Chandler Carruth | b113824 | 2011-06-16 06:47:06 +0000 | [diff] [blame] | 441 | void StmtProfiler::VisitAddrLabelExpr(const AddrLabelExpr *S) { |
Douglas Gregor | 41ef0c3 | 2009-07-28 00:33:38 +0000 | [diff] [blame] | 442 | VisitExpr(S); |
Chris Lattner | ad8dcf4 | 2011-02-17 07:39:24 +0000 | [diff] [blame] | 443 | VisitDecl(S->getLabel()); |
Douglas Gregor | 41ef0c3 | 2009-07-28 00:33:38 +0000 | [diff] [blame] | 444 | } |
| 445 | |
Chandler Carruth | b113824 | 2011-06-16 06:47:06 +0000 | [diff] [blame] | 446 | void StmtProfiler::VisitStmtExpr(const StmtExpr *S) { |
Douglas Gregor | 41ef0c3 | 2009-07-28 00:33:38 +0000 | [diff] [blame] | 447 | VisitExpr(S); |
| 448 | } |
| 449 | |
Chandler Carruth | b113824 | 2011-06-16 06:47:06 +0000 | [diff] [blame] | 450 | void StmtProfiler::VisitShuffleVectorExpr(const ShuffleVectorExpr *S) { |
Douglas Gregor | 41ef0c3 | 2009-07-28 00:33:38 +0000 | [diff] [blame] | 451 | VisitExpr(S); |
| 452 | } |
| 453 | |
Chandler Carruth | b113824 | 2011-06-16 06:47:06 +0000 | [diff] [blame] | 454 | void StmtProfiler::VisitChooseExpr(const ChooseExpr *S) { |
Douglas Gregor | 41ef0c3 | 2009-07-28 00:33:38 +0000 | [diff] [blame] | 455 | VisitExpr(S); |
| 456 | } |
| 457 | |
Chandler Carruth | b113824 | 2011-06-16 06:47:06 +0000 | [diff] [blame] | 458 | void StmtProfiler::VisitGNUNullExpr(const GNUNullExpr *S) { |
Douglas Gregor | 41ef0c3 | 2009-07-28 00:33:38 +0000 | [diff] [blame] | 459 | VisitExpr(S); |
| 460 | } |
| 461 | |
Chandler Carruth | b113824 | 2011-06-16 06:47:06 +0000 | [diff] [blame] | 462 | void StmtProfiler::VisitVAArgExpr(const VAArgExpr *S) { |
Douglas Gregor | 828e226 | 2009-07-29 16:09:57 +0000 | [diff] [blame] | 463 | VisitExpr(S); |
| 464 | } |
| 465 | |
Chandler Carruth | b113824 | 2011-06-16 06:47:06 +0000 | [diff] [blame] | 466 | void StmtProfiler::VisitInitListExpr(const InitListExpr *S) { |
Douglas Gregor | 41ef0c3 | 2009-07-28 00:33:38 +0000 | [diff] [blame] | 467 | if (S->getSyntacticForm()) { |
| 468 | VisitInitListExpr(S->getSyntacticForm()); |
| 469 | return; |
| 470 | } |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 471 | |
Douglas Gregor | 41ef0c3 | 2009-07-28 00:33:38 +0000 | [diff] [blame] | 472 | VisitExpr(S); |
| 473 | } |
| 474 | |
Chandler Carruth | b113824 | 2011-06-16 06:47:06 +0000 | [diff] [blame] | 475 | void StmtProfiler::VisitDesignatedInitExpr(const DesignatedInitExpr *S) { |
Douglas Gregor | 41ef0c3 | 2009-07-28 00:33:38 +0000 | [diff] [blame] | 476 | VisitExpr(S); |
| 477 | ID.AddBoolean(S->usesGNUSyntax()); |
Chandler Carruth | b113824 | 2011-06-16 06:47:06 +0000 | [diff] [blame] | 478 | for (DesignatedInitExpr::const_designators_iterator D = |
| 479 | S->designators_begin(), DEnd = S->designators_end(); |
Douglas Gregor | 41ef0c3 | 2009-07-28 00:33:38 +0000 | [diff] [blame] | 480 | D != DEnd; ++D) { |
| 481 | if (D->isFieldDesignator()) { |
| 482 | ID.AddInteger(0); |
| 483 | VisitName(D->getFieldName()); |
| 484 | continue; |
| 485 | } |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 486 | |
Douglas Gregor | 41ef0c3 | 2009-07-28 00:33:38 +0000 | [diff] [blame] | 487 | if (D->isArrayDesignator()) { |
| 488 | ID.AddInteger(1); |
| 489 | } else { |
| 490 | assert(D->isArrayRangeDesignator()); |
| 491 | ID.AddInteger(2); |
| 492 | } |
| 493 | ID.AddInteger(D->getFirstExprIndex()); |
| 494 | } |
| 495 | } |
| 496 | |
Chandler Carruth | b113824 | 2011-06-16 06:47:06 +0000 | [diff] [blame] | 497 | void StmtProfiler::VisitImplicitValueInitExpr(const ImplicitValueInitExpr *S) { |
Douglas Gregor | 41ef0c3 | 2009-07-28 00:33:38 +0000 | [diff] [blame] | 498 | VisitExpr(S); |
| 499 | } |
| 500 | |
Chandler Carruth | b113824 | 2011-06-16 06:47:06 +0000 | [diff] [blame] | 501 | void StmtProfiler::VisitExtVectorElementExpr(const ExtVectorElementExpr *S) { |
Douglas Gregor | 41ef0c3 | 2009-07-28 00:33:38 +0000 | [diff] [blame] | 502 | VisitExpr(S); |
| 503 | VisitName(&S->getAccessor()); |
| 504 | } |
| 505 | |
Chandler Carruth | b113824 | 2011-06-16 06:47:06 +0000 | [diff] [blame] | 506 | void StmtProfiler::VisitBlockExpr(const BlockExpr *S) { |
Douglas Gregor | 41ef0c3 | 2009-07-28 00:33:38 +0000 | [diff] [blame] | 507 | VisitExpr(S); |
| 508 | VisitDecl(S->getBlockDecl()); |
| 509 | } |
| 510 | |
Chandler Carruth | b113824 | 2011-06-16 06:47:06 +0000 | [diff] [blame] | 511 | void StmtProfiler::VisitGenericSelectionExpr(const GenericSelectionExpr *S) { |
Peter Collingbourne | f111d93 | 2011-04-15 00:35:48 +0000 | [diff] [blame] | 512 | VisitExpr(S); |
| 513 | for (unsigned i = 0; i != S->getNumAssocs(); ++i) { |
| 514 | QualType T = S->getAssocType(i); |
| 515 | if (T.isNull()) |
| 516 | ID.AddPointer(0); |
| 517 | else |
| 518 | VisitType(T); |
| 519 | VisitExpr(S->getAssocExpr(i)); |
| 520 | } |
| 521 | } |
| 522 | |
John McCall | 4b9c2d2 | 2011-11-06 09:01:30 +0000 | [diff] [blame] | 523 | void StmtProfiler::VisitPseudoObjectExpr(const PseudoObjectExpr *S) { |
| 524 | VisitExpr(S); |
| 525 | for (PseudoObjectExpr::const_semantics_iterator |
| 526 | i = S->semantics_begin(), e = S->semantics_end(); i != e; ++i) |
| 527 | // Normally, we would not profile the source expressions of OVEs. |
| 528 | if (const OpaqueValueExpr *OVE = dyn_cast<OpaqueValueExpr>(*i)) |
| 529 | Visit(OVE->getSourceExpr()); |
| 530 | } |
| 531 | |
Eli Friedman | 276b061 | 2011-10-11 02:20:01 +0000 | [diff] [blame] | 532 | void StmtProfiler::VisitAtomicExpr(const AtomicExpr *S) { |
| 533 | VisitExpr(S); |
Eli Friedman | 2be4607 | 2011-10-14 20:59:01 +0000 | [diff] [blame] | 534 | ID.AddInteger(S->getOp()); |
Eli Friedman | 276b061 | 2011-10-11 02:20:01 +0000 | [diff] [blame] | 535 | } |
| 536 | |
Chandler Carruth | b113824 | 2011-06-16 06:47:06 +0000 | [diff] [blame] | 537 | static Stmt::StmtClass DecodeOperatorCall(const CXXOperatorCallExpr *S, |
John McCall | 2de56d1 | 2010-08-25 11:45:40 +0000 | [diff] [blame] | 538 | UnaryOperatorKind &UnaryOp, |
| 539 | BinaryOperatorKind &BinaryOp) { |
Douglas Gregor | a89064a | 2010-05-19 04:13:23 +0000 | [diff] [blame] | 540 | switch (S->getOperator()) { |
| 541 | case OO_None: |
| 542 | case OO_New: |
| 543 | case OO_Delete: |
| 544 | case OO_Array_New: |
| 545 | case OO_Array_Delete: |
| 546 | case OO_Arrow: |
| 547 | case OO_Call: |
| 548 | case OO_Conditional: |
| 549 | case NUM_OVERLOADED_OPERATORS: |
| 550 | llvm_unreachable("Invalid operator call kind"); |
Douglas Gregor | a89064a | 2010-05-19 04:13:23 +0000 | [diff] [blame] | 551 | |
| 552 | case OO_Plus: |
| 553 | if (S->getNumArgs() == 1) { |
John McCall | 2de56d1 | 2010-08-25 11:45:40 +0000 | [diff] [blame] | 554 | UnaryOp = UO_Plus; |
Douglas Gregor | a89064a | 2010-05-19 04:13:23 +0000 | [diff] [blame] | 555 | return Stmt::UnaryOperatorClass; |
| 556 | } |
| 557 | |
John McCall | 2de56d1 | 2010-08-25 11:45:40 +0000 | [diff] [blame] | 558 | BinaryOp = BO_Add; |
Douglas Gregor | a89064a | 2010-05-19 04:13:23 +0000 | [diff] [blame] | 559 | return Stmt::BinaryOperatorClass; |
| 560 | |
| 561 | case OO_Minus: |
| 562 | if (S->getNumArgs() == 1) { |
John McCall | 2de56d1 | 2010-08-25 11:45:40 +0000 | [diff] [blame] | 563 | UnaryOp = UO_Minus; |
Douglas Gregor | a89064a | 2010-05-19 04:13:23 +0000 | [diff] [blame] | 564 | return Stmt::UnaryOperatorClass; |
| 565 | } |
| 566 | |
John McCall | 2de56d1 | 2010-08-25 11:45:40 +0000 | [diff] [blame] | 567 | BinaryOp = BO_Sub; |
Douglas Gregor | a89064a | 2010-05-19 04:13:23 +0000 | [diff] [blame] | 568 | return Stmt::BinaryOperatorClass; |
| 569 | |
| 570 | case OO_Star: |
| 571 | if (S->getNumArgs() == 1) { |
John McCall | 2de56d1 | 2010-08-25 11:45:40 +0000 | [diff] [blame] | 572 | UnaryOp = UO_Minus; |
Douglas Gregor | a89064a | 2010-05-19 04:13:23 +0000 | [diff] [blame] | 573 | return Stmt::UnaryOperatorClass; |
| 574 | } |
| 575 | |
John McCall | 2de56d1 | 2010-08-25 11:45:40 +0000 | [diff] [blame] | 576 | BinaryOp = BO_Sub; |
Douglas Gregor | a89064a | 2010-05-19 04:13:23 +0000 | [diff] [blame] | 577 | return Stmt::BinaryOperatorClass; |
| 578 | |
| 579 | case OO_Slash: |
John McCall | 2de56d1 | 2010-08-25 11:45:40 +0000 | [diff] [blame] | 580 | BinaryOp = BO_Div; |
Douglas Gregor | a89064a | 2010-05-19 04:13:23 +0000 | [diff] [blame] | 581 | return Stmt::BinaryOperatorClass; |
| 582 | |
| 583 | case OO_Percent: |
John McCall | 2de56d1 | 2010-08-25 11:45:40 +0000 | [diff] [blame] | 584 | BinaryOp = BO_Rem; |
Douglas Gregor | a89064a | 2010-05-19 04:13:23 +0000 | [diff] [blame] | 585 | return Stmt::BinaryOperatorClass; |
| 586 | |
| 587 | case OO_Caret: |
John McCall | 2de56d1 | 2010-08-25 11:45:40 +0000 | [diff] [blame] | 588 | BinaryOp = BO_Xor; |
Douglas Gregor | a89064a | 2010-05-19 04:13:23 +0000 | [diff] [blame] | 589 | return Stmt::BinaryOperatorClass; |
| 590 | |
| 591 | case OO_Amp: |
| 592 | if (S->getNumArgs() == 1) { |
John McCall | 2de56d1 | 2010-08-25 11:45:40 +0000 | [diff] [blame] | 593 | UnaryOp = UO_AddrOf; |
Douglas Gregor | a89064a | 2010-05-19 04:13:23 +0000 | [diff] [blame] | 594 | return Stmt::UnaryOperatorClass; |
| 595 | } |
| 596 | |
John McCall | 2de56d1 | 2010-08-25 11:45:40 +0000 | [diff] [blame] | 597 | BinaryOp = BO_And; |
Douglas Gregor | a89064a | 2010-05-19 04:13:23 +0000 | [diff] [blame] | 598 | return Stmt::BinaryOperatorClass; |
| 599 | |
| 600 | case OO_Pipe: |
John McCall | 2de56d1 | 2010-08-25 11:45:40 +0000 | [diff] [blame] | 601 | BinaryOp = BO_Or; |
Douglas Gregor | a89064a | 2010-05-19 04:13:23 +0000 | [diff] [blame] | 602 | return Stmt::BinaryOperatorClass; |
| 603 | |
| 604 | case OO_Tilde: |
John McCall | 2de56d1 | 2010-08-25 11:45:40 +0000 | [diff] [blame] | 605 | UnaryOp = UO_Not; |
Douglas Gregor | a89064a | 2010-05-19 04:13:23 +0000 | [diff] [blame] | 606 | return Stmt::UnaryOperatorClass; |
| 607 | |
| 608 | case OO_Exclaim: |
John McCall | 2de56d1 | 2010-08-25 11:45:40 +0000 | [diff] [blame] | 609 | UnaryOp = UO_LNot; |
Douglas Gregor | a89064a | 2010-05-19 04:13:23 +0000 | [diff] [blame] | 610 | return Stmt::UnaryOperatorClass; |
| 611 | |
| 612 | case OO_Equal: |
John McCall | 2de56d1 | 2010-08-25 11:45:40 +0000 | [diff] [blame] | 613 | BinaryOp = BO_Assign; |
Douglas Gregor | a89064a | 2010-05-19 04:13:23 +0000 | [diff] [blame] | 614 | return Stmt::BinaryOperatorClass; |
| 615 | |
| 616 | case OO_Less: |
John McCall | 2de56d1 | 2010-08-25 11:45:40 +0000 | [diff] [blame] | 617 | BinaryOp = BO_LT; |
Douglas Gregor | a89064a | 2010-05-19 04:13:23 +0000 | [diff] [blame] | 618 | return Stmt::BinaryOperatorClass; |
| 619 | |
| 620 | case OO_Greater: |
John McCall | 2de56d1 | 2010-08-25 11:45:40 +0000 | [diff] [blame] | 621 | BinaryOp = BO_GT; |
Douglas Gregor | a89064a | 2010-05-19 04:13:23 +0000 | [diff] [blame] | 622 | return Stmt::BinaryOperatorClass; |
| 623 | |
| 624 | case OO_PlusEqual: |
John McCall | 2de56d1 | 2010-08-25 11:45:40 +0000 | [diff] [blame] | 625 | BinaryOp = BO_AddAssign; |
Douglas Gregor | a89064a | 2010-05-19 04:13:23 +0000 | [diff] [blame] | 626 | return Stmt::CompoundAssignOperatorClass; |
| 627 | |
| 628 | case OO_MinusEqual: |
John McCall | 2de56d1 | 2010-08-25 11:45:40 +0000 | [diff] [blame] | 629 | BinaryOp = BO_SubAssign; |
Douglas Gregor | a89064a | 2010-05-19 04:13:23 +0000 | [diff] [blame] | 630 | return Stmt::CompoundAssignOperatorClass; |
| 631 | |
| 632 | case OO_StarEqual: |
John McCall | 2de56d1 | 2010-08-25 11:45:40 +0000 | [diff] [blame] | 633 | BinaryOp = BO_MulAssign; |
Douglas Gregor | a89064a | 2010-05-19 04:13:23 +0000 | [diff] [blame] | 634 | return Stmt::CompoundAssignOperatorClass; |
| 635 | |
| 636 | case OO_SlashEqual: |
John McCall | 2de56d1 | 2010-08-25 11:45:40 +0000 | [diff] [blame] | 637 | BinaryOp = BO_DivAssign; |
Douglas Gregor | a89064a | 2010-05-19 04:13:23 +0000 | [diff] [blame] | 638 | return Stmt::CompoundAssignOperatorClass; |
| 639 | |
| 640 | case OO_PercentEqual: |
John McCall | 2de56d1 | 2010-08-25 11:45:40 +0000 | [diff] [blame] | 641 | BinaryOp = BO_RemAssign; |
Douglas Gregor | a89064a | 2010-05-19 04:13:23 +0000 | [diff] [blame] | 642 | return Stmt::CompoundAssignOperatorClass; |
| 643 | |
| 644 | case OO_CaretEqual: |
John McCall | 2de56d1 | 2010-08-25 11:45:40 +0000 | [diff] [blame] | 645 | BinaryOp = BO_XorAssign; |
Douglas Gregor | a89064a | 2010-05-19 04:13:23 +0000 | [diff] [blame] | 646 | return Stmt::CompoundAssignOperatorClass; |
| 647 | |
| 648 | case OO_AmpEqual: |
John McCall | 2de56d1 | 2010-08-25 11:45:40 +0000 | [diff] [blame] | 649 | BinaryOp = BO_AndAssign; |
Douglas Gregor | a89064a | 2010-05-19 04:13:23 +0000 | [diff] [blame] | 650 | return Stmt::CompoundAssignOperatorClass; |
| 651 | |
| 652 | case OO_PipeEqual: |
John McCall | 2de56d1 | 2010-08-25 11:45:40 +0000 | [diff] [blame] | 653 | BinaryOp = BO_OrAssign; |
Douglas Gregor | a89064a | 2010-05-19 04:13:23 +0000 | [diff] [blame] | 654 | return Stmt::CompoundAssignOperatorClass; |
| 655 | |
| 656 | case OO_LessLess: |
John McCall | 2de56d1 | 2010-08-25 11:45:40 +0000 | [diff] [blame] | 657 | BinaryOp = BO_Shl; |
Douglas Gregor | a89064a | 2010-05-19 04:13:23 +0000 | [diff] [blame] | 658 | return Stmt::BinaryOperatorClass; |
| 659 | |
| 660 | case OO_GreaterGreater: |
John McCall | 2de56d1 | 2010-08-25 11:45:40 +0000 | [diff] [blame] | 661 | BinaryOp = BO_Shr; |
Douglas Gregor | a89064a | 2010-05-19 04:13:23 +0000 | [diff] [blame] | 662 | return Stmt::BinaryOperatorClass; |
| 663 | |
| 664 | case OO_LessLessEqual: |
John McCall | 2de56d1 | 2010-08-25 11:45:40 +0000 | [diff] [blame] | 665 | BinaryOp = BO_ShlAssign; |
Douglas Gregor | a89064a | 2010-05-19 04:13:23 +0000 | [diff] [blame] | 666 | return Stmt::CompoundAssignOperatorClass; |
| 667 | |
| 668 | case OO_GreaterGreaterEqual: |
John McCall | 2de56d1 | 2010-08-25 11:45:40 +0000 | [diff] [blame] | 669 | BinaryOp = BO_ShrAssign; |
Douglas Gregor | a89064a | 2010-05-19 04:13:23 +0000 | [diff] [blame] | 670 | return Stmt::CompoundAssignOperatorClass; |
| 671 | |
| 672 | case OO_EqualEqual: |
John McCall | 2de56d1 | 2010-08-25 11:45:40 +0000 | [diff] [blame] | 673 | BinaryOp = BO_EQ; |
Douglas Gregor | a89064a | 2010-05-19 04:13:23 +0000 | [diff] [blame] | 674 | return Stmt::BinaryOperatorClass; |
| 675 | |
| 676 | case OO_ExclaimEqual: |
John McCall | 2de56d1 | 2010-08-25 11:45:40 +0000 | [diff] [blame] | 677 | BinaryOp = BO_NE; |
Douglas Gregor | a89064a | 2010-05-19 04:13:23 +0000 | [diff] [blame] | 678 | return Stmt::BinaryOperatorClass; |
| 679 | |
| 680 | case OO_LessEqual: |
John McCall | 2de56d1 | 2010-08-25 11:45:40 +0000 | [diff] [blame] | 681 | BinaryOp = BO_LE; |
Douglas Gregor | a89064a | 2010-05-19 04:13:23 +0000 | [diff] [blame] | 682 | return Stmt::BinaryOperatorClass; |
| 683 | |
| 684 | case OO_GreaterEqual: |
John McCall | 2de56d1 | 2010-08-25 11:45:40 +0000 | [diff] [blame] | 685 | BinaryOp = BO_GE; |
Douglas Gregor | a89064a | 2010-05-19 04:13:23 +0000 | [diff] [blame] | 686 | return Stmt::BinaryOperatorClass; |
| 687 | |
| 688 | case OO_AmpAmp: |
John McCall | 2de56d1 | 2010-08-25 11:45:40 +0000 | [diff] [blame] | 689 | BinaryOp = BO_LAnd; |
Douglas Gregor | a89064a | 2010-05-19 04:13:23 +0000 | [diff] [blame] | 690 | return Stmt::BinaryOperatorClass; |
| 691 | |
| 692 | case OO_PipePipe: |
John McCall | 2de56d1 | 2010-08-25 11:45:40 +0000 | [diff] [blame] | 693 | BinaryOp = BO_LOr; |
Douglas Gregor | a89064a | 2010-05-19 04:13:23 +0000 | [diff] [blame] | 694 | return Stmt::BinaryOperatorClass; |
| 695 | |
| 696 | case OO_PlusPlus: |
John McCall | 2de56d1 | 2010-08-25 11:45:40 +0000 | [diff] [blame] | 697 | UnaryOp = S->getNumArgs() == 1? UO_PreInc |
| 698 | : UO_PostInc; |
Douglas Gregor | a89064a | 2010-05-19 04:13:23 +0000 | [diff] [blame] | 699 | return Stmt::UnaryOperatorClass; |
| 700 | |
| 701 | case OO_MinusMinus: |
John McCall | 2de56d1 | 2010-08-25 11:45:40 +0000 | [diff] [blame] | 702 | UnaryOp = S->getNumArgs() == 1? UO_PreDec |
| 703 | : UO_PostDec; |
Douglas Gregor | a89064a | 2010-05-19 04:13:23 +0000 | [diff] [blame] | 704 | return Stmt::UnaryOperatorClass; |
| 705 | |
| 706 | case OO_Comma: |
John McCall | 2de56d1 | 2010-08-25 11:45:40 +0000 | [diff] [blame] | 707 | BinaryOp = BO_Comma; |
Douglas Gregor | a89064a | 2010-05-19 04:13:23 +0000 | [diff] [blame] | 708 | return Stmt::BinaryOperatorClass; |
| 709 | |
| 710 | |
| 711 | case OO_ArrowStar: |
John McCall | 2de56d1 | 2010-08-25 11:45:40 +0000 | [diff] [blame] | 712 | BinaryOp = BO_PtrMemI; |
Douglas Gregor | a89064a | 2010-05-19 04:13:23 +0000 | [diff] [blame] | 713 | return Stmt::BinaryOperatorClass; |
| 714 | |
| 715 | case OO_Subscript: |
| 716 | return Stmt::ArraySubscriptExprClass; |
| 717 | } |
| 718 | |
| 719 | llvm_unreachable("Invalid overloaded operator expression"); |
| 720 | } |
| 721 | |
| 722 | |
Chandler Carruth | b113824 | 2011-06-16 06:47:06 +0000 | [diff] [blame] | 723 | void StmtProfiler::VisitCXXOperatorCallExpr(const CXXOperatorCallExpr *S) { |
Douglas Gregor | a89064a | 2010-05-19 04:13:23 +0000 | [diff] [blame] | 724 | if (S->isTypeDependent()) { |
| 725 | // Type-dependent operator calls are profiled like their underlying |
| 726 | // syntactic operator. |
John McCall | 2de56d1 | 2010-08-25 11:45:40 +0000 | [diff] [blame] | 727 | UnaryOperatorKind UnaryOp = UO_Extension; |
| 728 | BinaryOperatorKind BinaryOp = BO_Comma; |
Douglas Gregor | a89064a | 2010-05-19 04:13:23 +0000 | [diff] [blame] | 729 | Stmt::StmtClass SC = DecodeOperatorCall(S, UnaryOp, BinaryOp); |
| 730 | |
| 731 | ID.AddInteger(SC); |
| 732 | for (unsigned I = 0, N = S->getNumArgs(); I != N; ++I) |
| 733 | Visit(S->getArg(I)); |
| 734 | if (SC == Stmt::UnaryOperatorClass) |
| 735 | ID.AddInteger(UnaryOp); |
| 736 | else if (SC == Stmt::BinaryOperatorClass || |
| 737 | SC == Stmt::CompoundAssignOperatorClass) |
| 738 | ID.AddInteger(BinaryOp); |
| 739 | else |
| 740 | assert(SC == Stmt::ArraySubscriptExprClass); |
| 741 | |
| 742 | return; |
| 743 | } |
| 744 | |
Douglas Gregor | 41ef0c3 | 2009-07-28 00:33:38 +0000 | [diff] [blame] | 745 | VisitCallExpr(S); |
| 746 | ID.AddInteger(S->getOperator()); |
| 747 | } |
| 748 | |
Chandler Carruth | b113824 | 2011-06-16 06:47:06 +0000 | [diff] [blame] | 749 | void StmtProfiler::VisitCXXMemberCallExpr(const CXXMemberCallExpr *S) { |
Douglas Gregor | 41ef0c3 | 2009-07-28 00:33:38 +0000 | [diff] [blame] | 750 | VisitCallExpr(S); |
| 751 | } |
| 752 | |
Chandler Carruth | b113824 | 2011-06-16 06:47:06 +0000 | [diff] [blame] | 753 | void StmtProfiler::VisitCUDAKernelCallExpr(const CUDAKernelCallExpr *S) { |
Peter Collingbourne | e08ce65 | 2011-02-09 21:07:24 +0000 | [diff] [blame] | 754 | VisitCallExpr(S); |
| 755 | } |
| 756 | |
Chandler Carruth | b113824 | 2011-06-16 06:47:06 +0000 | [diff] [blame] | 757 | void StmtProfiler::VisitAsTypeExpr(const AsTypeExpr *S) { |
Tanya Lattner | 61eee0c | 2011-06-04 00:47:47 +0000 | [diff] [blame] | 758 | VisitExpr(S); |
| 759 | } |
| 760 | |
Chandler Carruth | b113824 | 2011-06-16 06:47:06 +0000 | [diff] [blame] | 761 | void StmtProfiler::VisitCXXNamedCastExpr(const CXXNamedCastExpr *S) { |
Douglas Gregor | 41ef0c3 | 2009-07-28 00:33:38 +0000 | [diff] [blame] | 762 | VisitExplicitCastExpr(S); |
| 763 | } |
| 764 | |
Chandler Carruth | b113824 | 2011-06-16 06:47:06 +0000 | [diff] [blame] | 765 | void StmtProfiler::VisitCXXStaticCastExpr(const CXXStaticCastExpr *S) { |
Douglas Gregor | 41ef0c3 | 2009-07-28 00:33:38 +0000 | [diff] [blame] | 766 | VisitCXXNamedCastExpr(S); |
| 767 | } |
| 768 | |
Chandler Carruth | b113824 | 2011-06-16 06:47:06 +0000 | [diff] [blame] | 769 | void StmtProfiler::VisitCXXDynamicCastExpr(const CXXDynamicCastExpr *S) { |
Douglas Gregor | 41ef0c3 | 2009-07-28 00:33:38 +0000 | [diff] [blame] | 770 | VisitCXXNamedCastExpr(S); |
| 771 | } |
| 772 | |
Chandler Carruth | b113824 | 2011-06-16 06:47:06 +0000 | [diff] [blame] | 773 | void |
| 774 | StmtProfiler::VisitCXXReinterpretCastExpr(const CXXReinterpretCastExpr *S) { |
Douglas Gregor | 41ef0c3 | 2009-07-28 00:33:38 +0000 | [diff] [blame] | 775 | VisitCXXNamedCastExpr(S); |
| 776 | } |
| 777 | |
Chandler Carruth | b113824 | 2011-06-16 06:47:06 +0000 | [diff] [blame] | 778 | void StmtProfiler::VisitCXXConstCastExpr(const CXXConstCastExpr *S) { |
Douglas Gregor | 41ef0c3 | 2009-07-28 00:33:38 +0000 | [diff] [blame] | 779 | VisitCXXNamedCastExpr(S); |
| 780 | } |
| 781 | |
Richard Smith | 9fcce65 | 2012-03-07 08:35:16 +0000 | [diff] [blame] | 782 | void StmtProfiler::VisitUserDefinedLiteral(const UserDefinedLiteral *S) { |
| 783 | VisitCallExpr(S); |
| 784 | } |
| 785 | |
Chandler Carruth | b113824 | 2011-06-16 06:47:06 +0000 | [diff] [blame] | 786 | void StmtProfiler::VisitCXXBoolLiteralExpr(const CXXBoolLiteralExpr *S) { |
Douglas Gregor | 41ef0c3 | 2009-07-28 00:33:38 +0000 | [diff] [blame] | 787 | VisitExpr(S); |
| 788 | ID.AddBoolean(S->getValue()); |
| 789 | } |
| 790 | |
Chandler Carruth | b113824 | 2011-06-16 06:47:06 +0000 | [diff] [blame] | 791 | void StmtProfiler::VisitCXXNullPtrLiteralExpr(const CXXNullPtrLiteralExpr *S) { |
Douglas Gregor | 828e226 | 2009-07-29 16:09:57 +0000 | [diff] [blame] | 792 | VisitExpr(S); |
| 793 | } |
| 794 | |
Richard Smith | 7c3e615 | 2013-06-12 22:31:48 +0000 | [diff] [blame] | 795 | void StmtProfiler::VisitCXXStdInitializerListExpr( |
| 796 | const CXXStdInitializerListExpr *S) { |
| 797 | VisitExpr(S); |
| 798 | } |
| 799 | |
Chandler Carruth | b113824 | 2011-06-16 06:47:06 +0000 | [diff] [blame] | 800 | void StmtProfiler::VisitCXXTypeidExpr(const CXXTypeidExpr *S) { |
Douglas Gregor | 41ef0c3 | 2009-07-28 00:33:38 +0000 | [diff] [blame] | 801 | VisitExpr(S); |
| 802 | if (S->isTypeOperand()) |
| 803 | VisitType(S->getTypeOperand()); |
| 804 | } |
| 805 | |
Chandler Carruth | b113824 | 2011-06-16 06:47:06 +0000 | [diff] [blame] | 806 | void StmtProfiler::VisitCXXUuidofExpr(const CXXUuidofExpr *S) { |
Francois Pichet | 01b7c30 | 2010-09-08 12:20:18 +0000 | [diff] [blame] | 807 | VisitExpr(S); |
| 808 | if (S->isTypeOperand()) |
| 809 | VisitType(S->getTypeOperand()); |
| 810 | } |
| 811 | |
John McCall | 76da55d | 2013-04-16 07:28:30 +0000 | [diff] [blame] | 812 | void StmtProfiler::VisitMSPropertyRefExpr(const MSPropertyRefExpr *S) { |
| 813 | VisitExpr(S); |
| 814 | VisitDecl(S->getPropertyDecl()); |
| 815 | } |
| 816 | |
Chandler Carruth | b113824 | 2011-06-16 06:47:06 +0000 | [diff] [blame] | 817 | void StmtProfiler::VisitCXXThisExpr(const CXXThisExpr *S) { |
Douglas Gregor | 41ef0c3 | 2009-07-28 00:33:38 +0000 | [diff] [blame] | 818 | VisitExpr(S); |
Douglas Gregor | cefc3af | 2012-04-16 07:05:22 +0000 | [diff] [blame] | 819 | ID.AddBoolean(S->isImplicit()); |
Douglas Gregor | 41ef0c3 | 2009-07-28 00:33:38 +0000 | [diff] [blame] | 820 | } |
| 821 | |
Chandler Carruth | b113824 | 2011-06-16 06:47:06 +0000 | [diff] [blame] | 822 | void StmtProfiler::VisitCXXThrowExpr(const CXXThrowExpr *S) { |
Douglas Gregor | 41ef0c3 | 2009-07-28 00:33:38 +0000 | [diff] [blame] | 823 | VisitExpr(S); |
| 824 | } |
| 825 | |
Chandler Carruth | b113824 | 2011-06-16 06:47:06 +0000 | [diff] [blame] | 826 | void StmtProfiler::VisitCXXDefaultArgExpr(const CXXDefaultArgExpr *S) { |
Douglas Gregor | 41ef0c3 | 2009-07-28 00:33:38 +0000 | [diff] [blame] | 827 | VisitExpr(S); |
| 828 | VisitDecl(S->getParam()); |
| 829 | } |
| 830 | |
Richard Smith | c3bf52c | 2013-04-20 22:23:05 +0000 | [diff] [blame] | 831 | void StmtProfiler::VisitCXXDefaultInitExpr(const CXXDefaultInitExpr *S) { |
| 832 | VisitExpr(S); |
| 833 | VisitDecl(S->getField()); |
| 834 | } |
| 835 | |
Chandler Carruth | b113824 | 2011-06-16 06:47:06 +0000 | [diff] [blame] | 836 | void StmtProfiler::VisitCXXBindTemporaryExpr(const CXXBindTemporaryExpr *S) { |
Douglas Gregor | 41ef0c3 | 2009-07-28 00:33:38 +0000 | [diff] [blame] | 837 | VisitExpr(S); |
| 838 | VisitDecl( |
| 839 | const_cast<CXXDestructorDecl *>(S->getTemporary()->getDestructor())); |
| 840 | } |
| 841 | |
Chandler Carruth | b113824 | 2011-06-16 06:47:06 +0000 | [diff] [blame] | 842 | void StmtProfiler::VisitCXXConstructExpr(const CXXConstructExpr *S) { |
Douglas Gregor | 41ef0c3 | 2009-07-28 00:33:38 +0000 | [diff] [blame] | 843 | VisitExpr(S); |
| 844 | VisitDecl(S->getConstructor()); |
| 845 | ID.AddBoolean(S->isElidable()); |
| 846 | } |
| 847 | |
Chandler Carruth | b113824 | 2011-06-16 06:47:06 +0000 | [diff] [blame] | 848 | void StmtProfiler::VisitCXXFunctionalCastExpr(const CXXFunctionalCastExpr *S) { |
Douglas Gregor | 41ef0c3 | 2009-07-28 00:33:38 +0000 | [diff] [blame] | 849 | VisitExplicitCastExpr(S); |
| 850 | } |
| 851 | |
Chandler Carruth | b113824 | 2011-06-16 06:47:06 +0000 | [diff] [blame] | 852 | void |
| 853 | StmtProfiler::VisitCXXTemporaryObjectExpr(const CXXTemporaryObjectExpr *S) { |
Douglas Gregor | 41ef0c3 | 2009-07-28 00:33:38 +0000 | [diff] [blame] | 854 | VisitCXXConstructExpr(S); |
| 855 | } |
| 856 | |
Chandler Carruth | b113824 | 2011-06-16 06:47:06 +0000 | [diff] [blame] | 857 | void |
Douglas Gregor | 01d0801 | 2012-02-07 10:09:13 +0000 | [diff] [blame] | 858 | StmtProfiler::VisitLambdaExpr(const LambdaExpr *S) { |
| 859 | VisitExpr(S); |
| 860 | for (LambdaExpr::capture_iterator C = S->explicit_capture_begin(), |
| 861 | CEnd = S->explicit_capture_end(); |
| 862 | C != CEnd; ++C) { |
| 863 | ID.AddInteger(C->getCaptureKind()); |
Richard Smith | 0d8e964 | 2013-05-16 06:20:58 +0000 | [diff] [blame] | 864 | switch (C->getCaptureKind()) { |
| 865 | case LCK_This: |
| 866 | break; |
| 867 | case LCK_ByRef: |
| 868 | case LCK_ByCopy: |
Douglas Gregor | 01d0801 | 2012-02-07 10:09:13 +0000 | [diff] [blame] | 869 | VisitDecl(C->getCapturedVar()); |
| 870 | ID.AddBoolean(C->isPackExpansion()); |
Richard Smith | 0d8e964 | 2013-05-16 06:20:58 +0000 | [diff] [blame] | 871 | break; |
| 872 | case LCK_Init: |
| 873 | VisitDecl(C->getInitCaptureField()); |
| 874 | break; |
Douglas Gregor | 01d0801 | 2012-02-07 10:09:13 +0000 | [diff] [blame] | 875 | } |
| 876 | } |
| 877 | // Note: If we actually needed to be able to match lambda |
| 878 | // expressions, we would have to consider parameters and return type |
| 879 | // here, among other things. |
| 880 | VisitStmt(S->getBody()); |
| 881 | } |
| 882 | |
| 883 | void |
Chandler Carruth | b113824 | 2011-06-16 06:47:06 +0000 | [diff] [blame] | 884 | StmtProfiler::VisitCXXScalarValueInitExpr(const CXXScalarValueInitExpr *S) { |
Douglas Gregor | 41ef0c3 | 2009-07-28 00:33:38 +0000 | [diff] [blame] | 885 | VisitExpr(S); |
| 886 | } |
| 887 | |
Chandler Carruth | b113824 | 2011-06-16 06:47:06 +0000 | [diff] [blame] | 888 | void StmtProfiler::VisitCXXDeleteExpr(const CXXDeleteExpr *S) { |
Douglas Gregor | 41ef0c3 | 2009-07-28 00:33:38 +0000 | [diff] [blame] | 889 | VisitExpr(S); |
| 890 | ID.AddBoolean(S->isGlobalDelete()); |
| 891 | ID.AddBoolean(S->isArrayForm()); |
| 892 | VisitDecl(S->getOperatorDelete()); |
| 893 | } |
| 894 | |
| 895 | |
Chandler Carruth | b113824 | 2011-06-16 06:47:06 +0000 | [diff] [blame] | 896 | void StmtProfiler::VisitCXXNewExpr(const CXXNewExpr *S) { |
Douglas Gregor | 41ef0c3 | 2009-07-28 00:33:38 +0000 | [diff] [blame] | 897 | VisitExpr(S); |
| 898 | VisitType(S->getAllocatedType()); |
| 899 | VisitDecl(S->getOperatorNew()); |
| 900 | VisitDecl(S->getOperatorDelete()); |
Douglas Gregor | 41ef0c3 | 2009-07-28 00:33:38 +0000 | [diff] [blame] | 901 | ID.AddBoolean(S->isArray()); |
| 902 | ID.AddInteger(S->getNumPlacementArgs()); |
| 903 | ID.AddBoolean(S->isGlobalNew()); |
| 904 | ID.AddBoolean(S->isParenTypeId()); |
Sebastian Redl | 2aed8b8 | 2012-02-16 12:22:20 +0000 | [diff] [blame] | 905 | ID.AddInteger(S->getInitializationStyle()); |
Douglas Gregor | 41ef0c3 | 2009-07-28 00:33:38 +0000 | [diff] [blame] | 906 | } |
| 907 | |
Chandler Carruth | b113824 | 2011-06-16 06:47:06 +0000 | [diff] [blame] | 908 | void |
| 909 | StmtProfiler::VisitCXXPseudoDestructorExpr(const CXXPseudoDestructorExpr *S) { |
Douglas Gregor | a71d819 | 2009-09-04 17:36:40 +0000 | [diff] [blame] | 910 | VisitExpr(S); |
| 911 | ID.AddBoolean(S->isArrow()); |
| 912 | VisitNestedNameSpecifier(S->getQualifier()); |
| 913 | VisitType(S->getDestroyedType()); |
| 914 | } |
| 915 | |
Chandler Carruth | b113824 | 2011-06-16 06:47:06 +0000 | [diff] [blame] | 916 | void StmtProfiler::VisitOverloadExpr(const OverloadExpr *S) { |
Argyrios Kyrtzidis | 7b3e3f6 | 2010-08-15 20:53:20 +0000 | [diff] [blame] | 917 | VisitExpr(S); |
John McCall | f7a1a74 | 2009-11-24 19:00:30 +0000 | [diff] [blame] | 918 | VisitNestedNameSpecifier(S->getQualifier()); |
Douglas Gregor | 41ef0c3 | 2009-07-28 00:33:38 +0000 | [diff] [blame] | 919 | VisitName(S->getName()); |
John McCall | f7a1a74 | 2009-11-24 19:00:30 +0000 | [diff] [blame] | 920 | ID.AddBoolean(S->hasExplicitTemplateArgs()); |
| 921 | if (S->hasExplicitTemplateArgs()) |
Argyrios Kyrtzidis | c35919b | 2010-08-15 01:15:38 +0000 | [diff] [blame] | 922 | VisitTemplateArguments(S->getExplicitTemplateArgs().getTemplateArgs(), |
| 923 | S->getExplicitTemplateArgs().NumTemplateArgs); |
| 924 | } |
| 925 | |
| 926 | void |
Chandler Carruth | b113824 | 2011-06-16 06:47:06 +0000 | [diff] [blame] | 927 | StmtProfiler::VisitUnresolvedLookupExpr(const UnresolvedLookupExpr *S) { |
Argyrios Kyrtzidis | c35919b | 2010-08-15 01:15:38 +0000 | [diff] [blame] | 928 | VisitOverloadExpr(S); |
Douglas Gregor | 41ef0c3 | 2009-07-28 00:33:38 +0000 | [diff] [blame] | 929 | } |
| 930 | |
Chandler Carruth | b113824 | 2011-06-16 06:47:06 +0000 | [diff] [blame] | 931 | void StmtProfiler::VisitUnaryTypeTraitExpr(const UnaryTypeTraitExpr *S) { |
Douglas Gregor | 41ef0c3 | 2009-07-28 00:33:38 +0000 | [diff] [blame] | 932 | VisitExpr(S); |
| 933 | ID.AddInteger(S->getTrait()); |
| 934 | VisitType(S->getQueriedType()); |
| 935 | } |
| 936 | |
Chandler Carruth | b113824 | 2011-06-16 06:47:06 +0000 | [diff] [blame] | 937 | void StmtProfiler::VisitBinaryTypeTraitExpr(const BinaryTypeTraitExpr *S) { |
Francois Pichet | 6ad6f28 | 2010-12-07 00:08:36 +0000 | [diff] [blame] | 938 | VisitExpr(S); |
| 939 | ID.AddInteger(S->getTrait()); |
| 940 | VisitType(S->getLhsType()); |
| 941 | VisitType(S->getRhsType()); |
| 942 | } |
| 943 | |
Douglas Gregor | 4ca8ac2 | 2012-02-24 07:38:34 +0000 | [diff] [blame] | 944 | void StmtProfiler::VisitTypeTraitExpr(const TypeTraitExpr *S) { |
| 945 | VisitExpr(S); |
| 946 | ID.AddInteger(S->getTrait()); |
| 947 | ID.AddInteger(S->getNumArgs()); |
| 948 | for (unsigned I = 0, N = S->getNumArgs(); I != N; ++I) |
| 949 | VisitType(S->getArg(I)->getType()); |
| 950 | } |
| 951 | |
Chandler Carruth | b113824 | 2011-06-16 06:47:06 +0000 | [diff] [blame] | 952 | void StmtProfiler::VisitArrayTypeTraitExpr(const ArrayTypeTraitExpr *S) { |
John Wiegley | 21ff2e5 | 2011-04-28 00:16:57 +0000 | [diff] [blame] | 953 | VisitExpr(S); |
| 954 | ID.AddInteger(S->getTrait()); |
| 955 | VisitType(S->getQueriedType()); |
| 956 | } |
| 957 | |
Chandler Carruth | b113824 | 2011-06-16 06:47:06 +0000 | [diff] [blame] | 958 | void StmtProfiler::VisitExpressionTraitExpr(const ExpressionTraitExpr *S) { |
John Wiegley | 5526220 | 2011-04-25 06:54:41 +0000 | [diff] [blame] | 959 | VisitExpr(S); |
| 960 | ID.AddInteger(S->getTrait()); |
| 961 | VisitExpr(S->getQueriedExpression()); |
| 962 | } |
| 963 | |
Chandler Carruth | b113824 | 2011-06-16 06:47:06 +0000 | [diff] [blame] | 964 | void StmtProfiler::VisitDependentScopeDeclRefExpr( |
| 965 | const DependentScopeDeclRefExpr *S) { |
Douglas Gregor | 41ef0c3 | 2009-07-28 00:33:38 +0000 | [diff] [blame] | 966 | VisitExpr(S); |
| 967 | VisitName(S->getDeclName()); |
| 968 | VisitNestedNameSpecifier(S->getQualifier()); |
John McCall | f7a1a74 | 2009-11-24 19:00:30 +0000 | [diff] [blame] | 969 | ID.AddBoolean(S->hasExplicitTemplateArgs()); |
| 970 | if (S->hasExplicitTemplateArgs()) |
| 971 | VisitTemplateArguments(S->getTemplateArgs(), S->getNumTemplateArgs()); |
Douglas Gregor | 41ef0c3 | 2009-07-28 00:33:38 +0000 | [diff] [blame] | 972 | } |
| 973 | |
Chandler Carruth | b113824 | 2011-06-16 06:47:06 +0000 | [diff] [blame] | 974 | void StmtProfiler::VisitExprWithCleanups(const ExprWithCleanups *S) { |
Douglas Gregor | 071f4eb | 2009-07-28 14:44:31 +0000 | [diff] [blame] | 975 | VisitExpr(S); |
Douglas Gregor | 071f4eb | 2009-07-28 14:44:31 +0000 | [diff] [blame] | 976 | } |
| 977 | |
Chandler Carruth | b113824 | 2011-06-16 06:47:06 +0000 | [diff] [blame] | 978 | void StmtProfiler::VisitCXXUnresolvedConstructExpr( |
| 979 | const CXXUnresolvedConstructExpr *S) { |
Douglas Gregor | 071f4eb | 2009-07-28 14:44:31 +0000 | [diff] [blame] | 980 | VisitExpr(S); |
| 981 | VisitType(S->getTypeAsWritten()); |
| 982 | } |
| 983 | |
Chandler Carruth | b113824 | 2011-06-16 06:47:06 +0000 | [diff] [blame] | 984 | void StmtProfiler::VisitCXXDependentScopeMemberExpr( |
| 985 | const CXXDependentScopeMemberExpr *S) { |
John McCall | aa81e16 | 2009-12-01 22:10:20 +0000 | [diff] [blame] | 986 | ID.AddBoolean(S->isImplicitAccess()); |
| 987 | if (!S->isImplicitAccess()) { |
| 988 | VisitExpr(S); |
| 989 | ID.AddBoolean(S->isArrow()); |
| 990 | } |
Douglas Gregor | a38c687 | 2009-09-03 16:14:30 +0000 | [diff] [blame] | 991 | VisitNestedNameSpecifier(S->getQualifier()); |
Douglas Gregor | 071f4eb | 2009-07-28 14:44:31 +0000 | [diff] [blame] | 992 | VisitName(S->getMember()); |
John McCall | aa81e16 | 2009-12-01 22:10:20 +0000 | [diff] [blame] | 993 | ID.AddBoolean(S->hasExplicitTemplateArgs()); |
| 994 | if (S->hasExplicitTemplateArgs()) |
John McCall | 129e2df | 2009-11-30 22:42:35 +0000 | [diff] [blame] | 995 | VisitTemplateArguments(S->getTemplateArgs(), S->getNumTemplateArgs()); |
| 996 | } |
| 997 | |
Chandler Carruth | b113824 | 2011-06-16 06:47:06 +0000 | [diff] [blame] | 998 | void StmtProfiler::VisitUnresolvedMemberExpr(const UnresolvedMemberExpr *S) { |
John McCall | aa81e16 | 2009-12-01 22:10:20 +0000 | [diff] [blame] | 999 | ID.AddBoolean(S->isImplicitAccess()); |
| 1000 | if (!S->isImplicitAccess()) { |
| 1001 | VisitExpr(S); |
| 1002 | ID.AddBoolean(S->isArrow()); |
| 1003 | } |
John McCall | 129e2df | 2009-11-30 22:42:35 +0000 | [diff] [blame] | 1004 | VisitNestedNameSpecifier(S->getQualifier()); |
| 1005 | VisitName(S->getMemberName()); |
| 1006 | ID.AddBoolean(S->hasExplicitTemplateArgs()); |
| 1007 | if (S->hasExplicitTemplateArgs()) |
| 1008 | VisitTemplateArguments(S->getTemplateArgs(), S->getNumTemplateArgs()); |
Douglas Gregor | 071f4eb | 2009-07-28 14:44:31 +0000 | [diff] [blame] | 1009 | } |
| 1010 | |
Chandler Carruth | b113824 | 2011-06-16 06:47:06 +0000 | [diff] [blame] | 1011 | void StmtProfiler::VisitCXXNoexceptExpr(const CXXNoexceptExpr *S) { |
Sebastian Redl | 2e15622 | 2010-09-10 20:55:43 +0000 | [diff] [blame] | 1012 | VisitExpr(S); |
| 1013 | } |
| 1014 | |
Chandler Carruth | b113824 | 2011-06-16 06:47:06 +0000 | [diff] [blame] | 1015 | void StmtProfiler::VisitPackExpansionExpr(const PackExpansionExpr *S) { |
Douglas Gregor | be230c3 | 2011-01-03 17:17:50 +0000 | [diff] [blame] | 1016 | VisitExpr(S); |
| 1017 | } |
| 1018 | |
Chandler Carruth | b113824 | 2011-06-16 06:47:06 +0000 | [diff] [blame] | 1019 | void StmtProfiler::VisitSizeOfPackExpr(const SizeOfPackExpr *S) { |
Douglas Gregor | ee8aff0 | 2011-01-04 17:33:58 +0000 | [diff] [blame] | 1020 | VisitExpr(S); |
| 1021 | VisitDecl(S->getPack()); |
| 1022 | } |
| 1023 | |
Douglas Gregor | c7793c7 | 2011-01-15 01:15:58 +0000 | [diff] [blame] | 1024 | void StmtProfiler::VisitSubstNonTypeTemplateParmPackExpr( |
Chandler Carruth | b113824 | 2011-06-16 06:47:06 +0000 | [diff] [blame] | 1025 | const SubstNonTypeTemplateParmPackExpr *S) { |
Douglas Gregor | c7793c7 | 2011-01-15 01:15:58 +0000 | [diff] [blame] | 1026 | VisitExpr(S); |
| 1027 | VisitDecl(S->getParameterPack()); |
| 1028 | VisitTemplateArgument(S->getArgumentPack()); |
| 1029 | } |
| 1030 | |
John McCall | 91a5755 | 2011-07-15 05:09:51 +0000 | [diff] [blame] | 1031 | void StmtProfiler::VisitSubstNonTypeTemplateParmExpr( |
| 1032 | const SubstNonTypeTemplateParmExpr *E) { |
| 1033 | // Profile exactly as the replacement expression. |
| 1034 | Visit(E->getReplacement()); |
| 1035 | } |
| 1036 | |
Richard Smith | 9a4db03 | 2012-09-12 00:56:43 +0000 | [diff] [blame] | 1037 | void StmtProfiler::VisitFunctionParmPackExpr(const FunctionParmPackExpr *S) { |
| 1038 | VisitExpr(S); |
| 1039 | VisitDecl(S->getParameterPack()); |
| 1040 | ID.AddInteger(S->getNumExpansions()); |
| 1041 | for (FunctionParmPackExpr::iterator I = S->begin(), E = S->end(); I != E; ++I) |
| 1042 | VisitDecl(*I); |
| 1043 | } |
| 1044 | |
Douglas Gregor | 03e8003 | 2011-06-21 17:03:29 +0000 | [diff] [blame] | 1045 | void StmtProfiler::VisitMaterializeTemporaryExpr( |
| 1046 | const MaterializeTemporaryExpr *S) { |
| 1047 | VisitExpr(S); |
| 1048 | } |
| 1049 | |
Chandler Carruth | b113824 | 2011-06-16 06:47:06 +0000 | [diff] [blame] | 1050 | void StmtProfiler::VisitOpaqueValueExpr(const OpaqueValueExpr *E) { |
John McCall | 7cd7d1a | 2010-11-15 23:31:06 +0000 | [diff] [blame] | 1051 | VisitExpr(E); |
| 1052 | } |
| 1053 | |
Chandler Carruth | b113824 | 2011-06-16 06:47:06 +0000 | [diff] [blame] | 1054 | void StmtProfiler::VisitObjCStringLiteral(const ObjCStringLiteral *S) { |
Douglas Gregor | 071f4eb | 2009-07-28 14:44:31 +0000 | [diff] [blame] | 1055 | VisitExpr(S); |
| 1056 | } |
| 1057 | |
Patrick Beard | eb382ec | 2012-04-19 00:25:12 +0000 | [diff] [blame] | 1058 | void StmtProfiler::VisitObjCBoxedExpr(const ObjCBoxedExpr *E) { |
Ted Kremenek | ebcb57a | 2012-03-06 20:05:56 +0000 | [diff] [blame] | 1059 | VisitExpr(E); |
| 1060 | } |
| 1061 | |
| 1062 | void StmtProfiler::VisitObjCArrayLiteral(const ObjCArrayLiteral *E) { |
| 1063 | VisitExpr(E); |
| 1064 | } |
| 1065 | |
| 1066 | void StmtProfiler::VisitObjCDictionaryLiteral(const ObjCDictionaryLiteral *E) { |
| 1067 | VisitExpr(E); |
| 1068 | } |
| 1069 | |
Chandler Carruth | b113824 | 2011-06-16 06:47:06 +0000 | [diff] [blame] | 1070 | void StmtProfiler::VisitObjCEncodeExpr(const ObjCEncodeExpr *S) { |
Douglas Gregor | 071f4eb | 2009-07-28 14:44:31 +0000 | [diff] [blame] | 1071 | VisitExpr(S); |
| 1072 | VisitType(S->getEncodedType()); |
| 1073 | } |
| 1074 | |
Chandler Carruth | b113824 | 2011-06-16 06:47:06 +0000 | [diff] [blame] | 1075 | void StmtProfiler::VisitObjCSelectorExpr(const ObjCSelectorExpr *S) { |
Douglas Gregor | 071f4eb | 2009-07-28 14:44:31 +0000 | [diff] [blame] | 1076 | VisitExpr(S); |
| 1077 | VisitName(S->getSelector()); |
| 1078 | } |
| 1079 | |
Chandler Carruth | b113824 | 2011-06-16 06:47:06 +0000 | [diff] [blame] | 1080 | void StmtProfiler::VisitObjCProtocolExpr(const ObjCProtocolExpr *S) { |
Douglas Gregor | 071f4eb | 2009-07-28 14:44:31 +0000 | [diff] [blame] | 1081 | VisitExpr(S); |
| 1082 | VisitDecl(S->getProtocol()); |
| 1083 | } |
| 1084 | |
Chandler Carruth | b113824 | 2011-06-16 06:47:06 +0000 | [diff] [blame] | 1085 | void StmtProfiler::VisitObjCIvarRefExpr(const ObjCIvarRefExpr *S) { |
Douglas Gregor | 071f4eb | 2009-07-28 14:44:31 +0000 | [diff] [blame] | 1086 | VisitExpr(S); |
| 1087 | VisitDecl(S->getDecl()); |
| 1088 | ID.AddBoolean(S->isArrow()); |
| 1089 | ID.AddBoolean(S->isFreeIvar()); |
| 1090 | } |
| 1091 | |
Chandler Carruth | b113824 | 2011-06-16 06:47:06 +0000 | [diff] [blame] | 1092 | void StmtProfiler::VisitObjCPropertyRefExpr(const ObjCPropertyRefExpr *S) { |
Douglas Gregor | 071f4eb | 2009-07-28 14:44:31 +0000 | [diff] [blame] | 1093 | VisitExpr(S); |
John McCall | 12f78a6 | 2010-12-02 01:19:52 +0000 | [diff] [blame] | 1094 | if (S->isImplicitProperty()) { |
| 1095 | VisitDecl(S->getImplicitPropertyGetter()); |
| 1096 | VisitDecl(S->getImplicitPropertySetter()); |
| 1097 | } else { |
| 1098 | VisitDecl(S->getExplicitProperty()); |
Fariborz Jahanian | 8ac2d44 | 2010-10-14 16:04:05 +0000 | [diff] [blame] | 1099 | } |
Fariborz Jahanian | 8ac2d44 | 2010-10-14 16:04:05 +0000 | [diff] [blame] | 1100 | if (S->isSuperReceiver()) { |
| 1101 | ID.AddBoolean(S->isSuperReceiver()); |
John McCall | 12f78a6 | 2010-12-02 01:19:52 +0000 | [diff] [blame] | 1102 | VisitType(S->getSuperReceiverType()); |
Fariborz Jahanian | 8ac2d44 | 2010-10-14 16:04:05 +0000 | [diff] [blame] | 1103 | } |
Douglas Gregor | 071f4eb | 2009-07-28 14:44:31 +0000 | [diff] [blame] | 1104 | } |
| 1105 | |
Ted Kremenek | ebcb57a | 2012-03-06 20:05:56 +0000 | [diff] [blame] | 1106 | void StmtProfiler::VisitObjCSubscriptRefExpr(const ObjCSubscriptRefExpr *S) { |
| 1107 | VisitExpr(S); |
| 1108 | VisitDecl(S->getAtIndexMethodDecl()); |
| 1109 | VisitDecl(S->setAtIndexMethodDecl()); |
| 1110 | } |
| 1111 | |
Chandler Carruth | b113824 | 2011-06-16 06:47:06 +0000 | [diff] [blame] | 1112 | void StmtProfiler::VisitObjCMessageExpr(const ObjCMessageExpr *S) { |
Douglas Gregor | 071f4eb | 2009-07-28 14:44:31 +0000 | [diff] [blame] | 1113 | VisitExpr(S); |
| 1114 | VisitName(S->getSelector()); |
| 1115 | VisitDecl(S->getMethodDecl()); |
| 1116 | } |
| 1117 | |
Chandler Carruth | b113824 | 2011-06-16 06:47:06 +0000 | [diff] [blame] | 1118 | void StmtProfiler::VisitObjCIsaExpr(const ObjCIsaExpr *S) { |
Douglas Gregor | 071f4eb | 2009-07-28 14:44:31 +0000 | [diff] [blame] | 1119 | VisitExpr(S); |
| 1120 | ID.AddBoolean(S->isArrow()); |
| 1121 | } |
| 1122 | |
Ted Kremenek | ebcb57a | 2012-03-06 20:05:56 +0000 | [diff] [blame] | 1123 | void StmtProfiler::VisitObjCBoolLiteralExpr(const ObjCBoolLiteralExpr *S) { |
| 1124 | VisitExpr(S); |
| 1125 | ID.AddBoolean(S->getValue()); |
| 1126 | } |
| 1127 | |
Chandler Carruth | b113824 | 2011-06-16 06:47:06 +0000 | [diff] [blame] | 1128 | void StmtProfiler::VisitObjCIndirectCopyRestoreExpr( |
| 1129 | const ObjCIndirectCopyRestoreExpr *S) { |
John McCall | f85e193 | 2011-06-15 23:02:42 +0000 | [diff] [blame] | 1130 | VisitExpr(S); |
| 1131 | ID.AddBoolean(S->shouldCopy()); |
| 1132 | } |
| 1133 | |
Chandler Carruth | b113824 | 2011-06-16 06:47:06 +0000 | [diff] [blame] | 1134 | void StmtProfiler::VisitObjCBridgedCastExpr(const ObjCBridgedCastExpr *S) { |
John McCall | f85e193 | 2011-06-15 23:02:42 +0000 | [diff] [blame] | 1135 | VisitExplicitCastExpr(S); |
| 1136 | ID.AddBoolean(S->getBridgeKind()); |
| 1137 | } |
| 1138 | |
Chandler Carruth | b113824 | 2011-06-16 06:47:06 +0000 | [diff] [blame] | 1139 | void StmtProfiler::VisitDecl(const Decl *D) { |
Douglas Gregor | 4a3f780 | 2009-07-31 15:45:02 +0000 | [diff] [blame] | 1140 | ID.AddInteger(D? D->getKind() : 0); |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 1141 | |
Douglas Gregor | b197572 | 2009-07-30 23:18:24 +0000 | [diff] [blame] | 1142 | if (Canonical && D) { |
Chandler Carruth | b113824 | 2011-06-16 06:47:06 +0000 | [diff] [blame] | 1143 | if (const NonTypeTemplateParmDecl *NTTP = |
| 1144 | dyn_cast<NonTypeTemplateParmDecl>(D)) { |
Douglas Gregor | d584eb2 | 2009-07-28 15:32:17 +0000 | [diff] [blame] | 1145 | ID.AddInteger(NTTP->getDepth()); |
| 1146 | ID.AddInteger(NTTP->getIndex()); |
Douglas Gregor | 61c4d28 | 2011-01-05 15:48:55 +0000 | [diff] [blame] | 1147 | ID.AddBoolean(NTTP->isParameterPack()); |
Douglas Gregor | 828e226 | 2009-07-29 16:09:57 +0000 | [diff] [blame] | 1148 | VisitType(NTTP->getType()); |
Douglas Gregor | 41ef0c3 | 2009-07-28 00:33:38 +0000 | [diff] [blame] | 1149 | return; |
| 1150 | } |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 1151 | |
Chandler Carruth | b113824 | 2011-06-16 06:47:06 +0000 | [diff] [blame] | 1152 | if (const ParmVarDecl *Parm = dyn_cast<ParmVarDecl>(D)) { |
John McCall | fb44de9 | 2011-05-01 22:35:37 +0000 | [diff] [blame] | 1153 | // The Itanium C++ ABI uses the type, scope depth, and scope |
| 1154 | // index of a parameter when mangling expressions that involve |
| 1155 | // function parameters, so we will use the parameter's type for |
| 1156 | // establishing function parameter identity. That way, our |
| 1157 | // definition of "equivalent" (per C++ [temp.over.link]) is at |
| 1158 | // least as strong as the definition of "equivalent" used for |
| 1159 | // name mangling. |
Douglas Gregor | 4a3f780 | 2009-07-31 15:45:02 +0000 | [diff] [blame] | 1160 | VisitType(Parm->getType()); |
John McCall | fb44de9 | 2011-05-01 22:35:37 +0000 | [diff] [blame] | 1161 | ID.AddInteger(Parm->getFunctionScopeDepth()); |
| 1162 | ID.AddInteger(Parm->getFunctionScopeIndex()); |
Douglas Gregor | 4a3f780 | 2009-07-31 15:45:02 +0000 | [diff] [blame] | 1163 | return; |
| 1164 | } |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 1165 | |
Richard Smith | 0f6931a | 2012-04-02 18:53:24 +0000 | [diff] [blame] | 1166 | if (const TemplateTypeParmDecl *TTP = |
| 1167 | dyn_cast<TemplateTypeParmDecl>(D)) { |
| 1168 | ID.AddInteger(TTP->getDepth()); |
| 1169 | ID.AddInteger(TTP->getIndex()); |
| 1170 | ID.AddBoolean(TTP->isParameterPack()); |
| 1171 | return; |
| 1172 | } |
| 1173 | |
Chandler Carruth | b113824 | 2011-06-16 06:47:06 +0000 | [diff] [blame] | 1174 | if (const TemplateTemplateParmDecl *TTP = |
| 1175 | dyn_cast<TemplateTemplateParmDecl>(D)) { |
Douglas Gregor | a2ffb98 | 2009-07-31 15:46:56 +0000 | [diff] [blame] | 1176 | ID.AddInteger(TTP->getDepth()); |
| 1177 | ID.AddInteger(TTP->getIndex()); |
Douglas Gregor | 61c4d28 | 2011-01-05 15:48:55 +0000 | [diff] [blame] | 1178 | ID.AddBoolean(TTP->isParameterPack()); |
Douglas Gregor | a2ffb98 | 2009-07-31 15:46:56 +0000 | [diff] [blame] | 1179 | return; |
| 1180 | } |
Douglas Gregor | 41ef0c3 | 2009-07-28 00:33:38 +0000 | [diff] [blame] | 1181 | } |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 1182 | |
Douglas Gregor | d584eb2 | 2009-07-28 15:32:17 +0000 | [diff] [blame] | 1183 | ID.AddPointer(D? D->getCanonicalDecl() : 0); |
| 1184 | } |
| 1185 | |
| 1186 | void StmtProfiler::VisitType(QualType T) { |
| 1187 | if (Canonical) |
| 1188 | T = Context.getCanonicalType(T); |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 1189 | |
Douglas Gregor | 41ef0c3 | 2009-07-28 00:33:38 +0000 | [diff] [blame] | 1190 | ID.AddPointer(T.getAsOpaquePtr()); |
| 1191 | } |
| 1192 | |
| 1193 | void StmtProfiler::VisitName(DeclarationName Name) { |
| 1194 | ID.AddPointer(Name.getAsOpaquePtr()); |
| 1195 | } |
| 1196 | |
| 1197 | void StmtProfiler::VisitNestedNameSpecifier(NestedNameSpecifier *NNS) { |
| 1198 | if (Canonical) |
| 1199 | NNS = Context.getCanonicalNestedNameSpecifier(NNS); |
| 1200 | ID.AddPointer(NNS); |
| 1201 | } |
| 1202 | |
| 1203 | void StmtProfiler::VisitTemplateName(TemplateName Name) { |
| 1204 | if (Canonical) |
| 1205 | Name = Context.getCanonicalTemplateName(Name); |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 1206 | |
Douglas Gregor | 41ef0c3 | 2009-07-28 00:33:38 +0000 | [diff] [blame] | 1207 | Name.Profile(ID); |
| 1208 | } |
| 1209 | |
John McCall | 833ca99 | 2009-10-29 08:12:44 +0000 | [diff] [blame] | 1210 | void StmtProfiler::VisitTemplateArguments(const TemplateArgumentLoc *Args, |
Douglas Gregor | 41ef0c3 | 2009-07-28 00:33:38 +0000 | [diff] [blame] | 1211 | unsigned NumArgs) { |
| 1212 | ID.AddInteger(NumArgs); |
John McCall | 833ca99 | 2009-10-29 08:12:44 +0000 | [diff] [blame] | 1213 | for (unsigned I = 0; I != NumArgs; ++I) |
| 1214 | VisitTemplateArgument(Args[I].getArgument()); |
| 1215 | } |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 1216 | |
John McCall | 833ca99 | 2009-10-29 08:12:44 +0000 | [diff] [blame] | 1217 | void StmtProfiler::VisitTemplateArgument(const TemplateArgument &Arg) { |
| 1218 | // Mostly repetitive with TemplateArgument::Profile! |
| 1219 | ID.AddInteger(Arg.getKind()); |
| 1220 | switch (Arg.getKind()) { |
| 1221 | case TemplateArgument::Null: |
| 1222 | break; |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 1223 | |
John McCall | 833ca99 | 2009-10-29 08:12:44 +0000 | [diff] [blame] | 1224 | case TemplateArgument::Type: |
| 1225 | VisitType(Arg.getAsType()); |
| 1226 | break; |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 1227 | |
Douglas Gregor | 788cd06 | 2009-11-11 01:00:40 +0000 | [diff] [blame] | 1228 | case TemplateArgument::Template: |
Douglas Gregor | a7fc901 | 2011-01-05 18:58:31 +0000 | [diff] [blame] | 1229 | case TemplateArgument::TemplateExpansion: |
| 1230 | VisitTemplateName(Arg.getAsTemplateOrTemplatePattern()); |
Douglas Gregor | 788cd06 | 2009-11-11 01:00:40 +0000 | [diff] [blame] | 1231 | break; |
Sean Hunt | c302113 | 2010-05-05 15:23:54 +0000 | [diff] [blame] | 1232 | |
John McCall | 833ca99 | 2009-10-29 08:12:44 +0000 | [diff] [blame] | 1233 | case TemplateArgument::Declaration: |
| 1234 | VisitDecl(Arg.getAsDecl()); |
| 1235 | break; |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 1236 | |
Eli Friedman | d7a6b16 | 2012-09-26 02:36:12 +0000 | [diff] [blame] | 1237 | case TemplateArgument::NullPtr: |
| 1238 | VisitType(Arg.getNullPtrType()); |
| 1239 | break; |
| 1240 | |
John McCall | 833ca99 | 2009-10-29 08:12:44 +0000 | [diff] [blame] | 1241 | case TemplateArgument::Integral: |
Benjamin Kramer | 8552437 | 2012-06-07 15:09:51 +0000 | [diff] [blame] | 1242 | Arg.getAsIntegral().Profile(ID); |
John McCall | 833ca99 | 2009-10-29 08:12:44 +0000 | [diff] [blame] | 1243 | VisitType(Arg.getIntegralType()); |
| 1244 | break; |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 1245 | |
John McCall | 833ca99 | 2009-10-29 08:12:44 +0000 | [diff] [blame] | 1246 | case TemplateArgument::Expression: |
| 1247 | Visit(Arg.getAsExpr()); |
| 1248 | break; |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 1249 | |
John McCall | 833ca99 | 2009-10-29 08:12:44 +0000 | [diff] [blame] | 1250 | case TemplateArgument::Pack: |
| 1251 | const TemplateArgument *Pack = Arg.pack_begin(); |
| 1252 | for (unsigned i = 0, e = Arg.pack_size(); i != e; ++i) |
| 1253 | VisitTemplateArgument(Pack[i]); |
| 1254 | break; |
Douglas Gregor | 41ef0c3 | 2009-07-28 00:33:38 +0000 | [diff] [blame] | 1255 | } |
| 1256 | } |
| 1257 | |
Jay Foad | 4ba2a17 | 2011-01-12 09:06:06 +0000 | [diff] [blame] | 1258 | void Stmt::Profile(llvm::FoldingSetNodeID &ID, const ASTContext &Context, |
Chandler Carruth | b113824 | 2011-06-16 06:47:06 +0000 | [diff] [blame] | 1259 | bool Canonical) const { |
Douglas Gregor | 41ef0c3 | 2009-07-28 00:33:38 +0000 | [diff] [blame] | 1260 | StmtProfiler Profiler(ID, Context, Canonical); |
| 1261 | Profiler.Visit(this); |
| 1262 | } |