[Lldb-commits] [lldb] [lldb] Make sure that the "TypeSystemClang::GetBuiltinTypeByName" method returns the correct value also for "_BitInt(...)" types. (PR #165857)
Matej Košík via lldb-commits
lldb-commits at lists.llvm.org
Wed Nov 19 06:47:51 PST 2025
https://github.com/sedymrak updated https://github.com/llvm/llvm-project/pull/165857
>From f9750d0fedc41532ffe7d5048c419cb91d223601 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Matej=20Ko=C5=A1=C3=ADk?= <matej.kosik at codasip.com>
Date: Fri, 31 Oct 2025 10:37:26 +0100
Subject: [PATCH 1/3] [lldb] add more tests
---
.../sbtype_basic_type/TestSBTypeBasicType.py | 14 ++++++++++++++
1 file changed, 14 insertions(+)
diff --git a/lldb/test/API/python_api/sbtype_basic_type/TestSBTypeBasicType.py b/lldb/test/API/python_api/sbtype_basic_type/TestSBTypeBasicType.py
index f8594dfc6b78d..99617cc68d19f 100644
--- a/lldb/test/API/python_api/sbtype_basic_type/TestSBTypeBasicType.py
+++ b/lldb/test/API/python_api/sbtype_basic_type/TestSBTypeBasicType.py
@@ -36,3 +36,17 @@ def test(self):
# Check the size of the chosen aliases of basic types.
self.assertEqual(self.target().FindFirstType("__int128_t").size, 16)
self.assertEqual(self.target().FindFirstType("__uint128_t").size, 16)
+
+ # "_BitInt(...)" and "unsigned _BitInt(...)" are GNU C compiler extensions
+ # that are supported by LLVM C(++) compiler as well.
+ #
+ # We check that LLDB is able to map the names of these types
+ # (as reported by LLDB for variables of this type)
+ # to the corresponding SBType objects.
+ self.assertEqual(self.target().FindFirstType("_BitInt(65)").name, "_BitInt(65)")
+ self.assertEqual(self.target().FindFirstType("_BitInt(65)").size, 16)
+ self.assertEqual(
+ self.target().FindFirstType("unsigned _BitInt(65)").name,
+ "unsigned _BitInt(65)",
+ )
+ self.assertEqual(self.target().FindFirstType("unsigned _BitInt(65)").size, 16)
>From e46d8f3037eaf9c84dd8f0d875013ff574fc04af Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Matej=20Ko=C5=A1=C3=ADk?= <matej.kosik at codasip.com>
Date: Fri, 31 Oct 2025 10:37:51 +0100
Subject: [PATCH 2/3] [lldb] fix the "TypeSystemClang::GetBuiltinTypeByName"
method
---
.../Plugins/TypeSystem/Clang/TypeSystemClang.cpp | 11 +++++++++++
1 file changed, 11 insertions(+)
diff --git a/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp b/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
index 6ec054d5eac05..cfa936415d634 100644
--- a/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
+++ b/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
@@ -5498,6 +5498,17 @@ TypeSystemClang::GetNumChildren(lldb::opaque_compiler_type_t type,
}
CompilerType TypeSystemClang::GetBuiltinTypeByName(ConstString name) {
+ StringRef name_ref = name.GetStringRef();
+ llvm::Regex re("^(unsigned )?_BitInt\\((.*)\\)$");
+ llvm::SmallVector<llvm::StringRef, 4> matches;
+ bool is_bitint = re.match(name_ref, &matches);
+ if (is_bitint && matches.size() == 3) {
+ bool is_unsigned = matches[1] == "unsigned ";
+ llvm::APInt ap_bit_size;
+ if (!matches[2].getAsInteger(10, ap_bit_size))
+ return GetType(getASTContext().getBitIntType(is_unsigned,
+ ap_bit_size.getZExtValue()));
+ }
return GetBasicType(GetBasicTypeEnumeration(name));
}
>From 418009c13b641c54bfacf4312eaec43f2c8c1bdc Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Matej=20Ko=C5=A1=C3=ADk?= <matej.kosik at codasip.com>
Date: Wed, 19 Nov 2025 15:47:20 +0100
Subject: [PATCH 3/3] [lldb] simplify the code
---
lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp b/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
index cfa936415d634..6d23a0115805d 100644
--- a/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
+++ b/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
@@ -5500,7 +5500,7 @@ TypeSystemClang::GetNumChildren(lldb::opaque_compiler_type_t type,
CompilerType TypeSystemClang::GetBuiltinTypeByName(ConstString name) {
StringRef name_ref = name.GetStringRef();
llvm::Regex re("^(unsigned )?_BitInt\\((.*)\\)$");
- llvm::SmallVector<llvm::StringRef, 4> matches;
+ llvm::SmallVector<llvm::StringRef, 3> matches;
bool is_bitint = re.match(name_ref, &matches);
if (is_bitint && matches.size() == 3) {
bool is_unsigned = matches[1] == "unsigned ";
More information about the lldb-commits
mailing list