- static Attributes get(LLVMContext &Context, Builder &B);
-
- //===--------------------------------------------------------------------===//
- /// Attributes::Builder - This class is used in conjunction with the
- /// Attributes::get method to create an Attributes object. The object itself
- /// is uniquified. The Builder's value, however, is not. So this can be used
- /// as a quick way to test for equality, presence of attributes, etc.
- class Builder {
- friend class Attributes;
- uint64_t Bits;
- public:
- Builder() : Bits(0) {}
- explicit Builder(uint64_t B) : Bits(B) {}
- Builder(const Attributes &A) : Bits(A.Raw()) {}
- Builder(const Builder &B) : Bits(B.Bits) {}
-
- void clear() { Bits = 0; }
-
- /// addAttribute - Add an attribute to the builder.
- Builder &addAttribute(Attributes::AttrVal Val);
-
- /// removeAttribute - Remove an attribute from the builder.
- Builder &removeAttribute(Attributes::AttrVal Val);
-
- /// addAttribute - Add the attributes from A to the builder.
- Builder &addAttributes(const Attributes &A);
-
- /// removeAttribute - Remove the attributes from A from the builder.
- Builder &removeAttributes(const Attributes &A);
-
- /// hasAttribute - Return true if the builder has the specified attribute.
- bool hasAttribute(Attributes::AttrVal A) const;
-
- /// hasAttributes - Return true if the builder has IR-level attributes.
- bool hasAttributes() const;
-
- /// hasAttributes - Return true if the builder has any attribute that's in
- /// the specified attribute.
- bool hasAttributes(const Attributes &A) const;
-
- /// hasAlignmentAttr - Return true if the builder has an alignment
- /// attribute.
- bool hasAlignmentAttr() const;
-
- /// getAlignment - Retrieve the alignment attribute, if it exists.
- uint64_t getAlignment() const;
-
- /// getStackAlignment - Retrieve the stack alignment attribute, if it
- /// exists.
- uint64_t getStackAlignment() const;
-
- /// addAlignmentAttr - This turns an int alignment (which must be a power of
- /// 2) into the form used internally in Attributes.
- Builder &addAlignmentAttr(unsigned Align);
-
- /// addStackAlignmentAttr - This turns an int stack alignment (which must be
- /// a power of 2) into the form used internally in Attributes.
- Builder &addStackAlignmentAttr(unsigned Align);
-
- /// addRawValue - Add the raw value to the internal representation.
- /// N.B. This should be used ONLY for decoding LLVM bitcode!
- Builder &addRawValue(uint64_t Val);
-
- /// @brief Remove attributes that are used on functions only.
- void removeFunctionOnlyAttrs() {
- removeAttribute(Attributes::NoReturn)
- .removeAttribute(Attributes::NoUnwind)
- .removeAttribute(Attributes::ReadNone)
- .removeAttribute(Attributes::ReadOnly)
- .removeAttribute(Attributes::NoInline)
- .removeAttribute(Attributes::AlwaysInline)
- .removeAttribute(Attributes::OptimizeForSize)
- .removeAttribute(Attributes::StackProtect)
- .removeAttribute(Attributes::StackProtectReq)
- .removeAttribute(Attributes::NoRedZone)
- .removeAttribute(Attributes::NoImplicitFloat)
- .removeAttribute(Attributes::Naked)
- .removeAttribute(Attributes::InlineHint)
- .removeAttribute(Attributes::StackAlignment)
- .removeAttribute(Attributes::UWTable)
- .removeAttribute(Attributes::NonLazyBind)
- .removeAttribute(Attributes::ReturnsTwice)
- .removeAttribute(Attributes::AddressSafety);
- }
-
- bool operator==(const Builder &B) {
- return Bits == B.Bits;
- }
- bool operator!=(const Builder &B) {
- return Bits != B.Bits;
- }
- };