From: Jani Nikula <jani.nikula@linux.intel.com>
To: Julia Lawall <julia.lawall@inria.fr>
Cc: "Ville Syrjälä" <ville.syrjala@linux.intel.com>,
cocci@systeme.lip6.fr, intel-gfx@lists.freedesktop.org
Subject: Re: Weirdness in parsing cpp macros
Date: Thu, 21 Mar 2024 11:48:29 +0200 [thread overview]
Message-ID: <87h6gznceq.fsf@intel.com> (raw)
In-Reply-To: <5abd6b1c-773d-94e7-da0-59393c7caeea@inria.fr>
On Thu, 21 Mar 2024, Julia Lawall <julia.lawall@inria.fr> wrote:
> On Wed, 20 Mar 2024, Jani Nikula wrote:
>
>> On Wed, 20 Mar 2024, Julia Lawall <julia.lawall@inria.fr> wrote:
>> > On Wed, 20 Mar 2024, Jani Nikula wrote:
>> >> Okay, I have another one wrt macros. :)
>> >>
>> >> I'm trying to add a completely new variadic macro, but it fails at
>> >> "...". I've tried all sorts of things, but can't seem to be able to add
>> >> a literal "...".
>> >>
>> >> I've tested that my cocci patch works with x's:
>> >>
>> >> + #define fn(p, xxx) foo(__VA_ARGS__)
>> >>
>> >> but when I try to make it actually variadic like:
>> >>
>> >> + #define fn(p, ...) foo(__VA_ARGS__)
>> >>
>> >> it gives me error. Is there a way to escape? Even tried to use a fresh
>> >> identifier vararg = "..."; but cocci made them unique with numbering
>> >> "...0" and "...1" etc.
>> >
>> > Put 6 dots. It's silly, but ... is a Coccinelle thing, so we had to use
>> > something else.
>>
>> I've tried, but it doesn't seem to work in the + side:
>>
>> plus: parse error:
>> File "/tmp/tmp.clvvc812Qe", line 20, column 2, charpos = 254
>> around = '#define fn(',
>> whole content = + #define fn(p, ......) __fn(__to_intel_display(p), __VA_ARGS__)
>
> A patch is below. I haven't tested it. It's working its way through the
> CI at the moment, but I'll be offline for the rest of the day, so I don't
> think I will be able to make it public today. But let me know if it
> works.
Thanks for looking into it!
I'm afraid setting up an environment to try cocci patches is a bit too
involved for me right now.
BR,
Jani.
>
> In particular, I don't think it would work for matching or removals, but
> it should work for additions.
>
> julia
>
> ---
>
> commit 8a637290a87ca86ca75a216ef1a7ac07c6a1fd57
> Author: Julia Lawall <Julia.Lawall@inria.fr>
> Date: Thu Mar 21 09:16:07 2024 +0100
>
> allow ...... as a #define param in SmPL
>
> diff --git a/parsing_cocci/parser_cocci_menhir.mly b/parsing_cocci/parser_cocci_menhir.mly
> index afba9e8f..4f9be9a6 100644
> --- a/parsing_cocci/parser_cocci_menhir.mly
> +++ b/parsing_cocci/parser_cocci_menhir.mly
> @@ -1614,6 +1614,12 @@ defineop:
>
> dparam: mident { Ast0_cocci.wrap(Ast0_cocci.DParam $1) }
> | TMetaDParamList { Parse_aux.meta_dparam_list $1 }
> +| TVAEllipsis
> + { let id = ("...",$1) in
> + Ast0_cocci.wrap
> + (Ast0_cocci.DParam
> + (Ast0_cocci.wrap
> + (Ast0_cocci.Id(Parse_aux.id2mcode id)))) }
>
> define_param_list_option:
> empty_list_start(dparam,TEllipsis)
--
Jani Nikula, Intel
next prev parent reply other threads:[~2024-03-21 9:48 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-03-20 12:37 Weirdness in parsing cpp macros Ville Syrjälä
2024-03-20 13:24 ` Julia Lawall
2024-03-20 13:31 ` Ville Syrjälä
2024-03-20 13:42 ` Jani Nikula
2024-03-20 14:39 ` Julia Lawall
2024-03-20 15:52 ` Jani Nikula
2024-03-20 16:44 ` Julia Lawall
2024-03-21 8:21 ` Julia Lawall
2024-03-21 9:48 ` Jani Nikula [this message]
2024-03-21 9:31 ` ✗ Fi.CI.BUILD: failure for " Patchwork
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=87h6gznceq.fsf@intel.com \
--to=jani.nikula@linux.intel.com \
--cc=cocci@systeme.lip6.fr \
--cc=intel-gfx@lists.freedesktop.org \
--cc=julia.lawall@inria.fr \
--cc=ville.syrjala@linux.intel.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox