diff options
| author | Adrian Prantl <aprantl@apple.com> | 2019-08-22 19:24:55 +0000 |
|---|---|---|
| committer | Adrian Prantl <aprantl@apple.com> | 2019-08-22 19:24:55 +0000 |
| commit | aa3a564efa6b5fff2129f81a4041069a0233168f (patch) | |
| tree | 230811320c2fff1889c8fcfa2d561dac57e6afc9 /lldb/tools | |
| parent | 6c6dd6acf9e4a9d0599c99abbcbb696ed6b5ab19 (diff) | |
| download | bcm5719-llvm-aa3a564efa6b5fff2129f81a4041069a0233168f.tar.gz bcm5719-llvm-aa3a564efa6b5fff2129f81a4041069a0233168f.zip | |
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>
llvm-svn: 369690
Diffstat (limited to 'lldb/tools')
| -rw-r--r-- | lldb/tools/lldb-test/lldb-test.cpp | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/lldb/tools/lldb-test/lldb-test.cpp b/lldb/tools/lldb-test/lldb-test.cpp index 5eaf006d128..8459d4b8a28 100644 --- a/lldb/tools/lldb-test/lldb-test.cpp +++ b/lldb/tools/lldb-test/lldb-test.cpp @@ -26,6 +26,7 @@ #include "lldb/Symbol/TypeList.h" #include "lldb/Symbol/TypeMap.h" #include "lldb/Symbol/VariableList.h" +#include "lldb/Target/Language.h" #include "lldb/Target/Process.h" #include "lldb/Target/Target.h" #include "lldb/Utility/CleanUp.h" @@ -144,6 +145,10 @@ static cl::opt<std::string> CompilerContext( cl::desc("Specify a compiler context as \"kind:name,...\"."), cl::value_desc("context"), cl::sub(SymbolsSubcommand)); +static cl::opt<std::string> + Language("language", cl::desc("Specify a language type, like C99."), + cl::value_desc("language"), cl::sub(SymbolsSubcommand)); + static cl::list<FunctionNameType> FunctionNameFlags( "function-flags", cl::desc("Function search flags:"), cl::values(clEnumValN(eFunctionNameTypeAuto, "auto", @@ -507,13 +512,17 @@ Error opts::symbols::findTypes(lldb_private::Module &Module) { CompilerDeclContext *ContextPtr = ContextOr->IsValid() ? &*ContextOr : nullptr; + LanguageSet languages; + if (!Language.empty()) + languages.Insert(Language::GetLanguageTypeFromString(Language)); + DenseSet<SymbolFile *> SearchedFiles; TypeMap Map; if (!Name.empty()) Symfile.FindTypes(ConstString(Name), ContextPtr, true, UINT32_MAX, SearchedFiles, Map); else - Symfile.FindTypes(parseCompilerContext(), true, Map); + Symfile.FindTypes(parseCompilerContext(), languages, true, Map); outs() << formatv("Found {0} types:\n", Map.GetSize()); StreamString Stream; |

