[llvm-rtdyld] Improve error handling, use Error().

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@253765 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Davide Italiano 2015-11-21 05:44:41 +00:00
parent 798892661c
commit 87daa918a1

View File

@ -595,21 +595,17 @@ static void remapSectionsAndSymbols(const llvm::Triple &TargetTriple,
static int linkAndVerify() {
// Check for missing triple.
if (TripleName == "") {
llvm::errs() << "Error: -triple required when running in -verify mode.\n";
return 1;
}
if (TripleName == "")
return Error("-triple required when running in -verify mode.");
// Look up the target and build the disassembler.
Triple TheTriple(Triple::normalize(TripleName));
std::string ErrorStr;
const Target *TheTarget =
TargetRegistry::lookupTarget("", TheTriple, ErrorStr);
if (!TheTarget) {
llvm::errs() << "Error accessing target '" << TripleName << "': "
<< ErrorStr << "\n";
return 1;
}
if (!TheTarget)
return Error("Error accessing target '" + TripleName + "': " + ErrorStr);
TripleName = TheTriple.getTriple();
std::unique_ptr<MCSubtargetInfo> STI(
@ -687,11 +683,9 @@ static int linkAndVerify() {
Dyld.registerEHFrames();
int ErrorCode = checkAllExpressions(Checker);
if (Dyld.hasError()) {
errs() << "RTDyld reported an error applying relocations:\n "
<< Dyld.getErrorString() << "\n";
ErrorCode = 1;
}
if (Dyld.hasError())
return Error("RTDyld reported an error applying relocations:\n " +
Dyld.getErrorString());
return ErrorCode;
}