diff --git a/infer/src/IR/Location.re b/infer/src/IR/Location.re index 498a387c2..c03732a2a 100644 --- a/infer/src/IR/Location.re +++ b/infer/src/IR/Location.re @@ -27,9 +27,11 @@ let equal = [%compare.equal : t]; /** Dump a location */ let d (loc: t) => L.add_print_action (L.PTloc, Obj.repr loc); +let none file => {line: (-1), col: (-1), file}; + /** Dummy location */ -let dummy = {line: (-1), col: (-1), file: SourceFile.invalid}; +let dummy = none SourceFile.invalid; /** Pretty print a location */ diff --git a/infer/src/IR/Location.rei b/infer/src/IR/Location.rei index ce7333526..4b89eed4e 100644 --- a/infer/src/IR/Location.rei +++ b/infer/src/IR/Location.rei @@ -24,7 +24,11 @@ let equal: t => t => bool; let d: t => unit; -/** Dummy location */ +/** Dummy source location for the given file */ +let none: SourceFile.t => t; + + +/** Dummy location with no source file */ let dummy: t; diff --git a/infer/src/backend/specs.ml b/infer/src/backend/specs.ml index a3c8b99a1..07386a6e7 100644 --- a/infer/src/backend/specs.ml +++ b/infer/src/backend/specs.ml @@ -733,7 +733,11 @@ let reset_summary proc_name attributes_opt proc_desc_option = | Some attributes -> attributes | None -> - ProcAttributes.default proc_name !Config.curr_language in + begin + match proc_desc_option with + | Some proc_desc -> Procdesc.get_attributes proc_desc + | None -> ProcAttributes.default proc_name !Config.curr_language + end in init_summary ( [], ProcAttributes.proc_flags_empty (), diff --git a/infer/src/clang/cMethod_trans.ml b/infer/src/clang/cMethod_trans.ml index cbea2213f..b0eb10132 100644 --- a/infer/src/clang/cMethod_trans.ml +++ b/infer/src/clang/cMethod_trans.ml @@ -444,12 +444,10 @@ let create_external_procdesc cfg proc_name is_objc_inst_method type_opt = | Some (ret_type, arg_types) -> ret_type, List.map ~f:(fun typ -> (Mangled.from_string "x", typ)) arg_types | None -> Typ.mk Typ.Tvoid, []) in - let loc = Location.dummy in let proc_attributes = { (ProcAttributes.default proc_name Config.Clang) with ProcAttributes.formals; is_objc_instance_method = is_objc_inst_method; - loc; ret_type; } in ignore (Cfg.create_proc_desc cfg proc_attributes) @@ -476,7 +474,7 @@ let add_default_method_for_class trans_unit_ctx class_name decl_info = let loc = CLocation.get_sil_location_from_range trans_unit_ctx decl_info.Clang_ast_t.di_source_range true in let proc_name = Typ.Procname.get_default_objc_class_method class_name in - let attrs = { (ProcAttributes.default proc_name Config.Clang) with loc = loc; } in + let attrs = { (ProcAttributes.default proc_name Config.Clang) with loc; } in AttributesTable.store_attributes attrs let get_procname_from_cpp_lambda context dec = diff --git a/infer/src/java/jFrontend.ml b/infer/src/java/jFrontend.ml index 441316421..0881100b3 100644 --- a/infer/src/java/jFrontend.ml +++ b/infer/src/java/jFrontend.ml @@ -153,9 +153,9 @@ let create_icfg source_file linereader program icfg cn node = begin match m with | Javalib.AbstractMethod am -> - ignore (JTrans.create_am_procdesc program icfg am proc_name) + ignore (JTrans.create_am_procdesc source_file program icfg am proc_name) | Javalib.ConcreteMethod cm when JTrans.is_java_native cm -> - ignore (JTrans.create_native_procdesc program icfg cm proc_name) + ignore (JTrans.create_native_procdesc source_file program icfg cm proc_name) | Javalib.ConcreteMethod cm -> add_cmethod source_file program linereader icfg cm proc_name end; diff --git a/infer/src/java/jTrans.ml b/infer/src/java/jTrans.ml index 358d1c12b..d6066b4dd 100644 --- a/infer/src/java/jTrans.ml +++ b/infer/src/java/jTrans.ml @@ -273,7 +273,7 @@ let trans_access = function | `Private -> PredSymb.Private | `Protected -> PredSymb.Protected -let create_am_procdesc program icfg am proc_name : Procdesc.t = +let create_am_procdesc source_file program icfg am proc_name : Procdesc.t = let cfg = icfg.JContext.cfg in let tenv = icfg.JContext.tenv in let m = Javalib.AbstractMethod am in @@ -295,18 +295,19 @@ let create_am_procdesc program icfg am proc_name : Procdesc.t = is_synthetic_method = am.Javalib.am_synthetic; method_annotation; ret_type = JTransType.return_type program tenv ms; + loc = Location.none source_file; } in Cfg.create_proc_desc cfg proc_attributes in let start_kind = Procdesc.Node.Start_node proc_name in - let start_node = Procdesc.create_node procdesc Location.dummy start_kind [] in + let start_node = Procdesc.create_node procdesc (Location.none source_file) start_kind [] in let exit_kind = (Procdesc.Node.Exit_node proc_name) in - let exit_node = Procdesc.create_node procdesc Location.dummy exit_kind [] in + let exit_node = Procdesc.create_node procdesc (Location.none source_file) exit_kind [] in Procdesc.node_set_succs_exn procdesc start_node [exit_node] [exit_node]; Procdesc.set_start_node procdesc start_node; Procdesc.set_exit_node procdesc exit_node; procdesc -let create_native_procdesc program icfg cm proc_name = +let create_native_procdesc source_file program icfg cm proc_name = let cfg = icfg.JContext.cfg in let tenv = icfg.JContext.tenv in let m = Javalib.ConcreteMethod cm in @@ -325,6 +326,7 @@ let create_native_procdesc program icfg cm proc_name = is_synthetic_method = cm.Javalib.cm_synthetic; method_annotation; ret_type = JTransType.return_type program tenv ms; + loc = Location.none source_file; } in Cfg.create_proc_desc cfg proc_attributes diff --git a/infer/src/java/jTrans.mli b/infer/src/java/jTrans.mli index 4bb08a5ab..8f85a80a2 100644 --- a/infer/src/java/jTrans.mli +++ b/infer/src/java/jTrans.mli @@ -24,10 +24,16 @@ val is_java_native : JCode.jcode Javalib.concrete_method -> bool (** Create the procedure description for an abstract method *) val create_am_procdesc : - JClasspath.program -> JContext.icfg -> Javalib.abstract_method -> Typ.Procname.t -> Procdesc.t + SourceFile.t -> + JClasspath.program -> + JContext.icfg -> + Javalib.abstract_method -> + Typ.Procname.t -> + Procdesc.t (** Create the procedure description for a concrete method *) val create_native_procdesc : + SourceFile.t -> JClasspath.program -> JContext.icfg -> JCode.jcode Javalib.concrete_method -> diff --git a/infer/src/java/jTransExn.ml b/infer/src/java/jTransExn.ml index 069d54160..fe34bf772 100644 --- a/infer/src/java/jTransExn.ml +++ b/infer/src/java/jTransExn.ml @@ -57,7 +57,7 @@ let translate_exceptions (context : JContext.t) exit_nodes get_body_nodes handle let catch_nodes = get_body_nodes handler.JBir.e_handler in let loc = match catch_nodes with | n:: _ -> Procdesc.Node.get_loc n - | [] -> Location.dummy in + | [] -> Location.none context.source_file in let exn_type = let class_name = match handler.JBir.e_catch_type with @@ -109,7 +109,7 @@ let translate_exceptions (context : JContext.t) exit_nodes get_body_nodes handle List.fold ~f:process_handler ~init:exit_nodes (List.rev handler_list) in let loc = match nodes_first_handler with | n:: _ -> Procdesc.Node.get_loc n - | [] -> Location.dummy in + | [] -> Location.none context.source_file in let entry_node = create_entry_node loc in Procdesc.node_set_succs_exn procdesc entry_node nodes_first_handler exit_nodes; Hashtbl.add catch_block_table handler_list [entry_node] in