[Mlir-commits] [mlir] [docs]: Add a note about using custom types with diagnostics (PR #73818)

llvmlistbot at llvm.org llvmlistbot at llvm.org
Wed Nov 29 08:47:56 PST 2023


llvmbot wrote:


<!--LLVM PR SUMMARY COMMENT-->

@llvm/pr-subscribers-mlir

Author: Jeremy Kun (j2kun)

<details>
<summary>Changes</summary>



---
Full diff: https://github.com/llvm/llvm-project/pull/73818.diff


1 Files Affected:

- (modified) mlir/docs/Diagnostics.md (+8) 


``````````diff
diff --git a/mlir/docs/Diagnostics.md b/mlir/docs/Diagnostics.md
index 9819843c563ca48..82bc61dd8c3adfb 100644
--- a/mlir/docs/Diagnostics.md
+++ b/mlir/docs/Diagnostics.md
@@ -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.

``````````

</details>


https://github.com/llvm/llvm-project/pull/73818


More information about the Mlir-commits mailing list