[Lldb-commits] [PATCH] D126103: Remove `friend` classes from TypeCategoryMap
Jorge Gorbe Moya via Phabricator via lldb-commits
lldb-commits at lists.llvm.org
Fri May 20 16:15:38 PDT 2022
jgorbe created this revision.
jgorbe added reviewers: labath, JDevlieghere.
Herald added a project: All.
jgorbe requested review of this revision.
Herald added a project: LLDB.
As far as I can tell, the only thing those `friend` classes access is the
`ValueSP` typedef.
Given that this is a map-ish class, with "Map" in its name, it doesn't seem like
a stretch to make `KeyType`, `ValueType` and `ValueSP` public. More so when the
public methods of the class have `KeyType` and `ValueSP` arguments and clearly
`ValueSP` needs to be accessed from the outside.
`friend` complicates local reasoning about who can access private members, which
is valuable in a class like this that has every method locking a mutex to
prevent concurrent access.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D126103
Files:
lldb/include/lldb/DataFormatters/TypeCategoryMap.h
Index: lldb/include/lldb/DataFormatters/TypeCategoryMap.h
===================================================================
--- lldb/include/lldb/DataFormatters/TypeCategoryMap.h
+++ lldb/include/lldb/DataFormatters/TypeCategoryMap.h
@@ -23,13 +23,13 @@
namespace lldb_private {
class TypeCategoryMap {
private:
- typedef ConstString KeyType;
- typedef TypeCategoryImpl ValueType;
- typedef ValueType::SharedPointer ValueSP;
typedef std::list<lldb::TypeCategoryImplSP> ActiveCategoriesList;
typedef ActiveCategoriesList::iterator ActiveCategoriesIterator;
public:
+ typedef ConstString KeyType;
+ typedef TypeCategoryImpl ValueType;
+ typedef ValueType::SharedPointer ValueSP;
typedef std::map<KeyType, ValueSP> MapType;
typedef MapType::iterator MapIterator;
typedef std::function<bool(const ValueSP &)> ForEachCallback;
@@ -103,9 +103,6 @@
ActiveCategoriesList &active_list() { return m_active_categories; }
std::recursive_mutex &mutex() { return m_map_mutex; }
-
- friend class FormattersContainer<ValueType>;
- friend class FormatManager;
};
} // namespace lldb_private
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D126103.431082.patch
Type: text/x-patch
Size: 1117 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/lldb-commits/attachments/20220520/8a52ec8d/attachment.bin>
More information about the lldb-commits
mailing list