aboutsummaryrefslogtreecommitdiff
path: root/lldb/test/API/python_api
diff options
context:
space:
mode:
authorMichael Buch <michaelbuch12@gmail.com>2025-07-23 08:52:49 +0100
committerGitHub <noreply@github.com>2025-07-23 08:52:49 +0100
commitb7889a65a8e54f2d9c7f578a515a7bf970044bfe (patch)
tree1dd26c84ecc5f997e52edc70d63575e09cdb5746 /lldb/test/API/python_api
parent0cfea5b73cadfcf408f3549ff209fba4f56f9138 (diff)
downloadllvm-b7889a65a8e54f2d9c7f578a515a7bf970044bfe.zip
llvm-b7889a65a8e54f2d9c7f578a515a7bf970044bfe.tar.gz
llvm-b7889a65a8e54f2d9c7f578a515a7bf970044bfe.tar.bz2
[lldb][SBType] GetBasicType to unwrap canonical type (#149112)
`SBType::GetBasicType` fails on typedefs to primitive types. The docs for `GetBasicType` state: ``` Returns the BasicType value that is most appropriate to this type ``` But, e.g., for `uint64_t` this would currently return `eBasicTypeInvalid`. `TypeSystemClang::GetBasicTypeEnumeration` (which is what `SBType::GetBasicType` uses) doesn't see through typedefs. Inside LLDB we almost always call `GetBasicTypeEnumeration` on the canonical type. In the cases we don't I suspect those were just subtle bugs. This patch gets the canonical type inside of `GetBasicTypeEnumeration` instead. rdar://155829208
Diffstat (limited to 'lldb/test/API/python_api')
-rw-r--r--lldb/test/API/python_api/sbtype_basic_type/Makefile3
-rw-r--r--lldb/test/API/python_api/sbtype_basic_type/TestSBTypeBasicType.py30
-rw-r--r--lldb/test/API/python_api/sbtype_basic_type/main.cpp11
3 files changed, 44 insertions, 0 deletions
diff --git a/lldb/test/API/python_api/sbtype_basic_type/Makefile b/lldb/test/API/python_api/sbtype_basic_type/Makefile
new file mode 100644
index 0000000..99998b2
--- /dev/null
+++ b/lldb/test/API/python_api/sbtype_basic_type/Makefile
@@ -0,0 +1,3 @@
+CXX_SOURCES := main.cpp
+
+include Makefile.rules
diff --git a/lldb/test/API/python_api/sbtype_basic_type/TestSBTypeBasicType.py b/lldb/test/API/python_api/sbtype_basic_type/TestSBTypeBasicType.py
new file mode 100644
index 0000000..535d8b9
--- /dev/null
+++ b/lldb/test/API/python_api/sbtype_basic_type/TestSBTypeBasicType.py
@@ -0,0 +1,30 @@
+import lldb
+from lldbsuite.test.decorators import *
+from lldbsuite.test.lldbtest import *
+from lldbsuite.test import lldbutil
+
+
+class TestCase(TestBase):
+ def test(self):
+ """Test that SBType.GetBasicType unwraps typedefs."""
+ self.build()
+ lldbutil.run_to_source_breakpoint(self, "return", lldb.SBFileSpec("main.cpp"))
+
+ a = self.frame().FindVariable("a")
+ self.assertTrue(a)
+
+ int_basic_type = a.GetType().GetBasicType()
+ self.assertEqual(int_basic_type, 13)
+
+ b = self.frame().FindVariable("b")
+ self.assertTrue(b)
+
+ c = self.frame().FindVariable("c")
+ self.assertTrue(c)
+
+ d = self.frame().FindVariable("d")
+ self.assertTrue(d)
+
+ self.assertEqual(b.GetType().GetBasicType(), int_basic_type)
+ self.assertEqual(c.GetType().GetBasicType(), int_basic_type)
+ self.assertEqual(d.GetType().GetBasicType(), int_basic_type)
diff --git a/lldb/test/API/python_api/sbtype_basic_type/main.cpp b/lldb/test/API/python_api/sbtype_basic_type/main.cpp
new file mode 100644
index 0000000..7ded371
--- /dev/null
+++ b/lldb/test/API/python_api/sbtype_basic_type/main.cpp
@@ -0,0 +1,11 @@
+using T1 = int;
+using T2 = T1;
+using T3 = T2;
+
+int main() {
+ int a;
+ T1 b;
+ T2 c;
+ T3 d;
+ return 0;
+}