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 {
28 SimpleConstraintManager(SubEngine *subengine, SValBuilder &SB)
29 : SU(subengine), 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 assumeWithinInclusiveRange(ProgramStateRef State,
43 const llvm::APSInt &From,
44 const llvm::APSInt &To,
45 bool InRange) override;
47 ProgramStateRef assumeSymRel(ProgramStateRef state,
49 BinaryOperator::Opcode op,
50 const llvm::APSInt& Int);
52 ProgramStateRef assumeSymWithinInclusiveRange(ProgramStateRef State,
54 const llvm::APSInt &From,
55 const llvm::APSInt &To,
61 //===------------------------------------------------------------------===//
62 // Interface that subclasses must implement.
63 //===------------------------------------------------------------------===//
65 // Each of these is of the form "$sym+Adj <> V", where "<>" is the comparison
66 // operation for the method being invoked.
67 virtual ProgramStateRef assumeSymNE(ProgramStateRef state, SymbolRef sym,
68 const llvm::APSInt& V,
69 const llvm::APSInt& Adjustment) = 0;
71 virtual ProgramStateRef assumeSymEQ(ProgramStateRef state, SymbolRef sym,
72 const llvm::APSInt& V,
73 const llvm::APSInt& Adjustment) = 0;
75 virtual ProgramStateRef assumeSymLT(ProgramStateRef state, SymbolRef sym,
76 const llvm::APSInt& V,
77 const llvm::APSInt& Adjustment) = 0;
79 virtual ProgramStateRef assumeSymGT(ProgramStateRef state, SymbolRef sym,
80 const llvm::APSInt& V,
81 const llvm::APSInt& Adjustment) = 0;
83 virtual ProgramStateRef assumeSymLE(ProgramStateRef state, SymbolRef sym,
84 const llvm::APSInt& V,
85 const llvm::APSInt& Adjustment) = 0;
87 virtual ProgramStateRef assumeSymGE(ProgramStateRef state, SymbolRef sym,
88 const llvm::APSInt& V,
89 const llvm::APSInt& Adjustment) = 0;
92 virtual ProgramStateRef assumeSymbolWithinInclusiveRange(
93 ProgramStateRef State, SymbolRef Sym, const llvm::APSInt &From,
94 const llvm::APSInt &To, const llvm::APSInt &Adjustment) = 0;
96 virtual ProgramStateRef assumeSymbolOutOfInclusiveRange(
97 ProgramStateRef state, SymbolRef Sym, const llvm::APSInt &From,
98 const llvm::APSInt &To, const llvm::APSInt &Adjustment) = 0;
99 //===------------------------------------------------------------------===//
100 // Internal implementation.
101 //===------------------------------------------------------------------===//
103 BasicValueFactory &getBasicVals() const { return SVB.getBasicValueFactory(); }
104 SymbolManager &getSymbolManager() const { return SVB.getSymbolManager(); }
106 bool canReasonAbout(SVal X) const override;
108 ProgramStateRef assumeAux(ProgramStateRef state,
112 ProgramStateRef assumeAuxForSymbol(ProgramStateRef State,
117 } // end GR namespace
119 } // end clang namespace