From: Douglas Gregor Date: Thu, 3 May 2012 21:25:24 +0000 (+0000) Subject: Do not keep track of the set of visited Objective-C containers when X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=c968334510b0193ae8977c83d3ee66cbd6867639;p=clang Do not keep track of the set of visited Objective-C containers when performing the search for overridden methods. We very rarely see the same container twice, and in those rare cases we still have the fallback of the second SmallPtrSet to eliminate duplicates. Good for ~1.5% -fsyntax-only speedup on the code in . git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@156103 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/Sema/SemaDeclObjC.cpp b/lib/Sema/SemaDeclObjC.cpp index ac6486de63..1b4896b505 100644 --- a/lib/Sema/SemaDeclObjC.cpp +++ b/lib/Sema/SemaDeclObjC.cpp @@ -2499,7 +2499,6 @@ class OverrideSearch { public: Sema &S; ObjCMethodDecl *Method; - llvm::SmallPtrSet Searched; llvm::SmallPtrSet Overridden; bool Recursive; @@ -2528,8 +2527,12 @@ public: // Prevent the search from reaching this container again. This is // important with categories, which override methods from the // interface and each other. - Searched.insert(container); - searchFromContainer(container); + if (ObjCCategoryDecl *Category = dyn_cast(container)) { + searchFromContainer(container); + searchFromContainer(Category->getClassInterface()); + } else { + searchFromContainer(container); + } } typedef llvm::SmallPtrSet::iterator iterator; @@ -2565,7 +2568,7 @@ private: void searchFrom(ObjCCategoryDecl *category) { // A method in a category declaration overrides declarations from // the main class and from protocols the category references. - search(category->getClassInterface()); + // The main class is handled in the constructor. search(category->getReferencedProtocols()); } @@ -2575,6 +2578,7 @@ private: // declaration. if (ObjCCategoryDecl *category = impl->getCategoryDecl()) { search(category); + search(category->getClassInterface()); // Otherwise it overrides declarations from the class. } else { @@ -2614,9 +2618,6 @@ private: } void search(ObjCContainerDecl *container) { - // Abort if we've already searched this container. - if (!Searched.insert(container)) return; - // Check for a method in this container which matches this selector. ObjCMethodDecl *meth = container->getMethod(Method->getSelector(), Method->isInstanceMethod());