From 32639d6ebc5bdf9aa7e5ce80a48fc8fdf59fa1cd Mon Sep 17 00:00:00 2001 From: Nikos Gorogiannis Date: Mon, 13 Jan 2020 04:57:01 -0800 Subject: [PATCH] [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 --- infer/man/man1/infer-analyze.txt | 5 +++++ infer/man/man1/infer-full.txt | 5 +++++ infer/man/man1/infer.txt | 5 +++++ infer/src/base/Config.ml | 8 ++++++++ infer/src/base/Config.mli | 2 ++ infer/src/concurrency/RacerD.ml | 3 ++- 6 files changed, 27 insertions(+), 1 deletion(-) diff --git a/infer/man/man1/infer-analyze.txt b/infer/man/man1/infer-analyze.txt index 45a66a78b..2cdf6210e 100644 --- a/infer/man/man1/infer-analyze.txt +++ b/infer/man/man1/infer-analyze.txt @@ -439,6 +439,11 @@ RACERD CHECKER OPTIONS Activates: Check @GuardedBy annotations with RacerD (Conversely: --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 Specify custom annotations that should be considered aliases of @ThreadSafe diff --git a/infer/man/man1/infer-full.txt b/infer/man/man1/infer-full.txt index 2142a3485..6d79e1225 100644 --- a/infer/man/man1/infer-full.txt +++ b/infer/man/man1/infer-full.txt @@ -943,6 +943,11 @@ OPTIONS Activates: Enable --racerd and disable all other checkers (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 Activates: Reactive mode: the analysis starts from the files captured since the infer command started (Conversely: diff --git a/infer/man/man1/infer.txt b/infer/man/man1/infer.txt index 3acfa0991..760412a1f 100644 --- a/infer/man/man1/infer.txt +++ b/infer/man/man1/infer.txt @@ -943,6 +943,11 @@ OPTIONS Activates: Enable --racerd and disable all other checkers (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 Activates: Reactive mode: the analysis starts from the files captured since the infer command started (Conversely: diff --git a/infer/src/base/Config.ml b/infer/src/base/Config.ml index 6ef9ab726..005ffbaca 100644 --- a/infer/src/base/Config.ml +++ b/infer/src/base/Config.ml @@ -1999,6 +1999,12 @@ and racerd_guardedby = "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 = CLOpt.mk_bool ~deprecated:["reactive"] ~long:"reactive" ~short:'r' ~in_help:InferCommand.[(Analyze, manual_generic)] @@ -3123,6 +3129,8 @@ and racerd = !racerd 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 d303580db..53463c767 100644 --- a/infer/src/base/Config.mli +++ b/infer/src/base/Config.mli @@ -572,6 +572,8 @@ val racerd : 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 c56a35d25..c33634de0 100644 --- a/infer/src/concurrency/RacerD.ml +++ b/infer/src/concurrency/RacerD.ml @@ -177,8 +177,9 @@ module TransferFunctions (CFG : ProcCfg.S) = struct 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) + || ((not call_flags.cf_interface) && List.is_empty actuals) || (* static [$Builder] creation methods *) creates_builder callee_pname in