summaryrefslogtreecommitdiffstats
path: root/clang/lib/AST
diff options
context:
space:
mode:
authorEli Friedman <eli.friedman@gmail.com>2013-08-29 23:44:43 +0000
committerEli Friedman <eli.friedman@gmail.com>2013-08-29 23:44:43 +0000
commit0718591771c8564f77706731db1b5d35c7fc4789 (patch)
treea9006bb972f8de34dfedcc46093fb17f6d96a903 /clang/lib/AST
parente72f132097fc8026981acf3f36d165734f3341dd (diff)
downloadbcm5719-llvm-0718591771c8564f77706731db1b5d35c7fc4789.tar.gz
bcm5719-llvm-0718591771c8564f77706731db1b5d35c7fc4789.zip
Adjust clang for change to APFloat::toString.
I changed the diagnostic printing code because it's probably better to cut off a digit from DBL_MAX than to print something like 1.300000001 when the user wrote 1.3. llvm-svn: 189625
Diffstat (limited to 'clang/lib/AST')
-rw-r--r--clang/lib/AST/ExprConstant.cpp11
1 files changed, 10 insertions, 1 deletions
diff --git a/clang/lib/AST/ExprConstant.cpp b/clang/lib/AST/ExprConstant.cpp
index 15c4a2193f7..b6602145e28 100644
--- a/clang/lib/AST/ExprConstant.cpp
+++ b/clang/lib/AST/ExprConstant.cpp
@@ -367,8 +367,17 @@ namespace {
OptionalDiagnostic &operator<<(const APFloat &F) {
if (Diag) {
+ // FIXME: Force the precision of the source value down so we don't
+ // print digits which are usually useless (we don't really care here if
+ // we truncate a digit by accident in edge cases). Ideally,
+ // APFloat::toString would automatically print the shortest
+ // representation which rounds to the correct value, but it's a bit
+ // tricky to implement.
+ unsigned precision =
+ llvm::APFloat::semanticsPrecision(F.getSemantics());
+ precision = (precision * 59 + 195) / 196;
SmallVector<char, 32> Buffer;
- F.toString(Buffer);
+ F.toString(Buffer, precision);
*Diag << StringRef(Buffer.data(), Buffer.size());
}
return *this;
OpenPOWER on IntegriCloud