diff options
Diffstat (limited to 'clang/include/clang/Analysis/Analyses/IntervalSolver/EquationSystem.hpp')
-rw-r--r-- | clang/include/clang/Analysis/Analyses/IntervalSolver/EquationSystem.hpp | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/clang/include/clang/Analysis/Analyses/IntervalSolver/EquationSystem.hpp b/clang/include/clang/Analysis/Analyses/IntervalSolver/EquationSystem.hpp index 3342cc7..5ee5405 100644 --- a/clang/include/clang/Analysis/Analyses/IntervalSolver/EquationSystem.hpp +++ b/clang/include/clang/Analysis/Analyses/IntervalSolver/EquationSystem.hpp @@ -76,9 +76,14 @@ struct EquationSystem { } Constant<Domain>& constant(const Domain& value) { - Constant<Domain>* constant = new Constant<Domain>(value); - _expressions.insert(constant); - return *constant; + if (_constants.find(value) == _constants.end()) { + Constant<Domain>* constant = new Constant<Domain>(value); + _expressions.insert(constant); + _constants[value] = constant; + return *constant; + } else { + return *_constants[value]; + } } MaxExpression<Domain>* operator[](const Variable<Domain>& var) const { @@ -127,6 +132,7 @@ struct EquationSystem { private: std::set<Operator<Domain>*> _operators; std::set<Expression<Domain>*> _expressions; + std::map<Domain,Constant<Domain>*> _constants; std::vector<Variable<Domain>*> _variables; std::map<std::string, Variable<Domain>*> _variable_names; IdMap<MaxExpression<Domain>, Variable<Domain>*>* _expr_to_var; |