diff options
author | Chris Lattner <sabre@nondot.org> | 2009-04-14 23:22:57 +0000 |
---|---|---|
committer | Chris Lattner <sabre@nondot.org> | 2009-04-14 23:22:57 +0000 |
commit | 184e65d363aa9148c3935ca445bb823e6e0d3617 (patch) | |
tree | a96cc2e85d6e328bc5623f14a4dcc1801cc3656e /clang/lib/Lex/Lexer.cpp | |
parent | 6c6aea914ab003284feb2ad49627007dd525940e (diff) | |
download | bcm5719-llvm-184e65d363aa9148c3935ca445bb823e6e0d3617.tar.gz bcm5719-llvm-184e65d363aa9148c3935ca445bb823e6e0d3617.zip |
Change Lexer::MeasureTokenLength to take a LangOptions reference.
This allows it to accurately measure tokens, so that we get:
t.cpp:8:13: error: unknown type name 'X'
static foo::X P;
~~~~~^
instead of the woefully inferior:
t.cpp:8:13: error: unknown type name 'X'
static foo::X P;
~~~~ ^
Most of this is just plumbing to push the reference around.
llvm-svn: 69099
Diffstat (limited to 'clang/lib/Lex/Lexer.cpp')
-rw-r--r-- | clang/lib/Lex/Lexer.cpp | 8 |
1 files changed, 2 insertions, 6 deletions
diff --git a/clang/lib/Lex/Lexer.cpp b/clang/lib/Lex/Lexer.cpp index 059afe21822..d04b1c2b69e 100644 --- a/clang/lib/Lex/Lexer.cpp +++ b/clang/lib/Lex/Lexer.cpp @@ -216,7 +216,8 @@ void Lexer::Stringify(llvm::SmallVectorImpl<char> &Str) { /// includes a trigraph or an escaped newline) then this count includes bytes /// that are part of that. unsigned Lexer::MeasureTokenLength(SourceLocation Loc, - const SourceManager &SM) { + const SourceManager &SM, + const LangOptions &LangOpts) { // TODO: this could be special cased for common tokens like identifiers, ')', // etc to make this faster, if it mattered. Just look at StrData[0] to handle // all obviously single-char tokens. This could use @@ -230,11 +231,6 @@ unsigned Lexer::MeasureTokenLength(SourceLocation Loc, std::pair<const char *,const char *> Buffer = SM.getBufferData(LocInfo.first); const char *StrData = Buffer.first+LocInfo.second; - // Create a langops struct and enable trigraphs. This is sufficient for - // measuring tokens. - LangOptions LangOpts; - LangOpts.Trigraphs = true; - // Create a lexer starting at the beginning of this token. Lexer TheLexer(Loc, LangOpts, Buffer.first, StrData, Buffer.second); Token TheTok; |