Static Value-Flow Analysis
Loading...
Searching...
No Matches
Classes | Public Types | Public Member Functions | Private Attributes | List of all members
SVF::CondPointsToSet< Cond > Class Template Reference

#include <ConditionalPT.h>

Classes

class  CondPtsSetIterator
 Conditional Points-to Set Iterator. More...
 

Public Types

typedef Map< Cond, PointsToCondPts
 
typedef CondPts::iterator CondPtsIter
 
typedef CondPts::const_iterator CondPtsConstIter
 
typedef CondVar< CondSingleCondVar
 
typedef CondPtsSetIterator iterator
 

Public Member Functions

 CondPointsToSet ()
 Constructor.
 
 CondPointsToSet (const Cond &cond, const PointsTo &pts)
 
 CondPointsToSet (const CondPointsToSet< Cond > &cptsSet)
 Copy constructor.
 
CondPtspointsTo (void)
 Get Conditional PointsTo and standard points-to.
 
const CondPtspointsTo (void) const
 
const PointsTopointsTo (Cond cond) const
 
bool hasPointsTo (Cond cond) const
 
PointsTopointsTo (Cond cond)
 
CondPtsIter cptsBegin ()
 iterators
 
CondPtsIter cptsEnd ()
 
CondPtsConstIter cptsBegin () const
 
CondPtsConstIter cptsEnd () const
 
void clear ()
 
unsigned numElement () const
 Get number of points-to targets.
 
bool empty () const
 Return true if no element in the set.
 
CondPointsToSet< Cond > & operator= (const CondPointsToSet< Cond > &other)
 Overloading operators.
 
bool operator== (const CondPointsToSet< Cond > &rhs) const
 Overloading operator ==.
 
bool aliased (const CondPointsToSet< Cond > &rhs) const
 
bool isSubset (const CondPointsToSet< Cond > &rhs) const
 Check whether this CondPointsToSet is a subset of RHS.
 
bool intersects (const CondPointsToSet< Cond > *rhs) const
 Return TRUE if this and RHS share any common element.
 
void intersectWithComplement (const CondPointsToSet< Cond > &cpts1, const CondPointsToSet< Cond > &cpts2)
 Result of cpts1 & ~cpts2 is stored into this bitmap.
 
void intersectWithComplement (const CondPointsToSet< Cond > &cpts1)
 Result of cur & ~cpts1 is stored into this bitmap.
 
bool operator&= (const CondPointsToSet< Cond > &rhs)
 Overloading operator &=.
 
bool operator!= (const CondPointsToSet< Cond > &rhs)
 Overloading operator !=.
 
bool operator|= (const CondPointsToSet< Cond > &rhs)
 
bool operator< (const CondPointsToSet< Cond > &rhs) const
 
bool test_and_set (const SingleCondVar &var)
 Test and set.
 
bool test (const SingleCondVar &var) const
 
void set (const SingleCondVar &var)
 
void reset (const SingleCondVar &var)
 
void dump (OutStream &O) const
 
std::string dumpStr () const
 
iterator begin ()
 iterators
 
iterator end ()
 
iterator begin () const
 
iterator end () const
 

Private Attributes

CondPts _condPts
 

Detailed Description

template<class Cond>
class SVF::CondPointsToSet< Cond >

Conditional Points-to set

Definition at line 304 of file ConditionalPT.h.

Member Typedef Documentation

◆ CondPts

Definition at line 307 of file ConditionalPT.h.

◆ CondPtsConstIter

template<class Cond >
typedef CondPts::const_iterator SVF::CondPointsToSet< Cond >::CondPtsConstIter

Definition at line 309 of file ConditionalPT.h.

◆ CondPtsIter

template<class Cond >
typedef CondPts::iterator SVF::CondPointsToSet< Cond >::CondPtsIter

Definition at line 308 of file ConditionalPT.h.

◆ iterator

Definition at line 815 of file ConditionalPT.h.

◆ SingleCondVar

template<class Cond >
typedef CondVar<Cond> SVF::CondPointsToSet< Cond >::SingleCondVar

Definition at line 310 of file ConditionalPT.h.

Constructor & Destructor Documentation

◆ CondPointsToSet() [1/3]

template<class Cond >
SVF::CondPointsToSet< Cond >::CondPointsToSet ( )
inline

Constructor.

Definition at line 314 of file ConditionalPT.h.

