diff --git a/include/swift/Parse/Lexer.h b/include/swift/Parse/Lexer.h index b787a9c53e329..fa32094085bf1 100644 --- a/include/swift/Parse/Lexer.h +++ b/include/swift/Parse/Lexer.h @@ -76,12 +76,6 @@ class Lexer { void primeLexer(); public: - Lexer(llvm::StringRef Buffer, SourceManager &SourceMgr, - DiagnosticEngine *Diags, bool InSILMode, bool KeepComments = false) - : Lexer(SourceMgr, Buffer, Diags, Buffer.begin(), InSILMode, - KeepComments, /*Prime=*/true) { - } - Lexer(SourceManager &SourceMgr, unsigned BufferID, DiagnosticEngine *Diags, bool InSILMode, bool KeepComments = false, unsigned Offset = 0, unsigned EndOffset = 0); diff --git a/lib/Parse/Parser.cpp b/lib/Parse/Parser.cpp index b191954aeb504..dc0b1794da542 100644 --- a/lib/Parse/Parser.cpp +++ b/lib/Parse/Parser.cpp @@ -243,9 +243,8 @@ Parser::Parser(Lexer *Lex, TranslationUnit *TU, Parser::Parser(unsigned BufferID, TranslationUnit *TU, bool IsMainModule, SILParserState *SIL, PersistentParserState *PersistentState) - : Parser(new Lexer(TU->getASTContext().SourceMgr - ->getMemoryBuffer(BufferID)->getBuffer(), - TU->getASTContext().SourceMgr, &TU->getASTContext().Diags, + : Parser(new Lexer(TU->getASTContext().SourceMgr, BufferID, + &TU->getASTContext().Diags, /*InSILMode=*/SIL != nullptr, /*KeepComments=*/false), TU, TU->getASTContext().Diags, SIL, PersistentState) { this->IsMainModule = IsMainModule; diff --git a/tools/swift/Immediate.cpp b/tools/swift/Immediate.cpp index 7c7c9f7016deb..6b3a4f754589e 100644 --- a/tools/swift/Immediate.cpp +++ b/tools/swift/Immediate.cpp @@ -1060,10 +1060,10 @@ class REPLEnvironment { case REPLInputKind::REPLDirective: { auto Buffer = llvm::MemoryBuffer::getMemBufferCopy(Line, ""); - TU->getASTContext().SourceMgr->AddNewSourceBuffer(Buffer, - llvm::SMLoc()); - Lexer L(Buffer->getBuffer(), CI.getSourceMgr(), nullptr, - false /*not SIL*/); + unsigned BufferID = + TU->getASTContext().SourceMgr->AddNewSourceBuffer(Buffer, + llvm::SMLoc()); + Lexer L(CI.getSourceMgr(), BufferID, nullptr, false /*not SIL*/); Token Tok; L.lex(Tok); assert(Tok.is(tok::colon)); diff --git a/unittests/Parse/LexerTests.cpp b/unittests/Parse/LexerTests.cpp index 5ba4f8127f59a..17462dd55a91a 100644 --- a/unittests/Parse/LexerTests.cpp +++ b/unittests/Parse/LexerTests.cpp @@ -14,9 +14,7 @@ class LexerTest : public ::testing::Test { public: std::vector tokenizeAndKeepEOF(unsigned BufferID) { - const llvm::MemoryBuffer *Buffer = SourceMgr->getMemoryBuffer(BufferID); - Lexer L(Buffer->getBuffer(), SourceMgr, /*Diags=*/nullptr, - /*InSILMode=*/false); + Lexer L(SourceMgr, BufferID, /*Diags=*/nullptr, /*InSILMode=*/false); std::vector Tokens; do { Tokens.emplace_back();