Index: include/llvm/Support/ErrorOr.h =================================================================== --- include/llvm/Support/ErrorOr.h +++ include/llvm/Support/ErrorOr.h @@ -18,6 +18,7 @@ #include "llvm/ADT/PointerIntPair.h" #include "llvm/Support/AlignOf.h" +#include "llvm/Support/ErrorHandling.h" #include #include #include @@ -175,6 +176,15 @@ reference get() { return *getStorage(); } const_reference get() const { return const_cast >(this)->get(); } + reference getOrDie() { + if (HasError) + report_fatal_error("Cannot get value when an error exists!", false); + return *getStorage(); + } + const_reference getOrDie() const { + return const_cast>(this)->getOrDie(); + } + std::error_code getError() const { return HasError ? *getErrorStorage() : std::error_code(); }