Static Value-Flow Analysis
Public Types | Public Member Functions | Static Public Member Functions | Private Attributes | List of all members
SVF::AddressValue Class Reference

#include <AddressValue.h>

Public Types

typedef Set< u32_tAddrSet
 

Public Member Functions

 AddressValue ()
 Default constructor. More...
 
 AddressValue (const Set< u32_t > &addrs)
 Constructor. More...
 
 AddressValue (u32_t addr)
 
 ~AddressValue ()=default
 Default destructor. More...
 
 AddressValue (const AddressValue &other)
 Copy constructor. More...
 
 AddressValue (AddressValue &&other) noexcept
 Move constructor. More...
 
AddressValueoperator= (const AddressValue &other)
 Copy operator=. More...
 
AddressValueoperator= (AddressValue &&other) noexcept
 Move operator=. More...
 
bool equals (const AddressValue &rhs) const
 
AddrSet::const_iterator begin () const
 
AddrSet::const_iterator end () const
 
bool empty () const
 
u32_t size () const
 
std::pair< AddressValue::AddrSet::iterator, bool > insert (u32_t id)
 
const AddrSetgetVals () const
 
void setVals (const AddrSet &vals)
 
bool join_with (const AddressValue &other)
 Current AddressValue joins with another AddressValue. More...
 
bool meet_with (const AddressValue &other)
 Return a intersected AddressValue. More...
 
bool contains (u32_t id) const
 Return true if the AddressValue contains n. More...
 
bool hasIntersect (const AddressValue &other)
 
bool isTop () const
 
bool isBottom () const
 
void setTop ()
 
void setBottom ()
 
const std::string toString () const
 

Static Public Member Functions

static u32_t getVirtualMemAddress (u32_t idx)
 The physical address starts with 0x7f...... + idx. More...
 
static bool isVirtualMemAddress (u32_t val)
 Check bit value of val start with 0x7F000000, filter by 0xFF000000. More...
 
static u32_t getInternalID (u32_t idx)
 Return the internal index if idx is an address otherwise return the value of idx. More...
 

Private Attributes

AddrSet _addrs
 

Detailed Description

Definition at line 43 of file AddressValue.h.

Member Typedef Documentation

◆ AddrSet

Definition at line 46 of file AddressValue.h.

Constructor & Destructor Documentation

◆ AddressValue() [1/5]

SVF::AddressValue::AddressValue ( )
inline

Default constructor.

Definition at line 51 of file AddressValue.h.

51 {}

◆ AddressValue() [2/5]

SVF::AddressValue::AddressValue ( const Set< u32_t > &  addrs)
inline

Constructor.

Definition at line 54 of file AddressValue.h.

54 : _addrs(addrs) {}

◆ AddressValue() [3/5]

SVF::AddressValue::AddressValue ( u32_t  addr)
inline

Definition at line 56 of file AddressValue.h.

56 : _addrs({addr}) {}

◆ ~AddressValue()

SVF::AddressValue::~AddressValue ( )
default

Default destructor.

◆ AddressValue() [4/5]

SVF::AddressValue::AddressValue ( const AddressValue other)
inline

Copy constructor.

Definition at line 62 of file AddressValue.h.

62 : _addrs(other._addrs) {}

◆ AddressValue() [5/5]

SVF::AddressValue::AddressValue ( AddressValue &&  other)
inlinenoexcept

Move constructor.

Definition at line 65 of file AddressValue.h.

65 : _addrs(std::move(other._addrs)) {}
constexpr std::remove_reference< T >::type && move(T &&t) noexcept
Definition: SVFUtil.h:447

Member Function Documentation

◆ begin()

AddrSet::const_iterator SVF::AddressValue::begin ( ) const
inline

Definition at line 92 of file AddressValue.h.

93  {
94  return _addrs.cbegin();
95  }

◆ contains()

bool SVF::AddressValue::contains ( u32_t  id) const
inline

Return true if the AddressValue contains n.

Definition at line 159 of file AddressValue.h.

160  {
161  return _addrs.count(id);
162  }

◆ empty()

bool SVF::AddressValue::empty ( ) const
inline

Definition at line 102 of file AddressValue.h.

103  {
104  return _addrs.empty();
105  }

◆ end()

AddrSet::const_iterator SVF::AddressValue::end ( ) const
inline

Definition at line 97 of file AddressValue.h.

98  {
99  return _addrs.cend();
100  }

◆ equals()

bool SVF::AddressValue::equals ( const AddressValue rhs) const
inline

Definition at line 87 of file AddressValue.h.

88  {
89  return _addrs == rhs._addrs;
90  }

◆ getInternalID()

static u32_t SVF::AddressValue::getInternalID ( u32_t  idx)
inlinestatic

Return the internal index if idx is an address otherwise return the value of idx.

Definition at line 226 of file AddressValue.h.

227  {
228  return (idx & FlippedAddressMask);
229  }
#define FlippedAddressMask
Definition: AddressValue.h:34

◆ getVals()

const AddrSet& SVF::AddressValue::getVals ( ) const
inline

Definition at line 117 of file AddressValue.h.

118  {
119  return _addrs;
120  }

◆ getVirtualMemAddress()

static u32_t SVF::AddressValue::getVirtualMemAddress ( u32_t  idx)
inlinestatic

