summaryrefslogtreecommitdiffstats
path: root/llvm/lib
diff options
context:
space:
mode:
authorLang Hames <lhames@gmail.com>2016-07-14 00:37:04 +0000
committerLang Hames <lhames@gmail.com>2016-07-14 00:37:04 +0000
commitae610ab528a382a393aae26d2d67cee05cabe634 (patch)
treebb4178e75d234c71dac75810b4662a0f979227f0 /llvm/lib
parent7f781aba9755633c53210db02d51f6f56d11ea48 (diff)
downloadbcm5719-llvm-ae610ab528a382a393aae26d2d67cee05cabe634.tar.gz
bcm5719-llvm-ae610ab528a382a393aae26d2d67cee05cabe634.zip
[Object] Revert r275316, Archive::child_iterator changes, while I update lld.
Should fix the bots broken by r275316. llvm-svn: 275353
Diffstat (limited to 'llvm/lib')
-rw-r--r--llvm/lib/ExecutionEngine/MCJIT/MCJIT.cpp9
-rw-r--r--llvm/lib/ExecutionEngine/Orc/OrcMCJITReplacement.h9
-rw-r--r--llvm/lib/Object/Archive.cpp48
-rw-r--r--llvm/lib/Support/Error.cpp11
4 files changed, 30 insertions, 47 deletions
diff --git a/llvm/lib/ExecutionEngine/MCJIT/MCJIT.cpp b/llvm/lib/ExecutionEngine/MCJIT/MCJIT.cpp
index 9da0045d201..30f18db0a46 100644
--- a/llvm/lib/ExecutionEngine/MCJIT/MCJIT.cpp
+++ b/llvm/lib/ExecutionEngine/MCJIT/MCJIT.cpp
@@ -327,14 +327,13 @@ RuntimeDyld::SymbolInfo MCJIT::findSymbol(const std::string &Name,
for (object::OwningBinary<object::Archive> &OB : Archives) {
object::Archive *A = OB.getBinary();
// Look for our symbols in each Archive
- Error Err;
- object::Archive::child_iterator ChildIt = A->findSym(Err, Name);
- if (Err)
- report_fatal_error(std::move(Err));
+ object::Archive::child_iterator ChildIt = A->findSym(Name);
+ if (std::error_code EC = ChildIt->getError())
+ report_fatal_error(EC.message());
if (ChildIt != A->child_end()) {
// FIXME: Support nested archives?
Expected<std::unique_ptr<object::Binary>> ChildBinOrErr =
- ChildIt->getAsBinary();
+ (*ChildIt)->getAsBinary();
if (!ChildBinOrErr) {
// TODO: Actually report errors helpfully.
consumeError(ChildBinOrErr.takeError());
diff --git a/llvm/lib/ExecutionEngine/Orc/OrcMCJITReplacement.h b/llvm/lib/ExecutionEngine/Orc/OrcMCJITReplacement.h
index 2fde56447fc..5ab47b97dbd 100644
--- a/llvm/lib/ExecutionEngine/Orc/OrcMCJITReplacement.h
+++ b/llvm/lib/ExecutionEngine/Orc/OrcMCJITReplacement.h
@@ -258,14 +258,13 @@ private:
for (object::OwningBinary<object::Archive> &OB : Archives) {
object::Archive *A = OB.getBinary();
// Look for our symbols in each Archive
- Error Err;
- object::Archive::child_iterator ChildIt = A->findSym(Err, Name);
- if (Err)
- report_fatal_error(std::move(Err));
+ object::Archive::child_iterator ChildIt = A->findSym(Name);
+ if (std::error_code EC = ChildIt->getError())
+ report_fatal_error(EC.message());
if (ChildIt != A->child_end()) {
// FIXME: Support nested archives?
Expected<std::unique_ptr<object::Binary>> ChildBinOrErr =
- ChildIt->getAsBinary();
+ (*ChildIt)->getAsBinary();
if (!ChildBinOrErr) {
// TODO: Actually report errors helpfully.
consumeError(ChildBinOrErr.takeError());
diff --git a/llvm/lib/Object/Archive.cpp b/llvm/lib/Object/Archive.cpp
index 4827e58f5d3..4720bf894e9 100644
--- a/llvm/lib/Object/Archive.cpp
+++ b/llvm/lib/Object/Archive.cpp
@@ -298,9 +298,12 @@ Archive::Archive(MemoryBufferRef Source, Error &Err)
}
// Get the special members.
- child_iterator I = child_begin(Err, false);
- if (Err)
+ child_iterator I = child_begin(false);
+ std::error_code ec;
+ if ((ec = I->getError())) {
+ Err = errorCodeToError(ec);
return;
+ }
child_iterator E = child_end();
// This is at least a valid empty archive. Since an empty archive is the
@@ -312,13 +315,13 @@ Archive::Archive(MemoryBufferRef Source, Error &Err)
Err = Error::success();
return;
}
- const Child *C = &*I;
+ const Child *C = &**I;
auto Increment = [&]() {
++I;
- if (Err)
+ if ((Err = errorCodeToError(I->getError())))
return true;
- C = &*I;
+ C = &**I;
return false;
};
@@ -363,7 +366,8 @@ Archive::Archive(MemoryBufferRef Source, Error &Err)
Format = K_BSD;
// We know this is BSD, so getName will work since there is no string table.
ErrorOr<StringRef> NameOrErr = C->getName();
- if (auto ec = NameOrErr.getError()) {
+ ec = NameOrErr.getError();
+ if (ec) {
Err = errorCodeToError(ec);
return;
}
@@ -461,29 +465,23 @@ Archive::Archive(MemoryBufferRef Source, Error &Err)
Err = Error::success();
}
-Archive::child_iterator Archive::child_begin(Error &Err,
- bool SkipInternal) const {
+Archive::child_iterator Archive::child_begin(bool SkipInternal) const {
if (Data.getBufferSize() == 8) // empty archive.
return child_end();
if (SkipInternal)
- return child_iterator(Child(this, FirstRegularData,
- FirstRegularStartOfFile),
- &Err);
+ return Child(this, FirstRegularData, FirstRegularStartOfFile);
const char *Loc = Data.getBufferStart() + strlen(Magic);
std::error_code EC;
- Child C(this, Loc, &EC);
- if (EC) {
- ErrorAsOutParameter ErrAsOutParam(Err);
- Err = errorCodeToError(EC);
- return child_end();
- }
- return child_iterator(C, &Err);
+ Child c(this, Loc, &EC);
+ if (EC)
+ return child_iterator(EC);
+ return child_iterator(c);
}
Archive::child_iterator Archive::child_end() const {
- return child_iterator(Child(this, nullptr, nullptr), nullptr);
+ return Child(this, nullptr, nullptr);
}
StringRef Archive::Symbol::getName() const {
@@ -667,20 +665,18 @@ uint32_t Archive::getNumberOfSymbols() const {
return read32le(buf);
}
-Archive::child_iterator Archive::findSym(Error &Err, StringRef name) const {
+Archive::child_iterator Archive::findSym(StringRef name) const {
Archive::symbol_iterator bs = symbol_begin();
Archive::symbol_iterator es = symbol_end();
for (; bs != es; ++bs) {
StringRef SymName = bs->getName();
if (SymName == name) {
- if (auto MemberOrErr = bs->getMember()) {
- return child_iterator(*MemberOrErr, &Err);
- } else {
- ErrorAsOutParameter ErrAsOutParam(Err);
- Err = errorCodeToError(MemberOrErr.getError());
+ ErrorOr<Archive::child_iterator> ResultOrErr = bs->getMember();
+ // FIXME: Should we really eat the error?
+ if (ResultOrErr.getError())
return child_end();
- }
+ return ResultOrErr.get();
}
}
return child_end();
diff --git a/llvm/lib/Support/Error.cpp b/llvm/lib/Support/Error.cpp
index 6b22691eb1a..df540d10bc5 100644
--- a/llvm/lib/Support/Error.cpp
+++ b/llvm/lib/Support/Error.cpp
@@ -64,7 +64,6 @@ void logAllUnhandledErrors(Error E, raw_ostream &OS, Twine ErrorBanner) {
});
}
-
std::error_code ErrorList::convertToErrorCode() const {
return std::error_code(static_cast<int>(ErrorErrorCode::MultipleErrors),
*ErrorErrorCat);
@@ -100,14 +99,4 @@ std::error_code StringError::convertToErrorCode() const {
return EC;
}
-void report_fatal_error(Error Err, bool GenCrashDiag) {
- assert(Err && "report_fatal_error called with success value");
- std::string ErrMsg;
- {
- raw_string_ostream ErrStream(ErrMsg);
- logAllUnhandledErrors(std::move(Err), ErrStream, "");
- }
- report_fatal_error(ErrMsg);
-}
-
}
OpenPOWER on IntegriCloud