[clang-tidy] Fix `readability-redundant-declaration` false positive for template...
authorFabian Wolff <fabian.wolff@alumni.ethz.ch>
Mon, 17 Jan 2022 19:50:32 +0000 (20:50 +0100)
committerFabian Wolff <fabian.wolff@alumni.ethz.ch>
Mon, 17 Jan 2022 19:50:32 +0000 (20:50 +0100)
commit42bc3275d3687524ddc0d20c72722b9324f87be4
tree1e9d687cc98a5cbcf4004c60fb98ac6aea14f1e1
parent523573e90ddb6db3b58d7a04b7dbe90fa7366dc2
[clang-tidy] Fix `readability-redundant-declaration` false positive for template friend declaration

Fixes [[ https://bugs.llvm.org/show_bug.cgi?id=48086 | PR#48086 ]]. The problem is that the current matcher uses `hasParent()` to detect friend declarations, but for a template friend declaration, the immediate parent of the `FunctionDecl` is a `FunctionTemplateDecl`, not the `FriendDecl`. Therefore, I have replaced the matcher with `hasAncestor()`.

Reviewed By: aaron.ballman

Differential Revision: https://reviews.llvm.org/D114299
clang-tools-extra/clang-tidy/readability/RedundantDeclarationCheck.cpp
clang-tools-extra/test/clang-tidy/checkers/readability-redundant-declaration.cpp