28 explicit Error(
const char *msg);
29 explicit Error(
const std::string &msg);
38 virtual const
char *
what() const noexcept;
85 virtual void warning(
const char *msg) = 0;
86 [[noreturn]]
virtual void error(
const char *msg) = 0;
129 return *
static_cast<T *
>(
this);
145 if (!
msg.str().empty() &&
msg.str().back() !=
'\n') {
152 T &
init(
const char *file,
const char *function,
const int line,
const char *condition_string,
const char *prefix) {
154 msg << prefix <<
" at " << file <<
":" << line <<
' ';
155 if (condition_string) {
156 msg <<
"Condition failed: " << condition_string <<
' ';
159 return *
static_cast<T *
>(
this);
163template<
typename Exception>
165 ErrorReport &
init(
const char *file,
const char *function,
const int line,
const char *condition_string) {
169 [[noreturn]]
void issue() noexcept(false) {
175 WarningReport &
init(
const char *file,
const char *function,
const int line,
const char *condition_string) {
176 return ReportBase::init(file, function, line, condition_string,
"Warning") <<
"Warning: ";
198#define _halide_error_impl(type) \
199 for (Halide::Internal::ErrorReport<type> _err; 1; _err.issue()) \
200 _err.init(__FILE__, __FUNCTION__, __LINE__, nullptr)
202#define _halide_assert_impl(condition, type) \
204 for (Halide::Internal::ErrorReport<type> _err; 1; _err.issue()) \
205 _err.init(__FILE__, __FUNCTION__, __LINE__, #condition)
207#define _halide_user_warning \
208 for (Halide::Internal::WarningReport _err; _err; _err.issue()) \
209 _err.init(__FILE__, __FUNCTION__, __LINE__, nullptr)
212#define user_warning _halide_user_warning
214#define user_error _halide_error_impl(Halide::CompileError)
215#define internal_error _halide_error_impl(Halide::InternalError)
216#define halide_runtime_error _halide_error_impl(Halide::RuntimeError)
218#define internal_assert(c) _halide_assert_impl(c, Halide::InternalError)
219#define user_assert(c) _halide_assert_impl(c, Halide::CompileError)
225#define _halide_user_error _halide_error_impl(Halide::CompileError)
226#define _halide_internal_error _halide_error_impl(Halide::InternalError)
227#define _halide_runtime_error _halide_error_impl(Halide::RuntimeError)
228#define _halide_internal_assert(c) _halide_assert_impl(c, Halide::InternalError)
229#define _halide_user_assert(c) _halide_assert_impl(c, Halide::CompileError)
Defines functions for debug logging during code generation.
This file declares the routines used by Halide internally in its runtime.
#define HALIDE_EXPORT_SYMBOL
#define HALIDE_ALWAYS_INLINE
CompileTimeErrorReporter is used at compile time (not runtime) when an error or warning is generated ...
virtual void warning(const char *msg)=0
virtual void error(const char *msg)=0
virtual ~CompileTimeErrorReporter()=default
void throw_error(const RuntimeError &e)
If a custom error reporter is configured, notifies the reporter by calling its error() function with ...
void issue_warning(const char *warning)
If a custom error reporter is configured, notifies the reporter by calling its warning() function.
HALIDE_EXPORT_SYMBOL void unhandled_exception_handler()
bool debug_is_active_impl(int verbosity, const char *file, const char *function, int line)
This file defines the class FunctionDAG, which is our representation of a Halide pipeline,...
bool exceptions_enabled()
Query whether Halide was compiled with exceptions.
void set_custom_compile_time_error_reporter(CompileTimeErrorReporter *error_reporter)
The default error reporter logs to stderr, then throws an exception (if HALIDE_WITH_EXCEPTIONS) or ca...
An error that occurs while compiling a Halide pipeline that Halide attributes to a user error.
static constexpr auto error_name
CompileError(const char *msg)
CompileError(const std::string &msg)
Error(const std::string &msg)
Error & operator=(const Error &)
virtual const char * what() const noexcept
void issue() noexcept(false)
ErrorReport & init(const char *file, const char *function, const int line, const char *condition_string)
std::string finalize_message()
T & init(const char *file, const char *function, const int line, const char *condition_string, const char *prefix)
HALIDE_ALWAYS_INLINE T & operator<<(const S &x)
WarningReport & init(const char *file, const char *function, const int line, const char *condition_string)
An error that occurs while compiling a Halide pipeline that Halide attributes to an internal compiler...
static constexpr auto error_name
InternalError(const std::string &msg)
InternalError(const char *msg)
An error that occurs while running a JIT-compiled Halide pipeline.
static constexpr auto error_name
RuntimeError(const char *msg)
RuntimeError(const std::string &msg)