From 3ffbac4432012fdf7a3cd28790b76afb2fc51944 Mon Sep 17 00:00:00 2001 From: Bill Wendling Date: Tue, 16 Oct 2012 05:55:09 +0000 Subject: [PATCH] Have AttrBuilder defriend the Attributes class. llvm-svn: 166011 --- llvm/include/llvm/Attributes.h | 3 ++- llvm/lib/VMCore/Attributes.cpp | 6 +++--- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/llvm/include/llvm/Attributes.h b/llvm/include/llvm/Attributes.h index aac5d9e..3452775 100644 --- a/llvm/include/llvm/Attributes.h +++ b/llvm/include/llvm/Attributes.h @@ -192,7 +192,6 @@ public: /// Builder's value, however, is not. So this can be used as a quick way to test /// for equality, presence of attributes, etc. class AttrBuilder { - friend class Attributes; uint64_t Bits; public: AttrBuilder() : Bits(0) {} @@ -267,6 +266,8 @@ public: .removeAttribute(Attributes::AddressSafety); } + uint64_t Raw() const { return Bits; } + bool operator==(const AttrBuilder &B) { return Bits == B.Bits; } diff --git a/llvm/lib/VMCore/Attributes.cpp b/llvm/lib/VMCore/Attributes.cpp index f028fd3..393eab0e 100644 --- a/llvm/lib/VMCore/Attributes.cpp +++ b/llvm/lib/VMCore/Attributes.cpp @@ -38,13 +38,13 @@ Attributes Attributes::get(LLVMContext &Context, ArrayRef Vals) { Attributes Attributes::get(LLVMContext &Context, AttrBuilder &B) { // If there are no attributes, return an empty Attributes class. - if (B.Bits == 0) + if (!B.hasAttributes()) return Attributes(); // Otherwise, build a key to look up the existing attributes. LLVMContextImpl *pImpl = Context.pImpl; FoldingSetNodeID ID; - ID.AddInteger(B.Bits); + ID.AddInteger(B.Raw()); void *InsertPoint; AttributesImpl *PA = pImpl->AttrsSet.FindNodeOrInsertPos(ID, InsertPoint); @@ -52,7 +52,7 @@ Attributes Attributes::get(LLVMContext &Context, AttrBuilder &B) { if (!PA) { // If we didn't find any existing attributes of the same shape then create a // new one and insert it. - PA = new AttributesImpl(B.Bits); + PA = new AttributesImpl(B.Raw()); pImpl->AttrsSet.InsertNode(PA, InsertPoint); } -- 2.7.4