- MetadataContext &TheMetadata = M->getContext().getMetadata();
- unsigned MDK = TheMetadata.getMDKindID(Name.c_str());
- MDsOnInst.push_back(std::make_pair(MDK, cast<MDNode>(Node)));
- return false;
+ unsigned MDK = M->getMDKindID(Name.c_str());
+ 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::NamedOrCustomMD)
+ return TokError("expected more custom metadata ids");
+ }