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.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@62422 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/Lex/Lexer.cpp b/lib/Lex/Lexer.cpp
index c379f58..772a4d9 100644
--- a/lib/Lex/Lexer.cpp
+++ b/lib/Lex/Lexer.cpp
@@ -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(),