From 3564e5c13d965b5963e1dd4c8608dbe9ebef42f2 Mon Sep 17 00:00:00 2001 From: Amaury Sechet Date: Tue, 14 Jun 2016 20:27:35 +0000 Subject: [PATCH] Make sure attribute kind and attributes are named respectively Kind and Attr consistently. Historically they used to be the same the terminology is very confused in the codebase. NFC. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@272704 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/IR/Attributes.h | 14 +++++----- include/llvm/IR/CallSite.h | 28 +++++++++---------- include/llvm/IR/Function.h | 18 ++++++------- include/llvm/IR/Instructions.h | 40 +++++++++++++-------------- lib/IR/Attributes.cpp | 23 ++++++---------- lib/IR/Function.cpp | 16 +++++------ lib/IR/Instructions.cpp | 49 +++++++++++++++++----------------- 7 files changed, 89 insertions(+), 99 deletions(-) diff --git a/include/llvm/IR/Attributes.h b/include/llvm/IR/Attributes.h index 5a3e07e0ea9..8a6b568ed8d 100644 --- a/include/llvm/IR/Attributes.h +++ b/include/llvm/IR/Attributes.h @@ -242,20 +242,18 @@ public: /// \brief Return an AttributeSet with the specified parameters in it. static AttributeSet get(LLVMContext &C, ArrayRef Attrs); static AttributeSet get(LLVMContext &C, unsigned Index, - ArrayRef Kind); + ArrayRef Kinds); static AttributeSet get(LLVMContext &C, unsigned Index, const AttrBuilder &B); /// \brief Add an attribute to the attribute set at the given index. Because /// attribute sets are immutable, this returns a new set. AttributeSet addAttribute(LLVMContext &C, unsigned Index, - Attribute::AttrKind Attr) const; + Attribute::AttrKind Kind) const; /// \brief Add an attribute to the attribute set at the given index. Because /// attribute sets are immutable, this returns a new set. - AttributeSet addAttribute(LLVMContext &C, unsigned Index, - StringRef Kind) const; - AttributeSet addAttribute(LLVMContext &C, unsigned Index, - StringRef Kind, StringRef Value) const; + AttributeSet addAttribute(LLVMContext &C, unsigned Index, StringRef Kind, + StringRef Value = StringRef()) const; /// Add an attribute to the attribute set at the given indices. Because /// attribute sets are immutable, this returns a new set. @@ -271,7 +269,7 @@ public: /// attribute list. Because attribute lists are immutable, this returns the /// new list. AttributeSet removeAttribute(LLVMContext &C, unsigned Index, - Attribute::AttrKind Attr) const; + Attribute::AttrKind Kind) const; /// \brief Remove the specified attributes at the specified index from this /// attribute list. Because attribute lists are immutable, this returns the @@ -333,7 +331,7 @@ public: /// \brief Return true if the specified attribute is set for at least one /// parameter or for the return value. - bool hasAttrSomewhere(Attribute::AttrKind Attr) const; + bool hasAttrSomewhere(Attribute::AttrKind Kind) const; /// \brief Return the attribute object that exists at the given index. Attribute getAttribute(unsigned Index, Attribute::AttrKind Kind) const; diff --git a/include/llvm/IR/CallSite.h b/include/llvm/IR/CallSite.h index 1a08434a31d..be93636d4c8 100644 --- a/include/llvm/IR/CallSite.h +++ b/include/llvm/IR/CallSite.h @@ -305,35 +305,35 @@ public: CALLSITE_DELEGATE_SETTER(setAttributes(PAL)); } - void addAttribute(unsigned i, Attribute::AttrKind attr) { - CALLSITE_DELEGATE_SETTER(addAttribute(i, attr)); + void addAttribute(unsigned i, Attribute::AttrKind Kind) { + CALLSITE_DELEGATE_SETTER(addAttribute(i, Kind)); } void addAttribute(unsigned i, StringRef Kind, StringRef Value) { CALLSITE_DELEGATE_SETTER(addAttribute(i, Kind, Value)); } - void removeAttribute(unsigned i, Attribute::AttrKind attr) { - CALLSITE_DELEGATE_SETTER(removeAttribute(i, attr)); + void removeAttribute(unsigned i, Attribute::AttrKind Kind) { + CALLSITE_DELEGATE_SETTER(removeAttribute(i, Kind)); } - void removeAttribute(unsigned i, Attribute attr) { - CALLSITE_DELEGATE_SETTER(removeAttribute(i, attr)); + void removeAttribute(unsigned i, Attribute Attr) { + CALLSITE_DELEGATE_SETTER(removeAttribute(i, Attr)); } /// \brief Return true if this function has the given attribute. - bool hasFnAttr(Attribute::AttrKind A) const { - CALLSITE_DELEGATE_GETTER(hasFnAttr(A)); + bool hasFnAttr(Attribute::AttrKind Kind) const { + CALLSITE_DELEGATE_GETTER(hasFnAttr(Kind)); } /// \brief Return true if this function has the given attribute. - bool hasFnAttr(StringRef A) const { - CALLSITE_DELEGATE_GETTER(hasFnAttr(A)); + bool hasFnAttr(StringRef Kind) const { + CALLSITE_DELEGATE_GETTER(hasFnAttr(Kind)); } /// \brief Return true if the call or the callee has the given attribute. - bool paramHasAttr(unsigned i, Attribute::AttrKind A) const { - CALLSITE_DELEGATE_GETTER(paramHasAttr(i, A)); + bool paramHasAttr(unsigned i, Attribute::AttrKind Kind) const { + CALLSITE_DELEGATE_GETTER(paramHasAttr(i, Kind)); } /// \brief Return true if the data operand at index \p i directly or @@ -343,8 +343,8 @@ public: /// in the attribute set attached to this instruction, while operand bundle /// operands may have some attributes implied by the type of its containing /// operand bundle. - bool dataOperandHasImpliedAttr(unsigned i, Attribute::AttrKind A) const { - CALLSITE_DELEGATE_GETTER(dataOperandHasImpliedAttr(i, A)); + bool dataOperandHasImpliedAttr(unsigned i, Attribute::AttrKind Kind) const { + CALLSITE_DELEGATE_GETTER(dataOperandHasImpliedAttr(i, Kind)); } /// @brief Extract the alignment for a call or parameter (0=unknown). diff --git a/include/llvm/IR/Function.h b/include/llvm/IR/Function.h index 7b6a68accbb..954ccd4f9e3 100644 --- a/include/llvm/IR/Function.h +++ b/include/llvm/IR/Function.h @@ -163,7 +163,7 @@ public: AttributeSet getAttributes() const { return AttributeSets; } /// @brief Set the attribute list for this Function. - void setAttributes(AttributeSet attrs) { AttributeSets = attrs; } + void setAttributes(AttributeSet Attrs) { AttributeSets = Attrs; } /// @brief Add function attributes to this function. void addFnAttr(Attribute::AttrKind N) { @@ -172,9 +172,9 @@ public: } /// @brief Remove function attributes from this function. - void removeFnAttr(Attribute::AttrKind N) { + void removeFnAttr(Attribute::AttrKind Kind) { setAttributes(AttributeSets.removeAttribute( - getContext(), AttributeSet::FunctionIndex, N)); + getContext(), AttributeSet::FunctionIndex, Kind)); } /// @brief Add function attributes to this function. @@ -228,23 +228,23 @@ public: void clearGC(); /// @brief adds the attribute to the list of attributes. - void addAttribute(unsigned i, Attribute::AttrKind attr); + void addAttribute(unsigned i, Attribute::AttrKind Kind); /// @brief adds the attribute to the list of attributes. void addAttribute(unsigned i, Attribute Attr); /// @brief adds the attributes to the list of attributes. - void addAttributes(unsigned i, AttributeSet attrs); + void addAttributes(unsigned i, AttributeSet Attrs); /// @brief removes the attribute from the list of attributes. - void removeAttribute(unsigned i, Attribute::AttrKind attr); + void removeAttribute(unsigned i, Attribute::AttrKind Kind); /// @brief removes the attributes from the list of attributes. - void removeAttributes(unsigned i, AttributeSet attr); + void removeAttributes(unsigned i, AttributeSet Attrs); /// @brief check if an attributes is in the list of attributes. - bool hasAttribute(unsigned i, Attribute::AttrKind attr) const { - return getAttributes().hasAttribute(i, attr); + bool hasAttribute(unsigned i, Attribute::AttrKind Kind) const { + return getAttributes().hasAttribute(i, Kind); } Attribute getAttribute(unsigned i, Attribute::AttrKind Kind) const { diff --git a/include/llvm/IR/Instructions.h b/include/llvm/IR/Instructions.h index def64ad2b5c..5b5c1ed59eb 100644 --- a/include/llvm/IR/Instructions.h +++ b/include/llvm/IR/Instructions.h @@ -1618,16 +1618,16 @@ public: void setAttributes(const AttributeSet &Attrs) { AttributeList = Attrs; } /// addAttribute - adds the attribute to the list of attributes. - void addAttribute(unsigned i, Attribute::AttrKind attr); + void addAttribute(unsigned i, Attribute::AttrKind Kind); /// addAttribute - adds the attribute to the list of attributes. void addAttribute(unsigned i, StringRef Kind, StringRef Value); /// removeAttribute - removes the attribute from the list of attributes. - void removeAttribute(unsigned i, Attribute::AttrKind attr); + void removeAttribute(unsigned i, Attribute::AttrKind Kind); /// removeAttribute - removes the attribute from the list of attributes. - void removeAttribute(unsigned i, Attribute attr); + void removeAttribute(unsigned i, Attribute Attr); /// \brief adds the dereferenceable attribute to the list of attributes. void addDereferenceableAttr(unsigned i, uint64_t Bytes); @@ -1637,19 +1637,19 @@ public: void addDereferenceableOrNullAttr(unsigned i, uint64_t Bytes); /// \brief Determine whether this call has the given attribute. - bool hasFnAttr(Attribute::AttrKind A) const { - assert(A != Attribute::NoBuiltin && + bool hasFnAttr(Attribute::AttrKind Kind) const { + assert(Kind != Attribute::NoBuiltin && "Use CallInst::isNoBuiltin() to check for Attribute::NoBuiltin"); - return hasFnAttrImpl(A); + return hasFnAttrImpl(Kind); } /// \brief Determine whether this call has the given attribute. - bool hasFnAttr(StringRef A) const { - return hasFnAttrImpl(A); + bool hasFnAttr(StringRef Kind) const { + return hasFnAttrImpl(Kind); } /// \brief Determine whether the call or the callee has the given attributes. - bool paramHasAttr(unsigned i, Attribute::AttrKind A) const; + bool paramHasAttr(unsigned i, Attribute::AttrKind Kind) const; /// \brief Return true if the data operand at index \p i has the attribute \p /// A. @@ -1664,7 +1664,7 @@ public: /// \p i in [1, arg_size + 1) -> argument number (\p i - 1) /// \p i in [arg_size + 1, data_operand_size + 1) -> bundle operand at index /// (\p i - 1) in the operand list. - bool dataOperandHasImpliedAttr(unsigned i, Attribute::AttrKind A) const; + bool dataOperandHasImpliedAttr(unsigned i, Attribute::AttrKind Kind) const; /// \brief Extract the alignment for a call or parameter (0=unknown). unsigned getParamAlignment(unsigned i) const { @@ -3562,13 +3562,13 @@ public: void setAttributes(const AttributeSet &Attrs) { AttributeList = Attrs; } /// addAttribute - adds the attribute to the list of attributes. - void addAttribute(unsigned i, Attribute::AttrKind attr); + void addAttribute(unsigned i, Attribute::AttrKind Kind); /// removeAttribute - removes the attribute from the list of attributes. - void removeAttribute(unsigned i, Attribute::AttrKind attr); + void removeAttribute(unsigned i, Attribute::AttrKind Kind); /// removeAttribute - removes the attribute from the list of attributes. - void removeAttribute(unsigned i, Attribute attr); + void removeAttribute(unsigned i, Attribute Attr); /// \brief adds the dereferenceable attribute to the list of attributes. void addDereferenceableAttr(unsigned i, uint64_t Bytes); @@ -3578,19 +3578,19 @@ public: void addDereferenceableOrNullAttr(unsigned i, uint64_t Bytes); /// \brief Determine whether this call has the given attribute. - bool hasFnAttr(Attribute::AttrKind A) const { - assert(A != Attribute::NoBuiltin && + bool hasFnAttr(Attribute::AttrKind Kind) const { + assert(Kind != Attribute::NoBuiltin && "Use CallInst::isNoBuiltin() to check for Attribute::NoBuiltin"); - return hasFnAttrImpl(A); + return hasFnAttrImpl(Kind); } /// \brief Determine whether this call has the given attribute. - bool hasFnAttr(StringRef A) const { - return hasFnAttrImpl(A); + bool hasFnAttr(StringRef Kind) const { + return hasFnAttrImpl(Kind); } /// \brief Determine whether the call or the callee has the given attributes. - bool paramHasAttr(unsigned i, Attribute::AttrKind A) const; + bool paramHasAttr(unsigned i, Attribute::AttrKind Kind) const; /// \brief Return true if the data operand at index \p i has the attribute \p /// A. @@ -3606,7 +3606,7 @@ public: /// \p i in [1, arg_size + 1) -> argument number (\p i - 1) /// \p i in [arg_size + 1, data_operand_size + 1) -> bundle operand at index /// (\p i - 1) in the operand list. - bool dataOperandHasImpliedAttr(unsigned i, Attribute::AttrKind A) const; + bool dataOperandHasImpliedAttr(unsigned i, Attribute::AttrKind Kind) const; /// \brief Extract the alignment for a call or parameter (0=unknown). unsigned getParamAlignment(unsigned i) const { diff --git a/lib/IR/Attributes.cpp b/lib/IR/Attributes.cpp index 8d2dc5ef671..6117cdbcddf 100644 --- a/lib/IR/Attributes.cpp +++ b/lib/IR/Attributes.cpp @@ -800,9 +800,9 @@ AttributeSet AttributeSet::get(LLVMContext &C, unsigned Index, } AttributeSet AttributeSet::get(LLVMContext &C, unsigned Index, - ArrayRef Kind) { + ArrayRef Kinds) { SmallVector, 8> Attrs; - for (Attribute::AttrKind K : Kind) + for (Attribute::AttrKind K : Kinds) Attrs.push_back(std::make_pair(Index, Attribute::get(C, K))); return get(C, Attrs); } @@ -838,16 +838,9 @@ AttributeSet AttributeSet::get(LLVMContext &C, ArrayRef Attrs) { } AttributeSet AttributeSet::addAttribute(LLVMContext &C, unsigned Index, - Attribute::AttrKind Attr) const { - if (hasAttribute(Index, Attr)) return *this; - return addAttributes(C, Index, AttributeSet::get(C, Index, Attr)); -} - -AttributeSet AttributeSet::addAttribute(LLVMContext &C, unsigned Index, - StringRef Kind) const { - llvm::AttrBuilder B; - B.addAttribute(Kind); - return addAttributes(C, Index, AttributeSet::get(C, Index, B)); + Attribute::AttrKind Kind) const { + if (hasAttribute(Index, Kind)) return *this; + return addAttributes(C, Index, AttributeSet::get(C, Index, Kind)); } AttributeSet AttributeSet::addAttribute(LLVMContext &C, unsigned Index, @@ -937,9 +930,9 @@ AttributeSet AttributeSet::addAttributes(LLVMContext &C, unsigned Index, } AttributeSet AttributeSet::removeAttribute(LLVMContext &C, unsigned Index, - Attribute::AttrKind Attr) const { - if (!hasAttribute(Index, Attr)) return *this; - return removeAttributes(C, Index, AttributeSet::get(C, Index, Attr)); + Attribute::AttrKind Kind) const { + if (!hasAttribute(Index, Kind)) return *this; + return removeAttributes(C, Index, AttributeSet::get(C, Index, Kind)); } AttributeSet AttributeSet::removeAttributes(LLVMContext &C, unsigned Index, diff --git a/lib/IR/Function.cpp b/lib/IR/Function.cpp index d7eaf7190c4..b71e1baf1e9 100644 --- a/lib/IR/Function.cpp +++ b/lib/IR/Function.cpp @@ -366,9 +366,9 @@ void Function::dropAllReferences() { clearMetadata(); } -void Function::addAttribute(unsigned i, Attribute::AttrKind attr) { +void Function::addAttribute(unsigned i, Attribute::AttrKind Kind) { AttributeSet PAL = getAttributes(); - PAL = PAL.addAttribute(getContext(), i, attr); + PAL = PAL.addAttribute(getContext(), i, Kind); setAttributes(PAL); } @@ -378,21 +378,21 @@ void Function::addAttribute(unsigned i, Attribute Attr) { setAttributes(PAL); } -void Function::addAttributes(unsigned i, AttributeSet attrs) { +void Function::addAttributes(unsigned i, AttributeSet Attrs) { AttributeSet PAL = getAttributes(); - PAL = PAL.addAttributes(getContext(), i, attrs); + PAL = PAL.addAttributes(getContext(), i, Attrs); setAttributes(PAL); } -void Function::removeAttribute(unsigned i, Attribute::AttrKind attr) { +void Function::removeAttribute(unsigned i, Attribute::AttrKind Kind) { AttributeSet PAL = getAttributes(); - PAL = PAL.removeAttribute(getContext(), i, attr); + PAL = PAL.removeAttribute(getContext(), i, Kind); setAttributes(PAL); } -void Function::removeAttributes(unsigned i, AttributeSet attrs) { +void Function::removeAttributes(unsigned i, AttributeSet Attrs) { AttributeSet PAL = getAttributes(); - PAL = PAL.removeAttributes(getContext(), i, attrs); + PAL = PAL.removeAttributes(getContext(), i, Attrs); setAttributes(PAL); } diff --git a/lib/IR/Instructions.cpp b/lib/IR/Instructions.cpp index 507ddc6d93d..01d180e4abe 100644 --- a/lib/IR/Instructions.cpp +++ b/lib/IR/Instructions.cpp @@ -331,9 +331,9 @@ CallInst *CallInst::Create(CallInst *CI, ArrayRef OpB, return NewCI; } -void CallInst::addAttribute(unsigned i, Attribute::AttrKind attr) { +void CallInst::addAttribute(unsigned i, Attribute::AttrKind Kind) { AttributeSet PAL = getAttributes(); - PAL = PAL.addAttribute(getContext(), i, attr); + PAL = PAL.addAttribute(getContext(), i, Kind); setAttributes(PAL); } @@ -343,15 +343,15 @@ void CallInst::addAttribute(unsigned i, StringRef Kind, StringRef Value) { setAttributes(PAL); } -void CallInst::removeAttribute(unsigned i, Attribute::AttrKind attr) { +void CallInst::removeAttribute(unsigned i, Attribute::AttrKind Kind) { AttributeSet PAL = getAttributes(); - PAL = PAL.removeAttribute(getContext(), i, attr); + PAL = PAL.removeAttribute(getContext(), i, Kind); setAttributes(PAL); } -void CallInst::removeAttribute(unsigned i, Attribute attr) { +void CallInst::removeAttribute(unsigned i, Attribute Attr) { AttributeSet PAL = getAttributes(); - AttrBuilder B(attr); + AttrBuilder B(Attr); LLVMContext &Context = getContext(); PAL = PAL.removeAttributes(Context, i, AttributeSet::get(Context, i, B)); @@ -370,19 +370,18 @@ void CallInst::addDereferenceableOrNullAttr(unsigned i, uint64_t Bytes) { setAttributes(PAL); } -bool CallInst::paramHasAttr(unsigned i, Attribute::AttrKind A) const { +bool CallInst::paramHasAttr(unsigned i, Attribute::AttrKind Kind) const { assert(i < (getNumArgOperands() + 1) && "Param index out of bounds!"); - if (AttributeList.hasAttribute(i, A)) + if (AttributeList.hasAttribute(i, Kind)) return true; if (const Function *F = getCalledFunction()) - return F->getAttributes().hasAttribute(i, A); + return F->getAttributes().hasAttribute(i, Kind); return false; } bool CallInst::dataOperandHasImpliedAttr(unsigned i, - Attribute::AttrKind A) const { - + Attribute::AttrKind Kind) const { // There are getNumOperands() - 1 data operands. The last operand is the // callee. assert(i < getNumOperands() && "Data operand index out of bounds!"); @@ -392,11 +391,11 @@ bool CallInst::dataOperandHasImpliedAttr(unsigned i, // containing operand bundle, if the operand is a bundle operand. if (i < (getNumArgOperands() + 1)) - return paramHasAttr(i, A); + return paramHasAttr(i, Kind); assert(hasOperandBundles() && i >= (getBundleOperandsStartIndex() + 1) && "Must be either a call argument or an operand bundle!"); - return bundleOperandHasAttr(i - 1, A); + return bundleOperandHasAttr(i - 1, Kind); } /// IsConstantOne - Return true only if val is constant int 1 @@ -669,18 +668,18 @@ void InvokeInst::setSuccessorV(unsigned idx, BasicBlock *B) { return setSuccessor(idx, B); } -bool InvokeInst::paramHasAttr(unsigned i, Attribute::AttrKind A) const { +bool InvokeInst::paramHasAttr(unsigned i, Attribute::AttrKind Kind) const { assert(i < (getNumArgOperands() + 1) && "Param index out of bounds!"); - if (AttributeList.hasAttribute(i, A)) + if (AttributeList.hasAttribute(i, Kind)) return true; if (const Function *F = getCalledFunction()) - return F->getAttributes().hasAttribute(i, A); + return F->getAttributes().hasAttribute(i, Kind); return false; } bool InvokeInst::dataOperandHasImpliedAttr(unsigned i, - Attribute::AttrKind A) const { + Attribute::AttrKind Kind) const { // There are getNumOperands() - 3 data operands. The last three operands are // the callee and the two successor basic blocks. assert(i < (getNumOperands() - 2) && "Data operand index out of bounds!"); @@ -690,28 +689,28 @@ bool InvokeInst::dataOperandHasImpliedAttr(unsigned i, // containing operand bundle, if the operand is a bundle operand. if (i < (getNumArgOperands() + 1)) - return paramHasAttr(i, A); + return paramHasAttr(i, Kind); assert(hasOperandBundles() && i >= (getBundleOperandsStartIndex() + 1) && "Must be either an invoke argument or an operand bundle!"); - return bundleOperandHasAttr(i - 1, A); + return bundleOperandHasAttr(i - 1, Kind); } -void InvokeInst::addAttribute(unsigned i, Attribute::AttrKind attr) { +void InvokeInst::addAttribute(unsigned i, Attribute::AttrKind Kind) { AttributeSet PAL = getAttributes(); - PAL = PAL.addAttribute(getContext(), i, attr); + PAL = PAL.addAttribute(getContext(), i, Kind); setAttributes(PAL); } -void InvokeInst::removeAttribute(unsigned i, Attribute::AttrKind attr) { +void InvokeInst::removeAttribute(unsigned i, Attribute::AttrKind Kind) { AttributeSet PAL = getAttributes(); - PAL = PAL.removeAttribute(getContext(), i, attr); + PAL = PAL.removeAttribute(getContext(), i, Kind); setAttributes(PAL); } -void InvokeInst::removeAttribute(unsigned i, Attribute attr) { +void InvokeInst::removeAttribute(unsigned i, Attribute Attr) { AttributeSet PAL = getAttributes(); - AttrBuilder B(attr); + AttrBuilder B(Attr); PAL = PAL.removeAttributes(getContext(), i, AttributeSet::get(getContext(), i, B)); setAttributes(PAL); -- 2.50.1