From 1e907d883191571b5c374fd1c3b2f6c1fe11da83 Mon Sep 17 00:00:00 2001 From: "Zancanaro; Carlo" Date: Thu, 8 Nov 2012 19:37:59 +1100 Subject: A few fixes to the MCF solver, and equation stuff General work on the equation systems. Trying to get them to generate correctly with the MCF stuff. It's harder than it seems! --- .../clang/Analysis/Analyses/IntervalSolver/Complete.hpp | 10 ++++++++++ .../Analysis/Analyses/IntervalSolver/EquationSystem.hpp | 12 +++++++++--- 2 files changed, 19 insertions(+), 3 deletions(-) (limited to 'clang/include') 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 friend std::ostream& operator<<(std::ostream&, const Complete&); + template + S as() const { + if (_infinity) { + if (_value > 0) + return infinity(); + return -infinity(); + } + 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& constant(const Domain& value) { - Constant* constant = new Constant(value); - _expressions.insert(constant); - return *constant; + if (_constants.find(value) == _constants.end()) { + Constant* constant = new Constant(value); + _expressions.insert(constant); + _constants[value] = constant; + return *constant; + } else { + return *_constants[value]; + } } MaxExpression* operator[](const Variable& var) const { @@ -127,6 +132,7 @@ struct EquationSystem { private: std::set*> _operators; std::set*> _expressions; + std::map*> _constants; std::vector*> _variables; std::map*> _variable_names; IdMap, Variable*>* _expr_to_var; -- cgit v1.2.3