cocci.inria.fr archive mirror
 help / color / mirror / Atom feed
From: Jaskaran Singh <jaskaran.singh@collabora.com>
To: cocci@systeme.lip6.fr
Subject: [Cocci] [PATCH 01/17] parsing_cocci: visitor_ast: Add attributefn to SmPL AST visitor
Date: Thu, 16 Jul 2020 18:35:05 +0530	[thread overview]
Message-ID: <20200716130521.7717-2-jaskaran.singh@collabora.com> (raw)
In-Reply-To: <20200716130521.7717-1-jaskaran.singh@collabora.com>

Add a public function to visit attributes in the SmPL AST visitor.

Signed-off-by: Jaskaran Singh <jaskaran.singh@collabora.com>
---
 parsing_cocci/visitor_ast.ml  | 12 ++++++++----
 parsing_cocci/visitor_ast.mli |  4 ++++
 2 files changed, 12 insertions(+), 4 deletions(-)

diff --git a/parsing_cocci/visitor_ast.ml b/parsing_cocci/visitor_ast.ml
index 5288c6f2..17afc518 100644
--- a/parsing_cocci/visitor_ast.ml
+++ b/parsing_cocci/visitor_ast.ml
@@ -34,6 +34,7 @@ type 'a combiner =
      combiner_rule_elem : Ast.rule_elem -> 'a;
      combiner_statement : Ast.statement -> 'a;
      combiner_case_line : Ast.case_line -> 'a;
+     combiner_attribute : Ast.attr -> 'a;
      combiner_top_level : Ast.top_level -> 'a;
      combiner_anything : Ast.anything  -> 'a;
      combiner_expression_dots : Ast.expression Ast.dots -> 'a;
@@ -57,7 +58,7 @@ let combiner bind option_default
     identfn exprfn fragfn fmtfn assignOpfn binaryOpfn ftfn tyfn initfn
     paramfn define_paramfn declfn
     annotated_declfn fieldfn annotated_fieldfn enum_declfn rulefn stmtfn
-    casefn topfn anyfn =
+    casefn attributefn topfn anyfn =
   let multibind l =
     let rec loop = function
 	[] -> option_default
@@ -921,7 +922,7 @@ let combiner bind option_default
     let k a =
       match Ast.unwrap a with
         Ast.Attribute(attr) -> string_mcode attr in
-    k a
+    attributefn all_functions k a
 
 
   and whencode notfn alwaysfn = function
@@ -1027,6 +1028,7 @@ let combiner bind option_default
       combiner_rule_elem = rule_elem;
       combiner_statement = statement;
       combiner_case_line = case_line;
+      combiner_attribute = attribute;
       combiner_top_level = top_level;
       combiner_anything = anything;
       combiner_expression_dots = expression_dots;
@@ -1059,6 +1061,7 @@ type rebuilder =
       rebuilder_parameter_list : Ast.parameter_list inout;
       rebuilder_statement : Ast.statement inout;
       rebuilder_case_line : Ast.case_line inout;
+      rebuilder_attribute : Ast.attr inout;
       rebuilder_rule_elem : Ast.rule_elem inout;
       rebuilder_top_level : Ast.top_level inout;
       rebuilder_expression_dots : Ast.expression Ast.dots inout;
@@ -1085,7 +1088,7 @@ let rebuilder
     enumdecldotsfn initdotsfn
     identfn exprfn fragfn fmtfn assignOpfn binaryOpfn ftfn tyfn initfn
     paramfn define_paramfn declfn annotated_declfn fieldfn annotated_fieldfn
-    enum_declfn rulefn stmtfn casefn topfn anyfn =
+    enum_declfn rulefn stmtfn casefn attributefn topfn anyfn =
   let get_option f = function
       Some x -> Some (f x)
     | None -> None in
@@ -1917,7 +1920,7 @@ let rebuilder
       Ast.rewrap a
         (match Ast.unwrap a with
           Ast.Attribute(attr) -> Ast.Attribute(string_mcode attr)) in
-    k a
+    attributefn all_functions k a
 
   and whencode notfn alwaysfn = function
       Ast.WhenNot a -> Ast.WhenNot (notfn a)
@@ -2026,6 +2029,7 @@ let rebuilder
       rebuilder_rule_elem = rule_elem;
       rebuilder_statement = statement;
       rebuilder_case_line = case_line;
+      rebuilder_attribute = attribute;
       rebuilder_top_level = top_level;
       rebuilder_expression_dots = expression_dots;
       rebuilder_statement_dots = statement_dots;
