blob: b379745b4afb281c563deed8835a1b7255933959 [file] [log] [blame]
Douglas Gregor5c193b92009-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 Gregor32615a12009-07-28 16:39:25 +000011// representation that identifies a statement/expression.
Douglas Gregor5c193b92009-07-28 00:33:38 +000012//
13//===----------------------------------------------------------------------===//
14#include "clang/AST/ASTContext.h"
Douglas Gregora7095092009-07-28 14:44:31 +000015#include "clang/AST/DeclCXX.h"
16#include "clang/AST/DeclObjC.h"
Douglas Gregor5c193b92009-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"
Alexey Bataev1a3320e2015-08-25 14:24:04 +000021#include "clang/AST/ExprOpenMP.h"
Douglas Gregor5c193b92009-07-28 00:33:38 +000022#include "clang/AST/StmtVisitor.h"
23#include "llvm/ADT/FoldingSet.h"
Douglas Gregor5c193b92009-07-28 00:33:38 +000024using namespace clang;
25
26namespace {
Chandler Carruth631abd92011-06-16 06:47:06 +000027 class StmtProfiler : public ConstStmtVisitor<StmtProfiler> {
Douglas Gregor5c193b92009-07-28 00:33:38 +000028 llvm::FoldingSetNodeID &ID;
Jay Foad39c79802011-01-12 09:06:06 +000029 const ASTContext &Context;
Douglas Gregor5c193b92009-07-28 00:33:38 +000030 bool Canonical;
Mike Stump11289f42009-09-09 15:08:12 +000031
Douglas Gregor5c193b92009-07-28 00:33:38 +000032 public:
Jay Foad39c79802011-01-12 09:06:06 +000033 StmtProfiler(llvm::FoldingSetNodeID &ID, const ASTContext &Context,
Mike Stump11289f42009-09-09 15:08:12 +000034 bool Canonical)
Douglas Gregor5c193b92009-07-28 00:33:38 +000035 : ID(ID), Context(Context), Canonical(Canonical) { }
Mike Stump11289f42009-09-09 15:08:12 +000036
Chandler Carruth631abd92011-06-16 06:47:06 +000037 void VisitStmt(const Stmt *S);
Mike Stump11289f42009-09-09 15:08:12 +000038
Chandler Carruth631abd92011-06-16 06:47:06 +000039#define STMT(Node, Base) void Visit##Node(const Node *S);
Alexis Hunt656bb312010-05-05 15:24:00 +000040#include "clang/AST/StmtNodes.inc"
Mike Stump11289f42009-09-09 15:08:12 +000041
Douglas Gregor5c193b92009-07-28 00:33:38 +000042 /// \brief Visit a declaration that is referenced within an expression
43 /// or statement.
Chandler Carruth631abd92011-06-16 06:47:06 +000044 void VisitDecl(const Decl *D);
Mike Stump11289f42009-09-09 15:08:12 +000045
46 /// \brief Visit a type that is referenced within an expression or
Douglas Gregor5c193b92009-07-28 00:33:38 +000047 /// statement.
48 void VisitType(QualType T);
Mike Stump11289f42009-09-09 15:08:12 +000049
Douglas Gregor5c193b92009-07-28 00:33:38 +000050 /// \brief Visit a name that occurs within an expression or statement.
51 void VisitName(DeclarationName Name);
Mike Stump11289f42009-09-09 15:08:12 +000052
Douglas Gregor5c193b92009-07-28 00:33:38 +000053 /// \brief Visit a nested-name-specifier that occurs within an expression
54 /// or statement.
55 void VisitNestedNameSpecifier(NestedNameSpecifier *NNS);
Mike Stump11289f42009-09-09 15:08:12 +000056
Douglas Gregor5c193b92009-07-28 00:33:38 +000057 /// \brief Visit a template name that occurs within an expression or
58 /// statement.
59 void VisitTemplateName(TemplateName Name);
Mike Stump11289f42009-09-09 15:08:12 +000060
Douglas Gregor5c193b92009-07-28 00:33:38 +000061 /// \brief Visit template arguments that occur within an expression or
62 /// statement.
Chandler Carruth631abd92011-06-16 06:47:06 +000063 void VisitTemplateArguments(const TemplateArgumentLoc *Args,
64 unsigned NumArgs);
John McCall0ad16662009-10-29 08:12:44 +000065
66 /// \brief Visit a single template argument.
67 void VisitTemplateArgument(const TemplateArgument &Arg);
Douglas Gregor5c193b92009-07-28 00:33:38 +000068 };
Alexander Kornienkoab9db512015-06-22 23:07:51 +000069}
Douglas Gregor5c193b92009-07-28 00:33:38 +000070
Chandler Carruth631abd92011-06-16 06:47:06 +000071void StmtProfiler::VisitStmt(const Stmt *S) {
Douglas Gregor5c193b92009-07-28 00:33:38 +000072 ID.AddInteger(S->getStmtClass());
Benjamin Kramer642f1732015-07-02 21:03:14 +000073 for (const Stmt *SubStmt : S->children()) {
74 if (SubStmt)
75 Visit(SubStmt);
Peter Collingbournecdb9f302012-03-01 16:34:31 +000076 else
77 ID.AddInteger(0);
78 }
Douglas Gregor5c193b92009-07-28 00:33:38 +000079}
80
Chandler Carruth631abd92011-06-16 06:47:06 +000081void StmtProfiler::VisitDeclStmt(const DeclStmt *S) {
Douglas Gregor44882592009-07-28 15:27:13 +000082 VisitStmt(S);
Aaron Ballman535bbcc2014-03-14 17:01:24 +000083 for (const auto *D : S->decls())
84 VisitDecl(D);
Douglas Gregor44882592009-07-28 15:27:13 +000085}
86
Chandler Carruth631abd92011-06-16 06:47:06 +000087void StmtProfiler::VisitNullStmt(const NullStmt *S) {
Douglas Gregor44882592009-07-28 15:27:13 +000088 VisitStmt(S);
89}
90
Chandler Carruth631abd92011-06-16 06:47:06 +000091void StmtProfiler::VisitCompoundStmt(const CompoundStmt *S) {
Douglas Gregor44882592009-07-28 15:27:13 +000092 VisitStmt(S);
93}
94
Chandler Carruth631abd92011-06-16 06:47:06 +000095void StmtProfiler::VisitSwitchCase(const SwitchCase *S) {
Douglas Gregor44882592009-07-28 15:27:13 +000096 VisitStmt(S);
97}
98
Chandler Carruth631abd92011-06-16 06:47:06 +000099void StmtProfiler::VisitCaseStmt(const CaseStmt *S) {
Douglas Gregor44882592009-07-28 15:27:13 +0000100 VisitStmt(S);
101}
102
Chandler Carruth631abd92011-06-16 06:47:06 +0000103void StmtProfiler::VisitDefaultStmt(const DefaultStmt *S) {
Douglas Gregor44882592009-07-28 15:27:13 +0000104 VisitStmt(S);
105}
106
Chandler Carruth631abd92011-06-16 06:47:06 +0000107void StmtProfiler::VisitLabelStmt(const LabelStmt *S) {
Douglas Gregor44882592009-07-28 15:27:13 +0000108 VisitStmt(S);
Chris Lattnerc8e630e2011-02-17 07:39:24 +0000109 VisitDecl(S->getDecl());
Douglas Gregor44882592009-07-28 15:27:13 +0000110}
111
Richard Smithc202b282012-04-14 00:33:13 +0000112void StmtProfiler::VisitAttributedStmt(const AttributedStmt *S) {
113 VisitStmt(S);
114 // TODO: maybe visit attributes?
115}
116
Chandler Carruth631abd92011-06-16 06:47:06 +0000117void StmtProfiler::VisitIfStmt(const IfStmt *S) {
Douglas Gregor44882592009-07-28 15:27:13 +0000118 VisitStmt(S);
Douglas Gregor7bab5ff2009-11-25 00:27:52 +0000119 VisitDecl(S->getConditionVariable());
Douglas Gregor44882592009-07-28 15:27:13 +0000120}
121
Chandler Carruth631abd92011-06-16 06:47:06 +0000122void StmtProfiler::VisitSwitchStmt(const SwitchStmt *S) {
Douglas Gregor00044172009-07-29 16:09:57 +0000123 VisitStmt(S);
Douglas Gregor7bab5ff2009-11-25 00:27:52 +0000124 VisitDecl(S->getConditionVariable());
Douglas Gregor00044172009-07-29 16:09:57 +0000125}
126
Chandler Carruth631abd92011-06-16 06:47:06 +0000127void StmtProfiler::VisitWhileStmt(const WhileStmt *S) {
Douglas Gregor44882592009-07-28 15:27:13 +0000128 VisitStmt(S);
Douglas Gregor7bab5ff2009-11-25 00:27:52 +0000129 VisitDecl(S->getConditionVariable());
Douglas Gregor44882592009-07-28 15:27:13 +0000130}
131
Chandler Carruth631abd92011-06-16 06:47:06 +0000132void StmtProfiler::VisitDoStmt(const DoStmt *S) {
Douglas Gregor44882592009-07-28 15:27:13 +0000133 VisitStmt(S);
134}
135
Chandler Carruth631abd92011-06-16 06:47:06 +0000136void StmtProfiler::VisitForStmt(const ForStmt *S) {
Douglas Gregor44882592009-07-28 15:27:13 +0000137 VisitStmt(S);
138}
139
Chandler Carruth631abd92011-06-16 06:47:06 +0000140void StmtProfiler::VisitGotoStmt(const GotoStmt *S) {
Douglas Gregor44882592009-07-28 15:27:13 +0000141 VisitStmt(S);
Chris Lattnerc8e630e2011-02-17 07:39:24 +0000142 VisitDecl(S->getLabel());
Douglas Gregor44882592009-07-28 15:27:13 +0000143}
144
Chandler Carruth631abd92011-06-16 06:47:06 +0000145void StmtProfiler::VisitIndirectGotoStmt(const IndirectGotoStmt *S) {
Douglas Gregor44882592009-07-28 15:27:13 +0000146 VisitStmt(S);
147}
148
Chandler Carruth631abd92011-06-16 06:47:06 +0000149void StmtProfiler::VisitContinueStmt(const ContinueStmt *S) {
Douglas Gregor44882592009-07-28 15:27:13 +0000150 VisitStmt(S);
151}
152
Chandler Carruth631abd92011-06-16 06:47:06 +0000153void StmtProfiler::VisitBreakStmt(const BreakStmt *S) {
Douglas Gregor44882592009-07-28 15:27:13 +0000154 VisitStmt(S);
155}
156
Chandler Carruth631abd92011-06-16 06:47:06 +0000157void StmtProfiler::VisitReturnStmt(const ReturnStmt *S) {
Douglas Gregor44882592009-07-28 15:27:13 +0000158 VisitStmt(S);
159}
160
Chad Rosierde70e0e2012-08-25 00:11:56 +0000161void StmtProfiler::VisitGCCAsmStmt(const GCCAsmStmt *S) {
Douglas Gregor44882592009-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 Rosierd9fb09a2012-08-27 23:28:41 +0000178 VisitStringLiteral(S->getClobberStringLiteral(I));
Douglas Gregor44882592009-07-28 15:27:13 +0000179}
180
Chad Rosier32503022012-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 Carruth631abd92011-06-16 06:47:06 +0000186void StmtProfiler::VisitCXXCatchStmt(const CXXCatchStmt *S) {
Douglas Gregor44882592009-07-28 15:27:13 +0000187 VisitStmt(S);
188 VisitType(S->getCaughtType());
189}
190
Chandler Carruth631abd92011-06-16 06:47:06 +0000191void StmtProfiler::VisitCXXTryStmt(const CXXTryStmt *S) {
Douglas Gregor44882592009-07-28 15:27:13 +0000192 VisitStmt(S);
193}
194
Chandler Carruth631abd92011-06-16 06:47:06 +0000195void StmtProfiler::VisitCXXForRangeStmt(const CXXForRangeStmt *S) {
Richard Smith02e85f32011-04-14 22:09:26 +0000196 VisitStmt(S);
197}
198
Douglas Gregordeb4a2be2011-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 Carruth631abd92011-06-16 06:47:06 +0000206void StmtProfiler::VisitSEHTryStmt(const SEHTryStmt *S) {
John Wiegley1c0675e2011-04-28 01:08:34 +0000207 VisitStmt(S);
208}
209
Chandler Carruth631abd92011-06-16 06:47:06 +0000210void StmtProfiler::VisitSEHFinallyStmt(const SEHFinallyStmt *S) {
John Wiegley1c0675e2011-04-28 01:08:34 +0000211 VisitStmt(S);
212}
213
Chandler Carruth631abd92011-06-16 06:47:06 +0000214void StmtProfiler::VisitSEHExceptStmt(const SEHExceptStmt *S) {
John Wiegley1c0675e2011-04-28 01:08:34 +0000215 VisitStmt(S);
216}
217
Nico Weber9b982072014-07-07 00:12:30 +0000218void StmtProfiler::VisitSEHLeaveStmt(const SEHLeaveStmt *S) {
219 VisitStmt(S);
220}
221
Tareq A. Siraj24110cc2013-04-16 18:53:08 +0000222void StmtProfiler::VisitCapturedStmt(const CapturedStmt *S) {
223 VisitStmt(S);
224}
225
Chandler Carruth631abd92011-06-16 06:47:06 +0000226void StmtProfiler::VisitObjCForCollectionStmt(const ObjCForCollectionStmt *S) {
Douglas Gregor44882592009-07-28 15:27:13 +0000227 VisitStmt(S);
228}
229
Chandler Carruth631abd92011-06-16 06:47:06 +0000230void StmtProfiler::VisitObjCAtCatchStmt(const ObjCAtCatchStmt *S) {
Douglas Gregor44882592009-07-28 15:27:13 +0000231 VisitStmt(S);
232 ID.AddBoolean(S->hasEllipsis());
233 if (S->getCatchParamDecl())
234 VisitType(S->getCatchParamDecl()->getType());
235}
236
Chandler Carruth631abd92011-06-16 06:47:06 +0000237void StmtProfiler::VisitObjCAtFinallyStmt(const ObjCAtFinallyStmt *S) {
Douglas Gregor44882592009-07-28 15:27:13 +0000238 VisitStmt(S);
239}
240
Chandler Carruth631abd92011-06-16 06:47:06 +0000241void StmtProfiler::VisitObjCAtTryStmt(const ObjCAtTryStmt *S) {
Douglas Gregor44882592009-07-28 15:27:13 +0000242 VisitStmt(S);
243}
244
Chandler Carruth631abd92011-06-16 06:47:06 +0000245void
246StmtProfiler::VisitObjCAtSynchronizedStmt(const ObjCAtSynchronizedStmt *S) {
Douglas Gregor44882592009-07-28 15:27:13 +0000247 VisitStmt(S);
248}
249
Chandler Carruth631abd92011-06-16 06:47:06 +0000250void StmtProfiler::VisitObjCAtThrowStmt(const ObjCAtThrowStmt *S) {
Douglas Gregor44882592009-07-28 15:27:13 +0000251 VisitStmt(S);
252}
253
Chandler Carruth631abd92011-06-16 06:47:06 +0000254void
255StmtProfiler::VisitObjCAutoreleasePoolStmt(const ObjCAutoreleasePoolStmt *S) {
John McCall31168b02011-06-15 23:02:42 +0000256 VisitStmt(S);
257}
258
Alexey Bataev5ec3eb12013-07-19 03:13:43 +0000259namespace {
260class OMPClauseProfiler : public ConstOMPClauseVisitor<OMPClauseProfiler> {
261 StmtProfiler *Profiler;
Alexey Bataev756c1962013-09-24 03:17:45 +0000262 /// \brief Process clauses with list of variables.
263 template <typename T>
264 void VisitOMPClauseList(T *Node);
Alexey Bataev5ec3eb12013-07-19 03:13:43 +0000265public:
266 OMPClauseProfiler(StmtProfiler *P) : Profiler(P) { }
267#define OPENMP_CLAUSE(Name, Class) \
268 void Visit##Class(const Class *C);
269#include "clang/Basic/OpenMPKinds.def"
270};
271
Alexey Bataevaadd52e2014-02-13 05:29:23 +0000272void OMPClauseProfiler::VisitOMPIfClause(const OMPIfClause *C) {
273 if (C->getCondition())
274 Profiler->VisitStmt(C->getCondition());
275}
276
Alexey Bataev3778b602014-07-17 07:32:53 +0000277void OMPClauseProfiler::VisitOMPFinalClause(const OMPFinalClause *C) {
278 if (C->getCondition())
279 Profiler->VisitStmt(C->getCondition());
280}
281
Alexey Bataev568a8332014-03-06 06:15:19 +0000282void OMPClauseProfiler::VisitOMPNumThreadsClause(const OMPNumThreadsClause *C) {
283 if (C->getNumThreads())
284 Profiler->VisitStmt(C->getNumThreads());
285}
286
Alexey Bataev62c87d22014-03-21 04:51:18 +0000287void OMPClauseProfiler::VisitOMPSafelenClause(const OMPSafelenClause *C) {
288 if (C->getSafelen())
289 Profiler->VisitStmt(C->getSafelen());
290}
291
Alexey Bataev66b15b52015-08-21 11:14:16 +0000292void OMPClauseProfiler::VisitOMPSimdlenClause(const OMPSimdlenClause *C) {
293 if (C->getSimdlen())
294 Profiler->VisitStmt(C->getSimdlen());
295}
296
Alexander Musman8bd31e62014-05-27 15:12:19 +0000297void OMPClauseProfiler::VisitOMPCollapseClause(const OMPCollapseClause *C) {
298 if (C->getNumForLoops())
299 Profiler->VisitStmt(C->getNumForLoops());
300}
301
Alexey Bataev5ec3eb12013-07-19 03:13:43 +0000302void OMPClauseProfiler::VisitOMPDefaultClause(const OMPDefaultClause *C) { }
Alexey Bataev756c1962013-09-24 03:17:45 +0000303
Alexey Bataevbcbadb62014-05-06 06:04:14 +0000304void OMPClauseProfiler::VisitOMPProcBindClause(const OMPProcBindClause *C) { }
305
Alexey Bataev56dafe82014-06-20 07:16:17 +0000306void OMPClauseProfiler::VisitOMPScheduleClause(const OMPScheduleClause *C) {
Alexey Bataev040d5402015-05-12 08:35:28 +0000307 if (C->getChunkSize()) {
Alexey Bataev56dafe82014-06-20 07:16:17 +0000308 Profiler->VisitStmt(C->getChunkSize());
Alexey Bataev040d5402015-05-12 08:35:28 +0000309 if (C->getHelperChunkSize()) {
310 Profiler->VisitStmt(C->getChunkSize());
311 }
312 }
Alexey Bataev56dafe82014-06-20 07:16:17 +0000313}
314
Alexey Bataev10e775f2015-07-30 11:36:16 +0000315void OMPClauseProfiler::VisitOMPOrderedClause(const OMPOrderedClause *C) {
316 if (auto *Num = C->getNumForLoops())
317 Profiler->VisitStmt(Num);
318}
Alexey Bataev142e1fc2014-06-20 09:44:06 +0000319
Alexey Bataev236070f2014-06-20 11:19:47 +0000320void OMPClauseProfiler::VisitOMPNowaitClause(const OMPNowaitClause *) {}
321
Alexey Bataev7aea99a2014-07-17 12:19:31 +0000322void OMPClauseProfiler::VisitOMPUntiedClause(const OMPUntiedClause *) {}
323
Alexey Bataev74ba3a52014-07-17 12:47:03 +0000324void OMPClauseProfiler::VisitOMPMergeableClause(const OMPMergeableClause *) {}
325
Alexey Bataevf98b00c2014-07-23 02:27:21 +0000326void OMPClauseProfiler::VisitOMPReadClause(const OMPReadClause *) {}
327
Alexey Bataevdea47612014-07-23 07:46:59 +0000328void OMPClauseProfiler::VisitOMPWriteClause(const OMPWriteClause *) {}
329
Alexey Bataev67a4f222014-07-23 10:25:33 +0000330void OMPClauseProfiler::VisitOMPUpdateClause(const OMPUpdateClause *) {}
331
Alexey Bataev459dec02014-07-24 06:46:57 +0000332void OMPClauseProfiler::VisitOMPCaptureClause(const OMPCaptureClause *) {}
333
Alexey Bataev82bad8b2014-07-24 08:55:34 +0000334void OMPClauseProfiler::VisitOMPSeqCstClause(const OMPSeqCstClause *) {}
335
Alexey Bataev756c1962013-09-24 03:17:45 +0000336template<typename T>
337void OMPClauseProfiler::VisitOMPClauseList(T *Node) {
Alexey Bataev03b340a2014-10-21 03:16:40 +0000338 for (auto *E : Node->varlists()) {
339 Profiler->VisitStmt(E);
340 }
Alexey Bataev756c1962013-09-24 03:17:45 +0000341}
Alexey Bataev5ec3eb12013-07-19 03:13:43 +0000342
343void OMPClauseProfiler::VisitOMPPrivateClause(const OMPPrivateClause *C) {
Alexey Bataev756c1962013-09-24 03:17:45 +0000344 VisitOMPClauseList(C);
Alexey Bataev03b340a2014-10-21 03:16:40 +0000345 for (auto *E : C->private_copies()) {
346 Profiler->VisitStmt(E);
347 }
Alexey Bataev5ec3eb12013-07-19 03:13:43 +0000348}
Alexey Bataev4a5bb772014-10-08 14:01:46 +0000349void
350OMPClauseProfiler::VisitOMPFirstprivateClause(const OMPFirstprivateClause *C) {
Alexey Bataevd5af8e42013-10-01 05:32:34 +0000351 VisitOMPClauseList(C);
Alexey Bataev4a5bb772014-10-08 14:01:46 +0000352 for (auto *E : C->private_copies()) {
353 Profiler->VisitStmt(E);
354 }
355 for (auto *E : C->inits()) {
356 Profiler->VisitStmt(E);
357 }
Alexey Bataevd5af8e42013-10-01 05:32:34 +0000358}
Alexander Musman1bb328c2014-06-04 13:06:39 +0000359void
360OMPClauseProfiler::VisitOMPLastprivateClause(const OMPLastprivateClause *C) {
361 VisitOMPClauseList(C);
Alexey Bataev38e89532015-04-16 04:54:05 +0000362 for (auto *E : C->source_exprs()) {
363 Profiler->VisitStmt(E);
364 }
365 for (auto *E : C->destination_exprs()) {
366 Profiler->VisitStmt(E);
367 }
368 for (auto *E : C->assignment_ops()) {
369 Profiler->VisitStmt(E);
370 }
Alexander Musman1bb328c2014-06-04 13:06:39 +0000371}
Alexey Bataev758e55e2013-09-06 18:03:48 +0000372void OMPClauseProfiler::VisitOMPSharedClause(const OMPSharedClause *C) {
Alexey Bataev756c1962013-09-24 03:17:45 +0000373 VisitOMPClauseList(C);
Alexey Bataev758e55e2013-09-06 18:03:48 +0000374}
Alexey Bataevc5e02582014-06-16 07:08:35 +0000375void OMPClauseProfiler::VisitOMPReductionClause(
376 const OMPReductionClause *C) {
377 Profiler->VisitNestedNameSpecifier(
378 C->getQualifierLoc().getNestedNameSpecifier());
379 Profiler->VisitName(C->getNameInfo().getName());
380 VisitOMPClauseList(C);
Alexey Bataev794ba0d2015-04-10 10:43:45 +0000381 for (auto *E : C->lhs_exprs()) {
382 Profiler->VisitStmt(E);
383 }
384 for (auto *E : C->rhs_exprs()) {
385 Profiler->VisitStmt(E);
386 }
387 for (auto *E : C->reduction_ops()) {
388 Profiler->VisitStmt(E);
389 }
Alexey Bataevc5e02582014-06-16 07:08:35 +0000390}
Alexander Musman8dba6642014-04-22 13:09:42 +0000391void OMPClauseProfiler::VisitOMPLinearClause(const OMPLinearClause *C) {
392 VisitOMPClauseList(C);
Alexey Bataevbd9fec12015-08-18 06:47:21 +0000393 for (auto *E : C->privates()) {
394 Profiler->VisitStmt(E);
395 }
Alexander Musman3276a272015-03-21 10:12:56 +0000396 for (auto *E : C->inits()) {
397 Profiler->VisitStmt(E);
398 }
399 for (auto *E : C->updates()) {
400 Profiler->VisitStmt(E);
401 }
402 for (auto *E : C->finals()) {
403 Profiler->VisitStmt(E);
404 }
Alexander Musman8dba6642014-04-22 13:09:42 +0000405 Profiler->VisitStmt(C->getStep());
Alexander Musman3276a272015-03-21 10:12:56 +0000406 Profiler->VisitStmt(C->getCalcStep());
Alexander Musman8dba6642014-04-22 13:09:42 +0000407}
Alexander Musmanf0d76e72014-05-29 14:36:25 +0000408void OMPClauseProfiler::VisitOMPAlignedClause(const OMPAlignedClause *C) {
409 VisitOMPClauseList(C);
410 Profiler->VisitStmt(C->getAlignment());
411}
Alexey Bataevd48bcd82014-03-31 03:36:38 +0000412void OMPClauseProfiler::VisitOMPCopyinClause(const OMPCopyinClause *C) {
413 VisitOMPClauseList(C);
Alexey Bataevf56f98c2015-04-16 05:39:01 +0000414 for (auto *E : C->source_exprs()) {
415 Profiler->VisitStmt(E);
416 }
417 for (auto *E : C->destination_exprs()) {
418 Profiler->VisitStmt(E);
419 }
420 for (auto *E : C->assignment_ops()) {
421 Profiler->VisitStmt(E);
422 }
Alexey Bataevd48bcd82014-03-31 03:36:38 +0000423}
Alexey Bataevbae9a792014-06-27 10:37:06 +0000424void
425OMPClauseProfiler::VisitOMPCopyprivateClause(const OMPCopyprivateClause *C) {
426 VisitOMPClauseList(C);
Alexey Bataeva63048e2015-03-23 06:18:07 +0000427 for (auto *E : C->source_exprs()) {
428 Profiler->VisitStmt(E);
429 }
430 for (auto *E : C->destination_exprs()) {
431 Profiler->VisitStmt(E);
432 }
433 for (auto *E : C->assignment_ops()) {
434 Profiler->VisitStmt(E);
435 }
Alexey Bataevbae9a792014-06-27 10:37:06 +0000436}
Alexey Bataev6125da92014-07-21 11:26:11 +0000437void OMPClauseProfiler::VisitOMPFlushClause(const OMPFlushClause *C) {
438 VisitOMPClauseList(C);
439}
Alexey Bataev1c2cfbc2015-06-23 14:25:19 +0000440void OMPClauseProfiler::VisitOMPDependClause(const OMPDependClause *C) {
441 VisitOMPClauseList(C);
442}
Michael Wonge710d542015-08-07 16:16:36 +0000443void OMPClauseProfiler::VisitOMPDeviceClause(const OMPDeviceClause *C) {
444 Profiler->VisitStmt(C->getDevice());
445}
Alexander Kornienkoab9db512015-06-22 23:07:51 +0000446}
Alexey Bataev5ec3eb12013-07-19 03:13:43 +0000447
448void
Alexey Bataev1b59ab52014-02-27 08:29:12 +0000449StmtProfiler::VisitOMPExecutableDirective(const OMPExecutableDirective *S) {
Alexey Bataev5ec3eb12013-07-19 03:13:43 +0000450 VisitStmt(S);
451 OMPClauseProfiler P(this);
452 ArrayRef<OMPClause *> Clauses = S->clauses();
453 for (ArrayRef<OMPClause *>::iterator I = Clauses.begin(), E = Clauses.end();
454 I != E; ++I)
455 if (*I)
456 P.Visit(*I);
457}
458
Alexander Musman3aaab662014-08-19 11:27:13 +0000459void StmtProfiler::VisitOMPLoopDirective(const OMPLoopDirective *S) {
460 VisitOMPExecutableDirective(S);
461}
462
Alexey Bataev1b59ab52014-02-27 08:29:12 +0000463void StmtProfiler::VisitOMPParallelDirective(const OMPParallelDirective *S) {
464 VisitOMPExecutableDirective(S);
465}
466
467void StmtProfiler::VisitOMPSimdDirective(const OMPSimdDirective *S) {
Alexander Musman3aaab662014-08-19 11:27:13 +0000468 VisitOMPLoopDirective(S);
Alexey Bataev1b59ab52014-02-27 08:29:12 +0000469}
470
Alexey Bataevf29276e2014-06-18 04:14:57 +0000471void StmtProfiler::VisitOMPForDirective(const OMPForDirective *S) {
Alexander Musman3aaab662014-08-19 11:27:13 +0000472 VisitOMPLoopDirective(S);
Alexey Bataevf29276e2014-06-18 04:14:57 +0000473}
474
Alexander Musmanf82886e2014-09-18 05:12:34 +0000475void StmtProfiler::VisitOMPForSimdDirective(const OMPForSimdDirective *S) {
476 VisitOMPLoopDirective(S);
477}
478
Alexey Bataevd3f8dd22014-06-25 11:44:49 +0000479void StmtProfiler::VisitOMPSectionsDirective(const OMPSectionsDirective *S) {
480 VisitOMPExecutableDirective(S);
481}
482
Alexey Bataev1e0498a2014-06-26 08:21:58 +0000483void StmtProfiler::VisitOMPSectionDirective(const OMPSectionDirective *S) {
484 VisitOMPExecutableDirective(S);
485}
486
Alexey Bataevd1e40fb2014-06-26 12:05:45 +0000487void StmtProfiler::VisitOMPSingleDirective(const OMPSingleDirective *S) {
488 VisitOMPExecutableDirective(S);
489}
490
Alexander Musman80c22892014-07-17 08:54:58 +0000491void StmtProfiler::VisitOMPMasterDirective(const OMPMasterDirective *S) {
492 VisitOMPExecutableDirective(S);
493}
494
Alexander Musmand9ed09f2014-07-21 09:42:05 +0000495void StmtProfiler::VisitOMPCriticalDirective(const OMPCriticalDirective *S) {
496 VisitOMPExecutableDirective(S);
497 VisitName(S->getDirectiveName().getName());
498}
499
Alexey Bataev4acb8592014-07-07 13:01:15 +0000500void
501StmtProfiler::VisitOMPParallelForDirective(const OMPParallelForDirective *S) {
Alexander Musman3aaab662014-08-19 11:27:13 +0000502 VisitOMPLoopDirective(S);
Alexey Bataev4acb8592014-07-07 13:01:15 +0000503}
504
Alexander Musmane4e893b2014-09-23 09:33:00 +0000505void StmtProfiler::VisitOMPParallelForSimdDirective(
506 const OMPParallelForSimdDirective *S) {
507 VisitOMPLoopDirective(S);
508}
509
Alexey Bataev84d0b3e2014-07-08 08:12:03 +0000510void StmtProfiler::VisitOMPParallelSectionsDirective(
511 const OMPParallelSectionsDirective *S) {
512 VisitOMPExecutableDirective(S);
513}
514
Alexey Bataev9c2e8ee2014-07-11 11:25:16 +0000515void StmtProfiler::VisitOMPTaskDirective(const OMPTaskDirective *S) {
516 VisitOMPExecutableDirective(S);
517}
518
Alexey Bataev68446b72014-07-18 07:47:19 +0000519void StmtProfiler::VisitOMPTaskyieldDirective(const OMPTaskyieldDirective *S) {
520 VisitOMPExecutableDirective(S);
521}
522
Alexey Bataev4d1dfea2014-07-18 09:11:51 +0000523void StmtProfiler::VisitOMPBarrierDirective(const OMPBarrierDirective *S) {
524 VisitOMPExecutableDirective(S);
525}
526
Alexey Bataev2df347a2014-07-18 10:17:07 +0000527void StmtProfiler::VisitOMPTaskwaitDirective(const OMPTaskwaitDirective *S) {
528 VisitOMPExecutableDirective(S);
529}
530
Alexey Bataevc30dd2d2015-06-18 12:14:09 +0000531void StmtProfiler::VisitOMPTaskgroupDirective(const OMPTaskgroupDirective *S) {
532 VisitOMPExecutableDirective(S);
533}
534
Alexey Bataev6125da92014-07-21 11:26:11 +0000535void StmtProfiler::VisitOMPFlushDirective(const OMPFlushDirective *S) {
536 VisitOMPExecutableDirective(S);
537}
538
Alexey Bataev9fb6e642014-07-22 06:45:04 +0000539void StmtProfiler::VisitOMPOrderedDirective(const OMPOrderedDirective *S) {
540 VisitOMPExecutableDirective(S);
541}
542
Alexey Bataev0162e452014-07-22 10:10:35 +0000543void StmtProfiler::VisitOMPAtomicDirective(const OMPAtomicDirective *S) {
544 VisitOMPExecutableDirective(S);
545}
546
Alexey Bataev0bd520b2014-09-19 08:19:49 +0000547void StmtProfiler::VisitOMPTargetDirective(const OMPTargetDirective *S) {
548 VisitOMPExecutableDirective(S);
549}
550
Michael Wong65f367f2015-07-21 13:44:28 +0000551void StmtProfiler::VisitOMPTargetDataDirective(const OMPTargetDataDirective *S) {
552 VisitOMPExecutableDirective(S);
553}
554
Alexey Bataev13314bf2014-10-09 04:18:56 +0000555void StmtProfiler::VisitOMPTeamsDirective(const OMPTeamsDirective *S) {
556 VisitOMPExecutableDirective(S);
557}
558
Alexey Bataev6d4ed052015-07-01 06:57:41 +0000559void StmtProfiler::VisitOMPCancellationPointDirective(
560 const OMPCancellationPointDirective *S) {
561 VisitOMPExecutableDirective(S);
562}
563
Alexey Bataev80909872015-07-02 11:25:17 +0000564void StmtProfiler::VisitOMPCancelDirective(const OMPCancelDirective *S) {
565 VisitOMPExecutableDirective(S);
566}
567
Chandler Carruth631abd92011-06-16 06:47:06 +0000568void StmtProfiler::VisitExpr(const Expr *S) {
Douglas Gregor5c193b92009-07-28 00:33:38 +0000569 VisitStmt(S);
570}
571
Chandler Carruth631abd92011-06-16 06:47:06 +0000572void StmtProfiler::VisitDeclRefExpr(const DeclRefExpr *S) {
Douglas Gregor5c193b92009-07-28 00:33:38 +0000573 VisitExpr(S);
Douglas Gregorf5b160f2010-07-13 08:37:11 +0000574 if (!Canonical)
575 VisitNestedNameSpecifier(S->getQualifier());
Douglas Gregor5c193b92009-07-28 00:33:38 +0000576 VisitDecl(S->getDecl());
Douglas Gregorf5b160f2010-07-13 08:37:11 +0000577 if (!Canonical)
578 VisitTemplateArguments(S->getTemplateArgs(), S->getNumTemplateArgs());
Douglas Gregor5c193b92009-07-28 00:33:38 +0000579}
580
Chandler Carruth631abd92011-06-16 06:47:06 +0000581void StmtProfiler::VisitPredefinedExpr(const PredefinedExpr *S) {
Douglas Gregor5c193b92009-07-28 00:33:38 +0000582 VisitExpr(S);
583 ID.AddInteger(S->getIdentType());
584}
585
Chandler Carruth631abd92011-06-16 06:47:06 +0000586void StmtProfiler::VisitIntegerLiteral(const IntegerLiteral *S) {
Douglas Gregor5c193b92009-07-28 00:33:38 +0000587 VisitExpr(S);
588 S->getValue().Profile(ID);
Richard Smithe9f130c2014-11-20 03:37:32 +0000589 ID.AddInteger(S->getType()->castAs<BuiltinType>()->getKind());
Douglas Gregor5c193b92009-07-28 00:33:38 +0000590}
591
Chandler Carruth631abd92011-06-16 06:47:06 +0000592void StmtProfiler::VisitCharacterLiteral(const CharacterLiteral *S) {
Douglas Gregor5c193b92009-07-28 00:33:38 +0000593 VisitExpr(S);
Douglas Gregorfb65e592011-07-27 05:40:30 +0000594 ID.AddInteger(S->getKind());
Douglas Gregor5c193b92009-07-28 00:33:38 +0000595 ID.AddInteger(S->getValue());
596}
597
Chandler Carruth631abd92011-06-16 06:47:06 +0000598void StmtProfiler::VisitFloatingLiteral(const FloatingLiteral *S) {
Douglas Gregor5c193b92009-07-28 00:33:38 +0000599 VisitExpr(S);
600 S->getValue().Profile(ID);
601 ID.AddBoolean(S->isExact());
Richard Smithe9f130c2014-11-20 03:37:32 +0000602 ID.AddInteger(S->getType()->castAs<BuiltinType>()->getKind());
Douglas Gregor5c193b92009-07-28 00:33:38 +0000603}
604
Chandler Carruth631abd92011-06-16 06:47:06 +0000605void StmtProfiler::VisitImaginaryLiteral(const ImaginaryLiteral *S) {
Douglas Gregor5c193b92009-07-28 00:33:38 +0000606 VisitExpr(S);
607}
608
Chandler Carruth631abd92011-06-16 06:47:06 +0000609void StmtProfiler::VisitStringLiteral(const StringLiteral *S) {
Douglas Gregor5c193b92009-07-28 00:33:38 +0000610 VisitExpr(S);
Douglas Gregor9d0eb8f2011-11-02 17:26:05 +0000611 ID.AddString(S->getBytes());
Douglas Gregorfb65e592011-07-27 05:40:30 +0000612 ID.AddInteger(S->getKind());
Douglas Gregor5c193b92009-07-28 00:33:38 +0000613}
614
Chandler Carruth631abd92011-06-16 06:47:06 +0000615void StmtProfiler::VisitParenExpr(const ParenExpr *S) {
Douglas Gregor5c193b92009-07-28 00:33:38 +0000616 VisitExpr(S);
617}
618
Chandler Carruth631abd92011-06-16 06:47:06 +0000619void StmtProfiler::VisitParenListExpr(const ParenListExpr *S) {
Nate Begeman5ec4b312009-08-10 23:49:36 +0000620 VisitExpr(S);
621}
622
Chandler Carruth631abd92011-06-16 06:47:06 +0000623void StmtProfiler::VisitUnaryOperator(const UnaryOperator *S) {
Douglas Gregor5c193b92009-07-28 00:33:38 +0000624 VisitExpr(S);
625 ID.AddInteger(S->getOpcode());
626}
627
Chandler Carruth631abd92011-06-16 06:47:06 +0000628void StmtProfiler::VisitOffsetOfExpr(const OffsetOfExpr *S) {
Douglas Gregor882211c2010-04-28 22:16:22 +0000629 VisitType(S->getTypeSourceInfo()->getType());
630 unsigned n = S->getNumComponents();
631 for (unsigned i = 0; i < n; ++i) {
632 const OffsetOfExpr::OffsetOfNode& ON = S->getComponent(i);
633 ID.AddInteger(ON.getKind());
634 switch (ON.getKind()) {
635 case OffsetOfExpr::OffsetOfNode::Array:
636 // Expressions handled below.
637 break;
638
639 case OffsetOfExpr::OffsetOfNode::Field:
640 VisitDecl(ON.getField());
641 break;
642
643 case OffsetOfExpr::OffsetOfNode::Identifier:
644 ID.AddPointer(ON.getFieldName());
645 break;
Alexis Hunta8136cc2010-05-05 15:23:54 +0000646
Douglas Gregord1702062010-04-29 00:18:15 +0000647 case OffsetOfExpr::OffsetOfNode::Base:
648 // These nodes are implicit, and therefore don't need profiling.
649 break;
Douglas Gregor882211c2010-04-28 22:16:22 +0000650 }
651 }
Alexis Hunta8136cc2010-05-05 15:23:54 +0000652
Douglas Gregor882211c2010-04-28 22:16:22 +0000653 VisitExpr(S);
654}
655
Chandler Carruth631abd92011-06-16 06:47:06 +0000656void
657StmtProfiler::VisitUnaryExprOrTypeTraitExpr(const UnaryExprOrTypeTraitExpr *S) {
Douglas Gregor5c193b92009-07-28 00:33:38 +0000658 VisitExpr(S);
Peter Collingbournee190dee2011-03-11 19:24:49 +0000659 ID.AddInteger(S->getKind());
Douglas Gregor5c193b92009-07-28 00:33:38 +0000660 if (S->isArgumentType())
661 VisitType(S->getArgumentType());
662}
663
Chandler Carruth631abd92011-06-16 06:47:06 +0000664void StmtProfiler::VisitArraySubscriptExpr(const ArraySubscriptExpr *S) {
Douglas Gregor5c193b92009-07-28 00:33:38 +0000665 VisitExpr(S);
666}
667
Alexey Bataev1a3320e2015-08-25 14:24:04 +0000668void StmtProfiler::VisitOMPArraySectionExpr(const OMPArraySectionExpr *S) {
669 VisitExpr(S);
670}
671
Chandler Carruth631abd92011-06-16 06:47:06 +0000672void StmtProfiler::VisitCallExpr(const CallExpr *S) {
Douglas Gregor5c193b92009-07-28 00:33:38 +0000673 VisitExpr(S);
674}
675
Chandler Carruth631abd92011-06-16 06:47:06 +0000676void StmtProfiler::VisitMemberExpr(const MemberExpr *S) {
Douglas Gregor5c193b92009-07-28 00:33:38 +0000677 VisitExpr(S);
678 VisitDecl(S->getMemberDecl());
Douglas Gregorf5b160f2010-07-13 08:37:11 +0000679 if (!Canonical)
680 VisitNestedNameSpecifier(S->getQualifier());
Douglas Gregor5c193b92009-07-28 00:33:38 +0000681 ID.AddBoolean(S->isArrow());
682}
683
Chandler Carruth631abd92011-06-16 06:47:06 +0000684void StmtProfiler::VisitCompoundLiteralExpr(const CompoundLiteralExpr *S) {
Douglas Gregor5c193b92009-07-28 00:33:38 +0000685 VisitExpr(S);
686 ID.AddBoolean(S->isFileScope());
687}
688
Chandler Carruth631abd92011-06-16 06:47:06 +0000689void StmtProfiler::VisitCastExpr(const CastExpr *S) {
Douglas Gregor5c193b92009-07-28 00:33:38 +0000690 VisitExpr(S);
691}
692
Chandler Carruth631abd92011-06-16 06:47:06 +0000693void StmtProfiler::VisitImplicitCastExpr(const ImplicitCastExpr *S) {
Douglas Gregor5c193b92009-07-28 00:33:38 +0000694 VisitCastExpr(S);
John McCall2536c6d2010-08-25 10:28:54 +0000695 ID.AddInteger(S->getValueKind());
Douglas Gregor5c193b92009-07-28 00:33:38 +0000696}
697
Chandler Carruth631abd92011-06-16 06:47:06 +0000698void StmtProfiler::VisitExplicitCastExpr(const ExplicitCastExpr *S) {
Douglas Gregor5c193b92009-07-28 00:33:38 +0000699 VisitCastExpr(S);
700 VisitType(S->getTypeAsWritten());
701}
702
Chandler Carruth631abd92011-06-16 06:47:06 +0000703void StmtProfiler::VisitCStyleCastExpr(const CStyleCastExpr *S) {
Douglas Gregor5c193b92009-07-28 00:33:38 +0000704 VisitExplicitCastExpr(S);
705}
706
Chandler Carruth631abd92011-06-16 06:47:06 +0000707void StmtProfiler::VisitBinaryOperator(const BinaryOperator *S) {
Douglas Gregor5c193b92009-07-28 00:33:38 +0000708 VisitExpr(S);
709 ID.AddInteger(S->getOpcode());
710}
711
Chandler Carruth631abd92011-06-16 06:47:06 +0000712void
713StmtProfiler::VisitCompoundAssignOperator(const CompoundAssignOperator *S) {
Douglas Gregor5c193b92009-07-28 00:33:38 +0000714 VisitBinaryOperator(S);
715}
716
Chandler Carruth631abd92011-06-16 06:47:06 +0000717void StmtProfiler::VisitConditionalOperator(const ConditionalOperator *S) {
Douglas Gregor5c193b92009-07-28 00:33:38 +0000718 VisitExpr(S);
719}
720
Chandler Carruth631abd92011-06-16 06:47:06 +0000721void StmtProfiler::VisitBinaryConditionalOperator(
Chandler Carruthcf5f43c2011-06-21 23:26:32 +0000722 const BinaryConditionalOperator *S) {
John McCallc07a0c72011-02-17 10:25:35 +0000723 VisitExpr(S);
724}
725
Chandler Carruth631abd92011-06-16 06:47:06 +0000726void StmtProfiler::VisitAddrLabelExpr(const AddrLabelExpr *S) {
Douglas Gregor5c193b92009-07-28 00:33:38 +0000727 VisitExpr(S);
Chris Lattnerc8e630e2011-02-17 07:39:24 +0000728 VisitDecl(S->getLabel());
Douglas Gregor5c193b92009-07-28 00:33:38 +0000729}
730
Chandler Carruth631abd92011-06-16 06:47:06 +0000731void StmtProfiler::VisitStmtExpr(const StmtExpr *S) {
Douglas Gregor5c193b92009-07-28 00:33:38 +0000732 VisitExpr(S);
733}
734
Chandler Carruth631abd92011-06-16 06:47:06 +0000735void StmtProfiler::VisitShuffleVectorExpr(const ShuffleVectorExpr *S) {
Douglas Gregor5c193b92009-07-28 00:33:38 +0000736 VisitExpr(S);
737}
738
Hal Finkelc4d7c822013-09-18 03:29:45 +0000739void StmtProfiler::VisitConvertVectorExpr(const ConvertVectorExpr *S) {
740 VisitExpr(S);
741}
742
Chandler Carruth631abd92011-06-16 06:47:06 +0000743void StmtProfiler::VisitChooseExpr(const ChooseExpr *S) {
Douglas Gregor5c193b92009-07-28 00:33:38 +0000744 VisitExpr(S);
745}
746
Chandler Carruth631abd92011-06-16 06:47:06 +0000747void StmtProfiler::VisitGNUNullExpr(const GNUNullExpr *S) {
Douglas Gregor5c193b92009-07-28 00:33:38 +0000748 VisitExpr(S);
749}
750
Chandler Carruth631abd92011-06-16 06:47:06 +0000751void StmtProfiler::VisitVAArgExpr(const VAArgExpr *S) {
Douglas Gregor00044172009-07-29 16:09:57 +0000752 VisitExpr(S);
753}
754
Chandler Carruth631abd92011-06-16 06:47:06 +0000755void StmtProfiler::VisitInitListExpr(const InitListExpr *S) {
Douglas Gregor5c193b92009-07-28 00:33:38 +0000756 if (S->getSyntacticForm()) {
757 VisitInitListExpr(S->getSyntacticForm());
758 return;
759 }
Mike Stump11289f42009-09-09 15:08:12 +0000760
Douglas Gregor5c193b92009-07-28 00:33:38 +0000761 VisitExpr(S);
762}
763
Chandler Carruth631abd92011-06-16 06:47:06 +0000764void StmtProfiler::VisitDesignatedInitExpr(const DesignatedInitExpr *S) {
Douglas Gregor5c193b92009-07-28 00:33:38 +0000765 VisitExpr(S);
766 ID.AddBoolean(S->usesGNUSyntax());
Chandler Carruth631abd92011-06-16 06:47:06 +0000767 for (DesignatedInitExpr::const_designators_iterator D =
768 S->designators_begin(), DEnd = S->designators_end();
Douglas Gregor5c193b92009-07-28 00:33:38 +0000769 D != DEnd; ++D) {
770 if (D->isFieldDesignator()) {
771 ID.AddInteger(0);
772 VisitName(D->getFieldName());
773 continue;
774 }
Mike Stump11289f42009-09-09 15:08:12 +0000775
Douglas Gregor5c193b92009-07-28 00:33:38 +0000776 if (D->isArrayDesignator()) {
777 ID.AddInteger(1);
778 } else {
779 assert(D->isArrayRangeDesignator());
780 ID.AddInteger(2);
781 }
782 ID.AddInteger(D->getFirstExprIndex());
783 }
784}
785
Yunzhong Gaocb779302015-06-10 00:27:52 +0000786// Seems that if VisitInitListExpr() only works on the syntactic form of an
787// InitListExpr, then a DesignatedInitUpdateExpr is not encountered.
788void StmtProfiler::VisitDesignatedInitUpdateExpr(
789 const DesignatedInitUpdateExpr *S) {
790 llvm_unreachable("Unexpected DesignatedInitUpdateExpr in syntactic form of "
791 "initializer");
792}
793
794void StmtProfiler::VisitNoInitExpr(const NoInitExpr *S) {
795 llvm_unreachable("Unexpected NoInitExpr in syntactic form of initializer");
796}
797
Chandler Carruth631abd92011-06-16 06:47:06 +0000798void StmtProfiler::VisitImplicitValueInitExpr(const ImplicitValueInitExpr *S) {
Douglas Gregor5c193b92009-07-28 00:33:38 +0000799 VisitExpr(S);
800}
801
Chandler Carruth631abd92011-06-16 06:47:06 +0000802void StmtProfiler::VisitExtVectorElementExpr(const ExtVectorElementExpr *S) {
Douglas Gregor5c193b92009-07-28 00:33:38 +0000803 VisitExpr(S);
804 VisitName(&S->getAccessor());
805}
806
Chandler Carruth631abd92011-06-16 06:47:06 +0000807void StmtProfiler::VisitBlockExpr(const BlockExpr *S) {
Douglas Gregor5c193b92009-07-28 00:33:38 +0000808 VisitExpr(S);
809 VisitDecl(S->getBlockDecl());
810}
811
Chandler Carruth631abd92011-06-16 06:47:06 +0000812void StmtProfiler::VisitGenericSelectionExpr(const GenericSelectionExpr *S) {
Peter Collingbourne91147592011-04-15 00:35:48 +0000813 VisitExpr(S);
814 for (unsigned i = 0; i != S->getNumAssocs(); ++i) {
815 QualType T = S->getAssocType(i);
816 if (T.isNull())
Craig Topper36250ad2014-05-12 05:36:57 +0000817 ID.AddPointer(nullptr);
Peter Collingbourne91147592011-04-15 00:35:48 +0000818 else
819 VisitType(T);
820 VisitExpr(S->getAssocExpr(i));
821 }
822}
823
John McCallfe96e0b2011-11-06 09:01:30 +0000824void StmtProfiler::VisitPseudoObjectExpr(const PseudoObjectExpr *S) {
825 VisitExpr(S);
826 for (PseudoObjectExpr::const_semantics_iterator
827 i = S->semantics_begin(), e = S->semantics_end(); i != e; ++i)
828 // Normally, we would not profile the source expressions of OVEs.
829 if (const OpaqueValueExpr *OVE = dyn_cast<OpaqueValueExpr>(*i))
830 Visit(OVE->getSourceExpr());
831}
832
Eli Friedmandf14b3a2011-10-11 02:20:01 +0000833void StmtProfiler::VisitAtomicExpr(const AtomicExpr *S) {
834 VisitExpr(S);
Eli Friedman4b72fdd2011-10-14 20:59:01 +0000835 ID.AddInteger(S->getOp());
Eli Friedmandf14b3a2011-10-11 02:20:01 +0000836}
837
Chandler Carruth631abd92011-06-16 06:47:06 +0000838static Stmt::StmtClass DecodeOperatorCall(const CXXOperatorCallExpr *S,
John McCalle3027922010-08-25 11:45:40 +0000839 UnaryOperatorKind &UnaryOp,
840 BinaryOperatorKind &BinaryOp) {
Douglas Gregore9ceb312010-05-19 04:13:23 +0000841 switch (S->getOperator()) {
842 case OO_None:
843 case OO_New:
844 case OO_Delete:
845 case OO_Array_New:
846 case OO_Array_Delete:
847 case OO_Arrow:
848 case OO_Call:
849 case OO_Conditional:
850 case NUM_OVERLOADED_OPERATORS:
851 llvm_unreachable("Invalid operator call kind");
Douglas Gregore9ceb312010-05-19 04:13:23 +0000852
853 case OO_Plus:
854 if (S->getNumArgs() == 1) {
John McCalle3027922010-08-25 11:45:40 +0000855 UnaryOp = UO_Plus;
Douglas Gregore9ceb312010-05-19 04:13:23 +0000856 return Stmt::UnaryOperatorClass;
857 }
858
John McCalle3027922010-08-25 11:45:40 +0000859 BinaryOp = BO_Add;
Douglas Gregore9ceb312010-05-19 04:13:23 +0000860 return Stmt::BinaryOperatorClass;
861
862 case OO_Minus:
863 if (S->getNumArgs() == 1) {
John McCalle3027922010-08-25 11:45:40 +0000864 UnaryOp = UO_Minus;
Douglas Gregore9ceb312010-05-19 04:13:23 +0000865 return Stmt::UnaryOperatorClass;
866 }
867
John McCalle3027922010-08-25 11:45:40 +0000868 BinaryOp = BO_Sub;
Douglas Gregore9ceb312010-05-19 04:13:23 +0000869 return Stmt::BinaryOperatorClass;
870
871 case OO_Star:
872 if (S->getNumArgs() == 1) {
Richard Smithf15acc52014-06-05 22:43:40 +0000873 UnaryOp = UO_Deref;
Douglas Gregore9ceb312010-05-19 04:13:23 +0000874 return Stmt::UnaryOperatorClass;
875 }
876
Richard Smithf15acc52014-06-05 22:43:40 +0000877 BinaryOp = BO_Mul;
Douglas Gregore9ceb312010-05-19 04:13:23 +0000878 return Stmt::BinaryOperatorClass;
879
880 case OO_Slash:
John McCalle3027922010-08-25 11:45:40 +0000881 BinaryOp = BO_Div;
Douglas Gregore9ceb312010-05-19 04:13:23 +0000882 return Stmt::BinaryOperatorClass;
883
884 case OO_Percent:
John McCalle3027922010-08-25 11:45:40 +0000885 BinaryOp = BO_Rem;
Douglas Gregore9ceb312010-05-19 04:13:23 +0000886 return Stmt::BinaryOperatorClass;
887
888 case OO_Caret:
John McCalle3027922010-08-25 11:45:40 +0000889 BinaryOp = BO_Xor;
Douglas Gregore9ceb312010-05-19 04:13:23 +0000890 return Stmt::BinaryOperatorClass;
891
892 case OO_Amp:
893 if (S->getNumArgs() == 1) {
John McCalle3027922010-08-25 11:45:40 +0000894 UnaryOp = UO_AddrOf;
Douglas Gregore9ceb312010-05-19 04:13:23 +0000895 return Stmt::UnaryOperatorClass;
896 }
897
John McCalle3027922010-08-25 11:45:40 +0000898 BinaryOp = BO_And;
Douglas Gregore9ceb312010-05-19 04:13:23 +0000899 return Stmt::BinaryOperatorClass;
900
901 case OO_Pipe:
John McCalle3027922010-08-25 11:45:40 +0000902 BinaryOp = BO_Or;
Douglas Gregore9ceb312010-05-19 04:13:23 +0000903 return Stmt::BinaryOperatorClass;
904
905 case OO_Tilde:
John McCalle3027922010-08-25 11:45:40 +0000906 UnaryOp = UO_Not;
Douglas Gregore9ceb312010-05-19 04:13:23 +0000907 return Stmt::UnaryOperatorClass;
908
909 case OO_Exclaim:
John McCalle3027922010-08-25 11:45:40 +0000910 UnaryOp = UO_LNot;
Douglas Gregore9ceb312010-05-19 04:13:23 +0000911 return Stmt::UnaryOperatorClass;
912
913 case OO_Equal:
John McCalle3027922010-08-25 11:45:40 +0000914 BinaryOp = BO_Assign;
Douglas Gregore9ceb312010-05-19 04:13:23 +0000915 return Stmt::BinaryOperatorClass;
916
917 case OO_Less:
John McCalle3027922010-08-25 11:45:40 +0000918 BinaryOp = BO_LT;
Douglas Gregore9ceb312010-05-19 04:13:23 +0000919 return Stmt::BinaryOperatorClass;
920
921 case OO_Greater:
John McCalle3027922010-08-25 11:45:40 +0000922 BinaryOp = BO_GT;
Douglas Gregore9ceb312010-05-19 04:13:23 +0000923 return Stmt::BinaryOperatorClass;
924
925 case OO_PlusEqual:
John McCalle3027922010-08-25 11:45:40 +0000926 BinaryOp = BO_AddAssign;
Douglas Gregore9ceb312010-05-19 04:13:23 +0000927 return Stmt::CompoundAssignOperatorClass;
928
929 case OO_MinusEqual:
John McCalle3027922010-08-25 11:45:40 +0000930 BinaryOp = BO_SubAssign;
Douglas Gregore9ceb312010-05-19 04:13:23 +0000931 return Stmt::CompoundAssignOperatorClass;
932
933 case OO_StarEqual:
John McCalle3027922010-08-25 11:45:40 +0000934 BinaryOp = BO_MulAssign;
Douglas Gregore9ceb312010-05-19 04:13:23 +0000935 return Stmt::CompoundAssignOperatorClass;
936
937 case OO_SlashEqual:
John McCalle3027922010-08-25 11:45:40 +0000938 BinaryOp = BO_DivAssign;
Douglas Gregore9ceb312010-05-19 04:13:23 +0000939 return Stmt::CompoundAssignOperatorClass;
940
941 case OO_PercentEqual:
John McCalle3027922010-08-25 11:45:40 +0000942 BinaryOp = BO_RemAssign;
Douglas Gregore9ceb312010-05-19 04:13:23 +0000943 return Stmt::CompoundAssignOperatorClass;
944
945 case OO_CaretEqual:
John McCalle3027922010-08-25 11:45:40 +0000946 BinaryOp = BO_XorAssign;
Douglas Gregore9ceb312010-05-19 04:13:23 +0000947 return Stmt::CompoundAssignOperatorClass;
948
949 case OO_AmpEqual:
John McCalle3027922010-08-25 11:45:40 +0000950 BinaryOp = BO_AndAssign;
Douglas Gregore9ceb312010-05-19 04:13:23 +0000951 return Stmt::CompoundAssignOperatorClass;
952
953 case OO_PipeEqual:
John McCalle3027922010-08-25 11:45:40 +0000954 BinaryOp = BO_OrAssign;
Douglas Gregore9ceb312010-05-19 04:13:23 +0000955 return Stmt::CompoundAssignOperatorClass;
956
957 case OO_LessLess:
John McCalle3027922010-08-25 11:45:40 +0000958 BinaryOp = BO_Shl;
Douglas Gregore9ceb312010-05-19 04:13:23 +0000959 return Stmt::BinaryOperatorClass;
960
961 case OO_GreaterGreater:
John McCalle3027922010-08-25 11:45:40 +0000962 BinaryOp = BO_Shr;
Douglas Gregore9ceb312010-05-19 04:13:23 +0000963 return Stmt::BinaryOperatorClass;
964
965 case OO_LessLessEqual:
John McCalle3027922010-08-25 11:45:40 +0000966 BinaryOp = BO_ShlAssign;
Douglas Gregore9ceb312010-05-19 04:13:23 +0000967 return Stmt::CompoundAssignOperatorClass;
968
969 case OO_GreaterGreaterEqual:
John McCalle3027922010-08-25 11:45:40 +0000970 BinaryOp = BO_ShrAssign;
Douglas Gregore9ceb312010-05-19 04:13:23 +0000971 return Stmt::CompoundAssignOperatorClass;
972
973 case OO_EqualEqual:
John McCalle3027922010-08-25 11:45:40 +0000974 BinaryOp = BO_EQ;
Douglas Gregore9ceb312010-05-19 04:13:23 +0000975 return Stmt::BinaryOperatorClass;
976
977 case OO_ExclaimEqual:
John McCalle3027922010-08-25 11:45:40 +0000978 BinaryOp = BO_NE;
Douglas Gregore9ceb312010-05-19 04:13:23 +0000979 return Stmt::BinaryOperatorClass;
980
981 case OO_LessEqual:
John McCalle3027922010-08-25 11:45:40 +0000982 BinaryOp = BO_LE;
Douglas Gregore9ceb312010-05-19 04:13:23 +0000983 return Stmt::BinaryOperatorClass;
984
985 case OO_GreaterEqual:
John McCalle3027922010-08-25 11:45:40 +0000986 BinaryOp = BO_GE;
Douglas Gregore9ceb312010-05-19 04:13:23 +0000987 return Stmt::BinaryOperatorClass;
988
989 case OO_AmpAmp:
John McCalle3027922010-08-25 11:45:40 +0000990 BinaryOp = BO_LAnd;
Douglas Gregore9ceb312010-05-19 04:13:23 +0000991 return Stmt::BinaryOperatorClass;
992
993 case OO_PipePipe:
John McCalle3027922010-08-25 11:45:40 +0000994 BinaryOp = BO_LOr;
Douglas Gregore9ceb312010-05-19 04:13:23 +0000995 return Stmt::BinaryOperatorClass;
996
997 case OO_PlusPlus:
John McCalle3027922010-08-25 11:45:40 +0000998 UnaryOp = S->getNumArgs() == 1? UO_PreInc
999 : UO_PostInc;
Douglas Gregore9ceb312010-05-19 04:13:23 +00001000 return Stmt::UnaryOperatorClass;
1001
1002 case OO_MinusMinus:
John McCalle3027922010-08-25 11:45:40 +00001003 UnaryOp = S->getNumArgs() == 1? UO_PreDec
1004 : UO_PostDec;
Douglas Gregore9ceb312010-05-19 04:13:23 +00001005 return Stmt::UnaryOperatorClass;
1006
1007 case OO_Comma:
John McCalle3027922010-08-25 11:45:40 +00001008 BinaryOp = BO_Comma;
Douglas Gregore9ceb312010-05-19 04:13:23 +00001009 return Stmt::BinaryOperatorClass;
1010
1011
1012 case OO_ArrowStar:
John McCalle3027922010-08-25 11:45:40 +00001013 BinaryOp = BO_PtrMemI;
Douglas Gregore9ceb312010-05-19 04:13:23 +00001014 return Stmt::BinaryOperatorClass;
1015
1016 case OO_Subscript:
1017 return Stmt::ArraySubscriptExprClass;
1018 }
1019
1020 llvm_unreachable("Invalid overloaded operator expression");
1021}
Richard Smithf15acc52014-06-05 22:43:40 +00001022
Douglas Gregore9ceb312010-05-19 04:13:23 +00001023
Chandler Carruth631abd92011-06-16 06:47:06 +00001024void StmtProfiler::VisitCXXOperatorCallExpr(const CXXOperatorCallExpr *S) {
Douglas Gregore9ceb312010-05-19 04:13:23 +00001025 if (S->isTypeDependent()) {
1026 // Type-dependent operator calls are profiled like their underlying
1027 // syntactic operator.
John McCalle3027922010-08-25 11:45:40 +00001028 UnaryOperatorKind UnaryOp = UO_Extension;
1029 BinaryOperatorKind BinaryOp = BO_Comma;
Douglas Gregore9ceb312010-05-19 04:13:23 +00001030 Stmt::StmtClass SC = DecodeOperatorCall(S, UnaryOp, BinaryOp);
Richard Smithf15acc52014-06-05 22:43:40 +00001031
Douglas Gregore9ceb312010-05-19 04:13:23 +00001032 ID.AddInteger(SC);
1033 for (unsigned I = 0, N = S->getNumArgs(); I != N; ++I)
1034 Visit(S->getArg(I));
1035 if (SC == Stmt::UnaryOperatorClass)
1036 ID.AddInteger(UnaryOp);
1037 else if (SC == Stmt::BinaryOperatorClass ||
1038 SC == Stmt::CompoundAssignOperatorClass)
1039 ID.AddInteger(BinaryOp);
1040 else
1041 assert(SC == Stmt::ArraySubscriptExprClass);
Richard Smithf15acc52014-06-05 22:43:40 +00001042
Douglas Gregore9ceb312010-05-19 04:13:23 +00001043 return;
1044 }
Richard Smithf15acc52014-06-05 22:43:40 +00001045
Douglas Gregor5c193b92009-07-28 00:33:38 +00001046 VisitCallExpr(S);
1047 ID.AddInteger(S->getOperator());
1048}
1049
Chandler Carruth631abd92011-06-16 06:47:06 +00001050void StmtProfiler::VisitCXXMemberCallExpr(const CXXMemberCallExpr *S) {
Douglas Gregor5c193b92009-07-28 00:33:38 +00001051 VisitCallExpr(S);
1052}
1053
Chandler Carruth631abd92011-06-16 06:47:06 +00001054void StmtProfiler::VisitCUDAKernelCallExpr(const CUDAKernelCallExpr *S) {
Peter Collingbourne41f85462011-02-09 21:07:24 +00001055 VisitCallExpr(S);
1056}
1057
Chandler Carruth631abd92011-06-16 06:47:06 +00001058void StmtProfiler::VisitAsTypeExpr(const AsTypeExpr *S) {
Tanya Lattner55808c12011-06-04 00:47:47 +00001059 VisitExpr(S);
1060}
1061
Chandler Carruth631abd92011-06-16 06:47:06 +00001062void StmtProfiler::VisitCXXNamedCastExpr(const CXXNamedCastExpr *S) {
Douglas Gregor5c193b92009-07-28 00:33:38 +00001063 VisitExplicitCastExpr(S);
1064}
1065
Chandler Carruth631abd92011-06-16 06:47:06 +00001066void StmtProfiler::VisitCXXStaticCastExpr(const CXXStaticCastExpr *S) {
Douglas Gregor5c193b92009-07-28 00:33:38 +00001067 VisitCXXNamedCastExpr(S);
1068}
1069
Chandler Carruth631abd92011-06-16 06:47:06 +00001070void StmtProfiler::VisitCXXDynamicCastExpr(const CXXDynamicCastExpr *S) {
Douglas Gregor5c193b92009-07-28 00:33:38 +00001071 VisitCXXNamedCastExpr(S);
1072}
1073
Chandler Carruth631abd92011-06-16 06:47:06 +00001074void
1075StmtProfiler::VisitCXXReinterpretCastExpr(const CXXReinterpretCastExpr *S) {
Douglas Gregor5c193b92009-07-28 00:33:38 +00001076 VisitCXXNamedCastExpr(S);
1077}
1078
Chandler Carruth631abd92011-06-16 06:47:06 +00001079void StmtProfiler::VisitCXXConstCastExpr(const CXXConstCastExpr *S) {
Douglas Gregor5c193b92009-07-28 00:33:38 +00001080 VisitCXXNamedCastExpr(S);
1081}
1082
Richard Smithc67fdd42012-03-07 08:35:16 +00001083void StmtProfiler::VisitUserDefinedLiteral(const UserDefinedLiteral *S) {
1084 VisitCallExpr(S);
1085}
1086
Chandler Carruth631abd92011-06-16 06:47:06 +00001087void StmtProfiler::VisitCXXBoolLiteralExpr(const CXXBoolLiteralExpr *S) {
Douglas Gregor5c193b92009-07-28 00:33:38 +00001088 VisitExpr(S);
1089 ID.AddBoolean(S->getValue());
1090}
1091
Chandler Carruth631abd92011-06-16 06:47:06 +00001092void StmtProfiler::VisitCXXNullPtrLiteralExpr(const CXXNullPtrLiteralExpr *S) {
Douglas Gregor00044172009-07-29 16:09:57 +00001093 VisitExpr(S);
1094}
1095
Richard Smithcc1b96d2013-06-12 22:31:48 +00001096void StmtProfiler::VisitCXXStdInitializerListExpr(
1097 const CXXStdInitializerListExpr *S) {
1098 VisitExpr(S);
1099}
1100
Chandler Carruth631abd92011-06-16 06:47:06 +00001101void StmtProfiler::VisitCXXTypeidExpr(const CXXTypeidExpr *S) {
Douglas Gregor5c193b92009-07-28 00:33:38 +00001102 VisitExpr(S);
1103 if (S->isTypeOperand())
David Majnemer143c55e2013-09-27 07:04:31 +00001104 VisitType(S->getTypeOperandSourceInfo()->getType());
Douglas Gregor5c193b92009-07-28 00:33:38 +00001105}
1106
Chandler Carruth631abd92011-06-16 06:47:06 +00001107void StmtProfiler::VisitCXXUuidofExpr(const CXXUuidofExpr *S) {
Francois Pichet9f4f2072010-09-08 12:20:18 +00001108 VisitExpr(S);
1109 if (S->isTypeOperand())
David Majnemer143c55e2013-09-27 07:04:31 +00001110 VisitType(S->getTypeOperandSourceInfo()->getType());
Francois Pichet9f4f2072010-09-08 12:20:18 +00001111}
1112
John McCall5e77d762013-04-16 07:28:30 +00001113void StmtProfiler::VisitMSPropertyRefExpr(const MSPropertyRefExpr *S) {
1114 VisitExpr(S);
1115 VisitDecl(S->getPropertyDecl());
1116}
1117
Chandler Carruth631abd92011-06-16 06:47:06 +00001118void StmtProfiler::VisitCXXThisExpr(const CXXThisExpr *S) {
Douglas Gregor5c193b92009-07-28 00:33:38 +00001119 VisitExpr(S);
Douglas Gregor3024f072012-04-16 07:05:22 +00001120 ID.AddBoolean(S->isImplicit());
Douglas Gregor5c193b92009-07-28 00:33:38 +00001121}
1122
Chandler Carruth631abd92011-06-16 06:47:06 +00001123void StmtProfiler::VisitCXXThrowExpr(const CXXThrowExpr *S) {
Douglas Gregor5c193b92009-07-28 00:33:38 +00001124 VisitExpr(S);
1125}
1126
Chandler Carruth631abd92011-06-16 06:47:06 +00001127void StmtProfiler::VisitCXXDefaultArgExpr(const CXXDefaultArgExpr *S) {
Douglas Gregor5c193b92009-07-28 00:33:38 +00001128 VisitExpr(S);
1129 VisitDecl(S->getParam());
1130}
1131
Richard Smith852c9db2013-04-20 22:23:05 +00001132void StmtProfiler::VisitCXXDefaultInitExpr(const CXXDefaultInitExpr *S) {
1133 VisitExpr(S);
1134 VisitDecl(S->getField());
1135}
1136
Chandler Carruth631abd92011-06-16 06:47:06 +00001137void StmtProfiler::VisitCXXBindTemporaryExpr(const CXXBindTemporaryExpr *S) {
Douglas Gregor5c193b92009-07-28 00:33:38 +00001138 VisitExpr(S);
1139 VisitDecl(
1140 const_cast<CXXDestructorDecl *>(S->getTemporary()->getDestructor()));
1141}
1142
Chandler Carruth631abd92011-06-16 06:47:06 +00001143void StmtProfiler::VisitCXXConstructExpr(const CXXConstructExpr *S) {
Douglas Gregor5c193b92009-07-28 00:33:38 +00001144 VisitExpr(S);
1145 VisitDecl(S->getConstructor());
1146 ID.AddBoolean(S->isElidable());
1147}
1148
Chandler Carruth631abd92011-06-16 06:47:06 +00001149void StmtProfiler::VisitCXXFunctionalCastExpr(const CXXFunctionalCastExpr *S) {
Douglas Gregor5c193b92009-07-28 00:33:38 +00001150 VisitExplicitCastExpr(S);
1151}
1152
Chandler Carruth631abd92011-06-16 06:47:06 +00001153void
1154StmtProfiler::VisitCXXTemporaryObjectExpr(const CXXTemporaryObjectExpr *S) {
Douglas Gregor5c193b92009-07-28 00:33:38 +00001155 VisitCXXConstructExpr(S);
1156}
1157
Chandler Carruth631abd92011-06-16 06:47:06 +00001158void
Douglas Gregore31e6062012-02-07 10:09:13 +00001159StmtProfiler::VisitLambdaExpr(const LambdaExpr *S) {
1160 VisitExpr(S);
1161 for (LambdaExpr::capture_iterator C = S->explicit_capture_begin(),
1162 CEnd = S->explicit_capture_end();
1163 C != CEnd; ++C) {
1164 ID.AddInteger(C->getCaptureKind());
Richard Smithba71c082013-05-16 06:20:58 +00001165 switch (C->getCaptureKind()) {
1166 case LCK_This:
1167 break;
1168 case LCK_ByRef:
1169 case LCK_ByCopy:
Douglas Gregore31e6062012-02-07 10:09:13 +00001170 VisitDecl(C->getCapturedVar());
1171 ID.AddBoolean(C->isPackExpansion());
Richard Smithba71c082013-05-16 06:20:58 +00001172 break;
Alexey Bataev39c81e22014-08-28 04:28:19 +00001173 case LCK_VLAType:
1174 llvm_unreachable("VLA type in explicit captures.");
Douglas Gregore31e6062012-02-07 10:09:13 +00001175 }
1176 }
1177 // Note: If we actually needed to be able to match lambda
1178 // expressions, we would have to consider parameters and return type
1179 // here, among other things.
1180 VisitStmt(S->getBody());
1181}
1182
1183void
Chandler Carruth631abd92011-06-16 06:47:06 +00001184StmtProfiler::VisitCXXScalarValueInitExpr(const CXXScalarValueInitExpr *S) {
Douglas Gregor5c193b92009-07-28 00:33:38 +00001185 VisitExpr(S);
1186}
1187
Chandler Carruth631abd92011-06-16 06:47:06 +00001188void StmtProfiler::VisitCXXDeleteExpr(const CXXDeleteExpr *S) {
Douglas Gregor5c193b92009-07-28 00:33:38 +00001189 VisitExpr(S);
1190 ID.AddBoolean(S->isGlobalDelete());
1191 ID.AddBoolean(S->isArrayForm());
1192 VisitDecl(S->getOperatorDelete());
1193}
1194
1195
Chandler Carruth631abd92011-06-16 06:47:06 +00001196void StmtProfiler::VisitCXXNewExpr(const CXXNewExpr *S) {
Douglas Gregor5c193b92009-07-28 00:33:38 +00001197 VisitExpr(S);
1198 VisitType(S->getAllocatedType());
1199 VisitDecl(S->getOperatorNew());
1200 VisitDecl(S->getOperatorDelete());
Douglas Gregor5c193b92009-07-28 00:33:38 +00001201 ID.AddBoolean(S->isArray());
1202 ID.AddInteger(S->getNumPlacementArgs());
1203 ID.AddBoolean(S->isGlobalNew());
1204 ID.AddBoolean(S->isParenTypeId());
Sebastian Redl6047f072012-02-16 12:22:20 +00001205 ID.AddInteger(S->getInitializationStyle());
Douglas Gregor5c193b92009-07-28 00:33:38 +00001206}
1207
Chandler Carruth631abd92011-06-16 06:47:06 +00001208void
1209StmtProfiler::VisitCXXPseudoDestructorExpr(const CXXPseudoDestructorExpr *S) {
Douglas Gregorad8a3362009-09-04 17:36:40 +00001210 VisitExpr(S);
1211 ID.AddBoolean(S->isArrow());
1212 VisitNestedNameSpecifier(S->getQualifier());
Craig Topper36250ad2014-05-12 05:36:57 +00001213 ID.AddBoolean(S->getScopeTypeInfo() != nullptr);
Eli Friedman85641392013-08-09 23:37:05 +00001214 if (S->getScopeTypeInfo())
1215 VisitType(S->getScopeTypeInfo()->getType());
Craig Topper36250ad2014-05-12 05:36:57 +00001216 ID.AddBoolean(S->getDestroyedTypeInfo() != nullptr);
Eli Friedman85641392013-08-09 23:37:05 +00001217 if (S->getDestroyedTypeInfo())
1218 VisitType(S->getDestroyedType());
1219 else
1220 ID.AddPointer(S->getDestroyedTypeIdentifier());
Douglas Gregorad8a3362009-09-04 17:36:40 +00001221}
1222
Chandler Carruth631abd92011-06-16 06:47:06 +00001223void StmtProfiler::VisitOverloadExpr(const OverloadExpr *S) {
Argyrios Kyrtzidisb482eb82010-08-15 20:53:20 +00001224 VisitExpr(S);
John McCalle66edc12009-11-24 19:00:30 +00001225 VisitNestedNameSpecifier(S->getQualifier());
Douglas Gregor5c193b92009-07-28 00:33:38 +00001226 VisitName(S->getName());
John McCalle66edc12009-11-24 19:00:30 +00001227 ID.AddBoolean(S->hasExplicitTemplateArgs());
1228 if (S->hasExplicitTemplateArgs())
Argyrios Kyrtzidisf4505452010-08-15 01:15:38 +00001229 VisitTemplateArguments(S->getExplicitTemplateArgs().getTemplateArgs(),
1230 S->getExplicitTemplateArgs().NumTemplateArgs);
1231}
1232
1233void
Chandler Carruth631abd92011-06-16 06:47:06 +00001234StmtProfiler::VisitUnresolvedLookupExpr(const UnresolvedLookupExpr *S) {
Argyrios Kyrtzidisf4505452010-08-15 01:15:38 +00001235 VisitOverloadExpr(S);
Douglas Gregor5c193b92009-07-28 00:33:38 +00001236}
1237
Douglas Gregor29c42f22012-02-24 07:38:34 +00001238void StmtProfiler::VisitTypeTraitExpr(const TypeTraitExpr *S) {
1239 VisitExpr(S);
1240 ID.AddInteger(S->getTrait());
1241 ID.AddInteger(S->getNumArgs());
1242 for (unsigned I = 0, N = S->getNumArgs(); I != N; ++I)
1243 VisitType(S->getArg(I)->getType());
1244}
1245
Chandler Carruth631abd92011-06-16 06:47:06 +00001246void StmtProfiler::VisitArrayTypeTraitExpr(const ArrayTypeTraitExpr *S) {
John Wiegley6242b6a2011-04-28 00:16:57 +00001247 VisitExpr(S);
1248 ID.AddInteger(S->getTrait());
1249 VisitType(S->getQueriedType());
1250}
1251
Chandler Carruth631abd92011-06-16 06:47:06 +00001252void StmtProfiler::VisitExpressionTraitExpr(const ExpressionTraitExpr *S) {
John Wiegleyf9f65842011-04-25 06:54:41 +00001253 VisitExpr(S);
1254 ID.AddInteger(S->getTrait());
1255 VisitExpr(S->getQueriedExpression());
1256}
1257
Chandler Carruth631abd92011-06-16 06:47:06 +00001258void StmtProfiler::VisitDependentScopeDeclRefExpr(
1259 const DependentScopeDeclRefExpr *S) {
Douglas Gregor5c193b92009-07-28 00:33:38 +00001260 VisitExpr(S);
1261 VisitName(S->getDeclName());
1262 VisitNestedNameSpecifier(S->getQualifier());
John McCalle66edc12009-11-24 19:00:30 +00001263 ID.AddBoolean(S->hasExplicitTemplateArgs());
1264 if (S->hasExplicitTemplateArgs())
1265 VisitTemplateArguments(S->getTemplateArgs(), S->getNumTemplateArgs());
Douglas Gregor5c193b92009-07-28 00:33:38 +00001266}
1267
Chandler Carruth631abd92011-06-16 06:47:06 +00001268void StmtProfiler::VisitExprWithCleanups(const ExprWithCleanups *S) {
Douglas Gregora7095092009-07-28 14:44:31 +00001269 VisitExpr(S);
Douglas Gregora7095092009-07-28 14:44:31 +00001270}
1271
Chandler Carruth631abd92011-06-16 06:47:06 +00001272void StmtProfiler::VisitCXXUnresolvedConstructExpr(
1273 const CXXUnresolvedConstructExpr *S) {
Douglas Gregora7095092009-07-28 14:44:31 +00001274 VisitExpr(S);
1275 VisitType(S->getTypeAsWritten());
1276}
1277
Chandler Carruth631abd92011-06-16 06:47:06 +00001278void StmtProfiler::VisitCXXDependentScopeMemberExpr(
1279 const CXXDependentScopeMemberExpr *S) {
John McCall2d74de92009-12-01 22:10:20 +00001280 ID.AddBoolean(S->isImplicitAccess());
1281 if (!S->isImplicitAccess()) {
1282 VisitExpr(S);
1283 ID.AddBoolean(S->isArrow());
1284 }
Douglas Gregorc26e0f62009-09-03 16:14:30 +00001285 VisitNestedNameSpecifier(S->getQualifier());
Douglas Gregora7095092009-07-28 14:44:31 +00001286 VisitName(S->getMember());
John McCall2d74de92009-12-01 22:10:20 +00001287 ID.AddBoolean(S->hasExplicitTemplateArgs());
1288 if (S->hasExplicitTemplateArgs())
John McCall10eae182009-11-30 22:42:35 +00001289 VisitTemplateArguments(S->getTemplateArgs(), S->getNumTemplateArgs());
1290}
1291
Chandler Carruth631abd92011-06-16 06:47:06 +00001292void StmtProfiler::VisitUnresolvedMemberExpr(const UnresolvedMemberExpr *S) {
John McCall2d74de92009-12-01 22:10:20 +00001293 ID.AddBoolean(S->isImplicitAccess());
1294 if (!S->isImplicitAccess()) {
1295 VisitExpr(S);
1296 ID.AddBoolean(S->isArrow());
1297 }
John McCall10eae182009-11-30 22:42:35 +00001298 VisitNestedNameSpecifier(S->getQualifier());
1299 VisitName(S->getMemberName());
1300 ID.AddBoolean(S->hasExplicitTemplateArgs());
1301 if (S->hasExplicitTemplateArgs())
1302 VisitTemplateArguments(S->getTemplateArgs(), S->getNumTemplateArgs());
Douglas Gregora7095092009-07-28 14:44:31 +00001303}
1304
Chandler Carruth631abd92011-06-16 06:47:06 +00001305void StmtProfiler::VisitCXXNoexceptExpr(const CXXNoexceptExpr *S) {
Sebastian Redl4202c0f2010-09-10 20:55:43 +00001306 VisitExpr(S);
1307}
1308
Chandler Carruth631abd92011-06-16 06:47:06 +00001309void StmtProfiler::VisitPackExpansionExpr(const PackExpansionExpr *S) {
Douglas Gregore8e9dd62011-01-03 17:17:50 +00001310 VisitExpr(S);
1311}
1312
Chandler Carruth631abd92011-06-16 06:47:06 +00001313void StmtProfiler::VisitSizeOfPackExpr(const SizeOfPackExpr *S) {
Douglas Gregor820ba7b2011-01-04 17:33:58 +00001314 VisitExpr(S);
1315 VisitDecl(S->getPack());
Richard Smithd784e682015-09-23 21:41:42 +00001316 if (S->isPartiallySubstituted()) {
1317 auto Args = S->getPartialArguments();
1318 ID.AddInteger(Args.size());
1319 for (const auto &TA : Args)
1320 VisitTemplateArgument(TA);
1321 } else {
1322 ID.AddInteger(0);
1323 }
Douglas Gregor820ba7b2011-01-04 17:33:58 +00001324}
1325
Douglas Gregorcdbc5392011-01-15 01:15:58 +00001326void StmtProfiler::VisitSubstNonTypeTemplateParmPackExpr(
Chandler Carruth631abd92011-06-16 06:47:06 +00001327 const SubstNonTypeTemplateParmPackExpr *S) {
Douglas Gregorcdbc5392011-01-15 01:15:58 +00001328 VisitExpr(S);
1329 VisitDecl(S->getParameterPack());
1330 VisitTemplateArgument(S->getArgumentPack());
1331}
1332
John McCall7c454bb2011-07-15 05:09:51 +00001333void StmtProfiler::VisitSubstNonTypeTemplateParmExpr(
1334 const SubstNonTypeTemplateParmExpr *E) {
1335 // Profile exactly as the replacement expression.
1336 Visit(E->getReplacement());
1337}
1338
Richard Smithb15fe3a2012-09-12 00:56:43 +00001339void StmtProfiler::VisitFunctionParmPackExpr(const FunctionParmPackExpr *S) {
1340 VisitExpr(S);
1341 VisitDecl(S->getParameterPack());
1342 ID.AddInteger(S->getNumExpansions());
1343 for (FunctionParmPackExpr::iterator I = S->begin(), E = S->end(); I != E; ++I)
1344 VisitDecl(*I);
1345}
1346
Douglas Gregorfe314812011-06-21 17:03:29 +00001347void StmtProfiler::VisitMaterializeTemporaryExpr(
1348 const MaterializeTemporaryExpr *S) {
1349 VisitExpr(S);
1350}
1351
Richard Smith0f0af192014-11-08 05:07:16 +00001352void StmtProfiler::VisitCXXFoldExpr(const CXXFoldExpr *S) {
1353 VisitExpr(S);
1354 ID.AddInteger(S->getOperator());
1355}
1356
Chandler Carruth631abd92011-06-16 06:47:06 +00001357void StmtProfiler::VisitOpaqueValueExpr(const OpaqueValueExpr *E) {
John McCall8d69a212010-11-15 23:31:06 +00001358 VisitExpr(E);
1359}
1360
Kaelyn Takatae1f49d52014-10-27 18:07:20 +00001361void StmtProfiler::VisitTypoExpr(const TypoExpr *E) {
1362 VisitExpr(E);
1363}
1364
Chandler Carruth631abd92011-06-16 06:47:06 +00001365void StmtProfiler::VisitObjCStringLiteral(const ObjCStringLiteral *S) {
Douglas Gregora7095092009-07-28 14:44:31 +00001366 VisitExpr(S);
1367}
1368
Patrick Beard0caa3942012-04-19 00:25:12 +00001369void StmtProfiler::VisitObjCBoxedExpr(const ObjCBoxedExpr *E) {
Ted Kremeneke65b0862012-03-06 20:05:56 +00001370 VisitExpr(E);
1371}
1372
1373void StmtProfiler::VisitObjCArrayLiteral(const ObjCArrayLiteral *E) {
1374 VisitExpr(E);
1375}
1376
1377void StmtProfiler::VisitObjCDictionaryLiteral(const ObjCDictionaryLiteral *E) {
1378 VisitExpr(E);
1379}
1380
Chandler Carruth631abd92011-06-16 06:47:06 +00001381void StmtProfiler::VisitObjCEncodeExpr(const ObjCEncodeExpr *S) {
Douglas Gregora7095092009-07-28 14:44:31 +00001382 VisitExpr(S);
1383 VisitType(S->getEncodedType());
1384}
1385
Chandler Carruth631abd92011-06-16 06:47:06 +00001386void StmtProfiler::VisitObjCSelectorExpr(const ObjCSelectorExpr *S) {
Douglas Gregora7095092009-07-28 14:44:31 +00001387 VisitExpr(S);
1388 VisitName(S->getSelector());
1389}
1390
Chandler Carruth631abd92011-06-16 06:47:06 +00001391void StmtProfiler::VisitObjCProtocolExpr(const ObjCProtocolExpr *S) {
Douglas Gregora7095092009-07-28 14:44:31 +00001392 VisitExpr(S);
1393 VisitDecl(S->getProtocol());
1394}
1395
Chandler Carruth631abd92011-06-16 06:47:06 +00001396void StmtProfiler::VisitObjCIvarRefExpr(const ObjCIvarRefExpr *S) {
Douglas Gregora7095092009-07-28 14:44:31 +00001397 VisitExpr(S);
1398 VisitDecl(S->getDecl());
1399 ID.AddBoolean(S->isArrow());
1400 ID.AddBoolean(S->isFreeIvar());
1401}
1402
Chandler Carruth631abd92011-06-16 06:47:06 +00001403void StmtProfiler::VisitObjCPropertyRefExpr(const ObjCPropertyRefExpr *S) {
Douglas Gregora7095092009-07-28 14:44:31 +00001404 VisitExpr(S);
John McCallb7bd14f2010-12-02 01:19:52 +00001405 if (S->isImplicitProperty()) {
1406 VisitDecl(S->getImplicitPropertyGetter());
1407 VisitDecl(S->getImplicitPropertySetter());
1408 } else {
1409 VisitDecl(S->getExplicitProperty());
Fariborz Jahanian681c0752010-10-14 16:04:05 +00001410 }
Fariborz Jahanian681c0752010-10-14 16:04:05 +00001411 if (S->isSuperReceiver()) {
1412 ID.AddBoolean(S->isSuperReceiver());
John McCallb7bd14f2010-12-02 01:19:52 +00001413 VisitType(S->getSuperReceiverType());
Fariborz Jahanian681c0752010-10-14 16:04:05 +00001414 }
Douglas Gregora7095092009-07-28 14:44:31 +00001415}
1416
Ted Kremeneke65b0862012-03-06 20:05:56 +00001417void StmtProfiler::VisitObjCSubscriptRefExpr(const ObjCSubscriptRefExpr *S) {
1418 VisitExpr(S);
1419 VisitDecl(S->getAtIndexMethodDecl());
1420 VisitDecl(S->setAtIndexMethodDecl());
1421}
1422
Chandler Carruth631abd92011-06-16 06:47:06 +00001423void StmtProfiler::VisitObjCMessageExpr(const ObjCMessageExpr *S) {
Douglas Gregora7095092009-07-28 14:44:31 +00001424 VisitExpr(S);
1425 VisitName(S->getSelector());
1426 VisitDecl(S->getMethodDecl());
1427}
1428
Chandler Carruth631abd92011-06-16 06:47:06 +00001429void StmtProfiler::VisitObjCIsaExpr(const ObjCIsaExpr *S) {
Douglas Gregora7095092009-07-28 14:44:31 +00001430 VisitExpr(S);
1431 ID.AddBoolean(S->isArrow());
1432}
1433
Ted Kremeneke65b0862012-03-06 20:05:56 +00001434void StmtProfiler::VisitObjCBoolLiteralExpr(const ObjCBoolLiteralExpr *S) {
1435 VisitExpr(S);
1436 ID.AddBoolean(S->getValue());
1437}
1438
Chandler Carruth631abd92011-06-16 06:47:06 +00001439void StmtProfiler::VisitObjCIndirectCopyRestoreExpr(
1440 const ObjCIndirectCopyRestoreExpr *S) {
John McCall31168b02011-06-15 23:02:42 +00001441 VisitExpr(S);
1442 ID.AddBoolean(S->shouldCopy());
1443}
1444
Chandler Carruth631abd92011-06-16 06:47:06 +00001445void StmtProfiler::VisitObjCBridgedCastExpr(const ObjCBridgedCastExpr *S) {
John McCall31168b02011-06-15 23:02:42 +00001446 VisitExplicitCastExpr(S);
1447 ID.AddBoolean(S->getBridgeKind());
1448}
1449
Chandler Carruth631abd92011-06-16 06:47:06 +00001450void StmtProfiler::VisitDecl(const Decl *D) {
Douglas Gregor70317122009-07-31 15:45:02 +00001451 ID.AddInteger(D? D->getKind() : 0);
Mike Stump11289f42009-09-09 15:08:12 +00001452
Douglas Gregora5dd9f82009-07-30 23:18:24 +00001453 if (Canonical && D) {
Chandler Carruth631abd92011-06-16 06:47:06 +00001454 if (const NonTypeTemplateParmDecl *NTTP =
1455 dyn_cast<NonTypeTemplateParmDecl>(D)) {
Douglas Gregord9aedfa2009-07-28 15:32:17 +00001456 ID.AddInteger(NTTP->getDepth());
1457 ID.AddInteger(NTTP->getIndex());
Douglas Gregorf5500772011-01-05 15:48:55 +00001458 ID.AddBoolean(NTTP->isParameterPack());
Douglas Gregor00044172009-07-29 16:09:57 +00001459 VisitType(NTTP->getType());
Douglas Gregor5c193b92009-07-28 00:33:38 +00001460 return;
1461 }
Mike Stump11289f42009-09-09 15:08:12 +00001462
Chandler Carruth631abd92011-06-16 06:47:06 +00001463 if (const ParmVarDecl *Parm = dyn_cast<ParmVarDecl>(D)) {
John McCall8fb0d9d2011-05-01 22:35:37 +00001464 // The Itanium C++ ABI uses the type, scope depth, and scope
1465 // index of a parameter when mangling expressions that involve
1466 // function parameters, so we will use the parameter's type for
1467 // establishing function parameter identity. That way, our
1468 // definition of "equivalent" (per C++ [temp.over.link]) is at
1469 // least as strong as the definition of "equivalent" used for
1470 // name mangling.
Douglas Gregor70317122009-07-31 15:45:02 +00001471 VisitType(Parm->getType());
John McCall8fb0d9d2011-05-01 22:35:37 +00001472 ID.AddInteger(Parm->getFunctionScopeDepth());
1473 ID.AddInteger(Parm->getFunctionScopeIndex());
Douglas Gregor70317122009-07-31 15:45:02 +00001474 return;
1475 }
Mike Stump11289f42009-09-09 15:08:12 +00001476
Richard Smithd9a1cd82012-04-02 18:53:24 +00001477 if (const TemplateTypeParmDecl *TTP =
1478 dyn_cast<TemplateTypeParmDecl>(D)) {
1479 ID.AddInteger(TTP->getDepth());
1480 ID.AddInteger(TTP->getIndex());
1481 ID.AddBoolean(TTP->isParameterPack());
1482 return;
1483 }
1484
Chandler Carruth631abd92011-06-16 06:47:06 +00001485 if (const TemplateTemplateParmDecl *TTP =
1486 dyn_cast<TemplateTemplateParmDecl>(D)) {
Douglas Gregorc97f09f2009-07-31 15:46:56 +00001487 ID.AddInteger(TTP->getDepth());
1488 ID.AddInteger(TTP->getIndex());
Douglas Gregorf5500772011-01-05 15:48:55 +00001489 ID.AddBoolean(TTP->isParameterPack());
Douglas Gregorc97f09f2009-07-31 15:46:56 +00001490 return;
1491 }
Douglas Gregor5c193b92009-07-28 00:33:38 +00001492 }
Mike Stump11289f42009-09-09 15:08:12 +00001493
Craig Topper36250ad2014-05-12 05:36:57 +00001494 ID.AddPointer(D? D->getCanonicalDecl() : nullptr);
Douglas Gregord9aedfa2009-07-28 15:32:17 +00001495}
1496
1497void StmtProfiler::VisitType(QualType T) {
1498 if (Canonical)
1499 T = Context.getCanonicalType(T);
Mike Stump11289f42009-09-09 15:08:12 +00001500
Douglas Gregor5c193b92009-07-28 00:33:38 +00001501 ID.AddPointer(T.getAsOpaquePtr());
1502}
1503
1504void StmtProfiler::VisitName(DeclarationName Name) {
1505 ID.AddPointer(Name.getAsOpaquePtr());
1506}
1507
1508void StmtProfiler::VisitNestedNameSpecifier(NestedNameSpecifier *NNS) {
1509 if (Canonical)
1510 NNS = Context.getCanonicalNestedNameSpecifier(NNS);
1511 ID.AddPointer(NNS);
1512}
1513
1514void StmtProfiler::VisitTemplateName(TemplateName Name) {
1515 if (Canonical)
1516 Name = Context.getCanonicalTemplateName(Name);
Mike Stump11289f42009-09-09 15:08:12 +00001517
Douglas Gregor5c193b92009-07-28 00:33:38 +00001518 Name.Profile(ID);
1519}
1520
John McCall0ad16662009-10-29 08:12:44 +00001521void StmtProfiler::VisitTemplateArguments(const TemplateArgumentLoc *Args,
Douglas Gregor5c193b92009-07-28 00:33:38 +00001522 unsigned NumArgs) {
1523 ID.AddInteger(NumArgs);
John McCall0ad16662009-10-29 08:12:44 +00001524 for (unsigned I = 0; I != NumArgs; ++I)
1525 VisitTemplateArgument(Args[I].getArgument());
1526}
Mike Stump11289f42009-09-09 15:08:12 +00001527
John McCall0ad16662009-10-29 08:12:44 +00001528void StmtProfiler::VisitTemplateArgument(const TemplateArgument &Arg) {
1529 // Mostly repetitive with TemplateArgument::Profile!
1530 ID.AddInteger(Arg.getKind());
1531 switch (Arg.getKind()) {
1532 case TemplateArgument::Null:
1533 break;
Mike Stump11289f42009-09-09 15:08:12 +00001534
John McCall0ad16662009-10-29 08:12:44 +00001535 case TemplateArgument::Type:
1536 VisitType(Arg.getAsType());
1537 break;
Mike Stump11289f42009-09-09 15:08:12 +00001538
Douglas Gregor9167f8b2009-11-11 01:00:40 +00001539 case TemplateArgument::Template:
Douglas Gregore4ff4b52011-01-05 18:58:31 +00001540 case TemplateArgument::TemplateExpansion:
1541 VisitTemplateName(Arg.getAsTemplateOrTemplatePattern());
Douglas Gregor9167f8b2009-11-11 01:00:40 +00001542 break;
Alexis Hunta8136cc2010-05-05 15:23:54 +00001543
John McCall0ad16662009-10-29 08:12:44 +00001544 case TemplateArgument::Declaration:
1545 VisitDecl(Arg.getAsDecl());
1546 break;
Mike Stump11289f42009-09-09 15:08:12 +00001547
Eli Friedmanb826a002012-09-26 02:36:12 +00001548 case TemplateArgument::NullPtr:
1549 VisitType(Arg.getNullPtrType());
1550 break;
1551
John McCall0ad16662009-10-29 08:12:44 +00001552 case TemplateArgument::Integral:
Benjamin Kramer6003ad52012-06-07 15:09:51 +00001553 Arg.getAsIntegral().Profile(ID);
John McCall0ad16662009-10-29 08:12:44 +00001554 VisitType(Arg.getIntegralType());
1555 break;
Mike Stump11289f42009-09-09 15:08:12 +00001556
John McCall0ad16662009-10-29 08:12:44 +00001557 case TemplateArgument::Expression:
1558 Visit(Arg.getAsExpr());
1559 break;
Mike Stump11289f42009-09-09 15:08:12 +00001560
John McCall0ad16662009-10-29 08:12:44 +00001561 case TemplateArgument::Pack:
Aaron Ballman2a89e852014-07-15 21:32:31 +00001562 for (const auto &P : Arg.pack_elements())
1563 VisitTemplateArgument(P);
John McCall0ad16662009-10-29 08:12:44 +00001564 break;
Douglas Gregor5c193b92009-07-28 00:33:38 +00001565 }
1566}
1567
Jay Foad39c79802011-01-12 09:06:06 +00001568void Stmt::Profile(llvm::FoldingSetNodeID &ID, const ASTContext &Context,
Chandler Carruth631abd92011-06-16 06:47:06 +00001569 bool Canonical) const {
Douglas Gregor5c193b92009-07-28 00:33:38 +00001570 StmtProfiler Profiler(ID, Context, Canonical);
1571 Profiler.Visit(this);
1572}