All of lore.kernel.org
 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 v3 27/32] engine: cocci_vs_c: Match Cast attributes
Date: Fri, 29 May 2020 17:36:57 +0530	[thread overview]
Message-ID: <20200529120703.31145-28-jaskaransingh7654321@gmail.com> (raw)
In-Reply-To: <20200529120703.31145-1-jaskaransingh7654321@gmail.com>

Cast attributes are added to the C and SmPL ASTs. Match these attributes
in cocci_vs_c.ml.

Signed-off-by: Jaskaran Singh <jaskaransingh7654321@gmail.com>
---
 engine/cocci_vs_c.ml | 24 +++++++++++++++++-------
 1 file changed, 17 insertions(+), 7 deletions(-)

diff --git a/engine/cocci_vs_c.ml b/engine/cocci_vs_c.ml
index 66cb104a..54ab21ae 100644
--- a/engine/cocci_vs_c.ml
+++ b/engine/cocci_vs_c.ml
@@ -1121,7 +1121,7 @@ let rec (expression: (A.expression, Ast_c.expression) matcher) =
        * differentiate between different cases *)
       let rec matches_id = function
 	  B.Ident(name) -> true
-	| B.Cast(ty,e) -> matches_id (B.unwrap_expr e)
+	| B.Cast(ty,a,e) -> matches_id (B.unwrap_expr e)
 	| _ -> false in
       let form_ok =
 	match (form,expr) with
@@ -1137,7 +1137,7 @@ let rec (expression: (A.expression, Ast_c.expression) matcher) =
 		    true
                   end
                   else false
-	      | B.Cast(ty,e) -> matches (B.unwrap_expr e)
+	      | B.Cast(ty,a,e) -> matches (B.unwrap_expr e)
 	      |	B.Unary(e,B.UnMinus) -> matches (B.unwrap_expr e)
 	      | B.SizeOfExpr(exp) -> true
 	      | B.SizeOfType(ty) -> true
@@ -1525,16 +1525,26 @@ let rec (expression: (A.expression, Ast_c.expression) matcher) =
    *    by trying | ea, B.Case (typb, eb) -> match_e_e ea eb ?
    *)
 
-  | A.Cast (ia1, typa, ia2, ea), ((B.Cast (typb, eb), typ),ii) ->
+  | A.Cast (ia1, typa, attrsa, ia2, ea),
+    ((B.Cast (typb, attrsb, eb), typ),ii) ->
+
+      let attr_allminus =
+        let mcode_is_not_context = function
+          | (_,_,A.CONTEXT(_,_),_) -> false
+          | _ -> true in
+        check_allminus.Visitor_ast.combiner_fullType typa &&
+        List.for_all mcode_is_not_context attrsa in
+
       let (ib1, ib2) = tuple_of_list2 ii in
       fullType typa typb >>= (fun typa typb ->
+      attribute_list attr_allminus attrsa attrsb >>= (fun attrsa attrsb ->
       expression ea eb >>= (fun ea eb ->
       tokenf ia1 ib1 >>= (fun ia1 ib1 ->
       tokenf ia2 ib2 >>= (fun ia2 ib2 ->
         return (
-          ((A.Cast (ia1, typa, ia2, ea))) +> wa,
-          ((B.Cast (typb, eb),typ),[ib1;ib2])
-        )))))
+          ((A.Cast (ia1, typa, attrsa, ia2, ea))) +> wa,
+          ((B.Cast (typb, attrsb, eb),typ),[ib1;ib2])
+        ))))))
 
   | A.SizeOfExpr (ia1, ea), ((B.SizeOfExpr (eb), typ),ii) ->
       let ib1 = tuple_of_list1 ii in
@@ -1641,7 +1651,7 @@ let rec (expression: (A.expression, Ast_c.expression) matcher) =
 
 
   | _,
