[llvm-commits] [llvm] r165923 - in /llvm/trunk: include/llvm/Attributes.h lib/VMCore/Attributes.cpp
Bill Wendling
isanbard at gmail.com
Sun Oct 14 23:53:28 PDT 2012
Author: void
Date: Mon Oct 15 01:53:28 2012
New Revision: 165923
URL: http://llvm.org/viewvc/llvm-project?rev=165923&view=rev
Log:
Use a ::get method to create the attribute from Attributes::AttrVals instead of a constructor.
Modified:
llvm/trunk/include/llvm/Attributes.h
llvm/trunk/lib/VMCore/Attributes.cpp
Modified: llvm/trunk/include/llvm/Attributes.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Attributes.h?rev=165923&r1=165922&r2=165923&view=diff
==============================================================================
--- llvm/trunk/include/llvm/Attributes.h (original)
+++ llvm/trunk/include/llvm/Attributes.h Mon Oct 15 01:53:28 2012
@@ -89,17 +89,26 @@
};
private:
AttributesImpl *Attrs;
-
- explicit Attributes(AttributesImpl *A);
+ Attributes(AttributesImpl *A);
public:
Attributes() : Attrs(0) {}
- explicit Attributes(LLVMContext &C, ArrayRef<AttrVal> Vals);
Attributes(const Attributes &A);
Attributes &operator=(const Attributes &A) {
Attrs = A.Attrs;
return *this;
}
+ /// get - Return a uniquified Attributes object. This takes the uniquified
+ /// value from the Builder and wraps it in the Attributes class.
+ class Builder;
+ static Attributes get(LLVMContext &Context, ArrayRef<AttrVal> Vals);
+ 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;
@@ -122,6 +131,9 @@
Builder &addAttribute(Attributes::AttrVal Val);
Builder &removeAttribute(Attributes::AttrVal Val);
+ Builder &addAttributes(const Attributes &A);
+ Builder &removeAttributes(const Attributes &A);
+
/// addRawValue - Add the raw value to the internal representation. This
/// should be used ONLY for decoding bitcode!
Builder &addRawValue(uint64_t Val);
@@ -134,9 +146,6 @@
/// a power of 2) into the form used internally in Attributes.
Builder &addStackAlignmentAttr(unsigned Align);
- Builder &addAttributes(const Attributes &A);
- Builder &removeAttributes(const Attributes &A);
-
/// @brief Remove attributes that are used on functions only.
void removeFunctionOnlyAttrs() {
removeAttribute(Attributes::NoReturn)
@@ -167,10 +176,6 @@
}
};
- /// get - Return a uniquified Attributes object. This takes the uniquified
- /// value from the Builder and wraps it in the Attributes class.
- static Attributes get(LLVMContext &Context, Builder &B);
-
/// @brief Return true if the attribute is present.
bool hasAttribute(AttrVal Val) const;
@@ -224,10 +229,10 @@
hasAttribute(Attributes::AddressSafety);
}
- bool operator == (const Attributes &A) const {
+ bool operator==(const Attributes &A) const {
return Attrs == A.Attrs;
}
- bool operator != (const Attributes &A) const {
+ bool operator!=(const Attributes &A) const {
return Attrs != A.Attrs;
}
Modified: llvm/trunk/lib/VMCore/Attributes.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/VMCore/Attributes.cpp?rev=165923&r1=165922&r2=165923&view=diff
==============================================================================
--- llvm/trunk/lib/VMCore/Attributes.cpp (original)
+++ llvm/trunk/lib/VMCore/Attributes.cpp Mon Oct 15 01:53:28 2012
@@ -28,18 +28,18 @@
// Attributes Implementation
//===----------------------------------------------------------------------===//
-Attributes::Attributes(LLVMContext &C, ArrayRef<AttrVal> Vals) {
+Attributes::Attributes(AttributesImpl *A) : Attrs(A) {}
+
+Attributes::Attributes(const Attributes &A) : Attrs(A.Attrs) {}
+
+Attributes Attributes::get(LLVMContext &Context, ArrayRef<AttrVal> Vals) {
Attributes::Builder B;
for (ArrayRef<AttrVal>::iterator I = Vals.begin(), E = Vals.end();
I != E; ++I)
B.addAttribute(*I);
- Attrs = Attributes::get(C, B).Attrs;
+ return Attributes::get(Context, B);
}
-Attributes::Attributes(AttributesImpl *A) : Attrs(A) {}
-
-Attributes::Attributes(const Attributes &A) : Attrs(A.Attrs) {}
-
Attributes Attributes::get(LLVMContext &Context, Attributes::Builder &B) {
// If there are no attributes, return an empty Attributes class.
if (B.Bits == 0)
@@ -186,8 +186,7 @@
// Attributes::Builder Implementation
//===----------------------------------------------------------------------===//
-Attributes::Builder &Attributes::Builder::
-addAttribute(Attributes::AttrVal Val) {
+Attributes::Builder &Attributes::Builder::addAttribute(Attributes::AttrVal Val){
Bits |= AttributesImpl::getAttrMask(Val);
return *this;
}
More information about the llvm-commits
mailing list