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