[Lldb-commits] [lldb] r370255 - [Core] Use GetAPInt instead of constructing APInts in place

Alex Langford via lldb-commits lldb-commits at lists.llvm.org
Wed Aug 28 13:15:57 PDT 2019


Author: xiaobai
Date: Wed Aug 28 13:15:57 2019
New Revision: 370255

URL: http://llvm.org/viewvc/llvm-project?rev=370255&view=rev
Log:
[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.

Modified:
    lldb/trunk/source/Core/DumpDataExtractor.cpp

Modified: lldb/trunk/source/Core/DumpDataExtractor.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/DumpDataExtractor.cpp?rev=370255&r1=370254&r2=370255&view=diff
==============================================================================
--- lldb/trunk/source/Core/DumpDataExtractor.cpp (original)
+++ lldb/trunk/source/Core/DumpDataExtractor.cpp Wed Aug 28 13:15:57 2019
@@ -567,11 +567,13 @@ lldb::offset_t lldb_private::DumpDataExt
             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::DumpDataExt
                 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()) {




More information about the lldb-commits mailing list