cocci.inria.fr archive mirror
 help / color / mirror / Atom feed
From: Jaskaran Singh <jaskaran.singh@collabora.com>
To: cocci@systeme.lip6.fr
Subject: [Cocci] [PATCH v2 RESEND 11/20] parsing_cocci: ast0toast: Wrap SmPL Attributes
Date: Wed,  8 Jul 2020 18:30:26 +0530	[thread overview]
Message-ID: <20200708130035.26687-12-jaskaran.singh@collabora.com> (raw)
In-Reply-To: <20200708130035.26687-1-jaskaran.singh@collabora.com>

Attributes are wrapped in the SmPL AST. Reflect these changes in
ast0toast.ml.

Signed-off-by: Jaskaran Singh <jaskaran.singh@collabora.com>
---
 parsing_cocci/ast0toast.ml | 21 +++++++++++++--------
 1 file changed, 13 insertions(+), 8 deletions(-)

diff --git a/parsing_cocci/ast0toast.ml b/parsing_cocci/ast0toast.ml
index cba32af6..f0cad067 100644
--- a/parsing_cocci/ast0toast.ml
+++ b/parsing_cocci/ast0toast.ml
@@ -441,7 +441,7 @@ and expression e =
 	Ast.RecordPtAccess(expression exp,mcode ar,ident field)
     | Ast0.Cast(lp,ty,attr,rp,exp) ->
 	let allminus = check_allminus.VT0.combiner_rec_expression e in
-	let attr = List.map mcode attr in
+	let attr = List.map attribute attr in
 	Ast.Cast(mcode lp,typeC allminus ty,attr,mcode rp,expression exp)
     | Ast0.SizeOfExpr(szf,exp) ->
 	Ast.SizeOfExpr(mcode szf,expression exp)
@@ -637,14 +637,14 @@ and declaration d =
 	let stg = get_option mcode stg in
 	let ty = typeC allminus ty in
 	let id = ident id in
-	let attr = List.map mcode attr in
+	let attr = List.map attribute attr in
 	let eq = mcode eq in
 	let ini = initialiser ini in
 	let sem = mcode sem in
 	Ast.Init(stg,ty,id,attr,eq,ini,sem)
     | Ast0.UnInit(stg,ty,id,attr,sem) ->
 	let allminus = check_allminus.VT0.combiner_rec_declaration d in
-	let attr = List.map mcode attr in
+	let attr = List.map attribute attr in
 	Ast.UnInit(get_option mcode stg,typeC allminus ty,ident id,attr,
 		   mcode sem)
     | Ast0.FunProto(fi,name,lp,params,va,rp,sem) ->
@@ -665,7 +665,7 @@ and declaration d =
 	let lp = mcode lp in
 	let args = dots expression args in
 	let rp = mcode rp in
-	let attr = List.map mcode attr in
+	let attr = List.map attribute attr in
 	let sem = mcode sem in
 	Ast.MacroDecl(stg,name,lp,args,rp,attr,sem)
     | Ast0.MacroDeclInit(stg,name,lp,args,rp,eq,ini,sem) ->
@@ -681,7 +681,7 @@ and declaration d =
 	Ast.MacroDeclInit(stg,name,lp,args,rp,eq,ini,sem)
     | Ast0.TyDecl(ty,attr,sem) ->
 	let allminus = check_allminus.VT0.combiner_rec_declaration d in
