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

#include <AbstractState.h>

Public Types

typedef Map< u32_t, AbstractValueVarToAbsValMap
 
typedef VarToAbsValMap AddrToAbsValMap
 

Public Member Functions

 AbstractState ()
 default constructor
 
 AbstractState (VarToAbsValMap &_varToValMap, AddrToAbsValMap &_locToValMap)
 
 AbstractState (const AbstractState &rhs)
 copy constructor
 
virtual ~AbstractState ()=default
 
void initObjVar (const ObjVar *objVar)
 
u32_t getIDFromAddr (u32_t addr) const
 Return the internal index if addr is an address otherwise return the value of idx.
 
 AbstractState (AbstractState &&rhs)
 move constructor
 
AbstractState bottom () const
 Set all value bottom.
 
AbstractState top () const
 Set all value top.
 
AbstractState sliceState (Set< u32_t > &sl)
 Copy some values and return a new IntervalExeState.
 
virtual AbstractValueoperator[] (u32_t varId)
 get abstract value of variable
 
virtual const AbstractValueoperator[] (u32_t varId) const
 get abstract value of variable
 
virtual AbstractValueload (u32_t addr)
 
virtual const AbstractValueload (u32_t addr) const
 
void store (u32_t addr, const AbstractValue &val)
 
bool inVarToAddrsTable (u32_t id) const
 whether the variable is in varToAddrs table
 
virtual bool inVarToValTable (u32_t id) const
 whether the variable is in varToVal table
 
bool inAddrToAddrsTable (u32_t id) const
 whether the memory address stores memory addresses
 
virtual bool inAddrToValTable (u32_t id) const
 whether the memory address stores abstract value
 
const VarToAbsValMapgetVarToVal () const
 get var2val map
 
const AddrToAbsValMapgetLocToVal () const
 get loc2val map
 
AbstractState widening (const AbstractState &other)
 domain widen with other, and return the widened domain
 
AbstractState narrowing (const AbstractState &other)
 domain narrow with other, and return the narrowed domain
 
void joinWith (const AbstractState &other)
 domain join with other, important! other widen this.
 
void updateAddrStateOnly (const AbstractState &other)
 Replace address-taken (ObjVar) state with other's, preserving ValVar state.
 
void meetWith (const AbstractState &other)
 domain meet with other, important! other widen this.
 
void addToFreedAddrs (NodeID addr)
 
const Set< NodeID > & getFreedAddrs () const
 
bool isFreedMem (u32_t addr) const
 
void printAbstractState () const
 
std::string toString () const
 
u32_t hash () const
 
bool eqVarToValMap (const VarToAbsValMap &lhs, const VarToAbsValMap &rhs) const
 
bool geqVarToValMap (const VarToAbsValMap &lhs, const VarToAbsValMap &rhs) const
 
bool equals (const AbstractState &other) const
 
AbstractStateoperator= (const AbstractState &rhs)
 Assignment operator.
 
AbstractStateoperator= (AbstractState &&rhs)
 operator= move constructor
 
bool operator== (const AbstractState &rhs) const
 
bool operator!= (const AbstractState &rhs) const
 
bool operator< (const AbstractState &rhs) const
 
bool operator>= (const AbstractState &rhs) const
 
void clear ()
 
void clearValVars ()
 

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 bool isNullMem (u32_t addr)
 
static bool isBlackHoleObjAddr (u32_t addr)
 

Protected Attributes

VarToAbsValMap _varToAbsVal
 Map a variable (symbol) to its abstract value.
 
AddrToAbsValMap _addrToAbsVal
 Map a memory address to its stored abstract value.
 
Set< NodeID_freedAddrs
 

Friends

class SVFIR2AbsState
 
class RelationSolver
 

Detailed Description

Definition at line 55 of file AbstractState.h.

Member Typedef Documentation

◆ AddrToAbsValMap

Definition at line 61 of file AbstractState.h.

◆ VarToAbsValMap

Definition at line 60 of file AbstractState.h.

Constructor & Destructor Documentation

◆ AbstractState() [1/4]

SVF::AbstractState::AbstractState ( )
inline

default constructor

Definition at line 63 of file AbstractState.h.

64 {
65 }

◆ AbstractState() [2/4]

SVF::AbstractState::AbstractState ( VarToAbsValMap _varToValMap,
AddrToAbsValMap _locToValMap 
)
inline

