/// 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) {}
.removeAttribute(Attributes::AddressSafety);
}
+ uint64_t Raw() const { return Bits; }
+
bool operator==(const AttrBuilder &B) {
return Bits == B.Bits;
}
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);
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);
}