diff --git a/infer/src/IR/Cfg.ml b/infer/src/IR/Cfg.ml index 3a9a50d60..aabd85e8c 100644 --- a/infer/src/IR/Cfg.ml +++ b/infer/src/IR/Cfg.ml @@ -50,23 +50,10 @@ let iter_all_nodes ~sorted cfg ~f = |> List.iter ~f:(fun node -> f pdesc node) ) -let load_statement = - ResultsDatabase.register_statement "SELECT cfgs FROM source_files WHERE source_file = :k" - - module SQLite = SqliteUtils.MarshalledData (struct type nonrec t = t end) -let load source = - ResultsDatabase.with_registered_statement load_statement ~f:(fun db load_stmt -> - SourceFile.SQLite.serialize source - |> Sqlite3.bind load_stmt 1 - |> SqliteUtils.check_result_code db ~log:"load bind source file" ; - SqliteUtils.result_single_column_option ~finalize:false ~log:"Cfg.load" db load_stmt - |> Option.map ~f:SQLite.deserialize ) - - let store source_file cfg = let save_proc _ proc_desc = let attributes = Procdesc.get_attributes proc_desc in diff --git a/infer/src/IR/Cfg.mli b/infer/src/IR/Cfg.mli index f0cfc03e6..9e88e665c 100644 --- a/infer/src/IR/Cfg.mli +++ b/infer/src/IR/Cfg.mli @@ -13,9 +13,6 @@ open! IStd (** A control-flow graph is a collection of all the CFGs for the procedure names in a file *) type t = Procdesc.t Typ.Procname.Hash.t -val load : SourceFile.t -> t option -(** Load the cfgs of the procedures of a source file *) - val get_all_defined_proc_names : t -> Typ.Procname.t list (** get all the procedure names that are defined in the current file *) diff --git a/infer/src/backend/printer.ml b/infer/src/backend/printer.ml index 5000167ba..0a90ed025 100644 --- a/infer/src/backend/printer.ml +++ b/infer/src/backend/printer.ml @@ -370,8 +370,8 @@ let write_html_file linereader filename procs = Io_infer.Html.close (fd, fmt) -(** Create filename.ext.html for each file in the cluster. *) -let write_all_html_files cluster = +(** Create the HTML debug file for the source file. *) +let write_all_html_files source_file = let opt_whitelist_regex = match Config.write_html_whitelist_regex with | [] -> @@ -385,20 +385,22 @@ let write_all_html_files cluster = Str.string_match regex fname 0 ) in let linereader = LineReader.create () in - let cfg = Cfg.load cluster in - Option.iter cfg ~f:(fun cfg -> - let source_files_in_cfg, pdescs_in_cfg = - Typ.Procname.Hash.fold - (fun _ proc_desc (files, pdescs) -> + let procs_in_source = SourceFiles.proc_names_of_source source_file in + let source_files_in_cfg, pdescs_in_cfg = + List.fold procs_in_source ~init:(SourceFile.Set.empty, []) + ~f:(fun ((files, pdescs) as acc) proc_name -> + match Procdesc.load proc_name with + | Some proc_desc -> let updated_files = if Procdesc.is_defined proc_desc then let file = (Procdesc.get_loc proc_desc).Location.file in if is_whitelisted file then SourceFile.Set.add file files else files else files in - (updated_files, proc_desc :: pdescs) ) - cfg (SourceFile.Set.empty, []) - in - SourceFile.Set.iter - (fun file -> write_html_file linereader file pdescs_in_cfg) - source_files_in_cfg ) + (updated_files, proc_desc :: pdescs) + | None -> + acc ) + in + SourceFile.Set.iter + (fun file -> write_html_file linereader file pdescs_in_cfg) + source_files_in_cfg