[docs]: Add a note about using custom types with diagnostics (#73818)

This commit is contained in:
Jeremy Kun 2024-02-08 11:06:43 -08:00 committed by GitHub
parent a56fa161ab
commit 3d71e4166d
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -119,6 +119,14 @@ op->emitError() << anotherOp;
op->emitRemark() << anotherOp;
```
To make a custom type compatible with Diagnostics, one must implement the
following friend function.
```c++
friend mlir::Diagnostic &operator<<(
mlir::Diagnostic &diagnostic, const MyType &foo);
```
### Attaching notes
Unlike many other compiler frameworks, notes in MLIR cannot be emitted directly.