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

VFCFLGraphBuilder: a CFLGraphBuilder specialized for handling value-flow. More...

#include <CFLGraphBuilder.h>

Inheritance diagram for SVF::VFCFLGraphBuilder:
SVF::CFLGraphBuilder

Public Member Functions

CFLGraphbuildBigraph (SVFG *graph, Kind startKind, GrammarBase *grammar)
 Builds a bidirectional CFL graph by copying nodes and edges from a const graph that inherits from SVFG.
 
CFLGraphbuildBiPEGgraph (ConstraintGraph *graph, Kind startKind, GrammarBase *grammar, SVFIR *pag)
 
- Public Member Functions inherited from SVF::CFLGraphBuilder
template<class N , class E >
CFLGraphbuild (GenericGraph< N, E > *graph, GrammarBase *grammar, BuildDirection direction=BuildDirection::plain)
 
CFLGraphbuild (std::string fileName, GrammarBase *grammar, BuildDirection direction=BuildDirection::plain)
 Method to build a CFL graph from external file.
 
Map< std::string, Kind > & getLabelToKindMap ()
 Returns a reference to the map that associates string labels with their corresponding Kind.
 
Map< Kind, std::string > & getKindToLabelMap ()
 Returns a reference to the map that associates Kinds with their corresponding string labels.
 
Map< CFGrammar::Kind, Set< CFGrammar::Attribute > > & getKindToAttrsMap ()
 Returns a reference to the map that associates Kinds with their corresponding attributes.
 

Private Member Functions

void connectVGep (CFLGraph *cflGraph, ConstraintGraph *graph, ConstraintNode *src, ConstraintNode *dst, u32_t level, SVFIR *pag)
 Connects VGep (Variable GEP)
 
void addBiCFLEdge (CFLGraph *cflGraph, ConstraintNode *src, ConstraintNode *dst, CFGrammar::Kind label)
 Handles edges, with the exception of the GEP.
 
void addBiGepCFLEdge (CFLGraph *cflGraph, ConstraintNode *src, ConstraintNode *dst, CFGrammar::Attribute attri)
 Adds bidirectional GEP edges with attributes.
 

Additional Inherited Members

- Protected Types inherited from SVF::CFLGraphBuilder
typedef CFGrammar::Kind Kind
 
typedef CFGrammar::Symbol Symbol
 
- Protected Member Functions inherited from SVF::CFLGraphBuilder
void addAttribute (CFGrammar::Kind kind, CFGrammar::Attribute attribute)
 Method to add an attribute to a specific kind.
 
void buildlabelToKindMap (GrammarBase *grammar)
 build label and kind connect from the grammar
 
CFLNodeaddGNode (u32_t NodeID)
 add src and dst node from file
 
CFLGraphbuildFromText (std::string fileName, GrammarBase *grammar, BuildDirection direction=BuildDirection::plain)
 Method to build a CFL graph from a Text file.
 
CFLGraphbuildFromDot (std::string filename, GrammarBase *grammar, BuildDirection direction=BuildDirection::plain)
 Method to build a CFL graph from a Dot file.
 
CFLGraphbuildFromJson (std::string filename, GrammarBase *grammar, BuildDirection direction=BuildDirection::plain)
 Method to build a CFL graph from a Json file.
 
- Protected Attributes inherited from SVF::CFLGraphBuilder
Map< std::string, KindlabelToKindMap
 Maps to maintain mapping between labels and kinds.
 
Map< Kind, std::string > kindToLabelMap
 
Map< CFGrammar::Kind, Set< CFGrammar::Attribute > > kindToAttrsMap
 Map to maintain attributes associated with each kind.
 
Kind current
 
CFLGraphcflGraph
 

Detailed Description

VFCFLGraphBuilder: a CFLGraphBuilder specialized for handling value-flow.

Definition at line 142 of file CFLGraphBuilder.h.

Member Function Documentation

◆ addBiCFLEdge()

void SVF::VFCFLGraphBuilder::addBiCFLEdge ( CFLGraph cflGraph,
ConstraintNode src,
ConstraintNode dst,
CFGrammar::Kind  label 
)
private

Handles edges, with the exception of the GEP.

◆ addBiGepCFLEdge()

void SVF::VFCFLGraphBuilder::addBiGepCFLEdge ( CFLGraph cflGraph,
ConstraintNode src,
ConstraintNode dst,
CFGrammar::Attribute  attri 
)
private

Adds bidirectional GEP edges with attributes.

◆ buildBigraph()

CFLGraph * SVF::VFCFLGraphBuilder::buildBigraph ( SVFG graph,
Kind  startKind,
GrammarBase grammar 
)

Builds a bidirectional CFL graph by copying nodes and edges from a const graph that inherits from SVFG.

Definition at line 481 of file CFLGraphBuilder.cpp.

