cocci.inria.fr archive mirror
 help / color / mirror / Atom feed
* [Cocci] [PATCH v3 00/26] cocci: Add ParenType/FunctionType to SmPL ASTs
@ 2020-03-20  7:01 Jaskaran Singh
  2020-03-20  7:01 ` [Cocci] [PATCH v3 01/26] parsing_cocci: Add Function Prototype token Jaskaran Singh
                   ` (25 more replies)
  0 siblings, 26 replies; 27+ messages in thread
From: Jaskaran Singh @ 2020-03-20  7:01 UTC (permalink / raw)
  To: cocci; +Cc: linux-kernel-mentees

The aim of this patch series is to add the types ParenType
and FunctionType to the SmPL AST. These types are present in
the C AST but not in the SmPL AST.

Preliminarily, a hack to resolve a reduce/reduce conflict
with the funproto rule in the SmPL parser is implemented.

Upon this, a rule similar to that of the C parser's direct
declarator rule is implemented, and used wherever suitable.
The direct declarator rule produces ParenType and FunctionType,
similar to the C parser.

Cases for these types are added to various places in the codebase.

The FunctionPointer type is removed from the SmPL AST, since
all the productions that produce FunctionPointers in the SmPL
parser are replaced by those that produce ParenType. Any functions,
constructs or cases of FunctionPointer are also removed from the
codebase.

A test case to match an array of function pointers is included to
demonstrate matching improvements.

Changes in v3:
--------------
- Patch 01/26:
    - Add case for __attribute__((.*)) in is_permissible_proto
      so that the p1p2 test case passes successfully with just
      01/26 applied.
    - Add case for typeof(.*) in is_permissible_proto.
    - Change the function balanced_args in find_function_names
      by adding a new argument "reverse". reverse is a bool that
      indicates whether the given list is reversed, and if it is
      then when to return the rest of the tokens and how to increment
      or decrement the current depth/level of the parentheses.
- Patch 02/26:
    Briefly describe how the new constructs are used in
    the SmPL AST.
- Patch 03/26:
    State examples of productions that are not supported
    by the direct_declarator and direct_abstract_d rules, and how some
    of these could be supported.
- Patch 04/26:
    - Group together repeated code in a function.
    - Place match statement on a single line.
    - Change spaces to tabs in a ParenType/FunctionType cases of
      named_type and named_type_typedef.
- Patch 05/26:
    - Group together repeated code in a function.
    - Place match statement on a single line.
- Patch 07/26:
    Change the comment in the head of index.ml to indicate
    which indexes have now been used.
- Patch 09/26:
    Group together repeated code in a function.
- Patch 10/26:
    Change ParenType's case as per what term is to the
    left.
- Patch 14/26:
    Change ParenType's case as per what term is to the
    left.
- Patch 15/26:
    Change promote_mcode rp to promote_mcode lp for
    ParenType's case.
- Patch 21/26:
    Group together repeated code in a function.
- Patch 22/26:
    - Group together repeated code in a function.
    - Add FunctionType case to named_type function.

Changes in v2:
--------------
- Patch 05/26: Change "visitor_ast0" in patch subject to "visitor_ast"

