<div dir="ltr">I had compiled a bunch of code with this, but right after I sent this out my local build of something failed with this:<div><br></div><div><div>../../buildtools/third_party/libc++/trunk/include/type_traits:2156:51: error: destructor called on non-final 'Ice::VariableDeclaration::RelocInitializer' that has virtual functions but non-virtual destructor [-Werror,-Wdelete-non-virtual-dtor]</div><div>        typename __is_destructible_apply<decltype(_VSTD::declval<_Tp1&>().~_Tp1())>::type</div><div>                                                  ^</div><div>../../buildtools/third_party/libc++/trunk/include/__config:435:15: note: expanded from macro '_VSTD'</div><div>#define _VSTD std::_LIBCPP_NAMESPACE</div><div>              ^</div><div>../../buildtools/third_party/libc++/trunk/include/type_traits:2156:76: note: qualify call to silence this warning</div><div>        typename __is_destructible_apply<decltype(_VSTD::declval<_Tp1&>().~_Tp1())>::type</div><div>                                                                           ^</div><div><br></div><div><br></div><div>So I'll have to tweak the warning to not fire in unevaluated contexts first. Feel free to ignore for now.</div><div><br></div><div><br></div></div></div><div class="gmail_extra"><br><div class="gmail_quote">On Mon, Aug 28, 2017 at 6:08 PM, Nico Weber via Phabricator via cfe-commits <span dir="ltr"><<a href="mailto:cfe-commits@lists.llvm.org" target="_blank">cfe-commits@lists.llvm.org</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">thakis created this revision.<br>
<br>
Makes the warning useful again in a std::unique_ptr world, PR28460.<br>
<br>
<br>
<a href="https://reviews.llvm.org/D37235" rel="noreferrer" target="_blank">https://reviews.llvm.org/<wbr>D37235</a><br>
<br>
Files:<br>
  include/clang/Basic/<wbr>DiagnosticSemaKinds.td<br>
  test/SemaCXX/destructor.cpp<br>
<br>
<br>
Index: test/SemaCXX/destructor.cpp<br>
==============================<wbr>==============================<wbr>=======<br>
--- test/SemaCXX/destructor.cpp<br>
+++ test/SemaCXX/destructor.cpp<br>
@@ -1,5 +1,31 @@<br>
 // RUN: %clang_cc1 -std=c++11 -triple %itanium_abi_triple -fsyntax-only -Wnon-virtual-dtor -Wdelete-non-virtual-dtor -fcxx-exceptions -verify %s<br>
 // RUN: %clang_cc1 -std=c++11 -triple %ms_abi_triple -DMSABI -fsyntax-only -Wnon-virtual-dtor -Wdelete-non-virtual-dtor -verify %s<br>
+<br>
+#if defined(BE_THE_HEADER)<br>
+<br>
+// Wdelete-non-virtual-dtor should warn about the delete from smart pointer<br>
+// classes in system headers (std::unique_ptr...) too.<br>
+<br>
+#pragma clang system_header<br>
+namespace dnvd {<br>
+template <typename T><br>
+class simple_ptr {<br>
+public:<br>
+  simple_ptr(T* t): _ptr(t) {}<br>
+  ~simple_ptr() { delete _ptr; } // \<br>
+    // expected-warning {{delete called on non-final 'dnvd::B' that has virtual functions but non-virtual destructor}} \<br>
+    // expected-warning {{delete called on non-final 'dnvd::D' that has virtual functions but non-virtual destructor}}<br>
+  T& operator*() const { return *_ptr; }<br>
+private:<br>
+  T* _ptr;<br>
+};<br>
+}<br>
+<br>
+#else<br>
+<br>
+#define BE_THE_HEADER<br>
+#include __FILE__<br>
+<br>
 class A {<br>
 public:<br>
   ~A();<br>
@@ -213,18 +239,6 @@<br>
 struct VF final: VB {};<br>
<br>
 template <typename T><br>
-class simple_ptr {<br>
-public:<br>
-  simple_ptr(T* t): _ptr(t) {}<br>
-  ~simple_ptr() { delete _ptr; } // \<br>
-    // expected-warning {{delete called on non-final 'dnvd::B' that has virtual functions but non-virtual destructor}} \<br>
-    // expected-warning {{delete called on non-final 'dnvd::D' that has virtual functions but non-virtual destructor}}<br>
-  T& operator*() const { return *_ptr; }<br>
-private:<br>
-  T* _ptr;<br>
-};<br>
-<br>
-template <typename T><br>
 class simple_ptr2 {<br>
 public:<br>
   simple_ptr2(T* t): _ptr(t) {}<br>
@@ -451,3 +465,4 @@<br>
   x.foo1();<br>
 }<br>
 }<br>
+#endif // BE_THE_HEADER<br>
Index: include/clang/Basic/<wbr>DiagnosticSemaKinds.td<br>
==============================<wbr>==============================<wbr>=======<br>
--- include/clang/Basic/<wbr>DiagnosticSemaKinds.td<br>
+++ include/clang/Basic/<wbr>DiagnosticSemaKinds.td<br>
@@ -6414,12 +6414,12 @@<br>
 def warn_delete_non_virtual_dtor : Warning<<br>
   "%select{delete|destructor}0 called on non-final %1 that has "<br>
   "virtual functions but non-virtual destructor">,<br>
-  InGroup<DeleteNonVirtualDtor>, DefaultIgnore;<br>
+  InGroup<DeleteNonVirtualDtor>, DefaultIgnore, ShowInSystemHeader;<br>
 def note_delete_non_virtual : Note<<br>
   "qualify call to silence this warning">;<br>
 def warn_delete_abstract_non_<wbr>virtual_dtor : Warning<<br>
   "%select{delete|destructor}0 called on %1 that is abstract but has "<br>
-  "non-virtual destructor">, InGroup<DeleteNonVirtualDtor>;<br>
+  "non-virtual destructor">, InGroup<DeleteNonVirtualDtor>, ShowInSystemHeader;<br>
 def warn_overloaded_virtual : Warning<<br>
   "%q0 hides overloaded virtual %select{function|functions}1"><wbr>,<br>
   InGroup<OverloadedVirtual>, DefaultIgnore;<br>
<br>
<br>
<br>______________________________<wbr>_________________<br>
cfe-commits mailing list<br>
<a href="mailto:cfe-commits@lists.llvm.org">cfe-commits@lists.llvm.org</a><br>
<a href="http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits" rel="noreferrer" target="_blank">http://lists.llvm.org/cgi-bin/<wbr>mailman/listinfo/cfe-commits</a><br>
<br></blockquote></div><br></div>