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

#include <PointsTo.h>

Public Types

using iterator_category = std::forward_iterator_tag
 
using value_type = u32_t
 
using difference_type = std::ptrdiff_t
 
using pointer = u32_t *
 
using reference = u32_t &
 

Public Member Functions

 PointsToIterator ()=delete
 Deleted because we don't want iterators with null pt.
 
 PointsToIterator (const PointsToIterator &pt)
 
 PointsToIterator (PointsToIterator &&pt) noexcept
 
 PointsToIterator (const PointsTo *pt, bool end=false)
 
PointsToIteratoroperator= (const PointsToIterator &rhs)
 
PointsToIteratoroperator= (PointsToIterator &&rhs) noexcept
 
const PointsToIteratoroperator++ ()
 Pre-increment: ++it.
 
const PointsToIterator operator++ (int)
 Post-increment: it++.
 
u32_t operator* () const
 Dereference: *it.
 
bool operator== (const PointsToIterator &rhs) const
 Equality: *this == rhs.
 
bool operator!= (const PointsToIterator &rhs) const
 Inequality: *this != rhs.
 

Private Member Functions

bool atEnd () const
 

Private Attributes

const PointsTopt
 PointsTo we are iterating over.
 
union { 
 
   SparseBitVector ::iterator   sbvIt 
 
   CoreBitVector::iterator   cbvIt 
 
   BitVector::iterator   bvIt 
 
};  
 

Detailed Description

Definition at line 187 of file PointsTo.h.

Member Typedef Documentation

◆ difference_type

Definition at line 192 of file PointsTo.h.

◆ iterator_category

Definition at line 190 of file PointsTo.h.

◆ pointer

Definition at line 193 of file PointsTo.h.

◆ reference

Definition at line 194 of file PointsTo.h.

◆ value_type

Definition at line 191 of file PointsTo.h.

Constructor & Destructor Documentation

◆ PointsToIterator() [1/4]

SVF::PointsTo::PointsToIterator::PointsToIterator ( )
delete

Deleted because we don't want iterators with null pt.

◆ PointsToIterator() [2/4]

SVF::PointsTo::PointsToIterator::PointsToIterator ( const PointsToIterator pt)

Definition at line 423 of file PointsTo.cpp.

424 : pt(pt.pt)
425{
426 if (this->pt->type == PointsTo::Type::SBV)
427 {
429 }
430 else if (this->pt->type == PointsTo::Type::CBV)
431 {
432 new (&cbvIt) CoreBitVector::iterator(pt.cbvIt);
433 }
434 else if (this->pt->type == PointsTo::Type::BV)
435 {
436 new (&bvIt) BitVector::iterator(pt.bvIt);
437 }
438 else
439 {
440 assert(false && "PointsToIterator::PointsToIterator&: unknown type");
441 abort();
442 }
443}
const_iterator iterator
CoreBitVector::iterator cbvIt
Definition PointsTo.h:234
SparseBitVector ::iterator sbvIt
Definition PointsTo.h:233
const PointsTo * pt
PointsTo we are iterating over.
Definition PointsTo.h:228
BitVector::iterator bvIt
Definition PointsTo.h:235
enum Type type
Type of this points-to set.
Definition PointsTo.h:180
SparseBitVectorIterator iterator
llvm::IRBuilder IRBuilder
Definition BasicTypes.h:76

◆ PointsToIterator() [3/4]

SVF::PointsTo::PointsToIterator::PointsToIterator ( PointsToIterator &&  pt)
noexcept

Definition at line 445 of file PointsTo.cpp.

446 : pt(pt.pt)
447{
448 if (this->pt->type == PointsTo::Type::SBV)
449 {
450 new (&sbvIt) SparseBitVector<>::iterator(std::move(pt.sbvIt));
451 }
452 else if (this->pt->type == PointsTo::Type::CBV)
453 {
454 new (&cbvIt) CoreBitVector::iterator(std::move(pt.cbvIt));
455 }
456 else if (this->pt->type == PointsTo::Type::BV)
457 {
458 new (&bvIt) BitVector::iterator(std::move(pt.bvIt));
459 }
460 else
461 {
462 assert(false && "PointsToIterator::PointsToIterator&&: unknown type");
463 abort();
464 }
465}

◆ PointsToIterator() [4/4]

SVF::PointsTo::PointsToIterator::PointsToIterator ( const PointsTo pt,
bool  end = false 
)
explicit

Returns an iterator to the beginning of pt if end is false, and to the end of pt if end is true.

Definition at line 401 of file PointsTo.cpp.

402 : pt(pt)
403{
404 if (pt->type == Type::CBV)
405 {
407 }
408 else if (pt->type == Type::SBV)
409 {
411 }
412 else if (pt->type == Type::BV)
413 {
414 new (&bvIt) BitVector::iterator(end ? pt->bv.end() : pt->bv.begin());
415 }
416 else
417 {
418 assert(false && "PointsToIterator::PointsToIterator: unknown type");
419 abort();
420 }
421}
const_iterator begin(void) const
const_iterator end(void) const
BitVector bv
Bit vector backing.
Definition PointsTo.h:176
const_iterator end() const
Definition PointsTo.h:133
CoreBitVector cbv
Core bit vector backing.
Definition PointsTo.h:174
SparseBitVector sbv
Sparse bit vector backing.
Definition PointsTo.h:172
iterator begin() const

