[cfe-commits] r160839 - in /cfe/trunk: lib/Sema/SemaExprObjC.cpp test/ARCMT/checking.m test/ARCMT/no-canceling-bridge-to-bridge-cast.m test/ARCMT/nonobjc-to-objc-cast-2.m test/SemaObjC/arc-bridged-cast.m test/SemaObjC/arc-cf.m test/SemaObjC/arc-type-conversion.m test/SemaObjC/arc-unbridged-cast.m test/SemaObjC/arc.m test/SemaObjCXX/arc-unbridged-cast.mm

Jordan Rose jordan_rose at apple.com
Fri Jul 27 09:35:21 PDT 2012


This commit was bothering me for a while, and I think I know why:

- (id)getSpecialName:(CFDictionaryRef)dict {
  return [(NSDictionary *)dict objectForKey:MySpecialKey];
}

- (voidd)extractSpecialName:(CFDictionaryRef)dict {
  _ivar = (id)CFDictionaryGetValue(dict, MySpecialCFKey);
}

Using CFBridgingRelease here would be very very wrong, in either case.


On Jul 26, 2012, at 4:17 PM, Fariborz Jahanian <fjahanian at apple.com> wrote:

> Author: fjahanian
> Date: Thu Jul 26 18:17:04 2012
> New Revision: 160839
> 
> URL: http://llvm.org/viewvc/llvm-project?rev=160839&view=rev
> Log:
> objc-arc: When objects with known CF semantics are assigned to
> retainable types in arc, only suggest CFBridgingRelease/
> CFBridgingRetain and not the confusing __bridge casts.
> // rdar://11923822
> 
> Modified:
>    cfe/trunk/lib/Sema/SemaExprObjC.cpp
>    cfe/trunk/test/ARCMT/checking.m
>    cfe/trunk/test/ARCMT/no-canceling-bridge-to-bridge-cast.m
>    cfe/trunk/test/ARCMT/nonobjc-to-objc-cast-2.m
>    cfe/trunk/test/SemaObjC/arc-bridged-cast.m
>    cfe/trunk/test/SemaObjC/arc-cf.m
>    cfe/trunk/test/SemaObjC/arc-type-conversion.m
>    cfe/trunk/test/SemaObjC/arc-unbridged-cast.m
>    cfe/trunk/test/SemaObjC/arc.m
>    cfe/trunk/test/SemaObjCXX/arc-unbridged-cast.mm
> 
> Modified: cfe/trunk/lib/Sema/SemaExprObjC.cpp
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaExprObjC.cpp?rev=160839&r1=160838&r2=160839&view=diff
> ==============================================================================
> --- cfe/trunk/lib/Sema/SemaExprObjC.cpp (original)
> +++ cfe/trunk/lib/Sema/SemaExprObjC.cpp Thu Jul 26 18:17:04 2012
> @@ -2918,19 +2918,12 @@
>       << castRange
>       << castExpr->getSourceRange();
>     bool br = S.isKnownName("CFBridgingRelease");
> -    {
> -      DiagnosticBuilder DiagB = S.Diag(noteLoc, diag::note_arc_bridge);
> -      addFixitForObjCARCConversion(S, DiagB, CCK, afterLParen,
> -                                   castType, castExpr, "__bridge ", 0);
> -    }
> -    {
> -      DiagnosticBuilder DiagB = S.Diag(br ? castExpr->getExprLoc() : noteLoc,
> -                                       diag::note_arc_bridge_transfer)
> -        << castExprType << br;
> -      addFixitForObjCARCConversion(S, DiagB, CCK, afterLParen,
> -                                   castType, castExpr, "__bridge_transfer ",
> -                                   br ? "CFBridgingRelease" : 0);
> -    }
> +    DiagnosticBuilder DiagB = S.Diag(br ? castExpr->getExprLoc() : noteLoc,
> +                                     diag::note_arc_bridge_transfer)
> +                                << castExprType << br;
> +    addFixitForObjCARCConversion(S, DiagB, CCK, afterLParen,
> +                                 castType, castExpr, "__bridge_transfer ",
> +                                 br ? "CFBridgingRelease" : 0);
> 
>     return;
>   }
> @@ -2946,20 +2939,12 @@
>       << castType
>       << castRange
>       << castExpr->getSourceRange();
> -
> -    {
> -      DiagnosticBuilder DiagB = S.Diag(noteLoc, diag::note_arc_bridge);
> -      addFixitForObjCARCConversion(S, DiagB, CCK, afterLParen,
> -                                   castType, castExpr, "__bridge ", 0);
> -    }
> -    {
> -      DiagnosticBuilder DiagB = S.Diag(br ? castExpr->getExprLoc() : noteLoc,
> -                                       diag::note_arc_bridge_retained)
> -        << castType << br;
> -      addFixitForObjCARCConversion(S, DiagB, CCK, afterLParen,
> -                                   castType, castExpr, "__bridge_retained ",
> -                                   br ? "CFBridgingRetain" : 0);
> -    }
> +    DiagnosticBuilder DiagB = S.Diag(br ? castExpr->getExprLoc() : noteLoc,
> +                                     diag::note_arc_bridge_retained)
> +                                  << castType << br;
> +    addFixitForObjCARCConversion(S, DiagB, CCK, afterLParen,
> +                                 castType, castExpr, "__bridge_retained ",
> +                                 br ? "CFBridgingRetain" : 0);
> 
>     return;
>   }
> 
> Modified: cfe/trunk/test/ARCMT/checking.m
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/ARCMT/checking.m?rev=160839&r1=160838&r2=160839&view=diff
> ==============================================================================
> --- cfe/trunk/test/ARCMT/checking.m (original)
> +++ cfe/trunk/test/ARCMT/checking.m Thu Jul 26 18:17:04 2012
> @@ -101,7 +101,6 @@
> 
>   CFStringRef cfstr;
>   NSString *str = (NSString *)cfstr; // expected-error {{cast of C pointer type 'CFStringRef' (aka 'const struct __CFString *') to Objective-C pointer type 'NSString *' requires a bridged cast}} \
> -  // expected-note {{use __bridge to convert directly (no change in ownership)}} \
>   // expected-note {{use CFBridgingRelease call to transfer ownership of a +1 'CFStringRef' (aka 'const struct __CFString *') into ARC}} \
>   str = (NSString *)kUTTypePlainText;
>   str = b ? kUTTypeRTF : kUTTypePlainText;
> @@ -160,10 +159,10 @@
>   (void)(void*)voidp_val;
>   (void)(void**)arg; // expected-error {{disallowed}}
>   cvt((void*)arg); // expected-error 2 {{requires a bridged cast}} \
> -                   // expected-note 2 {{use __bridge to}} expected-note {{use CFBridgingRelease call}} expected-note {{use CFBridgingRetain call}}
> +                   expected-note {{use CFBridgingRelease call}} expected-note {{use CFBridgingRetain call}}
>   cvt(0);
>   (void)(__strong id**)(0);
> -  return arg; // expected-error {{requires a bridged cast}} expected-note {{use __bridge}} expected-note {{use CFBridgingRetain call}}
> +  return arg; // expected-error {{requires a bridged cast}} expected-note {{use CFBridgingRetain call}}
> }
> 
> 
> 
> Modified: cfe/trunk/test/ARCMT/no-canceling-bridge-to-bridge-cast.m
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/ARCMT/no-canceling-bridge-to-bridge-cast.m?rev=160839&r1=160838&r2=160839&view=diff
> ==============================================================================
> --- cfe/trunk/test/ARCMT/no-canceling-bridge-to-bridge-cast.m (original)
> +++ cfe/trunk/test/ARCMT/no-canceling-bridge-to-bridge-cast.m Thu Jul 26 18:17:04 2012
> @@ -24,15 +24,12 @@
>   NSString *result;
> 
>   result = (id) CFRetain([NSString stringWithFormat:@"PBXLoopMode"]); // expected-error {{cast of C pointer type 'CFTypeRef' (aka 'const void *') to Objective-C pointer type 'id' requires a bridged cast}} \
> -								      // expected-note {{use __bridge to convert directly (no change in ownership)}} \
> 								      // expected-note {{use CFBridgingRelease call to transfer ownership of a +1 'CFTypeRef' (aka 'const void *') into ARC}}
> 
>   result = (id) CFRetain((id)((objc_format))); // expected-error {{cast of C pointer type 'CFTypeRef' (aka 'const void *') to Objective-C pointer type 'id' requires a bridged cast}} \
> -					       // expected-note {{use __bridge to convert directly (no change in ownership)}} \
> 					       // expected-note {{use CFBridgingRelease call to transfer ownership of a +1 'CFTypeRef' (aka 'const void *') into ARC}}
> 
>   result = (id) CFRetain((id)((cf_format))); // expected-error {{cast of C pointer type 'CFTypeRef' (aka 'const void *') to Objective-C pointer type 'id' requires a bridged cast}} \
> -					     // expected-note {{use __bridge to convert directly (no change in ownership)}} \
>                                              // expected-note {{use CFBridgingRelease call to transfer ownership of a +1 'CFTypeRef' (aka 'const void *') into ARC}}
> 
>   result = (id) CFRetain((CFTypeRef)((objc_format)));
> 
> Modified: cfe/trunk/test/ARCMT/nonobjc-to-objc-cast-2.m
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/ARCMT/nonobjc-to-objc-cast-2.m?rev=160839&r1=160838&r2=160839&view=diff
> ==============================================================================
> --- cfe/trunk/test/ARCMT/nonobjc-to-objc-cast-2.m (original)
> +++ cfe/trunk/test/ARCMT/nonobjc-to-objc-cast-2.m Thu Jul 26 18:17:04 2012
> @@ -29,7 +29,6 @@
> }
> -(id)newString {
>   return sref; // expected-error {{implicit conversion of C pointer type 'CFStringRef' (aka 'const struct __CFString *') to Objective-C pointer type 'id' requires a bridged cast}} \
> -    // expected-note{{use __bridge to convert directly (no change in ownership)}} \
>     // expected-note{{use CFBridgingRelease call to transfer ownership of a +1 'CFStringRef' (aka 'const struct __CFString *') into ARC}}
> }
> @end
> @@ -37,16 +36,14 @@
> void f(BOOL b) {
>   CFStringRef cfstr;
>   NSString *str = (NSString *)cfstr; // expected-error {{cast of C pointer type 'CFStringRef' (aka 'const struct __CFString *') to Objective-C pointer type 'NSString *' requires a bridged cast}} \
> -    // expected-note{{use __bridge to convert directly (no change in ownership)}} \
>     // expected-note{{use CFBridgingRelease call to transfer ownership of a +1 'CFStringRef' (aka 'const struct __CFString *') into ARC}}
> -  void *vp = str;  // expected-error {{requires a bridged cast}} expected-note {{use CFBridgingRetain call}} expected-note {{use __bridge}}
> +  void *vp = str;  // expected-error {{requires a bridged cast}} expected-note {{use CFBridgingRetain call}}
> }
> 
> void f2(NSString *s) {
>   CFStringRef ref;
>   ref = [(CFStringRef)[s string] retain]; // expected-error {{cast of Objective-C pointer type 'id' to C pointer type 'CFStringRef' (aka 'const struct __CFString *') requires a bridged cast}} \
>     // expected-error {{bad receiver type 'CFStringRef' (aka 'const struct __CFString *')}} \
> -    // expected-note{{use __bridge to convert directly (no change in ownership)}} \
>     // expected-note{{use CFBridgingRetain call to make an ARC object available as a +1 'CFStringRef' (aka 'const struct __CFString *')}}
> }
> 
> 
> Modified: cfe/trunk/test/SemaObjC/arc-bridged-cast.m
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaObjC/arc-bridged-cast.m?rev=160839&r1=160838&r2=160839&view=diff
> ==============================================================================
> --- cfe/trunk/test/SemaObjC/arc-bridged-cast.m (original)
> +++ cfe/trunk/test/SemaObjC/arc-bridged-cast.m Thu Jul 26 18:17:04 2012
> @@ -38,30 +38,22 @@
> 
> CFTypeRef fixits() {
>   id obj1 = (id)CFCreateSomething(); // expected-error{{cast of C pointer type 'CFTypeRef' (aka 'const void *') to Objective-C pointer type 'id' requires a bridged cast}} \
> -  // expected-note{{use __bridge to convert directly (no change in ownership)}} \
>   // expected-note{{use CFBridgingRelease call to transfer ownership of a +1 'CFTypeRef' (aka 'const void *') into ARC}}
> -  // CHECK: fix-it:"{{.*}}":{40:14-40:14}:"__bridge "
>   // CHECK: fix-it:"{{.*}}":{40:17-40:17}:"CFBridgingRelease("
>   // CHECK: fix-it:"{{.*}}":{40:36-40:36}:")"
> 
>   CFTypeRef cf1 = (CFTypeRef)CreateSomething(); // expected-error{{cast of Objective-C pointer type 'id' to C pointer type 'CFTypeRef' (aka 'const void *') requires a bridged cast}} \
> -  // expected-note{{use __bridge to convert directly (no change in ownership)}} \
>   // expected-note{{use CFBridgingRetain call to make an ARC object available as a +1 'CFTypeRef' (aka 'const void *')}}
> -  // CHECK: fix-it:"{{.*}}":{47:20-47:20}:"__bridge "
> -  // CHECK: fix-it:"{{.*}}":{47:30-47:30}:"CFBridgingRetain("
> -  // CHECK: fix-it:"{{.*}}":{47:47-47:47}:")"
> +  // CHECK: fix-it:"{{.*}}":{45:30-45:30}:"CFBridgingRetain("
> +  // CHECK: fix-it:"{{.*}}":{45:47-45:47}:")"
> 
>   return (obj1); // expected-error{{implicit conversion of Objective-C pointer type 'id' to C pointer type 'CFTypeRef' (aka 'const void *') requires a bridged cast}} \
> -  // expected-note{{use __bridge to convert directly (no change in ownership)}} \
>   // expected-note{{use CFBridgingRetain call to make an ARC object available as a +1 'CFTypeRef' (aka 'const void *')}}
> -  // CHECK: fix-it:"{{.*}}":{54:10-54:10}:"(__bridge CFTypeRef)"
> -  // CHECK: fix-it:"{{.*}}":{54:10-54:10}:"CFBridgingRetain"
> +  // CHECK: fix-it:"{{.*}}":{50:10-50:10}:"CFBridgingRetain"
> }
> 
> CFTypeRef fixitsWithSpace(id obj) {
>   return(obj); // expected-error{{implicit conversion of Objective-C pointer type 'id' to C pointer type 'CFTypeRef' (aka 'const void *') requires a bridged cast}} \
> -  // expected-note{{use __bridge to convert directly (no change in ownership)}} \
>   // expected-note{{use CFBridgingRetain call to make an ARC object available as a +1 'CFTypeRef' (aka 'const void *')}}
> -  // CHECK: fix-it:"{{.*}}":{62:9-62:9}:"(__bridge CFTypeRef)"
> -  // CHECK: fix-it:"{{.*}}":{62:9-62:9}:" CFBridgingRetain"
> +  // CHECK: fix-it:"{{.*}}":{56:9-56:9}:" CFBridgingRetain"
> }
> 
> Modified: cfe/trunk/test/SemaObjC/arc-cf.m
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaObjC/arc-cf.m?rev=160839&r1=160838&r2=160839&view=diff
> ==============================================================================
> --- cfe/trunk/test/SemaObjC/arc-cf.m (original)
> +++ cfe/trunk/test/SemaObjC/arc-cf.m Thu Jul 26 18:17:04 2012
> @@ -13,8 +13,8 @@
> extern CFStringRef CFCreateString0(void);
> void test0() {
>   id x;
> -  x = (id) CFMakeString0(); // expected-error {{requires a bridged cast}} expected-note {{__bridge to convert directly}} expected-note {{CFBridgingRelease call to transfer}}
> -  x = (id) CFCreateString0(); // expected-error {{requires a bridged cast}} expected-note {{__bridge to convert directly}} expected-note {{CFBridgingRelease call to transfer}}
> +  x = (id) CFMakeString0(); // expected-error {{requires a bridged cast}} expected-note {{CFBridgingRelease call to transfer}}
> +  x = (id) CFCreateString0(); // expected-error {{requires a bridged cast}} expected-note {{CFBridgingRelease call to transfer}}
> }
> 
> extern CFStringRef CFMakeString1(void) __attribute__((cf_returns_not_retained));
> @@ -22,7 +22,7 @@
> void test1() {
>   id x;
>   x = (id) CFMakeString1();
> -  x = (id) CFCreateString1(); // expected-error {{requires a bridged cast}} expected-note {{__bridge to convert directly}} expected-note {{CFBridgingRelease call to transfer}}
> +  x = (id) CFCreateString1(); // expected-error {{requires a bridged cast}} expected-note {{CFBridgingRelease call to transfer}}
> }
> 
> #define CF_AUDIT_BEGIN _Pragma("clang arc_cf_code_audited begin")
> @@ -40,6 +40,6 @@
>   id x;
>   x = (id) CFMakeString2();
>   x = (id) CFCreateString2();
> -  x = (id) CFMakeString3(); // expected-error {{requires a bridged cast}} expected-note {{__bridge to convert directly}} expected-note {{CFBridgingRelease call to transfer}}
> -  x = (id) CFCreateString3(); // expected-error {{requires a bridged cast}} expected-note {{__bridge to convert directly}} expected-note {{CFBridgingRelease call to transfer}}
> +  x = (id) CFMakeString3(); // expected-error {{requires a bridged cast}} expected-note {{CFBridgingRelease call to transfer}}
> +  x = (id) CFCreateString3(); // expected-error {{requires a bridged cast}} expected-note {{CFBridgingRelease call to transfer}}
> }
> 
> Modified: cfe/trunk/test/SemaObjC/arc-type-conversion.m
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaObjC/arc-type-conversion.m?rev=160839&r1=160838&r2=160839&view=diff
> ==============================================================================
> --- cfe/trunk/test/SemaObjC/arc-type-conversion.m (original)
> +++ cfe/trunk/test/SemaObjC/arc-type-conversion.m Thu Jul 26 18:17:04 2012
> @@ -17,13 +17,11 @@
>   (void)(void**)arg; // expected-error {{cast of an Objective-C pointer to 'void **' is disallowed with ARC}}
>   cvt((void*)arg); // expected-error {{cast of Objective-C pointer type 'id' to C pointer type 'void *' requires a bridged cast}} \
>                    // expected-error {{implicit conversion of C pointer type 'void *' to Objective-C pointer type 'id' requires a bridged cast}} \
> -                   // expected-note 2 {{use __bridge to convert directly (no change in ownership)}} \
>                    // expected-note {{use CFBridgingRetain call to make an ARC object available as a +1 'void *'}} \
>                    // expected-note {{use CFBridgingRelease call to transfer ownership of a +1 'void *' into ARC}}
>   cvt(0);
>   (void)(__strong id**)(0);
>   return arg; // expected-error {{implicit conversion of Objective-C pointer type 'id' to C pointer type 'void *' requires a bridged cast}} \
> -                   // expected-note {{use __bridge to convert directly (no change in ownership)}} \
>                    // expected-note {{use CFBridgingRetain call to make an ARC object available as a +1 'void *'}}
> }
> 
> 
> Modified: cfe/trunk/test/SemaObjC/arc-unbridged-cast.m
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaObjC/arc-unbridged-cast.m?rev=160839&r1=160838&r2=160839&view=diff
> ==============================================================================
> --- cfe/trunk/test/SemaObjC/arc-unbridged-cast.m (original)
> +++ cfe/trunk/test/SemaObjC/arc-unbridged-cast.m Thu Jul 26 18:17:04 2012
> @@ -39,15 +39,15 @@
>   x = (id) (cond ? (void*) 0 : auditedString());
>   x = (id) (cond ? (CFStringRef) @"help" : auditedString());
> 
> -  x = (id) unauditedString(); // expected-error {{requires a bridged cast}} expected-note {{use __bridge to}} expected-note {{use CFBridgingRelease call to}}
> -  x = (id) (cond ? unauditedString() : (void*) 0); // expected-error {{requires a bridged cast}} expected-note {{use __bridge to}} expected-note {{use CFBridgingRelease call to}}
> -  x = (id) (cond ? (void*) 0 : unauditedString()); // expected-error {{requires a bridged cast}} expected-note {{use __bridge to}} expected-note {{use CFBridgingRelease call to}}
> -  x = (id) (cond ? (CFStringRef) @"help" : unauditedString()); // expected-error {{requires a bridged cast}} expected-note {{use __bridge to}} expected-note {{use CFBridgingRelease call to}}
> -
> -  x = (id) auditedCreateString(); // expected-error {{requires a bridged cast}} expected-note {{use __bridge to}} expected-note {{use CFBridgingRelease call to}}
> -  x = (id) (cond ? auditedCreateString() : (void*) 0); // expected-error {{requires a bridged cast}} expected-note {{use __bridge to}} expected-note {{use CFBridgingRelease call to}}
> -  x = (id) (cond ? (void*) 0 : auditedCreateString()); // expected-error {{requires a bridged cast}} expected-note {{use __bridge to}} expected-note {{use CFBridgingRelease call to}}
> -  x = (id) (cond ? (CFStringRef) @"help" : auditedCreateString()); // expected-error {{requires a bridged cast}} expected-note {{use __bridge to}} expected-note {{use CFBridgingRelease call to}}
> +  x = (id) unauditedString(); // expected-error {{requires a bridged cast}} expected-note {{use CFBridgingRelease call to}}
> +  x = (id) (cond ? unauditedString() : (void*) 0); // expected-error {{requires a bridged cast}} expected-note {{use CFBridgingRelease call to}}
> +  x = (id) (cond ? (void*) 0 : unauditedString()); // expected-error {{requires a bridged cast}} expected-note {{use CFBridgingRelease call to}}
> +  x = (id) (cond ? (CFStringRef) @"help" : unauditedString()); // expected-error {{requires a bridged cast}} expected-note {{use CFBridgingRelease call to}}
> +
> +  x = (id) auditedCreateString(); // expected-error {{requires a bridged cast}} expected-note {{use CFBridgingRelease call to}}
> +  x = (id) (cond ? auditedCreateString() : (void*) 0); // expected-error {{requires a bridged cast}} expected-note {{use CFBridgingRelease call to}}
> +  x = (id) (cond ? (void*) 0 : auditedCreateString()); // expected-error {{requires a bridged cast}} expected-note {{use CFBridgingRelease call to}}
> +  x = (id) (cond ? (CFStringRef) @"help" : auditedCreateString()); // expected-error {{requires a bridged cast}} expected-note {{use CFBridgingRelease call to}}
> 
>   x = (id) [object property];
>   x = (id) (cond ? [object property] : (void*) 0);
> @@ -84,7 +84,7 @@
> void testCFTaker(CFTaker *taker, id string) {
>   [taker takeOrdinary: (CFStringRef) string];
>   [taker takeVariadic: 1, (CFStringRef) string];
> -  [taker takeConsumed: (CFStringRef) string]; // expected-error {{cast of Objective-C pointer type 'id' to C pointer type 'CFStringRef'}} expected-note {{use __bridge to}} expected-note {{use CFBridgingRetain call to}}
> +  [taker takeConsumed: (CFStringRef) string]; // expected-error {{cast of Objective-C pointer type 'id' to C pointer type 'CFStringRef'}} expected-note {{use CFBridgingRetain call to}}
> }
> 
> void takeCFOrdinaryUnaudited(CFStringRef arg);
> @@ -97,27 +97,27 @@
> #pragma clang arc_cf_code_audited end
> 
> void testTakerFunctions(id string) {
> -  takeCFOrdinaryUnaudited((CFStringRef) string); // expected-error {{cast of Objective-C pointer type 'id' to C pointer type 'CFStringRef'}} expected-note {{use __bridge to}} expected-note {{use CFBridgingRetain call to}}
> -  takeCFVariadicUnaudited(1, (CFStringRef) string); // expected-error {{cast of Objective-C pointer type 'id' to C pointer type 'CFStringRef'}} expected-note {{use __bridge to}} expected-note {{use CFBridgingRetain call to}}
> -  takeCFConsumedUnaudited((CFStringRef) string); // expected-error {{cast of Objective-C pointer type 'id' to C pointer type 'CFStringRef'}} expected-note {{use __bridge to}} expected-note {{use CFBridgingRetain call to}}
> +  takeCFOrdinaryUnaudited((CFStringRef) string); // expected-error {{cast of Objective-C pointer type 'id' to C pointer type 'CFStringRef'}} expected-note {{use CFBridgingRetain call to}}
> +  takeCFVariadicUnaudited(1, (CFStringRef) string); // expected-error {{cast of Objective-C pointer type 'id' to C pointer type 'CFStringRef'}} expected-note {{use CFBridgingRetain call to}}
> +  takeCFConsumedUnaudited((CFStringRef) string); // expected-error {{cast of Objective-C pointer type 'id' to C pointer type 'CFStringRef'}} expected-note {{use CFBridgingRetain call to}}
> 
>   void (*taker)(CFStringRef) = 0;
> -  taker((CFStringRef) string); // expected-error {{cast of Objective-C pointer type 'id' to C pointer type 'CFStringRef'}} expected-note {{use __bridge to}} expected-note {{use CFBridgingRetain call to}}
> +  taker((CFStringRef) string); // expected-error {{cast of Objective-C pointer type 'id' to C pointer type 'CFStringRef'}} expected-note {{use CFBridgingRetain call to}}
> 
>   takeCFOrdinaryAudited((CFStringRef) string);
>   takeCFVariadicAudited(1, (CFStringRef) string);
> -  takeCFConsumedAudited((CFStringRef) string); // expected-error {{cast of Objective-C pointer type 'id' to C pointer type 'CFStringRef'}} expected-note {{use __bridge to}} expected-note {{use CFBridgingRetain call to}}
> +  takeCFConsumedAudited((CFStringRef) string); // expected-error {{cast of Objective-C pointer type 'id' to C pointer type 'CFStringRef'}} expected-note {{use CFBridgingRetain call to}}
> }
> 
> void testTakerFunctions_parens(id string) {
> -  takeCFOrdinaryUnaudited(((CFStringRef) string)); // expected-error {{cast of Objective-C pointer type 'id' to C pointer type 'CFStringRef'}} expected-note {{use __bridge to}} expected-note {{use CFBridgingRetain call to}}
> -  takeCFVariadicUnaudited(1, ((CFStringRef) string)); // expected-error {{cast of Objective-C pointer type 'id' to C pointer type 'CFStringRef'}} expected-note {{use __bridge to}} expected-note {{use CFBridgingRetain call to}}
> -  takeCFConsumedUnaudited(((CFStringRef) string)); // expected-error {{cast of Objective-C pointer type 'id' to C pointer type 'CFStringRef'}} expected-note {{use __bridge to}} expected-note {{use CFBridgingRetain call to}}
> +  takeCFOrdinaryUnaudited(((CFStringRef) string)); // expected-error {{cast of Objective-C pointer type 'id' to C pointer type 'CFStringRef'}} expected-note {{use CFBridgingRetain call to}}
> +  takeCFVariadicUnaudited(1, ((CFStringRef) string)); // expected-error {{cast of Objective-C pointer type 'id' to C pointer type 'CFStringRef'}} expected-note {{use CFBridgingRetain call to}}
> +  takeCFConsumedUnaudited(((CFStringRef) string)); // expected-error {{cast of Objective-C pointer type 'id' to C pointer type 'CFStringRef'}} expected-note {{use CFBridgingRetain call to}}
> 
>   void (*taker)(CFStringRef) = 0;
> -  taker(((CFStringRef) string)); // expected-error {{cast of Objective-C pointer type 'id' to C pointer type 'CFStringRef'}} expected-note {{use __bridge to}} expected-note {{use CFBridgingRetain call to}}
> +  taker(((CFStringRef) string)); // expected-error {{cast of Objective-C pointer type 'id' to C pointer type 'CFStringRef'}} expected-note {{use CFBridgingRetain call to}}
> 
>   takeCFOrdinaryAudited(((CFStringRef) string));
>   takeCFVariadicAudited(1, ((CFStringRef) string));
> -  takeCFConsumedAudited(((CFStringRef) string)); // expected-error {{cast of Objective-C pointer type 'id' to C pointer type 'CFStringRef'}} expected-note {{use __bridge to}} expected-note {{use CFBridgingRetain call to}}
> +  takeCFConsumedAudited(((CFStringRef) string)); // expected-error {{cast of Objective-C pointer type 'id' to C pointer type 'CFStringRef'}} expected-note {{use CFBridgingRetain call to}}
> }
> 
> Modified: cfe/trunk/test/SemaObjC/arc.m
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaObjC/arc.m?rev=160839&r1=160838&r2=160839&view=diff
> ==============================================================================
> --- cfe/trunk/test/SemaObjC/arc.m (original)
> +++ cfe/trunk/test/SemaObjC/arc.m Thu Jul 26 18:17:04 2012
> @@ -264,8 +264,8 @@
>   b = (vp == nil);
>   b = (nil == vp);
> 
> -  b = (vp == op); // expected-error {{implicit conversion of Objective-C pointer type 'id' to C pointer type 'void *' requires a bridged cast}} expected-note {{use __bridge}} expected-note {{use CFBridgingRetain call}}
> -  b = (op == vp); // expected-error {{implicit conversion of C pointer type 'void *' to Objective-C pointer type 'id' requires a bridged cast}} expected-note {{use __bridge}} expected-note {{use CFBridgingRelease call}}
> +  b = (vp == op); // expected-error {{implicit conversion of Objective-C pointer type 'id' to C pointer type 'void *' requires a bridged cast}} expected-note {{use CFBridgingRetain call}}
> +  b = (op == vp); // expected-error {{implicit conversion of C pointer type 'void *' to Objective-C pointer type 'id' requires a bridged cast}} expected-note {{use CFBridgingRelease call}}
> }
> 
> void test12(id collection) {
> @@ -404,10 +404,8 @@
> void test19(void) {
>   id x;
>   x = (id) test19a; // expected-error {{bridged cast}} \
> -  // expected-note{{use __bridge to convert directly (no change in ownership)}} \
>   // expected-note{{use CFBridgingRelease call to transfer ownership of a +1 'struct Test19 *' into ARC}}
>   x = (id) test19b; // expected-error {{bridged cast}} \
> -  // expected-note{{use __bridge to convert directly (no change in ownership)}} \
>   // expected-note{{use CFBridgingRelease call to transfer ownership of a +1 'struct Test19 *' into ARC}}
> }
> 
> 
> Modified: cfe/trunk/test/SemaObjCXX/arc-unbridged-cast.mm
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaObjCXX/arc-unbridged-cast.mm?rev=160839&r1=160838&r2=160839&view=diff
> ==============================================================================
> --- cfe/trunk/test/SemaObjCXX/arc-unbridged-cast.mm (original)
> +++ cfe/trunk/test/SemaObjCXX/arc-unbridged-cast.mm Thu Jul 26 18:17:04 2012
> @@ -39,15 +39,15 @@
>   x = (id) (cond ? (void*) 0 : auditedString());
>   x = (id) (cond ? (CFStringRef) @"help" : auditedString());
> 
> -  x = (id) unauditedString(); // expected-error {{requires a bridged cast}} expected-note {{use __bridge to}} expected-note {{use CFBridgingRelease call to}}
> -  x = (id) (cond ? unauditedString() : (void*) 0); // expected-error {{requires a bridged cast}} expected-note {{use __bridge to}} expected-note {{use CFBridgingRelease call to}}
> -  x = (id) (cond ? (void*) 0 : unauditedString()); // expected-error {{requires a bridged cast}} expected-note {{use __bridge to}} expected-note {{use CFBridgingRelease call to}}
> -  x = (id) (cond ? (CFStringRef) @"help" : unauditedString()); // expected-error {{requires a bridged cast}} expected-note {{use __bridge to}} expected-note {{use CFBridgingRelease call to}}
> -
> -  x = (id) auditedCreateString(); // expected-error {{requires a bridged cast}} expected-note {{use __bridge to}} expected-note {{use CFBridgingRelease call to}}
> -  x = (id) (cond ? auditedCreateString() : (void*) 0); // expected-error {{requires a bridged cast}} expected-note {{use __bridge to}} expected-note {{use CFBridgingRelease call to}}
> -  x = (id) (cond ? (void*) 0 : auditedCreateString()); // expected-error {{requires a bridged cast}} expected-note {{use __bridge to}} expected-note {{use CFBridgingRelease call to}}
> -  x = (id) (cond ? (CFStringRef) @"help" : auditedCreateString()); // expected-error {{requires a bridged cast}} expected-note {{use __bridge to}} expected-note {{use CFBridgingRelease call to}}
> +  x = (id) unauditedString(); // expected-error {{requires a bridged cast}} expected-note {{use CFBridgingRelease call to}}
> +  x = (id) (cond ? unauditedString() : (void*) 0); // expected-error {{requires a bridged cast}} expected-note {{use CFBridgingRelease call to}}
> +  x = (id) (cond ? (void*) 0 : unauditedString()); // expected-error {{requires a bridged cast}} expected-note {{use CFBridgingRelease call to}}
> +  x = (id) (cond ? (CFStringRef) @"help" : unauditedString()); // expected-error {{requires a bridged cast}} expected-note {{use CFBridgingRelease call to}}
> +
> +  x = (id) auditedCreateString(); // expected-error {{requires a bridged cast}} expected-note {{use CFBridgingRelease call to}}
> +  x = (id) (cond ? auditedCreateString() : (void*) 0); // expected-error {{requires a bridged cast}} expected-note {{use CFBridgingRelease call to}}
> +  x = (id) (cond ? (void*) 0 : auditedCreateString()); // expected-error {{requires a bridged cast}} expected-note {{use CFBridgingRelease call to}}
> +  x = (id) (cond ? (CFStringRef) @"help" : auditedCreateString()); // expected-error {{requires a bridged cast}} expected-note {{use CFBridgingRelease call to}}
> 
>   x = (id) [object property];
>   x = (id) (cond ? [object property] : (void*) 0);
> @@ -84,7 +84,7 @@
> void testCFTaker(CFTaker *taker, id string) {
>   [taker takeOrdinary: (CFStringRef) string];
>   [taker takeVariadic: 1, (CFStringRef) string];
> -  [taker takeConsumed: (CFStringRef) string]; // expected-error {{cast of Objective-C pointer type 'id' to C pointer type 'CFStringRef'}} expected-note {{use __bridge to}} expected-note {{use CFBridgingRetain call to}}
> +  [taker takeConsumed: (CFStringRef) string]; // expected-error {{cast of Objective-C pointer type 'id' to C pointer type 'CFStringRef'}} expected-note {{use CFBridgingRetain call to}}
> }
> 
> void takeCFOrdinaryUnaudited(CFStringRef arg);
> @@ -97,14 +97,14 @@
> #pragma clang arc_cf_code_audited end
> 
> void testTakerFunctions(id string) {
> -  takeCFOrdinaryUnaudited((CFStringRef) string); // expected-error {{cast of Objective-C pointer type 'id' to C pointer type 'CFStringRef'}} expected-note {{use __bridge to}} expected-note {{use CFBridgingRetain call to}}
> -  takeCFVariadicUnaudited(1, (CFStringRef) string); // expected-error {{cast of Objective-C pointer type 'id' to C pointer type 'CFStringRef'}} expected-note {{use __bridge to}} expected-note {{use CFBridgingRetain call to}}
> -  takeCFConsumedUnaudited((CFStringRef) string); // expected-error {{cast of Objective-C pointer type 'id' to C pointer type 'CFStringRef'}} expected-note {{use __bridge to}} expected-note {{use CFBridgingRetain call to}}
> +  takeCFOrdinaryUnaudited((CFStringRef) string); // expected-error {{cast of Objective-C pointer type 'id' to C pointer type 'CFStringRef'}} expected-note {{use CFBridgingRetain call to}}
> +  takeCFVariadicUnaudited(1, (CFStringRef) string); // expected-error {{cast of Objective-C pointer type 'id' to C pointer type 'CFStringRef'}} expected-note {{use CFBridgingRetain call to}}
> +  takeCFConsumedUnaudited((CFStringRef) string); // expected-error {{cast of Objective-C pointer type 'id' to C pointer type 'CFStringRef'}} expected-note {{use CFBridgingRetain call to}}
> 
>   void (*taker)(CFStringRef) = 0;
> -  taker((CFStringRef) string); // expected-error {{cast of Objective-C pointer type 'id' to C pointer type 'CFStringRef'}} expected-note {{use __bridge to}} expected-note {{use CFBridgingRetain call to}}
> +  taker((CFStringRef) string); // expected-error {{cast of Objective-C pointer type 'id' to C pointer type 'CFStringRef'}} expected-note {{use CFBridgingRetain call to}}
> 
>   takeCFOrdinaryAudited((CFStringRef) string);
>   takeCFVariadicAudited(1, (CFStringRef) string);
> -  takeCFConsumedAudited((CFStringRef) string); // expected-error {{cast of Objective-C pointer type 'id' to C pointer type 'CFStringRef'}} expected-note {{use __bridge to}} expected-note {{use CFBridgingRetain call to}}
> +  takeCFConsumedAudited((CFStringRef) string); // expected-error {{cast of Objective-C pointer type 'id' to C pointer type 'CFStringRef'}} expected-note {{use CFBridgingRetain call to}}
> }
> 
> 
> _______________________________________________
> cfe-commits mailing list
> cfe-commits at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits




More information about the cfe-commits mailing list