1 //== SimpleConstraintManager.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 // Code shared between BasicConstraintManager and RangeConstraintManager.
12 //===----------------------------------------------------------------------===//
14 #ifndef LLVM_CLANG_LIB_STATICANALYZER_CORE_SIMPLECONSTRAINTMANAGER_H
15 #define LLVM_CLANG_LIB_STATICANALYZER_CORE_SIMPLECONSTRAINTMANAGER_H
17 #include "clang/StaticAnalyzer/Core/PathSensitive/ConstraintManager.h"
18 #include "clang/StaticAnalyzer/Core/PathSensitive/ProgramState.h"
24 class SimpleConstraintManager : public ConstraintManager {
29 SimpleConstraintManager(SubEngine *SE, SValBuilder &SB) : SU(SE), SVB(SB) {}
30 ~SimpleConstraintManager() override;
32 //===------------------------------------------------------------------===//
33 // Common implementation for the interface provided by ConstraintManager.
34 //===------------------------------------------------------------------===//
36 ProgramStateRef assume(ProgramStateRef State, DefinedSVal Cond,
37 bool Assumption) override;
39 ProgramStateRef assume(ProgramStateRef State, NonLoc Cond, bool Assumption);
41 ProgramStateRef assumeInclusiveRange(ProgramStateRef State, NonLoc Value,
42 const llvm::APSInt &From,
43 const llvm::APSInt &To,
44 bool InRange) override;
46 ProgramStateRef assumeSymRel(ProgramStateRef State, const SymExpr *LHS,
47 BinaryOperator::Opcode Op,
48 const llvm::APSInt &Int);
50 ProgramStateRef assumeSymWithinInclusiveRange(ProgramStateRef State,
52 const llvm::APSInt &From,
53 const llvm::APSInt &To,
57 //===------------------------------------------------------------------===//
58 // Interface that subclasses must implement.
59 //===------------------------------------------------------------------===//
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;
67 virtual ProgramStateRef assumeSymEQ(ProgramStateRef State, SymbolRef Sym,
68 const llvm::APSInt &V,
69 const llvm::APSInt &Adjustment) = 0;
71 virtual ProgramStateRef assumeSymLT(ProgramStateRef State, SymbolRef Sym,
72 const llvm::APSInt &V,
73 const llvm::APSInt &Adjustment) = 0;
75 virtual ProgramStateRef assumeSymGT(ProgramStateRef State, SymbolRef Sym,
76 const llvm::APSInt &V,
77 const llvm::APSInt &Adjustment) = 0;
79 virtual ProgramStateRef assumeSymLE(ProgramStateRef State, SymbolRef Sym,
80 const llvm::APSInt &V,
81 const llvm::APSInt &Adjustment) = 0;
83 virtual ProgramStateRef assumeSymGE(ProgramStateRef State, SymbolRef Sym,
84 const llvm::APSInt &V,
85 const llvm::APSInt &Adjustment) = 0;
87 virtual ProgramStateRef assumeSymbolWithinInclusiveRange(
88 ProgramStateRef State, SymbolRef Sym, const llvm::APSInt &From,
89 const llvm::APSInt &To, const llvm::APSInt &Adjustment) = 0;
91 virtual ProgramStateRef assumeSymbolOutOfInclusiveRange(
92 ProgramStateRef State, SymbolRef Sym, const llvm::APSInt &From,
93 const llvm::APSInt &To, const llvm::APSInt &Adjustment) = 0;
95 //===------------------------------------------------------------------===//
96 // Internal implementation.
97 //===------------------------------------------------------------------===//
99 BasicValueFactory &getBasicVals() const { return SVB.getBasicValueFactory(); }
100 SymbolManager &getSymbolManager() const { return SVB.getSymbolManager(); }
102 bool canReasonAbout(SVal X) const override;
104 ProgramStateRef assumeAux(ProgramStateRef State, NonLoc Cond,
107 ProgramStateRef assumeAuxForSymbol(ProgramStateRef State, SymbolRef Sym,
111 } // end GR namespace
113 } // end clang namespace