================
@@ -2758,6 +2758,15 @@ void SymbolFileDWARF::FindTypes(const TypeQuery &query, 
TypeResults &results) {
         return true; // Keep iterating over index types, language mismatch.
     }
 
+    // Since mangled names are unique, we only need to check if the names are
+    // the same.
+    if (query.GetSearchByMangledName()) {
+      if (die.GetMangledName() == query.GetTypeBasename().GetStringRef())
+        if (Type *matching_type = ResolveType(die, true, true))
+          results.InsertUnique(matching_type->shared_from_this());
+      return !results.Done(query); // Keep iterating if we aren't done.
+    }
----------------
clayborg wrote:

This logic needs doesn't need to check if results are done if we didn't add 
anything to the results. Maybe this would be more clear?:
```
    if (query.GetSearchByMangledName()) {
      if (die.GetMangledName() != query.GetTypeBasename().GetStringRef()) 
        return true; // Keep iterating over index types, mangled name mismatch.
      if (Type *matching_type = ResolveType(die, true, true)) {
        results.InsertUnique(matching_type->shared_from_this());
        return !results.Done(query); // Keep iterating if we aren't done.
      }
      return true; // Keep iterating over index types, weren't able to resolve 
this type
    }
```
One other issue is that `DWARFDie::GetMangledName()` will return the 
`DW_AT_name` if there is no mangled name:
```
const char *DWARFDIE::GetMangledName() const {
  if (IsValid())
    return m_die->GetMangledName(m_cu);
  else
    return nullptr;
}
```
But `const char *DWARFDebugInfoEntry::GetMangledName(const DWARFUnit *cu, bool 
substitute_name_allowed)` has a boolean option `substitute_name_allowed` that 
defaults to true. So we should probably also change:
```
const char *DWARFDIE::GetMangledName() const;
```
To have that same option with a default value:
```
const char *DWARFDIE::GetMangledName(bool substitute_name_allowed = true) const
```
And then change your code to pass in `false` for the `substitute_name_allowed`

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

Reply via email to