482{
483 cflGraph = new CFLGraph(startKind);
484
485 buildlabelToKindMap(grammar);
486 for(auto it = graph->begin(); it!= graph->end(); it++)
487 {
488 CFLNode* node = new CFLNode((*it).first);
489 cflGraph->addCFLNode((*it).first, node);
490 }
491 for(auto it = graph->begin(); it!= graph->end(); it++)
492 {
493 VFGNode* node = (*it).second;
494 for(VFGEdge* edge : node->getOutEdges())
495 {
497 // Get 'a' edge : IntraDirectVF || IntraIndirectVF
498 if (edge->getEdgeKind() == VFGEdge::IntraDirectVF || edge->getEdgeKind() == VFGEdge::IntraIndirectVF || edge->getEdgeKind() == VFGEdge::TheadMHPIndirectVF )
499 {
500 edgeLabel = 0;
501 cflGraph->addCFLEdge(cflGraph->getGNode(edge->getSrcID()), cflGraph->getGNode(edge->getDstID()), edgeLabel);
502 cflGraph->addCFLEdge(cflGraph->getGNode(edge->getSrcID()), cflGraph->getGNode(edge->getDstID()), edgeLabel);
503 std::string label = kindToLabelMap[edge->getEdgeKind()];
504 label.append("bar");
506 }
507 // Get 'call' edge : CallDirVF || CallIndVF
508 else if ( edge->getEdgeKind() == VFGEdge::CallDirVF )
509 {
510 edgeLabel = 1;
511 CallDirSVFGEdge *attributedEdge = SVFUtil::dyn_cast<CallDirSVFGEdge>(edge);
512 CFGrammar::Attribute attr = attributedEdge->getCallSiteId();
515 cflGraph->addCFLEdge(cflGraph->getGNode(edge->getSrcID()), cflGraph->getGNode(edge->getDstID()), edgeLabel);
516 std::string label = kindToLabelMap[edgeLabel];
517 label.append("bar"); // for example Gep_i should be Gepbar_i, not Gep_ibar
520 }
521 // Get 'call' edge : CallIndVF
522 else if ( edge->getEdgeKind() == VFGEdge::CallIndVF )
523 {
524 edgeLabel = 1;
525 CallIndSVFGEdge *attributedEdge = SVFUtil::dyn_cast<CallIndSVFGEdge>(edge);
526 CFGrammar::Attribute attr = attributedEdge->getCallSiteId();
529 cflGraph->addCFLEdge(cflGraph->getGNode(edge->getSrcID()), cflGraph->getGNode(edge->getDstID()), edgeLabel);
530 std::string label = kindToLabelMap[edgeLabel];
531 label.append("bar"); // for example Gep_i should be Gepbar_i, not Gep_ibar
534 }
535 // Get 'ret' edge : RetDirVF
536 else if ( edge->getEdgeKind() == VFGEdge::RetDirVF )
537 {
538 edgeLabel = 2;
539 RetDirSVFGEdge *attributedEdge = SVFUtil::dyn_cast<RetDirSVFGEdge>(edge);
540 CFGrammar::Attribute attr = attributedEdge->getCallSiteId();
543 cflGraph->addCFLEdge(cflGraph->getGNode(edge->getSrcID()), cflGraph->getGNode(edge->getDstID()), edgeLabel);
544 std::string label = kindToLabelMap[edgeLabel];
545 label.append("bar"); // for example Gep_i should be Gepbar_i, not Gep_ibar
548 }
549 // Get 'ret' edge : RetIndVF
550 else if ( edge->getEdgeKind() == VFGEdge::RetIndVF )
551 {
552 edgeLabel = 2;
553 RetIndSVFGEdge *attributedEdge = SVFUtil::dyn_cast<RetIndSVFGEdge>(edge);
554 CFGrammar::Attribute attr = attributedEdge->getCallSiteId();
557 cflGraph->addCFLEdge(cflGraph->getGNode(edge->getSrcID()), cflGraph->getGNode(edge->getDstID()), edgeLabel);
558 std::string label = kindToLabelMap[edgeLabel];
559 label.append("bar"); // for example Gep_i should be Gepbar_i, not Gep_ibar
562 }
563 }
564 }
565 return cflGraph;
566}
void buildlabelToKindMap(GrammarBase *grammar)
build label and kind connect from the grammar
Map< std::string, Kind > labelToKindMap
Maps to maintain mapping between labels and kinds.
Map< Kind, std::string > kindToLabelMap
void addAttribute(CFGrammar::Kind kind, CFGrammar::Attribute attribute)
Method to add an attribute to a specific kind.
virtual void addCFLNode(NodeID id, CFLNode *node)
Definition CFLGraph.cpp:42
virtual const CFLEdge * addCFLEdge(CFLNode *src, CFLNode *dst, CFLEdge::GEdgeFlag label)
Definition CFLGraph.cpp:47
NodeType * getGNode(NodeID id) const
Get a node.
static Kind getAttributedKind(Attribute attribute, Kind kind)
Definition CFGrammar.h:265
@ IntraDirectVF
Definition VFGEdge.h:53
@ IntraIndirectVF
Definition VFGEdge.h:54
@ TheadMHPIndirectVF
Definition VFGEdge.h:59
llvm::IRBuilder IRBuilder
Definition BasicTypes.h:74

◆ buildBiPEGgraph()

CFLGraph * SVF::VFCFLGraphBuilder::buildBiPEGgraph ( ConstraintGraph graph,
Kind  startKind,
GrammarBase grammar,
SVFIR pag 
)

Builds a bidirectional CFL graph by copying nodes and edges from any graph that inherits from GenericGraph Transfers Load and Store to copy edge and address edge to construct PEG style CFLGraph

Definition at line 568 of file CFLGraphBuilder.cpp.

569{
570 CFLGraph *cflGraph = new CFLGraph(startKind);
571 return cflGraph;
572}

◆ connectVGep()

void SVF::VFCFLGraphBuilder::connectVGep ( CFLGraph cflGraph,
ConstraintGraph graph,
ConstraintNode src,
ConstraintNode dst,
u32_t  level,
SVFIR pag 
)
private

Connects VGep (Variable GEP)


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