diff options
author | Hans Bolinder <[email protected]> | 2014-02-24 11:39:50 +0100 |
---|---|---|
committer | Hans Bolinder <[email protected]> | 2014-02-24 11:39:50 +0100 |
commit | bfbc7d65c3b2b3741c52047248e193f698287e47 (patch) | |
tree | d9564794b87fd6b78d573a47c6fd5b286fc37240 /lib/dialyzer/src/dialyzer_dep.erl | |
parent | 790e3739a14e3e77ab0282d961038714d84c0fb8 (diff) | |
parent | f4bafbfdc7183b4297b96c884a61545000eb7fbd (diff) | |
download | otp-bfbc7d65c3b2b3741c52047248e193f698287e47.tar.gz otp-bfbc7d65c3b2b3741c52047248e193f698287e47.tar.bz2 otp-bfbc7d65c3b2b3741c52047248e193f698287e47.zip |
Merge branch 'hb/dialyzer/fix_on_load/OTP-11743'
* hb/dialyzer/fix_on_load/OTP-11743:
FIx handling of 'on_load' attribute
Diffstat (limited to 'lib/dialyzer/src/dialyzer_dep.erl')
-rw-r--r-- | lib/dialyzer/src/dialyzer_dep.erl | 21 |
1 files changed, 16 insertions, 5 deletions
diff --git a/lib/dialyzer/src/dialyzer_dep.erl b/lib/dialyzer/src/dialyzer_dep.erl index 5c1245ae47..f1ac41ff04 100644 --- a/lib/dialyzer/src/dialyzer_dep.erl +++ b/lib/dialyzer/src/dialyzer_dep.erl @@ -65,7 +65,7 @@ analyze(Tree) -> %% io:format("Handling ~w\n", [cerl:atom_val(cerl:module_name(Tree))]), {_, State} = traverse(Tree, map__new(), state__new(Tree), top), Esc = state__esc(State), - %% Add dependency from 'external' to all escaping function + %% Add dependency from 'external' to all escaping functions State1 = state__add_deps(external, output(Esc), State), Deps = state__deps(State1), Calls = state__calls(State1), @@ -486,11 +486,22 @@ all_vars(Tree, AccIn) -> state__new(Tree) -> Exports = set__from_list([X || X <- cerl:module_exports(Tree)]), - InitEsc = set__from_list([cerl_trees:get_label(Fun) - || {Var, Fun} <- cerl:module_defs(Tree), - set__is_element(Var, Exports)]), + %% get the labels of all exported functions + ExpLs = [cerl_trees:get_label(Fun) || {Var, Fun} <- cerl:module_defs(Tree), + set__is_element(Var, Exports)], + %% make sure to also initiate an analysis from all functions called + %% from on_load attributes; in Core these exist as a list of {F,A} pairs + OnLoadFAs = lists:flatten([cerl:atom_val(Args) + || {Attr, Args} <- cerl:module_attrs(Tree), + cerl:atom_val(Attr) =:= on_load]), + OnLoadLs = [cerl_trees:get_label(Fun) + || {Var, Fun} <- cerl:module_defs(Tree), + lists:member(cerl:var_name(Var), OnLoadFAs)], + %% init the escaping function labels to exported + called from on_load + InitEsc = set__from_list(OnLoadLs ++ ExpLs), Arities = cerl_trees:fold(fun find_arities/2, dict:new(), Tree), - #state{deps = map__new(), esc = InitEsc, call = map__new(), arities = Arities, letrecs = map__new()}. + #state{deps = map__new(), esc = InitEsc, call = map__new(), + arities = Arities, letrecs = map__new()}. find_arities(Tree, AccMap) -> case cerl:is_c_fun(Tree) of |