[Lldb-commits] [lldb] 52db30e - [lldb] Fix compiler error in ValueObject tests

David Spickett via lldb-commits lldb-commits at lists.llvm.org
Fri Feb 7 02:29:49 PST 2025


Author: David Spickett
Date: 2025-02-07T10:29:35Z
New Revision: 52db30ec4154b0ef21db546ed9b5a9bfe47859cd

URL: https://github.com/llvm/llvm-project/commit/52db30ec4154b0ef21db546ed9b5a9bfe47859cd
DIFF: https://github.com/llvm/llvm-project/commit/52db30ec4154b0ef21db546ed9b5a9bfe47859cd.diff

LOG: [lldb] Fix compiler error in ValueObject tests

Fixes 0cbc4983adcdbbd85ccb38b2dfbfe5985367b1b2.

error: non-constant-expression cannot be narrowed from type 'uint64_t' (aka 'unsigned long long') to 'size_t' (aka 'unsigned int') in initializer list [-Wc++11-narrowing]
   71 |                     in_value.GetLocalBufferSize()};
      |                     ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Given this is test code, I think a static cast is fine here.

Tiny risk that it's actually a symptom of a bug that would
happen if you did 32-bit to 64-bit debugging. I expect you'd
find a lot more bugs than that though.

Added: 
    

Modified: 
    lldb/unittests/ValueObject/DynamicValueObjectLocalBuffer.cpp

Removed: 
    


################################################################################
diff  --git a/lldb/unittests/ValueObject/DynamicValueObjectLocalBuffer.cpp b/lldb/unittests/ValueObject/DynamicValueObjectLocalBuffer.cpp
index d311c05e511786..e3cf0f8a87bd2a 100644
--- a/lldb/unittests/ValueObject/DynamicValueObjectLocalBuffer.cpp
+++ b/lldb/unittests/ValueObject/DynamicValueObjectLocalBuffer.cpp
@@ -68,7 +68,7 @@ struct MockLanguageRuntime : public LanguageRuntime {
     class_type_or_name.SetCompilerType(int_type);
     local_buffer = {(uint8_t *)in_value.GetValue().GetScalar().ULongLong(
                         LLDB_INVALID_ADDRESS),
-                    in_value.GetLocalBufferSize()};
+                    static_cast<size_t>(in_value.GetLocalBufferSize())};
     value_type = Value::ValueType::HostAddress;
 
     return true;


        


More information about the lldb-commits mailing list