linux-kernel-mentees.lists.linuxfoundation.org archive mirror
 help / color / mirror / Atom feed
* [Linux-kernel-mentees] [PATCH 00/30] cocci: Add macrodecl attributes to C and SmPL ASTs
@ 2020-05-24 17:19 Jaskaran Singh
  2020-05-24 17:19 ` [Linux-kernel-mentees] [PATCH 01/30] parsing_cocci: ast0_cocci: Add Macrodecl attributes Jaskaran Singh
                   ` (29 more replies)
  0 siblings, 30 replies; 31+ messages in thread
From: Jaskaran Singh @ 2020-05-24 17:19 UTC (permalink / raw)
  To: cocci; +Cc: julia.lawall, jaskaransingh7654321, linux-kernel-mentees

This patch series aims to add macrodecl attributes to C and SmPL ASTs,
and match them in C source code. This is a continuation of the series
"cocci: Improve C parsing of attributes"[1].

Two test cases are included:

- detect_macrodecl_attr: Test case to detect a macrodecl attribute.

- remove_macrodecl_attr: Test case to remove a macrodecl attribute as per the
  given SmPL.

[1]https://www.mail-archive.com/cocci@systeme.lip6.fr/msg07133.html

Jaskaran Singh (30):
      parsing_cocci: ast0_cocci: Add Macrodecl attributes
      parsing_cocci: parser: Parse Macrodecl attributes
      parsing_cocci: visitor_ast0: Visit Macrodecl attributes
      parsing_cocci: unparse_ast0: Reflect Macrodecl attributes
      parsing_cocci: index: Reflect Macrodecl attributes
      parsing_cocci: iso_pattern: Reflect Macrodecl attributes
      parsing_cocci: type_infer: Reflect Macrodecl attributes
      parsing_cocci: arity: Reflect Macrodecl attributes
      parsing_cocci: check_meta: Reflect Macrodecl attributes
      parsing_cocci: compute_lines: Reflect Macrodecl attributes
      parsing_cocci: context_neg: Reflect Macrodecl attributes
      parsing_cocci: single_statement: Reflect Macrodecl attributes
      parsing_cocci: ast_cocci: Reflect Macrodecl attributes
      parsing_cocci: visitor_ast: Reflect Macrodecl attributes
      parsing_cocci: pretty_print_cocci: Reflect Macrodecl attributes
      parsing_cocci: disjdistr: Reflect Macrodecl attributes
      parsing_cocci: adjust_pragmas: Reflect Macrodecl attributes
      parsing_cocci: unify_ast: Reflect Macrodecl attributes
      parsing_cocci: ast0toast: Reflect Macrodecl attributes
      parsing_c: ast_c: Add Macrodecl attributes
      parsing_c: parser_c: Reflect Macrodecl attributes
      parsing_c: visitor_c: Reflect Macrodecl attributes
      parsing_c: pretty_print_c: Reflect Macrodecl attributes
      parsing_c: unparse_cocci: Reflect Macrodecl attributes
      engine: check_exhaustive_pattern: Reflect Macrodecl attributes
      engine: cocci_vs_c: Match Macrodecl attributes
      ocaml: coccilib: Reflect Macrodecl attributes
      tools: spgen: Reflect Macrodecl attributes
      tests: Add test case to remove macrodecl attributes
      tests: Add test case to detect a macrodecl attribute

 engine/check_exhaustive_pattern.ml       |    4 ++--
 engine/cocci_vs_c.ml                     |   23 +++++++++++++----------
 ocaml/coccilib.mli                       |    8 +++++---
 parsing_c/ast_c.ml                       |    3 ++-
 parsing_c/ast_c.mli                      |    4 +++-
 parsing_c/parser_c.mly                   |   23 ++++++++++++++++-------
 parsing_c/pretty_print_c.ml              |    7 ++++---
 parsing_c/unparse_cocci.ml               |    7 +++++--
 parsing_c/visitor_c.ml                   |    6 ++++--
 parsing_cocci/adjust_pragmas.ml          |   12 ++++++------
 parsing_cocci/arity.ml                   |    5 +++--
 parsing_cocci/ast0_cocci.ml              |    3 ++-
 parsing_cocci/ast0_cocci.mli             |    3 ++-
 parsing_cocci/ast0toast.ml               |    5 +++--
 parsing_cocci/ast_cocci.ml               |    3 ++-
 parsing_cocci/ast_cocci.mli              |    3 ++-
 parsing_cocci/check_meta.ml              |    3 ++-
 parsing_cocci/compute_lines.ml           |    7 ++++---
 parsing_cocci/context_neg.ml             |    6 +++---
 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      |    7 +++++--
 parsing_cocci/single_statement.ml        |    6 +++---
 parsing_cocci/type_infer.ml              |    2 +-
 parsing_cocci/unify_ast.ml               |    4 ++--
 parsing_cocci/unparse_ast0.ml            |    7 +++++--
 parsing_cocci/visitor_ast.ml             |   10 ++++++----
 parsing_cocci/visitor_ast0.ml            |    7 ++++---
 tests/detect_macrodecl_attr.c            |    5 +++++
 tests/detect_macrodecl_attr.cocci        |   12 ++++++++++++
 tests/detect_macrodecl_attr.res          |    5 +++++
 tests/remove_macrodecl_attr.c            |    3 +++
 tests/remove_macrodecl_attr.cocci        |    8 ++++++++
 tests/remove_macrodecl_attr.res          |    3 +++
 tools/spgen/source/meta_variable.ml      |    2 +-
 tools/spgen/source/position_generator.ml |    4 ++--
 38 files changed, 161 insertions(+), 82 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] 31+ messages in thread

* [Linux-kernel-mentees] [PATCH 01/30] parsing_cocci: ast0_cocci: Add Macrodecl attributes
  2020-05-24 17:19 [Linux-kernel-mentees] [PATCH 00/30] cocci: Add macrodecl attributes to C and SmPL ASTs Jaskaran Singh
@ 2020-05-24 17:19 ` Jaskaran Singh
  2020-05-24 17:19 ` [Linux-kernel-mentees] [PATCH 02/30] parsing_cocci: parser: Parse " Jaskaran Singh
                   ` (28 subsequent siblings)
  29 siblings, 0 replies; 31+ messages in thread
From: Jaskaran Singh @ 2020-05-24 17:19 UTC (permalink / raw)
  To: cocci; +Cc: julia.lawall, jaskaransingh7654321, linux-kernel-mentees

Add Macrodecl attributes to AST0 of SmPL. These attributes are for the
MacroDecl type of SmPL AST0.

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

diff --git a/parsing_cocci/ast0_cocci.ml b/parsing_cocci/ast0_cocci.ml
index a06d99ae..bf2b5633 100644
--- a/parsing_cocci/ast0_cocci.ml
+++ b/parsing_cocci/ast0_cocci.ml
@@ -255,7 +255,8 @@ and base_declaration =
   | TyDecl of typeC * string mcode (* ; *)
   | MacroDecl of Ast.storage mcode option *
 	ident (* name *) * string mcode (* ( *) *
-        expression dots * string mcode (* ) *) * string mcode (* ; *)
+        expression dots * string mcode (* ) *) *
+        attr list * string mcode (* ; *)
   | MacroDeclInit of Ast.storage mcode option *
 	ident (* name *) * string mcode (* ( *) *
         expression dots * string mcode (* ) *) * string mcode (*=*) *
diff --git a/parsing_cocci/ast0_cocci.mli b/parsing_cocci/ast0_cocci.mli
index 5c2520be..e2a9a9d8 100644
--- a/parsing_cocci/ast0_cocci.mli
+++ b/parsing_cocci/ast0_cocci.mli
@@ -243,7 +243,8 @@ and base_declaration =
   | TyDecl of typeC * string mcode (* ; *)
   | MacroDecl of Ast_cocci.storage mcode option *
 	ident (* name *) * string mcode (* ( *) *
-        expression dots * string mcode (* ) *) * string mcode (* ; *)
+        expression dots * string mcode (* ) *) *
+        attr list * string mcode (* ; *)
   | MacroDeclInit of Ast_cocci.storage mcode option *
 	ident (* name *) * string mcode (* ( *) *
         expression dots * string mcode (* ) *) * 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] 31+ messages in thread

* [Linux-kernel-mentees] [PATCH 02/30] parsing_cocci: parser: Parse Macrodecl attributes
  2020-05-24 17:19 [Linux-kernel-mentees] [PATCH 00/30] cocci: Add macrodecl attributes to C and SmPL ASTs Jaskaran Singh
  2020-05-24 17:19 ` [Linux-kernel-mentees] [PATCH 01/30] parsing_cocci: ast0_cocci: Add Macrodecl attributes Jaskaran Singh
@ 2020-05-24 17:19 ` Jaskaran Singh
  2020-05-24 17:19 ` [Linux-kernel-mentees] [PATCH 03/30] parsing_cocci: visitor_ast0: Visit " Jaskaran Singh
                   ` (27 subsequent siblings)
  29 siblings, 0 replies; 31+ messages in thread
From: Jaskaran Singh @ 2020-05-24 17:19 UTC (permalink / raw)
  To: cocci; +Cc: julia.lawall, jaskaransingh7654321, linux-kernel-mentees

Macrodecl attributes are added to the SmPL ASTs. Parse these attributes
in the SmPL parser and place them in the SmPL AST. The added production
only supports attributes before the semicolon.

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 db5661bd..d5d5df8c 100644
--- a/parsing_cocci/parser_cocci_menhir.mly
+++ b/parsing_cocci/parser_cocci_menhir.mly
@@ -1710,9 +1710,9 @@ decl_var:
       [Ast0.wrap(Ast0.Init(s,fn idtype,id,a,P.clt2mcode "=" q,e,
 			   P.clt2mcode ";" pv))] }
   | s=ioption(storage) d=decl_ident o=TOPar e=eexpr_list_option c=TCPar
-      p=TPtVirg
+      ar=attr_list p=TPtVirg
       { [Ast0.wrap(Ast0.MacroDecl(s,d,P.clt2mcode "(" o,e,
-				  P.clt2mcode ")" c,P.clt2mcode ";" p))] }
+				  P.clt2mcode ")" c,ar,P.clt2mcode ";" p))] }
   | s=ioption(storage)
       d=decl_ident o=TOPar e=eexpr_list_option c=TCPar q=TEq i=initialize
       p=TPtVirg
@@ -1758,9 +1758,9 @@ one_decl_var:
       Ast0.wrap(Ast0.Init(s,fn idtype,id,a,P.clt2mcode "=" q,e,
 			   P.clt2mcode ";" pv)) }
   | s=ioption(storage) d=decl_ident o=TOPar e=eexpr_list_option c=TCPar
-      p=TPtVirg
+      ar=attr_list p=TPtVirg
       { Ast0.wrap(Ast0.MacroDecl(s,d,P.clt2mcode "(" o,e,
-				  P.clt2mcode ")" c,P.clt2mcode ";" p)) }
+				  P.clt2mcode ")" c,ar,P.clt2mcode ";" p)) }
   | s=ioption(storage)
       d=decl_ident o=TOPar e=eexpr_list_option c=TCPar q=TEq i=initialize
       p=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] 31+ messages in thread

* [Linux-kernel-mentees] [PATCH 03/30] parsing_cocci: visitor_ast0: Visit Macrodecl attributes
  2020-05-24 17:19 [Linux-kernel-mentees] [PATCH 00/30] cocci: Add macrodecl attributes to C and SmPL ASTs Jaskaran Singh
  2020-05-24 17:19 ` [Linux-kernel-mentees] [PATCH 01/30] parsing_cocci: ast0_cocci: Add Macrodecl attributes Jaskaran Singh
  2020-05-24 17:19 ` [Linux-kernel-mentees] [PATCH 02/30] parsing_cocci: parser: Parse " Jaskaran Singh
@ 2020-05-24 17:19 ` Jaskaran Singh
  2020-05-24 17:19 ` [Linux-kernel-mentees] [PATCH 04/30] parsing_cocci: unparse_ast0: Reflect " Jaskaran Singh
                   ` (26 subsequent siblings)
  29 siblings, 0 replies; 31+ messages in thread
