]> granicus.if.org Git - clang/commitdiff
objc: Don't crash on missing @interface decl.
authorFariborz Jahanian <fjahanian@apple.com>
Tue, 8 Nov 2011 22:51:27 +0000 (22:51 +0000)
committerFariborz Jahanian <fjahanian@apple.com>
Tue, 8 Nov 2011 22:51:27 +0000 (22:51 +0000)
// rdar://10415026

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@144143 91177308-0d34-0410-b5e6-96231b3b80d8

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

index c6a5f1ec6f54cab301881651daa637d3feca418e..4ba294cb8a1d800bf9b361ba29143250bde8fae3 100644 (file)
@@ -1968,12 +1968,13 @@ Sema::LookupInObjCMethod(LookupResult &Lookup, Scope *S,
     }
   } else if (CurMethod->isInstanceMethod()) {
     // We should warn if a local variable hides an ivar.
-    ObjCInterfaceDecl *IFace = CurMethod->getClassInterface();
-    ObjCInterfaceDecl *ClassDeclared;
-    if (ObjCIvarDecl *IV = IFace->lookupInstanceVariable(II, ClassDeclared)) {
-      if (IV->getAccessControl() != ObjCIvarDecl::Private ||
-          IFace == ClassDeclared)
-        Diag(Loc, diag::warn_ivar_use_hidden) << IV->getDeclName();
+    if (ObjCInterfaceDecl *IFace = CurMethod->getClassInterface()) {
+      ObjCInterfaceDecl *ClassDeclared;
+      if (ObjCIvarDecl *IV = IFace->lookupInstanceVariable(II, ClassDeclared)) {
+        if (IV->getAccessControl() != ObjCIvarDecl::Private ||
+            IFace == ClassDeclared)
+          Diag(Loc, diag::warn_ivar_use_hidden) << IV->getDeclName();
+      }
     }
   }
 
index 9b7f2c8a975aeb225812b8559085c64e2bba6f82..6a1e28ae9b5b97f6bf976aa962c85b928f3396a0 100644 (file)
@@ -19,3 +19,10 @@ void foo() {
   @throw (id)0 // expected-error{{expected ';' after @throw}}
 }
 
+// <rdar://problem/10415026>
+@class NSView;
+@implementation IBFillView(IBFillViewIntegration) // expected-error {{cannot find interface declaration for 'IBFillView'}}
+- (NSView *)ibDesignableContentView {
+    return self;
+}
+@end