From d369eba15eb3425b9033e13349896264e766d122 Mon Sep 17 00:00:00 2001 From: Jules Villard Date: Mon, 4 May 2020 08:13:58 -0700 Subject: [PATCH] [nullsafe] get rid of Ondemand dependency Summary: On our way to making nullsafe its own dune library. Reviewed By: dulmarod Differential Revision: D21351455 fbshipit-source-id: 0d621d71d --- infer/src/nullsafe/AggregatedSummaries.ml | 5 +++-- infer/src/nullsafe/AggregatedSummaries.mli | 4 ++-- infer/src/nullsafe/ClassLevelAnalysis.ml | 6 +----- infer/src/nullsafe/FileLevelAnalysis.ml | 8 ++++---- 4 files changed, 10 insertions(+), 13 deletions(-) diff --git a/infer/src/nullsafe/AggregatedSummaries.ml b/infer/src/nullsafe/AggregatedSummaries.ml index 06b8940d2..2bd08deaa 100644 --- a/infer/src/nullsafe/AggregatedSummaries.ml +++ b/infer/src/nullsafe/AggregatedSummaries.ml @@ -8,9 +8,10 @@ open! IStd module ClassInfo = struct - type t = {summaries: Summary.t list; nested_anonymous_classes: anonymous_class_to_summaries} + type t = + {summaries: NullsafeSummary.t list; nested_anonymous_classes: anonymous_class_to_summaries} - and anonymous_class_to_summaries = Summary.t list JavaClassName.Map.t + and anonymous_class_to_summaries = NullsafeSummary.t list JavaClassName.Map.t let make_empty () = {summaries= []; nested_anonymous_classes= JavaClassName.Map.empty} diff --git a/infer/src/nullsafe/AggregatedSummaries.mli b/infer/src/nullsafe/AggregatedSummaries.mli index fe069b720..531dd03de 100644 --- a/infer/src/nullsafe/AggregatedSummaries.mli +++ b/infer/src/nullsafe/AggregatedSummaries.mli @@ -14,7 +14,7 @@ open! IStd module ClassInfo : sig type t - val get_all_summaries : t -> Summary.t list + val get_all_summaries : t -> NullsafeSummary.t list (** List of all summaries, user-level and anonymous, combined together *) end @@ -22,7 +22,7 @@ type t val make_empty : unit -> t -val register_summary : JavaClassName.t -> Summary.t -> t -> t +val register_summary : JavaClassName.t -> NullsafeSummary.t -> t -> t (** Add information about summary to the class map. Depending on if this an anonymous or user-defined class, adds it to corresponding lists. *) diff --git a/infer/src/nullsafe/ClassLevelAnalysis.ml b/infer/src/nullsafe/ClassLevelAnalysis.ml index 8a9ede78c..8540314ed 100644 --- a/infer/src/nullsafe/ClassLevelAnalysis.ml +++ b/infer/src/nullsafe/ClassLevelAnalysis.ml @@ -177,11 +177,7 @@ let report_meta_issues tenv source_file class_name class_struct class_info issue let current_mode = NullsafeMode.of_class tenv class_name in let summaries = AggregatedSummaries.ClassInfo.get_all_summaries class_info in let class_loc = get_class_loc source_file class_struct in - let all_issues = - List.map summaries ~f:(fun Summary.{payloads= {nullsafe}} -> - Option.value_map nullsafe ~f:(fun NullsafeSummary.{issues} -> issues) ~default:[] ) - |> List.fold ~init:[] ~f:( @ ) - in + let all_issues = List.concat_map summaries ~f:(fun {NullsafeSummary.issues} -> issues) in let {issue_type; description; severity; meta_issue_info} = make_meta_issue all_issues current_mode class_name in diff --git a/infer/src/nullsafe/FileLevelAnalysis.ml b/infer/src/nullsafe/FileLevelAnalysis.ml index 517a96939..d8527dc56 100644 --- a/infer/src/nullsafe/FileLevelAnalysis.ml +++ b/infer/src/nullsafe/FileLevelAnalysis.ml @@ -16,12 +16,12 @@ let get_java_class_name = function (* aggregate all of the procedures in the file env by their declaring class. this lets us analyze each class individually *) -let aggregate_by_class procedures = +let aggregate_by_class {InterproceduralAnalysis.procedures; analyze_file_dependency; _} = let open IOption.Let_syntax in List.fold procedures ~init:(AggregatedSummaries.make_empty ()) ~f:(fun map_to_update procname -> (let* class_name = Procname.get_class_type_name procname in let* java_class_name = get_java_class_name class_name in - let* summary = Ondemand.analyze_proc_name_no_caller procname in + let* _proc_desc, summary = analyze_file_dependency procname in return (AggregatedSummaries.register_summary java_class_name summary map_to_update)) |> Option.value ~default:map_to_update ) @@ -38,8 +38,8 @@ let analyze_class tenv source_file issue_log (class_name, class_info) = else ClassLevelAnalysis.analyze_class tenv source_file class_name class_info issue_log -let analyze_file {InterproceduralAnalysis.procedures; file_exe_env; source_file} = - let class_map = aggregate_by_class procedures in +let analyze_file ({InterproceduralAnalysis.file_exe_env; source_file} as analysis_data) = + let class_map = aggregate_by_class analysis_data in let tenv = Exe_env.load_java_global_tenv file_exe_env in let user_class_info = AggregatedSummaries.group_by_user_class class_map in List.fold user_class_info ~init:IssueLog.empty ~f:(analyze_class tenv source_file)