blob: 00ef0da18bbbf90cd0a8fb0ccd947cb9668b3c59 [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());
Douglas Gregorf5b160f2010-07-13 08:37:11 +0000969 if (!Canonical)
970 VisitTemplateArguments(S->getTemplateArgs(), S->getNumTemplateArgs());
Douglas Gregor5c193b92009-07-28 00:33:38 +0000971}
972
Chandler Carruth631abd92011-06-16 06:47:06 +0000973void StmtProfiler::VisitPredefinedExpr(const PredefinedExpr *S) {
Douglas Gregor5c193b92009-07-28 00:33:38 +0000974 VisitExpr(S);
975 ID.AddInteger(S->getIdentType());
976}
977
Chandler Carruth631abd92011-06-16 06:47:06 +0000978void StmtProfiler::VisitIntegerLiteral(const IntegerLiteral *S) {
Douglas Gregor5c193b92009-07-28 00:33:38 +0000979 VisitExpr(S);
980 S->getValue().Profile(ID);
Richard Smithe9f130c2014-11-20 03:37:32 +0000981 ID.AddInteger(S->getType()->castAs<BuiltinType>()->getKind());
Douglas Gregor5c193b92009-07-28 00:33:38 +0000982}
983
Chandler Carruth631abd92011-06-16 06:47:06 +0000984void StmtProfiler::VisitCharacterLiteral(const CharacterLiteral *S) {
Douglas Gregor5c193b92009-07-28 00:33:38 +0000985 VisitExpr(S);
Douglas Gregorfb65e592011-07-27 05:40:30 +0000986 ID.AddInteger(S->getKind());
Douglas Gregor5c193b92009-07-28 00:33:38 +0000987 ID.AddInteger(S->getValue());
988}
989
Chandler Carruth631abd92011-06-16 06:47:06 +0000990void StmtProfiler::VisitFloatingLiteral(const FloatingLiteral *S) {
Douglas Gregor5c193b92009-07-28 00:33:38 +0000991 VisitExpr(S);
992 S->getValue().Profile(ID);
993 ID.AddBoolean(S->isExact());
Richard Smithe9f130c2014-11-20 03:37:32 +0000994 ID.AddInteger(S->getType()->castAs<BuiltinType>()->getKind());
Douglas Gregor5c193b92009-07-28 00:33:38 +0000995}
996
Chandler Carruth631abd92011-06-16 06:47:06 +0000997void StmtProfiler::VisitImaginaryLiteral(const ImaginaryLiteral *S) {
Douglas Gregor5c193b92009-07-28 00:33:38 +0000998 VisitExpr(S);
999}
1000
Chandler Carruth631abd92011-06-16 06:47:06 +00001001void StmtProfiler::VisitStringLiteral(const StringLiteral *S) {
Douglas Gregor5c193b92009-07-28 00:33:38 +00001002 VisitExpr(S);
Douglas Gregor9d0eb8f2011-11-02 17:26:05 +00001003 ID.AddString(S->getBytes());
Douglas Gregorfb65e592011-07-27 05:40:30 +00001004 ID.AddInteger(S->getKind());
Douglas Gregor5c193b92009-07-28 00:33:38 +00001005}
1006
Chandler Carruth631abd92011-06-16 06:47:06 +00001007void StmtProfiler::VisitParenExpr(const ParenExpr *S) {
Douglas Gregor5c193b92009-07-28 00:33:38 +00001008 VisitExpr(S);
1009}
1010
Chandler Carruth631abd92011-06-16 06:47:06 +00001011void StmtProfiler::VisitParenListExpr(const ParenListExpr *S) {
Nate Begeman5ec4b312009-08-10 23:49:36 +00001012 VisitExpr(S);
1013}
1014
Chandler Carruth631abd92011-06-16 06:47:06 +00001015void StmtProfiler::VisitUnaryOperator(const UnaryOperator *S) {
Douglas Gregor5c193b92009-07-28 00:33:38 +00001016 VisitExpr(S);
1017 ID.AddInteger(S->getOpcode());
1018}
1019
Chandler Carruth631abd92011-06-16 06:47:06 +00001020void StmtProfiler::VisitOffsetOfExpr(const OffsetOfExpr *S) {
Douglas Gregor882211c2010-04-28 22:16:22 +00001021 VisitType(S->getTypeSourceInfo()->getType());
1022 unsigned n = S->getNumComponents();
1023 for (unsigned i = 0; i < n; ++i) {
James Y Knight7281c352015-12-29 22:31:18 +00001024 const OffsetOfNode &ON = S->getComponent(i);
Douglas Gregor882211c2010-04-28 22:16:22 +00001025 ID.AddInteger(ON.getKind());
1026 switch (ON.getKind()) {
James Y Knight7281c352015-12-29 22:31:18 +00001027 case OffsetOfNode::Array:
Douglas Gregor882211c2010-04-28 22:16:22 +00001028 // Expressions handled below.
1029 break;
1030
James Y Knight7281c352015-12-29 22:31:18 +00001031 case OffsetOfNode::Field:
Douglas Gregor882211c2010-04-28 22:16:22 +00001032 VisitDecl(ON.getField());
1033 break;
1034
James Y Knight7281c352015-12-29 22:31:18 +00001035 case OffsetOfNode::Identifier:
Richard Trieu639d7b62017-02-22 22:22:42 +00001036 VisitIdentifierInfo(ON.getFieldName());
Douglas Gregor882211c2010-04-28 22:16:22 +00001037 break;
James Y Knight7281c352015-12-29 22:31:18 +00001038
1039 case OffsetOfNode::Base:
Douglas Gregord1702062010-04-29 00:18:15 +00001040 // These nodes are implicit, and therefore don't need profiling.
1041 break;
Douglas Gregor882211c2010-04-28 22:16:22 +00001042 }
1043 }
Richard Trieu639d7b62017-02-22 22:22:42 +00001044
Douglas Gregor882211c2010-04-28 22:16:22 +00001045 VisitExpr(S);
1046}
1047
Chandler Carruth631abd92011-06-16 06:47:06 +00001048void
1049StmtProfiler::VisitUnaryExprOrTypeTraitExpr(const UnaryExprOrTypeTraitExpr *S) {
Douglas Gregor5c193b92009-07-28 00:33:38 +00001050 VisitExpr(S);
Peter Collingbournee190dee2011-03-11 19:24:49 +00001051 ID.AddInteger(S->getKind());
Douglas Gregor5c193b92009-07-28 00:33:38 +00001052 if (S->isArgumentType())
1053 VisitType(S->getArgumentType());
1054}
1055
Chandler Carruth631abd92011-06-16 06:47:06 +00001056void StmtProfiler::VisitArraySubscriptExpr(const ArraySubscriptExpr *S) {
Douglas Gregor5c193b92009-07-28 00:33:38 +00001057 VisitExpr(S);
1058}
1059
Alexey Bataev1a3320e2015-08-25 14:24:04 +00001060void StmtProfiler::VisitOMPArraySectionExpr(const OMPArraySectionExpr *S) {
1061 VisitExpr(S);
1062}
1063
Chandler Carruth631abd92011-06-16 06:47:06 +00001064void StmtProfiler::VisitCallExpr(const CallExpr *S) {
Douglas Gregor5c193b92009-07-28 00:33:38 +00001065 VisitExpr(S);
1066}
1067
Chandler Carruth631abd92011-06-16 06:47:06 +00001068void StmtProfiler::VisitMemberExpr(const MemberExpr *S) {
Douglas Gregor5c193b92009-07-28 00:33:38 +00001069 VisitExpr(S);
1070 VisitDecl(S->getMemberDecl());
Douglas Gregorf5b160f2010-07-13 08:37:11 +00001071 if (!Canonical)
1072 VisitNestedNameSpecifier(S->getQualifier());
Douglas Gregor5c193b92009-07-28 00:33:38 +00001073 ID.AddBoolean(S->isArrow());
1074}
1075
Chandler Carruth631abd92011-06-16 06:47:06 +00001076void StmtProfiler::VisitCompoundLiteralExpr(const CompoundLiteralExpr *S) {
Douglas Gregor5c193b92009-07-28 00:33:38 +00001077 VisitExpr(S);
1078 ID.AddBoolean(S->isFileScope());
1079}
1080
Chandler Carruth631abd92011-06-16 06:47:06 +00001081void StmtProfiler::VisitCastExpr(const CastExpr *S) {
Douglas Gregor5c193b92009-07-28 00:33:38 +00001082 VisitExpr(S);
1083}
1084
Chandler Carruth631abd92011-06-16 06:47:06 +00001085void StmtProfiler::VisitImplicitCastExpr(const ImplicitCastExpr *S) {
Douglas Gregor5c193b92009-07-28 00:33:38 +00001086 VisitCastExpr(S);
John McCall2536c6d2010-08-25 10:28:54 +00001087 ID.AddInteger(S->getValueKind());
Douglas Gregor5c193b92009-07-28 00:33:38 +00001088}
1089
Chandler Carruth631abd92011-06-16 06:47:06 +00001090void StmtProfiler::VisitExplicitCastExpr(const ExplicitCastExpr *S) {
Douglas Gregor5c193b92009-07-28 00:33:38 +00001091 VisitCastExpr(S);
1092 VisitType(S->getTypeAsWritten());
1093}
1094
Chandler Carruth631abd92011-06-16 06:47:06 +00001095void StmtProfiler::VisitCStyleCastExpr(const CStyleCastExpr *S) {
Douglas Gregor5c193b92009-07-28 00:33:38 +00001096 VisitExplicitCastExpr(S);
1097}
1098
Chandler Carruth631abd92011-06-16 06:47:06 +00001099void StmtProfiler::VisitBinaryOperator(const BinaryOperator *S) {
Douglas Gregor5c193b92009-07-28 00:33:38 +00001100 VisitExpr(S);
1101 ID.AddInteger(S->getOpcode());
1102}
1103
Chandler Carruth631abd92011-06-16 06:47:06 +00001104void
1105StmtProfiler::VisitCompoundAssignOperator(const CompoundAssignOperator *S) {
Douglas Gregor5c193b92009-07-28 00:33:38 +00001106 VisitBinaryOperator(S);
1107}
1108
Chandler Carruth631abd92011-06-16 06:47:06 +00001109void StmtProfiler::VisitConditionalOperator(const ConditionalOperator *S) {
Douglas Gregor5c193b92009-07-28 00:33:38 +00001110 VisitExpr(S);
1111}
1112
Chandler Carruth631abd92011-06-16 06:47:06 +00001113void StmtProfiler::VisitBinaryConditionalOperator(
Chandler Carruthcf5f43c2011-06-21 23:26:32 +00001114 const BinaryConditionalOperator *S) {
John McCallc07a0c72011-02-17 10:25:35 +00001115 VisitExpr(S);
1116}
1117
Chandler Carruth631abd92011-06-16 06:47:06 +00001118void StmtProfiler::VisitAddrLabelExpr(const AddrLabelExpr *S) {
Douglas Gregor5c193b92009-07-28 00:33:38 +00001119 VisitExpr(S);
Chris Lattnerc8e630e2011-02-17 07:39:24 +00001120 VisitDecl(S->getLabel());
Douglas Gregor5c193b92009-07-28 00:33:38 +00001121}
1122
Chandler Carruth631abd92011-06-16 06:47:06 +00001123void StmtProfiler::VisitStmtExpr(const StmtExpr *S) {
Douglas Gregor5c193b92009-07-28 00:33:38 +00001124 VisitExpr(S);
1125}
1126
Chandler Carruth631abd92011-06-16 06:47:06 +00001127void StmtProfiler::VisitShuffleVectorExpr(const ShuffleVectorExpr *S) {
Douglas Gregor5c193b92009-07-28 00:33:38 +00001128 VisitExpr(S);
1129}
1130
Hal Finkelc4d7c822013-09-18 03:29:45 +00001131void StmtProfiler::VisitConvertVectorExpr(const ConvertVectorExpr *S) {
1132 VisitExpr(S);
1133}
1134
Chandler Carruth631abd92011-06-16 06:47:06 +00001135void StmtProfiler::VisitChooseExpr(const ChooseExpr *S) {
Douglas Gregor5c193b92009-07-28 00:33:38 +00001136 VisitExpr(S);
1137}
1138
Chandler Carruth631abd92011-06-16 06:47:06 +00001139void StmtProfiler::VisitGNUNullExpr(const GNUNullExpr *S) {
Douglas Gregor5c193b92009-07-28 00:33:38 +00001140 VisitExpr(S);
1141}
1142
Chandler Carruth631abd92011-06-16 06:47:06 +00001143void StmtProfiler::VisitVAArgExpr(const VAArgExpr *S) {
Douglas Gregor00044172009-07-29 16:09:57 +00001144 VisitExpr(S);
1145}
1146
Chandler Carruth631abd92011-06-16 06:47:06 +00001147void StmtProfiler::VisitInitListExpr(const InitListExpr *S) {
Douglas Gregor5c193b92009-07-28 00:33:38 +00001148 if (S->getSyntacticForm()) {
1149 VisitInitListExpr(S->getSyntacticForm());
1150 return;
1151 }
Mike Stump11289f42009-09-09 15:08:12 +00001152
Douglas Gregor5c193b92009-07-28 00:33:38 +00001153 VisitExpr(S);
1154}
1155
Chandler Carruth631abd92011-06-16 06:47:06 +00001156void StmtProfiler::VisitDesignatedInitExpr(const DesignatedInitExpr *S) {
Douglas Gregor5c193b92009-07-28 00:33:38 +00001157 VisitExpr(S);
1158 ID.AddBoolean(S->usesGNUSyntax());
David Majnemerf7e36092016-06-23 00:15:04 +00001159 for (const DesignatedInitExpr::Designator &D : S->designators()) {
1160 if (D.isFieldDesignator()) {
Douglas Gregor5c193b92009-07-28 00:33:38 +00001161 ID.AddInteger(0);
David Majnemerf7e36092016-06-23 00:15:04 +00001162 VisitName(D.getFieldName());
Douglas Gregor5c193b92009-07-28 00:33:38 +00001163 continue;
1164 }
Mike Stump11289f42009-09-09 15:08:12 +00001165
David Majnemerf7e36092016-06-23 00:15:04 +00001166 if (D.isArrayDesignator()) {
Douglas Gregor5c193b92009-07-28 00:33:38 +00001167 ID.AddInteger(1);
1168 } else {
David Majnemerf7e36092016-06-23 00:15:04 +00001169 assert(D.isArrayRangeDesignator());
Douglas Gregor5c193b92009-07-28 00:33:38 +00001170 ID.AddInteger(2);
1171 }
David Majnemerf7e36092016-06-23 00:15:04 +00001172 ID.AddInteger(D.getFirstExprIndex());
Douglas Gregor5c193b92009-07-28 00:33:38 +00001173 }
1174}
1175
Yunzhong Gaocb779302015-06-10 00:27:52 +00001176// Seems that if VisitInitListExpr() only works on the syntactic form of an
1177// InitListExpr, then a DesignatedInitUpdateExpr is not encountered.
1178void StmtProfiler::VisitDesignatedInitUpdateExpr(
1179 const DesignatedInitUpdateExpr *S) {
1180 llvm_unreachable("Unexpected DesignatedInitUpdateExpr in syntactic form of "
1181 "initializer");
1182}
1183
Richard Smith410306b2016-12-12 02:53:20 +00001184void StmtProfiler::VisitArrayInitLoopExpr(const ArrayInitLoopExpr *S) {
1185 VisitExpr(S);
1186}
1187
1188void StmtProfiler::VisitArrayInitIndexExpr(const ArrayInitIndexExpr *S) {
1189 VisitExpr(S);
1190}
1191
Yunzhong Gaocb779302015-06-10 00:27:52 +00001192void StmtProfiler::VisitNoInitExpr(const NoInitExpr *S) {
1193 llvm_unreachable("Unexpected NoInitExpr in syntactic form of initializer");
1194}
1195
Chandler Carruth631abd92011-06-16 06:47:06 +00001196void StmtProfiler::VisitImplicitValueInitExpr(const ImplicitValueInitExpr *S) {
Douglas Gregor5c193b92009-07-28 00:33:38 +00001197 VisitExpr(S);
1198}
1199
Chandler Carruth631abd92011-06-16 06:47:06 +00001200void StmtProfiler::VisitExtVectorElementExpr(const ExtVectorElementExpr *S) {
Douglas Gregor5c193b92009-07-28 00:33:38 +00001201 VisitExpr(S);
1202 VisitName(&S->getAccessor());
1203}
1204
Chandler Carruth631abd92011-06-16 06:47:06 +00001205void StmtProfiler::VisitBlockExpr(const BlockExpr *S) {
Douglas Gregor5c193b92009-07-28 00:33:38 +00001206 VisitExpr(S);
1207 VisitDecl(S->getBlockDecl());
1208}
1209
Chandler Carruth631abd92011-06-16 06:47:06 +00001210void StmtProfiler::VisitGenericSelectionExpr(const GenericSelectionExpr *S) {
Peter Collingbourne91147592011-04-15 00:35:48 +00001211 VisitExpr(S);
1212 for (unsigned i = 0; i != S->getNumAssocs(); ++i) {
1213 QualType T = S->getAssocType(i);
1214 if (T.isNull())
Craig Topper36250ad2014-05-12 05:36:57 +00001215 ID.AddPointer(nullptr);
Peter Collingbourne91147592011-04-15 00:35:48 +00001216 else
1217 VisitType(T);
1218 VisitExpr(S->getAssocExpr(i));
1219 }
1220}
1221
John McCallfe96e0b2011-11-06 09:01:30 +00001222void StmtProfiler::VisitPseudoObjectExpr(const PseudoObjectExpr *S) {
1223 VisitExpr(S);
1224 for (PseudoObjectExpr::const_semantics_iterator
1225 i = S->semantics_begin(), e = S->semantics_end(); i != e; ++i)
1226 // Normally, we would not profile the source expressions of OVEs.
1227 if (const OpaqueValueExpr *OVE = dyn_cast<OpaqueValueExpr>(*i))
1228 Visit(OVE->getSourceExpr());
1229}
1230
Eli Friedmandf14b3a2011-10-11 02:20:01 +00001231void StmtProfiler::VisitAtomicExpr(const AtomicExpr *S) {
1232 VisitExpr(S);
Eli Friedman4b72fdd2011-10-14 20:59:01 +00001233 ID.AddInteger(S->getOp());
Eli Friedmandf14b3a2011-10-11 02:20:01 +00001234}
1235
Chandler Carruth631abd92011-06-16 06:47:06 +00001236static Stmt::StmtClass DecodeOperatorCall(const CXXOperatorCallExpr *S,
John McCalle3027922010-08-25 11:45:40 +00001237 UnaryOperatorKind &UnaryOp,
1238 BinaryOperatorKind &BinaryOp) {
Douglas Gregore9ceb312010-05-19 04:13:23 +00001239 switch (S->getOperator()) {
1240 case OO_None:
1241 case OO_New:
1242 case OO_Delete:
1243 case OO_Array_New:
1244 case OO_Array_Delete:
1245 case OO_Arrow:
1246 case OO_Call:
1247 case OO_Conditional:
Richard Smith9be594e2015-10-22 05:12:22 +00001248 case OO_Coawait:
Douglas Gregore9ceb312010-05-19 04:13:23 +00001249 case NUM_OVERLOADED_OPERATORS:
1250 llvm_unreachable("Invalid operator call kind");
Douglas Gregore9ceb312010-05-19 04:13:23 +00001251
1252 case OO_Plus:
1253 if (S->getNumArgs() == 1) {
John McCalle3027922010-08-25 11:45:40 +00001254 UnaryOp = UO_Plus;
Douglas Gregore9ceb312010-05-19 04:13:23 +00001255 return Stmt::UnaryOperatorClass;
1256 }
1257
John McCalle3027922010-08-25 11:45:40 +00001258 BinaryOp = BO_Add;
Douglas Gregore9ceb312010-05-19 04:13:23 +00001259 return Stmt::BinaryOperatorClass;
1260
1261 case OO_Minus:
1262 if (S->getNumArgs() == 1) {
John McCalle3027922010-08-25 11:45:40 +00001263 UnaryOp = UO_Minus;
Douglas Gregore9ceb312010-05-19 04:13:23 +00001264 return Stmt::UnaryOperatorClass;
1265 }
1266
John McCalle3027922010-08-25 11:45:40 +00001267 BinaryOp = BO_Sub;
Douglas Gregore9ceb312010-05-19 04:13:23 +00001268 return Stmt::BinaryOperatorClass;
1269
1270 case OO_Star:
1271 if (S->getNumArgs() == 1) {
Richard Smithf15acc52014-06-05 22:43:40 +00001272 UnaryOp = UO_Deref;
Douglas Gregore9ceb312010-05-19 04:13:23 +00001273 return Stmt::UnaryOperatorClass;
1274 }
1275
Richard Smithf15acc52014-06-05 22:43:40 +00001276 BinaryOp = BO_Mul;
Douglas Gregore9ceb312010-05-19 04:13:23 +00001277 return Stmt::BinaryOperatorClass;
1278
1279 case OO_Slash:
John McCalle3027922010-08-25 11:45:40 +00001280 BinaryOp = BO_Div;
Douglas Gregore9ceb312010-05-19 04:13:23 +00001281 return Stmt::BinaryOperatorClass;
1282
1283 case OO_Percent:
John McCalle3027922010-08-25 11:45:40 +00001284 BinaryOp = BO_Rem;
Douglas Gregore9ceb312010-05-19 04:13:23 +00001285 return Stmt::BinaryOperatorClass;
1286
1287 case OO_Caret:
John McCalle3027922010-08-25 11:45:40 +00001288 BinaryOp = BO_Xor;
Douglas Gregore9ceb312010-05-19 04:13:23 +00001289 return Stmt::BinaryOperatorClass;
1290
1291 case OO_Amp:
1292 if (S->getNumArgs() == 1) {
John McCalle3027922010-08-25 11:45:40 +00001293 UnaryOp = UO_AddrOf;
Douglas Gregore9ceb312010-05-19 04:13:23 +00001294 return Stmt::UnaryOperatorClass;
1295 }
1296
John McCalle3027922010-08-25 11:45:40 +00001297 BinaryOp = BO_And;
Douglas Gregore9ceb312010-05-19 04:13:23 +00001298 return Stmt::BinaryOperatorClass;
1299
1300 case OO_Pipe:
John McCalle3027922010-08-25 11:45:40 +00001301 BinaryOp = BO_Or;
Douglas Gregore9ceb312010-05-19 04:13:23 +00001302 return Stmt::BinaryOperatorClass;
1303
1304 case OO_Tilde:
John McCalle3027922010-08-25 11:45:40 +00001305 UnaryOp = UO_Not;
Douglas Gregore9ceb312010-05-19 04:13:23 +00001306 return Stmt::UnaryOperatorClass;
1307
1308 case OO_Exclaim:
John McCalle3027922010-08-25 11:45:40 +00001309 UnaryOp = UO_LNot;
Douglas Gregore9ceb312010-05-19 04:13:23 +00001310 return Stmt::UnaryOperatorClass;
1311
1312 case OO_Equal:
John McCalle3027922010-08-25 11:45:40 +00001313 BinaryOp = BO_Assign;
Douglas Gregore9ceb312010-05-19 04:13:23 +00001314 return Stmt::BinaryOperatorClass;
1315
1316 case OO_Less:
John McCalle3027922010-08-25 11:45:40 +00001317 BinaryOp = BO_LT;
Douglas Gregore9ceb312010-05-19 04:13:23 +00001318 return Stmt::BinaryOperatorClass;
1319
1320 case OO_Greater:
John McCalle3027922010-08-25 11:45:40 +00001321 BinaryOp = BO_GT;
Douglas Gregore9ceb312010-05-19 04:13:23 +00001322 return Stmt::BinaryOperatorClass;
1323
1324 case OO_PlusEqual:
John McCalle3027922010-08-25 11:45:40 +00001325 BinaryOp = BO_AddAssign;
Douglas Gregore9ceb312010-05-19 04:13:23 +00001326 return Stmt::CompoundAssignOperatorClass;
1327
1328 case OO_MinusEqual:
John McCalle3027922010-08-25 11:45:40 +00001329 BinaryOp = BO_SubAssign;
Douglas Gregore9ceb312010-05-19 04:13:23 +00001330 return Stmt::CompoundAssignOperatorClass;
1331
1332 case OO_StarEqual:
John McCalle3027922010-08-25 11:45:40 +00001333 BinaryOp = BO_MulAssign;
Douglas Gregore9ceb312010-05-19 04:13:23 +00001334 return Stmt::CompoundAssignOperatorClass;
1335
1336 case OO_SlashEqual:
John McCalle3027922010-08-25 11:45:40 +00001337 BinaryOp = BO_DivAssign;
Douglas Gregore9ceb312010-05-19 04:13:23 +00001338 return Stmt::CompoundAssignOperatorClass;
1339
1340 case OO_PercentEqual:
John McCalle3027922010-08-25 11:45:40 +00001341 BinaryOp = BO_RemAssign;
Douglas Gregore9ceb312010-05-19 04:13:23 +00001342 return Stmt::CompoundAssignOperatorClass;
1343
1344 case OO_CaretEqual:
John McCalle3027922010-08-25 11:45:40 +00001345 BinaryOp = BO_XorAssign;
Douglas Gregore9ceb312010-05-19 04:13:23 +00001346 return Stmt::CompoundAssignOperatorClass;
1347
1348 case OO_AmpEqual:
John McCalle3027922010-08-25 11:45:40 +00001349 BinaryOp = BO_AndAssign;
Douglas Gregore9ceb312010-05-19 04:13:23 +00001350 return Stmt::CompoundAssignOperatorClass;
1351
1352 case OO_PipeEqual:
John McCalle3027922010-08-25 11:45:40 +00001353 BinaryOp = BO_OrAssign;
Douglas Gregore9ceb312010-05-19 04:13:23 +00001354 return Stmt::CompoundAssignOperatorClass;
1355
1356 case OO_LessLess:
John McCalle3027922010-08-25 11:45:40 +00001357 BinaryOp = BO_Shl;
Douglas Gregore9ceb312010-05-19 04:13:23 +00001358 return Stmt::BinaryOperatorClass;
1359
1360 case OO_GreaterGreater:
John McCalle3027922010-08-25 11:45:40 +00001361 BinaryOp = BO_Shr;
Douglas Gregore9ceb312010-05-19 04:13:23 +00001362 return Stmt::BinaryOperatorClass;
1363
1364 case OO_LessLessEqual:
John McCalle3027922010-08-25 11:45:40 +00001365 BinaryOp = BO_ShlAssign;
Douglas Gregore9ceb312010-05-19 04:13:23 +00001366 return Stmt::CompoundAssignOperatorClass;
1367
1368 case OO_GreaterGreaterEqual:
John McCalle3027922010-08-25 11:45:40 +00001369 BinaryOp = BO_ShrAssign;
Douglas Gregore9ceb312010-05-19 04:13:23 +00001370 return Stmt::CompoundAssignOperatorClass;
1371
1372 case OO_EqualEqual:
John McCalle3027922010-08-25 11:45:40 +00001373 BinaryOp = BO_EQ;
Douglas Gregore9ceb312010-05-19 04:13:23 +00001374 return Stmt::BinaryOperatorClass;
1375
1376 case OO_ExclaimEqual:
John McCalle3027922010-08-25 11:45:40 +00001377 BinaryOp = BO_NE;
Douglas Gregore9ceb312010-05-19 04:13:23 +00001378 return Stmt::BinaryOperatorClass;
1379
1380 case OO_LessEqual:
John McCalle3027922010-08-25 11:45:40 +00001381 BinaryOp = BO_LE;
Douglas Gregore9ceb312010-05-19 04:13:23 +00001382 return Stmt::BinaryOperatorClass;
1383
1384 case OO_GreaterEqual:
John McCalle3027922010-08-25 11:45:40 +00001385 BinaryOp = BO_GE;
Douglas Gregore9ceb312010-05-19 04:13:23 +00001386 return Stmt::BinaryOperatorClass;
Richard Smithd30b23d2017-12-01 02:13:10 +00001387
1388 case OO_Spaceship:
1389 // FIXME: Update this once we support <=> expressions.
1390 llvm_unreachable("<=> expressions not supported yet");
Douglas Gregore9ceb312010-05-19 04:13:23 +00001391
1392 case OO_AmpAmp:
John McCalle3027922010-08-25 11:45:40 +00001393 BinaryOp = BO_LAnd;
Douglas Gregore9ceb312010-05-19 04:13:23 +00001394 return Stmt::BinaryOperatorClass;
1395
1396 case OO_PipePipe:
John McCalle3027922010-08-25 11:45:40 +00001397 BinaryOp = BO_LOr;
Douglas Gregore9ceb312010-05-19 04:13:23 +00001398 return Stmt::BinaryOperatorClass;
1399
1400 case OO_PlusPlus:
John McCalle3027922010-08-25 11:45:40 +00001401 UnaryOp = S->getNumArgs() == 1? UO_PreInc
1402 : UO_PostInc;
Douglas Gregore9ceb312010-05-19 04:13:23 +00001403 return Stmt::UnaryOperatorClass;
1404
1405 case OO_MinusMinus:
John McCalle3027922010-08-25 11:45:40 +00001406 UnaryOp = S->getNumArgs() == 1? UO_PreDec
1407 : UO_PostDec;
Douglas Gregore9ceb312010-05-19 04:13:23 +00001408 return Stmt::UnaryOperatorClass;
1409
1410 case OO_Comma:
John McCalle3027922010-08-25 11:45:40 +00001411 BinaryOp = BO_Comma;
Douglas Gregore9ceb312010-05-19 04:13:23 +00001412 return Stmt::BinaryOperatorClass;
1413
Douglas Gregore9ceb312010-05-19 04:13:23 +00001414 case OO_ArrowStar:
John McCalle3027922010-08-25 11:45:40 +00001415 BinaryOp = BO_PtrMemI;
Douglas Gregore9ceb312010-05-19 04:13:23 +00001416 return Stmt::BinaryOperatorClass;
1417
1418 case OO_Subscript:
1419 return Stmt::ArraySubscriptExprClass;
1420 }
1421
1422 llvm_unreachable("Invalid overloaded operator expression");
1423}
Richard Smithf15acc52014-06-05 22:43:40 +00001424
Reid Klecknere257e182017-10-13 16:18:32 +00001425#if defined(_MSC_VER) && !defined(__clang__)
Nico Weberf56f4462017-07-24 16:54:11 +00001426#if _MSC_VER == 1911
1427// Work around https://developercommunity.visualstudio.com/content/problem/84002/clang-cl-when-built-with-vc-2017-crashes-cause-vc.html
1428// MSVC 2017 update 3 miscompiles this function, and a clang built with it
1429// will crash in stage 2 of a bootstrap build.
1430#pragma optimize("", off)
1431#endif
1432#endif
1433
Chandler Carruth631abd92011-06-16 06:47:06 +00001434void StmtProfiler::VisitCXXOperatorCallExpr(const CXXOperatorCallExpr *S) {
Douglas Gregore9ceb312010-05-19 04:13:23 +00001435 if (S->isTypeDependent()) {
1436 // Type-dependent operator calls are profiled like their underlying
1437 // syntactic operator.
Richard Smithbac0a0d2016-10-24 18:47:04 +00001438 //
1439 // An operator call to operator-> is always implicit, so just skip it. The
1440 // enclosing MemberExpr will profile the actual member access.
1441 if (S->getOperator() == OO_Arrow)
1442 return Visit(S->getArg(0));
1443
John McCalle3027922010-08-25 11:45:40 +00001444 UnaryOperatorKind UnaryOp = UO_Extension;
1445 BinaryOperatorKind BinaryOp = BO_Comma;
Douglas Gregore9ceb312010-05-19 04:13:23 +00001446 Stmt::StmtClass SC = DecodeOperatorCall(S, UnaryOp, BinaryOp);
Richard Smithf15acc52014-06-05 22:43:40 +00001447
Douglas Gregore9ceb312010-05-19 04:13:23 +00001448 ID.AddInteger(SC);
1449 for (unsigned I = 0, N = S->getNumArgs(); I != N; ++I)
1450 Visit(S->getArg(I));
1451 if (SC == Stmt::UnaryOperatorClass)
1452 ID.AddInteger(UnaryOp);
1453 else if (SC == Stmt::BinaryOperatorClass ||
1454 SC == Stmt::CompoundAssignOperatorClass)
1455 ID.AddInteger(BinaryOp);
1456 else
1457 assert(SC == Stmt::ArraySubscriptExprClass);
Richard Smithf15acc52014-06-05 22:43:40 +00001458
Douglas Gregore9ceb312010-05-19 04:13:23 +00001459 return;
1460 }
Richard Smithf15acc52014-06-05 22:43:40 +00001461
Douglas Gregor5c193b92009-07-28 00:33:38 +00001462 VisitCallExpr(S);
1463 ID.AddInteger(S->getOperator());
1464}
1465
Reid Klecknere257e182017-10-13 16:18:32 +00001466#if defined(_MSC_VER) && !defined(__clang__)
Nico Weberf56f4462017-07-24 16:54:11 +00001467#if _MSC_VER == 1911
1468#pragma optimize("", on)
1469#endif
1470#endif
1471
Chandler Carruth631abd92011-06-16 06:47:06 +00001472void StmtProfiler::VisitCXXMemberCallExpr(const CXXMemberCallExpr *S) {
Douglas Gregor5c193b92009-07-28 00:33:38 +00001473 VisitCallExpr(S);
1474}
1475
Chandler Carruth631abd92011-06-16 06:47:06 +00001476void StmtProfiler::VisitCUDAKernelCallExpr(const CUDAKernelCallExpr *S) {
Peter Collingbourne41f85462011-02-09 21:07:24 +00001477 VisitCallExpr(S);
1478}
1479
Chandler Carruth631abd92011-06-16 06:47:06 +00001480void StmtProfiler::VisitAsTypeExpr(const AsTypeExpr *S) {
Tanya Lattner55808c12011-06-04 00:47:47 +00001481 VisitExpr(S);
1482}
1483
Chandler Carruth631abd92011-06-16 06:47:06 +00001484void StmtProfiler::VisitCXXNamedCastExpr(const CXXNamedCastExpr *S) {
Douglas Gregor5c193b92009-07-28 00:33:38 +00001485 VisitExplicitCastExpr(S);
1486}
1487
Chandler Carruth631abd92011-06-16 06:47:06 +00001488void StmtProfiler::VisitCXXStaticCastExpr(const CXXStaticCastExpr *S) {
Douglas Gregor5c193b92009-07-28 00:33:38 +00001489 VisitCXXNamedCastExpr(S);
1490}
1491
Chandler Carruth631abd92011-06-16 06:47:06 +00001492void StmtProfiler::VisitCXXDynamicCastExpr(const CXXDynamicCastExpr *S) {
Douglas Gregor5c193b92009-07-28 00:33:38 +00001493 VisitCXXNamedCastExpr(S);
1494}
1495
Chandler Carruth631abd92011-06-16 06:47:06 +00001496void
1497StmtProfiler::VisitCXXReinterpretCastExpr(const CXXReinterpretCastExpr *S) {
Douglas Gregor5c193b92009-07-28 00:33:38 +00001498 VisitCXXNamedCastExpr(S);
1499}
1500
Chandler Carruth631abd92011-06-16 06:47:06 +00001501void StmtProfiler::VisitCXXConstCastExpr(const CXXConstCastExpr *S) {
Douglas Gregor5c193b92009-07-28 00:33:38 +00001502 VisitCXXNamedCastExpr(S);
1503}
1504
Richard Smithc67fdd42012-03-07 08:35:16 +00001505void StmtProfiler::VisitUserDefinedLiteral(const UserDefinedLiteral *S) {
1506 VisitCallExpr(S);
1507}
1508
Chandler Carruth631abd92011-06-16 06:47:06 +00001509void StmtProfiler::VisitCXXBoolLiteralExpr(const CXXBoolLiteralExpr *S) {
Douglas Gregor5c193b92009-07-28 00:33:38 +00001510 VisitExpr(S);
1511 ID.AddBoolean(S->getValue());
1512}
1513
Chandler Carruth631abd92011-06-16 06:47:06 +00001514void StmtProfiler::VisitCXXNullPtrLiteralExpr(const CXXNullPtrLiteralExpr *S) {
Douglas Gregor00044172009-07-29 16:09:57 +00001515 VisitExpr(S);
1516}
1517
Richard Smithcc1b96d2013-06-12 22:31:48 +00001518void StmtProfiler::VisitCXXStdInitializerListExpr(
1519 const CXXStdInitializerListExpr *S) {
1520 VisitExpr(S);
1521}
1522
Chandler Carruth631abd92011-06-16 06:47:06 +00001523void StmtProfiler::VisitCXXTypeidExpr(const CXXTypeidExpr *S) {
Douglas Gregor5c193b92009-07-28 00:33:38 +00001524 VisitExpr(S);
1525 if (S->isTypeOperand())
David Majnemer143c55e2013-09-27 07:04:31 +00001526 VisitType(S->getTypeOperandSourceInfo()->getType());
Douglas Gregor5c193b92009-07-28 00:33:38 +00001527}
1528
Chandler Carruth631abd92011-06-16 06:47:06 +00001529void StmtProfiler::VisitCXXUuidofExpr(const CXXUuidofExpr *S) {
Francois Pichet9f4f2072010-09-08 12:20:18 +00001530 VisitExpr(S);
1531 if (S->isTypeOperand())
David Majnemer143c55e2013-09-27 07:04:31 +00001532 VisitType(S->getTypeOperandSourceInfo()->getType());
Francois Pichet9f4f2072010-09-08 12:20:18 +00001533}
1534
John McCall5e77d762013-04-16 07:28:30 +00001535void StmtProfiler::VisitMSPropertyRefExpr(const MSPropertyRefExpr *S) {
1536 VisitExpr(S);
1537 VisitDecl(S->getPropertyDecl());
1538}
1539
Alexey Bataevf7630272015-11-25 12:01:00 +00001540void StmtProfiler::VisitMSPropertySubscriptExpr(
1541 const MSPropertySubscriptExpr *S) {
1542 VisitExpr(S);
1543}
1544
Chandler Carruth631abd92011-06-16 06:47:06 +00001545void StmtProfiler::VisitCXXThisExpr(const CXXThisExpr *S) {
Douglas Gregor5c193b92009-07-28 00:33:38 +00001546 VisitExpr(S);
Douglas Gregor3024f072012-04-16 07:05:22 +00001547 ID.AddBoolean(S->isImplicit());
Douglas Gregor5c193b92009-07-28 00:33:38 +00001548}
1549
Chandler Carruth631abd92011-06-16 06:47:06 +00001550void StmtProfiler::VisitCXXThrowExpr(const CXXThrowExpr *S) {
Douglas Gregor5c193b92009-07-28 00:33:38 +00001551 VisitExpr(S);
1552}
1553
Chandler Carruth631abd92011-06-16 06:47:06 +00001554void StmtProfiler::VisitCXXDefaultArgExpr(const CXXDefaultArgExpr *S) {
Douglas Gregor5c193b92009-07-28 00:33:38 +00001555 VisitExpr(S);
1556 VisitDecl(S->getParam());
1557}
1558
Richard Smith852c9db2013-04-20 22:23:05 +00001559void StmtProfiler::VisitCXXDefaultInitExpr(const CXXDefaultInitExpr *S) {
1560 VisitExpr(S);
1561 VisitDecl(S->getField());
1562}
1563
Chandler Carruth631abd92011-06-16 06:47:06 +00001564void StmtProfiler::VisitCXXBindTemporaryExpr(const CXXBindTemporaryExpr *S) {
Douglas Gregor5c193b92009-07-28 00:33:38 +00001565 VisitExpr(S);
1566 VisitDecl(
1567 const_cast<CXXDestructorDecl *>(S->getTemporary()->getDestructor()));
1568}
1569
Chandler Carruth631abd92011-06-16 06:47:06 +00001570void StmtProfiler::VisitCXXConstructExpr(const CXXConstructExpr *S) {
Douglas Gregor5c193b92009-07-28 00:33:38 +00001571 VisitExpr(S);
1572 VisitDecl(S->getConstructor());
1573 ID.AddBoolean(S->isElidable());
1574}
1575
Richard Smith5179eb72016-06-28 19:03:57 +00001576void StmtProfiler::VisitCXXInheritedCtorInitExpr(
1577 const CXXInheritedCtorInitExpr *S) {
1578 VisitExpr(S);
1579 VisitDecl(S->getConstructor());
1580}
1581
Chandler Carruth631abd92011-06-16 06:47:06 +00001582void StmtProfiler::VisitCXXFunctionalCastExpr(const CXXFunctionalCastExpr *S) {
Douglas Gregor5c193b92009-07-28 00:33:38 +00001583 VisitExplicitCastExpr(S);
1584}
1585
Chandler Carruth631abd92011-06-16 06:47:06 +00001586void
1587StmtProfiler::VisitCXXTemporaryObjectExpr(const CXXTemporaryObjectExpr *S) {
Douglas Gregor5c193b92009-07-28 00:33:38 +00001588 VisitCXXConstructExpr(S);
1589}
1590
Chandler Carruth631abd92011-06-16 06:47:06 +00001591void
Douglas Gregore31e6062012-02-07 10:09:13 +00001592StmtProfiler::VisitLambdaExpr(const LambdaExpr *S) {
1593 VisitExpr(S);
1594 for (LambdaExpr::capture_iterator C = S->explicit_capture_begin(),
1595 CEnd = S->explicit_capture_end();
1596 C != CEnd; ++C) {
Richard Trieu931638e2017-11-11 00:54:25 +00001597 if (C->capturesVLAType())
1598 continue;
1599
Douglas Gregore31e6062012-02-07 10:09:13 +00001600 ID.AddInteger(C->getCaptureKind());
Richard Smithba71c082013-05-16 06:20:58 +00001601 switch (C->getCaptureKind()) {
Faisal Validc6b5962016-03-21 09:25:37 +00001602 case LCK_StarThis:
Richard Smithba71c082013-05-16 06:20:58 +00001603 case LCK_This:
1604 break;
1605 case LCK_ByRef:
1606 case LCK_ByCopy:
Douglas Gregore31e6062012-02-07 10:09:13 +00001607 VisitDecl(C->getCapturedVar());
1608 ID.AddBoolean(C->isPackExpansion());
Richard Smithba71c082013-05-16 06:20:58 +00001609 break;
Alexey Bataev39c81e22014-08-28 04:28:19 +00001610 case LCK_VLAType:
1611 llvm_unreachable("VLA type in explicit captures.");
Douglas Gregore31e6062012-02-07 10:09:13 +00001612 }
1613 }
1614 // Note: If we actually needed to be able to match lambda
1615 // expressions, we would have to consider parameters and return type
1616 // here, among other things.
1617 VisitStmt(S->getBody());
1618}
1619
1620void
Chandler Carruth631abd92011-06-16 06:47:06 +00001621StmtProfiler::VisitCXXScalarValueInitExpr(const CXXScalarValueInitExpr *S) {
Douglas Gregor5c193b92009-07-28 00:33:38 +00001622 VisitExpr(S);
1623}
1624
Chandler Carruth631abd92011-06-16 06:47:06 +00001625void StmtProfiler::VisitCXXDeleteExpr(const CXXDeleteExpr *S) {
Douglas Gregor5c193b92009-07-28 00:33:38 +00001626 VisitExpr(S);
1627 ID.AddBoolean(S->isGlobalDelete());
1628 ID.AddBoolean(S->isArrayForm());
1629 VisitDecl(S->getOperatorDelete());
1630}
1631
Chandler Carruth631abd92011-06-16 06:47:06 +00001632void StmtProfiler::VisitCXXNewExpr(const CXXNewExpr *S) {
Douglas Gregor5c193b92009-07-28 00:33:38 +00001633 VisitExpr(S);
1634 VisitType(S->getAllocatedType());
1635 VisitDecl(S->getOperatorNew());
1636 VisitDecl(S->getOperatorDelete());
Douglas Gregor5c193b92009-07-28 00:33:38 +00001637 ID.AddBoolean(S->isArray());
1638 ID.AddInteger(S->getNumPlacementArgs());
1639 ID.AddBoolean(S->isGlobalNew());
1640 ID.AddBoolean(S->isParenTypeId());
Sebastian Redl6047f072012-02-16 12:22:20 +00001641 ID.AddInteger(S->getInitializationStyle());
Douglas Gregor5c193b92009-07-28 00:33:38 +00001642}
1643
Chandler Carruth631abd92011-06-16 06:47:06 +00001644void
1645StmtProfiler::VisitCXXPseudoDestructorExpr(const CXXPseudoDestructorExpr *S) {
Douglas Gregorad8a3362009-09-04 17:36:40 +00001646 VisitExpr(S);
1647 ID.AddBoolean(S->isArrow());
1648 VisitNestedNameSpecifier(S->getQualifier());
Craig Topper36250ad2014-05-12 05:36:57 +00001649 ID.AddBoolean(S->getScopeTypeInfo() != nullptr);
Eli Friedman85641392013-08-09 23:37:05 +00001650 if (S->getScopeTypeInfo())
1651 VisitType(S->getScopeTypeInfo()->getType());
Craig Topper36250ad2014-05-12 05:36:57 +00001652 ID.AddBoolean(S->getDestroyedTypeInfo() != nullptr);
Eli Friedman85641392013-08-09 23:37:05 +00001653 if (S->getDestroyedTypeInfo())
1654 VisitType(S->getDestroyedType());
1655 else
Richard Trieu639d7b62017-02-22 22:22:42 +00001656 VisitIdentifierInfo(S->getDestroyedTypeIdentifier());
Douglas Gregorad8a3362009-09-04 17:36:40 +00001657}
1658
Chandler Carruth631abd92011-06-16 06:47:06 +00001659void StmtProfiler::VisitOverloadExpr(const OverloadExpr *S) {
Argyrios Kyrtzidisb482eb82010-08-15 20:53:20 +00001660 VisitExpr(S);
John McCalle66edc12009-11-24 19:00:30 +00001661 VisitNestedNameSpecifier(S->getQualifier());
Douglas Gregor5c193b92009-07-28 00:33:38 +00001662 VisitName(S->getName());
John McCalle66edc12009-11-24 19:00:30 +00001663 ID.AddBoolean(S->hasExplicitTemplateArgs());
1664 if (S->hasExplicitTemplateArgs())
James Y Knight04ec5bf2015-12-24 02:59:37 +00001665 VisitTemplateArguments(S->getTemplateArgs(), S->getNumTemplateArgs());
Argyrios Kyrtzidisf4505452010-08-15 01:15:38 +00001666}
1667
1668void
Chandler Carruth631abd92011-06-16 06:47:06 +00001669StmtProfiler::VisitUnresolvedLookupExpr(const UnresolvedLookupExpr *S) {
Argyrios Kyrtzidisf4505452010-08-15 01:15:38 +00001670 VisitOverloadExpr(S);
Douglas Gregor5c193b92009-07-28 00:33:38 +00001671}
1672
Douglas Gregor29c42f22012-02-24 07:38:34 +00001673void StmtProfiler::VisitTypeTraitExpr(const TypeTraitExpr *S) {
1674 VisitExpr(S);
1675 ID.AddInteger(S->getTrait());
1676 ID.AddInteger(S->getNumArgs());
1677 for (unsigned I = 0, N = S->getNumArgs(); I != N; ++I)
1678 VisitType(S->getArg(I)->getType());
1679}
1680
Chandler Carruth631abd92011-06-16 06:47:06 +00001681void StmtProfiler::VisitArrayTypeTraitExpr(const ArrayTypeTraitExpr *S) {
John Wiegley6242b6a2011-04-28 00:16:57 +00001682 VisitExpr(S);
1683 ID.AddInteger(S->getTrait());
1684 VisitType(S->getQueriedType());
1685}
1686
Chandler Carruth631abd92011-06-16 06:47:06 +00001687void StmtProfiler::VisitExpressionTraitExpr(const ExpressionTraitExpr *S) {
John Wiegleyf9f65842011-04-25 06:54:41 +00001688 VisitExpr(S);
1689 ID.AddInteger(S->getTrait());
1690 VisitExpr(S->getQueriedExpression());
1691}
1692
Chandler Carruth631abd92011-06-16 06:47:06 +00001693void StmtProfiler::VisitDependentScopeDeclRefExpr(
1694 const DependentScopeDeclRefExpr *S) {
Douglas Gregor5c193b92009-07-28 00:33:38 +00001695 VisitExpr(S);
1696 VisitName(S->getDeclName());
1697 VisitNestedNameSpecifier(S->getQualifier());
John McCalle66edc12009-11-24 19:00:30 +00001698 ID.AddBoolean(S->hasExplicitTemplateArgs());
1699 if (S->hasExplicitTemplateArgs())
1700 VisitTemplateArguments(S->getTemplateArgs(), S->getNumTemplateArgs());
Douglas Gregor5c193b92009-07-28 00:33:38 +00001701}
1702
Chandler Carruth631abd92011-06-16 06:47:06 +00001703void StmtProfiler::VisitExprWithCleanups(const ExprWithCleanups *S) {
Douglas Gregora7095092009-07-28 14:44:31 +00001704 VisitExpr(S);
Douglas Gregora7095092009-07-28 14:44:31 +00001705}
1706
Chandler Carruth631abd92011-06-16 06:47:06 +00001707void StmtProfiler::VisitCXXUnresolvedConstructExpr(
1708 const CXXUnresolvedConstructExpr *S) {
Douglas Gregora7095092009-07-28 14:44:31 +00001709 VisitExpr(S);
1710 VisitType(S->getTypeAsWritten());
Richard Smith39eca9b2017-08-23 22:12:08 +00001711 ID.AddInteger(S->isListInitialization());
Douglas Gregora7095092009-07-28 14:44:31 +00001712}
1713
Chandler Carruth631abd92011-06-16 06:47:06 +00001714void StmtProfiler::VisitCXXDependentScopeMemberExpr(
1715 const CXXDependentScopeMemberExpr *S) {
John McCall2d74de92009-12-01 22:10:20 +00001716 ID.AddBoolean(S->isImplicitAccess());
1717 if (!S->isImplicitAccess()) {
1718 VisitExpr(S);
1719 ID.AddBoolean(S->isArrow());
1720 }
Douglas Gregorc26e0f62009-09-03 16:14:30 +00001721 VisitNestedNameSpecifier(S->getQualifier());
Douglas Gregora7095092009-07-28 14:44:31 +00001722 VisitName(S->getMember());
John McCall2d74de92009-12-01 22:10:20 +00001723 ID.AddBoolean(S->hasExplicitTemplateArgs());
1724 if (S->hasExplicitTemplateArgs())
John McCall10eae182009-11-30 22:42:35 +00001725 VisitTemplateArguments(S->getTemplateArgs(), S->getNumTemplateArgs());
1726}
1727
Chandler Carruth631abd92011-06-16 06:47:06 +00001728void StmtProfiler::VisitUnresolvedMemberExpr(const UnresolvedMemberExpr *S) {
John McCall2d74de92009-12-01 22:10:20 +00001729 ID.AddBoolean(S->isImplicitAccess());
1730 if (!S->isImplicitAccess()) {
1731 VisitExpr(S);
1732 ID.AddBoolean(S->isArrow());
1733 }
John McCall10eae182009-11-30 22:42:35 +00001734 VisitNestedNameSpecifier(S->getQualifier());
1735 VisitName(S->getMemberName());
1736 ID.AddBoolean(S->hasExplicitTemplateArgs());
1737 if (S->hasExplicitTemplateArgs())
1738 VisitTemplateArguments(S->getTemplateArgs(), S->getNumTemplateArgs());
Douglas Gregora7095092009-07-28 14:44:31 +00001739}
1740
Chandler Carruth631abd92011-06-16 06:47:06 +00001741void StmtProfiler::VisitCXXNoexceptExpr(const CXXNoexceptExpr *S) {
Sebastian Redl4202c0f2010-09-10 20:55:43 +00001742 VisitExpr(S);
1743}
1744
Chandler Carruth631abd92011-06-16 06:47:06 +00001745void StmtProfiler::VisitPackExpansionExpr(const PackExpansionExpr *S) {
Douglas Gregore8e9dd62011-01-03 17:17:50 +00001746 VisitExpr(S);
1747}
1748
Chandler Carruth631abd92011-06-16 06:47:06 +00001749void StmtProfiler::VisitSizeOfPackExpr(const SizeOfPackExpr *S) {
Douglas Gregor820ba7b2011-01-04 17:33:58 +00001750 VisitExpr(S);
1751 VisitDecl(S->getPack());
Richard Smithd784e682015-09-23 21:41:42 +00001752 if (S->isPartiallySubstituted()) {
1753 auto Args = S->getPartialArguments();
1754 ID.AddInteger(Args.size());
1755 for (const auto &TA : Args)
1756 VisitTemplateArgument(TA);
1757 } else {
1758 ID.AddInteger(0);
1759 }
Douglas Gregor820ba7b2011-01-04 17:33:58 +00001760}
1761
Douglas Gregorcdbc5392011-01-15 01:15:58 +00001762void StmtProfiler::VisitSubstNonTypeTemplateParmPackExpr(
Chandler Carruth631abd92011-06-16 06:47:06 +00001763 const SubstNonTypeTemplateParmPackExpr *S) {
Douglas Gregorcdbc5392011-01-15 01:15:58 +00001764 VisitExpr(S);
1765 VisitDecl(S->getParameterPack());
1766 VisitTemplateArgument(S->getArgumentPack());
1767}
1768
John McCall7c454bb2011-07-15 05:09:51 +00001769void StmtProfiler::VisitSubstNonTypeTemplateParmExpr(
1770 const SubstNonTypeTemplateParmExpr *E) {
1771 // Profile exactly as the replacement expression.
1772 Visit(E->getReplacement());
1773}
1774
Richard Smithb15fe3a2012-09-12 00:56:43 +00001775void StmtProfiler::VisitFunctionParmPackExpr(const FunctionParmPackExpr *S) {
1776 VisitExpr(S);
1777 VisitDecl(S->getParameterPack());
1778 ID.AddInteger(S->getNumExpansions());
1779 for (FunctionParmPackExpr::iterator I = S->begin(), E = S->end(); I != E; ++I)
1780 VisitDecl(*I);
1781}
1782
Douglas Gregorfe314812011-06-21 17:03:29 +00001783void StmtProfiler::VisitMaterializeTemporaryExpr(
1784 const MaterializeTemporaryExpr *S) {
1785 VisitExpr(S);
1786}
1787
Richard Smith0f0af192014-11-08 05:07:16 +00001788void StmtProfiler::VisitCXXFoldExpr(const CXXFoldExpr *S) {
1789 VisitExpr(S);
1790 ID.AddInteger(S->getOperator());
1791}
1792
Richard Smith9f690bd2015-10-27 06:02:45 +00001793void StmtProfiler::VisitCoroutineBodyStmt(const CoroutineBodyStmt *S) {
1794 VisitStmt(S);
1795}
1796
1797void StmtProfiler::VisitCoreturnStmt(const CoreturnStmt *S) {
1798 VisitStmt(S);
1799}
1800
1801void StmtProfiler::VisitCoawaitExpr(const CoawaitExpr *S) {
1802 VisitExpr(S);
1803}
1804
Eric Fiselier20f25cb2017-03-06 23:38:15 +00001805void StmtProfiler::VisitDependentCoawaitExpr(const DependentCoawaitExpr *S) {
1806 VisitExpr(S);
1807}
1808
Richard Smith9f690bd2015-10-27 06:02:45 +00001809void StmtProfiler::VisitCoyieldExpr(const CoyieldExpr *S) {
1810 VisitExpr(S);
1811}
1812
Chandler Carruth631abd92011-06-16 06:47:06 +00001813void StmtProfiler::VisitOpaqueValueExpr(const OpaqueValueExpr *E) {
John McCall8d69a212010-11-15 23:31:06 +00001814 VisitExpr(E);
1815}
1816
Kaelyn Takatae1f49d52014-10-27 18:07:20 +00001817void StmtProfiler::VisitTypoExpr(const TypoExpr *E) {
1818 VisitExpr(E);
1819}
1820
Chandler Carruth631abd92011-06-16 06:47:06 +00001821void StmtProfiler::VisitObjCStringLiteral(const ObjCStringLiteral *S) {
Douglas Gregora7095092009-07-28 14:44:31 +00001822 VisitExpr(S);
1823}
1824
Patrick Beard0caa3942012-04-19 00:25:12 +00001825void StmtProfiler::VisitObjCBoxedExpr(const ObjCBoxedExpr *E) {
Ted Kremeneke65b0862012-03-06 20:05:56 +00001826 VisitExpr(E);
1827}
1828
1829void StmtProfiler::VisitObjCArrayLiteral(const ObjCArrayLiteral *E) {
1830 VisitExpr(E);
1831}
1832
1833void StmtProfiler::VisitObjCDictionaryLiteral(const ObjCDictionaryLiteral *E) {
1834 VisitExpr(E);
1835}
1836
Chandler Carruth631abd92011-06-16 06:47:06 +00001837void StmtProfiler::VisitObjCEncodeExpr(const ObjCEncodeExpr *S) {
Douglas Gregora7095092009-07-28 14:44:31 +00001838 VisitExpr(S);
1839 VisitType(S->getEncodedType());
1840}
1841
Chandler Carruth631abd92011-06-16 06:47:06 +00001842void StmtProfiler::VisitObjCSelectorExpr(const ObjCSelectorExpr *S) {
Douglas Gregora7095092009-07-28 14:44:31 +00001843 VisitExpr(S);
1844 VisitName(S->getSelector());
1845}
1846
Chandler Carruth631abd92011-06-16 06:47:06 +00001847void StmtProfiler::VisitObjCProtocolExpr(const ObjCProtocolExpr *S) {
Douglas Gregora7095092009-07-28 14:44:31 +00001848 VisitExpr(S);
1849 VisitDecl(S->getProtocol());
1850}
1851
Chandler Carruth631abd92011-06-16 06:47:06 +00001852void StmtProfiler::VisitObjCIvarRefExpr(const ObjCIvarRefExpr *S) {
Douglas Gregora7095092009-07-28 14:44:31 +00001853 VisitExpr(S);
1854 VisitDecl(S->getDecl());
1855 ID.AddBoolean(S->isArrow());
1856 ID.AddBoolean(S->isFreeIvar());
1857}
1858
Chandler Carruth631abd92011-06-16 06:47:06 +00001859void StmtProfiler::VisitObjCPropertyRefExpr(const ObjCPropertyRefExpr *S) {
Douglas Gregora7095092009-07-28 14:44:31 +00001860 VisitExpr(S);
John McCallb7bd14f2010-12-02 01:19:52 +00001861 if (S->isImplicitProperty()) {
1862 VisitDecl(S->getImplicitPropertyGetter());
1863 VisitDecl(S->getImplicitPropertySetter());
1864 } else {
1865 VisitDecl(S->getExplicitProperty());
Fariborz Jahanian681c0752010-10-14 16:04:05 +00001866 }
Fariborz Jahanian681c0752010-10-14 16:04:05 +00001867 if (S->isSuperReceiver()) {
1868 ID.AddBoolean(S->isSuperReceiver());
John McCallb7bd14f2010-12-02 01:19:52 +00001869 VisitType(S->getSuperReceiverType());
Fariborz Jahanian681c0752010-10-14 16:04:05 +00001870 }
Douglas Gregora7095092009-07-28 14:44:31 +00001871}
1872
Ted Kremeneke65b0862012-03-06 20:05:56 +00001873void StmtProfiler::VisitObjCSubscriptRefExpr(const ObjCSubscriptRefExpr *S) {
1874 VisitExpr(S);
1875 VisitDecl(S->getAtIndexMethodDecl());
1876 VisitDecl(S->setAtIndexMethodDecl());
1877}
1878
Chandler Carruth631abd92011-06-16 06:47:06 +00001879void StmtProfiler::VisitObjCMessageExpr(const ObjCMessageExpr *S) {
Douglas Gregora7095092009-07-28 14:44:31 +00001880 VisitExpr(S);
1881 VisitName(S->getSelector());
1882 VisitDecl(S->getMethodDecl());
1883}
1884
Chandler Carruth631abd92011-06-16 06:47:06 +00001885void StmtProfiler::VisitObjCIsaExpr(const ObjCIsaExpr *S) {
Douglas Gregora7095092009-07-28 14:44:31 +00001886 VisitExpr(S);
1887 ID.AddBoolean(S->isArrow());
1888}
1889
Ted Kremeneke65b0862012-03-06 20:05:56 +00001890void StmtProfiler::VisitObjCBoolLiteralExpr(const ObjCBoolLiteralExpr *S) {
1891 VisitExpr(S);
1892 ID.AddBoolean(S->getValue());
1893}
1894
Chandler Carruth631abd92011-06-16 06:47:06 +00001895void StmtProfiler::VisitObjCIndirectCopyRestoreExpr(
1896 const ObjCIndirectCopyRestoreExpr *S) {
John McCall31168b02011-06-15 23:02:42 +00001897 VisitExpr(S);
1898 ID.AddBoolean(S->shouldCopy());
1899}
1900
Chandler Carruth631abd92011-06-16 06:47:06 +00001901void StmtProfiler::VisitObjCBridgedCastExpr(const ObjCBridgedCastExpr *S) {
John McCall31168b02011-06-15 23:02:42 +00001902 VisitExplicitCastExpr(S);
1903 ID.AddBoolean(S->getBridgeKind());
1904}
1905
Erik Pilkington29099de2016-07-16 00:35:23 +00001906void StmtProfiler::VisitObjCAvailabilityCheckExpr(
1907 const ObjCAvailabilityCheckExpr *S) {
1908 VisitExpr(S);
1909}
1910
John McCall0ad16662009-10-29 08:12:44 +00001911void StmtProfiler::VisitTemplateArguments(const TemplateArgumentLoc *Args,
Douglas Gregor5c193b92009-07-28 00:33:38 +00001912 unsigned NumArgs) {
1913 ID.AddInteger(NumArgs);
John McCall0ad16662009-10-29 08:12:44 +00001914 for (unsigned I = 0; I != NumArgs; ++I)
1915 VisitTemplateArgument(Args[I].getArgument());
1916}
Mike Stump11289f42009-09-09 15:08:12 +00001917
John McCall0ad16662009-10-29 08:12:44 +00001918void StmtProfiler::VisitTemplateArgument(const TemplateArgument &Arg) {
1919 // Mostly repetitive with TemplateArgument::Profile!
1920 ID.AddInteger(Arg.getKind());
1921 switch (Arg.getKind()) {
1922 case TemplateArgument::Null:
1923 break;
Mike Stump11289f42009-09-09 15:08:12 +00001924
John McCall0ad16662009-10-29 08:12:44 +00001925 case TemplateArgument::Type:
1926 VisitType(Arg.getAsType());
1927 break;
Mike Stump11289f42009-09-09 15:08:12 +00001928
Douglas Gregor9167f8b2009-11-11 01:00:40 +00001929 case TemplateArgument::Template:
Douglas Gregore4ff4b52011-01-05 18:58:31 +00001930 case TemplateArgument::TemplateExpansion:
1931 VisitTemplateName(Arg.getAsTemplateOrTemplatePattern());
Douglas Gregor9167f8b2009-11-11 01:00:40 +00001932 break;
Alexis Hunta8136cc2010-05-05 15:23:54 +00001933
John McCall0ad16662009-10-29 08:12:44 +00001934 case TemplateArgument::Declaration:
1935 VisitDecl(Arg.getAsDecl());
1936 break;
Mike Stump11289f42009-09-09 15:08:12 +00001937
Eli Friedmanb826a002012-09-26 02:36:12 +00001938 case TemplateArgument::NullPtr:
1939 VisitType(Arg.getNullPtrType());
1940 break;
1941
John McCall0ad16662009-10-29 08:12:44 +00001942 case TemplateArgument::Integral:
Benjamin Kramer6003ad52012-06-07 15:09:51 +00001943 Arg.getAsIntegral().Profile(ID);
John McCall0ad16662009-10-29 08:12:44 +00001944 VisitType(Arg.getIntegralType());
1945 break;
Mike Stump11289f42009-09-09 15:08:12 +00001946
John McCall0ad16662009-10-29 08:12:44 +00001947 case TemplateArgument::Expression:
1948 Visit(Arg.getAsExpr());
1949 break;
Mike Stump11289f42009-09-09 15:08:12 +00001950
John McCall0ad16662009-10-29 08:12:44 +00001951 case TemplateArgument::Pack:
Aaron Ballman2a89e852014-07-15 21:32:31 +00001952 for (const auto &P : Arg.pack_elements())
1953 VisitTemplateArgument(P);
John McCall0ad16662009-10-29 08:12:44 +00001954 break;
Douglas Gregor5c193b92009-07-28 00:33:38 +00001955 }
1956}
1957
Jay Foad39c79802011-01-12 09:06:06 +00001958void Stmt::Profile(llvm::FoldingSetNodeID &ID, const ASTContext &Context,
Chandler Carruth631abd92011-06-16 06:47:06 +00001959 bool Canonical) const {
Richard Trieu639d7b62017-02-22 22:22:42 +00001960 StmtProfilerWithPointers Profiler(ID, Context, Canonical);
1961 Profiler.Visit(this);
1962}
1963
1964void Stmt::ProcessODRHash(llvm::FoldingSetNodeID &ID,
1965 class ODRHash &Hash) const {
1966 StmtProfilerWithoutPointers Profiler(ID, Hash);
Douglas Gregor5c193b92009-07-28 00:33:38 +00001967 Profiler.Visit(this);
1968}