[dsymutil] Introduce exit helper. NFC.
authorFrederic Riss <friss@apple.com>
Wed, 5 Aug 2015 18:27:38 +0000 (18:27 +0000)
committerFrederic Riss <friss@apple.com>
Wed, 5 Aug 2015 18:27:38 +0000 (18:27 +0000)
llvm-dsymutil will start creating temporary files in a followup
commit. To ease the correct cleanup of this files, introduce a
helper called to exit dsymutil.

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

tools/dsymutil/dsymutil.cpp
tools/dsymutil/dsymutil.h

index 54a4b5b3332ff2f4b150de32823b94b6de595f57..07fdf314c442a1140b792b258a770ca9dcbb50ba 100644 (file)
@@ -77,6 +77,10 @@ static std::string getOutputFileName(llvm::StringRef InputFile) {
   return OutputFileOpt;
 }
 
   return OutputFileOpt;
 }
 
+void llvm::dsymutil::exitDsymutil(int ExitStatus) {
+  exit(ExitStatus);
+}
+
 int main(int argc, char **argv) {
   llvm::sys::PrintStackTraceOnErrorSignal();
   llvm::PrettyStackTraceProgram StackPrinter(argc, argv);
 int main(int argc, char **argv) {
   llvm::sys::PrintStackTraceOnErrorSignal();
   llvm::PrettyStackTraceProgram StackPrinter(argc, argv);
@@ -120,7 +124,7 @@ int main(int argc, char **argv) {
     if (auto EC = DebugMapPtrOrErr.getError()) {
       llvm::errs() << "error: cannot parse the debug map for \"" << InputFile
                    << "\": " << EC.message() << '\n';
     if (auto EC = DebugMapPtrOrErr.getError()) {
       llvm::errs() << "error: cannot parse the debug map for \"" << InputFile
                    << "\": " << EC.message() << '\n';
-      return 1;
+      exitDsymutil(1);
     }
 
     if (Verbose || DumpDebugMap)
     }
 
     if (Verbose || DumpDebugMap)
@@ -131,8 +135,8 @@ int main(int argc, char **argv) {
 
     std::string OutputFile = getOutputFileName(InputFile);
     if (!linkDwarf(OutputFile, **DebugMapPtrOrErr, Options))
 
     std::string OutputFile = getOutputFileName(InputFile);
     if (!linkDwarf(OutputFile, **DebugMapPtrOrErr, Options))
-      return 1;
+      exitDsymuti(1);
   }
 
   }
 
-  return 0;
+  exitDsymutil(0);
 }
 }
index cd530a1177a963a4063d13219c79336ea0cbe1ba..7c1810f4fad823b38423d3c1bd6a2554ba9a8c78 100644 (file)
@@ -44,6 +44,11 @@ llvm::ErrorOr<std::unique_ptr<DebugMap>> parseDebugMap(StringRef InputFile,
 /// \returns false if the link failed.
 bool linkDwarf(StringRef OutputFilename, const DebugMap &DM,
                const LinkOptions &Options);
 /// \returns false if the link failed.
 bool linkDwarf(StringRef OutputFilename, const DebugMap &DM,
                const LinkOptions &Options);
+
+/// \brief Exit the dsymutil process, cleaning up every temporary
+/// files that we created.
+LLVM_ATTRIBUTE_NORETURN void exitDsymutil(int ExitStatus);
+
 }
 }
 #endif // LLVM_TOOLS_DSYMUTIL_DSYMUTIL_H
 }
 }
 #endif // LLVM_TOOLS_DSYMUTIL_DSYMUTIL_H