From: Bernhard Reutner-Fischer <rep.dot.nop@gmail.com>
To: Julia Lawall <julia.lawall@inria.fr>
Cc: rep.dot.nop@gmail.com, cocci@inria.fr
Subject: Re: [cocci] HELP: multiple inserts at one position
Date: Fri, 10 Mar 2023 11:01:35 +0100 [thread overview]
Message-ID: <20230310110135.66cbd31b@nbbrfq> (raw)
In-Reply-To: <ad666bb2-3f4-47a2-13fd-8f7e29b8af79@inria.fr>
On Thu, 9 Mar 2023 09:47:17 +0100 (CET)
Julia Lawall <julia.lawall@inria.fr> wrote:
> On Thu, 9 Mar 2023, Julia Lawall wrote:
> > On Thu, 9 Mar 2023, Bernhard Reutner-Fischer wrote:
[]
> Another issue is that your semantic patch could be more efficient. You
> have the declaration
>
> type mpz_t;
>
> I think you meant:
>
> typedef mpz_t;
>
> Then the only goal of the pattern
>
> mpz_t i;
> ...
>
> seems to be to ensure the type of i. This can be done in the metavariable
> declaration:
>
> local idexpression mpz_t i
>
> and then in the second rule, it would be:
>
> local idexpression mpz_t mpz_0_find.i;
>
> In this way, you will not be matching from the top of the function, but
> rather only from the relevant call to the return.
mhm. But if there is no return statement whatsoever in that scope?
Consider:
int myround (double dbl)
{
int ret = 0;
// mpfr_t outer; mpfr_init (outer);
if (global_var)
{
unsigned long ul;
mpfr_t i;
mpfr_init (i);
mpfr_frac (i, dbl, MPFR_RNDZ);
if (mpfr_cmp_si (i, 0) != 0)
{
ret = 42;
moan ("round");
}
/* mpfr_clear (i); missing here */
}
// mpfr_clear (outer) insertion works, there is a return stmt.
// probably breaks in a void function like in the scope above..
// There is no 'i' to clear _here_, of course!
return ret;
}
EOF
If i'd understand a local idexpression 'i' to have a scope, i would have
hoped to somehow get at the position of i at end of scope?
But i think i need to match either a return or end-of-block, so i can
insert the mpfr_clear properly in either case. Somehow.
Ideas?
many thanks,
next prev parent reply other threads:[~2023-03-10 10:09 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-03-09 8:28 [cocci] HELP: multiple inserts at one position Bernhard Reutner-Fischer
[not found] ` <89959f1e-b5ed-6b2c-2931-4fdd65428e89@inria.fr>
2023-03-09 8:47 ` Julia Lawall
2023-03-09 9:10 ` Bernhard Reutner-Fischer
2023-03-09 9:38 ` Julia Lawall
2023-03-09 10:15 ` Bernhard Reutner-Fischer
2023-03-09 10:23 ` Julia Lawall
2023-03-10 10:01 ` Bernhard Reutner-Fischer [this message]
2023-03-10 10:12 ` Julia Lawall
2023-03-13 19:38 ` Bernhard Reutner-Fischer
2023-03-13 21:09 ` Julia Lawall
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=20230310110135.66cbd31b@nbbrfq \
--to=rep.dot.nop@gmail.com \
--cc=cocci@inria.fr \
--cc=julia.lawall@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 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.