Add a way to add a kind-value string pair to an attribute.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@187138 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Bill Wendling 2013-07-25 18:34:24 +00:00
parent 4c9d299d80
commit 9e2ef7780b
3 changed files with 14 additions and 0 deletions

View File

@ -250,6 +250,8 @@ public:
/// attribute sets are immutable, this returns a new set.
AttributeSet addAttribute(LLVMContext &C, unsigned Index,
StringRef Kind) const;
AttributeSet addAttribute(LLVMContext &C, unsigned Index,
StringRef Kind, StringRef Value) const;
/// \brief Add attributes to the attribute set at the given index. Since
/// attribute sets are immutable, this returns a new set.

View File

@ -190,6 +190,11 @@ public:
AttributeSets.addAttribute(getContext(),
AttributeSet::FunctionIndex, Kind));
}
void addFnAttr(StringRef Kind, StringRef Value) {
setAttributes(
AttributeSets.addAttribute(getContext(),
AttributeSet::FunctionIndex, Kind, Value));
}
/// @brief Return true if the function has the attribute.
bool hasFnAttribute(Attribute::AttrKind Kind) const {

View File

@ -645,6 +645,13 @@ AttributeSet AttributeSet::addAttribute(LLVMContext &C, unsigned Index,
return addAttributes(C, Index, AttributeSet::get(C, Index, B));
}
AttributeSet AttributeSet::addAttribute(LLVMContext &C, unsigned Index,
StringRef Kind, StringRef Value) const {
llvm::AttrBuilder B;
B.addAttribute(Kind, Value);
return addAttributes(C, Index, AttributeSet::get(C, Index, B));
}
AttributeSet AttributeSet::addAttributes(LLVMContext &C, unsigned Index,
AttributeSet Attrs) const {
if (!pImpl) return Attrs;