Searching for switch statements with SmPL?
Hello,
I would appreciate if another source code analysis can be achieved also by the means of the semantic patch language.
Thus I tried the following SmPL script variant out.
@display@
constant c;
expression e;
statement s;
@@
(switch (e)
{
<+... case c: ... break; ...+>
}
|
*switch (...) s
)
Unfortunately, I am wondering about the following information.
Questionable test result (according to the software combination “Coccinelle 1.3.0”):
Markus_Elfring@Sonne:…/Projekte/Coccinelle/janitor> /usr/bin/spatch --parse-cocci show_switch_without_break2.cocci …
minus: parse error:
File "show_switch_without_break2.cocci", line 8, column 1, charpos = 68
around = '<+...',
whole content = <+... case c: ... break; ...+>
Under which circumstances will such data processing become better supported?
Regards,
Markus
Quoted 35 lines · Markus Elfring
Hello,
I would appreciate if another source code analysis can be achieved also by the means of the semantic patch language.
Thus I tried the following SmPL script variant out.@display@
constant c;
expression e;
statement s;
@@
(switch (e)
{
<+... case c: ... break; ...+>
}
|
*switch (...) s
)Unfortunately, I am wondering about the following information.
Questionable test result (according to the software combination “Coccinelle 1.3.0”):
Markus_Elfring@Sonne:…/Projekte/Coccinelle/janitor>/usr/bin/spatch--parse-coccishow_switch_without_break2.cocci…
minus: parse error:
File "show_switch_without_break2.cocci", line 8, column 1, charpos = 68
around = '<+...',
whole content = <+... case c: ... break; ...+>
Quoted 1 line
Under which circumstances will such data processing become better supported?
None. All cases are directly attached to the { of the switch, like if branches are attached to an if header. So the nest doesn’t make sense.
Quoted 3 lines
Regards,
Markus
Quoted 2 lines
Quoted 1 line
Under which circumstances will such data processing become better supported?
None. All cases are directly attached to the { of the switch, like if branches are attached to an if header. So the nest doesn’t make sense.
I hope that better common understanding can be achieved for more desirable software behaviour also according to such a feedback.
Which SmPL script variant would you find more reasonable for the mentioned use case?
Regards,
Markus
Quoted 15 lines · Markus Elfring
Quoted 3 lines
Quoted 2 lines
Under which circumstances will such data processing become better supported?
None. All cases are directly attached to the { of the switch, like if branches are attached to an if header. So the nest doesn’t make sense.
I hope that better common understanding can be achieved for more desirable software behaviour also according to such a feedback.
Which SmPL script variant would you find more reasonable for the mentioned use case?
Just remove the <+… …+>
Quoted 2 lines
Regards,
Markus
Quoted 4 lines
Quoted 2 lines
Which SmPL script variant would you find more reasonable for the mentioned use case?
Just remove the <+… …+>
May switch statements contain multiple cases?
https://cppreference.com/w/c/language/switch.html
Regards,
Markus
Yes. You used * so paths are considered individually Sent from my iPhone
Quoted 14 lines · Markus Elfring
Quoted 5 lines
Quoted 3 lines
Which SmPL script variant would you find more reasonable for the mentioned use case?
Just remove the <+… …+>
May switch statements contain multiple cases?
https://cppreference.com/w/c/language/switch.htmlRegards,
Markus
Quoted 1 line
Yes. You used * so paths are considered individually
Our development views might differ again on affected technical details.
* Which metavariable type would really fit to variable case distinctions by switch statements?
* Which implementation detail did hinder the desired parsing of SmPL code?
Regards,
Markus
A message that is not in the archive (sent off-list or not yet received): [email protected]
Quoted 1 line
There is no meta variable for case lines.
Did I stumble on another (temporary) software limitation then?
Quoted 1 line
The <+… …+> caused the parsing problem as far as I know.
I would expect that such an SmPL dot variant can usually handle multiple items.
Regards,
Markus
Quoted 1 line
Just remove the <+… …+>
Another interpretation:
Do you propose to restrict the source code search approach to a few known case distinctions?
Should the metavariable usage be adjusted any more accordingly?
Regards,
Markus