[llvm-branch-commits] [lldb] 27d93bc - Revert "[lldb][DWARFASTParserClang] Handle pointer-to-member-data non-type te…"

via llvm-branch-commits llvm-branch-commits at lists.llvm.org
Thu Mar 26 06:25:27 PDT 2026


Author: Michael Buch
Date: 2026-03-26T13:25:20Z
New Revision: 27d93bcb928ac7333c2f6e87b010b3fa071f794b

URL: https://github.com/llvm/llvm-project/commit/27d93bcb928ac7333c2f6e87b010b3fa071f794b
DIFF: https://github.com/llvm/llvm-project/commit/27d93bcb928ac7333c2f6e87b010b3fa071f794b.diff

LOG: Revert "[lldb][DWARFASTParserClang] Handle pointer-to-member-data non-type te…"

This reverts commit 303afa0899357b21a6a325115068108aa5e71a4f.

Added: 
    

Modified: 
    lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp
    lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.h

Removed: 
    lldb/test/API/lang/cpp/non-type-template-param-member-ptr/Makefile
    lldb/test/API/lang/cpp/non-type-template-param-member-ptr/TestCppNonTypeTemplateParamPtrToMember.py
    lldb/test/API/lang/cpp/non-type-template-param-member-ptr/main.cpp


################################################################################
diff  --git a/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp b/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp
index 6701bdc3e50b6..cb33fc21bfba9 100644
--- a/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp
+++ b/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp
@@ -2008,94 +2008,28 @@ class DWARFASTParserClang::DelayedAddObjCClassProperty {
 
 static std::optional<clang::APValue> MakeAPValue(const clang::ASTContext &ast,
                                                  CompilerType clang_type,
-                                                 uint64_t value,
-                                                 const DWARFDIE &die) {
+                                                 uint64_t value) {
   std::optional<uint64_t> bit_width =
       llvm::expectedToOptional(clang_type.GetBitSize(nullptr));
   if (!bit_width)
     return std::nullopt;
 
   bool is_signed = false;
+  const bool is_integral = clang_type.IsIntegerOrEnumerationType(is_signed);
 
-  if (clang_type.IsIntegerOrEnumerationType(is_signed) ||
-      clang_type.IsMemberDataPointerType()) {
-    llvm::APSInt apint(*bit_width, !is_signed);
-    apint = value;
+  llvm::APSInt apint(*bit_width, !is_signed);
+  apint = value;
+
+  if (is_integral)
     return clang::APValue(apint);
-  }
 
   // FIXME: we currently support a limited set of floating point types.
   // E.g., 16-bit floats are not supported.
-  if (clang_type.IsRealFloatingPointType()) {
-    llvm::APInt apint(*bit_width, value);
-    return clang::APValue(llvm::APFloat(
-        ast.getFloatTypeSemantics(ClangUtil::GetQualType(clang_type)), apint));
-  }
-
-  die.GetDWARF()->GetObjectFile()->GetModule()->ReportError(
-      "error: unsupported template value type in die {0:x16}, "
-      "please file a bug",
-      die.GetOffset());
-  lldbassert(false && "Unsupported type for non-type template parameter");
-
-  return std::nullopt;
-}
-
-clang::FieldDecl *DWARFASTParserClang::ResolveMemberDataPointerToFieldDecl(
-    const DWARFDIE &die, uint64_t member_byte_offset) {
-  Log *log = GetLog(DWARFLog::TypeCompletion);
-
-  DWARFDIE type_die = die.GetReferencedDIE(DW_AT_type);
-  assert(type_die && type_die.Tag() == DW_TAG_ptr_to_member_type &&
-         "DW_AT_type of a member data pointer must be "
-         "DW_TAG_ptr_to_member_type");
-
-  DWARFDIE containing_die = type_die.GetReferencedDIE(DW_AT_containing_type);
-  if (!containing_die) {
-    LLDB_LOG(log,
-             "ResolveMemberDataPointerToFieldDecl: DIE {0:x16} — "
-             "DW_TAG_ptr_to_member_type {1:x16} has no DW_AT_containing_type",
-             die.GetOffset(), type_die.GetOffset());
-    return nullptr;
-  }
-
-  Type *containing_type = die.ResolveTypeUID(containing_die);
-  if (!containing_type) {
-    LLDB_LOG(log,
-             "ResolveMemberDataPointerToFieldDecl: DIE {0:x16} — "
-             "failed to resolve containing type {1:x16}",
-             die.GetOffset(), containing_die.GetOffset());
-    return nullptr;
-  }
-
-  CompilerType containing_ct = containing_type->GetFullCompilerType();
-  auto *record_decl =
-      m_ast.GetAsCXXRecordDecl(containing_ct.GetOpaqueQualType());
-  if (!record_decl) {
-    LLDB_LOG(log,
-             "ResolveMemberDataPointerToFieldDecl: DIE {0:x16} — "
-             "containing type {1:x16} is not a CXXRecordDecl",
-             die.GetOffset(), containing_die.GetOffset());
-    return nullptr;
-  }
-
-  clang::ASTContext &ast = m_ast.getASTContext();
-  for (auto *field : record_decl->fields()) {
-    if (ast.getFieldOffset(field) / 8 == member_byte_offset) {
-      LLDB_LOG(log,
-               "ResolveMemberDataPointerToFieldDecl: DIE {0:x16} — "
-               "resolved to field '{1}' at byte offset {2} in {3}",
-               die.GetOffset(), field->getName(), member_byte_offset,
-               containing_die.GetName());
-      return field;
-    }
-  }
+  if (!clang_type.IsRealFloatingPointType())
+    return std::nullopt;
 
-  LLDB_LOG(log,
-           "ResolveMemberDataPointerToFieldDecl: DIE {0:x16} — "
-           "no field found at byte offset {1} in {2}",
-           die.GetOffset(), member_byte_offset, containing_die.GetName());
-  return nullptr;
+  return clang::APValue(llvm::APFloat(
+      ast.getFloatTypeSemantics(ClangUtil::GetQualType(clang_type)), apint));
 }
 
 bool DWARFASTParserClang::ParseTemplateDIE(
@@ -2180,24 +2114,7 @@ bool DWARFASTParserClang::ParseTemplateDIE(
         name = nullptr;
 
       if (tag == DW_TAG_template_value_parameter && uval64_valid) {
-        if (auto value = MakeAPValue(ast, clang_type, uval64, die)) {
-          // For pointer-to-member types, try to resolve to the actual FieldDecl
-          if (clang_type.IsMemberDataPointerType()) {
-            if (auto *field =
-                    ResolveMemberDataPointerToFieldDecl(die, uval64)) {
-              template_param_infos.InsertArg(
-                  name, clang::TemplateArgument(
-                            field, ClangUtil::GetQualType(clang_type),
-                            is_default_template_arg));
-              return true;
-            }
-            // Failed to resolve FieldDecl, fall through to integer path
-            die.GetDWARF()->GetObjectFile()->GetModule()->ReportError(
-                "error: failed to resolve member data pointer to FieldDecl "
-                "in die {0:x16}, please file a bug",
-                die.GetOffset());
-          }
-
+        if (auto value = MakeAPValue(ast, clang_type, uval64)) {
           template_param_infos.InsertArg(
               name, clang::TemplateArgument(
                         ast, ClangUtil::GetQualType(clang_type),

diff  --git a/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.h b/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.h
index ca76bcdc4ace2..03c431c73fb6f 100644
--- a/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.h
+++ b/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.h
@@ -185,13 +185,6 @@ class DWARFASTParserClang : public lldb_private::plugin::dwarf::DWARFASTParser {
                         lldb_private::TypeSystemClang::TemplateParameterInfos
                             &template_param_infos);
 
-  /// Given a DW_TAG_template_value_parameter DIE whose type is a
-  /// pointer-to-data-member, follow the DWARF chain to find the FieldDecl
-  /// at the given byte offset within the containing class.
-  clang::FieldDecl *ResolveMemberDataPointerToFieldDecl(
-      const lldb_private::plugin::dwarf::DWARFDIE &die,
-      uint64_t member_byte_offset);
-
   bool ParseTemplateParameterInfos(
       const lldb_private::plugin::dwarf::DWARFDIE &parent_die,
       lldb_private::TypeSystemClang::TemplateParameterInfos

diff  --git a/lldb/test/API/lang/cpp/non-type-template-param-member-ptr/Makefile b/lldb/test/API/lang/cpp/non-type-template-param-member-ptr/Makefile
deleted file mode 100644
index 99998b20bcb05..0000000000000
--- a/lldb/test/API/lang/cpp/non-type-template-param-member-ptr/Makefile
+++ /dev/null
@@ -1,3 +0,0 @@
-CXX_SOURCES := main.cpp
-
-include Makefile.rules

diff  --git a/lldb/test/API/lang/cpp/non-type-template-param-member-ptr/TestCppNonTypeTemplateParamPtrToMember.py b/lldb/test/API/lang/cpp/non-type-template-param-member-ptr/TestCppNonTypeTemplateParamPtrToMember.py
deleted file mode 100644
index 2133c58aeb8a5..0000000000000
--- a/lldb/test/API/lang/cpp/non-type-template-param-member-ptr/TestCppNonTypeTemplateParamPtrToMember.py
+++ /dev/null
@@ -1,14 +0,0 @@
-import lldb
-from lldbsuite.test.decorators import *
-from lldbsuite.test.lldbtest import *
-from lldbsuite.test import lldbutil
-
-
-class TestCase(TestBase):
-    def test_member_data_pointer(self):
-        """Member data pointer NTTPs: MemberData<&S::x> vs MemberData<&S::y>"""
-        self.build()
-        self.dbg.CreateTarget(self.getBuildArtifact("a.out"))
-        # Both must be resolvable as distinct specializations.
-        self.expect_expr("md1", result_type="MemberData<&S::x>")
-        self.expect_expr("md2", result_type="MemberData<&S::y>")

diff  --git a/lldb/test/API/lang/cpp/non-type-template-param-member-ptr/main.cpp b/lldb/test/API/lang/cpp/non-type-template-param-member-ptr/main.cpp
deleted file mode 100644
index 3de9c024c82f9..0000000000000
--- a/lldb/test/API/lang/cpp/non-type-template-param-member-ptr/main.cpp
+++ /dev/null
@@ -1,16 +0,0 @@
-struct S {
-  int x;
-  int y;
-};
-
-// --- Member data pointer NTTP ---
-template <int S::*P> struct MemberData {
-  int get(S &s) { return s.*P; }
-};
-MemberData<&S::x> md1;
-MemberData<&S::y> md2;
-
-int main() {
-  S s{1, 2};
-  return md1.get(s) + md2.get(s);
-}


        


More information about the llvm-branch-commits mailing list