File 0409-dialyzer-Support-modules-compiled-with-line_coverage.patch of Package erlang

From 017e756ff4af218bc19918246462a678bf156b66 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Bj=C3=B6rn=20Gustavsson?= <bjorn@erlang.org>
Date: Fri, 8 Nov 2024 07:11:00 +0100
Subject: [PATCH] dialyzer: Support modules compiled with `line_coverage`

Closes #9027
---
 lib/dialyzer/src/dialyzer_dataflow.erl |  2 ++
 lib/dialyzer/src/dialyzer_typesig.erl  |  2 ++
 lib/dialyzer/test/dialyzer_SUITE.erl   | 25 ++++++++++++++++++++++---
 3 files changed, 26 insertions(+), 3 deletions(-)

diff --git a/lib/dialyzer/src/dialyzer_dataflow.erl b/lib/dialyzer/src/dialyzer_dataflow.erl
index 939397741b..fa8bbf00ef 100644
--- a/lib/dialyzer/src/dialyzer_dataflow.erl
+++ b/lib/dialyzer/src/dialyzer_dataflow.erl
@@ -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.
diff --git a/lib/dialyzer/src/dialyzer_typesig.erl b/lib/dialyzer/src/dialyzer_typesig.erl
index ac6f57836e..039b90585f 100644
--- a/lib/dialyzer/src/dialyzer_typesig.erl
+++ b/lib/dialyzer/src/dialyzer_typesig.erl
@@ -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 ->
diff --git a/lib/dialyzer/test/dialyzer_SUITE.erl b/lib/dialyzer/test/dialyzer_SUITE.erl
index fe6987192a..a19e6930bc 100644
--- a/lib/dialyzer/test/dialyzer_SUITE.erl
+++ b/lib/dialyzer/test/dialyzer_SUITE.erl
@@ -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]}].
 
@@ -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() ->
     [].
@@ -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"])])}.
 
@@ -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.
+
-- 
2.43.0

openSUSE Build Service is sponsored by