[Lldb-commits] [lldb] 6217468 - [lldb][NFC] Remove support file searching from SourceFileCompleter

Raphael Isemann via lldb-commits lldb-commits at lists.llvm.org
Tue Feb 11 09:50:51 PST 2020


Author: Raphael Isemann
Date: 2020-02-11T18:50:25+01:00
New Revision: 62174682a039efce2ce7606d5416d2450ff42dab

URL: https://github.com/llvm/llvm-project/commit/62174682a039efce2ce7606d5416d2450ff42dab
DIFF: https://github.com/llvm/llvm-project/commit/62174682a039efce2ce7606d5416d2450ff42dab.diff

LOG: [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.

Added: 
    

Modified: 
    lldb/include/lldb/Interpreter/CommandCompletions.h
    lldb/source/Commands/CommandCompletions.cpp

Removed: 
    


################################################################################
diff  --git a/lldb/include/lldb/Interpreter/CommandCompletions.h b/lldb/include/lldb/Interpreter/CommandCompletions.h
index 275cc7e7c145..39061d9db8bc 100644
--- a/lldb/include/lldb/Interpreter/CommandCompletions.h
+++ b/lldb/include/lldb/Interpreter/CommandCompletions.h
@@ -121,7 +121,7 @@ class CommandCompletions {
   class SourceFileCompleter : public Completer {
   public:
     SourceFileCompleter(CommandInterpreter &interpreter,
-                        bool include_support_files, CompletionRequest &request);
+                        CompletionRequest &request);
 
     lldb::SearchDepth GetDepth() override;
 
@@ -132,7 +132,6 @@ class CommandCompletions {
     void DoCompletion(SearchFilter *filter) override;
 
   private:
-    bool m_include_support_files;
     FileSpecList m_matching_files;
     const char *m_file_name;
     const char *m_dir_name;

diff  --git a/lldb/source/Commands/CommandCompletions.cpp b/lldb/source/Commands/CommandCompletions.cpp
index e5f29115a8a7..2ced56f90178 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;


        


More information about the lldb-commits mailing list