[thread-safety] treat non-interface methods with no summary as angelic

Reviewed By: jeremydubreil

Differential Revision: D4758609

fbshipit-source-id: fa56bd5
master
Sam Blackshear 8 years ago committed by Facebook Github Bot
parent 2cc972705a
commit 6a39585999

@ -392,7 +392,7 @@ module TransferFunctions (CFG : ProcCfg.S) = struct
lhs_access_path target_exp target_typ ~f_resolve_id astate.attribute_map extras in
{ astate with attribute_map; }
| Sil.Call (ret_opt, Const (Cfun callee_pname), actuals, loc, _) ->
| Sil.Call (ret_opt, Const (Cfun callee_pname), actuals, loc, call_flags) ->
let astate_callee =
(* assuming that modeled procedures do not have useful summaries *)
if is_thread_utils_method "assertMainThread" callee_pname then
@ -500,6 +500,10 @@ module TransferFunctions (CFG : ProcCfg.S) = struct
extras in
{ astate with locks; threads; accesses; attribute_map; }
| None ->
let should_assume_returns_ownership (call_flags : CallFlags.t) actuals =
(* assume non-interface methods with no summary and no parameters return
ownership *)
not (call_flags.cf_interface) && List.is_empty actuals in
if is_box callee_pname
then
match ret_opt, actuals with
@ -520,9 +524,8 @@ module TransferFunctions (CFG : ProcCfg.S) = struct
end
| _ ->
astate
else if FbThreadSafety.is_graphql_constructor callee_pname
else if should_assume_returns_ownership call_flags actuals
then
(* assume generated GraphQL code returns ownership *)
match ret_opt with
| Some (ret_id, ret_typ) ->
let attribute_map =

@ -12,5 +12,3 @@ open! IStd
let is_custom_init _ _ = false
let is_logging_method _ = false
let is_graphql_constructor _ = false

@ -1,3 +1,9 @@
{
"threadsafe-aliases": ["MyThreadSafeAlias1", "codetoanalyze.java.checkers.MyThreadSafeAlias2"]
"threadsafe-aliases": ["MyThreadSafeAlias1", "codetoanalyze.java.checkers.MyThreadSafeAlias2"],
"skip-translation": [
{
"language": "Java",
"source_contains": "_SHOULD_BE_SKIPPED_"
}
]
}

@ -371,6 +371,11 @@ public class Ownership {
o.f = new Object();
}
void ownInSkippedCodeOk() {
SkippedClass c = SkippedClass.returnOwned();
c.f = new Object();
}
}

@ -0,0 +1,22 @@
/*
* Copyright (c) 2015 - present Facebook, Inc.
* All rights reserved.
*
* This source code is licensed under the BSD style license found in the
* LICENSE file in the root directory of this source tree. An additional grant
* of patent rights can be found in the PATENTS file in the same directory.
*/
// _SHOULD_BE_SKIPPED_
package codetoanalyze.java.checkers;
public class SkippedClass {
Object f;
public static SkippedClass returnOwned() {
return new SkippedClass();
}
}
Loading…
Cancel
Save