From 3be414736a67463ede1ff7f86e145897d79856fa Mon Sep 17 00:00:00 2001 From: "Duncan P. N. Exon Smith" Date: Fri, 24 Apr 2015 21:06:21 +0000 Subject: [PATCH] AsmWriter: Parameterize the syntactic separator for attachments Parameterize the separator for attachments, since `Function` metadata attachments (PR23340) aren't going to use a `,` (comma). No real functionality change. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@235775 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/IR/AsmWriter.cpp | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/lib/IR/AsmWriter.cpp b/lib/IR/AsmWriter.cpp index 54a370d08fb..299665531f3 100644 --- a/lib/IR/AsmWriter.cpp +++ b/lib/IR/AsmWriter.cpp @@ -1990,7 +1990,8 @@ private: /// \brief Print out metadata attachments. void printMetadataAttachments( - const SmallVectorImpl> &MDs); + const SmallVectorImpl> &MDs, + StringRef Separator); // printInfoComment - Print a little comment after the instruction indicating // which slot it occupies. @@ -2957,14 +2958,15 @@ void AssemblyWriter::printInstruction(const Instruction &I) { // Print Metadata info. SmallVector, 4> InstMD; I.getAllMetadata(InstMD); - printMetadataAttachments(InstMD); + printMetadataAttachments(InstMD, ", "); // Print a nice comment. printInfoComment(I); } void AssemblyWriter::printMetadataAttachments( - const SmallVectorImpl> &MDs) { + const SmallVectorImpl> &MDs, + StringRef Separator) { if (MDs.empty()) return; @@ -2973,11 +2975,11 @@ void AssemblyWriter::printMetadataAttachments( for (const auto &I : MDs) { unsigned Kind = I.first; - if (Kind < MDNames.size()) { - Out << ", !" << MDNames[Kind]; - } else { - Out << ", !"; - } + Out << Separator; + if (Kind < MDNames.size()) + Out << "!" << MDNames[Kind]; + else + Out << "!"; Out << ' '; WriteAsOperandInternal(Out, I.second, &TypePrinter, &Machine, TheModule); }