mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-08-09 11:25:55 +00:00
rename SourceMgr::PrintError to PrintMessage.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@73861 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@@ -107,10 +107,9 @@ public:
|
|||||||
/// specified file. This is not a fast method.
|
/// specified file. This is not a fast method.
|
||||||
unsigned FindLineNumber(SMLoc Loc, int BufferID = -1) const;
|
unsigned FindLineNumber(SMLoc Loc, int BufferID = -1) const;
|
||||||
|
|
||||||
|
/// PrintMessage - Emit a message about the specified location with the
|
||||||
/// PrintError - Emit an error message about the specified location with the
|
|
||||||
/// specified string.
|
/// specified string.
|
||||||
void PrintError(SMLoc ErrorLoc, const std::string &Msg) const;
|
void PrintMessage(SMLoc Loc, const std::string &Msg) const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void PrintIncludeStack(SMLoc IncludeLoc) const;
|
void PrintIncludeStack(SMLoc IncludeLoc) const;
|
||||||
|
@@ -90,12 +90,12 @@ void SourceMgr::PrintIncludeStack(SMLoc IncludeLoc) const {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void SourceMgr::PrintError(SMLoc ErrorLoc, const std::string &Msg) const {
|
void SourceMgr::PrintMessage(SMLoc Loc, const std::string &Msg) const {
|
||||||
raw_ostream &OS = errs();
|
raw_ostream &OS = errs();
|
||||||
|
|
||||||
// First thing to do: find the current buffer containing the specified
|
// First thing to do: find the current buffer containing the specified
|
||||||
// location.
|
// location.
|
||||||
int CurBuf = FindBufferContainingLoc(ErrorLoc);
|
int CurBuf = FindBufferContainingLoc(Loc);
|
||||||
assert(CurBuf != -1 && "Invalid or unspecified location!");
|
assert(CurBuf != -1 && "Invalid or unspecified location!");
|
||||||
|
|
||||||
PrintIncludeStack(getBufferInfo(CurBuf).IncludeLoc);
|
PrintIncludeStack(getBufferInfo(CurBuf).IncludeLoc);
|
||||||
@@ -104,24 +104,24 @@ void SourceMgr::PrintError(SMLoc ErrorLoc, const std::string &Msg) const {
|
|||||||
|
|
||||||
|
|
||||||
OS << "Parsing " << CurMB->getBufferIdentifier() << ":"
|
OS << "Parsing " << CurMB->getBufferIdentifier() << ":"
|
||||||
<< FindLineNumber(ErrorLoc, CurBuf) << ": ";
|
<< FindLineNumber(Loc, CurBuf) << ": ";
|
||||||
|
|
||||||
OS << Msg << "\n";
|
OS << Msg << "\n";
|
||||||
|
|
||||||
// Scan backward to find the start of the line.
|
// Scan backward to find the start of the line.
|
||||||
const char *LineStart = ErrorLoc.getPointer();
|
const char *LineStart = Loc.getPointer();
|
||||||
while (LineStart != CurMB->getBufferStart() &&
|
while (LineStart != CurMB->getBufferStart() &&
|
||||||
LineStart[-1] != '\n' && LineStart[-1] != '\r')
|
LineStart[-1] != '\n' && LineStart[-1] != '\r')
|
||||||
--LineStart;
|
--LineStart;
|
||||||
// Get the end of the line.
|
// Get the end of the line.
|
||||||
const char *LineEnd = ErrorLoc.getPointer();
|
const char *LineEnd = Loc.getPointer();
|
||||||
while (LineEnd != CurMB->getBufferEnd() &&
|
while (LineEnd != CurMB->getBufferEnd() &&
|
||||||
LineEnd[0] != '\n' && LineEnd[0] != '\r')
|
LineEnd[0] != '\n' && LineEnd[0] != '\r')
|
||||||
++LineEnd;
|
++LineEnd;
|
||||||
// Print out the line.
|
// Print out the line.
|
||||||
OS << std::string(LineStart, LineEnd) << "\n";
|
OS << std::string(LineStart, LineEnd) << "\n";
|
||||||
// Print out spaces before the caret.
|
// Print out spaces before the caret.
|
||||||
for (const char *Pos = LineStart; Pos != ErrorLoc.getPointer(); ++Pos)
|
for (const char *Pos = LineStart; Pos != Loc.getPointer(); ++Pos)
|
||||||
OS << (*Pos == '\t' ? '\t' : ' ');
|
OS << (*Pos == '\t' ? '\t' : ' ');
|
||||||
OS << "^\n";
|
OS << "^\n";
|
||||||
}
|
}
|
||||||
|
@@ -29,18 +29,14 @@ SMLoc AsmLexer::getLoc() const {
|
|||||||
return SMLoc::getFromPointer(TokStart);
|
return SMLoc::getFromPointer(TokStart);
|
||||||
}
|
}
|
||||||
|
|
||||||
void AsmLexer::PrintError(const char *Loc, const std::string &Msg) const {
|
void AsmLexer::PrintMessage(SMLoc Loc, const std::string &Msg) const {
|
||||||
SrcMgr.PrintError(SMLoc::getFromPointer(Loc), Msg);
|
SrcMgr.PrintMessage(Loc, Msg);
|
||||||
}
|
|
||||||
|
|
||||||
void AsmLexer::PrintError(SMLoc Loc, const std::string &Msg) const {
|
|
||||||
SrcMgr.PrintError(Loc, Msg);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// ReturnError - Set the error to the specified string at the specified
|
/// ReturnError - Set the error to the specified string at the specified
|
||||||
/// location. This is defined to always return asmtok::Error.
|
/// location. This is defined to always return asmtok::Error.
|
||||||
asmtok::TokKind AsmLexer::ReturnError(const char *Loc, const std::string &Msg) {
|
asmtok::TokKind AsmLexer::ReturnError(const char *Loc, const std::string &Msg) {
|
||||||
PrintError(Loc, Msg);
|
SrcMgr.PrintMessage(SMLoc::getFromPointer(Loc), Msg);
|
||||||
return asmtok::Error;
|
return asmtok::Error;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -203,10 +199,8 @@ asmtok::TokKind AsmLexer::LexQuote() {
|
|||||||
CurChar = getNextChar();
|
CurChar = getNextChar();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (CurChar == EOF) {
|
if (CurChar == EOF)
|
||||||
PrintError(TokStart, "unterminated string constant");
|
return ReturnError(TokStart, "unterminated string constant");
|
||||||
return asmtok::Eof;
|
|
||||||
}
|
|
||||||
|
|
||||||
CurChar = getNextChar();
|
CurChar = getNextChar();
|
||||||
}
|
}
|
||||||
|
@@ -89,8 +89,7 @@ public:
|
|||||||
|
|
||||||
SMLoc getLoc() const;
|
SMLoc getLoc() const;
|
||||||
|
|
||||||
void PrintError(const char *Loc, const std::string &Msg) const;
|
void PrintMessage(SMLoc Loc, const std::string &Msg) const;
|
||||||
void PrintError(SMLoc Loc, const std::string &Msg) const;
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
int getNextChar();
|
int getNextChar();
|
||||||
|
@@ -16,6 +16,17 @@
|
|||||||
#include "llvm/Support/raw_ostream.h"
|
#include "llvm/Support/raw_ostream.h"
|
||||||
using namespace llvm;
|
using namespace llvm;
|
||||||
|
|
||||||
|
bool AsmParser::Error(SMLoc L, const char *Msg) {
|
||||||
|
Lexer.PrintMessage(L, Msg);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool AsmParser::TokError(const char *Msg) {
|
||||||
|
Lexer.PrintMessage(Lexer.getLoc(), Msg);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
bool AsmParser::Run() {
|
bool AsmParser::Run() {
|
||||||
// Prime the lexer.
|
// Prime the lexer.
|
||||||
Lexer.Lex();
|
Lexer.Lex();
|
||||||
@@ -34,8 +45,7 @@ bool AsmParser::Run() {
|
|||||||
bool AsmParser::ParseStatement() {
|
bool AsmParser::ParseStatement() {
|
||||||
switch (Lexer.getKind()) {
|
switch (Lexer.getKind()) {
|
||||||
default:
|
default:
|
||||||
Lexer.PrintError(Lexer.getLoc(), "unexpected token at start of statement");
|
return TokError("unexpected token at start of statement");
|
||||||
return true;
|
|
||||||
case asmtok::EndOfStatement:
|
case asmtok::EndOfStatement:
|
||||||
Lexer.Lex();
|
Lexer.Lex();
|
||||||
return false;
|
return false;
|
||||||
|
@@ -30,6 +30,8 @@ public:
|
|||||||
private:
|
private:
|
||||||
bool ParseStatement();
|
bool ParseStatement();
|
||||||
|
|
||||||
|
bool Error(SMLoc L, const char *Msg);
|
||||||
|
bool TokError(const char *Msg);
|
||||||
};
|
};
|
||||||
|
|
||||||
} // end namespace llvm
|
} // end namespace llvm
|
||||||
|
@@ -77,7 +77,7 @@ static int AsLexInput(const char *ProgName) {
|
|||||||
while (Tok != asmtok::Eof) {
|
while (Tok != asmtok::Eof) {
|
||||||
switch (Tok) {
|
switch (Tok) {
|
||||||
default:
|
default:
|
||||||
Lexer.PrintError(Lexer.getLoc(), "driver: unknown token");
|
Lexer.PrintMessage(Lexer.getLoc(), "driver: unknown token");
|
||||||
Error = true;
|
Error = true;
|
||||||
break;
|
break;
|
||||||
case asmtok::Error:
|
case asmtok::Error:
|
||||||
|
@@ -44,11 +44,11 @@ tgtok::TokKind TGLexer::ReturnError(const char *Loc, const std::string &Msg) {
|
|||||||
|
|
||||||
|
|
||||||
void TGLexer::PrintError(const char *Loc, const std::string &Msg) const {
|
void TGLexer::PrintError(const char *Loc, const std::string &Msg) const {
|
||||||
SrcMgr.PrintError(SMLoc::getFromPointer(Loc), Msg);
|
SrcMgr.PrintMessage(SMLoc::getFromPointer(Loc), Msg);
|
||||||
}
|
}
|
||||||
|
|
||||||
void TGLexer::PrintError(SMLoc Loc, const std::string &Msg) const {
|
void TGLexer::PrintError(SMLoc Loc, const std::string &Msg) const {
|
||||||
SrcMgr.PrintError(Loc, Msg);
|
SrcMgr.PrintMessage(Loc, Msg);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@@ -127,7 +127,7 @@ RecordKeeper llvm::Records;
|
|||||||
static SourceMgr SrcMgr;
|
static SourceMgr SrcMgr;
|
||||||
|
|
||||||
void llvm::PrintError(SMLoc ErrorLoc, const std::string &Msg) {
|
void llvm::PrintError(SMLoc ErrorLoc, const std::string &Msg) {
|
||||||
SrcMgr.PrintError(ErrorLoc, Msg);
|
SrcMgr.PrintMessage(ErrorLoc, Msg);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user