[Lldb-commits] [lldb] [lldb] Make sure that the "TypeSystemClang::GetBuiltinTypeByName" method returns the correct value also for "_BitInt(...)" types. (PR #165857)
https://github.com/sedymrak updated
https://github.com/llvm/llvm-project/pull/165857
From 6d4c709db9ba4895d190c96f810ea8f3ca513511 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Matej=20Ko=C5=A1=C3=ADk?=
Date: Fri, 31 Oct 2025 10:37:26 +0100
Subject: [PATCH 1/9] [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 215d22ce25553cb0a0060217c4236ca4610d8bda Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Matej=20Ko=C5=A1=C3=ADk?=
Date: Fri, 31 Oct 2025 10:37:51 +0100
Subject: [PATCH 2/9] [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 1e1b265ba195a..8fe283c3a61fc 100644
--- a/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
+++ b/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
@@ -5508,6 +5508,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 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 a31e747b46ab132bd23a1ac4a44b58ab0ff44f48 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Matej=20Ko=C5=A1=C3=ADk?=
Date: Wed, 19 Nov 2025 15:47:20 +0100
Subject: [PATCH 3/9] [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 8fe283c3a61fc..2b8618371700c 100644
--- a/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
+++ b/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
@@ -5510,7 +5510,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 matches;
+ llvm::SmallVector matches;
bool is_bitint = re.match(name_ref, &matches);
if (is_bitint && matches.size() == 3) {
bool is_unsigned = matches[1] == "unsigned ";
From dd498a02744d5470e0d2fc9ea9c4d22b77eb4d74 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Matej=20Ko=C5=A1=C3=ADk?=
Date: Wed, 19 Nov 2025 22:14:43 +0100
Subject: [PATCH 4/9] [lldb] wrap regex compilation in a conditional to avoid
unnecessary compilation of regex
---
.../TypeSystem/Clang/TypeSystemClang.cpp | 23 +++
1 file changed, 14 insertions(+), 9 deletions(-)
diff --git a/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
b/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
index 2b8618371700c..a0bb0b15a1af5 100644
--- a/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
+++ b/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
@@ -5509,15 +5509,20 @@
TypeSystemClang::GetNumChildren(lldb::opaque_compiler_type_t type,
CompilerType TypeSystem
[Lldb-commits] [lldb] [lldb] Make sure that the "TypeSystemClang::GetBuiltinTypeByName" method returns the correct value also for "_BitInt(...)" types. (PR #165857)
Matej =?utf-8?q?Košík?= , Matej =?utf-8?q?Košík?= , Matej =?utf-8?q?Košík?= , Matej =?utf-8?q?Košík?= , Matej =?utf-8?q?Košík?= , Matej =?utf-8?q?Košík?= Message-ID: In-Reply-To: https://github.com/Michael137 edited https://github.com/llvm/llvm-project/pull/165857 ___ lldb-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Make sure that the "TypeSystemClang::GetBuiltinTypeByName" method returns the correct value also for "_BitInt(...)" types. (PR #165857)
https://github.com/sedymrak updated
https://github.com/llvm/llvm-project/pull/165857
From 6d4c709db9ba4895d190c96f810ea8f3ca513511 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Matej=20Ko=C5=A1=C3=ADk?=
Date: Fri, 31 Oct 2025 10:37:26 +0100
Subject: [PATCH 1/7] [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 215d22ce25553cb0a0060217c4236ca4610d8bda Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Matej=20Ko=C5=A1=C3=ADk?=
Date: Fri, 31 Oct 2025 10:37:51 +0100
Subject: [PATCH 2/7] [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 1e1b265ba195a..8fe283c3a61fc 100644
--- a/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
+++ b/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
@@ -5508,6 +5508,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 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 a31e747b46ab132bd23a1ac4a44b58ab0ff44f48 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Matej=20Ko=C5=A1=C3=ADk?=
Date: Wed, 19 Nov 2025 15:47:20 +0100
Subject: [PATCH 3/7] [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 8fe283c3a61fc..2b8618371700c 100644
--- a/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
+++ b/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
@@ -5510,7 +5510,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 matches;
+ llvm::SmallVector matches;
bool is_bitint = re.match(name_ref, &matches);
if (is_bitint && matches.size() == 3) {
bool is_unsigned = matches[1] == "unsigned ";
From dd498a02744d5470e0d2fc9ea9c4d22b77eb4d74 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Matej=20Ko=C5=A1=C3=ADk?=
Date: Wed, 19 Nov 2025 22:14:43 +0100
Subject: [PATCH 4/7] [lldb] wrap regex compilation in a conditional to avoid
unnecessary compilation of regex
---
.../TypeSystem/Clang/TypeSystemClang.cpp | 23 +++
1 file changed, 14 insertions(+), 9 deletions(-)
diff --git a/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
b/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
index 2b8618371700c..a0bb0b15a1af5 100644
--- a/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
+++ b/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
@@ -5509,15 +5509,20 @@
TypeSystemClang::GetNumChildren(lldb::opaque_compiler_type_t type,
CompilerType TypeSystem
[Lldb-commits] [lldb] [lldb] Make sure that the "TypeSystemClang::GetBuiltinTypeByName" method returns the correct value also for "_BitInt(...)" types. (PR #165857)
Matej =?utf-8?q?Košík?= , Matej =?utf-8?q?Košík?= , Matej =?utf-8?q?Košík?= , Matej =?utf-8?q?Košík?= , Matej =?utf-8?q?Košík?= Message-ID: In-Reply-To: https://github.com/Michael137 edited https://github.com/llvm/llvm-project/pull/165857 ___ lldb-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Make sure that the "TypeSystemClang::GetBuiltinTypeByName" method returns the correct value also for "_BitInt(...)" types. (PR #165857)
Matej =?utf-8?q?Ko=C5=A1=C3=ADk?= , Matej =?utf-8?q?Ko=C5=A1=C3=ADk?= , Matej =?utf-8?q?Ko=C5=A1=C3=ADk?= , Matej =?utf-8?q?Ko=C5=A1=C3=ADk?= , Matej =?utf-8?q?Ko=C5=A1=C3=ADk?= Message-ID: In-Reply-To: https://github.com/Michael137 approved this pull request. LGTM modulo the comments on tests https://github.com/llvm/llvm-project/pull/165857 ___ lldb-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Make sure that the "TypeSystemClang::GetBuiltinTypeByName" method returns the correct value also for "_BitInt(...)" types. (PR #165857)
Matej =?utf-8?q?Košík?= ,
Matej =?utf-8?q?Košík?= ,
Matej =?utf-8?q?Košík?= ,
Matej =?utf-8?q?Košík?= ,
Matej =?utf-8?q?Košík?=
Message-ID:
In-Reply-To:
@@ -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)
Michael137 wrote:
Can we add tests for:
```
unsigned _BitInt
unsigned _BitInt(65
unsigned _BitInt(0x41)
```
These should all fail
https://github.com/llvm/llvm-project/pull/165857
___
lldb-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Make sure that the "TypeSystemClang::GetBuiltinTypeByName" method returns the correct value also for "_BitInt(...)" types. (PR #165857)
Matej =?utf-8?q?Košík?= ,
Matej =?utf-8?q?Košík?= ,
Matej =?utf-8?q?Košík?= ,
Matej =?utf-8?q?Košík?= ,
Matej =?utf-8?q?Košík?=
Message-ID:
In-Reply-To:
@@ -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.
Michael137 wrote:
Think the tests are pretty self-explanatory, so don't need the comment
```suggestion
```
https://github.com/llvm/llvm-project/pull/165857
___
lldb-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Make sure that the "TypeSystemClang::GetBuiltinTypeByName" method returns the correct value also for "_BitInt(...)" types. (PR #165857)
@@ -5508,6 +5508,22 @@
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.empty() && name_ref[0] == '_') ||
+ (name_ref.size() >= 10 && name_ref[9] == '_')) {
sedymrak wrote:
Yes. Thank you. I've pushed a commit that incorporates your advice. Ultimately,
there is no need to reach for regex machinery.
https://github.com/llvm/llvm-project/pull/165857
___
lldb-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Make sure that the "TypeSystemClang::GetBuiltinTypeByName" method returns the correct value also for "_BitInt(...)" types. (PR #165857)
https://github.com/sedymrak updated
https://github.com/llvm/llvm-project/pull/165857
From 6d4c709db9ba4895d190c96f810ea8f3ca513511 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Matej=20Ko=C5=A1=C3=ADk?=
Date: Fri, 31 Oct 2025 10:37:26 +0100
Subject: [PATCH 1/6] [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 215d22ce25553cb0a0060217c4236ca4610d8bda Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Matej=20Ko=C5=A1=C3=ADk?=
Date: Fri, 31 Oct 2025 10:37:51 +0100
Subject: [PATCH 2/6] [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 1e1b265ba195a..8fe283c3a61fc 100644
--- a/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
+++ b/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
@@ -5508,6 +5508,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 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 a31e747b46ab132bd23a1ac4a44b58ab0ff44f48 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Matej=20Ko=C5=A1=C3=ADk?=
Date: Wed, 19 Nov 2025 15:47:20 +0100
Subject: [PATCH 3/6] [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 8fe283c3a61fc..2b8618371700c 100644
--- a/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
+++ b/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
@@ -5510,7 +5510,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 matches;
+ llvm::SmallVector matches;
bool is_bitint = re.match(name_ref, &matches);
if (is_bitint && matches.size() == 3) {
bool is_unsigned = matches[1] == "unsigned ";
From dd498a02744d5470e0d2fc9ea9c4d22b77eb4d74 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Matej=20Ko=C5=A1=C3=ADk?=
Date: Wed, 19 Nov 2025 22:14:43 +0100
Subject: [PATCH 4/6] [lldb] wrap regex compilation in a conditional to avoid
unnecessary compilation of regex
---
.../TypeSystem/Clang/TypeSystemClang.cpp | 23 +++
1 file changed, 14 insertions(+), 9 deletions(-)
diff --git a/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
b/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
index 2b8618371700c..a0bb0b15a1af5 100644
--- a/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
+++ b/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
@@ -5509,15 +5509,20 @@
TypeSystemClang::GetNumChildren(lldb::opaque_compiler_type_t type,
CompilerType TypeSystem
[Lldb-commits] [lldb] [lldb] Make sure that the "TypeSystemClang::GetBuiltinTypeByName" method returns the correct value also for "_BitInt(...)" types. (PR #165857)
Matej =?utf-8?q?Košík?= , Matej =?utf-8?q?Košík?= , Matej =?utf-8?q?Košík?= , Matej =?utf-8?q?Košík?= Message-ID: In-Reply-To: https://github.com/Michael137 edited https://github.com/llvm/llvm-project/pull/165857 ___ lldb-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Make sure that the "TypeSystemClang::GetBuiltinTypeByName" method returns the correct value also for "_BitInt(...)" types. (PR #165857)
Matej =?utf-8?q?Košík?= , Matej =?utf-8?q?Košík?= , Matej =?utf-8?q?Košík?= , Matej =?utf-8?q?Košík?= Message-ID: In-Reply-To: https://github.com/Michael137 edited https://github.com/llvm/llvm-project/pull/165857 ___ lldb-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Make sure that the "TypeSystemClang::GetBuiltinTypeByName" method returns the correct value also for "_BitInt(...)" types. (PR #165857)
Matej =?utf-8?q?Košík?= ,
Matej =?utf-8?q?Košík?= ,
Matej =?utf-8?q?Košík?= ,
Matej =?utf-8?q?Košík?=
Message-ID:
In-Reply-To:
@@ -5508,6 +5508,22 @@
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.empty() && name_ref[0] == '_') ||
+ (name_ref.size() >= 10 && name_ref[9] == '_')) {
Michael137 wrote:
Can we just do the following?
```
if (name_ref.consume_front("unsigned _BitInt") ||
name_ref.consume_front("_BitInt")) {
const bool is_unsigned = name.GetStringRef().starts_with("unsigned");
...
}
```
https://github.com/llvm/llvm-project/pull/165857
___
lldb-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Make sure that the "TypeSystemClang::GetBuiltinTypeByName" method returns the correct value also for "_BitInt(...)" types. (PR #165857)
https://github.com/sedymrak updated
https://github.com/llvm/llvm-project/pull/165857
From 6d4c709db9ba4895d190c96f810ea8f3ca513511 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Matej=20Ko=C5=A1=C3=ADk?=
Date: Fri, 31 Oct 2025 10:37:26 +0100
Subject: [PATCH 1/5] [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 215d22ce25553cb0a0060217c4236ca4610d8bda Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Matej=20Ko=C5=A1=C3=ADk?=
Date: Fri, 31 Oct 2025 10:37:51 +0100
Subject: [PATCH 2/5] [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 1e1b265ba195a..8fe283c3a61fc 100644
--- a/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
+++ b/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
@@ -5508,6 +5508,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 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 a31e747b46ab132bd23a1ac4a44b58ab0ff44f48 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Matej=20Ko=C5=A1=C3=ADk?=
Date: Wed, 19 Nov 2025 15:47:20 +0100
Subject: [PATCH 3/5] [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 8fe283c3a61fc..2b8618371700c 100644
--- a/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
+++ b/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
@@ -5510,7 +5510,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 matches;
+ llvm::SmallVector matches;
bool is_bitint = re.match(name_ref, &matches);
if (is_bitint && matches.size() == 3) {
bool is_unsigned = matches[1] == "unsigned ";
From dd498a02744d5470e0d2fc9ea9c4d22b77eb4d74 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Matej=20Ko=C5=A1=C3=ADk?=
Date: Wed, 19 Nov 2025 22:14:43 +0100
Subject: [PATCH 4/5] [lldb] wrap regex compilation in a conditional to avoid
unnecessary compilation of regex
---
.../TypeSystem/Clang/TypeSystemClang.cpp | 23 +++
1 file changed, 14 insertions(+), 9 deletions(-)
diff --git a/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
b/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
index 2b8618371700c..a0bb0b15a1af5 100644
--- a/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
+++ b/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
@@ -5509,15 +5509,20 @@
TypeSystemClang::GetNumChildren(lldb::opaque_compiler_type_t type,
CompilerType TypeSystem
[Lldb-commits] [lldb] [lldb] Make sure that the "TypeSystemClang::GetBuiltinTypeByName" method returns the correct value also for "_BitInt(...)" types. (PR #165857)
https://github.com/sedymrak updated
https://github.com/llvm/llvm-project/pull/165857
From 6d4c709db9ba4895d190c96f810ea8f3ca513511 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Matej=20Ko=C5=A1=C3=ADk?=
Date: Fri, 31 Oct 2025 10:37:26 +0100
Subject: [PATCH 1/4] [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 215d22ce25553cb0a0060217c4236ca4610d8bda Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Matej=20Ko=C5=A1=C3=ADk?=
Date: Fri, 31 Oct 2025 10:37:51 +0100
Subject: [PATCH 2/4] [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 1e1b265ba195a..8fe283c3a61fc 100644
--- a/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
+++ b/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
@@ -5508,6 +5508,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 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 a31e747b46ab132bd23a1ac4a44b58ab0ff44f48 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Matej=20Ko=C5=A1=C3=ADk?=
Date: Wed, 19 Nov 2025 15:47:20 +0100
Subject: [PATCH 3/4] [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 8fe283c3a61fc..2b8618371700c 100644
--- a/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
+++ b/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
@@ -5510,7 +5510,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 matches;
+ llvm::SmallVector matches;
bool is_bitint = re.match(name_ref, &matches);
if (is_bitint && matches.size() == 3) {
bool is_unsigned = matches[1] == "unsigned ";
From dd498a02744d5470e0d2fc9ea9c4d22b77eb4d74 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Matej=20Ko=C5=A1=C3=ADk?=
Date: Wed, 19 Nov 2025 22:14:43 +0100
Subject: [PATCH 4/4] [lldb] wrap regex compilation in a conditional to avoid
unnecessary compilation of regex
---
.../TypeSystem/Clang/TypeSystemClang.cpp | 23 +++
1 file changed, 14 insertions(+), 9 deletions(-)
diff --git a/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
b/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
index 2b8618371700c..a0bb0b15a1af5 100644
--- a/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
+++ b/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
@@ -5509,15 +5509,20 @@
TypeSystemClang::GetNumChildren(lldb::opaque_compiler_type_t type,
CompilerType TypeSystem
[Lldb-commits] [lldb] [lldb] Make sure that the "TypeSystemClang::GetBuiltinTypeByName" method returns the correct value also for "_BitInt(...)" types. (PR #165857)
https://github.com/sedymrak updated
https://github.com/llvm/llvm-project/pull/165857
From 7ce461e04700d159ee9b74fafb00dfe6bd0d1021 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Matej=20Ko=C5=A1=C3=ADk?=
Date: Fri, 31 Oct 2025 10:37:26 +0100
Subject: [PATCH 1/4] [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 8df59f7c6dabb2014916d200d7808f6948978cf6 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Matej=20Ko=C5=A1=C3=ADk?=
Date: Fri, 31 Oct 2025 10:37:51 +0100
Subject: [PATCH 2/4] [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 51cb883748514..014899cb57974 100644
--- a/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
+++ b/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
@@ -5506,6 +5506,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 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 a128f9577b1e1a67f3b6394cc8972f8337183a86 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Matej=20Ko=C5=A1=C3=ADk?=
Date: Wed, 19 Nov 2025 15:47:20 +0100
Subject: [PATCH 3/4] [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 014899cb57974..e167609d74006 100644
--- a/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
+++ b/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
@@ -5508,7 +5508,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 matches;
+ llvm::SmallVector matches;
bool is_bitint = re.match(name_ref, &matches);
if (is_bitint && matches.size() == 3) {
bool is_unsigned = matches[1] == "unsigned ";
From 87a243b530b30a92fd99511c787f1ea00616efde Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Matej=20Ko=C5=A1=C3=ADk?=
Date: Wed, 19 Nov 2025 22:14:43 +0100
Subject: [PATCH 4/4] [lldb] wrap regex compilation in a conditional to avoid
unnecessary compilation of regex
---
.../TypeSystem/Clang/TypeSystemClang.cpp | 23 +++
1 file changed, 14 insertions(+), 9 deletions(-)
diff --git a/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
b/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
index e167609d74006..a10b5013f0eeb 100644
--- a/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
+++ b/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
@@ -5507,15 +5507,20 @@
TypeSystemClang::GetNumChildren(lldb::opaque_compiler_type_t type,
CompilerType TypeSystem
[Lldb-commits] [lldb] [lldb] Make sure that the "TypeSystemClang::GetBuiltinTypeByName" method returns the correct value also for "_BitInt(...)" types. (PR #165857)
https://github.com/sedymrak updated
https://github.com/llvm/llvm-project/pull/165857
From 7ce461e04700d159ee9b74fafb00dfe6bd0d1021 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Matej=20Ko=C5=A1=C3=ADk?=
Date: Fri, 31 Oct 2025 10:37:26 +0100
Subject: [PATCH 1/5] [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 8df59f7c6dabb2014916d200d7808f6948978cf6 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Matej=20Ko=C5=A1=C3=ADk?=
Date: Fri, 31 Oct 2025 10:37:51 +0100
Subject: [PATCH 2/5] [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 51cb883748514..014899cb57974 100644
--- a/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
+++ b/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
@@ -5506,6 +5506,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 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 a128f9577b1e1a67f3b6394cc8972f8337183a86 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Matej=20Ko=C5=A1=C3=ADk?=
Date: Wed, 19 Nov 2025 15:47:20 +0100
Subject: [PATCH 3/5] [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 014899cb57974..e167609d74006 100644
--- a/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
+++ b/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
@@ -5508,7 +5508,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 matches;
+ llvm::SmallVector matches;
bool is_bitint = re.match(name_ref, &matches);
if (is_bitint && matches.size() == 3) {
bool is_unsigned = matches[1] == "unsigned ";
From 410b471357909722accf146927ab66ad97de984c Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Matej=20Ko=C5=A1=C3=ADk?=
Date: Wed, 19 Nov 2025 22:14:43 +0100
Subject: [PATCH 4/5] [lldb] wrap regex compilation in a conditional to avoid
unnecessary compilation of regex
---
.../TypeSystem/Clang/TypeSystemClang.cpp | 20 ++-
1 file changed, 11 insertions(+), 9 deletions(-)
diff --git a/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
b/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
index e167609d74006..68a657f5dbf97 100644
--- a/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
+++ b/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
@@ -5507,15 +5507,17 @@
TypeSystemClang::GetNumChildren(lldb::opaque_compiler_type_t type,
CompilerType TypeSystem
[Lldb-commits] [lldb] [lldb] Make sure that the "TypeSystemClang::GetBuiltinTypeByName" method returns the correct value also for "_BitInt(...)" types. (PR #165857)
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?=
Date: Fri, 31 Oct 2025 10:37:26 +0100
Subject: [PATCH 1/5] [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?=
Date: Fri, 31 Oct 2025 10:37:51 +0100
Subject: [PATCH 2/5] [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 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?=
Date: Wed, 19 Nov 2025 15:47:20 +0100
Subject: [PATCH 3/5] [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 matches;
+ llvm::SmallVector matches;
bool is_bitint = re.match(name_ref, &matches);
if (is_bitint && matches.size() == 3) {
bool is_unsigned = matches[1] == "unsigned ";
From 6ac8e0be133a9d9f694c47fd627eb0296a63815c Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Matej=20Ko=C5=A1=C3=ADk?=
Date: Wed, 19 Nov 2025 22:14:43 +0100
Subject: [PATCH 4/5] [lldb] wrap regex compilation in a conditional to avoid
unnecessary compilation of regex
---
.../TypeSystem/Clang/TypeSystemClang.cpp | 20 ++-
1 file changed, 11 insertions(+), 9 deletions(-)
diff --git a/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
b/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
index 6d23a0115805d..39000aec4425e 100644
--- a/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
+++ b/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
@@ -5499,15 +5499,17 @@
TypeSystemClang::GetNumChildren(lldb::opaque_compiler_type_t type,
CompilerType TypeSystem
[Lldb-commits] [lldb] [lldb] Make sure that the "TypeSystemClang::GetBuiltinTypeByName" method returns the correct value also for "_BitInt(...)" types. (PR #165857)
Matej =?utf-8?q?Košík?= ,
Matej =?utf-8?q?Košík?=
Message-ID:
In-Reply-To:
@@ -5495,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\\((.*)\\)$");
adrian-prantl wrote:
Should we wrap this in a `if (!name_ref.empty() && (name_ref[0] == '_' ||
name_ref[0] == '(')` to avoid compiling the regex every time?
https://github.com/llvm/llvm-project/pull/165857
___
lldb-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Make sure that the "TypeSystemClang::GetBuiltinTypeByName" method returns the correct value also for "_BitInt(...)" types. (PR #165857)
Matej =?utf-8?q?Ko=C5=A1=C3=ADk?= , Matej =?utf-8?q?Ko=C5=A1=C3=ADk?= Message-ID: In-Reply-To: github-actions[bot] wrote: # :penguin: Linux x64 Test Results * 33167 tests passed * 490 tests skipped https://github.com/llvm/llvm-project/pull/165857 ___ lldb-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Make sure that the "TypeSystemClang::GetBuiltinTypeByName" method returns the correct value also for "_BitInt(...)" types. (PR #165857)
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?=
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?=
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 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?=
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 matches;
+ llvm::SmallVector matches;
bool is_bitint = re.match(name_ref, &matches);
if (is_bitint && matches.size() == 3) {
bool is_unsigned = matches[1] == "unsigned ";
___
lldb-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Make sure that the "TypeSystemClang::GetBuiltinTypeByName" method returns the correct value also for "_BitInt(...)" types. (PR #165857)
https://github.com/sedymrak edited https://github.com/llvm/llvm-project/pull/165857 ___ lldb-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
