mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-06-22 10:24:26 +00:00
Changed the AsmParser to handle error messages itself
rather than passing them off to the AsmLexer to handle. This means the AsmLexer no longer requires a SourceMgr to do error handling. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@94047 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@ -36,11 +36,6 @@ SMLoc AsmLexer::getLoc() const {
|
|||||||
return SMLoc::getFromPointer(TokStart);
|
return SMLoc::getFromPointer(TokStart);
|
||||||
}
|
}
|
||||||
|
|
||||||
void AsmLexer::PrintMessage(SMLoc Loc, const std::string &Msg,
|
|
||||||
const char *Type) const {
|
|
||||||
SrcMgr.PrintMessage(Loc, Msg, Type);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// 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 AsmToken::Error.
|
/// location. This is defined to always return AsmToken::Error.
|
||||||
AsmToken AsmLexer::ReturnError(const char *Loc, const std::string &Msg) {
|
AsmToken AsmLexer::ReturnError(const char *Loc, const std::string &Msg) {
|
||||||
|
@ -61,8 +61,6 @@ public:
|
|||||||
/// EnterIncludeFile - Enter the specified file. This returns true on failure.
|
/// EnterIncludeFile - Enter the specified file. This returns true on failure.
|
||||||
bool EnterIncludeFile(const std::string &Filename);
|
bool EnterIncludeFile(const std::string &Filename);
|
||||||
|
|
||||||
void PrintMessage(SMLoc Loc, const std::string &Msg, const char *Type) const;
|
|
||||||
|
|
||||||
const MCAsmInfo &getMAI() const { return MAI; }
|
const MCAsmInfo &getMAI() const { return MAI; }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
@ -87,24 +87,29 @@ const MCSection *AsmParser::getMachOSection(const StringRef &Segment,
|
|||||||
}
|
}
|
||||||
|
|
||||||
void AsmParser::Warning(SMLoc L, const Twine &Msg) {
|
void AsmParser::Warning(SMLoc L, const Twine &Msg) {
|
||||||
Lexer.PrintMessage(L, Msg.str(), "warning");
|
PrintMessage(L, Msg.str(), "warning");
|
||||||
}
|
}
|
||||||
|
|
||||||
bool AsmParser::Error(SMLoc L, const Twine &Msg) {
|
bool AsmParser::Error(SMLoc L, const Twine &Msg) {
|
||||||
Lexer.PrintMessage(L, Msg.str(), "error");
|
PrintMessage(L, Msg.str(), "error");
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool AsmParser::TokError(const char *Msg) {
|
bool AsmParser::TokError(const char *Msg) {
|
||||||
Lexer.PrintMessage(Lexer.getLoc(), Msg, "error");
|
PrintMessage(Lexer.getLoc(), Msg, "error");
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void AsmParser::PrintMessage(SMLoc Loc, const std::string &Msg,
|
||||||
|
const char *Type) const {
|
||||||
|
SrcMgr.PrintMessage(Loc, Msg, Type);
|
||||||
|
}
|
||||||
|
|
||||||
const AsmToken &AsmParser::Lex() {
|
const AsmToken &AsmParser::Lex() {
|
||||||
const AsmToken &tok = Lexer.Lex();
|
const AsmToken &tok = Lexer.Lex();
|
||||||
|
|
||||||
if (tok.is(AsmToken::Error))
|
if (tok.is(AsmToken::Error))
|
||||||
Lexer.PrintMessage(Lexer.getErrLoc(), Lexer.getErr(), "error");
|
PrintMessage(Lexer.getErrLoc(), Lexer.getErr(), "error");
|
||||||
|
|
||||||
return tok;
|
return tok;
|
||||||
}
|
}
|
||||||
@ -1518,7 +1523,7 @@ bool AsmParser::ParseDirectiveInclude() {
|
|||||||
// Attempt to switch the lexer to the included file before consuming the end
|
// Attempt to switch the lexer to the included file before consuming the end
|
||||||
// of statement to avoid losing it when we switch.
|
// of statement to avoid losing it when we switch.
|
||||||
if (Lexer.EnterIncludeFile(Filename)) {
|
if (Lexer.EnterIncludeFile(Filename)) {
|
||||||
Lexer.PrintMessage(IncludeLoc,
|
PrintMessage(IncludeLoc,
|
||||||
"Could not find include file '" + Filename + "'",
|
"Could not find include file '" + Filename + "'",
|
||||||
"error");
|
"error");
|
||||||
return true;
|
return true;
|
||||||
|
@ -105,6 +105,8 @@ private:
|
|||||||
|
|
||||||
bool TokError(const char *Msg);
|
bool TokError(const char *Msg);
|
||||||
|
|
||||||
|
void PrintMessage(SMLoc Loc, const std::string &Msg, const char *Type) const;
|
||||||
|
|
||||||
bool ParseConditionalAssemblyDirectives(StringRef Directive,
|
bool ParseConditionalAssemblyDirectives(StringRef Directive,
|
||||||
SMLoc DirectiveLoc);
|
SMLoc DirectiveLoc);
|
||||||
void EatToEndOfStatement();
|
void EatToEndOfStatement();
|
||||||
|
@ -141,7 +141,7 @@ static int AsLexInput(const char *ProgName) {
|
|||||||
while (Lexer.Lex().isNot(AsmToken::Eof)) {
|
while (Lexer.Lex().isNot(AsmToken::Eof)) {
|
||||||
switch (Lexer.getKind()) {
|
switch (Lexer.getKind()) {
|
||||||
default:
|
default:
|
||||||
Lexer.PrintMessage(Lexer.getLoc(), "unknown token", "warning");
|
SrcMgr.PrintMessage(Lexer.getLoc(), "unknown token", "warning");
|
||||||
Error = true;
|
Error = true;
|
||||||
break;
|
break;
|
||||||
case AsmToken::Error:
|
case AsmToken::Error:
|
||||||
|
Reference in New Issue
Block a user