This is an archive of the discontinued LLVM Phabricator instance.

Make -Wdelete-non-virtual-dtor warn on explicit `a->~A()` dtor calls too.
ClosedPublic

Authored by thakis on Jan 14 2016, 4:41 PM.

Details

Reviewers
rtrieu
dblaikie
Summary

-Wdelete-non-virtual-dtor already warns if A is a type with virtual functions but without virtual dtor has its constructor called via delete a. This makes the warning also fire if the dtor is called via a->~A(). This would've found a security bug in Chromium at compile time. Fixes PR26137.

Includes fixit for silencing the warning:

test.cc:12:3: warning: destructor called on 'B' that is abstract but has non-virtual destructor [-Wdelete-non-virtual-dtor]
  b->~B();
  ^
test.cc:12:6: note: qualify call to silence this warning
  b->~B();
     ^
     B::

Diff Detail

Event Timeline

thakis updated this revision to Diff 44948.Jan 14 2016, 4:41 PM
thakis retitled this revision from to Make -Wdelete-non-virtual-dtor warn on explicit `a->~A()` dtor calls too..
thakis updated this object.
thakis added a reviewer: rtrieu.
thakis added a subscriber: cfe-commits.
thakis updated this object.Jan 14 2016, 5:05 PM
dblaikie accepted this revision.Jan 14 2016, 5:21 PM
dblaikie added a reviewer: dblaikie.
dblaikie added a subscriber: dblaikie.

Looks good - thanks!

This revision is now accepted and ready to land.Jan 14 2016, 5:21 PM
thakis updated this object.Jan 14 2016, 5:33 PM
thakis edited edge metadata.
thakis closed this revision.Jan 15 2016, 1:49 PM

r257939, thanks!