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

#include <CFLSolver.h>

Inheritance diagram for SVF::CFLSolver:
SVF::POCRSolver SVF::POCRHybridSolver

Public Types

typedef FIFOWorkList< const CFLEdge * > WorkList
 Define worklist.
 
typedef CFGrammar::Production Production
 
typedef CFGrammar::Symbol Symbol
 

Public Member Functions

 CFLSolver (CFLGraph *_graph, CFGrammar *_grammar)
 
virtual ~CFLSolver ()
 
virtual void initialize ()
 Initialize worklist.
 
virtual void processCFLEdge (const CFLEdge *Y_edge)
 Process CFLEdge.
 
virtual void solve ()
 Start solving.
 
const CFLGraphgetGraph () const
 Return CFL Graph.
 
const CFGrammargetGrammar () const
 Return CFL Grammar.
 
virtual bool pushIntoWorklist (const CFLEdge *item)
 
virtual bool isWorklistEmpty ()
 

Static Public Attributes

static double numOfChecks = 0
 

Protected Member Functions

const CFLEdgepopFromWorklist ()
 Worklist operations.
 
bool isInWorklist (const CFLEdge *item)
 

Protected Attributes

CFLGraphgraph
 
CFGrammargrammar
 
WorkList worklist
 Worklist for resolution.
 

Detailed Description

Definition at line 43 of file CFLSolver.h.

Member Typedef Documentation

◆ Production

Definition at line 49 of file CFLSolver.h.

◆ Symbol

Definition at line 50 of file CFLSolver.h.

◆ WorkList

Define worklist.

Definition at line 48 of file CFLSolver.h.

Constructor & Destructor Documentation

◆ CFLSolver()

SVF::CFLSolver::CFLSolver ( CFLGraph _graph,
CFGrammar _grammar 
)
inline

Definition at line 54 of file CFLSolver.h.

54 : graph(_graph), grammar(_grammar)
55 {
56 }
CFGrammar * grammar
Definition CFLSolver.h:109
CFLGraph * graph
Definition CFLSolver.h:108
llvm::IRBuilder IRBuilder
Definition BasicTypes.h:74

◆ ~CFLSolver()

virtual SVF::CFLSolver::~CFLSolver ( )
inlinevirtual

Definition at line 58 of file CFLSolver.h.

59 {
60 delete graph;
61 delete grammar;
62 }

Member Function Documentation

◆ getGrammar()

const CFGrammar * SVF::CFLSolver::getGrammar ( ) const
inline

Return CFL Grammar.

Definition at line 80 of file CFLSolver.h.

81 {
82 return grammar;
83 }

◆ getGraph()

const CFLGraph * SVF::CFLSolver::getGraph ( ) const
inline

Return CFL Graph.

Definition at line 74 of file CFLSolver.h.

75 {
76 return graph;
77 }

◆ initialize()

void CFLSolver::initialize ( )
virtual

Initialize worklist.

Foreach production X -> epsilon add X(i,i) if not exist to E and to worklist

Reimplemented in SVF::POCRSolver, and SVF::POCRHybridSolver.

Definition at line 36 of file CFLSolver.cpp.

37{
38 for(auto it = graph->begin(); it!= graph->end(); it++)
39 {
40 for(const CFLEdge* edge : (*it).second->getOutEdges())
41 {
43 }
44 }
45
48 for(const Production& prod : grammar->getEpsilonProds())
49 {
50 for(auto it = graph->begin(); it!= graph->end(); it++)
51 {
53 CFLNode* i = (*it).second;
54 if(const CFLEdge* edge = graph->addCFLEdge(i, i, X))
55 {
57 }
58 }
59 }
60}
const Symbol & getLHSSymbol(const Production &prod) const
Definition CFGrammar.h:368
virtual const CFLEdge * addCFLEdge(CFLNode *src, CFLNode *dst, CFLEdge::GEdgeFlag label)
Definition CFLGraph.cpp:47
CFGrammar::Production Production
Definition CFLSolver.h:49
CFGrammar::Symbol Symbol
Definition CFLSolver.h:50
virtual bool pushIntoWorklist(const CFLEdge *item)
Definition CFLSolver.h:84
iterator begin()
Iterators.

◆ isInWorklist()

bool SVF::CFLSolver::isInWorklist ( const CFLEdge item)
inlineprotected

Definition at line 101 of file CFLSolver.h.

102 {
103 return worklist.find(item);
104 }
cJSON * item
Definition cJSON.h:222
WorkList worklist
Worklist for resolution.
Definition CFLSolver.h:111
bool find(const Data &data) const
Definition WorkList.h:157

