[Soot-list] Jimple: simple if or if else

Manuel Bravo manuelbravogestoso at gmail.com
Mon May 13 16:02:16 EDT 2013


Hi everyone,

I need to distinguish between a simple if (without else clause) and a if-else. In other words, when I am analysing 
an IfStmt, I need to know whether the if has else clause or not. Digging into the mailing list, I found this 
post: http://www.sable.mcgill.ca/pipermail/soot-list/2011-March/003635.html. It is asking the same question. 
Nevertheless the last reply to the question (the one that was accepted as the solution) is the following:

Hi Pedro.

Thanks for the visualization. That helps.

One way to do this is to use a dominator analysis, e.g.
MHGDominatorsFinder. A statement s post-dominates a statement t if
every path starting at t has to go through s.

In the if-example you have, the statement that the if-statement jumps
to, i.e., the nop at the bottom, post-dominates the if-statement
itself. In the if-else-example, this is not the case: there is a path
(the left branch) which goes through the if statement but never goes
through the nop statement that the if jumps to.

HTH,
Eric
After experimenting a bit, I realize (at least I think), that this solution cannot be applied in case we have break
instruction in the if clause. For instance:

for (int i=0; i<3; i++){
  if (b>4){
    break;
  }
  b++;
}

In that example we have a "simple" if. Nevertheless, If we use the proposed solution, it is not going to be 
identified as a "simple" if but as if-else.

I could not come up with another idea, so I would like to know whether someone has a new proposition.

Thank you in advance.

Best,
Manuel


More information about the Soot-list mailing list