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 { |
Ted Kremenek | 4502195 | 2009-02-14 17:08:39 +0000 | [diff] [blame] | 23 | public: |
Ted Kremenek | f1b8227 | 2009-06-18 23:20:05 +0000 | [diff] [blame] | 24 | SimpleConstraintManager() {} |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 25 | virtual ~SimpleConstraintManager(); |
| 26 | |
Ted Kremenek | a591bc0 | 2009-06-18 22:57:13 +0000 | [diff] [blame] | 27 | //===------------------------------------------------------------------===// |
| 28 | // Common implementation for the interface provided by ConstraintManager. |
| 29 | //===------------------------------------------------------------------===// |
Ted Kremenek | f1b8227 | 2009-06-18 23:20:05 +0000 | [diff] [blame] | 30 | |
| 31 | bool canReasonAbout(SVal X) const; |
| 32 | |
Ted Kremenek | 5b9bd21 | 2009-09-11 22:07:28 +0000 | [diff] [blame] | 33 | const GRState *Assume(const GRState *state, DefinedSVal Cond, |
| 34 | bool Assumption); |
Ted Kremenek | f1b8227 | 2009-06-18 23:20:05 +0000 | [diff] [blame] | 35 | |
Ted Kremenek | a591bc0 | 2009-06-18 22:57:13 +0000 | [diff] [blame] | 36 | const GRState *Assume(const GRState *state, Loc Cond, bool Assumption); |
Ted Kremenek | 4502195 | 2009-02-14 17:08:39 +0000 | [diff] [blame] | 37 | |
Ted Kremenek | a591bc0 | 2009-06-18 22:57:13 +0000 | [diff] [blame] | 38 | const GRState *Assume(const GRState *state, NonLoc Cond, bool Assumption); |
Ted Kremenek | 4502195 | 2009-02-14 17:08:39 +0000 | [diff] [blame] | 39 | |
Ted Kremenek | a591bc0 | 2009-06-18 22:57:13 +0000 | [diff] [blame] | 40 | const GRState *AssumeSymInt(const GRState *state, bool Assumption, |
| 41 | const SymIntExpr *SE); |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 42 | |
Ted Kremenek | 5b9bd21 | 2009-09-11 22:07:28 +0000 | [diff] [blame] | 43 | const GRState *AssumeInBound(const GRState *state, DefinedSVal Idx, |
| 44 | DefinedSVal UpperBound, |
Ted Kremenek | a591bc0 | 2009-06-18 22:57:13 +0000 | [diff] [blame] | 45 | bool Assumption); |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 46 | |
Ted Kremenek | a591bc0 | 2009-06-18 22:57:13 +0000 | [diff] [blame] | 47 | protected: |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 48 | |
Ted Kremenek | a591bc0 | 2009-06-18 22:57:13 +0000 | [diff] [blame] | 49 | //===------------------------------------------------------------------===// |
| 50 | // Interface that subclasses must implement. |
| 51 | //===------------------------------------------------------------------===// |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 52 | |
Ted Kremenek | a591bc0 | 2009-06-18 22:57:13 +0000 | [diff] [blame] | 53 | virtual const GRState *AssumeSymNE(const GRState *state, SymbolRef sym, |
| 54 | const llvm::APSInt& V) = 0; |
Ted Kremenek | 4502195 | 2009-02-14 17:08:39 +0000 | [diff] [blame] | 55 | |
Ted Kremenek | a591bc0 | 2009-06-18 22:57:13 +0000 | [diff] [blame] | 56 | virtual const GRState *AssumeSymEQ(const GRState *state, SymbolRef sym, |
| 57 | const llvm::APSInt& V) = 0; |
Ted Kremenek | 4502195 | 2009-02-14 17:08:39 +0000 | [diff] [blame] | 58 | |
Ted Kremenek | a591bc0 | 2009-06-18 22:57:13 +0000 | [diff] [blame] | 59 | virtual const GRState *AssumeSymLT(const GRState *state, SymbolRef sym, |
| 60 | const llvm::APSInt& V) = 0; |
Ted Kremenek | 4502195 | 2009-02-14 17:08:39 +0000 | [diff] [blame] | 61 | |
Ted Kremenek | a591bc0 | 2009-06-18 22:57:13 +0000 | [diff] [blame] | 62 | virtual const GRState *AssumeSymGT(const GRState *state, SymbolRef sym, |
| 63 | const llvm::APSInt& V) = 0; |
Ted Kremenek | 4502195 | 2009-02-14 17:08:39 +0000 | [diff] [blame] | 64 | |
Ted Kremenek | a591bc0 | 2009-06-18 22:57:13 +0000 | [diff] [blame] | 65 | virtual const GRState *AssumeSymLE(const GRState *state, SymbolRef sym, |
| 66 | const llvm::APSInt& V) = 0; |
Ted Kremenek | 4502195 | 2009-02-14 17:08:39 +0000 | [diff] [blame] | 67 | |
Ted Kremenek | a591bc0 | 2009-06-18 22:57:13 +0000 | [diff] [blame] | 68 | virtual const GRState *AssumeSymGE(const GRState *state, SymbolRef sym, |
| 69 | const llvm::APSInt& V) = 0; |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 70 | |
Ted Kremenek | a591bc0 | 2009-06-18 22:57:13 +0000 | [diff] [blame] | 71 | //===------------------------------------------------------------------===// |
| 72 | // Internal implementation. |
| 73 | //===------------------------------------------------------------------===// |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 74 | |
Ted Kremenek | a591bc0 | 2009-06-18 22:57:13 +0000 | [diff] [blame] | 75 | const GRState *AssumeAux(const GRState *state, Loc Cond,bool Assumption); |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 76 | |
Ted Kremenek | a591bc0 | 2009-06-18 22:57:13 +0000 | [diff] [blame] | 77 | const GRState *AssumeAux(const GRState *state, NonLoc Cond, bool Assumption); |
Ted Kremenek | 4502195 | 2009-02-14 17:08:39 +0000 | [diff] [blame] | 78 | }; |
| 79 | |
| 80 | } // end clang namespace |
| 81 | |
Ted Kremenek | 669c0e1 | 2009-02-15 18:24:51 +0000 | [diff] [blame] | 82 | #endif |