xref: /llvm-project/mlir/include/mlir/CAPI/Diagnostics.h (revision 7b5dfb400a67f03122b43cd5d59b8b1ef6d00147)
1 //===- IR.h - C API Utils for MLIR Diagnostics ------------------*- C++ -*-===//
2 //
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6 //
7 //===----------------------------------------------------------------------===//
8 
9 #ifndef MLIR_CAPI_DIAGNOSTICS_H
10 #define MLIR_CAPI_DIAGNOSTICS_H
11 
12 #include "mlir-c/Diagnostics.h"
13 #include <cassert>
14 
15 namespace mlir {
16 class Diagnostic;
17 } // namespace mlir
18 
unwrap(MlirDiagnostic diagnostic)19 inline mlir::Diagnostic &unwrap(MlirDiagnostic diagnostic) {
20   assert(diagnostic.ptr && "unexpected null diagnostic");
21   return *(static_cast<mlir::Diagnostic *>(diagnostic.ptr));
22 }
23 
wrap(mlir::Diagnostic & diagnostic)24 inline MlirDiagnostic wrap(mlir::Diagnostic &diagnostic) {
25   return {&diagnostic};
26 }
27 
28 #endif // MLIR_CAPI_DIAGNOSTICS_H
29