Skip to content

Commit 918848d

Browse files
authored
[lldb] Devirtualize GetValueProperties (NFC) (llvm#126583)
Nobody is overriding GetValueProperties, so in practice we're always using `m_collection_sp`, which means we don't need to check the pointer. The temlated helpers were already operating on `m_collection_sp` directly so this makes the rest of the class consistent.
1 parent 55ae118 commit 918848d

File tree

2 files changed

+8
-29
lines changed

2 files changed

+8
-29
lines changed

lldb/include/lldb/Core/UserSettingsController.h

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,9 +38,7 @@ class Properties {
3838

3939
virtual ~Properties();
4040

41-
virtual lldb::OptionValuePropertiesSP GetValueProperties() const {
42-
// This function is virtual in case subclasses want to lazily implement
43-
// creating the properties.
41+
lldb::OptionValuePropertiesSP GetValueProperties() const {
4442
return m_collection_sp;
4543
}
4644

lldb/source/Core/UserSettingsController.cpp

Lines changed: 7 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -40,64 +40,45 @@ Properties::~Properties() = default;
4040
lldb::OptionValueSP
4141
Properties::GetPropertyValue(const ExecutionContext *exe_ctx,
4242
llvm::StringRef path, Status &error) const {
43-
OptionValuePropertiesSP properties_sp(GetValueProperties());
44-
if (properties_sp)
45-
return properties_sp->GetSubValue(exe_ctx, path, error);
46-
return lldb::OptionValueSP();
43+
return m_collection_sp->GetSubValue(exe_ctx, path, error);
4744
}
4845

4946
Status Properties::SetPropertyValue(const ExecutionContext *exe_ctx,
5047
VarSetOperationType op,
5148
llvm::StringRef path,
5249
llvm::StringRef value) {
53-
OptionValuePropertiesSP properties_sp(GetValueProperties());
54-
if (properties_sp)
55-
return properties_sp->SetSubValue(exe_ctx, op, path, value);
56-
return Status::FromErrorString("no properties");
50+
return m_collection_sp->SetSubValue(exe_ctx, op, path, value);
5751
}
5852

5953
void Properties::DumpAllPropertyValues(const ExecutionContext *exe_ctx,
6054
Stream &strm, uint32_t dump_mask,
6155
bool is_json) {
62-
OptionValuePropertiesSP properties_sp(GetValueProperties());
63-
if (!properties_sp)
64-
return;
65-
6656
if (is_json) {
67-
llvm::json::Value json = properties_sp->ToJSON(exe_ctx);
57+
llvm::json::Value json = m_collection_sp->ToJSON(exe_ctx);
6858
strm.Printf("%s", llvm::formatv("{0:2}", json).str().c_str());
6959
} else
70-
properties_sp->DumpValue(exe_ctx, strm, dump_mask);
60+
m_collection_sp->DumpValue(exe_ctx, strm, dump_mask);
7161
}
7262

7363
void Properties::DumpAllDescriptions(CommandInterpreter &interpreter,
7464
Stream &strm) const {
7565
strm.PutCString("Top level variables:\n\n");
7666

77-
OptionValuePropertiesSP properties_sp(GetValueProperties());
78-
if (properties_sp)
79-
return properties_sp->DumpAllDescriptions(interpreter, strm);
67+
return m_collection_sp->DumpAllDescriptions(interpreter, strm);
8068
}
8169

8270
Status Properties::DumpPropertyValue(const ExecutionContext *exe_ctx,
8371
Stream &strm,
8472
llvm::StringRef property_path,
8573
uint32_t dump_mask, bool is_json) {
86-
OptionValuePropertiesSP properties_sp(GetValueProperties());
87-
if (properties_sp) {
88-
return properties_sp->DumpPropertyValue(exe_ctx, strm, property_path,
74+
return m_collection_sp->DumpPropertyValue(exe_ctx, strm, property_path,
8975
dump_mask, is_json);
90-
}
91-
return Status::FromErrorString("empty property list");
9276
}
9377

9478
size_t
9579
Properties::Apropos(llvm::StringRef keyword,
9680
std::vector<const Property *> &matching_properties) const {
97-
OptionValuePropertiesSP properties_sp(GetValueProperties());
98-
if (properties_sp) {
99-
properties_sp->Apropos(keyword, matching_properties);
100-
}
81+
m_collection_sp->Apropos(keyword, matching_properties);
10182
return matching_properties.size();
10283
}
10384

0 commit comments

Comments
 (0)