Remove the bitwise OR operator from the Attributes class. Replace it with the equival...
authorBill Wendling <isanbard@gmail.com>
Sun, 14 Oct 2012 07:17:34 +0000 (07:17 +0000)
committerBill Wendling <isanbard@gmail.com>
Sun, 14 Oct 2012 07:17:34 +0000 (07:17 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@165894 91177308-0d34-0410-b5e6-96231b3b80d8

include/llvm/Attributes.h
lib/VMCore/Attributes.cpp

index c8f723a7dcffe43c3129bb1ea3df12d351a5920f..268fc5a8e1cd68a3225102118fdb37297a37b1c3 100644 (file)
@@ -131,6 +131,7 @@ public:
     /// 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.
@@ -234,7 +235,6 @@ public:
     return Attrs.Bits != A.Attrs.Bits;
   }
 
-  Attributes operator | (const Attributes &A) const;
   Attributes operator & (const Attributes &A) const;
   Attributes &operator |= (const Attributes &A);
   Attributes &operator &= (const Attributes &A);
index e70efc54fa70f30397a4f40578c4e3810c629e77..0f24f97f836cff1449310d8f4ed2bde91db6485e 100644 (file)
@@ -93,9 +93,6 @@ bool Attributes::isEmptyOrSingleton() const {
   return Attrs.isEmptyOrSingleton();
 }
 
-Attributes Attributes::operator | (const Attributes &A) const {
-  return Attributes(Raw() | A.Raw());
-}
 Attributes Attributes::operator & (const Attributes &A) const {
   return Attributes(Raw() & A.Raw());
 }
@@ -236,8 +233,12 @@ removeAttribute(Attributes::AttrVal Val) {
   return *this;
 }
 
-Attributes::Builder &Attributes::Builder::
-removeAttributes(const Attributes &A) {
+Attributes::Builder &Attributes::Builder::addAttributes(const Attributes &A) {
+  Bits |= A.Raw();
+  return *this;
+}
+
+Attributes::Builder &Attributes::Builder::removeAttributes(const Attributes &A){
   Bits &= ~A.Raw();
   return *this;
 }
@@ -514,8 +515,9 @@ AttrListPtr AttrListPtr::addAttr(unsigned Idx, Attributes Attrs) const {
          "Attempt to change alignment!");
 #endif
   
-  Attributes NewAttrs = OldAttrs | Attrs;
-  if (NewAttrs == OldAttrs)
+  Attributes::Builder NewAttrs =
+    Attributes::Builder(OldAttrs).addAttributes(Attrs);
+  if (NewAttrs == Attributes::Builder(OldAttrs))
     return *this;
   
   SmallVector<AttributeWithIndex, 8> NewAttrList;