Definition at line 67 of file AbstractState.h.

VarToAbsValMap _varToAbsVal
Map a variable (symbol) to its abstract value.
AddrToAbsValMap _addrToAbsVal
Map a memory address to its stored abstract value.
llvm::IRBuilder IRBuilder
Definition BasicTypes.h:76

◆ AbstractState() [3/4]

SVF::AbstractState::AbstractState ( const AbstractState rhs)
inline

copy constructor

Definition at line 70 of file AbstractState.h.

70 : _varToAbsVal(rhs.getVarToVal()), _addrToAbsVal(rhs.getLocToVal()), _freedAddrs(rhs._freedAddrs)
71 {
72
73 }
Set< NodeID > _freedAddrs

◆ ~AbstractState()

virtual SVF::AbstractState::~AbstractState ( )
virtualdefault

◆ AbstractState() [4/4]

SVF::AbstractState::AbstractState ( AbstractState &&  rhs)
inline

move constructor

Definition at line 100 of file AbstractState.h.

100 : _varToAbsVal(std::move(rhs._varToAbsVal)),
101 _addrToAbsVal(std::move(rhs._addrToAbsVal)),
102 _freedAddrs(std::move(rhs._freedAddrs))
103 {
104
105 }

Member Function Documentation

◆ addToFreedAddrs()

void SVF::AbstractState::addToFreedAddrs ( NodeID  addr)
inline

Definition at line 274 of file AbstractState.h.

275 {
276 _freedAddrs.insert(addr);
277 }

◆ bottom()

AbstractState SVF::AbstractState::bottom ( ) const
inline

Set all value bottom.

Definition at line 108 of file AbstractState.h.

109 {
110 AbstractState inv = *this;
111 for (auto &item: inv._varToAbsVal)
112 {
113 if (item.second.isInterval())
114 item.second.getInterval().set_to_bottom();
115 }
116 return inv;
117 }
cJSON * item
Definition cJSON.h:222
AbstractState()
default constructor

◆ clear()

void SVF::AbstractState::clear ( )
inline

Definition at line 348 of file AbstractState.h.

349 {
350 _addrToAbsVal.clear();
351 _varToAbsVal.clear();
352 _freedAddrs.clear();
353 }

◆ clearValVars()

void SVF::AbstractState::clearValVars ( )
inline

Drop all top-level variables (ValVars), keeping ObjVar storage and freed addresses intact. Used when building a cycle snapshot so the ValVar set is controlled by the caller rather than whatever was cached at the seed node.

Definition at line 359 of file AbstractState.h.

360 {
361 _varToAbsVal.clear();
362 }

◆ equals()

bool AbstractState::equals ( const AbstractState other) const

Definition at line 38 of file AbstractState.cpp.

39{
40 return *this == other;
41}

◆ eqVarToValMap()

bool AbstractState::eqVarToValMap ( const VarToAbsValMap lhs,
const VarToAbsValMap rhs 
) const

Definition at line 318 of file AbstractState.cpp.

319{
320 if (lhs.size() != rhs.size()) return false;
321 for (const auto &item: lhs)
322 {
323 auto it = rhs.find(item.first);
324 if (it == rhs.end())
325 return false;
326 if (!item.second.equals(it->second))
327 return false;
328 }
329 return true;
330}

◆ geqVarToValMap()

bool AbstractState::geqVarToValMap ( const VarToAbsValMap lhs,
const VarToAbsValMap rhs 
) const

Definition at line 332 of file AbstractState.cpp.

333{
334 if (rhs.empty()) return true;
335 for (const auto &item: rhs)
336 {
337 auto it = lhs.find(item.first);
338 if (it == lhs.end()) return false;
339 if (!it->second.getInterval().contain(
340 item.second.getInterval()))
341 return false;
342 }
343 return true;
344}

◆ getFreedAddrs()

const Set< NodeID > & SVF::AbstractState::getFreedAddrs ( ) const
inline

Definition at line 279 of file AbstractState.h.

280 {
281 return _freedAddrs;
282 }

◆ getIDFromAddr()

u32_t SVF::AbstractState::getIDFromAddr ( u32_t  addr) const
inline

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

Definition at line 94 of file AbstractState.h.

