-
Notifications
You must be signed in to change notification settings - Fork 4.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: correct merge code variables across PHI instructions (#930)
- Loading branch information
Showing
4 changed files
with
151 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
19 changes: 19 additions & 0 deletions
19
jadx-core/src/test/java/jadx/tests/integration/variables/TestVariablesInLoop.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
package jadx.tests.integration.variables; | ||
|
||
import org.junit.jupiter.api.Test; | ||
|
||
import jadx.tests.api.SmaliTest; | ||
|
||
import static jadx.tests.api.utils.assertj.JadxAssertions.assertThat; | ||
|
||
public class TestVariablesInLoop extends SmaliTest { | ||
|
||
@Test | ||
public void test() { | ||
assertThat(getClassNodeFromSmali()) | ||
.code() | ||
.containsOne("int i;") | ||
.countString(2, "i = 0;") | ||
.doesNotContain("i3"); | ||
} | ||
} |
103 changes: 103 additions & 0 deletions
103
jadx-core/src/test/smali/variables/TestVariablesInLoop.smali
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,103 @@ | ||
.class public abstract Lvariables/TestVariablesInLoop; | ||
.super Ljava/lang/Object; | ||
.source "SourceFile" | ||
|
||
.implements Ljava/util/List; | ||
|
||
.annotation system Ldalvik/annotation/Signature; | ||
value = { | ||
"Ljava/lang/Object;", | ||
"Ljava/util/List<", | ||
"Ljava/lang/Long;", | ||
">;" | ||
} | ||
.end annotation | ||
|
||
.method static test(Ljava/util/List;)I | ||
.locals 5 | ||
.annotation system Ldalvik/annotation/Signature; | ||
value = { | ||
"(", | ||
"Ljava/util/List<", | ||
"Ljava/lang/Long;", | ||
">;)I" | ||
} | ||
.end annotation | ||
|
||
invoke-interface {p0}, Ljava/util/List;->size()I | ||
|
||
move-result v0 | ||
|
||
const/4 v1, 0x0 | ||
|
||
if-nez v0, :cond_0 | ||
|
||
return v1 | ||
|
||
:cond_0 | ||
instance-of v2, p0, Lvariables/TestVariablesInLoop; | ||
|
||
if-eqz v2, :cond_1 | ||
|
||
check-cast p0, Lvariables/TestVariablesInLoop; | ||
|
||
const/4 v2, 0x0 | ||
|
||
:goto_0 | ||
if-ge v1, v0, :cond_2 | ||
|
||
invoke-virtual {p0, v1}, Lvariables/TestVariablesInLoop;->getLong(I)J | ||
|
||
move-result-wide v3 | ||
|
||
invoke-static {v3, v4}, Lvariables/TestVariablesInLoop;->mth(J)I | ||
|
||
move-result v3 | ||
|
||
add-int/2addr v2, v3 | ||
|
||
add-int/lit8 v1, v1, 0x1 | ||
|
||
goto :goto_0 | ||
|
||
:cond_1 | ||
const/4 v2, 0x0 | ||
|
||
:goto_1 | ||
if-ge v1, v0, :cond_2 | ||
|
||
invoke-interface {p0, v1}, Ljava/util/List;->get(I)Ljava/lang/Object; | ||
|
||
move-result-object v3 | ||
|
||
check-cast v3, Ljava/lang/Long; | ||
|
||
invoke-virtual {v3}, Ljava/lang/Long;->longValue()J | ||
|
||
move-result-wide v3 | ||
|
||
invoke-static {v3, v4}, Lvariables/TestVariablesInLoop;->mth(J)I | ||
|
||
move-result v3 | ||
|
||
add-int/2addr v2, v3 | ||
|
||
add-int/lit8 v1, v1, 0x1 | ||
|
||
goto :goto_1 | ||
|
||
:cond_2 | ||
return v2 | ||
.end method | ||
|
||
.method public final getLong(I)J | ||
.locals 2 | ||
const/16 v0, 0x0 | ||
return-wide v0 | ||
.end method | ||
|
||
.method static mth(J)I | ||
.locals 2 | ||
const/4 v0, 0x0 | ||
return v0 | ||
.end method |