linux-kernel-mentees.lists.linuxfoundation.org archive mirror
 help / color / mirror / Atom feed
* [Linux-kernel-mentees] [PATCH 00/27] cocci: Add struct end attributes to SmPL
@ 2020-05-31 15:25 Jaskaran Singh
  2020-05-31 15:25 ` [Linux-kernel-mentees] [PATCH 01/27] parsing_cocci: ast0_cocci: Add struct end attributes Jaskaran Singh
                   ` (26 more replies)
  0 siblings, 27 replies; 28+ messages in thread
From: Jaskaran Singh @ 2020-05-31 15:25 UTC (permalink / raw)
  To: cocci; +Cc: julia.lawall, jaskaransingh7654321, linux-kernel-mentees

This patch series aims to add struct/union end attributes to SmPL, and is a
continuation of the series "cocci: Improve C parsing of attributes"[1].

Two test cases are included:

- detect_struct_endattr: Test case to detect a struct end attribute.

- remove_struct_endattr: Test case to remove a struct end attribute as per the
  given SmPL.

- remove_struct_endattr_allminus: Test case to remove a struct definition and
  check if the end attribute is removed as well.

This series is rebased on [2].


[1]:
[RFC PATCH 00/25] cocci: Improve C parsing of attributes
https://lore.kernel.org/cocci/20200424091801.13871-1-jaskaransingh7654321@gmail.com/

[2]:
[PATCH 00/30] cocci: Add macrodecl attributes to C and SmPL ASTs
https://lore.kernel.org/cocci/20200524171935.2504-1-jaskaransingh7654321@gmail.com/


Jaskaran Singh (27):
      parsing_cocci: ast0_cocci: Add struct end attributes
      parsing_cocci: parser: Reflect struct end attributes
      parsing_cocci: visitor_ast0: Visit struct end attributes
      parsing_cocci: unparse_ast0: Reflect struct end attributes
      parsing_cocci: index: Reflect struct end attributes
      parsing_cocci: iso_pattern: Reflect struct end attributes
      parsing_cocci: type_infer: Reflect struct end attributes
      parsing_cocci: arity: Reflect struct end attributes
      parsing_cocci: check_meta: Reflect struct end attributes
      parsing_cocci: compute_lines: Reflect struct end attributes
      parsing_cocci: context_neg: Reflect struct end attributes
      parsing_cocci: single_statement: Reflect struct end attributes
      parsing_cocci: ast_cocci: Add struct end attributes
      parsing_cocci: visitor_ast: Visit struct end attributes
      parsing_cocci: pretty_print_cocci: Reflect struct end attributes
      parsing_cocci: disjdistr: Reflect struct end attributes
      parsing_cocci: adjust_pragmas: Reflect struct end attributes
      parsing_cocci: unify_ast: Reflect struct end attributes
      parsing_cocci: ast0toast: Reflect struct end attributes
      parsing_c: unparse_cocci: Reflect struct end attributes
      engine: check_exhaustive_pattern: Reflect struct end attributes
      engine: cocci_vs_c: Match struct end attributes
      ocaml: coccilib: Reflect struct end attributes
      tools: spgen: Reflect struct end attributes
      tests: Add test case to remove a struct end attribute
      tests: Add test case to detect a struct end attribute
      tests: Add test case to check struct endattr allminus

 engine/check_exhaustive_pattern.ml         |    4 ++--
 engine/cocci_vs_c.ml                       |   17 ++++++++++-------
 ocaml/coccilib.mli                         |    4 ++--
 parsing_c/unparse_cocci.ml                 |    6 +++++-
 parsing_cocci/adjust_pragmas.ml            |    8 ++++----
 parsing_cocci/arity.ml                     |    8 +++++---
 parsing_cocci/ast0_cocci.ml                |    2 +-
 parsing_cocci/ast0_cocci.mli               |    2 +-
 parsing_cocci/ast0toast.ml                 |    5 +++--
 parsing_cocci/ast_cocci.ml                 |    2 +-
 parsing_cocci/ast_cocci.mli                |    2 +-
 parsing_cocci/check_meta.ml                |    2 +-
 parsing_cocci/compute_lines.ml             |    5 +++--
 parsing_cocci/context_neg.ml               |    3 ++-
 parsing_cocci/disjdistr.ml                 |    4 ++--
 parsing_cocci/index.ml                     |    2 +-
 parsing_cocci/iso_pattern.ml               |    9 +++++++--
 parsing_cocci/parser_cocci_menhir.mly      |    8 ++++----
 parsing_cocci/pretty_print_cocci.ml        |    6 +++++-
 parsing_cocci/single_statement.ml          |    4 ++--
 parsing_cocci/type_infer.ml                |    2 +-
 parsing_cocci/unify_ast.ml                 |    5 ++++-
 parsing_cocci/unparse_ast0.ml              |    6 +++++-
 parsing_cocci/visitor_ast.ml               |   10 ++++++----
 parsing_cocci/visitor_ast0.ml              |    5 +++--
 tests/detect_struct_endattr.c              |   13 +++++++++++++
 tests/detect_struct_endattr.cocci          |    9 +++++++++
 tests/detect_struct_endattr.res            |   12 ++++++++++++
 tests/remove_struct_endattr.c              |    7 +++++++
 tests/remove_struct_endattr.cocci          |    7 +++++++
 tests/remove_struct_endattr.res            |    7 +++++++
 tests/remove_struct_endattr_allminus.c     |   13 +++++++++++++
 tests/remove_struct_endattr_allminus.cocci |    6 ++++++
 tests/remove_struct_endattr_allminus.res   |    1 +
 tools/spgen/source/position_generator.ml   |    4 ++--
 35 files changed, 158 insertions(+), 52 deletions(-)



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

^ permalink raw reply	[flat|nested] 28+ messages in thread

* [Linux-kernel-mentees] [PATCH 01/27] parsing_cocci: ast0_cocci: Add struct end attributes
  2020-05-31 15:25 [Linux-kernel-mentees] [PATCH 00/27] cocci: Add struct end attributes to SmPL Jaskaran Singh
@ 2020-05-31 15:25 ` Jaskaran Singh
  2020-05-31 15:25 ` [Linux-kernel-mentees] [PATCH 02/27] parsing_cocci: parser: Reflect " Jaskaran Singh
                   ` (25 subsequent siblings)
  26 siblings, 0 replies; 28+ messages in thread
From: Jaskaran Singh @ 2020-05-31 15:25 UTC (permalink / raw)
  To: cocci; +Cc: julia.lawall, jaskaransingh7654321, linux-kernel-mentees

Add struct end attributes to AST0 of SmPL. This is a list of attributes
in the TyDecl type of AST0.

Signed-off-by: Jaskaran Singh <jaskaransingh7654321@gmail.com>
---
 parsing_cocci/ast0_cocci.ml  | 2 +-
 parsing_cocci/ast0_cocci.mli | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/parsing_cocci/ast0_cocci.ml b/parsing_cocci/ast0_cocci.ml
index 7714fd16..743fab86 100644
--- a/parsing_cocci/ast0_cocci.ml
+++ b/parsing_cocci/ast0_cocci.ml
@@ -252,7 +252,7 @@ and base_declaration =
         (string mcode (* , *) * string mcode (* ...... *) ) option *
 	string mcode (* ) *) *
 	string mcode (* ; *)
-  | TyDecl of typeC * string mcode (* ; *)
+  | TyDecl of typeC * attr list * string mcode (* ; *)
   | MacroDecl of Ast.storage mcode option *
 	ident (* name *) * string mcode (* ( *) *
         expression dots * string mcode (* ) *) *
diff --git a/parsing_cocci/ast0_cocci.mli b/parsing_cocci/ast0_cocci.mli
index f4b25abc..470c837f 100644
--- a/parsing_cocci/ast0_cocci.mli
+++ b/parsing_cocci/ast0_cocci.mli
@@ -240,7 +240,7 @@ and base_declaration =
 	string mcode (* ( *) * parameter_list *
         (string mcode (* , *) * string mcode (* ...... *) ) option *
 	string mcode (* ) *) * string mcode (* ; *)
-  | TyDecl of typeC * string mcode (* ; *)
+  | TyDecl of typeC * attr list * string mcode (* ; *)
   | MacroDecl of Ast_cocci.storage mcode option *
 	ident (* name *) * string mcode (* ( *) *
         expression dots * string mcode (* ) *) *
-- 
2.21.1

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

^ permalink raw reply related	[flat|nested] 28+ messages in thread

* [Linux-kernel-mentees] [PATCH 02/27] parsing_cocci: parser: Reflect struct end attributes
  2020-05-31 15:25 [Linux-kernel-mentees] [PATCH 00/27] cocci: Add struct end attributes to SmPL Jaskaran Singh
  2020-05-31 15:25 ` [Linux-kernel-mentees] [PATCH 01/27] parsing_cocci: ast0_cocci: Add struct end attributes Jaskaran Singh