95 {
96 return _freedAddrs.count(addr) ? AddressValue::getInternalID(BlackHoleObjAddr) : AddressValue::getInternalID(addr);
97 }
#define BlackHoleObjAddr
static u32_t getInternalID(u32_t idx)
Return the internal index if idx is an address otherwise return the value of idx.

◆ getLocToVal()

const AddrToAbsValMap & SVF::AbstractState::getLocToVal ( ) const
inline

get loc2val map

Definition at line 250 of file AbstractState.h.

251 {
252 return _addrToAbsVal;
253 }

◆ getVarToVal()

const VarToAbsValMap & SVF::AbstractState::getVarToVal ( ) const
inline

get var2val map

Definition at line 244 of file AbstractState.h.

245 {
246 return _varToAbsVal;
247 }

◆ getVirtualMemAddress()

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

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

Definition at line 82 of file AbstractState.h.

83 {
85 }
static u32_t getVirtualMemAddress(u32_t idx)
The physical address starts with 0x7f...... + idx.

◆ hash()

u32_t AbstractState::hash ( ) const

Definition at line 43 of file AbstractState.cpp.

44{
45 size_t h = getVarToVal().size() * 2;
47 for (const auto &t: getVarToVal())
48 {
49 h ^= hf(t.first) + 0x9e3779b9 + (h << 6) + (h >> 2);
50 }
51 size_t h2 = getLocToVal().size() * 2;
52 for (const auto &t: getLocToVal())
53 {
54 h2 ^= hf(t.first) + 0x9e3779b9 + (h2 << 6) + (h2 >> 2);
55 }
57 return pairH({h, h2});
58}
const AddrToAbsValMap & getLocToVal() const
get loc2val map
const VarToAbsValMap & getVarToVal() const
get var2val map

◆ inAddrToAddrsTable()

bool SVF::AbstractState::inAddrToAddrsTable ( u32_t  id) const
inline

whether the memory address stores memory addresses

Definition at line 218 of file AbstractState.h.

219 {
220 if (_addrToAbsVal.find(id)!= _addrToAbsVal.end())
221 {
222 if (_addrToAbsVal.at(id).isAddr())
223 {
224 return true;
225 }
226 }
227 return false;
228 }

◆ inAddrToValTable()

virtual bool SVF::AbstractState::inAddrToValTable ( u32_t  id) const
inlinevirtual

whether the memory address stores abstract value

Definition at line 231 of file AbstractState.h.

232 {
233 if (_addrToAbsVal.find(id) != _addrToAbsVal.end())
234 {
235 if (_addrToAbsVal.at(id).isInterval())
236 {
237 return true;
238 }
239 }
240 return false;
241 }

◆ initObjVar()

void AbstractState::initObjVar ( const ObjVar objVar)

Definition at line 163 of file AbstractState.cpp.

164{
165 NodeID varId = objVar->getId();
166
167 // Check if the object variable has an associated value
168
169 const BaseObjVar* obj = PAG::getPAG()->getBaseObject(objVar->getId());
170
171 // Handle constant data, arrays, and structures
172 if (obj->isConstDataOrConstGlobal() || obj->isConstantArray() || obj->isConstantStruct())
173 {
174 if (const ConstIntObjVar* consInt = SVFUtil::dyn_cast<ConstIntObjVar>(objVar))
175 {
176 s64_t numeral = consInt->getSExtValue();
177 (*this)[varId] = IntervalValue(numeral, numeral);
178 }
179 else if (const ConstFPObjVar* consFP = SVFUtil::dyn_cast<ConstFPObjVar>(objVar))
180 {
181 (*this)[varId] = IntervalValue(consFP->getFPValue(), consFP->getFPValue());
182 }
183 else if (SVFUtil::isa<ConstNullPtrObjVar>(objVar))
184 {
185 (*this)[varId] = IntervalValue(0, 0);
186 }
187 else if (SVFUtil::isa<GlobalObjVar>(objVar))
188 {
190 }
191 else if (obj->isConstantArray() || obj->isConstantStruct())
192 {
193 (*this)[varId] = IntervalValue::top();
194 }
195 else
196 {
197 (*this)[varId] = IntervalValue::top();
198 }
199 }
200 // Handle non-constant memory objects
201 else
202 {
204 }
205 return;
206}
static u32_t getVirtualMemAddress(u32_t idx)
The physical address starts with 0x7f...... + idx.
static IntervalValue top()
Create the IntervalValue [-inf, +inf].
const BaseObjVar * getBaseObject(NodeID id) const
Definition SVFIR.h:496
static SVFIR * getPAG(bool buildFromFile=false)
Singleton design here to make sure we only have one instance during any analysis.
Definition SVFIR.h:118
u32_t NodeID
Definition GeneralType.h:56
signed long long s64_t
Definition GeneralType.h:50

