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
```
This commit is contained in:
Ralf W. Grosse-Kunstleve 2022-07-01 16:11:55 -07:00
parent 44966dab16
commit 68b155a10c
2 changed files with 9 additions and 1 deletions

View File

@ -64,6 +64,10 @@ struct src_loc {
#endif
#ifdef PYBIND11_DETAIL_DESCR_SRC_LOC_ON
namespace {
#endif
/* Concatenate type signatures at compile time */
template <size_t N, typename... Ts>
struct descr {
@ -212,5 +216,9 @@ constexpr descr<N + 2, Ts...> type_descr(const descr<N, Ts...> &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)

View File

@ -199,7 +199,7 @@ tu_local_no_data_always_false
type_caster_odr_guard_impl(
typeid(IntrinsicType),
get_type_caster_source_file_line<TypeCasterType>::source_file_line.text,
get_type_caster_source_file_line<TypeCasterType>::source_file_line.sloc,
TypeCasterType::name.sloc,
PYBIND11_DETAIL_TYPE_CASTER_ODR_GUARD_IMPL_THROW_DISABLED);
return tu_local_no_data_always_false();
}();