llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT--> @llvm/pr-subscribers-lldb Author: nerix (Nerixyz) <details> <summary>Changes</summary> All records were marked as not being a dynamic C++ type - even ones that contain virtual methods. However, these _are_ dynamic C++ types. With this PR, the metadata for dynamic C++ types is now set when a record is completed and a type is considered dynamic if it has any virtual method (e.g. destructor). I'm not sure how to test this. I noticed this when implementing a Microsoft ABI runtime to resolve types based on their vtables (PR TBD). --- Full diff: https://github.com/llvm/llvm-project/pull/155853.diff 3 Files Affected: - (modified) lldb/source/Plugins/SymbolFile/NativePDB/PdbAstBuilder.cpp (-1) - (modified) lldb/source/Plugins/SymbolFile/NativePDB/UdtRecordCompleter.cpp (+6-1) - (modified) lldb/source/Plugins/SymbolFile/NativePDB/UdtRecordCompleter.h (+1) ``````````diff diff --git a/lldb/source/Plugins/SymbolFile/NativePDB/PdbAstBuilder.cpp b/lldb/source/Plugins/SymbolFile/NativePDB/PdbAstBuilder.cpp index 709281cb32709..d837eee854801 100644 --- a/lldb/source/Plugins/SymbolFile/NativePDB/PdbAstBuilder.cpp +++ b/lldb/source/Plugins/SymbolFile/NativePDB/PdbAstBuilder.cpp @@ -615,7 +615,6 @@ clang::QualType PdbAstBuilder::CreateRecordType(PdbTypeSymId id, ClangASTMetadata metadata; metadata.SetUserID(toOpaqueUid(id)); - metadata.SetIsDynamicCXXType(false); CompilerType ct = m_clang.CreateRecordType( context, OptionalClangModuleID(), access, uname, llvm::to_underlying(ttk), diff --git a/lldb/source/Plugins/SymbolFile/NativePDB/UdtRecordCompleter.cpp b/lldb/source/Plugins/SymbolFile/NativePDB/UdtRecordCompleter.cpp index 1c575e90bd72c..1a9d91f6d6467 100644 --- a/lldb/source/Plugins/SymbolFile/NativePDB/UdtRecordCompleter.cpp +++ b/lldb/source/Plugins/SymbolFile/NativePDB/UdtRecordCompleter.cpp @@ -110,9 +110,11 @@ void UdtRecordCompleter::AddMethod(llvm::StringRef name, TypeIndex type_idx, lldb::AccessType access_type = TranslateMemberAccess(access); bool is_artificial = (options & MethodOptions::CompilerGenerated) == MethodOptions::CompilerGenerated; + bool is_virtual = attrs.isVirtual(); + m_any_virtual_method = m_any_virtual_method || is_virtual; m_ast_builder.clang().AddMethodToCXXRecordType( derived_opaque_ty, name.data(), /*asm_label=*/{}, method_ct, access_type, - attrs.isVirtual(), attrs.isStatic(), false, false, false, is_artificial); + is_virtual, attrs.isStatic(), false, false, false, is_artificial); m_cxx_record_map[derived_opaque_ty].insert({name, method_ct}); } @@ -336,6 +338,9 @@ void UdtRecordCompleter::complete() { if (auto *record_decl = llvm::dyn_cast<clang::CXXRecordDecl>(&m_tag_decl)) { m_ast_builder.GetClangASTImporter().SetRecordLayout(record_decl, m_layout); } + + if (auto meta = m_ast_builder.clang().GetMetadata(&m_tag_decl)) + meta->SetIsDynamicCXXType(m_any_virtual_method); } uint64_t diff --git a/lldb/source/Plugins/SymbolFile/NativePDB/UdtRecordCompleter.h b/lldb/source/Plugins/SymbolFile/NativePDB/UdtRecordCompleter.h index e6e91d0f2c3e4..08edcf39c4cd8 100644 --- a/lldb/source/Plugins/SymbolFile/NativePDB/UdtRecordCompleter.h +++ b/lldb/source/Plugins/SymbolFile/NativePDB/UdtRecordCompleter.h @@ -59,6 +59,7 @@ class UdtRecordCompleter : public llvm::codeview::TypeVisitorCallbacks { llvm::DenseMap<lldb::opaque_compiler_type_t, llvm::SmallSet<std::pair<llvm::StringRef, CompilerType>, 8>> &m_cxx_record_map; + bool m_any_virtual_method = false; public: UdtRecordCompleter( `````````` </details> https://github.com/llvm/llvm-project/pull/155853 _______________________________________________ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits