mkdir -p $(DESTDIR)$(SHAREDIR)/globals
mkdir -p $(DESTDIR)$(SHAREDIR)/parsing_c
mkdir -p $(DESTDIR)$(MANDIR)/man1
+ mkdir -p $(DESTDIR)$(MANDIR)/man3
$(INSTALL_DATA) standard.h $(DESTDIR)$(SHAREDIR)
$(INSTALL_DATA) standard.iso $(DESTDIR)$(SHAREDIR)
$(INSTALL_DATA) ocaml/coccilib.cmi $(DESTDIR)$(SHAREDIR)/ocaml/
$(INSTALL_DATA) commons/*.cmi $(DESTDIR)$(SHAREDIR)/commons/
$(INSTALL_DATA) globals/iteration.cmi $(DESTDIR)$(SHAREDIR)/globals/
$(INSTALL_DATA) docs/spatch.1 $(DESTDIR)$(MANDIR)/man1/
+ $(INSTALL_DATA) docs/Coccilib.3cocci $(DESTDIR)$(MANDIR)/man3/
@if [ $(FEATURE_PYTHON) -eq 1 ]; then $(MAKE) install-python; fi
install-bash:
rmdir $(DESTDIR)$(SHAREDIR)/ocaml
rmdir $(DESTDIR)$(SHAREDIR)
rm -f $(DESTDIR)$(MANDIR)/man1/spatch.1
+ rm -f $(DESTDIR)$(MANDIR)/man3/Coccilib.3cocci
uninstall-bash:
rm -f $(DESTDIR)$(BASH_COMPLETION_DIR)/spatch
PACKAGE=$(PRJNAME)-$(VERSION)
CCPACKAGE=coccicheck-$(CCVERSION)
-EXCLUDE=debian
+EXCLUDE=$(PACKAGE)/debian .depend
BINSRC=spatch env.sh env.csh standard.h standard.iso \
*.txt \
demos/*
BINSRC-PY=$(BINSRC) $(PYLIB) python/coccilib/
-EXCL=$(EXCLUDE:%=--exclude=$(PACKAGE)/%)
+EXCL=$(EXCLUDE:%=--exclude=%)
BINSRC2=$(BINSRC:%=$(PACKAGE)/%)
BINSRC2-PY=$(BINSRC-PY:%=$(PACKAGE)/%)
- Preserve spacing before // comments when not at the beginning of a line
- Adjusted parsing of endif to put it after jump code
- Improve warning message when using -use_cache
-- Allow - nest expressions
- More helpful initial value for exported variables in python
- Support - on expression nests
+- Better handling of the case of a matched declaration that should only
+ be replaced by other top level things.
** Bugfix:
- Corrected parsing of script strings delimited by a single quote. Thanks
contain adjacent modifications derived from the same SmPL code.
- check_meta takes into account fresh identifier seed information.
- Types for worth-trying optimization should not be followed by space
-- Improved pretty printing when the first parameter of a function is dropped
+- Improved filtering of result of matching atomic patterns
+- Drop positions before creating function prototype rules
+- Adjust position of { introduced by adding multiple statements in a
+ single-statement position
+- Drop newline after function call ( when all arguments on that line are
+ eliminated
+- Accept removal of a single declaration, replaced by arbitrary,
+ non-declaration code
+- smpl_spacing takes into account newlines, indentation
* 0.2.5
** Language:
let show_or_not_ctl_tex2 astcocci ctls =
if !Flag_cocci.show_ctl_tex then begin
+ let ctls =
+ List.map
+ (List.map
+ (function ((Asttoctl2.NONDECL ctl | Asttoctl2.CODE ctl),x) ->
+ (ctl,x)))
+ ctls in
Ctltotex.totex ("/tmp/__cocci_ctl.tex") astcocci ctls;
Common.command2 ("cd /tmp; latex __cocci_ctl.tex; " ^
"dvips __cocci_ctl.dvi -o __cocci_ctl.ps;" ^
);
pr "CTL = ";
- let (ctl,_) = ctl in
+ let ((Asttoctl2.CODE ctl | Asttoctl2.NONDECL ctl),_) = ctl in
adjust_pp_with_indent (fun () ->
Format.force_newline();
Pretty_print_engine.pp_ctlcocci
}
type toplevel_cocci_info_cocci_rule = {
- ctl: Lib_engine.ctlcocci * (CCI.pred list list);
+ ctl: Asttoctl2.top_formula * (CCI.pred list list);
metavars: Ast_cocci.metavar list;
ast_rule: Ast_cocci.rule;
isexp: bool; (* true if + code is an exp, only for Flag.make_hrule *)
(* does side effects on C ast and on Cocci info rule *)
and process_a_ctl_a_env_a_toplevel2 r e c f =
indent_do (fun () ->
- show_or_not_celem "trying" c.ast_c;
- Flag.currentfile := Some (f ^ ":" ^get_celem c.ast_c);
- let (trans_info, returned_any_states, inherited_bindings, newbindings) =
- Common.save_excursion Flag_ctl.loop_in_src_code (fun () ->
- Flag_ctl.loop_in_src_code := !Flag_ctl.loop_in_src_code||c.contain_loop;
+ show_or_not_celem "trying" c.ast_c;
+ Flag.currentfile := Some (f ^ ":" ^get_celem c.ast_c);
+ match (r.ctl,c.ast_c) with
+ ((Asttoctl2.NONDECL ctl,t),Ast_c.Declaration _) -> None
+ | ((Asttoctl2.NONDECL ctl,t), _)
+ | ((Asttoctl2.CODE ctl,t), _) ->
+ let ctl = (ctl,t) in (* ctl and other info *)
+ let (trans_info, returned_any_states, inherited_bindings, newbindings) =
+ Common.save_excursion Flag_ctl.loop_in_src_code (fun () ->
+ Flag_ctl.loop_in_src_code :=
+ !Flag_ctl.loop_in_src_code||c.contain_loop;
(***************************************)
(* !Main point! The call to the engine *)
(***************************************)
- let model_ctl = CCI.model_for_ctl r.dropped_isos (Common.some c.flow) e
- in CCI.mysat model_ctl r.ctl (r.rule_info.used_after, e)
- )
- in
- if not returned_any_states
- then None
- else begin
- show_or_not_celem "found match in" c.ast_c;
- show_or_not_trans_info trans_info;
- List.iter (show_or_not_binding "out") newbindings;
-
- r.rule_info.was_matched := true;
-
- if not (null trans_info) &&
- not (!Flag.sgrep_mode2 && not !Flag_cocci.show_diff)
- then begin
- c.was_modified := true;
- try
- (* les "more than one var in a decl" et "already tagged token"
- * font crasher coccinelle. Si on a 5 fichiers, donc on a 5
- * failed. Le try limite le scope des crashes pendant la
- * trasformation au fichier concerne. *)
-
- (* modify ast via side effect *)
- ignore(Transformation_c.transform r.rule_info.rulename r.dropped_isos
- inherited_bindings trans_info (Common.some c.flow));
- with Timeout -> raise Timeout | UnixExit i -> raise (UnixExit i)
- end;
-
- Some (List.map (function x -> x@inherited_bindings) newbindings)
- end
- )
+ let model_ctl =
+ CCI.model_for_ctl r.dropped_isos (Common.some c.flow) e
+ in CCI.mysat model_ctl ctl (r.rule_info.used_after, e))
+ in
+ if not returned_any_states
+ then None
+ else
+ begin
+ show_or_not_celem "found match in" c.ast_c;
+ show_or_not_trans_info trans_info;
+ List.iter (show_or_not_binding "out") newbindings;
+
+ r.rule_info.was_matched := true;
+
+ if not (null trans_info) &&
+ not (!Flag.sgrep_mode2 && not !Flag_cocci.show_diff)
+ then
+ begin
+ c.was_modified := true;
+ try
+ (* les "more than one var in a decl" et "already tagged token"
+ * font crasher coccinelle. Si on a 5 fichiers, donc on a 5
+ * failed. Le try limite le scope des crashes pendant la
+ * trasformation au fichier concerne. *)
+
+ (* modify ast via side effect *)
+ ignore
+ (Transformation_c.transform r.rule_info.rulename
+ r.dropped_isos
+ inherited_bindings trans_info (Common.some c.flow));
+ with Timeout -> raise Timeout | UnixExit i -> raise (UnixExit i)
+ end;
+
+ Some (List.map (function x -> x@inherited_bindings) newbindings)
+ end
+ )
and process_a_ctl_a_env_a_toplevel a b c f=
Common.profile_code "process_a_ctl_a_env_a_toplevel"
+++ /dev/null
-ctl_engine.cmi: ../commons/ograph_extended.cmi ast_ctl.cmo
-pretty_print_ctl.cmi: ast_ctl.cmo
-wrapper_ctl.cmi: ctl_engine.cmi ast_ctl.cmo
-ast_ctl.cmo:
-ast_ctl.cmx:
-ctl_engine.cmo: pretty_print_ctl.cmi ../commons/ograph_extended.cmi \
- flag_ctl.cmo ../globals/flag.cmo ../commons/common.cmi ast_ctl.cmo \
- ctl_engine.cmi
-ctl_engine.cmx: pretty_print_ctl.cmx ../commons/ograph_extended.cmx \
- flag_ctl.cmx ../globals/flag.cmx ../commons/common.cmx ast_ctl.cmx \
- ctl_engine.cmi
-flag_ctl.cmo:
-flag_ctl.cmx:
-pretty_print_ctl.cmo: flag_ctl.cmo ../commons/common.cmi ast_ctl.cmo \
- pretty_print_ctl.cmi
-pretty_print_ctl.cmx: flag_ctl.cmx ../commons/common.cmx ast_ctl.cmx \
- pretty_print_ctl.cmi
-test_ctl.cmo: wrapper_ctl.cmi ../commons/ograph_extended.cmi ctl_engine.cmi \
- ast_ctl.cmo
-test_ctl.cmx: wrapper_ctl.cmx ../commons/ograph_extended.cmx ctl_engine.cmx \
- ast_ctl.cmx
-wrapper_ctl.cmo: ../globals/flag.cmo ctl_engine.cmi ../commons/common.cmi \
- ast_ctl.cmo wrapper_ctl.cmi
-wrapper_ctl.cmx: ../globals/flag.cmx ctl_engine.cmx ../commons/common.cmx \
- ast_ctl.cmx wrapper_ctl.cmi
(List.map (function (st,th,_) -> (st,th)) triples);
triples
else setify(label p) in
- normalize
- (if !pREQUIRED_ENV_OPT
- then
- foldl
- (function rest ->
- function ((s,th,_) as t) ->
- if List.for_all
- (List.exists (function th' -> not(conj_subst th th' = None)))
- required
- then t::rest
- else rest)
- [] triples
- else triples)
+ (* normalize first; conj_subst relies on sorting *)
+ let ntriples = normalize triples in
+ if !pREQUIRED_ENV_OPT
+ then
+ foldl
+ (function rest ->
+ function ((s,th,_) as t) ->
+ if List.for_all
+ (List.exists (function th' -> not(conj_subst th th' = None)))
+ required
+ then t::rest
+ else rest)
+ [] ntriples
+ else ntriples
let get_required_states l =
if !pREQUIRED_STATES_OPT && not !Flag_ctl.partial_match
.\" -*- nroff -*-
.\" Please adjust this date whenever revising the manpage.
-.TH SPATCH 1 "may 18, 2011"
+.TH COCCILIB 3COCCI "May 18, 2011"
.\" see http://www.fnal.gov/docs/products/ups/ReferenceManual/html/manpages.html
.\" see http://www.linuxjournal.com/article/1158
\newcommand{\cpp}{\texttt{cpp}\xspace}
-\newcommand{\cocciversion}{0.2.5\xspace}
+\newcommand{\cocciversion}{1.0.0-rc3\xspace}
let warning s = Printf.fprintf stderr "warning: %s\n" s
type cocci_predicate = Lib_engine.predicate * Ast.meta_name Ast_ctl.modif
-type formula =
- (cocci_predicate,Ast.meta_name, Wrapper_ctl.info) Ast_ctl.generic_ctl
+type formula = Lib_engine.ctlcocci
+type top_formula = NONDECL of Lib_engine.ctlcocci | CODE of Lib_engine.ctlcocci
let union = Common.union_set
let intersect l1 l2 = List.filter (function x -> List.mem x l2) l1
used_after := ua;
saved := Ast.get_saved t;
let quantified = Common.minus_set (Common.union_set ua fuas) pos in
- quantify false quantified
- (match Ast.unwrap t with
+ let (wrap,formula) =
+ match Ast.unwrap t with
Ast.FILEINFO(old_file,new_file) -> failwith "not supported fileinfo"
- | Ast.DECL(stmt) ->
+ | Ast.NONDECL(stmt) ->
let unopt = elim_opt.V.rebuilder_statement stmt in
let unopt = preprocess_dots_e unopt in
- cleanup(statement unopt VeryEnd quantified [] None None None false)
+ let formula =
+ cleanup(statement unopt VeryEnd quantified [] None None None false) in
+ ((function x -> NONDECL x), formula)
| Ast.CODE(stmt_dots) ->
let unopt = elim_opt.V.rebuilder_statement_dots stmt_dots in
let unopt = preprocess_dots unopt in
let res =
statement_list unopt VeryEnd quantified [] None None None
false false in
- cleanup
- (if starts_with_dots
- then
+ let formula =
+ cleanup
+ (if starts_with_dots
+ then
(* EX because there is a loop on enter/top *)
- ctl_and CTL.NONSTRICT (toppred None) (ctl_ex res)
- else if starts_with_brace
- then
- ctl_and CTL.NONSTRICT
- (ctl_not(CTL.EX(CTL.BACKWARD,(funpred None)))) res
- else res)
- | Ast.ERRORWORDS(exps) -> failwith "not supported errorwords")
+ ctl_and CTL.NONSTRICT (toppred None) (ctl_ex res)
+ else if starts_with_brace
+ then
+ ctl_and CTL.NONSTRICT
+ (ctl_not(CTL.EX(CTL.BACKWARD,(funpred None)))) res
+ else res) in
+ ((function x -> CODE x), formula)
+ | Ast.ERRORWORDS(exps) -> failwith "not supported errorwords" in
+ wrap (quantify false quantified formula)
(* --------------------------------------------------------------------- *)
(* Entry points *)
Ast.ScriptRule _ | Ast.InitialScriptRule _ | Ast.FinalScriptRule _ -> []
| Ast.CocciRule (a,b,c,_,Ast_cocci.Normal) ->
asttoctlz (a,b,c) used_after positions
- | Ast.CocciRule (a,b,c,_,Ast_cocci.Generated) -> [CTL.True]
+ | Ast.CocciRule (a,b,c,_,Ast_cocci.Generated) -> [CODE CTL.True]
let pp_cocci_predicate (pred,modif) =
Pretty_print_engine.pp_predicate pred
type cocci_predicate = Lib_engine.predicate * Ast_cocci.meta_name Ast_ctl.modif
-type formula =
- (cocci_predicate,Ast_cocci.meta_name, Wrapper_ctl.info) Ast_ctl.generic_ctl
+type top_formula = NONDECL of Lib_engine.ctlcocci | CODE of Lib_engine.ctlcocci
val asttoctl :
Ast_cocci.rule ->
Ast_cocci.meta_name list list (* fresh used after *) *
Ast_cocci.meta_name list list (* fresh used after seeds *)) ->
Ast_cocci.meta_name list list (* positions *) ->
- formula list
+ top_formula list
val pp_cocci_predicate : cocci_predicate -> unit
let top_level testfn mcode t : 'a list list =
match Ast.unwrap t with
Ast.FILEINFO(old_file,new_file) -> failwith "not supported fileinfo"
- | Ast.DECL(stmt) -> statement testfn mcode false stmt
+ | Ast.NONDECL(stmt) -> statement testfn mcode false stmt
| Ast.CODE(stmt_dots) -> statement_list testfn mcode false stmt_dots
| Ast.ERRORWORDS(exps) -> failwith "not supported errorwords"
let dots2metavar (_,info,mcodekind,pos) =
(("","..."),info,mcodekind,pos)
let metavar2dots (_,info,mcodekind,pos) = ("...",info,mcodekind,pos)
+let metavar2ndots (_,info,mcodekind,pos) = ("<+...",info,mcodekind,pos)
let satisfies_regexpconstraint c id : bool =
match c with
X.distrf_e (dots2metavar starter) eb >>= (fun mcode eb ->
return (
(A.NestExpr
- (metavar2dots mcode,
+ (metavar2ndots mcode,
A.rewrap exps (A.DOTS [exp]),ender,None,true)) +> wa,
eb
)
val totex :
string ->
Ast_cocci.rule list ->
- ((Lib_engine.predicate * Ast_cocci.meta_name Ast_ctl.modif,
- Ast_cocci.meta_name,Wrapper_ctl.info)
- Ast_ctl.generic_ctl * 'a) list list ->
- unit
+ (Lib_engine.ctlcocci * 'a) list list ->
+ unit
-let version = "1.0.0-rc2"
+let version = "1.0.0-rc3"
let path =
try (Sys.getenv "COCCINELLE_HOME")
let (_typedef : (string, identkind) Common.scoped_h_env ref) =
ref (Common.empty_scoped_h_env ())
-let is_typedef s = if !_handle_typedef || !_always_look_typedef then
+let is_typedef s =
+ if !_handle_typedef || !_always_look_typedef then
(match (Common.optionise (fun () -> Common.lookup_h_env s !_typedef)) with
| Some TypeDefI -> true
| Some IdentI -> false
else x :: search_paren xs
| x::xs -> x :: search_paren xs
and search_minus seen_minus xs =
- let (spaces, rest) = Common.span is_space xs in
+ let (spaces, rest) = Common.span is_whitespace xs in
(* only delete spaces if something is actually deleted *)
match rest with
((T2(_,Min _,_)) as a)::rerest -> (* minus *)
| _ -> if seen_minus then rest else xs in (* drop trailing space *)
search_paren toks
+(* this is for the case where braces are added around an if branch *)
+let paren_then_brace toks =
+ let rec search_paren = function
+ [] -> []
+ | ((T2(_,Ctx,_)) as x)::xs ->
+ if List.mem (str_of_token2 x) [")"]
+ then x :: search_paren(search_plus xs)
+ else x :: search_paren xs
+ | x::xs -> x :: search_paren xs
+ and search_plus xs =
+ let (spaces, rest) = Common.span is_whitespace xs in
+ match rest with
+ (* move the brace up to the previous line *)
+ ((Cocci2("{",_,_,_,_)) as x) :: (((Cocci2 _) :: _) as rest) ->
+ (C2 " ") :: x :: spaces @ rest
+ | _ -> xs in
+ search_paren toks
+
let is_ident_like s = s ==~ Common.regexp_alpha
let rec drop_space_at_endline = function
something should be done to add newlines too, rather than
printing them explicitly in unparse_cocci. *)
x::C2 (String.make (lcoly-rcolx) ' ')::add_space (y::xs)
+ | (Cocci2(sx,lnx,_,rcolx,_) as x)::((Cocci2(sy,lny,lcoly,_,_)) as y)::xs
+ when !Flag_parsing_c.spacing = Flag_parsing_c.SMPL &&
+ not (lnx = -1) && lnx < lny && not (rcolx = -1) ->
+ (* this only works within a line. could consider whether
+ something should be done to add newlines too, rather than
+ printing them explicitly in unparse_cocci. *)
+ x::C2 (String.make (lny-lnx) '\n')::
+ C2 (String.make (lcoly-1) ' '):: (* -1 is for the + *)
+ add_space (y::xs)
| ((T2(_,Ctx,_)) as x)::((Cocci2 _) as y)::xs -> (* add space on boundary *)
let sx = str_of_token2 x in
let sy = str_of_token2 y in
let rec adjust_indentation xs =
- let _current_tabbing = ref "" in
+ let _current_tabbing = ref ([] : string list) in
let tabbing_unit = ref None in
let string_of_list l = String.concat "" (List.map string_of_char l) in
| (o::os,n::ns) -> loop (os,ns) in (* could check for equality *)
loop (old_tab,new_tab) in
+(*
let remtab tu current_tab =
let current_tab = List.rev(list_of_string current_tab) in
let rec loop = function
([],new_tab) -> string_of_list (List.rev new_tab)
- | (_,[]) -> "" (*weird; tabbing unit used up more than the current tab*)
+ | (_,[]) -> (-*weird; tabbing unit used up more than the current tab*-)
+ ""
| (t::ts,n::ns) when t =<= n -> loop (ts,ns)
- | (_,ns) -> (* mismatch; remove what we can *)
+ | (_,ns) -> (-* mismatch; remove what we can *-)
string_of_list (List.rev ns) in
loop (tu,current_tab) in
+*)
let rec find_first_tab started = function
[] -> ()
| ((T2 (Parser_c.TCommentNewline s, _, _)) as x)::xs
when balanced 0 (fst(Common.span (function x -> not(is_newline x)) xs)) ->
let old_tabbing = !_current_tabbing in
- str_of_token2 x +> new_tabbing +> (fun s -> _current_tabbing := s);
+ str_of_token2 x +> new_tabbing +> (fun s -> _current_tabbing := [s]);
(* only trust the indentation after the first { *)
(if started
- then adjust_tabbing_unit old_tabbing !_current_tabbing);
+ then
+ adjust_tabbing_unit
+ (String.concat "" old_tabbing)
+ (String.concat "" !_current_tabbing));
let coccis_rest = Common.span all_coccis xs in
(match coccis_rest with
(_::_,((T2 (tok,_,_)) as y)::_) when str_of_token2 y =$= "}" ->
(* the case where cocci code has been added before a close } *)
x::aux started (Indent_cocci2::xs)
| _ -> x::aux started xs)
+ | Indent_cocci2::((Cocci2(sy,lny,lcoly,_,_)) as y)::xs
+ when !Flag_parsing_c.spacing = Flag_parsing_c.SMPL ->
+ let tu = String.make (lcoly-1) ' ' in
+ _current_tabbing := tu::(!_current_tabbing);
+ C2 (tu)::aux started (y::xs)
| Indent_cocci2::xs ->
(match !tabbing_unit with
None -> aux started xs
| Some (tu,_) ->
- _current_tabbing := (!_current_tabbing)^tu;
- Cocci2 (tu,-1,-1,-1,None)::aux started xs)
+ _current_tabbing := tu::(!_current_tabbing);
+ (* can't be C2, for later phases *)
+ Cocci2 (tu,-1,-1,-1,None)::aux started xs)
| Unindent_cocci2(permanent)::xs ->
- (match !tabbing_unit with
- None -> aux started xs
- | Some (_,tu) ->
- _current_tabbing := remtab tu (!_current_tabbing);
+ (match !_current_tabbing with
+ [] -> aux started xs
+ | _::new_tabbing ->
+ _current_tabbing := new_tabbing;
aux started xs)
(* border between existing code and cocci code *)
| ((T2 (tok,_,_)) as x)::((Cocci2("\n",_,_,_,_)) as y)::xs
| ((Cocci2("{",_,_,_,_)) as a)::xs -> a::aux true xs
| ((Cocci2("\n",_,_,_,_)) as x)::xs ->
(* dont inline in expr because of weird eval order of ocaml *)
- let s = !_current_tabbing in
+ let s = String.concat "" !_current_tabbing in
+ (* can't be C2, for later phases *)
x::Cocci2 (s,-1,-1,-1,None)::aux started xs
| x::xs -> x::aux started xs in
(aux false xs,!tabbing_unit)
drop_expanded(drop_fake(drop_minus toks))
else
(* phase2: can now start to filter and adjust *)
- let (toks,tu) = adjust_indentation toks in
+ (let (toks,tu) = adjust_indentation toks in
let toks = adjust_before_semicolon toks in(*before remove minus*)
let toks = adjust_after_paren toks in(*also before remove minus*)
let toks = drop_space_at_endline toks in
(* assert Origin + Cocci + C and no minus *)
let toks = add_space toks in
let toks = add_newlines toks tu in
+ let toks = paren_then_brace toks in
let toks = fix_tokens toks in
- toks in
+ toks) in
(* in theory here could reparse and rework the ast! or
* apply some SP. Not before cos julia may have generated
let top_level t =
match Ast.unwrap t with
Ast.FILEINFO(old_file,new_file) -> raise CantBeInPlus
- | Ast.DECL(stmt) -> statement "" stmt
+ | Ast.NONDECL(stmt) -> statement "" stmt
| Ast.CODE(stmt_dots) -> dots force_newline (statement "") stmt_dots
| Ast.ERRORWORDS(exps) -> raise CantBeInPlus
in
Ast.CocciRule(_,_,[body],_,_) -> (* could extend to use attributes *)
(body,
match Ast.unwrap body with
- Ast.DECL(s) -> [[Ast.StatementTag s]]
+ Ast.NONDECL(s) -> [[Ast.StatementTag s]]
| Ast.CODE(ss) -> [[Ast.StmtDotsTag ss]]
| _ -> error body "bad rule body")
| _ -> failwith "bad rule" in
+++ /dev/null
-adjust_pragmas.cmi: ast0_cocci.cmi
-arity.cmi: ast0_cocci.cmi
-ast0_cocci.cmi: type_cocci.cmi ast_cocci.cmi
-ast0toast.cmi: ast_cocci.cmi ast0_cocci.cmi
-ast_cocci.cmi: type_cocci.cmi
-check_meta.cmi: ast_cocci.cmi ast0_cocci.cmi
-comm_assoc.cmi: ast0_cocci.cmi
-compute_lines.cmi: ast0_cocci.cmi
-context_neg.cmi: ../commons/common.cmi ast0_cocci.cmi
-data.cmi: type_cocci.cmi ../commons/common.cmi ast_cocci.cmi ast0_cocci.cmi
-disjdistr.cmi: ast_cocci.cmi
-free_vars.cmi: ast_cocci.cmi
-function_prototypes.cmi: ast_cocci.cmi ast0_cocci.cmi
-get_constants.cmi: ast_cocci.cmi
-get_constants2.cmi: ast_cocci.cmi
-id_utils.cmi: get_constants2.cmi
-index.cmi: ast0_cocci.cmi
-insert_plus.cmi: ast0_cocci.cmi
-iso_compile.cmi: iso_pattern.cmi
-iso_pattern.cmi: visitor_ast0_types.cmo ast_cocci.cmi ast0_cocci.cmi
-merge.cmi: ast_cocci.cmi ast0_cocci.cmi
-parse_cocci.cmi: get_constants2.cmi ast_cocci.cmi
-plus.cmi: ast_cocci.cmi
-pretty_print_cocci.cmi: ast_cocci.cmi
-safe_for_multi_decls.cmi: ast_cocci.cmi
-simple_assignments.cmi: ast0_cocci.cmi
-single_statement.cmi: ast0_cocci.cmi
-test_exps.cmi: ast0_cocci.cmi
-top_level.cmi: ast0_cocci.cmi
-type_cocci.cmi:
-type_infer.cmi: ast0_cocci.cmi
-unify_ast.cmi: ast_cocci.cmi
-unitary_ast0.cmi: ast0_cocci.cmi
-unparse_ast0.cmi: ast0_cocci.cmi
-visitor_ast.cmi: ast_cocci.cmi
-visitor_ast0.cmi: visitor_ast0_types.cmo ast_cocci.cmi ast0_cocci.cmi
-adjacency.cmo: visitor_ast0_types.cmo visitor_ast0.cmi ast0_cocci.cmi \
- adjacency.cmi
-adjacency.cmx: visitor_ast0_types.cmx visitor_ast0.cmx ast0_cocci.cmx \
- adjacency.cmi
-adjust_pragmas.cmo: visitor_ast0_types.cmo visitor_ast0.cmi ast_cocci.cmi \
- ast0_cocci.cmi adjust_pragmas.cmi
-adjust_pragmas.cmx: visitor_ast0_types.cmx visitor_ast0.cmx ast_cocci.cmx \
- ast0_cocci.cmx adjust_pragmas.cmi
-arity.cmo: ast_cocci.cmi ast0_cocci.cmi arity.cmi
-arity.cmx: ast_cocci.cmx ast0_cocci.cmx arity.cmi
-ast0_cocci.cmo: type_cocci.cmi ../globals/flag.cmo ../commons/common.cmi \
- ast_cocci.cmi ast0_cocci.cmi
-ast0_cocci.cmx: type_cocci.cmx ../globals/flag.cmx ../commons/common.cmx \
- ast_cocci.cmx ast0_cocci.cmi
-ast0toast.cmo: visitor_ast0_types.cmo visitor_ast0.cmi type_cocci.cmi \
- ../globals/flag.cmo ../commons/ocamlextra/dumper.cmi ast_cocci.cmi \
- ast0_cocci.cmi ast0toast.cmi
-ast0toast.cmx: visitor_ast0_types.cmx visitor_ast0.cmx type_cocci.cmx \
- ../globals/flag.cmx ../commons/ocamlextra/dumper.cmx ast_cocci.cmx \
- ast0_cocci.cmx ast0toast.cmi
-ast_cocci.cmo: type_cocci.cmi ../commons/common.cmi ast_cocci.cmi
-ast_cocci.cmx: type_cocci.cmx ../commons/common.cmx ast_cocci.cmi
-check_meta.cmo: visitor_ast0_types.cmo visitor_ast0.cmi type_cocci.cmi \
- ../commons/common.cmi ast_cocci.cmi ast0_cocci.cmi check_meta.cmi
-check_meta.cmx: visitor_ast0_types.cmx visitor_ast0.cmx type_cocci.cmx \
- ../commons/common.cmx ast_cocci.cmx ast0_cocci.cmx check_meta.cmi
-comm_assoc.cmo: visitor_ast0_types.cmo visitor_ast0.cmi unparse_ast0.cmi \
- ../globals/flag.cmo ast_cocci.cmi ast0_cocci.cmi comm_assoc.cmi
-comm_assoc.cmx: visitor_ast0_types.cmx visitor_ast0.cmx unparse_ast0.cmx \
- ../globals/flag.cmx ast_cocci.cmx ast0_cocci.cmx comm_assoc.cmi
-compute_lines.cmo: ast_cocci.cmi ast0_cocci.cmi compute_lines.cmi
-compute_lines.cmx: ast_cocci.cmx ast0_cocci.cmx compute_lines.cmi
-context_neg.cmo: visitor_ast0_types.cmo visitor_ast0.cmi unparse_ast0.cmi \
- index.cmi ../globals/flag.cmo compute_lines.cmi ../commons/common.cmi \
- ast_cocci.cmi ast0_cocci.cmi context_neg.cmi
-context_neg.cmx: visitor_ast0_types.cmx visitor_ast0.cmx unparse_ast0.cmx \
- index.cmx ../globals/flag.cmx compute_lines.cmx ../commons/common.cmx \
- ast_cocci.cmx ast0_cocci.cmx context_neg.cmi
-data.cmo: type_cocci.cmi ../commons/common.cmi ast_cocci.cmi ast0_cocci.cmi \
- data.cmi
-data.cmx: type_cocci.cmx ../commons/common.cmx ast_cocci.cmx ast0_cocci.cmx \
- data.cmi
-disjdistr.cmo: visitor_ast.cmi ../globals/flag.cmo ../commons/common.cmi \
- ast_cocci.cmi disjdistr.cmi
-disjdistr.cmx: visitor_ast.cmx ../globals/flag.cmx ../commons/common.cmx \
- ast_cocci.cmx disjdistr.cmi
-flag_parsing_cocci.cmo:
-flag_parsing_cocci.cmx:
-free_vars.cmo: visitor_ast.cmi type_cocci.cmi ../commons/common.cmi \
- ast_cocci.cmi free_vars.cmi
-free_vars.cmx: visitor_ast.cmx type_cocci.cmx ../commons/common.cmx \
- ast_cocci.cmx free_vars.cmi
-function_prototypes.cmo: visitor_ast0_types.cmo visitor_ast0.cmi \
- iso_pattern.cmi insert_plus.cmi context_neg.cmi compute_lines.cmi \
- ast_cocci.cmi ast0toast.cmi ast0_cocci.cmi function_prototypes.cmi
-function_prototypes.cmx: visitor_ast0_types.cmx visitor_ast0.cmx \
- iso_pattern.cmx insert_plus.cmx context_neg.cmx compute_lines.cmx \
- ast_cocci.cmx ast0toast.cmx ast0_cocci.cmx function_prototypes.cmi
-get_constants.cmo: visitor_ast.cmi type_cocci.cmi ../globals/flag.cmo \
- ../commons/common.cmi ast_cocci.cmi get_constants.cmi
-get_constants.cmx: visitor_ast.cmx type_cocci.cmx ../globals/flag.cmx \
- ../commons/common.cmx ast_cocci.cmx get_constants.cmi
-get_constants2.cmo: visitor_ast.cmi type_cocci.cmi ../globals/flag.cmo \
- ../commons/common.cmi ast_cocci.cmi get_constants2.cmi
-get_constants2.cmx: visitor_ast.cmx type_cocci.cmx ../globals/flag.cmx \
- ../commons/common.cmx ast_cocci.cmx get_constants2.cmi
-id_utils.cmo: get_constants2.cmi ../commons/common.cmi id_utils.cmi
-id_utils.cmx: get_constants2.cmx ../commons/common.cmx id_utils.cmi
-index.cmo: ast_cocci.cmi ast0_cocci.cmi index.cmi
-index.cmx: ast_cocci.cmx ast0_cocci.cmx index.cmi
-insert_plus.cmo: visitor_ast0_types.cmo visitor_ast0.cmi \
- pretty_print_cocci.cmi context_neg.cmi ast_cocci.cmi ast0toast.cmi \
- ast0_cocci.cmi insert_plus.cmi
-insert_plus.cmx: visitor_ast0_types.cmx visitor_ast0.cmx \
- pretty_print_cocci.cmx context_neg.cmx ast_cocci.cmx ast0toast.cmx \
- ast0_cocci.cmx insert_plus.cmi
-iso_compile.cmo: visitor_ast0_types.cmo visitor_ast0.cmi \
- ../commons/common.cmi ast_cocci.cmi ast0_cocci.cmi iso_compile.cmi
-iso_compile.cmx: visitor_ast0_types.cmx visitor_ast0.cmx \
- ../commons/common.cmx ast_cocci.cmx ast0_cocci.cmx iso_compile.cmi
-iso_pattern.cmo: visitor_ast0_types.cmo visitor_ast0.cmi unparse_ast0.cmi \
- type_cocci.cmi flag_parsing_cocci.cmo ../globals/flag.cmo \
- ../commons/ocamlextra/dumper.cmi compute_lines.cmi ../commons/common.cmi \
- ast_cocci.cmi ast0_cocci.cmi iso_pattern.cmi
-iso_pattern.cmx: visitor_ast0_types.cmx visitor_ast0.cmx unparse_ast0.cmx \
- type_cocci.cmx flag_parsing_cocci.cmx ../globals/flag.cmx \
- ../commons/ocamlextra/dumper.cmx compute_lines.cmx ../commons/common.cmx \
- ast_cocci.cmx ast0_cocci.cmx iso_pattern.cmi
-main.cmo: parse_cocci.cmi
-main.cmx: parse_cocci.cmx
-merge.cmo: visitor_ast0.cmi ast_cocci.cmi ast0_cocci.cmi merge.cmi
-merge.cmx: visitor_ast0.cmx ast_cocci.cmx ast0_cocci.cmx merge.cmi
-parse_aux.cmo: type_cocci.cmi semantic_cocci.cmo ../globals/flag.cmo data.cmi \
- ../commons/common.cmi ast_cocci.cmi ast0_cocci.cmi
-parse_aux.cmx: type_cocci.cmx semantic_cocci.cmx ../globals/flag.cmx data.cmx \
- ../commons/common.cmx ast_cocci.cmx ast0_cocci.cmx
-parse_cocci.cmo: visitor_ast0_types.cmo visitor_ast0.cmi unitary_ast0.cmi \
- type_infer.cmi test_exps.cmi single_statement.cmi simple_assignments.cmi \
- semantic_cocci.cmo safe_for_multi_decls.cmi pretty_print_cocci.cmi \
- parse_aux.cmo iso_pattern.cmi iso_compile.cmi insert_plus.cmi \
- get_constants2.cmi function_prototypes.cmi free_vars.cmi \
- flag_parsing_cocci.cmo ../globals/flag.cmo \
- ../commons/ocamlextra/dumper.cmi disjdistr.cmi data.cmi context_neg.cmi \
- compute_lines.cmi ../commons/common.cmi comm_assoc.cmi check_meta.cmi \
- ast_cocci.cmi ast0toast.cmi ast0_cocci.cmi arity.cmi adjust_pragmas.cmi \
- adjacency.cmi parse_cocci.cmi
-parse_cocci.cmx: visitor_ast0_types.cmx visitor_ast0.cmx unitary_ast0.cmx \
- type_infer.cmx test_exps.cmx single_statement.cmx simple_assignments.cmx \
- semantic_cocci.cmx safe_for_multi_decls.cmx pretty_print_cocci.cmx \
- parse_aux.cmx iso_pattern.cmx iso_compile.cmx insert_plus.cmx \
- get_constants2.cmx function_prototypes.cmx free_vars.cmx \
- flag_parsing_cocci.cmx ../globals/flag.cmx \
- ../commons/ocamlextra/dumper.cmx disjdistr.cmx data.cmx context_neg.cmx \
- compute_lines.cmx ../commons/common.cmx comm_assoc.cmx check_meta.cmx \
- ast_cocci.cmx ast0toast.cmx ast0_cocci.cmx arity.cmx adjust_pragmas.cmx \
- adjacency.cmx parse_cocci.cmi
-plus.cmo: visitor_ast.cmi ast_cocci.cmi plus.cmi
-plus.cmx: visitor_ast.cmx ast_cocci.cmx plus.cmi
-pretty_print_cocci.cmo: type_cocci.cmi ../globals/flag.cmo \
- ../commons/common.cmi ast_cocci.cmi pretty_print_cocci.cmi
-pretty_print_cocci.cmx: type_cocci.cmx ../globals/flag.cmx \
- ../commons/common.cmx ast_cocci.cmx pretty_print_cocci.cmi
-safe_for_multi_decls.cmo: visitor_ast.cmi ast_cocci.cmi \
- safe_for_multi_decls.cmi
-safe_for_multi_decls.cmx: visitor_ast.cmx ast_cocci.cmx \
- safe_for_multi_decls.cmi
-semantic_cocci.cmo:
-semantic_cocci.cmx:
-simple_assignments.cmo: visitor_ast0_types.cmo visitor_ast0.cmi \
- ../globals/flag.cmo ../commons/common.cmi ast_cocci.cmi ast0_cocci.cmi \
- simple_assignments.cmi
-simple_assignments.cmx: visitor_ast0_types.cmx visitor_ast0.cmx \
- ../globals/flag.cmx ../commons/common.cmx ast_cocci.cmx ast0_cocci.cmx \
- simple_assignments.cmi
-single_statement.cmo: visitor_ast0_types.cmo visitor_ast0.cmi iso_pattern.cmi \
- flag_parsing_cocci.cmo compute_lines.cmi ast_cocci.cmi ast0_cocci.cmi \
- single_statement.cmi
-single_statement.cmx: visitor_ast0_types.cmx visitor_ast0.cmx iso_pattern.cmx \
- flag_parsing_cocci.cmx compute_lines.cmx ast_cocci.cmx ast0_cocci.cmx \
- single_statement.cmi
-test_exps.cmo: visitor_ast0_types.cmo visitor_ast0.cmi ast_cocci.cmi \
- ast0_cocci.cmi test_exps.cmi
-test_exps.cmx: visitor_ast0_types.cmx visitor_ast0.cmx ast_cocci.cmx \
- ast0_cocci.cmx test_exps.cmi
-top_level.cmo: ast0_cocci.cmi top_level.cmi
-top_level.cmx: ast0_cocci.cmx top_level.cmi
-type_cocci.cmo: type_cocci.cmi
-type_cocci.cmx: type_cocci.cmi
-type_infer.cmo: visitor_ast0_types.cmo visitor_ast0.cmi type_cocci.cmi \
- ast_cocci.cmi ast0_cocci.cmi type_infer.cmi
-type_infer.cmx: visitor_ast0_types.cmx visitor_ast0.cmx type_cocci.cmx \
- ast_cocci.cmx ast0_cocci.cmx type_infer.cmi
-unify_ast.cmo: visitor_ast.cmi ast_cocci.cmi unify_ast.cmi
-unify_ast.cmx: visitor_ast.cmx ast_cocci.cmx unify_ast.cmi
-unitary_ast0.cmo: visitor_ast0_types.cmo visitor_ast0.cmi ../globals/flag.cmo \
- ast_cocci.cmi ast0_cocci.cmi unitary_ast0.cmi
-unitary_ast0.cmx: visitor_ast0_types.cmx visitor_ast0.cmx ../globals/flag.cmx \
- ast_cocci.cmx ast0_cocci.cmx unitary_ast0.cmi
-unparse_ast0.cmo: type_cocci.cmi pretty_print_cocci.cmi ../commons/common.cmi \
- ast_cocci.cmi ast0_cocci.cmi unparse_ast0.cmi
-unparse_ast0.cmx: type_cocci.cmx pretty_print_cocci.cmx ../commons/common.cmx \
- ast_cocci.cmx ast0_cocci.cmx unparse_ast0.cmi
-visitor_ast.cmo: ast_cocci.cmi ast0_cocci.cmi visitor_ast.cmi
-visitor_ast.cmx: ast_cocci.cmx ast0_cocci.cmx visitor_ast.cmi
-visitor_ast0.cmo: visitor_ast0_types.cmo ast_cocci.cmi ast0_cocci.cmi \
- visitor_ast0.cmi
-visitor_ast0.cmx: visitor_ast0_types.cmx ast_cocci.cmx ast0_cocci.cmx \
- visitor_ast0.cmi
-visitor_ast0_types.cmo: ast_cocci.cmi ast0_cocci.cmi
-visitor_ast0_types.cmx: ast_cocci.cmx ast0_cocci.cmx
if mcode2arity old_file = Ast0.NONE && mcode2arity new_file = Ast0.NONE
then Ast0.FILEINFO(mcode old_file,mcode new_file)
else fail t "unexpected arity for file info"
- | Ast0.DECL(stmt) ->
- Ast0.DECL(statement tgt stmt)
+ | Ast0.NONDECL(stmt) ->
+ Ast0.NONDECL(statement tgt stmt)
| Ast0.CODE(rule_elem_dots) ->
Ast0.CODE(concat_dots (statement tgt) rule_elem_dots)
+ | Ast0.TOPCODE(rule_elem_dots) -> fail t "eliminated by top_level"
| Ast0.ERRORWORDS(exps) ->
Ast0.ERRORWORDS(List.map (top_expression false Ast0.NONE) exps)
| Ast0.OTHER(_) -> fail t "eliminated by top_level")
(* Top-level code *)
and base_top_level =
- DECL of statement
+ NONDECL of statement
+ | TOPCODE of statement dots
| CODE of statement dots
| FILEINFO of string mcode (* old file *) * string mcode (* new file *)
| ERRORWORDS of expression list
| Pointer(ty,_) -> TC.Pointer(ast0_type_to_type ty)
| FunctionPointer(ty,_,_,_,_,params,_) ->
TC.FunctionPointer(ast0_type_to_type ty)
- | FunctionType _ -> failwith "not supported"
+ | FunctionType _ -> TC.Unknown (*failwith "not supported"*)
| Array(ety,_,_,_) -> TC.Array(ast0_type_to_type ety)
| EnumName(su,Some tag) ->
(match unwrap tag with
(* Top-level code *)
and base_top_level =
- DECL of statement
+ NONDECL of statement (* cannot match all of a top-level declaration *)
+ | TOPCODE of statement dots
| CODE of statement dots
| FILEINFO of string mcode (* old file *) * string mcode (* new file *)
| ERRORWORDS of expression list
(match Ast0.unwrap t with
Ast0.FILEINFO(old_file,new_file) ->
Ast.FILEINFO(mcode old_file,mcode new_file)
- | Ast0.DECL(stmt) -> Ast.DECL(statement stmt)
- | Ast0.CODE(rule_elem_dots) ->
- Ast.CODE(statement_dots rule_elem_dots)
+ | Ast0.NONDECL(stmt) -> Ast.NONDECL(statement stmt)
+ | Ast0.CODE(rule_elem_dots) -> Ast.CODE(statement_dots rule_elem_dots)
| Ast0.ERRORWORDS(exps) -> Ast.ERRORWORDS(List.map expression exps)
- | Ast0.OTHER(_) -> failwith "eliminated by top_level")
+ | Ast0.OTHER(_) | Ast0.TOPCODE(_) -> failwith "eliminated by top_level")
(* --------------------------------------------------------------------- *)
(* Entry point for minus code *)
| IncDots
and base_top_level =
- DECL of statement
+ NONDECL of statement
| CODE of statement dots
| FILEINFO of string mcode (* old file *) * string mcode (* new file *)
| ERRORWORDS of expression list
| IncDots
and base_top_level =
- DECL of statement
+ NONDECL of statement (* cannot match all of a top-level declaration *)
| CODE of statement dots
| FILEINFO of string mcode (* old file *) * string mcode (* new file *)
| ERRORWORDS of expression list
let top_level old_metas table minus t =
match Ast0.unwrap t with
- Ast0.DECL(stmt) -> statement old_metas table minus stmt
- | Ast0.CODE(stmt_dots) -> dots (statement old_metas table minus) stmt_dots
+ Ast0.NONDECL(stmt) -> statement old_metas table minus stmt
+ | Ast0.CODE(stmt_dots) | Ast0.TOPCODE(stmt_dots) ->
+ dots (statement old_metas table minus) stmt_dots
| Ast0.ERRORWORDS(exps) ->
List.iter (expression FN old_metas table minus) exps
| _ -> () (* no metavariables possible *)
let top_level t =
match Ast0.unwrap t with
Ast0.FILEINFO(old_file,new_file) -> t
- | Ast0.DECL(stmt) ->
- let stmt = statement stmt in mkres t (Ast0.DECL(stmt)) stmt stmt
+ | Ast0.NONDECL(stmt) ->
+ let stmt = statement stmt in mkres t (Ast0.NONDECL(stmt)) stmt stmt
| Ast0.CODE(rule_elem_dots) ->
let rule_elem_dots = dots is_stm_dots None statement rule_elem_dots in
mkres t (Ast0.CODE(rule_elem_dots)) rule_elem_dots rule_elem_dots
| Ast0.ERRORWORDS(exps) -> t
- | Ast0.OTHER(_) -> failwith "eliminated by top_level"
+ | Ast0.OTHER(_) | Ast0.TOPCODE(_) -> failwith "eliminated by top_level"
(* --------------------------------------------------------------------- *)
(* Entry points *)
let rec equal_top_level t1 t2 =
match (Ast0.unwrap t1,Ast0.unwrap t2) with
- (Ast0.DECL(_),Ast0.DECL(_)) -> true
+ (Ast0.NONDECL(_),Ast0.NONDECL(_)) -> true
| (Ast0.FILEINFO(old_file1,new_file1),Ast0.FILEINFO(old_file2,new_file2)) ->
equal_mcode old_file1 old_file2 && equal_mcode new_file1 new_file2
| (Ast0.CODE(_),Ast0.CODE(_)) -> true
let iscode t =
match Ast0.unwrap t with
- Ast0.DECL(_) -> true
+ Ast0.NONDECL(_) -> true
| Ast0.FILEINFO(_) -> true
| Ast0.ERRORWORDS(_) -> false
| Ast0.CODE(_) -> true
+ | Ast0.TOPCODE(_)
| Ast0.OTHER(_) -> failwith "unexpected top level code"
(* ------------------------------------------------------------------- *)
[] -> []
| x::rest ->
(match Ast0.unwrap x with
- Ast0.DECL(s) -> let stms = loop rest in s::stms
+ Ast0.NONDECL(s) -> let stms = loop rest in s::stms
| Ast0.CODE(ss) ->
let stms = loop rest in
(match Ast0.unwrap ss with
| Ast0.Define(_,_,_,_) -> true
| _ -> false
+(* consider code and topcode to be the same; difference handled
+in top_level.ml *)
let check_compatible m p =
let fail _ =
failwith
"incompatible minus and plus code starting on lines %d and %d"
(Ast0.get_line m) (Ast0.get_line p)) in
match (Ast0.unwrap m, Ast0.unwrap p) with
- (Ast0.DECL(decl1),Ast0.DECL(decl2)) ->
+ (Ast0.NONDECL(decl1),Ast0.NONDECL(decl2)) ->
if not (is_decl decl1 && is_decl decl2)
then fail()
- | (Ast0.DECL(decl1),Ast0.CODE(code2)) ->
+ | (Ast0.NONDECL(decl1),Ast0.CODE(code2)) ->
+ (* This is probably the only important case. We don't want to
+ replace top-level declarations by arbitrary code. *)
let v1 = is_decl decl1 in
let v2 = List.for_all is_toplevel (Ast0.undots code2) in
- if !Flag.make_hrule = None && v1 && not v2 then fail()
- | (Ast0.CODE(code1),Ast0.DECL(decl2)) ->
+ if !Flag.make_hrule = None && v1 && not v2
+ then fail()
+ | (Ast0.CODE(code1),Ast0.NONDECL(decl2)) ->
let v1 = List.for_all is_toplevel (Ast0.undots code1) in
let v2 = is_decl decl2 in
- if v1 && not v2 then fail()
+ if v1 && not v2
+ then fail()
| (Ast0.CODE(code1),Ast0.CODE(code2)) ->
let v1 = isonly is_init code1 in
let v2a = isonly is_init code2 in
testers;
let v1 = isonly is_fndecl code1 in
let v2 = List.for_all is_toplevel (Ast0.undots code2) in
- if !Flag.make_hrule = None && v1 && not v2 then fail()
+ if !Flag.make_hrule = None && v1 && not v2
+ then fail()
| (Ast0.FILEINFO(_,_),Ast0.FILEINFO(_,_)) -> ()
| (Ast0.OTHER(_),Ast0.OTHER(_)) -> ()
| _ -> fail()
let collect_functions stmt_dots =
List.concat (List.map collect_function (Ast0.undots stmt_dots))
+let drop_positions =
+ let mcode (term,arity,info,mc,_,adj) =
+ (term,arity,info,mc,ref [],adj) in
+ let donothing r k e = k e in
+ let res =
+ V0.flat_rebuilder
+ mcode mcode mcode mcode mcode mcode mcode mcode mcode mcode mcode mcode
+ donothing donothing donothing donothing donothing donothing
+ donothing donothing donothing donothing donothing donothing donothing
+ donothing donothing in
+ res.VT0.rebuilder_rec_statement
+
let get_all_functions rule =
let res =
match Ast0.unwrap rule with
- Ast0.DECL(stmt) -> collect_function stmt
+ Ast0.NONDECL(stmt) -> collect_function stmt
| Ast0.CODE(rule_elem_dots) -> collect_functions rule_elem_dots
| _ -> [] in
List.map
(function (nm,def,vl) ->
(nm,
- (def,(Iso_pattern.rebuild_mcode None).VT0.rebuilder_rec_statement vl)))
+ (def,
+ drop_positions
+ ((Iso_pattern.rebuild_mcode None).VT0.rebuilder_rec_statement vl))))
res
(* --------------------------------------------------------------------- *)
| _ -> dec)
| _ -> dec
+let mkcode proto =
+ Ast0.copywrap proto (Ast0.CODE(Ast0.copywrap proto (Ast0.DOTS [proto])))
+
let merge mproto pproto =
- let mproto =
- Compute_lines.compute_lines true
- [Ast0.copywrap mproto (Ast0.DECL mproto)] in
- let pproto =
- Compute_lines.compute_lines true
- [Ast0.copywrap pproto (Ast0.DECL pproto)] in
+ let mproto = Compute_lines.compute_lines true [mkcode mproto] in
+ let pproto = Compute_lines.compute_lines true [mkcode pproto] in
let (m,p) = List.split(Context_neg.context_neg mproto pproto) in
Insert_plus.insert_plus m p true (* no isos for protos *);
(* convert to ast so that the + code will fall down to the tokens
- and off the artificially added Ast0.DECL *)
+ and off the artificially added Ast0.CODE *)
let mproto = Ast0toast.ast0toast_toplevel (List.hd mproto) in
(* clean up the wrapping added above *)
match Ast.unwrap mproto with
- Ast.DECL mproto -> mproto
+ Ast.CODE mproto -> List.hd (Ast.undots mproto)
| _ -> failwith "not possible"
let make_rule rule_name = function
List.map
(function x ->
match Ast0.unwrap x with
- Ast0.DECL(stmt) ->
+ Ast0.NONDECL(stmt) ->
(match Ast0.unwrap stmt with
Ast0.FunDecl(_,fninfo,name,lp,params,rp,lbrace,body,rbrace) ->
- (try Ast0.rewrap x (Ast0.DECL(List.assoc name table))
+ (try Ast0.rewrap x (Ast0.NONDECL(List.assoc name table))
with Not_found -> x)
| _ -> x)
| Ast0.CODE(rule_elem_dots) ->
| (a,b,c,d)::rest ->
let (ax,bx,cx,dx) = split4 rest in (a::ax,b::bx,c::cx,d::dx)
+let mk_ast_code proto =
+ Ast.rewrap proto (Ast.CODE(Ast.rewrap proto (Ast.DOTS [proto])))
+
let process rule_name rule_metavars dropped_isos minus plus ruletype =
let minus_functions = List.concat (List.map get_all_functions minus) in
match minus_functions with
Ast.CocciRule
("proto for "^rule_name,
(Ast.Dep rule_name,dropped_isos,Ast.Forall),
- [Ast.rewrap x (Ast.DECL x)],
+ [mk_ast_code x],
[false],ruletype)))
| x::_ ->
let drules =
Ast.CocciRule
("proto for "^rule_name,
(Ast.Dep rule_name,dropped_isos,Ast.Forall),
- [Ast.rewrap x (Ast.DECL (Ast.rewrap x (Ast.Disj drules)))],
+ [mk_ast_code (Ast.rewrap x (Ast.Disj drules))],
[false],ruletype) in
((mdef_metavars,minus),Some(metavars,res))
(* create an index for each constructor *)
-(* current max is 153 *)
+(* current max is 154 *)
(* doesn't really work - requires that identical terms with no token
subterms (eg dots) not appear on the same line *)
let top_level t =
match Ast0.unwrap t with
- Ast0.DECL(stmt) -> [90]
+ Ast0.NONDECL(stmt) -> [90]
| Ast0.FILEINFO(old_file,new_file) -> [92]
| Ast0.CODE(stmt_dots) -> [94]
| Ast0.ERRORWORDS(exps) -> [95]
| Ast0.OTHER(_) -> [96]
+ | Ast0.TOPCODE(_) -> [154]
(* 99-101 already used *)
let toplevel r k e =
match Ast0.unwrap e with
- Ast0.DECL(s) -> r.VT0.combiner_rec_statement s
+ Ast0.NONDECL(s) -> r.VT0.combiner_rec_statement s
| Ast0.CODE(sdots) -> r.VT0.combiner_rec_statement_dots sdots
| _ -> do_nothing mk_code r k e in
(match repl with
Ast.NOREPLACEMENT ->
let (bef,ti) = init p infop in
- Printf.printf "attachbefore 1 %s\n" (it2c c);
replacements := (Ast.REPLACEMENT(bef,c),ti)
| Ast.REPLACEMENT(repl,it) ->
- Printf.printf "attachbefore 2 %s %s\n" (it2c c) (it2c it);
let it = Ast.lub_count it c in
let (bef,ti) = insert p infop repl ti in
replacements := (Ast.REPLACEMENT(bef,it),ti))
(* sort of a hack, because there is no disj at top level *)
let transform_top (metavars,alts,name) e =
match Ast0.unwrap e with
- Ast0.DECL(declstm) ->
+ Ast0.NONDECL(declstm) ->
(try
let strip alts =
List.map
| _ -> raise (Failure "")))
alts in
let (count,mv,s) = transform_stmt (metavars,strip alts,name) declstm in
- (count,mv,Ast0.rewrap e (Ast0.DECL(s)))
+ (count,mv,Ast0.rewrap e (Ast0.NONDECL(s)))
with Failure _ -> (0,[],e))
| Ast0.CODE(stmts) ->
let (count,mv,res) =
then (* not actually used for anything, except context_neg *)
List.map
(Iso_pattern.rebuild_mcode None).VT0.rebuilder_rec_top_level
- minus_res
+ (Top_level.top_level false minus_res)
else
if is_expression
then parse_one "plus" PC.plus_exp_main file plus_tokens
else parse_one "plus" PC.plus_main file plus_tokens in
+ let plus_res = Top_level.top_level false plus_res in
+ (* minus code has to be CODE if the + code is CODE, otherwise
+ doesn't matter if + code is CODE or DECL or TOPCODE *)
+ let minus_res =
+ let any_code =
+ List.exists
+ (function x ->
+ match Ast0.unwrap x with Ast0.CODE _ -> true | _ -> false)
+ plus_res in
+ if any_code
+ then Top_level.top_level true minus_res
+ else Top_level.top_level false minus_res in
+ let minus_res = Top_level.clean minus_res in
+ let plus_res = Top_level.clean plus_res in
(*
Unparse_ast0.unparse plus_res;
Printf.printf "after plus parse\n";
# 816 "parser_cocci_menhir.mly"
( match f@b(*@ew*) with
[] -> raise (Semantic_cocci.Semantic "minus slice can't be empty")
- | code -> Top_level.top_level code )
+ | code -> code )
# 23275 "parser_cocci_menhir.ml"
in
_menhir_env.MenhirLib.EngineTypes.stack <- {
# 830 "parser_cocci_menhir.mly"
( match f@[b](*@ew*) with
[] -> raise (Semantic_cocci.Semantic "minus slice can't be empty")
- | code -> Top_level.top_level code )
+ | code -> code )
# 23307 "parser_cocci_menhir.ml"
in
_menhir_env.MenhirLib.EngineTypes.stack <- {
let _endpos = _endpos__1_ in
let _v : 'tv_minus_start =
# 2078 "parser_cocci_menhir.mly"
- ( [Ast0.wrap(Ast0.DECL(_1))] )
+ ( [Ast0.wrap(Ast0.OTHER(_1))] )
# 23523 "parser_cocci_menhir.ml"
in
_menhir_env.MenhirLib.EngineTypes.stack <- {
let _endpos = _endpos__2_ in
let _v : 'tv_plus_after_dots =
# 2149 "parser_cocci_menhir.mly"
- ( Ast0.wrap(Ast0.DECL(_1))::_2 )
+ ( Ast0.wrap(Ast0.OTHER(_1))::_2 )
# 28262 "parser_cocci_menhir.ml"
in
_menhir_env.MenhirLib.EngineTypes.stack <- {
let _endpos = _endpos__2_ in
let _v : 'tv_plus_after_stm =
# 2156 "parser_cocci_menhir.mly"
- ( Ast0.wrap(Ast0.DECL(_1))::_2 )
+ ( Ast0.wrap(Ast0.OTHER(_1))::_2 )
# 28416 "parser_cocci_menhir.ml"
in
_menhir_env.MenhirLib.EngineTypes.stack <- {
let _endpos = _endpos_b_ in
let _v : 'tv_plus_body =
# 824 "parser_cocci_menhir.mly"
- ( Top_level.top_level (f@b(*@ew*)) )
+ ( f@b(*@ew*) )
# 28476 "parser_cocci_menhir.ml"
in
_menhir_env.MenhirLib.EngineTypes.stack <- {
let _endpos = _endpos_b_ in
let _v : 'tv_plus_exp_body =
# 838 "parser_cocci_menhir.mly"
- ( Top_level.top_level (f@[b](*@ew*)) )
+ ( f@[b](*@ew*) )
# 28506 "parser_cocci_menhir.ml"
in
_menhir_env.MenhirLib.EngineTypes.stack <- {
let _endpos = _endpos__2_ in
let _v : 'tv_plus_start =
# 2136 "parser_cocci_menhir.mly"
- ( Ast0.wrap(Ast0.DECL(_1))::_2 )
+ ( Ast0.wrap(Ast0.OTHER(_1))::_2 )
# 28836 "parser_cocci_menhir.ml"
in
_menhir_env.MenhirLib.EngineTypes.stack <- {
/*ew=loption(error_words)*/
{ match f@b(*@ew*) with
[] -> raise (Semantic_cocci.Semantic "minus slice can't be empty")
- | code -> Top_level.top_level code }
+ | code -> code }
plus_body:
f=loption(filespec)
b=loption(plus_start)
/*ew=loption(error_words)*/
- { Top_level.top_level (f@b(*@ew*)) }
+ { f@b(*@ew*) }
minus_exp_body:
f=loption(filespec)
/*ew=loption(error_words)*/
{ match f@[b](*@ew*) with
[] -> raise (Semantic_cocci.Semantic "minus slice can't be empty")
- | code -> Top_level.top_level code }
+ | code -> code }
plus_exp_body:
f=loption(filespec)
b=top_eexpr
/*ew=loption(error_words)*/
- { Top_level.top_level (f@[b](*@ew*)) }
+ { f@[b](*@ew*) }
filespec:
TMinusFile TPlusFile
/* doesn't allow only ... */
minus_start:
- fundecl { [Ast0.wrap(Ast0.DECL($1))] }
+ fundecl { [Ast0.wrap(Ast0.OTHER($1))] }
| ctype { [Ast0.wrap(Ast0.OTHER(Ast0.wrap(Ast0.Ty($1))))] }
| top_init { [Ast0.wrap(Ast0.OTHER(Ast0.wrap(Ast0.TopInit($1))))] }
| toplevel_seq_startne(toplevel_after_dots_init)
{ (Ast0.wrap(Ast0.OTHER($1)))::$2 }
| expr plus_after_exp
{ (Ast0.wrap(Ast0.OTHER(Ast0.wrap(Ast0.Exp($1)))))::$2 }
-| fundecl plus_after_stm { Ast0.wrap(Ast0.DECL($1))::$2 }
+| fundecl plus_after_stm { Ast0.wrap(Ast0.OTHER($1))::$2 }
| decl_statement_expr plus_after_stm
{ (List.map (function x -> Ast0.wrap(Ast0.OTHER(x))) $1)@$2 }
| TNothing plus_after_exp {$2}
| expr plus_after_exp
{ (Ast0.wrap(Ast0.OTHER(Ast0.wrap(Ast0.Exp($1)))))::$2 }
-| fundecl plus_after_stm { Ast0.wrap(Ast0.DECL($1))::$2 }
+| fundecl plus_after_stm { Ast0.wrap(Ast0.OTHER($1))::$2 }
| decl_statement_expr plus_after_stm
{ (List.map (function x -> Ast0.wrap(Ast0.OTHER(x))) $1)@$2 }
plus_after_stm:
/* empty */ {[]}
| stm_dots plus_after_dots { (Ast0.wrap(Ast0.OTHER($1)))::$2 }
-| fundecl plus_after_stm { Ast0.wrap(Ast0.DECL($1))::$2 }
+| fundecl plus_after_stm { Ast0.wrap(Ast0.OTHER($1))::$2 }
| decl_statement plus_after_stm
{ (List.map (function x -> Ast0.wrap(Ast0.OTHER(x))) $1)@$2 }
Ast.FILEINFO(old_file,new_file) ->
print_string "--- "; mcode print_string old_file; force_newline();
print_string "+++ "; mcode print_string new_file
- | Ast.DECL(stmt) -> statement "" stmt
+ | Ast.NONDECL(stmt) -> statement "" stmt
| Ast.CODE(stmt_dots) ->
dots force_newline (statement "") stmt_dots
| Ast.ERRORWORDS(exps) ->
let top_level t =
Ast0.rewrap t
(match Ast0.unwrap t with
- Ast0.DECL(stmt_dots) -> Ast0.DECL(statement true true stmt_dots)
+ Ast0.NONDECL(stmt_dots) -> Ast0.NONDECL(statement true true stmt_dots)
| Ast0.CODE(stmt_dots) -> Ast0.CODE(statement_dots true true stmt_dots)
| t -> t)
then Ast0.wrap (Ast0.STARS(l))
else Ast0.wrap (Ast0.DOTS(l))
-let scan_code l =
- let statements = ref false in
+let rec is_decl s =
+ match Ast0.unwrap s with
+ Ast0.Decl(_,e) -> true
+ | _ -> false
+
+let isonly f l = match Ast0.undots l with [s] -> f s | _ -> false
+let isall f l = List.for_all (isonly f) l
+
+let rec is_toplevel s =
+ match Ast0.unwrap s with
+ Ast0.Decl(_,e) -> true
+ | Ast0.FunDecl(_,_,_,_,_,_,_,_,_) -> true
+ | Ast0.Disj(_,stmts,_,_) -> isall is_toplevel stmts
+ | Ast0.ExprStatement(Some fc,_) -> false
+ | Ast0.Include(_,_) -> true
+ | Ast0.Undef(_,_) -> true
+ | Ast0.Define(_,_,_,_) -> true
+ | _ -> false
+
+let scan_code must_be_code l =
let rec loop = function
[] -> ([],[])
| (x::xs) as all ->
- (match Ast0.unwrap x with
- (Ast0.OTHER(code)) ->
- (match Ast0.unwrap code with
- Ast0.Decl(_) ->
- let (front,rest) = loop xs in
- (code::front,rest)
- | _ ->
- statements := true;
- let (front,rest) = loop xs in
- (code::front,rest))
- | _ -> ([],all)) in
+ (match Ast0.unwrap x with
+ (Ast0.OTHER(code)) ->
+ let (front,rest) = loop xs in
+ (code::front,rest)
+ | _ -> ([],all)) in
match loop l with
([],_) as res -> res
| (code,rest) ->
- if !statements = true
- then ([Ast0.wrap(Ast0.CODE(top_dots code))],rest)
- else
- (List.map
- (function d ->
- match Ast0.unwrap d with
- Ast0.Decl(bef,x) -> Ast0.wrap (Ast0.DECL(d))
- | _ -> failwith "impossible")
- code,
- rest)
+ (match code with
+ | [x] when is_decl x && must_be_code ->
+ ([Ast0.wrap(Ast0.NONDECL x)],rest)
+ | _ when List.for_all is_toplevel code ->
+ ([Ast0.wrap(Ast0.TOPCODE(top_dots code))],rest)
+ | _ ->
+ ([Ast0.wrap(Ast0.CODE(top_dots code))],rest))
let rec scan_top_decl = function
[] -> ([],[])
| ((topdecl::rest) as all) ->
(match Ast0.unwrap topdecl with
Ast0.OTHER(_) -> ([],all)
- | _ -> let (front,rest) = scan_top_decl rest in (topdecl::front,rest))
+ | _ ->
+ let (front,rest) = scan_top_decl rest
+ in (topdecl::front,rest))
(* for debugging *)
let l2c l =
match Ast0.unwrap l with
- Ast0.DECL(_) -> "decl"
+ Ast0.NONDECL(_) -> "decl"
| Ast0.CODE(_) -> "code"
+ | Ast0.TOPCODE(_) -> "code"
| Ast0.FILEINFO(_,_) -> "fileinfo"
| Ast0.ERRORWORDS(_) -> "errorwords"
| Ast0.OTHER(_) -> "other"
-let rec top_level l =
- match scan_code l with
+let rec top_level must_be_code l =
+ match scan_code must_be_code l with
(code,[]) -> code
| (code,rest) ->
(match scan_top_decl rest with
(top_decls,[]) -> code@top_decls
- | (top_decls,rest) -> code @ top_decls @ (top_level rest))
+ | (top_decls,rest) -> code @ top_decls @ (top_level must_be_code rest))
+
+let clean l =
+ List.map
+ (function tl ->
+ match Ast0.unwrap tl with
+ Ast0.TOPCODE x -> Ast0.rewrap tl (Ast0.CODE x)
+ | _ -> tl)
+ l
*)
-val top_level : Ast0_cocci.rule -> Ast0_cocci.rule
+val top_level :
+ bool (* true if must be code *) -> Ast0_cocci.rule -> Ast0_cocci.rule
+
+val clean : Ast0_cocci.rule -> Ast0_cocci.rule
Ast0.FILEINFO(old_file,new_file) ->
print_string "--- "; mcode print_string old_file; force_newline();
print_string "+++ "; mcode print_string new_file
- | Ast0.DECL(stmt) -> statement "" stmt
- | Ast0.CODE(stmt_dots) ->
+ | Ast0.NONDECL(stmt) -> statement "" stmt
+ | Ast0.CODE(stmt_dots) | Ast0.TOPCODE(stmt_dots) ->
dots force_newline (statement "") stmt_dots
| Ast0.ERRORWORDS(exps) ->
print_string "error words = [";
match Ast.unwrap t with
Ast.FILEINFO(old_file,new_file) ->
bind (string_mcode old_file) (string_mcode new_file)
- | Ast.DECL(stmt) -> statement stmt
+ | Ast.NONDECL(stmt) -> statement stmt
| Ast.CODE(stmt_dots) -> statement_dots stmt_dots
| Ast.ERRORWORDS(exps) -> multibind (List.map expression exps) in
topfn all_functions k t
(match Ast.unwrap t with
Ast.FILEINFO(old_file,new_file) ->
Ast.FILEINFO (string_mcode old_file, string_mcode new_file)
- | Ast.DECL(stmt) -> Ast.DECL(statement stmt)
+ | Ast.NONDECL(stmt) -> Ast.NONDECL(statement stmt)
| Ast.CODE(stmt_dots) -> Ast.CODE(statement_dots stmt_dots)
| Ast.ERRORWORDS(exps) -> Ast.ERRORWORDS (List.map expression exps)) in
topfn all_functions k t
let (old_file_n,old_file) = string_mcode old_file in
let (new_file_n,new_file) = string_mcode new_file in
(bind old_file_n new_file_n,Ast0.FILEINFO(old_file,new_file))
- | Ast0.DECL(statement_dots) ->
+ | Ast0.NONDECL(statement_dots) ->
let (n,statement_dots) = statement statement_dots in
- (n,Ast0.DECL(statement_dots))
+ (n,Ast0.NONDECL(statement_dots))
| Ast0.CODE(stmt_dots) ->
let (stmt_dots_n,stmt_dots) = statement_dots stmt_dots in
(stmt_dots_n, Ast0.CODE(stmt_dots))
+ | Ast0.TOPCODE(stmt_dots) ->
+ let (stmt_dots_n,stmt_dots) = statement_dots stmt_dots in
+ (stmt_dots_n, Ast0.TOPCODE(stmt_dots))
| Ast0.ERRORWORDS(exps) ->
let (n,exps) = map_split_bind expression exps in
(n, Ast0.ERRORWORDS(exps))
type formula =
(cocci_predicate,Ast_cocci.meta_name, Wrapper_ctl.info) Ast_ctl.generic_ctl
-val popl : Ast_cocci.rule -> formula list
+val popl : Ast_cocci.rule -> Asttoctl2.top_formula list
(* --------------------------------------------------------------------- *)
-let toctl sl = ctl_seq true ctl_true sl
+let toctl sl = Asttoctl2.CODE (ctl_seq true ctl_true sl)
type formula =
(cocci_predicate,Ast_cocci.meta_name, Wrapper_ctl.info) Ast_ctl.generic_ctl
-val toctl : Ast_popl.sequence -> formula
+val toctl : Ast_popl.sequence -> Asttoctl2.top_formula
+++ /dev/null
-asttopopl.cmi: ast_popl.cmo ../parsing_cocci/ast_cocci.cmi
-insert_quantifiers.cmi: ast_popl.cmo
-popl.cmi: ../ctl/wrapper_ctl.cmi ../engine/lib_engine.cmo ../ctl/ast_ctl.cmo \
- ../parsing_cocci/ast_cocci.cmi
-popltoctl.cmi: ../ctl/wrapper_ctl.cmi ../engine/lib_engine.cmo ast_popl.cmo \
- ../ctl/ast_ctl.cmo ../parsing_cocci/ast_cocci.cmi
-pretty_print_popl.cmi: ast_popl.cmo
-ast_popl.cmo: ../parsing_cocci/ast_cocci.cmi
-ast_popl.cmx: ../parsing_cocci/ast_cocci.cmx
-asttopopl.cmo: ../parsing_cocci/pretty_print_cocci.cmi ast_popl.cmo \
- ../parsing_cocci/ast_cocci.cmi asttopopl.cmi
-asttopopl.cmx: ../parsing_cocci/pretty_print_cocci.cmx ast_popl.cmx \
- ../parsing_cocci/ast_cocci.cmx asttopopl.cmi
-flag_popl.cmo:
-flag_popl.cmx:
-insert_quantifiers.cmo: ../commons/common.cmi ast_popl.cmo \
- ../parsing_cocci/ast_cocci.cmi insert_quantifiers.cmi
-insert_quantifiers.cmx: ../commons/common.cmx ast_popl.cmx \
- ../parsing_cocci/ast_cocci.cmx insert_quantifiers.cmi
-popl.cmo: ../ctl/wrapper_ctl.cmi popltoctl.cmi ../engine/lib_engine.cmo \
- insert_quantifiers.cmi asttopopl.cmi ../ctl/ast_ctl.cmo \
- ../parsing_cocci/ast_cocci.cmi popl.cmi
-popl.cmx: ../ctl/wrapper_ctl.cmx popltoctl.cmx ../engine/lib_engine.cmx \
- insert_quantifiers.cmx asttopopl.cmx ../ctl/ast_ctl.cmx \
- ../parsing_cocci/ast_cocci.cmx popl.cmi
-popltoctl.cmo: ../ctl/wrapper_ctl.cmi ../parsing_cocci/visitor_ast.cmi \
- ../engine/lib_engine.cmo flag_popl.cmo ast_popl.cmo ../ctl/ast_ctl.cmo \
- ../parsing_cocci/ast_cocci.cmi popltoctl.cmi
-popltoctl.cmx: ../ctl/wrapper_ctl.cmx ../parsing_cocci/visitor_ast.cmx \
- ../engine/lib_engine.cmx flag_popl.cmx ast_popl.cmx ../ctl/ast_ctl.cmx \
- ../parsing_cocci/ast_cocci.cmx popltoctl.cmi
-pretty_print_popl.cmo: ../parsing_cocci/pretty_print_cocci.cmi ast_popl.cmo \
- ../parsing_cocci/ast_cocci.cmi pretty_print_popl.cmi
-pretty_print_popl.cmx: ../parsing_cocci/pretty_print_cocci.cmx ast_popl.cmx \
- ../parsing_cocci/ast_cocci.cmx pretty_print_popl.cmi
type formula =
(cocci_predicate,Ast_cocci.meta_name, Wrapper_ctl.info) Ast_ctl.generic_ctl
-val popl : Ast_cocci.rule -> formula list
+val popl : Ast_cocci.rule -> Asttoctl2.top_formula list
(* --------------------------------------------------------------------- *)
-let toctl sl = ctl_seq true ctl_true sl
+let toctl sl = Asttoctl2.CODE (ctl_seq true ctl_true sl)
type formula =
(cocci_predicate,Ast_cocci.meta_name, Wrapper_ctl.info) Ast_ctl.generic_ctl
-val toctl : Ast_popl.sequence -> formula
+val toctl : Ast_popl.sequence -> Asttoctl2.top_formula
+++ /dev/null
-pycocci.cmi: ../parsing_cocci/ast_cocci.cmi ../parsing_c/ast_c.cmo
-pycocci_aux.cmi: ../parsing_c/ast_c.cmo
-no_pycocci.cmo: pycocci_aux.cmi ../commons/common.cmi ../parsing_c/ast_c.cmo
-no_pycocci.cmx: pycocci_aux.cmx ../commons/common.cmx ../parsing_c/ast_c.cmx
-pycocci_aux.cmo: ../parsing_c/pretty_print_c.cmi ../commons/common.cmi \
- ../parsing_cocci/ast_cocci.cmi ../parsing_c/ast_c.cmo pycocci_aux.cmi
-pycocci_aux.cmx: ../parsing_c/pretty_print_c.cmx ../commons/common.cmx \
- ../parsing_cocci/ast_cocci.cmx ../parsing_c/ast_c.cmx pycocci_aux.cmi
-yes_pycocci.cmo: pycocci_aux.cmi ../globals/flag.cmo ../commons/common.cmi \
- ../parsing_c/ast_c.cmo
-yes_pycocci.cmx: pycocci_aux.cmx ../globals/flag.cmx ../commons/common.cmx \
- ../parsing_c/ast_c.cmx
distclean:
rm -rf \$(RESULTS)
+maintclean: distclean
+ rm Makefile
+
depend: update
EOF
((a.res Ok) (a3d.res Ok) (a_and_e.res Ok) (a_and_e_ver1.res Ok) (ab.res Ok)
(addaft.res Ok) (addbefore.res Ok) (addbeforeafter.res Ok) (addelse.res Ok)
- (addif.res Ok) (addif1.res Ok) (addif2.res Ok) (addtoo.res Ok)
- (after_if.res Ok) (anon.res Ok) (ar.res Ok) (arg.res Ok) (argument.res Ok)
- (arparam.res Ok) (array_init.res Ok) (array_size.res Ok) (arraysz.res Ok)
- (attradd.res Ok) (b1.res Ok) (b2.res Ok)
+ (addfield.res Ok) (addif.res Ok) (addif1.res Ok) (addif2.res Ok)
+ (addtoo.res Ok) (after_if.res Ok) (anon.res Ok) (ar.res Ok) (arg.res Ok)
+ (argument.res Ok) (arparam.res Ok) (array_init.res Ok) (array_size.res Ok)
+ (arraysz.res Ok) (attradd.res Ok) (b1.res Ok) (b2.res Ok)
(bad_iso_example.res
(Pb
"INCORRECT:diff token: ( VS x\nFile \"tests/bad_iso_example.c\", line 2, column 6, charpos = 19\n around = '(', whole content = if ((x = 3)) return;\nFile \"tests/bad_iso_example.res\", line 2, column 6, charpos = 19\n around = 'x', whole content = if (x) return;\n\n diff (result(<) vs expected_result(>)) = \n @@ -1,4 +1,4 @@\n int main() {\n - if ((x = 3)) return;\n + if (x) return;\n }\n \n"))
"INCORRECT:diff token: init_MUTEX VS mutex_init\nFile \"tests/serio.c\", line 7, column 1, charpos = 130\n around = 'init_MUTEX', whole content = \tinit_MUTEX(&serio->drv_sem);\nFile \"tests/serio.res\", line 7, column 1, charpos = 130\n around = 'mutex_init', whole content = \tmutex_init(&serio->new_lock);\n\n diff (result(<) vs expected_result(>)) = \n @@ -4,5 +4,5 @@\n \n static void serio_init_port(struct serio *serio)\n {\n -\tinit_MUTEX(&serio->drv_sem);\n +\tmutex_init(&serio->new_lock);\n }\n"))
(shared_brace.res Ok) (signed.res Ok) (sis.res Ok) (sizeof.res Ok)
(sizeof_julia.res Ok) (sizeptr.res Ok) (sizestar.res Ok) (skip.res Ok)
- (sp.res Ok) (spaces.res Ok) (spl.res Ok) (static.res Ok) (stm1.res Ok)
- (stm10.res Ok) (stm10_ver1.res Ok) (stm2.res Ok) (stm3.res Ok) (stm4.res Ok)
- (stm5.res Ok) (stm6.res Ok) (stm7.res Ok) (stm8.res Ok) (stmt.res Ok)
- (str_init.res Ok) (strangeorder.res Ok) (strid.res Ok) (strid2.res Ok)
- (string.res Ok) (struct.res Ok) (struct_metavar.res Ok)
+ (sp.res Ok) (spaces.res Ok) (spacing.res Ok) (spl.res Ok) (static.res Ok)
+ (stm1.res Ok) (stm10.res Ok) (stm10_ver1.res Ok) (stm2.res Ok) (stm3.res Ok)
+ (stm4.res Ok) (stm5.res Ok) (stm6.res Ok) (stm7.res Ok) (stm8.res Ok)
+ (stmt.res Ok) (str_init.res Ok) (strangeorder.res Ok) (strid.res Ok)
+ (strid2.res Ok) (string.res Ok) (struct.res Ok) (struct_metavar.res Ok)
(struct_typedef.res Ok) (structfoo.res Ok) (substruct.res Ok) (sw.res Ok)
(switch.res Ok) (switchdecl.res Ok) (td.res Ok) (tern.res Ok) (test0.res Ok)
(test1.res Ok) (test10.res Ok) (test10_ver1.res Ok) (test11.res Ok)
((a.res Ok) (a3d.res Ok) (a_and_e.res Ok) (a_and_e_ver1.res Ok) (ab.res Ok)
(addaft.res Ok) (addbefore.res Ok) (addbeforeafter.res Ok) (addelse.res Ok)
- (addif.res Ok) (addif1.res Ok) (addif2.res Ok) (addtoo.res Ok)
- (after_if.res Ok) (anon.res Ok) (ar.res Ok) (arg.res Ok) (argument.res Ok)
- (arparam.res Ok) (array_init.res Ok) (array_size.res Ok) (arraysz.res Ok)
- (attradd.res Ok) (b1.res Ok) (b2.res Ok)
+ (addfield.res Ok) (addif.res Ok) (addif1.res Ok) (addif2.res Ok)
+ (addtoo.res Ok) (after_if.res Ok) (anon.res Ok) (ar.res Ok) (arg.res Ok)
+ (argument.res Ok) (arparam.res Ok) (array_init.res Ok) (array_size.res Ok)
+ (arraysz.res Ok) (attradd.res Ok) (b1.res Ok) (b2.res Ok)
(bad_iso_example.res
(Pb
"INCORRECT:diff token: ( VS x\nFile \"tests/bad_iso_example.c\", line 2, column 6, charpos = 19\n around = '(', whole content = if ((x = 3)) return;\nFile \"tests/bad_iso_example.res\", line 2, column 6, charpos = 19\n around = 'x', whole content = if (x) return;\n\n diff (result(<) vs expected_result(>)) = \n @@ -1,4 +1,4 @@\n int main() {\n - if ((x = 3)) return;\n + if (x) return;\n }\n \n"))
"INCORRECT:diff token: init_MUTEX VS mutex_init\nFile \"tests/serio.c\", line 7, column 1, charpos = 130\n around = 'init_MUTEX', whole content = \tinit_MUTEX(&serio->drv_sem);\nFile \"tests/serio.res\", line 7, column 1, charpos = 130\n around = 'mutex_init', whole content = \tmutex_init(&serio->new_lock);\n\n diff (result(<) vs expected_result(>)) = \n @@ -4,5 +4,5 @@\n \n static void serio_init_port(struct serio *serio)\n {\n -\tinit_MUTEX(&serio->drv_sem);\n +\tmutex_init(&serio->new_lock);\n }\n"))
(shared_brace.res Ok) (signed.res Ok) (sis.res Ok) (sizeof.res Ok)
(sizeof_julia.res Ok) (sizeptr.res Ok) (sizestar.res Ok) (skip.res Ok)
- (sp.res Ok) (spaces.res Ok) (spl.res Ok) (static.res Ok)
+ (sp.res Ok) (spaces.res Ok) (spacing.res Ok) (spl.res Ok) (static.res Ok)
(stm1.res (Pb "PROBLEM\n exn = Failure(\"no python\")\n")) (stm10.res Ok)
(stm10_ver1.res Ok) (stm2.res Ok) (stm3.res Ok) (stm4.res Ok) (stm5.res Ok)
(stm6.res Ok) (stm7.res (Pb "PROBLEM\n exn = Failure(\"no python\")\n"))
--- /dev/null
+@@
+identifier I;
+expression E;
+@@
+
+struct i2c_client I = {
+ .name = E,
+ .foo = 16
+};
--- /dev/null
+@@
+identifier I;
+expression E;
+@@
+
+struct i2c_client I = {
+- .name = E,
+...,
++ .dev = { .name = E, },
+};
--- /dev/null
+@@
+identifier I;
+expression E;
+@@
+
+struct i2c_client I = {
+ .foo = 16,
+ .dev = {
+ .name = E,
+ },
+};
--- /dev/null
+typedef int *foo;
+
+int f(int x) {
+ one();
+ if (x) {
+ two();
+ }
+}
--- /dev/null
+@@
+@@
+ typedef int *foo;
++void *bar(int *baz)
++{
++ return baz;
++}
+
+@@
+identifier f,x;
+@@
+ f(int x) { ... }
++void *bar(int *baz)
++{
++ return baz;
++}
+
+@@
+@@
+
+two();
++if (y) {
++ test();
++}
--- /dev/null
+typedef int *foo;
+
+void *bar(int *baz) {
+return baz;
+}
+
+int f(int x) {
+ one();
+ if (x) {
+ two();
+ if (y) {
+ test();
+ }
+ }
+}
+
+void *bar(int *baz) {
+ return baz;
+}
@@
declarer name MODULE_PARM;
+declarer name module_param;
@@
- MODULE_PARM(...);