|
9 | 9 | #include "SymbolFileDWARF.h"
|
10 | 10 |
|
11 | 11 | #include "llvm/DebugInfo/DWARF/DWARFDebugLoc.h"
|
12 |
| -#include "llvm/DebugInfo/DWARF/DWARFTypePrinter.h" |
13 | 12 | #include "llvm/Support/Casting.h"
|
14 | 13 | #include "llvm/Support/FileUtilities.h"
|
15 | 14 | #include "llvm/Support/Format.h"
|
@@ -2811,14 +2810,33 @@ void SymbolFileDWARF::FindTypes(const TypeQuery &query, TypeResults &results) {
|
2811 | 2810 | return true; // Keep iterating over index types, language mismatch.
|
2812 | 2811 | }
|
2813 | 2812 |
|
2814 |
| - std::string qualified_name; |
2815 |
| - llvm::raw_string_ostream os(qualified_name); |
2816 |
| - llvm::DWARFTypePrinter<DWARFDIE> type_printer(os); |
2817 |
| - type_printer.appendQualifiedName(die); |
2818 |
| - TypeQuery die_query(qualified_name, e_exact_match); |
2819 |
| - if (query.ContextMatches(die_query.GetContextRef())) |
2820 |
| - if (Type *matching_type = ResolveType(die, true, true)) |
2821 |
| - results.InsertUnique(matching_type->shared_from_this()); |
| 2813 | + // Check the context matches |
| 2814 | + std::vector<lldb_private::CompilerContext> die_context; |
| 2815 | + if (query.GetModuleSearch()) |
| 2816 | + die_context = die.GetDeclContext(); |
| 2817 | + else |
| 2818 | + die_context = die.GetTypeLookupContext(); |
| 2819 | + assert(!die_context.empty()); |
| 2820 | + if (!query_simple.ContextMatches(die_context)) |
| 2821 | + return true; // Keep iterating over index types, context mismatch. |
| 2822 | + |
| 2823 | + // Try to resolve the type. |
| 2824 | + if (Type *matching_type = ResolveType(die, true, true)) { |
| 2825 | + ConstString name = matching_type->GetQualifiedName(); |
| 2826 | + // We have found a type that still might not match due to template |
| 2827 | + // parameters. If we create a new TypeQuery that uses the new type's |
| 2828 | + // fully qualified name, we can find out if this type matches at all |
| 2829 | + // context levels. We can't use just the "match_simple" context |
| 2830 | + // because all template parameters were stripped off. The fully |
| 2831 | + // qualified name of the type will have the template parameters and |
| 2832 | + // will allow us to make sure it matches correctly. |
| 2833 | + TypeQuery die_query(name.GetStringRef(), |
| 2834 | + TypeQueryOptions::e_exact_match); |
| 2835 | + if (!query.ContextMatches(die_query.GetContextRef())) |
| 2836 | + return true; // Keep iterating over index types, context mismatch. |
| 2837 | + |
| 2838 | + results.InsertUnique(matching_type->shared_from_this()); |
| 2839 | + } |
2822 | 2840 | return !results.Done(query); // Keep iterating if we aren't done.
|
2823 | 2841 | });
|
2824 | 2842 | if (results.Done(query)) {
|
|
0 commit comments