Coccinelle archive mirror
 help / color / mirror / Atom feed
From: Anon Anonson <anon@chud.cyou>
To: cocci@inria.fr
Subject: Re: [cocci] Possible bug
Date: Sun, 19 Oct 2025 21:34:16 +0200	[thread overview]
Message-ID: <0340ae74-dffc-408e-952a-85a30b6ba4d5@chud.cyou> (raw)
In-Reply-To: <a38c126f-8a35-343-f7d0-d2a0da17f521@inria.fr>

[-- Attachment #1: Type: text/plain, Size: 1464 bytes --]

On 9/15/25 11:37 PM, Julia Lawall wrote:

> I guess one could go either way on this.  Normally, a for loop header has
> the form
>
>   for ( ; ; )
>
> So the semicolons are part of thr for loop header, not part of the
> declaration.  So that's why your pattern doesn't match.  I think that
> currently the only solution is to make a special case for for loop
> headers.
>
> julia

I see. That works, thank you.
Any plans to change this? Seems like a bit of a footgun.


On 9/16/25 10:25 AM, Markus Elfring wrote:
> Can such a source code transformation approach ever work without the specification
> of the semicolon?
>
> @Renaming@
> @@
>   int
> -old
> +new
>
>
> Regards,
> Markus
Seems logical and useful.
Not sure whether it has problematic implications.

Similarly, is there a specific reason that:
@@
@@
- i
+ h

only matches uses, but not declarations of `i`?


On 9/16/25 10:00 AM, Markus Elfring wrote:
> Would you like to support any restrictions where anything should not be renamed accidentally?

If possible.
I was considering a solution where shadowing ambiguities would be 
resolved by providing a line number to my tool.
Then, an intermediate file with an inserted "marker pseudo-macro" would 
be used during matching.
E.g.:
@ rn_target @
type T;
identifier I = i;
@@
- T I; RENAME_TARGET;
+ T I;

@ rn_id depends on rn_target @
identifier I = rn_target.I;
@@
- I
+ h
However, it appears that `I` refers to the name and not the lexical 
variable.

[-- Attachment #2: Type: text/html, Size: 2774 bytes --]

  reply	other threads:[~2025-10-19 19:34 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-09-14 11:47 [cocci] Possible bug Anon Anonson
2025-09-15 21:37 ` Julia Lawall
2025-10-19 19:34   ` Anon Anonson [this message]
2025-09-16  8:00 ` [cocci] Renaming identifiers with SmPL Markus Elfring
2025-09-16  8:25 ` [cocci] Renaming identifiers with SmPL? 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=0340ae74-dffc-408e-952a-85a30b6ba4d5@chud.cyou \
    --to=anon@chud.cyou \
    --cc=cocci@inria.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 read-only IMAP folder(s) and NNTP newsgroup(s).