[Lldb-commits] [lldb] [lldb][NFCI] Remove typedef for TypeCategoryMap::ValueSP (PR #65555)
via lldb-commits
lldb-commits at lists.llvm.org
Wed Sep 6 17:15:22 PDT 2023
https://github.com/bulbazord created https://github.com/llvm/llvm-project/pull/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>`.
>From 818c728e55ab78b9a20a542a1b6829981994094b Mon Sep 17 00:00:00 2001
From: Alex Langford <alangford at apple.com>
Date: Wed, 6 Sep 2023 17:07:09 -0700
Subject: [PATCH] [lldb][NFCI] Remove typedef for TypeCategoryMap::ValueSP
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>`.
---
lldb/include/lldb/DataFormatters/FormatManager.h | 2 +-
.../lldb/DataFormatters/TypeCategoryMap.h | 14 ++++++--------
lldb/source/DataFormatters/TypeCategoryMap.cpp | 16 ++++++++--------
3 files changed, 15 insertions(+), 17 deletions(-)
diff --git a/lldb/include/lldb/DataFormatters/FormatManager.h b/lldb/include/lldb/DataFormatters/FormatManager.h
index 295d3b84342a5d2..986614f0c5e431f 100644
--- a/lldb/include/lldb/DataFormatters/FormatManager.h
+++ b/lldb/include/lldb/DataFormatters/FormatManager.h
@@ -57,7 +57,7 @@ class FormatManager : public IFormatChangeListener {
void EnableCategory(ConstString category_name,
TypeCategoryMap::Position pos, lldb::LanguageType lang) {
- TypeCategoryMap::ValueSP category_sp;
+ lldb::TypeCategoryImplSP category_sp;
if (m_categories_map.Get(category_name, category_sp) && category_sp) {
m_categories_map.Enable(category_sp, pos);
category_sp->AddLanguage(lang);
diff --git a/lldb/include/lldb/DataFormatters/TypeCategoryMap.h b/lldb/include/lldb/DataFormatters/TypeCategoryMap.h
index 363d841b198a297..efd01f321da92f1 100644
--- a/lldb/include/lldb/DataFormatters/TypeCategoryMap.h
+++ b/lldb/include/lldb/DataFormatters/TypeCategoryMap.h
@@ -29,11 +29,9 @@ class TypeCategoryMap {
public:
typedef ConstString KeyType;
- typedef TypeCategoryImpl ValueType;
- typedef ValueType::SharedPointer ValueSP;
- typedef std::map<KeyType, ValueSP> MapType;
+ typedef std::map<KeyType, lldb::TypeCategoryImplSP> MapType;
typedef MapType::iterator MapIterator;
- typedef std::function<bool(const ValueSP &)> ForEachCallback;
+ typedef std::function<bool(const lldb::TypeCategoryImplSP &)> ForEachCallback;
typedef uint32_t Position;
@@ -43,7 +41,7 @@ class TypeCategoryMap {
TypeCategoryMap(IFormatChangeListener *lst);
- void Add(KeyType name, const ValueSP &entry);
+ void Add(KeyType name, const lldb::TypeCategoryImplSP &entry);
bool Delete(KeyType name);
@@ -51,9 +49,9 @@ class TypeCategoryMap {
bool Disable(KeyType category_name);
- bool Enable(ValueSP category, Position pos = Default);
+ bool Enable(lldb::TypeCategoryImplSP category, Position pos = Default);
- bool Disable(ValueSP category);
+ bool Disable(lldb::TypeCategoryImplSP category);
void EnableAllCategories();
@@ -61,7 +59,7 @@ class TypeCategoryMap {
void Clear();
- bool Get(KeyType name, ValueSP &entry);
+ bool Get(KeyType name, lldb::TypeCategoryImplSP &entry);
void ForEach(ForEachCallback callback);
diff --git a/lldb/source/DataFormatters/TypeCategoryMap.cpp b/lldb/source/DataFormatters/TypeCategoryMap.cpp
index c3de9196e39c553..fd76bab95826af7 100644
--- a/lldb/source/DataFormatters/TypeCategoryMap.cpp
+++ b/lldb/source/DataFormatters/TypeCategoryMap.cpp
@@ -24,7 +24,7 @@ TypeCategoryMap::TypeCategoryMap(IFormatChangeListener *lst)
Enable(default_cs, First);
}
-void TypeCategoryMap::Add(KeyType name, const ValueSP &entry) {
+void TypeCategoryMap::Add(KeyType name, const TypeCategoryImplSP &entry) {
std::lock_guard<std::recursive_mutex> guard(m_map_mutex);
m_map[name] = entry;
if (listener)
@@ -45,7 +45,7 @@ bool TypeCategoryMap::Delete(KeyType name) {
bool TypeCategoryMap::Enable(KeyType category_name, Position pos) {
std::lock_guard<std::recursive_mutex> guard(m_map_mutex);
- ValueSP category;
+ TypeCategoryImplSP category;
if (!Get(category_name, category))
return false;
return Enable(category, pos);
@@ -53,13 +53,13 @@ bool TypeCategoryMap::Enable(KeyType category_name, Position pos) {
bool TypeCategoryMap::Disable(KeyType category_name) {
std::lock_guard<std::recursive_mutex> guard(m_map_mutex);
- ValueSP category;
+ TypeCategoryImplSP category;
if (!Get(category_name, category))
return false;
return Disable(category);
}
-bool TypeCategoryMap::Enable(ValueSP category, Position pos) {
+bool TypeCategoryMap::Enable(TypeCategoryImplSP category, Position pos) {
std::lock_guard<std::recursive_mutex> guard(m_map_mutex);
if (category.get()) {
Position pos_w = pos;
@@ -81,7 +81,7 @@ bool TypeCategoryMap::Enable(ValueSP category, Position pos) {
return false;
}
-bool TypeCategoryMap::Disable(ValueSP category) {
+bool TypeCategoryMap::Disable(TypeCategoryImplSP category) {
std::lock_guard<std::recursive_mutex> guard(m_map_mutex);
if (category.get()) {
m_active_categories.remove_if(delete_matching_categories(category));
@@ -93,7 +93,7 @@ bool TypeCategoryMap::Disable(ValueSP category) {
void TypeCategoryMap::EnableAllCategories() {
std::lock_guard<std::recursive_mutex> guard(m_map_mutex);
- std::vector<ValueSP> sorted_categories(m_map.size(), ValueSP());
+ std::vector<TypeCategoryImplSP> sorted_categories(m_map.size(), TypeCategoryImplSP());
MapType::iterator iter = m_map.begin(), end = m_map.end();
for (; iter != end; ++iter) {
if (iter->second->IsEnabled())
@@ -102,7 +102,7 @@ void TypeCategoryMap::EnableAllCategories() {
if (pos >= sorted_categories.size()) {
auto iter = std::find_if(
sorted_categories.begin(), sorted_categories.end(),
- [](const ValueSP &sp) -> bool { return sp.get() == nullptr; });
+ [](const TypeCategoryImplSP &sp) -> bool { return sp.get() == nullptr; });
pos = std::distance(sorted_categories.begin(), iter);
}
sorted_categories.at(pos) = iter->second;
@@ -130,7 +130,7 @@ void TypeCategoryMap::Clear() {
listener->Changed();
}
-bool TypeCategoryMap::Get(KeyType name, ValueSP &entry) {
+bool TypeCategoryMap::Get(KeyType name, TypeCategoryImplSP &entry) {
std::lock_guard<std::recursive_mutex> guard(m_map_mutex);
MapIterator iter = m_map.find(name);
if (iter == m_map.end())
More information about the lldb-commits
mailing list