[PATCH] D110614: [clang-tidy] Fix false positives in cppcoreguidelines-virtual-class-destructor

Carlos Galvez via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Wed Sep 29 00:29:41 PDT 2021


carlosgalvezp added inline comments.


================
Comment at: clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines-virtual-class-destructor.cpp:216-218
+template <typename T>
+struct TemplatedDerived : PublicVirtualBaseStruct {
+};
----------------
aaron.ballman wrote:
> I think there are more interesting template test cases that should be checked.
> ```
> // What to do when the derived type is definitely polymorphic
> // but the base class may or may not be?
> template <typename Ty>
> struct Derived : Ty {
>   virtual void func();
> };
> 
> struct S {};
> struct  T { virtual ~T(); };
> 
> void instantiate() {
>   Derived<S> d1; // Diagnose
>   Derived<T> d2; // Don't diagnose
> }
> ```
> 
Very interesting example.

The problem is that the diagnostic is shown where `Derived` is, not where the template is instantiated. How to go about that?

Seems like more testing and better diagnostics are needed to lower the amount of false positives, I wonder if we should disable the test meanwhile?


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

https://reviews.llvm.org/D110614



More information about the cfe-commits mailing list