[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:56:51 PST 2026
================
@@ -182,6 +233,15 @@ bool BugSuppression::isSuppressed(const PathDiagnosticLocation &Location,
// declaration that isn't TranslationUnitDecl, because we should respect
// attributes on the entire declaration chain.
while (true) {
+
+ // Template specializations (e.g., Wrapper<int>) should inherit
+ // suppression attributes from their primary template or partial
+ // specialization. Transform specializations to their template definitions
+ // before checking for suppressions or walking up the lexical parent
+ // chain.
----------------
ziqingluo-90 wrote:
So far my understanding is:
- Template specialization is fine--it does inherit suppression attributes (according to the printed AST).
- The reason that we need this fix is that `getLexicalDeclContext` is not doing what we expect it to do. Though it may not be a bug in `getLexicalDeclContext` because I do not know if "lexical parent of a template specialization" is well defined.
https://github.com/llvm/llvm-project/pull/178441
More information about the cfe-commits
mailing list