-	let attr = List.map mcode attr in
+	let attr = List.map attribute 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
@@ -861,10 +861,10 @@ and parameterTypeDef p =
   rewrap p no_isos
     (match Ast0.unwrap p with
       Ast0.VoidParam(ty,attr) ->
-        Ast.VoidParam(typeC false ty,List.map mcode attr)
+        Ast.VoidParam(typeC false ty,List.map attribute attr)
     | Ast0.Param(ty,id,attr) ->
 	let allminus = check_allminus.VT0.combiner_rec_parameter p in
-	Ast.Param(typeC allminus ty,get_option ident id,List.map mcode attr)
+	Ast.Param(typeC allminus ty,get_option ident id,List.map attribute attr)
     | Ast0.MetaParam(name,cstr,_) ->
 	Ast.MetaParam(mcode name,constraints cstr,unitary,false)
     | Ast0.MetaParamList(name,lenname,cstr,_) ->
@@ -1195,7 +1195,12 @@ and fninfo = function
     Ast0.FStorage(stg) -> Ast.FStorage(mcode stg)
   | Ast0.FType(ty) -> Ast.FType(typeC false ty)
   | Ast0.FInline(inline) -> Ast.FInline(mcode inline)
-  | Ast0.FAttr(attr) -> Ast.FAttr(mcode attr)
+  | Ast0.FAttr(attr) -> Ast.FAttr(attribute attr)
+
+and attribute a =
+  rewrap a no_isos
+    (match Ast0.unwrap a with
+      Ast0.Attribute(attr) -> Ast.Attribute(mcode attr))
 
 and option_to_list = function
     Some x -> [x]
-- 
2.21.3

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

  parent reply	other threads:[~2020-07-08 13:01 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-07-08 13:00 [Cocci] [PATCH v2 RESEND 00/20] parsing_cocci: Wrap SmPL Attributes Jaskaran Singh
2020-07-08 13:00 ` [Cocci] [PATCH v2 RESEND 01/20] parsing_cocci: ast0_cocci: " Jaskaran Singh
2020-07-08 13:00 ` [Cocci] [PATCH v2 RESEND 02/20] parsing_cocci: parser: " Jaskaran Singh
2020-07-08 13:00 ` [Cocci] [PATCH v2 RESEND 03/20] parsing_cocci: visitor_ast0: " Jaskaran Singh
2020-07-08 13:00 ` [Cocci] [PATCH v2 RESEND 04/20] parsing_cocci: adjust_pragmas: " Jaskaran Singh
2020-07-08 13:00 ` [Cocci] [PATCH v2 RESEND 05/20] parsing_cocci: arity: " Jaskaran Singh
2020-07-08 13:00 ` [Cocci] [PATCH v2 RESEND 06/20] parsing_cocci: compute_lines: " Jaskaran Singh
2020-07-08 13:00 ` [Cocci] [PATCH v2 RESEND 07/20] parsing_cocci: context_neg: " Jaskaran Singh
2020-07-08 13:00 ` [Cocci] [PATCH v2 RESEND 08/20] parsing_cocci: iso_pattern: " Jaskaran Singh
2020-07-08 13:00 ` [Cocci] [PATCH v2 RESEND 09/20] parsing_cocci: index: " Jaskaran Singh
2020-07-08 13:00 ` [Cocci] [PATCH v2 RESEND 10/20] parsing_cocci: unparse_ast0: " Jaskaran Singh
2020-07-08 13:00 ` Jaskaran Singh [this message]
2020-07-08 13:00 ` [Cocci] [PATCH v2 RESEND 12/20] parsing_cocci: ast_cocci: " Jaskaran Singh
2020-07-08 13:00 ` [Cocci] [PATCH v2 RESEND 13/20] parsing_cocci: visitor_ast: " Jaskaran Singh
2020-07-08 13:00 ` [Cocci] [PATCH v2 RESEND 14/20] parsing_cocci: get_constants2: " Jaskaran Singh
2020-07-08 13:00 ` [Cocci] [PATCH v2 RESEND 15/20] parsing_cocci: safe_for_multi_decls: " Jaskaran Singh
2020-07-08 13:00 ` [Cocci] [PATCH v2 RESEND 16/20] parsing_cocci: unify_ast: " Jaskaran Singh
2020-07-08 13:00 ` [Cocci] [PATCH v2 RESEND 17/20] parsing_cocci: pretty_print_cocci: " Jaskaran Singh
2020-07-08 13:00 ` [Cocci] [PATCH v2 RESEND 18/20] parsing_c: unparse_cocci: " Jaskaran Singh
2020-07-08 13:00 ` [Cocci] [PATCH v2 RESEND 19/20] engine: cocci_vs_c: " Jaskaran Singh
2020-07-08 13:00 ` [Cocci] [PATCH v2 RESEND 20/20] ocaml: coccilib: " Jaskaran Singh
2020-07-08 18:22 ` [Cocci] [PATCH v2 RESEND 00/20] parsing_cocci: " Julia Lawall

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20200708130035.26687-12-jaskaran.singh@collabora.com \
    --to=jaskaran.singh@collabora.com \
    --cc=cocci@systeme.lip6.fr \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is 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).