Index: clang-tools-extra/clang-tidy/readability/RedundantDeclarationCheck.cpp =================================================================== --- clang-tools-extra/clang-tidy/readability/RedundantDeclarationCheck.cpp +++ clang-tools-extra/clang-tidy/readability/RedundantDeclarationCheck.cpp @@ -37,7 +37,7 @@ functionDecl(unless(anyOf( isDefinition(), isDefaulted(), doesDeclarationForceExternallyVisibleDefinition(), - hasParent(friendDecl())))))) + hasAncestor(friendDecl())))))) .bind("Decl"), this); } Index: clang-tools-extra/test/clang-tidy/checkers/readability-redundant-declaration.cpp =================================================================== --- clang-tools-extra/test/clang-tidy/checkers/readability-redundant-declaration.cpp +++ clang-tools-extra/test/clang-tidy/checkers/readability-redundant-declaration.cpp @@ -70,6 +70,32 @@ void enemy(); +template +struct TemplateFriendly { + template + friend void generic_friend(); +}; + +template +void generic_friend() {} + +TemplateFriendly template_friendly; + +template +struct TemplateFriendly2 { + template + friend void generic_friend2() {} +}; + +template +void generic_friend2(); + +void generic_friend_caller() { + TemplateFriendly2 f; + generic_friend2(); +} + + namespace macros { #define DECLARE(x) extern int x #define DEFINE(x) extern int x; int x = 42