Add userData to the diagnostic handler C API
authorGeorge <>
Mon, 23 Nov 2020 17:52:17 +0000 (09:52 -0800)
committerGeorge <>
Mon, 23 Nov 2020 17:52:45 +0000 (09:52 -0800)
commit0c5cff300ffa1d5cc55f2b11e4546f18b3389aa6
treed7732a592bf97ab7455605b85448709afba1303c
parent3a1c6cec15e32e4aa5593ce624915bda790dadff
Add userData to the diagnostic handler C API

Previously, there was no way to add context to the diagnostic engine via the C API. Adding this ability makes it much easier to reason about memory ownership, particularly in reference-counted languages such as Swift. There are more details in the review comments.

Reviewed By: ftynse, mehdi_amini

Differential Revision: https://reviews.llvm.org/D91738
mlir/include/mlir-c/Diagnostics.h
mlir/lib/CAPI/IR/Diagnostics.cpp
mlir/test/CAPI/ir.c