17#ifndef LLVM_SUPPORT_HASHINGOUTPUTBACKEND_H
18#define LLVM_SUPPORT_HASHINGOUTPUTBACKEND_H
31template <
typename HasherT>
40 void write_impl(
const char *
Ptr,
size_t Size)
override {
48 uint64_t current_pos()
const override {
return OS.str().size(); }
54 Builder.update(OS.str());
55 return Builder.final();
59template <
typename HasherT>
class HashingOutputFile;
66 std::lock_guard<std::mutex> Lock(OutputHashLock);
67 OutputHashes[Path] = Hash.
str();
77 return std::make_unique<HashingOutputFile<HasherT>>(Path, *
this);
91 auto F = OutputHashes.find(Path);
92 if (
F == OutputHashes.end())
98 std::mutex OutputHashLock;
103template <
typename HasherT>
107 auto Result = OS.final();
108 Backend.addOutputFile(OutputPath,
toStringRef(Result));
116 : OutputPath(OutputPath.str()), Backend(Backend) {}
119 const std::string OutputPath;
This file defines the StringMap class.
This file contains the declarations of the VirtualOutputBackend class, which can be used to virtualiz...
This file contains the declarations of the OutputConfig class.
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.
Interface to help hash various types through a hasher type.
A smart pointer to a reference-counted object that inherits from RefCountedBase or ThreadSafeRefCount...
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small.
StringMap - This is an unconventional map that is specialized for handling keys that are "strings",...
StringRef - Represent a constant reference to a string, i.e.
std::string str() const
str - Get the contents as an std::string.
void SetUnbuffered()
Set the stream to be unbuffered.
An abstract base class for streams implementations that also support a pwrite operation.
A raw_ostream that writes to an SmallVector or SmallString.
An output backend that only generates the hash for outputs.
std::optional< std::string > getHashValueForFile(StringRef Path)
Get hash value for the output files in hex representation.
IntrusiveRefCntPtr< OutputBackend > cloneImpl() const override
Must be thread-safe.
Expected< std::unique_ptr< OutputFileImpl > > createFileImpl(StringRef Path, std::optional< OutputConfig > Config) override
Create a file for Path.
auto outputFiles() const
Iterator for all the output file names.
HashingOutputFile(StringRef OutputPath, HashingOutputBackend< HasherT > &Backend)
raw_pwrite_stream & getOS() override
raw_pwrite_stream that writes to a hasher.
void toHex(ArrayRef< uint8_t > Input, bool LowerCase, SmallVectorImpl< char > &Output)
Convert buffer Input to its hexadecimal representation. The returned string is double the size of Inp...
StringRef toStringRef(bool B)
Construct a string ref from a boolean.