* [Cocci] How to handle/ignore iterator macros?
@ 2019-02-25 17:42 Timur Tabi
2019-02-25 19:52 ` Michael Stefaniuc
2019-02-25 20:38 ` Julia Lawall
0 siblings, 2 replies; 5+ messages in thread
From: Timur Tabi @ 2019-02-25 17:42 UTC (permalink / raw)
To: cocci
I have lots of code that looks like this:
#define MY_ITERATOR(x, y) for (x=0; x<y; x++)
MY_ITERATOR(v, 20)
{
printf("%i\n", v);
}
Spatch chokes on this because it thinks MY_ITERATOR() should end with
a semicolon:
...
bad: MY_ITERATOR(v, 20)
BAD:!!!!! {
bad: printf("%i\n", v);
...
I tried specifying "--undefined MY_ITERATOR", but that did nothing.
_______________________________________________
Cocci mailing list
Cocci@systeme.lip6.fr
https://systeme.lip6.fr/mailman/listinfo/cocci
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [Cocci] How to handle/ignore iterator macros?
2019-02-25 17:42 [Cocci] How to handle/ignore iterator macros? Timur Tabi
@ 2019-02-25 19:52 ` Michael Stefaniuc
2019-02-25 20:38 ` Timur Tabi
2019-02-25 20:38 ` Julia Lawall
1 sibling, 1 reply; 5+ messages in thread
From: Michael Stefaniuc @ 2019-02-25 19:52 UTC (permalink / raw)
To: Timur Tabi; +Cc: cocci
On 2/25/19 6:42 PM, Timur Tabi wrote:
> I have lots of code that looks like this:
>
> #define MY_ITERATOR(x, y) for (x=0; x<y; x++)
>
> MY_ITERATOR(v, 20)
> {
> printf("%i\n", v);
> }
>
> Spatch chokes on this because it thinks MY_ITERATOR() should end with
> a semicolon:
>
> ...
> bad: MY_ITERATOR(v, 20)
> BAD:!!!!! {
> bad: printf("%i\n", v);
> ...
>
> I tried specifying "--undefined MY_ITERATOR", but that did nothing.
For cases like that I've added a define to my macro file to be used with
--macro-file-builtins or --macro-file.
But I'm working on Wine so have to use my own macro file anyway so I'm
not relying on the one that comes with coccinelle.
bye
michael
_______________________________________________
Cocci mailing list
Cocci@systeme.lip6.fr
https://systeme.lip6.fr/mailman/listinfo/cocci
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [Cocci] How to handle/ignore iterator macros?
2019-02-25 19:52 ` Michael Stefaniuc
@ 2019-02-25 20:38 ` Timur Tabi
2019-02-25 20:45 ` Julia Lawall
0 siblings, 1 reply; 5+ messages in thread
From: Timur Tabi @ 2019-02-25 20:38 UTC (permalink / raw)
To: Michael Stefaniuc; +Cc: cocci, Timur Tabi
On Mon, Feb 25, 2019 at 1:52 PM Michael Stefaniuc <mstefani@mykolab.com> wrote:
>
> For cases like that I've added a define to my macro file to be used with
> --macro-file-builtins or --macro-file.
That works great, thanks! I used this:
#define MY_ITERATOR(a,b) for (;;)
_______________________________________________
Cocci mailing list
Cocci@systeme.lip6.fr
https://systeme.lip6.fr/mailman/listinfo/cocci
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [Cocci] How to handle/ignore iterator macros?
2019-02-25 17:42 [Cocci] How to handle/ignore iterator macros? Timur Tabi
2019-02-25 19:52 ` Michael Stefaniuc
@ 2019-02-25 20:38 ` Julia Lawall
1 sibling, 0 replies; 5+ messages in thread
From: Julia Lawall @ 2019-02-25 20:38 UTC (permalink / raw)
To: Timur Tabi; +Cc: cocci
On Mon, 25 Feb 2019, Timur Tabi wrote:
> I have lots of code that looks like this:
>
> #define MY_ITERATOR(x, y) for (x=0; x<y; x++)
>
> MY_ITERATOR(v, 20)
> {
> printf("%i\n", v);
> }
>
> Spatch chokes on this because it thinks MY_ITERATOR() should end with
> a semicolon:
>
> ...
> bad: MY_ITERATOR(v, 20)
> BAD:!!!!! {
> bad: printf("%i\n", v);
> ...
>
> I tried specifying "--undefined MY_ITERATOR", but that did nothing.
If you just want to get it to parse, but don't care about the iterator
behavior, you can put the following in standard.h
#define MY_ITERATOR(x) MACROSTATEMENT
A feature that was considered, but I don't remember whether it was
implemented, was to put
iterator name MY_ITERATOR;
in some rule of the semantic patch. Then Coccinelle would know about the
looping behavior as well. But I don't know if that works.
--undefined is for choosing ifdef branches.
julia
> _______________________________________________
> Cocci mailing list
> Cocci@systeme.lip6.fr
> https://systeme.lip6.fr/mailman/listinfo/cocci
>
_______________________________________________
Cocci mailing list
Cocci@systeme.lip6.fr
https://systeme.lip6.fr/mailman/listinfo/cocci
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [Cocci] How to handle/ignore iterator macros?
2019-02-25 20:38 ` Timur Tabi
@ 2019-02-25 20:45 ` Julia Lawall
0 siblings, 0 replies; 5+ messages in thread
From: Julia Lawall @ 2019-02-25 20:45 UTC (permalink / raw)
To: Timur Tabi; +Cc: cocci
On Mon, 25 Feb 2019, Timur Tabi wrote:
> On Mon, Feb 25, 2019 at 1:52 PM Michael Stefaniuc <mstefani@mykolab.com> wrote:
> >
> > For cases like that I've added a define to my macro file to be used with
> > --macro-file-builtins or --macro-file.
>
> That works great, thanks! I used this:
>
> #define MY_ITERATOR(a,b) for (;;)
Yes, this is another option that will likely capture the loop behavior as
well.
julia
_______________________________________________
Cocci mailing list
Cocci@systeme.lip6.fr
https://systeme.lip6.fr/mailman/listinfo/cocci
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2019-02-25 20:45 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-02-25 17:42 [Cocci] How to handle/ignore iterator macros? Timur Tabi
2019-02-25 19:52 ` Michael Stefaniuc
2019-02-25 20:38 ` Timur Tabi
2019-02-25 20:45 ` Julia Lawall
2019-02-25 20:38 ` Julia Lawall
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).