[Mlir-commits] [mlir] 2b28679 - [MLIR] Add a non-const ActionHandler getter to MLIRContext (#199652)
llvmlistbot at llvm.org
llvmlistbot at llvm.org
Tue May 26 23:42:55 PDT 2026
Author: Kigyosi Alexandru
Date: 2026-05-27T14:42:50+08:00
New Revision: 2b286794010f5549d109b37941a4c3171489c5d8
URL: https://github.com/llvm/llvm-project/commit/2b286794010f5549d109b37941a4c3171489c5d8
DIFF: https://github.com/llvm/llvm-project/commit/2b286794010f5549d109b37941a4c3171489c5d8.diff
LOG: [MLIR] Add a non-const ActionHandler getter to MLIRContext (#199652)
#197230 added a getter for the ActionHandler, but only returns a const
ref with a non-const accessor.
Instead provide both variants: a const accessor returning a const ref
and non-const one returning a mutable ref.
Added:
Modified:
mlir/include/mlir/IR/MLIRContext.h
mlir/lib/IR/MLIRContext.cpp
Removed:
################################################################################
diff --git a/mlir/include/mlir/IR/MLIRContext.h b/mlir/include/mlir/IR/MLIRContext.h
index ab121777a1296..12cd00b60215e 100644
--- a/mlir/include/mlir/IR/MLIRContext.h
+++ b/mlir/include/mlir/IR/MLIRContext.h
@@ -211,6 +211,7 @@ class MLIRContext {
// This is effectively private given that only MLIRContext.cpp can see the
// MLIRContextImpl type.
MLIRContextImpl &getImpl() { return *impl; }
+ const MLIRContextImpl &getImpl() const { return *impl; }
/// Returns the diagnostic engine for this context.
DiagnosticEngine &getDiagEngine();
@@ -269,7 +270,8 @@ class MLIRContext {
/// Return a reference to the currently registered action handler. Its target
/// can be used to gain access to the handler's state, if any.
- const HandlerTy &getActionHandler();
+ const HandlerTy &getActionHandler() const;
+ HandlerTy &getActionHandler();
/// Return true if a valid ActionHandler is set.
bool hasActionHandler();
diff --git a/mlir/lib/IR/MLIRContext.cpp b/mlir/lib/IR/MLIRContext.cpp
index 624121c2733ba..da891a7e6e014 100644
--- a/mlir/lib/IR/MLIRContext.cpp
+++ b/mlir/lib/IR/MLIRContext.cpp
@@ -380,7 +380,11 @@ void MLIRContext::registerActionHandler(HandlerTy handler) {
getImpl().actionHandler = std::move(handler);
}
-const MLIRContext::HandlerTy &MLIRContext::getActionHandler() {
+const MLIRContext::HandlerTy &MLIRContext::getActionHandler() const {
+ return getImpl().actionHandler;
+}
+
+MLIRContext::HandlerTy &MLIRContext::getActionHandler() {
return getImpl().actionHandler;
}
More information about the Mlir-commits
mailing list