diff options
-rw-r--r-- | lib/tools/src/xref_reader.erl | 2 | ||||
-rw-r--r-- | lib/tools/test/xref_SUITE.erl | 26 | ||||
-rw-r--r-- | lib/tools/test/xref_SUITE_data/lib_test/bi.erl | 3 | ||||
-rw-r--r-- | lib/tools/test/xref_SUITE_data/lib_test/no_bi.erl | 6 |
4 files changed, 35 insertions, 2 deletions
diff --git a/lib/tools/src/xref_reader.erl b/lib/tools/src/xref_reader.erl index d28bdb78db..87c02db9eb 100644 --- a/lib/tools/src/xref_reader.erl +++ b/lib/tools/src/xref_reader.erl @@ -95,6 +95,8 @@ form({function, _, module_info, 0, _Clauses}, S) -> S; form({function, _, module_info, 1, _Clauses}, S) -> S; +form({function, 0 = _Line, behaviour_info, 1, _Clauses}, S) -> + S; form({function, Anno, Name, Arity, Clauses}, S) -> MFA0 = {S#xrefr.module, Name, Arity}, MFA = adjust_arity(S, MFA0), diff --git a/lib/tools/test/xref_SUITE.erl b/lib/tools/test/xref_SUITE.erl index c84f47c207..b5b3ff7796 100644 --- a/lib/tools/test/xref_SUITE.erl +++ b/lib/tools/test/xref_SUITE.erl @@ -48,7 +48,8 @@ fun_mfa/1, fun_mfa_r14/1, fun_mfa_vars/1, qlc/1]). --export([analyze/1, basic/1, md/1, q/1, variables/1, unused_locals/1]). +-export([analyze/1, basic/1, md/1, q/1, variables/1, unused_locals/1, + behaviour_info_t/1, fake_behaviour_info_t/1]). -export([format_error/1, otp_7423/1, otp_7831/1, otp_10192/1, otp_13708/1, otp_14464/1, otp_14344/1]). @@ -83,7 +84,7 @@ groups() -> fun_mfa_r14, fun_mfa_vars, qlc]}, {analyses, [], - [analyze, basic, md, q, variables, unused_locals]}, + [analyze, basic, md, q, variables, unused_locals, behaviour_info_t, fake_behaviour_info_t]}, {misc, [], [format_error, otp_7423, otp_7831, otp_10192, otp_13708, otp_14464, otp_14344]}]. @@ -2825,3 +2826,24 @@ add_erts_code_path(KernelPath) -> [KernelPath] end end. + +behaviour_info_t(Config) -> + bi_t(_Module = bi, + _IsExportNotUsed = false, + Config). + +fake_behaviour_info_t(Config) -> + bi_t(_Module = no_bi, + _IsExportNotUsed = true, + Config). + +bi_t(Module, IsExportNotUsed, Conf) -> + LibTestDir = fname(?copydir, "lib_test"), + XRefServer = s, + {ok, Module} = compile:file(fname(LibTestDir, Module), + [debug_info, {outdir, LibTestDir}]), + {ok, _} = start(XRefServer), + {ok, Module} = xref:add_module(XRefServer, fname(LibTestDir, Module)), + {ok, MFAs} = xref:analyze(XRefServer, exports_not_used), + true = lists:member({Module, behaviour_info, 1}, MFAs) =:= IsExportNotUsed, + _ = xref:stop(XRefServer). diff --git a/lib/tools/test/xref_SUITE_data/lib_test/bi.erl b/lib/tools/test/xref_SUITE_data/lib_test/bi.erl new file mode 100644 index 0000000000..e083fa0f3c --- /dev/null +++ b/lib/tools/test/xref_SUITE_data/lib_test/bi.erl @@ -0,0 +1,3 @@ +-module(bi). + +-callback a() -> ok. diff --git a/lib/tools/test/xref_SUITE_data/lib_test/no_bi.erl b/lib/tools/test/xref_SUITE_data/lib_test/no_bi.erl new file mode 100644 index 0000000000..5aac4a193e --- /dev/null +++ b/lib/tools/test/xref_SUITE_data/lib_test/no_bi.erl @@ -0,0 +1,6 @@ +-module(no_bi). + +-export([behaviour_info/1]). + +behaviour_info(_) -> + ok. |