Add some comparison operators to compare the Attribute object with the AttrKind value.
authorBill Wendling <isanbard@gmail.com>
Mon, 31 Dec 2012 11:51:54 +0000 (11:51 +0000)
committerBill Wendling <isanbard@gmail.com>
Mon, 31 Dec 2012 11:51:54 +0000 (11:51 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@171294 91177308-0d34-0410-b5e6-96231b3b80d8

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

index caba9633ebca6a153a6b3957eb4070fbcd76d43a..a8fedb8210b8c68041434f330ae0c21a4a104893 100644 (file)
@@ -120,6 +120,10 @@ public:
   /// alignment value.
   unsigned getStackAlignment() const;
 
+  bool operator==(AttrKind K) const;
+  bool operator!=(AttrKind K) const;
+
+  // FIXME: Remove these 'operator' methods.
   bool operator==(const Attribute &A) const {
     return pImpl == A.pImpl;
   }
@@ -141,7 +145,7 @@ public:
   /// that have been decoded from the given integer.  This function must stay in
   /// sync with 'encodeLLVMAttributesForBitcode'.
   static Attribute decodeLLVMAttributesForBitcode(LLVMContext &C,
-                                                   uint64_t EncodedAttrs);
+                                                  uint64_t EncodedAttrs);
 
   /// \brief The Attribute is converted to a string of equivalent mnemonic. This
   /// is, presumably, for writing out the mnemonics for the assembly writer.
index e8c6b2a01c8200fac3b0145bbc83b35486c2c7d9..f17a9b70f7b389ba950b05e6a092d1c6334c4cd0 100644 (file)
@@ -88,6 +88,14 @@ unsigned Attribute::getStackAlignment() const {
   return 1U << ((pImpl->getStackAlignment() >> 26) - 1);
 }
 
+bool Attribute::operator==(AttrKind K) const {
+  return pImpl && pImpl->contains(K);
+}
+
+bool Attribute::operator!=(AttrKind K) const {
+  return !(pImpl && pImpl->contains(K));
+}
+
 uint64_t Attribute::getBitMask() const {
   return pImpl ? pImpl->getBitMask() : 0;
 }
@@ -473,8 +481,8 @@ uint64_t AttributeSet::getBitMask(unsigned Index) const {
 }
 
 /// getAttributes - The attributes for the specified index are returned.
-/// Attribute for the result are denoted with Idx = 0.  Function notes are
-/// denoted with idx = ~0.
+/// Attributes for the result are denoted with Idx = 0.  Function attributes are
+/// denoted with Idx = ~0.
 Attribute AttributeSet::getAttributes(unsigned Idx) const {
   if (AttrList == 0) return Attribute();