aboutsummaryrefslogtreecommitdiff
path: root/AST/ASTContext.cpp
diff options
context:
space:
mode:
authorSteve Naroff <snaroff@apple.com>2007-08-27 01:27:54 +0000
committerSteve Naroff <snaroff@apple.com>2007-08-27 01:27:54 +0000
commitf1448a0e4a1e868ff873a8530a61a09cb68666cc (patch)
treefb389669d2f59f0aa3c84b6bd9018661c9475c4b /AST/ASTContext.cpp
parent45a566cfcbec0efd50bc737991bdfcc70e986811 (diff)
Replaced ASTContext::maxComplexType() with ASTContext::getFloatingTypeOfSizeWithinDomain().
Changed Sema::UsualArithmeticConversions to correctly implement complex/float conversions, using maxFloatingType() with getFloatingTypeOfSizeWithinDomain(). git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@41474 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'AST/ASTContext.cpp')
-rw-r--r--AST/ASTContext.cpp42
1 files changed, 21 insertions, 21 deletions
diff --git a/AST/ASTContext.cpp b/AST/ASTContext.cpp
index 7293d4574f..919cc9e2e2 100644
--- a/AST/ASTContext.cpp
+++ b/AST/ASTContext.cpp
@@ -685,28 +685,28 @@ static int getFloatingRank(QualType T) {
}
}
-// maxComplexType - the following code handles 3 different combinations:
-// complex/complex, complex/float, float/complex.
-// When both operands are complex, the shorter operand is converted to the
-// type of the longer, and that is the type of the result. This corresponds
-// to what is done when combining two real floating-point operands.
-// The fun begins when size promotion occur across type domains. g
-// getFloatingRank & convertFloatingRankToComplexType handle this without
-// enumerating all permutations.
-// It also allows us to add new types without breakage.
-// From H&S 6.3.4: When one operand is complex and the other is a real
-// floating-point type, the less precise type is converted, within it's
-// real or complex domain, to the precision of the other type. For example,
-// when combining a "long double" with a "double _Complex", the
-// "double _Complex" is promoted to "long double _Complex".
-
-QualType ASTContext::maxComplexType(QualType lt, QualType rt) const {
- switch (std::max(getFloatingRank(lt), getFloatingRank(rt))) {
- default: assert(0 && "convertRankToComplex(): illegal value for rank");
- case FloatRank: return FloatComplexTy;
- case DoubleRank: return DoubleComplexTy;
- case LongDoubleRank: return LongDoubleComplexTy;
+/// getFloatingTypeOfSizeWithinDomain - Returns the either a real floating
+/// point type or a complex type (based on typeDomain) of typeSize.
+/// typeSize is expected to be a floating point type (real or complex).
+QualType ASTContext::getFloatingTypeOfSizeWithinDomain(
+ QualType typeSize, QualType typeDomain) const {
+ if (typeDomain->isComplexType()) {
+ switch (getFloatingRank(typeSize)) {
+ default: assert(0 && "convertRankToComplex(): illegal value for rank");
+ case FloatRank: return FloatComplexTy;
+ case DoubleRank: return DoubleComplexTy;
+ case LongDoubleRank: return LongDoubleComplexTy;
+ }
+ }
+ if (typeDomain->isRealFloatingType()) {
+ switch (getFloatingRank(typeSize)) {
+ default: assert(0 && "convertRankToComplex(): illegal value for rank");
+ case FloatRank: return FloatTy;
+ case DoubleRank: return DoubleTy;
+ case LongDoubleRank: return LongDoubleTy;
+ }
}
+ assert(0 && "getFloatingTypeOfSizeWithinDomain(): illegal domain");
}
// maxFloatingType - handles the simple case, both operands are floats.