Fixed a bug that caused floating-point values

to be printed truncated.

<rdar://problem/12389615>

llvm-svn: 166368
This commit is contained in:
Sean Callanan 2012-10-20 06:08:09 +00:00
parent 3940bafb54
commit a2cd62a1e7
1 changed files with 23 additions and 15 deletions

View File

@ -11,6 +11,8 @@
#include <stddef.h>
#include <bitset>
#include <limits>
#include <sstream>
#include <string>
#include "llvm/ADT/APFloat.h"
@ -1706,22 +1708,28 @@ DataExtractor::Dump (Stream *s,
break;
case eFormatFloat:
if (sizeof(float) == item_byte_size)
{
s->Printf ("%g", GetFloat (&offset));
}
else if (sizeof(double) == item_byte_size)
{
s->Printf ("%lg", GetDouble(&offset));
}
else if (sizeof(long double) == item_byte_size)
{
s->Printf ("%Lg", GetLongDouble(&offset));
}
else
{
s->Printf("error: unsupported byte size (%u) for float format", item_byte_size);
return offset;
std::ostringstream ss;
switch (item_byte_size)
{
default:
s->Printf("error: unsupported byte size (%u) for float format", item_byte_size);
return offset;
case sizeof(float):
ss.precision(std::numeric_limits<float>::digits10);
ss << GetFloat(&offset);
break;
case sizeof(double):
ss.precision(std::numeric_limits<double>::digits10);
ss << GetDouble(&offset);
break;
case sizeof(long double):
ss.precision(std::numeric_limits<long double>::digits10);
ss << GetLongDouble(&offset);
break;
}
ss.flush();
s->Printf("%s", ss.str().c_str());
}
break;