Dominator: corner case if there is a if without else for dominance frontier

add phi_callback for state variable
pull/87/head
Josselin 6 years ago
parent e25be40be4
commit 767e01ec2c
  1. 37
      slither/core/dominators/node_dominator_tree.py
  2. 41
      slither/slithir/operations/phi_callback.py

@ -0,0 +1,37 @@
'''
Nodes of the dominator tree
'''
from slither.core.children.child_function import ChildFunction
class DominatorNode(object):
def __init__(self):
self._succ = set()
self._nodes = []
def add_node(self, node):
self._nodes.append(node)
def add_successor(self, succ):
self._succ.add(succ)
@property
def cfg_nodes(self):
return self._nodes
@property
def sucessors(self):
'''
Returns:
dict(Node)
'''
return self._succ
class DominatorTree(ChildFunction):
def __init__(self, entry_point):
super(DominatorTree, self).__init__()

@ -0,0 +1,41 @@
import logging
from slither.core.variables.variable import Variable
from slither.slithir.variables import TupleVariable
from slither.core.declarations.function import Function
from slither.slithir.utils.utils import is_valid_lvalue, is_valid_rvalue
from .phi import Phi
class PhiCallback(Phi):
def __init__(self, left_variable, nodes):
assert is_valid_lvalue(left_variable)
assert isinstance(nodes, set)
super(PhiCallback, self).__init__(left_variable, nodes)
@property
def read(self):
return [self.rvalues]
@property
def rvalues(self):
return self._rvalues
@property
def rvalue_no_callback(self):
'''
rvalue if callback are not considered
'''
return self._rvalues[0]
@rvalues.setter
def rvalues(self, vals):
self._rvalues = vals
@property
def nodes(self):
return self._nodes
def __str__(self):
return '{}({}) := \u03D5({})'.format(self.lvalue, self.lvalue.type, [v.ssa_name for v in self._rvalues])
Loading…
Cancel
Save