All of lore.kernel.org
 help / color / mirror / Atom feed
* [Cocci] Moving a function body to an other source code place with SmPL
@ 2018-05-14 13:10 SF Markus Elfring
  2018-05-14 14:35 ` Julia Lawall
  0 siblings, 1 reply; 8+ messages in thread
From: SF Markus Elfring @ 2018-05-14 13:10 UTC (permalink / raw)
  To: cocci

Hello,

I am curious on how good the Coccinelle software can support a specific
source code transformation:
It would be occasionally nice if an implementation of a function could be
completely stored into a metavariable.
Is a statement list variable appropriate for this use case?

Can these data be moved to an other function (or macro definition)?

Regards,
Markus

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

* [Cocci] Moving a function body to an other source code place with SmPL
  2018-05-14 13:10 [Cocci] Moving a function body to an other source code place with SmPL SF Markus Elfring
@ 2018-05-14 14:35 ` Julia Lawall
  2018-05-14 15:12   ` SF Markus Elfring
  0 siblings, 1 reply; 8+ messages in thread
From: Julia Lawall @ 2018-05-14 14:35 UTC (permalink / raw)
  To: cocci



On Mon, 14 May 2018, SF Markus Elfring wrote:

> Hello,
>
> I am curious on how good the Coccinelle software can support a specific
> source code transformation:
> It would be occasionally nice if an implementation of a function could be
> completely stored into a metavariable.
> Is a statement list variable appropriate for this use case?

Yes.

@@
identifier f;
statement list SS;
@@

f() {
  SS
}

A statement list metavariable should only be used as the body of a block
{}.  If it is not working at the top of a function, it should be possible
to fix that.

> Can these data be moved to an other function (or macro definition)?

Yes.  A statement list variable can be added anywhere a list of statements
is allowed, ie not necessarily as the complete body of a block.

julia

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

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

* [Cocci] Moving a function body to an other source code place with SmPL
  2018-05-14 14:35 ` Julia Lawall
@ 2018-05-14 15:12   ` SF Markus Elfring
  2018-05-14 15:15     ` Julia Lawall
  0 siblings, 1 reply; 8+ messages in thread
From: SF Markus Elfring @ 2018-05-14 15:12 UTC (permalink / raw)
  To: cocci

>> It would be occasionally nice if an implementation of a function could be
>> completely stored into a metavariable.
>> Is a statement list variable appropriate for this use case?
> 
> Yes.

Thanks for your acknowledgement that it should usually work.


I have noticed a moment ago that a blank line is not marked by the SmPL
asterisk operator (for a small source code example) so far.

Can such whitespace characters be also preserved there anyhow?


>> Can these data be moved to an other function (or macro definition)?
> 
> Yes.  A statement list variable can be added anywhere a list of statements
> is allowed, ie not necessarily as the complete body of a block.

How will the software behaviour evolve if I stumble on the message
?Fatal error: exception Coccinelle_modules.Common.Timeout? after passing
the parameter ?--timeout 123? for a change attempt with a C++ source file?
(Am I too impatient here?)

Regards,
Markus

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

* [Cocci] Moving a function body to an other source code place with SmPL
  2018-05-14 15:12   ` SF Markus Elfring
@ 2018-05-14 15:15     ` Julia Lawall
  2018-05-14 15:26       ` SF Markus Elfring
                         ` (2 more replies)
  0 siblings, 3 replies; 8+ messages in thread
From: Julia Lawall @ 2018-05-14 15:15 UTC (permalink / raw)
  To: cocci



On Mon, 14 May 2018, SF Markus Elfring wrote:

> >> It would be occasionally nice if an implementation of a function could be
> >> completely stored into a metavariable.
> >> Is a statement list variable appropriate for this use case?
> >
> > Yes.
>
> Thanks for your acknowledgement that it should usually work.
>
>
> I have noticed a moment ago that a blank line is not marked by the SmPL
> asterisk operator (for a small source code example) so far.
>
> Can such whitespace characters be also preserved there anyhow?

No.  Whitespace is never preserved in metavariables.

>
>
> >> Can these data be moved to an other function (or macro definition)?
> >
> > Yes.  A statement list variable can be added anywhere a list of statements
> > is allowed, ie not necessarily as the complete body of a block.
>
> How will the software behaviour evolve if I stumble on the message
> ?Fatal error: exception Coccinelle_modules.Common.Timeout? after passing
> the parameter ?--timeout 123? for a change attempt with a C++ source file?
> (Am I too impatient here?)

No evolution is planned.  I see no reason why matching the body of a
function should intrinsically cause a timeout.

julia

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

* [Cocci] Moving a function body to an other source code place with SmPL
  2018-05-14 15:15     ` Julia Lawall
@ 2018-05-14 15:26       ` SF Markus Elfring
  2018-05-14 15:33         ` Julia Lawall
       [not found]       ` <9507e4af-3a80-f691-e75a-e4ddec1548c8@users.sourceforge.net>
       [not found]       ` <ca7b8507-86e7-dab4-2394-07df379034e7@users.sourceforge.net>
  2 siblings, 1 reply; 8+ messages in thread
From: SF Markus Elfring @ 2018-05-14 15:26 UTC (permalink / raw)
  To: cocci

>> I have noticed a moment ago that a blank line is not marked by the SmPL
>> asterisk operator (for a small source code example) so far.
>>
>> Can such whitespace characters be also preserved there anyhow?
> 
> No.  Whitespace is never preserved in metavariables.

I guess that this aspect will trigger further software development consequences.

How should a function body be converted into a part of a macro then?


>> How will the software behaviour evolve if I stumble on the message
>> ?Fatal error: exception Coccinelle_modules.Common.Timeout? after passing
>> the parameter ?--timeout 123? for a change attempt with a C++ source file?
>> (Am I too impatient here?)
> 
> No evolution is planned.  I see no reason why matching the body of a
> function should intrinsically cause a timeout.

I am also unsure if the Coccinelle software can cope in an other time frame
with another example file I am experimenting a bit.

Regards,
Markus

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

* [Cocci] Moving a function body to an other source code place with SmPL
  2018-05-14 15:26       ` SF Markus Elfring
