cocci.inria.fr archive mirror
 help / color / mirror / Atom feed
* [Cocci] Replacing a std::string check by strcmp() with SmPL
@ 2020-02-03 20:45 Markus Elfring
  2020-02-03 20:52 ` Julia Lawall
  2020-02-03 21:00 ` [Cocci] Replacing a std::string check by strcmp() with SmPL wellington wallace
  0 siblings, 2 replies; 24+ messages in thread
From: Markus Elfring @ 2020-02-03 20:45 UTC (permalink / raw)
  To: Coccinelle; +Cc: Wellington Wallace

Hello,

I have tried the following small script variant out for
the semantic patch language.

@replacement@
constant c;
identifier text;
expression x;
statement is, es;
@@
char* text = x(...);

if (
+   strcmp(
    text
+   ,
-   == std::string(
    c
    )
   )
   is
else
   es


A corresponding transformation result from the software
“Coccinelle 1.0.8-00029-ga549b9f0” looks promising (in principle).

elfring@Sonne:~/Projekte/Coccinelle/Probe> spatch --c++ replace_std_string_check_by_strcmp2.cocci PulseEffects-source_output_effects-excerpt2.cpp
…
@@ -1,7 +1,7 @@
 void on_message_element(const GstBus* gst_bus, GstMessage* message, SourceOutputEffects* soe) {
   char* src_name = GST_OBJECT_NAME(message->src);

-  if (src_name == std::string("equalizer_input_level")) {
+  if (strcmp(src_name, "equalizer_input_level")) {
     soe->equalizer_input_level.emit(soe->get_peak(message));
 // Deleted part
   } else if (src_name == std::string("webrtc_output_level")) {


1. But I wonder about an additional space character at the beginning
   of the shown function in the generated patch.

2. Will it become possible to achieve a similar change
   if the specification “auto” would be used instead of
   the data type “char*”?
   https://github.com/wwmm/pulseeffects/blob/acb5161a6ab8d3b0c395ed2809d3318ccf4931bc/src/source_output_effects.cpp#L6

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

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

* Re: [Cocci] Replacing a std::string check by strcmp() with SmPL
  2020-02-03 20:45 [Cocci] Replacing a std::string check by strcmp() with SmPL Markus Elfring
@ 2020-02-03 20:52 ` Julia Lawall
  2020-02-03 21:13   ` Markus Elfring
  2020-02-04 12:24   ` [Cocci] Searching for usage of “auto” with SmPL? Markus Elfring
  2020-02-03 21:00 ` [Cocci] Replacing a std::string check by strcmp() with SmPL wellington wallace
  1 sibling, 2 replies; 24+ messages in thread
From: Julia Lawall @ 2020-02-03 20:52 UTC (permalink / raw)
  To: Markus Elfring; +Cc: Wellington Wallace, Coccinelle

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

On Mon, 3 Feb 2020, Markus Elfring wrote:

> Hello,
>
> I have tried the following small script variant out for
> the semantic patch language.
>
> @replacement@
> constant c;
> identifier text;
> expression x;
> statement is, es;
> @@
> char* text = x(...);
>
> if (
> +   strcmp(
>     text
> +   ,
> -   == std::string(
>     c
>     )
>    )
>    is
> else
>    es
>
>
> A corresponding transformation result from the software
> “Coccinelle 1.0.8-00029-ga549b9f0” looks promising (in principle).
>
> elfring@Sonne:~/Projekte/Coccinelle/Probe> spatch --c++ replace_std_string_check_by_strcmp2.cocci PulseEffects-source_output_effects-excerpt2.cpp
> …
> @@ -1,7 +1,7 @@
>  void on_message_element(const GstBus* gst_bus, GstMessage* message, SourceOutputEffects* soe) {
>    char* src_name = GST_OBJECT_NAME(message->src);
>
> -  if (src_name == std::string("equalizer_input_level")) {
> +  if (strcmp(src_name, "equalizer_input_level")) {
>      soe->equalizer_input_level.emit(soe->get_peak(message));
>  // Deleted part
>    } else if (src_name == std::string("webrtc_output_level")) {
>
>
> 1. But I wonder about an additional space character at the beginning
>    of the shown function in the generated patch.

Where is the space that yoyu are concerned about?

>
> 2. Will it become possible to achieve a similar change
>    if the specification “auto” would be used instead of
>    the data type “char*”?
>    https://github.com/wwmm/pulseeffects/blob/acb5161a6ab8d3b0c395ed2809d3318ccf4931bc/src/source_output_effects.cpp#L6

I guess it would be fine if you put

typedef auto;

among the metavariables?

julia

[-- Attachment #2: Type: text/plain, Size: 136 bytes --]

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

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

* Re: [Cocci] Replacing a std::string check by strcmp() with SmPL
  2020-02-03 20:45 [Cocci] Replacing a std::string check by strcmp() with SmPL Markus Elfring
  2020-02-03 20:52 ` Julia Lawall
@ 2020-02-03 21:00 ` wellington wallace
  2020-02-04 13:02   ` Markus Elfring
  1 sibling, 1 reply; 24+ messages in thread
From: wellington wallace @ 2020-02-03 21:00 UTC (permalink / raw)
  To: Markus Elfring; +Cc: Coccinelle


[-- Attachment #1.1: Type: text/plain, Size: 1997 bytes --]

Hi!

I did not have the time to look at this file. Lots of places comparing two
chars indeed.

The strcmp output has to be compared to zero strcmp(src_name,
"equalizer_input_level") == 0. This is the result returned when the
arguments are equal.

Best Regards,
              Wellington.

On Mon, Feb 3, 2020 at 5:45 PM Markus Elfring <Markus.Elfring@web.de> wrote:

> Hello,
>
> I have tried the following small script variant out for
> the semantic patch language.
>
> @replacement@
> constant c;
> identifier text;
> expression x;
> statement is, es;
> @@
> char* text = x(...);
>
> if (
> +   strcmp(
>     text
> +   ,
> -   == std::string(
>     c
>     )
>    )
>    is
> else
>    es
>
>
> A corresponding transformation result from the software
> “Coccinelle 1.0.8-00029-ga549b9f0” looks promising (in principle).
>
> elfring@Sonne:~/Projekte/Coccinelle/Probe> spatch --c++
> replace_std_string_check_by_strcmp2.cocci
> PulseEffects-source_output_effects-excerpt2.cpp
> …
> @@ -1,7 +1,7 @@
>  void on_message_element(const GstBus* gst_bus, GstMessage* message,
> SourceOutputEffects* soe) {
>    char* src_name = GST_OBJECT_NAME(message->src);
>
> -  if (src_name == std::string("equalizer_input_level")) {
> +  if (strcmp(src_name, "equalizer_input_level")) {
>      soe->equalizer_input_level.emit(soe->get_peak(message));
>  // Deleted part
>    } else if (src_name == std::string("webrtc_output_level")) {
>
>
> 1. But I wonder about an additional space character at the beginning
>    of the shown function in the generated patch.
>
> 2. Will it become possible to achieve a similar change
>    if the specification “auto” would be used instead of
>    the data type “char*”?
>
> https://github.com/wwmm/pulseeffects/blob/acb5161a6ab8d3b0c395ed2809d3318ccf4931bc/src/source_output_effects.cpp#L6
>
> Regards,
> Markus
>


-- 
Prof.° Wellington Wallace Miguel Melo

CEFET/RJ Uned Nova Iguaçu

[-- Attachment #1.2: Type: text/html, Size: 2826 bytes --]

[-- Attachment #2: Type: text/plain, Size: 136 bytes --]

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

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

* Re: [Cocci] Replacing a std::string check by strcmp() with SmPL
  2020-02-03 20:52 ` Julia Lawall
@ 2020-02-03 21:13   ` Markus Elfring
  2020-02-03 21:28     ` Julia Lawall
  2020-02-03 21:31     ` [Cocci] Replacing a std::string check by strcmp() with SmPL Julia Lawall
  2020-02-04 12:24   ` [Cocci] Searching for usage of “auto” with SmPL? Markus Elfring
  1 sibling, 2 replies; 24+ messages in thread
From: Markus Elfring @ 2020-02-03 21:13 UTC (permalink / raw)
  To: Julia Lawall; +Cc: Wellington Wallace, Coccinelle

> Where is the space that yoyu are concerned about?

…
@@ -1,7 +1,7 @@
 void on_message_element …
↑

How was this character added at the first column in this line
of my software test approach?


>>    https://github.com/wwmm/pulseeffects/blob/acb5161a6ab8d3b0c395ed2809d3318ccf4931bc/src/source_output_effects.cpp#L6
>
> I guess it would be fine if you put
>
> typedef auto;
>
> among the metavariables?

Do you distinguish between the storage class specifier
and other uses of such a key word?
https://en.cppreference.com/w/cpp/language/auto

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

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

* Re: [Cocci] Replacing a std::string check by strcmp() with SmPL
  2020-02-03 21:13   ` Markus Elfring
@ 2020-02-03 21:28     ` Julia Lawall
  2020-02-04  8:11       ` Markus Elfring
  2020-02-03 21:31     ` [Cocci] Replacing a std::string check by strcmp() with SmPL Julia Lawall
  1 sibling, 1 reply; 24+ messages in thread
From: Julia Lawall @ 2020-02-03 21:28 UTC (permalink / raw)
  To: Markus Elfring; +Cc: Wellington Wallace, Coccinelle

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



On Mon, 3 Feb 2020, Markus Elfring wrote:

> > Where is the space that yoyu are concerned about?
>
> …
> @@ -1,7 +1,7 @@
>  void on_message_element …
> ↑
>
> How was this character added at the first column in this line
> of my software test approach?
>
>
> >>    https://github.com/wwmm/pulseeffects/blob/acb5161a6ab8d3b0c395ed2809d3318ccf4931bc/src/source_output_effects.cpp#L6
> >
> > I guess it would be fine if you put
> >
> > typedef auto;
> >
> > among the metavariables?
>
> Do you distinguish between the storage class specifier
> and other uses of such a key word?
> https://en.cppreference.com/w/cpp/language/auto

Sorry.  I know nothing about C++.  Auto seems to be supported - I see it
in both the C parser and the SmPL parser.

julia

[-- Attachment #2: Type: text/plain, Size: 136 bytes --]

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

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

* Re: [Cocci] Replacing a std::string check by strcmp() with SmPL
  2020-02-03 21:13   ` Markus Elfring
  2020-02-03 21:28     ` Julia Lawall
@ 2020-02-03 21:31     ` Julia Lawall
  2020-02-04  8:19       ` Markus Elfring
  1 sibling, 1 reply; 24+ messages in thread
From: Julia Lawall @ 2020-02-03 21:31 UTC (permalink / raw)
  To: Markus Elfring; +Cc: Wellington Wallace, Coccinelle

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

On Mon, 3 Feb 2020, Markus Elfring wrote:

> > Where is the space that yoyu are concerned about?
>
> …
> @@ -1,7 +1,7 @@
>  void on_message_element …
> ↑
>
> How was this character added at the first column in this line
> of my software test approach?

I don't understand.  If you are showing a patch, then the first column is
empty, except for the - and + characters.

julia

>
>
> >>    https://github.com/wwmm/pulseeffects/blob/acb5161a6ab8d3b0c395ed2809d3318ccf4931bc/src/source_output_effects.cpp#L6
> >
> > I guess it would be fine if you put
> >
> > typedef auto;
> >
> > among the metavariables?
>
> Do you distinguish between the storage class specifier
> and other uses of such a key word?
> https://en.cppreference.com/w/cpp/language/auto
>
> Regards,
> Markus
>

[-- Attachment #2: Type: text/plain, Size: 136 bytes --]

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

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

* Re: [Cocci] Replacing a std::string check by strcmp() with SmPL
  2020-02-03 21:28     ` Julia Lawall
@ 2020-02-04  8:11       ` Markus Elfring
  2020-02-04  8:14         ` Julia Lawall
  0 siblings, 1 reply; 24+ messages in thread
From: Markus Elfring @ 2020-02-04  8:11 UTC (permalink / raw)
  To: Julia Lawall; +Cc: Wellington Wallace, Coccinelle

>> Do you distinguish between the storage class specifier
>> and other uses of such a key word?
>> https://en.cppreference.com/w/cpp/language/auto
>
> Sorry.  I know nothing about C++.

I guess that you know something also for this programming language
according to the program option “--c++”.
https://github.com/coccinelle/coccinelle/blob/0cece3639048dc7e81c4b2cc8f2a6f7a57fd546b/docs/spatch.1.in#L434
https://github.com/coccinelle/coccinelle/issues/1


> Auto seems to be supported

I am looking for further evolution around this software area.


> - I see it in both the C parser and the SmPL parser.

How would we like to handle corresponding development challenges?

@display@
expression X;
identifier I;
@@
*auto I = X(...);


elfring@Sonne:~/Projekte/Coccinelle/Probe> spatch --parse-cocci show_variable_definition_with_auto1.cocci
init_defs_builtins: /usr/local/bin/../lib/coccinelle/standard.h
minus: parse error:
  File "show_variable_definition_with_auto1.cocci", line 5, column 6, charpos = 47
  around = 'I',
  whole content = *auto I = X(...);


Can such a source code search approach make sense also according to
the rules of the C programming language?

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

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

* Re: [Cocci] Replacing a std::string check by strcmp() with SmPL
  2020-02-04  8:11       ` Markus Elfring
@ 2020-02-04  8:14         ` Julia Lawall
  2020-02-04  8:39           ` Markus Elfring
  2020-02-04 10:38           ` [Cocci] Replacing usages of “auto” with SmPL? Markus Elfring
  0 siblings, 2 replies; 24+ messages in thread
From: Julia Lawall @ 2020-02-04  8:14 UTC (permalink / raw)
  To: Markus Elfring; +Cc: Wellington Wallace, Coccinelle

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



On Tue, 4 Feb 2020, Markus Elfring wrote:

> >> Do you distinguish between the storage class specifier
> >> and other uses of such a key word?
> >> https://en.cppreference.com/w/cpp/language/auto
> >
> > Sorry.  I know nothing about C++.
>
> I guess that you know something also for this programming language
> according to the program option “--c++”.
> https://github.com/coccinelle/coccinelle/blob/0cece3639048dc7e81c4b2cc8f2a6f7a57fd546b/docs/spatch.1.in#L434
> https://github.com/coccinelle/coccinelle/issues/1
>
>
> > Auto seems to be supported
>
> I am looking for further evolution around this software area.
>
>
> > - I see it in both the C parser and the SmPL parser.
>
> How would we like to handle corresponding development challenges?
>
> @display@
> expression X;
> identifier I;
> @@
> *auto I = X(...);
>
>
> elfring@Sonne:~/Projekte/Coccinelle/Probe> spatch --parse-cocci show_variable_definition_with_auto1.cocci
> init_defs_builtins: /usr/local/bin/../lib/coccinelle/standard.h
> minus: parse error:
>   File "show_variable_definition_with_auto1.cocci", line 5, column 6, charpos = 47
>   around = 'I',
>   whole content = *auto I = X(...);
>
>
> Can such a source code search approach make sense also according to
> the rules of the C programming language?

I think it expects a type as well.  I don't know if that is a reasonable
assumption in C or in C++.

julia

[-- Attachment #2: Type: text/plain, Size: 136 bytes --]

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

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

* Re: [Cocci] Replacing a std::string check by strcmp() with SmPL
  2020-02-03 21:31     ` [Cocci] Replacing a std::string check by strcmp() with SmPL Julia Lawall
@ 2020-02-04  8:19       ` Markus Elfring
  0 siblings, 0 replies; 24+ messages in thread
From: Markus Elfring @ 2020-02-04  8:19 UTC (permalink / raw)
  To: Julia Lawall; +Cc: Wellington Wallace, Coccinelle

> If you are showing a patch, then the first column is empty,
> except for the - and + characters.

You are right.

I am sorry for my misinterpretation of the “indentation” at this place.

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

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

* Re: [Cocci] Replacing a std::string check by strcmp() with SmPL
  2020-02-04  8:14         ` Julia Lawall
@ 2020-02-04  8:39           ` Markus Elfring
  2020-02-04 10:38           ` [Cocci] Replacing usages of “auto” with SmPL? Markus Elfring
  1 sibling, 0 replies; 24+ messages in thread
From: Markus Elfring @ 2020-02-04  8:39 UTC (permalink / raw)
  To: Julia Lawall; +Cc: Wellington Wallace, Coccinelle

>> @display@
>> expression X;
>> identifier I;
>> @@
>> *auto I = X(...);
> I think it expects a type as well.  I don't know if that is a reasonable
> assumption in C or in C++.

How do you think about to interpret such a variable definition in the way
that the omission of an other data type specification would result into
the usage of “int”?

Under which circumstances will the handling of “placeholder type specifiers”
become relevant finally?
https://en.cppreference.com/w/cpp/language/auto

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

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

* Re: [Cocci] Replacing usages of “auto” with SmPL?
  2020-02-04  8:14         ` Julia Lawall
  2020-02-04  8:39           ` Markus Elfring
@ 2020-02-04 10:38           ` Markus Elfring
  2020-02-04 11:01             ` Julia Lawall
  1 sibling, 1 reply; 24+ messages in thread
From: Markus Elfring @ 2020-02-04 10:38 UTC (permalink / raw)
  To: Julia Lawall; +Cc: Wellington Wallace, Coccinelle

> I think it expects a type as well.  I don't know if that is a reasonable
> assumption in C or in C++.

Can a source code transformation approach like the following make sense?

@replacement@
@@
-auto
+my_type


elfring@Sonne:~/Projekte/Coccinelle/Probe> spatch --parse-cocci replace_auto1.cocci
init_defs_builtins: /usr/local/bin/../lib/coccinelle/standard.h
minus: parse error:
  File "replace_auto1.cocci", line 5, column 0, charpos = 32
  around = '',
  whole content =


Will the software support for adjustments around the explicit specification of
automatic storage duration become better anyhow?
https://en.cppreference.com/w/c/language/storage_duration

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

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

* Re: [Cocci] Replacing usages of “auto” with SmPL?
  2020-02-04 10:38           ` [Cocci] Replacing usages of “auto” with SmPL? Markus Elfring
@ 2020-02-04 11:01             ` Julia Lawall
  2020-02-04 11:45               ` Markus Elfring
  0 siblings, 1 reply; 24+ messages in thread
From: Julia Lawall @ 2020-02-04 11:01 UTC (permalink / raw)
  To: Markus Elfring; +Cc: Wellington Wallace, Coccinelle



On Tue, 4 Feb 2020, Markus Elfring wrote:

> > I think it expects a type as well.  I don't know if that is a reasonable
> > assumption in C or in C++.
>
> Can a source code transformation approach like the following make sense?
>
> @replacement@
> @@
> -auto
> +my_type

There is nothing to support this.  So far I don't have the impression that
anyone has had a need for it either.

julia


>
>
> elfring@Sonne:~/Projekte/Coccinelle/Probe> spatch --parse-cocci replace_auto1.cocci
> init_defs_builtins: /usr/local/bin/../lib/coccinelle/standard.h
> minus: parse error:
>   File "replace_auto1.cocci", line 5, column 0, charpos = 32
>   around = '',
>   whole content =
>
>
> Will the software support for adjustments around the explicit specification of
> automatic storage duration become better anyhow?
> https://en.cppreference.com/w/c/language/storage_duration
>
> Regards,
> Markus
>
_______________________________________________
Cocci mailing list
Cocci@systeme.lip6.fr
https://systeme.lip6.fr/mailman/listinfo/cocci

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

* Re: [Cocci] Replacing usages of “auto” with SmPL?
  2020-02-04 11:01             ` Julia Lawall
@ 2020-02-04 11:45               ` Markus Elfring
  2020-02-04 12:07                 ` Julia Lawall
  0 siblings, 1 reply; 24+ messages in thread
From: Markus Elfring @ 2020-02-04 11:45 UTC (permalink / raw)
  To: Julia Lawall; +Cc: Wellington Wallace, Coccinelle

>> @replacement@
>> @@
>> -auto
>> +my_type
>
> There is nothing to support this.

Thanks for such feedback.


> So far I don't have the impression that anyone has had a need for it either.

How often will I be the first one who shows a need for further software extensions?


Would anybody like to help any more for corresponding development challenges?

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

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

* Re: [Cocci] Replacing usages of “auto” with SmPL?
  2020-02-04 11:45               ` Markus Elfring
@ 2020-02-04 12:07                 ` Julia Lawall
  2020-02-04 12:18                   ` Markus Elfring
  0 siblings, 1 reply; 24+ messages in thread
From: Julia Lawall @ 2020-02-04 12:07 UTC (permalink / raw)
  To: Markus Elfring; +Cc: Wellington Wallace, Coccinelle



On Tue, 4 Feb 2020, Markus Elfring wrote:

> >> @replacement@
> >> @@
> >> -auto
> >> +my_type
> >
> > There is nothing to support this.
>
> Thanks for such feedback.
>
>
> > So far I don't have the impression that anyone has had a need for it either.
>
> How often will I be the first one who shows a need for further software extensions?

You're not actually showing a need.  Ie you don't have a real piece of
software in which this transformation is actually needed.

julia

>
>
> Would anybody like to help any more for corresponding development challenges?
>
> Regards,
> Markus
>
_______________________________________________
Cocci mailing list
Cocci@systeme.lip6.fr
https://systeme.lip6.fr/mailman/listinfo/cocci

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

* Re: [Cocci] Replacing usages of “auto” with SmPL?
  2020-02-04 12:07                 ` Julia Lawall
@ 2020-02-04 12:18                   ` Markus Elfring
  0 siblings, 0 replies; 24+ messages in thread
From: Markus Elfring @ 2020-02-04 12:18 UTC (permalink / raw)
  To: Julia Lawall; +Cc: Wellington Wallace, Coccinelle

> You're not actually showing a need.

I disagree. - Our needs are just different.


> Ie you don't have a real piece of software in which this transformation is actually needed.

Under which circumstances will the clarification of related components
become more attractive?

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

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

* Re: [Cocci] Searching for usage of “auto” with SmPL?
  2020-02-03 20:52 ` Julia Lawall
  2020-02-03 21:13   ` Markus Elfring
@ 2020-02-04 12:24   ` Markus Elfring
  2020-02-04 12:42     ` Julia Lawall
  1 sibling, 1 reply; 24+ messages in thread
From: Markus Elfring @ 2020-02-04 12:24 UTC (permalink / raw)
  To: Julia Lawall; +Cc: Wellington Wallace, Coccinelle

>>    https://github.com/wwmm/pulseeffects/blob/acb5161a6ab8d3b0c395ed2809d3318ccf4931bc/src/source_output_effects.cpp#L6
>
> I guess it would be fine if you put
>
> typedef auto;
>
> among the metavariables?

I would like to show another software test result.

@display@
expression E;
identifier I;
typedef auto;
@@
*auto I = E(...);


elfring@Sonne:~/Projekte/Coccinelle/Probe> spatch --parse-cocci show_variable_definition_with_auto3.cocci
init_defs_builtins: /usr/local/bin/../lib/coccinelle/standard.h
meta: parse error:
  File "show_variable_definition_with_auto3.cocci", line 4, column 8, charpos = 46
  around = 'auto',
  whole content = typedef auto;


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

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

* Re: [Cocci] Searching for usage of “auto” with SmPL?
  2020-02-04 12:24   ` [Cocci] Searching for usage of “auto” with SmPL? Markus Elfring
@ 2020-02-04 12:42     ` Julia Lawall
  2020-02-04 12:52       ` Markus Elfring
  0 siblings, 1 reply; 24+ messages in thread
From: Julia Lawall @ 2020-02-04 12:42 UTC (permalink / raw)
  To: Markus Elfring; +Cc: Wellington Wallace, Coccinelle



On Tue, 4 Feb 2020, Markus Elfring wrote:

> >>    https://github.com/wwmm/pulseeffects/blob/acb5161a6ab8d3b0c395ed2809d3318ccf4931bc/src/source_output_effects.cpp#L6
> >
> > I guess it would be fine if you put
> >
> > typedef auto;
> >
> > among the metavariables?
>
> I would like to show another software test result.
>
> @display@
> expression E;
> identifier I;
> typedef auto;
> @@
> *auto I = E(...);
>
>
> elfring@Sonne:~/Projekte/Coccinelle/Probe> spatch --parse-cocci show_variable_definition_with_auto3.cocci
> init_defs_builtins: /usr/local/bin/../lib/coccinelle/standard.h
> meta: parse error:
>   File "show_variable_definition_with_auto3.cocci", line 4, column 8, charpos = 46
>   around = 'auto',
>   whole content = typedef auto;

I understood already that it was not meant as a type.

julia
_______________________________________________
Cocci mailing list
Cocci@systeme.lip6.fr
https://systeme.lip6.fr/mailman/listinfo/cocci

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

* Re: [Cocci] Searching for usage of “auto” with SmPL?
  2020-02-04 12:42     ` Julia Lawall
@ 2020-02-04 12:52       ` Markus Elfring
  0 siblings, 0 replies; 24+ messages in thread
From: Markus Elfring @ 2020-02-04 12:52 UTC (permalink / raw)
  To: Julia Lawall; +Cc: Wellington Wallace, Coccinelle

>> meta: parse error:
>>   File "show_variable_definition_with_auto3.cocci", line 4, column 8, charpos = 46
>>   around = 'auto',
>>   whole content = typedef auto;
>
> I understood already that it was not meant as a type.

I tried your suggestion out if the idea can work finally.
May such a key word be occasionally redefined (by the means of the semantic patch language)?

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

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

* Re: [Cocci] Replacing a std::string check by strcmp() with SmPL
  2020-02-03 21:00 ` [Cocci] Replacing a std::string check by strcmp() with SmPL wellington wallace
@ 2020-02-04 13:02   ` Markus Elfring
  2020-02-04 13:19     ` Julia Lawall
  0 siblings, 1 reply; 24+ messages in thread
From: Markus Elfring @ 2020-02-04 13:02 UTC (permalink / raw)
  To: Wellington Wallace; +Cc: Coccinelle

> The strcmp output has to be compared to zero strcmp(src_name, "equalizer_input_level") == 0.

Would you like to let the following script for the semantic patch language
perform any changes in your source files automatically?

@replacement@
constant c;
identifier text;
statement is, es;
@@
 <+...
 if (
+    !std::strcmp(
     text
+    ,
-    == std::string(
     c
     )
    )
    is
 else
    es
 ...+>


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

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

* Re: [Cocci] Replacing a std::string check by strcmp() with SmPL
  2020-02-04 13:02   ` Markus Elfring
@ 2020-02-04 13:19     ` Julia Lawall
  2020-02-04 13:28       ` Markus Elfring
  0 siblings, 1 reply; 24+ messages in thread
From: Julia Lawall @ 2020-02-04 13:19 UTC (permalink / raw)
  To: Markus Elfring; +Cc: Wellington Wallace, Coccinelle



On Tue, 4 Feb 2020, Markus Elfring wrote:

> > The strcmp output has to be compared to zero strcmp(src_name, "equalizer_input_level") == 0.
>
> Would you like to let the following script for the semantic patch language
> perform any changes in your source files automatically?
>
> @replacement@
> constant c;
> identifier text;
> statement is, es;
> @@
>  <+...

What is thhe point of the outer <+... ...+>?

julia

>  if (
> +    !std::strcmp(
>      text
> +    ,
> -    == std::string(
>      c
>      )
>     )
>     is
>  else
>     es
>  ...+>
>
>
> Regards,
> Markus
> _______________________________________________
> Cocci mailing list
> Cocci@systeme.lip6.fr
> https://systeme.lip6.fr/mailman/listinfo/cocci
>
_______________________________________________
Cocci mailing list
Cocci@systeme.lip6.fr
https://systeme.lip6.fr/mailman/listinfo/cocci

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

* Re: [Cocci] Replacing a std::string check by strcmp() with SmPL
  2020-02-04 13:19     ` Julia Lawall
@ 2020-02-04 13:28       ` Markus Elfring
  2020-02-04 13:47         ` Julia Lawall
  0 siblings, 1 reply; 24+ messages in thread
From: Markus Elfring @ 2020-02-04 13:28 UTC (permalink / raw)
  To: Julia Lawall; +Cc: Wellington Wallace, Coccinelle

>> @replacement@
>> constant c;
>> identifier text;
>> statement is, es;
>> @@
>>  <+...
>
> What is thhe point of the outer <+... ...+>?

I would like to stress the possibility that source code adjustments
can be performed multiple times.
https://github.com/coccinelle/coccinelle/blob/a549b9f0a20e14fe9c36f45990b40dc5708ef8f2/docs/manual/cocci_syntax.tex#L696

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

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

* Re: [Cocci] Replacing a std::string check by strcmp() with SmPL
  2020-02-04 13:28       ` Markus Elfring
@ 2020-02-04 13:47         ` Julia Lawall
  2020-02-04 14:08           ` Markus Elfring
  0 siblings, 1 reply; 24+ messages in thread
From: Julia Lawall @ 2020-02-04 13:47 UTC (permalink / raw)
  To: Markus Elfring; +Cc: Wellington Wallace, Coccinelle



On Tue, 4 Feb 2020, Markus Elfring wrote:

> >> @replacement@
> >> constant c;
> >> identifier text;
> >> statement is, es;
> >> @@
> >>  <+...
> >
> > What is thhe point of the outer <+... ...+>?
>
> I would like to stress the possibility that source code adjustments
> can be performed multiple times.
> https://github.com/coccinelle/coccinelle/blob/a549b9f0a20e14fe9c36f45990b40dc5708ef8f2/docs/manual/cocci_syntax.tex#L696

Perhaps, but it will unnecessarily raise the running time of your semantic
patch.

julia
_______________________________________________
Cocci mailing list
Cocci@systeme.lip6.fr
https://systeme.lip6.fr/mailman/listinfo/cocci

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

* Re: [Cocci] Replacing a std::string check by strcmp() with SmPL
  2020-02-04 13:47         ` Julia Lawall
@ 2020-02-04 14:08           ` Markus Elfring
       [not found]             ` <alpine.DEB.2.21.2002041524400.3345@hadrien>
  0 siblings, 1 reply; 24+ messages in thread
From: Markus Elfring @ 2020-02-04 14:08 UTC (permalink / raw)
  To: Julia Lawall; +Cc: Wellington Wallace, Coccinelle

> Perhaps, but it will unnecessarily raise the running time of your semantic patch.

We come along different expectations again for the possible application
of the construct “<+... … ...+>” for the semantic patch language.
Should the concrete run time characteristics be clarified any more
for current update candidates in known source files?

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

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

* Re: [Cocci] Usage concerns around the SmPL construct “<+... … ...+>”
       [not found]             ` <alpine.DEB.2.21.2002041524400.3345@hadrien>
@ 2020-02-04 14:42               ` Markus Elfring
  0 siblings, 0 replies; 24+ messages in thread
From: Markus Elfring @ 2020-02-04 14:42 UTC (permalink / raw)
  To: Julia Lawall; +Cc: Coccinelle

> Coccinelle could provide an appropriate running time by just ignoring the
> <+... ...+>.  But that seems like a pointless optimization, when the user
> could just not put the <+... ...+> in the first place.

I would like to express a specific SmPL functionality.


> Coccinelle already applies a rule everywhere that it occurs,

This aspect is clear to some degree.


> regardless of whether the two occurrences are in the same function.

Our views can be different also for the discussed use case.

* How much will the requirement for changing selected items
  multiple times matter?

* Are we eventually looking for another clarification also
  in the software documentation?

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

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

end of thread, other threads:[~2020-02-04 14:43 UTC | newest]

Thread overview: 24+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-02-03 20:45 [Cocci] Replacing a std::string check by strcmp() with SmPL Markus Elfring
2020-02-03 20:52 ` Julia Lawall
2020-02-03 21:13   ` Markus Elfring
2020-02-03 21:28     ` Julia Lawall
2020-02-04  8:11       ` Markus Elfring
2020-02-04  8:14         ` Julia Lawall
2020-02-04  8:39           ` Markus Elfring
2020-02-04 10:38           ` [Cocci] Replacing usages of “auto” with SmPL? Markus Elfring
2020-02-04 11:01             ` Julia Lawall
2020-02-04 11:45               ` Markus Elfring
2020-02-04 12:07                 ` Julia Lawall
2020-02-04 12:18                   ` Markus Elfring
2020-02-03 21:31     ` [Cocci] Replacing a std::string check by strcmp() with SmPL Julia Lawall
2020-02-04  8:19       ` Markus Elfring
2020-02-04 12:24   ` [Cocci] Searching for usage of “auto” with SmPL? Markus Elfring
2020-02-04 12:42     ` Julia Lawall
2020-02-04 12:52       ` Markus Elfring
2020-02-03 21:00 ` [Cocci] Replacing a std::string check by strcmp() with SmPL wellington wallace
2020-02-04 13:02   ` Markus Elfring
2020-02-04 13:19     ` Julia Lawall
2020-02-04 13:28       ` Markus Elfring
2020-02-04 13:47         ` Julia Lawall
2020-02-04 14:08           ` Markus Elfring
     [not found]             ` <alpine.DEB.2.21.2002041524400.3345@hadrien>
2020-02-04 14:42               ` [Cocci] Usage concerns around the SmPL construct “<+... … ...+>” Markus Elfring

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