From: Jaskaran Singh @ 2020-05-24 17:19 UTC (permalink / raw)
  To: cocci; +Cc: julia.lawall, jaskaransingh7654321, linux-kernel-mentees

Macrodecl attributes are added to the SmPL AST. Visit these attributes
the AST0 visitor of SmPL.

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

diff --git a/parsing_cocci/visitor_ast0.ml b/parsing_cocci/visitor_ast0.ml
index d9e340ed..edc8ff78 100644
--- a/parsing_cocci/visitor_ast0.ml
+++ b/parsing_cocci/visitor_ast0.ml
@@ -637,15 +637,16 @@ let visitor mode bind option_default
 	    let (sem_n,sem) = string_mcode sem in
 	    (multibind [fi_n;name_n;lp1_n;params_n;va_n;rp1_n;sem_n],
 	     Ast0.FunProto(fi,name,lp1,params,va,rp1,sem))
-	| Ast0.MacroDecl(stg,name,lp,args,rp,sem) ->
+	| Ast0.MacroDecl(stg,name,lp,args,rp,attr,sem) ->
 	    let (stg_n,stg) = get_option storage_mcode stg in
 	    let (name_n,name) = ident name in
 	    let (lp_n,lp) = string_mcode lp in
 	    let (args_n,args) = expression_dots args in
 	    let (rp_n,rp) = string_mcode rp in
+	    let (attr_n,attr) = map_split_bind string_mcode attr in
 	    let (sem_n,sem) = string_mcode sem in
-	    (multibind [stg_n;name_n;lp_n;args_n;rp_n;sem_n],
-	     Ast0.MacroDecl(stg,name,lp,args,rp,sem))
+	    (multibind [stg_n;name_n;lp_n;args_n;rp_n;attr_n;sem_n],
+	     Ast0.MacroDecl(stg,name,lp,args,rp,attr,sem))
 	| Ast0.MacroDeclInit(stg,name,lp,args,rp,eq,ini,sem) ->
 	    let (stg_n,stg) = get_option storage_mcode stg in
 	    let (name_n,name) = ident name 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] 31+ messages in thread

* [Linux-kernel-mentees] [PATCH 04/30] parsing_cocci: unparse_ast0: Reflect Macrodecl attributes
  2020-05-24 17:19 [Linux-kernel-mentees] [PATCH 00/30] cocci: Add macrodecl attributes to C and SmPL ASTs Jaskaran Singh
                   ` (2 preceding siblings ...)
  2020-05-24 17:19 ` [Linux-kernel-mentees] [PATCH 03/30] parsing_cocci: visitor_ast0: Visit " Jaskaran Singh
@ 2020-05-24 17:19 ` Jaskaran Singh
  2020-05-24 17:19 ` [Linux-kernel-mentees] [PATCH 05/30] parsing_cocci: index: " Jaskaran Singh
                   ` (25 subsequent siblings)
  29 siblings, 0 replies; 31+ messages in thread
From: Jaskaran Singh @ 2020-05-24 17:19 UTC (permalink / raw)
  To: cocci; +Cc: julia.lawall, jaskaransingh7654321, linux-kernel-mentees

Macrodecl 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 | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/parsing_cocci/unparse_ast0.ml b/parsing_cocci/unparse_ast0.ml
index fdaf6cfa..4e2a09f9 100644
--- a/parsing_cocci/unparse_ast0.ml
+++ b/parsing_cocci/unparse_ast0.ml
@@ -422,11 +422,14 @@ and declaration d =
 	  parameter_list params; varargs va;
 	  close_box(); mcode print_string rp1;
 	  mcode print_string sem
-      | Ast0.MacroDecl(stg,name,lp,args,rp,sem) ->
+      | Ast0.MacroDecl(stg,name,lp,args,rp,attr,sem) ->
 	  print_option (mcode U.storage) stg;
 	  ident name; mcode print_string_box lp;
 	  let _ = dots (function _ -> ()) expression args in
-	  close_box(); mcode print_string rp; mcode print_string sem
+	  close_box(); mcode print_string rp;
+	  (if not (attr = []) then print_string " ");
+	  print_between (fun _ -> print_string " ") (mcode print_string) attr;
+	  mcode print_string sem
       | Ast0.MacroDeclInit(stg,name,lp,args,rp,eq,ini,sem) ->
 	  print_option (mcode U.storage) stg;
 	  ident name; mcode print_string_box lp;
-- 
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] 31+ messages in thread

* [Linux-kernel-mentees] [PATCH 05/30] parsing_cocci: index: Reflect Macrodecl attributes
  2020-05-24 17:19 [Linux-kernel-mentees] [PATCH 00/30] cocci: Add macrodecl attributes to C and SmPL ASTs Jaskaran Singh
                   ` (3 preceding siblings ...)
  2020-05-24 17:19 ` [Linux-kernel-mentees] [PATCH 04/30] parsing_cocci: unparse_ast0: Reflect " Jaskaran Singh
@ 2020-05-24 17:19 ` Jaskaran Singh
  2020-05-24 17:19 ` [Linux-kernel-mentees] [PATCH 06/30] parsing_cocci: iso_pattern: " Jaskaran Singh
                   ` (24 subsequent siblings)
  29 siblings, 0 replies; 31+ messages in thread
From: Jaskaran Singh @ 2020-05-24 17:19 UTC (permalink / raw)
  To: cocci; +Cc: julia.lawall, jaskaransingh7654321, linux-kernel-mentees

Macrodecl 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 6bda797e..3d74fc41 100644
--- a/parsing_cocci/index.ml
+++ b/parsing_cocci/index.ml
@@ -117,7 +117,7 @@ let declaration d =
   | Ast0.Init(stg,ty,id,attr,eq,exp,sem) -> [54]
   | Ast0.UnInit(stg,ty,id,attr,sem) -> [55]
   | Ast0.FunProto(fi,name,lp1,params,va,rp1,sem) -> [132]
-  | Ast0.MacroDecl(stg,name,lp,args,rp,sem) -> [137]
+  | 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.Typedef(stg,ty,id,sem) -> [143]
-- 
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] 31+ messages in thread

* [Linux-kernel-mentees] [PATCH 06/30] parsing_cocci: iso_pattern: Reflect Macrodecl attributes
  2020-05-24 17:19 [Linux-kernel-mentees] [PATCH 00/30] cocci: Add macrodecl attributes to C and SmPL ASTs Jaskaran Singh
                   ` (4 preceding siblings ...)
  2020-05-24 17:19 ` [Linux-kernel-mentees] [PATCH 05/30] parsing_cocci: index: " Jaskaran Singh
@ 2020-05-24 17:19 ` Jaskaran Singh
  2020-05-24 17:19 ` [Linux-kernel-mentees] [PATCH 07/30] parsing_cocci: type_infer: " Jaskaran Singh
                   ` (23 subsequent siblings)
  29 siblings, 0 replies; 31+ messages in thread
From: Jaskaran Singh @ 2020-05-24 17:19 UTC (permalink / raw)
  To: cocci; +Cc: julia.lawall, jaskaransingh7654321, linux-kernel-mentees

Macrodecl 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, 6 insertions(+), 3 deletions(-)

diff --git a/parsing_cocci/iso_pattern.ml b/parsing_cocci/iso_pattern.ml
index 9df21fb9..ebb83e23 100644
--- a/parsing_cocci/iso_pattern.ml
+++ b/parsing_cocci/iso_pattern.ml
@@ -965,9 +965,12 @@ let match_maker checks_needed context_required whencode_allowed =
 		     params1 params;
                    match_option varargs_equal va1a va1b
                  ]
-	  | (Ast0.MacroDecl(stga,namea,lp1,argsa,rp1,sc1),
-	     Ast0.MacroDecl(stgb,nameb,lp,argsb,rp,sc)) ->
-	       if bool_match_option mcode_equal stga stgb
+	  | (Ast0.MacroDecl(stga,namea,lp1,argsa,rp1,attra,sc1),
+	     Ast0.MacroDecl(stgb,nameb,lp,argsb,rp,attrb,sc)) ->
+	       if bool_match_option mcode_equal stga stgb &&
+                 (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_many_bindings
 		   [match_ident namea nameb;
-- 
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] 31+ messages in thread

* [Linux-kernel-mentees] [PATCH 07/30] parsing_cocci: type_infer: Reflect Macrodecl attributes
  2020-05-24 17:19 [Linux-kernel-mentees] [PATCH 00/30] cocci: Add macrodecl attributes to C and SmPL ASTs Jaskaran Singh
                   ` (5 preceding siblings ...)
  2020-05-24 17:19 ` [Linux-kernel-mentees] [PATCH 06/30] parsing_cocci: iso_pattern: " Jaskaran Singh
@ 2020-05-24 17:19 ` Jaskaran Singh
  2020-05-24 17:19 ` [Linux-kernel-mentees] [PATCH 08/30] parsing_cocci: arity: " Jaskaran Singh
                   ` (22 subsequent siblings)
  29 siblings, 0 replies; 31+ messages in thread
From: Jaskaran Singh @ 2020-05-24 17:19 UTC (permalink / raw)
  To: cocci; +Cc: julia.lawall, jaskaransingh7654321, linux-kernel-mentees

