Do not delete polymorphic objects without a virtual destructor (#23705)
authorOmair Majid <omajid@redhat.com>
Fri, 7 Jun 2019 20:49:52 +0000 (16:49 -0400)
committerJan Vorlicek <janvorli@microsoft.com>
Fri, 7 Jun 2019 20:49:52 +0000 (22:49 +0200)
commit3fcaf0373369ed4b17bd1ed068592c2e0cec3997
treea751b81233e46f1163ffd2bacf31697cea72231c
parentb314ed86b11756834b0936e56c3d841e7407f81d
Do not delete polymorphic objects without a virtual destructor (#23705)

SEI CERT C++ Coding Standard says:

> Do not delete an object of derived class type through a pointer to its
> base class type that has a non-virtual destructor. Instead, the base
> class should be defined with a virtual destructor. Deleting an object
> through a pointer to a type without a virtual destructor results in
> undefined behavior.

See https://wiki.sei.cmu.edu/confluence/display/cplusplus/OOP52-CPP.+Do+not+delete+a+polymorphic+object+without+a+virtual+destructor

Clang generally warns about this, but we disabled the warning via
-Wno-delete-non-virtual-dtor. This commit re-enables the warning and
fixes up all the code that hits the warning.
src/ToolBox/SOS/lldbplugin/CMakeLists.txt
src/ToolBox/SOS/lldbplugin/inc/lldbservices.h
src/ToolBox/SOS/lldbplugin/services.h
src/dlls/mscorpe/CMakeLists.txt
src/ilasm/CMakeLists.txt
src/ilasm/asmparse.h
src/inc/iceefilegen.h