================
@@ -0,0 +1,366 @@
+// RUN: %clang_analyze_cc1 -analyzer-checker=core,debug.ExprInspection -verify
%s
+
+void clang_analyzer_warnIfReached();
+
+// Systematic tests for [[clang::suppress]] on classes with friend
declarations.
+//
+// Pruned matrix of valid combinations:
+// Axis 1: fwd-decl at namespace scope (yes / no)
+// Axis 2: body location (inline / out-of-line)
+// Axis 3: template (yes / no)
+//
+// Each case has a suppressed variant (class has [[clang::suppress]])
+// and an unsuppressed variant (class without it).
+
+// Placeholder types for triggering instantiations.
+// - Type{A,B} should match an unconstrained template type parameter.
+// - Specialized should match some specialization pattern.
+struct TypeA{};
+struct TypeB{};
+struct Specialized{};
+
+// ============================================================================
+// Group A: Non-template friend functions
+// ============================================================================
+
+// --- A1: no fwd-decl, inline body ---
+
+struct [[clang::suppress]] A1_Suppressed {
+ friend void a1_suppressed(A1_Suppressed) {
+ clang_analyzer_warnIfReached(); // no-warning
+ }
+};
+struct A1_Unsuppressed {
+ friend void a1_unsuppressed(A1_Unsuppressed) {
+ clang_analyzer_warnIfReached(); // expected-warning{{REACHABLE}}
+ }
+};
+void test_A1() {
+ a1_suppressed(A1_Suppressed{});
+ a1_unsuppressed(A1_Unsuppressed{});
+}
+
+// --- A2: no fwd-decl, out-of-line body ---
+
+struct [[clang::suppress]] A2_Suppressed {
+ friend void a2_suppressed(A2_Suppressed);
+};
+void a2_suppressed(A2_Suppressed) {
+ // Out-of-line: lexical parent is the namespace, NOT the class.
----------------
NagyDonat wrote:
```suggestion
// Out-of-line: lexical parent is the translation unit, NOT the class.
```
Again, this is not wrapped in a namespace. (Of course, this is not a
significant difference.)
https://github.com/llvm/llvm-project/pull/186447
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits