llvm-project
ef4f8742 - [analyzer] Fix [[clang::suppress]] for friend function templates with namespace-scope forward-declarations (#187043)

Commit
31 days ago
[analyzer] Fix [[clang::suppress]] for friend function templates with namespace-scope forward-declarations (#187043) When a friend function template is defined inline inside a [[clang::suppress]]-annotated class but was forward-declared at namespace scope, the instantiation's lexical DeclContext was the namespace (from the forward-declaration), not the class. The lexical parent chain walk in BugSuppression::isSuppressed therefore never reached the class and suppression did not apply. Fix by extending preferTemplateDefinitionForTemplateSpecializations to handle FunctionDecl instances: calling getTemplateInstantiationPattern() that maps the instantiation back to the primary template FunctionDecl, whose lexical DC is the class where the friend was defined inline. So the existing parent-chain walk then finds the suppression attribute. Assisted-By: claude
Author
Parents
Loading