clang 24.0.0git
CIRDiagnosticHandler.h
Go to the documentation of this file.
1//===--- CIRDiagnosticHandler.h - Route MLIR diags to clang ----*- 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 CLANG_LIB_CIR_FRONTENDACTION_CIRDIAGNOSTICHANDLER_H
10#define CLANG_LIB_CIR_FRONTENDACTION_CIRDIAGNOSTICHANDLER_H
11
12#include "mlir/IR/Diagnostics.h"
13
14namespace clang {
16class FileManager;
17class SourceLocation;
18class SourceManager;
19} // namespace clang
20
21namespace mlir {
22class Location;
23class MLIRContext;
24} // namespace mlir
25
26namespace cir {
27
28/// Routes MLIR-side diagnostics emitted during CIR passes, the verifier, and
29/// CIR-to-LLVM lowering through the surrounding clang::DiagnosticsEngine.
30///
31/// MLIR locations carrying file/line/column info are translated to a
32/// clang::SourceLocation via the active SourceManager + FileManager so errors
33/// surface in the user's preferred format. Locations that cannot be translated
34/// fall back to an invalid clang::SourceLocation.
35class CIRDiagnosticHandler : public mlir::ScopedDiagnosticHandler {
36public:
37 CIRDiagnosticHandler(mlir::MLIRContext *ctx, clang::DiagnosticsEngine &diags,
39 clang::FileManager &fileMgr);
40
41private:
42 mlir::LogicalResult handle(mlir::Diagnostic &diag);
43 void emit(mlir::Diagnostic &diag, bool isNote);
44 clang::SourceLocation translateLoc(mlir::Location loc);
45
48 clang::FileManager &FileMgr;
49};
50
51} // namespace cir
52
53#endif // CLANG_LIB_CIR_FRONTENDACTION_CIRDIAGNOSTICHANDLER_H
CIRDiagnosticHandler(mlir::MLIRContext *ctx, clang::DiagnosticsEngine &diags, clang::SourceManager &srcMgr, clang::FileManager &fileMgr)
Concrete class used by the front-end to report problems and issues.
Definition Diagnostic.h:234
Implements support for file system lookup, file system caching, and directory search management.
Definition FileManager.h:52
Encodes a location in the source.
This class handles loading and caching of source files into memory.
The JSON file list parser is used to communicate input to InstallAPI.