clang 20.0.0git
StmtProfile.cpp
Go to the documentation of this file.
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//===----------------------------------------------------------------------===//
14#include "clang/AST/DeclCXX.h"
15#include "clang/AST/DeclObjC.h"
17#include "clang/AST/Expr.h"
18#include "clang/AST/ExprCXX.h"
19#include "clang/AST/ExprObjC.h"
21#include "clang/AST/ODRHash.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 void VisitStmtNoChildren(const Stmt *S) {
44 HandleStmtClass(S->getStmtClass());
45 }
46
47 virtual void HandleStmtClass(Stmt::StmtClass SC) = 0;
48
49#define STMT(Node, Base) void Visit##Node(const Node *S);
50#include "clang/AST/StmtNodes.inc"
51
52 /// Visit a declaration that is referenced within an expression
53 /// or statement.
54 virtual void VisitDecl(const Decl *D) = 0;
55
56 /// Visit a type that is referenced within an expression or
57 /// statement.
58 virtual void VisitType(QualType T) = 0;
59
60 /// Visit a name that occurs within an expression or statement.
61 virtual void VisitName(DeclarationName Name, bool TreatAsDecl = false) = 0;
62
63 /// Visit identifiers that are not in Decl's or Type's.
64 virtual void VisitIdentifierInfo(const IdentifierInfo *II) = 0;
65
66 /// Visit a nested-name-specifier that occurs within an expression
67 /// or statement.
68 virtual void VisitNestedNameSpecifier(NestedNameSpecifier *NNS) = 0;
69
70 /// Visit a template name that occurs within an expression or
71 /// statement.
72 virtual void VisitTemplateName(TemplateName Name) = 0;
73
74 /// Visit template arguments that occur within an expression or
75 /// statement.
76 void VisitTemplateArguments(const TemplateArgumentLoc *Args,
77 unsigned NumArgs);
78
79 /// Visit a single template argument.
80 void VisitTemplateArgument(const TemplateArgument &Arg);
81 };
82
83 class StmtProfilerWithPointers : public StmtProfiler {
84 const ASTContext &Context;
85
86 public:
87 StmtProfilerWithPointers(llvm::FoldingSetNodeID &ID,
88 const ASTContext &Context, bool Canonical,
89 bool ProfileLambdaExpr)
90 : StmtProfiler(ID, Canonical, ProfileLambdaExpr), Context(Context) {}
91
92 private:
93 void HandleStmtClass(Stmt::StmtClass SC) override {
94 ID.AddInteger(SC);
95 }
96
97 void VisitDecl(const Decl *D) override {
98 ID.AddInteger(D ? D->getKind() : 0);
99
100 if (Canonical && D) {
101 if (const NonTypeTemplateParmDecl *NTTP =
102 dyn_cast<NonTypeTemplateParmDecl>(D)) {
103 ID.AddInteger(NTTP->getDepth());
104 ID.AddInteger(NTTP->getIndex());
105 ID.AddBoolean(NTTP->isParameterPack());
106 // C++20 [temp.over.link]p6:
107 // Two template-parameters are equivalent under the following
108 // conditions: [...] if they declare non-type template parameters,
109 // they have equivalent types ignoring the use of type-constraints
110 // for placeholder types
111 //
112 // TODO: Why do we need to include the type in the profile? It's not
113 // part of the mangling.
114 VisitType(Context.getUnconstrainedType(NTTP->getType()));
115 return;
116 }
117
118 if (const ParmVarDecl *Parm = dyn_cast<ParmVarDecl>(D)) {
119 // The Itanium C++ ABI uses the type, scope depth, and scope
120 // index of a parameter when mangling expressions that involve
121 // function parameters, so we will use the parameter's type for
122 // establishing function parameter identity. That way, our
123 // definition of "equivalent" (per C++ [temp.over.link]) is at
124 // least as strong as the definition of "equivalent" used for
125 // name mangling.
126 //
127 // TODO: The Itanium C++ ABI only uses the top-level cv-qualifiers,
128 // not the entirety of the type.
129 VisitType(Parm->getType());
130 ID.AddInteger(Parm->getFunctionScopeDepth());
131 ID.AddInteger(Parm->getFunctionScopeIndex());
132 return;
133 }
134
135 if (const TemplateTypeParmDecl *TTP =
136 dyn_cast<TemplateTypeParmDecl>(D)) {
137 ID.AddInteger(TTP->getDepth());
138 ID.AddInteger(TTP->getIndex());
139 ID.AddBoolean(TTP->isParameterPack());
140 return;
141 }
142
143 if (const TemplateTemplateParmDecl *TTP =
144 dyn_cast<TemplateTemplateParmDecl>(D)) {
145 ID.AddInteger(TTP->getDepth());
146 ID.AddInteger(TTP->getIndex());
147 ID.AddBoolean(TTP->isParameterPack());
148 return;
149 }
150 }
151
152 ID.AddPointer(D ? D->getCanonicalDecl() : nullptr);
153 }
154
155 void VisitType(QualType T) override {
156 if (Canonical && !T.isNull())
157 T = Context.getCanonicalType(T);
158
159 ID.AddPointer(T.getAsOpaquePtr());
160 }
161
162 void VisitName(DeclarationName Name, bool /*TreatAsDecl*/) override {
163 ID.AddPointer(Name.getAsOpaquePtr());
164 }
165
166 void VisitIdentifierInfo(const IdentifierInfo *II) override {
167 ID.AddPointer(II);
168 }
169
170 void VisitNestedNameSpecifier(NestedNameSpecifier *NNS) override {
171 if (Canonical)
172 NNS = Context.getCanonicalNestedNameSpecifier(NNS);
173 ID.AddPointer(NNS);
174 }
175
176 void VisitTemplateName(TemplateName Name) override {
177 if (Canonical)
178 Name = Context.getCanonicalTemplateName(Name);
179
180 Name.Profile(ID);
181 }
182 };
183
184 class StmtProfilerWithoutPointers : public StmtProfiler {
185 ODRHash &Hash;
186 public:
187 StmtProfilerWithoutPointers(llvm::FoldingSetNodeID &ID, ODRHash &Hash)
188 : StmtProfiler(ID, /*Canonical=*/false, /*ProfileLambdaExpr=*/false),
189 Hash(Hash) {}
190
191 private:
192 void HandleStmtClass(Stmt::StmtClass SC) override {
193 if (SC == Stmt::UnresolvedLookupExprClass) {
194 // Pretend that the name looked up is a Decl due to how templates
195 // handle some Decl lookups.
196 ID.AddInteger(Stmt::DeclRefExprClass);
197 } else {
198 ID.AddInteger(SC);
199 }
200 }
201
202 void VisitType(QualType T) override {
203 Hash.AddQualType(T);
204 }
205
206 void VisitName(DeclarationName Name, bool TreatAsDecl) override {
207 if (TreatAsDecl) {
208 // A Decl can be null, so each Decl is preceded by a boolean to
209 // store its nullness. Add a boolean here to match.
210 ID.AddBoolean(true);
211 }
212 Hash.AddDeclarationName(Name, TreatAsDecl);
213 }
214 void VisitIdentifierInfo(const IdentifierInfo *II) override {
215 ID.AddBoolean(II);
216 if (II) {
217 Hash.AddIdentifierInfo(II);
218 }
219 }
220 void VisitDecl(const Decl *D) override {
221 ID.AddBoolean(D);
222 if (D) {
223 Hash.AddDecl(D);
224 }
225 }
226 void VisitTemplateName(TemplateName Name) override {
227 Hash.AddTemplateName(Name);
228 }
229 void VisitNestedNameSpecifier(NestedNameSpecifier *NNS) override {
230 ID.AddBoolean(NNS);
231 if (NNS) {
232 Hash.AddNestedNameSpecifier(NNS);
233 }
234 }
235 };
236}
237
238void StmtProfiler::VisitStmt(const Stmt *S) {
239 assert(S && "Requires non-null Stmt pointer");
240
241 VisitStmtNoChildren(S);
242
243 for (const Stmt *SubStmt : S->children()) {
244 if (SubStmt)
245 Visit(SubStmt);
246 else
247 ID.AddInteger(0);
248 }
249}
250
251void StmtProfiler::VisitDeclStmt(const DeclStmt *S) {
252 VisitStmt(S);
253 for (const auto *D : S->decls())
254 VisitDecl(D);
255}
256
257void StmtProfiler::VisitNullStmt(const NullStmt *S) {
258 VisitStmt(S);
259}
260
261void StmtProfiler::VisitCompoundStmt(const CompoundStmt *S) {
262 VisitStmt(S);
263}
264
265void StmtProfiler::VisitCaseStmt(const CaseStmt *S) {
266 VisitStmt(S);
267}
268
269void StmtProfiler::VisitDefaultStmt(const DefaultStmt *S) {
270 VisitStmt(S);
271}
272
273void StmtProfiler::VisitLabelStmt(const LabelStmt *S) {
274 VisitStmt(S);
275 VisitDecl(S->getDecl());
276}
277
278void StmtProfiler::VisitAttributedStmt(const AttributedStmt *S) {
279 VisitStmt(S);
280 // TODO: maybe visit attributes?
281}
282
283void StmtProfiler::VisitIfStmt(const IfStmt *S) {
284 VisitStmt(S);
285 VisitDecl(S->getConditionVariable());
286}
287
288void StmtProfiler::VisitSwitchStmt(const SwitchStmt *S) {
289 VisitStmt(S);
290 VisitDecl(S->getConditionVariable());
291}
292
293void StmtProfiler::VisitWhileStmt(const WhileStmt *S) {
294 VisitStmt(S);
295 VisitDecl(S->getConditionVariable());
296}
297
298void StmtProfiler::VisitDoStmt(const DoStmt *S) {
299 VisitStmt(S);
300}
301
302void StmtProfiler::VisitForStmt(const ForStmt *S) {
303 VisitStmt(S);
304}
305
306void StmtProfiler::VisitGotoStmt(const GotoStmt *S) {
307 VisitStmt(S);
308 VisitDecl(S->getLabel());
309}
310
311void StmtProfiler::VisitIndirectGotoStmt(const IndirectGotoStmt *S) {
312 VisitStmt(S);
313}
314
315void StmtProfiler::VisitContinueStmt(const ContinueStmt *S) {
316 VisitStmt(S);
317}
318
319void StmtProfiler::VisitBreakStmt(const BreakStmt *S) {
320 VisitStmt(S);
321}
322
323void StmtProfiler::VisitReturnStmt(const ReturnStmt *S) {
324 VisitStmt(S);
325}
326
327void StmtProfiler::VisitGCCAsmStmt(const GCCAsmStmt *S) {
328 VisitStmt(S);
329 ID.AddBoolean(S->isVolatile());
330 ID.AddBoolean(S->isSimple());
331 VisitStringLiteral(S->getAsmString());
332 ID.AddInteger(S->getNumOutputs());
333 for (unsigned I = 0, N = S->getNumOutputs(); I != N; ++I) {
334 ID.AddString(S->getOutputName(I));
335 VisitStringLiteral(S->getOutputConstraintLiteral(I));
336 }
337 ID.AddInteger(S->getNumInputs());
338 for (unsigned I = 0, N = S->getNumInputs(); I != N; ++I) {
339 ID.AddString(S->getInputName(I));
340 VisitStringLiteral(S->getInputConstraintLiteral(I));
341 }
342 ID.AddInteger(S->getNumClobbers());
343 for (unsigned I = 0, N = S->getNumClobbers(); I != N; ++I)
344 VisitStringLiteral(S->getClobberStringLiteral(I));
345 ID.AddInteger(S->getNumLabels());
346 for (auto *L : S->labels())
347 VisitDecl(L->getLabel());
348}
349
350void StmtProfiler::VisitMSAsmStmt(const MSAsmStmt *S) {
351 // FIXME: Implement MS style inline asm statement profiler.
352 VisitStmt(S);
353}
354
355void StmtProfiler::VisitCXXCatchStmt(const CXXCatchStmt *S) {
356 VisitStmt(S);
357 VisitType(S->getCaughtType());
358}
359
360void StmtProfiler::VisitCXXTryStmt(const CXXTryStmt *S) {
361 VisitStmt(S);
362}
363
364void StmtProfiler::VisitCXXForRangeStmt(const CXXForRangeStmt *S) {
365 VisitStmt(S);
366}
367
368void StmtProfiler::VisitMSDependentExistsStmt(const MSDependentExistsStmt *S) {
369 VisitStmt(S);
370 ID.AddBoolean(S->isIfExists());
371 VisitNestedNameSpecifier(S->getQualifierLoc().getNestedNameSpecifier());
372 VisitName(S->getNameInfo().getName());
373}
374
375void StmtProfiler::VisitSEHTryStmt(const SEHTryStmt *S) {
376 VisitStmt(S);
377}
378
379void StmtProfiler::VisitSEHFinallyStmt(const SEHFinallyStmt *S) {
380 VisitStmt(S);
381}
382
383void StmtProfiler::VisitSEHExceptStmt(const SEHExceptStmt *S) {
384 VisitStmt(S);
385}
386
387void StmtProfiler::VisitSEHLeaveStmt(const SEHLeaveStmt *S) {
388 VisitStmt(S);
389}
390
391void StmtProfiler::VisitCapturedStmt(const CapturedStmt *S) {
392 VisitStmt(S);
393}
394
395void StmtProfiler::VisitObjCForCollectionStmt(const ObjCForCollectionStmt *S) {
396 VisitStmt(S);
397}
398
399void StmtProfiler::VisitObjCAtCatchStmt(const ObjCAtCatchStmt *S) {
400 VisitStmt(S);
401 ID.AddBoolean(S->hasEllipsis());
402 if (S->getCatchParamDecl())
403 VisitType(S->getCatchParamDecl()->getType());
404}
405
406void StmtProfiler::VisitObjCAtFinallyStmt(const ObjCAtFinallyStmt *S) {
407 VisitStmt(S);
408}
409
410void StmtProfiler::VisitObjCAtTryStmt(const ObjCAtTryStmt *S) {
411 VisitStmt(S);
412}
413
414void
415StmtProfiler::VisitObjCAtSynchronizedStmt(const ObjCAtSynchronizedStmt *S) {
416 VisitStmt(S);
417}
418
419void StmtProfiler::VisitObjCAtThrowStmt(const ObjCAtThrowStmt *S) {
420 VisitStmt(S);
421}
422
423void
424StmtProfiler::VisitObjCAutoreleasePoolStmt(const ObjCAutoreleasePoolStmt *S) {
425 VisitStmt(S);
426}
427
428namespace {
429class OMPClauseProfiler : public ConstOMPClauseVisitor<OMPClauseProfiler> {
430 StmtProfiler *Profiler;
431 /// Process clauses with list of variables.
432 template <typename T>
433 void VisitOMPClauseList(T *Node);
434
435public:
436 OMPClauseProfiler(StmtProfiler *P) : Profiler(P) { }
437#define GEN_CLANG_CLAUSE_CLASS
438#define CLAUSE_CLASS(Enum, Str, Class) void Visit##Class(const Class *C);
439#include "llvm/Frontend/OpenMP/OMP.inc"
440 void VistOMPClauseWithPreInit(const OMPClauseWithPreInit *C);
441 void VistOMPClauseWithPostUpdate(const OMPClauseWithPostUpdate *C);
442};
443
444void OMPClauseProfiler::VistOMPClauseWithPreInit(
445 const OMPClauseWithPreInit *C) {
446 if (auto *S = C->getPreInitStmt())
447 Profiler->VisitStmt(S);
448}
449
450void OMPClauseProfiler::VistOMPClauseWithPostUpdate(
451 const OMPClauseWithPostUpdate *C) {
452 VistOMPClauseWithPreInit(C);
453 if (auto *E = C->getPostUpdateExpr())
454 Profiler->VisitStmt(E);
455}
456
457void OMPClauseProfiler::VisitOMPIfClause(const OMPIfClause *C) {
458 VistOMPClauseWithPreInit(C);
459 if (C->getCondition())
460 Profiler->VisitStmt(C->getCondition());
461}
462
463void OMPClauseProfiler::VisitOMPFinalClause(const OMPFinalClause *C) {
464 VistOMPClauseWithPreInit(C);
465 if (C->getCondition())
466 Profiler->VisitStmt(C->getCondition());
467}
468
469void OMPClauseProfiler::VisitOMPNumThreadsClause(const OMPNumThreadsClause *C) {
470 VistOMPClauseWithPreInit(C);
471 if (C->getNumThreads())
472 Profiler->VisitStmt(C->getNumThreads());
473}
474
475void OMPClauseProfiler::VisitOMPAlignClause(const OMPAlignClause *C) {
476 if (C->getAlignment())
477 Profiler->VisitStmt(C->getAlignment());
478}
479
480void OMPClauseProfiler::VisitOMPSafelenClause(const OMPSafelenClause *C) {
481 if (C->getSafelen())
482 Profiler->VisitStmt(C->getSafelen());
483}
484
485void OMPClauseProfiler::VisitOMPSimdlenClause(const OMPSimdlenClause *C) {
486 if (C->getSimdlen())
487 Profiler->VisitStmt(C->getSimdlen());
488}
489
490void OMPClauseProfiler::VisitOMPSizesClause(const OMPSizesClause *C) {
491 for (auto *E : C->getSizesRefs())
492 if (E)
493 Profiler->VisitExpr(E);
494}
495
496void OMPClauseProfiler::VisitOMPPermutationClause(
497 const OMPPermutationClause *C) {
498 for (Expr *E : C->getArgsRefs())
499 if (E)
500 Profiler->VisitExpr(E);
501}
502
503void OMPClauseProfiler::VisitOMPFullClause(const OMPFullClause *C) {}
504
505void OMPClauseProfiler::VisitOMPPartialClause(const OMPPartialClause *C) {
506 if (const Expr *Factor = C->getFactor())
507 Profiler->VisitExpr(Factor);
508}
509
510void OMPClauseProfiler::VisitOMPAllocatorClause(const OMPAllocatorClause *C) {
511 if (C->getAllocator())
512 Profiler->VisitStmt(C->getAllocator());
513}
514
515void OMPClauseProfiler::VisitOMPCollapseClause(const OMPCollapseClause *C) {
516 if (C->getNumForLoops())
517 Profiler->VisitStmt(C->getNumForLoops());
518}
519
520void OMPClauseProfiler::VisitOMPDetachClause(const OMPDetachClause *C) {
521 if (Expr *Evt = C->getEventHandler())
522 Profiler->VisitStmt(Evt);
523}
524
525void OMPClauseProfiler::VisitOMPNovariantsClause(const OMPNovariantsClause *C) {
526 VistOMPClauseWithPreInit(C);
527 if (C->getCondition())
528 Profiler->VisitStmt(C->getCondition());
529}
530
531void OMPClauseProfiler::VisitOMPNocontextClause(const OMPNocontextClause *C) {
532 VistOMPClauseWithPreInit(C);
533 if (C->getCondition())
534 Profiler->VisitStmt(C->getCondition());
535}
536
537void OMPClauseProfiler::VisitOMPDefaultClause(const OMPDefaultClause *C) { }
538
539void OMPClauseProfiler::VisitOMPProcBindClause(const OMPProcBindClause *C) { }
540
541void OMPClauseProfiler::VisitOMPUnifiedAddressClause(
542 const OMPUnifiedAddressClause *C) {}
543
544void OMPClauseProfiler::VisitOMPUnifiedSharedMemoryClause(
546
547void OMPClauseProfiler::VisitOMPReverseOffloadClause(
548 const OMPReverseOffloadClause *C) {}
549
550void OMPClauseProfiler::VisitOMPDynamicAllocatorsClause(
552
553void OMPClauseProfiler::VisitOMPAtomicDefaultMemOrderClause(
555
556void OMPClauseProfiler::VisitOMPAtClause(const OMPAtClause *C) {}
557
558void OMPClauseProfiler::VisitOMPSeverityClause(const OMPSeverityClause *C) {}
559
560void OMPClauseProfiler::VisitOMPMessageClause(const OMPMessageClause *C) {
561 if (C->getMessageString())
562 Profiler->VisitStmt(C->getMessageString());
563}
564
565void OMPClauseProfiler::VisitOMPScheduleClause(const OMPScheduleClause *C) {
566 VistOMPClauseWithPreInit(C);
567 if (auto *S = C->getChunkSize())
568 Profiler->VisitStmt(S);
569}
570
571void OMPClauseProfiler::VisitOMPOrderedClause(const OMPOrderedClause *C) {
572 if (auto *Num = C->getNumForLoops())
573 Profiler->VisitStmt(Num);
574}
575
576void OMPClauseProfiler::VisitOMPNowaitClause(const OMPNowaitClause *) {}
577
578void OMPClauseProfiler::VisitOMPUntiedClause(const OMPUntiedClause *) {}
579
580void OMPClauseProfiler::VisitOMPMergeableClause(const OMPMergeableClause *) {}
581
582void OMPClauseProfiler::VisitOMPReadClause(const OMPReadClause *) {}
583
584void OMPClauseProfiler::VisitOMPWriteClause(const OMPWriteClause *) {}
585
586void OMPClauseProfiler::VisitOMPUpdateClause(const OMPUpdateClause *) {}
587
588void OMPClauseProfiler::VisitOMPCaptureClause(const OMPCaptureClause *) {}
589
590void OMPClauseProfiler::VisitOMPCompareClause(const OMPCompareClause *) {}
591
592void OMPClauseProfiler::VisitOMPFailClause(const OMPFailClause *) {}
593
594void OMPClauseProfiler::VisitOMPAbsentClause(const OMPAbsentClause *) {}
595
596void OMPClauseProfiler::VisitOMPHoldsClause(const OMPHoldsClause *) {}
597
598void OMPClauseProfiler::VisitOMPContainsClause(const OMPContainsClause *) {}
599
600void OMPClauseProfiler::VisitOMPNoOpenMPClause(const OMPNoOpenMPClause *) {}
601
602void OMPClauseProfiler::VisitOMPNoOpenMPRoutinesClause(
603 const OMPNoOpenMPRoutinesClause *) {}
604
605void OMPClauseProfiler::VisitOMPNoParallelismClause(
606 const OMPNoParallelismClause *) {}
607
608void OMPClauseProfiler::VisitOMPSeqCstClause(const OMPSeqCstClause *) {}
609
610void OMPClauseProfiler::VisitOMPAcqRelClause(const OMPAcqRelClause *) {}
611
612void OMPClauseProfiler::VisitOMPAcquireClause(const OMPAcquireClause *) {}
613
614void OMPClauseProfiler::VisitOMPReleaseClause(const OMPReleaseClause *) {}
615
616void OMPClauseProfiler::VisitOMPRelaxedClause(const OMPRelaxedClause *) {}
617
618void OMPClauseProfiler::VisitOMPWeakClause(const OMPWeakClause *) {}
619
620void OMPClauseProfiler::VisitOMPThreadsClause(const OMPThreadsClause *) {}
621
622void OMPClauseProfiler::VisitOMPSIMDClause(const OMPSIMDClause *) {}
623
624void OMPClauseProfiler::VisitOMPNogroupClause(const OMPNogroupClause *) {}
625
626void OMPClauseProfiler::VisitOMPInitClause(const OMPInitClause *C) {
627 VisitOMPClauseList(C);
628}
629
630void OMPClauseProfiler::VisitOMPUseClause(const OMPUseClause *C) {
631 if (C->getInteropVar())
632 Profiler->VisitStmt(C->getInteropVar());
633}
634
635void OMPClauseProfiler::VisitOMPDestroyClause(const OMPDestroyClause *C) {
636 if (C->getInteropVar())
637 Profiler->VisitStmt(C->getInteropVar());
638}
639
640void OMPClauseProfiler::VisitOMPFilterClause(const OMPFilterClause *C) {
641 VistOMPClauseWithPreInit(C);
642 if (C->getThreadID())
643 Profiler->VisitStmt(C->getThreadID());
644}
645
646template<typename T>
647void OMPClauseProfiler::VisitOMPClauseList(T *Node) {
648 for (auto *E : Node->varlist()) {
649 if (E)
650 Profiler->VisitStmt(E);
651 }
652}
653
654void OMPClauseProfiler::VisitOMPPrivateClause(const OMPPrivateClause *C) {
655 VisitOMPClauseList(C);
656 for (auto *E : C->private_copies()) {
657 if (E)
658 Profiler->VisitStmt(E);
659 }
660}
661void
662OMPClauseProfiler::VisitOMPFirstprivateClause(const OMPFirstprivateClause *C) {
663 VisitOMPClauseList(C);
664 VistOMPClauseWithPreInit(C);
665 for (auto *E : C->private_copies()) {
666 if (E)
667 Profiler->VisitStmt(E);
668 }
669 for (auto *E : C->inits()) {
670 if (E)
671 Profiler->VisitStmt(E);
672 }
673}
674void
675OMPClauseProfiler::VisitOMPLastprivateClause(const OMPLastprivateClause *C) {
676 VisitOMPClauseList(C);
677 VistOMPClauseWithPostUpdate(C);
678 for (auto *E : C->source_exprs()) {
679 if (E)
680 Profiler->VisitStmt(E);
681 }
682 for (auto *E : C->destination_exprs()) {
683 if (E)
684 Profiler->VisitStmt(E);
685 }
686 for (auto *E : C->assignment_ops()) {
687 if (E)
688 Profiler->VisitStmt(E);
689 }
690}
691void OMPClauseProfiler::VisitOMPSharedClause(const OMPSharedClause *C) {
692 VisitOMPClauseList(C);
693}
694void OMPClauseProfiler::VisitOMPReductionClause(
695 const OMPReductionClause *C) {
696 Profiler->VisitNestedNameSpecifier(
697 C->getQualifierLoc().getNestedNameSpecifier());
698 Profiler->VisitName(C->getNameInfo().getName());
699 VisitOMPClauseList(C);
700 VistOMPClauseWithPostUpdate(C);
701 for (auto *E : C->privates()) {
702 if (E)
703 Profiler->VisitStmt(E);
704 }
705 for (auto *E : C->lhs_exprs()) {
706 if (E)
707 Profiler->VisitStmt(E);
708 }
709 for (auto *E : C->rhs_exprs()) {
710 if (E)
711 Profiler->VisitStmt(E);
712 }
713 for (auto *E : C->reduction_ops()) {
714 if (E)
715 Profiler->VisitStmt(E);
716 }
717 if (C->getModifier() == clang::OMPC_REDUCTION_inscan) {
718 for (auto *E : C->copy_ops()) {
719 if (E)
720 Profiler->VisitStmt(E);
721 }
722 for (auto *E : C->copy_array_temps()) {
723 if (E)
724 Profiler->VisitStmt(E);
725 }
726 for (auto *E : C->copy_array_elems()) {
727 if (E)
728 Profiler->VisitStmt(E);
729 }
730 }
731}
732void OMPClauseProfiler::VisitOMPTaskReductionClause(
733 const OMPTaskReductionClause *C) {
734 Profiler->VisitNestedNameSpecifier(
735 C->getQualifierLoc().getNestedNameSpecifier());
736 Profiler->VisitName(C->getNameInfo().getName());
737 VisitOMPClauseList(C);
738 VistOMPClauseWithPostUpdate(C);
739 for (auto *E : C->privates()) {
740 if (E)
741 Profiler->VisitStmt(E);
742 }
743 for (auto *E : C->lhs_exprs()) {
744 if (E)
745 Profiler->VisitStmt(E);
746 }
747 for (auto *E : C->rhs_exprs()) {
748 if (E)
749 Profiler->VisitStmt(E);
750 }
751 for (auto *E : C->reduction_ops()) {
752 if (E)
753 Profiler->VisitStmt(E);
754 }
755}
756void OMPClauseProfiler::VisitOMPInReductionClause(
757 const OMPInReductionClause *C) {
758 Profiler->VisitNestedNameSpecifier(
759 C->getQualifierLoc().getNestedNameSpecifier());
760 Profiler->VisitName(C->getNameInfo().getName());
761 VisitOMPClauseList(C);
762 VistOMPClauseWithPostUpdate(C);
763 for (auto *E : C->privates()) {
764 if (E)
765 Profiler->VisitStmt(E);
766 }
767 for (auto *E : C->lhs_exprs()) {
768 if (E)
769 Profiler->VisitStmt(E);
770 }
771 for (auto *E : C->rhs_exprs()) {
772 if (E)
773 Profiler->VisitStmt(E);
774 }
775 for (auto *E : C->reduction_ops()) {
776 if (E)
777 Profiler->VisitStmt(E);
778 }
779 for (auto *E : C->taskgroup_descriptors()) {
780 if (E)
781 Profiler->VisitStmt(E);
782 }
783}
784void OMPClauseProfiler::VisitOMPLinearClause(const OMPLinearClause *C) {
785 VisitOMPClauseList(C);
786 VistOMPClauseWithPostUpdate(C);
787 for (auto *E : C->privates()) {
788 if (E)
789 Profiler->VisitStmt(E);
790 }
791 for (auto *E : C->inits()) {
792 if (E)
793 Profiler->VisitStmt(E);
794 }
795 for (auto *E : C->updates()) {
796 if (E)
797 Profiler->VisitStmt(E);
798 }
799 for (auto *E : C->finals()) {
800 if (E)
801 Profiler->VisitStmt(E);
802 }
803 if (C->getStep())
804 Profiler->VisitStmt(C->getStep());
805 if (C->getCalcStep())
806 Profiler->VisitStmt(C->getCalcStep());
807}
808void OMPClauseProfiler::VisitOMPAlignedClause(const OMPAlignedClause *C) {
809 VisitOMPClauseList(C);
810 if (C->getAlignment())
811 Profiler->VisitStmt(C->getAlignment());
812}
813void OMPClauseProfiler::VisitOMPCopyinClause(const OMPCopyinClause *C) {
814 VisitOMPClauseList(C);
815 for (auto *E : C->source_exprs()) {
816 if (E)
817 Profiler->VisitStmt(E);
818 }
819 for (auto *E : C->destination_exprs()) {
820 if (E)
821 Profiler->VisitStmt(E);
822 }
823 for (auto *E : C->assignment_ops()) {
824 if (E)
825 Profiler->VisitStmt(E);
826 }
827}
828void
829OMPClauseProfiler::VisitOMPCopyprivateClause(const OMPCopyprivateClause *C) {
830 VisitOMPClauseList(C);
831 for (auto *E : C->source_exprs()) {
832 if (E)
833 Profiler->VisitStmt(E);
834 }
835 for (auto *E : C->destination_exprs()) {
836 if (E)
837 Profiler->VisitStmt(E);
838 }
839 for (auto *E : C->assignment_ops()) {
840 if (E)
841 Profiler->VisitStmt(E);
842 }
843}
844void OMPClauseProfiler::VisitOMPFlushClause(const OMPFlushClause *C) {
845 VisitOMPClauseList(C);
846}
847void OMPClauseProfiler::VisitOMPDepobjClause(const OMPDepobjClause *C) {
848 if (const Expr *Depobj = C->getDepobj())
849 Profiler->VisitStmt(Depobj);
850}
851void OMPClauseProfiler::VisitOMPDependClause(const OMPDependClause *C) {
852 VisitOMPClauseList(C);
853}
854void OMPClauseProfiler::VisitOMPDeviceClause(const OMPDeviceClause *C) {
855 if (C->getDevice())
856 Profiler->VisitStmt(C->getDevice());
857}
858void OMPClauseProfiler::VisitOMPMapClause(const OMPMapClause *C) {
859 VisitOMPClauseList(C);
860}
861void OMPClauseProfiler::VisitOMPAllocateClause(const OMPAllocateClause *C) {
862 if (Expr *Allocator = C->getAllocator())
863 Profiler->VisitStmt(Allocator);
864 VisitOMPClauseList(C);
865}
866void OMPClauseProfiler::VisitOMPNumTeamsClause(const OMPNumTeamsClause *C) {
867 VisitOMPClauseList(C);
868 VistOMPClauseWithPreInit(C);
869}
870void OMPClauseProfiler::VisitOMPThreadLimitClause(
871 const OMPThreadLimitClause *C) {
872 VisitOMPClauseList(C);
873 VistOMPClauseWithPreInit(C);
874}
875void OMPClauseProfiler::VisitOMPPriorityClause(const OMPPriorityClause *C) {
876 VistOMPClauseWithPreInit(C);
877 if (C->getPriority())
878 Profiler->VisitStmt(C->getPriority());
879}
880void OMPClauseProfiler::VisitOMPGrainsizeClause(const OMPGrainsizeClause *C) {
881 VistOMPClauseWithPreInit(C);
882 if (C->getGrainsize())
883 Profiler->VisitStmt(C->getGrainsize());
884}
885void OMPClauseProfiler::VisitOMPNumTasksClause(const OMPNumTasksClause *C) {
886 VistOMPClauseWithPreInit(C);
887 if (C->getNumTasks())
888 Profiler->VisitStmt(C->getNumTasks());
889}
890void OMPClauseProfiler::VisitOMPHintClause(const OMPHintClause *C) {
891 if (C->getHint())
892 Profiler->VisitStmt(C->getHint());
893}
894void OMPClauseProfiler::VisitOMPToClause(const OMPToClause *C) {
895 VisitOMPClauseList(C);
896}
897void OMPClauseProfiler::VisitOMPFromClause(const OMPFromClause *C) {
898 VisitOMPClauseList(C);
899}
900void OMPClauseProfiler::VisitOMPUseDevicePtrClause(
901 const OMPUseDevicePtrClause *C) {
902 VisitOMPClauseList(C);
903}
904void OMPClauseProfiler::VisitOMPUseDeviceAddrClause(
905 const OMPUseDeviceAddrClause *C) {
906 VisitOMPClauseList(C);
907}
908void OMPClauseProfiler::VisitOMPIsDevicePtrClause(
909 const OMPIsDevicePtrClause *C) {
910 VisitOMPClauseList(C);
911}
912void OMPClauseProfiler::VisitOMPHasDeviceAddrClause(
913 const OMPHasDeviceAddrClause *C) {
914 VisitOMPClauseList(C);
915}
916void OMPClauseProfiler::VisitOMPNontemporalClause(
917 const OMPNontemporalClause *C) {
918 VisitOMPClauseList(C);
919 for (auto *E : C->private_refs())
920 Profiler->VisitStmt(E);
921}
922void OMPClauseProfiler::VisitOMPInclusiveClause(const OMPInclusiveClause *C) {
923 VisitOMPClauseList(C);
924}
925void OMPClauseProfiler::VisitOMPExclusiveClause(const OMPExclusiveClause *C) {
926 VisitOMPClauseList(C);
927}
928void OMPClauseProfiler::VisitOMPUsesAllocatorsClause(
929 const OMPUsesAllocatorsClause *C) {
930 for (unsigned I = 0, E = C->getNumberOfAllocators(); I < E; ++I) {
931 OMPUsesAllocatorsClause::Data D = C->getAllocatorData(I);
932 Profiler->VisitStmt(D.Allocator);
933 if (D.AllocatorTraits)
934 Profiler->VisitStmt(D.AllocatorTraits);
935 }
936}
937void OMPClauseProfiler::VisitOMPAffinityClause(const OMPAffinityClause *C) {
938 if (const Expr *Modifier = C->getModifier())
939 Profiler->VisitStmt(Modifier);
940 for (const Expr *E : C->varlist())
941 Profiler->VisitStmt(E);
942}
943void OMPClauseProfiler::VisitOMPOrderClause(const OMPOrderClause *C) {}
944void OMPClauseProfiler::VisitOMPBindClause(const OMPBindClause *C) {}
945void OMPClauseProfiler::VisitOMPXDynCGroupMemClause(
946 const OMPXDynCGroupMemClause *C) {
947 VistOMPClauseWithPreInit(C);
948 if (Expr *Size = C->getSize())
949 Profiler->VisitStmt(Size);
950}
951void OMPClauseProfiler::VisitOMPDoacrossClause(const OMPDoacrossClause *C) {
952 VisitOMPClauseList(C);
953}
954void OMPClauseProfiler::VisitOMPXAttributeClause(const OMPXAttributeClause *C) {
955}
956void OMPClauseProfiler::VisitOMPXBareClause(const OMPXBareClause *C) {}
957} // namespace
958
959void
960StmtProfiler::VisitOMPExecutableDirective(const OMPExecutableDirective *S) {
961 VisitStmt(S);
962 OMPClauseProfiler P(this);
963 ArrayRef<OMPClause *> Clauses = S->clauses();
964 for (ArrayRef<OMPClause *>::iterator I = Clauses.begin(), E = Clauses.end();
965 I != E; ++I)
966 if (*I)
967 P.Visit(*I);
968}
969
970void StmtProfiler::VisitOMPCanonicalLoop(const OMPCanonicalLoop *L) {
971 VisitStmt(L);
972}
973
974void StmtProfiler::VisitOMPLoopBasedDirective(const OMPLoopBasedDirective *S) {
975 VisitOMPExecutableDirective(S);
976}
977
978void StmtProfiler::VisitOMPLoopDirective(const OMPLoopDirective *S) {
979 VisitOMPLoopBasedDirective(S);
980}
981
982void StmtProfiler::VisitOMPMetaDirective(const OMPMetaDirective *S) {
983 VisitOMPExecutableDirective(S);
984}
985
986void StmtProfiler::VisitOMPParallelDirective(const OMPParallelDirective *S) {
987 VisitOMPExecutableDirective(S);
988}
989
990void StmtProfiler::VisitOMPSimdDirective(const OMPSimdDirective *S) {
991 VisitOMPLoopDirective(S);
992}
993
994void StmtProfiler::VisitOMPLoopTransformationDirective(
996 VisitOMPLoopBasedDirective(S);
997}
998
999void StmtProfiler::VisitOMPTileDirective(const OMPTileDirective *S) {
1000 VisitOMPLoopTransformationDirective(S);
1001}
1002
1003void StmtProfiler::VisitOMPUnrollDirective(const OMPUnrollDirective *S) {
1004 VisitOMPLoopTransformationDirective(S);
1005}
1006
1007void StmtProfiler::VisitOMPReverseDirective(const OMPReverseDirective *S) {
1008 VisitOMPLoopTransformationDirective(S);
1009}
1010
1011void StmtProfiler::VisitOMPInterchangeDirective(
1012 const OMPInterchangeDirective *S) {
1013 VisitOMPLoopTransformationDirective(S);
1014}
1015
1016void StmtProfiler::VisitOMPForDirective(const OMPForDirective *S) {
1017 VisitOMPLoopDirective(S);
1018}
1019
1020void StmtProfiler::VisitOMPForSimdDirective(const OMPForSimdDirective *S) {
1021 VisitOMPLoopDirective(S);
1022}
1023
1024void StmtProfiler::VisitOMPSectionsDirective(const OMPSectionsDirective *S) {
1025 VisitOMPExecutableDirective(S);
1026}
1027
1028void StmtProfiler::VisitOMPSectionDirective(const OMPSectionDirective *S) {
1029 VisitOMPExecutableDirective(S);
1030}
1031
1032void StmtProfiler::VisitOMPScopeDirective(const OMPScopeDirective *S) {
1033 VisitOMPExecutableDirective(S);
1034}
1035
1036void StmtProfiler::VisitOMPSingleDirective(const OMPSingleDirective *S) {
1037 VisitOMPExecutableDirective(S);
1038}
1039
1040void StmtProfiler::VisitOMPMasterDirective(const OMPMasterDirective *S) {
1041 VisitOMPExecutableDirective(S);
1042}
1043
1044void StmtProfiler::VisitOMPCriticalDirective(const OMPCriticalDirective *S) {
1045 VisitOMPExecutableDirective(S);
1046 VisitName(S->getDirectiveName().getName());
1047}
1048
1049void
1050StmtProfiler::VisitOMPParallelForDirective(const OMPParallelForDirective *S) {
1051 VisitOMPLoopDirective(S);
1052}
1053
1054void StmtProfiler::VisitOMPParallelForSimdDirective(
1055 const OMPParallelForSimdDirective *S) {
1056 VisitOMPLoopDirective(S);
1057}
1058
1059void StmtProfiler::VisitOMPParallelMasterDirective(
1060 const OMPParallelMasterDirective *S) {
1061 VisitOMPExecutableDirective(S);
1062}
1063
1064void StmtProfiler::VisitOMPParallelMaskedDirective(
1065 const OMPParallelMaskedDirective *S) {
1066 VisitOMPExecutableDirective(S);
1067}
1068
1069void StmtProfiler::VisitOMPParallelSectionsDirective(
1071 VisitOMPExecutableDirective(S);
1072}
1073
1074void StmtProfiler::VisitOMPTaskDirective(const OMPTaskDirective *S) {
1075 VisitOMPExecutableDirective(S);
1076}
1077
1078void StmtProfiler::VisitOMPTaskyieldDirective(const OMPTaskyieldDirective *S) {
1079 VisitOMPExecutableDirective(S);
1080}
1081
1082void StmtProfiler::VisitOMPBarrierDirective(const OMPBarrierDirective *S) {
1083 VisitOMPExecutableDirective(S);
1084}
1085
1086void StmtProfiler::VisitOMPTaskwaitDirective(const OMPTaskwaitDirective *S) {
1087 VisitOMPExecutableDirective(S);
1088}
1089
1090void StmtProfiler::VisitOMPAssumeDirective(const OMPAssumeDirective *S) {
1091 VisitOMPExecutableDirective(S);
1092}
1093
1094void StmtProfiler::VisitOMPErrorDirective(const OMPErrorDirective *S) {
1095 VisitOMPExecutableDirective(S);
1096}
1097void StmtProfiler::VisitOMPTaskgroupDirective(const OMPTaskgroupDirective *S) {
1098 VisitOMPExecutableDirective(S);
1099 if (const Expr *E = S->getReductionRef())
1100 VisitStmt(E);
1101}
1102
1103void StmtProfiler::VisitOMPFlushDirective(const OMPFlushDirective *S) {
1104 VisitOMPExecutableDirective(S);
1105}
1106
1107void StmtProfiler::VisitOMPDepobjDirective(const OMPDepobjDirective *S) {
1108 VisitOMPExecutableDirective(S);
1109}
1110
1111void StmtProfiler::VisitOMPScanDirective(const OMPScanDirective *S) {
1112 VisitOMPExecutableDirective(S);
1113}
1114
1115void StmtProfiler::VisitOMPOrderedDirective(const OMPOrderedDirective *S) {
1116 VisitOMPExecutableDirective(S);
1117}
1118
1119void StmtProfiler::VisitOMPAtomicDirective(const OMPAtomicDirective *S) {
1120 VisitOMPExecutableDirective(S);
1121}
1122
1123void StmtProfiler::VisitOMPTargetDirective(const OMPTargetDirective *S) {
1124 VisitOMPExecutableDirective(S);
1125}
1126
1127void StmtProfiler::VisitOMPTargetDataDirective(const OMPTargetDataDirective *S) {
1128 VisitOMPExecutableDirective(S);
1129}
1130
1131void StmtProfiler::VisitOMPTargetEnterDataDirective(
1132 const OMPTargetEnterDataDirective *S) {
1133 VisitOMPExecutableDirective(S);
1134}
1135
1136void StmtProfiler::VisitOMPTargetExitDataDirective(
1137 const OMPTargetExitDataDirective *S) {
1138 VisitOMPExecutableDirective(S);
1139}
1140
1141void StmtProfiler::VisitOMPTargetParallelDirective(
1142 const OMPTargetParallelDirective *S) {
1143 VisitOMPExecutableDirective(S);
1144}
1145
1146void StmtProfiler::VisitOMPTargetParallelForDirective(
1148 VisitOMPExecutableDirective(S);
1149}
1150
1151void StmtProfiler::VisitOMPTeamsDirective(const OMPTeamsDirective *S) {
1152 VisitOMPExecutableDirective(S);
1153}
1154
1155void StmtProfiler::VisitOMPCancellationPointDirective(
1157 VisitOMPExecutableDirective(S);
1158}
1159
1160void StmtProfiler::VisitOMPCancelDirective(const OMPCancelDirective *S) {
1161 VisitOMPExecutableDirective(S);
1162}
1163
1164void StmtProfiler::VisitOMPTaskLoopDirective(const OMPTaskLoopDirective *S) {
1165 VisitOMPLoopDirective(S);
1166}
1167
1168void StmtProfiler::VisitOMPTaskLoopSimdDirective(
1169 const OMPTaskLoopSimdDirective *S) {
1170 VisitOMPLoopDirective(S);
1171}
1172
1173void StmtProfiler::VisitOMPMasterTaskLoopDirective(
1174 const OMPMasterTaskLoopDirective *S) {
1175 VisitOMPLoopDirective(S);
1176}
1177
1178void StmtProfiler::VisitOMPMaskedTaskLoopDirective(
1179 const OMPMaskedTaskLoopDirective *S) {
1180 VisitOMPLoopDirective(S);
1181}
1182
1183void StmtProfiler::VisitOMPMasterTaskLoopSimdDirective(
1185 VisitOMPLoopDirective(S);
1186}
1187
1188void StmtProfiler::VisitOMPMaskedTaskLoopSimdDirective(
1190 VisitOMPLoopDirective(S);
1191}
1192
1193void StmtProfiler::VisitOMPParallelMasterTaskLoopDirective(
1195 VisitOMPLoopDirective(S);
1196}
1197
1198void StmtProfiler::VisitOMPParallelMaskedTaskLoopDirective(
1200 VisitOMPLoopDirective(S);
1201}
1202
1203void StmtProfiler::VisitOMPParallelMasterTaskLoopSimdDirective(
1205 VisitOMPLoopDirective(S);
1206}
1207
1208void StmtProfiler::VisitOMPParallelMaskedTaskLoopSimdDirective(
1210 VisitOMPLoopDirective(S);
1211}
1212
1213void StmtProfiler::VisitOMPDistributeDirective(
1214 const OMPDistributeDirective *S) {
1215 VisitOMPLoopDirective(S);
1216}
1217
1218void OMPClauseProfiler::VisitOMPDistScheduleClause(
1219 const OMPDistScheduleClause *C) {
1220 VistOMPClauseWithPreInit(C);
1221 if (auto *S = C->getChunkSize())
1222 Profiler->VisitStmt(S);
1223}
1224
1225void OMPClauseProfiler::VisitOMPDefaultmapClause(const OMPDefaultmapClause *) {}
1226
1227void StmtProfiler::VisitOMPTargetUpdateDirective(
1228 const OMPTargetUpdateDirective *S) {
1229 VisitOMPExecutableDirective(S);
1230}
1231
1232void StmtProfiler::VisitOMPDistributeParallelForDirective(
1234 VisitOMPLoopDirective(S);
1235}
1236
1237void StmtProfiler::VisitOMPDistributeParallelForSimdDirective(
1239 VisitOMPLoopDirective(S);
1240}
1241
1242void StmtProfiler::VisitOMPDistributeSimdDirective(
1243 const OMPDistributeSimdDirective *S) {
1244 VisitOMPLoopDirective(S);
1245}
1246
1247void StmtProfiler::VisitOMPTargetParallelForSimdDirective(
1249 VisitOMPLoopDirective(S);
1250}
1251
1252void StmtProfiler::VisitOMPTargetSimdDirective(
1253 const OMPTargetSimdDirective *S) {
1254 VisitOMPLoopDirective(S);
1255}
1256
1257void StmtProfiler::VisitOMPTeamsDistributeDirective(
1258 const OMPTeamsDistributeDirective *S) {
1259 VisitOMPLoopDirective(S);
1260}
1261
1262void StmtProfiler::VisitOMPTeamsDistributeSimdDirective(
1264 VisitOMPLoopDirective(S);
1265}
1266
1267void StmtProfiler::VisitOMPTeamsDistributeParallelForSimdDirective(
1269 VisitOMPLoopDirective(S);
1270}
1271
1272void StmtProfiler::VisitOMPTeamsDistributeParallelForDirective(
1274 VisitOMPLoopDirective(S);
1275}
1276
1277void StmtProfiler::VisitOMPTargetTeamsDirective(
1278 const OMPTargetTeamsDirective *S) {
1279 VisitOMPExecutableDirective(S);
1280}
1281
1282void StmtProfiler::VisitOMPTargetTeamsDistributeDirective(
1284 VisitOMPLoopDirective(S);
1285}
1286
1287void StmtProfiler::VisitOMPTargetTeamsDistributeParallelForDirective(
1289 VisitOMPLoopDirective(S);
1290}
1291
1292void StmtProfiler::VisitOMPTargetTeamsDistributeParallelForSimdDirective(
1294 VisitOMPLoopDirective(S);
1295}
1296
1297void StmtProfiler::VisitOMPTargetTeamsDistributeSimdDirective(
1299 VisitOMPLoopDirective(S);
1300}
1301
1302void StmtProfiler::VisitOMPInteropDirective(const OMPInteropDirective *S) {
1303 VisitOMPExecutableDirective(S);
1304}
1305
1306void StmtProfiler::VisitOMPDispatchDirective(const OMPDispatchDirective *S) {
1307 VisitOMPExecutableDirective(S);
1308}
1309
1310void StmtProfiler::VisitOMPMaskedDirective(const OMPMaskedDirective *S) {
1311 VisitOMPExecutableDirective(S);
1312}
1313
1314void StmtProfiler::VisitOMPGenericLoopDirective(
1315 const OMPGenericLoopDirective *S) {
1316 VisitOMPLoopDirective(S);
1317}
1318
1319void StmtProfiler::VisitOMPTeamsGenericLoopDirective(
1321 VisitOMPLoopDirective(S);
1322}
1323
1324void StmtProfiler::VisitOMPTargetTeamsGenericLoopDirective(
1326 VisitOMPLoopDirective(S);
1327}
1328
1329void StmtProfiler::VisitOMPParallelGenericLoopDirective(
1331 VisitOMPLoopDirective(S);
1332}
1333
1334void StmtProfiler::VisitOMPTargetParallelGenericLoopDirective(
1336 VisitOMPLoopDirective(S);
1337}
1338
1339void StmtProfiler::VisitExpr(const Expr *S) {
1340 VisitStmt(S);
1341}
1342
1343void StmtProfiler::VisitConstantExpr(const ConstantExpr *S) {
1344 VisitExpr(S);
1345}
1346
1347void StmtProfiler::VisitDeclRefExpr(const DeclRefExpr *S) {
1348 VisitExpr(S);
1349 if (!Canonical)
1350 VisitNestedNameSpecifier(S->getQualifier());
1351 VisitDecl(S->getDecl());
1352 if (!Canonical) {
1353 ID.AddBoolean(S->hasExplicitTemplateArgs());
1354 if (S->hasExplicitTemplateArgs())
1355 VisitTemplateArguments(S->getTemplateArgs(), S->getNumTemplateArgs());
1356 }
1357}
1358
1359void StmtProfiler::VisitSYCLUniqueStableNameExpr(
1360 const SYCLUniqueStableNameExpr *S) {
1361 VisitExpr(S);
1362 VisitType(S->getTypeSourceInfo()->getType());
1363}
1364
1365void StmtProfiler::VisitPredefinedExpr(const PredefinedExpr *S) {
1366 VisitExpr(S);
1367 ID.AddInteger(llvm::to_underlying(S->getIdentKind()));
1368}
1369
1370void StmtProfiler::VisitOpenACCAsteriskSizeExpr(
1371 const OpenACCAsteriskSizeExpr *S) {
1372 VisitExpr(S);
1373}
1374
1375void StmtProfiler::VisitIntegerLiteral(const IntegerLiteral *S) {
1376 VisitExpr(S);
1377 S->getValue().Profile(ID);
1378
1379 QualType T = S->getType();
1380 if (Canonical)
1381 T = T.getCanonicalType();
1382 ID.AddInteger(T->getTypeClass());
1383 if (auto BitIntT = T->getAs<BitIntType>())
1384 BitIntT->Profile(ID);
1385 else
1386 ID.AddInteger(T->castAs<BuiltinType>()->getKind());
1387}
1388
1389void StmtProfiler::VisitFixedPointLiteral(const FixedPointLiteral *S) {
1390 VisitExpr(S);
1391 S->getValue().Profile(ID);
1392 ID.AddInteger(S->getType()->castAs<BuiltinType>()->getKind());
1393}
1394
1395void StmtProfiler::VisitCharacterLiteral(const CharacterLiteral *S) {
1396 VisitExpr(S);
1397 ID.AddInteger(llvm::to_underlying(S->getKind()));
1398 ID.AddInteger(S->getValue());
1399}
1400
1401void StmtProfiler::VisitFloatingLiteral(const FloatingLiteral *S) {
1402 VisitExpr(S);
1403 S->getValue().Profile(ID);
1404 ID.AddBoolean(S->isExact());
1405 ID.AddInteger(S->getType()->castAs<BuiltinType>()->getKind());
1406}
1407
1408void StmtProfiler::VisitImaginaryLiteral(const ImaginaryLiteral *S) {
1409 VisitExpr(S);
1410}
1411
1412void StmtProfiler::VisitStringLiteral(const StringLiteral *S) {
1413 VisitExpr(S);
1414 ID.AddString(S->getBytes());
1415 ID.AddInteger(llvm::to_underlying(S->getKind()));
1416}
1417
1418void StmtProfiler::VisitParenExpr(const ParenExpr *S) {
1419 VisitExpr(S);
1420}
1421
1422void StmtProfiler::VisitParenListExpr(const ParenListExpr *S) {
1423 VisitExpr(S);
1424}
1425
1426void StmtProfiler::VisitUnaryOperator(const UnaryOperator *S) {
1427 VisitExpr(S);
1428 ID.AddInteger(S->getOpcode());
1429}
1430
1431void StmtProfiler::VisitOffsetOfExpr(const OffsetOfExpr *S) {
1432 VisitType(S->getTypeSourceInfo()->getType());
1433 unsigned n = S->getNumComponents();
1434 for (unsigned i = 0; i < n; ++i) {
1435 const OffsetOfNode &ON = S->getComponent(i);
1436 ID.AddInteger(ON.getKind());
1437 switch (ON.getKind()) {
1439 // Expressions handled below.
1440 break;
1441
1443 VisitDecl(ON.getField());
1444 break;
1445
1447 VisitIdentifierInfo(ON.getFieldName());
1448 break;
1449
1450 case OffsetOfNode::Base:
1451 // These nodes are implicit, and therefore don't need profiling.
1452 break;
1453 }
1454 }
1455
1456 VisitExpr(S);
1457}
1458
1459void
1460StmtProfiler::VisitUnaryExprOrTypeTraitExpr(const UnaryExprOrTypeTraitExpr *S) {
1461 VisitExpr(S);
1462 ID.AddInteger(S->getKind());
1463 if (S->isArgumentType())
1464 VisitType(S->getArgumentType());
1465}
1466
1467void StmtProfiler::VisitArraySubscriptExpr(const ArraySubscriptExpr *S) {
1468 VisitExpr(S);
1469}
1470
1471void StmtProfiler::VisitMatrixSubscriptExpr(const MatrixSubscriptExpr *S) {
1472 VisitExpr(S);
1473}
1474
1475void StmtProfiler::VisitArraySectionExpr(const ArraySectionExpr *S) {
1476 VisitExpr(S);
1477}
1478
1479void StmtProfiler::VisitOMPArrayShapingExpr(const OMPArrayShapingExpr *S) {
1480 VisitExpr(S);
1481}
1482
1483void StmtProfiler::VisitOMPIteratorExpr(const OMPIteratorExpr *S) {
1484 VisitExpr(S);
1485 for (unsigned I = 0, E = S->numOfIterators(); I < E; ++I)
1486 VisitDecl(S->getIteratorDecl(I));
1487}
1488
1489void StmtProfiler::VisitCallExpr(const CallExpr *S) {
1490 VisitExpr(S);
1491}
1492
1493void StmtProfiler::VisitMemberExpr(const MemberExpr *S) {
1494 VisitExpr(S);
1495 VisitDecl(S->getMemberDecl());
1496 if (!Canonical)
1497 VisitNestedNameSpecifier(S->getQualifier());
1498 ID.AddBoolean(S->isArrow());
1499}
1500
1501void StmtProfiler::VisitCompoundLiteralExpr(const CompoundLiteralExpr *S) {
1502 VisitExpr(S);
1503 ID.AddBoolean(S->isFileScope());
1504}
1505
1506void StmtProfiler::VisitCastExpr(const CastExpr *S) {
1507 VisitExpr(S);
1508}
1509
1510void StmtProfiler::VisitImplicitCastExpr(const ImplicitCastExpr *S) {
1511 VisitCastExpr(S);
1512 ID.AddInteger(S->getValueKind());
1513}
1514
1515void StmtProfiler::VisitExplicitCastExpr(const ExplicitCastExpr *S) {
1516 VisitCastExpr(S);
1517 VisitType(S->getTypeAsWritten());
1518}
1519
1520void StmtProfiler::VisitCStyleCastExpr(const CStyleCastExpr *S) {
1521 VisitExplicitCastExpr(S);
1522}
1523
1524void StmtProfiler::VisitBinaryOperator(const BinaryOperator *S) {
1525 VisitExpr(S);
1526 ID.AddInteger(S->getOpcode());
1527}
1528
1529void
1530StmtProfiler::VisitCompoundAssignOperator(const CompoundAssignOperator *S) {
1531 VisitBinaryOperator(S);
1532}
1533
1534void StmtProfiler::VisitConditionalOperator(const ConditionalOperator *S) {
1535 VisitExpr(S);
1536}
1537
1538void StmtProfiler::VisitBinaryConditionalOperator(
1539 const BinaryConditionalOperator *S) {
1540 VisitExpr(S);
1541}
1542
1543void StmtProfiler::VisitAddrLabelExpr(const AddrLabelExpr *S) {
1544 VisitExpr(S);
1545 VisitDecl(S->getLabel());
1546}
1547
1548void StmtProfiler::VisitStmtExpr(const StmtExpr *S) {
1549 VisitExpr(S);
1550}
1551
1552void StmtProfiler::VisitShuffleVectorExpr(const ShuffleVectorExpr *S) {
1553 VisitExpr(S);
1554}
1555
1556void StmtProfiler::VisitConvertVectorExpr(const ConvertVectorExpr *S) {
1557 VisitExpr(S);
1558}
1559
1560void StmtProfiler::VisitChooseExpr(const ChooseExpr *S) {
1561 VisitExpr(S);
1562}
1563
1564void StmtProfiler::VisitGNUNullExpr(const GNUNullExpr *S) {
1565 VisitExpr(S);
1566}
1567
1568void StmtProfiler::VisitVAArgExpr(const VAArgExpr *S) {
1569 VisitExpr(S);
1570}
1571
1572void StmtProfiler::VisitInitListExpr(const InitListExpr *S) {
1573 if (S->getSyntacticForm()) {
1574 VisitInitListExpr(S->getSyntacticForm());
1575 return;
1576 }
1577
1578 VisitExpr(S);
1579}
1580
1581void StmtProfiler::VisitDesignatedInitExpr(const DesignatedInitExpr *S) {
1582 VisitExpr(S);
1583 ID.AddBoolean(S->usesGNUSyntax());
1584 for (const DesignatedInitExpr::Designator &D : S->designators()) {
1585 if (D.isFieldDesignator()) {
1586 ID.AddInteger(0);
1587 VisitName(D.getFieldName());
1588 continue;
1589 }
1590
1591 if (D.isArrayDesignator()) {
1592 ID.AddInteger(1);
1593 } else {
1594 assert(D.isArrayRangeDesignator());
1595 ID.AddInteger(2);
1596 }
1597 ID.AddInteger(D.getArrayIndex());
1598 }
1599}
1600
1601// Seems that if VisitInitListExpr() only works on the syntactic form of an
1602// InitListExpr, then a DesignatedInitUpdateExpr is not encountered.
1603void StmtProfiler::VisitDesignatedInitUpdateExpr(
1604 const DesignatedInitUpdateExpr *S) {
1605 llvm_unreachable("Unexpected DesignatedInitUpdateExpr in syntactic form of "
1606 "initializer");
1607}
1608
1609void StmtProfiler::VisitArrayInitLoopExpr(const ArrayInitLoopExpr *S) {
1610 VisitExpr(S);
1611}
1612
1613void StmtProfiler::VisitArrayInitIndexExpr(const ArrayInitIndexExpr *S) {
1614 VisitExpr(S);
1615}
1616
1617void StmtProfiler::VisitNoInitExpr(const NoInitExpr *S) {
1618 llvm_unreachable("Unexpected NoInitExpr in syntactic form of initializer");
1619}
1620
1621void StmtProfiler::VisitImplicitValueInitExpr(const ImplicitValueInitExpr *S) {
1622 VisitExpr(S);
1623}
1624
1625void StmtProfiler::VisitExtVectorElementExpr(const ExtVectorElementExpr *S) {
1626 VisitExpr(S);
1627 VisitName(&S->getAccessor());
1628}
1629
1630void StmtProfiler::VisitBlockExpr(const BlockExpr *S) {
1631 VisitExpr(S);
1632 VisitDecl(S->getBlockDecl());
1633}
1634
1635void StmtProfiler::VisitGenericSelectionExpr(const GenericSelectionExpr *S) {
1636 VisitExpr(S);
1638 S->associations()) {
1639 QualType T = Assoc.getType();
1640 if (T.isNull())
1641 ID.AddPointer(nullptr);
1642 else
1643 VisitType(T);
1644 VisitExpr(Assoc.getAssociationExpr());
1645 }
1646}
1647
1648void StmtProfiler::VisitPseudoObjectExpr(const PseudoObjectExpr *S) {
1649 VisitExpr(S);
1651 i = S->semantics_begin(), e = S->semantics_end(); i != e; ++i)
1652 // Normally, we would not profile the source expressions of OVEs.
1653 if (const OpaqueValueExpr *OVE = dyn_cast<OpaqueValueExpr>(*i))
1654 Visit(OVE->getSourceExpr());
1655}
1656
1657void StmtProfiler::VisitAtomicExpr(const AtomicExpr *S) {
1658 VisitExpr(S);
1659 ID.AddInteger(S->getOp());
1660}
1661
1662void StmtProfiler::VisitConceptSpecializationExpr(
1663 const ConceptSpecializationExpr *S) {
1664 VisitExpr(S);
1665 VisitDecl(S->getNamedConcept());
1666 for (const TemplateArgument &Arg : S->getTemplateArguments())
1667 VisitTemplateArgument(Arg);
1668}
1669
1670void StmtProfiler::VisitRequiresExpr(const RequiresExpr *S) {
1671 VisitExpr(S);
1672 ID.AddInteger(S->getLocalParameters().size());
1673 for (ParmVarDecl *LocalParam : S->getLocalParameters())
1674 VisitDecl(LocalParam);
1675 ID.AddInteger(S->getRequirements().size());
1676 for (concepts::Requirement *Req : S->getRequirements()) {
1677 if (auto *TypeReq = dyn_cast<concepts::TypeRequirement>(Req)) {
1679 ID.AddBoolean(TypeReq->isSubstitutionFailure());
1680 if (!TypeReq->isSubstitutionFailure())
1681 VisitType(TypeReq->getType()->getType());
1682 } else if (auto *ExprReq = dyn_cast<concepts::ExprRequirement>(Req)) {
1684 ID.AddBoolean(ExprReq->isExprSubstitutionFailure());
1685 if (!ExprReq->isExprSubstitutionFailure())
1686 Visit(ExprReq->getExpr());
1687 // C++2a [expr.prim.req.compound]p1 Example:
1688 // [...] The compound-requirement in C1 requires that x++ is a valid
1689 // expression. It is equivalent to the simple-requirement x++; [...]
1690 // We therefore do not profile isSimple() here.
1691 ID.AddBoolean(ExprReq->getNoexceptLoc().isValid());
1693 ExprReq->getReturnTypeRequirement();
1694 if (RetReq.isEmpty()) {
1695 ID.AddInteger(0);
1696 } else if (RetReq.isTypeConstraint()) {
1697 ID.AddInteger(1);
1699 } else {
1700 assert(RetReq.isSubstitutionFailure());
1701 ID.AddInteger(2);
1702 }
1703 } else {
1705 auto *NestedReq = cast<concepts::NestedRequirement>(Req);
1706 ID.AddBoolean(NestedReq->hasInvalidConstraint());
1707 if (!NestedReq->hasInvalidConstraint())
1708 Visit(NestedReq->getConstraintExpr());
1709 }
1710 }
1711}
1712
1714 UnaryOperatorKind &UnaryOp,
1715 BinaryOperatorKind &BinaryOp,
1716 unsigned &NumArgs) {
1717 switch (S->getOperator()) {
1718 case OO_None:
1719 case OO_New:
1720 case OO_Delete:
1721 case OO_Array_New:
1722 case OO_Array_Delete:
1723 case OO_Arrow:
1724 case OO_Conditional:
1726 llvm_unreachable("Invalid operator call kind");
1727
1728 case OO_Plus:
1729 if (NumArgs == 1) {
1730 UnaryOp = UO_Plus;
1731 return Stmt::UnaryOperatorClass;
1732 }
1733
1734 BinaryOp = BO_Add;
1735 return Stmt::BinaryOperatorClass;
1736
1737 case OO_Minus:
1738 if (NumArgs == 1) {
1739 UnaryOp = UO_Minus;
1740 return Stmt::UnaryOperatorClass;
1741 }
1742
1743 BinaryOp = BO_Sub;
1744 return Stmt::BinaryOperatorClass;
1745
1746 case OO_Star:
1747 if (NumArgs == 1) {
1748 UnaryOp = UO_Deref;
1749 return Stmt::UnaryOperatorClass;
1750 }
1751
1752 BinaryOp = BO_Mul;
1753 return Stmt::BinaryOperatorClass;
1754
1755 case OO_Slash:
1756 BinaryOp = BO_Div;
1757 return Stmt::BinaryOperatorClass;
1758
1759 case OO_Percent:
1760 BinaryOp = BO_Rem;
1761 return Stmt::BinaryOperatorClass;
1762
1763 case OO_Caret:
1764 BinaryOp = BO_Xor;
1765 return Stmt::BinaryOperatorClass;
1766
1767 case OO_Amp:
1768 if (NumArgs == 1) {
1769 UnaryOp = UO_AddrOf;
1770 return Stmt::UnaryOperatorClass;
1771 }
1772
1773 BinaryOp = BO_And;
1774 return Stmt::BinaryOperatorClass;
1775
1776 case OO_Pipe:
1777 BinaryOp = BO_Or;
1778 return Stmt::BinaryOperatorClass;
1779
1780 case OO_Tilde:
1781 UnaryOp = UO_Not;
1782 return Stmt::UnaryOperatorClass;
1783
1784 case OO_Exclaim:
1785 UnaryOp = UO_LNot;
1786 return Stmt::UnaryOperatorClass;
1787
1788 case OO_Equal:
1789 BinaryOp = BO_Assign;
1790 return Stmt::BinaryOperatorClass;
1791
1792 case OO_Less:
1793 BinaryOp = BO_LT;
1794 return Stmt::BinaryOperatorClass;
1795
1796 case OO_Greater:
1797 BinaryOp = BO_GT;
1798 return Stmt::BinaryOperatorClass;
1799
1800 case OO_PlusEqual:
1801 BinaryOp = BO_AddAssign;
1802 return Stmt::CompoundAssignOperatorClass;
1803
1804 case OO_MinusEqual:
1805 BinaryOp = BO_SubAssign;
1806 return Stmt::CompoundAssignOperatorClass;
1807
1808 case OO_StarEqual:
1809 BinaryOp = BO_MulAssign;
1810 return Stmt::CompoundAssignOperatorClass;
1811
1812 case OO_SlashEqual:
1813 BinaryOp = BO_DivAssign;
1814 return Stmt::CompoundAssignOperatorClass;
1815
1816 case OO_PercentEqual:
1817 BinaryOp = BO_RemAssign;
1818 return Stmt::CompoundAssignOperatorClass;
1819
1820 case OO_CaretEqual:
1821 BinaryOp = BO_XorAssign;
1822 return Stmt::CompoundAssignOperatorClass;
1823
1824 case OO_AmpEqual:
1825 BinaryOp = BO_AndAssign;
1826 return Stmt::CompoundAssignOperatorClass;
1827
1828 case OO_PipeEqual:
1829 BinaryOp = BO_OrAssign;
1830 return Stmt::CompoundAssignOperatorClass;
1831
1832 case OO_LessLess:
1833 BinaryOp = BO_Shl;
1834 return Stmt::BinaryOperatorClass;
1835
1836 case OO_GreaterGreater:
1837 BinaryOp = BO_Shr;
1838 return Stmt::BinaryOperatorClass;
1839
1840 case OO_LessLessEqual:
1841 BinaryOp = BO_ShlAssign;
1842 return Stmt::CompoundAssignOperatorClass;
1843
1844 case OO_GreaterGreaterEqual:
1845 BinaryOp = BO_ShrAssign;
1846 return Stmt::CompoundAssignOperatorClass;
1847
1848 case OO_EqualEqual:
1849 BinaryOp = BO_EQ;
1850 return Stmt::BinaryOperatorClass;
1851
1852 case OO_ExclaimEqual:
1853 BinaryOp = BO_NE;
1854 return Stmt::BinaryOperatorClass;
1855
1856 case OO_LessEqual:
1857 BinaryOp = BO_LE;
1858 return Stmt::BinaryOperatorClass;
1859
1860 case OO_GreaterEqual:
1861 BinaryOp = BO_GE;
1862 return Stmt::BinaryOperatorClass;
1863
1864 case OO_Spaceship:
1865 BinaryOp = BO_Cmp;
1866 return Stmt::BinaryOperatorClass;
1867
1868 case OO_AmpAmp:
1869 BinaryOp = BO_LAnd;
1870 return Stmt::BinaryOperatorClass;
1871
1872 case OO_PipePipe:
1873 BinaryOp = BO_LOr;
1874 return Stmt::BinaryOperatorClass;
1875
1876 case OO_PlusPlus:
1877 UnaryOp = NumArgs == 1 ? UO_PreInc : UO_PostInc;
1878 NumArgs = 1;
1879 return Stmt::UnaryOperatorClass;
1880
1881 case OO_MinusMinus:
1882 UnaryOp = NumArgs == 1 ? UO_PreDec : UO_PostDec;
1883 NumArgs = 1;
1884 return Stmt::UnaryOperatorClass;
1885
1886 case OO_Comma:
1887 BinaryOp = BO_Comma;
1888 return Stmt::BinaryOperatorClass;
1889
1890 case OO_ArrowStar:
1891 BinaryOp = BO_PtrMemI;
1892 return Stmt::BinaryOperatorClass;
1893
1894 case OO_Subscript:
1895 return Stmt::ArraySubscriptExprClass;
1896
1897 case OO_Call:
1898 return Stmt::CallExprClass;
1899
1900 case OO_Coawait:
1901 UnaryOp = UO_Coawait;
1902 return Stmt::UnaryOperatorClass;
1903 }
1904
1905 llvm_unreachable("Invalid overloaded operator expression");
1906}
1907
1908#if defined(_MSC_VER) && !defined(__clang__)
1909#if _MSC_VER == 1911
1910// Work around https://developercommunity.visualstudio.com/content/problem/84002/clang-cl-when-built-with-vc-2017-crashes-cause-vc.html
1911// MSVC 2017 update 3 miscompiles this function, and a clang built with it
1912// will crash in stage 2 of a bootstrap build.
1913#pragma optimize("", off)
1914#endif
1915#endif
1916
1917void StmtProfiler::VisitCXXOperatorCallExpr(const CXXOperatorCallExpr *S) {
1918 if (S->isTypeDependent()) {
1919 // Type-dependent operator calls are profiled like their underlying
1920 // syntactic operator.
1921 //
1922 // An operator call to operator-> is always implicit, so just skip it. The
1923 // enclosing MemberExpr will profile the actual member access.
1924 if (S->getOperator() == OO_Arrow)
1925 return Visit(S->getArg(0));
1926
1927 UnaryOperatorKind UnaryOp = UO_Extension;
1928 BinaryOperatorKind BinaryOp = BO_Comma;
1929 unsigned NumArgs = S->getNumArgs();
1930 Stmt::StmtClass SC = DecodeOperatorCall(S, UnaryOp, BinaryOp, NumArgs);
1931
1932 ID.AddInteger(SC);
1933 for (unsigned I = 0; I != NumArgs; ++I)
1934 Visit(S->getArg(I));
1935 if (SC == Stmt::UnaryOperatorClass)
1936 ID.AddInteger(UnaryOp);
1937 else if (SC == Stmt::BinaryOperatorClass ||
1938 SC == Stmt::CompoundAssignOperatorClass)
1939 ID.AddInteger(BinaryOp);
1940 else
1941 assert(SC == Stmt::ArraySubscriptExprClass || SC == Stmt::CallExprClass);
1942
1943 return;
1944 }
1945
1946 VisitCallExpr(S);
1947 ID.AddInteger(S->getOperator());
1948}
1949
1950void StmtProfiler::VisitCXXRewrittenBinaryOperator(
1951 const CXXRewrittenBinaryOperator *S) {
1952 // If a rewritten operator were ever to be type-dependent, we should profile
1953 // it following its syntactic operator.
1954 assert(!S->isTypeDependent() &&
1955 "resolved rewritten operator should never be type-dependent");
1956 ID.AddBoolean(S->isReversed());
1957 VisitExpr(S->getSemanticForm());
1958}
1959
1960#if defined(_MSC_VER) && !defined(__clang__)
1961#if _MSC_VER == 1911
1962#pragma optimize("", on)
1963#endif
1964#endif
1965
1966void StmtProfiler::VisitCXXMemberCallExpr(const CXXMemberCallExpr *S) {
1967 VisitCallExpr(S);
1968}
1969
1970void StmtProfiler::VisitCUDAKernelCallExpr(const CUDAKernelCallExpr *S) {
1971 VisitCallExpr(S);
1972}
1973
1974void StmtProfiler::VisitAsTypeExpr(const AsTypeExpr *S) {
1975 VisitExpr(S);
1976}
1977
1978void StmtProfiler::VisitCXXNamedCastExpr(const CXXNamedCastExpr *S) {
1979 VisitExplicitCastExpr(S);
1980}
1981
1982void StmtProfiler::VisitCXXStaticCastExpr(const CXXStaticCastExpr *S) {
1983 VisitCXXNamedCastExpr(S);
1984}
1985
1986void StmtProfiler::VisitCXXDynamicCastExpr(const CXXDynamicCastExpr *S) {
1987 VisitCXXNamedCastExpr(S);
1988}
1989
1990void
1991StmtProfiler::VisitCXXReinterpretCastExpr(const CXXReinterpretCastExpr *S) {
1992 VisitCXXNamedCastExpr(S);
1993}
1994
1995void StmtProfiler::VisitCXXConstCastExpr(const CXXConstCastExpr *S) {
1996 VisitCXXNamedCastExpr(S);
1997}
1998
1999void StmtProfiler::VisitBuiltinBitCastExpr(const BuiltinBitCastExpr *S) {
2000 VisitExpr(S);
2001 VisitType(S->getTypeInfoAsWritten()->getType());
2002}
2003
2004void StmtProfiler::VisitCXXAddrspaceCastExpr(const CXXAddrspaceCastExpr *S) {
2005 VisitCXXNamedCastExpr(S);
2006}
2007
2008void StmtProfiler::VisitUserDefinedLiteral(const UserDefinedLiteral *S) {
2009 VisitCallExpr(S);
2010}
2011
2012void StmtProfiler::VisitCXXBoolLiteralExpr(const CXXBoolLiteralExpr *S) {
2013 VisitExpr(S);
2014 ID.AddBoolean(S->getValue());
2015}
2016
2017void StmtProfiler::VisitCXXNullPtrLiteralExpr(const CXXNullPtrLiteralExpr *S) {
2018 VisitExpr(S);
2019}
2020
2021void StmtProfiler::VisitCXXStdInitializerListExpr(
2022 const CXXStdInitializerListExpr *S) {
2023 VisitExpr(S);
2024}
2025
2026void StmtProfiler::VisitCXXTypeidExpr(const CXXTypeidExpr *S) {
2027 VisitExpr(S);
2028 if (S->isTypeOperand())
2029 VisitType(S->getTypeOperandSourceInfo()->getType());
2030}
2031
2032void StmtProfiler::VisitCXXUuidofExpr(const CXXUuidofExpr *S) {
2033 VisitExpr(S);
2034 if (S->isTypeOperand())
2035 VisitType(S->getTypeOperandSourceInfo()->getType());
2036}
2037
2038void StmtProfiler::VisitMSPropertyRefExpr(const MSPropertyRefExpr *S) {
2039 VisitExpr(S);
2040 VisitDecl(S->getPropertyDecl());
2041}
2042
2043void StmtProfiler::VisitMSPropertySubscriptExpr(
2044 const MSPropertySubscriptExpr *S) {
2045 VisitExpr(S);
2046}
2047
2048void StmtProfiler::VisitCXXThisExpr(const CXXThisExpr *S) {
2049 VisitExpr(S);
2050 ID.AddBoolean(S->isImplicit());
2051 ID.AddBoolean(S->isCapturedByCopyInLambdaWithExplicitObjectParameter());
2052}
2053
2054void StmtProfiler::VisitCXXThrowExpr(const CXXThrowExpr *S) {
2055 VisitExpr(S);
2056}
2057
2058void StmtProfiler::VisitCXXDefaultArgExpr(const CXXDefaultArgExpr *S) {
2059 VisitExpr(S);
2060 VisitDecl(S->getParam());
2061}
2062
2063void StmtProfiler::VisitCXXDefaultInitExpr(const CXXDefaultInitExpr *S) {
2064 VisitExpr(S);
2065 VisitDecl(S->getField());
2066}
2067
2068void StmtProfiler::VisitCXXBindTemporaryExpr(const CXXBindTemporaryExpr *S) {
2069 VisitExpr(S);
2070 VisitDecl(
2071 const_cast<CXXDestructorDecl *>(S->getTemporary()->getDestructor()));
2072}
2073
2074void StmtProfiler::VisitCXXConstructExpr(const CXXConstructExpr *S) {
2075 VisitExpr(S);
2076 VisitDecl(S->getConstructor());
2077 ID.AddBoolean(S->isElidable());
2078}
2079
2080void StmtProfiler::VisitCXXInheritedCtorInitExpr(
2081 const CXXInheritedCtorInitExpr *S) {
2082 VisitExpr(S);
2083 VisitDecl(S->getConstructor());
2084}
2085
2086void StmtProfiler::VisitCXXFunctionalCastExpr(const CXXFunctionalCastExpr *S) {
2087 VisitExplicitCastExpr(S);
2088}
2089
2090void
2091StmtProfiler::VisitCXXTemporaryObjectExpr(const CXXTemporaryObjectExpr *S) {
2092 VisitCXXConstructExpr(S);
2093}
2094
2095void
2096StmtProfiler::VisitLambdaExpr(const LambdaExpr *S) {
2097 if (!ProfileLambdaExpr) {
2098 // Do not recursively visit the children of this expression. Profiling the
2099 // body would result in unnecessary work, and is not safe to do during
2100 // deserialization.
2101 VisitStmtNoChildren(S);
2102
2103 // C++20 [temp.over.link]p5:
2104 // Two lambda-expressions are never considered equivalent.
2105 VisitDecl(S->getLambdaClass());
2106
2107 return;
2108 }
2109
2110 CXXRecordDecl *Lambda = S->getLambdaClass();
2111 for (const auto &Capture : Lambda->captures()) {
2112 ID.AddInteger(Capture.getCaptureKind());
2113 if (Capture.capturesVariable())
2114 VisitDecl(Capture.getCapturedVar());
2115 }
2116
2117 // Profiling the body of the lambda may be dangerous during deserialization.
2118 // So we'd like only to profile the signature here.
2119 ODRHash Hasher;
2120 // FIXME: We can't get the operator call easily by
2121 // `CXXRecordDecl::getLambdaCallOperator()` if we're in deserialization.
2122 // So we have to do something raw here.
2123 for (auto *SubDecl : Lambda->decls()) {
2124 FunctionDecl *Call = nullptr;
2125 if (auto *FTD = dyn_cast<FunctionTemplateDecl>(SubDecl))
2126 Call = FTD->getTemplatedDecl();
2127 else if (auto *FD = dyn_cast<FunctionDecl>(SubDecl))
2128 Call = FD;
2129
2130 if (!Call)
2131 continue;
2132
2133 Hasher.AddFunctionDecl(Call, /*SkipBody=*/true);
2134 }
2135 ID.AddInteger(Hasher.CalculateHash());
2136}
2137
2138void
2139StmtProfiler::VisitCXXScalarValueInitExpr(const CXXScalarValueInitExpr *S) {
2140 VisitExpr(S);
2141}
2142
2143void StmtProfiler::VisitCXXDeleteExpr(const CXXDeleteExpr *S) {
2144 VisitExpr(S);
2145 ID.AddBoolean(S->isGlobalDelete());
2146 ID.AddBoolean(S->isArrayForm());
2147 VisitDecl(S->getOperatorDelete());
2148}
2149
2150void StmtProfiler::VisitCXXNewExpr(const CXXNewExpr *S) {
2151 VisitExpr(S);
2152 VisitType(S->getAllocatedType());
2153 VisitDecl(S->getOperatorNew());
2154 VisitDecl(S->getOperatorDelete());
2155 ID.AddBoolean(S->isArray());
2156 ID.AddInteger(S->getNumPlacementArgs());
2157 ID.AddBoolean(S->isGlobalNew());
2158 ID.AddBoolean(S->isParenTypeId());
2159 ID.AddInteger(llvm::to_underlying(S->getInitializationStyle()));
2160}
2161
2162void
2163StmtProfiler::VisitCXXPseudoDestructorExpr(const CXXPseudoDestructorExpr *S) {
2164 VisitExpr(S);
2165 ID.AddBoolean(S->isArrow());
2166 VisitNestedNameSpecifier(S->getQualifier());
2167 ID.AddBoolean(S->getScopeTypeInfo() != nullptr);
2168 if (S->getScopeTypeInfo())
2169 VisitType(S->getScopeTypeInfo()->getType());
2170 ID.AddBoolean(S->getDestroyedTypeInfo() != nullptr);
2171 if (S->getDestroyedTypeInfo())
2172 VisitType(S->getDestroyedType());
2173 else
2174 VisitIdentifierInfo(S->getDestroyedTypeIdentifier());
2175}
2176
2177void StmtProfiler::VisitOverloadExpr(const OverloadExpr *S) {
2178 VisitExpr(S);
2179 VisitNestedNameSpecifier(S->getQualifier());
2180 VisitName(S->getName(), /*TreatAsDecl*/ true);
2181 ID.AddBoolean(S->hasExplicitTemplateArgs());
2182 if (S->hasExplicitTemplateArgs())
2183 VisitTemplateArguments(S->getTemplateArgs(), S->getNumTemplateArgs());
2184}
2185
2186void
2187StmtProfiler::VisitUnresolvedLookupExpr(const UnresolvedLookupExpr *S) {
2188 VisitOverloadExpr(S);
2189}
2190
2191void StmtProfiler::VisitTypeTraitExpr(const TypeTraitExpr *S) {
2192 VisitExpr(S);
2193 ID.AddInteger(S->getTrait());
2194 ID.AddInteger(S->getNumArgs());
2195 for (unsigned I = 0, N = S->getNumArgs(); I != N; ++I)
2196 VisitType(S->getArg(I)->getType());
2197}
2198
2199void StmtProfiler::VisitArrayTypeTraitExpr(const ArrayTypeTraitExpr *S) {
2200 VisitExpr(S);
2201 ID.AddInteger(S->getTrait());
2202 VisitType(S->getQueriedType());
2203}
2204
2205void StmtProfiler::VisitExpressionTraitExpr(const ExpressionTraitExpr *S) {
2206 VisitExpr(S);
2207 ID.AddInteger(S->getTrait());
2208 VisitExpr(S->getQueriedExpression());
2209}
2210
2211void StmtProfiler::VisitDependentScopeDeclRefExpr(
2212 const DependentScopeDeclRefExpr *S) {
2213 VisitExpr(S);
2214 VisitName(S->getDeclName());
2215 VisitNestedNameSpecifier(S->getQualifier());
2216 ID.AddBoolean(S->hasExplicitTemplateArgs());
2217 if (S->hasExplicitTemplateArgs())
2218 VisitTemplateArguments(S->getTemplateArgs(), S->getNumTemplateArgs());
2219}
2220
2221void StmtProfiler::VisitExprWithCleanups(const ExprWithCleanups *S) {
2222 VisitExpr(S);
2223}
2224
2225void StmtProfiler::VisitCXXUnresolvedConstructExpr(
2226 const CXXUnresolvedConstructExpr *S) {
2227 VisitExpr(S);
2228 VisitType(S->getTypeAsWritten());
2229 ID.AddInteger(S->isListInitialization());
2230}
2231
2232void StmtProfiler::VisitCXXDependentScopeMemberExpr(
2233 const CXXDependentScopeMemberExpr *S) {
2234 ID.AddBoolean(S->isImplicitAccess());
2235 if (!S->isImplicitAccess()) {
2236 VisitExpr(S);
2237 ID.AddBoolean(S->isArrow());
2238 }
2239 VisitNestedNameSpecifier(S->getQualifier());
2240 VisitName(S->getMember());
2241 ID.AddBoolean(S->hasExplicitTemplateArgs());
2242 if (S->hasExplicitTemplateArgs())
2243 VisitTemplateArguments(S->getTemplateArgs(), S->getNumTemplateArgs());
2244}
2245
2246void StmtProfiler::VisitUnresolvedMemberExpr(const UnresolvedMemberExpr *S) {
2247 ID.AddBoolean(S->isImplicitAccess());
2248 if (!S->isImplicitAccess()) {
2249 VisitExpr(S);
2250 ID.AddBoolean(S->isArrow());
2251 }
2252 VisitNestedNameSpecifier(S->getQualifier());
2253 VisitName(S->getMemberName());
2254 ID.AddBoolean(S->hasExplicitTemplateArgs());
2255 if (S->hasExplicitTemplateArgs())
2256 VisitTemplateArguments(S->getTemplateArgs(), S->getNumTemplateArgs());
2257}
2258
2259void StmtProfiler::VisitCXXNoexceptExpr(const CXXNoexceptExpr *S) {
2260 VisitExpr(S);
2261}
2262
2263void StmtProfiler::VisitPackExpansionExpr(const PackExpansionExpr *S) {
2264 VisitExpr(S);
2265}
2266
2267void StmtProfiler::VisitSizeOfPackExpr(const SizeOfPackExpr *S) {
2268 VisitExpr(S);
2269 VisitDecl(S->getPack());
2270 if (S->isPartiallySubstituted()) {
2271 auto Args = S->getPartialArguments();
2272 ID.AddInteger(Args.size());
2273 for (const auto &TA : Args)
2274 VisitTemplateArgument(TA);
2275 } else {
2276 ID.AddInteger(0);
2277 }
2278}
2279
2280void StmtProfiler::VisitPackIndexingExpr(const PackIndexingExpr *E) {
2281 VisitExpr(E);
2282 VisitExpr(E->getPackIdExpression());
2283 VisitExpr(E->getIndexExpr());
2284}
2285
2286void StmtProfiler::VisitSubstNonTypeTemplateParmPackExpr(
2288 VisitExpr(S);
2289 VisitDecl(S->getParameterPack());
2290 VisitTemplateArgument(S->getArgumentPack());
2291}
2292
2293void StmtProfiler::VisitSubstNonTypeTemplateParmExpr(
2295 // Profile exactly as the replacement expression.
2296 Visit(E->getReplacement());
2297}
2298
2299void StmtProfiler::VisitFunctionParmPackExpr(const FunctionParmPackExpr *S) {
2300 VisitExpr(S);
2301 VisitDecl(S->getParameterPack());
2302 ID.AddInteger(S->getNumExpansions());
2303 for (FunctionParmPackExpr::iterator I = S->begin(), E = S->end(); I != E; ++I)
2304 VisitDecl(*I);
2305}
2306
2307void StmtProfiler::VisitMaterializeTemporaryExpr(
2308 const MaterializeTemporaryExpr *S) {
2309 VisitExpr(S);
2310}
2311
2312void StmtProfiler::VisitCXXFoldExpr(const CXXFoldExpr *S) {
2313 VisitExpr(S);
2314 ID.AddInteger(S->getOperator());
2315}
2316
2317void StmtProfiler::VisitCXXParenListInitExpr(const CXXParenListInitExpr *S) {
2318 VisitExpr(S);
2319}
2320
2321void StmtProfiler::VisitCoroutineBodyStmt(const CoroutineBodyStmt *S) {
2322 VisitStmt(S);
2323}
2324
2325void StmtProfiler::VisitCoreturnStmt(const CoreturnStmt *S) {
2326 VisitStmt(S);
2327}
2328
2329void StmtProfiler::VisitCoawaitExpr(const CoawaitExpr *S) {
2330 VisitExpr(S);
2331}
2332
2333void StmtProfiler::VisitDependentCoawaitExpr(const DependentCoawaitExpr *S) {
2334 VisitExpr(S);
2335}
2336
2337void StmtProfiler::VisitCoyieldExpr(const CoyieldExpr *S) {
2338 VisitExpr(S);
2339}
2340
2341void StmtProfiler::VisitOpaqueValueExpr(const OpaqueValueExpr *E) {
2342 VisitExpr(E);
2343}
2344
2345void StmtProfiler::VisitTypoExpr(const TypoExpr *E) {
2346 VisitExpr(E);
2347}
2348
2349void StmtProfiler::VisitSourceLocExpr(const SourceLocExpr *E) {
2350 VisitExpr(E);
2351}
2352
2353void StmtProfiler::VisitEmbedExpr(const EmbedExpr *E) { VisitExpr(E); }
2354
2355void StmtProfiler::VisitRecoveryExpr(const RecoveryExpr *E) { VisitExpr(E); }
2356
2357void StmtProfiler::VisitObjCStringLiteral(const ObjCStringLiteral *S) {
2358 VisitExpr(S);
2359}
2360
2361void StmtProfiler::VisitObjCBoxedExpr(const ObjCBoxedExpr *E) {
2362 VisitExpr(E);
2363}
2364
2365void StmtProfiler::VisitObjCArrayLiteral(const ObjCArrayLiteral *E) {
2366 VisitExpr(E);
2367}
2368
2369void StmtProfiler::VisitObjCDictionaryLiteral(const ObjCDictionaryLiteral *E) {
2370 VisitExpr(E);
2371}
2372
2373void StmtProfiler::VisitObjCEncodeExpr(const ObjCEncodeExpr *S) {
2374 VisitExpr(S);
2375 VisitType(S->getEncodedType());
2376}
2377
2378void StmtProfiler::VisitObjCSelectorExpr(const ObjCSelectorExpr *S) {
2379 VisitExpr(S);
2380 VisitName(S->getSelector());
2381}
2382
2383void StmtProfiler::VisitObjCProtocolExpr(const ObjCProtocolExpr *S) {
2384 VisitExpr(S);
2385 VisitDecl(S->getProtocol());
2386}
2387
2388void StmtProfiler::VisitObjCIvarRefExpr(const ObjCIvarRefExpr *S) {
2389 VisitExpr(S);
2390 VisitDecl(S->getDecl());
2391 ID.AddBoolean(S->isArrow());
2392 ID.AddBoolean(S->isFreeIvar());
2393}
2394
2395void StmtProfiler::VisitObjCPropertyRefExpr(const ObjCPropertyRefExpr *S) {
2396 VisitExpr(S);
2397 if (S->isImplicitProperty()) {
2398 VisitDecl(S->getImplicitPropertyGetter());
2399 VisitDecl(S->getImplicitPropertySetter());
2400 } else {
2401 VisitDecl(S->getExplicitProperty());
2402 }
2403 if (S->isSuperReceiver()) {
2404 ID.AddBoolean(S->isSuperReceiver());
2405 VisitType(S->getSuperReceiverType());
2406 }
2407}
2408
2409void StmtProfiler::VisitObjCSubscriptRefExpr(const ObjCSubscriptRefExpr *S) {
2410 VisitExpr(S);
2411 VisitDecl(S->getAtIndexMethodDecl());
2412 VisitDecl(S->setAtIndexMethodDecl());
2413}
2414
2415void StmtProfiler::VisitObjCMessageExpr(const ObjCMessageExpr *S) {
2416 VisitExpr(S);
2417 VisitName(S->getSelector());
2418 VisitDecl(S->getMethodDecl());
2419}
2420
2421void StmtProfiler::VisitObjCIsaExpr(const ObjCIsaExpr *S) {
2422 VisitExpr(S);
2423 ID.AddBoolean(S->isArrow());
2424}
2425
2426void StmtProfiler::VisitObjCBoolLiteralExpr(const ObjCBoolLiteralExpr *S) {
2427 VisitExpr(S);
2428 ID.AddBoolean(S->getValue());
2429}
2430
2431void StmtProfiler::VisitObjCIndirectCopyRestoreExpr(
2432 const ObjCIndirectCopyRestoreExpr *S) {
2433 VisitExpr(S);
2434 ID.AddBoolean(S->shouldCopy());
2435}
2436
2437void StmtProfiler::VisitObjCBridgedCastExpr(const ObjCBridgedCastExpr *S) {
2438 VisitExplicitCastExpr(S);
2439 ID.AddBoolean(S->getBridgeKind());
2440}
2441
2442void StmtProfiler::VisitObjCAvailabilityCheckExpr(
2443 const ObjCAvailabilityCheckExpr *S) {
2444 VisitExpr(S);
2445}
2446
2447void StmtProfiler::VisitTemplateArguments(const TemplateArgumentLoc *Args,
2448 unsigned NumArgs) {
2449 ID.AddInteger(NumArgs);
2450 for (unsigned I = 0; I != NumArgs; ++I)
2451 VisitTemplateArgument(Args[I].getArgument());
2452}
2453
2454void StmtProfiler::VisitTemplateArgument(const TemplateArgument &Arg) {
2455 // Mostly repetitive with TemplateArgument::Profile!
2456 ID.AddInteger(Arg.getKind());
2457 switch (Arg.getKind()) {
2459 break;
2460
2462 VisitType(Arg.getAsType());
2463 break;
2464
2467 VisitTemplateName(Arg.getAsTemplateOrTemplatePattern());
2468 break;
2469
2471 VisitType(Arg.getParamTypeForDecl());
2472 // FIXME: Do we need to recursively decompose template parameter objects?
2473 VisitDecl(Arg.getAsDecl());
2474 break;
2475
2477 VisitType(Arg.getNullPtrType());
2478 break;
2479
2481 VisitType(Arg.getIntegralType());
2482 Arg.getAsIntegral().Profile(ID);
2483 break;
2484
2486 VisitType(Arg.getStructuralValueType());
2487 // FIXME: Do we need to recursively decompose this ourselves?
2488 Arg.getAsStructuralValue().Profile(ID);
2489 break;
2490
2492 Visit(Arg.getAsExpr());
2493 break;
2494
2496 for (const auto &P : Arg.pack_elements())
2497 VisitTemplateArgument(P);
2498 break;
2499 }
2500}
2501
2502namespace {
2503class OpenACCClauseProfiler
2504 : public OpenACCClauseVisitor<OpenACCClauseProfiler> {
2505 StmtProfiler &Profiler;
2506
2507public:
2508 OpenACCClauseProfiler(StmtProfiler &P) : Profiler(P) {}
2509
2510 void VisitOpenACCClauseList(ArrayRef<const OpenACCClause *> Clauses) {
2511 for (const OpenACCClause *Clause : Clauses) {
2512 // TODO OpenACC: When we have clauses with expressions, we should
2513 // profile them too.
2514 Visit(Clause);
2515 }
2516 }
2517
2518 void VisitClauseWithVarList(const OpenACCClauseWithVarList &Clause) {
2519 for (auto *E : Clause.getVarList())
2520 Profiler.VisitStmt(E);
2521 }
2522
2523#define VISIT_CLAUSE(CLAUSE_NAME) \
2524 void Visit##CLAUSE_NAME##Clause(const OpenACC##CLAUSE_NAME##Clause &Clause);
2525
2526#include "clang/Basic/OpenACCClauses.def"
2527};
2528
2529/// Nothing to do here, there are no sub-statements.
2530void OpenACCClauseProfiler::VisitDefaultClause(
2531 const OpenACCDefaultClause &Clause) {}
2532
2533void OpenACCClauseProfiler::VisitIfClause(const OpenACCIfClause &Clause) {
2534 assert(Clause.hasConditionExpr() &&
2535 "if clause requires a valid condition expr");
2536 Profiler.VisitStmt(Clause.getConditionExpr());
2537}
2538
2539void OpenACCClauseProfiler::VisitCopyClause(const OpenACCCopyClause &Clause) {
2540 VisitClauseWithVarList(Clause);
2541}
2542void OpenACCClauseProfiler::VisitCopyInClause(
2543 const OpenACCCopyInClause &Clause) {
2544 VisitClauseWithVarList(Clause);
2545}
2546
2547void OpenACCClauseProfiler::VisitCopyOutClause(
2548 const OpenACCCopyOutClause &Clause) {
2549 VisitClauseWithVarList(Clause);
2550}
2551
2552void OpenACCClauseProfiler::VisitCreateClause(
2553 const OpenACCCreateClause &Clause) {
2554 VisitClauseWithVarList(Clause);
2555}
2556
2557void OpenACCClauseProfiler::VisitSelfClause(const OpenACCSelfClause &Clause) {
2558 if (Clause.hasConditionExpr())
2559 Profiler.VisitStmt(Clause.getConditionExpr());
2560}
2561
2562void OpenACCClauseProfiler::VisitFinalizeClause(
2563 const OpenACCFinalizeClause &Clause) {}
2564
2565void OpenACCClauseProfiler::VisitIfPresentClause(
2566 const OpenACCIfPresentClause &Clause) {}
2567
2568void OpenACCClauseProfiler::VisitNumGangsClause(
2569 const OpenACCNumGangsClause &Clause) {
2570 for (auto *E : Clause.getIntExprs())
2571 Profiler.VisitStmt(E);
2572}
2573
2574void OpenACCClauseProfiler::VisitTileClause(const OpenACCTileClause &Clause) {
2575 for (auto *E : Clause.getSizeExprs())
2576 Profiler.VisitStmt(E);
2577}
2578
2579void OpenACCClauseProfiler::VisitNumWorkersClause(
2580 const OpenACCNumWorkersClause &Clause) {
2581 assert(Clause.hasIntExpr() && "num_workers clause requires a valid int expr");
2582 Profiler.VisitStmt(Clause.getIntExpr());
2583}
2584
2585void OpenACCClauseProfiler::VisitCollapseClause(
2586 const OpenACCCollapseClause &Clause) {
2587 assert(Clause.getLoopCount() && "collapse clause requires a valid int expr");
2588 Profiler.VisitStmt(Clause.getLoopCount());
2589}
2590
2591void OpenACCClauseProfiler::VisitPrivateClause(
2592 const OpenACCPrivateClause &Clause) {
2593 VisitClauseWithVarList(Clause);
2594}
2595
2596void OpenACCClauseProfiler::VisitFirstPrivateClause(
2597 const OpenACCFirstPrivateClause &Clause) {
2598 VisitClauseWithVarList(Clause);
2599}
2600
2601void OpenACCClauseProfiler::VisitAttachClause(
2602 const OpenACCAttachClause &Clause) {
2603 VisitClauseWithVarList(Clause);
2604}
2605
2606void OpenACCClauseProfiler::VisitDetachClause(
2607 const OpenACCDetachClause &Clause) {
2608 VisitClauseWithVarList(Clause);
2609}
2610
2611void OpenACCClauseProfiler::VisitDeleteClause(
2612 const OpenACCDeleteClause &Clause) {
2613 VisitClauseWithVarList(Clause);
2614}
2615
2616void OpenACCClauseProfiler::VisitDevicePtrClause(
2617 const OpenACCDevicePtrClause &Clause) {
2618 VisitClauseWithVarList(Clause);
2619}
2620
2621void OpenACCClauseProfiler::VisitNoCreateClause(
2622 const OpenACCNoCreateClause &Clause) {
2623 VisitClauseWithVarList(Clause);
2624}
2625
2626void OpenACCClauseProfiler::VisitPresentClause(
2627 const OpenACCPresentClause &Clause) {
2628 VisitClauseWithVarList(Clause);
2629}
2630
2631void OpenACCClauseProfiler::VisitUseDeviceClause(
2632 const OpenACCUseDeviceClause &Clause) {
2633 VisitClauseWithVarList(Clause);
2634}
2635
2636void OpenACCClauseProfiler::VisitVectorLengthClause(
2637 const OpenACCVectorLengthClause &Clause) {
2638 assert(Clause.hasIntExpr() &&
2639 "vector_length clause requires a valid int expr");
2640 Profiler.VisitStmt(Clause.getIntExpr());
2641}
2642
2643void OpenACCClauseProfiler::VisitAsyncClause(const OpenACCAsyncClause &Clause) {
2644 if (Clause.hasIntExpr())
2645 Profiler.VisitStmt(Clause.getIntExpr());
2646}
2647
2648void OpenACCClauseProfiler::VisitDeviceNumClause(
2649 const OpenACCDeviceNumClause &Clause) {
2650 Profiler.VisitStmt(Clause.getIntExpr());
2651}
2652
2653void OpenACCClauseProfiler::VisitWorkerClause(
2654 const OpenACCWorkerClause &Clause) {
2655 if (Clause.hasIntExpr())
2656 Profiler.VisitStmt(Clause.getIntExpr());
2657}
2658
2659void OpenACCClauseProfiler::VisitVectorClause(
2660 const OpenACCVectorClause &Clause) {
2661 if (Clause.hasIntExpr())
2662 Profiler.VisitStmt(Clause.getIntExpr());
2663}
2664
2665void OpenACCClauseProfiler::VisitWaitClause(const OpenACCWaitClause &Clause) {
2666 if (Clause.hasDevNumExpr())
2667 Profiler.VisitStmt(Clause.getDevNumExpr());
2668 for (auto *E : Clause.getQueueIdExprs())
2669 Profiler.VisitStmt(E);
2670}
2671/// Nothing to do here, there are no sub-statements.
2672void OpenACCClauseProfiler::VisitDeviceTypeClause(
2673 const OpenACCDeviceTypeClause &Clause) {}
2674
2675void OpenACCClauseProfiler::VisitAutoClause(const OpenACCAutoClause &Clause) {}
2676
2677void OpenACCClauseProfiler::VisitIndependentClause(
2678 const OpenACCIndependentClause &Clause) {}
2679
2680void OpenACCClauseProfiler::VisitSeqClause(const OpenACCSeqClause &Clause) {}
2681
2682void OpenACCClauseProfiler::VisitGangClause(const OpenACCGangClause &Clause) {
2683 for (unsigned I = 0; I < Clause.getNumExprs(); ++I) {
2684 Profiler.VisitStmt(Clause.getExpr(I).second);
2685 }
2686}
2687
2688void OpenACCClauseProfiler::VisitReductionClause(
2689 const OpenACCReductionClause &Clause) {
2690 VisitClauseWithVarList(Clause);
2691}
2692} // namespace
2693
2694void StmtProfiler::VisitOpenACCComputeConstruct(
2695 const OpenACCComputeConstruct *S) {
2696 // VisitStmt handles children, so the AssociatedStmt is handled.
2697 VisitStmt(S);
2698
2699 OpenACCClauseProfiler P{*this};
2700 P.VisitOpenACCClauseList(S->clauses());
2701}
2702
2703void StmtProfiler::VisitOpenACCLoopConstruct(const OpenACCLoopConstruct *S) {
2704 // VisitStmt handles children, so the Loop is handled.
2705 VisitStmt(S);
2706
2707 OpenACCClauseProfiler P{*this};
2708 P.VisitOpenACCClauseList(S->clauses());
2709}
2710
2711void StmtProfiler::VisitOpenACCCombinedConstruct(
2712 const OpenACCCombinedConstruct *S) {
2713 // VisitStmt handles children, so the Loop is handled.
2714 VisitStmt(S);
2715
2716 OpenACCClauseProfiler P{*this};
2717 P.VisitOpenACCClauseList(S->clauses());
2718}
2719
2720void StmtProfiler::VisitOpenACCDataConstruct(const OpenACCDataConstruct *S) {
2721 VisitStmt(S);
2722
2723 OpenACCClauseProfiler P{*this};
2724 P.VisitOpenACCClauseList(S->clauses());
2725}
2726
2727void StmtProfiler::VisitOpenACCEnterDataConstruct(
2728 const OpenACCEnterDataConstruct *S) {
2729 VisitStmt(S);
2730
2731 OpenACCClauseProfiler P{*this};
2732 P.VisitOpenACCClauseList(S->clauses());
2733}
2734
2735void StmtProfiler::VisitOpenACCExitDataConstruct(
2736 const OpenACCExitDataConstruct *S) {
2737 VisitStmt(S);
2738
2739 OpenACCClauseProfiler P{*this};
2740 P.VisitOpenACCClauseList(S->clauses());
2741}
2742
2743void StmtProfiler::VisitOpenACCHostDataConstruct(
2744 const OpenACCHostDataConstruct *S) {
2745 VisitStmt(S);
2746
2747 OpenACCClauseProfiler P{*this};
2748 P.VisitOpenACCClauseList(S->clauses());
2749}
2750
2751void StmtProfiler::VisitOpenACCWaitConstruct(const OpenACCWaitConstruct *S) {
2752 // VisitStmt covers 'children', so the exprs inside of it are covered.
2753 VisitStmt(S);
2754
2755 OpenACCClauseProfiler P{*this};
2756 P.VisitOpenACCClauseList(S->clauses());
2757}
2758
2759void StmtProfiler::VisitOpenACCInitConstruct(const OpenACCInitConstruct *S) {
2760 VisitStmt(S);
2761 OpenACCClauseProfiler P{*this};
2762 P.VisitOpenACCClauseList(S->clauses());
2763}
2764
2765void StmtProfiler::VisitOpenACCShutdownConstruct(
2766 const OpenACCShutdownConstruct *S) {
2767 VisitStmt(S);
2768 OpenACCClauseProfiler P{*this};
2769 P.VisitOpenACCClauseList(S->clauses());
2770}
2771
2772void StmtProfiler::VisitHLSLOutArgExpr(const HLSLOutArgExpr *S) {
2773 VisitStmt(S);
2774}
2775
2776void Stmt::Profile(llvm::FoldingSetNodeID &ID, const ASTContext &Context,
2777 bool Canonical, bool ProfileLambdaExpr) const {
2778 StmtProfilerWithPointers Profiler(ID, Context, Canonical, ProfileLambdaExpr);
2779 Profiler.Visit(this);
2780}
2781
2782void Stmt::ProcessODRHash(llvm::FoldingSetNodeID &ID,
2783 class ODRHash &Hash) const {
2784 StmtProfilerWithoutPointers Profiler(ID, Hash);
2785 Profiler.Visit(this);
2786}
Defines the clang::ASTContext interface.
DynTypedNode Node
StringRef P
const Decl * D
Expr * E
Defines the C++ Decl subclasses, other than those for templates (found in DeclTemplate....
Defines the C++ template declaration subclasses.
Defines the clang::Expr interface and subclasses for C++ expressions.
This file contains the declaration of the ODRHash class, which calculates a hash based on AST nodes,...
This file defines OpenMP AST classes for clauses.
static Stmt::StmtClass DecodeOperatorCall(const CXXOperatorCallExpr *S, UnaryOperatorKind &UnaryOp, BinaryOperatorKind &BinaryOp, unsigned &NumArgs)
static const TemplateArgument & getArgument(const TemplateArgument &A)
void Profile(llvm::FoldingSetNodeID &ID) const
profile this value.
Definition: APValue.cpp:479
Holds long-lived AST nodes (such as types and decls) that can be referred to throughout the semantic ...
Definition: ASTContext.h:188
CanQualType getCanonicalType(QualType T) const
Return the canonical (structural) type corresponding to the specified potentially non-canonical type ...
Definition: ASTContext.h:2716
TemplateName getCanonicalTemplateName(TemplateName Name, bool IgnoreDeduced=false) const
Retrieves the "canonical" template name that refers to a given template.
QualType getUnconstrainedType(QualType T) const
Remove any type constraints from a template parameter type, for equivalence comparison of template pa...
NestedNameSpecifier * getCanonicalNestedNameSpecifier(NestedNameSpecifier *NNS) const
Retrieves the "canonical" nested name specifier for a given nested name specifier.
AddrLabelExpr - The GNU address of label extension, representing &&label.
Definition: Expr.h:4421
Represents the index of the current element of an array being initialized by an ArrayInitLoopExpr.
Definition: Expr.h:5805
Represents a loop initializing the elements of an array.
Definition: Expr.h:5752
This class represents BOTH the OpenMP Array Section and OpenACC 'subarray', with a boolean differenti...
Definition: Expr.h:6986
ArraySubscriptExpr - [C99 6.5.2.1] Array Subscripting.
Definition: Expr.h:2718
An Embarcadero array type trait, as used in the implementation of __array_rank and __array_extent.
Definition: ExprCXX.h:2853
AsTypeExpr - Clang builtin function __builtin_astype [OpenCL 6.2.4.2] This AST node provides support ...
Definition: Expr.h:6475
AtomicExpr - Variadic atomic builtins: __atomic_exchange, __atomic_fetch_*, __atomic_load,...
Definition: Expr.h:6678
Represents an attribute applied to a statement.
Definition: Stmt.h:2107
BinaryConditionalOperator - The GNU extension to the conditional operator which allows the middle ope...
Definition: Expr.h:4324
A builtin binary operation expression such as "x + y" or "x <= y".
Definition: Expr.h:3909
A fixed int type of a specified bitwidth.
Definition: Type.h:7814
BlockExpr - Adaptor class for mixing a BlockDecl with expressions.
Definition: Expr.h:6414
BreakStmt - This represents a break.
Definition: Stmt.h:3007
Represents a C++2a __builtin_bit_cast(T, v) expression.
Definition: ExprCXX.h:5298
This class is used for builtin types like 'int'.
Definition: Type.h:3034
Kind getKind() const
Definition: Type.h:3082
CStyleCastExpr - An explicit cast in C (C99 6.5.4) or a C-style cast in C++ (C++ [expr....
Definition: Expr.h:3840
Represents a call to a CUDA kernel function.
Definition: ExprCXX.h:231
A C++ addrspace_cast expression (currently only enabled for OpenCL).
Definition: ExprCXX.h:601
Represents binding an expression to a temporary.
Definition: ExprCXX.h:1491
A boolean literal, per ([C++ lex.bool] Boolean literals).
Definition: ExprCXX.h:720
CXXCatchStmt - This represents a C++ catch block.
Definition: StmtCXX.h:28
A C++ const_cast expression (C++ [expr.const.cast]).
Definition: ExprCXX.h:563
Represents a call to a C++ constructor.
Definition: ExprCXX.h:1546
A default argument (C++ [dcl.fct.default]).
Definition: ExprCXX.h:1268
A use of a default initializer in a constructor or in aggregate initialization.
Definition: ExprCXX.h:1375
Represents a delete expression for memory deallocation and destructor calls, e.g.
Definition: ExprCXX.h:2498
Represents a C++ member access expression where the actual member referenced could not be resolved be...
Definition: ExprCXX.h:3683
Represents a C++ destructor within a class.
Definition: DeclCXX.h:2817
A C++ dynamic_cast expression (C++ [expr.dynamic.cast]).
Definition: ExprCXX.h:478
Represents a folding of a pack over an operator.
Definition: ExprCXX.h:4846
CXXForRangeStmt - This represents C++0x [stmt.ranged]'s ranged for statement, represented as 'for (ra...
Definition: StmtCXX.h:135
Represents an explicit C++ type conversion that uses "functional" notation (C++ [expr....
Definition: ExprCXX.h:1817
Represents a call to an inherited base class constructor from an inheriting constructor.
Definition: ExprCXX.h:1737
Represents a call to a member function that may be written either with member call syntax (e....
Definition: ExprCXX.h:176
Abstract class common to all of the C++ "named"/"keyword" casts.
Definition: ExprCXX.h:372
Represents a new-expression for memory allocation and constructor calls, e.g: "new CXXNewExpr(foo)".
Definition: ExprCXX.h:2241
Represents a C++11 noexcept expression (C++ [expr.unary.noexcept]).
Definition: ExprCXX.h:4126
The null pointer literal (C++11 [lex.nullptr])
Definition: ExprCXX.h:765
A call to an overloaded operator written using operator syntax.
Definition: ExprCXX.h:81
Represents a list-initialization with parenthesis.
Definition: ExprCXX.h:4960
Represents a C++ pseudo-destructor (C++ [expr.pseudo]).
Definition: ExprCXX.h:2617
Represents a C++ struct/union/class.
Definition: DeclCXX.h:258
capture_const_range captures() const
Definition: DeclCXX.h:1109
A C++ reinterpret_cast expression (C++ [expr.reinterpret.cast]).
Definition: ExprCXX.h:523
A rewritten comparison expression that was originally written using operator syntax.
Definition: ExprCXX.h:283
An expression "T()" which creates an rvalue of a non-class type T.
Definition: ExprCXX.h:2182
A C++ static_cast expression (C++ [expr.static.cast]).
Definition: ExprCXX.h:433
Implicit construction of a std::initializer_list<T> object from an array temporary within list-initia...
Definition: ExprCXX.h:797
Represents a C++ functional cast expression that builds a temporary object.
Definition: ExprCXX.h:1885
Represents the this expression in C++.
Definition: ExprCXX.h:1152
A C++ throw-expression (C++ [except.throw]).
Definition: ExprCXX.h:1206
CXXTryStmt - A C++ try block, including all handlers.
Definition: StmtCXX.h:69
A C++ typeid expression (C++ [expr.typeid]), which gets the type_info that corresponds to the supplie...
Definition: ExprCXX.h:845
Describes an explicit type conversion that uses functional notion but could not be resolved because o...
Definition: ExprCXX.h:3557
A Microsoft C++ __uuidof expression, which gets the _GUID that corresponds to the supplied type or ex...
Definition: ExprCXX.h:1066
CallExpr - Represents a function call (C99 6.5.2.2, C++ [expr.call]).
Definition: Expr.h:2874
This captures a statement into a function.
Definition: Stmt.h:3784
CaseStmt - Represent a case statement.
Definition: Stmt.h:1828
CastExpr - Base class for type casts, including both implicit casts (ImplicitCastExpr) and explicit c...
Definition: Expr.h:3547
ChooseExpr - GNU builtin-in function __builtin_choose_expr.
Definition: Expr.h:4641
Represents a 'co_await' expression.
Definition: ExprCXX.h:5191
CompoundAssignOperator - For compound assignments (e.g.
Definition: Expr.h:4171
CompoundLiteralExpr - [C99 6.5.2.5].
Definition: Expr.h:3477
CompoundStmt - This represents a group of statements like { stmt stmt }.
Definition: Stmt.h:1628
Represents the specialization of a concept - evaluates to a prvalue of type bool.
Definition: ExprConcepts.h:42
ConditionalOperator - The ?: ternary operator.
Definition: Expr.h:4262
ConstStmtVisitor - This class implements a simple visitor for Stmt subclasses.
Definition: StmtVisitor.h:195
ConstantExpr - An expression that occurs in a constant context and optionally the result of evaluatin...
Definition: Expr.h:1077
ContinueStmt - This represents a continue.
Definition: Stmt.h:2977
ConvertVectorExpr - Clang builtin function __builtin_convertvector This AST node provides support for...
Definition: Expr.h:4582
Represents a 'co_return' statement in the C++ Coroutines TS.
Definition: StmtCXX.h:473
Represents the body of a coroutine.
Definition: StmtCXX.h:320
Represents a 'co_yield' expression.
Definition: ExprCXX.h:5272
decl_range decls() const
decls_begin/decls_end - Iterate over the declarations stored in this context.
Definition: DeclBase.h:2349
A reference to a declared variable, function, enum, etc.
Definition: Expr.h:1265
DeclStmt - Adaptor class for mixing declarations with statements and expressions.
Definition: Stmt.h:1519
Decl - This represents one declaration (or definition), e.g.
Definition: DeclBase.h:86
virtual Decl * getCanonicalDecl()
Retrieves the "canonical" declaration of the given declaration.
Definition: DeclBase.h:967
Kind getKind() const
Definition: DeclBase.h:445
The name of a declaration.
Represents a 'co_await' expression while the type of the promise is dependent.
Definition: ExprCXX.h:5223
A qualified reference to a name whose declaration cannot yet be resolved.
Definition: ExprCXX.h:3323
Represents a single C99 designator.
Definition: Expr.h:5376
Represents a C99 designated initializer expression.
Definition: Expr.h:5333
DoStmt - This represents a 'do/while' stmt.
Definition: Stmt.h:2752
Represents a reference to #emded data.
Definition: Expr.h:4916
ExplicitCastExpr - An explicit cast written in the source code.
Definition: Expr.h:3799
Represents an expression – generally a full-expression – that introduces cleanups to be run at the en...
Definition: ExprCXX.h:3474
This represents one expression.
Definition: Expr.h:110
An expression trait intrinsic.
Definition: ExprCXX.h:2924
ExtVectorElementExpr - This represents access to specific elements of a vector, and may occur on the ...
Definition: Expr.h:6354
ForStmt - This represents a 'for (init;cond;inc)' stmt.
Definition: Stmt.h:2808
Represents a function declaration or definition.
Definition: Decl.h:1935
Represents a reference to a function parameter pack or init-capture pack that has been substituted bu...
Definition: ExprCXX.h:4654
VarDecl *const * iterator
Iterators over the parameters which the parameter pack expanded into.
Definition: ExprCXX.h:4688
This represents a GCC inline-assembly statement extension.
Definition: Stmt.h:3286
GNUNullExpr - Implements the GNU __null extension, which is a name for a null pointer constant that h...
Definition: Expr.h:4716
Represents a C11 generic selection.
Definition: Expr.h:5966
AssociationTy< true > ConstAssociation
Definition: Expr.h:6198
GotoStmt - This represents a direct goto.
Definition: Stmt.h:2889
This class represents temporary values used to represent inout and out arguments in HLSL.
Definition: Expr.h:7152
One of these records is kept for each identifier that is lexed.
IfStmt - This represents an if/then/else.
Definition: Stmt.h:2165
ImaginaryLiteral - We support imaginary integer and floating point literals, like "1....
Definition: Expr.h:1717
ImplicitCastExpr - Allows us to explicitly represent implicit type conversions, which have no direct ...
Definition: Expr.h:3724
Represents an implicitly-generated value initialization of an object of a given type.
Definition: Expr.h:5841
IndirectGotoStmt - This represents an indirect goto.
Definition: Stmt.h:2928
Describes an C or C++ initializer list.
Definition: Expr.h:5088
LabelStmt - Represents a label, which has a substatement.
Definition: Stmt.h:2058
A C++ lambda expression, which produces a function object (of unspecified type) that can be invoked l...
Definition: ExprCXX.h:1954
This represents a Microsoft inline-assembly statement extension.
Definition: Stmt.h:3509
Representation of a Microsoft __if_exists or __if_not_exists statement with a dependent name.
Definition: StmtCXX.h:253
A member reference to an MSPropertyDecl.
Definition: ExprCXX.h:933
MS property subscript expression.
Definition: ExprCXX.h:1004
Represents a prvalue temporary that is written into memory so that a reference can bind to it.
Definition: ExprCXX.h:4734
MatrixSubscriptExpr - Matrix subscript expression for the MatrixType extension.
Definition: Expr.h:2796
MemberExpr - [C99 6.5.2.3] Structure and Union Members.
Definition: Expr.h:3236
Represents a C++ nested name specifier, such as "\::std::vector<int>::".
Represents a place-holder for an object not to be initialized by anything.
Definition: Expr.h:5661
NonTypeTemplateParmDecl - Declares a non-type template parameter, e.g., "Size" in.
NullStmt - This is the null statement ";": C99 6.8.3p3.
Definition: Stmt.h:1591
void AddDecl(const Decl *D)
Definition: ODRHash.cpp:808
void AddIdentifierInfo(const IdentifierInfo *II)
Definition: ODRHash.cpp:28
void AddDeclarationName(DeclarationName Name, bool TreatAsDecl=false)
Definition: ODRHash.cpp:33
void AddNestedNameSpecifier(const NestedNameSpecifier *NNS)
Definition: ODRHash.cpp:111
void AddFunctionDecl(const FunctionDecl *Function, bool SkipBody=false)
Definition: ODRHash.cpp:662
void AddTemplateName(TemplateName Name)
Definition: ODRHash.cpp:140
void AddQualType(QualType T)
Definition: ODRHash.cpp:1268
unsigned CalculateHash()
Definition: ODRHash.cpp:226
This represents the 'absent' clause in the '#pragma omp assume' directive.
This represents 'acq_rel' clause in the '#pragma omp atomic|flush' directives.
This represents 'acquire' clause in the '#pragma omp atomic|flush' directives.
This represents clause 'affinity' in the '#pragma omp task'-based directives.
This represents the 'align' clause in the '#pragma omp allocate' directive.
Definition: OpenMPClause.h:448
This represents clause 'aligned' in the '#pragma omp ...' directives.
This represents clause 'allocate' in the '#pragma omp ...' directives.
Definition: OpenMPClause.h:493
This represents 'allocator' clause in the '#pragma omp ...' directive.
Definition: OpenMPClause.h:414
An explicit cast in C or a C-style cast in C++, which uses the syntax ([s1][s2]......
Definition: ExprOpenMP.h:24
This represents 'at' clause in the '#pragma omp error' directive.
This represents 'atomic_default_mem_order' clause in the '#pragma omp requires' directive.
This represents '#pragma omp atomic' directive.
Definition: StmtOpenMP.h:2947
This represents '#pragma omp barrier' directive.
Definition: StmtOpenMP.h:2625
This represents 'bind' clause in the '#pragma omp ...' directives.
This represents '#pragma omp cancel' directive.
Definition: StmtOpenMP.h:3655
This represents '#pragma omp cancellation point' directive.
Definition: StmtOpenMP.h:3597
Representation of an OpenMP canonical loop.
Definition: StmtOpenMP.h:142
This represents 'capture' clause in the '#pragma omp atomic' directive.
Class that handles post-update expression for some clauses, like 'lastprivate', 'reduction' etc.
Definition: OpenMPClause.h:233
Class that handles pre-initialization statement for some clauses, like 'schedule',...
Definition: OpenMPClause.h:195
This represents 'collapse' clause in the '#pragma omp ...' directive.
This represents 'compare' clause in the '#pragma omp atomic' directive.
This represents the 'contains' clause in the '#pragma omp assume' directive.
This represents clause 'copyin' in the '#pragma omp ...' directives.
This represents clause 'copyprivate' in the '#pragma omp ...' directives.
This represents '#pragma omp critical' directive.
Definition: StmtOpenMP.h:2076
This represents 'default' clause in the '#pragma omp ...' directive.
This represents 'defaultmap' clause in the '#pragma omp ...' directive.
This represents implicit clause 'depend' for the '#pragma omp task' directive.
This represents implicit clause 'depobj' for the '#pragma omp depobj' directive.
This represents '#pragma omp depobj' directive.
Definition: StmtOpenMP.h:2841
This represents 'destroy' clause in the '#pragma omp depobj' directive or the '#pragma omp interop' d...
This represents 'detach' clause in the '#pragma omp task' directive.
This represents 'device' clause in the '#pragma omp ...' directive.
This represents '#pragma omp dispatch' directive.
Definition: StmtOpenMP.h:5948
This represents 'dist_schedule' clause in the '#pragma omp ...' directive.
This represents '#pragma omp distribute' directive.
Definition: StmtOpenMP.h:4425
This represents '#pragma omp distribute parallel for' composite directive.
Definition: StmtOpenMP.h:4547
This represents '#pragma omp distribute parallel for simd' composite directive.
Definition: StmtOpenMP.h:4643
This represents '#pragma omp distribute simd' composite directive.
Definition: StmtOpenMP.h:4708
This represents the 'doacross' clause for the '#pragma omp ordered' directive.
This represents 'dynamic_allocators' clause in the '#pragma omp requires' directive.
This represents '#pragma omp error' directive.
Definition: StmtOpenMP.h:6432
This represents clause 'exclusive' in the '#pragma omp scan' directive.
This is a basic class for representing single OpenMP executable directive.
Definition: StmtOpenMP.h:266
This represents 'fail' clause in the '#pragma omp atomic' directive.
This represents 'filter' clause in the '#pragma omp ...' directive.
This represents 'final' clause in the '#pragma omp ...' directive.
Definition: OpenMPClause.h:715
This represents clause 'firstprivate' in the '#pragma omp ...' directives.
This represents implicit clause 'flush' for the '#pragma omp flush' directive.
This represents '#pragma omp flush' directive.
Definition: StmtOpenMP.h:2789
This represents '#pragma omp for' directive.
Definition: StmtOpenMP.h:1634
This represents '#pragma omp for simd' directive.
Definition: StmtOpenMP.h:1724
This represents clause 'from' in the '#pragma omp ...' directives.
Representation of the 'full' clause of the '#pragma omp unroll' directive.
This represents '#pragma omp loop' directive.
Definition: StmtOpenMP.h:6103
This represents 'grainsize' clause in the '#pragma omp ...' directive.
This represents clause 'has_device_ptr' in the '#pragma omp ...' directives.
This represents 'hint' clause in the '#pragma omp ...' directive.
This represents the 'holds' clause in the '#pragma omp assume' directive.
This represents 'if' clause in the '#pragma omp ...' directive.
Definition: OpenMPClause.h:612
This represents clause 'in_reduction' in the '#pragma omp task' directives.
This represents clause 'inclusive' in the '#pragma omp scan' directive.
This represents the 'init' clause in '#pragma omp ...' directives.
Represents the '#pragma omp interchange' loop transformation directive.
Definition: StmtOpenMP.h:5769
This represents '#pragma omp interop' directive.
Definition: StmtOpenMP.h:5895
This represents clause 'is_device_ptr' in the '#pragma omp ...' directives.
OpenMP 5.0 [2.1.6 Iterators] Iterators are identifiers that expand to multiple values in the clause o...
Definition: ExprOpenMP.h:151
This represents clause 'lastprivate' in the '#pragma omp ...' directives.
This represents clause 'linear' in the '#pragma omp ...' directives.
The base class for all loop-based directives, including loop transformation directives.
Definition: StmtOpenMP.h:683
This is a common base class for loop directives ('omp simd', 'omp for', 'omp for simd' etc....
Definition: StmtOpenMP.h:1004
The base class for all loop transformation directives.
Definition: StmtOpenMP.h:960
This represents clause 'map' in the '#pragma omp ...' directives.
This represents '#pragma omp masked' directive.
Definition: StmtOpenMP.h:6013
This represents '#pragma omp masked taskloop' directive.
Definition: StmtOpenMP.h:3930
This represents '#pragma omp masked taskloop simd' directive.
Definition: StmtOpenMP.h:4071
This represents '#pragma omp master' directive.
Definition: StmtOpenMP.h:2028
This represents '#pragma omp master taskloop' directive.
Definition: StmtOpenMP.h:3854
This represents '#pragma omp master taskloop simd' directive.
Definition: StmtOpenMP.h:4006
This represents 'mergeable' clause in the '#pragma omp ...' directive.
This represents 'message' clause in the '#pragma omp error' directive.
This represents '#pragma omp metadirective' directive.
Definition: StmtOpenMP.h:6064
This represents the 'no_openmp' clause in the '#pragma omp assume' directive.
This represents the 'no_openmp_routines' clause in the '#pragma omp assume' directive.
This represents the 'no_parallelism' clause in the '#pragma omp assume' directive.
This represents 'nocontext' clause in the '#pragma omp ...' directive.
This represents 'nogroup' clause in the '#pragma omp ...' directive.
This represents clause 'nontemporal' in the '#pragma omp ...' directives.
This represents 'novariants' clause in the '#pragma omp ...' directive.
This represents 'nowait' clause in the '#pragma omp ...' directive.
This represents 'num_tasks' clause in the '#pragma omp ...' directive.
This represents 'num_teams' clause in the '#pragma omp ...' directive.
This represents 'num_threads' clause in the '#pragma omp ...' directive.
Definition: OpenMPClause.h:761
This represents 'order' clause in the '#pragma omp ...' directive.
This represents 'ordered' clause in the '#pragma omp ...' directive.
This represents '#pragma omp ordered' directive.
Definition: StmtOpenMP.h:2893
This represents '#pragma omp parallel' directive.
Definition: StmtOpenMP.h:612
This represents '#pragma omp parallel for' directive.
Definition: StmtOpenMP.h:2147
This represents '#pragma omp parallel for simd' directive.
Definition: StmtOpenMP.h:2244
This represents '#pragma omp parallel loop' directive.
Definition: StmtOpenMP.h:6305
This represents '#pragma omp parallel masked' directive.
Definition: StmtOpenMP.h:2372
This represents '#pragma omp parallel masked taskloop' directive.
Definition: StmtOpenMP.h:4215
This represents '#pragma omp parallel masked taskloop simd' directive.
Definition: StmtOpenMP.h:4360
This represents '#pragma omp parallel master' directive.
Definition: StmtOpenMP.h:2309
This represents '#pragma omp parallel master taskloop' directive.
Definition: StmtOpenMP.h:4137
This represents '#pragma omp parallel master taskloop simd' directive.
Definition: StmtOpenMP.h:4293
This represents '#pragma omp parallel sections' directive.
Definition: StmtOpenMP.h:2436
Representation of the 'partial' clause of the '#pragma omp unroll' directive.
This class represents the 'permutation' clause in the '#pragma omp interchange' directive.
Definition: OpenMPClause.h:968
This represents 'priority' clause in the '#pragma omp ...' directive.
This represents clause 'private' in the '#pragma omp ...' directives.
This represents 'proc_bind' clause in the '#pragma omp ...' directive.
This represents 'read' clause in the '#pragma omp atomic' directive.
This represents clause 'reduction' in the '#pragma omp ...' directives.
This represents 'relaxed' clause in the '#pragma omp atomic' directives.
This represents 'release' clause in the '#pragma omp atomic|flush' directives.
Represents the '#pragma omp reverse' loop transformation directive.
Definition: StmtOpenMP.h:5704
This represents 'reverse_offload' clause in the '#pragma omp requires' directive.
This represents 'simd' clause in the '#pragma omp ...' directive.
This represents 'safelen' clause in the '#pragma omp ...' directive.
Definition: OpenMPClause.h:806
This represents '#pragma omp scan' directive.
Definition: StmtOpenMP.h:5842
This represents 'schedule' clause in the '#pragma omp ...' directive.
This represents '#pragma omp scope' directive.
Definition: StmtOpenMP.h:1925
This represents '#pragma omp section' directive.
Definition: StmtOpenMP.h:1864
This represents '#pragma omp sections' directive.
Definition: StmtOpenMP.h:1787
This represents 'seq_cst' clause in the '#pragma omp atomic|flush' directives.
This represents 'severity' clause in the '#pragma omp error' directive.
This represents clause 'shared' in the '#pragma omp ...' directives.
This represents '#pragma omp simd' directive.
Definition: StmtOpenMP.h:1571
This represents 'simdlen' clause in the '#pragma omp ...' directive.
Definition: OpenMPClause.h:841
This represents '#pragma omp single' directive.
Definition: StmtOpenMP.h:1977
This represents the 'sizes' clause in the '#pragma omp tile' directive.
Definition: OpenMPClause.h:873
This represents '#pragma omp target data' directive.
Definition: StmtOpenMP.h:3206
This represents '#pragma omp target' directive.
Definition: StmtOpenMP.h:3152
This represents '#pragma omp target enter data' directive.
Definition: StmtOpenMP.h:3260
This represents '#pragma omp target exit data' directive.
Definition: StmtOpenMP.h:3315
This represents '#pragma omp target parallel' directive.
Definition: StmtOpenMP.h:3369
This represents '#pragma omp target parallel for' directive.
Definition: StmtOpenMP.h:3449
This represents '#pragma omp target parallel for simd' directive.
Definition: StmtOpenMP.h:4774
This represents '#pragma omp target parallel loop' directive.
Definition: StmtOpenMP.h:6370
This represents '#pragma omp target simd' directive.
Definition: StmtOpenMP.h:4841
This represents '#pragma omp target teams' directive.
Definition: StmtOpenMP.h:5199
This represents '#pragma omp target teams distribute' combined directive.
Definition: StmtOpenMP.h:5255
This represents '#pragma omp target teams distribute parallel for' combined directive.
Definition: StmtOpenMP.h:5322
This represents '#pragma omp target teams distribute parallel for simd' combined directive.
Definition: StmtOpenMP.h:5420
This represents '#pragma omp target teams distribute simd' combined directive.
Definition: StmtOpenMP.h:5490
This represents '#pragma omp target teams loop' directive.
Definition: StmtOpenMP.h:6230
This represents '#pragma omp target update' directive.
Definition: StmtOpenMP.h:4491
This represents '#pragma omp task' directive.
Definition: StmtOpenMP.h:2517
This represents '#pragma omp taskloop' directive.
Definition: StmtOpenMP.h:3715
This represents '#pragma omp taskloop simd' directive.
Definition: StmtOpenMP.h:3788
This represents clause 'task_reduction' in the '#pragma omp taskgroup' directives.
This represents '#pragma omp taskgroup' directive.
Definition: StmtOpenMP.h:2722
This represents '#pragma omp taskwait' directive.
Definition: StmtOpenMP.h:2671
This represents '#pragma omp taskyield' directive.
Definition: StmtOpenMP.h:2579
This represents '#pragma omp teams' directive.
Definition: StmtOpenMP.h:3544
This represents '#pragma omp teams distribute' directive.
Definition: StmtOpenMP.h:4906
This represents '#pragma omp teams distribute parallel for' composite directive.
Definition: StmtOpenMP.h:5106
This represents '#pragma omp teams distribute parallel for simd' composite directive.
Definition: StmtOpenMP.h:5040
This represents '#pragma omp teams distribute simd' combined directive.
Definition: StmtOpenMP.h:4972
This represents '#pragma omp teams loop' directive.
Definition: StmtOpenMP.h:6165
This represents 'thread_limit' clause in the '#pragma omp ...' directive.
This represents 'threads' clause in the '#pragma omp ...' directive.
This represents the '#pragma omp tile' loop transformation directive.
Definition: StmtOpenMP.h:5548
This represents clause 'to' in the '#pragma omp ...' directives.
This represents 'unified_address' clause in the '#pragma omp requires' directive.
This represents 'unified_shared_memory' clause in the '#pragma omp requires' directive.
This represents the '#pragma omp unroll' loop transformation directive.
Definition: StmtOpenMP.h:5630
This represents 'untied' clause in the '#pragma omp ...' directive.
This represents 'update' clause in the '#pragma omp atomic' directive.
This represents the 'use' clause in '#pragma omp ...' directives.
This represents clause 'use_device_addr' in the '#pragma omp ...' directives.
This represents clause 'use_device_ptr' in the '#pragma omp ...' directives.
This represents clause 'uses_allocators' in the '#pragma omp target'-based directives.
This represents 'weak' clause in the '#pragma omp atomic' directives.
This represents 'write' clause in the '#pragma omp atomic' directive.
This represents 'ompx_attribute' clause in a directive that might generate an outlined function.
This represents 'ompx_bare' clause in the '#pragma omp target teams ...' directive.
This represents 'ompx_dyn_cgroup_mem' clause in the '#pragma omp target ...' directive.
ObjCArrayLiteral - used for objective-c array containers; as in: @["Hello", NSApp,...
Definition: ExprObjC.h:191
Represents Objective-C's @catch statement.
Definition: StmtObjC.h:77
Represents Objective-C's @finally statement.
Definition: StmtObjC.h:127
Represents Objective-C's @synchronized statement.
Definition: StmtObjC.h:303
Represents Objective-C's @throw statement.
Definition: StmtObjC.h:358
Represents Objective-C's @try ... @catch ... @finally statement.
Definition: StmtObjC.h:167
Represents Objective-C's @autoreleasepool Statement.
Definition: StmtObjC.h:394
A runtime availability query.
Definition: ExprObjC.h:1692
ObjCBoolLiteralExpr - Objective-C Boolean Literal.
Definition: ExprObjC.h:87
ObjCBoxedExpr - used for generalized expression boxing.
Definition: ExprObjC.h:127
An Objective-C "bridged" cast expression, which casts between Objective-C pointers and C pointers,...
Definition: ExprObjC.h:1632
ObjCDictionaryLiteral - AST node to represent objective-c dictionary literals; as in:"name" : NSUserN...
Definition: ExprObjC.h:309
ObjCEncodeExpr, used for @encode in Objective-C.
Definition: ExprObjC.h:410
Represents Objective-C's collection statement.
Definition: StmtObjC.h:23
ObjCIndirectCopyRestoreExpr - Represents the passing of a function argument by indirect copy-restore ...
Definition: ExprObjC.h:1571
ObjCIsaExpr - Represent X->isa and X.isa when X is an ObjC 'id' type.
Definition: ExprObjC.h:1487
ObjCIvarRefExpr - A reference to an ObjC instance variable.
Definition: ExprObjC.h:549
An expression that sends a message to the given Objective-C object or class.
Definition: ExprObjC.h:941
ObjCPropertyRefExpr - A dot-syntax expression to access an ObjC property.
Definition: ExprObjC.h:617
ObjCProtocolExpr used for protocol expression in Objective-C.
Definition: ExprObjC.h:505
ObjCSelectorExpr used for @selector in Objective-C.
Definition: ExprObjC.h:455
ObjCStringLiteral, used for Objective-C string literals i.e.
Definition: ExprObjC.h:51
ObjCSubscriptRefExpr - used for array and dictionary subscripting.
Definition: ExprObjC.h:840
OffsetOfExpr - [C99 7.17] - This represents an expression of the form offsetof(record-type,...
Definition: Expr.h:2519
Helper class for OffsetOfExpr.
Definition: Expr.h:2413
FieldDecl * getField() const
For a field offsetof node, returns the field.
Definition: Expr.h:2477
IdentifierInfo * getFieldName() const
For a field or identifier offsetof node, returns the name of the field.
Definition: Expr.cpp:1700
@ Array
An index into an array.
Definition: Expr.h:2418
@ Identifier
A field in a dependent type, known only by its name.
Definition: Expr.h:2422
@ Field
A field.
Definition: Expr.h:2420
@ Base
An implicit indirection through a C++ base class, when the field found is in a base class.
Definition: Expr.h:2425
Kind getKind() const
Determine what kind of offsetof node this is.
Definition: Expr.h:2467
OpaqueValueExpr - An expression referring to an opaque object of a fixed type and value class.
Definition: Expr.h:1173
This expression type represents an asterisk in an OpenACC Size-Expr, used in the 'tile' and 'gang' cl...
Definition: Expr.h:2078
void Visit(const OpenACCClause *C)
const Expr * getConditionExpr() const
Represents a clause with one or more 'var' objects, represented as an expr, as its arguments.
ArrayRef< Expr * > getVarList()
This is the base type for all OpenACC Clauses.
Definition: OpenACCClause.h:24
Represents a 'collapse' clause on a 'loop' construct.
const Expr * getLoopCount() const
This class represents a compute construct, representing a 'Kind' of ‘parallel’, 'serial',...
Definition: StmtOpenACC.h:131
A 'default' clause, has the optional 'none' or 'present' argument.
A 'device_type' or 'dtype' clause, takes a list of either an 'asterisk' or an identifier.
unsigned getNumExprs() const
std::pair< OpenACCGangKind, const Expr * > getExpr(unsigned I) const
An 'if' clause, which has a required condition expression.
This class represents a 'loop' construct.
Definition: StmtOpenACC.h:194
llvm::ArrayRef< Expr * > getIntExprs()
A 'self' clause, which has an optional condition expression.
llvm::ArrayRef< Expr * > getSizeExprs()
Expr * getDevNumExpr() const
llvm::ArrayRef< Expr * > getQueueIdExprs()
A reference to an overloaded function set, either an UnresolvedLookupExpr or an UnresolvedMemberExpr.
Definition: ExprCXX.h:2983
Represents a C++11 pack expansion that produces a sequence of expressions.
Definition: ExprCXX.h:4180
ParenExpr - This represents a parenthesized expression, e.g.
Definition: Expr.h:2170
Represents a parameter to a function.
Definition: Decl.h:1725
[C99 6.4.2.2] - A predefined identifier such as func.
Definition: Expr.h:1991
PseudoObjectExpr - An expression which accesses a pseudo-object l-value.
Definition: Expr.h:6546
const Expr *const * const_semantics_iterator
Definition: Expr.h:6611
A (possibly-)qualified type.
Definition: Type.h:929
Frontend produces RecoveryExprs on semantic errors that prevent creating other well-formed expression...
Definition: Expr.h:7258
C++2a [expr.prim.req]: A requires-expression provides a concise way to express requirements on templa...
Definition: ExprConcepts.h:502
ReturnStmt - This represents a return, optionally of an expression: return; return 4;.
Definition: Stmt.h:3046
Represents a __leave statement.
Definition: Stmt.h:3745
ShuffleVectorExpr - clang-specific builtin-in function __builtin_shufflevector.
Definition: Expr.h:4514
Represents an expression that computes the length of a parameter pack.
Definition: ExprCXX.h:4258
Represents a function call to one of __builtin_LINE(), __builtin_COLUMN(), __builtin_FUNCTION(),...
Definition: Expr.h:4810
StmtExpr - This is the GNU Statement Expression extension: ({int X=4; X;}).
Definition: Expr.h:4466
Stmt - This represents one statement.
Definition: Stmt.h:84
void ProcessODRHash(llvm::FoldingSetNodeID &ID, ODRHash &Hash) const
Calculate a unique representation for a statement that is stable across compiler invocations.
StmtClass
Definition: Stmt.h:86
void Profile(llvm::FoldingSetNodeID &ID, const ASTContext &Context, bool Canonical, bool ProfileLambdaExpr=false) const
Produce a unique representation of the given statement.
StringLiteral - This represents a string literal expression, e.g.
Definition: Expr.h:1778
Represents a reference to a non-type template parameter that has been substituted with a template arg...
Definition: ExprCXX.h:4490
Represents a reference to a non-type template parameter pack that has been substituted with a non-tem...
Definition: ExprCXX.h:4575
SwitchStmt - This represents a 'switch' stmt.
Definition: Stmt.h:2415
Location wrapper for a TemplateArgument.
Definition: TemplateBase.h:524
Represents a template argument.
Definition: TemplateBase.h:61
QualType getStructuralValueType() const
Get the type of a StructuralValue.
Definition: TemplateBase.h:399
QualType getParamTypeForDecl() const
Definition: TemplateBase.h:331
Expr * getAsExpr() const
Retrieve the template argument as an expression.
Definition: TemplateBase.h:408
QualType getAsType() const
Retrieve the type for a type template argument.
Definition: TemplateBase.h:319
llvm::APSInt getAsIntegral() const
Retrieve the template argument as an integral value.
Definition: TemplateBase.h:363
QualType getNullPtrType() const
Retrieve the type for null non-type template argument.
Definition: TemplateBase.h:337
QualType getIntegralType() const
Retrieve the type of the integral value.
Definition: TemplateBase.h:377
ValueDecl * getAsDecl() const
Retrieve the declaration for a declaration non-type template argument.
Definition: TemplateBase.h:326
ArrayRef< TemplateArgument > pack_elements() const
Iterator range referencing all of the elements of a template argument pack.
Definition: TemplateBase.h:432
@ Declaration
The template argument is a declaration that was provided for a pointer, reference,...
Definition: TemplateBase.h:74
@ Template
The template argument is a template name that was provided for a template template parameter.
Definition: TemplateBase.h:93
@ StructuralValue
The template argument is a non-type template argument that can't be represented by the special-case D...
Definition: TemplateBase.h:89
@ Pack
The template argument is actually a parameter pack.
Definition: TemplateBase.h:107
@ TemplateExpansion
The template argument is a pack expansion of a template name that was provided for a template templat...
Definition: TemplateBase.h:97
@ NullPtr
The template argument is a null pointer or null pointer to member that was provided for a non-type te...
Definition: TemplateBase.h:78
@ Type
The template argument is a type.
Definition: TemplateBase.h:70
@ Null
Represents an empty template argument, e.g., one that has not been deduced.
Definition: TemplateBase.h:67
@ Integral
The template argument is an integral value stored in an llvm::APSInt that was provided for an integra...
Definition: TemplateBase.h:82
@ Expression
The template argument is an expression, and we've not resolved it to one of the other forms yet,...
Definition: TemplateBase.h:103
ArgKind getKind() const
Return the kind of stored template argument.
Definition: TemplateBase.h:295
TemplateName getAsTemplateOrTemplatePattern() const
Retrieve the template argument as a template name; if the argument is a pack expansion,...
Definition: TemplateBase.h:350
const APValue & getAsStructuralValue() const
Get the value of a StructuralValue.
Definition: TemplateBase.h:396
Represents a C++ template name within the type system.
Definition: TemplateName.h:220
TemplateTemplateParmDecl - Declares a template template parameter, e.g., "T" in.
Declaration of a template type parameter.
Expr * getImmediatelyDeclaredConstraint() const
Get the immediately-declared constraint expression introduced by this type-constraint,...
Definition: ASTConcept.h:242
A type trait used in the implementation of various C++11 and Library TR1 trait templates.
Definition: ExprCXX.h:2768
const T * castAs() const
Member-template castAs<specific type>.
Definition: Type.h:8800
TypeClass getTypeClass() const
Definition: Type.h:2341
const T * getAs() const
Member-template getAs<specific type>'.
Definition: Type.h:8731
TypoExpr - Internal placeholder for expressions where typo correction still needs to be performed and...
Definition: Expr.h:6837
UnaryExprOrTypeTraitExpr - expression with either a type or (unevaluated) expression operand.
Definition: Expr.h:2622
UnaryOperator - This represents the unary-expression's (except sizeof and alignof),...
Definition: Expr.h:2232
A reference to a name which we were able to look up during parsing but could not resolve to a specifi...
Definition: ExprCXX.h:3203
Represents a C++ member access expression for which lookup produced a set of overloaded functions.
Definition: ExprCXX.h:3943
A call to a literal operator (C++11 [over.literal]) written as a user-defined literal (C++11 [lit....
Definition: ExprCXX.h:637
Represents a call to the builtin function __builtin_va_arg.
Definition: Expr.h:4750
WhileStmt - This represents a 'while' stmt.
Definition: Stmt.h:2611
A static requirement that can be used in a requires-expression to check properties of types and expre...
Definition: ExprConcepts.h:168
The JSON file list parser is used to communicate input to InstallAPI.
@ OO_None
Not an overloaded operator.
Definition: OperatorKinds.h:22
@ NUM_OVERLOADED_OPERATORS
Definition: OperatorKinds.h:26
BinaryOperatorKind
UnaryOperatorKind
const FunctionProtoType * T
#define false
Definition: stdbool.h:26
Data for list of allocators.