aboutsummaryrefslogtreecommitdiff
path: root/lldb/source/Host/common/FileSystem.cpp
diff options
context:
space:
mode:
authorJonas Devlieghere <jonas@devlieghere.com>2025-07-25 15:55:21 -0700
committerGitHub <noreply@github.com>2025-07-25 15:55:21 -0700
commitcf6a4bbc42c7e54bf6e251206134b207e757b604 (patch)
tree2f03b5614fbb26d189c6a68274b4f48d0fcac931 /lldb/source/Host/common/FileSystem.cpp
parent67b519577ee6b3743c6c03c6230991cede5648a5 (diff)
downloadllvm-cf6a4bbc42c7e54bf6e251206134b207e757b604.zip
llvm-cf6a4bbc42c7e54bf6e251206134b207e757b604.tar.gz
llvm-cf6a4bbc42c7e54bf6e251206134b207e757b604.tar.bz2
[lldb] Use std::make_shared where possible (NFC) (#150714)
This is a continuation of 68fd102, which did the same thing but only for StopInfo. Using make_shared is both safer and more efficient: - With make_shared, the object and the control block are allocated together, which is more efficient. - With make_shared, the enable_shared_from_this base class is properly linked to the control block before the constructor finishes, so shared_from_this() will be safe to use (though still not recommended during construction).
Diffstat (limited to 'lldb/source/Host/common/FileSystem.cpp')
-rw-r--r--lldb/source/Host/common/FileSystem.cpp6
1 files changed, 3 insertions, 3 deletions
diff --git a/lldb/source/Host/common/FileSystem.cpp b/lldb/source/Host/common/FileSystem.cpp
index 5153a0a9..00919fe 100644
--- a/lldb/source/Host/common/FileSystem.cpp
+++ b/lldb/source/Host/common/FileSystem.cpp
@@ -35,6 +35,7 @@
#include <algorithm>
#include <fstream>
+#include <memory>
#include <optional>
#include <vector>
@@ -288,8 +289,7 @@ FileSystem::CreateWritableDataBuffer(const llvm::Twine &path, uint64_t size,
is_volatile);
if (!buffer)
return {};
- return std::shared_ptr<WritableDataBufferLLVM>(
- new WritableDataBufferLLVM(std::move(buffer)));
+ return std::make_shared<WritableDataBufferLLVM>(std::move(buffer));
}
std::shared_ptr<DataBuffer>
@@ -300,7 +300,7 @@ FileSystem::CreateDataBuffer(const llvm::Twine &path, uint64_t size,
GetMemoryBuffer<llvm::MemoryBuffer>(path, size, offset, is_volatile);
if (!buffer)
return {};
- return std::shared_ptr<DataBufferLLVM>(new DataBufferLLVM(std::move(buffer)));
+ return std::make_shared<DataBufferLLVM>(std::move(buffer));
}
std::shared_ptr<WritableDataBuffer>