[dwarfdump] Move dumping to a helper function NFC
[oota-llvm.git] / tools / llvm-dwarfdump / llvm-dwarfdump.cpp
index cd48d81c8de23cbcdedced03d0f0b3065435fa4a..018e6662facc5898437eeeb40ad22f6ad177ca91 100644 (file)
@@ -76,6 +76,15 @@ static void error(StringRef Filename, std::error_code EC) {
   exit(1);
 }
 
+static void DumpObjectFile(ObjectFile &Obj, StringRef Filename) {
+  std::unique_ptr<DIContext> DICtx(new DWARFContextInMemory(Obj));
+
+  outs() << Filename
+         << ":\tfile format " << Obj.getFileFormatName() << "\n\n";
+  // Dump the complete DWARF structure.
+  DICtx->dump(outs(), DumpType);
+}
+
 static void DumpInput(StringRef Filename) {
   ErrorOr<std::unique_ptr<MemoryBuffer>> BuffOrErr =
       MemoryBuffer::getFileOrSTDIN(Filename);
@@ -87,12 +96,7 @@ static void DumpInput(StringRef Filename) {
   error(Filename, ObjOrErr.getError());
   ObjectFile &Obj = *ObjOrErr.get();
 
-  std::unique_ptr<DIContext> DICtx(new DWARFContextInMemory(Obj));
-
-  outs() << Filename
-         << ":\tfile format " << Obj.getFileFormatName() << "\n\n";
-  // Dump the complete DWARF structure.
-  DICtx->dump(outs(), DumpType);
+  DumpObjectFile(Obj, Filename);
 }
 
 int main(int argc, char **argv) {