aboutsummaryrefslogtreecommitdiff
path: root/lib/AST/ASTContext.cpp
diff options
context:
space:
mode:
authorArgyrios Kyrtzidis <akyrtzi@gmail.com>2013-04-13 01:04:01 +0000
committerArgyrios Kyrtzidis <akyrtzi@gmail.com>2013-04-13 01:04:01 +0000
commit175c8e2e57befe2db15dd339ab5eb27d0c2b6013 (patch)
treeb8aa20a5d67521db1fcc8f26cf939fc6448126b6 /lib/AST/ASTContext.cpp
parentecc65238c98ba21d08763da7b7972d617677e908 (diff)
Speed-up ObjCMethodDecl::getOverriddenMethods().
Use an newly introduce ASTContext::getBaseObjCCategoriesAfterInterface() which caches its results instead of re-calculating the categories multiple times. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@179436 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/AST/ASTContext.cpp')
-rw-r--r--lib/AST/ASTContext.cpp37
1 files changed, 35 insertions, 2 deletions
diff --git a/lib/AST/ASTContext.cpp b/lib/AST/ASTContext.cpp
index 170cc0298b..8ede90dede 100644
--- a/lib/AST/ASTContext.cpp
+++ b/lib/AST/ASTContext.cpp
@@ -1127,8 +1127,8 @@ void ASTContext::getOverriddenMethods(
assert(D);
if (const CXXMethodDecl *CXXMethod = dyn_cast<CXXMethodDecl>(D)) {
- Overridden.append(CXXMethod->begin_overridden_methods(),
- CXXMethod->end_overridden_methods());
+ Overridden.append(overridden_methods_begin(CXXMethod),
+ overridden_methods_end(CXXMethod));
return;
}
@@ -1141,6 +1141,39 @@ void ASTContext::getOverriddenMethods(
Overridden.append(OverDecls.begin(), OverDecls.end());
}
+void ASTContext::getBaseObjCCategoriesAfterInterface(
+ const ObjCInterfaceDecl *D,
+ SmallVectorImpl<const ObjCCategoryDecl *> &Cats) const {
+ if (!D)
+ return;
+
+ typedef llvm::SmallVector<const ObjCCategoryDecl *, 2> VecTy;
+ typedef llvm::DenseMap<const ObjCInterfaceDecl *, VecTy> MapTy;
+
+ std::pair<MapTy::iterator, bool>
+ InsertOp = CatsAfterInterface.insert(std::make_pair(D, VecTy()));
+ VecTy &Vec = InsertOp.first->second;
+ if (!InsertOp.second) {
+ // already in map.
+ Cats.append(Vec.begin(), Vec.end());
+ return;
+ }
+
+ SourceLocation Loc = D->getLocation();
+ for (const ObjCInterfaceDecl *
+ Class = D->getSuperClass(); Class; Class = Class->getSuperClass()) {
+ for (ObjCInterfaceDecl::known_categories_iterator
+ CatI = Class->known_categories_begin(),
+ CatEnd = Class->known_categories_end();
+ CatI != CatEnd; ++CatI) {
+ if (SourceMgr.isBeforeInTranslationUnit(Loc, CatI->getLocation()))
+ Vec.push_back(*CatI);
+ }
+ }
+
+ Cats.append(Vec.begin(), Vec.end());
+}
+
void ASTContext::addedLocalImportDecl(ImportDecl *Import) {
assert(!Import->NextLocalImport && "Import declaration already in the chain");
assert(!Import->isFromASTFile() && "Non-local import declaration");