Decomposing short circuit

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

Decomposing short circuit

Ilya Mirsky
Hi,

I need to decompose short circuit expressions into regular And, Or.
I've started doing it manually, but then I figured out that the compiler probably does the same.
Currently I identify such expressions using Stmt::hasImplicitControlFlow, and then if it's a BinaryOperator I check if opCode is BO_LAnd or BO_LOr. Is this the right way?
Is there a way to get clang to do it for me?
Can I assist CFG class with this issue?


Thanks in advance,

--
Best Regards,
Ilya Mirsky
www.cs.bgu.ac.il/~mirskyil


_______________________________________________
cfe-dev mailing list
[hidden email]
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev
Reply | Threaded
Open this post in threaded view
|

Re: Decomposing short circuit

Ted Kremenek

On Sep 20, 2010, at 5:38 AM, Ilya Mirsky wrote:

> Hi,
>
> I need to decompose short circuit expressions into regular And, Or.
> I've started doing it manually, but then I figured out that the compiler probably does the same.
> Currently I identify such expressions using Stmt::hasImplicitControlFlow, and then if it's a BinaryOperator I check if opCode is BO_LAnd or BO_LOr. Is this the right way?
> Is there a way to get clang to do it for me?
> Can I assist CFG class with this issue?

Hi Ilya,

It's a little hard for me to advise you on what to do since I don't have a sense for what you are trying to accomplish, but your approach for identifying '||' and '&&' operations is correct.  The CFG class represents all such control-flow explicitly by constructing basic blocks, etc., but that might be overkill for what you are trying to accomplish.

Ted


_______________________________________________
cfe-dev mailing list
[hidden email]
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev