Examples of FriendTemplateDecl ?


In the documentation of AST class FriendTemplateDecl it is said:

01221 /// Declaration of a friend template. For example:
01222 ///
01223 /// template <typename T> class A {
01224 /// friend class MyVector<T>; // not a friend template
01225 /// template <typename U> friend class B; // friend template
01226 /// template <typename U> friend class Foo<T>::Nested; // friend template

I tried the examples above and, as far as I can see, clang generates no FriendTemplateDecl node at all.

For the first friend template declaration
     template <typename U> friend class B;
it seems that a "normal" FriendDecl node is produced, containing a NamedDecl node (shouldn't we get a Type node?), which is a ClassTemplateDecl.

For the second frined template declaration
     template <typename U> friend class Foo<T>::Nested;
we still obtain a "normal" FriendDecl node, but this time the node contains a Type node (an ElaborateType). In this case there is no list of template parameters.

Is this a known issue or should we file a bug?
Are there other examples where clang actually generates a FriendTemplateDecl node?

Enea Zaffanella.

I would not be surprised to hear than nothing is actually generating a friend template decl right now. Friend declarations were hacked together to be good enough to support finding friend functions through ADL, but no better. All the friend declaration classes are going to be reworked in the next few months as we start needing them for access control.

Put another way: I would not recommend writing any code which relies on the current representation of friends, because that representation is known to be unsatisfactory and is scheduled to soon see large changes.