mirror of
https://github.com/RPCSX/llvm.git
synced 2024-11-24 12:19:53 +00:00
This only needs a StringRef.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@212401 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
bb7ad610ef
commit
26a84a6e7c
@ -28,7 +28,7 @@ class AsmLexer : public MCAsmLexer {
|
||||
const MCAsmInfo &MAI;
|
||||
|
||||
const char *CurPtr;
|
||||
const MemoryBuffer *CurBuf;
|
||||
StringRef CurBuf;
|
||||
bool isAtStartOfLine;
|
||||
|
||||
void operator=(const AsmLexer&) LLVM_DELETED_FUNCTION;
|
||||
@ -42,7 +42,7 @@ public:
|
||||
AsmLexer(const MCAsmInfo &MAI);
|
||||
~AsmLexer();
|
||||
|
||||
void setBuffer(const MemoryBuffer *buf, const char *ptr = nullptr);
|
||||
void setBuffer(StringRef Buf, const char *ptr = nullptr);
|
||||
|
||||
StringRef LexUntilEndOfStatement() override;
|
||||
StringRef LexUntilEndOfLine();
|
||||
|
@ -22,7 +22,6 @@
|
||||
using namespace llvm;
|
||||
|
||||
AsmLexer::AsmLexer(const MCAsmInfo &_MAI) : MAI(_MAI) {
|
||||
CurBuf = nullptr;
|
||||
CurPtr = nullptr;
|
||||
isAtStartOfLine = true;
|
||||
AllowAtInIdentifier = !StringRef(MAI.getCommentString()).startswith("@");
|
||||
@ -31,13 +30,13 @@ AsmLexer::AsmLexer(const MCAsmInfo &_MAI) : MAI(_MAI) {
|
||||
AsmLexer::~AsmLexer() {
|
||||
}
|
||||
|
||||
void AsmLexer::setBuffer(const MemoryBuffer *buf, const char *ptr) {
|
||||
CurBuf = buf;
|
||||
void AsmLexer::setBuffer(StringRef Buf, const char *ptr) {
|
||||
CurBuf = Buf;
|
||||
|
||||
if (ptr)
|
||||
CurPtr = ptr;
|
||||
else
|
||||
CurPtr = CurBuf->getBufferStart();
|
||||
CurPtr = CurBuf.begin();
|
||||
|
||||
TokStart = nullptr;
|
||||
}
|
||||
@ -58,7 +57,7 @@ int AsmLexer::getNextChar() {
|
||||
case 0:
|
||||
// A nul character in the stream is either the end of the current buffer or
|
||||
// a random nul in the file. Disambiguate that here.
|
||||
if (CurPtr-1 != CurBuf->getBufferEnd())
|
||||
if (CurPtr - 1 != CurBuf.end())
|
||||
return 0; // Just whitespace.
|
||||
|
||||
// Otherwise, return end of file.
|
||||
@ -420,9 +419,8 @@ StringRef AsmLexer::LexUntilEndOfStatement() {
|
||||
|
||||
while (!isAtStartOfComment(*CurPtr) && // Start of line comment.
|
||||
!isAtStatementSeparator(CurPtr) && // End of statement marker.
|
||||
*CurPtr != '\n' &&
|
||||
*CurPtr != '\r' &&
|
||||
(*CurPtr != 0 || CurPtr != CurBuf->getBufferEnd())) {
|
||||
*CurPtr != '\n' && *CurPtr != '\r' &&
|
||||
(*CurPtr != 0 || CurPtr != CurBuf.end())) {
|
||||
++CurPtr;
|
||||
}
|
||||
return StringRef(TokStart, CurPtr-TokStart);
|
||||
@ -431,9 +429,8 @@ StringRef AsmLexer::LexUntilEndOfStatement() {
|
||||
StringRef AsmLexer::LexUntilEndOfLine() {
|
||||
TokStart = CurPtr;
|
||||
|
||||
while (*CurPtr != '\n' &&
|
||||
*CurPtr != '\r' &&
|
||||
(*CurPtr != 0 || CurPtr != CurBuf->getBufferEnd())) {
|
||||
while (*CurPtr != '\n' && *CurPtr != '\r' &&
|
||||
(*CurPtr != 0 || CurPtr != CurBuf.end())) {
|
||||
++CurPtr;
|
||||
}
|
||||
return StringRef(TokStart, CurPtr-TokStart);
|
||||
|
@ -499,7 +499,7 @@ AsmParser::AsmParser(SourceMgr &_SM, MCContext &_Ctx, MCStreamer &_Out,
|
||||
SavedDiagContext = SrcMgr.getDiagContext();
|
||||
// Set our own handler which calls the saved handler.
|
||||
SrcMgr.setDiagHandler(DiagHandler, this);
|
||||
Lexer.setBuffer(SrcMgr.getMemoryBuffer(CurBuffer));
|
||||
Lexer.setBuffer(SrcMgr.getMemoryBuffer(CurBuffer)->getBuffer());
|
||||
|
||||
// Initialize the platform / file format parser.
|
||||
switch (_Ctx.getObjectFileInfo()->getObjectFileType()) {
|
||||
@ -572,7 +572,7 @@ bool AsmParser::enterIncludeFile(const std::string &Filename) {
|
||||
return true;
|
||||
|
||||
CurBuffer = NewBuf;
|
||||
Lexer.setBuffer(SrcMgr.getMemoryBuffer(CurBuffer));
|
||||
Lexer.setBuffer(SrcMgr.getMemoryBuffer(CurBuffer)->getBuffer());
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -593,7 +593,8 @@ bool AsmParser::processIncbinFile(const std::string &Filename) {
|
||||
|
||||
void AsmParser::jumpToLoc(SMLoc Loc, unsigned InBuffer) {
|
||||
CurBuffer = InBuffer ? InBuffer : SrcMgr.FindBufferContainingLoc(Loc);
|
||||
Lexer.setBuffer(SrcMgr.getMemoryBuffer(CurBuffer), Loc.getPointer());
|
||||
Lexer.setBuffer(SrcMgr.getMemoryBuffer(CurBuffer)->getBuffer(),
|
||||
Loc.getPointer());
|
||||
}
|
||||
|
||||
const AsmToken &AsmParser::Lex() {
|
||||
@ -2127,7 +2128,7 @@ bool AsmParser::handleMacroEntry(const MCAsmMacro *M, SMLoc NameLoc) {
|
||||
|
||||
// Jump to the macro instantiation and prime the lexer.
|
||||
CurBuffer = SrcMgr.AddNewSourceBuffer(MI->Instantiation, SMLoc());
|
||||
Lexer.setBuffer(SrcMgr.getMemoryBuffer(CurBuffer));
|
||||
Lexer.setBuffer(SrcMgr.getMemoryBuffer(CurBuffer)->getBuffer());
|
||||
Lex();
|
||||
|
||||
return false;
|
||||
@ -4264,7 +4265,7 @@ void AsmParser::instantiateMacroLikeBody(MCAsmMacro *M, SMLoc DirectiveLoc,
|
||||
|
||||
// Jump to the macro instantiation and prime the lexer.
|
||||
CurBuffer = SrcMgr.AddNewSourceBuffer(MI->Instantiation, SMLoc());
|
||||
Lexer.setBuffer(SrcMgr.getMemoryBuffer(CurBuffer));
|
||||
Lexer.setBuffer(SrcMgr.getMemoryBuffer(CurBuffer)->getBuffer());
|
||||
Lex();
|
||||
}
|
||||
|
||||
|
@ -242,7 +242,7 @@ static int AsLexInput(SourceMgr &SrcMgr, MCAsmInfo &MAI,
|
||||
tool_output_file *Out) {
|
||||
|
||||
AsmLexer Lexer(MAI);
|
||||
Lexer.setBuffer(SrcMgr.getMemoryBuffer(SrcMgr.getMainFileID()));
|
||||
Lexer.setBuffer(SrcMgr.getMemoryBuffer(SrcMgr.getMainFileID())->getBuffer());
|
||||
|
||||
bool Error = false;
|
||||
while (Lexer.Lex().isNot(AsmToken::Eof)) {
|
||||
|
Loading…
Reference in New Issue
Block a user