提交 ec8309af 编写于 作者: S Skylot

core: fix processing 'if' at loop end

上级 627a4dc8
......@@ -47,8 +47,8 @@ public class IfMakerHelper {
info.setOutBlock(null);
return info;
}
boolean badThen = !allPathsFromIf(thenBlock, info);
boolean badElse = !allPathsFromIf(elseBlock, info);
boolean badThen = thenBlock.contains(AFlag.LOOP_START) || !allPathsFromIf(thenBlock, info);
boolean badElse = elseBlock.contains(AFlag.LOOP_START) || !allPathsFromIf(elseBlock, info);
if (badThen && badElse) {
LOG.debug("Stop processing blocks after 'if': {}, method: {}", info.getIfBlock(), mth);
return null;
......
package jadx.tests.internal.loops;
import jadx.api.InternalJadxTest;
import jadx.core.dex.nodes.ClassNode;
import java.util.Iterator;
import org.junit.Test;
import static jadx.tests.utils.JadxMatchers.containsOne;
import static org.junit.Assert.assertThat;
public class TestLoopDetection4 extends InternalJadxTest {
public static class TestCls {
private Iterator<String> iterator;
private SomeCls filter;
private String test() {
while (iterator.hasNext()) {
String next = iterator.next();
String filtered = filter.filter(next);
if (filtered != null) {
return filtered;
}
}
return null;
}
private class SomeCls {
public String filter(String str) {
return str;
}
}
}
@Test
public void test() {
ClassNode cls = getClassNode(TestCls.class);
String code = cls.getCode().toString();
System.out.println(code);
assertThat(code, containsOne("while (this.iterator.hasNext()) {"));
assertThat(code, containsOne("if (filtered != null) {"));
assertThat(code, containsOne("return filtered;"));
assertThat(code, containsOne("return null;"));
}
}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册