From 9ad04d91281ab9eabca7058411ac51a350ea8cdc Mon Sep 17 00:00:00 2001 From: Josselin Date: Wed, 11 Sep 2019 10:17:26 +0200 Subject: [PATCH] Add missing source mapping --- slither/solc_parsing/cfg/node.py | 10 ++++++---- slither/solc_parsing/declarations/contract.py | 1 + slither/solc_parsing/expressions/expression_parsing.py | 4 +++- 3 files changed, 10 insertions(+), 5 deletions(-) diff --git a/slither/solc_parsing/cfg/node.py b/slither/solc_parsing/cfg/node.py index 1775084f6..c711b31c3 100644 --- a/slither/solc_parsing/cfg/node.py +++ b/slither/solc_parsing/cfg/node.py @@ -37,10 +37,12 @@ class NodeSolc(Node): if self.type == NodeType.VARIABLE: # Update the expression to be an assignement to the variable #print(self.variable_declaration) - self._expression = AssignmentOperation(Identifier(self.variable_declaration), - self.expression, - AssignmentOperationType.ASSIGN, - self.variable_declaration.type) + _expression = AssignmentOperation(Identifier(self.variable_declaration), + self.expression, + AssignmentOperationType.ASSIGN, + self.variable_declaration.type) + _expression.set_offset(self.expression.source_mapping, caller_context) + self._expression = _expression expression = self.expression pp = ReadVar(expression) diff --git a/slither/solc_parsing/declarations/contract.py b/slither/solc_parsing/declarations/contract.py index 3f8b52f6f..ebb43a185 100644 --- a/slither/solc_parsing/declarations/contract.py +++ b/slither/solc_parsing/declarations/contract.py @@ -382,6 +382,7 @@ class ContractSolc04(Contract): AssignmentOperationType.ASSIGN, variable.type) + expression.set_offset(variable.source_mapping, self.slither) node.add_expression(expression) return node diff --git a/slither/solc_parsing/expressions/expression_parsing.py b/slither/solc_parsing/expressions/expression_parsing.py index 92314a80a..4ccaeb275 100644 --- a/slither/solc_parsing/expressions/expression_parsing.py +++ b/slither/solc_parsing/expressions/expression_parsing.py @@ -581,7 +581,9 @@ def parse_expression(expression, caller_context): var = find_variable(super_name, caller_context, is_super=True) if var is None: raise VariableNotFound('Variable not found: {}'.format(super_name)) - return SuperIdentifier(var) + sup = SuperIdentifier(var) + sup.set_offset(expression['src'], caller_context) + return sup member_access = MemberAccess(member_name, member_type, member_expression) member_access.set_offset(expression['src'], caller_context.slither) if str(member_access) in SOLIDITY_VARIABLES_COMPOSED: