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

#include <SlicedGraphs.h>

Public Member Functions

 SlicedPAGView (SVFIR *pag, const OrderedSet< const SVFStmt * > &keptStmts)
 
const OrderedSet< const SVFStmt * > & getKeptStmts () const
 Get all kept statements.
 
const Set< NodeID > & getKeptNodeIds () const
 Node IDs (SVFVars) touched by the kept statements – the sliced PAG's nodes.
 
bool isKeptStmt (const SVFStmt *s) const
 
SVFIRgetSVFIR () const
 The underlying SVFIR (to resolve node ids to SVFVars).
 
void dump (const std::string &filename) const
 Dump the sliced PAG to a dot file.
 

Private Member Functions

void buildKeptNodeIds ()
 

Private Attributes

SVFIRpag
 
OrderedSet< const SVFStmt * > keptStmts
 
Set< NodeIDkeptNodeIds
 

Detailed Description

Definition at line 140 of file SlicedGraphs.h.

Constructor & Destructor Documentation

◆ SlicedPAGView()

SVF::SlicedPAGView::SlicedPAGView ( SVFIR pag,
const OrderedSet< const SVFStmt * > &  keptStmts 
)

Definition at line 505 of file SlicedGraphs.cpp.

507{
509}
OrderedSet< const SVFStmt * > keptStmts

Member Function Documentation

◆ buildKeptNodeIds()

void SVF::SlicedPAGView::buildKeptNodeIds ( )
private

Definition at line 511 of file SlicedGraphs.cpp.

512{
513 for (const SVFStmt* stmt : keptStmts)
514 {
515 // extract the node IDs involved in the statement
516 const AssignStmt* assignStmt = SVFUtil::dyn_cast<AssignStmt>(stmt);
517 if (assignStmt)
518 {
519 keptNodeIds.insert(assignStmt->getLHSVarID());
520 keptNodeIds.insert(assignStmt->getRHSVarID());
521 continue;
522 }
523
524 const LoadStmt* loadStmt = SVFUtil::dyn_cast<LoadStmt>(stmt);
525 if (loadStmt)
526 {
527 keptNodeIds.insert(loadStmt->getLHSVarID());
528 keptNodeIds.insert(loadStmt->getRHSVarID());
529 continue;
530 }
531
532 const StoreStmt* storeStmt = SVFUtil::dyn_cast<StoreStmt>(stmt);
533 if (storeStmt)
534 {
535 keptNodeIds.insert(storeStmt->getLHSVarID());
536 keptNodeIds.insert(storeStmt->getRHSVarID());
537 continue;
538 }
539
540 const CopyStmt* copyStmt = SVFUtil::dyn_cast<CopyStmt>(stmt);
541 if (copyStmt)
542 {
543 keptNodeIds.insert(copyStmt->getLHSVarID());
544 keptNodeIds.insert(copyStmt->getRHSVarID());
545 continue;
546 }
547
548 const GepStmt* gepStmt = SVFUtil::dyn_cast<GepStmt>(stmt);
549 if (gepStmt)
550 {
551 keptNodeIds.insert(gepStmt->getLHSVarID());
552 keptNodeIds.insert(gepStmt->getRHSVarID());
553 continue;
554 }
555
556 const AddrStmt* addrStmt = SVFUtil::dyn_cast<AddrStmt>(stmt);
557 if (addrStmt)
558 {
559 keptNodeIds.insert(addrStmt->getLHSVarID());
560 keptNodeIds.insert(addrStmt->getRHSVarID());
561 continue;
562 }
563
564 const CallPE* callPE = SVFUtil::dyn_cast<CallPE>(stmt);
565 if (callPE)
566 {
567 // CallPE is a MultiOpndStmt (result + per-call-site operands)
568 // rather than a single-LHS/RHS AssignStmt.
569 keptNodeIds.insert(callPE->getResID());
570 for (u32_t i = 0; i < callPE->getOpVarNum(); ++i)
571 keptNodeIds.insert(callPE->getOpVarID(i));
572 continue;
573 }
574
575 const RetPE* retPE = SVFUtil::dyn_cast<RetPE>(stmt);
576 if (retPE)
577 {
578 keptNodeIds.insert(retPE->getLHSVarID());
579 keptNodeIds.insert(retPE->getRHSVarID());
580 continue;
581 }
582 }
583}
unsigned u32_t
Definition CommandLine.h:18
NodeID getRHSVarID() const
NodeID getLHSVarID() const
NodeID getOpVarID(u32_t pos) const
NodeID getResID() const
u32_t getOpVarNum() const
Set< NodeID > keptNodeIds
llvm::IRBuilder IRBuilder
Definition BasicTypes.h:76

◆ dump()

void SVF::SlicedPAGView::dump ( const std::string &  filename) const

Dump the sliced PAG to a dot file.

Definition at line 585 of file SlicedGraphs.cpp.

586{
587 // Nodes = SVFVars of kept statements; edges = kept SVFStmts via
588 // GenericGraphTraits<const SlicedPAGView*>. MultiOpndStmts use the
589 // underlying src/dst (no operand fan-out).
591}
static void WriteGraphToFile(SVF::OutStream &O, const std::string &GraphName, const GraphType &GT, bool simple=false)
std::ostream & outs()
Overwrite llvm::outs()
Definition SVFUtil.h:52

◆ getKeptNodeIds()

const Set< NodeID > & SVF::SlicedPAGView::getKeptNodeIds ( ) const
inline

Node IDs (SVFVars) touched by the kept statements – the sliced PAG's nodes.

Definition at line 152 of file SlicedGraphs.h.

153 {
154 return keptNodeIds;
155 }

◆ getKeptStmts()

const OrderedSet< const SVFStmt * > & SVF::SlicedPAGView::getKeptStmts ( ) const
inline

Get all kept statements.

Definition at line 146 of file SlicedGraphs.h.

147 {
148 return keptStmts;
149 }

◆ getSVFIR()

SVFIR * SVF::SlicedPAGView::getSVFIR ( ) const
inline

The underlying SVFIR (to resolve node ids to SVFVars).

Definition at line 165 of file SlicedGraphs.h.

166 {
167 return pag;
168 }

◆ isKeptStmt()

bool SVF::SlicedPAGView::isKeptStmt ( const SVFStmt s) const
inline

Canonical edge membership: a kept SVFVar may have incident statements not in the slice, so traits/queries keep only statements in keptStmts.

Definition at line 159 of file SlicedGraphs.h.

160 {
161 return keptStmts.count(s) > 0;
162 }

Member Data Documentation

◆ keptNodeIds

Set<NodeID> SVF::SlicedPAGView::keptNodeIds
private

Definition at line 176 of file SlicedGraphs.h.

◆ keptStmts

OrderedSet<const SVFStmt*> SVF::SlicedPAGView::keptStmts
private

Definition at line 175 of file SlicedGraphs.h.

◆ pag

SVFIR* SVF::SlicedPAGView::pag
private

Definition at line 174 of file SlicedGraphs.h.


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