315 {
316 }

◆ CondPointsToSet() [2/3]

template<class Cond >
SVF::CondPointsToSet< Cond >::CondPointsToSet ( const Cond cond,
const PointsTo pts 
)
inline

Definition at line 317 of file ConditionalPT.h.

318 {
319 _condPts[cond] |= pts;
320 }
llvm::IRBuilder IRBuilder
Definition BasicTypes.h:74

◆ CondPointsToSet() [3/3]

template<class Cond >
SVF::CondPointsToSet< Cond >::CondPointsToSet ( const CondPointsToSet< Cond > &  cptsSet)
inline

Copy constructor.

Definition at line 324 of file ConditionalPT.h.

326 {
327 _condPts = cptsSet.pointsTo();
328 }

Member Function Documentation

◆ aliased()

template<class Cond >
bool SVF::CondPointsToSet< Cond >::aliased ( const CondPointsToSet< Cond > &  rhs) const
inline

Two conditional points-to set are aliased when they access the same memory location under the same condition

Definition at line 434 of file ConditionalPT.h.

435 {
436 if (pointsTo().empty() || rhs.pointsTo().empty())
437 return false;
438 else
439 {
441 for (; lit != elit; ++lit)
442 {
443 const Cond& lc = lit->first;
444 const PointsTo& pts = lit->second;
445 CondPtsConstIter rit = rhs.pointsTo().find(lc);
446 if(rit !=rhs.pointsTo().end())
447 {
448 const PointsTo& rpts = rit->second;
449 if (pts.intersects(rpts))
450 return true;
451 }
452 }
453 return false;
454 }
455 }
CondPtsIter cptsEnd()
CondPts::const_iterator CondPtsConstIter
bool empty() const
Return true if no element in the set.
CondPtsIter cptsBegin()
iterators
CondPts & pointsTo(void)
Get Conditional PointsTo and standard points-to.

◆ begin() [1/2]

template<class Cond >
iterator SVF::CondPointsToSet< Cond >::begin ( )
inline

iterators

Definition at line 818 of file ConditionalPT.h.

819 {
820 return iterator(this);
821 }
CondPtsSetIterator iterator

◆ begin() [2/2]

template<class Cond >
iterator SVF::CondPointsToSet< Cond >::begin ( ) const
inline

Definition at line 828 of file ConditionalPT.h.

829 {
830 return iterator(this);
831 }

◆ clear()

template<class Cond >
void SVF::CondPointsToSet< Cond >::clear ( )
inline

Definition at line 376 of file ConditionalPT.h.

377 {
378 _condPts.clear();
379 }

◆ cptsBegin() [1/2]

template<class Cond >
CondPtsIter SVF::CondPointsToSet< Cond >::cptsBegin ( )
inline

iterators

Definition at line 358 of file ConditionalPT.h.

359 {
360 return _condPts.begin();
361 }

◆ cptsBegin() [2/2]

template<class Cond >
CondPtsConstIter SVF::CondPointsToSet< Cond >::cptsBegin ( ) const
inline

Definition at line 366 of file ConditionalPT.h.

367 {
368 return _condPts.begin();
369 }

◆ cptsEnd() [1/2]

template<class Cond >
CondPtsIter SVF::CondPointsToSet< Cond >::cptsEnd ( )
inline

Definition at line 362 of file ConditionalPT.h.

363 {
364 return _condPts.end();
365 }

◆ cptsEnd() [2/2]

template<class Cond >
CondPtsConstIter SVF::CondPointsToSet< Cond >::cptsEnd ( ) const
inline

Definition at line 370 of file ConditionalPT.h.

371 {
372 return _condPts.end();
373 }

◆ dump()

template<class Cond >
void SVF::CondPointsToSet< Cond >::dump ( OutStream O) const
inline

Definition at line 711 of file ConditionalPT.h.

712 {
715 for (; it != eit; it++)
716 {
717 const PointsTo& pts = it->second;
718 O << "pts{";
720 O << "}";
721 }
722 }
void dumpSet(NodeBS To, OutStream &O=SVFUtil::outs())
Dump sparse bitvector set.
Definition SVFUtil.cpp:148

◆ dumpStr()

template<class Cond >
std::string SVF::CondPointsToSet< Cond >::dumpStr ( ) const
inline

Definition at line 723 of file ConditionalPT.h.

