From 965bf52bf87a905afb1af49029f1caf2d7a4ca22 Mon Sep 17 00:00:00 2001 From: Nikos Gorogiannis Date: Thu, 3 Oct 2019 05:08:27 -0700 Subject: [PATCH] [filtering/dedup] add deduplicate flag and disambiguate filtering Summary: The documentation and uses of filtering disagree. One typical usage is deduplication. Split that where obvious, add comments where not obvious, and leave alone when obviously unrelated to deduplication. Reviewed By: mityal Differential Revision: D17715329 fbshipit-source-id: ec757927b --- infer/man/man1/infer-analyze.txt | 4 ++++ infer/man/man1/infer-full.txt | 10 ++++++++-- infer/man/man1/infer-report.txt | 4 ++++ infer/man/man1/infer-reportdiff.txt | 4 ++++ infer/man/man1/infer.txt | 5 +++++ infer/src/backend/Differential.ml | 1 + infer/src/backend/Issue.ml | 1 + infer/src/base/Config.ml | 16 +++++++++++++--- infer/src/base/Config.mli | 2 ++ infer/src/checkers/Siof.ml | 1 + infer/src/concurrency/RacerD.ml | 4 ++-- infer/src/integration/ReportDiff.ml | 1 + infer/src/nullsafe/NullabilityCheck.ml | 1 + 13 files changed, 47 insertions(+), 7 deletions(-) diff --git a/infer/man/man1/infer-analyze.txt b/infer/man/man1/infer-analyze.txt index d8c8507ec..8c2ce965a 100644 --- a/infer/man/man1/infer-analyze.txt +++ b/infer/man/man1/infer-analyze.txt @@ -96,6 +96,10 @@ OPTIONS Debug level for the linters. See --debug-level for accepted values. + --no-deduplicate + Deactivates: Apply issue-specific deduplication during analysis + and/or reporting. (Conversely: --deduplicate) + --no-default-checkers Deactivates: Default checkers: --biabduction, --fragment-retains-view, --inefficient-keyset-iterator, --linters, diff --git a/infer/man/man1/infer-full.txt b/infer/man/man1/infer-full.txt index 324cd2802..3b5d4979c 100644 --- a/infer/man/man1/infer-full.txt +++ b/infer/man/man1/infer-full.txt @@ -296,6 +296,11 @@ OPTIONS infer-events(1), infer-report(1), infer-reportdiff(1), and infer-run(1). + --no-deduplicate + Deactivates: Apply issue-specific deduplication during analysis + and/or reporting. (Conversely: --deduplicate) See also infer-analyze(1), infer-report(1), and + infer-reportdiff(1). + --no-default-checkers Deactivates: Default checkers: --biabduction, --fragment-retains-view, --inefficient-keyset-iterator, --linters, @@ -1277,8 +1282,9 @@ INTERNAL OPTIONS --debug-exceptions Activates: Generate lightweight debugging information: just print the internal exceptions during analysis (also sets - --developer-mode, --no-filtering, --print-buckets, - --reports-include-ml-loc) (Conversely: --no-debug-exceptions) + --developer-mode, --no-filtering, --no-deduplicate, + --print-buckets, --reports-include-ml-loc) (Conversely: + --no-debug-exceptions) --debug-level-reset Cancel the effect of --debug-level. diff --git a/infer/man/man1/infer-report.txt b/infer/man/man1/infer-report.txt index e4ae91463..14d86a241 100644 --- a/infer/man/man1/infer-report.txt +++ b/infer/man/man1/infer-report.txt @@ -60,6 +60,10 @@ OPTIONS Debug level for the linters. See --debug-level for accepted values. + --no-deduplicate + Deactivates: Apply issue-specific deduplication during analysis + and/or reporting. (Conversely: --deduplicate) + --differential-filter-files string Specify the file containing the list of source files for which a differential report is desired. Source files should be specified diff --git a/infer/man/man1/infer-reportdiff.txt b/infer/man/man1/infer-reportdiff.txt index f2ee623f0..8f98406ad 100644 --- a/infer/man/man1/infer-reportdiff.txt +++ b/infer/man/man1/infer-reportdiff.txt @@ -51,6 +51,10 @@ OPTIONS Debug level for the linters. See --debug-level for accepted values. + --no-deduplicate + Deactivates: Apply issue-specific deduplication during analysis + and/or reporting. (Conversely: --deduplicate) + --file-renamings path JSON with a list of file renamings to use while computing differential reports diff --git a/infer/man/man1/infer.txt b/infer/man/man1/infer.txt index 5134b98e6..d42e49b7c 100644 --- a/infer/man/man1/infer.txt +++ b/infer/man/man1/infer.txt @@ -296,6 +296,11 @@ OPTIONS infer-events(1), infer-report(1), infer-reportdiff(1), and infer-run(1). + --no-deduplicate + Deactivates: Apply issue-specific deduplication during analysis + and/or reporting. (Conversely: --deduplicate) See also infer-analyze(1), infer-report(1), and + infer-reportdiff(1). + --no-default-checkers Deactivates: Default checkers: --biabduction, --fragment-retains-view, --inefficient-keyset-iterator, --linters, diff --git a/infer/src/backend/Differential.ml b/infer/src/backend/Differential.ml index 6aa34f5d6..845feec2d 100644 --- a/infer/src/backend/Differential.ml +++ b/infer/src/backend/Differential.ml @@ -19,6 +19,7 @@ module LocListSet = struct end let is_duplicate_report end_locs reported_ends = + (* FIXME(T54950303) replace use of filtering with deduplicate *) Config.filtering && LocListSet.mem reported_ends end_locs diff --git a/infer/src/backend/Issue.ml b/infer/src/backend/Issue.ml index f17c594a1..b86d7ff0b 100644 --- a/infer/src/backend/Issue.ml +++ b/infer/src/backend/Issue.ml @@ -38,6 +38,7 @@ type t_ignore_duplicates = t = de-duplicating. *) let sort_filter_issues issues = let issues' = + (* FIXME(T54950303) replace use of filtering with deduplicate *) let compare = if Config.filtering then compare_t_ignore_duplicates else compare in List.dedup_and_sort ~compare issues in diff --git a/infer/src/base/Config.ml b/infer/src/base/Config.ml index 645f706bf..cc132e20b 100644 --- a/infer/src/base/Config.ml +++ b/infer/src/base/Config.ml @@ -1136,6 +1136,7 @@ and custom_symbols = and ( biabduction_models_mode , bo_debug + , deduplicate , developer_mode , debug , debug_exceptions @@ -1168,6 +1169,12 @@ and ( biabduction_models_mode CLOpt.mk_int ~default:0 ~long:"bo-debug" ~in_help:InferCommand.[(Analyze, manual_buffer_overrun)] "Debug level for buffer-overrun checker (0-4)" + and deduplicate = + CLOpt.mk_bool ~long:"deduplicate" ~default:true + ~in_help: + InferCommand. + [(Analyze, manual_generic); (Report, manual_generic); (ReportDiff, manual_generic)] + "Apply issue-specific deduplication during analysis and/or reporting." and debug_level_analysis = CLOpt.mk_int ~long:"debug-level-analysis" ~default:0 ~in_help:all_generic_manuals "Debug level for the analysis. See $(b,--debug-level) for accepted values." @@ -1248,10 +1255,10 @@ and ( biabduction_models_mode and debug_exceptions = CLOpt.mk_bool_group ~long:"debug-exceptions" "Generate lightweight debugging information: just print the internal exceptions during \ - analysis (also sets $(b,--developer-mode), $(b,--no-filtering), $(b,--print-buckets), \ - $(b,--reports-include-ml-loc))" + analysis (also sets $(b,--developer-mode), $(b,--no-filtering), $(b,--no-deduplicate), \ + $(b,--print-buckets), $(b,--reports-include-ml-loc))" [developer_mode; print_buckets; reports_include_ml_loc] - [filtering; keep_going] + [filtering; keep_going; deduplicate] and default_linters = CLOpt.mk_bool ~long:"default-linters" ~in_help:InferCommand.[(Capture, manual_clang_linters)] @@ -1285,6 +1292,7 @@ and ( biabduction_models_mode in ( biabduction_models_mode , bo_debug + , deduplicate , developer_mode , debug , debug_exceptions @@ -2837,6 +2845,8 @@ and debug_exceptions = !debug_exceptions and debug_mode = !debug +and deduplicate = !deduplicate + and default_linters = !default_linters and dependency_mode = !dependencies diff --git a/infer/src/base/Config.mli b/infer/src/base/Config.mli index 7f42c4c2d..f8634e7c5 100644 --- a/infer/src/base/Config.mli +++ b/infer/src/base/Config.mli @@ -312,6 +312,8 @@ val cxx : bool val cxx_scope_guards : Yojson.Basic.t +val deduplicate : bool + val debug_exceptions : bool val debug_level_analysis : int diff --git a/infer/src/checkers/Siof.ml b/infer/src/checkers/Siof.ml index 259c4e64a..fd9816471 100644 --- a/infer/src/checkers/Siof.ml +++ b/infer/src/checkers/Siof.ml @@ -242,6 +242,7 @@ let report_siof summary trace gname loc = Reporting.log_error summary ~loc ~ltr IssueType.static_initialization_order_fiasco description in let reportable_paths = SiofTrace.get_reportable_sink_paths trace ~trace_of_pname in + (* FIXME(T54950303) replace use of filtering with deduplicate *) if Config.filtering then List.hd reportable_paths |> Option.iter ~f:report_one_path else List.iter ~f:report_one_path reportable_paths diff --git a/infer/src/concurrency/RacerD.ml b/infer/src/concurrency/RacerD.ml index cf66f2a41..2f686b081 100644 --- a/infer/src/concurrency/RacerD.ml +++ b/infer/src/concurrency/RacerD.ml @@ -1000,7 +1000,7 @@ let report_unsafe_accesses ~issue_log classname (aggregated_access_map : ReportM ({reported_sites; reported_writes; reported_reads; reported_unannotated_calls}, _) = let pname = Procdesc.get_proc_name procdesc in let call_site = CallSite.make pname (TraceElem.get_loc snapshot.access) in - if Config.filtering then + if Config.deduplicate then CallSite.Set.mem call_site reported_sites || match snapshot.access.TraceElem.elem with @@ -1013,7 +1013,7 @@ let report_unsafe_accesses ~issue_log classname (aggregated_access_map : ReportM else false in let update_reported ({snapshot; procdesc} : reported_access) reported = - if Config.filtering then + if Config.deduplicate then let pname = Procdesc.get_proc_name procdesc in let call_site = CallSite.make pname (TraceElem.get_loc snapshot.access) in let reported_sites = CallSite.Set.add call_site reported.reported_sites in diff --git a/infer/src/integration/ReportDiff.ml b/infer/src/integration/ReportDiff.ml index bbca11afb..18f7ea237 100644 --- a/infer/src/integration/ReportDiff.ml +++ b/infer/src/integration/ReportDiff.ml @@ -21,6 +21,7 @@ let reportdiff ~current_report:current_report_fname ~previous_report:previous_re let unfiltered_diff = Differential.of_reports ~current_report ~previous_report ~current_costs ~previous_costs in + (* FIXME(T54950303) replace use of filtering with deduplicate *) if Config.filtering then let file_renamings = match Config.file_renamings with diff --git a/infer/src/nullsafe/NullabilityCheck.ml b/infer/src/nullsafe/NullabilityCheck.ml index 553d6357f..d1908bb8f 100644 --- a/infer/src/nullsafe/NullabilityCheck.ml +++ b/infer/src/nullsafe/NullabilityCheck.ml @@ -73,6 +73,7 @@ module TransferFunctions (CFG : ProcCfg.S) = struct let is_conflicting_report summary report_location = + (* FIXME(T54950303) replace use of filtering with deduplicate *) if not Config.filtering then false else Errlog.fold