blob: 4bdded1d600a8766363a992df74364144e08571a [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
Richard Smith534986f2012-04-14 00:33:13 +0000112void StmtProfiler::VisitAttributedStmt(const AttributedStmt *S) {
113 VisitStmt(S);
114 // TODO: maybe visit attributes?
115}
116
Chandler Carruthb1138242011-06-16 06:47:06 +0000117void StmtProfiler::VisitIfStmt(const IfStmt *S) {
Douglas Gregor3fe81fc2009-07-28 15:27:13 +0000118 VisitStmt(S);
Douglas Gregor99e9b4d2009-11-25 00:27:52 +0000119 VisitDecl(S->getConditionVariable());
Douglas Gregor3fe81fc2009-07-28 15:27:13 +0000120}
121
Chandler Carruthb1138242011-06-16 06:47:06 +0000122void StmtProfiler::VisitSwitchStmt(const SwitchStmt *S) {
Douglas Gregor828e2262009-07-29 16:09:57 +0000123 VisitStmt(S);
Douglas Gregor99e9b4d2009-11-25 00:27:52 +0000124 VisitDecl(S->getConditionVariable());
Douglas Gregor828e2262009-07-29 16:09:57 +0000125}
126
Chandler Carruthb1138242011-06-16 06:47:06 +0000127void StmtProfiler::VisitWhileStmt(const WhileStmt *S) {
Douglas Gregor3fe81fc2009-07-28 15:27:13 +0000128 VisitStmt(S);
Douglas Gregor99e9b4d2009-11-25 00:27:52 +0000129 VisitDecl(S->getConditionVariable());
Douglas Gregor3fe81fc2009-07-28 15:27:13 +0000130}
131
Chandler Carruthb1138242011-06-16 06:47:06 +0000132void StmtProfiler::VisitDoStmt(const DoStmt *S) {
Douglas Gregor3fe81fc2009-07-28 15:27:13 +0000133 VisitStmt(S);
134}
135
Chandler Carruthb1138242011-06-16 06:47:06 +0000136void StmtProfiler::VisitForStmt(const ForStmt *S) {
Douglas Gregor3fe81fc2009-07-28 15:27:13 +0000137 VisitStmt(S);
138}
139
Chandler Carruthb1138242011-06-16 06:47:06 +0000140void StmtProfiler::VisitGotoStmt(const GotoStmt *S) {
Douglas Gregor3fe81fc2009-07-28 15:27:13 +0000141 VisitStmt(S);
Chris Lattnerad8dcf42011-02-17 07:39:24 +0000142 VisitDecl(S->getLabel());
Douglas Gregor3fe81fc2009-07-28 15:27:13 +0000143}
144
Chandler Carruthb1138242011-06-16 06:47:06 +0000145void StmtProfiler::VisitIndirectGotoStmt(const IndirectGotoStmt *S) {
Douglas Gregor3fe81fc2009-07-28 15:27:13 +0000146 VisitStmt(S);
147}
148
Chandler Carruthb1138242011-06-16 06:47:06 +0000149void StmtProfiler::VisitContinueStmt(const ContinueStmt *S) {
Douglas Gregor3fe81fc2009-07-28 15:27:13 +0000150 VisitStmt(S);
151}
152
Chandler Carruthb1138242011-06-16 06:47:06 +0000153void StmtProfiler::VisitBreakStmt(const BreakStmt *S) {
Douglas Gregor3fe81fc2009-07-28 15:27:13 +0000154 VisitStmt(S);
155}
156
Chandler Carruthb1138242011-06-16 06:47:06 +0000157void StmtProfiler::VisitReturnStmt(const ReturnStmt *S) {
Douglas Gregor3fe81fc2009-07-28 15:27:13 +0000158 VisitStmt(S);
159}
160
Chandler Carruthb1138242011-06-16 06:47:06 +0000161void StmtProfiler::VisitAsmStmt(const AsmStmt *S) {
Douglas Gregor3fe81fc2009-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)
178 VisitStringLiteral(S->getClobber(I));
179}
180
Chandler Carruthb1138242011-06-16 06:47:06 +0000181void StmtProfiler::VisitCXXCatchStmt(const CXXCatchStmt *S) {
Douglas Gregor3fe81fc2009-07-28 15:27:13 +0000182 VisitStmt(S);
183 VisitType(S->getCaughtType());
184}
185
Chandler Carruthb1138242011-06-16 06:47:06 +0000186void StmtProfiler::VisitCXXTryStmt(const CXXTryStmt *S) {
Douglas Gregor3fe81fc2009-07-28 15:27:13 +0000187 VisitStmt(S);
188}
189
Chandler Carruthb1138242011-06-16 06:47:06 +0000190void StmtProfiler::VisitCXXForRangeStmt(const CXXForRangeStmt *S) {
Richard Smithad762fc2011-04-14 22:09:26 +0000191 VisitStmt(S);
192}
193
Douglas Gregorba0513d2011-10-25 01:33:02 +0000194void StmtProfiler::VisitMSDependentExistsStmt(const MSDependentExistsStmt *S) {
195 VisitStmt(S);
196 ID.AddBoolean(S->isIfExists());
197 VisitNestedNameSpecifier(S->getQualifierLoc().getNestedNameSpecifier());
198 VisitName(S->getNameInfo().getName());
199}
200
Chandler Carruthb1138242011-06-16 06:47:06 +0000201void StmtProfiler::VisitSEHTryStmt(const SEHTryStmt *S) {
John Wiegley28bbe4b2011-04-28 01:08:34 +0000202 VisitStmt(S);
203}
204
Chandler Carruthb1138242011-06-16 06:47:06 +0000205void StmtProfiler::VisitSEHFinallyStmt(const SEHFinallyStmt *S) {
John Wiegley28bbe4b2011-04-28 01:08:34 +0000206 VisitStmt(S);
207}
208
Chandler Carruthb1138242011-06-16 06:47:06 +0000209void StmtProfiler::VisitSEHExceptStmt(const SEHExceptStmt *S) {
John Wiegley28bbe4b2011-04-28 01:08:34 +0000210 VisitStmt(S);
211}
212
Chandler Carruthb1138242011-06-16 06:47:06 +0000213void StmtProfiler::VisitObjCForCollectionStmt(const ObjCForCollectionStmt *S) {
Douglas Gregor3fe81fc2009-07-28 15:27:13 +0000214 VisitStmt(S);
215}
216
Chandler Carruthb1138242011-06-16 06:47:06 +0000217void StmtProfiler::VisitObjCAtCatchStmt(const ObjCAtCatchStmt *S) {
Douglas Gregor3fe81fc2009-07-28 15:27:13 +0000218 VisitStmt(S);
219 ID.AddBoolean(S->hasEllipsis());
220 if (S->getCatchParamDecl())
221 VisitType(S->getCatchParamDecl()->getType());
222}
223
Chandler Carruthb1138242011-06-16 06:47:06 +0000224void StmtProfiler::VisitObjCAtFinallyStmt(const ObjCAtFinallyStmt *S) {
Douglas Gregor3fe81fc2009-07-28 15:27:13 +0000225 VisitStmt(S);
226}
227
Chandler Carruthb1138242011-06-16 06:47:06 +0000228void StmtProfiler::VisitObjCAtTryStmt(const ObjCAtTryStmt *S) {
Douglas Gregor3fe81fc2009-07-28 15:27:13 +0000229 VisitStmt(S);
230}
231
Chandler Carruthb1138242011-06-16 06:47:06 +0000232void
233StmtProfiler::VisitObjCAtSynchronizedStmt(const ObjCAtSynchronizedStmt *S) {
Douglas Gregor3fe81fc2009-07-28 15:27:13 +0000234 VisitStmt(S);
235}
236
Chandler Carruthb1138242011-06-16 06:47:06 +0000237void StmtProfiler::VisitObjCAtThrowStmt(const ObjCAtThrowStmt *S) {
Douglas Gregor3fe81fc2009-07-28 15:27:13 +0000238 VisitStmt(S);
239}
240
Chandler Carruthb1138242011-06-16 06:47:06 +0000241void
242StmtProfiler::VisitObjCAutoreleasePoolStmt(const ObjCAutoreleasePoolStmt *S) {
John McCallf85e1932011-06-15 23:02:42 +0000243 VisitStmt(S);
244}
245
Chandler Carruthb1138242011-06-16 06:47:06 +0000246void StmtProfiler::VisitExpr(const Expr *S) {
Douglas Gregor41ef0c32009-07-28 00:33:38 +0000247 VisitStmt(S);
248}
249
Chandler Carruthb1138242011-06-16 06:47:06 +0000250void StmtProfiler::VisitDeclRefExpr(const DeclRefExpr *S) {
Douglas Gregor41ef0c32009-07-28 00:33:38 +0000251 VisitExpr(S);
Douglas Gregor218f47f2010-07-13 08:37:11 +0000252 if (!Canonical)
253 VisitNestedNameSpecifier(S->getQualifier());
Douglas Gregor41ef0c32009-07-28 00:33:38 +0000254 VisitDecl(S->getDecl());
Douglas Gregor218f47f2010-07-13 08:37:11 +0000255 if (!Canonical)
256 VisitTemplateArguments(S->getTemplateArgs(), S->getNumTemplateArgs());
Douglas Gregor41ef0c32009-07-28 00:33:38 +0000257}
258
Chandler Carruthb1138242011-06-16 06:47:06 +0000259void StmtProfiler::VisitPredefinedExpr(const PredefinedExpr *S) {
Douglas Gregor41ef0c32009-07-28 00:33:38 +0000260 VisitExpr(S);
261 ID.AddInteger(S->getIdentType());
262}
263
Chandler Carruthb1138242011-06-16 06:47:06 +0000264void StmtProfiler::VisitIntegerLiteral(const IntegerLiteral *S) {
Douglas Gregor41ef0c32009-07-28 00:33:38 +0000265 VisitExpr(S);
266 S->getValue().Profile(ID);
267}
268
Chandler Carruthb1138242011-06-16 06:47:06 +0000269void StmtProfiler::VisitCharacterLiteral(const CharacterLiteral *S) {
Douglas Gregor41ef0c32009-07-28 00:33:38 +0000270 VisitExpr(S);
Douglas Gregor5cee1192011-07-27 05:40:30 +0000271 ID.AddInteger(S->getKind());
Douglas Gregor41ef0c32009-07-28 00:33:38 +0000272 ID.AddInteger(S->getValue());
273}
274
Chandler Carruthb1138242011-06-16 06:47:06 +0000275void StmtProfiler::VisitFloatingLiteral(const FloatingLiteral *S) {
Douglas Gregor41ef0c32009-07-28 00:33:38 +0000276 VisitExpr(S);
277 S->getValue().Profile(ID);
278 ID.AddBoolean(S->isExact());
279}
280
Chandler Carruthb1138242011-06-16 06:47:06 +0000281void StmtProfiler::VisitImaginaryLiteral(const ImaginaryLiteral *S) {
Douglas Gregor41ef0c32009-07-28 00:33:38 +0000282 VisitExpr(S);
283}
284
Chandler Carruthb1138242011-06-16 06:47:06 +0000285void StmtProfiler::VisitStringLiteral(const StringLiteral *S) {
Douglas Gregor41ef0c32009-07-28 00:33:38 +0000286 VisitExpr(S);
Douglas Gregor38738fc2011-11-02 17:26:05 +0000287 ID.AddString(S->getBytes());
Douglas Gregor5cee1192011-07-27 05:40:30 +0000288 ID.AddInteger(S->getKind());
Douglas Gregor41ef0c32009-07-28 00:33:38 +0000289}
290
Chandler Carruthb1138242011-06-16 06:47:06 +0000291void StmtProfiler::VisitParenExpr(const ParenExpr *S) {
Douglas Gregor41ef0c32009-07-28 00:33:38 +0000292 VisitExpr(S);
293}
294
Chandler Carruthb1138242011-06-16 06:47:06 +0000295void StmtProfiler::VisitParenListExpr(const ParenListExpr *S) {
Nate Begeman2ef13e52009-08-10 23:49:36 +0000296 VisitExpr(S);
297}
298
Chandler Carruthb1138242011-06-16 06:47:06 +0000299void StmtProfiler::VisitUnaryOperator(const UnaryOperator *S) {
Douglas Gregor41ef0c32009-07-28 00:33:38 +0000300 VisitExpr(S);
301 ID.AddInteger(S->getOpcode());
302}
303
Chandler Carruthb1138242011-06-16 06:47:06 +0000304void StmtProfiler::VisitOffsetOfExpr(const OffsetOfExpr *S) {
Douglas Gregor8ecdb652010-04-28 22:16:22 +0000305 VisitType(S->getTypeSourceInfo()->getType());
306 unsigned n = S->getNumComponents();
307 for (unsigned i = 0; i < n; ++i) {
308 const OffsetOfExpr::OffsetOfNode& ON = S->getComponent(i);
309 ID.AddInteger(ON.getKind());
310 switch (ON.getKind()) {
311 case OffsetOfExpr::OffsetOfNode::Array:
312 // Expressions handled below.
313 break;
314
315 case OffsetOfExpr::OffsetOfNode::Field:
316 VisitDecl(ON.getField());
317 break;
318
319 case OffsetOfExpr::OffsetOfNode::Identifier:
320 ID.AddPointer(ON.getFieldName());
321 break;
Sean Huntc3021132010-05-05 15:23:54 +0000322
Douglas Gregorcc8a5d52010-04-29 00:18:15 +0000323 case OffsetOfExpr::OffsetOfNode::Base:
324 // These nodes are implicit, and therefore don't need profiling.
325 break;
Douglas Gregor8ecdb652010-04-28 22:16:22 +0000326 }
327 }
Sean Huntc3021132010-05-05 15:23:54 +0000328
Douglas Gregor8ecdb652010-04-28 22:16:22 +0000329 VisitExpr(S);
330}
331
Chandler Carruthb1138242011-06-16 06:47:06 +0000332void
333StmtProfiler::VisitUnaryExprOrTypeTraitExpr(const UnaryExprOrTypeTraitExpr *S) {
Douglas Gregor41ef0c32009-07-28 00:33:38 +0000334 VisitExpr(S);
Peter Collingbournef4e3cfb2011-03-11 19:24:49 +0000335 ID.AddInteger(S->getKind());
Douglas Gregor41ef0c32009-07-28 00:33:38 +0000336 if (S->isArgumentType())
337 VisitType(S->getArgumentType());
338}
339
Chandler Carruthb1138242011-06-16 06:47:06 +0000340void StmtProfiler::VisitArraySubscriptExpr(const ArraySubscriptExpr *S) {
Douglas Gregor41ef0c32009-07-28 00:33:38 +0000341 VisitExpr(S);
342}
343
Chandler Carruthb1138242011-06-16 06:47:06 +0000344void StmtProfiler::VisitCallExpr(const CallExpr *S) {
Douglas Gregor41ef0c32009-07-28 00:33:38 +0000345 VisitExpr(S);
346}
347
Chandler Carruthb1138242011-06-16 06:47:06 +0000348void StmtProfiler::VisitMemberExpr(const MemberExpr *S) {
Douglas Gregor41ef0c32009-07-28 00:33:38 +0000349 VisitExpr(S);
350 VisitDecl(S->getMemberDecl());
Douglas Gregor218f47f2010-07-13 08:37:11 +0000351 if (!Canonical)
352 VisitNestedNameSpecifier(S->getQualifier());
Douglas Gregor41ef0c32009-07-28 00:33:38 +0000353 ID.AddBoolean(S->isArrow());
354}
355
Chandler Carruthb1138242011-06-16 06:47:06 +0000356void StmtProfiler::VisitCompoundLiteralExpr(const CompoundLiteralExpr *S) {
Douglas Gregor41ef0c32009-07-28 00:33:38 +0000357 VisitExpr(S);
358 ID.AddBoolean(S->isFileScope());
359}
360
Chandler Carruthb1138242011-06-16 06:47:06 +0000361void StmtProfiler::VisitCastExpr(const CastExpr *S) {
Douglas Gregor41ef0c32009-07-28 00:33:38 +0000362 VisitExpr(S);
363}
364
Chandler Carruthb1138242011-06-16 06:47:06 +0000365void StmtProfiler::VisitImplicitCastExpr(const ImplicitCastExpr *S) {
Douglas Gregor41ef0c32009-07-28 00:33:38 +0000366 VisitCastExpr(S);
John McCall5baba9d2010-08-25 10:28:54 +0000367 ID.AddInteger(S->getValueKind());
Douglas Gregor41ef0c32009-07-28 00:33:38 +0000368}
369
Chandler Carruthb1138242011-06-16 06:47:06 +0000370void StmtProfiler::VisitExplicitCastExpr(const ExplicitCastExpr *S) {
Douglas Gregor41ef0c32009-07-28 00:33:38 +0000371 VisitCastExpr(S);
372 VisitType(S->getTypeAsWritten());
373}
374
Chandler Carruthb1138242011-06-16 06:47:06 +0000375void StmtProfiler::VisitCStyleCastExpr(const CStyleCastExpr *S) {
Douglas Gregor41ef0c32009-07-28 00:33:38 +0000376 VisitExplicitCastExpr(S);
377}
378
Chandler Carruthb1138242011-06-16 06:47:06 +0000379void StmtProfiler::VisitBinaryOperator(const BinaryOperator *S) {
Douglas Gregor41ef0c32009-07-28 00:33:38 +0000380 VisitExpr(S);
381 ID.AddInteger(S->getOpcode());
382}
383
Chandler Carruthb1138242011-06-16 06:47:06 +0000384void
385StmtProfiler::VisitCompoundAssignOperator(const CompoundAssignOperator *S) {
Douglas Gregor41ef0c32009-07-28 00:33:38 +0000386 VisitBinaryOperator(S);
387}
388
Chandler Carruthb1138242011-06-16 06:47:06 +0000389void StmtProfiler::VisitConditionalOperator(const ConditionalOperator *S) {
Douglas Gregor41ef0c32009-07-28 00:33:38 +0000390 VisitExpr(S);
391}
392
Chandler Carruthb1138242011-06-16 06:47:06 +0000393void StmtProfiler::VisitBinaryConditionalOperator(
Chandler Carruth08949762011-06-21 23:26:32 +0000394 const BinaryConditionalOperator *S) {
John McCall56ca35d2011-02-17 10:25:35 +0000395 VisitExpr(S);
396}
397
Chandler Carruthb1138242011-06-16 06:47:06 +0000398void StmtProfiler::VisitAddrLabelExpr(const AddrLabelExpr *S) {
Douglas Gregor41ef0c32009-07-28 00:33:38 +0000399 VisitExpr(S);
Chris Lattnerad8dcf42011-02-17 07:39:24 +0000400 VisitDecl(S->getLabel());
Douglas Gregor41ef0c32009-07-28 00:33:38 +0000401}
402
Chandler Carruthb1138242011-06-16 06:47:06 +0000403void StmtProfiler::VisitStmtExpr(const StmtExpr *S) {
Douglas Gregor41ef0c32009-07-28 00:33:38 +0000404 VisitExpr(S);
405}
406
Chandler Carruthb1138242011-06-16 06:47:06 +0000407void StmtProfiler::VisitShuffleVectorExpr(const ShuffleVectorExpr *S) {
Douglas Gregor41ef0c32009-07-28 00:33:38 +0000408 VisitExpr(S);
409}
410
Chandler Carruthb1138242011-06-16 06:47:06 +0000411void StmtProfiler::VisitChooseExpr(const ChooseExpr *S) {
Douglas Gregor41ef0c32009-07-28 00:33:38 +0000412 VisitExpr(S);
413}
414
Chandler Carruthb1138242011-06-16 06:47:06 +0000415void StmtProfiler::VisitGNUNullExpr(const GNUNullExpr *S) {
Douglas Gregor41ef0c32009-07-28 00:33:38 +0000416 VisitExpr(S);
417}
418
Chandler Carruthb1138242011-06-16 06:47:06 +0000419void StmtProfiler::VisitVAArgExpr(const VAArgExpr *S) {
Douglas Gregor828e2262009-07-29 16:09:57 +0000420 VisitExpr(S);
421}
422
Chandler Carruthb1138242011-06-16 06:47:06 +0000423void StmtProfiler::VisitInitListExpr(const InitListExpr *S) {
Douglas Gregor41ef0c32009-07-28 00:33:38 +0000424 if (S->getSyntacticForm()) {
425 VisitInitListExpr(S->getSyntacticForm());
426 return;
427 }
Mike Stump1eb44332009-09-09 15:08:12 +0000428
Douglas Gregor41ef0c32009-07-28 00:33:38 +0000429 VisitExpr(S);
430}
431
Chandler Carruthb1138242011-06-16 06:47:06 +0000432void StmtProfiler::VisitDesignatedInitExpr(const DesignatedInitExpr *S) {
Douglas Gregor41ef0c32009-07-28 00:33:38 +0000433 VisitExpr(S);
434 ID.AddBoolean(S->usesGNUSyntax());
Chandler Carruthb1138242011-06-16 06:47:06 +0000435 for (DesignatedInitExpr::const_designators_iterator D =
436 S->designators_begin(), DEnd = S->designators_end();
Douglas Gregor41ef0c32009-07-28 00:33:38 +0000437 D != DEnd; ++D) {
438 if (D->isFieldDesignator()) {
439 ID.AddInteger(0);
440 VisitName(D->getFieldName());
441 continue;
442 }
Mike Stump1eb44332009-09-09 15:08:12 +0000443
Douglas Gregor41ef0c32009-07-28 00:33:38 +0000444 if (D->isArrayDesignator()) {
445 ID.AddInteger(1);
446 } else {
447 assert(D->isArrayRangeDesignator());
448 ID.AddInteger(2);
449 }
450 ID.AddInteger(D->getFirstExprIndex());
451 }
452}
453
Chandler Carruthb1138242011-06-16 06:47:06 +0000454void StmtProfiler::VisitImplicitValueInitExpr(const ImplicitValueInitExpr *S) {
Douglas Gregor41ef0c32009-07-28 00:33:38 +0000455 VisitExpr(S);
456}
457
Chandler Carruthb1138242011-06-16 06:47:06 +0000458void StmtProfiler::VisitExtVectorElementExpr(const ExtVectorElementExpr *S) {
Douglas Gregor41ef0c32009-07-28 00:33:38 +0000459 VisitExpr(S);
460 VisitName(&S->getAccessor());
461}
462
Chandler Carruthb1138242011-06-16 06:47:06 +0000463void StmtProfiler::VisitBlockExpr(const BlockExpr *S) {
Douglas Gregor41ef0c32009-07-28 00:33:38 +0000464 VisitExpr(S);
465 VisitDecl(S->getBlockDecl());
466}
467
Chandler Carruthb1138242011-06-16 06:47:06 +0000468void StmtProfiler::VisitGenericSelectionExpr(const GenericSelectionExpr *S) {
Peter Collingbournef111d932011-04-15 00:35:48 +0000469 VisitExpr(S);
470 for (unsigned i = 0; i != S->getNumAssocs(); ++i) {
471 QualType T = S->getAssocType(i);
472 if (T.isNull())
473 ID.AddPointer(0);
474 else
475 VisitType(T);
476 VisitExpr(S->getAssocExpr(i));
477 }
478}
479
John McCall4b9c2d22011-11-06 09:01:30 +0000480void StmtProfiler::VisitPseudoObjectExpr(const PseudoObjectExpr *S) {
481 VisitExpr(S);
482 for (PseudoObjectExpr::const_semantics_iterator
483 i = S->semantics_begin(), e = S->semantics_end(); i != e; ++i)
484 // Normally, we would not profile the source expressions of OVEs.
485 if (const OpaqueValueExpr *OVE = dyn_cast<OpaqueValueExpr>(*i))
486 Visit(OVE->getSourceExpr());
487}
488
Eli Friedman276b0612011-10-11 02:20:01 +0000489void StmtProfiler::VisitAtomicExpr(const AtomicExpr *S) {
490 VisitExpr(S);
Eli Friedman2be46072011-10-14 20:59:01 +0000491 ID.AddInteger(S->getOp());
Eli Friedman276b0612011-10-11 02:20:01 +0000492}
493
Chandler Carruthb1138242011-06-16 06:47:06 +0000494static Stmt::StmtClass DecodeOperatorCall(const CXXOperatorCallExpr *S,
John McCall2de56d12010-08-25 11:45:40 +0000495 UnaryOperatorKind &UnaryOp,
496 BinaryOperatorKind &BinaryOp) {
Douglas Gregora89064a2010-05-19 04:13:23 +0000497 switch (S->getOperator()) {
498 case OO_None:
499 case OO_New:
500 case OO_Delete:
501 case OO_Array_New:
502 case OO_Array_Delete:
503 case OO_Arrow:
504 case OO_Call:
505 case OO_Conditional:
506 case NUM_OVERLOADED_OPERATORS:
507 llvm_unreachable("Invalid operator call kind");
Douglas Gregora89064a2010-05-19 04:13:23 +0000508
509 case OO_Plus:
510 if (S->getNumArgs() == 1) {
John McCall2de56d12010-08-25 11:45:40 +0000511 UnaryOp = UO_Plus;
Douglas Gregora89064a2010-05-19 04:13:23 +0000512 return Stmt::UnaryOperatorClass;
513 }
514
John McCall2de56d12010-08-25 11:45:40 +0000515 BinaryOp = BO_Add;
Douglas Gregora89064a2010-05-19 04:13:23 +0000516 return Stmt::BinaryOperatorClass;
517
518 case OO_Minus:
519 if (S->getNumArgs() == 1) {
John McCall2de56d12010-08-25 11:45:40 +0000520 UnaryOp = UO_Minus;
Douglas Gregora89064a2010-05-19 04:13:23 +0000521 return Stmt::UnaryOperatorClass;
522 }
523
John McCall2de56d12010-08-25 11:45:40 +0000524 BinaryOp = BO_Sub;
Douglas Gregora89064a2010-05-19 04:13:23 +0000525 return Stmt::BinaryOperatorClass;
526
527 case OO_Star:
528 if (S->getNumArgs() == 1) {
John McCall2de56d12010-08-25 11:45:40 +0000529 UnaryOp = UO_Minus;
Douglas Gregora89064a2010-05-19 04:13:23 +0000530 return Stmt::UnaryOperatorClass;
531 }
532
John McCall2de56d12010-08-25 11:45:40 +0000533 BinaryOp = BO_Sub;
Douglas Gregora89064a2010-05-19 04:13:23 +0000534 return Stmt::BinaryOperatorClass;
535
536 case OO_Slash:
John McCall2de56d12010-08-25 11:45:40 +0000537 BinaryOp = BO_Div;
Douglas Gregora89064a2010-05-19 04:13:23 +0000538 return Stmt::BinaryOperatorClass;
539
540 case OO_Percent:
John McCall2de56d12010-08-25 11:45:40 +0000541 BinaryOp = BO_Rem;
Douglas Gregora89064a2010-05-19 04:13:23 +0000542 return Stmt::BinaryOperatorClass;
543
544 case OO_Caret:
John McCall2de56d12010-08-25 11:45:40 +0000545 BinaryOp = BO_Xor;
Douglas Gregora89064a2010-05-19 04:13:23 +0000546 return Stmt::BinaryOperatorClass;
547
548 case OO_Amp:
549 if (S->getNumArgs() == 1) {
John McCall2de56d12010-08-25 11:45:40 +0000550 UnaryOp = UO_AddrOf;
Douglas Gregora89064a2010-05-19 04:13:23 +0000551 return Stmt::UnaryOperatorClass;
552 }
553
John McCall2de56d12010-08-25 11:45:40 +0000554 BinaryOp = BO_And;
Douglas Gregora89064a2010-05-19 04:13:23 +0000555 return Stmt::BinaryOperatorClass;
556
557 case OO_Pipe:
John McCall2de56d12010-08-25 11:45:40 +0000558 BinaryOp = BO_Or;
Douglas Gregora89064a2010-05-19 04:13:23 +0000559 return Stmt::BinaryOperatorClass;
560
561 case OO_Tilde:
John McCall2de56d12010-08-25 11:45:40 +0000562 UnaryOp = UO_Not;
Douglas Gregora89064a2010-05-19 04:13:23 +0000563 return Stmt::UnaryOperatorClass;
564
565 case OO_Exclaim:
John McCall2de56d12010-08-25 11:45:40 +0000566 UnaryOp = UO_LNot;
Douglas Gregora89064a2010-05-19 04:13:23 +0000567 return Stmt::UnaryOperatorClass;
568
569 case OO_Equal:
John McCall2de56d12010-08-25 11:45:40 +0000570 BinaryOp = BO_Assign;
Douglas Gregora89064a2010-05-19 04:13:23 +0000571 return Stmt::BinaryOperatorClass;
572
573 case OO_Less:
John McCall2de56d12010-08-25 11:45:40 +0000574 BinaryOp = BO_LT;
Douglas Gregora89064a2010-05-19 04:13:23 +0000575 return Stmt::BinaryOperatorClass;
576
577 case OO_Greater:
John McCall2de56d12010-08-25 11:45:40 +0000578 BinaryOp = BO_GT;
Douglas Gregora89064a2010-05-19 04:13:23 +0000579 return Stmt::BinaryOperatorClass;
580
581 case OO_PlusEqual:
John McCall2de56d12010-08-25 11:45:40 +0000582 BinaryOp = BO_AddAssign;
Douglas Gregora89064a2010-05-19 04:13:23 +0000583 return Stmt::CompoundAssignOperatorClass;
584
585 case OO_MinusEqual:
John McCall2de56d12010-08-25 11:45:40 +0000586 BinaryOp = BO_SubAssign;
Douglas Gregora89064a2010-05-19 04:13:23 +0000587 return Stmt::CompoundAssignOperatorClass;
588
589 case OO_StarEqual:
John McCall2de56d12010-08-25 11:45:40 +0000590 BinaryOp = BO_MulAssign;
Douglas Gregora89064a2010-05-19 04:13:23 +0000591 return Stmt::CompoundAssignOperatorClass;
592
593 case OO_SlashEqual:
John McCall2de56d12010-08-25 11:45:40 +0000594 BinaryOp = BO_DivAssign;
Douglas Gregora89064a2010-05-19 04:13:23 +0000595 return Stmt::CompoundAssignOperatorClass;
596
597 case OO_PercentEqual:
John McCall2de56d12010-08-25 11:45:40 +0000598 BinaryOp = BO_RemAssign;
Douglas Gregora89064a2010-05-19 04:13:23 +0000599 return Stmt::CompoundAssignOperatorClass;
600
601 case OO_CaretEqual:
John McCall2de56d12010-08-25 11:45:40 +0000602 BinaryOp = BO_XorAssign;
Douglas Gregora89064a2010-05-19 04:13:23 +0000603 return Stmt::CompoundAssignOperatorClass;
604
605 case OO_AmpEqual:
John McCall2de56d12010-08-25 11:45:40 +0000606 BinaryOp = BO_AndAssign;
Douglas Gregora89064a2010-05-19 04:13:23 +0000607 return Stmt::CompoundAssignOperatorClass;
608
609 case OO_PipeEqual:
John McCall2de56d12010-08-25 11:45:40 +0000610 BinaryOp = BO_OrAssign;
Douglas Gregora89064a2010-05-19 04:13:23 +0000611 return Stmt::CompoundAssignOperatorClass;
612
613 case OO_LessLess:
John McCall2de56d12010-08-25 11:45:40 +0000614 BinaryOp = BO_Shl;
Douglas Gregora89064a2010-05-19 04:13:23 +0000615 return Stmt::BinaryOperatorClass;
616
617 case OO_GreaterGreater:
John McCall2de56d12010-08-25 11:45:40 +0000618 BinaryOp = BO_Shr;
Douglas Gregora89064a2010-05-19 04:13:23 +0000619 return Stmt::BinaryOperatorClass;
620
621 case OO_LessLessEqual:
John McCall2de56d12010-08-25 11:45:40 +0000622 BinaryOp = BO_ShlAssign;
Douglas Gregora89064a2010-05-19 04:13:23 +0000623 return Stmt::CompoundAssignOperatorClass;
624
625 case OO_GreaterGreaterEqual:
John McCall2de56d12010-08-25 11:45:40 +0000626 BinaryOp = BO_ShrAssign;
Douglas Gregora89064a2010-05-19 04:13:23 +0000627 return Stmt::CompoundAssignOperatorClass;
628
629 case OO_EqualEqual:
John McCall2de56d12010-08-25 11:45:40 +0000630 BinaryOp = BO_EQ;
Douglas Gregora89064a2010-05-19 04:13:23 +0000631 return Stmt::BinaryOperatorClass;
632
633 case OO_ExclaimEqual:
John McCall2de56d12010-08-25 11:45:40 +0000634 BinaryOp = BO_NE;
Douglas Gregora89064a2010-05-19 04:13:23 +0000635 return Stmt::BinaryOperatorClass;
636
637 case OO_LessEqual:
John McCall2de56d12010-08-25 11:45:40 +0000638 BinaryOp = BO_LE;
Douglas Gregora89064a2010-05-19 04:13:23 +0000639 return Stmt::BinaryOperatorClass;
640
641 case OO_GreaterEqual:
John McCall2de56d12010-08-25 11:45:40 +0000642 BinaryOp = BO_GE;
Douglas Gregora89064a2010-05-19 04:13:23 +0000643 return Stmt::BinaryOperatorClass;
644
645 case OO_AmpAmp:
John McCall2de56d12010-08-25 11:45:40 +0000646 BinaryOp = BO_LAnd;
Douglas Gregora89064a2010-05-19 04:13:23 +0000647 return Stmt::BinaryOperatorClass;
648
649 case OO_PipePipe:
John McCall2de56d12010-08-25 11:45:40 +0000650 BinaryOp = BO_LOr;
Douglas Gregora89064a2010-05-19 04:13:23 +0000651 return Stmt::BinaryOperatorClass;
652
653 case OO_PlusPlus:
John McCall2de56d12010-08-25 11:45:40 +0000654 UnaryOp = S->getNumArgs() == 1? UO_PreInc
655 : UO_PostInc;
Douglas Gregora89064a2010-05-19 04:13:23 +0000656 return Stmt::UnaryOperatorClass;
657
658 case OO_MinusMinus:
John McCall2de56d12010-08-25 11:45:40 +0000659 UnaryOp = S->getNumArgs() == 1? UO_PreDec
660 : UO_PostDec;
Douglas Gregora89064a2010-05-19 04:13:23 +0000661 return Stmt::UnaryOperatorClass;
662
663 case OO_Comma:
John McCall2de56d12010-08-25 11:45:40 +0000664 BinaryOp = BO_Comma;
Douglas Gregora89064a2010-05-19 04:13:23 +0000665 return Stmt::BinaryOperatorClass;
666
667
668 case OO_ArrowStar:
John McCall2de56d12010-08-25 11:45:40 +0000669 BinaryOp = BO_PtrMemI;
Douglas Gregora89064a2010-05-19 04:13:23 +0000670 return Stmt::BinaryOperatorClass;
671
672 case OO_Subscript:
673 return Stmt::ArraySubscriptExprClass;
674 }
675
676 llvm_unreachable("Invalid overloaded operator expression");
677}
678
679
Chandler Carruthb1138242011-06-16 06:47:06 +0000680void StmtProfiler::VisitCXXOperatorCallExpr(const CXXOperatorCallExpr *S) {
Douglas Gregora89064a2010-05-19 04:13:23 +0000681 if (S->isTypeDependent()) {
682 // Type-dependent operator calls are profiled like their underlying
683 // syntactic operator.
John McCall2de56d12010-08-25 11:45:40 +0000684 UnaryOperatorKind UnaryOp = UO_Extension;
685 BinaryOperatorKind BinaryOp = BO_Comma;
Douglas Gregora89064a2010-05-19 04:13:23 +0000686 Stmt::StmtClass SC = DecodeOperatorCall(S, UnaryOp, BinaryOp);
687
688 ID.AddInteger(SC);
689 for (unsigned I = 0, N = S->getNumArgs(); I != N; ++I)
690 Visit(S->getArg(I));
691 if (SC == Stmt::UnaryOperatorClass)
692 ID.AddInteger(UnaryOp);
693 else if (SC == Stmt::BinaryOperatorClass ||
694 SC == Stmt::CompoundAssignOperatorClass)
695 ID.AddInteger(BinaryOp);
696 else
697 assert(SC == Stmt::ArraySubscriptExprClass);
698
699 return;
700 }
701
Douglas Gregor41ef0c32009-07-28 00:33:38 +0000702 VisitCallExpr(S);
703 ID.AddInteger(S->getOperator());
704}
705
Chandler Carruthb1138242011-06-16 06:47:06 +0000706void StmtProfiler::VisitCXXMemberCallExpr(const CXXMemberCallExpr *S) {
Douglas Gregor41ef0c32009-07-28 00:33:38 +0000707 VisitCallExpr(S);
708}
709
Chandler Carruthb1138242011-06-16 06:47:06 +0000710void StmtProfiler::VisitCUDAKernelCallExpr(const CUDAKernelCallExpr *S) {
Peter Collingbournee08ce652011-02-09 21:07:24 +0000711 VisitCallExpr(S);
712}
713
Chandler Carruthb1138242011-06-16 06:47:06 +0000714void StmtProfiler::VisitAsTypeExpr(const AsTypeExpr *S) {
Tanya Lattner61eee0c2011-06-04 00:47:47 +0000715 VisitExpr(S);
716}
717
Chandler Carruthb1138242011-06-16 06:47:06 +0000718void StmtProfiler::VisitCXXNamedCastExpr(const CXXNamedCastExpr *S) {
Douglas Gregor41ef0c32009-07-28 00:33:38 +0000719 VisitExplicitCastExpr(S);
720}
721
Chandler Carruthb1138242011-06-16 06:47:06 +0000722void StmtProfiler::VisitCXXStaticCastExpr(const CXXStaticCastExpr *S) {
Douglas Gregor41ef0c32009-07-28 00:33:38 +0000723 VisitCXXNamedCastExpr(S);
724}
725
Chandler Carruthb1138242011-06-16 06:47:06 +0000726void StmtProfiler::VisitCXXDynamicCastExpr(const CXXDynamicCastExpr *S) {
Douglas Gregor41ef0c32009-07-28 00:33:38 +0000727 VisitCXXNamedCastExpr(S);
728}
729
Chandler Carruthb1138242011-06-16 06:47:06 +0000730void
731StmtProfiler::VisitCXXReinterpretCastExpr(const CXXReinterpretCastExpr *S) {
Douglas Gregor41ef0c32009-07-28 00:33:38 +0000732 VisitCXXNamedCastExpr(S);
733}
734
Chandler Carruthb1138242011-06-16 06:47:06 +0000735void StmtProfiler::VisitCXXConstCastExpr(const CXXConstCastExpr *S) {
Douglas Gregor41ef0c32009-07-28 00:33:38 +0000736 VisitCXXNamedCastExpr(S);
737}
738
Richard Smith9fcce652012-03-07 08:35:16 +0000739void StmtProfiler::VisitUserDefinedLiteral(const UserDefinedLiteral *S) {
740 VisitCallExpr(S);
741}
742
Chandler Carruthb1138242011-06-16 06:47:06 +0000743void StmtProfiler::VisitCXXBoolLiteralExpr(const CXXBoolLiteralExpr *S) {
Douglas Gregor41ef0c32009-07-28 00:33:38 +0000744 VisitExpr(S);
745 ID.AddBoolean(S->getValue());
746}
747
Chandler Carruthb1138242011-06-16 06:47:06 +0000748void StmtProfiler::VisitCXXNullPtrLiteralExpr(const CXXNullPtrLiteralExpr *S) {
Douglas Gregor828e2262009-07-29 16:09:57 +0000749 VisitExpr(S);
750}
751
Chandler Carruthb1138242011-06-16 06:47:06 +0000752void StmtProfiler::VisitCXXTypeidExpr(const CXXTypeidExpr *S) {
Douglas Gregor41ef0c32009-07-28 00:33:38 +0000753 VisitExpr(S);
754 if (S->isTypeOperand())
755 VisitType(S->getTypeOperand());
756}
757
Chandler Carruthb1138242011-06-16 06:47:06 +0000758void StmtProfiler::VisitCXXUuidofExpr(const CXXUuidofExpr *S) {
Francois Pichet01b7c302010-09-08 12:20:18 +0000759 VisitExpr(S);
760 if (S->isTypeOperand())
761 VisitType(S->getTypeOperand());
762}
763
Chandler Carruthb1138242011-06-16 06:47:06 +0000764void StmtProfiler::VisitCXXThisExpr(const CXXThisExpr *S) {
Douglas Gregor41ef0c32009-07-28 00:33:38 +0000765 VisitExpr(S);
766}
767
Chandler Carruthb1138242011-06-16 06:47:06 +0000768void StmtProfiler::VisitCXXThrowExpr(const CXXThrowExpr *S) {
Douglas Gregor41ef0c32009-07-28 00:33:38 +0000769 VisitExpr(S);
770}
771
Chandler Carruthb1138242011-06-16 06:47:06 +0000772void StmtProfiler::VisitCXXDefaultArgExpr(const CXXDefaultArgExpr *S) {
Douglas Gregor41ef0c32009-07-28 00:33:38 +0000773 VisitExpr(S);
774 VisitDecl(S->getParam());
775}
776
Chandler Carruthb1138242011-06-16 06:47:06 +0000777void StmtProfiler::VisitCXXBindTemporaryExpr(const CXXBindTemporaryExpr *S) {
Douglas Gregor41ef0c32009-07-28 00:33:38 +0000778 VisitExpr(S);
779 VisitDecl(
780 const_cast<CXXDestructorDecl *>(S->getTemporary()->getDestructor()));
781}
782
Chandler Carruthb1138242011-06-16 06:47:06 +0000783void StmtProfiler::VisitCXXConstructExpr(const CXXConstructExpr *S) {
Douglas Gregor41ef0c32009-07-28 00:33:38 +0000784 VisitExpr(S);
785 VisitDecl(S->getConstructor());
786 ID.AddBoolean(S->isElidable());
787}
788
Chandler Carruthb1138242011-06-16 06:47:06 +0000789void StmtProfiler::VisitCXXFunctionalCastExpr(const CXXFunctionalCastExpr *S) {
Douglas Gregor41ef0c32009-07-28 00:33:38 +0000790 VisitExplicitCastExpr(S);
791}
792
Chandler Carruthb1138242011-06-16 06:47:06 +0000793void
794StmtProfiler::VisitCXXTemporaryObjectExpr(const CXXTemporaryObjectExpr *S) {
Douglas Gregor41ef0c32009-07-28 00:33:38 +0000795 VisitCXXConstructExpr(S);
796}
797
Chandler Carruthb1138242011-06-16 06:47:06 +0000798void
Douglas Gregor01d08012012-02-07 10:09:13 +0000799StmtProfiler::VisitLambdaExpr(const LambdaExpr *S) {
800 VisitExpr(S);
801 for (LambdaExpr::capture_iterator C = S->explicit_capture_begin(),
802 CEnd = S->explicit_capture_end();
803 C != CEnd; ++C) {
804 ID.AddInteger(C->getCaptureKind());
805 if (C->capturesVariable()) {
806 VisitDecl(C->getCapturedVar());
807 ID.AddBoolean(C->isPackExpansion());
808 }
809 }
810 // Note: If we actually needed to be able to match lambda
811 // expressions, we would have to consider parameters and return type
812 // here, among other things.
813 VisitStmt(S->getBody());
814}
815
816void
Chandler Carruthb1138242011-06-16 06:47:06 +0000817StmtProfiler::VisitCXXScalarValueInitExpr(const CXXScalarValueInitExpr *S) {
Douglas Gregor41ef0c32009-07-28 00:33:38 +0000818 VisitExpr(S);
819}
820
Chandler Carruthb1138242011-06-16 06:47:06 +0000821void StmtProfiler::VisitCXXDeleteExpr(const CXXDeleteExpr *S) {
Douglas Gregor41ef0c32009-07-28 00:33:38 +0000822 VisitExpr(S);
823 ID.AddBoolean(S->isGlobalDelete());
824 ID.AddBoolean(S->isArrayForm());
825 VisitDecl(S->getOperatorDelete());
826}
827
828
Chandler Carruthb1138242011-06-16 06:47:06 +0000829void StmtProfiler::VisitCXXNewExpr(const CXXNewExpr *S) {
Douglas Gregor41ef0c32009-07-28 00:33:38 +0000830 VisitExpr(S);
831 VisitType(S->getAllocatedType());
832 VisitDecl(S->getOperatorNew());
833 VisitDecl(S->getOperatorDelete());
Douglas Gregor41ef0c32009-07-28 00:33:38 +0000834 ID.AddBoolean(S->isArray());
835 ID.AddInteger(S->getNumPlacementArgs());
836 ID.AddBoolean(S->isGlobalNew());
837 ID.AddBoolean(S->isParenTypeId());
Sebastian Redl2aed8b82012-02-16 12:22:20 +0000838 ID.AddInteger(S->getInitializationStyle());
Douglas Gregor41ef0c32009-07-28 00:33:38 +0000839}
840
Chandler Carruthb1138242011-06-16 06:47:06 +0000841void
842StmtProfiler::VisitCXXPseudoDestructorExpr(const CXXPseudoDestructorExpr *S) {
Douglas Gregora71d8192009-09-04 17:36:40 +0000843 VisitExpr(S);
844 ID.AddBoolean(S->isArrow());
845 VisitNestedNameSpecifier(S->getQualifier());
846 VisitType(S->getDestroyedType());
847}
848
Chandler Carruthb1138242011-06-16 06:47:06 +0000849void StmtProfiler::VisitOverloadExpr(const OverloadExpr *S) {
Argyrios Kyrtzidis7b3e3f62010-08-15 20:53:20 +0000850 VisitExpr(S);
John McCallf7a1a742009-11-24 19:00:30 +0000851 VisitNestedNameSpecifier(S->getQualifier());
Douglas Gregor41ef0c32009-07-28 00:33:38 +0000852 VisitName(S->getName());
John McCallf7a1a742009-11-24 19:00:30 +0000853 ID.AddBoolean(S->hasExplicitTemplateArgs());
854 if (S->hasExplicitTemplateArgs())
Argyrios Kyrtzidisc35919b2010-08-15 01:15:38 +0000855 VisitTemplateArguments(S->getExplicitTemplateArgs().getTemplateArgs(),
856 S->getExplicitTemplateArgs().NumTemplateArgs);
857}
858
859void
Chandler Carruthb1138242011-06-16 06:47:06 +0000860StmtProfiler::VisitUnresolvedLookupExpr(const UnresolvedLookupExpr *S) {
Argyrios Kyrtzidisc35919b2010-08-15 01:15:38 +0000861 VisitOverloadExpr(S);
Douglas Gregor41ef0c32009-07-28 00:33:38 +0000862}
863
Chandler Carruthb1138242011-06-16 06:47:06 +0000864void StmtProfiler::VisitUnaryTypeTraitExpr(const UnaryTypeTraitExpr *S) {
Douglas Gregor41ef0c32009-07-28 00:33:38 +0000865 VisitExpr(S);
866 ID.AddInteger(S->getTrait());
867 VisitType(S->getQueriedType());
868}
869
Chandler Carruthb1138242011-06-16 06:47:06 +0000870void StmtProfiler::VisitBinaryTypeTraitExpr(const BinaryTypeTraitExpr *S) {
Francois Pichet6ad6f282010-12-07 00:08:36 +0000871 VisitExpr(S);
872 ID.AddInteger(S->getTrait());
873 VisitType(S->getLhsType());
874 VisitType(S->getRhsType());
875}
876
Douglas Gregor4ca8ac22012-02-24 07:38:34 +0000877void StmtProfiler::VisitTypeTraitExpr(const TypeTraitExpr *S) {
878 VisitExpr(S);
879 ID.AddInteger(S->getTrait());
880 ID.AddInteger(S->getNumArgs());
881 for (unsigned I = 0, N = S->getNumArgs(); I != N; ++I)
882 VisitType(S->getArg(I)->getType());
883}
884
Chandler Carruthb1138242011-06-16 06:47:06 +0000885void StmtProfiler::VisitArrayTypeTraitExpr(const ArrayTypeTraitExpr *S) {
John Wiegley21ff2e52011-04-28 00:16:57 +0000886 VisitExpr(S);
887 ID.AddInteger(S->getTrait());
888 VisitType(S->getQueriedType());
889}
890
Chandler Carruthb1138242011-06-16 06:47:06 +0000891void StmtProfiler::VisitExpressionTraitExpr(const ExpressionTraitExpr *S) {
John Wiegley55262202011-04-25 06:54:41 +0000892 VisitExpr(S);
893 ID.AddInteger(S->getTrait());
894 VisitExpr(S->getQueriedExpression());
895}
896
Chandler Carruthb1138242011-06-16 06:47:06 +0000897void StmtProfiler::VisitDependentScopeDeclRefExpr(
898 const DependentScopeDeclRefExpr *S) {
Douglas Gregor41ef0c32009-07-28 00:33:38 +0000899 VisitExpr(S);
900 VisitName(S->getDeclName());
901 VisitNestedNameSpecifier(S->getQualifier());
John McCallf7a1a742009-11-24 19:00:30 +0000902 ID.AddBoolean(S->hasExplicitTemplateArgs());
903 if (S->hasExplicitTemplateArgs())
904 VisitTemplateArguments(S->getTemplateArgs(), S->getNumTemplateArgs());
Douglas Gregor41ef0c32009-07-28 00:33:38 +0000905}
906
Chandler Carruthb1138242011-06-16 06:47:06 +0000907void StmtProfiler::VisitExprWithCleanups(const ExprWithCleanups *S) {
Douglas Gregor071f4eb2009-07-28 14:44:31 +0000908 VisitExpr(S);
Douglas Gregor071f4eb2009-07-28 14:44:31 +0000909}
910
Chandler Carruthb1138242011-06-16 06:47:06 +0000911void StmtProfiler::VisitCXXUnresolvedConstructExpr(
912 const CXXUnresolvedConstructExpr *S) {
Douglas Gregor071f4eb2009-07-28 14:44:31 +0000913 VisitExpr(S);
914 VisitType(S->getTypeAsWritten());
915}
916
Chandler Carruthb1138242011-06-16 06:47:06 +0000917void StmtProfiler::VisitCXXDependentScopeMemberExpr(
918 const CXXDependentScopeMemberExpr *S) {
John McCallaa81e162009-12-01 22:10:20 +0000919 ID.AddBoolean(S->isImplicitAccess());
920 if (!S->isImplicitAccess()) {
921 VisitExpr(S);
922 ID.AddBoolean(S->isArrow());
923 }
Douglas Gregora38c6872009-09-03 16:14:30 +0000924 VisitNestedNameSpecifier(S->getQualifier());
Douglas Gregor071f4eb2009-07-28 14:44:31 +0000925 VisitName(S->getMember());
John McCallaa81e162009-12-01 22:10:20 +0000926 ID.AddBoolean(S->hasExplicitTemplateArgs());
927 if (S->hasExplicitTemplateArgs())
John McCall129e2df2009-11-30 22:42:35 +0000928 VisitTemplateArguments(S->getTemplateArgs(), S->getNumTemplateArgs());
929}
930
Chandler Carruthb1138242011-06-16 06:47:06 +0000931void StmtProfiler::VisitUnresolvedMemberExpr(const UnresolvedMemberExpr *S) {
John McCallaa81e162009-12-01 22:10:20 +0000932 ID.AddBoolean(S->isImplicitAccess());
933 if (!S->isImplicitAccess()) {
934 VisitExpr(S);
935 ID.AddBoolean(S->isArrow());
936 }
John McCall129e2df2009-11-30 22:42:35 +0000937 VisitNestedNameSpecifier(S->getQualifier());
938 VisitName(S->getMemberName());
939 ID.AddBoolean(S->hasExplicitTemplateArgs());
940 if (S->hasExplicitTemplateArgs())
941 VisitTemplateArguments(S->getTemplateArgs(), S->getNumTemplateArgs());
Douglas Gregor071f4eb2009-07-28 14:44:31 +0000942}
943
Chandler Carruthb1138242011-06-16 06:47:06 +0000944void StmtProfiler::VisitCXXNoexceptExpr(const CXXNoexceptExpr *S) {
Sebastian Redl2e156222010-09-10 20:55:43 +0000945 VisitExpr(S);
946}
947
Chandler Carruthb1138242011-06-16 06:47:06 +0000948void StmtProfiler::VisitPackExpansionExpr(const PackExpansionExpr *S) {
Douglas Gregorbe230c32011-01-03 17:17:50 +0000949 VisitExpr(S);
950}
951
Chandler Carruthb1138242011-06-16 06:47:06 +0000952void StmtProfiler::VisitSizeOfPackExpr(const SizeOfPackExpr *S) {
Douglas Gregoree8aff02011-01-04 17:33:58 +0000953 VisitExpr(S);
954 VisitDecl(S->getPack());
955}
956
Douglas Gregorc7793c72011-01-15 01:15:58 +0000957void StmtProfiler::VisitSubstNonTypeTemplateParmPackExpr(
Chandler Carruthb1138242011-06-16 06:47:06 +0000958 const SubstNonTypeTemplateParmPackExpr *S) {
Douglas Gregorc7793c72011-01-15 01:15:58 +0000959 VisitExpr(S);
960 VisitDecl(S->getParameterPack());
961 VisitTemplateArgument(S->getArgumentPack());
962}
963
John McCall91a57552011-07-15 05:09:51 +0000964void StmtProfiler::VisitSubstNonTypeTemplateParmExpr(
965 const SubstNonTypeTemplateParmExpr *E) {
966 // Profile exactly as the replacement expression.
967 Visit(E->getReplacement());
968}
969
Douglas Gregor03e80032011-06-21 17:03:29 +0000970void StmtProfiler::VisitMaterializeTemporaryExpr(
971 const MaterializeTemporaryExpr *S) {
972 VisitExpr(S);
973}
974
Chandler Carruthb1138242011-06-16 06:47:06 +0000975void StmtProfiler::VisitOpaqueValueExpr(const OpaqueValueExpr *E) {
John McCall7cd7d1a2010-11-15 23:31:06 +0000976 VisitExpr(E);
977}
978
Chandler Carruthb1138242011-06-16 06:47:06 +0000979void StmtProfiler::VisitObjCStringLiteral(const ObjCStringLiteral *S) {
Douglas Gregor071f4eb2009-07-28 14:44:31 +0000980 VisitExpr(S);
981}
982
Ted Kremenekebcb57a2012-03-06 20:05:56 +0000983void StmtProfiler::VisitObjCNumericLiteral(const ObjCNumericLiteral *E) {
984 VisitExpr(E);
985}
986
987void StmtProfiler::VisitObjCArrayLiteral(const ObjCArrayLiteral *E) {
988 VisitExpr(E);
989}
990
991void StmtProfiler::VisitObjCDictionaryLiteral(const ObjCDictionaryLiteral *E) {
992 VisitExpr(E);
993}
994
Chandler Carruthb1138242011-06-16 06:47:06 +0000995void StmtProfiler::VisitObjCEncodeExpr(const ObjCEncodeExpr *S) {
Douglas Gregor071f4eb2009-07-28 14:44:31 +0000996 VisitExpr(S);
997 VisitType(S->getEncodedType());
998}
999
Chandler Carruthb1138242011-06-16 06:47:06 +00001000void StmtProfiler::VisitObjCSelectorExpr(const ObjCSelectorExpr *S) {
Douglas Gregor071f4eb2009-07-28 14:44:31 +00001001 VisitExpr(S);
1002 VisitName(S->getSelector());
1003}
1004
Chandler Carruthb1138242011-06-16 06:47:06 +00001005void StmtProfiler::VisitObjCProtocolExpr(const ObjCProtocolExpr *S) {
Douglas Gregor071f4eb2009-07-28 14:44:31 +00001006 VisitExpr(S);
1007 VisitDecl(S->getProtocol());
1008}
1009
Chandler Carruthb1138242011-06-16 06:47:06 +00001010void StmtProfiler::VisitObjCIvarRefExpr(const ObjCIvarRefExpr *S) {
Douglas Gregor071f4eb2009-07-28 14:44:31 +00001011 VisitExpr(S);
1012 VisitDecl(S->getDecl());
1013 ID.AddBoolean(S->isArrow());
1014 ID.AddBoolean(S->isFreeIvar());
1015}
1016
Chandler Carruthb1138242011-06-16 06:47:06 +00001017void StmtProfiler::VisitObjCPropertyRefExpr(const ObjCPropertyRefExpr *S) {
Douglas Gregor071f4eb2009-07-28 14:44:31 +00001018 VisitExpr(S);
John McCall12f78a62010-12-02 01:19:52 +00001019 if (S->isImplicitProperty()) {
1020 VisitDecl(S->getImplicitPropertyGetter());
1021 VisitDecl(S->getImplicitPropertySetter());
1022 } else {
1023 VisitDecl(S->getExplicitProperty());
Fariborz Jahanian8ac2d442010-10-14 16:04:05 +00001024 }
Fariborz Jahanian8ac2d442010-10-14 16:04:05 +00001025 if (S->isSuperReceiver()) {
1026 ID.AddBoolean(S->isSuperReceiver());
John McCall12f78a62010-12-02 01:19:52 +00001027 VisitType(S->getSuperReceiverType());
Fariborz Jahanian8ac2d442010-10-14 16:04:05 +00001028 }
Douglas Gregor071f4eb2009-07-28 14:44:31 +00001029}
1030
Ted Kremenekebcb57a2012-03-06 20:05:56 +00001031void StmtProfiler::VisitObjCSubscriptRefExpr(const ObjCSubscriptRefExpr *S) {
1032 VisitExpr(S);
1033 VisitDecl(S->getAtIndexMethodDecl());
1034 VisitDecl(S->setAtIndexMethodDecl());
1035}
1036
Chandler Carruthb1138242011-06-16 06:47:06 +00001037void StmtProfiler::VisitObjCMessageExpr(const ObjCMessageExpr *S) {
Douglas Gregor071f4eb2009-07-28 14:44:31 +00001038 VisitExpr(S);
1039 VisitName(S->getSelector());
1040 VisitDecl(S->getMethodDecl());
1041}
1042
Chandler Carruthb1138242011-06-16 06:47:06 +00001043void StmtProfiler::VisitObjCIsaExpr(const ObjCIsaExpr *S) {
Douglas Gregor071f4eb2009-07-28 14:44:31 +00001044 VisitExpr(S);
1045 ID.AddBoolean(S->isArrow());
1046}
1047
Ted Kremenekebcb57a2012-03-06 20:05:56 +00001048void StmtProfiler::VisitObjCBoolLiteralExpr(const ObjCBoolLiteralExpr *S) {
1049 VisitExpr(S);
1050 ID.AddBoolean(S->getValue());
1051}
1052
Chandler Carruthb1138242011-06-16 06:47:06 +00001053void StmtProfiler::VisitObjCIndirectCopyRestoreExpr(
1054 const ObjCIndirectCopyRestoreExpr *S) {
John McCallf85e1932011-06-15 23:02:42 +00001055 VisitExpr(S);
1056 ID.AddBoolean(S->shouldCopy());
1057}
1058
Chandler Carruthb1138242011-06-16 06:47:06 +00001059void StmtProfiler::VisitObjCBridgedCastExpr(const ObjCBridgedCastExpr *S) {
John McCallf85e1932011-06-15 23:02:42 +00001060 VisitExplicitCastExpr(S);
1061 ID.AddBoolean(S->getBridgeKind());
1062}
1063
Chandler Carruthb1138242011-06-16 06:47:06 +00001064void StmtProfiler::VisitDecl(const Decl *D) {
Douglas Gregor4a3f7802009-07-31 15:45:02 +00001065 ID.AddInteger(D? D->getKind() : 0);
Mike Stump1eb44332009-09-09 15:08:12 +00001066
Douglas Gregorb1975722009-07-30 23:18:24 +00001067 if (Canonical && D) {
Chandler Carruthb1138242011-06-16 06:47:06 +00001068 if (const NonTypeTemplateParmDecl *NTTP =
1069 dyn_cast<NonTypeTemplateParmDecl>(D)) {
Douglas Gregord584eb22009-07-28 15:32:17 +00001070 ID.AddInteger(NTTP->getDepth());
1071 ID.AddInteger(NTTP->getIndex());
Douglas Gregor61c4d282011-01-05 15:48:55 +00001072 ID.AddBoolean(NTTP->isParameterPack());
Douglas Gregor828e2262009-07-29 16:09:57 +00001073 VisitType(NTTP->getType());
Douglas Gregor41ef0c32009-07-28 00:33:38 +00001074 return;
1075 }
Mike Stump1eb44332009-09-09 15:08:12 +00001076
Chandler Carruthb1138242011-06-16 06:47:06 +00001077 if (const ParmVarDecl *Parm = dyn_cast<ParmVarDecl>(D)) {
John McCallfb44de92011-05-01 22:35:37 +00001078 // The Itanium C++ ABI uses the type, scope depth, and scope
1079 // index of a parameter when mangling expressions that involve
1080 // function parameters, so we will use the parameter's type for
1081 // establishing function parameter identity. That way, our
1082 // definition of "equivalent" (per C++ [temp.over.link]) is at
1083 // least as strong as the definition of "equivalent" used for
1084 // name mangling.
Douglas Gregor4a3f7802009-07-31 15:45:02 +00001085 VisitType(Parm->getType());
John McCallfb44de92011-05-01 22:35:37 +00001086 ID.AddInteger(Parm->getFunctionScopeDepth());
1087 ID.AddInteger(Parm->getFunctionScopeIndex());
Douglas Gregor4a3f7802009-07-31 15:45:02 +00001088 return;
1089 }
Mike Stump1eb44332009-09-09 15:08:12 +00001090
Richard Smith0f6931a2012-04-02 18:53:24 +00001091 if (const TemplateTypeParmDecl *TTP =
1092 dyn_cast<TemplateTypeParmDecl>(D)) {
1093 ID.AddInteger(TTP->getDepth());
1094 ID.AddInteger(TTP->getIndex());
1095 ID.AddBoolean(TTP->isParameterPack());
1096 return;
1097 }
1098
Chandler Carruthb1138242011-06-16 06:47:06 +00001099 if (const TemplateTemplateParmDecl *TTP =
1100 dyn_cast<TemplateTemplateParmDecl>(D)) {
Douglas Gregora2ffb982009-07-31 15:46:56 +00001101 ID.AddInteger(TTP->getDepth());
1102 ID.AddInteger(TTP->getIndex());
Douglas Gregor61c4d282011-01-05 15:48:55 +00001103 ID.AddBoolean(TTP->isParameterPack());
Douglas Gregora2ffb982009-07-31 15:46:56 +00001104 return;
1105 }
Douglas Gregor41ef0c32009-07-28 00:33:38 +00001106 }
Mike Stump1eb44332009-09-09 15:08:12 +00001107
Douglas Gregord584eb22009-07-28 15:32:17 +00001108 ID.AddPointer(D? D->getCanonicalDecl() : 0);
1109}
1110
1111void StmtProfiler::VisitType(QualType T) {
1112 if (Canonical)
1113 T = Context.getCanonicalType(T);
Mike Stump1eb44332009-09-09 15:08:12 +00001114
Douglas Gregor41ef0c32009-07-28 00:33:38 +00001115 ID.AddPointer(T.getAsOpaquePtr());
1116}
1117
1118void StmtProfiler::VisitName(DeclarationName Name) {
1119 ID.AddPointer(Name.getAsOpaquePtr());
1120}
1121
1122void StmtProfiler::VisitNestedNameSpecifier(NestedNameSpecifier *NNS) {
1123 if (Canonical)
1124 NNS = Context.getCanonicalNestedNameSpecifier(NNS);
1125 ID.AddPointer(NNS);
1126}
1127
1128void StmtProfiler::VisitTemplateName(TemplateName Name) {
1129 if (Canonical)
1130 Name = Context.getCanonicalTemplateName(Name);
Mike Stump1eb44332009-09-09 15:08:12 +00001131
Douglas Gregor41ef0c32009-07-28 00:33:38 +00001132 Name.Profile(ID);
1133}
1134
John McCall833ca992009-10-29 08:12:44 +00001135void StmtProfiler::VisitTemplateArguments(const TemplateArgumentLoc *Args,
Douglas Gregor41ef0c32009-07-28 00:33:38 +00001136 unsigned NumArgs) {
1137 ID.AddInteger(NumArgs);
John McCall833ca992009-10-29 08:12:44 +00001138 for (unsigned I = 0; I != NumArgs; ++I)
1139 VisitTemplateArgument(Args[I].getArgument());
1140}
Mike Stump1eb44332009-09-09 15:08:12 +00001141
John McCall833ca992009-10-29 08:12:44 +00001142void StmtProfiler::VisitTemplateArgument(const TemplateArgument &Arg) {
1143 // Mostly repetitive with TemplateArgument::Profile!
1144 ID.AddInteger(Arg.getKind());
1145 switch (Arg.getKind()) {
1146 case TemplateArgument::Null:
1147 break;
Mike Stump1eb44332009-09-09 15:08:12 +00001148
John McCall833ca992009-10-29 08:12:44 +00001149 case TemplateArgument::Type:
1150 VisitType(Arg.getAsType());
1151 break;
Mike Stump1eb44332009-09-09 15:08:12 +00001152
Douglas Gregor788cd062009-11-11 01:00:40 +00001153 case TemplateArgument::Template:
Douglas Gregora7fc9012011-01-05 18:58:31 +00001154 case TemplateArgument::TemplateExpansion:
1155 VisitTemplateName(Arg.getAsTemplateOrTemplatePattern());
Douglas Gregor788cd062009-11-11 01:00:40 +00001156 break;
Sean Huntc3021132010-05-05 15:23:54 +00001157
John McCall833ca992009-10-29 08:12:44 +00001158 case TemplateArgument::Declaration:
1159 VisitDecl(Arg.getAsDecl());
1160 break;
Mike Stump1eb44332009-09-09 15:08:12 +00001161
John McCall833ca992009-10-29 08:12:44 +00001162 case TemplateArgument::Integral:
1163 Arg.getAsIntegral()->Profile(ID);
1164 VisitType(Arg.getIntegralType());
1165 break;
Mike Stump1eb44332009-09-09 15:08:12 +00001166
John McCall833ca992009-10-29 08:12:44 +00001167 case TemplateArgument::Expression:
1168 Visit(Arg.getAsExpr());
1169 break;
Mike Stump1eb44332009-09-09 15:08:12 +00001170
John McCall833ca992009-10-29 08:12:44 +00001171 case TemplateArgument::Pack:
1172 const TemplateArgument *Pack = Arg.pack_begin();
1173 for (unsigned i = 0, e = Arg.pack_size(); i != e; ++i)
1174 VisitTemplateArgument(Pack[i]);
1175 break;
Douglas Gregor41ef0c32009-07-28 00:33:38 +00001176 }
1177}
1178
Jay Foad4ba2a172011-01-12 09:06:06 +00001179void Stmt::Profile(llvm::FoldingSetNodeID &ID, const ASTContext &Context,
Chandler Carruthb1138242011-06-16 06:47:06 +00001180 bool Canonical) const {
Douglas Gregor41ef0c32009-07-28 00:33:38 +00001181 StmtProfiler Profiler(ID, Context, Canonical);
1182 Profiler.Visit(this);
1183}