1218887Sdim//== SimpleConstraintManager.h ----------------------------------*- C++ -*--==//
2218887Sdim//
3218887Sdim//                     The LLVM Compiler Infrastructure
4218887Sdim//
5218887Sdim// This file is distributed under the University of Illinois Open Source
6218887Sdim// License. See LICENSE.TXT for details.
7218887Sdim//
8218887Sdim//===----------------------------------------------------------------------===//
9218887Sdim//
10218887Sdim//  Code shared between BasicConstraintManager and RangeConstraintManager.
11218887Sdim//
12218887Sdim//===----------------------------------------------------------------------===//
13218887Sdim
14218887Sdim#ifndef LLVM_CLANG_GR_SIMPLE_CONSTRAINT_MANAGER_H
15218887Sdim#define LLVM_CLANG_GR_SIMPLE_CONSTRAINT_MANAGER_H
16218887Sdim
17218887Sdim#include "clang/StaticAnalyzer/Core/PathSensitive/ConstraintManager.h"
18226633Sdim#include "clang/StaticAnalyzer/Core/PathSensitive/ProgramState.h"
19218887Sdim
20218887Sdimnamespace clang {
21218887Sdim
22218887Sdimnamespace ento {
23218887Sdim
24218887Sdimclass SimpleConstraintManager : public ConstraintManager {
25243830Sdim  SubEngine *SU;
26249423Sdim  SValBuilder &SVB;
27218887Sdimpublic:
28249423Sdim  SimpleConstraintManager(SubEngine *subengine, SValBuilder &SB)
29249423Sdim    : SU(subengine), SVB(SB) {}
30218887Sdim  virtual ~SimpleConstraintManager();
31218887Sdim
32218887Sdim  //===------------------------------------------------------------------===//
33218887Sdim  // Common implementation for the interface provided by ConstraintManager.
34218887Sdim  //===------------------------------------------------------------------===//
35218887Sdim
36234353Sdim  ProgramStateRef assume(ProgramStateRef state, DefinedSVal Cond,
37218887Sdim                        bool Assumption);
38218887Sdim
39234353Sdim  ProgramStateRef assume(ProgramStateRef state, NonLoc Cond, bool Assumption);
40218887Sdim
41234353Sdim  ProgramStateRef assumeSymRel(ProgramStateRef state,
42218887Sdim                              const SymExpr *LHS,
43218887Sdim                              BinaryOperator::Opcode op,
44218887Sdim                              const llvm::APSInt& Int);
45218887Sdim
46218887Sdimprotected:
47218887Sdim
48218887Sdim  //===------------------------------------------------------------------===//
49218887Sdim  // Interface that subclasses must implement.
50218887Sdim  //===------------------------------------------------------------------===//
51218887Sdim
52218887Sdim  // Each of these is of the form "$sym+Adj <> V", where "<>" is the comparison
53218887Sdim  // operation for the method being invoked.
54234353Sdim  virtual ProgramStateRef assumeSymNE(ProgramStateRef state, SymbolRef sym,
55218887Sdim                                     const llvm::APSInt& V,
56218887Sdim                                     const llvm::APSInt& Adjustment) = 0;
57218887Sdim
58234353Sdim  virtual ProgramStateRef assumeSymEQ(ProgramStateRef state, SymbolRef sym,
59218887Sdim                                     const llvm::APSInt& V,
60218887Sdim                                     const llvm::APSInt& Adjustment) = 0;
61218887Sdim
62234353Sdim  virtual ProgramStateRef assumeSymLT(ProgramStateRef state, SymbolRef sym,
63218887Sdim                                     const llvm::APSInt& V,
64218887Sdim                                     const llvm::APSInt& Adjustment) = 0;
65218887Sdim
66234353Sdim  virtual ProgramStateRef assumeSymGT(ProgramStateRef state, SymbolRef sym,
67218887Sdim                                     const llvm::APSInt& V,
68218887Sdim                                     const llvm::APSInt& Adjustment) = 0;
69218887Sdim
70234353Sdim  virtual ProgramStateRef assumeSymLE(ProgramStateRef state, SymbolRef sym,
71218887Sdim                                     const llvm::APSInt& V,
72218887Sdim                                     const llvm::APSInt& Adjustment) = 0;
73218887Sdim
74234353Sdim  virtual ProgramStateRef assumeSymGE(ProgramStateRef state, SymbolRef sym,
75218887Sdim                                     const llvm::APSInt& V,
76218887Sdim                                     const llvm::APSInt& Adjustment) = 0;
77218887Sdim
78218887Sdim  //===------------------------------------------------------------------===//
79218887Sdim  // Internal implementation.
80218887Sdim  //===------------------------------------------------------------------===//
81218887Sdim
82249423Sdim  BasicValueFactory &getBasicVals() const { return SVB.getBasicValueFactory(); }
83249423Sdim  SymbolManager &getSymbolManager() const { return SVB.getSymbolManager(); }
84239462Sdim
85234353Sdim  bool canReasonAbout(SVal X) const;
86218887Sdim
87234353Sdim  ProgramStateRef assumeAux(ProgramStateRef state,
88234353Sdim                                NonLoc Cond,
89234353Sdim                                bool Assumption);
90234353Sdim
91234353Sdim  ProgramStateRef assumeAuxForSymbol(ProgramStateRef State,
92234353Sdim                                         SymbolRef Sym,
93234353Sdim                                         bool Assumption);
94218887Sdim};
95218887Sdim
96218887Sdim} // end GR namespace
97218887Sdim
98218887Sdim} // end clang namespace
99218887Sdim
100218887Sdim#endif
101