This is an archive of the discontinued LLVM Phabricator instance.

[analyzer] Enable cfg-temporary-dtors by default?
ClosedPublic

Authored by NoQ on Feb 26 2018, 8:13 PM.

Details

Summary

Final results are still being baked on my end, but by putting this on review i'm trying to say that i believe i managed to fix the biggest problems with this mode with the recent patches, to the point where the new mode is not worse than the old mode. There are still known issues, such as the loss of coverage due to default arguments of object or reference type, but these seem fairly minor and will hopefully be addressed incrementally later on.

The change is not very loud - it's 2-3 times more impactful than the operator new support we added earlier, which is noticeable but not definitely extreme. The new mode fixes some but definitely not all false positives i wanted it to fix - adding support for more constructors is necessary, and i hope to continue improving it in the nearest future. It also provides a fairly fair amount of neat true positives and an expected skew due to the changes in inlining.

Diff Detail

Repository
rL LLVM

Event Timeline

NoQ created this revision.Feb 26 2018, 8:13 PM

Currently there's no test demonstrating a different behavior from cfg-temporary-dtors being set to true?..

NoQ added a comment.Feb 28 2018, 11:30 AM

That's right, most analyzer-oriented tests were added explicitly by me to temporaries.cpp and lifetime-extension.cpp in previous patches, so they didn't need to be changed in this patch. There didn't seem to be many FIXME tests specific to my work before i started doing it - it seems that i covered all of them by adding a cfg-temporary-dtors=true run-line in previous patches.

NoQ updated this revision to Diff 136428.Feb 28 2018, 4:45 PM

Don't inline temporary destructors for now (i.e. keep c++-temp-dtor-inlining=false, previously it was by default irrelevant and arbitrarily set to true). That's because D43791 wasn't enough to handle all the problems with smart pointers; some custom reference counting pointers produce large inlining stacks that we just refuse to traverse. I'd try to address it sooner rather than later and then enable this flag as well.

With c++-temp-dtor-inlining=false this change seems even more quiet (around +27/-24, on roughly the same codebase that produced +20/-35 in D42219), and much like the last time it's mostly about rearranging large chunks of false positives due to complete lack of support for temporaries into smaller groups of false positives due to lack of support for something else. This is far from a breakthrough yet - a lot more work needs to be done, but neither it is falling apart immediately, and, most importantly, it gives hope to address any single problem with a targeted fix, because fundamental issues we used to have with temporaries would be mostly gone. So i wish to encourage switching to the new mode earlier rather than later (though it's always possible to flip the flag back locally in case of any severe problems i didn't foresee).

dcoughlin accepted this revision.Feb 28 2018, 4:48 PM

Yay! This looks good to me.

This revision is now accepted and ready to land.Feb 28 2018, 4:48 PM
This revision was automatically updated to reflect the committed changes.