724 {
725 std::string str;
728 for (; it != eit; it++)
729 {
730 const PointsTo& pts = it->second;
731 str += "pts{";
732 for (PointsTo::iterator ii = pts.begin(), ie = pts.end();
733 ii != ie; ii++)
734 {
735 char int2str[16];
736 snprintf(int2str, sizeof(int2str), "%d", *ii);
737 str += int2str;
738 str += " ";
739 }
740 str += "}";
741 }
742 return str;
743 }
const_iterator iterator
Definition PointsTo.h:40

◆ empty()

template<class Cond >
bool SVF::CondPointsToSet< Cond >::empty ( ) const
inline

Return true if no element in the set.

Definition at line 398 of file ConditionalPT.h.

399 {
400 return numElement()==0;
401 }
unsigned numElement() const
Get number of points-to targets.

◆ end() [1/2]

template<class Cond >
iterator SVF::CondPointsToSet< Cond >::end ( )
inline

Definition at line 823 of file ConditionalPT.h.

824 {
825 return iterator(this,true);
826 }

◆ end() [2/2]

template<class Cond >
iterator SVF::CondPointsToSet< Cond >::end ( ) const
inline

Definition at line 833 of file ConditionalPT.h.

834 {
835 return iterator(this,true);
836 }

◆ hasPointsTo()

template<class Cond >
bool SVF::CondPointsToSet< Cond >::hasPointsTo ( Cond  cond) const
inline

Definition at line 346 of file ConditionalPT.h.

347 {
348 return (_condPts.find(cond) != _condPts.end());
349 }

◆ intersects()

template<class Cond >
bool SVF::CondPointsToSet< Cond >::intersects ( const CondPointsToSet< Cond > *  rhs) const
inline

Return TRUE if this and RHS share any common element.

if either cpts is empty, just return.

Definition at line 484 of file ConditionalPT.h.

485 {
487 if (pointsTo().empty() && rhs->pointsTo().empty())
488 return false;
489
490 CondPtsConstIter it = rhs->cptsBegin(), eit = rhs->cptsEnd();
491 for (; it != eit; ++it)
492 {
493 const Cond& cond = it->first;
494 if (hasPointsTo(cond))
495 {
496 const PointsTo& rhs_pts= it->second;
497 const PointsTo& pts= pointsTo(cond);
498 if (pts.intersects(rhs_pts))
499 return true;
500 }
501 }
502
503 return false;
504 }
bool hasPointsTo(Cond cond) const

◆ intersectWithComplement() [1/2]

template<class Cond >
void SVF::CondPointsToSet< Cond >::intersectWithComplement ( const CondPointsToSet< Cond > &  cpts1)
inline

Result of cur & ~cpts1 is stored into this bitmap.

if either cpts is empty, just return.

Definition at line 540 of file ConditionalPT.h.

541 {
543 if (empty() || cpts1.pointsTo().empty())
544 {
545 return;
546 }
547 else
548 {
550 for (; it != eit; ++it)
551 {
552 const Cond& cond = it->first;
553 PointsTo& pts = it->second;
554 if (cpts1.hasPointsTo(cond))
555 {
556 const PointsTo& pts1 = cpts1.pointsTo(cond);
557 pts.intersectWithComplement(pts1);
558 }
559 }
560 }
561 }
CondPts::iterator CondPtsIter

◆ intersectWithComplement() [2/2]

template<class Cond >
void SVF::CondPointsToSet< Cond >::intersectWithComplement ( const CondPointsToSet< Cond > &  cpts1,
const CondPointsToSet< Cond > &  cpts2 
)
inline

Result of cpts1 & ~cpts2 is stored into this bitmap.

Definition at line 507 of file ConditionalPT.h.

508 {
509 if (cpts1.pointsTo().empty())
510 {
511 clear();
512 return;
513 }
514 else if (cpts2.pointsTo().empty())
515 {
516 (*this) = cpts1;
517 }
518 else
519 {
520 CondPtsConstIter it1 = cpts1.cptsBegin(), eit1 = cpts1.cptsEnd();
521 for (; it1 != eit1; ++it1)
522 {
523 const Cond& cond = it1->first;
524 const PointsTo& pts1 = it1->second;
525 PointsTo& pts = pointsTo(cond);
526 if (cpts2.hasPointsTo(cond))
527 {
528 const PointsTo& pts2 = cpts2.pointsTo(cond);
529 pts.intersectWithComplement(pts1, pts2);
530 }
531 else
532 {
533 pts = pts1;
534 }
535 }
536 }
537 }

