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

Richard Smith via cfe-dev cfe-dev at lists.llvm.org
Wed May 30 11:18:39 PDT 2018


Use getFriendObjectKind()

On Wed, 30 May 2018, 09:26 Eric Liu, <ioeric at google.com> wrote:

> 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/a1d108c6/attachment.html>


More information about the cfe-dev mailing list