mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-07-28 19:25:00 +00:00
This only needs a StringRef.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@212402 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@@ -28,8 +28,8 @@ using namespace llvm;
|
|||||||
|
|
||||||
TGLexer::TGLexer(SourceMgr &SM) : SrcMgr(SM) {
|
TGLexer::TGLexer(SourceMgr &SM) : SrcMgr(SM) {
|
||||||
CurBuffer = SrcMgr.getMainFileID();
|
CurBuffer = SrcMgr.getMainFileID();
|
||||||
CurBuf = SrcMgr.getMemoryBuffer(CurBuffer);
|
CurBuf = SrcMgr.getMemoryBuffer(CurBuffer)->getBuffer();
|
||||||
CurPtr = CurBuf->getBufferStart();
|
CurPtr = CurBuf.begin();
|
||||||
TokStart = nullptr;
|
TokStart = nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -52,7 +52,7 @@ int TGLexer::getNextChar() {
|
|||||||
case 0: {
|
case 0: {
|
||||||
// A nul character in the stream is either the end of the current buffer or
|
// A nul character in the stream is either the end of the current buffer or
|
||||||
// a random nul in the file. Disambiguate that here.
|
// a random nul in the file. Disambiguate that here.
|
||||||
if (CurPtr-1 != CurBuf->getBufferEnd())
|
if (CurPtr-1 != CurBuf.end())
|
||||||
return 0; // Just whitespace.
|
return 0; // Just whitespace.
|
||||||
|
|
||||||
// If this is the end of an included file, pop the parent file off the
|
// If this is the end of an included file, pop the parent file off the
|
||||||
@@ -60,7 +60,7 @@ int TGLexer::getNextChar() {
|
|||||||
SMLoc ParentIncludeLoc = SrcMgr.getParentIncludeLoc(CurBuffer);
|
SMLoc ParentIncludeLoc = SrcMgr.getParentIncludeLoc(CurBuffer);
|
||||||
if (ParentIncludeLoc != SMLoc()) {
|
if (ParentIncludeLoc != SMLoc()) {
|
||||||
CurBuffer = SrcMgr.FindBufferContainingLoc(ParentIncludeLoc);
|
CurBuffer = SrcMgr.FindBufferContainingLoc(ParentIncludeLoc);
|
||||||
CurBuf = SrcMgr.getMemoryBuffer(CurBuffer);
|
CurBuf = SrcMgr.getMemoryBuffer(CurBuffer)->getBuffer();
|
||||||
CurPtr = ParentIncludeLoc.getPointer();
|
CurPtr = ParentIncludeLoc.getPointer();
|
||||||
return getNextChar();
|
return getNextChar();
|
||||||
}
|
}
|
||||||
@@ -187,7 +187,7 @@ tgtok::TokKind TGLexer::LexString() {
|
|||||||
|
|
||||||
while (*CurPtr != '"') {
|
while (*CurPtr != '"') {
|
||||||
// If we hit the end of the buffer, report an error.
|
// If we hit the end of the buffer, report an error.
|
||||||
if (*CurPtr == 0 && CurPtr == CurBuf->getBufferEnd())
|
if (*CurPtr == 0 && CurPtr == CurBuf.end())
|
||||||
return ReturnError(StrStart, "End of file in string literal");
|
return ReturnError(StrStart, "End of file in string literal");
|
||||||
|
|
||||||
if (*CurPtr == '\n' || *CurPtr == '\r')
|
if (*CurPtr == '\n' || *CurPtr == '\r')
|
||||||
@@ -220,7 +220,7 @@ tgtok::TokKind TGLexer::LexString() {
|
|||||||
|
|
||||||
// If we hit the end of the buffer, report an error.
|
// If we hit the end of the buffer, report an error.
|
||||||
case '\0':
|
case '\0':
|
||||||
if (CurPtr == CurBuf->getBufferEnd())
|
if (CurPtr == CurBuf.end())
|
||||||
return ReturnError(StrStart, "End of file in string literal");
|
return ReturnError(StrStart, "End of file in string literal");
|
||||||
// FALL THROUGH
|
// FALL THROUGH
|
||||||
default:
|
default:
|
||||||
@@ -319,8 +319,8 @@ bool TGLexer::LexInclude() {
|
|||||||
}
|
}
|
||||||
Dependencies.insert(std::make_pair(IncludedFile, getLoc()));
|
Dependencies.insert(std::make_pair(IncludedFile, getLoc()));
|
||||||
// Save the line number and lex buffer of the includer.
|
// Save the line number and lex buffer of the includer.
|
||||||
CurBuf = SrcMgr.getMemoryBuffer(CurBuffer);
|
CurBuf = SrcMgr.getMemoryBuffer(CurBuffer)->getBuffer();
|
||||||
CurPtr = CurBuf->getBufferStart();
|
CurPtr = CurBuf.begin();
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -333,7 +333,7 @@ void TGLexer::SkipBCPLComment() {
|
|||||||
return; // Newline is end of comment.
|
return; // Newline is end of comment.
|
||||||
case 0:
|
case 0:
|
||||||
// If this is the end of the buffer, end the comment.
|
// If this is the end of the buffer, end the comment.
|
||||||
if (CurPtr == CurBuf->getBufferEnd())
|
if (CurPtr == CurBuf.end())
|
||||||
return;
|
return;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@@ -14,6 +14,7 @@
|
|||||||
#ifndef TGLEXER_H
|
#ifndef TGLEXER_H
|
||||||
#define TGLEXER_H
|
#define TGLEXER_H
|
||||||
|
|
||||||
|
#include "llvm/ADT/StringRef.h"
|
||||||
#include "llvm/Support/DataTypes.h"
|
#include "llvm/Support/DataTypes.h"
|
||||||
#include "llvm/Support/SMLoc.h"
|
#include "llvm/Support/SMLoc.h"
|
||||||
#include <cassert>
|
#include <cassert>
|
||||||
@@ -21,7 +22,6 @@
|
|||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
namespace llvm {
|
namespace llvm {
|
||||||
class MemoryBuffer;
|
|
||||||
class SourceMgr;
|
class SourceMgr;
|
||||||
class SMLoc;
|
class SMLoc;
|
||||||
class Twine;
|
class Twine;
|
||||||
@@ -63,7 +63,7 @@ class TGLexer {
|
|||||||
SourceMgr &SrcMgr;
|
SourceMgr &SrcMgr;
|
||||||
|
|
||||||
const char *CurPtr;
|
const char *CurPtr;
|
||||||
const MemoryBuffer *CurBuf;
|
StringRef CurBuf;
|
||||||
|
|
||||||
// Information about the current token.
|
// Information about the current token.
|
||||||
const char *TokStart;
|
const char *TokStart;
|
||||||
|
Reference in New Issue
Block a user