diff --git a/slither/core/declarations/function.py b/slither/core/declarations/function.py index cdc90048e..ac8451729 100644 --- a/slither/core/declarations/function.py +++ b/slither/core/declarations/function.py @@ -54,7 +54,11 @@ class Function(ChildContract, SourceMapping): self._expression_modifiers = [] self._modifiers = [] self._payable = False + self._contains_assembly = False + @property + def contains_assembly(self): + return self._contains_assembly @property def return_type(self): diff --git a/slither/detectors/variables/uninitialized_local_variables.py b/slither/detectors/variables/uninitialized_local_variables.py index 967bc0214..5974c5803 100644 --- a/slither/detectors/variables/uninitialized_local_variables.py +++ b/slither/detectors/variables/uninitialized_local_variables.py @@ -60,10 +60,6 @@ class UninitializedLocalVars(AbstractDetector): self._detect_uninitialized(function, son, visited) - @staticmethod - def has_assembly_code(function): - return any(x.type == NodeType.ASSEMBLY for x in function.nodes) - def detect(self): """ Detect uninitialized state variables @@ -79,7 +75,7 @@ class UninitializedLocalVars(AbstractDetector): for contract in self.slither.contracts: for function in contract.functions: if function.is_implemented: - if self.has_assembly_code(function): + if function.contains_assembly: continue # dont consider storage variable, as they are detected by another detector uninitialized_local_variables = [v for v in function.local_variables if not v.is_storage and v.uninitialized] diff --git a/slither/solc_parsing/declarations/function.py b/slither/solc_parsing/declarations/function.py index 5b3952917..40fca4b73 100644 --- a/slither/solc_parsing/declarations/function.py +++ b/slither/solc_parsing/declarations/function.py @@ -135,33 +135,6 @@ class FunctionSolc(Function): link_nodes(condition_node, endIf_node) return endIf_node -# def _parse_if(self, ifStatement, node): -# # IfStatement = 'if' '(' Expression ')' Statement ( 'else' Statement )? -# -# children = ifStatement[self.get_children('children')] -# condition_node = self._new_node(NodeType.IF) -# #condition = parse_expression(children[0], self) -# condition = children[0] -# condition_node.add_unparsed_expression(condition) -# -# link_nodes(node, condition_node) -# -# trueStatement = self._parse_statement(children[1], condition_node) -# -# -# endIf_node = self._new_node(NodeType.ENDIF) -# link_nodes(trueStatement, endIf_node) -# -# if len(children) == 3: -# falseStatement = self._parse_statement(children[2], condition_node) -# -# link_nodes(falseStatement, endIf_node) -# -# else: -# link_nodes(condition_node, endIf_node) -# -# return endIf_node - def _parse_while(self, whileStatement, node): # WhileStatement = 'while' '(' Expression ')' Statement @@ -536,6 +509,7 @@ class FunctionSolc(Function): node = self._parse_block(statement, node) elif name == 'InlineAssembly': break_node = self._new_node(NodeType.ASSEMBLY, statement['src']) + self._contains_assembly = True link_nodes(node, break_node) node = break_node elif name == 'DoWhileStatement':