Static Value-Flow Analysis
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. More...
 
 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. More...
 
const PointsToIterator operator++ (int)
 Post-increment: it++. More...
 
u32_t operator* () const
 Dereference: *it. More...
 
bool operator== (const PointsToIterator &rhs) const
 Equality: *this == rhs. More...
 
bool operator!= (const PointsToIterator &rhs) const
 Inequality: *this != rhs. More...
 

Private Member Functions

bool atEnd () const
 

Private Attributes

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

Detailed Description

Definition at line 181 of file PointsTo.h.

Member Typedef Documentation

◆ difference_type

Definition at line 186 of file PointsTo.h.

◆ iterator_category

using SVF::PointsTo::PointsToIterator::iterator_category = std::forward_iterator_tag

Definition at line 184 of file PointsTo.h.

◆ pointer

Definition at line 187 of file PointsTo.h.

◆ reference

Definition at line 188 of file PointsTo.h.

◆ value_type

Definition at line 185 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 411 of file PointsTo.cpp.

412  : pt(pt.pt)
413 {
414  if (this->pt->type == PointsTo::Type::SBV)
415  {
416  new (&sbvIt) SparseBitVector<>::iterator(pt.sbvIt);
417  }
418  else if (this->pt->type == PointsTo::Type::CBV)
419  {
420  new (&cbvIt) CoreBitVector::iterator(pt.cbvIt);
421  }
422  else if (this->pt->type == PointsTo::Type::BV)
423  {
424  new (&bvIt) BitVector::iterator(pt.bvIt);
425  }
426  else
427  {
428  assert(false && "PointsToIterator::PointsToIterator&: unknown type");
429  abort();
430  }
431 }
const_iterator iterator
Definition: CoreBitVector.h:38
CoreBitVector::iterator cbvIt
Definition: PointsTo.h:228
SparseBitVector ::iterator sbvIt
Definition: PointsTo.h:227
const PointsTo * pt
PointsTo we are iterating over.
Definition: PointsTo.h:222
BitVector::iterator bvIt
Definition: PointsTo.h:229
enum Type type
Type of this points-to set.
Definition: PointsTo.h:174
SparseBitVectorIterator iterator

◆ PointsToIterator() [3/4]

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

Definition at line 433 of file PointsTo.cpp.

434  : pt(pt.pt)
435 {
436  if (this->pt->type == PointsTo::Type::SBV)
437  {
439  }
440  else if (this->pt->type == PointsTo::Type::CBV)
441  {
442  new (&cbvIt) CoreBitVector::iterator(std::move(pt.cbvIt));
443  }
444  else if (this->pt->type == PointsTo::Type::BV)
445  {
446  new (&bvIt) BitVector::iterator(std::move(pt.bvIt));
447  }
448  else
449  {
450  assert(false && "PointsToIterator::PointsToIterator&&: unknown type");
451  abort();
452  }
453 }
constexpr std::remove_reference< T >::type && move(T &&t) noexcept
Definition: SVFUtil.h:447

◆ 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 389 of file PointsTo.cpp.

390  : pt(pt)
391 {
392  if (pt->type == Type::CBV)
393  {
394  new (&cbvIt) CoreBitVector::iterator(end ? pt->cbv.end() : pt->cbv.begin());
395  }
396  else if (pt->type == Type::SBV)
397  {
399  }
400  else if (pt->type == Type::BV)
401  {
402  new (&bvIt) BitVector::iterator(end ? pt->bv.end() : pt->bv.begin());
403  }
404  else
405  {
406  assert(false && "PointsToIterator::PointsToIterator: unknown type");
407  abort();
408  }
409 }
const_iterator begin(void) const
const_iterator end(void) const
BitVector bv
Bit vector backing.
Definition: PointsTo.h:170
const_iterator end() const
Definition: PointsTo.h:132
CoreBitVector cbv
Core bit vector backing.
Definition: PointsTo.h:168
SparseBitVector sbv
Sparse bit vector backing.
Definition: PointsTo.h:166
iterator end() const
iterator begin() const

Member Function Documentation

◆ atEnd()

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

Definition at line 552 of file PointsTo.cpp.

553 {
554  assert(pt != nullptr && "PointsToIterator::atEnd: iterator iterating over nothing!");
555  if (pt->type == Type::CBV) return cbvIt == pt->cbv.end();
556  else if (pt->type == Type::SBV) return sbvIt == pt->sbv.end();
557  else if (pt->type == Type::BV) return bvIt == pt->bv.end();
558  else
559  {
560  assert(false && "PointsToIterator::atEnd: unknown type");
561  abort();
562  }
563 }

