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