parsing_cocci: Add attributefn to the SmPL AST0 visitor
cover parsing_cocci: Add attributefn to the SmPL AST0 visitor
This patch series aims to add a public function for visiting attributes to the SmPL AST0 visitor. This is needed to support meta attributes. An AttributeTag constructor is also added due to dependencies, as well as to maintain consistency with the codebase.
Jaskaran Singh (24):
parsing_cocci: visitor_ast0: Add attributefn to SmPL AST0 visitor
parsing_cocci: ast0toast: Reflect attributefn in AST0 visitor
parsing_cocci: check_meta: Reflect attributefn in AST0 visitor
parsing_cocci: function_prototypes: Reflect attributefn in AST0 visitor
parsing_cocci: iso_compile: Reflect attributefn in AST0 visitor
parsing_cocci: iso_pattern: Reflect attributefn in AST0 visitor
parsing_cocci: parse_cocci: Reflect attributefn in AST0 visitor
parsing_cocci: single_statement: Reflect attributefn in AST0 visitor
parsing_cocci: unitary_ast0: Reflect attributefn in AST0 visitor
parsing_cocci: ast0_cocci: Add AttributeTag to SmPL AST0
parsing_cocci: visitor_ast0: Reflect AttributeTag in SmPL AST0
parsing_cocci: iso_pattern: Reflect AttributeTag in SmPL AST0
parsing_cocci: unparse_ast0: Reflect AttributeTag in SmPL AST0
parsing_cocci: context_neg: Reflect AttributeTag in SmPL AST0
parsing_cocci: insert_plus: Reflect AttributeTag in SmPL AST0
parsing_cocci: ast_cocci: Add AttributeTag to the SmPL AST
parsing_cocci: pretty_print_cocci: Reflect AttributeTag in SmPL AST
parsing_c: unparse_cocci: Reflect AttributeTag in SmPL AST
parsing_cocci: visitor_ast: Reflect AttributeTag in SmPL AST
parsing_cocci: ast0toast: Reflect AttributeTag in the SmPL ASTs
ocaml: coccilib: Reflect AttributeTag in the SmPL ASTs
parsing_cocci: context_neg: Reflect attributefn in AST0 visitor
parsing_cocci: insert_plus: Reflect attributefn in AST0 visitor
tools: spgen: Reflect attributefn in AST0 visitor
ocaml/coccilib.mli | 2 ++ parsing_c/unparse_cocci.ml | 1 + parsing_cocci/ast0_cocci.ml | 2 ++ parsing_cocci/ast0_cocci.mli | 2 ++ parsing_cocci/ast0toast.ml | 5 +++-- parsing_cocci/ast0toast.mli | 1 + parsing_cocci/ast_cocci.ml | 2 ++ parsing_cocci/ast_cocci.mli | 1 + parsing_cocci/check_meta.ml | 4 ++-- parsing_cocci/context_neg.ml | 23 +++++++++++++++++------ parsing_cocci/function_prototypes.ml | 6 +++--- parsing_cocci/insert_plus.ml | 18 ++++++++++++++---- parsing_cocci/iso_compile.ml | 2 +- parsing_cocci/iso_pattern.ml | 17 +++++++++++------ parsing_cocci/parse_cocci.ml | 2 +- parsing_cocci/pretty_print_cocci.ml | 1 + parsing_cocci/single_statement.ml | 2 +- parsing_cocci/unitary_ast0.ml | 2 +- parsing_cocci/unparse_ast0.ml | 1 + parsing_cocci/visitor_ast.ml | 2 ++ parsing_cocci/visitor_ast0.ml | 24 ++++++++++++++++++++---- parsing_cocci/visitor_ast0.mli | 2 ++ parsing_cocci/visitor_ast0_types.ml | 6 ++++++ parsing_cocci/visitor_ast0_types.mli | 6 ++++++ tools/spgen/source/detect_patch.ml | 3 ++- tools/spgen/source/meta_variable.ml | 3 ++- tools/spgen/source/rule_body.ml | 3 ++- 27 files changed, 109 insertions(+), 34 deletions(-)
_______________________________________________
Cocci mailing list
[email protected]
https://systeme.lip6.fr/mailman/listinfo/cocci
PATCH 1/24 parsing_cocci: visitor_ast0: Add attributefn to SmPL AST0 visitor
Add a public function for visiting attributes to the SmPL AST0 visitor.
--- parsing_cocci/visitor_ast0.ml | 21 +++++++++++++++++---- parsing_cocci/visitor_ast0.mli | 2 ++ parsing_cocci/visitor_ast0_types.ml | 6 ++++++ parsing_cocci/visitor_ast0_types.mli | 6 ++++++ 4 files changed, 31 insertions(+), 4 deletions(-)
parsing_cocci/visitor_ast0.ml +17 -4
@@ -25,7 +25,7 @@ let visitor mode bind option_default dotsenumdeclfn dotscasefn dotsdefparfn identfn exprfn assignOpfn binaryOpfn tyfn initfn paramfn declfn fieldfn enumdeclfn - stmtfn forinfofn casefn string_fragmentfn topfn = + stmtfn forinfofn casefn string_fragmentfn attributefn topfn = let multibind l = let rec loop = function [] -> option_default
@@ -1155,7 +1155,7 @@ let visitor mode bind option_default Ast0.Attribute(attr) -> let (attr_n,attr) = string_mcode attr in (attr_n,Ast0.Attribute(attr))) in - k a + attributefn all_functions k a (* we only include the when string mcode w because the parameterised string_mcodefn function might have side-effects *)
@@ -1370,6 +1370,7 @@ let visitor mode bind option_default VT0.case_line = case_line; VT0.define_param = define_param; VT0.string_fragment = string_fragment; + VT0.attribute = attribute; VT0.top_level = top_level; VT0.expression_dots = expression_dots; VT0.statement_dots = statement_dots;
@@ -1419,6 +1420,7 @@ let combiner_functions = VT0.combiner_forinfofn = (fun r k e -> k e); VT0.combiner_casefn = (fun r k e -> k e); VT0.combiner_string_fragmentfn = (fun r k e -> k e); + VT0.combiner_attributefn = (fun r k e -> k e); VT0.combiner_topfn = (fun r k e -> k e)} let combiner_dz r =
@@ -1458,6 +1460,8 @@ let combiner_dz r = (function e -> let (n,_) = r.VT0.define_param e in n); VT0.combiner_rec_string_fragment = (function e -> let (n,_) = r.VT0.string_fragment e in n); + VT0.combiner_rec_attribute = + (function e -> let (n,_) = r.VT0.attribute e in n); VT0.combiner_rec_top_level = (function e -> let (n,_) = r.VT0.top_level e in n); VT0.combiner_rec_expression_dots =
@@ -1524,6 +1528,7 @@ let combiner bind option_default functions = (fun r k e -> (functions.VT0.combiner_forinfofn (dz r) (xk k) e, e)) (fun r k e -> (functions.VT0.combiner_casefn (dz r) (xk k) e, e)) (fun r k e -> (functions.VT0.combiner_string_fragmentfn (dz r) (xk k) e,e)) + (fun r k e -> (functions.VT0.combiner_attributefn (dz r) (xk k) e, e)) (fun r k e -> (functions.VT0.combiner_topfn (dz r) (xk k) e, e))) let flat_combiner bind option_default
@@ -1534,7 +1539,7 @@ let flat_combiner bind option_default dotsenumdeclfn dotscasefn dotsdefparfn identfn exprfn assignOpfn binaryOpfn tyfn initfn paramfn declfn fieldfn enumdeclfn - stmtfn forinfofn casefn string_fragmentfn topfn = + stmtfn forinfofn casefn string_fragmentfn attributefn topfn = let dz = combiner_dz in let xk k e = let (n,_) = k e in n in combiner_dz (visitor COMBINER bind option_default
@@ -1575,6 +1580,7 @@ let flat_combiner bind option_default (fun r k e -> (forinfofn (dz r) (xk k) e, e)) (fun r k e -> (casefn (dz r) (xk k) e, e)) (fun r k e -> (string_fragmentfn (dz r) (xk k) e, e)) + (fun r k e -> (attributefn (dz r) (xk k) e, e)) (fun r k e -> (topfn (dz r) (xk k) e, e))) let rebuilder_functions =
@@ -1615,6 +1621,7 @@ let rebuilder_functions = VT0.rebuilder_forinfofn = (fun r k e -> k e); VT0.rebuilder_casefn = (fun r k e -> k e); VT0.rebuilder_string_fragmentfn = (fun r k e -> k e); + VT0.rebuilder_attributefn = (fun r k e -> k e); VT0.rebuilder_topfn = (fun r k e -> k e)} let rebuilder_dz r =
@@ -1652,6 +1659,8 @@ let rebuilder_dz r = (function e -> let (_,e) = r.VT0.case_line e in e); VT0.rebuilder_rec_string_fragment = (function e -> let (_,e) = r.VT0.string_fragment e in e); + VT0.rebuilder_rec_attribute = + (function e -> let (_,e) = r.VT0.attribute e in e); VT0.rebuilder_rec_top_level = (function e -> let (_,e) = r.VT0.top_level e in e); VT0.rebuilder_rec_expression_dots =
@@ -1714,6 +1723,7 @@ let rebuilder functions = (fun r k e -> ((),functions.VT0.rebuilder_casefn (dz r) (xk k) e)) (fun r k e -> ((),functions.VT0.rebuilder_string_fragmentfn (dz r) (xk k) e)) + (fun r k e -> ((),functions.VT0.rebuilder_attributefn (dz r) (xk k) e)) (fun r k e -> ((),functions.VT0.rebuilder_topfn (dz r) (xk k) e))) let flat_rebuilder
@@ -1725,7 +1735,7 @@ let flat_rebuilder dotsenumdeclfn dotscasefn dotsdefparfn identfn exprfn assignOpfn arithOpfn tyfn initfn paramfn declfn fieldfn enumdeclfn - stmtfn forinfofn casefn string_fragmentfn topfn = + stmtfn forinfofn casefn string_fragmentfn attributefn topfn = let dz = rebuilder_dz in let xk k e = let (_,e) = k e in e in rebuilder_dz
@@ -1767,6 +1777,7 @@ let flat_rebuilder (fun r k e -> ((),forinfofn (dz r) (xk k) e)) (fun r k e -> ((),casefn (dz r) (xk k) e)) (fun r k e -> ((),string_fragmentfn (dz r) (xk k) e)) + (fun r k e -> ((),attributefn (dz r) (xk k) e)) (fun r k e -> ((),topfn (dz r) (xk k) e))) let combiner_rebuilder_functions =
@@ -1821,6 +1832,7 @@ let combiner_rebuilder_functions = VT0.combiner_rebuilder_forinfofn = (fun r k e -> k e); VT0.combiner_rebuilder_casefn = (fun r k e -> k e); VT0.combiner_rebuilder_string_fragmentfn = (fun r k e -> k e); + VT0.combiner_rebuilder_attributefn = (fun r k e -> k e); VT0.combiner_rebuilder_topfn = (fun r k e -> k e)} let combiner_rebuilder bind option_default functions =
@@ -1862,4 +1874,5 @@ let combiner_rebuilder bind option_default functions = functions.VT0.combiner_rebuilder_forinfofn functions.VT0.combiner_rebuilder_casefn functions.VT0.combiner_rebuilder_string_fragmentfn + functions.VT0.combiner_rebuilder_attributefn functions.VT0.combiner_rebuilder_topfn
parsing_cocci/visitor_ast0.mli +2 -0
@@ -50,6 +50,7 @@ val flat_combiner : ((Ast0_cocci.forinfo,'a) Visitor_ast0_types.ccode) -> ((Ast0_cocci.case_line,'a) Visitor_ast0_types.ccode) -> ((Ast0_cocci.string_fragment,'a) Visitor_ast0_types.ccode) -> + ((Ast0_cocci.attr,'a) Visitor_ast0_types.ccode) -> ((Ast0_cocci.top_level,'a) Visitor_ast0_types.ccode) -> 'a Visitor_ast0_types.combiner_rec_functions
@@ -95,6 +96,7 @@ val flat_rebuilder : (Ast0_cocci.forinfo Visitor_ast0_types.rcode) -> (Ast0_cocci.case_line Visitor_ast0_types.rcode) -> (Ast0_cocci.string_fragment Visitor_ast0_types.rcode) -> + (Ast0_cocci.attr Visitor_ast0_types.rcode) -> (Ast0_cocci.top_level Visitor_ast0_types.rcode) -> Visitor_ast0_types.rebuilder_rec_functions
parsing_cocci/visitor_ast0_types.ml +6 -0
@@ -28,6 +28,7 @@ type 'n all_functions = case_line : (Ast0.case_line,'n) inout; define_param : (Ast0.define_param,'n) inout; string_fragment : (Ast0.string_fragment,'n) inout; + attribute : (Ast0.attr,'n) inout; top_level : (Ast0.top_level,'n) inout; expression_dots : (Ast0.expression Ast0.dots,'n) inout; statement_dots : (Ast0.statement Ast0.dots,'n) inout;
@@ -63,6 +64,7 @@ type 'n combiner_rec_functions = combiner_rec_case_line : (Ast0.case_line,'n) combiner_inout; combiner_rec_define_param : (Ast0.define_param,'n) combiner_inout; combiner_rec_string_fragment : (Ast0.string_fragment,'n) combiner_inout; + combiner_rec_attribute : (Ast0.attr,'n) combiner_inout; combiner_rec_top_level : (Ast0.top_level,'n) combiner_inout; combiner_rec_expression_dots : (Ast0.expression Ast0.dots,'n) combiner_inout;
@@ -122,6 +124,7 @@ type 'n combiner_functions = combiner_forinfofn : (Ast0.forinfo,'n) ccode; combiner_casefn : (Ast0.case_line,'n) ccode; combiner_string_fragmentfn : (Ast0.string_fragment,'n) ccode; + combiner_attributefn : (Ast0.attr,'n) ccode; combiner_topfn : (Ast0.top_level,'n) ccode} (* ----------------------------------------------------------------------- *)
@@ -148,6 +151,7 @@ type rebuilder_rec_functions = rebuilder_rec_forinfo : Ast0.forinfo rebuilder_inout; rebuilder_rec_case_line : Ast0.case_line rebuilder_inout; rebuilder_rec_string_fragment : Ast0.string_fragment rebuilder_inout; + rebuilder_rec_attribute : Ast0.attr rebuilder_inout; rebuilder_rec_top_level : Ast0.top_level rebuilder_inout; rebuilder_rec_expression_dots : Ast0.expression Ast0.dots rebuilder_inout;
@@ -208,6 +212,7 @@ type rebuilder_functions = rebuilder_forinfofn : Ast0.forinfo rcode; rebuilder_casefn : Ast0.case_line rcode; rebuilder_string_fragmentfn : Ast0.string_fragment rcode; + rebuilder_attributefn : Ast0.attr rcode; rebuilder_topfn : Ast0.top_level rcode} (* ----------------------------------------------------------------------- *)
@@ -256,4 +261,5 @@ type 'n combiner_rebuilder_functions = combiner_rebuilder_forinfofn : (Ast0.forinfo,'n) rccode; combiner_rebuilder_casefn : (Ast0.case_line,'n) rccode; combiner_rebuilder_string_fragmentfn : (Ast0.string_fragment,'n) rccode; + combiner_rebuilder_attributefn : (Ast0.attr,'n) rccode; combiner_rebuilder_topfn : (Ast0.top_level,'n) rccode}
parsing_cocci/visitor_ast0_types.mli +6 -0
@@ -18,6 +18,7 @@ type 'n all_functions = { case_line : (Ast0_cocci.case_line, 'n) inout; define_param : (Ast0_cocci.define_param, 'n) inout; string_fragment : (Ast0_cocci.string_fragment, 'n) inout; + attribute : (Ast0_cocci.attr, 'n) inout; top_level : (Ast0_cocci.top_level, 'n) inout; expression_dots : (Ast0_cocci.expression Ast0_cocci.dots, 'n) inout; statement_dots : (Ast0_cocci.statement Ast0_cocci.dots, 'n) inout;
@@ -48,6 +49,7 @@ type 'n combiner_rec_functions = { combiner_rec_case_line : (Ast0_cocci.case_line, 'n) combiner_inout; combiner_rec_define_param : (Ast0_cocci.define_param, 'n) combiner_inout; combiner_rec_string_fragment : (Ast0_cocci.string_fragment, 'n) combiner_inout; + combiner_rec_attribute : (Ast0_cocci.attr, 'n) combiner_inout; combiner_rec_top_level : (Ast0_cocci.top_level, 'n) combiner_inout; combiner_rec_expression_dots : (Ast0_cocci.expression Ast0_cocci.dots, 'n) combiner_inout;
@@ -102,6 +104,7 @@ type 'n combiner_functions = { combiner_forinfofn : (Ast0_cocci.forinfo, 'n) ccode; combiner_casefn : (Ast0_cocci.case_line, 'n) ccode; combiner_string_fragmentfn : (Ast0_cocci.string_fragment, 'n) ccode; + combiner_attributefn : (Ast0_cocci.attr, 'n) ccode; combiner_topfn : (Ast0_cocci.top_level, 'n) ccode; } type 'a rebuilder_inout = 'a -> 'a
@@ -123,6 +126,7 @@ type rebuilder_rec_functions = { rebuilder_rec_forinfo : Ast0_cocci.forinfo rebuilder_inout; rebuilder_rec_case_line : Ast0_cocci.case_line rebuilder_inout; rebuilder_rec_string_fragment : Ast0_cocci.string_fragment rebuilder_inout; + rebuilder_rec_attribute : Ast0_cocci.attr rebuilder_inout; rebuilder_rec_top_level : Ast0_cocci.top_level rebuilder_inout; rebuilder_rec_expression_dots : Ast0_cocci.expression Ast0_cocci.dots rebuilder_inout; rebuilder_rec_statement_dots : Ast0_cocci.statement Ast0_cocci.dots rebuilder_inout;
@@ -175,6 +179,7 @@ type rebuilder_functions = { rebuilder_forinfofn : Ast0_cocci.forinfo rcode; rebuilder_casefn : Ast0_cocci.case_line rcode; rebuilder_string_fragmentfn : Ast0_cocci.string_fragment rcode; + rebuilder_attributefn : Ast0_cocci.attr rcode; rebuilder_topfn : Ast0_cocci.top_level rcode; } type ('mc, 'a) rcmcode = 'a -> 'mc Ast0_cocci.mcode -> 'a * 'mc Ast0_cocci.mcode
@@ -219,5 +224,6 @@ type 'n combiner_rebuilder_functions = { combiner_rebuilder_forinfofn : (Ast0_cocci.forinfo, 'n) rccode; combiner_rebuilder_casefn : (Ast0_cocci.case_line, 'n) rccode; combiner_rebuilder_string_fragmentfn : (Ast0_cocci.string_fragment, 'n) rccode; + combiner_rebuilder_attributefn : (Ast0_cocci.attr, 'n) rccode; combiner_rebuilder_topfn : (Ast0_cocci.top_level, 'n) rccode; }
Signature · 6 lines
2.21.3 _______________________________________________ Cocci mailing list [email protected] https://systeme.lip6.fr/mailman/listinfo/cocci
PATCH 2/24 parsing_cocci: ast0toast: Reflect attributefn in AST0 visitor
In reply to Jaskaran SinghThe SmPL AST0 visitor has a function for attributes. Reflect these changes in ast0toast.ml.
--- parsing_cocci/ast0toast.ml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
parsing_cocci/ast0toast.ml +2 -2
@@ -190,7 +190,7 @@ let inline_mcodes = do_nothing do_nothing do_nothing do_nothing do_nothing do_nothing do_nothing do_nothing do_nothing do_nothing do_nothing_end do_nothing_end do_nothing do_nothing - do_nothing do_nothing do_nothing do_nothing + do_nothing do_nothing do_nothing do_nothing do_nothing (* --------------------------------------------------------------------- *) (* For function declarations. Can't use the mcode at the root, because that
@@ -274,7 +274,7 @@ let check_allminus = donothing donothing ident expression donothing donothing typeC initialiser donothing declaration field donothing statement donothing case_line donothing - donothing + donothing donothing (* --------------------------------------------------------------------- *) (* --------------------------------------------------------------------- *)
Signature · 6 lines
2.21.3 _______________________________________________ Cocci mailing list [email protected] https://systeme.lip6.fr/mailman/listinfo/cocci
PATCH 3/24 parsing_cocci: check_meta: Reflect attributefn in AST0 visitor
In reply to Jaskaran SinghThe SmPL AST0 visitor has a function for attributes. Reflect these changes in check_meta.ml.
--- parsing_cocci/check_meta.ml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
parsing_cocci/check_meta.ml +2 -2
@@ -597,7 +597,7 @@ let positions rname table rules = donothing donothing donothing donothing donothing donothing donothing donothing donothing donothing donothing donothing donothing donothing donothing donothing donothing donothing donothing donothing donothing - donothing donothing donothing in + donothing donothing donothing donothing in List.iter fn.VT0.combiner_rec_top_level rules
@@ -667,7 +667,7 @@ let dup_positions rules = donothing donothing donothing donothing donothing donothing donothing donothing donothing donothing expression donothing donothing typeC donothing donothing declaration field donothing statement - donothing donothing donothing donothing in + donothing donothing donothing donothing donothing in let res = List.sort compare
Signature · 6 lines
2.21.3 _______________________________________________ Cocci mailing list [email protected] https://systeme.lip6.fr/mailman/listinfo/cocci
PATCH 4/24 parsing_cocci: function_prototypes: Reflect attributefn in AST0 visitor
In reply to Jaskaran SinghThe SmPL AST0 visitor has a function for attributes. Reflect these changes in function_prototypes.ml.
--- parsing_cocci/function_prototypes.ml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
parsing_cocci/function_prototypes.ml +3 -3
@@ -68,7 +68,7 @@ let drop_positions = donothing donothing donothing donothing donothing donothing donothing donothing donothing donothing donothing donothing donothing donothing donothing donothing donothing donothing donothing donothing donothing - donothing donothing donothing in + donothing donothing donothing donothing in res.VT0.rebuilder_rec_statement let get_all_functions rule =
@@ -174,7 +174,7 @@ and strip = donothing donothing ident donothing donothing donothing typeC donothing param donothing donothing donothing donothing donothing donothing donothing - donothing + donothing donothing and changed_proto = function (mname,mdef,mproto,None) -> true
@@ -198,7 +198,7 @@ let collect_ident_strings id = donothing donothing donothing donothing donothing donothing donothing donothing donothing donothing donothing donothing donothing donothing donothing donothing donothing donothing donothing donothing donothing - donothing donothing donothing in + donothing donothing donothing donothing in v.VT0.combiner_rec_ident id let right_attach_mcode strings (x,ar,info,mc,pos,adj) =
Signature · 6 lines
2.21.3 _______________________________________________ Cocci mailing list [email protected] https://systeme.lip6.fr/mailman/listinfo/cocci
PATCH 5/24 parsing_cocci: iso_compile: Reflect attributefn in AST0 visitor
In reply to Jaskaran SinghThe SmPL AST0 visitor has a function for attributes. Reflect these changes in iso_compile.ml.
--- parsing_cocci/iso_compile.ml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
parsing_cocci/iso_compile.ml +1 -1
@@ -55,7 +55,7 @@ let sequence_tokens = donothing donothing donothing donothing donothing donothing donothing donothing donothing donothing donothing donothing donothing donothing donothing donothing donothing donothing donothing donothing donothing - donothing donothing donothing + donothing donothing donothing donothing (* In general, we will get a list of lists:
Signature · 6 lines
2.21.3 _______________________________________________ Cocci mailing list [email protected] https://systeme.lip6.fr/mailman/listinfo/cocci
PATCH 6/24 parsing_cocci: iso_pattern: Reflect attributefn in AST0 visitor
In reply to Jaskaran SinghThe SmPL AST0 visitor has a function for attributes. Reflect these changes in iso_pattern.ml.
--- parsing_cocci/iso_pattern.ml | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-)
parsing_cocci/iso_pattern.ml +6 -6
@@ -45,7 +45,7 @@ let strip_info = donothing donothing donothing donothing donothing donothing donothing donothing donothing donothing donothing donothing donothing donothing donothing donothing donothing donothing donothing donothing donothing - donothing donothing donothing + donothing donothing donothing donothing let anything_equal = function (Ast0.DotsExprTag(d1),Ast0.DotsExprTag(d2)) ->
@@ -478,7 +478,7 @@ let match_maker checks_needed context_required whencode_allowed = donothing donothing donothing donothing donothing donothing donothing donothing donothing ident expression assignOp binaryOp typeC init param decl field donothing - stmt donothing donothing donothing donothing in + stmt donothing donothing donothing donothing donothing in let add_pure_list_binding name pure is_pure builder1 builder2 lst = match (checks_needed,pure) with
@@ -1595,7 +1595,7 @@ let make_minus = dots dots dots dots dots dots dots dots dots donothing expression donothing donothing donothing initialiser donothing declaration field enum_decl statement donothing donothing donothing - donothing + donothing donothing (* --------------------------------------------------------------------- *) (* rebuild mcode cells in an instantiated alt *)
@@ -1687,7 +1687,7 @@ let rebuild_mcode start_line = donothing donothing donothing donothing donothing donothing donothing donothing donothing donothing donothing donothing donothing donothing donothing donothing donothing donothing donothing statement donothing - donothing donothing donothing + donothing donothing donothing donothing (* --------------------------------------------------------------------- *) (* The problem of whencode. If an isomorphism contains dots in multiple
@@ -2172,7 +2172,7 @@ let instantiate bindings mv_bindings model = (dots elist) donothing (dots plist) (dots slist) donothing donothing donothing donothing donothing identfn exprfn donothing donothing tyfn initfn paramfn declfn fieldfn - enumdeclfn stmtfn donothing donothing donothing donothing + enumdeclfn stmtfn donothing donothing donothing donothing donothing (* --------------------------------------------------------------------- *)
@@ -2902,7 +2902,7 @@ let rewrap = donothing donothing donothing donothing donothing donothing donothing donothing donothing donothing donothing donothing donothing donothing donothing donothing donothing donothing donothing donothing donothing - donothing donothing donothing + donothing donothing donothing donothing let rec rewrap_anything = function Ast0.DotsExprTag(d) ->
Signature · 6 lines
2.21.3 _______________________________________________ Cocci mailing list [email protected] https://systeme.lip6.fr/mailman/listinfo/cocci
PATCH 7/24 parsing_cocci: parse_cocci: Reflect attributefn in AST0 visitor
In reply to Jaskaran SinghThe SmPL AST0 visitor has a function for attributes. Reflect these changes in parse_cocci.ml.
--- parsing_cocci/parse_cocci.ml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
parsing_cocci/parse_cocci.ml +1 -1
@@ -1966,7 +1966,7 @@ let any_modif rule = donothing donothing donothing donothing donothing donothing donothing donothing donothing donothing donothing donothing donothing donothing donothing donothing donothing donothing donothing donothing donothing - donothing donothing donothing in + donothing donothing donothing donothing in List.exists fn.VT0.combiner_rec_top_level rule let eval_virt virt =
Signature · 6 lines
2.21.3 _______________________________________________ Cocci mailing list [email protected] https://systeme.lip6.fr/mailman/listinfo/cocci
PATCH 8/24 parsing_cocci: single_statement: Reflect attributefn in AST0 visitor
In reply to Jaskaran SinghThe SmPL AST0 visitor has a function for attributes. Reflect these changes in single_statement.ml.
--- parsing_cocci/single_statement.ml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
parsing_cocci/single_statement.ml +1 -1
@@ -463,7 +463,7 @@ and contains_only_minus = dots dots dots dots dots dots dots dots dots identifier expression donothing donothing typeC donothing donothing declaration field donothing statement donothing case_line donothing - donothing + donothing donothing (* needs a special case when there is a Disj or an empty DOTS *)
Signature · 6 lines
2.21.3 _______________________________________________ Cocci mailing list [email protected] https://systeme.lip6.fr/mailman/listinfo/cocci
PATCH 9/24 parsing_cocci: unitary_ast0: Reflect attributefn in AST0 visitor
In reply to Jaskaran SinghThe SmPL AST0 visitor has a function for attributes. Reflect these changes in unitary_ast0.ml.
--- parsing_cocci/unitary_ast0.ml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
parsing_cocci/unitary_ast0.ml +1 -1
@@ -207,7 +207,7 @@ let get_free checker t = donothing donothing ident expression donothing donothing typeC donothing parameter declaration field donothing statement donothing case_line donothing - donothing in + donothing donothing in collect_unitary_nonunitary (List.concat (List.map res.VT0.combiner_rec_top_level t))
Signature · 6 lines
2.21.3 _______________________________________________ Cocci mailing list [email protected] https://systeme.lip6.fr/mailman/listinfo/cocci
PATCH 10/24 parsing_cocci: ast0_cocci: Add AttributeTag to SmPL AST0
In reply to Jaskaran SinghAdd the AttributeTag constructor to AST0 of SmPL.
--- parsing_cocci/ast0_cocci.ml | 2 ++ parsing_cocci/ast0_cocci.mli | 1 + 2 files changed, 3 insertions(+)
parsing_cocci/ast0_cocci.ml +2 -0
@@ -577,6 +577,7 @@ and anything = | ForInfoTag of forinfo | CaseLineTag of case_line | StringFragmentTag of string_fragment + | AttributeTag of attr | TopTag of top_level | IsoWhenTag of Ast.when_modifier | IsoWhenTTag of expression
@@ -608,6 +609,7 @@ let stmt x = StmtTag x let forinfo x = ForInfoTag x let case_line x = CaseLineTag x let string_fragment x = StringFragmentTag x +let attr x = AttributeTag x let top x = TopTag x let enum_decl x = EnumDeclTag x
parsing_cocci/ast0_cocci.mli +1 -0
@@ -566,6 +566,7 @@ and anything = | ForInfoTag of forinfo | CaseLineTag of case_line | StringFragmentTag of string_fragment + | AttributeTag of attr | TopTag of top_level | IsoWhenTag of Ast_cocci.when_modifier (*only for when code, in iso phase*) | IsoWhenTTag of expression(*only for when code, in iso phase*)
Signature · 6 lines
2.21.3 _______________________________________________ Cocci mailing list [email protected] https://systeme.lip6.fr/mailman/listinfo/cocci
PATCH 11/24 parsing_cocci: visitor_ast0: Reflect AttributeTag in SmPL AST0
In reply to Jaskaran SinghAttributeTag is added to SmPL AST0. Reflect these changes in visitor_ast0.ml.
--- parsing_cocci/visitor_ast0.ml | 3 +++ 1 file changed, 3 insertions(+)
parsing_cocci/visitor_ast0.ml +3 -0
@@ -1328,6 +1328,9 @@ let visitor mode bind option_default | Ast0.StringFragmentTag(f) -> let (f_n,f) = string_fragment f in (f_n,Ast0.StringFragmentTag(f)) + | Ast0.AttributeTag(a) -> + let (a_n,a) = attribute a in + (a_n,Ast0.AttributeTag(a)) | Ast0.TopTag(top) -> let (top_n,top) = top_level top in (top_n,Ast0.TopTag(top))
Signature · 6 lines
2.21.3 _______________________________________________ Cocci mailing list [email protected] https://systeme.lip6.fr/mailman/listinfo/cocci
PATCH 12/24 parsing_cocci: iso_pattern: Reflect AttributeTag in SmPL AST0
In reply to Jaskaran SinghAttributeTag is added to SmPL AST0. Reflect these changes in iso_pattern.ml.
--- parsing_cocci/iso_pattern.ml | 5 +++++ 1 file changed, 5 insertions(+)
parsing_cocci/iso_pattern.ml +5 -0
@@ -92,6 +92,9 @@ let anything_equal = function | (Ast0.StringFragmentTag(d1),Ast0.StringFragmentTag(d2)) -> (strip_info.VT0.rebuilder_rec_string_fragment d1) = (strip_info.VT0.rebuilder_rec_string_fragment d2) + | (Ast0.AttributeTag(d1),Ast0.AttributeTag(d2)) -> + (strip_info.VT0.rebuilder_rec_attribute d1) = + (strip_info.VT0.rebuilder_rec_attribute d2) | (Ast0.TopTag(d1),Ast0.TopTag(d2)) -> (strip_info.VT0.rebuilder_rec_top_level d1) = (strip_info.VT0.rebuilder_rec_top_level d2)
@@ -2946,6 +2949,8 @@ let rec rewrap_anything = function Ast0.CaseLineTag(rewrap.VT0.rebuilder_rec_case_line d) | Ast0.StringFragmentTag(d) -> Ast0.StringFragmentTag(rewrap.VT0.rebuilder_rec_string_fragment d) + | Ast0.AttributeTag(d) -> + Ast0.AttributeTag(rewrap.VT0.rebuilder_rec_attribute d) | Ast0.TopTag(d) -> Ast0.TopTag(rewrap.VT0.rebuilder_rec_top_level d) | Ast0.IsoWhenTag(_) | Ast0.IsoWhenTTag(_) | Ast0.IsoWhenFTag(_) -> failwith "only for isos within iso phase"
Signature · 6 lines
2.21.3 _______________________________________________ Cocci mailing list [email protected] https://systeme.lip6.fr/mailman/listinfo/cocci
PATCH 13/24 parsing_cocci: unparse_ast0: Reflect AttributeTag in SmPL AST0
In reply to Jaskaran SinghAttributeTag is added to SmPL AST0. Reflect these changes in unparse_ast0.ml.
--- parsing_cocci/unparse_ast0.ml | 1 + 1 file changed, 1 insertion(+)
parsing_cocci/unparse_ast0.ml +1 -0
@@ -873,6 +873,7 @@ let rec unparse_anything x = | Ast0.ForDecl (_,decl) -> declaration decl) | Ast0.CaseLineTag(d) -> case_line "" d | Ast0.StringFragmentTag(d) -> string_fragment d + | Ast0.AttributeTag(d) -> print_attribute d | Ast0.TopTag(d) -> top_level d | Ast0.IsoWhenTag(x) -> U.print_when_modif x | Ast0.IsoWhenTTag(e) -> expression e
Signature · 6 lines
2.21.3 _______________________________________________ Cocci mailing list [email protected] https://systeme.lip6.fr/mailman/listinfo/cocci
PATCH 14/24 parsing_cocci: context_neg: Reflect AttributeTag in SmPL AST0
In reply to Jaskaran SinghAttributeTag is added to SmPL AST0. Reflect these changes in context_neg.ml.
--- parsing_cocci/context_neg.ml | 3 +++ 1 file changed, 3 insertions(+)
parsing_cocci/context_neg.ml +3 -0
@@ -46,6 +46,7 @@ let set_mcodekind x mcodekind = | Ast0.ForInfoTag(d) -> Ast0.set_mcodekind d mcodekind | Ast0.CaseLineTag(d) -> Ast0.set_mcodekind d mcodekind | Ast0.StringFragmentTag(d) -> Ast0.set_mcodekind d mcodekind + | Ast0.AttributeTag(d) -> Ast0.set_mcodekind d mcodekind | Ast0.TopTag(d) -> Ast0.set_mcodekind d mcodekind | Ast0.IsoWhenTag(_) -> failwith "only within iso phase" | Ast0.IsoWhenTTag(_) -> failwith "only within iso phase"
@@ -81,6 +82,7 @@ let set_index x index = | Ast0.ForInfoTag(d) -> Ast0.set_index d index | Ast0.CaseLineTag(d) -> Ast0.set_index d index | Ast0.StringFragmentTag(d) -> Ast0.set_index d index + | Ast0.AttributeTag(d) -> Ast0.set_index d index | Ast0.TopTag(d) -> Ast0.set_index d index | Ast0.IsoWhenTag(_) -> failwith "only within iso phase" | Ast0.IsoWhenTTag(_) -> failwith "only within iso phase"
@@ -115,6 +117,7 @@ let get_index = function | Ast0.ForInfoTag(d) -> Index.forinfo d | Ast0.CaseLineTag(d) -> Index.case_line d | Ast0.StringFragmentTag(d) -> Index.string_fragment d + | Ast0.AttributeTag(d) -> Index.attribute d | Ast0.TopTag(d) -> Index.top_level d | Ast0.IsoWhenTag(_) -> failwith "only within iso phase" | Ast0.IsoWhenTTag(_) -> failwith "only within iso phase"
Signature · 6 lines
2.21.3 _______________________________________________ Cocci mailing list [email protected] https://systeme.lip6.fr/mailman/listinfo/cocci
PATCH 15/24 parsing_cocci: insert_plus: Reflect AttributeTag in SmPL AST0
In reply to Jaskaran SinghAttributeTag is added to SmPL AST0. Reflect these changes in insert_plus.ml.
--- parsing_cocci/ast0toast.mli | 1 + parsing_cocci/insert_plus.ml | 8 ++++++++ 2 files changed, 9 insertions(+)
parsing_cocci/ast0toast.mli +1 -0
@@ -36,6 +36,7 @@ val define_param_dots : Ast_cocci.define_param Ast_cocci.dots val case_line : Ast0_cocci.case_line -> Ast_cocci.case_line val string_fragment : Ast0_cocci.string_fragment -> Ast_cocci.string_fragment +val attribute : Ast0_cocci.attr -> Ast_cocci.attr val typeC : bool (*allminus*) -> Ast0_cocci.typeC -> Ast_cocci.fullType val declaration : Ast0_cocci.declaration -> Ast_cocci.declaration val field : Ast0_cocci.field -> Ast_cocci.field
parsing_cocci/insert_plus.ml +8 -0
@@ -133,6 +133,7 @@ let create_root_token_table minus = | Ast0.ForInfoTag(d) -> Ast0.get_index d | Ast0.CaseLineTag(d) -> Ast0.get_index d | Ast0.StringFragmentTag(d) -> Ast0.get_index d + | Ast0.AttributeTag(d) -> Ast0.get_index d | Ast0.TopTag(d) -> Ast0.get_index d | Ast0.IsoWhenTag(_) -> failwith "only within iso phase" | Ast0.IsoWhenTTag(_) -> failwith "only within iso phase"
@@ -461,6 +462,9 @@ let call_collect_minus context_nodes : | Ast0.StringFragmentTag(e) -> (Ast0.get_index e, (collect_minus_join_points e).VT0.combiner_rec_string_fragment e) + | Ast0.AttributeTag(e) -> + (Ast0.get_index e, + (collect_minus_join_points e).VT0.combiner_rec_attribute e) | Ast0.CaseLineTag(e) -> (Ast0.get_index e, (collect_minus_join_points e).VT0.combiner_rec_case_line e)
@@ -548,6 +552,7 @@ let mk_statement x = Ast.StatementTag (Ast0toast.statement x) let mk_forinfo x = Ast.ForInfoTag (Ast0toast.forinfo x) let mk_case_line x = Ast.CaseLineTag (Ast0toast.case_line x) let mk_string_fragment x = Ast.StringFragmentTag (Ast0toast.string_fragment x) +let mk_attribute x = Ast.AttributeTag (Ast0toast.attribute x) let mk_const_vol x = Ast.ConstVolTag x let mk_token x info = Ast.Token (x,Some info) let mk_meta (_,x) info = Ast.Token (x,Some info)
@@ -751,6 +756,9 @@ let call_collect_plus context_nodes : | Ast0.StringFragmentTag(e) -> (Ast0.get_index e, (collect_plus_nodes e).VT0.combiner_rec_string_fragment e) + | Ast0.AttributeTag(e) -> + (Ast0.get_index e, + (collect_plus_nodes e).VT0.combiner_rec_attribute e) | Ast0.TopTag(e) -> (Ast0.get_index e, (collect_plus_nodes e).VT0.combiner_rec_top_level e)
Signature · 6 lines
2.21.3 _______________________________________________ Cocci mailing list [email protected] https://systeme.lip6.fr/mailman/listinfo/cocci
PATCH 16/24 parsing_cocci: ast_cocci: Add AttributeTag to the SmPL AST
In reply to Jaskaran SinghAdd the AttributeTag constructor to the SmPL AST.
--- parsing_cocci/ast_cocci.ml | 2 ++ parsing_cocci/ast_cocci.mli | 1 + 2 files changed, 3 insertions(+)
parsing_cocci/ast_cocci.ml +2 -0
@@ -804,6 +804,7 @@ and anything = | ForInfoTag of forinfo | CaseLineTag of case_line | StringFragmentTag of string_fragment + | AttributeTag of attr | ConstVolTag of const_vol | Token of string * info option | Directive of added_string list
@@ -948,6 +949,7 @@ and tag2c = function | ForInfoTag _ -> "ForInfoTag" | CaseLineTag _ -> "CaseLineTag" | StringFragmentTag _ -> "StringFragmentTag" + | AttributeTag _ -> "AttributeTag" | ConstVolTag _ -> "ConstVolTag" | Token _ -> "Token" | Directive _ -> "Directive"
parsing_cocci/ast_cocci.mli +1 -0
@@ -773,6 +773,7 @@ and anything = | ForInfoTag of forinfo | CaseLineTag of case_line | StringFragmentTag of string_fragment + | AttributeTag of attr | ConstVolTag of const_vol | Token of string * info option | Directive of added_string list
Signature · 6 lines
2.21.3 _______________________________________________ Cocci mailing list [email protected] https://systeme.lip6.fr/mailman/listinfo/cocci
PATCH 17/24 parsing_cocci: pretty_print_cocci: Reflect AttributeTag in SmPL AST
In reply to Jaskaran SinghAttributeTag is added to the SmPL AST. Reflect these changes in pretty_print_cocci.ml.
--- parsing_cocci/pretty_print_cocci.ml | 1 + 1 file changed, 1 insertion(+)
parsing_cocci/pretty_print_cocci.ml +1 -0
@@ -1169,6 +1169,7 @@ let _ = | Ast.ForInfoTag(x) -> forinfo x | Ast.CaseLineTag(x) -> case_line "" x | Ast.StringFragmentTag(x) -> string_fragment x + | Ast.AttributeTag(x) -> print_attribute x | Ast.ConstVolTag(x) -> const_vol x | Ast.Token(x,Some info) -> print_string_befaft print_string x info | Ast.Token(x,None) -> print_string x
Signature · 6 lines
2.21.3 _______________________________________________ Cocci mailing list [email protected] https://systeme.lip6.fr/mailman/listinfo/cocci
PATCH 18/24 parsing_c: unparse_cocci: Reflect AttributeTag in SmPL AST
In reply to Jaskaran SinghAttributeTag is added to the SmPL AST. Reflect these changes in unparse_cocci.ml.
--- parsing_c/unparse_cocci.ml | 1 + 1 file changed, 1 insertion(+)
parsing_c/unparse_cocci.ml +1 -0
@@ -1512,6 +1512,7 @@ let pp_any = function | Ast.ForInfoTag(x) -> forinfo x; false | Ast.CaseLineTag(x) -> case_line "" x; false | Ast.StringFragmentTag(x) -> string_fragment x; false + | Ast.AttributeTag(x) -> print_attribute x; false | Ast.ConstVolTag(x) -> const_vol x unknown unknown; false | Ast.Directive(xs) ->
Signature · 6 lines
2.21.3 _______________________________________________ Cocci mailing list [email protected] https://systeme.lip6.fr/mailman/listinfo/cocci
PATCH 19/24 parsing_cocci: visitor_ast: Reflect AttributeTag in SmPL AST
In reply to Jaskaran SinghAttributeTag is added to the SmPL AST. Reflect these changes in visitor_ast.ml.
--- parsing_cocci/visitor_ast.ml | 2 ++ 1 file changed, 2 insertions(+)
parsing_cocci/visitor_ast.ml +2 -0
@@ -990,6 +990,7 @@ let combiner bind option_default | Ast.ForInfoTag(rule) -> forinfo rule | Ast.CaseLineTag(case) -> case_line case | Ast.StringFragmentTag(frag) -> string_fragment frag + | Ast.AttributeTag(attr) -> attribute attr | Ast.ConstVolTag(cv) -> option_default | Ast.Token(tok,info) -> option_default | Ast.Directive(str) -> option_default
@@ -1988,6 +1989,7 @@ let rebuilder | Ast.CaseLineTag(case) -> Ast.CaseLineTag(case_line case) | Ast.StringFragmentTag(frag) -> Ast.StringFragmentTag(string_fragment frag) + | Ast.AttributeTag(attr) -> Ast.AttributeTag(attribute attr) | Ast.ConstVolTag(cv) as x -> x | Ast.Token(tok,info) as x -> x | Ast.Directive(str) as x -> x
Signature · 6 lines
2.21.3 _______________________________________________ Cocci mailing list [email protected] https://systeme.lip6.fr/mailman/listinfo/cocci
PATCH 20/24 parsing_cocci: ast0toast: Reflect AttributeTag in the SmPL ASTs
In reply to Jaskaran SinghAttributeTag is added to the SmPL ASTs. Reflect these changes in ast0toast.ml.
--- parsing_cocci/ast0toast.ml | 1 + 1 file changed, 1 insertion(+)
parsing_cocci/ast0toast.ml +1 -0
@@ -1264,6 +1264,7 @@ and anything = function | Ast0.ForInfoTag(d) -> Ast.ForInfoTag(forinfo d) | Ast0.CaseLineTag(d) -> Ast.CaseLineTag(case_line d) | Ast0.StringFragmentTag(d) -> Ast.StringFragmentTag(string_fragment d) + | Ast0.AttributeTag(d) -> Ast.AttributeTag(attribute d) | Ast0.TopTag(d) -> Ast.Code(top_level d) | Ast0.IsoWhenTag(_) -> failwith "not possible" | Ast0.IsoWhenTTag(_) -> failwith "not possible"
Signature · 6 lines
2.21.3 _______________________________________________ Cocci mailing list [email protected] https://systeme.lip6.fr/mailman/listinfo/cocci
PATCH 21/24 ocaml: coccilib: Reflect AttributeTag in the SmPL ASTs
In reply to Jaskaran SinghAttributeTag is added to the SmPL ASTs. Reflect these changes in coccilib.mli.
--- ocaml/coccilib.mli | 2 ++ 1 file changed, 2 insertions(+)
ocaml/coccilib.mli +2 -0
@@ -3078,6 +3078,7 @@ module Ast_cocci : | ForInfoTag of forinfo | CaseLineTag of case_line | StringFragmentTag of string_fragment + | AttributeTag of attr | ConstVolTag of const_vol | Token of string * info option | Directive of added_string list
@@ -3660,6 +3661,7 @@ module Ast0_cocci : | ForInfoTag of forinfo | CaseLineTag of case_line | StringFragmentTag of string_fragment + | AttributeTag of attr | TopTag of top_level | IsoWhenTag of Ast_cocci.when_modifier | IsoWhenTTag of expression
Signature · 6 lines
2.21.3 _______________________________________________ Cocci mailing list [email protected] https://systeme.lip6.fr/mailman/listinfo/cocci
PATCH 22/24 parsing_cocci: context_neg: Reflect attributefn in AST0 visitor
In reply to Jaskaran SinghThe SmPL AST0 visitor has a function for attributes. Reflect these changes in context_neg.ml. Also add a few general fixes w/r/t the usage of the for_all2 function for comparing attributes.
--- parsing_cocci/ast0_cocci.mli | 1 + parsing_cocci/context_neg.ml | 20 ++++++++++++++------ 2 files changed, 15 insertions(+), 6 deletions(-)
parsing_cocci/ast0_cocci.mli +1 -0
@@ -599,6 +599,7 @@ val stmt : statement -> anything val forinfo : forinfo -> anything val case_line : case_line -> anything val string_fragment : string_fragment -> anything +val attr : attr -> anything val top : top_level -> anything (* --------------------------------------------------------------------- *)
parsing_cocci/context_neg.ml +14 -6
@@ -186,7 +186,7 @@ let collect_plus_lines top = donothing donothing donothing donothing donothing donothing donothing donothing donothing donothing donothing donothing statement donothing donothing donothing - donothing in + donothing donothing in fn.VT0.combiner_rec_top_level top (* --------------------------------------------------------------------- *)
@@ -557,7 +557,7 @@ let classify is_minus all_marked table code = ident expression (do_nothing Ast0.assignOp) (do_nothing Ast0.binaryOp) typeC initialiser param declaration field enum_decl statement (do_nothing Ast0.forinfo) case_line string_fragment - (do_top Ast0.top) in + (do_nothing Ast0.attr) (do_top Ast0.top) in combiner.VT0.combiner_rec_top_level code (* --------------------------------------------------------------------- *)
@@ -644,6 +644,7 @@ let rec equal_expression e1 e2 = equal_mcode ar1 ar2 | (Ast0.Cast(lp1,_,ar1,rp1,_),Ast0.Cast(lp2,_,ar2,rp2,_)) -> equal_mcode lp1 lp2 && + (List.length ar1) = (List.length ar2) && List.for_all2 equal_attribute ar1 ar2 && equal_mcode rp1 rp2 | (Ast0.SizeOfExpr(szf1,_),Ast0.SizeOfExpr(szf2,_)) ->
@@ -752,10 +753,14 @@ let equal_declaration d1 d2 = equal_mcode name1 name2 | (Ast0.Init(stg1,_,_,attr1,eq1,_,sem1), Ast0.Init(stg2,_,_,attr2,eq2,_,sem2)) -> - equal_option stg1 stg2 && List.for_all2 equal_attribute attr1 attr2 && + equal_option stg1 stg2 && + (List.length attr1) = (List.length attr2) && + List.for_all2 equal_attribute attr1 attr2 && equal_mcode eq1 eq2 && equal_mcode sem1 sem2 | (Ast0.UnInit(stg1,_,_,attr1,sem1),Ast0.UnInit(stg2,_,_,attr2,sem2)) -> - equal_option stg1 stg2 && List.for_all2 equal_attribute attr1 attr2 && + equal_option stg1 stg2 && + (List.length attr1) = (List.length attr2) && + List.for_all2 equal_attribute attr1 attr2 && equal_mcode sem1 sem2 | (Ast0.FunProto(fninfo1,name1,lp1,p1,va1,rp1,sem1), Ast0.FunProto(fninfo2,name2,lp2,p2,va2,rp2,sem2)) ->
@@ -770,7 +775,9 @@ let equal_declaration d1 d2 = equal_mcode rp1 rp2 && equal_mcode sem1 sem2 | (Ast0.MacroDecl(stg1,nm1,lp1,_,rp1,attr1,sem1), Ast0.MacroDecl(stg2,nm2,lp2,_,rp2,attr2,sem2)) -> - equal_option stg1 stg2 && List.for_all2 equal_attribute attr1 attr2 && + equal_option stg1 stg2 && + (List.length attr1) = (List.length attr2) && + List.for_all2 equal_attribute attr1 attr2 && equal_mcode lp1 lp2 && equal_mcode rp1 rp2 && equal_mcode sem1 sem2 | (Ast0.MacroDeclInit(stg1,nm1,lp1,_,rp1,eq1,_,sem1), Ast0.MacroDeclInit(stg2,nm2,lp2,_,rp2,eq2,_,sem2)) ->
@@ -778,6 +785,7 @@ let equal_declaration d1 d2 = equal_mcode lp1 lp2 && equal_mcode rp1 rp2 && equal_mcode eq1 eq2 && equal_mcode sem1 sem2 | (Ast0.TyDecl(_,attr1,sem1),Ast0.TyDecl(_,attr2,sem2)) -> + (List.length attr1) = (List.length attr2) && List.for_all2 equal_attribute attr1 attr2 && equal_mcode sem1 sem2 | (Ast0.OptDecl(_),Ast0.OptDecl(_)) -> true | (Ast0.DisjDecl(starter1,_,mids1,ender1),
@@ -1055,7 +1063,7 @@ let contextify_all = donothing donothing donothing donothing donothing donothing donothing donothing donothing donothing donothing donothing donothing donothing donothing donothing donothing donothing donothing donothing donothing - donothing donothing donothing + donothing donothing donothing donothing let contextify_whencode = let bind x y = () in
Signature · 6 lines
2.21.3 _______________________________________________ Cocci mailing list [email protected] https://systeme.lip6.fr/mailman/listinfo/cocci
PATCH 23/24 parsing_cocci: insert_plus: Reflect attributefn in AST0 visitor
In reply to Jaskaran SinghThe SmPL AST0 visitor has a function for attributes. Reflect these changes in insert_plus.ml.
--- parsing_cocci/insert_plus.ml | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-)
parsing_cocci/insert_plus.ml +6 -4
@@ -83,7 +83,8 @@ it *) (donothing Ast0.param) (donothing Ast0.decl) (donothing Ast0.field) (donothing Ast0.enum_decl) statement (donothing Ast0.forinfo) (donothing Ast0.case_line) - (donothing Ast0.string_fragment) topfn in + (donothing Ast0.string_fragment) (donothing Ast0.attr) + topfn in res.VT0.combiner_rec_top_level e (* --------------------------------------------------------------------- *)
@@ -386,7 +387,7 @@ bind to that; not good for isomorphisms *) edots idots pdots sdots ddots fdots enumdots cdots dpdots ident expression do_nothing do_nothing typeC initialiser param decl field do_nothing statement forinfo - case_line do_nothing do_top + case_line do_nothing do_nothing do_top let call_collect_minus context_nodes :
@@ -678,7 +679,8 @@ let collect_plus_nodes root = (do_nothing mk_declaration) (do_nothing mk_field) (do_nothing mk_enum_decl) stmt (do_nothing mk_forinfo) (do_nothing mk_case_line) - (do_nothing mk_string_fragment) toplevel + (do_nothing mk_string_fragment) (do_nothing mk_attribute) + toplevel let call_collect_plus context_nodes : (int * (Ast0.info * Ast.count * Ast.anything) list) list =
@@ -1239,7 +1241,7 @@ let reevaluate_contextness = donothing donothing donothing donothing donothing donothing stmt donothing donothing donothing - donothing in + donothing donothing in res.VT0.combiner_rec_top_level (* --------------------------------------------------------------------- *)
Signature · 6 lines
2.21.3 _______________________________________________ Cocci mailing list [email protected] https://systeme.lip6.fr/mailman/listinfo/cocci
PATCH 24/24 tools: spgen: Reflect attributefn in AST0 visitor
In reply to Jaskaran SinghThe SmPL AST0 visitor has a function for attributes. Reflect these changes in spgen.
--- tools/spgen/source/detect_patch.ml | 3 ++- tools/spgen/source/meta_variable.ml | 3 ++- tools/spgen/source/rule_body.ml | 3 ++- 3 files changed, 6 insertions(+), 3 deletions(-)
tools/spgen/source/detect_patch.ml +2 -1
@@ -111,6 +111,7 @@ let patch_combiner = let paramfn = donothing in let forinfofn = donothing in let string_fragmentfn = donothing in + let attributefn = donothing in let topfn = donothing in let dotsstmtfn = donothing in
@@ -163,7 +164,7 @@ let patch_combiner = dotsexprfn dotsinitfn dotsparamfn dotsstmtfn dotsdeclfn dotsfieldfn dotsenumdeclfn dotscasefn dotsdefparfn identfn exprfn assignOpfn binaryOpfn tyfn initfn paramfn declfn fieldfn - enumdeclfn stmtfn forinfofn casefn string_fragmentfn topfn + enumdeclfn stmtfn forinfofn casefn string_fragmentfn attributefn topfn (* ------------------------------------------------------------------------- *)
tools/spgen/source/meta_variable.ml +2 -1
@@ -396,6 +396,7 @@ let metavar_combiner rn = let casefn = donothing in let topfn = donothing in let enumdeclfn = donothing in + let attributefn = donothing in (* --- These are shortened formatting functions that return MVSets --- *)
@@ -577,7 +578,7 @@ let metavar_combiner rn = dotsexprfn dotsinitfn dotsparamfn dotsstmtfn dotsdeclfn dotsfieldfn dotsenumdeclfn dotscasefn dotsdefparfn identfn exprfn assignOpfn binaryOpfn tyfn initfn paramfn declfn fieldfn - enumdeclfn stmtfn forinfofn casefn string_fragmentfn topfn + enumdeclfn stmtfn forinfofn casefn string_fragmentfn attributefn topfn (* ------------------------------------------------------------------------- *)
tools/spgen/source/rule_body.ml +2 -1
@@ -231,6 +231,7 @@ let rec gen_combiner ~context_mode = let forinfofn = donothing in let casefn = donothing in let string_fragmentfn = donothing in + let attributefn = donothing in (* Universal special cases, regardless of no_gen mode: * Disjunctions with SmPL style pattern-matching may need to be split into
@@ -353,7 +354,7 @@ let rec gen_combiner ~context_mode = dotsexprfn dotsinitfn dotsparamfn dotsstmtfn dotsdeclfn dotsfieldfn dotsenumdeclfn dotscasefn dotsdefparfn identfn exprfn assignOpfn binaryOpfn tyfn initfn paramfn declfn fieldfn - enumdeclfn stmtfn forinfofn casefn string_fragmentfn topfn + enumdeclfn stmtfn forinfofn casefn string_fragmentfn attributefn topfn (* ------------------------------------------------------------------------- *)
Signature · 6 lines
2.21.3 _______________________________________________ Cocci mailing list [email protected] https://systeme.lip6.fr/mailman/listinfo/cocci
Julia Lawall
AppliedQuoted 4 lines · Jaskaran Singh
This patch series aims to add a public function for visiting attributes to the SmPL AST0 visitor. This is needed to support meta attributes. An AttributeTag constructor is also added due to dependencies, as well as to maintain consistency with the codebase.
Applied.
Quoted 47 lines
Jaskaran Singh (24):
parsing_cocci:visitor_ast0: Add attributefn to SmPL AST0 visitor
parsing_cocci: ast0toast: Reflect attributefn in AST0 visitor
parsing_cocci:check_meta: Reflect attributefn in AST0 visitor
parsing_cocci:function_prototypes: Reflect attributefn in AST0 visitor
parsing_cocci:iso_compile: Reflect attributefn in AST0 visitor
parsing_cocci:iso_pattern: Reflect attributefn in AST0 visitor
parsing_cocci:parse_cocci: Reflect attributefn in AST0 visitor
parsing_cocci:single_statement: Reflect attributefn in AST0 visitor
parsing_cocci:unitary_ast0: Reflect attributefn in AST0 visitor
parsing_cocci:ast0_cocci: Add AttributeTag to SmPL AST0
parsing_cocci:visitor_ast0: Reflect AttributeTag in SmPL AST0
parsing_cocci:iso_pattern: Reflect AttributeTag in SmPL AST0
parsing_cocci:unparse_ast0: Reflect AttributeTag in SmPL AST0
parsing_cocci:context_neg: Reflect AttributeTag in SmPL AST0
parsing_cocci:insert_plus: Reflect AttributeTag in SmPL AST0
parsing_cocci:ast_cocci: Add AttributeTag to the SmPL AST
parsing_cocci:pretty_print_cocci: Reflect AttributeTag in SmPL AST
parsing_c:unparse_cocci: Reflect AttributeTag in SmPL AST
parsing_cocci:visitor_ast: Reflect AttributeTag in SmPL AST
parsing_cocci: ast0toast: Reflect AttributeTag in the SmPL ASTs
ocaml: coccilib: Reflect AttributeTag in the SmPL ASTs
parsing_cocci:context_neg: Reflect attributefn in AST0 visitor
parsing_cocci:insert_plus: Reflect attributefn in AST0 visitor
tools: spgen: Reflect attributefn in AST0 visitorocaml/coccilib.mli | 2 ++ parsing_c/unparse_cocci.ml | 1 + parsing_cocci/ast0_cocci.ml | 2 ++ parsing_cocci/ast0_cocci.mli | 2 ++ parsing_cocci/ast0toast.ml | 5 +++-- parsing_cocci/ast0toast.mli | 1 + parsing_cocci/ast_cocci.ml | 2 ++ parsing_cocci/ast_cocci.mli | 1 + parsing_cocci/check_meta.ml | 4 ++-- parsing_cocci/context_neg.ml | 23 +++++++++++++++++------ parsing_cocci/function_prototypes.ml | 6 +++--- parsing_cocci/insert_plus.ml | 18 ++++++++++++++---- parsing_cocci/iso_compile.ml | 2 +- parsing_cocci/iso_pattern.ml | 17 +++++++++++------ parsing_cocci/parse_cocci.ml | 2 +- parsing_cocci/pretty_print_cocci.ml | 1 + parsing_cocci/single_statement.ml | 2 +- parsing_cocci/unitary_ast0.ml | 2 +- parsing_cocci/unparse_ast0.ml | 1 + parsing_cocci/visitor_ast.ml | 2 ++
Quoted 11 lines
parsing_cocci/visitor_ast0.ml | 24 ++++++++++++++++++++---- parsing_cocci/visitor_ast0.mli | 2 ++ parsing_cocci/visitor_ast0_types.ml | 6 ++++++ parsing_cocci/visitor_ast0_types.mli | 6 ++++++ tools/spgen/source/detect_patch.ml | 3 ++- tools/spgen/source/meta_variable.ml | 3 ++- tools/spgen/source/rule_body.ml | 3 ++- 27 files changed, 109 insertions(+), 34 deletions(-)
_______________________________________________
Cocci mailing list
[email protected]
https://systeme.lip6.fr/mailman/listinfo/cocci