[llvm] r235775 - AsmWriter: Parameterize the syntactic separator for attachments

Duncan P. N. Exon Smith dexonsmith at apple.com
Fri Apr 24 14:06:21 PDT 2015


Author: dexonsmith
Date: Fri Apr 24 16:06:21 2015
New Revision: 235775

URL: http://llvm.org/viewvc/llvm-project?rev=235775&view=rev
Log:
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.

Modified:
    llvm/trunk/lib/IR/AsmWriter.cpp

Modified: llvm/trunk/lib/IR/AsmWriter.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/IR/AsmWriter.cpp?rev=235775&r1=235774&r2=235775&view=diff
==============================================================================
--- llvm/trunk/lib/IR/AsmWriter.cpp (original)
+++ llvm/trunk/lib/IR/AsmWriter.cpp Fri Apr 24 16:06:21 2015
@@ -1990,7 +1990,8 @@ private:
 
   /// \brief Print out metadata attachments.
   void printMetadataAttachments(
-      const SmallVectorImpl<std::pair<unsigned, MDNode *>> &MDs);
+      const SmallVectorImpl<std::pair<unsigned, MDNode *>> &MDs,
+      StringRef Separator);
 
   // printInfoComment - Print a little comment after the instruction indicating
   // which slot it occupies.
@@ -2957,14 +2958,15 @@ void AssemblyWriter::printInstruction(co
   // Print Metadata info.
   SmallVector<std::pair<unsigned, MDNode *>, 4> InstMD;
   I.getAllMetadata(InstMD);
-  printMetadataAttachments(InstMD);
+  printMetadataAttachments(InstMD, ", ");
 
   // Print a nice comment.
   printInfoComment(I);
 }
 
 void AssemblyWriter::printMetadataAttachments(
-    const SmallVectorImpl<std::pair<unsigned, MDNode *>> &MDs) {
+    const SmallVectorImpl<std::pair<unsigned, MDNode *>> &MDs,
+    StringRef Separator) {
   if (MDs.empty())
     return;
 
@@ -2973,11 +2975,11 @@ void AssemblyWriter::printMetadataAttach
 
   for (const auto &I : MDs) {
     unsigned Kind = I.first;
-    if (Kind < MDNames.size()) {
-      Out << ", !" << MDNames[Kind];
-    } else {
-      Out << ", !<unknown kind #" << Kind << ">";
-    }
+    Out << Separator;
+    if (Kind < MDNames.size())
+      Out << "!" << MDNames[Kind];
+    else
+      Out << "!<unknown kind #" << Kind << ">";
     Out << ' ';
     WriteAsOperandInternal(Out, I.second, &TypePrinter, &Machine, TheModule);
   }





More information about the llvm-commits mailing list