diff options
Diffstat (limited to 'lib/dialyzer/src/dialyzer_races.erl')
-rw-r--r-- | lib/dialyzer/src/dialyzer_races.erl | 40 |
1 files changed, 26 insertions, 14 deletions
diff --git a/lib/dialyzer/src/dialyzer_races.erl b/lib/dialyzer/src/dialyzer_races.erl index ee9d5e88a3..2aa8343bce 100644 --- a/lib/dialyzer/src/dialyzer_races.erl +++ b/lib/dialyzer/src/dialyzer_races.erl @@ -2,7 +2,7 @@ %%----------------------------------------------------------------------- %% %CopyrightBegin% %% -%% Copyright Ericsson AB 2008-2010. All Rights Reserved. +%% Copyright Ericsson AB 2008-2012. All Rights Reserved. %% %% The contents of this file are subject to the Erlang Public License, %% Version 1.1, (the "License"); you may not use this file except in @@ -36,10 +36,11 @@ -export([beg_clause_new/3, cleanup/1, end_case_new/1, end_clause_new/3, get_curr_fun/1, get_curr_fun_args/1, get_new_table/1, get_race_analysis/1, get_race_list/1, get_race_list_size/1, + get_race_list_and_size/1, let_tag_new/2, new/0, put_curr_fun/3, put_fun_args/2, put_race_analysis/2, put_race_list/3]). --export_type([races/0, mfa_or_funlbl/0, core_vars/0]). +-export_type([races/0, core_vars/0]). -include("dialyzer.hrl"). @@ -66,8 +67,6 @@ %%% %%% =========================================================================== --type mfa_or_funlbl() :: label() | mfa(). - -type label_type() :: label() | [label()] | {label()} | ?no_label. -type args() :: [label_type() | [string()]]. -type core_vars() :: cerl:cerl() | ?no_arg | ?bypassed. @@ -94,7 +93,7 @@ guard :: cerl:cerl()}). -record(end_case, {clauses :: [#end_clause{}]}). -record(curr_fun, {status :: 'in' | 'out', - mfa :: mfa_or_funlbl(), + mfa :: dialyzer_callgraph:mfa_or_funlbl(), label :: label(), def_vars :: [core_vars()], arg_types :: [erl_types:erl_type()], @@ -107,8 +106,8 @@ state :: _, %% XXX: recursive file_line :: file_line(), var_map :: dict()}). --record(fun_call, {caller :: mfa_or_funlbl(), - callee :: mfa_or_funlbl(), +-record(fun_call, {caller :: dialyzer_callgraph:mfa_or_funlbl(), + callee :: dialyzer_callgraph:mfa_or_funlbl(), arg_types :: [erl_types:erl_type()], vars :: [core_vars()]}). -record(let_tag, {var :: var_to_map1(), @@ -130,10 +129,10 @@ vars :: [core_vars()], file_line :: file_line(), index :: non_neg_integer(), - fun_mfa :: mfa_or_funlbl(), + fun_mfa :: dialyzer_callgraph:mfa_or_funlbl(), fun_label :: label()}). --record(races, {curr_fun :: mfa_or_funlbl(), +-record(races, {curr_fun :: dialyzer_callgraph:mfa_or_funlbl(), curr_fun_label :: label(), curr_fun_args = 'empty' :: core_args(), new_table = 'no_t' :: table(), @@ -158,7 +157,8 @@ %%% %%% =========================================================================== --spec store_race_call(mfa_or_funlbl(), [erl_types:erl_type()], [core_vars()], +-spec store_race_call(dialyzer_callgraph:mfa_or_funlbl(), + [erl_types:erl_type()], [core_vars()], file_line(), dialyzer_dataflow:state()) -> dialyzer_dataflow:state(). @@ -347,6 +347,7 @@ fixup_race_list(RaceWarnTag, WarnVarArgs, State) -> DepList2 = fixup_race_list_helper(NewParents, Calls, CurrFun, WarnVarArgs, RaceWarnTag, NewState), + dialyzer_dataflow:dispose_state(CleanState), lists:usort(cleanup_dep_calls(DepList1 ++ DepList2)). fixup_race_list_helper(Parents, Calls, CurrFun, WarnVarArgs, RaceWarnTag, @@ -381,13 +382,15 @@ fixup_race_forward_pullout(CurrFun, CurrFunLabel, Calls, Code, RaceList, InitFun, WarnVarArgs, RaceWarnTag, RaceVarMap, FunDefVars, FunCallVars, FunArgTypes, NestingLevel, State) -> + TState = dialyzer_dataflow:state__duplicate(State), {DepList, NewCurrFun, NewCurrFunLabel, NewCalls, NewCode, NewRaceList, NewRaceVarMap, NewFunDefVars, NewFunCallVars, NewFunArgTypes, NewNestingLevel} = fixup_race_forward(CurrFun, CurrFunLabel, Calls, Code, RaceList, InitFun, WarnVarArgs, RaceWarnTag, RaceVarMap, FunDefVars, FunCallVars, FunArgTypes, NestingLevel, - cleanup_race_code(State)), + cleanup_race_code(TState)), + dialyzer_dataflow:dispose_state(TState), case NewCode of [] -> DepList; [#fun_call{caller = NewCurrFun, callee = Call, arg_types = FunTypes, @@ -1755,7 +1758,10 @@ compare_var_list(Var, VarList, RaceVarMap) -> ets_list_args(MaybeList) -> case is_list(MaybeList) of - true -> [ets_tuple_args(T) || T <- MaybeList]; + true -> + try [ets_tuple_args(T) || T <- MaybeList] + catch _:_ -> [?no_label] + end; false -> [ets_tuple_args(MaybeList)] end. @@ -2405,7 +2411,7 @@ end_case_new(Clauses) -> end_clause_new(Arg, Pats, Guard) -> #end_clause{arg = Arg, pats = Pats, guard = Guard}. --spec get_curr_fun(races()) -> mfa_or_funlbl(). +-spec get_curr_fun(races()) -> dialyzer_callgraph:mfa_or_funlbl(). get_curr_fun(#races{curr_fun = CurrFun}) -> CurrFun. @@ -2435,6 +2441,12 @@ get_race_list(#races{race_list = RaceList}) -> get_race_list_size(#races{race_list_size = RaceListSize}) -> RaceListSize. +-spec get_race_list_and_size(races()) -> {code(), non_neg_integer()}. + +get_race_list_and_size(#races{race_list = RaceList, + race_list_size = RaceListSize}) -> + {RaceList, RaceListSize}. + -spec let_tag_new(var_to_map1(), var_to_map1()) -> #let_tag{}. let_tag_new(Var, Arg) -> @@ -2444,7 +2456,7 @@ let_tag_new(Var, Arg) -> new() -> #races{}. --spec put_curr_fun(mfa_or_funlbl(), label(), races()) -> +-spec put_curr_fun(dialyzer_callgraph:mfa_or_funlbl(), label(), races()) -> races(). put_curr_fun(CurrFun, CurrFunLabel, Races) -> |