[Lldb-commits] [lldb] [lldb][DWARFASTParserClang] Handle pointer-to-member-data non-type te… (PR #189510)
Pavel Labath via lldb-commits
lldb-commits at lists.llvm.org
Mon Apr 13 04:11:50 PDT 2026
labath wrote:
I'm afraid there still a problem with this patch. Here's a reduced reproducer:
```
$ cat a.cc
struct X;
struct ReferencesX {
template<ReferencesX X::*>
static void DoIt(X*) {}
};
struct X {
int needed_for_some_reason;
ReferencesX member;
};
int main() {
X x;
ReferencesX::DoIt<&X::member>(&x);
}
$ clang++ -g a.cc
$ lldb a.out -o "type lookup X"
(lldb) target create "a.out"
Current executable set to '/tmp/a.out' (x86_64).
(lldb) type lookup X
lldb: clang/lib/AST/RecordLayoutBuilder.cpp:3390: const clang::ASTRecordLayout& clan
g::ASTContext::getASTRecordLayout(const clang::RecordDecl*) const: Assertion `D->isCompleteDefinition() &
& "Cannot layout type before complete!"' failed.
```
Basically, this introduces a cycle in the "requires complete" graph: `X` requires `ReferencesX` to be complete due to it being a member. And `ReferencesX` now requires `X` to be complete due to the reference in the template (static) member function. There is (a slightly more complicated version of) a pattern like this in the protobuf, which means this breaks quite a lot of things on our end.
Unfortunately, I don't see an easy way to resolve this problem. The c++ compiler avoids this recursion by delaying the template instantiation, but lldb doesn't have anything like that. I'm going to revert this patch until we figure out a solution for this. Let me know if you need help reproducing the problem (be sure to build with assertions enabled).
https://github.com/llvm/llvm-project/pull/189510
More information about the lldb-commits
mailing list