blob: 45742ebd7d0e7d9ff60879e2272c978af826af1c [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
Argyrios Kyrtzidis98cabba2010-12-22 18:51:49 +000017#include "clang/GR/PathSensitive/ConstraintManager.h"
18#include "clang/GR/PathSensitive/GRState.h"
Ted Kremenek45021952009-02-14 17:08:39 +000019
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 Kremenek28f47b92010-12-01 22:16:56 +000034 const GRState *assume(const GRState *state, DefinedSVal Cond,
Ted Kremenek5b9bd212009-09-11 22:07:28 +000035 bool Assumption);
Ted Kremenekf1b82272009-06-18 23:20:05 +000036
Ted Kremenek28f47b92010-12-01 22:16:56 +000037 const GRState *assume(const GRState *state, Loc Cond, bool Assumption);
Ted Kremenek45021952009-02-14 17:08:39 +000038
Ted Kremenek28f47b92010-12-01 22:16:56 +000039 const GRState *assume(const GRState *state, NonLoc Cond, bool Assumption);
Ted Kremenek45021952009-02-14 17:08:39 +000040
Ted Kremenek28f47b92010-12-01 22:16:56 +000041 const GRState *assumeSymRel(const GRState *state,
Jordy Roseba0f61c2010-06-18 22:49:11 +000042 const SymExpr *LHS,
43 BinaryOperator::Opcode op,
44 const llvm::APSInt& Int);
Mike Stump1eb44332009-09-09 15:08:12 +000045
Ted Kremeneka591bc02009-06-18 22:57:13 +000046protected:
Mike Stump1eb44332009-09-09 15:08:12 +000047
Ted Kremeneka591bc02009-06-18 22:57:13 +000048 //===------------------------------------------------------------------===//
49 // Interface that subclasses must implement.
50 //===------------------------------------------------------------------===//
Mike Stump1eb44332009-09-09 15:08:12 +000051
Jordy Roseba0f61c2010-06-18 22:49:11 +000052 // Each of these is of the form "$sym+Adj <> V", where "<>" is the comparison
53 // operation for the method being invoked.
Ted Kremenek28f47b92010-12-01 22:16:56 +000054 virtual const GRState *assumeSymNE(const GRState *state, SymbolRef sym,
Jordy Roseba0f61c2010-06-18 22:49:11 +000055 const llvm::APSInt& V,
56 const llvm::APSInt& Adjustment) = 0;
Ted Kremenek45021952009-02-14 17:08:39 +000057
Ted Kremenek28f47b92010-12-01 22:16:56 +000058 virtual const GRState *assumeSymEQ(const GRState *state, SymbolRef sym,
Jordy Roseba0f61c2010-06-18 22:49:11 +000059 const llvm::APSInt& V,
60 const llvm::APSInt& Adjustment) = 0;
Ted Kremenek45021952009-02-14 17:08:39 +000061
Ted Kremenek28f47b92010-12-01 22:16:56 +000062 virtual const GRState *assumeSymLT(const GRState *state, SymbolRef sym,
Jordy Roseba0f61c2010-06-18 22:49:11 +000063 const llvm::APSInt& V,
64 const llvm::APSInt& Adjustment) = 0;
Ted Kremenek45021952009-02-14 17:08:39 +000065
Ted Kremenek28f47b92010-12-01 22:16:56 +000066 virtual const GRState *assumeSymGT(const GRState *state, SymbolRef sym,
Jordy Roseba0f61c2010-06-18 22:49:11 +000067 const llvm::APSInt& V,
68 const llvm::APSInt& Adjustment) = 0;
Ted Kremenek45021952009-02-14 17:08:39 +000069
Ted Kremenek28f47b92010-12-01 22:16:56 +000070 virtual const GRState *assumeSymLE(const GRState *state, SymbolRef sym,
Jordy Roseba0f61c2010-06-18 22:49:11 +000071 const llvm::APSInt& V,
72 const llvm::APSInt& Adjustment) = 0;
Ted Kremenek45021952009-02-14 17:08:39 +000073
Ted Kremenek28f47b92010-12-01 22:16:56 +000074 virtual const GRState *assumeSymGE(const GRState *state, SymbolRef sym,
Jordy Roseba0f61c2010-06-18 22:49:11 +000075 const llvm::APSInt& V,
76 const llvm::APSInt& Adjustment) = 0;
Mike Stump1eb44332009-09-09 15:08:12 +000077
Ted Kremeneka591bc02009-06-18 22:57:13 +000078 //===------------------------------------------------------------------===//
79 // Internal implementation.
80 //===------------------------------------------------------------------===//
Mike Stump1eb44332009-09-09 15:08:12 +000081
Ted Kremenek28f47b92010-12-01 22:16:56 +000082 const GRState *assumeAux(const GRState *state, Loc Cond,bool Assumption);
Mike Stump1eb44332009-09-09 15:08:12 +000083
Ted Kremenek28f47b92010-12-01 22:16:56 +000084 const GRState *assumeAux(const GRState *state, NonLoc Cond, bool Assumption);
Ted Kremenek45021952009-02-14 17:08:39 +000085};
86
87} // end clang namespace
88
Ted Kremenek669c0e12009-02-15 18:24:51 +000089#endif