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