@@ -65,21 +65,23 @@ DebugNamesDWARFIndex::IsForeignTypeUnit(const DebugNames::Entry &entry) const {
65
65
std::optional<uint64_t > type_sig = entry.getForeignTUTypeSignature ();
66
66
if (!type_sig.has_value ())
67
67
return std::nullopt;
68
+
69
+ // Ask the entry for the skeleton compile unit offset and fetch the .dwo
70
+ // file from it and get the type unit by signature from there. If we find
71
+ // the type unit in the .dwo file, we don't need to check that the
72
+ // DW_AT_dwo_name matches because each .dwo file can have its own type unit.
73
+ std::optional<uint64_t > cu_offset = entry.getForeignTUSkeletonCUOffset ();
74
+ if (!cu_offset)
75
+ return nullptr ; // Return NULL, this is a type unit, but couldn't find it.
76
+
77
+ DWARFUnit *cu =
78
+ m_debug_info.GetUnitAtOffset (DIERef::Section::DebugInfo, *cu_offset);
79
+ if (!cu)
80
+ return nullptr ; // Return NULL, this is a type unit, but couldn't find it.
81
+
68
82
auto dwp_sp = m_debug_info.GetDwpSymbolFile ();
69
83
if (!dwp_sp) {
70
84
// No .dwp file, we need to load the .dwo file.
71
-
72
- // Ask the entry for the skeleton compile unit offset and fetch the .dwo
73
- // file from it and get the type unit by signature from there. If we find
74
- // the type unit in the .dwo file, we don't need to check that the
75
- // DW_AT_dwo_name matches because each .dwo file can have its own type unit.
76
- std::optional<uint64_t > unit_offset = entry.getForeignTUSkeletonCUOffset ();
77
- if (!unit_offset)
78
- return nullptr ; // Return NULL, this is a type unit, but couldn't find it.
79
- DWARFUnit *cu =
80
- m_debug_info.GetUnitAtOffset (DIERef::Section::DebugInfo, *unit_offset);
81
- if (!cu)
82
- return nullptr ; // Return NULL, this is a type unit, but couldn't find it.
83
85
DWARFUnit &dwo_cu = cu->GetNonSkeletonUnit ();
84
86
// We don't need the check if the type unit matches the .dwo file if we have
85
87
// a .dwo file (not a .dwp), so we can just return the value here.
@@ -104,20 +106,14 @@ DebugNamesDWARFIndex::IsForeignTypeUnit(const DebugNames::Entry &entry) const {
104
106
if (!foreign_tu)
105
107
return nullptr ; // Return NULL, this is a type unit, but couldn't find it.
106
108
107
- std::optional<uint64_t > cu_offset = entry.getForeignTUSkeletonCUOffset ();
108
- if (cu_offset) {
109
- DWARFUnit *cu = m_debug_info.GetUnitAtOffset (DIERef::DebugInfo, *cu_offset);
110
- if (cu) {
111
- DWARFBaseDIE cu_die = cu->GetUnitDIEOnly ();
112
- DWARFBaseDIE tu_die = foreign_tu->GetUnitDIEOnly ();
113
- llvm::StringRef cu_dwo_name =
114
- cu_die.GetAttributeValueAsString (DW_AT_dwo_name, nullptr );
115
- llvm::StringRef tu_dwo_name =
116
- tu_die.GetAttributeValueAsString (DW_AT_dwo_name, nullptr );
117
- if (cu_dwo_name == tu_dwo_name)
118
- return foreign_tu; // We found a match!
119
- }
120
- }
109
+ DWARFBaseDIE cu_die = cu->GetUnitDIEOnly ();
110
+ DWARFBaseDIE tu_die = foreign_tu->GetUnitDIEOnly ();
111
+ llvm::StringRef cu_dwo_name =
112
+ cu_die.GetAttributeValueAsString (DW_AT_dwo_name, nullptr );
113
+ llvm::StringRef tu_dwo_name =
114
+ tu_die.GetAttributeValueAsString (DW_AT_dwo_name, nullptr );
115
+ if (cu_dwo_name == tu_dwo_name)
116
+ return foreign_tu; // We found a match!
121
117
return nullptr ; // Return NULL, this is a type unit, but couldn't find it.
122
118
}
123
119
0 commit comments