From bb90c94939521d0cc7e719ded257d6acc481e3d1 Mon Sep 17 00:00:00 2001 From: Daiva Naudziuniene Date: Fri, 3 Nov 2017 08:57:06 -0700 Subject: [PATCH] [LockConsistency] Checking for both type ObjC_Cpp and C to include c-style functions. Summary: When C++ functions are translated to SIL procedures, their type is C rather then C++. In RacerD, we want to treat C++ functions the same as C++ methods. Added a function to check if the procedure is Objc/Objc++/C/C++. Reviewed By: sblackshear Differential Revision: D6209523 fbshipit-source-id: 293f938 --- infer/src/IR/Typ.ml | 2 ++ infer/src/IR/Typ.mli | 3 +++ infer/src/concurrency/RacerD.ml | 1 - infer/src/concurrency/RacerDConfig.ml | 10 +++++----- 4 files changed, 10 insertions(+), 6 deletions(-) diff --git a/infer/src/IR/Typ.ml b/infer/src/IR/Typ.ml index 783791ecd..85b4c85aa 100644 --- a/infer/src/IR/Typ.ml +++ b/infer/src/IR/Typ.ml @@ -657,6 +657,8 @@ module Procname = struct let is_c_method = function ObjC_Cpp _ -> true | _ -> false + let is_obj_c_pp = function ObjC_Cpp _ | C _ -> true | _ -> false + let is_constexpr = function ObjC_Cpp {kind= CPPConstructor (_, true)} -> true | _ -> false (** Replace the class name component of a procedure name. diff --git a/infer/src/IR/Typ.mli b/infer/src/IR/Typ.mli index 5be448fcb..0e7af475f 100644 --- a/infer/src/IR/Typ.mli +++ b/infer/src/IR/Typ.mli @@ -347,6 +347,9 @@ module Procname : sig val is_c_method : t -> bool (** Check if this is an Objective-C/C++ method name. *) + val is_obj_c_pp : t -> bool + (** Check if this is an Objective-C/C++ method name or C-style function. *) + val is_objc_constructor : string -> bool (** Check if this is a constructor method in Objective-C. *) diff --git a/infer/src/concurrency/RacerD.ml b/infer/src/concurrency/RacerD.ml index 351cba561..b2679a810 100644 --- a/infer/src/concurrency/RacerD.ml +++ b/infer/src/concurrency/RacerD.ml @@ -1723,4 +1723,3 @@ let file_analysis {Callbacks.procedures} = else (module MayAliasQuotientedAccessListMap) ) class_env)) (aggregate_by_class procedures) - diff --git a/infer/src/concurrency/RacerDConfig.ml b/infer/src/concurrency/RacerDConfig.ml index f4f6b9059..2e29077f6 100644 --- a/infer/src/concurrency/RacerDConfig.ml +++ b/infer/src/concurrency/RacerDConfig.ml @@ -133,11 +133,11 @@ module Models = struct Lock | _ -> NoEffect ) - | Typ.Procname.ObjC_Cpp _ as pname when is_cpp_lock pname actuals -> + | Typ.Procname.ObjC_Cpp _ | C _ as pname when is_cpp_lock pname actuals -> Lock - | Typ.Procname.ObjC_Cpp _ as pname when is_cpp_unlock pname -> + | Typ.Procname.ObjC_Cpp _ | C _ as pname when is_cpp_unlock pname -> Unlock - | Typ.Procname.ObjC_Cpp _ as pname when is_cpp_trylock pname -> + | Typ.Procname.ObjC_Cpp _ | C _ as pname when is_cpp_trylock pname -> LockedIfTrue | pname when Typ.Procname.equal pname BuiltinDecl.__set_locked_attribute -> Lock @@ -198,9 +198,9 @@ module Models = struct None in PatternMatch.supertype_find_map_opt tenv get_container_access_ typename - | Typ.Procname.ObjC_Cpp _ as pname when is_cpp_container_read pname -> + | Typ.Procname.ObjC_Cpp _ | C _ as pname when is_cpp_container_read pname -> Some ContainerRead - | Typ.Procname.ObjC_Cpp _ as pname when is_cpp_container_write pname -> + | Typ.Procname.ObjC_Cpp _ | C _ as pname when is_cpp_container_write pname -> Some ContainerWrite | _ -> None