@ 2020-05-31 15:25 ` Jaskaran Singh
  2020-05-31 15:25 ` [Linux-kernel-mentees] [PATCH 03/27] parsing_cocci: visitor_ast0: Visit " Jaskaran Singh
                   ` (24 subsequent siblings)
  26 siblings, 0 replies; 28+ messages in thread
From: Jaskaran Singh @ 2020-05-31 15:25 UTC (permalink / raw)
  To: cocci; +Cc: julia.lawall, jaskaransingh7654321, linux-kernel-mentees

Struct end attributes are added to the SmPL AST. Parse these attributes
correctly in the SmPL parser.

Signed-off-by: Jaskaran Singh <jaskaransingh7654321@gmail.com>
---
 parsing_cocci/parser_cocci_menhir.mly | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/parsing_cocci/parser_cocci_menhir.mly b/parsing_cocci/parser_cocci_menhir.mly
index 94e0b84a..63cb8b5e 100644
--- a/parsing_cocci/parser_cocci_menhir.mly
+++ b/parsing_cocci/parser_cocci_menhir.mly
@@ -1678,8 +1678,8 @@ the language is ambiguous: what is foo * bar; */
 /* The AST DisjDecl cannot be generated because it would be ambiguous with
 a disjunction on a statement with a declaration in each branch */
 decl_var:
-    t=ctype pv=TPtVirg
-      { [Ast0.wrap(Ast0.TyDecl(t,P.clt2mcode ";" pv))] }
+    t=ctype ar=attr_list pv=TPtVirg
+      { [Ast0.wrap(Ast0.TyDecl(t,ar,P.clt2mcode ";" pv))] }
   | TMetaDecl { [P.meta_decl $1] }
   | s=ioption(storage) t=ctype
       d=comma_list(direct_declarator(disj_ident)) pv=TPtVirg
@@ -1731,8 +1731,8 @@ decl_var:
 	  d }
 
 one_decl_var:
-    t=ctype pv=TPtVirg
-      { Ast0.wrap(Ast0.TyDecl(t,P.clt2mcode ";" pv)) }
+    t=ctype ar=attr_list pv=TPtVirg
+      { Ast0.wrap(Ast0.TyDecl(t,ar,P.clt2mcode ";" pv)) }
   | TMetaDecl { P.meta_decl $1 }
   | s=ioption(storage) t=ctype d=direct_declarator(disj_ident)
       a=attr_list pv=TPtVirg
-- 
2.21.1

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

^ permalink raw reply related	[flat|nested] 28+ messages in thread

* [Linux-kernel-mentees] [PATCH 03/27] parsing_cocci: visitor_ast0: Visit struct end attributes
  2020-05-31 15:25 [Linux-kernel-mentees] [PATCH 00/27] cocci: Add struct end attributes to SmPL Jaskaran Singh
  2020-05-31 15:25 ` [Linux-kernel-mentees] [PATCH 01/27] parsing_cocci: ast0_cocci: Add struct end attributes Jaskaran Singh
  2020-05-31 15:25 ` [Linux-kernel-mentees] [PATCH 02/27] parsing_cocci: parser: Reflect " Jaskaran Singh
@ 2020-05-31 15:25 ` Jaskaran Singh
  2020-05-31 15:25 ` [Linux-kernel-mentees] [PATCH 04/27] parsing_cocci: unparse_ast0: Reflect " Jaskaran Singh
                   ` (23 subsequent siblings)
  26 siblings, 0 replies; 28+ messages in thread
From: Jaskaran Singh @ 2020-05-31 15:25 UTC (permalink / raw)
  To: cocci; +Cc: julia.lawall, jaskaransingh7654321, linux-kernel-mentees

Struct end attributes are added to AST0 of SmPL. Visit these attributes
in the AST0 visitor.

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

diff --git a/parsing_cocci/visitor_ast0.ml b/parsing_cocci/visitor_ast0.ml
index 63241ffd..87b2b3f5 100644
--- a/parsing_cocci/visitor_ast0.ml
+++ b/parsing_cocci/visitor_ast0.ml
@@ -660,10 +660,11 @@ let visitor mode bind option_default
 	    let (sem_n,sem) = string_mcode sem in
 	    (multibind [stg_n;name_n;lp_n;args_n;rp_n;eq_n;ini_n;sem_n],
 	     Ast0.MacroDeclInit(stg,name,lp,args,rp,eq,ini,sem))
-	| Ast0.TyDecl(ty,sem) ->
+	| Ast0.TyDecl(ty,attr,sem) ->
 	    let (ty_n,ty) = typeC ty in
+	    let (attr_n,attr) = map_split_bind string_mcode attr in
 	    let (sem_n,sem) = string_mcode sem in
-	    (bind ty_n sem_n, Ast0.TyDecl(ty,sem))
+            (multibind [ty_n; attr_n; sem_n], Ast0.TyDecl(ty,attr,sem))
 	| Ast0.Typedef(stg,ty,id,sem) ->
 	    let (stg_n,stg) = string_mcode stg in
 	    let ((ty_id_n,ty),id) = named_type_typedef ty id in
-- 
2.21.1

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

^ permalink raw reply related	[flat|nested] 28+ messages in thread

* [Linux-kernel-mentees] [PATCH 04/27] parsing_cocci: unparse_ast0: Reflect struct end attributes
  2020-05-31 15:25 [Linux-kernel-mentees] [PATCH 00/27] cocci: Add struct end attributes to SmPL Jaskaran Singh
                   ` (2 preceding siblings ...)
  2020-05-31 15:25 ` [Linux-kernel-mentees] [PATCH 03/27] parsing_cocci: visitor_ast0: Visit " Jaskaran Singh
@ 2020-05-31 15:25 ` Jaskaran Singh
  2020-05-31 15:25 ` [Linux-kernel-mentees] [PATCH 05/27] parsing_cocci: index: " Jaskaran Singh
                   ` (22 subsequent siblings)
  26 siblings, 0 replies; 28+ messages in thread
From: Jaskaran Singh @ 2020-05-31 15:25 UTC (permalink / raw)
  To: cocci; +Cc: julia.lawall, jaskaransingh7654321, linux-kernel-mentees

Struct end attributes are added to the SmPL AST. Reflect these changes
in unparse_ast0.ml.

Signed-off-by: Jaskaran Singh <jaskaransingh7654321@gmail.com>
---
 parsing_cocci/unparse_ast0.ml | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/parsing_cocci/unparse_ast0.ml b/parsing_cocci/unparse_ast0.ml
index ebe8084a..81bbb71a 100644
--- a/parsing_cocci/unparse_ast0.ml
+++ b/parsing_cocci/unparse_ast0.ml
@@ -440,7 +440,11 @@ and declaration d =
           print_string " ";
           mcode print_string eq; print_string " "; initialiser ini;
 	  mcode print_string sem
-      | Ast0.TyDecl(ty,sem) -> typeC ty; mcode print_string sem
+      | Ast0.TyDecl(ty,attr,sem) ->
+          typeC ty;
+          (if not (attr = []) then print_string " ");
+          print_between (fun _ -> print_string " ") (mcode print_string) attr;
+          mcode print_string sem
       | Ast0.Typedef(stg,ty,id,sem) ->
 	  mcode print_string stg; typeC ty; typeC id;
 	  mcode print_string sem
-- 
2.21.1

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

^ permalink raw reply related	[flat|nested] 28+ messages in thread

* [Linux-kernel-mentees] [PATCH 05/27] parsing_cocci: index: Reflect struct end attributes
  2020-05-31 15:25 [Linux-kernel-mentees] [PATCH 00/27] cocci: Add struct end attributes to SmPL Jaskaran Singh
                   ` (3 preceding siblings ...)
  2020-05-31 15:25 ` [Linux-kernel-mentees] [PATCH 04/27] parsing_cocci: unparse_ast0: Reflect " Jaskaran Singh
@ 2020-05-31 15:25 ` Jaskaran Singh
  2020-05-31 15:26 ` [Linux-kernel-mentees] [PATCH 06/27] parsing_cocci: iso_pattern: " Jaskaran Singh
                   ` (21 subsequent siblings)
  26 siblings, 0 replies; 28+ messages in thread
From: Jaskaran Singh @ 2020-05-31 15:25 UTC (permalink / raw)
  To: cocci; +Cc: julia.lawall, jaskaransingh7654321, linux-kernel-mentees

Struct end attributes are added to the SmPL AST. Reflect these changes
in index.ml.

Signed-off-by: Jaskaran Singh <jaskaransingh7654321@gmail.com>
---
 parsing_cocci/index.ml | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/parsing_cocci/index.ml b/parsing_cocci/index.ml
index fc04bd6f..8df048dd 100644
--- a/parsing_cocci/index.ml
+++ b/parsing_cocci/index.ml
@@ -119,7 +119,7 @@ let declaration d =
   | Ast0.FunProto(fi,name,lp1,params,va,rp1,sem) -> [132]
   | Ast0.MacroDecl(stg,name,lp,args,rp,attr,sem) -> [137]
   | Ast0.MacroDeclInit(stg,name,lp,args,rp,eq,ini,sem) -> [157]
-  | Ast0.TyDecl(ty,sem) -> [116]
+  | Ast0.TyDecl(ty,attr,sem) -> [116]
   | Ast0.Typedef(stg,ty,id,sem) -> [143]
   | Ast0.DisjDecl(_,decls,_,_) -> [97] (* added after *)
   | Ast0.ConjDecl(_,decls,_,_) -> [88] (* added after *)
-- 
2.21.1

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

^ permalink raw reply related	[flat|nested] 28+ messages in thread

* [Linux-kernel-mentees] [PATCH 06/27] parsing_cocci: iso_pattern: Reflect struct end attributes
  2020-05-31 15:25 [Linux-kernel-mentees] [PATCH 00/27] cocci: Add struct end attributes to SmPL Jaskaran Singh
                   ` (4 preceding siblings ...)
  2020-05-31 15:25 ` [Linux-kernel-mentees] [PATCH 05/27] parsing_cocci: index: " Jaskaran Singh
@ 2020-05-31 15:26 ` Jaskaran Singh
  2020-05-31 15:26 ` [Linux-kernel-mentees] [PATCH 07/27] parsing_cocci: type_infer: " Jaskaran Singh
                   ` (20 subsequent siblings)
  26 siblings, 0 replies; 28+ messages in thread
From: Jaskaran Singh @ 2020-05-31 15:26 UTC (permalink / raw)
  To: cocci; +Cc: julia.lawall, jaskaransingh7654321, linux-kernel-mentees

Struct end 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 | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)

diff --git a/parsing_cocci/iso_pattern.ml b/parsing_cocci/iso_pattern.ml
index 5b4c5f61..6cd5f1cb 100644
--- a/parsing_cocci/iso_pattern.ml
+++ b/parsing_cocci/iso_pattern.ml
@@ -998,8 +998,13 @@ let match_maker checks_needed context_required whencode_allowed =
 		       argsa argsb;
 		     match_init ini1 ini]
 	       else return false
-	  | (Ast0.TyDecl(tya,sc1),Ast0.TyDecl(tyb,sc)) ->
-	      conjunct_bindings (check_mcode sc1 sc) (match_typeC tya tyb)
+	  | (Ast0.TyDecl(tya,attra,sc1),Ast0.TyDecl(tyb,attrb,sc)) ->
+	      if (List.length attra = List.length attrb &&
+                  List.fold_left2 (fun p a b -> p && mcode_equal a b) true
+                    attra attrb) (* no metavars *)
+              then
+	        conjunct_bindings (check_mcode sc1 sc) (match_typeC tya tyb)
+              else return false
 	  | (Ast0.Typedef(stga,tya,ida,sc1),Ast0.Typedef(stgb,tyb,idb,sc)) ->
 	      conjunct_bindings (check_mcode sc1 sc)
 		(conjunct_bindings (match_typeC tya tyb) (match_typeC ida idb))
-- 
2.21.1

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

^ permalink raw reply related	[flat|nested] 28+ messages in thread

* [Linux-kernel-mentees] [PATCH 07/27] parsing_cocci: type_infer: Reflect struct end attributes
  2020-05-31 15:25 [Linux-kernel-mentees] [PATCH 00/27] cocci: Add struct end attributes to SmPL Jaskaran Singh
                   ` (5 preceding siblings ...)
  2020-05-31 15:26 ` [Linux-kernel-mentees] [PATCH 06/27] parsing_cocci: iso_pattern: " Jaskaran Singh
@ 2020-05-31 15:26 ` Jaskaran Singh
  2020-05-31 15:26 ` [Linux-kernel-mentees] [PATCH 08/27] parsing_cocci: arity: " Jaskaran Singh
                   ` (19 subsequent siblings)
  26 siblings, 0 replies; 28+ messages in thread
