diff options
author | Argyrios Kyrtzidis <akyrtzi@gmail.com> | 2013-04-15 18:47:22 +0000 |
---|---|---|
committer | Argyrios Kyrtzidis <akyrtzi@gmail.com> | 2013-04-15 18:47:22 +0000 |
commit | 77670f17ae3a5c3188149c19a7e386c01d0aa7c0 (patch) | |
tree | 63a989619863e0ff50192279a22ea1a2b42610a8 /lib/AST/DeclObjC.cpp | |
parent | 1f35ec3c2c5662644c07969a1b5c5ad748764285 (diff) |
Revert "Speed-up ObjCMethodDecl::getOverriddenMethods()."
This reverts commit r179436.
Due to caching, it was possible that we could miss overridden methods that
were introduced by categories later on.
Along with reverting the commit I also included a test case that would have caught this.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@179547 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/AST/DeclObjC.cpp')
-rw-r--r-- | lib/AST/DeclObjC.cpp | 32 |
1 files changed, 25 insertions, 7 deletions
diff --git a/lib/AST/DeclObjC.cpp b/lib/AST/DeclObjC.cpp index 1fe262cc0c..5f5ba52947 100644 --- a/lib/AST/DeclObjC.cpp +++ b/lib/AST/DeclObjC.cpp @@ -959,6 +959,26 @@ static void collectOverriddenMethodsSlow(const ObjCMethodDecl *Method, } } +static void collectOnCategoriesAfterLocation(SourceLocation Loc, + const ObjCInterfaceDecl *Class, + SourceManager &SM, + const ObjCMethodDecl *Method, + SmallVectorImpl<const ObjCMethodDecl *> &Methods) { + if (!Class) + return; + + for (ObjCInterfaceDecl::known_categories_iterator + Cat = Class->known_categories_begin(), + CatEnd = Class->known_categories_end(); + Cat != CatEnd; ++Cat) { + if (SM.isBeforeInTranslationUnit(Loc, Cat->getLocation())) + CollectOverriddenMethodsRecurse(*Cat, Method, Methods, true); + } + + collectOnCategoriesAfterLocation(Loc, Class->getSuperClass(), SM, + Method, Methods); +} + /// \brief Faster collection that is enabled when ObjCMethodDecl::isOverriding() /// returns false. /// You'd think that in that case there are no overrides but categories can @@ -968,7 +988,7 @@ static void collectOverriddenMethodsSlow(const ObjCMethodDecl *Method, /// further in super classes. /// Methods in an implementation can overide methods in super class's category /// but not in current class's category. But, such methods -static void collectOverriddenMethodsFast(ASTContext &Ctx, +static void collectOverriddenMethodsFast(SourceManager &SM, const ObjCMethodDecl *Method, SmallVectorImpl<const ObjCMethodDecl *> &Methods) { assert(!Method->isOverriding()); @@ -981,11 +1001,8 @@ static void collectOverriddenMethodsFast(ASTContext &Ctx, if (!Class) return; - SmallVector<const ObjCCategoryDecl *, 32> Cats; - Ctx.getBaseObjCCategoriesAfterInterface(Class, Cats); - for (SmallVectorImpl<const ObjCCategoryDecl *>::iterator - I = Cats.begin(), E = Cats.end(); I != E; ++I) - CollectOverriddenMethodsRecurse(*I, Method, Methods, true); + collectOnCategoriesAfterLocation(Class->getLocation(), Class->getSuperClass(), + SM, Method, Methods); } void ObjCMethodDecl::getOverriddenMethods( @@ -998,7 +1015,8 @@ void ObjCMethodDecl::getOverriddenMethods( } if (!Method->isOverriding()) { - collectOverriddenMethodsFast(getASTContext(), Method, Overridden); + collectOverriddenMethodsFast(getASTContext().getSourceManager(), + Method, Overridden); } else { collectOverriddenMethodsSlow(Method, Overridden); assert(!Overridden.empty() && |