diff options
author | Zhongxing Xu <xuzhongxing@gmail.com> | 2008-08-27 14:03:33 +0000 |
---|---|---|
committer | Zhongxing Xu <xuzhongxing@gmail.com> | 2008-08-27 14:03:33 +0000 |
commit | 30ad167f74cb8a04c35ced6c69b116f15d104f8e (patch) | |
tree | ad56b0bfe9b201ce6caecae63e6d4a2ad5aceea4 /include/clang | |
parent | 9c3fc703b29a31d40bcf5027dbb4784dd393804e (diff) |
Refactor Assume logic into a separate class ConstraintManager.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@55412 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'include/clang')
-rw-r--r-- | include/clang/Analysis/PathSensitive/BasicStore.h | 2 | ||||
-rw-r--r-- | include/clang/Analysis/PathSensitive/ConstraintManager.h | 20 | ||||
-rw-r--r-- | include/clang/Analysis/PathSensitive/GRState.h | 56 |
3 files changed, 31 insertions, 47 deletions
diff --git a/include/clang/Analysis/PathSensitive/BasicStore.h b/include/clang/Analysis/PathSensitive/BasicStore.h index b936e2ac4f..d9d3208ac5 100644 --- a/include/clang/Analysis/PathSensitive/BasicStore.h +++ b/include/clang/Analysis/PathSensitive/BasicStore.h @@ -17,7 +17,7 @@ #include "clang/Analysis/PathSensitive/Store.h" namespace llvm { - class llvm::BumpPtrAllocator; + class BumpPtrAllocator; class ASTContext; } diff --git a/include/clang/Analysis/PathSensitive/ConstraintManager.h b/include/clang/Analysis/PathSensitive/ConstraintManager.h new file mode 100644 index 0000000000..0d8b56a9d7 --- /dev/null +++ b/include/clang/Analysis/PathSensitive/ConstraintManager.h @@ -0,0 +1,20 @@ +#ifndef CONSTRAINT_MANAGER_H +#define CONSTRAINT_MANAGER_H + +namespace clang { + +class GRState; +class GRStateManager; +class RVal; + +class ConstraintManager { +public: + virtual const GRState* Assume(const GRState* St, RVal Cond, bool Assumption, + bool& isFeasible) = 0; +}; + +ConstraintManager* CreateBasicConstraintManager(GRStateManager& statemgr); + +} // end clang namespace + +#endif diff --git a/include/clang/Analysis/PathSensitive/GRState.h b/include/clang/Analysis/PathSensitive/GRState.h index c360da9a7c..aca5a66a52 100644 --- a/include/clang/Analysis/PathSensitive/GRState.h +++ b/include/clang/Analysis/PathSensitive/GRState.h @@ -18,6 +18,7 @@ #include "clang/Analysis/PathSensitive/Environment.h" #include "clang/Analysis/PathSensitive/Store.h" +#include "clang/Analysis/PathSensitive/ConstraintManager.h" #include "clang/Analysis/PathSensitive/RValues.h" #include "clang/Analysis/PathSensitive/GRCoreEngine.h" #include "clang/AST/Expr.h" @@ -233,6 +234,7 @@ class GRStateManager { private: EnvironmentManager EnvMgr; llvm::OwningPtr<StoreManager> StMgr; + llvm::OwningPtr<ConstraintManager> ConstraintMgr; GRState::IntSetTy::Factory ISetFactory; GRState::GenericDataMap::Factory GDMFactory; @@ -286,9 +288,12 @@ private: const GRState* BindVar(const GRState* St, VarDecl* D, RVal V) { return SetRVal(St, lval::DeclVal(D), V); } + + typedef ConstraintManager* (*ConstraintManagerCreater)(GRStateManager&); public: GRStateManager(ASTContext& Ctx, StoreManager* stmgr, + ConstraintManagerCreater CreateConstraintManager, llvm::BumpPtrAllocator& alloc, CFG& c, LiveVariables& L) : EnvMgr(alloc), StMgr(stmgr), @@ -298,7 +303,9 @@ public: SymMgr(alloc), Alloc(alloc), cfg(c), - Liveness(L) {} + Liveness(L) { + ConstraintMgr.reset((*CreateConstraintManager)(*this)); + } ~GRStateManager(); @@ -309,6 +316,7 @@ public: const BasicValueFactory& getBasicVals() const { return BasicVals; } SymbolManager& getSymbolManager() { return SymMgr; } LiveVariables& getLiveVariables() { return Liveness; } + llvm::BumpPtrAllocator& getAllocator() { return Alloc; } typedef StoreManager::DeadSymbolsTy DeadSymbolsTy; @@ -440,52 +448,8 @@ public: // Assumption logic. const GRState* Assume(const GRState* St, RVal Cond, bool Assumption, bool& isFeasible) { - - if (Cond.isUnknown()) { - isFeasible = true; - return St; - } - - if (isa<LVal>(Cond)) - return Assume(St, cast<LVal>(Cond), Assumption, isFeasible); - else - return Assume(St, cast<NonLVal>(Cond), Assumption, isFeasible); + return ConstraintMgr->Assume(St, Cond, Assumption, isFeasible); } - - const GRState* Assume(const GRState* St, LVal Cond, bool Assumption, - bool& isFeasible); - - const GRState* Assume(const GRState* St, NonLVal Cond, bool Assumption, - bool& isFeasible); - -private: - const GRState* AssumeAux(const GRState* St, LVal Cond, bool Assumption, - bool& isFeasible); - - - const GRState* AssumeAux(const GRState* St, NonLVal Cond, - bool Assumption, bool& isFeasible); - - const GRState* AssumeSymInt(const GRState* St, bool Assumption, - const SymIntConstraint& C, bool& isFeasible); - - const GRState* AssumeSymNE(const GRState* St, SymbolID sym, - const llvm::APSInt& V, bool& isFeasible); - - const GRState* AssumeSymEQ(const GRState* St, SymbolID sym, - const llvm::APSInt& V, bool& isFeasible); - - const GRState* AssumeSymLT(const GRState* St, SymbolID sym, - const llvm::APSInt& V, bool& isFeasible); - - const GRState* AssumeSymLE(const GRState* St, SymbolID sym, - const llvm::APSInt& V, bool& isFeasible); - - const GRState* AssumeSymGT(const GRState* St, SymbolID sym, - const llvm::APSInt& V, bool& isFeasible); - - const GRState* AssumeSymGE(const GRState* St, SymbolID sym, - const llvm::APSInt& V, bool& isFeasible); }; //===----------------------------------------------------------------------===// |