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_ANALYSIS_SIMPLE_CONSTRAINT_MANAGER_H
15 #define LLVM_CLANG_ANALYSIS_SIMPLE_CONSTRAINT_MANAGER_H
17 #include "clang/Checker/PathSensitive/ConstraintManager.h"
18 #include "clang/Checker/PathSensitive/GRState.h"
22 class SimpleConstraintManager
: public ConstraintManager
{
25 SimpleConstraintManager(GRSubEngine
&subengine
) : SU(subengine
) {}
26 virtual ~SimpleConstraintManager();
28 //===------------------------------------------------------------------===//
29 // Common implementation for the interface provided by ConstraintManager.
30 //===------------------------------------------------------------------===//
32 bool canReasonAbout(SVal X
) const;
34 const GRState
*Assume(const GRState
*state
, DefinedSVal Cond
,
37 const GRState
*Assume(const GRState
*state
, Loc Cond
, bool Assumption
);
39 const GRState
*Assume(const GRState
*state
, NonLoc Cond
, bool Assumption
);
41 const GRState
*AssumeSymRel(const GRState
*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 const GRState
*AssumeSymNE(const GRState
*state
, SymbolRef sym
,
55 const llvm::APSInt
& V
,
56 const llvm::APSInt
& Adjustment
) = 0;
58 virtual const GRState
*AssumeSymEQ(const GRState
*state
, SymbolRef sym
,
59 const llvm::APSInt
& V
,
60 const llvm::APSInt
& Adjustment
) = 0;
62 virtual const GRState
*AssumeSymLT(const GRState
*state
, SymbolRef sym
,
63 const llvm::APSInt
& V
,
64 const llvm::APSInt
& Adjustment
) = 0;
66 virtual const GRState
*AssumeSymGT(const GRState
*state
, SymbolRef sym
,
67 const llvm::APSInt
& V
,
68 const llvm::APSInt
& Adjustment
) = 0;
70 virtual const GRState
*AssumeSymLE(const GRState
*state
, SymbolRef sym
,
71 const llvm::APSInt
& V
,
72 const llvm::APSInt
& Adjustment
) = 0;
74 virtual const GRState
*AssumeSymGE(const GRState
*state
, SymbolRef sym
,
75 const llvm::APSInt
& V
,
76 const llvm::APSInt
& Adjustment
) = 0;
78 //===------------------------------------------------------------------===//
79 // Internal implementation.
80 //===------------------------------------------------------------------===//
82 const GRState
*AssumeAux(const GRState
*state
, Loc Cond
,bool Assumption
);
84 const GRState
*AssumeAux(const GRState
*state
, NonLoc Cond
, bool Assumption
);
87 } // end clang namespace