Remove the 'contains' methods in favor of the 'operator==' method.
The 'operator==' method is a bit clearer and much less verbose for somethings that should have only one value. Remove from the AttrBuilder for consistency. llvm-svn: 171442
This commit is contained in:
parent
cedab7ecf3
commit
af9a90cc00
|
@ -179,9 +179,6 @@ public:
|
||||||
/// removeAttribute - Remove the attributes from A from the builder.
|
/// removeAttribute - Remove the attributes from A from the builder.
|
||||||
AttrBuilder &removeAttributes(const Attribute &A);
|
AttrBuilder &removeAttributes(const Attribute &A);
|
||||||
|
|
||||||
/// \brief Return true if the builder has the specified attribute.
|
|
||||||
bool contains(Attribute::AttrKind A) const;
|
|
||||||
|
|
||||||
/// hasAttributes - Return true if the builder has IR-level attributes.
|
/// hasAttributes - Return true if the builder has IR-level attributes.
|
||||||
bool hasAttributes() const;
|
bool hasAttributes() const;
|
||||||
|
|
||||||
|
@ -242,6 +239,9 @@ public:
|
||||||
bool operator!=(const AttrBuilder &B) {
|
bool operator!=(const AttrBuilder &B) {
|
||||||
return Bits != B.Bits;
|
return Bits != B.Bits;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool operator==(Attribute::AttrKind A) const;
|
||||||
|
bool operator!=(Attribute::AttrKind A) const;
|
||||||
};
|
};
|
||||||
|
|
||||||
//===----------------------------------------------------------------------===//
|
//===----------------------------------------------------------------------===//
|
||||||
|
|
|
@ -42,9 +42,6 @@ public:
|
||||||
return Vals;
|
return Vals;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool contains(Attribute::AttrKind Kind) const;
|
|
||||||
bool contains(StringRef Kind) const;
|
|
||||||
|
|
||||||
bool hasAttribute(Attribute::AttrKind A) const;
|
bool hasAttribute(Attribute::AttrKind A) const;
|
||||||
|
|
||||||
bool hasAttributes() const;
|
bool hasAttributes() const;
|
||||||
|
@ -53,19 +50,11 @@ public:
|
||||||
uint64_t getAlignment() const;
|
uint64_t getAlignment() const;
|
||||||
uint64_t getStackAlignment() const;
|
uint64_t getStackAlignment() const;
|
||||||
|
|
||||||
bool operator==(Attribute::AttrKind Kind) const {
|
bool operator==(Attribute::AttrKind Kind) const;
|
||||||
return contains(Kind);
|
bool operator!=(Attribute::AttrKind Kind) const;
|
||||||
}
|
|
||||||
bool operator!=(Attribute::AttrKind Kind) const {
|
|
||||||
return !contains(Kind);
|
|
||||||
}
|
|
||||||
|
|
||||||
bool operator==(StringRef Kind) const {
|
bool operator==(StringRef Kind) const;
|
||||||
return contains(Kind);
|
bool operator!=(StringRef Kind) const;
|
||||||
}
|
|
||||||
bool operator!=(StringRef Kind) const {
|
|
||||||
return !contains(Kind);
|
|
||||||
}
|
|
||||||
|
|
||||||
uint64_t getBitMask() const; // FIXME: Remove.
|
uint64_t getBitMask() const; // FIXME: Remove.
|
||||||
|
|
||||||
|
|
|
@ -89,11 +89,11 @@ unsigned Attribute::getStackAlignment() const {
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Attribute::operator==(AttrKind K) const {
|
bool Attribute::operator==(AttrKind K) const {
|
||||||
return pImpl && pImpl->contains(K);
|
return pImpl && *pImpl == K;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Attribute::operator!=(AttrKind K) const {
|
bool Attribute::operator!=(AttrKind K) const {
|
||||||
return !(pImpl && pImpl->contains(K));
|
return !(pImpl && *pImpl == K);
|
||||||
}
|
}
|
||||||
|
|
||||||
uint64_t Attribute::getBitMask() const {
|
uint64_t Attribute::getBitMask() const {
|
||||||
|
@ -274,10 +274,14 @@ AttrBuilder &AttrBuilder::removeAttributes(const Attribute &A){
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool AttrBuilder::contains(Attribute::AttrKind A) const {
|
bool AttrBuilder::operator==(Attribute::AttrKind A) const {
|
||||||
return Bits & AttributeImpl::getAttrMask(A);
|
return Bits & AttributeImpl::getAttrMask(A);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool AttrBuilder::operator!=(Attribute::AttrKind A) const {
|
||||||
|
return !(*this == A);
|
||||||
|
}
|
||||||
|
|
||||||
bool AttrBuilder::hasAttributes() const {
|
bool AttrBuilder::hasAttributes() const {
|
||||||
return Bits != 0;
|
return Bits != 0;
|
||||||
}
|
}
|
||||||
|
@ -322,18 +326,24 @@ AttributeImpl::AttributeImpl(LLVMContext &C, StringRef data) {
|
||||||
Data = ConstantDataArray::getString(C, data);
|
Data = ConstantDataArray::getString(C, data);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool AttributeImpl::contains(Attribute::AttrKind Kind) const {
|
bool AttributeImpl::operator==(Attribute::AttrKind Kind) const {
|
||||||
if (ConstantInt *CI = dyn_cast<ConstantInt>(Data))
|
if (ConstantInt *CI = dyn_cast<ConstantInt>(Data))
|
||||||
return CI->getZExtValue() == Kind;
|
return CI->getZExtValue() == Kind;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
bool AttributeImpl::operator!=(Attribute::AttrKind Kind) const {
|
||||||
|
return !(*this == Kind);
|
||||||
|
}
|
||||||
|
|
||||||
bool AttributeImpl::contains(StringRef Kind) const {
|
bool AttributeImpl::operator==(StringRef Kind) const {
|
||||||
if (ConstantDataArray *CDA = dyn_cast<ConstantDataArray>(Data))
|
if (ConstantDataArray *CDA = dyn_cast<ConstantDataArray>(Data))
|
||||||
if (CDA->isString())
|
if (CDA->isString())
|
||||||
return CDA->getAsString() == Kind;
|
return CDA->getAsString() == Kind;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
bool AttributeImpl::operator!=(StringRef Kind) const {
|
||||||
|
return !(*this == Kind);
|
||||||
|
}
|
||||||
|
|
||||||
uint64_t AttributeImpl::getBitMask() const {
|
uint64_t AttributeImpl::getBitMask() const {
|
||||||
// FIXME: Remove this.
|
// FIXME: Remove this.
|
||||||
|
|
Loading…
Reference in New Issue