aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBill Wendling <isanbard@gmail.com>2013-02-15 00:55:08 +0000
committerBill Wendling <isanbard@gmail.com>2013-02-15 00:55:08 +0000
commit0ec707a4e586f41f8a2cf91557fbbbe142377dd0 (patch)
tree94ffaa47af37ac388b64edb2f8076196bbc8a0a2
parentd977aacf990d241d0224d20518f631a928c1b1a8 (diff)
Simplify the attributes '<' comparison function.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@175235 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r--lib/IR/Attributes.cpp28
1 files changed, 13 insertions, 15 deletions
diff --git a/lib/IR/Attributes.cpp b/lib/IR/Attributes.cpp
index 3de304e760..629679c683 100644
--- a/lib/IR/Attributes.cpp
+++ b/lib/IR/Attributes.cpp
@@ -332,25 +332,23 @@ 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.isAlignAttribute() || AI.isEnumAttribute())
- return getKindAsEnum() < AI.getKindAsEnum();
-
- if (isAlignAttribute()) {
- if (!AI.isStringAttribute() && getKindAsEnum() < AI.getKindAsEnum())
- return true;
- if (AI.isAlignAttribute())
- return getValueAsInt() < AI.getValueAsInt();
+ if (isEnumAttribute()) {
+ if (AI.isEnumAttribute()) return getKindAsEnum() < AI.getKindAsEnum();
+ if (AI.isAlignAttribute()) return true;
+ if (AI.isStringAttribute()) return true;
}
- if (isStringAttribute()) {
- if (!AI.isStringAttribute()) return false;
- if (getKindAsString() < AI.getKindAsString()) return true;
- if (getKindAsString() == AI.getKindAsString())
- return getValueAsString() < AI.getValueAsString();
+ if (isAlignAttribute()) {
+ if (AI.isEnumAttribute()) return false;
+ if (AI.isAlignAttribute()) return getValueAsInt() < AI.getValueAsInt();
+ if (AI.isStringAttribute()) return true;
}
- return false;
+ if (AI.isEnumAttribute()) return false;
+ if (AI.isAlignAttribute()) return false;
+ if (getKindAsString() == AI.getKindAsString())
+ return getValueAsString() < AI.getValueAsString();
+ return getKindAsString() < AI.getKindAsString();
}
uint64_t AttributeImpl::getAttrMask(Attribute::AttrKind Val) {