aboutsummaryrefslogtreecommitdiff
path: root/lib/Sema/SemaChecking.cpp
diff options
context:
space:
mode:
authorJeffrey Yasskin <jyasskin@google.com>2011-07-15 17:03:07 +0000
committerJeffrey Yasskin <jyasskin@google.com>2011-07-15 17:03:07 +0000
commit3e1ef7849845a9e7bf79156bbb8a2c26d77a1d2e (patch)
treed3e5ed7e0e91550b253f872f5eed53c48958d158 /lib/Sema/SemaChecking.cpp
parent5b8968cc599eb6100bb73ae87be9d6cd2577ac9e (diff)
Use the new APFloat::convertToInt(APSInt) function to simplify uses of
convertToInt(integerParts*) and make them more reliable. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@135279 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Sema/SemaChecking.cpp')
-rw-r--r--lib/Sema/SemaChecking.cpp12
1 files changed, 5 insertions, 7 deletions
diff --git a/lib/Sema/SemaChecking.cpp b/lib/Sema/SemaChecking.cpp
index 3b48201edd..690a29d281 100644
--- a/lib/Sema/SemaChecking.cpp
+++ b/lib/Sema/SemaChecking.cpp
@@ -3030,18 +3030,16 @@ void DiagnoseFloatingLiteralImpCast(Sema &S, FloatingLiteral *FL, QualType T,
if (&Value.getSemantics() == &llvm::APFloat::PPCDoubleDouble)
return;
- // Try to convert this exactly to an 64-bit integer. FIXME: It would be
- // nice to support arbitrarily large integers here.
+ // Try to convert this exactly to an integer.
bool isExact = false;
- uint64_t IntegerPart;
- if (Value.convertToInteger(&IntegerPart, 64, /*isSigned=*/true,
+ llvm::APSInt IntegerValue(S.Context.getIntWidth(T),
+ T->hasUnsignedIntegerRepresentation());
+ if (Value.convertToInteger(IntegerValue,
llvm::APFloat::rmTowardZero, &isExact)
!= llvm::APFloat::opOK || !isExact)
return;
- llvm::APInt IntegerValue(64, IntegerPart, /*isSigned=*/true);
-
- std::string LiteralValue = IntegerValue.toString(10, /*isSigned=*/true);
+ std::string LiteralValue = IntegerValue.toString(10);
S.Diag(FL->getExprLoc(), diag::note_fix_integral_float_as_integer)
<< FixItHint::CreateReplacement(FL->getSourceRange(), LiteralValue);
}