diff options
author | Chris Lattner <sabre@nondot.org> | 2008-04-06 23:38:49 +0000 |
---|---|---|
committer | Chris Lattner <sabre@nondot.org> | 2008-04-06 23:38:49 +0000 |
commit | a75cea3f6be0daa8054d36af81a6ffda1713f82d (patch) | |
tree | ab8a09dcf5ee31e6319b04a824013e477812f1fe /lib/AST/ASTContext.cpp | |
parent | 8bcfc5bef434d7052e28d0ce45182855659ebd3d (diff) |
minor simplifications/cleanups to type comparisons.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@49296 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/AST/ASTContext.cpp')
-rw-r--r-- | lib/AST/ASTContext.cpp | 22 |
1 files changed, 12 insertions, 10 deletions
diff --git a/lib/AST/ASTContext.cpp b/lib/AST/ASTContext.cpp index 9a6cd4db15..eb2f7ef52d 100644 --- a/lib/AST/ASTContext.cpp +++ b/lib/AST/ASTContext.cpp @@ -1010,13 +1010,12 @@ QualType ASTContext::getArrayDecayedType(QualType Ty) { /// getFloatingRank - Return a relative rank for floating point types. /// This routine will assert if passed a built-in type that isn't a float. -static int getFloatingRank(QualType T) { - T = T.getCanonicalType(); +static FloatingRank getFloatingRank(QualType T) { if (const ComplexType *CT = T->getAsComplexType()) return getFloatingRank(CT->getElementType()); - + switch (T->getAsBuiltinType()->getKind()) { - default: assert(0 && "getFloatingRank(): not a floating type"); + default: assert(0 && "getFloatingRank(): not a floating type"); case BuiltinType::Float: return FloatRank; case BuiltinType::Double: return DoubleRank; case BuiltinType::LongDouble: return LongDoubleRank; @@ -1051,13 +1050,16 @@ QualType ASTContext::getFloatingTypeOfSizeWithinDomain( return VoidTy; } -/// compareFloatingType - Handles 3 different combos: +/// getFloatingTypeOrder - Handles 3 different combos: /// float/float, float/complex, complex/complex. /// If lt > rt, return 1. If lt == rt, return 0. If lt < rt, return -1. -int ASTContext::compareFloatingType(QualType lt, QualType rt) { - if (getFloatingRank(lt) == getFloatingRank(rt)) +int ASTContext::getFloatingTypeOrder(QualType LHS, QualType RHS) { + FloatingRank LHSR = getFloatingRank(LHS); + FloatingRank RHSR = getFloatingRank(RHS); + + if (LHSR == RHSR) return 0; - if (getFloatingRank(lt) > getFloatingRank(rt)) + if (LHSR > RHSR) return 1; return -1; } @@ -1094,9 +1096,9 @@ static unsigned getIntegerRank(Type *T) { } } -// maxIntegerType - Returns the highest ranked integer type. Handles 3 case: +// getMaxIntegerType - Returns the highest ranked integer type. Handles 3 case: // unsigned/unsigned, signed/signed, signed/unsigned. C99 6.3.1.8p1. -QualType ASTContext::maxIntegerType(QualType LHS, QualType RHS) { +QualType ASTContext::getMaxIntegerType(QualType LHS, QualType RHS) { Type *LHSC = getCanonicalType(LHS).getTypePtr(); Type *RHSC = getCanonicalType(RHS).getTypePtr(); if (LHSC == RHSC) return LHS; |