[clang] [Clang] support friend declarations with a dependent nested-name-specifier (PR #191268)

Oleksandr Tarasiuk via cfe-commits cfe-commits at lists.llvm.org
Wed Apr 29 07:23:29 PDT 2026


================
@@ -191,9 +129,10 @@ class FriendDecl final
 
   // Implement isa/cast/dyncast/etc.
   static bool classof(const Decl *D) { return classofKind(D->getKind()); }
-  static bool classofKind(Kind K) { return K == Decl::Friend; }
+  static bool classofKind(Kind K) {
+    return K == Decl::Friend || K == Decl::FriendTemplate;
+  }
----------------
a-tarasyuk wrote:

@@cor3ntin, many thanks for your feedback.
 
`FriendTemplateDecl` now inherits from `FriendDecl`. For example, `CXXRecordDecl::friends()` returns `FriendDecl *`, this lets friend traversal handle both friends and friend templates.

>From my understanding, `FriendTemplateDecl` is an extension of `FriendDecl` that can also have template parameter lists.

I considered keeping them completely separate, but using `FriendDecl` as the common base avoids introducing another friend-specific base class and keeps the existing friend iteration mostly unchanged.

 WDYT? If there are better options, I’m happy to adjust the structure.

https://github.com/llvm/llvm-project/pull/191268


More information about the cfe-commits mailing list