https://github.com/weliveindetail created https://github.com/llvm/llvm-project/pull/115177
Following up from https://github.com/llvm/llvm-project/pull/112928, we can reuse the [approach from Clang Sema](https://github.com/llvm/llvm-project/blob/release/19.x/clang/lib/Sema/SemaType.cpp#L9039) to infer the `MSInheritanceModel` and add the necessary attribute manually. This allows the inspection of member function pointers with DWARF on Windows. From 32d7b7d5261e651851e5a36c5fd5ae9d927a9fb3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Stefan=20Gr=C3=A4nitz?= <stefan.graen...@gmail.com> Date: Wed, 6 Nov 2024 15:45:03 +0100 Subject: [PATCH] [lldb] Infer MSInheritanceAttr for CXXRecordDecl with DWARF on Windows --- .../Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp | 5 +++++ lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp | 8 +++++++- 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp b/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp index a30d898a93cc4d..319540389c05ee 100644 --- a/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp +++ b/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp @@ -2138,6 +2138,11 @@ bool DWARFASTParserClang::CompleteRecordType(const DWARFDIE &die, if (record_decl) GetClangASTImporter().SetRecordLayout(record_decl, layout_info); + // TODO: Only necessary if we target the Microsoft C++ ABI + auto IM = record_decl->calculateInheritanceModel(); + record_decl->addAttr(clang::MSInheritanceAttr::CreateImplicit( + m_ast.getASTContext(), true, {}, clang::MSInheritanceAttr::Spelling(IM))); + // Now parse all contained types inside of the class. We make forward // declarations to all classes, but we need the CXXRecordDecl to have decls // for all contained types because we don't get asked for them via the diff --git a/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp b/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp index f5063175d6e070..a1e224a395e69f 100644 --- a/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp +++ b/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp @@ -2771,8 +2771,14 @@ static bool GetCompleteQualType(clang::ASTContext *ast, ast, llvm::cast<clang::AttributedType>(qual_type)->getModifiedType(), allow_completion); - case clang::Type::MemberPointer: + case clang::Type::MemberPointer: { + auto *MPT = qual_type.getTypePtr()->castAs<clang::MemberPointerType>(); + if (MPT->getClass()->isRecordType()) + GetCompleteRecordType(ast, clang::QualType(MPT->getClass(), 0), + allow_completion); + return !qual_type.getTypePtr()->isIncompleteType(); + } default: break; _______________________________________________ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits