]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - lib/Checker/SimpleConstraintManager.h
Update clang to r96341.
[FreeBSD/FreeBSD.git] / lib / Checker / SimpleConstraintManager.h
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/Checker/PathSensitive/ConstraintManager.h"
18 #include "clang/Checker/PathSensitive/GRState.h"
19
20 namespace clang {
21
22 class SimpleConstraintManager : public ConstraintManager {
23   GRSubEngine &SU;
24 public:
25   SimpleConstraintManager(GRSubEngine &subengine) : SU(subengine) {}
26   virtual ~SimpleConstraintManager();
27
28   //===------------------------------------------------------------------===//
29   // Common implementation for the interface provided by ConstraintManager.
30   //===------------------------------------------------------------------===//
31
32   bool canReasonAbout(SVal X) const;
33
34   const GRState *Assume(const GRState *state, DefinedSVal Cond,
35                         bool Assumption);
36
37   const GRState *Assume(const GRState *state, Loc Cond, bool Assumption);
38
39   const GRState *Assume(const GRState *state, NonLoc Cond, bool Assumption);
40
41   const GRState *AssumeSymInt(const GRState *state, bool Assumption,
42                               const SymIntExpr *SE);
43
44   const GRState *AssumeInBound(const GRState *state, DefinedSVal Idx,
45                                DefinedSVal UpperBound,
46                                bool Assumption);
47
48 protected:
49
50   //===------------------------------------------------------------------===//
51   // Interface that subclasses must implement.
52   //===------------------------------------------------------------------===//
53
54   virtual const GRState *AssumeSymNE(const GRState *state, SymbolRef sym,
55                                      const llvm::APSInt& V) = 0;
56
57   virtual const GRState *AssumeSymEQ(const GRState *state, SymbolRef sym,
58                                      const llvm::APSInt& V) = 0;
59
60   virtual const GRState *AssumeSymLT(const GRState *state, SymbolRef sym,
61                                      const llvm::APSInt& V) = 0;
62
63   virtual const GRState *AssumeSymGT(const GRState *state, SymbolRef sym,
64                                      const llvm::APSInt& V) = 0;
65
66   virtual const GRState *AssumeSymLE(const GRState *state, SymbolRef sym,
67                                      const llvm::APSInt& V) = 0;
68
69   virtual const GRState *AssumeSymGE(const GRState *state, SymbolRef sym,
70                                      const llvm::APSInt& V) = 0;
71
72   //===------------------------------------------------------------------===//
73   // Internal implementation.
74   //===------------------------------------------------------------------===//
75
76   const GRState *AssumeAux(const GRState *state, Loc Cond,bool Assumption);
77
78   const GRState *AssumeAux(const GRState *state, NonLoc Cond, bool Assumption);
79 };
80
81 }  // end clang namespace
82
83 #endif