diff options
author | Erik Pilkington <erik.pilkington@gmail.com> | 2019-02-25 21:35:14 +0000 |
---|---|---|
committer | Erik Pilkington <erik.pilkington@gmail.com> | 2019-02-25 21:35:14 +0000 |
commit | 55e703a5504c9a3ac27183191c440d89ee1650e3 (patch) | |
tree | 991bab3fb5647aea746dd807616c0366e5a4b677 | |
parent | f4bfe4cd178e09d3ceafb613fb61a70ba845cab8 (diff) | |
download | bcm5719-llvm-55e703a5504c9a3ac27183191c440d89ee1650e3.tar.gz bcm5719-llvm-55e703a5504c9a3ac27183191c440d89ee1650e3.zip |
[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
llvm-svn: 354826
-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 |