[Lldb-commits] [lldb] [lldb][DWARFASTParserClang] GetCXXObjectParameter to take DeclContext DIE parameter (PR #144876)
Michael Buch via lldb-commits
lldb-commits at lists.llvm.org
Thu Jun 19 04:18:06 PDT 2025
https://github.com/Michael137 created https://github.com/llvm/llvm-project/pull/144876
I'm trying to call `GetCXXObjectParameter` from unit-tests in a follow-up patch and taking a `DWARFDIE` instead of `clang::DeclContext` makes that much simpler. These should be equivalent, since all we're trying to check is that the parent context is a record type.
>From bda770fa0bd47fc0ac64189f5e25a9b820051d8c Mon Sep 17 00:00:00 2001
From: Michael Buch <michaelbuch12 at gmail.com>
Date: Thu, 19 Jun 2025 12:11:32 +0100
Subject: [PATCH] [lldb][DWARFASTParserClang] GetCXXObjectParameter to take
DeclContext DIE parameter
I'm trying to call `GetCXXObjectParameter` from unit-tests in a
follow-up patch and taking a `DWARFDIE` instead of `clang::DeclContext`
makes that much simpler. These should be equivalent, since all we're
trying to check is that the parent context is a record type.
---
.../SymbolFile/DWARF/DWARFASTParserClang.cpp | 18 +++++++++---------
1 file changed, 9 insertions(+), 9 deletions(-)
diff --git a/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp b/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp
index 620501b304e63..7fc1d70898d1d 100644
--- a/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp
+++ b/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp
@@ -163,14 +163,14 @@ static bool TagIsRecordType(dw_tag_t tag) {
/// a default DWARFDIE. If \c containing_decl_ctx is not a valid
/// C++ declaration context for class methods, assume no object
/// parameter exists for the given \c subprogram.
-static DWARFDIE
-GetCXXObjectParameter(const DWARFDIE &subprogram,
- const clang::DeclContext &containing_decl_ctx) {
+static DWARFDIE GetCXXObjectParameter(const DWARFDIE &subprogram,
+ const DWARFDIE &decl_ctx_die) {
+ assert(subprogram);
assert(subprogram.Tag() == DW_TAG_subprogram ||
subprogram.Tag() == DW_TAG_inlined_subroutine ||
subprogram.Tag() == DW_TAG_subroutine_type);
- if (!DeclKindIsCXXClass(containing_decl_ctx.getDeclKind()))
+ if (!decl_ctx_die.IsStructUnionOrClass())
return {};
if (DWARFDIE object_parameter =
@@ -1304,8 +1304,7 @@ DWARFASTParserClang::ParseSubroutine(const DWARFDIE &die,
clang::CallingConv calling_convention =
ConvertDWARFCallingConventionToClang(attrs);
- const DWARFDIE object_parameter =
- GetCXXObjectParameter(die, *containing_decl_ctx);
+ const DWARFDIE object_parameter = GetCXXObjectParameter(die, decl_ctx_die);
// clang_type will get the function prototype clang type after this
// call
@@ -2411,12 +2410,13 @@ DWARFASTParserClang::ConstructDemangledNameFromDWARF(const DWARFDIE &die) {
DWARFDeclContext decl_ctx = die.GetDWARFDeclContext();
sstr << decl_ctx.GetQualifiedName();
+ DWARFDIE decl_ctx_die;
clang::DeclContext *containing_decl_ctx =
- GetClangDeclContextContainingDIE(die, nullptr);
+ GetClangDeclContextContainingDIE(die, &decl_ctx_die);
assert(containing_decl_ctx);
- const unsigned cv_quals = GetCXXMethodCVQuals(
- die, GetCXXObjectParameter(die, *containing_decl_ctx));
+ const unsigned cv_quals =
+ GetCXXMethodCVQuals(die, GetCXXObjectParameter(die, decl_ctx_die));
ParseChildParameters(containing_decl_ctx, die, is_variadic,
has_template_params, param_types, param_names);
More information about the lldb-commits
mailing list