[Lldb-commits] [lldb] [llvm] [lldb] Support DW_AT_address_class on pointer types in DWARFASTParserClang (PR #230555)

Michael Buch via lldb-commits lldb-commits at lists.llvm.org
Wed Oct 28 02:05:01 PDT 2026


================
@@ -1554,3 +1554,35 @@ TEST_F(TestTypeSystemClang, TestIsMemberDataPointerType) {
   EXPECT_FALSE(int_type.IsMemberDataPointerType());
   EXPECT_FALSE(int_type.IsMemberFunctionPointerType());
 }
+
+TEST_F(TestTypeSystemClang, TestAddressSpaceModifier) {
+  CompilerType invalid_type;
+  EXPECT_EQ(invalid_type.GetTargetAddressSpace(), std::nullopt);
+  EXPECT_FALSE(m_ast->AddAddressSpaceModifier(invalid_type, 3).IsValid());
+
+  CompilerType int_type = m_ast->GetBasicType(lldb::eBasicTypeInt);
+  ASSERT_TRUE(int_type.IsValid());
+  EXPECT_EQ(int_type.GetTargetAddressSpace(), std::nullopt);
+
+  // Address space 0 is the default address space (no qualifier added).
+  CompilerType zero_as_type = m_ast->AddAddressSpaceModifier(int_type, 0);
+  EXPECT_EQ(zero_as_type.GetTargetAddressSpace(), std::nullopt);
+
+  // Qualifying with a non-zero target address space records it on the type.
+  CompilerType as3_int = m_ast->AddAddressSpaceModifier(int_type, 3);
+  ASSERT_TRUE(as3_int.IsValid());
+  EXPECT_EQ(as3_int.GetTargetAddressSpace(), std::optional<uint32_t>(3U));
+
+  // Re-qualifying an already address-space-qualified type preserves the
+  // existing address space.
+  CompilerType re_qualified = m_ast->AddAddressSpaceModifier(as3_int, 5);
+  EXPECT_EQ(re_qualified.GetTargetAddressSpace(), std::optional<uint32_t>(3U));
+
+  // A pointer to an address-space-qualified type carries the qualifier on
+  // the pointee, while the pointer itself lives in the default space.
+  CompilerType ptr_to_as3_int = as3_int.GetPointerType();
+  ASSERT_TRUE(ptr_to_as3_int.IsPointerType());
+  EXPECT_EQ(ptr_to_as3_int.GetTargetAddressSpace(), std::nullopt);
+  EXPECT_EQ(ptr_to_as3_int.GetPointeeType().GetTargetAddressSpace(),
+            std::optional<uint32_t>(3U));
+}
----------------
Michael137 wrote:

thanks, i adjusted the title too

https://github.com/llvm/llvm-project/pull/230555


More information about the lldb-commits mailing list