◆ isSubset()

template<class Cond >
bool SVF::CondPointsToSet< Cond >::isSubset ( const CondPointsToSet< Cond > &  rhs) const
inline

Check whether this CondPointsToSet is a subset of RHS.

Definition at line 458 of file ConditionalPT.h.

459 {
460 if (pointsTo().size() > rhs.pointsTo().size())
461 return false;
462 else
463 {
465 for (; lit != elit; ++lit)
466 {
467 const Cond& lc = lit->first;
468 CondPtsConstIter rit = rhs.pointsTo().find(lc);
469 if (rit == rhs.pointsTo().end())
470 return false;
471 else
472 {
473 const PointsTo& pts = lit->second;
474 const PointsTo& rpts = rit->second;
475 if (!rpts.contains(pts))
476 return false;
477 }
478 }
479 }
480 return true;
481 }

◆ numElement()

template<class Cond >
unsigned SVF::CondPointsToSet< Cond >::numElement ( ) const
inline

Get number of points-to targets.

Definition at line 382 of file ConditionalPT.h.

383 {
384 if (_condPts.empty())
385 return 0;
386 else
387 {
388 unsigned num = 0;
389 for (CondPtsConstIter it = cptsBegin(); it != cptsEnd(); it++)
390 {
391 PointsTo pts = it->second;
392 num += pts.count();
393 }
394 return num;
395 }
396 }

◆ operator!=()

template<class Cond >
bool SVF::CondPointsToSet< Cond >::operator!= ( const CondPointsToSet< Cond > &  rhs)
inline

Overloading operator !=.

Definition at line 601 of file ConditionalPT.h.

602 {
603 return !(*this == rhs);
604 }

◆ operator&=()

Overloading operator &=.

Definition at line 564 of file ConditionalPT.h.

565 {
566 if (empty())
567 {
568 return false;
569 }
570 else if (rhs.empty())
571 {
572 clear();
573 return true;
574 }
575 else
576 {
577 bool changed = false;
578 for (CondPtsIter it = cptsBegin(), eit = cptsEnd(); it != eit; ++it)
579 {
580 const Cond& cond = it->first;
581 PointsTo& pts = it->second;
582 if (rhs.hasPointsTo(cond))
583 {
584 if (pts &= rhs.pointsTo(cond))
585 changed = true;
586 }
587 else
588 {
589 if (!pts.empty())
590 {
591 pts.clear();
592 changed = true;
593 }
594 }
595 }
596 return changed;
597 }
598 }

◆ operator<()

template<class Cond >
bool SVF::CondPointsToSet< Cond >::operator< ( const CondPointsToSet< Cond > &  rhs) const
inline

Compare two CondPointsToSet according to their points-to set size and points-to elements.

  1. CondPointsToSet with smaller points-to set size is smaller than the other;
  2. If the sizes are equal, comparing the conditions and real points-to targets in their points-to elements.

Definition at line 634 of file ConditionalPT.h.

635 {
636 if (pointsTo().size() < rhs.pointsTo().size())
637 return true;
638 else if (pointsTo().size() == rhs.pointsTo().size())
639 {
641 CondPtsConstIter rit = rhs.cptsBegin(), erit = rhs.cptsEnd();
642 for (; lit != elit && rit != erit; ++lit, ++rit)
643 {
644 const Cond& lc = lit->first;
645 const Cond& rc = rit->first;
646 if (lc < rc)
647 return true;
648 else if (lc == rc)
649 {
650 const PointsTo& lpts = lit->second;
651 const PointsTo& rpts = rit->second;
652 if (lpts.count() < rpts.count())
653 return true;
654 else if (lpts.count() == rpts.count())
655 {
656 PointsTo::iterator bit = lpts.begin();
658 PointsTo::iterator rbit = rpts.begin();
660 for (; bit != eit && rbit != reit; bit++, rbit++)
661 {
662 if (*bit < *rbit)
663 return true;
664 else if (*bit > *rbit)
665 return false;
666 }
667 }
668 else
669 return false;
670 }
671 else
672 return false;
673 }
674 }
675 return false;
676 }

◆ operator=()

Overloading operators.

