From 040180078db70b8673932d7e5615920d64ceeaf5 Mon Sep 17 00:00:00 2001 From: breathe1 Date: Fri, 15 Nov 2024 17:15:09 +0000 Subject: [PATCH] Ensure that destructor's needed by lldb make it into binary in non-inlined fashion --- Eigen/src/Core/EigenBase.h | 14 ++++++++++++++ test/dense_storage.cpp | 7 +++++++ 2 files changed, 21 insertions(+) diff --git a/Eigen/src/Core/EigenBase.h b/Eigen/src/Core/EigenBase.h index 6d167006a..7a5fdc8e0 100644 --- a/Eigen/src/Core/EigenBase.h +++ b/Eigen/src/Core/EigenBase.h @@ -109,6 +109,20 @@ struct EigenBase { EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE DeviceWrapper device(Device& device); template EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE DeviceWrapper device(Device& device) const; + + /** + * By defining the empty destructor here, subclasses which override the destructor with `~SubClass = default` will not + * inline their destructor. This ensures ensures the destructor symbol will exists in the binary. + * This is needed to support expression evaluation in lldb (for _some_ reason). Without this hack, the destructor + * will be inlined and lldb will produce a missing symbol error (referring to eg ~MatrixBase destructor) when trying + * to evaluate an expression that returns an Eigen::Matrix. + * + * We use the normal default destructor to make the object trivially destructible when not debugging or when testing + * as the testsuite asserts std::is_trivially_destructible + */ +#if !defined(EIGEN_NO_DEBUG) && !defined(EIGEN_TESTING_PLAINOBJECT_CTOR) + EIGEN_DEVICE_FUNC ~EigenBase() {} +#endif }; /*************************************************************************** diff --git a/test/dense_storage.cpp b/test/dense_storage.cpp index 0f6ab64a1..d394a94f9 100644 --- a/test/dense_storage.cpp +++ b/test/dense_storage.cpp @@ -38,6 +38,13 @@ static_assert(std::is_trivially_default_constructible::value, "Array4f // all fixed-size, fixed-dimension plain object types are trivially move constructible static_assert(std::is_trivially_move_constructible::value, "Matrix4f not trivially_move_constructible"); static_assert(std::is_trivially_move_constructible::value, "Array4f not trivially_move_constructible"); +// all statically-allocated plain object types are trivially destructible +static_assert(std::is_trivially_destructible::value, "Matrix4f not trivially_destructible"); +static_assert(std::is_trivially_destructible::value, "Array4f not trivially_destructible"); +static_assert(std::is_trivially_destructible>::value, + "Matrix4X44 not trivially_destructible"); +static_assert(std::is_trivially_destructible>::value, + "Array4X44 not trivially_destructible"); #if !defined(EIGEN_DENSE_STORAGE_CTOR_PLUGIN) // all fixed-size, fixed-dimension plain object types are trivially copy constructible static_assert(std::is_trivially_copy_constructible::value, "Matrix4f not trivially_copy_constructible");