~ubuntu-branches/debian/squeeze/erlang/squeeze

« back to all changes in this revision

Viewing changes to lib/dialyzer/src/dialyzer_analysis_callgraph.erl

  • Committer: Bazaar Package Importer
  • Author(s): Sergei Golovan
  • Date: 2009-08-05 20:54:29 UTC
  • mfrom: (6.1.2 sid)
  • Revision ID: james.westby@ubuntu.com-20090805205429-pm4pnwew8axraosl
Tags: 1:13.b.1-dfsg-5
* Fixed parentheses in Emacs mode (closes: #536891).
* Removed unnecessary conflicts with erlang-manpages package.
* Added workaround for #475459: disabled threads on sparc architecture.
  This breaks wxErlang, so it's only a temporary solution.

Show diffs side-by-side

added added

removed removed

Lines of Context:
104
104
%%--------------------------------------------------------------------
105
105
 
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),
 
128
  NewCallgraph =
 
129
    case Analysis#analysis.race_detection of
 
130
      true ->
 
131
        Callgraph#dialyzer_callgraph{race_detection = true,
 
132
          exports = sets:to_list(Exports)};
 
133
      false -> Callgraph
 
134
    end,
 
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),
345
 
  NewCallgraph2 = 
346
 
    case get(dialyzer_race_analysis) of
347
 
      true -> 
348
 
        NewCallgraph1 = concat_module_local_calls(Callgraph, NewCallgraph),
349
 
        concat_inter_module_calls(Callgraph, NewCallgraph1);
350
 
      _ -> NewCallgraph
351
 
    end,
352
351
  CServer2 = dialyzer_codeserver:insert([{Mod, CoreTree}], CServer),
353
 
  {ok, NewCallgraph2, NoWarn, CServer2}.
354
 
 
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}.
359
 
 
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}.
364
 
 
365
 
normalize_module_local_calls(Calls) ->
366
 
  case Calls of
367
 
    [] -> [];
368
 
    _Other ->
369
 
      [norm_module_local_call(C) || C <- Calls]
370
 
  end.
371
 
 
372
 
norm_module_local_call(C) ->
373
 
  case C of
374
 
    {TupleA, TupleB} ->
375
 
      {TupleA, empty, TupleB, empty, empty, empty, empty, false};
376
 
    {_TupleA, _IntA, _TupleB, _IntB, _ArgsB, _CodeA, _CodeB, _Bool} -> C
377
 
  end.
378
 
 
379
 
normalize_inter_module_calls(Calls) ->
380
 
  case Calls of
381
 
    [] -> [];
382
 
    _Other ->
383
 
      [norm_inter_module_call(C) || C <- Calls]
384
 
  end.
385
 
 
386
 
norm_inter_module_call(C) ->
387
 
  case C of
388
 
    {TupleA, TupleB} -> {TupleA, TupleB, empty, [], [], false, false};
389
 
    {_TupleA, _TupleB, _ArgsB, _ListA, _ListB, _BoolA, _BoolB} -> C
390
 
  end.
 
352
  {ok, NewCallgraph, NoWarn, CServer2}.
391
353
 
392
354
%%--------------------------------------------------------------------
393
355
%% Utilities