[cfg] Allow between-join-exit nodes in cfg

Reviewed By: dulmarod

Differential Revision: D7829904

fbshipit-source-id: 18df121
master
Daiva Naudziuniene 7 years ago committed by Facebook Github Bot
parent 68129abab8
commit f57e62f205

@ -57,6 +57,13 @@ let is_proc_cfg_connected proc_desc =
let is_exit_node n =
match Procdesc.Node.get_kind n with Procdesc.Node.Exit_node _ -> true | _ -> false
in
let is_between_join_and_exit_node n =
match Procdesc.Node.get_kind n with
| Procdesc.Node.Stmt_node "between_join_and_exit" -> (
match Procdesc.Node.get_succs n with [n'] when is_exit_node n' -> true | _ -> false )
| _ ->
false
in
let is_broken_node n =
let succs = Procdesc.Node.get_succs n in
let preds = Procdesc.Node.get_preds n in
@ -69,9 +76,13 @@ let is_proc_cfg_connected proc_desc =
Int.equal (List.length succs) 0 || Int.equal (List.length preds) 0
| Procdesc.Node.Join_node ->
(* Join node has the exception that it may be without predecessors
and pointing to an exit node *)
(* if the if brances end with a return *)
match succs with [n'] when is_exit_node n' -> false | _ -> Int.equal (List.length preds) 0
and pointing to between_join_and_exit which points to an exit node *)
(* this happens when the if branches end with a return *)
match succs with
| [n'] when is_between_join_and_exit_node n' ->
false
| _ ->
Int.equal (List.length preds) 0
in
not (List.exists ~f:is_broken_node (Procdesc.get_nodes proc_desc))

Loading…
Cancel
Save