All of lore.kernel.org
 help / color / mirror / Atom feed
From: elfring@users.sourceforge.net (SF Markus Elfring)
To: cocci@systeme.lip6.fr
Subject: [Cocci] Match #define with SmPL
Date: Thu, 15 Sep 2016 10:11:44 +0200	[thread overview]
Message-ID: <42692ede-c509-7a9e-04d4-5eec51a2fc25@users.sourceforge.net> (raw)
In-Reply-To: <CAHKzcEMSxEXkDRqwTKq-AXZmFsH8uwsniQoCd1Uj_xCzn-nU_Q@mail.gmail.com>

> One more, I use 1.0.2 version as I had a problem with  1.0.5
> compilation previously.

Thanks that you added a bit more version information to your bug report.


> I will try bump to 1.0. 5 anyway and check the behavior.

Thanks for your interest to try additional software variants out.

I have tried also the following script out for the semantic patch language
of the software combination "Coccinelle 1.0.5-00089-g0849d71-dirty (OCaml 4.03.0)"
a moment ago.


@macro_deletion@
@@
-#define pr_fmt(fmt) "SVM: " fmt


elfring at Sonne:~/Projekte/Linux/next-patched> spatch.opt ~/Projekte/Coccinelle/Probe/delete_macro1.cocci arch/x86/kvm/svm.c
init_defs_builtins: /usr/local/lib64/coccinelle/standard.h
minus: parse error: 
  File "/home/elfring/Projekte/Coccinelle/Probe/delete_macro1.cocci", line 3, column 29, charpos = 49
  around = 'fmt',
  whole content = -#define pr_fmt(fmt) "SVM: " fmt


Do you eventually know any more software developers who would like to help in the task
"Completion of support for preprocessor statements by the Coccinelle software"?


I would be also looking for an interface to store the text from the macro definition
into a corresponding data structure.

* How do think about to look at another "story" like "Checking printk() calls with SmPL"
  once more?
  https://github.com/coccinelle/coccinelle/issues/54#issuecomment-169988424

* Which metavariable types would be appropriate for the discussed source code transformation?


I would like to point another detail out for further considerations according to
your initial request.

1. I guess that you should use the SmPL asterisk functionality if you are interested
   in only finding (or "matching") a bit of code.

@macro_definition@
@@
*#define pr_fmt(fmt) "SVM: " fmt


init_defs_builtins: /usr/local/lib64/coccinelle/standard.h
minus: parse error: 
  File "/home/elfring/Projekte/Coccinelle/Probe/show_macro_definition1.cocci", line 3, column 29, charpos = 51
  around = 'fmt',
  whole content = *#define pr_fmt(fmt) "SVM: " fmt


2. Do you want to try another source code adjustment out?

@statement_addition@
@@
+#undef  pr_fmt
 #define pr_fmt(fmt) "SVM: " fmt


elfring at Sonne:~/Projekte/Linux/next-patched> spatch.opt ~/Projekte/Coccinelle/Probe/add_undef1.cocci arch/x86/kvm/svm.c
init_defs_builtins: /usr/local/lib64/coccinelle/standard.h
minus: parse error: 
  File "/home/elfring/Projekte/Coccinelle/Probe/add_undef1.cocci", line 4, column 29, charpos = 69
  around = 'fmt',
  whole content =  #define pr_fmt(fmt) "SVM: " fmt


How often would you like to use such search patterns for your source files?

Regards,
Markus

  parent reply	other threads:[~2016-09-15  8:11 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-09-14 13:31 [Cocci] Match #define in cocci Waldemar Rymarkiewicz
2016-09-14 14:16 ` Julia Lawall
2016-09-15  5:57   ` Waldemar Rymarkiewicz
2016-09-15  6:03     ` Julia Lawall
2016-09-15  6:41       ` Waldemar Rymarkiewicz
2016-09-15  7:44         ` Waldemar Rymarkiewicz
2016-09-15  7:59           ` Julia Lawall
2016-09-15  8:11         ` SF Markus Elfring [this message]
2016-09-20 12:38           ` [Cocci] Match #define with SmPL Waldemar Rymarkiewicz
2016-09-20 18:20             ` SF Markus Elfring

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=42692ede-c509-7a9e-04d4-5eec51a2fc25@users.sourceforge.net \
    --to=elfring@users.sourceforge.net \
    --cc=cocci@systeme.lip6.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
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.