Member Function Documentation

◆ atEnd()

bool SVF::PointsTo::PointsToIterator::atEnd ( ) const
private

Definition at line 564 of file PointsTo.cpp.

565{
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();
570 else
571 {
572 assert(false && "PointsToIterator::atEnd: unknown type");
573 abort();
574 }
575}

◆ operator!=()

bool SVF::PointsTo::PointsToIterator::operator!= ( const PointsToIterator rhs) const

Inequality: *this != rhs.

Definition at line 557 of file PointsTo.cpp.

558{
559 assert(pt == rhs.pt
560 && "PointsToIterator::!=: comparing iterators from different PointsTos!");
561 return !(*this == rhs);
562}

◆ operator*()

NodeID SVF::PointsTo::PointsToIterator::operator* ( ) const

Dereference: *it.

Definition at line 528 of file PointsTo.cpp.

529{
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);
534 else
535 {
536 assert(false && "PointsToIterator::*: unknown type");
537 abort();
538 }
539}
NodeID getExternalNode(NodeID n) const
Returns reverseNodeMapping[n], checking for nullptr and size.
Definition PointsTo.cpp:361

◆ operator++() [1/2]

const PointsTo::PointsToIterator & SVF::PointsTo::PointsToIterator::operator++ ( )

Pre-increment: ++it.

Definition at line 509 of file PointsTo.cpp.

510{
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");
516
517 return *this;
518}

◆ operator++() [2/2]

const PointsTo::PointsToIterator SVF::PointsTo::PointsToIterator::operator++ ( int  )

Post-increment: it++.

Definition at line 520 of file PointsTo.cpp.

521{
522 assert(!atEnd() && "PointsToIterator::++(pre): incrementing past end!");
523 PointsToIterator old = *this;
524 ++*this;
525 return old;
526}
PointsToIterator()=delete
Deleted because we don't want iterators with null pt.

◆ operator=() [1/2]

PointsTo::PointsToIterator & SVF::PointsTo::PointsToIterator::operator= ( const PointsToIterator rhs)

Definition at line 467 of file PointsTo.cpp.

468{
469 this->pt = rhs.pt;
470
471 if (this->pt->type == PointsTo::Type::SBV)
472 {
474 }
475 else if (this->pt->type == PointsTo::Type::CBV)
476 {
477 new (&cbvIt) CoreBitVector::iterator(rhs.cbvIt);
478 }
479 else if (this->pt->type == PointsTo::Type::BV)
480 {
481 new (&bvIt) BitVector::iterator(rhs.bvIt);
482 }
483 else assert(false && "PointsToIterator::PointsToIterator&: unknown type");
484
485 return *this;
486}

◆ operator=() [2/2]

PointsTo::PointsToIterator & SVF::PointsTo::PointsToIterator::operator= ( PointsToIterator &&  rhs)
noexcept

Definition at line 488 of file PointsTo.cpp.

489{
490 this->pt = rhs.pt;
491
492 if (this->pt->type == PointsTo::Type::SBV)
493 {
494 new (&sbvIt) SparseBitVector<>::iterator(std::move(rhs.sbvIt));
495 }
496 else if (this->pt->type == PointsTo::Type::CBV)
497 {
498 new (&cbvIt) CoreBitVector::iterator(std::move(rhs.cbvIt));
499 }
500 else if (this->pt->type == PointsTo::Type::BV)
501 {
502 new (&bvIt) BitVector::iterator(std::move(rhs.bvIt));
503 }
504 else assert(false && "PointsToIterator::PointsToIterator&&: unknown type");
505
506 return *this;
507}

◆ operator==()

bool SVF::PointsTo::PointsToIterator::operator== ( const PointsToIterator rhs) const

Equality: *this == rhs.

Definition at line 541 of file PointsTo.cpp.

542{
543 assert(pt == rhs.pt
544 && "PointsToIterator::==: comparing iterators from different PointsTos!");
545
546 // Handles end implicitly.
547 if (pt->type == Type::CBV) return cbvIt == rhs.cbvIt;
548 else if (pt->type == Type::SBV) return sbvIt == rhs.sbvIt;
549 else if (pt->type == Type::BV) return bvIt == rhs.bvIt;
550 else
551 {
552 assert(false && "PointsToIterator::==: unknown type");
553 abort();
554 }
555}

Member Data Documentation

◆ [union]

Iterator into the backing data structure. Discriminated by pt->type. TODO: std::variant when we move to C++17.

◆ bvIt

BitVector::iterator SVF::PointsTo::PointsToIterator::bvIt

Definition at line 235 of file PointsTo.h.

◆ cbvIt

CoreBitVector::iterator SVF::PointsTo::PointsToIterator::cbvIt

Definition at line 234 of file PointsTo.h.

◆ pt

const PointsTo* SVF::PointsTo::PointsToIterator::pt
private

PointsTo we are iterating over.

Definition at line 228 of file PointsTo.h.

◆ sbvIt

SparseBitVector ::iterator SVF::PointsTo::PointsToIterator::sbvIt

Definition at line 233 of file PointsTo.h.


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