This is an archive of the discontinued LLVM Phabricator instance.

[libcxx] Disable -Wnon-virtual-dtor warning in <locale>
ClosedPublic

Authored by EricWF on Jul 30 2015, 6:43 PM.

Details

Summary

Normally people won't see warnings in libc++ headers, but if they compile with "-Wsystem-headers -Wnon-virtual-dtor" they will likely see issues in <locale>.

In the libc++ implementation time_get' has a private base class, __time_get_c_storage`, with virtual methods but a non-virtual destructor.
time_get itself can safely be used as a polymorphic base class because it inherits a virtual destructor from locale::facet. To placate the compiler we change __time_get_c_storage's destructor from public to protected, ensuring that it will never be deleted polymorphically.

Diff Detail

Event Timeline

EricWF updated this revision to Diff 31099.Jul 30 2015, 6:43 PM
EricWF retitled this revision from to [libcxx] Disable -Wnon-virtual-dtor warning in <locale>.
EricWF updated this object.
EricWF added a reviewer: mclow.lists.
EricWF added a subscriber: cfe-commits.
EricWF updated this object.Jul 30 2015, 9:49 PM
EricWF updated this revision to Diff 31107.Jul 30 2015, 10:05 PM
EricWF updated this object.

David Blaikie pointed out that a better way to solve this warning is to make __time_get_c_storage's destructor protected.

mclow.lists accepted this revision.Jul 31 2015, 1:26 PM
mclow.lists edited edge metadata.
This revision is now accepted and ready to land.Jul 31 2015, 1:26 PM
EricWF closed this revision.Aug 18 2015, 12:40 PM