◆ inVarToAddrsTable()

bool SVF::AbstractState::inVarToAddrsTable ( u32_t  id) const
inline

whether the variable is in varToAddrs table

Definition at line 196 of file AbstractState.h.

197 {
198 if (_varToAbsVal.find(id)!= _varToAbsVal.end())
199 {
200 if (_varToAbsVal.at(id).isAddr())
201 return true;
202 }
203 return false;
204 }

◆ inVarToValTable()

virtual bool SVF::AbstractState::inVarToValTable ( u32_t  id) const
inlinevirtual

whether the variable is in varToVal table

Definition at line 207 of file AbstractState.h.

208 {
209 if (_varToAbsVal.find(id) != _varToAbsVal.end())
210 {
211 if (_varToAbsVal.at(id).isInterval())
212 return true;
213 }
214 return false;
215 }

◆ isBlackHoleObjAddr()

static bool SVF::AbstractState::isBlackHoleObjAddr ( u32_t  addr)
inlinestatic

Definition at line 145 of file AbstractState.h.

146 {
147 return addr == BlackHoleObjAddr;
148 }

◆ isFreedMem()

bool SVF::AbstractState::isFreedMem ( u32_t  addr) const
inline

Definition at line 284 of file AbstractState.h.

285 {
286 return _freedAddrs.find(addr) != _freedAddrs.end();
287 }

◆ isNullMem()

static bool SVF::AbstractState::isNullMem ( u32_t  addr)
inlinestatic

Definition at line 140 of file AbstractState.h.

141 {
142 return addr == NullMemAddr;
143 }
#define NullMemAddr

◆ isVirtualMemAddress()

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

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

Definition at line 88 of file AbstractState.h.

89 {
91 }
static bool isVirtualMemAddress(u32_t val)
Check bit value of val start with 0x7F000000, filter by 0xFF000000.

◆ joinWith()

void AbstractState::joinWith ( const AbstractState other)

domain join with other, important! other widen this.

Definition at line 103 of file AbstractState.cpp.

104{
105 for (auto it = other._varToAbsVal.begin(); it != other._varToAbsVal.end(); ++it)
106 {
107 auto key = it->first;
108 auto oit = _varToAbsVal.find(key);
109 if (oit != _varToAbsVal.end())
110 {
111 oit->second.join_with(it->second);
112 }
113 else
114 {
115 _varToAbsVal.emplace(key, it->second);
116 }
117 }
118 for (auto it = other._addrToAbsVal.begin(); it != other._addrToAbsVal.end(); ++it)
119 {
120 auto key = it->first;
121 auto oit = _addrToAbsVal.find(key);
122 if (oit != _addrToAbsVal.end())
123 {
124 oit->second.join_with(it->second);
125 }
126 else
127 {
128 _addrToAbsVal.emplace(key, it->second);
129 }
130 }
131 _freedAddrs.insert(other._freedAddrs.begin(), other._freedAddrs.end());
132}

◆ load() [1/2]

virtual AbstractValue & SVF::AbstractState::load ( u32_t  addr)
inlinevirtual

Definition at line 173 of file AbstractState.h.

174 {
175 assert(isVirtualMemAddress(addr) && "not virtual address?");
177 return _addrToAbsVal[objId];
178 }
unsigned u32_t
Definition CommandLine.h:18
u32_t getIDFromAddr(u32_t addr) const
Return the internal index if addr is an address otherwise return the value of idx.
static bool isVirtualMemAddress(u32_t val)
Check bit value of val start with 0x7F000000, filter by 0xFF000000.

◆ load() [2/2]

virtual const AbstractValue & SVF::AbstractState::load ( u32_t  addr) const
inlinevirtual

Definition at line 180 of file AbstractState.h.

181 {
182 assert(isVirtualMemAddress(addr) && "not virtual address?");
184 return _addrToAbsVal.at(objId);
185 }

◆ meetWith()

void AbstractState::meetWith ( const AbstractState other)

