Index: include/llvm/Support/Error.h =================================================================== --- include/llvm/Support/Error.h +++ include/llvm/Support/Error.h @@ -280,6 +280,12 @@ (reinterpret_cast(EI) & ~static_cast(0x1)) | (reinterpret_cast(Payload) & 0x1)); + +# if !defined(NDEBUG) + if (BreakOnError && EI != nullptr) { + LLVM_BUILTIN_DEBUGTRAP; + } +# endif #else Payload = EI; #endif @@ -316,6 +322,11 @@ } ErrorInfoBase *Payload = nullptr; + +#if LLVM_ENABLE_ABI_BREAKING_CHECKS && !defined(NDEBUG) + // Set to true in debug sessions to immediately break when an error occcurs. + static bool BreakOnError; +#endif }; /// Subclass of Error for the sole purpose of identifying the success path in Index: lib/Support/Error.cpp =================================================================== --- lib/Support/Error.cpp +++ lib/Support/Error.cpp @@ -54,6 +54,10 @@ char ECError::ID = 0; char StringError::ID = 0; +#if LLVM_ENABLE_ABI_BREAKING_CHECKS && !defined(NDEBUG) +bool Error::BreakOnError = false; +#endif + void logAllUnhandledErrors(Error E, raw_ostream &OS, Twine ErrorBanner) { if (!E) return;