[Lldb-commits] [lldb] [lldb][TypeSystemClang] Add support for floating point template argument constants (PR #127206)

Pavel Labath via lldb-commits lldb-commits at lists.llvm.org
Fri Feb 14 05:09:23 PST 2025


================
@@ -1973,6 +1973,27 @@ class DWARFASTParserClang::DelayedAddObjCClassProperty {
   ClangASTMetadata m_metadata;
 };
 
+static clang::APValue MakeAPValue(CompilerType clang_type, uint64_t bit_width,
+                                  uint64_t value) {
+  bool is_signed = false;
+  const bool is_integral = clang_type.IsIntegerOrEnumerationType(is_signed);
+
+  llvm::APSInt apint(bit_width, !is_signed);
+  apint = value;
+
+  if (is_integral)
+    return clang::APValue(apint);
+
+  uint32_t count;
+  bool is_complex;
+  assert(clang_type.IsFloatingPointType(count, is_complex));
+
+  if (bit_width == 32)
+    return clang::APValue(llvm::APFloat(apint.bitsToFloat()));
+
+  return clang::APValue(llvm::APFloat(apint.bitsToDouble()));
----------------
labath wrote:

I don't think we need to solve the problem of parsing all floating point types here. What I'm mainly interested in is seeing if there's a way to write this code such that it is automatically correct for any floating point type that we do support. I'm assuming/hoping that there is *a* way to get floating point semantics object out of a clang type without relying on the bitwidth...

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


More information about the lldb-commits mailing list