[llvm] r244086 - [dsymutil] Introduce exit helper. NFC.

Frederic Riss friss at apple.com
Wed Aug 5 11:27:38 PDT 2015


Author: friss
Date: Wed Aug  5 13:27:38 2015
New Revision: 244086

URL: http://llvm.org/viewvc/llvm-project?rev=244086&view=rev
Log:
[dsymutil] Introduce exit helper. NFC.

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.

Modified:
    llvm/trunk/tools/dsymutil/dsymutil.cpp
    llvm/trunk/tools/dsymutil/dsymutil.h

Modified: llvm/trunk/tools/dsymutil/dsymutil.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/dsymutil/dsymutil.cpp?rev=244086&r1=244085&r2=244086&view=diff
==============================================================================
--- llvm/trunk/tools/dsymutil/dsymutil.cpp (original)
+++ llvm/trunk/tools/dsymutil/dsymutil.cpp Wed Aug  5 13:27:38 2015
@@ -77,6 +77,10 @@ static std::string getOutputFileName(llv
   return OutputFileOpt;
 }
 
+void llvm::dsymutil::exitDsymutil(int ExitStatus) {
+  exit(ExitStatus);
+}
+
 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';
-      return 1;
+      exitDsymutil(1);
     }
 
     if (Verbose || DumpDebugMap)
@@ -131,8 +135,8 @@ int main(int argc, char **argv) {
 
     std::string OutputFile = getOutputFileName(InputFile);
     if (!linkDwarf(OutputFile, **DebugMapPtrOrErr, Options))
-      return 1;
+      exitDsymuti(1);
   }
 
-  return 0;
+  exitDsymutil(0);
 }

Modified: llvm/trunk/tools/dsymutil/dsymutil.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/dsymutil/dsymutil.h?rev=244086&r1=244085&r2=244086&view=diff
==============================================================================
--- llvm/trunk/tools/dsymutil/dsymutil.h (original)
+++ llvm/trunk/tools/dsymutil/dsymutil.h Wed Aug  5 13:27:38 2015
@@ -44,6 +44,11 @@ llvm::ErrorOr<std::unique_ptr<DebugMap>>
 /// \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




More information about the llvm-commits mailing list