Add support for empty named metadata too. This isn't particularly
authorDan Gohman <gohman@apple.com>
Tue, 13 Jul 2010 19:42:44 +0000 (19:42 +0000)
committerDan Gohman <gohman@apple.com>
Tue, 13 Jul 2010 19:42:44 +0000 (19:42 +0000)
useful, but it is nice for consistency.

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

lib/AsmParser/LLParser.cpp
test/Feature/metadata.ll

index 8c4d7348eb1bf3c0fedc7640f36c8096351c358c..3948071c420546c52ce1d688a3eb78493d330307 100644 (file)
@@ -544,20 +544,21 @@ bool LLParser::ParseNamedMetadata() {
     return true;
 
   SmallVector<MDNode *, 8> Elts;
-  do {
-    // Null is a special case since it is typeless.
-    if (EatIfPresent(lltok::kw_null)) {
-      Elts.push_back(0);
-      continue;
-    }
+  if (Lex.getKind() != lltok::rbrace)
+    do {
+      // Null is a special case since it is typeless.
+      if (EatIfPresent(lltok::kw_null)) {
+        Elts.push_back(0);
+        continue;
+      }
 
-    if (ParseToken(lltok::exclaim, "Expected '!' here"))
-      return true;
+      if (ParseToken(lltok::exclaim, "Expected '!' here"))
+        return true;
     
-    MDNode *N = 0;
-    if (ParseMDNodeID(N)) return true;
-    Elts.push_back(N);
-  } while (EatIfPresent(lltok::comma));
+      MDNode *N = 0;
+      if (ParseMDNodeID(N)) return true;
+      Elts.push_back(N);
+    } while (EatIfPresent(lltok::comma));
 
   if (ParseToken(lltok::rbrace, "expected end of metadata node"))
     return true;
index b34c947df4d1fc4aadce53678a6b23ffc847685f..d43815be46aa512de588d003d9c1d90a83f1797d 100644 (file)
@@ -9,6 +9,7 @@ define void @foo() {
 declare void @llvm.zonk(metadata, i64, metadata) nounwind readnone
 
 !named = !{!0}
+!another_named = !{}
 !0 = metadata !{i8** null}
 !1 = metadata !{i8* null, metadata !2}
 !2 = metadata !{}