aboutsummaryrefslogtreecommitdiff
path: root/include/clang/Lex/Lexer.h
diff options
context:
space:
mode:
authorDouglas Gregor <dgregor@apple.com>2010-07-22 20:22:31 +0000
committerDouglas Gregor <dgregor@apple.com>2010-07-22 20:22:31 +0000
commita8e5c5bdbe387b2552c1c23b828f54abcf085a40 (patch)
treed115ba6aac99af91204c9921723bebd4d9d247ef /include/clang/Lex/Lexer.h
parent3fe104154dd2e8ffb351142d74f308938b5c99bf (diff)
Improve performance during cursor traversal when a region of interest
is present. Rather than using clang_getCursorExtent(), which requires us to lex the token at the ending position to determine its length. Then, we'd be comparing [a, b) source ranges that cover the characters in the range rather than the normal behavior for Clang's source ranges, which covers the tokens in the range. However, relexing causes us to read the source file (which may come from a precompiled header), which is rather unfortunate and affects performance. In the new scheme, we only use Clang-style source ranges that cover the tokens in the range. At the entry points where this matters (clang_annotateTokens, clang_getCursor), we make sure to move source locations to the start of the token. Addresses most of <rdar://problem/8049381>. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@109134 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'include/clang/Lex/Lexer.h')
-rw-r--r--include/clang/Lex/Lexer.h9
1 files changed, 9 insertions, 0 deletions
diff --git a/include/clang/Lex/Lexer.h b/include/clang/Lex/Lexer.h
index 96d7605e4d..8dd37d0348 100644
--- a/include/clang/Lex/Lexer.h
+++ b/include/clang/Lex/Lexer.h
@@ -219,6 +219,15 @@ public:
const SourceManager &SM,
const LangOptions &LangOpts);
+ /// \brief Given a location any where in a source buffer, find the location
+ /// that corresponds to the beginning of the token in which the original
+ /// source location lands.
+ ///
+ /// \param Loc
+ static SourceLocation GetBeginningOfToken(SourceLocation Loc,
+ const SourceManager &SM,
+ const LangOptions &LangOpts);
+
/// \brief Compute the preamble of the given file.
///
/// The preamble of a file contains the initial comments, include directives,