This is an archive of the discontinued LLVM Phabricator instance.

[analyzer] Invalidate union regions properly. Don't hesitate to load the default binding later.
ClosedPublic

Authored by NoQ on Apr 3 2018, 7:13 PM.

Details

Summary

(1) We weren't invalidating our unions correctly. The previous behavior in invalidateRegionsWorker::VisitCluster() was to direct-bind an UnknownVal to the union (at offset 0). The proposed behavior is to default-bind a conjured symbol (of irrelevant type) to the union that's being invalidated, similarly to what we do for structures and classes.

(2) In order to keep ourselves afloat, we were never actually loading default bindings from our unions, because there never was any default binding to load, and the value that is presumed when there's no default binding to load is usually completely incorrect (eg. UndefinedVal for stack unions).

Fix bug (1) and then remove hack (2).

Diff Detail

Repository
rC Clang

Event Timeline

NoQ created this revision.Apr 3 2018, 7:13 PM
NoQ added inline comments.Apr 3 2018, 7:17 PM
test/Analysis/unions.cpp
82

This test got fixed because we're now loading the default-bound lazy compound value for vv from uu correctly.

a.sidorin accepted this revision.Apr 8 2018, 6:04 AM

LGTM, thanks!

This revision is now accepted and ready to land.Apr 8 2018, 6:04 AM
This revision was automatically updated to reflect the committed changes.