From: Jaskaran Singh @ 2020-05-31 15:26 UTC (permalink / raw)
  To: cocci; +Cc: julia.lawall, jaskaransingh7654321, linux-kernel-mentees

Struct end attributes are added to the SmPL AST. Reflect these changes
in type_infer.ml.

Signed-off-by: Jaskaran Singh <jaskaransingh7654321@gmail.com>
---
 parsing_cocci/type_infer.ml | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/parsing_cocci/type_infer.ml b/parsing_cocci/type_infer.ml
index b5bc3a38..02e300a2 100644
--- a/parsing_cocci/type_infer.ml
+++ b/parsing_cocci/type_infer.ml
@@ -384,7 +384,7 @@ let rec propagate_types env =
     | Ast0.MacroDeclInit(_,_,_,_,_,_,exp,_) ->
         let _ = (propagate_types env).VT0.combiner_rec_initialiser exp in
 	[]
-    | Ast0.TyDecl(ty,_) -> []
+    | Ast0.TyDecl(ty,_,_) -> []
               (* pad: should handle typedef one day and add a binding *)
     | Ast0.Typedef((a,_,_,_,_,_),b,c,(d,_,_,_,_,_)) ->
 	[]
-- 
2.21.1

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

^ permalink raw reply related	[flat|nested] 28+ messages in thread

* [Linux-kernel-mentees] [PATCH 08/27] parsing_cocci: arity: Reflect struct end attributes
  2020-05-31 15:25 [Linux-kernel-mentees] [PATCH 00/27] cocci: Add struct end attributes to SmPL Jaskaran Singh
                   ` (6 preceding siblings ...)
  2020-05-31 15:26 ` [Linux-kernel-mentees] [PATCH 07/27] parsing_cocci: type_infer: " Jaskaran Singh
@ 2020-05-31 15:26 ` Jaskaran Singh
  2020-05-31 15:26 ` [Linux-kernel-mentees] [PATCH 09/27] parsing_cocci: check_meta: " Jaskaran Singh
                   ` (18 subsequent siblings)
  26 siblings, 0 replies; 28+ messages in thread
From: Jaskaran Singh @ 2020-05-31 15:26 UTC (permalink / raw)
  To: cocci; +Cc: julia.lawall, jaskaransingh7654321, linux-kernel-mentees

Struct end attributes are added to the SmPL AST. Reflect these changes
in arity.ml.

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

diff --git a/parsing_cocci/arity.ml b/parsing_cocci/arity.ml
index cbfb84e3..6f90616e 100644
--- a/parsing_cocci/arity.ml
+++ b/parsing_cocci/arity.ml
@@ -624,12 +624,14 @@ and declaration tgt decl =
       let sem = mcode sem in
       make_decl decl tgt arity
 	(Ast0.MacroDeclInit(stg,name,lp,args,rp,eq,ini,sem))
-  | Ast0.TyDecl(ty,sem) ->
+  | Ast0.TyDecl(ty,attr,sem) ->
       let arity =
-	all_same true tgt (mcode2line sem) [mcode2arity sem] in
+        all_same true tgt
+          (mcode2line sem) (List.map mcode2arity (attr @ [sem])) in
       let ty = typeC arity ty in
+      let attr = List.map mcode attr in
       let sem = mcode sem in
-      make_decl decl tgt arity (Ast0.TyDecl(ty,sem))
+      make_decl decl tgt arity (Ast0.TyDecl(ty,attr,sem))
   | Ast0.Typedef(stg,ty,id,sem) ->
       let arity =
 	all_same true tgt (mcode2line sem)
-- 
2.21.1

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

^ permalink raw reply related	[flat|nested] 28+ messages in thread

* [Linux-kernel-mentees] [PATCH 09/27] parsing_cocci: check_meta: Reflect struct end attributes
  2020-05-31 15:25 [Linux-kernel-mentees] [PATCH 00/27] cocci: Add struct end attributes to SmPL Jaskaran Singh
                   ` (7 preceding siblings ...)
  2020-05-31 15:26 ` [Linux-kernel-mentees] [PATCH 08/27] parsing_cocci: arity: " Jaskaran Singh
@ 2020-05-31 15:26 ` Jaskaran Singh
  2020-05-31 15:26 ` [Linux-kernel-mentees] [PATCH 10/27] parsing_cocci: compute_lines: " Jaskaran Singh
                   ` (17 subsequent siblings)
  26 siblings, 0 replies; 28+ messages in thread
From: Jaskaran Singh @ 2020-05-31 15:26 UTC (permalink / raw)
  To: cocci; +Cc: julia.lawall, jaskaransingh7654321, linux-kernel-mentees

Struct end attributes are added to the SmPL AST. Reflect these changes
in check_meta.ml.

Signed-off-by: Jaskaran Singh <jaskaransingh7654321@gmail.com>
---
 parsing_cocci/check_meta.ml | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/parsing_cocci/check_meta.ml b/parsing_cocci/check_meta.ml
index 7035766c..f651ff8b 100644
--- a/parsing_cocci/check_meta.ml
+++ b/parsing_cocci/check_meta.ml
@@ -292,7 +292,7 @@ and declaration context old_metas table minus d =
       (match Ast0.unwrap ini with
 	Ast0.InitExpr exp -> expression ID old_metas table minus exp
       |	_ -> initialiser old_metas table minus ini)
-  | Ast0.TyDecl(ty,sem) -> typeC old_metas table minus ty
+  | Ast0.TyDecl(ty,attr,sem) -> typeC old_metas table minus ty
   | Ast0.Typedef(stg,ty,id,sem) ->
       typeC old_metas table minus ty;
       typeC old_metas table minus id
-- 
2.21.1

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

^ permalink raw reply related	[flat|nested] 28+ messages in thread

* [Linux-kernel-mentees] [PATCH 10/27] parsing_cocci: compute_lines: Reflect struct end attributes
  2020-05-31 15:25 [Linux-kernel-mentees] [PATCH 00/27] cocci: Add struct end attributes to SmPL Jaskaran Singh
                   ` (8 preceding siblings ...)
  2020-05-31 15:26 ` [Linux-kernel-mentees] [PATCH 09/27] parsing_cocci: check_meta: " Jaskaran Singh
@ 2020-05-31 15:26 ` Jaskaran Singh
  2020-05-31 15:26 ` [Linux-kernel-mentees] [PATCH 11/27] parsing_cocci: context_neg: " Jaskaran Singh
                   ` (16 subsequent siblings)
  26 siblings, 0 replies; 28+ messages in thread
From: Jaskaran Singh @ 2020-05-31 15:26 UTC (permalink / raw)
  To: cocci; +Cc: julia.lawall, jaskaransingh7654321, linux-kernel-mentees

Struct end attributes are added to the SmPL AST. Reflect these changes
in compute_lines.ml.

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

diff --git a/parsing_cocci/compute_lines.ml b/parsing_cocci/compute_lines.ml
index 682e41a4..4f273307 100644
--- a/parsing_cocci/compute_lines.ml
+++ b/parsing_cocci/compute_lines.ml
@@ -747,10 +747,11 @@ and declaration d =
 	  let stg = Some (normal_mcode x) in
 	  mkres d (Ast0.MacroDeclInit(stg,name,lp,args,rp,eq,ini,sem))
 	    (promote_mcode x) (promote_mcode sem))
-  | Ast0.TyDecl(ty,sem) ->
+  | Ast0.TyDecl(ty,attr,sem) ->
       let ty = typeC ty in
+      let attr = List.map normal_mcode attr in
       let sem = normal_mcode sem in
-      mkres d (Ast0.TyDecl(ty,sem)) ty (promote_mcode sem)
+      mkres d (Ast0.TyDecl(ty,attr,sem)) ty (promote_mcode sem)
   | Ast0.Typedef(stg,ty,id,sem) ->
       let stg = normal_mcode stg in
       let ty = typeC ty in
-- 
2.21.1

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

^ permalink raw reply related	[flat|nested] 28+ messages in thread

* [Linux-kernel-mentees] [PATCH 11/27] parsing_cocci: context_neg: Reflect struct end attributes
  2020-05-31 15:25 [Linux-kernel-mentees] [PATCH 00/27] cocci: Add struct end attributes to SmPL Jaskaran Singh
                   ` (9 preceding siblings ...)
  2020-05-31 15:26 ` [Linux-kernel-mentees] [PATCH 10/27] parsing_cocci: compute_lines: " Jaskaran Singh
@ 2020-05-31 15:26 ` Jaskaran Singh
  2020-05-31 15:26 ` [Linux-kernel-mentees] [PATCH 12/27] parsing_cocci: single_statement: " Jaskaran Singh
                   ` (15 subsequent siblings)
  26 siblings, 0 replies; 28+ messages in thread
From: Jaskaran Singh @ 2020-05-31 15:26 UTC (permalink / raw)
  To: cocci; +Cc: julia.lawall, jaskaransingh7654321, linux-kernel-mentees

