aboutsummaryrefslogtreecommitdiffstats
path: root/lib/dialyzer/src/dialyzer_succ_typings.erl
diff options
context:
space:
mode:
authorStavros Aronis <[email protected]>2011-02-22 02:41:06 +0200
committerNiclas Axelsson <[email protected]>2011-03-11 12:03:53 +0100
commit8342fcf5395133a19d647f2ace606af9b7fc1732 (patch)
tree36577d4747e8f8d1e7401409e7e7e293d74f895c /lib/dialyzer/src/dialyzer_succ_typings.erl
parent31ffea630ffd73d39970c3def796b00dd782373d (diff)
downloadotp-8342fcf5395133a19d647f2ace606af9b7fc1732.tar.gz
otp-8342fcf5395133a19d647f2ace606af9b7fc1732.tar.bz2
otp-8342fcf5395133a19d647f2ace606af9b7fc1732.zip
Better blame assignment when a spec is erroneous
Applies to the specification of the return value of a function.
Diffstat (limited to 'lib/dialyzer/src/dialyzer_succ_typings.erl')
-rw-r--r--lib/dialyzer/src/dialyzer_succ_typings.erl26
1 files changed, 24 insertions, 2 deletions
diff --git a/lib/dialyzer/src/dialyzer_succ_typings.erl b/lib/dialyzer/src/dialyzer_succ_typings.erl
index 8bfc66fc39..daf68d24f0 100644
--- a/lib/dialyzer/src/dialyzer_succ_typings.erl
+++ b/lib/dialyzer/src/dialyzer_succ_typings.erl
@@ -131,8 +131,9 @@ get_warnings_from_modules([M|Ms], State, DocPlt,
%% Check if there are contracts for functions that do not exist
Warnings1 =
dialyzer_contracts:contracts_without_fun(Contracts, AllFuns, Callgraph),
- {Warnings2, FunTypes, RaceCode, PublicTables, NamedTables} =
+ {RawWarnings2, FunTypes, RaceCode, PublicTables, NamedTables} =
dialyzer_dataflow:get_warnings(ModCode, Plt, Callgraph, Records, NoWarnUnused),
+ {NewAcc, Warnings2} = postprocess_dataflow_warns(RawWarnings2, State, Acc),
Attrs = cerl:module_attrs(ModCode),
Warnings3 = if BehavioursChk ->
dialyzer_behaviours:check_callbacks(M, Attrs,
@@ -145,10 +146,31 @@ get_warnings_from_modules([M|Ms], State, DocPlt,
NamedTables),
State1 = st__renew_state_calls(NewCallgraph, State),
get_warnings_from_modules(Ms, State1, NewDocPlt, BehavioursChk,
- [Warnings1, Warnings2, Warnings3|Acc]);
+ [Warnings1, Warnings2, Warnings3|NewAcc]);
get_warnings_from_modules([], #st{plt = Plt}, DocPlt, _, Acc) ->
{lists:flatten(Acc), Plt, DocPlt}.
+postprocess_dataflow_warns(RawWarnings, State, WarnAcc) ->
+ postprocess_dataflow_warns(RawWarnings, State, WarnAcc, []).
+
+postprocess_dataflow_warns([], _State, WAcc, Acc) ->
+ {WAcc, lists:reverse(Acc)};
+postprocess_dataflow_warns([{?WARN_CONTRACT_RANGE, {File, CallL}, Msg}|Rest],
+ #st{codeserver = Codeserver} = State, WAcc, Acc) ->
+ {contract_range, [Contract, M, F, A, ArgStrings, CRet]} = Msg,
+ {ok, {{File, _ContrL} = FileLine, _C}} =
+ dialyzer_codeserver:lookup_mfa_contract({M,F,A}, Codeserver),
+ NewMsg =
+ {contract_range, [Contract, M, F, ArgStrings, CallL, CRet]},
+ W = {?WARN_CONTRACT_RANGE, FileLine, NewMsg},
+ Filter =
+ fun({?WARN_CONTRACT_TYPES, FL, _}) when FL =:= FileLine -> false;
+ (_) -> true
+ end,
+ postprocess_dataflow_warns(Rest, State, lists:filter(Filter, WAcc), [W|Acc]);
+postprocess_dataflow_warns([W|Rest], State, Wacc, Acc) ->
+ postprocess_dataflow_warns(Rest, State, Wacc, [W|Acc]).
+
refine_succ_typings(ModulePostorder, State) ->
?debug("Module postorder: ~p\n", [ModulePostorder]),
refine_succ_typings(ModulePostorder, State, []).