[racerd] assume unknown code returns owned objects

Summary: Add command line option that directs racerd to treat all return values from unknown code (including abstract methods) as owned objects.  This is essentially treating return values with full angelicism

Reviewed By: artempyanykh

Differential Revision: D19368375

fbshipit-source-id: 6a10153fa
master
Nikos Gorogiannis 5 years ago committed by Facebook Github Bot
parent a187d1b0b6
commit 32639d6ebc

@ -439,6 +439,11 @@ RACERD CHECKER OPTIONS
Activates: Check @GuardedBy annotations with RacerD (Conversely: Activates: Check @GuardedBy annotations with RacerD (Conversely:
--no-racerd-guardedby) --no-racerd-guardedby)
--racerd-unknown-returns-owned
Activates: Assume that all methods without a CFG (including
abstract methods) return owned objects (Conversely:
--no-racerd-unknown-returns-owned)
--threadsafe-aliases json --threadsafe-aliases json
Specify custom annotations that should be considered aliases of Specify custom annotations that should be considered aliases of
@ThreadSafe @ThreadSafe

@ -943,6 +943,11 @@ OPTIONS
Activates: Enable --racerd and disable all other checkers Activates: Enable --racerd and disable all other checkers
(Conversely: --no-racerd-only) See also infer-analyze(1). (Conversely: --no-racerd-only) See also infer-analyze(1).
--racerd-unknown-returns-owned
Activates: Assume that all methods without a CFG (including
abstract methods) return owned objects (Conversely:
--no-racerd-unknown-returns-owned) See also infer-analyze(1).
--reactive,-r --reactive,-r
Activates: Reactive mode: the analysis starts from the files Activates: Reactive mode: the analysis starts from the files
captured since the infer command started (Conversely: captured since the infer command started (Conversely:

@ -943,6 +943,11 @@ OPTIONS
Activates: Enable --racerd and disable all other checkers Activates: Enable --racerd and disable all other checkers
(Conversely: --no-racerd-only) See also infer-analyze(1). (Conversely: --no-racerd-only) See also infer-analyze(1).
--racerd-unknown-returns-owned
Activates: Assume that all methods without a CFG (including
abstract methods) return owned objects (Conversely:
--no-racerd-unknown-returns-owned) See also infer-analyze(1).
--reactive,-r --reactive,-r
Activates: Reactive mode: the analysis starts from the files Activates: Reactive mode: the analysis starts from the files
captured since the infer command started (Conversely: captured since the infer command started (Conversely:

@ -1999,6 +1999,12 @@ and racerd_guardedby =
"Check @GuardedBy annotations with RacerD" "Check @GuardedBy annotations with RacerD"
and racerd_unknown_returns_owned =
CLOpt.mk_bool ~long:"racerd-unknown-returns-owned" ~default:false
~in_help:InferCommand.[(Analyze, manual_racerd)]
"Assume that all methods without a CFG (including abstract methods) return owned objects"
and reactive = and reactive =
CLOpt.mk_bool ~deprecated:["reactive"] ~long:"reactive" ~short:'r' CLOpt.mk_bool ~deprecated:["reactive"] ~long:"reactive" ~short:'r'
~in_help:InferCommand.[(Analyze, manual_generic)] ~in_help:InferCommand.[(Analyze, manual_generic)]
@ -3123,6 +3129,8 @@ and racerd = !racerd
and racerd_guardedby = !racerd_guardedby and racerd_guardedby = !racerd_guardedby
and racerd_unknown_returns_owned = !racerd_unknown_returns_owned
and reactive_mode = !reactive and reactive_mode = !reactive
and reactive_capture = !reactive_capture and reactive_capture = !reactive_capture

@ -572,6 +572,8 @@ val racerd : bool
val racerd_guardedby : bool val racerd_guardedby : bool
val racerd_unknown_returns_owned : bool
val reactive_capture : bool val reactive_capture : bool
val reactive_mode : bool val reactive_mode : bool

@ -177,8 +177,9 @@ module TransferFunctions (CFG : ProcCfg.S) = struct
let open RacerDModels in let open RacerDModels in
let open RacerDDomain in let open RacerDDomain in
let should_assume_returns_ownership callee_pname (call_flags : CallFlags.t) actuals = 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 *) (* non-interface methods with no summary and no parameters *)
((not call_flags.cf_interface) && List.is_empty actuals) || ((not call_flags.cf_interface) && List.is_empty actuals)
|| (* static [$Builder] creation methods *) || (* static [$Builder] creation methods *)
creates_builder callee_pname creates_builder callee_pname
in in

Loading…
Cancel
Save