[llvm] r174026 - Remove Attribute::hasAttributes() and make Attribute::hasAttribute() private.

Bill Wendling isanbard at gmail.com
Wed Jan 30 18:18:19 PST 2013


Author: void
Date: Wed Jan 30 20:18:19 2013
New Revision: 174026

URL: http://llvm.org/viewvc/llvm-project?rev=174026&view=rev
Log:
Remove Attribute::hasAttributes() and make Attribute::hasAttribute() private.

The Attribute::hasAttributes() is kind of meaningless since an Attribute can
have only one attribute. And we would rather people use the 'operator=='
instead of Attribute::hasAttribute().

Modified:
    llvm/trunk/include/llvm/IR/Attributes.h
    llvm/trunk/lib/IR/AttributeImpl.h
    llvm/trunk/lib/IR/Attributes.cpp

Modified: llvm/trunk/include/llvm/IR/Attributes.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/IR/Attributes.h?rev=174026&r1=174025&r2=174026&view=diff
==============================================================================
--- llvm/trunk/include/llvm/IR/Attributes.h (original)
+++ llvm/trunk/include/llvm/IR/Attributes.h Wed Jan 30 20:18:19 2013
@@ -107,6 +107,9 @@ private:
   Attribute(AttributeImpl *A) : pImpl(A) {}
 
   static Attribute get(LLVMContext &Context, AttrBuilder &B);
+
+  /// \brief Return true if the attribute is present.
+  bool hasAttribute(AttrKind Val) const;
 public:
   Attribute() : pImpl(0) {}
 
@@ -126,12 +129,6 @@ public:
   // Attribute Accessors
   //===--------------------------------------------------------------------===//
 
-  /// \brief Return true if the attribute is present.
-  bool hasAttribute(AttrKind Val) const;
-
-  /// \brief Return true if attributes exist
-  bool hasAttributes() const;
-
   /// \brief Return the kind of this attribute.
   Constant *getAttributeKind() const;
 

Modified: llvm/trunk/lib/IR/AttributeImpl.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/IR/AttributeImpl.h?rev=174026&r1=174025&r2=174026&view=diff
==============================================================================
--- llvm/trunk/lib/IR/AttributeImpl.h (original)
+++ llvm/trunk/lib/IR/AttributeImpl.h Wed Jan 30 20:18:19 2013
@@ -46,7 +46,6 @@ public:
   AttributeImpl(LLVMContext &C, StringRef data);
 
   bool hasAttribute(Attribute::AttrKind A) const;
-  bool hasAttributes() const;
 
   Constant *getAttributeKind() const { return Kind; }
   ArrayRef<Constant*> getAttributeValues() const { return Vals; }

Modified: llvm/trunk/lib/IR/Attributes.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/IR/Attributes.cpp?rev=174026&r1=174025&r2=174026&view=diff
==============================================================================
--- llvm/trunk/lib/IR/Attributes.cpp (original)
+++ llvm/trunk/lib/IR/Attributes.cpp Wed Jan 30 20:18:19 2013
@@ -82,10 +82,6 @@ bool Attribute::hasAttribute(AttrKind Va
   return pImpl && pImpl->hasAttribute(Val);
 }
 
-bool Attribute::hasAttributes() const {
-  return pImpl && pImpl->hasAttributes();
-}
-
 Constant *Attribute::getAttributeKind() const {
   return pImpl ? pImpl->getAttributeKind() : 0;
 }
@@ -185,7 +181,7 @@ std::string Attribute::getAsString() con
 }
 
 bool Attribute::operator==(AttrKind K) const {
-  return pImpl && *pImpl == K;
+  return (pImpl && *pImpl == K) || (!pImpl && K == None);
 }
 bool Attribute::operator!=(AttrKind K) const {
   return !(*this == K);
@@ -226,10 +222,6 @@ bool AttributeImpl::hasAttribute(Attribu
   return (Raw() & getAttrMask(A)) != 0;
 }
 
-bool AttributeImpl::hasAttributes() const {
-  return Raw() != 0;
-}
-
 uint64_t AttributeImpl::getAlignment() const {
   uint64_t Mask = Raw() & getAttrMask(Attribute::Alignment);
   return 1ULL << ((Mask >> 16) - 1);
@@ -369,7 +361,7 @@ AttributeSetNode *AttributeSetNode::get(
 bool AttributeSetNode::hasAttribute(Attribute::AttrKind Kind) const {
   for (SmallVectorImpl<Attribute>::const_iterator I = AttrList.begin(),
          E = AttrList.end(); I != E; ++I)
-    if (I->hasAttribute(Kind))
+    if (*I == Kind)
       return true;
   return false;
 }
@@ -377,7 +369,7 @@ bool AttributeSetNode::hasAttribute(Attr
 unsigned AttributeSetNode::getAlignment() const {
   for (SmallVectorImpl<Attribute>::const_iterator I = AttrList.begin(),
          E = AttrList.end(); I != E; ++I)
-    if (I->hasAttribute(Attribute::Alignment))
+    if (*I == Attribute::Alignment)
       return I->getAlignment();
   return 0;
 }
@@ -385,7 +377,7 @@ unsigned AttributeSetNode::getAlignment(
 unsigned AttributeSetNode::getStackAlignment() const {
   for (SmallVectorImpl<Attribute>::const_iterator I = AttrList.begin(),
          E = AttrList.end(); I != E; ++I)
-    if (I->hasAttribute(Attribute::StackAlignment))
+    if (*I == Attribute::StackAlignment)
       return I->getStackAlignment();
   return 0;
 }
@@ -454,7 +446,7 @@ AttributeSet AttributeSet::get(LLVMConte
   for (unsigned i = 0, e = Attrs.size(); i != e; ++i) {
     assert((!i || Attrs[i-1].first <= Attrs[i].first) &&
            "Misordered Attributes list!");
-    assert(Attrs[i].second.hasAttributes() &&
+    assert(Attrs[i].second != Attribute::None &&
            "Pointless attribute!");
   }
 #endif
@@ -682,7 +674,7 @@ bool AttributeSet::hasAttrSomewhere(Attr
   for (unsigned I = 0, E = pImpl->getNumAttributes(); I != E; ++I)
     for (AttributeSetImpl::const_iterator II = pImpl->begin(I),
            IE = pImpl->end(I); II != IE; ++II)
-      if (II->hasAttribute(Attr))
+      if (*II == Attr)
         return true;
 
   return false;





More information about the llvm-commits mailing list