mirror of
https://github.com/revanced/smali.git
synced 2025-05-29 04:10:13 +02:00
Check for unreachable instructions and comment them out
git-svn-id: https://smali.googlecode.com/svn/trunk@673 55b6fa8a-2a1e-11de-a435-ffa8d773f76a
This commit is contained in:
parent
10a9518111
commit
650725bbd3
@ -291,6 +291,8 @@ public class MethodDefinition {
|
|||||||
BitSet printPreRegister = new BitSet(registerCount);
|
BitSet printPreRegister = new BitSet(registerCount);
|
||||||
BitSet printPostRegister = new BitSet(registerCount);
|
BitSet printPostRegister = new BitSet(registerCount);
|
||||||
|
|
||||||
|
boolean lastIsUnreachable = false;
|
||||||
|
|
||||||
int currentCodeAddress = 0;
|
int currentCodeAddress = 0;
|
||||||
for (int i=0; i<instructions.size(); i++) {
|
for (int i=0; i<instructions.size(); i++) {
|
||||||
AnalyzedInstruction instruction = instructions.get(i);
|
AnalyzedInstruction instruction = instructions.get(i);
|
||||||
@ -301,13 +303,25 @@ public class MethodDefinition {
|
|||||||
|
|
||||||
if (instruction.isDead()) {
|
if (instruction.isDead()) {
|
||||||
methodItems.add(new CommentedOutMethodItem(stg, methodItem));
|
methodItems.add(new CommentedOutMethodItem(stg, methodItem));
|
||||||
|
lastIsUnreachable = false;
|
||||||
|
} else if (instruction.getPredecessorCount() == 0 &&
|
||||||
|
!instruction.getInstruction().getFormat().variableSizeFormat) {
|
||||||
|
if (!lastIsUnreachable) {
|
||||||
|
methodItems.add(
|
||||||
|
new CommentMethodItem(stg, "Unreachable code", currentCodeAddress, Double.MIN_VALUE));
|
||||||
|
}
|
||||||
|
|
||||||
|
methodItems.add(new CommentedOutMethodItem(stg, methodItem));
|
||||||
|
lastIsUnreachable = true;
|
||||||
} else {
|
} else {
|
||||||
methodItems.add(methodItem);
|
methodItems.add(methodItem);
|
||||||
|
lastIsUnreachable = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (instruction.getInstruction().getFormat() == Format.UnresolvedNullReference) {
|
if (instruction.getInstruction().getFormat() == Format.UnresolvedNullReference) {
|
||||||
methodItems.add(new CommentedOutMethodItem(stg, InstructionMethodItemFactory.makeInstructionFormatMethodItem(this,
|
methodItems.add(new CommentedOutMethodItem(stg,
|
||||||
encodedMethod.codeItem, currentCodeAddress, stg, instruction.getOriginalInstruction(), false)));
|
InstructionMethodItemFactory.makeInstructionFormatMethodItem(this, encodedMethod.codeItem,
|
||||||
|
currentCodeAddress, stg, instruction.getOriginalInstruction(), false)));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (i != instructions.size() - 1) {
|
if (i != instructions.size() - 1) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user