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>()
78 static constexpr
const char*
_type_key =
"Diagnostic";
126 template <
typename T>
144 std::stringstream stream_;
171 static constexpr
const char*
_type_key =
"DiagnosticRenderer";
184 ICHECK(get() !=
nullptr);
204 refl::ObjectDef<DiagnosticContextNode>()
210 static constexpr
const char*
_type_key =
"DiagnosticContext";
237 ICHECK(get() !=
nullptr);
A wrapper around std::stringstream to build a diagnostic.
Definition: diagnostic.h:110
DiagnosticBuilder(DiagnosticLevel level, ObjectRef loc)
Definition: diagnostic.h:139
friend class Diagnostic
Definition: diagnostic.h:145
DiagnosticBuilder(const DiagnosticBuilder &builder)
Definition: diagnostic.h:134
Span span
The span of the diagnostic.
Definition: diagnostic.h:119
DiagnosticBuilder(DiagnosticLevel level, Span span)
Definition: diagnostic.h:137
SourceName source_name
The source name.
Definition: diagnostic.h:116
DiagnosticBuilder & operator<<(const T &val)
Definition: diagnostic.h:127
DiagnosticLevel level
The level.
Definition: diagnostic.h:113
DiagnosticBuilder()
Definition: diagnostic.h:132
ObjectRef loc
The object location at which to report an error.
Definition: diagnostic.h:124
Definition: diagnostic.h:191
static constexpr const char * _type_key
Definition: diagnostic.h:210
TVM_DECLARE_FINAL_OBJECT_INFO(DiagnosticContextNode, Object)
static constexpr TVMFFISEqHashKind _type_s_eq_hash_kind
Definition: diagnostic.h:209
static void RegisterReflection()
Definition: diagnostic.h:202
Array< Diagnostic > diagnostics
The set of diagnostics to report.
Definition: diagnostic.h:197
IRModule module
The Module to report against.
Definition: diagnostic.h:194
DiagnosticRenderer renderer
The renderer set for the context.
Definition: diagnostic.h:200
Definition: diagnostic.h:214
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.
DiagnosticContextNode * operator->()
Definition: diagnostic.h:236
DiagnosticContext(const IRModule &module, const DiagnosticRenderer &renderer)
static DiagnosticContext Default(const IRModule &source_map)
TVM_DEFINE_NOTNULLABLE_OBJECT_REF_METHODS(DiagnosticContext, ObjectRef, DiagnosticContextNode)
A compiler diagnostic message.
Definition: diagnostic.h:52
static constexpr TVMFFISEqHashKind _type_s_eq_hash_kind
Definition: diagnostic.h:77
static constexpr const char * _type_key
Definition: diagnostic.h:78
ObjectRef loc
The object location at which to report an error.
Definition: diagnostic.h:65
String message
The diagnostic message.
Definition: diagnostic.h:67
TVM_DECLARE_FINAL_OBJECT_INFO(DiagnosticNode, Object)
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
Display diagnostics in a given display format.
Definition: diagnostic.h:162
static constexpr const char * _type_key
Definition: diagnostic.h:171
TVM_DECLARE_FINAL_OBJECT_INFO(DiagnosticRendererNode, Object)
ffi::TypedFunction< void(DiagnosticContext ctx)> renderer
Definition: diagnostic.h:164
static void RegisterReflection()
Definition: diagnostic.h:166
Definition: diagnostic.h:175
DiagnosticRenderer(ffi::TypedFunction< void(DiagnosticContext ctx)> render)
void Render(const DiagnosticContext &ctx)
DiagnosticRendererNode * operator->()
Definition: diagnostic.h:183
TVM_DEFINE_NOTNULLABLE_OBJECT_REF_METHODS(DiagnosticRenderer, ObjectRef, DiagnosticRendererNode)
DiagnosticRenderer()
Definition: diagnostic.h:178
Definition: diagnostic.h:82
static DiagnosticBuilder Error(const Object *loc)
TVM_DEFINE_NOTNULLABLE_OBJECT_REF_METHODS(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:257
The source name of a file span.
Definition: source_map.h:65
Definition: source_map.h:113
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