This is an archive of the discontinued LLVM Phabricator instance.

[analyzer] Don't do anything when trivial-copying an empty class object.
ClosedPublic

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

Details

Summary

When modeling implicit copy/move-constructor or copy/move-assignment operator of an empty class, don't do anything. The previous behavior was to take the value of the empty source object (which is always UnknownVal for empty classes) and assign it to the empty target object. This causes problems when the target object is a field or a base class because, due to how RegionStore forgets binding sizes, such UnknownVal would overwrite any existing store binding at the respective offset.

While testing temporary constructors and destructors, this resulted in numerous leak false positives when the raw pointer value in unique_ptr started disappearing from the program state when the zero-size deleter part of the smart pointer was trivially-copied at its offset. Note that performTrivialCopy doesn't cause pointer escape, because it normally doesn't need to.

Diff Detail

Repository
rL LLVM

Event Timeline

NoQ created this revision.Feb 23 2018, 8:26 PM
This revision is now accepted and ready to land.Feb 24 2018, 12:02 PM
a.sidorin accepted this revision.Feb 27 2018, 12:40 AM

Looks good!

This revision was automatically updated to reflect the committed changes.