[cfe-commits] r62422 - in /cfe/trunk: include/clang/Lex/Lexer.h lib/Lex/Lexer.cpp lib/Lex/PPLexerChange.cpp
Chris Lattner
sabre at nondot.org
Sat Jan 17 00:03:43 PST 2009
Author: lattner
Date: Sat Jan 17 02:03:42 2009
New Revision: 62422
URL: http://llvm.org/viewvc/llvm-project?rev=62422&view=rev
Log:
Change the Lexer ctor used in the non _Pragma case to take a FileID instead
of a SourceLocation. This should speed it up and definitely simplifies it.
Modified:
cfe/trunk/include/clang/Lex/Lexer.h
cfe/trunk/lib/Lex/Lexer.cpp
cfe/trunk/lib/Lex/PPLexerChange.cpp
Modified: cfe/trunk/include/clang/Lex/Lexer.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Lex/Lexer.h?rev=62422&r1=62421&r2=62422&view=diff
==============================================================================
--- cfe/trunk/include/clang/Lex/Lexer.h (original)
+++ cfe/trunk/include/clang/Lex/Lexer.h Sat Jan 17 02:03:42 2009
@@ -77,7 +77,7 @@
/// with the specified preprocessor managing the lexing process. This lexer
/// assumes that the associated file buffer and Preprocessor objects will
/// outlive it, so it doesn't take ownership of either of them.
- Lexer(SourceLocation FileLoc, Preprocessor &PP);
+ Lexer(FileID FID, Preprocessor &PP);
Lexer(SourceLocation FileLoc, Preprocessor &PP,
const char *BufStart, const char *BufEnd);
Modified: cfe/trunk/lib/Lex/Lexer.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Lex/Lexer.cpp?rev=62422&r1=62421&r2=62422&view=diff
==============================================================================
--- cfe/trunk/lib/Lex/Lexer.cpp (original)
+++ cfe/trunk/lib/Lex/Lexer.cpp Sat Jan 17 02:03:42 2009
@@ -94,17 +94,12 @@
/// with the specified preprocessor managing the lexing process. This lexer
/// assumes that the associated file buffer and Preprocessor objects will
/// outlive it, so it doesn't take ownership of either of them.
-Lexer::Lexer(SourceLocation fileloc, Preprocessor &PP)
-// FIXME: This is really horrible and only needed for _Pragma lexers, split this
-// out of the main lexer path!
-: PreprocessorLexer(&PP,
- PP.getSourceManager().getCanonicalFileID(
- PP.getSourceManager().getSpellingLoc(fileloc))),
- FileLoc(fileloc),
- Features(PP.getLangOptions()) {
+Lexer::Lexer(FileID FID, Preprocessor &PP)
+ : PreprocessorLexer(&PP, FID),
+ FileLoc(PP.getSourceManager().getLocForStartOfFile(FID)),
+ Features(PP.getLangOptions()) {
- SourceManager &SourceMgr = PP.getSourceManager();
- const llvm::MemoryBuffer *InputFile = SourceMgr.getBuffer(getFileID());
+ const llvm::MemoryBuffer *InputFile = PP.getSourceManager().getBuffer(FID);
InitLexer(InputFile->getBufferStart(), InputFile->getBufferStart(),
InputFile->getBufferEnd());
@@ -124,7 +119,7 @@
: PreprocessorLexer(&PP,
PP.getSourceManager().getCanonicalFileID(
PP.getSourceManager().getSpellingLoc(fileloc))),
- FileLoc(fileloc),
+ FileLoc(fileloc),
Features(PP.getLangOptions()) {
InitLexer(PP.getSourceManager().getBuffer(getFileID())->getBufferStart(),
Modified: cfe/trunk/lib/Lex/PPLexerChange.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Lex/PPLexerChange.cpp?rev=62422&r1=62421&r2=62422&view=diff
==============================================================================
--- cfe/trunk/lib/Lex/PPLexerChange.cpp (original)
+++ cfe/trunk/lib/Lex/PPLexerChange.cpp Sat Jan 17 02:03:42 2009
@@ -74,16 +74,10 @@
MaxIncludeStackDepth = IncludeMacroStack.size();
if (PTH) {
- PTHLexer *PL = PTH->CreateLexer(FID, SourceMgr.getFileEntryForID(FID));
-
- if (PL) {
- EnterSourceFileWithPTH(PL, CurDir);
- return;
- }
+ if (PTHLexer *PL = PTH->CreateLexer(FID, SourceMgr.getFileEntryForID(FID)))
+ return EnterSourceFileWithPTH(PL, CurDir);
}
-
- Lexer *TheLexer = new Lexer(SourceMgr.getLocForStartOfFile(FID), *this);
- EnterSourceFileWithLexer(TheLexer, CurDir);
+ EnterSourceFileWithLexer(new Lexer(FID, *this), CurDir);
}
/// EnterSourceFileWithLexer - Add a source file to the top of the include stack
More information about the cfe-commits
mailing list