Static Value-Flow Analysis
Loading...
Searching...
No Matches
Public Types | Public Member Functions | Static Public Member Functions | Static Private Member Functions | Private Attributes | Friends | List of all members
SVF::AddressValue Class Reference

#include <AddressValue.h>

Public Types

typedef Set< u32_tAddrSet
 

Public Member Functions

 AddressValue ()
 Default constructor.
 
 AddressValue (const Set< u32_t > &addrs)
 Constructor.
 
 AddressValue (u32_t addr)
 
 ~AddressValue ()=default
 Default destructor.
 
 AddressValue (const AddressValue &other)
 Copy constructor.
 
 AddressValue (AddressValue &&other) noexcept
 Move constructor.
 
AddressValueoperator= (const AddressValue &other)
 Copy operator=.
 
AddressValueoperator= (AddressValue &&other) noexcept
 Move operator=.
 
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, boolinsert (u32_t id)
 
const AddrSetgetVals () const
 
void setVals (const AddrSet &vals)
 
bool join_with (const AddressValue &other)
 Current AddressValue joins with another AddressValue.
 
bool meet_with (const AddressValue &other)
 Return a intersected AddressValue.
 
bool contains (u32_t id) const
 Return true if the AddressValue contains n.
 
bool hasIntersect (const AddressValue &other)
 
bool isBottom () const
 
const std::string toString () const
 

Static Public Member Functions

static u32_t getVirtualMemAddress (u32_t idx)
 The physical address starts with 0x7f...... + idx.
 
static bool isVirtualMemAddress (u32_t val)
 Check bit value of val start with 0x7F000000, filter by 0xFF000000.
 

Static Private Member Functions

static u32_t getInternalID (u32_t idx)
 Return the internal index if idx is an address otherwise return the value of idx.
 

Private Attributes

AddrSet _addrs
 

Friends

class AbstractState
 
class RelExeState
 

Detailed Description

Definition at line 47 of file AddressValue.h.

Member Typedef Documentation

◆ AddrSet

Definition at line 52 of file AddressValue.h.

Constructor & Destructor Documentation

◆ AddressValue() [1/5]

SVF::AddressValue::AddressValue ( )
inline

Default constructor.

Definition at line 64 of file AddressValue.h.

64{}

◆ AddressValue() [2/5]

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

Constructor.

Definition at line 67 of file AddressValue.h.

67: _addrs(addrs) {}

◆ AddressValue() [3/5]

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

Definition at line 69 of file AddressValue.h.

69: _addrs({addr}) {}
llvm::IRBuilder IRBuilder
Definition BasicTypes.h:74

◆ ~AddressValue()

SVF::AddressValue::~AddressValue ( )
default

Default destructor.

◆ AddressValue() [4/5]

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

Copy constructor.

Definition at line 75 of file AddressValue.h.

75: _addrs(other._addrs) {}

◆ AddressValue() [5/5]

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

Move constructor.

Definition at line 78 of file AddressValue.h.

78: _addrs(std::move(other._addrs)) {}

Member Function Documentation

◆ begin()

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

Definition at line 105 of file AddressValue.h.

106 {
107 return _addrs.cbegin();
108 }

◆ contains()

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

Return true if the AddressValue contains n.

Definition at line 172 of file AddressValue.h.

173 {
174 return _addrs.count(id);
175 }

◆ empty()

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

Definition at line 115 of file AddressValue.h.

116 {
117 return _addrs.empty();
118 }

◆ end()

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

Definition at line 110 of file AddressValue.h.

111 {
112 return _addrs.cend();
113 }

◆ equals()

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

Definition at line 100 of file AddressValue.h.

101 {
102 return _addrs == rhs._addrs;
103 }

◆ getInternalID()

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

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

Definition at line 57 of file AddressValue.h.

58 {
59 return (idx & FlippedAddressMask);
60 }
#define FlippedAddressMask

◆ getVals()

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

Definition at line 130 of file AddressValue.h.

131 {
132 return _addrs;
133 }

◆ getVirtualMemAddress()

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

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

Definition at line 210 of file AddressValue.h.

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

◆ hasIntersect()

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

Definition at line 177 of file AddressValue.h.

178 {
179 AddressValue v = *this;
180 v.meet_with(other);
181 return !v.empty();
182 }
AddressValue()
Default constructor.

◆ insert()

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

Definition at line 125 of file AddressValue.h.

126 {
127 return _addrs.insert(id);
128 }

◆ isBottom()

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

Definition at line 184 of file AddressValue.h.

185 {
186 return empty();
187 }
bool empty() const

◆ isVirtualMemAddress()

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

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

Definition at line 218 of file AddressValue.h.

219 {
220 return (val & 0xff000000) == AddressMask && val != AddressMask + 0;
221 }

◆ join_with()

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

Current AddressValue joins with another AddressValue.

Definition at line 141 of file AddressValue.h.

142 {
143 bool changed = false;
144 for (const auto &addr: other)
145 {
146 if (!_addrs.count(addr))
147 {
148 if (insert(addr).second)
149 changed = true;
150 }
151 }
152 return changed;
153 }
std::pair< AddressValue::AddrSet::iterator, bool > insert(u32_t id)

◆ meet_with()

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

Return a intersected AddressValue.

Definition at line 156 of file AddressValue.h.

157 {
158 AddrSet s;
159 for (const auto &id: other._addrs)
160 {
161 if (_addrs.find(id) != _addrs.end())
162 {
163 s.insert(id);
164 }
165 }
166 bool changed = (_addrs != s);
167 _addrs = std::move(s);
168 return changed;
169 }
Set< u32_t > AddrSet

◆ operator=() [1/2]

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

Move operator=.

Definition at line 91 of file AddressValue.h.

92 {
93 if (this != &other)
94 {
95 _addrs = std::move(other._addrs);
96 }
97 return *this;
98 }

◆ operator=() [2/2]

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

Copy operator=.

Definition at line 81 of file AddressValue.h.

82 {
83 if (!this->equals(other))
84 {
85 _addrs = other._addrs;
86 }
87 return *this;
88 }
bool equals(const AddressValue &rhs) const

◆ setVals()

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

Definition at line 135 of file AddressValue.h.

136 {
137 _addrs = vals;
138 }

◆ size()

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

Definition at line 120 of file AddressValue.h.

121 {
122 return _addrs.size();
123 }

◆ toString()

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

Definition at line 189 of file AddressValue.h.

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

Friends And Related Symbol Documentation

◆ AbstractState

Definition at line 49 of file AddressValue.h.

◆ RelExeState

Definition at line 50 of file AddressValue.h.

Member Data Documentation

◆ _addrs

AddrSet SVF::AddressValue::_addrs
private

Definition at line 54 of file AddressValue.h.


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