32 else assert(
false &&
"PointsTo::PointsTo: unknown type");
42 else assert(
false &&
"PointsTo::PointsTo&: unknown type");
52 else assert(
false &&
"PointsTo::PointsTo&&: unknown type");
59 else if (
type ==
BV)
bv.~BitVector();
60 else assert(
false &&
"PointsTo::destroyBacking: unknown type");
87 else assert(
false &&
"PointsTo::PointsTo=&: unknown type");
99 this->
type = rhs.type;
105 else assert(
false &&
"PointsTo::PointsTo=&&: unknown type");
114 else if (
type ==
BV)
return bv.empty();
117 assert(
false &&
"PointsTo::empty: unknown type");
127 else if (
type ==
BV)
return bv.count();
130 assert(
false &&
"PointsTo::count: unknown type");
140 else assert(
false &&
"PointsTo::clear: unknown type");
151 assert(
false &&
"PointsTo::test: unknown type");
161 else if (
type ==
BV)
return bv.test_and_set(
n);
164 assert(
false &&
"PointsTo::test_and_set: unknown type");
175 else assert(
false &&
"PointsTo::set: unknown type");
184 else assert(
false &&
"PointsTo::reset: unknown type");
189 assert(
metaSame(rhs) &&
"PointsTo::contains: mappings of operands do not match!");
193 else if (
type ==
BV)
return bv.contains(rhs.
bv);
196 assert(
false &&
"PointsTo::contains: unknown type");
203 assert(
metaSame(rhs) &&
"PointsTo::intersects: mappings of operands do not match!");
207 else if (
type ==
BV)
return bv.intersects(rhs.
bv);
210 assert(
false &&
"PointsTo::intersects: unknown type");
217 if (
count() == 0)
return -1;
223 assert(
metaSame(rhs) &&
"PointsTo::==: mappings of operands do not match!");
230 assert(
false &&
"PointsTo::==: unknown type");
238 assert(
metaSame(rhs) &&
"PointsTo::!=: mappings of operands do not match!");
240 return !(*
this == rhs);
245 assert(
metaSame(rhs) &&
"PointsTo::|=: mappings of operands do not match!");
252 assert(
false &&
"PointsTo::|=: unknown type");
260 bool changed =
false;
272 assert(
metaSame(rhs) &&
"PointsTo::&=: mappings of operands do not match!");
279 assert(
false &&
"PointsTo::&=: unknown type");
286 assert(
metaSame(rhs) &&
"PointsTo::-=: mappings of operands do not match!");
288 if (
type ==
CBV)
return cbv.intersectWithComplement(rhs.
cbv);
289 else if (
type ==
SBV)
return sbv.intersectWithComplement(rhs.
sbv);
290 else if (
type ==
BV)
return bv.intersectWithComplement(rhs.
bv);
293 assert(
false &&
"PointsTo::-=: unknown type");
300 assert(
metaSame(rhs) &&
"PointsTo::intersectWithComplement: mappings of operands do not match!");
302 if (
type ==
CBV)
return cbv.intersectWithComplement(rhs.
cbv);
303 else if (
type ==
SBV)
return sbv.intersectWithComplement(rhs.
sbv);
304 else if (
type ==
BV)
return bv.intersectWithComplement(rhs.
bv);
306 assert(
false &&
"PointsTo::intersectWithComplement(PT): unknown type");
312 assert(
metaSame(rhs) &&
"PointsTo::intersectWithComplement: mappings of operands do not match!");
313 assert(
metaSame(lhs) &&
"PointsTo::intersectWithComplement: mappings of operands do not match!");
317 else if (
type ==
BV)
bv.intersectWithComplement(lhs.
bv, rhs.
bv);
320 assert(
false &&
"PointsTo::intersectWithComplement(PT, PT): unknown type");
337 std::hash<SparseBitVector<>> h;
340 else if (
type ==
BV)
return bv.hash();
344 assert(
false &&
"PointsTo::hash: unknown type");
396 for (
const NodeID o : *
this) newPt.
set(o);
397 *
this = std::move(newPt);
404 if (
pt->type == Type::CBV)
406 new (&cbvIt) CoreBitVector::iterator(end ? pt->cbv.end() : pt->cbv.begin());
408 else if (
pt->type == Type::SBV)
410 new (&sbvIt) SparseBitVector<>::iterator(end ? pt->sbv.end() : pt->sbv.begin());
412 else if (
pt->type == Type::BV)
414 new (&bvIt) BitVector::iterator(end ? pt->bv.end() : pt->bv.begin());
418 assert(false &&
"PointsToIterator::PointsToIterator: unknown type");
426 if (this->pt->type == PointsTo::Type::SBV)
428 new (&sbvIt) SparseBitVector<>::iterator(pt.sbvIt);
430 else if (this->pt->type == PointsTo::Type::CBV)
432 new (&cbvIt) CoreBitVector::iterator(pt.cbvIt);
434 else if (this->pt->type == PointsTo::Type::BV)
436 new (&bvIt) BitVector::iterator(pt.bvIt);
440 assert(false &&
"PointsToIterator::PointsToIterator&: unknown type");
448 if (this->
pt->type == PointsTo::Type::SBV)
452 else if (this->
pt->type == PointsTo::Type::CBV)
456 else if (this->
pt->type == PointsTo::Type::BV)
462 assert(
false &&
"PointsToIterator::PointsToIterator&&: unknown type");
471 if (this->
pt->type == PointsTo::Type::SBV)
475 else if (this->
pt->type == PointsTo::Type::CBV)
479 else if (this->
pt->type == PointsTo::Type::BV)
483 else assert(
false &&
"PointsToIterator::PointsToIterator&: unknown type");
492 if (this->
pt->type == PointsTo::Type::SBV)
496 else if (this->
pt->type == PointsTo::Type::CBV)
500 else if (this->
pt->type == PointsTo::Type::BV)
504 else assert(
false &&
"PointsToIterator::PointsToIterator&&: unknown type");
511 assert(!
atEnd() &&
"PointsToIterator::++(pre): incrementing past end!");
512 if (
pt->type == Type::CBV) ++
cbvIt;
513 else if (
pt->type == Type::SBV) ++
sbvIt;
514 else if (
pt->type == Type::BV) ++
bvIt;
515 else assert(
false &&
"PointsToIterator::++(void): unknown type");
522 assert(!
atEnd() &&
"PointsToIterator::++(pre): incrementing past end!");
530 assert(!
atEnd() &&
"PointsToIterator: dereferencing end!");
531 if (
pt->type == Type::CBV)
return pt->getExternalNode(*
cbvIt);
532 else if (
pt->type == Type::SBV)
return pt->getExternalNode(*
sbvIt);
533 else if (
pt->type == Type::BV)
return pt->getExternalNode(*
bvIt);
536 assert(
false &&
"PointsToIterator::*: unknown type");
544 &&
"PointsToIterator::==: comparing iterators from different PointsTos!");
548 else if (
pt->type == Type::SBV)
return sbvIt == rhs.
sbvIt;
549 else if (
pt->type == Type::BV)
return bvIt == rhs.
bvIt;
552 assert(
false &&
"PointsToIterator::==: unknown type");
560 &&
"PointsToIterator::!=: comparing iterators from different PointsTos!");
561 return !(*
this == rhs);
566 assert(
pt !=
nullptr &&
"PointsToIterator::atEnd: iterator iterating over nothing!");
567 if (
pt->type == Type::CBV)
return cbvIt ==
pt->cbv.end();
568 else if (
pt->type == Type::SBV)
return sbvIt ==
pt->sbv.end();
569 else if (
pt->type == Type::BV)
return bvIt ==
pt->bv.end();
572 assert(
false &&
"PointsToIterator::atEnd: unknown type");
PRIVATE SvfCore SvfLLVM if(NOT LLVM_ENABLE_RTTI) if(MSVC) target_compile_options($
Carries around command line options.
u32_t operator*() const
Dereference: *it.
CoreBitVector::iterator cbvIt
SparseBitVector ::iterator sbvIt
const PointsTo * pt
PointsTo we are iterating over.
bool operator!=(const PointsToIterator &rhs) const
Inequality: *this != rhs.
PointsToIterator()=delete
Deleted because we don't want iterators with null pt.
const PointsToIterator & operator++()
Pre-increment: ++it.
PointsToIterator & operator=(const PointsToIterator &rhs)
bool operator==(const PointsToIterator &rhs) const
Equality: *this == rhs.
bool test_and_set(u32_t n)
bool empty() const
Returns true if set is empty.
void clear()
Empty the set.
static MappingPtr getCurrentBestReverseNodeMapping()
MappingPtr reverseNodeMapping
Internal nodes -> external nodes.
void reset(u32_t n)
Removes n from the set.
bool operator-=(const PointsTo &rhs)
PointsTo & operator=(const PointsTo &rhs)
Copy assignment.
size_t hash() const
Return a hash of this set.
bool operator&=(const PointsTo &rhs)
static MappingPtr currentBestReverseNodeMapping
Likewise, but reversed.
MappingPtr getNodeMapping() const
BitVector bv
Bit vector backing.
bool operator==(const PointsTo &rhs) const
Returns true if this set and rhs contain exactly the same elements.
const_iterator end() const
CoreBitVector cbv
Core bit vector backing.
NodeID getExternalNode(NodeID n) const
Returns reverseNodeMapping[n], checking for nullptr and size.
std::shared_ptr< std::vector< NodeID > > MappingPtr
static void setCurrentBestNodeMapping(MappingPtr newCurrentBestNodeMapping, MappingPtr newCurrentBestReverseNodeMapping)
bool operator!=(const PointsTo &rhs) const
Returns true if either this set or rhs has an element not in the other.
static MappingPtr currentBestNodeMapping
Best node mapping we know of the for the analyses at hand.
u32_t count() const
Returns number of elements.
bool metaSame(const PointsTo &pt) const
bool operator|=(const PointsTo &rhs)
enum Type type
Type of this points-to set.
void set(u32_t n)
Inserts n in the set.
bool contains(const PointsTo &rhs) const
Returns true if this set is a superset of rhs.
PointsTo()
Construct empty points-to set.
MappingPtr nodeMapping
External nodes -> internal nodes.
NodeBS toNodeBS() const
Returns this points-to set as a NodeBS.
const_iterator begin() const
bool intersects(const PointsTo &rhs) const
Returns true if this set and rhs share any elements.
static MappingPtr getCurrentBestNodeMapping()
SparseBitVector sbv
Sparse bit vector backing.
NodeID getInternalNode(NodeID n) const
Returns nodeMapping[n], checking for nullptr and size.
bool test(u32_t n) const
Returns true if n is in this set.
bool intersectWithComplement(const PointsTo &rhs)
SparseBitVectorIterator iterator
IntervalValue operator-(const IntervalValue &lhs, const IntervalValue &rhs)
Subtract IntervalValues.
IntervalValue operator&(const IntervalValue &lhs, const IntervalValue &rhs)
Bitwise AND of IntervalValues.
IntervalValue operator|(const IntervalValue &lhs, const IntervalValue &rhs)
Bitwise OR of IntervalValues.