[PATCH v3 01/26] parsing_cocci: Add Function Prototype token
[PATCH v3 02/26] parsing_cocci: AST: Add ParenType and FunctionType
[PATCH v3 03/26] parsing_cocci: parser: Add
[PATCH v3 04/26] parsing_cocci: visitor_ast0: Add cases for
[PATCH v3 05/26] parsing_cocci: visitor_ast: Add cases for
[PATCH v3 06/26] parsing_cocci: arity: Add cases for
[PATCH v3 07/26] parsing_cocci: index: Add cases for
[PATCH v3 08/26] parsing_cocci: context_neg: Add cases for
[PATCH v3 09/26] parsing_cocci: unparse_ast0: Add cases for
[PATCH v3 10/26] parsing_cocci: single_statement: Add cases for
[PATCH v3 11/26] parsing_cocci: function_prototypes: Add cases for
[PATCH v3 12/26] parsing_cocci: check_meta: Add cases for
[PATCH v3 13/26] parsing_cocci: iso_pattern: Add cases for
[PATCH v3 14/26] parsing_cocci: adjust_pragmas: Add cases for
[PATCH v3 15/26] parsing_cocci: compute_lines: Add cases for
[PATCH v3 16/26] parsing_cocci: ast0toast: Add cases for
[PATCH v3 17/26] parsing_cocci: type_cocci: Add
[PATCH v3 18/26] parsing_cocci: unify_ast: Add cases for
[PATCH v3 19/26] parsing_cocci: disjdistr: Add cases for
[PATCH v3 20/26] parsing_cocci: ast_cocci: Add cases for
[PATCH v3 21/26] parsing_cocci: pretty_print_cocci: Print
[PATCH v3 22/26] parsing_c: unparse_cocci: Print
[PATCH v3 23/26] engine: Match A.ParenType and A.FunctionType
[PATCH v3 24/26] tools: spgen: Add cases for ParenType/FunctionType
[PATCH v3 25/26] cocci: Remove Ast_cocci.FunctionPointer
[PATCH v3 26/26] tests: Add test case for array of function pointers

 engine/check_exhaustive_pattern.ml       |    3 
 engine/cocci_vs_c.ml                     |   82 +++-------
 ocaml/coccilib.mli                       |   10 -
 parsing_c/unparse_cocci.ml               |   72 +++++++--
 parsing_cocci/adjust_pragmas.ml          |    7 
 parsing_cocci/arity.ml                   |   25 ++-
 parsing_cocci/ast0_cocci.ml              |    7 
 parsing_cocci/ast0_cocci.mli             |    6 
 parsing_cocci/ast0toast.ml               |   11 -
 parsing_cocci/ast_cocci.ml               |   21 +-
 parsing_cocci/ast_cocci.mli              |    6 
 parsing_cocci/check_meta.ml              |    8 -
 parsing_cocci/compute_lines.ml           |   21 +-
 parsing_cocci/context_neg.ml             |    4 
 parsing_cocci/disjdistr.ml               |   16 +-
 parsing_cocci/function_prototypes.ml     |    7 
 parsing_cocci/get_constants.ml           |    2 
 parsing_cocci/index.ml                   |    5 
 parsing_cocci/iso_pattern.ml             |   17 --
 parsing_cocci/parse_cocci.ml             |   97 +++++++++---
 parsing_cocci/parser_cocci_menhir.mly    |  248 +++++++++++++++----------------
 parsing_cocci/pretty_print_cocci.ml      |   64 ++++++--
 parsing_cocci/single_statement.ml        |    3 
 parsing_cocci/type_cocci.mli             |    3 
 parsing_cocci/type_infer.ml              |   25 +--
 parsing_cocci/unify_ast.ml               |   16 +-
 parsing_cocci/unparse_ast0.ml            |   51 ++++--
 parsing_cocci/visitor_ast.ml             |   92 ++++++++---
 parsing_cocci/visitor_ast0.ml            |  198 ++++++++++++++++++------
 tests/funptr_array.c                     |    1 
 tests/funptr_array.cocci                 |    9 +
 tests/funptr_array.res                   |    1 
 tools/spgen/source/meta_variable.ml      |    1 
 tools/spgen/source/position_generator.ml |    9 -
 34 files changed, 732 insertions(+), 416 deletions(-)


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

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

end of thread, other threads:[~2020-03-20  7:04 UTC | newest]

