(*
-* Copyright 2005-2009, Ecole des Mines de Nantes, University of Copenhagen
-* Yoann Padioleau, Julia Lawall, Rene Rydhof Hansen, Henrik Stuart, Gilles Muller
-* This file is part of Coccinelle.
-*
-* Coccinelle is free software: you can redistribute it and/or modify
-* it under the terms of the GNU General Public License as published by
-* the Free Software Foundation, according to version 2 of the License.
-*
-* Coccinelle is distributed in the hope that it will be useful,
-* but WITHOUT ANY WARRANTY; without even the implied warranty of
-* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-* GNU General Public License for more details.
-*
-* You should have received a copy of the GNU General Public License
-* along with Coccinelle. If not, see <http://www.gnu.org/licenses/>.
-*
-* The authors reserve the right to distribute this or future versions of
-* Coccinelle under other licenses.
-*)
-
-
+ * Copyright 2005-2009, Ecole des Mines de Nantes, University of Copenhagen
+ * Yoann Padioleau, Julia Lawall, Rene Rydhof Hansen, Henrik Stuart, Gilles Muller, Nicolas Palix
+ * This file is part of Coccinelle.
+ *
+ * Coccinelle is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, according to version 2 of the License.
+ *
+ * Coccinelle is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with Coccinelle. If not, see <http://www.gnu.org/licenses/>.
+ *
+ * The authors reserve the right to distribute this or future versions of
+ * Coccinelle under other licenses.
+ *)
+
+
+(* Yoann Padioleau
+ *
+ * Copyright (C) 2006, 2007 Ecole des Mines de Nantes
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License (GPL)
+ * version 2 as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * file license.txt for more details.
+ *
+ * This file was part of Coccinelle.
+ *)
open Common
module Flag_engine = Flag_matcher
else xs
*)
(* opti? use set instead of list *)
- m1 tin ++ m2 tin
+ let l1 = m1 tin in
+ let l2 = m2 tin in
+ if l2 = [] then l1 else l1 ++ l2 (*a small benefit; avoid a trivial @*)
let return res = fun tin ->
(* ------------------------------------------------------------------------*)
let tag_mck_pos mck posmck =
match mck with
- | Ast_cocci.PLUS -> Ast_cocci.PLUS
+ | Ast_cocci.PLUS c -> Ast_cocci.PLUS c
| Ast_cocci.CONTEXT (pos, xs) ->
- assert (pos = Ast_cocci.NoPos || pos = Ast_cocci.DontCarePos);
+ assert (pos =*= Ast_cocci.NoPos || pos =*= Ast_cocci.DontCarePos);
Ast_cocci.CONTEXT (posmck, xs)
- | Ast_cocci.MINUS (pos, xs) ->
- assert (pos = Ast_cocci.NoPos || pos = Ast_cocci.DontCarePos);
- Ast_cocci.MINUS (posmck, xs)
+ | Ast_cocci.MINUS (pos, inst, adj, xs) ->
+ assert (pos =*= Ast_cocci.NoPos || pos =*= Ast_cocci.DontCarePos);
+ Ast_cocci.MINUS (posmck, inst, adj, xs)
let tag_mck_pos_mcode (x,info,mck,pos) posmck stuff = fun tin ->
(* ------------------------------------------------------------------------*)
- (* Constraints on metavariable values *)
+ (* Constraints on metavariable values *)
(* ------------------------------------------------------------------------*)
- let check_constraints matcher constraints exp = fun f tin ->
+ let check_idconstraint matcher c id = fun f tin ->
+ if matcher c id then
+ (* success *)
+ f () tin
+ else
+ (* failure *)
+ fail tin
+
+ let check_constraints_ne matcher constraints exp = fun f tin ->
let rec loop = function
[] -> f () tin (* success *)
| c::cs ->
loop constraints
let check_pos_constraints constraints pvalu f tin =
- check_constraints
+ check_constraints_ne
(fun c exp tin ->
let success = [[]] in
let failure = [] in
inherited variables *)
(match Common.optionise (fun () -> tin.binding0 +> List.assoc c) with
Some valu' ->
- if Cocci_vs_c.equal_metavarval exp valu'
+ if Cocci_vs_c.equal_inh_metavarval exp valu'
then success else failure
| None ->
(* if the variable is not there, it puts no constraints *)
then
match Common.optionise (fun () -> tin.binding0 +> List.assoc k) with
| Some (valu') ->
- if Cocci_vs_c.equal_metavarval valu valu'
+ if Cocci_vs_c.equal_inh_metavarval valu valu'
then Some tin.binding
else None
| None -> None
then Lib_parsing_c.al_type a
else Lib_parsing_c.semi_al_type a)
+ | Ast_c.MetaInitVal a ->
+ Ast_c.MetaInitVal
+ (if strip
+ then Lib_parsing_c.al_init a
+ else Lib_parsing_c.semi_al_init a)
+
| Ast_c.MetaListlenVal a -> Ast_c.MetaListlenVal a
| Ast_c.MetaParamVal a -> failwith "not handling MetaParamVal"