aboutsummaryrefslogtreecommitdiffstats
path: root/lib/dialyzer
diff options
context:
space:
mode:
authorStavros Aronis <[email protected]>2012-02-20 21:29:22 +0100
committerHenrik Nord <[email protected]>2012-05-21 15:31:19 +0200
commitcf573e2ea378bae4c43007fb457dcd8379caf547 (patch)
treebe54501e4fa67462f768aaae618d13fc8523bc0c /lib/dialyzer
parenta6ab15d61cd4b36ba9d4eab7a3d290330b5c3798 (diff)
downloadotp-cf573e2ea378bae4c43007fb457dcd8379caf547.tar.gz
otp-cf573e2ea378bae4c43007fb457dcd8379caf547.tar.bz2
otp-cf573e2ea378bae4c43007fb457dcd8379caf547.zip
Simplify behaviour checking code
Diffstat (limited to 'lib/dialyzer')
-rw-r--r--lib/dialyzer/src/dialyzer_behaviours.erl19
-rw-r--r--lib/dialyzer/src/dialyzer_coordinator.erl14
-rw-r--r--lib/dialyzer/src/dialyzer_succ_typings.erl3
3 files changed, 18 insertions, 18 deletions
diff --git a/lib/dialyzer/src/dialyzer_behaviours.erl b/lib/dialyzer/src/dialyzer_behaviours.erl
index f86cc3d3d6..d40caae8b4 100644
--- a/lib/dialyzer/src/dialyzer_behaviours.erl
+++ b/lib/dialyzer/src/dialyzer_behaviours.erl
@@ -30,7 +30,7 @@
-module(dialyzer_behaviours).
--export([check_callbacks/4, get_behaviour_apis/1,
+-export([check_callbacks/5, get_behaviour_apis/1,
translate_behaviour_api_call/5, translatable_behaviours/1,
translate_callgraph/3]).
@@ -47,15 +47,16 @@
-record(state, {plt :: dialyzer_plt:plt(),
codeserver :: dialyzer_codeserver:codeserver(),
filename :: file:filename(),
- behlines :: [{behaviour(), non_neg_integer()}]}).
+ behlines :: [{behaviour(), non_neg_integer()}],
+ records :: dict()}).
%%--------------------------------------------------------------------
--spec check_callbacks(module(), [{cerl:cerl(), cerl:cerl()}],
+-spec check_callbacks(module(), [{cerl:cerl(), cerl:cerl()}], dict(),
dialyzer_plt:plt(),
dialyzer_codeserver:codeserver()) -> [dial_warning()].
-check_callbacks(Module, Attrs, Plt, Codeserver) ->
+check_callbacks(Module, Attrs, Records, Plt, Codeserver) ->
{Behaviours, BehLines} = get_behaviours(Attrs),
case Behaviours of
[] -> [];
@@ -64,7 +65,7 @@ check_callbacks(Module, Attrs, Plt, Codeserver) ->
{_Var,Code} = dialyzer_codeserver:lookup_mfa_code(MFA, Codeserver),
File = get_file(cerl:get_ann(Code)),
State = #state{plt = Plt, filename = File, behlines = BehLines,
- codeserver = Codeserver},
+ codeserver = Codeserver, records = Records},
Warnings = get_warnings(Module, Behaviours, State),
[add_tag_file_line(Module, W, State) || W <- Warnings]
end.
@@ -100,17 +101,13 @@ check_behaviour(Module, Behaviour, #state{plt = Plt} = State, Acc) ->
check_all_callbacks(_Module, _Behaviour, [], _State, Acc) ->
Acc;
check_all_callbacks(Module, Behaviour, [Cb|Rest],
- #state{plt = Plt, codeserver = Codeserver} = State, Acc) ->
+ #state{plt = Plt, codeserver = Codeserver,
+ records = Records} = State, Acc) ->
{{Behaviour, Function, Arity},
{{_BehFile, _BehLine}, Callback}} = Cb,
CbMFA = {Module, Function, Arity},
CbReturnType = dialyzer_contracts:get_contract_return(Callback),
CbArgTypes = dialyzer_contracts:get_contract_args(Callback),
- Records =
- case dict:find(Module, dialyzer_codeserver:get_records(Codeserver)) of
- {ok, V} -> V;
- error -> dict:new()
- end,
Acc0 = Acc,
Acc1 =
case dialyzer_plt:lookup(Plt, CbMFA) of
diff --git a/lib/dialyzer/src/dialyzer_coordinator.erl b/lib/dialyzer/src/dialyzer_coordinator.erl
index 93159ce7df..437af69f5a 100644
--- a/lib/dialyzer/src/dialyzer_coordinator.erl
+++ b/lib/dialyzer/src/dialyzer_coordinator.erl
@@ -220,18 +220,20 @@ handle_cast({done, Job, NewData},
#state{mode = Mode,
spawn_count = SpawnCount,
all_spawned = AllSpawned,
- result = OldResult
+ result = OldResult,
+ job_to_pid = JobToPID
} = State) ->
- NewResult =
+ {NewResult, NewJobToPID} =
case Mode of
X when X =:= 'typesig'; X =:= 'dataflow' ->
- ordsets:union(OldResult, NewData);
+ {ordsets:union(OldResult, NewData), dict:erase(Job, JobToPID)};
'compile' ->
- dialyzer_analysis_callgraph:add_to_result(Job, NewData, OldResult);
+ {dialyzer_analysis_callgraph:add_to_result(Job, NewData, OldResult),
+ JobToPID};
'warnings' ->
- NewData ++ OldResult
+ {NewData ++ OldResult, dict:erase(Job, JobToPID)}
end,
- UpdatedState = State#state{result = NewResult},
+ UpdatedState = State#state{result = NewResult, job_to_pid = NewJobToPID},
Action =
case AllSpawned of
false -> reduce;
diff --git a/lib/dialyzer/src/dialyzer_succ_typings.erl b/lib/dialyzer/src/dialyzer_succ_typings.erl
index c1c437f9a4..9a37a54206 100644
--- a/lib/dialyzer/src/dialyzer_succ_typings.erl
+++ b/lib/dialyzer/src/dialyzer_succ_typings.erl
@@ -171,7 +171,8 @@ collect_warnings(M, {Callgraph, Codeserver, NoWarnUnused, Plt, DocPlt}) ->
dialyzer_dataflow:get_warnings(ModCode, Plt, Callgraph,
Records, NoWarnUnused),
Attrs = cerl:module_attrs(ModCode),
- Warnings3 = dialyzer_behaviours:check_callbacks(M, Attrs, Plt, Codeserver),
+ Warnings3 =
+ dialyzer_behaviours:check_callbacks(M, Attrs, Records, Plt, Codeserver),
DocPlt = insert_into_doc_plt(FunTypes, Callgraph, DocPlt),
lists:flatten([Warnings1, Warnings2, Warnings3]).