From 77e9de50a112dc3f0bee0d43469db4bde47225c9 Mon Sep 17 00:00:00 2001 From: Chris Lattner Date: Fri, 20 Jul 2007 16:52:03 +0000 Subject: simplify the lexer ctor to take a SLoc instead of a sloc and a redundant buffer*. llvm-svn: 40104 --- clang/Lex/Lexer.cpp | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) (limited to 'clang/Lex/Lexer.cpp') diff --git a/clang/Lex/Lexer.cpp b/clang/Lex/Lexer.cpp index a1db060c3e6..4efd62113d4 100644 --- a/clang/Lex/Lexer.cpp +++ b/clang/Lex/Lexer.cpp @@ -34,20 +34,24 @@ using namespace clang; static void InitCharacterInfo(); -Lexer::Lexer(const llvm::MemoryBuffer *File, SourceLocation fileloc, - Preprocessor &pp, const char *BufStart, const char *BufEnd) - : BufferEnd(BufEnd ? BufEnd : File->getBufferEnd()), - InputFile(File), FileLoc(fileloc), PP(pp), Features(PP.getLangOptions()) { +Lexer::Lexer(SourceLocation fileloc, Preprocessor &pp, + const char *BufStart, const char *BufEnd) + : FileLoc(fileloc), PP(pp), Features(PP.getLangOptions()) { + + SourceManager &SourceMgr = PP.getSourceManager(); + InputFile =SourceMgr.getBuffer(SourceMgr.getPhysicalLoc(FileLoc).getFileID()); + Is_PragmaLexer = false; IsMainFile = false; InitCharacterInfo(); + BufferPtr = BufStart ? BufStart : InputFile->getBufferStart(); + BufferEnd = BufEnd ? BufEnd : InputFile->getBufferEnd(); + assert(BufferEnd[0] == 0 && "We assume that the input buffer has a null character at the end" " to simplify lexing!"); - - BufferPtr = BufStart ? BufStart : File->getBufferStart(); - + // Start of the file is a start of line. IsAtStartOfLine = true; -- cgit v1.2.3