r195480 - ObjectiveC modern translator. Fixes a translation bug

Fariborz Jahanian fjahanian at apple.com
Fri Nov 22 10:43:41 PST 2013


Author: fjahanian
Date: Fri Nov 22 12:43:41 2013
New Revision: 195480

URL: http://llvm.org/viewvc/llvm-project?rev=195480&view=rev
Log:
ObjectiveC modern translator. Fixes a translation bug
tranalation @protocol expression. // rdar://15517895

Modified:
    cfe/trunk/lib/Rewrite/Frontend/RewriteModernObjC.cpp
    cfe/trunk/test/Rewriter/protocol-rewrite-1.m

Modified: cfe/trunk/lib/Rewrite/Frontend/RewriteModernObjC.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Rewrite/Frontend/RewriteModernObjC.cpp?rev=195480&r1=195479&r2=195480&view=diff
==============================================================================
--- cfe/trunk/lib/Rewrite/Frontend/RewriteModernObjC.cpp (original)
+++ cfe/trunk/lib/Rewrite/Frontend/RewriteModernObjC.cpp Fri Nov 22 12:43:41 2013
@@ -3733,12 +3733,9 @@ Stmt *RewriteModernObjC::RewriteObjCProt
                                 SC_Extern);
   DeclRefExpr *DRE = new (Context) DeclRefExpr(VD, false, getProtocolType(),
                                                VK_LValue, SourceLocation());
-  Expr *DerefExpr = new (Context) UnaryOperator(DRE, UO_AddrOf,
-                             Context->getPointerType(DRE->getType()),
-                             VK_RValue, OK_Ordinary, SourceLocation());
-  CastExpr *castExpr = NoTypeInfoCStyleCastExpr(Context, DerefExpr->getType(),
-                                                CK_BitCast,
-                                                DerefExpr);
+  CastExpr *castExpr =
+    NoTypeInfoCStyleCastExpr(
+      Context, Context->getPointerType(DRE->getType()), CK_BitCast, DRE);
   ReplaceStmt(Exp, castExpr);
   ProtocolExprDecls.insert(Exp->getProtocol()->getCanonicalDecl());
   // delete Exp; leak for now, see RewritePropertyOrImplicitSetter() usage for more info.

Modified: cfe/trunk/test/Rewriter/protocol-rewrite-1.m
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Rewriter/protocol-rewrite-1.m?rev=195480&r1=195479&r2=195480&view=diff
==============================================================================
--- cfe/trunk/test/Rewriter/protocol-rewrite-1.m (original)
+++ cfe/trunk/test/Rewriter/protocol-rewrite-1.m Fri Nov 22 12:43:41 2013
@@ -1,4 +1,7 @@
-// RUN: %clang_cc1 -rewrite-objc -fobjc-runtime=macosx-fragile-10.5  %s -o -
+// RUN: %clang_cc1 -x objective-c -Wno-objc-root-class -fms-extensions -rewrite-objc %s -o %t-rw.cpp
+// RUN: FileCheck  --input-file=%t-rw.cpp %s
+// rdar://9846759
+// rdar://15517895
 
 typedef struct MyWidget {
   int a;
@@ -46,3 +49,25 @@ int main(void) {
 
   return 0;
 }
+
+// rdar://15517895
+ at class NSObject;
+
+ at interface NSProtocolChecker
++ (id)protocolCheckerWithTarget:(NSObject *)anObject protocol:(Protocol *)aProtocol;
+ at end
+
+ at protocol NSConnectionVersionedProtocol
+ at end
+
+
+ at interface NSConnection @end
+
+ at implementation NSConnection
+- (void) Meth {
+  [NSProtocolChecker protocolCheckerWithTarget:0 protocol:@protocol(NSConnectionVersionedProtocol)];
+}
+ at end
+
+// CHECK: static struct _protocol_t *_OBJC_PROTOCOL_REFERENCE_$_NSConnectionVersionedProtocol = &_OBJC_PROTOCOL_NSConnectionVersionedProtocol
+// CHECK: sel_registerName("protocolCheckerWithTarget:protocol:"), (NSObject *)0, (Protocol *)_OBJC_PROTOCOL_REFERENCE_$_NSConnectionVersionedProtocol





More information about the cfe-commits mailing list