]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - include/clang/Checker/PathSensitive/ConstraintManager.h
Update clang to r94309.
[FreeBSD/FreeBSD.git] / include / clang / Checker / PathSensitive / ConstraintManager.h
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_ANALYSIS_CONSTRAINT_MANAGER_H
15 #define LLVM_CLANG_ANALYSIS_CONSTRAINT_MANAGER_H
16
17 // FIXME: Typedef LiveSymbolsTy/DeadSymbolsTy at a more appropriate place.
18 #include "clang/Checker/PathSensitive/Store.h"
19
20 namespace llvm {
21 class APSInt;
22 }
23
24 namespace clang {
25
26 class GRState;
27 class GRStateManager;
28 class GRSubEngine;
29 class SVal;
30
31 class ConstraintManager {
32 public:
33   virtual ~ConstraintManager();
34   virtual const GRState *Assume(const GRState *state, DefinedSVal Cond,
35                                 bool Assumption) = 0;
36
37   virtual const GRState *AssumeInBound(const GRState *state, DefinedSVal Idx,
38                                        DefinedSVal UpperBound, bool Assumption) = 0;
39
40   std::pair<const GRState*, const GRState*> AssumeDual(const GRState *state,
41                                                        DefinedSVal Cond) {
42     return std::make_pair(Assume(state, Cond, true),
43                           Assume(state, Cond, false));
44   }
45
46   virtual const llvm::APSInt* getSymVal(const GRState *state,
47                                         SymbolRef sym) const = 0;
48
49   virtual bool isEqual(const GRState *state, SymbolRef sym,
50                        const llvm::APSInt& V) const = 0;
51
52   virtual const GRState *RemoveDeadBindings(const GRState *state,
53                                             SymbolReaper& SymReaper) = 0;
54
55   virtual void print(const GRState *state, llvm::raw_ostream& Out,
56                      const char* nl, const char *sep) = 0;
57
58   virtual void EndPath(const GRState *state) {}
59
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;
66 };
67
68 ConstraintManager* CreateBasicConstraintManager(GRStateManager& statemgr,
69                                                 GRSubEngine &subengine);
70 ConstraintManager* CreateRangeConstraintManager(GRStateManager& statemgr,
71                                                 GRSubEngine &subengine);
72
73 } // end clang namespace
74
75 #endif