* [Cocci] __init macro and Coccinelle
@ 2017-08-15 20:18 Gustavo A. R. Silva
2017-08-15 20:24 ` Julia Lawall
0 siblings, 1 reply; 5+ messages in thread
From: Gustavo A. R. Silva @ 2017-08-15 20:18 UTC (permalink / raw)
To: cocci
Hello everybody,
I have the following script:
@r@
identifier f_init;
position p;
@@
* __init f_init at p(...)
I want to spot __init functions, but it doesn't seem to work. I get a
parse error around the __init macro:
around = '__init',
whole content = * __init f_init at p(...)
I wonder if there is a way to work around that issue?
Thank you
--
Gustavo A. R. Silva
^ permalink raw reply [flat|nested] 5+ messages in thread
* [Cocci] __init macro and Coccinelle
2017-08-15 20:18 [Cocci] __init macro and Coccinelle Gustavo A. R. Silva
@ 2017-08-15 20:24 ` Julia Lawall
2017-08-15 20:29 ` Gustavo A. R. Silva
0 siblings, 1 reply; 5+ messages in thread
From: Julia Lawall @ 2017-08-15 20:24 UTC (permalink / raw)
To: cocci
On Tue, 15 Aug 2017, Gustavo A. R. Silva wrote:
> Hello everybody,
>
> I have the following script:
>
> @r@
> identifier f_init;
> position p;
> @@
>
>
> * __init f_init at p(...)
>
> I want to spot __init functions, but it doesn't seem to work. I get a parse
> error around the __init macro:
>
> around = '__init',
> whole content = * __init f_init at p(...)
>
> I wonder if there is a way to work around that issue?
If you want to match a function, you have to put something that will match
the whole function, not just the top part. So it would be
__init f(...) { ... }
julia
^ permalink raw reply [flat|nested] 5+ messages in thread* [Cocci] __init macro and Coccinelle
2017-08-15 20:24 ` Julia Lawall
@ 2017-08-15 20:29 ` Gustavo A. R. Silva
2017-08-15 20:42 ` Julia Lawall
0 siblings, 1 reply; 5+ messages in thread
From: Gustavo A. R. Silva @ 2017-08-15 20:29 UTC (permalink / raw)
To: cocci
On 08/15/2017 03:24 PM, Julia Lawall wrote:
>
>
> On Tue, 15 Aug 2017, Gustavo A. R. Silva wrote:
>
>> Hello everybody,
>>
>> I have the following script:
>>
>> @r@
>> identifier f_init;
>> position p;
>> @@
>>
>>
>> * __init f_init at p(...)
>>
>> I want to spot __init functions, but it doesn't seem to work. I get a parse
>> error around the __init macro:
>>
>> around = '__init',
>> whole content = * __init f_init at p(...)
>>
>> I wonder if there is a way to work around that issue?
>
> If you want to match a function, you have to put something that will match
> the whole function, not just the top part. So it would be
>
> __init f(...) { ... }
>
That worked, thanks. :)
But now if I combine it in the following way:
@r1@
identifier s_type;
identifier f_init;
identifier s;
position p;
type T;
@@
(
* struct s_type s = {.init = f_init at p};
|
* __init f_init at p(...) { ... }
)
I get the same error parse error:
around = '__init',
whole content = __init f_init at p(...) { ... }
--
Gustavo A. R. Silva
^ permalink raw reply [flat|nested] 5+ messages in thread* [Cocci] __init macro and Coccinelle
2017-08-15 20:29 ` Gustavo A. R. Silva
@ 2017-08-15 20:42 ` Julia Lawall
2017-08-15 20:45 ` Gustavo A. R. Silva
0 siblings, 1 reply; 5+ messages in thread
From: Julia Lawall @ 2017-08-15 20:42 UTC (permalink / raw)
To: cocci
On Tue, 15 Aug 2017, Gustavo A. R. Silva wrote:
>
>
> On 08/15/2017 03:24 PM, Julia Lawall wrote:
> >
> >
> > On Tue, 15 Aug 2017, Gustavo A. R. Silva wrote:
> >
> > > Hello everybody,
> > >
> > > I have the following script:
> > >
> > > @r@
> > > identifier f_init;
> > > position p;
> > > @@
> > >
> > >
> > > * __init f_init at p(...)
> > >
> > > I want to spot __init functions, but it doesn't seem to work. I get a
> > > parse
> > > error around the __init macro:
> > >
> > > around = '__init',
> > > whole content = * __init f_init at p(...)
> > >
> > > I wonder if there is a way to work around that issue?
> >
> > If you want to match a function, you have to put something that will match
> > the whole function, not just the top part. So it would be
> >
> > __init f(...) { ... }
> >
>
> That worked, thanks. :)
>
> But now if I combine it in the following way:
>
> @r1@
> identifier s_type;
> identifier f_init;
> identifier s;
> position p;
> type T;
> @@
>
> (
> * struct s_type s = {.init = f_init at p};
> |
> * __init f_init at p(...) { ... }
> )
>
> I get the same error parse error:
>
> around = '__init',
> whole content = __init f_init at p(...) { ... }
Don't do it :)
There are some parsing hacks to differentiate function calls from function
definitions. Adding the disjunction defeats them. Just make two separate
rules.
julia
^ permalink raw reply [flat|nested] 5+ messages in thread* [Cocci] __init macro and Coccinelle
2017-08-15 20:42 ` Julia Lawall
@ 2017-08-15 20:45 ` Gustavo A. R. Silva
0 siblings, 0 replies; 5+ messages in thread
From: Gustavo A. R. Silva @ 2017-08-15 20:45 UTC (permalink / raw)
To: cocci
On 08/15/2017 03:42 PM, Julia Lawall wrote:
>
>
> On Tue, 15 Aug 2017, Gustavo A. R. Silva wrote:
>
>>
>>
>> On 08/15/2017 03:24 PM, Julia Lawall wrote:
>>>
>>>
>>> On Tue, 15 Aug 2017, Gustavo A. R. Silva wrote:
>>>
>>>> Hello everybody,
>>>>
>>>> I have the following script:
>>>>
>>>> @r@
>>>> identifier f_init;
>>>> position p;
>>>> @@
>>>>
>>>>
>>>> * __init f_init at p(...)
>>>>
>>>> I want to spot __init functions, but it doesn't seem to work. I get a
>>>> parse
>>>> error around the __init macro:
>>>>
>>>> around = '__init',
>>>> whole content = * __init f_init at p(...)
>>>>
>>>> I wonder if there is a way to work around that issue?
>>>
>>> If you want to match a function, you have to put something that will match
>>> the whole function, not just the top part. So it would be
>>>
>>> __init f(...) { ... }
>>>
>>
>> That worked, thanks. :)
>>
>> But now if I combine it in the following way:
>>
>> @r1@
>> identifier s_type;
>> identifier f_init;
>> identifier s;
>> position p;
>> type T;
>> @@
>>
>> (
>> * struct s_type s = {.init = f_init at p};
>> |
>> * __init f_init at p(...) { ... }
>> )
>>
>> I get the same error parse error:
>>
>> around = '__init',
>> whole content = __init f_init at p(...) { ... }
>
> Don't do it :)
>
> There are some parsing hacks to differentiate function calls from function
> definitions. Adding the disjunction defeats them. Just make two separate
> rules.
>
Oh OK, I got it. I'll do that.
Thank you, Julia. :)
--
Gustavo A. R. Silva
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2017-08-15 20:45 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-08-15 20:18 [Cocci] __init macro and Coccinelle Gustavo A. R. Silva
2017-08-15 20:24 ` Julia Lawall
2017-08-15 20:29 ` Gustavo A. R. Silva
2017-08-15 20:42 ` Julia Lawall
2017-08-15 20:45 ` Gustavo A. R. Silva
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.