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 v2 RESEND 07/20] parsing_cocci: context_neg: Wrap SmPL Attributes
Date: Wed,  8 Jul 2020 18:30:22 +0530	[thread overview]
Message-ID: <20200708130035.26687-8-jaskaran.singh@collabora.com> (raw)
In-Reply-To: <20200708130035.26687-1-jaskaran.singh@collabora.com>

Attributes are wrapped in the SmPL AST. Reflect these changes in
context_neg.ml.

Signed-off-by: Jaskaran Singh <jaskaran.singh@collabora.com>
---
 parsing_cocci/context_neg.ml | 31 ++++++++++++++++++++-----------
 1 file changed, 20 insertions(+), 11 deletions(-)

diff --git a/parsing_cocci/context_neg.ml b/parsing_cocci/context_neg.ml
index 6e992245..6a04f49b 100644
--- a/parsing_cocci/context_neg.ml
+++ b/parsing_cocci/context_neg.ml
@@ -400,6 +400,10 @@ let classify is_minus all_marked table code =
 	  disj_cases e starter expr_list r.VT0.combiner_rec_expression ender
       |	_ -> k e) in
 
+  let attribute a =
+    match Ast0.unwrap a with
+      Ast0.Attribute(attr) -> mcode attr in
+
   (* not clear why we have the next cases, since DisjDecl and
   as it only comes from isos *)
   (* actually, DisjDecl now allowed in source struct decls *)
@@ -423,7 +427,7 @@ let classify is_minus all_marked table code =
 	    (bind (r.VT0.combiner_rec_typeC ty)
 	       (bind (r.VT0.combiner_rec_ident id)
                   (bind
-                     (List.fold_right bind (List.map mcode attr)
+                     (List.fold_right bind (List.map attribute attr)
 			option_default)
 		     (bind (mcode eq)
 			(bind (r.VT0.combiner_rec_initialiser ini)
@@ -433,7 +437,7 @@ let classify is_minus all_marked table code =
 	    (bind (r.VT0.combiner_rec_typeC ty)
 	       (bind (r.VT0.combiner_rec_ident id)
                   (bind
-                     (List.fold_right bind (List.map mcode attr)
+                     (List.fold_right bind (List.map attribute attr)
 			option_default)
 		     (mcode sem))))
       |	_ -> k e) in
@@ -470,7 +474,7 @@ let classify is_minus all_marked table code =
 	  (* needed for the same reason as in the Init and UnInit cases *)
 	  bind (r.VT0.combiner_rec_typeC ty)
            (bind (r.VT0.combiner_rec_ident id)
-              (List.fold_right bind (List.map mcode attr) option_default))
+              (List.fold_right bind (List.map attribute attr) option_default))
       |	_ -> k e) in
 
   let typeC r k e =
@@ -585,6 +589,11 @@ let equal_option e1 e2 =
 let dots fn d1 d2 =
   List.length (Ast0.unwrap d1) = List.length (Ast0.unwrap d2)
 
+let equal_attribute a1 a2 =
+  match (Ast0.unwrap a1, Ast0.unwrap a2) with
+    (Ast0.Attribute(attr1),Ast0.Attribute(attr2)) ->
+      equal_mcode attr1 attr2
+
 let equal_ident i1 i2 =
   match (Ast0.unwrap i1,Ast0.unwrap i2) with
     (Ast0.Id(name1),Ast0.Id(name2)) -> equal_mcode name1 name2
@@ -632,7 +641,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.for_all2 equal_mcode ar1 ar2 &&
+      List.for_all2 equal_attribute ar1 ar2 &&
       equal_mcode rp1 rp2
   | (Ast0.SizeOfExpr(szf1,_),Ast0.SizeOfExpr(szf2,_)) ->
       equal_mcode szf1 szf2
@@ -731,7 +740,7 @@ let equal_fninfo x y =
     (Ast0.FStorage(s1),Ast0.FStorage(s2)) -> equal_mcode s1 s2
   | (Ast0.FType(_),Ast0.FType(_)) -> true
   | (Ast0.FInline(i1),Ast0.FInline(i2)) -> equal_mcode i1 i2
-  | (Ast0.FAttr(i1),Ast0.FAttr(i2)) -> equal_mcode i1 i2
+  | (Ast0.FAttr(i1),Ast0.FAttr(i2)) -> equal_attribute i1 i2
   | _ -> false
 
 let equal_declaration d1 d2 =
@@ -740,10 +749,10 @@ 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_mcode attr1 attr2 &&
+      equal_option stg1 stg2 && 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_mcode attr1 attr2 &&
+      equal_option stg1 stg2 && 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)) ->
@@ -758,7 +767,7 @@ 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_mcode attr1 attr2 &&
+      equal_option stg1 stg2 && 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)) ->
@@ -766,7 +775,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.for_all2 equal_mcode attr1 attr2 && equal_mcode sem1 sem2
+       List.for_all2 equal_attribute attr1 attr2 && equal_mcode sem1 sem2
   | (Ast0.OptDecl(_),Ast0.OptDecl(_)) -> true
   | (Ast0.DisjDecl(starter1,_,mids1,ender1),
      Ast0.DisjDecl(starter2,_,mids2,ender2))
