[llvm] d9d2210 - [llvm-readobj] - An attempt to fix BB.
Georgii Rymar via llvm-commits
llvm-commits at lists.llvm.org
Tue Aug 4 01:57:37 PDT 2020
Author: Georgii Rymar
Date: 2020-08-04T11:56:58+03:00
New Revision: d9d22105792e08267583961a66ab6a53992fff89
URL: https://github.com/llvm/llvm-project/commit/d9d22105792e08267583961a66ab6a53992fff89
DIFF: https://github.com/llvm/llvm-project/commit/d9d22105792e08267583961a66ab6a53992fff89.diff
LOG: [llvm-readobj] - An attempt to fix BB.
http://lab.llvm.org:8011/builders/clang-cmake-x86_64-avx2-linux/builds/15710/steps/build%20stage%201/logs/stdio
fails with:
/home/ssglocal/clang-cmake-x86_64-avx2-linux/clang-cmake-x86_64-avx2-linux/llvm/llvm/tools/llvm-readobj/ELFDumper.cpp: In function ‘llvm::Expected<const llvm::object::Elf_Mips_Options<ELFT>*> readMipsOptions(const uint8_t*, llvm::ArrayRef<unsigned char>&, bool&)’:
/home/ssglocal/clang-cmake-x86_64-avx2-linux/clang-cmake-x86_64-avx2-linux/llvm/llvm/tools/llvm-readobj/ELFDumper.cpp:3373:19: error: the value of ‘ExpectedSize’ is not usable in a constant expression
if (O->size < ExpectedSize)
^
/home/ssglocal/clang-cmake-x86_64-avx2-linux/clang-cmake-x86_64-avx2-linux/llvm/llvm/tools/llvm-readobj/ELFDumper.cpp:3369:10: note: ‘size_t ExpectedSize’ is not const
size_t ExpectedSize =
^
/home/ssglocal/clang-cmake-x86_64-avx2-linux/clang-cmake-x86_64-avx2-linux/llvm/llvm/tools/llvm-readobj/ELFDumper.cpp:3373:12: error: parse error in template argument list
if (O->size < ExpectedSize)
^
/home/ssglocal/clang-cmake-x86_64-avx2-linux/clang-cmake-x86_64-avx2-linux/llvm/llvm/tools/llvm-readobj/ELFDumper.cpp: In instantiation of ‘llvm::Expected<const llvm::object::Elf_Mips_Options<ELFT>*> readMipsOptions(const uint8_t*, llvm::ArrayRef<unsigned char>&, bool&) [with ELFT = llvm::object::ELFType<(llvm::support::endianness)0u, true>; uint8_t = unsigned char]’:
/home/ssglocal/clang-cmake-x86_64-avx2-linux/clang-cmake-x86_64-avx2-linux/llvm/llvm/tools/llvm-readobj/ELFDumper.cpp:3400:30: required from ‘void {anonymous}::ELFDumper<ELFT>::printMipsOptions() [with ELFT = llvm::object::ELFType<(llvm::support::endianness)0u, true>]’
/home/ssglocal/clang-cmake-x86_64-avx2-linux/clang-cmake-x86_64-avx2-linux/llvm/llvm/tools/llvm-readobj/ELFDumper.cpp:2878:21: required from ‘void {anonymous}::ELFDumper<ELFT>::printArchSpecificInfo() [with ELFT = llvm::object::ELFType<(llvm::support::endianness)0u, true>]’
/home/ssglocal/clang-cmake-x86_64-avx2-linux/clang-cmake-x86_64-avx2-linux/llvm/llvm/tools/llvm-readobj/ELFDumper.cpp:6999:1: required from here
/home/ssglocal/clang-cmake-x86_64-avx2-linux/clang-cmake-x86_64-avx2-linux/llvm/llvm/tools/llvm-readobj/ELFDumper.cpp:3373:5: error: ‘size’ is not a member template function
Fix: add 2 `const` words to variables.
Added:
Modified:
llvm/tools/llvm-readobj/ELFDumper.cpp
Removed:
################################################################################
diff --git a/llvm/tools/llvm-readobj/ELFDumper.cpp b/llvm/tools/llvm-readobj/ELFDumper.cpp
index 2b7a103df975..3aee021748cb 100644
--- a/llvm/tools/llvm-readobj/ELFDumper.cpp
+++ b/llvm/tools/llvm-readobj/ELFDumper.cpp
@@ -3354,7 +3354,7 @@ readMipsOptions(const uint8_t *SecBegin, ArrayRef<uint8_t> &SecData,
return createError("the .MIPS.options section has an invalid size (0x" +
Twine::utohexstr(SecData.size()) + ")");
- auto *O = reinterpret_cast<const Elf_Mips_Options<ELFT> *>(SecData.data());
+ const auto *O = reinterpret_cast<const Elf_Mips_Options<ELFT> *>(SecData.data());
if (O->size > SecData.size()) {
const uint64_t Offset = SecData.data() - SecBegin;
const uint64_t SecSize = Offset + SecData.size();
@@ -3366,7 +3366,7 @@ readMipsOptions(const uint8_t *SecBegin, ArrayRef<uint8_t> &SecData,
}
IsSupported = O->kind == ODK_REGINFO;
- size_t ExpectedSize =
+ const size_t ExpectedSize =
sizeof(Elf_Mips_Options<ELFT>) + sizeof(Elf_Mips_RegInfo<ELFT>);
if (IsSupported)
More information about the llvm-commits
mailing list