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