aboutsummaryrefslogtreecommitdiff
path: root/tools/CIndex/CIndex.cpp
diff options
context:
space:
mode:
authorSteve Naroff <snaroff@apple.com>2009-10-21 13:56:23 +0000
committerSteve Naroff <snaroff@apple.com>2009-10-21 13:56:23 +0000
commit6a6de8b4fc944ca1bfa4e47c516d049a0d627b0e (patch)
tree3cd9fdb048843bd8aae56efb65d740a3bc072d3c /tools/CIndex/CIndex.cpp
parent727e268bd2974a7b16af65a5cfdfe47da9ebeb6c (diff)
Extend clang_getCursor() to take a 'relativeDecl' argument (so speed up searching). Without a 'relativeDecl', the algorithm is n-squared. For example, running the following command on 'Large.m' takes hours without a 'relatvieDecl'.
snaroff% time ../../Debug/bin/c-index-test Large.ast all > Large.out snaroff% cat Large.m #import <Cocoa/Cocoa.h> #import <QuickTime/QuickTime.h> #import <OpenGL/OpenGL.h> With a 'relativeDecl', it takes <30 seconds:-) git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@84760 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'tools/CIndex/CIndex.cpp')
-rw-r--r--tools/CIndex/CIndex.cpp6
1 files changed, 4 insertions, 2 deletions
diff --git a/tools/CIndex/CIndex.cpp b/tools/CIndex/CIndex.cpp
index eff602ff8e..fb6dd5608f 100644
--- a/tools/CIndex/CIndex.cpp
+++ b/tools/CIndex/CIndex.cpp
@@ -655,7 +655,8 @@ static enum CXCursorKind TranslateKind(Decl *D) {
// CXCursor Operations.
//
CXCursor clang_getCursor(CXTranslationUnit CTUnit, const char *source_name,
- unsigned line, unsigned column)
+ unsigned line, unsigned column,
+ CXDecl RelativeToDecl)
{
assert(CTUnit && "Passed null CXTranslationUnit");
ASTUnit *CXXUnit = static_cast<ASTUnit *>(CTUnit);
@@ -670,7 +671,8 @@ CXCursor clang_getCursor(CXTranslationUnit CTUnit, const char *source_name,
SourceLocation SLoc =
CXXUnit->getSourceManager().getLocation(File, line, column);
- ASTLocation ALoc = ResolveLocationInAST(CXXUnit->getASTContext(), SLoc);
+ ASTLocation ALoc = ResolveLocationInAST(CXXUnit->getASTContext(), SLoc,
+ static_cast<NamedDecl *>(RelativeToDecl));
Decl *Dcl = ALoc.getParentDecl();
if (ALoc.isNamedRef())