[clang] Warning for non-final classes with final destructors
authorDavid Bolvansky <david.bolvansky@gmail.com>
Sat, 31 Aug 2019 18:31:19 +0000 (18:31 +0000)
committerDavid Bolvansky <david.bolvansky@gmail.com>
Sat, 31 Aug 2019 18:31:19 +0000 (18:31 +0000)
commitd533f69aa9700f6c421ed2b8cde12bdc22ee6529
tree124f76f6fc705dd7459d36897eab9879a23e1c20
parentff0ad3c43d44e36d20787cfe1b4e4404de4c7cff
[clang] Warning for non-final classes with final destructors

Marking a class' destructor final prevents the class from being inherited from. However, it is a subtle and awkward way to express that at best, and unintended at worst. It may also generate worse code (in other compilers) than marking the class itself final. For these reasons, this revision adds a warning for nonfinal classes with final destructors, with a note to suggest marking the class final to silence the warning.

See https://reviews.llvm.org/D66621 for more background.

Patch by logan-5 (Logan Smith)

Differential Revision: https://reviews.llvm.org/D66711

llvm-svn: 370594
clang/lib/Sema/SemaDeclCXX.cpp
clang/test/SemaCXX/MicrosoftExtensions.cpp
clang/test/SemaCXX/warn-final-dtor-non-final-class.cpp [new file with mode: 0644]