aboutsummaryrefslogtreecommitdiff
path: root/lldb/source/Commands/CommandCompletions.cpp
diff options
context:
space:
mode:
authorRaphael Isemann <teemperor@gmail.com>2020-02-11 18:44:02 +0100
committerRaphael Isemann <teemperor@gmail.com>2020-02-11 18:50:25 +0100
commit62174682a039efce2ce7606d5416d2450ff42dab (patch)
tree1eb34c55350ef9c7c92ba34ca9c5c2fa71bcb5d2 /lldb/source/Commands/CommandCompletions.cpp
parent2ac0c4b46ee2a3c22b85b4483f2fd4d0fb916720 (diff)
downloadllvm-62174682a039efce2ce7606d5416d2450ff42dab.zip
llvm-62174682a039efce2ce7606d5416d2450ff42dab.tar.gz
llvm-62174682a039efce2ce7606d5416d2450ff42dab.tar.bz2
[lldb][NFC] Remove support file searching from SourceFileCompleter
This code seems wrong as the directory variable actually contains the file name. It's also unreachable code as m_include_support_files is hardcoded to false which is the condition for the surrounding 'if statement'. Let's just remove all of this.
Diffstat (limited to 'lldb/source/Commands/CommandCompletions.cpp')
-rw-r--r--lldb/source/Commands/CommandCompletions.cpp62
1 files changed, 19 insertions, 43 deletions
diff --git a/lldb/source/Commands/CommandCompletions.cpp b/lldb/source/Commands/CommandCompletions.cpp
index e5f2911..2ced56f 100644
--- a/lldb/source/Commands/CommandCompletions.cpp
+++ b/lldb/source/Commands/CommandCompletions.cpp
@@ -66,8 +66,7 @@ bool CommandCompletions::InvokeCommonCompletionCallbacks(
void CommandCompletions::SourceFiles(CommandInterpreter &interpreter,
CompletionRequest &request,
SearchFilter *searcher) {
- // Find some way to switch "include support files..."
- SourceFileCompleter completer(interpreter, false, request);
+ SourceFileCompleter completer(interpreter, request);
if (searcher == nullptr) {
lldb::TargetSP target_sp = interpreter.GetDebugger().GetSelectedTarget();
@@ -332,10 +331,8 @@ CommandCompletions::Completer::~Completer() = default;
// SourceFileCompleter
CommandCompletions::SourceFileCompleter::SourceFileCompleter(
- CommandInterpreter &interpreter, bool include_support_files,
- CompletionRequest &request)
- : CommandCompletions::Completer(interpreter, request),
- m_include_support_files(include_support_files), m_matching_files() {
+ CommandInterpreter &interpreter, CompletionRequest &request)
+ : CommandCompletions::Completer(interpreter, request), m_matching_files() {
FileSpec partial_spec(m_request.GetCursorArgumentPrefix());
m_file_name = partial_spec.GetFilename().GetCString();
m_dir_name = partial_spec.GetDirectory().GetCString();
@@ -350,43 +347,22 @@ CommandCompletions::SourceFileCompleter::SearchCallback(SearchFilter &filter,
SymbolContext &context,
Address *addr) {
if (context.comp_unit != nullptr) {
- if (m_include_support_files) {
- FileSpecList supporting_files = context.comp_unit->GetSupportFiles();
- for (size_t sfiles = 0; sfiles < supporting_files.GetSize(); sfiles++) {
- const FileSpec &sfile_spec =
- supporting_files.GetFileSpecAtIndex(sfiles);
- const char *sfile_file_name = sfile_spec.GetFilename().GetCString();
- const char *sfile_dir_name = sfile_spec.GetFilename().GetCString();
- bool match = false;
- if (m_file_name && sfile_file_name &&
- strstr(sfile_file_name, m_file_name) == sfile_file_name)
- match = true;
- if (match && m_dir_name && sfile_dir_name &&
- strstr(sfile_dir_name, m_dir_name) != sfile_dir_name)
- match = false;
-
- if (match) {
- m_matching_files.AppendIfUnique(sfile_spec);
- }
- }
- } else {
- const char *cur_file_name =
- context.comp_unit->GetPrimaryFile().GetFilename().GetCString();
- const char *cur_dir_name =
- context.comp_unit->GetPrimaryFile().GetDirectory().GetCString();
-
- bool match = false;
- if (m_file_name && cur_file_name &&
- strstr(cur_file_name, m_file_name) == cur_file_name)
- match = true;
-
- if (match && m_dir_name && cur_dir_name &&
- strstr(cur_dir_name, m_dir_name) != cur_dir_name)
- match = false;
-
- if (match) {
- m_matching_files.AppendIfUnique(context.comp_unit->GetPrimaryFile());
- }
+ const char *cur_file_name =
+ context.comp_unit->GetPrimaryFile().GetFilename().GetCString();
+ const char *cur_dir_name =
+ context.comp_unit->GetPrimaryFile().GetDirectory().GetCString();
+
+ bool match = false;
+ if (m_file_name && cur_file_name &&
+ strstr(cur_file_name, m_file_name) == cur_file_name)
+ match = true;
+
+ if (match && m_dir_name && cur_dir_name &&
+ strstr(cur_dir_name, m_dir_name) != cur_dir_name)
+ match = false;
+
+ if (match) {
+ m_matching_files.AppendIfUnique(context.comp_unit->GetPrimaryFile());
}
}
return Searcher::eCallbackReturnContinue;