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

Signed-off-by: Jaskaran Singh <[email protected]>
---
 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
[email protected]
https://systeme.lip6.fr/mailman/listinfo/cocci

Reply via email to