From: Argyrios Kyrtzidis Date: Tue, 21 Jul 2009 00:06:04 +0000 (+0000) Subject: Remove Sema::LookupObjCImplementation and replace it with just calling ObjCInterfaceD... X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=87018775ed689d0a67357cf767747166044b3a27;p=clang Remove Sema::LookupObjCImplementation and replace it with just calling ObjCInterfaceDecl::getImplementation(). git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@76509 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/Sema/Sema.h b/lib/Sema/Sema.h index 837b2c8fec..1e75bb2e3d 100644 --- a/lib/Sema/Sema.h +++ b/lib/Sema/Sema.h @@ -1153,7 +1153,6 @@ public: SourceLocation Loc = SourceLocation()); ObjCProtocolDecl *LookupProtocol(IdentifierInfo *II); - ObjCImplementationDecl *LookupObjCImplementation(IdentifierInfo *II); ObjCCategoryImplDecl *LookupObjCCategoryImpl(IdentifierInfo *II); void LookupOverloadedOperatorName(OverloadedOperatorKind Op, Scope *S, diff --git a/lib/Sema/SemaDeclObjC.cpp b/lib/Sema/SemaDeclObjC.cpp index 440b0fba6a..89bde815c0 100644 --- a/lib/Sema/SemaDeclObjC.cpp +++ b/lib/Sema/SemaDeclObjC.cpp @@ -716,10 +716,12 @@ Sema::DeclPtrTy Sema::ActOnStartClassImplementation( return DeclPtrTy::make(IMPDecl); // Check that there is no duplicate implementation of this class. - if (LookupObjCImplementation(ClassName)) + if (IDecl->getImplementation()) { // FIXME: Don't leak everything! Diag(ClassLoc, diag::err_dup_implementation_class) << ClassName; - else { // add it to the list. + Diag(IDecl->getImplementation()->getLocation(), + diag::note_previous_definition); + } else { // add it to the list. IDecl->setImplementation(IMPDecl); PushOnScopeChains(IMPDecl, TUScope); } @@ -869,8 +871,7 @@ bool Sema::isPropertyReadonly(ObjCPropertyDecl *PDecl, } } // Lastly, look through the implementation (if one is in scope). - if (ObjCImplementationDecl *ImpDecl - = LookupObjCImplementation(IDecl->getIdentifier())) + if (ObjCImplementationDecl *ImpDecl = IDecl->getImplementation()) if (ImpDecl->getInstanceMethod(PDecl->getSetterName())) return false; // If all fails, look at the super class. diff --git a/lib/Sema/SemaExpr.cpp b/lib/Sema/SemaExpr.cpp index 7aa66f9b62..2f47c79777 100644 --- a/lib/Sema/SemaExpr.cpp +++ b/lib/Sema/SemaExpr.cpp @@ -2067,8 +2067,7 @@ ObjCMethodDecl *Sema::FindMethodInNestedImplementations( const ObjCInterfaceDecl *IFace, const Selector &Sel) { ObjCMethodDecl *Method = 0; - if (ObjCImplementationDecl *ImpDecl - = LookupObjCImplementation(IFace->getIdentifier())) + if (ObjCImplementationDecl *ImpDecl = IFace->getImplementation()) Method = ImpDecl->getInstanceMethod(Sel); if (!Method && IFace->getSuperClass()) diff --git a/lib/Sema/SemaExprObjC.cpp b/lib/Sema/SemaExprObjC.cpp index 66e1beb983..141cd80bff 100644 --- a/lib/Sema/SemaExprObjC.cpp +++ b/lib/Sema/SemaExprObjC.cpp @@ -241,8 +241,7 @@ ObjCMethodDecl *Sema::LookupPrivateClassMethod(Selector Sel, ObjCMethodDecl *Method = 0; // lookup in class and all superclasses while (ClassDecl && !Method) { - if (ObjCImplementationDecl *ImpDecl - = LookupObjCImplementation(ClassDecl->getIdentifier())) + if (ObjCImplementationDecl *ImpDecl = ClassDecl->getImplementation()) Method = ImpDecl->getClassMethod(Sel); // Look through local category implementations associated with the class. @@ -274,8 +273,7 @@ ObjCMethodDecl *Sema::LookupPrivateInstanceMethod(Selector Sel, ObjCMethodDecl *Method = 0; while (ClassDecl && !Method) { // If we have implementations in scope, check "private" methods. - if (ObjCImplementationDecl *ImpDecl - = LookupObjCImplementation(ClassDecl->getIdentifier())) + if (ObjCImplementationDecl *ImpDecl = ClassDecl->getImplementation()) Method = ImpDecl->getInstanceMethod(Sel); // Look through local category implementations associated with the class. @@ -307,8 +305,7 @@ Action::OwningExprResult Sema::ActOnClassPropertyRefExpr( if (!Getter) if (ObjCMethodDecl *CurMeth = getCurMethodDecl()) if (ObjCInterfaceDecl *ClassDecl = CurMeth->getClassInterface()) - if (ObjCImplementationDecl *ImpDecl - = LookupObjCImplementation(ClassDecl->getIdentifier())) + if (ObjCImplementationDecl *ImpDecl = ClassDecl->getImplementation()) Getter = ImpDecl->getClassMethod(Sel); if (Getter) { @@ -329,8 +326,7 @@ Action::OwningExprResult Sema::ActOnClassPropertyRefExpr( // methods. if (ObjCMethodDecl *CurMeth = getCurMethodDecl()) if (ObjCInterfaceDecl *ClassDecl = CurMeth->getClassInterface()) - if (ObjCImplementationDecl *ImpDecl - = LookupObjCImplementation(ClassDecl->getIdentifier())) + if (ObjCImplementationDecl *ImpDecl = ClassDecl->getImplementation()) Setter = ImpDecl->getClassMethod(SetterSel); } // Look through local category implementations associated with the class. diff --git a/lib/Sema/SemaLookup.cpp b/lib/Sema/SemaLookup.cpp index d9dea66f82..57656ce8af 100644 --- a/lib/Sema/SemaLookup.cpp +++ b/lib/Sema/SemaLookup.cpp @@ -1671,13 +1671,6 @@ ObjCProtocolDecl *Sema::LookupProtocol(IdentifierInfo *II) { return cast_or_null(D); } -/// \brief Find the Objective-C implementation with the given name, if -/// any. -ObjCImplementationDecl *Sema::LookupObjCImplementation(IdentifierInfo *II) { - Decl *D = LookupName(TUScope, II, LookupObjCImplementationName).getAsDecl(); - return cast_or_null(D); -} - /// \brief Find the Objective-C category implementation with the given /// name, if any. ObjCCategoryImplDecl *Sema::LookupObjCCategoryImpl(IdentifierInfo *II) { diff --git a/test/SemaObjC/class-impl-1.m b/test/SemaObjC/class-impl-1.m index 5a67bef3d6..09ad1556c0 100644 --- a/test/SemaObjC/class-impl-1.m +++ b/test/SemaObjC/class-impl-1.m @@ -9,7 +9,7 @@ typedef int INTF3; // expected-note {{previous definition is here}} @interface INTF : OBJECT @end -@implementation INTF @end +@implementation INTF @end // expected-note {{previous definition is here}} @implementation INTF // expected-error {{reimplementation of class 'INTF'}} @end