diff options
Diffstat (limited to 'llvm/lib/IR/Attributes.cpp')
-rw-r--r-- | llvm/lib/IR/Attributes.cpp | 20 |
1 files changed, 15 insertions, 5 deletions
diff --git a/llvm/lib/IR/Attributes.cpp b/llvm/lib/IR/Attributes.cpp index a7fba3ff47f..fb99c855343 100644 --- a/llvm/lib/IR/Attributes.cpp +++ b/llvm/lib/IR/Attributes.cpp @@ -89,11 +89,11 @@ unsigned Attribute::getStackAlignment() const { } bool Attribute::operator==(AttrKind K) const { - return pImpl && pImpl->contains(K); + return pImpl && *pImpl == K; } bool Attribute::operator!=(AttrKind K) const { - return !(pImpl && pImpl->contains(K)); + return !(pImpl && *pImpl == K); } uint64_t Attribute::getBitMask() const { @@ -274,10 +274,14 @@ AttrBuilder &AttrBuilder::removeAttributes(const Attribute &A){ return *this; } -bool AttrBuilder::contains(Attribute::AttrKind A) const { +bool AttrBuilder::operator==(Attribute::AttrKind A) const { return Bits & AttributeImpl::getAttrMask(A); } +bool AttrBuilder::operator!=(Attribute::AttrKind A) const { + return !(*this == A); +} + bool AttrBuilder::hasAttributes() const { return Bits != 0; } @@ -322,18 +326,24 @@ AttributeImpl::AttributeImpl(LLVMContext &C, StringRef 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)) return CI->getZExtValue() == Kind; 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 (CDA->isString()) return CDA->getAsString() == Kind; return false; } +bool AttributeImpl::operator!=(StringRef Kind) const { + return !(*this == Kind); +} uint64_t AttributeImpl::getBitMask() const { // FIXME: Remove this. |