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)
 
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 275 of file AbstractState.h.

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

◆ 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 344 of file AbstractState.h.

345 {
346 _addrToAbsVal.clear();
347 _varToAbsVal.clear();
348 _freedAddrs.clear();
349 }

◆ 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 355 of file AbstractState.h.

356 {
357 _varToAbsVal.clear();
358 }

◆ equals()

bool AbstractState::equals ( const AbstractState other) const

Definition at line 39 of file AbstractState.cpp.

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

◆ eqVarToValMap()

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

Definition at line 325 of file AbstractState.cpp.

326{
327 if (lhs.size() != rhs.size()) return false;
328 for (const auto &item: lhs)
329 {
330 auto it = rhs.find(item.first);
331 if (it == rhs.end())
332 return false;
333 if (!item.second.equals(it->second))
334 return false;
335 }
336 return true;
337}

◆ geqVarToValMap()

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

Definition at line 339 of file AbstractState.cpp.

340{
341 if (rhs.empty()) return true;
342 for (const auto &item: rhs)
343 {
344 auto it = lhs.find(item.first);
345 if (it == lhs.end()) return false;
346 if (!it->second.getInterval().contain(
347 item.second.getInterval()))
348 return false;
349 }
350 return true;
351}

◆ 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 44 of file AbstractState.cpp.

45{
46 size_t h = getVarToVal().size() * 2;
48 for (const auto &t: getVarToVal())
49 {
50 h ^= hf(t.first) + 0x9e3779b9 + (h << 6) + (h >> 2);
51 }
52 size_t h2 = getLocToVal().size() * 2;
53 for (const auto &t: getLocToVal())
54 {
55 h2 ^= hf(t.first) + 0x9e3779b9 + (h2 << 6) + (h2 >> 2);
56 }
58 return pairH({h, h2});
59}
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 170 of file AbstractState.cpp.

171{
172 NodeID varId = objVar->getId();
173
174 // Check if the object variable has an associated value
175
176 const BaseObjVar* obj = PAG::getPAG()->getBaseObject(objVar->getId());
177
178 // Handle constant data, arrays, and structures
179 if (obj->isConstDataOrConstGlobal() || obj->isConstantArray() || obj->isConstantStruct())
180 {
181 if (const ConstIntObjVar* consInt = SVFUtil::dyn_cast<ConstIntObjVar>(objVar))
182 {
183 s64_t numeral = consInt->getSExtValue();
184 (*this)[varId] = IntervalValue(numeral, numeral);
185 }
186 else if (const ConstFPObjVar* consFP = SVFUtil::dyn_cast<ConstFPObjVar>(objVar))
187 {
188 (*this)[varId] = IntervalValue(consFP->getFPValue(), consFP->getFPValue());
189 }
190 else if (SVFUtil::isa<ConstNullPtrObjVar>(objVar))
191 {
192 (*this)[varId] = IntervalValue(0, 0);
193 }
194 else if (SVFUtil::isa<GlobalObjVar>(objVar))
195 {
197 }
198 else if (obj->isConstantArray() || obj->isConstantStruct())
199 {
200 (*this)[varId] = IntervalValue::top();
201 }
202 else
203 {
204 (*this)[varId] = IntervalValue::top();
205 }
206 }
207 // Handle non-constant memory objects
208 else
209 {
211 }
212 return;
213}
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 280 of file AbstractState.h.

281 {
282 return _freedAddrs.find(addr) != _freedAddrs.end();
283 }

◆ 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 104 of file AbstractState.cpp.

