diff options
| author | Steve Naroff <snaroff@apple.com> | 2009-10-21 13:56:23 +0000 |
|---|---|---|
| committer | Steve Naroff <snaroff@apple.com> | 2009-10-21 13:56:23 +0000 |
| commit | 20bad0b7c65bb74adc64d31ef76dcc12ff4d6737 (patch) | |
| tree | 8df7876b0c1b4feecc371c0919afcba99acc3415 /clang/lib/Index | |
| parent | 45f99d662157a9c41445355b5494bce3acf31b46 (diff) | |
| download | bcm5719-llvm-20bad0b7c65bb74adc64d31ef76dcc12ff4d6737.tar.gz bcm5719-llvm-20bad0b7c65bb74adc64d31ef76dcc12ff4d6737.zip | |
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:-)
llvm-svn: 84760
Diffstat (limited to 'clang/lib/Index')
| -rw-r--r-- | clang/lib/Index/ResolveLocation.cpp | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/clang/lib/Index/ResolveLocation.cpp b/clang/lib/Index/ResolveLocation.cpp index b94d48e33d6..d3ba8192b22 100644 --- a/clang/lib/Index/ResolveLocation.cpp +++ b/clang/lib/Index/ResolveLocation.cpp @@ -497,9 +497,12 @@ void LocResolverBase::print(Stmt *Node) { /// \brief Returns the AST node that a source location points to. /// -ASTLocation idx::ResolveLocationInAST(ASTContext &Ctx, SourceLocation Loc) { +ASTLocation idx::ResolveLocationInAST(ASTContext &Ctx, SourceLocation Loc, + Decl *RelativeToDecl) { if (Loc.isInvalid()) return ASTLocation(); + if (RelativeToDecl) + return DeclLocResolver(Ctx, Loc).Visit(RelativeToDecl); return DeclLocResolver(Ctx, Loc).Visit(Ctx.getTranslationUnitDecl()); } |

