1//===---- StmtProfile.cpp - Profile implementation for Stmt ASTs ----------===//
2//
3// 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
6//
7//===----------------------------------------------------------------------===//
8//
9// This file implements the Stmt::Profile method, which builds a unique bit
10// representation that identifies a statement/expression.
11//
12//===----------------------------------------------------------------------===//
13#include "clang/AST/ASTContext.h"
14#include "clang/AST/DeclCXX.h"
15#include "clang/AST/DeclObjC.h"
16#include "clang/AST/DeclTemplate.h"
17#include "clang/AST/Expr.h"
18#include "clang/AST/ExprCXX.h"
19#include "clang/AST/ExprObjC.h"
20#include "clang/AST/ExprOpenMP.h"
21#include "clang/AST/ODRHash.h"
22#include "clang/AST/OpenMPClause.h"
23#include "clang/AST/StmtVisitor.h"
24#include "llvm/ADT/FoldingSet.h"
25using namespace clang;
26
27namespace {
28 class StmtProfiler : public ConstStmtVisitor<StmtProfiler> {
29 protected:
30 llvm::FoldingSetNodeID &ID;
31 bool Canonical;
32 bool ProfileLambdaExpr;
33
34 public:
35 StmtProfiler(llvm::FoldingSetNodeID &ID, bool Canonical,
36 bool ProfileLambdaExpr)
37 : ID(ID), Canonical(Canonical), ProfileLambdaExpr(ProfileLambdaExpr) {}
38
39 virtual ~StmtProfiler() {}
40
41 void VisitStmt(const Stmt *S);
42
43 /// Fold a scalar value into the profile
44 void VisitInteger(uint64_t Value) { ID.AddInteger(I: Value); }
45
46 void VisitStmtNoChildren(const Stmt *S) {
47 HandleStmtClass(SC: S->getStmtClass());
48 }
49
50 virtual void HandleStmtClass(Stmt::StmtClass SC) = 0;
51
52#define STMT(Node, Base) void Visit##Node(const Node *S);
53#include "clang/AST/StmtNodes.inc"
54
55 /// Visit a declaration that is referenced within an expression
56 /// or statement.
57 virtual void VisitDecl(const Decl *D) = 0;
58
59 /// Visit a type that is referenced within an expression or
60 /// statement.
61 virtual void VisitType(QualType T) = 0;
62
63 /// Visit a name that occurs within an expression or statement.
64 virtual void VisitName(DeclarationName Name, bool TreatAsDecl = false) = 0;
65
66 /// Visit identifiers that are not in Decl's or Type's.
67 virtual void VisitIdentifierInfo(const IdentifierInfo *II) = 0;
68
69 /// Visit a nested-name-specifier that occurs within an expression
70 /// or statement.
71 virtual void VisitNestedNameSpecifier(NestedNameSpecifier NNS) = 0;
72
73 /// Visit a template name that occurs within an expression or
74 /// statement.
75 virtual void VisitTemplateName(TemplateName Name) = 0;
76
77 /// Visit template arguments that occur within an expression or
78 /// statement.
79 void VisitTemplateArguments(const TemplateArgumentLoc *Args,
80 unsigned NumArgs);
81
82 /// Visit a single template argument.
83 void VisitTemplateArgument(const TemplateArgument &Arg);
84 };
85
86 class StmtProfilerWithPointers : public StmtProfiler {
87 const ASTContext &Context;
88
89 public:
90 StmtProfilerWithPointers(llvm::FoldingSetNodeID &ID,
91 const ASTContext &Context, bool Canonical,
92 bool ProfileLambdaExpr)
93 : StmtProfiler(ID, Canonical, ProfileLambdaExpr), Context(Context) {}
94
95 private:
96 void HandleStmtClass(Stmt::StmtClass SC) override {
97 ID.AddInteger(I: SC);
98 }
99
100 void VisitDecl(const Decl *D) override {
101 ID.AddInteger(I: D ? D->getKind() : 0);
102
103 if (Canonical && D) {
104 if (const NonTypeTemplateParmDecl *NTTP =
105 dyn_cast<NonTypeTemplateParmDecl>(Val: D)) {
106 ID.AddInteger(I: NTTP->getDepth());
107 ID.AddInteger(I: NTTP->getIndex());
108 ID.AddBoolean(B: NTTP->isParameterPack());
109 // C++20 [temp.over.link]p6:
110 // Two template-parameters are equivalent under the following
111 // conditions: [...] if they declare non-type template parameters,
112 // they have equivalent types ignoring the use of type-constraints
113 // for placeholder types
114 //
115 // TODO: Why do we need to include the type in the profile? It's not
116 // part of the mangling.
117 VisitType(T: Context.getUnconstrainedType(T: NTTP->getType()));
118 return;
119 }
120
121 if (const ParmVarDecl *Parm = dyn_cast<ParmVarDecl>(Val: D)) {
122 // The Itanium C++ ABI uses the type, scope depth, and scope
123 // index of a parameter when mangling expressions that involve
124 // function parameters, so we will use the parameter's type for
125 // establishing function parameter identity. That way, our
126 // definition of "equivalent" (per C++ [temp.over.link]) is at
127 // least as strong as the definition of "equivalent" used for
128 // name mangling.
129 //
130 // TODO: The Itanium C++ ABI only uses the top-level cv-qualifiers,
131 // not the entirety of the type.
132 VisitType(T: Parm->getType());
133 ID.AddInteger(I: Parm->getFunctionScopeDepth());
134 ID.AddInteger(I: Parm->getFunctionScopeIndex());
135 return;
136 }
137
138 if (const TemplateTypeParmDecl *TTP =
139 dyn_cast<TemplateTypeParmDecl>(Val: D)) {
140 ID.AddInteger(I: TTP->getDepth());
141 ID.AddInteger(I: TTP->getIndex());
142 ID.AddBoolean(B: TTP->isParameterPack());
143 return;
144 }
145
146 if (const TemplateTemplateParmDecl *TTP =
147 dyn_cast<TemplateTemplateParmDecl>(Val: D)) {
148 ID.AddInteger(I: TTP->getDepth());
149 ID.AddInteger(I: TTP->getIndex());
150 ID.AddBoolean(B: TTP->isParameterPack());
151 return;
152 }
153 }
154
155 ID.AddPointer(Ptr: D ? D->getCanonicalDecl() : nullptr);
156 }
157
158 void VisitType(QualType T) override {
159 if (Canonical && !T.isNull())
160 T = Context.getCanonicalType(T);
161
162 ID.AddPointer(Ptr: T.getAsOpaquePtr());
163 }
164
165 void VisitName(DeclarationName Name, bool /*TreatAsDecl*/) override {
166 ID.AddPointer(Ptr: Name.getAsOpaquePtr());
167 }
168
169 void VisitIdentifierInfo(const IdentifierInfo *II) override {
170 ID.AddPointer(Ptr: II);
171 }
172
173 void VisitNestedNameSpecifier(NestedNameSpecifier NNS) override {
174 if (Canonical)
175 NNS = NNS.getCanonical();
176 NNS.Profile(ID);
177 }
178
179 void VisitTemplateName(TemplateName Name) override {
180 if (Canonical)
181 Name = Context.getCanonicalTemplateName(Name);
182
183 Name.Profile(ID);
184 }
185 };
186
187 class StmtProfilerWithoutPointers : public StmtProfiler {
188 ODRHash &Hash;
189 public:
190 StmtProfilerWithoutPointers(llvm::FoldingSetNodeID &ID, ODRHash &Hash)
191 : StmtProfiler(ID, /*Canonical=*/false, /*ProfileLambdaExpr=*/false),
192 Hash(Hash) {}
193
194 private:
195 void HandleStmtClass(Stmt::StmtClass SC) override {
196 if (SC == Stmt::UnresolvedLookupExprClass) {
197 // Pretend that the name looked up is a Decl due to how templates
198 // handle some Decl lookups.
199 ID.AddInteger(I: Stmt::DeclRefExprClass);
200 } else {
201 ID.AddInteger(I: SC);
202 }
203 }
204
205 void VisitType(QualType T) override {
206 Hash.AddQualType(T);
207 }
208
209 void VisitName(DeclarationName Name, bool TreatAsDecl) override {
210 if (TreatAsDecl) {
211 // A Decl can be null, so each Decl is preceded by a boolean to
212 // store its nullness. Add a boolean here to match.
213 ID.AddBoolean(B: true);
214 }
215 Hash.AddDeclarationName(Name, TreatAsDecl);
216 }
217 void VisitIdentifierInfo(const IdentifierInfo *II) override {
218 ID.AddBoolean(B: II);
219 if (II) {
220 Hash.AddIdentifierInfo(II);
221 }
222 }
223 void VisitDecl(const Decl *D) override {
224 ID.AddBoolean(B: D);
225 if (D) {
226 Hash.AddDecl(D);
227 }
228 }
229 void VisitTemplateName(TemplateName Name) override {
230 Hash.AddTemplateName(Name);
231 }
232 void VisitNestedNameSpecifier(NestedNameSpecifier NNS) override {
233 ID.AddBoolean(B: bool(NNS));
234 if (NNS)
235 Hash.AddNestedNameSpecifier(NNS);
236 }
237 };
238}
239
240void StmtProfiler::VisitStmt(const Stmt *S) {
241 assert(S && "Requires non-null Stmt pointer");
242
243 VisitStmtNoChildren(S);
244
245 for (const Stmt *SubStmt : S->children()) {
246 if (SubStmt)
247 Visit(S: SubStmt);
248 else
249 ID.AddInteger(I: 0);
250 }
251}
252
253void StmtProfiler::VisitDeclStmt(const DeclStmt *S) {
254 VisitStmt(S);
255 for (const auto *D : S->decls())
256 VisitDecl(D);
257}
258
259void StmtProfiler::VisitNullStmt(const NullStmt *S) {
260 VisitStmt(S);
261}
262
263void StmtProfiler::VisitCompoundStmt(const CompoundStmt *S) {
264 VisitStmt(S);
265}
266
267void StmtProfiler::VisitCaseStmt(const CaseStmt *S) {
268 VisitStmt(S);
269}
270
271void StmtProfiler::VisitDefaultStmt(const DefaultStmt *S) {
272 VisitStmt(S);
273}
274
275void StmtProfiler::VisitLabelStmt(const LabelStmt *S) {
276 VisitStmt(S);
277 VisitDecl(D: S->getDecl());
278}
279
280void StmtProfiler::VisitAttributedStmt(const AttributedStmt *S) {
281 VisitStmt(S);
282 // TODO: maybe visit attributes?
283}
284
285void StmtProfiler::VisitIfStmt(const IfStmt *S) {
286 VisitStmt(S);
287 VisitDecl(D: S->getConditionVariable());
288}
289
290void StmtProfiler::VisitSwitchStmt(const SwitchStmt *S) {
291 VisitStmt(S);
292 VisitDecl(D: S->getConditionVariable());
293}
294
295void StmtProfiler::VisitWhileStmt(const WhileStmt *S) {
296 VisitStmt(S);
297 VisitDecl(D: S->getConditionVariable());
298}
299
300void StmtProfiler::VisitDoStmt(const DoStmt *S) {
301 VisitStmt(S);
302}
303
304void StmtProfiler::VisitForStmt(const ForStmt *S) {
305 VisitStmt(S);
306}
307
308void StmtProfiler::VisitGotoStmt(const GotoStmt *S) {
309 VisitStmt(S);
310 VisitDecl(D: S->getLabel());
311}
312
313void StmtProfiler::VisitIndirectGotoStmt(const IndirectGotoStmt *S) {
314 VisitStmt(S);
315}
316
317void StmtProfiler::VisitContinueStmt(const ContinueStmt *S) {
318 VisitStmt(S);
319}
320
321void StmtProfiler::VisitBreakStmt(const BreakStmt *S) {
322 VisitStmt(S);
323}
324
325void StmtProfiler::VisitReturnStmt(const ReturnStmt *S) {
326 VisitStmt(S);
327}
328
329void StmtProfiler::VisitDeferStmt(const DeferStmt *S) { VisitStmt(S); }
330
331void StmtProfiler::VisitGCCAsmStmt(const GCCAsmStmt *S) {
332 VisitStmt(S);
333 ID.AddBoolean(B: S->isVolatile());
334 ID.AddBoolean(B: S->isSimple());
335 Visit(S: S->getAsmStringExpr());
336 ID.AddInteger(I: S->getNumOutputs());
337 for (unsigned I = 0, N = S->getNumOutputs(); I != N; ++I) {
338 ID.AddString(String: S->getOutputName(i: I));
339 VisitExpr(S: S->getOutputConstraintExpr(i: I));
340 }
341 ID.AddInteger(I: S->getNumInputs());
342 for (unsigned I = 0, N = S->getNumInputs(); I != N; ++I) {
343 ID.AddString(String: S->getInputName(i: I));
344 VisitExpr(S: S->getInputConstraintExpr(i: I));
345 }
346 ID.AddInteger(I: S->getNumClobbers());
347 for (unsigned I = 0, N = S->getNumClobbers(); I != N; ++I)
348 Visit(S: S->getClobberExpr(i: I));
349 ID.AddInteger(I: S->getNumLabels());
350 for (auto *L : S->labels())
351 VisitDecl(D: L->getLabel());
352}
353
354void StmtProfiler::VisitMSAsmStmt(const MSAsmStmt *S) {
355 // FIXME: Implement MS style inline asm statement profiler.
356 VisitStmt(S);
357}
358
359void StmtProfiler::VisitCXXCatchStmt(const CXXCatchStmt *S) {
360 VisitStmt(S);
361 VisitType(T: S->getCaughtType());
362}
363
364void StmtProfiler::VisitCXXTryStmt(const CXXTryStmt *S) {
365 VisitStmt(S);
366}
367
368void StmtProfiler::VisitCXXForRangeStmt(const CXXForRangeStmt *S) {
369 VisitStmt(S);
370}
371
372void StmtProfiler::VisitCXXExpansionStmtPattern(
373 const CXXExpansionStmtPattern *S) {
374 VisitStmt(S);
375}
376
377void StmtProfiler::VisitCXXExpansionStmtInstantiation(
378 const CXXExpansionStmtInstantiation *S) {
379 VisitStmt(S);
380 ID.AddBoolean(B: S->shouldApplyLifetimeExtensionToPreamble());
381}
382
383void StmtProfiler::VisitMSDependentExistsStmt(const MSDependentExistsStmt *S) {
384 VisitStmt(S);
385 ID.AddBoolean(B: S->isIfExists());
386 VisitNestedNameSpecifier(NNS: S->getQualifierLoc().getNestedNameSpecifier());
387 VisitName(Name: S->getNameInfo().getName());
388}
389
390void StmtProfiler::VisitSEHTryStmt(const SEHTryStmt *S) {
391 VisitStmt(S);
392}
393
394void StmtProfiler::VisitSEHFinallyStmt(const SEHFinallyStmt *S) {
395 VisitStmt(S);
396}
397
398void StmtProfiler::VisitSEHExceptStmt(const SEHExceptStmt *S) {
399 VisitStmt(S);
400}
401
402void StmtProfiler::VisitSEHLeaveStmt(const SEHLeaveStmt *S) {
403 VisitStmt(S);
404}
405
406void StmtProfiler::VisitCapturedStmt(const CapturedStmt *S) {
407 VisitStmt(S);
408}
409
410void StmtProfiler::VisitSYCLKernelCallStmt(const SYCLKernelCallStmt *S) {
411 VisitStmt(S);
412}
413
414void StmtProfiler::VisitObjCForCollectionStmt(const ObjCForCollectionStmt *S) {
415 VisitStmt(S);
416}
417
418void StmtProfiler::VisitObjCAtCatchStmt(const ObjCAtCatchStmt *S) {
419 VisitStmt(S);
420 ID.AddBoolean(B: S->hasEllipsis());
421 if (S->getCatchParamDecl())
422 VisitType(T: S->getCatchParamDecl()->getType());
423}
424
425void StmtProfiler::VisitObjCAtFinallyStmt(const ObjCAtFinallyStmt *S) {
426 VisitStmt(S);
427}
428
429void StmtProfiler::VisitObjCAtTryStmt(const ObjCAtTryStmt *S) {
430 VisitStmt(S);
431}
432
433void
434StmtProfiler::VisitObjCAtSynchronizedStmt(const ObjCAtSynchronizedStmt *S) {
435 VisitStmt(S);
436}
437
438void StmtProfiler::VisitObjCAtThrowStmt(const ObjCAtThrowStmt *S) {
439 VisitStmt(S);
440}
441
442void
443StmtProfiler::VisitObjCAutoreleasePoolStmt(const ObjCAutoreleasePoolStmt *S) {
444 VisitStmt(S);
445}
446
447namespace {
448class OMPClauseProfiler : public ConstOMPClauseVisitor<OMPClauseProfiler> {
449 StmtProfiler *Profiler;
450 /// Process clauses with list of variables.
451 template <typename T>
452 void VisitOMPClauseList(T *Node);
453
454public:
455 OMPClauseProfiler(StmtProfiler *P) : Profiler(P) { }
456#define GEN_CLANG_CLAUSE_CLASS
457#define CLAUSE_CLASS(Enum, Str, Class) void Visit##Class(const Class *C);
458#include "llvm/Frontend/OpenMP/OMP.inc"
459 void VisitOMPClauseWithPreInit(const OMPClauseWithPreInit *C);
460 void VisitOMPClauseWithPostUpdate(const OMPClauseWithPostUpdate *C);
461};
462
463void OMPClauseProfiler::VisitOMPClauseWithPreInit(
464 const OMPClauseWithPreInit *C) {
465 if (auto *S = C->getPreInitStmt())
466 Profiler->VisitStmt(S);
467}
468
469void OMPClauseProfiler::VisitOMPClauseWithPostUpdate(
470 const OMPClauseWithPostUpdate *C) {
471 VisitOMPClauseWithPreInit(C);
472 if (auto *E = C->getPostUpdateExpr())
473 Profiler->VisitStmt(S: E);
474}
475
476void OMPClauseProfiler::VisitOMPIfClause(const OMPIfClause *C) {
477 VisitOMPClauseWithPreInit(C);
478 if (C->getCondition())
479 Profiler->VisitStmt(S: C->getCondition());
480}
481
482void OMPClauseProfiler::VisitOMPFinalClause(const OMPFinalClause *C) {
483 VisitOMPClauseWithPreInit(C);
484 if (C->getCondition())
485 Profiler->VisitStmt(S: C->getCondition());
486}
487
488void OMPClauseProfiler::VisitOMPNumThreadsClause(const OMPNumThreadsClause *C) {
489 Profiler->VisitInteger(Value: C->getPrescriptivenessModifier());
490 Profiler->VisitInteger(Value: C->getDimsModifier());
491 if (const Expr *Modifier = C->getDimsModifierExpr())
492 Profiler->VisitStmt(S: Modifier);
493 VisitOMPClauseList(Node: C);
494 VisitOMPClauseWithPreInit(C);
495}
496
497void OMPClauseProfiler::VisitOMPAlignClause(const OMPAlignClause *C) {
498 if (C->getAlignment())
499 Profiler->VisitStmt(S: C->getAlignment());
500}
501
502void OMPClauseProfiler::VisitOMPSafelenClause(const OMPSafelenClause *C) {
503 if (C->getSafelen())
504 Profiler->VisitStmt(S: C->getSafelen());
505}
506
507void OMPClauseProfiler::VisitOMPSimdlenClause(const OMPSimdlenClause *C) {
508 if (C->getSimdlen())
509 Profiler->VisitStmt(S: C->getSimdlen());
510}
511
512void OMPClauseProfiler::VisitOMPSizesClause(const OMPSizesClause *C) {
513 for (auto *E : C->getSizesRefs())
514 if (E)
515 Profiler->VisitExpr(S: E);
516}
517
518void OMPClauseProfiler::VisitOMPCountsClause(const OMPCountsClause *C) {
519 for (auto *E : C->getCountsRefs())
520 if (E)
521 Profiler->VisitExpr(S: E);
522}
523
524void OMPClauseProfiler::VisitOMPPermutationClause(
525 const OMPPermutationClause *C) {
526 for (Expr *E : C->getArgsRefs())
527 if (E)
528 Profiler->VisitExpr(S: E);
529}
530
531void OMPClauseProfiler::VisitOMPFullClause(const OMPFullClause *C) {}
532
533void OMPClauseProfiler::VisitOMPPartialClause(const OMPPartialClause *C) {
534 if (const Expr *Factor = C->getFactor())
535 Profiler->VisitExpr(S: Factor);
536}
537
538void OMPClauseProfiler::VisitOMPDepthClause(const OMPDepthClause *C) {
539 if (const Expr *Depth = C->getDepth())
540 Profiler->VisitExpr(S: Depth);
541}
542
543void OMPClauseProfiler::VisitOMPLoopRangeClause(const OMPLoopRangeClause *C) {
544 if (const Expr *First = C->getFirst())
545 Profiler->VisitExpr(S: First);
546 if (const Expr *Count = C->getCount())
547 Profiler->VisitExpr(S: Count);
548}
549
550void OMPClauseProfiler::VisitOMPAllocatorClause(const OMPAllocatorClause *C) {
551 if (C->getAllocator())
552 Profiler->VisitStmt(S: C->getAllocator());
553}
554
555void OMPClauseProfiler::VisitOMPCollapseClause(const OMPCollapseClause *C) {
556 if (C->getNumForLoops())
557 Profiler->VisitStmt(S: C->getNumForLoops());
558}
559
560void OMPClauseProfiler::VisitOMPDetachClause(const OMPDetachClause *C) {
561 if (Expr *Evt = C->getEventHandler())
562 Profiler->VisitStmt(S: Evt);
563}
564
565void OMPClauseProfiler::VisitOMPNovariantsClause(const OMPNovariantsClause *C) {
566 VisitOMPClauseWithPreInit(C);
567 if (C->getCondition())
568 Profiler->VisitStmt(S: C->getCondition());
569}
570
571void OMPClauseProfiler::VisitOMPNocontextClause(const OMPNocontextClause *C) {
572 VisitOMPClauseWithPreInit(C);
573 if (C->getCondition())
574 Profiler->VisitStmt(S: C->getCondition());
575}
576
577void OMPClauseProfiler::VisitOMPDefaultClause(const OMPDefaultClause *C) { }
578
579void OMPClauseProfiler::VisitOMPThreadsetClause(const OMPThreadsetClause *C) {}
580
581void OMPClauseProfiler::VisitOMPTransparentClause(
582 const OMPTransparentClause *C) {
583 if (C->getImpexType())
584 Profiler->VisitStmt(S: C->getImpexType());
585}
586
587void OMPClauseProfiler::VisitOMPProcBindClause(const OMPProcBindClause *C) { }
588
589void OMPClauseProfiler::VisitOMPUnifiedAddressClause(
590 const OMPUnifiedAddressClause *C) {}
591
592void OMPClauseProfiler::VisitOMPUnifiedSharedMemoryClause(
593 const OMPUnifiedSharedMemoryClause *C) {}
594
595void OMPClauseProfiler::VisitOMPReverseOffloadClause(
596 const OMPReverseOffloadClause *C) {}
597
598void OMPClauseProfiler::VisitOMPDynamicAllocatorsClause(
599 const OMPDynamicAllocatorsClause *C) {}
600
601void OMPClauseProfiler::VisitOMPAtomicDefaultMemOrderClause(
602 const OMPAtomicDefaultMemOrderClause *C) {}
603
604void OMPClauseProfiler::VisitOMPSelfMapsClause(const OMPSelfMapsClause *C) {}
605
606void OMPClauseProfiler::VisitOMPAtClause(const OMPAtClause *C) {}
607
608void OMPClauseProfiler::VisitOMPSeverityClause(const OMPSeverityClause *C) {}
609
610void OMPClauseProfiler::VisitOMPMessageClause(const OMPMessageClause *C) {
611 if (C->getMessageString())
612 Profiler->VisitStmt(S: C->getMessageString());
613}
614
615void OMPClauseProfiler::VisitOMPScheduleClause(const OMPScheduleClause *C) {
616 VisitOMPClauseWithPreInit(C);
617 if (auto *S = C->getChunkSize())
618 Profiler->VisitStmt(S);
619}
620
621void OMPClauseProfiler::VisitOMPOrderedClause(const OMPOrderedClause *C) {
622 if (auto *Num = C->getNumForLoops())
623 Profiler->VisitStmt(S: Num);
624}
625
626void OMPClauseProfiler::VisitOMPNowaitClause(const OMPNowaitClause *C) {
627 if (C->getCondition())
628 Profiler->VisitStmt(S: C->getCondition());
629}
630
631void OMPClauseProfiler::VisitOMPUntiedClause(const OMPUntiedClause *) {}
632
633void OMPClauseProfiler::VisitOMPMergeableClause(const OMPMergeableClause *) {}
634
635void OMPClauseProfiler::VisitOMPReadClause(const OMPReadClause *) {}
636
637void OMPClauseProfiler::VisitOMPWriteClause(const OMPWriteClause *) {}
638
639void OMPClauseProfiler::VisitOMPUpdateClause(const OMPUpdateClause *) {}
640
641void OMPClauseProfiler::VisitOMPUpdateDependObjectsClause(
642 const OMPUpdateDependObjectsClause *) {}
643
644void OMPClauseProfiler::VisitOMPCaptureClause(const OMPCaptureClause *) {}
645
646void OMPClauseProfiler::VisitOMPCompareClause(const OMPCompareClause *) {}
647
648void OMPClauseProfiler::VisitOMPFailClause(const OMPFailClause *) {}
649
650void OMPClauseProfiler::VisitOMPAbsentClause(const OMPAbsentClause *) {}
651
652void OMPClauseProfiler::VisitOMPHoldsClause(const OMPHoldsClause *) {}
653
654void OMPClauseProfiler::VisitOMPContainsClause(const OMPContainsClause *) {}
655
656void OMPClauseProfiler::VisitOMPNoOpenMPClause(const OMPNoOpenMPClause *) {}
657
658void OMPClauseProfiler::VisitOMPNoOpenMPRoutinesClause(
659 const OMPNoOpenMPRoutinesClause *) {}
660
661void OMPClauseProfiler::VisitOMPNoOpenMPConstructsClause(
662 const OMPNoOpenMPConstructsClause *) {}
663
664void OMPClauseProfiler::VisitOMPNoParallelismClause(
665 const OMPNoParallelismClause *) {}
666
667void OMPClauseProfiler::VisitOMPSeqCstClause(const OMPSeqCstClause *) {}
668
669void OMPClauseProfiler::VisitOMPAcqRelClause(const OMPAcqRelClause *) {}
670
671void OMPClauseProfiler::VisitOMPAcquireClause(const OMPAcquireClause *) {}
672
673void OMPClauseProfiler::VisitOMPReleaseClause(const OMPReleaseClause *) {}
674
675void OMPClauseProfiler::VisitOMPRelaxedClause(const OMPRelaxedClause *) {}
676
677void OMPClauseProfiler::VisitOMPWeakClause(const OMPWeakClause *) {}
678
679void OMPClauseProfiler::VisitOMPThreadsClause(const OMPThreadsClause *) {}
680
681void OMPClauseProfiler::VisitOMPSIMDClause(const OMPSIMDClause *) {}
682
683void OMPClauseProfiler::VisitOMPNogroupClause(const OMPNogroupClause *) {}
684
685void OMPClauseProfiler::VisitOMPInitClause(const OMPInitClause *C) {
686 // Enumerate per pref-spec so the {fr, attr} grouping is part of the profile.
687 Profiler->VisitStmt(S: C->getInteropVar());
688 Profiler->VisitInteger(Value: C->hasPreferAttrs() ? 1 : 0);
689 Profiler->VisitInteger(Value: C->varlist_size() - 1);
690 for (OMPInitClause::PrefView P : C->prefs()) {
691 Profiler->VisitInteger(Value: P.Fr ? 1 : 0);
692 if (P.Fr)
693 Profiler->VisitStmt(S: P.Fr);
694 Profiler->VisitInteger(Value: P.Attrs.size());
695 for (const Expr *A : P.Attrs)
696 Profiler->VisitStmt(S: A);
697 }
698}
699
700void OMPClauseProfiler::VisitOMPUseClause(const OMPUseClause *C) {
701 if (C->getInteropVar())
702 Profiler->VisitStmt(S: C->getInteropVar());
703}
704
705void OMPClauseProfiler::VisitOMPDestroyClause(const OMPDestroyClause *C) {
706 if (C->getInteropVar())
707 Profiler->VisitStmt(S: C->getInteropVar());
708}
709
710void OMPClauseProfiler::VisitOMPFilterClause(const OMPFilterClause *C) {
711 VisitOMPClauseWithPreInit(C);
712 if (C->getThreadID())
713 Profiler->VisitStmt(S: C->getThreadID());
714}
715
716template<typename T>
717void OMPClauseProfiler::VisitOMPClauseList(T *Node) {
718 for (auto *E : Node->varlist()) {
719 if (E)
720 Profiler->VisitStmt(S: E);
721 }
722}
723
724void OMPClauseProfiler::VisitOMPPrivateClause(const OMPPrivateClause *C) {
725 VisitOMPClauseList(Node: C);
726 for (auto *E : C->private_copies()) {
727 if (E)
728 Profiler->VisitStmt(S: E);
729 }
730}
731void
732OMPClauseProfiler::VisitOMPFirstprivateClause(const OMPFirstprivateClause *C) {
733 VisitOMPClauseList(Node: C);
734 VisitOMPClauseWithPreInit(C);
735 for (auto *E : C->private_copies()) {
736 if (E)
737 Profiler->VisitStmt(S: E);
738 }
739 for (auto *E : C->inits()) {
740 if (E)
741 Profiler->VisitStmt(S: E);
742 }
743}
744void
745OMPClauseProfiler::VisitOMPLastprivateClause(const OMPLastprivateClause *C) {
746 VisitOMPClauseList(Node: C);
747 VisitOMPClauseWithPostUpdate(C);
748 for (auto *E : C->source_exprs()) {
749 if (E)
750 Profiler->VisitStmt(S: E);
751 }
752 for (auto *E : C->destination_exprs()) {
753 if (E)
754 Profiler->VisitStmt(S: E);
755 }
756 for (auto *E : C->assignment_ops()) {
757 if (E)
758 Profiler->VisitStmt(S: E);
759 }
760}
761void OMPClauseProfiler::VisitOMPSharedClause(const OMPSharedClause *C) {
762 VisitOMPClauseList(Node: C);
763}
764void OMPClauseProfiler::VisitOMPReductionClause(
765 const OMPReductionClause *C) {
766 Profiler->VisitNestedNameSpecifier(
767 NNS: C->getQualifierLoc().getNestedNameSpecifier());
768 Profiler->VisitName(Name: C->getNameInfo().getName());
769 VisitOMPClauseList(Node: C);
770 VisitOMPClauseWithPostUpdate(C);
771 for (auto *E : C->privates()) {
772 if (E)
773 Profiler->VisitStmt(S: E);
774 }
775 for (auto *E : C->lhs_exprs()) {
776 if (E)
777 Profiler->VisitStmt(S: E);
778 }
779 for (auto *E : C->rhs_exprs()) {
780 if (E)
781 Profiler->VisitStmt(S: E);
782 }
783 for (auto *E : C->reduction_ops()) {
784 if (E)
785 Profiler->VisitStmt(S: E);
786 }
787 if (C->getModifier() == clang::OMPC_REDUCTION_inscan) {
788 for (auto *E : C->copy_ops()) {
789 if (E)
790 Profiler->VisitStmt(S: E);
791 }
792 for (auto *E : C->copy_array_temps()) {
793 if (E)
794 Profiler->VisitStmt(S: E);
795 }
796 for (auto *E : C->copy_array_elems()) {
797 if (E)
798 Profiler->VisitStmt(S: E);
799 }
800 }
801}
802void OMPClauseProfiler::VisitOMPTaskReductionClause(
803 const OMPTaskReductionClause *C) {
804 Profiler->VisitNestedNameSpecifier(
805 NNS: C->getQualifierLoc().getNestedNameSpecifier());
806 Profiler->VisitName(Name: C->getNameInfo().getName());
807 VisitOMPClauseList(Node: C);
808 VisitOMPClauseWithPostUpdate(C);
809 for (auto *E : C->privates()) {
810 if (E)
811 Profiler->VisitStmt(S: E);
812 }
813 for (auto *E : C->lhs_exprs()) {
814 if (E)
815 Profiler->VisitStmt(S: E);
816 }
817 for (auto *E : C->rhs_exprs()) {
818 if (E)
819 Profiler->VisitStmt(S: E);
820 }
821 for (auto *E : C->reduction_ops()) {
822 if (E)
823 Profiler->VisitStmt(S: E);
824 }
825}
826void OMPClauseProfiler::VisitOMPInReductionClause(
827 const OMPInReductionClause *C) {
828 Profiler->VisitNestedNameSpecifier(
829 NNS: C->getQualifierLoc().getNestedNameSpecifier());
830 Profiler->VisitName(Name: C->getNameInfo().getName());
831 VisitOMPClauseList(Node: C);
832 VisitOMPClauseWithPostUpdate(C);
833 for (auto *E : C->privates()) {
834 if (E)
835 Profiler->VisitStmt(S: E);
836 }
837 for (auto *E : C->lhs_exprs()) {
838 if (E)
839 Profiler->VisitStmt(S: E);
840 }
841 for (auto *E : C->rhs_exprs()) {
842 if (E)
843 Profiler->VisitStmt(S: E);
844 }
845 for (auto *E : C->reduction_ops()) {
846 if (E)
847 Profiler->VisitStmt(S: E);
848 }
849 for (auto *E : C->taskgroup_descriptors()) {
850 if (E)
851 Profiler->VisitStmt(S: E);
852 }
853}
854void OMPClauseProfiler::VisitOMPLinearClause(const OMPLinearClause *C) {
855 VisitOMPClauseList(Node: C);
856 VisitOMPClauseWithPostUpdate(C);
857 for (auto *E : C->privates()) {
858 if (E)
859 Profiler->VisitStmt(S: E);
860 }
861 for (auto *E : C->inits()) {
862 if (E)
863 Profiler->VisitStmt(S: E);
864 }
865 for (auto *E : C->updates()) {
866 if (E)
867 Profiler->VisitStmt(S: E);
868 }
869 for (auto *E : C->finals()) {
870 if (E)
871 Profiler->VisitStmt(S: E);
872 }
873 if (C->getStep())
874 Profiler->VisitStmt(S: C->getStep());
875 if (C->getCalcStep())
876 Profiler->VisitStmt(S: C->getCalcStep());
877}
878void OMPClauseProfiler::VisitOMPAlignedClause(const OMPAlignedClause *C) {
879 VisitOMPClauseList(Node: C);
880 if (C->getAlignment())
881 Profiler->VisitStmt(S: C->getAlignment());
882}
883void OMPClauseProfiler::VisitOMPCopyinClause(const OMPCopyinClause *C) {
884 VisitOMPClauseList(Node: C);
885 for (auto *E : C->source_exprs()) {
886 if (E)
887 Profiler->VisitStmt(S: E);
888 }
889 for (auto *E : C->destination_exprs()) {
890 if (E)
891 Profiler->VisitStmt(S: E);
892 }
893 for (auto *E : C->assignment_ops()) {
894 if (E)
895 Profiler->VisitStmt(S: E);
896 }
897}
898void
899OMPClauseProfiler::VisitOMPCopyprivateClause(const OMPCopyprivateClause *C) {
900 VisitOMPClauseList(Node: C);
901 for (auto *E : C->source_exprs()) {
902 if (E)
903 Profiler->VisitStmt(S: E);
904 }
905 for (auto *E : C->destination_exprs()) {
906 if (E)
907 Profiler->VisitStmt(S: E);
908 }
909 for (auto *E : C->assignment_ops()) {
910 if (E)
911 Profiler->VisitStmt(S: E);
912 }
913}
914void OMPClauseProfiler::VisitOMPFlushClause(const OMPFlushClause *C) {
915 VisitOMPClauseList(Node: C);
916}
917void OMPClauseProfiler::VisitOMPDepobjClause(const OMPDepobjClause *C) {
918 if (const Expr *Depobj = C->getDepobj())
919 Profiler->VisitStmt(S: Depobj);
920}
921void OMPClauseProfiler::VisitOMPDependClause(const OMPDependClause *C) {
922 VisitOMPClauseList(Node: C);
923}
924void OMPClauseProfiler::VisitOMPDeviceClause(const OMPDeviceClause *C) {
925 if (C->getDevice())
926 Profiler->VisitStmt(S: C->getDevice());
927}
928void OMPClauseProfiler::VisitOMPMapClause(const OMPMapClause *C) {
929 VisitOMPClauseList(Node: C);
930}
931void OMPClauseProfiler::VisitOMPAllocateClause(const OMPAllocateClause *C) {
932 if (Expr *Allocator = C->getAllocator())
933 Profiler->VisitStmt(S: Allocator);
934 VisitOMPClauseList(Node: C);
935}
936void OMPClauseProfiler::VisitOMPNumTeamsClause(const OMPNumTeamsClause *C) {
937 Profiler->VisitInteger(Value: C->getModifier());
938 if (const Expr *Modifier = C->getModifierExpr())
939 Profiler->VisitStmt(S: Modifier);
940 VisitOMPClauseList(Node: C);
941 VisitOMPClauseWithPreInit(C);
942}
943void OMPClauseProfiler::VisitOMPThreadLimitClause(
944 const OMPThreadLimitClause *C) {
945 Profiler->VisitInteger(Value: C->getModifier());
946 if (const Expr *Modifier = C->getModifierExpr())
947 Profiler->VisitStmt(S: Modifier);
948 VisitOMPClauseList(Node: C);
949 VisitOMPClauseWithPreInit(C);
950}
951void OMPClauseProfiler::VisitOMPPriorityClause(const OMPPriorityClause *C) {
952 VisitOMPClauseWithPreInit(C);
953 if (C->getPriority())
954 Profiler->VisitStmt(S: C->getPriority());
955}
956void OMPClauseProfiler::VisitOMPGrainsizeClause(const OMPGrainsizeClause *C) {
957 VisitOMPClauseWithPreInit(C);
958 if (C->getGrainsize())
959 Profiler->VisitStmt(S: C->getGrainsize());
960}
961void OMPClauseProfiler::VisitOMPNumTasksClause(const OMPNumTasksClause *C) {
962 VisitOMPClauseWithPreInit(C);
963 if (C->getNumTasks())
964 Profiler->VisitStmt(S: C->getNumTasks());
965}
966void OMPClauseProfiler::VisitOMPHintClause(const OMPHintClause *C) {
967 if (C->getHint())
968 Profiler->VisitStmt(S: C->getHint());
969}
970void OMPClauseProfiler::VisitOMPToClause(const OMPToClause *C) {
971 VisitOMPClauseList(Node: C);
972}
973void OMPClauseProfiler::VisitOMPFromClause(const OMPFromClause *C) {
974 VisitOMPClauseList(Node: C);
975}
976void OMPClauseProfiler::VisitOMPUseDevicePtrClause(
977 const OMPUseDevicePtrClause *C) {
978 VisitOMPClauseList(Node: C);
979}
980void OMPClauseProfiler::VisitOMPUseDeviceAddrClause(
981 const OMPUseDeviceAddrClause *C) {
982 VisitOMPClauseList(Node: C);
983}
984void OMPClauseProfiler::VisitOMPIsDevicePtrClause(
985 const OMPIsDevicePtrClause *C) {
986 VisitOMPClauseList(Node: C);
987}
988void OMPClauseProfiler::VisitOMPHasDeviceAddrClause(
989 const OMPHasDeviceAddrClause *C) {
990 VisitOMPClauseList(Node: C);
991}
992void OMPClauseProfiler::VisitOMPNontemporalClause(
993 const OMPNontemporalClause *C) {
994 VisitOMPClauseList(Node: C);
995 for (auto *E : C->private_refs())
996 Profiler->VisitStmt(S: E);
997}
998void OMPClauseProfiler::VisitOMPInclusiveClause(const OMPInclusiveClause *C) {
999 VisitOMPClauseList(Node: C);
1000}
1001void OMPClauseProfiler::VisitOMPExclusiveClause(const OMPExclusiveClause *C) {
1002 VisitOMPClauseList(Node: C);
1003}
1004void OMPClauseProfiler::VisitOMPUsesAllocatorsClause(
1005 const OMPUsesAllocatorsClause *C) {
1006 for (unsigned I = 0, E = C->getNumberOfAllocators(); I < E; ++I) {
1007 OMPUsesAllocatorsClause::Data D = C->getAllocatorData(I);
1008 Profiler->VisitStmt(S: D.Allocator);
1009 if (D.AllocatorTraits)
1010 Profiler->VisitStmt(S: D.AllocatorTraits);
1011 }
1012}
1013void OMPClauseProfiler::VisitOMPAffinityClause(const OMPAffinityClause *C) {
1014 if (const Expr *Modifier = C->getModifier())
1015 Profiler->VisitStmt(S: Modifier);
1016 for (const Expr *E : C->varlist())
1017 Profiler->VisitStmt(S: E);
1018}
1019void OMPClauseProfiler::VisitOMPOrderClause(const OMPOrderClause *C) {}
1020void OMPClauseProfiler::VisitOMPBindClause(const OMPBindClause *C) {}
1021void OMPClauseProfiler::VisitOMPXDynCGroupMemClause(
1022 const OMPXDynCGroupMemClause *C) {
1023 VisitOMPClauseWithPreInit(C);
1024 if (Expr *Size = C->getSize())
1025 Profiler->VisitStmt(S: Size);
1026}
1027void OMPClauseProfiler::VisitOMPDynGroupprivateClause(
1028 const OMPDynGroupprivateClause *C) {
1029 VisitOMPClauseWithPreInit(C);
1030 if (auto *Size = C->getSize())
1031 Profiler->VisitStmt(S: Size);
1032}
1033void OMPClauseProfiler::VisitOMPDoacrossClause(const OMPDoacrossClause *C) {
1034 VisitOMPClauseList(Node: C);
1035}
1036void OMPClauseProfiler::VisitOMPXAttributeClause(const OMPXAttributeClause *C) {
1037}
1038void OMPClauseProfiler::VisitOMPXBareClause(const OMPXBareClause *C) {}
1039} // namespace
1040
1041void
1042StmtProfiler::VisitOMPExecutableDirective(const OMPExecutableDirective *S) {
1043 VisitStmt(S);
1044 OMPClauseProfiler P(this);
1045 ArrayRef<OMPClause *> Clauses = S->clauses();
1046 for (ArrayRef<OMPClause *>::iterator I = Clauses.begin(), E = Clauses.end();
1047 I != E; ++I)
1048 if (*I)
1049 P.Visit(S: *I);
1050}
1051
1052void StmtProfiler::VisitOMPCanonicalLoop(const OMPCanonicalLoop *L) {
1053 VisitStmt(S: L);
1054}
1055
1056void StmtProfiler::VisitOMPLoopBasedDirective(const OMPLoopBasedDirective *S) {
1057 VisitOMPExecutableDirective(S);
1058}
1059
1060void StmtProfiler::VisitOMPLoopDirective(const OMPLoopDirective *S) {
1061 VisitOMPLoopBasedDirective(S);
1062}
1063
1064void StmtProfiler::VisitOMPMetaDirective(const OMPMetaDirective *S) {
1065 VisitOMPExecutableDirective(S);
1066}
1067
1068void StmtProfiler::VisitOMPParallelDirective(const OMPParallelDirective *S) {
1069 VisitOMPExecutableDirective(S);
1070}
1071
1072void StmtProfiler::VisitOMPSimdDirective(const OMPSimdDirective *S) {
1073 VisitOMPLoopDirective(S);
1074}
1075
1076void StmtProfiler::VisitOMPCanonicalLoopNestTransformationDirective(
1077 const OMPCanonicalLoopNestTransformationDirective *S) {
1078 VisitOMPLoopBasedDirective(S);
1079}
1080
1081void StmtProfiler::VisitOMPTileDirective(const OMPTileDirective *S) {
1082 VisitOMPCanonicalLoopNestTransformationDirective(S);
1083}
1084
1085void StmtProfiler::VisitOMPStripeDirective(const OMPStripeDirective *S) {
1086 VisitOMPCanonicalLoopNestTransformationDirective(S);
1087}
1088
1089void StmtProfiler::VisitOMPUnrollDirective(const OMPUnrollDirective *S) {
1090 VisitOMPCanonicalLoopNestTransformationDirective(S);
1091}
1092
1093void StmtProfiler::VisitOMPReverseDirective(const OMPReverseDirective *S) {
1094 VisitOMPCanonicalLoopNestTransformationDirective(S);
1095}
1096
1097void StmtProfiler::VisitOMPInterchangeDirective(
1098 const OMPInterchangeDirective *S) {
1099 VisitOMPCanonicalLoopNestTransformationDirective(S);
1100}
1101
1102void StmtProfiler::VisitOMPFlattenDirective(const OMPFlattenDirective *S) {
1103 VisitOMPCanonicalLoopNestTransformationDirective(S);
1104}
1105
1106void StmtProfiler::VisitOMPSplitDirective(const OMPSplitDirective *S) {
1107 VisitOMPCanonicalLoopNestTransformationDirective(S);
1108}
1109
1110void StmtProfiler::VisitOMPCanonicalLoopSequenceTransformationDirective(
1111 const OMPCanonicalLoopSequenceTransformationDirective *S) {
1112 VisitOMPExecutableDirective(S);
1113}
1114
1115void StmtProfiler::VisitOMPFuseDirective(const OMPFuseDirective *S) {
1116 VisitOMPCanonicalLoopSequenceTransformationDirective(S);
1117}
1118
1119void StmtProfiler::VisitOMPForDirective(const OMPForDirective *S) {
1120 VisitOMPLoopDirective(S);
1121}
1122
1123void StmtProfiler::VisitOMPForSimdDirective(const OMPForSimdDirective *S) {
1124 VisitOMPLoopDirective(S);
1125}
1126
1127void StmtProfiler::VisitOMPSectionsDirective(const OMPSectionsDirective *S) {
1128 VisitOMPExecutableDirective(S);
1129}
1130
1131void StmtProfiler::VisitOMPSectionDirective(const OMPSectionDirective *S) {
1132 VisitOMPExecutableDirective(S);
1133}
1134
1135void StmtProfiler::VisitOMPScopeDirective(const OMPScopeDirective *S) {
1136 VisitOMPExecutableDirective(S);
1137}
1138
1139void StmtProfiler::VisitOMPSingleDirective(const OMPSingleDirective *S) {
1140 VisitOMPExecutableDirective(S);
1141}
1142
1143void StmtProfiler::VisitOMPMasterDirective(const OMPMasterDirective *S) {
1144 VisitOMPExecutableDirective(S);
1145}
1146
1147void StmtProfiler::VisitOMPCriticalDirective(const OMPCriticalDirective *S) {
1148 VisitOMPExecutableDirective(S);
1149 VisitName(Name: S->getDirectiveName().getName());
1150}
1151
1152void
1153StmtProfiler::VisitOMPParallelForDirective(const OMPParallelForDirective *S) {
1154 VisitOMPLoopDirective(S);
1155}
1156
1157void StmtProfiler::VisitOMPParallelForSimdDirective(
1158 const OMPParallelForSimdDirective *S) {
1159 VisitOMPLoopDirective(S);
1160}
1161
1162void StmtProfiler::VisitOMPParallelMasterDirective(
1163 const OMPParallelMasterDirective *S) {
1164 VisitOMPExecutableDirective(S);
1165}
1166
1167void StmtProfiler::VisitOMPParallelMaskedDirective(
1168 const OMPParallelMaskedDirective *S) {
1169 VisitOMPExecutableDirective(S);
1170}
1171
1172void StmtProfiler::VisitOMPParallelSectionsDirective(
1173 const OMPParallelSectionsDirective *S) {
1174 VisitOMPExecutableDirective(S);
1175}
1176
1177void StmtProfiler::VisitOMPTaskDirective(const OMPTaskDirective *S) {
1178 VisitOMPExecutableDirective(S);
1179}
1180
1181void StmtProfiler::VisitOMPTaskyieldDirective(const OMPTaskyieldDirective *S) {
1182 VisitOMPExecutableDirective(S);
1183}
1184
1185void StmtProfiler::VisitOMPBarrierDirective(const OMPBarrierDirective *S) {
1186 VisitOMPExecutableDirective(S);
1187}
1188
1189void StmtProfiler::VisitOMPTaskwaitDirective(const OMPTaskwaitDirective *S) {
1190 VisitOMPExecutableDirective(S);
1191}
1192
1193void StmtProfiler::VisitOMPAssumeDirective(const OMPAssumeDirective *S) {
1194 VisitOMPExecutableDirective(S);
1195}
1196
1197void StmtProfiler::VisitOMPErrorDirective(const OMPErrorDirective *S) {
1198 VisitOMPExecutableDirective(S);
1199}
1200void StmtProfiler::VisitOMPTaskgroupDirective(const OMPTaskgroupDirective *S) {
1201 VisitOMPExecutableDirective(S);
1202 if (const Expr *E = S->getReductionRef())
1203 VisitStmt(S: E);
1204}
1205
1206void StmtProfiler::VisitOMPFlushDirective(const OMPFlushDirective *S) {
1207 VisitOMPExecutableDirective(S);
1208}
1209
1210void StmtProfiler::VisitOMPDepobjDirective(const OMPDepobjDirective *S) {
1211 VisitOMPExecutableDirective(S);
1212}
1213
1214void StmtProfiler::VisitOMPScanDirective(const OMPScanDirective *S) {
1215 VisitOMPExecutableDirective(S);
1216}
1217
1218void StmtProfiler::VisitOMPOrderedStandaloneDirective(
1219 const OMPOrderedStandaloneDirective *S) {
1220 VisitOMPExecutableDirective(S);
1221}
1222
1223void StmtProfiler::VisitOMPOrderedBlockAssocDirective(
1224 const OMPOrderedBlockAssocDirective *S) {
1225 VisitOMPExecutableDirective(S);
1226}
1227
1228void StmtProfiler::VisitOMPAtomicDirective(const OMPAtomicDirective *S) {
1229 VisitOMPExecutableDirective(S);
1230}
1231
1232void StmtProfiler::VisitOMPTargetDirective(const OMPTargetDirective *S) {
1233 VisitOMPExecutableDirective(S);
1234}
1235
1236void StmtProfiler::VisitOMPTargetDataDirective(const OMPTargetDataDirective *S) {
1237 VisitOMPExecutableDirective(S);
1238}
1239
1240void StmtProfiler::VisitOMPTargetEnterDataDirective(
1241 const OMPTargetEnterDataDirective *S) {
1242 VisitOMPExecutableDirective(S);
1243}
1244
1245void StmtProfiler::VisitOMPTargetExitDataDirective(
1246 const OMPTargetExitDataDirective *S) {
1247 VisitOMPExecutableDirective(S);
1248}
1249
1250void StmtProfiler::VisitOMPTargetParallelDirective(
1251 const OMPTargetParallelDirective *S) {
1252 VisitOMPExecutableDirective(S);
1253}
1254
1255void StmtProfiler::VisitOMPTargetParallelForDirective(
1256 const OMPTargetParallelForDirective *S) {
1257 VisitOMPExecutableDirective(S);
1258}
1259
1260void StmtProfiler::VisitOMPTeamsDirective(const OMPTeamsDirective *S) {
1261 VisitOMPExecutableDirective(S);
1262}
1263
1264void StmtProfiler::VisitOMPCancellationPointDirective(
1265 const OMPCancellationPointDirective *S) {
1266 VisitOMPExecutableDirective(S);
1267}
1268
1269void StmtProfiler::VisitOMPCancelDirective(const OMPCancelDirective *S) {
1270 VisitOMPExecutableDirective(S);
1271}
1272
1273void StmtProfiler::VisitOMPTaskLoopDirective(const OMPTaskLoopDirective *S) {
1274 VisitOMPLoopDirective(S);
1275}
1276
1277void StmtProfiler::VisitOMPTaskLoopSimdDirective(
1278 const OMPTaskLoopSimdDirective *S) {
1279 VisitOMPLoopDirective(S);
1280}
1281
1282void StmtProfiler::VisitOMPMasterTaskLoopDirective(
1283 const OMPMasterTaskLoopDirective *S) {
1284 VisitOMPLoopDirective(S);
1285}
1286
1287void StmtProfiler::VisitOMPMaskedTaskLoopDirective(
1288 const OMPMaskedTaskLoopDirective *S) {
1289 VisitOMPLoopDirective(S);
1290}
1291
1292void StmtProfiler::VisitOMPMasterTaskLoopSimdDirective(
1293 const OMPMasterTaskLoopSimdDirective *S) {
1294 VisitOMPLoopDirective(S);
1295}
1296
1297void StmtProfiler::VisitOMPMaskedTaskLoopSimdDirective(
1298 const OMPMaskedTaskLoopSimdDirective *S) {
1299 VisitOMPLoopDirective(S);
1300}
1301
1302void StmtProfiler::VisitOMPParallelMasterTaskLoopDirective(
1303 const OMPParallelMasterTaskLoopDirective *S) {
1304 VisitOMPLoopDirective(S);
1305}
1306
1307void StmtProfiler::VisitOMPParallelMaskedTaskLoopDirective(
1308 const OMPParallelMaskedTaskLoopDirective *S) {
1309 VisitOMPLoopDirective(S);
1310}
1311
1312void StmtProfiler::VisitOMPParallelMasterTaskLoopSimdDirective(
1313 const OMPParallelMasterTaskLoopSimdDirective *S) {
1314 VisitOMPLoopDirective(S);
1315}
1316
1317void StmtProfiler::VisitOMPParallelMaskedTaskLoopSimdDirective(
1318 const OMPParallelMaskedTaskLoopSimdDirective *S) {
1319 VisitOMPLoopDirective(S);
1320}
1321
1322void StmtProfiler::VisitOMPDistributeDirective(
1323 const OMPDistributeDirective *S) {
1324 VisitOMPLoopDirective(S);
1325}
1326
1327void OMPClauseProfiler::VisitOMPDistScheduleClause(
1328 const OMPDistScheduleClause *C) {
1329 VisitOMPClauseWithPreInit(C);
1330 if (auto *S = C->getChunkSize())
1331 Profiler->VisitStmt(S);
1332}
1333
1334void OMPClauseProfiler::VisitOMPDefaultmapClause(const OMPDefaultmapClause *) {}
1335
1336void StmtProfiler::VisitOMPTargetUpdateDirective(
1337 const OMPTargetUpdateDirective *S) {
1338 VisitOMPExecutableDirective(S);
1339}
1340
1341void StmtProfiler::VisitOMPDistributeParallelForDirective(
1342 const OMPDistributeParallelForDirective *S) {
1343 VisitOMPLoopDirective(S);
1344}
1345
1346void StmtProfiler::VisitOMPDistributeParallelForSimdDirective(
1347 const OMPDistributeParallelForSimdDirective *S) {
1348 VisitOMPLoopDirective(S);
1349}
1350
1351void StmtProfiler::VisitOMPDistributeSimdDirective(
1352 const OMPDistributeSimdDirective *S) {
1353 VisitOMPLoopDirective(S);
1354}
1355
1356void StmtProfiler::VisitOMPTargetParallelForSimdDirective(
1357 const OMPTargetParallelForSimdDirective *S) {
1358 VisitOMPLoopDirective(S);
1359}
1360
1361void StmtProfiler::VisitOMPTargetSimdDirective(
1362 const OMPTargetSimdDirective *S) {
1363 VisitOMPLoopDirective(S);
1364}
1365
1366void StmtProfiler::VisitOMPTeamsDistributeDirective(
1367 const OMPTeamsDistributeDirective *S) {
1368 VisitOMPLoopDirective(S);
1369}
1370
1371void StmtProfiler::VisitOMPTeamsDistributeSimdDirective(
1372 const OMPTeamsDistributeSimdDirective *S) {
1373 VisitOMPLoopDirective(S);
1374}
1375
1376void StmtProfiler::VisitOMPTeamsDistributeParallelForSimdDirective(
1377 const OMPTeamsDistributeParallelForSimdDirective *S) {
1378 VisitOMPLoopDirective(S);
1379}
1380
1381void StmtProfiler::VisitOMPTeamsDistributeParallelForDirective(
1382 const OMPTeamsDistributeParallelForDirective *S) {
1383 VisitOMPLoopDirective(S);
1384}
1385
1386void StmtProfiler::VisitOMPTargetTeamsDirective(
1387 const OMPTargetTeamsDirective *S) {
1388 VisitOMPExecutableDirective(S);
1389}
1390
1391void StmtProfiler::VisitOMPTargetTeamsDistributeDirective(
1392 const OMPTargetTeamsDistributeDirective *S) {
1393 VisitOMPLoopDirective(S);
1394}
1395
1396void StmtProfiler::VisitOMPTargetTeamsDistributeParallelForDirective(
1397 const OMPTargetTeamsDistributeParallelForDirective *S) {
1398 VisitOMPLoopDirective(S);
1399}
1400
1401void StmtProfiler::VisitOMPTargetTeamsDistributeParallelForSimdDirective(
1402 const OMPTargetTeamsDistributeParallelForSimdDirective *S) {
1403 VisitOMPLoopDirective(S);
1404}
1405
1406void StmtProfiler::VisitOMPTargetTeamsDistributeSimdDirective(
1407 const OMPTargetTeamsDistributeSimdDirective *S) {
1408 VisitOMPLoopDirective(S);
1409}
1410
1411void StmtProfiler::VisitOMPInteropDirective(const OMPInteropDirective *S) {
1412 VisitOMPExecutableDirective(S);
1413}
1414
1415void StmtProfiler::VisitOMPDispatchDirective(const OMPDispatchDirective *S) {
1416 VisitOMPExecutableDirective(S);
1417}
1418
1419void StmtProfiler::VisitOMPMaskedDirective(const OMPMaskedDirective *S) {
1420 VisitOMPExecutableDirective(S);
1421}
1422
1423void StmtProfiler::VisitOMPGenericLoopDirective(
1424 const OMPGenericLoopDirective *S) {
1425 VisitOMPLoopDirective(S);
1426}
1427
1428void StmtProfiler::VisitOMPTeamsGenericLoopDirective(
1429 const OMPTeamsGenericLoopDirective *S) {
1430 VisitOMPLoopDirective(S);
1431}
1432
1433void StmtProfiler::VisitOMPTargetTeamsGenericLoopDirective(
1434 const OMPTargetTeamsGenericLoopDirective *S) {
1435 VisitOMPLoopDirective(S);
1436}
1437
1438void StmtProfiler::VisitOMPParallelGenericLoopDirective(
1439 const OMPParallelGenericLoopDirective *S) {
1440 VisitOMPLoopDirective(S);
1441}
1442
1443void StmtProfiler::VisitOMPTargetParallelGenericLoopDirective(
1444 const OMPTargetParallelGenericLoopDirective *S) {
1445 VisitOMPLoopDirective(S);
1446}
1447
1448void StmtProfiler::VisitOMPTargetGenericLoopDirective(
1449 const OMPTargetGenericLoopDirective *S) {
1450 VisitOMPLoopDirective(S);
1451}
1452
1453void StmtProfiler::VisitExpr(const Expr *S) {
1454 VisitStmt(S);
1455}
1456
1457void StmtProfiler::VisitConstantExpr(const ConstantExpr *S) {
1458 // Profile exactly as the sub-expression.
1459 Visit(S: S->getSubExpr());
1460}
1461
1462void StmtProfiler::VisitDeclRefExpr(const DeclRefExpr *S) {
1463 VisitExpr(S);
1464 if (!Canonical)
1465 VisitNestedNameSpecifier(NNS: S->getQualifier());
1466 VisitDecl(D: S->getDecl());
1467 if (!Canonical) {
1468 ID.AddBoolean(B: S->hasExplicitTemplateArgs());
1469 if (S->hasExplicitTemplateArgs())
1470 VisitTemplateArguments(Args: S->getTemplateArgs(), NumArgs: S->getNumTemplateArgs());
1471 }
1472}
1473
1474void StmtProfiler::VisitSYCLUniqueStableNameExpr(
1475 const SYCLUniqueStableNameExpr *S) {
1476 VisitExpr(S);
1477 VisitType(T: S->getTypeSourceInfo()->getType());
1478}
1479
1480void StmtProfiler::VisitUnresolvedSYCLKernelCallStmt(
1481 const UnresolvedSYCLKernelCallStmt *S) {
1482 VisitStmt(S);
1483}
1484
1485void StmtProfiler::VisitPredefinedExpr(const PredefinedExpr *S) {
1486 VisitExpr(S);
1487 ID.AddInteger(I: llvm::to_underlying(E: S->getIdentKind()));
1488}
1489
1490void StmtProfiler::VisitOpenACCAsteriskSizeExpr(
1491 const OpenACCAsteriskSizeExpr *S) {
1492 VisitExpr(S);
1493}
1494
1495void StmtProfiler::VisitIntegerLiteral(const IntegerLiteral *S) {
1496 VisitExpr(S);
1497 S->getValue().Profile(id&: ID);
1498
1499 QualType T = S->getType();
1500 if (Canonical)
1501 T = T.getCanonicalType();
1502 ID.AddInteger(I: T->getTypeClass());
1503 if (auto BitIntT = T->getAs<BitIntType>()) {
1504 auto [IsUnsigned, NumBits] = BitIntT->getKey();
1505 ID.AddInteger(I: IsUnsigned);
1506 ID.AddInteger(I: NumBits);
1507 } else {
1508 ID.AddInteger(I: T->castAs<BuiltinType>()->getKind());
1509 }
1510}
1511
1512void StmtProfiler::VisitFixedPointLiteral(const FixedPointLiteral *S) {
1513 VisitExpr(S);
1514 S->getValue().Profile(id&: ID);
1515 ID.AddInteger(I: S->getType()->castAs<BuiltinType>()->getKind());
1516}
1517
1518void StmtProfiler::VisitCharacterLiteral(const CharacterLiteral *S) {
1519 VisitExpr(S);
1520 ID.AddInteger(I: llvm::to_underlying(E: S->getKind()));
1521 ID.AddInteger(I: S->getValue());
1522}
1523
1524void StmtProfiler::VisitFloatingLiteral(const FloatingLiteral *S) {
1525 VisitExpr(S);
1526 S->getValue().Profile(NID&: ID);
1527 ID.AddBoolean(B: S->isExact());
1528 ID.AddInteger(I: S->getType()->castAs<BuiltinType>()->getKind());
1529}
1530
1531void StmtProfiler::VisitImaginaryLiteral(const ImaginaryLiteral *S) {
1532 VisitExpr(S);
1533}
1534
1535void StmtProfiler::VisitStringLiteral(const StringLiteral *S) {
1536 VisitExpr(S);
1537 ID.AddString(String: S->getBytes());
1538 ID.AddInteger(I: llvm::to_underlying(E: S->getKind()));
1539}
1540
1541void StmtProfiler::VisitParenExpr(const ParenExpr *S) {
1542 VisitExpr(S);
1543}
1544
1545void StmtProfiler::VisitParenListExpr(const ParenListExpr *S) {
1546 VisitExpr(S);
1547}
1548
1549void StmtProfiler::VisitUnaryOperator(const UnaryOperator *S) {
1550 VisitExpr(S);
1551 ID.AddInteger(I: S->getOpcode());
1552}
1553
1554void StmtProfiler::VisitOffsetOfExpr(const OffsetOfExpr *S) {
1555 VisitType(T: S->getTypeSourceInfo()->getType());
1556 unsigned n = S->getNumComponents();
1557 for (unsigned i = 0; i < n; ++i) {
1558 const OffsetOfNode &ON = S->getComponent(Idx: i);
1559 ID.AddInteger(I: ON.getKind());
1560 switch (ON.getKind()) {
1561 case OffsetOfNode::Array:
1562 // Expressions handled below.
1563 break;
1564
1565 case OffsetOfNode::Field:
1566 VisitDecl(D: ON.getField());
1567 break;
1568
1569 case OffsetOfNode::Identifier:
1570 VisitIdentifierInfo(II: ON.getFieldName());
1571 break;
1572
1573 case OffsetOfNode::Base:
1574 // These nodes are implicit, and therefore don't need profiling.
1575 break;
1576 }
1577 }
1578
1579 VisitExpr(S);
1580}
1581
1582void
1583StmtProfiler::VisitUnaryExprOrTypeTraitExpr(const UnaryExprOrTypeTraitExpr *S) {
1584 VisitExpr(S);
1585 ID.AddInteger(I: S->getKind());
1586 if (S->isArgumentType())
1587 VisitType(T: S->getArgumentType());
1588}
1589
1590void StmtProfiler::VisitArraySubscriptExpr(const ArraySubscriptExpr *S) {
1591 VisitExpr(S);
1592}
1593
1594void StmtProfiler::VisitMatrixSingleSubscriptExpr(
1595 const MatrixSingleSubscriptExpr *S) {
1596 VisitExpr(S);
1597}
1598
1599void StmtProfiler::VisitMatrixSubscriptExpr(const MatrixSubscriptExpr *S) {
1600 VisitExpr(S);
1601}
1602
1603void StmtProfiler::VisitArraySectionExpr(const ArraySectionExpr *S) {
1604 VisitExpr(S);
1605}
1606
1607void StmtProfiler::VisitOMPArrayShapingExpr(const OMPArrayShapingExpr *S) {
1608 VisitExpr(S);
1609}
1610
1611void StmtProfiler::VisitOMPIteratorExpr(const OMPIteratorExpr *S) {
1612 VisitExpr(S);
1613 for (unsigned I = 0, E = S->numOfIterators(); I < E; ++I)
1614 VisitDecl(D: S->getIteratorDecl(I));
1615}
1616
1617void StmtProfiler::VisitCallExpr(const CallExpr *S) {
1618 VisitExpr(S);
1619}
1620
1621void StmtProfiler::VisitMemberExpr(const MemberExpr *S) {
1622 VisitExpr(S);
1623 VisitDecl(D: S->getMemberDecl());
1624 if (!Canonical)
1625 VisitNestedNameSpecifier(NNS: S->getQualifier());
1626 ID.AddBoolean(B: S->isArrow());
1627}
1628
1629void StmtProfiler::VisitCompoundLiteralExpr(const CompoundLiteralExpr *S) {
1630 VisitExpr(S);
1631 ID.AddBoolean(B: S->isFileScope());
1632}
1633
1634void StmtProfiler::VisitCastExpr(const CastExpr *S) {
1635 VisitExpr(S);
1636}
1637
1638void StmtProfiler::VisitImplicitCastExpr(const ImplicitCastExpr *S) {
1639 VisitCastExpr(S);
1640 ID.AddInteger(I: S->getValueKind());
1641}
1642
1643void StmtProfiler::VisitExplicitCastExpr(const ExplicitCastExpr *S) {
1644 VisitCastExpr(S);
1645 VisitType(T: S->getTypeAsWritten());
1646}
1647
1648void StmtProfiler::VisitCStyleCastExpr(const CStyleCastExpr *S) {
1649 VisitExplicitCastExpr(S);
1650}
1651
1652void StmtProfiler::VisitBinaryOperator(const BinaryOperator *S) {
1653 VisitExpr(S);
1654 ID.AddInteger(I: S->getOpcode());
1655}
1656
1657void
1658StmtProfiler::VisitCompoundAssignOperator(const CompoundAssignOperator *S) {
1659 VisitBinaryOperator(S);
1660}
1661
1662void StmtProfiler::VisitConditionalOperator(const ConditionalOperator *S) {
1663 VisitExpr(S);
1664}
1665
1666void StmtProfiler::VisitBinaryConditionalOperator(
1667 const BinaryConditionalOperator *S) {
1668 VisitExpr(S);
1669}
1670
1671void StmtProfiler::VisitAddrLabelExpr(const AddrLabelExpr *S) {
1672 VisitExpr(S);
1673 VisitDecl(D: S->getLabel());
1674}
1675
1676void StmtProfiler::VisitStmtExpr(const StmtExpr *S) {
1677 VisitExpr(S);
1678}
1679
1680void StmtProfiler::VisitShuffleVectorExpr(const ShuffleVectorExpr *S) {
1681 VisitExpr(S);
1682}
1683
1684void StmtProfiler::VisitConvertVectorExpr(const ConvertVectorExpr *S) {
1685 VisitExpr(S);
1686}
1687
1688void StmtProfiler::VisitChooseExpr(const ChooseExpr *S) {
1689 VisitExpr(S);
1690}
1691
1692void StmtProfiler::VisitGNUNullExpr(const GNUNullExpr *S) {
1693 VisitExpr(S);
1694}
1695
1696void StmtProfiler::VisitVAArgExpr(const VAArgExpr *S) {
1697 VisitExpr(S);
1698}
1699
1700void StmtProfiler::VisitInitListExpr(const InitListExpr *S) {
1701 if (S->getSyntacticForm()) {
1702 VisitInitListExpr(S: S->getSyntacticForm());
1703 return;
1704 }
1705
1706 VisitExpr(S);
1707}
1708
1709void StmtProfiler::VisitDesignatedInitExpr(const DesignatedInitExpr *S) {
1710 VisitExpr(S);
1711 ID.AddBoolean(B: S->usesGNUSyntax());
1712 for (const DesignatedInitExpr::Designator &D : S->designators()) {
1713 if (D.isFieldDesignator()) {
1714 ID.AddInteger(I: 0);
1715 VisitName(Name: D.getFieldName());
1716 continue;
1717 }
1718
1719 if (D.isArrayDesignator()) {
1720 ID.AddInteger(I: 1);
1721 } else {
1722 assert(D.isArrayRangeDesignator());
1723 ID.AddInteger(I: 2);
1724 }
1725 ID.AddInteger(I: D.getArrayIndex());
1726 }
1727}
1728
1729// Seems that if VisitInitListExpr() only works on the syntactic form of an
1730// InitListExpr, then a DesignatedInitUpdateExpr is not encountered.
1731void StmtProfiler::VisitDesignatedInitUpdateExpr(
1732 const DesignatedInitUpdateExpr *S) {
1733 llvm_unreachable("Unexpected DesignatedInitUpdateExpr in syntactic form of "
1734 "initializer");
1735}
1736
1737void StmtProfiler::VisitArrayInitLoopExpr(const ArrayInitLoopExpr *S) {
1738 VisitExpr(S);
1739}
1740
1741void StmtProfiler::VisitArrayInitIndexExpr(const ArrayInitIndexExpr *S) {
1742 VisitExpr(S);
1743}
1744
1745void StmtProfiler::VisitNoInitExpr(const NoInitExpr *S) {
1746 llvm_unreachable("Unexpected NoInitExpr in syntactic form of initializer");
1747}
1748
1749void StmtProfiler::VisitImplicitValueInitExpr(const ImplicitValueInitExpr *S) {
1750 VisitExpr(S);
1751}
1752
1753void StmtProfiler::VisitExtVectorElementExpr(const ExtVectorElementExpr *S) {
1754 VisitExpr(S);
1755 VisitName(Name: &S->getAccessor());
1756}
1757
1758void StmtProfiler::VisitMatrixElementExpr(const MatrixElementExpr *S) {
1759 VisitExpr(S);
1760 VisitName(Name: &S->getAccessor());
1761}
1762
1763void StmtProfiler::VisitBlockExpr(const BlockExpr *S) {
1764 VisitExpr(S);
1765 VisitDecl(D: S->getBlockDecl());
1766}
1767
1768void StmtProfiler::VisitGenericSelectionExpr(const GenericSelectionExpr *S) {
1769 VisitExpr(S);
1770 for (const GenericSelectionExpr::ConstAssociation Assoc :
1771 S->associations()) {
1772 QualType T = Assoc.getType();
1773 if (T.isNull())
1774 ID.AddPointer(Ptr: nullptr);
1775 else
1776 VisitType(T);
1777 VisitExpr(S: Assoc.getAssociationExpr());
1778 }
1779}
1780
1781void StmtProfiler::VisitPseudoObjectExpr(const PseudoObjectExpr *S) {
1782 VisitExpr(S);
1783 for (PseudoObjectExpr::const_semantics_iterator
1784 i = S->semantics_begin(), e = S->semantics_end(); i != e; ++i)
1785 // Normally, we would not profile the source expressions of OVEs.
1786 if (const OpaqueValueExpr *OVE = dyn_cast<OpaqueValueExpr>(Val: *i))
1787 Visit(S: OVE->getSourceExpr());
1788}
1789
1790void StmtProfiler::VisitAtomicExpr(const AtomicExpr *S) {
1791 VisitExpr(S);
1792 ID.AddInteger(I: S->getOp());
1793}
1794
1795void StmtProfiler::VisitConceptSpecializationExpr(
1796 const ConceptSpecializationExpr *S) {
1797 VisitExpr(S);
1798 VisitTemplateName(Name: S->getNamedConcept());
1799 for (const TemplateArgument &Arg : S->getTemplateArguments())
1800 VisitTemplateArgument(Arg);
1801}
1802
1803void StmtProfiler::VisitRequiresExpr(const RequiresExpr *S) {
1804 VisitExpr(S);
1805 ID.AddInteger(I: S->getLocalParameters().size());
1806 for (ParmVarDecl *LocalParam : S->getLocalParameters())
1807 VisitDecl(D: LocalParam);
1808 ID.AddInteger(I: S->getRequirements().size());
1809 for (concepts::Requirement *Req : S->getRequirements()) {
1810 if (auto *TypeReq = dyn_cast<concepts::TypeRequirement>(Val: Req)) {
1811 ID.AddInteger(I: concepts::Requirement::RK_Type);
1812 ID.AddBoolean(B: TypeReq->isSubstitutionFailure());
1813 if (!TypeReq->isSubstitutionFailure())
1814 VisitType(T: TypeReq->getType()->getType());
1815 } else if (auto *ExprReq = dyn_cast<concepts::ExprRequirement>(Val: Req)) {
1816 ID.AddInteger(I: concepts::Requirement::RK_Compound);
1817 ID.AddBoolean(B: ExprReq->isExprSubstitutionFailure());
1818 if (!ExprReq->isExprSubstitutionFailure())
1819 Visit(S: ExprReq->getExpr());
1820 // C++2a [expr.prim.req.compound]p1 Example:
1821 // [...] The compound-requirement in C1 requires that x++ is a valid
1822 // expression. It is equivalent to the simple-requirement x++; [...]
1823 // We therefore do not profile isSimple() here.
1824 ID.AddBoolean(B: ExprReq->getNoexceptLoc().isValid());
1825 const concepts::ExprRequirement::ReturnTypeRequirement &RetReq =
1826 ExprReq->getReturnTypeRequirement();
1827 if (RetReq.isEmpty()) {
1828 ID.AddInteger(I: 0);
1829 } else if (RetReq.isTypeConstraint()) {
1830 ID.AddInteger(I: 1);
1831 Visit(S: RetReq.getTypeConstraint()->getImmediatelyDeclaredConstraint());
1832 } else {
1833 assert(RetReq.isSubstitutionFailure());
1834 ID.AddInteger(I: 2);
1835 }
1836 } else {
1837 ID.AddInteger(I: concepts::Requirement::RK_Nested);
1838 auto *NestedReq = cast<concepts::NestedRequirement>(Val: Req);
1839 ID.AddBoolean(B: NestedReq->hasInvalidConstraint());
1840 if (!NestedReq->hasInvalidConstraint())
1841 Visit(S: NestedReq->getConstraintExpr());
1842 }
1843 }
1844}
1845
1846static Stmt::StmtClass DecodeOperatorCall(const CXXOperatorCallExpr *S,
1847 UnaryOperatorKind &UnaryOp,
1848 BinaryOperatorKind &BinaryOp,
1849 unsigned &NumArgs) {
1850 switch (S->getOperator()) {
1851 case OO_None:
1852 case OO_New:
1853 case OO_Delete:
1854 case OO_Array_New:
1855 case OO_Array_Delete:
1856 case OO_Arrow:
1857 case OO_Conditional:
1858 case NUM_OVERLOADED_OPERATORS:
1859 llvm_unreachable("Invalid operator call kind");
1860
1861 case OO_Plus:
1862 if (NumArgs == 1) {
1863 UnaryOp = UO_Plus;
1864 return Stmt::UnaryOperatorClass;
1865 }
1866
1867 BinaryOp = BO_Add;
1868 return Stmt::BinaryOperatorClass;
1869
1870 case OO_Minus:
1871 if (NumArgs == 1) {
1872 UnaryOp = UO_Minus;
1873 return Stmt::UnaryOperatorClass;
1874 }
1875
1876 BinaryOp = BO_Sub;
1877 return Stmt::BinaryOperatorClass;
1878
1879 case OO_Star:
1880 if (NumArgs == 1) {
1881 UnaryOp = UO_Deref;
1882 return Stmt::UnaryOperatorClass;
1883 }
1884
1885 BinaryOp = BO_Mul;
1886 return Stmt::BinaryOperatorClass;
1887
1888 case OO_Slash:
1889 BinaryOp = BO_Div;
1890 return Stmt::BinaryOperatorClass;
1891
1892 case OO_Percent:
1893 BinaryOp = BO_Rem;
1894 return Stmt::BinaryOperatorClass;
1895
1896 case OO_Caret:
1897 BinaryOp = BO_Xor;
1898 return Stmt::BinaryOperatorClass;
1899
1900 case OO_Amp:
1901 if (NumArgs == 1) {
1902 UnaryOp = UO_AddrOf;
1903 return Stmt::UnaryOperatorClass;
1904 }
1905
1906 BinaryOp = BO_And;
1907 return Stmt::BinaryOperatorClass;
1908
1909 case OO_Pipe:
1910 BinaryOp = BO_Or;
1911 return Stmt::BinaryOperatorClass;
1912
1913 case OO_Tilde:
1914 UnaryOp = UO_Not;
1915 return Stmt::UnaryOperatorClass;
1916
1917 case OO_Exclaim:
1918 UnaryOp = UO_LNot;
1919 return Stmt::UnaryOperatorClass;
1920
1921 case OO_Equal:
1922 BinaryOp = BO_Assign;
1923 return Stmt::BinaryOperatorClass;
1924
1925 case OO_Less:
1926 BinaryOp = BO_LT;
1927 return Stmt::BinaryOperatorClass;
1928
1929 case OO_Greater:
1930 BinaryOp = BO_GT;
1931 return Stmt::BinaryOperatorClass;
1932
1933 case OO_PlusEqual:
1934 BinaryOp = BO_AddAssign;
1935 return Stmt::CompoundAssignOperatorClass;
1936
1937 case OO_MinusEqual:
1938 BinaryOp = BO_SubAssign;
1939 return Stmt::CompoundAssignOperatorClass;
1940
1941 case OO_StarEqual:
1942 BinaryOp = BO_MulAssign;
1943 return Stmt::CompoundAssignOperatorClass;
1944
1945 case OO_SlashEqual:
1946 BinaryOp = BO_DivAssign;
1947 return Stmt::CompoundAssignOperatorClass;
1948
1949 case OO_PercentEqual:
1950 BinaryOp = BO_RemAssign;
1951 return Stmt::CompoundAssignOperatorClass;
1952
1953 case OO_CaretEqual:
1954 BinaryOp = BO_XorAssign;
1955 return Stmt::CompoundAssignOperatorClass;
1956
1957 case OO_AmpEqual:
1958 BinaryOp = BO_AndAssign;
1959 return Stmt::CompoundAssignOperatorClass;
1960
1961 case OO_PipeEqual:
1962 BinaryOp = BO_OrAssign;
1963 return Stmt::CompoundAssignOperatorClass;
1964
1965 case OO_LessLess:
1966 BinaryOp = BO_Shl;
1967 return Stmt::BinaryOperatorClass;
1968
1969 case OO_GreaterGreater:
1970 BinaryOp = BO_Shr;
1971 return Stmt::BinaryOperatorClass;
1972
1973 case OO_LessLessEqual:
1974 BinaryOp = BO_ShlAssign;
1975 return Stmt::CompoundAssignOperatorClass;
1976
1977 case OO_GreaterGreaterEqual:
1978 BinaryOp = BO_ShrAssign;
1979 return Stmt::CompoundAssignOperatorClass;
1980
1981 case OO_EqualEqual:
1982 BinaryOp = BO_EQ;
1983 return Stmt::BinaryOperatorClass;
1984
1985 case OO_ExclaimEqual:
1986 BinaryOp = BO_NE;
1987 return Stmt::BinaryOperatorClass;
1988
1989 case OO_LessEqual:
1990 BinaryOp = BO_LE;
1991 return Stmt::BinaryOperatorClass;
1992
1993 case OO_GreaterEqual:
1994 BinaryOp = BO_GE;
1995 return Stmt::BinaryOperatorClass;
1996
1997 case OO_Spaceship:
1998 BinaryOp = BO_Cmp;
1999 return Stmt::BinaryOperatorClass;
2000
2001 case OO_AmpAmp:
2002 BinaryOp = BO_LAnd;
2003 return Stmt::BinaryOperatorClass;
2004
2005 case OO_PipePipe:
2006 BinaryOp = BO_LOr;
2007 return Stmt::BinaryOperatorClass;
2008
2009 case OO_PlusPlus:
2010 UnaryOp = NumArgs == 1 ? UO_PreInc : UO_PostInc;
2011 NumArgs = 1;
2012 return Stmt::UnaryOperatorClass;
2013
2014 case OO_MinusMinus:
2015 UnaryOp = NumArgs == 1 ? UO_PreDec : UO_PostDec;
2016 NumArgs = 1;
2017 return Stmt::UnaryOperatorClass;
2018
2019 case OO_Comma:
2020 BinaryOp = BO_Comma;
2021 return Stmt::BinaryOperatorClass;
2022
2023 case OO_ArrowStar:
2024 BinaryOp = BO_PtrMemI;
2025 return Stmt::BinaryOperatorClass;
2026
2027 case OO_Subscript:
2028 return Stmt::ArraySubscriptExprClass;
2029
2030 case OO_Call:
2031 return Stmt::CallExprClass;
2032
2033 case OO_Coawait:
2034 UnaryOp = UO_Coawait;
2035 return Stmt::UnaryOperatorClass;
2036 }
2037
2038 llvm_unreachable("Invalid overloaded operator expression");
2039}
2040
2041#if defined(_MSC_VER) && !defined(__clang__)
2042#if _MSC_VER == 1911
2043// Work around https://developercommunity.visualstudio.com/content/problem/84002/clang-cl-when-built-with-vc-2017-crashes-cause-vc.html
2044// MSVC 2017 update 3 miscompiles this function, and a clang built with it
2045// will crash in stage 2 of a bootstrap build.
2046#pragma optimize("", off)
2047#endif
2048#endif
2049
2050void StmtProfiler::VisitCXXOperatorCallExpr(const CXXOperatorCallExpr *S) {
2051 if (S->isTypeDependent()) {
2052 // Type-dependent operator calls are profiled like their underlying
2053 // syntactic operator.
2054 //
2055 // An operator call to operator-> is always implicit, so just skip it. The
2056 // enclosing MemberExpr will profile the actual member access.
2057 if (S->getOperator() == OO_Arrow)
2058 return Visit(S: S->getArg(Arg: 0));
2059
2060 UnaryOperatorKind UnaryOp = UO_Extension;
2061 BinaryOperatorKind BinaryOp = BO_Comma;
2062 unsigned NumArgs = S->getNumArgs();
2063 Stmt::StmtClass SC = DecodeOperatorCall(S, UnaryOp, BinaryOp, NumArgs);
2064
2065 ID.AddInteger(I: SC);
2066 for (unsigned I = 0; I != NumArgs; ++I)
2067 Visit(S: S->getArg(Arg: I));
2068 if (SC == Stmt::UnaryOperatorClass)
2069 ID.AddInteger(I: UnaryOp);
2070 else if (SC == Stmt::BinaryOperatorClass ||
2071 SC == Stmt::CompoundAssignOperatorClass)
2072 ID.AddInteger(I: BinaryOp);
2073 else
2074 assert(SC == Stmt::ArraySubscriptExprClass || SC == Stmt::CallExprClass);
2075
2076 return;
2077 }
2078
2079 VisitCallExpr(S);
2080 ID.AddInteger(I: S->getOperator());
2081}
2082
2083void StmtProfiler::VisitCXXRewrittenBinaryOperator(
2084 const CXXRewrittenBinaryOperator *S) {
2085 // If a rewritten operator were ever to be type-dependent, we should profile
2086 // it following its syntactic operator.
2087 assert(!S->isTypeDependent() &&
2088 "resolved rewritten operator should never be type-dependent");
2089 ID.AddBoolean(B: S->isReversed());
2090 VisitExpr(S: S->getSemanticForm());
2091}
2092
2093#if defined(_MSC_VER) && !defined(__clang__)
2094#if _MSC_VER == 1911
2095#pragma optimize("", on)
2096#endif
2097#endif
2098
2099void StmtProfiler::VisitCXXMemberCallExpr(const CXXMemberCallExpr *S) {
2100 VisitCallExpr(S);
2101}
2102
2103void StmtProfiler::VisitCUDAKernelCallExpr(const CUDAKernelCallExpr *S) {
2104 VisitCallExpr(S);
2105}
2106
2107void StmtProfiler::VisitAsTypeExpr(const AsTypeExpr *S) {
2108 VisitExpr(S);
2109}
2110
2111void StmtProfiler::VisitCXXNamedCastExpr(const CXXNamedCastExpr *S) {
2112 VisitExplicitCastExpr(S);
2113}
2114
2115void StmtProfiler::VisitCXXStaticCastExpr(const CXXStaticCastExpr *S) {
2116 VisitCXXNamedCastExpr(S);
2117}
2118
2119void StmtProfiler::VisitCXXDynamicCastExpr(const CXXDynamicCastExpr *S) {
2120 VisitCXXNamedCastExpr(S);
2121}
2122
2123void
2124StmtProfiler::VisitCXXReinterpretCastExpr(const CXXReinterpretCastExpr *S) {
2125 VisitCXXNamedCastExpr(S);
2126}
2127
2128void StmtProfiler::VisitCXXConstCastExpr(const CXXConstCastExpr *S) {
2129 VisitCXXNamedCastExpr(S);
2130}
2131
2132void StmtProfiler::VisitBuiltinBitCastExpr(const BuiltinBitCastExpr *S) {
2133 VisitExpr(S);
2134 VisitType(T: S->getTypeInfoAsWritten()->getType());
2135}
2136
2137void StmtProfiler::VisitCXXAddrspaceCastExpr(const CXXAddrspaceCastExpr *S) {
2138 VisitCXXNamedCastExpr(S);
2139}
2140
2141void StmtProfiler::VisitUserDefinedLiteral(const UserDefinedLiteral *S) {
2142 VisitCallExpr(S);
2143}
2144
2145void StmtProfiler::VisitCXXBoolLiteralExpr(const CXXBoolLiteralExpr *S) {
2146 VisitExpr(S);
2147 ID.AddBoolean(B: S->getValue());
2148}
2149
2150void StmtProfiler::VisitCXXNullPtrLiteralExpr(const CXXNullPtrLiteralExpr *S) {
2151 VisitExpr(S);
2152}
2153
2154void StmtProfiler::VisitCXXStdInitializerListExpr(
2155 const CXXStdInitializerListExpr *S) {
2156 VisitExpr(S);
2157}
2158
2159void StmtProfiler::VisitCXXTypeidExpr(const CXXTypeidExpr *S) {
2160 VisitExpr(S);
2161 if (S->isTypeOperand())
2162 VisitType(T: S->getTypeOperandSourceInfo()->getType());
2163}
2164
2165void StmtProfiler::VisitCXXUuidofExpr(const CXXUuidofExpr *S) {
2166 VisitExpr(S);
2167 if (S->isTypeOperand())
2168 VisitType(T: S->getTypeOperandSourceInfo()->getType());
2169}
2170
2171void StmtProfiler::VisitMSPropertyRefExpr(const MSPropertyRefExpr *S) {
2172 VisitExpr(S);
2173 VisitDecl(D: S->getPropertyDecl());
2174}
2175
2176void StmtProfiler::VisitMSPropertySubscriptExpr(
2177 const MSPropertySubscriptExpr *S) {
2178 VisitExpr(S);
2179}
2180
2181void StmtProfiler::VisitCXXThisExpr(const CXXThisExpr *S) {
2182 VisitExpr(S);
2183 ID.AddBoolean(B: S->isImplicit());
2184 ID.AddBoolean(B: S->isCapturedByCopyInLambdaWithExplicitObjectParameter());
2185}
2186
2187void StmtProfiler::VisitCXXThrowExpr(const CXXThrowExpr *S) {
2188 VisitExpr(S);
2189}
2190
2191void StmtProfiler::VisitCXXDefaultArgExpr(const CXXDefaultArgExpr *S) {
2192 VisitExpr(S);
2193 VisitDecl(D: S->getParam());
2194}
2195
2196void StmtProfiler::VisitCXXDefaultInitExpr(const CXXDefaultInitExpr *S) {
2197 VisitExpr(S);
2198 VisitDecl(D: S->getField());
2199}
2200
2201void StmtProfiler::VisitCXXBindTemporaryExpr(const CXXBindTemporaryExpr *S) {
2202 VisitExpr(S);
2203 VisitDecl(
2204 D: const_cast<CXXDestructorDecl *>(S->getTemporary()->getDestructor()));
2205}
2206
2207void StmtProfiler::VisitCXXConstructExpr(const CXXConstructExpr *S) {
2208 VisitExpr(S);
2209 VisitDecl(D: S->getConstructor());
2210 ID.AddBoolean(B: S->isElidable());
2211}
2212
2213void StmtProfiler::VisitCXXInheritedCtorInitExpr(
2214 const CXXInheritedCtorInitExpr *S) {
2215 VisitExpr(S);
2216 VisitDecl(D: S->getConstructor());
2217}
2218
2219void StmtProfiler::VisitCXXFunctionalCastExpr(const CXXFunctionalCastExpr *S) {
2220 VisitExplicitCastExpr(S);
2221}
2222
2223void
2224StmtProfiler::VisitCXXTemporaryObjectExpr(const CXXTemporaryObjectExpr *S) {
2225 VisitCXXConstructExpr(S);
2226}
2227
2228void
2229StmtProfiler::VisitLambdaExpr(const LambdaExpr *S) {
2230 if (!ProfileLambdaExpr) {
2231 // Do not recursively visit the children of this expression. Profiling the
2232 // body would result in unnecessary work, and is not safe to do during
2233 // deserialization.
2234 VisitStmtNoChildren(S);
2235
2236 // C++20 [temp.over.link]p5:
2237 // Two lambda-expressions are never considered equivalent.
2238 VisitDecl(D: S->getLambdaClass());
2239
2240 return;
2241 }
2242
2243 CXXRecordDecl *Lambda = S->getLambdaClass();
2244 for (const auto &Capture : Lambda->captures()) {
2245 ID.AddInteger(I: Capture.getCaptureKind());
2246 if (Capture.capturesVariable())
2247 VisitDecl(D: Capture.getCapturedVar());
2248 }
2249
2250 // Profiling the body of the lambda may be dangerous during deserialization.
2251 // So we'd like only to profile the signature here.
2252 ODRHash Hasher;
2253 // FIXME: We can't get the operator call easily by
2254 // `CXXRecordDecl::getLambdaCallOperator()` if we're in deserialization.
2255 // So we have to do something raw here.
2256 for (auto *SubDecl : Lambda->decls()) {
2257 FunctionDecl *Call = nullptr;
2258 if (auto *FTD = dyn_cast<FunctionTemplateDecl>(Val: SubDecl))
2259 Call = FTD->getTemplatedDecl();
2260 else if (auto *FD = dyn_cast<FunctionDecl>(Val: SubDecl))
2261 Call = FD;
2262
2263 // Ignore implicit conversion functions and __invoke. They are not
2264 // part of the lambda signature.
2265 // Semantically, it is better to use `getLambdaCallOperator` but that may
2266 // not be properly deserialized yet.
2267 if (!Call || Call->getOverloadedOperator() != OO_Call)
2268 continue;
2269
2270 Hasher.AddFunctionDecl(Function: Call, /*SkipBody=*/true);
2271 }
2272 ID.AddInteger(I: Hasher.CalculateHash());
2273}
2274
2275void StmtProfiler::VisitCXXReflectExpr(const CXXReflectExpr *E) {
2276 // TODO(Reflection): Add support for Null, TypeSourceInfo,
2277 // TemplateReference and DeclRefExpr
2278 VisitExpr(S: E);
2279 ID.AddInteger(I: static_cast<int>(E->getKind()));
2280 switch (E->getKind()) {
2281 case ReflectionKind::Null:
2282 assert(false && "null reflection can't be constructed from parsing a "
2283 "reflection operand");
2284 return;
2285 case ReflectionKind::Type: {
2286 QualType QT = E->getTypeSourceInfo()->getType();
2287 if (isTypeAliasAsReflectionName(QT)) {
2288 if (const auto *TDT = QT->getAs<TypedefType>()) {
2289 ID.AddBoolean(B: true);
2290 VisitDecl(D: TDT->getDecl()->getCanonicalDecl());
2291 return;
2292 }
2293 }
2294 ID.AddBoolean(B: false);
2295 VisitType(T: QT);
2296 return;
2297 }
2298 }
2299 assert(false && "unknown or unimplemented reflection entities");
2300}
2301
2302void
2303StmtProfiler::VisitCXXScalarValueInitExpr(const CXXScalarValueInitExpr *S) {
2304 VisitExpr(S);
2305}
2306
2307void StmtProfiler::VisitCXXDeleteExpr(const CXXDeleteExpr *S) {
2308 VisitExpr(S);
2309 ID.AddBoolean(B: S->isGlobalDelete());
2310 ID.AddBoolean(B: S->isArrayForm());
2311 VisitDecl(D: S->getOperatorDelete());
2312}
2313
2314void StmtProfiler::VisitCXXNewExpr(const CXXNewExpr *S) {
2315 VisitExpr(S);
2316 VisitType(T: S->getAllocatedType());
2317 VisitDecl(D: S->getOperatorNew());
2318 VisitDecl(D: S->getOperatorDelete());
2319 ID.AddBoolean(B: S->isArray());
2320 ID.AddInteger(I: S->getNumPlacementArgs());
2321 ID.AddBoolean(B: S->isGlobalNew());
2322 ID.AddBoolean(B: S->isParenTypeId());
2323 ID.AddInteger(I: llvm::to_underlying(E: S->getInitializationStyle()));
2324}
2325
2326void
2327StmtProfiler::VisitCXXPseudoDestructorExpr(const CXXPseudoDestructorExpr *S) {
2328 VisitExpr(S);
2329 ID.AddBoolean(B: S->isArrow());
2330 VisitNestedNameSpecifier(NNS: S->getQualifier());
2331 ID.AddBoolean(B: S->getScopeTypeInfo() != nullptr);
2332 if (S->getScopeTypeInfo())
2333 VisitType(T: S->getScopeTypeInfo()->getType());
2334 ID.AddBoolean(B: S->getDestroyedTypeInfo() != nullptr);
2335 if (S->getDestroyedTypeInfo())
2336 VisitType(T: S->getDestroyedType());
2337 else
2338 VisitIdentifierInfo(II: S->getDestroyedTypeIdentifier());
2339}
2340
2341void StmtProfiler::VisitOverloadExpr(const OverloadExpr *S) {
2342 VisitExpr(S);
2343 bool DescribingDependentVarTemplate =
2344 S->getNumDecls() == 1 && isa<VarTemplateDecl>(Val: *S->decls_begin());
2345 if (DescribingDependentVarTemplate) {
2346 VisitDecl(D: *S->decls_begin());
2347 } else {
2348 VisitNestedNameSpecifier(NNS: S->getQualifier());
2349 VisitName(Name: S->getName(), /*TreatAsDecl*/ true);
2350 }
2351 ID.AddBoolean(B: S->hasExplicitTemplateArgs());
2352 if (S->hasExplicitTemplateArgs())
2353 VisitTemplateArguments(Args: S->getTemplateArgs(), NumArgs: S->getNumTemplateArgs());
2354}
2355
2356void
2357StmtProfiler::VisitUnresolvedLookupExpr(const UnresolvedLookupExpr *S) {
2358 VisitOverloadExpr(S);
2359}
2360
2361void StmtProfiler::VisitTypeTraitExpr(const TypeTraitExpr *S) {
2362 VisitExpr(S);
2363 ID.AddInteger(I: S->getTrait());
2364 ID.AddInteger(I: S->getNumArgs());
2365 for (unsigned I = 0, N = S->getNumArgs(); I != N; ++I)
2366 VisitType(T: S->getArg(I)->getType());
2367}
2368
2369void StmtProfiler::VisitArrayTypeTraitExpr(const ArrayTypeTraitExpr *S) {
2370 VisitExpr(S);
2371 ID.AddInteger(I: S->getTrait());
2372 VisitType(T: S->getQueriedType());
2373}
2374
2375void StmtProfiler::VisitExpressionTraitExpr(const ExpressionTraitExpr *S) {
2376 VisitExpr(S);
2377 ID.AddInteger(I: S->getTrait());
2378 VisitExpr(S: S->getQueriedExpression());
2379}
2380
2381void StmtProfiler::VisitDependentScopeDeclRefExpr(
2382 const DependentScopeDeclRefExpr *S) {
2383 VisitExpr(S);
2384 VisitName(Name: S->getDeclName());
2385 VisitNestedNameSpecifier(NNS: S->getQualifier());
2386 ID.AddBoolean(B: S->hasExplicitTemplateArgs());
2387 if (S->hasExplicitTemplateArgs())
2388 VisitTemplateArguments(Args: S->getTemplateArgs(), NumArgs: S->getNumTemplateArgs());
2389}
2390
2391void StmtProfiler::VisitExprWithCleanups(const ExprWithCleanups *S) {
2392 VisitExpr(S);
2393}
2394
2395void StmtProfiler::VisitCXXUnresolvedConstructExpr(
2396 const CXXUnresolvedConstructExpr *S) {
2397 VisitExpr(S);
2398 VisitType(T: S->getTypeAsWritten());
2399 ID.AddInteger(I: S->isListInitialization());
2400}
2401
2402void StmtProfiler::VisitDependentTemplateIdExpr(
2403 const DependentTemplateIdExpr *S) {
2404 VisitExpr(S);
2405 VisitTemplateName(Name: S->getTemplateName());
2406 VisitTemplateArguments(Args: S->template_arguments().data(),
2407 NumArgs: S->getNumTemplateArgs());
2408}
2409
2410void StmtProfiler::VisitCXXDependentScopeMemberExpr(
2411 const CXXDependentScopeMemberExpr *S) {
2412 ID.AddBoolean(B: S->isImplicitAccess());
2413 if (!S->isImplicitAccess()) {
2414 VisitExpr(S);
2415 ID.AddBoolean(B: S->isArrow());
2416 }
2417 VisitNestedNameSpecifier(NNS: S->getQualifier());
2418 VisitName(Name: S->getMember());
2419 ID.AddBoolean(B: S->hasExplicitTemplateArgs());
2420 if (S->hasExplicitTemplateArgs())
2421 VisitTemplateArguments(Args: S->getTemplateArgs(), NumArgs: S->getNumTemplateArgs());
2422}
2423
2424void StmtProfiler::VisitUnresolvedMemberExpr(const UnresolvedMemberExpr *S) {
2425 ID.AddBoolean(B: S->isImplicitAccess());
2426 if (!S->isImplicitAccess()) {
2427 VisitExpr(S);
2428 ID.AddBoolean(B: S->isArrow());
2429 }
2430 VisitNestedNameSpecifier(NNS: S->getQualifier());
2431 VisitName(Name: S->getMemberName());
2432 ID.AddBoolean(B: S->hasExplicitTemplateArgs());
2433 if (S->hasExplicitTemplateArgs())
2434 VisitTemplateArguments(Args: S->getTemplateArgs(), NumArgs: S->getNumTemplateArgs());
2435}
2436
2437void StmtProfiler::VisitCXXNoexceptExpr(const CXXNoexceptExpr *S) {
2438 VisitExpr(S);
2439}
2440
2441void StmtProfiler::VisitPackExpansionExpr(const PackExpansionExpr *S) {
2442 VisitExpr(S);
2443}
2444
2445void StmtProfiler::VisitSizeOfPackExpr(const SizeOfPackExpr *S) {
2446 VisitExpr(S);
2447 if (S->isPartiallySubstituted()) {
2448 auto Args = S->getPartialArguments();
2449 ID.AddInteger(I: Args.size());
2450 for (const auto &TA : Args)
2451 VisitTemplateArgument(Arg: TA);
2452 } else {
2453 VisitDecl(D: S->getPack());
2454 ID.AddInteger(I: 0);
2455 }
2456}
2457
2458void StmtProfiler::VisitPackIndexingExpr(const PackIndexingExpr *E) {
2459 VisitStmtNoChildren(S: E);
2460 Visit(S: E->getIndexExpr());
2461 if (E->expandsToEmptyPack() || E->getExpressions().size() != 0) {
2462 ID.AddInteger(I: E->getExpressions().size());
2463 for (const Expr *Sub : E->getExpressions())
2464 Visit(S: Sub);
2465 } else {
2466 Visit(S: E->getPackIdExpression());
2467 }
2468}
2469
2470void StmtProfiler::VisitSubstNonTypeTemplateParmPackExpr(
2471 const SubstNonTypeTemplateParmPackExpr *S) {
2472 VisitExpr(S);
2473 VisitDecl(D: S->getParameterPack());
2474 VisitTemplateArgument(Arg: S->getArgumentPack());
2475}
2476
2477void StmtProfiler::VisitSubstNonTypeTemplateParmExpr(
2478 const SubstNonTypeTemplateParmExpr *E) {
2479 // Profile exactly as the replacement expression.
2480 Visit(S: E->getReplacement());
2481}
2482
2483void StmtProfiler::VisitFunctionParmPackExpr(const FunctionParmPackExpr *S) {
2484 VisitExpr(S);
2485 VisitDecl(D: S->getParameterPack());
2486 ID.AddInteger(I: S->getNumExpansions());
2487 for (FunctionParmPackExpr::iterator I = S->begin(), E = S->end(); I != E; ++I)
2488 VisitDecl(D: *I);
2489}
2490
2491void StmtProfiler::VisitMaterializeTemporaryExpr(
2492 const MaterializeTemporaryExpr *S) {
2493 VisitExpr(S);
2494}
2495
2496void StmtProfiler::VisitCXXFoldExpr(const CXXFoldExpr *S) {
2497 VisitStmtNoChildren(S);
2498 // The callee sub-expression is not part of how the expression is written,
2499 // so it's not added to the profile.
2500 //
2501 // Example:
2502 // template <typename... T> requires ((sizeof(T) > 0) && ...) void f() {}
2503 // class A;
2504 // void operator&&(A, A);
2505 // template <typename... T> requires ((sizeof(T) > 0) && ...) void f() {}
2506 //
2507 // Both definitions have identically written fold expressions, but semantic
2508 // analysis adds the overloaded operator to the second one.
2509 if (S->getLHS())
2510 Visit(S: S->getLHS());
2511 else
2512 ID.AddInteger(I: 0);
2513 if (S->getRHS())
2514 Visit(S: S->getRHS());
2515 else
2516 ID.AddInteger(I: 0);
2517 ID.AddInteger(I: S->getOperator());
2518}
2519
2520void StmtProfiler::VisitCXXParenListInitExpr(const CXXParenListInitExpr *S) {
2521 VisitExpr(S);
2522}
2523
2524void StmtProfiler::VisitCoroutineBodyStmt(const CoroutineBodyStmt *S) {
2525 VisitStmt(S);
2526}
2527
2528void StmtProfiler::VisitCoreturnStmt(const CoreturnStmt *S) {
2529 VisitStmt(S);
2530}
2531
2532void StmtProfiler::VisitCoawaitExpr(const CoawaitExpr *S) {
2533 VisitExpr(S);
2534}
2535
2536void StmtProfiler::VisitDependentCoawaitExpr(const DependentCoawaitExpr *S) {
2537 VisitExpr(S);
2538}
2539
2540void StmtProfiler::VisitCoyieldExpr(const CoyieldExpr *S) {
2541 VisitExpr(S);
2542}
2543
2544void StmtProfiler::VisitOpaqueValueExpr(const OpaqueValueExpr *E) {
2545 VisitExpr(S: E);
2546}
2547
2548void StmtProfiler::VisitSourceLocExpr(const SourceLocExpr *E) {
2549 VisitExpr(S: E);
2550}
2551
2552void StmtProfiler::VisitEmbedExpr(const EmbedExpr *E) { VisitExpr(S: E); }
2553
2554void StmtProfiler::VisitCXXExpansionSelectExpr(
2555 const CXXExpansionSelectExpr *E) {
2556 VisitExpr(S: E);
2557}
2558
2559void StmtProfiler::VisitRecoveryExpr(const RecoveryExpr *E) { VisitExpr(S: E); }
2560
2561void StmtProfiler::VisitObjCObjectLiteral(const ObjCObjectLiteral *E) {
2562 VisitExpr(S: E);
2563}
2564
2565void StmtProfiler::VisitObjCStringLiteral(const ObjCStringLiteral *S) {
2566 VisitObjCObjectLiteral(E: S);
2567}
2568
2569void StmtProfiler::VisitObjCBoxedExpr(const ObjCBoxedExpr *E) {
2570 VisitObjCObjectLiteral(E);
2571}
2572
2573void StmtProfiler::VisitObjCArrayLiteral(const ObjCArrayLiteral *E) {
2574 VisitObjCObjectLiteral(E);
2575}
2576
2577void StmtProfiler::VisitObjCDictionaryLiteral(const ObjCDictionaryLiteral *E) {
2578 VisitObjCObjectLiteral(E);
2579}
2580
2581void StmtProfiler::VisitObjCEncodeExpr(const ObjCEncodeExpr *S) {
2582 VisitExpr(S);
2583 VisitType(T: S->getEncodedType());
2584}
2585
2586void StmtProfiler::VisitObjCSelectorExpr(const ObjCSelectorExpr *S) {
2587 VisitExpr(S);
2588 VisitName(Name: S->getSelector());
2589}
2590
2591void StmtProfiler::VisitObjCProtocolExpr(const ObjCProtocolExpr *S) {
2592 VisitExpr(S);
2593 VisitDecl(D: S->getProtocol());
2594}
2595
2596void StmtProfiler::VisitObjCIvarRefExpr(const ObjCIvarRefExpr *S) {
2597 VisitExpr(S);
2598 VisitDecl(D: S->getDecl());
2599 ID.AddBoolean(B: S->isArrow());
2600 ID.AddBoolean(B: S->isFreeIvar());
2601}
2602
2603void StmtProfiler::VisitObjCPropertyRefExpr(const ObjCPropertyRefExpr *S) {
2604 VisitExpr(S);
2605 if (S->isImplicitProperty()) {
2606 VisitDecl(D: S->getImplicitPropertyGetter());
2607 VisitDecl(D: S->getImplicitPropertySetter());
2608 } else {
2609 VisitDecl(D: S->getExplicitProperty());
2610 }
2611 if (S->isSuperReceiver()) {
2612 ID.AddBoolean(B: S->isSuperReceiver());
2613 VisitType(T: S->getSuperReceiverType());
2614 }
2615}
2616
2617void StmtProfiler::VisitObjCSubscriptRefExpr(const ObjCSubscriptRefExpr *S) {
2618 VisitExpr(S);
2619 VisitDecl(D: S->getAtIndexMethodDecl());
2620 VisitDecl(D: S->setAtIndexMethodDecl());
2621}
2622
2623void StmtProfiler::VisitObjCMessageExpr(const ObjCMessageExpr *S) {
2624 VisitExpr(S);
2625 VisitName(Name: S->getSelector());
2626 VisitDecl(D: S->getMethodDecl());
2627}
2628
2629void StmtProfiler::VisitObjCIsaExpr(const ObjCIsaExpr *S) {
2630 VisitExpr(S);
2631 ID.AddBoolean(B: S->isArrow());
2632}
2633
2634void StmtProfiler::VisitObjCBoolLiteralExpr(const ObjCBoolLiteralExpr *S) {
2635 VisitExpr(S);
2636 ID.AddBoolean(B: S->getValue());
2637}
2638
2639void StmtProfiler::VisitObjCIndirectCopyRestoreExpr(
2640 const ObjCIndirectCopyRestoreExpr *S) {
2641 VisitExpr(S);
2642 ID.AddBoolean(B: S->shouldCopy());
2643}
2644
2645void StmtProfiler::VisitObjCBridgedCastExpr(const ObjCBridgedCastExpr *S) {
2646 VisitExplicitCastExpr(S);
2647 ID.AddBoolean(B: S->getBridgeKind());
2648}
2649
2650void StmtProfiler::VisitObjCAvailabilityCheckExpr(
2651 const ObjCAvailabilityCheckExpr *S) {
2652 VisitExpr(S);
2653}
2654
2655void StmtProfiler::VisitTemplateArguments(const TemplateArgumentLoc *Args,
2656 unsigned NumArgs) {
2657 ID.AddInteger(I: NumArgs);
2658 for (unsigned I = 0; I != NumArgs; ++I)
2659 VisitTemplateArgument(Arg: Args[I].getArgument());
2660}
2661
2662void StmtProfiler::VisitTemplateArgument(const TemplateArgument &Arg) {
2663 // Mostly repetitive with TemplateArgument::Profile!
2664 ID.AddInteger(I: Arg.getKind());
2665 switch (Arg.getKind()) {
2666 case TemplateArgument::Null:
2667 break;
2668
2669 case TemplateArgument::Type:
2670 VisitType(T: Arg.getAsType());
2671 break;
2672
2673 case TemplateArgument::Template:
2674 case TemplateArgument::TemplateExpansion:
2675 VisitTemplateName(Name: Arg.getAsTemplateOrTemplatePattern());
2676 break;
2677
2678 case TemplateArgument::Declaration:
2679 VisitType(T: Arg.getParamTypeForDecl());
2680 // FIXME: Do we need to recursively decompose template parameter objects?
2681 VisitDecl(D: Arg.getAsDecl());
2682 break;
2683
2684 case TemplateArgument::NullPtr:
2685 VisitType(T: Arg.getNullPtrType());
2686 break;
2687
2688 case TemplateArgument::Integral:
2689 VisitType(T: Arg.getIntegralType());
2690 Arg.getAsIntegral().Profile(ID);
2691 break;
2692
2693 case TemplateArgument::StructuralValue:
2694 VisitType(T: Arg.getStructuralValueType());
2695 // FIXME: Do we need to recursively decompose this ourselves?
2696 Arg.getAsStructuralValue().Profile(ID);
2697 break;
2698
2699 case TemplateArgument::Expression:
2700 Visit(S: Arg.getAsExpr());
2701 break;
2702
2703 case TemplateArgument::Pack:
2704 for (const auto &P : Arg.pack_elements())
2705 VisitTemplateArgument(Arg: P);
2706 break;
2707 }
2708}
2709
2710namespace {
2711class OpenACCClauseProfiler
2712 : public OpenACCClauseVisitor<OpenACCClauseProfiler> {
2713 StmtProfiler &Profiler;
2714
2715public:
2716 OpenACCClauseProfiler(StmtProfiler &P) : Profiler(P) {}
2717
2718 void VisitOpenACCClauseList(ArrayRef<const OpenACCClause *> Clauses) {
2719 for (const OpenACCClause *Clause : Clauses) {
2720 // TODO OpenACC: When we have clauses with expressions, we should
2721 // profile them too.
2722 Visit(C: Clause);
2723 }
2724 }
2725
2726 void VisitClauseWithVarList(const OpenACCClauseWithVarList &Clause) {
2727 for (auto *E : Clause.getVarList())
2728 Profiler.VisitStmt(S: E);
2729 }
2730
2731#define VISIT_CLAUSE(CLAUSE_NAME) \
2732 void Visit##CLAUSE_NAME##Clause(const OpenACC##CLAUSE_NAME##Clause &Clause);
2733
2734#include "clang/Basic/OpenACCClauses.def"
2735};
2736
2737/// Nothing to do here, there are no sub-statements.
2738void OpenACCClauseProfiler::VisitDefaultClause(
2739 const OpenACCDefaultClause &Clause) {}
2740
2741void OpenACCClauseProfiler::VisitIfClause(const OpenACCIfClause &Clause) {
2742 assert(Clause.hasConditionExpr() &&
2743 "if clause requires a valid condition expr");
2744 Profiler.VisitStmt(S: Clause.getConditionExpr());
2745}
2746
2747void OpenACCClauseProfiler::VisitCopyClause(const OpenACCCopyClause &Clause) {
2748 VisitClauseWithVarList(Clause);
2749}
2750
2751void OpenACCClauseProfiler::VisitLinkClause(const OpenACCLinkClause &Clause) {
2752 VisitClauseWithVarList(Clause);
2753}
2754
2755void OpenACCClauseProfiler::VisitDeviceResidentClause(
2756 const OpenACCDeviceResidentClause &Clause) {
2757 VisitClauseWithVarList(Clause);
2758}
2759
2760void OpenACCClauseProfiler::VisitCopyInClause(
2761 const OpenACCCopyInClause &Clause) {
2762 VisitClauseWithVarList(Clause);
2763}
2764
2765void OpenACCClauseProfiler::VisitCopyOutClause(
2766 const OpenACCCopyOutClause &Clause) {
2767 VisitClauseWithVarList(Clause);
2768}
2769
2770void OpenACCClauseProfiler::VisitCreateClause(
2771 const OpenACCCreateClause &Clause) {
2772 VisitClauseWithVarList(Clause);
2773}
2774
2775void OpenACCClauseProfiler::VisitHostClause(const OpenACCHostClause &Clause) {
2776 VisitClauseWithVarList(Clause);
2777}
2778
2779void OpenACCClauseProfiler::VisitDeviceClause(
2780 const OpenACCDeviceClause &Clause) {
2781 VisitClauseWithVarList(Clause);
2782}
2783
2784void OpenACCClauseProfiler::VisitSelfClause(const OpenACCSelfClause &Clause) {
2785 if (Clause.isConditionExprClause()) {
2786 if (Clause.hasConditionExpr())
2787 Profiler.VisitStmt(S: Clause.getConditionExpr());
2788 } else {
2789 for (auto *E : Clause.getVarList())
2790 Profiler.VisitStmt(S: E);
2791 }
2792}
2793
2794void OpenACCClauseProfiler::VisitFinalizeClause(
2795 const OpenACCFinalizeClause &Clause) {}
2796
2797void OpenACCClauseProfiler::VisitIfPresentClause(
2798 const OpenACCIfPresentClause &Clause) {}
2799
2800void OpenACCClauseProfiler::VisitNumGangsClause(
2801 const OpenACCNumGangsClause &Clause) {
2802 for (auto *E : Clause.getIntExprs())
2803 Profiler.VisitStmt(S: E);
2804}
2805
2806void OpenACCClauseProfiler::VisitTileClause(const OpenACCTileClause &Clause) {
2807 for (auto *E : Clause.getSizeExprs())
2808 Profiler.VisitStmt(S: E);
2809}
2810
2811void OpenACCClauseProfiler::VisitNumWorkersClause(
2812 const OpenACCNumWorkersClause &Clause) {
2813 assert(Clause.hasIntExpr() && "num_workers clause requires a valid int expr");
2814 Profiler.VisitStmt(S: Clause.getIntExpr());
2815}
2816
2817void OpenACCClauseProfiler::VisitCollapseClause(
2818 const OpenACCCollapseClause &Clause) {
2819 assert(Clause.getLoopCount() && "collapse clause requires a valid int expr");
2820 Profiler.VisitStmt(S: Clause.getLoopCount());
2821}
2822
2823void OpenACCClauseProfiler::VisitPrivateClause(
2824 const OpenACCPrivateClause &Clause) {
2825 VisitClauseWithVarList(Clause);
2826
2827 for (auto &Recipe : Clause.getInitRecipes()) {
2828 Profiler.VisitDecl(D: Recipe.AllocaDecl);
2829 }
2830}
2831
2832void OpenACCClauseProfiler::VisitFirstPrivateClause(
2833 const OpenACCFirstPrivateClause &Clause) {
2834 VisitClauseWithVarList(Clause);
2835
2836 for (auto &Recipe : Clause.getInitRecipes()) {
2837 Profiler.VisitDecl(D: Recipe.AllocaDecl);
2838 Profiler.VisitDecl(D: Recipe.InitFromTemporary);
2839 }
2840}
2841
2842void OpenACCClauseProfiler::VisitAttachClause(
2843 const OpenACCAttachClause &Clause) {
2844 VisitClauseWithVarList(Clause);
2845}
2846
2847void OpenACCClauseProfiler::VisitDetachClause(
2848 const OpenACCDetachClause &Clause) {
2849 VisitClauseWithVarList(Clause);
2850}
2851
2852void OpenACCClauseProfiler::VisitDeleteClause(
2853 const OpenACCDeleteClause &Clause) {
2854 VisitClauseWithVarList(Clause);
2855}
2856
2857void OpenACCClauseProfiler::VisitDevicePtrClause(
2858 const OpenACCDevicePtrClause &Clause) {
2859 VisitClauseWithVarList(Clause);
2860}
2861
2862void OpenACCClauseProfiler::VisitNoCreateClause(
2863 const OpenACCNoCreateClause &Clause) {
2864 VisitClauseWithVarList(Clause);
2865}
2866
2867void OpenACCClauseProfiler::VisitPresentClause(
2868 const OpenACCPresentClause &Clause) {
2869 VisitClauseWithVarList(Clause);
2870}
2871
2872void OpenACCClauseProfiler::VisitUseDeviceClause(
2873 const OpenACCUseDeviceClause &Clause) {
2874 VisitClauseWithVarList(Clause);
2875}
2876
2877void OpenACCClauseProfiler::VisitVectorLengthClause(
2878 const OpenACCVectorLengthClause &Clause) {
2879 assert(Clause.hasIntExpr() &&
2880 "vector_length clause requires a valid int expr");
2881 Profiler.VisitStmt(S: Clause.getIntExpr());
2882}
2883
2884void OpenACCClauseProfiler::VisitAsyncClause(const OpenACCAsyncClause &Clause) {
2885 if (Clause.hasIntExpr())
2886 Profiler.VisitStmt(S: Clause.getIntExpr());
2887}
2888
2889void OpenACCClauseProfiler::VisitDeviceNumClause(
2890 const OpenACCDeviceNumClause &Clause) {
2891 Profiler.VisitStmt(S: Clause.getIntExpr());
2892}
2893
2894void OpenACCClauseProfiler::VisitDefaultAsyncClause(
2895 const OpenACCDefaultAsyncClause &Clause) {
2896 Profiler.VisitStmt(S: Clause.getIntExpr());
2897}
2898
2899void OpenACCClauseProfiler::VisitWorkerClause(
2900 const OpenACCWorkerClause &Clause) {
2901 if (Clause.hasIntExpr())
2902 Profiler.VisitStmt(S: Clause.getIntExpr());
2903}
2904
2905void OpenACCClauseProfiler::VisitVectorClause(
2906 const OpenACCVectorClause &Clause) {
2907 if (Clause.hasIntExpr())
2908 Profiler.VisitStmt(S: Clause.getIntExpr());
2909}
2910
2911void OpenACCClauseProfiler::VisitWaitClause(const OpenACCWaitClause &Clause) {
2912 if (Clause.hasDevNumExpr())
2913 Profiler.VisitStmt(S: Clause.getDevNumExpr());
2914 for (auto *E : Clause.getQueueIdExprs())
2915 Profiler.VisitStmt(S: E);
2916}
2917
2918/// Nothing to do here, there are no sub-statements.
2919void OpenACCClauseProfiler::VisitDeviceTypeClause(
2920 const OpenACCDeviceTypeClause &Clause) {}
2921
2922void OpenACCClauseProfiler::VisitAutoClause(const OpenACCAutoClause &Clause) {}
2923
2924void OpenACCClauseProfiler::VisitIndependentClause(
2925 const OpenACCIndependentClause &Clause) {}
2926
2927void OpenACCClauseProfiler::VisitSeqClause(const OpenACCSeqClause &Clause) {}
2928void OpenACCClauseProfiler::VisitNoHostClause(
2929 const OpenACCNoHostClause &Clause) {}
2930
2931void OpenACCClauseProfiler::VisitGangClause(const OpenACCGangClause &Clause) {
2932 for (unsigned I = 0; I < Clause.getNumExprs(); ++I) {
2933 Profiler.VisitStmt(S: Clause.getExpr(I).second);
2934 }
2935}
2936
2937void OpenACCClauseProfiler::VisitReductionClause(
2938 const OpenACCReductionClause &Clause) {
2939 VisitClauseWithVarList(Clause);
2940
2941 for (auto &Recipe : Clause.getRecipes()) {
2942 Profiler.VisitDecl(D: Recipe.AllocaDecl);
2943
2944 // TODO: OpenACC: Make sure we remember to update this when we figure out
2945 // what we're adding for the operation recipe, in the meantime, a static
2946 // assert will make sure we don't add something.
2947 static_assert(sizeof(OpenACCReductionRecipe::CombinerRecipe) ==
2948 3 * sizeof(int *));
2949 for (auto &CombinerRecipe : Recipe.CombinerRecipes) {
2950 if (CombinerRecipe.Op) {
2951 Profiler.VisitDecl(D: CombinerRecipe.LHS);
2952 Profiler.VisitDecl(D: CombinerRecipe.RHS);
2953 Profiler.VisitStmt(S: CombinerRecipe.Op);
2954 }
2955 }
2956 }
2957}
2958
2959void OpenACCClauseProfiler::VisitBindClause(const OpenACCBindClause &Clause) {
2960 assert(false && "not implemented... what can we do about our expr?");
2961}
2962} // namespace
2963
2964void StmtProfiler::VisitOpenACCComputeConstruct(
2965 const OpenACCComputeConstruct *S) {
2966 // VisitStmt handles children, so the AssociatedStmt is handled.
2967 VisitStmt(S);
2968
2969 OpenACCClauseProfiler P{*this};
2970 P.VisitOpenACCClauseList(Clauses: S->clauses());
2971}
2972
2973void StmtProfiler::VisitOpenACCLoopConstruct(const OpenACCLoopConstruct *S) {
2974 // VisitStmt handles children, so the Loop is handled.
2975 VisitStmt(S);
2976
2977 OpenACCClauseProfiler P{*this};
2978 P.VisitOpenACCClauseList(Clauses: S->clauses());
2979}
2980
2981void StmtProfiler::VisitOpenACCCombinedConstruct(
2982 const OpenACCCombinedConstruct *S) {
2983 // VisitStmt handles children, so the Loop is handled.
2984 VisitStmt(S);
2985
2986 OpenACCClauseProfiler P{*this};
2987 P.VisitOpenACCClauseList(Clauses: S->clauses());
2988}
2989
2990void StmtProfiler::VisitOpenACCDataConstruct(const OpenACCDataConstruct *S) {
2991 VisitStmt(S);
2992
2993 OpenACCClauseProfiler P{*this};
2994 P.VisitOpenACCClauseList(Clauses: S->clauses());
2995}
2996
2997void StmtProfiler::VisitOpenACCEnterDataConstruct(
2998 const OpenACCEnterDataConstruct *S) {
2999 VisitStmt(S);
3000
3001 OpenACCClauseProfiler P{*this};
3002 P.VisitOpenACCClauseList(Clauses: S->clauses());
3003}
3004
3005void StmtProfiler::VisitOpenACCExitDataConstruct(
3006 const OpenACCExitDataConstruct *S) {
3007 VisitStmt(S);
3008
3009 OpenACCClauseProfiler P{*this};
3010 P.VisitOpenACCClauseList(Clauses: S->clauses());
3011}
3012
3013void StmtProfiler::VisitOpenACCHostDataConstruct(
3014 const OpenACCHostDataConstruct *S) {
3015 VisitStmt(S);
3016
3017 OpenACCClauseProfiler P{*this};
3018 P.VisitOpenACCClauseList(Clauses: S->clauses());
3019}
3020
3021void StmtProfiler::VisitOpenACCWaitConstruct(const OpenACCWaitConstruct *S) {
3022 // VisitStmt covers 'children', so the exprs inside of it are covered.
3023 VisitStmt(S);
3024
3025 OpenACCClauseProfiler P{*this};
3026 P.VisitOpenACCClauseList(Clauses: S->clauses());
3027}
3028
3029void StmtProfiler::VisitOpenACCCacheConstruct(const OpenACCCacheConstruct *S) {
3030 // VisitStmt covers 'children', so the exprs inside of it are covered.
3031 VisitStmt(S);
3032}
3033
3034void StmtProfiler::VisitOpenACCInitConstruct(const OpenACCInitConstruct *S) {
3035 VisitStmt(S);
3036 OpenACCClauseProfiler P{*this};
3037 P.VisitOpenACCClauseList(Clauses: S->clauses());
3038}
3039
3040void StmtProfiler::VisitOpenACCShutdownConstruct(
3041 const OpenACCShutdownConstruct *S) {
3042 VisitStmt(S);
3043 OpenACCClauseProfiler P{*this};
3044 P.VisitOpenACCClauseList(Clauses: S->clauses());
3045}
3046
3047void StmtProfiler::VisitOpenACCSetConstruct(const OpenACCSetConstruct *S) {
3048 VisitStmt(S);
3049 OpenACCClauseProfiler P{*this};
3050 P.VisitOpenACCClauseList(Clauses: S->clauses());
3051}
3052
3053void StmtProfiler::VisitOpenACCUpdateConstruct(
3054 const OpenACCUpdateConstruct *S) {
3055 VisitStmt(S);
3056 OpenACCClauseProfiler P{*this};
3057 P.VisitOpenACCClauseList(Clauses: S->clauses());
3058}
3059
3060void StmtProfiler::VisitOpenACCAtomicConstruct(
3061 const OpenACCAtomicConstruct *S) {
3062 VisitStmt(S);
3063 OpenACCClauseProfiler P{*this};
3064 P.VisitOpenACCClauseList(Clauses: S->clauses());
3065}
3066
3067void StmtProfiler::VisitHLSLOutArgExpr(const HLSLOutArgExpr *S) {
3068 VisitStmt(S);
3069}
3070
3071void Stmt::Profile(llvm::FoldingSetNodeID &ID, const ASTContext &Context,
3072 bool Canonical, bool ProfileLambdaExpr) const {
3073 StmtProfilerWithPointers Profiler(ID, Context, Canonical, ProfileLambdaExpr);
3074 Profiler.Visit(S: this);
3075}
3076
3077void Stmt::ProcessODRHash(llvm::FoldingSetNodeID &ID,
3078 class ODRHash &Hash) const {
3079 StmtProfilerWithoutPointers Profiler(ID, Hash);
3080 Profiler.Visit(S: this);
3081}
3082