Skip to content

[lldb][DWARFASTParserClang] DWARFv5: support DW_TAG_variable static data members declarations #72236

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged

Conversation

Michael137
Copy link
Member

@Michael137 Michael137 commented Nov 14, 2023

The accepted DWARFv5 issue 161118.1: "DW_TAG for C++ static data members" specifies that static data member declaration be described by DW_TAG_variable. Make sure we recognize such members.

Depends on:

…ata members

The accepted DWARFv5 issue 161118.1: "DW_TAG for C++ static data members"
specifies that static data member declaration be described
by DW_TAG_variable. Make sure we recognize such members.
@llvmbot
Copy link
Member

llvmbot commented Nov 14, 2023

@llvm/pr-subscribers-lldb

Author: Michael Buch (Michael137)

Changes

The accepted DWARFv5 issue 161118.1: "DW_TAG for C++ static data members" specifies that static data member declaration be described by DW_TAG_variable. Make sure we recognize such members.


Full diff: https://github.com/llvm/llvm-project/pull/72236.diff

1 Files Affected:

  • (modified) lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp (+6-2)
diff --git a/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp b/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp
index f5628b2753da2a7..79d3199855e1be7 100644
--- a/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp
+++ b/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp
@@ -144,7 +144,7 @@ static bool ShouldIgnoreArtificialField(llvm::StringRef FieldName) {
 
 std::optional<DWARFFormValue>
 DWARFASTParserClang::FindConstantOnVariableDefinition(DWARFDIE die) {
-  assert(die.Tag() == llvm::dwarf::DW_TAG_member);
+  assert(die.Tag() == DW_TAG_member || die.Tag() == DW_TAG_variable);
 
   auto *dwarf = die.GetDWARF();
   if (!dwarf)
@@ -2889,7 +2889,7 @@ void DWARFASTParserClang::CreateStaticMemberVariable(
     const DWARFDIE &die, const MemberAttributes &attrs,
     const lldb_private::CompilerType &class_clang_type) {
   Log *log = GetLog(DWARFLog::TypeCompletion | DWARFLog::Lookups);
-  assert(die.Tag() == DW_TAG_member);
+  assert(die.Tag() == DW_TAG_member || die.Tag() == DW_TAG_variable);
 
   Type *var_type = die.ResolveTypeUID(attrs.encoding_form.Reference());
 
@@ -3195,6 +3195,10 @@ bool DWARFASTParserClang::ParseChildMembers(
       }
       break;
 
+    case DW_TAG_variable: {
+      const MemberAttributes attrs(die, parent_die, module_sp);
+      CreateStaticMemberVariable(die, attrs, class_clang_type);
+    } break;
     case DW_TAG_member:
       ParseSingleMember(die, parent_die, class_clang_type,
                         default_accessibility, layout_info, last_field_info);

@Michael137 Michael137 merged commit 35b10ac into llvm:main Nov 15, 2023
@@ -2965,6 +2965,7 @@ void DWARFASTParserClang::ParseSingleMember(
// data members is DW_AT_declaration, so we check it instead.
// FIXME: Since DWARFv5, static data members are marked DW_AT_variable so we
// can consistently detect them on both GCC and Clang without below heuristic.
// Remove this block if we ever drop DWARFv4 support.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

FWIW this seems extremely unlikely. It doesn't really matter, but I would've just said that the next block is specific to DWARF4.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Clarified here: #72495

zahiraam pushed a commit to zahiraam/llvm-project that referenced this pull request Nov 20, 2023
…ata members declarations (llvm#72236)

The accepted DWARFv5 issue 161118.1: "DW_TAG for C++ static data
members" specifies that static data member declaration be described by
DW_TAG_variable. Make sure we recognize such members.

Depends on:
* llvm#72234
* llvm#72235
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants