[flang-commits] [clang] [flang] [llvm] [OpenMP] Fix context selector matching and scoring (PR #231668)

via flang-commits flang-commits at lists.llvm.org
Fri Oct 16 23:09:02 PDT 2026


================
@@ -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


More information about the flang-commits mailing list