2 * Copyright 2005-2010, 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.
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.
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.
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/>.
18 * The authors reserve the right to distribute this or future versions of
19 * Coccinelle under other licenses.
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.
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.
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.
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/>.
40 * The authors reserve the right to distribute this or future versions of
41 * Coccinelle under other licenses.
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.
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. *)
56 module F
= Control_flow_c
58 (* dependencies_to_adjust: pattern.ml, transformaton.ml *)
60 let dumb_astcocci_rule_elem = function
61 | A.MetaRuleElem _
-> ()
62 | A.MetaStmt
(ida
,_
,_
,_
) -> ()
63 | A.MetaStmtList _
-> ()
67 | A.TopInit init
-> ()
68 | A.FunHeader
(bef
,allminus
, fninfo
, ida
, _
, paramsa
, _
) -> ()
69 | A.Decl
(bef
,allminus
,decla
) -> ()
72 | A.ExprStatement
(ea
, _
) -> ()
73 | A.IfHeader
(_
,_
, ea
, _
) -> ()
75 | A.WhileHeader
(_
, _
, ea
, _
) -> ()
77 | A.WhileTail
(_
,_
,ea
,_
,_
) -> ()
78 | A.ForHeader
(_
, _
, ea1opt
, _
, ea2opt
, _
, ea3opt
, _
) -> ()
79 | A.IteratorHeader
(ia1
, ia2
, ea
, ia3
) -> ()
80 | A.SwitchHeader _
-> ()
86 | A.ReturnExpr
(_
, ea
, _
) -> ()
87 | A.DefineHeader _
-> ()
91 | A.DisjRuleElem _
-> failwith
"not possible - compiled away in asttoctl"
93 let 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
) -> ()
100 | A.Typedef
(d
,ty1
,ty2
,pv
) -> ()
101 | A.DisjDecl xs
-> ()
102 | A.OptDecl _
| A.UniqueDecl _
-> ()
104 let 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
) -> ()
116 let dumb_astcocci_expr = function
117 | A.MetaExpr
(ida
,_
,_
, opttypa
, _
, _
) -> ()
118 | A.Edots
(_
,_
) -> ()
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
, _
) -> ()
142 | A.MetaExprList _
-> ()
146 | A.DisjExpr eas
-> ()
147 | A.UniqueExp _
-> ()
150 let dumb_astcocci_fulltype = function
152 | A.DisjType
(types
) -> ()
153 | A.OptType
(ty
) -> ()
154 | A.UniqueType
(ty
) -> ()
156 let dumb_astcocci_type = function
157 | A.MetaType
(ida
,_
,_
) -> ()
158 | A.BaseType
(basea
,strings
) -> ()
159 | A.SignedT
(signa
,tya
) -> ()
160 | A.Pointer
(typa
, _
) -> ()
161 | A.FunctionPointer
(ty
,lp1
,star
,rp1
,lp2
,params
,rp2
) -> ()
162 | A.FunctionType _
-> ()
163 | A.Array
(typa
, _
, eaopt
, _
) -> ()
164 | A.EnumName
(en
, ena
) -> ()
165 | A.StructUnionName
(sa
, sua
) -> ()
166 | A.StructUnionDef
(ty
, lb
, decls
, rb
) -> ()
167 | A.TypeName sa
-> ()
170 (* ------------------------------------------------------------------------- *)
173 | (Ident (_) | Constant _ | FunCall (_,_) | CondExpr (_,_,_)
176 | Postfix (_,_) | Infix (_,_) | Unary (_,_) | Binary (_,_,_)
177 | ArrayAccess (_,_) | RecordAccess (_,_) | RecordPtAccess (_,_)
178 | SizeOfExpr (_) | SizeOfType (_) | Cast (_,_)
179 | StatementExpr (_) | Constructor
180 | ParenExpr (_) | MacroCall (_) | MacroCall2 (_)
183 | ( Labeled (Label (_,_)) | Labeled (Case (_,_))
184 | Labeled (CaseRange (_,_,_)) | Labeled (Default _)
185 | Compound _ | ExprStatement _
186 | Selection (If (_, _, _)) | Selection (Switch (_, _))
187 | Iteration (While (_, _)) | Iteration (DoWhile (_, _))
188 | Iteration (For ((_,_), (_,_), (_, _), _))
189 | Jump (Goto _) | Jump ((Continue|Break|Return)) | Jump (ReturnExpr _)
190 | Decl _ | Asm | Selection (IfCpp (_,_))
194 (* for control flow nodes
196 | ( F.ExprStatement (_, _)
197 | F.IfHeader (_, _) | F.SwitchHeader (_, _)
198 | F.WhileHeader (_, _) | (* F.DoHeader (_, _) | *) F.DoWhileTail
(_
, _
)
200 | F.Return
(_
, _
) | F.ReturnExpr
(_
, _
)
201 (* no counter part in cocci *)
203 | F.Case
(_
,_
) | (* F.CaseRange (_, _) | *) F.Default
(_
, _
)
204 | F.Goto
(_
, _
) | F.Continue
(_
, _
) | F.Break
(_
, _
)
205 ) -> raise Impossible