diff options
author | Jonas Devlieghere <jonas@devlieghere.com> | 2024-01-12 14:30:04 -0800 |
---|---|---|
committer | Jonas Devlieghere <jonas@devlieghere.com> | 2024-01-16 15:40:15 -0800 |
commit | 854aa9112df253bcad4db6f21ea9b2fbca4ed83e (patch) | |
tree | 8a0200fc590f3666f1b2cd4d1ce0338f7f81f1ba /lldb | |
parent | 9c607e77eae75f0f9152eb3e6ba2a69616aba4fa (diff) | |
download | llvm-854aa9112df253bcad4db6f21ea9b2fbca4ed83e.zip llvm-854aa9112df253bcad4db6f21ea9b2fbca4ed83e.tar.gz llvm-854aa9112df253bcad4db6f21ea9b2fbca4ed83e.tar.bz2 |
[lldb] Store SupportFile as shared_ptr (NFC)
Diffstat (limited to 'lldb')
-rw-r--r-- | lldb/include/lldb/Utility/FileSpecList.h | 9 | ||||
-rw-r--r-- | lldb/source/Utility/FileSpecList.cpp | 9 |
2 files changed, 13 insertions, 5 deletions
diff --git a/lldb/include/lldb/Utility/FileSpecList.h b/lldb/include/lldb/Utility/FileSpecList.h index 6ddb9d1..9edff64 100644 --- a/lldb/include/lldb/Utility/FileSpecList.h +++ b/lldb/include/lldb/Utility/FileSpecList.h @@ -25,21 +25,22 @@ public: 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 @@ public: 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 8d2cf81..7647e04 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 |