[llvm] r175250 - Revert "Simplify the attributes '<' comparison function."

Anna Zaks ganna at apple.com
Thu Feb 14 20:15:55 PST 2013


Author: zaks
Date: Thu Feb 14 22:15:55 2013
New Revision: 175250

URL: http://llvm.org/viewvc/llvm-project?rev=175250&view=rev
Log:
Revert "Simplify the attributes '<' comparison function."

This reverts commit 82c101153fe7b35bce48781fab038e1b8f31a7bd.

Modified:
    llvm/trunk/lib/IR/Attributes.cpp

Modified: llvm/trunk/lib/IR/Attributes.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/IR/Attributes.cpp?rev=175250&r1=175249&r2=175250&view=diff
==============================================================================
--- llvm/trunk/lib/IR/Attributes.cpp (original)
+++ llvm/trunk/lib/IR/Attributes.cpp Thu Feb 14 22:15:55 2013
@@ -332,23 +332,25 @@ StringRef AttributeImpl::getValueAsStrin
 bool AttributeImpl::operator<(const AttributeImpl &AI) const {
   // This sorts the attributes with Attribute::AttrKinds coming first (sorted
   // relative to their enum value) and then strings.
-  if (isEnumAttribute()) {
-    if (AI.isEnumAttribute()) return getKindAsEnum() < AI.getKindAsEnum();
-    if (AI.isAlignAttribute()) return true;
-    if (AI.isStringAttribute()) return true;
-  }
+  if (isEnumAttribute())
+    if (AI.isAlignAttribute() || AI.isEnumAttribute())
+      return getKindAsEnum() < AI.getKindAsEnum();
 
   if (isAlignAttribute()) {
-    if (AI.isEnumAttribute()) return false;
-    if (AI.isAlignAttribute()) return getValueAsInt() < AI.getValueAsInt();
-    if (AI.isStringAttribute()) return true;
+    if (!AI.isStringAttribute() && getKindAsEnum() < AI.getKindAsEnum())
+      return true;
+    if (AI.isAlignAttribute())
+      return getValueAsInt() < AI.getValueAsInt();
+  }
+
+  if (isStringAttribute()) {
+    if (!AI.isStringAttribute()) return false;
+    if (getKindAsString() < AI.getKindAsString()) return true;
+    if (getKindAsString() == AI.getKindAsString())
+      return getValueAsString() < AI.getValueAsString();
   }
 
-  if (AI.isEnumAttribute()) return false;
-  if (AI.isAlignAttribute()) return false;
-  if (getKindAsString() == AI.getKindAsString())
-    return getValueAsString() < AI.getValueAsString();
-  return getKindAsString() < AI.getKindAsString();
+  return false;
 }
 
 uint64_t AttributeImpl::getAttrMask(Attribute::AttrKind Val) {





More information about the llvm-commits mailing list