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

Marc-André Laverdière-Papineau marc-andre.laverdiere-papineau at polymtl.ca
Fri May 24 12:49:43 EDT 2013


Thinking a bit about it, I would suggest to look into the Java source AST.

The problem is that, in data flow terms, there is no difference between

if (a) {b} else {c}

and

if (a){b}
c

So I doubt any of the Jimple will give you a API to detect that...

That being said, why do you need to distinguish those two cases anyway?

Marc-André Laverdière-Papineau
Doctorant - PhD Candidate

On 13/05/13 04:02 PM, Manuel Bravo wrote:
> 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
> _______________________________________________
> Soot-list mailing list
> Soot-list at sable.mcgill.ca
> http://mailman.cs.mcgill.ca/mailman/listinfo/soot-list
> 


More information about the Soot-list mailing list