[llvm-commits] [llvm] r170037 - /llvm/trunk/lib/MC/MCParser/AsmParser.cpp

Chad Rosier mcrosier at apple.com
Wed Dec 12 14:45:53 PST 2012


Author: mcrosier
Date: Wed Dec 12 16:45:52 2012
New Revision: 170037

URL: http://llvm.org/viewvc/llvm-project?rev=170037&view=rev
Log:
[ms-inline asm] Make sure we fail gracefully on parse errors.  Parse errors
should only occur on invalid input.  Instruction matching errors aren't
unexpected, so we can't rely on the AsmParsers HadError variable directly.
rdar://12840278

Modified:
    llvm/trunk/lib/MC/MCParser/AsmParser.cpp

Modified: llvm/trunk/lib/MC/MCParser/AsmParser.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/MC/MCParser/AsmParser.cpp?rev=170037&r1=170036&r2=170037&view=diff
==============================================================================
--- llvm/trunk/lib/MC/MCParser/AsmParser.cpp (original)
+++ llvm/trunk/lib/MC/MCParser/AsmParser.cpp Wed Dec 12 16:45:52 2012
@@ -97,11 +97,14 @@
   /// Opcode - The opcode from the last parsed instruction.
   unsigned Opcode;
 
+  /// Error - Was there an error parsing the inline assembly?
+  bool ParseError;
+
   SmallVectorImpl<AsmRewrite> *AsmRewrites;
 
-  ParseStatementInfo() : Opcode(~0U), AsmRewrites(0) {}
+  ParseStatementInfo() : Opcode(~0U), ParseError(false), AsmRewrites(0) {}
   ParseStatementInfo(SmallVectorImpl<AsmRewrite> *rewrites)
-    : Opcode(~0), AsmRewrites(rewrites) {}
+    : Opcode(~0), ParseError(false), AsmRewrites(rewrites) {}
 
   ~ParseStatementInfo() {
     // Free any parsed operands.
@@ -1385,6 +1388,7 @@
   ParseInstructionInfo IInfo(Info.AsmRewrites);
   bool HadError = getTargetParser().ParseInstruction(IInfo, OpcodeStr.str(),
                                                      IDLoc,Info.ParsedOperands);
+  Info.ParseError = HadError;
 
   // Dump the parsed representation, if requested.
   if (getShowParsedOperands()) {
@@ -3705,6 +3709,9 @@
     if (ParseStatement(Info))
       return true;
 
+    if (Info.ParseError)
+      return true;
+
     if (Info.Opcode != ~0U) {
       const MCInstrDesc &Desc = MII->get(Info.Opcode);
 





More information about the llvm-commits mailing list