forked from OSchip/llvm-project
Add functions for adding and testing string attributes to CallInst. NFC.
This change is needed later when I make changes to attach string function attributes to llvm.trap and llvm.debugtrap. llvm-svn: 241304
This commit is contained in:
parent
a68d90fa52
commit
5c40eeabef
|
@ -22,6 +22,7 @@
|
||||||
#include "llvm/IR/Attributes.h"
|
#include "llvm/IR/Attributes.h"
|
||||||
#include "llvm/IR/CallingConv.h"
|
#include "llvm/IR/CallingConv.h"
|
||||||
#include "llvm/IR/DerivedTypes.h"
|
#include "llvm/IR/DerivedTypes.h"
|
||||||
|
#include "llvm/IR/Function.h"
|
||||||
#include "llvm/IR/InstrTypes.h"
|
#include "llvm/IR/InstrTypes.h"
|
||||||
#include "llvm/Support/ErrorHandling.h"
|
#include "llvm/Support/ErrorHandling.h"
|
||||||
#include <iterator>
|
#include <iterator>
|
||||||
|
@ -1508,6 +1509,9 @@ public:
|
||||||
/// addAttribute - adds the attribute to the list of attributes.
|
/// addAttribute - adds the attribute to the list of attributes.
|
||||||
void addAttribute(unsigned i, Attribute::AttrKind attr);
|
void addAttribute(unsigned i, Attribute::AttrKind attr);
|
||||||
|
|
||||||
|
/// addAttribute - adds the attribute to the list of attributes.
|
||||||
|
void addAttribute(unsigned i, StringRef Kind, StringRef Value);
|
||||||
|
|
||||||
/// removeAttribute - removes the attribute from the list of attributes.
|
/// removeAttribute - removes the attribute from the list of attributes.
|
||||||
void removeAttribute(unsigned i, Attribute attr);
|
void removeAttribute(unsigned i, Attribute attr);
|
||||||
|
|
||||||
|
@ -1525,6 +1529,11 @@ public:
|
||||||
return hasFnAttrImpl(A);
|
return hasFnAttrImpl(A);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// \brief Determine whether this call has the given attribute.
|
||||||
|
bool hasFnAttr(StringRef A) const {
|
||||||
|
return hasFnAttrImpl(A);
|
||||||
|
}
|
||||||
|
|
||||||
/// \brief Determine whether the call or the callee has the given attributes.
|
/// \brief Determine whether the call or the callee has the given attributes.
|
||||||
bool paramHasAttr(unsigned i, Attribute::AttrKind A) const;
|
bool paramHasAttr(unsigned i, Attribute::AttrKind A) const;
|
||||||
|
|
||||||
|
@ -1651,7 +1660,14 @@ public:
|
||||||
}
|
}
|
||||||
private:
|
private:
|
||||||
|
|
||||||
bool hasFnAttrImpl(Attribute::AttrKind A) const;
|
template<typename AttrKind>
|
||||||
|
bool hasFnAttrImpl(AttrKind A) const {
|
||||||
|
if (AttributeList.hasAttribute(AttributeSet::FunctionIndex, A))
|
||||||
|
return true;
|
||||||
|
if (const Function *F = getCalledFunction())
|
||||||
|
return F->getAttributes().hasAttribute(AttributeSet::FunctionIndex, A);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
// Shadow Instruction::setInstructionSubclassData with a private forwarding
|
// Shadow Instruction::setInstructionSubclassData with a private forwarding
|
||||||
// method so that subclasses cannot accidentally use it.
|
// method so that subclasses cannot accidentally use it.
|
||||||
|
|
|
@ -292,6 +292,12 @@ void CallInst::addAttribute(unsigned i, Attribute::AttrKind attr) {
|
||||||
setAttributes(PAL);
|
setAttributes(PAL);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void CallInst::addAttribute(unsigned i, StringRef Kind, StringRef Value) {
|
||||||
|
AttributeSet PAL = getAttributes();
|
||||||
|
PAL = PAL.addAttribute(getContext(), i, Kind, Value);
|
||||||
|
setAttributes(PAL);
|
||||||
|
}
|
||||||
|
|
||||||
void CallInst::removeAttribute(unsigned i, Attribute attr) {
|
void CallInst::removeAttribute(unsigned i, Attribute attr) {
|
||||||
AttributeSet PAL = getAttributes();
|
AttributeSet PAL = getAttributes();
|
||||||
AttrBuilder B(attr);
|
AttrBuilder B(attr);
|
||||||
|
@ -313,14 +319,6 @@ void CallInst::addDereferenceableOrNullAttr(unsigned i, uint64_t Bytes) {
|
||||||
setAttributes(PAL);
|
setAttributes(PAL);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool CallInst::hasFnAttrImpl(Attribute::AttrKind A) const {
|
|
||||||
if (AttributeList.hasAttribute(AttributeSet::FunctionIndex, A))
|
|
||||||
return true;
|
|
||||||
if (const Function *F = getCalledFunction())
|
|
||||||
return F->getAttributes().hasAttribute(AttributeSet::FunctionIndex, A);
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool CallInst::paramHasAttr(unsigned i, Attribute::AttrKind A) const {
|
bool CallInst::paramHasAttr(unsigned i, Attribute::AttrKind A) const {
|
||||||
if (AttributeList.hasAttribute(i, A))
|
if (AttributeList.hasAttribute(i, A))
|
||||||
return true;
|
return true;
|
||||||
|
|
Loading…
Reference in New Issue