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 06/20] parsing_cocci: compute_lines: Wrap SmPL Attributes
Date: Fri,  3 Jul 2020 23:29:17 +0530	[thread overview]
Message-ID: <20200703175931.1693-7-jaskaran.singh@collabora.com> (raw)
In-Reply-To: <20200703175931.1693-1-jaskaran.singh@collabora.com>

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

Signed-off-by: Jaskaran Singh <jaskaran.singh@collabora.com>
---
 parsing_cocci/compute_lines.ml | 42 +++++++++++++++++++---------------
 1 file changed, 24 insertions(+), 18 deletions(-)

diff --git a/parsing_cocci/compute_lines.ml b/parsing_cocci/compute_lines.ml
index 4f273307..4420e952 100644
--- a/parsing_cocci/compute_lines.ml
+++ b/parsing_cocci/compute_lines.ml
@@ -428,7 +428,7 @@ let rec expression e =
   | Ast0.Cast(lp,ty,attr,rp,exp) ->
       let lp = normal_mcode lp in
       let exp = expression exp in
-      let attr = List.map normal_mcode attr in
+      let attr = List.map attribute attr in
       let rp = normal_mcode rp in
       mkres e (Ast0.Cast(lp,typeC ty,attr,rp,exp)) (promote_mcode lp) exp
   | Ast0.SizeOfExpr(szf,exp) ->
@@ -672,7 +672,7 @@ and declaration d =
   | Ast0.Init(stg,ty,id,attr,eq,exp,sem) ->
       let ty = typeC ty in
       let id = ident id in
-      let attr = List.map normal_mcode attr in
+      let attr = List.map attribute attr in
       let eq = normal_mcode eq in
       let exp = initialiser exp in
       let sem = normal_mcode sem in
@@ -686,7 +686,7 @@ and declaration d =
   | Ast0.UnInit(stg,ty,id,attr,sem) ->
       let ty = typeC ty in
       let id = ident id in
-      let attr = List.map normal_mcode attr in
+      let attr = List.map attribute attr in
       let sem = normal_mcode sem in
       (match stg with
 	None ->
@@ -715,13 +715,13 @@ and declaration d =
 	| Ast0.FStorage(stg)::_ -> mkres d res (promote_mcode stg) right
 	| 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.FAttr(attr)::_ -> mkres d res attr right)
   | 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 attr = List.map attribute attr in
       let sem = normal_mcode sem in
       (match stg with
 	None ->
@@ -749,7 +749,7 @@ and declaration d =
 	    (promote_mcode x) (promote_mcode sem))
   | Ast0.TyDecl(ty,attr,sem) ->
       let ty = typeC ty in
-      let attr = List.map normal_mcode attr in
+      let attr = List.map attribute attr in
       let sem = normal_mcode sem in
       mkres d (Ast0.TyDecl(ty,attr,sem)) ty (promote_mcode sem)
   | Ast0.Typedef(stg,ty,id,sem) ->
@@ -907,6 +907,13 @@ and initialiser_list prev = dots is_init_dots prev initialiser
 (* for export *)
 and initialiser_dots x = dots is_init_dots None initialiser x
 
+and attribute a =
+  match Ast0.unwrap a with
+    Ast0.Attribute(attr) ->
+      let ln = promote_mcode attr in
+      mkres a (Ast0.Attribute(attr)) ln ln
+
+
 (* --------------------------------------------------------------------- *)
 (* Parameter *)
 
@@ -918,30 +925,30 @@ and is_param_dots p =
 and parameterTypeDef p =
   match Ast0.unwrap p with
     Ast0.VoidParam(ty,attr) ->
-      let attr = List.map normal_mcode attr in
+      let attr = List.map attribute attr in
       let ty = typeC ty in
       (match attr with
         [] -> mkres p (Ast0.VoidParam(ty,attr)) ty ty
       | l ->
           let lattr = List.hd (List.rev l) in
-          mkres p (Ast0.VoidParam(ty,attr)) ty (promote_mcode lattr))
+          mkres p (Ast0.VoidParam(ty,attr)) ty lattr)
   | Ast0.Param(ty,Some id,attr) ->
       let id = ident id in
       let ty = typeC ty in
-      let attr = List.map normal_mcode attr in
+      let attr = List.map attribute attr in
       (match attr with
         [] -> mkres p (Ast0.Param(ty,Some id,attr)) ty id
       | l ->
           let lattr = List.hd (List.rev l) in
-          mkres p (Ast0.Param(ty,Some id,attr)) ty (promote_mcode lattr))
+          mkres p (Ast0.Param(ty,Some id,attr)) ty lattr)
   | Ast0.Param(ty,None,attr) ->
-      let attr = List.map normal_mcode attr in
+      let attr = List.map attribute attr in
       let ty = typeC ty in
       (match attr with
         [] -> mkres p (Ast0.Param(ty,None,attr)) ty ty
       | l ->
           let lattr = List.hd (List.rev l) in
-          mkres p (Ast0.Param(ty,None,attr)) ty (promote_mcode lattr))
+          mkres p (Ast0.Param(ty,None,attr)) ty lattr)
   | Ast0.MetaParam(name,a,b) ->
       let name = normal_mcode name in
       let ln = promote_mcode name in
@@ -1297,7 +1304,7 @@ let rec statement s =
 	| Ast0.FStorage(stg)::_ -> mkres s res (promote_mcode stg) right
 	| Ast0.FType(ty)::_ -> mkres s res ty right
 	| Ast0.FInline(inline)::_ -> mkres s res (promote_mcode inline) right
-	| Ast0.FAttr(attr)::_ -> mkres s res (promote_mcode attr) right)
+	| Ast0.FAttr(attr)::_ -> mkres s res attr right)
 
     | Ast0.Include(inc,stm) ->
 	let inc = normal_mcode inc in
@@ -1359,11 +1366,10 @@ and leftfninfo fninfo name bef = (* cases on what is leftmost *)
        Ast0.FInline(set_mcode_info inline (Ast0.get_info inlinfo))::rest,
        name)
   | Ast0.FAttr(attr)::rest ->
-      let (leftinfo,attrinfo) =
-	promote_to_statement_start (promote_mcode attr) bef in
-      (leftinfo,
-       Ast0.FAttr(set_mcode_info attr (Ast0.get_info attrinfo))::rest,
-       name)
+      let attr = attribute attr in
+      let (leftinfo,attr) =
+	promote_to_statement_start attr bef in
+      (leftinfo,Ast0.FAttr(attr)::rest,name)
 
 and pragmainfo pi =
   match Ast0.unwrap pi with
-- 
2.21.3

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

  parent reply	other threads:[~2020-07-03 18:03 UTC|newest]

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

Reply instructions:

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

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

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

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

  git send-email \
    --in-reply-to=20200703175931.1693-7-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).