In Cil, it automatically simplify If conditional expressions to have a
cascade of simple predicates. For example,
if (x > 10 && x < 100)
will be transformed to
if (x > 10)
if (x < 100)
Could anyone please point me to the code of this functionality in the Cil
A bunch of thanks !
With Kind Regards
From: Gabriel Kerneis <gabriel@ke...> - 2012-12-20 09:48:57
On Thu, Dec 20, 2012 at 08:23:20AM +0800, TheAnh Do wrote:
> In Cil, it automatically simplify If conditional expressions to have a
> cascade of simple predicates. For example,
> if (x > 10 && x < 100)
> will be transformed to
> if (x > 10)
> if (x < 100)
Yes, unless you use the flag --useLogicalOperators.
> Could anyone please point me to the code of this functionality in the Cil
Like most of CIL transformations, it happens in the file src/frontc/cabs2cil.ml.
The function compileCondExp does the actual transformation, using CEAnd and CEOr
constructors (of type condExpRes) returned by doCondExp. This compileCondExp is
called by doCondition, which handles the IF case in doStatement (but also in a
number of other cases, like WHILE, DOWHILE, FOR, etc.), as well as by doExp
directly to handle arbitrary expressions involving && and ||. The QUESTION case
(corresponding to the ternary operator ?:) is a more complicated matter and
I suggest you to ignore it until you fully understand how the previous functions
Get latest updates about Open Source Projects, Conferences and News.