blob: 08261205ef010324ddc152e70d4a5c8822e1c21a [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 }
Alexey Bataev88202be2017-07-27 13:20:36 +0000599 for (auto *E : C->taskgroup_descriptors()) {
600 if (E)
601 Profiler->VisitStmt(E);
602 }
Alexey Bataevfa312f32017-07-21 18:48:21 +0000603}
Alexander Musman8dba6642014-04-22 13:09:42 +0000604void OMPClauseProfiler::VisitOMPLinearClause(const OMPLinearClause *C) {
605 VisitOMPClauseList(C);
Alexey Bataev78849fb2016-03-09 09:49:00 +0000606 VistOMPClauseWithPostUpdate(C);
Alexey Bataevbd9fec12015-08-18 06:47:21 +0000607 for (auto *E : C->privates()) {
Richard Trieu6a77a1c2016-06-10 04:52:09 +0000608 if (E)
609 Profiler->VisitStmt(E);
Alexey Bataevbd9fec12015-08-18 06:47:21 +0000610 }
Alexander Musman3276a272015-03-21 10:12:56 +0000611 for (auto *E : C->inits()) {
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->updates()) {
Richard Trieu6a77a1c2016-06-10 04:52:09 +0000616 if (E)
617 Profiler->VisitStmt(E);
Alexander Musman3276a272015-03-21 10:12:56 +0000618 }
619 for (auto *E : C->finals()) {
Richard Trieu6a77a1c2016-06-10 04:52:09 +0000620 if (E)
621 Profiler->VisitStmt(E);
Alexander Musman3276a272015-03-21 10:12:56 +0000622 }
Richard Trieu6a77a1c2016-06-10 04:52:09 +0000623 if (C->getStep())
624 Profiler->VisitStmt(C->getStep());
625 if (C->getCalcStep())
626 Profiler->VisitStmt(C->getCalcStep());
Alexander Musman8dba6642014-04-22 13:09:42 +0000627}
Alexander Musmanf0d76e72014-05-29 14:36:25 +0000628void OMPClauseProfiler::VisitOMPAlignedClause(const OMPAlignedClause *C) {
629 VisitOMPClauseList(C);
Richard Trieu6a77a1c2016-06-10 04:52:09 +0000630 if (C->getAlignment())
631 Profiler->VisitStmt(C->getAlignment());
Alexander Musmanf0d76e72014-05-29 14:36:25 +0000632}
Alexey Bataevd48bcd82014-03-31 03:36:38 +0000633void OMPClauseProfiler::VisitOMPCopyinClause(const OMPCopyinClause *C) {
634 VisitOMPClauseList(C);
Alexey Bataevf56f98c2015-04-16 05:39:01 +0000635 for (auto *E : C->source_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->destination_exprs()) {
Richard Trieu6a77a1c2016-06-10 04:52:09 +0000640 if (E)
641 Profiler->VisitStmt(E);
Alexey Bataevf56f98c2015-04-16 05:39:01 +0000642 }
643 for (auto *E : C->assignment_ops()) {
Richard Trieu6a77a1c2016-06-10 04:52:09 +0000644 if (E)
645 Profiler->VisitStmt(E);
Alexey Bataevf56f98c2015-04-16 05:39:01 +0000646 }
Alexey Bataevd48bcd82014-03-31 03:36:38 +0000647}
Alexey Bataevbae9a792014-06-27 10:37:06 +0000648void
649OMPClauseProfiler::VisitOMPCopyprivateClause(const OMPCopyprivateClause *C) {
650 VisitOMPClauseList(C);
Alexey Bataeva63048e2015-03-23 06:18:07 +0000651 for (auto *E : C->source_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->destination_exprs()) {
Richard Trieu6a77a1c2016-06-10 04:52:09 +0000656 if (E)
657 Profiler->VisitStmt(E);
Alexey Bataeva63048e2015-03-23 06:18:07 +0000658 }
659 for (auto *E : C->assignment_ops()) {
Richard Trieu6a77a1c2016-06-10 04:52:09 +0000660 if (E)
661 Profiler->VisitStmt(E);
Alexey Bataeva63048e2015-03-23 06:18:07 +0000662 }
Alexey Bataevbae9a792014-06-27 10:37:06 +0000663}
Alexey Bataev6125da92014-07-21 11:26:11 +0000664void OMPClauseProfiler::VisitOMPFlushClause(const OMPFlushClause *C) {
665 VisitOMPClauseList(C);
666}
Alexey Bataev1c2cfbc2015-06-23 14:25:19 +0000667void OMPClauseProfiler::VisitOMPDependClause(const OMPDependClause *C) {
668 VisitOMPClauseList(C);
669}
Michael Wonge710d542015-08-07 16:16:36 +0000670void OMPClauseProfiler::VisitOMPDeviceClause(const OMPDeviceClause *C) {
Richard Trieu6a77a1c2016-06-10 04:52:09 +0000671 if (C->getDevice())
672 Profiler->VisitStmt(C->getDevice());
Michael Wonge710d542015-08-07 16:16:36 +0000673}
Kelvin Li0bff7af2015-11-23 05:32:03 +0000674void OMPClauseProfiler::VisitOMPMapClause(const OMPMapClause *C) {
675 VisitOMPClauseList(C);
676}
Kelvin Li099bb8c2015-11-24 20:50:12 +0000677void OMPClauseProfiler::VisitOMPNumTeamsClause(const OMPNumTeamsClause *C) {
Arpith Chacko Jacobbc126342017-01-25 11:28:18 +0000678 VistOMPClauseWithPreInit(C);
Richard Trieu6a77a1c2016-06-10 04:52:09 +0000679 if (C->getNumTeams())
680 Profiler->VisitStmt(C->getNumTeams());
Kelvin Li099bb8c2015-11-24 20:50:12 +0000681}
Kelvin Lia15fb1a2015-11-27 18:47:36 +0000682void OMPClauseProfiler::VisitOMPThreadLimitClause(
683 const OMPThreadLimitClause *C) {
Arpith Chacko Jacob7ecc0b72017-01-25 11:44:35 +0000684 VistOMPClauseWithPreInit(C);
Richard Trieu6a77a1c2016-06-10 04:52:09 +0000685 if (C->getThreadLimit())
686 Profiler->VisitStmt(C->getThreadLimit());
Kelvin Lia15fb1a2015-11-27 18:47:36 +0000687}
Alexey Bataeva0569352015-12-01 10:17:31 +0000688void OMPClauseProfiler::VisitOMPPriorityClause(const OMPPriorityClause *C) {
Richard Trieu6a77a1c2016-06-10 04:52:09 +0000689 if (C->getPriority())
690 Profiler->VisitStmt(C->getPriority());
Alexey Bataeva0569352015-12-01 10:17:31 +0000691}
Alexey Bataev1fd4aed2015-12-07 12:52:51 +0000692void OMPClauseProfiler::VisitOMPGrainsizeClause(const OMPGrainsizeClause *C) {
Richard Trieu6a77a1c2016-06-10 04:52:09 +0000693 if (C->getGrainsize())
694 Profiler->VisitStmt(C->getGrainsize());
Alexey Bataev1fd4aed2015-12-07 12:52:51 +0000695}
Alexey Bataev382967a2015-12-08 12:06:20 +0000696void OMPClauseProfiler::VisitOMPNumTasksClause(const OMPNumTasksClause *C) {
Richard Trieu6a77a1c2016-06-10 04:52:09 +0000697 if (C->getNumTasks())
698 Profiler->VisitStmt(C->getNumTasks());
Alexey Bataev382967a2015-12-08 12:06:20 +0000699}
Alexey Bataev28c75412015-12-15 08:19:24 +0000700void OMPClauseProfiler::VisitOMPHintClause(const OMPHintClause *C) {
Richard Trieu6a77a1c2016-06-10 04:52:09 +0000701 if (C->getHint())
702 Profiler->VisitStmt(C->getHint());
Alexey Bataev28c75412015-12-15 08:19:24 +0000703}
Samuel Antao661c0902016-05-26 17:39:58 +0000704void OMPClauseProfiler::VisitOMPToClause(const OMPToClause *C) {
705 VisitOMPClauseList(C);
706}
Samuel Antaoec172c62016-05-26 17:49:04 +0000707void OMPClauseProfiler::VisitOMPFromClause(const OMPFromClause *C) {
708 VisitOMPClauseList(C);
709}
Carlo Bertolli2404b172016-07-13 15:37:16 +0000710void OMPClauseProfiler::VisitOMPUseDevicePtrClause(
711 const OMPUseDevicePtrClause *C) {
712 VisitOMPClauseList(C);
713}
Carlo Bertolli70594e92016-07-13 17:16:49 +0000714void OMPClauseProfiler::VisitOMPIsDevicePtrClause(
715 const OMPIsDevicePtrClause *C) {
716 VisitOMPClauseList(C);
717}
Alexander Kornienkoab9db512015-06-22 23:07:51 +0000718}
Alexey Bataev5ec3eb12013-07-19 03:13:43 +0000719
720void
Alexey Bataev1b59ab52014-02-27 08:29:12 +0000721StmtProfiler::VisitOMPExecutableDirective(const OMPExecutableDirective *S) {
Alexey Bataev5ec3eb12013-07-19 03:13:43 +0000722 VisitStmt(S);
723 OMPClauseProfiler P(this);
724 ArrayRef<OMPClause *> Clauses = S->clauses();
725 for (ArrayRef<OMPClause *>::iterator I = Clauses.begin(), E = Clauses.end();
726 I != E; ++I)
727 if (*I)
728 P.Visit(*I);
729}
730
Alexander Musman3aaab662014-08-19 11:27:13 +0000731void StmtProfiler::VisitOMPLoopDirective(const OMPLoopDirective *S) {
732 VisitOMPExecutableDirective(S);
733}
734
Alexey Bataev1b59ab52014-02-27 08:29:12 +0000735void StmtProfiler::VisitOMPParallelDirective(const OMPParallelDirective *S) {
736 VisitOMPExecutableDirective(S);
737}
738
739void StmtProfiler::VisitOMPSimdDirective(const OMPSimdDirective *S) {
Alexander Musman3aaab662014-08-19 11:27:13 +0000740 VisitOMPLoopDirective(S);
Alexey Bataev1b59ab52014-02-27 08:29:12 +0000741}
742
Alexey Bataevf29276e2014-06-18 04:14:57 +0000743void StmtProfiler::VisitOMPForDirective(const OMPForDirective *S) {
Alexander Musman3aaab662014-08-19 11:27:13 +0000744 VisitOMPLoopDirective(S);
Alexey Bataevf29276e2014-06-18 04:14:57 +0000745}
746
Alexander Musmanf82886e2014-09-18 05:12:34 +0000747void StmtProfiler::VisitOMPForSimdDirective(const OMPForSimdDirective *S) {
748 VisitOMPLoopDirective(S);
749}
750
Alexey Bataevd3f8dd22014-06-25 11:44:49 +0000751void StmtProfiler::VisitOMPSectionsDirective(const OMPSectionsDirective *S) {
752 VisitOMPExecutableDirective(S);
753}
754
Alexey Bataev1e0498a2014-06-26 08:21:58 +0000755void StmtProfiler::VisitOMPSectionDirective(const OMPSectionDirective *S) {
756 VisitOMPExecutableDirective(S);
757}
758
Alexey Bataevd1e40fb2014-06-26 12:05:45 +0000759void StmtProfiler::VisitOMPSingleDirective(const OMPSingleDirective *S) {
760 VisitOMPExecutableDirective(S);
761}
762
Alexander Musman80c22892014-07-17 08:54:58 +0000763void StmtProfiler::VisitOMPMasterDirective(const OMPMasterDirective *S) {
764 VisitOMPExecutableDirective(S);
765}
766
Alexander Musmand9ed09f2014-07-21 09:42:05 +0000767void StmtProfiler::VisitOMPCriticalDirective(const OMPCriticalDirective *S) {
768 VisitOMPExecutableDirective(S);
769 VisitName(S->getDirectiveName().getName());
770}
771
Alexey Bataev4acb8592014-07-07 13:01:15 +0000772void
773StmtProfiler::VisitOMPParallelForDirective(const OMPParallelForDirective *S) {
Alexander Musman3aaab662014-08-19 11:27:13 +0000774 VisitOMPLoopDirective(S);
Alexey Bataev4acb8592014-07-07 13:01:15 +0000775}
776
Alexander Musmane4e893b2014-09-23 09:33:00 +0000777void StmtProfiler::VisitOMPParallelForSimdDirective(
778 const OMPParallelForSimdDirective *S) {
779 VisitOMPLoopDirective(S);
780}
781
Alexey Bataev84d0b3e2014-07-08 08:12:03 +0000782void StmtProfiler::VisitOMPParallelSectionsDirective(
783 const OMPParallelSectionsDirective *S) {
784 VisitOMPExecutableDirective(S);
785}
786
Alexey Bataev9c2e8ee2014-07-11 11:25:16 +0000787void StmtProfiler::VisitOMPTaskDirective(const OMPTaskDirective *S) {
788 VisitOMPExecutableDirective(S);
789}
790
Alexey Bataev68446b72014-07-18 07:47:19 +0000791void StmtProfiler::VisitOMPTaskyieldDirective(const OMPTaskyieldDirective *S) {
792 VisitOMPExecutableDirective(S);
793}
794
Alexey Bataev4d1dfea2014-07-18 09:11:51 +0000795void StmtProfiler::VisitOMPBarrierDirective(const OMPBarrierDirective *S) {
796 VisitOMPExecutableDirective(S);
797}
798
Alexey Bataev2df347a2014-07-18 10:17:07 +0000799void StmtProfiler::VisitOMPTaskwaitDirective(const OMPTaskwaitDirective *S) {
800 VisitOMPExecutableDirective(S);
801}
802
Alexey Bataevc30dd2d2015-06-18 12:14:09 +0000803void StmtProfiler::VisitOMPTaskgroupDirective(const OMPTaskgroupDirective *S) {
804 VisitOMPExecutableDirective(S);
Alexey Bataev3b1b8952017-07-25 15:53:26 +0000805 if (const Expr *E = S->getReductionRef())
806 VisitStmt(E);
Alexey Bataevc30dd2d2015-06-18 12:14:09 +0000807}
808
Alexey Bataev6125da92014-07-21 11:26:11 +0000809void StmtProfiler::VisitOMPFlushDirective(const OMPFlushDirective *S) {
810 VisitOMPExecutableDirective(S);
811}
812
Alexey Bataev9fb6e642014-07-22 06:45:04 +0000813void StmtProfiler::VisitOMPOrderedDirective(const OMPOrderedDirective *S) {
814 VisitOMPExecutableDirective(S);
815}
816
Alexey Bataev0162e452014-07-22 10:10:35 +0000817void StmtProfiler::VisitOMPAtomicDirective(const OMPAtomicDirective *S) {
818 VisitOMPExecutableDirective(S);
819}
820
Alexey Bataev0bd520b2014-09-19 08:19:49 +0000821void StmtProfiler::VisitOMPTargetDirective(const OMPTargetDirective *S) {
822 VisitOMPExecutableDirective(S);
823}
824
Michael Wong65f367f2015-07-21 13:44:28 +0000825void StmtProfiler::VisitOMPTargetDataDirective(const OMPTargetDataDirective *S) {
826 VisitOMPExecutableDirective(S);
827}
828
Samuel Antaodf67fc42016-01-19 19:15:56 +0000829void StmtProfiler::VisitOMPTargetEnterDataDirective(
830 const OMPTargetEnterDataDirective *S) {
831 VisitOMPExecutableDirective(S);
832}
833
Samuel Antao72590762016-01-19 20:04:50 +0000834void StmtProfiler::VisitOMPTargetExitDataDirective(
835 const OMPTargetExitDataDirective *S) {
836 VisitOMPExecutableDirective(S);
837}
838
Arpith Chacko Jacobe955b3d2016-01-26 18:48:41 +0000839void StmtProfiler::VisitOMPTargetParallelDirective(
840 const OMPTargetParallelDirective *S) {
841 VisitOMPExecutableDirective(S);
842}
843
Arpith Chacko Jacob05bebb52016-02-03 15:46:42 +0000844void StmtProfiler::VisitOMPTargetParallelForDirective(
845 const OMPTargetParallelForDirective *S) {
846 VisitOMPExecutableDirective(S);
847}
848
Alexey Bataev13314bf2014-10-09 04:18:56 +0000849void StmtProfiler::VisitOMPTeamsDirective(const OMPTeamsDirective *S) {
850 VisitOMPExecutableDirective(S);
851}
852
Alexey Bataev6d4ed052015-07-01 06:57:41 +0000853void StmtProfiler::VisitOMPCancellationPointDirective(
854 const OMPCancellationPointDirective *S) {
855 VisitOMPExecutableDirective(S);
856}
857
Alexey Bataev80909872015-07-02 11:25:17 +0000858void StmtProfiler::VisitOMPCancelDirective(const OMPCancelDirective *S) {
859 VisitOMPExecutableDirective(S);
860}
861
Alexey Bataev49f6e782015-12-01 04:18:41 +0000862void StmtProfiler::VisitOMPTaskLoopDirective(const OMPTaskLoopDirective *S) {
863 VisitOMPLoopDirective(S);
864}
865
Alexey Bataev0a6ed842015-12-03 09:40:15 +0000866void StmtProfiler::VisitOMPTaskLoopSimdDirective(
867 const OMPTaskLoopSimdDirective *S) {
868 VisitOMPLoopDirective(S);
869}
870
Carlo Bertolli6200a3d2015-12-14 14:51:25 +0000871void StmtProfiler::VisitOMPDistributeDirective(
872 const OMPDistributeDirective *S) {
873 VisitOMPLoopDirective(S);
874}
875
Carlo Bertollib4adf552016-01-15 18:50:31 +0000876void OMPClauseProfiler::VisitOMPDistScheduleClause(
877 const OMPDistScheduleClause *C) {
Alexey Bataev3392d762016-02-16 11:18:12 +0000878 VistOMPClauseWithPreInit(C);
879 if (auto *S = C->getChunkSize())
880 Profiler->VisitStmt(S);
Carlo Bertollib4adf552016-01-15 18:50:31 +0000881}
882
Arpith Chacko Jacob3cf89042016-01-26 16:37:23 +0000883void OMPClauseProfiler::VisitOMPDefaultmapClause(const OMPDefaultmapClause *) {}
884
Samuel Antao686c70c2016-05-26 17:30:50 +0000885void StmtProfiler::VisitOMPTargetUpdateDirective(
886 const OMPTargetUpdateDirective *S) {
887 VisitOMPExecutableDirective(S);
888}
889
Carlo Bertolli9925f152016-06-27 14:55:37 +0000890void StmtProfiler::VisitOMPDistributeParallelForDirective(
891 const OMPDistributeParallelForDirective *S) {
892 VisitOMPLoopDirective(S);
893}
894
Kelvin Li4a39add2016-07-05 05:00:15 +0000895void StmtProfiler::VisitOMPDistributeParallelForSimdDirective(
896 const OMPDistributeParallelForSimdDirective *S) {
897 VisitOMPLoopDirective(S);
898}
899
Kelvin Li787f3fc2016-07-06 04:45:38 +0000900void StmtProfiler::VisitOMPDistributeSimdDirective(
901 const OMPDistributeSimdDirective *S) {
902 VisitOMPLoopDirective(S);
903}
904
Kelvin Lia579b912016-07-14 02:54:56 +0000905void StmtProfiler::VisitOMPTargetParallelForSimdDirective(
906 const OMPTargetParallelForSimdDirective *S) {
907 VisitOMPLoopDirective(S);
908}
909
Kelvin Li986330c2016-07-20 22:57:10 +0000910void StmtProfiler::VisitOMPTargetSimdDirective(
911 const OMPTargetSimdDirective *S) {
912 VisitOMPLoopDirective(S);
913}
914
Kelvin Li02532872016-08-05 14:37:37 +0000915void StmtProfiler::VisitOMPTeamsDistributeDirective(
916 const OMPTeamsDistributeDirective *S) {
917 VisitOMPLoopDirective(S);
918}
919
Kelvin Li4e325f72016-10-25 12:50:55 +0000920void StmtProfiler::VisitOMPTeamsDistributeSimdDirective(
921 const OMPTeamsDistributeSimdDirective *S) {
922 VisitOMPLoopDirective(S);
923}
924
Kelvin Li579e41c2016-11-30 23:51:03 +0000925void StmtProfiler::VisitOMPTeamsDistributeParallelForSimdDirective(
926 const OMPTeamsDistributeParallelForSimdDirective *S) {
927 VisitOMPLoopDirective(S);
928}
929
Kelvin Li7ade93f2016-12-09 03:24:30 +0000930void StmtProfiler::VisitOMPTeamsDistributeParallelForDirective(
931 const OMPTeamsDistributeParallelForDirective *S) {
932 VisitOMPLoopDirective(S);
933}
934
Kelvin Libf594a52016-12-17 05:48:59 +0000935void StmtProfiler::VisitOMPTargetTeamsDirective(
936 const OMPTargetTeamsDirective *S) {
937 VisitOMPExecutableDirective(S);
938}
939
Kelvin Li83c451e2016-12-25 04:52:54 +0000940void StmtProfiler::VisitOMPTargetTeamsDistributeDirective(
941 const OMPTargetTeamsDistributeDirective *S) {
942 VisitOMPLoopDirective(S);
943}
944
Kelvin Li80e8f562016-12-29 22:16:30 +0000945void StmtProfiler::VisitOMPTargetTeamsDistributeParallelForDirective(
946 const OMPTargetTeamsDistributeParallelForDirective *S) {
947 VisitOMPLoopDirective(S);
948}
949
Kelvin Li1851df52017-01-03 05:23:48 +0000950void StmtProfiler::VisitOMPTargetTeamsDistributeParallelForSimdDirective(
951 const OMPTargetTeamsDistributeParallelForSimdDirective *S) {
952 VisitOMPLoopDirective(S);
953}
954
Kelvin Lida681182017-01-10 18:08:18 +0000955void StmtProfiler::VisitOMPTargetTeamsDistributeSimdDirective(
956 const OMPTargetTeamsDistributeSimdDirective *S) {
957 VisitOMPLoopDirective(S);
958}
959
Chandler Carruth631abd92011-06-16 06:47:06 +0000960void StmtProfiler::VisitExpr(const Expr *S) {
Douglas Gregor5c193b92009-07-28 00:33:38 +0000961 VisitStmt(S);
962}
963
Chandler Carruth631abd92011-06-16 06:47:06 +0000964void StmtProfiler::VisitDeclRefExpr(const DeclRefExpr *S) {
Douglas Gregor5c193b92009-07-28 00:33:38 +0000965 VisitExpr(S);
Douglas Gregorf5b160f2010-07-13 08:37:11 +0000966 if (!Canonical)
967 VisitNestedNameSpecifier(S->getQualifier());
Douglas Gregor5c193b92009-07-28 00:33:38 +0000968 VisitDecl(S->getDecl());
Richard Trieu4d06bef2018-02-13 19:53:40 +0000969 if (!Canonical) {
970 ID.AddBoolean(S->hasExplicitTemplateArgs());
971 if (S->hasExplicitTemplateArgs())
972 VisitTemplateArguments(S->getTemplateArgs(), S->getNumTemplateArgs());
973 }
Douglas Gregor5c193b92009-07-28 00:33:38 +0000974}
975
Chandler Carruth631abd92011-06-16 06:47:06 +0000976void StmtProfiler::VisitPredefinedExpr(const PredefinedExpr *S) {
Douglas Gregor5c193b92009-07-28 00:33:38 +0000977 VisitExpr(S);
978 ID.AddInteger(S->getIdentType());
979}
980
Chandler Carruth631abd92011-06-16 06:47:06 +0000981void StmtProfiler::VisitIntegerLiteral(const IntegerLiteral *S) {
Douglas Gregor5c193b92009-07-28 00:33:38 +0000982 VisitExpr(S);
983 S->getValue().Profile(ID);
Richard Smithe9f130c2014-11-20 03:37:32 +0000984 ID.AddInteger(S->getType()->castAs<BuiltinType>()->getKind());
Douglas Gregor5c193b92009-07-28 00:33:38 +0000985}
986
Chandler Carruth631abd92011-06-16 06:47:06 +0000987void StmtProfiler::VisitCharacterLiteral(const CharacterLiteral *S) {
Douglas Gregor5c193b92009-07-28 00:33:38 +0000988 VisitExpr(S);
Douglas Gregorfb65e592011-07-27 05:40:30 +0000989 ID.AddInteger(S->getKind());
Douglas Gregor5c193b92009-07-28 00:33:38 +0000990 ID.AddInteger(S->getValue());
991}
992
Chandler Carruth631abd92011-06-16 06:47:06 +0000993void StmtProfiler::VisitFloatingLiteral(const FloatingLiteral *S) {
Douglas Gregor5c193b92009-07-28 00:33:38 +0000994 VisitExpr(S);
995 S->getValue().Profile(ID);
996 ID.AddBoolean(S->isExact());
Richard Smithe9f130c2014-11-20 03:37:32 +0000997 ID.AddInteger(S->getType()->castAs<BuiltinType>()->getKind());
Douglas Gregor5c193b92009-07-28 00:33:38 +0000998}
999
Chandler Carruth631abd92011-06-16 06:47:06 +00001000void StmtProfiler::VisitImaginaryLiteral(const ImaginaryLiteral *S) {
Douglas Gregor5c193b92009-07-28 00:33:38 +00001001 VisitExpr(S);
1002}
1003
Chandler Carruth631abd92011-06-16 06:47:06 +00001004void StmtProfiler::VisitStringLiteral(const StringLiteral *S) {
Douglas Gregor5c193b92009-07-28 00:33:38 +00001005 VisitExpr(S);
Douglas Gregor9d0eb8f2011-11-02 17:26:05 +00001006 ID.AddString(S->getBytes());
Douglas Gregorfb65e592011-07-27 05:40:30 +00001007 ID.AddInteger(S->getKind());
Douglas Gregor5c193b92009-07-28 00:33:38 +00001008}
1009
Chandler Carruth631abd92011-06-16 06:47:06 +00001010void StmtProfiler::VisitParenExpr(const ParenExpr *S) {
Douglas Gregor5c193b92009-07-28 00:33:38 +00001011 VisitExpr(S);
1012}
1013
Chandler Carruth631abd92011-06-16 06:47:06 +00001014void StmtProfiler::VisitParenListExpr(const ParenListExpr *S) {
Nate Begeman5ec4b312009-08-10 23:49:36 +00001015 VisitExpr(S);
1016}
1017
Chandler Carruth631abd92011-06-16 06:47:06 +00001018void StmtProfiler::VisitUnaryOperator(const UnaryOperator *S) {
Douglas Gregor5c193b92009-07-28 00:33:38 +00001019 VisitExpr(S);
1020 ID.AddInteger(S->getOpcode());
1021}
1022
Chandler Carruth631abd92011-06-16 06:47:06 +00001023void StmtProfiler::VisitOffsetOfExpr(const OffsetOfExpr *S) {
Douglas Gregor882211c2010-04-28 22:16:22 +00001024 VisitType(S->getTypeSourceInfo()->getType());
1025 unsigned n = S->getNumComponents();
1026 for (unsigned i = 0; i < n; ++i) {
James Y Knight7281c352015-12-29 22:31:18 +00001027 const OffsetOfNode &ON = S->getComponent(i);
Douglas Gregor882211c2010-04-28 22:16:22 +00001028 ID.AddInteger(ON.getKind());
1029 switch (ON.getKind()) {
James Y Knight7281c352015-12-29 22:31:18 +00001030 case OffsetOfNode::Array:
Douglas Gregor882211c2010-04-28 22:16:22 +00001031 // Expressions handled below.
1032 break;
1033
James Y Knight7281c352015-12-29 22:31:18 +00001034 case OffsetOfNode::Field:
Douglas Gregor882211c2010-04-28 22:16:22 +00001035 VisitDecl(ON.getField());
1036 break;
1037
James Y Knight7281c352015-12-29 22:31:18 +00001038 case OffsetOfNode::Identifier:
Richard Trieu639d7b62017-02-22 22:22:42 +00001039 VisitIdentifierInfo(ON.getFieldName());
Douglas Gregor882211c2010-04-28 22:16:22 +00001040 break;
James Y Knight7281c352015-12-29 22:31:18 +00001041
1042 case OffsetOfNode::Base:
Douglas Gregord1702062010-04-29 00:18:15 +00001043 // These nodes are implicit, and therefore don't need profiling.
1044 break;
Douglas Gregor882211c2010-04-28 22:16:22 +00001045 }
1046 }
Richard Trieu639d7b62017-02-22 22:22:42 +00001047
Douglas Gregor882211c2010-04-28 22:16:22 +00001048 VisitExpr(S);
1049}
1050
Chandler Carruth631abd92011-06-16 06:47:06 +00001051void
1052StmtProfiler::VisitUnaryExprOrTypeTraitExpr(const UnaryExprOrTypeTraitExpr *S) {
Douglas Gregor5c193b92009-07-28 00:33:38 +00001053 VisitExpr(S);
Peter Collingbournee190dee2011-03-11 19:24:49 +00001054 ID.AddInteger(S->getKind());
Douglas Gregor5c193b92009-07-28 00:33:38 +00001055 if (S->isArgumentType())
1056 VisitType(S->getArgumentType());
1057}
1058
Chandler Carruth631abd92011-06-16 06:47:06 +00001059void StmtProfiler::VisitArraySubscriptExpr(const ArraySubscriptExpr *S) {
Douglas Gregor5c193b92009-07-28 00:33:38 +00001060 VisitExpr(S);
1061}
1062
Alexey Bataev1a3320e2015-08-25 14:24:04 +00001063void StmtProfiler::VisitOMPArraySectionExpr(const OMPArraySectionExpr *S) {
1064 VisitExpr(S);
1065}
1066
Chandler Carruth631abd92011-06-16 06:47:06 +00001067void StmtProfiler::VisitCallExpr(const CallExpr *S) {
Douglas Gregor5c193b92009-07-28 00:33:38 +00001068 VisitExpr(S);
1069}
1070
Chandler Carruth631abd92011-06-16 06:47:06 +00001071void StmtProfiler::VisitMemberExpr(const MemberExpr *S) {
Douglas Gregor5c193b92009-07-28 00:33:38 +00001072 VisitExpr(S);
1073 VisitDecl(S->getMemberDecl());
Douglas Gregorf5b160f2010-07-13 08:37:11 +00001074 if (!Canonical)
1075 VisitNestedNameSpecifier(S->getQualifier());
Douglas Gregor5c193b92009-07-28 00:33:38 +00001076 ID.AddBoolean(S->isArrow());
1077}
1078
Chandler Carruth631abd92011-06-16 06:47:06 +00001079void StmtProfiler::VisitCompoundLiteralExpr(const CompoundLiteralExpr *S) {
Douglas Gregor5c193b92009-07-28 00:33:38 +00001080 VisitExpr(S);
1081 ID.AddBoolean(S->isFileScope());
1082}
1083
Chandler Carruth631abd92011-06-16 06:47:06 +00001084void StmtProfiler::VisitCastExpr(const CastExpr *S) {
Douglas Gregor5c193b92009-07-28 00:33:38 +00001085 VisitExpr(S);
1086}
1087
Chandler Carruth631abd92011-06-16 06:47:06 +00001088void StmtProfiler::VisitImplicitCastExpr(const ImplicitCastExpr *S) {
Douglas Gregor5c193b92009-07-28 00:33:38 +00001089 VisitCastExpr(S);
John McCall2536c6d2010-08-25 10:28:54 +00001090 ID.AddInteger(S->getValueKind());
Douglas Gregor5c193b92009-07-28 00:33:38 +00001091}
1092
Chandler Carruth631abd92011-06-16 06:47:06 +00001093void StmtProfiler::VisitExplicitCastExpr(const ExplicitCastExpr *S) {
Douglas Gregor5c193b92009-07-28 00:33:38 +00001094 VisitCastExpr(S);
1095 VisitType(S->getTypeAsWritten());
1096}
1097
Chandler Carruth631abd92011-06-16 06:47:06 +00001098void StmtProfiler::VisitCStyleCastExpr(const CStyleCastExpr *S) {
Douglas Gregor5c193b92009-07-28 00:33:38 +00001099 VisitExplicitCastExpr(S);
1100}
1101
Chandler Carruth631abd92011-06-16 06:47:06 +00001102void StmtProfiler::VisitBinaryOperator(const BinaryOperator *S) {
Douglas Gregor5c193b92009-07-28 00:33:38 +00001103 VisitExpr(S);
1104 ID.AddInteger(S->getOpcode());
1105}
1106
Chandler Carruth631abd92011-06-16 06:47:06 +00001107void
1108StmtProfiler::VisitCompoundAssignOperator(const CompoundAssignOperator *S) {
Douglas Gregor5c193b92009-07-28 00:33:38 +00001109 VisitBinaryOperator(S);
1110}
1111
Chandler Carruth631abd92011-06-16 06:47:06 +00001112void StmtProfiler::VisitConditionalOperator(const ConditionalOperator *S) {
Douglas Gregor5c193b92009-07-28 00:33:38 +00001113 VisitExpr(S);
1114}
1115
Chandler Carruth631abd92011-06-16 06:47:06 +00001116void StmtProfiler::VisitBinaryConditionalOperator(
Chandler Carruthcf5f43c2011-06-21 23:26:32 +00001117 const BinaryConditionalOperator *S) {
John McCallc07a0c72011-02-17 10:25:35 +00001118 VisitExpr(S);
1119}
1120
Chandler Carruth631abd92011-06-16 06:47:06 +00001121void StmtProfiler::VisitAddrLabelExpr(const AddrLabelExpr *S) {
Douglas Gregor5c193b92009-07-28 00:33:38 +00001122 VisitExpr(S);
Chris Lattnerc8e630e2011-02-17 07:39:24 +00001123 VisitDecl(S->getLabel());
Douglas Gregor5c193b92009-07-28 00:33:38 +00001124}
1125
Chandler Carruth631abd92011-06-16 06:47:06 +00001126void StmtProfiler::VisitStmtExpr(const StmtExpr *S) {
Douglas Gregor5c193b92009-07-28 00:33:38 +00001127 VisitExpr(S);
1128}
1129
Chandler Carruth631abd92011-06-16 06:47:06 +00001130void StmtProfiler::VisitShuffleVectorExpr(const ShuffleVectorExpr *S) {
Douglas Gregor5c193b92009-07-28 00:33:38 +00001131 VisitExpr(S);
1132}
1133
Hal Finkelc4d7c822013-09-18 03:29:45 +00001134void StmtProfiler::VisitConvertVectorExpr(const ConvertVectorExpr *S) {
1135 VisitExpr(S);
1136}
1137
Chandler Carruth631abd92011-06-16 06:47:06 +00001138void StmtProfiler::VisitChooseExpr(const ChooseExpr *S) {
Douglas Gregor5c193b92009-07-28 00:33:38 +00001139 VisitExpr(S);
1140}
1141
Chandler Carruth631abd92011-06-16 06:47:06 +00001142void StmtProfiler::VisitGNUNullExpr(const GNUNullExpr *S) {
Douglas Gregor5c193b92009-07-28 00:33:38 +00001143 VisitExpr(S);
1144}
1145
Chandler Carruth631abd92011-06-16 06:47:06 +00001146void StmtProfiler::VisitVAArgExpr(const VAArgExpr *S) {
Douglas Gregor00044172009-07-29 16:09:57 +00001147 VisitExpr(S);
1148}
1149
Chandler Carruth631abd92011-06-16 06:47:06 +00001150void StmtProfiler::VisitInitListExpr(const InitListExpr *S) {
Douglas Gregor5c193b92009-07-28 00:33:38 +00001151 if (S->getSyntacticForm()) {
1152 VisitInitListExpr(S->getSyntacticForm());
1153 return;
1154 }
Mike Stump11289f42009-09-09 15:08:12 +00001155
Douglas Gregor5c193b92009-07-28 00:33:38 +00001156 VisitExpr(S);
1157}
1158
Chandler Carruth631abd92011-06-16 06:47:06 +00001159void StmtProfiler::VisitDesignatedInitExpr(const DesignatedInitExpr *S) {
Douglas Gregor5c193b92009-07-28 00:33:38 +00001160 VisitExpr(S);
1161 ID.AddBoolean(S->usesGNUSyntax());
David Majnemerf7e36092016-06-23 00:15:04 +00001162 for (const DesignatedInitExpr::Designator &D : S->designators()) {
1163 if (D.isFieldDesignator()) {
Douglas Gregor5c193b92009-07-28 00:33:38 +00001164 ID.AddInteger(0);
David Majnemerf7e36092016-06-23 00:15:04 +00001165 VisitName(D.getFieldName());
Douglas Gregor5c193b92009-07-28 00:33:38 +00001166 continue;
1167 }
Mike Stump11289f42009-09-09 15:08:12 +00001168
David Majnemerf7e36092016-06-23 00:15:04 +00001169 if (D.isArrayDesignator()) {
Douglas Gregor5c193b92009-07-28 00:33:38 +00001170 ID.AddInteger(1);
1171 } else {
David Majnemerf7e36092016-06-23 00:15:04 +00001172 assert(D.isArrayRangeDesignator());
Douglas Gregor5c193b92009-07-28 00:33:38 +00001173 ID.AddInteger(2);
1174 }
David Majnemerf7e36092016-06-23 00:15:04 +00001175 ID.AddInteger(D.getFirstExprIndex());
Douglas Gregor5c193b92009-07-28 00:33:38 +00001176 }
1177}
1178
Yunzhong Gaocb779302015-06-10 00:27:52 +00001179// Seems that if VisitInitListExpr() only works on the syntactic form of an
1180// InitListExpr, then a DesignatedInitUpdateExpr is not encountered.
1181void StmtProfiler::VisitDesignatedInitUpdateExpr(
1182 const DesignatedInitUpdateExpr *S) {
1183 llvm_unreachable("Unexpected DesignatedInitUpdateExpr in syntactic form of "
1184 "initializer");
1185}
1186
Richard Smith410306b2016-12-12 02:53:20 +00001187void StmtProfiler::VisitArrayInitLoopExpr(const ArrayInitLoopExpr *S) {
1188 VisitExpr(S);
1189}
1190
1191void StmtProfiler::VisitArrayInitIndexExpr(const ArrayInitIndexExpr *S) {
1192 VisitExpr(S);
1193}
1194
Yunzhong Gaocb779302015-06-10 00:27:52 +00001195void StmtProfiler::VisitNoInitExpr(const NoInitExpr *S) {
1196 llvm_unreachable("Unexpected NoInitExpr in syntactic form of initializer");
1197}
1198
Chandler Carruth631abd92011-06-16 06:47:06 +00001199void StmtProfiler::VisitImplicitValueInitExpr(const ImplicitValueInitExpr *S) {
Douglas Gregor5c193b92009-07-28 00:33:38 +00001200 VisitExpr(S);
1201}
1202
Chandler Carruth631abd92011-06-16 06:47:06 +00001203void StmtProfiler::VisitExtVectorElementExpr(const ExtVectorElementExpr *S) {
Douglas Gregor5c193b92009-07-28 00:33:38 +00001204 VisitExpr(S);
1205 VisitName(&S->getAccessor());
1206}
1207
Chandler Carruth631abd92011-06-16 06:47:06 +00001208void StmtProfiler::VisitBlockExpr(const BlockExpr *S) {
Douglas Gregor5c193b92009-07-28 00:33:38 +00001209 VisitExpr(S);
1210 VisitDecl(S->getBlockDecl());
1211}
1212
Chandler Carruth631abd92011-06-16 06:47:06 +00001213void StmtProfiler::VisitGenericSelectionExpr(const GenericSelectionExpr *S) {
Peter Collingbourne91147592011-04-15 00:35:48 +00001214 VisitExpr(S);
1215 for (unsigned i = 0; i != S->getNumAssocs(); ++i) {
1216 QualType T = S->getAssocType(i);
1217 if (T.isNull())
Craig Topper36250ad2014-05-12 05:36:57 +00001218 ID.AddPointer(nullptr);
Peter Collingbourne91147592011-04-15 00:35:48 +00001219 else
1220 VisitType(T);
1221 VisitExpr(S->getAssocExpr(i));
1222 }
1223}
1224
John McCallfe96e0b2011-11-06 09:01:30 +00001225void StmtProfiler::VisitPseudoObjectExpr(const PseudoObjectExpr *S) {
1226 VisitExpr(S);
1227 for (PseudoObjectExpr::const_semantics_iterator
1228 i = S->semantics_begin(), e = S->semantics_end(); i != e; ++i)
1229 // Normally, we would not profile the source expressions of OVEs.
1230 if (const OpaqueValueExpr *OVE = dyn_cast<OpaqueValueExpr>(*i))
1231 Visit(OVE->getSourceExpr());
1232}
1233
Eli Friedmandf14b3a2011-10-11 02:20:01 +00001234void StmtProfiler::VisitAtomicExpr(const AtomicExpr *S) {
1235 VisitExpr(S);
Eli Friedman4b72fdd2011-10-14 20:59:01 +00001236 ID.AddInteger(S->getOp());
Eli Friedmandf14b3a2011-10-11 02:20:01 +00001237}
1238
Chandler Carruth631abd92011-06-16 06:47:06 +00001239static Stmt::StmtClass DecodeOperatorCall(const CXXOperatorCallExpr *S,
John McCalle3027922010-08-25 11:45:40 +00001240 UnaryOperatorKind &UnaryOp,
1241 BinaryOperatorKind &BinaryOp) {
Douglas Gregore9ceb312010-05-19 04:13:23 +00001242 switch (S->getOperator()) {
1243 case OO_None:
1244 case OO_New:
1245 case OO_Delete:
1246 case OO_Array_New:
1247 case OO_Array_Delete:
1248 case OO_Arrow:
1249 case OO_Call:
1250 case OO_Conditional:
Richard Smith9be594e2015-10-22 05:12:22 +00001251 case OO_Coawait:
Douglas Gregore9ceb312010-05-19 04:13:23 +00001252 case NUM_OVERLOADED_OPERATORS:
1253 llvm_unreachable("Invalid operator call kind");
Douglas Gregore9ceb312010-05-19 04:13:23 +00001254
1255 case OO_Plus:
1256 if (S->getNumArgs() == 1) {
John McCalle3027922010-08-25 11:45:40 +00001257 UnaryOp = UO_Plus;
Douglas Gregore9ceb312010-05-19 04:13:23 +00001258 return Stmt::UnaryOperatorClass;
1259 }
1260
John McCalle3027922010-08-25 11:45:40 +00001261 BinaryOp = BO_Add;
Douglas Gregore9ceb312010-05-19 04:13:23 +00001262 return Stmt::BinaryOperatorClass;
1263
1264 case OO_Minus:
1265 if (S->getNumArgs() == 1) {
John McCalle3027922010-08-25 11:45:40 +00001266 UnaryOp = UO_Minus;
Douglas Gregore9ceb312010-05-19 04:13:23 +00001267 return Stmt::UnaryOperatorClass;
1268 }
1269
John McCalle3027922010-08-25 11:45:40 +00001270 BinaryOp = BO_Sub;
Douglas Gregore9ceb312010-05-19 04:13:23 +00001271 return Stmt::BinaryOperatorClass;
1272
1273 case OO_Star:
1274 if (S->getNumArgs() == 1) {
Richard Smithf15acc52014-06-05 22:43:40 +00001275 UnaryOp = UO_Deref;
Douglas Gregore9ceb312010-05-19 04:13:23 +00001276 return Stmt::UnaryOperatorClass;
1277 }
1278
Richard Smithf15acc52014-06-05 22:43:40 +00001279 BinaryOp = BO_Mul;
Douglas Gregore9ceb312010-05-19 04:13:23 +00001280 return Stmt::BinaryOperatorClass;
1281
1282 case OO_Slash:
John McCalle3027922010-08-25 11:45:40 +00001283 BinaryOp = BO_Div;
Douglas Gregore9ceb312010-05-19 04:13:23 +00001284 return Stmt::BinaryOperatorClass;
1285
1286 case OO_Percent:
John McCalle3027922010-08-25 11:45:40 +00001287 BinaryOp = BO_Rem;
Douglas Gregore9ceb312010-05-19 04:13:23 +00001288 return Stmt::BinaryOperatorClass;
1289
1290 case OO_Caret:
John McCalle3027922010-08-25 11:45:40 +00001291 BinaryOp = BO_Xor;
Douglas Gregore9ceb312010-05-19 04:13:23 +00001292 return Stmt::BinaryOperatorClass;
1293
1294 case OO_Amp:
1295 if (S->getNumArgs() == 1) {
John McCalle3027922010-08-25 11:45:40 +00001296 UnaryOp = UO_AddrOf;
Douglas Gregore9ceb312010-05-19 04:13:23 +00001297 return Stmt::UnaryOperatorClass;
1298 }
1299
John McCalle3027922010-08-25 11:45:40 +00001300 BinaryOp = BO_And;
Douglas Gregore9ceb312010-05-19 04:13:23 +00001301 return Stmt::BinaryOperatorClass;
1302
1303 case OO_Pipe:
John McCalle3027922010-08-25 11:45:40 +00001304 BinaryOp = BO_Or;
Douglas Gregore9ceb312010-05-19 04:13:23 +00001305 return Stmt::BinaryOperatorClass;
1306
1307 case OO_Tilde:
John McCalle3027922010-08-25 11:45:40 +00001308 UnaryOp = UO_Not;
Douglas Gregore9ceb312010-05-19 04:13:23 +00001309 return Stmt::UnaryOperatorClass;
1310
1311 case OO_Exclaim:
John McCalle3027922010-08-25 11:45:40 +00001312 UnaryOp = UO_LNot;
Douglas Gregore9ceb312010-05-19 04:13:23 +00001313 return Stmt::UnaryOperatorClass;
1314
1315 case OO_Equal:
John McCalle3027922010-08-25 11:45:40 +00001316 BinaryOp = BO_Assign;
Douglas Gregore9ceb312010-05-19 04:13:23 +00001317 return Stmt::BinaryOperatorClass;
1318
1319 case OO_Less:
John McCalle3027922010-08-25 11:45:40 +00001320 BinaryOp = BO_LT;
Douglas Gregore9ceb312010-05-19 04:13:23 +00001321 return Stmt::BinaryOperatorClass;
1322
1323 case OO_Greater:
John McCalle3027922010-08-25 11:45:40 +00001324 BinaryOp = BO_GT;
Douglas Gregore9ceb312010-05-19 04:13:23 +00001325 return Stmt::BinaryOperatorClass;
1326
1327 case OO_PlusEqual:
John McCalle3027922010-08-25 11:45:40 +00001328 BinaryOp = BO_AddAssign;
Douglas Gregore9ceb312010-05-19 04:13:23 +00001329 return Stmt::CompoundAssignOperatorClass;
1330
1331 case OO_MinusEqual:
John McCalle3027922010-08-25 11:45:40 +00001332 BinaryOp = BO_SubAssign;
Douglas Gregore9ceb312010-05-19 04:13:23 +00001333 return Stmt::CompoundAssignOperatorClass;
1334
1335 case OO_StarEqual:
John McCalle3027922010-08-25 11:45:40 +00001336 BinaryOp = BO_MulAssign;
Douglas Gregore9ceb312010-05-19 04:13:23 +00001337 return Stmt::CompoundAssignOperatorClass;
1338
1339 case OO_SlashEqual:
John McCalle3027922010-08-25 11:45:40 +00001340 BinaryOp = BO_DivAssign;
Douglas Gregore9ceb312010-05-19 04:13:23 +00001341 return Stmt::CompoundAssignOperatorClass;
1342
1343 case OO_PercentEqual:
John McCalle3027922010-08-25 11:45:40 +00001344 BinaryOp = BO_RemAssign;
Douglas Gregore9ceb312010-05-19 04:13:23 +00001345 return Stmt::CompoundAssignOperatorClass;
1346
1347 case OO_CaretEqual:
John McCalle3027922010-08-25 11:45:40 +00001348 BinaryOp = BO_XorAssign;
Douglas Gregore9ceb312010-05-19 04:13:23 +00001349 return Stmt::CompoundAssignOperatorClass;
1350
1351 case OO_AmpEqual:
John McCalle3027922010-08-25 11:45:40 +00001352 BinaryOp = BO_AndAssign;
Douglas Gregore9ceb312010-05-19 04:13:23 +00001353 return Stmt::CompoundAssignOperatorClass;
1354
1355 case OO_PipeEqual:
John McCalle3027922010-08-25 11:45:40 +00001356 BinaryOp = BO_OrAssign;
Douglas Gregore9ceb312010-05-19 04:13:23 +00001357 return Stmt::CompoundAssignOperatorClass;
1358
1359 case OO_LessLess:
John McCalle3027922010-08-25 11:45:40 +00001360 BinaryOp = BO_Shl;
Douglas Gregore9ceb312010-05-19 04:13:23 +00001361 return Stmt::BinaryOperatorClass;
1362
1363 case OO_GreaterGreater:
John McCalle3027922010-08-25 11:45:40 +00001364 BinaryOp = BO_Shr;
Douglas Gregore9ceb312010-05-19 04:13:23 +00001365 return Stmt::BinaryOperatorClass;
1366
1367 case OO_LessLessEqual:
John McCalle3027922010-08-25 11:45:40 +00001368 BinaryOp = BO_ShlAssign;
Douglas Gregore9ceb312010-05-19 04:13:23 +00001369 return Stmt::CompoundAssignOperatorClass;
1370
1371 case OO_GreaterGreaterEqual:
John McCalle3027922010-08-25 11:45:40 +00001372 BinaryOp = BO_ShrAssign;
Douglas Gregore9ceb312010-05-19 04:13:23 +00001373 return Stmt::CompoundAssignOperatorClass;
1374
1375 case OO_EqualEqual:
John McCalle3027922010-08-25 11:45:40 +00001376 BinaryOp = BO_EQ;
Douglas Gregore9ceb312010-05-19 04:13:23 +00001377 return Stmt::BinaryOperatorClass;
1378
1379 case OO_ExclaimEqual:
John McCalle3027922010-08-25 11:45:40 +00001380 BinaryOp = BO_NE;
Douglas Gregore9ceb312010-05-19 04:13:23 +00001381 return Stmt::BinaryOperatorClass;
1382
1383 case OO_LessEqual:
John McCalle3027922010-08-25 11:45:40 +00001384 BinaryOp = BO_LE;
Douglas Gregore9ceb312010-05-19 04:13:23 +00001385 return Stmt::BinaryOperatorClass;
1386
1387 case OO_GreaterEqual:
John McCalle3027922010-08-25 11:45:40 +00001388 BinaryOp = BO_GE;
Douglas Gregore9ceb312010-05-19 04:13:23 +00001389 return Stmt::BinaryOperatorClass;
Richard Smithd30b23d2017-12-01 02:13:10 +00001390
1391 case OO_Spaceship:
1392 // FIXME: Update this once we support <=> expressions.
1393 llvm_unreachable("<=> expressions not supported yet");
Douglas Gregore9ceb312010-05-19 04:13:23 +00001394
1395 case OO_AmpAmp:
John McCalle3027922010-08-25 11:45:40 +00001396 BinaryOp = BO_LAnd;
Douglas Gregore9ceb312010-05-19 04:13:23 +00001397 return Stmt::BinaryOperatorClass;
1398
1399 case OO_PipePipe:
John McCalle3027922010-08-25 11:45:40 +00001400 BinaryOp = BO_LOr;
Douglas Gregore9ceb312010-05-19 04:13:23 +00001401 return Stmt::BinaryOperatorClass;
1402
1403 case OO_PlusPlus:
John McCalle3027922010-08-25 11:45:40 +00001404 UnaryOp = S->getNumArgs() == 1? UO_PreInc
1405 : UO_PostInc;
Douglas Gregore9ceb312010-05-19 04:13:23 +00001406 return Stmt::UnaryOperatorClass;
1407
1408 case OO_MinusMinus:
John McCalle3027922010-08-25 11:45:40 +00001409 UnaryOp = S->getNumArgs() == 1? UO_PreDec
1410 : UO_PostDec;
Douglas Gregore9ceb312010-05-19 04:13:23 +00001411 return Stmt::UnaryOperatorClass;
1412
1413 case OO_Comma:
John McCalle3027922010-08-25 11:45:40 +00001414 BinaryOp = BO_Comma;
Douglas Gregore9ceb312010-05-19 04:13:23 +00001415 return Stmt::BinaryOperatorClass;
1416
Douglas Gregore9ceb312010-05-19 04:13:23 +00001417 case OO_ArrowStar:
John McCalle3027922010-08-25 11:45:40 +00001418 BinaryOp = BO_PtrMemI;
Douglas Gregore9ceb312010-05-19 04:13:23 +00001419 return Stmt::BinaryOperatorClass;
1420
1421 case OO_Subscript:
1422 return Stmt::ArraySubscriptExprClass;
1423 }
1424
1425 llvm_unreachable("Invalid overloaded operator expression");
1426}
Richard Smithf15acc52014-06-05 22:43:40 +00001427
Reid Klecknere257e182017-10-13 16:18:32 +00001428#if defined(_MSC_VER) && !defined(__clang__)
Nico Weberf56f4462017-07-24 16:54:11 +00001429#if _MSC_VER == 1911
1430// Work around https://developercommunity.visualstudio.com/content/problem/84002/clang-cl-when-built-with-vc-2017-crashes-cause-vc.html
1431// MSVC 2017 update 3 miscompiles this function, and a clang built with it
1432// will crash in stage 2 of a bootstrap build.
1433#pragma optimize("", off)
1434#endif
1435#endif
1436
Chandler Carruth631abd92011-06-16 06:47:06 +00001437void StmtProfiler::VisitCXXOperatorCallExpr(const CXXOperatorCallExpr *S) {
Douglas Gregore9ceb312010-05-19 04:13:23 +00001438 if (S->isTypeDependent()) {
1439 // Type-dependent operator calls are profiled like their underlying
1440 // syntactic operator.
Richard Smithbac0a0d2016-10-24 18:47:04 +00001441 //
1442 // An operator call to operator-> is always implicit, so just skip it. The
1443 // enclosing MemberExpr will profile the actual member access.
1444 if (S->getOperator() == OO_Arrow)
1445 return Visit(S->getArg(0));
1446
John McCalle3027922010-08-25 11:45:40 +00001447 UnaryOperatorKind UnaryOp = UO_Extension;
1448 BinaryOperatorKind BinaryOp = BO_Comma;
Douglas Gregore9ceb312010-05-19 04:13:23 +00001449 Stmt::StmtClass SC = DecodeOperatorCall(S, UnaryOp, BinaryOp);
Richard Smithf15acc52014-06-05 22:43:40 +00001450
Douglas Gregore9ceb312010-05-19 04:13:23 +00001451 ID.AddInteger(SC);
1452 for (unsigned I = 0, N = S->getNumArgs(); I != N; ++I)
1453 Visit(S->getArg(I));
1454 if (SC == Stmt::UnaryOperatorClass)
1455 ID.AddInteger(UnaryOp);
1456 else if (SC == Stmt::BinaryOperatorClass ||
1457 SC == Stmt::CompoundAssignOperatorClass)
1458 ID.AddInteger(BinaryOp);
1459 else
1460 assert(SC == Stmt::ArraySubscriptExprClass);
Richard Smithf15acc52014-06-05 22:43:40 +00001461
Douglas Gregore9ceb312010-05-19 04:13:23 +00001462 return;
1463 }
Richard Smithf15acc52014-06-05 22:43:40 +00001464
Douglas Gregor5c193b92009-07-28 00:33:38 +00001465 VisitCallExpr(S);
1466 ID.AddInteger(S->getOperator());
1467}
1468
Reid Klecknere257e182017-10-13 16:18:32 +00001469#if defined(_MSC_VER) && !defined(__clang__)
Nico Weberf56f4462017-07-24 16:54:11 +00001470#if _MSC_VER == 1911
1471#pragma optimize("", on)
1472#endif
1473#endif
1474
Chandler Carruth631abd92011-06-16 06:47:06 +00001475void StmtProfiler::VisitCXXMemberCallExpr(const CXXMemberCallExpr *S) {
Douglas Gregor5c193b92009-07-28 00:33:38 +00001476 VisitCallExpr(S);
1477}
1478
Chandler Carruth631abd92011-06-16 06:47:06 +00001479void StmtProfiler::VisitCUDAKernelCallExpr(const CUDAKernelCallExpr *S) {
Peter Collingbourne41f85462011-02-09 21:07:24 +00001480 VisitCallExpr(S);
1481}
1482
Chandler Carruth631abd92011-06-16 06:47:06 +00001483void StmtProfiler::VisitAsTypeExpr(const AsTypeExpr *S) {
Tanya Lattner55808c12011-06-04 00:47:47 +00001484 VisitExpr(S);
1485}
1486
Chandler Carruth631abd92011-06-16 06:47:06 +00001487void StmtProfiler::VisitCXXNamedCastExpr(const CXXNamedCastExpr *S) {
Douglas Gregor5c193b92009-07-28 00:33:38 +00001488 VisitExplicitCastExpr(S);
1489}
1490
Chandler Carruth631abd92011-06-16 06:47:06 +00001491void StmtProfiler::VisitCXXStaticCastExpr(const CXXStaticCastExpr *S) {
Douglas Gregor5c193b92009-07-28 00:33:38 +00001492 VisitCXXNamedCastExpr(S);
1493}
1494
Chandler Carruth631abd92011-06-16 06:47:06 +00001495void StmtProfiler::VisitCXXDynamicCastExpr(const CXXDynamicCastExpr *S) {
Douglas Gregor5c193b92009-07-28 00:33:38 +00001496 VisitCXXNamedCastExpr(S);
1497}
1498
Chandler Carruth631abd92011-06-16 06:47:06 +00001499void
1500StmtProfiler::VisitCXXReinterpretCastExpr(const CXXReinterpretCastExpr *S) {
Douglas Gregor5c193b92009-07-28 00:33:38 +00001501 VisitCXXNamedCastExpr(S);
1502}
1503
Chandler Carruth631abd92011-06-16 06:47:06 +00001504void StmtProfiler::VisitCXXConstCastExpr(const CXXConstCastExpr *S) {
Douglas Gregor5c193b92009-07-28 00:33:38 +00001505 VisitCXXNamedCastExpr(S);
1506}
1507
Richard Smithc67fdd42012-03-07 08:35:16 +00001508void StmtProfiler::VisitUserDefinedLiteral(const UserDefinedLiteral *S) {
1509 VisitCallExpr(S);
1510}
1511
Chandler Carruth631abd92011-06-16 06:47:06 +00001512void StmtProfiler::VisitCXXBoolLiteralExpr(const CXXBoolLiteralExpr *S) {
Douglas Gregor5c193b92009-07-28 00:33:38 +00001513 VisitExpr(S);
1514 ID.AddBoolean(S->getValue());
1515}
1516
Chandler Carruth631abd92011-06-16 06:47:06 +00001517void StmtProfiler::VisitCXXNullPtrLiteralExpr(const CXXNullPtrLiteralExpr *S) {
Douglas Gregor00044172009-07-29 16:09:57 +00001518 VisitExpr(S);
1519}
1520
Richard Smithcc1b96d2013-06-12 22:31:48 +00001521void StmtProfiler::VisitCXXStdInitializerListExpr(
1522 const CXXStdInitializerListExpr *S) {
1523 VisitExpr(S);
1524}
1525
Chandler Carruth631abd92011-06-16 06:47:06 +00001526void StmtProfiler::VisitCXXTypeidExpr(const CXXTypeidExpr *S) {
Douglas Gregor5c193b92009-07-28 00:33:38 +00001527 VisitExpr(S);
1528 if (S->isTypeOperand())
David Majnemer143c55e2013-09-27 07:04:31 +00001529 VisitType(S->getTypeOperandSourceInfo()->getType());
Douglas Gregor5c193b92009-07-28 00:33:38 +00001530}
1531
Chandler Carruth631abd92011-06-16 06:47:06 +00001532void StmtProfiler::VisitCXXUuidofExpr(const CXXUuidofExpr *S) {
Francois Pichet9f4f2072010-09-08 12:20:18 +00001533 VisitExpr(S);
1534 if (S->isTypeOperand())
David Majnemer143c55e2013-09-27 07:04:31 +00001535 VisitType(S->getTypeOperandSourceInfo()->getType());
Francois Pichet9f4f2072010-09-08 12:20:18 +00001536}
1537
John McCall5e77d762013-04-16 07:28:30 +00001538void StmtProfiler::VisitMSPropertyRefExpr(const MSPropertyRefExpr *S) {
1539 VisitExpr(S);
1540 VisitDecl(S->getPropertyDecl());
1541}
1542
Alexey Bataevf7630272015-11-25 12:01:00 +00001543void StmtProfiler::VisitMSPropertySubscriptExpr(
1544 const MSPropertySubscriptExpr *S) {
1545 VisitExpr(S);
1546}
1547
Chandler Carruth631abd92011-06-16 06:47:06 +00001548void StmtProfiler::VisitCXXThisExpr(const CXXThisExpr *S) {
Douglas Gregor5c193b92009-07-28 00:33:38 +00001549 VisitExpr(S);
Douglas Gregor3024f072012-04-16 07:05:22 +00001550 ID.AddBoolean(S->isImplicit());
Douglas Gregor5c193b92009-07-28 00:33:38 +00001551}
1552
Chandler Carruth631abd92011-06-16 06:47:06 +00001553void StmtProfiler::VisitCXXThrowExpr(const CXXThrowExpr *S) {
Douglas Gregor5c193b92009-07-28 00:33:38 +00001554 VisitExpr(S);
1555}
1556
Chandler Carruth631abd92011-06-16 06:47:06 +00001557void StmtProfiler::VisitCXXDefaultArgExpr(const CXXDefaultArgExpr *S) {
Douglas Gregor5c193b92009-07-28 00:33:38 +00001558 VisitExpr(S);
1559 VisitDecl(S->getParam());
1560}
1561
Richard Smith852c9db2013-04-20 22:23:05 +00001562void StmtProfiler::VisitCXXDefaultInitExpr(const CXXDefaultInitExpr *S) {
1563 VisitExpr(S);
1564 VisitDecl(S->getField());
1565}
1566
Chandler Carruth631abd92011-06-16 06:47:06 +00001567void StmtProfiler::VisitCXXBindTemporaryExpr(const CXXBindTemporaryExpr *S) {
Douglas Gregor5c193b92009-07-28 00:33:38 +00001568 VisitExpr(S);
1569 VisitDecl(
1570 const_cast<CXXDestructorDecl *>(S->getTemporary()->getDestructor()));
1571}
1572
Chandler Carruth631abd92011-06-16 06:47:06 +00001573void StmtProfiler::VisitCXXConstructExpr(const CXXConstructExpr *S) {
Douglas Gregor5c193b92009-07-28 00:33:38 +00001574 VisitExpr(S);
1575 VisitDecl(S->getConstructor());
1576 ID.AddBoolean(S->isElidable());
1577}
1578
Richard Smith5179eb72016-06-28 19:03:57 +00001579void StmtProfiler::VisitCXXInheritedCtorInitExpr(
1580 const CXXInheritedCtorInitExpr *S) {
1581 VisitExpr(S);
1582 VisitDecl(S->getConstructor());
1583}
1584
Chandler Carruth631abd92011-06-16 06:47:06 +00001585void StmtProfiler::VisitCXXFunctionalCastExpr(const CXXFunctionalCastExpr *S) {
Douglas Gregor5c193b92009-07-28 00:33:38 +00001586 VisitExplicitCastExpr(S);
1587}
1588
Chandler Carruth631abd92011-06-16 06:47:06 +00001589void
1590StmtProfiler::VisitCXXTemporaryObjectExpr(const CXXTemporaryObjectExpr *S) {
Douglas Gregor5c193b92009-07-28 00:33:38 +00001591 VisitCXXConstructExpr(S);
1592}
1593
Chandler Carruth631abd92011-06-16 06:47:06 +00001594void
Douglas Gregore31e6062012-02-07 10:09:13 +00001595StmtProfiler::VisitLambdaExpr(const LambdaExpr *S) {
1596 VisitExpr(S);
1597 for (LambdaExpr::capture_iterator C = S->explicit_capture_begin(),
1598 CEnd = S->explicit_capture_end();
1599 C != CEnd; ++C) {
Richard Trieu931638e2017-11-11 00:54:25 +00001600 if (C->capturesVLAType())
1601 continue;
1602
Douglas Gregore31e6062012-02-07 10:09:13 +00001603 ID.AddInteger(C->getCaptureKind());
Richard Smithba71c082013-05-16 06:20:58 +00001604 switch (C->getCaptureKind()) {
Faisal Validc6b5962016-03-21 09:25:37 +00001605 case LCK_StarThis:
Richard Smithba71c082013-05-16 06:20:58 +00001606 case LCK_This:
1607 break;
1608 case LCK_ByRef:
1609 case LCK_ByCopy:
Douglas Gregore31e6062012-02-07 10:09:13 +00001610 VisitDecl(C->getCapturedVar());
1611 ID.AddBoolean(C->isPackExpansion());
Richard Smithba71c082013-05-16 06:20:58 +00001612 break;
Alexey Bataev39c81e22014-08-28 04:28:19 +00001613 case LCK_VLAType:
1614 llvm_unreachable("VLA type in explicit captures.");
Douglas Gregore31e6062012-02-07 10:09:13 +00001615 }
1616 }
1617 // Note: If we actually needed to be able to match lambda
1618 // expressions, we would have to consider parameters and return type
1619 // here, among other things.
1620 VisitStmt(S->getBody());
1621}
1622
1623void
Chandler Carruth631abd92011-06-16 06:47:06 +00001624StmtProfiler::VisitCXXScalarValueInitExpr(const CXXScalarValueInitExpr *S) {
Douglas Gregor5c193b92009-07-28 00:33:38 +00001625 VisitExpr(S);
1626}
1627
Chandler Carruth631abd92011-06-16 06:47:06 +00001628void StmtProfiler::VisitCXXDeleteExpr(const CXXDeleteExpr *S) {
Douglas Gregor5c193b92009-07-28 00:33:38 +00001629 VisitExpr(S);
1630 ID.AddBoolean(S->isGlobalDelete());
1631 ID.AddBoolean(S->isArrayForm());
1632 VisitDecl(S->getOperatorDelete());
1633}
1634
Chandler Carruth631abd92011-06-16 06:47:06 +00001635void StmtProfiler::VisitCXXNewExpr(const CXXNewExpr *S) {
Douglas Gregor5c193b92009-07-28 00:33:38 +00001636 VisitExpr(S);
1637 VisitType(S->getAllocatedType());
1638 VisitDecl(S->getOperatorNew());
1639 VisitDecl(S->getOperatorDelete());
Douglas Gregor5c193b92009-07-28 00:33:38 +00001640 ID.AddBoolean(S->isArray());
1641 ID.AddInteger(S->getNumPlacementArgs());
1642 ID.AddBoolean(S->isGlobalNew());
1643 ID.AddBoolean(S->isParenTypeId());
Sebastian Redl6047f072012-02-16 12:22:20 +00001644 ID.AddInteger(S->getInitializationStyle());
Douglas Gregor5c193b92009-07-28 00:33:38 +00001645}
1646
Chandler Carruth631abd92011-06-16 06:47:06 +00001647void
1648StmtProfiler::VisitCXXPseudoDestructorExpr(const CXXPseudoDestructorExpr *S) {
Douglas Gregorad8a3362009-09-04 17:36:40 +00001649 VisitExpr(S);
1650 ID.AddBoolean(S->isArrow());
1651 VisitNestedNameSpecifier(S->getQualifier());
Craig Topper36250ad2014-05-12 05:36:57 +00001652 ID.AddBoolean(S->getScopeTypeInfo() != nullptr);
Eli Friedman85641392013-08-09 23:37:05 +00001653 if (S->getScopeTypeInfo())
1654 VisitType(S->getScopeTypeInfo()->getType());
Craig Topper36250ad2014-05-12 05:36:57 +00001655 ID.AddBoolean(S->getDestroyedTypeInfo() != nullptr);
Eli Friedman85641392013-08-09 23:37:05 +00001656 if (S->getDestroyedTypeInfo())
1657 VisitType(S->getDestroyedType());
1658 else
Richard Trieu639d7b62017-02-22 22:22:42 +00001659 VisitIdentifierInfo(S->getDestroyedTypeIdentifier());
Douglas Gregorad8a3362009-09-04 17:36:40 +00001660}
1661
Chandler Carruth631abd92011-06-16 06:47:06 +00001662void StmtProfiler::VisitOverloadExpr(const OverloadExpr *S) {
Argyrios Kyrtzidisb482eb82010-08-15 20:53:20 +00001663 VisitExpr(S);
John McCalle66edc12009-11-24 19:00:30 +00001664 VisitNestedNameSpecifier(S->getQualifier());
Douglas Gregor5c193b92009-07-28 00:33:38 +00001665 VisitName(S->getName());
John McCalle66edc12009-11-24 19:00:30 +00001666 ID.AddBoolean(S->hasExplicitTemplateArgs());
1667 if (S->hasExplicitTemplateArgs())
James Y Knight04ec5bf2015-12-24 02:59:37 +00001668 VisitTemplateArguments(S->getTemplateArgs(), S->getNumTemplateArgs());
Argyrios Kyrtzidisf4505452010-08-15 01:15:38 +00001669}
1670
1671void
Chandler Carruth631abd92011-06-16 06:47:06 +00001672StmtProfiler::VisitUnresolvedLookupExpr(const UnresolvedLookupExpr *S) {
Argyrios Kyrtzidisf4505452010-08-15 01:15:38 +00001673 VisitOverloadExpr(S);
Douglas Gregor5c193b92009-07-28 00:33:38 +00001674}
1675
Douglas Gregor29c42f22012-02-24 07:38:34 +00001676void StmtProfiler::VisitTypeTraitExpr(const TypeTraitExpr *S) {
1677 VisitExpr(S);
1678 ID.AddInteger(S->getTrait());
1679 ID.AddInteger(S->getNumArgs());
1680 for (unsigned I = 0, N = S->getNumArgs(); I != N; ++I)
1681 VisitType(S->getArg(I)->getType());
1682}
1683
Chandler Carruth631abd92011-06-16 06:47:06 +00001684void StmtProfiler::VisitArrayTypeTraitExpr(const ArrayTypeTraitExpr *S) {
John Wiegley6242b6a2011-04-28 00:16:57 +00001685 VisitExpr(S);
1686 ID.AddInteger(S->getTrait());
1687 VisitType(S->getQueriedType());
1688}
1689
Chandler Carruth631abd92011-06-16 06:47:06 +00001690void StmtProfiler::VisitExpressionTraitExpr(const ExpressionTraitExpr *S) {
John Wiegleyf9f65842011-04-25 06:54:41 +00001691 VisitExpr(S);
1692 ID.AddInteger(S->getTrait());
1693 VisitExpr(S->getQueriedExpression());
1694}
1695
Chandler Carruth631abd92011-06-16 06:47:06 +00001696void StmtProfiler::VisitDependentScopeDeclRefExpr(
1697 const DependentScopeDeclRefExpr *S) {
Douglas Gregor5c193b92009-07-28 00:33:38 +00001698 VisitExpr(S);
1699 VisitName(S->getDeclName());
1700 VisitNestedNameSpecifier(S->getQualifier());
John McCalle66edc12009-11-24 19:00:30 +00001701 ID.AddBoolean(S->hasExplicitTemplateArgs());
1702 if (S->hasExplicitTemplateArgs())
1703 VisitTemplateArguments(S->getTemplateArgs(), S->getNumTemplateArgs());
Douglas Gregor5c193b92009-07-28 00:33:38 +00001704}
1705
Chandler Carruth631abd92011-06-16 06:47:06 +00001706void StmtProfiler::VisitExprWithCleanups(const ExprWithCleanups *S) {
Douglas Gregora7095092009-07-28 14:44:31 +00001707 VisitExpr(S);
Douglas Gregora7095092009-07-28 14:44:31 +00001708}
1709
Chandler Carruth631abd92011-06-16 06:47:06 +00001710void StmtProfiler::VisitCXXUnresolvedConstructExpr(
1711 const CXXUnresolvedConstructExpr *S) {
Douglas Gregora7095092009-07-28 14:44:31 +00001712 VisitExpr(S);
1713 VisitType(S->getTypeAsWritten());
Richard Smith39eca9b2017-08-23 22:12:08 +00001714 ID.AddInteger(S->isListInitialization());
Douglas Gregora7095092009-07-28 14:44:31 +00001715}
1716
Chandler Carruth631abd92011-06-16 06:47:06 +00001717void StmtProfiler::VisitCXXDependentScopeMemberExpr(
1718 const CXXDependentScopeMemberExpr *S) {
John McCall2d74de92009-12-01 22:10:20 +00001719 ID.AddBoolean(S->isImplicitAccess());
1720 if (!S->isImplicitAccess()) {
1721 VisitExpr(S);
1722 ID.AddBoolean(S->isArrow());
1723 }
Douglas Gregorc26e0f62009-09-03 16:14:30 +00001724 VisitNestedNameSpecifier(S->getQualifier());
Douglas Gregora7095092009-07-28 14:44:31 +00001725 VisitName(S->getMember());
John McCall2d74de92009-12-01 22:10:20 +00001726 ID.AddBoolean(S->hasExplicitTemplateArgs());
1727 if (S->hasExplicitTemplateArgs())
John McCall10eae182009-11-30 22:42:35 +00001728 VisitTemplateArguments(S->getTemplateArgs(), S->getNumTemplateArgs());
1729}
1730
Chandler Carruth631abd92011-06-16 06:47:06 +00001731void StmtProfiler::VisitUnresolvedMemberExpr(const UnresolvedMemberExpr *S) {
John McCall2d74de92009-12-01 22:10:20 +00001732 ID.AddBoolean(S->isImplicitAccess());
1733 if (!S->isImplicitAccess()) {
1734 VisitExpr(S);
1735 ID.AddBoolean(S->isArrow());
1736 }
John McCall10eae182009-11-30 22:42:35 +00001737 VisitNestedNameSpecifier(S->getQualifier());
1738 VisitName(S->getMemberName());
1739 ID.AddBoolean(S->hasExplicitTemplateArgs());
1740 if (S->hasExplicitTemplateArgs())
1741 VisitTemplateArguments(S->getTemplateArgs(), S->getNumTemplateArgs());
Douglas Gregora7095092009-07-28 14:44:31 +00001742}
1743
Chandler Carruth631abd92011-06-16 06:47:06 +00001744void StmtProfiler::VisitCXXNoexceptExpr(const CXXNoexceptExpr *S) {
Sebastian Redl4202c0f2010-09-10 20:55:43 +00001745 VisitExpr(S);
1746}
1747
Chandler Carruth631abd92011-06-16 06:47:06 +00001748void StmtProfiler::VisitPackExpansionExpr(const PackExpansionExpr *S) {
Douglas Gregore8e9dd62011-01-03 17:17:50 +00001749 VisitExpr(S);
1750}
1751
Chandler Carruth631abd92011-06-16 06:47:06 +00001752void StmtProfiler::VisitSizeOfPackExpr(const SizeOfPackExpr *S) {
Douglas Gregor820ba7b2011-01-04 17:33:58 +00001753 VisitExpr(S);
1754 VisitDecl(S->getPack());
Richard Smithd784e682015-09-23 21:41:42 +00001755 if (S->isPartiallySubstituted()) {
1756 auto Args = S->getPartialArguments();
1757 ID.AddInteger(Args.size());
1758 for (const auto &TA : Args)
1759 VisitTemplateArgument(TA);
1760 } else {
1761 ID.AddInteger(0);
1762 }
Douglas Gregor820ba7b2011-01-04 17:33:58 +00001763}
1764
Douglas Gregorcdbc5392011-01-15 01:15:58 +00001765void StmtProfiler::VisitSubstNonTypeTemplateParmPackExpr(
Chandler Carruth631abd92011-06-16 06:47:06 +00001766 const SubstNonTypeTemplateParmPackExpr *S) {
Douglas Gregorcdbc5392011-01-15 01:15:58 +00001767 VisitExpr(S);
1768 VisitDecl(S->getParameterPack());
1769 VisitTemplateArgument(S->getArgumentPack());
1770}
1771
John McCall7c454bb2011-07-15 05:09:51 +00001772void StmtProfiler::VisitSubstNonTypeTemplateParmExpr(
1773 const SubstNonTypeTemplateParmExpr *E) {
1774 // Profile exactly as the replacement expression.
1775 Visit(E->getReplacement());
1776}
1777
Richard Smithb15fe3a2012-09-12 00:56:43 +00001778void StmtProfiler::VisitFunctionParmPackExpr(const FunctionParmPackExpr *S) {
1779 VisitExpr(S);
1780 VisitDecl(S->getParameterPack());
1781 ID.AddInteger(S->getNumExpansions());
1782 for (FunctionParmPackExpr::iterator I = S->begin(), E = S->end(); I != E; ++I)
1783 VisitDecl(*I);
1784}
1785
Douglas Gregorfe314812011-06-21 17:03:29 +00001786void StmtProfiler::VisitMaterializeTemporaryExpr(
1787 const MaterializeTemporaryExpr *S) {
1788 VisitExpr(S);
1789}
1790
Richard Smith0f0af192014-11-08 05:07:16 +00001791void StmtProfiler::VisitCXXFoldExpr(const CXXFoldExpr *S) {
1792 VisitExpr(S);
1793 ID.AddInteger(S->getOperator());
1794}
1795
Richard Smith9f690bd2015-10-27 06:02:45 +00001796void StmtProfiler::VisitCoroutineBodyStmt(const CoroutineBodyStmt *S) {
1797 VisitStmt(S);
1798}
1799
1800void StmtProfiler::VisitCoreturnStmt(const CoreturnStmt *S) {
1801 VisitStmt(S);
1802}
1803
1804void StmtProfiler::VisitCoawaitExpr(const CoawaitExpr *S) {
1805 VisitExpr(S);
1806}
1807
Eric Fiselier20f25cb2017-03-06 23:38:15 +00001808void StmtProfiler::VisitDependentCoawaitExpr(const DependentCoawaitExpr *S) {
1809 VisitExpr(S);
1810}
1811
Richard Smith9f690bd2015-10-27 06:02:45 +00001812void StmtProfiler::VisitCoyieldExpr(const CoyieldExpr *S) {
1813 VisitExpr(S);
1814}
1815
Chandler Carruth631abd92011-06-16 06:47:06 +00001816void StmtProfiler::VisitOpaqueValueExpr(const OpaqueValueExpr *E) {
John McCall8d69a212010-11-15 23:31:06 +00001817 VisitExpr(E);
1818}
1819
Kaelyn Takatae1f49d52014-10-27 18:07:20 +00001820void StmtProfiler::VisitTypoExpr(const TypoExpr *E) {
1821 VisitExpr(E);
1822}
1823
Chandler Carruth631abd92011-06-16 06:47:06 +00001824void StmtProfiler::VisitObjCStringLiteral(const ObjCStringLiteral *S) {
Douglas Gregora7095092009-07-28 14:44:31 +00001825 VisitExpr(S);
1826}
1827
Patrick Beard0caa3942012-04-19 00:25:12 +00001828void StmtProfiler::VisitObjCBoxedExpr(const ObjCBoxedExpr *E) {
Ted Kremeneke65b0862012-03-06 20:05:56 +00001829 VisitExpr(E);
1830}
1831
1832void StmtProfiler::VisitObjCArrayLiteral(const ObjCArrayLiteral *E) {
1833 VisitExpr(E);
1834}
1835
1836void StmtProfiler::VisitObjCDictionaryLiteral(const ObjCDictionaryLiteral *E) {
1837 VisitExpr(E);
1838}
1839
Chandler Carruth631abd92011-06-16 06:47:06 +00001840void StmtProfiler::VisitObjCEncodeExpr(const ObjCEncodeExpr *S) {
Douglas Gregora7095092009-07-28 14:44:31 +00001841 VisitExpr(S);
1842 VisitType(S->getEncodedType());
1843}
1844
Chandler Carruth631abd92011-06-16 06:47:06 +00001845void StmtProfiler::VisitObjCSelectorExpr(const ObjCSelectorExpr *S) {
Douglas Gregora7095092009-07-28 14:44:31 +00001846 VisitExpr(S);
1847 VisitName(S->getSelector());
1848}
1849
Chandler Carruth631abd92011-06-16 06:47:06 +00001850void StmtProfiler::VisitObjCProtocolExpr(const ObjCProtocolExpr *S) {
Douglas Gregora7095092009-07-28 14:44:31 +00001851 VisitExpr(S);
1852 VisitDecl(S->getProtocol());
1853}
1854
Chandler Carruth631abd92011-06-16 06:47:06 +00001855void StmtProfiler::VisitObjCIvarRefExpr(const ObjCIvarRefExpr *S) {
Douglas Gregora7095092009-07-28 14:44:31 +00001856 VisitExpr(S);
1857 VisitDecl(S->getDecl());
1858 ID.AddBoolean(S->isArrow());
1859 ID.AddBoolean(S->isFreeIvar());
1860}
1861
Chandler Carruth631abd92011-06-16 06:47:06 +00001862void StmtProfiler::VisitObjCPropertyRefExpr(const ObjCPropertyRefExpr *S) {
Douglas Gregora7095092009-07-28 14:44:31 +00001863 VisitExpr(S);
John McCallb7bd14f2010-12-02 01:19:52 +00001864 if (S->isImplicitProperty()) {
1865 VisitDecl(S->getImplicitPropertyGetter());
1866 VisitDecl(S->getImplicitPropertySetter());
1867 } else {
1868 VisitDecl(S->getExplicitProperty());
Fariborz Jahanian681c0752010-10-14 16:04:05 +00001869 }
Fariborz Jahanian681c0752010-10-14 16:04:05 +00001870 if (S->isSuperReceiver()) {
1871 ID.AddBoolean(S->isSuperReceiver());
John McCallb7bd14f2010-12-02 01:19:52 +00001872 VisitType(S->getSuperReceiverType());
Fariborz Jahanian681c0752010-10-14 16:04:05 +00001873 }
Douglas Gregora7095092009-07-28 14:44:31 +00001874}
1875
Ted Kremeneke65b0862012-03-06 20:05:56 +00001876void StmtProfiler::VisitObjCSubscriptRefExpr(const ObjCSubscriptRefExpr *S) {
1877 VisitExpr(S);
1878 VisitDecl(S->getAtIndexMethodDecl());
1879 VisitDecl(S->setAtIndexMethodDecl());
1880}
1881
Chandler Carruth631abd92011-06-16 06:47:06 +00001882void StmtProfiler::VisitObjCMessageExpr(const ObjCMessageExpr *S) {
Douglas Gregora7095092009-07-28 14:44:31 +00001883 VisitExpr(S);
1884 VisitName(S->getSelector());
1885 VisitDecl(S->getMethodDecl());
1886}
1887
Chandler Carruth631abd92011-06-16 06:47:06 +00001888void StmtProfiler::VisitObjCIsaExpr(const ObjCIsaExpr *S) {
Douglas Gregora7095092009-07-28 14:44:31 +00001889 VisitExpr(S);
1890 ID.AddBoolean(S->isArrow());
1891}
1892
Ted Kremeneke65b0862012-03-06 20:05:56 +00001893void StmtProfiler::VisitObjCBoolLiteralExpr(const ObjCBoolLiteralExpr *S) {
1894 VisitExpr(S);
1895 ID.AddBoolean(S->getValue());
1896}
1897
Chandler Carruth631abd92011-06-16 06:47:06 +00001898void StmtProfiler::VisitObjCIndirectCopyRestoreExpr(
1899 const ObjCIndirectCopyRestoreExpr *S) {
John McCall31168b02011-06-15 23:02:42 +00001900 VisitExpr(S);
1901 ID.AddBoolean(S->shouldCopy());
1902}
1903
Chandler Carruth631abd92011-06-16 06:47:06 +00001904void StmtProfiler::VisitObjCBridgedCastExpr(const ObjCBridgedCastExpr *S) {
John McCall31168b02011-06-15 23:02:42 +00001905 VisitExplicitCastExpr(S);
1906 ID.AddBoolean(S->getBridgeKind());
1907}
1908
Erik Pilkington29099de2016-07-16 00:35:23 +00001909void StmtProfiler::VisitObjCAvailabilityCheckExpr(
1910 const ObjCAvailabilityCheckExpr *S) {
1911 VisitExpr(S);
1912}
1913
John McCall0ad16662009-10-29 08:12:44 +00001914void StmtProfiler::VisitTemplateArguments(const TemplateArgumentLoc *Args,
Douglas Gregor5c193b92009-07-28 00:33:38 +00001915 unsigned NumArgs) {
1916 ID.AddInteger(NumArgs);
John McCall0ad16662009-10-29 08:12:44 +00001917 for (unsigned I = 0; I != NumArgs; ++I)
1918 VisitTemplateArgument(Args[I].getArgument());
1919}
Mike Stump11289f42009-09-09 15:08:12 +00001920
John McCall0ad16662009-10-29 08:12:44 +00001921void StmtProfiler::VisitTemplateArgument(const TemplateArgument &Arg) {
1922 // Mostly repetitive with TemplateArgument::Profile!
1923 ID.AddInteger(Arg.getKind());
1924 switch (Arg.getKind()) {
1925 case TemplateArgument::Null:
1926 break;
Mike Stump11289f42009-09-09 15:08:12 +00001927
John McCall0ad16662009-10-29 08:12:44 +00001928 case TemplateArgument::Type:
1929 VisitType(Arg.getAsType());
1930 break;
Mike Stump11289f42009-09-09 15:08:12 +00001931
Douglas Gregor9167f8b2009-11-11 01:00:40 +00001932 case TemplateArgument::Template:
Douglas Gregore4ff4b52011-01-05 18:58:31 +00001933 case TemplateArgument::TemplateExpansion:
1934 VisitTemplateName(Arg.getAsTemplateOrTemplatePattern());
Douglas Gregor9167f8b2009-11-11 01:00:40 +00001935 break;
Alexis Hunta8136cc2010-05-05 15:23:54 +00001936
John McCall0ad16662009-10-29 08:12:44 +00001937 case TemplateArgument::Declaration:
1938 VisitDecl(Arg.getAsDecl());
1939 break;
Mike Stump11289f42009-09-09 15:08:12 +00001940
Eli Friedmanb826a002012-09-26 02:36:12 +00001941 case TemplateArgument::NullPtr:
1942 VisitType(Arg.getNullPtrType());
1943 break;
1944
John McCall0ad16662009-10-29 08:12:44 +00001945 case TemplateArgument::Integral:
Benjamin Kramer6003ad52012-06-07 15:09:51 +00001946 Arg.getAsIntegral().Profile(ID);
John McCall0ad16662009-10-29 08:12:44 +00001947 VisitType(Arg.getIntegralType());
1948 break;
Mike Stump11289f42009-09-09 15:08:12 +00001949
John McCall0ad16662009-10-29 08:12:44 +00001950 case TemplateArgument::Expression:
1951 Visit(Arg.getAsExpr());
1952 break;
Mike Stump11289f42009-09-09 15:08:12 +00001953
John McCall0ad16662009-10-29 08:12:44 +00001954 case TemplateArgument::Pack:
Aaron Ballman2a89e852014-07-15 21:32:31 +00001955 for (const auto &P : Arg.pack_elements())
1956 VisitTemplateArgument(P);
John McCall0ad16662009-10-29 08:12:44 +00001957 break;
Douglas Gregor5c193b92009-07-28 00:33:38 +00001958 }
1959}
1960
Jay Foad39c79802011-01-12 09:06:06 +00001961void Stmt::Profile(llvm::FoldingSetNodeID &ID, const ASTContext &Context,
Chandler Carruth631abd92011-06-16 06:47:06 +00001962 bool Canonical) const {
Richard Trieu639d7b62017-02-22 22:22:42 +00001963 StmtProfilerWithPointers Profiler(ID, Context, Canonical);
1964 Profiler.Visit(this);
1965}
1966
1967void Stmt::ProcessODRHash(llvm::FoldingSetNodeID &ID,
1968 class ODRHash &Hash) const {
1969 StmtProfilerWithoutPointers Profiler(ID, Hash);
Douglas Gregor5c193b92009-07-28 00:33:38 +00001970 Profiler.Visit(this);
1971}