Definition at line 406 of file ConditionalPT.h.

408 {
409 _condPts = other.pointsTo();
410 return *this;
411 }

◆ operator==()

template<class Cond >
bool SVF::CondPointsToSet< Cond >::operator== ( const CondPointsToSet< Cond > &  rhs) const
inline

Overloading operator ==.

Definition at line 414 of file ConditionalPT.h.

415 {
416 // Always remember give the typename when define a template variable
417 if (pointsTo().size() != rhs.pointsTo().size())
418 return false;
420 CondPtsConstIter rit = rhs.cptsBegin(), erit = rhs.cptsEnd();
421 for (; lit != elit && rit != erit; ++lit, ++rit)
422 {
423 const Cond& lc = lit->first;
424 const Cond& rc = rit->first;
425 if (lc != rc || lit->second != rit->second)
426 return false;
427 }
428 return true;
429 }

◆ operator|=()

Overloading operator |= Merge CondPointsToSet of RHS into this one.

Definition at line 610 of file ConditionalPT.h.

611 {
612 bool changed = false;
613 CondPtsConstIter rhsIt = rhs.cptsBegin();
614 CondPtsConstIter rhsEit = rhs.cptsEnd();
615 for (; rhsIt != rhsEit; ++rhsIt)
616 {
617 const Cond& cond = rhsIt->first;
618 const PointsTo& rhsPts = rhsIt->second;
619 PointsTo& pts = pointsTo(cond);
620 if ((pts |= rhsPts))
621 changed = true;
622 }
623 return changed;
624 }

◆ pointsTo() [1/4]

template<class Cond >
PointsTo & SVF::CondPointsToSet< Cond >::pointsTo ( Cond  cond)
inline

Definition at line 350 of file ConditionalPT.h.

351 {
352 return _condPts[cond];
353 }

◆ pointsTo() [2/4]

template<class Cond >
const PointsTo & SVF::CondPointsToSet< Cond >::pointsTo ( Cond  cond) const
inline

Definition at line 340 of file ConditionalPT.h.

341 {
342 CondPtsConstIter it = _condPts.find(cond);
343 assert(it!=_condPts.end() && "do not have pts of such condition!");
344 return it->second;
345 }

◆ pointsTo() [3/4]

template<class Cond >
CondPts & SVF::CondPointsToSet< Cond >::pointsTo ( void  )
inline

Get Conditional PointsTo and standard points-to.

Definition at line 332 of file ConditionalPT.h.

333 {
334 return _condPts;
335 }

◆ pointsTo() [4/4]

template<class Cond >
const CondPts & SVF::CondPointsToSet< Cond >::pointsTo ( void  ) const
inline

Definition at line 336 of file ConditionalPT.h.

337 {
338 return _condPts;
339 }

◆ reset()

template<class Cond >
void SVF::CondPointsToSet< Cond >::reset ( const SingleCondVar var)
inline

Definition at line 699 of file ConditionalPT.h.

700 {
701 if (hasPointsTo(var.get_cond()))
702 {
703 PointsTo& pts = pointsTo(var.get_cond());
704 pts.reset(var.get_id());
705 }
706 }

◆ set()

template<class Cond >
void SVF::CondPointsToSet< Cond >::set ( const SingleCondVar var)
inline

Definition at line 694 of file ConditionalPT.h.

695 {
696 PointsTo& pts = pointsTo(var.get_cond());
697 pts.set(var.get_id());
698 }

◆ test()

template<class Cond >
bool SVF::CondPointsToSet< Cond >::test ( const SingleCondVar var) const
inline

Definition at line 685 of file ConditionalPT.h.

686 {
687 if (hasPointsTo(var.get_cond()))
688 {
689 const PointsTo& pts = pointsTo(var.get_cond());
690 return pts.test(var.get_id());
691 }
692 return false;
693 }

◆ test_and_set()

template<class Cond >
bool SVF::CondPointsToSet< Cond >::test_and_set ( const SingleCondVar var)
inline

Test and set.

Definition at line 680 of file ConditionalPT.h.

681 {
682 PointsTo& pts = pointsTo(var.get_cond());
683 return pts.test_and_set(var.get_id());
684 }

Member Data Documentation

◆ _condPts

template<class Cond >
CondPts SVF::CondPointsToSet< Cond >::_condPts
private

Definition at line 840 of file ConditionalPT.h.


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