Track alias analysis on Binary operation

pull/125/head
Josselin 6 years ago
parent a938c3af14
commit 60ab8eb105
  1. 10
      slither/slithir/operations/binary.py
  2. 6
      slither/slithir/utils/ssa.py

@ -3,6 +3,7 @@ from slither.slithir.operations.lvalue import OperationWithLValue
from slither.core.variables.variable import Variable
from slither.slithir.utils.utils import is_valid_lvalue, is_valid_rvalue
from slither.core.solidity_types import ElementaryType
from slither.slithir.variables import ReferenceVariable
logger = logging.getLogger("BinaryOperationIR")
@ -165,6 +166,15 @@ class Binary(OperationWithLValue):
return BinaryType.str(self._type)
def __str__(self):
if isinstance(self.lvalue, ReferenceVariable):
points = self.lvalue.points_to
while isinstance(points, ReferenceVariable):
points = points.points_to
return '{}(-> {}) = {} {} {}'.format(str(self.lvalue),
points,
self.variable_left,
self.type_str,
self.variable_right)
return '{}({}) = {} {} {}'.format(str(self.lvalue),
self.lvalue.type,
self.variable_left,

@ -152,7 +152,7 @@ def update_lvalue(new_ir, node, local_variables_instances, all_local_variables_i
if isinstance(new_ir, OperationWithLValue):
lvalue = new_ir.lvalue
update_through_ref = False
if isinstance(new_ir, Assignment):
if isinstance(new_ir, (Assignment, Binary)):
if isinstance(lvalue, ReferenceVariable):
update_through_ref = True
while isinstance(lvalue, ReferenceVariable):
@ -275,7 +275,7 @@ def generate_ssa_irs(node, local_variables_instances, all_local_variables_instan
# rvalues are fixed in solc_parsing.declaration.function
node.add_ssa_ir(phi_ir)
if isinstance(new_ir, Assignment):
if isinstance(new_ir, (Assignment, Binary)):
if isinstance(new_ir.lvalue, LocalIRVariable):
if new_ir.lvalue.is_storage:
if isinstance(new_ir.rvalue, ReferenceVariable):
@ -315,7 +315,7 @@ def fix_phi_rvalues_and_storage_ref(node, local_variables_instances, all_local_v
l = [item for sublist in l for item in sublist]
ir.lvalue.refers_to = set(l)
if isinstance(ir, Assignment):
if isinstance(ir, (Assignment, Binary)):
if isinstance(ir.lvalue, ReferenceVariable):
origin = ir.lvalue.points_to_origin

Loading…
Cancel
Save