blob: bd18b6af93121ddd044ffcec6f3355f0c23b1fae [file] [log] [blame]
Ted Kremenek45021952009-02-14 17:08:39 +00001//== SimpleConstraintManager.h ----------------------------------*- C++ -*--==//
2//
3// The LLVM Compiler Infrastructure
4//
5// This file is distributed under the University of Illinois Open Source
6// License. See LICENSE.TXT for details.
7//
8//===----------------------------------------------------------------------===//
9//
10// Code shared between BasicConstraintManager and RangeConstraintManager.
11//
12//===----------------------------------------------------------------------===//
13
14#ifndef LLVM_CLANG_ANALYSIS_SIMPLE_CONSTRAINT_MANAGER_H
15#define LLVM_CLANG_ANALYSIS_SIMPLE_CONSTRAINT_MANAGER_H
16
17#include "clang/Analysis/PathSensitive/ConstraintManager.h"
18#include "clang/Analysis/PathSensitive/GRState.h"
19
20namespace clang {
21
22class SimpleConstraintManager : public ConstraintManager {
23protected:
24 GRStateManager& StateMgr;
25public:
26 SimpleConstraintManager(GRStateManager& statemgr)
27 : StateMgr(statemgr) {}
28 virtual ~SimpleConstraintManager();
Ted Kremenek66b52712009-03-11 02:22:59 +000029
30 bool canReasonAbout(SVal X) const;
31
Ted Kremeneka591bc02009-06-18 22:57:13 +000032 virtual const GRState *Assume(const GRState *state, SVal Cond,
33 bool Assumption);
Ted Kremenek45021952009-02-14 17:08:39 +000034
Ted Kremeneka591bc02009-06-18 22:57:13 +000035 //===------------------------------------------------------------------===//
36 // Common implementation for the interface provided by ConstraintManager.
37 //===------------------------------------------------------------------===//
38
39 const GRState *Assume(const GRState *state, Loc Cond, bool Assumption);
Ted Kremenek45021952009-02-14 17:08:39 +000040
Ted Kremeneka591bc02009-06-18 22:57:13 +000041 const GRState *Assume(const GRState *state, NonLoc Cond, bool Assumption);
Ted Kremenek45021952009-02-14 17:08:39 +000042
Ted Kremeneka591bc02009-06-18 22:57:13 +000043 const GRState *AssumeSymInt(const GRState *state, bool Assumption,
44 const SymIntExpr *SE);
45
46 const GRState *AssumeInBound(const GRState *state, SVal Idx, SVal UpperBound,
47 bool Assumption);
48
49protected:
50
51 //===------------------------------------------------------------------===//
52 // Interface that subclasses must implement.
53 //===------------------------------------------------------------------===//
54
55 virtual const GRState *AssumeSymNE(const GRState *state, SymbolRef sym,
56 const llvm::APSInt& V) = 0;
Ted Kremenek45021952009-02-14 17:08:39 +000057
Ted Kremeneka591bc02009-06-18 22:57:13 +000058 virtual const GRState *AssumeSymEQ(const GRState *state, SymbolRef sym,
59 const llvm::APSInt& V) = 0;
Ted Kremenek45021952009-02-14 17:08:39 +000060
Ted Kremeneka591bc02009-06-18 22:57:13 +000061 virtual const GRState *AssumeSymLT(const GRState *state, SymbolRef sym,
62 const llvm::APSInt& V) = 0;
Ted Kremenek45021952009-02-14 17:08:39 +000063
Ted Kremeneka591bc02009-06-18 22:57:13 +000064 virtual const GRState *AssumeSymGT(const GRState *state, SymbolRef sym,
65 const llvm::APSInt& V) = 0;
Ted Kremenek45021952009-02-14 17:08:39 +000066
Ted Kremeneka591bc02009-06-18 22:57:13 +000067 virtual const GRState *AssumeSymLE(const GRState *state, SymbolRef sym,
68 const llvm::APSInt& V) = 0;
Ted Kremenek45021952009-02-14 17:08:39 +000069
Ted Kremeneka591bc02009-06-18 22:57:13 +000070 virtual const GRState *AssumeSymGE(const GRState *state, SymbolRef sym,
71 const llvm::APSInt& V) = 0;
72
73 //===------------------------------------------------------------------===//
74 // Internal implementation.
75 //===------------------------------------------------------------------===//
76
77 const GRState *AssumeAux(const GRState *state, Loc Cond,bool Assumption);
78
79 const GRState *AssumeAux(const GRState *state, NonLoc Cond, bool Assumption);
Ted Kremenek45021952009-02-14 17:08:39 +000080
Ted Kremeneka591bc02009-06-18 22:57:13 +000081 //===------------------------------------------------------------------===//
82 // FIXME: These can probably be removed now.
83 //===------------------------------------------------------------------===//
Ted Kremenek45021952009-02-14 17:08:39 +000084
85private:
86 BasicValueFactory& getBasicVals() { return StateMgr.getBasicVals(); }
Zhongxing Xua129eb92009-03-25 05:58:37 +000087 SymbolManager& getSymbolManager() const { return StateMgr.getSymbolManager(); }
Ted Kremenek45021952009-02-14 17:08:39 +000088};
89
90} // end clang namespace
91
Ted Kremenek669c0e12009-02-15 18:24:51 +000092#endif