linux-kernel-mentees.lists.linuxfoundation.org archive mirror
 help / color / mirror / Atom feed
From: Julia Lawall <julia.lawall@inria.fr>
To: Jaskaran Singh <jaskaransingh7654321@gmail.com>
Cc: linux-kernel-mentees@lists.linuxfoundation.org, cocci@systeme.lip6.fr
Subject: Re: [Linux-kernel-mentees] [PATCH 01/32] parsing_c: parser: Pass attribute list from type_name
Date: Mon, 4 May 2020 15:18:40 +0200 (CEST)	[thread overview]
Message-ID: <alpine.DEB.2.21.2005041517560.2425@hadrien> (raw)
In-Reply-To: <946de1fd2c3faacd4794c8cda8717847f95834bd.camel@gmail.com>



On Mon, 4 May 2020, Jaskaran Singh wrote:

> On Mon, 2020-05-04 at 11:17 +0200, Julia Lawall wrote:
> >
> > On Mon, 4 May 2020, Jaskaran Singh wrote:
> >
> > > On Sun, 2020-05-03 at 21:23 +0200, Julia Lawall wrote:
> > > > On Tue, 28 Apr 2020, Jaskaran Singh wrote:
> > > >
> > > > > To add Cast attributes to the C AST, pass attributes from the
> > > > > type_name
> > > > > rule of the C parser.
> > > >
> > > > I'm not sure what you mean by "pass".  Normally, one passes
> > > > something
> > > > to
> > > > something else, but it's not clear what the something else is.
> > > >
> > >
> > > The something else would be the cast_expr rule (and basically any
> > > other
> > > rule that uses the type_name rule).
> > >
> > > I guess a better way to say it would be "return the attributes from
> > > the
> > > type_name rule as well"
> >
> > This seems fine, thanks!
> >
> > In this patch there are a lot of places where the information is just
> > discarded.  Will it be used in the future?
> >
>
> We could add support for those attributes as well (ex. typeof, sizeof,
> etc.). This patch only adds support for cast attributes though.

OK.  I'm not sure that attributes make sense for sizeof.  Perhaps give a
warning rather than just dropping it.

julia