Struct end attributes are added to the SmPL AST. Reflect these changes
in context_neg.ml.

Signed-off-by: Jaskaran Singh <jaskaransingh7654321@gmail.com>
---
 parsing_cocci/context_neg.ml | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/parsing_cocci/context_neg.ml b/parsing_cocci/context_neg.ml
index 5354bb3e..41bc621f 100644
--- a/parsing_cocci/context_neg.ml
+++ b/parsing_cocci/context_neg.ml
@@ -763,7 +763,8 @@ let equal_declaration d1 d2 =
        equal_option stg1 stg2 &&
        equal_mcode lp1 lp2 && equal_mcode rp1 rp2 && equal_mcode eq1 eq2
 	 && equal_mcode sem1 sem2
-  | (Ast0.TyDecl(_,sem1),Ast0.TyDecl(_,sem2)) -> equal_mcode sem1 sem2
+  | (Ast0.TyDecl(_,attr1,sem1),Ast0.TyDecl(_,attr2,sem2)) ->
+       List.for_all2 equal_mcode attr1 attr2 && equal_mcode sem1 sem2
   | (Ast0.OptDecl(_),Ast0.OptDecl(_)) -> true
   | (Ast0.DisjDecl(starter1,_,mids1,ender1),
      Ast0.DisjDecl(starter2,_,mids2,ender2))
-- 
2.21.1

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

^ permalink raw reply related	[flat|nested] 28+ messages in thread

* [Linux-kernel-mentees] [PATCH 12/27] parsing_cocci: single_statement: Reflect struct end attributes
  2020-05-31 15:25 [Linux-kernel-mentees] [PATCH 00/27] cocci: Add struct end attributes to SmPL Jaskaran Singh
                   ` (10 preceding siblings ...)
  2020-05-31 15:26 ` [Linux-kernel-mentees] [PATCH 11/27] parsing_cocci: context_neg: " Jaskaran Singh
@ 2020-05-31 15:26 ` Jaskaran Singh
  2020-05-31 15:26 ` [Linux-kernel-mentees] [PATCH 13/27] parsing_cocci: ast_cocci: Add " Jaskaran Singh
                   ` (14 subsequent siblings)
  26 siblings, 0 replies; 28+ messages in thread
From: Jaskaran Singh @ 2020-05-31 15:26 UTC (permalink / raw)
  To: cocci; +Cc: julia.lawall, jaskaransingh7654321, linux-kernel-mentees

Struct end attributes are added to the SmPL AST. Reflect these changes
in single_statement.ml.

Signed-off-by: Jaskaran Singh <jaskaransingh7654321@gmail.com>
---
 parsing_cocci/single_statement.ml | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/parsing_cocci/single_statement.ml b/parsing_cocci/single_statement.ml
index cd1b2c05..df50df6a 100644
--- a/parsing_cocci/single_statement.ml
+++ b/parsing_cocci/single_statement.ml
@@ -205,7 +205,7 @@ and left_declaration d =
   | Ast0.MacroDeclInit(Some stg,name,lp,args,rp,eq,ini,sem) ->
       modif_before_mcode stg
   | Ast0.MacroDeclInit(None,name,lp,args,rp,eq,ini,sem) -> left_ident name
-  | Ast0.TyDecl(ty,sem) -> left_typeC ty
+  | Ast0.TyDecl(ty,attr,sem) -> left_typeC ty
   | Ast0.Typedef(stg,ty,id,sem) -> modif_before_mcode stg
   | Ast0.DisjDecl(_,decls,_,_) -> List.exists left_declaration decls
   | Ast0.ConjDecl(_,decls,_,_) -> List.exists left_declaration decls
@@ -221,7 +221,7 @@ and right_declaration d =
   | Ast0.FunProto(fninfo,name,lp1,params,va,rp1,sem) -> modif_after_mcode sem
   | Ast0.MacroDecl(_,name,lp,args,rp,attr,sem) -> modif_after_mcode sem
   | Ast0.MacroDeclInit(_,name,lp,args,rp,eq,ini,sem) -> modif_after_mcode sem
-  | Ast0.TyDecl(ty,sem) -> modif_after_mcode sem
+  | Ast0.TyDecl(ty,attr,sem) -> modif_after_mcode sem
   | Ast0.Typedef(stg,ty,id,sem) -> modif_after_mcode sem
   | Ast0.DisjDecl(_,decls,_,_) -> List.exists right_declaration decls
   | Ast0.ConjDecl(_,decls,_,_) -> List.exists right_declaration decls
-- 
2.21.1

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

^ permalink raw reply related	[flat|nested] 28+ messages in thread

* [Linux-kernel-mentees] [PATCH 13/27] parsing_cocci: ast_cocci: Add struct end attributes
  2020-05-31 15:25 [Linux-kernel-mentees] [PATCH 00/27] cocci: Add struct end attributes to SmPL Jaskaran Singh
                   ` (11 preceding siblings ...)
  2020-05-31 15:26 ` [Linux-kernel-mentees] [PATCH 12/27] parsing_cocci: single_statement: " Jaskaran Singh
@ 2020-05-31 15:26 ` Jaskaran Singh
  2020-05-31 15:26 ` [Linux-kernel-mentees] [PATCH 14/27] parsing_cocci: visitor_ast: Visit " Jaskaran Singh
                   ` (13 subsequent siblings)
  26 siblings, 0 replies; 28+ messages in thread
From: Jaskaran Singh @ 2020-05-31 15:26 UTC (permalink / raw)
  To: cocci; +Cc: julia.lawall, jaskaransingh7654321, linux-kernel-mentees

Add struct end attributes to the SmPL AST. This is a list of attributes
in the TyDecl type of the SmPL AST.

Signed-off-by: Jaskaran Singh <jaskaransingh7654321@gmail.com>
---
 parsing_cocci/ast_cocci.ml  | 2 +-
 parsing_cocci/ast_cocci.mli | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/parsing_cocci/ast_cocci.ml b/parsing_cocci/ast_cocci.ml
index b4b74a67..403756c4 100644
--- a/parsing_cocci/ast_cocci.ml
+++ b/parsing_cocci/ast_cocci.ml
@@ -396,7 +396,7 @@ and base_declaration =
 	string mcode (* ( *) * parameter_list *
 	(string mcode (* , *) * string mcode (* ...... *) ) option *
 	string mcode (* ) *) * string mcode (* ; *)
-  | TyDecl of fullType * string mcode (* ; *)
+  | TyDecl of fullType * attr list * string mcode (* ; *)
   | MacroDecl of storage mcode option *
 	ident (* name *) * string mcode (* ( *) *
         expression dots * string mcode (* ) *) *
diff --git a/parsing_cocci/ast_cocci.mli b/parsing_cocci/ast_cocci.mli
index 77dba10f..873e1d31 100644
--- a/parsing_cocci/ast_cocci.mli
+++ b/parsing_cocci/ast_cocci.mli
@@ -378,7 +378,7 @@ and base_declaration =
 	string mcode (* ( *) * parameter_list *
 	(string mcode (* , *) * string mcode (* ...... *) ) option *
 	string mcode (* ) *) * string mcode (* ; *)
-  | TyDecl of fullType * string mcode (* ; *)
+  | TyDecl of fullType * attr list * string mcode (* ; *)
   | MacroDecl of storage mcode option *
 	ident (* name *) * string mcode (* ( *) *
         expression dots * string mcode (* ) *) *
-- 
2.21.1

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

^ permalink raw reply related	[flat|nested] 28+ messages in thread

* [Linux-kernel-mentees] [PATCH 14/27] parsing_cocci: visitor_ast: Visit struct end attributes
  2020-05-31 15:25 [Linux-kernel-mentees] [PATCH 00/27] cocci: Add struct end attributes to SmPL Jaskaran Singh
                   ` (12 preceding siblings ...)
  2020-05-31 15:26 ` [Linux-kernel-mentees] [PATCH 13/27] parsing_cocci: ast_cocci: Add " Jaskaran Singh
@ 2020-05-31 15:26 ` Jaskaran Singh
  2020-05-31 15:26 ` [Linux-kernel-mentees] [PATCH 15/27] parsing_cocci: pretty_print_cocci: Reflect " Jaskaran Singh
                   ` (12 subsequent siblings)
  26 siblings, 0 replies; 28+ messages in thread
From: Jaskaran Singh @ 2020-05-31 15:26 UTC (permalink / raw)
  To: cocci; +Cc: julia.lawall, jaskaransingh7654321, linux-kernel-mentees

Struct end attributes are added to the SmPL AST. Visit these changes in
the AST visitor.

Signed-off-by: Jaskaran Singh <jaskaransingh7654321@gmail.com>
---
 parsing_cocci/visitor_ast.ml | 10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)

diff --git a/parsing_cocci/visitor_ast.ml b/parsing_cocci/visitor_ast.ml
index faadfbb9..8129bcda 100644
--- a/parsing_cocci/visitor_ast.ml
+++ b/parsing_cocci/visitor_ast.ml
@@ -490,10 +490,11 @@ let combiner bind option_default
 	  let lini = initialiser ini in
 	  let lsem = string_mcode sem in
 	  multibind [lstg; lname; llp; largs; lrp; leq; lini; lsem]
-      | Ast.TyDecl(ty,sem) ->
+      | Ast.TyDecl(ty,attr,sem) ->
 	  let lty = fullType ty in
+	  let lattr = multibind (List.map string_mcode attr) in
 	  let lsem = string_mcode sem in
-	  bind lty lsem
+	  multibind [lty; lattr; lsem]
       | Ast.Typedef(stg,ty,id,sem) ->
 	  let lstg = string_mcode stg in
 	  let lty = fullType ty in
@@ -1448,10 +1449,11 @@ let rebuilder
 	    let lini = initialiser ini in
 	    let lsem = string_mcode sem in
 	    Ast.MacroDeclInit(lstg, lname, llp, largs, lrp, leq, lini, lsem)
-	| Ast.TyDecl(ty,sem) ->
+	| Ast.TyDecl(ty,attr,sem) ->
 	    let lty = fullType ty in
+	    let lattr = List.map string_mcode attr in
 	    let lsem = string_mcode sem in
-	    Ast.TyDecl(lty, lsem)
+	    Ast.TyDecl(lty, lattr, lsem)
 	| Ast.Typedef(stg,ty,id,sem) ->
 	    let lstg = string_mcode stg in
 	    let lty = fullType ty in
-- 
2.21.1

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

^ permalink raw reply related	[flat|nested] 28+ messages in thread

* [Linux-kernel-mentees] [PATCH 15/27] parsing_cocci: pretty_print_cocci: Reflect struct end attributes
  2020-05-31 15:25 [Linux-kernel-mentees] [PATCH 00/27] cocci: Add struct end attributes to SmPL Jaskaran Singh
                   ` (13 preceding siblings ...)
  2020-05-31 15:26 ` [Linux-kernel-mentees] [PATCH 14/27] parsing_cocci: visitor_ast: Visit " Jaskaran Singh
@ 2020-05-31 15:26 ` Jaskaran Singh
  2020-05-31 15:26 ` [Linux-kernel-mentees] [PATCH 16/27] parsing_cocci: disjdistr: " Jaskaran Singh
                   ` (11 subsequent siblings)
  26 siblings, 0 replies; 28+ messages in thread
