clang  7.0.0
SMTConstraintManager.h
Go to the documentation of this file.
1 //== SMTConstraintManager.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 // This file defines a SMT generic API, which will be the base class for
11 // every SMT solver specific class.
12 //
13 //===----------------------------------------------------------------------===//
14 
15 #ifndef LLVM_CLANG_STATICANALYZER_CORE_PATHSENSITIVE_SMTCONSTRAINTMANAGER_H
16 #define LLVM_CLANG_STATICANALYZER_CORE_PATHSENSITIVE_SMTCONSTRAINTMANAGER_H
17 
20 
21 namespace clang {
22 namespace ento {
23 
25  SMTSolverRef &Solver;
26 
27 public:
29  SMTSolverRef &S)
30  : SimpleConstraintManager(SE, SB), Solver(S) {}
31  virtual ~SMTConstraintManager() = default;
32 
33  //===------------------------------------------------------------------===//
34  // Implementation for interface from SimpleConstraintManager.
35  //===------------------------------------------------------------------===//
36 
38  bool Assumption) override;
39 
41  const llvm::APSInt &From,
42  const llvm::APSInt &To,
43  bool InRange) override;
44 
46  bool Assumption) override;
47 
48  //===------------------------------------------------------------------===//
49  // Implementation for interface from ConstraintManager.
50  //===------------------------------------------------------------------===//
51 
53 
54  const llvm::APSInt *getSymVal(ProgramStateRef State,
55  SymbolRef Sym) const override;
56 
57  /// Dumps SMT formula
58  LLVM_DUMP_METHOD void dump() const { Solver->dump(); }
59 
60 protected:
61  // Check whether a new model is satisfiable, and update the program state.
63  const SMTExprRef &Exp) = 0;
64 
65  /// Given a program state, construct the logical conjunction and add it to
66  /// the solver
67  virtual void addStateConstraints(ProgramStateRef State) const = 0;
68 
69  // Generate and check a Z3 model, using the given constraint.
71  const SMTExprRef &Exp) const;
72 }; // end class SMTConstraintManager
73 
74 } // namespace ento
75 } // namespace clang
76 
77 #endif
ProgramStateRef assumeSymUnsupported(ProgramStateRef State, SymbolRef Sym, bool Assumption) override
Given a symbolic expression that cannot be reasoned about, assume that it is zero/nonzero and add it ...
ConditionTruthVal checkModel(ProgramStateRef State, const SMTExprRef &Exp) const
Symbolic value.
Definition: SymExpr.h:30
LineState State
i32 captured_struct **param SharedsTy A type which contains references the shared variables *param Shareds Context with the list of shared variables from the p *TaskFunction *param Data Additional data for task generation like final * state
ProgramStateRef assumeSymInclusiveRange(ProgramStateRef State, SymbolRef Sym, const llvm::APSInt &From, const llvm::APSInt &To, bool InRange) override
Given a symbolic expression within the range [From, To], assume that it is true/false and generate th...
virtual ~SMTConstraintManager()=default
virtual void addStateConstraints(ProgramStateRef State) const =0
Given a program state, construct the logical conjunction and add it to the solver.
const llvm::APSInt * getSymVal(ProgramStateRef State, SymbolRef Sym) const override
If a symbol is perfectly constrained to a constant, attempt to return the concrete value...
Dataflow Directional Tag Classes.
LLVM_DUMP_METHOD void dump() const
Dumps SMT formula.
std::shared_ptr< SMTSolver > SMTSolverRef
Shared pointer for SMTSolvers.
Definition: SMTSolver.h:988
SMTConstraintManager(clang::ento::SubEngine *SE, clang::ento::SValBuilder &SB, SMTSolverRef &S)
ConditionTruthVal checkNull(ProgramStateRef State, SymbolRef Sym) override
Returns whether or not a symbol is known to be null ("true"), known to be non-null ("false")...
std::shared_ptr< SMTExpr > SMTExprRef
Shared pointer for SMTExprs, used by SMTSolver API.
Definition: SMTExpr.h:57
ProgramStateRef assumeSym(ProgramStateRef state, SymbolRef Sym, bool Assumption) override
Given a symbolic expression that can be reasoned about, assume that it is true/false and generate the...
virtual ProgramStateRef assumeExpr(ProgramStateRef State, SymbolRef Sym, const SMTExprRef &Exp)=0