Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in
Toggle navigation
J
jadx
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
open-source
jadx
Commits
7f4e6418
Commit
7f4e6418
authored
Feb 15, 2019
by
Skylot
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix: skip duplicated block in complex if (#441)
parent
710245d5
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
687 additions
and
1 deletion
+687
-1
IfMakerHelper.java
...in/java/jadx/core/dex/visitors/regions/IfMakerHelper.java
+12
-1
TestComplexIf.java
...java/jadx/tests/integration/conditions/TestComplexIf.java
+39
-0
TestComplexIf.smali
jadx-core/src/test/smali/conditions/TestComplexIf.smali
+636
-0
No files found.
jadx-core/src/main/java/jadx/core/dex/visitors/regions/IfMakerHelper.java
View file @
7f4e6418
...
...
@@ -263,7 +263,18 @@ public class IfMakerHelper {
result
.
setIfBlock
(
first
.
getIfBlock
());
result
.
merge
(
first
,
second
);
BlockNode
otherPathBlock
=
followThenBranch
?
first
.
getElseBlock
()
:
first
.
getThenBlock
();
BlockNode
otherPathBlock
;
if
(
followThenBranch
)
{
otherPathBlock
=
first
.
getElseBlock
();
if
(!
otherPathBlock
.
equals
(
result
.
getElseBlock
()))
{
result
.
getSkipBlocks
().
add
(
otherPathBlock
);
}
}
else
{
otherPathBlock
=
first
.
getThenBlock
();
if
(!
otherPathBlock
.
equals
(
result
.
getThenBlock
()))
{
result
.
getSkipBlocks
().
add
(
otherPathBlock
);
}
}
skipSimplePath
(
otherPathBlock
,
result
.
getSkipBlocks
());
return
result
;
}
...
...
jadx-core/src/test/java/jadx/tests/integration/conditions/TestComplexIf.java
0 → 100644
View file @
7f4e6418
package
jadx
.
tests
.
integration
.
conditions
;
import
org.junit.Test
;
import
jadx.core.dex.nodes.ClassNode
;
import
jadx.tests.api.SmaliTest
;
import
static
jadx
.
tests
.
api
.
utils
.
JadxMatchers
.
containsOne
;
import
static
org
.
junit
.
Assert
.
assertThat
;
public
class
TestComplexIf
extends
SmaliTest
{
/*
public final class TestComplexIf {
private String a;
private int b;
private float c;
public final boolean test() {
if (this.a.equals("GT-P6200") || this.a.equals("GT-P6210") || ... ) {
return true;
}
if (this.a.equals("SM-T810") || this.a.equals("SM-T813") || ...) {
return false;
}
return this.c > 160.0f ? true : this.c <= 0.0f && ((this.b & 15) == 4 ? 1 : null) != null;
}
}
*/
@Test
public
void
test
()
{
ClassNode
cls
=
getClassNodeFromSmaliWithPkg
(
"conditions"
,
"TestComplexIf"
);
String
code
=
cls
.
getCode
().
toString
();
assertThat
(
code
,
containsOne
(
"if (this.a.equals(\"GT-P6200\") || this.a.equals(\"GT-P6210\") || this.a.equals(\"A100\") "
+
"|| this.a.equals(\"A101\") || this.a.equals(\"LIFETAB_S786X\") || this.a.equals(\"VS890 4G\")) {"
));
}
}
jadx-core/src/test/smali/conditions/TestComplexIf.smali
0 → 100644
View file @
7f4e6418
This diff is collapsed.
Click to expand it.
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment