cocci.inria.fr archive mirror
 help / color / mirror / Atom feed
* [Cocci] "depends on" per file
@ 2019-05-24 13:18 Christoph Böhmwalder
  2019-05-24 13:20 ` Julia Lawall
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Christoph Böhmwalder @ 2019-05-24 13:18 UTC (permalink / raw)
  To: cocci

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

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2019-05-27 18:14 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-05-24 13:18 [Cocci] "depends on" per file Christoph Böhmwalder
2019-05-24 13:20 ` Julia Lawall
2019-05-24 15:17 ` Markus Elfring
2019-05-27 18:13 ` Markus Elfring

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).