Release coccinelle-0.2.0
[bpt/coccinelle.git] / engine / check_exhaustive_pattern.ml
1 (*
2 * Copyright 2005-2009, Ecole des Mines de Nantes, University of Copenhagen
3 * Yoann Padioleau, Julia Lawall, Rene Rydhof Hansen, Henrik Stuart, Gilles Muller, Nicolas Palix
4 * This file is part of Coccinelle.
5 *
6 * Coccinelle is free software: you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation, according to version 2 of the License.
9 *
10 * Coccinelle is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with Coccinelle. If not, see <http://www.gnu.org/licenses/>.
17 *
18 * The authors reserve the right to distribute this or future versions of
19 * Coccinelle under other licenses.
20 *)
21
22
23
24 (* Just to warn me when there is some news in the types in
25 * ast_cocci.ml or even ast_c.ml, so that I can then adjust my code in
26 * pattern.ml or transformation.ml.
27 *
28 * For the moment I do it only for myself (pad), that is I check only
29 * for news in ast_cocci.ml, because I already know when I add stuff in
30 * my code in ast_c.ml or control_flow_c.ml. *)
31
32 module A = Ast_cocci
33 module B = Ast_c
34 module F = Control_flow_c
35
36 (* dependencies_to_adjust: pattern.ml, transformaton.ml *)
37
38 let dumb_astcocci_rule_elem = function
39 | A.MetaRuleElem _ -> ()
40 | A.MetaStmt (ida,_,_,_) -> ()
41 | A.MetaStmtList _ -> ()
42 | A.Exp expr -> ()
43 | A.TopExp expr -> ()
44 | A.Ty ty -> ()
45 | A.TopInit init -> ()
46 | A.FunHeader (bef,allminus, fninfo, ida, _, paramsa, _) -> ()
47 | A.Decl (bef,allminus,decla) -> ()
48 | A.SeqStart _ -> ()
49 | A.SeqEnd _ -> ()
50 | A.ExprStatement (ea, _) -> ()
51 | A.IfHeader (_,_, ea, _) -> ()
52 | A.Else _ -> ()
53 | A.WhileHeader (_, _, ea, _) -> ()
54 | A.DoHeader _ -> ()
55 | A.WhileTail (_,_,ea,_,_) -> ()
56 | A.ForHeader (_, _, ea1opt, _, ea2opt, _, ea3opt, _) -> ()
57 | A.IteratorHeader (ia1, ia2, ea, ia3) -> ()
58 | A.SwitchHeader _ -> ()
59 | A.Break _ -> ()
60 | A.Continue _ -> ()
61 | A.Label _ -> ()
62 | A.Goto(_,_,_) -> ()
63 | A.Return _ -> ()
64 | A.ReturnExpr (_, ea, _) -> ()
65 | A.DefineHeader _ -> ()
66 | A.Include _ -> ()
67 | A.Default _ -> ()
68 | A.Case _ -> ()
69 | A.DisjRuleElem _ -> failwith "not possible - compiled away in asttoctl"
70
71 let dumb_astcocci_decl = function
72 | A.UnInit (stg, typa, sa, _) -> ()
73 | A.Init (stg, typa, sa, _, expa, _) -> ()
74 | A.TyDecl (typa, _) -> ()
75 | A.MacroDecl(fn, _, eas, _, _) -> ()
76 | A.Ddots(dots,whencode) -> ()
77 | A.MetaDecl _ -> ()
78 | A.Typedef(d,ty1,ty2,pv) -> ()
79 | A.DisjDecl xs -> ()
80 | A.OptDecl _ | A.UniqueDecl _ -> ()
81
82 let dumb_astcocci_initialiser = function
83 A.Init(stg,ty,id,eq,ini,sem) -> ()
84 | A.UnInit(stg,ty,id,sem) -> ()
85 | A.MacroDecl(fn, _, eas, _, _) -> ()
86 | A.TyDecl(ty,sem) -> ()
87 | A.Typedef(d,ty1,ty2,pv) -> ()
88 | A.DisjDecl(decls) -> ()
89 | A.Ddots(dots,whencode) -> ()
90 | A.MetaDecl(name,_,_) -> ()
91 | A.OptDecl(decl) -> ()
92 | A.UniqueDecl(decl) -> ()
93
94 let dumb_astcocci_expr = function
95 | A.MetaExpr (ida,_,_, opttypa, _, _) -> ()
96 | A.Edots (_,_) -> ()
97 | A.MetaErr _ -> ()
98 | A.Ident ida -> ()
99 | A.Constant (A.String sa,_,_,_) -> ()
100 | A.Constant (A.Char sa,_,_,_) -> ()
101 | A.Constant (A.Int sa,_,_,_) -> ()
102 | A.Constant (A.Float sa,_,_,_) -> ()
103 | A.FunCall (ea1, _, eas, _) -> ()
104 | A.Assignment (ea1, opa, ea2, _) -> ()
105 | A.CondExpr (ea1,_,ea2opt,_,ea3) -> ()
106 | A.Postfix (ea, opa) -> ()
107 | A.Infix (ea, opa) -> ()
108 | A.Unary (ea, opa) -> ()
109 | A.Binary (ea1, opa, ea2) -> ()
110 | A.Nested (ea1, opa, ea2) -> ()
111 | A.ArrayAccess (ea1, _, ea2, _) -> ()
112 | A.RecordAccess (ea, _, ida) -> ()
113 | A.RecordPtAccess (ea, _, ida) -> ()
114 | A.Cast (_, typa, _, ea) -> ()
115 | A.SizeOfExpr (_, ea) -> ()
116 | A.SizeOfType (_, _, typa, _) -> ()
117 | A.TypeExp (typa) -> ()
118 | A.Paren (_, ea, _) -> ()
119 | A.NestExpr _ -> ()
120 | A.MetaExprList _ -> ()
121 | A.EComma _ -> ()
122 | A.Ecircles _ -> ()
123 | A.Estars _ -> ()
124 | A.DisjExpr eas -> ()
125 | A.UniqueExp _ -> ()
126 | A.OptExp _ -> ()
127
128 let dumb_astcocci_fulltype = function
129 A.Type(cv,ty) -> ()
130 | A.DisjType(types) -> ()
131 | A.OptType(ty) -> ()
132 | A.UniqueType(ty) -> ()
133
134 let dumb_astcocci_type = function
135 | A.MetaType(ida,_,_) -> ()
136 | A.BaseType (basea,strings) -> ()
137 | A.SignedT (signa,tya) -> ()
138 | A.Pointer (typa, _) -> ()
139 | A.FunctionPointer(ty,lp1,star,rp1,lp2,params,rp2) -> ()
140 | A.FunctionType _ -> ()
141 | A.Array (typa, _, eaopt, _) -> ()
142 | A.EnumName(en, ena) -> ()
143 | A.StructUnionName(sa, sua) -> ()
144 | A.StructUnionDef(ty, lb, decls, rb) -> ()
145 | A.TypeName sa -> ()
146
147
148 (* ------------------------------------------------------------------------- *)
149 (* for C *)
150 (*
151 | (Ident (_) | Constant _ | FunCall (_,_) | CondExpr (_,_,_)
152 | Sequence (_,_)
153 | Assignment (_,_,_)
154 | Postfix (_,_) | Infix (_,_) | Unary (_,_) | Binary (_,_,_)
155 | ArrayAccess (_,_) | RecordAccess (_,_) | RecordPtAccess (_,_)
156 | SizeOfExpr (_) | SizeOfType (_) | Cast (_,_)
157 | StatementExpr (_) | Constructor
158 | ParenExpr (_) | MacroCall (_) | MacroCall2 (_)
159 ),_ ->
160
161 | ( Labeled (Label (_,_)) | Labeled (Case (_,_))
162 | Labeled (CaseRange (_,_,_)) | Labeled (Default _)
163 | Compound _ | ExprStatement _
164 | Selection (If (_, _, _)) | Selection (Switch (_, _))
165 | Iteration (While (_, _)) | Iteration (DoWhile (_, _))
166 | Iteration (For ((_,_), (_,_), (_, _), _))
167 | Jump (Goto _) | Jump ((Continue|Break|Return)) | Jump (ReturnExpr _)
168 | Decl _ | Asm | Selection (IfCpp (_,_))
169 ), _ ->
170 *)
171
172 (* for control flow nodes
173
174 | ( F.ExprStatement (_, _)
175 | F.IfHeader (_, _) | F.SwitchHeader (_, _)
176 | F.WhileHeader (_, _) | (* F.DoHeader (_, _) | *) F.DoWhileTail (_, _)
177 | F.ForHeader (_, _)
178 | F.Return (_, _) | F.ReturnExpr (_, _)
179 (* no counter part in cocci *)
180 | F.Label (_, _)
181 | F.Case (_,_) | (* F.CaseRange (_, _) | *) F.Default (_, _)
182 | F.Goto (_, _) | F.Continue (_, _) | F.Break (_, _)
183 ) -> raise Impossible
184
185 *)