blob: bfd3132506ec3f249676d527580e63ed5a39aa83 [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
Chandler Carruthb1138242011-06-16 06:47:06 +0000769void StmtProfiler::VisitCXXThisExpr(const CXXThisExpr *S) {
Douglas Gregor41ef0c32009-07-28 00:33:38 +0000770 VisitExpr(S);
Douglas Gregorcefc3af2012-04-16 07:05:22 +0000771 ID.AddBoolean(S->isImplicit());
Douglas Gregor41ef0c32009-07-28 00:33:38 +0000772}
773
Chandler Carruthb1138242011-06-16 06:47:06 +0000774void StmtProfiler::VisitCXXThrowExpr(const CXXThrowExpr *S) {
Douglas Gregor41ef0c32009-07-28 00:33:38 +0000775 VisitExpr(S);
776}
777
Chandler Carruthb1138242011-06-16 06:47:06 +0000778void StmtProfiler::VisitCXXDefaultArgExpr(const CXXDefaultArgExpr *S) {
Douglas Gregor41ef0c32009-07-28 00:33:38 +0000779 VisitExpr(S);
780 VisitDecl(S->getParam());
781}
782
Chandler Carruthb1138242011-06-16 06:47:06 +0000783void StmtProfiler::VisitCXXBindTemporaryExpr(const CXXBindTemporaryExpr *S) {
Douglas Gregor41ef0c32009-07-28 00:33:38 +0000784 VisitExpr(S);
785 VisitDecl(
786 const_cast<CXXDestructorDecl *>(S->getTemporary()->getDestructor()));
787}
788
Chandler Carruthb1138242011-06-16 06:47:06 +0000789void StmtProfiler::VisitCXXConstructExpr(const CXXConstructExpr *S) {
Douglas Gregor41ef0c32009-07-28 00:33:38 +0000790 VisitExpr(S);
791 VisitDecl(S->getConstructor());
792 ID.AddBoolean(S->isElidable());
793}
794
Chandler Carruthb1138242011-06-16 06:47:06 +0000795void StmtProfiler::VisitCXXFunctionalCastExpr(const CXXFunctionalCastExpr *S) {
Douglas Gregor41ef0c32009-07-28 00:33:38 +0000796 VisitExplicitCastExpr(S);
797}
798
Chandler Carruthb1138242011-06-16 06:47:06 +0000799void
800StmtProfiler::VisitCXXTemporaryObjectExpr(const CXXTemporaryObjectExpr *S) {
Douglas Gregor41ef0c32009-07-28 00:33:38 +0000801 VisitCXXConstructExpr(S);
802}
803
Chandler Carruthb1138242011-06-16 06:47:06 +0000804void
Douglas Gregor01d08012012-02-07 10:09:13 +0000805StmtProfiler::VisitLambdaExpr(const LambdaExpr *S) {
806 VisitExpr(S);
807 for (LambdaExpr::capture_iterator C = S->explicit_capture_begin(),
808 CEnd = S->explicit_capture_end();
809 C != CEnd; ++C) {
810 ID.AddInteger(C->getCaptureKind());
811 if (C->capturesVariable()) {
812 VisitDecl(C->getCapturedVar());
813 ID.AddBoolean(C->isPackExpansion());
814 }
815 }
816 // Note: If we actually needed to be able to match lambda
817 // expressions, we would have to consider parameters and return type
818 // here, among other things.
819 VisitStmt(S->getBody());
820}
821
822void
Chandler Carruthb1138242011-06-16 06:47:06 +0000823StmtProfiler::VisitCXXScalarValueInitExpr(const CXXScalarValueInitExpr *S) {
Douglas Gregor41ef0c32009-07-28 00:33:38 +0000824 VisitExpr(S);
825}
826
Chandler Carruthb1138242011-06-16 06:47:06 +0000827void StmtProfiler::VisitCXXDeleteExpr(const CXXDeleteExpr *S) {
Douglas Gregor41ef0c32009-07-28 00:33:38 +0000828 VisitExpr(S);
829 ID.AddBoolean(S->isGlobalDelete());
830 ID.AddBoolean(S->isArrayForm());
831 VisitDecl(S->getOperatorDelete());
832}
833
834
Chandler Carruthb1138242011-06-16 06:47:06 +0000835void StmtProfiler::VisitCXXNewExpr(const CXXNewExpr *S) {
Douglas Gregor41ef0c32009-07-28 00:33:38 +0000836 VisitExpr(S);
837 VisitType(S->getAllocatedType());
838 VisitDecl(S->getOperatorNew());
839 VisitDecl(S->getOperatorDelete());
Douglas Gregor41ef0c32009-07-28 00:33:38 +0000840 ID.AddBoolean(S->isArray());
841 ID.AddInteger(S->getNumPlacementArgs());
842 ID.AddBoolean(S->isGlobalNew());
843 ID.AddBoolean(S->isParenTypeId());
Sebastian Redl2aed8b82012-02-16 12:22:20 +0000844 ID.AddInteger(S->getInitializationStyle());
Douglas Gregor41ef0c32009-07-28 00:33:38 +0000845}
846
Chandler Carruthb1138242011-06-16 06:47:06 +0000847void
848StmtProfiler::VisitCXXPseudoDestructorExpr(const CXXPseudoDestructorExpr *S) {
Douglas Gregora71d8192009-09-04 17:36:40 +0000849 VisitExpr(S);
850 ID.AddBoolean(S->isArrow());
851 VisitNestedNameSpecifier(S->getQualifier());
852 VisitType(S->getDestroyedType());
853}
854
Chandler Carruthb1138242011-06-16 06:47:06 +0000855void StmtProfiler::VisitOverloadExpr(const OverloadExpr *S) {
Argyrios Kyrtzidis7b3e3f62010-08-15 20:53:20 +0000856 VisitExpr(S);
John McCallf7a1a742009-11-24 19:00:30 +0000857 VisitNestedNameSpecifier(S->getQualifier());
Douglas Gregor41ef0c32009-07-28 00:33:38 +0000858 VisitName(S->getName());
John McCallf7a1a742009-11-24 19:00:30 +0000859 ID.AddBoolean(S->hasExplicitTemplateArgs());
860 if (S->hasExplicitTemplateArgs())
Argyrios Kyrtzidisc35919b2010-08-15 01:15:38 +0000861 VisitTemplateArguments(S->getExplicitTemplateArgs().getTemplateArgs(),
862 S->getExplicitTemplateArgs().NumTemplateArgs);
863}
864
865void
Chandler Carruthb1138242011-06-16 06:47:06 +0000866StmtProfiler::VisitUnresolvedLookupExpr(const UnresolvedLookupExpr *S) {
Argyrios Kyrtzidisc35919b2010-08-15 01:15:38 +0000867 VisitOverloadExpr(S);
Douglas Gregor41ef0c32009-07-28 00:33:38 +0000868}
869
Chandler Carruthb1138242011-06-16 06:47:06 +0000870void StmtProfiler::VisitUnaryTypeTraitExpr(const UnaryTypeTraitExpr *S) {
Douglas Gregor41ef0c32009-07-28 00:33:38 +0000871 VisitExpr(S);
872 ID.AddInteger(S->getTrait());
873 VisitType(S->getQueriedType());
874}
875
Chandler Carruthb1138242011-06-16 06:47:06 +0000876void StmtProfiler::VisitBinaryTypeTraitExpr(const BinaryTypeTraitExpr *S) {
Francois Pichet6ad6f282010-12-07 00:08:36 +0000877 VisitExpr(S);
878 ID.AddInteger(S->getTrait());
879 VisitType(S->getLhsType());
880 VisitType(S->getRhsType());
881}
882
Douglas Gregor4ca8ac22012-02-24 07:38:34 +0000883void StmtProfiler::VisitTypeTraitExpr(const TypeTraitExpr *S) {
884 VisitExpr(S);
885 ID.AddInteger(S->getTrait());
886 ID.AddInteger(S->getNumArgs());
887 for (unsigned I = 0, N = S->getNumArgs(); I != N; ++I)
888 VisitType(S->getArg(I)->getType());
889}
890
Chandler Carruthb1138242011-06-16 06:47:06 +0000891void StmtProfiler::VisitArrayTypeTraitExpr(const ArrayTypeTraitExpr *S) {
John Wiegley21ff2e52011-04-28 00:16:57 +0000892 VisitExpr(S);
893 ID.AddInteger(S->getTrait());
894 VisitType(S->getQueriedType());
895}
896
Chandler Carruthb1138242011-06-16 06:47:06 +0000897void StmtProfiler::VisitExpressionTraitExpr(const ExpressionTraitExpr *S) {
John Wiegley55262202011-04-25 06:54:41 +0000898 VisitExpr(S);
899 ID.AddInteger(S->getTrait());
900 VisitExpr(S->getQueriedExpression());
901}
902
Chandler Carruthb1138242011-06-16 06:47:06 +0000903void StmtProfiler::VisitDependentScopeDeclRefExpr(
904 const DependentScopeDeclRefExpr *S) {
Douglas Gregor41ef0c32009-07-28 00:33:38 +0000905 VisitExpr(S);
906 VisitName(S->getDeclName());
907 VisitNestedNameSpecifier(S->getQualifier());
John McCallf7a1a742009-11-24 19:00:30 +0000908 ID.AddBoolean(S->hasExplicitTemplateArgs());
909 if (S->hasExplicitTemplateArgs())
910 VisitTemplateArguments(S->getTemplateArgs(), S->getNumTemplateArgs());
Douglas Gregor41ef0c32009-07-28 00:33:38 +0000911}
912
Chandler Carruthb1138242011-06-16 06:47:06 +0000913void StmtProfiler::VisitExprWithCleanups(const ExprWithCleanups *S) {
Douglas Gregor071f4eb2009-07-28 14:44:31 +0000914 VisitExpr(S);
Douglas Gregor071f4eb2009-07-28 14:44:31 +0000915}
916
Chandler Carruthb1138242011-06-16 06:47:06 +0000917void StmtProfiler::VisitCXXUnresolvedConstructExpr(
918 const CXXUnresolvedConstructExpr *S) {
Douglas Gregor071f4eb2009-07-28 14:44:31 +0000919 VisitExpr(S);
920 VisitType(S->getTypeAsWritten());
921}
922
Chandler Carruthb1138242011-06-16 06:47:06 +0000923void StmtProfiler::VisitCXXDependentScopeMemberExpr(
924 const CXXDependentScopeMemberExpr *S) {
John McCallaa81e162009-12-01 22:10:20 +0000925 ID.AddBoolean(S->isImplicitAccess());
926 if (!S->isImplicitAccess()) {
927 VisitExpr(S);
928 ID.AddBoolean(S->isArrow());
929 }
Douglas Gregora38c6872009-09-03 16:14:30 +0000930 VisitNestedNameSpecifier(S->getQualifier());
Douglas Gregor071f4eb2009-07-28 14:44:31 +0000931 VisitName(S->getMember());
John McCallaa81e162009-12-01 22:10:20 +0000932 ID.AddBoolean(S->hasExplicitTemplateArgs());
933 if (S->hasExplicitTemplateArgs())
John McCall129e2df2009-11-30 22:42:35 +0000934 VisitTemplateArguments(S->getTemplateArgs(), S->getNumTemplateArgs());
935}
936
Chandler Carruthb1138242011-06-16 06:47:06 +0000937void StmtProfiler::VisitUnresolvedMemberExpr(const UnresolvedMemberExpr *S) {
John McCallaa81e162009-12-01 22:10:20 +0000938 ID.AddBoolean(S->isImplicitAccess());
939 if (!S->isImplicitAccess()) {
940 VisitExpr(S);
941 ID.AddBoolean(S->isArrow());
942 }
John McCall129e2df2009-11-30 22:42:35 +0000943 VisitNestedNameSpecifier(S->getQualifier());
944 VisitName(S->getMemberName());
945 ID.AddBoolean(S->hasExplicitTemplateArgs());
946 if (S->hasExplicitTemplateArgs())
947 VisitTemplateArguments(S->getTemplateArgs(), S->getNumTemplateArgs());
Douglas Gregor071f4eb2009-07-28 14:44:31 +0000948}
949
Chandler Carruthb1138242011-06-16 06:47:06 +0000950void StmtProfiler::VisitCXXNoexceptExpr(const CXXNoexceptExpr *S) {
Sebastian Redl2e156222010-09-10 20:55:43 +0000951 VisitExpr(S);
952}
953
Chandler Carruthb1138242011-06-16 06:47:06 +0000954void StmtProfiler::VisitPackExpansionExpr(const PackExpansionExpr *S) {
Douglas Gregorbe230c32011-01-03 17:17:50 +0000955 VisitExpr(S);
956}
957
Chandler Carruthb1138242011-06-16 06:47:06 +0000958void StmtProfiler::VisitSizeOfPackExpr(const SizeOfPackExpr *S) {
Douglas Gregoree8aff02011-01-04 17:33:58 +0000959 VisitExpr(S);
960 VisitDecl(S->getPack());
961}
962
Douglas Gregorc7793c72011-01-15 01:15:58 +0000963void StmtProfiler::VisitSubstNonTypeTemplateParmPackExpr(
Chandler Carruthb1138242011-06-16 06:47:06 +0000964 const SubstNonTypeTemplateParmPackExpr *S) {
Douglas Gregorc7793c72011-01-15 01:15:58 +0000965 VisitExpr(S);
966 VisitDecl(S->getParameterPack());
967 VisitTemplateArgument(S->getArgumentPack());
968}
969
John McCall91a57552011-07-15 05:09:51 +0000970void StmtProfiler::VisitSubstNonTypeTemplateParmExpr(
971 const SubstNonTypeTemplateParmExpr *E) {
972 // Profile exactly as the replacement expression.
973 Visit(E->getReplacement());
974}
975
Richard Smith9a4db032012-09-12 00:56:43 +0000976void StmtProfiler::VisitFunctionParmPackExpr(const FunctionParmPackExpr *S) {
977 VisitExpr(S);
978 VisitDecl(S->getParameterPack());
979 ID.AddInteger(S->getNumExpansions());
980 for (FunctionParmPackExpr::iterator I = S->begin(), E = S->end(); I != E; ++I)
981 VisitDecl(*I);
982}
983
Douglas Gregor03e80032011-06-21 17:03:29 +0000984void StmtProfiler::VisitMaterializeTemporaryExpr(
985 const MaterializeTemporaryExpr *S) {
986 VisitExpr(S);
987}
988
Chandler Carruthb1138242011-06-16 06:47:06 +0000989void StmtProfiler::VisitOpaqueValueExpr(const OpaqueValueExpr *E) {
John McCall7cd7d1a2010-11-15 23:31:06 +0000990 VisitExpr(E);
991}
992
Chandler Carruthb1138242011-06-16 06:47:06 +0000993void StmtProfiler::VisitObjCStringLiteral(const ObjCStringLiteral *S) {
Douglas Gregor071f4eb2009-07-28 14:44:31 +0000994 VisitExpr(S);
995}
996
Patrick Beardeb382ec2012-04-19 00:25:12 +0000997void StmtProfiler::VisitObjCBoxedExpr(const ObjCBoxedExpr *E) {
Ted Kremenekebcb57a2012-03-06 20:05:56 +0000998 VisitExpr(E);
999}
1000
1001void StmtProfiler::VisitObjCArrayLiteral(const ObjCArrayLiteral *E) {
1002 VisitExpr(E);
1003}
1004
1005void StmtProfiler::VisitObjCDictionaryLiteral(const ObjCDictionaryLiteral *E) {
1006 VisitExpr(E);
1007}
1008
Chandler Carruthb1138242011-06-16 06:47:06 +00001009void StmtProfiler::VisitObjCEncodeExpr(const ObjCEncodeExpr *S) {
Douglas Gregor071f4eb2009-07-28 14:44:31 +00001010 VisitExpr(S);
1011 VisitType(S->getEncodedType());
1012}
1013
Chandler Carruthb1138242011-06-16 06:47:06 +00001014void StmtProfiler::VisitObjCSelectorExpr(const ObjCSelectorExpr *S) {
Douglas Gregor071f4eb2009-07-28 14:44:31 +00001015 VisitExpr(S);
1016 VisitName(S->getSelector());
1017}
1018
Chandler Carruthb1138242011-06-16 06:47:06 +00001019void StmtProfiler::VisitObjCProtocolExpr(const ObjCProtocolExpr *S) {
Douglas Gregor071f4eb2009-07-28 14:44:31 +00001020 VisitExpr(S);
1021 VisitDecl(S->getProtocol());
1022}
1023
Chandler Carruthb1138242011-06-16 06:47:06 +00001024void StmtProfiler::VisitObjCIvarRefExpr(const ObjCIvarRefExpr *S) {
Douglas Gregor071f4eb2009-07-28 14:44:31 +00001025 VisitExpr(S);
1026 VisitDecl(S->getDecl());
1027 ID.AddBoolean(S->isArrow());
1028 ID.AddBoolean(S->isFreeIvar());
1029}
1030
Chandler Carruthb1138242011-06-16 06:47:06 +00001031void StmtProfiler::VisitObjCPropertyRefExpr(const ObjCPropertyRefExpr *S) {
Douglas Gregor071f4eb2009-07-28 14:44:31 +00001032 VisitExpr(S);
John McCall12f78a62010-12-02 01:19:52 +00001033 if (S->isImplicitProperty()) {
1034 VisitDecl(S->getImplicitPropertyGetter());
1035 VisitDecl(S->getImplicitPropertySetter());
1036 } else {
1037 VisitDecl(S->getExplicitProperty());
Fariborz Jahanian8ac2d442010-10-14 16:04:05 +00001038 }
Fariborz Jahanian8ac2d442010-10-14 16:04:05 +00001039 if (S->isSuperReceiver()) {
1040 ID.AddBoolean(S->isSuperReceiver());
John McCall12f78a62010-12-02 01:19:52 +00001041 VisitType(S->getSuperReceiverType());
Fariborz Jahanian8ac2d442010-10-14 16:04:05 +00001042 }
Douglas Gregor071f4eb2009-07-28 14:44:31 +00001043}
1044
Ted Kremenekebcb57a2012-03-06 20:05:56 +00001045void StmtProfiler::VisitObjCSubscriptRefExpr(const ObjCSubscriptRefExpr *S) {
1046 VisitExpr(S);
1047 VisitDecl(S->getAtIndexMethodDecl());
1048 VisitDecl(S->setAtIndexMethodDecl());
1049}
1050
Chandler Carruthb1138242011-06-16 06:47:06 +00001051void StmtProfiler::VisitObjCMessageExpr(const ObjCMessageExpr *S) {
Douglas Gregor071f4eb2009-07-28 14:44:31 +00001052 VisitExpr(S);
1053 VisitName(S->getSelector());
1054 VisitDecl(S->getMethodDecl());
1055}
1056
Chandler Carruthb1138242011-06-16 06:47:06 +00001057void StmtProfiler::VisitObjCIsaExpr(const ObjCIsaExpr *S) {
Douglas Gregor071f4eb2009-07-28 14:44:31 +00001058 VisitExpr(S);
1059 ID.AddBoolean(S->isArrow());
1060}
1061
Ted Kremenekebcb57a2012-03-06 20:05:56 +00001062void StmtProfiler::VisitObjCBoolLiteralExpr(const ObjCBoolLiteralExpr *S) {
1063 VisitExpr(S);
1064 ID.AddBoolean(S->getValue());
1065}
1066
Chandler Carruthb1138242011-06-16 06:47:06 +00001067void StmtProfiler::VisitObjCIndirectCopyRestoreExpr(
1068 const ObjCIndirectCopyRestoreExpr *S) {
John McCallf85e1932011-06-15 23:02:42 +00001069 VisitExpr(S);
1070 ID.AddBoolean(S->shouldCopy());
1071}
1072
Chandler Carruthb1138242011-06-16 06:47:06 +00001073void StmtProfiler::VisitObjCBridgedCastExpr(const ObjCBridgedCastExpr *S) {
John McCallf85e1932011-06-15 23:02:42 +00001074 VisitExplicitCastExpr(S);
1075 ID.AddBoolean(S->getBridgeKind());
1076}
1077
Chandler Carruthb1138242011-06-16 06:47:06 +00001078void StmtProfiler::VisitDecl(const Decl *D) {
Douglas Gregor4a3f7802009-07-31 15:45:02 +00001079 ID.AddInteger(D? D->getKind() : 0);
Mike Stump1eb44332009-09-09 15:08:12 +00001080
Douglas Gregorb1975722009-07-30 23:18:24 +00001081 if (Canonical && D) {
Chandler Carruthb1138242011-06-16 06:47:06 +00001082 if (const NonTypeTemplateParmDecl *NTTP =
1083 dyn_cast<NonTypeTemplateParmDecl>(D)) {
Douglas Gregord584eb22009-07-28 15:32:17 +00001084 ID.AddInteger(NTTP->getDepth());
1085 ID.AddInteger(NTTP->getIndex());
Douglas Gregor61c4d282011-01-05 15:48:55 +00001086 ID.AddBoolean(NTTP->isParameterPack());
Douglas Gregor828e2262009-07-29 16:09:57 +00001087 VisitType(NTTP->getType());
Douglas Gregor41ef0c32009-07-28 00:33:38 +00001088 return;
1089 }
Mike Stump1eb44332009-09-09 15:08:12 +00001090
Chandler Carruthb1138242011-06-16 06:47:06 +00001091 if (const ParmVarDecl *Parm = dyn_cast<ParmVarDecl>(D)) {
John McCallfb44de92011-05-01 22:35:37 +00001092 // The Itanium C++ ABI uses the type, scope depth, and scope
1093 // index of a parameter when mangling expressions that involve
1094 // function parameters, so we will use the parameter's type for
1095 // establishing function parameter identity. That way, our
1096 // definition of "equivalent" (per C++ [temp.over.link]) is at
1097 // least as strong as the definition of "equivalent" used for
1098 // name mangling.
Douglas Gregor4a3f7802009-07-31 15:45:02 +00001099 VisitType(Parm->getType());
John McCallfb44de92011-05-01 22:35:37 +00001100 ID.AddInteger(Parm->getFunctionScopeDepth());
1101 ID.AddInteger(Parm->getFunctionScopeIndex());
Douglas Gregor4a3f7802009-07-31 15:45:02 +00001102 return;
1103 }
Mike Stump1eb44332009-09-09 15:08:12 +00001104
Richard Smith0f6931a2012-04-02 18:53:24 +00001105 if (const TemplateTypeParmDecl *TTP =
1106 dyn_cast<TemplateTypeParmDecl>(D)) {
1107 ID.AddInteger(TTP->getDepth());
1108 ID.AddInteger(TTP->getIndex());
1109 ID.AddBoolean(TTP->isParameterPack());
1110 return;
1111 }
1112
Chandler Carruthb1138242011-06-16 06:47:06 +00001113 if (const TemplateTemplateParmDecl *TTP =
1114 dyn_cast<TemplateTemplateParmDecl>(D)) {
Douglas Gregora2ffb982009-07-31 15:46:56 +00001115 ID.AddInteger(TTP->getDepth());
1116 ID.AddInteger(TTP->getIndex());
Douglas Gregor61c4d282011-01-05 15:48:55 +00001117 ID.AddBoolean(TTP->isParameterPack());
Douglas Gregora2ffb982009-07-31 15:46:56 +00001118 return;
1119 }
Douglas Gregor41ef0c32009-07-28 00:33:38 +00001120 }
Mike Stump1eb44332009-09-09 15:08:12 +00001121
Douglas Gregord584eb22009-07-28 15:32:17 +00001122 ID.AddPointer(D? D->getCanonicalDecl() : 0);
1123}
1124
1125void StmtProfiler::VisitType(QualType T) {
1126 if (Canonical)
1127 T = Context.getCanonicalType(T);
Mike Stump1eb44332009-09-09 15:08:12 +00001128
Douglas Gregor41ef0c32009-07-28 00:33:38 +00001129 ID.AddPointer(T.getAsOpaquePtr());
1130}
1131
1132void StmtProfiler::VisitName(DeclarationName Name) {
1133 ID.AddPointer(Name.getAsOpaquePtr());
1134}
1135
1136void StmtProfiler::VisitNestedNameSpecifier(NestedNameSpecifier *NNS) {
1137 if (Canonical)
1138 NNS = Context.getCanonicalNestedNameSpecifier(NNS);
1139 ID.AddPointer(NNS);
1140}
1141
1142void StmtProfiler::VisitTemplateName(TemplateName Name) {
1143 if (Canonical)
1144 Name = Context.getCanonicalTemplateName(Name);
Mike Stump1eb44332009-09-09 15:08:12 +00001145
Douglas Gregor41ef0c32009-07-28 00:33:38 +00001146 Name.Profile(ID);
1147}
1148
John McCall833ca992009-10-29 08:12:44 +00001149void StmtProfiler::VisitTemplateArguments(const TemplateArgumentLoc *Args,
Douglas Gregor41ef0c32009-07-28 00:33:38 +00001150 unsigned NumArgs) {
1151 ID.AddInteger(NumArgs);
John McCall833ca992009-10-29 08:12:44 +00001152 for (unsigned I = 0; I != NumArgs; ++I)
1153 VisitTemplateArgument(Args[I].getArgument());
1154}
Mike Stump1eb44332009-09-09 15:08:12 +00001155
John McCall833ca992009-10-29 08:12:44 +00001156void StmtProfiler::VisitTemplateArgument(const TemplateArgument &Arg) {
1157 // Mostly repetitive with TemplateArgument::Profile!
1158 ID.AddInteger(Arg.getKind());
1159 switch (Arg.getKind()) {
1160 case TemplateArgument::Null:
1161 break;
Mike Stump1eb44332009-09-09 15:08:12 +00001162
John McCall833ca992009-10-29 08:12:44 +00001163 case TemplateArgument::Type:
1164 VisitType(Arg.getAsType());
1165 break;
Mike Stump1eb44332009-09-09 15:08:12 +00001166
Douglas Gregor788cd062009-11-11 01:00:40 +00001167 case TemplateArgument::Template:
Douglas Gregora7fc9012011-01-05 18:58:31 +00001168 case TemplateArgument::TemplateExpansion:
1169 VisitTemplateName(Arg.getAsTemplateOrTemplatePattern());
Douglas Gregor788cd062009-11-11 01:00:40 +00001170 break;
Sean Huntc3021132010-05-05 15:23:54 +00001171
John McCall833ca992009-10-29 08:12:44 +00001172 case TemplateArgument::Declaration:
1173 VisitDecl(Arg.getAsDecl());
1174 break;
Mike Stump1eb44332009-09-09 15:08:12 +00001175
Eli Friedmand7a6b162012-09-26 02:36:12 +00001176 case TemplateArgument::NullPtr:
1177 VisitType(Arg.getNullPtrType());
1178 break;
1179
John McCall833ca992009-10-29 08:12:44 +00001180 case TemplateArgument::Integral:
Benjamin Kramer85524372012-06-07 15:09:51 +00001181 Arg.getAsIntegral().Profile(ID);
John McCall833ca992009-10-29 08:12:44 +00001182 VisitType(Arg.getIntegralType());
1183 break;
Mike Stump1eb44332009-09-09 15:08:12 +00001184
John McCall833ca992009-10-29 08:12:44 +00001185 case TemplateArgument::Expression:
1186 Visit(Arg.getAsExpr());
1187 break;
Mike Stump1eb44332009-09-09 15:08:12 +00001188
John McCall833ca992009-10-29 08:12:44 +00001189 case TemplateArgument::Pack:
1190 const TemplateArgument *Pack = Arg.pack_begin();
1191 for (unsigned i = 0, e = Arg.pack_size(); i != e; ++i)
1192 VisitTemplateArgument(Pack[i]);
1193 break;
Douglas Gregor41ef0c32009-07-28 00:33:38 +00001194 }
1195}
1196
Jay Foad4ba2a172011-01-12 09:06:06 +00001197void Stmt::Profile(llvm::FoldingSetNodeID &ID, const ASTContext &Context,
Chandler Carruthb1138242011-06-16 06:47:06 +00001198 bool Canonical) const {
Douglas Gregor41ef0c32009-07-28 00:33:38 +00001199 StmtProfiler Profiler(ID, Context, Canonical);
1200 Profiler.Visit(this);
1201}