Thanks to visit codestin.com
Credit goes to clang.llvm.org

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