blob: f92c3dc60ba5cdceb8f9b5280159638c129a9a62 [file] [log] [blame]
Douglas Gregor5c193b92009-07-28 00:33:38 +00001//===---- StmtProfile.cpp - Profile implementation for Stmt ASTs ----------===//
2//
Chandler Carruth2946cd72019-01-19 08:50:56 +00003// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
Douglas Gregor5c193b92009-07-28 00:33:38 +00006//
7//===----------------------------------------------------------------------===//
8//
9// This file implements the Stmt::Profile method, which builds a unique bit
Douglas Gregor32615a12009-07-28 16:39:25 +000010// representation that identifies a statement/expression.
Douglas Gregor5c193b92009-07-28 00:33:38 +000011//
12//===----------------------------------------------------------------------===//
13#include "clang/AST/ASTContext.h"
Douglas Gregora7095092009-07-28 14:44:31 +000014#include "clang/AST/DeclCXX.h"
15#include "clang/AST/DeclObjC.h"
Douglas Gregor5c193b92009-07-28 00:33:38 +000016#include "clang/AST/DeclTemplate.h"
17#include "clang/AST/Expr.h"
18#include "clang/AST/ExprCXX.h"
19#include "clang/AST/ExprObjC.h"
Alexey Bataev1a3320e2015-08-25 14:24:04 +000020#include "clang/AST/ExprOpenMP.h"
Richard Trieu639d7b62017-02-22 22:22:42 +000021#include "clang/AST/ODRHash.h"
Douglas Gregor5c193b92009-07-28 00:33:38 +000022#include "clang/AST/StmtVisitor.h"
23#include "llvm/ADT/FoldingSet.h"
Douglas Gregor5c193b92009-07-28 00:33:38 +000024using namespace clang;
25
26namespace {
Chandler Carruth631abd92011-06-16 06:47:06 +000027 class StmtProfiler : public ConstStmtVisitor<StmtProfiler> {
Richard Trieu639d7b62017-02-22 22:22:42 +000028 protected:
Douglas Gregor5c193b92009-07-28 00:33:38 +000029 llvm::FoldingSetNodeID &ID;
Douglas Gregor5c193b92009-07-28 00:33:38 +000030 bool Canonical;
Mike Stump11289f42009-09-09 15:08:12 +000031
Douglas Gregor5c193b92009-07-28 00:33:38 +000032 public:
Richard Trieu639d7b62017-02-22 22:22:42 +000033 StmtProfiler(llvm::FoldingSetNodeID &ID, bool Canonical)
34 : ID(ID), Canonical(Canonical) {}
35
36 virtual ~StmtProfiler() {}
Mike Stump11289f42009-09-09 15:08:12 +000037
Chandler Carruth631abd92011-06-16 06:47:06 +000038 void VisitStmt(const Stmt *S);
Mike Stump11289f42009-09-09 15:08:12 +000039
Richard Trieuf65efae2018-02-22 05:32:25 +000040 virtual void HandleStmtClass(Stmt::StmtClass SC) = 0;
41
Chandler Carruth631abd92011-06-16 06:47:06 +000042#define STMT(Node, Base) void Visit##Node(const Node *S);
Alexis Hunt656bb312010-05-05 15:24:00 +000043#include "clang/AST/StmtNodes.inc"
Mike Stump11289f42009-09-09 15:08:12 +000044
Adrian Prantl9fc8faf2018-05-09 01:00:01 +000045 /// Visit a declaration that is referenced within an expression
Douglas Gregor5c193b92009-07-28 00:33:38 +000046 /// or statement.
Richard Trieu639d7b62017-02-22 22:22:42 +000047 virtual void VisitDecl(const Decl *D) = 0;
Mike Stump11289f42009-09-09 15:08:12 +000048
Adrian Prantl9fc8faf2018-05-09 01:00:01 +000049 /// Visit a type that is referenced within an expression or
Douglas Gregor5c193b92009-07-28 00:33:38 +000050 /// statement.
Richard Trieu639d7b62017-02-22 22:22:42 +000051 virtual void VisitType(QualType T) = 0;
Mike Stump11289f42009-09-09 15:08:12 +000052
Adrian Prantl9fc8faf2018-05-09 01:00:01 +000053 /// Visit a name that occurs within an expression or statement.
Richard Trieuf65efae2018-02-22 05:32:25 +000054 virtual void VisitName(DeclarationName Name, bool TreatAsDecl = false) = 0;
Richard Trieu639d7b62017-02-22 22:22:42 +000055
Adrian Prantl9fc8faf2018-05-09 01:00:01 +000056 /// Visit identifiers that are not in Decl's or Type's.
Richard Trieu639d7b62017-02-22 22:22:42 +000057 virtual void VisitIdentifierInfo(IdentifierInfo *II) = 0;
Mike Stump11289f42009-09-09 15:08:12 +000058
Adrian Prantl9fc8faf2018-05-09 01:00:01 +000059 /// Visit a nested-name-specifier that occurs within an expression
Douglas Gregor5c193b92009-07-28 00:33:38 +000060 /// or statement.
Richard Trieu639d7b62017-02-22 22:22:42 +000061 virtual void VisitNestedNameSpecifier(NestedNameSpecifier *NNS) = 0;
Mike Stump11289f42009-09-09 15:08:12 +000062
Adrian Prantl9fc8faf2018-05-09 01:00:01 +000063 /// Visit a template name that occurs within an expression or
Douglas Gregor5c193b92009-07-28 00:33:38 +000064 /// statement.
Richard Trieu639d7b62017-02-22 22:22:42 +000065 virtual void VisitTemplateName(TemplateName Name) = 0;
Mike Stump11289f42009-09-09 15:08:12 +000066
Adrian Prantl9fc8faf2018-05-09 01:00:01 +000067 /// Visit template arguments that occur within an expression or
Douglas Gregor5c193b92009-07-28 00:33:38 +000068 /// statement.
Chandler Carruth631abd92011-06-16 06:47:06 +000069 void VisitTemplateArguments(const TemplateArgumentLoc *Args,
70 unsigned NumArgs);
John McCall0ad16662009-10-29 08:12:44 +000071
Adrian Prantl9fc8faf2018-05-09 01:00:01 +000072 /// Visit a single template argument.
John McCall0ad16662009-10-29 08:12:44 +000073 void VisitTemplateArgument(const TemplateArgument &Arg);
Douglas Gregor5c193b92009-07-28 00:33:38 +000074 };
Richard Trieu639d7b62017-02-22 22:22:42 +000075
76 class StmtProfilerWithPointers : public StmtProfiler {
77 const ASTContext &Context;
78
79 public:
80 StmtProfilerWithPointers(llvm::FoldingSetNodeID &ID,
81 const ASTContext &Context, bool Canonical)
82 : StmtProfiler(ID, Canonical), Context(Context) {}
83 private:
Richard Trieuf65efae2018-02-22 05:32:25 +000084 void HandleStmtClass(Stmt::StmtClass SC) override {
85 ID.AddInteger(SC);
86 }
87
Richard Trieu639d7b62017-02-22 22:22:42 +000088 void VisitDecl(const Decl *D) override {
89 ID.AddInteger(D ? D->getKind() : 0);
90
91 if (Canonical && D) {
92 if (const NonTypeTemplateParmDecl *NTTP =
93 dyn_cast<NonTypeTemplateParmDecl>(D)) {
94 ID.AddInteger(NTTP->getDepth());
95 ID.AddInteger(NTTP->getIndex());
96 ID.AddBoolean(NTTP->isParameterPack());
97 VisitType(NTTP->getType());
98 return;
99 }
100
101 if (const ParmVarDecl *Parm = dyn_cast<ParmVarDecl>(D)) {
102 // The Itanium C++ ABI uses the type, scope depth, and scope
103 // index of a parameter when mangling expressions that involve
104 // function parameters, so we will use the parameter's type for
105 // establishing function parameter identity. That way, our
106 // definition of "equivalent" (per C++ [temp.over.link]) is at
107 // least as strong as the definition of "equivalent" used for
108 // name mangling.
109 VisitType(Parm->getType());
110 ID.AddInteger(Parm->getFunctionScopeDepth());
111 ID.AddInteger(Parm->getFunctionScopeIndex());
112 return;
113 }
114
115 if (const TemplateTypeParmDecl *TTP =
116 dyn_cast<TemplateTypeParmDecl>(D)) {
117 ID.AddInteger(TTP->getDepth());
118 ID.AddInteger(TTP->getIndex());
119 ID.AddBoolean(TTP->isParameterPack());
120 return;
121 }
122
123 if (const TemplateTemplateParmDecl *TTP =
124 dyn_cast<TemplateTemplateParmDecl>(D)) {
125 ID.AddInteger(TTP->getDepth());
126 ID.AddInteger(TTP->getIndex());
127 ID.AddBoolean(TTP->isParameterPack());
128 return;
129 }
130 }
131
132 ID.AddPointer(D ? D->getCanonicalDecl() : nullptr);
133 }
134
135 void VisitType(QualType T) override {
Richard Trieua5f4ade2017-03-04 02:42:41 +0000136 if (Canonical && !T.isNull())
Richard Trieu639d7b62017-02-22 22:22:42 +0000137 T = Context.getCanonicalType(T);
138
139 ID.AddPointer(T.getAsOpaquePtr());
140 }
141
Richard Trieuf65efae2018-02-22 05:32:25 +0000142 void VisitName(DeclarationName Name, bool /*TreatAsDecl*/) override {
Richard Trieu639d7b62017-02-22 22:22:42 +0000143 ID.AddPointer(Name.getAsOpaquePtr());
144 }
145
146 void VisitIdentifierInfo(IdentifierInfo *II) override {
147 ID.AddPointer(II);
148 }
149
150 void VisitNestedNameSpecifier(NestedNameSpecifier *NNS) override {
151 if (Canonical)
152 NNS = Context.getCanonicalNestedNameSpecifier(NNS);
153 ID.AddPointer(NNS);
154 }
155
156 void VisitTemplateName(TemplateName Name) override {
157 if (Canonical)
158 Name = Context.getCanonicalTemplateName(Name);
159
160 Name.Profile(ID);
161 }
162 };
163
164 class StmtProfilerWithoutPointers : public StmtProfiler {
165 ODRHash &Hash;
166 public:
167 StmtProfilerWithoutPointers(llvm::FoldingSetNodeID &ID, ODRHash &Hash)
168 : StmtProfiler(ID, false), Hash(Hash) {}
169
170 private:
Richard Trieuf65efae2018-02-22 05:32:25 +0000171 void HandleStmtClass(Stmt::StmtClass SC) override {
172 if (SC == Stmt::UnresolvedLookupExprClass) {
173 // Pretend that the name looked up is a Decl due to how templates
174 // handle some Decl lookups.
175 ID.AddInteger(Stmt::DeclRefExprClass);
176 } else {
177 ID.AddInteger(SC);
178 }
179 }
180
Richard Trieu639d7b62017-02-22 22:22:42 +0000181 void VisitType(QualType T) override {
182 Hash.AddQualType(T);
183 }
184
Richard Trieuf65efae2018-02-22 05:32:25 +0000185 void VisitName(DeclarationName Name, bool TreatAsDecl) override {
186 if (TreatAsDecl) {
187 // A Decl can be null, so each Decl is preceded by a boolean to
188 // store its nullness. Add a boolean here to match.
189 ID.AddBoolean(true);
190 }
Richard Trieu22ddc282018-09-04 22:53:19 +0000191 Hash.AddDeclarationName(Name, TreatAsDecl);
Richard Trieu639d7b62017-02-22 22:22:42 +0000192 }
193 void VisitIdentifierInfo(IdentifierInfo *II) override {
194 ID.AddBoolean(II);
195 if (II) {
196 Hash.AddIdentifierInfo(II);
197 }
198 }
199 void VisitDecl(const Decl *D) override {
200 ID.AddBoolean(D);
201 if (D) {
202 Hash.AddDecl(D);
203 }
204 }
205 void VisitTemplateName(TemplateName Name) override {
206 Hash.AddTemplateName(Name);
207 }
208 void VisitNestedNameSpecifier(NestedNameSpecifier *NNS) override {
Richard Trieu96b41642017-07-01 02:00:05 +0000209 ID.AddBoolean(NNS);
210 if (NNS) {
211 Hash.AddNestedNameSpecifier(NNS);
212 }
Richard Trieu639d7b62017-02-22 22:22:42 +0000213 }
214 };
Alexander Kornienkoab9db512015-06-22 23:07:51 +0000215}
Douglas Gregor5c193b92009-07-28 00:33:38 +0000216
Chandler Carruth631abd92011-06-16 06:47:06 +0000217void StmtProfiler::VisitStmt(const Stmt *S) {
Richard Trieu6a77a1c2016-06-10 04:52:09 +0000218 assert(S && "Requires non-null Stmt pointer");
Richard Trieuf65efae2018-02-22 05:32:25 +0000219
220 HandleStmtClass(S->getStmtClass());
221
Benjamin Kramer642f1732015-07-02 21:03:14 +0000222 for (const Stmt *SubStmt : S->children()) {
223 if (SubStmt)
224 Visit(SubStmt);
Peter Collingbournecdb9f302012-03-01 16:34:31 +0000225 else
226 ID.AddInteger(0);
227 }
Douglas Gregor5c193b92009-07-28 00:33:38 +0000228}
229
Chandler Carruth631abd92011-06-16 06:47:06 +0000230void StmtProfiler::VisitDeclStmt(const DeclStmt *S) {
Douglas Gregor44882592009-07-28 15:27:13 +0000231 VisitStmt(S);
Aaron Ballman535bbcc2014-03-14 17:01:24 +0000232 for (const auto *D : S->decls())
233 VisitDecl(D);
Douglas Gregor44882592009-07-28 15:27:13 +0000234}
235
Chandler Carruth631abd92011-06-16 06:47:06 +0000236void StmtProfiler::VisitNullStmt(const NullStmt *S) {
Douglas Gregor44882592009-07-28 15:27:13 +0000237 VisitStmt(S);
238}
239
Chandler Carruth631abd92011-06-16 06:47:06 +0000240void StmtProfiler::VisitCompoundStmt(const CompoundStmt *S) {
Douglas Gregor44882592009-07-28 15:27:13 +0000241 VisitStmt(S);
242}
243
Chandler Carruth631abd92011-06-16 06:47:06 +0000244void StmtProfiler::VisitCaseStmt(const CaseStmt *S) {
Douglas Gregor44882592009-07-28 15:27:13 +0000245 VisitStmt(S);
246}
247
Chandler Carruth631abd92011-06-16 06:47:06 +0000248void StmtProfiler::VisitDefaultStmt(const DefaultStmt *S) {
Douglas Gregor44882592009-07-28 15:27:13 +0000249 VisitStmt(S);
250}
251
Chandler Carruth631abd92011-06-16 06:47:06 +0000252void StmtProfiler::VisitLabelStmt(const LabelStmt *S) {
Douglas Gregor44882592009-07-28 15:27:13 +0000253 VisitStmt(S);
Chris Lattnerc8e630e2011-02-17 07:39:24 +0000254 VisitDecl(S->getDecl());
Douglas Gregor44882592009-07-28 15:27:13 +0000255}
256
Richard Smithc202b282012-04-14 00:33:13 +0000257void StmtProfiler::VisitAttributedStmt(const AttributedStmt *S) {
258 VisitStmt(S);
259 // TODO: maybe visit attributes?
260}
261
Chandler Carruth631abd92011-06-16 06:47:06 +0000262void StmtProfiler::VisitIfStmt(const IfStmt *S) {
Douglas Gregor44882592009-07-28 15:27:13 +0000263 VisitStmt(S);
Douglas Gregor7bab5ff2009-11-25 00:27:52 +0000264 VisitDecl(S->getConditionVariable());
Douglas Gregor44882592009-07-28 15:27:13 +0000265}
266
Chandler Carruth631abd92011-06-16 06:47:06 +0000267void StmtProfiler::VisitSwitchStmt(const SwitchStmt *S) {
Douglas Gregor00044172009-07-29 16:09:57 +0000268 VisitStmt(S);
Douglas Gregor7bab5ff2009-11-25 00:27:52 +0000269 VisitDecl(S->getConditionVariable());
Douglas Gregor00044172009-07-29 16:09:57 +0000270}
271
Chandler Carruth631abd92011-06-16 06:47:06 +0000272void StmtProfiler::VisitWhileStmt(const WhileStmt *S) {
Douglas Gregor44882592009-07-28 15:27:13 +0000273 VisitStmt(S);
Douglas Gregor7bab5ff2009-11-25 00:27:52 +0000274 VisitDecl(S->getConditionVariable());
Douglas Gregor44882592009-07-28 15:27:13 +0000275}
276
Chandler Carruth631abd92011-06-16 06:47:06 +0000277void StmtProfiler::VisitDoStmt(const DoStmt *S) {
Douglas Gregor44882592009-07-28 15:27:13 +0000278 VisitStmt(S);
279}
280
Chandler Carruth631abd92011-06-16 06:47:06 +0000281void StmtProfiler::VisitForStmt(const ForStmt *S) {
Douglas Gregor44882592009-07-28 15:27:13 +0000282 VisitStmt(S);
283}
284
Chandler Carruth631abd92011-06-16 06:47:06 +0000285void StmtProfiler::VisitGotoStmt(const GotoStmt *S) {
Douglas Gregor44882592009-07-28 15:27:13 +0000286 VisitStmt(S);
Chris Lattnerc8e630e2011-02-17 07:39:24 +0000287 VisitDecl(S->getLabel());
Douglas Gregor44882592009-07-28 15:27:13 +0000288}
289
Chandler Carruth631abd92011-06-16 06:47:06 +0000290void StmtProfiler::VisitIndirectGotoStmt(const IndirectGotoStmt *S) {
Douglas Gregor44882592009-07-28 15:27:13 +0000291 VisitStmt(S);
292}
293
Chandler Carruth631abd92011-06-16 06:47:06 +0000294void StmtProfiler::VisitContinueStmt(const ContinueStmt *S) {
Douglas Gregor44882592009-07-28 15:27:13 +0000295 VisitStmt(S);
296}
297
Chandler Carruth631abd92011-06-16 06:47:06 +0000298void StmtProfiler::VisitBreakStmt(const BreakStmt *S) {
Douglas Gregor44882592009-07-28 15:27:13 +0000299 VisitStmt(S);
300}
301
Chandler Carruth631abd92011-06-16 06:47:06 +0000302void StmtProfiler::VisitReturnStmt(const ReturnStmt *S) {
Douglas Gregor44882592009-07-28 15:27:13 +0000303 VisitStmt(S);
304}
305
Chad Rosierde70e0e2012-08-25 00:11:56 +0000306void StmtProfiler::VisitGCCAsmStmt(const GCCAsmStmt *S) {
Douglas Gregor44882592009-07-28 15:27:13 +0000307 VisitStmt(S);
308 ID.AddBoolean(S->isVolatile());
309 ID.AddBoolean(S->isSimple());
310 VisitStringLiteral(S->getAsmString());
311 ID.AddInteger(S->getNumOutputs());
312 for (unsigned I = 0, N = S->getNumOutputs(); I != N; ++I) {
313 ID.AddString(S->getOutputName(I));
314 VisitStringLiteral(S->getOutputConstraintLiteral(I));
315 }
316 ID.AddInteger(S->getNumInputs());
317 for (unsigned I = 0, N = S->getNumInputs(); I != N; ++I) {
318 ID.AddString(S->getInputName(I));
319 VisitStringLiteral(S->getInputConstraintLiteral(I));
320 }
321 ID.AddInteger(S->getNumClobbers());
322 for (unsigned I = 0, N = S->getNumClobbers(); I != N; ++I)
Chad Rosierd9fb09a2012-08-27 23:28:41 +0000323 VisitStringLiteral(S->getClobberStringLiteral(I));
Jennifer Yub8fee672019-06-03 15:57:25 +0000324 ID.AddInteger(S->getNumLabels());
325 for (auto *L : S->labels())
326 VisitDecl(L->getLabel());
Douglas Gregor44882592009-07-28 15:27:13 +0000327}
328
Chad Rosier32503022012-06-11 20:47:18 +0000329void StmtProfiler::VisitMSAsmStmt(const MSAsmStmt *S) {
330 // FIXME: Implement MS style inline asm statement profiler.
331 VisitStmt(S);
332}
333
Chandler Carruth631abd92011-06-16 06:47:06 +0000334void StmtProfiler::VisitCXXCatchStmt(const CXXCatchStmt *S) {
Douglas Gregor44882592009-07-28 15:27:13 +0000335 VisitStmt(S);
336 VisitType(S->getCaughtType());
337}
338
Chandler Carruth631abd92011-06-16 06:47:06 +0000339void StmtProfiler::VisitCXXTryStmt(const CXXTryStmt *S) {
Douglas Gregor44882592009-07-28 15:27:13 +0000340 VisitStmt(S);
341}
342
Chandler Carruth631abd92011-06-16 06:47:06 +0000343void StmtProfiler::VisitCXXForRangeStmt(const CXXForRangeStmt *S) {
Richard Smith02e85f32011-04-14 22:09:26 +0000344 VisitStmt(S);
345}
346
Douglas Gregordeb4a2be2011-10-25 01:33:02 +0000347void StmtProfiler::VisitMSDependentExistsStmt(const MSDependentExistsStmt *S) {
348 VisitStmt(S);
349 ID.AddBoolean(S->isIfExists());
350 VisitNestedNameSpecifier(S->getQualifierLoc().getNestedNameSpecifier());
351 VisitName(S->getNameInfo().getName());
352}
353
Chandler Carruth631abd92011-06-16 06:47:06 +0000354void StmtProfiler::VisitSEHTryStmt(const SEHTryStmt *S) {
John Wiegley1c0675e2011-04-28 01:08:34 +0000355 VisitStmt(S);
356}
357
Chandler Carruth631abd92011-06-16 06:47:06 +0000358void StmtProfiler::VisitSEHFinallyStmt(const SEHFinallyStmt *S) {
John Wiegley1c0675e2011-04-28 01:08:34 +0000359 VisitStmt(S);
360}
361
Chandler Carruth631abd92011-06-16 06:47:06 +0000362void StmtProfiler::VisitSEHExceptStmt(const SEHExceptStmt *S) {
John Wiegley1c0675e2011-04-28 01:08:34 +0000363 VisitStmt(S);
364}
365
Nico Weber9b982072014-07-07 00:12:30 +0000366void StmtProfiler::VisitSEHLeaveStmt(const SEHLeaveStmt *S) {
367 VisitStmt(S);
368}
369
Tareq A. Siraj24110cc2013-04-16 18:53:08 +0000370void StmtProfiler::VisitCapturedStmt(const CapturedStmt *S) {
371 VisitStmt(S);
372}
373
Chandler Carruth631abd92011-06-16 06:47:06 +0000374void StmtProfiler::VisitObjCForCollectionStmt(const ObjCForCollectionStmt *S) {
Douglas Gregor44882592009-07-28 15:27:13 +0000375 VisitStmt(S);
376}
377
Chandler Carruth631abd92011-06-16 06:47:06 +0000378void StmtProfiler::VisitObjCAtCatchStmt(const ObjCAtCatchStmt *S) {
Douglas Gregor44882592009-07-28 15:27:13 +0000379 VisitStmt(S);
380 ID.AddBoolean(S->hasEllipsis());
381 if (S->getCatchParamDecl())
382 VisitType(S->getCatchParamDecl()->getType());
383}
384
Chandler Carruth631abd92011-06-16 06:47:06 +0000385void StmtProfiler::VisitObjCAtFinallyStmt(const ObjCAtFinallyStmt *S) {
Douglas Gregor44882592009-07-28 15:27:13 +0000386 VisitStmt(S);
387}
388
Chandler Carruth631abd92011-06-16 06:47:06 +0000389void StmtProfiler::VisitObjCAtTryStmt(const ObjCAtTryStmt *S) {
Douglas Gregor44882592009-07-28 15:27:13 +0000390 VisitStmt(S);
391}
392
Chandler Carruth631abd92011-06-16 06:47:06 +0000393void
394StmtProfiler::VisitObjCAtSynchronizedStmt(const ObjCAtSynchronizedStmt *S) {
Douglas Gregor44882592009-07-28 15:27:13 +0000395 VisitStmt(S);
396}
397
Chandler Carruth631abd92011-06-16 06:47:06 +0000398void StmtProfiler::VisitObjCAtThrowStmt(const ObjCAtThrowStmt *S) {
Douglas Gregor44882592009-07-28 15:27:13 +0000399 VisitStmt(S);
400}
401
Chandler Carruth631abd92011-06-16 06:47:06 +0000402void
403StmtProfiler::VisitObjCAutoreleasePoolStmt(const ObjCAutoreleasePoolStmt *S) {
John McCall31168b02011-06-15 23:02:42 +0000404 VisitStmt(S);
405}
406
Alexey Bataev5ec3eb12013-07-19 03:13:43 +0000407namespace {
408class OMPClauseProfiler : public ConstOMPClauseVisitor<OMPClauseProfiler> {
409 StmtProfiler *Profiler;
Adrian Prantl9fc8faf2018-05-09 01:00:01 +0000410 /// Process clauses with list of variables.
Alexey Bataev756c1962013-09-24 03:17:45 +0000411 template <typename T>
412 void VisitOMPClauseList(T *Node);
NAKAMURA Takumiaa13f942015-12-09 07:52:46 +0000413
Alexey Bataev5ec3eb12013-07-19 03:13:43 +0000414public:
415 OMPClauseProfiler(StmtProfiler *P) : Profiler(P) { }
416#define OPENMP_CLAUSE(Name, Class) \
417 void Visit##Class(const Class *C);
418#include "clang/Basic/OpenMPKinds.def"
Alexey Bataev3392d762016-02-16 11:18:12 +0000419 void VistOMPClauseWithPreInit(const OMPClauseWithPreInit *C);
Alexey Bataev005248a2016-02-25 05:25:57 +0000420 void VistOMPClauseWithPostUpdate(const OMPClauseWithPostUpdate *C);
Alexey Bataev5ec3eb12013-07-19 03:13:43 +0000421};
422
Alexey Bataev3392d762016-02-16 11:18:12 +0000423void OMPClauseProfiler::VistOMPClauseWithPreInit(
424 const OMPClauseWithPreInit *C) {
425 if (auto *S = C->getPreInitStmt())
426 Profiler->VisitStmt(S);
427}
428
Alexey Bataev005248a2016-02-25 05:25:57 +0000429void OMPClauseProfiler::VistOMPClauseWithPostUpdate(
430 const OMPClauseWithPostUpdate *C) {
Alexey Bataev37e594c2016-03-04 07:21:16 +0000431 VistOMPClauseWithPreInit(C);
Alexey Bataev005248a2016-02-25 05:25:57 +0000432 if (auto *E = C->getPostUpdateExpr())
433 Profiler->VisitStmt(E);
434}
435
Alexey Bataevaadd52e2014-02-13 05:29:23 +0000436void OMPClauseProfiler::VisitOMPIfClause(const OMPIfClause *C) {
Arpith Chacko Jacobfe4890a2017-01-18 20:40:48 +0000437 VistOMPClauseWithPreInit(C);
Alexey Bataevaadd52e2014-02-13 05:29:23 +0000438 if (C->getCondition())
439 Profiler->VisitStmt(C->getCondition());
440}
441
Alexey Bataev3778b602014-07-17 07:32:53 +0000442void OMPClauseProfiler::VisitOMPFinalClause(const OMPFinalClause *C) {
443 if (C->getCondition())
444 Profiler->VisitStmt(C->getCondition());
445}
446
Alexey Bataev568a8332014-03-06 06:15:19 +0000447void OMPClauseProfiler::VisitOMPNumThreadsClause(const OMPNumThreadsClause *C) {
Arpith Chacko Jacob33c849a2017-01-25 00:57:16 +0000448 VistOMPClauseWithPreInit(C);
Alexey Bataev568a8332014-03-06 06:15:19 +0000449 if (C->getNumThreads())
450 Profiler->VisitStmt(C->getNumThreads());
451}
452
Alexey Bataev62c87d22014-03-21 04:51:18 +0000453void OMPClauseProfiler::VisitOMPSafelenClause(const OMPSafelenClause *C) {
454 if (C->getSafelen())
455 Profiler->VisitStmt(C->getSafelen());
456}
457
Alexey Bataev66b15b52015-08-21 11:14:16 +0000458void OMPClauseProfiler::VisitOMPSimdlenClause(const OMPSimdlenClause *C) {
459 if (C->getSimdlen())
460 Profiler->VisitStmt(C->getSimdlen());
461}
462
Alexey Bataev9cc10fc2019-03-12 18:52:33 +0000463void OMPClauseProfiler::VisitOMPAllocatorClause(const OMPAllocatorClause *C) {
464 if (C->getAllocator())
465 Profiler->VisitStmt(C->getAllocator());
466}
467
Alexander Musman8bd31e62014-05-27 15:12:19 +0000468void OMPClauseProfiler::VisitOMPCollapseClause(const OMPCollapseClause *C) {
469 if (C->getNumForLoops())
470 Profiler->VisitStmt(C->getNumForLoops());
471}
472
Alexey Bataev5ec3eb12013-07-19 03:13:43 +0000473void OMPClauseProfiler::VisitOMPDefaultClause(const OMPDefaultClause *C) { }
Alexey Bataev756c1962013-09-24 03:17:45 +0000474
Alexey Bataevbcbadb62014-05-06 06:04:14 +0000475void OMPClauseProfiler::VisitOMPProcBindClause(const OMPProcBindClause *C) { }
476
Kelvin Li1408f912018-09-26 04:28:39 +0000477void OMPClauseProfiler::VisitOMPUnifiedAddressClause(
478 const OMPUnifiedAddressClause *C) {}
479
Patrick Lyster4a370b92018-10-01 13:47:43 +0000480void OMPClauseProfiler::VisitOMPUnifiedSharedMemoryClause(
481 const OMPUnifiedSharedMemoryClause *C) {}
482
Patrick Lyster6bdf63b2018-10-03 20:07:58 +0000483void OMPClauseProfiler::VisitOMPReverseOffloadClause(
484 const OMPReverseOffloadClause *C) {}
485
Patrick Lyster3fe9e392018-10-11 14:41:10 +0000486void OMPClauseProfiler::VisitOMPDynamicAllocatorsClause(
487 const OMPDynamicAllocatorsClause *C) {}
488
Patrick Lyster7a2a27c2018-11-02 12:18:11 +0000489void OMPClauseProfiler::VisitOMPAtomicDefaultMemOrderClause(
490 const OMPAtomicDefaultMemOrderClause *C) {}
491
Alexey Bataev56dafe82014-06-20 07:16:17 +0000492void OMPClauseProfiler::VisitOMPScheduleClause(const OMPScheduleClause *C) {
Alexey Bataev3392d762016-02-16 11:18:12 +0000493 VistOMPClauseWithPreInit(C);
494 if (auto *S = C->getChunkSize())
495 Profiler->VisitStmt(S);
Alexey Bataev56dafe82014-06-20 07:16:17 +0000496}
497
Alexey Bataev10e775f2015-07-30 11:36:16 +0000498void OMPClauseProfiler::VisitOMPOrderedClause(const OMPOrderedClause *C) {
499 if (auto *Num = C->getNumForLoops())
500 Profiler->VisitStmt(Num);
501}
Alexey Bataev142e1fc2014-06-20 09:44:06 +0000502
Alexey Bataev236070f2014-06-20 11:19:47 +0000503void OMPClauseProfiler::VisitOMPNowaitClause(const OMPNowaitClause *) {}
504
Alexey Bataev7aea99a2014-07-17 12:19:31 +0000505void OMPClauseProfiler::VisitOMPUntiedClause(const OMPUntiedClause *) {}
506
Alexey Bataev74ba3a52014-07-17 12:47:03 +0000507void OMPClauseProfiler::VisitOMPMergeableClause(const OMPMergeableClause *) {}
508
Alexey Bataevf98b00c2014-07-23 02:27:21 +0000509void OMPClauseProfiler::VisitOMPReadClause(const OMPReadClause *) {}
510
Alexey Bataevdea47612014-07-23 07:46:59 +0000511void OMPClauseProfiler::VisitOMPWriteClause(const OMPWriteClause *) {}
512
Alexey Bataev67a4f222014-07-23 10:25:33 +0000513void OMPClauseProfiler::VisitOMPUpdateClause(const OMPUpdateClause *) {}
514
Alexey Bataev459dec02014-07-24 06:46:57 +0000515void OMPClauseProfiler::VisitOMPCaptureClause(const OMPCaptureClause *) {}
516
Alexey Bataev82bad8b2014-07-24 08:55:34 +0000517void OMPClauseProfiler::VisitOMPSeqCstClause(const OMPSeqCstClause *) {}
518
Alexey Bataev346265e2015-09-25 10:37:12 +0000519void OMPClauseProfiler::VisitOMPThreadsClause(const OMPThreadsClause *) {}
520
Alexey Bataevd14d1e62015-09-28 06:39:35 +0000521void OMPClauseProfiler::VisitOMPSIMDClause(const OMPSIMDClause *) {}
522
Alexey Bataevb825de12015-12-07 10:51:44 +0000523void OMPClauseProfiler::VisitOMPNogroupClause(const OMPNogroupClause *) {}
524
Alexey Bataev756c1962013-09-24 03:17:45 +0000525template<typename T>
526void OMPClauseProfiler::VisitOMPClauseList(T *Node) {
Alexey Bataev03b340a2014-10-21 03:16:40 +0000527 for (auto *E : Node->varlists()) {
Richard Trieu6a77a1c2016-06-10 04:52:09 +0000528 if (E)
529 Profiler->VisitStmt(E);
Alexey Bataev03b340a2014-10-21 03:16:40 +0000530 }
Alexey Bataev756c1962013-09-24 03:17:45 +0000531}
Alexey Bataev5ec3eb12013-07-19 03:13:43 +0000532
533void OMPClauseProfiler::VisitOMPPrivateClause(const OMPPrivateClause *C) {
Alexey Bataev756c1962013-09-24 03:17:45 +0000534 VisitOMPClauseList(C);
Alexey Bataev03b340a2014-10-21 03:16:40 +0000535 for (auto *E : C->private_copies()) {
Richard Trieu6a77a1c2016-06-10 04:52:09 +0000536 if (E)
537 Profiler->VisitStmt(E);
Alexey Bataev03b340a2014-10-21 03:16:40 +0000538 }
Alexey Bataev5ec3eb12013-07-19 03:13:43 +0000539}
Alexey Bataev4a5bb772014-10-08 14:01:46 +0000540void
541OMPClauseProfiler::VisitOMPFirstprivateClause(const OMPFirstprivateClause *C) {
Alexey Bataevd5af8e42013-10-01 05:32:34 +0000542 VisitOMPClauseList(C);
Alexey Bataev417089f2016-02-17 13:19:37 +0000543 VistOMPClauseWithPreInit(C);
Alexey Bataev4a5bb772014-10-08 14:01:46 +0000544 for (auto *E : C->private_copies()) {
Richard Trieu6a77a1c2016-06-10 04:52:09 +0000545 if (E)
546 Profiler->VisitStmt(E);
Alexey Bataev4a5bb772014-10-08 14:01:46 +0000547 }
548 for (auto *E : C->inits()) {
Richard Trieu6a77a1c2016-06-10 04:52:09 +0000549 if (E)
550 Profiler->VisitStmt(E);
Alexey Bataev4a5bb772014-10-08 14:01:46 +0000551 }
Alexey Bataevd5af8e42013-10-01 05:32:34 +0000552}
Alexander Musman1bb328c2014-06-04 13:06:39 +0000553void
554OMPClauseProfiler::VisitOMPLastprivateClause(const OMPLastprivateClause *C) {
555 VisitOMPClauseList(C);
Alexey Bataev005248a2016-02-25 05:25:57 +0000556 VistOMPClauseWithPostUpdate(C);
Alexey Bataev38e89532015-04-16 04:54:05 +0000557 for (auto *E : C->source_exprs()) {
Richard Trieu6a77a1c2016-06-10 04:52:09 +0000558 if (E)
559 Profiler->VisitStmt(E);
Alexey Bataev38e89532015-04-16 04:54:05 +0000560 }
561 for (auto *E : C->destination_exprs()) {
Richard Trieu6a77a1c2016-06-10 04:52:09 +0000562 if (E)
563 Profiler->VisitStmt(E);
Alexey Bataev38e89532015-04-16 04:54:05 +0000564 }
565 for (auto *E : C->assignment_ops()) {
Richard Trieu6a77a1c2016-06-10 04:52:09 +0000566 if (E)
567 Profiler->VisitStmt(E);
Alexey Bataev38e89532015-04-16 04:54:05 +0000568 }
Alexander Musman1bb328c2014-06-04 13:06:39 +0000569}
Alexey Bataev758e55e2013-09-06 18:03:48 +0000570void OMPClauseProfiler::VisitOMPSharedClause(const OMPSharedClause *C) {
Alexey Bataev756c1962013-09-24 03:17:45 +0000571 VisitOMPClauseList(C);
Alexey Bataev758e55e2013-09-06 18:03:48 +0000572}
Alexey Bataevc5e02582014-06-16 07:08:35 +0000573void OMPClauseProfiler::VisitOMPReductionClause(
574 const OMPReductionClause *C) {
575 Profiler->VisitNestedNameSpecifier(
576 C->getQualifierLoc().getNestedNameSpecifier());
577 Profiler->VisitName(C->getNameInfo().getName());
578 VisitOMPClauseList(C);
Alexey Bataev61205072016-03-02 04:57:40 +0000579 VistOMPClauseWithPostUpdate(C);
Alexey Bataevf24e7b12015-10-08 09:10:53 +0000580 for (auto *E : C->privates()) {
Richard Trieu6a77a1c2016-06-10 04:52:09 +0000581 if (E)
582 Profiler->VisitStmt(E);
Alexey Bataevf24e7b12015-10-08 09:10:53 +0000583 }
Alexey Bataev794ba0d2015-04-10 10:43:45 +0000584 for (auto *E : C->lhs_exprs()) {
Richard Trieu6a77a1c2016-06-10 04:52:09 +0000585 if (E)
586 Profiler->VisitStmt(E);
Alexey Bataev794ba0d2015-04-10 10:43:45 +0000587 }
588 for (auto *E : C->rhs_exprs()) {
Richard Trieu6a77a1c2016-06-10 04:52:09 +0000589 if (E)
590 Profiler->VisitStmt(E);
Alexey Bataev794ba0d2015-04-10 10:43:45 +0000591 }
592 for (auto *E : C->reduction_ops()) {
Richard Trieu6a77a1c2016-06-10 04:52:09 +0000593 if (E)
594 Profiler->VisitStmt(E);
Alexey Bataev794ba0d2015-04-10 10:43:45 +0000595 }
Alexey Bataevc5e02582014-06-16 07:08:35 +0000596}
Alexey Bataev169d96a2017-07-18 20:17:46 +0000597void OMPClauseProfiler::VisitOMPTaskReductionClause(
598 const OMPTaskReductionClause *C) {
599 Profiler->VisitNestedNameSpecifier(
600 C->getQualifierLoc().getNestedNameSpecifier());
601 Profiler->VisitName(C->getNameInfo().getName());
602 VisitOMPClauseList(C);
603 VistOMPClauseWithPostUpdate(C);
604 for (auto *E : C->privates()) {
605 if (E)
606 Profiler->VisitStmt(E);
607 }
608 for (auto *E : C->lhs_exprs()) {
609 if (E)
610 Profiler->VisitStmt(E);
611 }
612 for (auto *E : C->rhs_exprs()) {
613 if (E)
614 Profiler->VisitStmt(E);
615 }
616 for (auto *E : C->reduction_ops()) {
617 if (E)
618 Profiler->VisitStmt(E);
619 }
620}
Alexey Bataevfa312f32017-07-21 18:48:21 +0000621void OMPClauseProfiler::VisitOMPInReductionClause(
622 const OMPInReductionClause *C) {
623 Profiler->VisitNestedNameSpecifier(
624 C->getQualifierLoc().getNestedNameSpecifier());
625 Profiler->VisitName(C->getNameInfo().getName());
626 VisitOMPClauseList(C);
627 VistOMPClauseWithPostUpdate(C);
628 for (auto *E : C->privates()) {
629 if (E)
630 Profiler->VisitStmt(E);
631 }
632 for (auto *E : C->lhs_exprs()) {
633 if (E)
634 Profiler->VisitStmt(E);
635 }
636 for (auto *E : C->rhs_exprs()) {
637 if (E)
638 Profiler->VisitStmt(E);
639 }
640 for (auto *E : C->reduction_ops()) {
641 if (E)
642 Profiler->VisitStmt(E);
643 }
Alexey Bataev88202be2017-07-27 13:20:36 +0000644 for (auto *E : C->taskgroup_descriptors()) {
645 if (E)
646 Profiler->VisitStmt(E);
647 }
Alexey Bataevfa312f32017-07-21 18:48:21 +0000648}
Alexander Musman8dba6642014-04-22 13:09:42 +0000649void OMPClauseProfiler::VisitOMPLinearClause(const OMPLinearClause *C) {
650 VisitOMPClauseList(C);
Alexey Bataev78849fb2016-03-09 09:49:00 +0000651 VistOMPClauseWithPostUpdate(C);
Alexey Bataevbd9fec12015-08-18 06:47:21 +0000652 for (auto *E : C->privates()) {
Richard Trieu6a77a1c2016-06-10 04:52:09 +0000653 if (E)
654 Profiler->VisitStmt(E);
Alexey Bataevbd9fec12015-08-18 06:47:21 +0000655 }
Alexander Musman3276a272015-03-21 10:12:56 +0000656 for (auto *E : C->inits()) {
Richard Trieu6a77a1c2016-06-10 04:52:09 +0000657 if (E)
658 Profiler->VisitStmt(E);
Alexander Musman3276a272015-03-21 10:12:56 +0000659 }
660 for (auto *E : C->updates()) {
Richard Trieu6a77a1c2016-06-10 04:52:09 +0000661 if (E)
662 Profiler->VisitStmt(E);
Alexander Musman3276a272015-03-21 10:12:56 +0000663 }
664 for (auto *E : C->finals()) {
Richard Trieu6a77a1c2016-06-10 04:52:09 +0000665 if (E)
666 Profiler->VisitStmt(E);
Alexander Musman3276a272015-03-21 10:12:56 +0000667 }
Richard Trieu6a77a1c2016-06-10 04:52:09 +0000668 if (C->getStep())
669 Profiler->VisitStmt(C->getStep());
670 if (C->getCalcStep())
671 Profiler->VisitStmt(C->getCalcStep());
Alexander Musman8dba6642014-04-22 13:09:42 +0000672}
Alexander Musmanf0d76e72014-05-29 14:36:25 +0000673void OMPClauseProfiler::VisitOMPAlignedClause(const OMPAlignedClause *C) {
674 VisitOMPClauseList(C);
Richard Trieu6a77a1c2016-06-10 04:52:09 +0000675 if (C->getAlignment())
676 Profiler->VisitStmt(C->getAlignment());
Alexander Musmanf0d76e72014-05-29 14:36:25 +0000677}
Alexey Bataevd48bcd82014-03-31 03:36:38 +0000678void OMPClauseProfiler::VisitOMPCopyinClause(const OMPCopyinClause *C) {
679 VisitOMPClauseList(C);
Alexey Bataevf56f98c2015-04-16 05:39:01 +0000680 for (auto *E : C->source_exprs()) {
Richard Trieu6a77a1c2016-06-10 04:52:09 +0000681 if (E)
682 Profiler->VisitStmt(E);
Alexey Bataevf56f98c2015-04-16 05:39:01 +0000683 }
684 for (auto *E : C->destination_exprs()) {
Richard Trieu6a77a1c2016-06-10 04:52:09 +0000685 if (E)
686 Profiler->VisitStmt(E);
Alexey Bataevf56f98c2015-04-16 05:39:01 +0000687 }
688 for (auto *E : C->assignment_ops()) {
Richard Trieu6a77a1c2016-06-10 04:52:09 +0000689 if (E)
690 Profiler->VisitStmt(E);
Alexey Bataevf56f98c2015-04-16 05:39:01 +0000691 }
Alexey Bataevd48bcd82014-03-31 03:36:38 +0000692}
Alexey Bataevbae9a792014-06-27 10:37:06 +0000693void
694OMPClauseProfiler::VisitOMPCopyprivateClause(const OMPCopyprivateClause *C) {
695 VisitOMPClauseList(C);
Alexey Bataeva63048e2015-03-23 06:18:07 +0000696 for (auto *E : C->source_exprs()) {
Richard Trieu6a77a1c2016-06-10 04:52:09 +0000697 if (E)
698 Profiler->VisitStmt(E);
Alexey Bataeva63048e2015-03-23 06:18:07 +0000699 }
700 for (auto *E : C->destination_exprs()) {
Richard Trieu6a77a1c2016-06-10 04:52:09 +0000701 if (E)
702 Profiler->VisitStmt(E);
Alexey Bataeva63048e2015-03-23 06:18:07 +0000703 }
704 for (auto *E : C->assignment_ops()) {
Richard Trieu6a77a1c2016-06-10 04:52:09 +0000705 if (E)
706 Profiler->VisitStmt(E);
Alexey Bataeva63048e2015-03-23 06:18:07 +0000707 }
Alexey Bataevbae9a792014-06-27 10:37:06 +0000708}
Alexey Bataev6125da92014-07-21 11:26:11 +0000709void OMPClauseProfiler::VisitOMPFlushClause(const OMPFlushClause *C) {
710 VisitOMPClauseList(C);
711}
Alexey Bataev1c2cfbc2015-06-23 14:25:19 +0000712void OMPClauseProfiler::VisitOMPDependClause(const OMPDependClause *C) {
713 VisitOMPClauseList(C);
714}
Michael Wonge710d542015-08-07 16:16:36 +0000715void OMPClauseProfiler::VisitOMPDeviceClause(const OMPDeviceClause *C) {
Richard Trieu6a77a1c2016-06-10 04:52:09 +0000716 if (C->getDevice())
717 Profiler->VisitStmt(C->getDevice());
Michael Wonge710d542015-08-07 16:16:36 +0000718}
Kelvin Li0bff7af2015-11-23 05:32:03 +0000719void OMPClauseProfiler::VisitOMPMapClause(const OMPMapClause *C) {
720 VisitOMPClauseList(C);
721}
Alexey Bataeve04483e2019-03-27 14:14:31 +0000722void OMPClauseProfiler::VisitOMPAllocateClause(const OMPAllocateClause *C) {
723 if (Expr *Allocator = C->getAllocator())
724 Profiler->VisitStmt(Allocator);
725 VisitOMPClauseList(C);
726}
Kelvin Li099bb8c2015-11-24 20:50:12 +0000727void OMPClauseProfiler::VisitOMPNumTeamsClause(const OMPNumTeamsClause *C) {
Arpith Chacko Jacobbc126342017-01-25 11:28:18 +0000728 VistOMPClauseWithPreInit(C);
Richard Trieu6a77a1c2016-06-10 04:52:09 +0000729 if (C->getNumTeams())
730 Profiler->VisitStmt(C->getNumTeams());
Kelvin Li099bb8c2015-11-24 20:50:12 +0000731}
Kelvin Lia15fb1a2015-11-27 18:47:36 +0000732void OMPClauseProfiler::VisitOMPThreadLimitClause(
733 const OMPThreadLimitClause *C) {
Arpith Chacko Jacob7ecc0b72017-01-25 11:44:35 +0000734 VistOMPClauseWithPreInit(C);
Richard Trieu6a77a1c2016-06-10 04:52:09 +0000735 if (C->getThreadLimit())
736 Profiler->VisitStmt(C->getThreadLimit());
Kelvin Lia15fb1a2015-11-27 18:47:36 +0000737}
Alexey Bataeva0569352015-12-01 10:17:31 +0000738void OMPClauseProfiler::VisitOMPPriorityClause(const OMPPriorityClause *C) {
Richard Trieu6a77a1c2016-06-10 04:52:09 +0000739 if (C->getPriority())
740 Profiler->VisitStmt(C->getPriority());
Alexey Bataeva0569352015-12-01 10:17:31 +0000741}
Alexey Bataev1fd4aed2015-12-07 12:52:51 +0000742void OMPClauseProfiler::VisitOMPGrainsizeClause(const OMPGrainsizeClause *C) {
Richard Trieu6a77a1c2016-06-10 04:52:09 +0000743 if (C->getGrainsize())
744 Profiler->VisitStmt(C->getGrainsize());
Alexey Bataev1fd4aed2015-12-07 12:52:51 +0000745}
Alexey Bataev382967a2015-12-08 12:06:20 +0000746void OMPClauseProfiler::VisitOMPNumTasksClause(const OMPNumTasksClause *C) {
Richard Trieu6a77a1c2016-06-10 04:52:09 +0000747 if (C->getNumTasks())
748 Profiler->VisitStmt(C->getNumTasks());
Alexey Bataev382967a2015-12-08 12:06:20 +0000749}
Alexey Bataev28c75412015-12-15 08:19:24 +0000750void OMPClauseProfiler::VisitOMPHintClause(const OMPHintClause *C) {
Richard Trieu6a77a1c2016-06-10 04:52:09 +0000751 if (C->getHint())
752 Profiler->VisitStmt(C->getHint());
Alexey Bataev28c75412015-12-15 08:19:24 +0000753}
Samuel Antao661c0902016-05-26 17:39:58 +0000754void OMPClauseProfiler::VisitOMPToClause(const OMPToClause *C) {
755 VisitOMPClauseList(C);
756}
Samuel Antaoec172c62016-05-26 17:49:04 +0000757void OMPClauseProfiler::VisitOMPFromClause(const OMPFromClause *C) {
758 VisitOMPClauseList(C);
759}
Carlo Bertolli2404b172016-07-13 15:37:16 +0000760void OMPClauseProfiler::VisitOMPUseDevicePtrClause(
761 const OMPUseDevicePtrClause *C) {
762 VisitOMPClauseList(C);
763}
Carlo Bertolli70594e92016-07-13 17:16:49 +0000764void OMPClauseProfiler::VisitOMPIsDevicePtrClause(
765 const OMPIsDevicePtrClause *C) {
766 VisitOMPClauseList(C);
767}
Alexander Kornienkoab9db512015-06-22 23:07:51 +0000768}
Alexey Bataev5ec3eb12013-07-19 03:13:43 +0000769
770void
Alexey Bataev1b59ab52014-02-27 08:29:12 +0000771StmtProfiler::VisitOMPExecutableDirective(const OMPExecutableDirective *S) {
Alexey Bataev5ec3eb12013-07-19 03:13:43 +0000772 VisitStmt(S);
773 OMPClauseProfiler P(this);
774 ArrayRef<OMPClause *> Clauses = S->clauses();
775 for (ArrayRef<OMPClause *>::iterator I = Clauses.begin(), E = Clauses.end();
776 I != E; ++I)
777 if (*I)
778 P.Visit(*I);
779}
780
Alexander Musman3aaab662014-08-19 11:27:13 +0000781void StmtProfiler::VisitOMPLoopDirective(const OMPLoopDirective *S) {
782 VisitOMPExecutableDirective(S);
783}
784
Alexey Bataev1b59ab52014-02-27 08:29:12 +0000785void StmtProfiler::VisitOMPParallelDirective(const OMPParallelDirective *S) {
786 VisitOMPExecutableDirective(S);
787}
788
789void StmtProfiler::VisitOMPSimdDirective(const OMPSimdDirective *S) {
Alexander Musman3aaab662014-08-19 11:27:13 +0000790 VisitOMPLoopDirective(S);
Alexey Bataev1b59ab52014-02-27 08:29:12 +0000791}
792
Alexey Bataevf29276e2014-06-18 04:14:57 +0000793void StmtProfiler::VisitOMPForDirective(const OMPForDirective *S) {
Alexander Musman3aaab662014-08-19 11:27:13 +0000794 VisitOMPLoopDirective(S);
Alexey Bataevf29276e2014-06-18 04:14:57 +0000795}
796
Alexander Musmanf82886e2014-09-18 05:12:34 +0000797void StmtProfiler::VisitOMPForSimdDirective(const OMPForSimdDirective *S) {
798 VisitOMPLoopDirective(S);
799}
800
Alexey Bataevd3f8dd22014-06-25 11:44:49 +0000801void StmtProfiler::VisitOMPSectionsDirective(const OMPSectionsDirective *S) {
802 VisitOMPExecutableDirective(S);
803}
804
Alexey Bataev1e0498a2014-06-26 08:21:58 +0000805void StmtProfiler::VisitOMPSectionDirective(const OMPSectionDirective *S) {
806 VisitOMPExecutableDirective(S);
807}
808
Alexey Bataevd1e40fb2014-06-26 12:05:45 +0000809void StmtProfiler::VisitOMPSingleDirective(const OMPSingleDirective *S) {
810 VisitOMPExecutableDirective(S);
811}
812
Alexander Musman80c22892014-07-17 08:54:58 +0000813void StmtProfiler::VisitOMPMasterDirective(const OMPMasterDirective *S) {
814 VisitOMPExecutableDirective(S);
815}
816
Alexander Musmand9ed09f2014-07-21 09:42:05 +0000817void StmtProfiler::VisitOMPCriticalDirective(const OMPCriticalDirective *S) {
818 VisitOMPExecutableDirective(S);
819 VisitName(S->getDirectiveName().getName());
820}
821
Alexey Bataev4acb8592014-07-07 13:01:15 +0000822void
823StmtProfiler::VisitOMPParallelForDirective(const OMPParallelForDirective *S) {
Alexander Musman3aaab662014-08-19 11:27:13 +0000824 VisitOMPLoopDirective(S);
Alexey Bataev4acb8592014-07-07 13:01:15 +0000825}
826
Alexander Musmane4e893b2014-09-23 09:33:00 +0000827void StmtProfiler::VisitOMPParallelForSimdDirective(
828 const OMPParallelForSimdDirective *S) {
829 VisitOMPLoopDirective(S);
830}
831
Alexey Bataev84d0b3e2014-07-08 08:12:03 +0000832void StmtProfiler::VisitOMPParallelSectionsDirective(
833 const OMPParallelSectionsDirective *S) {
834 VisitOMPExecutableDirective(S);
835}
836
Alexey Bataev9c2e8ee2014-07-11 11:25:16 +0000837void StmtProfiler::VisitOMPTaskDirective(const OMPTaskDirective *S) {
838 VisitOMPExecutableDirective(S);
839}
840
Alexey Bataev68446b72014-07-18 07:47:19 +0000841void StmtProfiler::VisitOMPTaskyieldDirective(const OMPTaskyieldDirective *S) {
842 VisitOMPExecutableDirective(S);
843}
844
Alexey Bataev4d1dfea2014-07-18 09:11:51 +0000845void StmtProfiler::VisitOMPBarrierDirective(const OMPBarrierDirective *S) {
846 VisitOMPExecutableDirective(S);
847}
848
Alexey Bataev2df347a2014-07-18 10:17:07 +0000849void StmtProfiler::VisitOMPTaskwaitDirective(const OMPTaskwaitDirective *S) {
850 VisitOMPExecutableDirective(S);
851}
852
Alexey Bataevc30dd2d2015-06-18 12:14:09 +0000853void StmtProfiler::VisitOMPTaskgroupDirective(const OMPTaskgroupDirective *S) {
854 VisitOMPExecutableDirective(S);
Alexey Bataev3b1b8952017-07-25 15:53:26 +0000855 if (const Expr *E = S->getReductionRef())
856 VisitStmt(E);
Alexey Bataevc30dd2d2015-06-18 12:14:09 +0000857}
858
Alexey Bataev6125da92014-07-21 11:26:11 +0000859void StmtProfiler::VisitOMPFlushDirective(const OMPFlushDirective *S) {
860 VisitOMPExecutableDirective(S);
861}
862
Alexey Bataev9fb6e642014-07-22 06:45:04 +0000863void StmtProfiler::VisitOMPOrderedDirective(const OMPOrderedDirective *S) {
864 VisitOMPExecutableDirective(S);
865}
866
Alexey Bataev0162e452014-07-22 10:10:35 +0000867void StmtProfiler::VisitOMPAtomicDirective(const OMPAtomicDirective *S) {
868 VisitOMPExecutableDirective(S);
869}
870
Alexey Bataev0bd520b2014-09-19 08:19:49 +0000871void StmtProfiler::VisitOMPTargetDirective(const OMPTargetDirective *S) {
872 VisitOMPExecutableDirective(S);
873}
874
Michael Wong65f367f2015-07-21 13:44:28 +0000875void StmtProfiler::VisitOMPTargetDataDirective(const OMPTargetDataDirective *S) {
876 VisitOMPExecutableDirective(S);
877}
878
Samuel Antaodf67fc42016-01-19 19:15:56 +0000879void StmtProfiler::VisitOMPTargetEnterDataDirective(
880 const OMPTargetEnterDataDirective *S) {
881 VisitOMPExecutableDirective(S);
882}
883
Samuel Antao72590762016-01-19 20:04:50 +0000884void StmtProfiler::VisitOMPTargetExitDataDirective(
885 const OMPTargetExitDataDirective *S) {
886 VisitOMPExecutableDirective(S);
887}
888
Arpith Chacko Jacobe955b3d2016-01-26 18:48:41 +0000889void StmtProfiler::VisitOMPTargetParallelDirective(
890 const OMPTargetParallelDirective *S) {
891 VisitOMPExecutableDirective(S);
892}
893
Arpith Chacko Jacob05bebb52016-02-03 15:46:42 +0000894void StmtProfiler::VisitOMPTargetParallelForDirective(
895 const OMPTargetParallelForDirective *S) {
896 VisitOMPExecutableDirective(S);
897}
898
Alexey Bataev13314bf2014-10-09 04:18:56 +0000899void StmtProfiler::VisitOMPTeamsDirective(const OMPTeamsDirective *S) {
900 VisitOMPExecutableDirective(S);
901}
902
Alexey Bataev6d4ed052015-07-01 06:57:41 +0000903void StmtProfiler::VisitOMPCancellationPointDirective(
904 const OMPCancellationPointDirective *S) {
905 VisitOMPExecutableDirective(S);
906}
907
Alexey Bataev80909872015-07-02 11:25:17 +0000908void StmtProfiler::VisitOMPCancelDirective(const OMPCancelDirective *S) {
909 VisitOMPExecutableDirective(S);
910}
911
Alexey Bataev49f6e782015-12-01 04:18:41 +0000912void StmtProfiler::VisitOMPTaskLoopDirective(const OMPTaskLoopDirective *S) {
913 VisitOMPLoopDirective(S);
914}
915
Alexey Bataev0a6ed842015-12-03 09:40:15 +0000916void StmtProfiler::VisitOMPTaskLoopSimdDirective(
917 const OMPTaskLoopSimdDirective *S) {
918 VisitOMPLoopDirective(S);
919}
920
Carlo Bertolli6200a3d2015-12-14 14:51:25 +0000921void StmtProfiler::VisitOMPDistributeDirective(
922 const OMPDistributeDirective *S) {
923 VisitOMPLoopDirective(S);
924}
925
Carlo Bertollib4adf552016-01-15 18:50:31 +0000926void OMPClauseProfiler::VisitOMPDistScheduleClause(
927 const OMPDistScheduleClause *C) {
Alexey Bataev3392d762016-02-16 11:18:12 +0000928 VistOMPClauseWithPreInit(C);
929 if (auto *S = C->getChunkSize())
930 Profiler->VisitStmt(S);
Carlo Bertollib4adf552016-01-15 18:50:31 +0000931}
932
Arpith Chacko Jacob3cf89042016-01-26 16:37:23 +0000933void OMPClauseProfiler::VisitOMPDefaultmapClause(const OMPDefaultmapClause *) {}
934
Samuel Antao686c70c2016-05-26 17:30:50 +0000935void StmtProfiler::VisitOMPTargetUpdateDirective(
936 const OMPTargetUpdateDirective *S) {
937 VisitOMPExecutableDirective(S);
938}
939
Carlo Bertolli9925f152016-06-27 14:55:37 +0000940void StmtProfiler::VisitOMPDistributeParallelForDirective(
941 const OMPDistributeParallelForDirective *S) {
942 VisitOMPLoopDirective(S);
943}
944
Kelvin Li4a39add2016-07-05 05:00:15 +0000945void StmtProfiler::VisitOMPDistributeParallelForSimdDirective(
946 const OMPDistributeParallelForSimdDirective *S) {
947 VisitOMPLoopDirective(S);
948}
949
Kelvin Li787f3fc2016-07-06 04:45:38 +0000950void StmtProfiler::VisitOMPDistributeSimdDirective(
951 const OMPDistributeSimdDirective *S) {
952 VisitOMPLoopDirective(S);
953}
954
Kelvin Lia579b912016-07-14 02:54:56 +0000955void StmtProfiler::VisitOMPTargetParallelForSimdDirective(
956 const OMPTargetParallelForSimdDirective *S) {
957 VisitOMPLoopDirective(S);
958}
959
Kelvin Li986330c2016-07-20 22:57:10 +0000960void StmtProfiler::VisitOMPTargetSimdDirective(
961 const OMPTargetSimdDirective *S) {
962 VisitOMPLoopDirective(S);
963}
964
Kelvin Li02532872016-08-05 14:37:37 +0000965void StmtProfiler::VisitOMPTeamsDistributeDirective(
966 const OMPTeamsDistributeDirective *S) {
967 VisitOMPLoopDirective(S);
968}
969
Kelvin Li4e325f72016-10-25 12:50:55 +0000970void StmtProfiler::VisitOMPTeamsDistributeSimdDirective(
971 const OMPTeamsDistributeSimdDirective *S) {
972 VisitOMPLoopDirective(S);
973}
974
Kelvin Li579e41c2016-11-30 23:51:03 +0000975void StmtProfiler::VisitOMPTeamsDistributeParallelForSimdDirective(
976 const OMPTeamsDistributeParallelForSimdDirective *S) {
977 VisitOMPLoopDirective(S);
978}
979
Kelvin Li7ade93f2016-12-09 03:24:30 +0000980void StmtProfiler::VisitOMPTeamsDistributeParallelForDirective(
981 const OMPTeamsDistributeParallelForDirective *S) {
982 VisitOMPLoopDirective(S);
983}
984
Kelvin Libf594a52016-12-17 05:48:59 +0000985void StmtProfiler::VisitOMPTargetTeamsDirective(
986 const OMPTargetTeamsDirective *S) {
987 VisitOMPExecutableDirective(S);
988}
989
Kelvin Li83c451e2016-12-25 04:52:54 +0000990void StmtProfiler::VisitOMPTargetTeamsDistributeDirective(
991 const OMPTargetTeamsDistributeDirective *S) {
992 VisitOMPLoopDirective(S);
993}
994
Kelvin Li80e8f562016-12-29 22:16:30 +0000995void StmtProfiler::VisitOMPTargetTeamsDistributeParallelForDirective(
996 const OMPTargetTeamsDistributeParallelForDirective *S) {
997 VisitOMPLoopDirective(S);
998}
999
Kelvin Li1851df52017-01-03 05:23:48 +00001000void StmtProfiler::VisitOMPTargetTeamsDistributeParallelForSimdDirective(
1001 const OMPTargetTeamsDistributeParallelForSimdDirective *S) {
1002 VisitOMPLoopDirective(S);
1003}
1004
Kelvin Lida681182017-01-10 18:08:18 +00001005void StmtProfiler::VisitOMPTargetTeamsDistributeSimdDirective(
1006 const OMPTargetTeamsDistributeSimdDirective *S) {
1007 VisitOMPLoopDirective(S);
1008}
1009
Chandler Carruth631abd92011-06-16 06:47:06 +00001010void StmtProfiler::VisitExpr(const Expr *S) {
Douglas Gregor5c193b92009-07-28 00:33:38 +00001011 VisitStmt(S);
1012}
1013
Bill Wendling7c44da22018-10-31 03:48:47 +00001014void StmtProfiler::VisitConstantExpr(const ConstantExpr *S) {
1015 VisitExpr(S);
1016}
1017
Chandler Carruth631abd92011-06-16 06:47:06 +00001018void StmtProfiler::VisitDeclRefExpr(const DeclRefExpr *S) {
Douglas Gregor5c193b92009-07-28 00:33:38 +00001019 VisitExpr(S);
Douglas Gregorf5b160f2010-07-13 08:37:11 +00001020 if (!Canonical)
1021 VisitNestedNameSpecifier(S->getQualifier());
Douglas Gregor5c193b92009-07-28 00:33:38 +00001022 VisitDecl(S->getDecl());
Richard Trieu4d06bef2018-02-13 19:53:40 +00001023 if (!Canonical) {
1024 ID.AddBoolean(S->hasExplicitTemplateArgs());
1025 if (S->hasExplicitTemplateArgs())
1026 VisitTemplateArguments(S->getTemplateArgs(), S->getNumTemplateArgs());
1027 }
Douglas Gregor5c193b92009-07-28 00:33:38 +00001028}
1029
Chandler Carruth631abd92011-06-16 06:47:06 +00001030void StmtProfiler::VisitPredefinedExpr(const PredefinedExpr *S) {
Douglas Gregor5c193b92009-07-28 00:33:38 +00001031 VisitExpr(S);
Bruno Ricci17ff0262018-10-27 19:21:19 +00001032 ID.AddInteger(S->getIdentKind());
Douglas Gregor5c193b92009-07-28 00:33:38 +00001033}
1034
Chandler Carruth631abd92011-06-16 06:47:06 +00001035void StmtProfiler::VisitIntegerLiteral(const IntegerLiteral *S) {
Douglas Gregor5c193b92009-07-28 00:33:38 +00001036 VisitExpr(S);
1037 S->getValue().Profile(ID);
Richard Smithe9f130c2014-11-20 03:37:32 +00001038 ID.AddInteger(S->getType()->castAs<BuiltinType>()->getKind());
Douglas Gregor5c193b92009-07-28 00:33:38 +00001039}
1040
Leonard Chandb01c3a2018-06-20 17:19:40 +00001041void StmtProfiler::VisitFixedPointLiteral(const FixedPointLiteral *S) {
1042 VisitExpr(S);
1043 S->getValue().Profile(ID);
1044 ID.AddInteger(S->getType()->castAs<BuiltinType>()->getKind());
1045}
1046
Chandler Carruth631abd92011-06-16 06:47:06 +00001047void StmtProfiler::VisitCharacterLiteral(const CharacterLiteral *S) {
Douglas Gregor5c193b92009-07-28 00:33:38 +00001048 VisitExpr(S);
Douglas Gregorfb65e592011-07-27 05:40:30 +00001049 ID.AddInteger(S->getKind());
Douglas Gregor5c193b92009-07-28 00:33:38 +00001050 ID.AddInteger(S->getValue());
1051}
1052
Chandler Carruth631abd92011-06-16 06:47:06 +00001053void StmtProfiler::VisitFloatingLiteral(const FloatingLiteral *S) {
Douglas Gregor5c193b92009-07-28 00:33:38 +00001054 VisitExpr(S);
1055 S->getValue().Profile(ID);
1056 ID.AddBoolean(S->isExact());
Richard Smithe9f130c2014-11-20 03:37:32 +00001057 ID.AddInteger(S->getType()->castAs<BuiltinType>()->getKind());
Douglas Gregor5c193b92009-07-28 00:33:38 +00001058}
1059
Chandler Carruth631abd92011-06-16 06:47:06 +00001060void StmtProfiler::VisitImaginaryLiteral(const ImaginaryLiteral *S) {
Douglas Gregor5c193b92009-07-28 00:33:38 +00001061 VisitExpr(S);
1062}
1063
Chandler Carruth631abd92011-06-16 06:47:06 +00001064void StmtProfiler::VisitStringLiteral(const StringLiteral *S) {
Douglas Gregor5c193b92009-07-28 00:33:38 +00001065 VisitExpr(S);
Douglas Gregor9d0eb8f2011-11-02 17:26:05 +00001066 ID.AddString(S->getBytes());
Douglas Gregorfb65e592011-07-27 05:40:30 +00001067 ID.AddInteger(S->getKind());
Douglas Gregor5c193b92009-07-28 00:33:38 +00001068}
1069
Chandler Carruth631abd92011-06-16 06:47:06 +00001070void StmtProfiler::VisitParenExpr(const ParenExpr *S) {
Douglas Gregor5c193b92009-07-28 00:33:38 +00001071 VisitExpr(S);
1072}
1073
Chandler Carruth631abd92011-06-16 06:47:06 +00001074void StmtProfiler::VisitParenListExpr(const ParenListExpr *S) {
Nate Begeman5ec4b312009-08-10 23:49:36 +00001075 VisitExpr(S);
1076}
1077
Chandler Carruth631abd92011-06-16 06:47:06 +00001078void StmtProfiler::VisitUnaryOperator(const UnaryOperator *S) {
Douglas Gregor5c193b92009-07-28 00:33:38 +00001079 VisitExpr(S);
1080 ID.AddInteger(S->getOpcode());
1081}
1082
Chandler Carruth631abd92011-06-16 06:47:06 +00001083void StmtProfiler::VisitOffsetOfExpr(const OffsetOfExpr *S) {
Douglas Gregor882211c2010-04-28 22:16:22 +00001084 VisitType(S->getTypeSourceInfo()->getType());
1085 unsigned n = S->getNumComponents();
1086 for (unsigned i = 0; i < n; ++i) {
James Y Knight7281c352015-12-29 22:31:18 +00001087 const OffsetOfNode &ON = S->getComponent(i);
Douglas Gregor882211c2010-04-28 22:16:22 +00001088 ID.AddInteger(ON.getKind());
1089 switch (ON.getKind()) {
James Y Knight7281c352015-12-29 22:31:18 +00001090 case OffsetOfNode::Array:
Douglas Gregor882211c2010-04-28 22:16:22 +00001091 // Expressions handled below.
1092 break;
1093
James Y Knight7281c352015-12-29 22:31:18 +00001094 case OffsetOfNode::Field:
Douglas Gregor882211c2010-04-28 22:16:22 +00001095 VisitDecl(ON.getField());
1096 break;
1097
James Y Knight7281c352015-12-29 22:31:18 +00001098 case OffsetOfNode::Identifier:
Richard Trieu639d7b62017-02-22 22:22:42 +00001099 VisitIdentifierInfo(ON.getFieldName());
Douglas Gregor882211c2010-04-28 22:16:22 +00001100 break;
James Y Knight7281c352015-12-29 22:31:18 +00001101
1102 case OffsetOfNode::Base:
Douglas Gregord1702062010-04-29 00:18:15 +00001103 // These nodes are implicit, and therefore don't need profiling.
1104 break;
Douglas Gregor882211c2010-04-28 22:16:22 +00001105 }
1106 }
Richard Trieu639d7b62017-02-22 22:22:42 +00001107
Douglas Gregor882211c2010-04-28 22:16:22 +00001108 VisitExpr(S);
1109}
1110
Chandler Carruth631abd92011-06-16 06:47:06 +00001111void
1112StmtProfiler::VisitUnaryExprOrTypeTraitExpr(const UnaryExprOrTypeTraitExpr *S) {
Douglas Gregor5c193b92009-07-28 00:33:38 +00001113 VisitExpr(S);
Peter Collingbournee190dee2011-03-11 19:24:49 +00001114 ID.AddInteger(S->getKind());
Douglas Gregor5c193b92009-07-28 00:33:38 +00001115 if (S->isArgumentType())
1116 VisitType(S->getArgumentType());
1117}
1118
Chandler Carruth631abd92011-06-16 06:47:06 +00001119void StmtProfiler::VisitArraySubscriptExpr(const ArraySubscriptExpr *S) {
Douglas Gregor5c193b92009-07-28 00:33:38 +00001120 VisitExpr(S);
1121}
1122
Alexey Bataev1a3320e2015-08-25 14:24:04 +00001123void StmtProfiler::VisitOMPArraySectionExpr(const OMPArraySectionExpr *S) {
1124 VisitExpr(S);
1125}
1126
Chandler Carruth631abd92011-06-16 06:47:06 +00001127void StmtProfiler::VisitCallExpr(const CallExpr *S) {
Douglas Gregor5c193b92009-07-28 00:33:38 +00001128 VisitExpr(S);
1129}
1130
Chandler Carruth631abd92011-06-16 06:47:06 +00001131void StmtProfiler::VisitMemberExpr(const MemberExpr *S) {
Douglas Gregor5c193b92009-07-28 00:33:38 +00001132 VisitExpr(S);
1133 VisitDecl(S->getMemberDecl());
Douglas Gregorf5b160f2010-07-13 08:37:11 +00001134 if (!Canonical)
1135 VisitNestedNameSpecifier(S->getQualifier());
Douglas Gregor5c193b92009-07-28 00:33:38 +00001136 ID.AddBoolean(S->isArrow());
1137}
1138
Chandler Carruth631abd92011-06-16 06:47:06 +00001139void StmtProfiler::VisitCompoundLiteralExpr(const CompoundLiteralExpr *S) {
Douglas Gregor5c193b92009-07-28 00:33:38 +00001140 VisitExpr(S);
1141 ID.AddBoolean(S->isFileScope());
1142}
1143
Chandler Carruth631abd92011-06-16 06:47:06 +00001144void StmtProfiler::VisitCastExpr(const CastExpr *S) {
Douglas Gregor5c193b92009-07-28 00:33:38 +00001145 VisitExpr(S);
1146}
1147
Chandler Carruth631abd92011-06-16 06:47:06 +00001148void StmtProfiler::VisitImplicitCastExpr(const ImplicitCastExpr *S) {
Douglas Gregor5c193b92009-07-28 00:33:38 +00001149 VisitCastExpr(S);
John McCall2536c6d2010-08-25 10:28:54 +00001150 ID.AddInteger(S->getValueKind());
Douglas Gregor5c193b92009-07-28 00:33:38 +00001151}
1152
Chandler Carruth631abd92011-06-16 06:47:06 +00001153void StmtProfiler::VisitExplicitCastExpr(const ExplicitCastExpr *S) {
Douglas Gregor5c193b92009-07-28 00:33:38 +00001154 VisitCastExpr(S);
1155 VisitType(S->getTypeAsWritten());
1156}
1157
Chandler Carruth631abd92011-06-16 06:47:06 +00001158void StmtProfiler::VisitCStyleCastExpr(const CStyleCastExpr *S) {
Douglas Gregor5c193b92009-07-28 00:33:38 +00001159 VisitExplicitCastExpr(S);
1160}
1161
Chandler Carruth631abd92011-06-16 06:47:06 +00001162void StmtProfiler::VisitBinaryOperator(const BinaryOperator *S) {
Douglas Gregor5c193b92009-07-28 00:33:38 +00001163 VisitExpr(S);
1164 ID.AddInteger(S->getOpcode());
1165}
1166
Chandler Carruth631abd92011-06-16 06:47:06 +00001167void
1168StmtProfiler::VisitCompoundAssignOperator(const CompoundAssignOperator *S) {
Douglas Gregor5c193b92009-07-28 00:33:38 +00001169 VisitBinaryOperator(S);
1170}
1171
Chandler Carruth631abd92011-06-16 06:47:06 +00001172void StmtProfiler::VisitConditionalOperator(const ConditionalOperator *S) {
Douglas Gregor5c193b92009-07-28 00:33:38 +00001173 VisitExpr(S);
1174}
1175
Chandler Carruth631abd92011-06-16 06:47:06 +00001176void StmtProfiler::VisitBinaryConditionalOperator(
Chandler Carruthcf5f43c2011-06-21 23:26:32 +00001177 const BinaryConditionalOperator *S) {
John McCallc07a0c72011-02-17 10:25:35 +00001178 VisitExpr(S);
1179}
1180
Chandler Carruth631abd92011-06-16 06:47:06 +00001181void StmtProfiler::VisitAddrLabelExpr(const AddrLabelExpr *S) {
Douglas Gregor5c193b92009-07-28 00:33:38 +00001182 VisitExpr(S);
Chris Lattnerc8e630e2011-02-17 07:39:24 +00001183 VisitDecl(S->getLabel());
Douglas Gregor5c193b92009-07-28 00:33:38 +00001184}
1185
Chandler Carruth631abd92011-06-16 06:47:06 +00001186void StmtProfiler::VisitStmtExpr(const StmtExpr *S) {
Douglas Gregor5c193b92009-07-28 00:33:38 +00001187 VisitExpr(S);
1188}
1189
Chandler Carruth631abd92011-06-16 06:47:06 +00001190void StmtProfiler::VisitShuffleVectorExpr(const ShuffleVectorExpr *S) {
Douglas Gregor5c193b92009-07-28 00:33:38 +00001191 VisitExpr(S);
1192}
1193
Hal Finkelc4d7c822013-09-18 03:29:45 +00001194void StmtProfiler::VisitConvertVectorExpr(const ConvertVectorExpr *S) {
1195 VisitExpr(S);
1196}
1197
Chandler Carruth631abd92011-06-16 06:47:06 +00001198void StmtProfiler::VisitChooseExpr(const ChooseExpr *S) {
Douglas Gregor5c193b92009-07-28 00:33:38 +00001199 VisitExpr(S);
1200}
1201
Chandler Carruth631abd92011-06-16 06:47:06 +00001202void StmtProfiler::VisitGNUNullExpr(const GNUNullExpr *S) {
Douglas Gregor5c193b92009-07-28 00:33:38 +00001203 VisitExpr(S);
1204}
1205
Chandler Carruth631abd92011-06-16 06:47:06 +00001206void StmtProfiler::VisitVAArgExpr(const VAArgExpr *S) {
Douglas Gregor00044172009-07-29 16:09:57 +00001207 VisitExpr(S);
1208}
1209
Chandler Carruth631abd92011-06-16 06:47:06 +00001210void StmtProfiler::VisitInitListExpr(const InitListExpr *S) {
Douglas Gregor5c193b92009-07-28 00:33:38 +00001211 if (S->getSyntacticForm()) {
1212 VisitInitListExpr(S->getSyntacticForm());
1213 return;
1214 }
Mike Stump11289f42009-09-09 15:08:12 +00001215
Douglas Gregor5c193b92009-07-28 00:33:38 +00001216 VisitExpr(S);
1217}
1218
Chandler Carruth631abd92011-06-16 06:47:06 +00001219void StmtProfiler::VisitDesignatedInitExpr(const DesignatedInitExpr *S) {
Douglas Gregor5c193b92009-07-28 00:33:38 +00001220 VisitExpr(S);
1221 ID.AddBoolean(S->usesGNUSyntax());
David Majnemerf7e36092016-06-23 00:15:04 +00001222 for (const DesignatedInitExpr::Designator &D : S->designators()) {
1223 if (D.isFieldDesignator()) {
Douglas Gregor5c193b92009-07-28 00:33:38 +00001224 ID.AddInteger(0);
David Majnemerf7e36092016-06-23 00:15:04 +00001225 VisitName(D.getFieldName());
Douglas Gregor5c193b92009-07-28 00:33:38 +00001226 continue;
1227 }
Mike Stump11289f42009-09-09 15:08:12 +00001228
David Majnemerf7e36092016-06-23 00:15:04 +00001229 if (D.isArrayDesignator()) {
Douglas Gregor5c193b92009-07-28 00:33:38 +00001230 ID.AddInteger(1);
1231 } else {
David Majnemerf7e36092016-06-23 00:15:04 +00001232 assert(D.isArrayRangeDesignator());
Douglas Gregor5c193b92009-07-28 00:33:38 +00001233 ID.AddInteger(2);
1234 }
David Majnemerf7e36092016-06-23 00:15:04 +00001235 ID.AddInteger(D.getFirstExprIndex());
Douglas Gregor5c193b92009-07-28 00:33:38 +00001236 }
1237}
1238
Yunzhong Gaocb779302015-06-10 00:27:52 +00001239// Seems that if VisitInitListExpr() only works on the syntactic form of an
1240// InitListExpr, then a DesignatedInitUpdateExpr is not encountered.
1241void StmtProfiler::VisitDesignatedInitUpdateExpr(
1242 const DesignatedInitUpdateExpr *S) {
1243 llvm_unreachable("Unexpected DesignatedInitUpdateExpr in syntactic form of "
1244 "initializer");
1245}
1246
Richard Smith410306b2016-12-12 02:53:20 +00001247void StmtProfiler::VisitArrayInitLoopExpr(const ArrayInitLoopExpr *S) {
1248 VisitExpr(S);
1249}
1250
1251void StmtProfiler::VisitArrayInitIndexExpr(const ArrayInitIndexExpr *S) {
1252 VisitExpr(S);
1253}
1254
Yunzhong Gaocb779302015-06-10 00:27:52 +00001255void StmtProfiler::VisitNoInitExpr(const NoInitExpr *S) {
1256 llvm_unreachable("Unexpected NoInitExpr in syntactic form of initializer");
1257}
1258
Chandler Carruth631abd92011-06-16 06:47:06 +00001259void StmtProfiler::VisitImplicitValueInitExpr(const ImplicitValueInitExpr *S) {
Douglas Gregor5c193b92009-07-28 00:33:38 +00001260 VisitExpr(S);
1261}
1262
Chandler Carruth631abd92011-06-16 06:47:06 +00001263void StmtProfiler::VisitExtVectorElementExpr(const ExtVectorElementExpr *S) {
Douglas Gregor5c193b92009-07-28 00:33:38 +00001264 VisitExpr(S);
1265 VisitName(&S->getAccessor());
1266}
1267
Chandler Carruth631abd92011-06-16 06:47:06 +00001268void StmtProfiler::VisitBlockExpr(const BlockExpr *S) {
Douglas Gregor5c193b92009-07-28 00:33:38 +00001269 VisitExpr(S);
1270 VisitDecl(S->getBlockDecl());
1271}
1272
Chandler Carruth631abd92011-06-16 06:47:06 +00001273void StmtProfiler::VisitGenericSelectionExpr(const GenericSelectionExpr *S) {
Peter Collingbourne91147592011-04-15 00:35:48 +00001274 VisitExpr(S);
Bruno Ricci1ec7fd32019-01-29 12:57:11 +00001275 for (const GenericSelectionExpr::ConstAssociation &Assoc :
1276 S->associations()) {
1277 QualType T = Assoc.getType();
Peter Collingbourne91147592011-04-15 00:35:48 +00001278 if (T.isNull())
Craig Topper36250ad2014-05-12 05:36:57 +00001279 ID.AddPointer(nullptr);
Peter Collingbourne91147592011-04-15 00:35:48 +00001280 else
1281 VisitType(T);
Bruno Ricci1ec7fd32019-01-29 12:57:11 +00001282 VisitExpr(Assoc.getAssociationExpr());
Peter Collingbourne91147592011-04-15 00:35:48 +00001283 }
1284}
1285
John McCallfe96e0b2011-11-06 09:01:30 +00001286void StmtProfiler::VisitPseudoObjectExpr(const PseudoObjectExpr *S) {
1287 VisitExpr(S);
1288 for (PseudoObjectExpr::const_semantics_iterator
1289 i = S->semantics_begin(), e = S->semantics_end(); i != e; ++i)
1290 // Normally, we would not profile the source expressions of OVEs.
1291 if (const OpaqueValueExpr *OVE = dyn_cast<OpaqueValueExpr>(*i))
1292 Visit(OVE->getSourceExpr());
1293}
1294
Eli Friedmandf14b3a2011-10-11 02:20:01 +00001295void StmtProfiler::VisitAtomicExpr(const AtomicExpr *S) {
1296 VisitExpr(S);
Eli Friedman4b72fdd2011-10-14 20:59:01 +00001297 ID.AddInteger(S->getOp());
Eli Friedmandf14b3a2011-10-11 02:20:01 +00001298}
1299
Chandler Carruth631abd92011-06-16 06:47:06 +00001300static Stmt::StmtClass DecodeOperatorCall(const CXXOperatorCallExpr *S,
John McCalle3027922010-08-25 11:45:40 +00001301 UnaryOperatorKind &UnaryOp,
1302 BinaryOperatorKind &BinaryOp) {
Douglas Gregore9ceb312010-05-19 04:13:23 +00001303 switch (S->getOperator()) {
1304 case OO_None:
1305 case OO_New:
1306 case OO_Delete:
1307 case OO_Array_New:
1308 case OO_Array_Delete:
1309 case OO_Arrow:
1310 case OO_Call:
1311 case OO_Conditional:
1312 case NUM_OVERLOADED_OPERATORS:
1313 llvm_unreachable("Invalid operator call kind");
Fangrui Song6907ce22018-07-30 19:24:48 +00001314
Douglas Gregore9ceb312010-05-19 04:13:23 +00001315 case OO_Plus:
1316 if (S->getNumArgs() == 1) {
John McCalle3027922010-08-25 11:45:40 +00001317 UnaryOp = UO_Plus;
Douglas Gregore9ceb312010-05-19 04:13:23 +00001318 return Stmt::UnaryOperatorClass;
1319 }
Fangrui Song6907ce22018-07-30 19:24:48 +00001320
John McCalle3027922010-08-25 11:45:40 +00001321 BinaryOp = BO_Add;
Douglas Gregore9ceb312010-05-19 04:13:23 +00001322 return Stmt::BinaryOperatorClass;
Fangrui Song6907ce22018-07-30 19:24:48 +00001323
Douglas Gregore9ceb312010-05-19 04:13:23 +00001324 case OO_Minus:
1325 if (S->getNumArgs() == 1) {
John McCalle3027922010-08-25 11:45:40 +00001326 UnaryOp = UO_Minus;
Douglas Gregore9ceb312010-05-19 04:13:23 +00001327 return Stmt::UnaryOperatorClass;
1328 }
Fangrui Song6907ce22018-07-30 19:24:48 +00001329
John McCalle3027922010-08-25 11:45:40 +00001330 BinaryOp = BO_Sub;
Douglas Gregore9ceb312010-05-19 04:13:23 +00001331 return Stmt::BinaryOperatorClass;
1332
1333 case OO_Star:
1334 if (S->getNumArgs() == 1) {
Richard Smithf15acc52014-06-05 22:43:40 +00001335 UnaryOp = UO_Deref;
Douglas Gregore9ceb312010-05-19 04:13:23 +00001336 return Stmt::UnaryOperatorClass;
1337 }
Fangrui Song6907ce22018-07-30 19:24:48 +00001338
Richard Smithf15acc52014-06-05 22:43:40 +00001339 BinaryOp = BO_Mul;
Douglas Gregore9ceb312010-05-19 04:13:23 +00001340 return Stmt::BinaryOperatorClass;
1341
1342 case OO_Slash:
John McCalle3027922010-08-25 11:45:40 +00001343 BinaryOp = BO_Div;
Douglas Gregore9ceb312010-05-19 04:13:23 +00001344 return Stmt::BinaryOperatorClass;
Fangrui Song6907ce22018-07-30 19:24:48 +00001345
Douglas Gregore9ceb312010-05-19 04:13:23 +00001346 case OO_Percent:
John McCalle3027922010-08-25 11:45:40 +00001347 BinaryOp = BO_Rem;
Douglas Gregore9ceb312010-05-19 04:13:23 +00001348 return Stmt::BinaryOperatorClass;
1349
1350 case OO_Caret:
John McCalle3027922010-08-25 11:45:40 +00001351 BinaryOp = BO_Xor;
Douglas Gregore9ceb312010-05-19 04:13:23 +00001352 return Stmt::BinaryOperatorClass;
1353
1354 case OO_Amp:
1355 if (S->getNumArgs() == 1) {
John McCalle3027922010-08-25 11:45:40 +00001356 UnaryOp = UO_AddrOf;
Douglas Gregore9ceb312010-05-19 04:13:23 +00001357 return Stmt::UnaryOperatorClass;
1358 }
Fangrui Song6907ce22018-07-30 19:24:48 +00001359
John McCalle3027922010-08-25 11:45:40 +00001360 BinaryOp = BO_And;
Douglas Gregore9ceb312010-05-19 04:13:23 +00001361 return Stmt::BinaryOperatorClass;
Fangrui Song6907ce22018-07-30 19:24:48 +00001362
Douglas Gregore9ceb312010-05-19 04:13:23 +00001363 case OO_Pipe:
John McCalle3027922010-08-25 11:45:40 +00001364 BinaryOp = BO_Or;
Douglas Gregore9ceb312010-05-19 04:13:23 +00001365 return Stmt::BinaryOperatorClass;
1366
1367 case OO_Tilde:
John McCalle3027922010-08-25 11:45:40 +00001368 UnaryOp = UO_Not;
Douglas Gregore9ceb312010-05-19 04:13:23 +00001369 return Stmt::UnaryOperatorClass;
1370
1371 case OO_Exclaim:
John McCalle3027922010-08-25 11:45:40 +00001372 UnaryOp = UO_LNot;
Douglas Gregore9ceb312010-05-19 04:13:23 +00001373 return Stmt::UnaryOperatorClass;
1374
1375 case OO_Equal:
John McCalle3027922010-08-25 11:45:40 +00001376 BinaryOp = BO_Assign;
Douglas Gregore9ceb312010-05-19 04:13:23 +00001377 return Stmt::BinaryOperatorClass;
1378
1379 case OO_Less:
John McCalle3027922010-08-25 11:45:40 +00001380 BinaryOp = BO_LT;
Douglas Gregore9ceb312010-05-19 04:13:23 +00001381 return Stmt::BinaryOperatorClass;
1382
1383 case OO_Greater:
John McCalle3027922010-08-25 11:45:40 +00001384 BinaryOp = BO_GT;
Douglas Gregore9ceb312010-05-19 04:13:23 +00001385 return Stmt::BinaryOperatorClass;
Fangrui Song6907ce22018-07-30 19:24:48 +00001386
Douglas Gregore9ceb312010-05-19 04:13:23 +00001387 case OO_PlusEqual:
John McCalle3027922010-08-25 11:45:40 +00001388 BinaryOp = BO_AddAssign;
Douglas Gregore9ceb312010-05-19 04:13:23 +00001389 return Stmt::CompoundAssignOperatorClass;
1390
1391 case OO_MinusEqual:
John McCalle3027922010-08-25 11:45:40 +00001392 BinaryOp = BO_SubAssign;
Douglas Gregore9ceb312010-05-19 04:13:23 +00001393 return Stmt::CompoundAssignOperatorClass;
1394
1395 case OO_StarEqual:
John McCalle3027922010-08-25 11:45:40 +00001396 BinaryOp = BO_MulAssign;
Douglas Gregore9ceb312010-05-19 04:13:23 +00001397 return Stmt::CompoundAssignOperatorClass;
1398
1399 case OO_SlashEqual:
John McCalle3027922010-08-25 11:45:40 +00001400 BinaryOp = BO_DivAssign;
Douglas Gregore9ceb312010-05-19 04:13:23 +00001401 return Stmt::CompoundAssignOperatorClass;
1402
1403 case OO_PercentEqual:
John McCalle3027922010-08-25 11:45:40 +00001404 BinaryOp = BO_RemAssign;
Douglas Gregore9ceb312010-05-19 04:13:23 +00001405 return Stmt::CompoundAssignOperatorClass;
1406
1407 case OO_CaretEqual:
John McCalle3027922010-08-25 11:45:40 +00001408 BinaryOp = BO_XorAssign;
Douglas Gregore9ceb312010-05-19 04:13:23 +00001409 return Stmt::CompoundAssignOperatorClass;
Fangrui Song6907ce22018-07-30 19:24:48 +00001410
Douglas Gregore9ceb312010-05-19 04:13:23 +00001411 case OO_AmpEqual:
John McCalle3027922010-08-25 11:45:40 +00001412 BinaryOp = BO_AndAssign;
Douglas Gregore9ceb312010-05-19 04:13:23 +00001413 return Stmt::CompoundAssignOperatorClass;
Fangrui Song6907ce22018-07-30 19:24:48 +00001414
Douglas Gregore9ceb312010-05-19 04:13:23 +00001415 case OO_PipeEqual:
John McCalle3027922010-08-25 11:45:40 +00001416 BinaryOp = BO_OrAssign;
Douglas Gregore9ceb312010-05-19 04:13:23 +00001417 return Stmt::CompoundAssignOperatorClass;
Fangrui Song6907ce22018-07-30 19:24:48 +00001418
Douglas Gregore9ceb312010-05-19 04:13:23 +00001419 case OO_LessLess:
John McCalle3027922010-08-25 11:45:40 +00001420 BinaryOp = BO_Shl;
Douglas Gregore9ceb312010-05-19 04:13:23 +00001421 return Stmt::BinaryOperatorClass;
Fangrui Song6907ce22018-07-30 19:24:48 +00001422
Douglas Gregore9ceb312010-05-19 04:13:23 +00001423 case OO_GreaterGreater:
John McCalle3027922010-08-25 11:45:40 +00001424 BinaryOp = BO_Shr;
Douglas Gregore9ceb312010-05-19 04:13:23 +00001425 return Stmt::BinaryOperatorClass;
1426
1427 case OO_LessLessEqual:
John McCalle3027922010-08-25 11:45:40 +00001428 BinaryOp = BO_ShlAssign;
Douglas Gregore9ceb312010-05-19 04:13:23 +00001429 return Stmt::CompoundAssignOperatorClass;
Fangrui Song6907ce22018-07-30 19:24:48 +00001430
Douglas Gregore9ceb312010-05-19 04:13:23 +00001431 case OO_GreaterGreaterEqual:
John McCalle3027922010-08-25 11:45:40 +00001432 BinaryOp = BO_ShrAssign;
Douglas Gregore9ceb312010-05-19 04:13:23 +00001433 return Stmt::CompoundAssignOperatorClass;
1434
1435 case OO_EqualEqual:
John McCalle3027922010-08-25 11:45:40 +00001436 BinaryOp = BO_EQ;
Douglas Gregore9ceb312010-05-19 04:13:23 +00001437 return Stmt::BinaryOperatorClass;
Fangrui Song6907ce22018-07-30 19:24:48 +00001438
Douglas Gregore9ceb312010-05-19 04:13:23 +00001439 case OO_ExclaimEqual:
John McCalle3027922010-08-25 11:45:40 +00001440 BinaryOp = BO_NE;
Douglas Gregore9ceb312010-05-19 04:13:23 +00001441 return Stmt::BinaryOperatorClass;
Fangrui Song6907ce22018-07-30 19:24:48 +00001442
Douglas Gregore9ceb312010-05-19 04:13:23 +00001443 case OO_LessEqual:
John McCalle3027922010-08-25 11:45:40 +00001444 BinaryOp = BO_LE;
Douglas Gregore9ceb312010-05-19 04:13:23 +00001445 return Stmt::BinaryOperatorClass;
Fangrui Song6907ce22018-07-30 19:24:48 +00001446
Douglas Gregore9ceb312010-05-19 04:13:23 +00001447 case OO_GreaterEqual:
John McCalle3027922010-08-25 11:45:40 +00001448 BinaryOp = BO_GE;
Douglas Gregore9ceb312010-05-19 04:13:23 +00001449 return Stmt::BinaryOperatorClass;
Richard Smithd30b23d2017-12-01 02:13:10 +00001450
1451 case OO_Spaceship:
1452 // FIXME: Update this once we support <=> expressions.
1453 llvm_unreachable("<=> expressions not supported yet");
Fangrui Song6907ce22018-07-30 19:24:48 +00001454
Douglas Gregore9ceb312010-05-19 04:13:23 +00001455 case OO_AmpAmp:
John McCalle3027922010-08-25 11:45:40 +00001456 BinaryOp = BO_LAnd;
Douglas Gregore9ceb312010-05-19 04:13:23 +00001457 return Stmt::BinaryOperatorClass;
Fangrui Song6907ce22018-07-30 19:24:48 +00001458
Douglas Gregore9ceb312010-05-19 04:13:23 +00001459 case OO_PipePipe:
John McCalle3027922010-08-25 11:45:40 +00001460 BinaryOp = BO_LOr;
Douglas Gregore9ceb312010-05-19 04:13:23 +00001461 return Stmt::BinaryOperatorClass;
1462
1463 case OO_PlusPlus:
Fangrui Song6907ce22018-07-30 19:24:48 +00001464 UnaryOp = S->getNumArgs() == 1? UO_PreInc
John McCalle3027922010-08-25 11:45:40 +00001465 : UO_PostInc;
Douglas Gregore9ceb312010-05-19 04:13:23 +00001466 return Stmt::UnaryOperatorClass;
1467
1468 case OO_MinusMinus:
John McCalle3027922010-08-25 11:45:40 +00001469 UnaryOp = S->getNumArgs() == 1? UO_PreDec
1470 : UO_PostDec;
Douglas Gregore9ceb312010-05-19 04:13:23 +00001471 return Stmt::UnaryOperatorClass;
1472
1473 case OO_Comma:
John McCalle3027922010-08-25 11:45:40 +00001474 BinaryOp = BO_Comma;
Douglas Gregore9ceb312010-05-19 04:13:23 +00001475 return Stmt::BinaryOperatorClass;
1476
Douglas Gregore9ceb312010-05-19 04:13:23 +00001477 case OO_ArrowStar:
John McCalle3027922010-08-25 11:45:40 +00001478 BinaryOp = BO_PtrMemI;
Douglas Gregore9ceb312010-05-19 04:13:23 +00001479 return Stmt::BinaryOperatorClass;
Fangrui Song6907ce22018-07-30 19:24:48 +00001480
Douglas Gregore9ceb312010-05-19 04:13:23 +00001481 case OO_Subscript:
1482 return Stmt::ArraySubscriptExprClass;
Richard Smith6fff5c42018-07-31 00:47:41 +00001483
1484 case OO_Coawait:
1485 UnaryOp = UO_Coawait;
1486 return Stmt::UnaryOperatorClass;
Douglas Gregore9ceb312010-05-19 04:13:23 +00001487 }
Fangrui Song6907ce22018-07-30 19:24:48 +00001488
Douglas Gregore9ceb312010-05-19 04:13:23 +00001489 llvm_unreachable("Invalid overloaded operator expression");
1490}
Richard Smithf15acc52014-06-05 22:43:40 +00001491
Reid Klecknere257e182017-10-13 16:18:32 +00001492#if defined(_MSC_VER) && !defined(__clang__)
Nico Weberf56f4462017-07-24 16:54:11 +00001493#if _MSC_VER == 1911
1494// Work around https://developercommunity.visualstudio.com/content/problem/84002/clang-cl-when-built-with-vc-2017-crashes-cause-vc.html
1495// MSVC 2017 update 3 miscompiles this function, and a clang built with it
1496// will crash in stage 2 of a bootstrap build.
1497#pragma optimize("", off)
1498#endif
1499#endif
1500
Chandler Carruth631abd92011-06-16 06:47:06 +00001501void StmtProfiler::VisitCXXOperatorCallExpr(const CXXOperatorCallExpr *S) {
Douglas Gregore9ceb312010-05-19 04:13:23 +00001502 if (S->isTypeDependent()) {
1503 // Type-dependent operator calls are profiled like their underlying
1504 // syntactic operator.
Richard Smithbac0a0d2016-10-24 18:47:04 +00001505 //
1506 // An operator call to operator-> is always implicit, so just skip it. The
1507 // enclosing MemberExpr will profile the actual member access.
1508 if (S->getOperator() == OO_Arrow)
1509 return Visit(S->getArg(0));
1510
John McCalle3027922010-08-25 11:45:40 +00001511 UnaryOperatorKind UnaryOp = UO_Extension;
1512 BinaryOperatorKind BinaryOp = BO_Comma;
Douglas Gregore9ceb312010-05-19 04:13:23 +00001513 Stmt::StmtClass SC = DecodeOperatorCall(S, UnaryOp, BinaryOp);
Richard Smithf15acc52014-06-05 22:43:40 +00001514
Douglas Gregore9ceb312010-05-19 04:13:23 +00001515 ID.AddInteger(SC);
1516 for (unsigned I = 0, N = S->getNumArgs(); I != N; ++I)
1517 Visit(S->getArg(I));
1518 if (SC == Stmt::UnaryOperatorClass)
1519 ID.AddInteger(UnaryOp);
Fangrui Song6907ce22018-07-30 19:24:48 +00001520 else if (SC == Stmt::BinaryOperatorClass ||
Douglas Gregore9ceb312010-05-19 04:13:23 +00001521 SC == Stmt::CompoundAssignOperatorClass)
1522 ID.AddInteger(BinaryOp);
1523 else
1524 assert(SC == Stmt::ArraySubscriptExprClass);
Richard Smithf15acc52014-06-05 22:43:40 +00001525
Douglas Gregore9ceb312010-05-19 04:13:23 +00001526 return;
1527 }
Richard Smithf15acc52014-06-05 22:43:40 +00001528
Douglas Gregor5c193b92009-07-28 00:33:38 +00001529 VisitCallExpr(S);
1530 ID.AddInteger(S->getOperator());
1531}
1532
Reid Klecknere257e182017-10-13 16:18:32 +00001533#if defined(_MSC_VER) && !defined(__clang__)
Nico Weberf56f4462017-07-24 16:54:11 +00001534#if _MSC_VER == 1911
1535#pragma optimize("", on)
1536#endif
1537#endif
1538
Chandler Carruth631abd92011-06-16 06:47:06 +00001539void StmtProfiler::VisitCXXMemberCallExpr(const CXXMemberCallExpr *S) {
Douglas Gregor5c193b92009-07-28 00:33:38 +00001540 VisitCallExpr(S);
1541}
1542
Chandler Carruth631abd92011-06-16 06:47:06 +00001543void StmtProfiler::VisitCUDAKernelCallExpr(const CUDAKernelCallExpr *S) {
Peter Collingbourne41f85462011-02-09 21:07:24 +00001544 VisitCallExpr(S);
1545}
1546
Chandler Carruth631abd92011-06-16 06:47:06 +00001547void StmtProfiler::VisitAsTypeExpr(const AsTypeExpr *S) {
Tanya Lattner55808c12011-06-04 00:47:47 +00001548 VisitExpr(S);
1549}
1550
Chandler Carruth631abd92011-06-16 06:47:06 +00001551void StmtProfiler::VisitCXXNamedCastExpr(const CXXNamedCastExpr *S) {
Douglas Gregor5c193b92009-07-28 00:33:38 +00001552 VisitExplicitCastExpr(S);
1553}
1554
Chandler Carruth631abd92011-06-16 06:47:06 +00001555void StmtProfiler::VisitCXXStaticCastExpr(const CXXStaticCastExpr *S) {
Douglas Gregor5c193b92009-07-28 00:33:38 +00001556 VisitCXXNamedCastExpr(S);
1557}
1558
Chandler Carruth631abd92011-06-16 06:47:06 +00001559void StmtProfiler::VisitCXXDynamicCastExpr(const CXXDynamicCastExpr *S) {
Douglas Gregor5c193b92009-07-28 00:33:38 +00001560 VisitCXXNamedCastExpr(S);
1561}
1562
Chandler Carruth631abd92011-06-16 06:47:06 +00001563void
1564StmtProfiler::VisitCXXReinterpretCastExpr(const CXXReinterpretCastExpr *S) {
Douglas Gregor5c193b92009-07-28 00:33:38 +00001565 VisitCXXNamedCastExpr(S);
1566}
1567
Chandler Carruth631abd92011-06-16 06:47:06 +00001568void StmtProfiler::VisitCXXConstCastExpr(const CXXConstCastExpr *S) {
Douglas Gregor5c193b92009-07-28 00:33:38 +00001569 VisitCXXNamedCastExpr(S);
1570}
1571
Erik Pilkingtoneee944e2019-07-02 18:28:13 +00001572void StmtProfiler::VisitBuiltinBitCastExpr(const BuiltinBitCastExpr *S) {
1573 VisitExpr(S);
1574 VisitType(S->getTypeInfoAsWritten()->getType());
1575}
1576
Richard Smithc67fdd42012-03-07 08:35:16 +00001577void StmtProfiler::VisitUserDefinedLiteral(const UserDefinedLiteral *S) {
1578 VisitCallExpr(S);
1579}
1580
Chandler Carruth631abd92011-06-16 06:47:06 +00001581void StmtProfiler::VisitCXXBoolLiteralExpr(const CXXBoolLiteralExpr *S) {
Douglas Gregor5c193b92009-07-28 00:33:38 +00001582 VisitExpr(S);
1583 ID.AddBoolean(S->getValue());
1584}
1585
Chandler Carruth631abd92011-06-16 06:47:06 +00001586void StmtProfiler::VisitCXXNullPtrLiteralExpr(const CXXNullPtrLiteralExpr *S) {
Douglas Gregor00044172009-07-29 16:09:57 +00001587 VisitExpr(S);
1588}
1589
Richard Smithcc1b96d2013-06-12 22:31:48 +00001590void StmtProfiler::VisitCXXStdInitializerListExpr(
1591 const CXXStdInitializerListExpr *S) {
1592 VisitExpr(S);
1593}
1594
Chandler Carruth631abd92011-06-16 06:47:06 +00001595void StmtProfiler::VisitCXXTypeidExpr(const CXXTypeidExpr *S) {
Douglas Gregor5c193b92009-07-28 00:33:38 +00001596 VisitExpr(S);
1597 if (S->isTypeOperand())
David Majnemer143c55e2013-09-27 07:04:31 +00001598 VisitType(S->getTypeOperandSourceInfo()->getType());
Douglas Gregor5c193b92009-07-28 00:33:38 +00001599}
1600
Chandler Carruth631abd92011-06-16 06:47:06 +00001601void StmtProfiler::VisitCXXUuidofExpr(const CXXUuidofExpr *S) {
Francois Pichet9f4f2072010-09-08 12:20:18 +00001602 VisitExpr(S);
1603 if (S->isTypeOperand())
David Majnemer143c55e2013-09-27 07:04:31 +00001604 VisitType(S->getTypeOperandSourceInfo()->getType());
Francois Pichet9f4f2072010-09-08 12:20:18 +00001605}
1606
John McCall5e77d762013-04-16 07:28:30 +00001607void StmtProfiler::VisitMSPropertyRefExpr(const MSPropertyRefExpr *S) {
1608 VisitExpr(S);
1609 VisitDecl(S->getPropertyDecl());
1610}
1611
Alexey Bataevf7630272015-11-25 12:01:00 +00001612void StmtProfiler::VisitMSPropertySubscriptExpr(
1613 const MSPropertySubscriptExpr *S) {
1614 VisitExpr(S);
1615}
1616
Chandler Carruth631abd92011-06-16 06:47:06 +00001617void StmtProfiler::VisitCXXThisExpr(const CXXThisExpr *S) {
Douglas Gregor5c193b92009-07-28 00:33:38 +00001618 VisitExpr(S);
Douglas Gregor3024f072012-04-16 07:05:22 +00001619 ID.AddBoolean(S->isImplicit());
Douglas Gregor5c193b92009-07-28 00:33:38 +00001620}
1621
Chandler Carruth631abd92011-06-16 06:47:06 +00001622void StmtProfiler::VisitCXXThrowExpr(const CXXThrowExpr *S) {
Douglas Gregor5c193b92009-07-28 00:33:38 +00001623 VisitExpr(S);
1624}
1625
Chandler Carruth631abd92011-06-16 06:47:06 +00001626void StmtProfiler::VisitCXXDefaultArgExpr(const CXXDefaultArgExpr *S) {
Douglas Gregor5c193b92009-07-28 00:33:38 +00001627 VisitExpr(S);
1628 VisitDecl(S->getParam());
1629}
1630
Richard Smith852c9db2013-04-20 22:23:05 +00001631void StmtProfiler::VisitCXXDefaultInitExpr(const CXXDefaultInitExpr *S) {
1632 VisitExpr(S);
1633 VisitDecl(S->getField());
1634}
1635
Chandler Carruth631abd92011-06-16 06:47:06 +00001636void StmtProfiler::VisitCXXBindTemporaryExpr(const CXXBindTemporaryExpr *S) {
Douglas Gregor5c193b92009-07-28 00:33:38 +00001637 VisitExpr(S);
1638 VisitDecl(
1639 const_cast<CXXDestructorDecl *>(S->getTemporary()->getDestructor()));
1640}
1641
Chandler Carruth631abd92011-06-16 06:47:06 +00001642void StmtProfiler::VisitCXXConstructExpr(const CXXConstructExpr *S) {
Douglas Gregor5c193b92009-07-28 00:33:38 +00001643 VisitExpr(S);
1644 VisitDecl(S->getConstructor());
1645 ID.AddBoolean(S->isElidable());
1646}
1647
Richard Smith5179eb72016-06-28 19:03:57 +00001648void StmtProfiler::VisitCXXInheritedCtorInitExpr(
1649 const CXXInheritedCtorInitExpr *S) {
1650 VisitExpr(S);
1651 VisitDecl(S->getConstructor());
1652}
1653
Chandler Carruth631abd92011-06-16 06:47:06 +00001654void StmtProfiler::VisitCXXFunctionalCastExpr(const CXXFunctionalCastExpr *S) {
Douglas Gregor5c193b92009-07-28 00:33:38 +00001655 VisitExplicitCastExpr(S);
1656}
1657
Chandler Carruth631abd92011-06-16 06:47:06 +00001658void
1659StmtProfiler::VisitCXXTemporaryObjectExpr(const CXXTemporaryObjectExpr *S) {
Douglas Gregor5c193b92009-07-28 00:33:38 +00001660 VisitCXXConstructExpr(S);
1661}
1662
Chandler Carruth631abd92011-06-16 06:47:06 +00001663void
Douglas Gregore31e6062012-02-07 10:09:13 +00001664StmtProfiler::VisitLambdaExpr(const LambdaExpr *S) {
1665 VisitExpr(S);
1666 for (LambdaExpr::capture_iterator C = S->explicit_capture_begin(),
1667 CEnd = S->explicit_capture_end();
1668 C != CEnd; ++C) {
Richard Trieu931638e2017-11-11 00:54:25 +00001669 if (C->capturesVLAType())
1670 continue;
1671
Douglas Gregore31e6062012-02-07 10:09:13 +00001672 ID.AddInteger(C->getCaptureKind());
Richard Smithba71c082013-05-16 06:20:58 +00001673 switch (C->getCaptureKind()) {
Faisal Validc6b5962016-03-21 09:25:37 +00001674 case LCK_StarThis:
Richard Smithba71c082013-05-16 06:20:58 +00001675 case LCK_This:
1676 break;
1677 case LCK_ByRef:
1678 case LCK_ByCopy:
Douglas Gregore31e6062012-02-07 10:09:13 +00001679 VisitDecl(C->getCapturedVar());
1680 ID.AddBoolean(C->isPackExpansion());
Richard Smithba71c082013-05-16 06:20:58 +00001681 break;
Alexey Bataev39c81e22014-08-28 04:28:19 +00001682 case LCK_VLAType:
1683 llvm_unreachable("VLA type in explicit captures.");
Douglas Gregore31e6062012-02-07 10:09:13 +00001684 }
1685 }
1686 // Note: If we actually needed to be able to match lambda
1687 // expressions, we would have to consider parameters and return type
1688 // here, among other things.
1689 VisitStmt(S->getBody());
1690}
1691
1692void
Chandler Carruth631abd92011-06-16 06:47:06 +00001693StmtProfiler::VisitCXXScalarValueInitExpr(const CXXScalarValueInitExpr *S) {
Douglas Gregor5c193b92009-07-28 00:33:38 +00001694 VisitExpr(S);
1695}
1696
Chandler Carruth631abd92011-06-16 06:47:06 +00001697void StmtProfiler::VisitCXXDeleteExpr(const CXXDeleteExpr *S) {
Douglas Gregor5c193b92009-07-28 00:33:38 +00001698 VisitExpr(S);
1699 ID.AddBoolean(S->isGlobalDelete());
1700 ID.AddBoolean(S->isArrayForm());
1701 VisitDecl(S->getOperatorDelete());
1702}
1703
Chandler Carruth631abd92011-06-16 06:47:06 +00001704void StmtProfiler::VisitCXXNewExpr(const CXXNewExpr *S) {
Douglas Gregor5c193b92009-07-28 00:33:38 +00001705 VisitExpr(S);
1706 VisitType(S->getAllocatedType());
1707 VisitDecl(S->getOperatorNew());
1708 VisitDecl(S->getOperatorDelete());
Douglas Gregor5c193b92009-07-28 00:33:38 +00001709 ID.AddBoolean(S->isArray());
1710 ID.AddInteger(S->getNumPlacementArgs());
1711 ID.AddBoolean(S->isGlobalNew());
1712 ID.AddBoolean(S->isParenTypeId());
Sebastian Redl6047f072012-02-16 12:22:20 +00001713 ID.AddInteger(S->getInitializationStyle());
Douglas Gregor5c193b92009-07-28 00:33:38 +00001714}
1715
Chandler Carruth631abd92011-06-16 06:47:06 +00001716void
1717StmtProfiler::VisitCXXPseudoDestructorExpr(const CXXPseudoDestructorExpr *S) {
Douglas Gregorad8a3362009-09-04 17:36:40 +00001718 VisitExpr(S);
1719 ID.AddBoolean(S->isArrow());
1720 VisitNestedNameSpecifier(S->getQualifier());
Craig Topper36250ad2014-05-12 05:36:57 +00001721 ID.AddBoolean(S->getScopeTypeInfo() != nullptr);
Eli Friedman85641392013-08-09 23:37:05 +00001722 if (S->getScopeTypeInfo())
1723 VisitType(S->getScopeTypeInfo()->getType());
Craig Topper36250ad2014-05-12 05:36:57 +00001724 ID.AddBoolean(S->getDestroyedTypeInfo() != nullptr);
Eli Friedman85641392013-08-09 23:37:05 +00001725 if (S->getDestroyedTypeInfo())
1726 VisitType(S->getDestroyedType());
1727 else
Richard Trieu639d7b62017-02-22 22:22:42 +00001728 VisitIdentifierInfo(S->getDestroyedTypeIdentifier());
Douglas Gregorad8a3362009-09-04 17:36:40 +00001729}
1730
Chandler Carruth631abd92011-06-16 06:47:06 +00001731void StmtProfiler::VisitOverloadExpr(const OverloadExpr *S) {
Argyrios Kyrtzidisb482eb82010-08-15 20:53:20 +00001732 VisitExpr(S);
John McCalle66edc12009-11-24 19:00:30 +00001733 VisitNestedNameSpecifier(S->getQualifier());
Richard Trieuf65efae2018-02-22 05:32:25 +00001734 VisitName(S->getName(), /*TreatAsDecl*/ true);
John McCalle66edc12009-11-24 19:00:30 +00001735 ID.AddBoolean(S->hasExplicitTemplateArgs());
1736 if (S->hasExplicitTemplateArgs())
James Y Knight04ec5bf2015-12-24 02:59:37 +00001737 VisitTemplateArguments(S->getTemplateArgs(), S->getNumTemplateArgs());
Argyrios Kyrtzidisf4505452010-08-15 01:15:38 +00001738}
1739
1740void
Chandler Carruth631abd92011-06-16 06:47:06 +00001741StmtProfiler::VisitUnresolvedLookupExpr(const UnresolvedLookupExpr *S) {
Argyrios Kyrtzidisf4505452010-08-15 01:15:38 +00001742 VisitOverloadExpr(S);
Douglas Gregor5c193b92009-07-28 00:33:38 +00001743}
1744
Douglas Gregor29c42f22012-02-24 07:38:34 +00001745void StmtProfiler::VisitTypeTraitExpr(const TypeTraitExpr *S) {
1746 VisitExpr(S);
1747 ID.AddInteger(S->getTrait());
1748 ID.AddInteger(S->getNumArgs());
1749 for (unsigned I = 0, N = S->getNumArgs(); I != N; ++I)
1750 VisitType(S->getArg(I)->getType());
1751}
1752
Chandler Carruth631abd92011-06-16 06:47:06 +00001753void StmtProfiler::VisitArrayTypeTraitExpr(const ArrayTypeTraitExpr *S) {
John Wiegley6242b6a2011-04-28 00:16:57 +00001754 VisitExpr(S);
1755 ID.AddInteger(S->getTrait());
1756 VisitType(S->getQueriedType());
1757}
1758
Chandler Carruth631abd92011-06-16 06:47:06 +00001759void StmtProfiler::VisitExpressionTraitExpr(const ExpressionTraitExpr *S) {
John Wiegleyf9f65842011-04-25 06:54:41 +00001760 VisitExpr(S);
1761 ID.AddInteger(S->getTrait());
1762 VisitExpr(S->getQueriedExpression());
1763}
1764
Chandler Carruth631abd92011-06-16 06:47:06 +00001765void StmtProfiler::VisitDependentScopeDeclRefExpr(
1766 const DependentScopeDeclRefExpr *S) {
Douglas Gregor5c193b92009-07-28 00:33:38 +00001767 VisitExpr(S);
1768 VisitName(S->getDeclName());
1769 VisitNestedNameSpecifier(S->getQualifier());
John McCalle66edc12009-11-24 19:00:30 +00001770 ID.AddBoolean(S->hasExplicitTemplateArgs());
1771 if (S->hasExplicitTemplateArgs())
1772 VisitTemplateArguments(S->getTemplateArgs(), S->getNumTemplateArgs());
Douglas Gregor5c193b92009-07-28 00:33:38 +00001773}
1774
Chandler Carruth631abd92011-06-16 06:47:06 +00001775void StmtProfiler::VisitExprWithCleanups(const ExprWithCleanups *S) {
Douglas Gregora7095092009-07-28 14:44:31 +00001776 VisitExpr(S);
Douglas Gregora7095092009-07-28 14:44:31 +00001777}
1778
Chandler Carruth631abd92011-06-16 06:47:06 +00001779void StmtProfiler::VisitCXXUnresolvedConstructExpr(
1780 const CXXUnresolvedConstructExpr *S) {
Douglas Gregora7095092009-07-28 14:44:31 +00001781 VisitExpr(S);
1782 VisitType(S->getTypeAsWritten());
Richard Smith39eca9b2017-08-23 22:12:08 +00001783 ID.AddInteger(S->isListInitialization());
Douglas Gregora7095092009-07-28 14:44:31 +00001784}
1785
Chandler Carruth631abd92011-06-16 06:47:06 +00001786void StmtProfiler::VisitCXXDependentScopeMemberExpr(
1787 const CXXDependentScopeMemberExpr *S) {
John McCall2d74de92009-12-01 22:10:20 +00001788 ID.AddBoolean(S->isImplicitAccess());
1789 if (!S->isImplicitAccess()) {
1790 VisitExpr(S);
1791 ID.AddBoolean(S->isArrow());
1792 }
Douglas Gregorc26e0f62009-09-03 16:14:30 +00001793 VisitNestedNameSpecifier(S->getQualifier());
Douglas Gregora7095092009-07-28 14:44:31 +00001794 VisitName(S->getMember());
John McCall2d74de92009-12-01 22:10:20 +00001795 ID.AddBoolean(S->hasExplicitTemplateArgs());
1796 if (S->hasExplicitTemplateArgs())
John McCall10eae182009-11-30 22:42:35 +00001797 VisitTemplateArguments(S->getTemplateArgs(), S->getNumTemplateArgs());
1798}
1799
Chandler Carruth631abd92011-06-16 06:47:06 +00001800void StmtProfiler::VisitUnresolvedMemberExpr(const UnresolvedMemberExpr *S) {
John McCall2d74de92009-12-01 22:10:20 +00001801 ID.AddBoolean(S->isImplicitAccess());
1802 if (!S->isImplicitAccess()) {
1803 VisitExpr(S);
1804 ID.AddBoolean(S->isArrow());
1805 }
John McCall10eae182009-11-30 22:42:35 +00001806 VisitNestedNameSpecifier(S->getQualifier());
1807 VisitName(S->getMemberName());
1808 ID.AddBoolean(S->hasExplicitTemplateArgs());
1809 if (S->hasExplicitTemplateArgs())
1810 VisitTemplateArguments(S->getTemplateArgs(), S->getNumTemplateArgs());
Douglas Gregora7095092009-07-28 14:44:31 +00001811}
1812
Chandler Carruth631abd92011-06-16 06:47:06 +00001813void StmtProfiler::VisitCXXNoexceptExpr(const CXXNoexceptExpr *S) {
Sebastian Redl4202c0f2010-09-10 20:55:43 +00001814 VisitExpr(S);
1815}
1816
Chandler Carruth631abd92011-06-16 06:47:06 +00001817void StmtProfiler::VisitPackExpansionExpr(const PackExpansionExpr *S) {
Douglas Gregore8e9dd62011-01-03 17:17:50 +00001818 VisitExpr(S);
1819}
1820
Chandler Carruth631abd92011-06-16 06:47:06 +00001821void StmtProfiler::VisitSizeOfPackExpr(const SizeOfPackExpr *S) {
Douglas Gregor820ba7b2011-01-04 17:33:58 +00001822 VisitExpr(S);
1823 VisitDecl(S->getPack());
Richard Smithd784e682015-09-23 21:41:42 +00001824 if (S->isPartiallySubstituted()) {
1825 auto Args = S->getPartialArguments();
1826 ID.AddInteger(Args.size());
1827 for (const auto &TA : Args)
1828 VisitTemplateArgument(TA);
1829 } else {
1830 ID.AddInteger(0);
1831 }
Douglas Gregor820ba7b2011-01-04 17:33:58 +00001832}
1833
Douglas Gregorcdbc5392011-01-15 01:15:58 +00001834void StmtProfiler::VisitSubstNonTypeTemplateParmPackExpr(
Chandler Carruth631abd92011-06-16 06:47:06 +00001835 const SubstNonTypeTemplateParmPackExpr *S) {
Douglas Gregorcdbc5392011-01-15 01:15:58 +00001836 VisitExpr(S);
1837 VisitDecl(S->getParameterPack());
1838 VisitTemplateArgument(S->getArgumentPack());
1839}
1840
John McCall7c454bb2011-07-15 05:09:51 +00001841void StmtProfiler::VisitSubstNonTypeTemplateParmExpr(
1842 const SubstNonTypeTemplateParmExpr *E) {
1843 // Profile exactly as the replacement expression.
1844 Visit(E->getReplacement());
1845}
1846
Richard Smithb15fe3a2012-09-12 00:56:43 +00001847void StmtProfiler::VisitFunctionParmPackExpr(const FunctionParmPackExpr *S) {
1848 VisitExpr(S);
1849 VisitDecl(S->getParameterPack());
1850 ID.AddInteger(S->getNumExpansions());
1851 for (FunctionParmPackExpr::iterator I = S->begin(), E = S->end(); I != E; ++I)
1852 VisitDecl(*I);
1853}
1854
Douglas Gregorfe314812011-06-21 17:03:29 +00001855void StmtProfiler::VisitMaterializeTemporaryExpr(
1856 const MaterializeTemporaryExpr *S) {
1857 VisitExpr(S);
1858}
1859
Richard Smith0f0af192014-11-08 05:07:16 +00001860void StmtProfiler::VisitCXXFoldExpr(const CXXFoldExpr *S) {
1861 VisitExpr(S);
1862 ID.AddInteger(S->getOperator());
1863}
1864
Richard Smith9f690bd2015-10-27 06:02:45 +00001865void StmtProfiler::VisitCoroutineBodyStmt(const CoroutineBodyStmt *S) {
1866 VisitStmt(S);
1867}
1868
1869void StmtProfiler::VisitCoreturnStmt(const CoreturnStmt *S) {
1870 VisitStmt(S);
1871}
1872
1873void StmtProfiler::VisitCoawaitExpr(const CoawaitExpr *S) {
1874 VisitExpr(S);
1875}
1876
Eric Fiselier20f25cb2017-03-06 23:38:15 +00001877void StmtProfiler::VisitDependentCoawaitExpr(const DependentCoawaitExpr *S) {
1878 VisitExpr(S);
1879}
1880
Richard Smith9f690bd2015-10-27 06:02:45 +00001881void StmtProfiler::VisitCoyieldExpr(const CoyieldExpr *S) {
1882 VisitExpr(S);
1883}
1884
Chandler Carruth631abd92011-06-16 06:47:06 +00001885void StmtProfiler::VisitOpaqueValueExpr(const OpaqueValueExpr *E) {
Fangrui Song6907ce22018-07-30 19:24:48 +00001886 VisitExpr(E);
John McCall8d69a212010-11-15 23:31:06 +00001887}
1888
Kaelyn Takatae1f49d52014-10-27 18:07:20 +00001889void StmtProfiler::VisitTypoExpr(const TypoExpr *E) {
1890 VisitExpr(E);
1891}
1892
Eric Fiselier708afb52019-05-16 21:04:15 +00001893void StmtProfiler::VisitSourceLocExpr(const SourceLocExpr *E) {
1894 VisitExpr(E);
1895}
1896
Chandler Carruth631abd92011-06-16 06:47:06 +00001897void StmtProfiler::VisitObjCStringLiteral(const ObjCStringLiteral *S) {
Douglas Gregora7095092009-07-28 14:44:31 +00001898 VisitExpr(S);
1899}
1900
Patrick Beard0caa3942012-04-19 00:25:12 +00001901void StmtProfiler::VisitObjCBoxedExpr(const ObjCBoxedExpr *E) {
Ted Kremeneke65b0862012-03-06 20:05:56 +00001902 VisitExpr(E);
1903}
1904
1905void StmtProfiler::VisitObjCArrayLiteral(const ObjCArrayLiteral *E) {
1906 VisitExpr(E);
1907}
1908
1909void StmtProfiler::VisitObjCDictionaryLiteral(const ObjCDictionaryLiteral *E) {
1910 VisitExpr(E);
1911}
1912
Chandler Carruth631abd92011-06-16 06:47:06 +00001913void StmtProfiler::VisitObjCEncodeExpr(const ObjCEncodeExpr *S) {
Douglas Gregora7095092009-07-28 14:44:31 +00001914 VisitExpr(S);
1915 VisitType(S->getEncodedType());
1916}
1917
Chandler Carruth631abd92011-06-16 06:47:06 +00001918void StmtProfiler::VisitObjCSelectorExpr(const ObjCSelectorExpr *S) {
Douglas Gregora7095092009-07-28 14:44:31 +00001919 VisitExpr(S);
1920 VisitName(S->getSelector());
1921}
1922
Chandler Carruth631abd92011-06-16 06:47:06 +00001923void StmtProfiler::VisitObjCProtocolExpr(const ObjCProtocolExpr *S) {
Douglas Gregora7095092009-07-28 14:44:31 +00001924 VisitExpr(S);
1925 VisitDecl(S->getProtocol());
1926}
1927
Chandler Carruth631abd92011-06-16 06:47:06 +00001928void StmtProfiler::VisitObjCIvarRefExpr(const ObjCIvarRefExpr *S) {
Douglas Gregora7095092009-07-28 14:44:31 +00001929 VisitExpr(S);
1930 VisitDecl(S->getDecl());
1931 ID.AddBoolean(S->isArrow());
1932 ID.AddBoolean(S->isFreeIvar());
1933}
1934
Chandler Carruth631abd92011-06-16 06:47:06 +00001935void StmtProfiler::VisitObjCPropertyRefExpr(const ObjCPropertyRefExpr *S) {
Douglas Gregora7095092009-07-28 14:44:31 +00001936 VisitExpr(S);
John McCallb7bd14f2010-12-02 01:19:52 +00001937 if (S->isImplicitProperty()) {
1938 VisitDecl(S->getImplicitPropertyGetter());
1939 VisitDecl(S->getImplicitPropertySetter());
1940 } else {
1941 VisitDecl(S->getExplicitProperty());
Fariborz Jahanian681c0752010-10-14 16:04:05 +00001942 }
Fariborz Jahanian681c0752010-10-14 16:04:05 +00001943 if (S->isSuperReceiver()) {
1944 ID.AddBoolean(S->isSuperReceiver());
John McCallb7bd14f2010-12-02 01:19:52 +00001945 VisitType(S->getSuperReceiverType());
Fariborz Jahanian681c0752010-10-14 16:04:05 +00001946 }
Douglas Gregora7095092009-07-28 14:44:31 +00001947}
1948
Ted Kremeneke65b0862012-03-06 20:05:56 +00001949void StmtProfiler::VisitObjCSubscriptRefExpr(const ObjCSubscriptRefExpr *S) {
1950 VisitExpr(S);
1951 VisitDecl(S->getAtIndexMethodDecl());
1952 VisitDecl(S->setAtIndexMethodDecl());
1953}
1954
Chandler Carruth631abd92011-06-16 06:47:06 +00001955void StmtProfiler::VisitObjCMessageExpr(const ObjCMessageExpr *S) {
Douglas Gregora7095092009-07-28 14:44:31 +00001956 VisitExpr(S);
1957 VisitName(S->getSelector());
1958 VisitDecl(S->getMethodDecl());
1959}
1960
Chandler Carruth631abd92011-06-16 06:47:06 +00001961void StmtProfiler::VisitObjCIsaExpr(const ObjCIsaExpr *S) {
Douglas Gregora7095092009-07-28 14:44:31 +00001962 VisitExpr(S);
1963 ID.AddBoolean(S->isArrow());
1964}
1965
Ted Kremeneke65b0862012-03-06 20:05:56 +00001966void StmtProfiler::VisitObjCBoolLiteralExpr(const ObjCBoolLiteralExpr *S) {
1967 VisitExpr(S);
1968 ID.AddBoolean(S->getValue());
1969}
1970
Chandler Carruth631abd92011-06-16 06:47:06 +00001971void StmtProfiler::VisitObjCIndirectCopyRestoreExpr(
1972 const ObjCIndirectCopyRestoreExpr *S) {
John McCall31168b02011-06-15 23:02:42 +00001973 VisitExpr(S);
1974 ID.AddBoolean(S->shouldCopy());
1975}
1976
Chandler Carruth631abd92011-06-16 06:47:06 +00001977void StmtProfiler::VisitObjCBridgedCastExpr(const ObjCBridgedCastExpr *S) {
John McCall31168b02011-06-15 23:02:42 +00001978 VisitExplicitCastExpr(S);
1979 ID.AddBoolean(S->getBridgeKind());
1980}
1981
Erik Pilkington29099de2016-07-16 00:35:23 +00001982void StmtProfiler::VisitObjCAvailabilityCheckExpr(
1983 const ObjCAvailabilityCheckExpr *S) {
1984 VisitExpr(S);
1985}
1986
John McCall0ad16662009-10-29 08:12:44 +00001987void StmtProfiler::VisitTemplateArguments(const TemplateArgumentLoc *Args,
Douglas Gregor5c193b92009-07-28 00:33:38 +00001988 unsigned NumArgs) {
1989 ID.AddInteger(NumArgs);
John McCall0ad16662009-10-29 08:12:44 +00001990 for (unsigned I = 0; I != NumArgs; ++I)
1991 VisitTemplateArgument(Args[I].getArgument());
1992}
Mike Stump11289f42009-09-09 15:08:12 +00001993
John McCall0ad16662009-10-29 08:12:44 +00001994void StmtProfiler::VisitTemplateArgument(const TemplateArgument &Arg) {
1995 // Mostly repetitive with TemplateArgument::Profile!
1996 ID.AddInteger(Arg.getKind());
1997 switch (Arg.getKind()) {
1998 case TemplateArgument::Null:
1999 break;
Mike Stump11289f42009-09-09 15:08:12 +00002000
John McCall0ad16662009-10-29 08:12:44 +00002001 case TemplateArgument::Type:
2002 VisitType(Arg.getAsType());
2003 break;
Mike Stump11289f42009-09-09 15:08:12 +00002004
Douglas Gregor9167f8b2009-11-11 01:00:40 +00002005 case TemplateArgument::Template:
Douglas Gregore4ff4b52011-01-05 18:58:31 +00002006 case TemplateArgument::TemplateExpansion:
2007 VisitTemplateName(Arg.getAsTemplateOrTemplatePattern());
Douglas Gregor9167f8b2009-11-11 01:00:40 +00002008 break;
Fangrui Song6907ce22018-07-30 19:24:48 +00002009
John McCall0ad16662009-10-29 08:12:44 +00002010 case TemplateArgument::Declaration:
2011 VisitDecl(Arg.getAsDecl());
2012 break;
Mike Stump11289f42009-09-09 15:08:12 +00002013
Eli Friedmanb826a002012-09-26 02:36:12 +00002014 case TemplateArgument::NullPtr:
2015 VisitType(Arg.getNullPtrType());
2016 break;
2017
John McCall0ad16662009-10-29 08:12:44 +00002018 case TemplateArgument::Integral:
Benjamin Kramer6003ad52012-06-07 15:09:51 +00002019 Arg.getAsIntegral().Profile(ID);
John McCall0ad16662009-10-29 08:12:44 +00002020 VisitType(Arg.getIntegralType());
2021 break;
Mike Stump11289f42009-09-09 15:08:12 +00002022
John McCall0ad16662009-10-29 08:12:44 +00002023 case TemplateArgument::Expression:
2024 Visit(Arg.getAsExpr());
2025 break;
Mike Stump11289f42009-09-09 15:08:12 +00002026
John McCall0ad16662009-10-29 08:12:44 +00002027 case TemplateArgument::Pack:
Aaron Ballman2a89e852014-07-15 21:32:31 +00002028 for (const auto &P : Arg.pack_elements())
2029 VisitTemplateArgument(P);
John McCall0ad16662009-10-29 08:12:44 +00002030 break;
Douglas Gregor5c193b92009-07-28 00:33:38 +00002031 }
2032}
2033
Jay Foad39c79802011-01-12 09:06:06 +00002034void Stmt::Profile(llvm::FoldingSetNodeID &ID, const ASTContext &Context,
Chandler Carruth631abd92011-06-16 06:47:06 +00002035 bool Canonical) const {
Richard Trieu639d7b62017-02-22 22:22:42 +00002036 StmtProfilerWithPointers Profiler(ID, Context, Canonical);
2037 Profiler.Visit(this);
2038}
2039
2040void Stmt::ProcessODRHash(llvm::FoldingSetNodeID &ID,
2041 class ODRHash &Hash) const {
2042 StmtProfilerWithoutPointers Profiler(ID, Hash);
Douglas Gregor5c193b92009-07-28 00:33:38 +00002043 Profiler.Visit(this);
2044}