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 | |
Argyrios Kyrtzidis | 98cabba | 2010-12-22 18:51:49 +0000 | [diff] [blame^] | 17 | #include "clang/GR/PathSensitive/ConstraintManager.h" |
| 18 | #include "clang/GR/PathSensitive/GRState.h" |
Ted Kremenek | 4502195 | 2009-02-14 17:08:39 +0000 | [diff] [blame] | 19 | |
| 20 | namespace clang { |
| 21 | |
| 22 | class SimpleConstraintManager : public ConstraintManager { |
Ted Kremenek | 32a5808 | 2010-01-05 00:15:18 +0000 | [diff] [blame] | 23 | GRSubEngine &SU; |
Ted Kremenek | 4502195 | 2009-02-14 17:08:39 +0000 | [diff] [blame] | 24 | public: |
Ted Kremenek | 32a5808 | 2010-01-05 00:15:18 +0000 | [diff] [blame] | 25 | SimpleConstraintManager(GRSubEngine &subengine) : SU(subengine) {} |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 26 | virtual ~SimpleConstraintManager(); |
| 27 | |
Ted Kremenek | a591bc0 | 2009-06-18 22:57:13 +0000 | [diff] [blame] | 28 | //===------------------------------------------------------------------===// |
| 29 | // Common implementation for the interface provided by ConstraintManager. |
| 30 | //===------------------------------------------------------------------===// |
Ted Kremenek | f1b8227 | 2009-06-18 23:20:05 +0000 | [diff] [blame] | 31 | |
| 32 | bool canReasonAbout(SVal X) const; |
| 33 | |
Ted Kremenek | 28f47b9 | 2010-12-01 22:16:56 +0000 | [diff] [blame] | 34 | const GRState *assume(const GRState *state, DefinedSVal Cond, |
Ted Kremenek | 5b9bd21 | 2009-09-11 22:07:28 +0000 | [diff] [blame] | 35 | bool Assumption); |
Ted Kremenek | f1b8227 | 2009-06-18 23:20:05 +0000 | [diff] [blame] | 36 | |
Ted Kremenek | 28f47b9 | 2010-12-01 22:16:56 +0000 | [diff] [blame] | 37 | const GRState *assume(const GRState *state, Loc Cond, bool Assumption); |
Ted Kremenek | 4502195 | 2009-02-14 17:08:39 +0000 | [diff] [blame] | 38 | |
Ted Kremenek | 28f47b9 | 2010-12-01 22:16:56 +0000 | [diff] [blame] | 39 | const GRState *assume(const GRState *state, NonLoc Cond, bool Assumption); |
Ted Kremenek | 4502195 | 2009-02-14 17:08:39 +0000 | [diff] [blame] | 40 | |
Ted Kremenek | 28f47b9 | 2010-12-01 22:16:56 +0000 | [diff] [blame] | 41 | const GRState *assumeSymRel(const GRState *state, |
Jordy Rose | ba0f61c | 2010-06-18 22:49:11 +0000 | [diff] [blame] | 42 | const SymExpr *LHS, |
| 43 | BinaryOperator::Opcode op, |
| 44 | const llvm::APSInt& Int); |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 45 | |
Ted Kremenek | a591bc0 | 2009-06-18 22:57:13 +0000 | [diff] [blame] | 46 | protected: |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 47 | |
Ted Kremenek | a591bc0 | 2009-06-18 22:57:13 +0000 | [diff] [blame] | 48 | //===------------------------------------------------------------------===// |
| 49 | // Interface that subclasses must implement. |
| 50 | //===------------------------------------------------------------------===// |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 51 | |
Jordy Rose | ba0f61c | 2010-06-18 22:49:11 +0000 | [diff] [blame] | 52 | // Each of these is of the form "$sym+Adj <> V", where "<>" is the comparison |
| 53 | // operation for the method being invoked. |
Ted Kremenek | 28f47b9 | 2010-12-01 22:16:56 +0000 | [diff] [blame] | 54 | virtual const GRState *assumeSymNE(const GRState *state, SymbolRef sym, |
Jordy Rose | ba0f61c | 2010-06-18 22:49:11 +0000 | [diff] [blame] | 55 | const llvm::APSInt& V, |
| 56 | const llvm::APSInt& Adjustment) = 0; |
Ted Kremenek | 4502195 | 2009-02-14 17:08:39 +0000 | [diff] [blame] | 57 | |
Ted Kremenek | 28f47b9 | 2010-12-01 22:16:56 +0000 | [diff] [blame] | 58 | virtual const GRState *assumeSymEQ(const GRState *state, SymbolRef sym, |
Jordy Rose | ba0f61c | 2010-06-18 22:49:11 +0000 | [diff] [blame] | 59 | const llvm::APSInt& V, |
| 60 | const llvm::APSInt& Adjustment) = 0; |
Ted Kremenek | 4502195 | 2009-02-14 17:08:39 +0000 | [diff] [blame] | 61 | |
Ted Kremenek | 28f47b9 | 2010-12-01 22:16:56 +0000 | [diff] [blame] | 62 | virtual const GRState *assumeSymLT(const GRState *state, SymbolRef sym, |
Jordy Rose | ba0f61c | 2010-06-18 22:49:11 +0000 | [diff] [blame] | 63 | const llvm::APSInt& V, |
| 64 | const llvm::APSInt& Adjustment) = 0; |
Ted Kremenek | 4502195 | 2009-02-14 17:08:39 +0000 | [diff] [blame] | 65 | |
Ted Kremenek | 28f47b9 | 2010-12-01 22:16:56 +0000 | [diff] [blame] | 66 | virtual const GRState *assumeSymGT(const GRState *state, SymbolRef sym, |
Jordy Rose | ba0f61c | 2010-06-18 22:49:11 +0000 | [diff] [blame] | 67 | const llvm::APSInt& V, |
| 68 | const llvm::APSInt& Adjustment) = 0; |
Ted Kremenek | 4502195 | 2009-02-14 17:08:39 +0000 | [diff] [blame] | 69 | |
Ted Kremenek | 28f47b9 | 2010-12-01 22:16:56 +0000 | [diff] [blame] | 70 | virtual const GRState *assumeSymLE(const GRState *state, SymbolRef sym, |
Jordy Rose | ba0f61c | 2010-06-18 22:49:11 +0000 | [diff] [blame] | 71 | const llvm::APSInt& V, |
| 72 | const llvm::APSInt& Adjustment) = 0; |
Ted Kremenek | 4502195 | 2009-02-14 17:08:39 +0000 | [diff] [blame] | 73 | |
Ted Kremenek | 28f47b9 | 2010-12-01 22:16:56 +0000 | [diff] [blame] | 74 | virtual const GRState *assumeSymGE(const GRState *state, SymbolRef sym, |
Jordy Rose | ba0f61c | 2010-06-18 22:49:11 +0000 | [diff] [blame] | 75 | const llvm::APSInt& V, |
| 76 | const llvm::APSInt& Adjustment) = 0; |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 77 | |
Ted Kremenek | a591bc0 | 2009-06-18 22:57:13 +0000 | [diff] [blame] | 78 | //===------------------------------------------------------------------===// |
| 79 | // Internal implementation. |
| 80 | //===------------------------------------------------------------------===// |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 81 | |
Ted Kremenek | 28f47b9 | 2010-12-01 22:16:56 +0000 | [diff] [blame] | 82 | const GRState *assumeAux(const GRState *state, Loc Cond,bool Assumption); |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 83 | |
Ted Kremenek | 28f47b9 | 2010-12-01 22:16:56 +0000 | [diff] [blame] | 84 | const GRState *assumeAux(const GRState *state, NonLoc Cond, bool Assumption); |
Ted Kremenek | 4502195 | 2009-02-14 17:08:39 +0000 | [diff] [blame] | 85 | }; |
| 86 | |
| 87 | } // end clang namespace |
| 88 | |
Ted Kremenek | 669c0e1 | 2009-02-15 18:24:51 +0000 | [diff] [blame] | 89 | #endif |