r194938 - ObjectiveC ARC. More validation of toll-free bridging of

Fariborz Jahanian fjahanian at apple.com
Sat Nov 16 15:22:37 PST 2013


Author: fjahanian
Date: Sat Nov 16 17:22:37 2013
New Revision: 194938

URL: http://llvm.org/viewvc/llvm-project?rev=194938&view=rev
Log:
ObjectiveC ARC. More validation of toll-free bridging of
CF objects with objc_bridge'ing annotaiton.
// rdar://15454846

Modified:
    cfe/trunk/lib/Sema/SemaExprObjC.cpp
    cfe/trunk/test/SemaObjC/objcbridge-attribute.m

Modified: cfe/trunk/lib/Sema/SemaExprObjC.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaExprObjC.cpp?rev=194938&r1=194937&r2=194938&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaExprObjC.cpp (original)
+++ cfe/trunk/lib/Sema/SemaExprObjC.cpp Sat Nov 16 17:22:37 2013
@@ -3190,7 +3190,11 @@ static bool CheckObjCBridgeNSCast(Sema &
               S.Diag(castExpr->getLocStart(), diag::warn_objc_invalid_bridge)
                 << TDNDecl->getName() << Target->getName() << CastClass->getName();
               return true;
-            }
+            } else {
+              S.Diag(castExpr->getLocStart(), diag::warn_objc_invalid_bridge)
+                << TDNDecl->getName() << Target->getName() << castType;
+              return true;
+           }
           }
         }
         S.Diag(castExpr->getLocStart(), diag::err_objc_cf_bridged_not_interface)
@@ -3233,6 +3237,11 @@ static bool CheckObjCBridgeCFCast(Sema &
                 << ExprClass->getName() << TDNDecl->getName();
               S.Diag(TDNDecl->getLocStart(), diag::note_declared_at);
               return true;
+            } else {
+              S.Diag(castExpr->getLocStart(), diag::warn_objc_invalid_bridge_to_cf)
+                << castExpr->getType() << castType;
+              S.Diag(TDNDecl->getLocStart(), diag::note_declared_at);
+              return true;
             }
           }
         }

Modified: cfe/trunk/test/SemaObjC/objcbridge-attribute.m
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaObjC/objcbridge-attribute.m?rev=194938&r1=194937&r2=194938&view=diff
==============================================================================
--- cfe/trunk/test/SemaObjC/objcbridge-attribute.m (original)
+++ cfe/trunk/test/SemaObjC/objcbridge-attribute.m Sat Nov 16 17:22:37 2013
@@ -1,7 +1,7 @@
 // RUN: %clang_cc1 -fsyntax-only -fobjc-arc -verify -Wno-objc-root-class %s
 // rdar://15454846
 
-typedef struct __CFErrorRef * __attribute__ ((objc_bridge(NSError))) CFErrorRef; // expected-note {{declared here}}
+typedef struct __CFErrorRef * __attribute__ ((objc_bridge(NSError))) CFErrorRef; // expected-note 2 {{declared here}}
 
 typedef struct __CFMyColor  * __attribute__((objc_bridge(12))) CFMyColorRef; // expected-error {{parameter of 'objc_bridge' attribute must be a single name of an Objective-C class}}
 
@@ -48,10 +48,12 @@ typedef CFErrorRef1 CFErrorRef2;
 
 @class NSString;
 
-void Test2(CFErrorRef2 cf, NSError *ns, NSString *str) {
+void Test2(CFErrorRef2 cf, NSError *ns, NSString *str, Class c) {
   (void)(NSString *)cf; // expected-warning {{CFErrorRef bridges to NSError, not NSString}}
   (void)(NSError *)cf; // okay
   (void)(MyError*)cf; // okay,
   (void)(CFErrorRef)ns; // okay
   (void)(CFErrorRef)str;  // expected-warning {{NSString cannot bridge to CFErrorRef}}
+  (void)(Class)cf; // expected-warning {{CFErrorRef bridges to NSError, not 'Class'}}
+  (void)(CFErrorRef)c; // expected-warning {{'Class' cannot bridge to 'CFErrorRef'}}
 }





More information about the cfe-commits mailing list