forked from OSchip/llvm-project
ObjectiveC modern translator. Fixes a translation bug
tranalation @protocol expression. // rdar://15517895 llvm-svn: 195480
This commit is contained in:
parent
a74768a12a
commit
d38951acff
|
@ -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.
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue