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