change the MC "ParseInstruction" interface to make it the
authorChris Lattner <sabre@nondot.org>
Wed, 8 Sep 2010 05:10:46 +0000 (05:10 +0000)
committerChris Lattner <sabre@nondot.org>
Wed, 8 Sep 2010 05:10:46 +0000 (05:10 +0000)
implementation's job to check for and lex the EndOfStatement
marker.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@113347 91177308-0d34-0410-b5e6-96231b3b80d8

lib/MC/MCParser/AsmParser.cpp
lib/Target/ARM/AsmParser/ARMAsmParser.cpp
lib/Target/X86/AsmParser/X86AsmParser.cpp

index f83cd5eb2a16015b6135f70b46575841e2b442ce..310574fe27be5acd3b4e322b2476c61e04f34904 100644 (file)
@@ -917,8 +917,6 @@ bool AsmParser::ParseStatement() {
   SmallVector<MCParsedAsmOperand*, 8> ParsedOperands;
   bool HadError = getTargetParser().ParseInstruction(Opcode.str(), IDLoc,
                                                      ParsedOperands);
-  if (!HadError && Lexer.isNot(AsmToken::EndOfStatement))
-    HadError = TokError("unexpected token in argument list");
 
   // Dump the parsed representation, if requested.
   if (getShowParsedOperands()) {
@@ -945,11 +943,6 @@ bool AsmParser::ParseStatement() {
       HadError = true;
   }
 
-  // If there was no error, consume the end-of-statement token. Otherwise this
-  // will be done by our caller.
-  if (!HadError)
-    Lex();
-
   // Free any parsed operands.
   for (unsigned i = 0, e = ParsedOperands.size(); i != e; ++i)
     delete ParsedOperands[i];
index f2099d29386924c68110b77006fa44c6f3137414..f44470b2c1b514bc5002c7a6efb8a635f5d9e7c1 100644 (file)
@@ -737,6 +737,11 @@ bool ARMAsmParser::ParseInstruction(StringRef Name, SMLoc NameLoc,
       Operands.push_back(Op.take());
     }
   }
+  
+  if (getLexer().isNot(AsmToken::EndOfStatement))
+    return TokError("unexpected token in argument list");
+  Parser.Lex(); // Consume the EndOfStatement
+  
   return false;
 }
 
index 58e4554ab03919daecdb0a4ab8325fa92221b260..068ed56e951082f166ba825671a6c6343d64ef6a 100644 (file)
@@ -786,6 +786,10 @@ ParseInstruction(StringRef Name, SMLoc NameLoc,
         return true;
     }
   }
+  
+  if (getLexer().isNot(AsmToken::EndOfStatement))
+    return TokError("unexpected token in argument list");
+  Parser.Lex(); // Consume the EndOfStatement
 
   // FIXME: Hack to handle recognizing s{hr,ar,hl}? $1.
   if ((Name.startswith("shr") || Name.startswith("sar") ||