[Core] Use GetAPInt instead of constructing APInts in place

GetAPInt should be able to handle all cases. I have plans to generalize
the float dumping logic and this makes it easier to do later.

llvm-svn: 370255
This commit is contained in:
Alex Langford 2019-08-28 20:15:57 +00:00
parent 7080ffa21a
commit 3e45e3ba95
1 changed files with 14 additions and 9 deletions

View File

@ -567,11 +567,13 @@ lldb::offset_t lldb_private::DumpDataExtractor(
size_t item_bit_size = item_byte_size * 8;
if (item_bit_size == ast->getTypeSize(ast->FloatTy)) {
llvm::APInt apint(item_bit_size,
DE.GetMaxU64(&offset, item_byte_size));
llvm::APFloat apfloat(ast->getFloatTypeSemantics(ast->FloatTy),
apint);
apfloat.toString(sv, format_precision, format_max_padding);
llvm::Optional<llvm::APInt> apint =
GetAPInt(DE, &offset, item_byte_size);
if (apint.hasValue()) {
llvm::APFloat apfloat(ast->getFloatTypeSemantics(ast->FloatTy),
apint.getValue());
apfloat.toString(sv, format_precision, format_max_padding);
}
} else if (item_bit_size == ast->getTypeSize(ast->DoubleTy)) {
llvm::Optional<llvm::APInt> apint =
GetAPInt(DE, &offset, item_byte_size);
@ -595,10 +597,13 @@ lldb::offset_t lldb_private::DumpDataExtractor(
apfloat.toString(sv, format_precision, format_max_padding);
}
} else if (item_bit_size == ast->getTypeSize(ast->HalfTy)) {
llvm::APInt apint(item_bit_size, DE.GetU16(&offset));
llvm::APFloat apfloat(ast->getFloatTypeSemantics(ast->HalfTy),
apint);
apfloat.toString(sv, format_precision, format_max_padding);
llvm::Optional<llvm::APInt> apint =
GetAPInt(DE, &offset, item_byte_size);
if (apint.hasValue()) {
llvm::APFloat apfloat(ast->getFloatTypeSemantics(ast->HalfTy),
apint.getValue());
apfloat.toString(sv, format_precision, format_max_padding);
}
}
if (!sv.empty()) {