105{
106 // In semi-sparse mode, skip ValVar (_varToAbsVal) merge — ValVars are
107 // pulled on demand from def-sites via getAbstractValue.
108 // In dense mode, merge everything.
110 {
111 for (auto it = other._varToAbsVal.begin(); it != other._varToAbsVal.end(); ++it)
112 {
113 auto key = it->first;
114 auto oit = _varToAbsVal.find(key);
115 if (oit != _varToAbsVal.end())
116 {
117 oit->second.join_with(it->second);
118 }
119 else
120 {
121 _varToAbsVal.emplace(key, it->second);
122 }
123 }
124 }
125 for (auto it = other._addrToAbsVal.begin(); it != other._addrToAbsVal.end(); ++it)
126 {
127 auto key = it->first;
128 auto oit = _addrToAbsVal.find(key);
129 if (oit != _addrToAbsVal.end())
130 {
131 oit->second.join_with(it->second);
132 }
133 else
134 {
135 _addrToAbsVal.emplace(key, it->second);
136 }
137 }
138 _freedAddrs.insert(other._freedAddrs.begin(), other._freedAddrs.end());
139}
static const OptionMap< u32_t > AESparsity
Definition Options.h:243

◆ 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 142 of file AbstractState.cpp.

143{
144 for (auto it = other._varToAbsVal.begin(); it != other._varToAbsVal.end(); ++it)
145 {
146 auto key = it->first;
147 auto oit = _varToAbsVal.find(key);
148 if (oit != _varToAbsVal.end())
149 {
150 oit->second.meet_with(it->second);
151 }
152 }
153 for (auto it = other._addrToAbsVal.begin(); it != other._addrToAbsVal.end(); ++it)
154 {
155 auto key = it->first;
156 auto oit = _addrToAbsVal.find(key);
157 if (oit != _addrToAbsVal.end())
158 {
159 oit->second.meet_with(it->second);
160 }
161 }
163 std::set_intersection(_freedAddrs.begin(), _freedAddrs.end(),
164 other._freedAddrs.begin(), other._freedAddrs.end(),
165 std::inserter(intersection, intersection.begin()));
166 _freedAddrs = std::move(intersection);
167}

◆ narrowing()

AbstractState AbstractState::narrowing ( const AbstractState other)

domain narrow with other, and return the narrowed domain

Definition at line 82 of file AbstractState.cpp.

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

◆ operator!=()

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

Definition at line 329 of file AbstractState.h.

330 {
331 return !(*this == rhs);
332 }

◆ operator<()

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

Definition at line 334 of file AbstractState.h.

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

◆ operator=() [1/2]

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

operator= move constructor

Definition at line 312 of file AbstractState.h.

313 {
314 if (&rhs != this)
315 {
316 _varToAbsVal = std::move(rhs._varToAbsVal);
317 _addrToAbsVal = std::move(rhs._addrToAbsVal);
318 _freedAddrs = std::move(rhs._freedAddrs);
319 }
320 return *this;
321 }

◆ operator=() [2/2]

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

Assignment operator.

Definition at line 300 of file AbstractState.h.

301 {
302 if (&rhs != this)
303 {
304 _varToAbsVal = rhs._varToAbsVal;
305 _addrToAbsVal = rhs._addrToAbsVal;
306 _freedAddrs = rhs._freedAddrs;
307 }
308 return *this;
309 }

◆ operator==()

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

Definition at line 323 of file AbstractState.h.

324 {
325 return eqVarToValMap(_varToAbsVal, rhs.getVarToVal()) &&
326 eqVarToValMap(_addrToAbsVal, rhs.getLocToVal());
327 }
bool eqVarToValMap(const VarToAbsValMap &lhs, const VarToAbsValMap &rhs) const

◆ operator>=()

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

Definition at line 339 of file AbstractState.h.

340 {
341 return geqVarToValMap(_varToAbsVal, rhs.getVarToVal()) && geqVarToValMap(_addrToAbsVal, rhs.getLocToVal());
342 }
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 215 of file AbstractState.cpp.

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

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

◆ updateAddrStateOnly()

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

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

Definition at line 266 of file AbstractState.h.

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

◆ widening()

AbstractState AbstractState::widening ( const AbstractState other)

domain widen with other, and return the widened domain

Definition at line 61 of file AbstractState.cpp.

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

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: