| 1 | //===- TestDiagnosticsNext.cpp - Test Diagnostic Utilities ----------------===// |
|---|---|
| 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 | // This file contains test passes for the next diagnostic manipulator. |
| 10 | // |
| 11 | //===----------------------------------------------------------------------===// |
| 12 | |
| 13 | #include "mlir/IR/BuiltinOps.h" |
| 14 | #include "mlir/IR/Diagnostics.h" |
| 15 | #include "mlir/IR/SymbolTable.h" |
| 16 | #include "mlir/Pass/Pass.h" |
| 17 | #include "llvm/ADT/StringRef.h" |
| 18 | |
| 19 | using namespace mlir; |
| 20 | |
| 21 | namespace { |
| 22 | struct TestDiagnosticsNextPass |
| 23 | : public PassWrapper<TestDiagnosticsNextPass, |
| 24 | InterfacePass<SymbolOpInterface>> { |
| 25 | MLIR_DEFINE_EXPLICIT_INTERNAL_INLINE_TYPE_ID(TestDiagnosticsNextPass) |
| 26 | |
| 27 | StringRef getArgument() const final { return "test-diagnostic-next"; } |
| 28 | StringRef getDescription() const final { |
| 29 | return "Test diagnostic next support."; |
| 30 | } |
| 31 | |
| 32 | void runOnOperation() override { |
| 33 | getOperation()->walk(callback: [](SymbolOpInterface op) { |
| 34 | StringRef opName = op.getNameAttr(); |
| 35 | InFlightDiagnostic diag = op->emitRemark(message: opName) << "1"<< diag::next; |
| 36 | diag << opName << "2"<< diag::next << opName << "3"; |
| 37 | }); |
| 38 | } |
| 39 | }; |
| 40 | |
| 41 | } // namespace |
| 42 | |
| 43 | namespace mlir { |
| 44 | namespace test { |
| 45 | void registerTestDiagnosticsNextPass() { |
| 46 | PassRegistration<TestDiagnosticsNextPass>{}; |
| 47 | } |
| 48 | } // namespace test |
| 49 | } // namespace mlir |
| 50 |