[clang] [APINotes] Diagnose invalid Where.Parameters selectors (PR #209408)

John Hui via cfe-commits cfe-commits at lists.llvm.org
Thu Jul 23 18:50:17 PDT 2026


================
@@ -1243,13 +1276,25 @@ class YAMLConverter {
 
     // Write all global functions.
     llvm::StringSet<> KnownNameOnlyFunctions;
+    llvm::StringSet<> KnownFunctionSelectors;
     for (const auto &Function : TLItems.Functions) {
       auto WhereParameters = getWhereParameters(Function);
       if (!WhereParameters.first)
         continue;
 
-      // Check for duplicate name-only global functions. Selector-aware
-      // duplicate diagnostics are handled by a later overload-matching PR.
+      if (WhereParameters.second) {
+        if (!KnownFunctionSelectors
+                 .insert(getFunctionSelectorKey(Function.Name,
+                                                *WhereParameters.second))
+                 .second) {
+          emitError(llvm::Twine("duplicate definition of global function '") +
----------------
j-hui wrote:

The wording of this diagnostic makes it sound like the _function_ was defined twice. Instead it should probably say something like:

> multiple APINotes entries for global function 'NAME' with Where.Parameters [PARAMS]

https://github.com/llvm/llvm-project/pull/209408


More information about the cfe-commits mailing list