aboutsummaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorArgyrios Kyrtzidis <akyrtzi@gmail.com>2012-03-02 19:14:29 +0000
committerArgyrios Kyrtzidis <akyrtzi@gmail.com>2012-03-02 19:14:29 +0000
commit5a61e0c4229dc82617a37a68ac2fc08d46e00488 (patch)
treebcddc8292df271da097d124b88b136a5d6953241 /lib
parent8235f9c9c8b3d1737d1c6bd57f7ba3f616b92392 (diff)
[Sema] Fix crash-on-invalid-code issue:
@class I; @implementation I(cat) // crashes here @end rdar://10968158 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@151931 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib')
-rw-r--r--lib/AST/DeclObjC.cpp4
-rw-r--r--lib/Sema/SemaDeclObjC.cpp2
2 files changed, 5 insertions, 1 deletions
diff --git a/lib/AST/DeclObjC.cpp b/lib/AST/DeclObjC.cpp
index 996e93a8f9..7822eb217f 100644
--- a/lib/AST/DeclObjC.cpp
+++ b/lib/AST/DeclObjC.cpp
@@ -806,6 +806,10 @@ ObjCIvarDecl *ObjCInterfaceDecl::all_declared_ivar_begin() {
///
ObjCCategoryDecl *
ObjCInterfaceDecl::FindCategoryDeclaration(IdentifierInfo *CategoryId) const {
+ // FIXME: Should make sure no callers ever do this.
+ if (!hasDefinition())
+ return 0;
+
if (data().ExternallyCompleted)
LoadExternalDefinition();
diff --git a/lib/Sema/SemaDeclObjC.cpp b/lib/Sema/SemaDeclObjC.cpp
index 9b492600ca..4df5ab3916 100644
--- a/lib/Sema/SemaDeclObjC.cpp
+++ b/lib/Sema/SemaDeclObjC.cpp
@@ -820,7 +820,7 @@ Decl *Sema::ActOnStartCategoryImplementation(
IdentifierInfo *CatName, SourceLocation CatLoc) {
ObjCInterfaceDecl *IDecl = getObjCInterfaceDecl(ClassName, ClassLoc, true);
ObjCCategoryDecl *CatIDecl = 0;
- if (IDecl) {
+ if (IDecl && IDecl->hasDefinition()) {
CatIDecl = IDecl->FindCategoryDeclaration(CatName);
if (!CatIDecl) {
// Category @implementation with no corresponding @interface.