From bf2013ee22e7684ed37e4b78fca6937f38247ae7 Mon Sep 17 00:00:00 2001 From: Sean Callanan Date: Wed, 20 Jan 2010 23:19:55 +0000 Subject: 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 --- tools/llvm-mc/AsmParser.cpp | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) (limited to 'tools/llvm-mc/AsmParser.cpp') diff --git a/tools/llvm-mc/AsmParser.cpp b/tools/llvm-mc/AsmParser.cpp index 2cbf74916c..0e0c1a4de7 100644 --- a/tools/llvm-mc/AsmParser.cpp +++ b/tools/llvm-mc/AsmParser.cpp @@ -87,24 +87,29 @@ const MCSection *AsmParser::getMachOSection(const StringRef &Segment, } 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) { - Lexer.PrintMessage(L, Msg.str(), "error"); + PrintMessage(L, Msg.str(), "error"); return true; } bool AsmParser::TokError(const char *Msg) { - Lexer.PrintMessage(Lexer.getLoc(), Msg, "error"); + PrintMessage(Lexer.getLoc(), Msg, "error"); 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 &tok = Lexer.Lex(); if (tok.is(AsmToken::Error)) - Lexer.PrintMessage(Lexer.getErrLoc(), Lexer.getErr(), "error"); + PrintMessage(Lexer.getErrLoc(), Lexer.getErr(), "error"); return tok; } @@ -1518,9 +1523,9 @@ bool AsmParser::ParseDirectiveInclude() { // Attempt to switch the lexer to the included file before consuming the end // of statement to avoid losing it when we switch. if (Lexer.EnterIncludeFile(Filename)) { - Lexer.PrintMessage(IncludeLoc, - "Could not find include file '" + Filename + "'", - "error"); + PrintMessage(IncludeLoc, + "Could not find include file '" + Filename + "'", + "error"); return true; } -- cgit v1.2.3-18-g5258