Skip to content

Commit 2c16566

Browse files
committed
[lldb] Remove an obsolete wrapper class (NFC)
1 parent f379c52 commit 2c16566

File tree

3 files changed

+14
-46
lines changed

3 files changed

+14
-46
lines changed

lldb/source/Plugins/Language/Swift/SwiftOptional.cpp

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ std::string lldb_private::formatters::swift::SwiftOptionalSummaryProvider::
4040

4141
// if this ValueObject is an Optional<T> with the Some(T) case selected,
4242
// retrieve the value of the Some case..
43-
static PointerOrSP
43+
static ValueObjectSP
4444
ExtractSomeIfAny(ValueObject *optional,
4545
bool synthetic_value = false) {
4646
if (!optional)
@@ -58,8 +58,8 @@ ExtractSomeIfAny(ValueObject *optional,
5858
if (!value || value == g_None)
5959
return nullptr;
6060

61-
PointerOrSP value_sp(
62-
non_synth_valobj->GetChildMemberWithName(g_Some, true).get());
61+
ValueObjectSP value_sp(
62+
non_synth_valobj->GetChildMemberWithName(g_Some, true));
6363
if (!value_sp)
6464
return nullptr;
6565

@@ -86,7 +86,7 @@ ExtractSomeIfAny(ValueObject *optional,
8686
DataExtractor extractor(buffer_sp, process_sp->GetByteOrder(),
8787
process_sp->GetAddressByteSize());
8888
ExecutionContext exe_ctx(process_sp);
89-
value_sp = PointerOrSP(ValueObject::CreateValueObjectFromData(
89+
value_sp = ValueObjectSP(ValueObject::CreateValueObjectFromData(
9090
value_sp->GetName().AsCString(), extractor, exe_ctx, value_type));
9191
if (!value_sp)
9292
return nullptr;
@@ -116,12 +116,12 @@ ExtractSomeIfAny(ValueObject *optional,
116116
value_sp = value_sp->GetSyntheticValue();
117117

118118
return value_sp;
119-
}
119+
}
120120

121121
static bool
122122
SwiftOptional_SummaryProvider_Impl(ValueObject &valobj, Stream &stream,
123123
const TypeSummaryOptions &options) {
124-
PointerOrSP some = ExtractSomeIfAny(&valobj, true);
124+
ValueObjectSP some = ExtractSomeIfAny(&valobj, true);
125125
if (!some) {
126126
stream.Printf("nil");
127127
return true;
@@ -145,7 +145,7 @@ SwiftOptional_SummaryProvider_Impl(ValueObject &valobj, Stream &stream,
145145
.SetSkipReferences(false);
146146
StringSummaryFormat oneliner(oneliner_flags, "");
147147
std::string buffer;
148-
oneliner.FormatObject(some, buffer, options);
148+
oneliner.FormatObject(some.get(), buffer, options);
149149
stream.Printf("%s", buffer.c_str());
150150
}
151151

@@ -172,7 +172,7 @@ bool lldb_private::formatters::swift::SwiftOptionalSummaryProvider::
172172
if (!target_valobj)
173173
return false;
174174

175-
PointerOrSP some = ExtractSomeIfAny(target_valobj, true);
175+
ValueObjectSP some = ExtractSomeIfAny(target_valobj, true);
176176

177177
if (!some)
178178
return true;
@@ -191,7 +191,7 @@ bool lldb_private::formatters::swift::SwiftOptionalSummaryProvider::
191191
return false;
192192
return some->HasChildren();
193193
}
194-
return some->HasChildren() && summary_sp->DoesPrintChildren(some);
194+
return some->HasChildren() && summary_sp->DoesPrintChildren(some.get());
195195
}
196196

197197
bool lldb_private::formatters::swift::SwiftOptionalSummaryProvider::

lldb/source/Plugins/Language/Swift/SwiftOptional.h

Lines changed: 1 addition & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -22,42 +22,6 @@
2222

2323
namespace lldb_private {
2424
namespace formatters {
25-
// ExtractSomeIfAny() can return EITHER a child member or some other long-lived
26-
// ValueObject
27-
// OR an entirely consed-up ValueObject
28-
// The lifetime of these two is radically different, and there is no trivial way
29-
// to do the right
30-
// thing for both cases - except have a class that can wrap either and is safe
31-
// to store and pass around
32-
class PointerOrSP {
33-
public:
34-
PointerOrSP(std::nullptr_t) : m_raw_ptr(nullptr), m_shared_ptr(nullptr) {}
35-
36-
PointerOrSP(ValueObject *valobj) : m_raw_ptr(valobj), m_shared_ptr(nullptr) {}
37-
38-
PointerOrSP(lldb::ValueObjectSP valobj_sp)
39-
: m_raw_ptr(nullptr), m_shared_ptr(valobj_sp) {}
40-
41-
ValueObject *operator->() {
42-
if (m_shared_ptr)
43-
return m_shared_ptr.get();
44-
return m_raw_ptr;
45-
}
46-
47-
ValueObject &operator*() { return *(this->operator->()); }
48-
49-
operator ValueObject *() { return this->operator->(); }
50-
51-
explicit operator bool() const {
52-
return (m_shared_ptr.get() != nullptr) || (m_raw_ptr != nullptr);
53-
}
54-
55-
bool operator==(std::nullptr_t) const { return !(this->operator bool()); }
56-
57-
protected:
58-
ValueObject *m_raw_ptr;
59-
lldb::ValueObjectSP m_shared_ptr;
60-
};
6125

6226
namespace swift {
6327
struct SwiftOptionalSummaryProvider : public TypeSummaryImpl {
@@ -92,7 +56,7 @@ class SwiftOptionalSyntheticFrontEnd : public SyntheticChildrenFrontEnd {
9256
private:
9357
bool m_is_none;
9458
bool m_children;
95-
PointerOrSP m_some;
59+
lldb::ValueObjectSP m_some;
9660

9761
bool IsEmpty() const;
9862
};

lldb/source/Plugins/LanguageRuntime/Swift/SwiftLanguageRuntimeDynamicTypeResolution.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -866,6 +866,10 @@ SwiftLanguageRuntime::GetNumFields(CompilerType type,
866866
return rti->getNumFields();
867867
}
868868
}
869+
case TypeInfoKind::Builtin: {
870+
// Clang types without debug info may present themselves like this.
871+
return {};
872+
}
869873
case TypeInfoKind::Enum: {
870874
auto *eti = llvm::cast<EnumTypeInfo>(ti);
871875
return eti->getNumPayloadCases();

0 commit comments

Comments
 (0)