From: Jaskaran Singh <jaskaran.singh@collabora.com> To: cocci@systeme.lip6.fr Subject: [Cocci] [PATCH 24/43] parsing_cocci: iso_pattern: Reflect MetaAttribute Date: Sun, 26 Jul 2020 18:21:22 +0530 Message-ID: <20200726125141.17787-25-jaskaran.singh@collabora.com> (raw) In-Reply-To: <20200726125141.17787-1-jaskaran.singh@collabora.com> MetaAttribute is added to the SmPL AST. Reflect these changes in iso_pattern.ml. Signed-off-by: Jaskaran Singh <jaskaran.singh@collabora.com> --- parsing_cocci/iso_pattern.ml | 44 +++++++++++++++++++++++++++++++----- 1 file changed, 38 insertions(+), 6 deletions(-) diff --git a/parsing_cocci/iso_pattern.ml b/parsing_cocci/iso_pattern.ml index 4a9a80b4f..c800665fd 100644 --- a/parsing_cocci/iso_pattern.ml +++ b/parsing_cocci/iso_pattern.ml @@ -475,13 +475,19 @@ let match_maker checks_needed context_required whencode_allowed = Ast0.MetaStmt(name,_,pure) | Ast0.MetaStmtList(name,_,_,pure) -> pure | _ -> Ast0.Impure) in + let attribute r k a = + bind (bind (pure_mcodekind (Ast0.get_mcodekind a)) (k a)) + (match Ast0.unwrap a with + Ast0.MetaAttribute(name,_,pure) -> pure + | _ -> Ast0.Impure) in + V0.flat_combiner bind option_default mcode mcode mcode mcode mcode mcode mcode mcode mcode mcode mcode mcode mcode mcode donothing donothing donothing donothing donothing donothing donothing donothing donothing ident expression assignOp binaryOp typeC init param decl field donothing - stmt donothing donothing donothing donothing donothing in + stmt donothing donothing donothing attribute donothing in let add_pure_list_binding name pure is_pure builder1 builder2 lst = match (checks_needed,pure) with @@ -1417,10 +1423,22 @@ let match_maker checks_needed context_required whencode_allowed = | _ -> return false in loop (patterninfo,cinfo) - and match_attribute a1 a2 = - match (Ast0.unwrap a1,Ast0.unwrap a2) with - (Ast0.Attribute(attr1),Ast0.Attribute(attr2)) -> - check_mcode attr1 attr2 + and match_attribute pattern a = + match Ast0.unwrap pattern with + Ast0.MetaAttribute(name,_,pure) -> + add_pure_binding name pure pure_sp_code.VT0.combiner_rec_attribute + (function a -> Ast0.AttributeTag a) + a + | up -> + if not(checks_needed) || not(context_required) || is_context a + then + match (up,Ast0.unwrap a) with + (Ast0.Attribute(attra),Ast0.Attribute(attrb)) -> + if mcode_equal attra attrb + then check_mcode attra attrb + else return false + | _ -> return false + else return_false (ContextRequired (Ast0.AttributeTag a)) and match_attributes a1 a2 = match_list match_attribute @@ -2169,13 +2187,27 @@ let instantiate bindings mv_bindings model = (List.filter (function (x,v) -> x = (dot_term d)) bindings))) | _ -> e in + let attributefn r k e = + let e = k e in + match Ast0.unwrap e with + Ast0.MetaAttribute(name,cstr,pure) -> + (rebuild_mcode None).VT0.rebuilder_rec_attribute + (match lookup name bindings mv_bindings with + Common.Left(Ast0.AttributeTag(a)) -> a + | Common.Left(_) -> failwith "not possible 1" + | Common.Right(new_mv) -> + Ast0.rewrap e + (Ast0.MetaAttribute + (Ast0.set_mcode_data new_mv name,cstr,pure))) + | _ -> e in + V0.flat_rebuilder mcode mcode mcode mcode mcode mcode mcode mcode mcode mcode mcode mcode mcode mcode (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 donothing + enumdeclfn stmtfn donothing donothing donothing attributefn donothing (* --------------------------------------------------------------------- *) -- 2.21.3 _______________________________________________ Cocci mailing list Cocci@systeme.lip6.fr https://systeme.lip6.fr/mailman/listinfo/cocci
next prev parent reply index Thread overview: 46+ messages / expand[flat|nested] mbox.gz Atom feed top 2020-07-26 12:50 [Cocci] [PATCH 00/43] cocci: Add support for meta attributes to SmPL Jaskaran Singh 2020-07-26 12:50 ` [Cocci] [PATCH 01/43] parsing_cocci: ast0_cocci: Add MetaAttribute & MetaAttributeDecl Jaskaran Singh 2020-07-26 12:51 ` [Cocci] [PATCH 02/43] parsing_cocci: parser: Parse meta attributes and metaattr decls Jaskaran Singh 2020-07-26 12:51 ` [Cocci] [PATCH 03/43] parsing_cocci: parse_cocci: Reflect MetaAttribute & MetaAttributeDecl Jaskaran Singh 2020-07-26 12:51 ` [Cocci] [PATCH 04/43] parsing_cocci: ast_cocci: Add " Jaskaran Singh 2020-07-26 12:51 ` [Cocci] [PATCH 05/43] parsing_cocci: iso_pattern: Reflect " Jaskaran Singh 2020-07-26 12:51 ` [Cocci] [PATCH 06/43] parsing_c: unparse_hrule: " Jaskaran Singh 2020-07-26 12:51 ` [Cocci] [PATCH 07/43] parsing_cocci: pretty_print_cocci: " Jaskaran Singh 2020-07-26 12:51 ` [Cocci] [PATCH 08/43] ocaml: coccilib: " Jaskaran Singh 2020-07-26 12:51 ` [Cocci] [PATCH 09/43] ocaml: yes_prepare_ocamlcocci: " Jaskaran Singh 2020-07-26 12:51 ` [Cocci] [PATCH 10/43] parsing_c: ast_c: Add MetaAttributeVal Jaskaran Singh 2020-07-26 12:51 ` [Cocci] [PATCH 11/43] parsing_c: unparse_hrule: Reflect MetaAttributeVal Jaskaran Singh 2020-07-26 12:51 ` [Cocci] [PATCH 12/43] engine: cocci_vs_c: " Jaskaran Singh 2020-07-26 12:51 ` [Cocci] [PATCH 13/43] engine: pattern_c: " Jaskaran Singh 2020-07-26 12:51 ` [Cocci] [PATCH 14/43] engine: pretty_print_engine: Add MetaAttributeVal Jaskaran Singh 2020-07-26 12:51 ` [Cocci] [PATCH 15/43] ocaml: coccilib: Reflect MetaAttributeVal Jaskaran Singh 2020-07-26 12:51 ` [Cocci] [PATCH 16/43] ocaml: ocamlcocci_aux: " Jaskaran Singh 2020-07-26 12:51 ` [Cocci] [PATCH 17/43] ocaml: run_ocamlcocci: " Jaskaran Singh 2020-07-26 12:51 ` [Cocci] [PATCH 18/43] python: pycocci_aux: " Jaskaran Singh 2020-07-26 12:51 ` [Cocci] [PATCH 19/43] parsing_cocci: visitor_ast0: Reflect MetaAttribute Jaskaran Singh 2020-07-26 12:51 ` [Cocci] [PATCH 20/43] parsing_cocci: check_meta: " Jaskaran Singh 2020-07-26 12:51 ` [Cocci] [PATCH 21/43] parsing_cocci: adjust_pragmas: " Jaskaran Singh 2020-07-26 12:51 ` [Cocci] [PATCH 22/43] parsing_cocci: context_neg: " Jaskaran Singh 2020-07-26 12:51 ` [Cocci] [PATCH 23/43] parsing_cocci: compute_lines: " Jaskaran Singh 2020-07-26 12:51 ` Jaskaran Singh [this message] 2020-07-26 12:51 ` [Cocci] [PATCH 25/43] parsing_cocci: function_prototypes: " Jaskaran Singh 2020-07-26 12:51 ` [Cocci] [PATCH 26/43] parsing_cocci: arity: " Jaskaran Singh 2020-07-26 12:51 ` [Cocci] [PATCH 27/43] parsing_cocci: unitary_ast0: " Jaskaran Singh 2020-07-26 12:51 ` [Cocci] [PATCH 28/43] parsing_cocci: unparse_ast0: " Jaskaran Singh 2020-07-26 12:51 ` [Cocci] [PATCH 29/43] parsing_cocci: ast0toast: " Jaskaran Singh 2020-07-26 12:51 ` [Cocci] [PATCH 30/43] parsing_cocci: visitor_ast: " Jaskaran Singh 2020-07-26 12:51 ` [Cocci] [PATCH 31/43] parsing_cocci: cleanup_rules: " Jaskaran Singh 2020-07-26 12:51 ` [Cocci] [PATCH 32/43] parsing_cocci: free_vars: " Jaskaran Singh 2020-07-26 12:51 ` [Cocci] [PATCH 33/43] parsing_cocci: get_constants: " Jaskaran Singh 2020-07-26 12:51 ` [Cocci] [PATCH 34/43] parsing_cocci: get_constants2: " Jaskaran Singh 2020-07-26 12:51 ` [Cocci] [PATCH 35/43] parsing_cocci: index: " Jaskaran Singh 2020-07-26 12:51 ` [Cocci] [PATCH 36/43] parsing_cocci: pretty_print_cocci: " Jaskaran Singh 2020-07-26 12:51 ` [Cocci] [PATCH 37/43] parsing_cocci: safe_for_multi_decls: " Jaskaran Singh 2020-07-26 12:51 ` [Cocci] [PATCH 38/43] parsing_cocci: unify_ast: " Jaskaran Singh 2020-07-26 12:51 ` [Cocci] [PATCH 39/43] parsing_c: unparse_cocci: " Jaskaran Singh 2020-07-26 12:51 ` [Cocci] [PATCH 40/43] engine: cocci_vs_c: " Jaskaran Singh 2020-07-26 12:51 ` [Cocci] [PATCH 41/43] tools: spgen: " Jaskaran Singh 2020-07-26 12:51 ` [Cocci] [PATCH 42/43] tests: Add test case to match meta attribute Jaskaran Singh 2020-07-26 12:51 ` [Cocci] [PATCH 43/43] tests: Add test case to remove a " Jaskaran Singh 2020-08-01 20:36 ` [Cocci] [PATCH 00/43] cocci: Add support for meta attributes to SmPL Julia Lawall 2020-08-02 12:16 ` 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=20200726125141.17787-25-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
Coccinelle Archive on lore.kernel.org Archives are clonable: git clone --mirror https://lore.kernel.org/cocci/0 cocci/git/0.git # If you have public-inbox 1.1+ installed, you may # initialize and index your mirror using the following commands: public-inbox-init -V2 cocci cocci/ https://lore.kernel.org/cocci \ cocci@systeme.lip6.fr public-inbox-index cocci Example config snippet for mirrors Newsgroup available over NNTP: nntp://nntp.lore.kernel.org/fr.lip6.systeme.cocci AGPL code for this site: git clone https://public-inbox.org/public-inbox.git