Skip to content

Commit b90621d

Browse files
committed
Dce command can count the issues.
1 parent 359d064 commit b90621d

File tree

7 files changed

+15
-19
lines changed

7 files changed

+15
-19
lines changed

analysis/reanalyze/src/Arnold.ml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1418,4 +1418,4 @@ let processCmt (cmt_infos : Cmt_format.cmt_infos) =
14181418
| Implementation structure -> processStructure structure
14191419
| _ -> ()
14201420

1421-
let reportResults ~ppf = if !Common.Cli.debug then Stats.dump ~ppf
1421+
let reportStats () = Stats.dump ~ppf:Format.std_formatter

analysis/reanalyze/src/DeadCommon.ml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -507,7 +507,7 @@ module Decl = struct
507507
then Current.maxValuePosEnd := decl.posEnd;
508508
insideReportedValue
509509

510-
let report ~ppf decl =
510+
let report decl =
511511
let insideReportedValue = decl |> isInsideReportedValue in
512512
if decl.report then
513513
let name, message =
@@ -650,7 +650,7 @@ let rec resolveRecursiveRefs ~checkOptionalArg ~deadDeclarations ~level
650650
refsString level);
651651
isDead
652652

653-
let reportDead ~checkOptionalArg ppf =
653+
let reportDead ~checkOptionalArg =
654654
let iterDeclInOrder ~deadDeclarations ~orderedFiles decl =
655655
let refs =
656656
match decl |> Decl.isValue with
@@ -692,4 +692,4 @@ let reportDead ~checkOptionalArg ppf =
692692
let sortedDeadDeclarations =
693693
!deadDeclarations |> List.fast_sort Decl.compareForReporting
694694
in
695-
sortedDeadDeclarations |> List.iter (Decl.report ~ppf)
695+
sortedDeadDeclarations |> List.iter Decl.report

analysis/reanalyze/src/Exception.ml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -488,5 +488,3 @@ let processCmt (cmt_infos : Cmt_format.cmt_infos) =
488488
Values.newCmt ();
489489
structure |> processStructure
490490
| _ -> ()
491-
492-
let reportResults ~ppf:_ = Checks.doChecks ()

analysis/reanalyze/src/Reanalyze.ml

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -85,17 +85,16 @@ let runAnalysis ~cmtRoot =
8585
processCmtFiles ~cmtRoot;
8686
if runConfig.dce then (
8787
DeadException.forceDelayedItems ();
88-
DeadOptionalArgs.forceDelayedItems ())
88+
DeadOptionalArgs.forceDelayedItems ();
89+
DeadCommon.reportDead ~checkOptionalArg:DeadOptionalArgs.check;
90+
WriteDeadAnnotations.write ());
91+
if runConfig.exception_ then Exception.Checks.doChecks ();
92+
if runConfig.termination && !Common.Cli.debug then Arnold.reportStats ()
8993

90-
let runAnalysisAndReport ~cmtRoot ~ppf =
94+
let runAnalysisAndReport ~cmtRoot =
9195
Log_.Color.setup ();
9296
if !Common.Cli.json then EmitJson.start ();
9397
runAnalysis ~cmtRoot;
94-
if runConfig.dce then (
95-
DeadCommon.reportDead ~checkOptionalArg:DeadOptionalArgs.check ppf;
96-
WriteDeadAnnotations.write ());
97-
if runConfig.exception_ then Exception.reportResults ~ppf;
98-
if runConfig.termination then Arnold.reportResults ~ppf;
9998
Log_.Stats.report ();
10099
Log_.Stats.clear ();
101100
if !Common.Cli.json then EmitJson.finish ()
@@ -207,11 +206,10 @@ let cli () =
207206
"Write @dead annotations directly in the source files" );
208207
]
209208
in
210-
let ppf = Format.std_formatter in
211209
Arg.parse speclist print_endline usage;
212210
if !analysisKindSet = false then setConfig ();
213211
let cmtRoot = !cmtRootRef in
214-
runAnalysisAndReport ~cmtRoot ~ppf
212+
runAnalysisAndReport ~cmtRoot
215213
[@@raises exit]
216214

217215
module RunConfig = RunConfig

analysis/reanalyze/src/dune

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
(library
22
(name reanalyze)
33
(flags
4-
(-w "-9")
4+
(-w "+6+26+27+32+33+39")
55
(-open Compilerlibs406)
66
(-open Jsonlib)
77
(-open Ext))

analysis/src/DceCommand.ml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
let command () =
22
Reanalyze.RunConfig.dce ();
33
Reanalyze.runAnalysis ~cmtRoot:None;
4-
let issues = Reanalyze.Log_.Stats.getSortedIssues () in
5-
Printf.printf "kinds of issues:%d\n" (List.length (fst issues))
4+
let issues = !Reanalyze.Log_.Stats.issues in
5+
Printf.printf "issues:%d\n" (List.length issues)
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
DCE src/Dce.res
2-
kinds of issues:0
2+
issues:233
33

0 commit comments

Comments
 (0)