[Lldb-commits] [lldb] [LLDB] Add APFloat helper functions to Scalar class. (PR #86862)

via lldb-commits lldb-commits at lists.llvm.org
Wed Mar 27 12:42:39 PDT 2024


github-actions[bot] wrote:

<!--LLVM CODE FORMAT COMMENT: {clang-format}-->


:warning: C/C++ code formatter, clang-format found issues in your code. :warning:

<details>
<summary>
You can test this locally with the following command:
</summary>

``````````bash
git-clang-format --diff dcd0f2b6103072b74b446c2d1e9ecec60001a28c 03ef6db02f49ab4cc4f63b32553015b4f3801b5b -- lldb/include/lldb/Utility/Scalar.h lldb/source/Utility/Scalar.cpp
``````````

</details>

<details>
<summary>
View the diff from clang-format here.
</summary>

``````````diff
diff --git a/lldb/include/lldb/Utility/Scalar.h b/lldb/include/lldb/Utility/Scalar.h
index d5e70fdf20..c89566f5e9 100644
--- a/lldb/include/lldb/Utility/Scalar.h
+++ b/lldb/include/lldb/Utility/Scalar.h
@@ -71,8 +71,7 @@ public:
       : m_type(e_int), m_integer(std::move(v), false), m_float(0.0f) {}
   Scalar(llvm::APSInt v)
       : m_type(e_int), m_integer(std::move(v)), m_float(0.0f) {}
-  Scalar(llvm::APFloat v)
-      : m_integer(0), m_float(v) {}
+  Scalar(llvm::APFloat v) : m_integer(0), m_float(v) {}
 
   bool SignExtend(uint32_t bit_pos);
 
diff --git a/lldb/source/Utility/Scalar.cpp b/lldb/source/Utility/Scalar.cpp
index afcb204d8f..e94fd45962 100644
--- a/lldb/source/Utility/Scalar.cpp
+++ b/lldb/source/Utility/Scalar.cpp
@@ -815,46 +815,46 @@ bool Scalar::ExtractBitfield(uint32_t bit_size, uint32_t bit_offset) {
 
 llvm::APFloat Scalar::CreateAPFloatFromAPSInt(lldb::BasicType basic_type) {
   switch (basic_type) {
-    case lldb::eBasicTypeFloat:
-      return llvm::APFloat(m_integer.isSigned()
-                           ? llvm::APIntOps::RoundSignedAPIntToFloat(m_integer)
-                           : llvm::APIntOps::RoundAPIntToFloat(m_integer));
-    case lldb::eBasicTypeDouble:
-      // No way to get more precision at the moment.
-    case lldb::eBasicTypeLongDouble:
-      return llvm::APFloat(m_integer.isSigned()
-                               ? llvm::APIntOps::RoundSignedAPIntToDouble(
-                                   m_integer)
-                               : llvm::APIntOps::RoundAPIntToDouble(m_integer));
-    default:
-      const llvm::fltSemantics &sem = APFloat::IEEEsingle();
-      return llvm::APFloat::getNaN(sem);
+  case lldb::eBasicTypeFloat:
+    return llvm::APFloat(
+        m_integer.isSigned()
+            ? llvm::APIntOps::RoundSignedAPIntToFloat(m_integer)
+            : llvm::APIntOps::RoundAPIntToFloat(m_integer));
+  case lldb::eBasicTypeDouble:
+    // No way to get more precision at the moment.
+  case lldb::eBasicTypeLongDouble:
+    return llvm::APFloat(
+        m_integer.isSigned()
+            ? llvm::APIntOps::RoundSignedAPIntToDouble(m_integer)
+            : llvm::APIntOps::RoundAPIntToDouble(m_integer));
+  default:
+    const llvm::fltSemantics &sem = APFloat::IEEEsingle();
+    return llvm::APFloat::getNaN(sem);
   }
 }
 
 llvm::APFloat Scalar::CreateAPFloatFromAPFloat(lldb::BasicType basic_type) {
   switch (basic_type) {
-    case lldb::eBasicTypeFloat: {
-      bool loses_info;
-      m_float.convert(llvm::APFloat::IEEEsingle(),
-                      llvm::APFloat::rmNearestTiesToEven, &loses_info);
-      return m_float;
-    }
-    case lldb::eBasicTypeDouble:
-      // No way to get more precision at the moment.
-    case lldb::eBasicTypeLongDouble: {
-      bool loses_info;
-      m_float.convert(llvm::APFloat::IEEEdouble(),
+  case lldb::eBasicTypeFloat: {
+    bool loses_info;
+    m_float.convert(llvm::APFloat::IEEEsingle(),
                     llvm::APFloat::rmNearestTiesToEven, &loses_info);
-      return m_float;
-    }
-    default:
-      const llvm::fltSemantics &sem = APFloat::IEEEsingle();
-      return llvm::APFloat::getNaN(sem);
+    return m_float;
+  }
+  case lldb::eBasicTypeDouble:
+    // No way to get more precision at the moment.
+  case lldb::eBasicTypeLongDouble: {
+    bool loses_info;
+    m_float.convert(llvm::APFloat::IEEEdouble(),
+                    llvm::APFloat::rmNearestTiesToEven, &loses_info);
+    return m_float;
+  }
+  default:
+    const llvm::fltSemantics &sem = APFloat::IEEEsingle();
+    return llvm::APFloat::getNaN(sem);
   }
 }
 
-
 bool lldb_private::operator==(Scalar lhs, Scalar rhs) {
   // If either entry is void then we can just compare the types
   if (lhs.m_type == Scalar::e_void || rhs.m_type == Scalar::e_void)

``````````

</details>


https://github.com/llvm/llvm-project/pull/86862


More information about the lldb-commits mailing list