diff --git a/infer/src/IR/Procdesc.ml b/infer/src/IR/Procdesc.ml index 0737b609d..1a92d3a16 100644 --- a/infer/src/IR/Procdesc.ml +++ b/infer/src/IR/Procdesc.ml @@ -841,15 +841,11 @@ let is_captured_pvar procdesc pvar = in let pvar_matches (name, _) = Mangled.equal name pvar_name in let is_captured_var_cpp_lambda = - match procname with - | Procname.ObjC_Cpp cpp_pname -> - (* var is captured if the procedure is a lambda and the var is not in the locals or formals *) - Procname.ObjC_Cpp.is_cpp_lambda cpp_pname - && not - ( List.exists ~f:pvar_local_matches (get_locals procdesc) - || List.exists ~f:pvar_matches (get_formals procdesc) ) - | _ -> - false + (* var is captured if the procedure is a lambda and the var is not in the locals or formals *) + Procname.is_cpp_lambda procname + && not + ( List.exists ~f:pvar_local_matches (get_locals procdesc) + || List.exists ~f:pvar_matches (get_formals procdesc) ) in let pvar_matches_in_captured {CapturedVar.name} = Mangled.equal name pvar_name in let is_captured_var_objc_block = diff --git a/infer/src/IR/Procname.ml b/infer/src/IR/Procname.ml index d4590c50c..032e90a4f 100644 --- a/infer/src/IR/Procname.ml +++ b/infer/src/IR/Procname.ml @@ -624,6 +624,14 @@ let rec get_method = function (** Return whether the procname is a block procname. *) let is_objc_block = function Block _ -> true | _ -> false +(** Return whether the procname is a cpp lambda procname. *) +let is_cpp_lambda = function + | ObjC_Cpp cpp_pname when ObjC_Cpp.is_cpp_lambda cpp_pname -> + true + | _ -> + false + + (** Return the language of the procedure. *) let get_language = function | ObjC_Cpp _ -> diff --git a/infer/src/IR/Procname.mli b/infer/src/IR/Procname.mli index dba106a32..252ef7e82 100644 --- a/infer/src/IR/Procname.mli +++ b/infer/src/IR/Procname.mli @@ -181,9 +181,6 @@ module ObjC_Cpp : sig val is_constexpr : t -> bool (** Check if this is a constexpr function. *) - - val is_cpp_lambda : t -> bool - (** Return whether the procname is a cpp lambda. *) end module C : sig @@ -316,6 +313,9 @@ val get_method : t -> string val is_objc_block : t -> bool (** Return whether the procname is a block procname. *) +val is_cpp_lambda : t -> bool +(** Return whether the procname is a cpp lambda procname. *) + val is_objc_dealloc : t -> bool (** Return whether the dealloc method of an Objective-C class. *) diff --git a/infer/src/clang/cTrans.ml b/infer/src/clang/cTrans.ml index 89da03a37..402a5656a 100644 --- a/infer/src/clang/cTrans.ml +++ b/infer/src/clang/cTrans.ml @@ -831,17 +831,8 @@ module CTrans_funct (F : CModule_type.CFrontend) : CModule_type.CTranslation = s (* Captured variables without initialization do not have the correct types inside of lambda bodies. The same issue happens for variables captured by reference inside objc blocks. Use the types stored in the procdesc. *) - let is_objc_block_or_cpp_lambda = - match procname with - | Procname.ObjC_Cpp cpp_pname when Procname.ObjC_Cpp.is_cpp_lambda cpp_pname -> - true - | Block _ -> - true - | _ -> - false - in let typ = - if is_objc_block_or_cpp_lambda then + if Procname.is_cpp_lambda procname || Procname.is_objc_block procname then let pvar_name = Pvar.get_name pvar in List.find (Procdesc.get_captured context.procdesc) ~f:(fun {CapturedVar.name= captured_var} -> Mangled.equal captured_var pvar_name) diff --git a/infer/src/concurrency/RacerDFileAnalysis.ml b/infer/src/concurrency/RacerDFileAnalysis.ml index 33e171121..184a4f037 100644 --- a/infer/src/concurrency/RacerDFileAnalysis.ml +++ b/infer/src/concurrency/RacerDFileAnalysis.ml @@ -365,7 +365,7 @@ let should_report_on_proc tenv procdesc = && (not (Procname.Java.is_class_initializer java_pname)) && (not (Procname.Java.is_autogen_method java_pname)) && not (Annotations.pdesc_return_annot_ends_with procdesc Annotations.visibleForTesting) - | ObjC_Cpp objc_cpp when Procname.ObjC_Cpp.is_cpp_lambda objc_cpp -> + | ObjC_Cpp _ when Procname.is_cpp_lambda proc_name -> (* do not report on lambdas; they are essentially private though do not appear as such *) false | ObjC_Cpp {kind= CPPMethod _ | CPPConstructor _ | CPPDestructor _} ->