Skip to content

[lldb][NFCI] Remove typedef for TypeCategoryMap::ValueSP #65555

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Sep 7, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion lldb/include/lldb/DataFormatters/FormatManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
14 changes: 6 additions & 8 deletions lldb/include/lldb/DataFormatters/TypeCategoryMap.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand All @@ -43,25 +41,25 @@ class TypeCategoryMap {

TypeCategoryMap(IFormatChangeListener *lst);

void Add(KeyType name, const ValueSP &entry);
void Add(KeyType name, const lldb::TypeCategoryImplSP &entry);

bool Delete(KeyType name);

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

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();

void DisableAllCategories();

void Clear();

bool Get(KeyType name, ValueSP &entry);
bool Get(KeyType name, lldb::TypeCategoryImplSP &entry);

void ForEach(ForEachCallback callback);

Expand Down
16 changes: 8 additions & 8 deletions lldb/source/DataFormatters/TypeCategoryMap.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -45,21 +45,21 @@ 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);
}

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;
Expand All @@ -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));
Expand All @@ -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())
Expand All @@ -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;
Expand Down Expand Up @@ -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())
Expand Down