let warn_lval_read lv loc contents =
let pretty_param fmt param =
match param with
| Location_Bits.Top_Param.Top -> Format.fprintf fmt "is imprecise"
| Location_Bits.Top_Param.Set _s ->
Format.fprintf fmt "is a garbled mix of %a"
Location_Bits.Top_Param.pretty param
in
let pretty_param_b fmt param =
match param with
| Location_Bytes.Top_Param.Top ->
Format.fprintf fmt "The contents@ are imprecise"
| Location_Bytes.Top_Param.Set _s ->
Format.fprintf fmt "It contains@ a garbled@ mix@ of@ %a"
Location_Bytes.Top_Param.pretty param
in
let something_to_warn =
match loc.loc with Location_Bits.Top _ -> true
| Location_Bits.Map _ ->
match contents with
| Location_Bytes.Top _ -> true
| Location_Bytes.Map _ -> false
in
if something_to_warn then
Value_parameters.result ~current:true ~once:true
"@[<v>@[Reading left-value %a.@]@ %t%t%t@]"
!Ast_printer.d_lval lv
(fun fmt ->
match lv with
| Mem _, _ ->
(match loc.loc with
| Location_Bits.Top (param,o) when Origin.equal o Origin.top ->
Format.fprintf fmt "@[The location %a.@]@ "
pretty_param param
| Location_Bits.Top (param,orig) ->
Format.fprintf fmt "@[The location @[%a@]@ because of@ %a.@]@ "
pretty_param param
Origin.pretty orig
| Location_Bits.Map _ ->
Format.fprintf fmt "@[The location is @[%a@].@]@ "
Location_Bits.pretty loc.loc)
| Var _, _ -> ())
(fun fmt ->
match contents with
| Location_Bytes.Top (param,o) when Origin.equal o Origin.top ->
Format.fprintf fmt "@[%a.@]"
pretty_param_b param
| Location_Bytes.Top (param,orig) ->
Format.fprintf fmt "@[%a@ because of@ %a.@]"
pretty_param_b param
Origin.pretty orig
| Location_Bytes.Map _ -> ())
pp_callstack