This is an archive of the discontinued LLVM Phabricator instance.

[analyzer] Inline destructors for non-array deletes.
AbandonedPublic

Authored by NoQ on Jan 5 2018, 5:11 PM.

Details

Summary

Similarly to how we allow (since D40560) inlining the constructor after operator new which isn't operator new[], even if the target region is an ElementRegion (which doesn't necessarily represent an array element - it may represent a result of pointer arithmetic or a cast), we should allow inlining the destructors for non-array-but-still-element regions, but not when they are part of operator delete[]. There aren't any known issues in this situation. We still aren't attempting to model array new/delete because it requires an unknown amount of constructor calls to be modeled symbolically.

Before the patch, in new.cpp tests testCallToDestructor() and test_delete_dtor_Arg() started failing under -analyzer-config c++-allocator-inlining=true, because the new behavior of operator new is to return an ElementRegion surrounding the void pointer, which disables destructor inlining; the old behavior is to call the destructor over a raw void pointer, which kind of worked. Additionally, some fixmes in new.cpp were fixed in the new mode. The change in testPlacementNew() also seems correct, even if it wasn't marked as a FIXME.

Diff Detail

Event Timeline

NoQ created this revision.Jan 5 2018, 5:11 PM
NoQ added inline comments.Jan 5 2018, 5:24 PM
lib/StaticAnalyzer/Core/ExprEngineCallAndReturn.cpp
692–693

I hope i'd be able to get rid of this ParentMap call - once i update D40560 as discussed there and rebase.

NoQ abandoned this revision.Jan 9 2018, 7:45 PM

because the new behavior of operator new is to return an ElementRegion surrounding the void pointer

The new behavior was reverted in D41250#971888 so this patch is no longer useful.