Make the AttrListPtr object a part of the LLVMContext.

When code deletes the context, the AttributeImpls that the AttrListPtr points to
are now invalid. Therefore, instead of keeping a separate managed static for the
AttrListPtrs that's reference counted, move it into the LLVMContext and delete
it when deleting the AttributeImpls.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@168354 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Bill Wendling
2012-11-20 05:09:20 +00:00
parent 9eecb35d6b
commit 0976e00fd1
12 changed files with 103 additions and 125 deletions

View File

@ -312,21 +312,26 @@ public:
FunctionIndex = ~0U
};
private:
/// AttrList - The attributes that we are managing. This can be null to
/// represent the empty attributes list.
/// @brief The attributes that we are managing. This can be null to represent
/// the empty attributes list.
AttributeListImpl *AttrList;
/// @brief The attributes for the specified index are returned. Attributes
/// for the result are denoted with Idx = 0.
Attributes getAttributes(unsigned Idx) const;
explicit AttrListPtr(AttributeListImpl *LI) : AttrList(LI) {}
public:
AttrListPtr() : AttrList(0) {}
AttrListPtr(const AttrListPtr &P);
AttrListPtr(const AttrListPtr &P) : AttrList(P.AttrList) {}
const AttrListPtr &operator=(const AttrListPtr &RHS);
~AttrListPtr();
//===--------------------------------------------------------------------===//
// Attribute List Construction and Mutation
//===--------------------------------------------------------------------===//
/// get - Return a Attributes list with the specified parameters in it.
static AttrListPtr get(ArrayRef<AttributeWithIndex> Attrs);
static AttrListPtr get(LLVMContext &C, ArrayRef<AttributeWithIndex> Attrs);
/// addAttr - Add the specified attribute at the specified index to this
/// attribute list. Since attribute lists are immutable, this
@ -413,13 +418,6 @@ public:
const AttributeWithIndex &getSlot(unsigned Slot) const;
void dump() const;
private:
explicit AttrListPtr(AttributeListImpl *L);
/// getAttributes - The attributes for the specified index are
/// returned. Attributes for the result are denoted with Idx = 0.
Attributes getAttributes(unsigned Idx) const;
};
} // End llvm namespace