summaryrefslogtreecommitdiff
path: root/clang/include
diff options
context:
space:
mode:
authorZancanaro; Carlo <czan8762@plang3.cs.usyd.edu.au>2012-11-08 19:37:59 +1100
committerZancanaro; Carlo <czan8762@plang3.cs.usyd.edu.au>2012-11-08 19:37:59 +1100
commit1e907d883191571b5c374fd1c3b2f6c1fe11da83 (patch)
tree8faa72279b2ac8221b683f489840e89001494b04 /clang/include
parent6a15c4a790d35d1468f31209267be22ab437742a (diff)
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!
Diffstat (limited to 'clang/include')
-rw-r--r--clang/include/clang/Analysis/Analyses/IntervalSolver/Complete.hpp10
-rw-r--r--clang/include/clang/Analysis/Analyses/IntervalSolver/EquationSystem.hpp12
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;