1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2024-11-24 03:33:20 +01:00

Have AttrBuilder defriend the Attributes class.

llvm-svn: 166011
This commit is contained in:
Bill Wendling 2012-10-16 05:55:09 +00:00
parent 17275364ed
commit bd68badfdd
2 changed files with 5 additions and 4 deletions

View File

@ -192,7 +192,6 @@ public:
/// Builder's value, however, is not. So this can be used as a quick way to test /// Builder's value, however, is not. So this can be used as a quick way to test
/// for equality, presence of attributes, etc. /// for equality, presence of attributes, etc.
class AttrBuilder { class AttrBuilder {
friend class Attributes;
uint64_t Bits; uint64_t Bits;
public: public:
AttrBuilder() : Bits(0) {} AttrBuilder() : Bits(0) {}
@ -267,6 +266,8 @@ public:
.removeAttribute(Attributes::AddressSafety); .removeAttribute(Attributes::AddressSafety);
} }
uint64_t Raw() const { return Bits; }
bool operator==(const AttrBuilder &B) { bool operator==(const AttrBuilder &B) {
return Bits == B.Bits; return Bits == B.Bits;
} }

View File

@ -38,13 +38,13 @@ Attributes Attributes::get(LLVMContext &Context, ArrayRef<AttrVal> Vals) {
Attributes Attributes::get(LLVMContext &Context, AttrBuilder &B) { Attributes Attributes::get(LLVMContext &Context, AttrBuilder &B) {
// If there are no attributes, return an empty Attributes class. // If there are no attributes, return an empty Attributes class.
if (B.Bits == 0) if (!B.hasAttributes())
return Attributes(); return Attributes();
// Otherwise, build a key to look up the existing attributes. // Otherwise, build a key to look up the existing attributes.
LLVMContextImpl *pImpl = Context.pImpl; LLVMContextImpl *pImpl = Context.pImpl;
FoldingSetNodeID ID; FoldingSetNodeID ID;
ID.AddInteger(B.Bits); ID.AddInteger(B.Raw());
void *InsertPoint; void *InsertPoint;
AttributesImpl *PA = pImpl->AttrsSet.FindNodeOrInsertPos(ID, InsertPoint); AttributesImpl *PA = pImpl->AttrsSet.FindNodeOrInsertPos(ID, InsertPoint);
@ -52,7 +52,7 @@ Attributes Attributes::get(LLVMContext &Context, AttrBuilder &B) {
if (!PA) { if (!PA) {
// If we didn't find any existing attributes of the same shape then create a // If we didn't find any existing attributes of the same shape then create a
// new one and insert it. // new one and insert it.
PA = new AttributesImpl(B.Bits); PA = new AttributesImpl(B.Raw());
pImpl->AttrsSet.InsertNode(PA, InsertPoint); pImpl->AttrsSet.InsertNode(PA, InsertPoint);
} }