summaryrefslogtreecommitdiff
path: root/clang/include
diff options
context:
space:
mode:
authorZancanaro; Carlo <czan8762@plang3.cs.usyd.edu.au>2012-10-04 17:11:33 +1000
committerZancanaro; Carlo <czan8762@plang3.cs.usyd.edu.au>2012-10-04 17:11:33 +1000
commit684045e9e843ed9b8be30728482ce3d69d63b527 (patch)
tree0707aa71b902384766a7c0eb4d901fac9a5cbb63 /clang/include
parentf168645671e31b5d2e7fb134b9d9f8750aebb872 (diff)
Lets keep trying with this here equation system.
Still not there, but more non-functional code is there. Splitting blocks into sub-blocks now works, as does some of the guard stuff and the general "shape" of the resulting equation system.
Diffstat (limited to 'clang/include')
l---------clang/include/clang/Analysis/Analyses/IntervalSolver/.#EquationSystem.hpp1
l---------clang/include/clang/Analysis/Analyses/IntervalSolver/.#EquationSystem_flymake.hpp1
l---------clang/include/clang/Analysis/Analyses/IntervalSolver/.#Expression.hpp1
l---------clang/include/clang/Analysis/Analyses/IntervalSolver/.#Expression_flymake.hpp1
l---------clang/include/clang/Analysis/Analyses/IntervalSolver/.#Operator_flymake.hpp1
-rw-r--r--clang/include/clang/Analysis/Analyses/IntervalSolver/EquationSystem.hpp21
-rw-r--r--clang/include/clang/Analysis/Analyses/IntervalSolver/Expression.hpp5
-rw-r--r--clang/include/clang/Analysis/Analyses/IntervalSolver/IdMap.hpp2
-rw-r--r--clang/include/clang/Analysis/Analyses/IntervalSolver/Operator.hpp7
-rw-r--r--clang/include/clang/Analysis/Analyses/IntervalSolver/VariableAssignment.hpp2
-rw-r--r--clang/include/clang/Frontend/Analyses.def1
-rw-r--r--clang/include/clang/StaticAnalyzer/Core/PathSensitive/ConstraintManager.h2
12 files changed, 25 insertions, 20 deletions
diff --git a/clang/include/clang/Analysis/Analyses/IntervalSolver/.#EquationSystem.hpp b/clang/include/clang/Analysis/Analyses/IntervalSolver/.#EquationSystem.hpp
deleted file mode 120000
index 56b9060..0000000
--- a/clang/include/clang/Analysis/Analyses/IntervalSolver/.#EquationSystem.hpp
+++ /dev/null
@@ -1 +0,0 @@
-carlo@pc-4w14-0.cs.usyd.edu.au.4300:1348200365 \ No newline at end of file
diff --git a/clang/include/clang/Analysis/Analyses/IntervalSolver/.#EquationSystem_flymake.hpp b/clang/include/clang/Analysis/Analyses/IntervalSolver/.#EquationSystem_flymake.hpp
deleted file mode 120000
index 4dc56be..0000000
--- a/clang/include/clang/Analysis/Analyses/IntervalSolver/.#EquationSystem_flymake.hpp
+++ /dev/null
@@ -1 +0,0 @@
-carlo@pc-4w14-0.cs.usyd.edu.au.9390:1348126501 \ No newline at end of file
diff --git a/clang/include/clang/Analysis/Analyses/IntervalSolver/.#Expression.hpp b/clang/include/clang/Analysis/Analyses/IntervalSolver/.#Expression.hpp
deleted file mode 120000
index 4dc56be..0000000
--- a/clang/include/clang/Analysis/Analyses/IntervalSolver/.#Expression.hpp
+++ /dev/null
@@ -1 +0,0 @@
-carlo@pc-4w14-0.cs.usyd.edu.au.9390:1348126501 \ No newline at end of file
diff --git a/clang/include/clang/Analysis/Analyses/IntervalSolver/.#Expression_flymake.hpp b/clang/include/clang/Analysis/Analyses/IntervalSolver/.#Expression_flymake.hpp
deleted file mode 120000
index 4dc56be..0000000
--- a/clang/include/clang/Analysis/Analyses/IntervalSolver/.#Expression_flymake.hpp
+++ /dev/null
@@ -1 +0,0 @@
-carlo@pc-4w14-0.cs.usyd.edu.au.9390:1348126501 \ No newline at end of file
diff --git a/clang/include/clang/Analysis/Analyses/IntervalSolver/.#Operator_flymake.hpp b/clang/include/clang/Analysis/Analyses/IntervalSolver/.#Operator_flymake.hpp
deleted file mode 120000
index 4dc56be..0000000
--- a/clang/include/clang/Analysis/Analyses/IntervalSolver/.#Operator_flymake.hpp
+++ /dev/null
@@ -1 +0,0 @@
-carlo@pc-4w14-0.cs.usyd.edu.au.9390:1348126501 \ No newline at end of file
diff --git a/clang/include/clang/Analysis/Analyses/IntervalSolver/EquationSystem.hpp b/clang/include/clang/Analysis/Analyses/IntervalSolver/EquationSystem.hpp
index 701da7c..d95366d 100644
--- a/clang/include/clang/Analysis/Analyses/IntervalSolver/EquationSystem.hpp
+++ b/clang/include/clang/Analysis/Analyses/IntervalSolver/EquationSystem.hpp
@@ -91,22 +91,18 @@ struct EquationSystem {
void indexMaxExpressions() {
_expr_to_var = new IdMap<MaxExpression<Domain>,Variable<Domain>*>(maxExpressionCount(), NULL);
for (unsigned int i = 0, length = _right_sides.size(); i < length; ++i) {
- _right_sides[i]->mapTo(*_variables[i], *_expr_to_var);
+ if (_right_sides[i])
+ _right_sides[i]->mapTo(*_variables[i], *_expr_to_var);
}
}
Variable<Domain>* varFromExpr(const Expression<Domain>& expr) const {
- if (_expr_to_var) { // we've indexed:
- const MaxExpression<Domain>* maxExpr = expr.toMaxExpression();//dynamic_cast<const MaxExpression<Domain>*>(&expr);
- if (maxExpr) {
- return (*_expr_to_var)[*maxExpr];
- } else {
- return NULL;
- }
+ assert(_expr_to_var != NULL); // ensure we've indexed
+ const MaxExpression<Domain>* maxExpr = expr.toMaxExpression();//dynamic_cast<const MaxExpression<Domain>*>(&expr);
+ if (maxExpr) {
+ return (*_expr_to_var)[*maxExpr];
} else {
- std::cout << "throw exception" << *(char*)NULL;
return NULL;
- //throw "Must index max expressions before attempting lookup";
}
}
@@ -125,7 +121,10 @@ struct EquationSystem {
for (unsigned int i = 0, length = _variables.size();
i < length;
++i) {
- cout << *_variables[i] << " = " << *_right_sides[i] << std::endl;
+ if (_right_sides[i])
+ cout << *_variables[i] << " = " << *_right_sides[i] << std::endl;
+ else
+ cout << *_variables[i] << " = NULL" << std::endl;
}
}
diff --git a/clang/include/clang/Analysis/Analyses/IntervalSolver/Expression.hpp b/clang/include/clang/Analysis/Analyses/IntervalSolver/Expression.hpp
index 7b0f2cf..c4ee4c0 100644
--- a/clang/include/clang/Analysis/Analyses/IntervalSolver/Expression.hpp
+++ b/clang/include/clang/Analysis/Analyses/IntervalSolver/Expression.hpp
@@ -84,7 +84,9 @@ struct Variable : public Expression<Domain> {
template<typename Domain>
struct OperatorExpression : public Expression<Domain> {
OperatorExpression(const Operator<Domain>& op, const std::vector<Expression<Domain>*>& arguments)
- : _operator(op), _arguments(arguments) { }
+ : _operator(op), _arguments(arguments) {
+ assert(!arguments.empty());
+ }
virtual Domain eval(const VariableAssignment<Domain>& rho) const {
std::vector<Domain> argumentValues;
@@ -145,7 +147,6 @@ struct MaxExpression : public OperatorExpression<Domain> {
MaxExpression(const unsigned int& id, const Maximum<Domain>& op, const std::vector<Expression<Domain>*>& arguments)
: OperatorExpression<Domain>(op, arguments), _id(id) { }
-
const MaxExpression* toMaxExpression() const {
return this;
}
diff --git a/clang/include/clang/Analysis/Analyses/IntervalSolver/IdMap.hpp b/clang/include/clang/Analysis/Analyses/IntervalSolver/IdMap.hpp
index 27c0806..5e3aa3b 100644
--- a/clang/include/clang/Analysis/Analyses/IntervalSolver/IdMap.hpp
+++ b/clang/include/clang/Analysis/Analyses/IntervalSolver/IdMap.hpp
@@ -7,7 +7,7 @@ template<typename T, typename V>
struct IdMap {
IdMap(unsigned int length, V initial)
: _length(length), _assignment(new V[length]) {
- for (unsigned int i = 0; i < _length; ++i) {
+ for (unsigned int i = 0; i < length; ++i) {
_assignment[i] = initial;
}
}
diff --git a/clang/include/clang/Analysis/Analyses/IntervalSolver/Operator.hpp b/clang/include/clang/Analysis/Analyses/IntervalSolver/Operator.hpp
index b67591f..08c66ff 100644
--- a/clang/include/clang/Analysis/Analyses/IntervalSolver/Operator.hpp
+++ b/clang/include/clang/Analysis/Analyses/IntervalSolver/Operator.hpp
@@ -28,6 +28,11 @@ struct Maximum : public Operator<Domain> {
}
};
+
+template<class T>
+T minimum(const T& l, const T& r) {
+ return (l < r ? l : r);
+}
template<typename Domain>
struct Minimum : public Operator<Domain> {
virtual Domain eval(const std::vector<Domain>& arguments) const {
@@ -35,7 +40,7 @@ struct Minimum : public Operator<Domain> {
for (typename std::vector<Domain>::const_iterator it = arguments.begin();
it != arguments.end();
++it) {
- result = (*it < result ? *it : result);
+ result = minimum(*it, result); //*it < result ? *it : result);
}
return result;
}
diff --git a/clang/include/clang/Analysis/Analyses/IntervalSolver/VariableAssignment.hpp b/clang/include/clang/Analysis/Analyses/IntervalSolver/VariableAssignment.hpp
index d2adff5..0bbebfc 100644
--- a/clang/include/clang/Analysis/Analyses/IntervalSolver/VariableAssignment.hpp
+++ b/clang/include/clang/Analysis/Analyses/IntervalSolver/VariableAssignment.hpp
@@ -47,6 +47,8 @@ private:
solver_log::fixpoint << indent() << "Stabilise " << x << std::endl;
stack_depth++;
+ if (!_system[x])
+ return;
Domain val = _system[x]->eval(DependencyAssignment(*this, x),
_strategy);
stack_depth--;
diff --git a/clang/include/clang/Frontend/Analyses.def b/clang/include/clang/Frontend/Analyses.def
index b5b9394..902575f 100644
--- a/clang/include/clang/Frontend/Analyses.def
+++ b/clang/include/clang/Frontend/Analyses.def
@@ -23,6 +23,7 @@ ANALYSIS_STORE(RegionStore, "region", "Use region-based analyzer store", CreateR
ANALYSIS_CONSTRAINTS(BasicConstraints, "basic", "Use basic constraint tracking", CreateBasicConstraintManager)
ANALYSIS_CONSTRAINTS(RangeConstraints, "range", "Use constraint tracking of concrete value ranges", CreateRangeConstraintManager)
+ANALYSIS_CONSTRAINTS(IntervalConstraints, "interval", "Use constraint tracking of intervals", CreateIntervalConstraintManager)
#ifndef ANALYSIS_DIAGNOSTICS
#define ANALYSIS_DIAGNOSTICS(NAME, CMDFLAG, DESC, CREATEFN, AUTOCREATE)
diff --git a/clang/include/clang/StaticAnalyzer/Core/PathSensitive/ConstraintManager.h b/clang/include/clang/StaticAnalyzer/Core/PathSensitive/ConstraintManager.h
index 631858d..4051cfc 100644
--- a/clang/include/clang/StaticAnalyzer/Core/PathSensitive/ConstraintManager.h
+++ b/clang/include/clang/StaticAnalyzer/Core/PathSensitive/ConstraintManager.h
@@ -73,6 +73,8 @@ ConstraintManager* CreateBasicConstraintManager(ProgramStateManager& statemgr,
SubEngine &subengine);
ConstraintManager* CreateRangeConstraintManager(ProgramStateManager& statemgr,
SubEngine &subengine);
+ConstraintManager* CreateIntervalConstraintManager(ProgramStateManager& statemgr,
+ SubEngine &subengine);
} // end GR namespace