MC: Avoid some UB caused by left shifting a negative value. NFC

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@237408 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Justin Bogner 2015-05-14 23:54:49 +00:00
parent 19eda5312a
commit 47ccfa7de8

View File

@ -637,7 +637,7 @@ void MachObjectWriter::ComputeSymbolTable(
unsigned Index = Rel.Sym->getIndex();
assert(isInt<24>(Index));
if (IsLittleEndian)
Rel.MRE.r_word1 = (Rel.MRE.r_word1 & (-1 << 24)) | Index | (1 << 27);
Rel.MRE.r_word1 = (Rel.MRE.r_word1 & (~0U << 24)) | Index | (1 << 27);
else
Rel.MRE.r_word1 = (Rel.MRE.r_word1 & 0xff) | Index << 8 | (1 << 4);
}