Halide 20.0.0
Halide compiler and libraries
Error.h File Reference
#include <sstream>
#include <stdexcept>
#include "Debug.h"
#include "runtime/HalideRuntime.h"

Go to the source code of this file.

Classes

struct  Halide::Error
 A base class for Halide errors. More...
 
struct  Halide::RuntimeError
 An error that occurs while running a JIT-compiled Halide pipeline. More...
 
struct  Halide::CompileError
 An error that occurs while compiling a Halide pipeline that Halide attributes to a user error. More...
 
struct  Halide::InternalError
 An error that occurs while compiling a Halide pipeline that Halide attributes to an internal compiler bug, or to an invalid use of Halide's internals. More...
 
class  Halide::CompileTimeErrorReporter
 CompileTimeErrorReporter is used at compile time (not runtime) when an error or warning is generated by Halide. More...
 
struct  Halide::Internal::ReportBase< T >
 
struct  Halide::Internal::ErrorReport< Exception >
 
struct  Halide::Internal::WarningReport
 

Namespaces

namespace  Halide
 This file defines the class FunctionDAG, which is our representation of a Halide pipeline, and contains methods to using Halide's bounds tools to query properties of it.
 
namespace  Halide::Internal
 

Macros

#define _halide_internal_diagnostic(condition, type, condition_string)
 _halide_internal_diagnostic is used to implement our assertion macros in such a way that the messages output for the assertion are only evaluated if the assertion's value is false. More...
 
#define _halide_internal_error(type)    _halide_internal_diagnostic(0, Halide::Internal::ErrorReport<type>, nullptr)
 
#define _halide_internal_assertion(condition, type)    _halide_internal_diagnostic(condition, Halide::Internal::ErrorReport<type>, #condition)
 
#define user_error   _halide_internal_error(Halide::CompileError)
 
#define internal_error   _halide_internal_error(Halide::InternalError)
 
#define halide_runtime_error   _halide_internal_error(Halide::RuntimeError)
 
#define user_warning   _halide_internal_diagnostic(0, Halide::Internal::WarningReport, nullptr)
 
#define internal_assert(c)   _halide_internal_assertion(c, Halide::InternalError)
 
#define user_assert(c)   _halide_internal_assertion(c, Halide::CompileError)
 
#define _halide_internal_assert(c)   _halide_internal_assertion(c, Halide::InternalError)
 
#define _halide_user_assert(c)   _halide_internal_assertion(c, Halide::CompileError)
 

Functions

bool Halide::exceptions_enabled ()
 Query whether Halide was compiled with exceptions. More...
 
void Halide::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 calls abort (if not). More...
 
void Halide::Internal::issue_warning (const char *warning)
 If a custom error reporter is configured, notifies the reporter by calling its warning() function. More...
 
HALIDE_EXPORT_SYMBOL void Halide::Internal::unhandled_exception_handler ()
 
void Halide::Internal::throw_error (const RuntimeError &e)
 If a custom error reporter is configured, notifies the reporter by calling its error() function with the value of e.what() More...
 
void Halide::Internal::throw_error (const CompileError &e)
 If a custom error reporter is configured, notifies the reporter by calling its error() function with the value of e.what() More...
 
void Halide::Internal::throw_error (const InternalError &e)
 If a custom error reporter is configured, notifies the reporter by calling its error() function with the value of e.what() More...
 

Macro Definition Documentation

◆ _halide_internal_diagnostic

#define _halide_internal_diagnostic (   condition,
  type,
  condition_string 
)
Value:
/* NOLINTNEXTLINE(bugprone-macro-parentheses) */ \
if (!(condition)) for (type _err; _err; _err.issue()) _err.init(__FILE__, __FUNCTION__, __LINE__, condition_string)

_halide_internal_diagnostic is used to implement our assertion macros in such a way that the messages output for the assertion are only evaluated if the assertion's value is false.

This (regrettably) requires a macro to work, but has the highly desirable effect that all assertion parameters are totally skipped (not ever evaluated) when the assertion is true.

The macro works by deferring the call to issue() until after the stream has been evaluated. This previously used a trick where ErrorReport would throw in the destructor, but throwing in a destructor is UB in a lot of scenarios, and it was easy to break things by mistake.

Definition at line 199 of file Error.h.

◆ _halide_internal_error

#define _halide_internal_error (   type)     _halide_internal_diagnostic(0, Halide::Internal::ErrorReport<type>, nullptr)

Definition at line 204 of file Error.h.

◆ _halide_internal_assertion

#define _halide_internal_assertion (   condition,
  type 
)     _halide_internal_diagnostic(condition, Halide::Internal::ErrorReport<type>, #condition)

Definition at line 207 of file Error.h.

◆ user_error

#define user_error   _halide_internal_error(Halide::CompileError)

Definition at line 210 of file Error.h.

◆ internal_error

#define internal_error   _halide_internal_error(Halide::InternalError)

Definition at line 211 of file Error.h.

◆ halide_runtime_error

#define halide_runtime_error   _halide_internal_error(Halide::RuntimeError)

Definition at line 212 of file Error.h.

◆ user_warning

#define user_warning   _halide_internal_diagnostic(0, Halide::Internal::WarningReport, nullptr)

Definition at line 214 of file Error.h.

◆ internal_assert

#define internal_assert (   c)    _halide_internal_assertion(c, Halide::InternalError)

Definition at line 216 of file Error.h.

◆ user_assert

#define user_assert (   c)    _halide_internal_assertion(c, Halide::CompileError)

Definition at line 217 of file Error.h.

◆ _halide_internal_assert

#define _halide_internal_assert (   c)    _halide_internal_assertion(c, Halide::InternalError)

Definition at line 223 of file Error.h.

◆ _halide_user_assert

#define _halide_user_assert (   c)    _halide_internal_assertion(c, Halide::CompileError)

Definition at line 224 of file Error.h.