diff options
author | Chris Lattner <sabre@nondot.org> | 2009-01-17 07:35:14 +0000 |
---|---|---|
committer | Chris Lattner <sabre@nondot.org> | 2009-01-17 07:35:14 +0000 |
commit | 025c3a66402fb713c2d9bf5dc174ff264765379a (patch) | |
tree | 9a7d1d7292856fbe5322c27ddc30467b5e35cebe /lib/Lex/Lexer.cpp | |
parent | 22d91ca8d7c134eac5cc6a4869e6a84c461ad624 (diff) |
add a simplified lexer ctor that sets up the lexer to raw-lex an
entire file.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@62414 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Lex/Lexer.cpp')
-rw-r--r-- | lib/Lex/Lexer.cpp | 15 |
1 files changed, 14 insertions, 1 deletions
diff --git a/lib/Lex/Lexer.cpp b/lib/Lex/Lexer.cpp index e89815029d..704c4db661 100644 --- a/lib/Lex/Lexer.cpp +++ b/lib/Lex/Lexer.cpp @@ -127,7 +127,6 @@ Lexer::Lexer(SourceLocation fileloc, const LangOptions &features, const char *BufPtr, const char *BufEnd, const llvm::MemoryBuffer *FromFile) : FileLoc(fileloc), Features(features) { - // If a MemoryBuffer was specified, use its start as BufferStart. This affects // the source location objects produced by this lexer. @@ -140,6 +139,20 @@ Lexer::Lexer(SourceLocation fileloc, const LangOptions &features, LexingRawMode = true; } +/// Lexer constructor - Create a new raw lexer object. This object is only +/// 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(FileID FID, const SourceManager &SM, const LangOptions &features) + : FileLoc(SM.getLocForStartOfFile(FID)), Features(features) { + const llvm::MemoryBuffer *FromFile = SM.getBuffer(FID); + + InitLexer(FromFile->getBufferStart(), FromFile->getBufferStart(), + FromFile->getBufferEnd()); + + // We *are* in raw mode. + LexingRawMode = true; +} + /// Stringify - Convert the specified string into a C string, with surrounding /// ""'s, and with escaped \ and " characters. |