[proc-cfg][4/5] kill Cfg.load

Summary: Remove the last use of file-wide CFGs in the database.

Reviewed By: jberdine

Differential Revision: D10173352

fbshipit-source-id: e8e9bd729
master
Jules Villard 6 years ago committed by Facebook Github Bot
parent 31e01a9aa0
commit 2b30dec50a

@ -50,23 +50,10 @@ let iter_all_nodes ~sorted cfg ~f =
|> List.iter ~f:(fun node -> f pdesc node) ) |> 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 module SQLite = SqliteUtils.MarshalledData (struct
type nonrec t = t type nonrec t = t
end) 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 store source_file cfg =
let save_proc _ proc_desc = let save_proc _ proc_desc =
let attributes = Procdesc.get_attributes proc_desc in let attributes = Procdesc.get_attributes proc_desc in

@ -13,9 +13,6 @@ open! IStd
(** A control-flow graph is a collection of all the CFGs for the procedure names in a file *) (** 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 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 val get_all_defined_proc_names : t -> Typ.Procname.t list
(** get all the procedure names that are defined in the current file *) (** get all the procedure names that are defined in the current file *)

@ -370,8 +370,8 @@ let write_html_file linereader filename procs =
Io_infer.Html.close (fd, fmt) Io_infer.Html.close (fd, fmt)
(** Create filename.ext.html for each file in the cluster. *) (** Create the HTML debug file for the source file. *)
let write_all_html_files cluster = let write_all_html_files source_file =
let opt_whitelist_regex = let opt_whitelist_regex =
match Config.write_html_whitelist_regex with match Config.write_html_whitelist_regex with
| [] -> | [] ->
@ -385,20 +385,22 @@ let write_all_html_files cluster =
Str.string_match regex fname 0 ) Str.string_match regex fname 0 )
in in
let linereader = LineReader.create () in let linereader = LineReader.create () in
let cfg = Cfg.load cluster in let procs_in_source = SourceFiles.proc_names_of_source source_file in
Option.iter cfg ~f:(fun cfg ->
let source_files_in_cfg, pdescs_in_cfg = let source_files_in_cfg, pdescs_in_cfg =
Typ.Procname.Hash.fold List.fold procs_in_source ~init:(SourceFile.Set.empty, [])
(fun _ proc_desc (files, pdescs) -> ~f:(fun ((files, pdescs) as acc) proc_name ->
match Procdesc.load proc_name with
| Some proc_desc ->
let updated_files = let updated_files =
if Procdesc.is_defined proc_desc then if Procdesc.is_defined proc_desc then
let file = (Procdesc.get_loc proc_desc).Location.file in let file = (Procdesc.get_loc proc_desc).Location.file in
if is_whitelisted file then SourceFile.Set.add file files else files if is_whitelisted file then SourceFile.Set.add file files else files
else files else files
in in
(updated_files, proc_desc :: pdescs) ) (updated_files, proc_desc :: pdescs)
cfg (SourceFile.Set.empty, []) | None ->
acc )
in in
SourceFile.Set.iter SourceFile.Set.iter
(fun file -> write_html_file linereader file pdescs_in_cfg) (fun file -> write_html_file linereader file pdescs_in_cfg)
source_files_in_cfg ) source_files_in_cfg

Loading…
Cancel
Save