@@ -21,19 +21,19 @@ void DWARFMappedHash::ExtractDIEArray(const DIEInfoArray &die_info_array,
2121 DIEArray &die_offsets) {
2222 if (tag == 0 ) {
2323 ExtractDIEArray (die_info_array, die_offsets);
24- } else {
25- const size_t count = die_info_array.size ();
26- for (size_t i = 0 ; i < count; ++i) {
27- const dw_tag_t die_tag = die_info_array[i].tag ;
28- bool tag_matches = die_tag == 0 || tag == die_tag;
29- if (!tag_matches) {
30- if (die_tag == DW_TAG_class_type || die_tag == DW_TAG_structure_type)
31- tag_matches =
32- tag == DW_TAG_structure_type || tag == DW_TAG_class_type;
33- }
34- if (tag_matches)
35- die_offsets.emplace_back (die_info_array[i]);
24+ return ;
25+ }
26+
27+ const size_t count = die_info_array.size ();
28+ for (size_t i = 0 ; i < count; ++i) {
29+ const dw_tag_t die_tag = die_info_array[i].tag ;
30+ bool tag_matches = die_tag == 0 || tag == die_tag;
31+ if (!tag_matches) {
32+ if (die_tag == DW_TAG_class_type || die_tag == DW_TAG_structure_type)
33+ tag_matches = tag == DW_TAG_structure_type || tag == DW_TAG_class_type;
3634 }
35+ if (tag_matches)
36+ die_offsets.emplace_back (die_info_array[i]);
3737 }
3838}
3939
@@ -43,21 +43,21 @@ void DWARFMappedHash::ExtractDIEArray(const DIEInfoArray &die_info_array,
4343 DIEArray &die_offsets) {
4444 if (tag == 0 ) {
4545 ExtractDIEArray (die_info_array, die_offsets);
46- } else {
47- const size_t count = die_info_array.size ();
48- for (size_t i = 0 ; i < count; ++i) {
49- if (qualified_name_hash != die_info_array[i].qualified_name_hash )
50- continue ;
51- const dw_tag_t die_tag = die_info_array[i].tag ;
52- bool tag_matches = die_tag == 0 || tag == die_tag;
53- if (!tag_matches) {
54- if (die_tag == DW_TAG_class_type || die_tag == DW_TAG_structure_type)
55- tag_matches =
56- tag == DW_TAG_structure_type || tag == DW_TAG_class_type;
57- }
58- if (tag_matches)
59- die_offsets.emplace_back (die_info_array[i]);
46+ return ;
47+ }
48+
49+ const size_t count = die_info_array.size ();
50+ for (size_t i = 0 ; i < count; ++i) {
51+ if (qualified_name_hash != die_info_array[i].qualified_name_hash )
52+ continue ;
53+ const dw_tag_t die_tag = die_info_array[i].tag ;
54+ bool tag_matches = die_tag == 0 || tag == die_tag;
55+ if (!tag_matches) {
56+ if (die_tag == DW_TAG_class_type || die_tag == DW_TAG_structure_type)
57+ tag_matches = tag == DW_TAG_structure_type || tag == DW_TAG_class_type;
6058 }
59+ if (tag_matches)
60+ die_offsets.emplace_back (die_info_array[i]);
6161 }
6262}
6363
@@ -67,22 +67,22 @@ void DWARFMappedHash::ExtractClassOrStructDIEArray(
6767 const size_t count = die_info_array.size ();
6868 for (size_t i = 0 ; i < count; ++i) {
6969 const dw_tag_t die_tag = die_info_array[i].tag ;
70- if (die_tag == 0 || die_tag == DW_TAG_class_type ||
71- die_tag == DW_TAG_structure_type) {
72- if (die_info_array[i].type_flags & eTypeFlagClassIsImplementation) {
73- if (return_implementation_only_if_available) {
74- // We found the one true definition for this class, so only return
75- // that
76- die_offsets.clear ();
77- die_offsets.emplace_back (die_info_array[i]);
78- return ;
79- } else {
80- // Put the one true definition as the first entry so it matches first
81- die_offsets.emplace (die_offsets.begin (), die_info_array[i]);
82- }
83- } else {
70+ if (die_tag != 0 && die_tag != DW_TAG_class_type &&
71+ die_tag != DW_TAG_structure_type)
72+ continue ;
73+ if (die_info_array[i].type_flags & eTypeFlagClassIsImplementation) {
74+ if (return_implementation_only_if_available) {
75+ // We found the one true definition for this class, so only return
76+ // that
77+ die_offsets.clear ();
8478 die_offsets.emplace_back (die_info_array[i]);
79+ return ;
80+ } else {
81+ // Put the one true definition as the first entry so it matches first
82+ die_offsets.emplace (die_offsets.begin (), die_info_array[i]);
8583 }
84+ } else {
85+ die_offsets.emplace_back (die_info_array[i]);
8686 }
8787 }
8888}
@@ -548,24 +548,24 @@ size_t DWARFMappedHash::MemoryTable::FindByNameAndTagAndQualifiedNameHash(
548548size_t DWARFMappedHash::MemoryTable::FindCompleteObjCClassByName (
549549 llvm::StringRef name, DIEArray &die_offsets, bool must_be_implementation) {
550550 DIEInfoArray die_info_array;
551- if (FindByName (name, die_info_array)) {
552- if (must_be_implementation &&
553- GetHeader ().header_data .ContainsAtom (eAtomTypeTypeFlags)) {
554- // If we have two atoms, then we have the DIE offset and the type flags
555- // so we can find the objective C class efficiently.
556- DWARFMappedHash::ExtractTypesFromDIEArray (die_info_array, UINT32_MAX,
557- eTypeFlagClassIsImplementation,
558- die_offsets);
559- } else {
560- // We don't only want the one true definition, so try and see what we can
561- // find, and only return class or struct DIEs. If we do have the full
562- // implementation, then return it alone, else return all possible
563- // matches.
564- const bool return_implementation_only_if_available = true ;
565- DWARFMappedHash::ExtractClassOrStructDIEArray (
566- die_info_array, return_implementation_only_if_available, die_offsets);
567- }
551+ if (!FindByName (name, die_info_array))
552+ return 0 ;
553+ if (must_be_implementation &&
554+ GetHeader ().header_data .ContainsAtom (eAtomTypeTypeFlags)) {
555+ // If we have two atoms, then we have the DIE offset and the type flags
556+ // so we can find the objective C class efficiently.
557+ DWARFMappedHash::ExtractTypesFromDIEArray (die_info_array, UINT32_MAX,
558+ eTypeFlagClassIsImplementation,
559+ die_offsets);
560+ return die_offsets.size ();
568561 }
562+ // We don't only want the one true definition, so try and see what we can
563+ // find, and only return class or struct DIEs. If we do have the full
564+ // implementation, then return it alone, else return all possible
565+ // matches.
566+ const bool return_implementation_only_if_available = true ;
567+ DWARFMappedHash::ExtractClassOrStructDIEArray (
568+ die_info_array, return_implementation_only_if_available, die_offsets);
569569 return die_offsets.size ();
570570}
571571
0 commit comments