diff options
author | Hans Bolinder <[email protected]> | 2017-01-19 09:40:11 +0100 |
---|---|---|
committer | Hans Bolinder <[email protected]> | 2017-02-03 08:58:00 +0100 |
commit | a669fdb4bc19c508c8c5edbefa1c81ee647b3362 (patch) | |
tree | 3051ce1efb1f74331a0cadc67c434e76d892ccf5 /lib | |
parent | 2c577356c419b9420cae91a74d4b1602d584275a (diff) | |
download | otp-a669fdb4bc19c508c8c5edbefa1c81ee647b3362.tar.gz otp-a669fdb4bc19c508c8c5edbefa1c81ee647b3362.tar.bz2 otp-a669fdb4bc19c508c8c5edbefa1c81ee647b3362.zip |
dialyzer: Check return value of digrahp:add_edge()
Diffstat (limited to 'lib')
-rw-r--r-- | lib/dialyzer/src/dialyzer_callgraph.erl | 18 |
1 files changed, 15 insertions, 3 deletions
diff --git a/lib/dialyzer/src/dialyzer_callgraph.erl b/lib/dialyzer/src/dialyzer_callgraph.erl index 68f3d7a240..8f6a3b99b3 100644 --- a/lib/dialyzer/src/dialyzer_callgraph.erl +++ b/lib/dialyzer/src/dialyzer_callgraph.erl @@ -285,7 +285,7 @@ module_postorder(#callgraph{digraph = DG}) -> Nodes = sets:from_list([M || {M,_F,_A} <- digraph_vertices(DG)]), MDG = digraph:new([acyclic]), digraph_confirm_vertices(sets:to_list(Nodes), MDG), - Foreach = fun({M1,M2}) -> digraph:add_edge(MDG, M1, M2) end, + Foreach = fun({M1,M2}) -> _ = digraph:add_edge(MDG, M1, M2) end, lists:foreach(Foreach, sets:to_list(Edges)), {digraph_utils:topsort(MDG), {'d', MDG}}. @@ -305,7 +305,7 @@ module_deps(#callgraph{digraph = DG}) -> Nodes = sets:from_list([M || {M,_F,_A} <- digraph_vertices(DG)]), MDG = digraph:new(), digraph_confirm_vertices(sets:to_list(Nodes), MDG), - Foreach = fun({M1,M2}) -> digraph:add_edge(MDG, M1, M2) end, + Foreach = fun({M1,M2}) -> check_add_edge(MDG, M1, M2) end, lists:foreach(Foreach, sets:to_list(Edges)), Deps = [{N, ordsets:from_list(digraph:in_neighbours(MDG, N))} || N <- sets:to_list(Nodes)], @@ -552,9 +552,21 @@ digraph_add_edge(From, To, DG) -> false -> digraph:add_vertex(DG, To); {To, _} -> ok end, - digraph:add_edge(DG, {From, To}, From, To, []), + check_add_edge(DG, {From, To}, From, To, []), ok. +check_add_edge(G, V1, V2) -> + case digraph:add_edge(G, V1, V2) of + {error, Error} -> exit({add_edge, V1, V2, Error}); + _Edge -> ok + end. + +check_add_edge(G, E, V1, V2, L) -> + case digraph:add_edge(G, E, V1, V2, L) of + {error, Error} -> exit({add_edge, E, V1, V2, L, Error}); + _Edge -> ok + end. + digraph_confirm_vertices([MFA|Left], DG) -> digraph:add_vertex(DG, MFA, confirmed), digraph_confirm_vertices(Left, DG); |