@@ -2926,15 +2926,7 @@ 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
- // 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;
2929
+ const MemberAttributes attrs (die, parent_die, module_sp);
2938
2930
2939
2931
// Handle static members, which are typically members without
2940
2932
// locations. However, GCC doesn't emit DW_AT_data_member_location
@@ -2949,13 +2941,13 @@ void DWARFASTParserClang::ParseSingleMember(
2949
2941
if (attrs.member_byte_offset == UINT32_MAX &&
2950
2942
attrs.data_bit_offset == UINT64_MAX && attrs.is_declaration ) {
2951
2943
Type *var_type = die.ResolveTypeUID (attrs.encoding_form .Reference ());
2952
-
2953
2944
if (var_type) {
2954
- if (attrs.accessibility == eAccessNone)
2955
- attrs.accessibility = eAccessPublic;
2945
+ const auto accessibility = attrs.accessibility == eAccessNone
2946
+ ? eAccessPublic
2947
+ : attrs.accessibility ;
2956
2948
CompilerType ct = var_type->GetForwardCompilerType ();
2957
2949
clang::VarDecl *v = TypeSystemClang::AddVariableToRecordType (
2958
- class_clang_type, attrs.name , ct, attrs. accessibility );
2950
+ class_clang_type, attrs.name , ct, accessibility);
2959
2951
if (!v) {
2960
2952
LLDB_LOG (log, " Failed to add variable to the record type" );
2961
2953
return ;
@@ -2966,20 +2958,20 @@ void DWARFASTParserClang::ParseSingleMember(
2966
2958
if (!ct.IsIntegerOrEnumerationType (unused))
2967
2959
return ;
2968
2960
2961
+ auto maybe_const_form_value = attrs.const_value_form ;
2962
+
2969
2963
// Newer versions of Clang don't emit the DW_AT_const_value
2970
2964
// on the declaration of an inline static data member. Instead
2971
2965
// it's attached to the definition DIE. If that's the case,
2972
2966
// try and fetch it.
2973
- if (!attrs. const_value_form ) {
2974
- auto maybe_form_value = FindConstantOnVariableDefinition (die);
2975
- if (!maybe_form_value )
2967
+ if (!maybe_const_form_value ) {
2968
+ maybe_const_form_value = FindConstantOnVariableDefinition (die);
2969
+ if (!maybe_const_form_value )
2976
2970
return ;
2977
-
2978
- attrs.const_value_form = *maybe_form_value;
2979
2971
}
2980
2972
2981
2973
llvm::Expected<llvm::APInt> const_value_or_err =
2982
- ExtractIntFromFormValue (ct, *attrs. const_value_form );
2974
+ ExtractIntFromFormValue (ct, *maybe_const_form_value );
2983
2975
if (!const_value_or_err) {
2984
2976
LLDB_LOG_ERROR (log, const_value_or_err.takeError (),
2985
2977
" Failed to add const value to variable {1}: {0}" ,
@@ -3011,8 +3003,9 @@ void DWARFASTParserClang::ParseSingleMember(
3011
3003
const uint64_t word_width = 32 ;
3012
3004
CompilerType member_clang_type = member_type->GetLayoutCompilerType ();
3013
3005
3014
- if (attrs.accessibility == eAccessNone)
3015
- attrs.accessibility = default_accessibility;
3006
+ const auto accessibility = attrs.accessibility == eAccessNone
3007
+ ? default_accessibility
3008
+ : attrs.accessibility ;
3016
3009
3017
3010
uint64_t field_bit_offset = (attrs.member_byte_offset == UINT32_MAX
3018
3011
? 0
@@ -3026,12 +3019,13 @@ void DWARFASTParserClang::ParseSingleMember(
3026
3019
if (attrs.data_bit_offset != UINT64_MAX) {
3027
3020
this_field_info.bit_offset = attrs.data_bit_offset ;
3028
3021
} else {
3029
- if (!attrs.byte_size )
3030
- attrs.byte_size = member_type->GetByteSize (nullptr );
3022
+ auto byte_size = attrs.byte_size ;
3023
+ if (!byte_size)
3024
+ byte_size = member_type->GetByteSize (nullptr );
3031
3025
3032
3026
ObjectFile *objfile = die.GetDWARF ()->GetObjectFile ();
3033
3027
if (objfile->GetByteOrder () == eByteOrderLittle) {
3034
- this_field_info.bit_offset += attrs. byte_size .value_or (0 ) * 8 ;
3028
+ this_field_info.bit_offset += byte_size.value_or (0 ) * 8 ;
3035
3029
this_field_info.bit_offset -= (attrs.bit_offset + attrs.bit_size );
3036
3030
} else {
3037
3031
this_field_info.bit_offset += attrs.bit_offset ;
@@ -3070,7 +3064,7 @@ void DWARFASTParserClang::ParseSingleMember(
3070
3064
// unnamed bitfields if we have a new enough clang.
3071
3065
bool detect_unnamed_bitfields = true ;
3072
3066
3073
- if (class_is_objc_object_or_interface )
3067
+ if (TypeSystemClang::IsObjCObjectOrInterfaceType (class_clang_type) )
3074
3068
detect_unnamed_bitfields =
3075
3069
die.GetCU ()->Supports_unnamed_objc_bitfields ();
3076
3070
@@ -3102,7 +3096,7 @@ void DWARFASTParserClang::ParseSingleMember(
3102
3096
class_clang_type, llvm::StringRef (),
3103
3097
m_ast.GetBuiltinTypeForEncodingAndBitSize (eEncodingSint,
3104
3098
word_width),
3105
- attrs. accessibility , unnamed_field_info->bit_size );
3099
+ accessibility, unnamed_field_info->bit_size );
3106
3100
3107
3101
layout_info.field_offsets .insert (std::make_pair (
3108
3102
unnamed_bitfield_decl, unnamed_field_info->bit_offset ));
@@ -3172,7 +3166,7 @@ void DWARFASTParserClang::ParseSingleMember(
3172
3166
TypeSystemClang::RequireCompleteType (member_clang_type);
3173
3167
3174
3168
clang::FieldDecl *field_decl = TypeSystemClang::AddFieldToRecordType (
3175
- class_clang_type, attrs.name , member_clang_type, attrs. accessibility ,
3169
+ class_clang_type, attrs.name , member_clang_type, accessibility,
3176
3170
attrs.bit_size );
3177
3171
3178
3172
m_ast.SetMetadataAsUserID (field_decl, die.GetID ());
0 commit comments