[Lldb-commits] [PATCH] D121030: [LLDB][NativePDB] Don't complete static members' types when completing a record type.

Zequan Wu via Phabricator via lldb-commits lldb-commits at lists.llvm.org
Tue Mar 15 14:07:42 PDT 2022


This revision was automatically updated to reflect the committed changes.
Closed by commit rG583223cd5ec4: [LLDB][NativePDB] Don't complete static members' types when completing a record… (authored by zequanwu).

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D121030/new/

https://reviews.llvm.org/D121030

Files:
  lldb/source/Plugins/SymbolFile/NativePDB/PdbAstBuilder.cpp
  lldb/source/Plugins/SymbolFile/NativePDB/UdtRecordCompleter.cpp
  lldb/test/Shell/SymbolFile/NativePDB/Inputs/lookup-by-types.lldbinit
  lldb/test/Shell/SymbolFile/NativePDB/lookup-by-types.cpp


Index: lldb/test/Shell/SymbolFile/NativePDB/lookup-by-types.cpp
===================================================================
--- /dev/null
+++ lldb/test/Shell/SymbolFile/NativePDB/lookup-by-types.cpp
@@ -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: }"
Index: lldb/test/Shell/SymbolFile/NativePDB/Inputs/lookup-by-types.lldbinit
===================================================================
--- /dev/null
+++ lldb/test/Shell/SymbolFile/NativePDB/Inputs/lookup-by-types.lldbinit
@@ -0,0 +1,4 @@
+image lookup -type A
+image lookup -type B
+
+quit
\ No newline at end of file
Index: lldb/source/Plugins/SymbolFile/NativePDB/UdtRecordCompleter.cpp
===================================================================
--- lldb/source/Plugins/SymbolFile/NativePDB/UdtRecordCompleter.cpp
+++ lldb/source/Plugins/SymbolFile/NativePDB/UdtRecordCompleter.cpp
@@ -138,8 +138,6 @@
   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 @@
 
   // 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 =
Index: lldb/source/Plugins/SymbolFile/NativePDB/PdbAstBuilder.cpp
===================================================================
--- lldb/source/Plugins/SymbolFile/NativePDB/PdbAstBuilder.cpp
+++ lldb/source/Plugins/SymbolFile/NativePDB/PdbAstBuilder.cpp
@@ -1231,8 +1231,10 @@
 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);


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D121030.415575.patch
Type: text/x-patch
Size: 3388 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/lldb-commits/attachments/20220315/25d5458f/attachment.bin>


More information about the lldb-commits mailing list