Skip to content

Commit 0a118f5

Browse files
author
Zachary R. Anderson
committed
Using Util.list_map instead of List.map
1 parent 1a9391d commit 0a118f5

28 files changed

+127
-125
lines changed

src/cil.ml

+10-10
Original file line numberDiff line numberDiff line change
@@ -1454,7 +1454,7 @@ let mkCompInfo
14541454
comp.ckey <- !nextCompinfoKey;
14551455
incr nextCompinfoKey;
14561456
let flds =
1457-
List.map (fun (fn, ft, fb, fa, fl) ->
1457+
Util.list_map (fun (fn, ft, fb, fa, fl) ->
14581458
{ fcomp = comp;
14591459
ftype = ft;
14601460
fname = fn;
@@ -1471,7 +1471,7 @@ let copyCompInfo (ci: compinfo) (n: string) : compinfo =
14711471
ckey = !nextCompinfoKey; } in
14721472
incr nextCompinfoKey;
14731473
(* Copy the fields and set the new pointers to parents *)
1474-
ci'.cfields <- List.map (fun f -> {f with fcomp = ci'}) ci'.cfields;
1474+
ci'.cfields <- Util.list_map (fun f -> {f with fcomp = ci'}) ci'.cfields;
14751475
ci'
14761476

14771477
(**** Utility functions ******)
@@ -1558,7 +1558,7 @@ let rec unrollTypeDeep (t: typ) : typ =
15581558
(match args with
15591559
None -> None
15601560
| Some argl ->
1561-
Some (List.map (fun (an,at,aa) ->
1561+
Some (Util.list_map (fun (an,at,aa) ->
15621562
(an, unrollTypeDeep at, aa)) argl)),
15631563
isva,
15641564
addAttributes al a')
@@ -1808,7 +1808,7 @@ let separateStorageModifiers (al: attribute list) =
18081808
(* Put back the declspec. Put it without the leading __ since these will
18091809
* be added later *)
18101810
let stom' =
1811-
List.map (fun (Attr(an, args)) ->
1811+
Util.list_map (fun (Attr(an, args)) ->
18121812
Attr("declspec", [ACons(an, args)])) stom in
18131813
stom', rest
18141814

@@ -4802,7 +4802,7 @@ let setFormals (f: fundec) (forms: varinfo list) =
48024802
TFun(rt, _, isva, fa) ->
48034803
f.svar.vtype <-
48044804
TFun(rt,
4805-
Some (List.map (fun a -> (a.vname, a.vtype, a.vattr)) forms),
4805+
Some (Util.list_map (fun a -> (a.vname, a.vtype, a.vattr)) forms),
48064806
isva, fa)
48074807
| _ -> E.s (E.bug "Set formals. %s does not have function type\n"
48084808
f.svar.vname)
@@ -4838,7 +4838,7 @@ let setFunctionTypeMakeFormals (f: fundec) (t: typ) =
48384838
f.svar.vtype <- t;
48394839
f.sformals <- [];
48404840

4841-
f.sformals <- List.map (fun (n,t,a) -> makeLocal f n t) args;
4841+
f.sformals <- Util.list_map (fun (n,t,a) -> makeLocal f n t) args;
48424842

48434843
setFunctionType f t
48444844

@@ -5667,7 +5667,7 @@ let getGlobInit ?(main_name="main") (fl: file) =
56675667
(* Fold over all globals, including the global initializer *)
56685668
let mapGlobals (fl: file)
56695669
(doone: global -> global) : unit =
5670-
fl.globals <- List.map doone fl.globals;
5670+
fl.globals <- Util.list_map doone fl.globals;
56715671
(match fl.globinit with
56725672
None -> ()
56735673
| Some g -> begin
@@ -5852,7 +5852,7 @@ let rec typeSigWithAttrs ?(ignoreSign=false) doattr t =
58525852
TSComp (comp.cstruct, comp.cname, doattr (addAttributes comp.cattr a))
58535853
| TFun(rt,args,isva,a) ->
58545854
TSFun(typeSig rt,
5855-
List.map (fun (_, atype, _) -> (typeSig atype)) (argsToList args),
5855+
Util.list_map (fun (_, atype, _) -> (typeSig atype)) (argsToList args),
58565856
isva, doattr a)
58575857
| TNamed(t, a) -> typeSigAddAttrs (doattr a) (typeSig t.ttype)
58585858
| TBuiltin_va_list al -> TSBase (TBuiltin_va_list (doattr al))
@@ -6292,7 +6292,7 @@ class copyFunctionVisitor (newname: string) = object (self)
62926292
s.skind <- Goto (sr',l)
62936293
| Switch (e, body, cases, l) ->
62946294
s.skind <- Switch (e, body,
6295-
List.map (fun cs -> findStmt cs.sid) cases, l)
6295+
Util.list_map (fun cs -> findStmt cs.sid) cases, l)
62966296
| _ -> ()
62976297
in
62986298
List.iter patchstmt !patches;
@@ -6454,7 +6454,7 @@ let get_switch_count () =
64546454
let switch_label = ref (-1)
64556455

64566456
let rec xform_switch_stmt s break_dest cont_dest label_index = begin
6457-
s.labels <- List.map (fun lab -> match lab with
6457+
s.labels <- Util.list_map (fun lab -> match lab with
64586458
Label _ -> lab
64596459
| Case(e,l) ->
64606460
let suffix =

src/ext/arithabs.ml

+6-6
Original file line numberDiff line numberDiff line change
@@ -244,14 +244,14 @@ let fundecToCFGInfo (fdec: fundec) : S.cfgInfo =
244244
in
245245
List.iter
246246
(fun s ->
247-
ci.S.successors.(s.sid) <- List.map (fun s' -> s'.sid) s.succs;
248-
ci.S.predecessors.(s.sid) <- List.map (fun s' -> s'.sid) s.preds;
247+
ci.S.successors.(s.sid) <- Util.list_map (fun s' -> s'.sid) s.succs;
248+
ci.S.predecessors.(s.sid) <- Util.list_map (fun s' -> s'.sid) s.preds;
249249
ci.S.blocks.(s.sid) <- begin
250250
let instrs: (S.reg list * S.reg list) list =
251251
match s.skind with
252252
Instr il ->
253253
(* Each instruction is transformed independently *)
254-
List.map (fun i ->
254+
Util.list_map (fun i ->
255255
let vused, vdefs = Usedef.computeUseDefInstr i in
256256
(vsToRegList vdefs, vsToRegList vused)) il
257257

@@ -478,7 +478,7 @@ class absPrinterClass (callgraph: CG.callgraph) : cilPrinter =
478478
let argdoc: doc =
479479
(docList ~sep:break (self#pExp ()))
480480
()
481-
(args @ (List.map (fun v -> Lval (Var v, NoOffset)) grt))
481+
(args @ (Util.list_map (fun v -> Lval (Var v, NoOffset)) grt))
482482
in
483483
dprintf "%a = (%s @[%a@]);"
484484
(docList
@@ -556,7 +556,7 @@ class absPrinterClass (callgraph: CG.callgraph) : cilPrinter =
556556
(* initVarRenameState has already set the state for the phi register *)
557557
let lhs: string = self#variableUse varRenameState v in
558558
let rhs: string list =
559-
List.map
559+
Util.list_map
560560
(fun p ->
561561
self#variableUse blockEndData.(p) v)
562562
cfgi.S.predecessors.(s.sid)
@@ -1060,7 +1060,7 @@ let feature : featureDescr =
10601060
nrNodes := 0;
10611061
IH.iter (fun idx cn ->
10621062
let cnlistToNodeList (cnl: (string, CG.callnode) H.t) : int list =
1063-
List.map
1063+
Util.list_map
10641064
(fun (_, sn) ->
10651065
try IH.find funidToNodeId sn.CG.cnInfo.vid
10661066
with Not_found -> assert false

src/ext/blockinggraph.ml

+2-2
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ let myTypeSig (t: typ) : typsig =
104104
| TSArray (base, e, a) ->
105105
TSArray (removeFunPtrs base, e, a)
106106
| TSFun (ret, args, v, a) ->
107-
TSFun (removeFunPtrs ret, List.map removeFunPtrs args, v, a)
107+
TSFun (removeFunPtrs ret, Util.list_map removeFunPtrs args, v, a)
108108
| _ -> ts
109109
in
110110
removeFunPtrs (typeSigWithAttrs (fun _ -> []) t)
@@ -563,7 +563,7 @@ let makeStartNodeLinks () : unit =
563563

564564
let funType (ret_t: typ) (args: (string * typ) list) =
565565
TFun(ret_t,
566-
Some (List.map (fun (n,t) -> (n, t, [])) args),
566+
Some (Util.list_map (fun (n,t) -> (n, t, [])) args),
567567
false, [])
568568

569569
class instrumentClass = object

src/ext/canonicalize.ml

+2-2
Original file line numberDiff line numberDiff line change
@@ -197,7 +197,7 @@ class canonicalizeVisitor = object(self)
197197
match f with
198198
Lval(Mem(fp), off) ->
199199
let counter: int ref = ref 0 in
200-
let newFormals = List.map
200+
let newFormals = Util.list_map
201201
(fun (actual:exp) ->
202202
incr counter;
203203
let formalName = "a" ^ (string_of_int !counter) in
@@ -223,7 +223,7 @@ class canonicalizeVisitor = object(self)
223223
This should be done in vglob if needed. *)
224224
| CompoundInit(t, initList) ->
225225
let changed: bool ref = ref false in
226-
let initList' = List.map
226+
let initList' = Util.list_map
227227
(* iterate over the list, adding casts for any expression that
228228
is expected to be an enum type. *)
229229
(function

src/ext/ccl.ml

+3-3
Original file line numberDiff line numberDiff line change
@@ -1878,7 +1878,7 @@ class outVisitor = object
18781878
match inst with
18791879
| Call (ret, fn, args, attrs) ->
18801880
let newArgs =
1881-
List.map
1881+
Util.list_map
18821882
(fun arg ->
18831883
match arg with
18841884
| Lval (Var vi, NoOffset) when Hashtbl.mem mapping vi.vname ->
@@ -1917,8 +1917,8 @@ let analyzeFile (f : file) : unit =
19171917
visitCilFile (new preVisitor) f;
19181918
visitCilFile (new outVisitor) f;
19191919
visitCilFile (new ptrArithVisitor) f;
1920-
verifiedExps := List.map fst expStats.verified;
1921-
verifiedArgs := List.map fst argStats.verified;
1920+
verifiedExps := Util.list_map fst expStats.verified;
1921+
verifiedArgs := Util.list_map fst argStats.verified;
19221922
ignore (E.log "\nCCL Results:\n Derefs: %a\n Args: %a\n\n"
19231923
d_stats expStats d_stats argStats);
19241924
(*

src/ext/cfg.ml

+4-2
Original file line numberDiff line numberDiff line change
@@ -137,8 +137,10 @@ and cfgStmt (s: stmt) (next:stmt option) (break:stmt option) (cont:stmt option)
137137
incr start_id;
138138
s.sid <- !start_id;
139139
nodeList := s :: !nodeList; (* Future traversals can be made in linear time. e.g. *)
140-
if s.succs <> [] then
141-
E.s (bug "CFG must be cleared before being computed!");
140+
if s.succs <> [] then begin
141+
(*E.s*)ignore (bug "CFG must be cleared before being computed!");
142+
raise (Failure "CFG bug")
143+
end;
142144
let addSucc (n: stmt) =
143145
if not (List.memq n s.succs) then
144146
s.succs <- n::s.succs;

src/ext/ciltools.ml

+1-1
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,7 @@ class callBBVisitor = object
154154
match s.skind with
155155
Instr(il) -> begin
156156
if (List.length il > 1) then
157-
let list_of_stmts = List.map (fun one_inst ->
157+
let list_of_stmts = Util.list_map (fun one_inst ->
158158
mkStmtOneInstr one_inst) il in
159159
let block = mkBlock list_of_stmts in
160160
s.skind <- Block block;

src/ext/dataslicing.ml

+6-6
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,7 @@ and sliceType (i : int) (t : typ) : typ =
156156
if checkRegion i attrs then
157157
TFun (sliceTypeAll ret,
158158
applyOption
159-
(List.map (fun (aname, atype, aattrs) ->
159+
(Util.list_map (fun (aname, atype, aattrs) ->
160160
(aname, sliceTypeAll atype, aattrs)))
161161
args,
162162
va, attrs)
@@ -310,13 +310,13 @@ let sliceInstr (inst : instr) : instr list =
310310
(fun i rest ->
311311
if not (isVoidType (sliceType i t)) then
312312
Call (Some (sliceLval i lv), sliceExp 1 fn,
313-
List.map (sliceExp i) args, l) :: rest
313+
Util.list_map (sliceExp i) args, l) :: rest
314314
else
315315
rest)
316316
[]
317317
| Call (ret, fn, args, l) when isExternalFunction fn ->
318318
[Call (applyOption (sliceLval 1) ret, sliceExp 1 fn,
319-
List.map (sliceExp 1) args, l)]
319+
Util.list_map (sliceExp 1) args, l)]
320320
| Call (ret, fn, args, l) ->
321321
let ret', set =
322322
match ret with
@@ -349,14 +349,14 @@ let sliceReturnExp (eo : exp option) (l : location) : stmtkind =
349349

350350
let rec sliceStmtKind (sk : stmtkind) : stmtkind =
351351
match sk with
352-
| Instr instrs -> Instr (List.flatten (List.map sliceInstr instrs))
352+
| Instr instrs -> Instr (List.flatten (Util.list_map sliceInstr instrs))
353353
| Block b -> Block (sliceBlock b)
354354
| If (e, b1, b2, l) -> If (sliceExp 1 e, sliceBlock b1, sliceBlock b2, l)
355355
| Break l -> Break l
356356
| Continue l -> Continue l
357357
| Return (eo, l) -> sliceReturnExp eo l
358358
| Switch (e, b, sl, l) -> Switch (sliceExp 1 e, sliceBlock b,
359-
List.map sliceStmt sl, l)
359+
Util.list_map sliceStmt sl, l)
360360
| Loop (b, l, so1, so2) -> Loop (sliceBlock b, l,
361361
applyOption sliceStmt so1,
362362
applyOption sliceStmt so2)
@@ -369,7 +369,7 @@ and sliceStmt (s : stmt) : stmt =
369369
s
370370

371371
and sliceBlock (b : block) : block =
372-
ignore (List.map sliceStmt b.bstmts);
372+
ignore (Util.list_map sliceStmt b.bstmts);
373373
b
374374

375375
let sliceFundec (fd : fundec) (l : location) : unit =

src/ext/inliner.ml

+2-2
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ class copyBodyVisitor (host: fundec) (* The host of the
106106
s.skind <- Goto (sr',l)
107107
| Switch (e, body, cases, l) ->
108108
s.skind <- Switch (e, body,
109-
List.map (fun cs -> findStmt cs.sid) cases, l)
109+
Util.list_map (fun cs -> findStmt cs.sid) cases, l)
110110
| _ -> ()
111111
in
112112
List.iter patchstmt !patches;
@@ -161,7 +161,7 @@ class copyBodyVisitor (host: fundec) (* The host of the
161161
let postProc (s': stmt) : stmt =
162162
(* Rename the labels if necessary *)
163163
s'.labels <-
164-
List.map (fun lb ->
164+
Util.list_map (fun lb ->
165165
match lb with
166166
Label (n, l, fromsrc) -> Label(replLabel n, l, fromsrc)
167167
| _ -> lb) s'.labels;

src/ext/logcalls.ml

+1-1
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,7 @@ let logCalls (f: file) : unit =
141141
(* Collect expressions that denote the actual arguments *)
142142
let actargs =
143143
(* make lvals out of args which pass test below *)
144-
(List.map
144+
(Util.list_map
145145
(fun vi -> match unrollType vi.vtype with
146146
| TComp(cinfo, _) when isFatCharPtr(cinfo) ->
147147
(* access the _p field for these *)

src/ext/partial.ml

+4-4
Original file line numberDiff line numberDiff line change
@@ -419,7 +419,7 @@ object
419419
Instr il when contains_call il ->
420420
begin
421421
let list_of_stmts =
422-
List.map (fun one_inst -> mkStmtOneInstr one_inst) il in
422+
Util.list_map (fun one_inst -> mkStmtOneInstr one_inst) il in
423423
let block = mkBlock list_of_stmts in
424424
ChangeDoChildrenPost
425425
(s, (fun _ -> s.skind <- Block block; s))
@@ -603,7 +603,7 @@ struct
603603
Instr il ->
604604
let state = ref state in
605605
let new_il =
606-
List.map
606+
Util.list_map
607607
(fun i ->
608608
if debug then
609609
ignore (Pretty.printf "Instr %a@!" d_instr i);
@@ -643,7 +643,7 @@ struct
643643
[Call (lo, Lval (Var vi, NoOffset), al', loc)], false
644644
with e ->
645645
let state'' = S.call_to_unknown_function !state in
646-
let al' = List.map (S.evaluate !state) al in
646+
let al' = Util.list_map (S.evaluate !state) al in
647647
state := state'';
648648
[Call (lo, Lval (Var vi, NoOffset), al', loc)], false
649649
in
@@ -656,7 +656,7 @@ struct
656656
end;
657657
result
658658
| Call (lo, f, al, loc) ->
659-
let al' = List.map (S.evaluate !state) al in
659+
let al' = Util.list_map (S.evaluate !state) al in
660660
state := S.call_to_unknown_function !state;
661661
begin
662662
match lo with

src/ext/predabst.ml

+7-7
Original file line numberDiff line numberDiff line change
@@ -466,7 +466,7 @@ module PredAbst = functor(S:SOLVER) ->
466466
h'
467467

468468
let hl_combine hl1 hl2 =
469-
List.map
469+
Util.list_map
470470
(fun (h1, h2) -> h_combine h1 h2)
471471
(List.combine hl1 hl2)
472472

@@ -499,17 +499,17 @@ module PredAbst = functor(S:SOLVER) ->
499499
let pl2 = helper e2 in
500500
(* for every pair of things from pl1 and pl2 *)
501501
List.fold_left (fun l (c1,e1) ->
502-
l @ (List.map (fun (c2,e2) ->
502+
l @ (Util.list_map (fun (c2,e2) ->
503503
(BinOp(LAnd,c1,c2,intType),BinOp(op,e1,e2,t))) pl2))
504504
[] pl1
505505
| UnOp(op, e, t) ->
506506
let pl = helper e in
507-
List.map (fun (c,e) ->
507+
Util.list_map (fun (c,e) ->
508508
(c,UnOp(op,e,t)))
509509
pl
510510
| CastE(t, e) ->
511511
let pl = helper e in
512-
List.map (fun (c,e) ->
512+
Util.list_map (fun (c,e) ->
513513
(c,CastE(t,e)))
514514
pl
515515
| _ -> raise (E.s "Simplify has not been run\n")
@@ -633,7 +633,7 @@ module PredAbst = functor(S:SOLVER) ->
633633
(* replace the formals in rpreds with the
634634
expressions given as arguments *)
635635
let rpreds =
636-
List.map (fun e ->
636+
Util.list_map (fun e ->
637637
List.fold_left2 (fun e vi ae ->
638638
substitute ae (* for *) (Var vi, NoOffset) (* in *) e)
639639
e fsig.fsFormals el)
@@ -644,7 +644,7 @@ module PredAbst = functor(S:SOLVER) ->
644644
| None, None -> rpreds
645645
| Some lv, Some rvi ->
646646
(* replace fsig.fsReturn in rpreds with Lval(lv) *)
647-
List.map (fun e ->
647+
Util.list_map (fun e ->
648648
substitute (Lval lv) (* for *) (Var rvi,NoOffset) (* in *) e)
649649
rpreds
650650
| _, _ -> raise (E.s "fsReturn is wrong in handleCallInstr\n")
@@ -764,7 +764,7 @@ module PredAbst = functor(S:SOLVER) ->
764764

765765
let copy ss = match ss with
766766
| ILState hl -> begin
767-
ILState(List.map (fun h -> IH.copy h) hl)
767+
ILState(Util.list_map (fun h -> IH.copy h) hl)
768768
end
769769
| StmState h -> StmState(IH.copy h)
770770

0 commit comments

Comments
 (0)