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

Umann Kristóf via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Thu Aug 9 04:58:39 PDT 2018


Szelethus created this revision.
Szelethus added reviewers: xazax.hun, rnkovacs, NoQ, george.karpenkov.
Herald added subscribers: cfe-commits, mikhail.ramalho, a.sidorin, szepet, whisperity.

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.


Repository:
  rC Clang

https://reviews.llvm.org/D50506

Files:
  lib/StaticAnalyzer/Checkers/UninitializedObject.h
  lib/StaticAnalyzer/Checkers/UninitializedObjectChecker.cpp
  lib/StaticAnalyzer/Checkers/UninitializedPointee.cpp
  test/Analysis/cxx-uninitialized-object.cpp

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D50506.159896.patch
Type: text/x-patch
Size: 20318 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20180809/8cf8aca6/attachment-0001.bin>


More information about the cfe-commits mailing list