[pulse] Model Core Foundation create and copy functions

Reviewed By: jvillard

Differential Revision: D21301068

fbshipit-source-id: 76a997eb2
master
Dulma Churchill 5 years ago committed by Facebook GitHub Bot
parent 7b5356cf97
commit 6c044ba2d4

@ -465,6 +465,12 @@ module ObjectiveC = struct
|| String.is_substring ~substring:"Copy" procname ) || String.is_substring ~substring:"Copy" procname )
let is_core_foundation_create_or_copy _ procname =
String.is_prefix ~prefix:"CF" procname
&& ( String.is_substring ~substring:"Create" procname
|| String.is_substring ~substring:"Copy" procname )
let is_core_graphics_release _ procname = let is_core_graphics_release _ procname =
String.is_prefix ~prefix:"CG" procname && String.is_suffix ~suffix:"Release" procname String.is_prefix ~prefix:"CG" procname && String.is_suffix ~suffix:"Release" procname

@ -164,6 +164,8 @@ val is_override_of_java_lang_object_equals : Procname.t -> bool
module ObjectiveC : sig module ObjectiveC : sig
val is_core_graphics_create_or_copy : Tenv.t -> string -> bool val is_core_graphics_create_or_copy : Tenv.t -> string -> bool
val is_core_foundation_create_or_copy : Tenv.t -> string -> bool
val is_core_graphics_release : Tenv.t -> string -> bool val is_core_graphics_release : Tenv.t -> string -> bool
val is_modelled_as_alloc : Tenv.t -> string -> bool val is_modelled_as_alloc : Tenv.t -> string -> bool

@ -674,6 +674,7 @@ module ProcNameDispatcher = struct
$!--> fun x -> StdVector.at ~desc:"Enumeration.nextElement" x (AbstractValue.mk_fresh (), []) $!--> fun x -> StdVector.at ~desc:"Enumeration.nextElement" x (AbstractValue.mk_fresh (), [])
) )
; +PatternMatch.ObjectiveC.is_core_graphics_create_or_copy &++> C.malloc ; +PatternMatch.ObjectiveC.is_core_graphics_create_or_copy &++> C.malloc
; +PatternMatch.ObjectiveC.is_core_foundation_create_or_copy &++> C.malloc
; +PatternMatch.ObjectiveC.is_core_graphics_release <>$ capt_arg_payload $--> C.free ; +PatternMatch.ObjectiveC.is_core_graphics_release <>$ capt_arg_payload $--> C.free
; -"CFRelease" <>$ capt_arg_payload $--> C.free ; -"CFRelease" <>$ capt_arg_payload $--> C.free
; -"CFAutorelease" <>$ capt_arg_payload $--> C.free ; -"CFAutorelease" <>$ capt_arg_payload $--> C.free

@ -7,7 +7,7 @@ TESTS_DIR = ../../..
CLANG_OPTIONS = -c $(OBJC_CLANG_OPTIONS) -fobjc-arc CLANG_OPTIONS = -c $(OBJC_CLANG_OPTIONS) -fobjc-arc
INFER_OPTIONS = --pulse-only --debug-exceptions --project-root $(TESTS_DIR) \ INFER_OPTIONS = --pulse-only --debug-exceptions --project-root $(TESTS_DIR) \
--pulse-model-alloc-pattern "AB[IF].*Create.*\|CFLocaleCreate" \ --pulse-model-alloc-pattern "AB[IF].*Create.*" \
--pulse-model-free-pattern ABFRelease --pulse-model-free-pattern ABFRelease
INFERPRINT_OPTIONS = --issues-tests INFERPRINT_OPTIONS = --issues-tests

@ -72,7 +72,12 @@
return CFBridgingRelease(nameRef); return CFBridgingRelease(nameRef);
} }
- (void)call_bridge_no_leak_good { - (void)create_release_no_leak_ok {
CFLocaleRef nameRef = CFLocaleCreate(NULL, NULL);
CFRelease(nameRef);
}
- (void)call_bridge_no_leak_ok {
NSLocale* locale = [self ret_bridge]; NSLocale* locale = [self ret_bridge];
} }

Loading…
Cancel
Save