All of lore.kernel.org
 help / color / mirror / Atom feed
From: Markus Elfring <Markus.Elfring@web.de>
To: Jakob Koschel <jkl820.git@gmail.com>
Cc: cocci@inria.fr
Subject: Re: [cocci] match arbitrary argument position
Date: Wed, 17 Aug 2022 21:21:16 +0200	[thread overview]
Message-ID: <1686c000-31ec-106d-583b-96e8292f26d3@web.de> (raw)
In-Reply-To: <8080D5E0-2491-47A0-AEDD-3EB84661917F@gmail.com>

>>> looking at the following code snippet:
>>>
>>> test.c:
>> …
>>>      func3(argc, argv);
>>>
>>>      func3(argv);
>>
>> Would you like to handle function overloading here?
> I'm not exactly sure I understand what you mean here.


I suggest to take another look at the implementation detail that it was specified
to call a function with different number of expressions.


> Finally I would like to archive something like this:


You would probably like to achieve special source code transformations
instead of archiving items.



> In the end I want to, for example, turn it into:
>
> void func(void) {
>
>     int x = 0;
>     // 'x' was used as first argument to interesting_func
>     int y = 0;
>     // 'y' was used as first argument to interesting_func
>
>     func1(x, 0);
>     func2(0, y);
> }
>
> void func1(int arg1, int arg2) {
>     interesting_func(arg1);
> }
>
> void func2(int arg1, int arg2) {
>     interesting_func(arg2);
> }


Will any filters (or related SmPL constraints) be relevant for such function names?


> Basically I want to flag create the matching from 'x'/'y' to the argument to interesting_func.


How do you think about further possibilities to choose which function argument
should be passed as an expression for corresponding computations?


> I was imagining if I could match the parameter list of any function calling 'interesting_func'
> then I can also create a matching from x to that function call and do the rest of the correlation
> in python somehow.


I propose to reconsider also the need for extra scripting according to
the discussed use case.



> However I'm still failing to detect if any argument (arg1 or arg2 in this case) is used as
> any argument in 'interesting_func'.


Multiple SmPL rules can be applied on demand for desirable data processing results.


> I hope this makes more sense?


It can be challenging to express special imaginations by the means of
the semantic patch language.



> hopefully the example above makes it a bit more clear.


It seems so.

Regards,
Markus


  reply	other threads:[~2022-08-17 19:21 UTC|newest]

Thread overview: 26+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-08-16  8:54 [cocci] match arbitrary argument position Jakob Koschel
2022-08-16 11:37 ` Julia Lawall
2022-08-16 12:35   ` Jakob Koschel
2022-08-16 17:55     ` Markus Elfring
2022-08-17 14:26       ` Jakob Koschel
2022-08-17 19:21         ` Markus Elfring [this message]
2022-08-16 21:07     ` Julia Lawall
2022-08-17 14:18       ` Jakob Koschel
2022-08-17 14:36         ` Julia Lawall
2022-08-17 14:50           ` Jakob Koschel
2022-08-17 15:26             ` Julia Lawall
2022-08-17 19:48           ` [cocci] Working with parameter/expression lists by SmPL Markus Elfring
2022-08-18 12:51             ` Jakob Koschel
2022-08-18 17:42               ` Markus Elfring
2022-08-19  9:12                 ` Jakob Koschel
2022-08-19  9:57                   ` Julia Lawall
2022-08-19 10:00                     ` Jakob Koschel
2022-08-19 17:00                   ` Markus Elfring
2022-08-20 12:57                     ` Jakob Koschel
2022-08-21  8:10                       ` Markus Elfring
2022-08-21  9:09                         ` Julia Lawall
2022-08-21  9:46                           ` Markus Elfring
2022-08-21 10:01                             ` Julia Lawall
2022-08-21 11:33                               ` Markus Elfring
2022-08-18 18:00               ` [cocci] Checking a comment addition Markus Elfring
  -- strict thread matches above, loose matches on Subject: below --
2022-08-16  8:58 [cocci] match arbitrary argument position Jakob Koschel

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=1686c000-31ec-106d-583b-96e8292f26d3@web.de \
    --to=markus.elfring@web.de \
    --cc=cocci@inria.fr \
    --cc=jkl820.git@gmail.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 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.