[PATCH] Dereference then check

Anders Rönnholm Anders.Ronnholm at evidente.se
Mon Oct 13 02:07:51 PDT 2014


Hi Anna,

It follows the path for one block. If a check occurs after a dereference in that path a warning will be made.

This example don't work since the check occurs in a different block. I would like to be able to warn here but i guess we need to follow all blocks and make sure a dereference is made on all paths if this example is going to work. How do we see that?

//Anders

> 
> Anders,
> 
> Could you describe the high-level algorithm you are using?
> 
> Here is one example I would expect to work.
> int test (int *x, int cond) {
>   if (cond)
>     *x = 1; // expected-warning
>   else
>     *x = 2;  // expected-warning
>   if (!x)
>     return 0;
>  // *x = 0;// no-warning
> 
>   return 1;
> }
> 
> I have a bunch of other minor comments about the other parts of the patch
> that I will send separately.
> 
> Anna.
> 
> > On Sep 25, 2014, at 7:30 AM, Anders Rönnholm
> <Anders.Ronnholm at evidente.se> wrote:
> >
> > Hi,
> >
> > I have made a new checker similar to the divison by zero i previously
> submitted.
> >
> > This one checks for dereferences that are later compared against zero.
> >
> > As requested i have made it CFG-based like how DeadStores is
> implemented. I hope this is how you meant.
> >
> > //Anders<derefthencheck.diff>





More information about the cfe-commits mailing list