[clang] [analyzer] Fix [[clang::suppress]] for tricky template specializations (PR #178441)

Ziqing Luo via cfe-commits cfe-commits at lists.llvm.org
Thu Jan 29 10:42:33 PST 2026


================
@@ -0,0 +1,33 @@
+// RUN: %clang_analyze_cc1 -analyzer-checker=core,debug.ExprInspection -verify %s
+// expected-no-diagnostics
+
+void clang_analyzer_warnIfReached();
+
+// Forward declaration
+namespace N { // 1st
+template <class T> struct Wrapper;
----------------
ziqingluo-90 wrote:

Thanks for printing the extra information!  

```
DeclWithIssue initially was 0xacad0d4d0  CXXMethod
  begin: clang/test/Analysis/suppress-namespace-redecl-core.cpp:22:3
  end:   clang/test/Analysis/suppress-namespace-redecl-core.cpp:27:3
DeclWithIssue was changed to 0xacad0d220  ClassTemplateSpecialization
  begin: clang/test/Analysis/suppress-namespace-redecl-core.cpp:13:1
  end:   clang/test/Analysis/suppress-namespace-redecl-core.cpp:13:27
```

This is the confusing step, right?   The `CXXMethod` should be a descendant of the template specialization. It is counterintuitive that the lexical parent of the `CXXMethod` is not in the same namespace as itself.  And it does not match the AST. 

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


More information about the cfe-commits mailing list