21#if !defined(_MSC_VER) && !defined(__MINGW32__)
30 const Twine &TempFilePrefixRef,
31 const Twine &CacheDirectoryPathRef,
37 TempFilePrefixRef.
toVector(TempFilePrefix);
38 CacheDirectoryPathRef.
toVector(CacheDirectoryPath);
58 AddBuffer(Task,
ModuleName, std::move(*MBOrErr));
72 if (EC != errc::no_such_file_or_directory && EC != errc::permission_denied)
74 EntryPath +
": " + EC.message() +
"\n");
84 CacheStream(std::unique_ptr<raw_pwrite_stream>
OS,
AddBufferFn AddBuffer,
88 AddBuffer(std::move(AddBuffer)), TempFile(std::move(TempFile)),
106 MBOrErr.
getError().message() +
"\n");
119 std::error_code EC =
E.convertToErrorCode();
120 if (EC != errc::permission_denied)
125 MBOrErr = std::move(MBCopy);
135 TempFile.
TmpName +
" to " + ObjectPathName +
": " +
138 AddBuffer(Task,
ModuleName, std::move(*MBOrErr));
143 ->
Expected<std::unique_ptr<CachedFileStream>> {
147 CacheDirectoryPath,
true))
149 CacheDirectoryPath +
": " +
155 TempFilePrefix +
"-%%%%%%.tmp.o");
161 ": Can't get a temporary file");
164 return std::make_unique<CacheStream>(
165 std::make_unique<raw_fd_ostream>(Temp->FD,
false),
166 AddBuffer, std::move(*Temp), std::string(EntryPath),
ModuleName.str(),
static GCRegistry::Add< CoreCLRGC > E("coreclr", "CoreCLR-compatible GC")
This class wraps an output stream for a file.
This class wraps a std::error_code in a Error.
Represents either an error or a value T.
std::error_code getError() const
Lightweight error class with error context and mandatory checking.
static ErrorSuccess success()
Create a success value.
Tagged union holding either a T or a Error.
Error takeError()
Take ownership of the stored error.
static ErrorOr< std::unique_ptr< MemoryBuffer > > getOpenFile(sys::fs::file_t FD, const Twine &Filename, uint64_t FileSize, bool RequiresNullTerminator=true, bool IsVolatile=false, std::optional< Align > Alignment=std::nullopt)
Given an already-open file descriptor, read the file and return a MemoryBuffer.
static std::unique_ptr< MemoryBuffer > getMemBufferCopy(StringRef InputData, const Twine &BufferName="")
Open the specified memory range as a MemoryBuffer, copying the contents and taking ownership of it.
SmallString - A SmallString is just a SmallVector with methods and accessors that make it work better...
StringRef - Represent a constant reference to a string, i.e.
Twine - A lightweight data structure for efficiently representing the concatenation of temporary valu...
void toVector(SmallVectorImpl< char > &Out) const
Append the concatenated string into the given SmallString or SmallVector.
Represents a temporary file.
Error keep(const Twine &Name)
static Expected< TempFile > create(const Twine &Model, unsigned Mode=all_read|all_write, OpenFlags ExtraFlags=OF_None)
This creates a temporary file with createUniqueFile and schedules it for deletion with sys::RemoveFil...
std::optional< const char * > toString(const std::optional< DWARFFormValue > &V)
Take an optional DWARFFormValue and try to extract a string value from it.
std::error_code closeFile(file_t &F)
Close the file object.
@ OF_UpdateAtime
Force files Atime to be updated on access.
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.
file_t convertFDToNativeFile(int FD)
Converts from a Posix file descriptor number to a native file handle.
Expected< file_t > openNativeFileForRead(const Twine &Name, OpenFlags Flags=OF_None, SmallVectorImpl< char > *RealPath=nullptr)
Opens the file with the given name in a read-only mode, returning its open file descriptor.
void append(SmallVectorImpl< char > &path, const Twine &a, const Twine &b="", const Twine &c="", const Twine &d="")
Append to path.
This is an optimization pass for GlobalISel generic memory operations.
std::function< void(unsigned Task, const Twine &ModuleName, std::unique_ptr< MemoryBuffer > MB)> AddBufferFn
This type defines the callback to add a pre-existing file (e.g.
Error handleErrors(Error E, HandlerTs &&... Hs)
Pass the ErrorInfo(s) contained in E to their respective handlers.
std::function< Expected< std::unique_ptr< CachedFileStream > >(unsigned Task, const Twine &ModuleName)> AddStreamFn
This type defines the callback to add a file that is generated on the fly.
Error createStringError(std::error_code EC, char const *Fmt, const Ts &... Vals)
Create formatted StringError object.
void report_fatal_error(Error Err, bool gen_crash_diag=true)
Report a serious error, calling any installed error handler.
Error errorCodeToError(std::error_code EC)
Helper for converting an std::error_code to a Error.
std::error_code errorToErrorCode(Error Err)
Helper for converting an ECError to a std::error_code.
void consumeError(Error Err)
Consume a Error without doing anything.
Expected< FileCache > localCache(const Twine &CacheNameRef, const Twine &TempFilePrefixRef, const Twine &CacheDirectoryPathRef, AddBufferFn AddBuffer=[](size_t Task, const Twine &ModuleName, std::unique_ptr< MemoryBuffer > MB) {})
Create a local file system cache which uses the given cache name, temporary file prefix,...