From: Jaskaran Singh <jaskaran.singh@collabora.com>
To: cocci@systeme.lip6.fr
Subject: [Cocci] [PATCH 08/20] parsing_cocci: iso_pattern: Wrap SmPL Attributes
Date: Fri, 3 Jul 2020 23:29:19 +0530 [thread overview]
Message-ID: <20200703175931.1693-9-jaskaran.singh@collabora.com> (raw)
In-Reply-To: <20200703175931.1693-1-jaskaran.singh@collabora.com>
Attributes are wrapped in the SmPL AST. Reflect these changes in
iso_pattern.ml.
Signed-off-by: Jaskaran Singh <jaskaran.singh@collabora.com>
---
parsing_cocci/iso_pattern.ml | 68 ++++++++++++++----------------------
1 file changed, 27 insertions(+), 41 deletions(-)
diff --git a/parsing_cocci/iso_pattern.ml b/parsing_cocci/iso_pattern.ml
index 6cd5f1cb..40fd67e8 100644
--- a/parsing_cocci/iso_pattern.ml
+++ b/parsing_cocci/iso_pattern.ml
@@ -759,14 +759,10 @@ let match_maker checks_needed context_required whencode_allowed =
match_ident fielda fieldb]
| (Ast0.Cast(lp1,tya,attra,rp1,expa),
Ast0.Cast(lp,tyb,attrb,rp,expb)) ->
- if (List.length attra = List.length attrb &&
- List.fold_left2 (fun p a b -> p && mcode_equal a b) true
- attra attrb)
- then
conjunct_many_bindings
[check_mcode lp1 lp; check_mcode rp1 rp;
+ match_attributes attra attrb;
match_typeC tya tyb; match_expr expa expb]
- else return false
| (Ast0.SizeOfExpr(szf1,expa),Ast0.SizeOfExpr(szf,expb)) ->
conjunct_bindings (check_mcode szf1 szf) (match_expr expa expb)
| (Ast0.SizeOfType(szf1,lp1,tya,rp1),
@@ -940,27 +936,23 @@ let match_maker checks_needed context_required whencode_allowed =
match (up,Ast0.unwrap d) with
(Ast0.Init(stga,tya,ida,attra,eq1,inia,sc1),
Ast0.Init(stgb,tyb,idb,attrb,eq,inib,sc)) ->
- if bool_match_option mcode_equal stga stgb &&
- (List.length attra = List.length attrb &&
- List.fold_left2 (fun p a b -> p && mcode_equal a b) true
- attra attrb) (* no metavars *)
+ if bool_match_option mcode_equal stga stgb
then
conjunct_many_bindings
[check_mcode eq1 eq; check_mcode sc1 sc;
match_option check_mcode stga stgb;
match_typeC tya tyb; match_ident ida idb;
+ match_attributes attra attrb;
match_init inia inib]
else return false
| (Ast0.UnInit(stga,tya,ida,attra,sc1),
Ast0.UnInit(stgb,tyb,idb,attrb,sc)) ->
- if bool_match_option mcode_equal stga stgb &&
- (List.length attra = List.length attrb &&
- List.fold_left2 (fun p a b -> p && mcode_equal a b) true
- attra attrb) (* no metavars *)
+ if bool_match_option mcode_equal stga stgb
then
conjunct_many_bindings
[check_mcode sc1 sc; match_option check_mcode stga stgb;
- match_typeC tya tyb; match_ident ida idb]
+ match_typeC tya tyb; match_ident ida idb;
+ match_attributes attra attrb]
else return false
| (Ast0.FunProto(fninfo1,name1,lp1,params1,va1a,rp1,sem1),
Ast0.FunProto(fninfo,name,lp,params,va1b,rp,sem)) ->
@@ -973,17 +965,15 @@ let match_maker checks_needed context_required whencode_allowed =
]
| (Ast0.MacroDecl(stga,namea,lp1,argsa,rp1,attra,sc1),
Ast0.MacroDecl(stgb,nameb,lp,argsb,rp,attrb,sc)) ->
- if bool_match_option mcode_equal stga stgb &&
- (List.length attra = List.length attrb &&
- List.fold_left2 (fun p a b -> p && mcode_equal a b) true
- attra attrb) (* no metavars *)
+ if bool_match_option mcode_equal stga stgb
then
conjunct_many_bindings
[match_ident namea nameb;
check_mcode lp1 lp; check_mcode rp1 rp;
check_mcode sc1 sc;
match_dots match_expr is_elist_matcher do_elist_match
- argsa argsb]
+ argsa argsb;
+ match_attributes attra attrb]
else return false
| (Ast0.MacroDeclInit(stga,namea,lp1,argsa,rp1,eq1,ini1,sc1),
Ast0.MacroDeclInit(stgb,nameb,lp,argsb,rp,eq,ini,sc)) ->
@@ -999,12 +989,10 @@ let match_maker checks_needed context_required whencode_allowed =
match_init ini1 ini]
else return false
| (Ast0.TyDecl(tya,attra,sc1),Ast0.TyDecl(tyb,attrb,sc)) ->
- if (List.length attra = List.length attrb &&
- List.fold_left2 (fun p a b -> p && mcode_equal a b) true
- attra attrb) (* no metavars *)
- then
- conjunct_bindings (check_mcode sc1 sc) (match_typeC tya tyb)
- else return false
+ conjunct_many_bindings
+ [check_mcode sc1 sc;
+ match_typeC tya tyb;
+ match_attributes attra attrb]
| (Ast0.Typedef(stga,tya,ida,sc1),Ast0.Typedef(stgb,tyb,idb,sc)) ->
conjunct_bindings (check_mcode sc1 sc)
(conjunct_bindings (match_typeC tya tyb) (match_typeC ida idb))
@@ -1180,21 +1168,11 @@ let match_maker checks_needed context_required whencode_allowed =
then
match (up,Ast0.unwrap p) with
(Ast0.VoidParam(tya,attra),Ast0.VoidParam(tyb,attrb)) ->
- if (List.length attra = List.length attrb &&
- List.fold_left2 (fun p a b -> p && mcode_equal a b) true
- attra attrb)
- then
- match_typeC tya tyb
- else return false
+ conjunct_bindings (match_typeC tya tyb)
+ (match_attributes attra attrb)
| (Ast0.Param(tya,ida,attra),Ast0.Param(tyb,idb,attrb)) ->
- if (List.length attra = List.length attrb &&
- List.fold_left2 (fun p a b -> p && mcode_equal a b) true
- attra attrb)
- then
- conjunct_bindings (match_typeC tya tyb)
+ conjunct_bindings (match_typeC tya tyb)
(match_option match_ident ida idb)
- else
- return false
| (Ast0.PComma(c1),Ast0.PComma(c)) -> check_mcode c1 c
| (Ast0.Pdots(d1),Ast0.Pdots(d)) -> check_mcode d1 d
| (Ast0.OptParam(parama),Ast0.OptParam(paramb)) ->
@@ -1427,9 +1405,7 @@ let match_maker checks_needed context_required whencode_allowed =
then conjunct_bindings (check_mcode ia ib) (loop (resta,restb))
else return false
| (Ast0.FAttr(ia)::resta,Ast0.FAttr(ib)::restb) ->
- if mcode_equal ia ib
- then conjunct_bindings (check_mcode ia ib) (loop (resta,restb))
- else return false
+ conjunct_bindings (match_attributes [ia] [ib]) (loop (resta,restb))
| (x::resta,((y::_) as restb)) ->
(match compare x y with
-1 -> return false
@@ -1438,6 +1414,16 @@ 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_attributes a1 a2 =
+ match_list match_attribute
+ (function _ -> false) (function _ -> failwith "")
+ a1 a2
+
and match_case_line pattern c =
if not(checks_needed) || not(context_required) || is_context c
then
--
2.21.3
_______________________________________________
Cocci mailing list
Cocci@systeme.lip6.fr
https://systeme.lip6.fr/mailman/listinfo/cocci
next prev parent reply other threads:[~2020-07-03 18:03 UTC|newest]
Thread overview: 25+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-07-03 17:59 [Cocci] [PATCH 00/20] parsing_cocci: Wrap SmPL Attributes Jaskaran Singh
2020-07-03 17:59 ` [Cocci] [PATCH 01/20] parsing_cocci: ast0_cocci: " Jaskaran Singh
2020-07-03 17:59 ` [Cocci] [PATCH 02/20] parsing_cocci: parser: " Jaskaran Singh
2020-07-06 20:03 ` Julia Lawall
2020-07-07 9:51 ` Jaskaran Singh
2020-07-03 17:59 ` [Cocci] [PATCH 03/20] parsing_cocci: visitor_ast0: " Jaskaran Singh
2020-07-03 17:59 ` [Cocci] [PATCH 04/20] parsing_cocci: adjust_pragmas: " Jaskaran Singh
2020-07-03 17:59 ` [Cocci] [PATCH 05/20] parsing_cocci: arity: " Jaskaran Singh
2020-07-06 20:04 ` Julia Lawall
2020-07-03 17:59 ` [Cocci] [PATCH 06/20] parsing_cocci: compute_lines: " Jaskaran Singh
2020-07-03 17:59 ` [Cocci] [PATCH 07/20] parsing_cocci: context_neg: " Jaskaran Singh
2020-07-03 17:59 ` Jaskaran Singh [this message]
2020-07-03 17:59 ` [Cocci] [PATCH 09/20] parsing_cocci: index: " Jaskaran Singh
2020-07-03 17:59 ` [Cocci] [PATCH 10/20] parsing_cocci: unparse_ast0: " Jaskaran Singh
2020-07-03 17:59 ` [Cocci] [PATCH 11/20] parsing_cocci: ast0toast: " Jaskaran Singh
2020-07-03 17:59 ` [Cocci] [PATCH 12/20] parsing_cocci: ast_cocci: " Jaskaran Singh
2020-07-03 17:59 ` [Cocci] [PATCH 13/20] parsing_cocci: visitor_ast: " Jaskaran Singh
2020-07-03 17:59 ` [Cocci] [PATCH 14/20] parsing_cocci: get_constants2: " Jaskaran Singh
2020-07-03 17:59 ` [Cocci] [PATCH 15/20] parsing_cocci: safe_for_multi_decls: " Jaskaran Singh
2020-07-03 17:59 ` [Cocci] [PATCH 16/20] parsing_cocci: unify_ast: " Jaskaran Singh
2020-07-03 17:59 ` [Cocci] [PATCH 17/20] parsing_cocci: pretty_print_cocci: " Jaskaran Singh
2020-07-03 17:59 ` [Cocci] [PATCH 18/20] parsing_c: unparse_cocci: " Jaskaran Singh
2020-07-03 17:59 ` [Cocci] [PATCH 19/20] engine: cocci_vs_c: " Jaskaran Singh
2020-07-03 17:59 ` [Cocci] [PATCH 20/20] ocaml: coccilib: " Jaskaran Singh
2020-07-08 12:53 [Cocci] [PATCH v2 00/20] parsing_cocci: " Jaskaran Singh
2020-07-08 12:53 ` [Cocci] [PATCH 08/20] parsing_cocci: iso_pattern: " 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=20200703175931.1693-9-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).