================
@@ -195,17 +195,17 @@ void DebugNamesDWARFIndex::GetCompleteObjCClass(
     if (!ref)
       continue;
 
-    DWARFUnit *cu = m_debug_info.GetUnit(*ref);
-    if (!cu || !cu->Supports_DW_AT_APPLE_objc_complete_type()) {
-      incomplete_types.push_back(*ref);
-      continue;
-    }
-
-    DWARFDIE die = m_debug_info.GetDIE(*ref);
+    SymbolFileDWARF &dwarf = *llvm::cast<SymbolFileDWARF>(
+        m_module.GetSymbolFile()->GetBackingSymbolFile());
----------------
felipepiovezan wrote:

This concerns me a little because `GetSymbolFile()` can fail (and so does 
GetBackingSymbolFile), and we're doing this somewhat expensive operation inside 
a loop, even though they are loop invariant.

We can probably address both of these issues by hoisting this outside the loop, 
computing the range, early exiting if the range is empty, and then setting up 
the symbol file. Something like:

```
auto range = m_debug_names_up->equal_range(class_name.GetStringRef()
if (range.empty()) return;

auto *symbolfile = m_module.GetSymbolFile();
if (!symbolfile) ...
if (!backing symbol file)...

// maybe just wrap all the lines above into a helper function

for (const DebugNames::Entry &entry :
       m_debug_names_up->equal_range(class_name.GetStringRef())) {
...
```



```

https://github.com/llvm/llvm-project/pull/92894
_______________________________________________
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits

Reply via email to