]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - contrib/llvm/tools/clang/lib/StaticAnalyzer/Core/RangedConstraintManager.h
MFC r343918: Teach /etc/rc.d/growfs how to handle systems running ZFS.
[FreeBSD/FreeBSD.git] / contrib / llvm / tools / clang / lib / StaticAnalyzer / Core / RangedConstraintManager.h
1 //== RangedConstraintManager.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 //  Ranged constraint manager, built on SimpleConstraintManager.
11 //
12 //===----------------------------------------------------------------------===//
13
14 #ifndef LLVM_CLANG_LIB_STATICANALYZER_CORE_RANGEDCONSTRAINTMANAGER_H
15 #define LLVM_CLANG_LIB_STATICANALYZER_CORE_RANGEDCONSTRAINTMANAGER_H
16
17 #include "clang/StaticAnalyzer/Core/PathSensitive/ProgramState.h"
18 #include "clang/StaticAnalyzer/Core/PathSensitive/SimpleConstraintManager.h"
19
20 namespace clang {
21
22 namespace ento {
23
24 class RangedConstraintManager : public SimpleConstraintManager {
25 public:
26   RangedConstraintManager(SubEngine *SE, SValBuilder &SB)
27       : SimpleConstraintManager(SE, SB) {}
28
29   ~RangedConstraintManager() override;
30
31   //===------------------------------------------------------------------===//
32   // Implementation for interface from SimpleConstraintManager.
33   //===------------------------------------------------------------------===//
34
35   ProgramStateRef assumeSym(ProgramStateRef State, SymbolRef Sym,
36                             bool Assumption) override;
37
38   ProgramStateRef assumeSymInclusiveRange(ProgramStateRef State, SymbolRef Sym,
39                                           const llvm::APSInt &From,
40                                           const llvm::APSInt &To,
41                                           bool InRange) override;
42
43   ProgramStateRef assumeSymUnsupported(ProgramStateRef State, SymbolRef Sym,
44                                        bool Assumption) override;
45
46 protected:
47   /// Assume a constraint between a symbolic expression and a concrete integer.
48   virtual ProgramStateRef assumeSymRel(ProgramStateRef State, SymbolRef Sym,
49                                BinaryOperator::Opcode op,
50                                const llvm::APSInt &Int);
51
52   //===------------------------------------------------------------------===//
53   // Interface that subclasses must implement.
54   //===------------------------------------------------------------------===//
55
56   // Each of these is of the form "$Sym+Adj <> V", where "<>" is the comparison
57   // operation for the method being invoked.
58
59   virtual ProgramStateRef assumeSymNE(ProgramStateRef State, SymbolRef Sym,
60                                       const llvm::APSInt &V,
61                                       const llvm::APSInt &Adjustment) = 0;
62
63   virtual ProgramStateRef assumeSymEQ(ProgramStateRef State, SymbolRef Sym,
64                                       const llvm::APSInt &V,
65                                       const llvm::APSInt &Adjustment) = 0;
66
67   virtual ProgramStateRef assumeSymLT(ProgramStateRef State, SymbolRef Sym,
68                                       const llvm::APSInt &V,
69                                       const llvm::APSInt &Adjustment) = 0;
70
71   virtual ProgramStateRef assumeSymGT(ProgramStateRef State, SymbolRef Sym,
72                                       const llvm::APSInt &V,
73                                       const llvm::APSInt &Adjustment) = 0;
74
75   virtual ProgramStateRef assumeSymLE(ProgramStateRef State, SymbolRef Sym,
76                                       const llvm::APSInt &V,
77                                       const llvm::APSInt &Adjustment) = 0;
78
79   virtual ProgramStateRef assumeSymGE(ProgramStateRef State, SymbolRef Sym,
80                                       const llvm::APSInt &V,
81                                       const llvm::APSInt &Adjustment) = 0;
82
83   virtual ProgramStateRef assumeSymWithinInclusiveRange(
84       ProgramStateRef State, SymbolRef Sym, const llvm::APSInt &From,
85       const llvm::APSInt &To, const llvm::APSInt &Adjustment) = 0;
86
87   virtual ProgramStateRef assumeSymOutsideInclusiveRange(
88       ProgramStateRef State, SymbolRef Sym, const llvm::APSInt &From,
89       const llvm::APSInt &To, const llvm::APSInt &Adjustment) = 0;
90
91   //===------------------------------------------------------------------===//
92   // Internal implementation.
93   //===------------------------------------------------------------------===//
94 private:
95   static void computeAdjustment(SymbolRef &Sym, llvm::APSInt &Adjustment);
96 };
97
98 } // end GR namespace
99
100 } // end clang namespace
101
102 #endif