Skip to content

Commit 94c0bdd

Browse files
committed
fixup! adjust remaining STL types
1 parent 22b5d31 commit 94c0bdd

File tree

1 file changed

+19
-19
lines changed

1 file changed

+19
-19
lines changed

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

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -49,10 +49,6 @@ static void consumeInlineNamespace(llvm::StringRef &name) {
4949
}
5050
}
5151

52-
static bool isOldCompressedPairLayout(ValueObject &pair_obj) {
53-
return isStdTemplate(pair_obj.GetTypeName(), "__compressed_pair");
54-
}
55-
5652
bool lldb_private::formatters::isStdTemplate(ConstString type_name,
5753
llvm::StringRef type) {
5854
llvm::StringRef name = type_name.GetStringRef();
@@ -108,18 +104,22 @@ std::pair<lldb::ValueObjectSP, bool>
108104
lldb_private::formatters::GetValueOrOldCompressedPair(
109105
ValueObject &obj, size_t anon_struct_idx, llvm::StringRef child_name,
110106
llvm::StringRef compressed_pair_name) {
107+
auto is_old_compressed_pair = [](ValueObject &pair_obj) -> bool {
108+
return isStdTemplate(pair_obj.GetTypeName(), "__compressed_pair");
109+
};
110+
111111
// Try searching the child member in an anonymous structure first.
112112
if (auto unwrapped = obj.GetChildAtIndex(anon_struct_idx)) {
113113
ValueObjectSP node_sp(obj.GetChildMemberWithName(child_name));
114114
if (node_sp)
115-
return {node_sp, isOldCompressedPairLayout(*node_sp)};
115+
return {node_sp, is_old_compressed_pair(*node_sp)};
116116
}
117117

118118
// Older versions of libc++ don't wrap the children in anonymous structures.
119119
// Try that instead.
120120
ValueObjectSP node_sp(obj.GetChildMemberWithName(child_name));
121121
if (node_sp)
122-
return {node_sp, isOldCompressedPairLayout(*node_sp)};
122+
return {node_sp, is_old_compressed_pair(*node_sp)};
123123

124124
// Try the even older __compressed_pair layout.
125125

@@ -132,7 +132,7 @@ lldb_private::formatters::GetValueOrOldCompressedPair(
132132
return {nullptr, false};
133133

134134
// Expected old compressed_pair layout, but got something else.
135-
if (!isOldCompressedPairLayout(*node_sp))
135+
if (!is_old_compressed_pair(*node_sp))
136136
return {nullptr, false};
137137

138138
return {node_sp, true};
@@ -238,11 +238,12 @@ bool lldb_private::formatters::LibcxxUniquePointerSummaryProvider(
238238
if (!valobj_sp)
239239
return false;
240240

241-
ValueObjectSP ptr_sp(valobj_sp->GetChildMemberWithName("__ptr_"));
241+
auto [ptr_sp, is_compressed_pair] = GetValueOrOldCompressedPair(
242+
*valobj_sp, /*anon_struct_idx=*/0, "__ptr_", "__ptr_");
242243
if (!ptr_sp)
243244
return false;
244245

245-
if (isOldCompressedPairLayout(*ptr_sp))
246+
if (is_compressed_pair)
246247
ptr_sp = GetFirstValueOfLibCXXCompressedPair(*ptr_sp);
247248

248249
if (!ptr_sp)
@@ -412,13 +413,14 @@ lldb_private::formatters::LibcxxUniquePtrSyntheticFrontEnd::Update() {
412413
if (!valobj_sp)
413414
return lldb::ChildCacheState::eRefetch;
414415

415-
ValueObjectSP ptr_sp(valobj_sp->GetChildMemberWithName("__ptr_"));
416+
auto [ptr_sp, is_compressed_pair] = GetValueOrOldCompressedPair(
417+
*valobj_sp, /*anon_struct_idx=*/0, "__ptr_", "__ptr_");
416418
if (!ptr_sp)
417419
return lldb::ChildCacheState::eRefetch;
418420

419421
// Retrieve the actual pointer and the deleter, and clone them to give them
420422
// user-friendly names.
421-
if (isOldCompressedPairLayout(*ptr_sp)) {
423+
if (is_compressed_pair) {
422424
if (ValueObjectSP value_pointer_sp =
423425
GetFirstValueOfLibCXXCompressedPair(*ptr_sp))
424426
m_value_ptr_sp = value_pointer_sp->Clone(ConstString("pointer"));
@@ -457,17 +459,15 @@ enum class StringLayout { CSD, DSC };
457459
}
458460

459461
static ValueObjectSP ExtractLibCxxStringData(ValueObject &valobj) {
460-
if (auto rep_sp = valobj.GetChildMemberWithName("__rep_"))
461-
return rep_sp;
462-
463-
ValueObjectSP valobj_r_sp = valobj.GetChildMemberWithName("__r_");
464-
if (!valobj_r_sp || !valobj_r_sp->GetError().Success())
462+
auto [valobj_r_sp, is_compressed_pair] = GetValueOrOldCompressedPair(
463+
valobj, /*anon_struct_idx=*/0, "__rep_", "__r_");
464+
if (!valobj_r_sp)
465465
return nullptr;
466466

467-
if (!isOldCompressedPairLayout(*valobj_r_sp))
468-
return nullptr;
467+
if (is_compressed_pair)
468+
return GetFirstValueOfLibCXXCompressedPair(*valobj_r_sp);
469469

470-
return GetFirstValueOfLibCXXCompressedPair(*valobj_r_sp);
470+
return valobj_r_sp;
471471
}
472472

473473
/// Determine the size in bytes of \p valobj (a libc++ std::string object) and

0 commit comments

Comments
 (0)