forked from OSchip/llvm-project
Move a utility function to Strings.cpp.
So that we can use the function from anywhere. llvm-svn: 284092
This commit is contained in:
parent
45c9c1432f
commit
acb67bcb98
|
@ -160,8 +160,8 @@ template <class ELFT> void InputSectionBase<ELFT>::uncompress() {
|
|||
|
||||
// Uncompress Buf.
|
||||
UncompressedData.reset(new uint8_t[Size]);
|
||||
if (zlib::uncompress(StringRef((const char *)Buf.data(), Buf.size()),
|
||||
(char *)UncompressedData.get(), Size) != zlib::StatusOK)
|
||||
if (zlib::uncompress(toStringRef(Buf), (char *)UncompressedData.get(),
|
||||
Size) != zlib::StatusOK)
|
||||
fatal(getName(this) + ": error while uncompressing section");
|
||||
Data = ArrayRef<uint8_t>(UncompressedData.get(), Size);
|
||||
}
|
||||
|
|
|
@ -1232,10 +1232,6 @@ template <class ELFT> void MergeOutputSection<ELFT>::writeTo(uint8_t *Buf) {
|
|||
Builder.write(Buf);
|
||||
}
|
||||
|
||||
static StringRef toStringRef(ArrayRef<uint8_t> A) {
|
||||
return {(const char *)A.data(), A.size()};
|
||||
}
|
||||
|
||||
template <class ELFT>
|
||||
void MergeOutputSection<ELFT>::addSection(InputSectionBase<ELFT> *C) {
|
||||
auto *Sec = cast<MergeInputSection<ELFT>>(C);
|
||||
|
@ -1694,7 +1690,7 @@ void BuildIdFastHash<ELFT>::writeBuildId(ArrayRef<uint8_t> Buf) {
|
|||
const endianness E = ELFT::TargetEndianness;
|
||||
|
||||
// 64-bit xxhash
|
||||
uint64_t Hash = xxHash64(StringRef((const char *)Buf.data(), Buf.size()));
|
||||
uint64_t Hash = xxHash64(toStringRef(Buf));
|
||||
write64<E>(this->HashBuf, Hash);
|
||||
}
|
||||
|
||||
|
|
|
@ -11,6 +11,8 @@
|
|||
#define LLD_ELF_STRINGS_H
|
||||
|
||||
#include "lld/Core/LLVM.h"
|
||||
#include "llvm/ADT/ArrayRef.h"
|
||||
#include "llvm/ADT/StringRef.h"
|
||||
#include "llvm/Support/Regex.h"
|
||||
#include <vector>
|
||||
|
||||
|
@ -27,6 +29,10 @@ StringRef unquote(StringRef S);
|
|||
// name or the system does not provide __cxa_demangle function,
|
||||
// it returns an unmodified string.
|
||||
std::string demangle(StringRef Name);
|
||||
|
||||
inline StringRef toStringRef(ArrayRef<uint8_t> Arr) {
|
||||
return {(const char *)Arr.data(), Arr.size()};
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue