From 98fdc339ab29b8f1ad6197f0294da2568b840738 Mon Sep 17 00:00:00 2001 From: Josselin Date: Fri, 18 Jan 2019 12:27:38 +0100 Subject: [PATCH] Convert ternary operator in modifier (close #140) --- slither/solc_parsing/declarations/function.py | 5 ++++- slither/solc_parsing/declarations/modifier.py | 3 +++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/slither/solc_parsing/declarations/function.py b/slither/solc_parsing/declarations/function.py index 7d4ab0857..39f3fc683 100644 --- a/slither/solc_parsing/declarations/function.py +++ b/slither/solc_parsing/declarations/function.py @@ -833,6 +833,10 @@ class FunctionSolc(Function): for node in self.nodes: node.analyze_expressions(self) + self._filter_ternary() + self._remove_alone_endif() + + def _filter_ternary(self): ternary_found = True while ternary_found: ternary_found = False @@ -847,7 +851,6 @@ class FunctionSolc(Function): self.split_ternary_node(node, condition, true_expr, false_expr) ternary_found = True break - self._remove_alone_endif() def get_last_ssa_state_variables_instances(self): if not self.is_implemented: diff --git a/slither/solc_parsing/declarations/modifier.py b/slither/solc_parsing/declarations/modifier.py index a62eb8902..5e2748c4e 100644 --- a/slither/solc_parsing/declarations/modifier.py +++ b/slither/solc_parsing/declarations/modifier.py @@ -59,6 +59,9 @@ class ModifierSolc(Modifier, FunctionSolc): for node in self.nodes: node.analyze_expressions(self) + self._filter_ternary() + self._remove_alone_endif() + self._analyze_read_write() self._analyze_calls()