Skip to content

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

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Feb 8, 2024

Conversation

j2kun
Copy link
Contributor

@j2kun j2kun commented Nov 29, 2023

No description provided.

@llvmbot llvmbot added the mlir label Nov 29, 2023
@llvmbot
Copy link
Member

llvmbot commented Nov 29, 2023

@llvm/pr-subscribers-mlir

Author: Jeremy Kun (j2kun)

Changes

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

1 Files Affected:

  • (modified) mlir/docs/Diagnostics.md (+8)
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.

Copy link
Collaborator

@joker-eph joker-eph left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

@j2kun
Copy link
Contributor Author

j2kun commented Feb 8, 2024

I will need someone to merge this on for me please, thanks!

@j2kun j2kun force-pushed the diagnostic-friend-docs branch from 7137d88 to 0cf9fca Compare February 8, 2024 19:03
@joker-eph
Copy link
Collaborator

Please ask for commit access @j2kun :)

@joker-eph joker-eph merged commit 3d71e41 into llvm:main Feb 8, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants