Emre Kultursay e439a463a3 [lldb] Use forward type in pointer-to-member
This change is similar in spirit to the change at:
https://reviews.llvm.org/rG34c697c85e9d0af11a72ac4df5578aac94a627b3

It fixes the problem where the layout of a type was being accessed
while its base classes were not populated yet; which caused an
incorrect layout to be produced and cached.

This fixes PR50054

Reviewed By: teemperor

Differential Revision: https://reviews.llvm.org/D100977
2021-04-26 15:23:58 +02:00

75 lines
1.9 KiB
C++

//----------------------------------------------------------------------------//
// Struct loading declarations.
struct StructFirstMember { int i; };
struct StructBehindPointer { int i; };
struct StructBehindRef { int i; };
struct StructMember { int i; };
StructBehindRef struct_instance;
struct SomeStruct {
StructFirstMember *first;
StructBehindPointer *ptr;
StructMember member;
StructBehindRef &ref = struct_instance;
};
struct OtherStruct {
int member_int;
};
//----------------------------------------------------------------------------//
// Class loading declarations.
struct ClassMember { int i; };
struct StaticClassMember { int i; };
struct UnusedClassMember { int i; };
struct UnusedClassMemberPtr { int i; };
struct PointerToMember { int i; };
namespace NS {
class ClassInNamespace {
int i;
};
class ClassWeEnter {
public:
int dummy; // Prevent bug where LLDB always completes first member.
ClassMember member;
static StaticClassMember static_member;
int (PointerToMember::*ptr_to_member);
UnusedClassMember unused_member;
UnusedClassMemberPtr *unused_member_ptr;
int enteredFunction() {
return member.i; // Location: class function
}
};
StaticClassMember ClassWeEnter::static_member;
};
//----------------------------------------------------------------------------//
// Function we can stop in.
int functionWithOtherStruct() {
OtherStruct other_struct_var;
other_struct_var.member_int++; // Location: other struct function
return other_struct_var.member_int;
}
int functionWithMultipleLocals() {
SomeStruct struct_var;
OtherStruct other_struct_var;
NS::ClassInNamespace namespace_class;
other_struct_var.member_int++; // Location: multiple locals function
return other_struct_var.member_int;
}
int main(int argc, char **argv) {
NS::ClassWeEnter c;
c.enteredFunction();
functionWithOtherStruct();
functionWithMultipleLocals();
return 0;
}