[llvm-commits] [llvm] r113551 - in /llvm/trunk: lib/MC/MCParser/AsmParser.cpp test/MC/AsmParser/directive_abort.s

Daniel Dunbar daniel at zuster.org
Thu Sep 9 15:42:56 PDT 2010


Author: ddunbar
Date: Thu Sep  9 17:42:56 2010
New Revision: 113551

URL: http://llvm.org/viewvc/llvm-project?rev=113551&view=rev
Log:
llvm-mc: Make sure we exit != 0 if any errors are encountered.

Modified:
    llvm/trunk/lib/MC/MCParser/AsmParser.cpp
    llvm/trunk/test/MC/AsmParser/directive_abort.s

Modified: llvm/trunk/lib/MC/MCParser/AsmParser.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/MC/MCParser/AsmParser.cpp?rev=113551&r1=113550&r2=113551&view=diff
==============================================================================
--- llvm/trunk/lib/MC/MCParser/AsmParser.cpp (original)
+++ llvm/trunk/lib/MC/MCParser/AsmParser.cpp Thu Sep  9 17:42:56 2010
@@ -102,6 +102,9 @@
   /// Boolean tracking whether macro substitution is enabled.
   unsigned MacrosEnabled : 1;
 
+  /// Flag tracking whether any errors have been encountered.
+  unsigned HadError : 1;
+
 public:
   AsmParser(const Target &T, SourceMgr &SM, MCContext &Ctx, MCStreamer &Out,
             const MCAsmInfo &MAI);
@@ -304,6 +307,7 @@
 }
 
 bool AsmParser::Error(SMLoc L, const Twine &Msg) {
+  HadError = true;
   PrintMessage(L, Msg.str(), "error");
   PrintMacroInstantiations();
   return true;
@@ -361,17 +365,17 @@
 
   // Prime the lexer.
   Lex();
-  
-  bool HadError = false;
-  
+
+  HadError = false;
   AsmCond StartingCondState = TheCondState;
 
   // While we have input, parse each statement.
   while (Lexer.isNot(AsmToken::Eof)) {
     if (!ParseStatement()) continue;
   
-    // We had an error, remember it and recover by skipping to the next line.
-    HadError = true;
+    // We had an error, validate that one was emitted and recover by skipping to
+    // the next line.
+    assert(HadError && "Parse statement returned an error, but none emitted!");
     EatToEndOfStatement();
   }
 
@@ -383,10 +387,8 @@
   const std::vector<MCDwarfFile *> &MCDwarfFiles =
     getContext().getMCDwarfFiles();
   for (unsigned i = 1; i < MCDwarfFiles.size(); i++) {
-    if (!MCDwarfFiles[i]){
+    if (!MCDwarfFiles[i])
       TokError("unassigned file number: " + Twine(i) + " for .file directives");
-      HadError = true;
-    }
   }
   
   // Finalize the output stream if there are no errors and if the client wants

Modified: llvm/trunk/test/MC/AsmParser/directive_abort.s
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/MC/AsmParser/directive_abort.s?rev=113551&r1=113550&r2=113551&view=diff
==============================================================================
--- llvm/trunk/test/MC/AsmParser/directive_abort.s (original)
+++ llvm/trunk/test/MC/AsmParser/directive_abort.s Thu Sep  9 17:42:56 2010
@@ -1,4 +1,4 @@
-# RUN: llvm-mc -triple i386-unknown-unknown %s 2> %t
+# RUN: not llvm-mc -triple i386-unknown-unknown %s 2> %t
 # RUN: FileCheck -input-file %t %s
 
 # CHECK: error: .abort 'please stop assembing'





More information about the llvm-commits mailing list