/Users/buildslave/jenkins/sharedspace/clang-stage2-coverage-R@2/llvm/tools/clang/lib/StaticAnalyzer/Core/SimpleConstraintManager.h
Line | Count | Source |
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_LIB_STATICANALYZER_CORE_SIMPLECONSTRAINTMANAGER_H |
15 | | #define LLVM_CLANG_LIB_STATICANALYZER_CORE_SIMPLECONSTRAINTMANAGER_H |
16 | | |
17 | | #include "clang/StaticAnalyzer/Core/PathSensitive/ConstraintManager.h" |
18 | | #include "clang/StaticAnalyzer/Core/PathSensitive/ProgramState.h" |
19 | | |
20 | | namespace clang { |
21 | | |
22 | | namespace ento { |
23 | | |
24 | | class SimpleConstraintManager : public ConstraintManager { |
25 | | SubEngine *SU; |
26 | | SValBuilder &SVB; |
27 | | |
28 | | public: |
29 | 6.67k | SimpleConstraintManager(SubEngine *SE, SValBuilder &SB) : SU(SE), SVB(SB) {} |
30 | | ~SimpleConstraintManager() override; |
31 | | |
32 | | //===------------------------------------------------------------------===// |
33 | | // Common implementation for the interface provided by ConstraintManager. |
34 | | //===------------------------------------------------------------------===// |
35 | | |
36 | | ProgramStateRef assume(ProgramStateRef State, DefinedSVal Cond, |
37 | | bool Assumption) override; |
38 | | |
39 | | ProgramStateRef assume(ProgramStateRef State, NonLoc Cond, bool Assumption); |
40 | | |
41 | | ProgramStateRef assumeInclusiveRange(ProgramStateRef State, NonLoc Value, |
42 | | const llvm::APSInt &From, |
43 | | const llvm::APSInt &To, |
44 | | bool InRange) override; |
45 | | |
46 | | ProgramStateRef assumeSymRel(ProgramStateRef State, const SymExpr *LHS, |
47 | | BinaryOperator::Opcode Op, |
48 | | const llvm::APSInt &Int); |
49 | | |
50 | | ProgramStateRef assumeSymWithinInclusiveRange(ProgramStateRef State, |
51 | | SymbolRef Sym, |
52 | | const llvm::APSInt &From, |
53 | | const llvm::APSInt &To, |
54 | | bool InRange); |
55 | | |
56 | | protected: |
57 | | //===------------------------------------------------------------------===// |
58 | | // Interface that subclasses must implement. |
59 | | //===------------------------------------------------------------------===// |
60 | | |
61 | | // Each of these is of the form "$Sym+Adj <> V", where "<>" is the comparison |
62 | | // operation for the method being invoked. |
63 | | virtual ProgramStateRef assumeSymNE(ProgramStateRef State, SymbolRef Sym, |
64 | | const llvm::APSInt &V, |
65 | | const llvm::APSInt &Adjustment) = 0; |
66 | | |
67 | | virtual ProgramStateRef assumeSymEQ(ProgramStateRef State, SymbolRef Sym, |
68 | | const llvm::APSInt &V, |
69 | | const llvm::APSInt &Adjustment) = 0; |
70 | | |
71 | | virtual ProgramStateRef assumeSymLT(ProgramStateRef State, SymbolRef Sym, |
72 | | const llvm::APSInt &V, |
73 | | const llvm::APSInt &Adjustment) = 0; |
74 | | |
75 | | virtual ProgramStateRef assumeSymGT(ProgramStateRef State, SymbolRef Sym, |
76 | | const llvm::APSInt &V, |
77 | | const llvm::APSInt &Adjustment) = 0; |
78 | | |
79 | | virtual ProgramStateRef assumeSymLE(ProgramStateRef State, SymbolRef Sym, |
80 | | const llvm::APSInt &V, |
81 | | const llvm::APSInt &Adjustment) = 0; |
82 | | |
83 | | virtual ProgramStateRef assumeSymGE(ProgramStateRef State, SymbolRef Sym, |
84 | | const llvm::APSInt &V, |
85 | | const llvm::APSInt &Adjustment) = 0; |
86 | | |
87 | | virtual ProgramStateRef assumeSymbolWithinInclusiveRange( |
88 | | ProgramStateRef State, SymbolRef Sym, const llvm::APSInt &From, |
89 | | const llvm::APSInt &To, const llvm::APSInt &Adjustment) = 0; |
90 | | |
91 | | virtual ProgramStateRef assumeSymbolOutOfInclusiveRange( |
92 | | ProgramStateRef State, SymbolRef Sym, const llvm::APSInt &From, |
93 | | const llvm::APSInt &To, const llvm::APSInt &Adjustment) = 0; |
94 | | |
95 | | //===------------------------------------------------------------------===// |
96 | | // Internal implementation. |
97 | | //===------------------------------------------------------------------===// |
98 | | |
99 | 257k | BasicValueFactory &getBasicVals() const { return SVB.getBasicValueFactory(); } |
100 | 425 | SymbolManager &getSymbolManager() const { return SVB.getSymbolManager(); } |
101 | | |
102 | | bool canReasonAbout(SVal X) const override; |
103 | | |
104 | | ProgramStateRef assumeAux(ProgramStateRef State, NonLoc Cond, |
105 | | bool Assumption); |
106 | | |
107 | | ProgramStateRef assumeAuxForSymbol(ProgramStateRef State, SymbolRef Sym, |
108 | | bool Assumption); |
109 | | }; |
110 | | |
111 | | } // end GR namespace |
112 | | |
113 | | } // end clang namespace |
114 | | |
115 | | #endif |