summaryrefslogtreecommitdiffstats
path: root/clang/lib/StaticAnalyzer/Core/SimpleConstraintManager.h
diff options
context:
space:
mode:
authorJordan Rose <jordan_rose@apple.com>2013-03-23 01:21:16 +0000
committerJordan Rose <jordan_rose@apple.com>2013-03-23 01:21:16 +0000
commit8e6b6c0c2f9174c868a79704537116aa9c8cee41 (patch)
tree85f848d42570e093cdace79d26458c9162f11a77 /clang/lib/StaticAnalyzer/Core/SimpleConstraintManager.h
parent3b4c3ea2fb4de1126e1f07744e0e0bb480bed6ad (diff)
downloadbcm5719-llvm-8e6b6c0c2f9174c868a79704537116aa9c8cee41.tar.gz
bcm5719-llvm-8e6b6c0c2f9174c868a79704537116aa9c8cee41.zip
[analyzer] Translate "a != b" to "(b - a) != 0" in the constraint manager.
Canonicalizing these two forms allows us to better model containers like std::vector, which use "m_start != m_finish" to implement empty() but "m_finish - m_start" to implement size(). The analyzer should have a consistent interpretation of these two symbolic expressions, even though it's not properly reasoning about either one yet. The other unfortunate thing is that while the size() expression will only ever be written "m_finish - m_start", the comparison may be written "m_finish == m_start" or "m_start == m_finish". Right now the analyzer does not attempt to canonicalize those two expressions, since it doesn't know which length expression to pick. Doing this correctly will probably require implementing unary minus as a new SymExpr kind (<rdar://problem/12351075>). For now, the analyzer inverts the order of arguments in the comparison to build the subtraction, on the assumption that "begin() != end()" is written more often than "end() != begin()". This is purely speculation. <rdar://problem/13239003> llvm-svn: 177801
Diffstat (limited to 'clang/lib/StaticAnalyzer/Core/SimpleConstraintManager.h')
-rw-r--r--clang/lib/StaticAnalyzer/Core/SimpleConstraintManager.h9
1 files changed, 5 insertions, 4 deletions
diff --git a/clang/lib/StaticAnalyzer/Core/SimpleConstraintManager.h b/clang/lib/StaticAnalyzer/Core/SimpleConstraintManager.h
index 01f0b4e4461..10ddef1341c 100644
--- a/clang/lib/StaticAnalyzer/Core/SimpleConstraintManager.h
+++ b/clang/lib/StaticAnalyzer/Core/SimpleConstraintManager.h
@@ -23,10 +23,10 @@ namespace ento {
class SimpleConstraintManager : public ConstraintManager {
SubEngine *SU;
- BasicValueFactory &BVF;
+ SValBuilder &SVB;
public:
- SimpleConstraintManager(SubEngine *subengine, BasicValueFactory &BV)
- : SU(subengine), BVF(BV) {}
+ SimpleConstraintManager(SubEngine *subengine, SValBuilder &SB)
+ : SU(subengine), SVB(SB) {}
virtual ~SimpleConstraintManager();
//===------------------------------------------------------------------===//
@@ -81,7 +81,8 @@ protected:
// Internal implementation.
//===------------------------------------------------------------------===//
- BasicValueFactory &getBasicVals() const { return BVF; }
+ BasicValueFactory &getBasicVals() const { return SVB.getBasicValueFactory(); }
+ SymbolManager &getSymbolManager() const { return SVB.getSymbolManager(); }
bool canReasonAbout(SVal X) const;
OpenPOWER on IntegriCloud