From 57bafedfafac38491f7402c45bd72a02a6a9d214 Mon Sep 17 00:00:00 2001 From: Lang Hames Date: Tue, 30 Aug 2016 05:32:41 +0000 Subject: [PATCH] [Support] Add a conditionally defined default constructor (available on MSVC only) for Expected so that it can interoperate with MSVC's std::future implementation. MSVC 2013's std::future implementation requires the wrapped type to be default constructible. Hopefully this will fix the bot breakage in http://lab.llvm.org:8011/builders/clang-x86-win2008-selfhost/builds/9937 . llvm-svn: 280058 --- llvm/include/llvm/Support/Error.h | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/llvm/include/llvm/Support/Error.h b/llvm/include/llvm/Support/Error.h index afd2660..bd488e4 100644 --- a/llvm/include/llvm/Support/Error.h +++ b/llvm/include/llvm/Support/Error.h @@ -629,6 +629,27 @@ private: typedef const typename std::remove_reference::type *const_pointer; public: + +#ifdef _MSC_VER + // WARNING: This constructor should *never* be called in user code. + // It is provided under MSVC only so that Expected can be used + // with MSVC's header, which requires types to be default + // constructible. + // + // FIXME; Kill this as soon as MSVC's implementation no longer + // requires types to be default constructible. + Expected() + : HasError(true) +#ifndef NDEBUG + , + Checked(true) +#endif // NDEBUG + { + new (getErrorStorage()) Error(); + !!*getErrorStorage(); + } +#endif // _MSC_VER + /// Create an Expected error value from the given Error. Expected(Error Err) : HasError(true) -- 2.7.4