================
@@ -0,0 +1,132 @@
+// RUN: %clang_analyze_cc1 -analyzer-checker=core,debug.ExprInspection -verify 
%s
+
+void clang_analyzer_warnIfReached();
+
+// Systematic tests for [[clang::suppress]] on template methods inside
+// non-template and template classes.
+
+// Placeholder types for triggering instantiations.
+// - Type{A,B} should match an unconstrained template type parameter.
+struct TypeA{};
+struct TypeB{};
+
+// ============================================================================
+// Group A: Non-template class with suppressed/unsuppressed template methods
+// ============================================================================
+
+struct NonTemplateClassWithTemplatedMethod {
+  template <typename T>
+  [[clang::suppress]] void suppressed(T) {
+    clang_analyzer_warnIfReached(); // no-warning
+  }
+
+  template <typename T>
+  void unsuppressed(T) {
+    clang_analyzer_warnIfReached(); // expected-warning{{REACHABLE}}
+  }
+};
+
+void test_nontpl_class() {
+  NonTemplateClassWithTemplatedMethod().suppressed(TypeA{});
+  NonTemplateClassWithTemplatedMethod().unsuppressed(TypeA{});
+}
+
+// ============================================================================
+// Group B: Template class with template methods — inline
+// ============================================================================
+
+template <typename T>
+struct TemplateClassWithTemplateMethod {
+  template <typename U>
+  [[clang::suppress]] void suppressed(U) {
+    clang_analyzer_warnIfReached(); // no-warning
+  }
+
+  template <typename U>
+  void unsuppressed(U) {
+    clang_analyzer_warnIfReached(); // expected-warning{{REACHABLE}}
+  }
+
+  template <typename U>
+  [[clang::suppress]] void suppress_at_decl_outline(U);
+
+  template <typename U>
+  void suppress_at_def_outline(U);
+};
+
+// ============================================================================
+// Group C: Template class with template methods — out-of-line
+// ============================================================================
+
----------------
steakhal wrote:

Valid! I decided to split them in c6161179298864344885b348c194a3d1b7a391a3

https://github.com/llvm/llvm-project/pull/186447
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to