cocci.inria.fr archive mirror
 help / color / mirror / Atom feed
From: Jaskaran Singh <jaskaransingh7654321@gmail.com>
To: cocci@systeme.lip6.fr
Cc: linux-kernel-mentees@lists.linuxfoundation.org
Subject: [Cocci] [PATCH 07/32] parsing_cocci: iso_pattern: Reflect Cast attributes
Date: Tue, 28 Apr 2020 22:32:03 +0530	[thread overview]
Message-ID: <20200428170228.7002-8-jaskaransingh7654321@gmail.com> (raw)
In-Reply-To: <20200428170228.7002-1-jaskaransingh7654321@gmail.com>

Cast attributes are added to the SmPL AST. Reflect these changes in
iso_pattern.ml.

Signed-off-by: Jaskaran Singh <jaskaransingh7654321@gmail.com>
---
 parsing_cocci/iso_pattern.ml | 12 +++++++++---
 1 file changed, 9 insertions(+), 3 deletions(-)

diff --git a/parsing_cocci/iso_pattern.ml b/parsing_cocci/iso_pattern.ml
index 9df21fb9..b57e293e 100644
--- a/parsing_cocci/iso_pattern.ml
+++ b/parsing_cocci/iso_pattern.ml
@@ -575,7 +575,7 @@ let match_maker checks_needed context_required whencode_allowed =
 			(* all caps is a const *)
 			Str.string_match all_caps nm 0
 		    | _ -> false)
-		| Ast0.Cast(lp,ty,rp,e) -> matches e
+		| Ast0.Cast(lp,ty,attr,rp,e) -> matches e
 		| Ast0.SizeOfExpr(se,exp) -> true
 		| Ast0.SizeOfType(se,lp,ty,rp) -> true
 		| Ast0.MetaExpr(nm,_,_,Ast.CONST,p,_bitfield) ->
@@ -586,7 +586,7 @@ let match_maker checks_needed context_required whencode_allowed =
 	      let rec matches e =
 		match Ast0.unwrap e with
 		  Ast0.Ident(c) -> true
-		| Ast0.Cast(lp,ty,rp,e) -> matches e
+		| Ast0.Cast(lp,ty,attr,rp,e) -> matches e
 		| Ast0.MetaExpr(nm,_,_,Ast.ID,p,_bitfield) ->
 		    (Ast0.lub_pure p pure) = pure
 		| _ -> false in
@@ -757,10 +757,16 @@ let match_maker checks_needed context_required whencode_allowed =
 	       conjunct_many_bindings
 		 [check_mcode opa op; match_expr expa expb;
 		   match_ident fielda fieldb]
-	  | (Ast0.Cast(lp1,tya,rp1,expa),Ast0.Cast(lp,tyb,rp,expb)) ->
+	  | (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_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),
-- 
2.21.1

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

  parent reply	other threads:[~2020-04-28 17:03 UTC|newest]

