<html xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:w="urn:schemas-microsoft-com:office:word" xmlns:m="http://schemas.microsoft.com/office/2004/12/omml" xmlns="http://www.w3.org/TR/REC-html40">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta name="Generator" content="Microsoft Word 14 (filtered medium)">
<style><!--
/* Font Definitions */
@font-face
        {font-family:"MS Mincho";
        panose-1:2 2 6 9 4 2 5 8 3 4;}
@font-face
        {font-family:"MS Mincho";
        panose-1:2 2 6 9 4 2 5 8 3 4;}
@font-face
        {font-family:Calibri;
        panose-1:2 15 5 2 2 2 4 3 2 4;}
@font-face
        {font-family:Tahoma;
        panose-1:2 11 6 4 3 5 4 4 2 4;}
@font-face
        {font-family:"\@MS Mincho";
        panose-1:2 2 6 9 4 2 5 8 3 4;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
        {margin:0in;
        margin-bottom:.0001pt;
        font-size:12.0pt;
        font-family:"Times New Roman","serif";}
a:link, span.MsoHyperlink
        {mso-style-priority:99;
        color:blue;
        text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
        {mso-style-priority:99;
        color:purple;
        text-decoration:underline;}
p
        {mso-style-priority:99;
        mso-margin-top-alt:auto;
        margin-right:0in;
        mso-margin-bottom-alt:auto;
        margin-left:0in;
        font-size:12.0pt;
        font-family:"Times New Roman","serif";}
pre
        {mso-style-priority:99;
        mso-style-link:"HTML Preformatted Char";
        margin:0in;
        margin-bottom:.0001pt;
        font-size:10.0pt;
        font-family:"Courier New";}
span.EmailStyle17
        {mso-style-type:personal-reply;
        font-family:"Calibri","sans-serif";
        color:#1F497D;}
span.HTMLPreformattedChar
        {mso-style-name:"HTML Preformatted Char";
        mso-style-priority:99;
        mso-style-link:"HTML Preformatted";
        font-family:"Courier New";}
span.k
        {mso-style-name:k;}
span.nc
        {mso-style-name:nc;}
span.o
        {mso-style-name:o;}
span.na
        {mso-style-name:na;}
span.nf
        {mso-style-name:nf;}
span.no
        {mso-style-name:no;}
.MsoChpDefault
        {mso-style-type:export-only;
        font-family:"Calibri","sans-serif";}
@page WordSection1
        {size:8.5in 11.0in;
        margin:1.0in 1.0in 1.0in 1.0in;}
div.WordSection1
        {page:WordSection1;}
--></style><!--[if gte mso 9]><xml>
<o:shapedefaults v:ext="edit" spidmax="1026" />
</xml><![endif]--><!--[if gte mso 9]><xml>
<o:shapelayout v:ext="edit">
<o:idmap v:ext="edit" data="1" />
</o:shapelayout></xml><![endif]-->
</head>
<body lang="EN-US" link="blue" vlink="purple">
<div class="WordSection1">
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D"><o:p> </o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D"><o:p> </o:p></span></p>
<div style="border:none;border-left:solid blue 1.5pt;padding:0in 0in 0in 4.0pt">
<div>
<div style="border:none;border-top:solid #B5C4DF 1.0pt;padding:3.0pt 0in 0in 0in">
<p class="MsoNormal"><b><span style="font-size:10.0pt;font-family:"Tahoma","sans-serif"">From:</span></b><span style="font-size:10.0pt;font-family:"Tahoma","sans-serif""> David Blaikie [mailto:dblaikie@gmail.com]
<br>
<b>Sent:</b> Wednesday, May 13, 2015 11:06 AM<br>
<b>To:</b> reviews+D7895+public+7827be49c0b04087@reviews.llvm.org<br>
<b>Cc:</b> Romanova, Katya; Eric Christopher; Frédéric Riss; Duncan P. N. Exon Smith; Robinson, Paul; Adrian Prantl; llvm-commits@cs.uiuc.edu<br>
<b>Subject:</b> Re: [PATCH] Anonymous namespaces are missing import DW_TAG_imported_module.<o:p></o:p></span></p>
</div>
</div>
<p class="MsoNormal"><o:p> </o:p></p>
<div>
<p class="MsoNormal"><o:p> </o:p></p>
<div>
<p class="MsoNormal"><o:p> </o:p></p>
<div>
<p class="MsoNormal">On Wed, May 13, 2015 at 10:56 AM, Katya Romanova <<a href="mailto:Katya_Romanova@playstation.sony.com" target="_blank">Katya_Romanova@playstation.sony.com</a>> wrote:<o:p></o:p></p>
<p class="MsoNormal">Hi David,<br>
Sorry for the delay answering your question about AST.<br>
<br>
> > One question, if you're up for it - there is actually an implicit UsingDirectiveDecl in the AST<br>
>..<br>
> > 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<br>
><br>
> >  imported module from scratch in the debug info code gen?<br>
><br>
> >  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?<br>
><br>
<br>
<br>
Implicit UsingDirectiveDecl is generated by Sema::ActOnStartNamespaceDef() when it’s given an anonymous namespace.<br>
The UsingDirectedDecl is added to the Parent (top level) which is why you see it in AST dump.<br>
<br>
Above function is called from ParseNamespace(), which is called by ParseDeclaration(). ParseDeclaration() returns DeclGroup.<br>
The problem is that group is populated with a SingleDecl that ParseNamespace returns ([anonymous] NamespaceDecl).<br>
<br>
ParseDeclaration doesn’t know anything about the UsingNamespaceDecl that ParseNamespace implicitly generated<br>
and added to the parent.. This implicit declaration is not added to the DeclGroup and thus you don’t generate<br>
debug node for it.<br>
<br>
If we want ParseNamespace to generate both NamespaceDecl AND an implicit UsingNamespaceDecl<br>
then the following piece of code:<br>
<br>
  case tok::kw_namespace:<br>
    ProhibitAttributes(attrs);<br>
    SingleDecl = ParseNamespace(Context, DeclEnd);<br>
    break;<br>
<br>
should return not the SingleDecl (converted to DeclGroup), but a DeclGroup containing both NamespaceDecl AND UsingNamespaceDecl.<br>
<br>
I think that this fix (conditional for PS4 only) will be more complicated and more invasive solution than FE solution that I implemented before.<br>
<br>
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.<o:p></o:p></p>
<div>
<p class="MsoNormal"><br>
After seeing Clang's output on some other code, I'm not sure this fix is correct.<br>
<br>
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).<br>
<br>
<span style="color:#1F497D"><o:p></o:p></span></p>
<p class="MsoNormal"><b><i><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D">[Katya Romanova]
<o:p></o:p></span></i></b></p>
<p class="MsoNormal"><b><i><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D">I have tried anonymous namespace inside another anonymous namespace like you suggested . You are right. I can see that implicit using directive is always
 emitted for a nested namespace. That means, that for PS4 we will emit duplicate using directive for a nested anonymous namespace.<o:p></o:p></span></i></b></p>
<p class="MsoNormal"><br>
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.<br>
<br>
<span style="color:#1F497D"><o:p></o:p></span></p>
<p class="MsoNormal"><b><i><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D">[Katya Romanova]
<o:p></o:p></span></i></b></p>
<p class="MsoNormal"><b><i><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D">So the current plan is to add an implicit using directive for the top level anonymous namespace to the DeclGroup containing top level decls. Hopefully,
 it could be done by changing ParseNamespace to return a DeclGroup containing both NamespaceDecl and UsingDirectiveDecl. If not, I will figure out a different way to do it.<o:p></o:p></span></i></b></p>
<p class="MsoNormal"><b><i><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D">After that, I need to suppress generation of a using directive for *top level* implicit anonymous namespace (except for PS4). I assume we still want to
 keep generating  implicit using directive for the *nested* anonymous namespace. Rright?
<o:p></o:p></span></i></b></p>
<p class="MsoNormal"><b><i><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D"><o:p> </o:p></span></i></b></p>
<p class="MsoNormal"><b><i><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D">Let me know if this solution sounds reasonable. I will implement the  patch.<o:p></o:p></span></i></b></p>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto">ParseDeclaration doesn’t know anything about the UsingNamespaceDecl that ParseNamespace implicitly generated<br>
and added to the parent.. This implicit declaration is not added to the DeclGroup and thus you don’t generate<br>
debug node for it.<o:p></o:p></p>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto">If we want ParseNamespace to generate both NamespaceDecl AND an implicit UsingNamespaceDecl<br>
then the following piece of code:<o:p></o:p></p>
<p class="MsoNormal"><span style="font-size:10.0pt;font-family:"Courier New"">case tok::kw_namespace:<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:10.0pt;font-family:"Courier New"">  ProhibitAttributes(attrs);<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:10.0pt;font-family:"Courier New"">  SingleDecl = ParseNamespace(Context, DeclEnd);<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:10.0pt;font-family:"Courier New"">  break;<o:p></o:p></span></p>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto">should return not the SingleDecl (converted to DeclGroup), but a DeclGroup containing both NamespaceDecl AND UsingNamespaceDecl.<o:p></o:p></p>
<p class="MsoNormal"><span style="color:#1F497D"><o:p> </o:p></span></p>
<p class="MsoNormal"><br>
- David<br>
 <o:p></o:p></p>
</div>
<blockquote style="border:none;border-left:solid #CCCCCC 1.0pt;padding:0in 0in 0in 6.0pt;margin-left:4.8pt;margin-right:0in">
<p class="MsoNormal"><br>
If everything is OK, I will rebase and commit my latest FE patch.<br>
Thanks for reviewing!<o:p></o:p></p>
<div>
<div>
<p class="MsoNormal" style="margin-bottom:12.0pt"><br>
<br>
<a href="http://reviews.llvm.org/D7895" target="_blank">http://reviews.llvm.org/D7895</a><br>
<br>
EMAIL PREFERENCES<br>
  <a href="http://reviews.llvm.org/settings/panel/emailpreferences/" target="_blank">
http://reviews.llvm.org/settings/panel/emailpreferences/</a><br>
<br>
<o:p></o:p></p>
</div>
</div>
</blockquote>
</div>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
</div>
</div>
</div>
</body>
</html>