summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2009-07-02 21:53:43 +0000
committerChris Lattner <sabre@nondot.org>2009-07-02 21:53:43 +0000
commitb717fb0fe0d41629ae07800869157b6d178c545f (patch)
treeb96dd7850baa1da1aee6f279cfd33152a5a94dc0
parenta8185fe50bdc2de23c00c2ada1a632e17adcf6c5 (diff)
downloadexternal_llvm-b717fb0fe0d41629ae07800869157b6d178c545f.zip
external_llvm-b717fb0fe0d41629ae07800869157b6d178c545f.tar.gz
external_llvm-b717fb0fe0d41629ae07800869157b6d178c545f.tar.bz2
implement error recovery in the llvm-mc parser. Feel the power!
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@74728 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r--tools/llvm-mc/AsmParser.cpp15
1 files changed, 11 insertions, 4 deletions
diff --git a/tools/llvm-mc/AsmParser.cpp b/tools/llvm-mc/AsmParser.cpp
index 339a16d..f5bf589 100644
--- a/tools/llvm-mc/AsmParser.cpp
+++ b/tools/llvm-mc/AsmParser.cpp
@@ -40,11 +40,18 @@ bool AsmParser::Run() {
// Prime the lexer.
Lexer.Lex();
- while (Lexer.isNot(asmtok::Eof))
- if (ParseStatement())
- return true;
+ bool HadError = false;
- return false;
+ // While we have input, parse each statement.
+ while (Lexer.isNot(asmtok::Eof)) {
+ if (!ParseStatement()) continue;
+
+ // If we had an error, remember it and recover by skipping to the next line.
+ HadError = true;
+ EatToEndOfStatement();
+ }
+
+ return HadError;
}
/// EatToEndOfStatement - Throw away the rest of the line for testing purposes.