blob: 5525018f7986e60f866ade1ed5202b5a1b80a5b8 [file] [log] [blame]
Douglas Gregor5c193b92009-07-28 00:33:38 +00001//===---- 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 Gregor32615a12009-07-28 16:39:25 +000011// representation that identifies a statement/expression.
Douglas Gregor5c193b92009-07-28 00:33:38 +000012//
13//===----------------------------------------------------------------------===//
14#include "clang/AST/ASTContext.h"
Douglas Gregora7095092009-07-28 14:44:31 +000015#include "clang/AST/DeclCXX.h"
16#include "clang/AST/DeclObjC.h"
Douglas Gregor5c193b92009-07-28 00:33:38 +000017#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 Gregor5c193b92009-07-28 00:33:38 +000023using namespace clang;
24
25namespace {
Chandler Carruth631abd92011-06-16 06:47:06 +000026 class StmtProfiler : public ConstStmtVisitor<StmtProfiler> {
Douglas Gregor5c193b92009-07-28 00:33:38 +000027 llvm::FoldingSetNodeID &ID;
Jay Foad39c79802011-01-12 09:06:06 +000028 const ASTContext &Context;
Douglas Gregor5c193b92009-07-28 00:33:38 +000029 bool Canonical;
Mike Stump11289f42009-09-09 15:08:12 +000030
Douglas Gregor5c193b92009-07-28 00:33:38 +000031 public:
Jay Foad39c79802011-01-12 09:06:06 +000032 StmtProfiler(llvm::FoldingSetNodeID &ID, const ASTContext &Context,
Mike Stump11289f42009-09-09 15:08:12 +000033 bool Canonical)
Douglas Gregor5c193b92009-07-28 00:33:38 +000034 : ID(ID), Context(Context), Canonical(Canonical) { }
Mike Stump11289f42009-09-09 15:08:12 +000035
Chandler Carruth631abd92011-06-16 06:47:06 +000036 void VisitStmt(const Stmt *S);
Mike Stump11289f42009-09-09 15:08:12 +000037
Chandler Carruth631abd92011-06-16 06:47:06 +000038#define STMT(Node, Base) void Visit##Node(const Node *S);
Alexis Hunt656bb312010-05-05 15:24:00 +000039#include "clang/AST/StmtNodes.inc"
Mike Stump11289f42009-09-09 15:08:12 +000040
Douglas Gregor5c193b92009-07-28 00:33:38 +000041 /// \brief Visit a declaration that is referenced within an expression
42 /// or statement.
Chandler Carruth631abd92011-06-16 06:47:06 +000043 void VisitDecl(const Decl *D);
Mike Stump11289f42009-09-09 15:08:12 +000044
45 /// \brief Visit a type that is referenced within an expression or
Douglas Gregor5c193b92009-07-28 00:33:38 +000046 /// statement.
47 void VisitType(QualType T);
Mike Stump11289f42009-09-09 15:08:12 +000048
Douglas Gregor5c193b92009-07-28 00:33:38 +000049 /// \brief Visit a name that occurs within an expression or statement.
50 void VisitName(DeclarationName Name);
Mike Stump11289f42009-09-09 15:08:12 +000051
Douglas Gregor5c193b92009-07-28 00:33:38 +000052 /// \brief Visit a nested-name-specifier that occurs within an expression
53 /// or statement.
54 void VisitNestedNameSpecifier(NestedNameSpecifier *NNS);
Mike Stump11289f42009-09-09 15:08:12 +000055
Douglas Gregor5c193b92009-07-28 00:33:38 +000056 /// \brief Visit a template name that occurs within an expression or
57 /// statement.
58 void VisitTemplateName(TemplateName Name);
Mike Stump11289f42009-09-09 15:08:12 +000059
Douglas Gregor5c193b92009-07-28 00:33:38 +000060 /// \brief Visit template arguments that occur within an expression or
61 /// statement.
Chandler Carruth631abd92011-06-16 06:47:06 +000062 void VisitTemplateArguments(const TemplateArgumentLoc *Args,
63 unsigned NumArgs);
John McCall0ad16662009-10-29 08:12:44 +000064
65 /// \brief Visit a single template argument.
66 void VisitTemplateArgument(const TemplateArgument &Arg);
Douglas Gregor5c193b92009-07-28 00:33:38 +000067 };
68}
69
Chandler Carruth631abd92011-06-16 06:47:06 +000070void StmtProfiler::VisitStmt(const Stmt *S) {
Douglas Gregor5c193b92009-07-28 00:33:38 +000071 ID.AddInteger(S->getStmtClass());
Peter Collingbournecdb9f302012-03-01 16:34:31 +000072 for (Stmt::const_child_range C = S->children(); C; ++C) {
73 if (*C)
74 Visit(*C);
75 else
76 ID.AddInteger(0);
77 }
Douglas Gregor5c193b92009-07-28 00:33:38 +000078}
79
Chandler Carruth631abd92011-06-16 06:47:06 +000080void StmtProfiler::VisitDeclStmt(const DeclStmt *S) {
Douglas Gregor44882592009-07-28 15:27:13 +000081 VisitStmt(S);
Chandler Carruth631abd92011-06-16 06:47:06 +000082 for (DeclStmt::const_decl_iterator D = S->decl_begin(), DEnd = S->decl_end();
Douglas Gregor44882592009-07-28 15:27:13 +000083 D != DEnd; ++D)
84 VisitDecl(*D);
85}
86
Chandler Carruth631abd92011-06-16 06:47:06 +000087void StmtProfiler::VisitNullStmt(const NullStmt *S) {
Douglas Gregor44882592009-07-28 15:27:13 +000088 VisitStmt(S);
89}
90
Chandler Carruth631abd92011-06-16 06:47:06 +000091void StmtProfiler::VisitCompoundStmt(const CompoundStmt *S) {
Douglas Gregor44882592009-07-28 15:27:13 +000092 VisitStmt(S);
93}
94
Chandler Carruth631abd92011-06-16 06:47:06 +000095void StmtProfiler::VisitSwitchCase(const SwitchCase *S) {
Douglas Gregor44882592009-07-28 15:27:13 +000096 VisitStmt(S);
97}
98
Chandler Carruth631abd92011-06-16 06:47:06 +000099void StmtProfiler::VisitCaseStmt(const CaseStmt *S) {
Douglas Gregor44882592009-07-28 15:27:13 +0000100 VisitStmt(S);
101}
102
Chandler Carruth631abd92011-06-16 06:47:06 +0000103void StmtProfiler::VisitDefaultStmt(const DefaultStmt *S) {
Douglas Gregor44882592009-07-28 15:27:13 +0000104 VisitStmt(S);
105}
106
Chandler Carruth631abd92011-06-16 06:47:06 +0000107void StmtProfiler::VisitLabelStmt(const LabelStmt *S) {
Douglas Gregor44882592009-07-28 15:27:13 +0000108 VisitStmt(S);
Chris Lattnerc8e630e2011-02-17 07:39:24 +0000109 VisitDecl(S->getDecl());
Douglas Gregor44882592009-07-28 15:27:13 +0000110}
111
Richard Smithc202b282012-04-14 00:33:13 +0000112void StmtProfiler::VisitAttributedStmt(const AttributedStmt *S) {
113 VisitStmt(S);
114 // TODO: maybe visit attributes?
115}
116
Chandler Carruth631abd92011-06-16 06:47:06 +0000117void StmtProfiler::VisitIfStmt(const IfStmt *S) {
Douglas Gregor44882592009-07-28 15:27:13 +0000118 VisitStmt(S);
Douglas Gregor7bab5ff2009-11-25 00:27:52 +0000119 VisitDecl(S->getConditionVariable());
Douglas Gregor44882592009-07-28 15:27:13 +0000120}
121
Chandler Carruth631abd92011-06-16 06:47:06 +0000122void StmtProfiler::VisitSwitchStmt(const SwitchStmt *S) {
Douglas Gregor00044172009-07-29 16:09:57 +0000123 VisitStmt(S);
Douglas Gregor7bab5ff2009-11-25 00:27:52 +0000124 VisitDecl(S->getConditionVariable());
Douglas Gregor00044172009-07-29 16:09:57 +0000125}
126
Chandler Carruth631abd92011-06-16 06:47:06 +0000127void StmtProfiler::VisitWhileStmt(const WhileStmt *S) {
Douglas Gregor44882592009-07-28 15:27:13 +0000128 VisitStmt(S);
Douglas Gregor7bab5ff2009-11-25 00:27:52 +0000129 VisitDecl(S->getConditionVariable());
Douglas Gregor44882592009-07-28 15:27:13 +0000130}
131
Chandler Carruth631abd92011-06-16 06:47:06 +0000132void StmtProfiler::VisitDoStmt(const DoStmt *S) {
Douglas Gregor44882592009-07-28 15:27:13 +0000133 VisitStmt(S);
134}
135
Chandler Carruth631abd92011-06-16 06:47:06 +0000136void StmtProfiler::VisitForStmt(const ForStmt *S) {
Douglas Gregor44882592009-07-28 15:27:13 +0000137 VisitStmt(S);
138}
139
Chandler Carruth631abd92011-06-16 06:47:06 +0000140void StmtProfiler::VisitGotoStmt(const GotoStmt *S) {
Douglas Gregor44882592009-07-28 15:27:13 +0000141 VisitStmt(S);
Chris Lattnerc8e630e2011-02-17 07:39:24 +0000142 VisitDecl(S->getLabel());
Douglas Gregor44882592009-07-28 15:27:13 +0000143}
144
Chandler Carruth631abd92011-06-16 06:47:06 +0000145void StmtProfiler::VisitIndirectGotoStmt(const IndirectGotoStmt *S) {
Douglas Gregor44882592009-07-28 15:27:13 +0000146 VisitStmt(S);
147}
148
Chandler Carruth631abd92011-06-16 06:47:06 +0000149void StmtProfiler::VisitContinueStmt(const ContinueStmt *S) {
Douglas Gregor44882592009-07-28 15:27:13 +0000150 VisitStmt(S);
151}
152
Chandler Carruth631abd92011-06-16 06:47:06 +0000153void StmtProfiler::VisitBreakStmt(const BreakStmt *S) {
Douglas Gregor44882592009-07-28 15:27:13 +0000154 VisitStmt(S);
155}
156
Chandler Carruth631abd92011-06-16 06:47:06 +0000157void StmtProfiler::VisitReturnStmt(const ReturnStmt *S) {
Douglas Gregor44882592009-07-28 15:27:13 +0000158 VisitStmt(S);
159}
160
Chad Rosierde70e0e2012-08-25 00:11:56 +0000161void StmtProfiler::VisitGCCAsmStmt(const GCCAsmStmt *S) {
Douglas Gregor44882592009-07-28 15:27:13 +0000162 VisitStmt(S);
163 ID.AddBoolean(S->isVolatile());
164 ID.AddBoolean(S->isSimple());
165 VisitStringLiteral(S->getAsmString());
166 ID.AddInteger(S->getNumOutputs());
167 for (unsigned I = 0, N = S->getNumOutputs(); I != N; ++I) {
168 ID.AddString(S->getOutputName(I));
169 VisitStringLiteral(S->getOutputConstraintLiteral(I));
170 }
171 ID.AddInteger(S->getNumInputs());
172 for (unsigned I = 0, N = S->getNumInputs(); I != N; ++I) {
173 ID.AddString(S->getInputName(I));
174 VisitStringLiteral(S->getInputConstraintLiteral(I));
175 }
176 ID.AddInteger(S->getNumClobbers());
177 for (unsigned I = 0, N = S->getNumClobbers(); I != N; ++I)
Chad Rosierd9fb09a2012-08-27 23:28:41 +0000178 VisitStringLiteral(S->getClobberStringLiteral(I));
Douglas Gregor44882592009-07-28 15:27:13 +0000179}
180
Chad Rosier32503022012-06-11 20:47:18 +0000181void StmtProfiler::VisitMSAsmStmt(const MSAsmStmt *S) {
182 // FIXME: Implement MS style inline asm statement profiler.
183 VisitStmt(S);
184}
185
Chandler Carruth631abd92011-06-16 06:47:06 +0000186void StmtProfiler::VisitCXXCatchStmt(const CXXCatchStmt *S) {
Douglas Gregor44882592009-07-28 15:27:13 +0000187 VisitStmt(S);
188 VisitType(S->getCaughtType());
189}
190
Chandler Carruth631abd92011-06-16 06:47:06 +0000191void StmtProfiler::VisitCXXTryStmt(const CXXTryStmt *S) {
Douglas Gregor44882592009-07-28 15:27:13 +0000192 VisitStmt(S);
193}
194
Chandler Carruth631abd92011-06-16 06:47:06 +0000195void StmtProfiler::VisitCXXForRangeStmt(const CXXForRangeStmt *S) {
Richard Smith02e85f32011-04-14 22:09:26 +0000196 VisitStmt(S);
197}
198
Douglas Gregordeb4a2be2011-10-25 01:33:02 +0000199void StmtProfiler::VisitMSDependentExistsStmt(const MSDependentExistsStmt *S) {
200 VisitStmt(S);
201 ID.AddBoolean(S->isIfExists());
202 VisitNestedNameSpecifier(S->getQualifierLoc().getNestedNameSpecifier());
203 VisitName(S->getNameInfo().getName());
204}
205
Chandler Carruth631abd92011-06-16 06:47:06 +0000206void StmtProfiler::VisitSEHTryStmt(const SEHTryStmt *S) {
John Wiegley1c0675e2011-04-28 01:08:34 +0000207 VisitStmt(S);
208}
209
Chandler Carruth631abd92011-06-16 06:47:06 +0000210void StmtProfiler::VisitSEHFinallyStmt(const SEHFinallyStmt *S) {
John Wiegley1c0675e2011-04-28 01:08:34 +0000211 VisitStmt(S);
212}
213
Chandler Carruth631abd92011-06-16 06:47:06 +0000214void StmtProfiler::VisitSEHExceptStmt(const SEHExceptStmt *S) {
John Wiegley1c0675e2011-04-28 01:08:34 +0000215 VisitStmt(S);
216}
217
Chandler Carruth631abd92011-06-16 06:47:06 +0000218void StmtProfiler::VisitObjCForCollectionStmt(const ObjCForCollectionStmt *S) {
Douglas Gregor44882592009-07-28 15:27:13 +0000219 VisitStmt(S);
220}
221
Chandler Carruth631abd92011-06-16 06:47:06 +0000222void StmtProfiler::VisitObjCAtCatchStmt(const ObjCAtCatchStmt *S) {
Douglas Gregor44882592009-07-28 15:27:13 +0000223 VisitStmt(S);
224 ID.AddBoolean(S->hasEllipsis());
225 if (S->getCatchParamDecl())
226 VisitType(S->getCatchParamDecl()->getType());
227}
228
Chandler Carruth631abd92011-06-16 06:47:06 +0000229void StmtProfiler::VisitObjCAtFinallyStmt(const ObjCAtFinallyStmt *S) {
Douglas Gregor44882592009-07-28 15:27:13 +0000230 VisitStmt(S);
231}
232
Chandler Carruth631abd92011-06-16 06:47:06 +0000233void StmtProfiler::VisitObjCAtTryStmt(const ObjCAtTryStmt *S) {
Douglas Gregor44882592009-07-28 15:27:13 +0000234 VisitStmt(S);
235}
236
Chandler Carruth631abd92011-06-16 06:47:06 +0000237void
238StmtProfiler::VisitObjCAtSynchronizedStmt(const ObjCAtSynchronizedStmt *S) {
Douglas Gregor44882592009-07-28 15:27:13 +0000239 VisitStmt(S);
240}
241
Chandler Carruth631abd92011-06-16 06:47:06 +0000242void StmtProfiler::VisitObjCAtThrowStmt(const ObjCAtThrowStmt *S) {
Douglas Gregor44882592009-07-28 15:27:13 +0000243 VisitStmt(S);
244}
245
Chandler Carruth631abd92011-06-16 06:47:06 +0000246void
247StmtProfiler::VisitObjCAutoreleasePoolStmt(const ObjCAutoreleasePoolStmt *S) {
John McCall31168b02011-06-15 23:02:42 +0000248 VisitStmt(S);
249}
250
Chandler Carruth631abd92011-06-16 06:47:06 +0000251void StmtProfiler::VisitExpr(const Expr *S) {
Douglas Gregor5c193b92009-07-28 00:33:38 +0000252 VisitStmt(S);
253}
254
Chandler Carruth631abd92011-06-16 06:47:06 +0000255void StmtProfiler::VisitDeclRefExpr(const DeclRefExpr *S) {
Douglas Gregor5c193b92009-07-28 00:33:38 +0000256 VisitExpr(S);
Douglas Gregorf5b160f2010-07-13 08:37:11 +0000257 if (!Canonical)
258 VisitNestedNameSpecifier(S->getQualifier());
Douglas Gregor5c193b92009-07-28 00:33:38 +0000259 VisitDecl(S->getDecl());
Douglas Gregorf5b160f2010-07-13 08:37:11 +0000260 if (!Canonical)
261 VisitTemplateArguments(S->getTemplateArgs(), S->getNumTemplateArgs());
Douglas Gregor5c193b92009-07-28 00:33:38 +0000262}
263
Chandler Carruth631abd92011-06-16 06:47:06 +0000264void StmtProfiler::VisitPredefinedExpr(const PredefinedExpr *S) {
Douglas Gregor5c193b92009-07-28 00:33:38 +0000265 VisitExpr(S);
266 ID.AddInteger(S->getIdentType());
267}
268
Chandler Carruth631abd92011-06-16 06:47:06 +0000269void StmtProfiler::VisitIntegerLiteral(const IntegerLiteral *S) {
Douglas Gregor5c193b92009-07-28 00:33:38 +0000270 VisitExpr(S);
271 S->getValue().Profile(ID);
272}
273
Chandler Carruth631abd92011-06-16 06:47:06 +0000274void StmtProfiler::VisitCharacterLiteral(const CharacterLiteral *S) {
Douglas Gregor5c193b92009-07-28 00:33:38 +0000275 VisitExpr(S);
Douglas Gregorfb65e592011-07-27 05:40:30 +0000276 ID.AddInteger(S->getKind());
Douglas Gregor5c193b92009-07-28 00:33:38 +0000277 ID.AddInteger(S->getValue());
278}
279
Chandler Carruth631abd92011-06-16 06:47:06 +0000280void StmtProfiler::VisitFloatingLiteral(const FloatingLiteral *S) {
Douglas Gregor5c193b92009-07-28 00:33:38 +0000281 VisitExpr(S);
282 S->getValue().Profile(ID);
283 ID.AddBoolean(S->isExact());
284}
285
Chandler Carruth631abd92011-06-16 06:47:06 +0000286void StmtProfiler::VisitImaginaryLiteral(const ImaginaryLiteral *S) {
Douglas Gregor5c193b92009-07-28 00:33:38 +0000287 VisitExpr(S);
288}
289
Chandler Carruth631abd92011-06-16 06:47:06 +0000290void StmtProfiler::VisitStringLiteral(const StringLiteral *S) {
Douglas Gregor5c193b92009-07-28 00:33:38 +0000291 VisitExpr(S);
Douglas Gregor9d0eb8f2011-11-02 17:26:05 +0000292 ID.AddString(S->getBytes());
Douglas Gregorfb65e592011-07-27 05:40:30 +0000293 ID.AddInteger(S->getKind());
Douglas Gregor5c193b92009-07-28 00:33:38 +0000294}
295
Chandler Carruth631abd92011-06-16 06:47:06 +0000296void StmtProfiler::VisitParenExpr(const ParenExpr *S) {
Douglas Gregor5c193b92009-07-28 00:33:38 +0000297 VisitExpr(S);
298}
299
Chandler Carruth631abd92011-06-16 06:47:06 +0000300void StmtProfiler::VisitParenListExpr(const ParenListExpr *S) {
Nate Begeman5ec4b312009-08-10 23:49:36 +0000301 VisitExpr(S);
302}
303
Chandler Carruth631abd92011-06-16 06:47:06 +0000304void StmtProfiler::VisitUnaryOperator(const UnaryOperator *S) {
Douglas Gregor5c193b92009-07-28 00:33:38 +0000305 VisitExpr(S);
306 ID.AddInteger(S->getOpcode());
307}
308
Chandler Carruth631abd92011-06-16 06:47:06 +0000309void StmtProfiler::VisitOffsetOfExpr(const OffsetOfExpr *S) {
Douglas Gregor882211c2010-04-28 22:16:22 +0000310 VisitType(S->getTypeSourceInfo()->getType());
311 unsigned n = S->getNumComponents();
312 for (unsigned i = 0; i < n; ++i) {
313 const OffsetOfExpr::OffsetOfNode& ON = S->getComponent(i);
314 ID.AddInteger(ON.getKind());
315 switch (ON.getKind()) {
316 case OffsetOfExpr::OffsetOfNode::Array:
317 // Expressions handled below.
318 break;
319
320 case OffsetOfExpr::OffsetOfNode::Field:
321 VisitDecl(ON.getField());
322 break;
323
324 case OffsetOfExpr::OffsetOfNode::Identifier:
325 ID.AddPointer(ON.getFieldName());
326 break;
Alexis Hunta8136cc2010-05-05 15:23:54 +0000327
Douglas Gregord1702062010-04-29 00:18:15 +0000328 case OffsetOfExpr::OffsetOfNode::Base:
329 // These nodes are implicit, and therefore don't need profiling.
330 break;
Douglas Gregor882211c2010-04-28 22:16:22 +0000331 }
332 }
Alexis Hunta8136cc2010-05-05 15:23:54 +0000333
Douglas Gregor882211c2010-04-28 22:16:22 +0000334 VisitExpr(S);
335}
336
Chandler Carruth631abd92011-06-16 06:47:06 +0000337void
338StmtProfiler::VisitUnaryExprOrTypeTraitExpr(const UnaryExprOrTypeTraitExpr *S) {
Douglas Gregor5c193b92009-07-28 00:33:38 +0000339 VisitExpr(S);
Peter Collingbournee190dee2011-03-11 19:24:49 +0000340 ID.AddInteger(S->getKind());
Douglas Gregor5c193b92009-07-28 00:33:38 +0000341 if (S->isArgumentType())
342 VisitType(S->getArgumentType());
343}
344
Chandler Carruth631abd92011-06-16 06:47:06 +0000345void StmtProfiler::VisitArraySubscriptExpr(const ArraySubscriptExpr *S) {
Douglas Gregor5c193b92009-07-28 00:33:38 +0000346 VisitExpr(S);
347}
348
Chandler Carruth631abd92011-06-16 06:47:06 +0000349void StmtProfiler::VisitCallExpr(const CallExpr *S) {
Douglas Gregor5c193b92009-07-28 00:33:38 +0000350 VisitExpr(S);
351}
352
Chandler Carruth631abd92011-06-16 06:47:06 +0000353void StmtProfiler::VisitMemberExpr(const MemberExpr *S) {
Douglas Gregor5c193b92009-07-28 00:33:38 +0000354 VisitExpr(S);
355 VisitDecl(S->getMemberDecl());
Douglas Gregorf5b160f2010-07-13 08:37:11 +0000356 if (!Canonical)
357 VisitNestedNameSpecifier(S->getQualifier());
Douglas Gregor5c193b92009-07-28 00:33:38 +0000358 ID.AddBoolean(S->isArrow());
359}
360
Chandler Carruth631abd92011-06-16 06:47:06 +0000361void StmtProfiler::VisitCompoundLiteralExpr(const CompoundLiteralExpr *S) {
Douglas Gregor5c193b92009-07-28 00:33:38 +0000362 VisitExpr(S);
363 ID.AddBoolean(S->isFileScope());
364}
365
Chandler Carruth631abd92011-06-16 06:47:06 +0000366void StmtProfiler::VisitCastExpr(const CastExpr *S) {
Douglas Gregor5c193b92009-07-28 00:33:38 +0000367 VisitExpr(S);
368}
369
Chandler Carruth631abd92011-06-16 06:47:06 +0000370void StmtProfiler::VisitImplicitCastExpr(const ImplicitCastExpr *S) {
Douglas Gregor5c193b92009-07-28 00:33:38 +0000371 VisitCastExpr(S);
John McCall2536c6d2010-08-25 10:28:54 +0000372 ID.AddInteger(S->getValueKind());
Douglas Gregor5c193b92009-07-28 00:33:38 +0000373}
374
Chandler Carruth631abd92011-06-16 06:47:06 +0000375void StmtProfiler::VisitExplicitCastExpr(const ExplicitCastExpr *S) {
Douglas Gregor5c193b92009-07-28 00:33:38 +0000376 VisitCastExpr(S);
377 VisitType(S->getTypeAsWritten());
378}
379
Chandler Carruth631abd92011-06-16 06:47:06 +0000380void StmtProfiler::VisitCStyleCastExpr(const CStyleCastExpr *S) {
Douglas Gregor5c193b92009-07-28 00:33:38 +0000381 VisitExplicitCastExpr(S);
382}
383
Chandler Carruth631abd92011-06-16 06:47:06 +0000384void StmtProfiler::VisitBinaryOperator(const BinaryOperator *S) {
Douglas Gregor5c193b92009-07-28 00:33:38 +0000385 VisitExpr(S);
386 ID.AddInteger(S->getOpcode());
387}
388
Chandler Carruth631abd92011-06-16 06:47:06 +0000389void
390StmtProfiler::VisitCompoundAssignOperator(const CompoundAssignOperator *S) {
Douglas Gregor5c193b92009-07-28 00:33:38 +0000391 VisitBinaryOperator(S);
392}
393
Chandler Carruth631abd92011-06-16 06:47:06 +0000394void StmtProfiler::VisitConditionalOperator(const ConditionalOperator *S) {
Douglas Gregor5c193b92009-07-28 00:33:38 +0000395 VisitExpr(S);
396}
397
Chandler Carruth631abd92011-06-16 06:47:06 +0000398void StmtProfiler::VisitBinaryConditionalOperator(
Chandler Carruthcf5f43c2011-06-21 23:26:32 +0000399 const BinaryConditionalOperator *S) {
John McCallc07a0c72011-02-17 10:25:35 +0000400 VisitExpr(S);
401}
402
Chandler Carruth631abd92011-06-16 06:47:06 +0000403void StmtProfiler::VisitAddrLabelExpr(const AddrLabelExpr *S) {
Douglas Gregor5c193b92009-07-28 00:33:38 +0000404 VisitExpr(S);
Chris Lattnerc8e630e2011-02-17 07:39:24 +0000405 VisitDecl(S->getLabel());
Douglas Gregor5c193b92009-07-28 00:33:38 +0000406}
407
Chandler Carruth631abd92011-06-16 06:47:06 +0000408void StmtProfiler::VisitStmtExpr(const StmtExpr *S) {
Douglas Gregor5c193b92009-07-28 00:33:38 +0000409 VisitExpr(S);
410}
411
Chandler Carruth631abd92011-06-16 06:47:06 +0000412void StmtProfiler::VisitShuffleVectorExpr(const ShuffleVectorExpr *S) {
Douglas Gregor5c193b92009-07-28 00:33:38 +0000413 VisitExpr(S);
414}
415
Chandler Carruth631abd92011-06-16 06:47:06 +0000416void StmtProfiler::VisitChooseExpr(const ChooseExpr *S) {
Douglas Gregor5c193b92009-07-28 00:33:38 +0000417 VisitExpr(S);
418}
419
Chandler Carruth631abd92011-06-16 06:47:06 +0000420void StmtProfiler::VisitGNUNullExpr(const GNUNullExpr *S) {
Douglas Gregor5c193b92009-07-28 00:33:38 +0000421 VisitExpr(S);
422}
423
Chandler Carruth631abd92011-06-16 06:47:06 +0000424void StmtProfiler::VisitVAArgExpr(const VAArgExpr *S) {
Douglas Gregor00044172009-07-29 16:09:57 +0000425 VisitExpr(S);
426}
427
Chandler Carruth631abd92011-06-16 06:47:06 +0000428void StmtProfiler::VisitInitListExpr(const InitListExpr *S) {
Douglas Gregor5c193b92009-07-28 00:33:38 +0000429 if (S->getSyntacticForm()) {
430 VisitInitListExpr(S->getSyntacticForm());
431 return;
432 }
Mike Stump11289f42009-09-09 15:08:12 +0000433
Douglas Gregor5c193b92009-07-28 00:33:38 +0000434 VisitExpr(S);
435}
436
Chandler Carruth631abd92011-06-16 06:47:06 +0000437void StmtProfiler::VisitDesignatedInitExpr(const DesignatedInitExpr *S) {
Douglas Gregor5c193b92009-07-28 00:33:38 +0000438 VisitExpr(S);
439 ID.AddBoolean(S->usesGNUSyntax());
Chandler Carruth631abd92011-06-16 06:47:06 +0000440 for (DesignatedInitExpr::const_designators_iterator D =
441 S->designators_begin(), DEnd = S->designators_end();
Douglas Gregor5c193b92009-07-28 00:33:38 +0000442 D != DEnd; ++D) {
443 if (D->isFieldDesignator()) {
444 ID.AddInteger(0);
445 VisitName(D->getFieldName());
446 continue;
447 }
Mike Stump11289f42009-09-09 15:08:12 +0000448
Douglas Gregor5c193b92009-07-28 00:33:38 +0000449 if (D->isArrayDesignator()) {
450 ID.AddInteger(1);
451 } else {
452 assert(D->isArrayRangeDesignator());
453 ID.AddInteger(2);
454 }
455 ID.AddInteger(D->getFirstExprIndex());
456 }
457}
458
Chandler Carruth631abd92011-06-16 06:47:06 +0000459void StmtProfiler::VisitImplicitValueInitExpr(const ImplicitValueInitExpr *S) {
Douglas Gregor5c193b92009-07-28 00:33:38 +0000460 VisitExpr(S);
461}
462
Chandler Carruth631abd92011-06-16 06:47:06 +0000463void StmtProfiler::VisitExtVectorElementExpr(const ExtVectorElementExpr *S) {
Douglas Gregor5c193b92009-07-28 00:33:38 +0000464 VisitExpr(S);
465 VisitName(&S->getAccessor());
466}
467
Chandler Carruth631abd92011-06-16 06:47:06 +0000468void StmtProfiler::VisitBlockExpr(const BlockExpr *S) {
Douglas Gregor5c193b92009-07-28 00:33:38 +0000469 VisitExpr(S);
470 VisitDecl(S->getBlockDecl());
471}
472
Chandler Carruth631abd92011-06-16 06:47:06 +0000473void StmtProfiler::VisitGenericSelectionExpr(const GenericSelectionExpr *S) {
Peter Collingbourne91147592011-04-15 00:35:48 +0000474 VisitExpr(S);
475 for (unsigned i = 0; i != S->getNumAssocs(); ++i) {
476 QualType T = S->getAssocType(i);
477 if (T.isNull())
478 ID.AddPointer(0);
479 else
480 VisitType(T);
481 VisitExpr(S->getAssocExpr(i));
482 }
483}
484
John McCallfe96e0b2011-11-06 09:01:30 +0000485void StmtProfiler::VisitPseudoObjectExpr(const PseudoObjectExpr *S) {
486 VisitExpr(S);
487 for (PseudoObjectExpr::const_semantics_iterator
488 i = S->semantics_begin(), e = S->semantics_end(); i != e; ++i)
489 // Normally, we would not profile the source expressions of OVEs.
490 if (const OpaqueValueExpr *OVE = dyn_cast<OpaqueValueExpr>(*i))
491 Visit(OVE->getSourceExpr());
492}
493
Eli Friedmandf14b3a2011-10-11 02:20:01 +0000494void StmtProfiler::VisitAtomicExpr(const AtomicExpr *S) {
495 VisitExpr(S);
Eli Friedman4b72fdd2011-10-14 20:59:01 +0000496 ID.AddInteger(S->getOp());
Eli Friedmandf14b3a2011-10-11 02:20:01 +0000497}
498
Chandler Carruth631abd92011-06-16 06:47:06 +0000499static Stmt::StmtClass DecodeOperatorCall(const CXXOperatorCallExpr *S,
John McCalle3027922010-08-25 11:45:40 +0000500 UnaryOperatorKind &UnaryOp,
501 BinaryOperatorKind &BinaryOp) {
Douglas Gregore9ceb312010-05-19 04:13:23 +0000502 switch (S->getOperator()) {
503 case OO_None:
504 case OO_New:
505 case OO_Delete:
506 case OO_Array_New:
507 case OO_Array_Delete:
508 case OO_Arrow:
509 case OO_Call:
510 case OO_Conditional:
511 case NUM_OVERLOADED_OPERATORS:
512 llvm_unreachable("Invalid operator call kind");
Douglas Gregore9ceb312010-05-19 04:13:23 +0000513
514 case OO_Plus:
515 if (S->getNumArgs() == 1) {
John McCalle3027922010-08-25 11:45:40 +0000516 UnaryOp = UO_Plus;
Douglas Gregore9ceb312010-05-19 04:13:23 +0000517 return Stmt::UnaryOperatorClass;
518 }
519
John McCalle3027922010-08-25 11:45:40 +0000520 BinaryOp = BO_Add;
Douglas Gregore9ceb312010-05-19 04:13:23 +0000521 return Stmt::BinaryOperatorClass;
522
523 case OO_Minus:
524 if (S->getNumArgs() == 1) {
John McCalle3027922010-08-25 11:45:40 +0000525 UnaryOp = UO_Minus;
Douglas Gregore9ceb312010-05-19 04:13:23 +0000526 return Stmt::UnaryOperatorClass;
527 }
528
John McCalle3027922010-08-25 11:45:40 +0000529 BinaryOp = BO_Sub;
Douglas Gregore9ceb312010-05-19 04:13:23 +0000530 return Stmt::BinaryOperatorClass;
531
532 case OO_Star:
533 if (S->getNumArgs() == 1) {
John McCalle3027922010-08-25 11:45:40 +0000534 UnaryOp = UO_Minus;
Douglas Gregore9ceb312010-05-19 04:13:23 +0000535 return Stmt::UnaryOperatorClass;
536 }
537
John McCalle3027922010-08-25 11:45:40 +0000538 BinaryOp = BO_Sub;
Douglas Gregore9ceb312010-05-19 04:13:23 +0000539 return Stmt::BinaryOperatorClass;
540
541 case OO_Slash:
John McCalle3027922010-08-25 11:45:40 +0000542 BinaryOp = BO_Div;
Douglas Gregore9ceb312010-05-19 04:13:23 +0000543 return Stmt::BinaryOperatorClass;
544
545 case OO_Percent:
John McCalle3027922010-08-25 11:45:40 +0000546 BinaryOp = BO_Rem;
Douglas Gregore9ceb312010-05-19 04:13:23 +0000547 return Stmt::BinaryOperatorClass;
548
549 case OO_Caret:
John McCalle3027922010-08-25 11:45:40 +0000550 BinaryOp = BO_Xor;
Douglas Gregore9ceb312010-05-19 04:13:23 +0000551 return Stmt::BinaryOperatorClass;
552
553 case OO_Amp:
554 if (S->getNumArgs() == 1) {
John McCalle3027922010-08-25 11:45:40 +0000555 UnaryOp = UO_AddrOf;
Douglas Gregore9ceb312010-05-19 04:13:23 +0000556 return Stmt::UnaryOperatorClass;
557 }
558
John McCalle3027922010-08-25 11:45:40 +0000559 BinaryOp = BO_And;
Douglas Gregore9ceb312010-05-19 04:13:23 +0000560 return Stmt::BinaryOperatorClass;
561
562 case OO_Pipe:
John McCalle3027922010-08-25 11:45:40 +0000563 BinaryOp = BO_Or;
Douglas Gregore9ceb312010-05-19 04:13:23 +0000564 return Stmt::BinaryOperatorClass;
565
566 case OO_Tilde:
John McCalle3027922010-08-25 11:45:40 +0000567 UnaryOp = UO_Not;
Douglas Gregore9ceb312010-05-19 04:13:23 +0000568 return Stmt::UnaryOperatorClass;
569
570 case OO_Exclaim:
John McCalle3027922010-08-25 11:45:40 +0000571 UnaryOp = UO_LNot;
Douglas Gregore9ceb312010-05-19 04:13:23 +0000572 return Stmt::UnaryOperatorClass;
573
574 case OO_Equal:
John McCalle3027922010-08-25 11:45:40 +0000575 BinaryOp = BO_Assign;
Douglas Gregore9ceb312010-05-19 04:13:23 +0000576 return Stmt::BinaryOperatorClass;
577
578 case OO_Less:
John McCalle3027922010-08-25 11:45:40 +0000579 BinaryOp = BO_LT;
Douglas Gregore9ceb312010-05-19 04:13:23 +0000580 return Stmt::BinaryOperatorClass;
581
582 case OO_Greater:
John McCalle3027922010-08-25 11:45:40 +0000583 BinaryOp = BO_GT;
Douglas Gregore9ceb312010-05-19 04:13:23 +0000584 return Stmt::BinaryOperatorClass;
585
586 case OO_PlusEqual:
John McCalle3027922010-08-25 11:45:40 +0000587 BinaryOp = BO_AddAssign;
Douglas Gregore9ceb312010-05-19 04:13:23 +0000588 return Stmt::CompoundAssignOperatorClass;
589
590 case OO_MinusEqual:
John McCalle3027922010-08-25 11:45:40 +0000591 BinaryOp = BO_SubAssign;
Douglas Gregore9ceb312010-05-19 04:13:23 +0000592 return Stmt::CompoundAssignOperatorClass;
593
594 case OO_StarEqual:
John McCalle3027922010-08-25 11:45:40 +0000595 BinaryOp = BO_MulAssign;
Douglas Gregore9ceb312010-05-19 04:13:23 +0000596 return Stmt::CompoundAssignOperatorClass;
597
598 case OO_SlashEqual:
John McCalle3027922010-08-25 11:45:40 +0000599 BinaryOp = BO_DivAssign;
Douglas Gregore9ceb312010-05-19 04:13:23 +0000600 return Stmt::CompoundAssignOperatorClass;
601
602 case OO_PercentEqual:
John McCalle3027922010-08-25 11:45:40 +0000603 BinaryOp = BO_RemAssign;
Douglas Gregore9ceb312010-05-19 04:13:23 +0000604 return Stmt::CompoundAssignOperatorClass;
605
606 case OO_CaretEqual:
John McCalle3027922010-08-25 11:45:40 +0000607 BinaryOp = BO_XorAssign;
Douglas Gregore9ceb312010-05-19 04:13:23 +0000608 return Stmt::CompoundAssignOperatorClass;
609
610 case OO_AmpEqual:
John McCalle3027922010-08-25 11:45:40 +0000611 BinaryOp = BO_AndAssign;
Douglas Gregore9ceb312010-05-19 04:13:23 +0000612 return Stmt::CompoundAssignOperatorClass;
613
614 case OO_PipeEqual:
John McCalle3027922010-08-25 11:45:40 +0000615 BinaryOp = BO_OrAssign;
Douglas Gregore9ceb312010-05-19 04:13:23 +0000616 return Stmt::CompoundAssignOperatorClass;
617
618 case OO_LessLess:
John McCalle3027922010-08-25 11:45:40 +0000619 BinaryOp = BO_Shl;
Douglas Gregore9ceb312010-05-19 04:13:23 +0000620 return Stmt::BinaryOperatorClass;
621
622 case OO_GreaterGreater:
John McCalle3027922010-08-25 11:45:40 +0000623 BinaryOp = BO_Shr;
Douglas Gregore9ceb312010-05-19 04:13:23 +0000624 return Stmt::BinaryOperatorClass;
625
626 case OO_LessLessEqual:
John McCalle3027922010-08-25 11:45:40 +0000627 BinaryOp = BO_ShlAssign;
Douglas Gregore9ceb312010-05-19 04:13:23 +0000628 return Stmt::CompoundAssignOperatorClass;
629
630 case OO_GreaterGreaterEqual:
John McCalle3027922010-08-25 11:45:40 +0000631 BinaryOp = BO_ShrAssign;
Douglas Gregore9ceb312010-05-19 04:13:23 +0000632 return Stmt::CompoundAssignOperatorClass;
633
634 case OO_EqualEqual:
John McCalle3027922010-08-25 11:45:40 +0000635 BinaryOp = BO_EQ;
Douglas Gregore9ceb312010-05-19 04:13:23 +0000636 return Stmt::BinaryOperatorClass;
637
638 case OO_ExclaimEqual:
John McCalle3027922010-08-25 11:45:40 +0000639 BinaryOp = BO_NE;
Douglas Gregore9ceb312010-05-19 04:13:23 +0000640 return Stmt::BinaryOperatorClass;
641
642 case OO_LessEqual:
John McCalle3027922010-08-25 11:45:40 +0000643 BinaryOp = BO_LE;
Douglas Gregore9ceb312010-05-19 04:13:23 +0000644 return Stmt::BinaryOperatorClass;
645
646 case OO_GreaterEqual:
John McCalle3027922010-08-25 11:45:40 +0000647 BinaryOp = BO_GE;
Douglas Gregore9ceb312010-05-19 04:13:23 +0000648 return Stmt::BinaryOperatorClass;
649
650 case OO_AmpAmp:
John McCalle3027922010-08-25 11:45:40 +0000651 BinaryOp = BO_LAnd;
Douglas Gregore9ceb312010-05-19 04:13:23 +0000652 return Stmt::BinaryOperatorClass;
653
654 case OO_PipePipe:
John McCalle3027922010-08-25 11:45:40 +0000655 BinaryOp = BO_LOr;
Douglas Gregore9ceb312010-05-19 04:13:23 +0000656 return Stmt::BinaryOperatorClass;
657
658 case OO_PlusPlus:
John McCalle3027922010-08-25 11:45:40 +0000659 UnaryOp = S->getNumArgs() == 1? UO_PreInc
660 : UO_PostInc;
Douglas Gregore9ceb312010-05-19 04:13:23 +0000661 return Stmt::UnaryOperatorClass;
662
663 case OO_MinusMinus:
John McCalle3027922010-08-25 11:45:40 +0000664 UnaryOp = S->getNumArgs() == 1? UO_PreDec
665 : UO_PostDec;
Douglas Gregore9ceb312010-05-19 04:13:23 +0000666 return Stmt::UnaryOperatorClass;
667
668 case OO_Comma:
John McCalle3027922010-08-25 11:45:40 +0000669 BinaryOp = BO_Comma;
Douglas Gregore9ceb312010-05-19 04:13:23 +0000670 return Stmt::BinaryOperatorClass;
671
672
673 case OO_ArrowStar:
John McCalle3027922010-08-25 11:45:40 +0000674 BinaryOp = BO_PtrMemI;
Douglas Gregore9ceb312010-05-19 04:13:23 +0000675 return Stmt::BinaryOperatorClass;
676
677 case OO_Subscript:
678 return Stmt::ArraySubscriptExprClass;
679 }
680
681 llvm_unreachable("Invalid overloaded operator expression");
682}
683
684
Chandler Carruth631abd92011-06-16 06:47:06 +0000685void StmtProfiler::VisitCXXOperatorCallExpr(const CXXOperatorCallExpr *S) {
Douglas Gregore9ceb312010-05-19 04:13:23 +0000686 if (S->isTypeDependent()) {
687 // Type-dependent operator calls are profiled like their underlying
688 // syntactic operator.
John McCalle3027922010-08-25 11:45:40 +0000689 UnaryOperatorKind UnaryOp = UO_Extension;
690 BinaryOperatorKind BinaryOp = BO_Comma;
Douglas Gregore9ceb312010-05-19 04:13:23 +0000691 Stmt::StmtClass SC = DecodeOperatorCall(S, UnaryOp, BinaryOp);
692
693 ID.AddInteger(SC);
694 for (unsigned I = 0, N = S->getNumArgs(); I != N; ++I)
695 Visit(S->getArg(I));
696 if (SC == Stmt::UnaryOperatorClass)
697 ID.AddInteger(UnaryOp);
698 else if (SC == Stmt::BinaryOperatorClass ||
699 SC == Stmt::CompoundAssignOperatorClass)
700 ID.AddInteger(BinaryOp);
701 else
702 assert(SC == Stmt::ArraySubscriptExprClass);
703
704 return;
705 }
706
Douglas Gregor5c193b92009-07-28 00:33:38 +0000707 VisitCallExpr(S);
708 ID.AddInteger(S->getOperator());
709}
710
Chandler Carruth631abd92011-06-16 06:47:06 +0000711void StmtProfiler::VisitCXXMemberCallExpr(const CXXMemberCallExpr *S) {
Douglas Gregor5c193b92009-07-28 00:33:38 +0000712 VisitCallExpr(S);
713}
714
Chandler Carruth631abd92011-06-16 06:47:06 +0000715void StmtProfiler::VisitCUDAKernelCallExpr(const CUDAKernelCallExpr *S) {
Peter Collingbourne41f85462011-02-09 21:07:24 +0000716 VisitCallExpr(S);
717}
718
Chandler Carruth631abd92011-06-16 06:47:06 +0000719void StmtProfiler::VisitAsTypeExpr(const AsTypeExpr *S) {
Tanya Lattner55808c12011-06-04 00:47:47 +0000720 VisitExpr(S);
721}
722
Chandler Carruth631abd92011-06-16 06:47:06 +0000723void StmtProfiler::VisitCXXNamedCastExpr(const CXXNamedCastExpr *S) {
Douglas Gregor5c193b92009-07-28 00:33:38 +0000724 VisitExplicitCastExpr(S);
725}
726
Chandler Carruth631abd92011-06-16 06:47:06 +0000727void StmtProfiler::VisitCXXStaticCastExpr(const CXXStaticCastExpr *S) {
Douglas Gregor5c193b92009-07-28 00:33:38 +0000728 VisitCXXNamedCastExpr(S);
729}
730
Chandler Carruth631abd92011-06-16 06:47:06 +0000731void StmtProfiler::VisitCXXDynamicCastExpr(const CXXDynamicCastExpr *S) {
Douglas Gregor5c193b92009-07-28 00:33:38 +0000732 VisitCXXNamedCastExpr(S);
733}
734
Chandler Carruth631abd92011-06-16 06:47:06 +0000735void
736StmtProfiler::VisitCXXReinterpretCastExpr(const CXXReinterpretCastExpr *S) {
Douglas Gregor5c193b92009-07-28 00:33:38 +0000737 VisitCXXNamedCastExpr(S);
738}
739
Chandler Carruth631abd92011-06-16 06:47:06 +0000740void StmtProfiler::VisitCXXConstCastExpr(const CXXConstCastExpr *S) {
Douglas Gregor5c193b92009-07-28 00:33:38 +0000741 VisitCXXNamedCastExpr(S);
742}
743
Richard Smithc67fdd42012-03-07 08:35:16 +0000744void StmtProfiler::VisitUserDefinedLiteral(const UserDefinedLiteral *S) {
745 VisitCallExpr(S);
746}
747
Chandler Carruth631abd92011-06-16 06:47:06 +0000748void StmtProfiler::VisitCXXBoolLiteralExpr(const CXXBoolLiteralExpr *S) {
Douglas Gregor5c193b92009-07-28 00:33:38 +0000749 VisitExpr(S);
750 ID.AddBoolean(S->getValue());
751}
752
Chandler Carruth631abd92011-06-16 06:47:06 +0000753void StmtProfiler::VisitCXXNullPtrLiteralExpr(const CXXNullPtrLiteralExpr *S) {
Douglas Gregor00044172009-07-29 16:09:57 +0000754 VisitExpr(S);
755}
756
Chandler Carruth631abd92011-06-16 06:47:06 +0000757void StmtProfiler::VisitCXXTypeidExpr(const CXXTypeidExpr *S) {
Douglas Gregor5c193b92009-07-28 00:33:38 +0000758 VisitExpr(S);
759 if (S->isTypeOperand())
760 VisitType(S->getTypeOperand());
761}
762
Chandler Carruth631abd92011-06-16 06:47:06 +0000763void StmtProfiler::VisitCXXUuidofExpr(const CXXUuidofExpr *S) {
Francois Pichet9f4f2072010-09-08 12:20:18 +0000764 VisitExpr(S);
765 if (S->isTypeOperand())
766 VisitType(S->getTypeOperand());
767}
768
John McCall5e77d762013-04-16 07:28:30 +0000769void StmtProfiler::VisitMSPropertyRefExpr(const MSPropertyRefExpr *S) {
770 VisitExpr(S);
771 VisitDecl(S->getPropertyDecl());
772}
773
Chandler Carruth631abd92011-06-16 06:47:06 +0000774void StmtProfiler::VisitCXXThisExpr(const CXXThisExpr *S) {
Douglas Gregor5c193b92009-07-28 00:33:38 +0000775 VisitExpr(S);
Douglas Gregor3024f072012-04-16 07:05:22 +0000776 ID.AddBoolean(S->isImplicit());
Douglas Gregor5c193b92009-07-28 00:33:38 +0000777}
778
Chandler Carruth631abd92011-06-16 06:47:06 +0000779void StmtProfiler::VisitCXXThrowExpr(const CXXThrowExpr *S) {
Douglas Gregor5c193b92009-07-28 00:33:38 +0000780 VisitExpr(S);
781}
782
Chandler Carruth631abd92011-06-16 06:47:06 +0000783void StmtProfiler::VisitCXXDefaultArgExpr(const CXXDefaultArgExpr *S) {
Douglas Gregor5c193b92009-07-28 00:33:38 +0000784 VisitExpr(S);
785 VisitDecl(S->getParam());
786}
787
Chandler Carruth631abd92011-06-16 06:47:06 +0000788void StmtProfiler::VisitCXXBindTemporaryExpr(const CXXBindTemporaryExpr *S) {
Douglas Gregor5c193b92009-07-28 00:33:38 +0000789 VisitExpr(S);
790 VisitDecl(
791 const_cast<CXXDestructorDecl *>(S->getTemporary()->getDestructor()));
792}
793
Chandler Carruth631abd92011-06-16 06:47:06 +0000794void StmtProfiler::VisitCXXConstructExpr(const CXXConstructExpr *S) {
Douglas Gregor5c193b92009-07-28 00:33:38 +0000795 VisitExpr(S);
796 VisitDecl(S->getConstructor());
797 ID.AddBoolean(S->isElidable());
798}
799
Chandler Carruth631abd92011-06-16 06:47:06 +0000800void StmtProfiler::VisitCXXFunctionalCastExpr(const CXXFunctionalCastExpr *S) {
Douglas Gregor5c193b92009-07-28 00:33:38 +0000801 VisitExplicitCastExpr(S);
802}
803
Chandler Carruth631abd92011-06-16 06:47:06 +0000804void
805StmtProfiler::VisitCXXTemporaryObjectExpr(const CXXTemporaryObjectExpr *S) {
Douglas Gregor5c193b92009-07-28 00:33:38 +0000806 VisitCXXConstructExpr(S);
807}
808
Chandler Carruth631abd92011-06-16 06:47:06 +0000809void
Douglas Gregore31e6062012-02-07 10:09:13 +0000810StmtProfiler::VisitLambdaExpr(const LambdaExpr *S) {
811 VisitExpr(S);
812 for (LambdaExpr::capture_iterator C = S->explicit_capture_begin(),
813 CEnd = S->explicit_capture_end();
814 C != CEnd; ++C) {
815 ID.AddInteger(C->getCaptureKind());
816 if (C->capturesVariable()) {
817 VisitDecl(C->getCapturedVar());
818 ID.AddBoolean(C->isPackExpansion());
819 }
820 }
821 // Note: If we actually needed to be able to match lambda
822 // expressions, we would have to consider parameters and return type
823 // here, among other things.
824 VisitStmt(S->getBody());
825}
826
827void
Chandler Carruth631abd92011-06-16 06:47:06 +0000828StmtProfiler::VisitCXXScalarValueInitExpr(const CXXScalarValueInitExpr *S) {
Douglas Gregor5c193b92009-07-28 00:33:38 +0000829 VisitExpr(S);
830}
831
Chandler Carruth631abd92011-06-16 06:47:06 +0000832void StmtProfiler::VisitCXXDeleteExpr(const CXXDeleteExpr *S) {
Douglas Gregor5c193b92009-07-28 00:33:38 +0000833 VisitExpr(S);
834 ID.AddBoolean(S->isGlobalDelete());
835 ID.AddBoolean(S->isArrayForm());
836 VisitDecl(S->getOperatorDelete());
837}
838
839
Chandler Carruth631abd92011-06-16 06:47:06 +0000840void StmtProfiler::VisitCXXNewExpr(const CXXNewExpr *S) {
Douglas Gregor5c193b92009-07-28 00:33:38 +0000841 VisitExpr(S);
842 VisitType(S->getAllocatedType());
843 VisitDecl(S->getOperatorNew());
844 VisitDecl(S->getOperatorDelete());
Douglas Gregor5c193b92009-07-28 00:33:38 +0000845 ID.AddBoolean(S->isArray());
846 ID.AddInteger(S->getNumPlacementArgs());
847 ID.AddBoolean(S->isGlobalNew());
848 ID.AddBoolean(S->isParenTypeId());
Sebastian Redl6047f072012-02-16 12:22:20 +0000849 ID.AddInteger(S->getInitializationStyle());
Douglas Gregor5c193b92009-07-28 00:33:38 +0000850}
851
Chandler Carruth631abd92011-06-16 06:47:06 +0000852void
853StmtProfiler::VisitCXXPseudoDestructorExpr(const CXXPseudoDestructorExpr *S) {
Douglas Gregorad8a3362009-09-04 17:36:40 +0000854 VisitExpr(S);
855 ID.AddBoolean(S->isArrow());
856 VisitNestedNameSpecifier(S->getQualifier());
857 VisitType(S->getDestroyedType());
858}
859
Chandler Carruth631abd92011-06-16 06:47:06 +0000860void StmtProfiler::VisitOverloadExpr(const OverloadExpr *S) {
Argyrios Kyrtzidisb482eb82010-08-15 20:53:20 +0000861 VisitExpr(S);
John McCalle66edc12009-11-24 19:00:30 +0000862 VisitNestedNameSpecifier(S->getQualifier());
Douglas Gregor5c193b92009-07-28 00:33:38 +0000863 VisitName(S->getName());
John McCalle66edc12009-11-24 19:00:30 +0000864 ID.AddBoolean(S->hasExplicitTemplateArgs());
865 if (S->hasExplicitTemplateArgs())
Argyrios Kyrtzidisf4505452010-08-15 01:15:38 +0000866 VisitTemplateArguments(S->getExplicitTemplateArgs().getTemplateArgs(),
867 S->getExplicitTemplateArgs().NumTemplateArgs);
868}
869
870void
Chandler Carruth631abd92011-06-16 06:47:06 +0000871StmtProfiler::VisitUnresolvedLookupExpr(const UnresolvedLookupExpr *S) {
Argyrios Kyrtzidisf4505452010-08-15 01:15:38 +0000872 VisitOverloadExpr(S);
Douglas Gregor5c193b92009-07-28 00:33:38 +0000873}
874
Chandler Carruth631abd92011-06-16 06:47:06 +0000875void StmtProfiler::VisitUnaryTypeTraitExpr(const UnaryTypeTraitExpr *S) {
Douglas Gregor5c193b92009-07-28 00:33:38 +0000876 VisitExpr(S);
877 ID.AddInteger(S->getTrait());
878 VisitType(S->getQueriedType());
879}
880
Chandler Carruth631abd92011-06-16 06:47:06 +0000881void StmtProfiler::VisitBinaryTypeTraitExpr(const BinaryTypeTraitExpr *S) {
Francois Pichet9dfa3ce2010-12-07 00:08:36 +0000882 VisitExpr(S);
883 ID.AddInteger(S->getTrait());
884 VisitType(S->getLhsType());
885 VisitType(S->getRhsType());
886}
887
Douglas Gregor29c42f22012-02-24 07:38:34 +0000888void StmtProfiler::VisitTypeTraitExpr(const TypeTraitExpr *S) {
889 VisitExpr(S);
890 ID.AddInteger(S->getTrait());
891 ID.AddInteger(S->getNumArgs());
892 for (unsigned I = 0, N = S->getNumArgs(); I != N; ++I)
893 VisitType(S->getArg(I)->getType());
894}
895
Chandler Carruth631abd92011-06-16 06:47:06 +0000896void StmtProfiler::VisitArrayTypeTraitExpr(const ArrayTypeTraitExpr *S) {
John Wiegley6242b6a2011-04-28 00:16:57 +0000897 VisitExpr(S);
898 ID.AddInteger(S->getTrait());
899 VisitType(S->getQueriedType());
900}
901
Chandler Carruth631abd92011-06-16 06:47:06 +0000902void StmtProfiler::VisitExpressionTraitExpr(const ExpressionTraitExpr *S) {
John Wiegleyf9f65842011-04-25 06:54:41 +0000903 VisitExpr(S);
904 ID.AddInteger(S->getTrait());
905 VisitExpr(S->getQueriedExpression());
906}
907
Chandler Carruth631abd92011-06-16 06:47:06 +0000908void StmtProfiler::VisitDependentScopeDeclRefExpr(
909 const DependentScopeDeclRefExpr *S) {
Douglas Gregor5c193b92009-07-28 00:33:38 +0000910 VisitExpr(S);
911 VisitName(S->getDeclName());
912 VisitNestedNameSpecifier(S->getQualifier());
John McCalle66edc12009-11-24 19:00:30 +0000913 ID.AddBoolean(S->hasExplicitTemplateArgs());
914 if (S->hasExplicitTemplateArgs())
915 VisitTemplateArguments(S->getTemplateArgs(), S->getNumTemplateArgs());
Douglas Gregor5c193b92009-07-28 00:33:38 +0000916}
917
Chandler Carruth631abd92011-06-16 06:47:06 +0000918void StmtProfiler::VisitExprWithCleanups(const ExprWithCleanups *S) {
Douglas Gregora7095092009-07-28 14:44:31 +0000919 VisitExpr(S);
Douglas Gregora7095092009-07-28 14:44:31 +0000920}
921
Chandler Carruth631abd92011-06-16 06:47:06 +0000922void StmtProfiler::VisitCXXUnresolvedConstructExpr(
923 const CXXUnresolvedConstructExpr *S) {
Douglas Gregora7095092009-07-28 14:44:31 +0000924 VisitExpr(S);
925 VisitType(S->getTypeAsWritten());
926}
927
Chandler Carruth631abd92011-06-16 06:47:06 +0000928void StmtProfiler::VisitCXXDependentScopeMemberExpr(
929 const CXXDependentScopeMemberExpr *S) {
John McCall2d74de92009-12-01 22:10:20 +0000930 ID.AddBoolean(S->isImplicitAccess());
931 if (!S->isImplicitAccess()) {
932 VisitExpr(S);
933 ID.AddBoolean(S->isArrow());
934 }
Douglas Gregorc26e0f62009-09-03 16:14:30 +0000935 VisitNestedNameSpecifier(S->getQualifier());
Douglas Gregora7095092009-07-28 14:44:31 +0000936 VisitName(S->getMember());
John McCall2d74de92009-12-01 22:10:20 +0000937 ID.AddBoolean(S->hasExplicitTemplateArgs());
938 if (S->hasExplicitTemplateArgs())
John McCall10eae182009-11-30 22:42:35 +0000939 VisitTemplateArguments(S->getTemplateArgs(), S->getNumTemplateArgs());
940}
941
Chandler Carruth631abd92011-06-16 06:47:06 +0000942void StmtProfiler::VisitUnresolvedMemberExpr(const UnresolvedMemberExpr *S) {
John McCall2d74de92009-12-01 22:10:20 +0000943 ID.AddBoolean(S->isImplicitAccess());
944 if (!S->isImplicitAccess()) {
945 VisitExpr(S);
946 ID.AddBoolean(S->isArrow());
947 }
John McCall10eae182009-11-30 22:42:35 +0000948 VisitNestedNameSpecifier(S->getQualifier());
949 VisitName(S->getMemberName());
950 ID.AddBoolean(S->hasExplicitTemplateArgs());
951 if (S->hasExplicitTemplateArgs())
952 VisitTemplateArguments(S->getTemplateArgs(), S->getNumTemplateArgs());
Douglas Gregora7095092009-07-28 14:44:31 +0000953}
954
Chandler Carruth631abd92011-06-16 06:47:06 +0000955void StmtProfiler::VisitCXXNoexceptExpr(const CXXNoexceptExpr *S) {
Sebastian Redl4202c0f2010-09-10 20:55:43 +0000956 VisitExpr(S);
957}
958
Chandler Carruth631abd92011-06-16 06:47:06 +0000959void StmtProfiler::VisitPackExpansionExpr(const PackExpansionExpr *S) {
Douglas Gregore8e9dd62011-01-03 17:17:50 +0000960 VisitExpr(S);
961}
962
Chandler Carruth631abd92011-06-16 06:47:06 +0000963void StmtProfiler::VisitSizeOfPackExpr(const SizeOfPackExpr *S) {
Douglas Gregor820ba7b2011-01-04 17:33:58 +0000964 VisitExpr(S);
965 VisitDecl(S->getPack());
966}
967
Douglas Gregorcdbc5392011-01-15 01:15:58 +0000968void StmtProfiler::VisitSubstNonTypeTemplateParmPackExpr(
Chandler Carruth631abd92011-06-16 06:47:06 +0000969 const SubstNonTypeTemplateParmPackExpr *S) {
Douglas Gregorcdbc5392011-01-15 01:15:58 +0000970 VisitExpr(S);
971 VisitDecl(S->getParameterPack());
972 VisitTemplateArgument(S->getArgumentPack());
973}
974
John McCall7c454bb2011-07-15 05:09:51 +0000975void StmtProfiler::VisitSubstNonTypeTemplateParmExpr(
976 const SubstNonTypeTemplateParmExpr *E) {
977 // Profile exactly as the replacement expression.
978 Visit(E->getReplacement());
979}
980
Richard Smithb15fe3a2012-09-12 00:56:43 +0000981void StmtProfiler::VisitFunctionParmPackExpr(const FunctionParmPackExpr *S) {
982 VisitExpr(S);
983 VisitDecl(S->getParameterPack());
984 ID.AddInteger(S->getNumExpansions());
985 for (FunctionParmPackExpr::iterator I = S->begin(), E = S->end(); I != E; ++I)
986 VisitDecl(*I);
987}
988
Douglas Gregorfe314812011-06-21 17:03:29 +0000989void StmtProfiler::VisitMaterializeTemporaryExpr(
990 const MaterializeTemporaryExpr *S) {
991 VisitExpr(S);
992}
993
Chandler Carruth631abd92011-06-16 06:47:06 +0000994void StmtProfiler::VisitOpaqueValueExpr(const OpaqueValueExpr *E) {
John McCall8d69a212010-11-15 23:31:06 +0000995 VisitExpr(E);
996}
997
Chandler Carruth631abd92011-06-16 06:47:06 +0000998void StmtProfiler::VisitObjCStringLiteral(const ObjCStringLiteral *S) {
Douglas Gregora7095092009-07-28 14:44:31 +0000999 VisitExpr(S);
1000}
1001
Patrick Beard0caa3942012-04-19 00:25:12 +00001002void StmtProfiler::VisitObjCBoxedExpr(const ObjCBoxedExpr *E) {
Ted Kremeneke65b0862012-03-06 20:05:56 +00001003 VisitExpr(E);
1004}
1005
1006void StmtProfiler::VisitObjCArrayLiteral(const ObjCArrayLiteral *E) {
1007 VisitExpr(E);
1008}
1009
1010void StmtProfiler::VisitObjCDictionaryLiteral(const ObjCDictionaryLiteral *E) {
1011 VisitExpr(E);
1012}
1013
Chandler Carruth631abd92011-06-16 06:47:06 +00001014void StmtProfiler::VisitObjCEncodeExpr(const ObjCEncodeExpr *S) {
Douglas Gregora7095092009-07-28 14:44:31 +00001015 VisitExpr(S);
1016 VisitType(S->getEncodedType());
1017}
1018
Chandler Carruth631abd92011-06-16 06:47:06 +00001019void StmtProfiler::VisitObjCSelectorExpr(const ObjCSelectorExpr *S) {
Douglas Gregora7095092009-07-28 14:44:31 +00001020 VisitExpr(S);
1021 VisitName(S->getSelector());
1022}
1023
Chandler Carruth631abd92011-06-16 06:47:06 +00001024void StmtProfiler::VisitObjCProtocolExpr(const ObjCProtocolExpr *S) {
Douglas Gregora7095092009-07-28 14:44:31 +00001025 VisitExpr(S);
1026 VisitDecl(S->getProtocol());
1027}
1028
Chandler Carruth631abd92011-06-16 06:47:06 +00001029void StmtProfiler::VisitObjCIvarRefExpr(const ObjCIvarRefExpr *S) {
Douglas Gregora7095092009-07-28 14:44:31 +00001030 VisitExpr(S);
1031 VisitDecl(S->getDecl());
1032 ID.AddBoolean(S->isArrow());
1033 ID.AddBoolean(S->isFreeIvar());
1034}
1035
Chandler Carruth631abd92011-06-16 06:47:06 +00001036void StmtProfiler::VisitObjCPropertyRefExpr(const ObjCPropertyRefExpr *S) {
Douglas Gregora7095092009-07-28 14:44:31 +00001037 VisitExpr(S);
John McCallb7bd14f2010-12-02 01:19:52 +00001038 if (S->isImplicitProperty()) {
1039 VisitDecl(S->getImplicitPropertyGetter());
1040 VisitDecl(S->getImplicitPropertySetter());
1041 } else {
1042 VisitDecl(S->getExplicitProperty());
Fariborz Jahanian681c0752010-10-14 16:04:05 +00001043 }
Fariborz Jahanian681c0752010-10-14 16:04:05 +00001044 if (S->isSuperReceiver()) {
1045 ID.AddBoolean(S->isSuperReceiver());
John McCallb7bd14f2010-12-02 01:19:52 +00001046 VisitType(S->getSuperReceiverType());
Fariborz Jahanian681c0752010-10-14 16:04:05 +00001047 }
Douglas Gregora7095092009-07-28 14:44:31 +00001048}
1049
Ted Kremeneke65b0862012-03-06 20:05:56 +00001050void StmtProfiler::VisitObjCSubscriptRefExpr(const ObjCSubscriptRefExpr *S) {
1051 VisitExpr(S);
1052 VisitDecl(S->getAtIndexMethodDecl());
1053 VisitDecl(S->setAtIndexMethodDecl());
1054}
1055
Chandler Carruth631abd92011-06-16 06:47:06 +00001056void StmtProfiler::VisitObjCMessageExpr(const ObjCMessageExpr *S) {
Douglas Gregora7095092009-07-28 14:44:31 +00001057 VisitExpr(S);
1058 VisitName(S->getSelector());
1059 VisitDecl(S->getMethodDecl());
1060}
1061
Chandler Carruth631abd92011-06-16 06:47:06 +00001062void StmtProfiler::VisitObjCIsaExpr(const ObjCIsaExpr *S) {
Douglas Gregora7095092009-07-28 14:44:31 +00001063 VisitExpr(S);
1064 ID.AddBoolean(S->isArrow());
1065}
1066
Ted Kremeneke65b0862012-03-06 20:05:56 +00001067void StmtProfiler::VisitObjCBoolLiteralExpr(const ObjCBoolLiteralExpr *S) {
1068 VisitExpr(S);
1069 ID.AddBoolean(S->getValue());
1070}
1071
Chandler Carruth631abd92011-06-16 06:47:06 +00001072void StmtProfiler::VisitObjCIndirectCopyRestoreExpr(
1073 const ObjCIndirectCopyRestoreExpr *S) {
John McCall31168b02011-06-15 23:02:42 +00001074 VisitExpr(S);
1075 ID.AddBoolean(S->shouldCopy());
1076}
1077
Chandler Carruth631abd92011-06-16 06:47:06 +00001078void StmtProfiler::VisitObjCBridgedCastExpr(const ObjCBridgedCastExpr *S) {
John McCall31168b02011-06-15 23:02:42 +00001079 VisitExplicitCastExpr(S);
1080 ID.AddBoolean(S->getBridgeKind());
1081}
1082
Chandler Carruth631abd92011-06-16 06:47:06 +00001083void StmtProfiler::VisitDecl(const Decl *D) {
Douglas Gregor70317122009-07-31 15:45:02 +00001084 ID.AddInteger(D? D->getKind() : 0);
Mike Stump11289f42009-09-09 15:08:12 +00001085
Douglas Gregora5dd9f82009-07-30 23:18:24 +00001086 if (Canonical && D) {
Chandler Carruth631abd92011-06-16 06:47:06 +00001087 if (const NonTypeTemplateParmDecl *NTTP =
1088 dyn_cast<NonTypeTemplateParmDecl>(D)) {
Douglas Gregord9aedfa2009-07-28 15:32:17 +00001089 ID.AddInteger(NTTP->getDepth());
1090 ID.AddInteger(NTTP->getIndex());
Douglas Gregorf5500772011-01-05 15:48:55 +00001091 ID.AddBoolean(NTTP->isParameterPack());
Douglas Gregor00044172009-07-29 16:09:57 +00001092 VisitType(NTTP->getType());
Douglas Gregor5c193b92009-07-28 00:33:38 +00001093 return;
1094 }
Mike Stump11289f42009-09-09 15:08:12 +00001095
Chandler Carruth631abd92011-06-16 06:47:06 +00001096 if (const ParmVarDecl *Parm = dyn_cast<ParmVarDecl>(D)) {
John McCall8fb0d9d2011-05-01 22:35:37 +00001097 // The Itanium C++ ABI uses the type, scope depth, and scope
1098 // index of a parameter when mangling expressions that involve
1099 // function parameters, so we will use the parameter's type for
1100 // establishing function parameter identity. That way, our
1101 // definition of "equivalent" (per C++ [temp.over.link]) is at
1102 // least as strong as the definition of "equivalent" used for
1103 // name mangling.
Douglas Gregor70317122009-07-31 15:45:02 +00001104 VisitType(Parm->getType());
John McCall8fb0d9d2011-05-01 22:35:37 +00001105 ID.AddInteger(Parm->getFunctionScopeDepth());
1106 ID.AddInteger(Parm->getFunctionScopeIndex());
Douglas Gregor70317122009-07-31 15:45:02 +00001107 return;
1108 }
Mike Stump11289f42009-09-09 15:08:12 +00001109
Richard Smithd9a1cd82012-04-02 18:53:24 +00001110 if (const TemplateTypeParmDecl *TTP =
1111 dyn_cast<TemplateTypeParmDecl>(D)) {
1112 ID.AddInteger(TTP->getDepth());
1113 ID.AddInteger(TTP->getIndex());
1114 ID.AddBoolean(TTP->isParameterPack());
1115 return;
1116 }
1117
Chandler Carruth631abd92011-06-16 06:47:06 +00001118 if (const TemplateTemplateParmDecl *TTP =
1119 dyn_cast<TemplateTemplateParmDecl>(D)) {
Douglas Gregorc97f09f2009-07-31 15:46:56 +00001120 ID.AddInteger(TTP->getDepth());
1121 ID.AddInteger(TTP->getIndex());
Douglas Gregorf5500772011-01-05 15:48:55 +00001122 ID.AddBoolean(TTP->isParameterPack());
Douglas Gregorc97f09f2009-07-31 15:46:56 +00001123 return;
1124 }
Douglas Gregor5c193b92009-07-28 00:33:38 +00001125 }
Mike Stump11289f42009-09-09 15:08:12 +00001126
Douglas Gregord9aedfa2009-07-28 15:32:17 +00001127 ID.AddPointer(D? D->getCanonicalDecl() : 0);
1128}
1129
1130void StmtProfiler::VisitType(QualType T) {
1131 if (Canonical)
1132 T = Context.getCanonicalType(T);
Mike Stump11289f42009-09-09 15:08:12 +00001133
Douglas Gregor5c193b92009-07-28 00:33:38 +00001134 ID.AddPointer(T.getAsOpaquePtr());
1135}
1136
1137void StmtProfiler::VisitName(DeclarationName Name) {
1138 ID.AddPointer(Name.getAsOpaquePtr());
1139}
1140
1141void StmtProfiler::VisitNestedNameSpecifier(NestedNameSpecifier *NNS) {
1142 if (Canonical)
1143 NNS = Context.getCanonicalNestedNameSpecifier(NNS);
1144 ID.AddPointer(NNS);
1145}
1146
1147void StmtProfiler::VisitTemplateName(TemplateName Name) {
1148 if (Canonical)
1149 Name = Context.getCanonicalTemplateName(Name);
Mike Stump11289f42009-09-09 15:08:12 +00001150
Douglas Gregor5c193b92009-07-28 00:33:38 +00001151 Name.Profile(ID);
1152}
1153
John McCall0ad16662009-10-29 08:12:44 +00001154void StmtProfiler::VisitTemplateArguments(const TemplateArgumentLoc *Args,
Douglas Gregor5c193b92009-07-28 00:33:38 +00001155 unsigned NumArgs) {
1156 ID.AddInteger(NumArgs);
John McCall0ad16662009-10-29 08:12:44 +00001157 for (unsigned I = 0; I != NumArgs; ++I)
1158 VisitTemplateArgument(Args[I].getArgument());
1159}
Mike Stump11289f42009-09-09 15:08:12 +00001160
John McCall0ad16662009-10-29 08:12:44 +00001161void StmtProfiler::VisitTemplateArgument(const TemplateArgument &Arg) {
1162 // Mostly repetitive with TemplateArgument::Profile!
1163 ID.AddInteger(Arg.getKind());
1164 switch (Arg.getKind()) {
1165 case TemplateArgument::Null:
1166 break;
Mike Stump11289f42009-09-09 15:08:12 +00001167
John McCall0ad16662009-10-29 08:12:44 +00001168 case TemplateArgument::Type:
1169 VisitType(Arg.getAsType());
1170 break;
Mike Stump11289f42009-09-09 15:08:12 +00001171
Douglas Gregor9167f8b2009-11-11 01:00:40 +00001172 case TemplateArgument::Template:
Douglas Gregore4ff4b52011-01-05 18:58:31 +00001173 case TemplateArgument::TemplateExpansion:
1174 VisitTemplateName(Arg.getAsTemplateOrTemplatePattern());
Douglas Gregor9167f8b2009-11-11 01:00:40 +00001175 break;
Alexis Hunta8136cc2010-05-05 15:23:54 +00001176
John McCall0ad16662009-10-29 08:12:44 +00001177 case TemplateArgument::Declaration:
1178 VisitDecl(Arg.getAsDecl());
1179 break;
Mike Stump11289f42009-09-09 15:08:12 +00001180
Eli Friedmanb826a002012-09-26 02:36:12 +00001181 case TemplateArgument::NullPtr:
1182 VisitType(Arg.getNullPtrType());
1183 break;
1184
John McCall0ad16662009-10-29 08:12:44 +00001185 case TemplateArgument::Integral:
Benjamin Kramer6003ad52012-06-07 15:09:51 +00001186 Arg.getAsIntegral().Profile(ID);
John McCall0ad16662009-10-29 08:12:44 +00001187 VisitType(Arg.getIntegralType());
1188 break;
Mike Stump11289f42009-09-09 15:08:12 +00001189
John McCall0ad16662009-10-29 08:12:44 +00001190 case TemplateArgument::Expression:
1191 Visit(Arg.getAsExpr());
1192 break;
Mike Stump11289f42009-09-09 15:08:12 +00001193
John McCall0ad16662009-10-29 08:12:44 +00001194 case TemplateArgument::Pack:
1195 const TemplateArgument *Pack = Arg.pack_begin();
1196 for (unsigned i = 0, e = Arg.pack_size(); i != e; ++i)
1197 VisitTemplateArgument(Pack[i]);
1198 break;
Douglas Gregor5c193b92009-07-28 00:33:38 +00001199 }
1200}
1201
Jay Foad39c79802011-01-12 09:06:06 +00001202void Stmt::Profile(llvm::FoldingSetNodeID &ID, const ASTContext &Context,
Chandler Carruth631abd92011-06-16 06:47:06 +00001203 bool Canonical) const {
Douglas Gregor5c193b92009-07-28 00:33:38 +00001204 StmtProfiler Profiler(ID, Context, Canonical);
1205 Profiler.Visit(this);
1206}