diff options
author | Stavros Aronis <[email protected]> | 2012-01-23 16:40:42 +0100 |
---|---|---|
committer | Stavros Aronis <[email protected]> | 2012-02-22 14:13:19 +0100 |
commit | 7a99d71dd3f003bc6179bb69569ece27b38b57eb (patch) | |
tree | 79d680efdc73535e7f4d67c49bec0d1c64c7bcf8 /lib/dialyzer | |
parent | 4ca72667f3e655d175c7587b8998aa7d22f50985 (diff) | |
download | otp-7a99d71dd3f003bc6179bb69569ece27b38b57eb.tar.gz otp-7a99d71dd3f003bc6179bb69569ece27b38b57eb.tar.bz2 otp-7a99d71dd3f003bc6179bb69569ece27b38b57eb.zip |
Cleanups in dialyzer_callgraph and dialyzer_dataflow
Refactorings, code movements and reflection of mutable variables in the code.
Diffstat (limited to 'lib/dialyzer')
-rw-r--r-- | lib/dialyzer/src/dialyzer_callgraph.erl | 42 | ||||
-rw-r--r-- | lib/dialyzer/src/dialyzer_dataflow.erl | 6 |
2 files changed, 24 insertions, 24 deletions
diff --git a/lib/dialyzer/src/dialyzer_callgraph.erl b/lib/dialyzer/src/dialyzer_callgraph.erl index d3de5aaf45..e3308263e4 100644 --- a/lib/dialyzer/src/dialyzer_callgraph.erl +++ b/lib/dialyzer/src/dialyzer_callgraph.erl @@ -177,14 +177,14 @@ is_escaping(Label, #callgraph{esc = Esc}) when is_integer(Label) -> add_edges([], CG) -> CG; -add_edges(Edges, #callgraph{digraph = Callgraph} = CG) -> - CG#callgraph{digraph = digraph_add_edges(Edges, Callgraph)}. +add_edges(Edges, #callgraph{digraph = Digraph} = CG) -> + CG#callgraph{digraph = digraph_add_edges(Edges, Digraph)}. -spec add_edges([callgraph_edge()], [mfa_or_funlbl()], callgraph()) -> callgraph(). add_edges(Edges, MFAs, #callgraph{digraph = DG} = CG) -> - DG1 = digraph_confirm_vertices(MFAs, DG), - add_edges(Edges, CG#callgraph{digraph = DG1}). + DG = digraph_confirm_vertices(MFAs, DG), + add_edges(Edges, CG). -spec take_scc(callgraph()) -> 'none' | {'ok', scc(), callgraph()}. @@ -196,8 +196,8 @@ take_scc(#callgraph{postorder = []}) -> -spec remove_external(callgraph()) -> {callgraph(), [tuple()]}. remove_external(#callgraph{digraph = DG} = CG) -> - {NewDG, External} = digraph_remove_external(DG), - {CG#callgraph{digraph = NewDG}, External}. + {DG, External} = digraph_remove_external(DG), + {CG, External}. -spec non_local_calls(callgraph()) -> mfa_calls(). @@ -241,30 +241,30 @@ modules(#callgraph{digraph = DG}) -> -spec module_postorder(callgraph()) -> [[module()]]. module_postorder(#callgraph{digraph = DG}) -> + {MDG, _Nodes} = get_module_digraph_and_nodes(DG), + MDG1 = digraph_utils:condensation(MDG), + PostOrder = digraph_utils:postorder(MDG1), + PostOrder1 = sort_sccs_internally(PostOrder, MDG), + digraph:delete(MDG1), + digraph_delete(MDG), + PostOrder1. + +get_module_digraph_and_nodes(DG) -> Edges = digraph_edges(DG), Nodes = ordsets:from_list([M || {M,_F,_A} <- digraph_vertices(DG)]), MDG = digraph:new(), - MDG1 = digraph_confirm_vertices(Nodes, MDG), - MDG2 = create_module_digraph(Edges, MDG1), - MDG3 = digraph_utils:condensation(MDG2), - PostOrder = digraph_utils:postorder(MDG3), - PostOrder1 = sort_sccs_internally(PostOrder, MDG2), - digraph:delete(MDG2), - digraph_delete(MDG3), - PostOrder1. + MDG = digraph_confirm_vertices(Nodes, MDG), + MDG = create_module_digraph(Edges, MDG), + {MDG, Nodes}. %% The module deps of a module are modules that depend on the module -spec module_deps(callgraph()) -> dict(). module_deps(#callgraph{digraph = DG}) -> - Edges = digraph_edges(DG), - Nodes = ordsets:from_list([M || {M,_F,_A} <- digraph_vertices(DG)]), - MDG = digraph:new(), - MDG1 = digraph_confirm_vertices(Nodes, MDG), - MDG2 = create_module_digraph(Edges, MDG1), - Deps = [{N, ordsets:from_list(digraph:in_neighbours(MDG2, N))} + {MDG, Nodes} = get_module_digraph_and_nodes(DG), + Deps = [{N, ordsets:from_list(digraph:in_neighbours(MDG, N))} || N <- Nodes], - digraph_delete(MDG2), + digraph_delete(MDG), dict:from_list(Deps). -spec strip_module_deps(dict(), set()) -> dict(). diff --git a/lib/dialyzer/src/dialyzer_dataflow.erl b/lib/dialyzer/src/dialyzer_dataflow.erl index 887b2dd049..aba13278ff 100644 --- a/lib/dialyzer/src/dialyzer_dataflow.erl +++ b/lib/dialyzer/src/dialyzer_dataflow.erl @@ -272,6 +272,7 @@ analyze_module(Tree, Plt, Callgraph, Records, GetWarnings) -> debug_pp(Tree, false), Module = cerl:atom_val(cerl:module_name(Tree)), RaceDetection = dialyzer_callgraph:get_race_detection(Callgraph), + RaceCode = dialyzer_callgraph:get_race_code(Callgraph), BehaviourTranslations = case RaceDetection of true -> dialyzer_behaviours:translatable_behaviours(Tree); @@ -282,9 +283,6 @@ analyze_module(Tree, Plt, Callgraph, Records, GetWarnings) -> TopFun, Plt, Module, Records, BehaviourTranslations), State1 = state__race_analysis(not GetWarnings, State), State2 = analyze_loop(State1), - RaceCode = dialyzer_callgraph:get_race_code(Callgraph), - Callgraph1 = State2#state.callgraph, - RaceCode1 = dialyzer_callgraph:get_race_code(Callgraph1), case GetWarnings of true -> State3 = state__set_warning_mode(State2), @@ -309,6 +307,8 @@ analyze_module(Tree, Plt, Callgraph, Records, GetWarnings) -> St#state{callgraph = Callgraph3} end; false -> + Callgraph1 = State2#state.callgraph, + RaceCode1 = dialyzer_callgraph:get_race_code(Callgraph1), state__restore_race_code( dict:merge(fun (_K, V1, _V2) -> V1 end, RaceCode, RaceCode1), State2) |