[Lldb-commits] [lldb] [lldb] Fix `from_size` initialization in `DoIntegralPromotion` (PR #191421)
Ilia Kuklin via lldb-commits
lldb-commits at lists.llvm.org
Fri Apr 10 07:04:13 PDT 2026
https://github.com/kuilpd created https://github.com/llvm/llvm-project/pull/191421
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.
>From bff9f6d51c8062feeb02c8a4b6df5626889f5eff Mon Sep 17 00:00:00 2001
From: Ilia Kuklin <ikuklin at accesssoftek.com>
Date: Fri, 10 Apr 2026 18:53:54 +0500
Subject: [PATCH] [lldb] Fix `from_size` initialization in
TypeSystemClang::DoIntegralPromotion
---
lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp | 9 ++++-----
1 file changed, 4 insertions(+), 5 deletions(-)
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;
}
More information about the lldb-commits
mailing list