https://github.com/robk-dev updated https://github.com/llvm/llvm-project/pull/216711
>From d587863dc1f3b88f1c520d4dbff986d8cc99bb8c Mon Sep 17 00:00:00 2001 From: Rob <[email protected]> Date: Wed, 12 Aug 2026 23:37:16 +0100 Subject: [PATCH 1/2] [lldb] Guard MS inheritance model against non-CXXRecordDecl DWARF types CompleteRecordType() computes the MSInheritanceAttr for the Microsoft C++ ABI by calling calculateInheritanceModel() on the record's CXXRecordDecl. Objective-C interface types complete through the same path but are ObjCInterfaceDecls, so GetAsCXXRecordDecl() returns null and the Microsoft-ABI block crashed on every Objective-C type completion for *-windows-msvc targets. Guard it the same way as the SetRecordLayout call above. Found debugging GNUstep Objective-C programs on Windows, where any `frame variable` touching an object type crashed LLDB. Assisted-by: Claude Fable 5 --- .../Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp b/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp index b60f1d9e41958..8609e0b2b0388 100644 --- a/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp +++ b/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp @@ -2239,8 +2239,14 @@ bool DWARFASTParserClang::CompleteRecordType(const DWARFDIE &die, clang::CXXRecordDecl *record_decl = m_ast.GetAsCXXRecordDecl(clang_type.GetOpaqueQualType()); - if (record_decl) - GetClangASTImporter().SetRecordLayout(record_decl, layout_info); + // Objective-C interfaces are completed through this path as well, but are + // not CXXRecordDecls. Nothing that follows applies to them: they have no + // record layout to hand to the importer, no pointer-to-member + // representation to infer, and no nested types to resolve. + if (!record_decl) + return clang_type.IsValid(); + + GetClangASTImporter().SetRecordLayout(record_decl, layout_info); // DWARF doesn't have the attribute, but we can infer the value the same way // as Clang Sema does. It's required to calculate the size of pointers to >From 2ce5efd5fe8f0dca9bdd55c9903f8d1eb00eac4b Mon Sep 17 00:00:00 2001 From: Rob <[email protected]> Date: Mon, 17 Aug 2026 14:35:15 +0100 Subject: [PATCH 2/2] [lldb] Add a test for Objective-C type completion on MSVC targets Compile an Objective-C interface hierarchy for x86_64-pc-windows-msvc, link it into a PE image and dump the Clang AST LLDB builds from its DWARF. Without the guard in CompleteRecordType() this crashes in CXXRecordDecl::calculateInheritanceModel() on a null pointer. Requires lld so the object can be linked into an image; lldb-test has no symbol vendor for a bare COFF object file. Assisted-by: Claude Opus 5 --- ...clang-ast-from-dwarf-objc-interface-msvc.m | 34 +++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100644 lldb/test/Shell/SymbolFile/DWARF/clang-ast-from-dwarf-objc-interface-msvc.m diff --git a/lldb/test/Shell/SymbolFile/DWARF/clang-ast-from-dwarf-objc-interface-msvc.m b/lldb/test/Shell/SymbolFile/DWARF/clang-ast-from-dwarf-objc-interface-msvc.m new file mode 100644 index 0000000000000..e95d69a62c859 --- /dev/null +++ b/lldb/test/Shell/SymbolFile/DWARF/clang-ast-from-dwarf-objc-interface-msvc.m @@ -0,0 +1,34 @@ +// REQUIRES: lld, x86 + +// RUN: %clang --target=x86_64-pc-windows-msvc -gdwarf -c -o %t.obj -- %s +// RUN: lld-link -debug:dwarf -nodefaultlib -force:unresolved -entry:main \ +// RUN: -out:%t.exe -- %t.obj +// RUN: lldb-test symbols -dump-clang-ast %t.exe | FileCheck %s + +// CHECK: ObjCInterfaceDecl {{.*}} Base +// CHECK-NEXT: ObjCIvarDecl {{.*}} base_ivar 'int' +// CHECK: ObjCInterfaceDecl {{.*}} Derived +// CHECK-NEXT: super ObjCInterface {{.*}} 'Base' +// CHECK-NEXT: ObjCIvarDecl {{.*}} derived_ivar 'int' + +__attribute__((objc_root_class)) +@interface Base { + int base_ivar; +} +@end + +@implementation Base +@end + +@interface Derived : Base { + int derived_ivar; +} +@end + +@implementation Derived +@end + +int main(void) { + Derived *d = 0; + return (int)(__SIZE_TYPE__)d; +} _______________________________________________ lldb-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
