blob: b12258016d077cab6e13d53617b73deed5f209a9 [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) {
Arpith Chacko Jacob33c849a2017-01-25 00:57:16 +0000297 VistOMPClauseWithPreInit(C);
Alexey Bataev568a8332014-03-06 06:15:19 +0000298 if (C->getNumThreads())
299 Profiler->VisitStmt(C->getNumThreads());
300}
301
Alexey Bataev62c87d22014-03-21 04:51:18 +0000302void OMPClauseProfiler::VisitOMPSafelenClause(const OMPSafelenClause *C) {
303 if (C->getSafelen())
304 Profiler->VisitStmt(C->getSafelen());
305}
306
Alexey Bataev66b15b52015-08-21 11:14:16 +0000307void OMPClauseProfiler::VisitOMPSimdlenClause(const OMPSimdlenClause *C) {
308 if (C->getSimdlen())
309 Profiler->VisitStmt(C->getSimdlen());
310}
311
Alexander Musman8bd31e62014-05-27 15:12:19 +0000312void OMPClauseProfiler::VisitOMPCollapseClause(const OMPCollapseClause *C) {
313 if (C->getNumForLoops())
314 Profiler->VisitStmt(C->getNumForLoops());
315}
316
Alexey Bataev5ec3eb12013-07-19 03:13:43 +0000317void OMPClauseProfiler::VisitOMPDefaultClause(const OMPDefaultClause *C) { }
Alexey Bataev756c1962013-09-24 03:17:45 +0000318
Alexey Bataevbcbadb62014-05-06 06:04:14 +0000319void OMPClauseProfiler::VisitOMPProcBindClause(const OMPProcBindClause *C) { }
320
Alexey Bataev56dafe82014-06-20 07:16:17 +0000321void OMPClauseProfiler::VisitOMPScheduleClause(const OMPScheduleClause *C) {
Alexey Bataev3392d762016-02-16 11:18:12 +0000322 VistOMPClauseWithPreInit(C);
323 if (auto *S = C->getChunkSize())
324 Profiler->VisitStmt(S);
Alexey Bataev56dafe82014-06-20 07:16:17 +0000325}
326
Alexey Bataev10e775f2015-07-30 11:36:16 +0000327void OMPClauseProfiler::VisitOMPOrderedClause(const OMPOrderedClause *C) {
328 if (auto *Num = C->getNumForLoops())
329 Profiler->VisitStmt(Num);
330}
Alexey Bataev142e1fc2014-06-20 09:44:06 +0000331
Alexey Bataev236070f2014-06-20 11:19:47 +0000332void OMPClauseProfiler::VisitOMPNowaitClause(const OMPNowaitClause *) {}
333
Alexey Bataev7aea99a2014-07-17 12:19:31 +0000334void OMPClauseProfiler::VisitOMPUntiedClause(const OMPUntiedClause *) {}
335
Alexey Bataev74ba3a52014-07-17 12:47:03 +0000336void OMPClauseProfiler::VisitOMPMergeableClause(const OMPMergeableClause *) {}
337
Alexey Bataevf98b00c2014-07-23 02:27:21 +0000338void OMPClauseProfiler::VisitOMPReadClause(const OMPReadClause *) {}
339
Alexey Bataevdea47612014-07-23 07:46:59 +0000340void OMPClauseProfiler::VisitOMPWriteClause(const OMPWriteClause *) {}
341
Alexey Bataev67a4f222014-07-23 10:25:33 +0000342void OMPClauseProfiler::VisitOMPUpdateClause(const OMPUpdateClause *) {}
343
Alexey Bataev459dec02014-07-24 06:46:57 +0000344void OMPClauseProfiler::VisitOMPCaptureClause(const OMPCaptureClause *) {}
345
Alexey Bataev82bad8b2014-07-24 08:55:34 +0000346void OMPClauseProfiler::VisitOMPSeqCstClause(const OMPSeqCstClause *) {}
347
Alexey Bataev346265e2015-09-25 10:37:12 +0000348void OMPClauseProfiler::VisitOMPThreadsClause(const OMPThreadsClause *) {}
349
Alexey Bataevd14d1e62015-09-28 06:39:35 +0000350void OMPClauseProfiler::VisitOMPSIMDClause(const OMPSIMDClause *) {}
351
Alexey Bataevb825de12015-12-07 10:51:44 +0000352void OMPClauseProfiler::VisitOMPNogroupClause(const OMPNogroupClause *) {}
353
Alexey Bataev756c1962013-09-24 03:17:45 +0000354template<typename T>
355void OMPClauseProfiler::VisitOMPClauseList(T *Node) {
Alexey Bataev03b340a2014-10-21 03:16:40 +0000356 for (auto *E : Node->varlists()) {
Richard Trieu6a77a1c2016-06-10 04:52:09 +0000357 if (E)
358 Profiler->VisitStmt(E);
Alexey Bataev03b340a2014-10-21 03:16:40 +0000359 }
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()) {
Richard Trieu6a77a1c2016-06-10 04:52:09 +0000365 if (E)
366 Profiler->VisitStmt(E);
Alexey Bataev03b340a2014-10-21 03:16:40 +0000367 }
Alexey Bataev5ec3eb12013-07-19 03:13:43 +0000368}
Alexey Bataev4a5bb772014-10-08 14:01:46 +0000369void
370OMPClauseProfiler::VisitOMPFirstprivateClause(const OMPFirstprivateClause *C) {
Alexey Bataevd5af8e42013-10-01 05:32:34 +0000371 VisitOMPClauseList(C);
Alexey Bataev417089f2016-02-17 13:19:37 +0000372 VistOMPClauseWithPreInit(C);
Alexey Bataev4a5bb772014-10-08 14:01:46 +0000373 for (auto *E : C->private_copies()) {
Richard Trieu6a77a1c2016-06-10 04:52:09 +0000374 if (E)
375 Profiler->VisitStmt(E);
Alexey Bataev4a5bb772014-10-08 14:01:46 +0000376 }
377 for (auto *E : C->inits()) {
Richard Trieu6a77a1c2016-06-10 04:52:09 +0000378 if (E)
379 Profiler->VisitStmt(E);
Alexey Bataev4a5bb772014-10-08 14:01:46 +0000380 }
Alexey Bataevd5af8e42013-10-01 05:32:34 +0000381}
Alexander Musman1bb328c2014-06-04 13:06:39 +0000382void
383OMPClauseProfiler::VisitOMPLastprivateClause(const OMPLastprivateClause *C) {
384 VisitOMPClauseList(C);
Alexey Bataev005248a2016-02-25 05:25:57 +0000385 VistOMPClauseWithPostUpdate(C);
Alexey Bataev38e89532015-04-16 04:54:05 +0000386 for (auto *E : C->source_exprs()) {
Richard Trieu6a77a1c2016-06-10 04:52:09 +0000387 if (E)
388 Profiler->VisitStmt(E);
Alexey Bataev38e89532015-04-16 04:54:05 +0000389 }
390 for (auto *E : C->destination_exprs()) {
Richard Trieu6a77a1c2016-06-10 04:52:09 +0000391 if (E)
392 Profiler->VisitStmt(E);
Alexey Bataev38e89532015-04-16 04:54:05 +0000393 }
394 for (auto *E : C->assignment_ops()) {
Richard Trieu6a77a1c2016-06-10 04:52:09 +0000395 if (E)
396 Profiler->VisitStmt(E);
Alexey Bataev38e89532015-04-16 04:54:05 +0000397 }
Alexander Musman1bb328c2014-06-04 13:06:39 +0000398}
Alexey Bataev758e55e2013-09-06 18:03:48 +0000399void OMPClauseProfiler::VisitOMPSharedClause(const OMPSharedClause *C) {
Alexey Bataev756c1962013-09-24 03:17:45 +0000400 VisitOMPClauseList(C);
Alexey Bataev758e55e2013-09-06 18:03:48 +0000401}
Alexey Bataevc5e02582014-06-16 07:08:35 +0000402void OMPClauseProfiler::VisitOMPReductionClause(
403 const OMPReductionClause *C) {
404 Profiler->VisitNestedNameSpecifier(
405 C->getQualifierLoc().getNestedNameSpecifier());
406 Profiler->VisitName(C->getNameInfo().getName());
407 VisitOMPClauseList(C);
Alexey Bataev61205072016-03-02 04:57:40 +0000408 VistOMPClauseWithPostUpdate(C);
Alexey Bataevf24e7b12015-10-08 09:10:53 +0000409 for (auto *E : C->privates()) {
Richard Trieu6a77a1c2016-06-10 04:52:09 +0000410 if (E)
411 Profiler->VisitStmt(E);
Alexey Bataevf24e7b12015-10-08 09:10:53 +0000412 }
Alexey Bataev794ba0d2015-04-10 10:43:45 +0000413 for (auto *E : C->lhs_exprs()) {
Richard Trieu6a77a1c2016-06-10 04:52:09 +0000414 if (E)
415 Profiler->VisitStmt(E);
Alexey Bataev794ba0d2015-04-10 10:43:45 +0000416 }
417 for (auto *E : C->rhs_exprs()) {
Richard Trieu6a77a1c2016-06-10 04:52:09 +0000418 if (E)
419 Profiler->VisitStmt(E);
Alexey Bataev794ba0d2015-04-10 10:43:45 +0000420 }
421 for (auto *E : C->reduction_ops()) {
Richard Trieu6a77a1c2016-06-10 04:52:09 +0000422 if (E)
423 Profiler->VisitStmt(E);
Alexey Bataev794ba0d2015-04-10 10:43:45 +0000424 }
Alexey Bataevc5e02582014-06-16 07:08:35 +0000425}
Alexander Musman8dba6642014-04-22 13:09:42 +0000426void OMPClauseProfiler::VisitOMPLinearClause(const OMPLinearClause *C) {
427 VisitOMPClauseList(C);
Alexey Bataev78849fb2016-03-09 09:49:00 +0000428 VistOMPClauseWithPostUpdate(C);
Alexey Bataevbd9fec12015-08-18 06:47:21 +0000429 for (auto *E : C->privates()) {
Richard Trieu6a77a1c2016-06-10 04:52:09 +0000430 if (E)
431 Profiler->VisitStmt(E);
Alexey Bataevbd9fec12015-08-18 06:47:21 +0000432 }
Alexander Musman3276a272015-03-21 10:12:56 +0000433 for (auto *E : C->inits()) {
Richard Trieu6a77a1c2016-06-10 04:52:09 +0000434 if (E)
435 Profiler->VisitStmt(E);
Alexander Musman3276a272015-03-21 10:12:56 +0000436 }
437 for (auto *E : C->updates()) {
Richard Trieu6a77a1c2016-06-10 04:52:09 +0000438 if (E)
439 Profiler->VisitStmt(E);
Alexander Musman3276a272015-03-21 10:12:56 +0000440 }
441 for (auto *E : C->finals()) {
Richard Trieu6a77a1c2016-06-10 04:52:09 +0000442 if (E)
443 Profiler->VisitStmt(E);
Alexander Musman3276a272015-03-21 10:12:56 +0000444 }
Richard Trieu6a77a1c2016-06-10 04:52:09 +0000445 if (C->getStep())
446 Profiler->VisitStmt(C->getStep());
447 if (C->getCalcStep())
448 Profiler->VisitStmt(C->getCalcStep());
Alexander Musman8dba6642014-04-22 13:09:42 +0000449}
Alexander Musmanf0d76e72014-05-29 14:36:25 +0000450void OMPClauseProfiler::VisitOMPAlignedClause(const OMPAlignedClause *C) {
451 VisitOMPClauseList(C);
Richard Trieu6a77a1c2016-06-10 04:52:09 +0000452 if (C->getAlignment())
453 Profiler->VisitStmt(C->getAlignment());
Alexander Musmanf0d76e72014-05-29 14:36:25 +0000454}
Alexey Bataevd48bcd82014-03-31 03:36:38 +0000455void OMPClauseProfiler::VisitOMPCopyinClause(const OMPCopyinClause *C) {
456 VisitOMPClauseList(C);
Alexey Bataevf56f98c2015-04-16 05:39:01 +0000457 for (auto *E : C->source_exprs()) {
Richard Trieu6a77a1c2016-06-10 04:52:09 +0000458 if (E)
459 Profiler->VisitStmt(E);
Alexey Bataevf56f98c2015-04-16 05:39:01 +0000460 }
461 for (auto *E : C->destination_exprs()) {
Richard Trieu6a77a1c2016-06-10 04:52:09 +0000462 if (E)
463 Profiler->VisitStmt(E);
Alexey Bataevf56f98c2015-04-16 05:39:01 +0000464 }
465 for (auto *E : C->assignment_ops()) {
Richard Trieu6a77a1c2016-06-10 04:52:09 +0000466 if (E)
467 Profiler->VisitStmt(E);
Alexey Bataevf56f98c2015-04-16 05:39:01 +0000468 }
Alexey Bataevd48bcd82014-03-31 03:36:38 +0000469}
Alexey Bataevbae9a792014-06-27 10:37:06 +0000470void
471OMPClauseProfiler::VisitOMPCopyprivateClause(const OMPCopyprivateClause *C) {
472 VisitOMPClauseList(C);
Alexey Bataeva63048e2015-03-23 06:18:07 +0000473 for (auto *E : C->source_exprs()) {
Richard Trieu6a77a1c2016-06-10 04:52:09 +0000474 if (E)
475 Profiler->VisitStmt(E);
Alexey Bataeva63048e2015-03-23 06:18:07 +0000476 }
477 for (auto *E : C->destination_exprs()) {
Richard Trieu6a77a1c2016-06-10 04:52:09 +0000478 if (E)
479 Profiler->VisitStmt(E);
Alexey Bataeva63048e2015-03-23 06:18:07 +0000480 }
481 for (auto *E : C->assignment_ops()) {
Richard Trieu6a77a1c2016-06-10 04:52:09 +0000482 if (E)
483 Profiler->VisitStmt(E);
Alexey Bataeva63048e2015-03-23 06:18:07 +0000484 }
Alexey Bataevbae9a792014-06-27 10:37:06 +0000485}
Alexey Bataev6125da92014-07-21 11:26:11 +0000486void OMPClauseProfiler::VisitOMPFlushClause(const OMPFlushClause *C) {
487 VisitOMPClauseList(C);
488}
Alexey Bataev1c2cfbc2015-06-23 14:25:19 +0000489void OMPClauseProfiler::VisitOMPDependClause(const OMPDependClause *C) {
490 VisitOMPClauseList(C);
491}
Michael Wonge710d542015-08-07 16:16:36 +0000492void OMPClauseProfiler::VisitOMPDeviceClause(const OMPDeviceClause *C) {
Richard Trieu6a77a1c2016-06-10 04:52:09 +0000493 if (C->getDevice())
494 Profiler->VisitStmt(C->getDevice());
Michael Wonge710d542015-08-07 16:16:36 +0000495}
Kelvin Li0bff7af2015-11-23 05:32:03 +0000496void OMPClauseProfiler::VisitOMPMapClause(const OMPMapClause *C) {
497 VisitOMPClauseList(C);
498}
Kelvin Li099bb8c2015-11-24 20:50:12 +0000499void OMPClauseProfiler::VisitOMPNumTeamsClause(const OMPNumTeamsClause *C) {
Arpith Chacko Jacobbc126342017-01-25 11:28:18 +0000500 VistOMPClauseWithPreInit(C);
Richard Trieu6a77a1c2016-06-10 04:52:09 +0000501 if (C->getNumTeams())
502 Profiler->VisitStmt(C->getNumTeams());
Kelvin Li099bb8c2015-11-24 20:50:12 +0000503}
Kelvin Lia15fb1a2015-11-27 18:47:36 +0000504void OMPClauseProfiler::VisitOMPThreadLimitClause(
505 const OMPThreadLimitClause *C) {
Richard Trieu6a77a1c2016-06-10 04:52:09 +0000506 if (C->getThreadLimit())
507 Profiler->VisitStmt(C->getThreadLimit());
Kelvin Lia15fb1a2015-11-27 18:47:36 +0000508}
Alexey Bataeva0569352015-12-01 10:17:31 +0000509void OMPClauseProfiler::VisitOMPPriorityClause(const OMPPriorityClause *C) {
Richard Trieu6a77a1c2016-06-10 04:52:09 +0000510 if (C->getPriority())
511 Profiler->VisitStmt(C->getPriority());
Alexey Bataeva0569352015-12-01 10:17:31 +0000512}
Alexey Bataev1fd4aed2015-12-07 12:52:51 +0000513void OMPClauseProfiler::VisitOMPGrainsizeClause(const OMPGrainsizeClause *C) {
Richard Trieu6a77a1c2016-06-10 04:52:09 +0000514 if (C->getGrainsize())
515 Profiler->VisitStmt(C->getGrainsize());
Alexey Bataev1fd4aed2015-12-07 12:52:51 +0000516}
Alexey Bataev382967a2015-12-08 12:06:20 +0000517void OMPClauseProfiler::VisitOMPNumTasksClause(const OMPNumTasksClause *C) {
Richard Trieu6a77a1c2016-06-10 04:52:09 +0000518 if (C->getNumTasks())
519 Profiler->VisitStmt(C->getNumTasks());
Alexey Bataev382967a2015-12-08 12:06:20 +0000520}
Alexey Bataev28c75412015-12-15 08:19:24 +0000521void OMPClauseProfiler::VisitOMPHintClause(const OMPHintClause *C) {
Richard Trieu6a77a1c2016-06-10 04:52:09 +0000522 if (C->getHint())
523 Profiler->VisitStmt(C->getHint());
Alexey Bataev28c75412015-12-15 08:19:24 +0000524}
Samuel Antao661c0902016-05-26 17:39:58 +0000525void OMPClauseProfiler::VisitOMPToClause(const OMPToClause *C) {
526 VisitOMPClauseList(C);
527}
Samuel Antaoec172c62016-05-26 17:49:04 +0000528void OMPClauseProfiler::VisitOMPFromClause(const OMPFromClause *C) {
529 VisitOMPClauseList(C);
530}
Carlo Bertolli2404b172016-07-13 15:37:16 +0000531void OMPClauseProfiler::VisitOMPUseDevicePtrClause(
532 const OMPUseDevicePtrClause *C) {
533 VisitOMPClauseList(C);
534}
Carlo Bertolli70594e92016-07-13 17:16:49 +0000535void OMPClauseProfiler::VisitOMPIsDevicePtrClause(
536 const OMPIsDevicePtrClause *C) {
537 VisitOMPClauseList(C);
538}
Alexander Kornienkoab9db512015-06-22 23:07:51 +0000539}
Alexey Bataev5ec3eb12013-07-19 03:13:43 +0000540
541void
Alexey Bataev1b59ab52014-02-27 08:29:12 +0000542StmtProfiler::VisitOMPExecutableDirective(const OMPExecutableDirective *S) {
Alexey Bataev5ec3eb12013-07-19 03:13:43 +0000543 VisitStmt(S);
544 OMPClauseProfiler P(this);
545 ArrayRef<OMPClause *> Clauses = S->clauses();
546 for (ArrayRef<OMPClause *>::iterator I = Clauses.begin(), E = Clauses.end();
547 I != E; ++I)
548 if (*I)
549 P.Visit(*I);
550}
551
Alexander Musman3aaab662014-08-19 11:27:13 +0000552void StmtProfiler::VisitOMPLoopDirective(const OMPLoopDirective *S) {
553 VisitOMPExecutableDirective(S);
554}
555
Alexey Bataev1b59ab52014-02-27 08:29:12 +0000556void StmtProfiler::VisitOMPParallelDirective(const OMPParallelDirective *S) {
557 VisitOMPExecutableDirective(S);
558}
559
560void StmtProfiler::VisitOMPSimdDirective(const OMPSimdDirective *S) {
Alexander Musman3aaab662014-08-19 11:27:13 +0000561 VisitOMPLoopDirective(S);
Alexey Bataev1b59ab52014-02-27 08:29:12 +0000562}
563
Alexey Bataevf29276e2014-06-18 04:14:57 +0000564void StmtProfiler::VisitOMPForDirective(const OMPForDirective *S) {
Alexander Musman3aaab662014-08-19 11:27:13 +0000565 VisitOMPLoopDirective(S);
Alexey Bataevf29276e2014-06-18 04:14:57 +0000566}
567
Alexander Musmanf82886e2014-09-18 05:12:34 +0000568void StmtProfiler::VisitOMPForSimdDirective(const OMPForSimdDirective *S) {
569 VisitOMPLoopDirective(S);
570}
571
Alexey Bataevd3f8dd22014-06-25 11:44:49 +0000572void StmtProfiler::VisitOMPSectionsDirective(const OMPSectionsDirective *S) {
573 VisitOMPExecutableDirective(S);
574}
575
Alexey Bataev1e0498a2014-06-26 08:21:58 +0000576void StmtProfiler::VisitOMPSectionDirective(const OMPSectionDirective *S) {
577 VisitOMPExecutableDirective(S);
578}
579
Alexey Bataevd1e40fb2014-06-26 12:05:45 +0000580void StmtProfiler::VisitOMPSingleDirective(const OMPSingleDirective *S) {
581 VisitOMPExecutableDirective(S);
582}
583
Alexander Musman80c22892014-07-17 08:54:58 +0000584void StmtProfiler::VisitOMPMasterDirective(const OMPMasterDirective *S) {
585 VisitOMPExecutableDirective(S);
586}
587
Alexander Musmand9ed09f2014-07-21 09:42:05 +0000588void StmtProfiler::VisitOMPCriticalDirective(const OMPCriticalDirective *S) {
589 VisitOMPExecutableDirective(S);
590 VisitName(S->getDirectiveName().getName());
591}
592
Alexey Bataev4acb8592014-07-07 13:01:15 +0000593void
594StmtProfiler::VisitOMPParallelForDirective(const OMPParallelForDirective *S) {
Alexander Musman3aaab662014-08-19 11:27:13 +0000595 VisitOMPLoopDirective(S);
Alexey Bataev4acb8592014-07-07 13:01:15 +0000596}
597
Alexander Musmane4e893b2014-09-23 09:33:00 +0000598void StmtProfiler::VisitOMPParallelForSimdDirective(
599 const OMPParallelForSimdDirective *S) {
600 VisitOMPLoopDirective(S);
601}
602
Alexey Bataev84d0b3e2014-07-08 08:12:03 +0000603void StmtProfiler::VisitOMPParallelSectionsDirective(
604 const OMPParallelSectionsDirective *S) {
605 VisitOMPExecutableDirective(S);
606}
607
Alexey Bataev9c2e8ee2014-07-11 11:25:16 +0000608void StmtProfiler::VisitOMPTaskDirective(const OMPTaskDirective *S) {
609 VisitOMPExecutableDirective(S);
610}
611
Alexey Bataev68446b72014-07-18 07:47:19 +0000612void StmtProfiler::VisitOMPTaskyieldDirective(const OMPTaskyieldDirective *S) {
613 VisitOMPExecutableDirective(S);
614}
615
Alexey Bataev4d1dfea2014-07-18 09:11:51 +0000616void StmtProfiler::VisitOMPBarrierDirective(const OMPBarrierDirective *S) {
617 VisitOMPExecutableDirective(S);
618}
619
Alexey Bataev2df347a2014-07-18 10:17:07 +0000620void StmtProfiler::VisitOMPTaskwaitDirective(const OMPTaskwaitDirective *S) {
621 VisitOMPExecutableDirective(S);
622}
623
Alexey Bataevc30dd2d2015-06-18 12:14:09 +0000624void StmtProfiler::VisitOMPTaskgroupDirective(const OMPTaskgroupDirective *S) {
625 VisitOMPExecutableDirective(S);
626}
627
Alexey Bataev6125da92014-07-21 11:26:11 +0000628void StmtProfiler::VisitOMPFlushDirective(const OMPFlushDirective *S) {
629 VisitOMPExecutableDirective(S);
630}
631
Alexey Bataev9fb6e642014-07-22 06:45:04 +0000632void StmtProfiler::VisitOMPOrderedDirective(const OMPOrderedDirective *S) {
633 VisitOMPExecutableDirective(S);
634}
635
Alexey Bataev0162e452014-07-22 10:10:35 +0000636void StmtProfiler::VisitOMPAtomicDirective(const OMPAtomicDirective *S) {
637 VisitOMPExecutableDirective(S);
638}
639
Alexey Bataev0bd520b2014-09-19 08:19:49 +0000640void StmtProfiler::VisitOMPTargetDirective(const OMPTargetDirective *S) {
641 VisitOMPExecutableDirective(S);
642}
643
Michael Wong65f367f2015-07-21 13:44:28 +0000644void StmtProfiler::VisitOMPTargetDataDirective(const OMPTargetDataDirective *S) {
645 VisitOMPExecutableDirective(S);
646}
647
Samuel Antaodf67fc42016-01-19 19:15:56 +0000648void StmtProfiler::VisitOMPTargetEnterDataDirective(
649 const OMPTargetEnterDataDirective *S) {
650 VisitOMPExecutableDirective(S);
651}
652
Samuel Antao72590762016-01-19 20:04:50 +0000653void StmtProfiler::VisitOMPTargetExitDataDirective(
654 const OMPTargetExitDataDirective *S) {
655 VisitOMPExecutableDirective(S);
656}
657
Arpith Chacko Jacobe955b3d2016-01-26 18:48:41 +0000658void StmtProfiler::VisitOMPTargetParallelDirective(
659 const OMPTargetParallelDirective *S) {
660 VisitOMPExecutableDirective(S);
661}
662
Arpith Chacko Jacob05bebb52016-02-03 15:46:42 +0000663void StmtProfiler::VisitOMPTargetParallelForDirective(
664 const OMPTargetParallelForDirective *S) {
665 VisitOMPExecutableDirective(S);
666}
667
Alexey Bataev13314bf2014-10-09 04:18:56 +0000668void StmtProfiler::VisitOMPTeamsDirective(const OMPTeamsDirective *S) {
669 VisitOMPExecutableDirective(S);
670}
671
Alexey Bataev6d4ed052015-07-01 06:57:41 +0000672void StmtProfiler::VisitOMPCancellationPointDirective(
673 const OMPCancellationPointDirective *S) {
674 VisitOMPExecutableDirective(S);
675}
676
Alexey Bataev80909872015-07-02 11:25:17 +0000677void StmtProfiler::VisitOMPCancelDirective(const OMPCancelDirective *S) {
678 VisitOMPExecutableDirective(S);
679}
680
Alexey Bataev49f6e782015-12-01 04:18:41 +0000681void StmtProfiler::VisitOMPTaskLoopDirective(const OMPTaskLoopDirective *S) {
682 VisitOMPLoopDirective(S);
683}
684
Alexey Bataev0a6ed842015-12-03 09:40:15 +0000685void StmtProfiler::VisitOMPTaskLoopSimdDirective(
686 const OMPTaskLoopSimdDirective *S) {
687 VisitOMPLoopDirective(S);
688}
689
Carlo Bertolli6200a3d2015-12-14 14:51:25 +0000690void StmtProfiler::VisitOMPDistributeDirective(
691 const OMPDistributeDirective *S) {
692 VisitOMPLoopDirective(S);
693}
694
Carlo Bertollib4adf552016-01-15 18:50:31 +0000695void OMPClauseProfiler::VisitOMPDistScheduleClause(
696 const OMPDistScheduleClause *C) {
Alexey Bataev3392d762016-02-16 11:18:12 +0000697 VistOMPClauseWithPreInit(C);
698 if (auto *S = C->getChunkSize())
699 Profiler->VisitStmt(S);
Carlo Bertollib4adf552016-01-15 18:50:31 +0000700}
701
Arpith Chacko Jacob3cf89042016-01-26 16:37:23 +0000702void OMPClauseProfiler::VisitOMPDefaultmapClause(const OMPDefaultmapClause *) {}
703
Samuel Antao686c70c2016-05-26 17:30:50 +0000704void StmtProfiler::VisitOMPTargetUpdateDirective(
705 const OMPTargetUpdateDirective *S) {
706 VisitOMPExecutableDirective(S);
707}
708
Carlo Bertolli9925f152016-06-27 14:55:37 +0000709void StmtProfiler::VisitOMPDistributeParallelForDirective(
710 const OMPDistributeParallelForDirective *S) {
711 VisitOMPLoopDirective(S);
712}
713
Kelvin Li4a39add2016-07-05 05:00:15 +0000714void StmtProfiler::VisitOMPDistributeParallelForSimdDirective(
715 const OMPDistributeParallelForSimdDirective *S) {
716 VisitOMPLoopDirective(S);
717}
718
Kelvin Li787f3fc2016-07-06 04:45:38 +0000719void StmtProfiler::VisitOMPDistributeSimdDirective(
720 const OMPDistributeSimdDirective *S) {
721 VisitOMPLoopDirective(S);
722}
723
Kelvin Lia579b912016-07-14 02:54:56 +0000724void StmtProfiler::VisitOMPTargetParallelForSimdDirective(
725 const OMPTargetParallelForSimdDirective *S) {
726 VisitOMPLoopDirective(S);
727}
728
Kelvin Li986330c2016-07-20 22:57:10 +0000729void StmtProfiler::VisitOMPTargetSimdDirective(
730 const OMPTargetSimdDirective *S) {
731 VisitOMPLoopDirective(S);
732}
733
Kelvin Li02532872016-08-05 14:37:37 +0000734void StmtProfiler::VisitOMPTeamsDistributeDirective(
735 const OMPTeamsDistributeDirective *S) {
736 VisitOMPLoopDirective(S);
737}
738
Kelvin Li4e325f72016-10-25 12:50:55 +0000739void StmtProfiler::VisitOMPTeamsDistributeSimdDirective(
740 const OMPTeamsDistributeSimdDirective *S) {
741 VisitOMPLoopDirective(S);
742}
743
Kelvin Li579e41c2016-11-30 23:51:03 +0000744void StmtProfiler::VisitOMPTeamsDistributeParallelForSimdDirective(
745 const OMPTeamsDistributeParallelForSimdDirective *S) {
746 VisitOMPLoopDirective(S);
747}
748
Kelvin Li7ade93f2016-12-09 03:24:30 +0000749void StmtProfiler::VisitOMPTeamsDistributeParallelForDirective(
750 const OMPTeamsDistributeParallelForDirective *S) {
751 VisitOMPLoopDirective(S);
752}
753
Kelvin Libf594a52016-12-17 05:48:59 +0000754void StmtProfiler::VisitOMPTargetTeamsDirective(
755 const OMPTargetTeamsDirective *S) {
756 VisitOMPExecutableDirective(S);
757}
758
Kelvin Li83c451e2016-12-25 04:52:54 +0000759void StmtProfiler::VisitOMPTargetTeamsDistributeDirective(
760 const OMPTargetTeamsDistributeDirective *S) {
761 VisitOMPLoopDirective(S);
762}
763
Kelvin Li80e8f562016-12-29 22:16:30 +0000764void StmtProfiler::VisitOMPTargetTeamsDistributeParallelForDirective(
765 const OMPTargetTeamsDistributeParallelForDirective *S) {
766 VisitOMPLoopDirective(S);
767}
768
Kelvin Li1851df52017-01-03 05:23:48 +0000769void StmtProfiler::VisitOMPTargetTeamsDistributeParallelForSimdDirective(
770 const OMPTargetTeamsDistributeParallelForSimdDirective *S) {
771 VisitOMPLoopDirective(S);
772}
773
Kelvin Lida681182017-01-10 18:08:18 +0000774void StmtProfiler::VisitOMPTargetTeamsDistributeSimdDirective(
775 const OMPTargetTeamsDistributeSimdDirective *S) {
776 VisitOMPLoopDirective(S);
777}
778
Chandler Carruth631abd92011-06-16 06:47:06 +0000779void StmtProfiler::VisitExpr(const Expr *S) {
Douglas Gregor5c193b92009-07-28 00:33:38 +0000780 VisitStmt(S);
781}
782
Chandler Carruth631abd92011-06-16 06:47:06 +0000783void StmtProfiler::VisitDeclRefExpr(const DeclRefExpr *S) {
Douglas Gregor5c193b92009-07-28 00:33:38 +0000784 VisitExpr(S);
Douglas Gregorf5b160f2010-07-13 08:37:11 +0000785 if (!Canonical)
786 VisitNestedNameSpecifier(S->getQualifier());
Douglas Gregor5c193b92009-07-28 00:33:38 +0000787 VisitDecl(S->getDecl());
Douglas Gregorf5b160f2010-07-13 08:37:11 +0000788 if (!Canonical)
789 VisitTemplateArguments(S->getTemplateArgs(), S->getNumTemplateArgs());
Douglas Gregor5c193b92009-07-28 00:33:38 +0000790}
791
Chandler Carruth631abd92011-06-16 06:47:06 +0000792void StmtProfiler::VisitPredefinedExpr(const PredefinedExpr *S) {
Douglas Gregor5c193b92009-07-28 00:33:38 +0000793 VisitExpr(S);
794 ID.AddInteger(S->getIdentType());
795}
796
Chandler Carruth631abd92011-06-16 06:47:06 +0000797void StmtProfiler::VisitIntegerLiteral(const IntegerLiteral *S) {
Douglas Gregor5c193b92009-07-28 00:33:38 +0000798 VisitExpr(S);
799 S->getValue().Profile(ID);
Richard Smithe9f130c2014-11-20 03:37:32 +0000800 ID.AddInteger(S->getType()->castAs<BuiltinType>()->getKind());
Douglas Gregor5c193b92009-07-28 00:33:38 +0000801}
802
Chandler Carruth631abd92011-06-16 06:47:06 +0000803void StmtProfiler::VisitCharacterLiteral(const CharacterLiteral *S) {
Douglas Gregor5c193b92009-07-28 00:33:38 +0000804 VisitExpr(S);
Douglas Gregorfb65e592011-07-27 05:40:30 +0000805 ID.AddInteger(S->getKind());
Douglas Gregor5c193b92009-07-28 00:33:38 +0000806 ID.AddInteger(S->getValue());
807}
808
Chandler Carruth631abd92011-06-16 06:47:06 +0000809void StmtProfiler::VisitFloatingLiteral(const FloatingLiteral *S) {
Douglas Gregor5c193b92009-07-28 00:33:38 +0000810 VisitExpr(S);
811 S->getValue().Profile(ID);
812 ID.AddBoolean(S->isExact());
Richard Smithe9f130c2014-11-20 03:37:32 +0000813 ID.AddInteger(S->getType()->castAs<BuiltinType>()->getKind());
Douglas Gregor5c193b92009-07-28 00:33:38 +0000814}
815
Chandler Carruth631abd92011-06-16 06:47:06 +0000816void StmtProfiler::VisitImaginaryLiteral(const ImaginaryLiteral *S) {
Douglas Gregor5c193b92009-07-28 00:33:38 +0000817 VisitExpr(S);
818}
819
Chandler Carruth631abd92011-06-16 06:47:06 +0000820void StmtProfiler::VisitStringLiteral(const StringLiteral *S) {
Douglas Gregor5c193b92009-07-28 00:33:38 +0000821 VisitExpr(S);
Douglas Gregor9d0eb8f2011-11-02 17:26:05 +0000822 ID.AddString(S->getBytes());
Douglas Gregorfb65e592011-07-27 05:40:30 +0000823 ID.AddInteger(S->getKind());
Douglas Gregor5c193b92009-07-28 00:33:38 +0000824}
825
Chandler Carruth631abd92011-06-16 06:47:06 +0000826void StmtProfiler::VisitParenExpr(const ParenExpr *S) {
Douglas Gregor5c193b92009-07-28 00:33:38 +0000827 VisitExpr(S);
828}
829
Chandler Carruth631abd92011-06-16 06:47:06 +0000830void StmtProfiler::VisitParenListExpr(const ParenListExpr *S) {
Nate Begeman5ec4b312009-08-10 23:49:36 +0000831 VisitExpr(S);
832}
833
Chandler Carruth631abd92011-06-16 06:47:06 +0000834void StmtProfiler::VisitUnaryOperator(const UnaryOperator *S) {
Douglas Gregor5c193b92009-07-28 00:33:38 +0000835 VisitExpr(S);
836 ID.AddInteger(S->getOpcode());
837}
838
Chandler Carruth631abd92011-06-16 06:47:06 +0000839void StmtProfiler::VisitOffsetOfExpr(const OffsetOfExpr *S) {
Douglas Gregor882211c2010-04-28 22:16:22 +0000840 VisitType(S->getTypeSourceInfo()->getType());
841 unsigned n = S->getNumComponents();
842 for (unsigned i = 0; i < n; ++i) {
James Y Knight7281c352015-12-29 22:31:18 +0000843 const OffsetOfNode &ON = S->getComponent(i);
Douglas Gregor882211c2010-04-28 22:16:22 +0000844 ID.AddInteger(ON.getKind());
845 switch (ON.getKind()) {
James Y Knight7281c352015-12-29 22:31:18 +0000846 case OffsetOfNode::Array:
Douglas Gregor882211c2010-04-28 22:16:22 +0000847 // Expressions handled below.
848 break;
849
James Y Knight7281c352015-12-29 22:31:18 +0000850 case OffsetOfNode::Field:
Douglas Gregor882211c2010-04-28 22:16:22 +0000851 VisitDecl(ON.getField());
852 break;
853
James Y Knight7281c352015-12-29 22:31:18 +0000854 case OffsetOfNode::Identifier:
Douglas Gregor882211c2010-04-28 22:16:22 +0000855 ID.AddPointer(ON.getFieldName());
856 break;
James Y Knight7281c352015-12-29 22:31:18 +0000857
858 case OffsetOfNode::Base:
Douglas Gregord1702062010-04-29 00:18:15 +0000859 // These nodes are implicit, and therefore don't need profiling.
860 break;
Douglas Gregor882211c2010-04-28 22:16:22 +0000861 }
862 }
Alexis Hunta8136cc2010-05-05 15:23:54 +0000863
Douglas Gregor882211c2010-04-28 22:16:22 +0000864 VisitExpr(S);
865}
866
Chandler Carruth631abd92011-06-16 06:47:06 +0000867void
868StmtProfiler::VisitUnaryExprOrTypeTraitExpr(const UnaryExprOrTypeTraitExpr *S) {
Douglas Gregor5c193b92009-07-28 00:33:38 +0000869 VisitExpr(S);
Peter Collingbournee190dee2011-03-11 19:24:49 +0000870 ID.AddInteger(S->getKind());
Douglas Gregor5c193b92009-07-28 00:33:38 +0000871 if (S->isArgumentType())
872 VisitType(S->getArgumentType());
873}
874
Chandler Carruth631abd92011-06-16 06:47:06 +0000875void StmtProfiler::VisitArraySubscriptExpr(const ArraySubscriptExpr *S) {
Douglas Gregor5c193b92009-07-28 00:33:38 +0000876 VisitExpr(S);
877}
878
Alexey Bataev1a3320e2015-08-25 14:24:04 +0000879void StmtProfiler::VisitOMPArraySectionExpr(const OMPArraySectionExpr *S) {
880 VisitExpr(S);
881}
882
Chandler Carruth631abd92011-06-16 06:47:06 +0000883void StmtProfiler::VisitCallExpr(const CallExpr *S) {
Douglas Gregor5c193b92009-07-28 00:33:38 +0000884 VisitExpr(S);
885}
886
Chandler Carruth631abd92011-06-16 06:47:06 +0000887void StmtProfiler::VisitMemberExpr(const MemberExpr *S) {
Douglas Gregor5c193b92009-07-28 00:33:38 +0000888 VisitExpr(S);
889 VisitDecl(S->getMemberDecl());
Douglas Gregorf5b160f2010-07-13 08:37:11 +0000890 if (!Canonical)
891 VisitNestedNameSpecifier(S->getQualifier());
Douglas Gregor5c193b92009-07-28 00:33:38 +0000892 ID.AddBoolean(S->isArrow());
893}
894
Chandler Carruth631abd92011-06-16 06:47:06 +0000895void StmtProfiler::VisitCompoundLiteralExpr(const CompoundLiteralExpr *S) {
Douglas Gregor5c193b92009-07-28 00:33:38 +0000896 VisitExpr(S);
897 ID.AddBoolean(S->isFileScope());
898}
899
Chandler Carruth631abd92011-06-16 06:47:06 +0000900void StmtProfiler::VisitCastExpr(const CastExpr *S) {
Douglas Gregor5c193b92009-07-28 00:33:38 +0000901 VisitExpr(S);
902}
903
Chandler Carruth631abd92011-06-16 06:47:06 +0000904void StmtProfiler::VisitImplicitCastExpr(const ImplicitCastExpr *S) {
Douglas Gregor5c193b92009-07-28 00:33:38 +0000905 VisitCastExpr(S);
John McCall2536c6d2010-08-25 10:28:54 +0000906 ID.AddInteger(S->getValueKind());
Douglas Gregor5c193b92009-07-28 00:33:38 +0000907}
908
Chandler Carruth631abd92011-06-16 06:47:06 +0000909void StmtProfiler::VisitExplicitCastExpr(const ExplicitCastExpr *S) {
Douglas Gregor5c193b92009-07-28 00:33:38 +0000910 VisitCastExpr(S);
911 VisitType(S->getTypeAsWritten());
912}
913
Chandler Carruth631abd92011-06-16 06:47:06 +0000914void StmtProfiler::VisitCStyleCastExpr(const CStyleCastExpr *S) {
Douglas Gregor5c193b92009-07-28 00:33:38 +0000915 VisitExplicitCastExpr(S);
916}
917
Chandler Carruth631abd92011-06-16 06:47:06 +0000918void StmtProfiler::VisitBinaryOperator(const BinaryOperator *S) {
Douglas Gregor5c193b92009-07-28 00:33:38 +0000919 VisitExpr(S);
920 ID.AddInteger(S->getOpcode());
921}
922
Chandler Carruth631abd92011-06-16 06:47:06 +0000923void
924StmtProfiler::VisitCompoundAssignOperator(const CompoundAssignOperator *S) {
Douglas Gregor5c193b92009-07-28 00:33:38 +0000925 VisitBinaryOperator(S);
926}
927
Chandler Carruth631abd92011-06-16 06:47:06 +0000928void StmtProfiler::VisitConditionalOperator(const ConditionalOperator *S) {
Douglas Gregor5c193b92009-07-28 00:33:38 +0000929 VisitExpr(S);
930}
931
Chandler Carruth631abd92011-06-16 06:47:06 +0000932void StmtProfiler::VisitBinaryConditionalOperator(
Chandler Carruthcf5f43c2011-06-21 23:26:32 +0000933 const BinaryConditionalOperator *S) {
John McCallc07a0c72011-02-17 10:25:35 +0000934 VisitExpr(S);
935}
936
Chandler Carruth631abd92011-06-16 06:47:06 +0000937void StmtProfiler::VisitAddrLabelExpr(const AddrLabelExpr *S) {
Douglas Gregor5c193b92009-07-28 00:33:38 +0000938 VisitExpr(S);
Chris Lattnerc8e630e2011-02-17 07:39:24 +0000939 VisitDecl(S->getLabel());
Douglas Gregor5c193b92009-07-28 00:33:38 +0000940}
941
Chandler Carruth631abd92011-06-16 06:47:06 +0000942void StmtProfiler::VisitStmtExpr(const StmtExpr *S) {
Douglas Gregor5c193b92009-07-28 00:33:38 +0000943 VisitExpr(S);
944}
945
Chandler Carruth631abd92011-06-16 06:47:06 +0000946void StmtProfiler::VisitShuffleVectorExpr(const ShuffleVectorExpr *S) {
Douglas Gregor5c193b92009-07-28 00:33:38 +0000947 VisitExpr(S);
948}
949
Hal Finkelc4d7c822013-09-18 03:29:45 +0000950void StmtProfiler::VisitConvertVectorExpr(const ConvertVectorExpr *S) {
951 VisitExpr(S);
952}
953
Chandler Carruth631abd92011-06-16 06:47:06 +0000954void StmtProfiler::VisitChooseExpr(const ChooseExpr *S) {
Douglas Gregor5c193b92009-07-28 00:33:38 +0000955 VisitExpr(S);
956}
957
Chandler Carruth631abd92011-06-16 06:47:06 +0000958void StmtProfiler::VisitGNUNullExpr(const GNUNullExpr *S) {
Douglas Gregor5c193b92009-07-28 00:33:38 +0000959 VisitExpr(S);
960}
961
Chandler Carruth631abd92011-06-16 06:47:06 +0000962void StmtProfiler::VisitVAArgExpr(const VAArgExpr *S) {
Douglas Gregor00044172009-07-29 16:09:57 +0000963 VisitExpr(S);
964}
965
Chandler Carruth631abd92011-06-16 06:47:06 +0000966void StmtProfiler::VisitInitListExpr(const InitListExpr *S) {
Douglas Gregor5c193b92009-07-28 00:33:38 +0000967 if (S->getSyntacticForm()) {
968 VisitInitListExpr(S->getSyntacticForm());
969 return;
970 }
Mike Stump11289f42009-09-09 15:08:12 +0000971
Douglas Gregor5c193b92009-07-28 00:33:38 +0000972 VisitExpr(S);
973}
974
Chandler Carruth631abd92011-06-16 06:47:06 +0000975void StmtProfiler::VisitDesignatedInitExpr(const DesignatedInitExpr *S) {
Douglas Gregor5c193b92009-07-28 00:33:38 +0000976 VisitExpr(S);
977 ID.AddBoolean(S->usesGNUSyntax());
David Majnemerf7e36092016-06-23 00:15:04 +0000978 for (const DesignatedInitExpr::Designator &D : S->designators()) {
979 if (D.isFieldDesignator()) {
Douglas Gregor5c193b92009-07-28 00:33:38 +0000980 ID.AddInteger(0);
David Majnemerf7e36092016-06-23 00:15:04 +0000981 VisitName(D.getFieldName());
Douglas Gregor5c193b92009-07-28 00:33:38 +0000982 continue;
983 }
Mike Stump11289f42009-09-09 15:08:12 +0000984
David Majnemerf7e36092016-06-23 00:15:04 +0000985 if (D.isArrayDesignator()) {
Douglas Gregor5c193b92009-07-28 00:33:38 +0000986 ID.AddInteger(1);
987 } else {
David Majnemerf7e36092016-06-23 00:15:04 +0000988 assert(D.isArrayRangeDesignator());
Douglas Gregor5c193b92009-07-28 00:33:38 +0000989 ID.AddInteger(2);
990 }
David Majnemerf7e36092016-06-23 00:15:04 +0000991 ID.AddInteger(D.getFirstExprIndex());
Douglas Gregor5c193b92009-07-28 00:33:38 +0000992 }
993}
994
Yunzhong Gaocb779302015-06-10 00:27:52 +0000995// Seems that if VisitInitListExpr() only works on the syntactic form of an
996// InitListExpr, then a DesignatedInitUpdateExpr is not encountered.
997void StmtProfiler::VisitDesignatedInitUpdateExpr(
998 const DesignatedInitUpdateExpr *S) {
999 llvm_unreachable("Unexpected DesignatedInitUpdateExpr in syntactic form of "
1000 "initializer");
1001}
1002
Richard Smith410306b2016-12-12 02:53:20 +00001003void StmtProfiler::VisitArrayInitLoopExpr(const ArrayInitLoopExpr *S) {
1004 VisitExpr(S);
1005}
1006
1007void StmtProfiler::VisitArrayInitIndexExpr(const ArrayInitIndexExpr *S) {
1008 VisitExpr(S);
1009}
1010
Yunzhong Gaocb779302015-06-10 00:27:52 +00001011void StmtProfiler::VisitNoInitExpr(const NoInitExpr *S) {
1012 llvm_unreachable("Unexpected NoInitExpr in syntactic form of initializer");
1013}
1014
Chandler Carruth631abd92011-06-16 06:47:06 +00001015void StmtProfiler::VisitImplicitValueInitExpr(const ImplicitValueInitExpr *S) {
Douglas Gregor5c193b92009-07-28 00:33:38 +00001016 VisitExpr(S);
1017}
1018
Chandler Carruth631abd92011-06-16 06:47:06 +00001019void StmtProfiler::VisitExtVectorElementExpr(const ExtVectorElementExpr *S) {
Douglas Gregor5c193b92009-07-28 00:33:38 +00001020 VisitExpr(S);
1021 VisitName(&S->getAccessor());
1022}
1023
Chandler Carruth631abd92011-06-16 06:47:06 +00001024void StmtProfiler::VisitBlockExpr(const BlockExpr *S) {
Douglas Gregor5c193b92009-07-28 00:33:38 +00001025 VisitExpr(S);
1026 VisitDecl(S->getBlockDecl());
1027}
1028
Chandler Carruth631abd92011-06-16 06:47:06 +00001029void StmtProfiler::VisitGenericSelectionExpr(const GenericSelectionExpr *S) {
Peter Collingbourne91147592011-04-15 00:35:48 +00001030 VisitExpr(S);
1031 for (unsigned i = 0; i != S->getNumAssocs(); ++i) {
1032 QualType T = S->getAssocType(i);
1033 if (T.isNull())
Craig Topper36250ad2014-05-12 05:36:57 +00001034 ID.AddPointer(nullptr);
Peter Collingbourne91147592011-04-15 00:35:48 +00001035 else
1036 VisitType(T);
1037 VisitExpr(S->getAssocExpr(i));
1038 }
1039}
1040
John McCallfe96e0b2011-11-06 09:01:30 +00001041void StmtProfiler::VisitPseudoObjectExpr(const PseudoObjectExpr *S) {
1042 VisitExpr(S);
1043 for (PseudoObjectExpr::const_semantics_iterator
1044 i = S->semantics_begin(), e = S->semantics_end(); i != e; ++i)
1045 // Normally, we would not profile the source expressions of OVEs.
1046 if (const OpaqueValueExpr *OVE = dyn_cast<OpaqueValueExpr>(*i))
1047 Visit(OVE->getSourceExpr());
1048}
1049
Eli Friedmandf14b3a2011-10-11 02:20:01 +00001050void StmtProfiler::VisitAtomicExpr(const AtomicExpr *S) {
1051 VisitExpr(S);
Eli Friedman4b72fdd2011-10-14 20:59:01 +00001052 ID.AddInteger(S->getOp());
Eli Friedmandf14b3a2011-10-11 02:20:01 +00001053}
1054
Chandler Carruth631abd92011-06-16 06:47:06 +00001055static Stmt::StmtClass DecodeOperatorCall(const CXXOperatorCallExpr *S,
John McCalle3027922010-08-25 11:45:40 +00001056 UnaryOperatorKind &UnaryOp,
1057 BinaryOperatorKind &BinaryOp) {
Douglas Gregore9ceb312010-05-19 04:13:23 +00001058 switch (S->getOperator()) {
1059 case OO_None:
1060 case OO_New:
1061 case OO_Delete:
1062 case OO_Array_New:
1063 case OO_Array_Delete:
1064 case OO_Arrow:
1065 case OO_Call:
1066 case OO_Conditional:
Richard Smith9be594e2015-10-22 05:12:22 +00001067 case OO_Coawait:
Douglas Gregore9ceb312010-05-19 04:13:23 +00001068 case NUM_OVERLOADED_OPERATORS:
1069 llvm_unreachable("Invalid operator call kind");
Douglas Gregore9ceb312010-05-19 04:13:23 +00001070
1071 case OO_Plus:
1072 if (S->getNumArgs() == 1) {
John McCalle3027922010-08-25 11:45:40 +00001073 UnaryOp = UO_Plus;
Douglas Gregore9ceb312010-05-19 04:13:23 +00001074 return Stmt::UnaryOperatorClass;
1075 }
1076
John McCalle3027922010-08-25 11:45:40 +00001077 BinaryOp = BO_Add;
Douglas Gregore9ceb312010-05-19 04:13:23 +00001078 return Stmt::BinaryOperatorClass;
1079
1080 case OO_Minus:
1081 if (S->getNumArgs() == 1) {
John McCalle3027922010-08-25 11:45:40 +00001082 UnaryOp = UO_Minus;
Douglas Gregore9ceb312010-05-19 04:13:23 +00001083 return Stmt::UnaryOperatorClass;
1084 }
1085
John McCalle3027922010-08-25 11:45:40 +00001086 BinaryOp = BO_Sub;
Douglas Gregore9ceb312010-05-19 04:13:23 +00001087 return Stmt::BinaryOperatorClass;
1088
1089 case OO_Star:
1090 if (S->getNumArgs() == 1) {
Richard Smithf15acc52014-06-05 22:43:40 +00001091 UnaryOp = UO_Deref;
Douglas Gregore9ceb312010-05-19 04:13:23 +00001092 return Stmt::UnaryOperatorClass;
1093 }
1094
Richard Smithf15acc52014-06-05 22:43:40 +00001095 BinaryOp = BO_Mul;
Douglas Gregore9ceb312010-05-19 04:13:23 +00001096 return Stmt::BinaryOperatorClass;
1097
1098 case OO_Slash:
John McCalle3027922010-08-25 11:45:40 +00001099 BinaryOp = BO_Div;
Douglas Gregore9ceb312010-05-19 04:13:23 +00001100 return Stmt::BinaryOperatorClass;
1101
1102 case OO_Percent:
John McCalle3027922010-08-25 11:45:40 +00001103 BinaryOp = BO_Rem;
Douglas Gregore9ceb312010-05-19 04:13:23 +00001104 return Stmt::BinaryOperatorClass;
1105
1106 case OO_Caret:
John McCalle3027922010-08-25 11:45:40 +00001107 BinaryOp = BO_Xor;
Douglas Gregore9ceb312010-05-19 04:13:23 +00001108 return Stmt::BinaryOperatorClass;
1109
1110 case OO_Amp:
1111 if (S->getNumArgs() == 1) {
John McCalle3027922010-08-25 11:45:40 +00001112 UnaryOp = UO_AddrOf;
Douglas Gregore9ceb312010-05-19 04:13:23 +00001113 return Stmt::UnaryOperatorClass;
1114 }
1115
John McCalle3027922010-08-25 11:45:40 +00001116 BinaryOp = BO_And;
Douglas Gregore9ceb312010-05-19 04:13:23 +00001117 return Stmt::BinaryOperatorClass;
1118
1119 case OO_Pipe:
John McCalle3027922010-08-25 11:45:40 +00001120 BinaryOp = BO_Or;
Douglas Gregore9ceb312010-05-19 04:13:23 +00001121 return Stmt::BinaryOperatorClass;
1122
1123 case OO_Tilde:
John McCalle3027922010-08-25 11:45:40 +00001124 UnaryOp = UO_Not;
Douglas Gregore9ceb312010-05-19 04:13:23 +00001125 return Stmt::UnaryOperatorClass;
1126
1127 case OO_Exclaim:
John McCalle3027922010-08-25 11:45:40 +00001128 UnaryOp = UO_LNot;
Douglas Gregore9ceb312010-05-19 04:13:23 +00001129 return Stmt::UnaryOperatorClass;
1130
1131 case OO_Equal:
John McCalle3027922010-08-25 11:45:40 +00001132 BinaryOp = BO_Assign;
Douglas Gregore9ceb312010-05-19 04:13:23 +00001133 return Stmt::BinaryOperatorClass;
1134
1135 case OO_Less:
John McCalle3027922010-08-25 11:45:40 +00001136 BinaryOp = BO_LT;
Douglas Gregore9ceb312010-05-19 04:13:23 +00001137 return Stmt::BinaryOperatorClass;
1138
1139 case OO_Greater:
John McCalle3027922010-08-25 11:45:40 +00001140 BinaryOp = BO_GT;
Douglas Gregore9ceb312010-05-19 04:13:23 +00001141 return Stmt::BinaryOperatorClass;
1142
1143 case OO_PlusEqual:
John McCalle3027922010-08-25 11:45:40 +00001144 BinaryOp = BO_AddAssign;
Douglas Gregore9ceb312010-05-19 04:13:23 +00001145 return Stmt::CompoundAssignOperatorClass;
1146
1147 case OO_MinusEqual:
John McCalle3027922010-08-25 11:45:40 +00001148 BinaryOp = BO_SubAssign;
Douglas Gregore9ceb312010-05-19 04:13:23 +00001149 return Stmt::CompoundAssignOperatorClass;
1150
1151 case OO_StarEqual:
John McCalle3027922010-08-25 11:45:40 +00001152 BinaryOp = BO_MulAssign;
Douglas Gregore9ceb312010-05-19 04:13:23 +00001153 return Stmt::CompoundAssignOperatorClass;
1154
1155 case OO_SlashEqual:
John McCalle3027922010-08-25 11:45:40 +00001156 BinaryOp = BO_DivAssign;
Douglas Gregore9ceb312010-05-19 04:13:23 +00001157 return Stmt::CompoundAssignOperatorClass;
1158
1159 case OO_PercentEqual:
John McCalle3027922010-08-25 11:45:40 +00001160 BinaryOp = BO_RemAssign;
Douglas Gregore9ceb312010-05-19 04:13:23 +00001161 return Stmt::CompoundAssignOperatorClass;
1162
1163 case OO_CaretEqual:
John McCalle3027922010-08-25 11:45:40 +00001164 BinaryOp = BO_XorAssign;
Douglas Gregore9ceb312010-05-19 04:13:23 +00001165 return Stmt::CompoundAssignOperatorClass;
1166
1167 case OO_AmpEqual:
John McCalle3027922010-08-25 11:45:40 +00001168 BinaryOp = BO_AndAssign;
Douglas Gregore9ceb312010-05-19 04:13:23 +00001169 return Stmt::CompoundAssignOperatorClass;
1170
1171 case OO_PipeEqual:
John McCalle3027922010-08-25 11:45:40 +00001172 BinaryOp = BO_OrAssign;
Douglas Gregore9ceb312010-05-19 04:13:23 +00001173 return Stmt::CompoundAssignOperatorClass;
1174
1175 case OO_LessLess:
John McCalle3027922010-08-25 11:45:40 +00001176 BinaryOp = BO_Shl;
Douglas Gregore9ceb312010-05-19 04:13:23 +00001177 return Stmt::BinaryOperatorClass;
1178
1179 case OO_GreaterGreater:
John McCalle3027922010-08-25 11:45:40 +00001180 BinaryOp = BO_Shr;
Douglas Gregore9ceb312010-05-19 04:13:23 +00001181 return Stmt::BinaryOperatorClass;
1182
1183 case OO_LessLessEqual:
John McCalle3027922010-08-25 11:45:40 +00001184 BinaryOp = BO_ShlAssign;
Douglas Gregore9ceb312010-05-19 04:13:23 +00001185 return Stmt::CompoundAssignOperatorClass;
1186
1187 case OO_GreaterGreaterEqual:
John McCalle3027922010-08-25 11:45:40 +00001188 BinaryOp = BO_ShrAssign;
Douglas Gregore9ceb312010-05-19 04:13:23 +00001189 return Stmt::CompoundAssignOperatorClass;
1190
1191 case OO_EqualEqual:
John McCalle3027922010-08-25 11:45:40 +00001192 BinaryOp = BO_EQ;
Douglas Gregore9ceb312010-05-19 04:13:23 +00001193 return Stmt::BinaryOperatorClass;
1194
1195 case OO_ExclaimEqual:
John McCalle3027922010-08-25 11:45:40 +00001196 BinaryOp = BO_NE;
Douglas Gregore9ceb312010-05-19 04:13:23 +00001197 return Stmt::BinaryOperatorClass;
1198
1199 case OO_LessEqual:
John McCalle3027922010-08-25 11:45:40 +00001200 BinaryOp = BO_LE;
Douglas Gregore9ceb312010-05-19 04:13:23 +00001201 return Stmt::BinaryOperatorClass;
1202
1203 case OO_GreaterEqual:
John McCalle3027922010-08-25 11:45:40 +00001204 BinaryOp = BO_GE;
Douglas Gregore9ceb312010-05-19 04:13:23 +00001205 return Stmt::BinaryOperatorClass;
1206
1207 case OO_AmpAmp:
John McCalle3027922010-08-25 11:45:40 +00001208 BinaryOp = BO_LAnd;
Douglas Gregore9ceb312010-05-19 04:13:23 +00001209 return Stmt::BinaryOperatorClass;
1210
1211 case OO_PipePipe:
John McCalle3027922010-08-25 11:45:40 +00001212 BinaryOp = BO_LOr;
Douglas Gregore9ceb312010-05-19 04:13:23 +00001213 return Stmt::BinaryOperatorClass;
1214
1215 case OO_PlusPlus:
John McCalle3027922010-08-25 11:45:40 +00001216 UnaryOp = S->getNumArgs() == 1? UO_PreInc
1217 : UO_PostInc;
Douglas Gregore9ceb312010-05-19 04:13:23 +00001218 return Stmt::UnaryOperatorClass;
1219
1220 case OO_MinusMinus:
John McCalle3027922010-08-25 11:45:40 +00001221 UnaryOp = S->getNumArgs() == 1? UO_PreDec
1222 : UO_PostDec;
Douglas Gregore9ceb312010-05-19 04:13:23 +00001223 return Stmt::UnaryOperatorClass;
1224
1225 case OO_Comma:
John McCalle3027922010-08-25 11:45:40 +00001226 BinaryOp = BO_Comma;
Douglas Gregore9ceb312010-05-19 04:13:23 +00001227 return Stmt::BinaryOperatorClass;
1228
Douglas Gregore9ceb312010-05-19 04:13:23 +00001229 case OO_ArrowStar:
John McCalle3027922010-08-25 11:45:40 +00001230 BinaryOp = BO_PtrMemI;
Douglas Gregore9ceb312010-05-19 04:13:23 +00001231 return Stmt::BinaryOperatorClass;
1232
1233 case OO_Subscript:
1234 return Stmt::ArraySubscriptExprClass;
1235 }
1236
1237 llvm_unreachable("Invalid overloaded operator expression");
1238}
Richard Smithf15acc52014-06-05 22:43:40 +00001239
Chandler Carruth631abd92011-06-16 06:47:06 +00001240void StmtProfiler::VisitCXXOperatorCallExpr(const CXXOperatorCallExpr *S) {
Douglas Gregore9ceb312010-05-19 04:13:23 +00001241 if (S->isTypeDependent()) {
1242 // Type-dependent operator calls are profiled like their underlying
1243 // syntactic operator.
Richard Smithbac0a0d2016-10-24 18:47:04 +00001244 //
1245 // An operator call to operator-> is always implicit, so just skip it. The
1246 // enclosing MemberExpr will profile the actual member access.
1247 if (S->getOperator() == OO_Arrow)
1248 return Visit(S->getArg(0));
1249
John McCalle3027922010-08-25 11:45:40 +00001250 UnaryOperatorKind UnaryOp = UO_Extension;
1251 BinaryOperatorKind BinaryOp = BO_Comma;
Douglas Gregore9ceb312010-05-19 04:13:23 +00001252 Stmt::StmtClass SC = DecodeOperatorCall(S, UnaryOp, BinaryOp);
Richard Smithf15acc52014-06-05 22:43:40 +00001253
Douglas Gregore9ceb312010-05-19 04:13:23 +00001254 ID.AddInteger(SC);
1255 for (unsigned I = 0, N = S->getNumArgs(); I != N; ++I)
1256 Visit(S->getArg(I));
1257 if (SC == Stmt::UnaryOperatorClass)
1258 ID.AddInteger(UnaryOp);
1259 else if (SC == Stmt::BinaryOperatorClass ||
1260 SC == Stmt::CompoundAssignOperatorClass)
1261 ID.AddInteger(BinaryOp);
1262 else
1263 assert(SC == Stmt::ArraySubscriptExprClass);
Richard Smithf15acc52014-06-05 22:43:40 +00001264
Douglas Gregore9ceb312010-05-19 04:13:23 +00001265 return;
1266 }
Richard Smithf15acc52014-06-05 22:43:40 +00001267
Douglas Gregor5c193b92009-07-28 00:33:38 +00001268 VisitCallExpr(S);
1269 ID.AddInteger(S->getOperator());
1270}
1271
Chandler Carruth631abd92011-06-16 06:47:06 +00001272void StmtProfiler::VisitCXXMemberCallExpr(const CXXMemberCallExpr *S) {
Douglas Gregor5c193b92009-07-28 00:33:38 +00001273 VisitCallExpr(S);
1274}
1275
Chandler Carruth631abd92011-06-16 06:47:06 +00001276void StmtProfiler::VisitCUDAKernelCallExpr(const CUDAKernelCallExpr *S) {
Peter Collingbourne41f85462011-02-09 21:07:24 +00001277 VisitCallExpr(S);
1278}
1279
Chandler Carruth631abd92011-06-16 06:47:06 +00001280void StmtProfiler::VisitAsTypeExpr(const AsTypeExpr *S) {
Tanya Lattner55808c12011-06-04 00:47:47 +00001281 VisitExpr(S);
1282}
1283
Chandler Carruth631abd92011-06-16 06:47:06 +00001284void StmtProfiler::VisitCXXNamedCastExpr(const CXXNamedCastExpr *S) {
Douglas Gregor5c193b92009-07-28 00:33:38 +00001285 VisitExplicitCastExpr(S);
1286}
1287
Chandler Carruth631abd92011-06-16 06:47:06 +00001288void StmtProfiler::VisitCXXStaticCastExpr(const CXXStaticCastExpr *S) {
Douglas Gregor5c193b92009-07-28 00:33:38 +00001289 VisitCXXNamedCastExpr(S);
1290}
1291
Chandler Carruth631abd92011-06-16 06:47:06 +00001292void StmtProfiler::VisitCXXDynamicCastExpr(const CXXDynamicCastExpr *S) {
Douglas Gregor5c193b92009-07-28 00:33:38 +00001293 VisitCXXNamedCastExpr(S);
1294}
1295
Chandler Carruth631abd92011-06-16 06:47:06 +00001296void
1297StmtProfiler::VisitCXXReinterpretCastExpr(const CXXReinterpretCastExpr *S) {
Douglas Gregor5c193b92009-07-28 00:33:38 +00001298 VisitCXXNamedCastExpr(S);
1299}
1300
Chandler Carruth631abd92011-06-16 06:47:06 +00001301void StmtProfiler::VisitCXXConstCastExpr(const CXXConstCastExpr *S) {
Douglas Gregor5c193b92009-07-28 00:33:38 +00001302 VisitCXXNamedCastExpr(S);
1303}
1304
Richard Smithc67fdd42012-03-07 08:35:16 +00001305void StmtProfiler::VisitUserDefinedLiteral(const UserDefinedLiteral *S) {
1306 VisitCallExpr(S);
1307}
1308
Chandler Carruth631abd92011-06-16 06:47:06 +00001309void StmtProfiler::VisitCXXBoolLiteralExpr(const CXXBoolLiteralExpr *S) {
Douglas Gregor5c193b92009-07-28 00:33:38 +00001310 VisitExpr(S);
1311 ID.AddBoolean(S->getValue());
1312}
1313
Chandler Carruth631abd92011-06-16 06:47:06 +00001314void StmtProfiler::VisitCXXNullPtrLiteralExpr(const CXXNullPtrLiteralExpr *S) {
Douglas Gregor00044172009-07-29 16:09:57 +00001315 VisitExpr(S);
1316}
1317
Richard Smithcc1b96d2013-06-12 22:31:48 +00001318void StmtProfiler::VisitCXXStdInitializerListExpr(
1319 const CXXStdInitializerListExpr *S) {
1320 VisitExpr(S);
1321}
1322
Chandler Carruth631abd92011-06-16 06:47:06 +00001323void StmtProfiler::VisitCXXTypeidExpr(const CXXTypeidExpr *S) {
Douglas Gregor5c193b92009-07-28 00:33:38 +00001324 VisitExpr(S);
1325 if (S->isTypeOperand())
David Majnemer143c55e2013-09-27 07:04:31 +00001326 VisitType(S->getTypeOperandSourceInfo()->getType());
Douglas Gregor5c193b92009-07-28 00:33:38 +00001327}
1328
Chandler Carruth631abd92011-06-16 06:47:06 +00001329void StmtProfiler::VisitCXXUuidofExpr(const CXXUuidofExpr *S) {
Francois Pichet9f4f2072010-09-08 12:20:18 +00001330 VisitExpr(S);
1331 if (S->isTypeOperand())
David Majnemer143c55e2013-09-27 07:04:31 +00001332 VisitType(S->getTypeOperandSourceInfo()->getType());
Francois Pichet9f4f2072010-09-08 12:20:18 +00001333}
1334
John McCall5e77d762013-04-16 07:28:30 +00001335void StmtProfiler::VisitMSPropertyRefExpr(const MSPropertyRefExpr *S) {
1336 VisitExpr(S);
1337 VisitDecl(S->getPropertyDecl());
1338}
1339
Alexey Bataevf7630272015-11-25 12:01:00 +00001340void StmtProfiler::VisitMSPropertySubscriptExpr(
1341 const MSPropertySubscriptExpr *S) {
1342 VisitExpr(S);
1343}
1344
Chandler Carruth631abd92011-06-16 06:47:06 +00001345void StmtProfiler::VisitCXXThisExpr(const CXXThisExpr *S) {
Douglas Gregor5c193b92009-07-28 00:33:38 +00001346 VisitExpr(S);
Douglas Gregor3024f072012-04-16 07:05:22 +00001347 ID.AddBoolean(S->isImplicit());
Douglas Gregor5c193b92009-07-28 00:33:38 +00001348}
1349
Chandler Carruth631abd92011-06-16 06:47:06 +00001350void StmtProfiler::VisitCXXThrowExpr(const CXXThrowExpr *S) {
Douglas Gregor5c193b92009-07-28 00:33:38 +00001351 VisitExpr(S);
1352}
1353
Chandler Carruth631abd92011-06-16 06:47:06 +00001354void StmtProfiler::VisitCXXDefaultArgExpr(const CXXDefaultArgExpr *S) {
Douglas Gregor5c193b92009-07-28 00:33:38 +00001355 VisitExpr(S);
1356 VisitDecl(S->getParam());
1357}
1358
Richard Smith852c9db2013-04-20 22:23:05 +00001359void StmtProfiler::VisitCXXDefaultInitExpr(const CXXDefaultInitExpr *S) {
1360 VisitExpr(S);
1361 VisitDecl(S->getField());
1362}
1363
Chandler Carruth631abd92011-06-16 06:47:06 +00001364void StmtProfiler::VisitCXXBindTemporaryExpr(const CXXBindTemporaryExpr *S) {
Douglas Gregor5c193b92009-07-28 00:33:38 +00001365 VisitExpr(S);
1366 VisitDecl(
1367 const_cast<CXXDestructorDecl *>(S->getTemporary()->getDestructor()));
1368}
1369
Chandler Carruth631abd92011-06-16 06:47:06 +00001370void StmtProfiler::VisitCXXConstructExpr(const CXXConstructExpr *S) {
Douglas Gregor5c193b92009-07-28 00:33:38 +00001371 VisitExpr(S);
1372 VisitDecl(S->getConstructor());
1373 ID.AddBoolean(S->isElidable());
1374}
1375
Richard Smith5179eb72016-06-28 19:03:57 +00001376void StmtProfiler::VisitCXXInheritedCtorInitExpr(
1377 const CXXInheritedCtorInitExpr *S) {
1378 VisitExpr(S);
1379 VisitDecl(S->getConstructor());
1380}
1381
Chandler Carruth631abd92011-06-16 06:47:06 +00001382void StmtProfiler::VisitCXXFunctionalCastExpr(const CXXFunctionalCastExpr *S) {
Douglas Gregor5c193b92009-07-28 00:33:38 +00001383 VisitExplicitCastExpr(S);
1384}
1385
Chandler Carruth631abd92011-06-16 06:47:06 +00001386void
1387StmtProfiler::VisitCXXTemporaryObjectExpr(const CXXTemporaryObjectExpr *S) {
Douglas Gregor5c193b92009-07-28 00:33:38 +00001388 VisitCXXConstructExpr(S);
1389}
1390
Chandler Carruth631abd92011-06-16 06:47:06 +00001391void
Douglas Gregore31e6062012-02-07 10:09:13 +00001392StmtProfiler::VisitLambdaExpr(const LambdaExpr *S) {
1393 VisitExpr(S);
1394 for (LambdaExpr::capture_iterator C = S->explicit_capture_begin(),
1395 CEnd = S->explicit_capture_end();
1396 C != CEnd; ++C) {
1397 ID.AddInteger(C->getCaptureKind());
Richard Smithba71c082013-05-16 06:20:58 +00001398 switch (C->getCaptureKind()) {
Faisal Validc6b5962016-03-21 09:25:37 +00001399 case LCK_StarThis:
Richard Smithba71c082013-05-16 06:20:58 +00001400 case LCK_This:
1401 break;
1402 case LCK_ByRef:
1403 case LCK_ByCopy:
Douglas Gregore31e6062012-02-07 10:09:13 +00001404 VisitDecl(C->getCapturedVar());
1405 ID.AddBoolean(C->isPackExpansion());
Richard Smithba71c082013-05-16 06:20:58 +00001406 break;
Alexey Bataev39c81e22014-08-28 04:28:19 +00001407 case LCK_VLAType:
1408 llvm_unreachable("VLA type in explicit captures.");
Douglas Gregore31e6062012-02-07 10:09:13 +00001409 }
1410 }
1411 // Note: If we actually needed to be able to match lambda
1412 // expressions, we would have to consider parameters and return type
1413 // here, among other things.
1414 VisitStmt(S->getBody());
1415}
1416
1417void
Chandler Carruth631abd92011-06-16 06:47:06 +00001418StmtProfiler::VisitCXXScalarValueInitExpr(const CXXScalarValueInitExpr *S) {
Douglas Gregor5c193b92009-07-28 00:33:38 +00001419 VisitExpr(S);
1420}
1421
Chandler Carruth631abd92011-06-16 06:47:06 +00001422void StmtProfiler::VisitCXXDeleteExpr(const CXXDeleteExpr *S) {
Douglas Gregor5c193b92009-07-28 00:33:38 +00001423 VisitExpr(S);
1424 ID.AddBoolean(S->isGlobalDelete());
1425 ID.AddBoolean(S->isArrayForm());
1426 VisitDecl(S->getOperatorDelete());
1427}
1428
Chandler Carruth631abd92011-06-16 06:47:06 +00001429void StmtProfiler::VisitCXXNewExpr(const CXXNewExpr *S) {
Douglas Gregor5c193b92009-07-28 00:33:38 +00001430 VisitExpr(S);
1431 VisitType(S->getAllocatedType());
1432 VisitDecl(S->getOperatorNew());
1433 VisitDecl(S->getOperatorDelete());
Douglas Gregor5c193b92009-07-28 00:33:38 +00001434 ID.AddBoolean(S->isArray());
1435 ID.AddInteger(S->getNumPlacementArgs());
1436 ID.AddBoolean(S->isGlobalNew());
1437 ID.AddBoolean(S->isParenTypeId());
Sebastian Redl6047f072012-02-16 12:22:20 +00001438 ID.AddInteger(S->getInitializationStyle());
Douglas Gregor5c193b92009-07-28 00:33:38 +00001439}
1440
Chandler Carruth631abd92011-06-16 06:47:06 +00001441void
1442StmtProfiler::VisitCXXPseudoDestructorExpr(const CXXPseudoDestructorExpr *S) {
Douglas Gregorad8a3362009-09-04 17:36:40 +00001443 VisitExpr(S);
1444 ID.AddBoolean(S->isArrow());
1445 VisitNestedNameSpecifier(S->getQualifier());
Craig Topper36250ad2014-05-12 05:36:57 +00001446 ID.AddBoolean(S->getScopeTypeInfo() != nullptr);
Eli Friedman85641392013-08-09 23:37:05 +00001447 if (S->getScopeTypeInfo())
1448 VisitType(S->getScopeTypeInfo()->getType());
Craig Topper36250ad2014-05-12 05:36:57 +00001449 ID.AddBoolean(S->getDestroyedTypeInfo() != nullptr);
Eli Friedman85641392013-08-09 23:37:05 +00001450 if (S->getDestroyedTypeInfo())
1451 VisitType(S->getDestroyedType());
1452 else
1453 ID.AddPointer(S->getDestroyedTypeIdentifier());
Douglas Gregorad8a3362009-09-04 17:36:40 +00001454}
1455
Chandler Carruth631abd92011-06-16 06:47:06 +00001456void StmtProfiler::VisitOverloadExpr(const OverloadExpr *S) {
Argyrios Kyrtzidisb482eb82010-08-15 20:53:20 +00001457 VisitExpr(S);
John McCalle66edc12009-11-24 19:00:30 +00001458 VisitNestedNameSpecifier(S->getQualifier());
Douglas Gregor5c193b92009-07-28 00:33:38 +00001459 VisitName(S->getName());
John McCalle66edc12009-11-24 19:00:30 +00001460 ID.AddBoolean(S->hasExplicitTemplateArgs());
1461 if (S->hasExplicitTemplateArgs())
James Y Knight04ec5bf2015-12-24 02:59:37 +00001462 VisitTemplateArguments(S->getTemplateArgs(), S->getNumTemplateArgs());
Argyrios Kyrtzidisf4505452010-08-15 01:15:38 +00001463}
1464
1465void
Chandler Carruth631abd92011-06-16 06:47:06 +00001466StmtProfiler::VisitUnresolvedLookupExpr(const UnresolvedLookupExpr *S) {
Argyrios Kyrtzidisf4505452010-08-15 01:15:38 +00001467 VisitOverloadExpr(S);
Douglas Gregor5c193b92009-07-28 00:33:38 +00001468}
1469
Douglas Gregor29c42f22012-02-24 07:38:34 +00001470void StmtProfiler::VisitTypeTraitExpr(const TypeTraitExpr *S) {
1471 VisitExpr(S);
1472 ID.AddInteger(S->getTrait());
1473 ID.AddInteger(S->getNumArgs());
1474 for (unsigned I = 0, N = S->getNumArgs(); I != N; ++I)
1475 VisitType(S->getArg(I)->getType());
1476}
1477
Chandler Carruth631abd92011-06-16 06:47:06 +00001478void StmtProfiler::VisitArrayTypeTraitExpr(const ArrayTypeTraitExpr *S) {
John Wiegley6242b6a2011-04-28 00:16:57 +00001479 VisitExpr(S);
1480 ID.AddInteger(S->getTrait());
1481 VisitType(S->getQueriedType());
1482}
1483
Chandler Carruth631abd92011-06-16 06:47:06 +00001484void StmtProfiler::VisitExpressionTraitExpr(const ExpressionTraitExpr *S) {
John Wiegleyf9f65842011-04-25 06:54:41 +00001485 VisitExpr(S);
1486 ID.AddInteger(S->getTrait());
1487 VisitExpr(S->getQueriedExpression());
1488}
1489
Chandler Carruth631abd92011-06-16 06:47:06 +00001490void StmtProfiler::VisitDependentScopeDeclRefExpr(
1491 const DependentScopeDeclRefExpr *S) {
Douglas Gregor5c193b92009-07-28 00:33:38 +00001492 VisitExpr(S);
1493 VisitName(S->getDeclName());
1494 VisitNestedNameSpecifier(S->getQualifier());
John McCalle66edc12009-11-24 19:00:30 +00001495 ID.AddBoolean(S->hasExplicitTemplateArgs());
1496 if (S->hasExplicitTemplateArgs())
1497 VisitTemplateArguments(S->getTemplateArgs(), S->getNumTemplateArgs());
Douglas Gregor5c193b92009-07-28 00:33:38 +00001498}
1499
Chandler Carruth631abd92011-06-16 06:47:06 +00001500void StmtProfiler::VisitExprWithCleanups(const ExprWithCleanups *S) {
Douglas Gregora7095092009-07-28 14:44:31 +00001501 VisitExpr(S);
Douglas Gregora7095092009-07-28 14:44:31 +00001502}
1503
Chandler Carruth631abd92011-06-16 06:47:06 +00001504void StmtProfiler::VisitCXXUnresolvedConstructExpr(
1505 const CXXUnresolvedConstructExpr *S) {
Douglas Gregora7095092009-07-28 14:44:31 +00001506 VisitExpr(S);
1507 VisitType(S->getTypeAsWritten());
1508}
1509
Chandler Carruth631abd92011-06-16 06:47:06 +00001510void StmtProfiler::VisitCXXDependentScopeMemberExpr(
1511 const CXXDependentScopeMemberExpr *S) {
John McCall2d74de92009-12-01 22:10:20 +00001512 ID.AddBoolean(S->isImplicitAccess());
1513 if (!S->isImplicitAccess()) {
1514 VisitExpr(S);
1515 ID.AddBoolean(S->isArrow());
1516 }
Douglas Gregorc26e0f62009-09-03 16:14:30 +00001517 VisitNestedNameSpecifier(S->getQualifier());
Douglas Gregora7095092009-07-28 14:44:31 +00001518 VisitName(S->getMember());
John McCall2d74de92009-12-01 22:10:20 +00001519 ID.AddBoolean(S->hasExplicitTemplateArgs());
1520 if (S->hasExplicitTemplateArgs())
John McCall10eae182009-11-30 22:42:35 +00001521 VisitTemplateArguments(S->getTemplateArgs(), S->getNumTemplateArgs());
1522}
1523
Chandler Carruth631abd92011-06-16 06:47:06 +00001524void StmtProfiler::VisitUnresolvedMemberExpr(const UnresolvedMemberExpr *S) {
John McCall2d74de92009-12-01 22:10:20 +00001525 ID.AddBoolean(S->isImplicitAccess());
1526 if (!S->isImplicitAccess()) {
1527 VisitExpr(S);
1528 ID.AddBoolean(S->isArrow());
1529 }
John McCall10eae182009-11-30 22:42:35 +00001530 VisitNestedNameSpecifier(S->getQualifier());
1531 VisitName(S->getMemberName());
1532 ID.AddBoolean(S->hasExplicitTemplateArgs());
1533 if (S->hasExplicitTemplateArgs())
1534 VisitTemplateArguments(S->getTemplateArgs(), S->getNumTemplateArgs());
Douglas Gregora7095092009-07-28 14:44:31 +00001535}
1536
Chandler Carruth631abd92011-06-16 06:47:06 +00001537void StmtProfiler::VisitCXXNoexceptExpr(const CXXNoexceptExpr *S) {
Sebastian Redl4202c0f2010-09-10 20:55:43 +00001538 VisitExpr(S);
1539}
1540
Chandler Carruth631abd92011-06-16 06:47:06 +00001541void StmtProfiler::VisitPackExpansionExpr(const PackExpansionExpr *S) {
Douglas Gregore8e9dd62011-01-03 17:17:50 +00001542 VisitExpr(S);
1543}
1544
Chandler Carruth631abd92011-06-16 06:47:06 +00001545void StmtProfiler::VisitSizeOfPackExpr(const SizeOfPackExpr *S) {
Douglas Gregor820ba7b2011-01-04 17:33:58 +00001546 VisitExpr(S);
1547 VisitDecl(S->getPack());
Richard Smithd784e682015-09-23 21:41:42 +00001548 if (S->isPartiallySubstituted()) {
1549 auto Args = S->getPartialArguments();
1550 ID.AddInteger(Args.size());
1551 for (const auto &TA : Args)
1552 VisitTemplateArgument(TA);
1553 } else {
1554 ID.AddInteger(0);
1555 }
Douglas Gregor820ba7b2011-01-04 17:33:58 +00001556}
1557
Douglas Gregorcdbc5392011-01-15 01:15:58 +00001558void StmtProfiler::VisitSubstNonTypeTemplateParmPackExpr(
Chandler Carruth631abd92011-06-16 06:47:06 +00001559 const SubstNonTypeTemplateParmPackExpr *S) {
Douglas Gregorcdbc5392011-01-15 01:15:58 +00001560 VisitExpr(S);
1561 VisitDecl(S->getParameterPack());
1562 VisitTemplateArgument(S->getArgumentPack());
1563}
1564
John McCall7c454bb2011-07-15 05:09:51 +00001565void StmtProfiler::VisitSubstNonTypeTemplateParmExpr(
1566 const SubstNonTypeTemplateParmExpr *E) {
1567 // Profile exactly as the replacement expression.
1568 Visit(E->getReplacement());
1569}
1570
Richard Smithb15fe3a2012-09-12 00:56:43 +00001571void StmtProfiler::VisitFunctionParmPackExpr(const FunctionParmPackExpr *S) {
1572 VisitExpr(S);
1573 VisitDecl(S->getParameterPack());
1574 ID.AddInteger(S->getNumExpansions());
1575 for (FunctionParmPackExpr::iterator I = S->begin(), E = S->end(); I != E; ++I)
1576 VisitDecl(*I);
1577}
1578
Douglas Gregorfe314812011-06-21 17:03:29 +00001579void StmtProfiler::VisitMaterializeTemporaryExpr(
1580 const MaterializeTemporaryExpr *S) {
1581 VisitExpr(S);
1582}
1583
Richard Smith0f0af192014-11-08 05:07:16 +00001584void StmtProfiler::VisitCXXFoldExpr(const CXXFoldExpr *S) {
1585 VisitExpr(S);
1586 ID.AddInteger(S->getOperator());
1587}
1588
Richard Smith9f690bd2015-10-27 06:02:45 +00001589void StmtProfiler::VisitCoroutineBodyStmt(const CoroutineBodyStmt *S) {
1590 VisitStmt(S);
1591}
1592
1593void StmtProfiler::VisitCoreturnStmt(const CoreturnStmt *S) {
1594 VisitStmt(S);
1595}
1596
1597void StmtProfiler::VisitCoawaitExpr(const CoawaitExpr *S) {
1598 VisitExpr(S);
1599}
1600
1601void StmtProfiler::VisitCoyieldExpr(const CoyieldExpr *S) {
1602 VisitExpr(S);
1603}
1604
Chandler Carruth631abd92011-06-16 06:47:06 +00001605void StmtProfiler::VisitOpaqueValueExpr(const OpaqueValueExpr *E) {
John McCall8d69a212010-11-15 23:31:06 +00001606 VisitExpr(E);
1607}
1608
Kaelyn Takatae1f49d52014-10-27 18:07:20 +00001609void StmtProfiler::VisitTypoExpr(const TypoExpr *E) {
1610 VisitExpr(E);
1611}
1612
Chandler Carruth631abd92011-06-16 06:47:06 +00001613void StmtProfiler::VisitObjCStringLiteral(const ObjCStringLiteral *S) {
Douglas Gregora7095092009-07-28 14:44:31 +00001614 VisitExpr(S);
1615}
1616
Patrick Beard0caa3942012-04-19 00:25:12 +00001617void StmtProfiler::VisitObjCBoxedExpr(const ObjCBoxedExpr *E) {
Ted Kremeneke65b0862012-03-06 20:05:56 +00001618 VisitExpr(E);
1619}
1620
1621void StmtProfiler::VisitObjCArrayLiteral(const ObjCArrayLiteral *E) {
1622 VisitExpr(E);
1623}
1624
1625void StmtProfiler::VisitObjCDictionaryLiteral(const ObjCDictionaryLiteral *E) {
1626 VisitExpr(E);
1627}
1628
Chandler Carruth631abd92011-06-16 06:47:06 +00001629void StmtProfiler::VisitObjCEncodeExpr(const ObjCEncodeExpr *S) {
Douglas Gregora7095092009-07-28 14:44:31 +00001630 VisitExpr(S);
1631 VisitType(S->getEncodedType());
1632}
1633
Chandler Carruth631abd92011-06-16 06:47:06 +00001634void StmtProfiler::VisitObjCSelectorExpr(const ObjCSelectorExpr *S) {
Douglas Gregora7095092009-07-28 14:44:31 +00001635 VisitExpr(S);
1636 VisitName(S->getSelector());
1637}
1638
Chandler Carruth631abd92011-06-16 06:47:06 +00001639void StmtProfiler::VisitObjCProtocolExpr(const ObjCProtocolExpr *S) {
Douglas Gregora7095092009-07-28 14:44:31 +00001640 VisitExpr(S);
1641 VisitDecl(S->getProtocol());
1642}
1643
Chandler Carruth631abd92011-06-16 06:47:06 +00001644void StmtProfiler::VisitObjCIvarRefExpr(const ObjCIvarRefExpr *S) {
Douglas Gregora7095092009-07-28 14:44:31 +00001645 VisitExpr(S);
1646 VisitDecl(S->getDecl());
1647 ID.AddBoolean(S->isArrow());
1648 ID.AddBoolean(S->isFreeIvar());
1649}
1650
Chandler Carruth631abd92011-06-16 06:47:06 +00001651void StmtProfiler::VisitObjCPropertyRefExpr(const ObjCPropertyRefExpr *S) {
Douglas Gregora7095092009-07-28 14:44:31 +00001652 VisitExpr(S);
John McCallb7bd14f2010-12-02 01:19:52 +00001653 if (S->isImplicitProperty()) {
1654 VisitDecl(S->getImplicitPropertyGetter());
1655 VisitDecl(S->getImplicitPropertySetter());
1656 } else {
1657 VisitDecl(S->getExplicitProperty());
Fariborz Jahanian681c0752010-10-14 16:04:05 +00001658 }
Fariborz Jahanian681c0752010-10-14 16:04:05 +00001659 if (S->isSuperReceiver()) {
1660 ID.AddBoolean(S->isSuperReceiver());
John McCallb7bd14f2010-12-02 01:19:52 +00001661 VisitType(S->getSuperReceiverType());
Fariborz Jahanian681c0752010-10-14 16:04:05 +00001662 }
Douglas Gregora7095092009-07-28 14:44:31 +00001663}
1664
Ted Kremeneke65b0862012-03-06 20:05:56 +00001665void StmtProfiler::VisitObjCSubscriptRefExpr(const ObjCSubscriptRefExpr *S) {
1666 VisitExpr(S);
1667 VisitDecl(S->getAtIndexMethodDecl());
1668 VisitDecl(S->setAtIndexMethodDecl());
1669}
1670
Chandler Carruth631abd92011-06-16 06:47:06 +00001671void StmtProfiler::VisitObjCMessageExpr(const ObjCMessageExpr *S) {
Douglas Gregora7095092009-07-28 14:44:31 +00001672 VisitExpr(S);
1673 VisitName(S->getSelector());
1674 VisitDecl(S->getMethodDecl());
1675}
1676
Chandler Carruth631abd92011-06-16 06:47:06 +00001677void StmtProfiler::VisitObjCIsaExpr(const ObjCIsaExpr *S) {
Douglas Gregora7095092009-07-28 14:44:31 +00001678 VisitExpr(S);
1679 ID.AddBoolean(S->isArrow());
1680}
1681
Ted Kremeneke65b0862012-03-06 20:05:56 +00001682void StmtProfiler::VisitObjCBoolLiteralExpr(const ObjCBoolLiteralExpr *S) {
1683 VisitExpr(S);
1684 ID.AddBoolean(S->getValue());
1685}
1686
Chandler Carruth631abd92011-06-16 06:47:06 +00001687void StmtProfiler::VisitObjCIndirectCopyRestoreExpr(
1688 const ObjCIndirectCopyRestoreExpr *S) {
John McCall31168b02011-06-15 23:02:42 +00001689 VisitExpr(S);
1690 ID.AddBoolean(S->shouldCopy());
1691}
1692
Chandler Carruth631abd92011-06-16 06:47:06 +00001693void StmtProfiler::VisitObjCBridgedCastExpr(const ObjCBridgedCastExpr *S) {
John McCall31168b02011-06-15 23:02:42 +00001694 VisitExplicitCastExpr(S);
1695 ID.AddBoolean(S->getBridgeKind());
1696}
1697
Erik Pilkington29099de2016-07-16 00:35:23 +00001698void StmtProfiler::VisitObjCAvailabilityCheckExpr(
1699 const ObjCAvailabilityCheckExpr *S) {
1700 VisitExpr(S);
1701}
1702
Chandler Carruth631abd92011-06-16 06:47:06 +00001703void StmtProfiler::VisitDecl(const Decl *D) {
Douglas Gregor70317122009-07-31 15:45:02 +00001704 ID.AddInteger(D? D->getKind() : 0);
Mike Stump11289f42009-09-09 15:08:12 +00001705
Douglas Gregora5dd9f82009-07-30 23:18:24 +00001706 if (Canonical && D) {
Chandler Carruth631abd92011-06-16 06:47:06 +00001707 if (const NonTypeTemplateParmDecl *NTTP =
1708 dyn_cast<NonTypeTemplateParmDecl>(D)) {
Douglas Gregord9aedfa2009-07-28 15:32:17 +00001709 ID.AddInteger(NTTP->getDepth());
1710 ID.AddInteger(NTTP->getIndex());
Douglas Gregorf5500772011-01-05 15:48:55 +00001711 ID.AddBoolean(NTTP->isParameterPack());
Douglas Gregor00044172009-07-29 16:09:57 +00001712 VisitType(NTTP->getType());
Douglas Gregor5c193b92009-07-28 00:33:38 +00001713 return;
1714 }
Mike Stump11289f42009-09-09 15:08:12 +00001715
Chandler Carruth631abd92011-06-16 06:47:06 +00001716 if (const ParmVarDecl *Parm = dyn_cast<ParmVarDecl>(D)) {
John McCall8fb0d9d2011-05-01 22:35:37 +00001717 // The Itanium C++ ABI uses the type, scope depth, and scope
1718 // index of a parameter when mangling expressions that involve
1719 // function parameters, so we will use the parameter's type for
1720 // establishing function parameter identity. That way, our
1721 // definition of "equivalent" (per C++ [temp.over.link]) is at
1722 // least as strong as the definition of "equivalent" used for
1723 // name mangling.
Douglas Gregor70317122009-07-31 15:45:02 +00001724 VisitType(Parm->getType());
John McCall8fb0d9d2011-05-01 22:35:37 +00001725 ID.AddInteger(Parm->getFunctionScopeDepth());
1726 ID.AddInteger(Parm->getFunctionScopeIndex());
Douglas Gregor70317122009-07-31 15:45:02 +00001727 return;
1728 }
Mike Stump11289f42009-09-09 15:08:12 +00001729
Richard Smithd9a1cd82012-04-02 18:53:24 +00001730 if (const TemplateTypeParmDecl *TTP =
1731 dyn_cast<TemplateTypeParmDecl>(D)) {
1732 ID.AddInteger(TTP->getDepth());
1733 ID.AddInteger(TTP->getIndex());
1734 ID.AddBoolean(TTP->isParameterPack());
1735 return;
1736 }
1737
Chandler Carruth631abd92011-06-16 06:47:06 +00001738 if (const TemplateTemplateParmDecl *TTP =
1739 dyn_cast<TemplateTemplateParmDecl>(D)) {
Douglas Gregorc97f09f2009-07-31 15:46:56 +00001740 ID.AddInteger(TTP->getDepth());
1741 ID.AddInteger(TTP->getIndex());
Douglas Gregorf5500772011-01-05 15:48:55 +00001742 ID.AddBoolean(TTP->isParameterPack());
Douglas Gregorc97f09f2009-07-31 15:46:56 +00001743 return;
1744 }
Douglas Gregor5c193b92009-07-28 00:33:38 +00001745 }
Mike Stump11289f42009-09-09 15:08:12 +00001746
Craig Topper36250ad2014-05-12 05:36:57 +00001747 ID.AddPointer(D? D->getCanonicalDecl() : nullptr);
Douglas Gregord9aedfa2009-07-28 15:32:17 +00001748}
1749
1750void StmtProfiler::VisitType(QualType T) {
1751 if (Canonical)
1752 T = Context.getCanonicalType(T);
Mike Stump11289f42009-09-09 15:08:12 +00001753
Douglas Gregor5c193b92009-07-28 00:33:38 +00001754 ID.AddPointer(T.getAsOpaquePtr());
1755}
1756
1757void StmtProfiler::VisitName(DeclarationName Name) {
1758 ID.AddPointer(Name.getAsOpaquePtr());
1759}
1760
1761void StmtProfiler::VisitNestedNameSpecifier(NestedNameSpecifier *NNS) {
1762 if (Canonical)
1763 NNS = Context.getCanonicalNestedNameSpecifier(NNS);
1764 ID.AddPointer(NNS);
1765}
1766
1767void StmtProfiler::VisitTemplateName(TemplateName Name) {
1768 if (Canonical)
1769 Name = Context.getCanonicalTemplateName(Name);
Mike Stump11289f42009-09-09 15:08:12 +00001770
Douglas Gregor5c193b92009-07-28 00:33:38 +00001771 Name.Profile(ID);
1772}
1773
John McCall0ad16662009-10-29 08:12:44 +00001774void StmtProfiler::VisitTemplateArguments(const TemplateArgumentLoc *Args,
Douglas Gregor5c193b92009-07-28 00:33:38 +00001775 unsigned NumArgs) {
1776 ID.AddInteger(NumArgs);
John McCall0ad16662009-10-29 08:12:44 +00001777 for (unsigned I = 0; I != NumArgs; ++I)
1778 VisitTemplateArgument(Args[I].getArgument());
1779}
Mike Stump11289f42009-09-09 15:08:12 +00001780
John McCall0ad16662009-10-29 08:12:44 +00001781void StmtProfiler::VisitTemplateArgument(const TemplateArgument &Arg) {
1782 // Mostly repetitive with TemplateArgument::Profile!
1783 ID.AddInteger(Arg.getKind());
1784 switch (Arg.getKind()) {
1785 case TemplateArgument::Null:
1786 break;
Mike Stump11289f42009-09-09 15:08:12 +00001787
John McCall0ad16662009-10-29 08:12:44 +00001788 case TemplateArgument::Type:
1789 VisitType(Arg.getAsType());
1790 break;
Mike Stump11289f42009-09-09 15:08:12 +00001791
Douglas Gregor9167f8b2009-11-11 01:00:40 +00001792 case TemplateArgument::Template:
Douglas Gregore4ff4b52011-01-05 18:58:31 +00001793 case TemplateArgument::TemplateExpansion:
1794 VisitTemplateName(Arg.getAsTemplateOrTemplatePattern());
Douglas Gregor9167f8b2009-11-11 01:00:40 +00001795 break;
Alexis Hunta8136cc2010-05-05 15:23:54 +00001796
John McCall0ad16662009-10-29 08:12:44 +00001797 case TemplateArgument::Declaration:
1798 VisitDecl(Arg.getAsDecl());
1799 break;
Mike Stump11289f42009-09-09 15:08:12 +00001800
Eli Friedmanb826a002012-09-26 02:36:12 +00001801 case TemplateArgument::NullPtr:
1802 VisitType(Arg.getNullPtrType());
1803 break;
1804
John McCall0ad16662009-10-29 08:12:44 +00001805 case TemplateArgument::Integral:
Benjamin Kramer6003ad52012-06-07 15:09:51 +00001806 Arg.getAsIntegral().Profile(ID);
John McCall0ad16662009-10-29 08:12:44 +00001807 VisitType(Arg.getIntegralType());
1808 break;
Mike Stump11289f42009-09-09 15:08:12 +00001809
John McCall0ad16662009-10-29 08:12:44 +00001810 case TemplateArgument::Expression:
1811 Visit(Arg.getAsExpr());
1812 break;
Mike Stump11289f42009-09-09 15:08:12 +00001813
John McCall0ad16662009-10-29 08:12:44 +00001814 case TemplateArgument::Pack:
Aaron Ballman2a89e852014-07-15 21:32:31 +00001815 for (const auto &P : Arg.pack_elements())
1816 VisitTemplateArgument(P);
John McCall0ad16662009-10-29 08:12:44 +00001817 break;
Douglas Gregor5c193b92009-07-28 00:33:38 +00001818 }
1819}
1820
Jay Foad39c79802011-01-12 09:06:06 +00001821void Stmt::Profile(llvm::FoldingSetNodeID &ID, const ASTContext &Context,
Chandler Carruth631abd92011-06-16 06:47:06 +00001822 bool Canonical) const {
Douglas Gregor5c193b92009-07-28 00:33:38 +00001823 StmtProfiler Profiler(ID, Context, Canonical);
1824 Profiler.Visit(this);
1825}