diff --git a/parsing_cocci/visitor_ast.mli b/parsing_cocci/visitor_ast.mli
index 0ed17774..55bfbf3f 100644
--- a/parsing_cocci/visitor_ast.mli
+++ b/parsing_cocci/visitor_ast.mli
@@ -23,6 +23,7 @@ type 'a combiner =
      combiner_rule_elem : Ast_cocci.rule_elem -> 'a;
      combiner_statement : Ast_cocci.statement -> 'a;
      combiner_case_line : Ast_cocci.case_line -> 'a;
+     combiner_attribute : Ast_cocci.attr -> 'a;
      combiner_top_level : Ast_cocci.top_level -> 'a;
      combiner_anything : Ast_cocci.anything  -> 'a;
      combiner_expression_dots : Ast_cocci.expression Ast_cocci.dots -> 'a;
@@ -77,6 +78,7 @@ val combiner :
       ((Ast_cocci.rule_elem,'a) ccode) ->
       ((Ast_cocci.statement,'a) ccode) ->
       ((Ast_cocci.case_line,'a) ccode) ->
+      ((Ast_cocci.attr,'a) ccode) ->
       ((Ast_cocci.top_level,'a) ccode) ->
       ((Ast_cocci.anything,'a) ccode) ->
       'a combiner
@@ -101,6 +103,7 @@ type rebuilder =
       rebuilder_parameter_list : Ast_cocci.parameter_list inout;
       rebuilder_statement : Ast_cocci.statement inout;
       rebuilder_case_line : Ast_cocci.case_line inout;
+      rebuilder_attribute : Ast_cocci.attr inout;
       rebuilder_rule_elem : Ast_cocci.rule_elem inout;
       rebuilder_top_level : Ast_cocci.top_level inout;
       rebuilder_expression_dots : Ast_cocci.expression Ast_cocci.dots inout;
@@ -158,6 +161,7 @@ val rebuilder :
     (Ast_cocci.rule_elem rcode) ->
     (Ast_cocci.statement rcode) ->
     (Ast_cocci.case_line rcode) ->
+    (Ast_cocci.attr rcode) ->
     (Ast_cocci.top_level rcode) ->
     (Ast_cocci.anything rcode) ->
     rebuilder
-- 
2.21.3

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

  reply	other threads:[~2020-07-16 13:06 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-07-16 13:05 [Cocci] [PATCH 00/17] parsing_cocci: Add attributefn to the SmPL AST visitor Jaskaran Singh
2020-07-16 13:05 ` Jaskaran Singh [this message]
2020-07-16 13:05 ` [Cocci] [PATCH 02/17] parsing_cocci: parse_cocci: Reflect attributefn in " Jaskaran Singh
2020-07-16 13:05 ` [Cocci] [PATCH 03/17] parsing_cocci: cleanup_rules: " Jaskaran Singh
2020-07-16 13:05 ` [Cocci] [PATCH 04/17] parsing_cocci: disjdistr: " Jaskaran Singh
2020-07-16 13:05 ` [Cocci] [PATCH 05/17] parsing_cocci: free_vars: " Jaskaran Singh
2020-07-16 13:05 ` [Cocci] [PATCH 06/17] parsing_cocci: get_constants2: " Jaskaran Singh
2020-07-16 13:05 ` [Cocci] [PATCH 07/17] parsing_cocci: re_constraints: " Jaskaran Singh
2020-07-16 13:05 ` [Cocci] [PATCH 08/17] parsing_cocci: safe_for_multi_decls: " Jaskaran Singh
2020-07-16 13:05 ` [Cocci] [PATCH 09/17] parsing_cocci: stmtlist: " Jaskaran Singh
2020-07-16 13:05 ` [Cocci] [PATCH 10/17] parsing_cocci: unify_ast: " Jaskaran Singh
2020-07-16 13:05 ` [Cocci] [PATCH 11/17] parsing_c: unparse_hrule: " Jaskaran Singh
2020-07-16 13:05 ` [Cocci] [PATCH 12/17] cocci: " Jaskaran Singh
2020-07-16 13:05 ` [Cocci] [PATCH 13/17] engine: asttoctl2: " Jaskaran Singh
2020-07-16 13:05 ` [Cocci] [PATCH 14/17] engine: asttomember: " Jaskaran Singh
2020-07-16 13:05 ` [Cocci] [PATCH 15/17] engine: cocci_vs_c: " Jaskaran Singh
2020-07-16 13:05 ` [Cocci] [PATCH 16/17] engine: transformation_c: " Jaskaran Singh
2020-07-16 13:05 ` [Cocci] [PATCH 17/17] popl09: popltoctl: " Jaskaran Singh
2020-07-18 14:17 ` [Cocci] [PATCH 00/17] parsing_cocci: Add attributefn to the SmPL " 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=20200716130521.7717-2-jaskaran.singh@collabora.com \
    --to=jaskaran.singh@collabora.com \
    --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 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).