Cast attributes are added to the C and SmPL ASTs. Match these attributes in cocci_vs_c.ml.
Signed-off-by: Jaskaran Singh <jaskaransingh7654...@gmail.com> --- engine/cocci_vs_c.ml | 24 +++++++++++++++++------- 1 file changed, 17 insertions(+), 7 deletions(-) diff --git a/engine/cocci_vs_c.ml b/engine/cocci_vs_c.ml index 317fa71e..0001ec2a 100644 --- a/engine/cocci_vs_c.ml +++ b/engine/cocci_vs_c.ml @@ -1121,7 +1121,7 @@ let rec (expression: (A.expression, Ast_c.expression) matcher) = * differentiate between different cases *) let rec matches_id = function B.Ident(name) -> true - | B.Cast(ty,e) -> matches_id (B.unwrap_expr e) + | B.Cast(ty,e,a) -> matches_id (B.unwrap_expr e) | _ -> false in let form_ok = match (form,expr) with @@ -1137,7 +1137,7 @@ let rec (expression: (A.expression, Ast_c.expression) matcher) = true end else false - | B.Cast(ty,e) -> matches (B.unwrap_expr e) + | B.Cast(ty,e,a) -> matches (B.unwrap_expr e) | B.Unary(e,B.UnMinus) -> matches (B.unwrap_expr e) | B.SizeOfExpr(exp) -> true | B.SizeOfType(ty) -> true @@ -1525,16 +1525,26 @@ let rec (expression: (A.expression, Ast_c.expression) matcher) = * by trying | ea, B.Case (typb, eb) -> match_e_e ea eb ? *) - | A.Cast (ia1, typa, ia2, ea), ((B.Cast (typb, eb), typ),ii) -> + | A.Cast (ia1, typa, attrsa, ia2, ea), + ((B.Cast (typb, eb, attrsb), typ),ii) -> + + let attr_allminus = + let mcode_is_not_context = function + | (_,_,A.CONTEXT(_,_),_) -> false + | _ -> true in + check_allminus.Visitor_ast.combiner_fullType typa && + List.for_all mcode_is_not_context attrsa in + let (ib1, ib2) = tuple_of_list2 ii in fullType typa typb >>= (fun typa typb -> + attribute_list attr_allminus attrsa attrsb >>= (fun attrsa attrsb -> expression ea eb >>= (fun ea eb -> tokenf ia1 ib1 >>= (fun ia1 ib1 -> tokenf ia2 ib2 >>= (fun ia2 ib2 -> return ( - ((A.Cast (ia1, typa, ia2, ea))) +> wa, - ((B.Cast (typb, eb),typ),[ib1;ib2]) - ))))) + ((A.Cast (ia1, typa, attrsa, ia2, ea))) +> wa, + ((B.Cast (typb, eb, attrsb),typ),[ib1;ib2]) + )))))) | A.SizeOfExpr (ia1, ea), ((B.SizeOfExpr (eb), typ),ii) -> let ib1 = tuple_of_list1 ii in @@ -1641,7 +1651,7 @@ let rec (expression: (A.expression, Ast_c.expression) matcher) = | _, - (((B.Cast (_, _)|B.ParenExpr _|B.SizeOfType _|B.SizeOfExpr _| + (((B.Cast (_, _, _)|B.ParenExpr _|B.SizeOfType _|B.SizeOfExpr _| B.Constructor (_, _)| B.RecordPtAccess (_, _)| B.RecordAccess (_, _)|B.ArrayAccess (_, _)| -- 2.21.1 _______________________________________________ Cocci mailing list Cocci@systeme.lip6.fr https://systeme.lip6.fr/mailman/listinfo/cocci