[llvm-bugs] [Bug 24420] New: RecordDecl::LoadFieldsFromExternalStorage() expels existing decls from the DeclContext linked list

via llvm-bugs llvm-bugs at lists.llvm.org
Mon Aug 10 12:33:43 PDT 2015


https://llvm.org/bugs/show_bug.cgi?id=24420

            Bug ID: 24420
           Summary: RecordDecl::LoadFieldsFromExternalStorage() expels
                    existing decls from the DeclContext linked list
           Product: clang
           Version: trunk
          Hardware: All
                OS: All
            Status: NEW
          Severity: normal
          Priority: P
         Component: -New Bugs
          Assignee: unassignedclangbugs at nondot.org
          Reporter: syniurge at gmail.com
                CC: llvm-bugs at lists.llvm.org
    Classification: Unclassified

Unlike DeclContext::LoadLexicalDeclsFromExternalStorage() which preserve
existing decls with:

  // Splice the newly-read declarations into the beginning of the list
  // of declarations.
  Decl *ExternalFirst, *ExternalLast;
  std::tie(ExternalFirst, ExternalLast) =
      BuildDeclChain(Decls, FieldsAlreadyLoaded);
  ExternalLast->NextInContextAndBits.setPointer(FirstDecl);
  FirstDecl = ExternalFirst;
  if (!LastDecl)
    LastDecl = ExternalLast;

RecordDecl::LoadFieldsFromExternalStorage() resets the linked list:

  std::tie(FirstDecl, LastDecl) = BuildDeclChain(Decls,
/*FieldsAlreadyLoaded=*/false);

Assuming it to be empty may be correct most of the time but in my particular
usage of Clang this becomes a serious hassle because implicit
constructors/operators/etc. may be declared before
RecordDecl::LoadFieldsFromExternalStorage() gets called, there's no way to
control this and the only workaround I've found is to traverse the entire PCH's
AST before doing anything to ensure the fields get deserialized before implicit
methods get declared by Sema, which defeats the benefits of lazy
deserialization.

(The implicit methods are still returned by Sema::LookupXXXX after being
expelled, and they still believe their lexical decl context to be the record,
despite missing from a dump())

-- 
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20150810/809f37c8/attachment.html>


More information about the llvm-bugs mailing list