blob: 15653c4fd838c9daa76060dbb376a6603d920c2e [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
Richard Trieuf65efae2018-02-22 05:32:25 +000041 virtual void HandleStmtClass(Stmt::StmtClass SC) = 0;
42
Chandler Carruth631abd92011-06-16 06:47:06 +000043#define STMT(Node, Base) void Visit##Node(const Node *S);
Alexis Hunt656bb312010-05-05 15:24:00 +000044#include "clang/AST/StmtNodes.inc"
Mike Stump11289f42009-09-09 15:08:12 +000045
Adrian Prantl9fc8faf2018-05-09 01:00:01 +000046 /// Visit a declaration that is referenced within an expression
Douglas Gregor5c193b92009-07-28 00:33:38 +000047 /// or statement.
Richard Trieu639d7b62017-02-22 22:22:42 +000048 virtual void VisitDecl(const Decl *D) = 0;
Mike Stump11289f42009-09-09 15:08:12 +000049
Adrian Prantl9fc8faf2018-05-09 01:00:01 +000050 /// Visit a type that is referenced within an expression or
Douglas Gregor5c193b92009-07-28 00:33:38 +000051 /// statement.
Richard Trieu639d7b62017-02-22 22:22:42 +000052 virtual void VisitType(QualType T) = 0;
Mike Stump11289f42009-09-09 15:08:12 +000053
Adrian Prantl9fc8faf2018-05-09 01:00:01 +000054 /// Visit a name that occurs within an expression or statement.
Richard Trieuf65efae2018-02-22 05:32:25 +000055 virtual void VisitName(DeclarationName Name, bool TreatAsDecl = false) = 0;
Richard Trieu639d7b62017-02-22 22:22:42 +000056
Adrian Prantl9fc8faf2018-05-09 01:00:01 +000057 /// Visit identifiers that are not in Decl's or Type's.
Richard Trieu639d7b62017-02-22 22:22:42 +000058 virtual void VisitIdentifierInfo(IdentifierInfo *II) = 0;
Mike Stump11289f42009-09-09 15:08:12 +000059
Adrian Prantl9fc8faf2018-05-09 01:00:01 +000060 /// Visit a nested-name-specifier that occurs within an expression
Douglas Gregor5c193b92009-07-28 00:33:38 +000061 /// or statement.
Richard Trieu639d7b62017-02-22 22:22:42 +000062 virtual void VisitNestedNameSpecifier(NestedNameSpecifier *NNS) = 0;
Mike Stump11289f42009-09-09 15:08:12 +000063
Adrian Prantl9fc8faf2018-05-09 01:00:01 +000064 /// Visit a template name that occurs within an expression or
Douglas Gregor5c193b92009-07-28 00:33:38 +000065 /// statement.
Richard Trieu639d7b62017-02-22 22:22:42 +000066 virtual void VisitTemplateName(TemplateName Name) = 0;
Mike Stump11289f42009-09-09 15:08:12 +000067
Adrian Prantl9fc8faf2018-05-09 01:00:01 +000068 /// Visit template arguments that occur within an expression or
Douglas Gregor5c193b92009-07-28 00:33:38 +000069 /// statement.
Chandler Carruth631abd92011-06-16 06:47:06 +000070 void VisitTemplateArguments(const TemplateArgumentLoc *Args,
71 unsigned NumArgs);
John McCall0ad16662009-10-29 08:12:44 +000072
Adrian Prantl9fc8faf2018-05-09 01:00:01 +000073 /// Visit a single template argument.
John McCall0ad16662009-10-29 08:12:44 +000074 void VisitTemplateArgument(const TemplateArgument &Arg);
Douglas Gregor5c193b92009-07-28 00:33:38 +000075 };
Richard Trieu639d7b62017-02-22 22:22:42 +000076
77 class StmtProfilerWithPointers : public StmtProfiler {
78 const ASTContext &Context;
79
80 public:
81 StmtProfilerWithPointers(llvm::FoldingSetNodeID &ID,
82 const ASTContext &Context, bool Canonical)
83 : StmtProfiler(ID, Canonical), Context(Context) {}
84 private:
Richard Trieuf65efae2018-02-22 05:32:25 +000085 void HandleStmtClass(Stmt::StmtClass SC) override {
86 ID.AddInteger(SC);
87 }
88
Richard Trieu639d7b62017-02-22 22:22:42 +000089 void VisitDecl(const Decl *D) override {
90 ID.AddInteger(D ? D->getKind() : 0);
91
92 if (Canonical && D) {
93 if (const NonTypeTemplateParmDecl *NTTP =
94 dyn_cast<NonTypeTemplateParmDecl>(D)) {
95 ID.AddInteger(NTTP->getDepth());
96 ID.AddInteger(NTTP->getIndex());
97 ID.AddBoolean(NTTP->isParameterPack());
98 VisitType(NTTP->getType());
99 return;
100 }
101
102 if (const ParmVarDecl *Parm = dyn_cast<ParmVarDecl>(D)) {
103 // The Itanium C++ ABI uses the type, scope depth, and scope
104 // index of a parameter when mangling expressions that involve
105 // function parameters, so we will use the parameter's type for
106 // establishing function parameter identity. That way, our
107 // definition of "equivalent" (per C++ [temp.over.link]) is at
108 // least as strong as the definition of "equivalent" used for
109 // name mangling.
110 VisitType(Parm->getType());
111 ID.AddInteger(Parm->getFunctionScopeDepth());
112 ID.AddInteger(Parm->getFunctionScopeIndex());
113 return;
114 }
115
116 if (const TemplateTypeParmDecl *TTP =
117 dyn_cast<TemplateTypeParmDecl>(D)) {
118 ID.AddInteger(TTP->getDepth());
119 ID.AddInteger(TTP->getIndex());
120 ID.AddBoolean(TTP->isParameterPack());
121 return;
122 }
123
124 if (const TemplateTemplateParmDecl *TTP =
125 dyn_cast<TemplateTemplateParmDecl>(D)) {
126 ID.AddInteger(TTP->getDepth());
127 ID.AddInteger(TTP->getIndex());
128 ID.AddBoolean(TTP->isParameterPack());
129 return;
130 }
131 }
132
133 ID.AddPointer(D ? D->getCanonicalDecl() : nullptr);
134 }
135
136 void VisitType(QualType T) override {
Richard Trieua5f4ade2017-03-04 02:42:41 +0000137 if (Canonical && !T.isNull())
Richard Trieu639d7b62017-02-22 22:22:42 +0000138 T = Context.getCanonicalType(T);
139
140 ID.AddPointer(T.getAsOpaquePtr());
141 }
142
Richard Trieuf65efae2018-02-22 05:32:25 +0000143 void VisitName(DeclarationName Name, bool /*TreatAsDecl*/) override {
Richard Trieu639d7b62017-02-22 22:22:42 +0000144 ID.AddPointer(Name.getAsOpaquePtr());
145 }
146
147 void VisitIdentifierInfo(IdentifierInfo *II) override {
148 ID.AddPointer(II);
149 }
150
151 void VisitNestedNameSpecifier(NestedNameSpecifier *NNS) override {
152 if (Canonical)
153 NNS = Context.getCanonicalNestedNameSpecifier(NNS);
154 ID.AddPointer(NNS);
155 }
156
157 void VisitTemplateName(TemplateName Name) override {
158 if (Canonical)
159 Name = Context.getCanonicalTemplateName(Name);
160
161 Name.Profile(ID);
162 }
163 };
164
165 class StmtProfilerWithoutPointers : public StmtProfiler {
166 ODRHash &Hash;
167 public:
168 StmtProfilerWithoutPointers(llvm::FoldingSetNodeID &ID, ODRHash &Hash)
169 : StmtProfiler(ID, false), Hash(Hash) {}
170
171 private:
Richard Trieuf65efae2018-02-22 05:32:25 +0000172 void HandleStmtClass(Stmt::StmtClass SC) override {
173 if (SC == Stmt::UnresolvedLookupExprClass) {
174 // Pretend that the name looked up is a Decl due to how templates
175 // handle some Decl lookups.
176 ID.AddInteger(Stmt::DeclRefExprClass);
177 } else {
178 ID.AddInteger(SC);
179 }
180 }
181
Richard Trieu639d7b62017-02-22 22:22:42 +0000182 void VisitType(QualType T) override {
183 Hash.AddQualType(T);
184 }
185
Richard Trieuf65efae2018-02-22 05:32:25 +0000186 void VisitName(DeclarationName Name, bool TreatAsDecl) override {
187 if (TreatAsDecl) {
188 // A Decl can be null, so each Decl is preceded by a boolean to
189 // store its nullness. Add a boolean here to match.
190 ID.AddBoolean(true);
191 }
Richard Trieu639d7b62017-02-22 22:22:42 +0000192 Hash.AddDeclarationName(Name);
193 }
194 void VisitIdentifierInfo(IdentifierInfo *II) override {
195 ID.AddBoolean(II);
196 if (II) {
197 Hash.AddIdentifierInfo(II);
198 }
199 }
200 void VisitDecl(const Decl *D) override {
201 ID.AddBoolean(D);
202 if (D) {
203 Hash.AddDecl(D);
204 }
205 }
206 void VisitTemplateName(TemplateName Name) override {
207 Hash.AddTemplateName(Name);
208 }
209 void VisitNestedNameSpecifier(NestedNameSpecifier *NNS) override {
Richard Trieu96b41642017-07-01 02:00:05 +0000210 ID.AddBoolean(NNS);
211 if (NNS) {
212 Hash.AddNestedNameSpecifier(NNS);
213 }
Richard Trieu639d7b62017-02-22 22:22:42 +0000214 }
215 };
Alexander Kornienkoab9db512015-06-22 23:07:51 +0000216}
Douglas Gregor5c193b92009-07-28 00:33:38 +0000217
Chandler Carruth631abd92011-06-16 06:47:06 +0000218void StmtProfiler::VisitStmt(const Stmt *S) {
Richard Trieu6a77a1c2016-06-10 04:52:09 +0000219 assert(S && "Requires non-null Stmt pointer");
Richard Trieuf65efae2018-02-22 05:32:25 +0000220
221 HandleStmtClass(S->getStmtClass());
222
Benjamin Kramer642f1732015-07-02 21:03:14 +0000223 for (const Stmt *SubStmt : S->children()) {
224 if (SubStmt)
225 Visit(SubStmt);
Peter Collingbournecdb9f302012-03-01 16:34:31 +0000226 else
227 ID.AddInteger(0);
228 }
Douglas Gregor5c193b92009-07-28 00:33:38 +0000229}
230
Chandler Carruth631abd92011-06-16 06:47:06 +0000231void StmtProfiler::VisitDeclStmt(const DeclStmt *S) {
Douglas Gregor44882592009-07-28 15:27:13 +0000232 VisitStmt(S);
Aaron Ballman535bbcc2014-03-14 17:01:24 +0000233 for (const auto *D : S->decls())
234 VisitDecl(D);
Douglas Gregor44882592009-07-28 15:27:13 +0000235}
236
Chandler Carruth631abd92011-06-16 06:47:06 +0000237void StmtProfiler::VisitNullStmt(const NullStmt *S) {
Douglas Gregor44882592009-07-28 15:27:13 +0000238 VisitStmt(S);
239}
240
Chandler Carruth631abd92011-06-16 06:47:06 +0000241void StmtProfiler::VisitCompoundStmt(const CompoundStmt *S) {
Douglas Gregor44882592009-07-28 15:27:13 +0000242 VisitStmt(S);
243}
244
Chandler Carruth631abd92011-06-16 06:47:06 +0000245void StmtProfiler::VisitCaseStmt(const CaseStmt *S) {
Douglas Gregor44882592009-07-28 15:27:13 +0000246 VisitStmt(S);
247}
248
Chandler Carruth631abd92011-06-16 06:47:06 +0000249void StmtProfiler::VisitDefaultStmt(const DefaultStmt *S) {
Douglas Gregor44882592009-07-28 15:27:13 +0000250 VisitStmt(S);
251}
252
Chandler Carruth631abd92011-06-16 06:47:06 +0000253void StmtProfiler::VisitLabelStmt(const LabelStmt *S) {
Douglas Gregor44882592009-07-28 15:27:13 +0000254 VisitStmt(S);
Chris Lattnerc8e630e2011-02-17 07:39:24 +0000255 VisitDecl(S->getDecl());
Douglas Gregor44882592009-07-28 15:27:13 +0000256}
257
Richard Smithc202b282012-04-14 00:33:13 +0000258void StmtProfiler::VisitAttributedStmt(const AttributedStmt *S) {
259 VisitStmt(S);
260 // TODO: maybe visit attributes?
261}
262
Chandler Carruth631abd92011-06-16 06:47:06 +0000263void StmtProfiler::VisitIfStmt(const IfStmt *S) {
Douglas Gregor44882592009-07-28 15:27:13 +0000264 VisitStmt(S);
Douglas Gregor7bab5ff2009-11-25 00:27:52 +0000265 VisitDecl(S->getConditionVariable());
Douglas Gregor44882592009-07-28 15:27:13 +0000266}
267
Chandler Carruth631abd92011-06-16 06:47:06 +0000268void StmtProfiler::VisitSwitchStmt(const SwitchStmt *S) {
Douglas Gregor00044172009-07-29 16:09:57 +0000269 VisitStmt(S);
Douglas Gregor7bab5ff2009-11-25 00:27:52 +0000270 VisitDecl(S->getConditionVariable());
Douglas Gregor00044172009-07-29 16:09:57 +0000271}
272
Chandler Carruth631abd92011-06-16 06:47:06 +0000273void StmtProfiler::VisitWhileStmt(const WhileStmt *S) {
Douglas Gregor44882592009-07-28 15:27:13 +0000274 VisitStmt(S);
Douglas Gregor7bab5ff2009-11-25 00:27:52 +0000275 VisitDecl(S->getConditionVariable());
Douglas Gregor44882592009-07-28 15:27:13 +0000276}
277
Chandler Carruth631abd92011-06-16 06:47:06 +0000278void StmtProfiler::VisitDoStmt(const DoStmt *S) {
Douglas Gregor44882592009-07-28 15:27:13 +0000279 VisitStmt(S);
280}
281
Chandler Carruth631abd92011-06-16 06:47:06 +0000282void StmtProfiler::VisitForStmt(const ForStmt *S) {
Douglas Gregor44882592009-07-28 15:27:13 +0000283 VisitStmt(S);
284}
285
Chandler Carruth631abd92011-06-16 06:47:06 +0000286void StmtProfiler::VisitGotoStmt(const GotoStmt *S) {
Douglas Gregor44882592009-07-28 15:27:13 +0000287 VisitStmt(S);
Chris Lattnerc8e630e2011-02-17 07:39:24 +0000288 VisitDecl(S->getLabel());
Douglas Gregor44882592009-07-28 15:27:13 +0000289}
290
Chandler Carruth631abd92011-06-16 06:47:06 +0000291void StmtProfiler::VisitIndirectGotoStmt(const IndirectGotoStmt *S) {
Douglas Gregor44882592009-07-28 15:27:13 +0000292 VisitStmt(S);
293}
294
Chandler Carruth631abd92011-06-16 06:47:06 +0000295void StmtProfiler::VisitContinueStmt(const ContinueStmt *S) {
Douglas Gregor44882592009-07-28 15:27:13 +0000296 VisitStmt(S);
297}
298
Chandler Carruth631abd92011-06-16 06:47:06 +0000299void StmtProfiler::VisitBreakStmt(const BreakStmt *S) {
Douglas Gregor44882592009-07-28 15:27:13 +0000300 VisitStmt(S);
301}
302
Chandler Carruth631abd92011-06-16 06:47:06 +0000303void StmtProfiler::VisitReturnStmt(const ReturnStmt *S) {
Douglas Gregor44882592009-07-28 15:27:13 +0000304 VisitStmt(S);
305}
306
Chad Rosierde70e0e2012-08-25 00:11:56 +0000307void StmtProfiler::VisitGCCAsmStmt(const GCCAsmStmt *S) {
Douglas Gregor44882592009-07-28 15:27:13 +0000308 VisitStmt(S);
309 ID.AddBoolean(S->isVolatile());
310 ID.AddBoolean(S->isSimple());
311 VisitStringLiteral(S->getAsmString());
312 ID.AddInteger(S->getNumOutputs());
313 for (unsigned I = 0, N = S->getNumOutputs(); I != N; ++I) {
314 ID.AddString(S->getOutputName(I));
315 VisitStringLiteral(S->getOutputConstraintLiteral(I));
316 }
317 ID.AddInteger(S->getNumInputs());
318 for (unsigned I = 0, N = S->getNumInputs(); I != N; ++I) {
319 ID.AddString(S->getInputName(I));
320 VisitStringLiteral(S->getInputConstraintLiteral(I));
321 }
322 ID.AddInteger(S->getNumClobbers());
323 for (unsigned I = 0, N = S->getNumClobbers(); I != N; ++I)
Chad Rosierd9fb09a2012-08-27 23:28:41 +0000324 VisitStringLiteral(S->getClobberStringLiteral(I));
Douglas Gregor44882592009-07-28 15:27:13 +0000325}
326
Chad Rosier32503022012-06-11 20:47:18 +0000327void StmtProfiler::VisitMSAsmStmt(const MSAsmStmt *S) {
328 // FIXME: Implement MS style inline asm statement profiler.
329 VisitStmt(S);
330}
331
Chandler Carruth631abd92011-06-16 06:47:06 +0000332void StmtProfiler::VisitCXXCatchStmt(const CXXCatchStmt *S) {
Douglas Gregor44882592009-07-28 15:27:13 +0000333 VisitStmt(S);
334 VisitType(S->getCaughtType());
335}
336
Chandler Carruth631abd92011-06-16 06:47:06 +0000337void StmtProfiler::VisitCXXTryStmt(const CXXTryStmt *S) {
Douglas Gregor44882592009-07-28 15:27:13 +0000338 VisitStmt(S);
339}
340
Chandler Carruth631abd92011-06-16 06:47:06 +0000341void StmtProfiler::VisitCXXForRangeStmt(const CXXForRangeStmt *S) {
Richard Smith02e85f32011-04-14 22:09:26 +0000342 VisitStmt(S);
343}
344
Douglas Gregordeb4a2be2011-10-25 01:33:02 +0000345void StmtProfiler::VisitMSDependentExistsStmt(const MSDependentExistsStmt *S) {
346 VisitStmt(S);
347 ID.AddBoolean(S->isIfExists());
348 VisitNestedNameSpecifier(S->getQualifierLoc().getNestedNameSpecifier());
349 VisitName(S->getNameInfo().getName());
350}
351
Chandler Carruth631abd92011-06-16 06:47:06 +0000352void StmtProfiler::VisitSEHTryStmt(const SEHTryStmt *S) {
John Wiegley1c0675e2011-04-28 01:08:34 +0000353 VisitStmt(S);
354}
355
Chandler Carruth631abd92011-06-16 06:47:06 +0000356void StmtProfiler::VisitSEHFinallyStmt(const SEHFinallyStmt *S) {
John Wiegley1c0675e2011-04-28 01:08:34 +0000357 VisitStmt(S);
358}
359
Chandler Carruth631abd92011-06-16 06:47:06 +0000360void StmtProfiler::VisitSEHExceptStmt(const SEHExceptStmt *S) {
John Wiegley1c0675e2011-04-28 01:08:34 +0000361 VisitStmt(S);
362}
363
Nico Weber9b982072014-07-07 00:12:30 +0000364void StmtProfiler::VisitSEHLeaveStmt(const SEHLeaveStmt *S) {
365 VisitStmt(S);
366}
367
Tareq A. Siraj24110cc2013-04-16 18:53:08 +0000368void StmtProfiler::VisitCapturedStmt(const CapturedStmt *S) {
369 VisitStmt(S);
370}
371
Chandler Carruth631abd92011-06-16 06:47:06 +0000372void StmtProfiler::VisitObjCForCollectionStmt(const ObjCForCollectionStmt *S) {
Douglas Gregor44882592009-07-28 15:27:13 +0000373 VisitStmt(S);
374}
375
Chandler Carruth631abd92011-06-16 06:47:06 +0000376void StmtProfiler::VisitObjCAtCatchStmt(const ObjCAtCatchStmt *S) {
Douglas Gregor44882592009-07-28 15:27:13 +0000377 VisitStmt(S);
378 ID.AddBoolean(S->hasEllipsis());
379 if (S->getCatchParamDecl())
380 VisitType(S->getCatchParamDecl()->getType());
381}
382
Chandler Carruth631abd92011-06-16 06:47:06 +0000383void StmtProfiler::VisitObjCAtFinallyStmt(const ObjCAtFinallyStmt *S) {
Douglas Gregor44882592009-07-28 15:27:13 +0000384 VisitStmt(S);
385}
386
Chandler Carruth631abd92011-06-16 06:47:06 +0000387void StmtProfiler::VisitObjCAtTryStmt(const ObjCAtTryStmt *S) {
Douglas Gregor44882592009-07-28 15:27:13 +0000388 VisitStmt(S);
389}
390
Chandler Carruth631abd92011-06-16 06:47:06 +0000391void
392StmtProfiler::VisitObjCAtSynchronizedStmt(const ObjCAtSynchronizedStmt *S) {
Douglas Gregor44882592009-07-28 15:27:13 +0000393 VisitStmt(S);
394}
395
Chandler Carruth631abd92011-06-16 06:47:06 +0000396void StmtProfiler::VisitObjCAtThrowStmt(const ObjCAtThrowStmt *S) {
Douglas Gregor44882592009-07-28 15:27:13 +0000397 VisitStmt(S);
398}
399
Chandler Carruth631abd92011-06-16 06:47:06 +0000400void
401StmtProfiler::VisitObjCAutoreleasePoolStmt(const ObjCAutoreleasePoolStmt *S) {
John McCall31168b02011-06-15 23:02:42 +0000402 VisitStmt(S);
403}
404
Alexey Bataev5ec3eb12013-07-19 03:13:43 +0000405namespace {
406class OMPClauseProfiler : public ConstOMPClauseVisitor<OMPClauseProfiler> {
407 StmtProfiler *Profiler;
Adrian Prantl9fc8faf2018-05-09 01:00:01 +0000408 /// Process clauses with list of variables.
Alexey Bataev756c1962013-09-24 03:17:45 +0000409 template <typename T>
410 void VisitOMPClauseList(T *Node);
NAKAMURA Takumiaa13f942015-12-09 07:52:46 +0000411
Alexey Bataev5ec3eb12013-07-19 03:13:43 +0000412public:
413 OMPClauseProfiler(StmtProfiler *P) : Profiler(P) { }
414#define OPENMP_CLAUSE(Name, Class) \
415 void Visit##Class(const Class *C);
416#include "clang/Basic/OpenMPKinds.def"
Alexey Bataev3392d762016-02-16 11:18:12 +0000417 void VistOMPClauseWithPreInit(const OMPClauseWithPreInit *C);
Alexey Bataev005248a2016-02-25 05:25:57 +0000418 void VistOMPClauseWithPostUpdate(const OMPClauseWithPostUpdate *C);
Alexey Bataev5ec3eb12013-07-19 03:13:43 +0000419};
420
Alexey Bataev3392d762016-02-16 11:18:12 +0000421void OMPClauseProfiler::VistOMPClauseWithPreInit(
422 const OMPClauseWithPreInit *C) {
423 if (auto *S = C->getPreInitStmt())
424 Profiler->VisitStmt(S);
425}
426
Alexey Bataev005248a2016-02-25 05:25:57 +0000427void OMPClauseProfiler::VistOMPClauseWithPostUpdate(
428 const OMPClauseWithPostUpdate *C) {
Alexey Bataev37e594c2016-03-04 07:21:16 +0000429 VistOMPClauseWithPreInit(C);
Alexey Bataev005248a2016-02-25 05:25:57 +0000430 if (auto *E = C->getPostUpdateExpr())
431 Profiler->VisitStmt(E);
432}
433
Alexey Bataevaadd52e2014-02-13 05:29:23 +0000434void OMPClauseProfiler::VisitOMPIfClause(const OMPIfClause *C) {
Arpith Chacko Jacobfe4890a2017-01-18 20:40:48 +0000435 VistOMPClauseWithPreInit(C);
Alexey Bataevaadd52e2014-02-13 05:29:23 +0000436 if (C->getCondition())
437 Profiler->VisitStmt(C->getCondition());
438}
439
Alexey Bataev3778b602014-07-17 07:32:53 +0000440void OMPClauseProfiler::VisitOMPFinalClause(const OMPFinalClause *C) {
441 if (C->getCondition())
442 Profiler->VisitStmt(C->getCondition());
443}
444
Alexey Bataev568a8332014-03-06 06:15:19 +0000445void OMPClauseProfiler::VisitOMPNumThreadsClause(const OMPNumThreadsClause *C) {
Arpith Chacko Jacob33c849a2017-01-25 00:57:16 +0000446 VistOMPClauseWithPreInit(C);
Alexey Bataev568a8332014-03-06 06:15:19 +0000447 if (C->getNumThreads())
448 Profiler->VisitStmt(C->getNumThreads());
449}
450
Alexey Bataev62c87d22014-03-21 04:51:18 +0000451void OMPClauseProfiler::VisitOMPSafelenClause(const OMPSafelenClause *C) {
452 if (C->getSafelen())
453 Profiler->VisitStmt(C->getSafelen());
454}
455
Alexey Bataev66b15b52015-08-21 11:14:16 +0000456void OMPClauseProfiler::VisitOMPSimdlenClause(const OMPSimdlenClause *C) {
457 if (C->getSimdlen())
458 Profiler->VisitStmt(C->getSimdlen());
459}
460
Alexander Musman8bd31e62014-05-27 15:12:19 +0000461void OMPClauseProfiler::VisitOMPCollapseClause(const OMPCollapseClause *C) {
462 if (C->getNumForLoops())
463 Profiler->VisitStmt(C->getNumForLoops());
464}
465
Alexey Bataev5ec3eb12013-07-19 03:13:43 +0000466void OMPClauseProfiler::VisitOMPDefaultClause(const OMPDefaultClause *C) { }
Alexey Bataev756c1962013-09-24 03:17:45 +0000467
Alexey Bataevbcbadb62014-05-06 06:04:14 +0000468void OMPClauseProfiler::VisitOMPProcBindClause(const OMPProcBindClause *C) { }
469
Alexey Bataev56dafe82014-06-20 07:16:17 +0000470void OMPClauseProfiler::VisitOMPScheduleClause(const OMPScheduleClause *C) {
Alexey Bataev3392d762016-02-16 11:18:12 +0000471 VistOMPClauseWithPreInit(C);
472 if (auto *S = C->getChunkSize())
473 Profiler->VisitStmt(S);
Alexey Bataev56dafe82014-06-20 07:16:17 +0000474}
475
Alexey Bataev10e775f2015-07-30 11:36:16 +0000476void OMPClauseProfiler::VisitOMPOrderedClause(const OMPOrderedClause *C) {
477 if (auto *Num = C->getNumForLoops())
478 Profiler->VisitStmt(Num);
479}
Alexey Bataev142e1fc2014-06-20 09:44:06 +0000480
Alexey Bataev236070f2014-06-20 11:19:47 +0000481void OMPClauseProfiler::VisitOMPNowaitClause(const OMPNowaitClause *) {}
482
Alexey Bataev7aea99a2014-07-17 12:19:31 +0000483void OMPClauseProfiler::VisitOMPUntiedClause(const OMPUntiedClause *) {}
484
Alexey Bataev74ba3a52014-07-17 12:47:03 +0000485void OMPClauseProfiler::VisitOMPMergeableClause(const OMPMergeableClause *) {}
486
Alexey Bataevf98b00c2014-07-23 02:27:21 +0000487void OMPClauseProfiler::VisitOMPReadClause(const OMPReadClause *) {}
488
Alexey Bataevdea47612014-07-23 07:46:59 +0000489void OMPClauseProfiler::VisitOMPWriteClause(const OMPWriteClause *) {}
490
Alexey Bataev67a4f222014-07-23 10:25:33 +0000491void OMPClauseProfiler::VisitOMPUpdateClause(const OMPUpdateClause *) {}
492
Alexey Bataev459dec02014-07-24 06:46:57 +0000493void OMPClauseProfiler::VisitOMPCaptureClause(const OMPCaptureClause *) {}
494
Alexey Bataev82bad8b2014-07-24 08:55:34 +0000495void OMPClauseProfiler::VisitOMPSeqCstClause(const OMPSeqCstClause *) {}
496
Alexey Bataev346265e2015-09-25 10:37:12 +0000497void OMPClauseProfiler::VisitOMPThreadsClause(const OMPThreadsClause *) {}
498
Alexey Bataevd14d1e62015-09-28 06:39:35 +0000499void OMPClauseProfiler::VisitOMPSIMDClause(const OMPSIMDClause *) {}
500
Alexey Bataevb825de12015-12-07 10:51:44 +0000501void OMPClauseProfiler::VisitOMPNogroupClause(const OMPNogroupClause *) {}
502
Alexey Bataev756c1962013-09-24 03:17:45 +0000503template<typename T>
504void OMPClauseProfiler::VisitOMPClauseList(T *Node) {
Alexey Bataev03b340a2014-10-21 03:16:40 +0000505 for (auto *E : Node->varlists()) {
Richard Trieu6a77a1c2016-06-10 04:52:09 +0000506 if (E)
507 Profiler->VisitStmt(E);
Alexey Bataev03b340a2014-10-21 03:16:40 +0000508 }
Alexey Bataev756c1962013-09-24 03:17:45 +0000509}
Alexey Bataev5ec3eb12013-07-19 03:13:43 +0000510
511void OMPClauseProfiler::VisitOMPPrivateClause(const OMPPrivateClause *C) {
Alexey Bataev756c1962013-09-24 03:17:45 +0000512 VisitOMPClauseList(C);
Alexey Bataev03b340a2014-10-21 03:16:40 +0000513 for (auto *E : C->private_copies()) {
Richard Trieu6a77a1c2016-06-10 04:52:09 +0000514 if (E)
515 Profiler->VisitStmt(E);
Alexey Bataev03b340a2014-10-21 03:16:40 +0000516 }
Alexey Bataev5ec3eb12013-07-19 03:13:43 +0000517}
Alexey Bataev4a5bb772014-10-08 14:01:46 +0000518void
519OMPClauseProfiler::VisitOMPFirstprivateClause(const OMPFirstprivateClause *C) {
Alexey Bataevd5af8e42013-10-01 05:32:34 +0000520 VisitOMPClauseList(C);
Alexey Bataev417089f2016-02-17 13:19:37 +0000521 VistOMPClauseWithPreInit(C);
Alexey Bataev4a5bb772014-10-08 14:01:46 +0000522 for (auto *E : C->private_copies()) {
Richard Trieu6a77a1c2016-06-10 04:52:09 +0000523 if (E)
524 Profiler->VisitStmt(E);
Alexey Bataev4a5bb772014-10-08 14:01:46 +0000525 }
526 for (auto *E : C->inits()) {
Richard Trieu6a77a1c2016-06-10 04:52:09 +0000527 if (E)
528 Profiler->VisitStmt(E);
Alexey Bataev4a5bb772014-10-08 14:01:46 +0000529 }
Alexey Bataevd5af8e42013-10-01 05:32:34 +0000530}
Alexander Musman1bb328c2014-06-04 13:06:39 +0000531void
532OMPClauseProfiler::VisitOMPLastprivateClause(const OMPLastprivateClause *C) {
533 VisitOMPClauseList(C);
Alexey Bataev005248a2016-02-25 05:25:57 +0000534 VistOMPClauseWithPostUpdate(C);
Alexey Bataev38e89532015-04-16 04:54:05 +0000535 for (auto *E : C->source_exprs()) {
Richard Trieu6a77a1c2016-06-10 04:52:09 +0000536 if (E)
537 Profiler->VisitStmt(E);
Alexey Bataev38e89532015-04-16 04:54:05 +0000538 }
539 for (auto *E : C->destination_exprs()) {
Richard Trieu6a77a1c2016-06-10 04:52:09 +0000540 if (E)
541 Profiler->VisitStmt(E);
Alexey Bataev38e89532015-04-16 04:54:05 +0000542 }
543 for (auto *E : C->assignment_ops()) {
Richard Trieu6a77a1c2016-06-10 04:52:09 +0000544 if (E)
545 Profiler->VisitStmt(E);
Alexey Bataev38e89532015-04-16 04:54:05 +0000546 }
Alexander Musman1bb328c2014-06-04 13:06:39 +0000547}
Alexey Bataev758e55e2013-09-06 18:03:48 +0000548void OMPClauseProfiler::VisitOMPSharedClause(const OMPSharedClause *C) {
Alexey Bataev756c1962013-09-24 03:17:45 +0000549 VisitOMPClauseList(C);
Alexey Bataev758e55e2013-09-06 18:03:48 +0000550}
Alexey Bataevc5e02582014-06-16 07:08:35 +0000551void OMPClauseProfiler::VisitOMPReductionClause(
552 const OMPReductionClause *C) {
553 Profiler->VisitNestedNameSpecifier(
554 C->getQualifierLoc().getNestedNameSpecifier());
555 Profiler->VisitName(C->getNameInfo().getName());
556 VisitOMPClauseList(C);
Alexey Bataev61205072016-03-02 04:57:40 +0000557 VistOMPClauseWithPostUpdate(C);
Alexey Bataevf24e7b12015-10-08 09:10:53 +0000558 for (auto *E : C->privates()) {
Richard Trieu6a77a1c2016-06-10 04:52:09 +0000559 if (E)
560 Profiler->VisitStmt(E);
Alexey Bataevf24e7b12015-10-08 09:10:53 +0000561 }
Alexey Bataev794ba0d2015-04-10 10:43:45 +0000562 for (auto *E : C->lhs_exprs()) {
Richard Trieu6a77a1c2016-06-10 04:52:09 +0000563 if (E)
564 Profiler->VisitStmt(E);
Alexey Bataev794ba0d2015-04-10 10:43:45 +0000565 }
566 for (auto *E : C->rhs_exprs()) {
Richard Trieu6a77a1c2016-06-10 04:52:09 +0000567 if (E)
568 Profiler->VisitStmt(E);
Alexey Bataev794ba0d2015-04-10 10:43:45 +0000569 }
570 for (auto *E : C->reduction_ops()) {
Richard Trieu6a77a1c2016-06-10 04:52:09 +0000571 if (E)
572 Profiler->VisitStmt(E);
Alexey Bataev794ba0d2015-04-10 10:43:45 +0000573 }
Alexey Bataevc5e02582014-06-16 07:08:35 +0000574}
Alexey Bataev169d96a2017-07-18 20:17:46 +0000575void OMPClauseProfiler::VisitOMPTaskReductionClause(
576 const OMPTaskReductionClause *C) {
577 Profiler->VisitNestedNameSpecifier(
578 C->getQualifierLoc().getNestedNameSpecifier());
579 Profiler->VisitName(C->getNameInfo().getName());
580 VisitOMPClauseList(C);
581 VistOMPClauseWithPostUpdate(C);
582 for (auto *E : C->privates()) {
583 if (E)
584 Profiler->VisitStmt(E);
585 }
586 for (auto *E : C->lhs_exprs()) {
587 if (E)
588 Profiler->VisitStmt(E);
589 }
590 for (auto *E : C->rhs_exprs()) {
591 if (E)
592 Profiler->VisitStmt(E);
593 }
594 for (auto *E : C->reduction_ops()) {
595 if (E)
596 Profiler->VisitStmt(E);
597 }
598}
Alexey Bataevfa312f32017-07-21 18:48:21 +0000599void OMPClauseProfiler::VisitOMPInReductionClause(
600 const OMPInReductionClause *C) {
601 Profiler->VisitNestedNameSpecifier(
602 C->getQualifierLoc().getNestedNameSpecifier());
603 Profiler->VisitName(C->getNameInfo().getName());
604 VisitOMPClauseList(C);
605 VistOMPClauseWithPostUpdate(C);
606 for (auto *E : C->privates()) {
607 if (E)
608 Profiler->VisitStmt(E);
609 }
610 for (auto *E : C->lhs_exprs()) {
611 if (E)
612 Profiler->VisitStmt(E);
613 }
614 for (auto *E : C->rhs_exprs()) {
615 if (E)
616 Profiler->VisitStmt(E);
617 }
618 for (auto *E : C->reduction_ops()) {
619 if (E)
620 Profiler->VisitStmt(E);
621 }
Alexey Bataev88202be2017-07-27 13:20:36 +0000622 for (auto *E : C->taskgroup_descriptors()) {
623 if (E)
624 Profiler->VisitStmt(E);
625 }
Alexey Bataevfa312f32017-07-21 18:48:21 +0000626}
Alexander Musman8dba6642014-04-22 13:09:42 +0000627void OMPClauseProfiler::VisitOMPLinearClause(const OMPLinearClause *C) {
628 VisitOMPClauseList(C);
Alexey Bataev78849fb2016-03-09 09:49:00 +0000629 VistOMPClauseWithPostUpdate(C);
Alexey Bataevbd9fec12015-08-18 06:47:21 +0000630 for (auto *E : C->privates()) {
Richard Trieu6a77a1c2016-06-10 04:52:09 +0000631 if (E)
632 Profiler->VisitStmt(E);
Alexey Bataevbd9fec12015-08-18 06:47:21 +0000633 }
Alexander Musman3276a272015-03-21 10:12:56 +0000634 for (auto *E : C->inits()) {
Richard Trieu6a77a1c2016-06-10 04:52:09 +0000635 if (E)
636 Profiler->VisitStmt(E);
Alexander Musman3276a272015-03-21 10:12:56 +0000637 }
638 for (auto *E : C->updates()) {
Richard Trieu6a77a1c2016-06-10 04:52:09 +0000639 if (E)
640 Profiler->VisitStmt(E);
Alexander Musman3276a272015-03-21 10:12:56 +0000641 }
642 for (auto *E : C->finals()) {
Richard Trieu6a77a1c2016-06-10 04:52:09 +0000643 if (E)
644 Profiler->VisitStmt(E);
Alexander Musman3276a272015-03-21 10:12:56 +0000645 }
Richard Trieu6a77a1c2016-06-10 04:52:09 +0000646 if (C->getStep())
647 Profiler->VisitStmt(C->getStep());
648 if (C->getCalcStep())
649 Profiler->VisitStmt(C->getCalcStep());
Alexander Musman8dba6642014-04-22 13:09:42 +0000650}
Alexander Musmanf0d76e72014-05-29 14:36:25 +0000651void OMPClauseProfiler::VisitOMPAlignedClause(const OMPAlignedClause *C) {
652 VisitOMPClauseList(C);
Richard Trieu6a77a1c2016-06-10 04:52:09 +0000653 if (C->getAlignment())
654 Profiler->VisitStmt(C->getAlignment());
Alexander Musmanf0d76e72014-05-29 14:36:25 +0000655}
Alexey Bataevd48bcd82014-03-31 03:36:38 +0000656void OMPClauseProfiler::VisitOMPCopyinClause(const OMPCopyinClause *C) {
657 VisitOMPClauseList(C);
Alexey Bataevf56f98c2015-04-16 05:39:01 +0000658 for (auto *E : C->source_exprs()) {
Richard Trieu6a77a1c2016-06-10 04:52:09 +0000659 if (E)
660 Profiler->VisitStmt(E);
Alexey Bataevf56f98c2015-04-16 05:39:01 +0000661 }
662 for (auto *E : C->destination_exprs()) {
Richard Trieu6a77a1c2016-06-10 04:52:09 +0000663 if (E)
664 Profiler->VisitStmt(E);
Alexey Bataevf56f98c2015-04-16 05:39:01 +0000665 }
666 for (auto *E : C->assignment_ops()) {
Richard Trieu6a77a1c2016-06-10 04:52:09 +0000667 if (E)
668 Profiler->VisitStmt(E);
Alexey Bataevf56f98c2015-04-16 05:39:01 +0000669 }
Alexey Bataevd48bcd82014-03-31 03:36:38 +0000670}
Alexey Bataevbae9a792014-06-27 10:37:06 +0000671void
672OMPClauseProfiler::VisitOMPCopyprivateClause(const OMPCopyprivateClause *C) {
673 VisitOMPClauseList(C);
Alexey Bataeva63048e2015-03-23 06:18:07 +0000674 for (auto *E : C->source_exprs()) {
Richard Trieu6a77a1c2016-06-10 04:52:09 +0000675 if (E)
676 Profiler->VisitStmt(E);
Alexey Bataeva63048e2015-03-23 06:18:07 +0000677 }
678 for (auto *E : C->destination_exprs()) {
Richard Trieu6a77a1c2016-06-10 04:52:09 +0000679 if (E)
680 Profiler->VisitStmt(E);
Alexey Bataeva63048e2015-03-23 06:18:07 +0000681 }
682 for (auto *E : C->assignment_ops()) {
Richard Trieu6a77a1c2016-06-10 04:52:09 +0000683 if (E)
684 Profiler->VisitStmt(E);
Alexey Bataeva63048e2015-03-23 06:18:07 +0000685 }
Alexey Bataevbae9a792014-06-27 10:37:06 +0000686}
Alexey Bataev6125da92014-07-21 11:26:11 +0000687void OMPClauseProfiler::VisitOMPFlushClause(const OMPFlushClause *C) {
688 VisitOMPClauseList(C);
689}
Alexey Bataev1c2cfbc2015-06-23 14:25:19 +0000690void OMPClauseProfiler::VisitOMPDependClause(const OMPDependClause *C) {
691 VisitOMPClauseList(C);
692}
Michael Wonge710d542015-08-07 16:16:36 +0000693void OMPClauseProfiler::VisitOMPDeviceClause(const OMPDeviceClause *C) {
Richard Trieu6a77a1c2016-06-10 04:52:09 +0000694 if (C->getDevice())
695 Profiler->VisitStmt(C->getDevice());
Michael Wonge710d542015-08-07 16:16:36 +0000696}
Kelvin Li0bff7af2015-11-23 05:32:03 +0000697void OMPClauseProfiler::VisitOMPMapClause(const OMPMapClause *C) {
698 VisitOMPClauseList(C);
699}
Kelvin Li099bb8c2015-11-24 20:50:12 +0000700void OMPClauseProfiler::VisitOMPNumTeamsClause(const OMPNumTeamsClause *C) {
Arpith Chacko Jacobbc126342017-01-25 11:28:18 +0000701 VistOMPClauseWithPreInit(C);
Richard Trieu6a77a1c2016-06-10 04:52:09 +0000702 if (C->getNumTeams())
703 Profiler->VisitStmt(C->getNumTeams());
Kelvin Li099bb8c2015-11-24 20:50:12 +0000704}
Kelvin Lia15fb1a2015-11-27 18:47:36 +0000705void OMPClauseProfiler::VisitOMPThreadLimitClause(
706 const OMPThreadLimitClause *C) {
Arpith Chacko Jacob7ecc0b72017-01-25 11:44:35 +0000707 VistOMPClauseWithPreInit(C);
Richard Trieu6a77a1c2016-06-10 04:52:09 +0000708 if (C->getThreadLimit())
709 Profiler->VisitStmt(C->getThreadLimit());
Kelvin Lia15fb1a2015-11-27 18:47:36 +0000710}
Alexey Bataeva0569352015-12-01 10:17:31 +0000711void OMPClauseProfiler::VisitOMPPriorityClause(const OMPPriorityClause *C) {
Richard Trieu6a77a1c2016-06-10 04:52:09 +0000712 if (C->getPriority())
713 Profiler->VisitStmt(C->getPriority());
Alexey Bataeva0569352015-12-01 10:17:31 +0000714}
Alexey Bataev1fd4aed2015-12-07 12:52:51 +0000715void OMPClauseProfiler::VisitOMPGrainsizeClause(const OMPGrainsizeClause *C) {
Richard Trieu6a77a1c2016-06-10 04:52:09 +0000716 if (C->getGrainsize())
717 Profiler->VisitStmt(C->getGrainsize());
Alexey Bataev1fd4aed2015-12-07 12:52:51 +0000718}
Alexey Bataev382967a2015-12-08 12:06:20 +0000719void OMPClauseProfiler::VisitOMPNumTasksClause(const OMPNumTasksClause *C) {
Richard Trieu6a77a1c2016-06-10 04:52:09 +0000720 if (C->getNumTasks())
721 Profiler->VisitStmt(C->getNumTasks());
Alexey Bataev382967a2015-12-08 12:06:20 +0000722}
Alexey Bataev28c75412015-12-15 08:19:24 +0000723void OMPClauseProfiler::VisitOMPHintClause(const OMPHintClause *C) {
Richard Trieu6a77a1c2016-06-10 04:52:09 +0000724 if (C->getHint())
725 Profiler->VisitStmt(C->getHint());
Alexey Bataev28c75412015-12-15 08:19:24 +0000726}
Samuel Antao661c0902016-05-26 17:39:58 +0000727void OMPClauseProfiler::VisitOMPToClause(const OMPToClause *C) {
728 VisitOMPClauseList(C);
729}
Samuel Antaoec172c62016-05-26 17:49:04 +0000730void OMPClauseProfiler::VisitOMPFromClause(const OMPFromClause *C) {
731 VisitOMPClauseList(C);
732}
Carlo Bertolli2404b172016-07-13 15:37:16 +0000733void OMPClauseProfiler::VisitOMPUseDevicePtrClause(
734 const OMPUseDevicePtrClause *C) {
735 VisitOMPClauseList(C);
736}
Carlo Bertolli70594e92016-07-13 17:16:49 +0000737void OMPClauseProfiler::VisitOMPIsDevicePtrClause(
738 const OMPIsDevicePtrClause *C) {
739 VisitOMPClauseList(C);
740}
Alexander Kornienkoab9db512015-06-22 23:07:51 +0000741}
Alexey Bataev5ec3eb12013-07-19 03:13:43 +0000742
743void
Alexey Bataev1b59ab52014-02-27 08:29:12 +0000744StmtProfiler::VisitOMPExecutableDirective(const OMPExecutableDirective *S) {
Alexey Bataev5ec3eb12013-07-19 03:13:43 +0000745 VisitStmt(S);
746 OMPClauseProfiler P(this);
747 ArrayRef<OMPClause *> Clauses = S->clauses();
748 for (ArrayRef<OMPClause *>::iterator I = Clauses.begin(), E = Clauses.end();
749 I != E; ++I)
750 if (*I)
751 P.Visit(*I);
752}
753
Alexander Musman3aaab662014-08-19 11:27:13 +0000754void StmtProfiler::VisitOMPLoopDirective(const OMPLoopDirective *S) {
755 VisitOMPExecutableDirective(S);
756}
757
Alexey Bataev1b59ab52014-02-27 08:29:12 +0000758void StmtProfiler::VisitOMPParallelDirective(const OMPParallelDirective *S) {
759 VisitOMPExecutableDirective(S);
760}
761
762void StmtProfiler::VisitOMPSimdDirective(const OMPSimdDirective *S) {
Alexander Musman3aaab662014-08-19 11:27:13 +0000763 VisitOMPLoopDirective(S);
Alexey Bataev1b59ab52014-02-27 08:29:12 +0000764}
765
Alexey Bataevf29276e2014-06-18 04:14:57 +0000766void StmtProfiler::VisitOMPForDirective(const OMPForDirective *S) {
Alexander Musman3aaab662014-08-19 11:27:13 +0000767 VisitOMPLoopDirective(S);
Alexey Bataevf29276e2014-06-18 04:14:57 +0000768}
769
Alexander Musmanf82886e2014-09-18 05:12:34 +0000770void StmtProfiler::VisitOMPForSimdDirective(const OMPForSimdDirective *S) {
771 VisitOMPLoopDirective(S);
772}
773
Alexey Bataevd3f8dd22014-06-25 11:44:49 +0000774void StmtProfiler::VisitOMPSectionsDirective(const OMPSectionsDirective *S) {
775 VisitOMPExecutableDirective(S);
776}
777
Alexey Bataev1e0498a2014-06-26 08:21:58 +0000778void StmtProfiler::VisitOMPSectionDirective(const OMPSectionDirective *S) {
779 VisitOMPExecutableDirective(S);
780}
781
Alexey Bataevd1e40fb2014-06-26 12:05:45 +0000782void StmtProfiler::VisitOMPSingleDirective(const OMPSingleDirective *S) {
783 VisitOMPExecutableDirective(S);
784}
785
Alexander Musman80c22892014-07-17 08:54:58 +0000786void StmtProfiler::VisitOMPMasterDirective(const OMPMasterDirective *S) {
787 VisitOMPExecutableDirective(S);
788}
789
Alexander Musmand9ed09f2014-07-21 09:42:05 +0000790void StmtProfiler::VisitOMPCriticalDirective(const OMPCriticalDirective *S) {
791 VisitOMPExecutableDirective(S);
792 VisitName(S->getDirectiveName().getName());
793}
794
Alexey Bataev4acb8592014-07-07 13:01:15 +0000795void
796StmtProfiler::VisitOMPParallelForDirective(const OMPParallelForDirective *S) {
Alexander Musman3aaab662014-08-19 11:27:13 +0000797 VisitOMPLoopDirective(S);
Alexey Bataev4acb8592014-07-07 13:01:15 +0000798}
799
Alexander Musmane4e893b2014-09-23 09:33:00 +0000800void StmtProfiler::VisitOMPParallelForSimdDirective(
801 const OMPParallelForSimdDirective *S) {
802 VisitOMPLoopDirective(S);
803}
804
Alexey Bataev84d0b3e2014-07-08 08:12:03 +0000805void StmtProfiler::VisitOMPParallelSectionsDirective(
806 const OMPParallelSectionsDirective *S) {
807 VisitOMPExecutableDirective(S);
808}
809
Alexey Bataev9c2e8ee2014-07-11 11:25:16 +0000810void StmtProfiler::VisitOMPTaskDirective(const OMPTaskDirective *S) {
811 VisitOMPExecutableDirective(S);
812}
813
Alexey Bataev68446b72014-07-18 07:47:19 +0000814void StmtProfiler::VisitOMPTaskyieldDirective(const OMPTaskyieldDirective *S) {
815 VisitOMPExecutableDirective(S);
816}
817
Alexey Bataev4d1dfea2014-07-18 09:11:51 +0000818void StmtProfiler::VisitOMPBarrierDirective(const OMPBarrierDirective *S) {
819 VisitOMPExecutableDirective(S);
820}
821
Alexey Bataev2df347a2014-07-18 10:17:07 +0000822void StmtProfiler::VisitOMPTaskwaitDirective(const OMPTaskwaitDirective *S) {
823 VisitOMPExecutableDirective(S);
824}
825
Alexey Bataevc30dd2d2015-06-18 12:14:09 +0000826void StmtProfiler::VisitOMPTaskgroupDirective(const OMPTaskgroupDirective *S) {
827 VisitOMPExecutableDirective(S);
Alexey Bataev3b1b8952017-07-25 15:53:26 +0000828 if (const Expr *E = S->getReductionRef())
829 VisitStmt(E);
Alexey Bataevc30dd2d2015-06-18 12:14:09 +0000830}
831
Alexey Bataev6125da92014-07-21 11:26:11 +0000832void StmtProfiler::VisitOMPFlushDirective(const OMPFlushDirective *S) {
833 VisitOMPExecutableDirective(S);
834}
835
Alexey Bataev9fb6e642014-07-22 06:45:04 +0000836void StmtProfiler::VisitOMPOrderedDirective(const OMPOrderedDirective *S) {
837 VisitOMPExecutableDirective(S);
838}
839
Alexey Bataev0162e452014-07-22 10:10:35 +0000840void StmtProfiler::VisitOMPAtomicDirective(const OMPAtomicDirective *S) {
841 VisitOMPExecutableDirective(S);
842}
843
Alexey Bataev0bd520b2014-09-19 08:19:49 +0000844void StmtProfiler::VisitOMPTargetDirective(const OMPTargetDirective *S) {
845 VisitOMPExecutableDirective(S);
846}
847
Michael Wong65f367f2015-07-21 13:44:28 +0000848void StmtProfiler::VisitOMPTargetDataDirective(const OMPTargetDataDirective *S) {
849 VisitOMPExecutableDirective(S);
850}
851
Samuel Antaodf67fc42016-01-19 19:15:56 +0000852void StmtProfiler::VisitOMPTargetEnterDataDirective(
853 const OMPTargetEnterDataDirective *S) {
854 VisitOMPExecutableDirective(S);
855}
856
Samuel Antao72590762016-01-19 20:04:50 +0000857void StmtProfiler::VisitOMPTargetExitDataDirective(
858 const OMPTargetExitDataDirective *S) {
859 VisitOMPExecutableDirective(S);
860}
861
Arpith Chacko Jacobe955b3d2016-01-26 18:48:41 +0000862void StmtProfiler::VisitOMPTargetParallelDirective(
863 const OMPTargetParallelDirective *S) {
864 VisitOMPExecutableDirective(S);
865}
866
Arpith Chacko Jacob05bebb52016-02-03 15:46:42 +0000867void StmtProfiler::VisitOMPTargetParallelForDirective(
868 const OMPTargetParallelForDirective *S) {
869 VisitOMPExecutableDirective(S);
870}
871
Alexey Bataev13314bf2014-10-09 04:18:56 +0000872void StmtProfiler::VisitOMPTeamsDirective(const OMPTeamsDirective *S) {
873 VisitOMPExecutableDirective(S);
874}
875
Alexey Bataev6d4ed052015-07-01 06:57:41 +0000876void StmtProfiler::VisitOMPCancellationPointDirective(
877 const OMPCancellationPointDirective *S) {
878 VisitOMPExecutableDirective(S);
879}
880
Alexey Bataev80909872015-07-02 11:25:17 +0000881void StmtProfiler::VisitOMPCancelDirective(const OMPCancelDirective *S) {
882 VisitOMPExecutableDirective(S);
883}
884
Alexey Bataev49f6e782015-12-01 04:18:41 +0000885void StmtProfiler::VisitOMPTaskLoopDirective(const OMPTaskLoopDirective *S) {
886 VisitOMPLoopDirective(S);
887}
888
Alexey Bataev0a6ed842015-12-03 09:40:15 +0000889void StmtProfiler::VisitOMPTaskLoopSimdDirective(
890 const OMPTaskLoopSimdDirective *S) {
891 VisitOMPLoopDirective(S);
892}
893
Carlo Bertolli6200a3d2015-12-14 14:51:25 +0000894void StmtProfiler::VisitOMPDistributeDirective(
895 const OMPDistributeDirective *S) {
896 VisitOMPLoopDirective(S);
897}
898
Carlo Bertollib4adf552016-01-15 18:50:31 +0000899void OMPClauseProfiler::VisitOMPDistScheduleClause(
900 const OMPDistScheduleClause *C) {
Alexey Bataev3392d762016-02-16 11:18:12 +0000901 VistOMPClauseWithPreInit(C);
902 if (auto *S = C->getChunkSize())
903 Profiler->VisitStmt(S);
Carlo Bertollib4adf552016-01-15 18:50:31 +0000904}
905
Arpith Chacko Jacob3cf89042016-01-26 16:37:23 +0000906void OMPClauseProfiler::VisitOMPDefaultmapClause(const OMPDefaultmapClause *) {}
907
Samuel Antao686c70c2016-05-26 17:30:50 +0000908void StmtProfiler::VisitOMPTargetUpdateDirective(
909 const OMPTargetUpdateDirective *S) {
910 VisitOMPExecutableDirective(S);
911}
912
Carlo Bertolli9925f152016-06-27 14:55:37 +0000913void StmtProfiler::VisitOMPDistributeParallelForDirective(
914 const OMPDistributeParallelForDirective *S) {
915 VisitOMPLoopDirective(S);
916}
917
Kelvin Li4a39add2016-07-05 05:00:15 +0000918void StmtProfiler::VisitOMPDistributeParallelForSimdDirective(
919 const OMPDistributeParallelForSimdDirective *S) {
920 VisitOMPLoopDirective(S);
921}
922
Kelvin Li787f3fc2016-07-06 04:45:38 +0000923void StmtProfiler::VisitOMPDistributeSimdDirective(
924 const OMPDistributeSimdDirective *S) {
925 VisitOMPLoopDirective(S);
926}
927
Kelvin Lia579b912016-07-14 02:54:56 +0000928void StmtProfiler::VisitOMPTargetParallelForSimdDirective(
929 const OMPTargetParallelForSimdDirective *S) {
930 VisitOMPLoopDirective(S);
931}
932
Kelvin Li986330c2016-07-20 22:57:10 +0000933void StmtProfiler::VisitOMPTargetSimdDirective(
934 const OMPTargetSimdDirective *S) {
935 VisitOMPLoopDirective(S);
936}
937
Kelvin Li02532872016-08-05 14:37:37 +0000938void StmtProfiler::VisitOMPTeamsDistributeDirective(
939 const OMPTeamsDistributeDirective *S) {
940 VisitOMPLoopDirective(S);
941}
942
Kelvin Li4e325f72016-10-25 12:50:55 +0000943void StmtProfiler::VisitOMPTeamsDistributeSimdDirective(
944 const OMPTeamsDistributeSimdDirective *S) {
945 VisitOMPLoopDirective(S);
946}
947
Kelvin Li579e41c2016-11-30 23:51:03 +0000948void StmtProfiler::VisitOMPTeamsDistributeParallelForSimdDirective(
949 const OMPTeamsDistributeParallelForSimdDirective *S) {
950 VisitOMPLoopDirective(S);
951}
952
Kelvin Li7ade93f2016-12-09 03:24:30 +0000953void StmtProfiler::VisitOMPTeamsDistributeParallelForDirective(
954 const OMPTeamsDistributeParallelForDirective *S) {
955 VisitOMPLoopDirective(S);
956}
957
Kelvin Libf594a52016-12-17 05:48:59 +0000958void StmtProfiler::VisitOMPTargetTeamsDirective(
959 const OMPTargetTeamsDirective *S) {
960 VisitOMPExecutableDirective(S);
961}
962
Kelvin Li83c451e2016-12-25 04:52:54 +0000963void StmtProfiler::VisitOMPTargetTeamsDistributeDirective(
964 const OMPTargetTeamsDistributeDirective *S) {
965 VisitOMPLoopDirective(S);
966}
967
Kelvin Li80e8f562016-12-29 22:16:30 +0000968void StmtProfiler::VisitOMPTargetTeamsDistributeParallelForDirective(
969 const OMPTargetTeamsDistributeParallelForDirective *S) {
970 VisitOMPLoopDirective(S);
971}
972
Kelvin Li1851df52017-01-03 05:23:48 +0000973void StmtProfiler::VisitOMPTargetTeamsDistributeParallelForSimdDirective(
974 const OMPTargetTeamsDistributeParallelForSimdDirective *S) {
975 VisitOMPLoopDirective(S);
976}
977
Kelvin Lida681182017-01-10 18:08:18 +0000978void StmtProfiler::VisitOMPTargetTeamsDistributeSimdDirective(
979 const OMPTargetTeamsDistributeSimdDirective *S) {
980 VisitOMPLoopDirective(S);
981}
982
Chandler Carruth631abd92011-06-16 06:47:06 +0000983void StmtProfiler::VisitExpr(const Expr *S) {
Douglas Gregor5c193b92009-07-28 00:33:38 +0000984 VisitStmt(S);
985}
986
Chandler Carruth631abd92011-06-16 06:47:06 +0000987void StmtProfiler::VisitDeclRefExpr(const DeclRefExpr *S) {
Douglas Gregor5c193b92009-07-28 00:33:38 +0000988 VisitExpr(S);
Douglas Gregorf5b160f2010-07-13 08:37:11 +0000989 if (!Canonical)
990 VisitNestedNameSpecifier(S->getQualifier());
Douglas Gregor5c193b92009-07-28 00:33:38 +0000991 VisitDecl(S->getDecl());
Richard Trieu4d06bef2018-02-13 19:53:40 +0000992 if (!Canonical) {
993 ID.AddBoolean(S->hasExplicitTemplateArgs());
994 if (S->hasExplicitTemplateArgs())
995 VisitTemplateArguments(S->getTemplateArgs(), S->getNumTemplateArgs());
996 }
Douglas Gregor5c193b92009-07-28 00:33:38 +0000997}
998
Chandler Carruth631abd92011-06-16 06:47:06 +0000999void StmtProfiler::VisitPredefinedExpr(const PredefinedExpr *S) {
Douglas Gregor5c193b92009-07-28 00:33:38 +00001000 VisitExpr(S);
1001 ID.AddInteger(S->getIdentType());
1002}
1003
Chandler Carruth631abd92011-06-16 06:47:06 +00001004void StmtProfiler::VisitIntegerLiteral(const IntegerLiteral *S) {
Douglas Gregor5c193b92009-07-28 00:33:38 +00001005 VisitExpr(S);
1006 S->getValue().Profile(ID);
Richard Smithe9f130c2014-11-20 03:37:32 +00001007 ID.AddInteger(S->getType()->castAs<BuiltinType>()->getKind());
Douglas Gregor5c193b92009-07-28 00:33:38 +00001008}
1009
Leonard Chandb01c3a2018-06-20 17:19:40 +00001010void StmtProfiler::VisitFixedPointLiteral(const FixedPointLiteral *S) {
1011 VisitExpr(S);
1012 S->getValue().Profile(ID);
1013 ID.AddInteger(S->getType()->castAs<BuiltinType>()->getKind());
1014}
1015
Chandler Carruth631abd92011-06-16 06:47:06 +00001016void StmtProfiler::VisitCharacterLiteral(const CharacterLiteral *S) {
Douglas Gregor5c193b92009-07-28 00:33:38 +00001017 VisitExpr(S);
Douglas Gregorfb65e592011-07-27 05:40:30 +00001018 ID.AddInteger(S->getKind());
Douglas Gregor5c193b92009-07-28 00:33:38 +00001019 ID.AddInteger(S->getValue());
1020}
1021
Chandler Carruth631abd92011-06-16 06:47:06 +00001022void StmtProfiler::VisitFloatingLiteral(const FloatingLiteral *S) {
Douglas Gregor5c193b92009-07-28 00:33:38 +00001023 VisitExpr(S);
1024 S->getValue().Profile(ID);
1025 ID.AddBoolean(S->isExact());
Richard Smithe9f130c2014-11-20 03:37:32 +00001026 ID.AddInteger(S->getType()->castAs<BuiltinType>()->getKind());
Douglas Gregor5c193b92009-07-28 00:33:38 +00001027}
1028
Chandler Carruth631abd92011-06-16 06:47:06 +00001029void StmtProfiler::VisitImaginaryLiteral(const ImaginaryLiteral *S) {
Douglas Gregor5c193b92009-07-28 00:33:38 +00001030 VisitExpr(S);
1031}
1032
Chandler Carruth631abd92011-06-16 06:47:06 +00001033void StmtProfiler::VisitStringLiteral(const StringLiteral *S) {
Douglas Gregor5c193b92009-07-28 00:33:38 +00001034 VisitExpr(S);
Douglas Gregor9d0eb8f2011-11-02 17:26:05 +00001035 ID.AddString(S->getBytes());
Douglas Gregorfb65e592011-07-27 05:40:30 +00001036 ID.AddInteger(S->getKind());
Douglas Gregor5c193b92009-07-28 00:33:38 +00001037}
1038
Chandler Carruth631abd92011-06-16 06:47:06 +00001039void StmtProfiler::VisitParenExpr(const ParenExpr *S) {
Douglas Gregor5c193b92009-07-28 00:33:38 +00001040 VisitExpr(S);
1041}
1042
Chandler Carruth631abd92011-06-16 06:47:06 +00001043void StmtProfiler::VisitParenListExpr(const ParenListExpr *S) {
Nate Begeman5ec4b312009-08-10 23:49:36 +00001044 VisitExpr(S);
1045}
1046
Chandler Carruth631abd92011-06-16 06:47:06 +00001047void StmtProfiler::VisitUnaryOperator(const UnaryOperator *S) {
Douglas Gregor5c193b92009-07-28 00:33:38 +00001048 VisitExpr(S);
1049 ID.AddInteger(S->getOpcode());
1050}
1051
Chandler Carruth631abd92011-06-16 06:47:06 +00001052void StmtProfiler::VisitOffsetOfExpr(const OffsetOfExpr *S) {
Douglas Gregor882211c2010-04-28 22:16:22 +00001053 VisitType(S->getTypeSourceInfo()->getType());
1054 unsigned n = S->getNumComponents();
1055 for (unsigned i = 0; i < n; ++i) {
James Y Knight7281c352015-12-29 22:31:18 +00001056 const OffsetOfNode &ON = S->getComponent(i);
Douglas Gregor882211c2010-04-28 22:16:22 +00001057 ID.AddInteger(ON.getKind());
1058 switch (ON.getKind()) {
James Y Knight7281c352015-12-29 22:31:18 +00001059 case OffsetOfNode::Array:
Douglas Gregor882211c2010-04-28 22:16:22 +00001060 // Expressions handled below.
1061 break;
1062
James Y Knight7281c352015-12-29 22:31:18 +00001063 case OffsetOfNode::Field:
Douglas Gregor882211c2010-04-28 22:16:22 +00001064 VisitDecl(ON.getField());
1065 break;
1066
James Y Knight7281c352015-12-29 22:31:18 +00001067 case OffsetOfNode::Identifier:
Richard Trieu639d7b62017-02-22 22:22:42 +00001068 VisitIdentifierInfo(ON.getFieldName());
Douglas Gregor882211c2010-04-28 22:16:22 +00001069 break;
James Y Knight7281c352015-12-29 22:31:18 +00001070
1071 case OffsetOfNode::Base:
Douglas Gregord1702062010-04-29 00:18:15 +00001072 // These nodes are implicit, and therefore don't need profiling.
1073 break;
Douglas Gregor882211c2010-04-28 22:16:22 +00001074 }
1075 }
Richard Trieu639d7b62017-02-22 22:22:42 +00001076
Douglas Gregor882211c2010-04-28 22:16:22 +00001077 VisitExpr(S);
1078}
1079
Chandler Carruth631abd92011-06-16 06:47:06 +00001080void
1081StmtProfiler::VisitUnaryExprOrTypeTraitExpr(const UnaryExprOrTypeTraitExpr *S) {
Douglas Gregor5c193b92009-07-28 00:33:38 +00001082 VisitExpr(S);
Peter Collingbournee190dee2011-03-11 19:24:49 +00001083 ID.AddInteger(S->getKind());
Douglas Gregor5c193b92009-07-28 00:33:38 +00001084 if (S->isArgumentType())
1085 VisitType(S->getArgumentType());
1086}
1087
Chandler Carruth631abd92011-06-16 06:47:06 +00001088void StmtProfiler::VisitArraySubscriptExpr(const ArraySubscriptExpr *S) {
Douglas Gregor5c193b92009-07-28 00:33:38 +00001089 VisitExpr(S);
1090}
1091
Alexey Bataev1a3320e2015-08-25 14:24:04 +00001092void StmtProfiler::VisitOMPArraySectionExpr(const OMPArraySectionExpr *S) {
1093 VisitExpr(S);
1094}
1095
Chandler Carruth631abd92011-06-16 06:47:06 +00001096void StmtProfiler::VisitCallExpr(const CallExpr *S) {
Douglas Gregor5c193b92009-07-28 00:33:38 +00001097 VisitExpr(S);
1098}
1099
Chandler Carruth631abd92011-06-16 06:47:06 +00001100void StmtProfiler::VisitMemberExpr(const MemberExpr *S) {
Douglas Gregor5c193b92009-07-28 00:33:38 +00001101 VisitExpr(S);
1102 VisitDecl(S->getMemberDecl());
Douglas Gregorf5b160f2010-07-13 08:37:11 +00001103 if (!Canonical)
1104 VisitNestedNameSpecifier(S->getQualifier());
Douglas Gregor5c193b92009-07-28 00:33:38 +00001105 ID.AddBoolean(S->isArrow());
1106}
1107
Chandler Carruth631abd92011-06-16 06:47:06 +00001108void StmtProfiler::VisitCompoundLiteralExpr(const CompoundLiteralExpr *S) {
Douglas Gregor5c193b92009-07-28 00:33:38 +00001109 VisitExpr(S);
1110 ID.AddBoolean(S->isFileScope());
1111}
1112
Chandler Carruth631abd92011-06-16 06:47:06 +00001113void StmtProfiler::VisitCastExpr(const CastExpr *S) {
Douglas Gregor5c193b92009-07-28 00:33:38 +00001114 VisitExpr(S);
1115}
1116
Chandler Carruth631abd92011-06-16 06:47:06 +00001117void StmtProfiler::VisitImplicitCastExpr(const ImplicitCastExpr *S) {
Douglas Gregor5c193b92009-07-28 00:33:38 +00001118 VisitCastExpr(S);
John McCall2536c6d2010-08-25 10:28:54 +00001119 ID.AddInteger(S->getValueKind());
Douglas Gregor5c193b92009-07-28 00:33:38 +00001120}
1121
Chandler Carruth631abd92011-06-16 06:47:06 +00001122void StmtProfiler::VisitExplicitCastExpr(const ExplicitCastExpr *S) {
Douglas Gregor5c193b92009-07-28 00:33:38 +00001123 VisitCastExpr(S);
1124 VisitType(S->getTypeAsWritten());
1125}
1126
Chandler Carruth631abd92011-06-16 06:47:06 +00001127void StmtProfiler::VisitCStyleCastExpr(const CStyleCastExpr *S) {
Douglas Gregor5c193b92009-07-28 00:33:38 +00001128 VisitExplicitCastExpr(S);
1129}
1130
Chandler Carruth631abd92011-06-16 06:47:06 +00001131void StmtProfiler::VisitBinaryOperator(const BinaryOperator *S) {
Douglas Gregor5c193b92009-07-28 00:33:38 +00001132 VisitExpr(S);
1133 ID.AddInteger(S->getOpcode());
1134}
1135
Chandler Carruth631abd92011-06-16 06:47:06 +00001136void
1137StmtProfiler::VisitCompoundAssignOperator(const CompoundAssignOperator *S) {
Douglas Gregor5c193b92009-07-28 00:33:38 +00001138 VisitBinaryOperator(S);
1139}
1140
Chandler Carruth631abd92011-06-16 06:47:06 +00001141void StmtProfiler::VisitConditionalOperator(const ConditionalOperator *S) {
Douglas Gregor5c193b92009-07-28 00:33:38 +00001142 VisitExpr(S);
1143}
1144
Chandler Carruth631abd92011-06-16 06:47:06 +00001145void StmtProfiler::VisitBinaryConditionalOperator(
Chandler Carruthcf5f43c2011-06-21 23:26:32 +00001146 const BinaryConditionalOperator *S) {
John McCallc07a0c72011-02-17 10:25:35 +00001147 VisitExpr(S);
1148}
1149
Chandler Carruth631abd92011-06-16 06:47:06 +00001150void StmtProfiler::VisitAddrLabelExpr(const AddrLabelExpr *S) {
Douglas Gregor5c193b92009-07-28 00:33:38 +00001151 VisitExpr(S);
Chris Lattnerc8e630e2011-02-17 07:39:24 +00001152 VisitDecl(S->getLabel());
Douglas Gregor5c193b92009-07-28 00:33:38 +00001153}
1154
Chandler Carruth631abd92011-06-16 06:47:06 +00001155void StmtProfiler::VisitStmtExpr(const StmtExpr *S) {
Douglas Gregor5c193b92009-07-28 00:33:38 +00001156 VisitExpr(S);
1157}
1158
Chandler Carruth631abd92011-06-16 06:47:06 +00001159void StmtProfiler::VisitShuffleVectorExpr(const ShuffleVectorExpr *S) {
Douglas Gregor5c193b92009-07-28 00:33:38 +00001160 VisitExpr(S);
1161}
1162
Hal Finkelc4d7c822013-09-18 03:29:45 +00001163void StmtProfiler::VisitConvertVectorExpr(const ConvertVectorExpr *S) {
1164 VisitExpr(S);
1165}
1166
Chandler Carruth631abd92011-06-16 06:47:06 +00001167void StmtProfiler::VisitChooseExpr(const ChooseExpr *S) {
Douglas Gregor5c193b92009-07-28 00:33:38 +00001168 VisitExpr(S);
1169}
1170
Chandler Carruth631abd92011-06-16 06:47:06 +00001171void StmtProfiler::VisitGNUNullExpr(const GNUNullExpr *S) {
Douglas Gregor5c193b92009-07-28 00:33:38 +00001172 VisitExpr(S);
1173}
1174
Chandler Carruth631abd92011-06-16 06:47:06 +00001175void StmtProfiler::VisitVAArgExpr(const VAArgExpr *S) {
Douglas Gregor00044172009-07-29 16:09:57 +00001176 VisitExpr(S);
1177}
1178
Chandler Carruth631abd92011-06-16 06:47:06 +00001179void StmtProfiler::VisitInitListExpr(const InitListExpr *S) {
Douglas Gregor5c193b92009-07-28 00:33:38 +00001180 if (S->getSyntacticForm()) {
1181 VisitInitListExpr(S->getSyntacticForm());
1182 return;
1183 }
Mike Stump11289f42009-09-09 15:08:12 +00001184
Douglas Gregor5c193b92009-07-28 00:33:38 +00001185 VisitExpr(S);
1186}
1187
Chandler Carruth631abd92011-06-16 06:47:06 +00001188void StmtProfiler::VisitDesignatedInitExpr(const DesignatedInitExpr *S) {
Douglas Gregor5c193b92009-07-28 00:33:38 +00001189 VisitExpr(S);
1190 ID.AddBoolean(S->usesGNUSyntax());
David Majnemerf7e36092016-06-23 00:15:04 +00001191 for (const DesignatedInitExpr::Designator &D : S->designators()) {
1192 if (D.isFieldDesignator()) {
Douglas Gregor5c193b92009-07-28 00:33:38 +00001193 ID.AddInteger(0);
David Majnemerf7e36092016-06-23 00:15:04 +00001194 VisitName(D.getFieldName());
Douglas Gregor5c193b92009-07-28 00:33:38 +00001195 continue;
1196 }
Mike Stump11289f42009-09-09 15:08:12 +00001197
David Majnemerf7e36092016-06-23 00:15:04 +00001198 if (D.isArrayDesignator()) {
Douglas Gregor5c193b92009-07-28 00:33:38 +00001199 ID.AddInteger(1);
1200 } else {
David Majnemerf7e36092016-06-23 00:15:04 +00001201 assert(D.isArrayRangeDesignator());
Douglas Gregor5c193b92009-07-28 00:33:38 +00001202 ID.AddInteger(2);
1203 }
David Majnemerf7e36092016-06-23 00:15:04 +00001204 ID.AddInteger(D.getFirstExprIndex());
Douglas Gregor5c193b92009-07-28 00:33:38 +00001205 }
1206}
1207
Yunzhong Gaocb779302015-06-10 00:27:52 +00001208// Seems that if VisitInitListExpr() only works on the syntactic form of an
1209// InitListExpr, then a DesignatedInitUpdateExpr is not encountered.
1210void StmtProfiler::VisitDesignatedInitUpdateExpr(
1211 const DesignatedInitUpdateExpr *S) {
1212 llvm_unreachable("Unexpected DesignatedInitUpdateExpr in syntactic form of "
1213 "initializer");
1214}
1215
Richard Smith410306b2016-12-12 02:53:20 +00001216void StmtProfiler::VisitArrayInitLoopExpr(const ArrayInitLoopExpr *S) {
1217 VisitExpr(S);
1218}
1219
1220void StmtProfiler::VisitArrayInitIndexExpr(const ArrayInitIndexExpr *S) {
1221 VisitExpr(S);
1222}
1223
Yunzhong Gaocb779302015-06-10 00:27:52 +00001224void StmtProfiler::VisitNoInitExpr(const NoInitExpr *S) {
1225 llvm_unreachable("Unexpected NoInitExpr in syntactic form of initializer");
1226}
1227
Chandler Carruth631abd92011-06-16 06:47:06 +00001228void StmtProfiler::VisitImplicitValueInitExpr(const ImplicitValueInitExpr *S) {
Douglas Gregor5c193b92009-07-28 00:33:38 +00001229 VisitExpr(S);
1230}
1231
Chandler Carruth631abd92011-06-16 06:47:06 +00001232void StmtProfiler::VisitExtVectorElementExpr(const ExtVectorElementExpr *S) {
Douglas Gregor5c193b92009-07-28 00:33:38 +00001233 VisitExpr(S);
1234 VisitName(&S->getAccessor());
1235}
1236
Chandler Carruth631abd92011-06-16 06:47:06 +00001237void StmtProfiler::VisitBlockExpr(const BlockExpr *S) {
Douglas Gregor5c193b92009-07-28 00:33:38 +00001238 VisitExpr(S);
1239 VisitDecl(S->getBlockDecl());
1240}
1241
Chandler Carruth631abd92011-06-16 06:47:06 +00001242void StmtProfiler::VisitGenericSelectionExpr(const GenericSelectionExpr *S) {
Peter Collingbourne91147592011-04-15 00:35:48 +00001243 VisitExpr(S);
1244 for (unsigned i = 0; i != S->getNumAssocs(); ++i) {
1245 QualType T = S->getAssocType(i);
1246 if (T.isNull())
Craig Topper36250ad2014-05-12 05:36:57 +00001247 ID.AddPointer(nullptr);
Peter Collingbourne91147592011-04-15 00:35:48 +00001248 else
1249 VisitType(T);
1250 VisitExpr(S->getAssocExpr(i));
1251 }
1252}
1253
John McCallfe96e0b2011-11-06 09:01:30 +00001254void StmtProfiler::VisitPseudoObjectExpr(const PseudoObjectExpr *S) {
1255 VisitExpr(S);
1256 for (PseudoObjectExpr::const_semantics_iterator
1257 i = S->semantics_begin(), e = S->semantics_end(); i != e; ++i)
1258 // Normally, we would not profile the source expressions of OVEs.
1259 if (const OpaqueValueExpr *OVE = dyn_cast<OpaqueValueExpr>(*i))
1260 Visit(OVE->getSourceExpr());
1261}
1262
Eli Friedmandf14b3a2011-10-11 02:20:01 +00001263void StmtProfiler::VisitAtomicExpr(const AtomicExpr *S) {
1264 VisitExpr(S);
Eli Friedman4b72fdd2011-10-14 20:59:01 +00001265 ID.AddInteger(S->getOp());
Eli Friedmandf14b3a2011-10-11 02:20:01 +00001266}
1267
Chandler Carruth631abd92011-06-16 06:47:06 +00001268static Stmt::StmtClass DecodeOperatorCall(const CXXOperatorCallExpr *S,
John McCalle3027922010-08-25 11:45:40 +00001269 UnaryOperatorKind &UnaryOp,
1270 BinaryOperatorKind &BinaryOp) {
Douglas Gregore9ceb312010-05-19 04:13:23 +00001271 switch (S->getOperator()) {
1272 case OO_None:
1273 case OO_New:
1274 case OO_Delete:
1275 case OO_Array_New:
1276 case OO_Array_Delete:
1277 case OO_Arrow:
1278 case OO_Call:
1279 case OO_Conditional:
1280 case NUM_OVERLOADED_OPERATORS:
1281 llvm_unreachable("Invalid operator call kind");
Fangrui Song6907ce22018-07-30 19:24:48 +00001282
Douglas Gregore9ceb312010-05-19 04:13:23 +00001283 case OO_Plus:
1284 if (S->getNumArgs() == 1) {
John McCalle3027922010-08-25 11:45:40 +00001285 UnaryOp = UO_Plus;
Douglas Gregore9ceb312010-05-19 04:13:23 +00001286 return Stmt::UnaryOperatorClass;
1287 }
Fangrui Song6907ce22018-07-30 19:24:48 +00001288
John McCalle3027922010-08-25 11:45:40 +00001289 BinaryOp = BO_Add;
Douglas Gregore9ceb312010-05-19 04:13:23 +00001290 return Stmt::BinaryOperatorClass;
Fangrui Song6907ce22018-07-30 19:24:48 +00001291
Douglas Gregore9ceb312010-05-19 04:13:23 +00001292 case OO_Minus:
1293 if (S->getNumArgs() == 1) {
John McCalle3027922010-08-25 11:45:40 +00001294 UnaryOp = UO_Minus;
Douglas Gregore9ceb312010-05-19 04:13:23 +00001295 return Stmt::UnaryOperatorClass;
1296 }
Fangrui Song6907ce22018-07-30 19:24:48 +00001297
John McCalle3027922010-08-25 11:45:40 +00001298 BinaryOp = BO_Sub;
Douglas Gregore9ceb312010-05-19 04:13:23 +00001299 return Stmt::BinaryOperatorClass;
1300
1301 case OO_Star:
1302 if (S->getNumArgs() == 1) {
Richard Smithf15acc52014-06-05 22:43:40 +00001303 UnaryOp = UO_Deref;
Douglas Gregore9ceb312010-05-19 04:13:23 +00001304 return Stmt::UnaryOperatorClass;
1305 }
Fangrui Song6907ce22018-07-30 19:24:48 +00001306
Richard Smithf15acc52014-06-05 22:43:40 +00001307 BinaryOp = BO_Mul;
Douglas Gregore9ceb312010-05-19 04:13:23 +00001308 return Stmt::BinaryOperatorClass;
1309
1310 case OO_Slash:
John McCalle3027922010-08-25 11:45:40 +00001311 BinaryOp = BO_Div;
Douglas Gregore9ceb312010-05-19 04:13:23 +00001312 return Stmt::BinaryOperatorClass;
Fangrui Song6907ce22018-07-30 19:24:48 +00001313
Douglas Gregore9ceb312010-05-19 04:13:23 +00001314 case OO_Percent:
John McCalle3027922010-08-25 11:45:40 +00001315 BinaryOp = BO_Rem;
Douglas Gregore9ceb312010-05-19 04:13:23 +00001316 return Stmt::BinaryOperatorClass;
1317
1318 case OO_Caret:
John McCalle3027922010-08-25 11:45:40 +00001319 BinaryOp = BO_Xor;
Douglas Gregore9ceb312010-05-19 04:13:23 +00001320 return Stmt::BinaryOperatorClass;
1321
1322 case OO_Amp:
1323 if (S->getNumArgs() == 1) {
John McCalle3027922010-08-25 11:45:40 +00001324 UnaryOp = UO_AddrOf;
Douglas Gregore9ceb312010-05-19 04:13:23 +00001325 return Stmt::UnaryOperatorClass;
1326 }
Fangrui Song6907ce22018-07-30 19:24:48 +00001327
John McCalle3027922010-08-25 11:45:40 +00001328 BinaryOp = BO_And;
Douglas Gregore9ceb312010-05-19 04:13:23 +00001329 return Stmt::BinaryOperatorClass;
Fangrui Song6907ce22018-07-30 19:24:48 +00001330
Douglas Gregore9ceb312010-05-19 04:13:23 +00001331 case OO_Pipe:
John McCalle3027922010-08-25 11:45:40 +00001332 BinaryOp = BO_Or;
Douglas Gregore9ceb312010-05-19 04:13:23 +00001333 return Stmt::BinaryOperatorClass;
1334
1335 case OO_Tilde:
John McCalle3027922010-08-25 11:45:40 +00001336 UnaryOp = UO_Not;
Douglas Gregore9ceb312010-05-19 04:13:23 +00001337 return Stmt::UnaryOperatorClass;
1338
1339 case OO_Exclaim:
John McCalle3027922010-08-25 11:45:40 +00001340 UnaryOp = UO_LNot;
Douglas Gregore9ceb312010-05-19 04:13:23 +00001341 return Stmt::UnaryOperatorClass;
1342
1343 case OO_Equal:
John McCalle3027922010-08-25 11:45:40 +00001344 BinaryOp = BO_Assign;
Douglas Gregore9ceb312010-05-19 04:13:23 +00001345 return Stmt::BinaryOperatorClass;
1346
1347 case OO_Less:
John McCalle3027922010-08-25 11:45:40 +00001348 BinaryOp = BO_LT;
Douglas Gregore9ceb312010-05-19 04:13:23 +00001349 return Stmt::BinaryOperatorClass;
1350
1351 case OO_Greater:
John McCalle3027922010-08-25 11:45:40 +00001352 BinaryOp = BO_GT;
Douglas Gregore9ceb312010-05-19 04:13:23 +00001353 return Stmt::BinaryOperatorClass;
Fangrui Song6907ce22018-07-30 19:24:48 +00001354
Douglas Gregore9ceb312010-05-19 04:13:23 +00001355 case OO_PlusEqual:
John McCalle3027922010-08-25 11:45:40 +00001356 BinaryOp = BO_AddAssign;
Douglas Gregore9ceb312010-05-19 04:13:23 +00001357 return Stmt::CompoundAssignOperatorClass;
1358
1359 case OO_MinusEqual:
John McCalle3027922010-08-25 11:45:40 +00001360 BinaryOp = BO_SubAssign;
Douglas Gregore9ceb312010-05-19 04:13:23 +00001361 return Stmt::CompoundAssignOperatorClass;
1362
1363 case OO_StarEqual:
John McCalle3027922010-08-25 11:45:40 +00001364 BinaryOp = BO_MulAssign;
Douglas Gregore9ceb312010-05-19 04:13:23 +00001365 return Stmt::CompoundAssignOperatorClass;
1366
1367 case OO_SlashEqual:
John McCalle3027922010-08-25 11:45:40 +00001368 BinaryOp = BO_DivAssign;
Douglas Gregore9ceb312010-05-19 04:13:23 +00001369 return Stmt::CompoundAssignOperatorClass;
1370
1371 case OO_PercentEqual:
John McCalle3027922010-08-25 11:45:40 +00001372 BinaryOp = BO_RemAssign;
Douglas Gregore9ceb312010-05-19 04:13:23 +00001373 return Stmt::CompoundAssignOperatorClass;
1374
1375 case OO_CaretEqual:
John McCalle3027922010-08-25 11:45:40 +00001376 BinaryOp = BO_XorAssign;
Douglas Gregore9ceb312010-05-19 04:13:23 +00001377 return Stmt::CompoundAssignOperatorClass;
Fangrui Song6907ce22018-07-30 19:24:48 +00001378
Douglas Gregore9ceb312010-05-19 04:13:23 +00001379 case OO_AmpEqual:
John McCalle3027922010-08-25 11:45:40 +00001380 BinaryOp = BO_AndAssign;
Douglas Gregore9ceb312010-05-19 04:13:23 +00001381 return Stmt::CompoundAssignOperatorClass;
Fangrui Song6907ce22018-07-30 19:24:48 +00001382
Douglas Gregore9ceb312010-05-19 04:13:23 +00001383 case OO_PipeEqual:
John McCalle3027922010-08-25 11:45:40 +00001384 BinaryOp = BO_OrAssign;
Douglas Gregore9ceb312010-05-19 04:13:23 +00001385 return Stmt::CompoundAssignOperatorClass;
Fangrui Song6907ce22018-07-30 19:24:48 +00001386
Douglas Gregore9ceb312010-05-19 04:13:23 +00001387 case OO_LessLess:
John McCalle3027922010-08-25 11:45:40 +00001388 BinaryOp = BO_Shl;
Douglas Gregore9ceb312010-05-19 04:13:23 +00001389 return Stmt::BinaryOperatorClass;
Fangrui Song6907ce22018-07-30 19:24:48 +00001390
Douglas Gregore9ceb312010-05-19 04:13:23 +00001391 case OO_GreaterGreater:
John McCalle3027922010-08-25 11:45:40 +00001392 BinaryOp = BO_Shr;
Douglas Gregore9ceb312010-05-19 04:13:23 +00001393 return Stmt::BinaryOperatorClass;
1394
1395 case OO_LessLessEqual:
John McCalle3027922010-08-25 11:45:40 +00001396 BinaryOp = BO_ShlAssign;
Douglas Gregore9ceb312010-05-19 04:13:23 +00001397 return Stmt::CompoundAssignOperatorClass;
Fangrui Song6907ce22018-07-30 19:24:48 +00001398
Douglas Gregore9ceb312010-05-19 04:13:23 +00001399 case OO_GreaterGreaterEqual:
John McCalle3027922010-08-25 11:45:40 +00001400 BinaryOp = BO_ShrAssign;
Douglas Gregore9ceb312010-05-19 04:13:23 +00001401 return Stmt::CompoundAssignOperatorClass;
1402
1403 case OO_EqualEqual:
John McCalle3027922010-08-25 11:45:40 +00001404 BinaryOp = BO_EQ;
Douglas Gregore9ceb312010-05-19 04:13:23 +00001405 return Stmt::BinaryOperatorClass;
Fangrui Song6907ce22018-07-30 19:24:48 +00001406
Douglas Gregore9ceb312010-05-19 04:13:23 +00001407 case OO_ExclaimEqual:
John McCalle3027922010-08-25 11:45:40 +00001408 BinaryOp = BO_NE;
Douglas Gregore9ceb312010-05-19 04:13:23 +00001409 return Stmt::BinaryOperatorClass;
Fangrui Song6907ce22018-07-30 19:24:48 +00001410
Douglas Gregore9ceb312010-05-19 04:13:23 +00001411 case OO_LessEqual:
John McCalle3027922010-08-25 11:45:40 +00001412 BinaryOp = BO_LE;
Douglas Gregore9ceb312010-05-19 04:13:23 +00001413 return Stmt::BinaryOperatorClass;
Fangrui Song6907ce22018-07-30 19:24:48 +00001414
Douglas Gregore9ceb312010-05-19 04:13:23 +00001415 case OO_GreaterEqual:
John McCalle3027922010-08-25 11:45:40 +00001416 BinaryOp = BO_GE;
Douglas Gregore9ceb312010-05-19 04:13:23 +00001417 return Stmt::BinaryOperatorClass;
Richard Smithd30b23d2017-12-01 02:13:10 +00001418
1419 case OO_Spaceship:
1420 // FIXME: Update this once we support <=> expressions.
1421 llvm_unreachable("<=> expressions not supported yet");
Fangrui Song6907ce22018-07-30 19:24:48 +00001422
Douglas Gregore9ceb312010-05-19 04:13:23 +00001423 case OO_AmpAmp:
John McCalle3027922010-08-25 11:45:40 +00001424 BinaryOp = BO_LAnd;
Douglas Gregore9ceb312010-05-19 04:13:23 +00001425 return Stmt::BinaryOperatorClass;
Fangrui Song6907ce22018-07-30 19:24:48 +00001426
Douglas Gregore9ceb312010-05-19 04:13:23 +00001427 case OO_PipePipe:
John McCalle3027922010-08-25 11:45:40 +00001428 BinaryOp = BO_LOr;
Douglas Gregore9ceb312010-05-19 04:13:23 +00001429 return Stmt::BinaryOperatorClass;
1430
1431 case OO_PlusPlus:
Fangrui Song6907ce22018-07-30 19:24:48 +00001432 UnaryOp = S->getNumArgs() == 1? UO_PreInc
John McCalle3027922010-08-25 11:45:40 +00001433 : UO_PostInc;
Douglas Gregore9ceb312010-05-19 04:13:23 +00001434 return Stmt::UnaryOperatorClass;
1435
1436 case OO_MinusMinus:
John McCalle3027922010-08-25 11:45:40 +00001437 UnaryOp = S->getNumArgs() == 1? UO_PreDec
1438 : UO_PostDec;
Douglas Gregore9ceb312010-05-19 04:13:23 +00001439 return Stmt::UnaryOperatorClass;
1440
1441 case OO_Comma:
John McCalle3027922010-08-25 11:45:40 +00001442 BinaryOp = BO_Comma;
Douglas Gregore9ceb312010-05-19 04:13:23 +00001443 return Stmt::BinaryOperatorClass;
1444
Douglas Gregore9ceb312010-05-19 04:13:23 +00001445 case OO_ArrowStar:
John McCalle3027922010-08-25 11:45:40 +00001446 BinaryOp = BO_PtrMemI;
Douglas Gregore9ceb312010-05-19 04:13:23 +00001447 return Stmt::BinaryOperatorClass;
Fangrui Song6907ce22018-07-30 19:24:48 +00001448
Douglas Gregore9ceb312010-05-19 04:13:23 +00001449 case OO_Subscript:
1450 return Stmt::ArraySubscriptExprClass;
Richard Smith6fff5c42018-07-31 00:47:41 +00001451
1452 case OO_Coawait:
1453 UnaryOp = UO_Coawait;
1454 return Stmt::UnaryOperatorClass;
Douglas Gregore9ceb312010-05-19 04:13:23 +00001455 }
Fangrui Song6907ce22018-07-30 19:24:48 +00001456
Douglas Gregore9ceb312010-05-19 04:13:23 +00001457 llvm_unreachable("Invalid overloaded operator expression");
1458}
Richard Smithf15acc52014-06-05 22:43:40 +00001459
Reid Klecknere257e182017-10-13 16:18:32 +00001460#if defined(_MSC_VER) && !defined(__clang__)
Nico Weberf56f4462017-07-24 16:54:11 +00001461#if _MSC_VER == 1911
1462// Work around https://developercommunity.visualstudio.com/content/problem/84002/clang-cl-when-built-with-vc-2017-crashes-cause-vc.html
1463// MSVC 2017 update 3 miscompiles this function, and a clang built with it
1464// will crash in stage 2 of a bootstrap build.
1465#pragma optimize("", off)
1466#endif
1467#endif
1468
Chandler Carruth631abd92011-06-16 06:47:06 +00001469void StmtProfiler::VisitCXXOperatorCallExpr(const CXXOperatorCallExpr *S) {
Douglas Gregore9ceb312010-05-19 04:13:23 +00001470 if (S->isTypeDependent()) {
1471 // Type-dependent operator calls are profiled like their underlying
1472 // syntactic operator.
Richard Smithbac0a0d2016-10-24 18:47:04 +00001473 //
1474 // An operator call to operator-> is always implicit, so just skip it. The
1475 // enclosing MemberExpr will profile the actual member access.
1476 if (S->getOperator() == OO_Arrow)
1477 return Visit(S->getArg(0));
1478
John McCalle3027922010-08-25 11:45:40 +00001479 UnaryOperatorKind UnaryOp = UO_Extension;
1480 BinaryOperatorKind BinaryOp = BO_Comma;
Douglas Gregore9ceb312010-05-19 04:13:23 +00001481 Stmt::StmtClass SC = DecodeOperatorCall(S, UnaryOp, BinaryOp);
Richard Smithf15acc52014-06-05 22:43:40 +00001482
Douglas Gregore9ceb312010-05-19 04:13:23 +00001483 ID.AddInteger(SC);
1484 for (unsigned I = 0, N = S->getNumArgs(); I != N; ++I)
1485 Visit(S->getArg(I));
1486 if (SC == Stmt::UnaryOperatorClass)
1487 ID.AddInteger(UnaryOp);
Fangrui Song6907ce22018-07-30 19:24:48 +00001488 else if (SC == Stmt::BinaryOperatorClass ||
Douglas Gregore9ceb312010-05-19 04:13:23 +00001489 SC == Stmt::CompoundAssignOperatorClass)
1490 ID.AddInteger(BinaryOp);
1491 else
1492 assert(SC == Stmt::ArraySubscriptExprClass);
Richard Smithf15acc52014-06-05 22:43:40 +00001493
Douglas Gregore9ceb312010-05-19 04:13:23 +00001494 return;
1495 }
Richard Smithf15acc52014-06-05 22:43:40 +00001496
Douglas Gregor5c193b92009-07-28 00:33:38 +00001497 VisitCallExpr(S);
1498 ID.AddInteger(S->getOperator());
1499}
1500
Reid Klecknere257e182017-10-13 16:18:32 +00001501#if defined(_MSC_VER) && !defined(__clang__)
Nico Weberf56f4462017-07-24 16:54:11 +00001502#if _MSC_VER == 1911
1503#pragma optimize("", on)
1504#endif
1505#endif
1506
Chandler Carruth631abd92011-06-16 06:47:06 +00001507void StmtProfiler::VisitCXXMemberCallExpr(const CXXMemberCallExpr *S) {
Douglas Gregor5c193b92009-07-28 00:33:38 +00001508 VisitCallExpr(S);
1509}
1510
Chandler Carruth631abd92011-06-16 06:47:06 +00001511void StmtProfiler::VisitCUDAKernelCallExpr(const CUDAKernelCallExpr *S) {
Peter Collingbourne41f85462011-02-09 21:07:24 +00001512 VisitCallExpr(S);
1513}
1514
Chandler Carruth631abd92011-06-16 06:47:06 +00001515void StmtProfiler::VisitAsTypeExpr(const AsTypeExpr *S) {
Tanya Lattner55808c12011-06-04 00:47:47 +00001516 VisitExpr(S);
1517}
1518
Chandler Carruth631abd92011-06-16 06:47:06 +00001519void StmtProfiler::VisitCXXNamedCastExpr(const CXXNamedCastExpr *S) {
Douglas Gregor5c193b92009-07-28 00:33:38 +00001520 VisitExplicitCastExpr(S);
1521}
1522
Chandler Carruth631abd92011-06-16 06:47:06 +00001523void StmtProfiler::VisitCXXStaticCastExpr(const CXXStaticCastExpr *S) {
Douglas Gregor5c193b92009-07-28 00:33:38 +00001524 VisitCXXNamedCastExpr(S);
1525}
1526
Chandler Carruth631abd92011-06-16 06:47:06 +00001527void StmtProfiler::VisitCXXDynamicCastExpr(const CXXDynamicCastExpr *S) {
Douglas Gregor5c193b92009-07-28 00:33:38 +00001528 VisitCXXNamedCastExpr(S);
1529}
1530
Chandler Carruth631abd92011-06-16 06:47:06 +00001531void
1532StmtProfiler::VisitCXXReinterpretCastExpr(const CXXReinterpretCastExpr *S) {
Douglas Gregor5c193b92009-07-28 00:33:38 +00001533 VisitCXXNamedCastExpr(S);
1534}
1535
Chandler Carruth631abd92011-06-16 06:47:06 +00001536void StmtProfiler::VisitCXXConstCastExpr(const CXXConstCastExpr *S) {
Douglas Gregor5c193b92009-07-28 00:33:38 +00001537 VisitCXXNamedCastExpr(S);
1538}
1539
Richard Smithc67fdd42012-03-07 08:35:16 +00001540void StmtProfiler::VisitUserDefinedLiteral(const UserDefinedLiteral *S) {
1541 VisitCallExpr(S);
1542}
1543
Chandler Carruth631abd92011-06-16 06:47:06 +00001544void StmtProfiler::VisitCXXBoolLiteralExpr(const CXXBoolLiteralExpr *S) {
Douglas Gregor5c193b92009-07-28 00:33:38 +00001545 VisitExpr(S);
1546 ID.AddBoolean(S->getValue());
1547}
1548
Chandler Carruth631abd92011-06-16 06:47:06 +00001549void StmtProfiler::VisitCXXNullPtrLiteralExpr(const CXXNullPtrLiteralExpr *S) {
Douglas Gregor00044172009-07-29 16:09:57 +00001550 VisitExpr(S);
1551}
1552
Richard Smithcc1b96d2013-06-12 22:31:48 +00001553void StmtProfiler::VisitCXXStdInitializerListExpr(
1554 const CXXStdInitializerListExpr *S) {
1555 VisitExpr(S);
1556}
1557
Chandler Carruth631abd92011-06-16 06:47:06 +00001558void StmtProfiler::VisitCXXTypeidExpr(const CXXTypeidExpr *S) {
Douglas Gregor5c193b92009-07-28 00:33:38 +00001559 VisitExpr(S);
1560 if (S->isTypeOperand())
David Majnemer143c55e2013-09-27 07:04:31 +00001561 VisitType(S->getTypeOperandSourceInfo()->getType());
Douglas Gregor5c193b92009-07-28 00:33:38 +00001562}
1563
Chandler Carruth631abd92011-06-16 06:47:06 +00001564void StmtProfiler::VisitCXXUuidofExpr(const CXXUuidofExpr *S) {
Francois Pichet9f4f2072010-09-08 12:20:18 +00001565 VisitExpr(S);
1566 if (S->isTypeOperand())
David Majnemer143c55e2013-09-27 07:04:31 +00001567 VisitType(S->getTypeOperandSourceInfo()->getType());
Francois Pichet9f4f2072010-09-08 12:20:18 +00001568}
1569
John McCall5e77d762013-04-16 07:28:30 +00001570void StmtProfiler::VisitMSPropertyRefExpr(const MSPropertyRefExpr *S) {
1571 VisitExpr(S);
1572 VisitDecl(S->getPropertyDecl());
1573}
1574
Alexey Bataevf7630272015-11-25 12:01:00 +00001575void StmtProfiler::VisitMSPropertySubscriptExpr(
1576 const MSPropertySubscriptExpr *S) {
1577 VisitExpr(S);
1578}
1579
Chandler Carruth631abd92011-06-16 06:47:06 +00001580void StmtProfiler::VisitCXXThisExpr(const CXXThisExpr *S) {
Douglas Gregor5c193b92009-07-28 00:33:38 +00001581 VisitExpr(S);
Douglas Gregor3024f072012-04-16 07:05:22 +00001582 ID.AddBoolean(S->isImplicit());
Douglas Gregor5c193b92009-07-28 00:33:38 +00001583}
1584
Chandler Carruth631abd92011-06-16 06:47:06 +00001585void StmtProfiler::VisitCXXThrowExpr(const CXXThrowExpr *S) {
Douglas Gregor5c193b92009-07-28 00:33:38 +00001586 VisitExpr(S);
1587}
1588
Chandler Carruth631abd92011-06-16 06:47:06 +00001589void StmtProfiler::VisitCXXDefaultArgExpr(const CXXDefaultArgExpr *S) {
Douglas Gregor5c193b92009-07-28 00:33:38 +00001590 VisitExpr(S);
1591 VisitDecl(S->getParam());
1592}
1593
Richard Smith852c9db2013-04-20 22:23:05 +00001594void StmtProfiler::VisitCXXDefaultInitExpr(const CXXDefaultInitExpr *S) {
1595 VisitExpr(S);
1596 VisitDecl(S->getField());
1597}
1598
Chandler Carruth631abd92011-06-16 06:47:06 +00001599void StmtProfiler::VisitCXXBindTemporaryExpr(const CXXBindTemporaryExpr *S) {
Douglas Gregor5c193b92009-07-28 00:33:38 +00001600 VisitExpr(S);
1601 VisitDecl(
1602 const_cast<CXXDestructorDecl *>(S->getTemporary()->getDestructor()));
1603}
1604
Chandler Carruth631abd92011-06-16 06:47:06 +00001605void StmtProfiler::VisitCXXConstructExpr(const CXXConstructExpr *S) {
Douglas Gregor5c193b92009-07-28 00:33:38 +00001606 VisitExpr(S);
1607 VisitDecl(S->getConstructor());
1608 ID.AddBoolean(S->isElidable());
1609}
1610
Richard Smith5179eb72016-06-28 19:03:57 +00001611void StmtProfiler::VisitCXXInheritedCtorInitExpr(
1612 const CXXInheritedCtorInitExpr *S) {
1613 VisitExpr(S);
1614 VisitDecl(S->getConstructor());
1615}
1616
Chandler Carruth631abd92011-06-16 06:47:06 +00001617void StmtProfiler::VisitCXXFunctionalCastExpr(const CXXFunctionalCastExpr *S) {
Douglas Gregor5c193b92009-07-28 00:33:38 +00001618 VisitExplicitCastExpr(S);
1619}
1620
Chandler Carruth631abd92011-06-16 06:47:06 +00001621void
1622StmtProfiler::VisitCXXTemporaryObjectExpr(const CXXTemporaryObjectExpr *S) {
Douglas Gregor5c193b92009-07-28 00:33:38 +00001623 VisitCXXConstructExpr(S);
1624}
1625
Chandler Carruth631abd92011-06-16 06:47:06 +00001626void
Douglas Gregore31e6062012-02-07 10:09:13 +00001627StmtProfiler::VisitLambdaExpr(const LambdaExpr *S) {
1628 VisitExpr(S);
1629 for (LambdaExpr::capture_iterator C = S->explicit_capture_begin(),
1630 CEnd = S->explicit_capture_end();
1631 C != CEnd; ++C) {
Richard Trieu931638e2017-11-11 00:54:25 +00001632 if (C->capturesVLAType())
1633 continue;
1634
Douglas Gregore31e6062012-02-07 10:09:13 +00001635 ID.AddInteger(C->getCaptureKind());
Richard Smithba71c082013-05-16 06:20:58 +00001636 switch (C->getCaptureKind()) {
Faisal Validc6b5962016-03-21 09:25:37 +00001637 case LCK_StarThis:
Richard Smithba71c082013-05-16 06:20:58 +00001638 case LCK_This:
1639 break;
1640 case LCK_ByRef:
1641 case LCK_ByCopy:
Douglas Gregore31e6062012-02-07 10:09:13 +00001642 VisitDecl(C->getCapturedVar());
1643 ID.AddBoolean(C->isPackExpansion());
Richard Smithba71c082013-05-16 06:20:58 +00001644 break;
Alexey Bataev39c81e22014-08-28 04:28:19 +00001645 case LCK_VLAType:
1646 llvm_unreachable("VLA type in explicit captures.");
Douglas Gregore31e6062012-02-07 10:09:13 +00001647 }
1648 }
1649 // Note: If we actually needed to be able to match lambda
1650 // expressions, we would have to consider parameters and return type
1651 // here, among other things.
1652 VisitStmt(S->getBody());
1653}
1654
1655void
Chandler Carruth631abd92011-06-16 06:47:06 +00001656StmtProfiler::VisitCXXScalarValueInitExpr(const CXXScalarValueInitExpr *S) {
Douglas Gregor5c193b92009-07-28 00:33:38 +00001657 VisitExpr(S);
1658}
1659
Chandler Carruth631abd92011-06-16 06:47:06 +00001660void StmtProfiler::VisitCXXDeleteExpr(const CXXDeleteExpr *S) {
Douglas Gregor5c193b92009-07-28 00:33:38 +00001661 VisitExpr(S);
1662 ID.AddBoolean(S->isGlobalDelete());
1663 ID.AddBoolean(S->isArrayForm());
1664 VisitDecl(S->getOperatorDelete());
1665}
1666
Chandler Carruth631abd92011-06-16 06:47:06 +00001667void StmtProfiler::VisitCXXNewExpr(const CXXNewExpr *S) {
Douglas Gregor5c193b92009-07-28 00:33:38 +00001668 VisitExpr(S);
1669 VisitType(S->getAllocatedType());
1670 VisitDecl(S->getOperatorNew());
1671 VisitDecl(S->getOperatorDelete());
Douglas Gregor5c193b92009-07-28 00:33:38 +00001672 ID.AddBoolean(S->isArray());
1673 ID.AddInteger(S->getNumPlacementArgs());
1674 ID.AddBoolean(S->isGlobalNew());
1675 ID.AddBoolean(S->isParenTypeId());
Sebastian Redl6047f072012-02-16 12:22:20 +00001676 ID.AddInteger(S->getInitializationStyle());
Douglas Gregor5c193b92009-07-28 00:33:38 +00001677}
1678
Chandler Carruth631abd92011-06-16 06:47:06 +00001679void
1680StmtProfiler::VisitCXXPseudoDestructorExpr(const CXXPseudoDestructorExpr *S) {
Douglas Gregorad8a3362009-09-04 17:36:40 +00001681 VisitExpr(S);
1682 ID.AddBoolean(S->isArrow());
1683 VisitNestedNameSpecifier(S->getQualifier());
Craig Topper36250ad2014-05-12 05:36:57 +00001684 ID.AddBoolean(S->getScopeTypeInfo() != nullptr);
Eli Friedman85641392013-08-09 23:37:05 +00001685 if (S->getScopeTypeInfo())
1686 VisitType(S->getScopeTypeInfo()->getType());
Craig Topper36250ad2014-05-12 05:36:57 +00001687 ID.AddBoolean(S->getDestroyedTypeInfo() != nullptr);
Eli Friedman85641392013-08-09 23:37:05 +00001688 if (S->getDestroyedTypeInfo())
1689 VisitType(S->getDestroyedType());
1690 else
Richard Trieu639d7b62017-02-22 22:22:42 +00001691 VisitIdentifierInfo(S->getDestroyedTypeIdentifier());
Douglas Gregorad8a3362009-09-04 17:36:40 +00001692}
1693
Chandler Carruth631abd92011-06-16 06:47:06 +00001694void StmtProfiler::VisitOverloadExpr(const OverloadExpr *S) {
Argyrios Kyrtzidisb482eb82010-08-15 20:53:20 +00001695 VisitExpr(S);
John McCalle66edc12009-11-24 19:00:30 +00001696 VisitNestedNameSpecifier(S->getQualifier());
Richard Trieuf65efae2018-02-22 05:32:25 +00001697 VisitName(S->getName(), /*TreatAsDecl*/ true);
John McCalle66edc12009-11-24 19:00:30 +00001698 ID.AddBoolean(S->hasExplicitTemplateArgs());
1699 if (S->hasExplicitTemplateArgs())
James Y Knight04ec5bf2015-12-24 02:59:37 +00001700 VisitTemplateArguments(S->getTemplateArgs(), S->getNumTemplateArgs());
Argyrios Kyrtzidisf4505452010-08-15 01:15:38 +00001701}
1702
1703void
Chandler Carruth631abd92011-06-16 06:47:06 +00001704StmtProfiler::VisitUnresolvedLookupExpr(const UnresolvedLookupExpr *S) {
Argyrios Kyrtzidisf4505452010-08-15 01:15:38 +00001705 VisitOverloadExpr(S);
Douglas Gregor5c193b92009-07-28 00:33:38 +00001706}
1707
Douglas Gregor29c42f22012-02-24 07:38:34 +00001708void StmtProfiler::VisitTypeTraitExpr(const TypeTraitExpr *S) {
1709 VisitExpr(S);
1710 ID.AddInteger(S->getTrait());
1711 ID.AddInteger(S->getNumArgs());
1712 for (unsigned I = 0, N = S->getNumArgs(); I != N; ++I)
1713 VisitType(S->getArg(I)->getType());
1714}
1715
Chandler Carruth631abd92011-06-16 06:47:06 +00001716void StmtProfiler::VisitArrayTypeTraitExpr(const ArrayTypeTraitExpr *S) {
John Wiegley6242b6a2011-04-28 00:16:57 +00001717 VisitExpr(S);
1718 ID.AddInteger(S->getTrait());
1719 VisitType(S->getQueriedType());
1720}
1721
Chandler Carruth631abd92011-06-16 06:47:06 +00001722void StmtProfiler::VisitExpressionTraitExpr(const ExpressionTraitExpr *S) {
John Wiegleyf9f65842011-04-25 06:54:41 +00001723 VisitExpr(S);
1724 ID.AddInteger(S->getTrait());
1725 VisitExpr(S->getQueriedExpression());
1726}
1727
Chandler Carruth631abd92011-06-16 06:47:06 +00001728void StmtProfiler::VisitDependentScopeDeclRefExpr(
1729 const DependentScopeDeclRefExpr *S) {
Douglas Gregor5c193b92009-07-28 00:33:38 +00001730 VisitExpr(S);
1731 VisitName(S->getDeclName());
1732 VisitNestedNameSpecifier(S->getQualifier());
John McCalle66edc12009-11-24 19:00:30 +00001733 ID.AddBoolean(S->hasExplicitTemplateArgs());
1734 if (S->hasExplicitTemplateArgs())
1735 VisitTemplateArguments(S->getTemplateArgs(), S->getNumTemplateArgs());
Douglas Gregor5c193b92009-07-28 00:33:38 +00001736}
1737
Chandler Carruth631abd92011-06-16 06:47:06 +00001738void StmtProfiler::VisitExprWithCleanups(const ExprWithCleanups *S) {
Douglas Gregora7095092009-07-28 14:44:31 +00001739 VisitExpr(S);
Douglas Gregora7095092009-07-28 14:44:31 +00001740}
1741
Chandler Carruth631abd92011-06-16 06:47:06 +00001742void StmtProfiler::VisitCXXUnresolvedConstructExpr(
1743 const CXXUnresolvedConstructExpr *S) {
Douglas Gregora7095092009-07-28 14:44:31 +00001744 VisitExpr(S);
1745 VisitType(S->getTypeAsWritten());
Richard Smith39eca9b2017-08-23 22:12:08 +00001746 ID.AddInteger(S->isListInitialization());
Douglas Gregora7095092009-07-28 14:44:31 +00001747}
1748
Chandler Carruth631abd92011-06-16 06:47:06 +00001749void StmtProfiler::VisitCXXDependentScopeMemberExpr(
1750 const CXXDependentScopeMemberExpr *S) {
John McCall2d74de92009-12-01 22:10:20 +00001751 ID.AddBoolean(S->isImplicitAccess());
1752 if (!S->isImplicitAccess()) {
1753 VisitExpr(S);
1754 ID.AddBoolean(S->isArrow());
1755 }
Douglas Gregorc26e0f62009-09-03 16:14:30 +00001756 VisitNestedNameSpecifier(S->getQualifier());
Douglas Gregora7095092009-07-28 14:44:31 +00001757 VisitName(S->getMember());
John McCall2d74de92009-12-01 22:10:20 +00001758 ID.AddBoolean(S->hasExplicitTemplateArgs());
1759 if (S->hasExplicitTemplateArgs())
John McCall10eae182009-11-30 22:42:35 +00001760 VisitTemplateArguments(S->getTemplateArgs(), S->getNumTemplateArgs());
1761}
1762
Chandler Carruth631abd92011-06-16 06:47:06 +00001763void StmtProfiler::VisitUnresolvedMemberExpr(const UnresolvedMemberExpr *S) {
John McCall2d74de92009-12-01 22:10:20 +00001764 ID.AddBoolean(S->isImplicitAccess());
1765 if (!S->isImplicitAccess()) {
1766 VisitExpr(S);
1767 ID.AddBoolean(S->isArrow());
1768 }
John McCall10eae182009-11-30 22:42:35 +00001769 VisitNestedNameSpecifier(S->getQualifier());
1770 VisitName(S->getMemberName());
1771 ID.AddBoolean(S->hasExplicitTemplateArgs());
1772 if (S->hasExplicitTemplateArgs())
1773 VisitTemplateArguments(S->getTemplateArgs(), S->getNumTemplateArgs());
Douglas Gregora7095092009-07-28 14:44:31 +00001774}
1775
Chandler Carruth631abd92011-06-16 06:47:06 +00001776void StmtProfiler::VisitCXXNoexceptExpr(const CXXNoexceptExpr *S) {
Sebastian Redl4202c0f2010-09-10 20:55:43 +00001777 VisitExpr(S);
1778}
1779
Chandler Carruth631abd92011-06-16 06:47:06 +00001780void StmtProfiler::VisitPackExpansionExpr(const PackExpansionExpr *S) {
Douglas Gregore8e9dd62011-01-03 17:17:50 +00001781 VisitExpr(S);
1782}
1783
Chandler Carruth631abd92011-06-16 06:47:06 +00001784void StmtProfiler::VisitSizeOfPackExpr(const SizeOfPackExpr *S) {
Douglas Gregor820ba7b2011-01-04 17:33:58 +00001785 VisitExpr(S);
1786 VisitDecl(S->getPack());
Richard Smithd784e682015-09-23 21:41:42 +00001787 if (S->isPartiallySubstituted()) {
1788 auto Args = S->getPartialArguments();
1789 ID.AddInteger(Args.size());
1790 for (const auto &TA : Args)
1791 VisitTemplateArgument(TA);
1792 } else {
1793 ID.AddInteger(0);
1794 }
Douglas Gregor820ba7b2011-01-04 17:33:58 +00001795}
1796
Douglas Gregorcdbc5392011-01-15 01:15:58 +00001797void StmtProfiler::VisitSubstNonTypeTemplateParmPackExpr(
Chandler Carruth631abd92011-06-16 06:47:06 +00001798 const SubstNonTypeTemplateParmPackExpr *S) {
Douglas Gregorcdbc5392011-01-15 01:15:58 +00001799 VisitExpr(S);
1800 VisitDecl(S->getParameterPack());
1801 VisitTemplateArgument(S->getArgumentPack());
1802}
1803
John McCall7c454bb2011-07-15 05:09:51 +00001804void StmtProfiler::VisitSubstNonTypeTemplateParmExpr(
1805 const SubstNonTypeTemplateParmExpr *E) {
1806 // Profile exactly as the replacement expression.
1807 Visit(E->getReplacement());
1808}
1809
Richard Smithb15fe3a2012-09-12 00:56:43 +00001810void StmtProfiler::VisitFunctionParmPackExpr(const FunctionParmPackExpr *S) {
1811 VisitExpr(S);
1812 VisitDecl(S->getParameterPack());
1813 ID.AddInteger(S->getNumExpansions());
1814 for (FunctionParmPackExpr::iterator I = S->begin(), E = S->end(); I != E; ++I)
1815 VisitDecl(*I);
1816}
1817
Douglas Gregorfe314812011-06-21 17:03:29 +00001818void StmtProfiler::VisitMaterializeTemporaryExpr(
1819 const MaterializeTemporaryExpr *S) {
1820 VisitExpr(S);
1821}
1822
Richard Smith0f0af192014-11-08 05:07:16 +00001823void StmtProfiler::VisitCXXFoldExpr(const CXXFoldExpr *S) {
1824 VisitExpr(S);
1825 ID.AddInteger(S->getOperator());
1826}
1827
Richard Smith9f690bd2015-10-27 06:02:45 +00001828void StmtProfiler::VisitCoroutineBodyStmt(const CoroutineBodyStmt *S) {
1829 VisitStmt(S);
1830}
1831
1832void StmtProfiler::VisitCoreturnStmt(const CoreturnStmt *S) {
1833 VisitStmt(S);
1834}
1835
1836void StmtProfiler::VisitCoawaitExpr(const CoawaitExpr *S) {
1837 VisitExpr(S);
1838}
1839
Eric Fiselier20f25cb2017-03-06 23:38:15 +00001840void StmtProfiler::VisitDependentCoawaitExpr(const DependentCoawaitExpr *S) {
1841 VisitExpr(S);
1842}
1843
Richard Smith9f690bd2015-10-27 06:02:45 +00001844void StmtProfiler::VisitCoyieldExpr(const CoyieldExpr *S) {
1845 VisitExpr(S);
1846}
1847
Chandler Carruth631abd92011-06-16 06:47:06 +00001848void StmtProfiler::VisitOpaqueValueExpr(const OpaqueValueExpr *E) {
Fangrui Song6907ce22018-07-30 19:24:48 +00001849 VisitExpr(E);
John McCall8d69a212010-11-15 23:31:06 +00001850}
1851
Kaelyn Takatae1f49d52014-10-27 18:07:20 +00001852void StmtProfiler::VisitTypoExpr(const TypoExpr *E) {
1853 VisitExpr(E);
1854}
1855
Chandler Carruth631abd92011-06-16 06:47:06 +00001856void StmtProfiler::VisitObjCStringLiteral(const ObjCStringLiteral *S) {
Douglas Gregora7095092009-07-28 14:44:31 +00001857 VisitExpr(S);
1858}
1859
Patrick Beard0caa3942012-04-19 00:25:12 +00001860void StmtProfiler::VisitObjCBoxedExpr(const ObjCBoxedExpr *E) {
Ted Kremeneke65b0862012-03-06 20:05:56 +00001861 VisitExpr(E);
1862}
1863
1864void StmtProfiler::VisitObjCArrayLiteral(const ObjCArrayLiteral *E) {
1865 VisitExpr(E);
1866}
1867
1868void StmtProfiler::VisitObjCDictionaryLiteral(const ObjCDictionaryLiteral *E) {
1869 VisitExpr(E);
1870}
1871
Chandler Carruth631abd92011-06-16 06:47:06 +00001872void StmtProfiler::VisitObjCEncodeExpr(const ObjCEncodeExpr *S) {
Douglas Gregora7095092009-07-28 14:44:31 +00001873 VisitExpr(S);
1874 VisitType(S->getEncodedType());
1875}
1876
Chandler Carruth631abd92011-06-16 06:47:06 +00001877void StmtProfiler::VisitObjCSelectorExpr(const ObjCSelectorExpr *S) {
Douglas Gregora7095092009-07-28 14:44:31 +00001878 VisitExpr(S);
1879 VisitName(S->getSelector());
1880}
1881
Chandler Carruth631abd92011-06-16 06:47:06 +00001882void StmtProfiler::VisitObjCProtocolExpr(const ObjCProtocolExpr *S) {
Douglas Gregora7095092009-07-28 14:44:31 +00001883 VisitExpr(S);
1884 VisitDecl(S->getProtocol());
1885}
1886
Chandler Carruth631abd92011-06-16 06:47:06 +00001887void StmtProfiler::VisitObjCIvarRefExpr(const ObjCIvarRefExpr *S) {
Douglas Gregora7095092009-07-28 14:44:31 +00001888 VisitExpr(S);
1889 VisitDecl(S->getDecl());
1890 ID.AddBoolean(S->isArrow());
1891 ID.AddBoolean(S->isFreeIvar());
1892}
1893
Chandler Carruth631abd92011-06-16 06:47:06 +00001894void StmtProfiler::VisitObjCPropertyRefExpr(const ObjCPropertyRefExpr *S) {
Douglas Gregora7095092009-07-28 14:44:31 +00001895 VisitExpr(S);
John McCallb7bd14f2010-12-02 01:19:52 +00001896 if (S->isImplicitProperty()) {
1897 VisitDecl(S->getImplicitPropertyGetter());
1898 VisitDecl(S->getImplicitPropertySetter());
1899 } else {
1900 VisitDecl(S->getExplicitProperty());
Fariborz Jahanian681c0752010-10-14 16:04:05 +00001901 }
Fariborz Jahanian681c0752010-10-14 16:04:05 +00001902 if (S->isSuperReceiver()) {
1903 ID.AddBoolean(S->isSuperReceiver());
John McCallb7bd14f2010-12-02 01:19:52 +00001904 VisitType(S->getSuperReceiverType());
Fariborz Jahanian681c0752010-10-14 16:04:05 +00001905 }
Douglas Gregora7095092009-07-28 14:44:31 +00001906}
1907
Ted Kremeneke65b0862012-03-06 20:05:56 +00001908void StmtProfiler::VisitObjCSubscriptRefExpr(const ObjCSubscriptRefExpr *S) {
1909 VisitExpr(S);
1910 VisitDecl(S->getAtIndexMethodDecl());
1911 VisitDecl(S->setAtIndexMethodDecl());
1912}
1913
Chandler Carruth631abd92011-06-16 06:47:06 +00001914void StmtProfiler::VisitObjCMessageExpr(const ObjCMessageExpr *S) {
Douglas Gregora7095092009-07-28 14:44:31 +00001915 VisitExpr(S);
1916 VisitName(S->getSelector());
1917 VisitDecl(S->getMethodDecl());
1918}
1919
Chandler Carruth631abd92011-06-16 06:47:06 +00001920void StmtProfiler::VisitObjCIsaExpr(const ObjCIsaExpr *S) {
Douglas Gregora7095092009-07-28 14:44:31 +00001921 VisitExpr(S);
1922 ID.AddBoolean(S->isArrow());
1923}
1924
Ted Kremeneke65b0862012-03-06 20:05:56 +00001925void StmtProfiler::VisitObjCBoolLiteralExpr(const ObjCBoolLiteralExpr *S) {
1926 VisitExpr(S);
1927 ID.AddBoolean(S->getValue());
1928}
1929
Chandler Carruth631abd92011-06-16 06:47:06 +00001930void StmtProfiler::VisitObjCIndirectCopyRestoreExpr(
1931 const ObjCIndirectCopyRestoreExpr *S) {
John McCall31168b02011-06-15 23:02:42 +00001932 VisitExpr(S);
1933 ID.AddBoolean(S->shouldCopy());
1934}
1935
Chandler Carruth631abd92011-06-16 06:47:06 +00001936void StmtProfiler::VisitObjCBridgedCastExpr(const ObjCBridgedCastExpr *S) {
John McCall31168b02011-06-15 23:02:42 +00001937 VisitExplicitCastExpr(S);
1938 ID.AddBoolean(S->getBridgeKind());
1939}
1940
Erik Pilkington29099de2016-07-16 00:35:23 +00001941void StmtProfiler::VisitObjCAvailabilityCheckExpr(
1942 const ObjCAvailabilityCheckExpr *S) {
1943 VisitExpr(S);
1944}
1945
John McCall0ad16662009-10-29 08:12:44 +00001946void StmtProfiler::VisitTemplateArguments(const TemplateArgumentLoc *Args,
Douglas Gregor5c193b92009-07-28 00:33:38 +00001947 unsigned NumArgs) {
1948 ID.AddInteger(NumArgs);
John McCall0ad16662009-10-29 08:12:44 +00001949 for (unsigned I = 0; I != NumArgs; ++I)
1950 VisitTemplateArgument(Args[I].getArgument());
1951}
Mike Stump11289f42009-09-09 15:08:12 +00001952
John McCall0ad16662009-10-29 08:12:44 +00001953void StmtProfiler::VisitTemplateArgument(const TemplateArgument &Arg) {
1954 // Mostly repetitive with TemplateArgument::Profile!
1955 ID.AddInteger(Arg.getKind());
1956 switch (Arg.getKind()) {
1957 case TemplateArgument::Null:
1958 break;
Mike Stump11289f42009-09-09 15:08:12 +00001959
John McCall0ad16662009-10-29 08:12:44 +00001960 case TemplateArgument::Type:
1961 VisitType(Arg.getAsType());
1962 break;
Mike Stump11289f42009-09-09 15:08:12 +00001963
Douglas Gregor9167f8b2009-11-11 01:00:40 +00001964 case TemplateArgument::Template:
Douglas Gregore4ff4b52011-01-05 18:58:31 +00001965 case TemplateArgument::TemplateExpansion:
1966 VisitTemplateName(Arg.getAsTemplateOrTemplatePattern());
Douglas Gregor9167f8b2009-11-11 01:00:40 +00001967 break;
Fangrui Song6907ce22018-07-30 19:24:48 +00001968
John McCall0ad16662009-10-29 08:12:44 +00001969 case TemplateArgument::Declaration:
1970 VisitDecl(Arg.getAsDecl());
1971 break;
Mike Stump11289f42009-09-09 15:08:12 +00001972
Eli Friedmanb826a002012-09-26 02:36:12 +00001973 case TemplateArgument::NullPtr:
1974 VisitType(Arg.getNullPtrType());
1975 break;
1976
John McCall0ad16662009-10-29 08:12:44 +00001977 case TemplateArgument::Integral:
Benjamin Kramer6003ad52012-06-07 15:09:51 +00001978 Arg.getAsIntegral().Profile(ID);
John McCall0ad16662009-10-29 08:12:44 +00001979 VisitType(Arg.getIntegralType());
1980 break;
Mike Stump11289f42009-09-09 15:08:12 +00001981
John McCall0ad16662009-10-29 08:12:44 +00001982 case TemplateArgument::Expression:
1983 Visit(Arg.getAsExpr());
1984 break;
Mike Stump11289f42009-09-09 15:08:12 +00001985
John McCall0ad16662009-10-29 08:12:44 +00001986 case TemplateArgument::Pack:
Aaron Ballman2a89e852014-07-15 21:32:31 +00001987 for (const auto &P : Arg.pack_elements())
1988 VisitTemplateArgument(P);
John McCall0ad16662009-10-29 08:12:44 +00001989 break;
Douglas Gregor5c193b92009-07-28 00:33:38 +00001990 }
1991}
1992
Jay Foad39c79802011-01-12 09:06:06 +00001993void Stmt::Profile(llvm::FoldingSetNodeID &ID, const ASTContext &Context,
Chandler Carruth631abd92011-06-16 06:47:06 +00001994 bool Canonical) const {
Richard Trieu639d7b62017-02-22 22:22:42 +00001995 StmtProfilerWithPointers Profiler(ID, Context, Canonical);
1996 Profiler.Visit(this);
1997}
1998
1999void Stmt::ProcessODRHash(llvm::FoldingSetNodeID &ID,
2000 class ODRHash &Hash) const {
2001 StmtProfilerWithoutPointers Profiler(ID, Hash);
Douglas Gregor5c193b92009-07-28 00:33:38 +00002002 Profiler.Visit(this);
2003}