From 68b155a10c9c6f40d91df77aa085288dd4db7cef Mon Sep 17 00:00:00 2001 From: "Ralf W. Grosse-Kunstleve" Date: Fri, 1 Jul 2022 16:11:55 -0700 Subject: [PATCH] Use `TypeCasterType::name.sloc` instead of `source_file_line.sloc` Manual re-verification: ``` +++ b/tests/test_type_caster_odr_guard_2.cpp - // m.def("pass_vector_type_mrc", mrc_ns::pass_vector_type_mrc); + m.def("pass_vector_type_mrc", mrc_ns::pass_vector_type_mrc); ``` ``` > assert num_violations == 1 E assert 2 == 1 num_violations = 2 test_type_caster_odr_guard_1.py:51: AssertionError ``` --- include/pybind11/detail/descr.h | 8 ++++++++ include/pybind11/detail/type_caster_odr_guard.h | 2 +- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/include/pybind11/detail/descr.h b/include/pybind11/detail/descr.h index e4baa383b..e5a5a77e2 100644 --- a/include/pybind11/detail/descr.h +++ b/include/pybind11/detail/descr.h @@ -64,6 +64,10 @@ struct src_loc { #endif +#ifdef PYBIND11_DETAIL_DESCR_SRC_LOC_ON +namespace { +#endif + /* Concatenate type signatures at compile time */ template struct descr { @@ -212,5 +216,9 @@ constexpr descr type_descr(const descr &descr) { return const_name("{", src_loc{nullptr, 0}) + descr + const_name("}"); } +#ifdef PYBIND11_DETAIL_DESCR_SRC_LOC_ON +} // namespace +#endif + PYBIND11_NAMESPACE_END(detail) PYBIND11_NAMESPACE_END(PYBIND11_NAMESPACE) diff --git a/include/pybind11/detail/type_caster_odr_guard.h b/include/pybind11/detail/type_caster_odr_guard.h index 4ae6d91fe..bfe28a79b 100644 --- a/include/pybind11/detail/type_caster_odr_guard.h +++ b/include/pybind11/detail/type_caster_odr_guard.h @@ -199,7 +199,7 @@ tu_local_no_data_always_false type_caster_odr_guard_impl( typeid(IntrinsicType), get_type_caster_source_file_line::source_file_line.text, - get_type_caster_source_file_line::source_file_line.sloc, + TypeCasterType::name.sloc, PYBIND11_DETAIL_TYPE_CASTER_ODR_GUARD_IMPL_THROW_DISABLED); return tu_local_no_data_always_false(); }();