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