[cfe-commits] r157021 - in /cfe/trunk: lib/Sema/SemaDeclObjC.cpp test/SemaObjC/category-1.m
Douglas Gregor
dgregor at apple.com
Thu May 17 15:39:14 PDT 2012
Author: dgregor
Date: Thu May 17 17:39:14 2012
New Revision: 157021
URL: http://llvm.org/viewvc/llvm-project?rev=157021&view=rev
Log:
In the override search for Objective-C methods, protect against ASTs that have NULL interfaces behind a category, which can happen in invalid code. Fixes <rdar://problem/11478173>, a recent regression
Modified:
cfe/trunk/lib/Sema/SemaDeclObjC.cpp
cfe/trunk/test/SemaObjC/category-1.m
Modified: cfe/trunk/lib/Sema/SemaDeclObjC.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDeclObjC.cpp?rev=157021&r1=157020&r2=157021&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaDeclObjC.cpp (original)
+++ cfe/trunk/lib/Sema/SemaDeclObjC.cpp Thu May 17 17:39:14 2012
@@ -2520,7 +2520,8 @@
// interface and each other.
if (ObjCCategoryDecl *Category = dyn_cast<ObjCCategoryDecl>(container)) {
searchFromContainer(container);
- searchFromContainer(Category->getClassInterface());
+ if (ObjCInterfaceDecl *Interface = Category->getClassInterface())
+ searchFromContainer(Interface);
} else {
searchFromContainer(container);
}
@@ -2569,11 +2570,12 @@
// declaration.
if (ObjCCategoryDecl *category = impl->getCategoryDecl()) {
search(category);
- search(category->getClassInterface());
+ if (ObjCInterfaceDecl *Interface = category->getClassInterface())
+ search(Interface);
// Otherwise it overrides declarations from the class.
- } else {
- search(impl->getClassInterface());
+ } else if (ObjCInterfaceDecl *Interface = impl->getClassInterface()) {
+ search(Interface);
}
}
@@ -2598,7 +2600,8 @@
void searchFrom(ObjCImplementationDecl *impl) {
// A method in a class implementation overrides declarations from
// the class interface.
- search(impl->getClassInterface());
+ if (ObjCInterfaceDecl *Interface = impl->getClassInterface())
+ search(Interface);
}
Modified: cfe/trunk/test/SemaObjC/category-1.m
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaObjC/category-1.m?rev=157021&r1=157020&r2=157021&view=diff
==============================================================================
--- cfe/trunk/test/SemaObjC/category-1.m (original)
+++ cfe/trunk/test/SemaObjC/category-1.m Thu May 17 17:39:14 2012
@@ -99,3 +99,12 @@
@class I; // expected-note {{forward declaration}}
@implementation I(cat) // expected-error{{cannot find interface declaration}}
@end
+
+// <rdar://problem/11478173>
+ at interface Unrelated
+- foo;
+ at end
+
+ at interface Blah (Blarg) // expected-error{{cannot find interface declaration for 'Blah'}}
+- foo;
+ at end
More information about the cfe-commits
mailing list