aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFariborz Jahanian <fjahanian@apple.com>2013-11-22 18:43:41 +0000
committerFariborz Jahanian <fjahanian@apple.com>2013-11-22 18:43:41 +0000
commitd38951acff28b72b0709370659121a0f74379704 (patch)
treea648d1120869903623aa7dd2cf9d908ea6518caa
parenta74768a12a12889b73f0e24c566a0ef92a48dc31 (diff)
downloadllvm-d38951acff28b72b0709370659121a0f74379704.zip
llvm-d38951acff28b72b0709370659121a0f74379704.tar.gz
llvm-d38951acff28b72b0709370659121a0f74379704.tar.bz2
ObjectiveC modern translator. Fixes a translation bug
tranalation @protocol expression. // rdar://15517895 llvm-svn: 195480
-rw-r--r--clang/lib/Rewrite/Frontend/RewriteModernObjC.cpp9
-rw-r--r--clang/test/Rewriter/protocol-rewrite-1.m27
2 files changed, 29 insertions, 7 deletions
diff --git a/clang/lib/Rewrite/Frontend/RewriteModernObjC.cpp b/clang/lib/Rewrite/Frontend/RewriteModernObjC.cpp
index ae33ac8..a248675 100644
--- a/clang/lib/Rewrite/Frontend/RewriteModernObjC.cpp
+++ b/clang/lib/Rewrite/Frontend/RewriteModernObjC.cpp
@@ -3733,12 +3733,9 @@ Stmt *RewriteModernObjC::RewriteObjCProtocolExpr(ObjCProtocolExpr *Exp) {
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.
diff --git a/clang/test/Rewriter/protocol-rewrite-1.m b/clang/test/Rewriter/protocol-rewrite-1.m
index 541b7ee..0c5104f 100644
--- a/clang/test/Rewriter/protocol-rewrite-1.m
+++ b/clang/test/Rewriter/protocol-rewrite-1.m
@@ -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
+@class NSObject;
+
+@interface NSProtocolChecker
++ (id)protocolCheckerWithTarget:(NSObject *)anObject protocol:(Protocol *)aProtocol;
+@end
+
+@protocol NSConnectionVersionedProtocol
+@end
+
+
+@interface NSConnection @end
+
+@implementation NSConnection
+- (void) Meth {
+ [NSProtocolChecker protocolCheckerWithTarget:0 protocol:@protocol(NSConnectionVersionedProtocol)];
+}
+@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