Searching for selected function declarations 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@
identifier i;
@@
my_type
*i(...)
;
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_selected_function_declarations.cocci …
(my_type *(*...*) *i;
|my_type *(*...*) *i = ...;
)
…
It seems that isomorphism rules converted the SmPL code into something different. I would interpret the generated data representation as variable declaration variants.
The intended source code search pattern might be ambiguous.
* C: function declaration
https://cppreference.com/w/c/language/function_declaration.html
* C++: variable definition
https://cppreference.com/w/cpp/language/declarations.html#Simple_declaration
Under which circumstances will such data processing become better supported?
Regards,
Markus
Quoted 1 line
Unfortunately, I am wondering about the following information.
Another SmPL script example:
@display disable decl_init@
identifier i;
parameter list pl;
@@
my_type
*i(pl)
;
Questionable test result (according to the software combination “Coccinelle 1.3.0”):
Markus_Elfring@Sonne:…/Projekte/Coccinelle/janitor> /usr/bin/spatch --parse-cocci show_selected_function_declarations3.cocci …my_type *(*pl*) *i;
…
Will further development considerations trigger more desirable improvements?
Regards,
Markus
Quoted 6 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.
Quoted 6 lines
@display@
identifier i;
@@
my_type
*i(...)
;
It would work properly if my_type were declared as a typedef.
julia
Quoted 32 lines
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_selected_function_declarations.cocci…
(my_type*(*...*) *i;
|my_type*(*...*) *i = ...;
)
…It seems that isomorphism rules converted the SmPL code into something different. I would interpret the generated data representation as variable declaration variants.
The intended source code search pattern might be ambiguous.
* C: function declaration
https://cppreference.com/w/c/language/function_declaration.html* C++: variable definition
https://cppreference.com/w/cpp/language/declarations.html#Simple_declarationUnder which circumstances will such data processing become better supported?
Regards,
Markus
Quoted 7 lines
Quoted 6 lines
@display@
identifier i;
@@
my_type
*i(...)
;It would work properly if
my_typewere declared as a typedef.
Can such a source code search pattern become supported also with an indicated fixed information (without moving it to a constraint for an extra metavariable)?
Regards,
Markus
Quoted 10 lines · Markus Elfring
Quoted 7 lines
Quoted 6 lines
@display@
identifier i;
@@
my_type
*i(...)
;It would work properly if
my_typewere declared as a typedef.Can such a source code search pattern become supported also with an indicated fixed information (without moving it to a constraint for an extra metavariable)?
I don't understand the question.
Currently, the code is being parsed as a variable declaration, not as a function prototype, but I am not completely sure to understand why.
julia
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
@display@
identifier i;
@@
my_type
*i(...)
;
Quoted 6 lines
Quoted 4 lines
Quoted 1 line
It would work properly if
my_typewere declared as a typedef.Can such a source code search pattern become supported also with an indicated fixed information (without moving it to a constraint for an extra metavariable)?
I don't understand the question.
You pointed the possibility out to use an additional metavariable with the type (or kind) “typedef”.
* The selection approach would become “variable” then for the function return type.
* I might like to restrict the relevant return types further.
Quoted 2 lines
Currently, the code is being parsed as a variable declaration, not as a function prototype, but I am not completely sure to understand why.
My understanding for the Coccinelle software is also evolving accordingly.
Regards,
Markus