AsmWriter: Extract writeMetadataAsOperand(), NFC
authorDuncan P. N. Exon Smith <dexonsmith@apple.com>
Fri, 6 Feb 2015 22:27:22 +0000 (22:27 +0000)
committerDuncan P. N. Exon Smith <dexonsmith@apple.com>
Fri, 6 Feb 2015 22:27:22 +0000 (22:27 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@228446 91177308-0d34-0410-b5e6-96231b3b80d8

lib/IR/AsmWriter.cpp

index 46f26c579acb479a6476f666115597c38f5912f2..8b7ed55fe71f878a7c2c0498e6c44e07fc30fbdd 100644 (file)
@@ -1286,6 +1286,17 @@ raw_ostream &operator<<(raw_ostream &OS, FieldSeparator &FS) {
 }
 } // end namespace
 
+static void writeMetadataAsOperand(raw_ostream &Out, const Metadata *MD,
+                                   TypePrinting *TypePrinter,
+                                   SlotTracker *Machine,
+                                   const Module *Context) {
+  if (!MD) {
+    Out << "null";
+    return;
+  }
+  WriteAsOperandInternal(Out, MD, TypePrinter, Machine, Context);
+}
+
 static void writeGenericDebugNode(raw_ostream &Out, const GenericDebugNode *N,
                                   TypePrinting *TypePrinter,
                                   SlotTracker *Machine, const Module *Context) {
@@ -1306,11 +1317,7 @@ static void writeGenericDebugNode(raw_ostream &Out, const GenericDebugNode *N,
     FieldSeparator IFS;
     for (auto &I : N->dwarf_operands()) {
       Out << IFS;
-      if (!I) {
-        Out << "null";
-        continue;
-      }
-      WriteAsOperandInternal(Out, I, TypePrinter, Machine, Context);
+      writeMetadataAsOperand(Out, I, TypePrinter, Machine, Context);
     }
     Out << "}";
   }