On Thu, 31 Aug 2017, Ondřej Kuzník wrote:

> On Thu, Aug 31, 2017 at 06:01:07PM +0200, Julia Lawall wrote:
> > On Thu, 31 Aug 2017, Ondřej Kuzník wrote:
> >> On Thu, Aug 31, 2017 at 05:52:14PM +0200, Julia Lawall wrote:
> >>> So you want to drop the braces if there is no comment and keep the brace
> >>> if there is a comment?  You can't match on comments.  The only thing you
> >>> could do is check the number of lines between the { and Debug.
> >>
> >> Something slightly different, I want to remove the braces only if they
> >> do not "belong" to an if statement.
> >
> > Does that occur?
> >
> > In any case, just do:
> >
> > @r@
> > position p1;
> > statement S;
> > @@
> >
> > if (...) {@p1  Debug(...); } else S
> >
> > @@
> > position p1 != r.p1;
> > @@
> >
> > -{@p1
> >   Debug(...);
> > -}
>
> I have tried the following:
>
> @guard@
> position p;
> @@
>
> if ( ... ) {@p
>  Debug( ... );
> }

You didn't put the else S.

If you add it, the rule will still match cases with no else.

julia

>
> @@
> position p != guard.p;
> @@
> -{@p
>  Debug( ... );
> -}
>
> But it still modifies servers/slapd/back-asyncmeta/bind.c:879
>
> --
> Ondřej Kuzník
> Senior Software Engineer
> Symas Corporation                       http://www.symas.com
> Packaged, certified, and supported LDAP solutions powered by OpenLDAP
>
_______________________________________________
Cocci mailing list
Cocci@systeme.lip6.fr
https://systeme.lip6.fr/mailman/listinfo/cocci

Reply via email to