[analyzer][UninitializedObjectChecker] Refactoring p1.: ImmutableList factory is no longer static

This patch is the first part of a series of patches to refactor UninitializedObjectChecker. The goal of this effort is to

    Separate pointer chasing from the rest of the checker,
    Increase readability and reliability,
    Don't impact performance (too bad).

In this one, ImmutableList's factory is moved to FindUninitializedFields.

Differential Revision: https://reviews.llvm.org/D50503

llvm-svn: 339591
This commit is contained in:
Kristof Umann 2018-08-13 17:55:52 +00:00
parent fd709711e2
commit ea7cb67581
1 changed files with 8 additions and 7 deletions

View File

@ -73,17 +73,21 @@ public:
/// Note that this class is immutable, and new fields may only be added through
/// constructor calls.
class FieldChainInfo {
public:
using FieldChain = llvm::ImmutableList<const FieldRegion *>;
private:
FieldChain::Factory &Factory;
FieldChain Chain;
const bool IsDereferenced = false;
public:
FieldChainInfo() = default;
FieldChainInfo() = delete;
FieldChainInfo(FieldChain::Factory &F) : Factory(F) {}
FieldChainInfo(const FieldChainInfo &Other, const bool IsDereferenced)
: Chain(Other.Chain), IsDereferenced(IsDereferenced) {}
: Factory(Other.Factory), Chain(Other.Chain), IsDereferenced(IsDereferenced) {}
FieldChainInfo(const FieldChainInfo &Other, const FieldRegion *FR,
const bool IsDereferenced = false);
@ -128,6 +132,7 @@ class FindUninitializedFields {
bool IsAnyFieldInitialized = false;
FieldChainInfo::FieldChain::Factory Factory;
UninitFieldSet UninitFields;
public:
@ -217,10 +222,6 @@ private:
} // end of anonymous namespace
// Static variable instantionations.
static llvm::ImmutableListFactory<const FieldRegion *> Factory;
// Utility function declarations.
/// Returns the object that was constructed by CtorDecl, or None if that isn't
@ -355,7 +356,7 @@ FindUninitializedFields::FindUninitializedFields(
CheckPointeeInitialization(CheckPointeeInitialization) {}
const UninitFieldSet &FindUninitializedFields::getUninitFields() {
isNonUnionUninit(ObjectR, FieldChainInfo());
isNonUnionUninit(ObjectR, FieldChainInfo(Factory));
if (!IsPedantic && !IsAnyFieldInitialized)
UninitFields.clear();