[Lldb-commits] [lldb] [lldb] Support DW_AT_address_class in DWARFASTParserClang (PR #230555)

Michael Buch via lldb-commits lldb-commits at lists.llvm.org
Sun Oct 18 06:03:40 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:

You're only testing `DW_AT_address_class` on pointer types.

But it can also appear on:
* rvavlue reference type
* reference type
* subprograms
* member function pointers
* member data pointers (?)

Could you update the PR description stating you're not handling these. You could also add tests for those that currently don't work, and once you add support for them you can adjust them as needed.

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


More information about the lldb-commits mailing list