1 //== ConstraintManager.h - Constraints on symbolic values.-------*- C++ -*--==//
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
10 // This file defined the interface to manage constraints on symbolic values.
12 //===----------------------------------------------------------------------===//
14 #ifndef LLVM_CLANG_ANALYSIS_CONSTRAINT_MANAGER_H
15 #define LLVM_CLANG_ANALYSIS_CONSTRAINT_MANAGER_H
17 // FIXME: Typedef LiveSymbolsTy/DeadSymbolsTy at a more appropriate place.
18 #include "clang/Checker/PathSensitive/Store.h"
31 class ConstraintManager {
33 virtual ~ConstraintManager();
34 virtual const GRState *Assume(const GRState *state, DefinedSVal Cond,
37 virtual const GRState *AssumeInBound(const GRState *state, DefinedSVal Idx,
38 DefinedSVal UpperBound, bool Assumption) = 0;
40 std::pair<const GRState*, const GRState*> AssumeDual(const GRState *state,
42 return std::make_pair(Assume(state, Cond, true),
43 Assume(state, Cond, false));
46 virtual const llvm::APSInt* getSymVal(const GRState *state,
47 SymbolRef sym) const = 0;
49 virtual bool isEqual(const GRState *state, SymbolRef sym,
50 const llvm::APSInt& V) const = 0;
52 virtual const GRState *RemoveDeadBindings(const GRState *state,
53 SymbolReaper& SymReaper) = 0;
55 virtual void print(const GRState *state, llvm::raw_ostream& Out,
56 const char* nl, const char *sep) = 0;
58 virtual void EndPath(const GRState *state) {}
60 /// canReasonAbout - Not all ConstraintManagers can accurately reason about
61 /// all SVal values. This method returns true if the ConstraintManager can
62 /// reasonably handle a given SVal value. This is typically queried by
63 /// GRExprEngine to determine if the value should be replaced with a
64 /// conjured symbolic value in order to recover some precision.
65 virtual bool canReasonAbout(SVal X) const = 0;
68 ConstraintManager* CreateBasicConstraintManager(GRStateManager& statemgr,
69 GRSubEngine &subengine);
70 ConstraintManager* CreateRangeConstraintManager(GRStateManager& statemgr,
71 GRSubEngine &subengine);
73 } // end clang namespace