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