[Lldb-commits] [lldb] 854aa91 - [lldb] Store SupportFile as shared_ptr (NFC)
Jonas Devlieghere via lldb-commits
lldb-commits at lists.llvm.org
Tue Jan 16 15:40:26 PST 2024
Author: Jonas Devlieghere
Date: 2024-01-16T15:40:15-08:00
New Revision: 854aa9112df253bcad4db6f21ea9b2fbca4ed83e
URL: https://github.com/llvm/llvm-project/commit/854aa9112df253bcad4db6f21ea9b2fbca4ed83e
DIFF: https://github.com/llvm/llvm-project/commit/854aa9112df253bcad4db6f21ea9b2fbca4ed83e.diff
LOG: [lldb] Store SupportFile as shared_ptr (NFC)
Added:
Modified:
lldb/include/lldb/Utility/FileSpecList.h
lldb/source/Utility/FileSpecList.cpp
Removed:
################################################################################
diff --git a/lldb/include/lldb/Utility/FileSpecList.h b/lldb/include/lldb/Utility/FileSpecList.h
index 6ddb9d1aa646a2..9edff64a4bd081 100644
--- a/lldb/include/lldb/Utility/FileSpecList.h
+++ b/lldb/include/lldb/Utility/FileSpecList.h
@@ -25,21 +25,22 @@ class SupportFileList {
SupportFileList(const SupportFileList &) = delete;
SupportFileList(SupportFileList &&other) = default;
- typedef std::vector<std::unique_ptr<SupportFile>> collection;
+ typedef std::vector<std::shared_ptr<SupportFile>> collection;
typedef collection::const_iterator const_iterator;
const_iterator begin() const { return m_files.begin(); }
const_iterator end() const { return m_files.end(); }
void Append(const FileSpec &file) {
- return Append(std::make_unique<SupportFile>(file));
+ return Append(std::make_shared<SupportFile>(file));
}
- void Append(std::unique_ptr<SupportFile> &&file) {
+ void Append(std::shared_ptr<SupportFile> &&file) {
m_files.push_back(std::move(file));
}
// FIXME: Only used by SymbolFilePDB. Replace with a DenseSet at call site.
bool AppendIfUnique(const FileSpec &file);
size_t GetSize() const { return m_files.size(); }
const FileSpec &GetFileSpecAtIndex(size_t idx) const;
+ std::shared_ptr<SupportFile> GetSupportFileAtIndex(size_t idx) const;
size_t FindFileIndex(size_t idx, const FileSpec &file, bool full) const;
/// Find a compatible file index.
///
@@ -69,7 +70,7 @@ class SupportFileList {
template <class... Args> void EmplaceBack(Args &&...args) {
m_files.push_back(
- std::make_unique<SupportFile>(std::forward<Args>(args)...));
+ std::make_shared<SupportFile>(std::forward<Args>(args)...));
}
protected:
diff --git a/lldb/source/Utility/FileSpecList.cpp b/lldb/source/Utility/FileSpecList.cpp
index 8d2cf81efe5b13..7647e04a820451 100644
--- a/lldb/source/Utility/FileSpecList.cpp
+++ b/lldb/source/Utility/FileSpecList.cpp
@@ -41,7 +41,7 @@ bool FileSpecList::AppendIfUnique(const FileSpec &file_spec) {
bool SupportFileList::AppendIfUnique(const FileSpec &file_spec) {
collection::iterator end = m_files.end();
if (find_if(m_files.begin(), end,
- [&](const std::unique_ptr<SupportFile> &support_file) {
+ [&](const std::shared_ptr<SupportFile> &support_file) {
return support_file->GetSpecOnly() == file_spec;
}) == end) {
Append(file_spec);
@@ -176,6 +176,13 @@ const FileSpec &SupportFileList::GetFileSpecAtIndex(size_t idx) const {
return g_empty_file_spec;
}
+std::shared_ptr<SupportFile>
+SupportFileList::GetSupportFileAtIndex(size_t idx) const {
+ if (idx < m_files.size())
+ return m_files[idx];
+ return {};
+}
+
// Return the size in bytes that this object takes in memory. This returns the
// size in bytes of this object's member variables and any FileSpec objects its
// member variables contain, the result doesn't not include the string values
More information about the lldb-commits
mailing list