From: Jaskaran Singh @ 2020-05-31 15:26 UTC (permalink / raw)
  To: cocci; +Cc: julia.lawall, jaskaransingh7654321, linux-kernel-mentees

Struct end attributes are added to the SmPL AST. Print these changes in
pretty_print_cocci.ml.

Signed-off-by: Jaskaran Singh <jaskaransingh7654321@gmail.com>
---
 parsing_cocci/pretty_print_cocci.ml | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/parsing_cocci/pretty_print_cocci.ml b/parsing_cocci/pretty_print_cocci.ml
index e554a6df..aaea3f9d 100644
--- a/parsing_cocci/pretty_print_cocci.ml
+++ b/parsing_cocci/pretty_print_cocci.ml
@@ -580,7 +580,11 @@ and declaration d =
       close_box(); mcode print_string rp;
       print_string " "; mcode print_string eq;
       print_string " "; initialiser ini; mcode print_string sem
-  | Ast.TyDecl(ty,sem) -> fullType ty; mcode print_string sem
+  | Ast.TyDecl(ty,attr,sem) ->
+      fullType ty;
+      (if not (attr = []) then print_string " ");
+      print_between print_space (mcode print_string) attr;
+      mcode print_string sem
   | Ast.Typedef(stg,ty,id,sem) ->
       mcode print_string stg; print_string " ";
       print_named_type ty (fun _ -> typeC id);
-- 
2.21.1

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

^ permalink raw reply related	[flat|nested] 28+ messages in thread

* [Linux-kernel-mentees] [PATCH 16/27] parsing_cocci: disjdistr: Reflect struct end attributes
  2020-05-31 15:25 [Linux-kernel-mentees] [PATCH 00/27] cocci: Add struct end attributes to SmPL Jaskaran Singh
                   ` (14 preceding siblings ...)
  2020-05-31 15:26 ` [Linux-kernel-mentees] [PATCH 15/27] parsing_cocci: pretty_print_cocci: Reflect " Jaskaran Singh
@ 2020-05-31 15:26 ` Jaskaran Singh
  2020-05-31 15:26 ` [Linux-kernel-mentees] [PATCH 17/27] parsing_cocci: adjust_pragmas: " Jaskaran Singh
                   ` (10 subsequent siblings)
  26 siblings, 0 replies; 28+ messages in thread
From: Jaskaran Singh @ 2020-05-31 15:26 UTC (permalink / raw)
  To: cocci; +Cc: julia.lawall, jaskaransingh7654321, linux-kernel-mentees

Struct end attributes are added to the SmPL AST. Reflect these changes
in disjdistr.ml.

Signed-off-by: Jaskaran Singh <jaskaransingh7654321@gmail.com>
---
 parsing_cocci/disjdistr.ml | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/parsing_cocci/disjdistr.ml b/parsing_cocci/disjdistr.ml
index b8491931..ba2b8c02 100644
--- a/parsing_cocci/disjdistr.ml
+++ b/parsing_cocci/disjdistr.ml
@@ -351,9 +351,9 @@ and disjdecl d =
       disjmult3 (disjident name) (disjdots disjexp args) (disjini ini)
 	(fun name args ini ->
 	  Ast.rewrap d (Ast.MacroDeclInit(stg,name,lp,args,rp,eq,ini,sem)))
-  | Ast.TyDecl(ty,sem) ->
+  | Ast.TyDecl(ty,attr,sem) ->
       let ty = disjty ty in
-      List.map (function ty -> Ast.rewrap d (Ast.TyDecl(ty,sem))) ty
+      List.map (function ty -> Ast.rewrap d (Ast.TyDecl(ty,attr,sem))) ty
   | Ast.Typedef(stg,ty,id,sem) ->
       let ty = disjty ty in (* disj not allowed in id *)
       List.map (function ty -> Ast.rewrap d (Ast.Typedef(stg,ty,id,sem))) ty
-- 
2.21.1

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

^ permalink raw reply related	[flat|nested] 28+ messages in thread

* [Linux-kernel-mentees] [PATCH 17/27] parsing_cocci: adjust_pragmas: Reflect struct end attributes
  2020-05-31 15:25 [Linux-kernel-mentees] [PATCH 00/27] cocci: Add struct end attributes to SmPL Jaskaran Singh
                   ` (15 preceding siblings ...)
  2020-05-31 15:26 ` [Linux-kernel-mentees] [PATCH 16/27] parsing_cocci: disjdistr: " Jaskaran Singh
@ 2020-05-31 15:26 ` Jaskaran Singh
  2020-05-31 15:26 ` [Linux-kernel-mentees] [PATCH 18/27] parsing_cocci: unify_ast: " Jaskaran Singh
                   ` (9 subsequent siblings)
  26 siblings, 0 replies; 28+ messages in thread
From: Jaskaran Singh @ 2020-05-31 15:26 UTC (permalink / raw)
  To: cocci; +Cc: julia.lawall, jaskaransingh7654321, linux-kernel-mentees

Struct end attributes are added to the SmPL AST. Reflect these changes
in adjust_pragmas.ml.

Signed-off-by: Jaskaran Singh <jaskaransingh7654321@gmail.com>
---
 parsing_cocci/adjust_pragmas.ml | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/parsing_cocci/adjust_pragmas.ml b/parsing_cocci/adjust_pragmas.ml
index e5597943..b328ad27 100644
--- a/parsing_cocci/adjust_pragmas.ml
+++ b/parsing_cocci/adjust_pragmas.ml
@@ -60,9 +60,9 @@ let rec right_decl d =
   | Ast0.MacroDeclInit(stg,name,lp,args,rp,eq,ini,sem) ->
       call_right right_mcode sem d
 	(function sem -> Ast0.MacroDeclInit(stg,name,lp,args,rp,eq,ini,sem))
-  | Ast0.TyDecl(ty,sem) ->
+  | Ast0.TyDecl(ty,attr,sem) ->
       call_right right_mcode sem d
-	(function sem -> Ast0.TyDecl(ty,sem))
+	(function sem -> Ast0.TyDecl(ty,attr,sem))
   | Ast0.Typedef(stg,ty,id,sem) ->
       call_right right_mcode sem d
 	(function sem -> Ast0.Typedef(stg,ty,id,sem))
@@ -292,8 +292,8 @@ let rec left_decl decl =
   | Ast0.MacroDeclInit(None,name,lp,args,rp,eq,ini,sem) ->
       call_right left_ident name decl
 	(function name -> Ast0.MacroDeclInit(None,name,lp,args,rp,eq,ini,sem))
-  | Ast0.TyDecl(ty,sem) ->
-      call_right left_ty ty decl (function ty -> Ast0.TyDecl(ty,sem))
+  | Ast0.TyDecl(ty,attr,sem) ->
+      call_right left_ty ty decl (function ty -> Ast0.TyDecl(ty,attr,sem))
   | Ast0.Typedef(stg,ty,id,sem) ->
       call_right left_mcode stg decl
 	(function stg -> Ast0.Typedef(stg,ty,id,sem))
-- 
2.21.1

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

^ permalink raw reply related	[flat|nested] 28+ messages in thread

* [Linux-kernel-mentees] [PATCH 18/27] parsing_cocci: unify_ast: Reflect struct end attributes
  2020-05-31 15:25 [Linux-kernel-mentees] [PATCH 00/27] cocci: Add struct end attributes to SmPL Jaskaran Singh
                   ` (16 preceding siblings ...)
  2020-05-31 15:26 ` [Linux-kernel-mentees] [PATCH 17/27] parsing_cocci: adjust_pragmas: " Jaskaran Singh
@ 2020-05-31 15:26 ` Jaskaran Singh
  2020-05-31 15:26 ` [Linux-kernel-mentees] [PATCH 19/27] parsing_cocci: ast0toast: " Jaskaran Singh
                   ` (8 subsequent siblings)
  26 siblings, 0 replies; 28+ messages in thread
From: Jaskaran Singh @ 2020-05-31 15:26 UTC (permalink / raw)
  To: cocci; +Cc: julia.lawall, jaskaransingh7654321, linux-kernel-mentees

Struct end attributes are added to the SmPL AST. Reflect these changes
in unify_ast.ml.

Signed-off-by: Jaskaran Singh <jaskaransingh7654321@gmail.com>
---
 parsing_cocci/unify_ast.ml | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/parsing_cocci/unify_ast.ml b/parsing_cocci/unify_ast.ml
index e36c0807..752e9283 100644
--- a/parsing_cocci/unify_ast.ml
+++ b/parsing_cocci/unify_ast.ml
@@ -426,7 +426,10 @@ and unify_declaration d1 d2 =
 	 unify_dots unify_expression edots args1 args2 &&
 	 unify_initialiser ini1 ini2
        else false
-  | (Ast.TyDecl(ft1,s1),Ast.TyDecl(ft2,s2)) -> unify_fullType ft1 ft2
+  | (Ast.TyDecl(ft1,attr1,s1),Ast.TyDecl(ft2,attr2,s2)) ->
+      if List.for_all2 unify_mcode attr1 attr2
+      then unify_fullType ft1 ft2
+      else false
   | (Ast.Typedef(stg1,ft1,id1,s1),Ast.Typedef(stg2,ft2,id2,s2)) ->
       unify_fullType ft1 ft2 && unify_typeC id1 id2
   | (Ast.DisjDecl(d1),_) ->
-- 
2.21.1

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

^ permalink raw reply related	[flat|nested] 28+ messages in thread

* [Linux-kernel-mentees] [PATCH 19/27] parsing_cocci: ast0toast: Reflect struct end attributes
  2020-05-31 15:25 [Linux-kernel-mentees] [PATCH 00/27] cocci: Add struct end attributes to SmPL Jaskaran Singh
                   ` (17 preceding siblings ...)
  2020-05-31 15:26 ` [Linux-kernel-mentees] [PATCH 18/27] parsing_cocci: unify_ast: " Jaskaran Singh
@ 2020-05-31 15:26 ` Jaskaran Singh
  2020-05-31 15:26 ` [Linux-kernel-mentees] [PATCH 20/27] parsing_c: unparse_cocci: " Jaskaran Singh
                   ` (7 subsequent siblings)
  26 siblings, 0 replies; 28+ messages in thread
