diff --git a/infer/src/IR/Procname.ml b/infer/src/IR/Procname.ml index 6c97f9b42..7d3e03057 100644 --- a/infer/src/IR/Procname.ml +++ b/infer/src/IR/Procname.ml @@ -357,9 +357,9 @@ module ObjC_Cpp = struct if is_instance then ObjCInstanceMethod else ObjCClassMethod - let is_objc_constructor method_name = - String.equal method_name "new" || String.is_prefix ~prefix:"init" method_name + let is_prefix_init s = String.is_prefix ~prefix:"init" s + let is_objc_constructor method_name = String.equal method_name "new" || is_prefix_init method_name let is_objc_kind = function | ObjCClassMethod | ObjCInstanceMethod | ObjCInternalMethod -> @@ -605,6 +605,12 @@ let is_objc_dealloc procname = match procname with ObjC_Cpp {method_name} -> ObjC_Cpp.is_objc_dealloc method_name | _ -> false +let is_objc_init procname = + is_objc_method procname + && + match procname with ObjC_Cpp {method_name} -> ObjC_Cpp.is_prefix_init method_name | _ -> false + + let block_of_procname procname = match procname with | Block block -> diff --git a/infer/src/IR/Procname.mli b/infer/src/IR/Procname.mli index b1a70f722..9c31eba2e 100644 --- a/infer/src/IR/Procname.mli +++ b/infer/src/IR/Procname.mli @@ -326,6 +326,9 @@ val is_cpp_lambda : t -> bool val is_objc_dealloc : t -> bool (** Return whether the dealloc method of an Objective-C class. *) +val is_objc_init : t -> bool +(** Return whether the init method of an Objective-C class. *) + val is_c_method : t -> bool (** Return true this is an Objective-C/C++ method name. *) diff --git a/infer/src/cost/ConfigImpactAnalysis.ml b/infer/src/cost/ConfigImpactAnalysis.ml index 88b863934..589b71928 100644 --- a/infer/src/cost/ConfigImpactAnalysis.ml +++ b/infer/src/cost/ConfigImpactAnalysis.ml @@ -447,6 +447,9 @@ module Dom = struct join_unchecked_callees (UncheckedCallees.replace_location_by_call location callee_summary) (UncheckedCalleesCond.replace_location_by_call location callee_summary_cond) + | None when Procname.is_objc_init callee -> + (* If callee is unknown ObjC initializer, ignore it. *) + astate | _ -> (* Otherwise, add callee's name. *) join_unchecked_callees