It broke many hosts to crash.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@174035
91177308-0d34-0410-b5e6-
96231b3b80d8
Attribute(AttributeImpl *A) : pImpl(A) {}
static Attribute get(LLVMContext &Context, AttrBuilder &B);
Attribute(AttributeImpl *A) : pImpl(A) {}
static Attribute get(LLVMContext &Context, AttrBuilder &B);
-
- /// \brief Return true if the attribute is present.
- bool hasAttribute(AttrKind Val) const;
public:
Attribute() : pImpl(0) {}
public:
Attribute() : pImpl(0) {}
// Attribute Accessors
//===--------------------------------------------------------------------===//
// Attribute Accessors
//===--------------------------------------------------------------------===//
+ /// \brief Return true if the attribute is present.
+ bool hasAttribute(AttrKind Val) const;
+
+ /// \brief Return true if attributes exist
+ bool hasAttributes() const;
+
/// \brief Return the kind of this attribute.
Constant *getAttributeKind() const;
/// \brief Return the kind of this attribute.
Constant *getAttributeKind() const;
AttributeImpl(LLVMContext &C, StringRef data);
bool hasAttribute(Attribute::AttrKind A) const;
AttributeImpl(LLVMContext &C, StringRef data);
bool hasAttribute(Attribute::AttrKind A) const;
+ bool hasAttributes() const;
Constant *getAttributeKind() const { return Kind; }
ArrayRef<Constant*> getAttributeValues() const { return Vals; }
Constant *getAttributeKind() const { return Kind; }
ArrayRef<Constant*> getAttributeValues() const { return Vals; }
return pImpl && pImpl->hasAttribute(Val);
}
return pImpl && pImpl->hasAttribute(Val);
}
+bool Attribute::hasAttributes() const {
+ return pImpl && pImpl->hasAttributes();
+}
+
Constant *Attribute::getAttributeKind() const {
return pImpl ? pImpl->getAttributeKind() : 0;
}
Constant *Attribute::getAttributeKind() const {
return pImpl ? pImpl->getAttributeKind() : 0;
}
}
bool Attribute::operator==(AttrKind K) 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);
}
bool Attribute::operator!=(AttrKind K) const {
return !(*this == K);
return (Raw() & getAttrMask(A)) != 0;
}
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);
uint64_t AttributeImpl::getAlignment() const {
uint64_t Mask = Raw() & getAttrMask(Attribute::Alignment);
return 1ULL << ((Mask >> 16) - 1);
bool AttributeSetNode::hasAttribute(Attribute::AttrKind Kind) const {
for (SmallVectorImpl<Attribute>::const_iterator I = AttrList.begin(),
E = AttrList.end(); I != E; ++I)
bool AttributeSetNode::hasAttribute(Attribute::AttrKind Kind) const {
for (SmallVectorImpl<Attribute>::const_iterator I = AttrList.begin(),
E = AttrList.end(); I != E; ++I)
+ if (I->hasAttribute(Kind))
return true;
return false;
}
return true;
return false;
}
unsigned AttributeSetNode::getAlignment() const {
for (SmallVectorImpl<Attribute>::const_iterator I = AttrList.begin(),
E = AttrList.end(); I != E; ++I)
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;
}
return I->getAlignment();
return 0;
}
unsigned AttributeSetNode::getStackAlignment() const {
for (SmallVectorImpl<Attribute>::const_iterator I = AttrList.begin(),
E = AttrList.end(); I != E; ++I)
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;
}
return I->getStackAlignment();
return 0;
}
for (unsigned i = 0, e = Attrs.size(); i != e; ++i) {
assert((!i || Attrs[i-1].first <= Attrs[i].first) &&
"Misordered Attributes list!");
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
"Pointless attribute!");
}
#endif
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)
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->hasAttribute(Attr))
return true;
return false;
return true;
return false;