Skip to content

Commit 140f616

Browse files
authored
[lldb][NFCI] Remove typedef for TypeCategoryMap::ValueSP (#65555)
lldb already has a `ValueSP` type. This was confusing to me when reading TypeCategoryMap, especially when `ValueSP` is not qualified. From first glance it looks like it's referring to a `std::shared_ptr<lldb_private::Value>` when it's really referring to a `std::shared_ptr<lldb_private::TypeCategoryImpl>`.
1 parent 1e6b0df commit 140f616

File tree

3 files changed

+15
-17
lines changed

3 files changed

+15
-17
lines changed

lldb/include/lldb/DataFormatters/FormatManager.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ class FormatManager : public IFormatChangeListener {
5757

5858
void EnableCategory(ConstString category_name,
5959
TypeCategoryMap::Position pos, lldb::LanguageType lang) {
60-
TypeCategoryMap::ValueSP category_sp;
60+
lldb::TypeCategoryImplSP category_sp;
6161
if (m_categories_map.Get(category_name, category_sp) && category_sp) {
6262
m_categories_map.Enable(category_sp, pos);
6363
category_sp->AddLanguage(lang);

lldb/include/lldb/DataFormatters/TypeCategoryMap.h

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -29,11 +29,9 @@ class TypeCategoryMap {
2929

3030
public:
3131
typedef ConstString KeyType;
32-
typedef TypeCategoryImpl ValueType;
33-
typedef ValueType::SharedPointer ValueSP;
34-
typedef std::map<KeyType, ValueSP> MapType;
32+
typedef std::map<KeyType, lldb::TypeCategoryImplSP> MapType;
3533
typedef MapType::iterator MapIterator;
36-
typedef std::function<bool(const ValueSP &)> ForEachCallback;
34+
typedef std::function<bool(const lldb::TypeCategoryImplSP &)> ForEachCallback;
3735

3836
typedef uint32_t Position;
3937

@@ -43,25 +41,25 @@ class TypeCategoryMap {
4341

4442
TypeCategoryMap(IFormatChangeListener *lst);
4543

46-
void Add(KeyType name, const ValueSP &entry);
44+
void Add(KeyType name, const lldb::TypeCategoryImplSP &entry);
4745

4846
bool Delete(KeyType name);
4947

5048
bool Enable(KeyType category_name, Position pos = Default);
5149

5250
bool Disable(KeyType category_name);
5351

54-
bool Enable(ValueSP category, Position pos = Default);
52+
bool Enable(lldb::TypeCategoryImplSP category, Position pos = Default);
5553

56-
bool Disable(ValueSP category);
54+
bool Disable(lldb::TypeCategoryImplSP category);
5755

5856
void EnableAllCategories();
5957

6058
void DisableAllCategories();
6159

6260
void Clear();
6361

64-
bool Get(KeyType name, ValueSP &entry);
62+
bool Get(KeyType name, lldb::TypeCategoryImplSP &entry);
6563

6664
void ForEach(ForEachCallback callback);
6765

lldb/source/DataFormatters/TypeCategoryMap.cpp

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ TypeCategoryMap::TypeCategoryMap(IFormatChangeListener *lst)
2424
Enable(default_cs, First);
2525
}
2626

27-
void TypeCategoryMap::Add(KeyType name, const ValueSP &entry) {
27+
void TypeCategoryMap::Add(KeyType name, const TypeCategoryImplSP &entry) {
2828
std::lock_guard<std::recursive_mutex> guard(m_map_mutex);
2929
m_map[name] = entry;
3030
if (listener)
@@ -45,21 +45,21 @@ bool TypeCategoryMap::Delete(KeyType name) {
4545

4646
bool TypeCategoryMap::Enable(KeyType category_name, Position pos) {
4747
std::lock_guard<std::recursive_mutex> guard(m_map_mutex);
48-
ValueSP category;
48+
TypeCategoryImplSP category;
4949
if (!Get(category_name, category))
5050
return false;
5151
return Enable(category, pos);
5252
}
5353

5454
bool TypeCategoryMap::Disable(KeyType category_name) {
5555
std::lock_guard<std::recursive_mutex> guard(m_map_mutex);
56-
ValueSP category;
56+
TypeCategoryImplSP category;
5757
if (!Get(category_name, category))
5858
return false;
5959
return Disable(category);
6060
}
6161

62-
bool TypeCategoryMap::Enable(ValueSP category, Position pos) {
62+
bool TypeCategoryMap::Enable(TypeCategoryImplSP category, Position pos) {
6363
std::lock_guard<std::recursive_mutex> guard(m_map_mutex);
6464
if (category.get()) {
6565
Position pos_w = pos;
@@ -81,7 +81,7 @@ bool TypeCategoryMap::Enable(ValueSP category, Position pos) {
8181
return false;
8282
}
8383

84-
bool TypeCategoryMap::Disable(ValueSP category) {
84+
bool TypeCategoryMap::Disable(TypeCategoryImplSP category) {
8585
std::lock_guard<std::recursive_mutex> guard(m_map_mutex);
8686
if (category.get()) {
8787
m_active_categories.remove_if(delete_matching_categories(category));
@@ -93,7 +93,7 @@ bool TypeCategoryMap::Disable(ValueSP category) {
9393

9494
void TypeCategoryMap::EnableAllCategories() {
9595
std::lock_guard<std::recursive_mutex> guard(m_map_mutex);
96-
std::vector<ValueSP> sorted_categories(m_map.size(), ValueSP());
96+
std::vector<TypeCategoryImplSP> sorted_categories(m_map.size(), TypeCategoryImplSP());
9797
MapType::iterator iter = m_map.begin(), end = m_map.end();
9898
for (; iter != end; ++iter) {
9999
if (iter->second->IsEnabled())
@@ -102,7 +102,7 @@ void TypeCategoryMap::EnableAllCategories() {
102102
if (pos >= sorted_categories.size()) {
103103
auto iter = std::find_if(
104104
sorted_categories.begin(), sorted_categories.end(),
105-
[](const ValueSP &sp) -> bool { return sp.get() == nullptr; });
105+
[](const TypeCategoryImplSP &sp) -> bool { return sp.get() == nullptr; });
106106
pos = std::distance(sorted_categories.begin(), iter);
107107
}
108108
sorted_categories.at(pos) = iter->second;
@@ -130,7 +130,7 @@ void TypeCategoryMap::Clear() {
130130
listener->Changed();
131131
}
132132

133-
bool TypeCategoryMap::Get(KeyType name, ValueSP &entry) {
133+
bool TypeCategoryMap::Get(KeyType name, TypeCategoryImplSP &entry) {
134134
std::lock_guard<std::recursive_mutex> guard(m_map_mutex);
135135
MapIterator iter = m_map.find(name);
136136
if (iter == m_map.end())

0 commit comments

Comments
 (0)