[LLDB][NativePDB] Don't complete static members' types when completing a record type.

`UdtRecordCompleter` shouldn't complete static members' types. static members' types are going to be completed when the types are called in `SymbolFile::CompleteType`.

Reviewed By: labath

Differential Revision: https://reviews.llvm.org/D121030
This commit is contained in:
Zequan Wu 2022-03-14 13:53:19 -07:00
parent 8b50353335
commit 583223cd5e
4 changed files with 55 additions and 5 deletions

View File

@ -1231,8 +1231,10 @@ clang::QualType PdbAstBuilder::CreateEnumType(PdbTypeSymId id,
clang::QualType PdbAstBuilder::CreateArrayType(const ArrayRecord &ar) {
clang::QualType element_type = GetOrCreateType(ar.ElementType);
uint64_t element_count =
ar.Size / GetSizeOfType({ar.ElementType}, m_index.tpi());
uint64_t element_size = GetSizeOfType({ar.ElementType}, m_index.tpi());
if (element_size == 0)
return {};
uint64_t element_count = ar.Size / element_size;
CompilerType array_ct = m_clang.CreateArrayType(ToCompilerType(element_type),
element_count, false);

View File

@ -138,8 +138,6 @@ Error UdtRecordCompleter::visitKnownMember(
clang::QualType member_type =
m_ast_builder.GetOrCreateType(PdbTypeSymId(static_data_member.Type));
m_ast_builder.CompleteType(member_type);
CompilerType member_ct = m_ast_builder.ToCompilerType(member_type);
lldb::AccessType access =
@ -149,7 +147,7 @@ Error UdtRecordCompleter::visitKnownMember(
// Static constant members may be a const[expr] declaration.
// Query the symbol's value as the variable initializer if valid.
if (member_ct.IsConst()) {
if (member_ct.IsConst() && member_ct.IsCompleteType()) {
std::string qual_name = decl->getQualifiedNameAsString();
auto results =

View File

@ -0,0 +1,4 @@
image lookup -type A
image lookup -type B
quit

View File

@ -0,0 +1,46 @@
// clang-format off
// RUN: %build -o %t.exe -- %s
// RUN: env LLDB_USE_NATIVE_PDB_READER=1 %lldb -f %t.exe -s \
// RUN: %p/Inputs/lookup-by-types.lldbinit 2>&1 | FileCheck %s
class B;
class A {
public:
static const A constA;
static A a;
static B b;
int val = 1;
};
class B {
public:
static A a;
int val = 2;
};
A varA;
B varB;
const A A::constA = varA;
A A::a = varA;
B A::b = varB;
A B::a = varA;
int main(int argc, char **argv) {
return varA.val + varB.val;
}
// CHECK: image lookup -type A
// CHECK-NEXT: 1 match found in {{.*}}.exe
// CHECK-NEXT: compiler_type = "class A {
// CHECK-NEXT: static const A constA;
// CHECK-NEXT: static A a;
// CHECK-NEXT: static B b;
// CHECK-NEXT: public:
// CHECK-NEXT: int val;
// CHECK-NEXT: }"
// CHECK: image lookup -type B
// CHECK-NEXT: 1 match found in {{.*}}.exe
// CHECK-NEXT: compiler_type = "class B {
// CHECK-NEXT: static A a;
// CHECK-NEXT: public:
// CHECK-NEXT: int val;
// CHECK-NEXT: }"