[Mlir-commits] [mlir] [mlir][Python] fix namespace shadowing (PR #175077)
Maksim Levental
llvmlistbot at llvm.org
Thu Jan 8 14:23:42 PST 2026
https://github.com/makslevental updated https://github.com/llvm/llvm-project/pull/175077
>From 3938502779b0614514c893156c3c20d2f99f3e02 Mon Sep 17 00:00:00 2001
From: makslevental <maksim.levental at gmail.com>
Date: Thu, 8 Jan 2026 14:01:16 -0800
Subject: [PATCH] [mlir][Python] fix namespace shadowing
Co-authored-by: Abhishek Varma <abhvarma at amd.com>
---
mlir/include/mlir/Bindings/Python/IRCore.h | 22 +++++++++++-----------
1 file changed, 11 insertions(+), 11 deletions(-)
diff --git a/mlir/include/mlir/Bindings/Python/IRCore.h b/mlir/include/mlir/Bindings/Python/IRCore.h
index 59dc496c9e206..330318683c15e 100644
--- a/mlir/include/mlir/Bindings/Python/IRCore.h
+++ b/mlir/include/mlir/Bindings/Python/IRCore.h
@@ -947,7 +947,7 @@ class MLIR_PYTHON_API_EXPORTED PyConcreteType : public BaseTy {
if (!DerivedTy::isaFunction(orig)) {
auto origRepr =
nanobind::cast<std::string>(nanobind::repr(nanobind::cast(orig)));
- throw nanobind::value_error((llvm::Twine("Cannot cast type to ") +
+ throw nanobind::value_error((::llvm::Twine("Cannot cast type to ") +
DerivedTy::pyClassName + " (from " +
origRepr + ")")
.str()
@@ -966,7 +966,7 @@ class MLIR_PYTHON_API_EXPORTED PyConcreteType : public BaseTy {
if (DerivedTy::getTypeIdFunction)
return PyTypeID(DerivedTy::getTypeIdFunction());
throw nanobind::attribute_error(
- (DerivedTy::pyClassName + llvm::Twine(" has no typeid."))
+ (DerivedTy::pyClassName + ::llvm::Twine(" has no typeid."))
.str()
.c_str());
},
@@ -1080,7 +1080,7 @@ class MLIR_PYTHON_API_EXPORTED PyConcreteAttribute : public BaseTy {
if (!DerivedTy::isaFunction(orig)) {
auto origRepr =
nanobind::cast<std::string>(nanobind::repr(nanobind::cast(orig)));
- throw nanobind::value_error((llvm::Twine("Cannot cast attribute to ") +
+ throw nanobind::value_error((::llvm::Twine("Cannot cast attribute to ") +
DerivedTy::pyClassName + " (from " +
origRepr + ")")
.str()
@@ -1110,7 +1110,7 @@ class MLIR_PYTHON_API_EXPORTED PyConcreteAttribute : public BaseTy {
if (DerivedTy::getTypeIdFunction)
return PyTypeID(DerivedTy::getTypeIdFunction());
throw nanobind::attribute_error(
- (DerivedTy::pyClassName + llvm::Twine(" has no typeid."))
+ (DerivedTy::pyClassName + ::llvm::Twine(" has no typeid."))
.str()
.c_str());
},
@@ -1324,7 +1324,7 @@ class MLIR_PYTHON_API_EXPORTED PySymbolTable {
/// Custom exception that allows access to error diagnostic information. This is
/// converted to the `ir.MLIRError` python exception when thrown.
struct MLIR_PYTHON_API_EXPORTED MLIRError {
- MLIRError(llvm::Twine message,
+ MLIRError(::llvm::Twine message,
std::vector<PyDiagnostic::DiagnosticInfo> &&errorDiagnostics = {})
: message(message.str()), errorDiagnostics(std::move(errorDiagnostics)) {}
std::string message;
@@ -1544,7 +1544,7 @@ class MLIR_PYTHON_API_EXPORTED PyConcreteValue : public PyValue {
if (!DerivedTy::isaFunction(orig.get())) {
auto origRepr =
nanobind::cast<std::string>(nanobind::repr(nanobind::cast(orig)));
- throw nanobind::value_error((Twine("Cannot cast value to ") +
+ throw nanobind::value_error((::llvm::Twine("Cannot cast value to ") +
DerivedTy::pyClassName + " (from " +
origRepr + ")")
.str()
@@ -1555,11 +1555,11 @@ class MLIR_PYTHON_API_EXPORTED PyConcreteValue : public PyValue {
/// Binds the Python module objects to functions of this class.
static void bind(nanobind::module_ &m) {
- auto cls = ClassTy(
- m, DerivedTy::pyClassName, nanobind::is_generic(),
- nanobind::sig((Twine("class ") + DerivedTy::pyClassName + "(Value[_T])")
- .str()
- .c_str()));
+ auto cls = ClassTy(m, DerivedTy::pyClassName, nanobind::is_generic(),
+ nanobind::sig((::llvm::Twine("class ") +
+ DerivedTy::pyClassName + "(Value[_T])")
+ .str()
+ .c_str()));
cls.def(nanobind::init<PyValue &>(), nanobind::keep_alive<0, 1>(),
nanobind::arg("value"));
cls.def(
More information about the Mlir-commits
mailing list