26 #ifndef TVM_IR_DIAGNOSTIC_H_
27 #define TVM_IR_DIAGNOSTIC_H_
47 class DiagnosticBuilder;
72 v->Visit(
"level", &
level);
73 v->Visit(
"span", &
span);
82 static constexpr
const char*
_type_key =
"Diagnostic";
130 template <
typename T>
148 std::stringstream stream_;
173 static constexpr
const char*
_type_key =
"DiagnosticRenderer";
186 ICHECK(
get() !=
nullptr);
205 v->Visit(
"module", &
module);
213 static constexpr
const char*
_type_key =
"DiagnosticContext";
240 ICHECK(
get() !=
nullptr);
Visitor class to get the attributes of an AST/IR node. The content is going to be called for each fie...
Definition: reflection.h:52
A wrapper around std::stringstream to build a diagnostic.
Definition: diagnostic.h:114
DiagnosticBuilder(DiagnosticLevel level, ObjectRef loc)
Definition: diagnostic.h:143
friend class Diagnostic
Definition: diagnostic.h:149
DiagnosticBuilder(const DiagnosticBuilder &builder)
Definition: diagnostic.h:138
Span span
The span of the diagnostic.
Definition: diagnostic.h:123
DiagnosticBuilder(DiagnosticLevel level, Span span)
Definition: diagnostic.h:141
SourceName source_name
The source name.
Definition: diagnostic.h:120
DiagnosticBuilder & operator<<(const T &val)
Definition: diagnostic.h:131
DiagnosticLevel level
The level.
Definition: diagnostic.h:117
DiagnosticBuilder()
Definition: diagnostic.h:136
ObjectRef loc
The object location at which to report an error.
Definition: diagnostic.h:128
Definition: diagnostic.h:193
static constexpr const char * _type_key
Definition: diagnostic.h:213
TVM_DECLARE_FINAL_OBJECT_INFO(DiagnosticContextNode, Object)
bool SEqualReduce(const DiagnosticContextNode *other, SEqualReducer equal) const
Definition: diagnostic.h:209
void VisitAttrs(AttrVisitor *v)
Definition: diagnostic.h:204
Array< Diagnostic > diagnostics
The set of diagnostics to report.
Definition: diagnostic.h:199
IRModule module
The Module to report against.
Definition: diagnostic.h:196
DiagnosticRenderer renderer
The renderer set for the context.
Definition: diagnostic.h:202
Definition: diagnostic.h:217
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:239
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:53
bool SEqualReduce(const DiagnosticNode *other, SEqualReducer equal) const
Definition: diagnostic.h:77
static constexpr const char * _type_key
Definition: diagnostic.h:82
ObjectRef loc
The object location at which to report an error.
Definition: diagnostic.h:66
String message
The diagnostic message.
Definition: diagnostic.h:68
TVM_DECLARE_FINAL_OBJECT_INFO(DiagnosticNode, Object)
void VisitAttrs(AttrVisitor *v)
Definition: diagnostic.h:71
DiagnosticLevel level
The level.
Definition: diagnostic.h:56
Span span
The span at which to report an error.
Definition: diagnostic.h:58
Display diagnostics in a given display format.
Definition: diagnostic.h:166
static constexpr const char * _type_key
Definition: diagnostic.h:173
TVM_DECLARE_FINAL_OBJECT_INFO(DiagnosticRendererNode, Object)
TypedPackedFunc< void(DiagnosticContext ctx)> renderer
Definition: diagnostic.h:168
void VisitAttrs(AttrVisitor *v)
Definition: diagnostic.h:171
Definition: diagnostic.h:177
DiagnosticRenderer(TypedPackedFunc< void(DiagnosticContext ctx)> render)
void Render(const DiagnosticContext &ctx)
DiagnosticRendererNode * operator->()
Definition: diagnostic.h:185
TVM_DEFINE_NOTNULLABLE_OBJECT_REF_METHODS(DiagnosticRenderer, ObjectRef, DiagnosticRendererNode)
DiagnosticRenderer()
Definition: diagnostic.h:180
Definition: diagnostic.h:86
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:366
A Reducer class to reduce the structural equality result of two objects.
Definition: structural_equal.h:137
The source name of a file span.
Definition: source_map.h:67
Definition: source_map.h:120
Array, container representing a contiguous sequence of ObjectRefs.
Definition: array.h:289
Base class of all object reference.
Definition: object.h:519
const Object * get() const
Definition: object.h:554
Object * get_mutable() const
Definition: object.h:607
base class of all object containers.
Definition: object.h:171
Reference to string objects.
Definition: string.h:98
Please refer to TypedPackedFunc<R(Args..)>.
Definition: packed_func.h:63
IRModule that holds the functions and type definitions.
runtime implementation for LibTorch/TorchScript.
Definition: analyzer.h:36
PrimExpr equal(PrimExpr a, PrimExpr b, Span span=Span())
equal
DiagnosticRenderer TerminalRenderer(std::ostream &ostream)
DiagnosticLevel
The diagnostic level, controls the printing of the message.
Definition: diagnostic.h:39