Skip to content

Commit 1e6dfc6

Browse files
authored
[lldb][DataFormatter] Remove support for old std::map layout (#97549)
We currently supported the layout from pre-2016 (before the layout change in [14caaddd3f08e798dcd9ac0ddfc](14caaddd3f08e798dcd9ac0ddfc)). We have another upcoming layout change in `__tree` and `map` (as part of #93069) which will likely require rewriting parts of this formatter. Removing the support for the pre-2016 layout will make those changes more straightforward to review/maintain. Being backward compatible would be great but we have no tests that actually verify that the old layout still works (and our oldest matrix bot tests clang-15). If anyone feels strongly about keeping this layout, we could possibly factor out that logic and keep it around.
1 parent b9254ad commit 1e6dfc6

File tree

1 file changed

+30
-46
lines changed

1 file changed

+30
-46
lines changed

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

Lines changed: 30 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -269,11 +269,6 @@ bool lldb_private::formatters::LibcxxStdMapSyntheticFrontEnd::GetDataType() {
269269
deref = m_root_node->Dereference(error);
270270
if (!deref || error.Fail())
271271
return false;
272-
deref = deref->GetChildMemberWithName("__value_");
273-
if (deref) {
274-
m_element_type = deref->GetCompilerType();
275-
return true;
276-
}
277272
deref = m_backend.GetChildAtNamePath({"__tree_", "__pair3_"});
278273
if (!deref)
279274
return false;
@@ -301,40 +296,35 @@ void lldb_private::formatters::LibcxxStdMapSyntheticFrontEnd::GetValueOffset(
301296
return;
302297
if (!node)
303298
return;
299+
304300
CompilerType node_type(node->GetCompilerType());
305-
uint64_t bit_offset;
306-
if (node_type.GetIndexOfFieldWithName("__value_", nullptr, &bit_offset) !=
307-
UINT32_MAX) {
308-
// Old layout (pre d05b10ab4fc65)
309-
m_skip_size = bit_offset / 8u;
310-
} else {
311-
auto ast_ctx = node_type.GetTypeSystem().dyn_cast_or_null<TypeSystemClang>();
312-
if (!ast_ctx)
313-
return;
314-
CompilerType tree_node_type = ast_ctx->CreateStructForIdentifier(
315-
llvm::StringRef(),
316-
{{"ptr0", ast_ctx->GetBasicType(lldb::eBasicTypeVoid).GetPointerType()},
317-
{"ptr1", ast_ctx->GetBasicType(lldb::eBasicTypeVoid).GetPointerType()},
318-
{"ptr2", ast_ctx->GetBasicType(lldb::eBasicTypeVoid).GetPointerType()},
319-
{"cw", ast_ctx->GetBasicType(lldb::eBasicTypeBool)},
320-
{"payload", (m_element_type.GetCompleteType(), m_element_type)}});
321-
std::string child_name;
322-
uint32_t child_byte_size;
323-
int32_t child_byte_offset = 0;
324-
uint32_t child_bitfield_bit_size;
325-
uint32_t child_bitfield_bit_offset;
326-
bool child_is_base_class;
327-
bool child_is_deref_of_parent;
328-
uint64_t language_flags;
329-
auto child_type =
330-
llvm::expectedToStdOptional(tree_node_type.GetChildCompilerTypeAtIndex(
331-
nullptr, 4, true, true, true, child_name, child_byte_size,
332-
child_byte_offset, child_bitfield_bit_size,
333-
child_bitfield_bit_offset, child_is_base_class,
334-
child_is_deref_of_parent, nullptr, language_flags));
335-
if (child_type && child_type->IsValid())
336-
m_skip_size = (uint32_t)child_byte_offset;
337-
}
301+
auto ast_ctx = node_type.GetTypeSystem().dyn_cast_or_null<TypeSystemClang>();
302+
if (!ast_ctx)
303+
return;
304+
305+
CompilerType tree_node_type = ast_ctx->CreateStructForIdentifier(
306+
llvm::StringRef(),
307+
{{"ptr0", ast_ctx->GetBasicType(lldb::eBasicTypeVoid).GetPointerType()},
308+
{"ptr1", ast_ctx->GetBasicType(lldb::eBasicTypeVoid).GetPointerType()},
309+
{"ptr2", ast_ctx->GetBasicType(lldb::eBasicTypeVoid).GetPointerType()},
310+
{"cw", ast_ctx->GetBasicType(lldb::eBasicTypeBool)},
311+
{"payload", (m_element_type.GetCompleteType(), m_element_type)}});
312+
std::string child_name;
313+
uint32_t child_byte_size;
314+
int32_t child_byte_offset = 0;
315+
uint32_t child_bitfield_bit_size;
316+
uint32_t child_bitfield_bit_offset;
317+
bool child_is_base_class;
318+
bool child_is_deref_of_parent;
319+
uint64_t language_flags;
320+
auto child_type =
321+
llvm::expectedToStdOptional(tree_node_type.GetChildCompilerTypeAtIndex(
322+
nullptr, 4, true, true, true, child_name, child_byte_size,
323+
child_byte_offset, child_bitfield_bit_size, child_bitfield_bit_offset,
324+
child_is_base_class, child_is_deref_of_parent, nullptr,
325+
language_flags));
326+
if (child_type && child_type->IsValid())
327+
m_skip_size = (uint32_t)child_byte_offset;
338328
}
339329

340330
ValueObjectSP
@@ -369,14 +359,8 @@ lldb_private::formatters::LibcxxStdMapSyntheticFrontEnd::GetKeyValuePair(
369359
return nullptr;
370360

371361
GetValueOffset(iterated_sp);
372-
auto child_sp = iterated_sp->GetChildMemberWithName("__value_");
373-
if (child_sp) {
374-
// Old layout (pre 089a7cc5dea)
375-
iterated_sp = child_sp;
376-
} else {
377-
iterated_sp = iterated_sp->GetSyntheticChildAtOffset(
378-
m_skip_size, m_element_type, true);
379-
}
362+
iterated_sp = iterated_sp->GetSyntheticChildAtOffset(m_skip_size,
363+
m_element_type, true);
380364

381365
if (!iterated_sp)
382366
return nullptr;

0 commit comments

Comments
 (0)