cocci.inria.fr archive mirror
 help / color / mirror / Atom feed
From: Jaskaran Singh <jaskaransingh7654321@gmail.com>
To: cocci@systeme.lip6.fr
Cc: linux-kernel-mentees@lists.linuxfoundation.org
Subject: [Cocci] [RFC PATCH 16/25] engine: Add distrf_attr to PARAM functor
Date: Fri, 24 Apr 2020 14:47:52 +0530	[thread overview]
Message-ID: <20200424091801.13871-17-jaskaransingh7654321@gmail.com> (raw)
In-Reply-To: <20200424091801.13871-1-jaskaransingh7654321@gmail.com>

distrf_attr can be used to match a single attribute at a time. Add this
matcher function to the PARAM functor.

Signed-off-by: Jaskaran Singh <jaskaransingh7654321@gmail.com>
---
 engine/cocci_vs_c.ml       | 3 +++
 engine/cocci_vs_c.mli      | 3 +++
 engine/pattern_c.ml        | 1 +
 engine/transformation_c.ml | 5 +++++
 4 files changed, 12 insertions(+)

diff --git a/engine/cocci_vs_c.ml b/engine/cocci_vs_c.ml
index 2a3c3f94..e383aef8 100644
--- a/engine/cocci_vs_c.ml
+++ b/engine/cocci_vs_c.ml
@@ -700,6 +700,9 @@ module type PARAM =
     val distrf_exec_code_list :
       (A.meta_name A.mcode, (Ast_c.exec_code, Ast_c.il) either list) matcher
 
+    val distrf_attr :
+      (A.meta_name A.mcode, Ast_c.attribute) matcher
+
     val distrf_attrs :
       (A.meta_name A.mcode, (Ast_c.attribute, Ast_c.il) either list) matcher
 
diff --git a/engine/cocci_vs_c.mli b/engine/cocci_vs_c.mli
index ef55d478..70354e19 100644
--- a/engine/cocci_vs_c.mli
+++ b/engine/cocci_vs_c.mli
@@ -162,6 +162,9 @@ module type PARAM =
       (Ast_cocci.meta_name Ast_cocci.mcode,
        (Ast_c.exec_code, Ast_c.il) Common.either list) matcher
 
+    val distrf_attr :
+      (Ast_cocci.meta_name Ast_cocci.mcode, Ast_c.attribute) matcher
+
     val distrf_attrs :
       (Ast_cocci.meta_name Ast_cocci.mcode,
        (Ast_c.attribute, Ast_c.il) Common.either list) matcher
diff --git a/engine/pattern_c.ml b/engine/pattern_c.ml
index 7b1d0c0a..e6796368 100644
--- a/engine/pattern_c.ml
+++ b/engine/pattern_c.ml
@@ -335,6 +335,7 @@ module XMATCH = struct
   let distrf_define_params  = distrf Lib_parsing_c.ii_of_define_params
   let distrf_ident_list     = distrf Lib_parsing_c.ii_of_ident_list
   let distrf_exec_code_list = distrf Lib_parsing_c.ii_of_exec_code_list
+  let distrf_attr           = distrf Lib_parsing_c.ii_of_attr
   let distrf_attrs          = distrf Lib_parsing_c.ii_of_attrs
 
 
diff --git a/engine/transformation_c.ml b/engine/transformation_c.ml
index 4de8fe51..eecd4858 100644
--- a/engine/transformation_c.ml
+++ b/engine/transformation_c.ml
@@ -621,6 +621,9 @@ module XTRANS = struct
   let distribute_mck_ini (maxpos, minpos) = fun (lop,mop,rop,bop) -> fun x ->
     Visitor_c.vk_ini_s (mk_bigf (maxpos, minpos) (lop,mop,rop,bop)) x
 
+  let distribute_mck_attr (maxpos, minpos) = fun (lop,mop,rop,bop) -> fun x ->
+    Visitor_c.vk_attribute_s (mk_bigf (maxpos, minpos) (lop,mop,rop,bop)) x
+
   let distribute_mck_inis (maxpos, minpos) = fun (lop,mop,rop,bop) -> fun x ->
     Visitor_c.vk_inis_splitted_s (mk_bigf (maxpos, minpos) (lop,mop,rop,bop)) x
 
@@ -750,6 +753,8 @@ module XTRANS = struct
     distrf (Lib_parsing_c.ii_of_ident_list,distribute_mck_ident_list)
   let distrf_exec_code_list =
     distrf (Lib_parsing_c.ii_of_exec_code_list,distribute_mck_exec_code_list)
