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