Deleting unwanted semicolons (with SmPL)?
Hello,
A bit of patch review triggered further development ideas.
[PATCH v2 3/3] i2c: rcar: minor changes to adhere to coding style
https://lore.kernel.org/linux-kernel/Zop2vNCrzDmEKKiO@shikoro/
https://lkml.org/lkml/2024/7/7/136
See also:
https://elixir.bootlin.com/linux/v6.10-rc6/source/drivers/i2c/busses/i2c-rcar.c#L189
Thus I constructed another tiny script variant for the semantic patch language.
@deletion@
@@
return ...;
}
-;
Questionable test result:
Markus_Elfring@Sonne:…/Projekte/Linux/next-analyses> git checkout next-20240703 && spatch drivers/i2c/busses/i2c-rcar.c …/Projekte/Coccinelle/janitor/delete_unwanted_semicolon.cocci …
minus: parse error:
File "…/Projekte/Coccinelle/janitor/delete_unwanted_semicolon.cocci", line 4, column 1, charpos = 28
around = '}',
whole content = }
Will the shown source code transformation approach ever become supported by the Coccinelle software?
Regards,
Markus
Quoted 6 lines
@deletion@
@@
return ...;
}
-;
How should coccinelle transfer this incomplete function body to an AST?
Quoted 2 lines
Will the shown source code transformation approach ever become supported by the Coccinelle software?
Wrong tool. I suggest AWK for such changes.
Quoted 7 lines
Quoted 5 lines
@deletion@
@@
return ...;
}
-;How should coccinelle transfer this incomplete function body to an AST?
I hope that the support will grow also for advanced handling of abstract syntax trees and semantic graphs.
Development interests grew somehow for programming languages like C++ and Rust to some degree (for example).
Quoted 4 lines
Quoted 2 lines
Will the shown source code transformation approach ever become supported by the Coccinelle software?
Wrong tool. I suggest AWK for such changes.
This programming language is also powerful. But I guess that its support is too limited so far for more desirable source code transformations.
Further improvements can eventually happen depending on corresponding development resources.
See also another clarification approach:
Add a metavariable for the handling of source code 2018-05-23
https://github.com/coccinelle/coccinelle/issues/140
Regards,
Markus
Quoted 7 lines · Markus Elfring
Quoted 7 lines
Quoted 5 lines
@deletion@
@@
return ...;
}
-;How should coccinelle transfer this incomplete function body to an AST?
How about
@@
statement S;
@@
S
- ;
On the other hand if you mean that you want to find ; after the end of a function definition, Coccinelle won't help with that.
julia
Quoted 27 lines
I hope that the support will grow also for advanced handling of abstract syntax trees and semantic graphs.
Development interests grew somehow for programming languages like C++ and Rust to some degree (for example).
Quoted 4 lines
Quoted 2 lines
Will the shown source code transformation approach ever become supported by the Coccinelle software?
Wrong tool. I suggest AWK for such changes.
This programming language is also powerful. But I guess that its support is too limited so far for more desirable source code transformations.
Further improvements can eventually happen depending on corresponding development resources.
See also another clarification approach:
Add a metavariable for the handling of source code 2018-05-23
https://github.com/coccinelle/coccinelle/issues/140Regards,
Markus
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 5 lines
@deletion@
@@
return ...;
}
-;
…
Quoted 2 lines
On the other hand if you mean that you want to find ; after the end of a function definition, Coccinelle won't help with that.
I hope still that such a source code transformation approach can become supported by the means of the semantic patch language.
Coding style concerns according to the usage of blank lines at such places can eventually be also reconsidered.
Regards,
Markus
Quoted 5 lines
Quoted 2 lines
How should coccinelle transfer this incomplete function body to an AST?
I hope that the support will grow also for advanced handling of abstract syntax trees and semantic graphs.
What approach would you suggest to create an AST from an incomplete function?
Quoted 6 lines
Quoted 4 lines
Quoted 1 line
How should coccinelle transfer this incomplete function body to an AST?
I hope that the support will grow also for advanced handling of abstract syntax trees and semantic graphs.
What approach would you suggest to create an AST from an incomplete function?
The semantic patch language was developed to handle the discussed source code search and transformation pattern (in principle), wasn't it?
Unfortunately, there are some known software limitations involved so far.
https://gitlab.inria.fr/coccinelle/coccinelle/-/blob/d657cc2613877729ae3fbf33c5e935f927b23cdc/docs/manual/cocci_syntax.tex#L1771
https://github.com/coccinelle/coccinelle/blob/ac9af0e8b7c76341de1999389ce285b72ebaf81b/docs/manual/cocci_syntax.tex#L1771
Various open issues point further development opportunities out, don't they?
I became curious under which circumstances corresponding software improvements can be achieved.
Regards,
Markus