blob: 818239831948abf7e46da3506931099826e44b69 [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 Kremenek32a58082010-01-05 00:15:18 +000023 GRSubEngine &SU;
Ted Kremenek45021952009-02-14 17:08:39 +000024public:
Ted Kremenek32a58082010-01-05 00:15:18 +000025 SimpleConstraintManager(GRSubEngine &subengine) : SU(subengine) {}
Mike Stump1eb44332009-09-09 15:08:12 +000026 virtual ~SimpleConstraintManager();
27
Ted Kremeneka591bc02009-06-18 22:57:13 +000028 //===------------------------------------------------------------------===//
29 // Common implementation for the interface provided by ConstraintManager.
30 //===------------------------------------------------------------------===//
Ted Kremenekf1b82272009-06-18 23:20:05 +000031
32 bool canReasonAbout(SVal X) const;
33
Ted Kremenek5b9bd212009-09-11 22:07:28 +000034 const GRState *Assume(const GRState *state, DefinedSVal Cond,
35 bool Assumption);
Ted Kremenekf1b82272009-06-18 23:20:05 +000036
Ted Kremeneka591bc02009-06-18 22:57:13 +000037 const GRState *Assume(const GRState *state, Loc Cond, bool Assumption);
Ted Kremenek45021952009-02-14 17:08:39 +000038
Ted Kremeneka591bc02009-06-18 22:57:13 +000039 const GRState *Assume(const GRState *state, NonLoc Cond, bool Assumption);
Ted Kremenek45021952009-02-14 17:08:39 +000040
Ted Kremeneka591bc02009-06-18 22:57:13 +000041 const GRState *AssumeSymInt(const GRState *state, bool Assumption,
42 const SymIntExpr *SE);
Mike Stump1eb44332009-09-09 15:08:12 +000043
Ted Kremenek5b9bd212009-09-11 22:07:28 +000044 const GRState *AssumeInBound(const GRState *state, DefinedSVal Idx,
45 DefinedSVal UpperBound,
Ted Kremeneka591bc02009-06-18 22:57:13 +000046 bool Assumption);
Mike Stump1eb44332009-09-09 15:08:12 +000047
Ted Kremeneka591bc02009-06-18 22:57:13 +000048protected:
Mike Stump1eb44332009-09-09 15:08:12 +000049
Ted Kremeneka591bc02009-06-18 22:57:13 +000050 //===------------------------------------------------------------------===//
51 // Interface that subclasses must implement.
52 //===------------------------------------------------------------------===//
Mike Stump1eb44332009-09-09 15:08:12 +000053
Ted Kremeneka591bc02009-06-18 22:57:13 +000054 virtual const GRState *AssumeSymNE(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 *AssumeSymEQ(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 *AssumeSymLT(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 *AssumeSymGT(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 *AssumeSymLE(const GRState *state, SymbolRef sym,
67 const llvm::APSInt& V) = 0;
Ted Kremenek45021952009-02-14 17:08:39 +000068
Ted Kremeneka591bc02009-06-18 22:57:13 +000069 virtual const GRState *AssumeSymGE(const GRState *state, SymbolRef sym,
70 const llvm::APSInt& V) = 0;
Mike Stump1eb44332009-09-09 15:08:12 +000071
Ted Kremeneka591bc02009-06-18 22:57:13 +000072 //===------------------------------------------------------------------===//
73 // Internal implementation.
74 //===------------------------------------------------------------------===//
Mike Stump1eb44332009-09-09 15:08:12 +000075
Ted Kremeneka591bc02009-06-18 22:57:13 +000076 const GRState *AssumeAux(const GRState *state, Loc Cond,bool Assumption);
Mike Stump1eb44332009-09-09 15:08:12 +000077
Ted Kremeneka591bc02009-06-18 22:57:13 +000078 const GRState *AssumeAux(const GRState *state, NonLoc Cond, bool Assumption);
Ted Kremenek45021952009-02-14 17:08:39 +000079};
80
81} // end clang namespace
82
Ted Kremenek669c0e12009-02-15 18:24:51 +000083#endif