domain meet with other, important! other widen this.

Definition at line 135 of file AbstractState.cpp.

136{
137 for (auto it = other._varToAbsVal.begin(); it != other._varToAbsVal.end(); ++it)
138 {
139 auto key = it->first;
140 auto oit = _varToAbsVal.find(key);
141 if (oit != _varToAbsVal.end())
142 {
143 oit->second.meet_with(it->second);
144 }
145 }
146 for (auto it = other._addrToAbsVal.begin(); it != other._addrToAbsVal.end(); ++it)
147 {
148 auto key = it->first;
149 auto oit = _addrToAbsVal.find(key);
150 if (oit != _addrToAbsVal.end())
151 {
152 oit->second.meet_with(it->second);
153 }
154 }
156 std::set_intersection(_freedAddrs.begin(), _freedAddrs.end(),
157 other._freedAddrs.begin(), other._freedAddrs.end(),
158 std::inserter(intersection, intersection.begin()));
159 _freedAddrs = std::move(intersection);
160}

◆ narrowing()

AbstractState AbstractState::narrowing ( const AbstractState other)

domain narrow with other, and return the narrowed domain

Definition at line 81 of file AbstractState.cpp.

82{
83 AbstractState es = *this;
84 for (auto it = es._varToAbsVal.begin(); it != es._varToAbsVal.end(); ++it)
85 {
86 auto key = it->first;
87 if (other._varToAbsVal.find(key) != other._varToAbsVal.end())
88 if (it->second.isInterval() && other._varToAbsVal.at(key).isInterval())
89 it->second.getInterval().narrow_with(other._varToAbsVal.at(key).getInterval());
90 }
91 for (auto it = es._addrToAbsVal.begin(); it != es._addrToAbsVal.end(); ++it)
92 {
93 auto key = it->first;
94 if (other._addrToAbsVal.find(key) != other._addrToAbsVal.end())
95 if (it->second.isInterval() && other._addrToAbsVal.at(key).isInterval())
96 it->second.getInterval().narrow_with(other._addrToAbsVal.at(key).getInterval());
97 }
98 return es;
99
100}

◆ operator!=()

bool SVF::AbstractState::operator!= ( const AbstractState rhs) const
inline

Definition at line 333 of file AbstractState.h.

334 {
335 return !(*this == rhs);
336 }

◆ operator<()

bool SVF::AbstractState::operator< ( const AbstractState rhs) const
inline

Definition at line 338 of file AbstractState.h.

339 {
340 return !(*this >= rhs);
341 }

◆ operator=() [1/2]

AbstractState & SVF::AbstractState::operator= ( AbstractState &&  rhs)
inline

operator= move constructor

Definition at line 316 of file AbstractState.h.

317 {
318 if (&rhs != this)
319 {
320 _varToAbsVal = std::move(rhs._varToAbsVal);
321 _addrToAbsVal = std::move(rhs._addrToAbsVal);
322 _freedAddrs = std::move(rhs._freedAddrs);
323 }
324 return *this;
325 }

◆ operator=() [2/2]

AbstractState & SVF::AbstractState::operator= ( const AbstractState rhs)
inline

Assignment operator.

Definition at line 304 of file AbstractState.h.

305 {
306 if (&rhs != this)
307 {
308 _varToAbsVal = rhs._varToAbsVal;
309 _addrToAbsVal = rhs._addrToAbsVal;
310 _freedAddrs = rhs._freedAddrs;
311 }
312 return *this;
313 }

◆ operator==()

bool SVF::AbstractState::operator== ( const AbstractState rhs) const
inline

Definition at line 327 of file AbstractState.h.

328 {
329 return eqVarToValMap(_varToAbsVal, rhs.getVarToVal()) &&
330 eqVarToValMap(_addrToAbsVal, rhs.getLocToVal());
331 }
bool eqVarToValMap(const VarToAbsValMap &lhs, const VarToAbsValMap &rhs) const

◆ operator>=()

bool SVF::AbstractState::operator>= ( const AbstractState rhs) const
inline

Definition at line 343 of file AbstractState.h.

344 {
345 return geqVarToValMap(_varToAbsVal, rhs.getVarToVal()) && geqVarToValMap(_addrToAbsVal, rhs.getLocToVal());
346 }
bool geqVarToValMap(const VarToAbsValMap &lhs, const VarToAbsValMap &rhs) const

