Skip to content

Commit

Permalink
Merge branch 'bjorn/dialyzer/support-line_coverage/GH-9027/OTP-19344'…
Browse files Browse the repository at this point in the history
… into maint

* bjorn/dialyzer/support-line_coverage/GH-9027/OTP-19344:
  dialyzer: Support modules compiled with `line_coverage`
  • Loading branch information
bjorng committed Nov 11, 2024
2 parents 20244a6 + 017e756 commit 98b2d28
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 3 deletions.
2 changes: 2 additions & 0 deletions lib/dialyzer/src/dialyzer_dataflow.erl
Original file line number Diff line number Diff line change
Expand Up @@ -1013,6 +1013,8 @@ handle_primop(Tree, Map, State) ->
{State, Map, t_any()};
nif_start ->
{State, Map, t_any()};
executable_line ->
{State, Map, t_any()};
Other ->
error({'Unsupported primop', Other})
end.
Expand Down
2 changes: 2 additions & 0 deletions lib/dialyzer/src/dialyzer_typesig.erl
Original file line number Diff line number Diff line change
Expand Up @@ -438,6 +438,8 @@ traverse(Tree, DefinedVars, State) ->
{State, t_any()};
nif_start ->
{State, t_any()};
executable_line ->
{State, t_any()};
Other -> erlang:error({'Unsupported primop', Other})
end;
seq ->
Expand Down
25 changes: 22 additions & 3 deletions lib/dialyzer/test/dialyzer_SUITE.erl
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,8 @@
incremental_plt_given_to_classic_mode/1,
classic_plt_given_to_incremental_mode/1,
if_output_plt_is_missing_incremental_mode_makes_it/1,
file_list/1]).
file_list/1,
line_coverage/1]).

suite() -> [{ct_hooks,[ts_install_cth]}].

Expand All @@ -46,7 +47,8 @@ all() ->
incremental_plt_given_to_classic_mode,
classic_plt_given_to_incremental_mode,
if_output_plt_is_missing_incremental_mode_makes_it,
file_list].
file_list,
line_coverage].

groups() ->
[].
Expand Down Expand Up @@ -77,7 +79,7 @@ compile(Config, Prog, Module, CompileOpts) ->
PrivDir = proplists:get_value(priv_dir,Config),
Filename = filename:join([PrivDir, Source]),
ok = file:write_file(Filename, Prog),
Opts = [{outdir, PrivDir}, debug_info | CompileOpts],
Opts = [report, {outdir, PrivDir}, debug_info | CompileOpts],
{ok, Module} = compile:file(Filename, Opts),
{ok, filename:join([PrivDir, lists:concat([Module, ".beam"])])}.

Expand Down Expand Up @@ -242,3 +244,20 @@ expected(Files0) ->
" atom()\n" || F <- Files],
iolist_to_binary(S).

line_coverage(Config) ->
PrivDir = proplists:get_value(priv_dir, Config),
Prog = <<"-module(foo).
bar() -> ok."
>>,
{ok, Beam1} = compile(Config, Prog, foo, [line_coverage]),

Plt1 = filename:join(PrivDir, "line_coverage.plt"),
_ = dialyzer:run([{analysis_type, plt_build},
{files, [Beam1]},
{init_plt, Plt1},
{from, byte_code}]),

{ok, [{files, [Beam1]}]} = dialyzer:plt_info(Plt1),

ok.

0 comments on commit 98b2d28

Please sign in to comment.