aboutsummaryrefslogtreecommitdiffstats
path: root/tools
diff options
context:
space:
mode:
authorSean Callanan <scallanan@apple.com>2010-01-20 22:18:24 +0000
committerSean Callanan <scallanan@apple.com>2010-01-20 22:18:24 +0000
commit79036e421f22cf3f661386c560fda36aa5bd04cc (patch)
treeff3a1622a4c66e298447680207f7b5a0a0a64085 /tools
parent73a1aa0966af7605b5a15585b1b88ffc7dbd3e3e (diff)
downloadexternal_llvm-79036e421f22cf3f661386c560fda36aa5bd04cc.zip
external_llvm-79036e421f22cf3f661386c560fda36aa5bd04cc.tar.gz
external_llvm-79036e421f22cf3f661386c560fda36aa5bd04cc.tar.bz2
Modified MCAsmLexer to return error information upward
rather than printing it locally, reducing its dependence on SourceMgr. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@94041 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'tools')
-rw-r--r--tools/llvm-mc/AsmLexer.cpp3
-rw-r--r--tools/llvm-mc/AsmParser.cpp7
2 files changed, 8 insertions, 2 deletions
diff --git a/tools/llvm-mc/AsmLexer.cpp b/tools/llvm-mc/AsmLexer.cpp
index ba0d247..758fac4 100644
--- a/tools/llvm-mc/AsmLexer.cpp
+++ b/tools/llvm-mc/AsmLexer.cpp
@@ -44,7 +44,8 @@ void AsmLexer::PrintMessage(SMLoc Loc, const std::string &Msg,
/// 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) {
- PrintMessage(SMLoc::getFromPointer(Loc), Msg, "error");
+ SetError(SMLoc::getFromPointer(Loc), Msg);
+
return AsmToken(AsmToken::Error, StringRef(Loc, 0));
}
diff --git a/tools/llvm-mc/AsmParser.cpp b/tools/llvm-mc/AsmParser.cpp
index ab37eb8..eb77e8d 100644
--- a/tools/llvm-mc/AsmParser.cpp
+++ b/tools/llvm-mc/AsmParser.cpp
@@ -101,7 +101,12 @@ bool AsmParser::TokError(const char *Msg) {
}
const AsmToken &AsmParser::Lex() {
- return Lexer.Lex();
+ const AsmToken &tok = Lexer.Lex();
+
+ if (tok.is(AsmToken::Error))
+ Lexer.PrintMessage(Lexer.getErrLoc(), Lexer.getErr(), "error");
+
+ return tok;
}
bool AsmParser::Run() {