diff options
-rw-r--r-- | clang/lib/CodeGen/CGObjC.cpp | 5 | ||||
-rw-r--r-- | clang/test/CodeGenObjC/objc-alloc-init.m | 13 |
2 files changed, 16 insertions, 2 deletions
diff --git a/clang/lib/CodeGen/CGObjC.cpp b/clang/lib/CodeGen/CGObjC.cpp index 1b3e71b436b..fba1a531a2a 100644 --- a/clang/lib/CodeGen/CGObjC.cpp +++ b/clang/lib/CodeGen/CGObjC.cpp @@ -433,8 +433,9 @@ tryEmitSpecializedAllocInit(CodeGenFunction &CGF, const ObjCMessageExpr *OME) { // Match the exact pattern '[[MyClass alloc] init]'. Selector Sel = OME->getSelector(); - if (!OME->isInstanceMessage() || !OME->getType()->isObjCObjectPointerType() || - !Sel.isUnarySelector() || Sel.getNameForSlot(0) != "init") + if (OME->getReceiverKind() != ObjCMessageExpr::Instance || + !OME->getType()->isObjCObjectPointerType() || !Sel.isUnarySelector() || + Sel.getNameForSlot(0) != "init") return None; // Okay, this is '[receiver init]', check if 'receiver' is '[cls alloc]'. diff --git a/clang/test/CodeGenObjC/objc-alloc-init.m b/clang/test/CodeGenObjC/objc-alloc-init.m index e56303c7fef..a55a9835c8a 100644 --- a/clang/test/CodeGenObjC/objc-alloc-init.m +++ b/clang/test/CodeGenObjC/objc-alloc-init.m @@ -26,3 +26,16 @@ void f() { // EITHER: call {{.*}} @objc_msgSend } @end + +// rdar://48247290 +@interface Base +-(instancetype)init; +@end + +@interface Derived : Base +@end +@implementation Derived +-(void)meth { + [super init]; +} +@end |