The getter was equivalent to AttributeList::getAttributes(unsigned),
which seems like a better way to express getting the AttributeSet for a
given index. This static helper was only used in one place anyway.
The constructor doesn't benefit from inlining and doesn't need to be in
a header.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@299900
91177308-0d34-0410-b5e6-
96231b3b80d8
/// Bitset with a bit for each available attribute Attribute::AttrKind.
uint64_t AvailableAttrs;
- AttributeSetNode(ArrayRef<Attribute> Attrs)
- : NumAttrs(Attrs.size()), AvailableAttrs(0) {
- static_assert(Attribute::EndAttrKinds <= sizeof(AvailableAttrs) * CHAR_BIT,
- "Too many attributes for AvailableAttrs");
- // There's memory after the node where we can store the entries in.
- std::copy(Attrs.begin(), Attrs.end(), getTrailingObjects<Attribute>());
-
- for (Attribute I : *this) {
- if (!I.isStringAttribute()) {
- AvailableAttrs |= ((uint64_t)1) << I.getKindAsEnum();
- }
- }
- }
+ AttributeSetNode(ArrayRef<Attribute> Attrs);
public:
// AttributesSetNode is uniqued, these should not be available.
static AttributeSetNode *get(LLVMContext &C, ArrayRef<Attribute> Attrs);
- static AttributeSetNode *get(AttributeList AS, unsigned Index) {
- return AS.getAttributes(Index);
- }
-
/// \brief Return the number of attributes this AttributeList contains.
unsigned getNumAttributes() const { return NumAttrs; }
// AttributeSetNode Definition
//===----------------------------------------------------------------------===//
+AttributeSetNode::AttributeSetNode(ArrayRef<Attribute> Attrs)
+ : NumAttrs(Attrs.size()), AvailableAttrs(0) {
+ static_assert(Attribute::EndAttrKinds <= sizeof(AvailableAttrs) * CHAR_BIT,
+ "Too many attributes for AvailableAttrs");
+ // There's memory after the node where we can store the entries in.
+ std::copy(Attrs.begin(), Attrs.end(), getTrailingObjects<Attribute>());
+
+ for (Attribute I : *this) {
+ if (!I.isStringAttribute()) {
+ AvailableAttrs |= ((uint64_t)1) << I.getKindAsEnum();
+ }
+ }
+}
+
AttributeSetNode *AttributeSetNode::get(LLVMContext &C,
ArrayRef<Attribute> Attrs) {
if (Attrs.empty())
}
unsigned LLVMGetAttributeCountAtIndex(LLVMValueRef F, LLVMAttributeIndex Idx) {
- auto *ASN = AttributeSetNode::get(unwrap<Function>(F)->getAttributes(), Idx);
+ auto *ASN = unwrap<Function>(F)->getAttributes().getAttributes(Idx);
if (!ASN)
return 0;
return ASN->getNumAttributes();
void LLVMGetAttributesAtIndex(LLVMValueRef F, LLVMAttributeIndex Idx,
LLVMAttributeRef *Attrs) {
- auto *ASN = AttributeSetNode::get(unwrap<Function>(F)->getAttributes(), Idx);
+ auto *ASN = unwrap<Function>(F)->getAttributes().getAttributes(Idx);
if (!ASN)
return;
for (auto A: make_range(ASN->begin(), ASN->end()))
unsigned LLVMGetCallSiteAttributeCount(LLVMValueRef C,
LLVMAttributeIndex Idx) {
auto CS = CallSite(unwrap<Instruction>(C));
- auto *ASN = AttributeSetNode::get(CS.getAttributes(), Idx);
+ auto *ASN = CS.getAttributes().getAttributes(Idx);
if (!ASN)
return 0;
return ASN->getNumAttributes();
void LLVMGetCallSiteAttributes(LLVMValueRef C, LLVMAttributeIndex Idx,
LLVMAttributeRef *Attrs) {
auto CS = CallSite(unwrap<Instruction>(C));
- auto *ASN = AttributeSetNode::get(CS.getAttributes(), Idx);
+ auto *ASN = CS.getAttributes().getAttributes(Idx);
if (!ASN)
return;
for (auto A: make_range(ASN->begin(), ASN->end()))