summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRafael Espindola <rafael.espindola@gmail.com>2014-01-08 21:17:09 +0000
committerRafael Espindola <rafael.espindola@gmail.com>2014-01-08 21:17:09 +0000
commitd13e173eb627276ab546b05195c05fcbdf6a8baa (patch)
treef4c0086577f82dd9f0be60a9e5bee2d2c90a50e0
parentcb1f0ddce42c2da8428e331532518d753e62fd1b (diff)
downloadllvm-d13e173eb627276ab546b05195c05fcbdf6a8baa.tar.gz
llvm-d13e173eb627276ab546b05195c05fcbdf6a8baa.tar.bz2
llvm-d13e173eb627276ab546b05195c05fcbdf6a8baa.tar.xz
Add get and getError methods to ErrorOr.
ErrorOr is modeled after boost::optional which has a get method. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@198792 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r--include/llvm/Support/ErrorOr.h7
1 files changed, 7 insertions, 0 deletions
diff --git a/include/llvm/Support/ErrorOr.h b/include/llvm/Support/ErrorOr.h
index 26af1e8c80..21ab4e721d 100644
--- a/include/llvm/Support/ErrorOr.h
+++ b/include/llvm/Support/ErrorOr.h
@@ -178,10 +178,17 @@ public:
return HasError ? 0 : unspecified_bool_true;
}
+ T &get() { return *getStorage(); }
+ const T &get() const { return const_cast<ErrorOr<T> >(this)->get(); }
+
operator llvm::error_code() const {
return HasError ? *getErrorStorage() : llvm::error_code::success();
}
+ error_code getError() const {
+ return HasError ? *getErrorStorage() : error_code::success();
+ }
+
pointer operator ->() {
return toPointer(getStorage());
}