Make alloc save a given procanem in the path

Reviewed By: ddino

Differential Revision: D3184313

fb-gh-sync-id: 53624c4
fbshipit-source-id: 53624c4
master
Dulma Rodriguez 9 years ago committed by Facebook Github Bot 8
parent 82670de0c8
commit 8a1288860b

@ -1,20 +0,0 @@
/*
* 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.
*/
#import <Foundation/Foundation.h>
CFBitVectorRef __cf_alloc(CFBitVectorRef);
CFBitVectorRef __cf_non_null_alloc(CFBitVectorRef);
CFBitVectorRef CFBitVectorCreate(CFAllocatorRef allocator,
const UInt8* bytes,
CFIndex numBits) {
CFBitVectorRef c;
return __cf_non_null_alloc(c);
}

@ -1,18 +0,0 @@
/*
* 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.
*/
#import <Foundation/Foundation.h>
CFDateRef __cf_alloc(CFDateRef);
CFDateRef __cf_non_null_alloc(CFDateRef);
CFDateRef CFDateCreate(CFAllocatorRef allocator, CFAbsoluteTime at) {
CFDateRef c;
return __cf_non_null_alloc(c);
}

@ -15,13 +15,6 @@ CFDictionaryRef __cf_non_null_alloc(CFDictionaryRef);
CFDictionaryRef __cf_alloc(CFDictionaryRef);
CFDictionaryRef CGImageSourceCopyPropertiesAtIndex(CGImageSourceRef isrc,
size_t index,
CFDictionaryRef options) {
CFDictionaryRef c;
return __cf_non_null_alloc(c);
}
CFDictionaryRef CFDictionaryCreate(
CFAllocatorRef allocator,
const void** keys,
@ -39,17 +32,6 @@ CFDictionaryRef CFDictionaryCreateCopy(CFAllocatorRef allocator,
return __cf_alloc(c);
}
CFDictionaryRef CFNetworkCopySystemProxySettings(void) {
CFDictionaryRef c;
return __cf_non_null_alloc(c);
}
CFDictionaryRef CGImageSourceCopyProperties(CGImageSourceRef isrc,
CFDictionaryRef options) {
CFDictionaryRef c;
return __cf_non_null_alloc(c);
}
CFDictionaryRef CMCopyDictionaryOfAttachments(CFAllocatorRef allocator,
CMAttachmentBearerRef target,
CMAttachmentMode attachmentMode) {
@ -62,11 +44,6 @@ CFDictionaryRef CFHTTPMessageCopyAllHeaderFields(CFHTTPMessageRef message) {
return __cf_alloc(c);
}
CFDictionaryRef CNCopyCurrentNetworkInfo(CFStringRef interfaceName) {
CFDictionaryRef c;
return __cf_non_null_alloc(c);
}
CFDictionaryRef CMTimeCopyAsDictionary(CMTime time, CFAllocatorRef allocator) {
CFDictionaryRef c;
return __cf_alloc(c);

@ -12,11 +12,6 @@
CFLocaleRef __cf_alloc(CFLocaleRef);
CFLocaleRef __cf_non_null_alloc(CFLocaleRef);
CFLocaleRef CFLocaleCopyCurrent(void) {
CFLocaleRef c;
return __cf_non_null_alloc(c);
}
CFLocaleRef CFLocaleCreate(CFAllocatorRef allocator,
CFStringRef localeIdentifier) {
CFLocaleRef c;

@ -1,18 +0,0 @@
/*
* 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.
*/
#import <Foundation/Foundation.h>
CFMutableAttributedStringRef __cf_non_null_alloc(CFMutableAttributedStringRef);
CFMutableAttributedStringRef CFAttributedStringCreateMutable(
CFAllocatorRef alloc, CFIndex maxLength) {
CFMutableAttributedStringRef c;
return __cf_non_null_alloc(c);
}

@ -23,10 +23,3 @@ CFMutableDictionaryRef CFDictionaryCreateMutable(
CFMutableDictionaryRef c;
return __cf_alloc(c);
}
CFMutableDictionaryRef CFDictionaryCreateMutableCopy(CFAllocatorRef allocator,
CFIndex capacity,
CFDictionaryRef theDict) {
CFMutableDictionaryRef c;
return __cf_non_null_alloc(c);
}

@ -18,10 +18,3 @@ CFMutableSetRef CFSetCreateMutable(CFAllocatorRef allocator,
CFMutableSetRef c;
return __cf_alloc(c);
}
CFMutableSetRef CFSetCreateMutableCopy(CFAllocatorRef allocator,
CFIndex capacity,
CFSetRef theSet) {
CFMutableSetRef c;
return __cf_non_null_alloc(c);
}

@ -1,21 +0,0 @@
/*
* 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.
*/
#import <Foundation/Foundation.h>
CFDictionaryRef __cf_alloc(CFDictionaryRef);
CFDictionaryRef __cf_non_null_alloc(CFDictionaryRef);
CFDictionaryRef CFPreferencesCopyMultiple(CFArrayRef keysToFetch,
CFStringRef appName,
CFStringRef user,
CFStringRef host) {
CFDictionaryRef c;
return __cf_non_null_alloc(c);
}

@ -1,27 +0,0 @@
/*
* 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.
*/
#import <Foundation/Foundation.h>
CFRunLoopSourceRef __cf_alloc(CFRunLoopSourceRef);
CFRunLoopSourceRef __cf_non_null_alloc(CFRunLoopSourceRef);
CFRunLoopSourceRef CFRunLoopSourceCreate(CFAllocatorRef allocator,
CFIndex order,
CFRunLoopSourceContext* context) {
CFRunLoopSourceRef c;
return __cf_non_null_alloc(c);
}
CFRunLoopSourceRef CFSocketCreateRunLoopSource(CFAllocatorRef allocator,
CFSocketRef s,
CFIndex order) {
CFRunLoopSourceRef c;
return __cf_non_null_alloc(c);
}

@ -1,34 +0,0 @@
/*
* 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.
*/
#import <Foundation/Foundation.h>
CFRunLoopObserverRef __cf_alloc(CFRunLoopObserverRef);
CFRunLoopSourceRef __cf_non_null_alloc(CFRunLoopSourceRef);
CFRunLoopObserverRef CFRunLoopObserverCreate(
CFAllocatorRef allocator,
CFOptionFlags activities,
Boolean repeats,
CFIndex order,
CFRunLoopObserverCallBack callout,
CFRunLoopObserverContext* context) {
CFRunLoopObserverRef c;
return __cf_non_null_alloc(c);
}
CFRunLoopObserverRef CFRunLoopObserverCreateWithHandler(
CFAllocatorRef allocator,
CFOptionFlags activities,
Boolean repeats,
CFIndex order,
void (^block)(CFRunLoopObserverRef observer, CFRunLoopActivity activity)) {
CFRunLoopObserverRef c;
return __cf_non_null_alloc(c);
}

@ -1,22 +0,0 @@
/*
* 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.
*/
#import <Foundation/Foundation.h>
CFStringTokenizerRef __cf_alloc(CFStringTokenizerRef);
CFStringTokenizerRef __cf_non_null_alloc(CFStringTokenizerRef);
CFStringTokenizerRef CFStringTokenizerCreate(CFAllocatorRef alloc,
CFStringRef string,
CFRange range,
CFOptionFlags options,
CFLocaleRef locale) {
CFStringTokenizerRef c;
return __cf_non_null_alloc(c);
}

@ -1,24 +0,0 @@
/*
* 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.
*/
#import <Foundation/Foundation.h>
CFUUIDRef __cf_alloc(CFUUIDRef);
CFUUIDRef __cf_non_null_alloc(CFUUIDRef);
CFUUIDRef CFUUIDCreate(CFAllocatorRef alloc) {
CFUUIDRef c;
return __cf_non_null_alloc(c);
}
CFUUIDRef CFUUIDCreateFromUUIDBytes(CFAllocatorRef alloc, CFUUIDBytes bytes) {
CFUUIDRef c;
return __cf_non_null_alloc(c);
}

@ -1,25 +0,0 @@
/*
* 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.
*/
#import "SystemConfiguration/SCNetworkReachability.h"
#import <Foundation/Foundation.h>
SCNetworkReachabilityRef __cf_non_null_alloc(SCNetworkReachabilityRef);
SCNetworkReachabilityRef SCNetworkReachabilityCreateWithName(
CFAllocatorRef allocator, const char* nodename) {
SCNetworkReachabilityRef c;
return __cf_non_null_alloc(c);
}
SCNetworkReachabilityRef SCNetworkReachabilityCreateWithAddress(
CFAllocatorRef allocator, const struct sockaddr* address) {
SCNetworkReachabilityRef c;
return __cf_non_null_alloc(c);
}

@ -18,13 +18,3 @@ SecKeyRef SecTrustCopyPublicKey(SecTrustRef trust) {
SecKeyRef c;
return __cf_alloc(c);
}
SecPolicyRef SecPolicyCreateSSL(Boolean server, CFStringRef hostname) {
SecPolicyRef c;
return __cf_non_null_alloc(c);
}
SecPolicyRef SecPolicyCreateBasicX509(void) {
SecPolicyRef c;
return __cf_non_null_alloc(c);
}

@ -18,16 +18,6 @@ void CGColorRelease(CGColorRef color) {
__objc_release_cf(color);
}
CGColorRef CGColorCreate(CGColorSpaceRef space, const CGFloat components[]) {
CGColorRef c;
return __cf_non_null_alloc(c);
}
CGColorRef CGColorCreateCopyWithAlpha(CGColorRef color, CGFloat alpha) {
CGColorRef c;
return __cf_non_null_alloc(c);
}
// FB own code
CGColorRef FBColorCreateWithGray(CGFloat gray, CGFloat a) {

@ -20,33 +20,8 @@ CGDataProviderRef __cf_alloc(CGDataProviderRef);
CGDataProviderRef __cf_non_null_alloc(CGDataProviderRef);
CGDataProviderRef CGDataProviderCreateWithCFData(CFDataRef data) {
CGDataProviderRef c;
return __cf_non_null_alloc(c);
}
CGDataProviderRef CGDataProviderCreateWithData(
void* info,
const void* data,
size_t size,
CGDataProviderReleaseDataCallback releaseData) {
CGDataProviderRef c;
return __cf_non_null_alloc(c);
}
CGDataProviderRef CGDataProviderCreateWithURL(CFURLRef url) {
CGDataProviderRef c;
return __cf_alloc(c);
}
CGDataProviderRef CGDataProviderCreateDirect(
void* info, off_t size, const CGDataProviderDirectCallbacks* callbacks) {
CGDataProviderRef c;
return __cf_non_null_alloc(c);
}
CGDataProviderRef CGDataProviderCreateSequential(
void* info, const CGDataProviderSequentialCallbacks* callbacks) {
CGDataProviderRef c;
return __cf_non_null_alloc(c);
}

@ -17,18 +17,3 @@ void CGGradientRelease(CGGradientRef gradient) {
}
CGGradientRef __cf_non_null_alloc(CGGradientRef);
CGGradientRef CGGradientCreateWithColors(CGColorSpaceRef space,
CFArrayRef colors,
const CGFloat locations[]) {
CGGradientRef c;
return __cf_non_null_alloc(c);
}
CGGradientRef CGGradientCreateWithColorComponents(CGColorSpaceRef space,
const CGFloat components[],
const CGFloat locations[],
size_t count) {
CGGradientRef c;
return __cf_non_null_alloc(c);
}

@ -14,20 +14,6 @@ CGImageRef __cf_non_null_alloc(CGImageRef);
CGImageRef __cf_alloc(CGImageRef);
void __objc_release_cf(CGImageRef);
CGImageRef CGImageSourceCreateImageAtIndex(CGImageSourceRef isrc,
size_t index,
CFDictionaryRef options) {
CGImageRef c;
return __cf_non_null_alloc(c);
}
CGImageRef CGImageSourceCreateThumbnailAtIndex(CGImageSourceRef isrc,
size_t index,
CFDictionaryRef options) {
CGImageRef c;
return __cf_non_null_alloc(c);
}
void CGImageRelease(CGImageRef image) {
if (image)
__objc_release_cf(image);
@ -38,48 +24,7 @@ CGImageRef CGBitmapContextCreateImage(CGContextRef context) {
return __cf_alloc(c);
}
CGImageRef CGImageCreateCopy(CGImageRef image) {
CGImageRef c;
return __cf_non_null_alloc(c);
}
CGImageRef CGImageCreateWithImageInRect(CGImageRef image, CGRect rect) {
CGImageRef c;
return __cf_alloc(c);
}
CGImageRef CGImageCreateWithJPEGDataProvider(CGDataProviderRef source,
const CGFloat decode[],
bool shouldInterpolate,
CGColorRenderingIntent intent) {
CGImageRef c;
return __cf_non_null_alloc(c);
}
CGImageRef CGImageCreateWithPNGDataProvider(CGDataProviderRef source,
const CGFloat decode[],
bool shouldInterpolate,
CGColorRenderingIntent intent) {
CGImageRef c;
return __cf_non_null_alloc(c);
}
CGImageRef CGImageCreate(size_t width,
size_t height,
size_t bitsPerComponent,
size_t bitsPerPixel,
size_t bytesPerRow,
CGColorSpaceRef space,
CGBitmapInfo bitmapInfo,
CGDataProviderRef provider,
const CGFloat decode[],
bool shouldInterpolate,
CGColorRenderingIntent intent) {
CGImageRef c;
return __cf_non_null_alloc(c);
}
CGImageRef CGImageCreateWithMask(CGImageRef image, CGImageRef mask) {
CGImageRef c;
return __cf_non_null_alloc(c);
}

@ -1,31 +0,0 @@
/*
* 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.
*/
#import <CoreGraphics/CoreGraphics.h>
#import <ImageIO/ImageIO.h>
CGImageDestinationRef __cf_non_null_alloc(CGImageDestinationRef);
CGImageDestinationRef __cf_alloc(CGImageDestinationRef);
CGImageDestinationRef CGImageDestinationCreateWithURL(CFURLRef url,
CFStringRef type,
size_t count,
CFDictionaryRef options) {
CGImageDestinationRef c;
return __cf_non_null_alloc(c);
}
CGImageDestinationRef CGImageDestinationCreateWithData(
CFMutableDataRef data,
CFStringRef type,
size_t count,
CFDictionaryRef options) {
CGImageDestinationRef c;
return __cf_non_null_alloc(c);
}

@ -14,28 +14,12 @@ CGImageSourceRef __cf_non_null_alloc(CGImageSourceRef);
CGImageSourceRef __cf_alloc(CGImageSourceRef);
void __objc_release_cf(CGImageSourceRef);
CGImageSourceRef CGImageSourceCreateWithData(CFDataRef data,
CFDictionaryRef options) {
CGImageSourceRef c;
return __cf_non_null_alloc(c);
}
CGImageSourceRef CGImageSourceCreateWithDataProvider(CGDataProviderRef provider,
CFDictionaryRef options) {
CGImageSourceRef c;
return __cf_non_null_alloc(c);
}
CGImageSourceRef CGImageSourceCreateWithURL(CFURLRef url,
CFDictionaryRef options) {
CGImageSourceRef c;
return __cf_alloc(c);
}
CGImageSourceRef CGImageSourceCreateIncremental(CFDictionaryRef options) {
CGImageSourceRef c;
return __cf_non_null_alloc(c);
}
void CGImageSourceRelease(CGImageSourceRef image) {
if (image)

@ -13,43 +13,8 @@
CGPathRef __cf_non_null_alloc(CGPathRef);
void __objc_release_cf(CGPathRef);
CGMutablePathRef CGPathCreateMutable() {
CGMutablePathRef c;
return (CGMutablePathRef)__cf_non_null_alloc(c);
}
CGPathRef CGPathCreateWithRect(CGRect rect,
const CGAffineTransform* transform) {
CGPathRef c;
return __cf_non_null_alloc(c);
}
void CGPathRelease(CGPathRef path) {
if (path)
__objc_release_cf(path);
}
CGPathRef CGPathCreateWithEllipseInRect(CGRect rect,
const CGAffineTransform* transform) {
CGPathRef c;
return __cf_non_null_alloc(c);
}
CGPathRef CGPathCreateCopy(CGPathRef path) {
CGPathRef c;
return __cf_non_null_alloc(c);
}
CGPathRef CGPathCreateCopyByTransformingPath(
CGPathRef path, const CGAffineTransform* transform) {
CGPathRef c;
return __cf_non_null_alloc(c);
}
CGPathRef CGPathCreateWithRoundedRect(CGRect rect,
CGFloat cornerWidth,
CGFloat cornerHeight,
const CGAffineTransform* transform) {
CGPathRef c;
return __cf_non_null_alloc(c);
}

@ -748,11 +748,11 @@ let execute_alloc mk can_return_null
| Sil.Sizeof _ -> e in
let handle_sizeof_exp size_exp =
Sil.Sizeof (Sil.Tarray (Sil.Tint Sil.IChar, size_exp), Sil.Subtype.exact) in
let size_exp = match args with
let size_exp, procname = match args with
| [(size_exp, _)] -> (* for malloc and __new *)
size_exp
| [(num_obj, _); (base_exp, _)] -> (* for __new_array *)
Sil.BinOp (Sil.Mult, num_obj, base_exp)
size_exp, Sil.mem_alloc_pname mk
| [(size_exp, _); (Sil.Const (Sil.Cfun pname), _)] ->
size_exp, pname
| _ ->
raise (Exceptions.Wrong_argument_number __POS__) in
let ret_id = match ret_ids with
@ -768,12 +768,11 @@ let execute_alloc mk can_return_null
let ptsto_new =
Prop.mk_ptsto_exp (Some tenv) Prop.Fld_init (exp_new, cnt_te, None) Sil.Ialloc in
let prop_plus_ptsto =
let pname = Sil.mem_alloc_pname mk in
let prop' = Prop.normalize (Prop.prop_sigma_star prop [ptsto_new]) in
let ra =
{ Sil.ra_kind = Sil.Racquire;
Sil.ra_res = Sil.Rmemory mk;
Sil.ra_pname = pname;
Sil.ra_pname = procname;
Sil.ra_loc = loc;
Sil.ra_vpath = None } in
(* mark value as allocated *)
@ -1123,62 +1122,72 @@ let _ = Builtin.register
"wscanf" (execute_scan_function 1)
let execute_objc_alloc_no_fail
symb_state typ
symb_state typ alloc_fun_opt
{ Builtin.pdesc; tenv; ret_ids; loc; } =
let alloc_fun = Sil.Const (Sil.Cfun __objc_alloc_no_fail) in
let ptr_typ = Sil.Tptr (typ, Sil.Pk_pointer) in
let sizeof_typ = Sil.Sizeof (typ, Sil.Subtype.exact) in
let alloc_instr = Sil.Call (ret_ids, alloc_fun, [sizeof_typ, ptr_typ], loc, Sil.cf_default) in
let alloc_fun_exp =
match alloc_fun_opt with
| Some pname -> [Sil.Const (Sil.Cfun pname), Sil.Tvoid]
| None -> [] in
let alloc_instr =
Sil.Call (ret_ids, alloc_fun, [(sizeof_typ, ptr_typ)] @ alloc_fun_exp, loc, Sil.cf_default) in
SymExec.instrs tenv pdesc [alloc_instr] symb_state
let mk_objc_class_method class_name method_name =
let method_kind = Procname.mangled_of_objc_method_kind Procname.Class_objc_method in
(Procname.ObjC_Cpp
(Procname.objc_cpp class_name method_name method_kind))
(* NSArray models *)
let arrayWithObjects_pname = mk_objc_class_method "NSArray" "arrayWithObjects:"
let arrayWithObjectsCount_pname = mk_objc_class_method "NSArray" "arrayWithObjects:count:"
let execute_objc_NSArray_alloc_no_fail
({ Builtin.tenv; } as builtin_args) symb_state =
({ Builtin.tenv; } as builtin_args) symb_state pname =
let nsarray_typ_ =
Sil.Tvar (Typename.TN_csu (Csu.Class Csu.Objc, Mangled.from_string "NSArray")) in
let nsarray_typ = Tenv.expand_type tenv nsarray_typ_ in
execute_objc_alloc_no_fail symb_state nsarray_typ builtin_args
execute_objc_alloc_no_fail symb_state nsarray_typ (Some pname) builtin_args
let execute_NSArray_arrayWithObjects_count builtin_args =
let n_formals = 1 in
let res = SymExec.check_variadic_sentinel ~fails_on_nil: true n_formals (0,1) builtin_args in
execute_objc_NSArray_alloc_no_fail builtin_args res
execute_objc_NSArray_alloc_no_fail builtin_args res arrayWithObjectsCount_pname
let execute_NSArray_arrayWithObjects builtin_args =
let n_formals = 1 in
let res = SymExec.check_variadic_sentinel n_formals (0,1) builtin_args in
execute_objc_NSArray_alloc_no_fail builtin_args res
execute_objc_NSArray_alloc_no_fail builtin_args res arrayWithObjects_pname
let _ =
let method_kind = Procname.mangled_of_objc_method_kind Procname.Class_objc_method in
Builtin.register_procname
(Procname.ObjC_Cpp
(Procname.objc_cpp "NSArray" "arrayWithObjects:count:" method_kind))
execute_NSArray_arrayWithObjects_count
let _ =
let method_kind = Procname.mangled_of_objc_method_kind Procname.Class_objc_method in
Builtin.register_procname
(Procname.ObjC_Cpp
(Procname.objc_cpp "NSArray" "arrayWithObjects:" method_kind))
execute_NSArray_arrayWithObjects
Builtin.register_procname arrayWithObjectsCount_pname execute_NSArray_arrayWithObjects_count;
Builtin.register_procname arrayWithObjects_pname execute_NSArray_arrayWithObjects
(* NSDictionary models *)
let execute_objc_NSDictionary_alloc_no_fail
symb_state
symb_state pname
({ Builtin.tenv; } as builtin_args) =
let nsdictionary_typ_ =
Sil.Tvar (Typename.TN_csu (Csu.Class Csu.Objc, Mangled.from_string "NSDictionary")) in
let nsdictionary_typ =
Tenv.expand_type tenv nsdictionary_typ_ in
execute_objc_alloc_no_fail symb_state nsdictionary_typ builtin_args
execute_objc_alloc_no_fail symb_state nsdictionary_typ (Some pname) builtin_args
let __objc_dictionary_literal_pname =
mk_objc_class_method "NSDictionary" "dictionaryWithObjects:forKeys:count:"
let execute___objc_dictionary_literal builtin_args =
let n_formals = 1 in
let res' = SymExec.check_variadic_sentinel ~fails_on_nil: true n_formals (0,1) builtin_args in
execute_objc_NSDictionary_alloc_no_fail res' builtin_args
let pname = __objc_dictionary_literal_pname in
execute_objc_NSDictionary_alloc_no_fail res' pname builtin_args
let __objc_dictionary_literal =
let method_kind = Procname.mangled_of_objc_method_kind Procname.Class_objc_method in
let pname =
Procname.ObjC_Cpp
(Procname.objc_cpp "NSDictionary" "__objc_dictionary_literal:" method_kind) in
let pname = __objc_dictionary_literal_pname in
Builtin.register_procname pname execute___objc_dictionary_literal;
pname

@ -139,7 +139,7 @@ struct
Tenv.add tenv block_name block_struct_typ;
let trans_res =
CTrans_utils.alloc_trans
trans_state loc (Ast_expressions.dummy_stmt_info ()) block_type true in
trans_state loc (Ast_expressions.dummy_stmt_info ()) block_type true None in
let id_block = match trans_res.exps with
| [(Sil.Var id, _)] -> id
| _ -> assert false in

@ -291,7 +291,7 @@ struct
end
(** This function handles ObjC new/alloc and C++ new calls *)
let create_alloc_instrs context sil_loc function_type fname size_exp_opt =
let create_alloc_instrs context sil_loc function_type fname size_exp_opt procname_opt =
let function_type, function_type_np =
match function_type with
| Sil.Tptr (styp, Sil.Pk_pointer)
@ -306,17 +306,21 @@ let create_alloc_instrs context sil_loc function_type fname size_exp_opt =
| Some exp -> Sil.BinOp (Sil.Mult, sizeof_exp_, exp)
| None -> sizeof_exp_ in
let exp = (sizeof_exp, Sil.Tint Sil.IULong) in
let procname_arg = match procname_opt with
| Some procname -> [Sil.Const (Sil.Cfun (procname)), Sil.Tvoid]
| None -> [] in
let args = exp :: procname_arg in
let ret_id = Ident.create_fresh Ident.knormal in
let stmt_call = Sil.Call([ret_id], (Sil.Const (Sil.Cfun fname)), [exp], sil_loc, Sil.cf_default) in
let stmt_call = Sil.Call([ret_id], (Sil.Const (Sil.Cfun fname)), args, sil_loc, Sil.cf_default) in
(function_type, ret_id, stmt_call, Sil.Var ret_id)
let alloc_trans trans_state loc stmt_info function_type is_cf_non_null_alloc =
let alloc_trans trans_state loc stmt_info function_type is_cf_non_null_alloc procname_opt =
let fname = if is_cf_non_null_alloc then
ModelBuiltins.__objc_alloc_no_fail
else
ModelBuiltins.__objc_alloc in
let (function_type, ret_id, stmt_call, exp) =
create_alloc_instrs trans_state.context loc function_type fname None in
create_alloc_instrs trans_state.context loc function_type fname None procname_opt in
let res_trans_tmp = { empty_res_trans with ids =[ret_id]; instrs =[stmt_call]} in
let res_trans =
let nname = "Call alloc" in
@ -326,7 +330,7 @@ let alloc_trans trans_state loc stmt_info function_type is_cf_non_null_alloc =
let objc_new_trans trans_state loc stmt_info cls_name function_type =
let fname = ModelBuiltins.__objc_alloc_no_fail in
let (alloc_ret_type, alloc_ret_id, alloc_stmt_call, _) =
create_alloc_instrs trans_state.context loc function_type fname None in
create_alloc_instrs trans_state.context loc function_type fname None None in
let init_ret_id = Ident.create_fresh Ident.knormal in
let is_instance = true in
let call_flags = { Sil.cf_default with Sil.cf_virtual = is_instance; } in
@ -350,7 +354,7 @@ let new_or_alloc_trans trans_state loc stmt_info type_ptr class_name_opt selecto
| Some class_name -> class_name
| None -> CTypes.classname_of_type function_type in
if selector = CFrontend_config.alloc then
alloc_trans trans_state loc stmt_info function_type true
alloc_trans trans_state loc stmt_info function_type true None
else if selector = CFrontend_config.new_str then
objc_new_trans trans_state loc stmt_info class_name function_type
else assert false
@ -361,7 +365,7 @@ let cpp_new_trans trans_state sil_loc function_type size_exp_opt =
| Some _ -> ModelBuiltins.__new_array
| None -> ModelBuiltins.__new in
let (function_type, ret_id, stmt_call, exp) =
create_alloc_instrs trans_state.context sil_loc function_type fname size_exp_opt in
create_alloc_instrs trans_state.context sil_loc function_type fname size_exp_opt None in
{ empty_res_trans with ids = [ret_id]; instrs = [stmt_call]; exps = [(exp, function_type)] }
let create_cast_instrs context exp cast_from_typ cast_to_typ sil_loc =
@ -385,9 +389,9 @@ let cast_trans context exps sil_loc callee_pname_opt function_type =
let builtin_trans trans_state loc stmt_info function_type callee_pname_opt =
if CTrans_models.is_cf_non_null_alloc callee_pname_opt ||
CTrans_models.is_alloc_model function_type callee_pname_opt then
Some (alloc_trans trans_state loc stmt_info function_type true)
Some (alloc_trans trans_state loc stmt_info function_type true callee_pname_opt)
else if CTrans_models.is_alloc callee_pname_opt then
Some (alloc_trans trans_state loc stmt_info function_type false)
Some (alloc_trans trans_state loc stmt_info function_type false None)
else None
let dereference_var_sil (exp, typ) sil_loc =

@ -101,7 +101,8 @@ val builtin_trans : trans_state -> Location.t -> Clang_ast_t.stmt_info ->
Sil.typ -> Procname.t option -> trans_result option
val alloc_trans :
trans_state -> Location.t -> Clang_ast_t.stmt_info -> Sil.typ -> bool -> trans_result
trans_state -> Location.t -> Clang_ast_t.stmt_info -> Sil.typ -> bool ->
Procname.t option -> trans_result
val new_or_alloc_trans : trans_state -> Location.t -> Clang_ast_t.stmt_info ->
Clang_ast_t.type_ptr -> string option -> string -> trans_result

@ -154,7 +154,7 @@ digraph iCFG {
33 -> 32 ;
32 [label="32: DeclStmt \n n$25=_fun_CGPathCreateMutable() [line 62]\n *&path1:struct CGPath *=n$25 [line 62]\n REMOVE_TEMPS(n$25); [line 62]\n " shape="box"]
32 [label="32: DeclStmt \n n$25=_fun___objc_alloc_no_fail(sizeof(struct CGPath ):unsigned long ,_fun_CGPathCreateMutable:void ) [line 62]\n *&path1:struct CGPath *=n$25 [line 62]\n REMOVE_TEMPS(n$25); [line 62]\n " shape="box"]
32 -> 31 ;
@ -173,7 +173,7 @@ digraph iCFG {
28 -> 27 ;
27 [label="27: Call _fun_CGPathCreateMutable \n n$21=_fun_CGPathCreateMutable() [line 55]\n REMOVE_TEMPS(n$21); [line 55]\n APPLY_ABSTRACTION; [line 55]\n " shape="box"]
27 [label="27: Call alloc \n n$21=_fun___objc_alloc_no_fail(sizeof(struct CGPath ):unsigned long ,_fun_CGPathCreateMutable:void ) [line 55]\n REMOVE_TEMPS(n$21); [line 55]\n APPLY_ABSTRACTION; [line 55]\n " shape="box"]
27 -> 26 ;
@ -210,7 +210,7 @@ digraph iCFG {
18 -> 20 ;
17 [label="17: DeclStmt \n n$16=_fun_CFAttributedStringCreateMutable(0:struct __CFAllocator *,0:long ) [line 40]\n *&maString:struct __CFAttributedString *=n$16 [line 39]\n REMOVE_TEMPS(n$16); [line 39]\n " shape="box"]
17 [label="17: DeclStmt \n n$16=_fun___objc_alloc_no_fail(sizeof(struct __CFAttributedString ):unsigned long ,_fun_CFAttributedStringCreateMutable:void ) [line 40]\n *&maString:struct __CFAttributedString *=n$16 [line 39]\n REMOVE_TEMPS(n$16); [line 39]\n " shape="box"]
17 -> 16 ;
@ -225,7 +225,7 @@ digraph iCFG {
14 -> 17 ;
13 [label="13: Call _fun_CFAttributedStringCreateMutable \n n$14=_fun_CFAttributedStringCreateMutable(0:struct __CFAllocator *,0:long ) [line 35]\n REMOVE_TEMPS(n$14); [line 35]\n APPLY_ABSTRACTION; [line 35]\n " shape="box"]
13 [label="13: Call alloc \n n$14=_fun___objc_alloc_no_fail(sizeof(struct __CFAttributedString ):unsigned long ,_fun_CFAttributedStringCreateMutable:void ) [line 35]\n REMOVE_TEMPS(n$14); [line 35]\n APPLY_ABSTRACTION; [line 35]\n " shape="box"]
13 -> 12 ;
@ -236,7 +236,7 @@ digraph iCFG {
11 -> 13 ;
10 [label="10: DeclStmt \n n$10=*&self:class MemoryLeakExample * [line 30]\n n$11=_fun_MemoryLeakExample_backgroundCoveringView(n$10:class MemoryLeakExample *) [line 30]\n n$12=_fun_UIView_bounds(n$11:class UIView *) [line 30]\n n$13=_fun_CGPathCreateWithRect(n$12:struct CGRect ,0:struct CGAffineTransform *) [line 30]\n *&shadowPath:struct CGPath *=n$13 [line 29]\n REMOVE_TEMPS(n$10,n$11,n$12,n$13); [line 29]\n " shape="box"]
10 [label="10: DeclStmt \n n$13=_fun___objc_alloc_no_fail(sizeof(struct CGPath ):unsigned long ,_fun_CGPathCreateWithRect:void ) [line 30]\n *&shadowPath:struct CGPath *=n$13 [line 29]\n REMOVE_TEMPS(n$13); [line 29]\n " shape="box"]
10 -> 9 ;
@ -255,7 +255,7 @@ digraph iCFG {
6 -> 5 ;
5 [label="5: DeclStmt \n n$2=*&attachmentContainerView:class UIView * [line 22]\n n$3=_fun_UIView_bounds(n$2:class UIView *) [line 22]\n n$4=_fun_CGPathCreateWithRect(n$3:struct CGRect ,0:struct CGAffineTransform *) [line 22]\n *&shadowPath:struct CGPath *=n$4 [line 21]\n REMOVE_TEMPS(n$2,n$3,n$4); [line 21]\n " shape="box"]
5 [label="5: DeclStmt \n n$4=_fun___objc_alloc_no_fail(sizeof(struct CGPath ):unsigned long ,_fun_CGPathCreateWithRect:void ) [line 22]\n *&shadowPath:struct CGPath *=n$4 [line 21]\n REMOVE_TEMPS(n$4); [line 21]\n " shape="box"]
5 -> 4 ;

@ -1,5 +1,5 @@
digraph iCFG {
6 [label="6: Return Stmt \n n$0=_fun_NSString_stringWithUTF8String:(\"Matt\":char *) [line 25]\n n$1=_fun_NSString_stringWithUTF8String:(\"firstName\":char *) [line 25]\n n$2=_fun_NSString_stringWithUTF8String:(\"Galloway\":char *) [line 25]\n n$3=_fun_NSString_stringWithUTF8String:(\"lastName\":char *) [line 25]\n n$4=_fun_NSNumber_numberWithInt:(28:int ) [line 25]\n n$5=_fun_NSString_stringWithUTF8String:(\"age\":char *) [line 25]\n n$6=_fun_NSDictionary___objc_dictionary_literal:(n$0:struct objc_object *,n$1:struct objc_object *,n$2:struct objc_object *,n$3:struct objc_object *,n$4:struct objc_object *,n$5:struct objc_object *,0:struct objc_object *) [line 25]\n *&return:class NSDictionary *=n$6 [line 25]\n REMOVE_TEMPS(n$0,n$1,n$2,n$3,n$4,n$5,n$6); [line 25]\n APPLY_ABSTRACTION; [line 25]\n " shape="box"]
6 [label="6: Return Stmt \n n$0=_fun_NSString_stringWithUTF8String:(\"Matt\":char *) [line 25]\n n$1=_fun_NSString_stringWithUTF8String:(\"firstName\":char *) [line 25]\n n$2=_fun_NSString_stringWithUTF8String:(\"Galloway\":char *) [line 25]\n n$3=_fun_NSString_stringWithUTF8String:(\"lastName\":char *) [line 25]\n n$4=_fun_NSNumber_numberWithInt:(28:int ) [line 25]\n n$5=_fun_NSString_stringWithUTF8String:(\"age\":char *) [line 25]\n n$6=_fun_NSDictionary_dictionaryWithObjects:forKeys:count:(n$0:struct objc_object *,n$1:struct objc_object *,n$2:struct objc_object *,n$3:struct objc_object *,n$4:struct objc_object *,n$5:struct objc_object *,0:struct objc_object *) [line 25]\n *&return:class NSDictionary *=n$6 [line 25]\n REMOVE_TEMPS(n$0,n$1,n$2,n$3,n$4,n$5,n$6); [line 25]\n APPLY_ABSTRACTION; [line 25]\n " shape="box"]
6 -> 5 ;

Loading…
Cancel
Save