blob: f3db8f7e0405ef74a1cf86426425ee1daaf9bac7 [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 Trieu22ddc282018-09-04 22:53:19 +0000192 Hash.AddDeclarationName(Name, TreatAsDecl);
Richard Trieu639d7b62017-02-22 22:22:42 +0000193 }
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
Kelvin Li1408f912018-09-26 04:28:39 +0000470void OMPClauseProfiler::VisitOMPUnifiedAddressClause(
471 const OMPUnifiedAddressClause *C) {}
472
Patrick Lyster4a370b92018-10-01 13:47:43 +0000473void OMPClauseProfiler::VisitOMPUnifiedSharedMemoryClause(
474 const OMPUnifiedSharedMemoryClause *C) {}
475
Alexey Bataev56dafe82014-06-20 07:16:17 +0000476void OMPClauseProfiler::VisitOMPScheduleClause(const OMPScheduleClause *C) {
Alexey Bataev3392d762016-02-16 11:18:12 +0000477 VistOMPClauseWithPreInit(C);
478 if (auto *S = C->getChunkSize())
479 Profiler->VisitStmt(S);
Alexey Bataev56dafe82014-06-20 07:16:17 +0000480}
481
Alexey Bataev10e775f2015-07-30 11:36:16 +0000482void OMPClauseProfiler::VisitOMPOrderedClause(const OMPOrderedClause *C) {
483 if (auto *Num = C->getNumForLoops())
484 Profiler->VisitStmt(Num);
485}
Alexey Bataev142e1fc2014-06-20 09:44:06 +0000486
Alexey Bataev236070f2014-06-20 11:19:47 +0000487void OMPClauseProfiler::VisitOMPNowaitClause(const OMPNowaitClause *) {}
488
Alexey Bataev7aea99a2014-07-17 12:19:31 +0000489void OMPClauseProfiler::VisitOMPUntiedClause(const OMPUntiedClause *) {}
490
Alexey Bataev74ba3a52014-07-17 12:47:03 +0000491void OMPClauseProfiler::VisitOMPMergeableClause(const OMPMergeableClause *) {}
492
Alexey Bataevf98b00c2014-07-23 02:27:21 +0000493void OMPClauseProfiler::VisitOMPReadClause(const OMPReadClause *) {}
494
Alexey Bataevdea47612014-07-23 07:46:59 +0000495void OMPClauseProfiler::VisitOMPWriteClause(const OMPWriteClause *) {}
496
Alexey Bataev67a4f222014-07-23 10:25:33 +0000497void OMPClauseProfiler::VisitOMPUpdateClause(const OMPUpdateClause *) {}
498
Alexey Bataev459dec02014-07-24 06:46:57 +0000499void OMPClauseProfiler::VisitOMPCaptureClause(const OMPCaptureClause *) {}
500
Alexey Bataev82bad8b2014-07-24 08:55:34 +0000501void OMPClauseProfiler::VisitOMPSeqCstClause(const OMPSeqCstClause *) {}
502
Alexey Bataev346265e2015-09-25 10:37:12 +0000503void OMPClauseProfiler::VisitOMPThreadsClause(const OMPThreadsClause *) {}
504
Alexey Bataevd14d1e62015-09-28 06:39:35 +0000505void OMPClauseProfiler::VisitOMPSIMDClause(const OMPSIMDClause *) {}
506
Alexey Bataevb825de12015-12-07 10:51:44 +0000507void OMPClauseProfiler::VisitOMPNogroupClause(const OMPNogroupClause *) {}
508
Alexey Bataev756c1962013-09-24 03:17:45 +0000509template<typename T>
510void OMPClauseProfiler::VisitOMPClauseList(T *Node) {
Alexey Bataev03b340a2014-10-21 03:16:40 +0000511 for (auto *E : Node->varlists()) {
Richard Trieu6a77a1c2016-06-10 04:52:09 +0000512 if (E)
513 Profiler->VisitStmt(E);
Alexey Bataev03b340a2014-10-21 03:16:40 +0000514 }
Alexey Bataev756c1962013-09-24 03:17:45 +0000515}
Alexey Bataev5ec3eb12013-07-19 03:13:43 +0000516
517void OMPClauseProfiler::VisitOMPPrivateClause(const OMPPrivateClause *C) {
Alexey Bataev756c1962013-09-24 03:17:45 +0000518 VisitOMPClauseList(C);
Alexey Bataev03b340a2014-10-21 03:16:40 +0000519 for (auto *E : C->private_copies()) {
Richard Trieu6a77a1c2016-06-10 04:52:09 +0000520 if (E)
521 Profiler->VisitStmt(E);
Alexey Bataev03b340a2014-10-21 03:16:40 +0000522 }
Alexey Bataev5ec3eb12013-07-19 03:13:43 +0000523}
Alexey Bataev4a5bb772014-10-08 14:01:46 +0000524void
525OMPClauseProfiler::VisitOMPFirstprivateClause(const OMPFirstprivateClause *C) {
Alexey Bataevd5af8e42013-10-01 05:32:34 +0000526 VisitOMPClauseList(C);
Alexey Bataev417089f2016-02-17 13:19:37 +0000527 VistOMPClauseWithPreInit(C);
Alexey Bataev4a5bb772014-10-08 14:01:46 +0000528 for (auto *E : C->private_copies()) {
Richard Trieu6a77a1c2016-06-10 04:52:09 +0000529 if (E)
530 Profiler->VisitStmt(E);
Alexey Bataev4a5bb772014-10-08 14:01:46 +0000531 }
532 for (auto *E : C->inits()) {
Richard Trieu6a77a1c2016-06-10 04:52:09 +0000533 if (E)
534 Profiler->VisitStmt(E);
Alexey Bataev4a5bb772014-10-08 14:01:46 +0000535 }
Alexey Bataevd5af8e42013-10-01 05:32:34 +0000536}
Alexander Musman1bb328c2014-06-04 13:06:39 +0000537void
538OMPClauseProfiler::VisitOMPLastprivateClause(const OMPLastprivateClause *C) {
539 VisitOMPClauseList(C);
Alexey Bataev005248a2016-02-25 05:25:57 +0000540 VistOMPClauseWithPostUpdate(C);
Alexey Bataev38e89532015-04-16 04:54:05 +0000541 for (auto *E : C->source_exprs()) {
Richard Trieu6a77a1c2016-06-10 04:52:09 +0000542 if (E)
543 Profiler->VisitStmt(E);
Alexey Bataev38e89532015-04-16 04:54:05 +0000544 }
545 for (auto *E : C->destination_exprs()) {
Richard Trieu6a77a1c2016-06-10 04:52:09 +0000546 if (E)
547 Profiler->VisitStmt(E);
Alexey Bataev38e89532015-04-16 04:54:05 +0000548 }
549 for (auto *E : C->assignment_ops()) {
Richard Trieu6a77a1c2016-06-10 04:52:09 +0000550 if (E)
551 Profiler->VisitStmt(E);
Alexey Bataev38e89532015-04-16 04:54:05 +0000552 }
Alexander Musman1bb328c2014-06-04 13:06:39 +0000553}
Alexey Bataev758e55e2013-09-06 18:03:48 +0000554void OMPClauseProfiler::VisitOMPSharedClause(const OMPSharedClause *C) {
Alexey Bataev756c1962013-09-24 03:17:45 +0000555 VisitOMPClauseList(C);
Alexey Bataev758e55e2013-09-06 18:03:48 +0000556}
Alexey Bataevc5e02582014-06-16 07:08:35 +0000557void OMPClauseProfiler::VisitOMPReductionClause(
558 const OMPReductionClause *C) {
559 Profiler->VisitNestedNameSpecifier(
560 C->getQualifierLoc().getNestedNameSpecifier());
561 Profiler->VisitName(C->getNameInfo().getName());
562 VisitOMPClauseList(C);
Alexey Bataev61205072016-03-02 04:57:40 +0000563 VistOMPClauseWithPostUpdate(C);
Alexey Bataevf24e7b12015-10-08 09:10:53 +0000564 for (auto *E : C->privates()) {
Richard Trieu6a77a1c2016-06-10 04:52:09 +0000565 if (E)
566 Profiler->VisitStmt(E);
Alexey Bataevf24e7b12015-10-08 09:10:53 +0000567 }
Alexey Bataev794ba0d2015-04-10 10:43:45 +0000568 for (auto *E : C->lhs_exprs()) {
Richard Trieu6a77a1c2016-06-10 04:52:09 +0000569 if (E)
570 Profiler->VisitStmt(E);
Alexey Bataev794ba0d2015-04-10 10:43:45 +0000571 }
572 for (auto *E : C->rhs_exprs()) {
Richard Trieu6a77a1c2016-06-10 04:52:09 +0000573 if (E)
574 Profiler->VisitStmt(E);
Alexey Bataev794ba0d2015-04-10 10:43:45 +0000575 }
576 for (auto *E : C->reduction_ops()) {
Richard Trieu6a77a1c2016-06-10 04:52:09 +0000577 if (E)
578 Profiler->VisitStmt(E);
Alexey Bataev794ba0d2015-04-10 10:43:45 +0000579 }
Alexey Bataevc5e02582014-06-16 07:08:35 +0000580}
Alexey Bataev169d96a2017-07-18 20:17:46 +0000581void OMPClauseProfiler::VisitOMPTaskReductionClause(
582 const OMPTaskReductionClause *C) {
583 Profiler->VisitNestedNameSpecifier(
584 C->getQualifierLoc().getNestedNameSpecifier());
585 Profiler->VisitName(C->getNameInfo().getName());
586 VisitOMPClauseList(C);
587 VistOMPClauseWithPostUpdate(C);
588 for (auto *E : C->privates()) {
589 if (E)
590 Profiler->VisitStmt(E);
591 }
592 for (auto *E : C->lhs_exprs()) {
593 if (E)
594 Profiler->VisitStmt(E);
595 }
596 for (auto *E : C->rhs_exprs()) {
597 if (E)
598 Profiler->VisitStmt(E);
599 }
600 for (auto *E : C->reduction_ops()) {
601 if (E)
602 Profiler->VisitStmt(E);
603 }
604}
Alexey Bataevfa312f32017-07-21 18:48:21 +0000605void OMPClauseProfiler::VisitOMPInReductionClause(
606 const OMPInReductionClause *C) {
607 Profiler->VisitNestedNameSpecifier(
608 C->getQualifierLoc().getNestedNameSpecifier());
609 Profiler->VisitName(C->getNameInfo().getName());
610 VisitOMPClauseList(C);
611 VistOMPClauseWithPostUpdate(C);
612 for (auto *E : C->privates()) {
613 if (E)
614 Profiler->VisitStmt(E);
615 }
616 for (auto *E : C->lhs_exprs()) {
617 if (E)
618 Profiler->VisitStmt(E);
619 }
620 for (auto *E : C->rhs_exprs()) {
621 if (E)
622 Profiler->VisitStmt(E);
623 }
624 for (auto *E : C->reduction_ops()) {
625 if (E)
626 Profiler->VisitStmt(E);
627 }
Alexey Bataev88202be2017-07-27 13:20:36 +0000628 for (auto *E : C->taskgroup_descriptors()) {
629 if (E)
630 Profiler->VisitStmt(E);
631 }
Alexey Bataevfa312f32017-07-21 18:48:21 +0000632}
Alexander Musman8dba6642014-04-22 13:09:42 +0000633void OMPClauseProfiler::VisitOMPLinearClause(const OMPLinearClause *C) {
634 VisitOMPClauseList(C);
Alexey Bataev78849fb2016-03-09 09:49:00 +0000635 VistOMPClauseWithPostUpdate(C);
Alexey Bataevbd9fec12015-08-18 06:47:21 +0000636 for (auto *E : C->privates()) {
Richard Trieu6a77a1c2016-06-10 04:52:09 +0000637 if (E)
638 Profiler->VisitStmt(E);
Alexey Bataevbd9fec12015-08-18 06:47:21 +0000639 }
Alexander Musman3276a272015-03-21 10:12:56 +0000640 for (auto *E : C->inits()) {
Richard Trieu6a77a1c2016-06-10 04:52:09 +0000641 if (E)
642 Profiler->VisitStmt(E);
Alexander Musman3276a272015-03-21 10:12:56 +0000643 }
644 for (auto *E : C->updates()) {
Richard Trieu6a77a1c2016-06-10 04:52:09 +0000645 if (E)
646 Profiler->VisitStmt(E);
Alexander Musman3276a272015-03-21 10:12:56 +0000647 }
648 for (auto *E : C->finals()) {
Richard Trieu6a77a1c2016-06-10 04:52:09 +0000649 if (E)
650 Profiler->VisitStmt(E);
Alexander Musman3276a272015-03-21 10:12:56 +0000651 }
Richard Trieu6a77a1c2016-06-10 04:52:09 +0000652 if (C->getStep())
653 Profiler->VisitStmt(C->getStep());
654 if (C->getCalcStep())
655 Profiler->VisitStmt(C->getCalcStep());
Alexander Musman8dba6642014-04-22 13:09:42 +0000656}
Alexander Musmanf0d76e72014-05-29 14:36:25 +0000657void OMPClauseProfiler::VisitOMPAlignedClause(const OMPAlignedClause *C) {
658 VisitOMPClauseList(C);
Richard Trieu6a77a1c2016-06-10 04:52:09 +0000659 if (C->getAlignment())
660 Profiler->VisitStmt(C->getAlignment());
Alexander Musmanf0d76e72014-05-29 14:36:25 +0000661}
Alexey Bataevd48bcd82014-03-31 03:36:38 +0000662void OMPClauseProfiler::VisitOMPCopyinClause(const OMPCopyinClause *C) {
663 VisitOMPClauseList(C);
Alexey Bataevf56f98c2015-04-16 05:39:01 +0000664 for (auto *E : C->source_exprs()) {
Richard Trieu6a77a1c2016-06-10 04:52:09 +0000665 if (E)
666 Profiler->VisitStmt(E);
Alexey Bataevf56f98c2015-04-16 05:39:01 +0000667 }
668 for (auto *E : C->destination_exprs()) {
Richard Trieu6a77a1c2016-06-10 04:52:09 +0000669 if (E)
670 Profiler->VisitStmt(E);
Alexey Bataevf56f98c2015-04-16 05:39:01 +0000671 }
672 for (auto *E : C->assignment_ops()) {
Richard Trieu6a77a1c2016-06-10 04:52:09 +0000673 if (E)
674 Profiler->VisitStmt(E);
Alexey Bataevf56f98c2015-04-16 05:39:01 +0000675 }
Alexey Bataevd48bcd82014-03-31 03:36:38 +0000676}
Alexey Bataevbae9a792014-06-27 10:37:06 +0000677void
678OMPClauseProfiler::VisitOMPCopyprivateClause(const OMPCopyprivateClause *C) {
679 VisitOMPClauseList(C);
Alexey Bataeva63048e2015-03-23 06:18:07 +0000680 for (auto *E : C->source_exprs()) {
Richard Trieu6a77a1c2016-06-10 04:52:09 +0000681 if (E)
682 Profiler->VisitStmt(E);
Alexey Bataeva63048e2015-03-23 06:18:07 +0000683 }
684 for (auto *E : C->destination_exprs()) {
Richard Trieu6a77a1c2016-06-10 04:52:09 +0000685 if (E)
686 Profiler->VisitStmt(E);
Alexey Bataeva63048e2015-03-23 06:18:07 +0000687 }
688 for (auto *E : C->assignment_ops()) {
Richard Trieu6a77a1c2016-06-10 04:52:09 +0000689 if (E)
690 Profiler->VisitStmt(E);
Alexey Bataeva63048e2015-03-23 06:18:07 +0000691 }
Alexey Bataevbae9a792014-06-27 10:37:06 +0000692}
Alexey Bataev6125da92014-07-21 11:26:11 +0000693void OMPClauseProfiler::VisitOMPFlushClause(const OMPFlushClause *C) {
694 VisitOMPClauseList(C);
695}
Alexey Bataev1c2cfbc2015-06-23 14:25:19 +0000696void OMPClauseProfiler::VisitOMPDependClause(const OMPDependClause *C) {
697 VisitOMPClauseList(C);
698}
Michael Wonge710d542015-08-07 16:16:36 +0000699void OMPClauseProfiler::VisitOMPDeviceClause(const OMPDeviceClause *C) {
Richard Trieu6a77a1c2016-06-10 04:52:09 +0000700 if (C->getDevice())
701 Profiler->VisitStmt(C->getDevice());
Michael Wonge710d542015-08-07 16:16:36 +0000702}
Kelvin Li0bff7af2015-11-23 05:32:03 +0000703void OMPClauseProfiler::VisitOMPMapClause(const OMPMapClause *C) {
704 VisitOMPClauseList(C);
705}
Kelvin Li099bb8c2015-11-24 20:50:12 +0000706void OMPClauseProfiler::VisitOMPNumTeamsClause(const OMPNumTeamsClause *C) {
Arpith Chacko Jacobbc126342017-01-25 11:28:18 +0000707 VistOMPClauseWithPreInit(C);
Richard Trieu6a77a1c2016-06-10 04:52:09 +0000708 if (C->getNumTeams())
709 Profiler->VisitStmt(C->getNumTeams());
Kelvin Li099bb8c2015-11-24 20:50:12 +0000710}
Kelvin Lia15fb1a2015-11-27 18:47:36 +0000711void OMPClauseProfiler::VisitOMPThreadLimitClause(
712 const OMPThreadLimitClause *C) {
Arpith Chacko Jacob7ecc0b72017-01-25 11:44:35 +0000713 VistOMPClauseWithPreInit(C);
Richard Trieu6a77a1c2016-06-10 04:52:09 +0000714 if (C->getThreadLimit())
715 Profiler->VisitStmt(C->getThreadLimit());
Kelvin Lia15fb1a2015-11-27 18:47:36 +0000716}
Alexey Bataeva0569352015-12-01 10:17:31 +0000717void OMPClauseProfiler::VisitOMPPriorityClause(const OMPPriorityClause *C) {
Richard Trieu6a77a1c2016-06-10 04:52:09 +0000718 if (C->getPriority())
719 Profiler->VisitStmt(C->getPriority());
Alexey Bataeva0569352015-12-01 10:17:31 +0000720}
Alexey Bataev1fd4aed2015-12-07 12:52:51 +0000721void OMPClauseProfiler::VisitOMPGrainsizeClause(const OMPGrainsizeClause *C) {
Richard Trieu6a77a1c2016-06-10 04:52:09 +0000722 if (C->getGrainsize())
723 Profiler->VisitStmt(C->getGrainsize());
Alexey Bataev1fd4aed2015-12-07 12:52:51 +0000724}
Alexey Bataev382967a2015-12-08 12:06:20 +0000725void OMPClauseProfiler::VisitOMPNumTasksClause(const OMPNumTasksClause *C) {
Richard Trieu6a77a1c2016-06-10 04:52:09 +0000726 if (C->getNumTasks())
727 Profiler->VisitStmt(C->getNumTasks());
Alexey Bataev382967a2015-12-08 12:06:20 +0000728}
Alexey Bataev28c75412015-12-15 08:19:24 +0000729void OMPClauseProfiler::VisitOMPHintClause(const OMPHintClause *C) {
Richard Trieu6a77a1c2016-06-10 04:52:09 +0000730 if (C->getHint())
731 Profiler->VisitStmt(C->getHint());
Alexey Bataev28c75412015-12-15 08:19:24 +0000732}
Samuel Antao661c0902016-05-26 17:39:58 +0000733void OMPClauseProfiler::VisitOMPToClause(const OMPToClause *C) {
734 VisitOMPClauseList(C);
735}
Samuel Antaoec172c62016-05-26 17:49:04 +0000736void OMPClauseProfiler::VisitOMPFromClause(const OMPFromClause *C) {
737 VisitOMPClauseList(C);
738}
Carlo Bertolli2404b172016-07-13 15:37:16 +0000739void OMPClauseProfiler::VisitOMPUseDevicePtrClause(
740 const OMPUseDevicePtrClause *C) {
741 VisitOMPClauseList(C);
742}
Carlo Bertolli70594e92016-07-13 17:16:49 +0000743void OMPClauseProfiler::VisitOMPIsDevicePtrClause(
744 const OMPIsDevicePtrClause *C) {
745 VisitOMPClauseList(C);
746}
Alexander Kornienkoab9db512015-06-22 23:07:51 +0000747}
Alexey Bataev5ec3eb12013-07-19 03:13:43 +0000748
749void
Alexey Bataev1b59ab52014-02-27 08:29:12 +0000750StmtProfiler::VisitOMPExecutableDirective(const OMPExecutableDirective *S) {
Alexey Bataev5ec3eb12013-07-19 03:13:43 +0000751 VisitStmt(S);
752 OMPClauseProfiler P(this);
753 ArrayRef<OMPClause *> Clauses = S->clauses();
754 for (ArrayRef<OMPClause *>::iterator I = Clauses.begin(), E = Clauses.end();
755 I != E; ++I)
756 if (*I)
757 P.Visit(*I);
758}
759
Alexander Musman3aaab662014-08-19 11:27:13 +0000760void StmtProfiler::VisitOMPLoopDirective(const OMPLoopDirective *S) {
761 VisitOMPExecutableDirective(S);
762}
763
Alexey Bataev1b59ab52014-02-27 08:29:12 +0000764void StmtProfiler::VisitOMPParallelDirective(const OMPParallelDirective *S) {
765 VisitOMPExecutableDirective(S);
766}
767
768void StmtProfiler::VisitOMPSimdDirective(const OMPSimdDirective *S) {
Alexander Musman3aaab662014-08-19 11:27:13 +0000769 VisitOMPLoopDirective(S);
Alexey Bataev1b59ab52014-02-27 08:29:12 +0000770}
771
Alexey Bataevf29276e2014-06-18 04:14:57 +0000772void StmtProfiler::VisitOMPForDirective(const OMPForDirective *S) {
Alexander Musman3aaab662014-08-19 11:27:13 +0000773 VisitOMPLoopDirective(S);
Alexey Bataevf29276e2014-06-18 04:14:57 +0000774}
775
Alexander Musmanf82886e2014-09-18 05:12:34 +0000776void StmtProfiler::VisitOMPForSimdDirective(const OMPForSimdDirective *S) {
777 VisitOMPLoopDirective(S);
778}
779
Alexey Bataevd3f8dd22014-06-25 11:44:49 +0000780void StmtProfiler::VisitOMPSectionsDirective(const OMPSectionsDirective *S) {
781 VisitOMPExecutableDirective(S);
782}
783
Alexey Bataev1e0498a2014-06-26 08:21:58 +0000784void StmtProfiler::VisitOMPSectionDirective(const OMPSectionDirective *S) {
785 VisitOMPExecutableDirective(S);
786}
787
Alexey Bataevd1e40fb2014-06-26 12:05:45 +0000788void StmtProfiler::VisitOMPSingleDirective(const OMPSingleDirective *S) {
789 VisitOMPExecutableDirective(S);
790}
791
Alexander Musman80c22892014-07-17 08:54:58 +0000792void StmtProfiler::VisitOMPMasterDirective(const OMPMasterDirective *S) {
793 VisitOMPExecutableDirective(S);
794}
795
Alexander Musmand9ed09f2014-07-21 09:42:05 +0000796void StmtProfiler::VisitOMPCriticalDirective(const OMPCriticalDirective *S) {
797 VisitOMPExecutableDirective(S);
798 VisitName(S->getDirectiveName().getName());
799}
800
Alexey Bataev4acb8592014-07-07 13:01:15 +0000801void
802StmtProfiler::VisitOMPParallelForDirective(const OMPParallelForDirective *S) {
Alexander Musman3aaab662014-08-19 11:27:13 +0000803 VisitOMPLoopDirective(S);
Alexey Bataev4acb8592014-07-07 13:01:15 +0000804}
805
Alexander Musmane4e893b2014-09-23 09:33:00 +0000806void StmtProfiler::VisitOMPParallelForSimdDirective(
807 const OMPParallelForSimdDirective *S) {
808 VisitOMPLoopDirective(S);
809}
810
Alexey Bataev84d0b3e2014-07-08 08:12:03 +0000811void StmtProfiler::VisitOMPParallelSectionsDirective(
812 const OMPParallelSectionsDirective *S) {
813 VisitOMPExecutableDirective(S);
814}
815
Alexey Bataev9c2e8ee2014-07-11 11:25:16 +0000816void StmtProfiler::VisitOMPTaskDirective(const OMPTaskDirective *S) {
817 VisitOMPExecutableDirective(S);
818}
819
Alexey Bataev68446b72014-07-18 07:47:19 +0000820void StmtProfiler::VisitOMPTaskyieldDirective(const OMPTaskyieldDirective *S) {
821 VisitOMPExecutableDirective(S);
822}
823
Alexey Bataev4d1dfea2014-07-18 09:11:51 +0000824void StmtProfiler::VisitOMPBarrierDirective(const OMPBarrierDirective *S) {
825 VisitOMPExecutableDirective(S);
826}
827
Alexey Bataev2df347a2014-07-18 10:17:07 +0000828void StmtProfiler::VisitOMPTaskwaitDirective(const OMPTaskwaitDirective *S) {
829 VisitOMPExecutableDirective(S);
830}
831
Alexey Bataevc30dd2d2015-06-18 12:14:09 +0000832void StmtProfiler::VisitOMPTaskgroupDirective(const OMPTaskgroupDirective *S) {
833 VisitOMPExecutableDirective(S);
Alexey Bataev3b1b8952017-07-25 15:53:26 +0000834 if (const Expr *E = S->getReductionRef())
835 VisitStmt(E);
Alexey Bataevc30dd2d2015-06-18 12:14:09 +0000836}
837
Alexey Bataev6125da92014-07-21 11:26:11 +0000838void StmtProfiler::VisitOMPFlushDirective(const OMPFlushDirective *S) {
839 VisitOMPExecutableDirective(S);
840}
841
Alexey Bataev9fb6e642014-07-22 06:45:04 +0000842void StmtProfiler::VisitOMPOrderedDirective(const OMPOrderedDirective *S) {
843 VisitOMPExecutableDirective(S);
844}
845
Alexey Bataev0162e452014-07-22 10:10:35 +0000846void StmtProfiler::VisitOMPAtomicDirective(const OMPAtomicDirective *S) {
847 VisitOMPExecutableDirective(S);
848}
849
Alexey Bataev0bd520b2014-09-19 08:19:49 +0000850void StmtProfiler::VisitOMPTargetDirective(const OMPTargetDirective *S) {
851 VisitOMPExecutableDirective(S);
852}
853
Michael Wong65f367f2015-07-21 13:44:28 +0000854void StmtProfiler::VisitOMPTargetDataDirective(const OMPTargetDataDirective *S) {
855 VisitOMPExecutableDirective(S);
856}
857
Samuel Antaodf67fc42016-01-19 19:15:56 +0000858void StmtProfiler::VisitOMPTargetEnterDataDirective(
859 const OMPTargetEnterDataDirective *S) {
860 VisitOMPExecutableDirective(S);
861}
862
Samuel Antao72590762016-01-19 20:04:50 +0000863void StmtProfiler::VisitOMPTargetExitDataDirective(
864 const OMPTargetExitDataDirective *S) {
865 VisitOMPExecutableDirective(S);
866}
867
Arpith Chacko Jacobe955b3d2016-01-26 18:48:41 +0000868void StmtProfiler::VisitOMPTargetParallelDirective(
869 const OMPTargetParallelDirective *S) {
870 VisitOMPExecutableDirective(S);
871}
872
Arpith Chacko Jacob05bebb52016-02-03 15:46:42 +0000873void StmtProfiler::VisitOMPTargetParallelForDirective(
874 const OMPTargetParallelForDirective *S) {
875 VisitOMPExecutableDirective(S);
876}
877
Alexey Bataev13314bf2014-10-09 04:18:56 +0000878void StmtProfiler::VisitOMPTeamsDirective(const OMPTeamsDirective *S) {
879 VisitOMPExecutableDirective(S);
880}
881
Alexey Bataev6d4ed052015-07-01 06:57:41 +0000882void StmtProfiler::VisitOMPCancellationPointDirective(
883 const OMPCancellationPointDirective *S) {
884 VisitOMPExecutableDirective(S);
885}
886
Alexey Bataev80909872015-07-02 11:25:17 +0000887void StmtProfiler::VisitOMPCancelDirective(const OMPCancelDirective *S) {
888 VisitOMPExecutableDirective(S);
889}
890
Alexey Bataev49f6e782015-12-01 04:18:41 +0000891void StmtProfiler::VisitOMPTaskLoopDirective(const OMPTaskLoopDirective *S) {
892 VisitOMPLoopDirective(S);
893}
894
Alexey Bataev0a6ed842015-12-03 09:40:15 +0000895void StmtProfiler::VisitOMPTaskLoopSimdDirective(
896 const OMPTaskLoopSimdDirective *S) {
897 VisitOMPLoopDirective(S);
898}
899
Carlo Bertolli6200a3d2015-12-14 14:51:25 +0000900void StmtProfiler::VisitOMPDistributeDirective(
901 const OMPDistributeDirective *S) {
902 VisitOMPLoopDirective(S);
903}
904
Carlo Bertollib4adf552016-01-15 18:50:31 +0000905void OMPClauseProfiler::VisitOMPDistScheduleClause(
906 const OMPDistScheduleClause *C) {
Alexey Bataev3392d762016-02-16 11:18:12 +0000907 VistOMPClauseWithPreInit(C);
908 if (auto *S = C->getChunkSize())
909 Profiler->VisitStmt(S);
Carlo Bertollib4adf552016-01-15 18:50:31 +0000910}
911
Arpith Chacko Jacob3cf89042016-01-26 16:37:23 +0000912void OMPClauseProfiler::VisitOMPDefaultmapClause(const OMPDefaultmapClause *) {}
913
Samuel Antao686c70c2016-05-26 17:30:50 +0000914void StmtProfiler::VisitOMPTargetUpdateDirective(
915 const OMPTargetUpdateDirective *S) {
916 VisitOMPExecutableDirective(S);
917}
918
Carlo Bertolli9925f152016-06-27 14:55:37 +0000919void StmtProfiler::VisitOMPDistributeParallelForDirective(
920 const OMPDistributeParallelForDirective *S) {
921 VisitOMPLoopDirective(S);
922}
923
Kelvin Li4a39add2016-07-05 05:00:15 +0000924void StmtProfiler::VisitOMPDistributeParallelForSimdDirective(
925 const OMPDistributeParallelForSimdDirective *S) {
926 VisitOMPLoopDirective(S);
927}
928
Kelvin Li787f3fc2016-07-06 04:45:38 +0000929void StmtProfiler::VisitOMPDistributeSimdDirective(
930 const OMPDistributeSimdDirective *S) {
931 VisitOMPLoopDirective(S);
932}
933
Kelvin Lia579b912016-07-14 02:54:56 +0000934void StmtProfiler::VisitOMPTargetParallelForSimdDirective(
935 const OMPTargetParallelForSimdDirective *S) {
936 VisitOMPLoopDirective(S);
937}
938
Kelvin Li986330c2016-07-20 22:57:10 +0000939void StmtProfiler::VisitOMPTargetSimdDirective(
940 const OMPTargetSimdDirective *S) {
941 VisitOMPLoopDirective(S);
942}
943
Kelvin Li02532872016-08-05 14:37:37 +0000944void StmtProfiler::VisitOMPTeamsDistributeDirective(
945 const OMPTeamsDistributeDirective *S) {
946 VisitOMPLoopDirective(S);
947}
948
Kelvin Li4e325f72016-10-25 12:50:55 +0000949void StmtProfiler::VisitOMPTeamsDistributeSimdDirective(
950 const OMPTeamsDistributeSimdDirective *S) {
951 VisitOMPLoopDirective(S);
952}
953
Kelvin Li579e41c2016-11-30 23:51:03 +0000954void StmtProfiler::VisitOMPTeamsDistributeParallelForSimdDirective(
955 const OMPTeamsDistributeParallelForSimdDirective *S) {
956 VisitOMPLoopDirective(S);
957}
958
Kelvin Li7ade93f2016-12-09 03:24:30 +0000959void StmtProfiler::VisitOMPTeamsDistributeParallelForDirective(
960 const OMPTeamsDistributeParallelForDirective *S) {
961 VisitOMPLoopDirective(S);
962}
963
Kelvin Libf594a52016-12-17 05:48:59 +0000964void StmtProfiler::VisitOMPTargetTeamsDirective(
965 const OMPTargetTeamsDirective *S) {
966 VisitOMPExecutableDirective(S);
967}
968
Kelvin Li83c451e2016-12-25 04:52:54 +0000969void StmtProfiler::VisitOMPTargetTeamsDistributeDirective(
970 const OMPTargetTeamsDistributeDirective *S) {
971 VisitOMPLoopDirective(S);
972}
973
Kelvin Li80e8f562016-12-29 22:16:30 +0000974void StmtProfiler::VisitOMPTargetTeamsDistributeParallelForDirective(
975 const OMPTargetTeamsDistributeParallelForDirective *S) {
976 VisitOMPLoopDirective(S);
977}
978
Kelvin Li1851df52017-01-03 05:23:48 +0000979void StmtProfiler::VisitOMPTargetTeamsDistributeParallelForSimdDirective(
980 const OMPTargetTeamsDistributeParallelForSimdDirective *S) {
981 VisitOMPLoopDirective(S);
982}
983
Kelvin Lida681182017-01-10 18:08:18 +0000984void StmtProfiler::VisitOMPTargetTeamsDistributeSimdDirective(
985 const OMPTargetTeamsDistributeSimdDirective *S) {
986 VisitOMPLoopDirective(S);
987}
988
Chandler Carruth631abd92011-06-16 06:47:06 +0000989void StmtProfiler::VisitExpr(const Expr *S) {
Douglas Gregor5c193b92009-07-28 00:33:38 +0000990 VisitStmt(S);
991}
992
Chandler Carruth631abd92011-06-16 06:47:06 +0000993void StmtProfiler::VisitDeclRefExpr(const DeclRefExpr *S) {
Douglas Gregor5c193b92009-07-28 00:33:38 +0000994 VisitExpr(S);
Douglas Gregorf5b160f2010-07-13 08:37:11 +0000995 if (!Canonical)
996 VisitNestedNameSpecifier(S->getQualifier());
Douglas Gregor5c193b92009-07-28 00:33:38 +0000997 VisitDecl(S->getDecl());
Richard Trieu4d06bef2018-02-13 19:53:40 +0000998 if (!Canonical) {
999 ID.AddBoolean(S->hasExplicitTemplateArgs());
1000 if (S->hasExplicitTemplateArgs())
1001 VisitTemplateArguments(S->getTemplateArgs(), S->getNumTemplateArgs());
1002 }
Douglas Gregor5c193b92009-07-28 00:33:38 +00001003}
1004
Chandler Carruth631abd92011-06-16 06:47:06 +00001005void StmtProfiler::VisitPredefinedExpr(const PredefinedExpr *S) {
Douglas Gregor5c193b92009-07-28 00:33:38 +00001006 VisitExpr(S);
1007 ID.AddInteger(S->getIdentType());
1008}
1009
Chandler Carruth631abd92011-06-16 06:47:06 +00001010void StmtProfiler::VisitIntegerLiteral(const IntegerLiteral *S) {
Douglas Gregor5c193b92009-07-28 00:33:38 +00001011 VisitExpr(S);
1012 S->getValue().Profile(ID);
Richard Smithe9f130c2014-11-20 03:37:32 +00001013 ID.AddInteger(S->getType()->castAs<BuiltinType>()->getKind());
Douglas Gregor5c193b92009-07-28 00:33:38 +00001014}
1015
Leonard Chandb01c3a2018-06-20 17:19:40 +00001016void StmtProfiler::VisitFixedPointLiteral(const FixedPointLiteral *S) {
1017 VisitExpr(S);
1018 S->getValue().Profile(ID);
1019 ID.AddInteger(S->getType()->castAs<BuiltinType>()->getKind());
1020}
1021
Chandler Carruth631abd92011-06-16 06:47:06 +00001022void StmtProfiler::VisitCharacterLiteral(const CharacterLiteral *S) {
Douglas Gregor5c193b92009-07-28 00:33:38 +00001023 VisitExpr(S);
Douglas Gregorfb65e592011-07-27 05:40:30 +00001024 ID.AddInteger(S->getKind());
Douglas Gregor5c193b92009-07-28 00:33:38 +00001025 ID.AddInteger(S->getValue());
1026}
1027
Chandler Carruth631abd92011-06-16 06:47:06 +00001028void StmtProfiler::VisitFloatingLiteral(const FloatingLiteral *S) {
Douglas Gregor5c193b92009-07-28 00:33:38 +00001029 VisitExpr(S);
1030 S->getValue().Profile(ID);
1031 ID.AddBoolean(S->isExact());
Richard Smithe9f130c2014-11-20 03:37:32 +00001032 ID.AddInteger(S->getType()->castAs<BuiltinType>()->getKind());
Douglas Gregor5c193b92009-07-28 00:33:38 +00001033}
1034
Chandler Carruth631abd92011-06-16 06:47:06 +00001035void StmtProfiler::VisitImaginaryLiteral(const ImaginaryLiteral *S) {
Douglas Gregor5c193b92009-07-28 00:33:38 +00001036 VisitExpr(S);
1037}
1038
Chandler Carruth631abd92011-06-16 06:47:06 +00001039void StmtProfiler::VisitStringLiteral(const StringLiteral *S) {
Douglas Gregor5c193b92009-07-28 00:33:38 +00001040 VisitExpr(S);
Douglas Gregor9d0eb8f2011-11-02 17:26:05 +00001041 ID.AddString(S->getBytes());
Douglas Gregorfb65e592011-07-27 05:40:30 +00001042 ID.AddInteger(S->getKind());
Douglas Gregor5c193b92009-07-28 00:33:38 +00001043}
1044
Chandler Carruth631abd92011-06-16 06:47:06 +00001045void StmtProfiler::VisitParenExpr(const ParenExpr *S) {
Douglas Gregor5c193b92009-07-28 00:33:38 +00001046 VisitExpr(S);
1047}
1048
Chandler Carruth631abd92011-06-16 06:47:06 +00001049void StmtProfiler::VisitParenListExpr(const ParenListExpr *S) {
Nate Begeman5ec4b312009-08-10 23:49:36 +00001050 VisitExpr(S);
1051}
1052
Chandler Carruth631abd92011-06-16 06:47:06 +00001053void StmtProfiler::VisitUnaryOperator(const UnaryOperator *S) {
Douglas Gregor5c193b92009-07-28 00:33:38 +00001054 VisitExpr(S);
1055 ID.AddInteger(S->getOpcode());
1056}
1057
Chandler Carruth631abd92011-06-16 06:47:06 +00001058void StmtProfiler::VisitOffsetOfExpr(const OffsetOfExpr *S) {
Douglas Gregor882211c2010-04-28 22:16:22 +00001059 VisitType(S->getTypeSourceInfo()->getType());
1060 unsigned n = S->getNumComponents();
1061 for (unsigned i = 0; i < n; ++i) {
James Y Knight7281c352015-12-29 22:31:18 +00001062 const OffsetOfNode &ON = S->getComponent(i);
Douglas Gregor882211c2010-04-28 22:16:22 +00001063 ID.AddInteger(ON.getKind());
1064 switch (ON.getKind()) {
James Y Knight7281c352015-12-29 22:31:18 +00001065 case OffsetOfNode::Array:
Douglas Gregor882211c2010-04-28 22:16:22 +00001066 // Expressions handled below.
1067 break;
1068
James Y Knight7281c352015-12-29 22:31:18 +00001069 case OffsetOfNode::Field:
Douglas Gregor882211c2010-04-28 22:16:22 +00001070 VisitDecl(ON.getField());
1071 break;
1072
James Y Knight7281c352015-12-29 22:31:18 +00001073 case OffsetOfNode::Identifier:
Richard Trieu639d7b62017-02-22 22:22:42 +00001074 VisitIdentifierInfo(ON.getFieldName());
Douglas Gregor882211c2010-04-28 22:16:22 +00001075 break;
James Y Knight7281c352015-12-29 22:31:18 +00001076
1077 case OffsetOfNode::Base:
Douglas Gregord1702062010-04-29 00:18:15 +00001078 // These nodes are implicit, and therefore don't need profiling.
1079 break;
Douglas Gregor882211c2010-04-28 22:16:22 +00001080 }
1081 }
Richard Trieu639d7b62017-02-22 22:22:42 +00001082
Douglas Gregor882211c2010-04-28 22:16:22 +00001083 VisitExpr(S);
1084}
1085
Chandler Carruth631abd92011-06-16 06:47:06 +00001086void
1087StmtProfiler::VisitUnaryExprOrTypeTraitExpr(const UnaryExprOrTypeTraitExpr *S) {
Douglas Gregor5c193b92009-07-28 00:33:38 +00001088 VisitExpr(S);
Peter Collingbournee190dee2011-03-11 19:24:49 +00001089 ID.AddInteger(S->getKind());
Douglas Gregor5c193b92009-07-28 00:33:38 +00001090 if (S->isArgumentType())
1091 VisitType(S->getArgumentType());
1092}
1093
Chandler Carruth631abd92011-06-16 06:47:06 +00001094void StmtProfiler::VisitArraySubscriptExpr(const ArraySubscriptExpr *S) {
Douglas Gregor5c193b92009-07-28 00:33:38 +00001095 VisitExpr(S);
1096}
1097
Alexey Bataev1a3320e2015-08-25 14:24:04 +00001098void StmtProfiler::VisitOMPArraySectionExpr(const OMPArraySectionExpr *S) {
1099 VisitExpr(S);
1100}
1101
Chandler Carruth631abd92011-06-16 06:47:06 +00001102void StmtProfiler::VisitCallExpr(const CallExpr *S) {
Douglas Gregor5c193b92009-07-28 00:33:38 +00001103 VisitExpr(S);
1104}
1105
Chandler Carruth631abd92011-06-16 06:47:06 +00001106void StmtProfiler::VisitMemberExpr(const MemberExpr *S) {
Douglas Gregor5c193b92009-07-28 00:33:38 +00001107 VisitExpr(S);
1108 VisitDecl(S->getMemberDecl());
Douglas Gregorf5b160f2010-07-13 08:37:11 +00001109 if (!Canonical)
1110 VisitNestedNameSpecifier(S->getQualifier());
Douglas Gregor5c193b92009-07-28 00:33:38 +00001111 ID.AddBoolean(S->isArrow());
1112}
1113
Chandler Carruth631abd92011-06-16 06:47:06 +00001114void StmtProfiler::VisitCompoundLiteralExpr(const CompoundLiteralExpr *S) {
Douglas Gregor5c193b92009-07-28 00:33:38 +00001115 VisitExpr(S);
1116 ID.AddBoolean(S->isFileScope());
1117}
1118
Chandler Carruth631abd92011-06-16 06:47:06 +00001119void StmtProfiler::VisitCastExpr(const CastExpr *S) {
Douglas Gregor5c193b92009-07-28 00:33:38 +00001120 VisitExpr(S);
1121}
1122
Chandler Carruth631abd92011-06-16 06:47:06 +00001123void StmtProfiler::VisitImplicitCastExpr(const ImplicitCastExpr *S) {
Douglas Gregor5c193b92009-07-28 00:33:38 +00001124 VisitCastExpr(S);
John McCall2536c6d2010-08-25 10:28:54 +00001125 ID.AddInteger(S->getValueKind());
Douglas Gregor5c193b92009-07-28 00:33:38 +00001126}
1127
Chandler Carruth631abd92011-06-16 06:47:06 +00001128void StmtProfiler::VisitExplicitCastExpr(const ExplicitCastExpr *S) {
Douglas Gregor5c193b92009-07-28 00:33:38 +00001129 VisitCastExpr(S);
1130 VisitType(S->getTypeAsWritten());
1131}
1132
Chandler Carruth631abd92011-06-16 06:47:06 +00001133void StmtProfiler::VisitCStyleCastExpr(const CStyleCastExpr *S) {
Douglas Gregor5c193b92009-07-28 00:33:38 +00001134 VisitExplicitCastExpr(S);
1135}
1136
Chandler Carruth631abd92011-06-16 06:47:06 +00001137void StmtProfiler::VisitBinaryOperator(const BinaryOperator *S) {
Douglas Gregor5c193b92009-07-28 00:33:38 +00001138 VisitExpr(S);
1139 ID.AddInteger(S->getOpcode());
1140}
1141
Chandler Carruth631abd92011-06-16 06:47:06 +00001142void
1143StmtProfiler::VisitCompoundAssignOperator(const CompoundAssignOperator *S) {
Douglas Gregor5c193b92009-07-28 00:33:38 +00001144 VisitBinaryOperator(S);
1145}
1146
Chandler Carruth631abd92011-06-16 06:47:06 +00001147void StmtProfiler::VisitConditionalOperator(const ConditionalOperator *S) {
Douglas Gregor5c193b92009-07-28 00:33:38 +00001148 VisitExpr(S);
1149}
1150
Chandler Carruth631abd92011-06-16 06:47:06 +00001151void StmtProfiler::VisitBinaryConditionalOperator(
Chandler Carruthcf5f43c2011-06-21 23:26:32 +00001152 const BinaryConditionalOperator *S) {
John McCallc07a0c72011-02-17 10:25:35 +00001153 VisitExpr(S);
1154}
1155
Chandler Carruth631abd92011-06-16 06:47:06 +00001156void StmtProfiler::VisitAddrLabelExpr(const AddrLabelExpr *S) {
Douglas Gregor5c193b92009-07-28 00:33:38 +00001157 VisitExpr(S);
Chris Lattnerc8e630e2011-02-17 07:39:24 +00001158 VisitDecl(S->getLabel());
Douglas Gregor5c193b92009-07-28 00:33:38 +00001159}
1160
Chandler Carruth631abd92011-06-16 06:47:06 +00001161void StmtProfiler::VisitStmtExpr(const StmtExpr *S) {
Douglas Gregor5c193b92009-07-28 00:33:38 +00001162 VisitExpr(S);
1163}
1164
Chandler Carruth631abd92011-06-16 06:47:06 +00001165void StmtProfiler::VisitShuffleVectorExpr(const ShuffleVectorExpr *S) {
Douglas Gregor5c193b92009-07-28 00:33:38 +00001166 VisitExpr(S);
1167}
1168
Hal Finkelc4d7c822013-09-18 03:29:45 +00001169void StmtProfiler::VisitConvertVectorExpr(const ConvertVectorExpr *S) {
1170 VisitExpr(S);
1171}
1172
Chandler Carruth631abd92011-06-16 06:47:06 +00001173void StmtProfiler::VisitChooseExpr(const ChooseExpr *S) {
Douglas Gregor5c193b92009-07-28 00:33:38 +00001174 VisitExpr(S);
1175}
1176
Chandler Carruth631abd92011-06-16 06:47:06 +00001177void StmtProfiler::VisitGNUNullExpr(const GNUNullExpr *S) {
Douglas Gregor5c193b92009-07-28 00:33:38 +00001178 VisitExpr(S);
1179}
1180
Chandler Carruth631abd92011-06-16 06:47:06 +00001181void StmtProfiler::VisitVAArgExpr(const VAArgExpr *S) {
Douglas Gregor00044172009-07-29 16:09:57 +00001182 VisitExpr(S);
1183}
1184
Chandler Carruth631abd92011-06-16 06:47:06 +00001185void StmtProfiler::VisitInitListExpr(const InitListExpr *S) {
Douglas Gregor5c193b92009-07-28 00:33:38 +00001186 if (S->getSyntacticForm()) {
1187 VisitInitListExpr(S->getSyntacticForm());
1188 return;
1189 }
Mike Stump11289f42009-09-09 15:08:12 +00001190
Douglas Gregor5c193b92009-07-28 00:33:38 +00001191 VisitExpr(S);
1192}
1193
Chandler Carruth631abd92011-06-16 06:47:06 +00001194void StmtProfiler::VisitDesignatedInitExpr(const DesignatedInitExpr *S) {
Douglas Gregor5c193b92009-07-28 00:33:38 +00001195 VisitExpr(S);
1196 ID.AddBoolean(S->usesGNUSyntax());
David Majnemerf7e36092016-06-23 00:15:04 +00001197 for (const DesignatedInitExpr::Designator &D : S->designators()) {
1198 if (D.isFieldDesignator()) {
Douglas Gregor5c193b92009-07-28 00:33:38 +00001199 ID.AddInteger(0);
David Majnemerf7e36092016-06-23 00:15:04 +00001200 VisitName(D.getFieldName());
Douglas Gregor5c193b92009-07-28 00:33:38 +00001201 continue;
1202 }
Mike Stump11289f42009-09-09 15:08:12 +00001203
David Majnemerf7e36092016-06-23 00:15:04 +00001204 if (D.isArrayDesignator()) {
Douglas Gregor5c193b92009-07-28 00:33:38 +00001205 ID.AddInteger(1);
1206 } else {
David Majnemerf7e36092016-06-23 00:15:04 +00001207 assert(D.isArrayRangeDesignator());
Douglas Gregor5c193b92009-07-28 00:33:38 +00001208 ID.AddInteger(2);
1209 }
David Majnemerf7e36092016-06-23 00:15:04 +00001210 ID.AddInteger(D.getFirstExprIndex());
Douglas Gregor5c193b92009-07-28 00:33:38 +00001211 }
1212}
1213
Yunzhong Gaocb779302015-06-10 00:27:52 +00001214// Seems that if VisitInitListExpr() only works on the syntactic form of an
1215// InitListExpr, then a DesignatedInitUpdateExpr is not encountered.
1216void StmtProfiler::VisitDesignatedInitUpdateExpr(
1217 const DesignatedInitUpdateExpr *S) {
1218 llvm_unreachable("Unexpected DesignatedInitUpdateExpr in syntactic form of "
1219 "initializer");
1220}
1221
Richard Smith410306b2016-12-12 02:53:20 +00001222void StmtProfiler::VisitArrayInitLoopExpr(const ArrayInitLoopExpr *S) {
1223 VisitExpr(S);
1224}
1225
1226void StmtProfiler::VisitArrayInitIndexExpr(const ArrayInitIndexExpr *S) {
1227 VisitExpr(S);
1228}
1229
Yunzhong Gaocb779302015-06-10 00:27:52 +00001230void StmtProfiler::VisitNoInitExpr(const NoInitExpr *S) {
1231 llvm_unreachable("Unexpected NoInitExpr in syntactic form of initializer");
1232}
1233
Chandler Carruth631abd92011-06-16 06:47:06 +00001234void StmtProfiler::VisitImplicitValueInitExpr(const ImplicitValueInitExpr *S) {
Douglas Gregor5c193b92009-07-28 00:33:38 +00001235 VisitExpr(S);
1236}
1237
Chandler Carruth631abd92011-06-16 06:47:06 +00001238void StmtProfiler::VisitExtVectorElementExpr(const ExtVectorElementExpr *S) {
Douglas Gregor5c193b92009-07-28 00:33:38 +00001239 VisitExpr(S);
1240 VisitName(&S->getAccessor());
1241}
1242
Chandler Carruth631abd92011-06-16 06:47:06 +00001243void StmtProfiler::VisitBlockExpr(const BlockExpr *S) {
Douglas Gregor5c193b92009-07-28 00:33:38 +00001244 VisitExpr(S);
1245 VisitDecl(S->getBlockDecl());
1246}
1247
Chandler Carruth631abd92011-06-16 06:47:06 +00001248void StmtProfiler::VisitGenericSelectionExpr(const GenericSelectionExpr *S) {
Peter Collingbourne91147592011-04-15 00:35:48 +00001249 VisitExpr(S);
1250 for (unsigned i = 0; i != S->getNumAssocs(); ++i) {
1251 QualType T = S->getAssocType(i);
1252 if (T.isNull())
Craig Topper36250ad2014-05-12 05:36:57 +00001253 ID.AddPointer(nullptr);
Peter Collingbourne91147592011-04-15 00:35:48 +00001254 else
1255 VisitType(T);
1256 VisitExpr(S->getAssocExpr(i));
1257 }
1258}
1259
John McCallfe96e0b2011-11-06 09:01:30 +00001260void StmtProfiler::VisitPseudoObjectExpr(const PseudoObjectExpr *S) {
1261 VisitExpr(S);
1262 for (PseudoObjectExpr::const_semantics_iterator
1263 i = S->semantics_begin(), e = S->semantics_end(); i != e; ++i)
1264 // Normally, we would not profile the source expressions of OVEs.
1265 if (const OpaqueValueExpr *OVE = dyn_cast<OpaqueValueExpr>(*i))
1266 Visit(OVE->getSourceExpr());
1267}
1268
Eli Friedmandf14b3a2011-10-11 02:20:01 +00001269void StmtProfiler::VisitAtomicExpr(const AtomicExpr *S) {
1270 VisitExpr(S);
Eli Friedman4b72fdd2011-10-14 20:59:01 +00001271 ID.AddInteger(S->getOp());
Eli Friedmandf14b3a2011-10-11 02:20:01 +00001272}
1273
Chandler Carruth631abd92011-06-16 06:47:06 +00001274static Stmt::StmtClass DecodeOperatorCall(const CXXOperatorCallExpr *S,
John McCalle3027922010-08-25 11:45:40 +00001275 UnaryOperatorKind &UnaryOp,
1276 BinaryOperatorKind &BinaryOp) {
Douglas Gregore9ceb312010-05-19 04:13:23 +00001277 switch (S->getOperator()) {
1278 case OO_None:
1279 case OO_New:
1280 case OO_Delete:
1281 case OO_Array_New:
1282 case OO_Array_Delete:
1283 case OO_Arrow:
1284 case OO_Call:
1285 case OO_Conditional:
1286 case NUM_OVERLOADED_OPERATORS:
1287 llvm_unreachable("Invalid operator call kind");
Fangrui Song6907ce22018-07-30 19:24:48 +00001288
Douglas Gregore9ceb312010-05-19 04:13:23 +00001289 case OO_Plus:
1290 if (S->getNumArgs() == 1) {
John McCalle3027922010-08-25 11:45:40 +00001291 UnaryOp = UO_Plus;
Douglas Gregore9ceb312010-05-19 04:13:23 +00001292 return Stmt::UnaryOperatorClass;
1293 }
Fangrui Song6907ce22018-07-30 19:24:48 +00001294
John McCalle3027922010-08-25 11:45:40 +00001295 BinaryOp = BO_Add;
Douglas Gregore9ceb312010-05-19 04:13:23 +00001296 return Stmt::BinaryOperatorClass;
Fangrui Song6907ce22018-07-30 19:24:48 +00001297
Douglas Gregore9ceb312010-05-19 04:13:23 +00001298 case OO_Minus:
1299 if (S->getNumArgs() == 1) {
John McCalle3027922010-08-25 11:45:40 +00001300 UnaryOp = UO_Minus;
Douglas Gregore9ceb312010-05-19 04:13:23 +00001301 return Stmt::UnaryOperatorClass;
1302 }
Fangrui Song6907ce22018-07-30 19:24:48 +00001303
John McCalle3027922010-08-25 11:45:40 +00001304 BinaryOp = BO_Sub;
Douglas Gregore9ceb312010-05-19 04:13:23 +00001305 return Stmt::BinaryOperatorClass;
1306
1307 case OO_Star:
1308 if (S->getNumArgs() == 1) {
Richard Smithf15acc52014-06-05 22:43:40 +00001309 UnaryOp = UO_Deref;
Douglas Gregore9ceb312010-05-19 04:13:23 +00001310 return Stmt::UnaryOperatorClass;
1311 }
Fangrui Song6907ce22018-07-30 19:24:48 +00001312
Richard Smithf15acc52014-06-05 22:43:40 +00001313 BinaryOp = BO_Mul;
Douglas Gregore9ceb312010-05-19 04:13:23 +00001314 return Stmt::BinaryOperatorClass;
1315
1316 case OO_Slash:
John McCalle3027922010-08-25 11:45:40 +00001317 BinaryOp = BO_Div;
Douglas Gregore9ceb312010-05-19 04:13:23 +00001318 return Stmt::BinaryOperatorClass;
Fangrui Song6907ce22018-07-30 19:24:48 +00001319
Douglas Gregore9ceb312010-05-19 04:13:23 +00001320 case OO_Percent:
John McCalle3027922010-08-25 11:45:40 +00001321 BinaryOp = BO_Rem;
Douglas Gregore9ceb312010-05-19 04:13:23 +00001322 return Stmt::BinaryOperatorClass;
1323
1324 case OO_Caret:
John McCalle3027922010-08-25 11:45:40 +00001325 BinaryOp = BO_Xor;
Douglas Gregore9ceb312010-05-19 04:13:23 +00001326 return Stmt::BinaryOperatorClass;
1327
1328 case OO_Amp:
1329 if (S->getNumArgs() == 1) {
John McCalle3027922010-08-25 11:45:40 +00001330 UnaryOp = UO_AddrOf;
Douglas Gregore9ceb312010-05-19 04:13:23 +00001331 return Stmt::UnaryOperatorClass;
1332 }
Fangrui Song6907ce22018-07-30 19:24:48 +00001333
John McCalle3027922010-08-25 11:45:40 +00001334 BinaryOp = BO_And;
Douglas Gregore9ceb312010-05-19 04:13:23 +00001335 return Stmt::BinaryOperatorClass;
Fangrui Song6907ce22018-07-30 19:24:48 +00001336
Douglas Gregore9ceb312010-05-19 04:13:23 +00001337 case OO_Pipe:
John McCalle3027922010-08-25 11:45:40 +00001338 BinaryOp = BO_Or;
Douglas Gregore9ceb312010-05-19 04:13:23 +00001339 return Stmt::BinaryOperatorClass;
1340
1341 case OO_Tilde:
John McCalle3027922010-08-25 11:45:40 +00001342 UnaryOp = UO_Not;
Douglas Gregore9ceb312010-05-19 04:13:23 +00001343 return Stmt::UnaryOperatorClass;
1344
1345 case OO_Exclaim:
John McCalle3027922010-08-25 11:45:40 +00001346 UnaryOp = UO_LNot;
Douglas Gregore9ceb312010-05-19 04:13:23 +00001347 return Stmt::UnaryOperatorClass;
1348
1349 case OO_Equal:
John McCalle3027922010-08-25 11:45:40 +00001350 BinaryOp = BO_Assign;
Douglas Gregore9ceb312010-05-19 04:13:23 +00001351 return Stmt::BinaryOperatorClass;
1352
1353 case OO_Less:
John McCalle3027922010-08-25 11:45:40 +00001354 BinaryOp = BO_LT;
Douglas Gregore9ceb312010-05-19 04:13:23 +00001355 return Stmt::BinaryOperatorClass;
1356
1357 case OO_Greater:
John McCalle3027922010-08-25 11:45:40 +00001358 BinaryOp = BO_GT;
Douglas Gregore9ceb312010-05-19 04:13:23 +00001359 return Stmt::BinaryOperatorClass;
Fangrui Song6907ce22018-07-30 19:24:48 +00001360
Douglas Gregore9ceb312010-05-19 04:13:23 +00001361 case OO_PlusEqual:
John McCalle3027922010-08-25 11:45:40 +00001362 BinaryOp = BO_AddAssign;
Douglas Gregore9ceb312010-05-19 04:13:23 +00001363 return Stmt::CompoundAssignOperatorClass;
1364
1365 case OO_MinusEqual:
John McCalle3027922010-08-25 11:45:40 +00001366 BinaryOp = BO_SubAssign;
Douglas Gregore9ceb312010-05-19 04:13:23 +00001367 return Stmt::CompoundAssignOperatorClass;
1368
1369 case OO_StarEqual:
John McCalle3027922010-08-25 11:45:40 +00001370 BinaryOp = BO_MulAssign;
Douglas Gregore9ceb312010-05-19 04:13:23 +00001371 return Stmt::CompoundAssignOperatorClass;
1372
1373 case OO_SlashEqual:
John McCalle3027922010-08-25 11:45:40 +00001374 BinaryOp = BO_DivAssign;
Douglas Gregore9ceb312010-05-19 04:13:23 +00001375 return Stmt::CompoundAssignOperatorClass;
1376
1377 case OO_PercentEqual:
John McCalle3027922010-08-25 11:45:40 +00001378 BinaryOp = BO_RemAssign;
Douglas Gregore9ceb312010-05-19 04:13:23 +00001379 return Stmt::CompoundAssignOperatorClass;
1380
1381 case OO_CaretEqual:
John McCalle3027922010-08-25 11:45:40 +00001382 BinaryOp = BO_XorAssign;
Douglas Gregore9ceb312010-05-19 04:13:23 +00001383 return Stmt::CompoundAssignOperatorClass;
Fangrui Song6907ce22018-07-30 19:24:48 +00001384
Douglas Gregore9ceb312010-05-19 04:13:23 +00001385 case OO_AmpEqual:
John McCalle3027922010-08-25 11:45:40 +00001386 BinaryOp = BO_AndAssign;
Douglas Gregore9ceb312010-05-19 04:13:23 +00001387 return Stmt::CompoundAssignOperatorClass;
Fangrui Song6907ce22018-07-30 19:24:48 +00001388
Douglas Gregore9ceb312010-05-19 04:13:23 +00001389 case OO_PipeEqual:
John McCalle3027922010-08-25 11:45:40 +00001390 BinaryOp = BO_OrAssign;
Douglas Gregore9ceb312010-05-19 04:13:23 +00001391 return Stmt::CompoundAssignOperatorClass;
Fangrui Song6907ce22018-07-30 19:24:48 +00001392
Douglas Gregore9ceb312010-05-19 04:13:23 +00001393 case OO_LessLess:
John McCalle3027922010-08-25 11:45:40 +00001394 BinaryOp = BO_Shl;
Douglas Gregore9ceb312010-05-19 04:13:23 +00001395 return Stmt::BinaryOperatorClass;
Fangrui Song6907ce22018-07-30 19:24:48 +00001396
Douglas Gregore9ceb312010-05-19 04:13:23 +00001397 case OO_GreaterGreater:
John McCalle3027922010-08-25 11:45:40 +00001398 BinaryOp = BO_Shr;
Douglas Gregore9ceb312010-05-19 04:13:23 +00001399 return Stmt::BinaryOperatorClass;
1400
1401 case OO_LessLessEqual:
John McCalle3027922010-08-25 11:45:40 +00001402 BinaryOp = BO_ShlAssign;
Douglas Gregore9ceb312010-05-19 04:13:23 +00001403 return Stmt::CompoundAssignOperatorClass;
Fangrui Song6907ce22018-07-30 19:24:48 +00001404
Douglas Gregore9ceb312010-05-19 04:13:23 +00001405 case OO_GreaterGreaterEqual:
John McCalle3027922010-08-25 11:45:40 +00001406 BinaryOp = BO_ShrAssign;
Douglas Gregore9ceb312010-05-19 04:13:23 +00001407 return Stmt::CompoundAssignOperatorClass;
1408
1409 case OO_EqualEqual:
John McCalle3027922010-08-25 11:45:40 +00001410 BinaryOp = BO_EQ;
Douglas Gregore9ceb312010-05-19 04:13:23 +00001411 return Stmt::BinaryOperatorClass;
Fangrui Song6907ce22018-07-30 19:24:48 +00001412
Douglas Gregore9ceb312010-05-19 04:13:23 +00001413 case OO_ExclaimEqual:
John McCalle3027922010-08-25 11:45:40 +00001414 BinaryOp = BO_NE;
Douglas Gregore9ceb312010-05-19 04:13:23 +00001415 return Stmt::BinaryOperatorClass;
Fangrui Song6907ce22018-07-30 19:24:48 +00001416
Douglas Gregore9ceb312010-05-19 04:13:23 +00001417 case OO_LessEqual:
John McCalle3027922010-08-25 11:45:40 +00001418 BinaryOp = BO_LE;
Douglas Gregore9ceb312010-05-19 04:13:23 +00001419 return Stmt::BinaryOperatorClass;
Fangrui Song6907ce22018-07-30 19:24:48 +00001420
Douglas Gregore9ceb312010-05-19 04:13:23 +00001421 case OO_GreaterEqual:
John McCalle3027922010-08-25 11:45:40 +00001422 BinaryOp = BO_GE;
Douglas Gregore9ceb312010-05-19 04:13:23 +00001423 return Stmt::BinaryOperatorClass;
Richard Smithd30b23d2017-12-01 02:13:10 +00001424
1425 case OO_Spaceship:
1426 // FIXME: Update this once we support <=> expressions.
1427 llvm_unreachable("<=> expressions not supported yet");
Fangrui Song6907ce22018-07-30 19:24:48 +00001428
Douglas Gregore9ceb312010-05-19 04:13:23 +00001429 case OO_AmpAmp:
John McCalle3027922010-08-25 11:45:40 +00001430 BinaryOp = BO_LAnd;
Douglas Gregore9ceb312010-05-19 04:13:23 +00001431 return Stmt::BinaryOperatorClass;
Fangrui Song6907ce22018-07-30 19:24:48 +00001432
Douglas Gregore9ceb312010-05-19 04:13:23 +00001433 case OO_PipePipe:
John McCalle3027922010-08-25 11:45:40 +00001434 BinaryOp = BO_LOr;
Douglas Gregore9ceb312010-05-19 04:13:23 +00001435 return Stmt::BinaryOperatorClass;
1436
1437 case OO_PlusPlus:
Fangrui Song6907ce22018-07-30 19:24:48 +00001438 UnaryOp = S->getNumArgs() == 1? UO_PreInc
John McCalle3027922010-08-25 11:45:40 +00001439 : UO_PostInc;
Douglas Gregore9ceb312010-05-19 04:13:23 +00001440 return Stmt::UnaryOperatorClass;
1441
1442 case OO_MinusMinus:
John McCalle3027922010-08-25 11:45:40 +00001443 UnaryOp = S->getNumArgs() == 1? UO_PreDec
1444 : UO_PostDec;
Douglas Gregore9ceb312010-05-19 04:13:23 +00001445 return Stmt::UnaryOperatorClass;
1446
1447 case OO_Comma:
John McCalle3027922010-08-25 11:45:40 +00001448 BinaryOp = BO_Comma;
Douglas Gregore9ceb312010-05-19 04:13:23 +00001449 return Stmt::BinaryOperatorClass;
1450
Douglas Gregore9ceb312010-05-19 04:13:23 +00001451 case OO_ArrowStar:
John McCalle3027922010-08-25 11:45:40 +00001452 BinaryOp = BO_PtrMemI;
Douglas Gregore9ceb312010-05-19 04:13:23 +00001453 return Stmt::BinaryOperatorClass;
Fangrui Song6907ce22018-07-30 19:24:48 +00001454
Douglas Gregore9ceb312010-05-19 04:13:23 +00001455 case OO_Subscript:
1456 return Stmt::ArraySubscriptExprClass;
Richard Smith6fff5c42018-07-31 00:47:41 +00001457
1458 case OO_Coawait:
1459 UnaryOp = UO_Coawait;
1460 return Stmt::UnaryOperatorClass;
Douglas Gregore9ceb312010-05-19 04:13:23 +00001461 }
Fangrui Song6907ce22018-07-30 19:24:48 +00001462
Douglas Gregore9ceb312010-05-19 04:13:23 +00001463 llvm_unreachable("Invalid overloaded operator expression");
1464}
Richard Smithf15acc52014-06-05 22:43:40 +00001465
Reid Klecknere257e182017-10-13 16:18:32 +00001466#if defined(_MSC_VER) && !defined(__clang__)
Nico Weberf56f4462017-07-24 16:54:11 +00001467#if _MSC_VER == 1911
1468// Work around https://developercommunity.visualstudio.com/content/problem/84002/clang-cl-when-built-with-vc-2017-crashes-cause-vc.html
1469// MSVC 2017 update 3 miscompiles this function, and a clang built with it
1470// will crash in stage 2 of a bootstrap build.
1471#pragma optimize("", off)
1472#endif
1473#endif
1474
Chandler Carruth631abd92011-06-16 06:47:06 +00001475void StmtProfiler::VisitCXXOperatorCallExpr(const CXXOperatorCallExpr *S) {
Douglas Gregore9ceb312010-05-19 04:13:23 +00001476 if (S->isTypeDependent()) {
1477 // Type-dependent operator calls are profiled like their underlying
1478 // syntactic operator.
Richard Smithbac0a0d2016-10-24 18:47:04 +00001479 //
1480 // An operator call to operator-> is always implicit, so just skip it. The
1481 // enclosing MemberExpr will profile the actual member access.
1482 if (S->getOperator() == OO_Arrow)
1483 return Visit(S->getArg(0));
1484
John McCalle3027922010-08-25 11:45:40 +00001485 UnaryOperatorKind UnaryOp = UO_Extension;
1486 BinaryOperatorKind BinaryOp = BO_Comma;
Douglas Gregore9ceb312010-05-19 04:13:23 +00001487 Stmt::StmtClass SC = DecodeOperatorCall(S, UnaryOp, BinaryOp);
Richard Smithf15acc52014-06-05 22:43:40 +00001488
Douglas Gregore9ceb312010-05-19 04:13:23 +00001489 ID.AddInteger(SC);
1490 for (unsigned I = 0, N = S->getNumArgs(); I != N; ++I)
1491 Visit(S->getArg(I));
1492 if (SC == Stmt::UnaryOperatorClass)
1493 ID.AddInteger(UnaryOp);
Fangrui Song6907ce22018-07-30 19:24:48 +00001494 else if (SC == Stmt::BinaryOperatorClass ||
Douglas Gregore9ceb312010-05-19 04:13:23 +00001495 SC == Stmt::CompoundAssignOperatorClass)
1496 ID.AddInteger(BinaryOp);
1497 else
1498 assert(SC == Stmt::ArraySubscriptExprClass);
Richard Smithf15acc52014-06-05 22:43:40 +00001499
Douglas Gregore9ceb312010-05-19 04:13:23 +00001500 return;
1501 }
Richard Smithf15acc52014-06-05 22:43:40 +00001502
Douglas Gregor5c193b92009-07-28 00:33:38 +00001503 VisitCallExpr(S);
1504 ID.AddInteger(S->getOperator());
1505}
1506
Reid Klecknere257e182017-10-13 16:18:32 +00001507#if defined(_MSC_VER) && !defined(__clang__)
Nico Weberf56f4462017-07-24 16:54:11 +00001508#if _MSC_VER == 1911
1509#pragma optimize("", on)
1510#endif
1511#endif
1512
Chandler Carruth631abd92011-06-16 06:47:06 +00001513void StmtProfiler::VisitCXXMemberCallExpr(const CXXMemberCallExpr *S) {
Douglas Gregor5c193b92009-07-28 00:33:38 +00001514 VisitCallExpr(S);
1515}
1516
Chandler Carruth631abd92011-06-16 06:47:06 +00001517void StmtProfiler::VisitCUDAKernelCallExpr(const CUDAKernelCallExpr *S) {
Peter Collingbourne41f85462011-02-09 21:07:24 +00001518 VisitCallExpr(S);
1519}
1520
Chandler Carruth631abd92011-06-16 06:47:06 +00001521void StmtProfiler::VisitAsTypeExpr(const AsTypeExpr *S) {
Tanya Lattner55808c12011-06-04 00:47:47 +00001522 VisitExpr(S);
1523}
1524
Chandler Carruth631abd92011-06-16 06:47:06 +00001525void StmtProfiler::VisitCXXNamedCastExpr(const CXXNamedCastExpr *S) {
Douglas Gregor5c193b92009-07-28 00:33:38 +00001526 VisitExplicitCastExpr(S);
1527}
1528
Chandler Carruth631abd92011-06-16 06:47:06 +00001529void StmtProfiler::VisitCXXStaticCastExpr(const CXXStaticCastExpr *S) {
Douglas Gregor5c193b92009-07-28 00:33:38 +00001530 VisitCXXNamedCastExpr(S);
1531}
1532
Chandler Carruth631abd92011-06-16 06:47:06 +00001533void StmtProfiler::VisitCXXDynamicCastExpr(const CXXDynamicCastExpr *S) {
Douglas Gregor5c193b92009-07-28 00:33:38 +00001534 VisitCXXNamedCastExpr(S);
1535}
1536
Chandler Carruth631abd92011-06-16 06:47:06 +00001537void
1538StmtProfiler::VisitCXXReinterpretCastExpr(const CXXReinterpretCastExpr *S) {
Douglas Gregor5c193b92009-07-28 00:33:38 +00001539 VisitCXXNamedCastExpr(S);
1540}
1541
Chandler Carruth631abd92011-06-16 06:47:06 +00001542void StmtProfiler::VisitCXXConstCastExpr(const CXXConstCastExpr *S) {
Douglas Gregor5c193b92009-07-28 00:33:38 +00001543 VisitCXXNamedCastExpr(S);
1544}
1545
Richard Smithc67fdd42012-03-07 08:35:16 +00001546void StmtProfiler::VisitUserDefinedLiteral(const UserDefinedLiteral *S) {
1547 VisitCallExpr(S);
1548}
1549
Chandler Carruth631abd92011-06-16 06:47:06 +00001550void StmtProfiler::VisitCXXBoolLiteralExpr(const CXXBoolLiteralExpr *S) {
Douglas Gregor5c193b92009-07-28 00:33:38 +00001551 VisitExpr(S);
1552 ID.AddBoolean(S->getValue());
1553}
1554
Chandler Carruth631abd92011-06-16 06:47:06 +00001555void StmtProfiler::VisitCXXNullPtrLiteralExpr(const CXXNullPtrLiteralExpr *S) {
Douglas Gregor00044172009-07-29 16:09:57 +00001556 VisitExpr(S);
1557}
1558
Richard Smithcc1b96d2013-06-12 22:31:48 +00001559void StmtProfiler::VisitCXXStdInitializerListExpr(
1560 const CXXStdInitializerListExpr *S) {
1561 VisitExpr(S);
1562}
1563
Chandler Carruth631abd92011-06-16 06:47:06 +00001564void StmtProfiler::VisitCXXTypeidExpr(const CXXTypeidExpr *S) {
Douglas Gregor5c193b92009-07-28 00:33:38 +00001565 VisitExpr(S);
1566 if (S->isTypeOperand())
David Majnemer143c55e2013-09-27 07:04:31 +00001567 VisitType(S->getTypeOperandSourceInfo()->getType());
Douglas Gregor5c193b92009-07-28 00:33:38 +00001568}
1569
Chandler Carruth631abd92011-06-16 06:47:06 +00001570void StmtProfiler::VisitCXXUuidofExpr(const CXXUuidofExpr *S) {
Francois Pichet9f4f2072010-09-08 12:20:18 +00001571 VisitExpr(S);
1572 if (S->isTypeOperand())
David Majnemer143c55e2013-09-27 07:04:31 +00001573 VisitType(S->getTypeOperandSourceInfo()->getType());
Francois Pichet9f4f2072010-09-08 12:20:18 +00001574}
1575
John McCall5e77d762013-04-16 07:28:30 +00001576void StmtProfiler::VisitMSPropertyRefExpr(const MSPropertyRefExpr *S) {
1577 VisitExpr(S);
1578 VisitDecl(S->getPropertyDecl());
1579}
1580
Alexey Bataevf7630272015-11-25 12:01:00 +00001581void StmtProfiler::VisitMSPropertySubscriptExpr(
1582 const MSPropertySubscriptExpr *S) {
1583 VisitExpr(S);
1584}
1585
Chandler Carruth631abd92011-06-16 06:47:06 +00001586void StmtProfiler::VisitCXXThisExpr(const CXXThisExpr *S) {
Douglas Gregor5c193b92009-07-28 00:33:38 +00001587 VisitExpr(S);
Douglas Gregor3024f072012-04-16 07:05:22 +00001588 ID.AddBoolean(S->isImplicit());
Douglas Gregor5c193b92009-07-28 00:33:38 +00001589}
1590
Chandler Carruth631abd92011-06-16 06:47:06 +00001591void StmtProfiler::VisitCXXThrowExpr(const CXXThrowExpr *S) {
Douglas Gregor5c193b92009-07-28 00:33:38 +00001592 VisitExpr(S);
1593}
1594
Chandler Carruth631abd92011-06-16 06:47:06 +00001595void StmtProfiler::VisitCXXDefaultArgExpr(const CXXDefaultArgExpr *S) {
Douglas Gregor5c193b92009-07-28 00:33:38 +00001596 VisitExpr(S);
1597 VisitDecl(S->getParam());
1598}
1599
Richard Smith852c9db2013-04-20 22:23:05 +00001600void StmtProfiler::VisitCXXDefaultInitExpr(const CXXDefaultInitExpr *S) {
1601 VisitExpr(S);
1602 VisitDecl(S->getField());
1603}
1604
Chandler Carruth631abd92011-06-16 06:47:06 +00001605void StmtProfiler::VisitCXXBindTemporaryExpr(const CXXBindTemporaryExpr *S) {
Douglas Gregor5c193b92009-07-28 00:33:38 +00001606 VisitExpr(S);
1607 VisitDecl(
1608 const_cast<CXXDestructorDecl *>(S->getTemporary()->getDestructor()));
1609}
1610
Chandler Carruth631abd92011-06-16 06:47:06 +00001611void StmtProfiler::VisitCXXConstructExpr(const CXXConstructExpr *S) {
Douglas Gregor5c193b92009-07-28 00:33:38 +00001612 VisitExpr(S);
1613 VisitDecl(S->getConstructor());
1614 ID.AddBoolean(S->isElidable());
1615}
1616
Richard Smith5179eb72016-06-28 19:03:57 +00001617void StmtProfiler::VisitCXXInheritedCtorInitExpr(
1618 const CXXInheritedCtorInitExpr *S) {
1619 VisitExpr(S);
1620 VisitDecl(S->getConstructor());
1621}
1622
Chandler Carruth631abd92011-06-16 06:47:06 +00001623void StmtProfiler::VisitCXXFunctionalCastExpr(const CXXFunctionalCastExpr *S) {
Douglas Gregor5c193b92009-07-28 00:33:38 +00001624 VisitExplicitCastExpr(S);
1625}
1626
Chandler Carruth631abd92011-06-16 06:47:06 +00001627void
1628StmtProfiler::VisitCXXTemporaryObjectExpr(const CXXTemporaryObjectExpr *S) {
Douglas Gregor5c193b92009-07-28 00:33:38 +00001629 VisitCXXConstructExpr(S);
1630}
1631
Chandler Carruth631abd92011-06-16 06:47:06 +00001632void
Douglas Gregore31e6062012-02-07 10:09:13 +00001633StmtProfiler::VisitLambdaExpr(const LambdaExpr *S) {
1634 VisitExpr(S);
1635 for (LambdaExpr::capture_iterator C = S->explicit_capture_begin(),
1636 CEnd = S->explicit_capture_end();
1637 C != CEnd; ++C) {
Richard Trieu931638e2017-11-11 00:54:25 +00001638 if (C->capturesVLAType())
1639 continue;
1640
Douglas Gregore31e6062012-02-07 10:09:13 +00001641 ID.AddInteger(C->getCaptureKind());
Richard Smithba71c082013-05-16 06:20:58 +00001642 switch (C->getCaptureKind()) {
Faisal Validc6b5962016-03-21 09:25:37 +00001643 case LCK_StarThis:
Richard Smithba71c082013-05-16 06:20:58 +00001644 case LCK_This:
1645 break;
1646 case LCK_ByRef:
1647 case LCK_ByCopy:
Douglas Gregore31e6062012-02-07 10:09:13 +00001648 VisitDecl(C->getCapturedVar());
1649 ID.AddBoolean(C->isPackExpansion());
Richard Smithba71c082013-05-16 06:20:58 +00001650 break;
Alexey Bataev39c81e22014-08-28 04:28:19 +00001651 case LCK_VLAType:
1652 llvm_unreachable("VLA type in explicit captures.");
Douglas Gregore31e6062012-02-07 10:09:13 +00001653 }
1654 }
1655 // Note: If we actually needed to be able to match lambda
1656 // expressions, we would have to consider parameters and return type
1657 // here, among other things.
1658 VisitStmt(S->getBody());
1659}
1660
1661void
Chandler Carruth631abd92011-06-16 06:47:06 +00001662StmtProfiler::VisitCXXScalarValueInitExpr(const CXXScalarValueInitExpr *S) {
Douglas Gregor5c193b92009-07-28 00:33:38 +00001663 VisitExpr(S);
1664}
1665
Chandler Carruth631abd92011-06-16 06:47:06 +00001666void StmtProfiler::VisitCXXDeleteExpr(const CXXDeleteExpr *S) {
Douglas Gregor5c193b92009-07-28 00:33:38 +00001667 VisitExpr(S);
1668 ID.AddBoolean(S->isGlobalDelete());
1669 ID.AddBoolean(S->isArrayForm());
1670 VisitDecl(S->getOperatorDelete());
1671}
1672
Chandler Carruth631abd92011-06-16 06:47:06 +00001673void StmtProfiler::VisitCXXNewExpr(const CXXNewExpr *S) {
Douglas Gregor5c193b92009-07-28 00:33:38 +00001674 VisitExpr(S);
1675 VisitType(S->getAllocatedType());
1676 VisitDecl(S->getOperatorNew());
1677 VisitDecl(S->getOperatorDelete());
Douglas Gregor5c193b92009-07-28 00:33:38 +00001678 ID.AddBoolean(S->isArray());
1679 ID.AddInteger(S->getNumPlacementArgs());
1680 ID.AddBoolean(S->isGlobalNew());
1681 ID.AddBoolean(S->isParenTypeId());
Sebastian Redl6047f072012-02-16 12:22:20 +00001682 ID.AddInteger(S->getInitializationStyle());
Douglas Gregor5c193b92009-07-28 00:33:38 +00001683}
1684
Chandler Carruth631abd92011-06-16 06:47:06 +00001685void
1686StmtProfiler::VisitCXXPseudoDestructorExpr(const CXXPseudoDestructorExpr *S) {
Douglas Gregorad8a3362009-09-04 17:36:40 +00001687 VisitExpr(S);
1688 ID.AddBoolean(S->isArrow());
1689 VisitNestedNameSpecifier(S->getQualifier());
Craig Topper36250ad2014-05-12 05:36:57 +00001690 ID.AddBoolean(S->getScopeTypeInfo() != nullptr);
Eli Friedman85641392013-08-09 23:37:05 +00001691 if (S->getScopeTypeInfo())
1692 VisitType(S->getScopeTypeInfo()->getType());
Craig Topper36250ad2014-05-12 05:36:57 +00001693 ID.AddBoolean(S->getDestroyedTypeInfo() != nullptr);
Eli Friedman85641392013-08-09 23:37:05 +00001694 if (S->getDestroyedTypeInfo())
1695 VisitType(S->getDestroyedType());
1696 else
Richard Trieu639d7b62017-02-22 22:22:42 +00001697 VisitIdentifierInfo(S->getDestroyedTypeIdentifier());
Douglas Gregorad8a3362009-09-04 17:36:40 +00001698}
1699
Chandler Carruth631abd92011-06-16 06:47:06 +00001700void StmtProfiler::VisitOverloadExpr(const OverloadExpr *S) {
Argyrios Kyrtzidisb482eb82010-08-15 20:53:20 +00001701 VisitExpr(S);
John McCalle66edc12009-11-24 19:00:30 +00001702 VisitNestedNameSpecifier(S->getQualifier());
Richard Trieuf65efae2018-02-22 05:32:25 +00001703 VisitName(S->getName(), /*TreatAsDecl*/ true);
John McCalle66edc12009-11-24 19:00:30 +00001704 ID.AddBoolean(S->hasExplicitTemplateArgs());
1705 if (S->hasExplicitTemplateArgs())
James Y Knight04ec5bf2015-12-24 02:59:37 +00001706 VisitTemplateArguments(S->getTemplateArgs(), S->getNumTemplateArgs());
Argyrios Kyrtzidisf4505452010-08-15 01:15:38 +00001707}
1708
1709void
Chandler Carruth631abd92011-06-16 06:47:06 +00001710StmtProfiler::VisitUnresolvedLookupExpr(const UnresolvedLookupExpr *S) {
Argyrios Kyrtzidisf4505452010-08-15 01:15:38 +00001711 VisitOverloadExpr(S);
Douglas Gregor5c193b92009-07-28 00:33:38 +00001712}
1713
Douglas Gregor29c42f22012-02-24 07:38:34 +00001714void StmtProfiler::VisitTypeTraitExpr(const TypeTraitExpr *S) {
1715 VisitExpr(S);
1716 ID.AddInteger(S->getTrait());
1717 ID.AddInteger(S->getNumArgs());
1718 for (unsigned I = 0, N = S->getNumArgs(); I != N; ++I)
1719 VisitType(S->getArg(I)->getType());
1720}
1721
Chandler Carruth631abd92011-06-16 06:47:06 +00001722void StmtProfiler::VisitArrayTypeTraitExpr(const ArrayTypeTraitExpr *S) {
John Wiegley6242b6a2011-04-28 00:16:57 +00001723 VisitExpr(S);
1724 ID.AddInteger(S->getTrait());
1725 VisitType(S->getQueriedType());
1726}
1727
Chandler Carruth631abd92011-06-16 06:47:06 +00001728void StmtProfiler::VisitExpressionTraitExpr(const ExpressionTraitExpr *S) {
John Wiegleyf9f65842011-04-25 06:54:41 +00001729 VisitExpr(S);
1730 ID.AddInteger(S->getTrait());
1731 VisitExpr(S->getQueriedExpression());
1732}
1733
Chandler Carruth631abd92011-06-16 06:47:06 +00001734void StmtProfiler::VisitDependentScopeDeclRefExpr(
1735 const DependentScopeDeclRefExpr *S) {
Douglas Gregor5c193b92009-07-28 00:33:38 +00001736 VisitExpr(S);
1737 VisitName(S->getDeclName());
1738 VisitNestedNameSpecifier(S->getQualifier());
John McCalle66edc12009-11-24 19:00:30 +00001739 ID.AddBoolean(S->hasExplicitTemplateArgs());
1740 if (S->hasExplicitTemplateArgs())
1741 VisitTemplateArguments(S->getTemplateArgs(), S->getNumTemplateArgs());
Douglas Gregor5c193b92009-07-28 00:33:38 +00001742}
1743
Chandler Carruth631abd92011-06-16 06:47:06 +00001744void StmtProfiler::VisitExprWithCleanups(const ExprWithCleanups *S) {
Douglas Gregora7095092009-07-28 14:44:31 +00001745 VisitExpr(S);
Douglas Gregora7095092009-07-28 14:44:31 +00001746}
1747
Chandler Carruth631abd92011-06-16 06:47:06 +00001748void StmtProfiler::VisitCXXUnresolvedConstructExpr(
1749 const CXXUnresolvedConstructExpr *S) {
Douglas Gregora7095092009-07-28 14:44:31 +00001750 VisitExpr(S);
1751 VisitType(S->getTypeAsWritten());
Richard Smith39eca9b2017-08-23 22:12:08 +00001752 ID.AddInteger(S->isListInitialization());
Douglas Gregora7095092009-07-28 14:44:31 +00001753}
1754
Chandler Carruth631abd92011-06-16 06:47:06 +00001755void StmtProfiler::VisitCXXDependentScopeMemberExpr(
1756 const CXXDependentScopeMemberExpr *S) {
John McCall2d74de92009-12-01 22:10:20 +00001757 ID.AddBoolean(S->isImplicitAccess());
1758 if (!S->isImplicitAccess()) {
1759 VisitExpr(S);
1760 ID.AddBoolean(S->isArrow());
1761 }
Douglas Gregorc26e0f62009-09-03 16:14:30 +00001762 VisitNestedNameSpecifier(S->getQualifier());
Douglas Gregora7095092009-07-28 14:44:31 +00001763 VisitName(S->getMember());
John McCall2d74de92009-12-01 22:10:20 +00001764 ID.AddBoolean(S->hasExplicitTemplateArgs());
1765 if (S->hasExplicitTemplateArgs())
John McCall10eae182009-11-30 22:42:35 +00001766 VisitTemplateArguments(S->getTemplateArgs(), S->getNumTemplateArgs());
1767}
1768
Chandler Carruth631abd92011-06-16 06:47:06 +00001769void StmtProfiler::VisitUnresolvedMemberExpr(const UnresolvedMemberExpr *S) {
John McCall2d74de92009-12-01 22:10:20 +00001770 ID.AddBoolean(S->isImplicitAccess());
1771 if (!S->isImplicitAccess()) {
1772 VisitExpr(S);
1773 ID.AddBoolean(S->isArrow());
1774 }
John McCall10eae182009-11-30 22:42:35 +00001775 VisitNestedNameSpecifier(S->getQualifier());
1776 VisitName(S->getMemberName());
1777 ID.AddBoolean(S->hasExplicitTemplateArgs());
1778 if (S->hasExplicitTemplateArgs())
1779 VisitTemplateArguments(S->getTemplateArgs(), S->getNumTemplateArgs());
Douglas Gregora7095092009-07-28 14:44:31 +00001780}
1781
Chandler Carruth631abd92011-06-16 06:47:06 +00001782void StmtProfiler::VisitCXXNoexceptExpr(const CXXNoexceptExpr *S) {
Sebastian Redl4202c0f2010-09-10 20:55:43 +00001783 VisitExpr(S);
1784}
1785
Chandler Carruth631abd92011-06-16 06:47:06 +00001786void StmtProfiler::VisitPackExpansionExpr(const PackExpansionExpr *S) {
Douglas Gregore8e9dd62011-01-03 17:17:50 +00001787 VisitExpr(S);
1788}
1789
Chandler Carruth631abd92011-06-16 06:47:06 +00001790void StmtProfiler::VisitSizeOfPackExpr(const SizeOfPackExpr *S) {
Douglas Gregor820ba7b2011-01-04 17:33:58 +00001791 VisitExpr(S);
1792 VisitDecl(S->getPack());
Richard Smithd784e682015-09-23 21:41:42 +00001793 if (S->isPartiallySubstituted()) {
1794 auto Args = S->getPartialArguments();
1795 ID.AddInteger(Args.size());
1796 for (const auto &TA : Args)
1797 VisitTemplateArgument(TA);
1798 } else {
1799 ID.AddInteger(0);
1800 }
Douglas Gregor820ba7b2011-01-04 17:33:58 +00001801}
1802
Douglas Gregorcdbc5392011-01-15 01:15:58 +00001803void StmtProfiler::VisitSubstNonTypeTemplateParmPackExpr(
Chandler Carruth631abd92011-06-16 06:47:06 +00001804 const SubstNonTypeTemplateParmPackExpr *S) {
Douglas Gregorcdbc5392011-01-15 01:15:58 +00001805 VisitExpr(S);
1806 VisitDecl(S->getParameterPack());
1807 VisitTemplateArgument(S->getArgumentPack());
1808}
1809
John McCall7c454bb2011-07-15 05:09:51 +00001810void StmtProfiler::VisitSubstNonTypeTemplateParmExpr(
1811 const SubstNonTypeTemplateParmExpr *E) {
1812 // Profile exactly as the replacement expression.
1813 Visit(E->getReplacement());
1814}
1815
Richard Smithb15fe3a2012-09-12 00:56:43 +00001816void StmtProfiler::VisitFunctionParmPackExpr(const FunctionParmPackExpr *S) {
1817 VisitExpr(S);
1818 VisitDecl(S->getParameterPack());
1819 ID.AddInteger(S->getNumExpansions());
1820 for (FunctionParmPackExpr::iterator I = S->begin(), E = S->end(); I != E; ++I)
1821 VisitDecl(*I);
1822}
1823
Douglas Gregorfe314812011-06-21 17:03:29 +00001824void StmtProfiler::VisitMaterializeTemporaryExpr(
1825 const MaterializeTemporaryExpr *S) {
1826 VisitExpr(S);
1827}
1828
Richard Smith0f0af192014-11-08 05:07:16 +00001829void StmtProfiler::VisitCXXFoldExpr(const CXXFoldExpr *S) {
1830 VisitExpr(S);
1831 ID.AddInteger(S->getOperator());
1832}
1833
Richard Smith9f690bd2015-10-27 06:02:45 +00001834void StmtProfiler::VisitCoroutineBodyStmt(const CoroutineBodyStmt *S) {
1835 VisitStmt(S);
1836}
1837
1838void StmtProfiler::VisitCoreturnStmt(const CoreturnStmt *S) {
1839 VisitStmt(S);
1840}
1841
1842void StmtProfiler::VisitCoawaitExpr(const CoawaitExpr *S) {
1843 VisitExpr(S);
1844}
1845
Eric Fiselier20f25cb2017-03-06 23:38:15 +00001846void StmtProfiler::VisitDependentCoawaitExpr(const DependentCoawaitExpr *S) {
1847 VisitExpr(S);
1848}
1849
Richard Smith9f690bd2015-10-27 06:02:45 +00001850void StmtProfiler::VisitCoyieldExpr(const CoyieldExpr *S) {
1851 VisitExpr(S);
1852}
1853
Chandler Carruth631abd92011-06-16 06:47:06 +00001854void StmtProfiler::VisitOpaqueValueExpr(const OpaqueValueExpr *E) {
Fangrui Song6907ce22018-07-30 19:24:48 +00001855 VisitExpr(E);
John McCall8d69a212010-11-15 23:31:06 +00001856}
1857
Kaelyn Takatae1f49d52014-10-27 18:07:20 +00001858void StmtProfiler::VisitTypoExpr(const TypoExpr *E) {
1859 VisitExpr(E);
1860}
1861
Chandler Carruth631abd92011-06-16 06:47:06 +00001862void StmtProfiler::VisitObjCStringLiteral(const ObjCStringLiteral *S) {
Douglas Gregora7095092009-07-28 14:44:31 +00001863 VisitExpr(S);
1864}
1865
Patrick Beard0caa3942012-04-19 00:25:12 +00001866void StmtProfiler::VisitObjCBoxedExpr(const ObjCBoxedExpr *E) {
Ted Kremeneke65b0862012-03-06 20:05:56 +00001867 VisitExpr(E);
1868}
1869
1870void StmtProfiler::VisitObjCArrayLiteral(const ObjCArrayLiteral *E) {
1871 VisitExpr(E);
1872}
1873
1874void StmtProfiler::VisitObjCDictionaryLiteral(const ObjCDictionaryLiteral *E) {
1875 VisitExpr(E);
1876}
1877
Chandler Carruth631abd92011-06-16 06:47:06 +00001878void StmtProfiler::VisitObjCEncodeExpr(const ObjCEncodeExpr *S) {
Douglas Gregora7095092009-07-28 14:44:31 +00001879 VisitExpr(S);
1880 VisitType(S->getEncodedType());
1881}
1882
Chandler Carruth631abd92011-06-16 06:47:06 +00001883void StmtProfiler::VisitObjCSelectorExpr(const ObjCSelectorExpr *S) {
Douglas Gregora7095092009-07-28 14:44:31 +00001884 VisitExpr(S);
1885 VisitName(S->getSelector());
1886}
1887
Chandler Carruth631abd92011-06-16 06:47:06 +00001888void StmtProfiler::VisitObjCProtocolExpr(const ObjCProtocolExpr *S) {
Douglas Gregora7095092009-07-28 14:44:31 +00001889 VisitExpr(S);
1890 VisitDecl(S->getProtocol());
1891}
1892
Chandler Carruth631abd92011-06-16 06:47:06 +00001893void StmtProfiler::VisitObjCIvarRefExpr(const ObjCIvarRefExpr *S) {
Douglas Gregora7095092009-07-28 14:44:31 +00001894 VisitExpr(S);
1895 VisitDecl(S->getDecl());
1896 ID.AddBoolean(S->isArrow());
1897 ID.AddBoolean(S->isFreeIvar());
1898}
1899
Chandler Carruth631abd92011-06-16 06:47:06 +00001900void StmtProfiler::VisitObjCPropertyRefExpr(const ObjCPropertyRefExpr *S) {
Douglas Gregora7095092009-07-28 14:44:31 +00001901 VisitExpr(S);
John McCallb7bd14f2010-12-02 01:19:52 +00001902 if (S->isImplicitProperty()) {
1903 VisitDecl(S->getImplicitPropertyGetter());
1904 VisitDecl(S->getImplicitPropertySetter());
1905 } else {
1906 VisitDecl(S->getExplicitProperty());
Fariborz Jahanian681c0752010-10-14 16:04:05 +00001907 }
Fariborz Jahanian681c0752010-10-14 16:04:05 +00001908 if (S->isSuperReceiver()) {
1909 ID.AddBoolean(S->isSuperReceiver());
John McCallb7bd14f2010-12-02 01:19:52 +00001910 VisitType(S->getSuperReceiverType());
Fariborz Jahanian681c0752010-10-14 16:04:05 +00001911 }
Douglas Gregora7095092009-07-28 14:44:31 +00001912}
1913
Ted Kremeneke65b0862012-03-06 20:05:56 +00001914void StmtProfiler::VisitObjCSubscriptRefExpr(const ObjCSubscriptRefExpr *S) {
1915 VisitExpr(S);
1916 VisitDecl(S->getAtIndexMethodDecl());
1917 VisitDecl(S->setAtIndexMethodDecl());
1918}
1919
Chandler Carruth631abd92011-06-16 06:47:06 +00001920void StmtProfiler::VisitObjCMessageExpr(const ObjCMessageExpr *S) {
Douglas Gregora7095092009-07-28 14:44:31 +00001921 VisitExpr(S);
1922 VisitName(S->getSelector());
1923 VisitDecl(S->getMethodDecl());
1924}
1925
Chandler Carruth631abd92011-06-16 06:47:06 +00001926void StmtProfiler::VisitObjCIsaExpr(const ObjCIsaExpr *S) {
Douglas Gregora7095092009-07-28 14:44:31 +00001927 VisitExpr(S);
1928 ID.AddBoolean(S->isArrow());
1929}
1930
Ted Kremeneke65b0862012-03-06 20:05:56 +00001931void StmtProfiler::VisitObjCBoolLiteralExpr(const ObjCBoolLiteralExpr *S) {
1932 VisitExpr(S);
1933 ID.AddBoolean(S->getValue());
1934}
1935
Chandler Carruth631abd92011-06-16 06:47:06 +00001936void StmtProfiler::VisitObjCIndirectCopyRestoreExpr(
1937 const ObjCIndirectCopyRestoreExpr *S) {
John McCall31168b02011-06-15 23:02:42 +00001938 VisitExpr(S);
1939 ID.AddBoolean(S->shouldCopy());
1940}
1941
Chandler Carruth631abd92011-06-16 06:47:06 +00001942void StmtProfiler::VisitObjCBridgedCastExpr(const ObjCBridgedCastExpr *S) {
John McCall31168b02011-06-15 23:02:42 +00001943 VisitExplicitCastExpr(S);
1944 ID.AddBoolean(S->getBridgeKind());
1945}
1946
Erik Pilkington29099de2016-07-16 00:35:23 +00001947void StmtProfiler::VisitObjCAvailabilityCheckExpr(
1948 const ObjCAvailabilityCheckExpr *S) {
1949 VisitExpr(S);
1950}
1951
John McCall0ad16662009-10-29 08:12:44 +00001952void StmtProfiler::VisitTemplateArguments(const TemplateArgumentLoc *Args,
Douglas Gregor5c193b92009-07-28 00:33:38 +00001953 unsigned NumArgs) {
1954 ID.AddInteger(NumArgs);
John McCall0ad16662009-10-29 08:12:44 +00001955 for (unsigned I = 0; I != NumArgs; ++I)
1956 VisitTemplateArgument(Args[I].getArgument());
1957}
Mike Stump11289f42009-09-09 15:08:12 +00001958
John McCall0ad16662009-10-29 08:12:44 +00001959void StmtProfiler::VisitTemplateArgument(const TemplateArgument &Arg) {
1960 // Mostly repetitive with TemplateArgument::Profile!
1961 ID.AddInteger(Arg.getKind());
1962 switch (Arg.getKind()) {
1963 case TemplateArgument::Null:
1964 break;
Mike Stump11289f42009-09-09 15:08:12 +00001965
John McCall0ad16662009-10-29 08:12:44 +00001966 case TemplateArgument::Type:
1967 VisitType(Arg.getAsType());
1968 break;
Mike Stump11289f42009-09-09 15:08:12 +00001969
Douglas Gregor9167f8b2009-11-11 01:00:40 +00001970 case TemplateArgument::Template:
Douglas Gregore4ff4b52011-01-05 18:58:31 +00001971 case TemplateArgument::TemplateExpansion:
1972 VisitTemplateName(Arg.getAsTemplateOrTemplatePattern());
Douglas Gregor9167f8b2009-11-11 01:00:40 +00001973 break;
Fangrui Song6907ce22018-07-30 19:24:48 +00001974
John McCall0ad16662009-10-29 08:12:44 +00001975 case TemplateArgument::Declaration:
1976 VisitDecl(Arg.getAsDecl());
1977 break;
Mike Stump11289f42009-09-09 15:08:12 +00001978
Eli Friedmanb826a002012-09-26 02:36:12 +00001979 case TemplateArgument::NullPtr:
1980 VisitType(Arg.getNullPtrType());
1981 break;
1982
John McCall0ad16662009-10-29 08:12:44 +00001983 case TemplateArgument::Integral:
Benjamin Kramer6003ad52012-06-07 15:09:51 +00001984 Arg.getAsIntegral().Profile(ID);
John McCall0ad16662009-10-29 08:12:44 +00001985 VisitType(Arg.getIntegralType());
1986 break;
Mike Stump11289f42009-09-09 15:08:12 +00001987
John McCall0ad16662009-10-29 08:12:44 +00001988 case TemplateArgument::Expression:
1989 Visit(Arg.getAsExpr());
1990 break;
Mike Stump11289f42009-09-09 15:08:12 +00001991
John McCall0ad16662009-10-29 08:12:44 +00001992 case TemplateArgument::Pack:
Aaron Ballman2a89e852014-07-15 21:32:31 +00001993 for (const auto &P : Arg.pack_elements())
1994 VisitTemplateArgument(P);
John McCall0ad16662009-10-29 08:12:44 +00001995 break;
Douglas Gregor5c193b92009-07-28 00:33:38 +00001996 }
1997}
1998
Jay Foad39c79802011-01-12 09:06:06 +00001999void Stmt::Profile(llvm::FoldingSetNodeID &ID, const ASTContext &Context,
Chandler Carruth631abd92011-06-16 06:47:06 +00002000 bool Canonical) const {
Richard Trieu639d7b62017-02-22 22:22:42 +00002001 StmtProfilerWithPointers Profiler(ID, Context, Canonical);
2002 Profiler.Visit(this);
2003}
2004
2005void Stmt::ProcessODRHash(llvm::FoldingSetNodeID &ID,
2006 class ODRHash &Hash) const {
2007 StmtProfilerWithoutPointers Profiler(ID, Hash);
Douglas Gregor5c193b92009-07-28 00:33:38 +00002008 Profiler.Visit(this);
2009}