[clang] [clang][Sema] Fix false-positive -Wshadow for friend functions (PR #221249)

Bruno De Fraine via cfe-commits cfe-commits at lists.llvm.org
Tue Sep 15 01:36:16 PDT 2026


================
@@ -90,6 +90,22 @@ class A {
   }
 };
 
+class FriendFunction {
+  int x; // expected-note {{previous declaration is here}}
+  friend bool operator==(const FriendFunction &f, int x) {
+    return f.x == x;
+  }
----------------
brunodf-gf wrote:

Another case you could consider to add for completeness is an inline-defined friend function that is not an operator.

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


More information about the cfe-commits mailing list