This is an archive of the discontinued LLVM Phabricator instance.

[analyzer] Suppress escape of this-pointer during construction.
ClosedPublic

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

Details

Summary

This one's easy. Under -analyzer-config c++-allocator-inlining=true, since D41406, we've teached MallocChecker to use the new callback, check::NewAllocator, which fires between the end of the operator new() call and the beginning of the constructor call. Because the constructor call causes a pointer escape event, during which the pointer returned by operator new() immediately escapes, MallocChecker immediately loses track of the allocated symbol and becomes completely useless. In particular, NewDeleteLeaks suffers a lot.

I'm open to suggestions regarding whether we should suppress this sort of pointer escape on the checker side or globally.

Diff Detail

Repository
rC Clang

Event Timeline

NoQ created this revision.Jan 5 2018, 5:32 PM

I am fine with suppressing the escape globally.
I did see some code in the wild where the constructors registered the objects with a (global) map.
But I think it is still easier to annotate code that does something unconventional than the other way around.

Hi Artem,
I think that global suppression is fine. If one really wants to check such escapes, he can implement a separate callback for this.

This revision is now accepted and ready to land.Jan 12 2018, 5:08 PM
This revision was automatically updated to reflect the committed changes.