Macrodecl 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 e8aad810..34c4aa31 100644
--- a/parsing_cocci/type_infer.ml
+++ b/parsing_cocci/type_infer.ml
@@ -380,7 +380,7 @@ let rec propagate_types env =
     | Ast0.UnInit(_,ty,id,_,_) ->
 	List.map (function i -> (i,ty)) (strip id)
     | Ast0.FunProto(fi,nm,lp,params,va,rp,sem) -> []
-    | Ast0.MacroDecl(_,_,_,_,_,_) -> []
+    | Ast0.MacroDecl(_,_,_,_,_,_,_) -> []
     | Ast0.MacroDeclInit(_,_,_,_,_,_,exp,_) ->
         let _ = (propagate_types env).VT0.combiner_rec_initialiser exp 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] 31+ messages in thread

* [Linux-kernel-mentees] [PATCH 08/30] parsing_cocci: arity: Reflect Macrodecl attributes
  2020-05-24 17:19 [Linux-kernel-mentees] [PATCH 00/30] cocci: Add macrodecl attributes to C and SmPL ASTs Jaskaran Singh
                   ` (6 preceding siblings ...)
  2020-05-24 17:19 ` [Linux-kernel-mentees] [PATCH 07/30] parsing_cocci: type_infer: " Jaskaran Singh
@ 2020-05-24 17:19 ` Jaskaran Singh
  2020-05-24 17:19 ` [Linux-kernel-mentees] [PATCH 09/30] parsing_cocci: check_meta: " Jaskaran Singh
                   ` (21 subsequent siblings)
  29 siblings, 0 replies; 31+ messages in thread
From: Jaskaran Singh @ 2020-05-24 17:19 UTC (permalink / raw)
  To: cocci; +Cc: julia.lawall, jaskaransingh7654321, linux-kernel-mentees

Macrodecl 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 | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/parsing_cocci/arity.ml b/parsing_cocci/arity.ml
index 8ee6d33f..1c74aa8b 100644
--- a/parsing_cocci/arity.ml
+++ b/parsing_cocci/arity.ml
@@ -595,7 +595,7 @@ and declaration tgt decl =
       let rp1 = mcode rp1 in
       let sem = mcode sem in
       make_decl decl tgt arity (Ast0.FunProto(fi,name,lp1,params,va,rp1,sem))
-  | Ast0.MacroDecl(stg,name,lp,args,rp,sem) ->
+  | Ast0.MacroDecl(stg,name,lp,args,rp,attr,sem) ->
       let arity =
 	all_same true tgt (mcode2line lp)
 	  ((match stg with None -> [] | Some x -> [mcode2arity x]) @
@@ -605,8 +605,9 @@ and declaration tgt decl =
       let lp = mcode lp in
       let args = dots (expression arity) args in
       let rp = mcode rp in
+      let attr = List.map mcode attr in
       let sem = mcode sem in
-      make_decl decl tgt arity (Ast0.MacroDecl(stg,name,lp,args,rp,sem))
+      make_decl decl tgt arity (Ast0.MacroDecl(stg,name,lp,args,rp,attr,sem))
   | Ast0.MacroDeclInit(stg,name,lp,args,rp,eq,ini,sem) ->
       let arity =
 	all_same true tgt (mcode2line lp)
-- 
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] 31+ messages in thread

* [Linux-kernel-mentees] [PATCH 09/30] parsing_cocci: check_meta: Reflect Macrodecl attributes
  2020-05-24 17:19 [Linux-kernel-mentees] [PATCH 00/30] cocci: Add macrodecl attributes to C and SmPL ASTs Jaskaran Singh
                   ` (7 preceding siblings ...)
  2020-05-24 17:19 ` [Linux-kernel-mentees] [PATCH 08/30] parsing_cocci: arity: " Jaskaran Singh
@ 2020-05-24 17:19 ` Jaskaran Singh
  2020-05-24 17:19 ` [Linux-kernel-mentees] [PATCH 10/30] parsing_cocci: compute_lines: " Jaskaran Singh
                   ` (20 subsequent siblings)
  29 siblings, 0 replies; 31+ messages in thread
From: Jaskaran Singh @ 2020-05-24 17:19 UTC (permalink / raw)
  To: cocci; +Cc: julia.lawall, jaskaransingh7654321, linux-kernel-mentees

Macrodecl 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 | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/parsing_cocci/check_meta.ml b/parsing_cocci/check_meta.ml
index 5a348ba3..da159a36 100644
--- a/parsing_cocci/check_meta.ml
+++ b/parsing_cocci/check_meta.ml
@@ -281,7 +281,8 @@ and declaration context old_metas table minus d =
       ident FN old_metas table minus name;
       List.iter (fninfo old_metas table minus) fi;
       parameter_list old_metas table minus params
-  | Ast0.MacroDecl(stg,name,lp,args,rp,sem) ->
+  | Ast0.MacroDecl(stg,name,lp,args,rp,attr,sem) ->
+      (* no meta attribute yet *)
       ident GLOBAL old_metas table minus name;
       dots (expression ID old_metas table minus) args
   | Ast0.MacroDeclInit(stg,name,lp,args,rp,eq,ini,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] 31+ messages in thread

* [Linux-kernel-mentees] [PATCH 10/30] parsing_cocci: compute_lines: Reflect Macrodecl attributes
  2020-05-24 17:19 [Linux-kernel-mentees] [PATCH 00/30] cocci: Add macrodecl attributes to C and SmPL ASTs Jaskaran Singh
                   ` (8 preceding siblings ...)
  2020-05-24 17:19 ` [Linux-kernel-mentees] [PATCH 09/30] parsing_cocci: check_meta: " Jaskaran Singh
@ 2020-05-24 17:19 ` Jaskaran Singh
  2020-05-24 17:19 ` [Linux-kernel-mentees] [PATCH 11/30] parsing_cocci: context_neg: " Jaskaran Singh
                   ` (19 subsequent siblings)
  29 siblings, 0 replies; 31+ messages in thread
From: Jaskaran Singh @ 2020-05-24 17:19 UTC (permalink / raw)
  To: cocci; +Cc: julia.lawall, jaskaransingh7654321, linux-kernel-mentees

Macrodecl 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 | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/parsing_cocci/compute_lines.ml b/parsing_cocci/compute_lines.ml
index 1361d842..d4124d15 100644
--- a/parsing_cocci/compute_lines.ml
+++ b/parsing_cocci/compute_lines.ml
@@ -715,19 +715,20 @@ and declaration d =
 	| Ast0.FType(ty)::_ -> mkres d res ty right
 	| Ast0.FInline(inline)::_ -> mkres d res (promote_mcode inline) right
 	| Ast0.FAttr(attr)::_ -> mkres d res (promote_mcode attr) right)
-  | Ast0.MacroDecl(stg,name,lp,args,rp,sem) ->
+  | Ast0.MacroDecl(stg,name,lp,args,rp,attr,sem) ->
       let name = ident name in
       let lp = normal_mcode lp in
       let args = dots is_exp_dots (Some(promote_mcode lp)) expression args in
       let rp = normal_mcode rp in
+      let attr = List.map normal_mcode attr in
       let sem = normal_mcode sem in
       (match stg with
 	None ->
-	  mkres d (Ast0.MacroDecl(None,name,lp,args,rp,sem))
+	  mkres d (Ast0.MacroDecl(None,name,lp,args,rp,attr,sem))
 	    name (promote_mcode sem)
       | Some x ->
 	  let stg = Some (normal_mcode x) in
-	  mkres d (Ast0.MacroDecl(stg,name,lp,args,rp,sem))
+	  mkres d (Ast0.MacroDecl(stg,name,lp,args,rp,attr,sem))
 	    (promote_mcode x) (promote_mcode sem))
   | Ast0.MacroDeclInit(stg,name,lp,args,rp,eq,ini,sem) ->
       let name = ident name 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] 31+ messages in thread

* [Linux-kernel-mentees] [PATCH 11/30] parsing_cocci: context_neg: Reflect Macrodecl attributes
  2020-05-24 17:19 [Linux-kernel-mentees] [PATCH 00/30] cocci: Add macrodecl attributes to C and SmPL ASTs Jaskaran Singh
                   ` (9 preceding siblings ...)
  2020-05-24 17:19 ` [Linux-kernel-mentees] [PATCH 10/30] parsing_cocci: compute_lines: " Jaskaran Singh
@ 2020-05-24 17:19 ` Jaskaran Singh
  2020-05-24 17:19 ` [Linux-kernel-mentees] [PATCH 12/30] parsing_cocci: single_statement: " Jaskaran Singh
                   ` (18 subsequent siblings)
  29 siblings, 0 replies; 31+ messages in thread
From: Jaskaran Singh @ 2020-05-24 17:19 UTC (permalink / raw)
  To: cocci; +Cc: julia.lawall, jaskaransingh7654321, linux-kernel-mentees

Macrodecl 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 | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/parsing_cocci/context_neg.ml b/parsing_cocci/context_neg.ml
index dd768a61..4b1376cf 100644
--- a/parsing_cocci/context_neg.ml
+++ b/parsing_cocci/context_neg.ml
@@ -752,9 +752,9 @@ let equal_declaration d1 d2 =
        List.for_all2 equal_fninfo fninfo1 fninfo2 &&
        equal_mcode lp1 lp2 && equal_varargs va1 va2 &&
        equal_mcode rp1 rp2 && equal_mcode sem1 sem2
-  | (Ast0.MacroDecl(stg1,nm1,lp1,_,rp1,sem1),
-     Ast0.MacroDecl(stg2,nm2,lp2,_,rp2,sem2)) ->
-      equal_option stg1 stg2 &&
+  | (Ast0.MacroDecl(stg1,nm1,lp1,_,rp1,attr1,sem1),
+     Ast0.MacroDecl(stg2,nm2,lp2,_,rp2,attr2,sem2)) ->
+      equal_option stg1 stg2 && List.for_all2 equal_mcode 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)) ->
-- 
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] 31+ messages in thread

* [Linux-kernel-mentees] [PATCH 12/30] parsing_cocci: single_statement: Reflect Macrodecl attributes
  2020-05-24 17:19 [Linux-kernel-mentees] [PATCH 00/30] cocci: Add macrodecl attributes to C and SmPL ASTs Jaskaran Singh
                   ` (10 preceding siblings ...)
  2020-05-24 17:19 ` [Linux-kernel-mentees] [PATCH 11/30] parsing_cocci: context_neg: " Jaskaran Singh
