[llvm-commits] [llvm] r171442 - in /llvm/trunk: include/llvm/IR/Attributes.h lib/IR/AttributeImpl.h lib/IR/Attributes.cpp
Bill Wendling
isanbard at gmail.com
Wed Jan 2 17:43:06 PST 2013
Author: void
Date: Wed Jan 2 19:43:05 2013
New Revision: 171442
URL: http://llvm.org/viewvc/llvm-project?rev=171442&view=rev
Log:
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.
Modified:
llvm/trunk/include/llvm/IR/Attributes.h
llvm/trunk/lib/IR/AttributeImpl.h
llvm/trunk/lib/IR/Attributes.cpp
Modified: llvm/trunk/include/llvm/IR/Attributes.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/IR/Attributes.h?rev=171442&r1=171441&r2=171442&view=diff
==============================================================================
--- llvm/trunk/include/llvm/IR/Attributes.h (original)
+++ llvm/trunk/include/llvm/IR/Attributes.h Wed Jan 2 19:43:05 2013
@@ -179,9 +179,6 @@
/// removeAttribute - Remove the attributes from A from the builder.
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.
bool hasAttributes() const;
@@ -242,6 +239,9 @@
bool operator!=(const AttrBuilder &B) {
return Bits != B.Bits;
}
+
+ bool operator==(Attribute::AttrKind A) const;
+ bool operator!=(Attribute::AttrKind A) const;
};
//===----------------------------------------------------------------------===//
Modified: llvm/trunk/lib/IR/AttributeImpl.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/IR/AttributeImpl.h?rev=171442&r1=171441&r2=171442&view=diff
==============================================================================
--- llvm/trunk/lib/IR/AttributeImpl.h (original)
+++ llvm/trunk/lib/IR/AttributeImpl.h Wed Jan 2 19:43:05 2013
@@ -42,9 +42,6 @@
return Vals;
}
- bool contains(Attribute::AttrKind Kind) const;
- bool contains(StringRef Kind) const;
-
bool hasAttribute(Attribute::AttrKind A) const;
bool hasAttributes() const;
@@ -53,19 +50,11 @@
uint64_t getAlignment() const;
uint64_t getStackAlignment() const;
- bool operator==(Attribute::AttrKind Kind) const {
- return contains(Kind);
- }
- bool operator!=(Attribute::AttrKind Kind) const {
- return !contains(Kind);
- }
+ bool operator==(Attribute::AttrKind Kind) const;
+ bool operator!=(Attribute::AttrKind Kind) const;
- bool operator==(StringRef Kind) const {
- return contains(Kind);
- }
- bool operator!=(StringRef Kind) const {
- return !contains(Kind);
- }
+ bool operator==(StringRef Kind) const;
+ bool operator!=(StringRef Kind) const;
uint64_t getBitMask() const; // FIXME: Remove.
Modified: llvm/trunk/lib/IR/Attributes.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/IR/Attributes.cpp?rev=171442&r1=171441&r2=171442&view=diff
==============================================================================
--- llvm/trunk/lib/IR/Attributes.cpp (original)
+++ llvm/trunk/lib/IR/Attributes.cpp Wed Jan 2 19:43:05 2013
@@ -89,11 +89,11 @@
}
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 @@
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 @@
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.
More information about the llvm-commits
mailing list