summaryrefslogtreecommitdiffstats
path: root/llvm/lib/ExecutionEngine/Orc/OrcMCJITReplacement.h
diff options
context:
space:
mode:
authorLang Hames <lhames@gmail.com>2016-07-13 21:13:05 +0000
committerLang Hames <lhames@gmail.com>2016-07-13 21:13:05 +0000
commitc2773e97d248c396636464de9726c04efe47bf03 (patch)
treed06cf695118c691289eabb963bdd2613836388c2 /llvm/lib/ExecutionEngine/Orc/OrcMCJITReplacement.h
parent02c15da062621032fbb9d72b73ee1996be9205ec (diff)
downloadbcm5719-llvm-c2773e97d248c396636464de9726c04efe47bf03.tar.gz
bcm5719-llvm-c2773e97d248c396636464de9726c04efe47bf03.zip
[Object] Change Archive::child_iterator for better interop with Error/Expected.
See http://reviews.llvm.org/D22079 Changes the Archive::child_begin and Archive::children to require a reference to an Error. If iterator increment fails (because the archive header is damaged) the iterator will be set to 'end()', and the error stored in the given Error&. The Error value should be checked by the user immediately after the loop. E.g.: Error Err; for (auto &C : A->children(Err)) { // Do something with archive child C. } // Check the error immediately after the loop. if (Err) return Err; Failure to check the Error will result in an abort() when the Error goes out of scope (as guaranteed by the Error class). llvm-svn: 275316
Diffstat (limited to 'llvm/lib/ExecutionEngine/Orc/OrcMCJITReplacement.h')
-rw-r--r--llvm/lib/ExecutionEngine/Orc/OrcMCJITReplacement.h9
1 files changed, 5 insertions, 4 deletions
diff --git a/llvm/lib/ExecutionEngine/Orc/OrcMCJITReplacement.h b/llvm/lib/ExecutionEngine/Orc/OrcMCJITReplacement.h
index 5ab47b97dbd..2fde56447fc 100644
--- a/llvm/lib/ExecutionEngine/Orc/OrcMCJITReplacement.h
+++ b/llvm/lib/ExecutionEngine/Orc/OrcMCJITReplacement.h
@@ -258,13 +258,14 @@ private:
for (object::OwningBinary<object::Archive> &OB : Archives) {
object::Archive *A = OB.getBinary();
// Look for our symbols in each Archive
- object::Archive::child_iterator ChildIt = A->findSym(Name);
- if (std::error_code EC = ChildIt->getError())
- report_fatal_error(EC.message());
+ Error Err;
+ object::Archive::child_iterator ChildIt = A->findSym(Err, Name);
+ if (Err)
+ report_fatal_error(std::move(Err));
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());
OpenPOWER on IntegriCloud