Release coccinelle-0.2.5-rc2
[bpt/coccinelle.git] / parsing_cocci / disjdistr.ml
index b2014ff..bb49e90 100644 (file)
@@ -1,27 +1,7 @@
 (*
- * 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 2010, 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.
  *
@@ -115,6 +95,10 @@ and disjtypeC bty =
        (function ty -> function size ->
          Ast.rewrap bty (Ast.Array(ty,lb,size,rb)))
   | Ast.EnumName(_,_) | Ast.StructUnionName(_,_) -> [bty]
+  | Ast.EnumDef(ty,lb,ids,rb) ->
+      disjmult2 (disjty ty) (disjdots disjexp ids)
+       (function ty -> function ids ->
+         Ast.rewrap bty (Ast.EnumDef(ty,lb,ids,rb)))
   | Ast.StructUnionDef(ty,lb,decls,rb) ->
       disjmult2 (disjty ty) (disjdots disjdecl decls)
        (function ty -> function decls ->
@@ -225,10 +209,15 @@ and disjini i =
   | Ast.InitExpr(exp) ->
       let exp = disjexp exp in
       List.map (function exp -> Ast.rewrap i (Ast.InitExpr(exp))) exp
-  | Ast.InitList(lb,initlist,rb,whencode) ->
+  | Ast.ArInitList(lb,initlist,rb) ->
+      List.map
+       (function initlist ->
+         Ast.rewrap i (Ast.ArInitList(lb,initlist,rb)))
+       (disjdots disjini initlist)
+  | Ast.StrInitList(allminus,lb,initlist,rb,whencode) ->
       List.map
        (function initlist ->
-         Ast.rewrap i (Ast.InitList(lb,initlist,rb,whencode)))
+         Ast.rewrap i (Ast.StrInitList(allminus,lb,initlist,rb,whencode)))
        (disjmult disjini initlist)
   | Ast.InitGccExt(designators,eq,ini) ->
       let designators = disjmult designator designators in
@@ -242,6 +231,7 @@ and disjini i =
        (function ini -> Ast.rewrap i (Ast.InitGccName(name,eq,ini)))
        ini
   | Ast.IComma(comma) -> [i]
+  | Ast.Idots(dots,_) -> [i]
   | Ast.OptIni(ini) ->
       let ini = disjini ini in
       List.map (function ini -> Ast.rewrap i (Ast.OptIni(ini))) ini
@@ -261,7 +251,8 @@ and designator = function
 
 and disjdecl d =
   match Ast.unwrap d with
-    Ast.Init(stg,ty,id,eq,ini,sem) ->
+    Ast.MetaDecl(_,_,_) | Ast.MetaField(_,_,_) -> [d]
+  | Ast.Init(stg,ty,id,eq,ini,sem) ->
       disjmult2 (disjty ty) (disjini ini)
        (function ty -> function ini ->
          Ast.rewrap d (Ast.Init(stg,ty,id,eq,ini,sem)))
@@ -279,7 +270,7 @@ and disjdecl d =
       let ty = disjty ty in (* disj not allowed in id *)
       List.map (function ty -> Ast.rewrap d (Ast.Typedef(stg,ty,id,sem))) ty
   | Ast.DisjDecl(decls) -> List.concat (List.map disjdecl decls)
-  | Ast.Ddots(_,_) | Ast.MetaDecl(_,_,_) -> [d]
+  | Ast.Ddots(_,_) -> [d]
   | Ast.OptDecl(decl) ->
       let decl = disjdecl decl in
       List.map (function decl -> Ast.rewrap d (Ast.OptDecl(decl))) decl
@@ -355,6 +346,7 @@ let rec disj_rule_elem r k re =
       orify_rule_elem_ini re init
        (function init -> Ast.rewrap init (Ast.TopInit(init)))
   | Ast.Include(inc,s) -> re
+  | Ast.Undef(def,id) -> re
   | Ast.DefineHeader(def,id,params) -> re
   | Ast.Default(def,colon) -> re
   | Ast.Case(case,exp,colon) ->
@@ -369,7 +361,7 @@ let disj_all =
   let donothing r k e = k e in
   V.rebuilder
     mcode mcode mcode mcode mcode mcode mcode mcode mcode mcode mcode mcode
-    donothing donothing donothing donothing
+    donothing donothing donothing donothing donothing
     donothing donothing donothing donothing donothing donothing donothing
     disj_rule_elem donothing donothing donothing donothing
 
@@ -386,7 +378,7 @@ let collect_all_isos =
     mcode mcode mcode mcode mcode mcode mcode mcode mcode mcode mcode mcode
     donothing donothing donothing donothing donothing donothing donothing
     donothing donothing donothing donothing donothing donothing donothing
-    donothing doanything
+    donothing donothing doanything
 
 let collect_iso_info =
   let mcode x = x in
@@ -400,6 +392,7 @@ let collect_iso_info =
   V.rebuilder
     mcode mcode mcode mcode mcode mcode mcode mcode mcode mcode mcode mcode
     donothing donothing donothing donothing donothing donothing donothing
+     donothing
     donothing donothing donothing donothing rule_elem donothing donothing
     donothing donothing