From ccc9e767f21cb9be55c98f9c7cb319134410184b Mon Sep 17 00:00:00 2001 From: Argyrios Kyrtzidis Date: Wed, 9 Nov 2011 00:22:48 +0000 Subject: [PATCH] Don't crash on invalid objc code. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@144150 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Sema/SemaExprObjC.cpp | 5 +++++ test/SemaObjC/invalid-code.m | 1 + 2 files changed, 6 insertions(+) diff --git a/lib/Sema/SemaExprObjC.cpp b/lib/Sema/SemaExprObjC.cpp index 54a3af52ec..28a5a43055 100644 --- a/lib/Sema/SemaExprObjC.cpp +++ b/lib/Sema/SemaExprObjC.cpp @@ -873,6 +873,11 @@ Sema::ObjCMessageKind Sema::getObjCMessageKind(Scope *S, // FIXME: This is a hack. Ivar lookup should be part of normal // lookup. if (ObjCMethodDecl *Method = getCurMethodDecl()) { + if (!Method->getClassInterface()) { + // Fall back: let the parser try to parse it as an instance message. + return ObjCInstanceMessage; + } + ObjCInterfaceDecl *ClassDeclared; if (Method->getClassInterface()->lookupInstanceVariable(Name, ClassDeclared)) diff --git a/test/SemaObjC/invalid-code.m b/test/SemaObjC/invalid-code.m index 6a1e28ae9b..b50baa41a1 100644 --- a/test/SemaObjC/invalid-code.m +++ b/test/SemaObjC/invalid-code.m @@ -23,6 +23,7 @@ void foo() { @class NSView; @implementation IBFillView(IBFillViewIntegration) // expected-error {{cannot find interface declaration for 'IBFillView'}} - (NSView *)ibDesignableContentView { + [Cake lie]; // expected-error {{undeclared}} return self; } @end -- 2.50.1