================
@@ -3039,6 +3043,47 @@ void
OMPClausePrinter::VisitOMPXBareClause(OMPXBareClause *Node) {
OS << "ompx_bare";
}
+namespace {
+/// Canonical profiles identify template and function parameters only by
+/// position; add the declaration that owns each referenced parameter.
+class ParameterOwnerProfiler final : public ConstDynamicRecursiveASTVisitor {
+ llvm::FoldingSetNodeID &ID;
+
+ void addOwner(const Decl *D) {
+ if (isa_and_nonnull<ParmVarDecl, NonTypeTemplateParmDecl,
+ TemplateTypeParmDecl, TemplateTemplateParmDecl>(D))
+ ID.AddPointer(cast<Decl>(D->getDeclContext())->getCanonicalDecl());
+ }
+
+public:
+ explicit ParameterOwnerProfiler(llvm::FoldingSetNodeID &ID) : ID(ID) {}
+
+ bool VisitDeclRefExpr(const DeclRefExpr *E) override {
+ addOwner(E->getDecl());
+ return true;
+ }
+ bool VisitSizeOfPackExpr(const SizeOfPackExpr *E) override {
+ if (!E->isPartiallySubstituted())
+ addOwner(E->getPack());
+ return true;
+ }
+ bool VisitTemplateTypeParmType(const TemplateTypeParmType *T) override {
+ addOwner(T->getDecl());
----------------
MattPD wrote:
`ParameterOwnerProfiler` is removed from this PR, so this case can move to the
condition-identity follow-up.
https://github.com/llvm/llvm-project/pull/231668
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits