Commit | Line | Data |
---|---|---|
f537ebc4 | 1 | (* |
17ba0788 C |
2 | * Copyright 2012, INRIA |
3 | * Julia Lawall, Gilles Muller | |
4 | * Copyright 2010-2011, INRIA, University of Copenhagen | |
f537ebc4 C |
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 | ||
feec80c3 | 27 | # 0 "./check_exhaustive_pattern.ml" |
34e49164 C |
28 | |
29 | (* Just to warn me when there is some news in the types in | |
30 | * ast_cocci.ml or even ast_c.ml, so that I can then adjust my code in | |
31 | * pattern.ml or transformation.ml. | |
ae4735db | 32 | * |
34e49164 C |
33 | * For the moment I do it only for myself (pad), that is I check only |
34 | * for news in ast_cocci.ml, because I already know when I add stuff in | |
35 | * my code in ast_c.ml or control_flow_c.ml. *) | |
36 | ||
37 | module A = Ast_cocci | |
38 | module B = Ast_c | |
39 | module F = Control_flow_c | |
40 | ||
41 | (* dependencies_to_adjust: pattern.ml, transformaton.ml *) | |
42 | ||
43 | let dumb_astcocci_rule_elem = function | |
44 | | A.MetaRuleElem _ -> () | |
45 | | A.MetaStmt (ida,_,_,_) -> () | |
46 | | A.MetaStmtList _ -> () | |
47 | | A.Exp expr -> () | |
48 | | A.TopExp expr -> () | |
49 | | A.Ty ty -> () | |
1be43e12 | 50 | | A.TopInit init -> () |
34e49164 C |
51 | | A.FunHeader (bef,allminus, fninfo, ida, _, paramsa, _) -> () |
52 | | A.Decl (bef,allminus,decla) -> () | |
53 | | A.SeqStart _ -> () | |
54 | | A.SeqEnd _ -> () | |
55 | | A.ExprStatement (ea, _) -> () | |
56 | | A.IfHeader (_,_, ea, _) -> () | |
57 | | A.Else _ -> () | |
58 | | A.WhileHeader (_, _, ea, _) -> () | |
59 | | A.DoHeader _ -> () | |
60 | | A.WhileTail (_,_,ea,_,_) -> () | |
755320b0 | 61 | | A.ForHeader (_, _, _, ea2opt, _, ea3opt, _) -> () |
34e49164 C |
62 | | A.IteratorHeader (ia1, ia2, ea, ia3) -> () |
63 | | A.SwitchHeader _ -> () | |
64 | | A.Break _ -> () | |
65 | | A.Continue _ -> () | |
66 | | A.Label _ -> () | |
67 | | A.Goto(_,_,_) -> () | |
68 | | A.Return _ -> () | |
69 | | A.ReturnExpr (_, ea, _) -> () | |
70 | | A.DefineHeader _ -> () | |
3a314143 | 71 | | A.Undef _ -> () |
34e49164 C |
72 | | A.Include _ -> () |
73 | | A.Default _ -> () | |
74 | | A.Case _ -> () | |
75 | | A.DisjRuleElem _ -> failwith "not possible - compiled away in asttoctl" | |
76 | ||
77 | let dumb_astcocci_decl = function | |
78 | | A.UnInit (stg, typa, sa, _) -> () | |
79 | | A.Init (stg, typa, sa, _, expa, _) -> () | |
80 | | A.TyDecl (typa, _) -> () | |
81 | | A.MacroDecl(fn, _, eas, _, _) -> () | |
17ba0788 | 82 | | A.MacroDeclInit(fn, _, eas, _, _, _, _) -> () |
34e49164 C |
83 | | A.Ddots(dots,whencode) -> () |
84 | | A.MetaDecl _ -> () | |
413ffc02 | 85 | | A.MetaField _ -> () |
190f1acf | 86 | | A.MetaFieldList _ -> () |
17ba0788 | 87 | | A.AsDecl _ -> () |
34e49164 C |
88 | | A.Typedef(d,ty1,ty2,pv) -> () |
89 | | A.DisjDecl xs -> () | |
90 | | A.OptDecl _ | A.UniqueDecl _ -> () | |
91 | ||
17ba0788 | 92 | let dumb_astcocci_initialiser = function (* seems same as the above *) |
34e49164 C |
93 | A.Init(stg,ty,id,eq,ini,sem) -> () |
94 | | A.UnInit(stg,ty,id,sem) -> () | |
95 | | A.MacroDecl(fn, _, eas, _, _) -> () | |
17ba0788 | 96 | | A.MacroDeclInit(fn, _, eas, _, _, _, _) -> () |
34e49164 C |
97 | | A.TyDecl(ty,sem) -> () |
98 | | A.Typedef(d,ty1,ty2,pv) -> () | |
99 | | A.DisjDecl(decls) -> () | |
100 | | A.Ddots(dots,whencode) -> () | |
101 | | A.MetaDecl(name,_,_) -> () | |
413ffc02 | 102 | | A.MetaField(name,_,_) -> () |
190f1acf | 103 | | A.MetaFieldList(name,_,_,_) -> () |
17ba0788 | 104 | | A.AsDecl(_,_) -> () |
34e49164 C |
105 | | A.OptDecl(decl) -> () |
106 | | A.UniqueDecl(decl) -> () | |
107 | ||
108 | let dumb_astcocci_expr = function | |
109 | | A.MetaExpr (ida,_,_, opttypa, _, _) -> () | |
17ba0788 | 110 | | A.AsExpr (_,_) -> () |
34e49164 C |
111 | | A.Edots (_,_) -> () |
112 | | A.MetaErr _ -> () | |
113 | | A.Ident ida -> () | |
114 | | A.Constant (A.String sa,_,_,_) -> () | |
115 | | A.Constant (A.Char sa,_,_,_) -> () | |
116 | | A.Constant (A.Int sa,_,_,_) -> () | |
117 | | A.Constant (A.Float sa,_,_,_) -> () | |
118 | | A.FunCall (ea1, _, eas, _) -> () | |
119 | | A.Assignment (ea1, opa, ea2, _) -> () | |
17ba0788 | 120 | | A.Sequence (ea1, opa, ea2) -> () |
34e49164 C |
121 | | A.CondExpr (ea1,_,ea2opt,_,ea3) -> () |
122 | | A.Postfix (ea, opa) -> () | |
123 | | A.Infix (ea, opa) -> () | |
124 | | A.Unary (ea, opa) -> () | |
125 | | A.Binary (ea1, opa, ea2) -> () | |
126 | | A.Nested (ea1, opa, ea2) -> () | |
127 | | A.ArrayAccess (ea1, _, ea2, _) -> () | |
128 | | A.RecordAccess (ea, _, ida) -> () | |
129 | | A.RecordPtAccess (ea, _, ida) -> () | |
130 | | A.Cast (_, typa, _, ea) -> () | |
131 | | A.SizeOfExpr (_, ea) -> () | |
132 | | A.SizeOfType (_, _, typa, _) -> () | |
133 | | A.TypeExp (typa) -> () | |
7fe62b65 | 134 | | A.Constructor (_, typa, _, ia) -> () |
34e49164 C |
135 | | A.Paren (_, ea, _) -> () |
136 | | A.NestExpr _ -> () | |
137 | | A.MetaExprList _ -> () | |
138 | | A.EComma _ -> () | |
139 | | A.Ecircles _ -> () | |
140 | | A.Estars _ -> () | |
141 | | A.DisjExpr eas -> () | |
142 | | A.UniqueExp _ -> () | |
143 | | A.OptExp _ -> () | |
144 | ||
145 | let dumb_astcocci_fulltype = function | |
17ba0788 C |
146 | A.Type(_,cv,ty) -> () |
147 | | A.AsType(_,_) -> () | |
34e49164 C |
148 | | A.DisjType(types) -> () |
149 | | A.OptType(ty) -> () | |
150 | | A.UniqueType(ty) -> () | |
151 | ||
152 | let dumb_astcocci_type = function | |
153 | | A.MetaType(ida,_,_) -> () | |
faf9a90c C |
154 | | A.BaseType (basea,strings) -> () |
155 | | A.SignedT (signa,tya) -> () | |
34e49164 C |
156 | | A.Pointer (typa, _) -> () |
157 | | A.FunctionPointer(ty,lp1,star,rp1,lp2,params,rp2) -> () | |
158 | | A.FunctionType _ -> () | |
159 | | A.Array (typa, _, eaopt, _) -> () | |
faf9a90c | 160 | | A.EnumName(en, ena) -> () |
c491d8ee | 161 | | A.EnumDef(ty, lb, ids, rb) -> () |
34e49164 C |
162 | | A.StructUnionName(sa, sua) -> () |
163 | | A.StructUnionDef(ty, lb, decls, rb) -> () | |
164 | | A.TypeName sa -> () | |
165 | ||
166 | ||
167 | (* ------------------------------------------------------------------------- *) | |
168 | (* for C *) | |
169 | (* | |
ae4735db | 170 | | (Ident (_) | Constant _ | FunCall (_,_) | CondExpr (_,_,_) |
34e49164 | 171 | | Sequence (_,_) |
ae4735db | 172 | | Assignment (_,_,_) |
34e49164 C |
173 | | Postfix (_,_) | Infix (_,_) | Unary (_,_) | Binary (_,_,_) |
174 | | ArrayAccess (_,_) | RecordAccess (_,_) | RecordPtAccess (_,_) | |
ae4735db C |
175 | | SizeOfExpr (_) | SizeOfType (_) | Cast (_,_) |
176 | | StatementExpr (_) | Constructor | |
34e49164 | 177 | | ParenExpr (_) | MacroCall (_) | MacroCall2 (_) |
ae4735db | 178 | ),_ -> |
34e49164 | 179 | |
ae4735db | 180 | | ( Labeled (Label (_,_)) | Labeled (Case (_,_)) |
34e49164 | 181 | | Labeled (CaseRange (_,_,_)) | Labeled (Default _) |
ae4735db | 182 | | Compound _ | ExprStatement _ |
34e49164 | 183 | | Selection (If (_, _, _)) | Selection (Switch (_, _)) |
ae4735db | 184 | | Iteration (While (_, _)) | Iteration (DoWhile (_, _)) |
34e49164 C |
185 | | Iteration (For ((_,_), (_,_), (_, _), _)) |
186 | | Jump (Goto _) | Jump ((Continue|Break|Return)) | Jump (ReturnExpr _) | |
187 | | Decl _ | Asm | Selection (IfCpp (_,_)) | |
ae4735db | 188 | ), _ -> |
34e49164 C |
189 | *) |
190 | ||
ae4735db | 191 | (* for control flow nodes |
34e49164 | 192 | |
ae4735db | 193 | | ( F.ExprStatement (_, _) |
34e49164 | 194 | | F.IfHeader (_, _) | F.SwitchHeader (_, _) |
ae4735db | 195 | | F.WhileHeader (_, _) | (* F.DoHeader (_, _) | *) F.DoWhileTail (_, _) |
34e49164 C |
196 | | F.ForHeader (_, _) |
197 | | F.Return (_, _) | F.ReturnExpr (_, _) | |
198 | (* no counter part in cocci *) | |
ae4735db | 199 | | F.Label (_, _) |
34e49164 C |
200 | | F.Case (_,_) | (* F.CaseRange (_, _) | *) F.Default (_, _) |
201 | | F.Goto (_, _) | F.Continue (_, _) | F.Break (_, _) | |
202 | ) -> raise Impossible | |
203 | ||
204 | *) |