Skip to content

Commit 5da641c

Browse files
committed
Perform DIE-to-string comparison
Rough prototype, doesn't handle namespace/context
1 parent ae672ed commit 5da641c

File tree

3 files changed

+194
-151
lines changed

3 files changed

+194
-151
lines changed

lldb/include/lldb/Symbol/Type.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -286,6 +286,9 @@ class TypeQuery {
286286
std::vector<lldb_private::CompilerContext> &GetContextRef() {
287287
return m_context;
288288
}
289+
const std::vector<lldb_private::CompilerContext> &GetContextRef() const {
290+
return m_context;
291+
}
289292

290293
protected:
291294
/// A full or partial compiler context array where the parent declaration

lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2787,15 +2787,20 @@ void SymbolFileDWARF::FindTypes(const TypeQuery &query, TypeResults &results) {
27872787
return true; // Keep iterating over index types, language mismatch.
27882788
}
27892789

2790-
std::string R;
2791-
llvm::raw_string_ostream OS(R);
2792-
llvm::DWARFTypePrinter<DWARFDIE> p(OS);
2790+
bool Success = true;
2791+
const auto &Context = query.GetContextRef();
2792+
assert(Context.size() == 1);
2793+
llvm::StringRef remaining = Context.front().name;
2794+
auto Visitor = [&](llvm::StringRef S) {
2795+
Success &= remaining.consume_front(S);
2796+
};
2797+
llvm::DWARFTypePrinter<DWARFDIE, decltype(Visitor)> p(Visitor);
27932798
p.appendQualifiedName(die);
27942799

2795-
TypeQuery die_query(R, TypeQueryOptions::e_exact_match);
2796-
if (query.ContextMatches(die_query.GetContextRef()))
2800+
if (Success && remaining.empty())
27972801
if (Type *matching_type = ResolveType(die, true, true))
27982802
results.InsertUnique(matching_type->shared_from_this());
2803+
27992804
return !results.Done(query); // Keep iterating if we aren't done.
28002805
});
28012806
if (results.Done(query))

0 commit comments

Comments
 (0)