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 10/17] parsing_cocci: unify_ast: Reflect attributefn in AST visitor
Date: Thu, 16 Jul 2020 18:35:14 +0530	[thread overview]
Message-ID: <20200716130521.7717-11-jaskaran.singh@collabora.com> (raw)
In-Reply-To: <20200716130521.7717-1-jaskaran.singh@collabora.com>

The SmPL AST visitor has a function for attributes. Reflect these
changes in unify_ast.ml. Also add a few fixes w/r/t the usage of
for_all2 for comparing attributes.

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

diff --git a/parsing_cocci/unify_ast.ml b/parsing_cocci/unify_ast.ml
index 90cb70ee..98e2ab1d 100644
--- a/parsing_cocci/unify_ast.ml
+++ b/parsing_cocci/unify_ast.ml
@@ -221,7 +221,8 @@ and unify_expression e1 e2 =
   | (Ast.RecordPtAccess(e1,pt1,fld1),Ast.RecordPtAccess(e2,pt2,fld2)) ->
       unify_expression e1 e2 && unify_ident fld1 fld2
   | (Ast.Cast(lp1,ty1,attr1,rp1,e1),Ast.Cast(lp2,ty2,attr2,rp2,e2)) ->
-      if List.for_all2 unify_attribute attr1 attr2
+      if (List.length attr1 = List.length attr2) &&
+         List.for_all2 unify_attribute attr1 attr2
       then unify_fullType ty1 ty2 && unify_expression e1 e2
       else false
   | (Ast.SizeOfExpr(szf1,e1),Ast.SizeOfExpr(szf2,e2)) ->
@@ -386,6 +387,7 @@ and unify_declaration d1 d2 =
   | (Ast.Init(stg1,ft1,id1,attr1,eq1,i1,s1),
      Ast.Init(stg2,ft2,id2,attr2,eq2,i2,s2)) ->
       if bool_unify_option unify_mcode stg1 stg2 &&
+         (List.length attr1 = List.length attr2) &&
          List.for_all2 unify_attribute attr1 attr2
       then
 	unify_fullType ft1 ft2 &&
@@ -394,6 +396,7 @@ and unify_declaration d1 d2 =
       else false
   | (Ast.UnInit(stg1,ft1,id1,attr1,s1),Ast.UnInit(stg2,ft2,id2,attr2,s2)) ->
       if bool_unify_option unify_mcode stg1 stg2 &&
+         (List.length attr1 = List.length attr2) &&
          List.for_all2 unify_attribute attr1 attr2
       then unify_fullType ft1 ft2 && unify_ident id1 id2
       else false
@@ -414,6 +417,7 @@ and unify_declaration d1 d2 =
   | (Ast.MacroDecl(s1,n1,lp1,args1,rp1,attr1,sem1),
      Ast.MacroDecl(s2,n2,lp2,args2,rp2,attr2,sem2)) ->
        if bool_unify_option unify_mcode s1 s2 &&
+         (List.length attr1 = List.length attr2) &&
          List.for_all2 unify_attribute attr1 attr2
        then
 	 unify_ident n1 n2 &&
@@ -428,7 +432,8 @@ and unify_declaration d1 d2 =
 	 unify_initialiser ini1 ini2
        else false
   | (Ast.TyDecl(ft1,attr1,s1),Ast.TyDecl(ft2,attr2,s2)) ->
-      if List.for_all2 unify_attribute attr1 attr2
+      if (List.length attr1 = List.length attr2) &&
+         List.for_all2 unify_attribute attr1 attr2
       then unify_fullType ft1 ft2
       else false
   | (Ast.Typedef(stg1,ft1,id1,s1),Ast.Typedef(stg2,ft2,id2,s2)) ->
@@ -549,12 +554,13 @@ and unify_designator d1 d2 =
 and unify_parameterTypeDef p1 p2 =
   match (Ast.unwrap p1,Ast.unwrap p2) with
     (Ast.VoidParam(ft1,attr1),Ast.VoidParam(ft2,attr2)) ->
