Adding code after function return types with SmPL
Hello,
I would like to try the following transformation approach out with the software combination “Coccinelle 1.0.8-00004-g842075f7”.
@addition@
identifier f;
type rt != void;
@@
rt
+__must_check
f(...);
elfring@Sonne:~/Projekte/Coccinelle/janitor> spatch --parse-cocci use_must_check.cocciinit_defs_builtins: /usr/local/bin/../lib/coccinelle/standard.h
plus: parse error:
File "use_must_check.cocci", line 7, column 1, charpos = 64
around = 'f',
whole content = f(...);
@is_void@
identifier f;
position p;
@@
void f@p(...);
@addition@
identifier f;
position p != is_void.p;
type rt;
@@
rt
+__must_check
f@p(...);
elfring@Sonne:~/Projekte/Coccinelle/janitor> spatch --parse-cocci use_must_check2.cocciinit_defs_builtins: /usr/local/bin/../lib/coccinelle/standard.h
plus: parse error:
File "use_must_check2.cocci", line 14, column 1, charpos = 137
around = 'f',
whole content = f@p(...);
Will the addition of such an annotation in a function declaration become supported for the semantic patch language?
Regards,
Markus
_______________________________________________
Cocci mailing list
[email protected]
https://systeme.lip6.fr/mailman/listinfo/cocci
Quoted 47 lines · Markus Elfring
Hello,
I would like to try the following transformation approach out with the software combination “Coccinelle 1.0.8-00004-g842075f7”.
@addition@
identifier f;
type rt != void;
@@
rt
+__must_check
f(...);elfring@Sonne:~/Projekte/Coccinelle/janitor> spatch --parse-cocci
use_must_check.cocciinit_defs_builtins:/usr/local/bin/../lib/coccinelle/standard.h
plus: parse error:
File "use_must_check.cocci", line 7, column 1, charpos = 64
around = 'f',
whole content = f(...);@is_void@
identifier f;
position p;
@@
void f@p(...);@addition@
identifier f;
position p != is_void.p;
type rt;
@@
rt
+__must_check
f@p(...);elfring@Sonne:~/Projekte/Coccinelle/janitor> spatch --parse-cocci
use_must_check2.cocciinit_defs_builtins:/usr/local/bin/../lib/coccinelle/standard.h
plus: parse error:
File "use_must_check2.cocci", line 14, column 1, charpos = 137
around = 'f',
whole content = f@p(...);
Quoted 2 lines
Will the addition of such an annotation in a function declaration become supported for the semantic patch language?
Perhaps some day.
julia
_______________________________________________
Cocci mailing list
[email protected]
https://systeme.lip6.fr/mailman/listinfo/cocci
Quoted 4 lines
Quoted 2 lines
Will the addition of such an annotation in a function declaration become supported for the semantic patch language?
Perhaps some day.
The desired modification for a known preprocessor symbol like “__must_check” points software development challenges out.
But the following SmPL script variant gets accepted.
@addition@
identifier f;
type rt != void;
@@
rt
+__attribute__ ((warn_unused_result))
f(...);
Can further improvements become easier also for another transformation approach?
@replacement@
@@
-__attribute__ ((warn_unused_result))
+__must_check
elfring@Sonne:~/Projekte/Coccinelle/janitor> spatch --parse-cocci use_must_check5.cocciinit_defs_builtins: /usr/local/bin/../lib/coccinelle/standard.h
File "use_must_check5.cocci", line 3, column 1, charpos = 18
around = '__attribute__',
whole content = -__attribute__ ((warn_unused_result))
Would any additional error information be helpful here?
Regards,
Markus
_______________________________________________
Cocci mailing list
[email protected]
https://systeme.lip6.fr/mailman/listinfo/cocci