MLIR  20.0.0git
Diagnostics.h
Go to the documentation of this file.
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 
19 inline mlir::Diagnostic &unwrap(MlirDiagnostic diagnostic) {
20  assert(diagnostic.ptr && "unexpected null diagnostic");
21  return *(static_cast<mlir::Diagnostic *>(diagnostic.ptr));
22 }
23 
24 inline MlirDiagnostic wrap(mlir::Diagnostic &diagnostic) {
25  return {&diagnostic};
26 }
27 
28 #endif // MLIR_CAPI_DIAGNOSTICS_H
This class contains all of the information necessary to report a diagnostic to the DiagnosticEngine.
Definition: Diagnostics.h:155
mlir::Diagnostic & unwrap(MlirDiagnostic diagnostic)
Definition: Diagnostics.h:19
MlirDiagnostic wrap(mlir::Diagnostic &diagnostic)
Definition: Diagnostics.h:24
Include the generated interface declarations.
An opaque reference to a diagnostic, always owned by the diagnostics engine (context).
Definition: Diagnostics.h:26