now we intersect only reachable fathers' dominators

pull/1984/head
Tigran Avagyan 1 year ago
parent 7b9024f96b
commit 49a31173ee
  1. 14
      slither/core/dominators/utils.py

@ -9,12 +9,18 @@ if TYPE_CHECKING:
def intersection_predecessor(node: "Node") -> Set["Node"]: def intersection_predecessor(node: "Node") -> Set["Node"]:
if not node.fathers: if not node.fathers:
return set() return set()
ret = node.fathers[0].dominators if not any(father.is_reachable for father in node.fathers):
for pred in node.fathers[1:]: return set()
ret = set()
for pred in node.fathers:
ret = ret.union(pred.dominators)
for pred in node.fathers:
if pred.is_reachable:
ret = ret.intersection(pred.dominators) ret = ret.intersection(pred.dominators)
return ret return ret
def _compute_dominators(nodes: List["Node"]) -> None: def _compute_dominators(nodes: List["Node"]) -> None:
changed = True changed = True
@ -84,6 +90,8 @@ def compute_dominance_frontier(nodes: List["Node"]) -> None:
for node in nodes: for node in nodes:
if len(node.fathers) >= 2: if len(node.fathers) >= 2:
for father in node.fathers: for father in node.fathers:
if not father.is_reachable:
continue
runner = father runner = father
# Corner case: if there is a if without else # Corner case: if there is a if without else
# we need to add update the conditional node # we need to add update the conditional node

Loading…
Cancel
Save