[cfe-dev] How to tell if a NamedDecl is created by a FriendDecl?

Eric Liu via cfe-dev cfe-dev at lists.llvm.org
Wed May 30 09:26:38 PDT 2018


In the following example, an "implicit" declaration of "class Y" will be
created for "friend class Y" (it's not marked as implicit in AST because
it's actually written in the friend declaration), and it will have the same
USR as the real declaration. I couldn't find a way to tell whether such
decl was created by the friend decl when only given the NamedDecl. Checking
its DeclContext doesn't help because the context is the namespace nx.

   - ```
   namespace nx {
   class X {
     friend class Y;
   };
   class Y {};
   }  // namespace nx
   ``

I'm wondering if this is actually possible. If not, would it make sense to
flag decls created by friend decls in the AST?

Thanks,
Eric
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20180530/e3bf4512/attachment.html>


More information about the cfe-dev mailing list