[PATCH] D114299: [clang-tidy] Fix `readability-redundant-declaration` false positive for template friend declaration

Aaron Ballman via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Wed Dec 1 06:13:27 PST 2021


aaron.ballman added a comment.

Hmm, the test case you added passes without the patch applied: https://godbolt.org/z/T9TerMYGz

I think the issue is that the class needs to be an instantiated template type: https://godbolt.org/z/bhznPdsvf, and a second (interesting but contrived) test case would be:

  template <typename>
  struct Friendly {
    template <typename T>
    friend void generic_friend() {}
  };
  
  template <typename T>
  void generic_friend();
  
  int main() {
    Friendly<int> f;
    generic_friend<int>();
  }

(We do NOT want to diagnose the second declaration of generic_friend as being redundant -- it is necessary to make the definition visible.)


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D114299/new/

https://reviews.llvm.org/D114299



More information about the cfe-commits mailing list