[cxx-interop] Disambiguate instantiations with template template parameters#88577
[cxx-interop] Disambiguate instantiations with template template parameters#88577egorzhdan wants to merge 1 commit intoswiftlang:mainfrom
Conversation
…meters `template<template <typename> typename>` was tripping up the template class name printer – different instantiations of a class template were getting assigned the same name. rdar://169199221
|
@swift-ci please smoke test |
Xazax-hun
left a comment
There was a problem hiding this comment.
This looks good, but I wonder if we should also cover other (non-integral) template arguments like:
struct S {
constexpr S(int) {}
};
template <S s>
void f();
void g() {
constexpr S s{5};
f<s>();
}
Could be a separate PR though.
|
@Xazax-hun that particular example wouldn't trigger this code path in the compiler, since the template name printer is exclusive to types, it isn't used for functions. Supporting more kinds of template scaffolding would definitely be an improvement! |
|
@swift-ci please test Windows |
1 similar comment
|
@swift-ci please test Windows |
j-hui
left a comment
There was a problem hiding this comment.
Just for posteriority: do you have any record of what the crash looked like prior to your fix?
Perhaps something like this? struct S { constexpr S(int) {} };
template <S s> struct T {};
using T5 = T<{5}>; |
| if (auto templateDecl = templateName.getAsTemplateDecl()) { | ||
| auto importedName = typePrinter.nameImporter->importName( | ||
| templateDecl, typePrinter.version); | ||
| importedName.getDeclName().print(buffer); |
There was a problem hiding this comment.
Do we care about qualified names, for example:
namespace foo {
template <typename> struct Traits {};
} // namespace foo
namespace bar {
template <typename> struct Traits {};
} // namespace bar
using HasTraits3 = HasTemplateTemplateParam<foo::Traits>;
using HasTraits4 = HasTemplateTemplateParam<bar::Traits>;prints:
typealias HasTraits3 = HasTemplateTemplateParam<Traits>
typealias HasTraits4 = HasTemplateTemplateParam<Traits>
template<template <typename> typename>was tripping up the template class name printer – different instantiations of a class template were getting assigned the same name.This adjusts the instantiation name printer to emit an actual name of the template parameter instead of a placeholder (
_).rdar://169199221
Low, this is covered by tests.
Added compiler tests.