[lld] caff023 - [lld] Silence compiler warnings by removing always true/false comparisons
Mikael Holmen via llvm-commits
llvm-commits at lists.llvm.org
Tue Feb 16 23:19:33 PST 2021
Author: Mikael Holmen
Date: 2021-02-17T08:16:02+01:00
New Revision: caff023b77995166c8f335ace3064c04f677cb9c
URL: https://github.com/llvm/llvm-project/commit/caff023b77995166c8f335ace3064c04f677cb9c
DIFF: https://github.com/llvm/llvm-project/commit/caff023b77995166c8f335ace3064c04f677cb9c.diff
LOG: [lld] Silence compiler warnings by removing always true/false comparisons
type is an uint8_t so
type >= 0
is always true and
type < 0
is always false.
Added:
Modified:
lld/MachO/Arch/ARM64.cpp
lld/MachO/Arch/X86_64.cpp
Removed:
################################################################################
diff --git a/lld/MachO/Arch/ARM64.cpp b/lld/MachO/Arch/ARM64.cpp
index 25918e16c894..cf51e7543fab 100644
--- a/lld/MachO/Arch/ARM64.cpp
+++ b/lld/MachO/Arch/ARM64.cpp
@@ -69,9 +69,8 @@ const TargetInfo::RelocAttrs &ARM64::getRelocAttrs(uint8_t type) const {
{"ADDEND", B(ADDEND)},
#undef B
}};
- assert(type >= 0 && type < relocAttrsArray.size() &&
- "invalid relocation type");
- if (type < 0 || type >= relocAttrsArray.size())
+ assert(type < relocAttrsArray.size() && "invalid relocation type");
+ if (type >= relocAttrsArray.size())
return TargetInfo::invalidRelocAttrs;
return relocAttrsArray[type];
}
diff --git a/lld/MachO/Arch/X86_64.cpp b/lld/MachO/Arch/X86_64.cpp
index c156b12c7644..ad7b26af78b0 100644
--- a/lld/MachO/Arch/X86_64.cpp
+++ b/lld/MachO/Arch/X86_64.cpp
@@ -58,9 +58,8 @@ const TargetInfo::RelocAttrs &X86_64::getRelocAttrs(uint8_t type) const {
{"TLV", B(PCREL) | B(EXTERN) | B(TLV) | B(LOAD) | B(BYTE4)},
#undef B
}};
- assert(type >= 0 && type < relocAttrsArray.size() &&
- "invalid relocation type");
- if (type < 0 || type >= relocAttrsArray.size())
+ assert(type < relocAttrsArray.size() && "invalid relocation type");
+ if (type >= relocAttrsArray.size())
return TargetInfo::invalidRelocAttrs;
return relocAttrsArray[type];
}
More information about the llvm-commits
mailing list