Skip to content

Commit 66ab512

Browse files
committed
fix(variant): support non-trivially destructable types
1 parent eeef5f3 commit 66ab512

File tree

1 file changed

+11
-7
lines changed

1 file changed

+11
-7
lines changed

lldb/source/Plugins/Language/CPlusPlus/MsvcStlVariant.cpp

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -69,14 +69,18 @@ std::optional<int64_t> GetIndexValue(ValueObject &valobj) {
6969
}
7070

7171
ValueObjectSP GetNthStorage(ValueObject &outer, int64_t index) {
72-
// We need to find the std::_Variant_storage base class.
73-
74-
// -> std::_SMF_control (typedef to std::_Variant_base)
75-
ValueObjectSP container_sp = outer.GetSP()->GetChildAtIndex(0);
76-
if (!container_sp)
72+
// navigate "down" to std::_SMF_control/std::_Variant_base
73+
// by finding the holder of "_Which". This might be down a few levels if a
74+
// variant member isn't trivally destructible/copyable/etc.
75+
ValueObjectSP which_sp = outer.GetChildMemberWithName("_Which");
76+
if (!which_sp)
7777
return nullptr;
78-
// -> std::_Variant_storage
79-
container_sp = container_sp->GetChildAtIndex(0);
78+
ValueObject *parent = which_sp->GetParent();
79+
if (!parent)
80+
return nullptr;
81+
82+
// Now go to std::_Variant_storage
83+
ValueObjectSP container_sp = parent->GetChildAtIndex(0);
8084
if (!container_sp)
8185
return nullptr;
8286

0 commit comments

Comments
 (0)