blob: db27f821f5b23815654debc0ff3514f53667578c [file] [log] [blame]
Douglas Gregor41ef0c32009-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 Gregor00aa3a62009-07-28 16:39:25 +000011// representation that identifies a statement/expression.
Douglas Gregor41ef0c32009-07-28 00:33:38 +000012//
13//===----------------------------------------------------------------------===//
14#include "clang/AST/ASTContext.h"
Douglas Gregor071f4eb2009-07-28 14:44:31 +000015#include "clang/AST/DeclCXX.h"
16#include "clang/AST/DeclObjC.h"
Douglas Gregor41ef0c32009-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 Gregor41ef0c32009-07-28 00:33:38 +000023using namespace clang;
24
25namespace {
Chandler Carruthb1138242011-06-16 06:47:06 +000026 class StmtProfiler : public ConstStmtVisitor<StmtProfiler> {
Douglas Gregor41ef0c32009-07-28 00:33:38 +000027 llvm::FoldingSetNodeID &ID;
Jay Foad4ba2a172011-01-12 09:06:06 +000028 const ASTContext &Context;
Douglas Gregor41ef0c32009-07-28 00:33:38 +000029 bool Canonical;
Mike Stump1eb44332009-09-09 15:08:12 +000030
Douglas Gregor41ef0c32009-07-28 00:33:38 +000031 public:
Jay Foad4ba2a172011-01-12 09:06:06 +000032 StmtProfiler(llvm::FoldingSetNodeID &ID, const ASTContext &Context,
Mike Stump1eb44332009-09-09 15:08:12 +000033 bool Canonical)
Douglas Gregor41ef0c32009-07-28 00:33:38 +000034 : ID(ID), Context(Context), Canonical(Canonical) { }
Mike Stump1eb44332009-09-09 15:08:12 +000035
Chandler Carruthb1138242011-06-16 06:47:06 +000036 void VisitStmt(const Stmt *S);
Mike Stump1eb44332009-09-09 15:08:12 +000037
Chandler Carruthb1138242011-06-16 06:47:06 +000038#define STMT(Node, Base) void Visit##Node(const Node *S);
Sean Hunt4bfe1962010-05-05 15:24:00 +000039#include "clang/AST/StmtNodes.inc"
Mike Stump1eb44332009-09-09 15:08:12 +000040
Douglas Gregor41ef0c32009-07-28 00:33:38 +000041 /// \brief Visit a declaration that is referenced within an expression
42 /// or statement.
Chandler Carruthb1138242011-06-16 06:47:06 +000043 void VisitDecl(const Decl *D);
Mike Stump1eb44332009-09-09 15:08:12 +000044
45 /// \brief Visit a type that is referenced within an expression or
Douglas Gregor41ef0c32009-07-28 00:33:38 +000046 /// statement.
47 void VisitType(QualType T);
Mike Stump1eb44332009-09-09 15:08:12 +000048
Douglas Gregor41ef0c32009-07-28 00:33:38 +000049 /// \brief Visit a name that occurs within an expression or statement.
50 void VisitName(DeclarationName Name);
Mike Stump1eb44332009-09-09 15:08:12 +000051
Douglas Gregor41ef0c32009-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 Stump1eb44332009-09-09 15:08:12 +000055
Douglas Gregor41ef0c32009-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 Stump1eb44332009-09-09 15:08:12 +000059
Douglas Gregor41ef0c32009-07-28 00:33:38 +000060 /// \brief Visit template arguments that occur within an expression or
61 /// statement.
Chandler Carruthb1138242011-06-16 06:47:06 +000062 void VisitTemplateArguments(const TemplateArgumentLoc *Args,
63 unsigned NumArgs);
John McCall833ca992009-10-29 08:12:44 +000064
65 /// \brief Visit a single template argument.
66 void VisitTemplateArgument(const TemplateArgument &Arg);
Douglas Gregor41ef0c32009-07-28 00:33:38 +000067 };
68}
69
Chandler Carruthb1138242011-06-16 06:47:06 +000070void StmtProfiler::VisitStmt(const Stmt *S) {
Douglas Gregor41ef0c32009-07-28 00:33:38 +000071 ID.AddInteger(S->getStmtClass());
Peter Collingbournedca17612012-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 Gregor41ef0c32009-07-28 00:33:38 +000078}
79
Chandler Carruthb1138242011-06-16 06:47:06 +000080void StmtProfiler::VisitDeclStmt(const DeclStmt *S) {
Douglas Gregor3fe81fc2009-07-28 15:27:13 +000081 VisitStmt(S);
Chandler Carruthb1138242011-06-16 06:47:06 +000082 for (DeclStmt::const_decl_iterator D = S->decl_begin(), DEnd = S->decl_end();
Douglas Gregor3fe81fc2009-07-28 15:27:13 +000083 D != DEnd; ++D)
84 VisitDecl(*D);
85}
86
Chandler Carruthb1138242011-06-16 06:47:06 +000087void StmtProfiler::VisitNullStmt(const NullStmt *S) {
Douglas Gregor3fe81fc2009-07-28 15:27:13 +000088 VisitStmt(S);
89}
90
Chandler Carruthb1138242011-06-16 06:47:06 +000091void StmtProfiler::VisitCompoundStmt(const CompoundStmt *S) {
Douglas Gregor3fe81fc2009-07-28 15:27:13 +000092 VisitStmt(S);
93}
94
Chandler Carruthb1138242011-06-16 06:47:06 +000095void StmtProfiler::VisitSwitchCase(const SwitchCase *S) {
Douglas Gregor3fe81fc2009-07-28 15:27:13 +000096 VisitStmt(S);
97}
98
Chandler Carruthb1138242011-06-16 06:47:06 +000099void StmtProfiler::VisitCaseStmt(const CaseStmt *S) {
Douglas Gregor3fe81fc2009-07-28 15:27:13 +0000100 VisitStmt(S);
101}
102
Chandler Carruthb1138242011-06-16 06:47:06 +0000103void StmtProfiler::VisitDefaultStmt(const DefaultStmt *S) {
Douglas Gregor3fe81fc2009-07-28 15:27:13 +0000104 VisitStmt(S);
105}
106
Chandler Carruthb1138242011-06-16 06:47:06 +0000107void StmtProfiler::VisitLabelStmt(const LabelStmt *S) {
Douglas Gregor3fe81fc2009-07-28 15:27:13 +0000108 VisitStmt(S);
Chris Lattnerad8dcf42011-02-17 07:39:24 +0000109 VisitDecl(S->getDecl());
Douglas Gregor3fe81fc2009-07-28 15:27:13 +0000110}
111
Chandler Carruthb1138242011-06-16 06:47:06 +0000112void StmtProfiler::VisitIfStmt(const IfStmt *S) {
Douglas Gregor3fe81fc2009-07-28 15:27:13 +0000113 VisitStmt(S);
Douglas Gregor99e9b4d2009-11-25 00:27:52 +0000114 VisitDecl(S->getConditionVariable());
Douglas Gregor3fe81fc2009-07-28 15:27:13 +0000115}
116
Chandler Carruthb1138242011-06-16 06:47:06 +0000117void StmtProfiler::VisitSwitchStmt(const SwitchStmt *S) {
Douglas Gregor828e2262009-07-29 16:09:57 +0000118 VisitStmt(S);
Douglas Gregor99e9b4d2009-11-25 00:27:52 +0000119 VisitDecl(S->getConditionVariable());
Douglas Gregor828e2262009-07-29 16:09:57 +0000120}
121
Chandler Carruthb1138242011-06-16 06:47:06 +0000122void StmtProfiler::VisitWhileStmt(const WhileStmt *S) {
Douglas Gregor3fe81fc2009-07-28 15:27:13 +0000123 VisitStmt(S);
Douglas Gregor99e9b4d2009-11-25 00:27:52 +0000124 VisitDecl(S->getConditionVariable());
Douglas Gregor3fe81fc2009-07-28 15:27:13 +0000125}
126
Chandler Carruthb1138242011-06-16 06:47:06 +0000127void StmtProfiler::VisitDoStmt(const DoStmt *S) {
Douglas Gregor3fe81fc2009-07-28 15:27:13 +0000128 VisitStmt(S);
129}
130
Chandler Carruthb1138242011-06-16 06:47:06 +0000131void StmtProfiler::VisitForStmt(const ForStmt *S) {
Douglas Gregor3fe81fc2009-07-28 15:27:13 +0000132 VisitStmt(S);
133}
134
Chandler Carruthb1138242011-06-16 06:47:06 +0000135void StmtProfiler::VisitGotoStmt(const GotoStmt *S) {
Douglas Gregor3fe81fc2009-07-28 15:27:13 +0000136 VisitStmt(S);
Chris Lattnerad8dcf42011-02-17 07:39:24 +0000137 VisitDecl(S->getLabel());
Douglas Gregor3fe81fc2009-07-28 15:27:13 +0000138}
139
Chandler Carruthb1138242011-06-16 06:47:06 +0000140void StmtProfiler::VisitIndirectGotoStmt(const IndirectGotoStmt *S) {
Douglas Gregor3fe81fc2009-07-28 15:27:13 +0000141 VisitStmt(S);
142}
143
Chandler Carruthb1138242011-06-16 06:47:06 +0000144void StmtProfiler::VisitContinueStmt(const ContinueStmt *S) {
Douglas Gregor3fe81fc2009-07-28 15:27:13 +0000145 VisitStmt(S);
146}
147
Chandler Carruthb1138242011-06-16 06:47:06 +0000148void StmtProfiler::VisitBreakStmt(const BreakStmt *S) {
Douglas Gregor3fe81fc2009-07-28 15:27:13 +0000149 VisitStmt(S);
150}
151
Chandler Carruthb1138242011-06-16 06:47:06 +0000152void StmtProfiler::VisitReturnStmt(const ReturnStmt *S) {
Douglas Gregor3fe81fc2009-07-28 15:27:13 +0000153 VisitStmt(S);
154}
155
Chandler Carruthb1138242011-06-16 06:47:06 +0000156void StmtProfiler::VisitAsmStmt(const AsmStmt *S) {
Douglas Gregor3fe81fc2009-07-28 15:27:13 +0000157 VisitStmt(S);
158 ID.AddBoolean(S->isVolatile());
159 ID.AddBoolean(S->isSimple());
160 VisitStringLiteral(S->getAsmString());
161 ID.AddInteger(S->getNumOutputs());
162 for (unsigned I = 0, N = S->getNumOutputs(); I != N; ++I) {
163 ID.AddString(S->getOutputName(I));
164 VisitStringLiteral(S->getOutputConstraintLiteral(I));
165 }
166 ID.AddInteger(S->getNumInputs());
167 for (unsigned I = 0, N = S->getNumInputs(); I != N; ++I) {
168 ID.AddString(S->getInputName(I));
169 VisitStringLiteral(S->getInputConstraintLiteral(I));
170 }
171 ID.AddInteger(S->getNumClobbers());
172 for (unsigned I = 0, N = S->getNumClobbers(); I != N; ++I)
173 VisitStringLiteral(S->getClobber(I));
174}
175
Chandler Carruthb1138242011-06-16 06:47:06 +0000176void StmtProfiler::VisitCXXCatchStmt(const CXXCatchStmt *S) {
Douglas Gregor3fe81fc2009-07-28 15:27:13 +0000177 VisitStmt(S);
178 VisitType(S->getCaughtType());
179}
180
Chandler Carruthb1138242011-06-16 06:47:06 +0000181void StmtProfiler::VisitCXXTryStmt(const CXXTryStmt *S) {
Douglas Gregor3fe81fc2009-07-28 15:27:13 +0000182 VisitStmt(S);
183}
184
Chandler Carruthb1138242011-06-16 06:47:06 +0000185void StmtProfiler::VisitCXXForRangeStmt(const CXXForRangeStmt *S) {
Richard Smithad762fc2011-04-14 22:09:26 +0000186 VisitStmt(S);
187}
188
Douglas Gregorba0513d2011-10-25 01:33:02 +0000189void StmtProfiler::VisitMSDependentExistsStmt(const MSDependentExistsStmt *S) {
190 VisitStmt(S);
191 ID.AddBoolean(S->isIfExists());
192 VisitNestedNameSpecifier(S->getQualifierLoc().getNestedNameSpecifier());
193 VisitName(S->getNameInfo().getName());
194}
195
Chandler Carruthb1138242011-06-16 06:47:06 +0000196void StmtProfiler::VisitSEHTryStmt(const SEHTryStmt *S) {
John Wiegley28bbe4b2011-04-28 01:08:34 +0000197 VisitStmt(S);
198}
199
Chandler Carruthb1138242011-06-16 06:47:06 +0000200void StmtProfiler::VisitSEHFinallyStmt(const SEHFinallyStmt *S) {
John Wiegley28bbe4b2011-04-28 01:08:34 +0000201 VisitStmt(S);
202}
203
Chandler Carruthb1138242011-06-16 06:47:06 +0000204void StmtProfiler::VisitSEHExceptStmt(const SEHExceptStmt *S) {
John Wiegley28bbe4b2011-04-28 01:08:34 +0000205 VisitStmt(S);
206}
207
Chandler Carruthb1138242011-06-16 06:47:06 +0000208void StmtProfiler::VisitObjCForCollectionStmt(const ObjCForCollectionStmt *S) {
Douglas Gregor3fe81fc2009-07-28 15:27:13 +0000209 VisitStmt(S);
210}
211
Chandler Carruthb1138242011-06-16 06:47:06 +0000212void StmtProfiler::VisitObjCAtCatchStmt(const ObjCAtCatchStmt *S) {
Douglas Gregor3fe81fc2009-07-28 15:27:13 +0000213 VisitStmt(S);
214 ID.AddBoolean(S->hasEllipsis());
215 if (S->getCatchParamDecl())
216 VisitType(S->getCatchParamDecl()->getType());
217}
218
Chandler Carruthb1138242011-06-16 06:47:06 +0000219void StmtProfiler::VisitObjCAtFinallyStmt(const ObjCAtFinallyStmt *S) {
Douglas Gregor3fe81fc2009-07-28 15:27:13 +0000220 VisitStmt(S);
221}
222
Chandler Carruthb1138242011-06-16 06:47:06 +0000223void StmtProfiler::VisitObjCAtTryStmt(const ObjCAtTryStmt *S) {
Douglas Gregor3fe81fc2009-07-28 15:27:13 +0000224 VisitStmt(S);
225}
226
Chandler Carruthb1138242011-06-16 06:47:06 +0000227void
228StmtProfiler::VisitObjCAtSynchronizedStmt(const ObjCAtSynchronizedStmt *S) {
Douglas Gregor3fe81fc2009-07-28 15:27:13 +0000229 VisitStmt(S);
230}
231
Chandler Carruthb1138242011-06-16 06:47:06 +0000232void StmtProfiler::VisitObjCAtThrowStmt(const ObjCAtThrowStmt *S) {
Douglas Gregor3fe81fc2009-07-28 15:27:13 +0000233 VisitStmt(S);
234}
235
Chandler Carruthb1138242011-06-16 06:47:06 +0000236void
237StmtProfiler::VisitObjCAutoreleasePoolStmt(const ObjCAutoreleasePoolStmt *S) {
John McCallf85e1932011-06-15 23:02:42 +0000238 VisitStmt(S);
239}
240
Chandler Carruthb1138242011-06-16 06:47:06 +0000241void StmtProfiler::VisitExpr(const Expr *S) {
Douglas Gregor41ef0c32009-07-28 00:33:38 +0000242 VisitStmt(S);
243}
244
Chandler Carruthb1138242011-06-16 06:47:06 +0000245void StmtProfiler::VisitDeclRefExpr(const DeclRefExpr *S) {
Douglas Gregor41ef0c32009-07-28 00:33:38 +0000246 VisitExpr(S);
Douglas Gregor218f47f2010-07-13 08:37:11 +0000247 if (!Canonical)
248 VisitNestedNameSpecifier(S->getQualifier());
Douglas Gregor41ef0c32009-07-28 00:33:38 +0000249 VisitDecl(S->getDecl());
Douglas Gregor218f47f2010-07-13 08:37:11 +0000250 if (!Canonical)
251 VisitTemplateArguments(S->getTemplateArgs(), S->getNumTemplateArgs());
Douglas Gregor41ef0c32009-07-28 00:33:38 +0000252}
253
Chandler Carruthb1138242011-06-16 06:47:06 +0000254void StmtProfiler::VisitPredefinedExpr(const PredefinedExpr *S) {
Douglas Gregor41ef0c32009-07-28 00:33:38 +0000255 VisitExpr(S);
256 ID.AddInteger(S->getIdentType());
257}
258
Chandler Carruthb1138242011-06-16 06:47:06 +0000259void StmtProfiler::VisitIntegerLiteral(const IntegerLiteral *S) {
Douglas Gregor41ef0c32009-07-28 00:33:38 +0000260 VisitExpr(S);
261 S->getValue().Profile(ID);
262}
263
Chandler Carruthb1138242011-06-16 06:47:06 +0000264void StmtProfiler::VisitCharacterLiteral(const CharacterLiteral *S) {
Douglas Gregor41ef0c32009-07-28 00:33:38 +0000265 VisitExpr(S);
Douglas Gregor5cee1192011-07-27 05:40:30 +0000266 ID.AddInteger(S->getKind());
Douglas Gregor41ef0c32009-07-28 00:33:38 +0000267 ID.AddInteger(S->getValue());
268}
269
Chandler Carruthb1138242011-06-16 06:47:06 +0000270void StmtProfiler::VisitFloatingLiteral(const FloatingLiteral *S) {
Douglas Gregor41ef0c32009-07-28 00:33:38 +0000271 VisitExpr(S);
272 S->getValue().Profile(ID);
273 ID.AddBoolean(S->isExact());
274}
275
Chandler Carruthb1138242011-06-16 06:47:06 +0000276void StmtProfiler::VisitImaginaryLiteral(const ImaginaryLiteral *S) {
Douglas Gregor41ef0c32009-07-28 00:33:38 +0000277 VisitExpr(S);
278}
279
Chandler Carruthb1138242011-06-16 06:47:06 +0000280void StmtProfiler::VisitStringLiteral(const StringLiteral *S) {
Douglas Gregor41ef0c32009-07-28 00:33:38 +0000281 VisitExpr(S);
Douglas Gregor38738fc2011-11-02 17:26:05 +0000282 ID.AddString(S->getBytes());
Douglas Gregor5cee1192011-07-27 05:40:30 +0000283 ID.AddInteger(S->getKind());
Douglas Gregor41ef0c32009-07-28 00:33:38 +0000284}
285
Chandler Carruthb1138242011-06-16 06:47:06 +0000286void StmtProfiler::VisitParenExpr(const ParenExpr *S) {
Douglas Gregor41ef0c32009-07-28 00:33:38 +0000287 VisitExpr(S);
288}
289
Chandler Carruthb1138242011-06-16 06:47:06 +0000290void StmtProfiler::VisitParenListExpr(const ParenListExpr *S) {
Nate Begeman2ef13e52009-08-10 23:49:36 +0000291 VisitExpr(S);
292}
293
Chandler Carruthb1138242011-06-16 06:47:06 +0000294void StmtProfiler::VisitUnaryOperator(const UnaryOperator *S) {
Douglas Gregor41ef0c32009-07-28 00:33:38 +0000295 VisitExpr(S);
296 ID.AddInteger(S->getOpcode());
297}
298
Chandler Carruthb1138242011-06-16 06:47:06 +0000299void StmtProfiler::VisitOffsetOfExpr(const OffsetOfExpr *S) {
Douglas Gregor8ecdb652010-04-28 22:16:22 +0000300 VisitType(S->getTypeSourceInfo()->getType());
301 unsigned n = S->getNumComponents();
302 for (unsigned i = 0; i < n; ++i) {
303 const OffsetOfExpr::OffsetOfNode& ON = S->getComponent(i);
304 ID.AddInteger(ON.getKind());
305 switch (ON.getKind()) {
306 case OffsetOfExpr::OffsetOfNode::Array:
307 // Expressions handled below.
308 break;
309
310 case OffsetOfExpr::OffsetOfNode::Field:
311 VisitDecl(ON.getField());
312 break;
313
314 case OffsetOfExpr::OffsetOfNode::Identifier:
315 ID.AddPointer(ON.getFieldName());
316 break;
Sean Huntc3021132010-05-05 15:23:54 +0000317
Douglas Gregorcc8a5d52010-04-29 00:18:15 +0000318 case OffsetOfExpr::OffsetOfNode::Base:
319 // These nodes are implicit, and therefore don't need profiling.
320 break;
Douglas Gregor8ecdb652010-04-28 22:16:22 +0000321 }
322 }
Sean Huntc3021132010-05-05 15:23:54 +0000323
Douglas Gregor8ecdb652010-04-28 22:16:22 +0000324 VisitExpr(S);
325}
326
Chandler Carruthb1138242011-06-16 06:47:06 +0000327void
328StmtProfiler::VisitUnaryExprOrTypeTraitExpr(const UnaryExprOrTypeTraitExpr *S) {
Douglas Gregor41ef0c32009-07-28 00:33:38 +0000329 VisitExpr(S);
Peter Collingbournef4e3cfb2011-03-11 19:24:49 +0000330 ID.AddInteger(S->getKind());
Douglas Gregor41ef0c32009-07-28 00:33:38 +0000331 if (S->isArgumentType())
332 VisitType(S->getArgumentType());
333}
334
Chandler Carruthb1138242011-06-16 06:47:06 +0000335void StmtProfiler::VisitArraySubscriptExpr(const ArraySubscriptExpr *S) {
Douglas Gregor41ef0c32009-07-28 00:33:38 +0000336 VisitExpr(S);
337}
338
Chandler Carruthb1138242011-06-16 06:47:06 +0000339void StmtProfiler::VisitCallExpr(const CallExpr *S) {
Douglas Gregor41ef0c32009-07-28 00:33:38 +0000340 VisitExpr(S);
341}
342
Chandler Carruthb1138242011-06-16 06:47:06 +0000343void StmtProfiler::VisitMemberExpr(const MemberExpr *S) {
Douglas Gregor41ef0c32009-07-28 00:33:38 +0000344 VisitExpr(S);
345 VisitDecl(S->getMemberDecl());
Douglas Gregor218f47f2010-07-13 08:37:11 +0000346 if (!Canonical)
347 VisitNestedNameSpecifier(S->getQualifier());
Douglas Gregor41ef0c32009-07-28 00:33:38 +0000348 ID.AddBoolean(S->isArrow());
349}
350
Chandler Carruthb1138242011-06-16 06:47:06 +0000351void StmtProfiler::VisitCompoundLiteralExpr(const CompoundLiteralExpr *S) {
Douglas Gregor41ef0c32009-07-28 00:33:38 +0000352 VisitExpr(S);
353 ID.AddBoolean(S->isFileScope());
354}
355
Chandler Carruthb1138242011-06-16 06:47:06 +0000356void StmtProfiler::VisitCastExpr(const CastExpr *S) {
Douglas Gregor41ef0c32009-07-28 00:33:38 +0000357 VisitExpr(S);
358}
359
Chandler Carruthb1138242011-06-16 06:47:06 +0000360void StmtProfiler::VisitImplicitCastExpr(const ImplicitCastExpr *S) {
Douglas Gregor41ef0c32009-07-28 00:33:38 +0000361 VisitCastExpr(S);
John McCall5baba9d2010-08-25 10:28:54 +0000362 ID.AddInteger(S->getValueKind());
Douglas Gregor41ef0c32009-07-28 00:33:38 +0000363}
364
Chandler Carruthb1138242011-06-16 06:47:06 +0000365void StmtProfiler::VisitExplicitCastExpr(const ExplicitCastExpr *S) {
Douglas Gregor41ef0c32009-07-28 00:33:38 +0000366 VisitCastExpr(S);
367 VisitType(S->getTypeAsWritten());
368}
369
Chandler Carruthb1138242011-06-16 06:47:06 +0000370void StmtProfiler::VisitCStyleCastExpr(const CStyleCastExpr *S) {
Douglas Gregor41ef0c32009-07-28 00:33:38 +0000371 VisitExplicitCastExpr(S);
372}
373
Chandler Carruthb1138242011-06-16 06:47:06 +0000374void StmtProfiler::VisitBinaryOperator(const BinaryOperator *S) {
Douglas Gregor41ef0c32009-07-28 00:33:38 +0000375 VisitExpr(S);
376 ID.AddInteger(S->getOpcode());
377}
378
Chandler Carruthb1138242011-06-16 06:47:06 +0000379void
380StmtProfiler::VisitCompoundAssignOperator(const CompoundAssignOperator *S) {
Douglas Gregor41ef0c32009-07-28 00:33:38 +0000381 VisitBinaryOperator(S);
382}
383
Chandler Carruthb1138242011-06-16 06:47:06 +0000384void StmtProfiler::VisitConditionalOperator(const ConditionalOperator *S) {
Douglas Gregor41ef0c32009-07-28 00:33:38 +0000385 VisitExpr(S);
386}
387
Chandler Carruthb1138242011-06-16 06:47:06 +0000388void StmtProfiler::VisitBinaryConditionalOperator(
Chandler Carruth08949762011-06-21 23:26:32 +0000389 const BinaryConditionalOperator *S) {
John McCall56ca35d2011-02-17 10:25:35 +0000390 VisitExpr(S);
391}
392
Chandler Carruthb1138242011-06-16 06:47:06 +0000393void StmtProfiler::VisitAddrLabelExpr(const AddrLabelExpr *S) {
Douglas Gregor41ef0c32009-07-28 00:33:38 +0000394 VisitExpr(S);
Chris Lattnerad8dcf42011-02-17 07:39:24 +0000395 VisitDecl(S->getLabel());
Douglas Gregor41ef0c32009-07-28 00:33:38 +0000396}
397
Chandler Carruthb1138242011-06-16 06:47:06 +0000398void StmtProfiler::VisitStmtExpr(const StmtExpr *S) {
Douglas Gregor41ef0c32009-07-28 00:33:38 +0000399 VisitExpr(S);
400}
401
Chandler Carruthb1138242011-06-16 06:47:06 +0000402void StmtProfiler::VisitShuffleVectorExpr(const ShuffleVectorExpr *S) {
Douglas Gregor41ef0c32009-07-28 00:33:38 +0000403 VisitExpr(S);
404}
405
Chandler Carruthb1138242011-06-16 06:47:06 +0000406void StmtProfiler::VisitChooseExpr(const ChooseExpr *S) {
Douglas Gregor41ef0c32009-07-28 00:33:38 +0000407 VisitExpr(S);
408}
409
Chandler Carruthb1138242011-06-16 06:47:06 +0000410void StmtProfiler::VisitGNUNullExpr(const GNUNullExpr *S) {
Douglas Gregor41ef0c32009-07-28 00:33:38 +0000411 VisitExpr(S);
412}
413
Chandler Carruthb1138242011-06-16 06:47:06 +0000414void StmtProfiler::VisitVAArgExpr(const VAArgExpr *S) {
Douglas Gregor828e2262009-07-29 16:09:57 +0000415 VisitExpr(S);
416}
417
Chandler Carruthb1138242011-06-16 06:47:06 +0000418void StmtProfiler::VisitInitListExpr(const InitListExpr *S) {
Douglas Gregor41ef0c32009-07-28 00:33:38 +0000419 if (S->getSyntacticForm()) {
420 VisitInitListExpr(S->getSyntacticForm());
421 return;
422 }
Mike Stump1eb44332009-09-09 15:08:12 +0000423
Douglas Gregor41ef0c32009-07-28 00:33:38 +0000424 VisitExpr(S);
425}
426
Chandler Carruthb1138242011-06-16 06:47:06 +0000427void StmtProfiler::VisitDesignatedInitExpr(const DesignatedInitExpr *S) {
Douglas Gregor41ef0c32009-07-28 00:33:38 +0000428 VisitExpr(S);
429 ID.AddBoolean(S->usesGNUSyntax());
Chandler Carruthb1138242011-06-16 06:47:06 +0000430 for (DesignatedInitExpr::const_designators_iterator D =
431 S->designators_begin(), DEnd = S->designators_end();
Douglas Gregor41ef0c32009-07-28 00:33:38 +0000432 D != DEnd; ++D) {
433 if (D->isFieldDesignator()) {
434 ID.AddInteger(0);
435 VisitName(D->getFieldName());
436 continue;
437 }
Mike Stump1eb44332009-09-09 15:08:12 +0000438
Douglas Gregor41ef0c32009-07-28 00:33:38 +0000439 if (D->isArrayDesignator()) {
440 ID.AddInteger(1);
441 } else {
442 assert(D->isArrayRangeDesignator());
443 ID.AddInteger(2);
444 }
445 ID.AddInteger(D->getFirstExprIndex());
446 }
447}
448
Chandler Carruthb1138242011-06-16 06:47:06 +0000449void StmtProfiler::VisitImplicitValueInitExpr(const ImplicitValueInitExpr *S) {
Douglas Gregor41ef0c32009-07-28 00:33:38 +0000450 VisitExpr(S);
451}
452
Chandler Carruthb1138242011-06-16 06:47:06 +0000453void StmtProfiler::VisitExtVectorElementExpr(const ExtVectorElementExpr *S) {
Douglas Gregor41ef0c32009-07-28 00:33:38 +0000454 VisitExpr(S);
455 VisitName(&S->getAccessor());
456}
457
Chandler Carruthb1138242011-06-16 06:47:06 +0000458void StmtProfiler::VisitBlockExpr(const BlockExpr *S) {
Douglas Gregor41ef0c32009-07-28 00:33:38 +0000459 VisitExpr(S);
460 VisitDecl(S->getBlockDecl());
461}
462
Chandler Carruthb1138242011-06-16 06:47:06 +0000463void StmtProfiler::VisitBlockDeclRefExpr(const BlockDeclRefExpr *S) {
Douglas Gregor41ef0c32009-07-28 00:33:38 +0000464 VisitExpr(S);
465 VisitDecl(S->getDecl());
466 ID.AddBoolean(S->isByRef());
467 ID.AddBoolean(S->isConstQualAdded());
468}
469
Chandler Carruthb1138242011-06-16 06:47:06 +0000470void StmtProfiler::VisitGenericSelectionExpr(const GenericSelectionExpr *S) {
Peter Collingbournef111d932011-04-15 00:35:48 +0000471 VisitExpr(S);
472 for (unsigned i = 0; i != S->getNumAssocs(); ++i) {
473 QualType T = S->getAssocType(i);
474 if (T.isNull())
475 ID.AddPointer(0);
476 else
477 VisitType(T);
478 VisitExpr(S->getAssocExpr(i));
479 }
480}
481
John McCall4b9c2d22011-11-06 09:01:30 +0000482void StmtProfiler::VisitPseudoObjectExpr(const PseudoObjectExpr *S) {
483 VisitExpr(S);
484 for (PseudoObjectExpr::const_semantics_iterator
485 i = S->semantics_begin(), e = S->semantics_end(); i != e; ++i)
486 // Normally, we would not profile the source expressions of OVEs.
487 if (const OpaqueValueExpr *OVE = dyn_cast<OpaqueValueExpr>(*i))
488 Visit(OVE->getSourceExpr());
489}
490
Eli Friedman276b0612011-10-11 02:20:01 +0000491void StmtProfiler::VisitAtomicExpr(const AtomicExpr *S) {
492 VisitExpr(S);
Eli Friedman2be46072011-10-14 20:59:01 +0000493 ID.AddInteger(S->getOp());
Eli Friedman276b0612011-10-11 02:20:01 +0000494}
495
Chandler Carruthb1138242011-06-16 06:47:06 +0000496static Stmt::StmtClass DecodeOperatorCall(const CXXOperatorCallExpr *S,
John McCall2de56d12010-08-25 11:45:40 +0000497 UnaryOperatorKind &UnaryOp,
498 BinaryOperatorKind &BinaryOp) {
Douglas Gregora89064a2010-05-19 04:13:23 +0000499 switch (S->getOperator()) {
500 case OO_None:
501 case OO_New:
502 case OO_Delete:
503 case OO_Array_New:
504 case OO_Array_Delete:
505 case OO_Arrow:
506 case OO_Call:
507 case OO_Conditional:
508 case NUM_OVERLOADED_OPERATORS:
509 llvm_unreachable("Invalid operator call kind");
Douglas Gregora89064a2010-05-19 04:13:23 +0000510
511 case OO_Plus:
512 if (S->getNumArgs() == 1) {
John McCall2de56d12010-08-25 11:45:40 +0000513 UnaryOp = UO_Plus;
Douglas Gregora89064a2010-05-19 04:13:23 +0000514 return Stmt::UnaryOperatorClass;
515 }
516
John McCall2de56d12010-08-25 11:45:40 +0000517 BinaryOp = BO_Add;
Douglas Gregora89064a2010-05-19 04:13:23 +0000518 return Stmt::BinaryOperatorClass;
519
520 case OO_Minus:
521 if (S->getNumArgs() == 1) {
John McCall2de56d12010-08-25 11:45:40 +0000522 UnaryOp = UO_Minus;
Douglas Gregora89064a2010-05-19 04:13:23 +0000523 return Stmt::UnaryOperatorClass;
524 }
525
John McCall2de56d12010-08-25 11:45:40 +0000526 BinaryOp = BO_Sub;
Douglas Gregora89064a2010-05-19 04:13:23 +0000527 return Stmt::BinaryOperatorClass;
528
529 case OO_Star:
530 if (S->getNumArgs() == 1) {
John McCall2de56d12010-08-25 11:45:40 +0000531 UnaryOp = UO_Minus;
Douglas Gregora89064a2010-05-19 04:13:23 +0000532 return Stmt::UnaryOperatorClass;
533 }
534
John McCall2de56d12010-08-25 11:45:40 +0000535 BinaryOp = BO_Sub;
Douglas Gregora89064a2010-05-19 04:13:23 +0000536 return Stmt::BinaryOperatorClass;
537
538 case OO_Slash:
John McCall2de56d12010-08-25 11:45:40 +0000539 BinaryOp = BO_Div;
Douglas Gregora89064a2010-05-19 04:13:23 +0000540 return Stmt::BinaryOperatorClass;
541
542 case OO_Percent:
John McCall2de56d12010-08-25 11:45:40 +0000543 BinaryOp = BO_Rem;
Douglas Gregora89064a2010-05-19 04:13:23 +0000544 return Stmt::BinaryOperatorClass;
545
546 case OO_Caret:
John McCall2de56d12010-08-25 11:45:40 +0000547 BinaryOp = BO_Xor;
Douglas Gregora89064a2010-05-19 04:13:23 +0000548 return Stmt::BinaryOperatorClass;
549
550 case OO_Amp:
551 if (S->getNumArgs() == 1) {
John McCall2de56d12010-08-25 11:45:40 +0000552 UnaryOp = UO_AddrOf;
Douglas Gregora89064a2010-05-19 04:13:23 +0000553 return Stmt::UnaryOperatorClass;
554 }
555
John McCall2de56d12010-08-25 11:45:40 +0000556 BinaryOp = BO_And;
Douglas Gregora89064a2010-05-19 04:13:23 +0000557 return Stmt::BinaryOperatorClass;
558
559 case OO_Pipe:
John McCall2de56d12010-08-25 11:45:40 +0000560 BinaryOp = BO_Or;
Douglas Gregora89064a2010-05-19 04:13:23 +0000561 return Stmt::BinaryOperatorClass;
562
563 case OO_Tilde:
John McCall2de56d12010-08-25 11:45:40 +0000564 UnaryOp = UO_Not;
Douglas Gregora89064a2010-05-19 04:13:23 +0000565 return Stmt::UnaryOperatorClass;
566
567 case OO_Exclaim:
John McCall2de56d12010-08-25 11:45:40 +0000568 UnaryOp = UO_LNot;
Douglas Gregora89064a2010-05-19 04:13:23 +0000569 return Stmt::UnaryOperatorClass;
570
571 case OO_Equal:
John McCall2de56d12010-08-25 11:45:40 +0000572 BinaryOp = BO_Assign;
Douglas Gregora89064a2010-05-19 04:13:23 +0000573 return Stmt::BinaryOperatorClass;
574
575 case OO_Less:
John McCall2de56d12010-08-25 11:45:40 +0000576 BinaryOp = BO_LT;
Douglas Gregora89064a2010-05-19 04:13:23 +0000577 return Stmt::BinaryOperatorClass;
578
579 case OO_Greater:
John McCall2de56d12010-08-25 11:45:40 +0000580 BinaryOp = BO_GT;
Douglas Gregora89064a2010-05-19 04:13:23 +0000581 return Stmt::BinaryOperatorClass;
582
583 case OO_PlusEqual:
John McCall2de56d12010-08-25 11:45:40 +0000584 BinaryOp = BO_AddAssign;
Douglas Gregora89064a2010-05-19 04:13:23 +0000585 return Stmt::CompoundAssignOperatorClass;
586
587 case OO_MinusEqual:
John McCall2de56d12010-08-25 11:45:40 +0000588 BinaryOp = BO_SubAssign;
Douglas Gregora89064a2010-05-19 04:13:23 +0000589 return Stmt::CompoundAssignOperatorClass;
590
591 case OO_StarEqual:
John McCall2de56d12010-08-25 11:45:40 +0000592 BinaryOp = BO_MulAssign;
Douglas Gregora89064a2010-05-19 04:13:23 +0000593 return Stmt::CompoundAssignOperatorClass;
594
595 case OO_SlashEqual:
John McCall2de56d12010-08-25 11:45:40 +0000596 BinaryOp = BO_DivAssign;
Douglas Gregora89064a2010-05-19 04:13:23 +0000597 return Stmt::CompoundAssignOperatorClass;
598
599 case OO_PercentEqual:
John McCall2de56d12010-08-25 11:45:40 +0000600 BinaryOp = BO_RemAssign;
Douglas Gregora89064a2010-05-19 04:13:23 +0000601 return Stmt::CompoundAssignOperatorClass;
602
603 case OO_CaretEqual:
John McCall2de56d12010-08-25 11:45:40 +0000604 BinaryOp = BO_XorAssign;
Douglas Gregora89064a2010-05-19 04:13:23 +0000605 return Stmt::CompoundAssignOperatorClass;
606
607 case OO_AmpEqual:
John McCall2de56d12010-08-25 11:45:40 +0000608 BinaryOp = BO_AndAssign;
Douglas Gregora89064a2010-05-19 04:13:23 +0000609 return Stmt::CompoundAssignOperatorClass;
610
611 case OO_PipeEqual:
John McCall2de56d12010-08-25 11:45:40 +0000612 BinaryOp = BO_OrAssign;
Douglas Gregora89064a2010-05-19 04:13:23 +0000613 return Stmt::CompoundAssignOperatorClass;
614
615 case OO_LessLess:
John McCall2de56d12010-08-25 11:45:40 +0000616 BinaryOp = BO_Shl;
Douglas Gregora89064a2010-05-19 04:13:23 +0000617 return Stmt::BinaryOperatorClass;
618
619 case OO_GreaterGreater:
John McCall2de56d12010-08-25 11:45:40 +0000620 BinaryOp = BO_Shr;
Douglas Gregora89064a2010-05-19 04:13:23 +0000621 return Stmt::BinaryOperatorClass;
622
623 case OO_LessLessEqual:
John McCall2de56d12010-08-25 11:45:40 +0000624 BinaryOp = BO_ShlAssign;
Douglas Gregora89064a2010-05-19 04:13:23 +0000625 return Stmt::CompoundAssignOperatorClass;
626
627 case OO_GreaterGreaterEqual:
John McCall2de56d12010-08-25 11:45:40 +0000628 BinaryOp = BO_ShrAssign;
Douglas Gregora89064a2010-05-19 04:13:23 +0000629 return Stmt::CompoundAssignOperatorClass;
630
631 case OO_EqualEqual:
John McCall2de56d12010-08-25 11:45:40 +0000632 BinaryOp = BO_EQ;
Douglas Gregora89064a2010-05-19 04:13:23 +0000633 return Stmt::BinaryOperatorClass;
634
635 case OO_ExclaimEqual:
John McCall2de56d12010-08-25 11:45:40 +0000636 BinaryOp = BO_NE;
Douglas Gregora89064a2010-05-19 04:13:23 +0000637 return Stmt::BinaryOperatorClass;
638
639 case OO_LessEqual:
John McCall2de56d12010-08-25 11:45:40 +0000640 BinaryOp = BO_LE;
Douglas Gregora89064a2010-05-19 04:13:23 +0000641 return Stmt::BinaryOperatorClass;
642
643 case OO_GreaterEqual:
John McCall2de56d12010-08-25 11:45:40 +0000644 BinaryOp = BO_GE;
Douglas Gregora89064a2010-05-19 04:13:23 +0000645 return Stmt::BinaryOperatorClass;
646
647 case OO_AmpAmp:
John McCall2de56d12010-08-25 11:45:40 +0000648 BinaryOp = BO_LAnd;
Douglas Gregora89064a2010-05-19 04:13:23 +0000649 return Stmt::BinaryOperatorClass;
650
651 case OO_PipePipe:
John McCall2de56d12010-08-25 11:45:40 +0000652 BinaryOp = BO_LOr;
Douglas Gregora89064a2010-05-19 04:13:23 +0000653 return Stmt::BinaryOperatorClass;
654
655 case OO_PlusPlus:
John McCall2de56d12010-08-25 11:45:40 +0000656 UnaryOp = S->getNumArgs() == 1? UO_PreInc
657 : UO_PostInc;
Douglas Gregora89064a2010-05-19 04:13:23 +0000658 return Stmt::UnaryOperatorClass;
659
660 case OO_MinusMinus:
John McCall2de56d12010-08-25 11:45:40 +0000661 UnaryOp = S->getNumArgs() == 1? UO_PreDec
662 : UO_PostDec;
Douglas Gregora89064a2010-05-19 04:13:23 +0000663 return Stmt::UnaryOperatorClass;
664
665 case OO_Comma:
John McCall2de56d12010-08-25 11:45:40 +0000666 BinaryOp = BO_Comma;
Douglas Gregora89064a2010-05-19 04:13:23 +0000667 return Stmt::BinaryOperatorClass;
668
669
670 case OO_ArrowStar:
John McCall2de56d12010-08-25 11:45:40 +0000671 BinaryOp = BO_PtrMemI;
Douglas Gregora89064a2010-05-19 04:13:23 +0000672 return Stmt::BinaryOperatorClass;
673
674 case OO_Subscript:
675 return Stmt::ArraySubscriptExprClass;
676 }
677
678 llvm_unreachable("Invalid overloaded operator expression");
679}
680
681
Chandler Carruthb1138242011-06-16 06:47:06 +0000682void StmtProfiler::VisitCXXOperatorCallExpr(const CXXOperatorCallExpr *S) {
Douglas Gregora89064a2010-05-19 04:13:23 +0000683 if (S->isTypeDependent()) {
684 // Type-dependent operator calls are profiled like their underlying
685 // syntactic operator.
John McCall2de56d12010-08-25 11:45:40 +0000686 UnaryOperatorKind UnaryOp = UO_Extension;
687 BinaryOperatorKind BinaryOp = BO_Comma;
Douglas Gregora89064a2010-05-19 04:13:23 +0000688 Stmt::StmtClass SC = DecodeOperatorCall(S, UnaryOp, BinaryOp);
689
690 ID.AddInteger(SC);
691 for (unsigned I = 0, N = S->getNumArgs(); I != N; ++I)
692 Visit(S->getArg(I));
693 if (SC == Stmt::UnaryOperatorClass)
694 ID.AddInteger(UnaryOp);
695 else if (SC == Stmt::BinaryOperatorClass ||
696 SC == Stmt::CompoundAssignOperatorClass)
697 ID.AddInteger(BinaryOp);
698 else
699 assert(SC == Stmt::ArraySubscriptExprClass);
700
701 return;
702 }
703
Douglas Gregor41ef0c32009-07-28 00:33:38 +0000704 VisitCallExpr(S);
705 ID.AddInteger(S->getOperator());
706}
707
Chandler Carruthb1138242011-06-16 06:47:06 +0000708void StmtProfiler::VisitCXXMemberCallExpr(const CXXMemberCallExpr *S) {
Douglas Gregor41ef0c32009-07-28 00:33:38 +0000709 VisitCallExpr(S);
710}
711
Chandler Carruthb1138242011-06-16 06:47:06 +0000712void StmtProfiler::VisitCUDAKernelCallExpr(const CUDAKernelCallExpr *S) {
Peter Collingbournee08ce652011-02-09 21:07:24 +0000713 VisitCallExpr(S);
714}
715
Chandler Carruthb1138242011-06-16 06:47:06 +0000716void StmtProfiler::VisitAsTypeExpr(const AsTypeExpr *S) {
Tanya Lattner61eee0c2011-06-04 00:47:47 +0000717 VisitExpr(S);
718}
719
Chandler Carruthb1138242011-06-16 06:47:06 +0000720void StmtProfiler::VisitCXXNamedCastExpr(const CXXNamedCastExpr *S) {
Douglas Gregor41ef0c32009-07-28 00:33:38 +0000721 VisitExplicitCastExpr(S);
722}
723
Chandler Carruthb1138242011-06-16 06:47:06 +0000724void StmtProfiler::VisitCXXStaticCastExpr(const CXXStaticCastExpr *S) {
Douglas Gregor41ef0c32009-07-28 00:33:38 +0000725 VisitCXXNamedCastExpr(S);
726}
727
Chandler Carruthb1138242011-06-16 06:47:06 +0000728void StmtProfiler::VisitCXXDynamicCastExpr(const CXXDynamicCastExpr *S) {
Douglas Gregor41ef0c32009-07-28 00:33:38 +0000729 VisitCXXNamedCastExpr(S);
730}
731
Chandler Carruthb1138242011-06-16 06:47:06 +0000732void
733StmtProfiler::VisitCXXReinterpretCastExpr(const CXXReinterpretCastExpr *S) {
Douglas Gregor41ef0c32009-07-28 00:33:38 +0000734 VisitCXXNamedCastExpr(S);
735}
736
Chandler Carruthb1138242011-06-16 06:47:06 +0000737void StmtProfiler::VisitCXXConstCastExpr(const CXXConstCastExpr *S) {
Douglas Gregor41ef0c32009-07-28 00:33:38 +0000738 VisitCXXNamedCastExpr(S);
739}
740
Richard Smith9fcce652012-03-07 08:35:16 +0000741void StmtProfiler::VisitUserDefinedLiteral(const UserDefinedLiteral *S) {
742 VisitCallExpr(S);
743}
744
Chandler Carruthb1138242011-06-16 06:47:06 +0000745void StmtProfiler::VisitCXXBoolLiteralExpr(const CXXBoolLiteralExpr *S) {
Douglas Gregor41ef0c32009-07-28 00:33:38 +0000746 VisitExpr(S);
747 ID.AddBoolean(S->getValue());
748}
749
Chandler Carruthb1138242011-06-16 06:47:06 +0000750void StmtProfiler::VisitCXXNullPtrLiteralExpr(const CXXNullPtrLiteralExpr *S) {
Douglas Gregor828e2262009-07-29 16:09:57 +0000751 VisitExpr(S);
752}
753
Chandler Carruthb1138242011-06-16 06:47:06 +0000754void StmtProfiler::VisitCXXTypeidExpr(const CXXTypeidExpr *S) {
Douglas Gregor41ef0c32009-07-28 00:33:38 +0000755 VisitExpr(S);
756 if (S->isTypeOperand())
757 VisitType(S->getTypeOperand());
758}
759
Chandler Carruthb1138242011-06-16 06:47:06 +0000760void StmtProfiler::VisitCXXUuidofExpr(const CXXUuidofExpr *S) {
Francois Pichet01b7c302010-09-08 12:20:18 +0000761 VisitExpr(S);
762 if (S->isTypeOperand())
763 VisitType(S->getTypeOperand());
764}
765
Chandler Carruthb1138242011-06-16 06:47:06 +0000766void StmtProfiler::VisitCXXThisExpr(const CXXThisExpr *S) {
Douglas Gregor41ef0c32009-07-28 00:33:38 +0000767 VisitExpr(S);
768}
769
Chandler Carruthb1138242011-06-16 06:47:06 +0000770void StmtProfiler::VisitCXXThrowExpr(const CXXThrowExpr *S) {
Douglas Gregor41ef0c32009-07-28 00:33:38 +0000771 VisitExpr(S);
772}
773
Chandler Carruthb1138242011-06-16 06:47:06 +0000774void StmtProfiler::VisitCXXDefaultArgExpr(const CXXDefaultArgExpr *S) {
Douglas Gregor41ef0c32009-07-28 00:33:38 +0000775 VisitExpr(S);
776 VisitDecl(S->getParam());
777}
778
Chandler Carruthb1138242011-06-16 06:47:06 +0000779void StmtProfiler::VisitCXXBindTemporaryExpr(const CXXBindTemporaryExpr *S) {
Douglas Gregor41ef0c32009-07-28 00:33:38 +0000780 VisitExpr(S);
781 VisitDecl(
782 const_cast<CXXDestructorDecl *>(S->getTemporary()->getDestructor()));
783}
784
Chandler Carruthb1138242011-06-16 06:47:06 +0000785void StmtProfiler::VisitCXXConstructExpr(const CXXConstructExpr *S) {
Douglas Gregor41ef0c32009-07-28 00:33:38 +0000786 VisitExpr(S);
787 VisitDecl(S->getConstructor());
788 ID.AddBoolean(S->isElidable());
789}
790
Chandler Carruthb1138242011-06-16 06:47:06 +0000791void StmtProfiler::VisitCXXFunctionalCastExpr(const CXXFunctionalCastExpr *S) {
Douglas Gregor41ef0c32009-07-28 00:33:38 +0000792 VisitExplicitCastExpr(S);
793}
794
Chandler Carruthb1138242011-06-16 06:47:06 +0000795void
796StmtProfiler::VisitCXXTemporaryObjectExpr(const CXXTemporaryObjectExpr *S) {
Douglas Gregor41ef0c32009-07-28 00:33:38 +0000797 VisitCXXConstructExpr(S);
798}
799
Chandler Carruthb1138242011-06-16 06:47:06 +0000800void
Douglas Gregor01d08012012-02-07 10:09:13 +0000801StmtProfiler::VisitLambdaExpr(const LambdaExpr *S) {
802 VisitExpr(S);
803 for (LambdaExpr::capture_iterator C = S->explicit_capture_begin(),
804 CEnd = S->explicit_capture_end();
805 C != CEnd; ++C) {
806 ID.AddInteger(C->getCaptureKind());
807 if (C->capturesVariable()) {
808 VisitDecl(C->getCapturedVar());
809 ID.AddBoolean(C->isPackExpansion());
810 }
811 }
812 // Note: If we actually needed to be able to match lambda
813 // expressions, we would have to consider parameters and return type
814 // here, among other things.
815 VisitStmt(S->getBody());
816}
817
818void
Chandler Carruthb1138242011-06-16 06:47:06 +0000819StmtProfiler::VisitCXXScalarValueInitExpr(const CXXScalarValueInitExpr *S) {
Douglas Gregor41ef0c32009-07-28 00:33:38 +0000820 VisitExpr(S);
821}
822
Chandler Carruthb1138242011-06-16 06:47:06 +0000823void StmtProfiler::VisitCXXDeleteExpr(const CXXDeleteExpr *S) {
Douglas Gregor41ef0c32009-07-28 00:33:38 +0000824 VisitExpr(S);
825 ID.AddBoolean(S->isGlobalDelete());
826 ID.AddBoolean(S->isArrayForm());
827 VisitDecl(S->getOperatorDelete());
828}
829
830
Chandler Carruthb1138242011-06-16 06:47:06 +0000831void StmtProfiler::VisitCXXNewExpr(const CXXNewExpr *S) {
Douglas Gregor41ef0c32009-07-28 00:33:38 +0000832 VisitExpr(S);
833 VisitType(S->getAllocatedType());
834 VisitDecl(S->getOperatorNew());
835 VisitDecl(S->getOperatorDelete());
Douglas Gregor41ef0c32009-07-28 00:33:38 +0000836 ID.AddBoolean(S->isArray());
837 ID.AddInteger(S->getNumPlacementArgs());
838 ID.AddBoolean(S->isGlobalNew());
839 ID.AddBoolean(S->isParenTypeId());
Sebastian Redl2aed8b82012-02-16 12:22:20 +0000840 ID.AddInteger(S->getInitializationStyle());
Douglas Gregor41ef0c32009-07-28 00:33:38 +0000841}
842
Chandler Carruthb1138242011-06-16 06:47:06 +0000843void
844StmtProfiler::VisitCXXPseudoDestructorExpr(const CXXPseudoDestructorExpr *S) {
Douglas Gregora71d8192009-09-04 17:36:40 +0000845 VisitExpr(S);
846 ID.AddBoolean(S->isArrow());
847 VisitNestedNameSpecifier(S->getQualifier());
848 VisitType(S->getDestroyedType());
849}
850
Chandler Carruthb1138242011-06-16 06:47:06 +0000851void StmtProfiler::VisitOverloadExpr(const OverloadExpr *S) {
Argyrios Kyrtzidis7b3e3f62010-08-15 20:53:20 +0000852 VisitExpr(S);
John McCallf7a1a742009-11-24 19:00:30 +0000853 VisitNestedNameSpecifier(S->getQualifier());
Douglas Gregor41ef0c32009-07-28 00:33:38 +0000854 VisitName(S->getName());
John McCallf7a1a742009-11-24 19:00:30 +0000855 ID.AddBoolean(S->hasExplicitTemplateArgs());
856 if (S->hasExplicitTemplateArgs())
Argyrios Kyrtzidisc35919b2010-08-15 01:15:38 +0000857 VisitTemplateArguments(S->getExplicitTemplateArgs().getTemplateArgs(),
858 S->getExplicitTemplateArgs().NumTemplateArgs);
859}
860
861void
Chandler Carruthb1138242011-06-16 06:47:06 +0000862StmtProfiler::VisitUnresolvedLookupExpr(const UnresolvedLookupExpr *S) {
Argyrios Kyrtzidisc35919b2010-08-15 01:15:38 +0000863 VisitOverloadExpr(S);
Douglas Gregor41ef0c32009-07-28 00:33:38 +0000864}
865
Chandler Carruthb1138242011-06-16 06:47:06 +0000866void StmtProfiler::VisitUnaryTypeTraitExpr(const UnaryTypeTraitExpr *S) {
Douglas Gregor41ef0c32009-07-28 00:33:38 +0000867 VisitExpr(S);
868 ID.AddInteger(S->getTrait());
869 VisitType(S->getQueriedType());
870}
871
Chandler Carruthb1138242011-06-16 06:47:06 +0000872void StmtProfiler::VisitBinaryTypeTraitExpr(const BinaryTypeTraitExpr *S) {
Francois Pichet6ad6f282010-12-07 00:08:36 +0000873 VisitExpr(S);
874 ID.AddInteger(S->getTrait());
875 VisitType(S->getLhsType());
876 VisitType(S->getRhsType());
877}
878
Douglas Gregor4ca8ac22012-02-24 07:38:34 +0000879void StmtProfiler::VisitTypeTraitExpr(const TypeTraitExpr *S) {
880 VisitExpr(S);
881 ID.AddInteger(S->getTrait());
882 ID.AddInteger(S->getNumArgs());
883 for (unsigned I = 0, N = S->getNumArgs(); I != N; ++I)
884 VisitType(S->getArg(I)->getType());
885}
886
Chandler Carruthb1138242011-06-16 06:47:06 +0000887void StmtProfiler::VisitArrayTypeTraitExpr(const ArrayTypeTraitExpr *S) {
John Wiegley21ff2e52011-04-28 00:16:57 +0000888 VisitExpr(S);
889 ID.AddInteger(S->getTrait());
890 VisitType(S->getQueriedType());
891}
892
Chandler Carruthb1138242011-06-16 06:47:06 +0000893void StmtProfiler::VisitExpressionTraitExpr(const ExpressionTraitExpr *S) {
John Wiegley55262202011-04-25 06:54:41 +0000894 VisitExpr(S);
895 ID.AddInteger(S->getTrait());
896 VisitExpr(S->getQueriedExpression());
897}
898
Chandler Carruthb1138242011-06-16 06:47:06 +0000899void StmtProfiler::VisitDependentScopeDeclRefExpr(
900 const DependentScopeDeclRefExpr *S) {
Douglas Gregor41ef0c32009-07-28 00:33:38 +0000901 VisitExpr(S);
902 VisitName(S->getDeclName());
903 VisitNestedNameSpecifier(S->getQualifier());
John McCallf7a1a742009-11-24 19:00:30 +0000904 ID.AddBoolean(S->hasExplicitTemplateArgs());
905 if (S->hasExplicitTemplateArgs())
906 VisitTemplateArguments(S->getTemplateArgs(), S->getNumTemplateArgs());
Douglas Gregor41ef0c32009-07-28 00:33:38 +0000907}
908
Chandler Carruthb1138242011-06-16 06:47:06 +0000909void StmtProfiler::VisitExprWithCleanups(const ExprWithCleanups *S) {
Douglas Gregor071f4eb2009-07-28 14:44:31 +0000910 VisitExpr(S);
Douglas Gregor071f4eb2009-07-28 14:44:31 +0000911}
912
Chandler Carruthb1138242011-06-16 06:47:06 +0000913void StmtProfiler::VisitCXXUnresolvedConstructExpr(
914 const CXXUnresolvedConstructExpr *S) {
Douglas Gregor071f4eb2009-07-28 14:44:31 +0000915 VisitExpr(S);
916 VisitType(S->getTypeAsWritten());
917}
918
Chandler Carruthb1138242011-06-16 06:47:06 +0000919void StmtProfiler::VisitCXXDependentScopeMemberExpr(
920 const CXXDependentScopeMemberExpr *S) {
John McCallaa81e162009-12-01 22:10:20 +0000921 ID.AddBoolean(S->isImplicitAccess());
922 if (!S->isImplicitAccess()) {
923 VisitExpr(S);
924 ID.AddBoolean(S->isArrow());
925 }
Douglas Gregora38c6872009-09-03 16:14:30 +0000926 VisitNestedNameSpecifier(S->getQualifier());
Douglas Gregor071f4eb2009-07-28 14:44:31 +0000927 VisitName(S->getMember());
John McCallaa81e162009-12-01 22:10:20 +0000928 ID.AddBoolean(S->hasExplicitTemplateArgs());
929 if (S->hasExplicitTemplateArgs())
John McCall129e2df2009-11-30 22:42:35 +0000930 VisitTemplateArguments(S->getTemplateArgs(), S->getNumTemplateArgs());
931}
932
Chandler Carruthb1138242011-06-16 06:47:06 +0000933void StmtProfiler::VisitUnresolvedMemberExpr(const UnresolvedMemberExpr *S) {
John McCallaa81e162009-12-01 22:10:20 +0000934 ID.AddBoolean(S->isImplicitAccess());
935 if (!S->isImplicitAccess()) {
936 VisitExpr(S);
937 ID.AddBoolean(S->isArrow());
938 }
John McCall129e2df2009-11-30 22:42:35 +0000939 VisitNestedNameSpecifier(S->getQualifier());
940 VisitName(S->getMemberName());
941 ID.AddBoolean(S->hasExplicitTemplateArgs());
942 if (S->hasExplicitTemplateArgs())
943 VisitTemplateArguments(S->getTemplateArgs(), S->getNumTemplateArgs());
Douglas Gregor071f4eb2009-07-28 14:44:31 +0000944}
945
Chandler Carruthb1138242011-06-16 06:47:06 +0000946void StmtProfiler::VisitCXXNoexceptExpr(const CXXNoexceptExpr *S) {
Sebastian Redl2e156222010-09-10 20:55:43 +0000947 VisitExpr(S);
948}
949
Chandler Carruthb1138242011-06-16 06:47:06 +0000950void StmtProfiler::VisitPackExpansionExpr(const PackExpansionExpr *S) {
Douglas Gregorbe230c32011-01-03 17:17:50 +0000951 VisitExpr(S);
952}
953
Chandler Carruthb1138242011-06-16 06:47:06 +0000954void StmtProfiler::VisitSizeOfPackExpr(const SizeOfPackExpr *S) {
Douglas Gregoree8aff02011-01-04 17:33:58 +0000955 VisitExpr(S);
956 VisitDecl(S->getPack());
957}
958
Douglas Gregorc7793c72011-01-15 01:15:58 +0000959void StmtProfiler::VisitSubstNonTypeTemplateParmPackExpr(
Chandler Carruthb1138242011-06-16 06:47:06 +0000960 const SubstNonTypeTemplateParmPackExpr *S) {
Douglas Gregorc7793c72011-01-15 01:15:58 +0000961 VisitExpr(S);
962 VisitDecl(S->getParameterPack());
963 VisitTemplateArgument(S->getArgumentPack());
964}
965
John McCall91a57552011-07-15 05:09:51 +0000966void StmtProfiler::VisitSubstNonTypeTemplateParmExpr(
967 const SubstNonTypeTemplateParmExpr *E) {
968 // Profile exactly as the replacement expression.
969 Visit(E->getReplacement());
970}
971
Douglas Gregor03e80032011-06-21 17:03:29 +0000972void StmtProfiler::VisitMaterializeTemporaryExpr(
973 const MaterializeTemporaryExpr *S) {
974 VisitExpr(S);
975}
976
Chandler Carruthb1138242011-06-16 06:47:06 +0000977void StmtProfiler::VisitOpaqueValueExpr(const OpaqueValueExpr *E) {
John McCall7cd7d1a2010-11-15 23:31:06 +0000978 VisitExpr(E);
979}
980
Chandler Carruthb1138242011-06-16 06:47:06 +0000981void StmtProfiler::VisitObjCStringLiteral(const ObjCStringLiteral *S) {
Douglas Gregor071f4eb2009-07-28 14:44:31 +0000982 VisitExpr(S);
983}
984
Ted Kremenekebcb57a2012-03-06 20:05:56 +0000985void StmtProfiler::VisitObjCNumericLiteral(const ObjCNumericLiteral *E) {
986 VisitExpr(E);
987}
988
989void StmtProfiler::VisitObjCArrayLiteral(const ObjCArrayLiteral *E) {
990 VisitExpr(E);
991}
992
993void StmtProfiler::VisitObjCDictionaryLiteral(const ObjCDictionaryLiteral *E) {
994 VisitExpr(E);
995}
996
Chandler Carruthb1138242011-06-16 06:47:06 +0000997void StmtProfiler::VisitObjCEncodeExpr(const ObjCEncodeExpr *S) {
Douglas Gregor071f4eb2009-07-28 14:44:31 +0000998 VisitExpr(S);
999 VisitType(S->getEncodedType());
1000}
1001
Chandler Carruthb1138242011-06-16 06:47:06 +00001002void StmtProfiler::VisitObjCSelectorExpr(const ObjCSelectorExpr *S) {
Douglas Gregor071f4eb2009-07-28 14:44:31 +00001003 VisitExpr(S);
1004 VisitName(S->getSelector());
1005}
1006
Chandler Carruthb1138242011-06-16 06:47:06 +00001007void StmtProfiler::VisitObjCProtocolExpr(const ObjCProtocolExpr *S) {
Douglas Gregor071f4eb2009-07-28 14:44:31 +00001008 VisitExpr(S);
1009 VisitDecl(S->getProtocol());
1010}
1011
Chandler Carruthb1138242011-06-16 06:47:06 +00001012void StmtProfiler::VisitObjCIvarRefExpr(const ObjCIvarRefExpr *S) {
Douglas Gregor071f4eb2009-07-28 14:44:31 +00001013 VisitExpr(S);
1014 VisitDecl(S->getDecl());
1015 ID.AddBoolean(S->isArrow());
1016 ID.AddBoolean(S->isFreeIvar());
1017}
1018
Chandler Carruthb1138242011-06-16 06:47:06 +00001019void StmtProfiler::VisitObjCPropertyRefExpr(const ObjCPropertyRefExpr *S) {
Douglas Gregor071f4eb2009-07-28 14:44:31 +00001020 VisitExpr(S);
John McCall12f78a62010-12-02 01:19:52 +00001021 if (S->isImplicitProperty()) {
1022 VisitDecl(S->getImplicitPropertyGetter());
1023 VisitDecl(S->getImplicitPropertySetter());
1024 } else {
1025 VisitDecl(S->getExplicitProperty());
Fariborz Jahanian8ac2d442010-10-14 16:04:05 +00001026 }
Fariborz Jahanian8ac2d442010-10-14 16:04:05 +00001027 if (S->isSuperReceiver()) {
1028 ID.AddBoolean(S->isSuperReceiver());
John McCall12f78a62010-12-02 01:19:52 +00001029 VisitType(S->getSuperReceiverType());
Fariborz Jahanian8ac2d442010-10-14 16:04:05 +00001030 }
Douglas Gregor071f4eb2009-07-28 14:44:31 +00001031}
1032
Ted Kremenekebcb57a2012-03-06 20:05:56 +00001033void StmtProfiler::VisitObjCSubscriptRefExpr(const ObjCSubscriptRefExpr *S) {
1034 VisitExpr(S);
1035 VisitDecl(S->getAtIndexMethodDecl());
1036 VisitDecl(S->setAtIndexMethodDecl());
1037}
1038
Chandler Carruthb1138242011-06-16 06:47:06 +00001039void StmtProfiler::VisitObjCMessageExpr(const ObjCMessageExpr *S) {
Douglas Gregor071f4eb2009-07-28 14:44:31 +00001040 VisitExpr(S);
1041 VisitName(S->getSelector());
1042 VisitDecl(S->getMethodDecl());
1043}
1044
Chandler Carruthb1138242011-06-16 06:47:06 +00001045void StmtProfiler::VisitObjCIsaExpr(const ObjCIsaExpr *S) {
Douglas Gregor071f4eb2009-07-28 14:44:31 +00001046 VisitExpr(S);
1047 ID.AddBoolean(S->isArrow());
1048}
1049
Ted Kremenekebcb57a2012-03-06 20:05:56 +00001050void StmtProfiler::VisitObjCBoolLiteralExpr(const ObjCBoolLiteralExpr *S) {
1051 VisitExpr(S);
1052 ID.AddBoolean(S->getValue());
1053}
1054
Chandler Carruthb1138242011-06-16 06:47:06 +00001055void StmtProfiler::VisitObjCIndirectCopyRestoreExpr(
1056 const ObjCIndirectCopyRestoreExpr *S) {
John McCallf85e1932011-06-15 23:02:42 +00001057 VisitExpr(S);
1058 ID.AddBoolean(S->shouldCopy());
1059}
1060
Chandler Carruthb1138242011-06-16 06:47:06 +00001061void StmtProfiler::VisitObjCBridgedCastExpr(const ObjCBridgedCastExpr *S) {
John McCallf85e1932011-06-15 23:02:42 +00001062 VisitExplicitCastExpr(S);
1063 ID.AddBoolean(S->getBridgeKind());
1064}
1065
Chandler Carruthb1138242011-06-16 06:47:06 +00001066void StmtProfiler::VisitDecl(const Decl *D) {
Douglas Gregor4a3f7802009-07-31 15:45:02 +00001067 ID.AddInteger(D? D->getKind() : 0);
Mike Stump1eb44332009-09-09 15:08:12 +00001068
Douglas Gregorb1975722009-07-30 23:18:24 +00001069 if (Canonical && D) {
Chandler Carruthb1138242011-06-16 06:47:06 +00001070 if (const NonTypeTemplateParmDecl *NTTP =
1071 dyn_cast<NonTypeTemplateParmDecl>(D)) {
Douglas Gregord584eb22009-07-28 15:32:17 +00001072 ID.AddInteger(NTTP->getDepth());
1073 ID.AddInteger(NTTP->getIndex());
Douglas Gregor61c4d282011-01-05 15:48:55 +00001074 ID.AddBoolean(NTTP->isParameterPack());
Douglas Gregor828e2262009-07-29 16:09:57 +00001075 VisitType(NTTP->getType());
Douglas Gregor41ef0c32009-07-28 00:33:38 +00001076 return;
1077 }
Mike Stump1eb44332009-09-09 15:08:12 +00001078
Chandler Carruthb1138242011-06-16 06:47:06 +00001079 if (const ParmVarDecl *Parm = dyn_cast<ParmVarDecl>(D)) {
John McCallfb44de92011-05-01 22:35:37 +00001080 // The Itanium C++ ABI uses the type, scope depth, and scope
1081 // index of a parameter when mangling expressions that involve
1082 // function parameters, so we will use the parameter's type for
1083 // establishing function parameter identity. That way, our
1084 // definition of "equivalent" (per C++ [temp.over.link]) is at
1085 // least as strong as the definition of "equivalent" used for
1086 // name mangling.
Douglas Gregor4a3f7802009-07-31 15:45:02 +00001087 VisitType(Parm->getType());
John McCallfb44de92011-05-01 22:35:37 +00001088 ID.AddInteger(Parm->getFunctionScopeDepth());
1089 ID.AddInteger(Parm->getFunctionScopeIndex());
Douglas Gregor4a3f7802009-07-31 15:45:02 +00001090 return;
1091 }
Mike Stump1eb44332009-09-09 15:08:12 +00001092
Chandler Carruthb1138242011-06-16 06:47:06 +00001093 if (const TemplateTemplateParmDecl *TTP =
1094 dyn_cast<TemplateTemplateParmDecl>(D)) {
Douglas Gregora2ffb982009-07-31 15:46:56 +00001095 ID.AddInteger(TTP->getDepth());
1096 ID.AddInteger(TTP->getIndex());
Douglas Gregor61c4d282011-01-05 15:48:55 +00001097 ID.AddBoolean(TTP->isParameterPack());
Douglas Gregora2ffb982009-07-31 15:46:56 +00001098 return;
1099 }
Douglas Gregor41ef0c32009-07-28 00:33:38 +00001100 }
Mike Stump1eb44332009-09-09 15:08:12 +00001101
Douglas Gregord584eb22009-07-28 15:32:17 +00001102 ID.AddPointer(D? D->getCanonicalDecl() : 0);
1103}
1104
1105void StmtProfiler::VisitType(QualType T) {
1106 if (Canonical)
1107 T = Context.getCanonicalType(T);
Mike Stump1eb44332009-09-09 15:08:12 +00001108
Douglas Gregor41ef0c32009-07-28 00:33:38 +00001109 ID.AddPointer(T.getAsOpaquePtr());
1110}
1111
1112void StmtProfiler::VisitName(DeclarationName Name) {
1113 ID.AddPointer(Name.getAsOpaquePtr());
1114}
1115
1116void StmtProfiler::VisitNestedNameSpecifier(NestedNameSpecifier *NNS) {
1117 if (Canonical)
1118 NNS = Context.getCanonicalNestedNameSpecifier(NNS);
1119 ID.AddPointer(NNS);
1120}
1121
1122void StmtProfiler::VisitTemplateName(TemplateName Name) {
1123 if (Canonical)
1124 Name = Context.getCanonicalTemplateName(Name);
Mike Stump1eb44332009-09-09 15:08:12 +00001125
Douglas Gregor41ef0c32009-07-28 00:33:38 +00001126 Name.Profile(ID);
1127}
1128
John McCall833ca992009-10-29 08:12:44 +00001129void StmtProfiler::VisitTemplateArguments(const TemplateArgumentLoc *Args,
Douglas Gregor41ef0c32009-07-28 00:33:38 +00001130 unsigned NumArgs) {
1131 ID.AddInteger(NumArgs);
John McCall833ca992009-10-29 08:12:44 +00001132 for (unsigned I = 0; I != NumArgs; ++I)
1133 VisitTemplateArgument(Args[I].getArgument());
1134}
Mike Stump1eb44332009-09-09 15:08:12 +00001135
John McCall833ca992009-10-29 08:12:44 +00001136void StmtProfiler::VisitTemplateArgument(const TemplateArgument &Arg) {
1137 // Mostly repetitive with TemplateArgument::Profile!
1138 ID.AddInteger(Arg.getKind());
1139 switch (Arg.getKind()) {
1140 case TemplateArgument::Null:
1141 break;
Mike Stump1eb44332009-09-09 15:08:12 +00001142
John McCall833ca992009-10-29 08:12:44 +00001143 case TemplateArgument::Type:
1144 VisitType(Arg.getAsType());
1145 break;
Mike Stump1eb44332009-09-09 15:08:12 +00001146
Douglas Gregor788cd062009-11-11 01:00:40 +00001147 case TemplateArgument::Template:
Douglas Gregora7fc9012011-01-05 18:58:31 +00001148 case TemplateArgument::TemplateExpansion:
1149 VisitTemplateName(Arg.getAsTemplateOrTemplatePattern());
Douglas Gregor788cd062009-11-11 01:00:40 +00001150 break;
Sean Huntc3021132010-05-05 15:23:54 +00001151
John McCall833ca992009-10-29 08:12:44 +00001152 case TemplateArgument::Declaration:
1153 VisitDecl(Arg.getAsDecl());
1154 break;
Mike Stump1eb44332009-09-09 15:08:12 +00001155
John McCall833ca992009-10-29 08:12:44 +00001156 case TemplateArgument::Integral:
1157 Arg.getAsIntegral()->Profile(ID);
1158 VisitType(Arg.getIntegralType());
1159 break;
Mike Stump1eb44332009-09-09 15:08:12 +00001160
John McCall833ca992009-10-29 08:12:44 +00001161 case TemplateArgument::Expression:
1162 Visit(Arg.getAsExpr());
1163 break;
Mike Stump1eb44332009-09-09 15:08:12 +00001164
John McCall833ca992009-10-29 08:12:44 +00001165 case TemplateArgument::Pack:
1166 const TemplateArgument *Pack = Arg.pack_begin();
1167 for (unsigned i = 0, e = Arg.pack_size(); i != e; ++i)
1168 VisitTemplateArgument(Pack[i]);
1169 break;
Douglas Gregor41ef0c32009-07-28 00:33:38 +00001170 }
1171}
1172
Jay Foad4ba2a172011-01-12 09:06:06 +00001173void Stmt::Profile(llvm::FoldingSetNodeID &ID, const ASTContext &Context,
Chandler Carruthb1138242011-06-16 06:47:06 +00001174 bool Canonical) const {
Douglas Gregor41ef0c32009-07-28 00:33:38 +00001175 StmtProfiler Profiler(ID, Context, Canonical);
1176 Profiler.Visit(this);
1177}