From ea83f226acc5f3d2ea28d6162cfcb466dd72b0d0 Mon Sep 17 00:00:00 2001 From: Davide Italiano Date: Sat, 21 Nov 2015 02:15:51 +0000 Subject: [PATCH] [llvm-rtdyld] Use report_fatal_error(). This is a first step towards saner/uniform error reporting in llvm-rtdyld. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@253759 91177308-0d34-0410-b5e6-96231b3b80d8 --- tools/llvm-rtdyld/llvm-rtdyld.cpp | 35 ++++++++++++------------------- 1 file changed, 13 insertions(+), 22 deletions(-) diff --git a/tools/llvm-rtdyld/llvm-rtdyld.cpp b/tools/llvm-rtdyld/llvm-rtdyld.cpp index eab74543cbb..c5f2665a5d7 100644 --- a/tools/llvm-rtdyld/llvm-rtdyld.cpp +++ b/tools/llvm-rtdyld/llvm-rtdyld.cpp @@ -463,11 +463,9 @@ applySpecificSectionMappings(RuntimeDyldChecker &Checker) { std::string SectionIDStr = Mapping.substr(0, EqualsIdx); size_t ComaIdx = Mapping.find_first_of(","); - if (ComaIdx == StringRef::npos) { - errs() << "Invalid section specification '" << Mapping - << "'. Should be ',
='\n"; - exit(1); - } + if (ComaIdx == StringRef::npos) + report_fatal_error("Invalid section specification '" + Mapping + + "'. Should be ',
='"); std::string FileName = SectionIDStr.substr(0, ComaIdx); std::string SectionName = SectionIDStr.substr(ComaIdx + 1); @@ -477,20 +475,17 @@ applySpecificSectionMappings(RuntimeDyldChecker &Checker) { std::tie(OldAddrInt, ErrorMsg) = Checker.getSectionAddr(FileName, SectionName, true); - if (ErrorMsg != "") { - errs() << ErrorMsg; - exit(1); - } + if (ErrorMsg != "") + report_fatal_error(ErrorMsg); void* OldAddr = reinterpret_cast(static_cast(OldAddrInt)); std::string NewAddrStr = Mapping.substr(EqualsIdx + 1); uint64_t NewAddr; - if (StringRef(NewAddrStr).getAsInteger(0, NewAddr)) { - errs() << "Invalid section address in mapping '" << Mapping << "'.\n"; - exit(1); - } + if (StringRef(NewAddrStr).getAsInteger(0, NewAddr)) + report_fatal_error("Invalid section address in mapping '" + Mapping + + "'."); Checker.getRTDyld().mapSectionAddress(OldAddr, NewAddr); SpecificMappings[OldAddr] = NewAddr; @@ -579,20 +574,16 @@ static void remapSectionsAndSymbols(const llvm::Triple &TargetTriple, for (const auto &Mapping : DummySymbolMappings) { size_t EqualsIdx = Mapping.find_first_of("="); - if (EqualsIdx == StringRef::npos) { - errs() << "Invalid dummy symbol specification '" << Mapping - << "'. Should be '='\n"; - exit(1); - } + if (EqualsIdx == StringRef::npos) + report_fatal_error("Invalid dummy symbol specification '" + Mapping + + "'. Should be '='"); std::string Symbol = Mapping.substr(0, EqualsIdx); std::string AddrStr = Mapping.substr(EqualsIdx + 1); uint64_t Addr; - if (StringRef(AddrStr).getAsInteger(0, Addr)) { - errs() << "Invalid symbol mapping '" << Mapping << "'.\n"; - exit(1); - } + if (StringRef(AddrStr).getAsInteger(0, Addr)) + report_fatal_error("Invalid symbol mapping '" + Mapping + "'."); MemMgr.addDummySymbol(Symbol, Addr); } -- 2.34.1