From: Jaskaran Singh @ 2020-05-31 15:26 UTC (permalink / raw)
  To: cocci; +Cc: julia.lawall, jaskaransingh7654321, linux-kernel-mentees

Struct end attributes are added to the SmPL AST. Reflect these changes
in ast0toast.ml.

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

diff --git a/parsing_cocci/ast0toast.ml b/parsing_cocci/ast0toast.ml
index 30e27cc5..cba32af6 100644
--- a/parsing_cocci/ast0toast.ml
+++ b/parsing_cocci/ast0toast.ml
@@ -679,9 +679,10 @@ and declaration d =
 	let ini = initialiser ini in
 	let sem = mcode sem in
 	Ast.MacroDeclInit(stg,name,lp,args,rp,eq,ini,sem)
-    | Ast0.TyDecl(ty,sem) ->
+    | Ast0.TyDecl(ty,attr,sem) ->
 	let allminus = check_allminus.VT0.combiner_rec_declaration d in
-	Ast.TyDecl(typeC allminus ty,mcode sem)
+	let attr = List.map mcode attr in
+	Ast.TyDecl(typeC allminus ty,attr,mcode sem)
     | Ast0.Typedef(stg,ty,id,sem) ->
 	let allminus = check_allminus.VT0.combiner_rec_declaration d in
 	let id = typeC allminus id in
-- 
2.21.1

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

^ permalink raw reply related	[flat|nested] 28+ messages in thread

* [Linux-kernel-mentees] [PATCH 20/27] parsing_c: unparse_cocci: Reflect struct end attributes
  2020-05-31 15:25 [Linux-kernel-mentees] [PATCH 00/27] cocci: Add struct end attributes to SmPL Jaskaran Singh
                   ` (18 preceding siblings ...)
  2020-05-31 15:26 ` [Linux-kernel-mentees] [PATCH 19/27] parsing_cocci: ast0toast: " Jaskaran Singh
@ 2020-05-31 15:26 ` Jaskaran Singh
  2020-05-31 15:26 ` [Linux-kernel-mentees] [PATCH 21/27] engine: check_exhaustive_pattern: " Jaskaran Singh
                   ` (6 subsequent siblings)
  26 siblings, 0 replies; 28+ messages in thread
From: Jaskaran Singh @ 2020-05-31 15:26 UTC (permalink / raw)
  To: cocci; +Cc: julia.lawall, jaskaransingh7654321, linux-kernel-mentees

Struct end attributes are added to the SmPL AST. Reflect these changes
in unparse_cocci.ml.

Signed-off-by: Jaskaran Singh <jaskaransingh7654321@gmail.com>
---
 parsing_c/unparse_cocci.ml | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/parsing_c/unparse_cocci.ml b/parsing_c/unparse_cocci.ml
index 30050ea1..f0efc968 100644
--- a/parsing_c/unparse_cocci.ml
+++ b/parsing_c/unparse_cocci.ml
@@ -955,7 +955,11 @@ and declaration d =
       close_box(); mcode print_string rp;
       pr_space(); mcode print_string eq;
       pr_space(); initialiser true ini; mcode print_string sem
-  | Ast.TyDecl(ty,sem) -> fullType ty; mcode print_string sem
+  | Ast.TyDecl(ty,attr,sem) ->
+      fullType ty;
+      (if not (attr = []) then pr_space());
+      print_between pr_space (mcode print_string) attr;
+      mcode print_string sem
   | Ast.Typedef(stg,ty,id,sem) ->
       mcode print_string stg; pr_space();
       print_named_type ty (fun _ -> typeC id);
-- 
2.21.1

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

^ permalink raw reply related	[flat|nested] 28+ messages in thread

* [Linux-kernel-mentees] [PATCH 21/27] engine: check_exhaustive_pattern: Reflect struct end attributes
  2020-05-31 15:25 [Linux-kernel-mentees] [PATCH 00/27] cocci: Add struct end attributes to SmPL Jaskaran Singh
                   ` (19 preceding siblings ...)
  2020-05-31 15:26 ` [Linux-kernel-mentees] [PATCH 20/27] parsing_c: unparse_cocci: " Jaskaran Singh
@ 2020-05-31 15:26 ` Jaskaran Singh
  2020-05-31 15:26 ` [Linux-kernel-mentees] [PATCH 22/27] engine: cocci_vs_c: Match " Jaskaran Singh
                   ` (5 subsequent siblings)
  26 siblings, 0 replies; 28+ messages in thread
From: Jaskaran Singh @ 2020-05-31 15:26 UTC (permalink / raw)
  To: cocci; +Cc: julia.lawall, jaskaransingh7654321, linux-kernel-mentees

Struct end attributes are added to the SmPL AST. Reflect these changes
in check_exhaustive_pattern.ml.

Signed-off-by: Jaskaran Singh <jaskaransingh7654321@gmail.com>
---
 engine/check_exhaustive_pattern.ml | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/engine/check_exhaustive_pattern.ml b/engine/check_exhaustive_pattern.ml
index b702063d..fe2dac67 100644
--- a/engine/check_exhaustive_pattern.ml
+++ b/engine/check_exhaustive_pattern.ml
@@ -62,7 +62,7 @@ let dumb_astcocci_decl = function
    A.UnInit (stg, typa, sa, attr, _)     -> ()
  | A.Init (stg, typa, sa, attr, _, expa, _) -> ()
  | A.FunProto _ -> ()
- | A.TyDecl (typa, _)     -> ()
+ | A.TyDecl (typa, _, _)     -> ()
  | A.MacroDecl(stg, fn, _, eas, _, _, _) -> ()
  | A.MacroDeclInit(stg, fn, _, eas, _, _, _, _) -> ()
  | A.MetaDecl _ -> ()
@@ -78,7 +78,7 @@ let dumb_astcocci_initialiser = function (* seems same as the above *)
   | A.FunProto _ -> ()
   | A.MacroDecl(_, fn, _, eas, _, _, _) -> ()
   | A.MacroDeclInit(_, fn, _, eas, _, _, _, _) -> ()
-  | A.TyDecl(ty,sem) -> ()
+  | A.TyDecl(ty,attr,sem) -> ()
   | A.Typedef(d,ty1,ty2,pv) -> ()
   | A.DisjDecl(decls) -> ()
   | A.ConjDecl(decls) -> ()
-- 
2.21.1

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

^ permalink raw reply related	[flat|nested] 28+ messages in thread

* [Linux-kernel-mentees] [PATCH 22/27] engine: cocci_vs_c: Match struct end attributes
  2020-05-31 15:25 [Linux-kernel-mentees] [PATCH 00/27] cocci: Add struct end attributes to SmPL Jaskaran Singh
                   ` (20 preceding siblings ...)
  2020-05-31 15:26 ` [Linux-kernel-mentees] [PATCH 21/27] engine: check_exhaustive_pattern: " Jaskaran Singh
