diff options
author | Steve Naroff <snaroff@apple.com> | 2008-06-04 23:08:38 +0000 |
---|---|---|
committer | Steve Naroff <snaroff@apple.com> | 2008-06-04 23:08:38 +0000 |
commit | cb28be6e82809f9f514585ac2692fa04bb56978a (patch) | |
tree | 211648bc41fe66eaba1449d59c4fab775eaea05b /lib/Sema/SemaExprObjC.cpp | |
parent | 44a3dded8080c5c9cfdad208ade8f8f7850d9a4f (diff) |
Fix crash identified by <rdar://problem/5986085>.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@51969 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Sema/SemaExprObjC.cpp')
-rw-r--r-- | lib/Sema/SemaExprObjC.cpp | 34 |
1 files changed, 23 insertions, 11 deletions
diff --git a/lib/Sema/SemaExprObjC.cpp b/lib/Sema/SemaExprObjC.cpp index d833efe309..e2e23ce063 100644 --- a/lib/Sema/SemaExprObjC.cpp +++ b/lib/Sema/SemaExprObjC.cpp @@ -166,19 +166,31 @@ Sema::ExprResult Sema::ActOnClassMessage( } else ClassDecl = getObjCInterfaceDecl(receiverName); - // FIXME: can ClassDecl ever be null? - ObjCMethodDecl *Method = ClassDecl->lookupClassMethod(Sel); + // ClassDecl is null in the following case. + // + // typedef XCElementDisplayRect XCElementGraphicsRect; + // + // @implementation XCRASlice + // - whatever { // Note that XCElementGraphicsRect is a typedef name. + // _sGraphicsDelegate =[[XCElementGraphicsRect alloc] init]; + // } + // + // FIXME: Investigate why GCC allows the above. + ObjCMethodDecl *Method = 0; QualType returnType; - - // If we have an implementation in scope, check "private" methods. - if (!Method) { - if (ObjCImplementationDecl *ImpDecl = - ObjCImplementations[ClassDecl->getIdentifier()]) - Method = ImpDecl->getClassMethod(Sel); + if (ClassDecl) { + Method = ClassDecl->lookupClassMethod(Sel); + + // If we have an implementation in scope, check "private" methods. + if (!Method) { + if (ObjCImplementationDecl *ImpDecl = + ObjCImplementations[ClassDecl->getIdentifier()]) + Method = ImpDecl->getClassMethod(Sel); + } + // Before we give up, check if the selector is an instance method. + if (!Method) + Method = ClassDecl->lookupInstanceMethod(Sel); } - // Before we give up, check if the selector is an instance method. - if (!Method) - Method = ClassDecl->lookupInstanceMethod(Sel); if (!Method) { Diag(lbrac, diag::warn_method_not_found, std::string("+"), Sel.getName(), SourceRange(lbrac, rbrac)); |