aboutsummaryrefslogtreecommitdiff
path: root/lib/IR/Attributes.cpp
diff options
context:
space:
mode:
authorNAKAMURA Takumi <geek4civic@gmail.com>2013-01-31 03:47:28 +0000
committerNAKAMURA Takumi <geek4civic@gmail.com>2013-01-31 03:47:28 +0000
commiteddab1550ee10cce3bb26a26e88529cb19451aa3 (patch)
treeeb36418a256549a4f275e0509ecda0a75a8ce321 /lib/IR/Attributes.cpp
parent3e3de565e9c7258fb97773b3a64fc091355cb2de (diff)
Revert r174026, "Remove Attribute::hasAttributes() and make Attribute::hasAttribute() private."
It broke many hosts to crash. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@174035 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/IR/Attributes.cpp')
-rw-r--r--lib/IR/Attributes.cpp20
1 files changed, 14 insertions, 6 deletions
diff --git a/lib/IR/Attributes.cpp b/lib/IR/Attributes.cpp
index 2c84a3d13f..98c12b5d85 100644
--- a/lib/IR/Attributes.cpp
+++ b/lib/IR/Attributes.cpp
@@ -82,6 +82,10 @@ bool Attribute::hasAttribute(AttrKind Val) const {
return pImpl && pImpl->hasAttribute(Val);
}
+bool Attribute::hasAttributes() const {
+ return pImpl && pImpl->hasAttributes();
+}
+
Constant *Attribute::getAttributeKind() const {
return pImpl ? pImpl->getAttributeKind() : 0;
}
@@ -181,7 +185,7 @@ std::string Attribute::getAsString() const {
}
bool Attribute::operator==(AttrKind K) const {
- return (pImpl && *pImpl == K) || (!pImpl && K == None);
+ return pImpl && *pImpl == K;
}
bool Attribute::operator!=(AttrKind K) const {
return !(*this == K);
@@ -222,6 +226,10 @@ bool AttributeImpl::hasAttribute(Attribute::AttrKind A) const {
return (Raw() & getAttrMask(A)) != 0;
}
+bool AttributeImpl::hasAttributes() const {
+ return Raw() != 0;
+}
+
uint64_t AttributeImpl::getAlignment() const {
uint64_t Mask = Raw() & getAttrMask(Attribute::Alignment);
return 1ULL << ((Mask >> 16) - 1);
@@ -361,7 +369,7 @@ AttributeSetNode *AttributeSetNode::get(LLVMContext &C,
bool AttributeSetNode::hasAttribute(Attribute::AttrKind Kind) const {
for (SmallVectorImpl<Attribute>::const_iterator I = AttrList.begin(),
E = AttrList.end(); I != E; ++I)
- if (*I == Kind)
+ if (I->hasAttribute(Kind))
return true;
return false;
}
@@ -369,7 +377,7 @@ bool AttributeSetNode::hasAttribute(Attribute::AttrKind Kind) const {
unsigned AttributeSetNode::getAlignment() const {
for (SmallVectorImpl<Attribute>::const_iterator I = AttrList.begin(),
E = AttrList.end(); I != E; ++I)
- if (*I == Attribute::Alignment)
+ if (I->hasAttribute(Attribute::Alignment))
return I->getAlignment();
return 0;
}
@@ -377,7 +385,7 @@ unsigned AttributeSetNode::getAlignment() const {
unsigned AttributeSetNode::getStackAlignment() const {
for (SmallVectorImpl<Attribute>::const_iterator I = AttrList.begin(),
E = AttrList.end(); I != E; ++I)
- if (*I == Attribute::StackAlignment)
+ if (I->hasAttribute(Attribute::StackAlignment))
return I->getStackAlignment();
return 0;
}
@@ -446,7 +454,7 @@ AttributeSet AttributeSet::get(LLVMContext &C,
for (unsigned i = 0, e = Attrs.size(); i != e; ++i) {
assert((!i || Attrs[i-1].first <= Attrs[i].first) &&
"Misordered Attributes list!");
- assert(Attrs[i].second != Attribute::None &&
+ assert(Attrs[i].second.hasAttributes() &&
"Pointless attribute!");
}
#endif
@@ -674,7 +682,7 @@ bool AttributeSet::hasAttrSomewhere(Attribute::AttrKind Attr) const {
for (unsigned I = 0, E = pImpl->getNumAttributes(); I != E; ++I)
for (AttributeSetImpl::const_iterator II = pImpl->begin(I),
IE = pImpl->end(I); II != IE; ++II)
- if (*II == Attr)
+ if (II->hasAttribute(Attr))
return true;
return false;