-
Notifications
You must be signed in to change notification settings - Fork 4.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: remove move instructions with unused result (#835)
- Loading branch information
Showing
4 changed files
with
124 additions
and
0 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
41 changes: 41 additions & 0 deletions
41
jadx-core/src/test/java/jadx/tests/integration/others/TestInsnsBeforeSuper2.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,41 @@ | ||
package jadx.tests.integration.others; | ||
|
||
import org.junit.jupiter.api.Test; | ||
|
||
import jadx.tests.api.SmaliTest; | ||
|
||
import static jadx.tests.api.utils.assertj.JadxAssertions.assertThat; | ||
|
||
public class TestInsnsBeforeSuper2 extends SmaliTest { | ||
// @formatter:off | ||
/* | ||
public class TestInsnsBeforeSuper2 extends java.lang.Exception { | ||
private int mErrorType; | ||
public TestInsnsBeforeSuper2(java.lang.String r9, int r10) { | ||
r8 = this; | ||
r0 = r8 | ||
r1 = r9 | ||
r2 = r10 | ||
r3 = r0 | ||
r4 = r1 | ||
r5 = r2 | ||
r6 = r1 | ||
r0.<init>(r6) | ||
r7 = 0 | ||
r0.mErrorType = r7 | ||
r0.mErrorType = r2 | ||
return | ||
} | ||
} | ||
*/ | ||
// @formatter:on | ||
|
||
@Test | ||
public void test() { | ||
assertThat(getClassNodeFromSmali()) | ||
.code() | ||
.containsOne("super(message);") | ||
.containsOne("this.mErrorType = errorType;"); | ||
} | ||
} |
51 changes: 51 additions & 0 deletions
51
jadx-core/src/test/smali/others/TestInsnsBeforeSuper2.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,51 @@ | ||
.class public Lothers/TestInsnsBeforeSuper2; | ||
.super Ljava/lang/Exception; | ||
.source "MyException.java" | ||
|
||
# instance fields | ||
.field private mErrorType:I | ||
|
||
|
||
# direct methods | ||
.method public constructor <init>(Ljava/lang/String;I)V | ||
.locals 8 | ||
|
||
.prologue | ||
move-object v0, p0 | ||
|
||
.local v0, "this":Lothers/TestInsnsBeforeSuper2; | ||
move-object v1, p1 | ||
|
||
.local v1, "message":Ljava/lang/String; | ||
move v2, p2 | ||
|
||
.line 39 | ||
.local v2, "errorType":I | ||
move-object v3, v0 | ||
|
||
.local v3, "this":Lothers/TestInsnsBeforeSuper2; | ||
move-object v4, v1 | ||
|
||
.local v4, "message":Ljava/lang/String; | ||
move v5, v2 | ||
|
||
.line 51 | ||
.end local v0 # "this":Lothers/TestInsnsBeforeSuper2; | ||
.end local v1 # "message":Ljava/lang/String; | ||
.end local v2 # "errorType":I | ||
.local v5, "errorType":I | ||
move-object v6, v1 | ||
|
||
invoke-direct {v0, v6}, Ljava/lang/Exception;-><init>(Ljava/lang/String;)V | ||
|
||
.line 39 | ||
const/4 v7, 0x0 | ||
|
||
iput v7, v0, Lothers/TestInsnsBeforeSuper2;->mErrorType:I | ||
|
||
.line 52 | ||
iput v2, v0, Lothers/TestInsnsBeforeSuper2;->mErrorType:I | ||
|
||
.line 53 | ||
return-void | ||
.end method |