Skip to content

Commit 47c9084

Browse files
committed
Add some type unrolling
1 parent 0c20c66 commit 47c9084

File tree

6 files changed

+13
-11
lines changed

6 files changed

+13
-11
lines changed

src/analyses/base.ml

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -928,7 +928,7 @@ struct
928928
(* | Lval (Mem e, ofs) -> get ~man st (eval_lv ~man (Mem e, ofs)) *)
929929
| (Mem e, ofs) ->
930930
(*if M.tracing then M.tracel "cast" "Deref: lval: %a" d_plainlval lv;*)
931-
let rec contains_vla (t:typ) = match t with (* TODO: unrolltype? *)
931+
let rec contains_vla (t:typ) = match Cil.unrollType t with
932932
| TPtr (t, _) -> contains_vla t
933933
| TArray(t, None, args) -> true
934934
| TArray(t, Some exp, args) when isConstant exp -> contains_vla t
@@ -1452,7 +1452,8 @@ struct
14521452
match eval_rv_address ~man man.local e with
14531453
| Address a ->
14541454
let slen = Seq.map String.length (List.to_seq (AD.to_string a)) in
1455-
let lenOf = function (* TODO: unrolltype? *)
1455+
let lenOf t =
1456+
match Cil.unrollType t with
14561457
| TArray (_, l, _) -> (try Some (lenOfArray l) with LenOfArray -> None)
14571458
| _ -> None
14581459
in
@@ -2285,7 +2286,7 @@ struct
22852286
) a
22862287
| _ -> false
22872288

2288-
let get_size_of_ptr_target man ptr =
2289+
let get_size_of_ptr_target man ptr = (* TODO: deduplicate with memOutOfBounds *)
22892290
let intdom_of_int x =
22902291
ID.of_int (Cilfacade.ptrdiff_ikind ()) (Z.of_int x)
22912292
in
@@ -2302,7 +2303,7 @@ struct
23022303
let pts_elems_to_sizes (addr: Queries.AD.elt) =
23032304
begin match addr with
23042305
| Addr (v, _) ->
2305-
begin match v.vtype with (* TODO: unrolltype? *)
2306+
begin match Cil.unrollType v.vtype with
23062307
| TArray (item_typ, _, _) ->
23072308
let item_typ_size_in_bytes = size_of_type_in_bytes item_typ in
23082309
begin match man.ask (Queries.EvalLength ptr) with

src/analyses/memOutOfBounds.ml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ struct
7777
) a
7878
| _ -> false
7979

80-
let get_size_of_ptr_target man ptr =
80+
let get_size_of_ptr_target man ptr = (* TODO: deduplicate with base *)
8181
if points_to_alloc_only man ptr then
8282
(* Ask for BlobSize from the base address (the second component being set to true) in order to avoid BlobSize giving us bot *)
8383
man.ask (Queries.BlobSize {exp = ptr; base_address = true})
@@ -92,7 +92,7 @@ struct
9292
set_mem_safety_flag InvalidDeref;
9393
M.warn "Var %a is potentially accessed out-of-scope. Invalid memory access may occur" CilType.Varinfo.pretty v
9494
);
95-
begin match v.vtype with (* TODO: unrolltype? *)
95+
begin match Cil.unrollType v.vtype with
9696
| TArray (item_typ, _, _) ->
9797
let item_typ_size_in_bytes = size_of_type_in_bytes item_typ in
9898
begin match man.ask (Queries.EvalLength ptr) with

src/analyses/raceAnalysis.ml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -351,7 +351,8 @@ struct
351351
| ts ->
352352
if not (Queries.TS.is_empty ts) then
353353
includes_uk := true;
354-
let f = function (* TODO: unrolltype? *)
354+
let f t =
355+
match Cil.unrollType t with
355356
| TComp (ci, _) ->
356357
add_access_struct (conf - 50) ci
357358
| _ -> ()

src/cdomain/value/cdomains/structDomain.ml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -269,15 +269,15 @@ struct
269269
match rem_fields with
270270
| [] -> second_choice
271271
| h::t -> begin
272-
match (h.ftype, get_bool "ana.base.structs.key.prefer-ptrs", get_bool "ana.base.structs.key.avoid-ints") with (* TODO: unrolltype? *)
272+
match Cil.unrollType h.ftype, get_bool "ana.base.structs.key.prefer-ptrs", get_bool "ana.base.structs.key.avoid-ints" with (* TODO: generalize to TEnum with Cil.isIntegralType? *)
273273
| (TPtr (_, _), _, _) -> h
274274
| (TInt (_, _), true, _)
275275
| (TInt (_, _), _, true) -> first_appropriate_key t second_choice
276276
| (TInt (_, _), _, _) -> h
277277
| (_, false, _) -> h
278278
| (_, _, false) -> first_appropriate_key t second_choice
279279
| (_, _, _) ->
280-
let second = match second_choice.ftype with (* TODO: unrolltype? *)
280+
let second = match Cil.unrollType second_choice.ftype with (* TODO: generalize to TEnum with Cil.isIntegralType? *)
281281
| TInt (_,_) -> h
282282
| _ -> second_choice
283283
in first_appropriate_key t second

src/cdomain/value/cdomains/valueDomain.ml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -372,7 +372,7 @@ struct
372372
if is_statically_safe_cast t2 t1 then
373373
true
374374
else
375-
match t2, t1, v with (* TODO: unrolltype? *)
375+
match Cil.unrollType t2, Cil.unrollType t1, v with
376376
| (TInt (ik2,_) | TEnum ({ekind=ik2; _},_)) , (TInt (ik1,_) | TEnum ({ekind=ik1; _},_)), Int v ->
377377
let cl, cu = IntDomain.Size.range ik2 in
378378
let l, u = ID.minimal v, ID.maximal v in

src/framework/constraints.ml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -259,7 +259,7 @@ struct
259259
Queries.AD.to_var_may ad (* TODO: don't convert, handle UnknownPtr below *)
260260
in
261261
let one_function f =
262-
match f.vtype with (* TODO: unrolltype? *)
262+
match Cil.unrollType f.vtype with
263263
| TFun (_, params, var_arg, _) ->
264264
let arg_length = List.length args in
265265
let p_length = Option.map_default List.length 0 params in

0 commit comments

Comments
 (0)