Commit Graph

12 Commits

Author SHA1 Message Date
Ben Langmuir 443aa4b4b0 Allow (Object *)kMyGlobalCFObj casts without bridging
Previously we allowed these casts only for constants declared in system
headers, which we assume are retain/release-neutral. Now also allow them
for constants in user headers, treating them as +0.  Practically, this
means that we will now allow:
id x = (id)kMyGlobalConst;

But unlike with system headers we cannot mix them with +1 values:
id y = (id)(b ? kMyGlobalConst : [Obj newValAtPlusOne]); // error
id z = (id)(b ? kSystemGlobalConst: [Obj newValAtPlusOne]); // OK

Thanks to John for suggesting this improvement.

llvm-svn: 230534
2015-02-25 20:09:06 +00:00
Alp Toker 5a60686cf9 Remove all DISABLE lines from tests
There's no evidence that a 'DISABLE' directive ever existed.

Let's see if anything breaks..

llvm-svn: 196733
2013-12-08 21:12:19 +00:00
Argyrios Kyrtzidis b03cc793a9 [arcmt] At an unbridged cast error, if we're returning a load-of-ivar from a +0 method,
automatically insert a __bridge cast.

radar://11560638

llvm-svn: 158127
2012-06-07 00:44:06 +00:00
Argyrios Kyrtzidis 7e79129d15 [arcmt] The migrator tests for the buildbot in http://lab.llvm.org:8011/builders/clang-native-mingw32-win7/
are messed up, XFAIL does not help. Waiting until DISABLE is supported..

llvm-svn: 148012
2012-01-12 02:34:32 +00:00
Argyrios Kyrtzidis 33976a6365 [arcmt] XFAIL on mingw.
llvm-svn: 147830
2012-01-10 02:39:29 +00:00
Argyrios Kyrtzidis 10398a3789 [arcmt] Disable tests in mingw, no idea why they are failing there.
llvm-svn: 147713
2012-01-07 02:24:23 +00:00
John McCall 9b0a7cea0f Make -fobjc-nonfragile-abi the -cc1 default, since it's the
increasingly prevailing case to the point that new features
like ARC don't even support the fragile ABI anymore.

This required a little bit of reshuffling with exceptions
because a check was assuming that ObjCNonFragileABI was
only being set in ObjC mode, and that's actually a bit
obnoxious to do.

Most, though, it involved a perl script to translate a ton
of test cases.

Mostly no functionality change for driver users, although
there are corner cases with disabling language-specific
exceptions that we should handle more correctly now.

llvm-svn: 140957
2011-10-02 01:16:38 +00:00
Argyrios Kyrtzidis 41899f3bac [arcmt] Use __bridge_retained when passing an objc object to a CF parameter
annotated with cf_consumed attribute.

llvm-svn: 139709
2011-09-14 18:17:09 +00:00
Argyrios Kyrtzidis 9390747349 [arcmt] More automatic transformations and safety improvements; rdar://9615812 :
- Replace calling -zone with 'nil'. -zone is obsolete in ARC.
- Allow removing retain/release on a static global var.
- Fix assertion hit when scanning for name references outside a NSAutoreleasePool scope.
- Automatically add bridged casts for results of objc method calls and when calling CFRetain, for example:

NSString *s;
CFStringRef ref = [s string];   -> CFStringRef ref = (__bridge CFStringRef)([s string]);
ref = s.string;                 -> ref = (__bridge CFStringRef)(s.string);
ref = [NSString new];           -> ref = (__bridge_retained CFStringRef)([NSString new]);
ref = [s newString];            -> ref = (__bridge_retained CFStringRef)([s newString]);
ref = [[NSString alloc] init];  -> ref = (__bridge_retained CFStringRef)([[NSString alloc] init]);
ref = [[s string] retain];      -> ref = (__bridge_retained CFStringRef)([s string]);
ref = CFRetain(s);              -> ref = (__bridge_retained CFTypeRef)(s);
ref = [s retain];               -> ref = (__bridge_retained CFStringRef)(s);

- Emit migrator error when trying to cast to CF type the result of autorelease/release:
  for

CFStringRef f3() {
  return (CFStringRef)[[[NSString alloc] init] autorelease];
}

emits:

t.m:12:10: error: [rewriter] it is not safe to cast to 'CFStringRef' the result of 'autorelease' message; a __bridge cast may result in a pointer to a destroyed object and a __bridge_retained may leak the object
  return (CFStringRef)[[[NSString alloc] init] autorelease];
         ^            ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
t.m:12:3: note: [rewriter] remove the cast and change return type of function to 'NSString *' to have the object automatically autoreleased
  return (CFStringRef)[[[NSString alloc] init] autorelease];
  ^

- Before changing attributes to weak/unsafe_unretained, check if the backing ivar
  is set to a +1 object, in which case use 'strong' instead.

llvm-svn: 136208
2011-07-27 05:28:18 +00:00
Argyrios Kyrtzidis 0a9d652331 [arcmt] Always add '__bridge' cast when 'self' is cast to a C pointer. rdar://9644061
llvm-svn: 133480
2011-06-20 23:39:20 +00:00
Argyrios Kyrtzidis 6e4ef20baf [arcmt] Make arcmt-test accept cc1 options to make it more portable and hopefully fix MSVC failures.
llvm-svn: 133119
2011-06-16 00:53:46 +00:00
John McCall d70fb9812a The ARC Migration Tool. All the credit goes to Argyrios and Fariborz
for this.

llvm-svn: 133104
2011-06-15 23:25:17 +00:00