@@ -132,6 +132,11 @@ class PluginProperties : public Properties {
132
132
133
133
} // namespace
134
134
135
+ bool IsStructOrClassTag (llvm::dwarf::Tag Tag) {
136
+ return Tag == llvm::dwarf::Tag::DW_TAG_class_type ||
137
+ Tag == llvm::dwarf::Tag::DW_TAG_structure_type;
138
+ }
139
+
135
140
static PluginProperties &GetGlobalPluginProperties () {
136
141
static PluginProperties g_settings;
137
142
return g_settings;
@@ -2947,29 +2952,18 @@ TypeSP SymbolFileDWARF::FindCompleteObjCDefinitionTypeForDIE(
2947
2952
2948
2953
m_index->GetCompleteObjCClass (
2949
2954
type_name, must_be_implementation, [&](DWARFDIE type_die) {
2950
- bool try_resolving_type = false ;
2951
-
2952
2955
// Don't try and resolve the DIE we are looking for with the DIE
2953
2956
// itself!
2954
- if (type_die != die) {
2955
- switch (type_die.Tag ()) {
2956
- case DW_TAG_class_type:
2957
- case DW_TAG_structure_type:
2958
- try_resolving_type = true ;
2959
- break ;
2960
- default :
2961
- break ;
2962
- }
2963
- }
2964
- if (!try_resolving_type)
2957
+ if (type_die == die || !IsStructOrClassTag (type_die.Tag ()))
2965
2958
return true ;
2966
2959
2967
2960
if (must_be_implementation &&
2968
- type_die.Supports_DW_AT_APPLE_objc_complete_type ())
2969
- try_resolving_type = type_die.GetAttributeValueAsUnsigned (
2961
+ type_die.Supports_DW_AT_APPLE_objc_complete_type ()) {
2962
+ const bool try_resolving_type = type_die.GetAttributeValueAsUnsigned (
2970
2963
DW_AT_APPLE_objc_complete_type, 0 );
2971
- if (!try_resolving_type)
2972
- return true ;
2964
+ if (!try_resolving_type)
2965
+ return true ;
2966
+ }
2973
2967
2974
2968
Type *resolved_type = ResolveType (type_die, false , true );
2975
2969
if (!resolved_type || resolved_type == DIE_IS_BEING_PARSED)
@@ -3128,36 +3122,12 @@ SymbolFileDWARF::FindDefinitionTypeForDWARFDeclContext(const DWARFDIE &die) {
3128
3122
if (type_system &&
3129
3123
!type_system->SupportsLanguage (GetLanguage (*type_die.GetCU ())))
3130
3124
return true ;
3131
- bool try_resolving_type = false ;
3132
3125
3133
- // Don't try and resolve the DIE we are looking for with the DIE
3134
- // itself!
3135
3126
const dw_tag_t type_tag = type_die.Tag ();
3136
- // Make sure the tags match
3137
- if (type_tag == tag) {
3138
- // The tags match, lets try resolving this type
3139
- try_resolving_type = true ;
3140
- } else {
3141
- // The tags don't match, but we need to watch our for a forward
3142
- // declaration for a struct and ("struct foo") ends up being a
3143
- // class ("class foo { ... };") or vice versa.
3144
- switch (type_tag) {
3145
- case DW_TAG_class_type:
3146
- // We had a "class foo", see if we ended up with a "struct foo
3147
- // { ... };"
3148
- try_resolving_type = (tag == DW_TAG_structure_type);
3149
- break ;
3150
- case DW_TAG_structure_type:
3151
- // We had a "struct foo", see if we ended up with a "class foo
3152
- // { ... };"
3153
- try_resolving_type = (tag == DW_TAG_class_type);
3154
- break ;
3155
- default :
3156
- // Tags don't match, don't event try to resolve using this type
3157
- // whose name matches....
3158
- break ;
3159
- }
3160
- }
3127
+ // Resolve the type if both have the same tag or {class, struct} tags.
3128
+ const bool try_resolving_type =
3129
+ type_tag == tag ||
3130
+ (IsStructOrClassTag (type_tag) && IsStructOrClassTag (tag));
3161
3131
3162
3132
if (!try_resolving_type) {
3163
3133
if (log) {
0 commit comments