Default case without predecessor

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

Default case without predecessor

Panke
Hi,

If I run clang on the code below, either via my own FrontendAction and libtooling or just with
clang -cc1 -analyze -analyze-checker debug.DumpCFG I get an CFG where the default case
has no predecessor. If I compile the code to llvm and dump a CFG from opt then all cases
are successors of the switch.

Is it possible to obtain a CFG from clang with all edges for the switch statement?

cheers,
Panke

--
typedef enum E
{
        A,
        B
} E;

int foo(E e)
{
        switch(e)
        {
                case A:
                        return 12;
                case B:
                        return 42;
                default:
                        return 1242;
        }
        return 0;
}
--

Reply | Threaded
Open this post in threaded view
|

Re: Default case without predecessor

Zach Davis
I believe the edge from the switch to the default case is pruned because all of the enum values are covered by the switch.  The analyzer is considering the default case as "not possible".

Zach


On Wed, Jan 29, 2014 at 12:33 PM, Panke <[hidden email]> wrote:
Hi,

If I run clang on the code below, either via my own FrontendAction and
libtooling or just with
clang -cc1 -analyze -analyze-checker debug.DumpCFG I get an CFG where the
default case
has no predecessor. If I compile the code to llvm and dump a CFG from opt
then all cases
are successors of the switch.

Is it possible to obtain a CFG from clang with all edges for the switch
statement?

cheers,
Panke

--
typedef enum E
{
        A,
        B
} E;

int foo(E e)
{
        switch(e)
        {
                case A:
                        return 12;
                case B:
                        return 42;
                default:
                        return 1242;
        }
        return 0;
}
--





--
View this message in context: http://clang-developers.42468.n3.nabble.com/Default-case-without-predecessor-tp4037484.html
Sent from the Clang Developers mailing list archive at Nabble.com.
_______________________________________________
cfe-dev mailing list
[hidden email]
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev


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

Re: Default case without predecessor

Panke
Zach Davis wrote
I believe the edge from the switch to the default case is pruned because
all of the enum values are covered by the switch.  The analyzer is
considering the default case as "not possible".
Is it possible to get a CFG before pruning? I've tried
BuildOptions.PruneTrivialFalseEdges = false, but that didn't help.
Reply | Threaded
Open this post in threaded view
|

Re: Default case without predecessor

Zach Davis
It looks like the option to disable this is

  CFGBlock::FilterOptions.IgnoreDefaultsWithCoveredEnums

I don't know what the easiest way to get this unset in you
program would be.


On Sun, Feb 2, 2014 at 11:52 AM, Panke <[hidden email]> wrote:
Zach Davis wrote
> I believe the edge from the switch to the default case is pruned because
> all of the enum values are covered by the switch.  The analyzer is
> considering the default case as "not possible".

Is it possible to get a CFG before pruning? I've tried
BuildOptions.PruneTrivialFalseEdges = false, but that didn't help.



--
View this message in context: http://clang-developers.42468.n3.nabble.com/Default-case-without-predecessor-tp4037484p4037619.html
Sent from the Clang Developers mailing list archive at Nabble.com.
_______________________________________________
cfe-dev mailing list
[hidden email]
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev


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