[all-commits] [llvm/llvm-project] 06488f: [mlir] Make the Python binding type casters well-f...

Nikhil Kalra via All-commits all-commits at lists.llvm.org
Wed Jul 8 20:51:11 PDT 2026


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: 06488f6c8d8941cda4973df32d420c71877be3e6
      https://github.com/llvm/llvm-project/commit/06488f6c8d8941cda4973df32d420c71877be3e6
  Author: Nikhil Kalra <nikhil.kalra at gmail.com>
  Date:   2026-07-08 (Wed, 08 Jul 2026)

  Changed paths:
    M mlir/include/mlir/Bindings/Python/IRCore.h

  Log Message:
  -----------
  [mlir] Make the Python binding type casters well-formed under C++23 (#208093)

The nanobind type/attr/loc/value casters in IRCore.h return a by-value
PyType/PyAttribute/PyLocation/PyValue as their DerivedTy result.

Under pre-C++23 rules, this was a rvalue that would decay to a lvalue
when passed to the DerivedTy constructor.

Under C++23's P2266 (implicit move on return), that return operand is an
xvalue, which cannot bind the PyConcrete* constructors that take a
non-const lvalue reference.

This patch constructs the derived type explicitly (return
DerivedTy(arg);) using the lvalue constructor; this preserves the
pre-C++23 behavior on C++23 builds.



To unsubscribe from these emails, change your notification settings at https://github.com/llvm/llvm-project/settings/notifications


More information about the All-commits mailing list