From 4f33ecef1e1e24543418b0c16af68d4419b7c421 Mon Sep 17 00:00:00 2001 From: Sam Blackshear Date: Tue, 14 Feb 2017 10:45:14 -0800 Subject: [PATCH] [thread-safety] treat generated GraphQL constructors as returning ownership Reviewed By: jeremydubreil Differential Revision: D4552975 fbshipit-source-id: 199b01b --- infer/src/checkers/ThreadSafety.ml | 12 ++++++++++++ infer/src/opensource/FbThreadSafety.ml | 2 ++ infer/src/opensource/FbThreadSafety.mli | 2 ++ 3 files changed, 16 insertions(+) diff --git a/infer/src/checkers/ThreadSafety.ml b/infer/src/checkers/ThreadSafety.ml index 72cc213c8..580b94b9b 100644 --- a/infer/src/checkers/ThreadSafety.ml +++ b/infer/src/checkers/ThreadSafety.ml @@ -421,6 +421,18 @@ module TransferFunctions (CFG : ProcCfg.S) = struct end | _ -> astate + else if FbThreadSafety.is_graphql_constructor callee_pname + then + (* assume generated GraphQL code returns ownership *) + match ret_opt with + | Some (ret_id, ret_typ) -> + let attribute_map = + AttributeMapDomain.add_attribute + (AccessPath.of_id ret_id ret_typ) + Attribute.unconditionally_owned + astate.attribute_map in + { astate with attribute_map; } + | None -> astate else astate in begin diff --git a/infer/src/opensource/FbThreadSafety.ml b/infer/src/opensource/FbThreadSafety.ml index d949237f0..0ab3001f1 100644 --- a/infer/src/opensource/FbThreadSafety.ml +++ b/infer/src/opensource/FbThreadSafety.ml @@ -12,3 +12,5 @@ open! IStd let is_custom_init _ _ = false let is_logging_method _ = false + +let is_graphql_constructor _ = false diff --git a/infer/src/opensource/FbThreadSafety.mli b/infer/src/opensource/FbThreadSafety.mli index 363d62ea9..a475abecc 100644 --- a/infer/src/opensource/FbThreadSafety.mli +++ b/infer/src/opensource/FbThreadSafety.mli @@ -12,3 +12,5 @@ open! IStd val is_custom_init : Tenv.t -> Procname.t -> bool val is_logging_method : Procname.t -> bool + +val is_graphql_constructor : Procname.t -> bool