blob: 0c58440ac0b6d0465a1e4697ec93684f433efa08 [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() {}
Mike Stump1eb44332009-09-09 15:08:12 +000025 virtual ~SimpleConstraintManager();
26
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
Ted Kremenek5b9bd212009-09-11 22:07:28 +000033 const GRState *Assume(const GRState *state, DefinedSVal Cond,
34 bool Assumption);
Ted Kremenekf1b82272009-06-18 23:20:05 +000035
Ted Kremeneka591bc02009-06-18 22:57:13 +000036 const GRState *Assume(const GRState *state, Loc Cond, bool Assumption);
Ted Kremenek45021952009-02-14 17:08:39 +000037
Ted Kremeneka591bc02009-06-18 22:57:13 +000038 const GRState *Assume(const GRState *state, NonLoc Cond, bool Assumption);
Ted Kremenek45021952009-02-14 17:08:39 +000039
Ted Kremeneka591bc02009-06-18 22:57:13 +000040 const GRState *AssumeSymInt(const GRState *state, bool Assumption,
41 const SymIntExpr *SE);
Mike Stump1eb44332009-09-09 15:08:12 +000042
Ted Kremenek5b9bd212009-09-11 22:07:28 +000043 const GRState *AssumeInBound(const GRState *state, DefinedSVal Idx,
44 DefinedSVal UpperBound,
Ted Kremeneka591bc02009-06-18 22:57:13 +000045 bool Assumption);
Mike Stump1eb44332009-09-09 15:08:12 +000046
Ted Kremeneka591bc02009-06-18 22:57:13 +000047protected:
Mike Stump1eb44332009-09-09 15:08:12 +000048
Ted Kremeneka591bc02009-06-18 22:57:13 +000049 //===------------------------------------------------------------------===//
50 // Interface that subclasses must implement.
51 //===------------------------------------------------------------------===//
Mike Stump1eb44332009-09-09 15:08:12 +000052
Ted Kremeneka591bc02009-06-18 22:57:13 +000053 virtual const GRState *AssumeSymNE(const GRState *state, SymbolRef sym,
54 const llvm::APSInt& V) = 0;
Ted Kremenek45021952009-02-14 17:08:39 +000055
Ted Kremeneka591bc02009-06-18 22:57:13 +000056 virtual const GRState *AssumeSymEQ(const GRState *state, SymbolRef sym,
57 const llvm::APSInt& V) = 0;
Ted Kremenek45021952009-02-14 17:08:39 +000058
Ted Kremeneka591bc02009-06-18 22:57:13 +000059 virtual const GRState *AssumeSymLT(const GRState *state, SymbolRef sym,
60 const llvm::APSInt& V) = 0;
Ted Kremenek45021952009-02-14 17:08:39 +000061
Ted Kremeneka591bc02009-06-18 22:57:13 +000062 virtual const GRState *AssumeSymGT(const GRState *state, SymbolRef sym,
63 const llvm::APSInt& V) = 0;
Ted Kremenek45021952009-02-14 17:08:39 +000064
Ted Kremeneka591bc02009-06-18 22:57:13 +000065 virtual const GRState *AssumeSymLE(const GRState *state, SymbolRef sym,
66 const llvm::APSInt& V) = 0;
Ted Kremenek45021952009-02-14 17:08:39 +000067
Ted Kremeneka591bc02009-06-18 22:57:13 +000068 virtual const GRState *AssumeSymGE(const GRState *state, SymbolRef sym,
69 const llvm::APSInt& V) = 0;
Mike Stump1eb44332009-09-09 15:08:12 +000070
Ted Kremeneka591bc02009-06-18 22:57:13 +000071 //===------------------------------------------------------------------===//
72 // Internal implementation.
73 //===------------------------------------------------------------------===//
Mike Stump1eb44332009-09-09 15:08:12 +000074
Ted Kremeneka591bc02009-06-18 22:57:13 +000075 const GRState *AssumeAux(const GRState *state, Loc Cond,bool Assumption);
Mike Stump1eb44332009-09-09 15:08:12 +000076
Ted Kremeneka591bc02009-06-18 22:57:13 +000077 const GRState *AssumeAux(const GRState *state, NonLoc Cond, bool Assumption);
Ted Kremenek45021952009-02-14 17:08:39 +000078};
79
80} // end clang namespace
81
Ted Kremenek669c0e12009-02-15 18:24:51 +000082#endif