◆ operator!=()

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

Inequality: *this != rhs.

Definition at line 545 of file PointsTo.cpp.

546 {
547  assert(pt == rhs.pt
548  && "PointsToIterator::!=: comparing iterators from different PointsTos!");
549  return !(*this == rhs);
550 }

◆ operator*()

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

Dereference: *it.

Definition at line 516 of file PointsTo.cpp.

517 {
518  assert(!atEnd() && "PointsToIterator: dereferencing end!");
519  if (pt->type == Type::CBV) return pt->getExternalNode(*cbvIt);
520  else if (pt->type == Type::SBV) return pt->getExternalNode(*sbvIt);
521  else if (pt->type == Type::BV) return pt->getExternalNode(*bvIt);
522  else
523  {
524  assert(false && "PointsToIterator::*: unknown type");
525  abort();
526  }
527 }
NodeID getExternalNode(NodeID n) const
Returns reverseNodeMapping[n], checking for nullptr and size.
Definition: PointsTo.cpp:349

◆ operator++() [1/2]

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

Pre-increment: ++it.

Definition at line 497 of file PointsTo.cpp.

498 {
499  assert(!atEnd() && "PointsToIterator::++(pre): incrementing past end!");
500  if (pt->type == Type::CBV) ++cbvIt;
501  else if (pt->type == Type::SBV) ++sbvIt;
502  else if (pt->type == Type::BV) ++bvIt;
503  else assert(false && "PointsToIterator::++(void): unknown type");
504 
505  return *this;
506 }

◆ operator++() [2/2]

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

Post-increment: it++.

Definition at line 508 of file PointsTo.cpp.

509 {
510  assert(!atEnd() && "PointsToIterator::++(pre): incrementing past end!");
511  PointsToIterator old = *this;
512  ++*this;
513  return old;
514 }
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 455 of file PointsTo.cpp.

456 {
457  this->pt = rhs.pt;
458 
459  if (this->pt->type == PointsTo::Type::SBV)
460  {
461  new (&sbvIt) SparseBitVector<>::iterator(rhs.sbvIt);
462  }
463  else if (this->pt->type == PointsTo::Type::CBV)
464  {
465  new (&cbvIt) CoreBitVector::iterator(rhs.cbvIt);
466  }
467  else if (this->pt->type == PointsTo::Type::BV)
468  {
469  new (&bvIt) BitVector::iterator(rhs.bvIt);
470  }
471  else assert(false && "PointsToIterator::PointsToIterator&: unknown type");
472 
473  return *this;
474 }

◆ operator=() [2/2]

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

Definition at line 476 of file PointsTo.cpp.

477 {
478  this->pt = rhs.pt;
479 
480  if (this->pt->type == PointsTo::Type::SBV)
481  {
482  new (&sbvIt) SparseBitVector<>::iterator(std::move(rhs.sbvIt));
483  }
484  else if (this->pt->type == PointsTo::Type::CBV)
485  {
486  new (&cbvIt) CoreBitVector::iterator(std::move(rhs.cbvIt));
487  }
488  else if (this->pt->type == PointsTo::Type::BV)
489  {
490  new (&bvIt) BitVector::iterator(std::move(rhs.bvIt));
491  }
492  else assert(false && "PointsToIterator::PointsToIterator&&: unknown type");
493 
494  return *this;
495 }

◆ operator==()

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

Equality: *this == rhs.

Definition at line 529 of file PointsTo.cpp.

530 {
531  assert(pt == rhs.pt
532  && "PointsToIterator::==: comparing iterators from different PointsTos!");
533 
534  // Handles end implicitly.
535  if (pt->type == Type::CBV) return cbvIt == rhs.cbvIt;
536  else if (pt->type == Type::SBV) return sbvIt == rhs.sbvIt;
537  else if (pt->type == Type::BV) return bvIt == rhs.bvIt;
538  else
539  {
540  assert(false && "PointsToIterator::==: unknown type");
541  abort();
542  }
543 }

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 229 of file PointsTo.h.

◆ cbvIt

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

Definition at line 228 of file PointsTo.h.

◆ pt

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

PointsTo we are iterating over.

Definition at line 222 of file PointsTo.h.

◆ sbvIt

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

Definition at line 227 of file PointsTo.h.


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