@ 2020-05-24 17:19 ` Jaskaran Singh
  2020-05-24 17:19 ` [Linux-kernel-mentees] [PATCH 13/30] parsing_cocci: ast_cocci: " Jaskaran Singh
                   ` (17 subsequent siblings)
  29 siblings, 0 replies; 31+ messages in thread
From: Jaskaran Singh @ 2020-05-24 17:19 UTC (permalink / raw)
  To: cocci; +Cc: julia.lawall, jaskaransingh7654321, linux-kernel-mentees

Macrodecl 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 | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/parsing_cocci/single_statement.ml b/parsing_cocci/single_statement.ml
index 4ad1c4e4..a75dc755 100644
--- a/parsing_cocci/single_statement.ml
+++ b/parsing_cocci/single_statement.ml
@@ -200,8 +200,8 @@ and left_declaration d =
   | Ast0.FunProto(fninfo,name,lp1,params,va,rp1,sem) ->
       (* should not be nested in anything anyway *)
       false
-  | Ast0.MacroDecl(Some stg,name,lp,args,rp,sem) -> modif_before_mcode stg
-  | Ast0.MacroDecl(None,name,lp,args,rp,sem) -> left_ident name
+  | Ast0.MacroDecl(Some stg,name,lp,args,rp,attr,sem) -> modif_before_mcode stg
+  | Ast0.MacroDecl(None,name,lp,args,rp,attr,sem) -> left_ident name
   | 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
@@ -219,7 +219,7 @@ and right_declaration d =
   | Ast0.Init(_,ty,id,eq,ini,attr,sem) -> modif_after_mcode sem
   | Ast0.UnInit(_,ty,id,attr,sem) -> modif_after_mcode sem
   | Ast0.FunProto(fninfo,name,lp1,params,va,rp1,sem) -> modif_after_mcode sem
-  | Ast0.MacroDecl(_,name,lp,args,rp,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.Typedef(stg,ty,id,sem) -> modif_after_mcode 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] 31+ messages in thread

* [Linux-kernel-mentees] [PATCH 13/30] parsing_cocci: ast_cocci: Reflect Macrodecl attributes
  2020-05-24 17:19 [Linux-kernel-mentees] [PATCH 00/30] cocci: Add macrodecl attributes to C and SmPL ASTs Jaskaran Singh
                   ` (11 preceding siblings ...)
  2020-05-24 17:19 ` [Linux-kernel-mentees] [PATCH 12/30] parsing_cocci: single_statement: " Jaskaran Singh
@ 2020-05-24 17:19 ` Jaskaran Singh
  2020-05-24 17:19 ` [Linux-kernel-mentees] [PATCH 14/30] parsing_cocci: visitor_ast: " Jaskaran Singh
                   ` (16 subsequent siblings)
  29 siblings, 0 replies; 31+ messages in thread
From: Jaskaran Singh @ 2020-05-24 17:19 UTC (permalink / raw)
  To: cocci; +Cc: julia.lawall, jaskaransingh7654321, linux-kernel-mentees

Add macrodecl attributes to the SmPL AST. This is a list of attributes
in the Macrodecl type of the SmPL AST.

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

diff --git a/parsing_cocci/ast_cocci.ml b/parsing_cocci/ast_cocci.ml
index 9b147e5c..87bd017a 100644
--- a/parsing_cocci/ast_cocci.ml
+++ b/parsing_cocci/ast_cocci.ml
@@ -399,7 +399,8 @@ and base_declaration =
   | TyDecl of fullType * string mcode (* ; *)
   | MacroDecl of storage mcode option *
 	ident (* name *) * string mcode (* ( *) *
-        expression dots * string mcode (* ) *) * string mcode (* ; *)
+        expression dots * string mcode (* ) *) *
+        attr list * string mcode (* ; *)
   | MacroDeclInit of storage mcode option *
 	ident (* name *) * string mcode (* ( *) *
         expression dots * string mcode (* ) *) * string mcode (*=*) *
diff --git a/parsing_cocci/ast_cocci.mli b/parsing_cocci/ast_cocci.mli
index c56bba88..5d04430c 100644
--- a/parsing_cocci/ast_cocci.mli
+++ b/parsing_cocci/ast_cocci.mli
@@ -381,7 +381,8 @@ and base_declaration =
   | TyDecl of fullType * string mcode (* ; *)
   | MacroDecl of storage mcode option *
 	ident (* name *) * string mcode (* ( *) *
-        expression dots * string mcode (* ) *) * string mcode (* ; *)
+        expression dots * string mcode (* ) *) *
+        attr list * string mcode (* ; *)
   | MacroDeclInit of storage mcode option *
 	ident (* name *) * string mcode (* ( *) *
         expression dots * string mcode (* ) *) * 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] 31+ messages in thread

* [Linux-kernel-mentees] [PATCH 14/30] parsing_cocci: visitor_ast: Reflect Macrodecl attributes
  2020-05-24 17:19 [Linux-kernel-mentees] [PATCH 00/30] cocci: Add macrodecl attributes to C and SmPL ASTs Jaskaran Singh
                   ` (12 preceding siblings ...)
  2020-05-24 17:19 ` [Linux-kernel-mentees] [PATCH 13/30] parsing_cocci: ast_cocci: " Jaskaran Singh
@ 2020-05-24 17:19 ` Jaskaran Singh
  2020-05-24 17:19 ` [Linux-kernel-mentees] [PATCH 15/30] parsing_cocci: pretty_print_cocci: " Jaskaran Singh
                   ` (15 subsequent siblings)
  29 siblings, 0 replies; 31+ messages in thread
From: Jaskaran Singh @ 2020-05-24 17:19 UTC (permalink / raw)
  To: cocci; +Cc: julia.lawall, jaskaransingh7654321, linux-kernel-mentees

Macrodecl attributes are added to the SmPL AST. Visit these attributes
in the SmPL 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 8e530114..9746b085 100644
--- a/parsing_cocci/visitor_ast.ml
+++ b/parsing_cocci/visitor_ast.ml
@@ -470,14 +470,15 @@ let combiner bind option_default
 	  let lrp1 = string_mcode rp1 in
 	  multibind
 	    (lfi @ [lname; llp1; lparams] @ lcomma @ lellipsis @ [lrp1])
-      | Ast.MacroDecl(stg,name,lp,args,rp,sem) ->
+      | Ast.MacroDecl(stg,name,lp,args,rp,attr,sem) ->
 	  let lstg = get_option storage_mcode stg in
 	  let lname = ident name in
 	  let llp = string_mcode lp in
 	  let largs = expression_dots args in
 	  let lrp = string_mcode rp in
+	  let lattr = multibind (List.map string_mcode attr) in
 	  let lsem = string_mcode sem in
-	  multibind [lstg; lname; llp; largs; lrp; lsem]
+	  multibind [lstg; lname; llp; largs; lrp; lattr; lsem]
       | Ast.MacroDeclInit(stg,name,lp,args,rp,eq,ini,sem) ->
 	  let lstg = get_option storage_mcode stg in
 	  let lname = ident name in
@@ -1417,14 +1418,15 @@ let rebuilder
 	    let lrp = string_mcode rp in
 	    let lsem = string_mcode sem in
 	    Ast.FunProto(lfi,lname,llp,lparams,lva,lrp,lsem)
-	| Ast.MacroDecl(stg,name,lp,args,rp,sem) ->
+	| Ast.MacroDecl(stg,name,lp,args,rp,attr,sem) ->
 	    let lstg = get_option storage_mcode stg in
 	    let lname = ident name in
 	    let llp = string_mcode lp in
 	    let largs = expression_dots args in
 	    let lrp = string_mcode rp in
+	    let lattr = List.map string_mcode attr in
 	    let lsem = string_mcode sem in
-	    Ast.MacroDecl(lstg, lname, llp, largs, lrp, lsem)
+	    Ast.MacroDecl(lstg, lname, llp, largs, lrp, lattr, lsem)
 	| Ast.MacroDeclInit(stg,name,lp,args,rp,eq,ini,sem) ->
 	    let lstg = get_option storage_mcode stg in
 	    let lname = ident name 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] 31+ messages in thread

* [Linux-kernel-mentees] [PATCH 15/30] parsing_cocci: pretty_print_cocci: Reflect Macrodecl attributes
  2020-05-24 17:19 [Linux-kernel-mentees] [PATCH 00/30] cocci: Add macrodecl attributes to C and SmPL ASTs Jaskaran Singh
                   ` (13 preceding siblings ...)
  2020-05-24 17:19 ` [Linux-kernel-mentees] [PATCH 14/30] parsing_cocci: visitor_ast: " Jaskaran Singh
@ 2020-05-24 17:19 ` Jaskaran Singh
  2020-05-24 17:19 ` [Linux-kernel-mentees] [PATCH 16/30] parsing_cocci: disjdistr: " Jaskaran Singh
                   ` (14 subsequent siblings)
  29 siblings, 0 replies; 31+ messages in thread
From: Jaskaran Singh @ 2020-05-24 17:19 UTC (permalink / raw)
  To: cocci; +Cc: julia.lawall, jaskaransingh7654321, linux-kernel-mentees

Macrodecl attributes are added to the SmPL AST. Reflect these changes in
pretty_print_cocci.ml.

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

diff --git a/parsing_cocci/pretty_print_cocci.ml b/parsing_cocci/pretty_print_cocci.ml
index 7628882b..0046737e 100644
--- a/parsing_cocci/pretty_print_cocci.ml
+++ b/parsing_cocci/pretty_print_cocci.ml
@@ -565,10 +565,13 @@ and declaration d =
       parameter_list params; varargs va;
       close_box(); mcode print_string rp1;
       mcode print_string sem
-  | Ast.MacroDecl(stg,name,lp,args,rp,sem) ->
+  | Ast.MacroDecl(stg,name,lp,args,rp,attr,sem) ->
       print_option (mcode storage) stg; ident name; mcode print_string_box lp;
       dots (function _ -> ()) expression args;
-      close_box(); mcode print_string rp; mcode print_string sem
+      close_box(); mcode print_string rp;
+      (if not (attr = []) then print_string " ");
+      print_between print_space (mcode print_string) attr;
+      mcode print_string sem
   | Ast.MacroDeclInit(stg,name,lp,args,rp,eq,ini,sem) ->
       print_option (mcode storage) stg; ident name; mcode print_string_box lp;
       dots (function _ -> ()) expression args;
-- 
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] 31+ messages in thread

* [Linux-kernel-mentees] [PATCH 16/30] parsing_cocci: disjdistr: Reflect Macrodecl attributes
  2020-05-24 17:19 [Linux-kernel-mentees] [PATCH 00/30] cocci: Add macrodecl attributes to C and SmPL ASTs Jaskaran Singh
                   ` (14 preceding siblings ...)
  2020-05-24 17:19 ` [Linux-kernel-mentees] [PATCH 15/30] parsing_cocci: pretty_print_cocci: " Jaskaran Singh
