8000
We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Applying the following semantic patch (simplified from https://gitlab.gnome.org/jtojnar/glib-refactoring/-/blob/0da312c4bfe3602cfc9d10c1e8f56b7574ad1c8a/patches/glib/autocleanup.cocci):
@@ identifier i; @@ Foo *i; <... -foo(i); ...> ?\Foo *i;
To the C code below:
void fun() { Foo *a; if (a != NULL) foo(a); }
produces invalid C code – the if body is removed but no empty block is inserted:
if
$ spatch --sp-file foo.cocci foo.c init_defs_builtins: /nix/store/i0xir67av8vqj2f5vrgaiq0v6f7yl9b2-coccinelle-dev/lib/coccinelle/standard.h SPECIAL NAMES: adding Foo as a type HANDLING: foo.c diff = --- foo.c +++ /tmp/cocci-output-28593-b00f94-foo.c @@ -2,5 +2,4 @@ void fun() { Foo *a; if (a != NULL) - foo(a); -} + }
Alternately, if there is more code after the if statement, the immediately following statement will become body of the if:
--- foo.c +++ /tmp/cocci-output-37272-626a04-foo.c @@ -2,7 +2,6 @@ void fun() { Foo *a; if (a != NULL) - foo(a); - bar(); + bar(); }
Empty block is correctly inserted if the question mark line is removed:
--- foo.c +++ /tmp/cocci-output-37350-45ac0d-foo.c @@ -2,7 +2,7 @@ void fun() { Foo *a; if (a != NULL) - foo(a); + {} bar(); }
Using coccinelle 1.2 but I can reproduce on master (ac9af0e) as well.
The text was updated successfully, but these errors were encountered:
No branches or pull requests
Applying the following semantic patch (simplified from https://gitlab.gnome.org/jtojnar/glib-refactoring/-/blob/0da312c4bfe3602cfc9d10c1e8f56b7574ad1c8a/patches/glib/autocleanup.cocci):
To the C code below:
produces invalid C code – the
if
body is removed but no empty block is inserted:Alternately, if there is more code after the
if
statement, the immediately following statement will become body of theif
:Empty block is correctly inserted if the question mark line is removed:
Using coccinelle 1.2 but I can reproduce on master (ac9af0e) as well.
The text was updated successfully, but these errors were encountered: