104
104
%%--------------------------------------------------------------------
106
106
analysis_start(Parent, Analysis) ->
107
put(dialyzer_race_analysis, Analysis#analysis.race_detection),
108
107
CServer = dialyzer_codeserver:new(),
109
108
Plt = Analysis#analysis.plt,
110
109
State = #analysis_state{codeserver = CServer,
125
124
%% Remove all old versions of the files being analyzed
126
125
AllNodes = dialyzer_callgraph:all_nodes(Callgraph),
127
126
Plt1 = dialyzer_plt:delete_list(Plt, AllNodes),
128
State3 = analyze_callgraph(Callgraph, State2#analysis_state{plt=Plt1}),
129
127
Exports = dialyzer_codeserver:all_exports(NewCServer),
129
case Analysis#analysis.race_detection of
131
Callgraph#dialyzer_callgraph{race_detection = true,
132
exports = sets:to_list(Exports)};
135
State3 = analyze_callgraph(NewCallgraph, State2#analysis_state{plt=Plt1}),
130
136
NonExports = sets:subtract(sets:from_list(AllNodes), Exports),
131
137
NonExportsList = sets:to_list(NonExports),
132
138
Plt3 = dialyzer_plt:delete_list(State3#analysis_state.plt, NonExportsList),
342
348
store_code_and_build_callgraph(Mod, Core, Callgraph, CServer, NoWarn) ->
343
349
CoreTree = cerl:from_records(Core),
344
350
NewCallgraph = dialyzer_callgraph:scan_core_tree(CoreTree, Callgraph),
346
case get(dialyzer_race_analysis) of
348
NewCallgraph1 = concat_module_local_calls(Callgraph, NewCallgraph),
349
concat_inter_module_calls(Callgraph, NewCallgraph1);
352
351
CServer2 = dialyzer_codeserver:insert([{Mod, CoreTree}], CServer),
353
{ok, NewCallgraph2, NoWarn, CServer2}.
355
concat_module_local_calls(#dialyzer_callgraph{module_local_calls=Calls},
356
NewCallgraph = #dialyzer_callgraph{module_local_calls=NewCalls}) ->
357
NormCalls = normalize_module_local_calls(Calls ++ NewCalls),
358
NewCallgraph#dialyzer_callgraph{module_local_calls = NormCalls}.
360
concat_inter_module_calls(#dialyzer_callgraph{inter_module_calls = Calls},
361
NewCallgraph = #dialyzer_callgraph{inter_module_calls = NewCalls}) ->
362
NormCalls = normalize_inter_module_calls(Calls ++ NewCalls),
363
NewCallgraph#dialyzer_callgraph{inter_module_calls = NormCalls}.
365
normalize_module_local_calls(Calls) ->
369
[norm_module_local_call(C) || C <- Calls]
372
norm_module_local_call(C) ->
375
{TupleA, empty, TupleB, empty, empty, empty, empty, false};
376
{_TupleA, _IntA, _TupleB, _IntB, _ArgsB, _CodeA, _CodeB, _Bool} -> C
379
normalize_inter_module_calls(Calls) ->
383
[norm_inter_module_call(C) || C <- Calls]
386
norm_inter_module_call(C) ->
388
{TupleA, TupleB} -> {TupleA, TupleB, empty, [], [], false, false};
389
{_TupleA, _TupleB, _ArgsB, _ListA, _ListB, _BoolA, _BoolB} -> C
352
{ok, NewCallgraph, NoWarn, CServer2}.
392
354
%%--------------------------------------------------------------------