aboutsummaryrefslogtreecommitdiff
path: root/lib/Lex/Lexer.cpp
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2008-10-12 01:15:46 +0000
committerChris Lattner <sabre@nondot.org>2008-10-12 01:15:46 +0000
commit590f0cc643274267d4d41125b62557e1d87886c3 (patch)
tree14c635be6f090632fb0f04d9e5957144d1270ac1 /lib/Lex/Lexer.cpp
parent3304e55f613ce34d9a14c3aaf06f5949408b3092 (diff)
Change how raw lexers are handled: instead of creating them and then
using LexRawToken, create one and use LexFromRawLexer. This avoids twiddling the RawLexer flag around and simplifies some code (even speeding raw lexing up a tiny bit). This change also improves the token paster to use a Lexer on the stack instead of new/deleting it. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@57393 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Lex/Lexer.cpp')
-rw-r--r--lib/Lex/Lexer.cpp11
1 files changed, 6 insertions, 5 deletions
diff --git a/lib/Lex/Lexer.cpp b/lib/Lex/Lexer.cpp
index c99dc1d4b8..e930f3def2 100644
--- a/lib/Lex/Lexer.cpp
+++ b/lib/Lex/Lexer.cpp
@@ -104,15 +104,16 @@ Lexer::Lexer(SourceLocation fileloc, Preprocessor &pp,
}
/// Lexer constructor - Create a new raw lexer object. This object is only
-/// suitable for calls to 'LexRawToken'. This lexer assumes that the
-/// associated file buffer will outlive it, so it doesn't take ownership of it.
+/// suitable for calls to 'LexRawToken'. This lexer assumes that the text
+/// range will outlive it, so it doesn't take ownership of it.
Lexer::Lexer(SourceLocation fileloc, const LangOptions &features,
- const char *BufStart, const char *BufEnd)
+ const char *BufStart, const char *BufEnd,
+ const llvm::MemoryBuffer *FromFile)
: FileLoc(fileloc), PP(0), Features(features) {
Is_PragmaLexer = false;
InitCharacterInfo();
- BufferStart = BufStart;
+ BufferStart = FromFile ? FromFile->getBufferStart() : BufStart;
BufferPtr = BufStart;
BufferEnd = BufEnd;
@@ -192,7 +193,7 @@ unsigned Lexer::MeasureTokenLength(SourceLocation Loc,
// Create a lexer starting at the beginning of this token.
Lexer TheLexer(Loc, LangOpts, StrData, BufEnd);
Token TheTok;
- TheLexer.LexRawToken(TheTok);
+ TheLexer.LexFromRawLexer(TheTok);
return TheTok.getLength();
}