From: Argyrios Kyrtzidis Date: Wed, 9 Nov 2011 00:22:48 +0000 (+0000) Subject: Don't crash on invalid objc code. X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=ccc9e767f21cb9be55c98f9c7cb319134410184b;p=clang Don't crash on invalid objc code. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@144150 91177308-0d34-0410-b5e6-96231b3b80d8 --- 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