This is an archive of the discontinued LLVM Phabricator instance.

Let -Wdelete-non-virtual-dtor fire in system headers too.
ClosedPublic

Authored by thakis on Aug 28 2017, 3:08 PM.

Details

Summary

Makes the warning useful again in a std::unique_ptr world, PR28460.

Also make the warning not fire in unevaluated contexts, since system libraries (e.g. libc++) do do that. This would've been a good change before we started emitting this warning in system headers too, but "normal" code seems to be less template-heavy, so we didn't notice until now.

Diff Detail

Event Timeline

thakis created this revision.Aug 28 2017, 3:08 PM
thakis updated this revision to Diff 112981.Aug 28 2017, 3:33 PM
thakis edited the summary of this revision. (Show Details)

Don't warn in unevaluated contexts. Ready for a look now.

dblaikie accepted this revision.Aug 28 2017, 4:22 PM
dblaikie added a subscriber: dblaikie.

(if you'd prefer to wait for Reid or Richard to take a look, that's OK too :) )

Looks good to me, though wouldn't mind if the tests were a bit simpler - if they can be made so.

test/SemaCXX/destructor.cpp
3–28

Could this be simpler?

For example would it work to put this test at the end of the file, something like:

struct foo { virtual void f(); };
#pragma clang system_header
void f(foo *p) { delete p; }
This revision is now accepted and ready to land.Aug 28 2017, 4:22 PM
rsmith added inline comments.Aug 28 2017, 4:38 PM
test/SemaCXX/destructor.cpp
27

Do we guarantee that __FILE__ names a path that can be used to include the current file? In other tests, we add -include %s to the RUN: line to model this situation.

thakis closed this revision.Aug 30 2017, 1:27 PM

Thanks, landed in r312167.

dblaikie: I believe the test can't be much simpler -- the pragma is file-based and having the main TU be marked as system header would be fairly different from what happens in real life even if it worked.