@ 2020-05-31 15:26 ` Jaskaran Singh
  2020-05-31 15:26 ` [Linux-kernel-mentees] [PATCH 23/27] ocaml: coccilib: Reflect " Jaskaran Singh
                   ` (4 subsequent siblings)
  26 siblings, 0 replies; 28+ messages in thread
From: Jaskaran Singh @ 2020-05-31 15:26 UTC (permalink / raw)
  To: cocci; +Cc: julia.lawall, jaskaransingh7654321, linux-kernel-mentees

Struct end attributes are added to the SmPL AST. Match these attributes
in cocci_vs_c.ml.

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

diff --git a/engine/cocci_vs_c.ml b/engine/cocci_vs_c.ml
index 83141bf5..7abc4d53 100644
--- a/engine/cocci_vs_c.ml
+++ b/engine/cocci_vs_c.ml
@@ -2461,7 +2461,7 @@ and onedecl = fun allminus decla (declb, iiptvirgb, iistob) ->
   * T { }; that we want to match against typedef struct { } xx_t;
   *)
 
- | A.TyDecl (tya0, ptvirga),
+ | A.TyDecl (tya0, attra, ptvirga),
    ({B.v_namei = Some (nameidb, B.NoInit);
      B.v_type = typb0;
      B.v_storage = (B.StoTypedef, inl);
@@ -2503,6 +2503,7 @@ and onedecl = fun allminus decla (declb, iiptvirgb, iistob) ->
        in
 
        struct_fields (A.unwrap declsa) declsb >>= (fun undeclsa declsb ->
+         attribute_list allminus attra endattrs >>= (fun attra endattrs ->
          tokenf ptvirga iiptvirgb >>= (fun ptvirga iiptvirgb ->
          tokenf lba lbb >>= (fun lba lbb ->
          tokenf rba rbb >>= (fun rba rbb ->
@@ -2531,7 +2532,8 @@ and onedecl = fun allminus decla (declb, iiptvirgb, iistob) ->
 			   check_constraints cstr ida (B.MetaTypeVal typ')
 			     (fun () ->
 			       return (
-			       (A.TyDecl (tya0, ptvirga)) +> A.rewrap decla,
+			       (A.TyDecl (tya0, attra, ptvirga))
+			        +> A.rewrap decla,
 			       (({B.v_namei = Some (nameidb, B.NoInit);
 				  B.v_type = typb0;
 				  B.v_storage = (B.StoTypedef, inl);
@@ -2563,7 +2565,7 @@ and onedecl = fun allminus decla (declb, iiptvirgb, iistob) ->
                    let typb0 = ((qu, il), typb1) in
 
                    return (
-                     (A.TyDecl (tya0, ptvirga)) +> A.rewrap decla,
+                     (A.TyDecl (tya0, attra, ptvirga)) +> A.rewrap decla,
                      (({B.v_namei = Some (nameidb, B.NoInit);
                         B.v_type = typb0;
                         B.v_storage = (B.StoTypedef, inl);
@@ -2579,7 +2581,7 @@ and onedecl = fun allminus decla (declb, iiptvirgb, iistob) ->
            | _ -> raise (Impossible 31)
            )
          | _ -> fail
-       )))))
+       ))))))
      | _ -> fail
      )
    | _ -> fail
@@ -2718,7 +2720,7 @@ and onedecl = fun allminus decla (declb, iiptvirgb, iistob) ->
 	      )))))))))
 
    (* do iso-by-absence here ? allow typedecl and var ? *)
-   | A.TyDecl (typa, ptvirga),
+   | A.TyDecl (typa, attra, ptvirga),
      ({B.v_namei = None; B.v_type = typb;
        B.v_storage = stob;
        B.v_local = local;
@@ -2730,9 +2732,10 @@ and onedecl = fun allminus decla (declb, iiptvirgb, iistob) ->
        if stob = (B.NoSto, false)
        then
          fullType typa typb >>= (fun typa typb ->
+         attribute_list allminus attra endattrs >>= (fun attra endattrs ->
          tokenf ptvirga iiptvirgb >>= (fun ptvirga iiptvirgb ->
            return (
-             (A.TyDecl (typa, ptvirga)) +> A.rewrap decla,
+             (A.TyDecl (typa, attra, ptvirga)) +> A.rewrap decla,
              (({B.v_namei = None;
                 B.v_type = typb;
                 B.v_storage = stob;
@@ -2741,7 +2744,7 @@ and onedecl = fun allminus decla (declb, iiptvirgb, iistob) ->
                 B.v_endattr = endattrs;
                 B.v_type_bis = typbbis;
              }, iivirg), iiptvirgb, iistob)
-           )))
+           ))))
        else fail
 
 
-- 
2.21.1

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

^ permalink raw reply related	[flat|nested] 28+ messages in thread

* [Linux-kernel-mentees] [PATCH 23/27] ocaml: coccilib: Reflect struct end attributes
  2020-05-31 15:25 [Linux-kernel-mentees] [PATCH 00/27] cocci: Add struct end attributes to SmPL Jaskaran Singh
                   ` (21 preceding siblings ...)
  2020-05-31 15:26 ` [Linux-kernel-mentees] [PATCH 22/27] engine: cocci_vs_c: Match " Jaskaran Singh
@ 2020-05-31 15:26 ` Jaskaran Singh
  2020-05-31 15:26 ` [Linux-kernel-mentees] [PATCH 24/27] tools: spgen: " Jaskaran Singh
                   ` (3 subsequent siblings)
  26 siblings, 0 replies; 28+ messages in thread
From: Jaskaran Singh @ 2020-05-31 15:26 UTC (permalink / raw)
  To: cocci; +Cc: julia.lawall, jaskaransingh7654321, linux-kernel-mentees

Struct end attributes are added to the SmPL AST. Reflect these changes
in coccilib.mli.

Signed-off-by: Jaskaran Singh <jaskaransingh7654321@gmail.com>
---
 ocaml/coccilib.mli | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/ocaml/coccilib.mli b/ocaml/coccilib.mli
index c5195084..24b5f1ae 100644
--- a/ocaml/coccilib.mli
+++ b/ocaml/coccilib.mli
@@ -2766,7 +2766,7 @@ module Ast_cocci :
           string mcode
       | FunProto of fninfo list * ident * string mcode * parameter_list *
           (string mcode * string mcode) option * string mcode * string mcode
-      | TyDecl of fullType * string mcode
+      | TyDecl of fullType * attr list * string mcode
       | MacroDecl of storage mcode option * ident * string mcode *
           expression dots * string mcode * attr list * string mcode
       | MacroDeclInit of storage mcode option * ident * string mcode *
@@ -3401,7 +3401,7 @@ module Ast0_cocci :
           attr list * string mcode
       | FunProto of fninfo list * ident * string mcode * parameter_list *
           (string mcode * string mcode) option * string mcode * string mcode
-      | TyDecl of typeC * string mcode
+      | TyDecl of typeC * attr list * string mcode
       | MacroDecl of Ast_cocci.storage mcode option * ident * string mcode *
           expression dots * string mcode * attr list * string mcode
       | MacroDeclInit of Ast_cocci.storage mcode option * ident *
-- 
2.21.1

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

^ permalink raw reply related	[flat|nested] 28+ messages in thread

* [Linux-kernel-mentees] [PATCH 24/27] tools: spgen: Reflect struct end attributes
  2020-05-31 15:25 [Linux-kernel-mentees] [PATCH 00/27] cocci: Add struct end attributes to SmPL Jaskaran Singh
                   ` (22 preceding siblings ...)
  2020-05-31 15:26 ` [Linux-kernel-mentees] [PATCH 23/27] ocaml: coccilib: Reflect " Jaskaran Singh
@ 2020-05-31 15:26 ` Jaskaran Singh
  2020-05-31 15:26 ` [Linux-kernel-mentees] [PATCH 25/27] tests: Add test case to remove a struct end attribute Jaskaran Singh
                   ` (2 subsequent siblings)
  26 siblings, 0 replies; 28+ messages in thread
From: Jaskaran Singh @ 2020-05-31 15:26 UTC (permalink / raw)
  To: cocci; +Cc: julia.lawall, jaskaransingh7654321, linux-kernel-mentees

Struct end attributes are added to the SmPL AST. Reflect these changes
in spgen.

Signed-off-by: Jaskaran Singh <jaskaransingh7654321@gmail.com>
---
 tools/spgen/source/position_generator.ml | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/tools/spgen/source/position_generator.ml b/tools/spgen/source/position_generator.ml
index deca6f73..e70a47b4 100644
--- a/tools/spgen/source/position_generator.ml
+++ b/tools/spgen/source/position_generator.ml
@@ -412,8 +412,8 @@ let rec declaration_pos decl snp
       let _ = type_pos ty snp in (* sanity check *)
       let constructor ~id = Ast0.UnInit(st, ty, id, attr, sem) in
       id_wrap ~id ~constructor snp
-  | Ast0.TyDecl (t, sem) ->
-      let c ~item ~mc = Ast0.TyDecl(item, mc) in
+  | Ast0.TyDecl (t, attr, sem) ->
+      let c ~item ~mc = Ast0.TyDecl(item, attr, mc) in
       let alt() = mcode_wrap ~mc:sem ~constructor:(c ~item:t) snp in
       item_wrap ~item:t ~item_posfn:type_pos ~constructor:(c ~mc:sem) ~alt snp
   | Ast0.Typedef (tm, tc, tc2, sem) ->
-- 
2.21.1

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

^ permalink raw reply related	[flat|nested] 28+ messages in thread

* [Linux-kernel-mentees] [PATCH 25/27] tests: Add test case to remove a struct end attribute
  2020-05-31 15:25 [Linux-kernel-mentees] [PATCH 00/27] cocci: Add struct end attributes to SmPL Jaskaran Singh
                   ` (23 preceding siblings ...)
  2020-05-31 15:26 ` [Linux-kernel-mentees] [PATCH 24/27] tools: spgen: " Jaskaran Singh
@ 2020-05-31 15:26 ` Jaskaran Singh
  2020-05-31 15:26 ` [Linux-kernel-mentees] [PATCH 26/27] tests: Add test case to detect " Jaskaran Singh
  2020-05-31 15:26 ` [Linux-kernel-mentees] [PATCH 27/27] tests: Add test case to check struct endattr allminus Jaskaran Singh
  26 siblings, 0 replies; 28+ messages in thread
From: Jaskaran Singh @ 2020-05-31 15:26 UTC (permalink / raw)
  To: cocci; +Cc: julia.lawall, jaskaransingh7654321, linux-kernel-mentees

Stuct end attributes are added to the SmPL and C ASTs. Add a test case
to remove struct end attributes.

Signed-off-by: Jaskaran Singh <jaskaransingh7654321@gmail.com>
---
 tests/remove_struct_endattr.c     | 7 +++++++
 tests/remove_struct_endattr.cocci | 7 +++++++
 tests/remove_struct_endattr.res   | 7 +++++++
 3 files changed, 21 insertions(+)
 create mode 100644 tests/remove_struct_endattr.c
 create mode 100644 tests/remove_struct_endattr.cocci
 create mode 100644 tests/remove_struct_endattr.res

diff --git a/tests/remove_struct_endattr.c b/tests/remove_struct_endattr.c
new file mode 100644
index 00000000..95aa8610
--- /dev/null
+++ b/tests/remove_struct_endattr.c
@@ -0,0 +1,7 @@
+#define __struct_endattr MACROANNOTATION
+
+struct abcd {
+	int a;
+	int b;
+	int c;
+} __struct_endattr;
diff --git a/tests/remove_struct_endattr.cocci b/tests/remove_struct_endattr.cocci
new file mode 100644
index 00000000..c4b86864
--- /dev/null
+++ b/tests/remove_struct_endattr.cocci
@@ -0,0 +1,7 @@
+@@
+attribute name __struct_endattr;
+@@
+
+struct abcd {...}
+-	__struct_endattr
+;
diff --git a/tests/remove_struct_endattr.res b/tests/remove_struct_endattr.res
new file mode 100644
index 00000000..dda83724
--- /dev/null
+++ b/tests/remove_struct_endattr.res
@@ -0,0 +1,7 @@
+#define __struct_endattr MACROANNOTATION
+
+struct abcd {
+	int a;
+	int b;
+	int c;
+};
-- 
2.21.1

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