@ 2018-05-14 15:33         ` Julia Lawall
  0 siblings, 0 replies; 8+ messages in thread
From: Julia Lawall @ 2018-05-14 15:33 UTC (permalink / raw)
  To: cocci



On Mon, 14 May 2018, SF Markus Elfring wrote:

> >> I have noticed a moment ago that a blank line is not marked by the SmPL
> >> asterisk operator (for a small source code example) so far.
> >>
> >> Can such whitespace characters be also preserved there anyhow?
> >
> > No.  Whitespace is never preserved in metavariables.
>
> I guess that this aspect will trigger further software development consequences.
>
> How should a function body be converted into a part of a macro then?

If you want to do this, you might need to add \ at the ends of lines.  You
can do that in python or ocaml, treating the result as an identifier.

julia

>
>
> >> How will the software behaviour evolve if I stumble on the message
> >> ?Fatal error: exception Coccinelle_modules.Common.Timeout? after passing
> >> the parameter ?--timeout 123? for a change attempt with a C++ source file?
> >> (Am I too impatient here?)
> >
> > No evolution is planned.  I see no reason why matching the body of a
> > function should intrinsically cause a timeout.
>
> I am also unsure if the Coccinelle software can cope in an other time frame
> with another example file I am experimenting a bit.
>
> Regards,
> Markus
>

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

* [Cocci] Checking the support for source code transformations with special characters
       [not found]       ` <9507e4af-3a80-f691-e75a-e4ddec1548c8@users.sourceforge.net>
@ 2018-05-14 19:41         ` Julia Lawall
  0 siblings, 0 replies; 8+ messages in thread
From: Julia Lawall @ 2018-05-14 19:41 UTC (permalink / raw)
  To: cocci



On Mon, 14 May 2018, SF Markus Elfring wrote:

> >> I have noticed a moment ago that a blank line is not marked by the SmPL
> >> asterisk operator (for a small source code example) so far.
> >>
> >> Can such whitespace characters be also preserved there anyhow?
> >
> > No.  Whitespace is never preserved in metavariables.
>
> How does such information fit to the following wording in the documentation?
> https://github.com/coccinelle/coccinelle/blob/848f85e256516330c06f5fd8dc782b854ed9aa03/docs/manual/introduction.tex#L4
>
> ?? automate repetitive source-to-source style-preserving program transformations ??

When Coccinelle adds code, it makes an effort to conform to the
indentation of the context in which the code is placed, not the context
from which the code was removed.  The goal is to preserve the stule of the
code as a whole.

julia

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

* [Cocci] Checking data processing for statement lists
       [not found]       ` <ca7b8507-86e7-dab4-2394-07df379034e7@users.sourceforge.net>
@ 2018-05-15  7:13         ` Julia Lawall
  0 siblings, 0 replies; 8+ messages in thread
From: Julia Lawall @ 2018-05-15  7:13 UTC (permalink / raw)
  To: cocci



On Tue, 15 May 2018, SF Markus Elfring wrote:

> >> How will the software behaviour evolve if I stumble on the message
> >> ?Fatal error: exception Coccinelle_modules.Common.Timeout? after passing
> >> the parameter ?--timeout 123? for a change attempt with a C++ source file?
> >> (Am I too impatient here?)
> >
> > No evolution is planned.
>
> I suggest to reconsider such a view.
>
> It is possible to perform some data processing with the help of the semantic
> patch language also on C++ source files in an acceptable time frame.
>
> Example:
> https://trac.cppcheck.net/ticket/8571
>
>
> > I see no reason why matching the body of a function should intrinsically
> > cause a timeout.
>
> I accidentally observed that the software situation can be changed
> in a dramatic way if a metavariable of the type ?statement list? is involved.
> Can the run time characteristics be considerably improved?

I don't have either semantic patch or the test data.  Perhaps you sent
them but without mentioning it in the message, so I didn't see it.

There is nothing about the processing of C++ that should be particularly
time consuming.

julia

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

end of thread, other threads:[~2018-05-15  7:13 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-05-14 13:10 [Cocci] Moving a function body to an other source code place with SmPL SF Markus Elfring
2018-05-14 14:35 ` Julia Lawall
2018-05-14 15:12   ` SF Markus Elfring
2018-05-14 15:15     ` Julia Lawall
2018-05-14 15:26       ` SF Markus Elfring
2018-05-14 15:33         ` Julia Lawall
     [not found]       ` <9507e4af-3a80-f691-e75a-e4ddec1548c8@users.sourceforge.net>
2018-05-14 19:41         ` [Cocci] Checking the support for source code transformations with special characters Julia Lawall
     [not found]       ` <ca7b8507-86e7-dab4-2394-07df379034e7@users.sourceforge.net>
2018-05-15  7:13         ` [Cocci] Checking data processing for statement lists Julia Lawall

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.