From b8240eadc1a77eb64d510264522abe814531f9a4 Mon Sep 17 00:00:00 2001 From: Jules Villard Date: Fri, 5 Oct 2018 09:35:06 -0700 Subject: [PATCH] [cfgs] only analyse *defined* procedures Summary: There's nothing to analyse for declared procedures, and if there is then that's because they are defined outside the source file and should not be analysed unless ondemand needs them. Reviewed By: ngorogiannis Differential Revision: D10173353 fbshipit-source-id: 39c42eb7a --- infer/src/IR/Cfg.ml | 4 ++-- infer/src/IR/Cfg.mli | 4 ++-- infer/src/IR/SourceFiles.ml | 3 ++- infer/src/backend/callbacks.ml | 2 +- 4 files changed, 7 insertions(+), 6 deletions(-) diff --git a/infer/src/IR/Cfg.ml b/infer/src/IR/Cfg.ml index cd807dd24..9f9718bd2 100644 --- a/infer/src/IR/Cfg.ml +++ b/infer/src/IR/Cfg.ml @@ -24,9 +24,9 @@ let iter_over_sorted_procs cfg ~f = |> List.iter ~f -let get_all_proc_names cfg = +let get_all_defined_proc_names cfg = let procs = ref [] in - let f pname _ = procs := pname :: !procs in + let f pname pdesc = if Procdesc.is_defined pdesc then procs := pname :: !procs in Typ.Procname.Hash.iter f cfg ; !procs diff --git a/infer/src/IR/Cfg.mli b/infer/src/IR/Cfg.mli index 4340c364e..a837b5e88 100644 --- a/infer/src/IR/Cfg.mli +++ b/infer/src/IR/Cfg.mli @@ -16,8 +16,8 @@ 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_proc_names : t -> Typ.Procname.t list -(** get all the keys from the hashtable *) +val get_all_defined_proc_names : t -> Typ.Procname.t list +(** get all the procedure names that are defined in the current file *) (** {2 Functions for manipulating an interprocedural CFG} *) diff --git a/infer/src/IR/SourceFiles.ml b/infer/src/IR/SourceFiles.ml index 5958ea5b9..c1dcac549 100644 --- a/infer/src/IR/SourceFiles.ml +++ b/infer/src/IR/SourceFiles.ml @@ -65,7 +65,8 @@ let add source_file cfg tenv = Tenv.SQLite.serialize tenv |> Sqlite3.bind store_stmt 3 (* :tenv *) |> SqliteUtils.check_result_code db ~log:"store bind type environment" ; - Cfg.get_all_proc_names cfg |> Typ.Procname.SQLiteList.serialize |> Sqlite3.bind store_stmt 4 + Cfg.get_all_defined_proc_names cfg + |> Typ.Procname.SQLiteList.serialize |> Sqlite3.bind store_stmt 4 (* :proc_names *) |> SqliteUtils.check_result_code db ~log:"store bind proc names" ; Sqlite3.bind store_stmt 5 (Sqlite3.Data.INT Int64.one) diff --git a/infer/src/backend/callbacks.ml b/infer/src/backend/callbacks.ml index 1e157a16b..69f4f1449 100644 --- a/infer/src/backend/callbacks.ml +++ b/infer/src/backend/callbacks.ml @@ -59,7 +59,7 @@ let iterate_procedure_callbacks exe_env summary proc_desc = let get_procs_in_file proc_name = match Exe_env.get_cfg exe_env proc_name with | Some cfg -> - Cfg.get_all_proc_names cfg + Cfg.get_all_defined_proc_names cfg | None -> [] in