mirror of
https://github.com/capstone-engine/llvm-capstone.git
synced 2024-11-26 23:21:11 +00:00
89a92fb3ba
The constructor function was being defined without indicating its "__init__" name, which made it interpret it as a regular fuction rather than a constructor. When overload resolution failed, Pybind would attempt to print the arguments actually passed to the function, including "self", which is not initialized since the constructor couldn't be called. This would result in "__repr__" being called with "self" referencing an uninitialized MLIR C API object, which in turn would cause undefined behavior when attempting to print in C++. Even if the correct name is provided, the mechanism used by PybindAdaptors.h to bind constructors directly as "__init__" functions taking "self" is deprecated by Pybind. The new mechanism does not seem to have access to a fully-constructed "self" object (i.e., the constructor in C++ takes a `pybind11::detail::value_and_holder` that cannot be forwarded back to Python). Instead, redefine "__new__" to perform the required checks (there are no additional initialization needed for attributes and types as they are all wrappers around a C++ pointer). "__new__" can call its equivalent on a superclass without needing "self". Bump pybind11 dependency to 3.8.0, which is the first version that allows one to redefine "__new__". Reviewed By: stellaraccident Differential Revision: https://reviews.llvm.org/D117646
13 lines
604 B
CMake
13 lines
604 B
CMake
set(LLVM_TARGET_DEFINITIONS python_test_ops.td)
|
|
mlir_tablegen(lib/PythonTestDialect.h.inc -gen-dialect-decls)
|
|
mlir_tablegen(lib/PythonTestDialect.cpp.inc -gen-dialect-defs)
|
|
mlir_tablegen(lib/PythonTestOps.h.inc -gen-op-decls)
|
|
mlir_tablegen(lib/PythonTestOps.cpp.inc -gen-op-defs)
|
|
mlir_tablegen(lib/PythonTestAttributes.h.inc -gen-attrdef-decls)
|
|
mlir_tablegen(lib/PythonTestAttributes.cpp.inc -gen-attrdef-defs)
|
|
mlir_tablegen(lib/PythonTestTypes.h.inc -gen-typedef-decls)
|
|
mlir_tablegen(lib/PythonTestTypes.cpp.inc -gen-typedef-defs)
|
|
add_public_tablegen_target(MLIRPythonTestIncGen)
|
|
|
|
add_subdirectory(lib)
|