All of lore.kernel.org
 help / color / mirror / Atom feed
From: julia.lawall@lip6.fr (Julia Lawall)
To: cocci@systeme.lip6.fr
Subject: [Cocci] Support for macro expansion
Date: Sat, 13 Jan 2018 07:46:09 +0100 (CET)	[thread overview]
Message-ID: <alpine.DEB.2.20.1801130744400.2203@hadrien> (raw)
In-Reply-To: <CALt5rJvkW=LLVxiVNocak_+q339SOpJy2WMmynswY2gOmxDNig@mail.gmail.com>



On Fri, 12 Jan 2018, Martijn Coenen wrote:

> On Fri, Jan 12, 2018 at 7:50 PM, Julia Lawall <julia.lawall@lip6.fr> wrote:
> >
> > Is it possible to parse the macro? That is, is the body a legal C
> > statement or expression?
>
> The macro I was looking at is module_usb_serial_driver():
>
> https://elixir.free-electrons.com/linux/v4.15-rc7/source/include/linux/usb/serial.h#L433
>
> The macro itself expands to another macro (maybe that is the
> problem?), which expands to a few C function definitions. In this case
> I was interested in seeing whether a file used the
> "usb_serial_register_drivers()" function, which is called in one of
> those function definitions.

The easiest thing would be to just extend your semantic patch to look for
uses of module_usb_serial_driver.  module_usb_serial_driver however is
called outside of any function.  So you need to make a declaration among
the metavariables:

declarer name module_usb_serial_driver;

It doesn't make it ia metavariable, but rather gives some information
about the name so that it will look for this name at top level.

julia


>
> Thanks,
> Martijn
>
> >
> >
> > Normally, macros are only unfolded when doing so is necessary to parse the
> > context in which the macro occurs.  But when a macro is unfolded for that
> > reason, it is not possible to transform the unfolded code, although it is
> > possible to match it.
> >
> > It is indeed possible that the --preprocess argument does not do anything.
> >
> > julia
>

  reply	other threads:[~2018-01-13  6:46 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-01-12 16:19 [Cocci] Support for macro expansion Martijn Coenen
2018-01-12 18:50 ` Julia Lawall
2018-01-12 19:10   ` Martijn Coenen
2018-01-13  6:46     ` Julia Lawall [this message]
2018-01-15  7:54       ` Martijn Coenen
2018-01-15  9:14         ` Julia Lawall
2018-01-16  8:33           ` Martijn Coenen

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=alpine.DEB.2.20.1801130744400.2203@hadrien \
    --to=julia.lawall@lip6.fr \
    --cc=cocci@systeme.lip6.fr \
    /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 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.