Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 17 additions & 2 deletions src/cdomains/arrayDomain.ml
Original file line number Diff line number Diff line change
Expand Up @@ -567,8 +567,23 @@ struct
let smart_widen = smart_widen_with_length None
let smart_leq = smart_leq_with_length None

let meet a b = normalize @@ meet a b
let narrow a b = normalize @@ narrow a b
let meet (e1,v1) (e2,v2) = normalize @@
match e1,e2 with
| `Lifted e1e, `Lifted e2e when not (Basetype.CilExp.equal e1e e2e) ->
(* partitioned according to two different expressions -> meet can not be element-wise *)
(* arrays can not be partitioned according to multiple expressions, arbitrary prefer the first one here *)
(* TODO: do smart things if the relationship between e1e and e2e is known *)
(e1,v1)
| _ -> meet (e1,v1) (e2,v2)

let narrow (e1,v1) (e2,v2) = normalize @@
match e1,e2 with
| `Lifted e1e, `Lifted e2e when not (Basetype.CilExp.equal e1e e2e) ->
(* partitioned according to two different expressions -> narrow can not be element-wise *)
(* arrays can not be partitioned according to multiple expressions, arbitrary prefer the first one here *)
(* TODO: do smart things if the relationship between e1e and e2e is known *)
(e1,v1)
| _ -> narrow (e1,v1) (e2,v2)

let update_length _ x = x
end
Expand Down
16 changes: 16 additions & 0 deletions tests/regression/22-partitioned_arrays/16-refine-meet.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
// PARAM: --enable exp.partition-arrays.enabled
int garr[7];

int main(int argc, char **argv)
{
// Call to a function with a missing fundef causes invalidation of garr
fundef_missing();

garr[0] = 8;


if (garr[1] == 1) {
// Statement so CIL doesn't optimize the if out
int ret = 12;
}
}