◆ operator[]() [1/2]

virtual AbstractValue & SVF::AbstractState::operator[] ( u32_t  varId)
inlinevirtual

get abstract value of variable

Definition at line 160 of file AbstractState.h.

161 {
162 assert(!isVirtualMemAddress(varId) && "varId is a virtual memory address, use load() instead");
163 return _varToAbsVal[varId];
164 }

◆ operator[]() [2/2]

virtual const AbstractValue & SVF::AbstractState::operator[] ( u32_t  varId) const
inlinevirtual

get abstract value of variable

Definition at line 167 of file AbstractState.h.

168 {
169 assert(!isVirtualMemAddress(varId) && "varId is a virtual memory address, use load() instead");
170 return _varToAbsVal.at(varId);
171 }

◆ printAbstractState()

void AbstractState::printAbstractState ( ) const

Definition at line 208 of file AbstractState.cpp.

209{
210 SVFUtil::outs() << "-----------Var and Value-----------\n";
211 u32_t fieldWidth = 20;
212 SVFUtil::outs().flags(std::ios::left);
213 std::vector<std::pair<u32_t, AbstractValue>> varToAbsValVec(_varToAbsVal.begin(), _varToAbsVal.end());
214 std::sort(varToAbsValVec.begin(), varToAbsValVec.end(), [](const auto &a, const auto &b)
215 {
216 return a.first < b.first;
217 });
218 for (const auto &item: varToAbsValVec)
219 {
220 SVFUtil::outs() << std::left << std::setw(fieldWidth) << ("Var" + std::to_string(item.first));
221 if (item.second.isInterval())
222 {
223 SVFUtil::outs() << " Value: " << item.second.getInterval().toString() << "\n";
224 }
225 else if (item.second.isAddr())
226 {
227 SVFUtil::outs() << " Value: {";
228 u32_t i = 0;
229 for (const auto& addr: item.second.getAddrs())
230 {
231 ++i;
232 if (i < item.second.getAddrs().size())
233 {
234 SVFUtil::outs() << "0x" << std::hex << addr << ", ";
235 }
236 else
237 {
238 SVFUtil::outs() << "0x" << std::hex << addr;
239 }
240 }
241 SVFUtil::outs() << "}\n";
242 }
243 else
244 {
245 SVFUtil::outs() << " Value: ⊥\n";
246 }
247 }
248
249 std::vector<std::pair<u32_t, AbstractValue>> addrToAbsValVec(_addrToAbsVal.begin(), _addrToAbsVal.end());
250 std::sort(addrToAbsValVec.begin(), addrToAbsValVec.end(), [](const auto &a, const auto &b)
251 {
252 return a.first < b.first;
253 });
254
255 for (const auto& item: addrToAbsValVec)
256 {
257 std::ostringstream oss;
258 oss << "0x" << std::hex << AbstractState::getVirtualMemAddress(item.first);
259 SVFUtil::outs() << std::left << std::setw(fieldWidth) << oss.str();
260 if (item.second.isInterval())
261 {
262 SVFUtil::outs() << " Value: " << item.second.getInterval().toString() << "\n";
263 }
264 else if (item.second.isAddr())
265 {
266 SVFUtil::outs() << " Value: {";
267 u32_t i = 0;
268 for (const auto& addr: item.second.getAddrs())
269 {
270 ++i;
271 if (i < item.second.getAddrs().size())
272 {
273 SVFUtil::outs() << "0x" << std::hex << addr << ", ";
274 }
275 else
276 {
277 SVFUtil::outs() << "0x" << std::hex << addr;
278 }
279 }
280 SVFUtil::outs() << "}\n";
281 }
282 else
283 {
284 SVFUtil::outs() << " Value: ⊥\n";
285 }
286 }
287 SVFUtil::outs() << "-----------------------------------------\n";
288}
cJSON * a
Definition cJSON.cpp:2560
const cJSON *const b
Definition cJSON.h:255
std::ostream & outs()
Overwrite llvm::outs()
Definition SVFUtil.h:52

◆ sliceState()

AbstractState SVF::AbstractState::sliceState ( Set< u32_t > &  sl)
inline

Copy some values and return a new IntervalExeState.

Definition at line 132 of file AbstractState.h.

