Switch from cast<> to dyn_cast<>.

This avoids a potential failed assertion that is happening on someone's out-of-tree build.

llvm-svn: 349940
This commit is contained in:
Aaron Ballman 2018-12-21 19:16:38 +00:00
parent 255b05820c
commit 88b36702dc
1 changed files with 5 additions and 2 deletions

View File

@ -63,8 +63,11 @@ static inline uint64_t getValueFromBitsInit(const BitsInit *B) {
uint64_t Value = 0;
for (unsigned i = 0, e = B->getNumBits(); i != e; ++i) {
const auto *Bit = cast<BitInit>(B->getBit(i));
Value |= uint64_t(Bit->getValue()) << i;
const auto *Bit = dyn_cast<BitInit>(B->getBit(i));
if (Bit)
Value |= uint64_t(Bit->getValue()) << i;
else
PrintFatalError("Invalid bits");
}
return Value;
}