-     (((B.Cast (_, _)|B.ParenExpr _|B.SizeOfType _|B.SizeOfExpr _|
+     (((B.Cast (_, _, _)|B.ParenExpr _|B.SizeOfType _|B.SizeOfExpr _|
      B.Constructor (_, _)|
      B.RecordPtAccess (_, _)|
      B.RecordAccess (_, _)|B.ArrayAccess (_, _)|
-- 
2.21.1

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

WARNING: multiple messages have this Message-ID (diff)
From: Jaskaran Singh <jaskaransingh7654321@gmail.com>
To: cocci@systeme.lip6.fr
Cc: julia.lawall@inria.fr, jaskaransingh7654321@gmail.com,
	linux-kernel-mentees@lists.linuxfoundation.org
Subject: [Linux-kernel-mentees] [PATCH v3 27/32] engine: cocci_vs_c: Match Cast attributes
Date: Fri, 29 May 2020 17:36:57 +0530	[thread overview]
Message-ID: <20200529120703.31145-28-jaskaransingh7654321@gmail.com> (raw)
In-Reply-To: <20200529120703.31145-1-jaskaransingh7654321@gmail.com>

Cast attributes are added to the C and SmPL ASTs. Match these attributes
in cocci_vs_c.ml.

Signed-off-by: Jaskaran Singh <jaskaransingh7654321@gmail.com>
---
 engine/cocci_vs_c.ml | 24 +++++++++++++++++-------
 1 file changed, 17 insertions(+), 7 deletions(-)

diff --git a/engine/cocci_vs_c.ml b/engine/cocci_vs_c.ml
index 66cb104a..54ab21ae 100644
--- a/engine/cocci_vs_c.ml
+++ b/engine/cocci_vs_c.ml
@@ -1121,7 +1121,7 @@ let rec (expression: (A.expression, Ast_c.expression) matcher) =
        * differentiate between different cases *)
       let rec matches_id = function
 	  B.Ident(name) -> true
-	| B.Cast(ty,e) -> matches_id (B.unwrap_expr e)
+	| B.Cast(ty,a,e) -> matches_id (B.unwrap_expr e)
 	| _ -> false in
       let form_ok =
 	match (form,expr) with
@@ -1137,7 +1137,7 @@ let rec (expression: (A.expression, Ast_c.expression) matcher) =
 		    true
                   end
                   else false
-	      | B.Cast(ty,e) -> matches (B.unwrap_expr e)
+	      | B.Cast(ty,a,e) -> matches (B.unwrap_expr e)
 	      |	B.Unary(e,B.UnMinus) -> matches (B.unwrap_expr e)
 	      | B.SizeOfExpr(exp) -> true
 	      | B.SizeOfType(ty) -> true
@@ -1525,16 +1525,26 @@ let rec (expression: (A.expression, Ast_c.expression) matcher) =
    *    by trying | ea, B.Case (typb, eb) -> match_e_e ea eb ?
    *)
 
-  | A.Cast (ia1, typa, ia2, ea), ((B.Cast (typb, eb), typ),ii) ->
+  | A.Cast (ia1, typa, attrsa, ia2, ea),
+    ((B.Cast (typb, attrsb, eb), typ),ii) ->
+
+      let attr_allminus =
+        let mcode_is_not_context = function
+          | (_,_,A.CONTEXT(_,_),_) -> false
+          | _ -> true in
+        check_allminus.Visitor_ast.combiner_fullType typa &&
+        List.for_all mcode_is_not_context attrsa in
+
       let (ib1, ib2) = tuple_of_list2 ii in
       fullType typa typb >>= (fun typa typb ->
+      attribute_list attr_allminus attrsa attrsb >>= (fun attrsa attrsb ->
       expression ea eb >>= (fun ea eb ->
       tokenf ia1 ib1 >>= (fun ia1 ib1 ->
       tokenf ia2 ib2 >>= (fun ia2 ib2 ->
         return (
-          ((A.Cast (ia1, typa, ia2, ea))) +> wa,
-          ((B.Cast (typb, eb),typ),[ib1;ib2])
-        )))))
+          ((A.Cast (ia1, typa, attrsa, ia2, ea))) +> wa,
+          ((B.Cast (typb, attrsb, eb),typ),[ib1;ib2])
+        ))))))
 
   | A.SizeOfExpr (ia1, ea), ((B.SizeOfExpr (eb), typ),ii) ->
       let ib1 = tuple_of_list1 ii in
@@ -1641,7 +1651,7 @@ let rec (expression: (A.expression, Ast_c.expression) matcher) =
 
 
   | _,
-     (((B.Cast (_, _)|B.ParenExpr _|B.SizeOfType _|B.SizeOfExpr _|
+     (((B.Cast (_, _, _)|B.ParenExpr _|B.SizeOfType _|B.SizeOfExpr _|
      B.Constructor (_, _)|
      B.RecordPtAccess (_, _)|
      B.RecordAccess (_, _)|B.ArrayAccess (_, _)|
-- 
2.21.1

_______________________________________________
Linux-kernel-mentees mailing list
Linux-kernel-mentees@lists.linuxfoundation.org
https://lists.linuxfoundation.org/mailman/listinfo/linux-kernel-mentees

  parent reply	other threads:[~2020-05-29 12:10 UTC|newest]

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