[Lldb-commits] [lldb] [lldb] Fix `from_size` initialization in `DoIntegralPromotion` (PR #191421)
via lldb-commits
lldb-commits at lists.llvm.org
Fri Apr 10 07:04:42 PDT 2026
llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-lldb
Author: Ilia Kuklin (kuilpd)
<details>
<summary>Changes</summary>
The check `(*from_size == *int_byte_size)` can only pass on systems where `short` and `int` types are the same width, which is why the bug was never triggered by tests.
---
Full diff: https://github.com/llvm/llvm-project/pull/191421.diff
1 Files Affected:
- (modified) lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp (+4-5)
``````````diff
diff --git a/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp b/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
index 86d39b51e9b4c..8689b5b353368 100644
--- a/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
+++ b/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
@@ -7315,7 +7315,9 @@ TypeSystemClang::DoIntegralPromotion(CompilerType from,
lldb::BasicType builtin_type =
from.GetCanonicalType().GetBasicTypeEnumeration();
- uint64_t from_size = 0;
+ llvm::Expected<uint64_t> from_size = from.GetByteSize(exe_scope);
+ if (!from_size)
+ return from_size.takeError();
if (builtin_type == lldb::eBasicTypeWChar ||
builtin_type == lldb::eBasicTypeSignedWChar ||
builtin_type == lldb::eBasicTypeUnsignedWChar ||
@@ -7323,9 +7325,6 @@ TypeSystemClang::DoIntegralPromotion(CompilerType from,
builtin_type == lldb::eBasicTypeChar32) {
// Find the type that can hold the entire range of values for our type.
bool is_signed = from.IsSigned();
- llvm::Expected<uint64_t> from_size = from.GetByteSize(exe_scope);
- if (!from_size)
- return from_size.takeError();
CompilerType promote_types[] = {
GetBasicTypeFromAST(lldb::eBasicTypeInt),
GetBasicTypeFromAST(lldb::eBasicTypeUnsignedInt),
@@ -7358,7 +7357,7 @@ TypeSystemClang::DoIntegralPromotion(CompilerType from,
}
// Unsigned integer types are promoted to "unsigned int" if "int" cannot hold
// their entire value range.
- return (from_size == *int_byte_size)
+ return (*from_size == *int_byte_size)
? GetBasicTypeFromAST(lldb::eBasicTypeUnsignedInt)
: int_type;
}
``````````
</details>
https://github.com/llvm/llvm-project/pull/191421
More information about the lldb-commits
mailing list