-      if List.for_all2 unify_attribute attr1 attr2
+      if (List.length attr1 = List.length attr2) &&
+         List.for_all2 unify_attribute attr1 attr2
       then unify_fullType ft1 ft2
       else false
   | (Ast.Param(ft1,i1,attr1),Ast.Param(ft2,i2,attr2)) ->
-
-      if List.for_all2 unify_attribute attr1 attr2
+      if (List.length attr1 = List.length attr2) &&
+         List.for_all2 unify_attribute attr1 attr2
       then
         unify_fullType ft1 ft2 &&
         unify_option unify_ident i1 i2
@@ -740,7 +746,7 @@ and subexp f =
       donothing expr
       donothing donothing donothing donothing donothing donothing donothing
       donothing donothing donothing donothing donothing donothing donothing
-      donothing donothing donothing donothing donothing in
+      donothing donothing donothing donothing donothing donothing in
   recursor.V.combiner_rule_elem
 
 and subtype f =
@@ -756,7 +762,7 @@ and subtype f =
       donothing donothing donothing donothing donothing donothing fullType
       donothing donothing donothing donothing donothing donothing
       donothing donothing donothing donothing donothing donothing
-      donothing donothing in
+      donothing donothing donothing in
   recursor.V.combiner_rule_elem
 
 let rec unify_statement s1 s2 =
-- 
2.21.3

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

  parent reply	other threads:[~2020-07-16 13:06 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-07-16 13:05 [Cocci] [PATCH 00/17] parsing_cocci: Add attributefn to the SmPL AST visitor Jaskaran Singh
2020-07-16 13:05 ` [Cocci] [PATCH 01/17] parsing_cocci: visitor_ast: Add attributefn to " Jaskaran Singh
2020-07-16 13:05 ` [Cocci] [PATCH 02/17] parsing_cocci: parse_cocci: Reflect attributefn in " Jaskaran Singh
2020-07-16 13:05 ` [Cocci] [PATCH 03/17] parsing_cocci: cleanup_rules: " Jaskaran Singh
2020-07-16 13:05 ` [Cocci] [PATCH 04/17] parsing_cocci: disjdistr: " Jaskaran Singh
2020-07-16 13:05 ` [Cocci] [PATCH 05/17] parsing_cocci: free_vars: " Jaskaran Singh
2020-07-16 13:05 ` [Cocci] [PATCH 06/17] parsing_cocci: get_constants2: " Jaskaran Singh
2020-07-16 13:05 ` [Cocci] [PATCH 07/17] parsing_cocci: re_constraints: " Jaskaran Singh
2020-07-16 13:05 ` [Cocci] [PATCH 08/17] parsing_cocci: safe_for_multi_decls: " Jaskaran Singh
2020-07-16 13:05 ` [Cocci] [PATCH 09/17] parsing_cocci: stmtlist: " Jaskaran Singh
2020-07-16 13:05 ` Jaskaran Singh [this message]
2020-07-16 13:05 ` [Cocci] [PATCH 11/17] parsing_c: unparse_hrule: " Jaskaran Singh
2020-07-16 13:05 ` [Cocci] [PATCH 12/17] cocci: " Jaskaran Singh
2020-07-16 13:05 ` [Cocci] [PATCH 13/17] engine: asttoctl2: " Jaskaran Singh
2020-07-16 13:05 ` [Cocci] [PATCH 14/17] engine: asttomember: " Jaskaran Singh
2020-07-16 13:05 ` [Cocci] [PATCH 15/17] engine: cocci_vs_c: " Jaskaran Singh
2020-07-16 13:05 ` [Cocci] [PATCH 16/17] engine: transformation_c: " Jaskaran Singh
2020-07-16 13:05 ` [Cocci] [PATCH 17/17] popl09: popltoctl: " Jaskaran Singh
2020-07-18 14:17 ` [Cocci] [PATCH 00/17] parsing_cocci: Add attributefn to the SmPL " 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=20200716130521.7717-11-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).