From 75fe73fb9abe112386118d9631cf561f363a20d7 Mon Sep 17 00:00:00 2001 From: Rafael Espindola Date: Thu, 16 Nov 2017 17:46:43 +0000 Subject: make exitDsymutil static. The objective is to remove it completelly. This first patch removes the last use outside dsymutil.cpp and makes it static. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@318429 91177308-0d34-0410-b5e6-96231b3b80d8 --- tools/dsymutil/DwarfLinker.cpp | 32 ++++++++++++++++++++------------ tools/dsymutil/dsymutil.cpp | 4 +++- tools/dsymutil/dsymutil.h | 4 ---- 3 files changed, 23 insertions(+), 17 deletions(-) (limited to 'tools') diff --git a/tools/dsymutil/DwarfLinker.cpp b/tools/dsymutil/DwarfLinker.cpp index 55c939f693d..9d98dd84c1b 100644 --- a/tools/dsymutil/DwarfLinker.cpp +++ b/tools/dsymutil/DwarfLinker.cpp @@ -1303,9 +1303,9 @@ private: /// Recursively add the debug info in this clang module .pcm /// file (and all the modules imported by it in a bottom-up fashion) /// to Units. - void loadClangModule(StringRef Filename, StringRef ModulePath, - StringRef ModuleName, uint64_t DwoId, - DebugMap &ModuleMap, unsigned Indent = 0); + Error loadClangModule(StringRef Filename, StringRef ModulePath, + StringRef ModuleName, uint64_t DwoId, + DebugMap &ModuleMap, unsigned Indent = 0); /// Flags passed to DwarfLinker::lookForDIEsToKeep enum TravesalFlags { @@ -3410,7 +3410,11 @@ bool DwarfLinker::registerModuleReference( // Cyclic dependencies are disallowed by Clang, but we still // shouldn't run into an infinite loop, so mark it as processed now. ClangModules.insert({PCMfile, DwoId}); - loadClangModule(PCMfile, PCMpath, Name, DwoId, ModuleMap, Indent + 2); + if (Error E = loadClangModule(PCMfile, PCMpath, Name, DwoId, ModuleMap, + Indent + 2)) { + consumeError(std::move(E)); + return false; + } return true; } @@ -3429,9 +3433,9 @@ DwarfLinker::loadObject(BinaryHolder &BinaryHolder, DebugMapObject &Obj, return ErrOrObj; } -void DwarfLinker::loadClangModule(StringRef Filename, StringRef ModulePath, - StringRef ModuleName, uint64_t DwoId, - DebugMap &ModuleMap, unsigned Indent) { +Error DwarfLinker::loadClangModule(StringRef Filename, StringRef ModulePath, + StringRef ModuleName, uint64_t DwoId, + DebugMap &ModuleMap, unsigned Indent) { SmallString<80> Path(Options.PrependPath); if (sys::path::is_relative(Filename)) sys::path::append(Path, ModulePath, Filename); @@ -3473,7 +3477,7 @@ void DwarfLinker::loadClangModule(StringRef Filename, StringRef ModulePath, } } } - return; + return Error::success(); } std::unique_ptr Unit; @@ -3488,9 +3492,12 @@ void DwarfLinker::loadClangModule(StringRef Filename, StringRef ModulePath, auto CUDie = CU->getUnitDIE(false); if (!registerModuleReference(CUDie, *CU, ModuleMap, Indent)) { if (Unit) { - errs() << Filename << ": Clang modules are expected to have exactly" - << " 1 compile unit.\n"; - exitDsymutil(1); + std::string Err = + (Filename + + ": Clang modules are expected to have exactly 1 compile unit.\n") + .str(); + errs() << Err; + return make_error(Err, inconvertibleErrorCode()); } // FIXME: Until PR27449 (https://llvm.org/bugs/show_bug.cgi?id=27449) is // fixed in clang, only warn about DWO_id mismatches in verbose mode. @@ -3516,7 +3523,7 @@ void DwarfLinker::loadClangModule(StringRef Filename, StringRef ModulePath, } } if (!Unit->getOrigUnit().getUnitDIE().hasChildren()) - return; + return Error::success(); if (Options.Verbose) { outs().indent(Indent); outs() << "cloning .debug_info from " << Filename << "\n"; @@ -3526,6 +3533,7 @@ void DwarfLinker::loadClangModule(StringRef Filename, StringRef ModulePath, CompileUnits.push_back(std::move(Unit)); DIECloner(*this, RelocMgr, DIEAlloc, CompileUnits, Options) .cloneAllCompileUnits(*DwarfContext); + return Error::success(); } void DwarfLinker::DIECloner::cloneAllCompileUnits(DWARFContext &DwarfContext) { diff --git a/tools/dsymutil/dsymutil.cpp b/tools/dsymutil/dsymutil.cpp index cea3aef1096..46953d90c03 100644 --- a/tools/dsymutil/dsymutil.cpp +++ b/tools/dsymutil/dsymutil.cpp @@ -250,7 +250,9 @@ static std::string getOutputFileName(llvm::StringRef InputFile, return BundleDir.str(); } -void llvm::dsymutil::exitDsymutil(int ExitStatus) { +/// Exit the dsymutil process, cleaning up every temporary files that we +/// created. +static LLVM_ATTRIBUTE_NORETURN void exitDsymutil(int ExitStatus) { // Cleanup temporary files. llvm::sys::RunInterruptHandlers(); exit(ExitStatus); diff --git a/tools/dsymutil/dsymutil.h b/tools/dsymutil/dsymutil.h index 35374fa5a2e..09053d1b1cc 100644 --- a/tools/dsymutil/dsymutil.h +++ b/tools/dsymutil/dsymutil.h @@ -65,10 +65,6 @@ bool dumpStab(StringRef InputFile, ArrayRef Archs, bool linkDwarf(raw_fd_ostream &OutFile, 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); - void warn(const Twine &Warning, const Twine &Context); bool error(const Twine &Error, const Twine &Context); -- cgit v1.2.3