* [Linux-kernel-mentees] [PATCH 0/3] parsing_cocci: Improve attr management in context_neg et al
@ 2020-06-12 6:45 Jaskaran Singh
2020-06-12 6:45 ` [Linux-kernel-mentees] [PATCH 1/3] parsing_cocci: arity: Apply mcode2arity on macrodecl/param attrs Jaskaran Singh
` (2 more replies)
0 siblings, 3 replies; 4+ messages in thread
From: Jaskaran Singh @ 2020-06-12 6:45 UTC (permalink / raw)
To: cocci; +Cc: julia.lawall, jaskaransingh7654321, linux-kernel-mentees
Introduction of recent patches[1][2][3] for adding additional attributes to the SmPL AST introduced some poor management of attributes in the following files:
parsing_cocci/context_neg.ml
parsing_cocci/arity.ml
parsing_cocci/unify_ast.ml
This patch series is for fixing these issues, by modifying cases wherever necessary.
[1]
[PATCH v3 00/23] cocci: Add parameter attributes to SmPL
https://lore.kernel.org/cocci/20200511101300.11101-1-jaskaransingh7654321@gmail.com/T/#t
[2]
[PATCH v3 00/32] cocci: Add cast attributes to C and SmPL ASTs
https://lore.kernel.org/cocci/20200529120703.31145-1-jaskaransingh7654321@gmail.com
[3]
[PATCH 00/30] cocci: Add macrodecl attributes to C and SmPL ASTs
https://lore.kernel.org/cocci/20200524171935.2504-1-jaskaransingh7654321@gmail.com
Jaskaran Singh (3):
parsing_cocci: arity: Apply mcode2arity on macrodecl/param attrs
parsing_cocci: context_neg: Apply equal_mcode for cast/param attrs
parsing_cocci: unify_ast: Apply unify_mcode to macrodecl attrs
arity.ml | 26 ++++++++++++++++++--------
context_neg.ml | 12 ++++++++----
unify_ast.ml | 3 ++-
3 files changed, 28 insertions(+), 13 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] 4+ messages in thread
* [Linux-kernel-mentees] [PATCH 1/3] parsing_cocci: arity: Apply mcode2arity on macrodecl/param attrs
2020-06-12 6:45 [Linux-kernel-mentees] [PATCH 0/3] parsing_cocci: Improve attr management in context_neg et al Jaskaran Singh
@ 2020-06-12 6:45 ` Jaskaran Singh
2020-06-12 6:45 ` [Linux-kernel-mentees] [PATCH 2/3] parsing_cocci: context_neg: Apply equal_mcode on cast/param attrs Jaskaran Singh
2020-06-12 6:45 ` [Linux-kernel-mentees] [PATCH 3/3] parsing_cocci: unify_ast: Apply unify_mcode on macrodecl attrs Jaskaran Singh
2 siblings, 0 replies; 4+ messages in thread
From: Jaskaran Singh @ 2020-06-12 6:45 UTC (permalink / raw)
To: cocci; +Cc: julia.lawall, jaskaransingh7654321, linux-kernel-mentees
The following commits introduced some poor management of attributes in
arity.ml:
08f1cd9fb83ec400435e0ad8fdf579ec8f9c0f21
b4b8653bd5a9607922e0050fe2fede10d422b218
Apply mcode2arity to macrodecl and parameter attributes.
Signed-off-by: Jaskaran Singh <jaskaransingh7654321@gmail.com>
---
parsing_cocci/arity.ml | 26 ++++++++++++++++++--------
1 file changed, 18 insertions(+), 8 deletions(-)
diff --git a/parsing_cocci/arity.ml b/parsing_cocci/arity.ml
index 6f90616e..3bbecedf 100644
--- a/parsing_cocci/arity.ml
+++ b/parsing_cocci/arity.ml
@@ -601,7 +601,7 @@ and declaration tgt decl =
let arity =
all_same true tgt (mcode2line lp)
((match stg with None -> [] | Some x -> [mcode2arity x]) @
- (List.map mcode2arity [lp;rp;sem])) in
+ (List.map mcode2arity ([lp;rp] @ attr @ [sem]))) in
let stg = get_option mcode stg in
let name = ident false arity name in
let lp = mcode lp in
@@ -816,30 +816,40 @@ and make_param =
and parameterTypeDef tgt param =
let param_same = all_same true tgt in
+ let make_param_attr param tgt ret = function
+ [] -> Ast0.rewrap param ret
+ | x::_ as xs ->
+ let arity = param_same (mcode2line x) (List.map mcode2arity xs) in
+ make_param param tgt arity ret in
match Ast0.unwrap param with
Ast0.VoidParam(ty,attr) ->
- Ast0.rewrap param (Ast0.VoidParam(typeC tgt ty,List.map mcode attr))
+ let ty = top_typeC tgt true ty in
+ let attr = List.map mcode attr in
+ let ret = Ast0.VoidParam(ty,attr) in
+ make_param_attr param tgt ret attr
| Ast0.Param(ty,Some id,attr) ->
let ty = top_typeC tgt true ty in
let id = ident true tgt id in
let attr = List.map mcode attr in
- Ast0.rewrap param
- (match (Ast0.unwrap ty,Ast0.unwrap id) with
+ let ret =
+ match (Ast0.unwrap ty,Ast0.unwrap id) with
(Ast0.OptType(ty),Ast0.OptIdent(id)) ->
Ast0.OptParam(Ast0.rewrap param (Ast0.Param(ty,Some id,attr)))
| (Ast0.OptType(ty),_) ->
fail param "arity mismatch in param declaration"
| (_,Ast0.OptIdent(id)) ->
fail param "arity mismatch in param declaration"
- | _ -> Ast0.Param(ty,Some id,attr))
+ | _ -> Ast0.Param(ty,Some id,attr) in
+ make_param_attr param tgt ret attr
| Ast0.Param(ty,None,attr) ->
let ty = top_typeC tgt true ty in
let attr = List.map mcode attr in
- Ast0.rewrap param
- (match Ast0.unwrap ty with
+ let ret =
+ match Ast0.unwrap ty with
Ast0.OptType(ty) ->
Ast0.OptParam(Ast0.rewrap param (Ast0.Param(ty,None,attr)))
- | _ -> Ast0.Param(ty,None,attr))
+ | _ -> Ast0.Param(ty,None,attr) in
+ make_param_attr param tgt ret attr
| Ast0.MetaParam(name,cstr,pure) ->
let arity = param_same (mcode2line name) [mcode2arity name] in
let name = mcode 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] 4+ messages in thread
* [Linux-kernel-mentees] [PATCH 2/3] parsing_cocci: context_neg: Apply equal_mcode on cast/param attrs
2020-06-12 6:45 [Linux-kernel-mentees] [PATCH 0/3] parsing_cocci: Improve attr management in context_neg et al Jaskaran Singh
2020-06-12 6:45 ` [Linux-kernel-mentees] [PATCH 1/3] parsing_cocci: arity: Apply mcode2arity on macrodecl/param attrs Jaskaran Singh
@ 2020-06-12 6:45 ` Jaskaran Singh
2020-06-12 6:45 ` [Linux-kernel-mentees] [PATCH 3/3] parsing_cocci: unify_ast: Apply unify_mcode on macrodecl attrs Jaskaran Singh
2 siblings, 0 replies; 4+ messages in thread
From: Jaskaran Singh @ 2020-06-12 6:45 UTC (permalink / raw)
To: cocci; +Cc: julia.lawall, jaskaransingh7654321, linux-kernel-mentees
The following commits introduced some poor management of attributes in
context_neg.ml:
2b7e99a5b86d41e05980c8a9d98eb931e42bb4d8
08f1cd9fb83ec400435e0ad8fdf579ec8f9c0f21
Apply equal_mcode on cast and parameter attributes in context_neg.ml.
Signed-off-by: Jaskaran Singh <jaskaransingh7654321@gmail.com>
---
parsing_cocci/context_neg.ml | 12 ++++++++----
1 file changed, 8 insertions(+), 4 deletions(-)
diff --git a/parsing_cocci/context_neg.ml b/parsing_cocci/context_neg.ml
index 41bc621f..6e992245 100644
--- a/parsing_cocci/context_neg.ml
+++ b/parsing_cocci/context_neg.ml
@@ -630,8 +630,10 @@ let rec equal_expression e1 e2 =
equal_mcode pt1 pt2
| (Ast0.RecordPtAccess(_,ar1,_),Ast0.RecordPtAccess(_,ar2,_)) ->
equal_mcode ar1 ar2
- | (Ast0.Cast(lp1,_,_,rp1,_),Ast0.Cast(lp2,_,_,rp2,_)) ->
- equal_mcode lp1 lp2 && equal_mcode rp1 rp2
+ | (Ast0.Cast(lp1,_,ar1,rp1,_),Ast0.Cast(lp2,_,ar2,rp2,_)) ->
+ equal_mcode lp1 lp2 &&
+ List.for_all2 equal_mcode ar1 ar2 &&
+ equal_mcode rp1 rp2
| (Ast0.SizeOfExpr(szf1,_),Ast0.SizeOfExpr(szf2,_)) ->
equal_mcode szf1 szf2
| (Ast0.SizeOfType(szf1,lp1,_,rp1),Ast0.SizeOfType(szf2,lp2,_,rp2)) ->
@@ -842,8 +844,10 @@ let equal_initialiser i1 i2 =
let equal_parameterTypeDef p1 p2 =
match (Ast0.unwrap p1,Ast0.unwrap p2) with
- (Ast0.VoidParam(_,_),Ast0.VoidParam(_,_)) -> true
- | (Ast0.Param(_,_,_),Ast0.Param(_,_,_)) -> true
+ (Ast0.VoidParam(_,ar1),Ast0.VoidParam(_,ar2)) ->
+ List.for_all2 equal_mcode ar1 ar2
+ | (Ast0.Param(_,_,ar1),Ast0.Param(_,_,ar2)) ->
+ List.for_all2 equal_mcode ar1 ar2
| (Ast0.MetaParam(name1,_,_),Ast0.MetaParam(name2,_,_))
| (Ast0.MetaParamList(name1,_,_,_),Ast0.MetaParamList(name2,_,_,_)) ->
equal_mcode name1 name2
--
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] 4+ messages in thread
* [Linux-kernel-mentees] [PATCH 3/3] parsing_cocci: unify_ast: Apply unify_mcode on macrodecl attrs
2020-06-12 6:45 [Linux-kernel-mentees] [PATCH 0/3] parsing_cocci: Improve attr management in context_neg et al Jaskaran Singh
2020-06-12 6:45 ` [Linux-kernel-mentees] [PATCH 1/3] parsing_cocci: arity: Apply mcode2arity on macrodecl/param attrs Jaskaran Singh
2020-06-12 6:45 ` [Linux-kernel-mentees] [PATCH 2/3] parsing_cocci: context_neg: Apply equal_mcode on cast/param attrs Jaskaran Singh
@ 2020-06-12 6:45 ` Jaskaran Singh
2 siblings, 0 replies; 4+ messages in thread
From: Jaskaran Singh @ 2020-06-12 6:45 UTC (permalink / raw)
To: cocci; +Cc: julia.lawall, jaskaransingh7654321, linux-kernel-mentees
The following commit introduced some poor management of attributes in
unify_ast.ml:
b4b8653bd5a9607922e0050fe2fede10d422b218
Apply unify_mcode on macrodecl attributes in unify_ast.ml.
Signed-off-by: Jaskaran Singh <jaskaransingh7654321@gmail.com>
---
parsing_cocci/unify_ast.ml | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/parsing_cocci/unify_ast.ml b/parsing_cocci/unify_ast.ml
index 752e9283..788c8fdc 100644
--- a/parsing_cocci/unify_ast.ml
+++ b/parsing_cocci/unify_ast.ml
@@ -413,7 +413,8 @@ and unify_declaration d1 d2 =
else false
| (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
+ if bool_unify_option unify_mcode s1 s2 &&
+ List.for_all2 unify_mcode attr1 attr2
then
unify_ident n1 n2 &&
unify_dots unify_expression edots args1 args2
--
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] 4+ messages in thread
end of thread, other threads:[~2020-06-12 6:46 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-06-12 6:45 [Linux-kernel-mentees] [PATCH 0/3] parsing_cocci: Improve attr management in context_neg et al Jaskaran Singh
2020-06-12 6:45 ` [Linux-kernel-mentees] [PATCH 1/3] parsing_cocci: arity: Apply mcode2arity on macrodecl/param attrs Jaskaran Singh
2020-06-12 6:45 ` [Linux-kernel-mentees] [PATCH 2/3] parsing_cocci: context_neg: Apply equal_mcode on cast/param attrs Jaskaran Singh
2020-06-12 6:45 ` [Linux-kernel-mentees] [PATCH 3/3] parsing_cocci: unify_ast: Apply unify_mcode on macrodecl attrs 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).