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