@@ -928,7 +928,7 @@ struct
928
928
(* | Lval (Mem e, ofs) -> get ~man st (eval_lv ~man (Mem e, ofs)) *)
929
929
| (Mem e , ofs ) ->
930
930
(* if M.tracing then M.tracel "cast" "Deref: lval: %a" d_plainlval lv;*)
931
- let rec contains_vla (t :typ ) = match t with
931
+ let rec contains_vla (t :typ ) = match Cil. unrollType t with
932
932
| TPtr (t , _ ) -> contains_vla t
933
933
| TArray (t , None, args ) -> true
934
934
| TArray (t , Some exp , args ) when isConstant exp -> contains_vla t
@@ -1452,7 +1452,8 @@ struct
1452
1452
match eval_rv_address ~man man.local e with
1453
1453
| Address a ->
1454
1454
let slen = Seq. map String. length (List. to_seq (AD. to_string a)) in
1455
- let lenOf = function
1455
+ let lenOf t =
1456
+ match Cil. unrollType t with
1456
1457
| TArray (_ , l , _ ) -> (try Some (lenOfArray l) with LenOfArray -> None )
1457
1458
| _ -> None
1458
1459
in
@@ -1563,7 +1564,7 @@ struct
1563
1564
let lval = Addr.Mval. to_cil mval in
1564
1565
(try `Lifted (Bytes. to_string (Hashtbl. find char_array lval))
1565
1566
with Not_found -> Queries.Result. top q)
1566
- | _ -> (* what about ISChar and IUChar? *)
1567
+ | _ -> (* TODO: what about ISChar and IUChar? what about TEnum ? *)
1567
1568
(* ignore @@ printf "Type %a\n" d_plaintype t; *)
1568
1569
Queries.Result. top q
1569
1570
end
@@ -2030,10 +2031,8 @@ struct
2030
2031
match exp with
2031
2032
| None -> nst
2032
2033
| Some exp ->
2033
- let t_override = match Cilfacade. fundec_return_type fundec with
2034
- | TVoid _ -> M. warn ~category: M.Category. Program " Returning a value from a void function" ; assert false
2035
- | ret -> ret
2036
- in
2034
+ let t_override = Cilfacade. fundec_return_type fundec in
2035
+ assert (not (Cil. isVoidType t_override)); (* Returning a value from a void function, CIL removes the Return expression for us anyway. *)
2037
2036
let rv = eval_rv ~man man.local exp in
2038
2037
let st' = set ~man ~t_override nst (return_var () ) t_override rv in
2039
2038
match ThreadId. get_current ask with
@@ -2284,7 +2283,7 @@ struct
2284
2283
) a
2285
2284
| _ -> false
2286
2285
2287
- let get_size_of_ptr_target man ptr =
2286
+ let get_size_of_ptr_target man ptr = (* TODO: deduplicate with memOutOfBounds *)
2288
2287
let intdom_of_int x =
2289
2288
ID. of_int (Cilfacade. ptrdiff_ikind () ) (Z. of_int x)
2290
2289
in
@@ -2301,7 +2300,7 @@ struct
2301
2300
let pts_elems_to_sizes (addr : Queries.AD.elt ) =
2302
2301
begin match addr with
2303
2302
| Addr (v , _ ) ->
2304
- begin match v.vtype with
2303
+ begin match Cil. unrollType v.vtype with
2305
2304
| TArray (item_typ , _ , _ ) ->
2306
2305
let item_typ_size_in_bytes = size_of_type_in_bytes item_typ in
2307
2306
begin match man.ask (Queries. EvalLength ptr) with
0 commit comments