@@ -135,6 +135,11 @@ class PluginProperties : public Properties {
135
135
136
136
} // namespace
137
137
138
+ bool IsStructOrClassTag (llvm::dwarf::Tag Tag) {
139
+ return Tag == llvm::dwarf::Tag::DW_TAG_class_type ||
140
+ Tag == llvm::dwarf::Tag::DW_TAG_structure_type;
141
+ }
142
+
138
143
static PluginProperties &GetGlobalPluginProperties () {
139
144
static PluginProperties g_settings;
140
145
return g_settings;
@@ -2888,29 +2893,18 @@ TypeSP SymbolFileDWARF::FindCompleteObjCDefinitionTypeForDIE(
2888
2893
2889
2894
m_index->GetCompleteObjCClass (
2890
2895
type_name, must_be_implementation, [&](DWARFDIE type_die) {
2891
- bool try_resolving_type = false ;
2892
-
2893
2896
// Don't try and resolve the DIE we are looking for with the DIE
2894
2897
// itself!
2895
- if (type_die != die) {
2896
- switch (type_die.Tag ()) {
2897
- case DW_TAG_class_type:
2898
- case DW_TAG_structure_type:
2899
- try_resolving_type = true ;
2900
- break ;
2901
- default :
2902
- break ;
2903
- }
2904
- }
2905
- if (!try_resolving_type)
2898
+ if (type_die == die || !IsStructOrClassTag (type_die.Tag ()))
2906
2899
return true ;
2907
2900
2908
2901
if (must_be_implementation &&
2909
- type_die.Supports_DW_AT_APPLE_objc_complete_type ())
2910
- try_resolving_type = type_die.GetAttributeValueAsUnsigned (
2902
+ type_die.Supports_DW_AT_APPLE_objc_complete_type ()) {
2903
+ const bool try_resolving_type = type_die.GetAttributeValueAsUnsigned (
2911
2904
DW_AT_APPLE_objc_complete_type, 0 );
2912
- if (!try_resolving_type)
2913
- return true ;
2905
+ if (!try_resolving_type)
2906
+ return true ;
2907
+ }
2914
2908
2915
2909
Type *resolved_type = ResolveType (type_die, false , true );
2916
2910
if (!resolved_type || resolved_type == DIE_IS_BEING_PARSED)
@@ -3069,36 +3063,12 @@ SymbolFileDWARF::FindDefinitionTypeForDWARFDeclContext(const DWARFDIE &die) {
3069
3063
if (type_system &&
3070
3064
!type_system->SupportsLanguage (GetLanguage (*type_die.GetCU ())))
3071
3065
return true ;
3072
- bool try_resolving_type = false ;
3073
3066
3074
- // Don't try and resolve the DIE we are looking for with the DIE
3075
- // itself!
3076
3067
const dw_tag_t type_tag = type_die.Tag ();
3077
- // Make sure the tags match
3078
- if (type_tag == tag) {
3079
- // The tags match, lets try resolving this type
3080
- try_resolving_type = true ;
3081
- } else {
3082
- // The tags don't match, but we need to watch our for a forward
3083
- // declaration for a struct and ("struct foo") ends up being a
3084
- // class ("class foo { ... };") or vice versa.
3085
- switch (type_tag) {
3086
- case DW_TAG_class_type:
3087
- // We had a "class foo", see if we ended up with a "struct foo
3088
- // { ... };"
3089
- try_resolving_type = (tag == DW_TAG_structure_type);
3090
- break ;
3091
- case DW_TAG_structure_type:
3092
- // We had a "struct foo", see if we ended up with a "class foo
3093
- // { ... };"
3094
- try_resolving_type = (tag == DW_TAG_class_type);
3095
- break ;
3096
- default :
3097
- // Tags don't match, don't event try to resolve using this type
3098
- // whose name matches....
3099
- break ;
3100
- }
3101
- }
3068
+ // Resolve the type if both have the same tag or {class, struct} tags.
3069
+ const bool try_resolving_type =
3070
+ type_tag == tag ||
3071
+ (IsStructOrClassTag (type_tag) && IsStructOrClassTag (tag));
3102
3072
3103
3073
if (!try_resolving_type) {
3104
3074
if (log) {
0 commit comments