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 837b2c8..1e75bb2 100644
--- a/lib/Sema/Sema.h
+++ b/lib/Sema/Sema.h
@@ -1153,7 +1153,6 @@
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 440b0fb..89bde81 100644
--- a/lib/Sema/SemaDeclObjC.cpp
+++ b/lib/Sema/SemaDeclObjC.cpp
@@ -716,10 +716,12 @@
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 @@
}
}
// 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 7aa66f9..2f47c79 100644
--- a/lib/Sema/SemaExpr.cpp
+++ b/lib/Sema/SemaExpr.cpp
@@ -2067,8 +2067,7 @@
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 66e1beb..141cd80 100644
--- a/lib/Sema/SemaExprObjC.cpp
+++ b/lib/Sema/SemaExprObjC.cpp
@@ -241,8 +241,7 @@
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 *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 @@
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 @@
// 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 d9dea66..57656ce 100644
--- a/lib/Sema/SemaLookup.cpp
+++ b/lib/Sema/SemaLookup.cpp
@@ -1671,13 +1671,6 @@
return cast_or_null<ObjCProtocolDecl>(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<ObjCImplementationDecl>(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 5a67bef..09ad155 100644
--- a/test/SemaObjC/class-impl-1.m
+++ b/test/SemaObjC/class-impl-1.m
@@ -9,7 +9,7 @@
@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