[dsymutil] Split some logic into a helper function. NFC
authorFrederic Riss <friss@apple.com>
Wed, 5 Aug 2015 18:27:34 +0000 (18:27 +0000)
committerFrederic Riss <friss@apple.com>
Wed, 5 Aug 2015 18:27:34 +0000 (18:27 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@244085 91177308-0d34-0410-b5e6-96231b3b80d8

tools/dsymutil/dsymutil.cpp

index a473c405ea8e9830e03d61eca5da6b447f38953e..54a4b5b3332ff2f4b150de32823b94b6de595f57 100644 (file)
@@ -68,6 +68,15 @@ static opt<bool> InputIsYAMLDebugMap(
     init(false), cat(DsymCategory));
 }
 
+static std::string getOutputFileName(llvm::StringRef InputFile) {
+  if (OutputFileOpt.empty()) {
+    if (InputFile == "-")
+      return "a.out.dwarf";
+    return (InputFile + ".dwarf").str();
+  }
+  return OutputFileOpt;
+}
+
 int main(int argc, char **argv) {
   llvm::sys::PrintStackTraceOnErrorSignal();
   llvm::PrettyStackTraceProgram StackPrinter(argc, argv);
@@ -120,16 +129,7 @@ int main(int argc, char **argv) {
     if (DumpDebugMap)
       continue;
 
-    std::string OutputFile;
-    if (OutputFileOpt.empty()) {
-      if (InputFile == "-")
-        OutputFile = "a.out.dwarf";
-      else
-        OutputFile = InputFile + ".dwarf";
-    } else {
-      OutputFile = OutputFileOpt;
-    }
-
+    std::string OutputFile = getOutputFileName(InputFile);
     if (!linkDwarf(OutputFile, **DebugMapPtrOrErr, Options))
       return 1;
   }