cocci.inria.fr archive mirror
 help / color / mirror / Atom feed
* Re: [Cocci] How to match function calls in macros?
@ 2020-05-18  8:26 Markus Elfring
  2020-05-18  9:19 ` Julia Lawall
  0 siblings, 1 reply; 21+ messages in thread
From: Markus Elfring @ 2020-05-18  8:26 UTC (permalink / raw)
  To: Julia Lawall; +Cc: Chuhong Yuan, cocci

> @@
> identifier mac,f;
> @@
>
> *#define mac(...) <+... f(...) ...+>

Does such an analysis approach restrict the source code search really on
complete definitions for function-like macros?


Will it become interesting for clarify corresponding special cases?

* How are empty macros treated by the Coccinelle software?

* Is there a connection managed between a macro declaration
  and subsequent source code?

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

^ permalink raw reply	[flat|nested] 21+ messages in thread
* Re: [Cocci] How to match function calls in macros?
@ 2020-05-16 11:42 Markus Elfring
  0 siblings, 0 replies; 21+ messages in thread
From: Markus Elfring @ 2020-05-16 11:42 UTC (permalink / raw)
  To: Julia Lawall; +Cc: Chuhong Yuan, cocci

> Normally, Coccinelle will match code inside of macro definitions,
> but only if it is able to parse the macro definition,

This is good to know.


> and the ability to parse macro definitions is somewhat limited.

How are the chances to reduce any software limitations in this area?

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

^ permalink raw reply	[flat|nested] 21+ messages in thread
* [Cocci] How to match function calls in macros?
@ 2020-05-16  8:16 Chuhong Yuan
  2020-05-16  8:49 ` Julia Lawall
  0 siblings, 1 reply; 21+ messages in thread
From: Chuhong Yuan @ 2020-05-16  8:16 UTC (permalink / raw)
  To: cocci

Hi all,
I want to write a script to match function calls in macros
but I don't know how to do that.
Here is an example:

#define __INIT_WORK(_work, _func, _onstack)     \
    do {     \
        static struct lock_class_key __key; \
        \
        __init_work((_work), _onstack); \
        (_work)->data = (atomic_long_t) WORK_DATA_INIT(); \
        lockdep_init_map(&(_work)->lockdep_map,
"(work_completion)"#_work, &__key, 0); \
        INIT_LIST_HEAD(&(_work)->entry); \
        (_work)->func = (_func); \
    } while (0)

In this example, I want to match function calls
like __init_work() and lockdep_init_map() in this macro.
So how to implement this by Coccinelle?

Thanks,
Chuhong
_______________________________________________
Cocci mailing list
Cocci@systeme.lip6.fr
https://systeme.lip6.fr/mailman/listinfo/cocci

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

end of thread, other threads:[~2020-05-19 12:04 UTC | newest]

Thread overview: 21+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-05-18  8:26 [Cocci] How to match function calls in macros? Markus Elfring
2020-05-18  9:19 ` Julia Lawall
2020-05-18 10:13   ` Markus Elfring
2020-05-18 10:18     ` Julia Lawall
2020-05-18 10:30       ` Markus Elfring
2020-05-18 10:34         ` Julia Lawall
2020-05-18 10:46           ` Markus Elfring
2020-05-18 10:50             ` Julia Lawall
2020-05-18 11:07               ` Markus Elfring
2020-05-19 11:15               ` Markus Elfring
2020-05-19 11:23                 ` Julia Lawall
2020-05-19 11:43                   ` Markus Elfring
2020-05-19 11:55                     ` Julia Lawall
2020-05-19 12:04                       ` Markus Elfring
2020-05-18 12:07       ` Markus Elfring
  -- strict thread matches above, loose matches on Subject: below --
2020-05-16 11:42 Markus Elfring
2020-05-16  8:16 Chuhong Yuan
2020-05-16  8:49 ` Julia Lawall
2020-05-16 12:26   ` Chuhong Yuan
2020-05-16 12:45     ` Julia Lawall
2020-05-16 14:17       ` Chuhong Yuan

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