[clang-tidy] Fix false positive in cppcoreguidelines-virtual-class-destructor
authorCarlos Galvez <carlosgalvezp@gmail.com>
Tue, 28 Sep 2021 08:37:32 +0000 (08:37 +0000)
committerCarlos Galvez <carlosgalvezp@gmail.com>
Sat, 16 Oct 2021 08:27:08 +0000 (08:27 +0000)
commitf0711106dc6c14dcaf06437a0467043e983bf9dc
tree39e96b5fecf947146ded0cc414e419ff9acd6497
parente7bb8dd92983a918fbb370b135e664825f387580
[clang-tidy] Fix false positive in cppcoreguidelines-virtual-class-destructor

Incorrectly triggers for template classes that inherit
from a base class that has virtual destructor.

Any class inheriting from a base that has a virtual destructor
will have their destructor also virtual, as per the Standard:

https://timsong-cpp.github.io/cppwp/n4140/class.dtor#9

> If a class has a base class with a virtual destructor,
> its destructor (whether user- or implicitly-declared) is virtual.

Added unit tests to prevent regression.

Fixes bug https://bugs.llvm.org/show_bug.cgi?id=51912

Differential Revision: https://reviews.llvm.org/D110614
clang-tools-extra/clang-tidy/cppcoreguidelines/VirtualClassDestructorCheck.cpp
clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines-virtual-class-destructor.cpp