Skip to content

Commit

Permalink
make exitDsymutil static.
Browse files Browse the repository at this point in the history
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
  • Loading branch information
espindola committed Nov 16, 2017
1 parent 37d0870 commit 75fe73f
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 17 deletions.
32 changes: 20 additions & 12 deletions tools/dsymutil/DwarfLinker.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1303,9 +1303,9 @@ class DwarfLinker {
/// 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 {
Expand Down Expand Up @@ -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;
}

Expand All @@ -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);
Expand Down Expand Up @@ -3473,7 +3477,7 @@ void DwarfLinker::loadClangModule(StringRef Filename, StringRef ModulePath,
}
}
}
return;
return Error::success();
}

std::unique_ptr<CompileUnit> Unit;
Expand All @@ -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<StringError>(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.
Expand All @@ -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";
Expand All @@ -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) {
Expand Down
4 changes: 3 additions & 1 deletion tools/dsymutil/dsymutil.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
4 changes: 0 additions & 4 deletions tools/dsymutil/dsymutil.h
Original file line number Diff line number Diff line change
Expand Up @@ -65,10 +65,6 @@ bool dumpStab(StringRef InputFile, ArrayRef<std::string> 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);

Expand Down

0 comments on commit 75fe73f

Please sign in to comment.