diff --git a/src/cil.ml b/src/cil.ml index 63da92793..64e60bb0b 100755 --- a/src/cil.ml +++ b/src/cil.ml @@ -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 *) @@ -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 diff --git a/src/ext/partial/heap.ml b/src/ext/partial/heap.ml index 10f48a045..5fbbe372c 100644 --- a/src/ext/partial/heap.ml +++ b/src/ext/partial/heap.ml @@ -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 ; } diff --git a/src/ext/pta/golf.ml b/src/ext/pta/golf.ml index 69c94abe4..233ee7ce4 100644 --- a/src/ext/pta/golf.ml +++ b/src/ext/pta/golf.ml @@ -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 * All rights reserved. * diff --git a/src/ext/pta/ptranal.ml b/src/ext/pta/ptranal.ml index e3a3be266..a11c36779 100644 --- a/src/ext/pta/ptranal.ml +++ b/src/ext/pta/ptranal.ml @@ -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 * All rights reserved. * @@ -42,7 +46,7 @@ open Feature module H = Hashtbl -module A = Olf +module A = Golf exception UnknownLocation = A.UnknownLocation type access = A.lvalue * bool @@ -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 () @@ -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) @@ -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; @@ -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", diff --git a/src/formatlex.mll b/src/formatlex.mll index 584a060d5..93d7ee61e 100644 --- a/src/formatlex.mll +++ b/src/formatlex.mll @@ -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 = diff --git a/src/frontc/cabs2cil.ml b/src/frontc/cabs2cil.ml index dc185e133..61721cd7d 100644 --- a/src/frontc/cabs2cil.ml +++ b/src/frontc/cabs2cil.ml @@ -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 @@ -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 diff --git a/src/ocamlutil/bitmap.ml b/src/ocamlutil/bitmap.ml index 14d26a08b..33f5f9aea 100644 --- a/src/ocamlutil/bitmap.ml +++ b/src/ocamlutil/bitmap.ml @@ -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 diff --git a/src/ocamlutil/errormsg.ml b/src/ocamlutil/errormsg.ml index 2ffee51cf..6b6ef06d6 100644 --- a/src/ocamlutil/errormsg.ml +++ b/src/ocamlutil/errormsg.ml @@ -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 diff --git a/src/ocamlutil/inthash.ml b/src/ocamlutil/inthash.ml index 8d5bd32af..a6253b9b6 100644 --- a/src/ocamlutil/inthash.ml +++ b/src/ocamlutil/inthash.ml @@ -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) -> diff --git a/src/ocamlutil/longarray.ml b/src/ocamlutil/longarray.ml index ed9f533b1..0cdef6154 100644 --- a/src/ocamlutil/longarray.ml +++ b/src/ocamlutil/longarray.ml @@ -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 diff --git a/src/ocamlutil/pretty.ml b/src/ocamlutil/pretty.ml index 41180974f..0076361d6 100644 --- a/src/ocamlutil/pretty.ml +++ b/src/ocamlutil/pretty.ml @@ -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 ->