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

Kristof Umann via cfe-commits cfe-commits at lists.llvm.org
Mon Aug 13 10:55:52 PDT 2018


Author: szelethus
Date: Mon Aug 13 10:55:52 2018
New Revision: 339591

URL: http://llvm.org/viewvc/llvm-project?rev=339591&view=rev
Log:
[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

Modified:
    cfe/trunk/lib/StaticAnalyzer/Checkers/UninitializedObjectChecker.cpp

Modified: cfe/trunk/lib/StaticAnalyzer/Checkers/UninitializedObjectChecker.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/StaticAnalyzer/Checkers/UninitializedObjectChecker.cpp?rev=339591&r1=339590&r2=339591&view=diff
==============================================================================
--- cfe/trunk/lib/StaticAnalyzer/Checkers/UninitializedObjectChecker.cpp (original)
+++ cfe/trunk/lib/StaticAnalyzer/Checkers/UninitializedObjectChecker.cpp Mon Aug 13 10:55:52 2018
@@ -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::FindUninitializ
       CheckPointeeInitialization(CheckPointeeInitialization) {}
 
 const UninitFieldSet &FindUninitializedFields::getUninitFields() {
-  isNonUnionUninit(ObjectR, FieldChainInfo());
+  isNonUnionUninit(ObjectR, FieldChainInfo(Factory));
 
   if (!IsPedantic && !IsAnyFieldInitialized)
     UninitFields.clear();




More information about the cfe-commits mailing list