|
|
|
@ -21,16 +21,6 @@ let tests =
|
|
|
|
|
let open AnalyzerTester.StructuredSil in
|
|
|
|
|
let assert_empty = invariant "{ }" in
|
|
|
|
|
let test_list = [
|
|
|
|
|
"var_tautology",
|
|
|
|
|
[
|
|
|
|
|
var_assign_var "a" "a";
|
|
|
|
|
assert_empty
|
|
|
|
|
];
|
|
|
|
|
"id_tautology",
|
|
|
|
|
[
|
|
|
|
|
id_assign_id "a" "a";
|
|
|
|
|
assert_empty
|
|
|
|
|
];
|
|
|
|
|
"id_letderef_id_no_gen",
|
|
|
|
|
[
|
|
|
|
|
id_assign_id "b" "a"; (* means b = *a *)
|
|
|
|
@ -41,7 +31,6 @@ let tests =
|
|
|
|
|
id_set_id "b" "a"; (* means *b = a *)
|
|
|
|
|
assert_empty
|
|
|
|
|
];
|
|
|
|
|
|
|
|
|
|
"id_set_id_no_kill",
|
|
|
|
|
[
|
|
|
|
|
id_assign_var "b" "a";
|
|
|
|
@ -54,10 +43,10 @@ let tests =
|
|
|
|
|
id_assign_var "b" "a";
|
|
|
|
|
invariant "{ b$0 -> &a }"
|
|
|
|
|
];
|
|
|
|
|
"var_assign_var_gen",
|
|
|
|
|
"var_assign_addrof_var_no_gen",
|
|
|
|
|
[
|
|
|
|
|
var_assign_var "b" "a";
|
|
|
|
|
invariant "{ &b -> &a }"
|
|
|
|
|
var_assign_addrof_var "b" "a"; (* means b = &a *)
|
|
|
|
|
assert_empty
|
|
|
|
|
];
|
|
|
|
|
"var_assign_id_gen",
|
|
|
|
|
[
|
|
|
|
@ -66,130 +55,112 @@ let tests =
|
|
|
|
|
];
|
|
|
|
|
"multi_command_gen",
|
|
|
|
|
[
|
|
|
|
|
var_assign_var "b" "a";
|
|
|
|
|
var_assign_var "c" "b";
|
|
|
|
|
var_assign_var "d" "c";
|
|
|
|
|
invariant "{ &b -> &a, &c -> &b, &d -> &c }"
|
|
|
|
|
id_assign_var "b" "a";
|
|
|
|
|
var_assign_id "c" "b";
|
|
|
|
|
id_assign_var "d" "c";
|
|
|
|
|
invariant "{ b$0 -> &a, d$0 -> &c, &c -> b$0 }"
|
|
|
|
|
];
|
|
|
|
|
"simple_kill",
|
|
|
|
|
[
|
|
|
|
|
var_assign_var "b" "a";
|
|
|
|
|
invariant "{ &b -> &a }";
|
|
|
|
|
id_assign_var "b" "a";
|
|
|
|
|
invariant "{ b$0 -> &a }";
|
|
|
|
|
var_assign_int "a" 1;
|
|
|
|
|
assert_empty
|
|
|
|
|
];
|
|
|
|
|
"kill_then_gen",
|
|
|
|
|
[
|
|
|
|
|
var_assign_var "b" "a";
|
|
|
|
|
invariant "{ &b -> &a }";
|
|
|
|
|
var_assign_var "a" "b";
|
|
|
|
|
invariant "{ &a -> &b }"
|
|
|
|
|
];
|
|
|
|
|
"harder_kill",
|
|
|
|
|
[
|
|
|
|
|
var_assign_var "b" "a";
|
|
|
|
|
var_assign_var "c" "b";
|
|
|
|
|
var_assign_var "d" "c";
|
|
|
|
|
invariant "{ &b -> &a, &c -> &b, &d -> &c }";
|
|
|
|
|
var_assign_int "b" 1;
|
|
|
|
|
invariant "{ &c -> &a, &d -> &c }";
|
|
|
|
|
var_assign_int "c" 1;
|
|
|
|
|
invariant "{ &d -> &a }"
|
|
|
|
|
id_assign_var "b" "a";
|
|
|
|
|
invariant "{ b$0 -> &a }";
|
|
|
|
|
var_assign_id "a" "c";
|
|
|
|
|
invariant "{ &a -> c$0 }"
|
|
|
|
|
];
|
|
|
|
|
"same_copy",
|
|
|
|
|
[
|
|
|
|
|
var_assign_var "b" "a";
|
|
|
|
|
var_assign_var "c" "b";
|
|
|
|
|
invariant "{ &b -> &a, &c -> &b }";
|
|
|
|
|
var_assign_var "c" "b";
|
|
|
|
|
invariant "{ &b -> &a, &c -> &b }"
|
|
|
|
|
];
|
|
|
|
|
"no_cycles",
|
|
|
|
|
[
|
|
|
|
|
var_assign_var "a" "b";
|
|
|
|
|
invariant "{ &a -> &b }";
|
|
|
|
|
var_assign_var "b" "a";
|
|
|
|
|
invariant "{ &b -> &a }";
|
|
|
|
|
var_assign_var "a" "a";
|
|
|
|
|
invariant "{ &b -> &a }"
|
|
|
|
|
var_assign_id "b" "a";
|
|
|
|
|
var_assign_id "c" "d";
|
|
|
|
|
invariant "{ &b -> a$0, &c -> d$0 }";
|
|
|
|
|
var_assign_id "c" "d";
|
|
|
|
|
invariant "{ &b -> a$0, &c -> d$0 }"
|
|
|
|
|
];
|
|
|
|
|
"conservative_if",
|
|
|
|
|
[
|
|
|
|
|
var_assign_var "b" "a";
|
|
|
|
|
var_assign_id "b" "a";
|
|
|
|
|
If (unknown_exp,
|
|
|
|
|
[invariant "{ &b -> &a }";
|
|
|
|
|
var_assign_var "a" "b";
|
|
|
|
|
invariant "{ &a -> &b }"],
|
|
|
|
|
[invariant "{ &b -> a$0 }";
|
|
|
|
|
var_assign_id "b" "c";
|
|
|
|
|
invariant "{ &b -> c$0 }"],
|
|
|
|
|
[]
|
|
|
|
|
);
|
|
|
|
|
assert_empty
|
|
|
|
|
];
|
|
|
|
|
"if1",
|
|
|
|
|
[
|
|
|
|
|
var_assign_var "b" "a";
|
|
|
|
|
var_assign_var "c" "b";
|
|
|
|
|
var_assign_id "b" "a";
|
|
|
|
|
var_assign_id "c" "d";
|
|
|
|
|
If (unknown_exp,
|
|
|
|
|
[invariant "{ &b -> &a, &c -> &b }";
|
|
|
|
|
var_assign_var "c" "d"],
|
|
|
|
|
[invariant "{ &b -> &a, &c -> &b }"]
|
|
|
|
|
[invariant "{ &b -> a$0, &c -> d$0 }";
|
|
|
|
|
var_assign_id "c" "e";
|
|
|
|
|
invariant "{ &b -> a$0, &c -> e$0 }";
|
|
|
|
|
],
|
|
|
|
|
[invariant "{ &b -> a$0, &c -> d$0 }"]
|
|
|
|
|
);
|
|
|
|
|
invariant "{ &b -> &a }"
|
|
|
|
|
invariant "{ &b -> a$0 }"
|
|
|
|
|
];
|
|
|
|
|
"if2",
|
|
|
|
|
[
|
|
|
|
|
If (unknown_exp,
|
|
|
|
|
[var_assign_var "a" "b"],
|
|
|
|
|
[var_assign_var "a" "b"]
|
|
|
|
|
[var_assign_id "a" "b"],
|
|
|
|
|
[var_assign_id "a" "b"]
|
|
|
|
|
);
|
|
|
|
|
invariant "{ &a -> &b }"
|
|
|
|
|
invariant "{ &a -> b$0 }"
|
|
|
|
|
];
|
|
|
|
|
"if3",
|
|
|
|
|
[
|
|
|
|
|
If (unknown_exp,
|
|
|
|
|
[var_assign_var "a" "b"],
|
|
|
|
|
[var_assign_var "a" "c"]
|
|
|
|
|
[var_assign_id "a" "b"],
|
|
|
|
|
[var_assign_id "a" "c"]
|
|
|
|
|
);
|
|
|
|
|
assert_empty
|
|
|
|
|
];
|
|
|
|
|
"nested_if",
|
|
|
|
|
[
|
|
|
|
|
var_assign_var "b" "a";
|
|
|
|
|
var_assign_var "c" "b";
|
|
|
|
|
var_assign_id "b" "a";
|
|
|
|
|
var_assign_id "c" "b";
|
|
|
|
|
If (unknown_exp,
|
|
|
|
|
[If (var_of_str "unknown2",
|
|
|
|
|
[ invariant "{ &b -> &a, &c -> &b }";
|
|
|
|
|
var_assign_var "a" "b";
|
|
|
|
|
invariant "{ &a -> &b, &c -> &b }"],
|
|
|
|
|
[ invariant "{ &b -> a$0, &c -> b$0 }";
|
|
|
|
|
var_assign_id "b" "d";
|
|
|
|
|
invariant "{ &b -> d$0, &c -> b$0 }"],
|
|
|
|
|
[]
|
|
|
|
|
)
|
|
|
|
|
],
|
|
|
|
|
[]
|
|
|
|
|
);
|
|
|
|
|
invariant "{ &c -> &b }"
|
|
|
|
|
invariant "{ &c -> b$0 }"
|
|
|
|
|
];
|
|
|
|
|
"loop_as_if",
|
|
|
|
|
[
|
|
|
|
|
var_assign_var "b" "a";
|
|
|
|
|
var_assign_id "b" "a";
|
|
|
|
|
While (unknown_exp,
|
|
|
|
|
[var_assign_var "a" "b"]
|
|
|
|
|
[var_assign_id "b" "c"]
|
|
|
|
|
);
|
|
|
|
|
assert_empty
|
|
|
|
|
];
|
|
|
|
|
"easy_loop_invariant",
|
|
|
|
|
[
|
|
|
|
|
var_assign_var "b" "a";
|
|
|
|
|
var_assign_id "b" "a";
|
|
|
|
|
While (unknown_exp,
|
|
|
|
|
[var_assign_var "c" "b";
|
|
|
|
|
invariant "{ &b -> &a, &c -> &b }"]
|
|
|
|
|
[var_assign_id "c" "d";
|
|
|
|
|
invariant "{ &b -> a$0, &c -> d$0 }"]
|
|
|
|
|
);
|
|
|
|
|
invariant "{ &b -> &a }"
|
|
|
|
|
invariant "{ &b -> a$0 }"
|
|
|
|
|
];
|
|
|
|
|
"empty_loop",
|
|
|
|
|
[
|
|
|
|
|
var_assign_var "b" "a";
|
|
|
|
|
var_assign_id "b" "a";
|
|
|
|
|
While (unknown_exp, []);
|
|
|
|
|
var_assign_var "c" "b";
|
|
|
|
|
invariant "{ &b -> &a, &c -> &b }"
|
|
|
|
|
var_assign_id "c" "b";
|
|
|
|
|
invariant "{ &b -> a$0, &c -> b$0 }"
|
|
|
|
|
];
|
|
|
|
|
] |> TestInterpreter.create_tests ProcData.empty_extras in
|
|
|
|
|
"copy_propagation_test_suite">:::test_list
|
|
|
|
|