diff --git a/llvm/lib/Object/OffloadBundle.cpp b/llvm/lib/Object/OffloadBundle.cpp index 5f087a5c84e8d..239a3e2616ba5 100644 --- a/llvm/lib/Object/OffloadBundle.cpp +++ b/llvm/lib/Object/OffloadBundle.cpp @@ -38,12 +38,11 @@ Error extractOffloadBundle(MemoryBufferRef Contents, uint64_t SectionOffset, StringRef FileName, SmallVectorImpl &Bundles) { - uint64_t Offset = 0; - int64_t NextbundleStart = 0; + size_t Offset = 0; + size_t NextbundleStart = 0; // There could be multiple offloading bundles stored at this section. - while (NextbundleStart >= 0) { - + while (NextbundleStart != StringRef::npos) { std::unique_ptr Buffer = MemoryBuffer::getMemBuffer(Contents.getBuffer().drop_front(Offset), "", /*RequiresNullTerminator=*/false); @@ -60,10 +59,9 @@ Error extractOffloadBundle(MemoryBufferRef Contents, uint64_t SectionOffset, // Find the next bundle by searching for the magic string StringRef Str = Buffer->getBuffer(); - NextbundleStart = - (int64_t)Str.find(StringRef("__CLANG_OFFLOAD_BUNDLE__"), 24); + NextbundleStart = Str.find(StringRef("__CLANG_OFFLOAD_BUNDLE__"), 24); - if (NextbundleStart >= 0) + if (NextbundleStart != StringRef::npos) Offset += NextbundleStart; }