@@ -845,9 +854,9 @@ let equal_initialiser i1 i2 =
 let equal_parameterTypeDef p1 p2 =
   match (Ast0.unwrap p1,Ast0.unwrap p2) with
     (Ast0.VoidParam(_,ar1),Ast0.VoidParam(_,ar2)) ->
-      List.for_all2 equal_mcode ar1 ar2
+      List.for_all2 equal_attribute ar1 ar2
   | (Ast0.Param(_,_,ar1),Ast0.Param(_,_,ar2)) ->
-      List.for_all2 equal_mcode ar1 ar2
+      List.for_all2 equal_attribute ar1 ar2
   | (Ast0.MetaParam(name1,_,_),Ast0.MetaParam(name2,_,_))
   | (Ast0.MetaParamList(name1,_,_,_),Ast0.MetaParamList(name2,_,_,_)) ->
       equal_mcode name1 name2
-- 
2.21.3

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

  parent reply	other threads:[~2020-07-08 13:01 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-07-08 13:00 [Cocci] [PATCH v2 RESEND 00/20] parsing_cocci: Wrap SmPL Attributes Jaskaran Singh
2020-07-08 13:00 ` [Cocci] [PATCH v2 RESEND 01/20] parsing_cocci: ast0_cocci: " Jaskaran Singh
2020-07-08 13:00 ` [Cocci] [PATCH v2 RESEND 02/20] parsing_cocci: parser: " Jaskaran Singh
2020-07-08 13:00 ` [Cocci] [PATCH v2 RESEND 03/20] parsing_cocci: visitor_ast0: " Jaskaran Singh
2020-07-08 13:00 ` [Cocci] [PATCH v2 RESEND 04/20] parsing_cocci: adjust_pragmas: " Jaskaran Singh
2020-07-08 13:00 ` [Cocci] [PATCH v2 RESEND 05/20] parsing_cocci: arity: " Jaskaran Singh
2020-07-08 13:00 ` [Cocci] [PATCH v2 RESEND 06/20] parsing_cocci: compute_lines: " Jaskaran Singh
2020-07-08 13:00 ` Jaskaran Singh [this message]
2020-07-08 13:00 ` [Cocci] [PATCH v2 RESEND 08/20] parsing_cocci: iso_pattern: " Jaskaran Singh
2020-07-08 13:00 ` [Cocci] [PATCH v2 RESEND 09/20] parsing_cocci: index: " Jaskaran Singh
2020-07-08 13:00 ` [Cocci] [PATCH v2 RESEND 10/20] parsing_cocci: unparse_ast0: " Jaskaran Singh
2020-07-08 13:00 ` [Cocci] [PATCH v2 RESEND 11/20] parsing_cocci: ast0toast: " Jaskaran Singh
2020-07-08 13:00 ` [Cocci] [PATCH v2 RESEND 12/20] parsing_cocci: ast_cocci: " Jaskaran Singh
2020-07-08 13:00 ` [Cocci] [PATCH v2 RESEND 13/20] parsing_cocci: visitor_ast: " Jaskaran Singh
2020-07-08 13:00 ` [Cocci] [PATCH v2 RESEND 14/20] parsing_cocci: get_constants2: " Jaskaran Singh
2020-07-08 13:00 ` [Cocci] [PATCH v2 RESEND 15/20] parsing_cocci: safe_for_multi_decls: " Jaskaran Singh
2020-07-08 13:00 ` [Cocci] [PATCH v2 RESEND 16/20] parsing_cocci: unify_ast: " Jaskaran Singh
2020-07-08 13:00 ` [Cocci] [PATCH v2 RESEND 17/20] parsing_cocci: pretty_print_cocci: " Jaskaran Singh
2020-07-08 13:00 ` [Cocci] [PATCH v2 RESEND 18/20] parsing_c: unparse_cocci: " Jaskaran Singh
2020-07-08 13:00 ` [Cocci] [PATCH v2 RESEND 19/20] engine: cocci_vs_c: " Jaskaran Singh
2020-07-08 13:00 ` [Cocci] [PATCH v2 RESEND 20/20] ocaml: coccilib: " Jaskaran Singh
2020-07-08 18:22 ` [Cocci] [PATCH v2 RESEND 00/20] parsing_cocci: " 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=20200708130035.26687-8-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).