Thread overview: 27+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-03-20  7:01 [Cocci] [PATCH v3 00/26] cocci: Add ParenType/FunctionType to SmPL ASTs Jaskaran Singh
2020-03-20  7:01 ` [Cocci] [PATCH v3 01/26] parsing_cocci: Add Function Prototype token Jaskaran Singh
2020-03-20  7:01 ` [Cocci] [PATCH v3 02/26] parsing_cocci: AST: Add ParenType and FunctionType to SmPL ASTs Jaskaran Singh
2020-03-20  7:01 ` [Cocci] [PATCH v3 03/26] parsing_cocci: parser: Add direct_declarator/direct_abstract_d rules Jaskaran Singh
2020-03-20  7:01 ` [Cocci] [PATCH v3 04/26] parsing_cocci: visitor_ast0: Add cases for ParenType/FunctionType Jaskaran Singh
2020-03-20  7:01 ` [Cocci] [PATCH v3 05/26] parsing_cocci: visitor_ast: " Jaskaran Singh
2020-03-20  7:01 ` [Cocci] [PATCH v3 06/26] parsing_cocci: arity: " Jaskaran Singh
2020-03-20  7:01 ` [Cocci] [PATCH v3 07/26] parsing_cocci: index: " Jaskaran Singh
2020-03-20  7:01 ` [Cocci] [PATCH v3 08/26] parsing_cocci: context_neg: " Jaskaran Singh
2020-03-20  7:01 ` [Cocci] [PATCH v3 09/26] parsing_cocci: unparse_ast0: " Jaskaran Singh
2020-03-20  7:01 ` [Cocci] [PATCH v3 10/26] parsing_cocci: single_statement: " Jaskaran Singh
2020-03-20  7:01 ` [Cocci] [PATCH v3 11/26] parsing_cocci: function_prototypes: " Jaskaran Singh
2020-03-20  7:01 ` [Cocci] [PATCH v3 12/26] parsing_cocci: check_meta: " Jaskaran Singh
2020-03-20  7:01 ` [Cocci] [PATCH v3 13/26] parsing_cocci: iso_pattern: " Jaskaran Singh
2020-03-20  7:01 ` [Cocci] [PATCH v3 14/26] parsing_cocci: adjust_pragmas: " Jaskaran Singh
2020-03-20  7:01 ` [Cocci] [PATCH v3 15/26] parsing_cocci: compute_lines: " Jaskaran Singh
2020-03-20  7:01 ` [Cocci] [PATCH v3 16/26] parsing_cocci: ast0toast: " Jaskaran Singh
2020-03-20  7:01 ` [Cocci] [PATCH v3 17/26] parsing_cocci: type_cocci: Add ParenType/FunctionType to types Jaskaran Singh
2020-03-20  7:01 ` [Cocci] [PATCH v3 18/26] parsing_cocci: unify_ast: Add cases for ParenType/FunctionType Jaskaran Singh
2020-03-20  7:01 ` [Cocci] [PATCH v3 19/26] parsing_cocci: disjdistr: " Jaskaran Singh
2020-03-20  7:01 ` [Cocci] [PATCH v3 20/26] parsing_cocci: ast_cocci: " Jaskaran Singh
2020-03-20  7:01 ` [Cocci] [PATCH v3 21/26] parsing_cocci: pretty_print_cocci: Print ParenType/FunctionType Jaskaran Singh
2020-03-20  7:01 ` [Cocci] [PATCH v3 22/26] parsing_c: unparse_cocci: " Jaskaran Singh
2020-03-20  7:01 ` [Cocci] [PATCH v3 23/26] engine: Match A.ParenType and A.FunctionType Jaskaran Singh
2020-03-20  7:01 ` [Cocci] [PATCH v3 24/26] tools: spgen: Add cases for ParenType/FunctionType Jaskaran Singh
2020-03-20  7:01 ` [Cocci] [PATCH v3 25/26] cocci: Remove Ast_cocci.FunctionPointer Jaskaran Singh
2020-03-20  7:01 ` [Cocci] [PATCH v3 26/26] tests: Add test case for array of function pointers 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).