Commit dbd5bb5d authored by Roman Alifanov's avatar Roman Alifanov

Fix DCE for this.field.method() pattern

The dead code elimination was not tracking string/array method usage when methods were called on class fields like this.source.len(). Now properly calls _check_method() when field class is unknown.
parent daedc86a
......@@ -292,12 +292,16 @@ class UsageAnalyzer:
elif isinstance(callee.object, MemberAccess) and isinstance(callee.object.object, ThisExpr):
field_name = callee.object.member
method = callee.member
found_field_class = False
for cls_name, fields in self.class_fields.items():
if field_name in fields and fields[field_name]:
field_class = fields[field_name]
if field_class not in self.used_methods:
self.used_methods[field_class] = set()
self.used_methods[field_class].add(method)
found_field_class = True
if not found_field_class:
self._check_method(method)
elif isinstance(callee.object, CallExpr):
self._analyze_call(callee.object)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment