Skip to content
12 changes: 6 additions & 6 deletions src/cil.ml
Original file line number Diff line number Diff line change
Expand Up @@ -2713,7 +2713,7 @@ let parseInt (str: string) : exp =
let l = String.length str in
fun s ->
let ls = String.length s in
l >= ls && s = String.uppercase (String.sub str (l - ls) ls)
l >= ls && s = String.uppercase_ascii (String.sub str (l - ls) ls)
in
let l = String.length str in
(* See if it is octal or hex *)
Expand Down Expand Up @@ -5080,19 +5080,19 @@ let loadBinaryFile (filename : string) : file =
(* Take the name of a file and make a valid symbol name out of it. There are
* a few characters that are not valid in symbols *)
let makeValidSymbolName (s: string) =
let s = String.copy s in (* So that we can update in place *)
let l = String.length s in
let s = Bytes.of_string s in (* strings are immutable; convert to mutable Bytes *)
let l = Bytes.length s in
for i = 0 to l - 1 do
let c = String.get s i in
let c = Bytes.get s i in
let isinvalid =
match c with
'-' | '.' -> true
| _ -> false
in
if isinvalid then
String.set s i '_';
Bytes.set s i '_';
done;
s
Bytes.to_string s

let rec addOffset (toadd: offset) (off: offset) : offset =
match off with
Expand Down
2 changes: 1 addition & 1 deletion src/ext/partial/heap.ml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ type ('a) t = {
}

let create size = {
elements = Array.create (size+1) (max_int,None) ;
elements = Array.make (size+1) (max_int,None) ;
size = 0 ;
capacity = size ;
}
Expand Down
6 changes: 5 additions & 1 deletion src/ext/pta/golf.ml
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
(* Tue Apr 23 10:16:43 EDT 2013 WRW -- this is a copy of 'golf.ml' from
* CIL 1.6.0 copied locally and adapted to work with Genprog (e.g., for
* handling the strong update problem when computing dataflow analyses). *)

(*
*
* Copyright (c) 2001-2002,
* Copyright (c) 2001-2017,
* John Kodumal <jkodumal@eecs.berkeley.edu>
* All rights reserved.
*
Expand Down
21 changes: 16 additions & 5 deletions src/ext/pta/ptranal.ml
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
(* Tue Apr 23 10:16:43 EDT 2013 WRW -- this is a copy of 'ptranal.ml' from
* CIL 1.6.0 copied locally and adapted to work with Genprog (e.g., for
* handling the strong update problem when computing dataflow analyses). *)

(*
*
* Copyright (c) 2001-2002,
* Copyright (c) 2001-2017,
* John Kodumal <jkodumal@eecs.berkeley.edu>
* All rights reserved.
*
Expand Down Expand Up @@ -42,7 +46,7 @@ open Feature

module H = Hashtbl

module A = Olf
module A = Golf
exception UnknownLocation = A.UnknownLocation

type access = A.lvalue * bool
Expand Down Expand Up @@ -245,13 +249,17 @@ and analyze_expr (e : exp ) : A.tau =
| AlignOf _ -> A.bottom ()
| UnOp (op, e, t) -> analyze_expr e
| BinOp (op, e, e', t) -> A.join (analyze_expr e) (analyze_expr e')
(*
| Question (_, e, e', _) -> A.join (analyze_expr e) (analyze_expr e')
*)
| CastE (t, e) -> analyze_expr e
| AddrOf l ->
if !fun_ptrs_as_funs && isFunctionType (typeOfLval l) then
A.rvalue (analyze_lval l)
else A.address (analyze_lval l)
(*
| AddrOfLabel _ -> failwith "not implemented yet" (* XXX *)
*)
| StartOf l -> A.address (analyze_lval l)
| AlignOfE _ -> A.bottom ()
| SizeOfE _ -> A.bottom ()
Expand Down Expand Up @@ -285,7 +293,7 @@ let analyze_instr (i : instr ) : unit =
List.iter (fun e -> ignore (analyze_expr e)) actuals
else (* todo : check to see if the thing is an undefined function *)
let fnres, site =
if is_undefined_fun fexpr && !conservative_undefineds then
if is_undefined_fun fexpr & !conservative_undefineds then
A.apply_undefined (Util.list_map analyze_expr actuals)
else
A.apply (analyze_expr fexpr) (Util.list_map analyze_expr actuals)
Expand Down Expand Up @@ -316,7 +324,9 @@ let rec analyze_stmt (s : stmt ) : unit =
| None -> ()
end
| Goto (s', l) -> () (* analyze_stmt(!s') *)
(*
| ComputedGoto (e, l) -> ()
*)
| If (e, b, b', l) ->
(* ignore the expression e; expressions can't be side-effecting *)
analyze_block b;
Expand Down Expand Up @@ -562,15 +572,16 @@ let absloc_eq a b = A.absloc_eq (a, b)
let d_absloc: unit -> absloc -> Pretty.doc = A.d_absloc


let ptrAnalysis = ref false
let ptrResults = ref false
let ptrTypes = ref false



(** Turn this into a CIL feature *)
let feature = {
let feature = {
fd_name = "ptranal";
fd_enabled = false;
fd_enabled = !ptrAnalysis;
fd_description = "alias analysis";
fd_extraopt = [
("--ptr_may_aliases",
Expand Down
4 changes: 2 additions & 2 deletions src/formatlex.mll
Original file line number Diff line number Diff line change
Expand Up @@ -145,11 +145,11 @@ let scan_oct_escape str =
* We convert L"Hi" to "H\000i\000" *)
let wbtowc wstr =
let len = String.length wstr in
let dest = String.make (len * 2) '\000' in
let dest = Bytes.make (len * 2) '\000' in
for i = 0 to len-1 do
dest.[i*2] <- wstr.[i] ;
done ;
dest
Bytes.to_string dest

(* This function converst the "Hi" in L"Hi" to { L'H', L'i', L'\0' } *)
let wstr_to_warray wstr =
Expand Down
4 changes: 2 additions & 2 deletions src/frontc/cabs2cil.ml
Original file line number Diff line number Diff line change
Expand Up @@ -1924,7 +1924,7 @@ let rec setOneInit (this: preInit)
let pMaxIdx, pArray =
match this with
NoInitPre -> (* No initializer so far here *)
ref idx, ref (Array.create (max 32 (idx + 1)) NoInitPre)
ref idx, ref (Array.make (max 32 (idx + 1)) NoInitPre)

| CompoundPre (pMaxIdx, pArray) ->
if !pMaxIdx < idx then begin
Expand Down Expand Up @@ -3417,7 +3417,7 @@ and doExp (asconst: bool) (* This expression is used as a constant *)
let l = String.length str in
fun s ->
let ls = String.length s in
l >= ls && s = String.uppercase (String.sub str (l - ls) ls)
l >= ls && s = String.uppercase_ascii (String.sub str (l - ls) ls)
in
match ct with
A.CONST_INT str -> begin
Expand Down
2 changes: 1 addition & 1 deletion src/ocamlutil/bitmap.ml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ type t = { mutable nrWords : int;
let enlarge b newWords =
let newbitmap =
if newWords > b.nrWords then
let a = Array.create newWords Int32.zero in
let a = Array.make newWords Int32.zero in
Array.blit b.bitmap 0 a 0 b.nrWords;
a
else
Expand Down
17 changes: 9 additions & 8 deletions src/ocamlutil/errormsg.ml
Original file line number Diff line number Diff line change
Expand Up @@ -205,28 +205,29 @@ let setHFile (f: string) : unit =

let rem_quotes str = String.sub str 1 ((String.length str) - 2)

(* Change \ into / in file names. To avoid complications with escapes *)
(* Change \ into / in file names. To avoid complications with escapes *)
let cleanFileName str =
let str1 =
if str <> "" && String.get str 0 = '"' (* '"' ( *)
then rem_quotes str else str in
let l = String.length str1 in
then Bytes.of_string (rem_quotes str) else Bytes.of_string str in
let l = Bytes.length str1 in
let rec loop (copyto: int) (i: int) =
if i >= l then
String.sub str1 0 copyto
Bytes.sub str1 0 copyto
else
let c = String.get str1 i in
let c = Bytes.get str1 i in
if c <> '\\' then begin
String.set str1 copyto c; loop (copyto + 1) (i + 1)
Bytes.set str1 copyto c; loop (copyto + 1) (i + 1)
end else begin
String.set str1 copyto '/';
if i < l - 2 && String.get str1 (i + 1) = '\\' then
Bytes.set str1 copyto '/';
if i < l - 2 && Bytes.get str1 (i + 1) = '\\' then
loop (copyto + 1) (i + 2)
else
loop (copyto + 1) (i + 1)
end
in
loop 0 0
Bytes.to_string (loop 0 0)

let readingFromStdin = ref false

Expand Down
2 changes: 1 addition & 1 deletion src/ocamlutil/inthash.ml
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ let resize tbl =
let osize = Array.length odata in
let nsize = min (2 * osize + 1) Sys.max_array_length in
if nsize <> osize then begin
let ndata = Array.create nsize Empty in
let ndata = Array.make nsize Empty in
let rec insert_bucket = function
Empty -> ()
| Cons(key, data, rest) ->
Expand Down
2 changes: 1 addition & 1 deletion src/ocamlutil/longarray.ml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ let split_idx (idx: int) : int option =

let rec create (len: int) (init: 'a) : 'a t =
let len1, len2 = split_len len in
(Array.create len1 init) :: (if len2 > 0 then create len2 init else [])
(Array.make len1 init) :: (if len2 > 0 then create len2 init else [])

let rec init (len: int) (fn: int -> 'a) : 'a t =
let len1, len2 = split_len len in
Expand Down
18 changes: 9 additions & 9 deletions src/ocamlutil/pretty.ml
Original file line number Diff line number Diff line change
Expand Up @@ -725,31 +725,31 @@ let gprintf (finish : doc -> 'b)
invalid_arg ("dprintf: unimplemented format "
^ (String.sub format i (j-i+1)));
let j' = succ j in (* eat the d,i,x etc. *)
let format_spec = "% " in
String.set format_spec 1 (fget j'); (* format_spec = "%x", etc. *)
let format_spec = Bytes.of_string "% " in
Bytes.set format_spec 1 (fget j'); (* format_spec = "%x", etc. *)
Obj.magic(fun n ->
collect (dctext1 acc
(Int64.format format_spec n))
(Int64.format (Bytes.to_string format_spec) n))
(succ j'))
| 'l' ->
if j != i + 1 then invalid_arg ("dprintf: unimplemented format "
^ (String.sub format i (j-i+1)));
let j' = succ j in (* eat the d,i,x etc. *)
let format_spec = "% " in
String.set format_spec 1 (fget j'); (* format_spec = "%x", etc. *)
let format_spec = Bytes.of_string "% " in
Bytes.set format_spec 1 (fget j'); (* format_spec = "%x", etc. *)
Obj.magic(fun n ->
collect (dctext1 acc
(Int32.format format_spec n))
(Int32.format (Bytes.to_string format_spec) n))
(succ j'))
| 'n' ->
if j != i + 1 then invalid_arg ("dprintf: unimplemented format "
^ (String.sub format i (j-i+1)));
let j' = succ j in (* eat the d,i,x etc. *)
let format_spec = "% " in
String.set format_spec 1 (fget j'); (* format_spec = "%x", etc. *)
let format_spec = Bytes.of_string "% " in
Bytes.set format_spec 1 (fget j'); (* format_spec = "%x", etc. *)
Obj.magic(fun n ->
collect (dctext1 acc
(Nativeint.format format_spec n))
(Nativeint.format (Bytes.to_string format_spec) n))
(succ j'))
| 'f' | 'e' | 'E' | 'g' | 'G' ->
Obj.magic(fun f ->
Expand Down