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_GR_SIMPLE_CONSTRAINT_MANAGER_H
15 #define LLVM_CLANG_GR_SIMPLE_CONSTRAINT_MANAGER_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 virtual ~SimpleConstraintManager();
32 //===------------------------------------------------------------------===//
33 // Common implementation for the interface provided by ConstraintManager.
34 //===------------------------------------------------------------------===//
36 ProgramStateRef assume(ProgramStateRef state, DefinedSVal Cond,
39 ProgramStateRef assume(ProgramStateRef state, NonLoc Cond, bool Assumption);
41 ProgramStateRef assumeSymRel(ProgramStateRef state,
43 BinaryOperator::Opcode op,
44 const llvm::APSInt& Int);
48 //===------------------------------------------------------------------===//
49 // Interface that subclasses must implement.
50 //===------------------------------------------------------------------===//
52 // Each of these is of the form "$sym+Adj <> V", where "<>" is the comparison
53 // operation for the method being invoked.
54 virtual ProgramStateRef assumeSymNE(ProgramStateRef state, SymbolRef sym,
55 const llvm::APSInt& V,
56 const llvm::APSInt& Adjustment) = 0;
58 virtual ProgramStateRef assumeSymEQ(ProgramStateRef state, SymbolRef sym,
59 const llvm::APSInt& V,
60 const llvm::APSInt& Adjustment) = 0;
62 virtual ProgramStateRef assumeSymLT(ProgramStateRef state, SymbolRef sym,
63 const llvm::APSInt& V,
64 const llvm::APSInt& Adjustment) = 0;
66 virtual ProgramStateRef assumeSymGT(ProgramStateRef state, SymbolRef sym,
67 const llvm::APSInt& V,
68 const llvm::APSInt& Adjustment) = 0;
70 virtual ProgramStateRef assumeSymLE(ProgramStateRef state, SymbolRef sym,
71 const llvm::APSInt& V,
72 const llvm::APSInt& Adjustment) = 0;
74 virtual ProgramStateRef assumeSymGE(ProgramStateRef state, SymbolRef sym,
75 const llvm::APSInt& V,
76 const llvm::APSInt& Adjustment) = 0;
78 //===------------------------------------------------------------------===//
79 // Internal implementation.
80 //===------------------------------------------------------------------===//
82 BasicValueFactory &getBasicVals() const { return SVB.getBasicValueFactory(); }
83 SymbolManager &getSymbolManager() const { return SVB.getSymbolManager(); }
85 bool canReasonAbout(SVal X) const;
87 ProgramStateRef assumeAux(ProgramStateRef state,
91 ProgramStateRef assumeAuxForSymbol(ProgramStateRef State,
98 } // end clang namespace