blob: 1e1a10da030fc3e80ce1847c1eb898bc47c381f7 [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 {
Ted Kremenek45021952009-02-14 17:08:39 +000023public:
Ted Kremenekf1b82272009-06-18 23:20:05 +000024 SimpleConstraintManager() {}
25 virtual ~SimpleConstraintManager();
Ted Kremenek66b52712009-03-11 02:22:59 +000026
Ted Kremeneka591bc02009-06-18 22:57:13 +000027 //===------------------------------------------------------------------===//
28 // Common implementation for the interface provided by ConstraintManager.
29 //===------------------------------------------------------------------===//
Ted Kremenekf1b82272009-06-18 23:20:05 +000030
31 bool canReasonAbout(SVal X) const;
32
33 const GRState *Assume(const GRState *state, SVal Cond, bool Assumption);
34
Ted Kremeneka591bc02009-06-18 22:57:13 +000035 const GRState *Assume(const GRState *state, Loc Cond, bool Assumption);
Ted Kremenek45021952009-02-14 17:08:39 +000036
Ted Kremeneka591bc02009-06-18 22:57:13 +000037 const GRState *Assume(const GRState *state, NonLoc Cond, bool Assumption);
Ted Kremenek45021952009-02-14 17:08:39 +000038
Ted Kremeneka591bc02009-06-18 22:57:13 +000039 const GRState *AssumeSymInt(const GRState *state, bool Assumption,
40 const SymIntExpr *SE);
41
42 const GRState *AssumeInBound(const GRState *state, SVal Idx, SVal UpperBound,
43 bool Assumption);
44
45protected:
46
47 //===------------------------------------------------------------------===//
48 // Interface that subclasses must implement.
49 //===------------------------------------------------------------------===//
50
51 virtual const GRState *AssumeSymNE(const GRState *state, SymbolRef sym,
52 const llvm::APSInt& V) = 0;
Ted Kremenek45021952009-02-14 17:08:39 +000053
Ted Kremeneka591bc02009-06-18 22:57:13 +000054 virtual const GRState *AssumeSymEQ(const GRState *state, SymbolRef sym,
55 const llvm::APSInt& V) = 0;
Ted Kremenek45021952009-02-14 17:08:39 +000056
Ted Kremeneka591bc02009-06-18 22:57:13 +000057 virtual const GRState *AssumeSymLT(const GRState *state, SymbolRef sym,
58 const llvm::APSInt& V) = 0;
Ted Kremenek45021952009-02-14 17:08:39 +000059
Ted Kremeneka591bc02009-06-18 22:57:13 +000060 virtual const GRState *AssumeSymGT(const GRState *state, SymbolRef sym,
61 const llvm::APSInt& V) = 0;
Ted Kremenek45021952009-02-14 17:08:39 +000062
Ted Kremeneka591bc02009-06-18 22:57:13 +000063 virtual const GRState *AssumeSymLE(const GRState *state, SymbolRef sym,
64 const llvm::APSInt& V) = 0;
Ted Kremenek45021952009-02-14 17:08:39 +000065
Ted Kremeneka591bc02009-06-18 22:57:13 +000066 virtual const GRState *AssumeSymGE(const GRState *state, SymbolRef sym,
67 const llvm::APSInt& V) = 0;
68
69 //===------------------------------------------------------------------===//
70 // Internal implementation.
71 //===------------------------------------------------------------------===//
72
73 const GRState *AssumeAux(const GRState *state, Loc Cond,bool Assumption);
74
75 const GRState *AssumeAux(const GRState *state, NonLoc Cond, bool Assumption);
Ted Kremenek45021952009-02-14 17:08:39 +000076};
77
78} // end clang namespace
79
Ted Kremenek669c0e12009-02-15 18:24:51 +000080#endif