blob: af2b934125dabb45a8d29f6ec5b59376d03a0f69 [file] [log] [blame]
Douglas Gregor5c088cb2009-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
11// representation that identifiers a statement/expression.
12//
13//===----------------------------------------------------------------------===//
14#include "clang/AST/ASTContext.h"
Douglas Gregor432d2f52009-07-28 14:44:31 +000015#include "clang/AST/DeclCXX.h"
16#include "clang/AST/DeclObjC.h"
Douglas Gregor5c088cb2009-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"
23#include "llvm/Support/Compiler.h"
24using namespace clang;
25
26namespace {
27 class VISIBILITY_HIDDEN StmtProfiler : public StmtVisitor<StmtProfiler> {
28 llvm::FoldingSetNodeID &ID;
29 ASTContext &Context;
30 bool Canonical;
31
32 public:
33 StmtProfiler(llvm::FoldingSetNodeID &ID, ASTContext &Context,
34 bool Canonical)
35 : ID(ID), Context(Context), Canonical(Canonical) { }
36
Douglas Gregor5c088cb2009-07-28 00:33:38 +000037 void VisitStmt(Stmt *S);
Douglas Gregor2f77e812009-07-28 15:27:13 +000038
39#define STMT(Node, Base) void Visit##Node(Node *S);
Douglas Gregor432d2f52009-07-28 14:44:31 +000040#include "clang/AST/StmtNodes.def"
Douglas Gregor5c088cb2009-07-28 00:33:38 +000041
42 /// \brief Visit a declaration that is referenced within an expression
43 /// or statement.
44 void VisitDecl(Decl *D);
45
46 /// \brief Visit a type that is referenced within an expression or
47 /// statement.
48 void VisitType(QualType T);
49
50 /// \brief Visit a name that occurs within an expression or statement.
51 void VisitName(DeclarationName Name);
52
53 /// \brief Visit a nested-name-specifier that occurs within an expression
54 /// or statement.
55 void VisitNestedNameSpecifier(NestedNameSpecifier *NNS);
56
57 /// \brief Visit a template name that occurs within an expression or
58 /// statement.
59 void VisitTemplateName(TemplateName Name);
60
61 /// \brief Visit template arguments that occur within an expression or
62 /// statement.
63 void VisitTemplateArguments(const TemplateArgument *Args, unsigned NumArgs);
64 };
65}
66
67void StmtProfiler::VisitStmt(Stmt *S) {
68 ID.AddInteger(S->getStmtClass());
69 for (Stmt::child_iterator C = S->child_begin(), CEnd = S->child_end();
70 C != CEnd; ++C)
71 Visit(*C);
72}
73
Douglas Gregor2f77e812009-07-28 15:27:13 +000074void StmtProfiler::VisitDeclStmt(DeclStmt *S) {
75 VisitStmt(S);
76 for (DeclStmt::decl_iterator D = S->decl_begin(), DEnd = S->decl_end();
77 D != DEnd; ++D)
78 VisitDecl(*D);
79}
80
81void StmtProfiler::VisitNullStmt(NullStmt *S) {
82 VisitStmt(S);
83}
84
85void StmtProfiler::VisitCompoundStmt(CompoundStmt *S) {
86 VisitStmt(S);
87}
88
89void StmtProfiler::VisitSwitchCase(SwitchCase *S) {
90 VisitStmt(S);
91}
92
93void StmtProfiler::VisitCaseStmt(CaseStmt *S) {
94 VisitStmt(S);
95}
96
97void StmtProfiler::VisitDefaultStmt(DefaultStmt *S) {
98 VisitStmt(S);
99}
100
101void StmtProfiler::VisitLabelStmt(LabelStmt *S) {
102 VisitStmt(S);
103 VisitName(S->getID());
104}
105
106void StmtProfiler::VisitIfStmt(IfStmt *S) {
107 VisitStmt(S);
108}
109
110void StmtProfiler::VisitWhileStmt(WhileStmt *S) {
111 VisitStmt(S);
112}
113
114void StmtProfiler::VisitDoStmt(DoStmt *S) {
115 VisitStmt(S);
116}
117
118void StmtProfiler::VisitForStmt(ForStmt *S) {
119 VisitStmt(S);
120}
121
122void StmtProfiler::VisitGotoStmt(GotoStmt *S) {
123 VisitStmt(S);
124 VisitName(S->getLabel()->getID());
125}
126
127void StmtProfiler::VisitIndirectGotoStmt(IndirectGotoStmt *S) {
128 VisitStmt(S);
129}
130
131void StmtProfiler::VisitContinueStmt(ContinueStmt *S) {
132 VisitStmt(S);
133}
134
135void StmtProfiler::VisitBreakStmt(BreakStmt *S) {
136 VisitStmt(S);
137}
138
139void StmtProfiler::VisitReturnStmt(ReturnStmt *S) {
140 VisitStmt(S);
141}
142
143void StmtProfiler::VisitAsmStmt(AsmStmt *S) {
144 VisitStmt(S);
145 ID.AddBoolean(S->isVolatile());
146 ID.AddBoolean(S->isSimple());
147 VisitStringLiteral(S->getAsmString());
148 ID.AddInteger(S->getNumOutputs());
149 for (unsigned I = 0, N = S->getNumOutputs(); I != N; ++I) {
150 ID.AddString(S->getOutputName(I));
151 VisitStringLiteral(S->getOutputConstraintLiteral(I));
152 }
153 ID.AddInteger(S->getNumInputs());
154 for (unsigned I = 0, N = S->getNumInputs(); I != N; ++I) {
155 ID.AddString(S->getInputName(I));
156 VisitStringLiteral(S->getInputConstraintLiteral(I));
157 }
158 ID.AddInteger(S->getNumClobbers());
159 for (unsigned I = 0, N = S->getNumClobbers(); I != N; ++I)
160 VisitStringLiteral(S->getClobber(I));
161}
162
163void StmtProfiler::VisitCXXCatchStmt(CXXCatchStmt *S) {
164 VisitStmt(S);
165 VisitType(S->getCaughtType());
166}
167
168void StmtProfiler::VisitCXXTryStmt(CXXTryStmt *S) {
169 VisitStmt(S);
170}
171
172void StmtProfiler::VisitObjCForCollectionStmt(ObjCForCollectionStmt *S) {
173 VisitStmt(S);
174}
175
176void StmtProfiler::VisitObjCAtCatchStmt(ObjCAtCatchStmt *S) {
177 VisitStmt(S);
178 ID.AddBoolean(S->hasEllipsis());
179 if (S->getCatchParamDecl())
180 VisitType(S->getCatchParamDecl()->getType());
181}
182
183void StmtProfiler::VisitObjCAtFinallyStmt(ObjCAtFinallyStmt *S) {
184 VisitStmt(S);
185}
186
187void StmtProfiler::VisitObjCAtTryStmt(ObjCAtTryStmt *S) {
188 VisitStmt(S);
189}
190
191void StmtProfiler::VisitObjCAtSynchronizedStmt(ObjCAtSynchronizedStmt *S) {
192 VisitStmt(S);
193}
194
195void StmtProfiler::VisitObjCAtThrowStmt(ObjCAtThrowStmt *S) {
196 VisitStmt(S);
197}
198
Douglas Gregor5c088cb2009-07-28 00:33:38 +0000199void StmtProfiler::VisitExpr(Expr *S) {
200 VisitStmt(S);
201}
202
203void StmtProfiler::VisitDeclRefExpr(DeclRefExpr *S) {
204 VisitExpr(S);
205 VisitDecl(S->getDecl());
206}
207
208void StmtProfiler::VisitPredefinedExpr(PredefinedExpr *S) {
209 VisitExpr(S);
210 ID.AddInteger(S->getIdentType());
211}
212
213void StmtProfiler::VisitIntegerLiteral(IntegerLiteral *S) {
214 VisitExpr(S);
215 S->getValue().Profile(ID);
216}
217
218void StmtProfiler::VisitCharacterLiteral(CharacterLiteral *S) {
219 VisitExpr(S);
220 ID.AddBoolean(S->isWide());
221 ID.AddInteger(S->getValue());
222}
223
224void StmtProfiler::VisitFloatingLiteral(FloatingLiteral *S) {
225 VisitExpr(S);
226 S->getValue().Profile(ID);
227 ID.AddBoolean(S->isExact());
228}
229
230void StmtProfiler::VisitImaginaryLiteral(ImaginaryLiteral *S) {
231 VisitExpr(S);
232}
233
234void StmtProfiler::VisitStringLiteral(StringLiteral *S) {
235 VisitExpr(S);
236 ID.AddString(S->getStrData(), S->getStrData() + S->getByteLength());
237 ID.AddBoolean(S->isWide());
238}
239
240void StmtProfiler::VisitParenExpr(ParenExpr *S) {
241 VisitExpr(S);
242}
243
244void StmtProfiler::VisitUnaryOperator(UnaryOperator *S) {
245 VisitExpr(S);
246 ID.AddInteger(S->getOpcode());
247}
248
249void StmtProfiler::VisitSizeOfAlignOfExpr(SizeOfAlignOfExpr *S) {
250 VisitExpr(S);
251 ID.AddBoolean(S->isSizeOf());
252 if (S->isArgumentType())
253 VisitType(S->getArgumentType());
254}
255
256void StmtProfiler::VisitArraySubscriptExpr(ArraySubscriptExpr *S) {
257 VisitExpr(S);
258}
259
260void StmtProfiler::VisitCallExpr(CallExpr *S) {
261 VisitExpr(S);
262}
263
264void StmtProfiler::VisitMemberExpr(MemberExpr *S) {
265 VisitExpr(S);
266 VisitDecl(S->getMemberDecl());
267 ID.AddBoolean(S->isArrow());
268}
269
270void StmtProfiler::VisitCompoundLiteralExpr(CompoundLiteralExpr *S) {
271 VisitExpr(S);
272 ID.AddBoolean(S->isFileScope());
273}
274
Douglas Gregor5c088cb2009-07-28 00:33:38 +0000275void StmtProfiler::VisitCastExpr(CastExpr *S) {
276 VisitExpr(S);
277}
278
279void StmtProfiler::VisitImplicitCastExpr(ImplicitCastExpr *S) {
280 VisitCastExpr(S);
281 ID.AddBoolean(S->isLvalueCast());
282}
283
284void StmtProfiler::VisitExplicitCastExpr(ExplicitCastExpr *S) {
285 VisitCastExpr(S);
286 VisitType(S->getTypeAsWritten());
287}
288
289void StmtProfiler::VisitCStyleCastExpr(CStyleCastExpr *S) {
290 VisitExplicitCastExpr(S);
291}
292
293void StmtProfiler::VisitBinaryOperator(BinaryOperator *S) {
294 VisitExpr(S);
295 ID.AddInteger(S->getOpcode());
296}
297
298void StmtProfiler::VisitCompoundAssignOperator(CompoundAssignOperator *S) {
299 VisitBinaryOperator(S);
300}
301
302void StmtProfiler::VisitConditionalOperator(ConditionalOperator *S) {
303 VisitExpr(S);
304}
305
306void StmtProfiler::VisitAddrLabelExpr(AddrLabelExpr *S) {
307 VisitExpr(S);
Douglas Gregor2f77e812009-07-28 15:27:13 +0000308 VisitName(S->getLabel()->getID());
Douglas Gregor5c088cb2009-07-28 00:33:38 +0000309}
310
311void StmtProfiler::VisitStmtExpr(StmtExpr *S) {
312 VisitExpr(S);
313}
314
315void StmtProfiler::VisitTypesCompatibleExpr(TypesCompatibleExpr *S) {
316 VisitExpr(S);
317 VisitType(S->getArgType1());
318 VisitType(S->getArgType2());
319}
320
321void StmtProfiler::VisitShuffleVectorExpr(ShuffleVectorExpr *S) {
322 VisitExpr(S);
323}
324
325void StmtProfiler::VisitChooseExpr(ChooseExpr *S) {
326 VisitExpr(S);
327}
328
329void StmtProfiler::VisitGNUNullExpr(GNUNullExpr *S) {
330 VisitExpr(S);
331}
332
333void StmtProfiler::VisitInitListExpr(InitListExpr *S) {
334 if (S->getSyntacticForm()) {
335 VisitInitListExpr(S->getSyntacticForm());
336 return;
337 }
338
339 VisitExpr(S);
340}
341
342void StmtProfiler::VisitDesignatedInitExpr(DesignatedInitExpr *S) {
343 VisitExpr(S);
344 ID.AddBoolean(S->usesGNUSyntax());
345 for (DesignatedInitExpr::designators_iterator D = S->designators_begin(),
346 DEnd = S->designators_end();
347 D != DEnd; ++D) {
348 if (D->isFieldDesignator()) {
349 ID.AddInteger(0);
350 VisitName(D->getFieldName());
351 continue;
352 }
353
354 if (D->isArrayDesignator()) {
355 ID.AddInteger(1);
356 } else {
357 assert(D->isArrayRangeDesignator());
358 ID.AddInteger(2);
359 }
360 ID.AddInteger(D->getFirstExprIndex());
361 }
362}
363
364void StmtProfiler::VisitImplicitValueInitExpr(ImplicitValueInitExpr *S) {
365 VisitExpr(S);
366}
367
368void StmtProfiler::VisitExtVectorElementExpr(ExtVectorElementExpr *S) {
369 VisitExpr(S);
370 VisitName(&S->getAccessor());
371}
372
373void StmtProfiler::VisitBlockExpr(BlockExpr *S) {
374 VisitExpr(S);
375 VisitDecl(S->getBlockDecl());
376}
377
378void StmtProfiler::VisitBlockDeclRefExpr(BlockDeclRefExpr *S) {
379 VisitExpr(S);
380 VisitDecl(S->getDecl());
381 ID.AddBoolean(S->isByRef());
382 ID.AddBoolean(S->isConstQualAdded());
383}
384
385void StmtProfiler::VisitCXXOperatorCallExpr(CXXOperatorCallExpr *S) {
386 VisitCallExpr(S);
387 ID.AddInteger(S->getOperator());
388}
389
390void StmtProfiler::VisitCXXMemberCallExpr(CXXMemberCallExpr *S) {
391 VisitCallExpr(S);
392}
393
394void StmtProfiler::VisitCXXNamedCastExpr(CXXNamedCastExpr *S) {
395 VisitExplicitCastExpr(S);
396}
397
398void StmtProfiler::VisitCXXStaticCastExpr(CXXStaticCastExpr *S) {
399 VisitCXXNamedCastExpr(S);
400}
401
402void StmtProfiler::VisitCXXDynamicCastExpr(CXXDynamicCastExpr *S) {
403 VisitCXXNamedCastExpr(S);
404}
405
406void StmtProfiler::VisitCXXReinterpretCastExpr(CXXReinterpretCastExpr *S) {
407 VisitCXXNamedCastExpr(S);
408}
409
410void StmtProfiler::VisitCXXConstCastExpr(CXXConstCastExpr *S) {
411 VisitCXXNamedCastExpr(S);
412}
413
414void StmtProfiler::VisitCXXBoolLiteralExpr(CXXBoolLiteralExpr *S) {
415 VisitExpr(S);
416 ID.AddBoolean(S->getValue());
417}
418
419void StmtProfiler::VisitCXXTypeidExpr(CXXTypeidExpr *S) {
420 VisitExpr(S);
421 if (S->isTypeOperand())
422 VisitType(S->getTypeOperand());
423}
424
425void StmtProfiler::VisitCXXThisExpr(CXXThisExpr *S) {
426 VisitExpr(S);
427}
428
429void StmtProfiler::VisitCXXThrowExpr(CXXThrowExpr *S) {
430 VisitExpr(S);
431}
432
433void StmtProfiler::VisitCXXDefaultArgExpr(CXXDefaultArgExpr *S) {
434 VisitExpr(S);
435 VisitDecl(S->getParam());
436}
437
438void StmtProfiler::VisitCXXBindTemporaryExpr(CXXBindTemporaryExpr *S) {
439 VisitExpr(S);
440 VisitDecl(
441 const_cast<CXXDestructorDecl *>(S->getTemporary()->getDestructor()));
442}
443
444void StmtProfiler::VisitCXXConstructExpr(CXXConstructExpr *S) {
445 VisitExpr(S);
446 VisitDecl(S->getConstructor());
447 ID.AddBoolean(S->isElidable());
448}
449
450void StmtProfiler::VisitCXXFunctionalCastExpr(CXXFunctionalCastExpr *S) {
451 VisitExplicitCastExpr(S);
452}
453
454void StmtProfiler::VisitCXXTemporaryObjectExpr(CXXTemporaryObjectExpr *S) {
455 VisitCXXConstructExpr(S);
456}
457
458void StmtProfiler::VisitCXXZeroInitValueExpr(CXXZeroInitValueExpr *S) {
459 VisitExpr(S);
460}
461
462void StmtProfiler::VisitCXXConditionDeclExpr(CXXConditionDeclExpr *S) {
463 VisitDeclRefExpr(S);
464}
465
466void StmtProfiler::VisitCXXDeleteExpr(CXXDeleteExpr *S) {
467 VisitExpr(S);
468 ID.AddBoolean(S->isGlobalDelete());
469 ID.AddBoolean(S->isArrayForm());
470 VisitDecl(S->getOperatorDelete());
471}
472
473
474void StmtProfiler::VisitCXXNewExpr(CXXNewExpr *S) {
475 VisitExpr(S);
476 VisitType(S->getAllocatedType());
477 VisitDecl(S->getOperatorNew());
478 VisitDecl(S->getOperatorDelete());
479 VisitDecl(S->getConstructor());
480 ID.AddBoolean(S->isArray());
481 ID.AddInteger(S->getNumPlacementArgs());
482 ID.AddBoolean(S->isGlobalNew());
483 ID.AddBoolean(S->isParenTypeId());
484 ID.AddBoolean(S->hasInitializer());
485 ID.AddInteger(S->getNumConstructorArgs());
486}
487
488void
489StmtProfiler::VisitUnresolvedFunctionNameExpr(UnresolvedFunctionNameExpr *S) {
490 VisitExpr(S);
491 VisitName(S->getName());
492}
493
494void StmtProfiler::VisitUnaryTypeTraitExpr(UnaryTypeTraitExpr *S) {
495 VisitExpr(S);
496 ID.AddInteger(S->getTrait());
497 VisitType(S->getQueriedType());
498}
499
500void StmtProfiler::VisitQualifiedDeclRefExpr(QualifiedDeclRefExpr *S) {
501 VisitDeclRefExpr(S);
502 VisitNestedNameSpecifier(S->getQualifier());
503}
504
505void StmtProfiler::VisitUnresolvedDeclRefExpr(UnresolvedDeclRefExpr *S) {
506 VisitExpr(S);
507 VisitName(S->getDeclName());
508 VisitNestedNameSpecifier(S->getQualifier());
509 ID.AddBoolean(S->isAddressOfOperand());
510}
511
512void StmtProfiler::VisitTemplateIdRefExpr(TemplateIdRefExpr *S) {
513 VisitExpr(S);
514 VisitNestedNameSpecifier(S->getQualifier());
515 VisitTemplateName(S->getTemplateName());
516 VisitTemplateArguments(S->getTemplateArgs(), S->getNumTemplateArgs());
517}
518
Douglas Gregor432d2f52009-07-28 14:44:31 +0000519void StmtProfiler::VisitCXXExprWithTemporaries(CXXExprWithTemporaries *S) {
520 VisitExpr(S);
521 ID.AddBoolean(S->shouldDestroyTemporaries());
522 for (unsigned I = 0, N = S->getNumTemporaries(); I != N; ++I)
523 VisitDecl(
524 const_cast<CXXDestructorDecl *>(S->getTemporary(I)->getDestructor()));
525}
526
527void
528StmtProfiler::VisitCXXUnresolvedConstructExpr(CXXUnresolvedConstructExpr *S) {
529 VisitExpr(S);
530 VisitType(S->getTypeAsWritten());
531}
532
533void StmtProfiler::VisitCXXUnresolvedMemberExpr(CXXUnresolvedMemberExpr *S) {
534 VisitExpr(S);
535 ID.AddBoolean(S->isArrow());
536 VisitName(S->getMember());
537}
538
539void StmtProfiler::VisitObjCStringLiteral(ObjCStringLiteral *S) {
540 VisitExpr(S);
541}
542
543void StmtProfiler::VisitObjCEncodeExpr(ObjCEncodeExpr *S) {
544 VisitExpr(S);
545 VisitType(S->getEncodedType());
546}
547
548void StmtProfiler::VisitObjCSelectorExpr(ObjCSelectorExpr *S) {
549 VisitExpr(S);
550 VisitName(S->getSelector());
551}
552
553void StmtProfiler::VisitObjCProtocolExpr(ObjCProtocolExpr *S) {
554 VisitExpr(S);
555 VisitDecl(S->getProtocol());
556}
557
558void StmtProfiler::VisitObjCIvarRefExpr(ObjCIvarRefExpr *S) {
559 VisitExpr(S);
560 VisitDecl(S->getDecl());
561 ID.AddBoolean(S->isArrow());
562 ID.AddBoolean(S->isFreeIvar());
563}
564
565void StmtProfiler::VisitObjCPropertyRefExpr(ObjCPropertyRefExpr *S) {
566 VisitExpr(S);
567 VisitDecl(S->getProperty());
568}
569
570void StmtProfiler::VisitObjCKVCRefExpr(ObjCKVCRefExpr *S) {
571 VisitExpr(S);
572 VisitDecl(S->getGetterMethod());
573 VisitDecl(S->getSetterMethod());
574 VisitDecl(S->getClassProp());
575}
576
577void StmtProfiler::VisitObjCMessageExpr(ObjCMessageExpr *S) {
578 VisitExpr(S);
579 VisitName(S->getSelector());
580 VisitDecl(S->getMethodDecl());
581}
582
583void StmtProfiler::VisitObjCSuperExpr(ObjCSuperExpr *S) {
584 VisitExpr(S);
585}
586
587void StmtProfiler::VisitObjCIsaExpr(ObjCIsaExpr *S) {
588 VisitExpr(S);
589 ID.AddBoolean(S->isArrow());
590}
591
Douglas Gregor455cfb82009-07-28 15:32:17 +0000592void StmtProfiler::VisitDecl(Decl *D) {
Douglas Gregor5c088cb2009-07-28 00:33:38 +0000593 if (Canonical) {
Douglas Gregor455cfb82009-07-28 15:32:17 +0000594 if (NonTypeTemplateParmDecl *NTTP
595 = dyn_cast_or_null<NonTypeTemplateParmDecl>(D)) {
596 ID.AddInteger(NTTP->getDepth());
597 ID.AddInteger(NTTP->getIndex());
Douglas Gregor5c088cb2009-07-28 00:33:38 +0000598 return;
599 }
600
Douglas Gregor455cfb82009-07-28 15:32:17 +0000601 // FIXME: Template template parameters?
Douglas Gregor5c088cb2009-07-28 00:33:38 +0000602 }
603
Douglas Gregor455cfb82009-07-28 15:32:17 +0000604 ID.AddPointer(D? D->getCanonicalDecl() : 0);
605}
606
607void StmtProfiler::VisitType(QualType T) {
608 if (Canonical)
609 T = Context.getCanonicalType(T);
610
Douglas Gregor5c088cb2009-07-28 00:33:38 +0000611 ID.AddPointer(T.getAsOpaquePtr());
612}
613
614void StmtProfiler::VisitName(DeclarationName Name) {
615 ID.AddPointer(Name.getAsOpaquePtr());
616}
617
618void StmtProfiler::VisitNestedNameSpecifier(NestedNameSpecifier *NNS) {
619 if (Canonical)
620 NNS = Context.getCanonicalNestedNameSpecifier(NNS);
621 ID.AddPointer(NNS);
622}
623
624void StmtProfiler::VisitTemplateName(TemplateName Name) {
625 if (Canonical)
626 Name = Context.getCanonicalTemplateName(Name);
627
628 Name.Profile(ID);
629}
630
631void StmtProfiler::VisitTemplateArguments(const TemplateArgument *Args,
632 unsigned NumArgs) {
633 ID.AddInteger(NumArgs);
634 for (unsigned I = 0; I != NumArgs; ++I) {
635 const TemplateArgument &Arg = Args[I];
636
637 // Mostly repetitive with TemplateArgument::Profile!
638 ID.AddInteger(Arg.getKind());
639 switch (Arg.getKind()) {
640 case TemplateArgument::Null:
641 break;
642
643 case TemplateArgument::Type:
644 VisitType(Arg.getAsType());
645 break;
646
647 case TemplateArgument::Declaration:
648 VisitDecl(Arg.getAsDecl());
649 break;
650
651 case TemplateArgument::Integral:
652 Arg.getAsIntegral()->Profile(ID);
653 VisitType(Arg.getIntegralType());
654 break;
655
656 case TemplateArgument::Expression:
657 Visit(Arg.getAsExpr());
658 break;
659
660 case TemplateArgument::Pack:
661 VisitTemplateArguments(Arg.pack_begin(), Arg.pack_size());
662 break;
663 }
664 }
665}
666
667void Stmt::Profile(llvm::FoldingSetNodeID &ID, ASTContext &Context,
668 bool Canonical) {
669 StmtProfiler Profiler(ID, Context, Canonical);
670 Profiler.Visit(this);
671}