[PATCH] D66621: [clang] Devirtualization for classes with destructors marked as 'final'

Richard Smith - zygoloid via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Thu Aug 22 17:58:54 PDT 2019


rsmith accepted this revision.
rsmith added a comment.
This revision is now accepted and ready to land.

This seems subtle, but I believe it is correct.

I wonder whether we should provide a warning for a non-final class has a final destructor, since moving the `final` from the destructor to the class seems like a more obvious way to present the code (and will likely lead to better code generation in compilers that haven't realized they can do this).



================
Comment at: clang/lib/AST/DeclCXX.cpp:2071
+  // Similarly, if the class itself or its destructor is marked 'final',
+  // the class can't be overridden and we can therefore devirtualize the 
+  // member function call.
----------------
This comment doesn't make much sense (pre-existing, but since you're changing it anyway): classes can't be "overridden", they can only be derived from.


Repository:
  rC Clang

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

https://reviews.llvm.org/D66621





More information about the cfe-commits mailing list