26 #ifndef TVM_IR_DIAGNOSTIC_H_
27 #define TVM_IR_DIAGNOSTIC_H_
29 #include <tvm/ffi/reflection/registry.h>
46 class DiagnosticBuilder;
71 refl::ObjectDef<DiagnosticNode>()
125 template <
typename T>
143 std::stringstream stream_;
181 ICHECK(get() !=
nullptr);
202 refl::ObjectDef<DiagnosticContextNode>()
234 ICHECK(get() !=
nullptr);
A wrapper around std::stringstream to build a diagnostic.
Definition: diagnostic.h:109
DiagnosticBuilder(DiagnosticLevel level, ObjectRef loc)
Definition: diagnostic.h:138
friend class Diagnostic
Definition: diagnostic.h:144
DiagnosticBuilder(const DiagnosticBuilder &builder)
Definition: diagnostic.h:133
Span span
The span of the diagnostic.
Definition: diagnostic.h:118
DiagnosticBuilder(DiagnosticLevel level, Span span)
Definition: diagnostic.h:136
SourceName source_name
The source name.
Definition: diagnostic.h:115
DiagnosticBuilder & operator<<(const T &val)
Definition: diagnostic.h:126
DiagnosticLevel level
The level.
Definition: diagnostic.h:112
DiagnosticBuilder()
Definition: diagnostic.h:131
ObjectRef loc
The object location at which to report an error.
Definition: diagnostic.h:123
Definition: diagnostic.h:189
ffi::Array< Diagnostic > diagnostics
The set of diagnostics to report.
Definition: diagnostic.h:195
static constexpr TVMFFISEqHashKind _type_s_eq_hash_kind
Definition: diagnostic.h:207
static void RegisterReflection()
Definition: diagnostic.h:200
IRModule module
The Module to report against.
Definition: diagnostic.h:192
DiagnosticRenderer renderer
The renderer set for the context.
Definition: diagnostic.h:198
TVM_FFI_DECLARE_OBJECT_INFO_FINAL("DiagnosticContext", DiagnosticContextNode, Object)
Definition: diagnostic.h:211
void Render()
Render the errors and raise a DiagnosticError exception.
void Emit(const Diagnostic &diagnostic)
Emit a diagnostic.
void EmitFatal(const Diagnostic &diagnostic)
Emit a diagnostic and then immediately attempt to render all errors.
TVM_FFI_DEFINE_OBJECT_REF_METHODS_NOTNULLABLE(DiagnosticContext, ObjectRef, DiagnosticContextNode)
DiagnosticContextNode * operator->()
Definition: diagnostic.h:233
DiagnosticContext(const IRModule &module, const DiagnosticRenderer &renderer)
static DiagnosticContext Default(const IRModule &source_map)
A compiler diagnostic message.
Definition: diagnostic.h:52
static constexpr TVMFFISEqHashKind _type_s_eq_hash_kind
Definition: diagnostic.h:77
ObjectRef loc
The object location at which to report an error.
Definition: diagnostic.h:65
ffi::String message
The diagnostic message.
Definition: diagnostic.h:67
DiagnosticLevel level
The level.
Definition: diagnostic.h:55
static void RegisterReflection()
Definition: diagnostic.h:69
Span span
The span at which to report an error.
Definition: diagnostic.h:57
TVM_FFI_DECLARE_OBJECT_INFO_FINAL("Diagnostic", DiagnosticNode, Object)
Display diagnostics in a given display format.
Definition: diagnostic.h:161
TVM_FFI_DECLARE_OBJECT_INFO_FINAL("DiagnosticRenderer", DiagnosticRendererNode, Object)
ffi::TypedFunction< void(DiagnosticContext ctx)> renderer
Definition: diagnostic.h:163
static void RegisterReflection()
Definition: diagnostic.h:165
Definition: diagnostic.h:172
DiagnosticRenderer(ffi::TypedFunction< void(DiagnosticContext ctx)> render)
void Render(const DiagnosticContext &ctx)
DiagnosticRendererNode * operator->()
Definition: diagnostic.h:180
TVM_FFI_DEFINE_OBJECT_REF_METHODS_NOTNULLABLE(DiagnosticRenderer, ObjectRef, DiagnosticRendererNode)
DiagnosticRenderer()
Definition: diagnostic.h:175
Definition: diagnostic.h:81
static DiagnosticBuilder Error(const Object *loc)
TVM_FFI_DEFINE_OBJECT_REF_METHODS_NOTNULLABLE(Diagnostic, ObjectRef, DiagnosticNode)
static DiagnosticBuilder Bug(ObjectRef loc)
Diagnostic(DiagnosticLevel level, Span span, const std::string &message)
static DiagnosticBuilder Warning(Span span)
static DiagnosticBuilder Note(ObjectRef loc)
static DiagnosticBuilder Warning(const Object *loc)
static DiagnosticBuilder Bug(Span span)
static DiagnosticBuilder Help(Span span)
static DiagnosticBuilder Note(const Object *loc)
static DiagnosticBuilder Bug(const Object *loc)
static DiagnosticBuilder Help(ObjectRef loc)
static DiagnosticBuilder Warning(ObjectRef loc)
static DiagnosticBuilder Error(Span span)
static DiagnosticBuilder Help(const Object *loc)
static DiagnosticBuilder Error(ObjectRef loc)
static DiagnosticBuilder Note(Span span)
Managed reference class to IRModuleNode.
Definition: module.h:256
The source name of a file span.
Definition: source_map.h:64
Definition: source_map.h:111
IRModule that holds the functions and type definitions.
Definition: repr_printer.h:91
Performance counters for profiling via the PAPI library.
Definition: analyzer.h:37
DiagnosticRenderer TerminalRenderer(std::ostream &ostream)
DiagnosticLevel
The diagnostic level, controls the printing of the message.
Definition: diagnostic.h:38