>
> Cheers,
> Jaskaran.
>
> > julia
> >
> > > (or if there is a specific term for it in
> > > parser-terminology, then that).
> > >
> > > Cheers,
> > > Jaskaran.
> > >
> > > > > Signed-off-by: Jaskaran Singh <jaskaransingh7654321@gmail.com>
> > > > > ---
> > > > >  ocaml/coccilib.mli     |  3 ++-
> > > > >  parsing_c/parse_c.ml   |  4 +++-
> > > > >  parsing_c/parser_c.mly | 16 ++++++++--------
> > > > >  3 files changed, 13 insertions(+), 10 deletions(-)
> > > > >
> > > > > diff --git a/ocaml/coccilib.mli b/ocaml/coccilib.mli
> > > > > index 0e807c9a..a305d616 100644
> > > > > --- a/ocaml/coccilib.mli
> > > > > +++ b/ocaml/coccilib.mli
> > > > > @@ -791,7 +791,8 @@ module Parser_c :
> > > > >        (Lexing.lexbuf -> token) -> Lexing.lexbuf ->
> > > > > Ast_c.statement
> > > > >      val expr : (Lexing.lexbuf -> token) -> Lexing.lexbuf ->
> > > > > Ast_c.expression
> > > > >      val type_name :
> > > > > -      (Lexing.lexbuf -> token) -> Lexing.lexbuf ->
> > > > > Ast_c.fullType
> > > > > +      (Lexing.lexbuf -> token) -> Lexing.lexbuf ->
> > > > > +      Ast_c.attribute list * Ast_c.fullType
> > > > >    end
> > > > >  module Lexer_c :
> > > > >    sig
> > > > > diff --git a/parsing_c/parse_c.ml b/parsing_c/parse_c.ml
> > > > > index 0d3a189a..5f8d5e2d 100644
> > > > > --- a/parsing_c/parse_c.ml
> > > > > +++ b/parsing_c/parse_c.ml
> > > > > @@ -370,7 +370,9 @@ let parse_gen ~cpp ~tos parsefunc s =
> > > > >    result
> > > > >
> > > > >  (* Please DO NOT remove this code, even though most of it is
> > > > > not
> > > > > used *)
> > > > > -let type_of_string       = parse_gen ~cpp:false ~tos:true
> > > > > Parser_c.type_name
> > > > > +let type_of_string s     =
> > > > > +  let typname = parse_gen ~cpp:false ~tos:true
> > > > > Parser_c.type_name
> > > > > s in
> > > > > +  Common.snd typname
> > > > >  let statement_of_string  = parse_gen ~cpp:false ~tos:false
> > > > > Parser_c.statement
> > > > >  let expression_of_string = parse_gen ~cpp:false ~tos:false
> > > > > Parser_c.expr
> > > > >  let cpp_expression_of_string = parse_gen ~cpp:true ~tos:false
> > > > > Parser_c.expr
> > > > > diff --git a/parsing_c/parser_c.mly b/parsing_c/parser_c.mly
> > > > > index aedde179..0abcc9b0 100644
> > > > > --- a/parsing_c/parser_c.mly
> > > > > +++ b/parsing_c/parser_c.mly
> > > > > @@ -665,7 +665,7 @@ let postfakeInfo pii  =
> > > > >
> > > > >  %type <Ast_c.statement> statement
> > > > >  %type <Ast_c.expression> expr
> > > > > -%type <Ast_c.fullType> type_name
> > > > > +%type <Ast_c.attribute list * Ast_c.fullType> type_name
> > > > >
> > > > >  %%
> > > > >  /*(***********************************************************
> > > > > ****
> > > > > **********)*/
> > > > > @@ -818,7 +818,7 @@ arith_expr:
> > > > >
> > > > >  cast_expr:
> > > > >   | unary_expr                        { $1 }
> > > > > - | topar2 type_name tcpar2 cast_expr { mk_e(Cast ($2, $4))
> > > > > [$1;$3]
> > > > > }
> > > > > + | topar2 type_name tcpar2 cast_expr { mk_e(Cast (snd $2, $4))
> > > > > [$1;$3] }
> > > > >  /*
> > > > >  It could be useful to have the following, but there is no
> > > > > place
> > > > > for the
> > > > >  attribute in the AST.
> > > > > @@ -831,7 +831,7 @@ unary_expr:
> > > > >   | TDec unary_expr                 { mk_e(Infix ($2,
> > > > > Dec))    [$1]
> > > > > }
> > > > >   | unary_op cast_expr              { mk_e(Unary ($2, fst $1))
> > > > > [snd
> > > > > $1] }
> > > > >   | Tsizeof unary_expr              { mk_e(SizeOfExpr
> > > > > ($2))    [$1]
> > > > > }
> > > > > - | Tsizeof topar2 type_name tcpar2 { mk_e(SizeOfType
> > > > > ($3))    [$1;$2;$4] }
> > > > > + | Tsizeof topar2 type_name tcpar2 { mk_e(SizeOfType (snd
> > > > > $3))    [$1;$2;$4] }
> > > >
> > > > There could be less white space in front of the [
> > > >
> > > > julia
> > > >
> > > > >   | Tnew new_argument               { mk_e(New (None,
> > > > > $2))     [$1]
> > > > > }
> > > > >   | Tnew TOPar argument_list_ne TCPar new_argument { mk_e(New
> > > > > (Some
> > > > > $3, $5))             [$1; $2; $4] }
> > > > >   | Tdelete cast_expr               { mk_e(Delete(false,
> > > > > $2))  [$1]
> > > > > }
> > > > > @@ -897,9 +897,9 @@ postfix_expr:
> > > > >
> > > > >   /*(* gccext: also called compound literals *)*/
> > > > >   | topar2 type_name tcpar2 TOBrace TCBrace
> > > > > -     { mk_e(Constructor ($2, (InitList [], [$4;$5]))) [$1;$3]
> > > > > }
> > > > > +     { mk_e(Constructor (snd $2, (InitList [], [$4;$5])))
> > > > > [$1;$3]
> > > > > }
> > > > >   | topar2 type_name tcpar2 TOBrace initialize_list
> > > > > gcc_comma_opt_struct TCBrace
> > > > > -     { mk_e(Constructor ($2, (InitList (List.rev $5),[$4;$7] @
> > > > > $6))) [$1;$3] }
> > > > > +     { mk_e(Constructor (snd $2, (InitList (List.rev
> > > > > $5),[$4;$7] @
> > > > > $6))) [$1;$3] }
> > > > >
> > > > >
> > > > >  primary_expr:
> > > > > @@ -1298,7 +1298,7 @@ type_spec2:
> > > > >         Right3 (TypeName (name, Ast_c.noTypedefDef())),[] }
> > > > >
> > > > >   | Ttypeof TOPar assign_expr TCPar { Right3 (TypeOfExpr ($3)),
> > > > > [$1;$2;$4] }
> > > > > - | Ttypeof TOPar type_name   TCPar { Right3 (TypeOfType ($3)),
> > > > > [$1;$2;$4] }
> > > > > + | Ttypeof TOPar type_name   TCPar { Right3 (TypeOfType (snd
> > > > > $3)),
> > > > > [$1;$2;$4] }
> > > > >
> > > > >  /*(*----------------------------*)*/
> > > > >  /*(* workarounds *)*/
> > > > > @@ -1531,12 +1531,12 @@ type_qualif_list:
> > > > >  type_name:
> > > > >   | spec_qualif_list
> > > > >       { let (attrs, ds) = $1 in
> > > > > -       let (returnType, _) = fixDeclSpecForDecl ds in
> > > > > returnType }
> > > > > +       let (returnType, _) = fixDeclSpecForDecl ds in (attrs,
> > > > > returnType) }
> > > > >   | spec_qualif_list abstract_declaratort
> > > > >       { let (attrs1, ds) = $1 in
> > > > >         let (attrs2, fn) = $2 in
> > > > >         let (returnType, _) = fixDeclSpecForDecl ds in
> > > > > -       fn returnType }
> > > > > +       (attrs1@attrs2, fn returnType) }
> > > > >
> > > > >
> > > > >
> > > > > --
> > > > > 2.21.1
> > > > >
> > > > >
>
>
_______________________________________________
Linux-kernel-mentees mailing list
Linux-kernel-mentees@lists.linuxfoundation.org
https://lists.linuxfoundation.org/mailman/listinfo/linux-kernel-mentees

  reply	other threads:[~2020-05-04 13:19 UTC|newest]

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

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

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