]> granicus.if.org Git - clang/commitdiff
Don't crash on invalid objc code.
authorArgyrios Kyrtzidis <akyrtzi@gmail.com>
Wed, 9 Nov 2011 00:22:48 +0000 (00:22 +0000)
committerArgyrios Kyrtzidis <akyrtzi@gmail.com>
Wed, 9 Nov 2011 00:22:48 +0000 (00:22 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@144150 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Sema/SemaExprObjC.cpp
test/SemaObjC/invalid-code.m

index 54a3af52ecad6a5d3613142d7299083760665cdf..28a5a43055792c6ffd77b36e638c312e216f2236 100644 (file)
@@ -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))
index 6a1e28ae9b5b97f6bf976aa962c85b928f3396a0..b50baa41a16e3e395eb38fe80b582c38f0fd61f9 100644 (file)
@@ -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