diff --git a/infer/man/man1/infer-analyze.txt b/infer/man/man1/infer-analyze.txt index 9ec8fa6fd..5581b443c 100644 --- a/infer/man/man1/infer-analyze.txt +++ b/infer/man/man1/infer-analyze.txt @@ -431,8 +431,7 @@ RACERD CHECKER OPTIONS --no-racerd-guardedby) --no-racerd-unknown-returns-owned - Deactivates: Assume that all methods without a CFG (including - abstract methods) return owned objects (Conversely: + Deactivates: DEPRECATED, does nothing. (Conversely: --racerd-unknown-returns-owned) --threadsafe-aliases json diff --git a/infer/man/man1/infer-full.txt b/infer/man/man1/infer-full.txt index 231202a34..4049e2d27 100644 --- a/infer/man/man1/infer-full.txt +++ b/infer/man/man1/infer-full.txt @@ -911,8 +911,7 @@ OPTIONS (Conversely: --no-racerd-only) See also infer-analyze(1). --no-racerd-unknown-returns-owned - Deactivates: Assume that all methods without a CFG (including - abstract methods) return owned objects (Conversely: + Deactivates: DEPRECATED, does nothing. (Conversely: --racerd-unknown-returns-owned) See also infer-analyze(1). --reactive,-r diff --git a/infer/man/man1/infer.txt b/infer/man/man1/infer.txt index 94545a5d1..5f1a7cd6c 100644 --- a/infer/man/man1/infer.txt +++ b/infer/man/man1/infer.txt @@ -911,8 +911,7 @@ OPTIONS (Conversely: --no-racerd-only) See also infer-analyze(1). --no-racerd-unknown-returns-owned - Deactivates: Assume that all methods without a CFG (including - abstract methods) return owned objects (Conversely: + Deactivates: DEPRECATED, does nothing. (Conversely: --racerd-unknown-returns-owned) See also infer-analyze(1). --reactive,-r diff --git a/infer/src/base/Config.ml b/infer/src/base/Config.ml index 8c63925e5..e08062237 100644 --- a/infer/src/base/Config.ml +++ b/infer/src/base/Config.ml @@ -1829,10 +1829,11 @@ and racerd_guardedby = "Check @GuardedBy annotations with RacerD" -and racerd_unknown_returns_owned = - CLOpt.mk_bool ~long:"racerd-unknown-returns-owned" ~default:true +and[@warning "-32"] racerd_unknown_returns_owned = + CLOpt.mk_bool ~deprecated:["racerd-unknown-returns-owned"] ~long:"racerd-unknown-returns-owned" + ~default:true ~in_help:InferCommand.[(Analyze, manual_racerd)] - "Assume that all methods without a CFG (including abstract methods) return owned objects" + "DEPRECATED, does nothing." and reactive = @@ -2879,8 +2880,6 @@ and quiet = !quiet and racerd_guardedby = !racerd_guardedby -and racerd_unknown_returns_owned = !racerd_unknown_returns_owned - and reactive_mode = !reactive and reactive_capture = !reactive_capture diff --git a/infer/src/base/Config.mli b/infer/src/base/Config.mli index c23ed8b19..fc10946c9 100644 --- a/infer/src/base/Config.mli +++ b/infer/src/base/Config.mli @@ -469,8 +469,6 @@ val quiet : bool val racerd_guardedby : bool -val racerd_unknown_returns_owned : bool - val reactive_capture : bool val reactive_mode : bool diff --git a/infer/src/concurrency/RacerD.ml b/infer/src/concurrency/RacerD.ml index 8fd3c46d8..c0142f872 100644 --- a/infer/src/concurrency/RacerD.ml +++ b/infer/src/concurrency/RacerD.ml @@ -149,22 +149,9 @@ module TransferFunctions (CFG : ProcCfg.S) = struct AccessDomain.fold update_callee_access callee_accesses caller_astate.accesses - let call_without_summary tenv callee_pname ret_base call_flags actuals astate = + let call_without_summary tenv callee_pname ret_base actuals astate = let open RacerDModels in let open RacerDDomain in - let should_assume_returns_ownership callee_pname (call_flags : CallFlags.t) actuals = - Config.racerd_unknown_returns_owned - (* non-interface methods with no summary and no parameters *) - || ((not call_flags.cf_interface) && List.is_empty actuals) - || (* static [$Builder] creation methods *) - creates_builder callee_pname - in - let should_assume_returns_conditional_ownership callee_pname = - (* non-interface methods with no parameters *) - is_abstract_getthis_like callee_pname - || (* non-static [$Builder] methods with same return type as receiver type *) - is_builder_passthrough callee_pname - in if RacerDModels.is_synchronized_container_constructor tenv callee_pname actuals then List.hd actuals |> Option.bind ~f:get_access_exp |> Option.value_map ~default:astate ~f:(fun receiver -> @@ -188,22 +175,12 @@ module TransferFunctions (CFG : ProcCfg.S) = struct {astate with attribute_map} | _ -> astate - else if should_assume_returns_ownership callee_pname call_flags actuals then + else let ownership = OwnershipDomain.add (AccessExpression.base ret_base) OwnershipAbstractValue.owned astate.ownership in {astate with ownership} - else if should_assume_returns_conditional_ownership callee_pname then - (* assume abstract, single-parameter methods whose return type is equal to that of the first - formal return conditional ownership -- an example is getThis in Litho *) - let ownership = - OwnershipDomain.add (AccessExpression.base ret_base) - (OwnershipAbstractValue.make_owned_if 0) - astate.ownership - in - {astate with ownership} - else astate let treat_call_acquiring_ownership ret_base procname actuals loc @@ -321,7 +298,7 @@ module TransferFunctions (CFG : ProcCfg.S) = struct in {locks; threads; accesses; ownership; attribute_map} | None -> - call_without_summary tenv callee_pname ret_base call_flags actuals astate ) + call_without_summary tenv callee_pname ret_base actuals astate ) in let add_if_annotated predicate attribute attribute_map = if PatternMatch.override_exists predicate tenv callee_pname then diff --git a/infer/src/concurrency/RacerDModels.ml b/infer/src/concurrency/RacerDModels.ml index 8cb9a8c83..1cd5f80f8 100644 --- a/infer/src/concurrency/RacerDModels.ml +++ b/infer/src/concurrency/RacerDModels.ml @@ -513,47 +513,5 @@ let is_synchronized_container callee_pname (access_exp : HilExp.AccessExpression false -(** check that callee is abstract and accepts one argument. In addition, its argument type must be - equal to its return type. *) -let is_abstract_getthis_like callee = - attrs_of_pname callee - |> Option.exists ~f:(fun (attrs : ProcAttributes.t) -> - attrs.is_abstract - && - match attrs.formals with - | [(_, typ)] when Typ.equal typ attrs.ret_type -> - true - | _ -> - false ) - - -let creates_builder callee = - (match callee with Procname.Java jpname -> Procname.Java.is_static jpname | _ -> false) - && String.equal "create" (Procname.get_method callee) - && attrs_of_pname callee - |> Option.exists ~f:(fun (attrs : ProcAttributes.t) -> - match attrs.ret_type with - | Typ.{desc= Tptr ({desc= Tstruct ret_class}, _)} -> - is_builder_class ret_class - | _ -> - false ) - - -let is_builder_passthrough callee = - match callee with - | Procname.Java java_pname -> - (not (Procname.Java.is_static java_pname)) - && is_builder_method java_pname - && attrs_of_pname callee - |> Option.exists ~f:(fun (attrs : ProcAttributes.t) -> - match attrs.formals with - | (_, typ) :: _ when Typ.equal typ attrs.ret_type -> - true - | _ -> - false ) - | _ -> - false - - let is_initializer tenv proc_name = Procname.is_constructor proc_name || FbThreadSafety.is_custom_init tenv proc_name diff --git a/infer/src/concurrency/RacerDModels.mli b/infer/src/concurrency/RacerDModels.mli index 7e76a2698..b85f9342f 100644 --- a/infer/src/concurrency/RacerDModels.mli +++ b/infer/src/concurrency/RacerDModels.mli @@ -53,15 +53,6 @@ val should_flag_interface_call : Tenv.t -> HilExp.t list -> CallFlags.t -> Procn val is_synchronized_container : Procname.t -> HilExp.AccessExpression.t -> Tenv.t -> bool (** is a call on an access expression to a method of a synchronized container? *) -val is_abstract_getthis_like : Procname.t -> bool -(** is the callee an abstract method with one argument where argument type is equal to return type *) - -val creates_builder : Procname.t -> bool -(** is the callee a static java method returning a [Builder] object? *) - -val is_builder_passthrough : Procname.t -> bool -(** is the callee a non-static [Builder] method returning the same type as its receiver *) - val is_initializer : Tenv.t -> Procname.t -> bool (** should the given procedure be treated as a constructor/initializer? *)