<html>
  <head>

    <meta http-equiv="content-type" content="text/html; charset=utf-8">
  </head>
  <body bgcolor="#FFFFFF" text="#000000">
    Forwarding to cfe-commits<br>
    <div class="moz-forward-container"><br>
      <br>
      -------- Forwarded Message --------
      <table class="moz-email-headers-table" border="0" cellpadding="0"
        cellspacing="0">
        <tbody>
          <tr>
            <th align="RIGHT" nowrap="nowrap" valign="BASELINE">Subject:
            </th>
            <td>[modules] PR24954</td>
          </tr>
          <tr>
            <th align="RIGHT" nowrap="nowrap" valign="BASELINE">Date: </th>
            <td>Thu, 8 Oct 2015 15:53:55 +0200</td>
          </tr>
          <tr>
            <th align="RIGHT" nowrap="nowrap" valign="BASELINE">From: </th>
            <td>Vassil Vassilev <a class="moz-txt-link-rfc2396E" href="mailto:vvasilev@cern.ch"><vvasilev@cern.ch></a></td>
          </tr>
          <tr>
            <th align="RIGHT" nowrap="nowrap" valign="BASELINE">To: </th>
            <td>Richard Smith <a class="moz-txt-link-rfc2396E" href="mailto:richard@metafoo.co.uk"><richard@metafoo.co.uk></a>,
              <a class="moz-txt-link-abbreviated" href="mailto:cfe-dev@cs.uiuc.edu">cfe-dev@cs.uiuc.edu</a> <a class="moz-txt-link-rfc2396E" href="mailto:cfe-dev@cs.uiuc.edu"><cfe-dev@cs.uiuc.edu></a></td>
          </tr>
          <tr>
            <th align="RIGHT" nowrap="nowrap" valign="BASELINE">CC: </th>
            <td>Ben Langmuir <a class="moz-txt-link-rfc2396E" href="mailto:blangmuir@apple.com"><blangmuir@apple.com></a></td>
          </tr>
        </tbody>
      </table>
      <br>
      <br>
      <pre>Hi Richard,
  I started working on <a class="moz-txt-link-freetext" href="https://llvm.org/bugs/show_bug.cgi?id=24954">https://llvm.org/bugs/show_bug.cgi?id=24954</a>

  IIUC r228485 introduces an abstraction to deal with 
not-really-anonymous friend decls 
(serialization::needsAnonymousDeclarationNumber in ASTCommon.cpp).

  A comment explicitly says:
  "// This doesn't apply to friend tag decls; Sema makes those 
available to name
   // lookup in the surrounding context."

  In the bug reproducer, the friend function (wrt __iom_t10) is forward 
declared in the same namespace, where Sema makes the friend available 
for a name lookup.

  It seems that the friend operator<< in __iom_t10 (sorry about the 
names they come from libcxx) doesn't get registered in the ASTWriter's 
DeclIDs but it gets registered in outer namespace's lookup table. Thus, 
assert is triggered when finalizing module A, since it rebuilds the 
lookups of the updated contexts.

  The issue only appears when building module A deserializes/uses module B.

  Currently I was assume that something wrong happens in either 
needsAnonymousDeclarationNumber or I hit a predicted issue 
ASTWriterDecl.cpp:1602
    // FIXME: This is not correct; when we reach an imported declaration we
    // won't emit its previous declaration.
    (void)Writer.GetDeclRef(D->getPreviousDecl());
    (void)Writer.GetDeclRef(MostRecent);

  The issue seems a fairly complex one and I am a bit stuck.

  Any hints are very very welcome ;)
Many thanks,
Vassil



</pre>
      <br>
    </div>
    <br>
  </body>
</html>