133 {
135 for (u32_t id: sl)
136 inv._varToAbsVal[id] = _varToAbsVal[id];
137 return inv;
138 }

◆ store()

void SVF::AbstractState::store ( u32_t  addr,
const AbstractValue val 
)
inline

Definition at line 187 of file AbstractState.h.

188 {
189 assert(isVirtualMemAddress(addr) && "not virtual address?");
191 if (isNullMem(addr)) return;
193 }
static bool isNullMem(u32_t addr)

◆ top()

AbstractState SVF::AbstractState::top ( ) const
inline

Set all value top.

Definition at line 120 of file AbstractState.h.

121 {
122 AbstractState inv = *this;
123 for (auto &item: inv._varToAbsVal)
124 {
125 if (item.second.isInterval())
126 item.second.getInterval().set_to_top();
127 }
128 return inv;
129 }

◆ toString()

std::string AbstractState::toString ( ) const

Definition at line 290 of file AbstractState.cpp.

291{
292 u32_t varIntervals = 0, varAddrs = 0, varBottom = 0;
293 for (const auto& item : _varToAbsVal)
294 {
295 if (item.second.isInterval()) ++varIntervals;
296 else if (item.second.isAddr()) ++varAddrs;
297 else ++varBottom;
298 }
300 for (const auto& item : _addrToAbsVal)
301 {
302 if (item.second.isInterval()) ++addrIntervals;
303 else if (item.second.isAddr()) ++addrAddrs;
304 else ++addrBottom;
305 }
306 std::ostringstream oss;
307 oss << "AbstractState {\n"
308 << " VarToAbsVal: " << _varToAbsVal.size() << " entries ("
309 << varIntervals << " intervals, " << varAddrs << " addresses, " << varBottom << " bottom)\n"
310 << " AddrToAbsVal: " << _addrToAbsVal.size() << " entries ("
311 << addrIntervals << " intervals, " << addrAddrs << " addresses, " << addrBottom << " bottom)\n"
312 << " FreedAddrs: " << _freedAddrs.size() << "\n"
313 << "}";
314 return oss.str();
315}

◆ updateAddrStateOnly()

void SVF::AbstractState::updateAddrStateOnly ( const AbstractState other)
inline

Replace address-taken (ObjVar) state with other's, preserving ValVar state.

Definition at line 265 of file AbstractState.h.

266 {
267 _addrToAbsVal = other._addrToAbsVal;
268 _freedAddrs = other._freedAddrs;
269 }

◆ widening()

AbstractState AbstractState::widening ( const AbstractState other)

domain widen with other, and return the widened domain

Definition at line 60 of file AbstractState.cpp.

61{
62 // widen interval
63 AbstractState es = *this;
64 for (auto it = es._varToAbsVal.begin(); it != es._varToAbsVal.end(); ++it)
65 {
66 auto key = it->first;
67 if (other._varToAbsVal.find(key) != other._varToAbsVal.end())
68 if (it->second.isInterval() && other._varToAbsVal.at(key).isInterval())
69 it->second.getInterval().widen_with(other._varToAbsVal.at(key).getInterval());
70 }
71 for (auto it = es._addrToAbsVal.begin(); it != es._addrToAbsVal.end(); ++it)
72 {
73 auto key = it->first;
74 if (other._addrToAbsVal.find(key) != other._addrToAbsVal.end())
75 if (it->second.isInterval() && other._addrToAbsVal.at(key).isInterval())
76 it->second.getInterval().widen_with(other._addrToAbsVal.at(key).getInterval());
77 }
78 return es;
79}

Friends And Related Symbol Documentation

◆ RelationSolver

Definition at line 58 of file AbstractState.h.

◆ SVFIR2AbsState

friend class SVFIR2AbsState
friend

Definition at line 57 of file AbstractState.h.

Member Data Documentation

◆ _addrToAbsVal

AddrToAbsValMap SVF::AbstractState::_addrToAbsVal
protected

Map a memory address to its stored abstract value.

Definition at line 153 of file AbstractState.h.

◆ _freedAddrs

Set<NodeID> SVF::AbstractState::_freedAddrs
protected

Definition at line 154 of file AbstractState.h.

◆ _varToAbsVal

VarToAbsValMap SVF::AbstractState::_varToAbsVal
protected

Map a variable (symbol) to its abstract value.

Definition at line 152 of file AbstractState.h.


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