@ 2020-05-24 17:19 ` Jaskaran Singh
  2020-05-24 17:19 ` [Linux-kernel-mentees] [PATCH 17/30] parsing_cocci: adjust_pragmas: " Jaskaran Singh
                   ` (13 subsequent siblings)
  29 siblings, 0 replies; 31+ messages in thread
From: Jaskaran Singh @ 2020-05-24 17:19 UTC (permalink / raw)
  To: cocci; +Cc: julia.lawall, jaskaransingh7654321, linux-kernel-mentees

Macrodecl 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 6724bb25..8a42743a 100644
--- a/parsing_cocci/disjdistr.ml
+++ b/parsing_cocci/disjdistr.ml
@@ -342,10 +342,10 @@ and disjdecl d =
       disjmult2 (disjmult disjfninfo fninfo) (disjident name)
 	(fun fninfo name ->
 	  Ast.rewrap d (Ast.FunProto(fninfo,name,lp1,params,va,rp1,sem)))
-  | Ast.MacroDecl(stg,name,lp,args,rp,sem) ->
+  | Ast.MacroDecl(stg,name,lp,args,rp,attr,sem) ->
       disjmult2 (disjident name) (disjdots disjexp args)
 	(fun name args ->
-	  Ast.rewrap d (Ast.MacroDecl(stg,name,lp,args,rp,sem)))
+	  Ast.rewrap d (Ast.MacroDecl(stg,name,lp,args,rp,attr,sem)))
   | Ast.MacroDeclInit(stg,name,lp,args,rp,eq,ini,sem) ->
       disjmult3 (disjident name) (disjdots disjexp args) (disjini ini)
 	(fun name args ini ->
-- 
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] 31+ messages in thread

* [Linux-kernel-mentees] [PATCH 17/30] parsing_cocci: adjust_pragmas: Reflect Macrodecl attributes
  2020-05-24 17:19 [Linux-kernel-mentees] [PATCH 00/30] cocci: Add macrodecl attributes to C and SmPL ASTs Jaskaran Singh
                   ` (15 preceding siblings ...)
  2020-05-24 17:19 ` [Linux-kernel-mentees] [PATCH 16/30] parsing_cocci: disjdistr: " Jaskaran Singh
@ 2020-05-24 17:19 ` Jaskaran Singh
  2020-05-24 17:19 ` [Linux-kernel-mentees] [PATCH 18/30] parsing_cocci: unify_ast: " Jaskaran Singh
                   ` (12 subsequent siblings)
  29 siblings, 0 replies; 31+ messages in thread
From: Jaskaran Singh @ 2020-05-24 17:19 UTC (permalink / raw)
  To: cocci; +Cc: julia.lawall, jaskaransingh7654321, linux-kernel-mentees

Macrodecl 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 | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/parsing_cocci/adjust_pragmas.ml b/parsing_cocci/adjust_pragmas.ml
index 63038bca..e5597943 100644
--- a/parsing_cocci/adjust_pragmas.ml
+++ b/parsing_cocci/adjust_pragmas.ml
@@ -54,9 +54,9 @@ let rec right_decl d =
   | Ast0.FunProto(fninfo,id,lp1,params,va,rp1,sem) ->
       call_right right_mcode sem d
 	(function ty -> Ast0.FunProto(fninfo,id,lp1,params,va,rp1,sem))
-  | Ast0.MacroDecl(stg,name,lp,args,rp,sem) ->
+  | Ast0.MacroDecl(stg,name,lp,args,rp,attr,sem) ->
       call_right right_mcode sem d
-	(function sem -> Ast0.MacroDecl(stg,name,lp,args,rp,sem))
+	(function sem -> Ast0.MacroDecl(stg,name,lp,args,rp,attr,sem))
   | 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))
@@ -279,12 +279,12 @@ let rec left_decl decl =
 	  call_right left_mcode attr decl
 	    (function attr ->
 	      Ast0.FunProto((Ast0.FAttr attr)::x,name,lp1,params,va,rp1,sem)))
-  | Ast0.MacroDecl(Some stg,name,lp,args,rp,sem) ->
+  | Ast0.MacroDecl(Some stg,name,lp,args,rp,attr,sem) ->
       call_right left_mcode stg decl
-	(function stg -> Ast0.MacroDecl(Some stg,name,lp,args,rp,sem))
-  | Ast0.MacroDecl(None,name,lp,args,rp,sem) ->
+	(function stg -> Ast0.MacroDecl(Some stg,name,lp,args,rp,attr,sem))
+  | Ast0.MacroDecl(None,name,lp,args,rp,attr,sem) ->
       call_right left_ident name decl
-	(function name -> Ast0.MacroDecl(None,name,lp,args,rp,sem))
+	(function name -> Ast0.MacroDecl(None,name,lp,args,rp,attr,sem))
   | Ast0.MacroDeclInit(Some stg,name,lp,args,rp,eq,ini,sem) ->
       call_right left_mcode stg decl
 	(function stg ->
-- 
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] 31+ messages in thread

* [Linux-kernel-mentees] [PATCH 18/30] parsing_cocci: unify_ast: Reflect Macrodecl attributes
  2020-05-24 17:19 [Linux-kernel-mentees] [PATCH 00/30] cocci: Add macrodecl attributes to C and SmPL ASTs Jaskaran Singh
                   ` (16 preceding siblings ...)
  2020-05-24 17:19 ` [Linux-kernel-mentees] [PATCH 17/30] parsing_cocci: adjust_pragmas: " Jaskaran Singh
@ 2020-05-24 17:19 ` Jaskaran Singh
  2020-05-24 17:19 ` [Linux-kernel-mentees] [PATCH 19/30] parsing_cocci: ast0toast: " Jaskaran Singh
                   ` (11 subsequent siblings)
  29 siblings, 0 replies; 31+ messages in thread
From: Jaskaran Singh @ 2020-05-24 17:19 UTC (permalink / raw)
  To: cocci; +Cc: julia.lawall, jaskaransingh7654321, linux-kernel-mentees

Macrodecl 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 | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/parsing_cocci/unify_ast.ml b/parsing_cocci/unify_ast.ml
index 68cb6613..c4a6e0ce 100644
--- a/parsing_cocci/unify_ast.ml
+++ b/parsing_cocci/unify_ast.ml
@@ -409,8 +409,8 @@ and unify_declaration d1 d2 =
 	  unify_ident nm1 nm2 &&
 	  unify_dots unify_parameterTypeDef pdots params1 params2
        else false
-  | (Ast.MacroDecl(s1,n1,lp1,args1,rp1,sem1),
-     Ast.MacroDecl(s2,n2,lp2,args2,rp2,sem2)) ->
+  | (Ast.MacroDecl(s1,n1,lp1,args1,rp1,attr1,sem1),
+     Ast.MacroDecl(s2,n2,lp2,args2,rp2,attr2,sem2)) ->
        if bool_unify_option unify_mcode s1 s2
        then
 	 unify_ident n1 n2 &&
-- 
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] 31+ messages in thread

* [Linux-kernel-mentees] [PATCH 19/30] parsing_cocci: ast0toast: Reflect Macrodecl attributes
  2020-05-24 17:19 [Linux-kernel-mentees] [PATCH 00/30] cocci: Add macrodecl attributes to C and SmPL ASTs Jaskaran Singh
                   ` (17 preceding siblings ...)
  2020-05-24 17:19 ` [Linux-kernel-mentees] [PATCH 18/30] parsing_cocci: unify_ast: " Jaskaran Singh
@ 2020-05-24 17:19 ` Jaskaran Singh
  2020-05-24 17:19 ` [Linux-kernel-mentees] [PATCH 20/30] parsing_c: ast_c: Add " Jaskaran Singh
                   ` (10 subsequent siblings)
  29 siblings, 0 replies; 31+ messages in thread
From: Jaskaran Singh @ 2020-05-24 17:19 UTC (permalink / raw)
  To: cocci; +Cc: julia.lawall, jaskaransingh7654321, linux-kernel-mentees

Macrodecl 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 09c28c06..7ca7bd3f 100644
--- a/parsing_cocci/ast0toast.ml
+++ b/parsing_cocci/ast0toast.ml
@@ -657,15 +657,16 @@ and declaration d =
 	  let rp = mcode rp in
 	  let sem = mcode sem in
 	  Ast.FunProto(fi,name,lp,params,va,rp,sem)
-    | Ast0.MacroDecl(stg,name,lp,args,rp,sem) ->
+    | Ast0.MacroDecl(stg,name,lp,args,rp,attr,sem) ->
 	(* this would seem to need allminus... *)
 	let stg = get_option mcode stg in
 	let name = ident name in
 	let lp = mcode lp in
 	let args = dots expression args in
 	let rp = mcode rp in
+	let attr = List.map mcode attr in
 	let sem = mcode sem in
-	Ast.MacroDecl(stg,name,lp,args,rp,sem)
+	Ast.MacroDecl(stg,name,lp,args,rp,attr,sem)
     | Ast0.MacroDeclInit(stg,name,lp,args,rp,eq,ini,sem) ->
 	(* this would seem to need allminus... *)
 	let stg = get_option mcode stg 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] 31+ messages in thread

* [Linux-kernel-mentees] [PATCH 20/30] parsing_c: ast_c: Add Macrodecl attributes
  2020-05-24 17:19 [Linux-kernel-mentees] [PATCH 00/30] cocci: Add macrodecl attributes to C and SmPL ASTs Jaskaran Singh
                   ` (18 preceding siblings ...)
  2020-05-24 17:19 ` [Linux-kernel-mentees] [PATCH 19/30] parsing_cocci: ast0toast: " Jaskaran Singh
