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

Eric Fiselier via cfe-commits cfe-commits at lists.llvm.org
Tue Aug 18 12:39:35 PDT 2015


Author: ericwf
Date: Tue Aug 18 14:39:35 2015
New Revision: 245333

URL: http://llvm.org/viewvc/llvm-project?rev=245333&view=rev
Log:
[libcxx] Disable -Wnon-virtual-dtor warning in <locale>

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.

Reviewers: mclow.lists

Subscribers: cfe-commits

Differential Revision: http://reviews.llvm.org/D11670

Modified:
    libcxx/trunk/include/locale

Modified: libcxx/trunk/include/locale
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/locale?rev=245333&r1=245332&r2=245333&view=diff
==============================================================================
--- libcxx/trunk/include/locale (original)
+++ libcxx/trunk/include/locale Tue Aug 18 14:39:35 2015
@@ -1888,6 +1888,9 @@ protected:
     virtual const string_type& __r() const;
     virtual const string_type& __x() const;
     virtual const string_type& __X() const;
+
+    _LIBCPP_ALWAYS_INLINE
+    ~__time_get_c_storage() {}
 };
 
 template <class _CharT, class _InputIterator = istreambuf_iterator<_CharT> >




More information about the cfe-commits mailing list