Don't add an attribute that already exists and don't remove an attribute that doesn't exist.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@176289 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Bill Wendling 2013-02-28 19:17:40 +00:00
parent a6ca703693
commit 1abc00b6d1

View File

@ -645,6 +645,7 @@ AttributeSet AttributeSet::get(LLVMContext &C, ArrayRef<AttributeSet> Attrs) {
AttributeSet AttributeSet::addAttribute(LLVMContext &C, unsigned Idx,
Attribute::AttrKind Attr) const {
if (hasAttribute(Idx, Attr)) return *this;
return addAttributes(C, Idx, AttributeSet::get(C, Idx, Attr));
}
@ -699,6 +700,7 @@ AttributeSet AttributeSet::addAttributes(LLVMContext &C, unsigned Idx,
AttributeSet AttributeSet::removeAttribute(LLVMContext &C, unsigned Idx,
Attribute::AttrKind Attr) const {
if (!hasAttribute(Idx, Attr)) return *this;
return removeAttributes(C, Idx, AttributeSet::get(C, Idx, Attr));
}