]> granicus.if.org Git - clang/commitdiff
Do not keep track of the set of visited Objective-C containers when
authorDouglas Gregor <dgregor@apple.com>
Thu, 3 May 2012 21:25:24 +0000 (21:25 +0000)
committerDouglas Gregor <dgregor@apple.com>
Thu, 3 May 2012 21:25:24 +0000 (21:25 +0000)
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 <rdar://problem/11004361>.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@156103 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Sema/SemaDeclObjC.cpp

index ac6486de6368ef7fae3faa33b74f23ec3bc97cec..1b4896b5053a5f4b7e7c2031929174d46ae404a1 100644 (file)
@@ -2499,7 +2499,6 @@ class OverrideSearch {
 public:
   Sema &S;
   ObjCMethodDecl *Method;
-  llvm::SmallPtrSet<ObjCContainerDecl*, 128> Searched;
   llvm::SmallPtrSet<ObjCMethodDecl*, 4> 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<ObjCCategoryDecl>(container)) {
+      searchFromContainer(container);
+      searchFromContainer(Category->getClassInterface());
+    } else {
+      searchFromContainer(container);
+    }
   }
 
   typedef llvm::SmallPtrSet<ObjCMethodDecl*, 128>::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());