Extend FindTypes with CompilerContext to allow filtering by language.
This patch is also motivated by the Swift branch and is effectively NFC for the single-TypeSystem llvm.org branch.
In multi-language projects it is extremely common to have, e.g., a
Clang type and a similarly-named rendition of that same type in
another language. When searching for a type It is much cheaper to pass
a set of supported languages to the SymbolFile than having it
materialize every result and then rejecting the materialized types
that have the wrong language.
Differential Revision: https://reviews.llvm.org/D66546
<rdar://problem/54471165>
This reapplies r369690 with a previously missing constructor for LanguageSet.
llvm-svn: 369710
diff --git a/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp b/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
index ba63b41..6b357c2 100644
--- a/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
+++ b/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
@@ -2485,7 +2485,8 @@
}
size_t SymbolFileDWARF::FindTypes(llvm::ArrayRef<CompilerContext> pattern,
- bool append, TypeMap &types) {
+ LanguageSet languages, bool append,
+ TypeMap &types) {
std::lock_guard<std::recursive_mutex> guard(GetModuleMutex());
if (!append)
types.Clear();
@@ -2508,6 +2509,9 @@
DWARFDIE die = GetDIE(die_ref);
if (die) {
+ if (!languages[die.GetCU()->GetLanguageType()])
+ continue;
+
llvm::SmallVector<CompilerContext, 4> die_context;
die.GetDeclContext(die_context);
if (!contextMatches(die_context, pattern))