blob: a86fded2a2c47cdec6373b568dea0b7ef01a571a [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"
Richard Trieu639d7b62017-02-22 22:22:42 +000022#include "clang/AST/ODRHash.h"
Douglas Gregor5c193b92009-07-28 00:33:38 +000023#include "clang/AST/StmtVisitor.h"
24#include "llvm/ADT/FoldingSet.h"
Douglas Gregor5c193b92009-07-28 00:33:38 +000025using namespace clang;
26
27namespace {
Chandler Carruth631abd92011-06-16 06:47:06 +000028 class StmtProfiler : public ConstStmtVisitor<StmtProfiler> {
Richard Trieu639d7b62017-02-22 22:22:42 +000029 protected:
Douglas Gregor5c193b92009-07-28 00:33:38 +000030 llvm::FoldingSetNodeID &ID;
Douglas Gregor5c193b92009-07-28 00:33:38 +000031 bool Canonical;
Mike Stump11289f42009-09-09 15:08:12 +000032
Douglas Gregor5c193b92009-07-28 00:33:38 +000033 public:
Richard Trieu639d7b62017-02-22 22:22:42 +000034 StmtProfiler(llvm::FoldingSetNodeID &ID, bool Canonical)
35 : ID(ID), Canonical(Canonical) {}
36
37 virtual ~StmtProfiler() {}
Mike Stump11289f42009-09-09 15:08:12 +000038
Chandler Carruth631abd92011-06-16 06:47:06 +000039 void VisitStmt(const Stmt *S);
Mike Stump11289f42009-09-09 15:08:12 +000040
Chandler Carruth631abd92011-06-16 06:47:06 +000041#define STMT(Node, Base) void Visit##Node(const Node *S);
Alexis Hunt656bb312010-05-05 15:24:00 +000042#include "clang/AST/StmtNodes.inc"
Mike Stump11289f42009-09-09 15:08:12 +000043
Douglas Gregor5c193b92009-07-28 00:33:38 +000044 /// \brief Visit a declaration that is referenced within an expression
45 /// or statement.
Richard Trieu639d7b62017-02-22 22:22:42 +000046 virtual void VisitDecl(const Decl *D) = 0;
Mike Stump11289f42009-09-09 15:08:12 +000047
48 /// \brief Visit a type that is referenced within an expression or
Douglas Gregor5c193b92009-07-28 00:33:38 +000049 /// statement.
Richard Trieu639d7b62017-02-22 22:22:42 +000050 virtual void VisitType(QualType T) = 0;
Mike Stump11289f42009-09-09 15:08:12 +000051
Douglas Gregor5c193b92009-07-28 00:33:38 +000052 /// \brief Visit a name that occurs within an expression or statement.
Richard Trieu639d7b62017-02-22 22:22:42 +000053 virtual void VisitName(DeclarationName Name) = 0;
54
55 /// \brief Visit identifiers that are not in Decl's or Type's.
56 virtual void VisitIdentifierInfo(IdentifierInfo *II) = 0;
Mike Stump11289f42009-09-09 15:08:12 +000057
Douglas Gregor5c193b92009-07-28 00:33:38 +000058 /// \brief Visit a nested-name-specifier that occurs within an expression
59 /// or statement.
Richard Trieu639d7b62017-02-22 22:22:42 +000060 virtual void VisitNestedNameSpecifier(NestedNameSpecifier *NNS) = 0;
Mike Stump11289f42009-09-09 15:08:12 +000061
Douglas Gregor5c193b92009-07-28 00:33:38 +000062 /// \brief Visit a template name that occurs within an expression or
63 /// statement.
Richard Trieu639d7b62017-02-22 22:22:42 +000064 virtual void VisitTemplateName(TemplateName Name) = 0;
Mike Stump11289f42009-09-09 15:08:12 +000065
Douglas Gregor5c193b92009-07-28 00:33:38 +000066 /// \brief Visit template arguments that occur within an expression or
67 /// statement.
Chandler Carruth631abd92011-06-16 06:47:06 +000068 void VisitTemplateArguments(const TemplateArgumentLoc *Args,
69 unsigned NumArgs);
John McCall0ad16662009-10-29 08:12:44 +000070
71 /// \brief Visit a single template argument.
72 void VisitTemplateArgument(const TemplateArgument &Arg);
Douglas Gregor5c193b92009-07-28 00:33:38 +000073 };
Richard Trieu639d7b62017-02-22 22:22:42 +000074
75 class StmtProfilerWithPointers : public StmtProfiler {
76 const ASTContext &Context;
77
78 public:
79 StmtProfilerWithPointers(llvm::FoldingSetNodeID &ID,
80 const ASTContext &Context, bool Canonical)
81 : StmtProfiler(ID, Canonical), Context(Context) {}
82 private:
83 void VisitDecl(const Decl *D) override {
84 ID.AddInteger(D ? D->getKind() : 0);
85
86 if (Canonical && D) {
87 if (const NonTypeTemplateParmDecl *NTTP =
88 dyn_cast<NonTypeTemplateParmDecl>(D)) {
89 ID.AddInteger(NTTP->getDepth());
90 ID.AddInteger(NTTP->getIndex());
91 ID.AddBoolean(NTTP->isParameterPack());
92 VisitType(NTTP->getType());
93 return;
94 }
95
96 if (const ParmVarDecl *Parm = dyn_cast<ParmVarDecl>(D)) {
97 // The Itanium C++ ABI uses the type, scope depth, and scope
98 // index of a parameter when mangling expressions that involve
99 // function parameters, so we will use the parameter's type for
100 // establishing function parameter identity. That way, our
101 // definition of "equivalent" (per C++ [temp.over.link]) is at
102 // least as strong as the definition of "equivalent" used for
103 // name mangling.
104 VisitType(Parm->getType());
105 ID.AddInteger(Parm->getFunctionScopeDepth());
106 ID.AddInteger(Parm->getFunctionScopeIndex());
107 return;
108 }
109
110 if (const TemplateTypeParmDecl *TTP =
111 dyn_cast<TemplateTypeParmDecl>(D)) {
112 ID.AddInteger(TTP->getDepth());
113 ID.AddInteger(TTP->getIndex());
114 ID.AddBoolean(TTP->isParameterPack());
115 return;
116 }
117
118 if (const TemplateTemplateParmDecl *TTP =
119 dyn_cast<TemplateTemplateParmDecl>(D)) {
120 ID.AddInteger(TTP->getDepth());
121 ID.AddInteger(TTP->getIndex());
122 ID.AddBoolean(TTP->isParameterPack());
123 return;
124 }
125 }
126
127 ID.AddPointer(D ? D->getCanonicalDecl() : nullptr);
128 }
129
130 void VisitType(QualType T) override {
Richard Trieua5f4ade2017-03-04 02:42:41 +0000131 if (Canonical && !T.isNull())
Richard Trieu639d7b62017-02-22 22:22:42 +0000132 T = Context.getCanonicalType(T);
133
134 ID.AddPointer(T.getAsOpaquePtr());
135 }
136
137 void VisitName(DeclarationName Name) override {
138 ID.AddPointer(Name.getAsOpaquePtr());
139 }
140
141 void VisitIdentifierInfo(IdentifierInfo *II) override {
142 ID.AddPointer(II);
143 }
144
145 void VisitNestedNameSpecifier(NestedNameSpecifier *NNS) override {
146 if (Canonical)
147 NNS = Context.getCanonicalNestedNameSpecifier(NNS);
148 ID.AddPointer(NNS);
149 }
150
151 void VisitTemplateName(TemplateName Name) override {
152 if (Canonical)
153 Name = Context.getCanonicalTemplateName(Name);
154
155 Name.Profile(ID);
156 }
157 };
158
159 class StmtProfilerWithoutPointers : public StmtProfiler {
160 ODRHash &Hash;
161 public:
162 StmtProfilerWithoutPointers(llvm::FoldingSetNodeID &ID, ODRHash &Hash)
163 : StmtProfiler(ID, false), Hash(Hash) {}
164
165 private:
166 void VisitType(QualType T) override {
167 Hash.AddQualType(T);
168 }
169
170 void VisitName(DeclarationName Name) override {
171 Hash.AddDeclarationName(Name);
172 }
173 void VisitIdentifierInfo(IdentifierInfo *II) override {
174 ID.AddBoolean(II);
175 if (II) {
176 Hash.AddIdentifierInfo(II);
177 }
178 }
179 void VisitDecl(const Decl *D) override {
180 ID.AddBoolean(D);
181 if (D) {
182 Hash.AddDecl(D);
183 }
184 }
185 void VisitTemplateName(TemplateName Name) override {
186 Hash.AddTemplateName(Name);
187 }
188 void VisitNestedNameSpecifier(NestedNameSpecifier *NNS) override {
Richard Trieu96b41642017-07-01 02:00:05 +0000189 ID.AddBoolean(NNS);
190 if (NNS) {
191 Hash.AddNestedNameSpecifier(NNS);
192 }
Richard Trieu639d7b62017-02-22 22:22:42 +0000193 }
194 };
Alexander Kornienkoab9db512015-06-22 23:07:51 +0000195}
Douglas Gregor5c193b92009-07-28 00:33:38 +0000196
Chandler Carruth631abd92011-06-16 06:47:06 +0000197void StmtProfiler::VisitStmt(const Stmt *S) {
Richard Trieu6a77a1c2016-06-10 04:52:09 +0000198 assert(S && "Requires non-null Stmt pointer");
Douglas Gregor5c193b92009-07-28 00:33:38 +0000199 ID.AddInteger(S->getStmtClass());
Benjamin Kramer642f1732015-07-02 21:03:14 +0000200 for (const Stmt *SubStmt : S->children()) {
201 if (SubStmt)
202 Visit(SubStmt);
Peter Collingbournecdb9f302012-03-01 16:34:31 +0000203 else
204 ID.AddInteger(0);
205 }
Douglas Gregor5c193b92009-07-28 00:33:38 +0000206}
207
Chandler Carruth631abd92011-06-16 06:47:06 +0000208void StmtProfiler::VisitDeclStmt(const DeclStmt *S) {
Douglas Gregor44882592009-07-28 15:27:13 +0000209 VisitStmt(S);
Aaron Ballman535bbcc2014-03-14 17:01:24 +0000210 for (const auto *D : S->decls())
211 VisitDecl(D);
Douglas Gregor44882592009-07-28 15:27:13 +0000212}
213
Chandler Carruth631abd92011-06-16 06:47:06 +0000214void StmtProfiler::VisitNullStmt(const NullStmt *S) {
Douglas Gregor44882592009-07-28 15:27:13 +0000215 VisitStmt(S);
216}
217
Chandler Carruth631abd92011-06-16 06:47:06 +0000218void StmtProfiler::VisitCompoundStmt(const CompoundStmt *S) {
Douglas Gregor44882592009-07-28 15:27:13 +0000219 VisitStmt(S);
220}
221
Chandler Carruth631abd92011-06-16 06:47:06 +0000222void StmtProfiler::VisitCaseStmt(const CaseStmt *S) {
Douglas Gregor44882592009-07-28 15:27:13 +0000223 VisitStmt(S);
224}
225
Chandler Carruth631abd92011-06-16 06:47:06 +0000226void StmtProfiler::VisitDefaultStmt(const DefaultStmt *S) {
Douglas Gregor44882592009-07-28 15:27:13 +0000227 VisitStmt(S);
228}
229
Chandler Carruth631abd92011-06-16 06:47:06 +0000230void StmtProfiler::VisitLabelStmt(const LabelStmt *S) {
Douglas Gregor44882592009-07-28 15:27:13 +0000231 VisitStmt(S);
Chris Lattnerc8e630e2011-02-17 07:39:24 +0000232 VisitDecl(S->getDecl());
Douglas Gregor44882592009-07-28 15:27:13 +0000233}
234
Richard Smithc202b282012-04-14 00:33:13 +0000235void StmtProfiler::VisitAttributedStmt(const AttributedStmt *S) {
236 VisitStmt(S);
237 // TODO: maybe visit attributes?
238}
239
Chandler Carruth631abd92011-06-16 06:47:06 +0000240void StmtProfiler::VisitIfStmt(const IfStmt *S) {
Douglas Gregor44882592009-07-28 15:27:13 +0000241 VisitStmt(S);
Douglas Gregor7bab5ff2009-11-25 00:27:52 +0000242 VisitDecl(S->getConditionVariable());
Douglas Gregor44882592009-07-28 15:27:13 +0000243}
244
Chandler Carruth631abd92011-06-16 06:47:06 +0000245void StmtProfiler::VisitSwitchStmt(const SwitchStmt *S) {
Douglas Gregor00044172009-07-29 16:09:57 +0000246 VisitStmt(S);
Douglas Gregor7bab5ff2009-11-25 00:27:52 +0000247 VisitDecl(S->getConditionVariable());
Douglas Gregor00044172009-07-29 16:09:57 +0000248}
249
Chandler Carruth631abd92011-06-16 06:47:06 +0000250void StmtProfiler::VisitWhileStmt(const WhileStmt *S) {
Douglas Gregor44882592009-07-28 15:27:13 +0000251 VisitStmt(S);
Douglas Gregor7bab5ff2009-11-25 00:27:52 +0000252 VisitDecl(S->getConditionVariable());
Douglas Gregor44882592009-07-28 15:27:13 +0000253}
254
Chandler Carruth631abd92011-06-16 06:47:06 +0000255void StmtProfiler::VisitDoStmt(const DoStmt *S) {
Douglas Gregor44882592009-07-28 15:27:13 +0000256 VisitStmt(S);
257}
258
Chandler Carruth631abd92011-06-16 06:47:06 +0000259void StmtProfiler::VisitForStmt(const ForStmt *S) {
Douglas Gregor44882592009-07-28 15:27:13 +0000260 VisitStmt(S);
261}
262
Chandler Carruth631abd92011-06-16 06:47:06 +0000263void StmtProfiler::VisitGotoStmt(const GotoStmt *S) {
Douglas Gregor44882592009-07-28 15:27:13 +0000264 VisitStmt(S);
Chris Lattnerc8e630e2011-02-17 07:39:24 +0000265 VisitDecl(S->getLabel());
Douglas Gregor44882592009-07-28 15:27:13 +0000266}
267
Chandler Carruth631abd92011-06-16 06:47:06 +0000268void StmtProfiler::VisitIndirectGotoStmt(const IndirectGotoStmt *S) {
Douglas Gregor44882592009-07-28 15:27:13 +0000269 VisitStmt(S);
270}
271
Chandler Carruth631abd92011-06-16 06:47:06 +0000272void StmtProfiler::VisitContinueStmt(const ContinueStmt *S) {
Douglas Gregor44882592009-07-28 15:27:13 +0000273 VisitStmt(S);
274}
275
Chandler Carruth631abd92011-06-16 06:47:06 +0000276void StmtProfiler::VisitBreakStmt(const BreakStmt *S) {
Douglas Gregor44882592009-07-28 15:27:13 +0000277 VisitStmt(S);
278}
279
Chandler Carruth631abd92011-06-16 06:47:06 +0000280void StmtProfiler::VisitReturnStmt(const ReturnStmt *S) {
Douglas Gregor44882592009-07-28 15:27:13 +0000281 VisitStmt(S);
282}
283
Chad Rosierde70e0e2012-08-25 00:11:56 +0000284void StmtProfiler::VisitGCCAsmStmt(const GCCAsmStmt *S) {
Douglas Gregor44882592009-07-28 15:27:13 +0000285 VisitStmt(S);
286 ID.AddBoolean(S->isVolatile());
287 ID.AddBoolean(S->isSimple());
288 VisitStringLiteral(S->getAsmString());
289 ID.AddInteger(S->getNumOutputs());
290 for (unsigned I = 0, N = S->getNumOutputs(); I != N; ++I) {
291 ID.AddString(S->getOutputName(I));
292 VisitStringLiteral(S->getOutputConstraintLiteral(I));
293 }
294 ID.AddInteger(S->getNumInputs());
295 for (unsigned I = 0, N = S->getNumInputs(); I != N; ++I) {
296 ID.AddString(S->getInputName(I));
297 VisitStringLiteral(S->getInputConstraintLiteral(I));
298 }
299 ID.AddInteger(S->getNumClobbers());
300 for (unsigned I = 0, N = S->getNumClobbers(); I != N; ++I)
Chad Rosierd9fb09a2012-08-27 23:28:41 +0000301 VisitStringLiteral(S->getClobberStringLiteral(I));
Douglas Gregor44882592009-07-28 15:27:13 +0000302}
303
Chad Rosier32503022012-06-11 20:47:18 +0000304void StmtProfiler::VisitMSAsmStmt(const MSAsmStmt *S) {
305 // FIXME: Implement MS style inline asm statement profiler.
306 VisitStmt(S);
307}
308
Chandler Carruth631abd92011-06-16 06:47:06 +0000309void StmtProfiler::VisitCXXCatchStmt(const CXXCatchStmt *S) {
Douglas Gregor44882592009-07-28 15:27:13 +0000310 VisitStmt(S);
311 VisitType(S->getCaughtType());
312}
313
Chandler Carruth631abd92011-06-16 06:47:06 +0000314void StmtProfiler::VisitCXXTryStmt(const CXXTryStmt *S) {
Douglas Gregor44882592009-07-28 15:27:13 +0000315 VisitStmt(S);
316}
317
Chandler Carruth631abd92011-06-16 06:47:06 +0000318void StmtProfiler::VisitCXXForRangeStmt(const CXXForRangeStmt *S) {
Richard Smith02e85f32011-04-14 22:09:26 +0000319 VisitStmt(S);
320}
321
Douglas Gregordeb4a2be2011-10-25 01:33:02 +0000322void StmtProfiler::VisitMSDependentExistsStmt(const MSDependentExistsStmt *S) {
323 VisitStmt(S);
324 ID.AddBoolean(S->isIfExists());
325 VisitNestedNameSpecifier(S->getQualifierLoc().getNestedNameSpecifier());
326 VisitName(S->getNameInfo().getName());
327}
328
Chandler Carruth631abd92011-06-16 06:47:06 +0000329void StmtProfiler::VisitSEHTryStmt(const SEHTryStmt *S) {
John Wiegley1c0675e2011-04-28 01:08:34 +0000330 VisitStmt(S);
331}
332
Chandler Carruth631abd92011-06-16 06:47:06 +0000333void StmtProfiler::VisitSEHFinallyStmt(const SEHFinallyStmt *S) {
John Wiegley1c0675e2011-04-28 01:08:34 +0000334 VisitStmt(S);
335}
336
Chandler Carruth631abd92011-06-16 06:47:06 +0000337void StmtProfiler::VisitSEHExceptStmt(const SEHExceptStmt *S) {
John Wiegley1c0675e2011-04-28 01:08:34 +0000338 VisitStmt(S);
339}
340
Nico Weber9b982072014-07-07 00:12:30 +0000341void StmtProfiler::VisitSEHLeaveStmt(const SEHLeaveStmt *S) {
342 VisitStmt(S);
343}
344
Tareq A. Siraj24110cc2013-04-16 18:53:08 +0000345void StmtProfiler::VisitCapturedStmt(const CapturedStmt *S) {
346 VisitStmt(S);
347}
348
Chandler Carruth631abd92011-06-16 06:47:06 +0000349void StmtProfiler::VisitObjCForCollectionStmt(const ObjCForCollectionStmt *S) {
Douglas Gregor44882592009-07-28 15:27:13 +0000350 VisitStmt(S);
351}
352
Chandler Carruth631abd92011-06-16 06:47:06 +0000353void StmtProfiler::VisitObjCAtCatchStmt(const ObjCAtCatchStmt *S) {
Douglas Gregor44882592009-07-28 15:27:13 +0000354 VisitStmt(S);
355 ID.AddBoolean(S->hasEllipsis());
356 if (S->getCatchParamDecl())
357 VisitType(S->getCatchParamDecl()->getType());
358}
359
Chandler Carruth631abd92011-06-16 06:47:06 +0000360void StmtProfiler::VisitObjCAtFinallyStmt(const ObjCAtFinallyStmt *S) {
Douglas Gregor44882592009-07-28 15:27:13 +0000361 VisitStmt(S);
362}
363
Chandler Carruth631abd92011-06-16 06:47:06 +0000364void StmtProfiler::VisitObjCAtTryStmt(const ObjCAtTryStmt *S) {
Douglas Gregor44882592009-07-28 15:27:13 +0000365 VisitStmt(S);
366}
367
Chandler Carruth631abd92011-06-16 06:47:06 +0000368void
369StmtProfiler::VisitObjCAtSynchronizedStmt(const ObjCAtSynchronizedStmt *S) {
Douglas Gregor44882592009-07-28 15:27:13 +0000370 VisitStmt(S);
371}
372
Chandler Carruth631abd92011-06-16 06:47:06 +0000373void StmtProfiler::VisitObjCAtThrowStmt(const ObjCAtThrowStmt *S) {
Douglas Gregor44882592009-07-28 15:27:13 +0000374 VisitStmt(S);
375}
376
Chandler Carruth631abd92011-06-16 06:47:06 +0000377void
378StmtProfiler::VisitObjCAutoreleasePoolStmt(const ObjCAutoreleasePoolStmt *S) {
John McCall31168b02011-06-15 23:02:42 +0000379 VisitStmt(S);
380}
381
Alexey Bataev5ec3eb12013-07-19 03:13:43 +0000382namespace {
383class OMPClauseProfiler : public ConstOMPClauseVisitor<OMPClauseProfiler> {
384 StmtProfiler *Profiler;
Alexey Bataev756c1962013-09-24 03:17:45 +0000385 /// \brief Process clauses with list of variables.
386 template <typename T>
387 void VisitOMPClauseList(T *Node);
NAKAMURA Takumiaa13f942015-12-09 07:52:46 +0000388
Alexey Bataev5ec3eb12013-07-19 03:13:43 +0000389public:
390 OMPClauseProfiler(StmtProfiler *P) : Profiler(P) { }
391#define OPENMP_CLAUSE(Name, Class) \
392 void Visit##Class(const Class *C);
393#include "clang/Basic/OpenMPKinds.def"
Alexey Bataev3392d762016-02-16 11:18:12 +0000394 void VistOMPClauseWithPreInit(const OMPClauseWithPreInit *C);
Alexey Bataev005248a2016-02-25 05:25:57 +0000395 void VistOMPClauseWithPostUpdate(const OMPClauseWithPostUpdate *C);
Alexey Bataev5ec3eb12013-07-19 03:13:43 +0000396};
397
Alexey Bataev3392d762016-02-16 11:18:12 +0000398void OMPClauseProfiler::VistOMPClauseWithPreInit(
399 const OMPClauseWithPreInit *C) {
400 if (auto *S = C->getPreInitStmt())
401 Profiler->VisitStmt(S);
402}
403
Alexey Bataev005248a2016-02-25 05:25:57 +0000404void OMPClauseProfiler::VistOMPClauseWithPostUpdate(
405 const OMPClauseWithPostUpdate *C) {
Alexey Bataev37e594c2016-03-04 07:21:16 +0000406 VistOMPClauseWithPreInit(C);
Alexey Bataev005248a2016-02-25 05:25:57 +0000407 if (auto *E = C->getPostUpdateExpr())
408 Profiler->VisitStmt(E);
409}
410
Alexey Bataevaadd52e2014-02-13 05:29:23 +0000411void OMPClauseProfiler::VisitOMPIfClause(const OMPIfClause *C) {
Arpith Chacko Jacobfe4890a2017-01-18 20:40:48 +0000412 VistOMPClauseWithPreInit(C);
Alexey Bataevaadd52e2014-02-13 05:29:23 +0000413 if (C->getCondition())
414 Profiler->VisitStmt(C->getCondition());
415}
416
Alexey Bataev3778b602014-07-17 07:32:53 +0000417void OMPClauseProfiler::VisitOMPFinalClause(const OMPFinalClause *C) {
418 if (C->getCondition())
419 Profiler->VisitStmt(C->getCondition());
420}
421
Alexey Bataev568a8332014-03-06 06:15:19 +0000422void OMPClauseProfiler::VisitOMPNumThreadsClause(const OMPNumThreadsClause *C) {
Arpith Chacko Jacob33c849a2017-01-25 00:57:16 +0000423 VistOMPClauseWithPreInit(C);
Alexey Bataev568a8332014-03-06 06:15:19 +0000424 if (C->getNumThreads())
425 Profiler->VisitStmt(C->getNumThreads());
426}
427
Alexey Bataev62c87d22014-03-21 04:51:18 +0000428void OMPClauseProfiler::VisitOMPSafelenClause(const OMPSafelenClause *C) {
429 if (C->getSafelen())
430 Profiler->VisitStmt(C->getSafelen());
431}
432
Alexey Bataev66b15b52015-08-21 11:14:16 +0000433void OMPClauseProfiler::VisitOMPSimdlenClause(const OMPSimdlenClause *C) {
434 if (C->getSimdlen())
435 Profiler->VisitStmt(C->getSimdlen());
436}
437
Alexander Musman8bd31e62014-05-27 15:12:19 +0000438void OMPClauseProfiler::VisitOMPCollapseClause(const OMPCollapseClause *C) {
439 if (C->getNumForLoops())
440 Profiler->VisitStmt(C->getNumForLoops());
441}
442
Alexey Bataev5ec3eb12013-07-19 03:13:43 +0000443void OMPClauseProfiler::VisitOMPDefaultClause(const OMPDefaultClause *C) { }
Alexey Bataev756c1962013-09-24 03:17:45 +0000444
Alexey Bataevbcbadb62014-05-06 06:04:14 +0000445void OMPClauseProfiler::VisitOMPProcBindClause(const OMPProcBindClause *C) { }
446
Alexey Bataev56dafe82014-06-20 07:16:17 +0000447void OMPClauseProfiler::VisitOMPScheduleClause(const OMPScheduleClause *C) {
Alexey Bataev3392d762016-02-16 11:18:12 +0000448 VistOMPClauseWithPreInit(C);
449 if (auto *S = C->getChunkSize())
450 Profiler->VisitStmt(S);
Alexey Bataev56dafe82014-06-20 07:16:17 +0000451}
452
Alexey Bataev10e775f2015-07-30 11:36:16 +0000453void OMPClauseProfiler::VisitOMPOrderedClause(const OMPOrderedClause *C) {
454 if (auto *Num = C->getNumForLoops())
455 Profiler->VisitStmt(Num);
456}
Alexey Bataev142e1fc2014-06-20 09:44:06 +0000457
Alexey Bataev236070f2014-06-20 11:19:47 +0000458void OMPClauseProfiler::VisitOMPNowaitClause(const OMPNowaitClause *) {}
459
Alexey Bataev7aea99a2014-07-17 12:19:31 +0000460void OMPClauseProfiler::VisitOMPUntiedClause(const OMPUntiedClause *) {}
461
Alexey Bataev74ba3a52014-07-17 12:47:03 +0000462void OMPClauseProfiler::VisitOMPMergeableClause(const OMPMergeableClause *) {}
463
Alexey Bataevf98b00c2014-07-23 02:27:21 +0000464void OMPClauseProfiler::VisitOMPReadClause(const OMPReadClause *) {}
465
Alexey Bataevdea47612014-07-23 07:46:59 +0000466void OMPClauseProfiler::VisitOMPWriteClause(const OMPWriteClause *) {}
467
Alexey Bataev67a4f222014-07-23 10:25:33 +0000468void OMPClauseProfiler::VisitOMPUpdateClause(const OMPUpdateClause *) {}
469
Alexey Bataev459dec02014-07-24 06:46:57 +0000470void OMPClauseProfiler::VisitOMPCaptureClause(const OMPCaptureClause *) {}
471
Alexey Bataev82bad8b2014-07-24 08:55:34 +0000472void OMPClauseProfiler::VisitOMPSeqCstClause(const OMPSeqCstClause *) {}
473
Alexey Bataev346265e2015-09-25 10:37:12 +0000474void OMPClauseProfiler::VisitOMPThreadsClause(const OMPThreadsClause *) {}
475
Alexey Bataevd14d1e62015-09-28 06:39:35 +0000476void OMPClauseProfiler::VisitOMPSIMDClause(const OMPSIMDClause *) {}
477
Alexey Bataevb825de12015-12-07 10:51:44 +0000478void OMPClauseProfiler::VisitOMPNogroupClause(const OMPNogroupClause *) {}
479
Alexey Bataev756c1962013-09-24 03:17:45 +0000480template<typename T>
481void OMPClauseProfiler::VisitOMPClauseList(T *Node) {
Alexey Bataev03b340a2014-10-21 03:16:40 +0000482 for (auto *E : Node->varlists()) {
Richard Trieu6a77a1c2016-06-10 04:52:09 +0000483 if (E)
484 Profiler->VisitStmt(E);
Alexey Bataev03b340a2014-10-21 03:16:40 +0000485 }
Alexey Bataev756c1962013-09-24 03:17:45 +0000486}
Alexey Bataev5ec3eb12013-07-19 03:13:43 +0000487
488void OMPClauseProfiler::VisitOMPPrivateClause(const OMPPrivateClause *C) {
Alexey Bataev756c1962013-09-24 03:17:45 +0000489 VisitOMPClauseList(C);
Alexey Bataev03b340a2014-10-21 03:16:40 +0000490 for (auto *E : C->private_copies()) {
Richard Trieu6a77a1c2016-06-10 04:52:09 +0000491 if (E)
492 Profiler->VisitStmt(E);
Alexey Bataev03b340a2014-10-21 03:16:40 +0000493 }
Alexey Bataev5ec3eb12013-07-19 03:13:43 +0000494}
Alexey Bataev4a5bb772014-10-08 14:01:46 +0000495void
496OMPClauseProfiler::VisitOMPFirstprivateClause(const OMPFirstprivateClause *C) {
Alexey Bataevd5af8e42013-10-01 05:32:34 +0000497 VisitOMPClauseList(C);
Alexey Bataev417089f2016-02-17 13:19:37 +0000498 VistOMPClauseWithPreInit(C);
Alexey Bataev4a5bb772014-10-08 14:01:46 +0000499 for (auto *E : C->private_copies()) {
Richard Trieu6a77a1c2016-06-10 04:52:09 +0000500 if (E)
501 Profiler->VisitStmt(E);
Alexey Bataev4a5bb772014-10-08 14:01:46 +0000502 }
503 for (auto *E : C->inits()) {
Richard Trieu6a77a1c2016-06-10 04:52:09 +0000504 if (E)
505 Profiler->VisitStmt(E);
Alexey Bataev4a5bb772014-10-08 14:01:46 +0000506 }
Alexey Bataevd5af8e42013-10-01 05:32:34 +0000507}
Alexander Musman1bb328c2014-06-04 13:06:39 +0000508void
509OMPClauseProfiler::VisitOMPLastprivateClause(const OMPLastprivateClause *C) {
510 VisitOMPClauseList(C);
Alexey Bataev005248a2016-02-25 05:25:57 +0000511 VistOMPClauseWithPostUpdate(C);
Alexey Bataev38e89532015-04-16 04:54:05 +0000512 for (auto *E : C->source_exprs()) {
Richard Trieu6a77a1c2016-06-10 04:52:09 +0000513 if (E)
514 Profiler->VisitStmt(E);
Alexey Bataev38e89532015-04-16 04:54:05 +0000515 }
516 for (auto *E : C->destination_exprs()) {
Richard Trieu6a77a1c2016-06-10 04:52:09 +0000517 if (E)
518 Profiler->VisitStmt(E);
Alexey Bataev38e89532015-04-16 04:54:05 +0000519 }
520 for (auto *E : C->assignment_ops()) {
Richard Trieu6a77a1c2016-06-10 04:52:09 +0000521 if (E)
522 Profiler->VisitStmt(E);
Alexey Bataev38e89532015-04-16 04:54:05 +0000523 }
Alexander Musman1bb328c2014-06-04 13:06:39 +0000524}
Alexey Bataev758e55e2013-09-06 18:03:48 +0000525void OMPClauseProfiler::VisitOMPSharedClause(const OMPSharedClause *C) {
Alexey Bataev756c1962013-09-24 03:17:45 +0000526 VisitOMPClauseList(C);
Alexey Bataev758e55e2013-09-06 18:03:48 +0000527}
Alexey Bataevc5e02582014-06-16 07:08:35 +0000528void OMPClauseProfiler::VisitOMPReductionClause(
529 const OMPReductionClause *C) {
530 Profiler->VisitNestedNameSpecifier(
531 C->getQualifierLoc().getNestedNameSpecifier());
532 Profiler->VisitName(C->getNameInfo().getName());
533 VisitOMPClauseList(C);
Alexey Bataev61205072016-03-02 04:57:40 +0000534 VistOMPClauseWithPostUpdate(C);
Alexey Bataevf24e7b12015-10-08 09:10:53 +0000535 for (auto *E : C->privates()) {
Richard Trieu6a77a1c2016-06-10 04:52:09 +0000536 if (E)
537 Profiler->VisitStmt(E);
Alexey Bataevf24e7b12015-10-08 09:10:53 +0000538 }
Alexey Bataev794ba0d2015-04-10 10:43:45 +0000539 for (auto *E : C->lhs_exprs()) {
Richard Trieu6a77a1c2016-06-10 04:52:09 +0000540 if (E)
541 Profiler->VisitStmt(E);
Alexey Bataev794ba0d2015-04-10 10:43:45 +0000542 }
543 for (auto *E : C->rhs_exprs()) {
Richard Trieu6a77a1c2016-06-10 04:52:09 +0000544 if (E)
545 Profiler->VisitStmt(E);
Alexey Bataev794ba0d2015-04-10 10:43:45 +0000546 }
547 for (auto *E : C->reduction_ops()) {
Richard Trieu6a77a1c2016-06-10 04:52:09 +0000548 if (E)
549 Profiler->VisitStmt(E);
Alexey Bataev794ba0d2015-04-10 10:43:45 +0000550 }
Alexey Bataevc5e02582014-06-16 07:08:35 +0000551}
Alexey Bataev169d96a2017-07-18 20:17:46 +0000552void OMPClauseProfiler::VisitOMPTaskReductionClause(
553 const OMPTaskReductionClause *C) {
554 Profiler->VisitNestedNameSpecifier(
555 C->getQualifierLoc().getNestedNameSpecifier());
556 Profiler->VisitName(C->getNameInfo().getName());
557 VisitOMPClauseList(C);
558 VistOMPClauseWithPostUpdate(C);
559 for (auto *E : C->privates()) {
560 if (E)
561 Profiler->VisitStmt(E);
562 }
563 for (auto *E : C->lhs_exprs()) {
564 if (E)
565 Profiler->VisitStmt(E);
566 }
567 for (auto *E : C->rhs_exprs()) {
568 if (E)
569 Profiler->VisitStmt(E);
570 }
571 for (auto *E : C->reduction_ops()) {
572 if (E)
573 Profiler->VisitStmt(E);
574 }
575}
Alexey Bataevfa312f32017-07-21 18:48:21 +0000576void OMPClauseProfiler::VisitOMPInReductionClause(
577 const OMPInReductionClause *C) {
578 Profiler->VisitNestedNameSpecifier(
579 C->getQualifierLoc().getNestedNameSpecifier());
580 Profiler->VisitName(C->getNameInfo().getName());
581 VisitOMPClauseList(C);
582 VistOMPClauseWithPostUpdate(C);
583 for (auto *E : C->privates()) {
584 if (E)
585 Profiler->VisitStmt(E);
586 }
587 for (auto *E : C->lhs_exprs()) {
588 if (E)
589 Profiler->VisitStmt(E);
590 }
591 for (auto *E : C->rhs_exprs()) {
592 if (E)
593 Profiler->VisitStmt(E);
594 }
595 for (auto *E : C->reduction_ops()) {
596 if (E)
597 Profiler->VisitStmt(E);
598 }
599}
Alexander Musman8dba6642014-04-22 13:09:42 +0000600void OMPClauseProfiler::VisitOMPLinearClause(const OMPLinearClause *C) {
601 VisitOMPClauseList(C);
Alexey Bataev78849fb2016-03-09 09:49:00 +0000602 VistOMPClauseWithPostUpdate(C);
Alexey Bataevbd9fec12015-08-18 06:47:21 +0000603 for (auto *E : C->privates()) {
Richard Trieu6a77a1c2016-06-10 04:52:09 +0000604 if (E)
605 Profiler->VisitStmt(E);
Alexey Bataevbd9fec12015-08-18 06:47:21 +0000606 }
Alexander Musman3276a272015-03-21 10:12:56 +0000607 for (auto *E : C->inits()) {
Richard Trieu6a77a1c2016-06-10 04:52:09 +0000608 if (E)
609 Profiler->VisitStmt(E);
Alexander Musman3276a272015-03-21 10:12:56 +0000610 }
611 for (auto *E : C->updates()) {
Richard Trieu6a77a1c2016-06-10 04:52:09 +0000612 if (E)
613 Profiler->VisitStmt(E);
Alexander Musman3276a272015-03-21 10:12:56 +0000614 }
615 for (auto *E : C->finals()) {
Richard Trieu6a77a1c2016-06-10 04:52:09 +0000616 if (E)
617 Profiler->VisitStmt(E);
Alexander Musman3276a272015-03-21 10:12:56 +0000618 }
Richard Trieu6a77a1c2016-06-10 04:52:09 +0000619 if (C->getStep())
620 Profiler->VisitStmt(C->getStep());
621 if (C->getCalcStep())
622 Profiler->VisitStmt(C->getCalcStep());
Alexander Musman8dba6642014-04-22 13:09:42 +0000623}
Alexander Musmanf0d76e72014-05-29 14:36:25 +0000624void OMPClauseProfiler::VisitOMPAlignedClause(const OMPAlignedClause *C) {
625 VisitOMPClauseList(C);
Richard Trieu6a77a1c2016-06-10 04:52:09 +0000626 if (C->getAlignment())
627 Profiler->VisitStmt(C->getAlignment());
Alexander Musmanf0d76e72014-05-29 14:36:25 +0000628}
Alexey Bataevd48bcd82014-03-31 03:36:38 +0000629void OMPClauseProfiler::VisitOMPCopyinClause(const OMPCopyinClause *C) {
630 VisitOMPClauseList(C);
Alexey Bataevf56f98c2015-04-16 05:39:01 +0000631 for (auto *E : C->source_exprs()) {
Richard Trieu6a77a1c2016-06-10 04:52:09 +0000632 if (E)
633 Profiler->VisitStmt(E);
Alexey Bataevf56f98c2015-04-16 05:39:01 +0000634 }
635 for (auto *E : C->destination_exprs()) {
Richard Trieu6a77a1c2016-06-10 04:52:09 +0000636 if (E)
637 Profiler->VisitStmt(E);
Alexey Bataevf56f98c2015-04-16 05:39:01 +0000638 }
639 for (auto *E : C->assignment_ops()) {
Richard Trieu6a77a1c2016-06-10 04:52:09 +0000640 if (E)
641 Profiler->VisitStmt(E);
Alexey Bataevf56f98c2015-04-16 05:39:01 +0000642 }
Alexey Bataevd48bcd82014-03-31 03:36:38 +0000643}
Alexey Bataevbae9a792014-06-27 10:37:06 +0000644void
645OMPClauseProfiler::VisitOMPCopyprivateClause(const OMPCopyprivateClause *C) {
646 VisitOMPClauseList(C);
Alexey Bataeva63048e2015-03-23 06:18:07 +0000647 for (auto *E : C->source_exprs()) {
Richard Trieu6a77a1c2016-06-10 04:52:09 +0000648 if (E)
649 Profiler->VisitStmt(E);
Alexey Bataeva63048e2015-03-23 06:18:07 +0000650 }
651 for (auto *E : C->destination_exprs()) {
Richard Trieu6a77a1c2016-06-10 04:52:09 +0000652 if (E)
653 Profiler->VisitStmt(E);
Alexey Bataeva63048e2015-03-23 06:18:07 +0000654 }
655 for (auto *E : C->assignment_ops()) {
Richard Trieu6a77a1c2016-06-10 04:52:09 +0000656 if (E)
657 Profiler->VisitStmt(E);
Alexey Bataeva63048e2015-03-23 06:18:07 +0000658 }
Alexey Bataevbae9a792014-06-27 10:37:06 +0000659}
Alexey Bataev6125da92014-07-21 11:26:11 +0000660void OMPClauseProfiler::VisitOMPFlushClause(const OMPFlushClause *C) {
661 VisitOMPClauseList(C);
662}
Alexey Bataev1c2cfbc2015-06-23 14:25:19 +0000663void OMPClauseProfiler::VisitOMPDependClause(const OMPDependClause *C) {
664 VisitOMPClauseList(C);
665}
Michael Wonge710d542015-08-07 16:16:36 +0000666void OMPClauseProfiler::VisitOMPDeviceClause(const OMPDeviceClause *C) {
Richard Trieu6a77a1c2016-06-10 04:52:09 +0000667 if (C->getDevice())
668 Profiler->VisitStmt(C->getDevice());
Michael Wonge710d542015-08-07 16:16:36 +0000669}
Kelvin Li0bff7af2015-11-23 05:32:03 +0000670void OMPClauseProfiler::VisitOMPMapClause(const OMPMapClause *C) {
671 VisitOMPClauseList(C);
672}
Kelvin Li099bb8c2015-11-24 20:50:12 +0000673void OMPClauseProfiler::VisitOMPNumTeamsClause(const OMPNumTeamsClause *C) {
Arpith Chacko Jacobbc126342017-01-25 11:28:18 +0000674 VistOMPClauseWithPreInit(C);
Richard Trieu6a77a1c2016-06-10 04:52:09 +0000675 if (C->getNumTeams())
676 Profiler->VisitStmt(C->getNumTeams());
Kelvin Li099bb8c2015-11-24 20:50:12 +0000677}
Kelvin Lia15fb1a2015-11-27 18:47:36 +0000678void OMPClauseProfiler::VisitOMPThreadLimitClause(
679 const OMPThreadLimitClause *C) {
Arpith Chacko Jacob7ecc0b72017-01-25 11:44:35 +0000680 VistOMPClauseWithPreInit(C);
Richard Trieu6a77a1c2016-06-10 04:52:09 +0000681 if (C->getThreadLimit())
682 Profiler->VisitStmt(C->getThreadLimit());
Kelvin Lia15fb1a2015-11-27 18:47:36 +0000683}
Alexey Bataeva0569352015-12-01 10:17:31 +0000684void OMPClauseProfiler::VisitOMPPriorityClause(const OMPPriorityClause *C) {
Richard Trieu6a77a1c2016-06-10 04:52:09 +0000685 if (C->getPriority())
686 Profiler->VisitStmt(C->getPriority());
Alexey Bataeva0569352015-12-01 10:17:31 +0000687}
Alexey Bataev1fd4aed2015-12-07 12:52:51 +0000688void OMPClauseProfiler::VisitOMPGrainsizeClause(const OMPGrainsizeClause *C) {
Richard Trieu6a77a1c2016-06-10 04:52:09 +0000689 if (C->getGrainsize())
690 Profiler->VisitStmt(C->getGrainsize());
Alexey Bataev1fd4aed2015-12-07 12:52:51 +0000691}
Alexey Bataev382967a2015-12-08 12:06:20 +0000692void OMPClauseProfiler::VisitOMPNumTasksClause(const OMPNumTasksClause *C) {
Richard Trieu6a77a1c2016-06-10 04:52:09 +0000693 if (C->getNumTasks())
694 Profiler->VisitStmt(C->getNumTasks());
Alexey Bataev382967a2015-12-08 12:06:20 +0000695}
Alexey Bataev28c75412015-12-15 08:19:24 +0000696void OMPClauseProfiler::VisitOMPHintClause(const OMPHintClause *C) {
Richard Trieu6a77a1c2016-06-10 04:52:09 +0000697 if (C->getHint())
698 Profiler->VisitStmt(C->getHint());
Alexey Bataev28c75412015-12-15 08:19:24 +0000699}
Samuel Antao661c0902016-05-26 17:39:58 +0000700void OMPClauseProfiler::VisitOMPToClause(const OMPToClause *C) {
701 VisitOMPClauseList(C);
702}
Samuel Antaoec172c62016-05-26 17:49:04 +0000703void OMPClauseProfiler::VisitOMPFromClause(const OMPFromClause *C) {
704 VisitOMPClauseList(C);
705}
Carlo Bertolli2404b172016-07-13 15:37:16 +0000706void OMPClauseProfiler::VisitOMPUseDevicePtrClause(
707 const OMPUseDevicePtrClause *C) {
708 VisitOMPClauseList(C);
709}
Carlo Bertolli70594e92016-07-13 17:16:49 +0000710void OMPClauseProfiler::VisitOMPIsDevicePtrClause(
711 const OMPIsDevicePtrClause *C) {
712 VisitOMPClauseList(C);
713}
Alexander Kornienkoab9db512015-06-22 23:07:51 +0000714}
Alexey Bataev5ec3eb12013-07-19 03:13:43 +0000715
716void
Alexey Bataev1b59ab52014-02-27 08:29:12 +0000717StmtProfiler::VisitOMPExecutableDirective(const OMPExecutableDirective *S) {
Alexey Bataev5ec3eb12013-07-19 03:13:43 +0000718 VisitStmt(S);
719 OMPClauseProfiler P(this);
720 ArrayRef<OMPClause *> Clauses = S->clauses();
721 for (ArrayRef<OMPClause *>::iterator I = Clauses.begin(), E = Clauses.end();
722 I != E; ++I)
723 if (*I)
724 P.Visit(*I);
725}
726
Alexander Musman3aaab662014-08-19 11:27:13 +0000727void StmtProfiler::VisitOMPLoopDirective(const OMPLoopDirective *S) {
728 VisitOMPExecutableDirective(S);
729}
730
Alexey Bataev1b59ab52014-02-27 08:29:12 +0000731void StmtProfiler::VisitOMPParallelDirective(const OMPParallelDirective *S) {
732 VisitOMPExecutableDirective(S);
733}
734
735void StmtProfiler::VisitOMPSimdDirective(const OMPSimdDirective *S) {
Alexander Musman3aaab662014-08-19 11:27:13 +0000736 VisitOMPLoopDirective(S);
Alexey Bataev1b59ab52014-02-27 08:29:12 +0000737}
738
Alexey Bataevf29276e2014-06-18 04:14:57 +0000739void StmtProfiler::VisitOMPForDirective(const OMPForDirective *S) {
Alexander Musman3aaab662014-08-19 11:27:13 +0000740 VisitOMPLoopDirective(S);
Alexey Bataevf29276e2014-06-18 04:14:57 +0000741}
742
Alexander Musmanf82886e2014-09-18 05:12:34 +0000743void StmtProfiler::VisitOMPForSimdDirective(const OMPForSimdDirective *S) {
744 VisitOMPLoopDirective(S);
745}
746
Alexey Bataevd3f8dd22014-06-25 11:44:49 +0000747void StmtProfiler::VisitOMPSectionsDirective(const OMPSectionsDirective *S) {
748 VisitOMPExecutableDirective(S);
749}
750
Alexey Bataev1e0498a2014-06-26 08:21:58 +0000751void StmtProfiler::VisitOMPSectionDirective(const OMPSectionDirective *S) {
752 VisitOMPExecutableDirective(S);
753}
754
Alexey Bataevd1e40fb2014-06-26 12:05:45 +0000755void StmtProfiler::VisitOMPSingleDirective(const OMPSingleDirective *S) {
756 VisitOMPExecutableDirective(S);
757}
758
Alexander Musman80c22892014-07-17 08:54:58 +0000759void StmtProfiler::VisitOMPMasterDirective(const OMPMasterDirective *S) {
760 VisitOMPExecutableDirective(S);
761}
762
Alexander Musmand9ed09f2014-07-21 09:42:05 +0000763void StmtProfiler::VisitOMPCriticalDirective(const OMPCriticalDirective *S) {
764 VisitOMPExecutableDirective(S);
765 VisitName(S->getDirectiveName().getName());
766}
767
Alexey Bataev4acb8592014-07-07 13:01:15 +0000768void
769StmtProfiler::VisitOMPParallelForDirective(const OMPParallelForDirective *S) {
Alexander Musman3aaab662014-08-19 11:27:13 +0000770 VisitOMPLoopDirective(S);
Alexey Bataev4acb8592014-07-07 13:01:15 +0000771}
772
Alexander Musmane4e893b2014-09-23 09:33:00 +0000773void StmtProfiler::VisitOMPParallelForSimdDirective(
774 const OMPParallelForSimdDirective *S) {
775 VisitOMPLoopDirective(S);
776}
777
Alexey Bataev84d0b3e2014-07-08 08:12:03 +0000778void StmtProfiler::VisitOMPParallelSectionsDirective(
779 const OMPParallelSectionsDirective *S) {
780 VisitOMPExecutableDirective(S);
781}
782
Alexey Bataev9c2e8ee2014-07-11 11:25:16 +0000783void StmtProfiler::VisitOMPTaskDirective(const OMPTaskDirective *S) {
784 VisitOMPExecutableDirective(S);
785}
786
Alexey Bataev68446b72014-07-18 07:47:19 +0000787void StmtProfiler::VisitOMPTaskyieldDirective(const OMPTaskyieldDirective *S) {
788 VisitOMPExecutableDirective(S);
789}
790
Alexey Bataev4d1dfea2014-07-18 09:11:51 +0000791void StmtProfiler::VisitOMPBarrierDirective(const OMPBarrierDirective *S) {
792 VisitOMPExecutableDirective(S);
793}
794
Alexey Bataev2df347a2014-07-18 10:17:07 +0000795void StmtProfiler::VisitOMPTaskwaitDirective(const OMPTaskwaitDirective *S) {
796 VisitOMPExecutableDirective(S);
797}
798
Alexey Bataevc30dd2d2015-06-18 12:14:09 +0000799void StmtProfiler::VisitOMPTaskgroupDirective(const OMPTaskgroupDirective *S) {
800 VisitOMPExecutableDirective(S);
801}
802
Alexey Bataev6125da92014-07-21 11:26:11 +0000803void StmtProfiler::VisitOMPFlushDirective(const OMPFlushDirective *S) {
804 VisitOMPExecutableDirective(S);
805}
806
Alexey Bataev9fb6e642014-07-22 06:45:04 +0000807void StmtProfiler::VisitOMPOrderedDirective(const OMPOrderedDirective *S) {
808 VisitOMPExecutableDirective(S);
809}
810
Alexey Bataev0162e452014-07-22 10:10:35 +0000811void StmtProfiler::VisitOMPAtomicDirective(const OMPAtomicDirective *S) {
812 VisitOMPExecutableDirective(S);
813}
814
Alexey Bataev0bd520b2014-09-19 08:19:49 +0000815void StmtProfiler::VisitOMPTargetDirective(const OMPTargetDirective *S) {
816 VisitOMPExecutableDirective(S);
817}
818
Michael Wong65f367f2015-07-21 13:44:28 +0000819void StmtProfiler::VisitOMPTargetDataDirective(const OMPTargetDataDirective *S) {
820 VisitOMPExecutableDirective(S);
821}
822
Samuel Antaodf67fc42016-01-19 19:15:56 +0000823void StmtProfiler::VisitOMPTargetEnterDataDirective(
824 const OMPTargetEnterDataDirective *S) {
825 VisitOMPExecutableDirective(S);
826}
827
Samuel Antao72590762016-01-19 20:04:50 +0000828void StmtProfiler::VisitOMPTargetExitDataDirective(
829 const OMPTargetExitDataDirective *S) {
830 VisitOMPExecutableDirective(S);
831}
832
Arpith Chacko Jacobe955b3d2016-01-26 18:48:41 +0000833void StmtProfiler::VisitOMPTargetParallelDirective(
834 const OMPTargetParallelDirective *S) {
835 VisitOMPExecutableDirective(S);
836}
837
Arpith Chacko Jacob05bebb52016-02-03 15:46:42 +0000838void StmtProfiler::VisitOMPTargetParallelForDirective(
839 const OMPTargetParallelForDirective *S) {
840 VisitOMPExecutableDirective(S);
841}
842
Alexey Bataev13314bf2014-10-09 04:18:56 +0000843void StmtProfiler::VisitOMPTeamsDirective(const OMPTeamsDirective *S) {
844 VisitOMPExecutableDirective(S);
845}
846
Alexey Bataev6d4ed052015-07-01 06:57:41 +0000847void StmtProfiler::VisitOMPCancellationPointDirective(
848 const OMPCancellationPointDirective *S) {
849 VisitOMPExecutableDirective(S);
850}
851
Alexey Bataev80909872015-07-02 11:25:17 +0000852void StmtProfiler::VisitOMPCancelDirective(const OMPCancelDirective *S) {
853 VisitOMPExecutableDirective(S);
854}
855
Alexey Bataev49f6e782015-12-01 04:18:41 +0000856void StmtProfiler::VisitOMPTaskLoopDirective(const OMPTaskLoopDirective *S) {
857 VisitOMPLoopDirective(S);
858}
859
Alexey Bataev0a6ed842015-12-03 09:40:15 +0000860void StmtProfiler::VisitOMPTaskLoopSimdDirective(
861 const OMPTaskLoopSimdDirective *S) {
862 VisitOMPLoopDirective(S);
863}
864
Carlo Bertolli6200a3d2015-12-14 14:51:25 +0000865void StmtProfiler::VisitOMPDistributeDirective(
866 const OMPDistributeDirective *S) {
867 VisitOMPLoopDirective(S);
868}
869
Carlo Bertollib4adf552016-01-15 18:50:31 +0000870void OMPClauseProfiler::VisitOMPDistScheduleClause(
871 const OMPDistScheduleClause *C) {
Alexey Bataev3392d762016-02-16 11:18:12 +0000872 VistOMPClauseWithPreInit(C);
873 if (auto *S = C->getChunkSize())
874 Profiler->VisitStmt(S);
Carlo Bertollib4adf552016-01-15 18:50:31 +0000875}
876
Arpith Chacko Jacob3cf89042016-01-26 16:37:23 +0000877void OMPClauseProfiler::VisitOMPDefaultmapClause(const OMPDefaultmapClause *) {}
878
Samuel Antao686c70c2016-05-26 17:30:50 +0000879void StmtProfiler::VisitOMPTargetUpdateDirective(
880 const OMPTargetUpdateDirective *S) {
881 VisitOMPExecutableDirective(S);
882}
883
Carlo Bertolli9925f152016-06-27 14:55:37 +0000884void StmtProfiler::VisitOMPDistributeParallelForDirective(
885 const OMPDistributeParallelForDirective *S) {
886 VisitOMPLoopDirective(S);
887}
888
Kelvin Li4a39add2016-07-05 05:00:15 +0000889void StmtProfiler::VisitOMPDistributeParallelForSimdDirective(
890 const OMPDistributeParallelForSimdDirective *S) {
891 VisitOMPLoopDirective(S);
892}
893
Kelvin Li787f3fc2016-07-06 04:45:38 +0000894void StmtProfiler::VisitOMPDistributeSimdDirective(
895 const OMPDistributeSimdDirective *S) {
896 VisitOMPLoopDirective(S);
897}
898
Kelvin Lia579b912016-07-14 02:54:56 +0000899void StmtProfiler::VisitOMPTargetParallelForSimdDirective(
900 const OMPTargetParallelForSimdDirective *S) {
901 VisitOMPLoopDirective(S);
902}
903
Kelvin Li986330c2016-07-20 22:57:10 +0000904void StmtProfiler::VisitOMPTargetSimdDirective(
905 const OMPTargetSimdDirective *S) {
906 VisitOMPLoopDirective(S);
907}
908
Kelvin Li02532872016-08-05 14:37:37 +0000909void StmtProfiler::VisitOMPTeamsDistributeDirective(
910 const OMPTeamsDistributeDirective *S) {
911 VisitOMPLoopDirective(S);
912}
913
Kelvin Li4e325f72016-10-25 12:50:55 +0000914void StmtProfiler::VisitOMPTeamsDistributeSimdDirective(
915 const OMPTeamsDistributeSimdDirective *S) {
916 VisitOMPLoopDirective(S);
917}
918
Kelvin Li579e41c2016-11-30 23:51:03 +0000919void StmtProfiler::VisitOMPTeamsDistributeParallelForSimdDirective(
920 const OMPTeamsDistributeParallelForSimdDirective *S) {
921 VisitOMPLoopDirective(S);
922}
923
Kelvin Li7ade93f2016-12-09 03:24:30 +0000924void StmtProfiler::VisitOMPTeamsDistributeParallelForDirective(
925 const OMPTeamsDistributeParallelForDirective *S) {
926 VisitOMPLoopDirective(S);
927}
928
Kelvin Libf594a52016-12-17 05:48:59 +0000929void StmtProfiler::VisitOMPTargetTeamsDirective(
930 const OMPTargetTeamsDirective *S) {
931 VisitOMPExecutableDirective(S);
932}
933
Kelvin Li83c451e2016-12-25 04:52:54 +0000934void StmtProfiler::VisitOMPTargetTeamsDistributeDirective(
935 const OMPTargetTeamsDistributeDirective *S) {
936 VisitOMPLoopDirective(S);
937}
938
Kelvin Li80e8f562016-12-29 22:16:30 +0000939void StmtProfiler::VisitOMPTargetTeamsDistributeParallelForDirective(
940 const OMPTargetTeamsDistributeParallelForDirective *S) {
941 VisitOMPLoopDirective(S);
942}
943
Kelvin Li1851df52017-01-03 05:23:48 +0000944void StmtProfiler::VisitOMPTargetTeamsDistributeParallelForSimdDirective(
945 const OMPTargetTeamsDistributeParallelForSimdDirective *S) {
946 VisitOMPLoopDirective(S);
947}
948
Kelvin Lida681182017-01-10 18:08:18 +0000949void StmtProfiler::VisitOMPTargetTeamsDistributeSimdDirective(
950 const OMPTargetTeamsDistributeSimdDirective *S) {
951 VisitOMPLoopDirective(S);
952}
953
Chandler Carruth631abd92011-06-16 06:47:06 +0000954void StmtProfiler::VisitExpr(const Expr *S) {
Douglas Gregor5c193b92009-07-28 00:33:38 +0000955 VisitStmt(S);
956}
957
Chandler Carruth631abd92011-06-16 06:47:06 +0000958void StmtProfiler::VisitDeclRefExpr(const DeclRefExpr *S) {
Douglas Gregor5c193b92009-07-28 00:33:38 +0000959 VisitExpr(S);
Douglas Gregorf5b160f2010-07-13 08:37:11 +0000960 if (!Canonical)
961 VisitNestedNameSpecifier(S->getQualifier());
Douglas Gregor5c193b92009-07-28 00:33:38 +0000962 VisitDecl(S->getDecl());
Douglas Gregorf5b160f2010-07-13 08:37:11 +0000963 if (!Canonical)
964 VisitTemplateArguments(S->getTemplateArgs(), S->getNumTemplateArgs());
Douglas Gregor5c193b92009-07-28 00:33:38 +0000965}
966
Chandler Carruth631abd92011-06-16 06:47:06 +0000967void StmtProfiler::VisitPredefinedExpr(const PredefinedExpr *S) {
Douglas Gregor5c193b92009-07-28 00:33:38 +0000968 VisitExpr(S);
969 ID.AddInteger(S->getIdentType());
970}
971
Chandler Carruth631abd92011-06-16 06:47:06 +0000972void StmtProfiler::VisitIntegerLiteral(const IntegerLiteral *S) {
Douglas Gregor5c193b92009-07-28 00:33:38 +0000973 VisitExpr(S);
974 S->getValue().Profile(ID);
Richard Smithe9f130c2014-11-20 03:37:32 +0000975 ID.AddInteger(S->getType()->castAs<BuiltinType>()->getKind());
Douglas Gregor5c193b92009-07-28 00:33:38 +0000976}
977
Chandler Carruth631abd92011-06-16 06:47:06 +0000978void StmtProfiler::VisitCharacterLiteral(const CharacterLiteral *S) {
Douglas Gregor5c193b92009-07-28 00:33:38 +0000979 VisitExpr(S);
Douglas Gregorfb65e592011-07-27 05:40:30 +0000980 ID.AddInteger(S->getKind());
Douglas Gregor5c193b92009-07-28 00:33:38 +0000981 ID.AddInteger(S->getValue());
982}
983
Chandler Carruth631abd92011-06-16 06:47:06 +0000984void StmtProfiler::VisitFloatingLiteral(const FloatingLiteral *S) {
Douglas Gregor5c193b92009-07-28 00:33:38 +0000985 VisitExpr(S);
986 S->getValue().Profile(ID);
987 ID.AddBoolean(S->isExact());
Richard Smithe9f130c2014-11-20 03:37:32 +0000988 ID.AddInteger(S->getType()->castAs<BuiltinType>()->getKind());
Douglas Gregor5c193b92009-07-28 00:33:38 +0000989}
990
Chandler Carruth631abd92011-06-16 06:47:06 +0000991void StmtProfiler::VisitImaginaryLiteral(const ImaginaryLiteral *S) {
Douglas Gregor5c193b92009-07-28 00:33:38 +0000992 VisitExpr(S);
993}
994
Chandler Carruth631abd92011-06-16 06:47:06 +0000995void StmtProfiler::VisitStringLiteral(const StringLiteral *S) {
Douglas Gregor5c193b92009-07-28 00:33:38 +0000996 VisitExpr(S);
Douglas Gregor9d0eb8f2011-11-02 17:26:05 +0000997 ID.AddString(S->getBytes());
Douglas Gregorfb65e592011-07-27 05:40:30 +0000998 ID.AddInteger(S->getKind());
Douglas Gregor5c193b92009-07-28 00:33:38 +0000999}
1000
Chandler Carruth631abd92011-06-16 06:47:06 +00001001void StmtProfiler::VisitParenExpr(const ParenExpr *S) {
Douglas Gregor5c193b92009-07-28 00:33:38 +00001002 VisitExpr(S);
1003}
1004
Chandler Carruth631abd92011-06-16 06:47:06 +00001005void StmtProfiler::VisitParenListExpr(const ParenListExpr *S) {
Nate Begeman5ec4b312009-08-10 23:49:36 +00001006 VisitExpr(S);
1007}
1008
Chandler Carruth631abd92011-06-16 06:47:06 +00001009void StmtProfiler::VisitUnaryOperator(const UnaryOperator *S) {
Douglas Gregor5c193b92009-07-28 00:33:38 +00001010 VisitExpr(S);
1011 ID.AddInteger(S->getOpcode());
1012}
1013
Chandler Carruth631abd92011-06-16 06:47:06 +00001014void StmtProfiler::VisitOffsetOfExpr(const OffsetOfExpr *S) {
Douglas Gregor882211c2010-04-28 22:16:22 +00001015 VisitType(S->getTypeSourceInfo()->getType());
1016 unsigned n = S->getNumComponents();
1017 for (unsigned i = 0; i < n; ++i) {
James Y Knight7281c352015-12-29 22:31:18 +00001018 const OffsetOfNode &ON = S->getComponent(i);
Douglas Gregor882211c2010-04-28 22:16:22 +00001019 ID.AddInteger(ON.getKind());
1020 switch (ON.getKind()) {
James Y Knight7281c352015-12-29 22:31:18 +00001021 case OffsetOfNode::Array:
Douglas Gregor882211c2010-04-28 22:16:22 +00001022 // Expressions handled below.
1023 break;
1024
James Y Knight7281c352015-12-29 22:31:18 +00001025 case OffsetOfNode::Field:
Douglas Gregor882211c2010-04-28 22:16:22 +00001026 VisitDecl(ON.getField());
1027 break;
1028
James Y Knight7281c352015-12-29 22:31:18 +00001029 case OffsetOfNode::Identifier:
Richard Trieu639d7b62017-02-22 22:22:42 +00001030 VisitIdentifierInfo(ON.getFieldName());
Douglas Gregor882211c2010-04-28 22:16:22 +00001031 break;
James Y Knight7281c352015-12-29 22:31:18 +00001032
1033 case OffsetOfNode::Base:
Douglas Gregord1702062010-04-29 00:18:15 +00001034 // These nodes are implicit, and therefore don't need profiling.
1035 break;
Douglas Gregor882211c2010-04-28 22:16:22 +00001036 }
1037 }
Richard Trieu639d7b62017-02-22 22:22:42 +00001038
Douglas Gregor882211c2010-04-28 22:16:22 +00001039 VisitExpr(S);
1040}
1041
Chandler Carruth631abd92011-06-16 06:47:06 +00001042void
1043StmtProfiler::VisitUnaryExprOrTypeTraitExpr(const UnaryExprOrTypeTraitExpr *S) {
Douglas Gregor5c193b92009-07-28 00:33:38 +00001044 VisitExpr(S);
Peter Collingbournee190dee2011-03-11 19:24:49 +00001045 ID.AddInteger(S->getKind());
Douglas Gregor5c193b92009-07-28 00:33:38 +00001046 if (S->isArgumentType())
1047 VisitType(S->getArgumentType());
1048}
1049
Chandler Carruth631abd92011-06-16 06:47:06 +00001050void StmtProfiler::VisitArraySubscriptExpr(const ArraySubscriptExpr *S) {
Douglas Gregor5c193b92009-07-28 00:33:38 +00001051 VisitExpr(S);
1052}
1053
Alexey Bataev1a3320e2015-08-25 14:24:04 +00001054void StmtProfiler::VisitOMPArraySectionExpr(const OMPArraySectionExpr *S) {
1055 VisitExpr(S);
1056}
1057
Chandler Carruth631abd92011-06-16 06:47:06 +00001058void StmtProfiler::VisitCallExpr(const CallExpr *S) {
Douglas Gregor5c193b92009-07-28 00:33:38 +00001059 VisitExpr(S);
1060}
1061
Chandler Carruth631abd92011-06-16 06:47:06 +00001062void StmtProfiler::VisitMemberExpr(const MemberExpr *S) {
Douglas Gregor5c193b92009-07-28 00:33:38 +00001063 VisitExpr(S);
1064 VisitDecl(S->getMemberDecl());
Douglas Gregorf5b160f2010-07-13 08:37:11 +00001065 if (!Canonical)
1066 VisitNestedNameSpecifier(S->getQualifier());
Douglas Gregor5c193b92009-07-28 00:33:38 +00001067 ID.AddBoolean(S->isArrow());
1068}
1069
Chandler Carruth631abd92011-06-16 06:47:06 +00001070void StmtProfiler::VisitCompoundLiteralExpr(const CompoundLiteralExpr *S) {
Douglas Gregor5c193b92009-07-28 00:33:38 +00001071 VisitExpr(S);
1072 ID.AddBoolean(S->isFileScope());
1073}
1074
Chandler Carruth631abd92011-06-16 06:47:06 +00001075void StmtProfiler::VisitCastExpr(const CastExpr *S) {
Douglas Gregor5c193b92009-07-28 00:33:38 +00001076 VisitExpr(S);
1077}
1078
Chandler Carruth631abd92011-06-16 06:47:06 +00001079void StmtProfiler::VisitImplicitCastExpr(const ImplicitCastExpr *S) {
Douglas Gregor5c193b92009-07-28 00:33:38 +00001080 VisitCastExpr(S);
John McCall2536c6d2010-08-25 10:28:54 +00001081 ID.AddInteger(S->getValueKind());
Douglas Gregor5c193b92009-07-28 00:33:38 +00001082}
1083
Chandler Carruth631abd92011-06-16 06:47:06 +00001084void StmtProfiler::VisitExplicitCastExpr(const ExplicitCastExpr *S) {
Douglas Gregor5c193b92009-07-28 00:33:38 +00001085 VisitCastExpr(S);
1086 VisitType(S->getTypeAsWritten());
1087}
1088
Chandler Carruth631abd92011-06-16 06:47:06 +00001089void StmtProfiler::VisitCStyleCastExpr(const CStyleCastExpr *S) {
Douglas Gregor5c193b92009-07-28 00:33:38 +00001090 VisitExplicitCastExpr(S);
1091}
1092
Chandler Carruth631abd92011-06-16 06:47:06 +00001093void StmtProfiler::VisitBinaryOperator(const BinaryOperator *S) {
Douglas Gregor5c193b92009-07-28 00:33:38 +00001094 VisitExpr(S);
1095 ID.AddInteger(S->getOpcode());
1096}
1097
Chandler Carruth631abd92011-06-16 06:47:06 +00001098void
1099StmtProfiler::VisitCompoundAssignOperator(const CompoundAssignOperator *S) {
Douglas Gregor5c193b92009-07-28 00:33:38 +00001100 VisitBinaryOperator(S);
1101}
1102
Chandler Carruth631abd92011-06-16 06:47:06 +00001103void StmtProfiler::VisitConditionalOperator(const ConditionalOperator *S) {
Douglas Gregor5c193b92009-07-28 00:33:38 +00001104 VisitExpr(S);
1105}
1106
Chandler Carruth631abd92011-06-16 06:47:06 +00001107void StmtProfiler::VisitBinaryConditionalOperator(
Chandler Carruthcf5f43c2011-06-21 23:26:32 +00001108 const BinaryConditionalOperator *S) {
John McCallc07a0c72011-02-17 10:25:35 +00001109 VisitExpr(S);
1110}
1111
Chandler Carruth631abd92011-06-16 06:47:06 +00001112void StmtProfiler::VisitAddrLabelExpr(const AddrLabelExpr *S) {
Douglas Gregor5c193b92009-07-28 00:33:38 +00001113 VisitExpr(S);
Chris Lattnerc8e630e2011-02-17 07:39:24 +00001114 VisitDecl(S->getLabel());
Douglas Gregor5c193b92009-07-28 00:33:38 +00001115}
1116
Chandler Carruth631abd92011-06-16 06:47:06 +00001117void StmtProfiler::VisitStmtExpr(const StmtExpr *S) {
Douglas Gregor5c193b92009-07-28 00:33:38 +00001118 VisitExpr(S);
1119}
1120
Chandler Carruth631abd92011-06-16 06:47:06 +00001121void StmtProfiler::VisitShuffleVectorExpr(const ShuffleVectorExpr *S) {
Douglas Gregor5c193b92009-07-28 00:33:38 +00001122 VisitExpr(S);
1123}
1124
Hal Finkelc4d7c822013-09-18 03:29:45 +00001125void StmtProfiler::VisitConvertVectorExpr(const ConvertVectorExpr *S) {
1126 VisitExpr(S);
1127}
1128
Chandler Carruth631abd92011-06-16 06:47:06 +00001129void StmtProfiler::VisitChooseExpr(const ChooseExpr *S) {
Douglas Gregor5c193b92009-07-28 00:33:38 +00001130 VisitExpr(S);
1131}
1132
Chandler Carruth631abd92011-06-16 06:47:06 +00001133void StmtProfiler::VisitGNUNullExpr(const GNUNullExpr *S) {
Douglas Gregor5c193b92009-07-28 00:33:38 +00001134 VisitExpr(S);
1135}
1136
Chandler Carruth631abd92011-06-16 06:47:06 +00001137void StmtProfiler::VisitVAArgExpr(const VAArgExpr *S) {
Douglas Gregor00044172009-07-29 16:09:57 +00001138 VisitExpr(S);
1139}
1140
Chandler Carruth631abd92011-06-16 06:47:06 +00001141void StmtProfiler::VisitInitListExpr(const InitListExpr *S) {
Douglas Gregor5c193b92009-07-28 00:33:38 +00001142 if (S->getSyntacticForm()) {
1143 VisitInitListExpr(S->getSyntacticForm());
1144 return;
1145 }
Mike Stump11289f42009-09-09 15:08:12 +00001146
Douglas Gregor5c193b92009-07-28 00:33:38 +00001147 VisitExpr(S);
1148}
1149
Chandler Carruth631abd92011-06-16 06:47:06 +00001150void StmtProfiler::VisitDesignatedInitExpr(const DesignatedInitExpr *S) {
Douglas Gregor5c193b92009-07-28 00:33:38 +00001151 VisitExpr(S);
1152 ID.AddBoolean(S->usesGNUSyntax());
David Majnemerf7e36092016-06-23 00:15:04 +00001153 for (const DesignatedInitExpr::Designator &D : S->designators()) {
1154 if (D.isFieldDesignator()) {
Douglas Gregor5c193b92009-07-28 00:33:38 +00001155 ID.AddInteger(0);
David Majnemerf7e36092016-06-23 00:15:04 +00001156 VisitName(D.getFieldName());
Douglas Gregor5c193b92009-07-28 00:33:38 +00001157 continue;
1158 }
Mike Stump11289f42009-09-09 15:08:12 +00001159
David Majnemerf7e36092016-06-23 00:15:04 +00001160 if (D.isArrayDesignator()) {
Douglas Gregor5c193b92009-07-28 00:33:38 +00001161 ID.AddInteger(1);
1162 } else {
David Majnemerf7e36092016-06-23 00:15:04 +00001163 assert(D.isArrayRangeDesignator());
Douglas Gregor5c193b92009-07-28 00:33:38 +00001164 ID.AddInteger(2);
1165 }
David Majnemerf7e36092016-06-23 00:15:04 +00001166 ID.AddInteger(D.getFirstExprIndex());
Douglas Gregor5c193b92009-07-28 00:33:38 +00001167 }
1168}
1169
Yunzhong Gaocb779302015-06-10 00:27:52 +00001170// Seems that if VisitInitListExpr() only works on the syntactic form of an
1171// InitListExpr, then a DesignatedInitUpdateExpr is not encountered.
1172void StmtProfiler::VisitDesignatedInitUpdateExpr(
1173 const DesignatedInitUpdateExpr *S) {
1174 llvm_unreachable("Unexpected DesignatedInitUpdateExpr in syntactic form of "
1175 "initializer");
1176}
1177
Richard Smith410306b2016-12-12 02:53:20 +00001178void StmtProfiler::VisitArrayInitLoopExpr(const ArrayInitLoopExpr *S) {
1179 VisitExpr(S);
1180}
1181
1182void StmtProfiler::VisitArrayInitIndexExpr(const ArrayInitIndexExpr *S) {
1183 VisitExpr(S);
1184}
1185
Yunzhong Gaocb779302015-06-10 00:27:52 +00001186void StmtProfiler::VisitNoInitExpr(const NoInitExpr *S) {
1187 llvm_unreachable("Unexpected NoInitExpr in syntactic form of initializer");
1188}
1189
Chandler Carruth631abd92011-06-16 06:47:06 +00001190void StmtProfiler::VisitImplicitValueInitExpr(const ImplicitValueInitExpr *S) {
Douglas Gregor5c193b92009-07-28 00:33:38 +00001191 VisitExpr(S);
1192}
1193
Chandler Carruth631abd92011-06-16 06:47:06 +00001194void StmtProfiler::VisitExtVectorElementExpr(const ExtVectorElementExpr *S) {
Douglas Gregor5c193b92009-07-28 00:33:38 +00001195 VisitExpr(S);
1196 VisitName(&S->getAccessor());
1197}
1198
Chandler Carruth631abd92011-06-16 06:47:06 +00001199void StmtProfiler::VisitBlockExpr(const BlockExpr *S) {
Douglas Gregor5c193b92009-07-28 00:33:38 +00001200 VisitExpr(S);
1201 VisitDecl(S->getBlockDecl());
1202}
1203
Chandler Carruth631abd92011-06-16 06:47:06 +00001204void StmtProfiler::VisitGenericSelectionExpr(const GenericSelectionExpr *S) {
Peter Collingbourne91147592011-04-15 00:35:48 +00001205 VisitExpr(S);
1206 for (unsigned i = 0; i != S->getNumAssocs(); ++i) {
1207 QualType T = S->getAssocType(i);
1208 if (T.isNull())
Craig Topper36250ad2014-05-12 05:36:57 +00001209 ID.AddPointer(nullptr);
Peter Collingbourne91147592011-04-15 00:35:48 +00001210 else
1211 VisitType(T);
1212 VisitExpr(S->getAssocExpr(i));
1213 }
1214}
1215
John McCallfe96e0b2011-11-06 09:01:30 +00001216void StmtProfiler::VisitPseudoObjectExpr(const PseudoObjectExpr *S) {
1217 VisitExpr(S);
1218 for (PseudoObjectExpr::const_semantics_iterator
1219 i = S->semantics_begin(), e = S->semantics_end(); i != e; ++i)
1220 // Normally, we would not profile the source expressions of OVEs.
1221 if (const OpaqueValueExpr *OVE = dyn_cast<OpaqueValueExpr>(*i))
1222 Visit(OVE->getSourceExpr());
1223}
1224
Eli Friedmandf14b3a2011-10-11 02:20:01 +00001225void StmtProfiler::VisitAtomicExpr(const AtomicExpr *S) {
1226 VisitExpr(S);
Eli Friedman4b72fdd2011-10-14 20:59:01 +00001227 ID.AddInteger(S->getOp());
Eli Friedmandf14b3a2011-10-11 02:20:01 +00001228}
1229
Chandler Carruth631abd92011-06-16 06:47:06 +00001230static Stmt::StmtClass DecodeOperatorCall(const CXXOperatorCallExpr *S,
John McCalle3027922010-08-25 11:45:40 +00001231 UnaryOperatorKind &UnaryOp,
1232 BinaryOperatorKind &BinaryOp) {
Douglas Gregore9ceb312010-05-19 04:13:23 +00001233 switch (S->getOperator()) {
1234 case OO_None:
1235 case OO_New:
1236 case OO_Delete:
1237 case OO_Array_New:
1238 case OO_Array_Delete:
1239 case OO_Arrow:
1240 case OO_Call:
1241 case OO_Conditional:
Richard Smith9be594e2015-10-22 05:12:22 +00001242 case OO_Coawait:
Douglas Gregore9ceb312010-05-19 04:13:23 +00001243 case NUM_OVERLOADED_OPERATORS:
1244 llvm_unreachable("Invalid operator call kind");
Douglas Gregore9ceb312010-05-19 04:13:23 +00001245
1246 case OO_Plus:
1247 if (S->getNumArgs() == 1) {
John McCalle3027922010-08-25 11:45:40 +00001248 UnaryOp = UO_Plus;
Douglas Gregore9ceb312010-05-19 04:13:23 +00001249 return Stmt::UnaryOperatorClass;
1250 }
1251
John McCalle3027922010-08-25 11:45:40 +00001252 BinaryOp = BO_Add;
Douglas Gregore9ceb312010-05-19 04:13:23 +00001253 return Stmt::BinaryOperatorClass;
1254
1255 case OO_Minus:
1256 if (S->getNumArgs() == 1) {
John McCalle3027922010-08-25 11:45:40 +00001257 UnaryOp = UO_Minus;
Douglas Gregore9ceb312010-05-19 04:13:23 +00001258 return Stmt::UnaryOperatorClass;
1259 }
1260
John McCalle3027922010-08-25 11:45:40 +00001261 BinaryOp = BO_Sub;
Douglas Gregore9ceb312010-05-19 04:13:23 +00001262 return Stmt::BinaryOperatorClass;
1263
1264 case OO_Star:
1265 if (S->getNumArgs() == 1) {
Richard Smithf15acc52014-06-05 22:43:40 +00001266 UnaryOp = UO_Deref;
Douglas Gregore9ceb312010-05-19 04:13:23 +00001267 return Stmt::UnaryOperatorClass;
1268 }
1269
Richard Smithf15acc52014-06-05 22:43:40 +00001270 BinaryOp = BO_Mul;
Douglas Gregore9ceb312010-05-19 04:13:23 +00001271 return Stmt::BinaryOperatorClass;
1272
1273 case OO_Slash:
John McCalle3027922010-08-25 11:45:40 +00001274 BinaryOp = BO_Div;
Douglas Gregore9ceb312010-05-19 04:13:23 +00001275 return Stmt::BinaryOperatorClass;
1276
1277 case OO_Percent:
John McCalle3027922010-08-25 11:45:40 +00001278 BinaryOp = BO_Rem;
Douglas Gregore9ceb312010-05-19 04:13:23 +00001279 return Stmt::BinaryOperatorClass;
1280
1281 case OO_Caret:
John McCalle3027922010-08-25 11:45:40 +00001282 BinaryOp = BO_Xor;
Douglas Gregore9ceb312010-05-19 04:13:23 +00001283 return Stmt::BinaryOperatorClass;
1284
1285 case OO_Amp:
1286 if (S->getNumArgs() == 1) {
John McCalle3027922010-08-25 11:45:40 +00001287 UnaryOp = UO_AddrOf;
Douglas Gregore9ceb312010-05-19 04:13:23 +00001288 return Stmt::UnaryOperatorClass;
1289 }
1290
John McCalle3027922010-08-25 11:45:40 +00001291 BinaryOp = BO_And;
Douglas Gregore9ceb312010-05-19 04:13:23 +00001292 return Stmt::BinaryOperatorClass;
1293
1294 case OO_Pipe:
John McCalle3027922010-08-25 11:45:40 +00001295 BinaryOp = BO_Or;
Douglas Gregore9ceb312010-05-19 04:13:23 +00001296 return Stmt::BinaryOperatorClass;
1297
1298 case OO_Tilde:
John McCalle3027922010-08-25 11:45:40 +00001299 UnaryOp = UO_Not;
Douglas Gregore9ceb312010-05-19 04:13:23 +00001300 return Stmt::UnaryOperatorClass;
1301
1302 case OO_Exclaim:
John McCalle3027922010-08-25 11:45:40 +00001303 UnaryOp = UO_LNot;
Douglas Gregore9ceb312010-05-19 04:13:23 +00001304 return Stmt::UnaryOperatorClass;
1305
1306 case OO_Equal:
John McCalle3027922010-08-25 11:45:40 +00001307 BinaryOp = BO_Assign;
Douglas Gregore9ceb312010-05-19 04:13:23 +00001308 return Stmt::BinaryOperatorClass;
1309
1310 case OO_Less:
John McCalle3027922010-08-25 11:45:40 +00001311 BinaryOp = BO_LT;
Douglas Gregore9ceb312010-05-19 04:13:23 +00001312 return Stmt::BinaryOperatorClass;
1313
1314 case OO_Greater:
John McCalle3027922010-08-25 11:45:40 +00001315 BinaryOp = BO_GT;
Douglas Gregore9ceb312010-05-19 04:13:23 +00001316 return Stmt::BinaryOperatorClass;
1317
1318 case OO_PlusEqual:
John McCalle3027922010-08-25 11:45:40 +00001319 BinaryOp = BO_AddAssign;
Douglas Gregore9ceb312010-05-19 04:13:23 +00001320 return Stmt::CompoundAssignOperatorClass;
1321
1322 case OO_MinusEqual:
John McCalle3027922010-08-25 11:45:40 +00001323 BinaryOp = BO_SubAssign;
Douglas Gregore9ceb312010-05-19 04:13:23 +00001324 return Stmt::CompoundAssignOperatorClass;
1325
1326 case OO_StarEqual:
John McCalle3027922010-08-25 11:45:40 +00001327 BinaryOp = BO_MulAssign;
Douglas Gregore9ceb312010-05-19 04:13:23 +00001328 return Stmt::CompoundAssignOperatorClass;
1329
1330 case OO_SlashEqual:
John McCalle3027922010-08-25 11:45:40 +00001331 BinaryOp = BO_DivAssign;
Douglas Gregore9ceb312010-05-19 04:13:23 +00001332 return Stmt::CompoundAssignOperatorClass;
1333
1334 case OO_PercentEqual:
John McCalle3027922010-08-25 11:45:40 +00001335 BinaryOp = BO_RemAssign;
Douglas Gregore9ceb312010-05-19 04:13:23 +00001336 return Stmt::CompoundAssignOperatorClass;
1337
1338 case OO_CaretEqual:
John McCalle3027922010-08-25 11:45:40 +00001339 BinaryOp = BO_XorAssign;
Douglas Gregore9ceb312010-05-19 04:13:23 +00001340 return Stmt::CompoundAssignOperatorClass;
1341
1342 case OO_AmpEqual:
John McCalle3027922010-08-25 11:45:40 +00001343 BinaryOp = BO_AndAssign;
Douglas Gregore9ceb312010-05-19 04:13:23 +00001344 return Stmt::CompoundAssignOperatorClass;
1345
1346 case OO_PipeEqual:
John McCalle3027922010-08-25 11:45:40 +00001347 BinaryOp = BO_OrAssign;
Douglas Gregore9ceb312010-05-19 04:13:23 +00001348 return Stmt::CompoundAssignOperatorClass;
1349
1350 case OO_LessLess:
John McCalle3027922010-08-25 11:45:40 +00001351 BinaryOp = BO_Shl;
Douglas Gregore9ceb312010-05-19 04:13:23 +00001352 return Stmt::BinaryOperatorClass;
1353
1354 case OO_GreaterGreater:
John McCalle3027922010-08-25 11:45:40 +00001355 BinaryOp = BO_Shr;
Douglas Gregore9ceb312010-05-19 04:13:23 +00001356 return Stmt::BinaryOperatorClass;
1357
1358 case OO_LessLessEqual:
John McCalle3027922010-08-25 11:45:40 +00001359 BinaryOp = BO_ShlAssign;
Douglas Gregore9ceb312010-05-19 04:13:23 +00001360 return Stmt::CompoundAssignOperatorClass;
1361
1362 case OO_GreaterGreaterEqual:
John McCalle3027922010-08-25 11:45:40 +00001363 BinaryOp = BO_ShrAssign;
Douglas Gregore9ceb312010-05-19 04:13:23 +00001364 return Stmt::CompoundAssignOperatorClass;
1365
1366 case OO_EqualEqual:
John McCalle3027922010-08-25 11:45:40 +00001367 BinaryOp = BO_EQ;
Douglas Gregore9ceb312010-05-19 04:13:23 +00001368 return Stmt::BinaryOperatorClass;
1369
1370 case OO_ExclaimEqual:
John McCalle3027922010-08-25 11:45:40 +00001371 BinaryOp = BO_NE;
Douglas Gregore9ceb312010-05-19 04:13:23 +00001372 return Stmt::BinaryOperatorClass;
1373
1374 case OO_LessEqual:
John McCalle3027922010-08-25 11:45:40 +00001375 BinaryOp = BO_LE;
Douglas Gregore9ceb312010-05-19 04:13:23 +00001376 return Stmt::BinaryOperatorClass;
1377
1378 case OO_GreaterEqual:
John McCalle3027922010-08-25 11:45:40 +00001379 BinaryOp = BO_GE;
Douglas Gregore9ceb312010-05-19 04:13:23 +00001380 return Stmt::BinaryOperatorClass;
1381
1382 case OO_AmpAmp:
John McCalle3027922010-08-25 11:45:40 +00001383 BinaryOp = BO_LAnd;
Douglas Gregore9ceb312010-05-19 04:13:23 +00001384 return Stmt::BinaryOperatorClass;
1385
1386 case OO_PipePipe:
John McCalle3027922010-08-25 11:45:40 +00001387 BinaryOp = BO_LOr;
Douglas Gregore9ceb312010-05-19 04:13:23 +00001388 return Stmt::BinaryOperatorClass;
1389
1390 case OO_PlusPlus:
John McCalle3027922010-08-25 11:45:40 +00001391 UnaryOp = S->getNumArgs() == 1? UO_PreInc
1392 : UO_PostInc;
Douglas Gregore9ceb312010-05-19 04:13:23 +00001393 return Stmt::UnaryOperatorClass;
1394
1395 case OO_MinusMinus:
John McCalle3027922010-08-25 11:45:40 +00001396 UnaryOp = S->getNumArgs() == 1? UO_PreDec
1397 : UO_PostDec;
Douglas Gregore9ceb312010-05-19 04:13:23 +00001398 return Stmt::UnaryOperatorClass;
1399
1400 case OO_Comma:
John McCalle3027922010-08-25 11:45:40 +00001401 BinaryOp = BO_Comma;
Douglas Gregore9ceb312010-05-19 04:13:23 +00001402 return Stmt::BinaryOperatorClass;
1403
Douglas Gregore9ceb312010-05-19 04:13:23 +00001404 case OO_ArrowStar:
John McCalle3027922010-08-25 11:45:40 +00001405 BinaryOp = BO_PtrMemI;
Douglas Gregore9ceb312010-05-19 04:13:23 +00001406 return Stmt::BinaryOperatorClass;
1407
1408 case OO_Subscript:
1409 return Stmt::ArraySubscriptExprClass;
1410 }
1411
1412 llvm_unreachable("Invalid overloaded operator expression");
1413}
Richard Smithf15acc52014-06-05 22:43:40 +00001414
Chandler Carruth631abd92011-06-16 06:47:06 +00001415void StmtProfiler::VisitCXXOperatorCallExpr(const CXXOperatorCallExpr *S) {
Douglas Gregore9ceb312010-05-19 04:13:23 +00001416 if (S->isTypeDependent()) {
1417 // Type-dependent operator calls are profiled like their underlying
1418 // syntactic operator.
Richard Smithbac0a0d2016-10-24 18:47:04 +00001419 //
1420 // An operator call to operator-> is always implicit, so just skip it. The
1421 // enclosing MemberExpr will profile the actual member access.
1422 if (S->getOperator() == OO_Arrow)
1423 return Visit(S->getArg(0));
1424
John McCalle3027922010-08-25 11:45:40 +00001425 UnaryOperatorKind UnaryOp = UO_Extension;
1426 BinaryOperatorKind BinaryOp = BO_Comma;
Douglas Gregore9ceb312010-05-19 04:13:23 +00001427 Stmt::StmtClass SC = DecodeOperatorCall(S, UnaryOp, BinaryOp);
Richard Smithf15acc52014-06-05 22:43:40 +00001428
Douglas Gregore9ceb312010-05-19 04:13:23 +00001429 ID.AddInteger(SC);
1430 for (unsigned I = 0, N = S->getNumArgs(); I != N; ++I)
1431 Visit(S->getArg(I));
1432 if (SC == Stmt::UnaryOperatorClass)
1433 ID.AddInteger(UnaryOp);
1434 else if (SC == Stmt::BinaryOperatorClass ||
1435 SC == Stmt::CompoundAssignOperatorClass)
1436 ID.AddInteger(BinaryOp);
1437 else
1438 assert(SC == Stmt::ArraySubscriptExprClass);
Richard Smithf15acc52014-06-05 22:43:40 +00001439
Douglas Gregore9ceb312010-05-19 04:13:23 +00001440 return;
1441 }
Richard Smithf15acc52014-06-05 22:43:40 +00001442
Douglas Gregor5c193b92009-07-28 00:33:38 +00001443 VisitCallExpr(S);
1444 ID.AddInteger(S->getOperator());
1445}
1446
Chandler Carruth631abd92011-06-16 06:47:06 +00001447void StmtProfiler::VisitCXXMemberCallExpr(const CXXMemberCallExpr *S) {
Douglas Gregor5c193b92009-07-28 00:33:38 +00001448 VisitCallExpr(S);
1449}
1450
Chandler Carruth631abd92011-06-16 06:47:06 +00001451void StmtProfiler::VisitCUDAKernelCallExpr(const CUDAKernelCallExpr *S) {
Peter Collingbourne41f85462011-02-09 21:07:24 +00001452 VisitCallExpr(S);
1453}
1454
Chandler Carruth631abd92011-06-16 06:47:06 +00001455void StmtProfiler::VisitAsTypeExpr(const AsTypeExpr *S) {
Tanya Lattner55808c12011-06-04 00:47:47 +00001456 VisitExpr(S);
1457}
1458
Chandler Carruth631abd92011-06-16 06:47:06 +00001459void StmtProfiler::VisitCXXNamedCastExpr(const CXXNamedCastExpr *S) {
Douglas Gregor5c193b92009-07-28 00:33:38 +00001460 VisitExplicitCastExpr(S);
1461}
1462
Chandler Carruth631abd92011-06-16 06:47:06 +00001463void StmtProfiler::VisitCXXStaticCastExpr(const CXXStaticCastExpr *S) {
Douglas Gregor5c193b92009-07-28 00:33:38 +00001464 VisitCXXNamedCastExpr(S);
1465}
1466
Chandler Carruth631abd92011-06-16 06:47:06 +00001467void StmtProfiler::VisitCXXDynamicCastExpr(const CXXDynamicCastExpr *S) {
Douglas Gregor5c193b92009-07-28 00:33:38 +00001468 VisitCXXNamedCastExpr(S);
1469}
1470
Chandler Carruth631abd92011-06-16 06:47:06 +00001471void
1472StmtProfiler::VisitCXXReinterpretCastExpr(const CXXReinterpretCastExpr *S) {
Douglas Gregor5c193b92009-07-28 00:33:38 +00001473 VisitCXXNamedCastExpr(S);
1474}
1475
Chandler Carruth631abd92011-06-16 06:47:06 +00001476void StmtProfiler::VisitCXXConstCastExpr(const CXXConstCastExpr *S) {
Douglas Gregor5c193b92009-07-28 00:33:38 +00001477 VisitCXXNamedCastExpr(S);
1478}
1479
Richard Smithc67fdd42012-03-07 08:35:16 +00001480void StmtProfiler::VisitUserDefinedLiteral(const UserDefinedLiteral *S) {
1481 VisitCallExpr(S);
1482}
1483
Chandler Carruth631abd92011-06-16 06:47:06 +00001484void StmtProfiler::VisitCXXBoolLiteralExpr(const CXXBoolLiteralExpr *S) {
Douglas Gregor5c193b92009-07-28 00:33:38 +00001485 VisitExpr(S);
1486 ID.AddBoolean(S->getValue());
1487}
1488
Chandler Carruth631abd92011-06-16 06:47:06 +00001489void StmtProfiler::VisitCXXNullPtrLiteralExpr(const CXXNullPtrLiteralExpr *S) {
Douglas Gregor00044172009-07-29 16:09:57 +00001490 VisitExpr(S);
1491}
1492
Richard Smithcc1b96d2013-06-12 22:31:48 +00001493void StmtProfiler::VisitCXXStdInitializerListExpr(
1494 const CXXStdInitializerListExpr *S) {
1495 VisitExpr(S);
1496}
1497
Chandler Carruth631abd92011-06-16 06:47:06 +00001498void StmtProfiler::VisitCXXTypeidExpr(const CXXTypeidExpr *S) {
Douglas Gregor5c193b92009-07-28 00:33:38 +00001499 VisitExpr(S);
1500 if (S->isTypeOperand())
David Majnemer143c55e2013-09-27 07:04:31 +00001501 VisitType(S->getTypeOperandSourceInfo()->getType());
Douglas Gregor5c193b92009-07-28 00:33:38 +00001502}
1503
Chandler Carruth631abd92011-06-16 06:47:06 +00001504void StmtProfiler::VisitCXXUuidofExpr(const CXXUuidofExpr *S) {
Francois Pichet9f4f2072010-09-08 12:20:18 +00001505 VisitExpr(S);
1506 if (S->isTypeOperand())
David Majnemer143c55e2013-09-27 07:04:31 +00001507 VisitType(S->getTypeOperandSourceInfo()->getType());
Francois Pichet9f4f2072010-09-08 12:20:18 +00001508}
1509
John McCall5e77d762013-04-16 07:28:30 +00001510void StmtProfiler::VisitMSPropertyRefExpr(const MSPropertyRefExpr *S) {
1511 VisitExpr(S);
1512 VisitDecl(S->getPropertyDecl());
1513}
1514
Alexey Bataevf7630272015-11-25 12:01:00 +00001515void StmtProfiler::VisitMSPropertySubscriptExpr(
1516 const MSPropertySubscriptExpr *S) {
1517 VisitExpr(S);
1518}
1519
Chandler Carruth631abd92011-06-16 06:47:06 +00001520void StmtProfiler::VisitCXXThisExpr(const CXXThisExpr *S) {
Douglas Gregor5c193b92009-07-28 00:33:38 +00001521 VisitExpr(S);
Douglas Gregor3024f072012-04-16 07:05:22 +00001522 ID.AddBoolean(S->isImplicit());
Douglas Gregor5c193b92009-07-28 00:33:38 +00001523}
1524
Chandler Carruth631abd92011-06-16 06:47:06 +00001525void StmtProfiler::VisitCXXThrowExpr(const CXXThrowExpr *S) {
Douglas Gregor5c193b92009-07-28 00:33:38 +00001526 VisitExpr(S);
1527}
1528
Chandler Carruth631abd92011-06-16 06:47:06 +00001529void StmtProfiler::VisitCXXDefaultArgExpr(const CXXDefaultArgExpr *S) {
Douglas Gregor5c193b92009-07-28 00:33:38 +00001530 VisitExpr(S);
1531 VisitDecl(S->getParam());
1532}
1533
Richard Smith852c9db2013-04-20 22:23:05 +00001534void StmtProfiler::VisitCXXDefaultInitExpr(const CXXDefaultInitExpr *S) {
1535 VisitExpr(S);
1536 VisitDecl(S->getField());
1537}
1538
Chandler Carruth631abd92011-06-16 06:47:06 +00001539void StmtProfiler::VisitCXXBindTemporaryExpr(const CXXBindTemporaryExpr *S) {
Douglas Gregor5c193b92009-07-28 00:33:38 +00001540 VisitExpr(S);
1541 VisitDecl(
1542 const_cast<CXXDestructorDecl *>(S->getTemporary()->getDestructor()));
1543}
1544
Chandler Carruth631abd92011-06-16 06:47:06 +00001545void StmtProfiler::VisitCXXConstructExpr(const CXXConstructExpr *S) {
Douglas Gregor5c193b92009-07-28 00:33:38 +00001546 VisitExpr(S);
1547 VisitDecl(S->getConstructor());
1548 ID.AddBoolean(S->isElidable());
1549}
1550
Richard Smith5179eb72016-06-28 19:03:57 +00001551void StmtProfiler::VisitCXXInheritedCtorInitExpr(
1552 const CXXInheritedCtorInitExpr *S) {
1553 VisitExpr(S);
1554 VisitDecl(S->getConstructor());
1555}
1556
Chandler Carruth631abd92011-06-16 06:47:06 +00001557void StmtProfiler::VisitCXXFunctionalCastExpr(const CXXFunctionalCastExpr *S) {
Douglas Gregor5c193b92009-07-28 00:33:38 +00001558 VisitExplicitCastExpr(S);
1559}
1560
Chandler Carruth631abd92011-06-16 06:47:06 +00001561void
1562StmtProfiler::VisitCXXTemporaryObjectExpr(const CXXTemporaryObjectExpr *S) {
Douglas Gregor5c193b92009-07-28 00:33:38 +00001563 VisitCXXConstructExpr(S);
1564}
1565
Chandler Carruth631abd92011-06-16 06:47:06 +00001566void
Douglas Gregore31e6062012-02-07 10:09:13 +00001567StmtProfiler::VisitLambdaExpr(const LambdaExpr *S) {
1568 VisitExpr(S);
1569 for (LambdaExpr::capture_iterator C = S->explicit_capture_begin(),
1570 CEnd = S->explicit_capture_end();
1571 C != CEnd; ++C) {
1572 ID.AddInteger(C->getCaptureKind());
Richard Smithba71c082013-05-16 06:20:58 +00001573 switch (C->getCaptureKind()) {
Faisal Validc6b5962016-03-21 09:25:37 +00001574 case LCK_StarThis:
Richard Smithba71c082013-05-16 06:20:58 +00001575 case LCK_This:
1576 break;
1577 case LCK_ByRef:
1578 case LCK_ByCopy:
Douglas Gregore31e6062012-02-07 10:09:13 +00001579 VisitDecl(C->getCapturedVar());
1580 ID.AddBoolean(C->isPackExpansion());
Richard Smithba71c082013-05-16 06:20:58 +00001581 break;
Alexey Bataev39c81e22014-08-28 04:28:19 +00001582 case LCK_VLAType:
1583 llvm_unreachable("VLA type in explicit captures.");
Douglas Gregore31e6062012-02-07 10:09:13 +00001584 }
1585 }
1586 // Note: If we actually needed to be able to match lambda
1587 // expressions, we would have to consider parameters and return type
1588 // here, among other things.
1589 VisitStmt(S->getBody());
1590}
1591
1592void
Chandler Carruth631abd92011-06-16 06:47:06 +00001593StmtProfiler::VisitCXXScalarValueInitExpr(const CXXScalarValueInitExpr *S) {
Douglas Gregor5c193b92009-07-28 00:33:38 +00001594 VisitExpr(S);
1595}
1596
Chandler Carruth631abd92011-06-16 06:47:06 +00001597void StmtProfiler::VisitCXXDeleteExpr(const CXXDeleteExpr *S) {
Douglas Gregor5c193b92009-07-28 00:33:38 +00001598 VisitExpr(S);
1599 ID.AddBoolean(S->isGlobalDelete());
1600 ID.AddBoolean(S->isArrayForm());
1601 VisitDecl(S->getOperatorDelete());
1602}
1603
Chandler Carruth631abd92011-06-16 06:47:06 +00001604void StmtProfiler::VisitCXXNewExpr(const CXXNewExpr *S) {
Douglas Gregor5c193b92009-07-28 00:33:38 +00001605 VisitExpr(S);
1606 VisitType(S->getAllocatedType());
1607 VisitDecl(S->getOperatorNew());
1608 VisitDecl(S->getOperatorDelete());
Douglas Gregor5c193b92009-07-28 00:33:38 +00001609 ID.AddBoolean(S->isArray());
1610 ID.AddInteger(S->getNumPlacementArgs());
1611 ID.AddBoolean(S->isGlobalNew());
1612 ID.AddBoolean(S->isParenTypeId());
Sebastian Redl6047f072012-02-16 12:22:20 +00001613 ID.AddInteger(S->getInitializationStyle());
Douglas Gregor5c193b92009-07-28 00:33:38 +00001614}
1615
Chandler Carruth631abd92011-06-16 06:47:06 +00001616void
1617StmtProfiler::VisitCXXPseudoDestructorExpr(const CXXPseudoDestructorExpr *S) {
Douglas Gregorad8a3362009-09-04 17:36:40 +00001618 VisitExpr(S);
1619 ID.AddBoolean(S->isArrow());
1620 VisitNestedNameSpecifier(S->getQualifier());
Craig Topper36250ad2014-05-12 05:36:57 +00001621 ID.AddBoolean(S->getScopeTypeInfo() != nullptr);
Eli Friedman85641392013-08-09 23:37:05 +00001622 if (S->getScopeTypeInfo())
1623 VisitType(S->getScopeTypeInfo()->getType());
Craig Topper36250ad2014-05-12 05:36:57 +00001624 ID.AddBoolean(S->getDestroyedTypeInfo() != nullptr);
Eli Friedman85641392013-08-09 23:37:05 +00001625 if (S->getDestroyedTypeInfo())
1626 VisitType(S->getDestroyedType());
1627 else
Richard Trieu639d7b62017-02-22 22:22:42 +00001628 VisitIdentifierInfo(S->getDestroyedTypeIdentifier());
Douglas Gregorad8a3362009-09-04 17:36:40 +00001629}
1630
Chandler Carruth631abd92011-06-16 06:47:06 +00001631void StmtProfiler::VisitOverloadExpr(const OverloadExpr *S) {
Argyrios Kyrtzidisb482eb82010-08-15 20:53:20 +00001632 VisitExpr(S);
John McCalle66edc12009-11-24 19:00:30 +00001633 VisitNestedNameSpecifier(S->getQualifier());
Douglas Gregor5c193b92009-07-28 00:33:38 +00001634 VisitName(S->getName());
John McCalle66edc12009-11-24 19:00:30 +00001635 ID.AddBoolean(S->hasExplicitTemplateArgs());
1636 if (S->hasExplicitTemplateArgs())
James Y Knight04ec5bf2015-12-24 02:59:37 +00001637 VisitTemplateArguments(S->getTemplateArgs(), S->getNumTemplateArgs());
Argyrios Kyrtzidisf4505452010-08-15 01:15:38 +00001638}
1639
1640void
Chandler Carruth631abd92011-06-16 06:47:06 +00001641StmtProfiler::VisitUnresolvedLookupExpr(const UnresolvedLookupExpr *S) {
Argyrios Kyrtzidisf4505452010-08-15 01:15:38 +00001642 VisitOverloadExpr(S);
Douglas Gregor5c193b92009-07-28 00:33:38 +00001643}
1644
Douglas Gregor29c42f22012-02-24 07:38:34 +00001645void StmtProfiler::VisitTypeTraitExpr(const TypeTraitExpr *S) {
1646 VisitExpr(S);
1647 ID.AddInteger(S->getTrait());
1648 ID.AddInteger(S->getNumArgs());
1649 for (unsigned I = 0, N = S->getNumArgs(); I != N; ++I)
1650 VisitType(S->getArg(I)->getType());
1651}
1652
Chandler Carruth631abd92011-06-16 06:47:06 +00001653void StmtProfiler::VisitArrayTypeTraitExpr(const ArrayTypeTraitExpr *S) {
John Wiegley6242b6a2011-04-28 00:16:57 +00001654 VisitExpr(S);
1655 ID.AddInteger(S->getTrait());
1656 VisitType(S->getQueriedType());
1657}
1658
Chandler Carruth631abd92011-06-16 06:47:06 +00001659void StmtProfiler::VisitExpressionTraitExpr(const ExpressionTraitExpr *S) {
John Wiegleyf9f65842011-04-25 06:54:41 +00001660 VisitExpr(S);
1661 ID.AddInteger(S->getTrait());
1662 VisitExpr(S->getQueriedExpression());
1663}
1664
Chandler Carruth631abd92011-06-16 06:47:06 +00001665void StmtProfiler::VisitDependentScopeDeclRefExpr(
1666 const DependentScopeDeclRefExpr *S) {
Douglas Gregor5c193b92009-07-28 00:33:38 +00001667 VisitExpr(S);
1668 VisitName(S->getDeclName());
1669 VisitNestedNameSpecifier(S->getQualifier());
John McCalle66edc12009-11-24 19:00:30 +00001670 ID.AddBoolean(S->hasExplicitTemplateArgs());
1671 if (S->hasExplicitTemplateArgs())
1672 VisitTemplateArguments(S->getTemplateArgs(), S->getNumTemplateArgs());
Douglas Gregor5c193b92009-07-28 00:33:38 +00001673}
1674
Chandler Carruth631abd92011-06-16 06:47:06 +00001675void StmtProfiler::VisitExprWithCleanups(const ExprWithCleanups *S) {
Douglas Gregora7095092009-07-28 14:44:31 +00001676 VisitExpr(S);
Douglas Gregora7095092009-07-28 14:44:31 +00001677}
1678
Chandler Carruth631abd92011-06-16 06:47:06 +00001679void StmtProfiler::VisitCXXUnresolvedConstructExpr(
1680 const CXXUnresolvedConstructExpr *S) {
Douglas Gregora7095092009-07-28 14:44:31 +00001681 VisitExpr(S);
1682 VisitType(S->getTypeAsWritten());
1683}
1684
Chandler Carruth631abd92011-06-16 06:47:06 +00001685void StmtProfiler::VisitCXXDependentScopeMemberExpr(
1686 const CXXDependentScopeMemberExpr *S) {
John McCall2d74de92009-12-01 22:10:20 +00001687 ID.AddBoolean(S->isImplicitAccess());
1688 if (!S->isImplicitAccess()) {
1689 VisitExpr(S);
1690 ID.AddBoolean(S->isArrow());
1691 }
Douglas Gregorc26e0f62009-09-03 16:14:30 +00001692 VisitNestedNameSpecifier(S->getQualifier());
Douglas Gregora7095092009-07-28 14:44:31 +00001693 VisitName(S->getMember());
John McCall2d74de92009-12-01 22:10:20 +00001694 ID.AddBoolean(S->hasExplicitTemplateArgs());
1695 if (S->hasExplicitTemplateArgs())
John McCall10eae182009-11-30 22:42:35 +00001696 VisitTemplateArguments(S->getTemplateArgs(), S->getNumTemplateArgs());
1697}
1698
Chandler Carruth631abd92011-06-16 06:47:06 +00001699void StmtProfiler::VisitUnresolvedMemberExpr(const UnresolvedMemberExpr *S) {
John McCall2d74de92009-12-01 22:10:20 +00001700 ID.AddBoolean(S->isImplicitAccess());
1701 if (!S->isImplicitAccess()) {
1702 VisitExpr(S);
1703 ID.AddBoolean(S->isArrow());
1704 }
John McCall10eae182009-11-30 22:42:35 +00001705 VisitNestedNameSpecifier(S->getQualifier());
1706 VisitName(S->getMemberName());
1707 ID.AddBoolean(S->hasExplicitTemplateArgs());
1708 if (S->hasExplicitTemplateArgs())
1709 VisitTemplateArguments(S->getTemplateArgs(), S->getNumTemplateArgs());
Douglas Gregora7095092009-07-28 14:44:31 +00001710}
1711
Chandler Carruth631abd92011-06-16 06:47:06 +00001712void StmtProfiler::VisitCXXNoexceptExpr(const CXXNoexceptExpr *S) {
Sebastian Redl4202c0f2010-09-10 20:55:43 +00001713 VisitExpr(S);
1714}
1715
Chandler Carruth631abd92011-06-16 06:47:06 +00001716void StmtProfiler::VisitPackExpansionExpr(const PackExpansionExpr *S) {
Douglas Gregore8e9dd62011-01-03 17:17:50 +00001717 VisitExpr(S);
1718}
1719
Chandler Carruth631abd92011-06-16 06:47:06 +00001720void StmtProfiler::VisitSizeOfPackExpr(const SizeOfPackExpr *S) {
Douglas Gregor820ba7b2011-01-04 17:33:58 +00001721 VisitExpr(S);
1722 VisitDecl(S->getPack());
Richard Smithd784e682015-09-23 21:41:42 +00001723 if (S->isPartiallySubstituted()) {
1724 auto Args = S->getPartialArguments();
1725 ID.AddInteger(Args.size());
1726 for (const auto &TA : Args)
1727 VisitTemplateArgument(TA);
1728 } else {
1729 ID.AddInteger(0);
1730 }
Douglas Gregor820ba7b2011-01-04 17:33:58 +00001731}
1732
Douglas Gregorcdbc5392011-01-15 01:15:58 +00001733void StmtProfiler::VisitSubstNonTypeTemplateParmPackExpr(
Chandler Carruth631abd92011-06-16 06:47:06 +00001734 const SubstNonTypeTemplateParmPackExpr *S) {
Douglas Gregorcdbc5392011-01-15 01:15:58 +00001735 VisitExpr(S);
1736 VisitDecl(S->getParameterPack());
1737 VisitTemplateArgument(S->getArgumentPack());
1738}
1739
John McCall7c454bb2011-07-15 05:09:51 +00001740void StmtProfiler::VisitSubstNonTypeTemplateParmExpr(
1741 const SubstNonTypeTemplateParmExpr *E) {
1742 // Profile exactly as the replacement expression.
1743 Visit(E->getReplacement());
1744}
1745
Richard Smithb15fe3a2012-09-12 00:56:43 +00001746void StmtProfiler::VisitFunctionParmPackExpr(const FunctionParmPackExpr *S) {
1747 VisitExpr(S);
1748 VisitDecl(S->getParameterPack());
1749 ID.AddInteger(S->getNumExpansions());
1750 for (FunctionParmPackExpr::iterator I = S->begin(), E = S->end(); I != E; ++I)
1751 VisitDecl(*I);
1752}
1753
Douglas Gregorfe314812011-06-21 17:03:29 +00001754void StmtProfiler::VisitMaterializeTemporaryExpr(
1755 const MaterializeTemporaryExpr *S) {
1756 VisitExpr(S);
1757}
1758
Richard Smith0f0af192014-11-08 05:07:16 +00001759void StmtProfiler::VisitCXXFoldExpr(const CXXFoldExpr *S) {
1760 VisitExpr(S);
1761 ID.AddInteger(S->getOperator());
1762}
1763
Richard Smith9f690bd2015-10-27 06:02:45 +00001764void StmtProfiler::VisitCoroutineBodyStmt(const CoroutineBodyStmt *S) {
1765 VisitStmt(S);
1766}
1767
1768void StmtProfiler::VisitCoreturnStmt(const CoreturnStmt *S) {
1769 VisitStmt(S);
1770}
1771
1772void StmtProfiler::VisitCoawaitExpr(const CoawaitExpr *S) {
1773 VisitExpr(S);
1774}
1775
Eric Fiselier20f25cb2017-03-06 23:38:15 +00001776void StmtProfiler::VisitDependentCoawaitExpr(const DependentCoawaitExpr *S) {
1777 VisitExpr(S);
1778}
1779
Richard Smith9f690bd2015-10-27 06:02:45 +00001780void StmtProfiler::VisitCoyieldExpr(const CoyieldExpr *S) {
1781 VisitExpr(S);
1782}
1783
Chandler Carruth631abd92011-06-16 06:47:06 +00001784void StmtProfiler::VisitOpaqueValueExpr(const OpaqueValueExpr *E) {
John McCall8d69a212010-11-15 23:31:06 +00001785 VisitExpr(E);
1786}
1787
Kaelyn Takatae1f49d52014-10-27 18:07:20 +00001788void StmtProfiler::VisitTypoExpr(const TypoExpr *E) {
1789 VisitExpr(E);
1790}
1791
Chandler Carruth631abd92011-06-16 06:47:06 +00001792void StmtProfiler::VisitObjCStringLiteral(const ObjCStringLiteral *S) {
Douglas Gregora7095092009-07-28 14:44:31 +00001793 VisitExpr(S);
1794}
1795
Patrick Beard0caa3942012-04-19 00:25:12 +00001796void StmtProfiler::VisitObjCBoxedExpr(const ObjCBoxedExpr *E) {
Ted Kremeneke65b0862012-03-06 20:05:56 +00001797 VisitExpr(E);
1798}
1799
1800void StmtProfiler::VisitObjCArrayLiteral(const ObjCArrayLiteral *E) {
1801 VisitExpr(E);
1802}
1803
1804void StmtProfiler::VisitObjCDictionaryLiteral(const ObjCDictionaryLiteral *E) {
1805 VisitExpr(E);
1806}
1807
Chandler Carruth631abd92011-06-16 06:47:06 +00001808void StmtProfiler::VisitObjCEncodeExpr(const ObjCEncodeExpr *S) {
Douglas Gregora7095092009-07-28 14:44:31 +00001809 VisitExpr(S);
1810 VisitType(S->getEncodedType());
1811}
1812
Chandler Carruth631abd92011-06-16 06:47:06 +00001813void StmtProfiler::VisitObjCSelectorExpr(const ObjCSelectorExpr *S) {
Douglas Gregora7095092009-07-28 14:44:31 +00001814 VisitExpr(S);
1815 VisitName(S->getSelector());
1816}
1817
Chandler Carruth631abd92011-06-16 06:47:06 +00001818void StmtProfiler::VisitObjCProtocolExpr(const ObjCProtocolExpr *S) {
Douglas Gregora7095092009-07-28 14:44:31 +00001819 VisitExpr(S);
1820 VisitDecl(S->getProtocol());
1821}
1822
Chandler Carruth631abd92011-06-16 06:47:06 +00001823void StmtProfiler::VisitObjCIvarRefExpr(const ObjCIvarRefExpr *S) {
Douglas Gregora7095092009-07-28 14:44:31 +00001824 VisitExpr(S);
1825 VisitDecl(S->getDecl());
1826 ID.AddBoolean(S->isArrow());
1827 ID.AddBoolean(S->isFreeIvar());
1828}
1829
Chandler Carruth631abd92011-06-16 06:47:06 +00001830void StmtProfiler::VisitObjCPropertyRefExpr(const ObjCPropertyRefExpr *S) {
Douglas Gregora7095092009-07-28 14:44:31 +00001831 VisitExpr(S);
John McCallb7bd14f2010-12-02 01:19:52 +00001832 if (S->isImplicitProperty()) {
1833 VisitDecl(S->getImplicitPropertyGetter());
1834 VisitDecl(S->getImplicitPropertySetter());
1835 } else {
1836 VisitDecl(S->getExplicitProperty());
Fariborz Jahanian681c0752010-10-14 16:04:05 +00001837 }
Fariborz Jahanian681c0752010-10-14 16:04:05 +00001838 if (S->isSuperReceiver()) {
1839 ID.AddBoolean(S->isSuperReceiver());
John McCallb7bd14f2010-12-02 01:19:52 +00001840 VisitType(S->getSuperReceiverType());
Fariborz Jahanian681c0752010-10-14 16:04:05 +00001841 }
Douglas Gregora7095092009-07-28 14:44:31 +00001842}
1843
Ted Kremeneke65b0862012-03-06 20:05:56 +00001844void StmtProfiler::VisitObjCSubscriptRefExpr(const ObjCSubscriptRefExpr *S) {
1845 VisitExpr(S);
1846 VisitDecl(S->getAtIndexMethodDecl());
1847 VisitDecl(S->setAtIndexMethodDecl());
1848}
1849
Chandler Carruth631abd92011-06-16 06:47:06 +00001850void StmtProfiler::VisitObjCMessageExpr(const ObjCMessageExpr *S) {
Douglas Gregora7095092009-07-28 14:44:31 +00001851 VisitExpr(S);
1852 VisitName(S->getSelector());
1853 VisitDecl(S->getMethodDecl());
1854}
1855
Chandler Carruth631abd92011-06-16 06:47:06 +00001856void StmtProfiler::VisitObjCIsaExpr(const ObjCIsaExpr *S) {
Douglas Gregora7095092009-07-28 14:44:31 +00001857 VisitExpr(S);
1858 ID.AddBoolean(S->isArrow());
1859}
1860
Ted Kremeneke65b0862012-03-06 20:05:56 +00001861void StmtProfiler::VisitObjCBoolLiteralExpr(const ObjCBoolLiteralExpr *S) {
1862 VisitExpr(S);
1863 ID.AddBoolean(S->getValue());
1864}
1865
Chandler Carruth631abd92011-06-16 06:47:06 +00001866void StmtProfiler::VisitObjCIndirectCopyRestoreExpr(
1867 const ObjCIndirectCopyRestoreExpr *S) {
John McCall31168b02011-06-15 23:02:42 +00001868 VisitExpr(S);
1869 ID.AddBoolean(S->shouldCopy());
1870}
1871
Chandler Carruth631abd92011-06-16 06:47:06 +00001872void StmtProfiler::VisitObjCBridgedCastExpr(const ObjCBridgedCastExpr *S) {
John McCall31168b02011-06-15 23:02:42 +00001873 VisitExplicitCastExpr(S);
1874 ID.AddBoolean(S->getBridgeKind());
1875}
1876
Erik Pilkington29099de2016-07-16 00:35:23 +00001877void StmtProfiler::VisitObjCAvailabilityCheckExpr(
1878 const ObjCAvailabilityCheckExpr *S) {
1879 VisitExpr(S);
1880}
1881
John McCall0ad16662009-10-29 08:12:44 +00001882void StmtProfiler::VisitTemplateArguments(const TemplateArgumentLoc *Args,
Douglas Gregor5c193b92009-07-28 00:33:38 +00001883 unsigned NumArgs) {
1884 ID.AddInteger(NumArgs);
John McCall0ad16662009-10-29 08:12:44 +00001885 for (unsigned I = 0; I != NumArgs; ++I)
1886 VisitTemplateArgument(Args[I].getArgument());
1887}
Mike Stump11289f42009-09-09 15:08:12 +00001888
John McCall0ad16662009-10-29 08:12:44 +00001889void StmtProfiler::VisitTemplateArgument(const TemplateArgument &Arg) {
1890 // Mostly repetitive with TemplateArgument::Profile!
1891 ID.AddInteger(Arg.getKind());
1892 switch (Arg.getKind()) {
1893 case TemplateArgument::Null:
1894 break;
Mike Stump11289f42009-09-09 15:08:12 +00001895
John McCall0ad16662009-10-29 08:12:44 +00001896 case TemplateArgument::Type:
1897 VisitType(Arg.getAsType());
1898 break;
Mike Stump11289f42009-09-09 15:08:12 +00001899
Douglas Gregor9167f8b2009-11-11 01:00:40 +00001900 case TemplateArgument::Template:
Douglas Gregore4ff4b52011-01-05 18:58:31 +00001901 case TemplateArgument::TemplateExpansion:
1902 VisitTemplateName(Arg.getAsTemplateOrTemplatePattern());
Douglas Gregor9167f8b2009-11-11 01:00:40 +00001903 break;
Alexis Hunta8136cc2010-05-05 15:23:54 +00001904
John McCall0ad16662009-10-29 08:12:44 +00001905 case TemplateArgument::Declaration:
1906 VisitDecl(Arg.getAsDecl());
1907 break;
Mike Stump11289f42009-09-09 15:08:12 +00001908
Eli Friedmanb826a002012-09-26 02:36:12 +00001909 case TemplateArgument::NullPtr:
1910 VisitType(Arg.getNullPtrType());
1911 break;
1912
John McCall0ad16662009-10-29 08:12:44 +00001913 case TemplateArgument::Integral:
Benjamin Kramer6003ad52012-06-07 15:09:51 +00001914 Arg.getAsIntegral().Profile(ID);
John McCall0ad16662009-10-29 08:12:44 +00001915 VisitType(Arg.getIntegralType());
1916 break;
Mike Stump11289f42009-09-09 15:08:12 +00001917
John McCall0ad16662009-10-29 08:12:44 +00001918 case TemplateArgument::Expression:
1919 Visit(Arg.getAsExpr());
1920 break;
Mike Stump11289f42009-09-09 15:08:12 +00001921
John McCall0ad16662009-10-29 08:12:44 +00001922 case TemplateArgument::Pack:
Aaron Ballman2a89e852014-07-15 21:32:31 +00001923 for (const auto &P : Arg.pack_elements())
1924 VisitTemplateArgument(P);
John McCall0ad16662009-10-29 08:12:44 +00001925 break;
Douglas Gregor5c193b92009-07-28 00:33:38 +00001926 }
1927}
1928
Jay Foad39c79802011-01-12 09:06:06 +00001929void Stmt::Profile(llvm::FoldingSetNodeID &ID, const ASTContext &Context,
Chandler Carruth631abd92011-06-16 06:47:06 +00001930 bool Canonical) const {
Richard Trieu639d7b62017-02-22 22:22:42 +00001931 StmtProfilerWithPointers Profiler(ID, Context, Canonical);
1932 Profiler.Visit(this);
1933}
1934
1935void Stmt::ProcessODRHash(llvm::FoldingSetNodeID &ID,
1936 class ODRHash &Hash) const {
1937 StmtProfilerWithoutPointers Profiler(ID, Hash);
Douglas Gregor5c193b92009-07-28 00:33:38 +00001938 Profiler.Visit(this);
1939}