<html>
  <head>
    <meta content="text/html; charset=utf-8" http-equiv="Content-Type">
  </head>
  <body bgcolor="#FFFFFF" text="#000000">
    <div class="moz-cite-prefix">Would this patch be more reasonable? It
      follows what RegisterTemplateSpecialization (introduced in
      r245779) does. AFAICT this adds an update record far less often.<br>
      --Vassil<br>
      On 12/12/15 16:13, Vassil Vassilev wrote:<br>
    </div>
    <blockquote cite="mid:566C3987.7040506@cern.ch" type="cite">
      <meta content="text/html; charset=utf-8" http-equiv="Content-Type">
      <div class="moz-cite-prefix">I couldn't find GetDecl routine in
        the ASTWriter. Could you elaborate?<br>
        <br>
        Assuming you meant ASTWriter::GetDeclRef(D): It seems that the
        conditions when calling GetDeclRef differ from the conditions of
        AddedCXXTemplateSpecialization. Eg:<br>
        <br>
        ASTWriter::AddedCXXTemplateSpecialization {<br>
          assert(!WritingAST && "Already writing the AST!");<br>
          ...<br>
        }<br>
        ASTWriter::GetDeclRef {<br>
          assert(WritingAST && "Cannot request a declaration ID
        before AST writing");<br>
          ..<br>
        }<br>
        <br>
        IIUC this particular instantiation happens *after* module B was
        built, thus it needs to be retrospectively added to the
        serialized namespace. It looks like even avoiding somehow the
        asserts of GetDeclRef it wouldn't help much.<br>
        <br>
        Alternatively I could try to reduce the redundant update records
        by narrowing down to instantiations coming in the context of
        friends.<br>
        <br>
        --Vassil<br>
        <br>
        On 12/12/15 01:07, Richard Smith wrote:<br>
      </div>
      <blockquote
cite="mid:CAOfiQqk0mJ_=uVX_0vjfb9UmonWPqhZGO_YnWsO4=pvx2M4XwQ@mail.gmail.com"
        type="cite">
        <meta http-equiv="Content-Type" content="text/html;
          charset=utf-8">
        <div dir="ltr">
          <div>Instead of adding an update record directly in this case
            (which will emit far more update records than necessary),
            how about just calling GetDecl(D) from
            AddedCXXTemplateSpecialization to ensure that it gets
            emitted?</div>
          <div>
            <div class="gmail_extra"><br>
              <div class="gmail_quote">On Fri, Dec 4, 2015 at 7:46 AM,
                Vassil Vassilev <span dir="ltr"><<a
                    moz-do-not-send="true"
                    class="moz-txt-link-abbreviated"
                    href="mailto:vvasilev@cern.ch"><a class="moz-txt-link-abbreviated" href="mailto:vvasilev@cern.ch">vvasilev@cern.ch</a></a>></span>
                wrote:<br>
                <blockquote class="gmail_quote" style="margin:0 0 0
                  .8ex;border-left:1px #ccc solid;padding-left:1ex">Hi,<br>
                    Could you review my fix please.<br>
                  Many thanks,<br>
                  Vassil
                  <div class="HOEnZb">
                    <div class="h5"><br>
                      On 08/10/15 15:53, Vassil Vassilev wrote:<br>
                      <blockquote class="gmail_quote" style="margin:0 0
                        0 .8ex;border-left:1px #ccc
                        solid;padding-left:1ex"> Hi Richard,<br>
                          I started working on <a
                          moz-do-not-send="true"
                          href="https://llvm.org/bugs/show_bug.cgi?id=24954"
                          rel="noreferrer" target="_blank"><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></a><br>
                        <br>
                          IIUC r228485 introduces an abstraction to deal
                        with not-really-anonymous friend decls
                        (serialization::needsAnonymousDeclarationNumber
                        in ASTCommon.cpp).<br>
                        <br>
                          A comment explicitly says:<br>
                          "// This doesn't apply to friend tag decls;
                        Sema makes those available to name<br>
                           // lookup in the surrounding context."<br>
                        <br>
                          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.<br>
                        <br>
                          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.<br>
                        <br>
                          The issue only appears when building module A
                        deserializes/uses module B.<br>
                        <br>
                          Currently I was assume that something wrong
                        happens in either
                        needsAnonymousDeclarationNumber or I hit a
                        predicted issue ASTWriterDecl.cpp:1602<br>
                            // FIXME: This is not correct; when we reach
                        an imported declaration we<br>
                            // won't emit its previous declaration.<br>
                           
                        (void)Writer.GetDeclRef(D->getPreviousDecl());<br>
                            (void)Writer.GetDeclRef(MostRecent);<br>
                        <br>
                          The issue seems a fairly complex one and I am
                        a bit stuck.<br>
                        <br>
                          Any hints are very very welcome ;)<br>
                        Many thanks,<br>
                        Vassil<br>
                        <br>
                        <br>
                        <br>
                      </blockquote>
                      <br>
                    </div>
                  </div>
                </blockquote>
              </div>
              <br>
            </div>
          </div>
        </div>
      </blockquote>
      <br>
    </blockquote>
    <br>
  </body>
</html>