- const uint16_t MutuallyIncompatible =
- ParamAttr::ByVal | ParamAttr::InReg |
- ParamAttr::Nest | ParamAttr::StructRet;
-
- const uint16_t MutuallyIncompatible2 =
- ParamAttr::ZExt | ParamAttr::SExt;
-
- const uint16_t IntegerTypeOnly =
- ParamAttr::SExt | ParamAttr::ZExt;
-
- const uint16_t PointerTypeOnly =
- ParamAttr::ByVal | ParamAttr::Nest |
- ParamAttr::NoAlias | ParamAttr::StructRet;
-
- bool SawSRet = false;
-
- if (const ParamAttrsList *Attrs = FT->getParamAttrs()) {
- unsigned Idx = 1;
- bool SawNest = false;
-
- uint16_t RetI = Attrs->getParamAttrs(0) & ReturnIncompatible;
- Assert1(!RetI, "Attribute " + Attrs->getParamAttrsText(RetI) +
- "should not apply to functions!", &F);
- uint16_t MutI = Attrs->getParamAttrs(0) & MutuallyIncompatible2;
- Assert1(MutI != MutuallyIncompatible2, "Attributes" +
- Attrs->getParamAttrsText(MutI) + "are incompatible!", &F);
-
- for (FunctionType::param_iterator I = FT->param_begin(),
- E = FT->param_end(); I != E; ++I, ++Idx) {
-
- uint16_t Attr = Attrs->getParamAttrs(Idx);
-
- uint16_t ParmI = Attr & ParameterIncompatible;
- Assert1(!ParmI, "Attribute " + Attrs->getParamAttrsText(ParmI) +
- "should only be applied to function!", &F);
-
- uint16_t MutI = Attr & MutuallyIncompatible;
- Assert1(!(MutI & (MutI - 1)), "Attributes " +
- Attrs->getParamAttrsText(MutI) + "are incompatible!", &F);
-
- uint16_t MutI2 = Attr & MutuallyIncompatible2;
- Assert1(MutI2 != MutuallyIncompatible2, "Attributes" +
- Attrs->getParamAttrsText(MutI2) + "are incompatible!", &F);
-
- uint16_t IType = Attr & IntegerTypeOnly;
- Assert1(!IType || FT->getParamType(Idx-1)->isInteger(),
- "Attribute " + Attrs->getParamAttrsText(IType) +
- "should only apply to Integer type!", &F);
-
- uint16_t PType = Attr & PointerTypeOnly;
- Assert1(!PType || isa<PointerType>(FT->getParamType(Idx-1)),
- "Attribute " + Attrs->getParamAttrsText(PType) +
- "should only apply to Pointer type!", &F);
-
- if (Attrs->paramHasAttr(Idx, ParamAttr::ByVal)) {
- const PointerType *Ty =
- dyn_cast<PointerType>(FT->getParamType(Idx-1));
- Assert1(!Ty || isa<StructType>(Ty->getElementType()),
- "Attribute byval should only apply to pointer to structs!", &F);
- }
-
- if (Attrs->paramHasAttr(Idx, ParamAttr::Nest)) {
- Assert1(!SawNest, "More than one parameter has attribute nest!", &F);
- SawNest = true;
- }