#include <AbstractState.h>
Definition at line 58 of file AbstractState.h.
◆ AddrToAbsValMap
◆ VarToAbsValMap
◆ AbstractState() [1/4]
SVF::AbstractState::AbstractState |
( |
| ) |
|
|
inline |
◆ AbstractState() [2/4]
Definition at line 73 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
◆ AbstractState() [3/4]
◆ ~AbstractState()
virtual SVF::AbstractState::~AbstractState |
( |
| ) |
|
|
virtualdefault |
◆ AbstractState() [4/4]
◆ bottom()
Set all value bottom.
Definition at line 153 of file AbstractState.h.
154 {
157 {
158 if (
item.second.isInterval())
159 item.second.getInterval().set_to_bottom();
160 }
162 }
AbstractState()
default constructor
◆ clear()
void SVF::AbstractState::clear |
( |
| ) |
|
|
inline |
◆ equals()
◆ eqVarToValMap()
Definition at line 326 of file AbstractState.h.
327 {
328 if (
lhs.size() !=
rhs.size())
return false;
330 {
333 return false;
334 if (!
item.second.equals(
it->second))
335 return false;
336 else
337 {
338 }
339 }
340 return true;
341 }
◆ geqVarToValMap()
Definition at line 357 of file AbstractState.h.
358 {
359 if (
rhs.empty())
return true;
361 {
363 if (
it ==
lhs.end())
return false;
364
365 if (!
it->second.getInterval().contain(
366 item.second.getInterval()))
367 return false;
368
369 }
370 return true;
371 }
◆ getAllocaInstByteSize()
Definition at line 486 of file AbstractState.cpp.
487{
490 {
492 if (
objvar->getMemObj()->isConstantByteSize())
493 {
496 }
497
498 else
499 {
500 const std::vector<SVFValue*>&
sizes =
addr->getArrSize();
501
505 {
507 {
509 }
513 }
515 }
516 }
517 assert (
false &&
"Addr rhs value is not ObjVar");
519}
virtual bool inVarToValTable(u32_t id) const
whether the variable is in varToVal table
s64_t getIntNumeral() const
NodeID getValueNode(const SVFValue *V)
const BoundedInt & ub() const
Return the upper bound.
static const Option< u32_t > MaxFieldLimit
Maximum number of field derivations for an object.
static SVFIR * getPAG(bool buildFromFile=false)
Singleton design here to make sure we only have one instance during any analysis.
◆ getByteOffset()
Definition at line 298 of file AbstractState.cpp.
299{
300
301 if (
gep->isConstantOffset())
303
305
306
307 for (
int i =
gep->getOffsetVarAndGepTypePairVec().size() - 1;
i >= 0;
i--)
308 {
311
312
314 {
319 elemByteSize =
gep->getAccessPath().gepSrcPointeeType()->getByteSize();
320 else
321 assert(
false &&
"idxOperandType must be ArrType or PtrType");
322
324 {
325
330 }
331 else
332 {
334
337 else
338 {
339
349 }
350 }
351 }
352
354 {
356 }
357 else
358 {
359 assert(
false &&
"gep type pair only support arr/ptr/struct");
360 }
361 }
362 return res;
363}
Carries around command line options.
u32_t getByteSize() const
◆ getElementIndex()
Definition at line 225 of file AbstractState.cpp.
226{
227
228 if (
gep->isConstantOffset())
230
232
233 for (
int i =
gep->getOffsetVarAndGepTypePairVec().size() - 1;
i >= 0;
i--)
234 {
236 const SVFVar*
var =
gep->getOffsetVarAndGepTypePairVec()[
i].first;
238
239
242
243
246 else
247 {
251 else
252 {
255 }
256 }
257
258
259 if (SVFUtil::isa<SVFPointerType>(
type))
260 {
261 u32_t elemNum =
gep->getAccessPath().getElementNum(
gep->getAccessPath().gepSrcPointeeType());
264 }
265
266 else
267 {
269 {
272 {
274 }
275 else
276 {
279 }
280 }
281 else
283 }
284
285
287 }
288
289
291 if (res.isBottom())
292 {
294 }
295 return res;
296}
std::pair< const SVFVar *, const SVFType * > IdxOperandPair
const BoundedInt & lb() const
Return the lower bound.
static const Option< bool > ModelArrays
std::vector< u32_t > & getFlattenedElemIdxVec()
u32_t getFlattenedElemIdx(const SVFType *T, u32_t origId)
Flattened element idx of an array or struct by considering stride.
static SymbolTableInfo * SymbolInfo()
Singleton design here to make sure we only have one instance during any analysis.
const StInfo * getTypeInfo(const SVFType *T) const
Get struct info.
◆ getGepObjAddrs()
Definition at line 156 of file AbstractState.cpp.
157{
164 {
166 for (
const auto&
addr : addrs.getAddrs())
167 {
173 }
174 }
175
177}
static u32_t getVirtualMemAddress(u32_t idx)
The physical address starts with 0x7f...... + idx.
static u32_t getInternalID(u32_t idx)
Return the internal index if idx is an address otherwise return the value of idx.
NodeID getGepObjVar(const MemObj *obj, const APOffset &ap)
Get a field SVFIR Object node according to base mem obj and offset.
◆ getInternalID()
Return the internal index if idx is an address otherwise return the value of idx.
Definition at line 114 of file AbstractState.h.
115 {
117 }
static u32_t getInternalID(u32_t idx)
Return the internal index if idx is an address otherwise return the value of idx.
◆ getLocToVal()
◆ getPointeeElement()
if this NodeID in SVFIR is a pointer, get the pointee type e.g arr = (int*) malloc(10*sizeof(int)) getPointeeType(arr) -> return int we can set arr[0]='c', arr[1]='c', arr[2]='\0'
- Parameters
-
call | callnode of memset like api |
Definition at line 465 of file AbstractState.cpp.
466{
469 {
471 for (
auto addr: addrs.getAddrs())
472 {
475 continue;
476 return SVFUtil::dyn_cast<ObjVar>(svfir->
getGNode(
addr_id))->getMemObj()->getType();
477 }
478 }
479 else
480 {
481
482 }
483 return nullptr;
484}
bool inVarToAddrsTable(u32_t id) const
whether the variable is in varToAddrs table
NodeType * getGNode(NodeID id) const
Get a node.
◆ getVarToVal()
◆ getVirtualMemAddress()
The physical address starts with 0x7f...... + idx.
Definition at line 102 of file AbstractState.h.
103 {
105 }
static u32_t getVirtualMemAddress(u32_t idx)
The physical address starts with 0x7f...... + idx.
◆ hash()
u32_t AbstractState::hash |
( |
| ) |
const |
Definition at line 42 of file AbstractState.cpp.
43{
47 {
48 h ^=
hf(t.first) + 0x9e3779b9 + (
h << 6) + (
h >> 2);
49 }
52 {
53 h2 ^=
hf(t.first) + 0x9e3779b9 + (
h2 << 6) + (
h2 >> 2);
54 }
57}
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 234 of file AbstractState.h.
235 {
237 {
239 {
240 return true;
241 }
242 }
243 return false;
244 }
◆ inAddrToValTable()
whether the memory address stores abstract value
Definition at line 247 of file AbstractState.h.
248 {
250 {
252 {
253 return true;
254 }
255 }
256 return false;
257 }
◆ initObjVar()
void AbstractState::initObjVar |
( |
ObjVar * |
objVar | ) |
|
Definition at line 179 of file AbstractState.cpp.
180{
182
183
184
186
187
188 if (
obj->isConstDataOrConstGlobal() ||
obj->isConstantArray() ||
obj->isConstantStruct())
189 {
191 {
194 }
196 {
198 }
199 else if (SVFUtil::isa<ConstantNullPtrObjVar>(
objVar))
200 {
202 }
203 else if (SVFUtil::isa<GlobalObjVar>(
objVar))
204 {
206 }
207 else if (
obj->isConstantArray() ||
obj->isConstantStruct())
208 {
210 }
211 else
212 {
214 }
215 }
216
217 else
218 {
220 }
221 return;
222}
static IntervalValue top()
Create the IntervalValue [-inf, +inf].
◆ inVarToAddrsTable()
bool SVF::AbstractState::inVarToAddrsTable |
( |
u32_t |
id | ) |
const |
|
inline |
whether the variable is in varToAddrs table
Definition at line 208 of file AbstractState.h.
209 {
211 {
213 {
214 return true;
215 }
216 }
217 return false;
218 }
◆ inVarToValTable()
whether the variable is in varToVal table
Definition at line 221 of file AbstractState.h.
222 {
224 {
226 {
227 return true;
228 }
229 }
230 return false;
231 }
◆ isNullPtr()
◆ isVirtualMemAddress()
Check bit value of val start with 0x7F000000, filter by 0xFF000000.
Definition at line 108 of file AbstractState.h.
109 {
111 }
static bool isVirtualMemAddress(u32_t val)
Check bit value of val start with 0x7F000000, filter by 0xFF000000.
◆ joinWith()
domain join with other, important! other widen this.
Definition at line 102 of file AbstractState.cpp.
103{
104 for (
auto it =
other._varToAbsVal.begin();
it !=
other._varToAbsVal.end(); ++
it)
105 {
106 auto key =
it->first;
109 {
110 oit->second.join_with(
it->second);
111 }
112 else
113 {
115 }
116 }
117 for (
auto it =
other._addrToAbsVal.begin();
it !=
other._addrToAbsVal.end(); ++
it)
118 {
119 auto key =
it->first;
122 {
123 oit->second.join_with(
it->second);
124 }
125 else
126 {
128 }
129 }
130}
◆ lessThanVarToValMap()
Definition at line 343 of file AbstractState.h.
344 {
345 if (
lhs.empty())
return !
rhs.empty();
347 {
349 if (
it ==
rhs.end())
return false;
350
351 if (
item.second.getInterval().contain(
it->second.getInterval()))
return false;
352 }
353 return true;
354 }
◆ load()
Definition at line 307 of file AbstractState.h.
308 {
312
313 }
static bool isVirtualMemAddress(u32_t val)
Check bit value of val start with 0x7F000000, filter by 0xFF000000.
◆ loadValue()
Definition at line 365 of file AbstractState.cpp.
366{
369 {
371 }
372 return res;
373}
virtual AbstractValue & load(u32_t addr)
void join_with(const AbstractValue &other)
◆ meetWith()
domain meet with other, important! other widen this.
Definition at line 133 of file AbstractState.cpp.
134{
135 for (
auto it =
other._varToAbsVal.begin();
it !=
other._varToAbsVal.end(); ++
it)
136 {
137 auto key =
it->first;
140 {
141 oit->second.meet_with(
it->second);
142 }
143 }
144 for (
auto it =
other._addrToAbsVal.begin();
it !=
other._addrToAbsVal.end(); ++
it)
145 {
146 auto key =
it->first;
149 {
150 oit->second.meet_with(
it->second);
151 }
152 }
153}
◆ narrowing()
domain narrow with other, and return the narrowed domain
Definition at line 80 of file AbstractState.cpp.
81{
83 for (
auto it =
es._varToAbsVal.begin();
it !=
es._varToAbsVal.end(); ++
it)
84 {
87 if (
it->second.isInterval() &&
other._varToAbsVal.at(
key).isInterval())
88 it->second.getInterval().narrow_with(
other._varToAbsVal.at(
key).getInterval());
89 }
90 for (
auto it =
es._addrToAbsVal.begin();
it !=
es._addrToAbsVal.end(); ++
it)
91 {
93 if (
other._addrToAbsVal.find(
key) !=
other._addrToAbsVal.end())
94 if (
it->second.isInterval() &&
other._addrToAbsVal.at(
key).isInterval())
95 it->second.getInterval().narrow_with(
other._addrToAbsVal.at(
key).getInterval());
96 }
98
99}
◆ operator!=()
◆ operator<()
◆ operator=() [1/2]
operator= move constructor
Definition at line 142 of file AbstractState.h.
143 {
145 {
148 }
149 return *this;
150 }
◆ operator=() [2/2]
◆ operator==()
Definition at line 373 of file AbstractState.h.
374 {
377 }
static bool eqVarToValMap(const VarToAbsValMap &lhs, const VarToAbsValMap &rhs)
◆ operator>=()
Definition at line 390 of file AbstractState.h.
391 {
393 }
static bool geqVarToValMap(const VarToAbsValMap &lhs, const VarToAbsValMap &rhs)
◆ operator[]() [1/2]
◆ operator[]() [2/2]
◆ printAbstractState()
void AbstractState::printAbstractState |
( |
| ) |
const |
Definition at line 383 of file AbstractState.cpp.
384{
390 {
391 return a.first < b.first;
392 });
394 {
396 if (
item.second.isInterval())
397 {
399 }
400 else if (
item.second.isAddr())
401 {
405 {
407 if (
i <
item.second.getAddrs().size())
408 {
410 }
411 else
412 {
414 }
415 }
417 }
418 else
419 {
421 }
422 }
423
426 {
427 return a.first < b.first;
428 });
429
431 {
432 std::ostringstream
oss;
435 if (
item.second.isInterval())
436 {
438 }
439 else if (
item.second.isAddr())
440 {
444 {
446 if (
i <
item.second.getAddrs().size())
447 {
449 }
450 else
451 {
453 }
454 }
456 }
457 else
458 {
460 }
461 }
462 SVFUtil::outs() <<
"-----------------------------------------\n";
463}
std::ostream & outs()
Overwrite llvm::outs()
◆ sliceState()
Copy some values and return a new IntervalExeState.
Definition at line 177 of file AbstractState.h.
◆ store()
Definition at line 299 of file AbstractState.h.
300 {
305 }
static bool isNullPtr(u32_t addr)
◆ storeValue()
Definition at line 375 of file AbstractState.cpp.
376{
378 {
380 }
381}
void store(u32_t addr, const AbstractValue &val)
◆ top()
Set all value top.
Definition at line 165 of file AbstractState.h.
166 {
169 {
170 if (
item.second.isInterval())
171 item.second.getInterval().set_to_top();
172 }
174 }
◆ toString()
std::string SVF::AbstractState::toString |
( |
| ) |
const |
|
inline |
◆ widening()
domain widen with other, and return the widened domain
Definition at line 59 of file AbstractState.cpp.
60{
61
63 for (
auto it =
es._varToAbsVal.begin();
it !=
es._varToAbsVal.end(); ++
it)
64 {
67 if (
it->second.isInterval() &&
other._varToAbsVal.at(
key).isInterval())
68 it->second.getInterval().widen_with(
other._varToAbsVal.at(
key).getInterval());
69 }
70 for (
auto it =
es._addrToAbsVal.begin();
it !=
es._addrToAbsVal.end(); ++
it)
71 {
73 if (
other._addrToAbsVal.find(
key) !=
other._addrToAbsVal.end())
74 if (
it->second.isInterval() &&
other._addrToAbsVal.at(
key).isInterval())
75 it->second.getInterval().widen_with(
other._addrToAbsVal.at(
key).getInterval());
76 }
78}
◆ RelationSolver
◆ SVFIR2AbsState
◆ _addrToAbsVal
Map a memory address to its stored abstract value.
Definition at line 190 of file AbstractState.h.
◆ _varToAbsVal
Map a variable (symbol) to its abstract value.
Definition at line 188 of file AbstractState.h.
The documentation for this class was generated from the following files: