[Lldb-commits] [lldb] [lldb][DWARFASTParserClang] Resolve nested types when parsing structures (PR #66879)

Michael Buch via lldb-commits lldb-commits at lists.llvm.org
Sat Sep 23 00:46:30 PDT 2023


Michael137 wrote:

>  I didn't see much explanation as to why this is needed in the bug report.

The motivating example is something like:
```
struct Info {
  enum Mask : uintptr_t {
    Enum
  };
}
```

`expr Info::Mask::Enum`.

> Is there a reason we need to complete nested types within a type? Seems like we can put that off until later. Right now if you parse a member function, any types it needs will be parsed lazily and only if needed, which is ok. If we start completing all types within types without ever needing to actually use then, it will make debugging slower and cause our memory usage to grow.

LLDB will first resolve the `Info` structure (and all its member fields, but not nested types). When clang looks for `Mask`, it wants to find it in a direct lookup into the `Info` DeclContext. But that lookup will fail because we never created the decls for the nested type. There is no fallback to the external source in such a case unfortunately so LLDB never has the chance to correct this. There was no obvious point to which we could defer completing the nested type when completing the outer, but I might've missed something obvious. A potential option would be to limit the completion performed in this patch to enums, though a general solution would be nice.

https://github.com/llvm/llvm-project/pull/66879


More information about the lldb-commits mailing list