[llvm] [DTLTO][NFC] Minor improvements to DTLTO archive support class (PR #176770)
Rose Hudson via llvm-commits
llvm-commits at lists.llvm.org
Tue Jan 20 02:28:32 PST 2026
================
@@ -28,36 +28,39 @@
#include "llvm/Support/TimeProfiler.h"
#include "llvm/Support/raw_ostream.h"
-#include <iostream>
#include <string>
using namespace llvm;
namespace {
-// Writes the content of a memory buffer into a file.
-llvm::Error saveBuffer(StringRef FileBuffer, StringRef FilePath) {
+// Saves the content of Buffer to Path overwriting any existing file.
+Error save(StringRef Buffer, StringRef Path) {
std::error_code EC;
- raw_fd_ostream OS(FilePath.str(), EC, sys::fs::OpenFlags::OF_None);
- if (EC) {
+ raw_fd_ostream OS(Path.str(), EC, sys::fs::OpenFlags::OF_None);
+ if (EC)
return createStringError(inconvertibleErrorCode(),
- "Failed to create file %s: %s", FilePath.data(),
+ "Failed to create file %s: %s", Path.data(),
EC.message().c_str());
- }
- OS.write(FileBuffer.data(), FileBuffer.size());
- if (OS.has_error()) {
+ OS.write(Buffer.data(), Buffer.size());
+ if (OS.has_error())
return createStringError(inconvertibleErrorCode(),
- "Failed writing to file %s", FilePath.data());
- }
+ "Failed writing to file %s", Path.data());
return Error::success();
}
-// Compute the file path for a thin archive member.
+// Saves the content of Input to Path overwriting any existing file.
+Error save(lto::InputFile *Input, StringRef Path) {
+ MemoryBufferRef MB = Input->getFileBuffer();
+ return save(MB.getBuffer(), Path);
+}
+
+// Compute the path for a thin archive member.
//
-// For thin archives, an archive member name is typically a file path relative
-// to the archive file's directory. This function resolves that path.
-SmallString<64> computeThinArchiveMemberPath(const StringRef ArchivePath,
- const StringRef MemberName) {
----------------
rosefromthedead wrote:
Non-blocking: is it not considered best practise to keep these?
https://github.com/llvm/llvm-project/pull/176770
More information about the llvm-commits
mailing list