Static Value-Flow Analysis
RelationSolver.h
Go to the documentation of this file.
1 //===- RelationSolver.h ----Relation Solver for Interval Domains-----------//
2 //
3 // SVF: Static Value-Flow Analysis
4 //
5 // Copyright (C) <2013-2022> <Yulei Sui>
6 //
7 
8 // This program is free software: you can redistribute it and/or modify
9 // it under the terms of the GNU Affero General Public License as published by
10 // the Free Software Foundation, either version 3 of the License, or
11 // (at your option) any later version.
12 
13 // This program is distributed in the hope that it will be useful,
14 // but WITHOUT ANY WARRANTY; without even the implied warranty of
15 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 // GNU Affero General Public License for more details.
17 
18 // You should have received a copy of the GNU Affero General Public License
19 // along with this program. If not, see <http://www.gnu.org/licenses/>.
20 //
21 //===----------------------------------------------------------------------===//
22 /*
23  * RelationSolver.h
24  *
25  * Created on: Aug 4, 2022
26  * Author: Jiawei Ren
27  *
28  */
29 
30 #ifndef Z3_EXAMPLE_RELATIONSOLVER_H
31 #define Z3_EXAMPLE_RELATIONSOLVER_H
32 
33 #include "AE/Core/AbstractState.h"
34 #include "Util/Z3Expr.h"
35 
36 namespace SVF
37 {
39 {
40 public:
41  RelationSolver() = default;
42 
43  /* gamma_hat, beta and abstract_consequence works on
44  IntervalESBase (the last element of inputs) for RSY or bilateral solver */
45 
47  Z3Expr gamma_hat(const AbstractState&exeState) const;
48 
50  Z3Expr gamma_hat(const AbstractState&alpha, const AbstractState&exeState) const;
51 
53  Z3Expr gamma_hat(u32_t id, const AbstractState&exeState) const;
54 
55  AbstractState abstract_consequence(const AbstractState&lower, const AbstractState&upper, const AbstractState&domain) const;
56 
57  AbstractState beta(const Map<u32_t, s32_t> &sigma, const AbstractState&exeState) const;
58 
59 
61  virtual inline Z3Expr toIntZ3Expr(u32_t varId) const
62  {
63  return Z3Expr::getContext().int_const(std::to_string(varId).c_str());
64  }
65 
66  inline Z3Expr toIntVal(s32_t f) const
67  {
68  return Z3Expr::getContext().int_val(f);
69  }
70  inline Z3Expr toRealVal(BoundedDouble f) const
71  {
72  return Z3Expr::getContext().real_val(std::to_string(f.getFVal()).c_str());
73  }
74 
75  /* two optional solvers: RSY and bilateral */
76 
77  AbstractState bilateral(const AbstractState& domain, const Z3Expr &phi, u32_t descend_check = 0);
78 
79  AbstractState RSY(const AbstractState& domain, const Z3Expr &phi);
80 
82 
83  AbstractState BS(const AbstractState& domain, const Z3Expr &phi);
84 
85  void updateMap(Map<u32_t, s32_t>& map, u32_t key, const s32_t& value);
86 
88 };
89 }
90 
91 #endif //Z3_EXAMPLE_RELATIONSOLVER_H
const double getFVal() const
Definition: NumericValue.h:758
Z3Expr gamma_hat(const AbstractState &exeState) const
Return Z3Expr according to valToValMap.
AbstractState RSY(const AbstractState &domain, const Z3Expr &phi)
AbstractState bilateral(const AbstractState &domain, const Z3Expr &phi, u32_t descend_check=0)
Map< u32_t, s32_t > BoxedOptSolver(const Z3Expr &phi, Map< u32_t, s32_t > &ret, Map< u32_t, s32_t > &low_values, Map< u32_t, s32_t > &high_values)
AbstractState beta(const Map< u32_t, s32_t > &sigma, const AbstractState &exeState) const
virtual Z3Expr toIntZ3Expr(u32_t varId) const
Return Z3 expression lazily based on SVFVar ID.
void updateMap(Map< u32_t, s32_t > &map, u32_t key, const s32_t &value)
AbstractState abstract_consequence(const AbstractState &lower, const AbstractState &upper, const AbstractState &domain) const
void decide_cpa_ext(const Z3Expr &phi, Map< u32_t, Z3Expr > &, Map< u32_t, s32_t > &, Map< u32_t, s32_t > &, Map< u32_t, s32_t > &, Map< u32_t, s32_t > &)
AbstractState BS(const AbstractState &domain, const Z3Expr &phi)
Z3Expr toRealVal(BoundedDouble f) const
RelationSolver()=default
Z3Expr toIntVal(s32_t f) const
static z3::context & getContext()
Get z3 context, singleton design here to make sure we only have one context.
Definition: Z3Expr.cpp:66
for isBitcode
Definition: BasicTypes.h:68
std::unordered_map< Key, Value, Hash, KeyEqual, Allocator > Map
Definition: GeneralType.h:101
signed s32_t
Definition: GeneralType.h:47
unsigned u32_t
Definition: GeneralType.h:46