Coccinelle release-1.0.0-rc11
[bpt/coccinelle.git] / parsing_cocci / adjust_pragmas.ml
index 09d041f..31c747d 100644 (file)
@@ -1,27 +1,9 @@
 (*
- * Copyright 2005-2010, Ecole des Mines de Nantes, University of Copenhagen
- * Yoann Padioleau, Julia Lawall, Rene Rydhof Hansen, Henrik Stuart, Gilles Muller, Nicolas Palix
- * This file is part of Coccinelle.
- *
- * Coccinelle is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, according to version 2 of the License.
- *
- * Coccinelle is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with Coccinelle.  If not, see <http://www.gnu.org/licenses/>.
- *
- * The authors reserve the right to distribute this or future versions of
- * Coccinelle under other licenses.
- *)
-
-
-(*
- * Copyright 2005-2010, Ecole des Mines de Nantes, University of Copenhagen
+ * Copyright 2012, INRIA
+ * Julia Lawall, Gilles Muller
+ * Copyright 2010-2011, INRIA, University of Copenhagen
+ * Julia Lawall, Rene Rydhof Hansen, Gilles Muller, Nicolas Palix
+ * Copyright 2005-2009, Ecole des Mines de Nantes, University of Copenhagen
  * Yoann Padioleau, Julia Lawall, Rene Rydhof Hansen, Henrik Stuart, Gilles Muller, Nicolas Palix
  * This file is part of Coccinelle.
  *
@@ -75,7 +57,17 @@ let update_after pragmas (info,x) =
 
 let rec right_decl d =
   match Ast0.unwrap d with
-    Ast0.Init(Some stg,ty,id,eq,ini,sem) ->
+    Ast0.MetaDecl(name,pure) ->
+      call_right right_mcode name d
+       (function name -> Ast0.MetaDecl(name,pure))
+  | Ast0.MetaField(name,pure) ->
+      call_right right_mcode name d
+       (function name -> Ast0.MetaField(name,pure))
+  | Ast0.MetaFieldList(name,lenname,pure) ->
+      call_right right_mcode name d
+       (function name -> Ast0.MetaFieldList(name,lenname,pure))
+  | Ast0.AsDecl(decl,asdecl) -> failwith "not possible"
+  | Ast0.Init(Some stg,ty,id,eq,ini,sem) ->
       call_right right_mcode sem d
        (function sem -> Ast0.Init(Some stg,ty,id,eq,ini,sem))
   | Ast0.Init(None,ty,id,eq,ini,sem) ->
@@ -90,6 +82,9 @@ let rec right_decl d =
   | Ast0.MacroDecl(name,lp,args,rp,sem) ->
       call_right right_mcode sem d
        (function sem -> Ast0.MacroDecl(name,lp,args,rp,sem))
+  | Ast0.MacroDeclInit(name,lp,args,rp,eq,ini,sem) ->
+      call_right right_mcode sem d
+       (function sem -> Ast0.MacroDeclInit(name,lp,args,rp,eq,ini,sem))
   | Ast0.TyDecl(ty,sem) ->
       call_right right_mcode sem d
        (function sem -> Ast0.TyDecl(ty,sem))
@@ -150,6 +145,7 @@ let rec right_statement s =
   | Ast0.MetaStmtList(name,pure) ->
       call_right right_mcode name s
        (function name -> Ast0.MetaStmtList(name,pure))
+  | Ast0.AsStmt(stm,asstm) -> failwith "not possible"
   | Ast0.Disj(starter,statement_dots_list,mids,ender) -> None
   | Ast0.Nest(starter,stmt_dots,ender,whn,multi) -> None
   (* the following are None, because they can't be adjacent to an aft node *)
@@ -163,6 +159,10 @@ let rec right_statement s =
   | Ast0.Include(inc,name) ->
       call_right right_mcode name s
        (function name -> Ast0.Include(inc,name))
+  | Ast0.Undef(def,id) ->
+      (* nothing available for ident, and not sure code can appear
+        here anyway *)
+      None
   | Ast0.Define(def,id,params,body) ->
       call_right right_statement_dots body s
        (function body -> Ast0.Define(def,id,params,body))
@@ -205,6 +205,9 @@ let rec left_ty t =
       call_right left_ty ty t (function ty -> Ast0.Array(ty,lb,size,rb))
   | Ast0.EnumName(kind,name) ->
       call_right left_mcode kind t (function kind -> Ast0.EnumName(kind,name))
+  | Ast0.EnumDef(ty,lb,ids,rb) ->
+      call_right left_ty ty t
+       (function ty -> Ast0.EnumDef(ty,lb,ids,rb))
   | Ast0.StructUnionName(kind,name) ->
       call_right left_mcode kind t
        (function kind -> Ast0.StructUnionName(kind,name))
@@ -215,6 +218,7 @@ let rec left_ty t =
       call_right left_mcode name t (function name -> Ast0.TypeName(name))
   | Ast0.MetaType(name,x) ->
       call_right left_mcode name t (function name -> Ast0.MetaType(name,x))
+  | Ast0.AsType(ty,asty) -> failwith "not possible"
   | Ast0.DisjType(starter,types,mids,ender) -> None
   | Ast0.OptType(ty) ->
       call_right left_ty ty t (function ty -> Ast0.OptType(ty))
@@ -223,22 +227,20 @@ let rec left_ty t =
 
 let rec left_ident i =
   match Ast0.unwrap i with
-      Ast0.Id(name) ->
-       call_right left_mcode name i
-         (function name -> Ast0.Id(name))
-    | Ast0.MetaId(name,a,b) ->
-       call_right left_mcode name i
-         (function name -> Ast0.MetaId(name,a,b))
-    | Ast0.MetaFunc(name,a,b) ->
-       call_right left_mcode name i
-         (function name -> Ast0.MetaFunc(name,a,b))
-    | Ast0.MetaLocalFunc(name,a,b) ->
-       call_right left_mcode name i
-         (function name -> Ast0.MetaLocalFunc(name,a,b))
-    | Ast0.OptIdent(id) ->
-       call_right left_ident id i (function id -> Ast0.OptIdent(id))
-    | Ast0.UniqueIdent(id) ->
-       call_right left_ident id i (function id -> Ast0.UniqueIdent(id))
+    Ast0.Id(name) ->
+      call_right left_mcode name i (function name -> Ast0.Id(name))
+  | Ast0.MetaId(name,a,b,c) ->
+      call_right left_mcode name i (function name -> Ast0.MetaId(name,a,b,c))
+  | Ast0.MetaFunc(name,a,b) ->
+      call_right left_mcode name i (function name -> Ast0.MetaFunc(name,a,b))
+  | Ast0.MetaLocalFunc(name,a,b) ->
+      call_right left_mcode name i
+       (function name -> Ast0.MetaLocalFunc(name,a,b))
+  | Ast0.DisjId(starter,ids,mids,ender) -> None
+  | Ast0.OptIdent(id) ->
+      call_right left_ident id i (function id -> Ast0.OptIdent(id))
+  | Ast0.UniqueIdent(id) ->
+      call_right left_ident id i (function id -> Ast0.UniqueIdent(id))
 
 let left_fundecl name fninfo =
   let fncall_right processor data cont =
@@ -261,7 +263,17 @@ let left_fundecl name fninfo =
 
 let rec left_decl decl =
   match Ast0.unwrap decl with
-    Ast0.Init(Some stg,ty,id,eq,ini,sem) ->
+    Ast0.MetaDecl(name,pure) ->
+      call_right right_mcode name decl
+       (function name -> Ast0.MetaDecl(name,pure))
+  | Ast0.MetaField(name,pure) ->
+      call_right right_mcode name decl
+       (function name -> Ast0.MetaField(name,pure))
+  | Ast0.MetaFieldList(name,lenname,pure) ->
+      call_right right_mcode name decl
+       (function name -> Ast0.MetaFieldList(name,lenname,pure))
+  | Ast0.AsDecl(decl,asdecl) -> failwith "not possible"
+  | Ast0.Init(Some stg,ty,id,eq,ini,sem) ->
       call_right left_mcode stg decl
        (function stg -> Ast0.Init(Some stg,ty,id,eq,ini,sem))
   | Ast0.Init(None,ty,id,eq,ini,sem) ->
@@ -276,6 +288,9 @@ let rec left_decl decl =
   | Ast0.MacroDecl(name,lp,args,rp,sem) ->
       call_right left_ident name decl
        (function name -> Ast0.MacroDecl(name,lp,args,rp,sem))
+  | Ast0.MacroDeclInit(name,lp,args,rp,eq,ini,sem) ->
+      call_right left_ident name decl
+       (function name -> Ast0.MacroDeclInit(name,lp,args,rp,eq,ini,sem))
   | Ast0.TyDecl(ty,sem) ->
       call_right left_ty ty decl (function ty -> Ast0.TyDecl(ty,sem))
   | Ast0.Typedef(stg,ty,id,sem) ->