[PATCH] Anonymous namespaces are missing import DW_TAG_imported_module.

David Blaikie dblaikie at gmail.com
Wed May 13 11:06:13 PDT 2015


On Wed, May 13, 2015 at 10:56 AM, Katya Romanova <
Katya_Romanova at playstation.sony.com> wrote:

> Hi David,
> Sorry for the delay answering your question about AST.
>
> > > One question, if you're up for it - there is actually an implicit
> UsingDirectiveDecl in the AST
>
> >
>
>
> ..
>
> > > It's possible we could figure out why that decl is being skipped
> normally? & avoid skipping it/filter it out later for non-ps4 while leaving
> it in for ps4, rather than synthesizing the extra
>
> >
>
> > >  imported module from scratch in the debug info code gen?
>
> >
>
> > >  I took a glance & didn't immediately see why we weren't already
> visiting this implicit decl - I guess something is filtering out implicit
> decls somewhere?
>
> >
>
>
> Implicit UsingDirectiveDecl is generated by Sema::ActOnStartNamespaceDef()
> when it’s given an anonymous namespace.
> The UsingDirectedDecl is added to the Parent (top level) which is why you
> see it in AST dump.
>
> Above function is called from ParseNamespace(), which is called by
> ParseDeclaration(). ParseDeclaration() returns DeclGroup.
> The problem is that group is populated with a SingleDecl that
> ParseNamespace returns ([anonymous] NamespaceDecl).
>
> ParseDeclaration doesn’t know anything about the UsingNamespaceDecl that
> ParseNamespace implicitly generated
> and added to the parent.. This implicit declaration is not added to the
> DeclGroup and thus you don’t generate
> debug node for it.
>
> If we want ParseNamespace to generate both NamespaceDecl AND an implicit
> UsingNamespaceDecl
> then the following piece of code:
>
>   case tok::kw_namespace:
>     ProhibitAttributes(attrs);
>     SingleDecl = ParseNamespace(Context, DeclEnd);
>     break;
>
> should return not the SingleDecl (converted to DeclGroup), but a DeclGroup
> containing both NamespaceDecl AND UsingNamespaceDecl.
>
> I think that this fix (conditional for PS4 only) will be more complicated
> and more invasive solution than FE solution that I implemented before.
>
> I saw that you already accepted my latest FE patch. Please confirm that
> you didn't change your mind about how this bug should get fixed after your
> saw this explanation about AST.
>

After seeing Clang's output on some other code, I'm not sure this fix is
correct.

Could you add a test case with an anonymous namespace inside another
namespace? When I tried that with ToT, we /do/ emit the (implicit) using
directive today. So your change might cause us to emit two using directives
(one marked artificial, and one not).

So it might be worth figuring out how to plumb through the implicit using
directive for the top level namespace so we treat anonymous namespaces the
same whether or not they are at the top level, and when making this change
- then deliberately suppress the implicit using directive for an anonymous
namespace except when targeting PS4/SCE.

- David


>
> If everything is OK, I will rebase and commit my latest FE patch.
> Thanks for reviewing!
>
>
> http://reviews.llvm.org/D7895
>
> EMAIL PREFERENCES
>   http://reviews.llvm.org/settings/panel/emailpreferences/
>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20150513/d6851190/attachment.html>


More information about the llvm-commits mailing list