aboutsummaryrefslogtreecommitdiffstats
path: root/tools
diff options
context:
space:
mode:
authorSean Callanan <scallanan@apple.com>2010-01-20 23:19:55 +0000
committerSean Callanan <scallanan@apple.com>2010-01-20 23:19:55 +0000
commitbf2013ee22e7684ed37e4b78fca6937f38247ae7 (patch)
tree1c5f9f5eba4c6431b3f6051d464e34c98a37d241 /tools
parent8d77cc8c5f47f2dbab867441251f5df796b78a6e (diff)
downloadexternal_llvm-bf2013ee22e7684ed37e4b78fca6937f38247ae7.zip
external_llvm-bf2013ee22e7684ed37e4b78fca6937f38247ae7.tar.gz
external_llvm-bf2013ee22e7684ed37e4b78fca6937f38247ae7.tar.bz2
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
Diffstat (limited to 'tools')
-rw-r--r--tools/llvm-mc/AsmLexer.cpp5
-rw-r--r--tools/llvm-mc/AsmLexer.h2
-rw-r--r--tools/llvm-mc/AsmParser.cpp19
-rw-r--r--tools/llvm-mc/AsmParser.h2
-rw-r--r--tools/llvm-mc/llvm-mc.cpp2
5 files changed, 15 insertions, 15 deletions
diff --git a/tools/llvm-mc/AsmLexer.cpp b/tools/llvm-mc/AsmLexer.cpp
index 758fac4..19f5247 100644
--- a/tools/llvm-mc/AsmLexer.cpp
+++ b/tools/llvm-mc/AsmLexer.cpp
@@ -36,11 +36,6 @@ SMLoc AsmLexer::getLoc() const {
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
/// location. This is defined to always return AsmToken::Error.
AsmToken AsmLexer::ReturnError(const char *Loc, const std::string &Msg) {
diff --git a/tools/llvm-mc/AsmLexer.h b/tools/llvm-mc/AsmLexer.h
index c0b3223..cc40d35 100644
--- a/tools/llvm-mc/AsmLexer.h
+++ b/tools/llvm-mc/AsmLexer.h
@@ -61,8 +61,6 @@ public:
/// EnterIncludeFile - Enter the specified file. This returns true on failure.
bool EnterIncludeFile(const std::string &Filename);
- void PrintMessage(SMLoc Loc, const std::string &Msg, const char *Type) const;
-
const MCAsmInfo &getMAI() const { return MAI; }
private:
diff --git a/tools/llvm-mc/AsmParser.cpp b/tools/llvm-mc/AsmParser.cpp
index 2cbf749..0e0c1a4 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;
}
diff --git a/tools/llvm-mc/AsmParser.h b/tools/llvm-mc/AsmParser.h
index af43f45..21792eb 100644
--- a/tools/llvm-mc/AsmParser.h
+++ b/tools/llvm-mc/AsmParser.h
@@ -105,6 +105,8 @@ private:
bool TokError(const char *Msg);
+ void PrintMessage(SMLoc Loc, const std::string &Msg, const char *Type) const;
+
bool ParseConditionalAssemblyDirectives(StringRef Directive,
SMLoc DirectiveLoc);
void EatToEndOfStatement();
diff --git a/tools/llvm-mc/llvm-mc.cpp b/tools/llvm-mc/llvm-mc.cpp
index c9d08ec..c84c684 100644
--- a/tools/llvm-mc/llvm-mc.cpp
+++ b/tools/llvm-mc/llvm-mc.cpp
@@ -141,7 +141,7 @@ static int AsLexInput(const char *ProgName) {
while (Lexer.Lex().isNot(AsmToken::Eof)) {
switch (Lexer.getKind()) {
default:
- Lexer.PrintMessage(Lexer.getLoc(), "unknown token", "warning");
+ SrcMgr.PrintMessage(Lexer.getLoc(), "unknown token", "warning");
Error = true;
break;
case AsmToken::Error: