[llvm] 43ab40a - [llvm] Silence warning when building with Clang ToT
Alexandre Ganea via llvm-commits
llvm-commits at lists.llvm.org
Thu Jan 25 06:34:43 PST 2024
Author: Alexandre Ganea
Date: 2024-01-25T09:34:19-05:00
New Revision: 43ab40a5baba4945efa6d6050ae34817c8044ebf
URL: https://github.com/llvm/llvm-project/commit/43ab40a5baba4945efa6d6050ae34817c8044ebf
DIFF: https://github.com/llvm/llvm-project/commit/43ab40a5baba4945efa6d6050ae34817c8044ebf.diff
LOG: [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);
| ^
```
Added:
Modified:
llvm/lib/Object/ELFObjectFile.cpp
Removed:
################################################################################
diff --git a/llvm/lib/Object/ELFObjectFile.cpp b/llvm/lib/Object/ELFObjectFile.cpp
index 28b96c341e3fff..8f7eead02a66c5 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;
};
More information about the llvm-commits
mailing list