rename ParseOptionalCustomMetadata -> ParseInstructionMetadata,
authorChris Lattner <sabre@nondot.org>
Wed, 30 Dec 2009 05:31:19 +0000 (05:31 +0000)
committerChris Lattner <sabre@nondot.org>
Wed, 30 Dec 2009 05:31:19 +0000 (05:31 +0000)
and make it non-optional.  This fixes the bug where we'd accept
and ignore a spurious comma after some instructions.

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

lib/AsmParser/LLParser.cpp
lib/AsmParser/LLParser.h

index f33e76f64deec915bd8711c4dc993fcc859586b9..1fd750e1dc2ccb8f50e697ad23cfd2415c346257 100644 (file)
@@ -1063,14 +1063,13 @@ bool LLParser::ParseOptionalCallingConv(CallingConv::ID &CC) {
   return false;
 }
 
-/// ParseOptionalCustomMetadata
-///   ::= /* empty */
+/// ParseInstructionMetadata
 ///   ::= !dbg !42 (',' !dbg !57)*
-bool LLParser::ParseOptionalCustomMetadata() {
-  if (Lex.getKind() != lltok::MetadataVar)
-    return false;
+bool LLParser::ParseInstructionMetadata() {
+  do {
+    if (Lex.getKind() != lltok::MetadataVar)
+      return TokError("expected metadata after comma");
 
-  while (1) {
     std::string Name = Lex.getStrVal();
     Lex.Lex();
 
@@ -1083,13 +1082,8 @@ bool LLParser::ParseOptionalCustomMetadata() {
     MDsOnInst.push_back(std::make_pair(MDK, Node));
 
     // If this is the end of the list, we're done.
-    if (!EatIfPresent(lltok::comma))
-      return false;
-
-    // The next value must be a custom metadata id.
-    if (Lex.getKind() != lltok::MetadataVar)
-      return TokError("expected more custom metadata ids");
-  }
+  } while (EatIfPresent(lltok::comma));
+  return false;
 }
 
 /// ParseOptionalAlignment
@@ -1113,7 +1107,7 @@ bool LLParser::ParseOptionalInfo(unsigned &Alignment) {
   // FIXME: Handle customized metadata info attached with an instruction.
   do {
     if (Lex.getKind() == lltok::MetadataVar) {
-      if (ParseOptionalCustomMetadata()) return true;
+      if (ParseInstructionMetadata()) return true;
     } else if (Lex.getKind() == lltok::kw_align) {
       if (ParseOptionalAlignment(Alignment)) return true;
     } else
@@ -2820,16 +2814,13 @@ bool LLParser::ParseBasicBlock(PerFunctionState &PFS) {
       // With a normal result, we check to see if the instruction is followed by
       // a comma and metadata.
       if (EatIfPresent(lltok::comma))
-        if (ParseOptionalCustomMetadata())
+        if (ParseInstructionMetadata())
           return true;
       break;
     case InstExtraComma:
       // If the instruction parser ate an extra comma at the end of it, it
       // *must* be followed by metadata.
-      if (Lex.getKind() != lltok::MetadataVar)
-        return TokError("expected metadata after comma");
-      // Parse it.
-      if (ParseOptionalCustomMetadata())
+      if (ParseInstructionMetadata())
         return true;
       break;        
     }
index a74974b1a6589390886add5fd20df44fa3c22d0f..8fd04d0bcc25e2d707c5bd9c6ca09d1426147a60 100644 (file)
@@ -171,7 +171,7 @@ namespace llvm {
     bool ParseOptionalVisibility(unsigned &Visibility);
     bool ParseOptionalCallingConv(CallingConv::ID &CC);
     bool ParseOptionalAlignment(unsigned &Alignment);
-    bool ParseOptionalCustomMetadata();
+    bool ParseInstructionMetadata();
     bool ParseOptionalInfo(unsigned &Alignment);
     bool ParseIndexList(SmallVectorImpl<unsigned> &Indices,bool &AteExtraComma);
     bool ParseIndexList(SmallVectorImpl<unsigned> &Indices) {