@ 2020-05-24 17:19 ` Jaskaran Singh
  2020-05-24 17:19 ` [Linux-kernel-mentees] [PATCH 21/30] parsing_c: parser_c: Reflect " Jaskaran Singh
                   ` (9 subsequent siblings)
  29 siblings, 0 replies; 31+ messages in thread
From: Jaskaran Singh @ 2020-05-24 17:19 UTC (permalink / raw)
  To: cocci; +Cc: julia.lawall, jaskaransingh7654321, linux-kernel-mentees

Add cast attributes to the C AST. This is a list of attributes in the
Macrodecl type of the C AST.

Signed-off-by: Jaskaran Singh <jaskaransingh7654321@gmail.com>
---
 parsing_c/ast_c.ml  | 3 ++-
 parsing_c/ast_c.mli | 4 +++-
 2 files changed, 5 insertions(+), 2 deletions(-)

diff --git a/parsing_c/ast_c.ml b/parsing_c/ast_c.ml
index 204bd412..f666d33c 100644
--- a/parsing_c/ast_c.ml
+++ b/parsing_c/ast_c.ml
@@ -561,7 +561,8 @@ and declaration =
   (* cppext: *)
     (* bool is true if there is a ; at the end *)
   | MacroDecl of
-      (storagebis * string * argument wrap2 list * bool) wrap (* fakestart *)
+      (storagebis * string * argument wrap2 list * attribute list * bool)
+        wrap (* fakestart *)
   | MacroDeclInit of
       (storagebis * string * argument wrap2 list * initialiser)
 	wrap (* fakestart *)
diff --git a/parsing_c/ast_c.mli b/parsing_c/ast_c.mli
index 5411bbb3..95da1f5f 100644
--- a/parsing_c/ast_c.mli
+++ b/parsing_c/ast_c.mli
@@ -201,7 +201,9 @@ and exec_code_bis = ExecEval of expression | ExecToken
 and exec_code = exec_code_bis wrap
 and declaration =
     DeclList of onedecl wrap2 list wrap
-  | MacroDecl of (storagebis * string * argument wrap2 list * bool) wrap
+  | MacroDecl of
+      (storagebis * string * argument wrap2 list * attribute list * bool)
+        wrap
   | MacroDeclInit of
       (storagebis * string * argument wrap2 list * initialiser) wrap
 and onedecl = {
-- 
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] 31+ messages in thread

* [Linux-kernel-mentees] [PATCH 21/30] parsing_c: parser_c: Reflect Macrodecl attributes
  2020-05-24 17:19 [Linux-kernel-mentees] [PATCH 00/30] cocci: Add macrodecl attributes to C and SmPL ASTs Jaskaran Singh
                   ` (19 preceding siblings ...)
  2020-05-24 17:19 ` [Linux-kernel-mentees] [PATCH 20/30] parsing_c: ast_c: Add " Jaskaran Singh
@ 2020-05-24 17:19 ` Jaskaran Singh
  2020-05-24 17:19 ` [Linux-kernel-mentees] [PATCH 22/30] parsing_c: visitor_c: " Jaskaran Singh
                   ` (8 subsequent siblings)
  29 siblings, 0 replies; 31+ messages in thread
From: Jaskaran Singh @ 2020-05-24 17:19 UTC (permalink / raw)
  To: cocci; +Cc: julia.lawall, jaskaransingh7654321, linux-kernel-mentees

Macrodecl attributes are added to the C AST. Parse these attributes in
the C parser and place them in the C AST.

Signed-off-by: Jaskaran Singh <jaskaransingh7654321@gmail.com>
---
 parsing_c/parser_c.mly | 23 ++++++++++++++++-------
 1 file changed, 16 insertions(+), 7 deletions(-)

diff --git a/parsing_c/parser_c.mly b/parsing_c/parser_c.mly
index aedde179..dadf675f 100644
--- a/parsing_c/parser_c.mly
+++ b/parsing_c/parser_c.mly
@@ -1600,10 +1600,11 @@ decl2:
        match $1 with
 	 Some (sto,stoii) ->
 	   MacroDecl
-	     ((sto, fst $2, $4, true), (snd $2::$3::$5::$6::fakeInfo()::stoii))
+             ((sto, fst $2, $4, [], true),
+              (snd $2::$3::$5::$6::fakeInfo()::stoii))
        | None ->
 	   MacroDecl
-	     ((NoSto, fst $2, $4, true), [snd $2;$3;$5;$6;fakeInfo()]) }
+             ((NoSto, fst $2, $4, [], true), [snd $2;$3;$5;$6;fakeInfo()]) }
 
  | storage_const_opt TMacroDecl TOPar argument_list TCPar end_attributes
    TPtVirg
@@ -1611,10 +1612,12 @@ decl2:
        match $1 with
 	 Some (sto,stoii) ->
 	   MacroDecl
-	     ((sto, fst $2, $4, true), (snd $2::$3::$5::$7::fakeInfo()::stoii))
+	     ((sto, fst $2, $4, $6, true),
+              (snd $2::$3::$5::$7::fakeInfo()::stoii))
        | None ->
 	   MacroDecl
-	     ((NoSto, fst $2, $4, true), [snd $2;$3;$5;$7;fakeInfo()]) }
+	     ((NoSto, fst $2, $4, $6, true),
+              [snd $2;$3;$5;$7;fakeInfo()]) }
 
  | storage_const_opt
      TMacroDecl TOPar argument_list TCPar teq initialize TPtVirg
@@ -2265,7 +2268,9 @@ cpp_other:
                    ($5::iistart::snd sto)))
        else
 	 Declaration
-	   (MacroDecl((NoSto, fst $1, $3, true), [snd $1;$2;$4;$5;fakeInfo()]))
+	   (MacroDecl
+             ((NoSto, fst $1, $3, Ast_c.noattr, true),
+               [snd $1;$2;$4;$5;fakeInfo()]))
            (* old: MacroTop (fst $1, $3,    [snd $1;$2;$4;$5])  *)
      }
 
@@ -2295,7 +2300,9 @@ cpp_other:
                    ($6::iistart::snd sto)))
        else
 	 Declaration
-	   (MacroDecl((NoSto, fst $1, $3, true), [snd $1;$2;$4;$6;fakeInfo()]))
+	   (MacroDecl
+             ((NoSto, fst $1, $3, $5, true),
+              [snd $1;$2;$4;$6;fakeInfo()]))
            (* old: MacroTop (fst $1, $3,    [snd $1;$2;$4;$5])  *)
      }
 
@@ -2321,7 +2328,9 @@ cpp_other:
  /*(* TCParEOL to fix the end-of-stream bug of ocamlyacc *)*/
  | identifier TOPar argument_list TCParEOL
      { Declaration
-	 (MacroDecl ((NoSto, fst $1, $3, false), [snd $1;$2;$4;fakeInfo()])) }
+	 (MacroDecl
+           ((NoSto, fst $1, $3, Ast_c.noattr, false),
+            [snd $1;$2;$4;fakeInfo()])) }
 
   /*(* ex: EXPORT_NO_SYMBOLS; *)*/
  | identifier TPtVirg { EmptyDef [snd $1;$2] }
-- 
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] 31+ messages in thread

* [Linux-kernel-mentees] [PATCH 22/30] parsing_c: visitor_c: Reflect Macrodecl attributes
  2020-05-24 17:19 [Linux-kernel-mentees] [PATCH 00/30] cocci: Add macrodecl attributes to C and SmPL ASTs Jaskaran Singh
                   ` (20 preceding siblings ...)
  2020-05-24 17:19 ` [Linux-kernel-mentees] [PATCH 21/30] parsing_c: parser_c: Reflect " Jaskaran Singh
@ 2020-05-24 17:19 ` Jaskaran Singh
  2020-05-24 17:19 ` [Linux-kernel-mentees] [PATCH 23/30] parsing_c: pretty_print_c: " Jaskaran Singh
                   ` (7 subsequent siblings)
  29 siblings, 0 replies; 31+ messages in thread
From: Jaskaran Singh @ 2020-05-24 17:19 UTC (permalink / raw)
  To: cocci; +Cc: julia.lawall, jaskaransingh7654321, linux-kernel-mentees

Macrodecl attributes are added to the C AST. Visit these attributes in
the C AST visitor.

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

diff --git a/parsing_c/visitor_c.ml b/parsing_c/visitor_c.ml
index 57b5f32b..3cc73ea8 100644
--- a/parsing_c/visitor_c.ml
+++ b/parsing_c/visitor_c.ml
@@ -548,8 +548,9 @@ and vk_decl = fun bigf d ->
         iif ii;
         vk_onedecl bigf x
       );
-    | MacroDecl ((_stob, s, args, ptvg),ii) ->
+    | MacroDecl ((_stob, s, args, attrs, ptvg),ii) ->
         iif ii;
+        attrs +> List.iter (vk_attribute bigf);
         vk_argument_list bigf args
     | MacroDeclInit ((_stob, s, args, ini),ii) ->
         iif ii;
@@ -1464,10 +1465,11 @@ and vk_decl_s = fun bigf d ->
     | DeclList (xs, ii) ->
         DeclList (List.map (fun (x,ii) -> (vk_onedecl_s bigf x, iif ii)) xs,
 		  iif ii)
-    | MacroDecl ((stob, s, args, ptvg),ii) ->
+    | MacroDecl ((stob, s, args, attrs, ptvg),ii) ->
         MacroDecl
           ((stob, s,
            args +> List.map (fun (e,ii) -> vk_argument_s bigf e, iif ii),
+           attrs +> List.map (vk_attribute_s bigf),
            ptvg),
           iif ii)
     | MacroDeclInit ((stob, s, args, ini),ii) ->
-- 
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] 31+ messages in thread

* [Linux-kernel-mentees] [PATCH 23/30] parsing_c: pretty_print_c: Reflect Macrodecl attributes
  2020-05-24 17:19 [Linux-kernel-mentees] [PATCH 00/30] cocci: Add macrodecl attributes to C and SmPL ASTs Jaskaran Singh
                   ` (21 preceding siblings ...)
  2020-05-24 17:19 ` [Linux-kernel-mentees] [PATCH 22/30] parsing_c: visitor_c: " Jaskaran Singh
@ 2020-05-24 17:19 ` Jaskaran Singh
  2020-05-24 17:19 ` [Linux-kernel-mentees] [PATCH 24/30] parsing_c: unparse_cocci: " Jaskaran Singh
                   ` (6 subsequent siblings)
  29 siblings, 0 replies; 31+ messages in thread
From: Jaskaran Singh @ 2020-05-24 17:19 UTC (permalink / raw)
  To: cocci; +Cc: julia.lawall, jaskaransingh7654321, linux-kernel-mentees

Macrodecl attributes are added to the C AST. Print these changes in
pretty_print_c.ml.

Signed-off-by: Jaskaran Singh <jaskaransingh7654321@gmail.com>
---
 parsing_c/pretty_print_c.ml | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/parsing_c/pretty_print_c.ml b/parsing_c/pretty_print_c.ml
index b9b9b929..4faa188d 100644
--- a/parsing_c/pretty_print_c.ml
+++ b/parsing_c/pretty_print_c.ml
@@ -1043,7 +1043,8 @@ and pp_string_format (e,ii) =
 
 	pr_elem iivirg;
 
-    | MacroDecl ((sto, s, es, true), iis::lp::rp::iiend::ifakestart::iisto) ->
+    | MacroDecl
+      ((sto, s, es, attrs, true), iis::lp::rp::iiend::ifakestart::iisto) ->
 	pr_elem ifakestart;
 	iisto +> List.iter pr_elem; (* static and const *)
 	pr_elem iis;
