coccinelle / coccinelle

Source code of the Coccinelle project (mirror of the main Coccinelle repository located at Inria)
http://coccinelle.lip6.fr/
GNU General Public License v2.0
623 stars 100 forks source link

Parsing difficulties for pointer annotations #214

Open elfring opened 4 years ago

elfring commented 4 years ago

I have tried another tiny script variant out for the semantic patch language (once more according to the software combination “Coccinelle 1.0.8-00168-gc4048513”).

@display@
identifier action;
@@
*void __iomem * action(...)
 { ... }

Test result:

elfring@Sonne:~/Projekte/Coccinelle/janitor> spatch --parse-cocci show_iomem_functions.cocci
…
minus: parse error: 
  File "show_iomem_functions.cocci", line 4, column 14, charpos = 46
  around = '*',
  whole content = *void __iomem * action(...)

:crystal_ball: Will the chances grow to improve corresponding software components?

JuliaLawall commented 4 years ago

On Sat, 5 Sep 2020, Markus Elfring wrote:

I have tried another tiny script variant out for the semantic patch language (once more according to the software combination “Coccinelle 1.0.8-00168-gc4048513”).

@display@ identifier action; @@ void __iomem action(...) { ... }

Test result:

elfring@Sonne:~/Projekte/Coccinelle/janitor> spatch --parse-cocci show_iomem_functions.cocci … minus: parse error: File "show_iomem_functions.cocci", line 4, column 14, charpos = 46 around = '', whole content = void __iomem * action(...)

🔮 Will the chances grow to improve corresponding software components?

I'm pretty sure that you already asked this question on the mailing list and Jaskaran already answered it.

If you put the * before the __iomem, it will parse and it will match the same things.

julia

elfring commented 4 years ago

I'm pretty sure that you already asked this question on the mailing list

I provided a link for my initial clarification request.

and Jaskaran already answered it.

I am curious if further software development progress will happen.

If you put the * before the __iomem, it will parse and it will match the same things.

I mentioned also another test result for this use case.

JuliaLawall commented 4 years ago

On Sat, 5 Sep 2020, Markus Elfring wrote:

  I'm pretty sure that you already asked this question on the mailing list

I provided a link for my initial clarification request.

  and Jaskaran already answered it.

I am curious if further software development progress will happen.

Maybe, maybe not. It seems like a low priority, since it has no impact on expressiveness.

julia

  If you put the * before the __iomem, it will parse and it will match the same things.

I mentioned also another test result for this use case.

— You are receiving this because you commented. Reply to this email directly, view it on GitHub, or unsubscribe.[AAD2ZGWNS3NRMTJA6NBAAXTSEJWFZA5CNFSM4Q3DKYH2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOFD6IFCY.gif]

elfring commented 4 years ago

It seems like a low priority,

Yes.

since it has no impact on expressiveness.

This issue points further development opportunities out for the safe and convenient handling of annotations (or similar attributes).

elfring commented 4 years ago

:crystal_ball: Will any support evolve for a source code search like the following?

@display@
identifier input, work;
type t;
@@
*work(t * __percpu * input)
 { ... }

Test result:

elfring@Sonne:~/Projekte/Coccinelle/janitor> spatch --parse-cocci show_functions_with_percpu_pointer_parameters3.cocci
…
minus: parse error: 
  File "show_functions_with_percpu_pointer_parameters3.cocci", line 5, column 19, charpos = 64
  around = '*',
  whole content = *work(t * __percpu * input)
jajajasalu2 commented 4 years ago

Hi @elfring

try the following:

@display@
attribute name __percpu;
identifier input, work;
type t;
@@
*work(t ** input __percpu)
 { ... }

The attribute name because SmPL needs to know __percpu is an attribute. Move __percpu to the end because matching of an attribute in a parameter is done regardless of its position.

elfring commented 4 years ago

Move __percpu to the end

Thanks for your suggestion.

because matching of an attribute in a parameter is done regardless of its position.

I got an other software understanding. I imagine that the position can be meaningful for such extra specifications.

elfring commented 4 years ago

:crystal_ball: Can the following source code search approach become useful (despite of the display of a parse error by the software “Coccinelle 1.0.8-00177-g28737419”)?

@display@
attribute name __iomem;
@@
* __iomem