Skip to content

Commit 524d91b

Browse files
authored
Merge branch 'master' into master
2 parents 55912b3 + fa6d3b4 commit 524d91b

File tree

24 files changed

+224
-206
lines changed

24 files changed

+224
-206
lines changed

.semgrep/let.yml

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
rules:
2-
- id: let-unit-in
3-
pattern: let () = $E in ...
4-
message: use ; instead (and, if needed, add surrounding parentheses to preserve precedence)
5-
languages: [ocaml]
6-
severity: WARNING
2+
[]
3+
# TODO: disabled because semgrep cannot distinguish from let@ which is fine (https://github.com/semgrep/semgrep/issues/11432)
4+
# - id: let-unit-in
5+
# pattern: let () = $E in ...
6+
# message: use ; instead (and, if needed, add surrounding parentheses to preserve precedence)
7+
# languages: [ocaml]
8+
# severity: WARNING

scripts/bash-completion.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ _goblint ()
2525
IFS=$'\n'
2626
local words cword cur
2727
_get_comp_words_by_ref -n = cur words cword # Bypass = in COMP_WORDBREAKS (https://stackoverflow.com/a/57437406/854540)
28-
COMPREPLY=($(${words[0]} --complete "${words[@]:1:cword}"))
28+
COMPREPLY=($(${words[0]/#\~/$HOME} --complete "${words[@]:1:cword}"))
2929
__ltrim_equal_completions "$cur" # Bypass = in COMP_WORDBREAKS (https://stackoverflow.com/a/57437406/854540)
3030
}
3131

@@ -45,7 +45,7 @@ _regtest ()
4545
*)
4646
local words cword cur
4747
_get_comp_words_by_ref -n = cur words cword # Bypass = in COMP_WORDBREAKS (https://stackoverflow.com/a/57437406/854540)
48-
COMPREPLY=($($(dirname ${words[0]})/goblint --complete "${words[@]:3:cword}"))
48+
COMPREPLY=($($(dirname ${words[0]/#\~/$HOME})/goblint --complete "${words[@]:3:cword}"))
4949
__ltrim_equal_completions "$cur" # Bypass = in COMP_WORDBREAKS (https://stackoverflow.com/a/57437406/854540)
5050
;;
5151
esac

src/analyses/base.ml

Lines changed: 29 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -169,14 +169,27 @@ struct
169169

170170
let iDtoIdx x = ID.cast_to ~kind:Internal (Cilfacade.ptrdiff_ikind ()) x (* TODO: proper castkind *)
171171

172+
(** Unary float predicates return non-zero for [true].
173+
@see C11 7.12.3 *)
174+
let fd_unary_pred = function
175+
| Some true -> ID.of_excl_list IInt [Z.zero]
176+
| Some false -> ID.of_int IInt Z.zero
177+
| None -> ID.top_of IInt
178+
179+
(** Binary float predicates return one for [true].
180+
@see C11 7.12.14, 6.5.8, 6.5.9 *)
181+
let fd_binary_pred = function
182+
| Some b -> ID.of_bool IInt b
183+
| None -> ID.top_of IInt
184+
172185
let unop_ID = function
173186
| Neg -> ID.neg
174187
| BNot -> ID.lognot
175188
| LNot -> ID.c_lognot
176189

177190
let unop_FD = function
178191
| Neg -> (fun v -> (Float (FD.neg v):value))
179-
| LNot -> (fun c -> Int (FD.eq c (FD.of_const (FD.get_fkind c) 0.)))
192+
| LNot -> (fun c -> Int (fd_unary_pred (FD.eq c (FD.of_const (FD.get_fkind c) 0.))))
180193
| BNot -> failwith "BNot on a value of type float!"
181194

182195

@@ -256,7 +269,7 @@ struct
256269
| Ge -> FD.ge
257270
| Eq -> FD.eq
258271
| Ne -> FD.ne
259-
| _ -> (fun _ _ -> ID.top ())
272+
| _ -> (fun _ _ -> None)
260273

261274
let is_int_returning_binop_FD = function
262275
| Lt | Gt | Le | Ge | Eq | Ne -> true
@@ -280,7 +293,7 @@ struct
280293
let rec addToOffset n (t:typ option) = function
281294
| `Index (i, `NoOffset) ->
282295
(* Binary operations on pointer types should not generate warnings in SV-COMP *)
283-
GobRef.wrap AnalysisState.executing_speculative_computations true @@ fun () ->
296+
let@ () = GobRef.wrap AnalysisState.executing_speculative_computations true in
284297
(* If we have arrived at the last Offset and it is an Index, we add our integer to it *)
285298
`Index(IdxDom.add i (iDtoIdx n), `NoOffset)
286299
| `Field (f, `NoOffset) ->
@@ -346,7 +359,8 @@ struct
346359
(* For the float values, we apply the float domain operators *)
347360
| Float v1, Float v2 when is_int_returning_binop_FD op ->
348361
let result_ik = Cilfacade.get_ikind t in
349-
Int (ID.cast_to ~kind:Internal result_ik (int_returning_binop_FD op v1 v2)) (* TODO: proper castkind *)
362+
assert (result_ik = IInt);
363+
Int (fd_binary_pred (int_returning_binop_FD op v1 v2))
350364
| Float v1, Float v2 -> Float (binop_FD (Cilfacade.get_fkind t) op v1 v2)
351365
(* For address +/- value, we try to do some elementary ptr arithmetic *)
352366
| Address p, Int n
@@ -2661,11 +2675,11 @@ struct
26612675
| Nan (fk, str) when Cil.isPointerType (Cilfacade.typeOf str) -> Float (FD.nan_of fk)
26622676
| Nan _ -> failwith ("non-pointer argument in call to function "^f.vname)
26632677
| Inf fk -> Float (FD.inf_of fk)
2664-
| Isfinite x -> Int (ID.cast_to ~kind:Internal IInt (apply_unary FDouble FD.isfinite x)) (* TODO: proper castkind *)
2665-
| Isinf x -> Int (ID.cast_to ~kind:Internal IInt (apply_unary FDouble FD.isinf x)) (* TODO: proper castkind *)
2666-
| Isnan x -> Int (ID.cast_to ~kind:Internal IInt (apply_unary FDouble FD.isnan x)) (* TODO: proper castkind *)
2667-
| Isnormal x -> Int (ID.cast_to ~kind:Internal IInt (apply_unary FDouble FD.isnormal x)) (* TODO: proper castkind *)
2668-
| Signbit x -> Int (ID.cast_to ~kind:Internal IInt (apply_unary FDouble FD.signbit x)) (* TODO: proper castkind *)
2678+
| Isfinite x -> Int (fd_unary_pred (apply_unary FDouble FD.isfinite x))
2679+
| Isinf x -> Int (fd_unary_pred (apply_unary FDouble FD.isinf x))
2680+
| Isnan x -> Int (fd_unary_pred (apply_unary FDouble FD.isnan x))
2681+
| Isnormal x -> Int (fd_unary_pred (apply_unary FDouble FD.isnormal x))
2682+
| Signbit x -> Int (fd_unary_pred (apply_unary FDouble FD.signbit x))
26692683
| Ceil (fk,x) -> Float (apply_unary fk FD.ceil x)
26702684
| Floor (fk,x) -> Float (apply_unary fk FD.floor x)
26712685
| Fabs (fk, x) -> Float (apply_unary fk FD.fabs x)
@@ -2676,12 +2690,12 @@ struct
26762690
| Cos (fk, x) -> Float (apply_unary fk FD.cos x)
26772691
| Sin (fk, x) -> Float (apply_unary fk FD.sin x)
26782692
| Tan (fk, x) -> Float (apply_unary fk FD.tan x)
2679-
| Isgreater (x,y) -> Int(ID.cast_to ~kind:Internal IInt (apply_binary FDouble FD.gt x y)) (* TODO: proper castkind *)
2680-
| Isgreaterequal (x,y) -> Int(ID.cast_to ~kind:Internal IInt (apply_binary FDouble FD.ge x y)) (* TODO: proper castkind *)
2681-
| Isless (x,y) -> Int(ID.cast_to ~kind:Internal IInt (apply_binary FDouble FD.lt x y)) (* TODO: proper castkind *)
2682-
| Islessequal (x,y) -> Int(ID.cast_to ~kind:Internal IInt (apply_binary FDouble FD.le x y)) (* TODO: proper castkind *)
2683-
| Islessgreater (x,y) -> Int(ID.c_logor (ID.cast_to ~kind:Internal IInt (apply_binary FDouble FD.lt x y)) (ID.cast_to ~kind:Internal IInt (apply_binary FDouble FD.gt x y))) (* TODO: proper castkind *)
2684-
| Isunordered (x,y) -> Int(ID.cast_to ~kind:Internal IInt (apply_binary FDouble FD.unordered x y)) (* TODO: proper castkind *)
2693+
| Isgreater (x,y) -> Int(fd_binary_pred (apply_binary FDouble FD.gt x y))
2694+
| Isgreaterequal (x,y) -> Int(fd_binary_pred (apply_binary FDouble FD.ge x y))
2695+
| Isless (x,y) -> Int(fd_binary_pred (apply_binary FDouble FD.lt x y))
2696+
| Islessequal (x,y) -> Int(fd_binary_pred (apply_binary FDouble FD.le x y))
2697+
| Islessgreater (x,y) -> Int(ID.c_logor (fd_binary_pred (apply_binary FDouble FD.lt x y)) (fd_binary_pred (apply_binary FDouble FD.gt x y)))
2698+
| Isunordered (x,y) -> Int(fd_binary_pred (apply_binary FDouble FD.unordered x y))
26852699
| Fmax (fd, x ,y) -> Float (apply_binary fd FD.fmax x y)
26862700
| Fmin (fd, x ,y) -> Float (apply_binary fd FD.fmin x y)
26872701
| Sqrt (fk, x) -> Float (apply_unary fk FD.sqrt x)

src/analyses/baseInvariant.ml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -890,6 +890,6 @@ struct
890890
let invariant man st exp tv =
891891
(* The computations that happen here are not computations that happen in the programs *)
892892
(* Any overflow during the forward evaluation will already have been flagged here *)
893-
GobRef.wrap AnalysisState.executing_speculative_computations true
894-
@@ fun () -> invariant man st exp tv
893+
let@ () = GobRef.wrap AnalysisState.executing_speculative_computations true in
894+
invariant man st exp tv
895895
end

src/analyses/basePriv.ml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2031,7 +2031,7 @@ struct
20312031
v
20322032

20332033
let dump () =
2034-
Out_channel.with_open_bin (get_string "exp.priv-prec-dump") @@ fun f ->
2034+
let@ f = Out_channel.with_open_bin (get_string "exp.priv-prec-dump") in
20352035
(* LVH.iter (fun (l, x) v ->
20362036
Logs.debug "%a %a = %a" CilType.Location.pretty l CilType.Varinfo.pretty x VD.pretty v
20372037
) lvh; *)

src/autoTune.ml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ class findAllocsInLoops = object
6262

6363
method! vinst = function
6464
| Call (_, Lval (Var f, NoOffset), args,_,_) when LibraryFunctions.is_special f ->
65-
Goblint_backtrace.protect ~mark:(fun () -> Cilfacade.FunVarinfo f) ~finally:Fun.id @@ fun () ->
65+
let@ () = Goblint_backtrace.protect ~mark:(fun () -> Cilfacade.FunVarinfo f) ~finally:Fun.id in
6666
let desc = LibraryFunctions.find f in
6767
begin match desc.special args with
6868
| Malloc _
@@ -96,7 +96,7 @@ let functionArgs fd = (ResettableLazy.force functionCallMaps).argLists |> Functi
9696

9797
let findMallocWrappers () =
9898
let isMalloc f =
99-
Goblint_backtrace.wrap_val ~mark:(Cilfacade.FunVarinfo f) @@ fun () ->
99+
let@ () = Goblint_backtrace.wrap_val ~mark:(Cilfacade.FunVarinfo f) in
100100
if LibraryFunctions.is_special f then
101101
let desc = LibraryFunctions.find f in
102102
let args = functionArgs f in
@@ -177,15 +177,15 @@ let disableIntervalContextsInRecursiveFunctions () =
177177

178178
let hasFunction pred =
179179
let relevant_static var =
180-
Goblint_backtrace.wrap_val ~mark:(Cilfacade.FunVarinfo var) @@ fun () ->
180+
let@ () = Goblint_backtrace.wrap_val ~mark:(Cilfacade.FunVarinfo var) in
181181
if LibraryFunctions.is_special var then
182182
let desc = LibraryFunctions.find var in
183183
GobOption.exists (fun args -> pred desc args) (functionArgs var)
184184
else
185185
false
186186
in
187187
let relevant_dynamic var =
188-
Goblint_backtrace.wrap_val ~mark:(Cilfacade.FunVarinfo var) @@ fun () ->
188+
let@ () = Goblint_backtrace.wrap_val ~mark:(Cilfacade.FunVarinfo var) in
189189
if LibraryFunctions.is_special var then
190190
let desc = LibraryFunctions.find var in
191191
(* We don't really have arguments at hand, so we cheat and just feed it a list of MyCFG.unknown_exp of appropriate length *)

0 commit comments

Comments
 (0)