[Lldb-commits] [lldb] [LLDB] Fix MS STL `variant` with non-trivial types and PDB (PR #171489)

Michael Buch via lldb-commits lldb-commits at lists.llvm.org
Thu Dec 11 00:44:45 PST 2025


================
@@ -67,12 +67,18 @@ std::optional<int64_t> GetIndexValue(ValueObject &valobj) {
 ValueObjectSP GetNthStorage(ValueObject &outer, int64_t index) {
   // We need to find the std::_Variant_storage base class.
 
-  // -> std::_SMF_control (typedef to std::_Variant_base)
-  ValueObjectSP container_sp = outer.GetSP()->GetChildAtIndex(0);
-  if (!container_sp)
+  // Navigate "down" to std::_Variant_base by finding the holder of "_Which".
+  // This might be down a few levels if a variant member isn't trivially
+  // destructible/copyable/etc.
+  ValueObjectSP which_sp = outer.GetChildMemberWithName("_Which");
----------------
Michael137 wrote:

Is this related to making it run with PDB? Or is this about handling more kinds of variant layouts in general? Is that where the additional test-case comes from? If it's the latter I'd prefer it if we split it into a separate PR

https://github.com/llvm/llvm-project/pull/171489


More information about the lldb-commits mailing list