r286925 - [analyzer] Minor optimization: avoid setting state if unchanged
Dominic Chen via cfe-commits
cfe-commits at lists.llvm.org
Mon Nov 14 17:40:59 PST 2016
Author: ddcc
Date: Mon Nov 14 19:40:58 2016
New Revision: 286925
URL: http://llvm.org/viewvc/llvm-project?rev=286925&view=rev
Log:
[analyzer] Minor optimization: avoid setting state if unchanged
Summary: Split out optimization from D26061
Reviewers: zaks.anna, dcoughlin
Subscribers: cfe-commits
Differential Revision: https://reviews.llvm.org/D26642
Modified:
cfe/trunk/lib/StaticAnalyzer/Core/RangeConstraintManager.cpp
Modified: cfe/trunk/lib/StaticAnalyzer/Core/RangeConstraintManager.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/StaticAnalyzer/Core/RangeConstraintManager.cpp?rev=286925&r1=286924&r2=286925&view=diff
==============================================================================
--- cfe/trunk/lib/StaticAnalyzer/Core/RangeConstraintManager.cpp (original)
+++ cfe/trunk/lib/StaticAnalyzer/Core/RangeConstraintManager.cpp Mon Nov 14 19:40:58 2016
@@ -398,17 +398,19 @@ ConditionTruthVal RangeConstraintManager
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
More information about the cfe-commits
mailing list