Biohazrd icon indicating copy to clipboard operation
Biohazrd copied to clipboard

The names of template specializations end up including their containing namespace

Open PathogenDavid opened this issue 3 years ago • 0 comments

Biohazrd uses the type name fo template specializations by default to avoid ambiguity:

https://github.com/InfectedLibraries/Biohazrd/blob/79a17535cc94cb1b56b44452191a00974a8be37d/Biohazrd/%23Declarations/TranslatedTemplateSpecialization.cs#L12-L14

As visible in https://github.com/InfectedLibraries/Biohazrd/issues/180, this has an unintentional side-effect of including the namespace portion of the type. For example:

namespace MyNamespace
{
    template<typename T>
    class MyTemplate<T>
    {
    };

    typedef MyTemplate<int> MyTemplateInt;
}

Will result in a TranslatedTemplateSpecialization named MyNamespace::MyTemplate<int>. We want it to just be MyTemplate<int>.

I imagine there's a prettyprint option we can use with Clang to avoid including the namespace info. Just need to surface it in ClangSharp.Pathogen.

This isn't a huge priority since these names end up translated pretty unfriendly as it is. The intent is that the names will be replaced by something more friendly by a transformation. (IE: You'd probably have a transformation which renames that declaration to MyTemplateInt.)

PathogenDavid avatar Mar 30 '21 09:03 PathogenDavid