@@ -1053,11 +1054,11 @@ and pp_string_format (e,ii) =
           opt +> List.iter pr_elem;
           pp_argument e;
 	);
-
 	pr_elem rp;
 	pr_elem iiend;
 
-    | MacroDecl ((sto, s, es, false), iis::lp::rp::ifakestart::iisto) ->
+    | MacroDecl
+      ((sto, s, es, attrs, false), iis::lp::rp::ifakestart::iisto) ->
 	pr_elem ifakestart;
 	iisto +> List.iter pr_elem; (* static and const *)
 	pr_elem iis;
-- 
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] 31+ messages in thread

* [Linux-kernel-mentees] [PATCH 24/30] parsing_c: unparse_cocci: Reflect Macrodecl attributes
  2020-05-24 17:19 [Linux-kernel-mentees] [PATCH 00/30] cocci: Add macrodecl attributes to C and SmPL ASTs Jaskaran Singh
                   ` (22 preceding siblings ...)
  2020-05-24 17:19 ` [Linux-kernel-mentees] [PATCH 23/30] parsing_c: pretty_print_c: " Jaskaran Singh
@ 2020-05-24 17:19 ` Jaskaran Singh
  2020-05-24 17:19 ` [Linux-kernel-mentees] [PATCH 25/30] engine: check_exhaustive_pattern: " Jaskaran Singh
                   ` (5 subsequent siblings)
  29 siblings, 0 replies; 31+ messages in thread
From: Jaskaran Singh @ 2020-05-24 17:19 UTC (permalink / raw)
  To: cocci; +Cc: julia.lawall, jaskaransingh7654321, linux-kernel-mentees

Macrodecl 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 | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/parsing_c/unparse_cocci.ml b/parsing_c/unparse_cocci.ml
index 395b3a3c..903dc785 100644
--- a/parsing_c/unparse_cocci.ml
+++ b/parsing_c/unparse_cocci.ml
@@ -936,12 +936,15 @@ and declaration d =
       end;
       close_box(); mcode print_string rp1;
       mcode print_string sem
-  | Ast.MacroDecl(stg,name,lp,args,rp,sem) ->
+  | Ast.MacroDecl(stg,name,lp,args,rp,attr,sem) ->
       print_option (mcode storage) stg;
       print_option (function _ -> pr_space()) stg;
       ident name; mcode print_string_box lp;
       dots (function _ -> ()) arg_expression args;
-      close_box(); mcode print_string rp; mcode print_string sem
+      close_box(); mcode print_string rp;
+      (if not (attr = []) then pr_space());
+      print_between pr_space (mcode print_string) attr;
+      mcode print_string sem
   | Ast.MacroDeclInit(stg,name,lp,args,rp,eq,ini,sem) ->
       print_option (mcode storage) stg;
       print_option (function _ -> pr_space()) stg;
-- 
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] 31+ messages in thread

* [Linux-kernel-mentees] [PATCH 25/30] engine: check_exhaustive_pattern: Reflect Macrodecl attributes
  2020-05-24 17:19 [Linux-kernel-mentees] [PATCH 00/30] cocci: Add macrodecl attributes to C and SmPL ASTs Jaskaran Singh
                   ` (23 preceding siblings ...)
  2020-05-24 17:19 ` [Linux-kernel-mentees] [PATCH 24/30] parsing_c: unparse_cocci: " Jaskaran Singh
@ 2020-05-24 17:19 ` Jaskaran Singh
  2020-05-24 17:19 ` [Linux-kernel-mentees] [PATCH 26/30] engine: cocci_vs_c: Match " Jaskaran Singh
                   ` (4 subsequent siblings)
  29 siblings, 0 replies; 31+ messages in thread
From: Jaskaran Singh @ 2020-05-24 17:19 UTC (permalink / raw)
  To: cocci; +Cc: julia.lawall, jaskaransingh7654321, linux-kernel-mentees

Macrodecl 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 903c32ff..2f1ef4a3 100644
--- a/engine/check_exhaustive_pattern.ml
+++ b/engine/check_exhaustive_pattern.ml
@@ -63,7 +63,7 @@ let dumb_astcocci_decl = function
  | A.Init (stg, typa, sa, attr, _, expa, _) -> ()
  | A.FunProto _ -> ()
  | A.TyDecl (typa, _)     -> ()
- | A.MacroDecl(stg, fn, _, eas, _, _) -> ()
+ | A.MacroDecl(stg, fn, _, eas, _, _, _) -> ()
  | A.MacroDeclInit(stg, fn, _, eas, _, _, _, _) -> ()
  | A.MetaDecl _ -> ()
  | A.AsDecl _ -> ()
@@ -76,7 +76,7 @@ let dumb_astcocci_initialiser = function (* seems same as the above *)
     A.Init(stg,ty,id,attr,eq,ini,sem) -> ()
   | A.UnInit(stg,ty,id,attr,sem) -> ()
   | A.FunProto _ -> ()
-  | A.MacroDecl(_, fn, _, eas, _, _) -> ()
+  | A.MacroDecl(_, fn, _, eas, _, _, _) -> ()
   | A.MacroDeclInit(_, fn, _, eas, _, _, _, _) -> ()
   | A.TyDecl(ty,sem) -> ()
   | A.Typedef(d,ty1,ty2,pv) -> ()
-- 
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] 31+ messages in thread

* [Linux-kernel-mentees] [PATCH 26/30] engine: cocci_vs_c: Match Macrodecl attributes
  2020-05-24 17:19 [Linux-kernel-mentees] [PATCH 00/30] cocci: Add macrodecl attributes to C and SmPL ASTs Jaskaran Singh
                   ` (24 preceding siblings ...)
  2020-05-24 17:19 ` [Linux-kernel-mentees] [PATCH 25/30] engine: check_exhaustive_pattern: " Jaskaran Singh
@ 2020-05-24 17:19 ` Jaskaran Singh
  2020-05-24 17:19 ` [Linux-kernel-mentees] [PATCH 27/30] ocaml: coccilib: Reflect " Jaskaran Singh
                   ` (3 subsequent siblings)
  29 siblings, 0 replies; 31+ messages in thread
From: Jaskaran Singh @ 2020-05-24 17:19 UTC (permalink / raw)
  To: cocci; +Cc: julia.lawall, jaskaransingh7654321, linux-kernel-mentees

Macrodecl 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 | 23 +++++++++++++----------
 1 file changed, 13 insertions(+), 10 deletions(-)

diff --git a/engine/cocci_vs_c.ml b/engine/cocci_vs_c.ml
index 317fa71e..ca911765 100644
--- a/engine/cocci_vs_c.ml
+++ b/engine/cocci_vs_c.ml
@@ -2340,8 +2340,8 @@ and (declaration: (A.mcodekind * bool * A.declaration,B.declaration) matcher) =
 	      fail
 	end
 
-  | A.MacroDecl (stoa,sa,lpa,eas,rpa,enda),
-	B.MacroDecl ((stob,sb,ebs,true),ii) ->
+  | A.MacroDecl (stoa,sa,lpa,eas,rpa,attrsa,enda),
+	B.MacroDecl ((stob,sb,ebs,attrsb,true),ii) ->
       let (iisb, lpb, rpb, iiendb, iifakestart, iistob) =
         (match ii with
         | iisb::lpb::rpb::iiendb::iifakestart::iisto ->
@@ -2352,6 +2352,7 @@ and (declaration: (A.mcodekind * bool * A.declaration,B.declaration) matcher) =
           stoa ((stob, false), iistob) >>= (fun stoa ((stob, _), iistob) ->
         X.tokenf_mck mckstart iifakestart >>= (fun mckstart iifakestart ->
 	ident DontKnow sa (sb, iisb) >>= (fun sa (sb, iisb) ->
+	attribute_list allminus attrsa attrsb >>= (fun attrsa attrsb ->
         tokenf lpa lpb >>= (fun lpa lpb ->
         tokenf rpa rpb >>= (fun rpa rpb ->
         tokenf enda iiendb >>= (fun enda iiendb ->
@@ -2360,13 +2361,13 @@ and (declaration: (A.mcodekind * bool * A.declaration,B.declaration) matcher) =
 
           return (
             (mckstart, allminus,
-            (A.MacroDecl (stoa,sa,lpa,eas,rpa,enda)) +> A.rewrap decla),
-            (B.MacroDecl ((stob,sb,ebs,true),
+            (A.MacroDecl (stoa,sa,lpa,eas,rpa,attrsa,enda)) +> A.rewrap decla),
+            (B.MacroDecl ((stob,sb,ebs,attrsb,true),
                          [iisb;lpb;rpb;iiendb;iifakestart] @ iistob))
-          ))))))))
+          )))))))))
 
-  | A.MacroDecl (None,sa,lpa,eas,rpa,enda),
-      B.MacroDecl ((B.NoSto,sb,ebs,false),ii) ->
+  | A.MacroDecl (None,sa,lpa,eas,rpa,attrsa,enda),
+      B.MacroDecl ((B.NoSto,sb,ebs,attrsb,false),ii) ->
 	(* This is for macrodecls with no semicolons, which come from
 	   a parsing rule that deals with function prototypes with no
 	   return type.  That parsing rule would have a conflict if there
@@ -2383,6 +2384,7 @@ and (declaration: (A.mcodekind * bool * A.declaration,B.declaration) matcher) =
 	    X.tokenf_mck mckstart iifakestart >>=
 	    (fun mckstart iifakestart ->
 	      ident DontKnow sa (sb, iisb) >>= (fun sa (sb, iisb) ->
+	      attribute_list allminus attrsa attrsb >>= (fun attrsa attrsb ->
 	      tokenf lpa lpb >>= (fun lpa lpb ->
 	      tokenf rpa rpb >>= (fun rpa rpb ->
 	      arguments (seqstyle eas) (A.unwrap eas) ebs >>=
@@ -2391,10 +2393,11 @@ and (declaration: (A.mcodekind * bool * A.declaration,B.declaration) matcher) =
 
 		  return (
 		  (mckstart, allminus,
-		   (A.MacroDecl (None,sa,lpa,eas,rpa,enda)) +> A.rewrap decla),
-		  (B.MacroDecl ((B.NoSto,sb,ebs,false),
+		   (A.MacroDecl
+                     (None,sa,lpa,eas,rpa,attrsa,enda)) +> A.rewrap decla),
+		  (B.MacroDecl ((B.NoSto,sb,ebs,attrsb,false),
 				[iisb;lpb;rpb;iifakestart]))
-		  ))))))
+		  )))))))
       | _ -> fail)
 
   | A.MacroDeclInit (stoa,sa,lpa,eas,rpa,weqa,inia,enda),
-- 
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] 31+ messages in thread

* [Linux-kernel-mentees] [PATCH 27/30] ocaml: coccilib: Reflect Macrodecl attributes
  2020-05-24 17:19 [Linux-kernel-mentees] [PATCH 00/30] cocci: Add macrodecl attributes to C and SmPL ASTs Jaskaran Singh
                   ` (25 preceding siblings ...)
  2020-05-24 17:19 ` [Linux-kernel-mentees] [PATCH 26/30] engine: cocci_vs_c: Match " Jaskaran Singh
@ 2020-05-24 17:19 ` Jaskaran Singh
  2020-05-24 17:19 ` [Linux-kernel-mentees] [PATCH 28/30] tools: spgen: " Jaskaran Singh
                   ` (2 subsequent siblings)
  29 siblings, 0 replies; 31+ messages in thread
