================
@@ -601,21 +601,26 @@ PdbAstBuilder::CreateModifierType(const ModifierRecord
&modifier) {
}
clang::QualType PdbAstBuilder::CreateRecordType(PdbTypeSymId id,
- const TagRecord &record) {
+ const CVTagRecord &record) {
clang::DeclContext *context = nullptr;
std::string uname;
- std::tie(context, uname) = CreateDeclInfoForType(record, id.index);
+ std::tie(context, uname) = CreateDeclInfoForType(record.asTag(), id.index);
if (!context)
return {};
- clang::TagTypeKind ttk = TranslateUdtKind(record);
+ clang::TagTypeKind ttk = TranslateUdtKind(record.asTag());
lldb::AccessType access = (ttk == clang::TagTypeKind::Class)
? lldb::eAccessPrivate
: lldb::eAccessPublic;
ClangASTMetadata metadata;
metadata.SetUserID(toOpaqueUid(id));
- metadata.SetIsDynamicCXXType(false);
+ // If a class has a vtable, it is dynamic.
+ // Otherwise, we wait until the record is completed - it might have virtual
+ // bases.
+ if (record.contextKind() == CompilerContextKind::ClassOrStruct &&
+ !record.asClass().getVTableShape().isNoneType())
+ metadata.SetIsDynamicCXXType(true);
----------------
Nerixyz wrote:
We should only set it to false if we know it can't ever be dynamic. At this
point (when only looking at the tag record), we know that unions can't be
dynamic.
However, for classes and structs, we might discover that they have virtual
bases when completing them. For example:
- Create record type for class with virtual bases
- Someone calls `IsPossibleDynamicType()`
- This [will complete the
type](https://github.com/llvm/llvm-project/blob/9d7449a82b83ee589b8af8d6f86525727788b3b9/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp#L3677)
- `UdtRecordCompleter` sets the class to be dynamic
If we were to set this to `false` in the beginning, `IsPossibleDynamicType`
would return `false` until the type is completed.
https://github.com/llvm/llvm-project/pull/155853
_______________________________________________
lldb-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits