[Soot-list] Distinguishing between if and while loops

Dhriti Khanna dhritik at iiitd.ac.in
Mon Aug 5 02:25:39 EDT 2019


Hello,
To distinguish loops from if statements, I am doing the following steps:
1. I am using LoopFinder to find all the loops in a file and storing them
in a list.
2. If I encounter an 'if' statement, I check if it is the head of any of
the loops in my list.
3. If it is, then its a loop, otherwise its an 'if' statement.

But, the above method does not accomodate the case when the loop head is
not the predicate statement but some preparatory statement. For example,
this loop: *for(int i = 0; i<Sample.f3; i++) {} *is converted into the
following:








*label7:        i = i + 1;     label8:        $i2 = <Sample: int f3>;
  if i < $i2 goto label7;*

and the loop head is not a predicate statement. How do I handle such cases?
If I start going inside loop bodies to check for the predicate statements,
the analysis might encounter a genuine 'if' statement inside the loop and
classify as a loop.
Is it okay if I check only the first statement of the loop body if the loop
header is not a predicate statement?

-- 
Regards
Dhriti Khanna
PhD Scholar
IIIT Delhi
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mailman.CS.McGill.CA/pipermail/soot-list/attachments/20190805/a190a016/attachment.html>


More information about the Soot-list mailing list