summaryrefslogtreecommitdiffstats
path: root/llvm/lib/IR/Function.cpp
diff options
context:
space:
mode:
authorReid Kleckner <rnk@google.com>2017-04-19 17:28:52 +0000
committerReid Kleckner <rnk@google.com>2017-04-19 17:28:52 +0000
commit9d16fa09c6827c5baffe2b2a470443f6c9cc560a (patch)
tree3e591471d0c6a3ca9707a372a4d5595aa0c2f32b /llvm/lib/IR/Function.cpp
parentffcb4df2042d314651bdf1842c3b1f1dd24aef85 (diff)
downloadbcm5719-llvm-9d16fa09c6827c5baffe2b2a470443f6c9cc560a.tar.gz
bcm5719-llvm-9d16fa09c6827c5baffe2b2a470443f6c9cc560a.zip
Prefer addAttr(Attribute::AttrKind) over the AttributeList overload
This should simplify the call sites, which typically want to tweak one attribute at a time. It should also avoid creating ephemeral AttributeLists that live forever. llvm-svn: 300718
Diffstat (limited to 'llvm/lib/IR/Function.cpp')
-rw-r--r--llvm/lib/IR/Function.cpp23
1 files changed, 16 insertions, 7 deletions
diff --git a/llvm/lib/IR/Function.cpp b/llvm/lib/IR/Function.cpp
index c4bb9e83acd..e1f5fdea44e 100644
--- a/llvm/lib/IR/Function.cpp
+++ b/llvm/lib/IR/Function.cpp
@@ -138,13 +138,18 @@ bool Argument::onlyReadsMemory() const {
Attrs.hasParamAttribute(getArgNo(), Attribute::ReadNone);
}
-void Argument::addAttr(AttributeList AS) {
- assert(AS.getNumSlots() <= 1 &&
- "Trying to add more than one attribute set to an argument!");
- AttrBuilder B(AS, AS.getSlotIndex(0));
- getParent()->addAttributes(
- getArgNo() + 1,
- AttributeList::get(Parent->getContext(), getArgNo() + 1, B));
+void Argument::addAttrs(AttrBuilder &B) {
+ AttributeList AL = getParent()->getAttributes();
+ AL = AL.addAttributes(Parent->getContext(), getArgNo() + 1, B);
+ getParent()->setAttributes(AL);
+}
+
+void Argument::addAttr(Attribute::AttrKind Kind) {
+ getParent()->addAttribute(getArgNo() + 1, Kind);
+}
+
+void Argument::addAttr(Attribute Attr) {
+ getParent()->addAttribute(getArgNo() + 1, Attr);
}
void Argument::removeAttr(AttributeList AS) {
@@ -156,6 +161,10 @@ void Argument::removeAttr(AttributeList AS) {
AttributeList::get(Parent->getContext(), getArgNo() + 1, B));
}
+void Argument::removeAttr(Attribute::AttrKind Kind) {
+ getParent()->removeAttribute(getArgNo() + 1, Kind);
+}
+
bool Argument::hasAttribute(Attribute::AttrKind Kind) const {
return getParent()->hasParamAttribute(getArgNo(), Kind);
}
OpenPOWER on IntegriCloud