From: Jaskaran Singh @ 2020-05-24 17:19 UTC (permalink / raw)
  To: cocci; +Cc: julia.lawall, jaskaransingh7654321, linux-kernel-mentees

Macrodecl attributes are added to the C and SmPL ASTs. Reflect these
changes in coccilib.mli.

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

diff --git a/ocaml/coccilib.mli b/ocaml/coccilib.mli
index 5e31eec3..264c01b2 100644
--- a/ocaml/coccilib.mli
+++ b/ocaml/coccilib.mli
@@ -288,7 +288,9 @@ module Ast_c :
     and declaration =
       Ast_c.declaration =
         DeclList of onedecl wrap2 list wrap
-      | MacroDecl of (storagebis * string * argument wrap2 list * bool) wrap
+      | MacroDecl of
+          (storagebis * string * argument wrap2 list * attribute list * bool)
+            wrap
       | MacroDeclInit of
           (storagebis * string * argument wrap2 list * initialiser) wrap
     and onedecl =
@@ -2765,7 +2767,7 @@ module Ast_cocci :
           (string mcode * string mcode) option * string mcode * string mcode
       | TyDecl of fullType * string mcode
       | MacroDecl of storage mcode option * ident * string mcode *
-          expression dots * string mcode * string mcode
+          expression dots * string mcode * attr list * string mcode
       | MacroDeclInit of storage mcode option * ident * string mcode *
           expression dots * string mcode * string mcode * initialiser *
           string mcode
@@ -3400,7 +3402,7 @@ module Ast0_cocci :
           (string mcode * string mcode) option * string mcode * string mcode
       | TyDecl of typeC * string mcode
       | MacroDecl of Ast_cocci.storage mcode option * ident * string mcode *
-          expression dots * string mcode * string mcode
+          expression dots * string mcode * attr list * string mcode
       | MacroDeclInit of Ast_cocci.storage mcode option * ident *
           string mcode * expression dots * string mcode * string mcode *
           initialiser * 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] 31+ messages in thread

* [Linux-kernel-mentees] [PATCH 28/30] tools: spgen: Reflect Macrodecl attributes
  2020-05-24 17:19 [Linux-kernel-mentees] [PATCH 00/30] cocci: Add macrodecl attributes to C and SmPL ASTs Jaskaran Singh
                   ` (26 preceding siblings ...)
  2020-05-24 17:19 ` [Linux-kernel-mentees] [PATCH 27/30] ocaml: coccilib: Reflect " Jaskaran Singh
@ 2020-05-24 17:19 ` Jaskaran Singh
  2020-05-24 17:19 ` [Linux-kernel-mentees] [PATCH 29/30] tests: Add test case to remove macrodecl attributes Jaskaran Singh
  2020-05-24 17:19 ` [Linux-kernel-mentees] [PATCH 30/30] tests: Add test case to detect a macrodecl attribute Jaskaran Singh
  29 siblings, 0 replies; 31+ messages in thread
From: Jaskaran Singh @ 2020-05-24 17:19 UTC (permalink / raw)
  To: cocci; +Cc: julia.lawall, jaskaransingh7654321, linux-kernel-mentees

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

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

diff --git a/tools/spgen/source/meta_variable.ml b/tools/spgen/source/meta_variable.ml
index 2197a3f6..31456614 100644
--- a/tools/spgen/source/meta_variable.ml
+++ b/tools/spgen/source/meta_variable.ml
@@ -538,7 +538,7 @@ let metavar_combiner rn =
         meta_mc_format ~mc ~typ:"declaration " ~constr
     | Ast0.AsDecl(dc1, dc2) ->
         let dec = c.VT0.combiner_rec_declaration in as_format dc1 dc2 dec dec
-    | Ast0.MacroDecl(_, id, _, expdots, _, _) ->
+    | Ast0.MacroDecl(_, id, _, expdots, _, _, _) ->
         let expids = c.VT0.combiner_rec_expression_dots expdots in
         MVSet.union (ids ~rn ~typ:"declarer" ~id) expids
     | Ast0.MacroDeclInit(_, id, _, expdots, _, _, ini, _) ->
diff --git a/tools/spgen/source/position_generator.ml b/tools/spgen/source/position_generator.ml
index 757faf5f..618ba19b 100644
--- a/tools/spgen/source/position_generator.ml
+++ b/tools/spgen/source/position_generator.ml
@@ -419,8 +419,8 @@ let rec declaration_pos decl snp
   | Ast0.Typedef (tm, tc, tc2, sem) ->
       let constructor ~mc = Ast0.Typedef (mc, tc, tc2, sem) in
       mcode_wrap ~mc:tm ~constructor snp
-  | Ast0.MacroDecl (st,id,lp,ed,rp,sem) ->
-      let constructor ~id = Ast0.MacroDecl (st, id, lp, ed, rp, sem) in
+  | Ast0.MacroDecl (st,id,lp,ed,rp,attr,sem) ->
+      let constructor ~id = Ast0.MacroDecl (st, id, lp, ed, rp, attr, sem) in
       id_wrap ~id ~constructor snp
   | Ast0.MacroDeclInit (st,id,lp,ed,rp,eq,init,sem) ->
       let constructor ~id = Ast0.MacroDeclInit (st,id,lp,ed,rp,eq,init,sem) 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] 31+ messages in thread

* [Linux-kernel-mentees] [PATCH 29/30] tests: Add test case to remove macrodecl attributes
  2020-05-24 17:19 [Linux-kernel-mentees] [PATCH 00/30] cocci: Add macrodecl attributes to C and SmPL ASTs Jaskaran Singh
                   ` (27 preceding siblings ...)
  2020-05-24 17:19 ` [Linux-kernel-mentees] [PATCH 28/30] tools: spgen: " Jaskaran Singh
@ 2020-05-24 17:19 ` Jaskaran Singh
  2020-05-24 17:19 ` [Linux-kernel-mentees] [PATCH 30/30] tests: Add test case to detect a macrodecl attribute Jaskaran Singh
  29 siblings, 0 replies; 31+ messages in thread
From: Jaskaran Singh @ 2020-05-24 17:19 UTC (permalink / raw)
  To: cocci; +Cc: julia.lawall, jaskaransingh7654321, linux-kernel-mentees

Macrodecl attributes are added to the SmPL and C ASTs. Add a test case
to remove a macrodecl attribute.

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

diff --git a/tests/remove_macrodecl_attr.c b/tests/remove_macrodecl_attr.c
new file mode 100644
index 00000000..73ed6d63
--- /dev/null
+++ b/tests/remove_macrodecl_attr.c
@@ -0,0 +1,3 @@
+#define __macro_attr MACROANNOTATION
+
+DECLARER(a, b) __macro_attr;
diff --git a/tests/remove_macrodecl_attr.cocci b/tests/remove_macrodecl_attr.cocci
new file mode 100644
index 00000000..cd0c44bc
--- /dev/null
+++ b/tests/remove_macrodecl_attr.cocci
@@ -0,0 +1,8 @@
+@r0@
+declarer name DECLARER;
+attribute name __macro_attr;
+@@
+
+DECLARER(...)
+- __macro_attr
+;
diff --git a/tests/remove_macrodecl_attr.res b/tests/remove_macrodecl_attr.res
new file mode 100644
index 00000000..38e4add5
--- /dev/null
+++ b/tests/remove_macrodecl_attr.res
@@ -0,0 +1,3 @@
+#define __macro_attr MACROANNOTATION
+
+DECLARER(a, b);
-- 
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] 31+ messages in thread

* [Linux-kernel-mentees] [PATCH 30/30] tests: Add test case to detect a macrodecl attribute
  2020-05-24 17:19 [Linux-kernel-mentees] [PATCH 00/30] cocci: Add macrodecl attributes to C and SmPL ASTs Jaskaran Singh
                   ` (28 preceding siblings ...)
  2020-05-24 17:19 ` [Linux-kernel-mentees] [PATCH 29/30] tests: Add test case to remove macrodecl attributes Jaskaran Singh
@ 2020-05-24 17:19 ` Jaskaran Singh
  29 siblings, 0 replies; 31+ messages in thread
From: Jaskaran Singh @ 2020-05-24 17:19 UTC (permalink / raw)
  To: cocci; +Cc: julia.lawall, jaskaransingh7654321, linux-kernel-mentees

Macrodecl attributes are added to the SmPL and C ASTs. Add a test case
to detect a macrodecl attribute.

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

diff --git a/tests/detect_macrodecl_attr.c b/tests/detect_macrodecl_attr.c
new file mode 100644
index 00000000..3dd89410
--- /dev/null
+++ b/tests/detect_macrodecl_attr.c
@@ -0,0 +1,5 @@
+#define __macro_attr MACROANNOTATION
+
+DECLARER(a, b) __macro_attr;
+
+DECLARER(a, b);
diff --git a/tests/detect_macrodecl_attr.cocci b/tests/detect_macrodecl_attr.cocci
new file mode 100644
index 00000000..70182f49
--- /dev/null
+++ b/tests/detect_macrodecl_attr.cocci
@@ -0,0 +1,12 @@
+@r0@
+declarer name DECLARER;
+attribute name __macro_attr;
+@@
+
+DECLARER(
+	...,
+-	a
++	c
+	,
+	...
+  ) __macro_attr;
diff --git a/tests/detect_macrodecl_attr.res b/tests/detect_macrodecl_attr.res
new file mode 100644
index 00000000..6574a7ea
--- /dev/null
+++ b/tests/detect_macrodecl_attr.res
@@ -0,0 +1,5 @@
+#define __macro_attr MACROANNOTATION
+
+DECLARER(c, b) __macro_attr;
+
+DECLARER(a, b);
-- 
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] 31+ messages in thread

end of thread, other threads:[~2020-05-24 17:23 UTC | newest]

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