ddcc created this revision.
ddcc added reviewers: zaks.anna, dcoughlin.
ddcc added a subscriber: cfe-commits.

Split out optimization from https://reviews.llvm.org/D26061


https://reviews.llvm.org/D26642

Files:
  lib/StaticAnalyzer/Core/RangeConstraintManager.cpp


Index: lib/StaticAnalyzer/Core/RangeConstraintManager.cpp
===================================================================
--- lib/StaticAnalyzer/Core/RangeConstraintManager.cpp
+++ lib/StaticAnalyzer/Core/RangeConstraintManager.cpp
@@ -398,17 +398,19 @@
 ProgramStateRef
 RangeConstraintManager::removeDeadBindings(ProgramStateRef state,
                                            SymbolReaper& SymReaper) {
-
+  bool Changed = false;
   ConstraintRangeTy CR = state->get<ConstraintRange>();
-  ConstraintRangeTy::Factory& CRFactory = 
state->get_context<ConstraintRange>();
+  ConstraintRangeTy::Factory &CRFactory = 
state->get_context<ConstraintRange>();
 
   for (ConstraintRangeTy::iterator I = CR.begin(), E = CR.end(); I != E; ++I) {
     SymbolRef sym = I.getKey();
-    if (SymReaper.maybeDead(sym))
+    if (SymReaper.maybeDead(sym)) {
+      Changed = true;
       CR = CRFactory.remove(CR, sym);
+    }
   }
 
-  return state->set<ConstraintRange>(CR);
+  return Changed ? state->set<ConstraintRange>(CR) : state;
 }
 
 RangeSet


Index: lib/StaticAnalyzer/Core/RangeConstraintManager.cpp
===================================================================
--- lib/StaticAnalyzer/Core/RangeConstraintManager.cpp
+++ lib/StaticAnalyzer/Core/RangeConstraintManager.cpp
@@ -398,17 +398,19 @@
 ProgramStateRef
 RangeConstraintManager::removeDeadBindings(ProgramStateRef state,
                                            SymbolReaper& SymReaper) {
-
+  bool Changed = false;
   ConstraintRangeTy CR = state->get<ConstraintRange>();
-  ConstraintRangeTy::Factory& CRFactory = state->get_context<ConstraintRange>();
+  ConstraintRangeTy::Factory &CRFactory = state->get_context<ConstraintRange>();
 
   for (ConstraintRangeTy::iterator I = CR.begin(), E = CR.end(); I != E; ++I) {
     SymbolRef sym = I.getKey();
-    if (SymReaper.maybeDead(sym))
+    if (SymReaper.maybeDead(sym)) {
+      Changed = true;
       CR = CRFactory.remove(CR, sym);
+    }
   }
 
-  return state->set<ConstraintRange>(CR);
+  return Changed ? state->set<ConstraintRange>(CR) : state;
 }
 
 RangeSet
_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to