Skip to content

Commit caff023

Browse files
committed
[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.
1 parent 33481c9 commit caff023

File tree

2 files changed

+4
-6
lines changed

2 files changed

+4
-6
lines changed

lld/MachO/Arch/ARM64.cpp

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -69,9 +69,8 @@ const TargetInfo::RelocAttrs &ARM64::getRelocAttrs(uint8_t type) const {
6969
{"ADDEND", B(ADDEND)},
7070
#undef B
7171
}};
72-
assert(type >= 0 && type < relocAttrsArray.size() &&
73-
"invalid relocation type");
74-
if (type < 0 || type >= relocAttrsArray.size())
72+
assert(type < relocAttrsArray.size() && "invalid relocation type");
73+
if (type >= relocAttrsArray.size())
7574
return TargetInfo::invalidRelocAttrs;
7675
return relocAttrsArray[type];
7776
}

lld/MachO/Arch/X86_64.cpp

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -58,9 +58,8 @@ const TargetInfo::RelocAttrs &X86_64::getRelocAttrs(uint8_t type) const {
5858
{"TLV", B(PCREL) | B(EXTERN) | B(TLV) | B(LOAD) | B(BYTE4)},
5959
#undef B
6060
}};
61-
assert(type >= 0 && type < relocAttrsArray.size() &&
62-
"invalid relocation type");
63-
if (type < 0 || type >= relocAttrsArray.size())
61+
assert(type < relocAttrsArray.size() && "invalid relocation type");
62+
if (type >= relocAttrsArray.size())
6463
return TargetInfo::invalidRelocAttrs;
6564
return relocAttrsArray[type];
6665
}

0 commit comments

Comments
 (0)