diff options
author | Alexandre Ganea <alex_toresh@yahoo.fr> | 2024-01-24 21:12:02 -0500 |
---|---|---|
committer | Alexandre Ganea <alex_toresh@yahoo.fr> | 2024-01-25 09:34:19 -0500 |
commit | 43ab40a5baba4945efa6d6050ae34817c8044ebf (patch) | |
tree | b515d129f3b190f46b41604225355930564eca92 /llvm/lib/Object/ELFObjectFile.cpp | |
parent | af263ceb90b9fe39ae1d3458c9f35b6b199d3951 (diff) | |
download | llvm-43ab40a5baba4945efa6d6050ae34817c8044ebf.zip llvm-43ab40a5baba4945efa6d6050ae34817c8044ebf.tar.gz llvm-43ab40a5baba4945efa6d6050ae34817c8044ebf.tar.bz2 |
[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);
| ^
```
Diffstat (limited to 'llvm/lib/Object/ELFObjectFile.cpp')
-rw-r--r-- | llvm/lib/Object/ELFObjectFile.cpp | 5 |
1 files changed, 4 insertions, 1 deletions
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<std::vector<BBAddrMap>> 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; }; |