File tree Expand file tree Collapse file tree 7 files changed +16
-29
lines changed
Expand file tree Collapse file tree 7 files changed +16
-29
lines changed Original file line number Diff line number Diff line change @@ -59,10 +59,8 @@ let exclude_vars_regexp = ResettableLazy.from_fun (fun () ->
5959(* let var_is_tmp {vdescrpure} = not vdescrpure (* doesn't exclude tmp___0 *) *)
6060(* TODO: instead check if vdescr is nonempty? (doesn't cover all cases, e.g. ternary temporary) *)
6161let varname_is_tmp vname = Str. string_match (ResettableLazy. force exclude_vars_regexp) vname 0
62- let var_is_tmp vi =
63- match Cilfacade. find_original_name vi with
64- | None -> true
65- | Some vname -> varname_is_tmp vname
62+ let var_is_tmp vi = BatOption. map_default varname_is_tmp true (Cilfacade. find_original_name vi)
63+
6664class exp_contains_tmp_visitor (acc : bool ref ) = object
6765 inherit nopCilVisitor as super
6866 method! vvrbl (vi: varinfo ) =
Original file line number Diff line number Diff line change @@ -61,9 +61,7 @@ let eval_int_binop (module Bool: Lattice.S with type t = bool) binop (eval_int:
6161 if ID. is_bot i || ID. is_bot_ikind i then
6262 Bool. top () (* base returns bot for non-int results, consider unknown *)
6363 else
64- match ID. to_bool i with
65- | Some b -> b
66- | None -> Bool. top ()
64+ BatOption. default (Bool. top () ) (ID. to_bool i)
6765
6866(* * Backwards-compatibility for former [MustBeEqual] query. *)
6967let must_be_equal = eval_int_binop (module MustBool ) Eq
Original file line number Diff line number Diff line change @@ -432,9 +432,10 @@ let createCFG (file: file) =
432432 List. iter (fun (fromNode , toNode ) ->
433433 addEdge_fromLoc fromNode (Test (one, false )) toNode;
434434 added_connect := true ;
435- match NH. find_option node_scc toNode with
436- | Some toNode_scc -> iter_scc toNode_scc (* continue to target scc as normally, to ensure they are also connected *)
437- | None -> () (* pseudo return, wasn't in scc, but is fine *)
435+ Option. iter (fun toNode_scc ->
436+ iter_scc toNode_scc (* continue to target scc as normally, to ensure they are also connected *)
437+ ) (NH. find_option node_scc toNode)
438+ (* otherwise pseudo return, wasn't in scc, but is fine *)
438439 ) targets
439440 )
440441 )
@@ -556,12 +557,10 @@ struct
556557 Format. fprintf out (" \t %a [%s];\n " ) p_node n styles;
557558 match n with
558559 | Statement s when get_bool " dbg.cfg.loop-unrolling" ->
559- begin match LoopUnrolling0. find_copyof s with
560- | Some s' ->
560+ Option. iter (fun s' ->
561561 let n' = Statement s' in
562562 Format. fprintf out " \t %a -> %a [style=dotted];\n " p_node n p_node n'
563- | None -> ()
564- end
563+ ) (LoopUnrolling0. find_copyof s)
565564 | _ -> ()
566565end
567566
Original file line number Diff line number Diff line change @@ -57,11 +57,7 @@ struct
5757
5858 let marshal () = ! xh
5959
60- let unmarshal = function
61- | Some xh_loaded ->
62- xh := xh_loaded
63- | None -> ()
64-
60+ let unmarshal = Option. iter ((:= ) xh)
6561 let bindings () = List. of_seq (XH. to_seq ! xh)
6662end
6763
Original file line number Diff line number Diff line change @@ -282,9 +282,7 @@ struct
282282 include S
283283
284284 let system x =
285- match S. system x with
286- | None -> None
287- | Some f ->
285+ Option. map (fun f ->
288286 let f' get set =
289287 let old_current_var = ! current_var in
290288 current_var := Some x;
@@ -294,6 +292,7 @@ struct
294292 f get set
295293 )
296294 in
297- Some f'
295+ f'
296+ ) (S. system x)
298297 end
299298end
Original file line number Diff line number Diff line change @@ -101,9 +101,7 @@ let addToFinalMatchesMapping oV nV final_matches =
101101let empty_rename_assms m = VarinfoMap. for_all (fun vo vn -> vo.vname = vn.vname) m
102102
103103let already_matched oV nV final_matches =
104- match VarinfoMap. find_opt oV (fst final_matches) with
105- | None -> false
106- | Some v -> v.vid = oV.vid
104+ GobOption. exists (fun v -> v.vid = nV.vid) (VarinfoMap. find_opt oV (fst final_matches))
107105
108106(* looks up the result of the already executed comparison and returns true if it is unchanged, false if it is changed.
109107 Throws an exception if not found. *)
Original file line number Diff line number Diff line change @@ -9,12 +9,11 @@ let comb_suffix = "_comb.c"
99
1010let exec_command ?path (command : string ) =
1111 let current_dir = Sys. getcwd () in
12- (match path with
13- | Some path ->
12+ GobOption. iter (fun path ->
1413 let path_str = Fpath. to_string path in
1514 if Sys. file_exists path_str && Sys. is_directory path_str then Sys. chdir path_str
1615 else failwith (" Directory " ^ path_str ^ " does not exist!" )
17- | None -> () ) ;
16+ ) path ;
1817 Logs. debug " %s" (" executing command `" ^ command ^ " ` in " ^ Sys. getcwd () );
1918 let (std_out, std_in) = open_process command in
2019 let output = Buffer. create buff_size in
You can’t perform that action at this time.
0 commit comments