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 | |
| 33 | const GRState *Assume(const GRState *state, SVal Cond, bool Assumption); |
| 34 | |
Ted Kremenek | a591bc0 | 2009-06-18 22:57:13 +0000 | [diff] [blame] | 35 | const GRState *Assume(const GRState *state, Loc Cond, bool Assumption); |
Ted Kremenek | 4502195 | 2009-02-14 17:08:39 +0000 | [diff] [blame] | 36 | |
Ted Kremenek | a591bc0 | 2009-06-18 22:57:13 +0000 | [diff] [blame] | 37 | const GRState *Assume(const GRState *state, NonLoc Cond, bool Assumption); |
Ted Kremenek | 4502195 | 2009-02-14 17:08:39 +0000 | [diff] [blame] | 38 | |
Ted Kremenek | a591bc0 | 2009-06-18 22:57:13 +0000 | [diff] [blame] | 39 | const GRState *AssumeSymInt(const GRState *state, bool Assumption, |
| 40 | const SymIntExpr *SE); |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame^] | 41 | |
Ted Kremenek | a591bc0 | 2009-06-18 22:57:13 +0000 | [diff] [blame] | 42 | const GRState *AssumeInBound(const GRState *state, SVal Idx, SVal UpperBound, |
| 43 | bool Assumption); |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame^] | 44 | |
Ted Kremenek | a591bc0 | 2009-06-18 22:57:13 +0000 | [diff] [blame] | 45 | protected: |
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 | //===------------------------------------------------------------------===// |
| 48 | // Interface that subclasses must implement. |
| 49 | //===------------------------------------------------------------------===// |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame^] | 50 | |
Ted Kremenek | a591bc0 | 2009-06-18 22:57:13 +0000 | [diff] [blame] | 51 | virtual const GRState *AssumeSymNE(const GRState *state, SymbolRef sym, |
| 52 | const llvm::APSInt& V) = 0; |
Ted Kremenek | 4502195 | 2009-02-14 17:08:39 +0000 | [diff] [blame] | 53 | |
Ted Kremenek | a591bc0 | 2009-06-18 22:57:13 +0000 | [diff] [blame] | 54 | virtual const GRState *AssumeSymEQ(const GRState *state, SymbolRef sym, |
| 55 | const llvm::APSInt& V) = 0; |
Ted Kremenek | 4502195 | 2009-02-14 17:08:39 +0000 | [diff] [blame] | 56 | |
Ted Kremenek | a591bc0 | 2009-06-18 22:57:13 +0000 | [diff] [blame] | 57 | virtual const GRState *AssumeSymLT(const GRState *state, SymbolRef sym, |
| 58 | const llvm::APSInt& V) = 0; |
Ted Kremenek | 4502195 | 2009-02-14 17:08:39 +0000 | [diff] [blame] | 59 | |
Ted Kremenek | a591bc0 | 2009-06-18 22:57:13 +0000 | [diff] [blame] | 60 | virtual const GRState *AssumeSymGT(const GRState *state, SymbolRef sym, |
| 61 | const llvm::APSInt& V) = 0; |
Ted Kremenek | 4502195 | 2009-02-14 17:08:39 +0000 | [diff] [blame] | 62 | |
Ted Kremenek | a591bc0 | 2009-06-18 22:57:13 +0000 | [diff] [blame] | 63 | virtual const GRState *AssumeSymLE(const GRState *state, SymbolRef sym, |
| 64 | const llvm::APSInt& V) = 0; |
Ted Kremenek | 4502195 | 2009-02-14 17:08:39 +0000 | [diff] [blame] | 65 | |
Ted Kremenek | a591bc0 | 2009-06-18 22:57:13 +0000 | [diff] [blame] | 66 | virtual const GRState *AssumeSymGE(const GRState *state, SymbolRef sym, |
| 67 | const llvm::APSInt& V) = 0; |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame^] | 68 | |
Ted Kremenek | a591bc0 | 2009-06-18 22:57:13 +0000 | [diff] [blame] | 69 | //===------------------------------------------------------------------===// |
| 70 | // Internal implementation. |
| 71 | //===------------------------------------------------------------------===// |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame^] | 72 | |
Ted Kremenek | a591bc0 | 2009-06-18 22:57:13 +0000 | [diff] [blame] | 73 | const GRState *AssumeAux(const GRState *state, Loc Cond,bool Assumption); |
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, NonLoc Cond, bool Assumption); |
Ted Kremenek | 4502195 | 2009-02-14 17:08:39 +0000 | [diff] [blame] | 76 | }; |
| 77 | |
| 78 | } // end clang namespace |
| 79 | |
Ted Kremenek | 669c0e1 | 2009-02-15 18:24:51 +0000 | [diff] [blame] | 80 | #endif |