Skip to content

Commit 1a0e097

Browse files
committed
Add utility function to manipulate attributes on CallSite. NFC
Summary: As per title. This will help work on the C API. Reviewers: Wallbraker, whitequark, joker.eph, echristo, rafael Subscribers: joker.eph, llvm-commits Differential Revision: http://reviews.llvm.org/D19173 llvm-svn: 267057
1 parent 6e295f2 commit 1a0e097

File tree

3 files changed

+34
-0
lines changed

3 files changed

+34
-0
lines changed

llvm/include/llvm/IR/CallSite.h

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -305,6 +305,22 @@ class CallSiteBase {
305305
CALLSITE_DELEGATE_SETTER(setAttributes(PAL));
306306
}
307307

308+
void addAttribute(unsigned i, Attribute::AttrKind attr) {
309+
CALLSITE_DELEGATE_SETTER(addAttribute(i, attr));
310+
}
311+
312+
void addAttribute(unsigned i, StringRef Kind, StringRef Value) {
313+
CALLSITE_DELEGATE_SETTER(addAttribute(i, Kind, Value));
314+
}
315+
316+
void removeAttribute(unsigned i, Attribute::AttrKind attr) {
317+
CALLSITE_DELEGATE_SETTER(removeAttribute(i, attr));
318+
}
319+
320+
void removeAttribute(unsigned i, Attribute attr) {
321+
CALLSITE_DELEGATE_SETTER(removeAttribute(i, attr));
322+
}
323+
308324
/// \brief Return true if this function has the given attribute.
309325
bool hasFnAttr(Attribute::AttrKind A) const {
310326
CALLSITE_DELEGATE_GETTER(hasFnAttr(A));

llvm/include/llvm/IR/Instructions.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1603,6 +1603,9 @@ class CallInst : public Instruction,
16031603
/// addAttribute - adds the attribute to the list of attributes.
16041604
void addAttribute(unsigned i, StringRef Kind, StringRef Value);
16051605

1606+
/// removeAttribute - removes the attribute from the list of attributes.
1607+
void removeAttribute(unsigned i, Attribute::AttrKind attr);
1608+
16061609
/// removeAttribute - removes the attribute from the list of attributes.
16071610
void removeAttribute(unsigned i, Attribute attr);
16081611

@@ -3541,6 +3544,9 @@ class InvokeInst : public TerminatorInst,
35413544
/// addAttribute - adds the attribute to the list of attributes.
35423545
void addAttribute(unsigned i, Attribute::AttrKind attr);
35433546

3547+
/// removeAttribute - removes the attribute from the list of attributes.
3548+
void removeAttribute(unsigned i, Attribute::AttrKind attr);
3549+
35443550
/// removeAttribute - removes the attribute from the list of attributes.
35453551
void removeAttribute(unsigned i, Attribute attr);
35463552

llvm/lib/IR/Instructions.cpp

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -343,6 +343,12 @@ void CallInst::addAttribute(unsigned i, StringRef Kind, StringRef Value) {
343343
setAttributes(PAL);
344344
}
345345

346+
void CallInst::removeAttribute(unsigned i, Attribute::AttrKind attr) {
347+
AttributeSet PAL = getAttributes();
348+
PAL = PAL.removeAttribute(getContext(), i, attr);
349+
setAttributes(PAL);
350+
}
351+
346352
void CallInst::removeAttribute(unsigned i, Attribute attr) {
347353
AttributeSet PAL = getAttributes();
348354
AttrBuilder B(attr);
@@ -663,6 +669,12 @@ void InvokeInst::addAttribute(unsigned i, Attribute::AttrKind attr) {
663669
setAttributes(PAL);
664670
}
665671

672+
void InvokeInst::removeAttribute(unsigned i, Attribute::AttrKind attr) {
673+
AttributeSet PAL = getAttributes();
674+
PAL = PAL.removeAttribute(getContext(), i, attr);
675+
setAttributes(PAL);
676+
}
677+
666678
void InvokeInst::removeAttribute(unsigned i, Attribute attr) {
667679
AttributeSet PAL = getAttributes();
668680
AttrBuilder B(attr);

0 commit comments

Comments
 (0)