mirror of
https://github.com/JakeHillion/object-introspection.git
synced 2024-11-13 22:06:55 +00: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
e431c00c9f
commit
851901d690
@ -213,9 +213,13 @@ template <typename T>
|
||||
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) {
|
||||
if (dynamic_cast<const Typedef*>(&t))
|
||||
continue;
|
||||
if (!emittedTypes.emplace(t.name()).second)
|
||||
continue;
|
||||
|
||||
code += "template <> struct NameProvider<";
|
||||
code += t.name();
|
||||
|
Loading…
Reference in New Issue
Block a user