TableGen/FixedLenDecoderEmitter.cpp: Fix a potential mask overflow in fieldFromInstruction().

Reported by Yang Yongyong, thanks!

llvm-svn: 171101
This commit is contained in:
NAKAMURA Takumi 2012-12-26 06:43:14 +00:00
parent 794a73124b
commit bf99a426cb
1 changed files with 1 additions and 1 deletions

View File

@ -1866,7 +1866,7 @@ static void emitFieldFromInstruction(formatted_raw_ostream &OS) {
<< " if (numBits == sizeof(InsnType)*8)\n" << " if (numBits == sizeof(InsnType)*8)\n"
<< " fieldMask = (InsnType)(-1LL);\n" << " fieldMask = (InsnType)(-1LL);\n"
<< " else\n" << " else\n"
<< " fieldMask = ((1 << numBits) - 1) << startBit;\n" << " fieldMask = (((InsnType)1 << numBits) - 1) << startBit;\n"
<< " return (insn & fieldMask) >> startBit;\n" << " return (insn & fieldMask) >> startBit;\n"
<< "}\n\n"; << "}\n\n";
} }