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 | d5bf26fa26e69c8bc54e9a2876cc23ee688f807c (patch) | |
tree | fb784a0dbaf53b8295ed767960f3ec8622f94b03 /clang/lib | |
parent | dbb7263fd96bbe03179b50bac79bb5efa253bf27 (diff) | |
download | bcm5719-llvm-d5bf26fa26e69c8bc54e9a2876cc23ee688f807c.tar.gz bcm5719-llvm-d5bf26fa26e69c8bc54e9a2876cc23ee688f807c.zip |
Fix crash identified by <rdar://problem/5986085>.
llvm-svn: 51969
Diffstat (limited to 'clang/lib')
-rw-r--r-- | clang/lib/Sema/SemaExprObjC.cpp | 34 |
1 files changed, 23 insertions, 11 deletions
diff --git a/clang/lib/Sema/SemaExprObjC.cpp b/clang/lib/Sema/SemaExprObjC.cpp index d833efe309e..e2e23ce0637 100644 --- a/clang/lib/Sema/SemaExprObjC.cpp +++ b/clang/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)); |