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 143 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 479 of file CFLGraphBuilder.cpp.

480{
481 cflGraph = new CFLGraph(startKind);
482
483 buildlabelToKindMap(grammar);
484 for(auto it = graph->begin(); it!= graph->end(); it++)
485 {
486 CFLNode* node = new CFLNode((*it).first);
487 cflGraph->addCFLNode((*it).first, node);
488 }
489 for(auto it = graph->begin(); it!= graph->end(); it++)
490 {
491 VFGNode* node = (*it).second;
492 for(VFGEdge* edge : node->getOutEdges())
493 {
495 // Get 'a' edge : IntraDirectVF || IntraIndirectVF
496 if (edge->getEdgeKind() == VFGEdge::IntraDirectVF || edge->getEdgeKind() == VFGEdge::IntraIndirectVF || edge->getEdgeKind() == VFGEdge::TheadMHPIndirectVF )
497 {
498 edgeLabel = 0;
499 cflGraph->addCFLEdge(cflGraph->getGNode(edge->getSrcID()), cflGraph->getGNode(edge->getDstID()), edgeLabel);
500 cflGraph->addCFLEdge(cflGraph->getGNode(edge->getSrcID()), cflGraph->getGNode(edge->getDstID()), edgeLabel);
501 std::string label = kindToLabelMap[edge->getEdgeKind()];
502 label.append("bar");
504 }
505 // Get 'call' edge : CallDirVF || CallIndVF
506 else if ( edge->getEdgeKind() == VFGEdge::CallDirVF )
507 {
508 edgeLabel = 1;
509 CallDirSVFGEdge *attributedEdge = SVFUtil::dyn_cast<CallDirSVFGEdge>(edge);
510 CFGrammar::Attribute attr = attributedEdge->getCallSiteId();
513 cflGraph->addCFLEdge(cflGraph->getGNode(edge->getSrcID()), cflGraph->getGNode(edge->getDstID()), edgeLabel);
514 std::string label = kindToLabelMap[edgeLabel];
515 label.append("bar"); // for example Gep_i should be Gepbar_i, not Gep_ibar
518 }
519 // Get 'call' edge : CallIndVF
520 else if ( edge->getEdgeKind() == VFGEdge::CallIndVF )
521 {
522 edgeLabel = 1;
523 CallIndSVFGEdge *attributedEdge = SVFUtil::dyn_cast<CallIndSVFGEdge>(edge);
524 CFGrammar::Attribute attr = attributedEdge->getCallSiteId();
527 cflGraph->addCFLEdge(cflGraph->getGNode(edge->getSrcID()), cflGraph->getGNode(edge->getDstID()), edgeLabel);
528 std::string label = kindToLabelMap[edgeLabel];
529 label.append("bar"); // for example Gep_i should be Gepbar_i, not Gep_ibar
532 }
533 // Get 'ret' edge : RetDirVF
534 else if ( edge->getEdgeKind() == VFGEdge::RetDirVF )
535 {
536 edgeLabel = 2;
537 RetDirSVFGEdge *attributedEdge = SVFUtil::dyn_cast<RetDirSVFGEdge>(edge);
538 CFGrammar::Attribute attr = attributedEdge->getCallSiteId();
541 cflGraph->addCFLEdge(cflGraph->getGNode(edge->getSrcID()), cflGraph->getGNode(edge->getDstID()), edgeLabel);
542 std::string label = kindToLabelMap[edgeLabel];
543 label.append("bar"); // for example Gep_i should be Gepbar_i, not Gep_ibar
546 }
547 // Get 'ret' edge : RetIndVF
548 else if ( edge->getEdgeKind() == VFGEdge::RetIndVF )
549 {
550 edgeLabel = 2;
551 RetIndSVFGEdge *attributedEdge = SVFUtil::dyn_cast<RetIndSVFGEdge>(edge);
552 CFGrammar::Attribute attr = attributedEdge->getCallSiteId();
555 cflGraph->addCFLEdge(cflGraph->getGNode(edge->getSrcID()), cflGraph->getGNode(edge->getDstID()), edgeLabel);
556 std::string label = kindToLabelMap[edgeLabel];
557 label.append("bar"); // for example Gep_i should be Gepbar_i, not Gep_ibar
560 }
561 }
562 }
563 return cflGraph;
564}
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:269
@ IntraDirectVF
Definition VFGEdge.h:53
@ IntraIndirectVF
Definition VFGEdge.h:54
@ TheadMHPIndirectVF
Definition VFGEdge.h:59
llvm::IRBuilder IRBuilder
Definition BasicTypes.h:76

◆ 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 566 of file CFLGraphBuilder.cpp.

567{
568 CFLGraph *cflGraph = new CFLGraph(startKind);
569 return cflGraph;
570}

◆ 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: