diff options
Diffstat (limited to 'clang/include/clang')
-rw-r--r-- | clang/include/clang/Analysis/Analyses/IntervalSolver/Complete.hpp | 10 | ||||
-rw-r--r-- | clang/include/clang/Analysis/Analyses/IntervalSolver/EquationSystem.hpp | 12 |
2 files changed, 19 insertions, 3 deletions
diff --git a/clang/include/clang/Analysis/Analyses/IntervalSolver/Complete.hpp b/clang/include/clang/Analysis/Analyses/IntervalSolver/Complete.hpp index e3ec15a..664d71f 100644 --- a/clang/include/clang/Analysis/Analyses/IntervalSolver/Complete.hpp +++ b/clang/include/clang/Analysis/Analyses/IntervalSolver/Complete.hpp @@ -99,6 +99,16 @@ struct Complete { template<typename Z> friend std::ostream& operator<<(std::ostream&, const Complete<Z>&); + template<typename S> + S as() const { + if (_infinity) { + if (_value > 0) + return infinity<S>(); + return -infinity<S>(); + } + return (S) _value; + } + private: T _value; bool _infinity; 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; |