From 49a31173ee0e08fbdf740fd571d1344ed87e61d8 Mon Sep 17 00:00:00 2001 From: Tigran Avagyan Date: Thu, 22 Jun 2023 16:58:55 +0400 Subject: [PATCH] now we intersect only reachable fathers' dominators --- slither/core/dominators/utils.py | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/slither/core/dominators/utils.py b/slither/core/dominators/utils.py index 4dd55749d..463eac4b7 100644 --- a/slither/core/dominators/utils.py +++ b/slither/core/dominators/utils.py @@ -9,11 +9,17 @@ if TYPE_CHECKING: def intersection_predecessor(node: "Node") -> Set["Node"]: if not node.fathers: return set() - ret = node.fathers[0].dominators - for pred in node.fathers[1:]: - ret = ret.intersection(pred.dominators) - return ret + if not any(father.is_reachable for father in node.fathers): + 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) + return ret def _compute_dominators(nodes: List["Node"]) -> None: changed = True @@ -84,6 +90,8 @@ def compute_dominance_frontier(nodes: List["Node"]) -> None: for node in nodes: if len(node.fathers) >= 2: for father in node.fathers: + if not father.is_reachable: + continue runner = father # Corner case: if there is a if without else # we need to add update the conditional node