mirror of
https://github.com/JakeHillion/object-introspection.git
synced 2024-09-19 19:19:05 +01:00
tbv2: account for duplicate types when emitting name providers
ClangTypeParser has emitted a duplicate type for `std::allocatr<int8_t>`. Rather than fixing this, add the same check the compiler will do for the duplicate templates that `addNames` emits. That is, `template<> NameProvider<Foo>` will collide if `Foo` is used twice. We can do this by adding a set of these strings for now. If this shows up regularly it will likely make sense to deduplicate the type graph with a deduplication pass. Test plan: - Fixes the issue in prod. This change is quite logical.
This commit is contained in:
parent
5a2ca8b059
commit
6d898bed95
@ -213,9 +213,13 @@ template <typename T>
|
|||||||
struct NameProvider {};
|
struct NameProvider {};
|
||||||
)";
|
)";
|
||||||
|
|
||||||
|
// TODO: stop types being duplicated at this point and remove this check
|
||||||
|
std::unordered_set<std::string_view> emittedTypes;
|
||||||
for (const Type& t : typeGraph.finalTypes) {
|
for (const Type& t : typeGraph.finalTypes) {
|
||||||
if (dynamic_cast<const Typedef*>(&t))
|
if (dynamic_cast<const Typedef*>(&t))
|
||||||
continue;
|
continue;
|
||||||
|
if (!emittedTypes.emplace(t.name()).second)
|
||||||
|
continue;
|
||||||
|
|
||||||
code += "template <> struct NameProvider<";
|
code += "template <> struct NameProvider<";
|
||||||
code += t.name();
|
code += t.name();
|
||||||
|
Loading…
Reference in New Issue
Block a user