Thread overview: 43+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-04-28 17:01 [Cocci] [PATCH 00/32] cocci: Add cast attributes to C and SmPL ASTs Jaskaran Singh
2020-04-28 17:01 ` [Cocci] [PATCH 01/32] parsing_c: parser: Pass attribute list from type_name Jaskaran Singh
2020-05-03 19:23   ` Julia Lawall
2020-05-04  9:06     ` Jaskaran Singh
2020-05-04  9:17       ` Julia Lawall
2020-05-04  9:20         ` Jaskaran Singh
2020-05-04 13:18           ` Julia Lawall
2020-04-28 17:01 ` [Cocci] [PATCH 02/32] parsing_cocci: ast0_cocci: Add cast attributes Jaskaran Singh
2020-04-28 17:01 ` [Cocci] [PATCH 03/32] parsing_cocci: parser: Parse " Jaskaran Singh
2020-05-03 19:26   ` Julia Lawall
2020-04-28 17:02 ` [Cocci] [PATCH 04/32] parsing_cocci: visitor_ast0: Visit " Jaskaran Singh
2020-04-28 17:02 ` [Cocci] [PATCH 05/32] parsing_cocci: unparse_ast0: Reflect " Jaskaran Singh
2020-04-28 17:02 ` [Cocci] [PATCH 06/32] parsing_cocci: index: Reflect Cast attributes Jaskaran Singh
2020-04-28 17:02 ` Jaskaran Singh [this message]
2020-04-28 17:02 ` [Cocci] [PATCH 08/32] parsing_cocci: type_infer: " Jaskaran Singh
2020-04-28 17:02 ` [Cocci] [PATCH 09/32] parsing_cocci: arity: " Jaskaran Singh
2020-05-03 19:28   ` Julia Lawall
2020-04-28 17:02 ` [Cocci] [PATCH 10/32] parsing_cocci: check_meta: " Jaskaran Singh
2020-04-28 17:02 ` [Cocci] [PATCH 11/32] parsing_cocci: compute_lines: " Jaskaran Singh
2020-04-28 17:02 ` [Cocci] [PATCH 12/32] parsing_cocci: context_neg: " Jaskaran Singh
2020-04-28 17:02 ` [Cocci] [PATCH 13/32] parsing_cocci: single_statement: " Jaskaran Singh
2020-04-28 17:02 ` [Cocci] [PATCH 14/32] parsing_cocci: ast_cocci: Add cast attributes Jaskaran Singh
2020-04-28 17:02 ` [Cocci] [PATCH 15/32] parsing_cocci: visitor_ast: Visit " Jaskaran Singh
2020-05-03 19:29   ` Julia Lawall
2020-04-28 17:02 ` [Cocci] [PATCH 16/32] parsing_cocci: pretty_print_cocci: Print " Jaskaran Singh
2020-04-28 17:02 ` [Cocci] [PATCH 17/32] parsing_cocci: ast0toast: Reflect Cast attributes Jaskaran Singh
2020-04-28 17:02 ` [Cocci] [PATCH 18/32] parsing_cocci: disjdistr: " Jaskaran Singh
2020-04-28 17:02 ` [Cocci] [PATCH 19/32] parsing_cocci: unify_ast: " Jaskaran Singh
2020-04-28 17:02 ` [Cocci] [PATCH 20/32] parsing_c: ast_c: Add " Jaskaran Singh
2020-05-03 19:31   ` Julia Lawall
2020-04-28 17:02 ` [Cocci] [PATCH 21/32] parsing_c: parser: Parse " Jaskaran Singh
2020-04-28 17:02 ` [Cocci] [PATCH 22/32] parsing_c: pretty_print_c: Reflect " Jaskaran Singh
2020-05-03 19:32   ` Julia Lawall
2020-04-28 17:02 ` [Cocci] [PATCH 23/32] parsing_c: type_annoter_c: " Jaskaran Singh
2020-04-28 17:02 ` [Cocci] [PATCH 24/32] parsing_c: unparse_cocci: " Jaskaran Singh
2020-04-28 17:02 ` [Cocci] [PATCH 25/32] parsing_c: visitor_c: Visit " Jaskaran Singh
2020-04-28 17:02 ` [Cocci] [PATCH 26/32] engine: check_exhaustive_pattern: Reflect " Jaskaran Singh
2020-04-28 17:02 ` [Cocci] [PATCH 27/32] engine: cocci_vs_c: Match " Jaskaran Singh
2020-04-28 17:02 ` [Cocci] [PATCH 28/32] ocaml: coccilib: Reflect " Jaskaran Singh
2020-04-28 17:02 ` [Cocci] [PATCH 29/32] tools: spgen: Reflect Cast attrs Jaskaran Singh
2020-04-28 17:02 ` [Cocci] [PATCH 30/32] tests: Add test case to check cast attribute allminus Jaskaran Singh
2020-04-28 17:02 ` [Cocci] [PATCH 31/32] tests: Add test case to remove cast attributes Jaskaran Singh
2020-04-28 17:02 ` [Cocci] [PATCH 32/32] tests: Add test case to detect " 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=20200428170228.7002-8-jaskaransingh7654321@gmail.com \
    --to=jaskaransingh7654321@gmail.com \
    --cc=cocci@systeme.lip6.fr \
    --cc=linux-kernel-mentees@lists.linuxfoundation.org \
    /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).