Don't crash when a cg cannot be loaded.

Summary:
public This assert false causes the whole analysis to crash.
It is currently happening intermittently which makes it hard to debug.
Other inconsistencies don't cause the whole analysis to crash normally,
so this one seems to be too strict.

Reviewed By: cristianoc

Differential Revision: D2849864

fb-gh-sync-id: de6dce0
master
Dulma Rodriguez 9 years ago committed by facebook-github-bot-5
parent 2e7956f384
commit f34f2dcd98

@ -85,29 +85,32 @@ let add_active_proc exe_env proc_name =
(** like add_cg, but use exclude_fun to determine files to be excluded *) (** like add_cg, but use exclude_fun to determine files to be excluded *)
let add_cg_exclude_fun (exe_env: t) (source_dir : DB.source_dir) exclude_fun = let add_cg_exclude_fun (exe_env: t) (source_dir : DB.source_dir) exclude_fun =
let cg_fname = DB.source_dir_get_internal_file source_dir ".cg" in let cg_fname = DB.source_dir_get_internal_file source_dir ".cg" in
let cg = match Cg.load_from_file cg_fname with let cg_opt = match Cg.load_from_file cg_fname with
| None -> (L.err "cannot load %s@." (DB.filename_to_string cg_fname); assert false) | None -> (L.stderr "cannot load %s@." (DB.filename_to_string cg_fname); None)
| Some cg -> | Some cg ->
Cg.restrict_defined cg exe_env.active_opt; Cg.restrict_defined cg exe_env.active_opt;
cg in Some cg in
let source = Cg.get_source cg in match cg_opt with
if exclude_fun source then None | None -> None
else | Some cg ->
let nLOC = Cg.get_nLOC cg in let source = Cg.get_source cg in
Cg.extend exe_env.cg cg; if exclude_fun source then None
let file_data = new_file_data source nLOC cg_fname in else
let defined_procs = Cg.get_defined_nodes cg in let nLOC = Cg.get_nLOC cg in
IList.iter (fun pname -> Cg.extend exe_env.cg cg;
let should_update = let file_data = new_file_data source nLOC cg_fname in
if Procname.Hash.mem exe_env.proc_map pname then let defined_procs = Cg.get_defined_nodes cg in
let old_source = (Procname.Hash.find exe_env.proc_map pname).source in IList.iter (fun pname ->
exe_env.procs_defined_in_several_files <- Procname.Set.add pname exe_env.procs_defined_in_several_files; let should_update =
(* L.err "Warning: procedure %a is defined in both %s and %s@." Procname.pp pname (DB.source_file_to_string source) (DB.source_file_to_string old_source); *) if Procname.Hash.mem exe_env.proc_map pname then
source < old_source (* when a procedure is defined in several files, map to the first alphabetically *) let old_source = (Procname.Hash.find exe_env.proc_map pname).source in
else true in exe_env.procs_defined_in_several_files <- Procname.Set.add pname exe_env.procs_defined_in_several_files;
if should_update then Procname.Hash.replace exe_env.proc_map pname file_data) defined_procs; (* L.err "Warning: procedure %a is defined in both %s and %s@." Procname.pp pname (DB.source_file_to_string source) (DB.source_file_to_string old_source); *)
Hashtbl.add exe_env.file_map source file_data; source < old_source (* when a procedure is defined in several files, map to the first alphabetically *)
Some cg else true in
if should_update then Procname.Hash.replace exe_env.proc_map pname file_data) defined_procs;
Hashtbl.add exe_env.file_map source file_data;
Some cg
(** add call graph from fname in the spec db, with relative tenv and cfg, to the execution environment *) (** add call graph from fname in the spec db, with relative tenv and cfg, to the execution environment *)
let add_cg exe_env (source_dir : DB.source_dir) = let add_cg exe_env (source_dir : DB.source_dir) =

Loading…
Cancel
Save