Skip to content

Commit c501bf4

Browse files
committed
Revert "[lldb][DWARFASTParserClang] Make MemberAttributes const when parsing member DIEs (#71921)"
This reverts commit 576f7cc. Causes build bot failure because new code started depending on the non-constness of the MemberAttributes.
1 parent 9d58748 commit c501bf4

File tree

1 file changed

+21
-15
lines changed

1 file changed

+21
-15
lines changed

lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp

Lines changed: 21 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -2926,7 +2926,15 @@ void DWARFASTParserClang::ParseSingleMember(
29262926
const uint64_t parent_bit_size =
29272927
parent_byte_size == UINT64_MAX ? UINT64_MAX : parent_byte_size * 8;
29282928

2929-
const MemberAttributes attrs(die, parent_die, module_sp);
2929+
// FIXME: Remove the workarounds below and make this const.
2930+
MemberAttributes attrs(die, parent_die, module_sp);
2931+
2932+
const bool class_is_objc_object_or_interface =
2933+
TypeSystemClang::IsObjCObjectOrInterfaceType(class_clang_type);
2934+
2935+
// FIXME: Make Clang ignore Objective-C accessibility for expressions
2936+
if (class_is_objc_object_or_interface)
2937+
attrs.accessibility = eAccessNone;
29302938

29312939
// Handle static members, which are typically members without
29322940
// locations. However, GCC doesn't emit DW_AT_data_member_location
@@ -2941,13 +2949,13 @@ void DWARFASTParserClang::ParseSingleMember(
29412949
if (attrs.member_byte_offset == UINT32_MAX &&
29422950
attrs.data_bit_offset == UINT64_MAX && attrs.is_declaration) {
29432951
Type *var_type = die.ResolveTypeUID(attrs.encoding_form.Reference());
2952+
29442953
if (var_type) {
2945-
const auto accessibility = attrs.accessibility == eAccessNone
2946-
? eAccessPublic
2947-
: attrs.accessibility;
2954+
if (attrs.accessibility == eAccessNone)
2955+
attrs.accessibility = eAccessPublic;
29482956
CompilerType ct = var_type->GetForwardCompilerType();
29492957
clang::VarDecl *v = TypeSystemClang::AddVariableToRecordType(
2950-
class_clang_type, attrs.name, ct, accessibility);
2958+
class_clang_type, attrs.name, ct, attrs.accessibility);
29512959
if (!v) {
29522960
LLDB_LOG(log, "Failed to add variable to the record type");
29532961
return;
@@ -3003,9 +3011,8 @@ void DWARFASTParserClang::ParseSingleMember(
30033011
const uint64_t word_width = 32;
30043012
CompilerType member_clang_type = member_type->GetLayoutCompilerType();
30053013

3006-
const auto accessibility = attrs.accessibility == eAccessNone
3007-
? default_accessibility
3008-
: attrs.accessibility;
3014+
if (attrs.accessibility == eAccessNone)
3015+
attrs.accessibility = default_accessibility;
30093016

30103017
uint64_t field_bit_offset = (attrs.member_byte_offset == UINT32_MAX
30113018
? 0
@@ -3019,13 +3026,12 @@ void DWARFASTParserClang::ParseSingleMember(
30193026
if (attrs.data_bit_offset != UINT64_MAX) {
30203027
this_field_info.bit_offset = attrs.data_bit_offset;
30213028
} else {
3022-
auto byte_size = attrs.byte_size;
3023-
if (!byte_size)
3024-
byte_size = member_type->GetByteSize(nullptr);
3029+
if (!attrs.byte_size)
3030+
attrs.byte_size = member_type->GetByteSize(nullptr);
30253031

30263032
ObjectFile *objfile = die.GetDWARF()->GetObjectFile();
30273033
if (objfile->GetByteOrder() == eByteOrderLittle) {
3028-
this_field_info.bit_offset += byte_size.value_or(0) * 8;
3034+
this_field_info.bit_offset += attrs.byte_size.value_or(0) * 8;
30293035
this_field_info.bit_offset -= (attrs.bit_offset + attrs.bit_size);
30303036
} else {
30313037
this_field_info.bit_offset += attrs.bit_offset;
@@ -3064,7 +3070,7 @@ void DWARFASTParserClang::ParseSingleMember(
30643070
// unnamed bitfields if we have a new enough clang.
30653071
bool detect_unnamed_bitfields = true;
30663072

3067-
if (TypeSystemClang::IsObjCObjectOrInterfaceType(class_clang_type))
3073+
if (class_is_objc_object_or_interface)
30683074
detect_unnamed_bitfields =
30693075
die.GetCU()->Supports_unnamed_objc_bitfields();
30703076

@@ -3096,7 +3102,7 @@ void DWARFASTParserClang::ParseSingleMember(
30963102
class_clang_type, llvm::StringRef(),
30973103
m_ast.GetBuiltinTypeForEncodingAndBitSize(eEncodingSint,
30983104
word_width),
3099-
accessibility, unnamed_field_info->bit_size);
3105+
attrs.accessibility, unnamed_field_info->bit_size);
31003106

31013107
layout_info.field_offsets.insert(std::make_pair(
31023108
unnamed_bitfield_decl, unnamed_field_info->bit_offset));
@@ -3166,7 +3172,7 @@ void DWARFASTParserClang::ParseSingleMember(
31663172
TypeSystemClang::RequireCompleteType(member_clang_type);
31673173

31683174
clang::FieldDecl *field_decl = TypeSystemClang::AddFieldToRecordType(
3169-
class_clang_type, attrs.name, member_clang_type, accessibility,
3175+
class_clang_type, attrs.name, member_clang_type, attrs.accessibility,
31703176
attrs.bit_size);
31713177

31723178
m_ast.SetMetadataAsUserID(field_decl, die.GetID());

0 commit comments

Comments
 (0)