From 45d5d878cf583c36ea54a086037a2997c9b76ad5 Mon Sep 17 00:00:00 2001 From: Jules Villard Date: Mon, 13 Nov 2017 03:34:59 -0800 Subject: [PATCH] [cfg] minor renamings Summary: `type Cfg.cfg` -> `type Cfg.t` `Cfg.{load,store}_cfg_*` -> `Cfg.{load_store}_*` Some comment movements that agree with `ocamlformat` more. Reviewed By: jberdine Differential Revision: D6296899 fbshipit-source-id: d4a5e9e --- infer/src/IR/Cfg.ml | 10 +++---- infer/src/IR/Cfg.mli | 28 +++++++++---------- infer/src/backend/dotty.mli | 2 +- infer/src/backend/exe_env.ml | 4 +-- infer/src/backend/exe_env.mli | 4 +-- infer/src/checkers/NullabilityPreanalysis.mli | 8 +++--- infer/src/clang/cContext.ml | 2 +- infer/src/clang/cContext.mli | 8 +++--- infer/src/clang/cFrontend.ml | 2 +- infer/src/clang/cMethod_trans.mli | 4 +-- infer/src/clang/cModule_type.ml | 4 +-- infer/src/harness/harness.mli | 2 +- infer/src/harness/inhabit.mli | 2 +- infer/src/java/jContext.ml | 2 +- infer/src/java/jContext.mli | 4 +-- infer/src/java/jFrontend.mli | 4 +-- infer/src/java/jMain.ml | 2 +- 17 files changed, 46 insertions(+), 46 deletions(-) diff --git a/infer/src/IR/Cfg.ml b/infer/src/IR/Cfg.ml index fd201b570..712de592e 100644 --- a/infer/src/IR/Cfg.ml +++ b/infer/src/IR/Cfg.ml @@ -13,7 +13,7 @@ module L = Logging module F = Format (** data type for the control flow graph *) -type cfg = {proc_desc_table: Procdesc.t Typ.Procname.Hash.t (** Map proc name to procdesc *)} +type t = {proc_desc_table: Procdesc.t Typ.Procname.Hash.t (** Map proc name to procdesc *)} (** create a new empty cfg *) let create_cfg () = {proc_desc_table= Typ.Procname.Hash.create 16} @@ -95,12 +95,12 @@ let check_cfg_connectedness cfg = (** Serializer for control flow graphs *) -let cfg_serializer : cfg Serialization.serializer = +let cfg_serializer : t Serialization.serializer = Serialization.create_serializer Serialization.Key.cfg (** Load a cfg from a file *) -let load_cfg_from_file (filename: DB.filename) : cfg option = +let load_from_file (filename: DB.filename) : t option = Serialization.read_from_file cfg_serializer filename @@ -276,10 +276,10 @@ let mark_unchanged_pdescs cfg_new cfg_old = (** Save a cfg into a file *) -let store_cfg_to_file ~source_file (filename: DB.filename) (cfg: cfg) = +let store_to_file ~source_file (filename: DB.filename) (cfg: t) = inline_java_synthetic_methods cfg ; ( if Config.incremental_procs then - match load_cfg_from_file filename with + match load_from_file filename with | Some old_cfg -> mark_unchanged_pdescs cfg old_cfg | None -> diff --git a/infer/src/IR/Cfg.mli b/infer/src/IR/Cfg.mli index 6b604c17a..8c91f9a2e 100644 --- a/infer/src/IR/Cfg.mli +++ b/infer/src/IR/Cfg.mli @@ -13,41 +13,41 @@ open! IStd (** Control Flow Graph for Interprocedural Analysis *) (** A control-flow graph *) -type cfg +type t -val load_cfg_from_file : DB.filename -> cfg option +val load_from_file : DB.filename -> t option (** Load a cfg from a file *) -val store_cfg_to_file : source_file:SourceFile.t -> DB.filename -> cfg -> unit -(** Save a cfg into a file, and save a copy of the source files if the boolean is true *) +val store_to_file : source_file:SourceFile.t -> DB.filename -> t -> unit +(** Save a cfg into a file *) (** {2 Functions for manipulating an interprocedural CFG} *) -val create_cfg : unit -> cfg +val create_cfg : unit -> t (** create a new empty cfg *) -val create_proc_desc : cfg -> ProcAttributes.t -> Procdesc.t +val create_proc_desc : t -> ProcAttributes.t -> Procdesc.t (** Create a new procdesc *) -val iter_proc_desc : cfg -> (Typ.Procname.t -> Procdesc.t -> unit) -> unit +val iter_proc_desc : t -> (Typ.Procname.t -> Procdesc.t -> unit) -> unit (** Iterate over all the procdesc's *) -val find_proc_desc_from_name : cfg -> Typ.Procname.t -> Procdesc.t option +val find_proc_desc_from_name : t -> Typ.Procname.t -> Procdesc.t option (** Find the procdesc given the proc name. Return None if not found. *) -val get_all_procs : cfg -> Procdesc.t list +val get_all_procs : t -> Procdesc.t list (** Get all the procedures (defined and declared) *) -val get_defined_procs : cfg -> Procdesc.t list +val get_defined_procs : t -> Procdesc.t list (** Get the procedures whose body is defined in this cfg *) -val iter_all_nodes : ?sorted:bool -> (Procdesc.t -> Procdesc.Node.t -> unit) -> cfg -> unit +val iter_all_nodes : ?sorted:bool -> (Procdesc.t -> Procdesc.Node.t -> unit) -> t -> unit (** Iterate over all the nodes in the cfg *) -val check_cfg_connectedness : cfg -> unit +val check_cfg_connectedness : t -> unit (** checks whether a cfg is connected or not *) -val remove_proc_desc : cfg -> Typ.Procname.t -> unit +val remove_proc_desc : t -> Typ.Procname.t -> unit (** Remove the procdesc from the control flow graph. *) val specialize_types : Procdesc.t -> Typ.Procname.t -> (Exp.t * Typ.t) list -> Procdesc.t @@ -64,4 +64,4 @@ val specialize_with_block_args : b) the parameters of the method are extended with parameters for the captured variables in the closures *) -val pp_proc_signatures : Format.formatter -> cfg -> unit +val pp_proc_signatures : Format.formatter -> t -> unit diff --git a/infer/src/backend/dotty.mli b/infer/src/backend/dotty.mli index 4cb250c86..aea4023af 100644 --- a/infer/src/backend/dotty.mli +++ b/infer/src/backend/dotty.mli @@ -34,7 +34,7 @@ val pp_proplist_parsed2dotty_file : string -> Prop.normal Prop.t list -> unit (** {2 Contol-Flow Graph} *) -val print_icfg_dotty : SourceFile.t -> Cfg.cfg -> unit +val print_icfg_dotty : SourceFile.t -> Cfg.t -> unit (** Print the cfg *) val reset_dotty_spec_counter : unit -> unit diff --git a/infer/src/backend/exe_env.ml b/infer/src/backend/exe_env.ml index bd88c8836..596f9f141 100644 --- a/infer/src/backend/exe_env.ml +++ b/infer/src/backend/exe_env.ml @@ -23,7 +23,7 @@ type file_data = ; tenv_file: DB.filename ; mutable tenv: Tenv.t option ; cfg_file: DB.filename - ; mutable cfg: Cfg.cfg option } + ; mutable cfg: Cfg.t option } (** get the path to the tenv file, which either one tenv file per source file or a global tenv file *) let tenv_filename file_base = @@ -151,7 +151,7 @@ let file_data_to_tenv file_data = let file_data_to_cfg file_data = - if is_none file_data.cfg then file_data.cfg <- Cfg.load_cfg_from_file file_data.cfg_file ; + if is_none file_data.cfg then file_data.cfg <- Cfg.load_from_file file_data.cfg_file ; file_data.cfg diff --git a/infer/src/backend/exe_env.mli b/infer/src/backend/exe_env.mli index 0eed6be82..70241fb92 100644 --- a/infer/src/backend/exe_env.mli +++ b/infer/src/backend/exe_env.mli @@ -34,11 +34,11 @@ val get_source : t -> Typ.Procname.t -> SourceFile.t option val get_tenv : t -> Typ.Procname.t -> Tenv.t (** return the type environment associated to the procedure *) -val get_cfg : t -> Typ.Procname.t -> Cfg.cfg option +val get_cfg : t -> Typ.Procname.t -> Cfg.t option (** return the cfg associated to the procedure *) val get_proc_desc : t -> Typ.Procname.t -> Procdesc.t option (** return the proc desc associated to the procedure *) -val iter_files : (SourceFile.t -> Cfg.cfg -> unit) -> t -> unit +val iter_files : (SourceFile.t -> Cfg.t -> unit) -> t -> unit (** [iter_files f exe_env] applies [f] to the source file and tenv and cfg for each file in [exe_env] *) diff --git a/infer/src/checkers/NullabilityPreanalysis.mli b/infer/src/checkers/NullabilityPreanalysis.mli index 66942596b..64a6d00dc 100644 --- a/infer/src/checkers/NullabilityPreanalysis.mli +++ b/infer/src/checkers/NullabilityPreanalysis.mli @@ -6,10 +6,10 @@ * LICENSE file in the root directory of this source tree. An additional grant * of patent rights can be found in the PATENTS file in the same directory. *) -(* Module that define preanalysis to derive nullability annotations *) -open! IStd +(** Module that define preanalysis to derive nullability annotations *) -(* Analysis the cfg and updates the tenv with nullability annotations *) +open! IStd -val analysis : Cfg.cfg -> Tenv.t -> unit +val analysis : Cfg.t -> Tenv.t -> unit +(** Analysis the cfg and updates the tenv with nullability annotations *) diff --git a/infer/src/clang/cContext.ml b/infer/src/clang/cContext.ml index bfe2e23f0..716539aa2 100644 --- a/infer/src/clang/cContext.ml +++ b/infer/src/clang/cContext.ml @@ -31,7 +31,7 @@ type t = { translation_unit_context: CFrontend_config.translation_unit_context ; tenv: Tenv.t ; cg: Cg.t - ; cfg: Cfg.cfg + ; cfg: Cfg.t ; procdesc: Procdesc.t ; is_objc_method: bool ; curr_class: curr_class diff --git a/infer/src/clang/cContext.mli b/infer/src/clang/cContext.mli index 95862fb3c..c3fcb8e6e 100644 --- a/infer/src/clang/cContext.mli +++ b/infer/src/clang/cContext.mli @@ -25,7 +25,7 @@ type t = { translation_unit_context: CFrontend_config.translation_unit_context ; tenv: Tenv.t ; cg: Cg.t - ; cfg: Cfg.cfg + ; cfg: Cfg.t ; procdesc: Procdesc.t ; is_objc_method: bool ; curr_class: curr_class @@ -41,7 +41,7 @@ type t = val get_procdesc : t -> Procdesc.t -val get_cfg : t -> Cfg.cfg +val get_cfg : t -> Cfg.t val get_cg : t -> Cg.t @@ -58,8 +58,8 @@ val is_objc_method : t -> bool val get_tenv : t -> Tenv.t val create_context : - CFrontend_config.translation_unit_context -> Tenv.t -> Cg.t -> Cfg.cfg -> Procdesc.t - -> curr_class -> Typ.t option -> bool -> t option -> Clang_ast_t.decl list StmtMap.t -> t + CFrontend_config.translation_unit_context -> Tenv.t -> Cg.t -> Cfg.t -> Procdesc.t -> curr_class + -> Typ.t option -> bool -> t option -> Clang_ast_t.decl list StmtMap.t -> t val add_block_static_var : t -> Typ.Procname.t -> Pvar.t * Typ.t -> unit diff --git a/infer/src/clang/cFrontend.ml b/infer/src/clang/cFrontend.ml index aec2d7716..9327a0613 100644 --- a/infer/src/clang/cFrontend.ml +++ b/infer/src/clang/cFrontend.ml @@ -59,7 +59,7 @@ let do_source_file translation_unit_context ast = let cg_file = DB.source_dir_get_internal_file source_dir ".cg" in NullabilityPreanalysis.analysis cfg tenv ; Cg.store_to_file cg_file call_graph ; - Cfg.store_cfg_to_file ~source_file cfg_file cfg ; + Cfg.store_to_file ~source_file cfg_file cfg ; Tenv.sort_fields_tenv tenv ; Tenv.store_to_file tenv_file tenv ; if Config.stats_mode then Cfg.check_cfg_connectedness cfg ; diff --git a/infer/src/clang/cMethod_trans.mli b/infer/src/clang/cMethod_trans.mli index d137d5815..7882f93a1 100644 --- a/infer/src/clang/cMethod_trans.mli +++ b/infer/src/clang/cMethod_trans.mli @@ -23,12 +23,12 @@ val equal_method_call_type : method_call_type -> method_call_type -> bool val should_add_return_param : Typ.t -> is_objc_method:bool -> bool val create_local_procdesc : - ?set_objc_accessor_attr:bool -> CFrontend_config.translation_unit_context -> Cfg.cfg -> Tenv.t + ?set_objc_accessor_attr:bool -> CFrontend_config.translation_unit_context -> Cfg.t -> Tenv.t -> CMethod_signature.method_signature -> Clang_ast_t.stmt list -> (Pvar.t * Typ.t) list -> bool -> bool val create_external_procdesc : - Cfg.cfg -> Typ.Procname.t -> bool -> (Typ.t * Typ.t list) option -> unit + Cfg.t -> Typ.Procname.t -> bool -> (Typ.t * Typ.t list) option -> unit val get_objc_method_data : Clang_ast_t.obj_c_message_expr_info -> string * Clang_ast_t.pointer option * method_call_type diff --git a/infer/src/clang/cModule_type.ml b/infer/src/clang/cModule_type.ml index 46634b788..706555d44 100644 --- a/infer/src/clang/cModule_type.ml +++ b/infer/src/clang/cModule_type.ml @@ -29,10 +29,10 @@ end module type CFrontend = sig val function_decl : - CFrontend_config.translation_unit_context -> Tenv.t -> Cfg.cfg -> Cg.t -> Clang_ast_t.decl + CFrontend_config.translation_unit_context -> Tenv.t -> Cfg.t -> Cg.t -> Clang_ast_t.decl -> block_data option -> unit val translate_one_declaration : - CFrontend_config.translation_unit_context -> Tenv.t -> Cg.t -> Cfg.cfg -> decl_trans_context + CFrontend_config.translation_unit_context -> Tenv.t -> Cg.t -> Cfg.t -> decl_trans_context -> Clang_ast_t.decl -> unit end diff --git a/infer/src/harness/harness.mli b/infer/src/harness/harness.mli index bddf06cf8..02bdba805 100644 --- a/infer/src/harness/harness.mli +++ b/infer/src/harness/harness.mli @@ -11,5 +11,5 @@ open! IStd (** Automatically create a harness method to exercise code under test *) -val create_harness : Cfg.cfg -> Cg.t -> Tenv.t -> unit +val create_harness : Cfg.t -> Cg.t -> Tenv.t -> unit (** Generate a harness method for exe_env and add it to the execution environment *) diff --git a/infer/src/harness/inhabit.mli b/infer/src/harness/inhabit.mli index 1f692e5b0..dab2b8c04 100644 --- a/infer/src/harness/inhabit.mli +++ b/infer/src/harness/inhabit.mli @@ -13,6 +13,6 @@ open! IStd type lifecycle_trace = (Typ.Procname.t * Typ.t option) list -val inhabit_trace : Tenv.t -> lifecycle_trace -> Typ.Procname.java -> Cg.t -> Cfg.cfg -> unit +val inhabit_trace : Tenv.t -> lifecycle_trace -> Typ.Procname.java -> Cg.t -> Cfg.t -> unit (** create a procedure named harness_name that calls each of the methods in trace add it to the cg/cfg *) diff --git a/infer/src/java/jContext.ml b/infer/src/java/jContext.ml index 12f49a0f0..9f90809cc 100644 --- a/infer/src/java/jContext.ml +++ b/infer/src/java/jContext.ml @@ -17,7 +17,7 @@ module NodeTbl = Procdesc.NodeHash type jump_kind = Next | Jump of int | Exit (** Translation data *) -type icfg = {tenv: Tenv.t; cg: Cg.t; cfg: Cfg.cfg} +type icfg = {tenv: Tenv.t; cg: Cg.t; cfg: Cfg.t} type t = { icfg: icfg diff --git a/infer/src/java/jContext.mli b/infer/src/java/jContext.mli index 7299c0a05..80c692382 100644 --- a/infer/src/java/jContext.mli +++ b/infer/src/java/jContext.mli @@ -22,7 +22,7 @@ module NodeTbl : Caml.Hashtbl.S with type key = Procdesc.Node.t (** data structure for saving the three structures tht contain the intermediate representation of a file: the type environment, the control graph and the control flow graph *) -type icfg = {tenv: Tenv.t; cg: Cg.t; cfg: Cfg.cfg} +type icfg = {tenv: Tenv.t; cg: Cg.t; cfg: Cfg.t} (** data structure for storing the context elements. *) type t = private @@ -46,7 +46,7 @@ val get_tenv : t -> Tenv.t val get_cg : t -> Cg.t (** returns the control graph that corresponds to the current file. *) -val get_cfg : t -> Cfg.cfg +val get_cfg : t -> Cfg.t (** returns the control flow graph that corresponds to the current file. *) val add_if_jump : t -> Procdesc.Node.t -> int -> unit diff --git a/infer/src/java/jFrontend.mli b/infer/src/java/jFrontend.mli index 53f6392dd..8967e44bf 100644 --- a/infer/src/java/jFrontend.mli +++ b/infer/src/java/jFrontend.mli @@ -22,10 +22,10 @@ val is_classname_cached : JBasics.class_name -> bool val compute_source_icfg : Printer.LineReader.t -> JBasics.ClassSet.t -> JClasspath.program -> Tenv.t -> string - -> string option -> SourceFile.t -> Cg.t * Cfg.cfg + -> string option -> SourceFile.t -> Cg.t * Cfg.t (** [compute_icfg linereader classes program tenv source_basename source_file] create the call graph and control flow graph for the file [source_file] by translating all the classes in [program] originating from [source_file] *) val compute_class_icfg : SourceFile.t -> Printer.LineReader.t -> JClasspath.program -> Tenv.t - -> JCode.jcode Javalib.interface_or_class -> Cg.t * Cfg.cfg + -> JCode.jcode Javalib.interface_or_class -> Cg.t * Cfg.t (** Compute the CFG for a class *) diff --git a/infer/src/java/jMain.ml b/infer/src/java/jMain.ml index 6f6fbdf8a..6b5087f04 100644 --- a/infer/src/java/jMain.ml +++ b/infer/src/java/jMain.ml @@ -34,7 +34,7 @@ let store_icfg source_file tenv cg cfg = let cg_file = DB.source_dir_get_internal_file source_dir ".cg" in if Config.create_harness then Harness.create_harness cfg cg tenv ; Cg.store_to_file cg_file cg ; - Cfg.store_cfg_to_file ~source_file cfg_file cfg ; + Cfg.store_to_file ~source_file cfg_file cfg ; if Config.debug_mode || Config.frontend_tests then ( Dotty.print_icfg_dotty source_file cfg ; Cg.save_call_graph_dotty source_file cg ) ;