Skip to content

Commit 2e36d3d

Browse files
committed
[lldb][DataFormatter] Remove support for old std::map layout
We currently supported the layout from pre-2016 (before the layout change in 14caaddd3f08e798dcd9ac0ddfc). We have another upcoming layout change in `__tree` and `map` (as part of require rewriting parts of this formatter. Removing the support 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 a017653 commit 2e36d3d

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
@@ -248,11 +248,6 @@ bool lldb_private::formatters::LibcxxStdMapSyntheticFrontEnd::GetDataType() {
248248
deref = m_root_node->Dereference(error);
249249
if (!deref || error.Fail())
250250
return false;
251-
deref = deref->GetChildMemberWithName("__value_");
252-
if (deref) {
253-
m_element_type = deref->GetCompilerType();
254-
return true;
255-
}
256251
deref = m_backend.GetChildAtNamePath({"__tree_", "__pair3_"});
257252
if (!deref)
258253
return false;
@@ -280,40 +275,35 @@ void lldb_private::formatters::LibcxxStdMapSyntheticFrontEnd::GetValueOffset(
280275
return;
281276
if (!node)
282277
return;
278+
283279
CompilerType node_type(node->GetCompilerType());
284-
uint64_t bit_offset;
285-
if (node_type.GetIndexOfFieldWithName("__value_", nullptr, &bit_offset) !=
286-
UINT32_MAX) {
287-
// Old layout (pre d05b10ab4fc65)
288-
m_skip_size = bit_offset / 8u;
289-
} else {
290-
auto ast_ctx = node_type.GetTypeSystem().dyn_cast_or_null<TypeSystemClang>();
291-
if (!ast_ctx)
292-
return;
293-
CompilerType tree_node_type = ast_ctx->CreateStructForIdentifier(
294-
llvm::StringRef(),
295-
{{"ptr0", ast_ctx->GetBasicType(lldb::eBasicTypeVoid).GetPointerType()},
296-
{"ptr1", ast_ctx->GetBasicType(lldb::eBasicTypeVoid).GetPointerType()},
297-
{"ptr2", ast_ctx->GetBasicType(lldb::eBasicTypeVoid).GetPointerType()},
298-
{"cw", ast_ctx->GetBasicType(lldb::eBasicTypeBool)},
299-
{"payload", (m_element_type.GetCompleteType(), m_element_type)}});
300-
std::string child_name;
301-
uint32_t child_byte_size;
302-
int32_t child_byte_offset = 0;
303-
uint32_t child_bitfield_bit_size;
304-
uint32_t child_bitfield_bit_offset;
305-
bool child_is_base_class;
306-
bool child_is_deref_of_parent;
307-
uint64_t language_flags;
308-
auto child_type =
309-
llvm::expectedToStdOptional(tree_node_type.GetChildCompilerTypeAtIndex(
310-
nullptr, 4, true, true, true, child_name, child_byte_size,
311-
child_byte_offset, child_bitfield_bit_size,
312-
child_bitfield_bit_offset, child_is_base_class,
313-
child_is_deref_of_parent, nullptr, language_flags));
314-
if (child_type && child_type->IsValid())
315-
m_skip_size = (uint32_t)child_byte_offset;
316-
}
280+
auto ast_ctx = node_type.GetTypeSystem().dyn_cast_or_null<TypeSystemClang>();
281+
if (!ast_ctx)
282+
return;
283+
284+
CompilerType tree_node_type = ast_ctx->CreateStructForIdentifier(
285+
llvm::StringRef(),
286+
{{"ptr0", ast_ctx->GetBasicType(lldb::eBasicTypeVoid).GetPointerType()},
287+
{"ptr1", ast_ctx->GetBasicType(lldb::eBasicTypeVoid).GetPointerType()},
288+
{"ptr2", ast_ctx->GetBasicType(lldb::eBasicTypeVoid).GetPointerType()},
289+
{"cw", ast_ctx->GetBasicType(lldb::eBasicTypeBool)},
290+
{"payload", (m_element_type.GetCompleteType(), m_element_type)}});
291+
std::string child_name;
292+
uint32_t child_byte_size;
293+
int32_t child_byte_offset = 0;
294+
uint32_t child_bitfield_bit_size;
295+
uint32_t child_bitfield_bit_offset;
296+
bool child_is_base_class;
297+
bool child_is_deref_of_parent;
298+
uint64_t language_flags;
299+
auto child_type =
300+
llvm::expectedToStdOptional(tree_node_type.GetChildCompilerTypeAtIndex(
301+
nullptr, 4, true, true, true, child_name, child_byte_size,
302+
child_byte_offset, child_bitfield_bit_size, child_bitfield_bit_offset,
303+
child_is_base_class, child_is_deref_of_parent, nullptr,
304+
language_flags));
305+
if (child_type && child_type->IsValid())
306+
m_skip_size = (uint32_t)child_byte_offset;
317307
}
318308

319309
ValueObjectSP
@@ -348,14 +338,8 @@ lldb_private::formatters::LibcxxStdMapSyntheticFrontEnd::GetKeyValuePair(
348338
return nullptr;
349339

350340
GetValueOffset(iterated_sp);
351-
auto child_sp = iterated_sp->GetChildMemberWithName("__value_");
352-
if (child_sp) {
353-
// Old layout (pre 089a7cc5dea)
354-
iterated_sp = child_sp;
355-
} else {
356-
iterated_sp = iterated_sp->GetSyntheticChildAtOffset(
357-
m_skip_size, m_element_type, true);
358-
}
341+
iterated_sp = iterated_sp->GetSyntheticChildAtOffset(m_skip_size,
342+
m_element_type, true);
359343

360344
if (!iterated_sp)
361345
return nullptr;

0 commit comments

Comments
 (0)