Skip to content

Commit 67fbf56

Browse files
committed
Revert "Remove SVFG::fromValue."
This reverts commit cfb6657.
1 parent 52f853f commit 67fbf56

File tree

2 files changed

+27
-0
lines changed

2 files changed

+27
-0
lines changed

include/Graphs/SVFG.h

+5
Original file line numberDiff line numberDiff line change
@@ -173,6 +173,11 @@ class SVFG : public VFG
173173
return getSVFGNode(getDef(pagNode));
174174
}
175175

176+
/// Return the corresponding SVFGNodes to a given llvm::Value.
177+
/// return an empty list, if the no mapping is possible
178+
std::set<const SVFGNode*> fromValue(const llvm::Value* value) const;
179+
180+
176181
/// Perform statistics
177182
void performStat();
178183

lib/Graphs/SVFG.cpp

+22
Original file line numberDiff line numberDiff line change
@@ -575,6 +575,28 @@ void SVFG::dump(const std::string& file, bool simple)
575575
GraphPrinter::WriteGraphToFile(outs(), file, this, simple);
576576
}
577577

578+
std::set<const SVFGNode*> SVFG::fromValue(const llvm::Value* value) const
579+
{
580+
SVFIR* pag = SVFIR::getPAG();
581+
std::set<const SVFGNode*> ret;
582+
// search for all PAGEdges first
583+
for (const PAGEdge* pagEdge : pag->getValueEdges(value))
584+
{
585+
PAGEdgeToStmtVFGNodeMapTy::const_iterator it = PAGEdgeToStmtVFGNodeMap.find(pagEdge);
586+
if (it != PAGEdgeToStmtVFGNodeMap.end())
587+
{
588+
ret.emplace(it->second);
589+
}
590+
}
591+
// add all PAGNodes
592+
PAGNode* pagNode = pag->getGNode(pag->getValueNode(value));
593+
if(hasDef(pagNode))
594+
{
595+
ret.emplace(getDefSVFGNode(pagNode));
596+
}
597+
return ret;
598+
}
599+
578600
/**
579601
* Get all inter value flow edges at this indirect call site, including call and return edges.
580602
*/

0 commit comments

Comments
 (0)