IR: Drop newline from AssemblyWriter::printMDNodeBody()
authorDuncan P. N. Exon Smith <dexonsmith@apple.com>
Wed, 25 Feb 2015 22:46:38 +0000 (22:46 +0000)
committerDuncan P. N. Exon Smith <dexonsmith@apple.com>
Wed, 25 Feb 2015 22:46:38 +0000 (22:46 +0000)
Remove a newline from `AssemblyWriter::printMDNodeBody()`, and add one
to `AssemblyWriter::writeMDNode()`.  NFCI for assembly output.

However, this drops an inconsistent newline from `Metadata::print()`
when `this` is an `MDNode`.  Now the newline added by `Metadata::dump()`
won't look so verbose.

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

lib/IR/AsmWriter.cpp
unittests/IR/MetadataTest.cpp

index dccbfe47dd2a35e3d90385a5220d037baeadcf8c..de0e614c876004ce3b8a2448f07bd3b72459d1c8 100644 (file)
@@ -3000,6 +3000,7 @@ static void WriteMDNodeComment(const MDNode *Node,
 void AssemblyWriter::writeMDNode(unsigned Slot, const MDNode *Node) {
   Out << '!' << Slot << " = ";
   printMDNodeBody(Node);
+  Out << "\n";
 }
 
 void AssemblyWriter::writeAllMDNodes() {
@@ -3017,7 +3018,6 @@ void AssemblyWriter::writeAllMDNodes() {
 void AssemblyWriter::printMDNodeBody(const MDNode *Node) {
   WriteMDNodeBodyInternal(Out, Node, &TypePrinter, &Machine, TheModule);
   WriteMDNodeComment(Node, Out);
-  Out << "\n";
 }
 
 void AssemblyWriter::writeAllAttributeGroups() {
index 849616b6af3e72c78d00269211ad0f01eef85b9b..6f2372d58cb81ff262736ce905d6304fbf1ec798 100644 (file)
@@ -228,7 +228,7 @@ TEST_F(MDNodeTest, Print) {
     MDNode *Nodes[] = {N0, N1, N2};
     for (auto *Node : Nodes)
       OS << ", <" << (void *)Node << ">";
-    OS << "}\n";
+    OS << "}";
   }
 
   std::string Actual;