Index: include/llvm/Support/Error.h =================================================================== --- include/llvm/Support/Error.h +++ include/llvm/Support/Error.h @@ -48,6 +48,14 @@ /// the ErrorInfo template subclass instead. class ErrorInfoBase { public: + ErrorInfoBase() { +#if !defined(NDEBUG) + if (BreakOnError) { + LLVM_BUILTIN_DEBUGTRAP; + } +#endif + } + virtual ~ErrorInfoBase() = default; /// Print an error message to an output stream. @@ -88,6 +96,11 @@ virtual void anchor(); static char ID; + +#if !defined(NDEBUG) + // Set to true in debug sessions to immediately break when an error occcurs. + static bool BreakOnError; +#endif }; /// Lightweight error class with error context and mandatory checking. 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 !defined(NDEBUG) +bool ErrorInfoBase::BreakOnError = false; +#endif + void logAllUnhandledErrors(Error E, raw_ostream &OS, Twine ErrorBanner) { if (!E) return;