LLVM type.h question

Hi,

I see this in the Type class:

unsigned getSubclassData() const { return SubclassData; }

void setSubclassData(unsigned val) {
  SubclassData = val;
  // Ensure we don't have any accidental truncation.
  assert(getSubclassData() == val && "Subclass data too large for field");
}

How will the assert ever get triggered?
The type is "unsigned" so how can getSubclassData() ever not equal val ?
Where does the truncation take place?

Kind Regards

James

Isn’t the SubclassData member a 24 bit bitfield? I think the truncation would happen on the assignment to it.

Right - this is intended to catch a problem where someone tries to store a value in SubclassData that is too large to fit in the bitfield.

-Chris

Thank you. I missed that SubclassData was a bitfield.

Kind Regards

James