1 //== ConstraintManager.h - Constraints on symbolic values.-------*- 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 // This file defined the interface to manage constraints on symbolic values. 11 // 12 //===----------------------------------------------------------------------===// 13 14 #ifndef LLVM_CLANG_GR_CONSTRAINT_MANAGER_H 15 #define LLVM_CLANG_GR_CONSTRAINT_MANAGER_H 16 17 // FIXME: Typedef LiveSymbolsTy/DeadSymbolsTy at a more appropriate place. 18 #include "clang/StaticAnalyzer/Core/PathSensitive/Store.h" 19 20 namespace llvm { 21 class APSInt; 22 } 23 24 namespace clang { 25 26 namespace ento { 27 28 class GRState; 29 class GRStateManager; 30 class SubEngine; 31 class SVal; 32 33 class ConstraintManager { 34 public: 35 virtual ~ConstraintManager(); 36 virtual const GRState *assume(const GRState *state, DefinedSVal Cond, 37 bool Assumption) = 0; 38 assumeDual(const GRState * state,DefinedSVal Cond)39 std::pair<const GRState*, const GRState*> assumeDual(const GRState *state, 40 DefinedSVal Cond) { 41 return std::make_pair(assume(state, Cond, true), 42 assume(state, Cond, false)); 43 } 44 45 virtual const llvm::APSInt* getSymVal(const GRState *state, 46 SymbolRef sym) const = 0; 47 48 virtual bool isEqual(const GRState *state, SymbolRef sym, 49 const llvm::APSInt& V) const = 0; 50 51 virtual const GRState *removeDeadBindings(const GRState *state, 52 SymbolReaper& SymReaper) = 0; 53 54 virtual void print(const GRState *state, llvm::raw_ostream& Out, 55 const char* nl, const char *sep) = 0; 56 EndPath(const GRState * state)57 virtual void EndPath(const GRState *state) {} 58 59 /// canReasonAbout - Not all ConstraintManagers can accurately reason about 60 /// all SVal values. This method returns true if the ConstraintManager can 61 /// reasonably handle a given SVal value. This is typically queried by 62 /// ExprEngine to determine if the value should be replaced with a 63 /// conjured symbolic value in order to recover some precision. 64 virtual bool canReasonAbout(SVal X) const = 0; 65 }; 66 67 ConstraintManager* CreateBasicConstraintManager(GRStateManager& statemgr, 68 SubEngine &subengine); 69 ConstraintManager* CreateRangeConstraintManager(GRStateManager& statemgr, 70 SubEngine &subengine); 71 72 } // end GR namespace 73 74 } // end clang namespace 75 76 #endif 77