Fix always-false condition in <AsmMethodSource: void assignReadOps(Local l)> #2046
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Problem Description:
The always-false condition was initially reported in Soot PR #1834, resulting in a branch that is never reached or covered. This issue may lead to redundant Jimple statements, as addressed by the fix in SootUp PR #472 in SootUp. Unfortunately, Soot PR #1834 was closed without being merged due to the absence of test cases.
Solution Overview:
I have ported the test cases from SootUp PR #472 to Soot and observed that the current Soot implementation does not generate redundant statements despite retaining the always-false condition.
Changes Made:
I corrected the always-false condition by referencing both Soot PR #1834 and SootUp PR #472. Following these modifications, all tests, including the ported ones, pass successfully when executing
mvn -B clean test -PJava8
,mvn -B clean test -PJava9
, andmvn -B clean test -PJava11
. However, one ported test consistently produces redundant Jimple statements, as reported in Issue #2045.Further Insights:
The results suggest that the current Soot implementation may not require the if-structure, as it has no impact on the test cases, whether the condition is reachable or not. This conclusion is supported by tracking the line coverage in Jacoco reports before and after the modification.