This is an archive of the discontinued LLVM Phabricator instance.

[analyzer][UninitializedObjectChecker] Refactoring p4.: Wrap FieldRegions and reduce weight on FieldChainInfo
ClosedPublic

Authored by Szelethus on Aug 9 2018, 4:58 AM.

Details

Summary

This patch is the bread and butter of the refactoring effort.

Currently on trunk, FieldChainInfo is a spaghetti: it takes care of way too many cases, even though it was always meant as a wrapper around ImmutableList<const FieldRegion *>.
This problem is solved by introducing a lightweight polymorphic wrapper around const FieldRegion *, FieldNode. It is an interface that abstracts away special cases like pointers/references, objects that need to be casted to another type for a proper note messages.

I also plan to solve base class related issues with the help on this interface.

Changes to FieldChainInfo:

  • Now wraps ImmutableList<const FieldNode &>.
  • Any pointer/reference related fields and methods were removed
  • Got a new add method. This replaces it's former constructors as a way to create a new FieldChainInfo objects with a new element.

Changes to FindUninitializedField:

  • In order not to deal with dynamic memory management, when an uninitialized field is found, the note message for it is constructed and is stored instead of a FieldChainInfo object. (see doc around addFieldToUninits).

Some of the test files are changed too, from now on uninitialized pointees of references always print "uninitialized pointee" instead of "uninitialized field" (which should've really been like this from the beginning).

I also updated every comment according to these changes.

Diff Detail

Repository
rC Clang