+  let distrf_attr =
+    distrf (Lib_parsing_c.ii_of_attr,distribute_mck_attr)
   let distrf_attrs =
     distrf (Lib_parsing_c.ii_of_attrs,distribute_mck_attrs)
 
-- 
2.21.1

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

  parent reply	other threads:[~2020-04-24  9:19 UTC|newest]

Thread overview: 26+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-04-24  9:17 [Cocci] [RFC PATCH 00/25] cocci: Improve C parsing of attributes Jaskaran Singh
2020-04-24  9:17 ` [Cocci] [RFC PATCH 01/25] parsing_c: parse_c: Ignore TMacroAttr and TMacroEndAttr in passed tokens Jaskaran Singh
2020-04-24  9:17 ` [Cocci] [RFC PATCH 02/25] parsing_c: parsing_hacks: Label end attributes correctly Jaskaran Singh
2020-04-24  9:17 ` [Cocci] [RFC PATCH 03/25] parsing_c: parsing_hacks: Commentize attributes before qualif/type Jaskaran Singh
2020-04-24  9:17 ` [Cocci] [RFC PATCH 04/25] parsing_c: parser: Add rule for multiple end attributes Jaskaran Singh
2020-04-24  9:17 ` [Cocci] [RFC PATCH 05/25] parsing_c: parser: Add expression statement attributes Jaskaran Singh
2020-04-24  9:17 ` [Cocci] [RFC PATCH 06/25] parsing_c: parser: Add attribute production in spec_qualif_list Jaskaran Singh
2020-04-24  9:17 ` [Cocci] [RFC PATCH 07/25] parsing_c: parser: Add init_declarator_attrs rule Jaskaran Singh
2020-04-24  9:17 ` [Cocci] [RFC PATCH 08/25] parsing_c: parser: Add field declaration end attributes production Jaskaran Singh
2020-04-24  9:17 ` [Cocci] [RFC PATCH 09/25] parsing_c: parser: Handle struct/union/enum end attributes Jaskaran Singh
2020-04-24  9:17 ` [Cocci] [RFC PATCH 10/25] parsing_c: parser: Add MacroDecl end attributes production Jaskaran Singh
2020-04-24  9:17 ` [Cocci] [RFC PATCH 11/25] parsing_c: parser: cpp_other " Jaskaran Singh
2020-04-24  9:17 ` [Cocci] [RFC PATCH 12/25] parsing_c: cpp_token_c: Introduce MACROANNOTATION hint Jaskaran Singh
2020-04-24  9:17 ` [Cocci] [RFC PATCH 13/25] cocci: standard.h: Annotate attributes with MACROANNOTATION Jaskaran Singh
2020-04-24  9:17 ` [Cocci] [RFC PATCH 14/25] parsing_c: visitor_c: Add vk_attribute and vk_attribute_s Jaskaran Singh
2020-04-24  9:17 ` [Cocci] [RFC PATCH 15/25] parsing_c: lib_parsing_c: Add ii_of_attr Jaskaran Singh
2020-04-24  9:17 ` Jaskaran Singh [this message]
2020-04-24  9:17 ` [Cocci] [RFC PATCH 17/25] engine: cocci_vs_c: Add allminus argument to attribute_list Jaskaran Singh
2020-04-24  9:17 ` [Cocci] [RFC PATCH 18/25] parsing_c: parser: Make abstract_declarator pass attributes Jaskaran Singh
2020-04-24  9:17 ` [Cocci] [RFC PATCH 19/25] cocci: Add parameter attributes to C AST Jaskaran Singh
2020-04-24  9:17 ` [Cocci] [RFC PATCH 20/25] parsing_c: parser: Place parameter attributes in " Jaskaran Singh
2020-04-24  9:17 ` [Cocci] [RFC PATCH 21/25] parsing_c: visitor_c: Visit parameter attributes Jaskaran Singh
2020-04-24  9:17 ` [Cocci] [RFC PATCH 22/25] parsing_c: unparse_hrule: Add parameter attributes in record Jaskaran Singh
2020-04-24  9:17 ` [Cocci] [RFC PATCH 23/25] parsing_c: type_c: Add parameter attributes to record Jaskaran Singh
2020-04-24  9:18 ` [Cocci] [RFC PATCH 24/25] engine: cocci_vs_c: "Match" parameter attributes Jaskaran Singh
2020-04-24  9:18 ` [Cocci] [RFC PATCH 25/25] engine: c_vs_c: Match " Jaskaran Singh

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=20200424091801.13871-17-jaskaransingh7654321@gmail.com \
    --to=jaskaransingh7654321@gmail.com \
    --cc=cocci@systeme.lip6.fr \
    --cc=linux-kernel-mentees@lists.linuxfoundation.org \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).