23 using namespace llvm::lto;
39 AddBuffer(Task, std::move(*MBOrErr));
45 ": " + MBOrErr.
getError().message() +
"\n");
51 std::string TempFilename;
52 std::string EntryPath;
55 CacheStream(std::unique_ptr<raw_pwrite_stream> OS,
AddBufferFn AddBuffer,
56 std::string TempFilename, std::string EntryPath,
59 TempFilename(std::move(TempFilename)),
60 EntryPath(std::move(EntryPath)), Task(Task) {}
71 TempFilename +
": " + EC.message() +
"\n");
77 ": " + MBOrErr.getError().message() +
"\n");
78 AddBuffer(Task, std::move(*MBOrErr));
82 return [=](
size_t Task) -> std::unique_ptr<NativeObjectStream> {
91 errs() <<
"Error: " << EC.message() <<
"\n";
96 return llvm::make_unique<CacheStream>(
97 llvm::make_unique<raw_fd_ostream>(TempFD,
true),
98 AddBuffer, TempFilename.
str(), EntryPath.
str(), Task);
std::error_code create_directories(const Twine &path, bool IgnoreExisting=true, perms Perms=owner_all|group_all)
Create all the non-existent directories in path.
std::error_code getError() const
Represents either an error or a value T.
raw_ostream & errs()
This returns a reference to a raw_ostream for standard error.
LLVM_ATTRIBUTE_NORETURN void report_fatal_error(Error Err, bool gen_crash_diag=true)
Report a serious error, calling any installed error handler.
std::error_code createUniqueFile(const Twine &Model, int &ResultFD, SmallVectorImpl< char > &ResultPath, unsigned Mode=all_read|all_write)
Create a uniquely named file.
std::function< void(unsigned Task, std::unique_ptr< MemoryBuffer > MB)> AddBufferFn
This type defines the callback to add a pre-existing native object file (e.g.
std::function< std::unique_ptr< NativeObjectStream >unsigned Task)> AddStreamFn
This type defines the callback to add a native object that is generated on the fly.
void append(SmallVectorImpl< char > &path, const Twine &a, const Twine &b="", const Twine &c="", const Twine &d="")
Append to path.
Twine - A lightweight data structure for efficiently representing the concatenation of temporary valu...
Tagged union holding either a T or a Error.
Error errorCodeToError(std::error_code EC)
Helper for converting an std::error_code to a Error.
This class wraps an output stream for a native object.
Expected< NativeObjectCache > localCache(StringRef CacheDirectoryPath, AddBufferFn AddBuffer)
Create a local file system cache which uses the given cache directory and file callback.
std::error_code rename(const Twine &from, const Twine &to)
Rename from to to.
StringRef str() const
Explicit conversion to StringRef.
static ErrorOr< std::unique_ptr< MemoryBuffer > > getFile(const Twine &Filename, int64_t FileSize=-1, bool RequiresNullTerminator=true, bool IsVolatile=false)
Open the specified file as a MemoryBuffer, returning a new MemoryBuffer if successful, otherwise returning null.
StringRef - Represent a constant reference to a string, i.e.