summaryrefslogtreecommitdiffstats
path: root/clang/lib/Sema/SemaDeclObjC.cpp
diff options
context:
space:
mode:
authorDouglas Gregor <dgregor@apple.com>2012-05-17 22:39:14 +0000
committerDouglas Gregor <dgregor@apple.com>2012-05-17 22:39:14 +0000
commitc5928afb69a541cd173e600a9424a09cb3248c22 (patch)
tree518a82c84c8a68844e029693a83098eb6053aece /clang/lib/Sema/SemaDeclObjC.cpp
parent6a50baa26e88d89985d587ee77384ec9830004a4 (diff)
downloadbcm5719-llvm-c5928afb69a541cd173e600a9424a09cb3248c22.tar.gz
bcm5719-llvm-c5928afb69a541cd173e600a9424a09cb3248c22.zip
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
llvm-svn: 157021
Diffstat (limited to 'clang/lib/Sema/SemaDeclObjC.cpp')
-rw-r--r--clang/lib/Sema/SemaDeclObjC.cpp13
1 files changed, 8 insertions, 5 deletions
diff --git a/clang/lib/Sema/SemaDeclObjC.cpp b/clang/lib/Sema/SemaDeclObjC.cpp
index 02430e6da54..10bc1c27f0d 100644
--- a/clang/lib/Sema/SemaDeclObjC.cpp
+++ b/clang/lib/Sema/SemaDeclObjC.cpp
@@ -2520,7 +2520,8 @@ public:
// 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 @@ private:
// 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 @@ private:
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);
}
OpenPOWER on IntegriCloud