[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.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@244086 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Frederic Riss 2015-08-05 18:27:38 +00:00
parent cca89d34ba
commit d2fb7bd3d5
2 changed files with 12 additions and 3 deletions

View File

@ -77,6 +77,10 @@ static std::string getOutputFileName(llvm::StringRef InputFile) {
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);
}

View 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);
/// \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