From: Jaskaran Singh <jaskaran.singh@collabora.com>
To: cocci@systeme.lip6.fr
Subject: [Cocci] [PATCH 22/24] parsing_cocci: context_neg: Reflect attributefn in AST0 visitor
Date: Thu, 16 Jul 2020 18:30:13 +0530 [thread overview]
Message-ID: <20200716130016.23729-23-jaskaran.singh@collabora.com> (raw)
In-Reply-To: <20200716130016.23729-1-jaskaran.singh@collabora.com>
The 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.
Signed-off-by: Jaskaran Singh <jaskaran.singh@collabora.com>
---
parsing_cocci/ast0_cocci.mli | 1 +
parsing_cocci/context_neg.ml | 20 ++++++++++++++------
2 files changed, 15 insertions(+), 6 deletions(-)
diff --git a/parsing_cocci/ast0_cocci.mli b/parsing_cocci/ast0_cocci.mli
index c4b9260b..6097039f 100644
--- a/parsing_cocci/ast0_cocci.mli
+++ b/parsing_cocci/ast0_cocci.mli
@@ -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
(* --------------------------------------------------------------------- *)
diff --git a/parsing_cocci/context_neg.ml b/parsing_cocci/context_neg.ml
index a0d52e9a..ebb93806 100644
--- a/parsing_cocci/context_neg.ml
+++ b/parsing_cocci/context_neg.ml
@@ -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
--
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-16 13:02 UTC|newest]
Thread overview: 26+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-07-16 12:59 [Cocci] [PATCH 00/24] parsing_cocci: Add attributefn to the SmPL AST0 visitor Jaskaran Singh
2020-07-16 12:59 ` [Cocci] [PATCH 01/24] parsing_cocci: visitor_ast0: Add attributefn to " Jaskaran Singh
2020-07-16 12:59 ` [Cocci] [PATCH 02/24] parsing_cocci: ast0toast: Reflect attributefn in " Jaskaran Singh
2020-07-16 12:59 ` [Cocci] [PATCH 03/24] parsing_cocci: check_meta: " Jaskaran Singh
2020-07-16 12:59 ` [Cocci] [PATCH 04/24] parsing_cocci: function_prototypes: " Jaskaran Singh
2020-07-16 12:59 ` [Cocci] [PATCH 05/24] parsing_cocci: iso_compile: " Jaskaran Singh
2020-07-16 12:59 ` [Cocci] [PATCH 06/24] parsing_cocci: iso_pattern: " Jaskaran Singh
2020-07-16 12:59 ` [Cocci] [PATCH 07/24] parsing_cocci: parse_cocci: " Jaskaran Singh
2020-07-16 12:59 ` [Cocci] [PATCH 08/24] parsing_cocci: single_statement: " Jaskaran Singh
2020-07-16 13:00 ` [Cocci] [PATCH 09/24] parsing_cocci: unitary_ast0: " Jaskaran Singh
2020-07-16 13:00 ` [Cocci] [PATCH 10/24] parsing_cocci: ast0_cocci: Add AttributeTag to SmPL AST0 Jaskaran Singh
2020-07-16 13:00 ` [Cocci] [PATCH 11/24] parsing_cocci: visitor_ast0: Reflect AttributeTag in " Jaskaran Singh
2020-07-16 13:00 ` [Cocci] [PATCH 12/24] parsing_cocci: iso_pattern: " Jaskaran Singh
2020-07-16 13:00 ` [Cocci] [PATCH 13/24] parsing_cocci: unparse_ast0: " Jaskaran Singh
2020-07-16 13:00 ` [Cocci] [PATCH 14/24] parsing_cocci: context_neg: " Jaskaran Singh
2020-07-16 13:00 ` [Cocci] [PATCH 15/24] parsing_cocci: insert_plus: " Jaskaran Singh
2020-07-16 13:00 ` [Cocci] [PATCH 16/24] parsing_cocci: ast_cocci: Add AttributeTag to the SmPL AST Jaskaran Singh
2020-07-16 13:00 ` [Cocci] [PATCH 17/24] parsing_cocci: pretty_print_cocci: Reflect AttributeTag in " Jaskaran Singh
2020-07-16 13:00 ` [Cocci] [PATCH 18/24] parsing_c: unparse_cocci: " Jaskaran Singh
2020-07-16 13:00 ` [Cocci] [PATCH 19/24] parsing_cocci: visitor_ast: " Jaskaran Singh
2020-07-16 13:00 ` [Cocci] [PATCH 20/24] parsing_cocci: ast0toast: Reflect AttributeTag in the SmPL ASTs Jaskaran Singh
2020-07-16 13:00 ` [Cocci] [PATCH 21/24] ocaml: coccilib: " Jaskaran Singh
2020-07-16 13:00 ` Jaskaran Singh [this message]
2020-07-16 13:00 ` [Cocci] [PATCH 23/24] parsing_cocci: insert_plus: Reflect attributefn in AST0 visitor Jaskaran Singh
2020-07-16 13:00 ` [Cocci] [PATCH 24/24] tools: spgen: " Jaskaran Singh
2020-07-18 13:59 ` [Cocci] [PATCH 00/24] 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=20200716130016.23729-23-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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.