Revert "Simplify the attributes '<' comparison function."
authorAnna Zaks <ganna@apple.com>
Fri, 15 Feb 2013 04:15:55 +0000 (04:15 +0000)
committerAnna Zaks <ganna@apple.com>
Fri, 15 Feb 2013 04:15:55 +0000 (04:15 +0000)
This reverts commit 82c101153fe7b35bce48781fab038e1b8f31a7bd.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@175250 91177308-0d34-0410-b5e6-96231b3b80d8

lib/IR/Attributes.cpp

index 629679c6831d039aeca09a138145bb1f95f240fd..3de304e760839f8e701ffc1f2349b3cd3a70f40e 100644 (file)
@@ -332,23 +332,25 @@ StringRef AttributeImpl::getValueAsString() const {
 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) {