Static Value-Flow Analysis
AbstractValue.h
Go to the documentation of this file.
1 //===- AbstractValue.h ----AbstractValue-------------------------//
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 // The implementation is based on
24 // Xiao Cheng, Jiawei Wang and Yulei Sui. Precise Sparse Abstract Execution via Cross-Domain Interaction.
25 // 46th International Conference on Software Engineering. (ICSE24)
26 
27 #include "AE/Core/IntervalValue.h"
28 #include "AE/Core/AddressValue.h"
29 #include "Util/SVFUtil.h"
30 
31 namespace SVF
32 {
33 
35 {
36 
37 public:
40 
42  {
44  addrs = AddressValue();
45  }
46 
48  {
49  interval = other.interval;
50  addrs = other.addrs;
51  }
52 
53  inline bool isInterval() const
54  {
55  return !interval.isBottom();
56  }
57  inline bool isAddr() const
58  {
59  return !addrs.isBottom();
60  }
61 
63  {
64  interval = SVFUtil::move(other.interval);
65  addrs = SVFUtil::move(other.addrs);
66  }
67 
68  // operator overload, supporting both interval and address
70  {
71  interval = other.interval;
72  addrs = other.addrs;
73  return *this;
74  }
75 
77  {
78  interval = SVFUtil::move(other.interval);
79  addrs = SVFUtil::move(other.addrs);
80  return *this;
81  }
82 
84  {
85  interval = other;
86  addrs = AddressValue();
87  return *this;
88  }
89 
91  {
92  addrs = other;
94  return *this;
95  }
96 
98 
99  AbstractValue(const AddressValue& addr) : interval(IntervalValue::bottom()), addrs(addr) {}
100 
102  {
103  return interval;
104  }
105 
107  {
108  return interval;
109  }
110 
112  {
113  return addrs;
114  }
115 
116  const AddressValue getAddrs() const
117  {
118  return addrs;
119  }
120 
122 
123  bool equals(const AbstractValue &rhs) const
124  {
125  return interval.equals(rhs.interval) && addrs.equals(rhs.addrs);
126  }
127 
128  void join_with(const AbstractValue &other)
129  {
130  interval.join_with(other.interval);
131  addrs.join_with(other.addrs);
132  }
133 
134  void meet_with(const AbstractValue &other)
135  {
136  interval.meet_with(other.interval);
137  addrs.meet_with(other.addrs);
138  }
139 
140  void widen_with(const AbstractValue &other)
141  {
143  // TODO: widen Addrs
144  }
145 
146  void narrow_with(const AbstractValue &other)
147  {
149  // TODO: narrow Addrs
150  }
151 
153  {
154  return "<" + interval.toString() + ", " + addrs.toString() + ">";
155  }
156 };
157 }
const char *const string
Definition: cJSON.h:172
void meet_with(const AbstractValue &other)
AbstractValue(const AbstractValue &other)
Definition: AbstractValue.h:47
AbstractValue(const IntervalValue &ival)
Definition: AbstractValue.h:97
AbstractValue & operator=(const AbstractValue &&other)
Definition: AbstractValue.h:76
void join_with(const AbstractValue &other)
bool isInterval() const
Definition: AbstractValue.h:53
AbstractValue & operator=(const AddressValue &other)
Definition: AbstractValue.h:90
IntervalValue interval
Definition: AbstractValue.h:38
void widen_with(const AbstractValue &other)
const IntervalValue getInterval() const
void narrow_with(const AbstractValue &other)
AbstractValue & operator=(const IntervalValue &other)
Definition: AbstractValue.h:83
const AddressValue getAddrs() const
AbstractValue(AbstractValue &&other)
Definition: AbstractValue.h:62
std::string toString() const
bool isAddr() const
Definition: AbstractValue.h:57
AbstractValue(const AddressValue &addr)
Definition: AbstractValue.h:99
AddressValue & getAddrs()
IntervalValue & getInterval()
AbstractValue & operator=(const AbstractValue &other)
Definition: AbstractValue.h:69
AddressValue addrs
Definition: AbstractValue.h:39
bool equals(const AbstractValue &rhs) const
bool meet_with(const AddressValue &other)
Return a intersected AddressValue.
Definition: AddressValue.h:143
bool equals(const AddressValue &rhs) const
Definition: AddressValue.h:87
const std::string toString() const
Definition: AddressValue.h:191
bool isBottom() const
Definition: AddressValue.h:176
bool join_with(const AddressValue &other)
Current AddressValue joins with another AddressValue.
Definition: AddressValue.h:128
void meet_with(const IntervalValue &other)
Return a intersected IntervalValue.
void join_with(const IntervalValue &other)
Current IntervalValue joins with another IntervalValue.
const std::string toString() const
bool isBottom() const
Definition: IntervalValue.h:71
void narrow_with(const IntervalValue &other)
Current IntervalValue narrow with another IntervalValue.
static IntervalValue bottom()
Create the bottom IntervalValue [+inf, -inf].
void widen_with(const IntervalValue &other)
Current IntervalValue widen with another IntervalValue.
bool equals(const IntervalValue &other) const
Equality comparison.
constexpr std::remove_reference< T >::type && move(T &&t) noexcept
Definition: SVFUtil.h:447
for isBitcode
Definition: BasicTypes.h:68