Cosmetic changes to parameter attribute verification.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@73188 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Duncan Sands 2009-06-11 08:11:03 +00:00
parent 861d20aab4
commit d6de30ceea
2 changed files with 21 additions and 19 deletions

View File

@ -61,7 +61,8 @@ const Attributes NoImplicitFloat = 1<<23; /// disable implicit floating point
/// @brief Attributes that only apply to function parameters.
const Attributes ParameterOnly = ByVal | Nest | StructRet | NoCapture;
/// @brief Attributes that only apply to function.
/// @brief Attributes that may be applied to the function itself. These cannot
/// be used on return values or function parameters.
const Attributes FunctionOnly = NoReturn | NoUnwind | ReadNone | ReadOnly |
NoInline | AlwaysInline | OptimizeForSize | StackProtect | StackProtectReq |
NoRedZone | NoImplicitFloat;
@ -186,7 +187,7 @@ public:
/// getFnAttributes - The function attributes are returned.
Attributes getFnAttributes() const {
return getAttributes(~0);
return getAttributes(~0U);
}
/// paramHasAttr - Return true if the specified parameter index has the

View File

@ -276,7 +276,7 @@ namespace {
int VT, unsigned ArgNo, std::string &Suffix);
void VerifyIntrinsicPrototype(Intrinsic::ID ID, Function *F,
unsigned RetNum, unsigned ParamNum, ...);
void VerifyAttrs(Attributes Attrs, const Type *Ty,
void VerifyParameterAttrs(Attributes Attrs, const Type *Ty,
bool isReturnValue, const Value *V);
void VerifyFunctionAttrs(const FunctionType *FT, const AttrListPtr &Attrs,
const Value *V);
@ -437,21 +437,22 @@ void Verifier::visitGlobalAlias(GlobalAlias &GA) {
void Verifier::verifyTypeSymbolTable(TypeSymbolTable &ST) {
}
// VerifyAttrs - Check the given parameter attributes for an argument or return
// VerifyParameterAttrs - Check the given attributes for an argument or return
// value of the specified type. The value V is printed in error messages.
void Verifier::VerifyAttrs(Attributes Attrs, const Type *Ty,
void Verifier::VerifyParameterAttrs(Attributes Attrs, const Type *Ty,
bool isReturnValue, const Value *V) {
if (Attrs == Attribute::None)
return;
Attributes FnCheckAttr = Attrs & Attribute::FunctionOnly;
Assert1(!FnCheckAttr, "Attribute " + Attribute::getAsString(FnCheckAttr) +
" only applies to the function!", V);
if (isReturnValue) {
Attributes RetI = Attrs & Attribute::ParameterOnly;
Assert1(!RetI, "Attribute " + Attribute::getAsString(RetI) +
" does not apply to return values!", V);
}
Attributes FnCheckAttr = Attrs & Attribute::FunctionOnly;
Assert1(!FnCheckAttr, "Attribute " + Attribute::getAsString(FnCheckAttr) +
" only applies to functions!", V);
for (unsigned i = 0;
i < array_lengthof(Attribute::MutuallyIncompatible); ++i) {
@ -495,9 +496,9 @@ void Verifier::VerifyFunctionAttrs(const FunctionType *FT,
else if (Attr.Index-1 < FT->getNumParams())
Ty = FT->getParamType(Attr.Index-1);
else
break; // VarArgs attributes, don't verify.
break; // VarArgs attributes, verified elsewhere.
VerifyAttrs(Attr.Attrs, Ty, Attr.Index == 0, V);
VerifyParameterAttrs(Attr.Attrs, Ty, Attr.Index == 0, V);
if (Attr.Attrs & Attribute::Nest) {
Assert1(!SawNest, "More than one parameter has attribute nest!", V);
@ -509,9 +510,9 @@ void Verifier::VerifyFunctionAttrs(const FunctionType *FT,
}
Attributes FAttrs = Attrs.getFnAttributes();
Assert1(!(FAttrs & (~Attribute::FunctionOnly)),
"Attribute " + Attribute::getAsString(FAttrs) +
" does not apply to function!", V);
Attributes NotFn = FAttrs & (~Attribute::FunctionOnly);
Assert1(!NotFn, "Attribute " + Attribute::getAsString(NotFn) +
" does not apply to the function!", V);
for (unsigned i = 0;
i < array_lengthof(Attribute::MutuallyIncompatible); ++i) {
@ -1025,7 +1026,7 @@ void Verifier::VerifyCallSite(CallSite CS) {
for (unsigned Idx = 1 + FTy->getNumParams(); Idx <= CS.arg_size(); ++Idx) {
Attributes Attr = Attrs.getParamAttributes(Idx);
VerifyAttrs(Attr, CS.getArgument(Idx-1)->getType(), false, I);
VerifyParameterAttrs(Attr, CS.getArgument(Idx-1)->getType(), false, I);
Attributes VArgI = Attr & Attribute::VarArgsIncompatible;
Assert1(!VArgI, "Attribute " + Attribute::getAsString(VArgI) +