[llvm-branch-commits] [lldb] 4528fc9 - [lldb] Make sure that the "TypeSystemClang::GetBuiltinTypeByName" method returns the correct value also for "_BitInt(...)" types. (#165857)
Cullen Rhodes via llvm-branch-commits
llvm-branch-commits at lists.llvm.org
Tue Jan 13 02:21:21 PST 2026
Author: Matej Košík
Date: 2026-01-13T10:18:55Z
New Revision: 4528fc9b14e3ae05a43a97df3cb8005347fb183d
URL: https://github.com/llvm/llvm-project/commit/4528fc9b14e3ae05a43a97df3cb8005347fb183d
DIFF: https://github.com/llvm/llvm-project/commit/4528fc9b14e3ae05a43a97df3cb8005347fb183d.diff
LOG: [lldb] Make sure that the "TypeSystemClang::GetBuiltinTypeByName" method returns the correct value also for "_BitInt(...)" types. (#165857)
When trying to get the `SBType` object corresponding to the
`_BitInt(...)` type name, we have noticed that the
`SBTarget::FindFirstType` metod returns `nil`. This branch proposes:
- some test that demonstrate that the problem exists
- a possible fix
---------
Co-authored-by: Matej Košík <matej.kosik at codasip.com>
Co-authored-by: Michael Buch <michaelbuch12 at gmail.com>
Added:
Modified:
lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
lldb/test/API/python_api/sbtype_basic_type/TestSBTypeBasicType.py
Removed:
################################################################################
diff --git a/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp b/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
index b70b1bf4b4aac..06f886b7e3438 100644
--- a/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
+++ b/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
@@ -5505,6 +5505,21 @@ TypeSystemClang::GetNumChildren(lldb::opaque_compiler_type_t type,
}
CompilerType TypeSystemClang::GetBuiltinTypeByName(ConstString name) {
+ StringRef name_ref = name.GetStringRef();
+ // We compile the regex only the type name fulfills certain
+ // necessary conditions. Otherwise we do not bother.
+ if (name_ref.consume_front("unsigned _BitInt(") ||
+ name_ref.consume_front("_BitInt(")) {
+ uint64_t bit_size;
+ if (name_ref.consumeInteger(/*Radix=*/10, bit_size))
+ return {};
+
+ if (!name_ref.consume_front(")"))
+ return {};
+
+ return GetType(getASTContext().getBitIntType(
+ name.GetStringRef().starts_with("unsigned"), bit_size));
+ }
return GetBasicType(GetBasicTypeEnumeration(name));
}
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..784f3e177d970 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,19 @@ 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)
+
+ self.assertFalse(self.target().FindFirstType("_BitInt"))
+ self.assertFalse(self.target().FindFirstType("unsigned _BitInt"))
+ self.assertFalse(self.target().FindFirstType("_BitInt()"))
+ self.assertFalse(self.target().FindFirstType("unsigned _BitInt()"))
+ self.assertFalse(self.target().FindFirstType("_BitInt(65"))
+ self.assertFalse(self.target().FindFirstType("unsigned _BitInt(65"))
+ self.assertFalse(self.target().FindFirstType("_BitInt(0x41)"))
+ self.assertFalse(self.target().FindFirstType("unsigned _BitInt(0x41)"))
+ 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)
More information about the llvm-branch-commits
mailing list