cocci.inria.fr archive mirror
 help / color / mirror / Atom feed
* [Cocci] More precise distinction of types for source code searches?
@ 2019-06-24 12:51 Markus Elfring
  2019-06-25 12:40 ` Markus Elfring
  0 siblings, 1 reply; 5+ messages in thread
From: Markus Elfring @ 2019-06-24 12:51 UTC (permalink / raw)
  To: Coccinelle

Hello,

The semantic patch language supports metavariables.
It can occur then that a source code search should be performed for items
which should be different while they belong still to the same data type.
(If these items would be identical, the software situation would provide
opportunities to simplify corresponding source code.)

The expected difference can trigger the need to express this detail
by the usage of two identifiers based on the same metavariable type.


SmPL script example:
@display@
constant c1, c2;
identifier x;
@@
 x =
*    c1
 ;
 x =
*    c2
 ;


Source file example:
int main(void)
{
int x;
x = 1;
x = 0;
return x;
}


The used constants are integers and additional properties can be expressed
for such numbers. These properties can eventually handled with scripted
SmPL constraints.
But I have got the impression that other metavariable types provide even more
software development challenges for safe distinction of relevant items.

I would like to point the detail out once more that also these metavariables
can be of the same kind then with the consequence that it is not guaranteed
that such metavariables will only match different source code.
The support for the introduction of additional subtypes on demand might be
too limited by the evolving software.

How do you think about this use case?

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

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

* Re: [Cocci] More precise distinction of types for source code searches?
  2019-06-24 12:51 [Cocci] More precise distinction of types for source code searches? Markus Elfring
@ 2019-06-25 12:40 ` Markus Elfring
  2019-06-25 14:38   ` Julia Lawall
  0 siblings, 1 reply; 5+ messages in thread
From: Markus Elfring @ 2019-06-25 12:40 UTC (permalink / raw)
  To: Coccinelle

> The expected difference can trigger the need to express this detail
> by the usage of two identifiers based on the same metavariable type.

I guess that this wording should be clarified a bit more according to
the current software development status around the semantic patch language.
A selection of different metavariable types is supported already.
https://github.com/coccinelle/coccinelle/blob/c6d7554edf7c4654aeae4d33c3f040e300682f23/docs/manual/cocci_syntax.tex#L199

So it seems to be occasionally appropriate to use metavariables with
the same type while different names are chosen then for the corresponding
variable declaration.


Another SmPL script example:
@test@
constant c1, c2;
@@
 x =
*    c1
 ;
 x =
*    c2
 ;


Such a source code search specification is too generic so far
when you would really like to determine if these assignments (or its elements)
are equivalent or even identical (or not).

I am looking again for possibilities to improve language distinctions here.

* How can a single metavariable remember a mapping to a previous instance
  from its type?

* How will it become possible to match only a subset of a known base type?

* How often do you want to exclude something because of a previous match with
  a similar type?


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

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

* Re: [Cocci] More precise distinction of types for source code searches?
  2019-06-25 12:40 ` Markus Elfring
@ 2019-06-25 14:38   ` Julia Lawall
  2019-06-25 17:09     ` Markus Elfring
  2019-06-26  8:36     ` Markus Elfring
  0 siblings, 2 replies; 5+ messages in thread
From: Julia Lawall @ 2019-06-25 14:38 UTC (permalink / raw)
  To: Markus Elfring; +Cc: Coccinelle



On Tue, 25 Jun 2019, Markus Elfring wrote:

> > The expected difference can trigger the need to express this detail
> > by the usage of two identifiers based on the same metavariable type.
>
> I guess that this wording should be clarified a bit more according to
> the current software development status around the semantic patch language.
> A selection of different metavariable types is supported already.
> https://github.com/coccinelle/coccinelle/blob/c6d7554edf7c4654aeae4d33c3f040e300682f23/docs/manual/cocci_syntax.tex#L199
>
> So it seems to be occasionally appropriate to use metavariables with
> the same type while different names are chosen then for the corresponding
> variable declaration.
>
>
> Another SmPL script example:
> @test@
> constant c1, c2;
> @@
>  x =
> *    c1
>  ;
>  x =
> *    c2
>  ;

@@
expression x;
constant c1,c2;
@@

x = c1;
(
x = c1;
|
*x = c2;
)

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

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

* Re: [Cocci] More precise distinction of types for source code searches?
  2019-06-25 14:38   ` Julia Lawall
@ 2019-06-25 17:09     ` Markus Elfring
  2019-06-26  8:36     ` Markus Elfring
  1 sibling, 0 replies; 5+ messages in thread
From: Markus Elfring @ 2019-06-25 17:09 UTC (permalink / raw)
  To: Julia Lawall; +Cc: Coccinelle

> @@
> expression x;
> constant c1,c2;
> @@
>
> x = c1;
> (
> x = c1;
> |
> *x = c2;
> )

Thanks for your suggestion of the possible usage of a SmPL disjunction.

* Does it indicate a search attempt to match the first assignment statement twice
  (for the implementation of exclusion of duplicate source code)?

* How many implementation details will become relevant for the corresponding
  documentation of the Coccinelle software?


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

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

* Re: [Cocci] More precise distinction of types for source code searches?
  2019-06-25 14:38   ` Julia Lawall
  2019-06-25 17:09     ` Markus Elfring
@ 2019-06-26  8:36     ` Markus Elfring
  1 sibling, 0 replies; 5+ messages in thread
From: Markus Elfring @ 2019-06-26  8:36 UTC (permalink / raw)
  To: Julia Lawall; +Cc: Coccinelle

> @@
> expression x;
> constant c1,c2;
> @@
>
> x = c1;

The SmPL manual contains the promising wording “As metavariables are bound
and inherited across rules, …”.
https://github.com/coccinelle/coccinelle/blob/c6d7554edf7c4654aeae4d33c3f040e300682f23/docs/manual/cocci_syntax.tex#L179

The mentioned binding and inheritance can still become clearer.
I guess that the Coccinelle software constructs corresponding internal
data structures. The application experience shows that specific matched values
can be directly reused in subsequent SmPL rules already.


> (
> x = c1;

Can it make sense then to support the direct access to a matched item also
as a constraint within the same SmPL rule?
How do you think about to work with backreferences to known data for further
checking (or exclusion) of such source code?


> |
> *x = c2;
> )

Will any SmPL constraint extensions result in the consequence to construct
a special metavariable type?

Will the software situation evolve further around the usage of such SmPL disjunctions?

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

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

end of thread, other threads:[~2019-06-26  8:37 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-06-24 12:51 [Cocci] More precise distinction of types for source code searches? Markus Elfring
2019-06-25 12:40 ` Markus Elfring
2019-06-25 14:38   ` Julia Lawall
2019-06-25 17:09     ` Markus Elfring
2019-06-26  8:36     ` 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).