[Mlir-commits] [mlir] [mlir][python] Add stable ABI (abi3) support (PR #183856)

llvmlistbot at llvm.org llvmlistbot at llvm.org
Fri Feb 27 14:53:27 PST 2026


github-actions[bot] wrote:

<!--LLVM CODE FORMAT COMMENT: {clang-format}-->


:warning: C/C++ code formatter, clang-format found issues in your code. :warning:

<details>
<summary>
You can test this locally with the following command:
</summary>

``````````bash
git-clang-format --diff origin/main HEAD --extensions cpp,h -- mlir/include/mlir/Bindings/Python/IRCore.h mlir/include/mlir/Bindings/Python/NanobindAdaptors.h mlir/include/mlir/Bindings/Python/NanobindUtils.h mlir/lib/Bindings/Python/IRAttributes.cpp mlir/lib/Bindings/Python/IRCore.cpp --diff_from_common_commit
``````````

:warning:
The reproduction instructions above might return results for more than one PR
in a stack if you are using a stacked PR workflow. You can limit the results by
changing `origin/main` to the base branch/commit you want to compare against.
:warning:

</details>

<details>
<summary>
View the diff from clang-format here.
</summary>

``````````diff
diff --git a/mlir/include/mlir/Bindings/Python/NanobindUtils.h b/mlir/include/mlir/Bindings/Python/NanobindUtils.h
index 53c8b823b..15ed8c731 100644
--- a/mlir/include/mlir/Bindings/Python/NanobindUtils.h
+++ b/mlir/include/mlir/Bindings/Python/NanobindUtils.h
@@ -412,8 +412,7 @@ public:
          })},
         // mp_subscript is used for both slices and integer lookups.
         {Py_mp_subscript,
-         (void *)(+[](PyObject *rawSelf,
-                       PyObject *rawSubscript) -> PyObject * {
+         (void *)(+[](PyObject *rawSelf, PyObject *rawSubscript) -> PyObject * {
            auto self = nanobind::cast<Derived *>(nanobind::handle(rawSelf));
            Py_ssize_t index =
                PyNumber_AsSsize_t(rawSubscript, PyExc_IndexError);
diff --git a/mlir/lib/Bindings/Python/IRCore.cpp b/mlir/lib/Bindings/Python/IRCore.cpp
index f9594f382..48dd5a7f5 100644
--- a/mlir/lib/Bindings/Python/IRCore.cpp
+++ b/mlir/lib/Bindings/Python/IRCore.cpp
@@ -2735,8 +2735,8 @@ MlirLocation tracebackToLocation(MlirContext ctx) {
     // Use attribute access instead of direct struct member access for
     // forward compatibility with the limited (stable) API where
     // PyCodeObject is opaque.
-    nb::object fileNameObj =
-        nb::steal(PyObject_GetAttrString(reinterpret_cast<PyObject *>(code), "co_filename"));
+    nb::object fileNameObj = nb::steal(PyObject_GetAttrString(
+        reinterpret_cast<PyObject *>(code), "co_filename"));
     auto fileNameStr = nb::cast<std::string>(fileNameObj);
     std::string_view fileName(fileNameStr);
     if (!PyGlobals::get().getTracebackLoc().isUserTracebackFilename(fileName))
@@ -2744,8 +2744,8 @@ MlirLocation tracebackToLocation(MlirContext ctx) {
 
     // co_qualname and PyCode_Addr2Location added in py3.11
 #if PY_VERSION_HEX < 0x030B00F0
-    nb::object nameObj =
-        nb::steal(PyObject_GetAttrString(reinterpret_cast<PyObject *>(code), "co_name"));
+    nb::object nameObj = nb::steal(
+        PyObject_GetAttrString(reinterpret_cast<PyObject *>(code), "co_name"));
     std::string name = nb::cast<std::string>(nameObj);
     std::string_view funcName(name);
     int startLine = PyFrame_GetLineNumber(pyFrame);
@@ -2753,8 +2753,8 @@ MlirLocation tracebackToLocation(MlirContext ctx) {
         ctx, mlirStringRefCreate(fileName.data(), fileName.size()), startLine,
         0);
 #else
-    nb::object nameObj =
-        nb::steal(PyObject_GetAttrString(reinterpret_cast<PyObject *>(code), "co_qualname"));
+    nb::object nameObj = nb::steal(PyObject_GetAttrString(
+        reinterpret_cast<PyObject *>(code), "co_qualname"));
     std::string name = nb::cast<std::string>(nameObj);
     std::string_view funcName(name);
     int startLine, startCol, endLine, endCol;

``````````

</details>


https://github.com/llvm/llvm-project/pull/183856


More information about the Mlir-commits mailing list