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

llvmlistbot at llvm.org llvmlistbot at llvm.org
Thu Feb 8 11:07:06 PST 2024


Author: Jeremy Kun
Date: 2024-02-08T11:06:43-08:00
New Revision: 3d71e4166de81bc3b86d127d9ac6607bda2b2755

URL: https://github.com/llvm/llvm-project/commit/3d71e4166de81bc3b86d127d9ac6607bda2b2755
DIFF: https://github.com/llvm/llvm-project/commit/3d71e4166de81bc3b86d127d9ac6607bda2b2755.diff

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

Added: 
    

Modified: 
    mlir/docs/Diagnostics.md

Removed: 
    


################################################################################
diff  --git a/mlir/docs/Diagnostics.md b/mlir/docs/Diagnostics.md
index 9819843c563ca4..82bc61dd8c3adf 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.


        


More information about the Mlir-commits mailing list