^ permalink raw reply related	[flat|nested] 28+ messages in thread

* [Linux-kernel-mentees] [PATCH 26/27] tests: Add test case to detect a struct end attribute
  2020-05-31 15:25 [Linux-kernel-mentees] [PATCH 00/27] cocci: Add struct end attributes to SmPL Jaskaran Singh
                   ` (24 preceding siblings ...)
  2020-05-31 15:26 ` [Linux-kernel-mentees] [PATCH 25/27] tests: Add test case to remove a struct end attribute Jaskaran Singh
@ 2020-05-31 15:26 ` Jaskaran Singh
  2020-05-31 15:26 ` [Linux-kernel-mentees] [PATCH 27/27] tests: Add test case to check struct endattr allminus Jaskaran Singh
  26 siblings, 0 replies; 28+ messages in thread
From: Jaskaran Singh @ 2020-05-31 15:26 UTC (permalink / raw)
  To: cocci; +Cc: julia.lawall, jaskaransingh7654321, linux-kernel-mentees

Struct end attributes are added to the SmPL and C ASTs. Add a test case
to detect a struct end attribute.

Signed-off-by: Jaskaran Singh <jaskaransingh7654321@gmail.com>
---
 tests/detect_struct_endattr.c     | 13 +++++++++++++
 tests/detect_struct_endattr.cocci |  9 +++++++++
 tests/detect_struct_endattr.res   | 12 ++++++++++++
 3 files changed, 34 insertions(+)
 create mode 100644 tests/detect_struct_endattr.c
 create mode 100644 tests/detect_struct_endattr.cocci
 create mode 100644 tests/detect_struct_endattr.res

diff --git a/tests/detect_struct_endattr.c b/tests/detect_struct_endattr.c
new file mode 100644
index 00000000..240fcde9
--- /dev/null
+++ b/tests/detect_struct_endattr.c
@@ -0,0 +1,13 @@
+#define __struct_endattr MACROANNOTATION
+
+struct abcd {
+	int a;
+	int b;
+	int c;
+} __struct_endattr;
+
+struct abcd {
+	int a;
+	int b;
+	int c;
+};
diff --git a/tests/detect_struct_endattr.cocci b/tests/detect_struct_endattr.cocci
new file mode 100644
index 00000000..8b6ba797
--- /dev/null
+++ b/tests/detect_struct_endattr.cocci
@@ -0,0 +1,9 @@
+@@
+attribute name __struct_endattr;
+@@
+
+struct abcd {
+	...
+-	int b;
+	...
+} __struct_endattr;
diff --git a/tests/detect_struct_endattr.res b/tests/detect_struct_endattr.res
new file mode 100644
index 00000000..71002542
--- /dev/null
+++ b/tests/detect_struct_endattr.res
@@ -0,0 +1,12 @@
+#define __struct_endattr MACROANNOTATION
+
+struct abcd {
+	int a;
+	int c;
+} __struct_endattr;
+
+struct abcd {
+	int a;
+	int b;
+	int c;
+};
-- 
2.21.1

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

^ permalink raw reply related	[flat|nested] 28+ messages in thread

* [Linux-kernel-mentees] [PATCH 27/27] tests: Add test case to check struct endattr allminus
  2020-05-31 15:25 [Linux-kernel-mentees] [PATCH 00/27] cocci: Add struct end attributes to SmPL Jaskaran Singh
                   ` (25 preceding siblings ...)
  2020-05-31 15:26 ` [Linux-kernel-mentees] [PATCH 26/27] tests: Add test case to detect " Jaskaran Singh
@ 2020-05-31 15:26 ` Jaskaran Singh
  26 siblings, 0 replies; 28+ messages in thread
From: Jaskaran Singh @ 2020-05-31 15:26 UTC (permalink / raw)
  To: cocci; +Cc: julia.lawall, jaskaransingh7654321, linux-kernel-mentees

Struct end attributes are added to the SmPL and C ASTs. Add a test case
to check allminus for struct end attributes.

Signed-off-by: Jaskaran Singh <jaskaransingh7654321@gmail.com>
---
 tests/remove_struct_endattr_allminus.c     | 13 +++++++++++++
 tests/remove_struct_endattr_allminus.cocci |  6 ++++++
 tests/remove_struct_endattr_allminus.res   |  1 +
 3 files changed, 20 insertions(+)
 create mode 100644 tests/remove_struct_endattr_allminus.c
 create mode 100644 tests/remove_struct_endattr_allminus.cocci
 create mode 100644 tests/remove_struct_endattr_allminus.res

diff --git a/tests/remove_struct_endattr_allminus.c b/tests/remove_struct_endattr_allminus.c
new file mode 100644
index 00000000..a99a7e9f
--- /dev/null
+++ b/tests/remove_struct_endattr_allminus.c
@@ -0,0 +1,13 @@
+#define __struct_endattr MACROANNOTATION
+
+struct abcd {
+	int a;
+	int b;
+	int c;
+} __struct_endattr;
+
+struct defg {
+	int a;
+	int b;
+	int c;
+};
diff --git a/tests/remove_struct_endattr_allminus.cocci b/tests/remove_struct_endattr_allminus.cocci
new file mode 100644
index 00000000..f63ab7cd
--- /dev/null
+++ b/tests/remove_struct_endattr_allminus.cocci
@@ -0,0 +1,6 @@
+@@
+identifier id;
+attribute name __struct_endattr;
+@@
+
+- struct id {...};
diff --git a/tests/remove_struct_endattr_allminus.res b/tests/remove_struct_endattr_allminus.res
new file mode 100644
index 00000000..e2f74e8f
--- /dev/null
+++ b/tests/remove_struct_endattr_allminus.res
@@ -0,0 +1 @@
+#define __struct_endattr MACROANNOTATION
-- 
2.21.1

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

^ permalink raw reply related	[flat|nested] 28+ messages in thread

end of thread, other threads:[~2020-05-31 15:28 UTC | newest]

Thread overview: 28+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-05-31 15:25 [Linux-kernel-mentees] [PATCH 00/27] cocci: Add struct end attributes to SmPL Jaskaran Singh
2020-05-31 15:25 ` [Linux-kernel-mentees] [PATCH 01/27] parsing_cocci: ast0_cocci: Add struct end attributes Jaskaran Singh
2020-05-31 15:25 ` [Linux-kernel-mentees] [PATCH 02/27] parsing_cocci: parser: Reflect " Jaskaran Singh
2020-05-31 15:25 ` [Linux-kernel-mentees] [PATCH 03/27] parsing_cocci: visitor_ast0: Visit " Jaskaran Singh
2020-05-31 15:25 ` [Linux-kernel-mentees] [PATCH 04/27] parsing_cocci: unparse_ast0: Reflect " Jaskaran Singh
2020-05-31 15:25 ` [Linux-kernel-mentees] [PATCH 05/27] parsing_cocci: index: " Jaskaran Singh
2020-05-31 15:26 ` [Linux-kernel-mentees] [PATCH 06/27] parsing_cocci: iso_pattern: " Jaskaran Singh
2020-05-31 15:26 ` [Linux-kernel-mentees] [PATCH 07/27] parsing_cocci: type_infer: " Jaskaran Singh
2020-05-31 15:26 ` [Linux-kernel-mentees] [PATCH 08/27] parsing_cocci: arity: " Jaskaran Singh
2020-05-31 15:26 ` [Linux-kernel-mentees] [PATCH 09/27] parsing_cocci: check_meta: " Jaskaran Singh
2020-05-31 15:26 ` [Linux-kernel-mentees] [PATCH 10/27] parsing_cocci: compute_lines: " Jaskaran Singh
2020-05-31 15:26 ` [Linux-kernel-mentees] [PATCH 11/27] parsing_cocci: context_neg: " Jaskaran Singh
2020-05-31 15:26 ` [Linux-kernel-mentees] [PATCH 12/27] parsing_cocci: single_statement: " Jaskaran Singh
2020-05-31 15:26 ` [Linux-kernel-mentees] [PATCH 13/27] parsing_cocci: ast_cocci: Add " Jaskaran Singh
2020-05-31 15:26 ` [Linux-kernel-mentees] [PATCH 14/27] parsing_cocci: visitor_ast: Visit " Jaskaran Singh
2020-05-31 15:26 ` [Linux-kernel-mentees] [PATCH 15/27] parsing_cocci: pretty_print_cocci: Reflect " Jaskaran Singh
2020-05-31 15:26 ` [Linux-kernel-mentees] [PATCH 16/27] parsing_cocci: disjdistr: " Jaskaran Singh
2020-05-31 15:26 ` [Linux-kernel-mentees] [PATCH 17/27] parsing_cocci: adjust_pragmas: " Jaskaran Singh
2020-05-31 15:26 ` [Linux-kernel-mentees] [PATCH 18/27] parsing_cocci: unify_ast: " Jaskaran Singh
2020-05-31 15:26 ` [Linux-kernel-mentees] [PATCH 19/27] parsing_cocci: ast0toast: " Jaskaran Singh
2020-05-31 15:26 ` [Linux-kernel-mentees] [PATCH 20/27] parsing_c: unparse_cocci: " Jaskaran Singh
2020-05-31 15:26 ` [Linux-kernel-mentees] [PATCH 21/27] engine: check_exhaustive_pattern: " Jaskaran Singh
2020-05-31 15:26 ` [Linux-kernel-mentees] [PATCH 22/27] engine: cocci_vs_c: Match " Jaskaran Singh
2020-05-31 15:26 ` [Linux-kernel-mentees] [PATCH 23/27] ocaml: coccilib: Reflect " Jaskaran Singh
2020-05-31 15:26 ` [Linux-kernel-mentees] [PATCH 24/27] tools: spgen: " Jaskaran Singh
2020-05-31 15:26 ` [Linux-kernel-mentees] [PATCH 25/27] tests: Add test case to remove a struct end attribute Jaskaran Singh
2020-05-31 15:26 ` [Linux-kernel-mentees] [PATCH 26/27] tests: Add test case to detect " Jaskaran Singh
2020-05-31 15:26 ` [Linux-kernel-mentees] [PATCH 27/27] tests: Add test case to check struct endattr allminus Jaskaran Singh

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).