diff --git a/llvm/include/llvm/Object/OffloadBinary.h b/llvm/include/llvm/Object/OffloadBinary.h --- a/llvm/include/llvm/Object/OffloadBinary.h +++ b/llvm/include/llvm/Object/OffloadBinary.h @@ -58,6 +58,13 @@ /// that may exist in the same section. All offsets are given as absolute byte /// offsets from the beginning of the file. class OffloadBinary : public Binary { + + using string_iterator = StringMap::const_iterator; + using string_iterator_range = iterator_range; + + string_iterator data_begin() const { return StringData.begin(); } + string_iterator data_end() const { return StringData.end(); } + public: /// The offloading metadata that will be serialized to a memory buffer. struct OffloadingImage { @@ -88,6 +95,11 @@ return StringRef(&Buffer[TheEntry->ImageOffset], TheEntry->ImageSize); } + // Iterator over all the key and value pairs in the binary. + string_iterator_range strings() const { + return string_iterator_range(data_begin(), data_end()); + } + StringRef getString(StringRef Key) const { return StringData.lookup(Key); } static bool classof(const Binary *V) { return V->isOffloadFile(); }