blob: 22b0b31285e18ed4104959a2f60e04b86eafdfc0 [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);
NAKAMURA Takumiaa13f942015-12-09 07:52:46 +0000265
Alexey Bataev5ec3eb12013-07-19 03:13:43 +0000266public:
267 OMPClauseProfiler(StmtProfiler *P) : Profiler(P) { }
268#define OPENMP_CLAUSE(Name, Class) \
269 void Visit##Class(const Class *C);
270#include "clang/Basic/OpenMPKinds.def"
Alexey Bataev3392d762016-02-16 11:18:12 +0000271 void VistOMPClauseWithPreInit(const OMPClauseWithPreInit *C);
Alexey Bataev005248a2016-02-25 05:25:57 +0000272 void VistOMPClauseWithPostUpdate(const OMPClauseWithPostUpdate *C);
Alexey Bataev5ec3eb12013-07-19 03:13:43 +0000273};
274
Alexey Bataev3392d762016-02-16 11:18:12 +0000275void OMPClauseProfiler::VistOMPClauseWithPreInit(
276 const OMPClauseWithPreInit *C) {
277 if (auto *S = C->getPreInitStmt())
278 Profiler->VisitStmt(S);
279}
280
Alexey Bataev005248a2016-02-25 05:25:57 +0000281void OMPClauseProfiler::VistOMPClauseWithPostUpdate(
282 const OMPClauseWithPostUpdate *C) {
Alexey Bataev37e594c2016-03-04 07:21:16 +0000283 VistOMPClauseWithPreInit(C);
Alexey Bataev005248a2016-02-25 05:25:57 +0000284 if (auto *E = C->getPostUpdateExpr())
285 Profiler->VisitStmt(E);
286}
287
Alexey Bataevaadd52e2014-02-13 05:29:23 +0000288void OMPClauseProfiler::VisitOMPIfClause(const OMPIfClause *C) {
289 if (C->getCondition())
290 Profiler->VisitStmt(C->getCondition());
291}
292
Alexey Bataev3778b602014-07-17 07:32:53 +0000293void OMPClauseProfiler::VisitOMPFinalClause(const OMPFinalClause *C) {
294 if (C->getCondition())
295 Profiler->VisitStmt(C->getCondition());
296}
297
Alexey Bataev568a8332014-03-06 06:15:19 +0000298void OMPClauseProfiler::VisitOMPNumThreadsClause(const OMPNumThreadsClause *C) {
299 if (C->getNumThreads())
300 Profiler->VisitStmt(C->getNumThreads());
301}
302
Alexey Bataev62c87d22014-03-21 04:51:18 +0000303void OMPClauseProfiler::VisitOMPSafelenClause(const OMPSafelenClause *C) {
304 if (C->getSafelen())
305 Profiler->VisitStmt(C->getSafelen());
306}
307
Alexey Bataev66b15b52015-08-21 11:14:16 +0000308void OMPClauseProfiler::VisitOMPSimdlenClause(const OMPSimdlenClause *C) {
309 if (C->getSimdlen())
310 Profiler->VisitStmt(C->getSimdlen());
311}
312
Alexander Musman8bd31e62014-05-27 15:12:19 +0000313void OMPClauseProfiler::VisitOMPCollapseClause(const OMPCollapseClause *C) {
314 if (C->getNumForLoops())
315 Profiler->VisitStmt(C->getNumForLoops());
316}
317
Alexey Bataev5ec3eb12013-07-19 03:13:43 +0000318void OMPClauseProfiler::VisitOMPDefaultClause(const OMPDefaultClause *C) { }
Alexey Bataev756c1962013-09-24 03:17:45 +0000319
Alexey Bataevbcbadb62014-05-06 06:04:14 +0000320void OMPClauseProfiler::VisitOMPProcBindClause(const OMPProcBindClause *C) { }
321
Alexey Bataev56dafe82014-06-20 07:16:17 +0000322void OMPClauseProfiler::VisitOMPScheduleClause(const OMPScheduleClause *C) {
Alexey Bataev3392d762016-02-16 11:18:12 +0000323 VistOMPClauseWithPreInit(C);
324 if (auto *S = C->getChunkSize())
325 Profiler->VisitStmt(S);
Alexey Bataev56dafe82014-06-20 07:16:17 +0000326}
327
Alexey Bataev10e775f2015-07-30 11:36:16 +0000328void OMPClauseProfiler::VisitOMPOrderedClause(const OMPOrderedClause *C) {
329 if (auto *Num = C->getNumForLoops())
330 Profiler->VisitStmt(Num);
331}
Alexey Bataev142e1fc2014-06-20 09:44:06 +0000332
Alexey Bataev236070f2014-06-20 11:19:47 +0000333void OMPClauseProfiler::VisitOMPNowaitClause(const OMPNowaitClause *) {}
334
Alexey Bataev7aea99a2014-07-17 12:19:31 +0000335void OMPClauseProfiler::VisitOMPUntiedClause(const OMPUntiedClause *) {}
336
Alexey Bataev74ba3a52014-07-17 12:47:03 +0000337void OMPClauseProfiler::VisitOMPMergeableClause(const OMPMergeableClause *) {}
338
Alexey Bataevf98b00c2014-07-23 02:27:21 +0000339void OMPClauseProfiler::VisitOMPReadClause(const OMPReadClause *) {}
340
Alexey Bataevdea47612014-07-23 07:46:59 +0000341void OMPClauseProfiler::VisitOMPWriteClause(const OMPWriteClause *) {}
342
Alexey Bataev67a4f222014-07-23 10:25:33 +0000343void OMPClauseProfiler::VisitOMPUpdateClause(const OMPUpdateClause *) {}
344
Alexey Bataev459dec02014-07-24 06:46:57 +0000345void OMPClauseProfiler::VisitOMPCaptureClause(const OMPCaptureClause *) {}
346
Alexey Bataev82bad8b2014-07-24 08:55:34 +0000347void OMPClauseProfiler::VisitOMPSeqCstClause(const OMPSeqCstClause *) {}
348
Alexey Bataev346265e2015-09-25 10:37:12 +0000349void OMPClauseProfiler::VisitOMPThreadsClause(const OMPThreadsClause *) {}
350
Alexey Bataevd14d1e62015-09-28 06:39:35 +0000351void OMPClauseProfiler::VisitOMPSIMDClause(const OMPSIMDClause *) {}
352
Alexey Bataevb825de12015-12-07 10:51:44 +0000353void OMPClauseProfiler::VisitOMPNogroupClause(const OMPNogroupClause *) {}
354
Alexey Bataev756c1962013-09-24 03:17:45 +0000355template<typename T>
356void OMPClauseProfiler::VisitOMPClauseList(T *Node) {
Alexey Bataev03b340a2014-10-21 03:16:40 +0000357 for (auto *E : Node->varlists()) {
358 Profiler->VisitStmt(E);
359 }
Alexey Bataev756c1962013-09-24 03:17:45 +0000360}
Alexey Bataev5ec3eb12013-07-19 03:13:43 +0000361
362void OMPClauseProfiler::VisitOMPPrivateClause(const OMPPrivateClause *C) {
Alexey Bataev756c1962013-09-24 03:17:45 +0000363 VisitOMPClauseList(C);
Alexey Bataev03b340a2014-10-21 03:16:40 +0000364 for (auto *E : C->private_copies()) {
365 Profiler->VisitStmt(E);
366 }
Alexey Bataev5ec3eb12013-07-19 03:13:43 +0000367}
Alexey Bataev4a5bb772014-10-08 14:01:46 +0000368void
369OMPClauseProfiler::VisitOMPFirstprivateClause(const OMPFirstprivateClause *C) {
Alexey Bataevd5af8e42013-10-01 05:32:34 +0000370 VisitOMPClauseList(C);
Alexey Bataev417089f2016-02-17 13:19:37 +0000371 VistOMPClauseWithPreInit(C);
Alexey Bataev4a5bb772014-10-08 14:01:46 +0000372 for (auto *E : C->private_copies()) {
373 Profiler->VisitStmt(E);
374 }
375 for (auto *E : C->inits()) {
376 Profiler->VisitStmt(E);
377 }
Alexey Bataevd5af8e42013-10-01 05:32:34 +0000378}
Alexander Musman1bb328c2014-06-04 13:06:39 +0000379void
380OMPClauseProfiler::VisitOMPLastprivateClause(const OMPLastprivateClause *C) {
381 VisitOMPClauseList(C);
Alexey Bataev005248a2016-02-25 05:25:57 +0000382 VistOMPClauseWithPostUpdate(C);
Alexey Bataev38e89532015-04-16 04:54:05 +0000383 for (auto *E : C->source_exprs()) {
384 Profiler->VisitStmt(E);
385 }
386 for (auto *E : C->destination_exprs()) {
387 Profiler->VisitStmt(E);
388 }
389 for (auto *E : C->assignment_ops()) {
390 Profiler->VisitStmt(E);
391 }
Alexander Musman1bb328c2014-06-04 13:06:39 +0000392}
Alexey Bataev758e55e2013-09-06 18:03:48 +0000393void OMPClauseProfiler::VisitOMPSharedClause(const OMPSharedClause *C) {
Alexey Bataev756c1962013-09-24 03:17:45 +0000394 VisitOMPClauseList(C);
Alexey Bataev758e55e2013-09-06 18:03:48 +0000395}
Alexey Bataevc5e02582014-06-16 07:08:35 +0000396void OMPClauseProfiler::VisitOMPReductionClause(
397 const OMPReductionClause *C) {
398 Profiler->VisitNestedNameSpecifier(
399 C->getQualifierLoc().getNestedNameSpecifier());
400 Profiler->VisitName(C->getNameInfo().getName());
401 VisitOMPClauseList(C);
Alexey Bataev61205072016-03-02 04:57:40 +0000402 VistOMPClauseWithPostUpdate(C);
Alexey Bataevf24e7b12015-10-08 09:10:53 +0000403 for (auto *E : C->privates()) {
404 Profiler->VisitStmt(E);
405 }
Alexey Bataev794ba0d2015-04-10 10:43:45 +0000406 for (auto *E : C->lhs_exprs()) {
407 Profiler->VisitStmt(E);
408 }
409 for (auto *E : C->rhs_exprs()) {
410 Profiler->VisitStmt(E);
411 }
412 for (auto *E : C->reduction_ops()) {
413 Profiler->VisitStmt(E);
414 }
Alexey Bataevc5e02582014-06-16 07:08:35 +0000415}
Alexander Musman8dba6642014-04-22 13:09:42 +0000416void OMPClauseProfiler::VisitOMPLinearClause(const OMPLinearClause *C) {
417 VisitOMPClauseList(C);
Alexey Bataev78849fb2016-03-09 09:49:00 +0000418 VistOMPClauseWithPostUpdate(C);
Alexey Bataevbd9fec12015-08-18 06:47:21 +0000419 for (auto *E : C->privates()) {
420 Profiler->VisitStmt(E);
421 }
Alexander Musman3276a272015-03-21 10:12:56 +0000422 for (auto *E : C->inits()) {
423 Profiler->VisitStmt(E);
424 }
425 for (auto *E : C->updates()) {
426 Profiler->VisitStmt(E);
427 }
428 for (auto *E : C->finals()) {
429 Profiler->VisitStmt(E);
430 }
Alexander Musman8dba6642014-04-22 13:09:42 +0000431 Profiler->VisitStmt(C->getStep());
Alexander Musman3276a272015-03-21 10:12:56 +0000432 Profiler->VisitStmt(C->getCalcStep());
Alexander Musman8dba6642014-04-22 13:09:42 +0000433}
Alexander Musmanf0d76e72014-05-29 14:36:25 +0000434void OMPClauseProfiler::VisitOMPAlignedClause(const OMPAlignedClause *C) {
435 VisitOMPClauseList(C);
436 Profiler->VisitStmt(C->getAlignment());
437}
Alexey Bataevd48bcd82014-03-31 03:36:38 +0000438void OMPClauseProfiler::VisitOMPCopyinClause(const OMPCopyinClause *C) {
439 VisitOMPClauseList(C);
Alexey Bataevf56f98c2015-04-16 05:39:01 +0000440 for (auto *E : C->source_exprs()) {
441 Profiler->VisitStmt(E);
442 }
443 for (auto *E : C->destination_exprs()) {
444 Profiler->VisitStmt(E);
445 }
446 for (auto *E : C->assignment_ops()) {
447 Profiler->VisitStmt(E);
448 }
Alexey Bataevd48bcd82014-03-31 03:36:38 +0000449}
Alexey Bataevbae9a792014-06-27 10:37:06 +0000450void
451OMPClauseProfiler::VisitOMPCopyprivateClause(const OMPCopyprivateClause *C) {
452 VisitOMPClauseList(C);
Alexey Bataeva63048e2015-03-23 06:18:07 +0000453 for (auto *E : C->source_exprs()) {
454 Profiler->VisitStmt(E);
455 }
456 for (auto *E : C->destination_exprs()) {
457 Profiler->VisitStmt(E);
458 }
459 for (auto *E : C->assignment_ops()) {
460 Profiler->VisitStmt(E);
461 }
Alexey Bataevbae9a792014-06-27 10:37:06 +0000462}
Alexey Bataev6125da92014-07-21 11:26:11 +0000463void OMPClauseProfiler::VisitOMPFlushClause(const OMPFlushClause *C) {
464 VisitOMPClauseList(C);
465}
Alexey Bataev1c2cfbc2015-06-23 14:25:19 +0000466void OMPClauseProfiler::VisitOMPDependClause(const OMPDependClause *C) {
467 VisitOMPClauseList(C);
468}
Michael Wonge710d542015-08-07 16:16:36 +0000469void OMPClauseProfiler::VisitOMPDeviceClause(const OMPDeviceClause *C) {
470 Profiler->VisitStmt(C->getDevice());
471}
Kelvin Li0bff7af2015-11-23 05:32:03 +0000472void OMPClauseProfiler::VisitOMPMapClause(const OMPMapClause *C) {
473 VisitOMPClauseList(C);
474}
Kelvin Li099bb8c2015-11-24 20:50:12 +0000475void OMPClauseProfiler::VisitOMPNumTeamsClause(const OMPNumTeamsClause *C) {
476 Profiler->VisitStmt(C->getNumTeams());
477}
Kelvin Lia15fb1a2015-11-27 18:47:36 +0000478void OMPClauseProfiler::VisitOMPThreadLimitClause(
479 const OMPThreadLimitClause *C) {
480 Profiler->VisitStmt(C->getThreadLimit());
481}
Alexey Bataeva0569352015-12-01 10:17:31 +0000482void OMPClauseProfiler::VisitOMPPriorityClause(const OMPPriorityClause *C) {
483 Profiler->VisitStmt(C->getPriority());
484}
Alexey Bataev1fd4aed2015-12-07 12:52:51 +0000485void OMPClauseProfiler::VisitOMPGrainsizeClause(const OMPGrainsizeClause *C) {
486 Profiler->VisitStmt(C->getGrainsize());
487}
Alexey Bataev382967a2015-12-08 12:06:20 +0000488void OMPClauseProfiler::VisitOMPNumTasksClause(const OMPNumTasksClause *C) {
489 Profiler->VisitStmt(C->getNumTasks());
490}
Alexey Bataev28c75412015-12-15 08:19:24 +0000491void OMPClauseProfiler::VisitOMPHintClause(const OMPHintClause *C) {
492 Profiler->VisitStmt(C->getHint());
493}
Samuel Antao661c0902016-05-26 17:39:58 +0000494void OMPClauseProfiler::VisitOMPToClause(const OMPToClause *C) {
495 VisitOMPClauseList(C);
496}
Alexander Kornienkoab9db512015-06-22 23:07:51 +0000497}
Alexey Bataev5ec3eb12013-07-19 03:13:43 +0000498
499void
Alexey Bataev1b59ab52014-02-27 08:29:12 +0000500StmtProfiler::VisitOMPExecutableDirective(const OMPExecutableDirective *S) {
Alexey Bataev5ec3eb12013-07-19 03:13:43 +0000501 VisitStmt(S);
502 OMPClauseProfiler P(this);
503 ArrayRef<OMPClause *> Clauses = S->clauses();
504 for (ArrayRef<OMPClause *>::iterator I = Clauses.begin(), E = Clauses.end();
505 I != E; ++I)
506 if (*I)
507 P.Visit(*I);
508}
509
Alexander Musman3aaab662014-08-19 11:27:13 +0000510void StmtProfiler::VisitOMPLoopDirective(const OMPLoopDirective *S) {
511 VisitOMPExecutableDirective(S);
512}
513
Alexey Bataev1b59ab52014-02-27 08:29:12 +0000514void StmtProfiler::VisitOMPParallelDirective(const OMPParallelDirective *S) {
515 VisitOMPExecutableDirective(S);
516}
517
518void StmtProfiler::VisitOMPSimdDirective(const OMPSimdDirective *S) {
Alexander Musman3aaab662014-08-19 11:27:13 +0000519 VisitOMPLoopDirective(S);
Alexey Bataev1b59ab52014-02-27 08:29:12 +0000520}
521
Alexey Bataevf29276e2014-06-18 04:14:57 +0000522void StmtProfiler::VisitOMPForDirective(const OMPForDirective *S) {
Alexander Musman3aaab662014-08-19 11:27:13 +0000523 VisitOMPLoopDirective(S);
Alexey Bataevf29276e2014-06-18 04:14:57 +0000524}
525
Alexander Musmanf82886e2014-09-18 05:12:34 +0000526void StmtProfiler::VisitOMPForSimdDirective(const OMPForSimdDirective *S) {
527 VisitOMPLoopDirective(S);
528}
529
Alexey Bataevd3f8dd22014-06-25 11:44:49 +0000530void StmtProfiler::VisitOMPSectionsDirective(const OMPSectionsDirective *S) {
531 VisitOMPExecutableDirective(S);
532}
533
Alexey Bataev1e0498a2014-06-26 08:21:58 +0000534void StmtProfiler::VisitOMPSectionDirective(const OMPSectionDirective *S) {
535 VisitOMPExecutableDirective(S);
536}
537
Alexey Bataevd1e40fb2014-06-26 12:05:45 +0000538void StmtProfiler::VisitOMPSingleDirective(const OMPSingleDirective *S) {
539 VisitOMPExecutableDirective(S);
540}
541
Alexander Musman80c22892014-07-17 08:54:58 +0000542void StmtProfiler::VisitOMPMasterDirective(const OMPMasterDirective *S) {
543 VisitOMPExecutableDirective(S);
544}
545
Alexander Musmand9ed09f2014-07-21 09:42:05 +0000546void StmtProfiler::VisitOMPCriticalDirective(const OMPCriticalDirective *S) {
547 VisitOMPExecutableDirective(S);
548 VisitName(S->getDirectiveName().getName());
549}
550
Alexey Bataev4acb8592014-07-07 13:01:15 +0000551void
552StmtProfiler::VisitOMPParallelForDirective(const OMPParallelForDirective *S) {
Alexander Musman3aaab662014-08-19 11:27:13 +0000553 VisitOMPLoopDirective(S);
Alexey Bataev4acb8592014-07-07 13:01:15 +0000554}
555
Alexander Musmane4e893b2014-09-23 09:33:00 +0000556void StmtProfiler::VisitOMPParallelForSimdDirective(
557 const OMPParallelForSimdDirective *S) {
558 VisitOMPLoopDirective(S);
559}
560
Alexey Bataev84d0b3e2014-07-08 08:12:03 +0000561void StmtProfiler::VisitOMPParallelSectionsDirective(
562 const OMPParallelSectionsDirective *S) {
563 VisitOMPExecutableDirective(S);
564}
565
Alexey Bataev9c2e8ee2014-07-11 11:25:16 +0000566void StmtProfiler::VisitOMPTaskDirective(const OMPTaskDirective *S) {
567 VisitOMPExecutableDirective(S);
568}
569
Alexey Bataev68446b72014-07-18 07:47:19 +0000570void StmtProfiler::VisitOMPTaskyieldDirective(const OMPTaskyieldDirective *S) {
571 VisitOMPExecutableDirective(S);
572}
573
Alexey Bataev4d1dfea2014-07-18 09:11:51 +0000574void StmtProfiler::VisitOMPBarrierDirective(const OMPBarrierDirective *S) {
575 VisitOMPExecutableDirective(S);
576}
577
Alexey Bataev2df347a2014-07-18 10:17:07 +0000578void StmtProfiler::VisitOMPTaskwaitDirective(const OMPTaskwaitDirective *S) {
579 VisitOMPExecutableDirective(S);
580}
581
Alexey Bataevc30dd2d2015-06-18 12:14:09 +0000582void StmtProfiler::VisitOMPTaskgroupDirective(const OMPTaskgroupDirective *S) {
583 VisitOMPExecutableDirective(S);
584}
585
Alexey Bataev6125da92014-07-21 11:26:11 +0000586void StmtProfiler::VisitOMPFlushDirective(const OMPFlushDirective *S) {
587 VisitOMPExecutableDirective(S);
588}
589
Alexey Bataev9fb6e642014-07-22 06:45:04 +0000590void StmtProfiler::VisitOMPOrderedDirective(const OMPOrderedDirective *S) {
591 VisitOMPExecutableDirective(S);
592}
593
Alexey Bataev0162e452014-07-22 10:10:35 +0000594void StmtProfiler::VisitOMPAtomicDirective(const OMPAtomicDirective *S) {
595 VisitOMPExecutableDirective(S);
596}
597
Alexey Bataev0bd520b2014-09-19 08:19:49 +0000598void StmtProfiler::VisitOMPTargetDirective(const OMPTargetDirective *S) {
599 VisitOMPExecutableDirective(S);
600}
601
Michael Wong65f367f2015-07-21 13:44:28 +0000602void StmtProfiler::VisitOMPTargetDataDirective(const OMPTargetDataDirective *S) {
603 VisitOMPExecutableDirective(S);
604}
605
Samuel Antaodf67fc42016-01-19 19:15:56 +0000606void StmtProfiler::VisitOMPTargetEnterDataDirective(
607 const OMPTargetEnterDataDirective *S) {
608 VisitOMPExecutableDirective(S);
609}
610
Samuel Antao72590762016-01-19 20:04:50 +0000611void StmtProfiler::VisitOMPTargetExitDataDirective(
612 const OMPTargetExitDataDirective *S) {
613 VisitOMPExecutableDirective(S);
614}
615
Arpith Chacko Jacobe955b3d2016-01-26 18:48:41 +0000616void StmtProfiler::VisitOMPTargetParallelDirective(
617 const OMPTargetParallelDirective *S) {
618 VisitOMPExecutableDirective(S);
619}
620
Arpith Chacko Jacob05bebb52016-02-03 15:46:42 +0000621void StmtProfiler::VisitOMPTargetParallelForDirective(
622 const OMPTargetParallelForDirective *S) {
623 VisitOMPExecutableDirective(S);
624}
625
Alexey Bataev13314bf2014-10-09 04:18:56 +0000626void StmtProfiler::VisitOMPTeamsDirective(const OMPTeamsDirective *S) {
627 VisitOMPExecutableDirective(S);
628}
629
Alexey Bataev6d4ed052015-07-01 06:57:41 +0000630void StmtProfiler::VisitOMPCancellationPointDirective(
631 const OMPCancellationPointDirective *S) {
632 VisitOMPExecutableDirective(S);
633}
634
Alexey Bataev80909872015-07-02 11:25:17 +0000635void StmtProfiler::VisitOMPCancelDirective(const OMPCancelDirective *S) {
636 VisitOMPExecutableDirective(S);
637}
638
Alexey Bataev49f6e782015-12-01 04:18:41 +0000639void StmtProfiler::VisitOMPTaskLoopDirective(const OMPTaskLoopDirective *S) {
640 VisitOMPLoopDirective(S);
641}
642
Alexey Bataev0a6ed842015-12-03 09:40:15 +0000643void StmtProfiler::VisitOMPTaskLoopSimdDirective(
644 const OMPTaskLoopSimdDirective *S) {
645 VisitOMPLoopDirective(S);
646}
647
Carlo Bertolli6200a3d2015-12-14 14:51:25 +0000648void StmtProfiler::VisitOMPDistributeDirective(
649 const OMPDistributeDirective *S) {
650 VisitOMPLoopDirective(S);
651}
652
Carlo Bertollib4adf552016-01-15 18:50:31 +0000653void OMPClauseProfiler::VisitOMPDistScheduleClause(
654 const OMPDistScheduleClause *C) {
Alexey Bataev3392d762016-02-16 11:18:12 +0000655 VistOMPClauseWithPreInit(C);
656 if (auto *S = C->getChunkSize())
657 Profiler->VisitStmt(S);
Carlo Bertollib4adf552016-01-15 18:50:31 +0000658}
659
Arpith Chacko Jacob3cf89042016-01-26 16:37:23 +0000660void OMPClauseProfiler::VisitOMPDefaultmapClause(const OMPDefaultmapClause *) {}
661
Samuel Antao686c70c2016-05-26 17:30:50 +0000662void StmtProfiler::VisitOMPTargetUpdateDirective(
663 const OMPTargetUpdateDirective *S) {
664 VisitOMPExecutableDirective(S);
665}
666
Chandler Carruth631abd92011-06-16 06:47:06 +0000667void StmtProfiler::VisitExpr(const Expr *S) {
Douglas Gregor5c193b92009-07-28 00:33:38 +0000668 VisitStmt(S);
669}
670
Chandler Carruth631abd92011-06-16 06:47:06 +0000671void StmtProfiler::VisitDeclRefExpr(const DeclRefExpr *S) {
Douglas Gregor5c193b92009-07-28 00:33:38 +0000672 VisitExpr(S);
Douglas Gregorf5b160f2010-07-13 08:37:11 +0000673 if (!Canonical)
674 VisitNestedNameSpecifier(S->getQualifier());
Douglas Gregor5c193b92009-07-28 00:33:38 +0000675 VisitDecl(S->getDecl());
Douglas Gregorf5b160f2010-07-13 08:37:11 +0000676 if (!Canonical)
677 VisitTemplateArguments(S->getTemplateArgs(), S->getNumTemplateArgs());
Douglas Gregor5c193b92009-07-28 00:33:38 +0000678}
679
Chandler Carruth631abd92011-06-16 06:47:06 +0000680void StmtProfiler::VisitPredefinedExpr(const PredefinedExpr *S) {
Douglas Gregor5c193b92009-07-28 00:33:38 +0000681 VisitExpr(S);
682 ID.AddInteger(S->getIdentType());
683}
684
Chandler Carruth631abd92011-06-16 06:47:06 +0000685void StmtProfiler::VisitIntegerLiteral(const IntegerLiteral *S) {
Douglas Gregor5c193b92009-07-28 00:33:38 +0000686 VisitExpr(S);
687 S->getValue().Profile(ID);
Richard Smithe9f130c2014-11-20 03:37:32 +0000688 ID.AddInteger(S->getType()->castAs<BuiltinType>()->getKind());
Douglas Gregor5c193b92009-07-28 00:33:38 +0000689}
690
Chandler Carruth631abd92011-06-16 06:47:06 +0000691void StmtProfiler::VisitCharacterLiteral(const CharacterLiteral *S) {
Douglas Gregor5c193b92009-07-28 00:33:38 +0000692 VisitExpr(S);
Douglas Gregorfb65e592011-07-27 05:40:30 +0000693 ID.AddInteger(S->getKind());
Douglas Gregor5c193b92009-07-28 00:33:38 +0000694 ID.AddInteger(S->getValue());
695}
696
Chandler Carruth631abd92011-06-16 06:47:06 +0000697void StmtProfiler::VisitFloatingLiteral(const FloatingLiteral *S) {
Douglas Gregor5c193b92009-07-28 00:33:38 +0000698 VisitExpr(S);
699 S->getValue().Profile(ID);
700 ID.AddBoolean(S->isExact());
Richard Smithe9f130c2014-11-20 03:37:32 +0000701 ID.AddInteger(S->getType()->castAs<BuiltinType>()->getKind());
Douglas Gregor5c193b92009-07-28 00:33:38 +0000702}
703
Chandler Carruth631abd92011-06-16 06:47:06 +0000704void StmtProfiler::VisitImaginaryLiteral(const ImaginaryLiteral *S) {
Douglas Gregor5c193b92009-07-28 00:33:38 +0000705 VisitExpr(S);
706}
707
Chandler Carruth631abd92011-06-16 06:47:06 +0000708void StmtProfiler::VisitStringLiteral(const StringLiteral *S) {
Douglas Gregor5c193b92009-07-28 00:33:38 +0000709 VisitExpr(S);
Douglas Gregor9d0eb8f2011-11-02 17:26:05 +0000710 ID.AddString(S->getBytes());
Douglas Gregorfb65e592011-07-27 05:40:30 +0000711 ID.AddInteger(S->getKind());
Douglas Gregor5c193b92009-07-28 00:33:38 +0000712}
713
Chandler Carruth631abd92011-06-16 06:47:06 +0000714void StmtProfiler::VisitParenExpr(const ParenExpr *S) {
Douglas Gregor5c193b92009-07-28 00:33:38 +0000715 VisitExpr(S);
716}
717
Chandler Carruth631abd92011-06-16 06:47:06 +0000718void StmtProfiler::VisitParenListExpr(const ParenListExpr *S) {
Nate Begeman5ec4b312009-08-10 23:49:36 +0000719 VisitExpr(S);
720}
721
Chandler Carruth631abd92011-06-16 06:47:06 +0000722void StmtProfiler::VisitUnaryOperator(const UnaryOperator *S) {
Douglas Gregor5c193b92009-07-28 00:33:38 +0000723 VisitExpr(S);
724 ID.AddInteger(S->getOpcode());
725}
726
Chandler Carruth631abd92011-06-16 06:47:06 +0000727void StmtProfiler::VisitOffsetOfExpr(const OffsetOfExpr *S) {
Douglas Gregor882211c2010-04-28 22:16:22 +0000728 VisitType(S->getTypeSourceInfo()->getType());
729 unsigned n = S->getNumComponents();
730 for (unsigned i = 0; i < n; ++i) {
James Y Knight7281c352015-12-29 22:31:18 +0000731 const OffsetOfNode &ON = S->getComponent(i);
Douglas Gregor882211c2010-04-28 22:16:22 +0000732 ID.AddInteger(ON.getKind());
733 switch (ON.getKind()) {
James Y Knight7281c352015-12-29 22:31:18 +0000734 case OffsetOfNode::Array:
Douglas Gregor882211c2010-04-28 22:16:22 +0000735 // Expressions handled below.
736 break;
737
James Y Knight7281c352015-12-29 22:31:18 +0000738 case OffsetOfNode::Field:
Douglas Gregor882211c2010-04-28 22:16:22 +0000739 VisitDecl(ON.getField());
740 break;
741
James Y Knight7281c352015-12-29 22:31:18 +0000742 case OffsetOfNode::Identifier:
Douglas Gregor882211c2010-04-28 22:16:22 +0000743 ID.AddPointer(ON.getFieldName());
744 break;
James Y Knight7281c352015-12-29 22:31:18 +0000745
746 case OffsetOfNode::Base:
Douglas Gregord1702062010-04-29 00:18:15 +0000747 // These nodes are implicit, and therefore don't need profiling.
748 break;
Douglas Gregor882211c2010-04-28 22:16:22 +0000749 }
750 }
Alexis Hunta8136cc2010-05-05 15:23:54 +0000751
Douglas Gregor882211c2010-04-28 22:16:22 +0000752 VisitExpr(S);
753}
754
Chandler Carruth631abd92011-06-16 06:47:06 +0000755void
756StmtProfiler::VisitUnaryExprOrTypeTraitExpr(const UnaryExprOrTypeTraitExpr *S) {
Douglas Gregor5c193b92009-07-28 00:33:38 +0000757 VisitExpr(S);
Peter Collingbournee190dee2011-03-11 19:24:49 +0000758 ID.AddInteger(S->getKind());
Douglas Gregor5c193b92009-07-28 00:33:38 +0000759 if (S->isArgumentType())
760 VisitType(S->getArgumentType());
761}
762
Chandler Carruth631abd92011-06-16 06:47:06 +0000763void StmtProfiler::VisitArraySubscriptExpr(const ArraySubscriptExpr *S) {
Douglas Gregor5c193b92009-07-28 00:33:38 +0000764 VisitExpr(S);
765}
766
Alexey Bataev1a3320e2015-08-25 14:24:04 +0000767void StmtProfiler::VisitOMPArraySectionExpr(const OMPArraySectionExpr *S) {
768 VisitExpr(S);
769}
770
Chandler Carruth631abd92011-06-16 06:47:06 +0000771void StmtProfiler::VisitCallExpr(const CallExpr *S) {
Douglas Gregor5c193b92009-07-28 00:33:38 +0000772 VisitExpr(S);
773}
774
Chandler Carruth631abd92011-06-16 06:47:06 +0000775void StmtProfiler::VisitMemberExpr(const MemberExpr *S) {
Douglas Gregor5c193b92009-07-28 00:33:38 +0000776 VisitExpr(S);
777 VisitDecl(S->getMemberDecl());
Douglas Gregorf5b160f2010-07-13 08:37:11 +0000778 if (!Canonical)
779 VisitNestedNameSpecifier(S->getQualifier());
Douglas Gregor5c193b92009-07-28 00:33:38 +0000780 ID.AddBoolean(S->isArrow());
781}
782
Chandler Carruth631abd92011-06-16 06:47:06 +0000783void StmtProfiler::VisitCompoundLiteralExpr(const CompoundLiteralExpr *S) {
Douglas Gregor5c193b92009-07-28 00:33:38 +0000784 VisitExpr(S);
785 ID.AddBoolean(S->isFileScope());
786}
787
Chandler Carruth631abd92011-06-16 06:47:06 +0000788void StmtProfiler::VisitCastExpr(const CastExpr *S) {
Douglas Gregor5c193b92009-07-28 00:33:38 +0000789 VisitExpr(S);
790}
791
Chandler Carruth631abd92011-06-16 06:47:06 +0000792void StmtProfiler::VisitImplicitCastExpr(const ImplicitCastExpr *S) {
Douglas Gregor5c193b92009-07-28 00:33:38 +0000793 VisitCastExpr(S);
John McCall2536c6d2010-08-25 10:28:54 +0000794 ID.AddInteger(S->getValueKind());
Douglas Gregor5c193b92009-07-28 00:33:38 +0000795}
796
Chandler Carruth631abd92011-06-16 06:47:06 +0000797void StmtProfiler::VisitExplicitCastExpr(const ExplicitCastExpr *S) {
Douglas Gregor5c193b92009-07-28 00:33:38 +0000798 VisitCastExpr(S);
799 VisitType(S->getTypeAsWritten());
800}
801
Chandler Carruth631abd92011-06-16 06:47:06 +0000802void StmtProfiler::VisitCStyleCastExpr(const CStyleCastExpr *S) {
Douglas Gregor5c193b92009-07-28 00:33:38 +0000803 VisitExplicitCastExpr(S);
804}
805
Chandler Carruth631abd92011-06-16 06:47:06 +0000806void StmtProfiler::VisitBinaryOperator(const BinaryOperator *S) {
Douglas Gregor5c193b92009-07-28 00:33:38 +0000807 VisitExpr(S);
808 ID.AddInteger(S->getOpcode());
809}
810
Chandler Carruth631abd92011-06-16 06:47:06 +0000811void
812StmtProfiler::VisitCompoundAssignOperator(const CompoundAssignOperator *S) {
Douglas Gregor5c193b92009-07-28 00:33:38 +0000813 VisitBinaryOperator(S);
814}
815
Chandler Carruth631abd92011-06-16 06:47:06 +0000816void StmtProfiler::VisitConditionalOperator(const ConditionalOperator *S) {
Douglas Gregor5c193b92009-07-28 00:33:38 +0000817 VisitExpr(S);
818}
819
Chandler Carruth631abd92011-06-16 06:47:06 +0000820void StmtProfiler::VisitBinaryConditionalOperator(
Chandler Carruthcf5f43c2011-06-21 23:26:32 +0000821 const BinaryConditionalOperator *S) {
John McCallc07a0c72011-02-17 10:25:35 +0000822 VisitExpr(S);
823}
824
Chandler Carruth631abd92011-06-16 06:47:06 +0000825void StmtProfiler::VisitAddrLabelExpr(const AddrLabelExpr *S) {
Douglas Gregor5c193b92009-07-28 00:33:38 +0000826 VisitExpr(S);
Chris Lattnerc8e630e2011-02-17 07:39:24 +0000827 VisitDecl(S->getLabel());
Douglas Gregor5c193b92009-07-28 00:33:38 +0000828}
829
Chandler Carruth631abd92011-06-16 06:47:06 +0000830void StmtProfiler::VisitStmtExpr(const StmtExpr *S) {
Douglas Gregor5c193b92009-07-28 00:33:38 +0000831 VisitExpr(S);
832}
833
Chandler Carruth631abd92011-06-16 06:47:06 +0000834void StmtProfiler::VisitShuffleVectorExpr(const ShuffleVectorExpr *S) {
Douglas Gregor5c193b92009-07-28 00:33:38 +0000835 VisitExpr(S);
836}
837
Hal Finkelc4d7c822013-09-18 03:29:45 +0000838void StmtProfiler::VisitConvertVectorExpr(const ConvertVectorExpr *S) {
839 VisitExpr(S);
840}
841
Chandler Carruth631abd92011-06-16 06:47:06 +0000842void StmtProfiler::VisitChooseExpr(const ChooseExpr *S) {
Douglas Gregor5c193b92009-07-28 00:33:38 +0000843 VisitExpr(S);
844}
845
Chandler Carruth631abd92011-06-16 06:47:06 +0000846void StmtProfiler::VisitGNUNullExpr(const GNUNullExpr *S) {
Douglas Gregor5c193b92009-07-28 00:33:38 +0000847 VisitExpr(S);
848}
849
Chandler Carruth631abd92011-06-16 06:47:06 +0000850void StmtProfiler::VisitVAArgExpr(const VAArgExpr *S) {
Douglas Gregor00044172009-07-29 16:09:57 +0000851 VisitExpr(S);
852}
853
Chandler Carruth631abd92011-06-16 06:47:06 +0000854void StmtProfiler::VisitInitListExpr(const InitListExpr *S) {
Douglas Gregor5c193b92009-07-28 00:33:38 +0000855 if (S->getSyntacticForm()) {
856 VisitInitListExpr(S->getSyntacticForm());
857 return;
858 }
Mike Stump11289f42009-09-09 15:08:12 +0000859
Douglas Gregor5c193b92009-07-28 00:33:38 +0000860 VisitExpr(S);
861}
862
Chandler Carruth631abd92011-06-16 06:47:06 +0000863void StmtProfiler::VisitDesignatedInitExpr(const DesignatedInitExpr *S) {
Douglas Gregor5c193b92009-07-28 00:33:38 +0000864 VisitExpr(S);
865 ID.AddBoolean(S->usesGNUSyntax());
Chandler Carruth631abd92011-06-16 06:47:06 +0000866 for (DesignatedInitExpr::const_designators_iterator D =
867 S->designators_begin(), DEnd = S->designators_end();
Douglas Gregor5c193b92009-07-28 00:33:38 +0000868 D != DEnd; ++D) {
869 if (D->isFieldDesignator()) {
870 ID.AddInteger(0);
871 VisitName(D->getFieldName());
872 continue;
873 }
Mike Stump11289f42009-09-09 15:08:12 +0000874
Douglas Gregor5c193b92009-07-28 00:33:38 +0000875 if (D->isArrayDesignator()) {
876 ID.AddInteger(1);
877 } else {
878 assert(D->isArrayRangeDesignator());
879 ID.AddInteger(2);
880 }
881 ID.AddInteger(D->getFirstExprIndex());
882 }
883}
884
Yunzhong Gaocb779302015-06-10 00:27:52 +0000885// Seems that if VisitInitListExpr() only works on the syntactic form of an
886// InitListExpr, then a DesignatedInitUpdateExpr is not encountered.
887void StmtProfiler::VisitDesignatedInitUpdateExpr(
888 const DesignatedInitUpdateExpr *S) {
889 llvm_unreachable("Unexpected DesignatedInitUpdateExpr in syntactic form of "
890 "initializer");
891}
892
893void StmtProfiler::VisitNoInitExpr(const NoInitExpr *S) {
894 llvm_unreachable("Unexpected NoInitExpr in syntactic form of initializer");
895}
896
Chandler Carruth631abd92011-06-16 06:47:06 +0000897void StmtProfiler::VisitImplicitValueInitExpr(const ImplicitValueInitExpr *S) {
Douglas Gregor5c193b92009-07-28 00:33:38 +0000898 VisitExpr(S);
899}
900
Chandler Carruth631abd92011-06-16 06:47:06 +0000901void StmtProfiler::VisitExtVectorElementExpr(const ExtVectorElementExpr *S) {
Douglas Gregor5c193b92009-07-28 00:33:38 +0000902 VisitExpr(S);
903 VisitName(&S->getAccessor());
904}
905
Chandler Carruth631abd92011-06-16 06:47:06 +0000906void StmtProfiler::VisitBlockExpr(const BlockExpr *S) {
Douglas Gregor5c193b92009-07-28 00:33:38 +0000907 VisitExpr(S);
908 VisitDecl(S->getBlockDecl());
909}
910
Chandler Carruth631abd92011-06-16 06:47:06 +0000911void StmtProfiler::VisitGenericSelectionExpr(const GenericSelectionExpr *S) {
Peter Collingbourne91147592011-04-15 00:35:48 +0000912 VisitExpr(S);
913 for (unsigned i = 0; i != S->getNumAssocs(); ++i) {
914 QualType T = S->getAssocType(i);
915 if (T.isNull())
Craig Topper36250ad2014-05-12 05:36:57 +0000916 ID.AddPointer(nullptr);
Peter Collingbourne91147592011-04-15 00:35:48 +0000917 else
918 VisitType(T);
919 VisitExpr(S->getAssocExpr(i));
920 }
921}
922
John McCallfe96e0b2011-11-06 09:01:30 +0000923void StmtProfiler::VisitPseudoObjectExpr(const PseudoObjectExpr *S) {
924 VisitExpr(S);
925 for (PseudoObjectExpr::const_semantics_iterator
926 i = S->semantics_begin(), e = S->semantics_end(); i != e; ++i)
927 // Normally, we would not profile the source expressions of OVEs.
928 if (const OpaqueValueExpr *OVE = dyn_cast<OpaqueValueExpr>(*i))
929 Visit(OVE->getSourceExpr());
930}
931
Eli Friedmandf14b3a2011-10-11 02:20:01 +0000932void StmtProfiler::VisitAtomicExpr(const AtomicExpr *S) {
933 VisitExpr(S);
Eli Friedman4b72fdd2011-10-14 20:59:01 +0000934 ID.AddInteger(S->getOp());
Eli Friedmandf14b3a2011-10-11 02:20:01 +0000935}
936
Chandler Carruth631abd92011-06-16 06:47:06 +0000937static Stmt::StmtClass DecodeOperatorCall(const CXXOperatorCallExpr *S,
John McCalle3027922010-08-25 11:45:40 +0000938 UnaryOperatorKind &UnaryOp,
939 BinaryOperatorKind &BinaryOp) {
Douglas Gregore9ceb312010-05-19 04:13:23 +0000940 switch (S->getOperator()) {
941 case OO_None:
942 case OO_New:
943 case OO_Delete:
944 case OO_Array_New:
945 case OO_Array_Delete:
946 case OO_Arrow:
947 case OO_Call:
948 case OO_Conditional:
Richard Smith9be594e2015-10-22 05:12:22 +0000949 case OO_Coawait:
Douglas Gregore9ceb312010-05-19 04:13:23 +0000950 case NUM_OVERLOADED_OPERATORS:
951 llvm_unreachable("Invalid operator call kind");
Douglas Gregore9ceb312010-05-19 04:13:23 +0000952
953 case OO_Plus:
954 if (S->getNumArgs() == 1) {
John McCalle3027922010-08-25 11:45:40 +0000955 UnaryOp = UO_Plus;
Douglas Gregore9ceb312010-05-19 04:13:23 +0000956 return Stmt::UnaryOperatorClass;
957 }
958
John McCalle3027922010-08-25 11:45:40 +0000959 BinaryOp = BO_Add;
Douglas Gregore9ceb312010-05-19 04:13:23 +0000960 return Stmt::BinaryOperatorClass;
961
962 case OO_Minus:
963 if (S->getNumArgs() == 1) {
John McCalle3027922010-08-25 11:45:40 +0000964 UnaryOp = UO_Minus;
Douglas Gregore9ceb312010-05-19 04:13:23 +0000965 return Stmt::UnaryOperatorClass;
966 }
967
John McCalle3027922010-08-25 11:45:40 +0000968 BinaryOp = BO_Sub;
Douglas Gregore9ceb312010-05-19 04:13:23 +0000969 return Stmt::BinaryOperatorClass;
970
971 case OO_Star:
972 if (S->getNumArgs() == 1) {
Richard Smithf15acc52014-06-05 22:43:40 +0000973 UnaryOp = UO_Deref;
Douglas Gregore9ceb312010-05-19 04:13:23 +0000974 return Stmt::UnaryOperatorClass;
975 }
976
Richard Smithf15acc52014-06-05 22:43:40 +0000977 BinaryOp = BO_Mul;
Douglas Gregore9ceb312010-05-19 04:13:23 +0000978 return Stmt::BinaryOperatorClass;
979
980 case OO_Slash:
John McCalle3027922010-08-25 11:45:40 +0000981 BinaryOp = BO_Div;
Douglas Gregore9ceb312010-05-19 04:13:23 +0000982 return Stmt::BinaryOperatorClass;
983
984 case OO_Percent:
John McCalle3027922010-08-25 11:45:40 +0000985 BinaryOp = BO_Rem;
Douglas Gregore9ceb312010-05-19 04:13:23 +0000986 return Stmt::BinaryOperatorClass;
987
988 case OO_Caret:
John McCalle3027922010-08-25 11:45:40 +0000989 BinaryOp = BO_Xor;
Douglas Gregore9ceb312010-05-19 04:13:23 +0000990 return Stmt::BinaryOperatorClass;
991
992 case OO_Amp:
993 if (S->getNumArgs() == 1) {
John McCalle3027922010-08-25 11:45:40 +0000994 UnaryOp = UO_AddrOf;
Douglas Gregore9ceb312010-05-19 04:13:23 +0000995 return Stmt::UnaryOperatorClass;
996 }
997
John McCalle3027922010-08-25 11:45:40 +0000998 BinaryOp = BO_And;
Douglas Gregore9ceb312010-05-19 04:13:23 +0000999 return Stmt::BinaryOperatorClass;
1000
1001 case OO_Pipe:
John McCalle3027922010-08-25 11:45:40 +00001002 BinaryOp = BO_Or;
Douglas Gregore9ceb312010-05-19 04:13:23 +00001003 return Stmt::BinaryOperatorClass;
1004
1005 case OO_Tilde:
John McCalle3027922010-08-25 11:45:40 +00001006 UnaryOp = UO_Not;
Douglas Gregore9ceb312010-05-19 04:13:23 +00001007 return Stmt::UnaryOperatorClass;
1008
1009 case OO_Exclaim:
John McCalle3027922010-08-25 11:45:40 +00001010 UnaryOp = UO_LNot;
Douglas Gregore9ceb312010-05-19 04:13:23 +00001011 return Stmt::UnaryOperatorClass;
1012
1013 case OO_Equal:
John McCalle3027922010-08-25 11:45:40 +00001014 BinaryOp = BO_Assign;
Douglas Gregore9ceb312010-05-19 04:13:23 +00001015 return Stmt::BinaryOperatorClass;
1016
1017 case OO_Less:
John McCalle3027922010-08-25 11:45:40 +00001018 BinaryOp = BO_LT;
Douglas Gregore9ceb312010-05-19 04:13:23 +00001019 return Stmt::BinaryOperatorClass;
1020
1021 case OO_Greater:
John McCalle3027922010-08-25 11:45:40 +00001022 BinaryOp = BO_GT;
Douglas Gregore9ceb312010-05-19 04:13:23 +00001023 return Stmt::BinaryOperatorClass;
1024
1025 case OO_PlusEqual:
John McCalle3027922010-08-25 11:45:40 +00001026 BinaryOp = BO_AddAssign;
Douglas Gregore9ceb312010-05-19 04:13:23 +00001027 return Stmt::CompoundAssignOperatorClass;
1028
1029 case OO_MinusEqual:
John McCalle3027922010-08-25 11:45:40 +00001030 BinaryOp = BO_SubAssign;
Douglas Gregore9ceb312010-05-19 04:13:23 +00001031 return Stmt::CompoundAssignOperatorClass;
1032
1033 case OO_StarEqual:
John McCalle3027922010-08-25 11:45:40 +00001034 BinaryOp = BO_MulAssign;
Douglas Gregore9ceb312010-05-19 04:13:23 +00001035 return Stmt::CompoundAssignOperatorClass;
1036
1037 case OO_SlashEqual:
John McCalle3027922010-08-25 11:45:40 +00001038 BinaryOp = BO_DivAssign;
Douglas Gregore9ceb312010-05-19 04:13:23 +00001039 return Stmt::CompoundAssignOperatorClass;
1040
1041 case OO_PercentEqual:
John McCalle3027922010-08-25 11:45:40 +00001042 BinaryOp = BO_RemAssign;
Douglas Gregore9ceb312010-05-19 04:13:23 +00001043 return Stmt::CompoundAssignOperatorClass;
1044
1045 case OO_CaretEqual:
John McCalle3027922010-08-25 11:45:40 +00001046 BinaryOp = BO_XorAssign;
Douglas Gregore9ceb312010-05-19 04:13:23 +00001047 return Stmt::CompoundAssignOperatorClass;
1048
1049 case OO_AmpEqual:
John McCalle3027922010-08-25 11:45:40 +00001050 BinaryOp = BO_AndAssign;
Douglas Gregore9ceb312010-05-19 04:13:23 +00001051 return Stmt::CompoundAssignOperatorClass;
1052
1053 case OO_PipeEqual:
John McCalle3027922010-08-25 11:45:40 +00001054 BinaryOp = BO_OrAssign;
Douglas Gregore9ceb312010-05-19 04:13:23 +00001055 return Stmt::CompoundAssignOperatorClass;
1056
1057 case OO_LessLess:
John McCalle3027922010-08-25 11:45:40 +00001058 BinaryOp = BO_Shl;
Douglas Gregore9ceb312010-05-19 04:13:23 +00001059 return Stmt::BinaryOperatorClass;
1060
1061 case OO_GreaterGreater:
John McCalle3027922010-08-25 11:45:40 +00001062 BinaryOp = BO_Shr;
Douglas Gregore9ceb312010-05-19 04:13:23 +00001063 return Stmt::BinaryOperatorClass;
1064
1065 case OO_LessLessEqual:
John McCalle3027922010-08-25 11:45:40 +00001066 BinaryOp = BO_ShlAssign;
Douglas Gregore9ceb312010-05-19 04:13:23 +00001067 return Stmt::CompoundAssignOperatorClass;
1068
1069 case OO_GreaterGreaterEqual:
John McCalle3027922010-08-25 11:45:40 +00001070 BinaryOp = BO_ShrAssign;
Douglas Gregore9ceb312010-05-19 04:13:23 +00001071 return Stmt::CompoundAssignOperatorClass;
1072
1073 case OO_EqualEqual:
John McCalle3027922010-08-25 11:45:40 +00001074 BinaryOp = BO_EQ;
Douglas Gregore9ceb312010-05-19 04:13:23 +00001075 return Stmt::BinaryOperatorClass;
1076
1077 case OO_ExclaimEqual:
John McCalle3027922010-08-25 11:45:40 +00001078 BinaryOp = BO_NE;
Douglas Gregore9ceb312010-05-19 04:13:23 +00001079 return Stmt::BinaryOperatorClass;
1080
1081 case OO_LessEqual:
John McCalle3027922010-08-25 11:45:40 +00001082 BinaryOp = BO_LE;
Douglas Gregore9ceb312010-05-19 04:13:23 +00001083 return Stmt::BinaryOperatorClass;
1084
1085 case OO_GreaterEqual:
John McCalle3027922010-08-25 11:45:40 +00001086 BinaryOp = BO_GE;
Douglas Gregore9ceb312010-05-19 04:13:23 +00001087 return Stmt::BinaryOperatorClass;
1088
1089 case OO_AmpAmp:
John McCalle3027922010-08-25 11:45:40 +00001090 BinaryOp = BO_LAnd;
Douglas Gregore9ceb312010-05-19 04:13:23 +00001091 return Stmt::BinaryOperatorClass;
1092
1093 case OO_PipePipe:
John McCalle3027922010-08-25 11:45:40 +00001094 BinaryOp = BO_LOr;
Douglas Gregore9ceb312010-05-19 04:13:23 +00001095 return Stmt::BinaryOperatorClass;
1096
1097 case OO_PlusPlus:
John McCalle3027922010-08-25 11:45:40 +00001098 UnaryOp = S->getNumArgs() == 1? UO_PreInc
1099 : UO_PostInc;
Douglas Gregore9ceb312010-05-19 04:13:23 +00001100 return Stmt::UnaryOperatorClass;
1101
1102 case OO_MinusMinus:
John McCalle3027922010-08-25 11:45:40 +00001103 UnaryOp = S->getNumArgs() == 1? UO_PreDec
1104 : UO_PostDec;
Douglas Gregore9ceb312010-05-19 04:13:23 +00001105 return Stmt::UnaryOperatorClass;
1106
1107 case OO_Comma:
John McCalle3027922010-08-25 11:45:40 +00001108 BinaryOp = BO_Comma;
Douglas Gregore9ceb312010-05-19 04:13:23 +00001109 return Stmt::BinaryOperatorClass;
1110
Douglas Gregore9ceb312010-05-19 04:13:23 +00001111 case OO_ArrowStar:
John McCalle3027922010-08-25 11:45:40 +00001112 BinaryOp = BO_PtrMemI;
Douglas Gregore9ceb312010-05-19 04:13:23 +00001113 return Stmt::BinaryOperatorClass;
1114
1115 case OO_Subscript:
1116 return Stmt::ArraySubscriptExprClass;
1117 }
1118
1119 llvm_unreachable("Invalid overloaded operator expression");
1120}
Richard Smithf15acc52014-06-05 22:43:40 +00001121
Chandler Carruth631abd92011-06-16 06:47:06 +00001122void StmtProfiler::VisitCXXOperatorCallExpr(const CXXOperatorCallExpr *S) {
Douglas Gregore9ceb312010-05-19 04:13:23 +00001123 if (S->isTypeDependent()) {
1124 // Type-dependent operator calls are profiled like their underlying
1125 // syntactic operator.
John McCalle3027922010-08-25 11:45:40 +00001126 UnaryOperatorKind UnaryOp = UO_Extension;
1127 BinaryOperatorKind BinaryOp = BO_Comma;
Douglas Gregore9ceb312010-05-19 04:13:23 +00001128 Stmt::StmtClass SC = DecodeOperatorCall(S, UnaryOp, BinaryOp);
Richard Smithf15acc52014-06-05 22:43:40 +00001129
Douglas Gregore9ceb312010-05-19 04:13:23 +00001130 ID.AddInteger(SC);
1131 for (unsigned I = 0, N = S->getNumArgs(); I != N; ++I)
1132 Visit(S->getArg(I));
1133 if (SC == Stmt::UnaryOperatorClass)
1134 ID.AddInteger(UnaryOp);
1135 else if (SC == Stmt::BinaryOperatorClass ||
1136 SC == Stmt::CompoundAssignOperatorClass)
1137 ID.AddInteger(BinaryOp);
1138 else
1139 assert(SC == Stmt::ArraySubscriptExprClass);
Richard Smithf15acc52014-06-05 22:43:40 +00001140
Douglas Gregore9ceb312010-05-19 04:13:23 +00001141 return;
1142 }
Richard Smithf15acc52014-06-05 22:43:40 +00001143
Douglas Gregor5c193b92009-07-28 00:33:38 +00001144 VisitCallExpr(S);
1145 ID.AddInteger(S->getOperator());
1146}
1147
Chandler Carruth631abd92011-06-16 06:47:06 +00001148void StmtProfiler::VisitCXXMemberCallExpr(const CXXMemberCallExpr *S) {
Douglas Gregor5c193b92009-07-28 00:33:38 +00001149 VisitCallExpr(S);
1150}
1151
Chandler Carruth631abd92011-06-16 06:47:06 +00001152void StmtProfiler::VisitCUDAKernelCallExpr(const CUDAKernelCallExpr *S) {
Peter Collingbourne41f85462011-02-09 21:07:24 +00001153 VisitCallExpr(S);
1154}
1155
Chandler Carruth631abd92011-06-16 06:47:06 +00001156void StmtProfiler::VisitAsTypeExpr(const AsTypeExpr *S) {
Tanya Lattner55808c12011-06-04 00:47:47 +00001157 VisitExpr(S);
1158}
1159
Chandler Carruth631abd92011-06-16 06:47:06 +00001160void StmtProfiler::VisitCXXNamedCastExpr(const CXXNamedCastExpr *S) {
Douglas Gregor5c193b92009-07-28 00:33:38 +00001161 VisitExplicitCastExpr(S);
1162}
1163
Chandler Carruth631abd92011-06-16 06:47:06 +00001164void StmtProfiler::VisitCXXStaticCastExpr(const CXXStaticCastExpr *S) {
Douglas Gregor5c193b92009-07-28 00:33:38 +00001165 VisitCXXNamedCastExpr(S);
1166}
1167
Chandler Carruth631abd92011-06-16 06:47:06 +00001168void StmtProfiler::VisitCXXDynamicCastExpr(const CXXDynamicCastExpr *S) {
Douglas Gregor5c193b92009-07-28 00:33:38 +00001169 VisitCXXNamedCastExpr(S);
1170}
1171
Chandler Carruth631abd92011-06-16 06:47:06 +00001172void
1173StmtProfiler::VisitCXXReinterpretCastExpr(const CXXReinterpretCastExpr *S) {
Douglas Gregor5c193b92009-07-28 00:33:38 +00001174 VisitCXXNamedCastExpr(S);
1175}
1176
Chandler Carruth631abd92011-06-16 06:47:06 +00001177void StmtProfiler::VisitCXXConstCastExpr(const CXXConstCastExpr *S) {
Douglas Gregor5c193b92009-07-28 00:33:38 +00001178 VisitCXXNamedCastExpr(S);
1179}
1180
Richard Smithc67fdd42012-03-07 08:35:16 +00001181void StmtProfiler::VisitUserDefinedLiteral(const UserDefinedLiteral *S) {
1182 VisitCallExpr(S);
1183}
1184
Chandler Carruth631abd92011-06-16 06:47:06 +00001185void StmtProfiler::VisitCXXBoolLiteralExpr(const CXXBoolLiteralExpr *S) {
Douglas Gregor5c193b92009-07-28 00:33:38 +00001186 VisitExpr(S);
1187 ID.AddBoolean(S->getValue());
1188}
1189
Chandler Carruth631abd92011-06-16 06:47:06 +00001190void StmtProfiler::VisitCXXNullPtrLiteralExpr(const CXXNullPtrLiteralExpr *S) {
Douglas Gregor00044172009-07-29 16:09:57 +00001191 VisitExpr(S);
1192}
1193
Richard Smithcc1b96d2013-06-12 22:31:48 +00001194void StmtProfiler::VisitCXXStdInitializerListExpr(
1195 const CXXStdInitializerListExpr *S) {
1196 VisitExpr(S);
1197}
1198
Chandler Carruth631abd92011-06-16 06:47:06 +00001199void StmtProfiler::VisitCXXTypeidExpr(const CXXTypeidExpr *S) {
Douglas Gregor5c193b92009-07-28 00:33:38 +00001200 VisitExpr(S);
1201 if (S->isTypeOperand())
David Majnemer143c55e2013-09-27 07:04:31 +00001202 VisitType(S->getTypeOperandSourceInfo()->getType());
Douglas Gregor5c193b92009-07-28 00:33:38 +00001203}
1204
Chandler Carruth631abd92011-06-16 06:47:06 +00001205void StmtProfiler::VisitCXXUuidofExpr(const CXXUuidofExpr *S) {
Francois Pichet9f4f2072010-09-08 12:20:18 +00001206 VisitExpr(S);
1207 if (S->isTypeOperand())
David Majnemer143c55e2013-09-27 07:04:31 +00001208 VisitType(S->getTypeOperandSourceInfo()->getType());
Francois Pichet9f4f2072010-09-08 12:20:18 +00001209}
1210
John McCall5e77d762013-04-16 07:28:30 +00001211void StmtProfiler::VisitMSPropertyRefExpr(const MSPropertyRefExpr *S) {
1212 VisitExpr(S);
1213 VisitDecl(S->getPropertyDecl());
1214}
1215
Alexey Bataevf7630272015-11-25 12:01:00 +00001216void StmtProfiler::VisitMSPropertySubscriptExpr(
1217 const MSPropertySubscriptExpr *S) {
1218 VisitExpr(S);
1219}
1220
Chandler Carruth631abd92011-06-16 06:47:06 +00001221void StmtProfiler::VisitCXXThisExpr(const CXXThisExpr *S) {
Douglas Gregor5c193b92009-07-28 00:33:38 +00001222 VisitExpr(S);
Douglas Gregor3024f072012-04-16 07:05:22 +00001223 ID.AddBoolean(S->isImplicit());
Douglas Gregor5c193b92009-07-28 00:33:38 +00001224}
1225
Chandler Carruth631abd92011-06-16 06:47:06 +00001226void StmtProfiler::VisitCXXThrowExpr(const CXXThrowExpr *S) {
Douglas Gregor5c193b92009-07-28 00:33:38 +00001227 VisitExpr(S);
1228}
1229
Chandler Carruth631abd92011-06-16 06:47:06 +00001230void StmtProfiler::VisitCXXDefaultArgExpr(const CXXDefaultArgExpr *S) {
Douglas Gregor5c193b92009-07-28 00:33:38 +00001231 VisitExpr(S);
1232 VisitDecl(S->getParam());
1233}
1234
Richard Smith852c9db2013-04-20 22:23:05 +00001235void StmtProfiler::VisitCXXDefaultInitExpr(const CXXDefaultInitExpr *S) {
1236 VisitExpr(S);
1237 VisitDecl(S->getField());
1238}
1239
Chandler Carruth631abd92011-06-16 06:47:06 +00001240void StmtProfiler::VisitCXXBindTemporaryExpr(const CXXBindTemporaryExpr *S) {
Douglas Gregor5c193b92009-07-28 00:33:38 +00001241 VisitExpr(S);
1242 VisitDecl(
1243 const_cast<CXXDestructorDecl *>(S->getTemporary()->getDestructor()));
1244}
1245
Chandler Carruth631abd92011-06-16 06:47:06 +00001246void StmtProfiler::VisitCXXConstructExpr(const CXXConstructExpr *S) {
Douglas Gregor5c193b92009-07-28 00:33:38 +00001247 VisitExpr(S);
1248 VisitDecl(S->getConstructor());
1249 ID.AddBoolean(S->isElidable());
1250}
1251
Chandler Carruth631abd92011-06-16 06:47:06 +00001252void StmtProfiler::VisitCXXFunctionalCastExpr(const CXXFunctionalCastExpr *S) {
Douglas Gregor5c193b92009-07-28 00:33:38 +00001253 VisitExplicitCastExpr(S);
1254}
1255
Chandler Carruth631abd92011-06-16 06:47:06 +00001256void
1257StmtProfiler::VisitCXXTemporaryObjectExpr(const CXXTemporaryObjectExpr *S) {
Douglas Gregor5c193b92009-07-28 00:33:38 +00001258 VisitCXXConstructExpr(S);
1259}
1260
Chandler Carruth631abd92011-06-16 06:47:06 +00001261void
Douglas Gregore31e6062012-02-07 10:09:13 +00001262StmtProfiler::VisitLambdaExpr(const LambdaExpr *S) {
1263 VisitExpr(S);
1264 for (LambdaExpr::capture_iterator C = S->explicit_capture_begin(),
1265 CEnd = S->explicit_capture_end();
1266 C != CEnd; ++C) {
1267 ID.AddInteger(C->getCaptureKind());
Richard Smithba71c082013-05-16 06:20:58 +00001268 switch (C->getCaptureKind()) {
Faisal Validc6b5962016-03-21 09:25:37 +00001269 case LCK_StarThis:
Richard Smithba71c082013-05-16 06:20:58 +00001270 case LCK_This:
1271 break;
1272 case LCK_ByRef:
1273 case LCK_ByCopy:
Douglas Gregore31e6062012-02-07 10:09:13 +00001274 VisitDecl(C->getCapturedVar());
1275 ID.AddBoolean(C->isPackExpansion());
Richard Smithba71c082013-05-16 06:20:58 +00001276 break;
Alexey Bataev39c81e22014-08-28 04:28:19 +00001277 case LCK_VLAType:
1278 llvm_unreachable("VLA type in explicit captures.");
Douglas Gregore31e6062012-02-07 10:09:13 +00001279 }
1280 }
1281 // Note: If we actually needed to be able to match lambda
1282 // expressions, we would have to consider parameters and return type
1283 // here, among other things.
1284 VisitStmt(S->getBody());
1285}
1286
1287void
Chandler Carruth631abd92011-06-16 06:47:06 +00001288StmtProfiler::VisitCXXScalarValueInitExpr(const CXXScalarValueInitExpr *S) {
Douglas Gregor5c193b92009-07-28 00:33:38 +00001289 VisitExpr(S);
1290}
1291
Chandler Carruth631abd92011-06-16 06:47:06 +00001292void StmtProfiler::VisitCXXDeleteExpr(const CXXDeleteExpr *S) {
Douglas Gregor5c193b92009-07-28 00:33:38 +00001293 VisitExpr(S);
1294 ID.AddBoolean(S->isGlobalDelete());
1295 ID.AddBoolean(S->isArrayForm());
1296 VisitDecl(S->getOperatorDelete());
1297}
1298
Chandler Carruth631abd92011-06-16 06:47:06 +00001299void StmtProfiler::VisitCXXNewExpr(const CXXNewExpr *S) {
Douglas Gregor5c193b92009-07-28 00:33:38 +00001300 VisitExpr(S);
1301 VisitType(S->getAllocatedType());
1302 VisitDecl(S->getOperatorNew());
1303 VisitDecl(S->getOperatorDelete());
Douglas Gregor5c193b92009-07-28 00:33:38 +00001304 ID.AddBoolean(S->isArray());
1305 ID.AddInteger(S->getNumPlacementArgs());
1306 ID.AddBoolean(S->isGlobalNew());
1307 ID.AddBoolean(S->isParenTypeId());
Sebastian Redl6047f072012-02-16 12:22:20 +00001308 ID.AddInteger(S->getInitializationStyle());
Douglas Gregor5c193b92009-07-28 00:33:38 +00001309}
1310
Chandler Carruth631abd92011-06-16 06:47:06 +00001311void
1312StmtProfiler::VisitCXXPseudoDestructorExpr(const CXXPseudoDestructorExpr *S) {
Douglas Gregorad8a3362009-09-04 17:36:40 +00001313 VisitExpr(S);
1314 ID.AddBoolean(S->isArrow());
1315 VisitNestedNameSpecifier(S->getQualifier());
Craig Topper36250ad2014-05-12 05:36:57 +00001316 ID.AddBoolean(S->getScopeTypeInfo() != nullptr);
Eli Friedman85641392013-08-09 23:37:05 +00001317 if (S->getScopeTypeInfo())
1318 VisitType(S->getScopeTypeInfo()->getType());
Craig Topper36250ad2014-05-12 05:36:57 +00001319 ID.AddBoolean(S->getDestroyedTypeInfo() != nullptr);
Eli Friedman85641392013-08-09 23:37:05 +00001320 if (S->getDestroyedTypeInfo())
1321 VisitType(S->getDestroyedType());
1322 else
1323 ID.AddPointer(S->getDestroyedTypeIdentifier());
Douglas Gregorad8a3362009-09-04 17:36:40 +00001324}
1325
Chandler Carruth631abd92011-06-16 06:47:06 +00001326void StmtProfiler::VisitOverloadExpr(const OverloadExpr *S) {
Argyrios Kyrtzidisb482eb82010-08-15 20:53:20 +00001327 VisitExpr(S);
John McCalle66edc12009-11-24 19:00:30 +00001328 VisitNestedNameSpecifier(S->getQualifier());
Douglas Gregor5c193b92009-07-28 00:33:38 +00001329 VisitName(S->getName());
John McCalle66edc12009-11-24 19:00:30 +00001330 ID.AddBoolean(S->hasExplicitTemplateArgs());
1331 if (S->hasExplicitTemplateArgs())
James Y Knight04ec5bf2015-12-24 02:59:37 +00001332 VisitTemplateArguments(S->getTemplateArgs(), S->getNumTemplateArgs());
Argyrios Kyrtzidisf4505452010-08-15 01:15:38 +00001333}
1334
1335void
Chandler Carruth631abd92011-06-16 06:47:06 +00001336StmtProfiler::VisitUnresolvedLookupExpr(const UnresolvedLookupExpr *S) {
Argyrios Kyrtzidisf4505452010-08-15 01:15:38 +00001337 VisitOverloadExpr(S);
Douglas Gregor5c193b92009-07-28 00:33:38 +00001338}
1339
Douglas Gregor29c42f22012-02-24 07:38:34 +00001340void StmtProfiler::VisitTypeTraitExpr(const TypeTraitExpr *S) {
1341 VisitExpr(S);
1342 ID.AddInteger(S->getTrait());
1343 ID.AddInteger(S->getNumArgs());
1344 for (unsigned I = 0, N = S->getNumArgs(); I != N; ++I)
1345 VisitType(S->getArg(I)->getType());
1346}
1347
Chandler Carruth631abd92011-06-16 06:47:06 +00001348void StmtProfiler::VisitArrayTypeTraitExpr(const ArrayTypeTraitExpr *S) {
John Wiegley6242b6a2011-04-28 00:16:57 +00001349 VisitExpr(S);
1350 ID.AddInteger(S->getTrait());
1351 VisitType(S->getQueriedType());
1352}
1353
Chandler Carruth631abd92011-06-16 06:47:06 +00001354void StmtProfiler::VisitExpressionTraitExpr(const ExpressionTraitExpr *S) {
John Wiegleyf9f65842011-04-25 06:54:41 +00001355 VisitExpr(S);
1356 ID.AddInteger(S->getTrait());
1357 VisitExpr(S->getQueriedExpression());
1358}
1359
Chandler Carruth631abd92011-06-16 06:47:06 +00001360void StmtProfiler::VisitDependentScopeDeclRefExpr(
1361 const DependentScopeDeclRefExpr *S) {
Douglas Gregor5c193b92009-07-28 00:33:38 +00001362 VisitExpr(S);
1363 VisitName(S->getDeclName());
1364 VisitNestedNameSpecifier(S->getQualifier());
John McCalle66edc12009-11-24 19:00:30 +00001365 ID.AddBoolean(S->hasExplicitTemplateArgs());
1366 if (S->hasExplicitTemplateArgs())
1367 VisitTemplateArguments(S->getTemplateArgs(), S->getNumTemplateArgs());
Douglas Gregor5c193b92009-07-28 00:33:38 +00001368}
1369
Chandler Carruth631abd92011-06-16 06:47:06 +00001370void StmtProfiler::VisitExprWithCleanups(const ExprWithCleanups *S) {
Douglas Gregora7095092009-07-28 14:44:31 +00001371 VisitExpr(S);
Douglas Gregora7095092009-07-28 14:44:31 +00001372}
1373
Chandler Carruth631abd92011-06-16 06:47:06 +00001374void StmtProfiler::VisitCXXUnresolvedConstructExpr(
1375 const CXXUnresolvedConstructExpr *S) {
Douglas Gregora7095092009-07-28 14:44:31 +00001376 VisitExpr(S);
1377 VisitType(S->getTypeAsWritten());
1378}
1379
Chandler Carruth631abd92011-06-16 06:47:06 +00001380void StmtProfiler::VisitCXXDependentScopeMemberExpr(
1381 const CXXDependentScopeMemberExpr *S) {
John McCall2d74de92009-12-01 22:10:20 +00001382 ID.AddBoolean(S->isImplicitAccess());
1383 if (!S->isImplicitAccess()) {
1384 VisitExpr(S);
1385 ID.AddBoolean(S->isArrow());
1386 }
Douglas Gregorc26e0f62009-09-03 16:14:30 +00001387 VisitNestedNameSpecifier(S->getQualifier());
Douglas Gregora7095092009-07-28 14:44:31 +00001388 VisitName(S->getMember());
John McCall2d74de92009-12-01 22:10:20 +00001389 ID.AddBoolean(S->hasExplicitTemplateArgs());
1390 if (S->hasExplicitTemplateArgs())
John McCall10eae182009-11-30 22:42:35 +00001391 VisitTemplateArguments(S->getTemplateArgs(), S->getNumTemplateArgs());
1392}
1393
Chandler Carruth631abd92011-06-16 06:47:06 +00001394void StmtProfiler::VisitUnresolvedMemberExpr(const UnresolvedMemberExpr *S) {
John McCall2d74de92009-12-01 22:10:20 +00001395 ID.AddBoolean(S->isImplicitAccess());
1396 if (!S->isImplicitAccess()) {
1397 VisitExpr(S);
1398 ID.AddBoolean(S->isArrow());
1399 }
John McCall10eae182009-11-30 22:42:35 +00001400 VisitNestedNameSpecifier(S->getQualifier());
1401 VisitName(S->getMemberName());
1402 ID.AddBoolean(S->hasExplicitTemplateArgs());
1403 if (S->hasExplicitTemplateArgs())
1404 VisitTemplateArguments(S->getTemplateArgs(), S->getNumTemplateArgs());
Douglas Gregora7095092009-07-28 14:44:31 +00001405}
1406
Chandler Carruth631abd92011-06-16 06:47:06 +00001407void StmtProfiler::VisitCXXNoexceptExpr(const CXXNoexceptExpr *S) {
Sebastian Redl4202c0f2010-09-10 20:55:43 +00001408 VisitExpr(S);
1409}
1410
Chandler Carruth631abd92011-06-16 06:47:06 +00001411void StmtProfiler::VisitPackExpansionExpr(const PackExpansionExpr *S) {
Douglas Gregore8e9dd62011-01-03 17:17:50 +00001412 VisitExpr(S);
1413}
1414
Chandler Carruth631abd92011-06-16 06:47:06 +00001415void StmtProfiler::VisitSizeOfPackExpr(const SizeOfPackExpr *S) {
Douglas Gregor820ba7b2011-01-04 17:33:58 +00001416 VisitExpr(S);
1417 VisitDecl(S->getPack());
Richard Smithd784e682015-09-23 21:41:42 +00001418 if (S->isPartiallySubstituted()) {
1419 auto Args = S->getPartialArguments();
1420 ID.AddInteger(Args.size());
1421 for (const auto &TA : Args)
1422 VisitTemplateArgument(TA);
1423 } else {
1424 ID.AddInteger(0);
1425 }
Douglas Gregor820ba7b2011-01-04 17:33:58 +00001426}
1427
Douglas Gregorcdbc5392011-01-15 01:15:58 +00001428void StmtProfiler::VisitSubstNonTypeTemplateParmPackExpr(
Chandler Carruth631abd92011-06-16 06:47:06 +00001429 const SubstNonTypeTemplateParmPackExpr *S) {
Douglas Gregorcdbc5392011-01-15 01:15:58 +00001430 VisitExpr(S);
1431 VisitDecl(S->getParameterPack());
1432 VisitTemplateArgument(S->getArgumentPack());
1433}
1434
John McCall7c454bb2011-07-15 05:09:51 +00001435void StmtProfiler::VisitSubstNonTypeTemplateParmExpr(
1436 const SubstNonTypeTemplateParmExpr *E) {
1437 // Profile exactly as the replacement expression.
1438 Visit(E->getReplacement());
1439}
1440
Richard Smithb15fe3a2012-09-12 00:56:43 +00001441void StmtProfiler::VisitFunctionParmPackExpr(const FunctionParmPackExpr *S) {
1442 VisitExpr(S);
1443 VisitDecl(S->getParameterPack());
1444 ID.AddInteger(S->getNumExpansions());
1445 for (FunctionParmPackExpr::iterator I = S->begin(), E = S->end(); I != E; ++I)
1446 VisitDecl(*I);
1447}
1448
Douglas Gregorfe314812011-06-21 17:03:29 +00001449void StmtProfiler::VisitMaterializeTemporaryExpr(
1450 const MaterializeTemporaryExpr *S) {
1451 VisitExpr(S);
1452}
1453
Richard Smith0f0af192014-11-08 05:07:16 +00001454void StmtProfiler::VisitCXXFoldExpr(const CXXFoldExpr *S) {
1455 VisitExpr(S);
1456 ID.AddInteger(S->getOperator());
1457}
1458
Richard Smith9f690bd2015-10-27 06:02:45 +00001459void StmtProfiler::VisitCoroutineBodyStmt(const CoroutineBodyStmt *S) {
1460 VisitStmt(S);
1461}
1462
1463void StmtProfiler::VisitCoreturnStmt(const CoreturnStmt *S) {
1464 VisitStmt(S);
1465}
1466
1467void StmtProfiler::VisitCoawaitExpr(const CoawaitExpr *S) {
1468 VisitExpr(S);
1469}
1470
1471void StmtProfiler::VisitCoyieldExpr(const CoyieldExpr *S) {
1472 VisitExpr(S);
1473}
1474
Chandler Carruth631abd92011-06-16 06:47:06 +00001475void StmtProfiler::VisitOpaqueValueExpr(const OpaqueValueExpr *E) {
John McCall8d69a212010-11-15 23:31:06 +00001476 VisitExpr(E);
1477}
1478
Kaelyn Takatae1f49d52014-10-27 18:07:20 +00001479void StmtProfiler::VisitTypoExpr(const TypoExpr *E) {
1480 VisitExpr(E);
1481}
1482
Chandler Carruth631abd92011-06-16 06:47:06 +00001483void StmtProfiler::VisitObjCStringLiteral(const ObjCStringLiteral *S) {
Douglas Gregora7095092009-07-28 14:44:31 +00001484 VisitExpr(S);
1485}
1486
Patrick Beard0caa3942012-04-19 00:25:12 +00001487void StmtProfiler::VisitObjCBoxedExpr(const ObjCBoxedExpr *E) {
Ted Kremeneke65b0862012-03-06 20:05:56 +00001488 VisitExpr(E);
1489}
1490
1491void StmtProfiler::VisitObjCArrayLiteral(const ObjCArrayLiteral *E) {
1492 VisitExpr(E);
1493}
1494
1495void StmtProfiler::VisitObjCDictionaryLiteral(const ObjCDictionaryLiteral *E) {
1496 VisitExpr(E);
1497}
1498
Chandler Carruth631abd92011-06-16 06:47:06 +00001499void StmtProfiler::VisitObjCEncodeExpr(const ObjCEncodeExpr *S) {
Douglas Gregora7095092009-07-28 14:44:31 +00001500 VisitExpr(S);
1501 VisitType(S->getEncodedType());
1502}
1503
Chandler Carruth631abd92011-06-16 06:47:06 +00001504void StmtProfiler::VisitObjCSelectorExpr(const ObjCSelectorExpr *S) {
Douglas Gregora7095092009-07-28 14:44:31 +00001505 VisitExpr(S);
1506 VisitName(S->getSelector());
1507}
1508
Chandler Carruth631abd92011-06-16 06:47:06 +00001509void StmtProfiler::VisitObjCProtocolExpr(const ObjCProtocolExpr *S) {
Douglas Gregora7095092009-07-28 14:44:31 +00001510 VisitExpr(S);
1511 VisitDecl(S->getProtocol());
1512}
1513
Chandler Carruth631abd92011-06-16 06:47:06 +00001514void StmtProfiler::VisitObjCIvarRefExpr(const ObjCIvarRefExpr *S) {
Douglas Gregora7095092009-07-28 14:44:31 +00001515 VisitExpr(S);
1516 VisitDecl(S->getDecl());
1517 ID.AddBoolean(S->isArrow());
1518 ID.AddBoolean(S->isFreeIvar());
1519}
1520
Chandler Carruth631abd92011-06-16 06:47:06 +00001521void StmtProfiler::VisitObjCPropertyRefExpr(const ObjCPropertyRefExpr *S) {
Douglas Gregora7095092009-07-28 14:44:31 +00001522 VisitExpr(S);
John McCallb7bd14f2010-12-02 01:19:52 +00001523 if (S->isImplicitProperty()) {
1524 VisitDecl(S->getImplicitPropertyGetter());
1525 VisitDecl(S->getImplicitPropertySetter());
1526 } else {
1527 VisitDecl(S->getExplicitProperty());
Fariborz Jahanian681c0752010-10-14 16:04:05 +00001528 }
Fariborz Jahanian681c0752010-10-14 16:04:05 +00001529 if (S->isSuperReceiver()) {
1530 ID.AddBoolean(S->isSuperReceiver());
John McCallb7bd14f2010-12-02 01:19:52 +00001531 VisitType(S->getSuperReceiverType());
Fariborz Jahanian681c0752010-10-14 16:04:05 +00001532 }
Douglas Gregora7095092009-07-28 14:44:31 +00001533}
1534
Ted Kremeneke65b0862012-03-06 20:05:56 +00001535void StmtProfiler::VisitObjCSubscriptRefExpr(const ObjCSubscriptRefExpr *S) {
1536 VisitExpr(S);
1537 VisitDecl(S->getAtIndexMethodDecl());
1538 VisitDecl(S->setAtIndexMethodDecl());
1539}
1540
Chandler Carruth631abd92011-06-16 06:47:06 +00001541void StmtProfiler::VisitObjCMessageExpr(const ObjCMessageExpr *S) {
Douglas Gregora7095092009-07-28 14:44:31 +00001542 VisitExpr(S);
1543 VisitName(S->getSelector());
1544 VisitDecl(S->getMethodDecl());
1545}
1546
Chandler Carruth631abd92011-06-16 06:47:06 +00001547void StmtProfiler::VisitObjCIsaExpr(const ObjCIsaExpr *S) {
Douglas Gregora7095092009-07-28 14:44:31 +00001548 VisitExpr(S);
1549 ID.AddBoolean(S->isArrow());
1550}
1551
Ted Kremeneke65b0862012-03-06 20:05:56 +00001552void StmtProfiler::VisitObjCBoolLiteralExpr(const ObjCBoolLiteralExpr *S) {
1553 VisitExpr(S);
1554 ID.AddBoolean(S->getValue());
1555}
1556
Chandler Carruth631abd92011-06-16 06:47:06 +00001557void StmtProfiler::VisitObjCIndirectCopyRestoreExpr(
1558 const ObjCIndirectCopyRestoreExpr *S) {
John McCall31168b02011-06-15 23:02:42 +00001559 VisitExpr(S);
1560 ID.AddBoolean(S->shouldCopy());
1561}
1562
Chandler Carruth631abd92011-06-16 06:47:06 +00001563void StmtProfiler::VisitObjCBridgedCastExpr(const ObjCBridgedCastExpr *S) {
John McCall31168b02011-06-15 23:02:42 +00001564 VisitExplicitCastExpr(S);
1565 ID.AddBoolean(S->getBridgeKind());
1566}
1567
Chandler Carruth631abd92011-06-16 06:47:06 +00001568void StmtProfiler::VisitDecl(const Decl *D) {
Douglas Gregor70317122009-07-31 15:45:02 +00001569 ID.AddInteger(D? D->getKind() : 0);
Mike Stump11289f42009-09-09 15:08:12 +00001570
Douglas Gregora5dd9f82009-07-30 23:18:24 +00001571 if (Canonical && D) {
Chandler Carruth631abd92011-06-16 06:47:06 +00001572 if (const NonTypeTemplateParmDecl *NTTP =
1573 dyn_cast<NonTypeTemplateParmDecl>(D)) {
Douglas Gregord9aedfa2009-07-28 15:32:17 +00001574 ID.AddInteger(NTTP->getDepth());
1575 ID.AddInteger(NTTP->getIndex());
Douglas Gregorf5500772011-01-05 15:48:55 +00001576 ID.AddBoolean(NTTP->isParameterPack());
Douglas Gregor00044172009-07-29 16:09:57 +00001577 VisitType(NTTP->getType());
Douglas Gregor5c193b92009-07-28 00:33:38 +00001578 return;
1579 }
Mike Stump11289f42009-09-09 15:08:12 +00001580
Chandler Carruth631abd92011-06-16 06:47:06 +00001581 if (const ParmVarDecl *Parm = dyn_cast<ParmVarDecl>(D)) {
John McCall8fb0d9d2011-05-01 22:35:37 +00001582 // The Itanium C++ ABI uses the type, scope depth, and scope
1583 // index of a parameter when mangling expressions that involve
1584 // function parameters, so we will use the parameter's type for
1585 // establishing function parameter identity. That way, our
1586 // definition of "equivalent" (per C++ [temp.over.link]) is at
1587 // least as strong as the definition of "equivalent" used for
1588 // name mangling.
Douglas Gregor70317122009-07-31 15:45:02 +00001589 VisitType(Parm->getType());
John McCall8fb0d9d2011-05-01 22:35:37 +00001590 ID.AddInteger(Parm->getFunctionScopeDepth());
1591 ID.AddInteger(Parm->getFunctionScopeIndex());
Douglas Gregor70317122009-07-31 15:45:02 +00001592 return;
1593 }
Mike Stump11289f42009-09-09 15:08:12 +00001594
Richard Smithd9a1cd82012-04-02 18:53:24 +00001595 if (const TemplateTypeParmDecl *TTP =
1596 dyn_cast<TemplateTypeParmDecl>(D)) {
1597 ID.AddInteger(TTP->getDepth());
1598 ID.AddInteger(TTP->getIndex());
1599 ID.AddBoolean(TTP->isParameterPack());
1600 return;
1601 }
1602
Chandler Carruth631abd92011-06-16 06:47:06 +00001603 if (const TemplateTemplateParmDecl *TTP =
1604 dyn_cast<TemplateTemplateParmDecl>(D)) {
Douglas Gregorc97f09f2009-07-31 15:46:56 +00001605 ID.AddInteger(TTP->getDepth());
1606 ID.AddInteger(TTP->getIndex());
Douglas Gregorf5500772011-01-05 15:48:55 +00001607 ID.AddBoolean(TTP->isParameterPack());
Douglas Gregorc97f09f2009-07-31 15:46:56 +00001608 return;
1609 }
Douglas Gregor5c193b92009-07-28 00:33:38 +00001610 }
Mike Stump11289f42009-09-09 15:08:12 +00001611
Craig Topper36250ad2014-05-12 05:36:57 +00001612 ID.AddPointer(D? D->getCanonicalDecl() : nullptr);
Douglas Gregord9aedfa2009-07-28 15:32:17 +00001613}
1614
1615void StmtProfiler::VisitType(QualType T) {
1616 if (Canonical)
1617 T = Context.getCanonicalType(T);
Mike Stump11289f42009-09-09 15:08:12 +00001618
Douglas Gregor5c193b92009-07-28 00:33:38 +00001619 ID.AddPointer(T.getAsOpaquePtr());
1620}
1621
1622void StmtProfiler::VisitName(DeclarationName Name) {
1623 ID.AddPointer(Name.getAsOpaquePtr());
1624}
1625
1626void StmtProfiler::VisitNestedNameSpecifier(NestedNameSpecifier *NNS) {
1627 if (Canonical)
1628 NNS = Context.getCanonicalNestedNameSpecifier(NNS);
1629 ID.AddPointer(NNS);
1630}
1631
1632void StmtProfiler::VisitTemplateName(TemplateName Name) {
1633 if (Canonical)
1634 Name = Context.getCanonicalTemplateName(Name);
Mike Stump11289f42009-09-09 15:08:12 +00001635
Douglas Gregor5c193b92009-07-28 00:33:38 +00001636 Name.Profile(ID);
1637}
1638
John McCall0ad16662009-10-29 08:12:44 +00001639void StmtProfiler::VisitTemplateArguments(const TemplateArgumentLoc *Args,
Douglas Gregor5c193b92009-07-28 00:33:38 +00001640 unsigned NumArgs) {
1641 ID.AddInteger(NumArgs);
John McCall0ad16662009-10-29 08:12:44 +00001642 for (unsigned I = 0; I != NumArgs; ++I)
1643 VisitTemplateArgument(Args[I].getArgument());
1644}
Mike Stump11289f42009-09-09 15:08:12 +00001645
John McCall0ad16662009-10-29 08:12:44 +00001646void StmtProfiler::VisitTemplateArgument(const TemplateArgument &Arg) {
1647 // Mostly repetitive with TemplateArgument::Profile!
1648 ID.AddInteger(Arg.getKind());
1649 switch (Arg.getKind()) {
1650 case TemplateArgument::Null:
1651 break;
Mike Stump11289f42009-09-09 15:08:12 +00001652
John McCall0ad16662009-10-29 08:12:44 +00001653 case TemplateArgument::Type:
1654 VisitType(Arg.getAsType());
1655 break;
Mike Stump11289f42009-09-09 15:08:12 +00001656
Douglas Gregor9167f8b2009-11-11 01:00:40 +00001657 case TemplateArgument::Template:
Douglas Gregore4ff4b52011-01-05 18:58:31 +00001658 case TemplateArgument::TemplateExpansion:
1659 VisitTemplateName(Arg.getAsTemplateOrTemplatePattern());
Douglas Gregor9167f8b2009-11-11 01:00:40 +00001660 break;
Alexis Hunta8136cc2010-05-05 15:23:54 +00001661
John McCall0ad16662009-10-29 08:12:44 +00001662 case TemplateArgument::Declaration:
1663 VisitDecl(Arg.getAsDecl());
1664 break;
Mike Stump11289f42009-09-09 15:08:12 +00001665
Eli Friedmanb826a002012-09-26 02:36:12 +00001666 case TemplateArgument::NullPtr:
1667 VisitType(Arg.getNullPtrType());
1668 break;
1669
John McCall0ad16662009-10-29 08:12:44 +00001670 case TemplateArgument::Integral:
Benjamin Kramer6003ad52012-06-07 15:09:51 +00001671 Arg.getAsIntegral().Profile(ID);
John McCall0ad16662009-10-29 08:12:44 +00001672 VisitType(Arg.getIntegralType());
1673 break;
Mike Stump11289f42009-09-09 15:08:12 +00001674
John McCall0ad16662009-10-29 08:12:44 +00001675 case TemplateArgument::Expression:
1676 Visit(Arg.getAsExpr());
1677 break;
Mike Stump11289f42009-09-09 15:08:12 +00001678
John McCall0ad16662009-10-29 08:12:44 +00001679 case TemplateArgument::Pack:
Aaron Ballman2a89e852014-07-15 21:32:31 +00001680 for (const auto &P : Arg.pack_elements())
1681 VisitTemplateArgument(P);
John McCall0ad16662009-10-29 08:12:44 +00001682 break;
Douglas Gregor5c193b92009-07-28 00:33:38 +00001683 }
1684}
1685
Jay Foad39c79802011-01-12 09:06:06 +00001686void Stmt::Profile(llvm::FoldingSetNodeID &ID, const ASTContext &Context,
Chandler Carruth631abd92011-06-16 06:47:06 +00001687 bool Canonical) const {
Douglas Gregor5c193b92009-07-28 00:33:38 +00001688 StmtProfiler Profiler(ID, Context, Canonical);
1689 Profiler.Visit(this);
1690}