1 //== RangedConstraintManager.h ----------------------------------*- 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 // Ranged constraint manager, built on SimpleConstraintManager.
12 //===----------------------------------------------------------------------===//
14 #ifndef LLVM_CLANG_LIB_STATICANALYZER_CORE_RANGEDCONSTRAINTMANAGER_H
15 #define LLVM_CLANG_LIB_STATICANALYZER_CORE_RANGEDCONSTRAINTMANAGER_H
17 #include "clang/StaticAnalyzer/Core/PathSensitive/ProgramState.h"
18 #include "clang/StaticAnalyzer/Core/PathSensitive/SimpleConstraintManager.h"
24 class RangedConstraintManager : public SimpleConstraintManager {
26 RangedConstraintManager(SubEngine *SE, SValBuilder &SB)
27 : SimpleConstraintManager(SE, SB) {}
29 ~RangedConstraintManager() override;
31 //===------------------------------------------------------------------===//
32 // Implementation for interface from SimpleConstraintManager.
33 //===------------------------------------------------------------------===//
35 ProgramStateRef assumeSym(ProgramStateRef State, SymbolRef Sym,
36 bool Assumption) override;
38 ProgramStateRef assumeSymInclusiveRange(ProgramStateRef State, SymbolRef Sym,
39 const llvm::APSInt &From,
40 const llvm::APSInt &To,
41 bool InRange) override;
43 ProgramStateRef assumeSymUnsupported(ProgramStateRef State, SymbolRef Sym,
44 bool Assumption) override;
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);
52 //===------------------------------------------------------------------===//
53 // Interface that subclasses must implement.
54 //===------------------------------------------------------------------===//
56 // Each of these is of the form "$Sym+Adj <> V", where "<>" is the comparison
57 // operation for the method being invoked.
59 virtual ProgramStateRef assumeSymNE(ProgramStateRef State, SymbolRef Sym,
60 const llvm::APSInt &V,
61 const llvm::APSInt &Adjustment) = 0;
63 virtual ProgramStateRef assumeSymEQ(ProgramStateRef State, SymbolRef Sym,
64 const llvm::APSInt &V,
65 const llvm::APSInt &Adjustment) = 0;
67 virtual ProgramStateRef assumeSymLT(ProgramStateRef State, SymbolRef Sym,
68 const llvm::APSInt &V,
69 const llvm::APSInt &Adjustment) = 0;
71 virtual ProgramStateRef assumeSymGT(ProgramStateRef State, SymbolRef Sym,
72 const llvm::APSInt &V,
73 const llvm::APSInt &Adjustment) = 0;
75 virtual ProgramStateRef assumeSymLE(ProgramStateRef State, SymbolRef Sym,
76 const llvm::APSInt &V,
77 const llvm::APSInt &Adjustment) = 0;
79 virtual ProgramStateRef assumeSymGE(ProgramStateRef State, SymbolRef Sym,
80 const llvm::APSInt &V,
81 const llvm::APSInt &Adjustment) = 0;
83 virtual ProgramStateRef assumeSymWithinInclusiveRange(
84 ProgramStateRef State, SymbolRef Sym, const llvm::APSInt &From,
85 const llvm::APSInt &To, const llvm::APSInt &Adjustment) = 0;
87 virtual ProgramStateRef assumeSymOutsideInclusiveRange(
88 ProgramStateRef State, SymbolRef Sym, const llvm::APSInt &From,
89 const llvm::APSInt &To, const llvm::APSInt &Adjustment) = 0;
91 //===------------------------------------------------------------------===//
92 // Internal implementation.
93 //===------------------------------------------------------------------===//
95 static void computeAdjustment(SymbolRef &Sym, llvm::APSInt &Adjustment);
100 } // end clang namespace