[frontend] Do not create exceptional successors for return nodes

Summary: Exceptional successors were not meant to be created for return nodes, but they were created if try block had a single return statement.

Reviewed By: jvillard

Differential Revision: D8913371

fbshipit-source-id: 6ac85b21d
master
Daiva Naudziuniene 6 years ago committed by Facebook Github Bot
parent c53f35fcf2
commit 84cfd0a450

@ -1909,8 +1909,14 @@ module CTrans_funct (F : CModule_type.CFrontend) : CModule_type.CTranslation = s
try_control.root_nodes try_control.root_nodes
else try_control.leaf_nodes else try_control.leaf_nodes
in in
(* do not add exceptional successors to return nodes *)
List.iter List.iter
~f:(fun try_end -> Procdesc.set_succs_exn_only try_end catch_start_nodes) ~f:(fun try_end ->
match Procdesc.Node.get_kind try_end with
| Procdesc.Node.Stmt_node "Return Stmt" ->
()
| _ ->
Procdesc.set_succs_exn_only try_end catch_start_nodes )
try_ends ; try_ends ;
try_trans_result try_trans_result
| _ -> | _ ->

@ -388,7 +388,7 @@ class Exceptions {
return 0; return 0;
} }
int FN_unreachable_catch_bad() { int unreachable_catch_bad() {
int i = 1; int i = 1;
try { try {
} catch (...) { } catch (...) {

@ -1,5 +1,6 @@
codetoanalyze/cpp/liveness/dead_stores.cpp, dead_stores::Exceptions_FP_read_in_catch_tricky_ok, 1, DEAD_STORE, no_bucket, ERROR, [Write of unused value] codetoanalyze/cpp/liveness/dead_stores.cpp, dead_stores::Exceptions_FP_read_in_catch_tricky_ok, 1, DEAD_STORE, no_bucket, ERROR, [Write of unused value]
codetoanalyze/cpp/liveness/dead_stores.cpp, dead_stores::Exceptions_dead_in_catch_bad, 4, DEAD_STORE, no_bucket, ERROR, [Write of unused value] codetoanalyze/cpp/liveness/dead_stores.cpp, dead_stores::Exceptions_dead_in_catch_bad, 4, DEAD_STORE, no_bucket, ERROR, [Write of unused value]
codetoanalyze/cpp/liveness/dead_stores.cpp, dead_stores::Exceptions_unreachable_catch_bad, 1, DEAD_STORE, no_bucket, ERROR, [Write of unused value]
codetoanalyze/cpp/liveness/dead_stores.cpp, dead_stores::FP_assign_array_tricky_ok, 3, DEAD_STORE, no_bucket, ERROR, [Write of unused value] codetoanalyze/cpp/liveness/dead_stores.cpp, dead_stores::FP_assign_array_tricky_ok, 3, DEAD_STORE, no_bucket, ERROR, [Write of unused value]
codetoanalyze/cpp/liveness/dead_stores.cpp, dead_stores::capture_by_value_bad, 3, DEAD_STORE, no_bucket, ERROR, [Write of unused value] codetoanalyze/cpp/liveness/dead_stores.cpp, dead_stores::capture_by_value_bad, 3, DEAD_STORE, no_bucket, ERROR, [Write of unused value]
codetoanalyze/cpp/liveness/dead_stores.cpp, dead_stores::dead_pointer_bad, 2, DEAD_STORE, no_bucket, ERROR, [Write of unused value] codetoanalyze/cpp/liveness/dead_stores.cpp, dead_stores::dead_pointer_bad, 2, DEAD_STORE, no_bucket, ERROR, [Write of unused value]

@ -128,4 +128,17 @@ const char* return_nullptr2_ok() {
return local; return local;
} }
struct A {
~A();
};
int try_catch_return_ok() {
A a;
try {
return 1;
} catch (...) {
return 2;
}
}
} // namespace returns } // namespace returns

@ -193,7 +193,6 @@ digraph cfg {
"main.fad58de7366495db4650cfefac2fcd61_3" -> "main.fad58de7366495db4650cfefac2fcd61_2" ; "main.fad58de7366495db4650cfefac2fcd61_3" -> "main.fad58de7366495db4650cfefac2fcd61_2" ;
"main.fad58de7366495db4650cfefac2fcd61_3" -> "main.fad58de7366495db4650cfefac2fcd61_4" [color="red" ];
"main.fad58de7366495db4650cfefac2fcd61_4" [label="4: Return Stmt \n *&return:int=-1 [line 76, column 5]\n " shape="box"] "main.fad58de7366495db4650cfefac2fcd61_4" [label="4: Return Stmt \n *&return:int=-1 [line 76, column 5]\n " shape="box"]

Loading…
Cancel
Save