The physical address starts with 0x7f...... + idx.

Definition at line 212 of file AddressValue.h.

213  {
214  // 0 is the null address, should not be used as a virtual address
215  assert(idx != 0 && "idx can’t be 0 because it represents a nullptr");
216  return AddressMask + idx;
217  }
#define AddressMask
Definition: AddressValue.h:33

◆ hasIntersect()

bool SVF::AddressValue::hasIntersect ( const AddressValue other)
inline

Definition at line 164 of file AddressValue.h.

165  {
166  AddressValue v = *this;
167  v.meet_with(other);
168  return !v.empty();
169  }
AddressValue()
Default constructor.
Definition: AddressValue.h:51

◆ insert()

std::pair<AddressValue::AddrSet::iterator, bool> SVF::AddressValue::insert ( u32_t  id)
inline

Definition at line 112 of file AddressValue.h.

113  {
114  return _addrs.insert(id);
115  }

◆ isBottom()

bool SVF::AddressValue::isBottom ( ) const
inline

Definition at line 176 of file AddressValue.h.

177  {
178  return empty();
179  }
bool empty() const
Definition: AddressValue.h:102

◆ isTop()

bool SVF::AddressValue::isTop ( ) const
inline

Definition at line 171 of file AddressValue.h.

172  {
173  return *this->begin() == BlackHoleAddr;
174  }
#define BlackHoleAddr
Definition: AddressValue.h:36
AddrSet::const_iterator begin() const
Definition: AddressValue.h:92

◆ isVirtualMemAddress()

static bool SVF::AddressValue::isVirtualMemAddress ( u32_t  val)
inlinestatic

Check bit value of val start with 0x7F000000, filter by 0xFF000000.

Definition at line 220 of file AddressValue.h.

221  {
222  return (val & 0xff000000) == AddressMask && val != AddressMask + 0;
223  }

◆ join_with()

bool SVF::AddressValue::join_with ( const AddressValue other)
inline

Current AddressValue joins with another AddressValue.

Definition at line 128 of file AddressValue.h.

129  {
130  bool changed = false;
131  for (const auto &addr: other)
132  {
133  if (!_addrs.count(addr))
134  {
135  if (insert(addr).second)
136  changed = true;
137  }
138  }
139  return changed;
140  }
std::pair< AddressValue::AddrSet::iterator, bool > insert(u32_t id)
Definition: AddressValue.h:112

◆ meet_with()

bool SVF::AddressValue::meet_with ( const AddressValue other)
inline

Return a intersected AddressValue.

Definition at line 143 of file AddressValue.h.

144  {
145  AddrSet s;
146  for (const auto &id: other._addrs)
147  {
148  if (_addrs.find(id) != _addrs.end())
149  {
150  s.insert(id);
151  }
152  }
153  bool changed = (_addrs != s);
154  _addrs = std::move(s);
155  return changed;
156  }
Set< u32_t > AddrSet
Definition: AddressValue.h:46

◆ operator=() [1/2]

AddressValue& SVF::AddressValue::operator= ( AddressValue &&  other)
inlinenoexcept

Move operator=.

Definition at line 78 of file AddressValue.h.

79  {
80  if (this != &other)
81  {
82  _addrs = std::move(other._addrs);
83  }
84  return *this;
85  }

◆ operator=() [2/2]

AddressValue& SVF::AddressValue::operator= ( const AddressValue other)
inline

Copy operator=.

Definition at line 68 of file AddressValue.h.

69  {
70  if (!this->equals(other))
71  {
72  _addrs = other._addrs;
73  }
74  return *this;
75  }
bool equals(const AddressValue &rhs) const
Definition: AddressValue.h:87

◆ setBottom()

void SVF::AddressValue::setBottom ( )
inline

Definition at line 186 of file AddressValue.h.

187  {
188  _addrs.clear();
189  }

◆ setTop()

void SVF::AddressValue::setTop ( )
inline

Definition at line 181 of file AddressValue.h.

182  {
183  *this = AddressValue(BlackHoleAddr);
184  }

◆ setVals()

void SVF::AddressValue::setVals ( const AddrSet vals)
inline

Definition at line 122 of file AddressValue.h.

123  {
124  _addrs = vals;
125  }

◆ size()

u32_t SVF::AddressValue::size ( ) const
inline

Definition at line 107 of file AddressValue.h.

108  {
109  return _addrs.size();
110  }

◆ toString()

const std::string SVF::AddressValue::toString ( ) const
inline

Definition at line 191 of file AddressValue.h.

192  {
193  std::string str;
194  std::stringstream rawStr(str);
195  if (this->isBottom())
196  {
197  rawStr << "⊥";
198  }
199  else
200  {
201  rawStr << "[";
202  for (auto it = _addrs.begin(), eit = _addrs.end(); it!= eit; ++it)
203  {
204  rawStr << *it << ", ";
205  }
206  rawStr << "]";
207  }
208  return rawStr.str();
209  }
const char *const string
Definition: cJSON.h:172
bool isBottom() const
Definition: AddressValue.h:176

Member Data Documentation

◆ _addrs

AddrSet SVF::AddressValue::_addrs
private

Definition at line 48 of file AddressValue.h.


The documentation for this class was generated from the following file: