[cfe-dev] QualifiedTemplateName as inner type of an ElaboratedType ?

Enea Zaffanella zaffanella at cs.unipr.it
Sat Jun 5 03:36:53 PDT 2010


Hello.

Consider the following small program:
=================
namespace NS {
template <typename T> struct Foo {};
}

template <typename T>
struct Bar {
   typedef NS::Foo<T> AAA;
   typedef typename NS::Foo<T> BBB;
};
==================

This is currently pretty printed as follows:
==================
namespace NS {
     template <typename T> struct Foo {
     };
}
template <typename T> struct Bar {
public:
     typedef NS::Foo<T> AAA;
     typedef typename NS::NS::Foo<T> BBB;
};
==================

Note the repeated namespace specifier in the name qualification for 
typedef BBB. This is not a problem of the pretty printer, rather the 
typedef BBB contains a structure as follows

    ElaboratedType
      --> TemplateSpecializationType
            --> TemplateName
                  --> QualifiedTemplateName

where both the ElaboratedType and the QualifiedTemplateName have their 
NNS qualifier set to "NS::"

This is clearly undesirable and should be fixed.
However, it is unclear to our eyes what is the right way of fixing it 
(as we cannot foresee possible consequences of changes).

Should clang get rid of the redundant qualification in the 
ElaboratedType (and DependentNameType) whenever the inner type already 
has name qualification info (i.e., a QualifiedTemplateName or a 
DependentTemplateName and maybe others)?

Or should clang rather insist on a stronger (and simpler?) design where 
a TemplateName is *never* qualified, i.e., any qualifier should be 
encoded as an external ElaboratedType (or DependentNameType) wrapper?

Regards,
Enea.



More information about the cfe-dev mailing list