Ted Kremenek | 4502195 | 2009-02-14 17:08:39 +0000 | [diff] [blame] | 1 | //== SimpleConstraintManager.h ----------------------------------*- C++ -*--==// |
| 2 | // |
| 3 | // The LLVM Compiler Infrastructure |
| 4 | // |
| 5 | // This file is distributed under the University of Illinois Open Source |
| 6 | // License. See LICENSE.TXT for details. |
| 7 | // |
| 8 | //===----------------------------------------------------------------------===// |
| 9 | // |
| 10 | // Code shared between BasicConstraintManager and RangeConstraintManager. |
| 11 | // |
| 12 | //===----------------------------------------------------------------------===// |
| 13 | |
| 14 | #ifndef LLVM_CLANG_ANALYSIS_SIMPLE_CONSTRAINT_MANAGER_H |
| 15 | #define LLVM_CLANG_ANALYSIS_SIMPLE_CONSTRAINT_MANAGER_H |
| 16 | |
| 17 | #include "clang/Analysis/PathSensitive/ConstraintManager.h" |
| 18 | #include "clang/Analysis/PathSensitive/GRState.h" |
| 19 | |
| 20 | namespace clang { |
| 21 | |
| 22 | class SimpleConstraintManager : public ConstraintManager { |
| 23 | protected: |
| 24 | GRStateManager& StateMgr; |
| 25 | public: |
| 26 | SimpleConstraintManager(GRStateManager& statemgr) |
| 27 | : StateMgr(statemgr) {} |
| 28 | virtual ~SimpleConstraintManager(); |
Ted Kremenek | 66b5271 | 2009-03-11 02:22:59 +0000 | [diff] [blame] | 29 | |
| 30 | bool canReasonAbout(SVal X) const; |
| 31 | |
Ted Kremenek | a591bc0 | 2009-06-18 22:57:13 +0000 | [diff] [blame^] | 32 | virtual const GRState *Assume(const GRState *state, SVal Cond, |
| 33 | bool Assumption); |
Ted Kremenek | 4502195 | 2009-02-14 17:08:39 +0000 | [diff] [blame] | 34 | |
Ted Kremenek | a591bc0 | 2009-06-18 22:57:13 +0000 | [diff] [blame^] | 35 | //===------------------------------------------------------------------===// |
| 36 | // Common implementation for the interface provided by ConstraintManager. |
| 37 | //===------------------------------------------------------------------===// |
| 38 | |
| 39 | const GRState *Assume(const GRState *state, Loc Cond, bool Assumption); |
Ted Kremenek | 4502195 | 2009-02-14 17:08:39 +0000 | [diff] [blame] | 40 | |
Ted Kremenek | a591bc0 | 2009-06-18 22:57:13 +0000 | [diff] [blame^] | 41 | const GRState *Assume(const GRState *state, NonLoc Cond, bool Assumption); |
Ted Kremenek | 4502195 | 2009-02-14 17:08:39 +0000 | [diff] [blame] | 42 | |
Ted Kremenek | a591bc0 | 2009-06-18 22:57:13 +0000 | [diff] [blame^] | 43 | const GRState *AssumeSymInt(const GRState *state, bool Assumption, |
| 44 | const SymIntExpr *SE); |
| 45 | |
| 46 | const GRState *AssumeInBound(const GRState *state, SVal Idx, SVal UpperBound, |
| 47 | bool Assumption); |
| 48 | |
| 49 | protected: |
| 50 | |
| 51 | //===------------------------------------------------------------------===// |
| 52 | // Interface that subclasses must implement. |
| 53 | //===------------------------------------------------------------------===// |
| 54 | |
| 55 | virtual const GRState *AssumeSymNE(const GRState *state, SymbolRef sym, |
| 56 | const llvm::APSInt& V) = 0; |
Ted Kremenek | 4502195 | 2009-02-14 17:08:39 +0000 | [diff] [blame] | 57 | |
Ted Kremenek | a591bc0 | 2009-06-18 22:57:13 +0000 | [diff] [blame^] | 58 | virtual const GRState *AssumeSymEQ(const GRState *state, SymbolRef sym, |
| 59 | const llvm::APSInt& V) = 0; |
Ted Kremenek | 4502195 | 2009-02-14 17:08:39 +0000 | [diff] [blame] | 60 | |
Ted Kremenek | a591bc0 | 2009-06-18 22:57:13 +0000 | [diff] [blame^] | 61 | virtual const GRState *AssumeSymLT(const GRState *state, SymbolRef sym, |
| 62 | const llvm::APSInt& V) = 0; |
Ted Kremenek | 4502195 | 2009-02-14 17:08:39 +0000 | [diff] [blame] | 63 | |
Ted Kremenek | a591bc0 | 2009-06-18 22:57:13 +0000 | [diff] [blame^] | 64 | virtual const GRState *AssumeSymGT(const GRState *state, SymbolRef sym, |
| 65 | const llvm::APSInt& V) = 0; |
Ted Kremenek | 4502195 | 2009-02-14 17:08:39 +0000 | [diff] [blame] | 66 | |
Ted Kremenek | a591bc0 | 2009-06-18 22:57:13 +0000 | [diff] [blame^] | 67 | virtual const GRState *AssumeSymLE(const GRState *state, SymbolRef sym, |
| 68 | const llvm::APSInt& V) = 0; |
Ted Kremenek | 4502195 | 2009-02-14 17:08:39 +0000 | [diff] [blame] | 69 | |
Ted Kremenek | a591bc0 | 2009-06-18 22:57:13 +0000 | [diff] [blame^] | 70 | virtual const GRState *AssumeSymGE(const GRState *state, SymbolRef sym, |
| 71 | const llvm::APSInt& V) = 0; |
| 72 | |
| 73 | //===------------------------------------------------------------------===// |
| 74 | // Internal implementation. |
| 75 | //===------------------------------------------------------------------===// |
| 76 | |
| 77 | const GRState *AssumeAux(const GRState *state, Loc Cond,bool Assumption); |
| 78 | |
| 79 | const GRState *AssumeAux(const GRState *state, NonLoc Cond, bool Assumption); |
Ted Kremenek | 4502195 | 2009-02-14 17:08:39 +0000 | [diff] [blame] | 80 | |
Ted Kremenek | a591bc0 | 2009-06-18 22:57:13 +0000 | [diff] [blame^] | 81 | //===------------------------------------------------------------------===// |
| 82 | // FIXME: These can probably be removed now. |
| 83 | //===------------------------------------------------------------------===// |
Ted Kremenek | 4502195 | 2009-02-14 17:08:39 +0000 | [diff] [blame] | 84 | |
| 85 | private: |
| 86 | BasicValueFactory& getBasicVals() { return StateMgr.getBasicVals(); } |
Zhongxing Xu | a129eb9 | 2009-03-25 05:58:37 +0000 | [diff] [blame] | 87 | SymbolManager& getSymbolManager() const { return StateMgr.getSymbolManager(); } |
Ted Kremenek | 4502195 | 2009-02-14 17:08:39 +0000 | [diff] [blame] | 88 | }; |
| 89 | |
| 90 | } // end clang namespace |
| 91 | |
Ted Kremenek | 669c0e1 | 2009-02-15 18:24:51 +0000 | [diff] [blame] | 92 | #endif |