blob: 2f3653f32d36b80a61851f5be8b491b90231099e [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) {
Richard Trieu6a77a1c2016-06-10 04:52:09 +000072 assert(S && "Requires non-null Stmt pointer");
Douglas Gregor5c193b92009-07-28 00:33:38 +000073 ID.AddInteger(S->getStmtClass());
Benjamin Kramer642f1732015-07-02 21:03:14 +000074 for (const Stmt *SubStmt : S->children()) {
75 if (SubStmt)
76 Visit(SubStmt);
Peter Collingbournecdb9f302012-03-01 16:34:31 +000077 else
78 ID.AddInteger(0);
79 }
Douglas Gregor5c193b92009-07-28 00:33:38 +000080}
81
Chandler Carruth631abd92011-06-16 06:47:06 +000082void StmtProfiler::VisitDeclStmt(const DeclStmt *S) {
Douglas Gregor44882592009-07-28 15:27:13 +000083 VisitStmt(S);
Aaron Ballman535bbcc2014-03-14 17:01:24 +000084 for (const auto *D : S->decls())
85 VisitDecl(D);
Douglas Gregor44882592009-07-28 15:27:13 +000086}
87
Chandler Carruth631abd92011-06-16 06:47:06 +000088void StmtProfiler::VisitNullStmt(const NullStmt *S) {
Douglas Gregor44882592009-07-28 15:27:13 +000089 VisitStmt(S);
90}
91
Chandler Carruth631abd92011-06-16 06:47:06 +000092void StmtProfiler::VisitCompoundStmt(const CompoundStmt *S) {
Douglas Gregor44882592009-07-28 15:27:13 +000093 VisitStmt(S);
94}
95
Chandler Carruth631abd92011-06-16 06:47:06 +000096void StmtProfiler::VisitCaseStmt(const CaseStmt *S) {
Douglas Gregor44882592009-07-28 15:27:13 +000097 VisitStmt(S);
98}
99
Chandler Carruth631abd92011-06-16 06:47:06 +0000100void StmtProfiler::VisitDefaultStmt(const DefaultStmt *S) {
Douglas Gregor44882592009-07-28 15:27:13 +0000101 VisitStmt(S);
102}
103
Chandler Carruth631abd92011-06-16 06:47:06 +0000104void StmtProfiler::VisitLabelStmt(const LabelStmt *S) {
Douglas Gregor44882592009-07-28 15:27:13 +0000105 VisitStmt(S);
Chris Lattnerc8e630e2011-02-17 07:39:24 +0000106 VisitDecl(S->getDecl());
Douglas Gregor44882592009-07-28 15:27:13 +0000107}
108
Richard Smithc202b282012-04-14 00:33:13 +0000109void StmtProfiler::VisitAttributedStmt(const AttributedStmt *S) {
110 VisitStmt(S);
111 // TODO: maybe visit attributes?
112}
113
Chandler Carruth631abd92011-06-16 06:47:06 +0000114void StmtProfiler::VisitIfStmt(const IfStmt *S) {
Douglas Gregor44882592009-07-28 15:27:13 +0000115 VisitStmt(S);
Douglas Gregor7bab5ff2009-11-25 00:27:52 +0000116 VisitDecl(S->getConditionVariable());
Douglas Gregor44882592009-07-28 15:27:13 +0000117}
118
Chandler Carruth631abd92011-06-16 06:47:06 +0000119void StmtProfiler::VisitSwitchStmt(const SwitchStmt *S) {
Douglas Gregor00044172009-07-29 16:09:57 +0000120 VisitStmt(S);
Douglas Gregor7bab5ff2009-11-25 00:27:52 +0000121 VisitDecl(S->getConditionVariable());
Douglas Gregor00044172009-07-29 16:09:57 +0000122}
123
Chandler Carruth631abd92011-06-16 06:47:06 +0000124void StmtProfiler::VisitWhileStmt(const WhileStmt *S) {
Douglas Gregor44882592009-07-28 15:27:13 +0000125 VisitStmt(S);
Douglas Gregor7bab5ff2009-11-25 00:27:52 +0000126 VisitDecl(S->getConditionVariable());
Douglas Gregor44882592009-07-28 15:27:13 +0000127}
128
Chandler Carruth631abd92011-06-16 06:47:06 +0000129void StmtProfiler::VisitDoStmt(const DoStmt *S) {
Douglas Gregor44882592009-07-28 15:27:13 +0000130 VisitStmt(S);
131}
132
Chandler Carruth631abd92011-06-16 06:47:06 +0000133void StmtProfiler::VisitForStmt(const ForStmt *S) {
Douglas Gregor44882592009-07-28 15:27:13 +0000134 VisitStmt(S);
135}
136
Chandler Carruth631abd92011-06-16 06:47:06 +0000137void StmtProfiler::VisitGotoStmt(const GotoStmt *S) {
Douglas Gregor44882592009-07-28 15:27:13 +0000138 VisitStmt(S);
Chris Lattnerc8e630e2011-02-17 07:39:24 +0000139 VisitDecl(S->getLabel());
Douglas Gregor44882592009-07-28 15:27:13 +0000140}
141
Chandler Carruth631abd92011-06-16 06:47:06 +0000142void StmtProfiler::VisitIndirectGotoStmt(const IndirectGotoStmt *S) {
Douglas Gregor44882592009-07-28 15:27:13 +0000143 VisitStmt(S);
144}
145
Chandler Carruth631abd92011-06-16 06:47:06 +0000146void StmtProfiler::VisitContinueStmt(const ContinueStmt *S) {
Douglas Gregor44882592009-07-28 15:27:13 +0000147 VisitStmt(S);
148}
149
Chandler Carruth631abd92011-06-16 06:47:06 +0000150void StmtProfiler::VisitBreakStmt(const BreakStmt *S) {
Douglas Gregor44882592009-07-28 15:27:13 +0000151 VisitStmt(S);
152}
153
Chandler Carruth631abd92011-06-16 06:47:06 +0000154void StmtProfiler::VisitReturnStmt(const ReturnStmt *S) {
Douglas Gregor44882592009-07-28 15:27:13 +0000155 VisitStmt(S);
156}
157
Chad Rosierde70e0e2012-08-25 00:11:56 +0000158void StmtProfiler::VisitGCCAsmStmt(const GCCAsmStmt *S) {
Douglas Gregor44882592009-07-28 15:27:13 +0000159 VisitStmt(S);
160 ID.AddBoolean(S->isVolatile());
161 ID.AddBoolean(S->isSimple());
162 VisitStringLiteral(S->getAsmString());
163 ID.AddInteger(S->getNumOutputs());
164 for (unsigned I = 0, N = S->getNumOutputs(); I != N; ++I) {
165 ID.AddString(S->getOutputName(I));
166 VisitStringLiteral(S->getOutputConstraintLiteral(I));
167 }
168 ID.AddInteger(S->getNumInputs());
169 for (unsigned I = 0, N = S->getNumInputs(); I != N; ++I) {
170 ID.AddString(S->getInputName(I));
171 VisitStringLiteral(S->getInputConstraintLiteral(I));
172 }
173 ID.AddInteger(S->getNumClobbers());
174 for (unsigned I = 0, N = S->getNumClobbers(); I != N; ++I)
Chad Rosierd9fb09a2012-08-27 23:28:41 +0000175 VisitStringLiteral(S->getClobberStringLiteral(I));
Douglas Gregor44882592009-07-28 15:27:13 +0000176}
177
Chad Rosier32503022012-06-11 20:47:18 +0000178void StmtProfiler::VisitMSAsmStmt(const MSAsmStmt *S) {
179 // FIXME: Implement MS style inline asm statement profiler.
180 VisitStmt(S);
181}
182
Chandler Carruth631abd92011-06-16 06:47:06 +0000183void StmtProfiler::VisitCXXCatchStmt(const CXXCatchStmt *S) {
Douglas Gregor44882592009-07-28 15:27:13 +0000184 VisitStmt(S);
185 VisitType(S->getCaughtType());
186}
187
Chandler Carruth631abd92011-06-16 06:47:06 +0000188void StmtProfiler::VisitCXXTryStmt(const CXXTryStmt *S) {
Douglas Gregor44882592009-07-28 15:27:13 +0000189 VisitStmt(S);
190}
191
Chandler Carruth631abd92011-06-16 06:47:06 +0000192void StmtProfiler::VisitCXXForRangeStmt(const CXXForRangeStmt *S) {
Richard Smith02e85f32011-04-14 22:09:26 +0000193 VisitStmt(S);
194}
195
Douglas Gregordeb4a2be2011-10-25 01:33:02 +0000196void StmtProfiler::VisitMSDependentExistsStmt(const MSDependentExistsStmt *S) {
197 VisitStmt(S);
198 ID.AddBoolean(S->isIfExists());
199 VisitNestedNameSpecifier(S->getQualifierLoc().getNestedNameSpecifier());
200 VisitName(S->getNameInfo().getName());
201}
202
Chandler Carruth631abd92011-06-16 06:47:06 +0000203void StmtProfiler::VisitSEHTryStmt(const SEHTryStmt *S) {
John Wiegley1c0675e2011-04-28 01:08:34 +0000204 VisitStmt(S);
205}
206
Chandler Carruth631abd92011-06-16 06:47:06 +0000207void StmtProfiler::VisitSEHFinallyStmt(const SEHFinallyStmt *S) {
John Wiegley1c0675e2011-04-28 01:08:34 +0000208 VisitStmt(S);
209}
210
Chandler Carruth631abd92011-06-16 06:47:06 +0000211void StmtProfiler::VisitSEHExceptStmt(const SEHExceptStmt *S) {
John Wiegley1c0675e2011-04-28 01:08:34 +0000212 VisitStmt(S);
213}
214
Nico Weber9b982072014-07-07 00:12:30 +0000215void StmtProfiler::VisitSEHLeaveStmt(const SEHLeaveStmt *S) {
216 VisitStmt(S);
217}
218
Tareq A. Siraj24110cc2013-04-16 18:53:08 +0000219void StmtProfiler::VisitCapturedStmt(const CapturedStmt *S) {
220 VisitStmt(S);
221}
222
Chandler Carruth631abd92011-06-16 06:47:06 +0000223void StmtProfiler::VisitObjCForCollectionStmt(const ObjCForCollectionStmt *S) {
Douglas Gregor44882592009-07-28 15:27:13 +0000224 VisitStmt(S);
225}
226
Chandler Carruth631abd92011-06-16 06:47:06 +0000227void StmtProfiler::VisitObjCAtCatchStmt(const ObjCAtCatchStmt *S) {
Douglas Gregor44882592009-07-28 15:27:13 +0000228 VisitStmt(S);
229 ID.AddBoolean(S->hasEllipsis());
230 if (S->getCatchParamDecl())
231 VisitType(S->getCatchParamDecl()->getType());
232}
233
Chandler Carruth631abd92011-06-16 06:47:06 +0000234void StmtProfiler::VisitObjCAtFinallyStmt(const ObjCAtFinallyStmt *S) {
Douglas Gregor44882592009-07-28 15:27:13 +0000235 VisitStmt(S);
236}
237
Chandler Carruth631abd92011-06-16 06:47:06 +0000238void StmtProfiler::VisitObjCAtTryStmt(const ObjCAtTryStmt *S) {
Douglas Gregor44882592009-07-28 15:27:13 +0000239 VisitStmt(S);
240}
241
Chandler Carruth631abd92011-06-16 06:47:06 +0000242void
243StmtProfiler::VisitObjCAtSynchronizedStmt(const ObjCAtSynchronizedStmt *S) {
Douglas Gregor44882592009-07-28 15:27:13 +0000244 VisitStmt(S);
245}
246
Chandler Carruth631abd92011-06-16 06:47:06 +0000247void StmtProfiler::VisitObjCAtThrowStmt(const ObjCAtThrowStmt *S) {
Douglas Gregor44882592009-07-28 15:27:13 +0000248 VisitStmt(S);
249}
250
Chandler Carruth631abd92011-06-16 06:47:06 +0000251void
252StmtProfiler::VisitObjCAutoreleasePoolStmt(const ObjCAutoreleasePoolStmt *S) {
John McCall31168b02011-06-15 23:02:42 +0000253 VisitStmt(S);
254}
255
Alexey Bataev5ec3eb12013-07-19 03:13:43 +0000256namespace {
257class OMPClauseProfiler : public ConstOMPClauseVisitor<OMPClauseProfiler> {
258 StmtProfiler *Profiler;
Alexey Bataev756c1962013-09-24 03:17:45 +0000259 /// \brief Process clauses with list of variables.
260 template <typename T>
261 void VisitOMPClauseList(T *Node);
NAKAMURA Takumiaa13f942015-12-09 07:52:46 +0000262
Alexey Bataev5ec3eb12013-07-19 03:13:43 +0000263public:
264 OMPClauseProfiler(StmtProfiler *P) : Profiler(P) { }
265#define OPENMP_CLAUSE(Name, Class) \
266 void Visit##Class(const Class *C);
267#include "clang/Basic/OpenMPKinds.def"
Alexey Bataev3392d762016-02-16 11:18:12 +0000268 void VistOMPClauseWithPreInit(const OMPClauseWithPreInit *C);
Alexey Bataev005248a2016-02-25 05:25:57 +0000269 void VistOMPClauseWithPostUpdate(const OMPClauseWithPostUpdate *C);
Alexey Bataev5ec3eb12013-07-19 03:13:43 +0000270};
271
Alexey Bataev3392d762016-02-16 11:18:12 +0000272void OMPClauseProfiler::VistOMPClauseWithPreInit(
273 const OMPClauseWithPreInit *C) {
274 if (auto *S = C->getPreInitStmt())
275 Profiler->VisitStmt(S);
276}
277
Alexey Bataev005248a2016-02-25 05:25:57 +0000278void OMPClauseProfiler::VistOMPClauseWithPostUpdate(
279 const OMPClauseWithPostUpdate *C) {
Alexey Bataev37e594c2016-03-04 07:21:16 +0000280 VistOMPClauseWithPreInit(C);
Alexey Bataev005248a2016-02-25 05:25:57 +0000281 if (auto *E = C->getPostUpdateExpr())
282 Profiler->VisitStmt(E);
283}
284
Alexey Bataevaadd52e2014-02-13 05:29:23 +0000285void OMPClauseProfiler::VisitOMPIfClause(const OMPIfClause *C) {
Arpith Chacko Jacobfe4890a2017-01-18 20:40:48 +0000286 VistOMPClauseWithPreInit(C);
Alexey Bataevaadd52e2014-02-13 05:29:23 +0000287 if (C->getCondition())
288 Profiler->VisitStmt(C->getCondition());
289}
290
Alexey Bataev3778b602014-07-17 07:32:53 +0000291void OMPClauseProfiler::VisitOMPFinalClause(const OMPFinalClause *C) {
292 if (C->getCondition())
293 Profiler->VisitStmt(C->getCondition());
294}
295
Alexey Bataev568a8332014-03-06 06:15:19 +0000296void OMPClauseProfiler::VisitOMPNumThreadsClause(const OMPNumThreadsClause *C) {
297 if (C->getNumThreads())
298 Profiler->VisitStmt(C->getNumThreads());
299}
300
Alexey Bataev62c87d22014-03-21 04:51:18 +0000301void OMPClauseProfiler::VisitOMPSafelenClause(const OMPSafelenClause *C) {
302 if (C->getSafelen())
303 Profiler->VisitStmt(C->getSafelen());
304}
305
Alexey Bataev66b15b52015-08-21 11:14:16 +0000306void OMPClauseProfiler::VisitOMPSimdlenClause(const OMPSimdlenClause *C) {
307 if (C->getSimdlen())
308 Profiler->VisitStmt(C->getSimdlen());
309}
310
Alexander Musman8bd31e62014-05-27 15:12:19 +0000311void OMPClauseProfiler::VisitOMPCollapseClause(const OMPCollapseClause *C) {
312 if (C->getNumForLoops())
313 Profiler->VisitStmt(C->getNumForLoops());
314}
315
Alexey Bataev5ec3eb12013-07-19 03:13:43 +0000316void OMPClauseProfiler::VisitOMPDefaultClause(const OMPDefaultClause *C) { }
Alexey Bataev756c1962013-09-24 03:17:45 +0000317
Alexey Bataevbcbadb62014-05-06 06:04:14 +0000318void OMPClauseProfiler::VisitOMPProcBindClause(const OMPProcBindClause *C) { }
319
Alexey Bataev56dafe82014-06-20 07:16:17 +0000320void OMPClauseProfiler::VisitOMPScheduleClause(const OMPScheduleClause *C) {
Alexey Bataev3392d762016-02-16 11:18:12 +0000321 VistOMPClauseWithPreInit(C);
322 if (auto *S = C->getChunkSize())
323 Profiler->VisitStmt(S);
Alexey Bataev56dafe82014-06-20 07:16:17 +0000324}
325
Alexey Bataev10e775f2015-07-30 11:36:16 +0000326void OMPClauseProfiler::VisitOMPOrderedClause(const OMPOrderedClause *C) {
327 if (auto *Num = C->getNumForLoops())
328 Profiler->VisitStmt(Num);
329}
Alexey Bataev142e1fc2014-06-20 09:44:06 +0000330
Alexey Bataev236070f2014-06-20 11:19:47 +0000331void OMPClauseProfiler::VisitOMPNowaitClause(const OMPNowaitClause *) {}
332
Alexey Bataev7aea99a2014-07-17 12:19:31 +0000333void OMPClauseProfiler::VisitOMPUntiedClause(const OMPUntiedClause *) {}
334
Alexey Bataev74ba3a52014-07-17 12:47:03 +0000335void OMPClauseProfiler::VisitOMPMergeableClause(const OMPMergeableClause *) {}
336
Alexey Bataevf98b00c2014-07-23 02:27:21 +0000337void OMPClauseProfiler::VisitOMPReadClause(const OMPReadClause *) {}
338
Alexey Bataevdea47612014-07-23 07:46:59 +0000339void OMPClauseProfiler::VisitOMPWriteClause(const OMPWriteClause *) {}
340
Alexey Bataev67a4f222014-07-23 10:25:33 +0000341void OMPClauseProfiler::VisitOMPUpdateClause(const OMPUpdateClause *) {}
342
Alexey Bataev459dec02014-07-24 06:46:57 +0000343void OMPClauseProfiler::VisitOMPCaptureClause(const OMPCaptureClause *) {}
344
Alexey Bataev82bad8b2014-07-24 08:55:34 +0000345void OMPClauseProfiler::VisitOMPSeqCstClause(const OMPSeqCstClause *) {}
346
Alexey Bataev346265e2015-09-25 10:37:12 +0000347void OMPClauseProfiler::VisitOMPThreadsClause(const OMPThreadsClause *) {}
348
Alexey Bataevd14d1e62015-09-28 06:39:35 +0000349void OMPClauseProfiler::VisitOMPSIMDClause(const OMPSIMDClause *) {}
350
Alexey Bataevb825de12015-12-07 10:51:44 +0000351void OMPClauseProfiler::VisitOMPNogroupClause(const OMPNogroupClause *) {}
352
Alexey Bataev756c1962013-09-24 03:17:45 +0000353template<typename T>
354void OMPClauseProfiler::VisitOMPClauseList(T *Node) {
Alexey Bataev03b340a2014-10-21 03:16:40 +0000355 for (auto *E : Node->varlists()) {
Richard Trieu6a77a1c2016-06-10 04:52:09 +0000356 if (E)
357 Profiler->VisitStmt(E);
Alexey Bataev03b340a2014-10-21 03:16:40 +0000358 }
Alexey Bataev756c1962013-09-24 03:17:45 +0000359}
Alexey Bataev5ec3eb12013-07-19 03:13:43 +0000360
361void OMPClauseProfiler::VisitOMPPrivateClause(const OMPPrivateClause *C) {
Alexey Bataev756c1962013-09-24 03:17:45 +0000362 VisitOMPClauseList(C);
Alexey Bataev03b340a2014-10-21 03:16:40 +0000363 for (auto *E : C->private_copies()) {
Richard Trieu6a77a1c2016-06-10 04:52:09 +0000364 if (E)
365 Profiler->VisitStmt(E);
Alexey Bataev03b340a2014-10-21 03:16:40 +0000366 }
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()) {
Richard Trieu6a77a1c2016-06-10 04:52:09 +0000373 if (E)
374 Profiler->VisitStmt(E);
Alexey Bataev4a5bb772014-10-08 14:01:46 +0000375 }
376 for (auto *E : C->inits()) {
Richard Trieu6a77a1c2016-06-10 04:52:09 +0000377 if (E)
378 Profiler->VisitStmt(E);
Alexey Bataev4a5bb772014-10-08 14:01:46 +0000379 }
Alexey Bataevd5af8e42013-10-01 05:32:34 +0000380}
Alexander Musman1bb328c2014-06-04 13:06:39 +0000381void
382OMPClauseProfiler::VisitOMPLastprivateClause(const OMPLastprivateClause *C) {
383 VisitOMPClauseList(C);
Alexey Bataev005248a2016-02-25 05:25:57 +0000384 VistOMPClauseWithPostUpdate(C);
Alexey Bataev38e89532015-04-16 04:54:05 +0000385 for (auto *E : C->source_exprs()) {
Richard Trieu6a77a1c2016-06-10 04:52:09 +0000386 if (E)
387 Profiler->VisitStmt(E);
Alexey Bataev38e89532015-04-16 04:54:05 +0000388 }
389 for (auto *E : C->destination_exprs()) {
Richard Trieu6a77a1c2016-06-10 04:52:09 +0000390 if (E)
391 Profiler->VisitStmt(E);
Alexey Bataev38e89532015-04-16 04:54:05 +0000392 }
393 for (auto *E : C->assignment_ops()) {
Richard Trieu6a77a1c2016-06-10 04:52:09 +0000394 if (E)
395 Profiler->VisitStmt(E);
Alexey Bataev38e89532015-04-16 04:54:05 +0000396 }
Alexander Musman1bb328c2014-06-04 13:06:39 +0000397}
Alexey Bataev758e55e2013-09-06 18:03:48 +0000398void OMPClauseProfiler::VisitOMPSharedClause(const OMPSharedClause *C) {
Alexey Bataev756c1962013-09-24 03:17:45 +0000399 VisitOMPClauseList(C);
Alexey Bataev758e55e2013-09-06 18:03:48 +0000400}
Alexey Bataevc5e02582014-06-16 07:08:35 +0000401void OMPClauseProfiler::VisitOMPReductionClause(
402 const OMPReductionClause *C) {
403 Profiler->VisitNestedNameSpecifier(
404 C->getQualifierLoc().getNestedNameSpecifier());
405 Profiler->VisitName(C->getNameInfo().getName());
406 VisitOMPClauseList(C);
Alexey Bataev61205072016-03-02 04:57:40 +0000407 VistOMPClauseWithPostUpdate(C);
Alexey Bataevf24e7b12015-10-08 09:10:53 +0000408 for (auto *E : C->privates()) {
Richard Trieu6a77a1c2016-06-10 04:52:09 +0000409 if (E)
410 Profiler->VisitStmt(E);
Alexey Bataevf24e7b12015-10-08 09:10:53 +0000411 }
Alexey Bataev794ba0d2015-04-10 10:43:45 +0000412 for (auto *E : C->lhs_exprs()) {
Richard Trieu6a77a1c2016-06-10 04:52:09 +0000413 if (E)
414 Profiler->VisitStmt(E);
Alexey Bataev794ba0d2015-04-10 10:43:45 +0000415 }
416 for (auto *E : C->rhs_exprs()) {
Richard Trieu6a77a1c2016-06-10 04:52:09 +0000417 if (E)
418 Profiler->VisitStmt(E);
Alexey Bataev794ba0d2015-04-10 10:43:45 +0000419 }
420 for (auto *E : C->reduction_ops()) {
Richard Trieu6a77a1c2016-06-10 04:52:09 +0000421 if (E)
422 Profiler->VisitStmt(E);
Alexey Bataev794ba0d2015-04-10 10:43:45 +0000423 }
Alexey Bataevc5e02582014-06-16 07:08:35 +0000424}
Alexander Musman8dba6642014-04-22 13:09:42 +0000425void OMPClauseProfiler::VisitOMPLinearClause(const OMPLinearClause *C) {
426 VisitOMPClauseList(C);
Alexey Bataev78849fb2016-03-09 09:49:00 +0000427 VistOMPClauseWithPostUpdate(C);
Alexey Bataevbd9fec12015-08-18 06:47:21 +0000428 for (auto *E : C->privates()) {
Richard Trieu6a77a1c2016-06-10 04:52:09 +0000429 if (E)
430 Profiler->VisitStmt(E);
Alexey Bataevbd9fec12015-08-18 06:47:21 +0000431 }
Alexander Musman3276a272015-03-21 10:12:56 +0000432 for (auto *E : C->inits()) {
Richard Trieu6a77a1c2016-06-10 04:52:09 +0000433 if (E)
434 Profiler->VisitStmt(E);
Alexander Musman3276a272015-03-21 10:12:56 +0000435 }
436 for (auto *E : C->updates()) {
Richard Trieu6a77a1c2016-06-10 04:52:09 +0000437 if (E)
438 Profiler->VisitStmt(E);
Alexander Musman3276a272015-03-21 10:12:56 +0000439 }
440 for (auto *E : C->finals()) {
Richard Trieu6a77a1c2016-06-10 04:52:09 +0000441 if (E)
442 Profiler->VisitStmt(E);
Alexander Musman3276a272015-03-21 10:12:56 +0000443 }
Richard Trieu6a77a1c2016-06-10 04:52:09 +0000444 if (C->getStep())
445 Profiler->VisitStmt(C->getStep());
446 if (C->getCalcStep())
447 Profiler->VisitStmt(C->getCalcStep());
Alexander Musman8dba6642014-04-22 13:09:42 +0000448}
Alexander Musmanf0d76e72014-05-29 14:36:25 +0000449void OMPClauseProfiler::VisitOMPAlignedClause(const OMPAlignedClause *C) {
450 VisitOMPClauseList(C);
Richard Trieu6a77a1c2016-06-10 04:52:09 +0000451 if (C->getAlignment())
452 Profiler->VisitStmt(C->getAlignment());
Alexander Musmanf0d76e72014-05-29 14:36:25 +0000453}
Alexey Bataevd48bcd82014-03-31 03:36:38 +0000454void OMPClauseProfiler::VisitOMPCopyinClause(const OMPCopyinClause *C) {
455 VisitOMPClauseList(C);
Alexey Bataevf56f98c2015-04-16 05:39:01 +0000456 for (auto *E : C->source_exprs()) {
Richard Trieu6a77a1c2016-06-10 04:52:09 +0000457 if (E)
458 Profiler->VisitStmt(E);
Alexey Bataevf56f98c2015-04-16 05:39:01 +0000459 }
460 for (auto *E : C->destination_exprs()) {
Richard Trieu6a77a1c2016-06-10 04:52:09 +0000461 if (E)
462 Profiler->VisitStmt(E);
Alexey Bataevf56f98c2015-04-16 05:39:01 +0000463 }
464 for (auto *E : C->assignment_ops()) {
Richard Trieu6a77a1c2016-06-10 04:52:09 +0000465 if (E)
466 Profiler->VisitStmt(E);
Alexey Bataevf56f98c2015-04-16 05:39:01 +0000467 }
Alexey Bataevd48bcd82014-03-31 03:36:38 +0000468}
Alexey Bataevbae9a792014-06-27 10:37:06 +0000469void
470OMPClauseProfiler::VisitOMPCopyprivateClause(const OMPCopyprivateClause *C) {
471 VisitOMPClauseList(C);
Alexey Bataeva63048e2015-03-23 06:18:07 +0000472 for (auto *E : C->source_exprs()) {
Richard Trieu6a77a1c2016-06-10 04:52:09 +0000473 if (E)
474 Profiler->VisitStmt(E);
Alexey Bataeva63048e2015-03-23 06:18:07 +0000475 }
476 for (auto *E : C->destination_exprs()) {
Richard Trieu6a77a1c2016-06-10 04:52:09 +0000477 if (E)
478 Profiler->VisitStmt(E);
Alexey Bataeva63048e2015-03-23 06:18:07 +0000479 }
480 for (auto *E : C->assignment_ops()) {
Richard Trieu6a77a1c2016-06-10 04:52:09 +0000481 if (E)
482 Profiler->VisitStmt(E);
Alexey Bataeva63048e2015-03-23 06:18:07 +0000483 }
Alexey Bataevbae9a792014-06-27 10:37:06 +0000484}
Alexey Bataev6125da92014-07-21 11:26:11 +0000485void OMPClauseProfiler::VisitOMPFlushClause(const OMPFlushClause *C) {
486 VisitOMPClauseList(C);
487}
Alexey Bataev1c2cfbc2015-06-23 14:25:19 +0000488void OMPClauseProfiler::VisitOMPDependClause(const OMPDependClause *C) {
489 VisitOMPClauseList(C);
490}
Michael Wonge710d542015-08-07 16:16:36 +0000491void OMPClauseProfiler::VisitOMPDeviceClause(const OMPDeviceClause *C) {
Richard Trieu6a77a1c2016-06-10 04:52:09 +0000492 if (C->getDevice())
493 Profiler->VisitStmt(C->getDevice());
Michael Wonge710d542015-08-07 16:16:36 +0000494}
Kelvin Li0bff7af2015-11-23 05:32:03 +0000495void OMPClauseProfiler::VisitOMPMapClause(const OMPMapClause *C) {
496 VisitOMPClauseList(C);
497}
Kelvin Li099bb8c2015-11-24 20:50:12 +0000498void OMPClauseProfiler::VisitOMPNumTeamsClause(const OMPNumTeamsClause *C) {
Richard Trieu6a77a1c2016-06-10 04:52:09 +0000499 if (C->getNumTeams())
500 Profiler->VisitStmt(C->getNumTeams());
Kelvin Li099bb8c2015-11-24 20:50:12 +0000501}
Kelvin Lia15fb1a2015-11-27 18:47:36 +0000502void OMPClauseProfiler::VisitOMPThreadLimitClause(
503 const OMPThreadLimitClause *C) {
Richard Trieu6a77a1c2016-06-10 04:52:09 +0000504 if (C->getThreadLimit())
505 Profiler->VisitStmt(C->getThreadLimit());
Kelvin Lia15fb1a2015-11-27 18:47:36 +0000506}
Alexey Bataeva0569352015-12-01 10:17:31 +0000507void OMPClauseProfiler::VisitOMPPriorityClause(const OMPPriorityClause *C) {
Richard Trieu6a77a1c2016-06-10 04:52:09 +0000508 if (C->getPriority())
509 Profiler->VisitStmt(C->getPriority());
Alexey Bataeva0569352015-12-01 10:17:31 +0000510}
Alexey Bataev1fd4aed2015-12-07 12:52:51 +0000511void OMPClauseProfiler::VisitOMPGrainsizeClause(const OMPGrainsizeClause *C) {
Richard Trieu6a77a1c2016-06-10 04:52:09 +0000512 if (C->getGrainsize())
513 Profiler->VisitStmt(C->getGrainsize());
Alexey Bataev1fd4aed2015-12-07 12:52:51 +0000514}
Alexey Bataev382967a2015-12-08 12:06:20 +0000515void OMPClauseProfiler::VisitOMPNumTasksClause(const OMPNumTasksClause *C) {
Richard Trieu6a77a1c2016-06-10 04:52:09 +0000516 if (C->getNumTasks())
517 Profiler->VisitStmt(C->getNumTasks());
Alexey Bataev382967a2015-12-08 12:06:20 +0000518}
Alexey Bataev28c75412015-12-15 08:19:24 +0000519void OMPClauseProfiler::VisitOMPHintClause(const OMPHintClause *C) {
Richard Trieu6a77a1c2016-06-10 04:52:09 +0000520 if (C->getHint())
521 Profiler->VisitStmt(C->getHint());
Alexey Bataev28c75412015-12-15 08:19:24 +0000522}
Samuel Antao661c0902016-05-26 17:39:58 +0000523void OMPClauseProfiler::VisitOMPToClause(const OMPToClause *C) {
524 VisitOMPClauseList(C);
525}
Samuel Antaoec172c62016-05-26 17:49:04 +0000526void OMPClauseProfiler::VisitOMPFromClause(const OMPFromClause *C) {
527 VisitOMPClauseList(C);
528}
Carlo Bertolli2404b172016-07-13 15:37:16 +0000529void OMPClauseProfiler::VisitOMPUseDevicePtrClause(
530 const OMPUseDevicePtrClause *C) {
531 VisitOMPClauseList(C);
532}
Carlo Bertolli70594e92016-07-13 17:16:49 +0000533void OMPClauseProfiler::VisitOMPIsDevicePtrClause(
534 const OMPIsDevicePtrClause *C) {
535 VisitOMPClauseList(C);
536}
Alexander Kornienkoab9db512015-06-22 23:07:51 +0000537}
Alexey Bataev5ec3eb12013-07-19 03:13:43 +0000538
539void
Alexey Bataev1b59ab52014-02-27 08:29:12 +0000540StmtProfiler::VisitOMPExecutableDirective(const OMPExecutableDirective *S) {
Alexey Bataev5ec3eb12013-07-19 03:13:43 +0000541 VisitStmt(S);
542 OMPClauseProfiler P(this);
543 ArrayRef<OMPClause *> Clauses = S->clauses();
544 for (ArrayRef<OMPClause *>::iterator I = Clauses.begin(), E = Clauses.end();
545 I != E; ++I)
546 if (*I)
547 P.Visit(*I);
548}
549
Alexander Musman3aaab662014-08-19 11:27:13 +0000550void StmtProfiler::VisitOMPLoopDirective(const OMPLoopDirective *S) {
551 VisitOMPExecutableDirective(S);
552}
553
Alexey Bataev1b59ab52014-02-27 08:29:12 +0000554void StmtProfiler::VisitOMPParallelDirective(const OMPParallelDirective *S) {
555 VisitOMPExecutableDirective(S);
556}
557
558void StmtProfiler::VisitOMPSimdDirective(const OMPSimdDirective *S) {
Alexander Musman3aaab662014-08-19 11:27:13 +0000559 VisitOMPLoopDirective(S);
Alexey Bataev1b59ab52014-02-27 08:29:12 +0000560}
561
Alexey Bataevf29276e2014-06-18 04:14:57 +0000562void StmtProfiler::VisitOMPForDirective(const OMPForDirective *S) {
Alexander Musman3aaab662014-08-19 11:27:13 +0000563 VisitOMPLoopDirective(S);
Alexey Bataevf29276e2014-06-18 04:14:57 +0000564}
565
Alexander Musmanf82886e2014-09-18 05:12:34 +0000566void StmtProfiler::VisitOMPForSimdDirective(const OMPForSimdDirective *S) {
567 VisitOMPLoopDirective(S);
568}
569
Alexey Bataevd3f8dd22014-06-25 11:44:49 +0000570void StmtProfiler::VisitOMPSectionsDirective(const OMPSectionsDirective *S) {
571 VisitOMPExecutableDirective(S);
572}
573
Alexey Bataev1e0498a2014-06-26 08:21:58 +0000574void StmtProfiler::VisitOMPSectionDirective(const OMPSectionDirective *S) {
575 VisitOMPExecutableDirective(S);
576}
577
Alexey Bataevd1e40fb2014-06-26 12:05:45 +0000578void StmtProfiler::VisitOMPSingleDirective(const OMPSingleDirective *S) {
579 VisitOMPExecutableDirective(S);
580}
581
Alexander Musman80c22892014-07-17 08:54:58 +0000582void StmtProfiler::VisitOMPMasterDirective(const OMPMasterDirective *S) {
583 VisitOMPExecutableDirective(S);
584}
585
Alexander Musmand9ed09f2014-07-21 09:42:05 +0000586void StmtProfiler::VisitOMPCriticalDirective(const OMPCriticalDirective *S) {
587 VisitOMPExecutableDirective(S);
588 VisitName(S->getDirectiveName().getName());
589}
590
Alexey Bataev4acb8592014-07-07 13:01:15 +0000591void
592StmtProfiler::VisitOMPParallelForDirective(const OMPParallelForDirective *S) {
Alexander Musman3aaab662014-08-19 11:27:13 +0000593 VisitOMPLoopDirective(S);
Alexey Bataev4acb8592014-07-07 13:01:15 +0000594}
595
Alexander Musmane4e893b2014-09-23 09:33:00 +0000596void StmtProfiler::VisitOMPParallelForSimdDirective(
597 const OMPParallelForSimdDirective *S) {
598 VisitOMPLoopDirective(S);
599}
600
Alexey Bataev84d0b3e2014-07-08 08:12:03 +0000601void StmtProfiler::VisitOMPParallelSectionsDirective(
602 const OMPParallelSectionsDirective *S) {
603 VisitOMPExecutableDirective(S);
604}
605
Alexey Bataev9c2e8ee2014-07-11 11:25:16 +0000606void StmtProfiler::VisitOMPTaskDirective(const OMPTaskDirective *S) {
607 VisitOMPExecutableDirective(S);
608}
609
Alexey Bataev68446b72014-07-18 07:47:19 +0000610void StmtProfiler::VisitOMPTaskyieldDirective(const OMPTaskyieldDirective *S) {
611 VisitOMPExecutableDirective(S);
612}
613
Alexey Bataev4d1dfea2014-07-18 09:11:51 +0000614void StmtProfiler::VisitOMPBarrierDirective(const OMPBarrierDirective *S) {
615 VisitOMPExecutableDirective(S);
616}
617
Alexey Bataev2df347a2014-07-18 10:17:07 +0000618void StmtProfiler::VisitOMPTaskwaitDirective(const OMPTaskwaitDirective *S) {
619 VisitOMPExecutableDirective(S);
620}
621
Alexey Bataevc30dd2d2015-06-18 12:14:09 +0000622void StmtProfiler::VisitOMPTaskgroupDirective(const OMPTaskgroupDirective *S) {
623 VisitOMPExecutableDirective(S);
624}
625
Alexey Bataev6125da92014-07-21 11:26:11 +0000626void StmtProfiler::VisitOMPFlushDirective(const OMPFlushDirective *S) {
627 VisitOMPExecutableDirective(S);
628}
629
Alexey Bataev9fb6e642014-07-22 06:45:04 +0000630void StmtProfiler::VisitOMPOrderedDirective(const OMPOrderedDirective *S) {
631 VisitOMPExecutableDirective(S);
632}
633
Alexey Bataev0162e452014-07-22 10:10:35 +0000634void StmtProfiler::VisitOMPAtomicDirective(const OMPAtomicDirective *S) {
635 VisitOMPExecutableDirective(S);
636}
637
Alexey Bataev0bd520b2014-09-19 08:19:49 +0000638void StmtProfiler::VisitOMPTargetDirective(const OMPTargetDirective *S) {
639 VisitOMPExecutableDirective(S);
640}
641
Michael Wong65f367f2015-07-21 13:44:28 +0000642void StmtProfiler::VisitOMPTargetDataDirective(const OMPTargetDataDirective *S) {
643 VisitOMPExecutableDirective(S);
644}
645
Samuel Antaodf67fc42016-01-19 19:15:56 +0000646void StmtProfiler::VisitOMPTargetEnterDataDirective(
647 const OMPTargetEnterDataDirective *S) {
648 VisitOMPExecutableDirective(S);
649}
650
Samuel Antao72590762016-01-19 20:04:50 +0000651void StmtProfiler::VisitOMPTargetExitDataDirective(
652 const OMPTargetExitDataDirective *S) {
653 VisitOMPExecutableDirective(S);
654}
655
Arpith Chacko Jacobe955b3d2016-01-26 18:48:41 +0000656void StmtProfiler::VisitOMPTargetParallelDirective(
657 const OMPTargetParallelDirective *S) {
658 VisitOMPExecutableDirective(S);
659}
660
Arpith Chacko Jacob05bebb52016-02-03 15:46:42 +0000661void StmtProfiler::VisitOMPTargetParallelForDirective(
662 const OMPTargetParallelForDirective *S) {
663 VisitOMPExecutableDirective(S);
664}
665
Alexey Bataev13314bf2014-10-09 04:18:56 +0000666void StmtProfiler::VisitOMPTeamsDirective(const OMPTeamsDirective *S) {
667 VisitOMPExecutableDirective(S);
668}
669
Alexey Bataev6d4ed052015-07-01 06:57:41 +0000670void StmtProfiler::VisitOMPCancellationPointDirective(
671 const OMPCancellationPointDirective *S) {
672 VisitOMPExecutableDirective(S);
673}
674
Alexey Bataev80909872015-07-02 11:25:17 +0000675void StmtProfiler::VisitOMPCancelDirective(const OMPCancelDirective *S) {
676 VisitOMPExecutableDirective(S);
677}
678
Alexey Bataev49f6e782015-12-01 04:18:41 +0000679void StmtProfiler::VisitOMPTaskLoopDirective(const OMPTaskLoopDirective *S) {
680 VisitOMPLoopDirective(S);
681}
682
Alexey Bataev0a6ed842015-12-03 09:40:15 +0000683void StmtProfiler::VisitOMPTaskLoopSimdDirective(
684 const OMPTaskLoopSimdDirective *S) {
685 VisitOMPLoopDirective(S);
686}
687
Carlo Bertolli6200a3d2015-12-14 14:51:25 +0000688void StmtProfiler::VisitOMPDistributeDirective(
689 const OMPDistributeDirective *S) {
690 VisitOMPLoopDirective(S);
691}
692
Carlo Bertollib4adf552016-01-15 18:50:31 +0000693void OMPClauseProfiler::VisitOMPDistScheduleClause(
694 const OMPDistScheduleClause *C) {
Alexey Bataev3392d762016-02-16 11:18:12 +0000695 VistOMPClauseWithPreInit(C);
696 if (auto *S = C->getChunkSize())
697 Profiler->VisitStmt(S);
Carlo Bertollib4adf552016-01-15 18:50:31 +0000698}
699
Arpith Chacko Jacob3cf89042016-01-26 16:37:23 +0000700void OMPClauseProfiler::VisitOMPDefaultmapClause(const OMPDefaultmapClause *) {}
701
Samuel Antao686c70c2016-05-26 17:30:50 +0000702void StmtProfiler::VisitOMPTargetUpdateDirective(
703 const OMPTargetUpdateDirective *S) {
704 VisitOMPExecutableDirective(S);
705}
706
Carlo Bertolli9925f152016-06-27 14:55:37 +0000707void StmtProfiler::VisitOMPDistributeParallelForDirective(
708 const OMPDistributeParallelForDirective *S) {
709 VisitOMPLoopDirective(S);
710}
711
Kelvin Li4a39add2016-07-05 05:00:15 +0000712void StmtProfiler::VisitOMPDistributeParallelForSimdDirective(
713 const OMPDistributeParallelForSimdDirective *S) {
714 VisitOMPLoopDirective(S);
715}
716
Kelvin Li787f3fc2016-07-06 04:45:38 +0000717void StmtProfiler::VisitOMPDistributeSimdDirective(
718 const OMPDistributeSimdDirective *S) {
719 VisitOMPLoopDirective(S);
720}
721
Kelvin Lia579b912016-07-14 02:54:56 +0000722void StmtProfiler::VisitOMPTargetParallelForSimdDirective(
723 const OMPTargetParallelForSimdDirective *S) {
724 VisitOMPLoopDirective(S);
725}
726
Kelvin Li986330c2016-07-20 22:57:10 +0000727void StmtProfiler::VisitOMPTargetSimdDirective(
728 const OMPTargetSimdDirective *S) {
729 VisitOMPLoopDirective(S);
730}
731
Kelvin Li02532872016-08-05 14:37:37 +0000732void StmtProfiler::VisitOMPTeamsDistributeDirective(
733 const OMPTeamsDistributeDirective *S) {
734 VisitOMPLoopDirective(S);
735}
736
Kelvin Li4e325f72016-10-25 12:50:55 +0000737void StmtProfiler::VisitOMPTeamsDistributeSimdDirective(
738 const OMPTeamsDistributeSimdDirective *S) {
739 VisitOMPLoopDirective(S);
740}
741
Kelvin Li579e41c2016-11-30 23:51:03 +0000742void StmtProfiler::VisitOMPTeamsDistributeParallelForSimdDirective(
743 const OMPTeamsDistributeParallelForSimdDirective *S) {
744 VisitOMPLoopDirective(S);
745}
746
Kelvin Li7ade93f2016-12-09 03:24:30 +0000747void StmtProfiler::VisitOMPTeamsDistributeParallelForDirective(
748 const OMPTeamsDistributeParallelForDirective *S) {
749 VisitOMPLoopDirective(S);
750}
751
Kelvin Libf594a52016-12-17 05:48:59 +0000752void StmtProfiler::VisitOMPTargetTeamsDirective(
753 const OMPTargetTeamsDirective *S) {
754 VisitOMPExecutableDirective(S);
755}
756
Kelvin Li83c451e2016-12-25 04:52:54 +0000757void StmtProfiler::VisitOMPTargetTeamsDistributeDirective(
758 const OMPTargetTeamsDistributeDirective *S) {
759 VisitOMPLoopDirective(S);
760}
761
Kelvin Li80e8f562016-12-29 22:16:30 +0000762void StmtProfiler::VisitOMPTargetTeamsDistributeParallelForDirective(
763 const OMPTargetTeamsDistributeParallelForDirective *S) {
764 VisitOMPLoopDirective(S);
765}
766
Kelvin Li1851df52017-01-03 05:23:48 +0000767void StmtProfiler::VisitOMPTargetTeamsDistributeParallelForSimdDirective(
768 const OMPTargetTeamsDistributeParallelForSimdDirective *S) {
769 VisitOMPLoopDirective(S);
770}
771
Kelvin Lida681182017-01-10 18:08:18 +0000772void StmtProfiler::VisitOMPTargetTeamsDistributeSimdDirective(
773 const OMPTargetTeamsDistributeSimdDirective *S) {
774 VisitOMPLoopDirective(S);
775}
776
Chandler Carruth631abd92011-06-16 06:47:06 +0000777void StmtProfiler::VisitExpr(const Expr *S) {
Douglas Gregor5c193b92009-07-28 00:33:38 +0000778 VisitStmt(S);
779}
780
Chandler Carruth631abd92011-06-16 06:47:06 +0000781void StmtProfiler::VisitDeclRefExpr(const DeclRefExpr *S) {
Douglas Gregor5c193b92009-07-28 00:33:38 +0000782 VisitExpr(S);
Douglas Gregorf5b160f2010-07-13 08:37:11 +0000783 if (!Canonical)
784 VisitNestedNameSpecifier(S->getQualifier());
Douglas Gregor5c193b92009-07-28 00:33:38 +0000785 VisitDecl(S->getDecl());
Douglas Gregorf5b160f2010-07-13 08:37:11 +0000786 if (!Canonical)
787 VisitTemplateArguments(S->getTemplateArgs(), S->getNumTemplateArgs());
Douglas Gregor5c193b92009-07-28 00:33:38 +0000788}
789
Chandler Carruth631abd92011-06-16 06:47:06 +0000790void StmtProfiler::VisitPredefinedExpr(const PredefinedExpr *S) {
Douglas Gregor5c193b92009-07-28 00:33:38 +0000791 VisitExpr(S);
792 ID.AddInteger(S->getIdentType());
793}
794
Chandler Carruth631abd92011-06-16 06:47:06 +0000795void StmtProfiler::VisitIntegerLiteral(const IntegerLiteral *S) {
Douglas Gregor5c193b92009-07-28 00:33:38 +0000796 VisitExpr(S);
797 S->getValue().Profile(ID);
Richard Smithe9f130c2014-11-20 03:37:32 +0000798 ID.AddInteger(S->getType()->castAs<BuiltinType>()->getKind());
Douglas Gregor5c193b92009-07-28 00:33:38 +0000799}
800
Chandler Carruth631abd92011-06-16 06:47:06 +0000801void StmtProfiler::VisitCharacterLiteral(const CharacterLiteral *S) {
Douglas Gregor5c193b92009-07-28 00:33:38 +0000802 VisitExpr(S);
Douglas Gregorfb65e592011-07-27 05:40:30 +0000803 ID.AddInteger(S->getKind());
Douglas Gregor5c193b92009-07-28 00:33:38 +0000804 ID.AddInteger(S->getValue());
805}
806
Chandler Carruth631abd92011-06-16 06:47:06 +0000807void StmtProfiler::VisitFloatingLiteral(const FloatingLiteral *S) {
Douglas Gregor5c193b92009-07-28 00:33:38 +0000808 VisitExpr(S);
809 S->getValue().Profile(ID);
810 ID.AddBoolean(S->isExact());
Richard Smithe9f130c2014-11-20 03:37:32 +0000811 ID.AddInteger(S->getType()->castAs<BuiltinType>()->getKind());
Douglas Gregor5c193b92009-07-28 00:33:38 +0000812}
813
Chandler Carruth631abd92011-06-16 06:47:06 +0000814void StmtProfiler::VisitImaginaryLiteral(const ImaginaryLiteral *S) {
Douglas Gregor5c193b92009-07-28 00:33:38 +0000815 VisitExpr(S);
816}
817
Chandler Carruth631abd92011-06-16 06:47:06 +0000818void StmtProfiler::VisitStringLiteral(const StringLiteral *S) {
Douglas Gregor5c193b92009-07-28 00:33:38 +0000819 VisitExpr(S);
Douglas Gregor9d0eb8f2011-11-02 17:26:05 +0000820 ID.AddString(S->getBytes());
Douglas Gregorfb65e592011-07-27 05:40:30 +0000821 ID.AddInteger(S->getKind());
Douglas Gregor5c193b92009-07-28 00:33:38 +0000822}
823
Chandler Carruth631abd92011-06-16 06:47:06 +0000824void StmtProfiler::VisitParenExpr(const ParenExpr *S) {
Douglas Gregor5c193b92009-07-28 00:33:38 +0000825 VisitExpr(S);
826}
827
Chandler Carruth631abd92011-06-16 06:47:06 +0000828void StmtProfiler::VisitParenListExpr(const ParenListExpr *S) {
Nate Begeman5ec4b312009-08-10 23:49:36 +0000829 VisitExpr(S);
830}
831
Chandler Carruth631abd92011-06-16 06:47:06 +0000832void StmtProfiler::VisitUnaryOperator(const UnaryOperator *S) {
Douglas Gregor5c193b92009-07-28 00:33:38 +0000833 VisitExpr(S);
834 ID.AddInteger(S->getOpcode());
835}
836
Chandler Carruth631abd92011-06-16 06:47:06 +0000837void StmtProfiler::VisitOffsetOfExpr(const OffsetOfExpr *S) {
Douglas Gregor882211c2010-04-28 22:16:22 +0000838 VisitType(S->getTypeSourceInfo()->getType());
839 unsigned n = S->getNumComponents();
840 for (unsigned i = 0; i < n; ++i) {
James Y Knight7281c352015-12-29 22:31:18 +0000841 const OffsetOfNode &ON = S->getComponent(i);
Douglas Gregor882211c2010-04-28 22:16:22 +0000842 ID.AddInteger(ON.getKind());
843 switch (ON.getKind()) {
James Y Knight7281c352015-12-29 22:31:18 +0000844 case OffsetOfNode::Array:
Douglas Gregor882211c2010-04-28 22:16:22 +0000845 // Expressions handled below.
846 break;
847
James Y Knight7281c352015-12-29 22:31:18 +0000848 case OffsetOfNode::Field:
Douglas Gregor882211c2010-04-28 22:16:22 +0000849 VisitDecl(ON.getField());
850 break;
851
James Y Knight7281c352015-12-29 22:31:18 +0000852 case OffsetOfNode::Identifier:
Douglas Gregor882211c2010-04-28 22:16:22 +0000853 ID.AddPointer(ON.getFieldName());
854 break;
James Y Knight7281c352015-12-29 22:31:18 +0000855
856 case OffsetOfNode::Base:
Douglas Gregord1702062010-04-29 00:18:15 +0000857 // These nodes are implicit, and therefore don't need profiling.
858 break;
Douglas Gregor882211c2010-04-28 22:16:22 +0000859 }
860 }
Alexis Hunta8136cc2010-05-05 15:23:54 +0000861
Douglas Gregor882211c2010-04-28 22:16:22 +0000862 VisitExpr(S);
863}
864
Chandler Carruth631abd92011-06-16 06:47:06 +0000865void
866StmtProfiler::VisitUnaryExprOrTypeTraitExpr(const UnaryExprOrTypeTraitExpr *S) {
Douglas Gregor5c193b92009-07-28 00:33:38 +0000867 VisitExpr(S);
Peter Collingbournee190dee2011-03-11 19:24:49 +0000868 ID.AddInteger(S->getKind());
Douglas Gregor5c193b92009-07-28 00:33:38 +0000869 if (S->isArgumentType())
870 VisitType(S->getArgumentType());
871}
872
Chandler Carruth631abd92011-06-16 06:47:06 +0000873void StmtProfiler::VisitArraySubscriptExpr(const ArraySubscriptExpr *S) {
Douglas Gregor5c193b92009-07-28 00:33:38 +0000874 VisitExpr(S);
875}
876
Alexey Bataev1a3320e2015-08-25 14:24:04 +0000877void StmtProfiler::VisitOMPArraySectionExpr(const OMPArraySectionExpr *S) {
878 VisitExpr(S);
879}
880
Chandler Carruth631abd92011-06-16 06:47:06 +0000881void StmtProfiler::VisitCallExpr(const CallExpr *S) {
Douglas Gregor5c193b92009-07-28 00:33:38 +0000882 VisitExpr(S);
883}
884
Chandler Carruth631abd92011-06-16 06:47:06 +0000885void StmtProfiler::VisitMemberExpr(const MemberExpr *S) {
Douglas Gregor5c193b92009-07-28 00:33:38 +0000886 VisitExpr(S);
887 VisitDecl(S->getMemberDecl());
Douglas Gregorf5b160f2010-07-13 08:37:11 +0000888 if (!Canonical)
889 VisitNestedNameSpecifier(S->getQualifier());
Douglas Gregor5c193b92009-07-28 00:33:38 +0000890 ID.AddBoolean(S->isArrow());
891}
892
Chandler Carruth631abd92011-06-16 06:47:06 +0000893void StmtProfiler::VisitCompoundLiteralExpr(const CompoundLiteralExpr *S) {
Douglas Gregor5c193b92009-07-28 00:33:38 +0000894 VisitExpr(S);
895 ID.AddBoolean(S->isFileScope());
896}
897
Chandler Carruth631abd92011-06-16 06:47:06 +0000898void StmtProfiler::VisitCastExpr(const CastExpr *S) {
Douglas Gregor5c193b92009-07-28 00:33:38 +0000899 VisitExpr(S);
900}
901
Chandler Carruth631abd92011-06-16 06:47:06 +0000902void StmtProfiler::VisitImplicitCastExpr(const ImplicitCastExpr *S) {
Douglas Gregor5c193b92009-07-28 00:33:38 +0000903 VisitCastExpr(S);
John McCall2536c6d2010-08-25 10:28:54 +0000904 ID.AddInteger(S->getValueKind());
Douglas Gregor5c193b92009-07-28 00:33:38 +0000905}
906
Chandler Carruth631abd92011-06-16 06:47:06 +0000907void StmtProfiler::VisitExplicitCastExpr(const ExplicitCastExpr *S) {
Douglas Gregor5c193b92009-07-28 00:33:38 +0000908 VisitCastExpr(S);
909 VisitType(S->getTypeAsWritten());
910}
911
Chandler Carruth631abd92011-06-16 06:47:06 +0000912void StmtProfiler::VisitCStyleCastExpr(const CStyleCastExpr *S) {
Douglas Gregor5c193b92009-07-28 00:33:38 +0000913 VisitExplicitCastExpr(S);
914}
915
Chandler Carruth631abd92011-06-16 06:47:06 +0000916void StmtProfiler::VisitBinaryOperator(const BinaryOperator *S) {
Douglas Gregor5c193b92009-07-28 00:33:38 +0000917 VisitExpr(S);
918 ID.AddInteger(S->getOpcode());
919}
920
Chandler Carruth631abd92011-06-16 06:47:06 +0000921void
922StmtProfiler::VisitCompoundAssignOperator(const CompoundAssignOperator *S) {
Douglas Gregor5c193b92009-07-28 00:33:38 +0000923 VisitBinaryOperator(S);
924}
925
Chandler Carruth631abd92011-06-16 06:47:06 +0000926void StmtProfiler::VisitConditionalOperator(const ConditionalOperator *S) {
Douglas Gregor5c193b92009-07-28 00:33:38 +0000927 VisitExpr(S);
928}
929
Chandler Carruth631abd92011-06-16 06:47:06 +0000930void StmtProfiler::VisitBinaryConditionalOperator(
Chandler Carruthcf5f43c2011-06-21 23:26:32 +0000931 const BinaryConditionalOperator *S) {
John McCallc07a0c72011-02-17 10:25:35 +0000932 VisitExpr(S);
933}
934
Chandler Carruth631abd92011-06-16 06:47:06 +0000935void StmtProfiler::VisitAddrLabelExpr(const AddrLabelExpr *S) {
Douglas Gregor5c193b92009-07-28 00:33:38 +0000936 VisitExpr(S);
Chris Lattnerc8e630e2011-02-17 07:39:24 +0000937 VisitDecl(S->getLabel());
Douglas Gregor5c193b92009-07-28 00:33:38 +0000938}
939
Chandler Carruth631abd92011-06-16 06:47:06 +0000940void StmtProfiler::VisitStmtExpr(const StmtExpr *S) {
Douglas Gregor5c193b92009-07-28 00:33:38 +0000941 VisitExpr(S);
942}
943
Chandler Carruth631abd92011-06-16 06:47:06 +0000944void StmtProfiler::VisitShuffleVectorExpr(const ShuffleVectorExpr *S) {
Douglas Gregor5c193b92009-07-28 00:33:38 +0000945 VisitExpr(S);
946}
947
Hal Finkelc4d7c822013-09-18 03:29:45 +0000948void StmtProfiler::VisitConvertVectorExpr(const ConvertVectorExpr *S) {
949 VisitExpr(S);
950}
951
Chandler Carruth631abd92011-06-16 06:47:06 +0000952void StmtProfiler::VisitChooseExpr(const ChooseExpr *S) {
Douglas Gregor5c193b92009-07-28 00:33:38 +0000953 VisitExpr(S);
954}
955
Chandler Carruth631abd92011-06-16 06:47:06 +0000956void StmtProfiler::VisitGNUNullExpr(const GNUNullExpr *S) {
Douglas Gregor5c193b92009-07-28 00:33:38 +0000957 VisitExpr(S);
958}
959
Chandler Carruth631abd92011-06-16 06:47:06 +0000960void StmtProfiler::VisitVAArgExpr(const VAArgExpr *S) {
Douglas Gregor00044172009-07-29 16:09:57 +0000961 VisitExpr(S);
962}
963
Chandler Carruth631abd92011-06-16 06:47:06 +0000964void StmtProfiler::VisitInitListExpr(const InitListExpr *S) {
Douglas Gregor5c193b92009-07-28 00:33:38 +0000965 if (S->getSyntacticForm()) {
966 VisitInitListExpr(S->getSyntacticForm());
967 return;
968 }
Mike Stump11289f42009-09-09 15:08:12 +0000969
Douglas Gregor5c193b92009-07-28 00:33:38 +0000970 VisitExpr(S);
971}
972
Chandler Carruth631abd92011-06-16 06:47:06 +0000973void StmtProfiler::VisitDesignatedInitExpr(const DesignatedInitExpr *S) {
Douglas Gregor5c193b92009-07-28 00:33:38 +0000974 VisitExpr(S);
975 ID.AddBoolean(S->usesGNUSyntax());
David Majnemerf7e36092016-06-23 00:15:04 +0000976 for (const DesignatedInitExpr::Designator &D : S->designators()) {
977 if (D.isFieldDesignator()) {
Douglas Gregor5c193b92009-07-28 00:33:38 +0000978 ID.AddInteger(0);
David Majnemerf7e36092016-06-23 00:15:04 +0000979 VisitName(D.getFieldName());
Douglas Gregor5c193b92009-07-28 00:33:38 +0000980 continue;
981 }
Mike Stump11289f42009-09-09 15:08:12 +0000982
David Majnemerf7e36092016-06-23 00:15:04 +0000983 if (D.isArrayDesignator()) {
Douglas Gregor5c193b92009-07-28 00:33:38 +0000984 ID.AddInteger(1);
985 } else {
David Majnemerf7e36092016-06-23 00:15:04 +0000986 assert(D.isArrayRangeDesignator());
Douglas Gregor5c193b92009-07-28 00:33:38 +0000987 ID.AddInteger(2);
988 }
David Majnemerf7e36092016-06-23 00:15:04 +0000989 ID.AddInteger(D.getFirstExprIndex());
Douglas Gregor5c193b92009-07-28 00:33:38 +0000990 }
991}
992
Yunzhong Gaocb779302015-06-10 00:27:52 +0000993// Seems that if VisitInitListExpr() only works on the syntactic form of an
994// InitListExpr, then a DesignatedInitUpdateExpr is not encountered.
995void StmtProfiler::VisitDesignatedInitUpdateExpr(
996 const DesignatedInitUpdateExpr *S) {
997 llvm_unreachable("Unexpected DesignatedInitUpdateExpr in syntactic form of "
998 "initializer");
999}
1000
Richard Smith410306b2016-12-12 02:53:20 +00001001void StmtProfiler::VisitArrayInitLoopExpr(const ArrayInitLoopExpr *S) {
1002 VisitExpr(S);
1003}
1004
1005void StmtProfiler::VisitArrayInitIndexExpr(const ArrayInitIndexExpr *S) {
1006 VisitExpr(S);
1007}
1008
Yunzhong Gaocb779302015-06-10 00:27:52 +00001009void StmtProfiler::VisitNoInitExpr(const NoInitExpr *S) {
1010 llvm_unreachable("Unexpected NoInitExpr in syntactic form of initializer");
1011}
1012
Chandler Carruth631abd92011-06-16 06:47:06 +00001013void StmtProfiler::VisitImplicitValueInitExpr(const ImplicitValueInitExpr *S) {
Douglas Gregor5c193b92009-07-28 00:33:38 +00001014 VisitExpr(S);
1015}
1016
Chandler Carruth631abd92011-06-16 06:47:06 +00001017void StmtProfiler::VisitExtVectorElementExpr(const ExtVectorElementExpr *S) {
Douglas Gregor5c193b92009-07-28 00:33:38 +00001018 VisitExpr(S);
1019 VisitName(&S->getAccessor());
1020}
1021
Chandler Carruth631abd92011-06-16 06:47:06 +00001022void StmtProfiler::VisitBlockExpr(const BlockExpr *S) {
Douglas Gregor5c193b92009-07-28 00:33:38 +00001023 VisitExpr(S);
1024 VisitDecl(S->getBlockDecl());
1025}
1026
Chandler Carruth631abd92011-06-16 06:47:06 +00001027void StmtProfiler::VisitGenericSelectionExpr(const GenericSelectionExpr *S) {
Peter Collingbourne91147592011-04-15 00:35:48 +00001028 VisitExpr(S);
1029 for (unsigned i = 0; i != S->getNumAssocs(); ++i) {
1030 QualType T = S->getAssocType(i);
1031 if (T.isNull())
Craig Topper36250ad2014-05-12 05:36:57 +00001032 ID.AddPointer(nullptr);
Peter Collingbourne91147592011-04-15 00:35:48 +00001033 else
1034 VisitType(T);
1035 VisitExpr(S->getAssocExpr(i));
1036 }
1037}
1038
John McCallfe96e0b2011-11-06 09:01:30 +00001039void StmtProfiler::VisitPseudoObjectExpr(const PseudoObjectExpr *S) {
1040 VisitExpr(S);
1041 for (PseudoObjectExpr::const_semantics_iterator
1042 i = S->semantics_begin(), e = S->semantics_end(); i != e; ++i)
1043 // Normally, we would not profile the source expressions of OVEs.
1044 if (const OpaqueValueExpr *OVE = dyn_cast<OpaqueValueExpr>(*i))
1045 Visit(OVE->getSourceExpr());
1046}
1047
Eli Friedmandf14b3a2011-10-11 02:20:01 +00001048void StmtProfiler::VisitAtomicExpr(const AtomicExpr *S) {
1049 VisitExpr(S);
Eli Friedman4b72fdd2011-10-14 20:59:01 +00001050 ID.AddInteger(S->getOp());
Eli Friedmandf14b3a2011-10-11 02:20:01 +00001051}
1052
Chandler Carruth631abd92011-06-16 06:47:06 +00001053static Stmt::StmtClass DecodeOperatorCall(const CXXOperatorCallExpr *S,
John McCalle3027922010-08-25 11:45:40 +00001054 UnaryOperatorKind &UnaryOp,
1055 BinaryOperatorKind &BinaryOp) {
Douglas Gregore9ceb312010-05-19 04:13:23 +00001056 switch (S->getOperator()) {
1057 case OO_None:
1058 case OO_New:
1059 case OO_Delete:
1060 case OO_Array_New:
1061 case OO_Array_Delete:
1062 case OO_Arrow:
1063 case OO_Call:
1064 case OO_Conditional:
Richard Smith9be594e2015-10-22 05:12:22 +00001065 case OO_Coawait:
Douglas Gregore9ceb312010-05-19 04:13:23 +00001066 case NUM_OVERLOADED_OPERATORS:
1067 llvm_unreachable("Invalid operator call kind");
Douglas Gregore9ceb312010-05-19 04:13:23 +00001068
1069 case OO_Plus:
1070 if (S->getNumArgs() == 1) {
John McCalle3027922010-08-25 11:45:40 +00001071 UnaryOp = UO_Plus;
Douglas Gregore9ceb312010-05-19 04:13:23 +00001072 return Stmt::UnaryOperatorClass;
1073 }
1074
John McCalle3027922010-08-25 11:45:40 +00001075 BinaryOp = BO_Add;
Douglas Gregore9ceb312010-05-19 04:13:23 +00001076 return Stmt::BinaryOperatorClass;
1077
1078 case OO_Minus:
1079 if (S->getNumArgs() == 1) {
John McCalle3027922010-08-25 11:45:40 +00001080 UnaryOp = UO_Minus;
Douglas Gregore9ceb312010-05-19 04:13:23 +00001081 return Stmt::UnaryOperatorClass;
1082 }
1083
John McCalle3027922010-08-25 11:45:40 +00001084 BinaryOp = BO_Sub;
Douglas Gregore9ceb312010-05-19 04:13:23 +00001085 return Stmt::BinaryOperatorClass;
1086
1087 case OO_Star:
1088 if (S->getNumArgs() == 1) {
Richard Smithf15acc52014-06-05 22:43:40 +00001089 UnaryOp = UO_Deref;
Douglas Gregore9ceb312010-05-19 04:13:23 +00001090 return Stmt::UnaryOperatorClass;
1091 }
1092
Richard Smithf15acc52014-06-05 22:43:40 +00001093 BinaryOp = BO_Mul;
Douglas Gregore9ceb312010-05-19 04:13:23 +00001094 return Stmt::BinaryOperatorClass;
1095
1096 case OO_Slash:
John McCalle3027922010-08-25 11:45:40 +00001097 BinaryOp = BO_Div;
Douglas Gregore9ceb312010-05-19 04:13:23 +00001098 return Stmt::BinaryOperatorClass;
1099
1100 case OO_Percent:
John McCalle3027922010-08-25 11:45:40 +00001101 BinaryOp = BO_Rem;
Douglas Gregore9ceb312010-05-19 04:13:23 +00001102 return Stmt::BinaryOperatorClass;
1103
1104 case OO_Caret:
John McCalle3027922010-08-25 11:45:40 +00001105 BinaryOp = BO_Xor;
Douglas Gregore9ceb312010-05-19 04:13:23 +00001106 return Stmt::BinaryOperatorClass;
1107
1108 case OO_Amp:
1109 if (S->getNumArgs() == 1) {
John McCalle3027922010-08-25 11:45:40 +00001110 UnaryOp = UO_AddrOf;
Douglas Gregore9ceb312010-05-19 04:13:23 +00001111 return Stmt::UnaryOperatorClass;
1112 }
1113
John McCalle3027922010-08-25 11:45:40 +00001114 BinaryOp = BO_And;
Douglas Gregore9ceb312010-05-19 04:13:23 +00001115 return Stmt::BinaryOperatorClass;
1116
1117 case OO_Pipe:
John McCalle3027922010-08-25 11:45:40 +00001118 BinaryOp = BO_Or;
Douglas Gregore9ceb312010-05-19 04:13:23 +00001119 return Stmt::BinaryOperatorClass;
1120
1121 case OO_Tilde:
John McCalle3027922010-08-25 11:45:40 +00001122 UnaryOp = UO_Not;
Douglas Gregore9ceb312010-05-19 04:13:23 +00001123 return Stmt::UnaryOperatorClass;
1124
1125 case OO_Exclaim:
John McCalle3027922010-08-25 11:45:40 +00001126 UnaryOp = UO_LNot;
Douglas Gregore9ceb312010-05-19 04:13:23 +00001127 return Stmt::UnaryOperatorClass;
1128
1129 case OO_Equal:
John McCalle3027922010-08-25 11:45:40 +00001130 BinaryOp = BO_Assign;
Douglas Gregore9ceb312010-05-19 04:13:23 +00001131 return Stmt::BinaryOperatorClass;
1132
1133 case OO_Less:
John McCalle3027922010-08-25 11:45:40 +00001134 BinaryOp = BO_LT;
Douglas Gregore9ceb312010-05-19 04:13:23 +00001135 return Stmt::BinaryOperatorClass;
1136
1137 case OO_Greater:
John McCalle3027922010-08-25 11:45:40 +00001138 BinaryOp = BO_GT;
Douglas Gregore9ceb312010-05-19 04:13:23 +00001139 return Stmt::BinaryOperatorClass;
1140
1141 case OO_PlusEqual:
John McCalle3027922010-08-25 11:45:40 +00001142 BinaryOp = BO_AddAssign;
Douglas Gregore9ceb312010-05-19 04:13:23 +00001143 return Stmt::CompoundAssignOperatorClass;
1144
1145 case OO_MinusEqual:
John McCalle3027922010-08-25 11:45:40 +00001146 BinaryOp = BO_SubAssign;
Douglas Gregore9ceb312010-05-19 04:13:23 +00001147 return Stmt::CompoundAssignOperatorClass;
1148
1149 case OO_StarEqual:
John McCalle3027922010-08-25 11:45:40 +00001150 BinaryOp = BO_MulAssign;
Douglas Gregore9ceb312010-05-19 04:13:23 +00001151 return Stmt::CompoundAssignOperatorClass;
1152
1153 case OO_SlashEqual:
John McCalle3027922010-08-25 11:45:40 +00001154 BinaryOp = BO_DivAssign;
Douglas Gregore9ceb312010-05-19 04:13:23 +00001155 return Stmt::CompoundAssignOperatorClass;
1156
1157 case OO_PercentEqual:
John McCalle3027922010-08-25 11:45:40 +00001158 BinaryOp = BO_RemAssign;
Douglas Gregore9ceb312010-05-19 04:13:23 +00001159 return Stmt::CompoundAssignOperatorClass;
1160
1161 case OO_CaretEqual:
John McCalle3027922010-08-25 11:45:40 +00001162 BinaryOp = BO_XorAssign;
Douglas Gregore9ceb312010-05-19 04:13:23 +00001163 return Stmt::CompoundAssignOperatorClass;
1164
1165 case OO_AmpEqual:
John McCalle3027922010-08-25 11:45:40 +00001166 BinaryOp = BO_AndAssign;
Douglas Gregore9ceb312010-05-19 04:13:23 +00001167 return Stmt::CompoundAssignOperatorClass;
1168
1169 case OO_PipeEqual:
John McCalle3027922010-08-25 11:45:40 +00001170 BinaryOp = BO_OrAssign;
Douglas Gregore9ceb312010-05-19 04:13:23 +00001171 return Stmt::CompoundAssignOperatorClass;
1172
1173 case OO_LessLess:
John McCalle3027922010-08-25 11:45:40 +00001174 BinaryOp = BO_Shl;
Douglas Gregore9ceb312010-05-19 04:13:23 +00001175 return Stmt::BinaryOperatorClass;
1176
1177 case OO_GreaterGreater:
John McCalle3027922010-08-25 11:45:40 +00001178 BinaryOp = BO_Shr;
Douglas Gregore9ceb312010-05-19 04:13:23 +00001179 return Stmt::BinaryOperatorClass;
1180
1181 case OO_LessLessEqual:
John McCalle3027922010-08-25 11:45:40 +00001182 BinaryOp = BO_ShlAssign;
Douglas Gregore9ceb312010-05-19 04:13:23 +00001183 return Stmt::CompoundAssignOperatorClass;
1184
1185 case OO_GreaterGreaterEqual:
John McCalle3027922010-08-25 11:45:40 +00001186 BinaryOp = BO_ShrAssign;
Douglas Gregore9ceb312010-05-19 04:13:23 +00001187 return Stmt::CompoundAssignOperatorClass;
1188
1189 case OO_EqualEqual:
John McCalle3027922010-08-25 11:45:40 +00001190 BinaryOp = BO_EQ;
Douglas Gregore9ceb312010-05-19 04:13:23 +00001191 return Stmt::BinaryOperatorClass;
1192
1193 case OO_ExclaimEqual:
John McCalle3027922010-08-25 11:45:40 +00001194 BinaryOp = BO_NE;
Douglas Gregore9ceb312010-05-19 04:13:23 +00001195 return Stmt::BinaryOperatorClass;
1196
1197 case OO_LessEqual:
John McCalle3027922010-08-25 11:45:40 +00001198 BinaryOp = BO_LE;
Douglas Gregore9ceb312010-05-19 04:13:23 +00001199 return Stmt::BinaryOperatorClass;
1200
1201 case OO_GreaterEqual:
John McCalle3027922010-08-25 11:45:40 +00001202 BinaryOp = BO_GE;
Douglas Gregore9ceb312010-05-19 04:13:23 +00001203 return Stmt::BinaryOperatorClass;
1204
1205 case OO_AmpAmp:
John McCalle3027922010-08-25 11:45:40 +00001206 BinaryOp = BO_LAnd;
Douglas Gregore9ceb312010-05-19 04:13:23 +00001207 return Stmt::BinaryOperatorClass;
1208
1209 case OO_PipePipe:
John McCalle3027922010-08-25 11:45:40 +00001210 BinaryOp = BO_LOr;
Douglas Gregore9ceb312010-05-19 04:13:23 +00001211 return Stmt::BinaryOperatorClass;
1212
1213 case OO_PlusPlus:
John McCalle3027922010-08-25 11:45:40 +00001214 UnaryOp = S->getNumArgs() == 1? UO_PreInc
1215 : UO_PostInc;
Douglas Gregore9ceb312010-05-19 04:13:23 +00001216 return Stmt::UnaryOperatorClass;
1217
1218 case OO_MinusMinus:
John McCalle3027922010-08-25 11:45:40 +00001219 UnaryOp = S->getNumArgs() == 1? UO_PreDec
1220 : UO_PostDec;
Douglas Gregore9ceb312010-05-19 04:13:23 +00001221 return Stmt::UnaryOperatorClass;
1222
1223 case OO_Comma:
John McCalle3027922010-08-25 11:45:40 +00001224 BinaryOp = BO_Comma;
Douglas Gregore9ceb312010-05-19 04:13:23 +00001225 return Stmt::BinaryOperatorClass;
1226
Douglas Gregore9ceb312010-05-19 04:13:23 +00001227 case OO_ArrowStar:
John McCalle3027922010-08-25 11:45:40 +00001228 BinaryOp = BO_PtrMemI;
Douglas Gregore9ceb312010-05-19 04:13:23 +00001229 return Stmt::BinaryOperatorClass;
1230
1231 case OO_Subscript:
1232 return Stmt::ArraySubscriptExprClass;
1233 }
1234
1235 llvm_unreachable("Invalid overloaded operator expression");
1236}
Richard Smithf15acc52014-06-05 22:43:40 +00001237
Chandler Carruth631abd92011-06-16 06:47:06 +00001238void StmtProfiler::VisitCXXOperatorCallExpr(const CXXOperatorCallExpr *S) {
Douglas Gregore9ceb312010-05-19 04:13:23 +00001239 if (S->isTypeDependent()) {
1240 // Type-dependent operator calls are profiled like their underlying
1241 // syntactic operator.
Richard Smithbac0a0d2016-10-24 18:47:04 +00001242 //
1243 // An operator call to operator-> is always implicit, so just skip it. The
1244 // enclosing MemberExpr will profile the actual member access.
1245 if (S->getOperator() == OO_Arrow)
1246 return Visit(S->getArg(0));
1247
John McCalle3027922010-08-25 11:45:40 +00001248 UnaryOperatorKind UnaryOp = UO_Extension;
1249 BinaryOperatorKind BinaryOp = BO_Comma;
Douglas Gregore9ceb312010-05-19 04:13:23 +00001250 Stmt::StmtClass SC = DecodeOperatorCall(S, UnaryOp, BinaryOp);
Richard Smithf15acc52014-06-05 22:43:40 +00001251
Douglas Gregore9ceb312010-05-19 04:13:23 +00001252 ID.AddInteger(SC);
1253 for (unsigned I = 0, N = S->getNumArgs(); I != N; ++I)
1254 Visit(S->getArg(I));
1255 if (SC == Stmt::UnaryOperatorClass)
1256 ID.AddInteger(UnaryOp);
1257 else if (SC == Stmt::BinaryOperatorClass ||
1258 SC == Stmt::CompoundAssignOperatorClass)
1259 ID.AddInteger(BinaryOp);
1260 else
1261 assert(SC == Stmt::ArraySubscriptExprClass);
Richard Smithf15acc52014-06-05 22:43:40 +00001262
Douglas Gregore9ceb312010-05-19 04:13:23 +00001263 return;
1264 }
Richard Smithf15acc52014-06-05 22:43:40 +00001265
Douglas Gregor5c193b92009-07-28 00:33:38 +00001266 VisitCallExpr(S);
1267 ID.AddInteger(S->getOperator());
1268}
1269
Chandler Carruth631abd92011-06-16 06:47:06 +00001270void StmtProfiler::VisitCXXMemberCallExpr(const CXXMemberCallExpr *S) {
Douglas Gregor5c193b92009-07-28 00:33:38 +00001271 VisitCallExpr(S);
1272}
1273
Chandler Carruth631abd92011-06-16 06:47:06 +00001274void StmtProfiler::VisitCUDAKernelCallExpr(const CUDAKernelCallExpr *S) {
Peter Collingbourne41f85462011-02-09 21:07:24 +00001275 VisitCallExpr(S);
1276}
1277
Chandler Carruth631abd92011-06-16 06:47:06 +00001278void StmtProfiler::VisitAsTypeExpr(const AsTypeExpr *S) {
Tanya Lattner55808c12011-06-04 00:47:47 +00001279 VisitExpr(S);
1280}
1281
Chandler Carruth631abd92011-06-16 06:47:06 +00001282void StmtProfiler::VisitCXXNamedCastExpr(const CXXNamedCastExpr *S) {
Douglas Gregor5c193b92009-07-28 00:33:38 +00001283 VisitExplicitCastExpr(S);
1284}
1285
Chandler Carruth631abd92011-06-16 06:47:06 +00001286void StmtProfiler::VisitCXXStaticCastExpr(const CXXStaticCastExpr *S) {
Douglas Gregor5c193b92009-07-28 00:33:38 +00001287 VisitCXXNamedCastExpr(S);
1288}
1289
Chandler Carruth631abd92011-06-16 06:47:06 +00001290void StmtProfiler::VisitCXXDynamicCastExpr(const CXXDynamicCastExpr *S) {
Douglas Gregor5c193b92009-07-28 00:33:38 +00001291 VisitCXXNamedCastExpr(S);
1292}
1293
Chandler Carruth631abd92011-06-16 06:47:06 +00001294void
1295StmtProfiler::VisitCXXReinterpretCastExpr(const CXXReinterpretCastExpr *S) {
Douglas Gregor5c193b92009-07-28 00:33:38 +00001296 VisitCXXNamedCastExpr(S);
1297}
1298
Chandler Carruth631abd92011-06-16 06:47:06 +00001299void StmtProfiler::VisitCXXConstCastExpr(const CXXConstCastExpr *S) {
Douglas Gregor5c193b92009-07-28 00:33:38 +00001300 VisitCXXNamedCastExpr(S);
1301}
1302
Richard Smithc67fdd42012-03-07 08:35:16 +00001303void StmtProfiler::VisitUserDefinedLiteral(const UserDefinedLiteral *S) {
1304 VisitCallExpr(S);
1305}
1306
Chandler Carruth631abd92011-06-16 06:47:06 +00001307void StmtProfiler::VisitCXXBoolLiteralExpr(const CXXBoolLiteralExpr *S) {
Douglas Gregor5c193b92009-07-28 00:33:38 +00001308 VisitExpr(S);
1309 ID.AddBoolean(S->getValue());
1310}
1311
Chandler Carruth631abd92011-06-16 06:47:06 +00001312void StmtProfiler::VisitCXXNullPtrLiteralExpr(const CXXNullPtrLiteralExpr *S) {
Douglas Gregor00044172009-07-29 16:09:57 +00001313 VisitExpr(S);
1314}
1315
Richard Smithcc1b96d2013-06-12 22:31:48 +00001316void StmtProfiler::VisitCXXStdInitializerListExpr(
1317 const CXXStdInitializerListExpr *S) {
1318 VisitExpr(S);
1319}
1320
Chandler Carruth631abd92011-06-16 06:47:06 +00001321void StmtProfiler::VisitCXXTypeidExpr(const CXXTypeidExpr *S) {
Douglas Gregor5c193b92009-07-28 00:33:38 +00001322 VisitExpr(S);
1323 if (S->isTypeOperand())
David Majnemer143c55e2013-09-27 07:04:31 +00001324 VisitType(S->getTypeOperandSourceInfo()->getType());
Douglas Gregor5c193b92009-07-28 00:33:38 +00001325}
1326
Chandler Carruth631abd92011-06-16 06:47:06 +00001327void StmtProfiler::VisitCXXUuidofExpr(const CXXUuidofExpr *S) {
Francois Pichet9f4f2072010-09-08 12:20:18 +00001328 VisitExpr(S);
1329 if (S->isTypeOperand())
David Majnemer143c55e2013-09-27 07:04:31 +00001330 VisitType(S->getTypeOperandSourceInfo()->getType());
Francois Pichet9f4f2072010-09-08 12:20:18 +00001331}
1332
John McCall5e77d762013-04-16 07:28:30 +00001333void StmtProfiler::VisitMSPropertyRefExpr(const MSPropertyRefExpr *S) {
1334 VisitExpr(S);
1335 VisitDecl(S->getPropertyDecl());
1336}
1337
Alexey Bataevf7630272015-11-25 12:01:00 +00001338void StmtProfiler::VisitMSPropertySubscriptExpr(
1339 const MSPropertySubscriptExpr *S) {
1340 VisitExpr(S);
1341}
1342
Chandler Carruth631abd92011-06-16 06:47:06 +00001343void StmtProfiler::VisitCXXThisExpr(const CXXThisExpr *S) {
Douglas Gregor5c193b92009-07-28 00:33:38 +00001344 VisitExpr(S);
Douglas Gregor3024f072012-04-16 07:05:22 +00001345 ID.AddBoolean(S->isImplicit());
Douglas Gregor5c193b92009-07-28 00:33:38 +00001346}
1347
Chandler Carruth631abd92011-06-16 06:47:06 +00001348void StmtProfiler::VisitCXXThrowExpr(const CXXThrowExpr *S) {
Douglas Gregor5c193b92009-07-28 00:33:38 +00001349 VisitExpr(S);
1350}
1351
Chandler Carruth631abd92011-06-16 06:47:06 +00001352void StmtProfiler::VisitCXXDefaultArgExpr(const CXXDefaultArgExpr *S) {
Douglas Gregor5c193b92009-07-28 00:33:38 +00001353 VisitExpr(S);
1354 VisitDecl(S->getParam());
1355}
1356
Richard Smith852c9db2013-04-20 22:23:05 +00001357void StmtProfiler::VisitCXXDefaultInitExpr(const CXXDefaultInitExpr *S) {
1358 VisitExpr(S);
1359 VisitDecl(S->getField());
1360}
1361
Chandler Carruth631abd92011-06-16 06:47:06 +00001362void StmtProfiler::VisitCXXBindTemporaryExpr(const CXXBindTemporaryExpr *S) {
Douglas Gregor5c193b92009-07-28 00:33:38 +00001363 VisitExpr(S);
1364 VisitDecl(
1365 const_cast<CXXDestructorDecl *>(S->getTemporary()->getDestructor()));
1366}
1367
Chandler Carruth631abd92011-06-16 06:47:06 +00001368void StmtProfiler::VisitCXXConstructExpr(const CXXConstructExpr *S) {
Douglas Gregor5c193b92009-07-28 00:33:38 +00001369 VisitExpr(S);
1370 VisitDecl(S->getConstructor());
1371 ID.AddBoolean(S->isElidable());
1372}
1373
Richard Smith5179eb72016-06-28 19:03:57 +00001374void StmtProfiler::VisitCXXInheritedCtorInitExpr(
1375 const CXXInheritedCtorInitExpr *S) {
1376 VisitExpr(S);
1377 VisitDecl(S->getConstructor());
1378}
1379
Chandler Carruth631abd92011-06-16 06:47:06 +00001380void StmtProfiler::VisitCXXFunctionalCastExpr(const CXXFunctionalCastExpr *S) {
Douglas Gregor5c193b92009-07-28 00:33:38 +00001381 VisitExplicitCastExpr(S);
1382}
1383
Chandler Carruth631abd92011-06-16 06:47:06 +00001384void
1385StmtProfiler::VisitCXXTemporaryObjectExpr(const CXXTemporaryObjectExpr *S) {
Douglas Gregor5c193b92009-07-28 00:33:38 +00001386 VisitCXXConstructExpr(S);
1387}
1388
Chandler Carruth631abd92011-06-16 06:47:06 +00001389void
Douglas Gregore31e6062012-02-07 10:09:13 +00001390StmtProfiler::VisitLambdaExpr(const LambdaExpr *S) {
1391 VisitExpr(S);
1392 for (LambdaExpr::capture_iterator C = S->explicit_capture_begin(),
1393 CEnd = S->explicit_capture_end();
1394 C != CEnd; ++C) {
1395 ID.AddInteger(C->getCaptureKind());
Richard Smithba71c082013-05-16 06:20:58 +00001396 switch (C->getCaptureKind()) {
Faisal Validc6b5962016-03-21 09:25:37 +00001397 case LCK_StarThis:
Richard Smithba71c082013-05-16 06:20:58 +00001398 case LCK_This:
1399 break;
1400 case LCK_ByRef:
1401 case LCK_ByCopy:
Douglas Gregore31e6062012-02-07 10:09:13 +00001402 VisitDecl(C->getCapturedVar());
1403 ID.AddBoolean(C->isPackExpansion());
Richard Smithba71c082013-05-16 06:20:58 +00001404 break;
Alexey Bataev39c81e22014-08-28 04:28:19 +00001405 case LCK_VLAType:
1406 llvm_unreachable("VLA type in explicit captures.");
Douglas Gregore31e6062012-02-07 10:09:13 +00001407 }
1408 }
1409 // Note: If we actually needed to be able to match lambda
1410 // expressions, we would have to consider parameters and return type
1411 // here, among other things.
1412 VisitStmt(S->getBody());
1413}
1414
1415void
Chandler Carruth631abd92011-06-16 06:47:06 +00001416StmtProfiler::VisitCXXScalarValueInitExpr(const CXXScalarValueInitExpr *S) {
Douglas Gregor5c193b92009-07-28 00:33:38 +00001417 VisitExpr(S);
1418}
1419
Chandler Carruth631abd92011-06-16 06:47:06 +00001420void StmtProfiler::VisitCXXDeleteExpr(const CXXDeleteExpr *S) {
Douglas Gregor5c193b92009-07-28 00:33:38 +00001421 VisitExpr(S);
1422 ID.AddBoolean(S->isGlobalDelete());
1423 ID.AddBoolean(S->isArrayForm());
1424 VisitDecl(S->getOperatorDelete());
1425}
1426
Chandler Carruth631abd92011-06-16 06:47:06 +00001427void StmtProfiler::VisitCXXNewExpr(const CXXNewExpr *S) {
Douglas Gregor5c193b92009-07-28 00:33:38 +00001428 VisitExpr(S);
1429 VisitType(S->getAllocatedType());
1430 VisitDecl(S->getOperatorNew());
1431 VisitDecl(S->getOperatorDelete());
Douglas Gregor5c193b92009-07-28 00:33:38 +00001432 ID.AddBoolean(S->isArray());
1433 ID.AddInteger(S->getNumPlacementArgs());
1434 ID.AddBoolean(S->isGlobalNew());
1435 ID.AddBoolean(S->isParenTypeId());
Sebastian Redl6047f072012-02-16 12:22:20 +00001436 ID.AddInteger(S->getInitializationStyle());
Douglas Gregor5c193b92009-07-28 00:33:38 +00001437}
1438
Chandler Carruth631abd92011-06-16 06:47:06 +00001439void
1440StmtProfiler::VisitCXXPseudoDestructorExpr(const CXXPseudoDestructorExpr *S) {
Douglas Gregorad8a3362009-09-04 17:36:40 +00001441 VisitExpr(S);
1442 ID.AddBoolean(S->isArrow());
1443 VisitNestedNameSpecifier(S->getQualifier());
Craig Topper36250ad2014-05-12 05:36:57 +00001444 ID.AddBoolean(S->getScopeTypeInfo() != nullptr);
Eli Friedman85641392013-08-09 23:37:05 +00001445 if (S->getScopeTypeInfo())
1446 VisitType(S->getScopeTypeInfo()->getType());
Craig Topper36250ad2014-05-12 05:36:57 +00001447 ID.AddBoolean(S->getDestroyedTypeInfo() != nullptr);
Eli Friedman85641392013-08-09 23:37:05 +00001448 if (S->getDestroyedTypeInfo())
1449 VisitType(S->getDestroyedType());
1450 else
1451 ID.AddPointer(S->getDestroyedTypeIdentifier());
Douglas Gregorad8a3362009-09-04 17:36:40 +00001452}
1453
Chandler Carruth631abd92011-06-16 06:47:06 +00001454void StmtProfiler::VisitOverloadExpr(const OverloadExpr *S) {
Argyrios Kyrtzidisb482eb82010-08-15 20:53:20 +00001455 VisitExpr(S);
John McCalle66edc12009-11-24 19:00:30 +00001456 VisitNestedNameSpecifier(S->getQualifier());
Douglas Gregor5c193b92009-07-28 00:33:38 +00001457 VisitName(S->getName());
John McCalle66edc12009-11-24 19:00:30 +00001458 ID.AddBoolean(S->hasExplicitTemplateArgs());
1459 if (S->hasExplicitTemplateArgs())
James Y Knight04ec5bf2015-12-24 02:59:37 +00001460 VisitTemplateArguments(S->getTemplateArgs(), S->getNumTemplateArgs());
Argyrios Kyrtzidisf4505452010-08-15 01:15:38 +00001461}
1462
1463void
Chandler Carruth631abd92011-06-16 06:47:06 +00001464StmtProfiler::VisitUnresolvedLookupExpr(const UnresolvedLookupExpr *S) {
Argyrios Kyrtzidisf4505452010-08-15 01:15:38 +00001465 VisitOverloadExpr(S);
Douglas Gregor5c193b92009-07-28 00:33:38 +00001466}
1467
Douglas Gregor29c42f22012-02-24 07:38:34 +00001468void StmtProfiler::VisitTypeTraitExpr(const TypeTraitExpr *S) {
1469 VisitExpr(S);
1470 ID.AddInteger(S->getTrait());
1471 ID.AddInteger(S->getNumArgs());
1472 for (unsigned I = 0, N = S->getNumArgs(); I != N; ++I)
1473 VisitType(S->getArg(I)->getType());
1474}
1475
Chandler Carruth631abd92011-06-16 06:47:06 +00001476void StmtProfiler::VisitArrayTypeTraitExpr(const ArrayTypeTraitExpr *S) {
John Wiegley6242b6a2011-04-28 00:16:57 +00001477 VisitExpr(S);
1478 ID.AddInteger(S->getTrait());
1479 VisitType(S->getQueriedType());
1480}
1481
Chandler Carruth631abd92011-06-16 06:47:06 +00001482void StmtProfiler::VisitExpressionTraitExpr(const ExpressionTraitExpr *S) {
John Wiegleyf9f65842011-04-25 06:54:41 +00001483 VisitExpr(S);
1484 ID.AddInteger(S->getTrait());
1485 VisitExpr(S->getQueriedExpression());
1486}
1487
Chandler Carruth631abd92011-06-16 06:47:06 +00001488void StmtProfiler::VisitDependentScopeDeclRefExpr(
1489 const DependentScopeDeclRefExpr *S) {
Douglas Gregor5c193b92009-07-28 00:33:38 +00001490 VisitExpr(S);
1491 VisitName(S->getDeclName());
1492 VisitNestedNameSpecifier(S->getQualifier());
John McCalle66edc12009-11-24 19:00:30 +00001493 ID.AddBoolean(S->hasExplicitTemplateArgs());
1494 if (S->hasExplicitTemplateArgs())
1495 VisitTemplateArguments(S->getTemplateArgs(), S->getNumTemplateArgs());
Douglas Gregor5c193b92009-07-28 00:33:38 +00001496}
1497
Chandler Carruth631abd92011-06-16 06:47:06 +00001498void StmtProfiler::VisitExprWithCleanups(const ExprWithCleanups *S) {
Douglas Gregora7095092009-07-28 14:44:31 +00001499 VisitExpr(S);
Douglas Gregora7095092009-07-28 14:44:31 +00001500}
1501
Chandler Carruth631abd92011-06-16 06:47:06 +00001502void StmtProfiler::VisitCXXUnresolvedConstructExpr(
1503 const CXXUnresolvedConstructExpr *S) {
Douglas Gregora7095092009-07-28 14:44:31 +00001504 VisitExpr(S);
1505 VisitType(S->getTypeAsWritten());
1506}
1507
Chandler Carruth631abd92011-06-16 06:47:06 +00001508void StmtProfiler::VisitCXXDependentScopeMemberExpr(
1509 const CXXDependentScopeMemberExpr *S) {
John McCall2d74de92009-12-01 22:10:20 +00001510 ID.AddBoolean(S->isImplicitAccess());
1511 if (!S->isImplicitAccess()) {
1512 VisitExpr(S);
1513 ID.AddBoolean(S->isArrow());
1514 }
Douglas Gregorc26e0f62009-09-03 16:14:30 +00001515 VisitNestedNameSpecifier(S->getQualifier());
Douglas Gregora7095092009-07-28 14:44:31 +00001516 VisitName(S->getMember());
John McCall2d74de92009-12-01 22:10:20 +00001517 ID.AddBoolean(S->hasExplicitTemplateArgs());
1518 if (S->hasExplicitTemplateArgs())
John McCall10eae182009-11-30 22:42:35 +00001519 VisitTemplateArguments(S->getTemplateArgs(), S->getNumTemplateArgs());
1520}
1521
Chandler Carruth631abd92011-06-16 06:47:06 +00001522void StmtProfiler::VisitUnresolvedMemberExpr(const UnresolvedMemberExpr *S) {
John McCall2d74de92009-12-01 22:10:20 +00001523 ID.AddBoolean(S->isImplicitAccess());
1524 if (!S->isImplicitAccess()) {
1525 VisitExpr(S);
1526 ID.AddBoolean(S->isArrow());
1527 }
John McCall10eae182009-11-30 22:42:35 +00001528 VisitNestedNameSpecifier(S->getQualifier());
1529 VisitName(S->getMemberName());
1530 ID.AddBoolean(S->hasExplicitTemplateArgs());
1531 if (S->hasExplicitTemplateArgs())
1532 VisitTemplateArguments(S->getTemplateArgs(), S->getNumTemplateArgs());
Douglas Gregora7095092009-07-28 14:44:31 +00001533}
1534
Chandler Carruth631abd92011-06-16 06:47:06 +00001535void StmtProfiler::VisitCXXNoexceptExpr(const CXXNoexceptExpr *S) {
Sebastian Redl4202c0f2010-09-10 20:55:43 +00001536 VisitExpr(S);
1537}
1538
Chandler Carruth631abd92011-06-16 06:47:06 +00001539void StmtProfiler::VisitPackExpansionExpr(const PackExpansionExpr *S) {
Douglas Gregore8e9dd62011-01-03 17:17:50 +00001540 VisitExpr(S);
1541}
1542
Chandler Carruth631abd92011-06-16 06:47:06 +00001543void StmtProfiler::VisitSizeOfPackExpr(const SizeOfPackExpr *S) {
Douglas Gregor820ba7b2011-01-04 17:33:58 +00001544 VisitExpr(S);
1545 VisitDecl(S->getPack());
Richard Smithd784e682015-09-23 21:41:42 +00001546 if (S->isPartiallySubstituted()) {
1547 auto Args = S->getPartialArguments();
1548 ID.AddInteger(Args.size());
1549 for (const auto &TA : Args)
1550 VisitTemplateArgument(TA);
1551 } else {
1552 ID.AddInteger(0);
1553 }
Douglas Gregor820ba7b2011-01-04 17:33:58 +00001554}
1555
Douglas Gregorcdbc5392011-01-15 01:15:58 +00001556void StmtProfiler::VisitSubstNonTypeTemplateParmPackExpr(
Chandler Carruth631abd92011-06-16 06:47:06 +00001557 const SubstNonTypeTemplateParmPackExpr *S) {
Douglas Gregorcdbc5392011-01-15 01:15:58 +00001558 VisitExpr(S);
1559 VisitDecl(S->getParameterPack());
1560 VisitTemplateArgument(S->getArgumentPack());
1561}
1562
John McCall7c454bb2011-07-15 05:09:51 +00001563void StmtProfiler::VisitSubstNonTypeTemplateParmExpr(
1564 const SubstNonTypeTemplateParmExpr *E) {
1565 // Profile exactly as the replacement expression.
1566 Visit(E->getReplacement());
1567}
1568
Richard Smithb15fe3a2012-09-12 00:56:43 +00001569void StmtProfiler::VisitFunctionParmPackExpr(const FunctionParmPackExpr *S) {
1570 VisitExpr(S);
1571 VisitDecl(S->getParameterPack());
1572 ID.AddInteger(S->getNumExpansions());
1573 for (FunctionParmPackExpr::iterator I = S->begin(), E = S->end(); I != E; ++I)
1574 VisitDecl(*I);
1575}
1576
Douglas Gregorfe314812011-06-21 17:03:29 +00001577void StmtProfiler::VisitMaterializeTemporaryExpr(
1578 const MaterializeTemporaryExpr *S) {
1579 VisitExpr(S);
1580}
1581
Richard Smith0f0af192014-11-08 05:07:16 +00001582void StmtProfiler::VisitCXXFoldExpr(const CXXFoldExpr *S) {
1583 VisitExpr(S);
1584 ID.AddInteger(S->getOperator());
1585}
1586
Richard Smith9f690bd2015-10-27 06:02:45 +00001587void StmtProfiler::VisitCoroutineBodyStmt(const CoroutineBodyStmt *S) {
1588 VisitStmt(S);
1589}
1590
1591void StmtProfiler::VisitCoreturnStmt(const CoreturnStmt *S) {
1592 VisitStmt(S);
1593}
1594
1595void StmtProfiler::VisitCoawaitExpr(const CoawaitExpr *S) {
1596 VisitExpr(S);
1597}
1598
1599void StmtProfiler::VisitCoyieldExpr(const CoyieldExpr *S) {
1600 VisitExpr(S);
1601}
1602
Chandler Carruth631abd92011-06-16 06:47:06 +00001603void StmtProfiler::VisitOpaqueValueExpr(const OpaqueValueExpr *E) {
John McCall8d69a212010-11-15 23:31:06 +00001604 VisitExpr(E);
1605}
1606
Kaelyn Takatae1f49d52014-10-27 18:07:20 +00001607void StmtProfiler::VisitTypoExpr(const TypoExpr *E) {
1608 VisitExpr(E);
1609}
1610
Chandler Carruth631abd92011-06-16 06:47:06 +00001611void StmtProfiler::VisitObjCStringLiteral(const ObjCStringLiteral *S) {
Douglas Gregora7095092009-07-28 14:44:31 +00001612 VisitExpr(S);
1613}
1614
Patrick Beard0caa3942012-04-19 00:25:12 +00001615void StmtProfiler::VisitObjCBoxedExpr(const ObjCBoxedExpr *E) {
Ted Kremeneke65b0862012-03-06 20:05:56 +00001616 VisitExpr(E);
1617}
1618
1619void StmtProfiler::VisitObjCArrayLiteral(const ObjCArrayLiteral *E) {
1620 VisitExpr(E);
1621}
1622
1623void StmtProfiler::VisitObjCDictionaryLiteral(const ObjCDictionaryLiteral *E) {
1624 VisitExpr(E);
1625}
1626
Chandler Carruth631abd92011-06-16 06:47:06 +00001627void StmtProfiler::VisitObjCEncodeExpr(const ObjCEncodeExpr *S) {
Douglas Gregora7095092009-07-28 14:44:31 +00001628 VisitExpr(S);
1629 VisitType(S->getEncodedType());
1630}
1631
Chandler Carruth631abd92011-06-16 06:47:06 +00001632void StmtProfiler::VisitObjCSelectorExpr(const ObjCSelectorExpr *S) {
Douglas Gregora7095092009-07-28 14:44:31 +00001633 VisitExpr(S);
1634 VisitName(S->getSelector());
1635}
1636
Chandler Carruth631abd92011-06-16 06:47:06 +00001637void StmtProfiler::VisitObjCProtocolExpr(const ObjCProtocolExpr *S) {
Douglas Gregora7095092009-07-28 14:44:31 +00001638 VisitExpr(S);
1639 VisitDecl(S->getProtocol());
1640}
1641
Chandler Carruth631abd92011-06-16 06:47:06 +00001642void StmtProfiler::VisitObjCIvarRefExpr(const ObjCIvarRefExpr *S) {
Douglas Gregora7095092009-07-28 14:44:31 +00001643 VisitExpr(S);
1644 VisitDecl(S->getDecl());
1645 ID.AddBoolean(S->isArrow());
1646 ID.AddBoolean(S->isFreeIvar());
1647}
1648
Chandler Carruth631abd92011-06-16 06:47:06 +00001649void StmtProfiler::VisitObjCPropertyRefExpr(const ObjCPropertyRefExpr *S) {
Douglas Gregora7095092009-07-28 14:44:31 +00001650 VisitExpr(S);
John McCallb7bd14f2010-12-02 01:19:52 +00001651 if (S->isImplicitProperty()) {
1652 VisitDecl(S->getImplicitPropertyGetter());
1653 VisitDecl(S->getImplicitPropertySetter());
1654 } else {
1655 VisitDecl(S->getExplicitProperty());
Fariborz Jahanian681c0752010-10-14 16:04:05 +00001656 }
Fariborz Jahanian681c0752010-10-14 16:04:05 +00001657 if (S->isSuperReceiver()) {
1658 ID.AddBoolean(S->isSuperReceiver());
John McCallb7bd14f2010-12-02 01:19:52 +00001659 VisitType(S->getSuperReceiverType());
Fariborz Jahanian681c0752010-10-14 16:04:05 +00001660 }
Douglas Gregora7095092009-07-28 14:44:31 +00001661}
1662
Ted Kremeneke65b0862012-03-06 20:05:56 +00001663void StmtProfiler::VisitObjCSubscriptRefExpr(const ObjCSubscriptRefExpr *S) {
1664 VisitExpr(S);
1665 VisitDecl(S->getAtIndexMethodDecl());
1666 VisitDecl(S->setAtIndexMethodDecl());
1667}
1668
Chandler Carruth631abd92011-06-16 06:47:06 +00001669void StmtProfiler::VisitObjCMessageExpr(const ObjCMessageExpr *S) {
Douglas Gregora7095092009-07-28 14:44:31 +00001670 VisitExpr(S);
1671 VisitName(S->getSelector());
1672 VisitDecl(S->getMethodDecl());
1673}
1674
Chandler Carruth631abd92011-06-16 06:47:06 +00001675void StmtProfiler::VisitObjCIsaExpr(const ObjCIsaExpr *S) {
Douglas Gregora7095092009-07-28 14:44:31 +00001676 VisitExpr(S);
1677 ID.AddBoolean(S->isArrow());
1678}
1679
Ted Kremeneke65b0862012-03-06 20:05:56 +00001680void StmtProfiler::VisitObjCBoolLiteralExpr(const ObjCBoolLiteralExpr *S) {
1681 VisitExpr(S);
1682 ID.AddBoolean(S->getValue());
1683}
1684
Chandler Carruth631abd92011-06-16 06:47:06 +00001685void StmtProfiler::VisitObjCIndirectCopyRestoreExpr(
1686 const ObjCIndirectCopyRestoreExpr *S) {
John McCall31168b02011-06-15 23:02:42 +00001687 VisitExpr(S);
1688 ID.AddBoolean(S->shouldCopy());
1689}
1690
Chandler Carruth631abd92011-06-16 06:47:06 +00001691void StmtProfiler::VisitObjCBridgedCastExpr(const ObjCBridgedCastExpr *S) {
John McCall31168b02011-06-15 23:02:42 +00001692 VisitExplicitCastExpr(S);
1693 ID.AddBoolean(S->getBridgeKind());
1694}
1695
Erik Pilkington29099de2016-07-16 00:35:23 +00001696void StmtProfiler::VisitObjCAvailabilityCheckExpr(
1697 const ObjCAvailabilityCheckExpr *S) {
1698 VisitExpr(S);
1699}
1700
Chandler Carruth631abd92011-06-16 06:47:06 +00001701void StmtProfiler::VisitDecl(const Decl *D) {
Douglas Gregor70317122009-07-31 15:45:02 +00001702 ID.AddInteger(D? D->getKind() : 0);
Mike Stump11289f42009-09-09 15:08:12 +00001703
Douglas Gregora5dd9f82009-07-30 23:18:24 +00001704 if (Canonical && D) {
Chandler Carruth631abd92011-06-16 06:47:06 +00001705 if (const NonTypeTemplateParmDecl *NTTP =
1706 dyn_cast<NonTypeTemplateParmDecl>(D)) {
Douglas Gregord9aedfa2009-07-28 15:32:17 +00001707 ID.AddInteger(NTTP->getDepth());
1708 ID.AddInteger(NTTP->getIndex());
Douglas Gregorf5500772011-01-05 15:48:55 +00001709 ID.AddBoolean(NTTP->isParameterPack());
Douglas Gregor00044172009-07-29 16:09:57 +00001710 VisitType(NTTP->getType());
Douglas Gregor5c193b92009-07-28 00:33:38 +00001711 return;
1712 }
Mike Stump11289f42009-09-09 15:08:12 +00001713
Chandler Carruth631abd92011-06-16 06:47:06 +00001714 if (const ParmVarDecl *Parm = dyn_cast<ParmVarDecl>(D)) {
John McCall8fb0d9d2011-05-01 22:35:37 +00001715 // The Itanium C++ ABI uses the type, scope depth, and scope
1716 // index of a parameter when mangling expressions that involve
1717 // function parameters, so we will use the parameter's type for
1718 // establishing function parameter identity. That way, our
1719 // definition of "equivalent" (per C++ [temp.over.link]) is at
1720 // least as strong as the definition of "equivalent" used for
1721 // name mangling.
Douglas Gregor70317122009-07-31 15:45:02 +00001722 VisitType(Parm->getType());
John McCall8fb0d9d2011-05-01 22:35:37 +00001723 ID.AddInteger(Parm->getFunctionScopeDepth());
1724 ID.AddInteger(Parm->getFunctionScopeIndex());
Douglas Gregor70317122009-07-31 15:45:02 +00001725 return;
1726 }
Mike Stump11289f42009-09-09 15:08:12 +00001727
Richard Smithd9a1cd82012-04-02 18:53:24 +00001728 if (const TemplateTypeParmDecl *TTP =
1729 dyn_cast<TemplateTypeParmDecl>(D)) {
1730 ID.AddInteger(TTP->getDepth());
1731 ID.AddInteger(TTP->getIndex());
1732 ID.AddBoolean(TTP->isParameterPack());
1733 return;
1734 }
1735
Chandler Carruth631abd92011-06-16 06:47:06 +00001736 if (const TemplateTemplateParmDecl *TTP =
1737 dyn_cast<TemplateTemplateParmDecl>(D)) {
Douglas Gregorc97f09f2009-07-31 15:46:56 +00001738 ID.AddInteger(TTP->getDepth());
1739 ID.AddInteger(TTP->getIndex());
Douglas Gregorf5500772011-01-05 15:48:55 +00001740 ID.AddBoolean(TTP->isParameterPack());
Douglas Gregorc97f09f2009-07-31 15:46:56 +00001741 return;
1742 }
Douglas Gregor5c193b92009-07-28 00:33:38 +00001743 }
Mike Stump11289f42009-09-09 15:08:12 +00001744
Craig Topper36250ad2014-05-12 05:36:57 +00001745 ID.AddPointer(D? D->getCanonicalDecl() : nullptr);
Douglas Gregord9aedfa2009-07-28 15:32:17 +00001746}
1747
1748void StmtProfiler::VisitType(QualType T) {
1749 if (Canonical)
1750 T = Context.getCanonicalType(T);
Mike Stump11289f42009-09-09 15:08:12 +00001751
Douglas Gregor5c193b92009-07-28 00:33:38 +00001752 ID.AddPointer(T.getAsOpaquePtr());
1753}
1754
1755void StmtProfiler::VisitName(DeclarationName Name) {
1756 ID.AddPointer(Name.getAsOpaquePtr());
1757}
1758
1759void StmtProfiler::VisitNestedNameSpecifier(NestedNameSpecifier *NNS) {
1760 if (Canonical)
1761 NNS = Context.getCanonicalNestedNameSpecifier(NNS);
1762 ID.AddPointer(NNS);
1763}
1764
1765void StmtProfiler::VisitTemplateName(TemplateName Name) {
1766 if (Canonical)
1767 Name = Context.getCanonicalTemplateName(Name);
Mike Stump11289f42009-09-09 15:08:12 +00001768
Douglas Gregor5c193b92009-07-28 00:33:38 +00001769 Name.Profile(ID);
1770}
1771
John McCall0ad16662009-10-29 08:12:44 +00001772void StmtProfiler::VisitTemplateArguments(const TemplateArgumentLoc *Args,
Douglas Gregor5c193b92009-07-28 00:33:38 +00001773 unsigned NumArgs) {
1774 ID.AddInteger(NumArgs);
John McCall0ad16662009-10-29 08:12:44 +00001775 for (unsigned I = 0; I != NumArgs; ++I)
1776 VisitTemplateArgument(Args[I].getArgument());
1777}
Mike Stump11289f42009-09-09 15:08:12 +00001778
John McCall0ad16662009-10-29 08:12:44 +00001779void StmtProfiler::VisitTemplateArgument(const TemplateArgument &Arg) {
1780 // Mostly repetitive with TemplateArgument::Profile!
1781 ID.AddInteger(Arg.getKind());
1782 switch (Arg.getKind()) {
1783 case TemplateArgument::Null:
1784 break;
Mike Stump11289f42009-09-09 15:08:12 +00001785
John McCall0ad16662009-10-29 08:12:44 +00001786 case TemplateArgument::Type:
1787 VisitType(Arg.getAsType());
1788 break;
Mike Stump11289f42009-09-09 15:08:12 +00001789
Douglas Gregor9167f8b2009-11-11 01:00:40 +00001790 case TemplateArgument::Template:
Douglas Gregore4ff4b52011-01-05 18:58:31 +00001791 case TemplateArgument::TemplateExpansion:
1792 VisitTemplateName(Arg.getAsTemplateOrTemplatePattern());
Douglas Gregor9167f8b2009-11-11 01:00:40 +00001793 break;
Alexis Hunta8136cc2010-05-05 15:23:54 +00001794
John McCall0ad16662009-10-29 08:12:44 +00001795 case TemplateArgument::Declaration:
1796 VisitDecl(Arg.getAsDecl());
1797 break;
Mike Stump11289f42009-09-09 15:08:12 +00001798
Eli Friedmanb826a002012-09-26 02:36:12 +00001799 case TemplateArgument::NullPtr:
1800 VisitType(Arg.getNullPtrType());
1801 break;
1802
John McCall0ad16662009-10-29 08:12:44 +00001803 case TemplateArgument::Integral:
Benjamin Kramer6003ad52012-06-07 15:09:51 +00001804 Arg.getAsIntegral().Profile(ID);
John McCall0ad16662009-10-29 08:12:44 +00001805 VisitType(Arg.getIntegralType());
1806 break;
Mike Stump11289f42009-09-09 15:08:12 +00001807
John McCall0ad16662009-10-29 08:12:44 +00001808 case TemplateArgument::Expression:
1809 Visit(Arg.getAsExpr());
1810 break;
Mike Stump11289f42009-09-09 15:08:12 +00001811
John McCall0ad16662009-10-29 08:12:44 +00001812 case TemplateArgument::Pack:
Aaron Ballman2a89e852014-07-15 21:32:31 +00001813 for (const auto &P : Arg.pack_elements())
1814 VisitTemplateArgument(P);
John McCall0ad16662009-10-29 08:12:44 +00001815 break;
Douglas Gregor5c193b92009-07-28 00:33:38 +00001816 }
1817}
1818
Jay Foad39c79802011-01-12 09:06:06 +00001819void Stmt::Profile(llvm::FoldingSetNodeID &ID, const ASTContext &Context,
Chandler Carruth631abd92011-06-16 06:47:06 +00001820 bool Canonical) const {
Douglas Gregor5c193b92009-07-28 00:33:38 +00001821 StmtProfiler Profiler(ID, Context, Canonical);
1822 Profiler.Visit(this);
1823}