It's required in following situations:
- As a base class.
- As a data member.
- As an array element type.
Differential D134066
[LLDB][NativePDB] Forcefully complete a record type if it has empty debug info and is required to have complete type. zequanwu on Sep 16 2022, 12:45 PM. Authored by
Details It's required in following situations:
Diff Detail
Event Timeline
Comment Actions It seems not correct. The dwarf test expects an error. I should figure out how to reduce that original crash.
Comment Actions How about this? $ cat a.cc struct A { int x; A(); }; A::A() : x(47) {} $ cat b.cc struct A { int x; A(); }; struct B : A {}; B b; int main(){} $ bin\clang a.cc -o a.o -c $ bin\clang.exe a.o b.cc -g -o b.exe $ bin\lldb b.exe (lldb) target create "b.exe" (lldb) Current executable set to 'b.exe' (x86_64). (lldb) b main Breakpoint 1: where = b.exe`main at b.cc:5, address = 0x0000000140007100 (lldb) r (lldb) Process 14288 launched: 'b.exe' (x86_64) Process 14288 stopped * thread #1, stop reason = breakpoint 1.1 frame #0: 0x00007ff6f37f7100 b.exe`main at b.cc:5 2 struct B : A {}; 3 4 B b; -> 5 int main(){} (lldb) p b Assertion failed: DD && "queried property of class with no definition", file clang\include\clang/AST/DeclCXX.h, line 443 Comment Actions Update to forcefully complete a record type only if it has empty debug info and is required to have complete type. I basically copied RequireCompleteType from dwarf plugin. Calling it when the tag type is one of 1. an element type 2. an base class 3. a class member. This is the same way that dwarf plugin is doing.
Comment Actions Update.
Comment Actions Removed PdbAstBuilder::RequireCompleteType from PdbAstBuilder::CreateArrayType as it's not necessary at all.
Comment Actions Adding a test for incomplete record type as class static member. It returns error, because its type not required to be completed. Comment Actions Looks good, but I think you missed one comment.
|
I suppose this won't hurt, but RequireCompleteType will not actually do anything for method types, right ?
Regarding method types, there is a slightly different problem. C++ rules require that in code like
struct B1 { virtual A1* f(); }; struct B2:B1 { A2* f(); };, the types A1 and A2 must be complete (because that code is only valid if A1 is a base of A2). However, I think that's better left to a separate patch.