From e603fe46649aee6f6aeca1668f0b617818af1e1d Mon Sep 17 00:00:00 2001 From: Bill Wendling Date: Wed, 19 Sep 2012 23:54:18 +0000 Subject: [PATCH] Convert some attribute existence queries over to use the predicate methods. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@164268 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/AsmParser/LLParser.cpp | 18 ++++++++--------- lib/CodeGen/Analysis.cpp | 4 ++-- lib/VMCore/Attributes.cpp | 50 +++++++++++++++++++++++----------------------- lib/VMCore/Verifier.cpp | 4 ++-- 4 files changed, 38 insertions(+), 38 deletions(-) diff --git a/lib/AsmParser/LLParser.cpp b/lib/AsmParser/LLParser.cpp index b0b64d89d92..2e4af3abb76 100644 --- a/lib/AsmParser/LLParser.cpp +++ b/lib/AsmParser/LLParser.cpp @@ -2726,16 +2726,16 @@ bool LLParser::ParseFunctionHeader(Function *&Fn, bool isDefine) { std::vector ParamTypeList; SmallVector Attrs; - if (RetAttrs != Attribute::None) + if (RetAttrs.hasAttributes()) Attrs.push_back(AttributeWithIndex::get(0, RetAttrs)); for (unsigned i = 0, e = ArgList.size(); i != e; ++i) { ParamTypeList.push_back(ArgList[i].Ty); - if (ArgList[i].Attrs != Attribute::None) + if (ArgList[i].Attrs.hasAttributes()) Attrs.push_back(AttributeWithIndex::get(i+1, ArgList[i].Attrs)); } - if (FuncAttrs != Attribute::None) + if (FuncAttrs.hasAttributes()) Attrs.push_back(AttributeWithIndex::get(~0, FuncAttrs)); AttrListPtr PAL = AttrListPtr::get(Attrs); @@ -3253,7 +3253,7 @@ bool LLParser::ParseInvoke(Instruction *&Inst, PerFunctionState &PFS) { // Set up the Attributes for the function. SmallVector Attrs; - if (RetAttrs != Attribute::None) + if (RetAttrs.hasAttributes()) Attrs.push_back(AttributeWithIndex::get(0, RetAttrs)); SmallVector Args; @@ -3274,14 +3274,14 @@ bool LLParser::ParseInvoke(Instruction *&Inst, PerFunctionState &PFS) { return Error(ArgList[i].Loc, "argument is not of expected type '" + getTypeString(ExpectedTy) + "'"); Args.push_back(ArgList[i].V); - if (ArgList[i].Attrs != Attribute::None) + if (ArgList[i].Attrs.hasAttributes()) Attrs.push_back(AttributeWithIndex::get(i+1, ArgList[i].Attrs)); } if (I != E) return Error(CallLoc, "not enough parameters specified for call"); - if (FnAttrs != Attribute::None) + if (FnAttrs.hasAttributes()) Attrs.push_back(AttributeWithIndex::get(~0, FnAttrs)); // Finish off the Attributes and check them @@ -3649,7 +3649,7 @@ bool LLParser::ParseCall(Instruction *&Inst, PerFunctionState &PFS, // Set up the Attributes for the function. SmallVector Attrs; - if (RetAttrs != Attribute::None) + if (RetAttrs.hasAttributes()) Attrs.push_back(AttributeWithIndex::get(0, RetAttrs)); SmallVector Args; @@ -3670,14 +3670,14 @@ bool LLParser::ParseCall(Instruction *&Inst, PerFunctionState &PFS, return Error(ArgList[i].Loc, "argument is not of expected type '" + getTypeString(ExpectedTy) + "'"); Args.push_back(ArgList[i].V); - if (ArgList[i].Attrs != Attribute::None) + if (ArgList[i].Attrs.hasAttributes()) Attrs.push_back(AttributeWithIndex::get(i+1, ArgList[i].Attrs)); } if (I != E) return Error(CallLoc, "not enough parameters specified for call"); - if (FnAttrs != Attribute::None) + if (FnAttrs.hasAttributes()) Attrs.push_back(AttributeWithIndex::get(~0, FnAttrs)); // Finish off the Attributes and check them diff --git a/lib/CodeGen/Analysis.cpp b/lib/CodeGen/Analysis.cpp index 447f3981b52..1f3f5a5f383 100644 --- a/lib/CodeGen/Analysis.cpp +++ b/lib/CodeGen/Analysis.cpp @@ -318,7 +318,7 @@ bool llvm::isInTailCallPosition(ImmutableCallSite CS, Attributes CalleeRetAttr, return false; // It's not safe to eliminate the sign / zero extension of the return value. - if ((CallerRetAttr & Attribute::ZExt) || (CallerRetAttr & Attribute::SExt)) + if (CallerRetAttr.hasZExtAttr() || CallerRetAttr.hasSExtAttr()) return false; // Otherwise, make sure the unmodified return value of I is the return value. @@ -358,7 +358,7 @@ bool llvm::isInTailCallPosition(SelectionDAG &DAG, SDNode *Node, return false; // It's not safe to eliminate the sign / zero extension of the return value. - if ((CallerRetAttr & Attribute::ZExt) || (CallerRetAttr & Attribute::SExt)) + if (CallerRetAttr.hasZExtAttr() || CallerRetAttr.hasSExtAttr()) return false; // Check if the only use is a function return node. diff --git a/lib/VMCore/Attributes.cpp b/lib/VMCore/Attributes.cpp index 0458853b3f6..7d85ecb60d8 100644 --- a/lib/VMCore/Attributes.cpp +++ b/lib/VMCore/Attributes.cpp @@ -28,55 +28,55 @@ using namespace llvm; std::string Attribute::getAsString(Attributes Attrs) { std::string Result; - if (Attrs & Attribute::ZExt) + if (Attrs.hasZExtAttr()) Result += "zeroext "; - if (Attrs & Attribute::SExt) + if (Attrs.hasSExtAttr()) Result += "signext "; - if (Attrs & Attribute::NoReturn) + if (Attrs.hasNoReturnAttr()) Result += "noreturn "; - if (Attrs & Attribute::NoUnwind) + if (Attrs.hasNoUnwindAttr()) Result += "nounwind "; - if (Attrs & Attribute::UWTable) + if (Attrs.hasUWTableAttr()) Result += "uwtable "; - if (Attrs & Attribute::ReturnsTwice) + if (Attrs.hasReturnsTwiceAttr()) Result += "returns_twice "; - if (Attrs & Attribute::InReg) + if (Attrs.hasInRegAttr()) Result += "inreg "; - if (Attrs & Attribute::NoAlias) + if (Attrs.hasNoAliasAttr()) Result += "noalias "; - if (Attrs & Attribute::NoCapture) + if (Attrs.hasNoCaptureAttr()) Result += "nocapture "; - if (Attrs & Attribute::StructRet) + if (Attrs.hasStructRetAttr()) Result += "sret "; - if (Attrs & Attribute::ByVal) + if (Attrs.hasByValAttr()) Result += "byval "; - if (Attrs & Attribute::Nest) + if (Attrs.hasNestAttr()) Result += "nest "; - if (Attrs & Attribute::ReadNone) + if (Attrs.hasReadNoneAttr()) Result += "readnone "; - if (Attrs & Attribute::ReadOnly) + if (Attrs.hasReadOnlyAttr()) Result += "readonly "; - if (Attrs & Attribute::OptimizeForSize) + if (Attrs.hasOptimizeForSizeAttr()) Result += "optsize "; - if (Attrs & Attribute::NoInline) + if (Attrs.hasNoInlineAttr()) Result += "noinline "; - if (Attrs & Attribute::InlineHint) + if (Attrs.hasInlineHintAttr()) Result += "inlinehint "; - if (Attrs & Attribute::AlwaysInline) + if (Attrs.hasAlwaysInlineAttr()) Result += "alwaysinline "; - if (Attrs & Attribute::StackProtect) + if (Attrs.hasStackProtectAttr()) Result += "ssp "; - if (Attrs & Attribute::StackProtectReq) + if (Attrs.hasStackProtectReqAttr()) Result += "sspreq "; - if (Attrs & Attribute::NoRedZone) + if (Attrs.hasNoRedZoneAttr()) Result += "noredzone "; - if (Attrs & Attribute::NoImplicitFloat) + if (Attrs.hasNoImplicitFloatAttr()) Result += "noimplicitfloat "; - if (Attrs & Attribute::Naked) + if (Attrs.hasNakedAttr()) Result += "naked "; - if (Attrs & Attribute::NonLazyBind) + if (Attrs.hasNonLazyBindAttr()) Result += "nonlazybind "; - if (Attrs & Attribute::AddressSafety) + if (Attrs.hasAddressSafetyAttr()) Result += "address_safety "; if (Attrs & Attribute::StackAlignment) { Result += "alignstack("; diff --git a/lib/VMCore/Verifier.cpp b/lib/VMCore/Verifier.cpp index c932d9e5398..83c900add58 100644 --- a/lib/VMCore/Verifier.cpp +++ b/lib/VMCore/Verifier.cpp @@ -585,12 +585,12 @@ void Verifier::VerifyFunctionAttrs(FunctionType *FT, VerifyParameterAttrs(Attr.Attrs, Ty, Attr.Index == 0, V); - if (Attr.Attrs & Attribute::Nest) { + if (Attr.Attrs.hasNestAttr()) { Assert1(!SawNest, "More than one parameter has attribute nest!", V); SawNest = true; } - if (Attr.Attrs & Attribute::StructRet) + if (Attr.Attrs.hasStructRetAttr()) Assert1(Attr.Index == 1, "Attribute sret not on first parameter!", V); } -- 2.11.0