llvmorg-github-actions[bot] wrote:

<!--LLVM PR SUMMARY COMMENT-->

@llvm/pr-subscribers-lldb

Author: robk-dev

<details>
<summary>Changes</summary>

`DWARFASTParserClang::CompleteRecordType` sets the Microsoft C++ ABI
inheritance model on records when the target uses that ABI. Objective-C
interfaces reach that code too, and `ObjCInterfaceDecl` is not a
`CXXRecordDecl`, so the cast asserted — every completion of an Objective-C type
from DWARF crashed LLDB on an MSVC target.

Only apply the inheritance model when the declaration really is a
`CXXRecordDecl`.

This is not specific to any Objective-C runtime: it is reachable by any DWARF
containing Objective-C types on a target using the Microsoft C++ ABI. It was
found while debugging Objective-C on Windows with the GNUstep runtime, where
it made every ObjC type unusable.

I have not included a regression test. Reproducing it needs DWARF containing
an Objective-C interface for a target whose C++ ABI is Microsoft, which the
existing `YAMLModuleTester`-based unit tests here do not currently set up, and
a Shell test would need an MSVC-target Objective-C binary. Happy to add either
if you have a preference — a unit test with a synthetic COFF module seems the
more portable of the two.


---
Full diff: https://github.com/llvm/llvm-project/pull/216711.diff


1 Files Affected:

- (modified) lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp 
(+4-2) 


``````````diff
diff --git a/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp 
b/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp
index b60f1d9e41958..24b5d73fd1d80 100644
--- a/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp
+++ b/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp
@@ -2244,8 +2244,10 @@ bool DWARFASTParserClang::CompleteRecordType(const 
DWARFDIE &die,
 
   // 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
-  // member functions of this type.
-  if (m_ast.getASTContext().getTargetInfo().getCXXABI().isMicrosoft()) {
+  // member functions of this type. Objective-C interface types reach this
+  // point too but are not CXXRecordDecls, so record_decl may be null here.
+  if (record_decl &&
+      m_ast.getASTContext().getTargetInfo().getCXXABI().isMicrosoft()) {
     auto IM = record_decl->calculateInheritanceModel();
     record_decl->addAttr(clang::MSInheritanceAttr::CreateImplicit(
         m_ast.getASTContext(), true, {},

``````````

</details>


https://github.com/llvm/llvm-project/pull/216711
_______________________________________________
lldb-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits

Reply via email to