cocci.inria.fr archive mirror
 help / color / mirror / Atom feed
From: "Christoph Böhmwalder" <christoph.boehmwalder@linbit.com>
To: cocci@systeme.lip6.fr
Subject: [Cocci] "depends on" per file
Date: Fri, 24 May 2019 15:18:33 +0200	[thread overview]
Message-ID: <CADC+RAzMNspm03FhGGQEDTsAMkQecjo_A930_SvsraKBpzu_bQ@mail.gmail.com> (raw)

Hi,

I'm trying to replace a function with a one-liner, where the one-liner
has a dependency on a header file that the function doesn't.
Now I want to include said header file iff it isn't already included
in the affected file.
In more concrete terms, this is my script:


@ find_linux_dcache_h @
@@
 #include <linux/dcache.h>

@ replace_simple_positive @
expression den;
@@
- simple_positive(den)
+ (den->d_inode && !d_unhashed(den))

@ add_linux_dcache_h depends on !find_linux_dcache_h && ever
replace_simple_positive @
@@
 #include <...>
+ #include <linux/dcache.h>


So far so good, (almost) works just fine. The issue is that if the
rule gets matched in one file, it will include the header in every
other file as well, because the "depends on ever" clause is satisfied.
Is there a way to tell coccinelle "apply this rule to file X, but only
if another rule matched in the same file"?

--
Regards,
Christoph
_______________________________________________
Cocci mailing list
Cocci@systeme.lip6.fr
https://systeme.lip6.fr/mailman/listinfo/cocci

             reply	other threads:[~2019-05-24 13:19 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-05-24 13:18 Christoph Böhmwalder [this message]
2019-05-24 13:20 ` [Cocci] "depends on" per file Julia Lawall
2019-05-24 15:17 ` Markus Elfring
2019-05-27 18:13 ` Markus Elfring

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=CADC+RAzMNspm03FhGGQEDTsAMkQecjo_A930_SvsraKBpzu_bQ@mail.gmail.com \
    --to=christoph.boehmwalder@linbit.com \
    --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 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).