Skip to content

Commit eb4ee16

Browse files
José Valimuabboli
José Valim
authored andcommitted
No longer support OTP 19 beam files in Dialyzer
This commit removes the old code branches that attempted to translate Erlang Abstract Format to Core and relies exclusively on the new debug_info chunk. This is a follow up to #1367.
1 parent fcca55a commit eb4ee16

File tree

1 file changed

+2
-84
lines changed

1 file changed

+2
-84
lines changed

lib/dialyzer/src/dialyzer_utils.erl

+2-84
Original file line numberDiff line numberDiff line change
@@ -120,92 +120,10 @@ get_core_from_beam(File, Opts) ->
120120
{error, " Could not get Core Erlang code for: " ++ File ++ "\n"}
121121
end;
122122
_ ->
123-
deprecated_get_core_from_beam(File, Opts)
123+
{error, " Could not get Core Erlang code for: " ++ File ++ "\n" ++
124+
" Recompile with +debug_info or analyze starting from source code"}
124125
end.
125126

126-
deprecated_get_core_from_beam(File, Opts) ->
127-
case get_abstract_code_from_beam(File) of
128-
error ->
129-
{error, " Could not get abstract code for: " ++ File ++ "\n" ++
130-
" Recompile with +debug_info or analyze starting from source code"};
131-
{ok, AbstrCode} ->
132-
case get_compile_options_from_beam(File) of
133-
error ->
134-
{error, " Could not get compile options for: " ++ File ++ "\n" ++
135-
" Recompile or analyze starting from source code"};
136-
{ok, CompOpts} ->
137-
case get_core_from_abstract_code(AbstrCode, Opts ++ CompOpts) of
138-
error ->
139-
{error, " Could not get core Erlang code for: " ++ File};
140-
{ok, _} = Core ->
141-
Core
142-
end
143-
end
144-
end.
145-
146-
get_abstract_code_from_beam(File) ->
147-
case beam_lib:chunks(File, [abstract_code]) of
148-
{ok, {_, List}} ->
149-
case lists:keyfind(abstract_code, 1, List) of
150-
{abstract_code, {raw_abstract_v1, Abstr}} -> {ok, Abstr};
151-
_ -> error
152-
end;
153-
_ ->
154-
%% No or unsuitable abstract code.
155-
error
156-
end.
157-
158-
get_compile_options_from_beam(File) ->
159-
case beam_lib:chunks(File, [compile_info]) of
160-
{ok, {_, List}} ->
161-
case lists:keyfind(compile_info, 1, List) of
162-
{compile_info, CompInfo} -> compile_info_to_options(CompInfo);
163-
_ -> error
164-
end;
165-
_ ->
166-
%% No or unsuitable compile info.
167-
error
168-
end.
169-
170-
compile_info_to_options(CompInfo) ->
171-
case lists:keyfind(options, 1, CompInfo) of
172-
{options, CompOpts} -> {ok, CompOpts};
173-
_ -> error
174-
end.
175-
176-
get_core_from_abstract_code(AbstrCode, Opts) ->
177-
%% We do not want the parse_transforms around since we already
178-
%% performed them. In some cases we end up in trouble when
179-
%% performing them again.
180-
AbstrCode1 = cleanup_parse_transforms(AbstrCode),
181-
%% Remove parse_transforms (and other options) from compile options.
182-
Opts2 = cleanup_compile_options(Opts),
183-
try compile:noenv_forms(AbstrCode1, Opts2 ++ src_compiler_opts()) of
184-
{ok, _, Core} -> {ok, Core};
185-
_What -> error
186-
catch
187-
error:_ -> error
188-
end.
189-
190-
cleanup_parse_transforms([{attribute, _, compile, {parse_transform, _}}|Left]) ->
191-
cleanup_parse_transforms(Left);
192-
cleanup_parse_transforms([Other|Left]) ->
193-
[Other|cleanup_parse_transforms(Left)];
194-
cleanup_parse_transforms([]) ->
195-
[].
196-
197-
cleanup_compile_options(Opts) ->
198-
lists:filter(fun keep_compile_option/1, Opts).
199-
200-
%% Using abstract, not asm or core.
201-
keep_compile_option(from_asm) -> false;
202-
keep_compile_option(from_core) -> false;
203-
%% The parse transform will already have been applied, may cause
204-
%% problems if it is re-applied.
205-
keep_compile_option({parse_transform, _}) -> false;
206-
keep_compile_option(warnings_as_errors) -> false;
207-
keep_compile_option(_) -> true.
208-
209127
%% ============================================================================
210128
%%
211129
%% Typed Records

0 commit comments

Comments
 (0)