◆ isWorklistEmpty()

virtual bool SVF::CFLSolver::isWorklistEmpty ( )
inlinevirtual

Definition at line 88 of file CFLSolver.h.

89 {
90 return worklist.empty();
91 }
bool empty() const
Definition WorkList.h:146

◆ popFromWorklist()

const CFLEdge * SVF::CFLSolver::popFromWorklist ( )
inlineprotected

Worklist operations.

Definition at line 96 of file CFLSolver.h.

97 {
98 return worklist.pop();
99 }

◆ processCFLEdge()

void CFLSolver::processCFLEdge ( const CFLEdge Y_edge)
virtual

Process CFLEdge.

For each production X -> Y add X(i,j) if not exist to E and to worklist

For each production X -> Y Z Foreach outgoing edge Z(j,k) from node j do add X(i,k) if not exist to E and to worklist

For each production X -> Z Y Foreach incoming edge Z(k,i) to node i do add X(k,j) if not exist to E and to worklist

Reimplemented in SVF::POCRSolver, and SVF::POCRHybridSolver.

Definition at line 62 of file CFLSolver.cpp.

63{
64 CFLNode* i = Y_edge->getSrcNode();
65 CFLNode* j = Y_edge->getDstNode();
66
69 Symbol Y = Y_edge->getEdgeKind();
71 for(const Production& prod : grammar->getProdsFromSingleRHS(Y))
72 {
75 if(const CFLEdge* newEdge = graph->addCFLEdge(i, j, X))
76 {
78 }
79 }
80
85 for(const Production& prod : grammar->getProdsFromFirstRHS(Y))
86 {
88 for(const CFLEdge* Z_edge : j->getOutEdgeWithTy(grammar->getSecondRHSSymbol(prod)))
89 {
90 CFLNode* k = Z_edge->getDstNode();
92 if(const CFLEdge* newEdge = graph->addCFLEdge(i, k, X))
93 {
95 }
96 }
97 }
98
103 for(const Production& prod : grammar->getProdsFromSecondRHS(Y))
104 {
106 for(const CFLEdge* Z_edge : i->getInEdgeWithTy(grammar->getFirstRHSSymbol(prod)))
107 {
108 CFLNode* k = Z_edge->getSrcNode();
109 numOfChecks++;
110 if(const CFLEdge* newEdge = graph->addCFLEdge(k, j, X))
111 {
113 }
114 }
115 }
116}
const bool hasProdsFromFirstRHS(const Symbol sym) const
Definition CFGrammar.h:328
const bool hasProdsFromSecondRHS(const Symbol sym) const
Definition CFGrammar.h:340
const bool hasProdsFromSingleRHS(const Symbol sym) const
Definition CFGrammar.h:334
static double numOfChecks
Definition CFLSolver.h:52

◆ pushIntoWorklist()

virtual bool SVF::CFLSolver::pushIntoWorklist ( const CFLEdge item)
inlinevirtual

Definition at line 84 of file CFLSolver.h.

85 {
86 return worklist.push(item);
87 }
bool push(const Data &data)
Definition WorkList.h:165

◆ solve()

void CFLSolver::solve ( )
virtual

Start solving.

initial worklist

Select and remove an edge Y(i,j) from worklist

Definition at line 119 of file CFLSolver.cpp.

120{
122 initialize();
123
124 while(!isWorklistEmpty())
125 {
127 const CFLEdge* Y_edge = popFromWorklist();
129 }
130}
virtual void processCFLEdge(const CFLEdge *Y_edge)
Process CFLEdge.
Definition CFLSolver.cpp:62
virtual void initialize()
Initialize worklist.
Definition CFLSolver.cpp:36
virtual bool isWorklistEmpty()
Definition CFLSolver.h:88
const CFLEdge * popFromWorklist()
Worklist operations.
Definition CFLSolver.h:96

Member Data Documentation

◆ grammar

CFGrammar* SVF::CFLSolver::grammar
protected

Definition at line 109 of file CFLSolver.h.

◆ graph

CFLGraph* SVF::CFLSolver::graph
protected

Definition at line 108 of file CFLSolver.h.

◆ numOfChecks

double CFLSolver::numOfChecks = 0
static

Definition at line 52 of file CFLSolver.h.

◆ worklist

WorkList SVF::CFLSolver::worklist
protected

Worklist for resolution.

Definition at line 111 of file CFLSolver.h.


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