blob: 7f10bef7134995c81e3f9cd185b84684d916ede0 [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 {
Benjamin Kramer770b4a82009-11-28 19:03:38 +000026 class StmtProfiler : public StmtVisitor<StmtProfiler> {
Douglas Gregor41ef0c32009-07-28 00:33:38 +000027 llvm::FoldingSetNodeID &ID;
28 ASTContext &Context;
29 bool Canonical;
Mike Stump1eb44332009-09-09 15:08:12 +000030
Douglas Gregor41ef0c32009-07-28 00:33:38 +000031 public:
32 StmtProfiler(llvm::FoldingSetNodeID &ID, 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
Douglas Gregor41ef0c32009-07-28 00:33:38 +000036 void VisitStmt(Stmt *S);
Mike Stump1eb44332009-09-09 15:08:12 +000037
Douglas Gregor3fe81fc2009-07-28 15:27:13 +000038#define STMT(Node, Base) void Visit##Node(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.
43 void VisitDecl(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.
John McCall833ca992009-10-29 08:12:44 +000062 void VisitTemplateArguments(const TemplateArgumentLoc *Args, unsigned NumArgs);
63
64 /// \brief Visit a single template argument.
65 void VisitTemplateArgument(const TemplateArgument &Arg);
Douglas Gregor41ef0c32009-07-28 00:33:38 +000066 };
67}
68
69void StmtProfiler::VisitStmt(Stmt *S) {
70 ID.AddInteger(S->getStmtClass());
71 for (Stmt::child_iterator C = S->child_begin(), CEnd = S->child_end();
72 C != CEnd; ++C)
73 Visit(*C);
74}
75
Douglas Gregor3fe81fc2009-07-28 15:27:13 +000076void StmtProfiler::VisitDeclStmt(DeclStmt *S) {
77 VisitStmt(S);
78 for (DeclStmt::decl_iterator D = S->decl_begin(), DEnd = S->decl_end();
79 D != DEnd; ++D)
80 VisitDecl(*D);
81}
82
83void StmtProfiler::VisitNullStmt(NullStmt *S) {
84 VisitStmt(S);
85}
86
87void StmtProfiler::VisitCompoundStmt(CompoundStmt *S) {
88 VisitStmt(S);
89}
90
91void StmtProfiler::VisitSwitchCase(SwitchCase *S) {
92 VisitStmt(S);
93}
94
95void StmtProfiler::VisitCaseStmt(CaseStmt *S) {
96 VisitStmt(S);
97}
98
99void StmtProfiler::VisitDefaultStmt(DefaultStmt *S) {
100 VisitStmt(S);
101}
102
103void StmtProfiler::VisitLabelStmt(LabelStmt *S) {
104 VisitStmt(S);
105 VisitName(S->getID());
106}
107
108void StmtProfiler::VisitIfStmt(IfStmt *S) {
109 VisitStmt(S);
Douglas Gregor99e9b4d2009-11-25 00:27:52 +0000110 VisitDecl(S->getConditionVariable());
Douglas Gregor3fe81fc2009-07-28 15:27:13 +0000111}
112
Douglas Gregor828e2262009-07-29 16:09:57 +0000113void StmtProfiler::VisitSwitchStmt(SwitchStmt *S) {
114 VisitStmt(S);
Douglas Gregor99e9b4d2009-11-25 00:27:52 +0000115 VisitDecl(S->getConditionVariable());
Douglas Gregor828e2262009-07-29 16:09:57 +0000116}
117
Douglas Gregor3fe81fc2009-07-28 15:27:13 +0000118void StmtProfiler::VisitWhileStmt(WhileStmt *S) {
119 VisitStmt(S);
Douglas Gregor99e9b4d2009-11-25 00:27:52 +0000120 VisitDecl(S->getConditionVariable());
Douglas Gregor3fe81fc2009-07-28 15:27:13 +0000121}
122
123void StmtProfiler::VisitDoStmt(DoStmt *S) {
124 VisitStmt(S);
125}
126
127void StmtProfiler::VisitForStmt(ForStmt *S) {
128 VisitStmt(S);
129}
130
131void StmtProfiler::VisitGotoStmt(GotoStmt *S) {
132 VisitStmt(S);
133 VisitName(S->getLabel()->getID());
134}
135
136void StmtProfiler::VisitIndirectGotoStmt(IndirectGotoStmt *S) {
137 VisitStmt(S);
138}
139
140void StmtProfiler::VisitContinueStmt(ContinueStmt *S) {
141 VisitStmt(S);
142}
143
144void StmtProfiler::VisitBreakStmt(BreakStmt *S) {
145 VisitStmt(S);
146}
147
148void StmtProfiler::VisitReturnStmt(ReturnStmt *S) {
149 VisitStmt(S);
150}
151
152void StmtProfiler::VisitAsmStmt(AsmStmt *S) {
153 VisitStmt(S);
154 ID.AddBoolean(S->isVolatile());
155 ID.AddBoolean(S->isSimple());
156 VisitStringLiteral(S->getAsmString());
157 ID.AddInteger(S->getNumOutputs());
158 for (unsigned I = 0, N = S->getNumOutputs(); I != N; ++I) {
159 ID.AddString(S->getOutputName(I));
160 VisitStringLiteral(S->getOutputConstraintLiteral(I));
161 }
162 ID.AddInteger(S->getNumInputs());
163 for (unsigned I = 0, N = S->getNumInputs(); I != N; ++I) {
164 ID.AddString(S->getInputName(I));
165 VisitStringLiteral(S->getInputConstraintLiteral(I));
166 }
167 ID.AddInteger(S->getNumClobbers());
168 for (unsigned I = 0, N = S->getNumClobbers(); I != N; ++I)
169 VisitStringLiteral(S->getClobber(I));
170}
171
172void StmtProfiler::VisitCXXCatchStmt(CXXCatchStmt *S) {
173 VisitStmt(S);
174 VisitType(S->getCaughtType());
175}
176
177void StmtProfiler::VisitCXXTryStmt(CXXTryStmt *S) {
178 VisitStmt(S);
179}
180
181void StmtProfiler::VisitObjCForCollectionStmt(ObjCForCollectionStmt *S) {
182 VisitStmt(S);
183}
184
185void StmtProfiler::VisitObjCAtCatchStmt(ObjCAtCatchStmt *S) {
186 VisitStmt(S);
187 ID.AddBoolean(S->hasEllipsis());
188 if (S->getCatchParamDecl())
189 VisitType(S->getCatchParamDecl()->getType());
190}
191
192void StmtProfiler::VisitObjCAtFinallyStmt(ObjCAtFinallyStmt *S) {
193 VisitStmt(S);
194}
195
196void StmtProfiler::VisitObjCAtTryStmt(ObjCAtTryStmt *S) {
197 VisitStmt(S);
198}
199
200void StmtProfiler::VisitObjCAtSynchronizedStmt(ObjCAtSynchronizedStmt *S) {
201 VisitStmt(S);
202}
203
204void StmtProfiler::VisitObjCAtThrowStmt(ObjCAtThrowStmt *S) {
205 VisitStmt(S);
206}
207
Douglas Gregor41ef0c32009-07-28 00:33:38 +0000208void StmtProfiler::VisitExpr(Expr *S) {
209 VisitStmt(S);
210}
211
212void StmtProfiler::VisitDeclRefExpr(DeclRefExpr *S) {
213 VisitExpr(S);
Douglas Gregor218f47f2010-07-13 08:37:11 +0000214 if (!Canonical)
215 VisitNestedNameSpecifier(S->getQualifier());
Douglas Gregor41ef0c32009-07-28 00:33:38 +0000216 VisitDecl(S->getDecl());
Douglas Gregor218f47f2010-07-13 08:37:11 +0000217 if (!Canonical)
218 VisitTemplateArguments(S->getTemplateArgs(), S->getNumTemplateArgs());
Douglas Gregor41ef0c32009-07-28 00:33:38 +0000219}
220
221void StmtProfiler::VisitPredefinedExpr(PredefinedExpr *S) {
222 VisitExpr(S);
223 ID.AddInteger(S->getIdentType());
224}
225
226void StmtProfiler::VisitIntegerLiteral(IntegerLiteral *S) {
227 VisitExpr(S);
228 S->getValue().Profile(ID);
229}
230
231void StmtProfiler::VisitCharacterLiteral(CharacterLiteral *S) {
232 VisitExpr(S);
233 ID.AddBoolean(S->isWide());
234 ID.AddInteger(S->getValue());
235}
236
237void StmtProfiler::VisitFloatingLiteral(FloatingLiteral *S) {
238 VisitExpr(S);
239 S->getValue().Profile(ID);
240 ID.AddBoolean(S->isExact());
241}
242
243void StmtProfiler::VisitImaginaryLiteral(ImaginaryLiteral *S) {
244 VisitExpr(S);
245}
246
247void StmtProfiler::VisitStringLiteral(StringLiteral *S) {
248 VisitExpr(S);
Daniel Dunbar932eb6d2009-09-22 10:06:21 +0000249 ID.AddString(S->getString());
Douglas Gregor41ef0c32009-07-28 00:33:38 +0000250 ID.AddBoolean(S->isWide());
251}
252
253void StmtProfiler::VisitParenExpr(ParenExpr *S) {
254 VisitExpr(S);
255}
256
Nate Begeman2ef13e52009-08-10 23:49:36 +0000257void StmtProfiler::VisitParenListExpr(ParenListExpr *S) {
258 VisitExpr(S);
259}
260
Douglas Gregor41ef0c32009-07-28 00:33:38 +0000261void StmtProfiler::VisitUnaryOperator(UnaryOperator *S) {
262 VisitExpr(S);
263 ID.AddInteger(S->getOpcode());
264}
265
Douglas Gregor8ecdb652010-04-28 22:16:22 +0000266void StmtProfiler::VisitOffsetOfExpr(OffsetOfExpr *S) {
267 VisitType(S->getTypeSourceInfo()->getType());
268 unsigned n = S->getNumComponents();
269 for (unsigned i = 0; i < n; ++i) {
270 const OffsetOfExpr::OffsetOfNode& ON = S->getComponent(i);
271 ID.AddInteger(ON.getKind());
272 switch (ON.getKind()) {
273 case OffsetOfExpr::OffsetOfNode::Array:
274 // Expressions handled below.
275 break;
276
277 case OffsetOfExpr::OffsetOfNode::Field:
278 VisitDecl(ON.getField());
279 break;
280
281 case OffsetOfExpr::OffsetOfNode::Identifier:
282 ID.AddPointer(ON.getFieldName());
283 break;
Sean Huntc3021132010-05-05 15:23:54 +0000284
Douglas Gregorcc8a5d52010-04-29 00:18:15 +0000285 case OffsetOfExpr::OffsetOfNode::Base:
286 // These nodes are implicit, and therefore don't need profiling.
287 break;
Douglas Gregor8ecdb652010-04-28 22:16:22 +0000288 }
289 }
Sean Huntc3021132010-05-05 15:23:54 +0000290
Douglas Gregor8ecdb652010-04-28 22:16:22 +0000291 VisitExpr(S);
292}
293
Douglas Gregor41ef0c32009-07-28 00:33:38 +0000294void StmtProfiler::VisitSizeOfAlignOfExpr(SizeOfAlignOfExpr *S) {
295 VisitExpr(S);
296 ID.AddBoolean(S->isSizeOf());
297 if (S->isArgumentType())
298 VisitType(S->getArgumentType());
299}
300
301void StmtProfiler::VisitArraySubscriptExpr(ArraySubscriptExpr *S) {
302 VisitExpr(S);
303}
304
305void StmtProfiler::VisitCallExpr(CallExpr *S) {
306 VisitExpr(S);
307}
308
309void StmtProfiler::VisitMemberExpr(MemberExpr *S) {
310 VisitExpr(S);
311 VisitDecl(S->getMemberDecl());
Douglas Gregor218f47f2010-07-13 08:37:11 +0000312 if (!Canonical)
313 VisitNestedNameSpecifier(S->getQualifier());
Douglas Gregor41ef0c32009-07-28 00:33:38 +0000314 ID.AddBoolean(S->isArrow());
315}
316
317void StmtProfiler::VisitCompoundLiteralExpr(CompoundLiteralExpr *S) {
318 VisitExpr(S);
319 ID.AddBoolean(S->isFileScope());
320}
321
Douglas Gregor41ef0c32009-07-28 00:33:38 +0000322void StmtProfiler::VisitCastExpr(CastExpr *S) {
323 VisitExpr(S);
324}
325
326void StmtProfiler::VisitImplicitCastExpr(ImplicitCastExpr *S) {
327 VisitCastExpr(S);
John McCall5baba9d2010-08-25 10:28:54 +0000328 ID.AddInteger(S->getValueKind());
Douglas Gregor41ef0c32009-07-28 00:33:38 +0000329}
330
331void StmtProfiler::VisitExplicitCastExpr(ExplicitCastExpr *S) {
332 VisitCastExpr(S);
333 VisitType(S->getTypeAsWritten());
334}
335
336void StmtProfiler::VisitCStyleCastExpr(CStyleCastExpr *S) {
337 VisitExplicitCastExpr(S);
338}
339
340void StmtProfiler::VisitBinaryOperator(BinaryOperator *S) {
341 VisitExpr(S);
342 ID.AddInteger(S->getOpcode());
343}
344
345void StmtProfiler::VisitCompoundAssignOperator(CompoundAssignOperator *S) {
346 VisitBinaryOperator(S);
347}
348
349void StmtProfiler::VisitConditionalOperator(ConditionalOperator *S) {
350 VisitExpr(S);
351}
352
353void StmtProfiler::VisitAddrLabelExpr(AddrLabelExpr *S) {
354 VisitExpr(S);
Douglas Gregor3fe81fc2009-07-28 15:27:13 +0000355 VisitName(S->getLabel()->getID());
Douglas Gregor41ef0c32009-07-28 00:33:38 +0000356}
357
358void StmtProfiler::VisitStmtExpr(StmtExpr *S) {
359 VisitExpr(S);
360}
361
362void StmtProfiler::VisitTypesCompatibleExpr(TypesCompatibleExpr *S) {
363 VisitExpr(S);
364 VisitType(S->getArgType1());
365 VisitType(S->getArgType2());
366}
367
368void StmtProfiler::VisitShuffleVectorExpr(ShuffleVectorExpr *S) {
369 VisitExpr(S);
370}
371
372void StmtProfiler::VisitChooseExpr(ChooseExpr *S) {
373 VisitExpr(S);
374}
375
376void StmtProfiler::VisitGNUNullExpr(GNUNullExpr *S) {
377 VisitExpr(S);
378}
379
Douglas Gregor828e2262009-07-29 16:09:57 +0000380void StmtProfiler::VisitVAArgExpr(VAArgExpr *S) {
381 VisitExpr(S);
382}
383
Douglas Gregor41ef0c32009-07-28 00:33:38 +0000384void StmtProfiler::VisitInitListExpr(InitListExpr *S) {
385 if (S->getSyntacticForm()) {
386 VisitInitListExpr(S->getSyntacticForm());
387 return;
388 }
Mike Stump1eb44332009-09-09 15:08:12 +0000389
Douglas Gregor41ef0c32009-07-28 00:33:38 +0000390 VisitExpr(S);
391}
392
393void StmtProfiler::VisitDesignatedInitExpr(DesignatedInitExpr *S) {
394 VisitExpr(S);
395 ID.AddBoolean(S->usesGNUSyntax());
396 for (DesignatedInitExpr::designators_iterator D = S->designators_begin(),
397 DEnd = S->designators_end();
398 D != DEnd; ++D) {
399 if (D->isFieldDesignator()) {
400 ID.AddInteger(0);
401 VisitName(D->getFieldName());
402 continue;
403 }
Mike Stump1eb44332009-09-09 15:08:12 +0000404
Douglas Gregor41ef0c32009-07-28 00:33:38 +0000405 if (D->isArrayDesignator()) {
406 ID.AddInteger(1);
407 } else {
408 assert(D->isArrayRangeDesignator());
409 ID.AddInteger(2);
410 }
411 ID.AddInteger(D->getFirstExprIndex());
412 }
413}
414
415void StmtProfiler::VisitImplicitValueInitExpr(ImplicitValueInitExpr *S) {
416 VisitExpr(S);
417}
418
419void StmtProfiler::VisitExtVectorElementExpr(ExtVectorElementExpr *S) {
420 VisitExpr(S);
421 VisitName(&S->getAccessor());
422}
423
424void StmtProfiler::VisitBlockExpr(BlockExpr *S) {
425 VisitExpr(S);
426 VisitDecl(S->getBlockDecl());
427}
428
429void StmtProfiler::VisitBlockDeclRefExpr(BlockDeclRefExpr *S) {
430 VisitExpr(S);
431 VisitDecl(S->getDecl());
432 ID.AddBoolean(S->isByRef());
433 ID.AddBoolean(S->isConstQualAdded());
Fariborz Jahanian89f9d3a2010-06-04 19:06:53 +0000434 if (S->getCopyConstructorExpr())
435 Visit(S->getCopyConstructorExpr());
Douglas Gregor41ef0c32009-07-28 00:33:38 +0000436}
437
Douglas Gregora89064a2010-05-19 04:13:23 +0000438static Stmt::StmtClass DecodeOperatorCall(CXXOperatorCallExpr *S,
John McCall2de56d12010-08-25 11:45:40 +0000439 UnaryOperatorKind &UnaryOp,
440 BinaryOperatorKind &BinaryOp) {
Douglas Gregora89064a2010-05-19 04:13:23 +0000441 switch (S->getOperator()) {
442 case OO_None:
443 case OO_New:
444 case OO_Delete:
445 case OO_Array_New:
446 case OO_Array_Delete:
447 case OO_Arrow:
448 case OO_Call:
449 case OO_Conditional:
450 case NUM_OVERLOADED_OPERATORS:
451 llvm_unreachable("Invalid operator call kind");
452 return Stmt::ArraySubscriptExprClass;
453
454 case OO_Plus:
455 if (S->getNumArgs() == 1) {
John McCall2de56d12010-08-25 11:45:40 +0000456 UnaryOp = UO_Plus;
Douglas Gregora89064a2010-05-19 04:13:23 +0000457 return Stmt::UnaryOperatorClass;
458 }
459
John McCall2de56d12010-08-25 11:45:40 +0000460 BinaryOp = BO_Add;
Douglas Gregora89064a2010-05-19 04:13:23 +0000461 return Stmt::BinaryOperatorClass;
462
463 case OO_Minus:
464 if (S->getNumArgs() == 1) {
John McCall2de56d12010-08-25 11:45:40 +0000465 UnaryOp = UO_Minus;
Douglas Gregora89064a2010-05-19 04:13:23 +0000466 return Stmt::UnaryOperatorClass;
467 }
468
John McCall2de56d12010-08-25 11:45:40 +0000469 BinaryOp = BO_Sub;
Douglas Gregora89064a2010-05-19 04:13:23 +0000470 return Stmt::BinaryOperatorClass;
471
472 case OO_Star:
473 if (S->getNumArgs() == 1) {
John McCall2de56d12010-08-25 11:45:40 +0000474 UnaryOp = UO_Minus;
Douglas Gregora89064a2010-05-19 04:13:23 +0000475 return Stmt::UnaryOperatorClass;
476 }
477
John McCall2de56d12010-08-25 11:45:40 +0000478 BinaryOp = BO_Sub;
Douglas Gregora89064a2010-05-19 04:13:23 +0000479 return Stmt::BinaryOperatorClass;
480
481 case OO_Slash:
John McCall2de56d12010-08-25 11:45:40 +0000482 BinaryOp = BO_Div;
Douglas Gregora89064a2010-05-19 04:13:23 +0000483 return Stmt::BinaryOperatorClass;
484
485 case OO_Percent:
John McCall2de56d12010-08-25 11:45:40 +0000486 BinaryOp = BO_Rem;
Douglas Gregora89064a2010-05-19 04:13:23 +0000487 return Stmt::BinaryOperatorClass;
488
489 case OO_Caret:
John McCall2de56d12010-08-25 11:45:40 +0000490 BinaryOp = BO_Xor;
Douglas Gregora89064a2010-05-19 04:13:23 +0000491 return Stmt::BinaryOperatorClass;
492
493 case OO_Amp:
494 if (S->getNumArgs() == 1) {
John McCall2de56d12010-08-25 11:45:40 +0000495 UnaryOp = UO_AddrOf;
Douglas Gregora89064a2010-05-19 04:13:23 +0000496 return Stmt::UnaryOperatorClass;
497 }
498
John McCall2de56d12010-08-25 11:45:40 +0000499 BinaryOp = BO_And;
Douglas Gregora89064a2010-05-19 04:13:23 +0000500 return Stmt::BinaryOperatorClass;
501
502 case OO_Pipe:
John McCall2de56d12010-08-25 11:45:40 +0000503 BinaryOp = BO_Or;
Douglas Gregora89064a2010-05-19 04:13:23 +0000504 return Stmt::BinaryOperatorClass;
505
506 case OO_Tilde:
John McCall2de56d12010-08-25 11:45:40 +0000507 UnaryOp = UO_Not;
Douglas Gregora89064a2010-05-19 04:13:23 +0000508 return Stmt::UnaryOperatorClass;
509
510 case OO_Exclaim:
John McCall2de56d12010-08-25 11:45:40 +0000511 UnaryOp = UO_LNot;
Douglas Gregora89064a2010-05-19 04:13:23 +0000512 return Stmt::UnaryOperatorClass;
513
514 case OO_Equal:
John McCall2de56d12010-08-25 11:45:40 +0000515 BinaryOp = BO_Assign;
Douglas Gregora89064a2010-05-19 04:13:23 +0000516 return Stmt::BinaryOperatorClass;
517
518 case OO_Less:
John McCall2de56d12010-08-25 11:45:40 +0000519 BinaryOp = BO_LT;
Douglas Gregora89064a2010-05-19 04:13:23 +0000520 return Stmt::BinaryOperatorClass;
521
522 case OO_Greater:
John McCall2de56d12010-08-25 11:45:40 +0000523 BinaryOp = BO_GT;
Douglas Gregora89064a2010-05-19 04:13:23 +0000524 return Stmt::BinaryOperatorClass;
525
526 case OO_PlusEqual:
John McCall2de56d12010-08-25 11:45:40 +0000527 BinaryOp = BO_AddAssign;
Douglas Gregora89064a2010-05-19 04:13:23 +0000528 return Stmt::CompoundAssignOperatorClass;
529
530 case OO_MinusEqual:
John McCall2de56d12010-08-25 11:45:40 +0000531 BinaryOp = BO_SubAssign;
Douglas Gregora89064a2010-05-19 04:13:23 +0000532 return Stmt::CompoundAssignOperatorClass;
533
534 case OO_StarEqual:
John McCall2de56d12010-08-25 11:45:40 +0000535 BinaryOp = BO_MulAssign;
Douglas Gregora89064a2010-05-19 04:13:23 +0000536 return Stmt::CompoundAssignOperatorClass;
537
538 case OO_SlashEqual:
John McCall2de56d12010-08-25 11:45:40 +0000539 BinaryOp = BO_DivAssign;
Douglas Gregora89064a2010-05-19 04:13:23 +0000540 return Stmt::CompoundAssignOperatorClass;
541
542 case OO_PercentEqual:
John McCall2de56d12010-08-25 11:45:40 +0000543 BinaryOp = BO_RemAssign;
Douglas Gregora89064a2010-05-19 04:13:23 +0000544 return Stmt::CompoundAssignOperatorClass;
545
546 case OO_CaretEqual:
John McCall2de56d12010-08-25 11:45:40 +0000547 BinaryOp = BO_XorAssign;
Douglas Gregora89064a2010-05-19 04:13:23 +0000548 return Stmt::CompoundAssignOperatorClass;
549
550 case OO_AmpEqual:
John McCall2de56d12010-08-25 11:45:40 +0000551 BinaryOp = BO_AndAssign;
Douglas Gregora89064a2010-05-19 04:13:23 +0000552 return Stmt::CompoundAssignOperatorClass;
553
554 case OO_PipeEqual:
John McCall2de56d12010-08-25 11:45:40 +0000555 BinaryOp = BO_OrAssign;
Douglas Gregora89064a2010-05-19 04:13:23 +0000556 return Stmt::CompoundAssignOperatorClass;
557
558 case OO_LessLess:
John McCall2de56d12010-08-25 11:45:40 +0000559 BinaryOp = BO_Shl;
Douglas Gregora89064a2010-05-19 04:13:23 +0000560 return Stmt::BinaryOperatorClass;
561
562 case OO_GreaterGreater:
John McCall2de56d12010-08-25 11:45:40 +0000563 BinaryOp = BO_Shr;
Douglas Gregora89064a2010-05-19 04:13:23 +0000564 return Stmt::BinaryOperatorClass;
565
566 case OO_LessLessEqual:
John McCall2de56d12010-08-25 11:45:40 +0000567 BinaryOp = BO_ShlAssign;
Douglas Gregora89064a2010-05-19 04:13:23 +0000568 return Stmt::CompoundAssignOperatorClass;
569
570 case OO_GreaterGreaterEqual:
John McCall2de56d12010-08-25 11:45:40 +0000571 BinaryOp = BO_ShrAssign;
Douglas Gregora89064a2010-05-19 04:13:23 +0000572 return Stmt::CompoundAssignOperatorClass;
573
574 case OO_EqualEqual:
John McCall2de56d12010-08-25 11:45:40 +0000575 BinaryOp = BO_EQ;
Douglas Gregora89064a2010-05-19 04:13:23 +0000576 return Stmt::BinaryOperatorClass;
577
578 case OO_ExclaimEqual:
John McCall2de56d12010-08-25 11:45:40 +0000579 BinaryOp = BO_NE;
Douglas Gregora89064a2010-05-19 04:13:23 +0000580 return Stmt::BinaryOperatorClass;
581
582 case OO_LessEqual:
John McCall2de56d12010-08-25 11:45:40 +0000583 BinaryOp = BO_LE;
Douglas Gregora89064a2010-05-19 04:13:23 +0000584 return Stmt::BinaryOperatorClass;
585
586 case OO_GreaterEqual:
John McCall2de56d12010-08-25 11:45:40 +0000587 BinaryOp = BO_GE;
Douglas Gregora89064a2010-05-19 04:13:23 +0000588 return Stmt::BinaryOperatorClass;
589
590 case OO_AmpAmp:
John McCall2de56d12010-08-25 11:45:40 +0000591 BinaryOp = BO_LAnd;
Douglas Gregora89064a2010-05-19 04:13:23 +0000592 return Stmt::BinaryOperatorClass;
593
594 case OO_PipePipe:
John McCall2de56d12010-08-25 11:45:40 +0000595 BinaryOp = BO_LOr;
Douglas Gregora89064a2010-05-19 04:13:23 +0000596 return Stmt::BinaryOperatorClass;
597
598 case OO_PlusPlus:
John McCall2de56d12010-08-25 11:45:40 +0000599 UnaryOp = S->getNumArgs() == 1? UO_PreInc
600 : UO_PostInc;
Douglas Gregora89064a2010-05-19 04:13:23 +0000601 return Stmt::UnaryOperatorClass;
602
603 case OO_MinusMinus:
John McCall2de56d12010-08-25 11:45:40 +0000604 UnaryOp = S->getNumArgs() == 1? UO_PreDec
605 : UO_PostDec;
Douglas Gregora89064a2010-05-19 04:13:23 +0000606 return Stmt::UnaryOperatorClass;
607
608 case OO_Comma:
John McCall2de56d12010-08-25 11:45:40 +0000609 BinaryOp = BO_Comma;
Douglas Gregora89064a2010-05-19 04:13:23 +0000610 return Stmt::BinaryOperatorClass;
611
612
613 case OO_ArrowStar:
John McCall2de56d12010-08-25 11:45:40 +0000614 BinaryOp = BO_PtrMemI;
Douglas Gregora89064a2010-05-19 04:13:23 +0000615 return Stmt::BinaryOperatorClass;
616
617 case OO_Subscript:
618 return Stmt::ArraySubscriptExprClass;
619 }
620
621 llvm_unreachable("Invalid overloaded operator expression");
622}
623
624
Douglas Gregor41ef0c32009-07-28 00:33:38 +0000625void StmtProfiler::VisitCXXOperatorCallExpr(CXXOperatorCallExpr *S) {
Douglas Gregora89064a2010-05-19 04:13:23 +0000626 if (S->isTypeDependent()) {
627 // Type-dependent operator calls are profiled like their underlying
628 // syntactic operator.
John McCall2de56d12010-08-25 11:45:40 +0000629 UnaryOperatorKind UnaryOp = UO_Extension;
630 BinaryOperatorKind BinaryOp = BO_Comma;
Douglas Gregora89064a2010-05-19 04:13:23 +0000631 Stmt::StmtClass SC = DecodeOperatorCall(S, UnaryOp, BinaryOp);
632
633 ID.AddInteger(SC);
634 for (unsigned I = 0, N = S->getNumArgs(); I != N; ++I)
635 Visit(S->getArg(I));
636 if (SC == Stmt::UnaryOperatorClass)
637 ID.AddInteger(UnaryOp);
638 else if (SC == Stmt::BinaryOperatorClass ||
639 SC == Stmt::CompoundAssignOperatorClass)
640 ID.AddInteger(BinaryOp);
641 else
642 assert(SC == Stmt::ArraySubscriptExprClass);
643
644 return;
645 }
646
Douglas Gregor41ef0c32009-07-28 00:33:38 +0000647 VisitCallExpr(S);
648 ID.AddInteger(S->getOperator());
649}
650
651void StmtProfiler::VisitCXXMemberCallExpr(CXXMemberCallExpr *S) {
652 VisitCallExpr(S);
653}
654
655void StmtProfiler::VisitCXXNamedCastExpr(CXXNamedCastExpr *S) {
656 VisitExplicitCastExpr(S);
657}
658
659void StmtProfiler::VisitCXXStaticCastExpr(CXXStaticCastExpr *S) {
660 VisitCXXNamedCastExpr(S);
661}
662
663void StmtProfiler::VisitCXXDynamicCastExpr(CXXDynamicCastExpr *S) {
664 VisitCXXNamedCastExpr(S);
665}
666
667void StmtProfiler::VisitCXXReinterpretCastExpr(CXXReinterpretCastExpr *S) {
668 VisitCXXNamedCastExpr(S);
669}
670
671void StmtProfiler::VisitCXXConstCastExpr(CXXConstCastExpr *S) {
672 VisitCXXNamedCastExpr(S);
673}
674
675void StmtProfiler::VisitCXXBoolLiteralExpr(CXXBoolLiteralExpr *S) {
676 VisitExpr(S);
677 ID.AddBoolean(S->getValue());
678}
679
Douglas Gregor828e2262009-07-29 16:09:57 +0000680void StmtProfiler::VisitCXXNullPtrLiteralExpr(CXXNullPtrLiteralExpr *S) {
681 VisitExpr(S);
682}
683
Douglas Gregor41ef0c32009-07-28 00:33:38 +0000684void StmtProfiler::VisitCXXTypeidExpr(CXXTypeidExpr *S) {
685 VisitExpr(S);
686 if (S->isTypeOperand())
687 VisitType(S->getTypeOperand());
688}
689
Francois Pichet01b7c302010-09-08 12:20:18 +0000690void StmtProfiler::VisitCXXUuidofExpr(CXXUuidofExpr *S) {
691 VisitExpr(S);
692 if (S->isTypeOperand())
693 VisitType(S->getTypeOperand());
694}
695
Douglas Gregor41ef0c32009-07-28 00:33:38 +0000696void StmtProfiler::VisitCXXThisExpr(CXXThisExpr *S) {
697 VisitExpr(S);
698}
699
700void StmtProfiler::VisitCXXThrowExpr(CXXThrowExpr *S) {
701 VisitExpr(S);
702}
703
704void StmtProfiler::VisitCXXDefaultArgExpr(CXXDefaultArgExpr *S) {
705 VisitExpr(S);
706 VisitDecl(S->getParam());
707}
708
709void StmtProfiler::VisitCXXBindTemporaryExpr(CXXBindTemporaryExpr *S) {
710 VisitExpr(S);
711 VisitDecl(
712 const_cast<CXXDestructorDecl *>(S->getTemporary()->getDestructor()));
713}
714
715void StmtProfiler::VisitCXXConstructExpr(CXXConstructExpr *S) {
716 VisitExpr(S);
717 VisitDecl(S->getConstructor());
718 ID.AddBoolean(S->isElidable());
719}
720
721void StmtProfiler::VisitCXXFunctionalCastExpr(CXXFunctionalCastExpr *S) {
722 VisitExplicitCastExpr(S);
723}
724
725void StmtProfiler::VisitCXXTemporaryObjectExpr(CXXTemporaryObjectExpr *S) {
726 VisitCXXConstructExpr(S);
727}
728
Douglas Gregored8abf12010-07-08 06:14:04 +0000729void StmtProfiler::VisitCXXScalarValueInitExpr(CXXScalarValueInitExpr *S) {
Douglas Gregor41ef0c32009-07-28 00:33:38 +0000730 VisitExpr(S);
731}
732
Douglas Gregor41ef0c32009-07-28 00:33:38 +0000733void StmtProfiler::VisitCXXDeleteExpr(CXXDeleteExpr *S) {
734 VisitExpr(S);
735 ID.AddBoolean(S->isGlobalDelete());
736 ID.AddBoolean(S->isArrayForm());
737 VisitDecl(S->getOperatorDelete());
738}
739
740
741void StmtProfiler::VisitCXXNewExpr(CXXNewExpr *S) {
742 VisitExpr(S);
743 VisitType(S->getAllocatedType());
744 VisitDecl(S->getOperatorNew());
745 VisitDecl(S->getOperatorDelete());
746 VisitDecl(S->getConstructor());
747 ID.AddBoolean(S->isArray());
748 ID.AddInteger(S->getNumPlacementArgs());
749 ID.AddBoolean(S->isGlobalNew());
750 ID.AddBoolean(S->isParenTypeId());
751 ID.AddBoolean(S->hasInitializer());
752 ID.AddInteger(S->getNumConstructorArgs());
753}
754
Douglas Gregora71d8192009-09-04 17:36:40 +0000755void StmtProfiler::VisitCXXPseudoDestructorExpr(CXXPseudoDestructorExpr *S) {
756 VisitExpr(S);
757 ID.AddBoolean(S->isArrow());
758 VisitNestedNameSpecifier(S->getQualifier());
759 VisitType(S->getDestroyedType());
760}
761
Argyrios Kyrtzidisc35919b2010-08-15 01:15:38 +0000762void StmtProfiler::VisitOverloadExpr(OverloadExpr *S) {
Argyrios Kyrtzidis7b3e3f62010-08-15 20:53:20 +0000763 VisitExpr(S);
John McCallf7a1a742009-11-24 19:00:30 +0000764 VisitNestedNameSpecifier(S->getQualifier());
Douglas Gregor41ef0c32009-07-28 00:33:38 +0000765 VisitName(S->getName());
John McCallf7a1a742009-11-24 19:00:30 +0000766 ID.AddBoolean(S->hasExplicitTemplateArgs());
767 if (S->hasExplicitTemplateArgs())
Argyrios Kyrtzidisc35919b2010-08-15 01:15:38 +0000768 VisitTemplateArguments(S->getExplicitTemplateArgs().getTemplateArgs(),
769 S->getExplicitTemplateArgs().NumTemplateArgs);
770}
771
772void
773StmtProfiler::VisitUnresolvedLookupExpr(UnresolvedLookupExpr *S) {
774 VisitOverloadExpr(S);
Douglas Gregor41ef0c32009-07-28 00:33:38 +0000775}
776
777void StmtProfiler::VisitUnaryTypeTraitExpr(UnaryTypeTraitExpr *S) {
778 VisitExpr(S);
779 ID.AddInteger(S->getTrait());
780 VisitType(S->getQueriedType());
781}
782
John McCall865d4472009-11-19 22:55:06 +0000783void
784StmtProfiler::VisitDependentScopeDeclRefExpr(DependentScopeDeclRefExpr *S) {
Douglas Gregor41ef0c32009-07-28 00:33:38 +0000785 VisitExpr(S);
786 VisitName(S->getDeclName());
787 VisitNestedNameSpecifier(S->getQualifier());
John McCallf7a1a742009-11-24 19:00:30 +0000788 ID.AddBoolean(S->hasExplicitTemplateArgs());
789 if (S->hasExplicitTemplateArgs())
790 VisitTemplateArguments(S->getTemplateArgs(), S->getNumTemplateArgs());
Douglas Gregor41ef0c32009-07-28 00:33:38 +0000791}
792
Douglas Gregor071f4eb2009-07-28 14:44:31 +0000793void StmtProfiler::VisitCXXExprWithTemporaries(CXXExprWithTemporaries *S) {
794 VisitExpr(S);
Douglas Gregor071f4eb2009-07-28 14:44:31 +0000795 for (unsigned I = 0, N = S->getNumTemporaries(); I != N; ++I)
796 VisitDecl(
797 const_cast<CXXDestructorDecl *>(S->getTemporary(I)->getDestructor()));
798}
799
Mike Stump1eb44332009-09-09 15:08:12 +0000800void
Douglas Gregor071f4eb2009-07-28 14:44:31 +0000801StmtProfiler::VisitCXXUnresolvedConstructExpr(CXXUnresolvedConstructExpr *S) {
802 VisitExpr(S);
803 VisitType(S->getTypeAsWritten());
804}
805
John McCall865d4472009-11-19 22:55:06 +0000806void
807StmtProfiler::VisitCXXDependentScopeMemberExpr(CXXDependentScopeMemberExpr *S) {
John McCallaa81e162009-12-01 22:10:20 +0000808 ID.AddBoolean(S->isImplicitAccess());
809 if (!S->isImplicitAccess()) {
810 VisitExpr(S);
811 ID.AddBoolean(S->isArrow());
812 }
Douglas Gregora38c6872009-09-03 16:14:30 +0000813 VisitNestedNameSpecifier(S->getQualifier());
Douglas Gregor071f4eb2009-07-28 14:44:31 +0000814 VisitName(S->getMember());
John McCallaa81e162009-12-01 22:10:20 +0000815 ID.AddBoolean(S->hasExplicitTemplateArgs());
816 if (S->hasExplicitTemplateArgs())
John McCall129e2df2009-11-30 22:42:35 +0000817 VisitTemplateArguments(S->getTemplateArgs(), S->getNumTemplateArgs());
818}
819
820void StmtProfiler::VisitUnresolvedMemberExpr(UnresolvedMemberExpr *S) {
John McCallaa81e162009-12-01 22:10:20 +0000821 ID.AddBoolean(S->isImplicitAccess());
822 if (!S->isImplicitAccess()) {
823 VisitExpr(S);
824 ID.AddBoolean(S->isArrow());
825 }
John McCall129e2df2009-11-30 22:42:35 +0000826 VisitNestedNameSpecifier(S->getQualifier());
827 VisitName(S->getMemberName());
828 ID.AddBoolean(S->hasExplicitTemplateArgs());
829 if (S->hasExplicitTemplateArgs())
830 VisitTemplateArguments(S->getTemplateArgs(), S->getNumTemplateArgs());
Douglas Gregor071f4eb2009-07-28 14:44:31 +0000831}
832
Sebastian Redl2e156222010-09-10 20:55:43 +0000833void StmtProfiler::VisitCXXNoexceptExpr(CXXNoexceptExpr *S) {
834 VisitExpr(S);
835}
836
John McCall7cd7d1a2010-11-15 23:31:06 +0000837void StmtProfiler::VisitOpaqueValueExpr(OpaqueValueExpr *E) {
838 VisitExpr(E);
839}
840
Douglas Gregor071f4eb2009-07-28 14:44:31 +0000841void StmtProfiler::VisitObjCStringLiteral(ObjCStringLiteral *S) {
842 VisitExpr(S);
843}
844
845void StmtProfiler::VisitObjCEncodeExpr(ObjCEncodeExpr *S) {
846 VisitExpr(S);
847 VisitType(S->getEncodedType());
848}
849
850void StmtProfiler::VisitObjCSelectorExpr(ObjCSelectorExpr *S) {
851 VisitExpr(S);
852 VisitName(S->getSelector());
853}
854
855void StmtProfiler::VisitObjCProtocolExpr(ObjCProtocolExpr *S) {
856 VisitExpr(S);
857 VisitDecl(S->getProtocol());
858}
859
860void StmtProfiler::VisitObjCIvarRefExpr(ObjCIvarRefExpr *S) {
861 VisitExpr(S);
862 VisitDecl(S->getDecl());
863 ID.AddBoolean(S->isArrow());
864 ID.AddBoolean(S->isFreeIvar());
865}
866
867void StmtProfiler::VisitObjCPropertyRefExpr(ObjCPropertyRefExpr *S) {
868 VisitExpr(S);
John McCall12f78a62010-12-02 01:19:52 +0000869 if (S->isImplicitProperty()) {
870 VisitDecl(S->getImplicitPropertyGetter());
871 VisitDecl(S->getImplicitPropertySetter());
872 } else {
873 VisitDecl(S->getExplicitProperty());
Fariborz Jahanian8ac2d442010-10-14 16:04:05 +0000874 }
Fariborz Jahanian8ac2d442010-10-14 16:04:05 +0000875 if (S->isSuperReceiver()) {
876 ID.AddBoolean(S->isSuperReceiver());
John McCall12f78a62010-12-02 01:19:52 +0000877 VisitType(S->getSuperReceiverType());
Fariborz Jahanian8ac2d442010-10-14 16:04:05 +0000878 }
Douglas Gregor071f4eb2009-07-28 14:44:31 +0000879}
880
881void StmtProfiler::VisitObjCMessageExpr(ObjCMessageExpr *S) {
882 VisitExpr(S);
883 VisitName(S->getSelector());
884 VisitDecl(S->getMethodDecl());
885}
886
Douglas Gregor071f4eb2009-07-28 14:44:31 +0000887void StmtProfiler::VisitObjCIsaExpr(ObjCIsaExpr *S) {
888 VisitExpr(S);
889 ID.AddBoolean(S->isArrow());
890}
891
Douglas Gregord584eb22009-07-28 15:32:17 +0000892void StmtProfiler::VisitDecl(Decl *D) {
Douglas Gregor4a3f7802009-07-31 15:45:02 +0000893 ID.AddInteger(D? D->getKind() : 0);
Mike Stump1eb44332009-09-09 15:08:12 +0000894
Douglas Gregorb1975722009-07-30 23:18:24 +0000895 if (Canonical && D) {
Douglas Gregor6ebd15e2009-07-31 05:24:01 +0000896 if (NonTypeTemplateParmDecl *NTTP = dyn_cast<NonTypeTemplateParmDecl>(D)) {
Douglas Gregord584eb22009-07-28 15:32:17 +0000897 ID.AddInteger(NTTP->getDepth());
898 ID.AddInteger(NTTP->getIndex());
Douglas Gregor828e2262009-07-29 16:09:57 +0000899 VisitType(NTTP->getType());
Douglas Gregor41ef0c32009-07-28 00:33:38 +0000900 return;
901 }
Mike Stump1eb44332009-09-09 15:08:12 +0000902
Douglas Gregor4a3f7802009-07-31 15:45:02 +0000903 if (ParmVarDecl *Parm = dyn_cast<ParmVarDecl>(D)) {
904 // The Itanium C++ ABI uses the type of a parameter when mangling
905 // expressions that involve function parameters, so we will use the
906 // parameter's type for establishing function parameter identity. That
Mike Stump1eb44332009-09-09 15:08:12 +0000907 // way, our definition of "equivalent" (per C++ [temp.over.link])
Douglas Gregor4a3f7802009-07-31 15:45:02 +0000908 // matches the definition of "equivalent" used for name mangling.
909 VisitType(Parm->getType());
910 return;
911 }
Mike Stump1eb44332009-09-09 15:08:12 +0000912
Douglas Gregora2ffb982009-07-31 15:46:56 +0000913 if (TemplateTemplateParmDecl *TTP = dyn_cast<TemplateTemplateParmDecl>(D)) {
914 ID.AddInteger(TTP->getDepth());
915 ID.AddInteger(TTP->getIndex());
916 return;
917 }
Douglas Gregor41ef0c32009-07-28 00:33:38 +0000918 }
Mike Stump1eb44332009-09-09 15:08:12 +0000919
Douglas Gregord584eb22009-07-28 15:32:17 +0000920 ID.AddPointer(D? D->getCanonicalDecl() : 0);
921}
922
923void StmtProfiler::VisitType(QualType T) {
924 if (Canonical)
925 T = Context.getCanonicalType(T);
Mike Stump1eb44332009-09-09 15:08:12 +0000926
Douglas Gregor41ef0c32009-07-28 00:33:38 +0000927 ID.AddPointer(T.getAsOpaquePtr());
928}
929
930void StmtProfiler::VisitName(DeclarationName Name) {
931 ID.AddPointer(Name.getAsOpaquePtr());
932}
933
934void StmtProfiler::VisitNestedNameSpecifier(NestedNameSpecifier *NNS) {
935 if (Canonical)
936 NNS = Context.getCanonicalNestedNameSpecifier(NNS);
937 ID.AddPointer(NNS);
938}
939
940void StmtProfiler::VisitTemplateName(TemplateName Name) {
941 if (Canonical)
942 Name = Context.getCanonicalTemplateName(Name);
Mike Stump1eb44332009-09-09 15:08:12 +0000943
Douglas Gregor41ef0c32009-07-28 00:33:38 +0000944 Name.Profile(ID);
945}
946
John McCall833ca992009-10-29 08:12:44 +0000947void StmtProfiler::VisitTemplateArguments(const TemplateArgumentLoc *Args,
Douglas Gregor41ef0c32009-07-28 00:33:38 +0000948 unsigned NumArgs) {
949 ID.AddInteger(NumArgs);
John McCall833ca992009-10-29 08:12:44 +0000950 for (unsigned I = 0; I != NumArgs; ++I)
951 VisitTemplateArgument(Args[I].getArgument());
952}
Mike Stump1eb44332009-09-09 15:08:12 +0000953
John McCall833ca992009-10-29 08:12:44 +0000954void StmtProfiler::VisitTemplateArgument(const TemplateArgument &Arg) {
955 // Mostly repetitive with TemplateArgument::Profile!
956 ID.AddInteger(Arg.getKind());
957 switch (Arg.getKind()) {
958 case TemplateArgument::Null:
959 break;
Mike Stump1eb44332009-09-09 15:08:12 +0000960
John McCall833ca992009-10-29 08:12:44 +0000961 case TemplateArgument::Type:
962 VisitType(Arg.getAsType());
963 break;
Mike Stump1eb44332009-09-09 15:08:12 +0000964
Douglas Gregor788cd062009-11-11 01:00:40 +0000965 case TemplateArgument::Template:
966 VisitTemplateName(Arg.getAsTemplate());
967 break;
Sean Huntc3021132010-05-05 15:23:54 +0000968
John McCall833ca992009-10-29 08:12:44 +0000969 case TemplateArgument::Declaration:
970 VisitDecl(Arg.getAsDecl());
971 break;
Mike Stump1eb44332009-09-09 15:08:12 +0000972
John McCall833ca992009-10-29 08:12:44 +0000973 case TemplateArgument::Integral:
974 Arg.getAsIntegral()->Profile(ID);
975 VisitType(Arg.getIntegralType());
976 break;
Mike Stump1eb44332009-09-09 15:08:12 +0000977
John McCall833ca992009-10-29 08:12:44 +0000978 case TemplateArgument::Expression:
979 Visit(Arg.getAsExpr());
980 break;
Mike Stump1eb44332009-09-09 15:08:12 +0000981
John McCall833ca992009-10-29 08:12:44 +0000982 case TemplateArgument::Pack:
983 const TemplateArgument *Pack = Arg.pack_begin();
984 for (unsigned i = 0, e = Arg.pack_size(); i != e; ++i)
985 VisitTemplateArgument(Pack[i]);
986 break;
Douglas Gregor41ef0c32009-07-28 00:33:38 +0000987 }
988}
989
990void Stmt::Profile(llvm::FoldingSetNodeID &ID, ASTContext &Context,
991 bool Canonical) {
992 StmtProfiler Profiler(ID, Context, Canonical);
993 Profiler.Visit(this);
994}