diff options
author | Ted Kremenek <kremenek@apple.com> | 2013-11-23 01:01:29 +0000 |
---|---|---|
committer | Ted Kremenek <kremenek@apple.com> | 2013-11-23 01:01:29 +0000 |
commit | 0078150c43f91c82cf43c8e65f6715b984e1a80f (patch) | |
tree | 7d86b92f990954130d9a22c2b4d2212b46e96ec1 /clang/lib | |
parent | 6fdeb365877d0b8f6811b4514d71f39f3be4cd72 (diff) | |
download | bcm5719-llvm-0078150c43f91c82cf43c8e65f6715b984e1a80f.tar.gz bcm5719-llvm-0078150c43f91c82cf43c8e65f6715b984e1a80f.zip |
Change ObjCIntefaceDecl::lookupMethod() to have optional 'followsSuper' argument.
This enables a micro-optimization in protocol conformance checking
to not examine the class hierarchy twice per method.
As part of this change, remove the default arguments from lookupInstanceMethod()
and lookupClassMethod(). It was becoming very redundant. For clients
needing the default arguments, have them use the full API instead of
these convenience methods.
llvm-svn: 195532
Diffstat (limited to 'clang/lib')
-rw-r--r-- | clang/lib/AST/DeclObjC.cpp | 16 | ||||
-rw-r--r-- | clang/lib/Sema/SemaDeclObjC.cpp | 23 |
2 files changed, 28 insertions, 11 deletions
diff --git a/clang/lib/AST/DeclObjC.cpp b/clang/lib/AST/DeclObjC.cpp index 28a651429c9..ca87bb8197f 100644 --- a/clang/lib/AST/DeclObjC.cpp +++ b/clang/lib/AST/DeclObjC.cpp @@ -457,9 +457,11 @@ ObjCInterfaceDecl::lookupNestedProtocol(IdentifierInfo *Name) { /// When argument category "C" is specified, any implicit method found /// in this category is ignored. ObjCMethodDecl *ObjCInterfaceDecl::lookupMethod(Selector Sel, - bool isInstance, - bool shallowCategoryLookup, - const ObjCCategoryDecl *C) const { + bool isInstance, + bool shallowCategoryLookup, + bool followSuper, + const ObjCCategoryDecl *C) const +{ // FIXME: Should make sure no callers ever do this. if (!hasDefinition()) return 0; @@ -470,7 +472,7 @@ ObjCMethodDecl *ObjCInterfaceDecl::lookupMethod(Selector Sel, if (data().ExternallyCompleted) LoadExternalDefinition(); - while (ClassDecl != NULL) { + while (ClassDecl) { if ((MethodDecl = ClassDecl->getMethod(Sel, isInstance))) return MethodDecl; @@ -501,7 +503,11 @@ ObjCMethodDecl *ObjCInterfaceDecl::lookupMethod(Selector Sel, return MethodDecl; } } - + + if (!followSuper) + return NULL; + + // Get the super class (if any). ClassDecl = ClassDecl->getSuperClass(); } return NULL; diff --git a/clang/lib/Sema/SemaDeclObjC.cpp b/clang/lib/Sema/SemaDeclObjC.cpp index 08556961109..95e3b4f4669 100644 --- a/clang/lib/Sema/SemaDeclObjC.cpp +++ b/clang/lib/Sema/SemaDeclObjC.cpp @@ -1664,7 +1664,10 @@ void Sema::CheckProtocolMethodDefs(SourceLocation ImpLoc, if (method->getImplementationControl() != ObjCMethodDecl::Optional && !method->isPropertyAccessor() && !InsMap.count(method->getSelector()) && - (!Super || !Super->lookupInstanceMethod(method->getSelector()))) { + (!Super || !Super->lookupMethod(method->getSelector(), + true /* instance */, + false /* shallowCategory */, + true /* followsSuper */))) { // If a method is not implemented in the category implementation but // has been declared in its primary class, superclass, // or in one of their protocols, no need to issue the warning. @@ -1675,8 +1678,10 @@ void Sema::CheckProtocolMethodDefs(SourceLocation ImpLoc, // have been synthesized due to a property declared in the class which // uses the protocol. if (ObjCMethodDecl *MethodInClass = - IDecl->lookupInstanceMethod(method->getSelector(), - true /*shallowCategoryLookup*/)) + IDecl->lookupMethod(method->getSelector(), + true /* instance */, + true /* shallowCategoryLookup */, + false /* followSuper */)) if (C || MethodInClass->isPropertyAccessor()) continue; unsigned DIAG = diag::warn_unimplemented_protocol_method; @@ -1695,11 +1700,17 @@ void Sema::CheckProtocolMethodDefs(SourceLocation ImpLoc, ObjCMethodDecl *method = *I; if (method->getImplementationControl() != ObjCMethodDecl::Optional && !ClsMap.count(method->getSelector()) && - (!Super || !Super->lookupClassMethod(method->getSelector()))) { + (!Super || !Super->lookupMethod(method->getSelector(), + false /* class method */, + false /* shallowCategoryLookup */, + true /* followSuper */))) { // See above comment for instance method lookups. - if (C && IDecl->lookupClassMethod(method->getSelector(), - true /*shallowCategoryLookup*/)) + if (C && IDecl->lookupMethod(method->getSelector(), + false /* class */, + true /* shallowCategoryLookup */, + false /* followSuper */)) continue; + unsigned DIAG = diag::warn_unimplemented_protocol_method; if (Diags.getDiagnosticLevel(DIAG, ImpLoc) != DiagnosticsEngine::Ignored) { |