[liveness] fix bug in usage of OneInstrPerNode CFG

Reviewed By: mbouaziz, jvillard

Differential Revision: D5468487

fbshipit-source-id: 7ab6f9a
master
Sam Blackshear 8 years ago committed by Facebook Github Bot
parent ecf9c1b402
commit 853d476f13

@ -77,11 +77,17 @@ let checker {Callbacks.tenv; summary; proc_desc} : Specs.summary =
| _
-> ()
in
List.iter (CFG.nodes cfg) ~f:(fun node ->
(* note: extract_pre grabs the post, since the analysis is backward *)
match Analyzer.extract_pre (CFG.id node) invariant_map with
| Some live_vars
-> List.iter ~f:(report_dead_store live_vars) (CFG.instrs node)
| None
-> () ) ;
let report_on_node node =
List.iter (CFG.instr_ids node) ~f:(fun (instr, node_id_opt) ->
match node_id_opt with
| Some node_id -> (
match Analyzer.extract_pre node_id invariant_map with
| Some live_vars
-> report_dead_store live_vars instr
| None
-> () )
| None
-> () )
in
List.iter (CFG.nodes cfg) ~f:report_on_node ;
summary

@ -31,6 +31,21 @@ void dead_pointer_bad() {
int* x = #
}
void plus_plus1_bad() {
int i = 0;
++i;
}
void plus_plus2_bad() {
int i = 0;
i++;
}
int plus_plus3_bad() {
int i = 0;
return i++;
}
int return_ok() {
int x = 5;
return x;
@ -85,6 +100,19 @@ int* assign_pointer2_ok() {
void by_ref_ok(int& ref) { ref = 7; }
int plus_plus_ok() {
int x = 0;
return ++x;
}
int plus_plus_loop_ok(int n) {
int i;
for (i = 0; i < n; i++) {
i++;
}
return i;
}
char* global;
void FP_assign_array_tricky_ok() {

@ -2,5 +2,8 @@ codetoanalyze/cpp/liveness/dead_stores.cpp, dead_stores::FP_assign_array_tricky_
codetoanalyze/cpp/liveness/dead_stores.cpp, dead_stores::dead_pointer_bad, 2, DEAD_STORE, [Write of unused value]
codetoanalyze/cpp/liveness/dead_stores.cpp, dead_stores::dead_then_live_bad, 1, DEAD_STORE, [Write of unused value]
codetoanalyze/cpp/liveness/dead_stores.cpp, dead_stores::easy_bad, 0, DEAD_STORE, [Write of unused value]
codetoanalyze/cpp/liveness/dead_stores.cpp, dead_stores::plus_plus1_bad, 2, DEAD_STORE, [Write of unused value]
codetoanalyze/cpp/liveness/dead_stores.cpp, dead_stores::plus_plus2_bad, 2, DEAD_STORE, [Write of unused value]
codetoanalyze/cpp/liveness/dead_stores.cpp, dead_stores::plus_plus3_bad, 2, DEAD_STORE, [Write of unused value]
codetoanalyze/cpp/liveness/dead_stores.cpp, dead_stores::reassign_param_bad, 0, DEAD_STORE, [Write of unused value]
codetoanalyze/cpp/liveness/dead_stores.cpp, dead_stores::use_then_dead_bad, 3, DEAD_STORE, [Write of unused value]

Loading…
Cancel
Save