@@ -2926,7 +2926,15 @@ void DWARFASTParserClang::ParseSingleMember(
2926
2926
const uint64_t parent_bit_size =
2927
2927
parent_byte_size == UINT64_MAX ? UINT64_MAX : parent_byte_size * 8 ;
2928
2928
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;
2930
2938
2931
2939
// Handle static members, which are typically members without
2932
2940
// locations. However, GCC doesn't emit DW_AT_data_member_location
@@ -2941,13 +2949,13 @@ void DWARFASTParserClang::ParseSingleMember(
2941
2949
if (attrs.member_byte_offset == UINT32_MAX &&
2942
2950
attrs.data_bit_offset == UINT64_MAX && attrs.is_declaration ) {
2943
2951
Type *var_type = die.ResolveTypeUID (attrs.encoding_form .Reference ());
2952
+
2944
2953
if (var_type) {
2945
- const auto accessibility = attrs.accessibility == eAccessNone
2946
- ? eAccessPublic
2947
- : attrs.accessibility ;
2954
+ if (attrs.accessibility == eAccessNone)
2955
+ attrs.accessibility = eAccessPublic;
2948
2956
CompilerType ct = var_type->GetForwardCompilerType ();
2949
2957
clang::VarDecl *v = TypeSystemClang::AddVariableToRecordType (
2950
- class_clang_type, attrs.name , ct, accessibility);
2958
+ class_clang_type, attrs.name , ct, attrs. accessibility );
2951
2959
if (!v) {
2952
2960
LLDB_LOG (log, " Failed to add variable to the record type" );
2953
2961
return ;
@@ -3003,9 +3011,8 @@ void DWARFASTParserClang::ParseSingleMember(
3003
3011
const uint64_t word_width = 32 ;
3004
3012
CompilerType member_clang_type = member_type->GetLayoutCompilerType ();
3005
3013
3006
- const auto accessibility = attrs.accessibility == eAccessNone
3007
- ? default_accessibility
3008
- : attrs.accessibility ;
3014
+ if (attrs.accessibility == eAccessNone)
3015
+ attrs.accessibility = default_accessibility;
3009
3016
3010
3017
uint64_t field_bit_offset = (attrs.member_byte_offset == UINT32_MAX
3011
3018
? 0
@@ -3019,13 +3026,12 @@ void DWARFASTParserClang::ParseSingleMember(
3019
3026
if (attrs.data_bit_offset != UINT64_MAX) {
3020
3027
this_field_info.bit_offset = attrs.data_bit_offset ;
3021
3028
} 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 );
3025
3031
3026
3032
ObjectFile *objfile = die.GetDWARF ()->GetObjectFile ();
3027
3033
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 ;
3029
3035
this_field_info.bit_offset -= (attrs.bit_offset + attrs.bit_size );
3030
3036
} else {
3031
3037
this_field_info.bit_offset += attrs.bit_offset ;
@@ -3064,7 +3070,7 @@ void DWARFASTParserClang::ParseSingleMember(
3064
3070
// unnamed bitfields if we have a new enough clang.
3065
3071
bool detect_unnamed_bitfields = true ;
3066
3072
3067
- if (TypeSystemClang::IsObjCObjectOrInterfaceType (class_clang_type) )
3073
+ if (class_is_objc_object_or_interface )
3068
3074
detect_unnamed_bitfields =
3069
3075
die.GetCU ()->Supports_unnamed_objc_bitfields ();
3070
3076
@@ -3096,7 +3102,7 @@ void DWARFASTParserClang::ParseSingleMember(
3096
3102
class_clang_type, llvm::StringRef (),
3097
3103
m_ast.GetBuiltinTypeForEncodingAndBitSize (eEncodingSint,
3098
3104
word_width),
3099
- accessibility, unnamed_field_info->bit_size );
3105
+ attrs. accessibility , unnamed_field_info->bit_size );
3100
3106
3101
3107
layout_info.field_offsets .insert (std::make_pair (
3102
3108
unnamed_bitfield_decl, unnamed_field_info->bit_offset ));
@@ -3166,7 +3172,7 @@ void DWARFASTParserClang::ParseSingleMember(
3166
3172
TypeSystemClang::RequireCompleteType (member_clang_type);
3167
3173
3168
3174
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 ,
3170
3176
attrs.bit_size );
3171
3177
3172
3178
m_ast.SetMetadataAsUserID (field_decl, die.GetID ());
0 commit comments