diff options
author | Bill Wendling <isanbard@gmail.com> | 2013-02-28 19:17:40 +0000 |
---|---|---|
committer | Bill Wendling <isanbard@gmail.com> | 2013-02-28 19:17:40 +0000 |
commit | 1abc00b6d18b1a81548e52783fbccd1c59ebf968 (patch) | |
tree | 20f95fcc8301750a02bc7428c45833c282018a3b /lib | |
parent | a6ca70369366d549f104ee72822c6f591ea0ece0 (diff) |
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
Diffstat (limited to 'lib')
-rw-r--r-- | lib/IR/Attributes.cpp | 2 |
1 files changed, 2 insertions, 0 deletions
diff --git a/lib/IR/Attributes.cpp b/lib/IR/Attributes.cpp index 6eb51f0edc..ed2bf05e90 100644 --- a/lib/IR/Attributes.cpp +++ b/lib/IR/Attributes.cpp @@ -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)); } |