Skip to content

Commit 854aa91

Browse files
committed
[lldb] Store SupportFile as shared_ptr (NFC)
1 parent 9c607e7 commit 854aa91

File tree

2 files changed

+13
-5
lines changed

2 files changed

+13
-5
lines changed

lldb/include/lldb/Utility/FileSpecList.h

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,21 +25,22 @@ class SupportFileList {
2525
SupportFileList(const SupportFileList &) = delete;
2626
SupportFileList(SupportFileList &&other) = default;
2727

28-
typedef std::vector<std::unique_ptr<SupportFile>> collection;
28+
typedef std::vector<std::shared_ptr<SupportFile>> collection;
2929
typedef collection::const_iterator const_iterator;
3030
const_iterator begin() const { return m_files.begin(); }
3131
const_iterator end() const { return m_files.end(); }
3232

3333
void Append(const FileSpec &file) {
34-
return Append(std::make_unique<SupportFile>(file));
34+
return Append(std::make_shared<SupportFile>(file));
3535
}
36-
void Append(std::unique_ptr<SupportFile> &&file) {
36+
void Append(std::shared_ptr<SupportFile> &&file) {
3737
m_files.push_back(std::move(file));
3838
}
3939
// FIXME: Only used by SymbolFilePDB. Replace with a DenseSet at call site.
4040
bool AppendIfUnique(const FileSpec &file);
4141
size_t GetSize() const { return m_files.size(); }
4242
const FileSpec &GetFileSpecAtIndex(size_t idx) const;
43+
std::shared_ptr<SupportFile> GetSupportFileAtIndex(size_t idx) const;
4344
size_t FindFileIndex(size_t idx, const FileSpec &file, bool full) const;
4445
/// Find a compatible file index.
4546
///
@@ -69,7 +70,7 @@ class SupportFileList {
6970

7071
template <class... Args> void EmplaceBack(Args &&...args) {
7172
m_files.push_back(
72-
std::make_unique<SupportFile>(std::forward<Args>(args)...));
73+
std::make_shared<SupportFile>(std::forward<Args>(args)...));
7374
}
7475

7576
protected:

lldb/source/Utility/FileSpecList.cpp

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ bool FileSpecList::AppendIfUnique(const FileSpec &file_spec) {
4141
bool SupportFileList::AppendIfUnique(const FileSpec &file_spec) {
4242
collection::iterator end = m_files.end();
4343
if (find_if(m_files.begin(), end,
44-
[&](const std::unique_ptr<SupportFile> &support_file) {
44+
[&](const std::shared_ptr<SupportFile> &support_file) {
4545
return support_file->GetSpecOnly() == file_spec;
4646
}) == end) {
4747
Append(file_spec);
@@ -176,6 +176,13 @@ const FileSpec &SupportFileList::GetFileSpecAtIndex(size_t idx) const {
176176
return g_empty_file_spec;
177177
}
178178

179+
std::shared_ptr<SupportFile>
180+
SupportFileList::GetSupportFileAtIndex(size_t idx) const {
181+
if (idx < m_files.size())
182+
return m_files[idx];
183+
return {};
184+
}
185+
179186
// Return the size in bytes that this object takes in memory. This returns the
180187
// size in bytes of this object's member variables and any FileSpec objects its
181188
// member variables contain, the result doesn't not include the string values

0 commit comments

Comments
 (0)