Author: epilk Date: Mon Feb 25 13:35:14 2019 New Revision: 354826 URL: http://llvm.org/viewvc/llvm-project?rev=354826&view=rev Log: [CodeGenObjC] Fix a nullptr dyn_cast
ObjCMessageExpr::getInstanceReceiver returns nullptr if the receiver is 'super'. Make this check more strict, since we don't care about messages to super here. rdar://48247290 Modified: cfe/trunk/lib/CodeGen/CGObjC.cpp cfe/trunk/test/CodeGenObjC/objc-alloc-init.m Modified: cfe/trunk/lib/CodeGen/CGObjC.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGObjC.cpp?rev=354826&r1=354825&r2=354826&view=diff ============================================================================== --- cfe/trunk/lib/CodeGen/CGObjC.cpp (original) +++ cfe/trunk/lib/CodeGen/CGObjC.cpp Mon Feb 25 13:35:14 2019 @@ -433,8 +433,9 @@ tryEmitSpecializedAllocInit(CodeGenFunct // 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]'. Modified: cfe/trunk/test/CodeGenObjC/objc-alloc-init.m URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenObjC/objc-alloc-init.m?rev=354826&r1=354825&r2=354826&view=diff ============================================================================== --- cfe/trunk/test/CodeGenObjC/objc-alloc-init.m (original) +++ cfe/trunk/test/CodeGenObjC/objc-alloc-init.m Mon Feb 25 13:35:14 2019 @@ -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 _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits