MetaAttribute is added to the SmPL AST. Reflect these changes in
cocci_vs_c.ml.

Signed-off-by: Jaskaran Singh <jaskaran.si...@collabora.com>
---
 engine/cocci_vs_c.ml | 15 ++++++++++++++-
 1 file changed, 14 insertions(+), 1 deletion(-)

diff --git a/engine/cocci_vs_c.ml b/engine/cocci_vs_c.ml
index ed91a4785..0b698287d 100644
--- a/engine/cocci_vs_c.ml
+++ b/engine/cocci_vs_c.ml
@@ -1535,7 +1535,8 @@ let rec (expression: (A.expression, Ast_c.expression) 
matcher) =
       let attr_allminus =
         let attr_is_not_context a =
           match A.unwrap a with
-          | A.Attribute(_,_,A.CONTEXT(_,_),_) -> false
+          | A.Attribute(_,_,A.CONTEXT(_,_),_)
+          | A.MetaAttribute((_,_,A.CONTEXT(_,_),_),_,_,_) -> false
           | _ -> true in
         check_allminus.Visitor_ast.combiner_fullType typa &&
         List.for_all attr_is_not_context attrsa in
@@ -4282,6 +4283,18 @@ and attribute = fun allminus ea eb ->
          A.rewrap ea (A.Attribute(attra)),
           (B.Attribute attrb,ib1)
         )))
+  | A.MetaAttribute (ida,constraints,keep,inherited), _ ->
+      (* todo: use quaopt, hasreg ? *)
+      let max_min _ = Lib_parsing_c.ii_of_attr eb in
+      let mn = Ast_c.MetaAttributeVal eb in
+      check_constraints constraints ida mn
+       (fun () ->
+         X.envf keep inherited (ida,mn,max_min) (fun () ->
+            X.distrf_attr ida eb)
+           >>= (fun ida eb ->
+             return
+               (A.MetaAttribute(ida,constraints,keep,inherited)+>
+                A.rewrap ea,eb)))
   | _ -> fail
 
 (*---------------------------------------------------------------------------*)
-- 
2.21.3

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

Reply via email to