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