Coccinelle Archive on lore.kernel.org
 help / color / Atom feed
From: Lukas Straub <lukasstraub2@web.de>
To: Julia Lawall <julia.lawall@inria.fr>
Cc: cocci@systeme.lip6.fr
Subject: [Cocci] Matching attributes
Date: Sat, 9 Jan 2021 00:48:41 +0100
Message-ID: <20210109004841.34cb9174@gecko.fritz.box> (raw)

[-- Attachment #1.1: Type: text/plain, Size: 729 bytes --]

Hello Everyone,
I am toying with coccinelle to assist in writing c code. My first try is to
automatically free/cleanup local variables when they go out of scope.

This works very well already:

 @@
 type T;
 identifier var;
 attribute name autofree;
 @@
 
    T var
 -  autofree
    = NULL;
    ...
 ++ free(var);
    return ...;

But this fails:

 @@
 type T;
 identifier var;
 attribute name autofree;
 @@
 
    T var autofree;
    ...
 ++ free(var);
    return ...;

with

 minus: parse error: 
   File "autofree.cocci", line 7, column 17, charpos = 73
   around = ';',
   whole content =    T var autofree;

What am I doing wrong here?
I tried both with v1.0.8 and latest git.
-- 


[-- Attachment #1.2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

[-- Attachment #2: Type: text/plain, Size: 136 bytes --]

_______________________________________________
Cocci mailing list
Cocci@systeme.lip6.fr
https://systeme.lip6.fr/mailman/listinfo/cocci

             reply index

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-01-08 23:48 Lukas Straub [this message]
2021-01-09  7:34 ` Julia Lawall

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20210109004841.34cb9174@gecko.fritz.box \
    --to=lukasstraub2@web.de \
    --cc=cocci@systeme.lip6.fr \
    --cc=julia.lawall@inria.fr \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link

Coccinelle Archive on lore.kernel.org

Archives are clonable:
	git clone --mirror https://lore.kernel.org/cocci/0 cocci/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 cocci cocci/ https://lore.kernel.org/cocci \
		cocci@systeme.lip6.fr
	public-inbox-index cocci

Example config snippet for mirrors

Newsgroup available over NNTP:
	nntp://nntp.lore.kernel.org/fr.lip6.systeme.cocci


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git