Skip to content

Commit 43ab40a

Browse files
committed
[llvm] Silence warning when building with Clang ToT
This fixes: ``` [1343/7452] Building CXX object lib\Object\CMakeFiles\LLVMObject.dir\ELFObjectFile.cpp.obj C:\git\llvm-project\llvm\lib\Object\ELFObjectFile.cpp(808,27): warning: comparison of integers of different signs: 'unsigned int' and '_Iter_diff_t<const Elf_Shdr_Impl<ELFType<llvm::endianness::little, false>> *>' (aka 'int') [-Wsign-compare] 808 | if (*TextSectionIndex != std::distance(Sections.begin(), *TextSecOrErr)) | ~~~~~~~~~~~~~~~~~ ^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ C:\git\llvm-project\llvm\lib\Object\ELFObjectFile.cpp(913,12): note: in instantiation of function template specialization 'readBBAddrMapImpl<llvm::object::ELFType<llvm::endianness::little, false>>' requested here 913 | return readBBAddrMapImpl(Obj->getELFFile(), TextSectionIndex, PGOAnalyses); | ^ ```
1 parent af263ce commit 43ab40a

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

llvm/lib/Object/ELFObjectFile.cpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -805,7 +805,10 @@ Expected<std::vector<BBAddrMap>> static readBBAddrMapImpl(
805805
return createError("unable to get the linked-to section for " +
806806
describe(EF, Sec) + ": " +
807807
toString(TextSecOrErr.takeError()));
808-
if (*TextSectionIndex != std::distance(Sections.begin(), *TextSecOrErr))
808+
assert(*TextSecOrErr >= Sections.begin() &&
809+
"Text section pointer outside of bounds");
810+
if (*TextSectionIndex !=
811+
(unsigned)std::distance(Sections.begin(), *TextSecOrErr))
809812
return false;
810813
return true;
811814
};

0 commit comments

Comments
 (0)