From 43ab40a5baba4945efa6d6050ae34817c8044ebf Mon Sep 17 00:00:00 2001 From: Alexandre Ganea Date: Wed, 24 Jan 2024 21:12:02 -0500 Subject: [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> *>' (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>' requested here 913 | return readBBAddrMapImpl(Obj->getELFFile(), TextSectionIndex, PGOAnalyses); | ^ ``` --- llvm/lib/Object/ELFObjectFile.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'llvm/lib/Object/ELFObjectFile.cpp') diff --git a/llvm/lib/Object/ELFObjectFile.cpp b/llvm/lib/Object/ELFObjectFile.cpp index 28b96c3..8f7eead 100644 --- a/llvm/lib/Object/ELFObjectFile.cpp +++ b/llvm/lib/Object/ELFObjectFile.cpp @@ -805,7 +805,10 @@ Expected> static readBBAddrMapImpl( return createError("unable to get the linked-to section for " + describe(EF, Sec) + ": " + toString(TextSecOrErr.takeError())); - if (*TextSectionIndex != std::distance(Sections.begin(), *TextSecOrErr)) + assert(*TextSecOrErr >= Sections.begin() && + "Text section pointer outside of bounds"); + if (*TextSectionIndex != + (unsigned)std::distance(Sections.begin(), *TextSecOrErr)) return false; return true; }; -- cgit v1.1