[lldb][NFC] NFC cleanup for the completion code

llvm-svn: 369632
diff --git a/lldb/source/Commands/CommandObjectHelp.cpp b/lldb/source/Commands/CommandObjectHelp.cpp
index 811841f..78e19f7 100644
--- a/lldb/source/Commands/CommandObjectHelp.cpp
+++ b/lldb/source/Commands/CommandObjectHelp.cpp
@@ -205,20 +205,20 @@
   // Return the completions of the commands in the help system:
   if (request.GetCursorIndex() == 0) {
     m_interpreter.HandleCompletionMatches(request);
-  } else {
-    CommandObject *cmd_obj =
-        m_interpreter.GetCommandObject(request.GetParsedLine()[0].ref);
-
-    // The command that they are getting help on might be ambiguous, in which
-    // case we should complete that, otherwise complete with the command the
-    // user is getting help on...
-
-    if (cmd_obj) {
-      request.GetParsedLine().Shift();
-      request.SetCursorIndex(request.GetCursorIndex() - 1);
-      cmd_obj->HandleCompletion(request);
-    } else {
-      m_interpreter.HandleCompletionMatches(request);
-    }
+    return;
   }
+  CommandObject *cmd_obj =
+      m_interpreter.GetCommandObject(request.GetParsedLine()[0].ref);
+
+  // The command that they are getting help on might be ambiguous, in which
+  // case we should complete that, otherwise complete with the command the
+  // user is getting help on...
+
+  if (cmd_obj) {
+    request.GetParsedLine().Shift();
+    request.SetCursorIndex(request.GetCursorIndex() - 1);
+    cmd_obj->HandleCompletion(request);
+    return;
+  }
+  m_interpreter.HandleCompletionMatches(request);
 }
diff --git a/lldb/source/Commands/CommandObjectMultiword.cpp b/lldb/source/Commands/CommandObjectMultiword.cpp
index ecc73a8..a223d70 100644
--- a/lldb/source/Commands/CommandObjectMultiword.cpp
+++ b/lldb/source/Commands/CommandObjectMultiword.cpp
@@ -201,20 +201,22 @@
         }
       }
     }
-  } else {
-    StringList new_matches;
-    CommandObject *sub_command_object = GetSubcommandObject(arg0, &new_matches);
-    if (sub_command_object == nullptr) {
-      request.AddCompletions(new_matches);
-    } else {
-      // Remove the one match that we got from calling GetSubcommandObject.
-      new_matches.DeleteStringAtIndex(0);
-      request.AddCompletions(new_matches);
-      request.GetParsedLine().Shift();
-      request.SetCursorIndex(request.GetCursorIndex() - 1);
-      return sub_command_object->HandleCompletion(request);
-    }
+    return;
   }
+
+  StringList new_matches;
+  CommandObject *sub_command_object = GetSubcommandObject(arg0, &new_matches);
+  if (sub_command_object == nullptr) {
+    request.AddCompletions(new_matches);
+    return;
+  }
+
+  // Remove the one match that we got from calling GetSubcommandObject.
+  new_matches.DeleteStringAtIndex(0);
+  request.AddCompletions(new_matches);
+  request.GetParsedLine().Shift();
+  request.SetCursorIndex(request.GetCursorIndex() - 1);
+  sub_command_object->HandleCompletion(request);
 }
 
 const char *CommandObjectMultiword::GetRepeatCommand(Args &current_command_args,
diff --git a/lldb/source/Commands/CommandObjectPlatform.cpp b/lldb/source/Commands/CommandObjectPlatform.cpp
index c1e78d7..8433fbd 100644
--- a/lldb/source/Commands/CommandObjectPlatform.cpp
+++ b/lldb/source/Commands/CommandObjectPlatform.cpp
@@ -1440,36 +1440,37 @@
 
       // We are only completing the name option for now...
 
-      if (GetDefinitions()[opt_defs_index].short_option == 'n') {
-        // Are we in the name?
+      // Are we in the name?
+      if (GetDefinitions()[opt_defs_index].short_option != 'n')
+        return false;
 
-        // Look to see if there is a -P argument provided, and if so use that
-        // plugin, otherwise use the default plugin.
+      // Look to see if there is a -P argument provided, and if so use that
+      // plugin, otherwise use the default plugin.
 
-        const char *partial_name = nullptr;
-        partial_name = request.GetParsedLine().GetArgumentAtIndex(opt_arg_pos);
+      const char *partial_name = nullptr;
+      partial_name = request.GetParsedLine().GetArgumentAtIndex(opt_arg_pos);
 
-        PlatformSP platform_sp(interpreter.GetPlatform(true));
-        if (platform_sp) {
-          ProcessInstanceInfoList process_infos;
-          ProcessInstanceInfoMatch match_info;
-          if (partial_name) {
-            match_info.GetProcessInfo().GetExecutableFile().SetFile(
-                partial_name, FileSpec::Style::native);
-            match_info.SetNameMatchType(NameMatch::StartsWith);
-          }
-          platform_sp->FindProcesses(match_info, process_infos);
-          const uint32_t num_matches = process_infos.GetSize();
-          if (num_matches > 0) {
-            for (uint32_t i = 0; i < num_matches; ++i) {
-              request.AddCompletion(llvm::StringRef(
-                  process_infos.GetProcessNameAtIndex(i),
-                  process_infos.GetProcessNameLengthAtIndex(i)));
-            }
-          }
-        }
+      PlatformSP platform_sp(interpreter.GetPlatform(true));
+      if (!platform_sp)
+        return false;
+
+      ProcessInstanceInfoList process_infos;
+      ProcessInstanceInfoMatch match_info;
+      if (partial_name) {
+        match_info.GetProcessInfo().GetExecutableFile().SetFile(
+            partial_name, FileSpec::Style::native);
+        match_info.SetNameMatchType(NameMatch::StartsWith);
       }
+      platform_sp->FindProcesses(match_info, process_infos);
+      const uint32_t num_matches = process_infos.GetSize();
+      if (num_matches == 0)
+        return false;
 
+      for (uint32_t i = 0; i < num_matches; ++i) {
+        request.AddCompletion(
+            llvm::StringRef(process_infos.GetProcessNameAtIndex(i),
+                            process_infos.GetProcessNameLengthAtIndex(i)));
+      }
       return false;
     }
 
diff --git a/lldb/source/Commands/CommandObjectProcess.cpp b/lldb/source/Commands/CommandObjectProcess.cpp
index 10af1a3..1a1378b 100644
--- a/lldb/source/Commands/CommandObjectProcess.cpp
+++ b/lldb/source/Commands/CommandObjectProcess.cpp
@@ -328,35 +328,35 @@
 
       // We are only completing the name option for now...
 
-      if (GetDefinitions()[opt_defs_index].short_option == 'n') {
-        // Are we in the name?
+      // Are we in the name?
+      if (GetDefinitions()[opt_defs_index].short_option != 'n')
+        return false;
 
-        // Look to see if there is a -P argument provided, and if so use that
-        // plugin, otherwise use the default plugin.
+      // Look to see if there is a -P argument provided, and if so use that
+      // plugin, otherwise use the default plugin.
 
-        const char *partial_name = nullptr;
-        partial_name = request.GetParsedLine().GetArgumentAtIndex(opt_arg_pos);
+      const char *partial_name = nullptr;
+      partial_name = request.GetParsedLine().GetArgumentAtIndex(opt_arg_pos);
 
-        PlatformSP platform_sp(interpreter.GetPlatform(true));
-        if (platform_sp) {
-          ProcessInstanceInfoList process_infos;
-          ProcessInstanceInfoMatch match_info;
-          if (partial_name) {
-            match_info.GetProcessInfo().GetExecutableFile().SetFile(
-                partial_name, FileSpec::Style::native);
-            match_info.SetNameMatchType(NameMatch::StartsWith);
-          }
+      PlatformSP platform_sp(interpreter.GetPlatform(true));
+      if (!platform_sp)
+        return false;
+      ProcessInstanceInfoList process_infos;
+      ProcessInstanceInfoMatch match_info;
+      if (partial_name) {
+        match_info.GetProcessInfo().GetExecutableFile().SetFile(
+            partial_name, FileSpec::Style::native);
+        match_info.SetNameMatchType(NameMatch::StartsWith);
+      }
           platform_sp->FindProcesses(match_info, process_infos);
           const size_t num_matches = process_infos.GetSize();
-          if (num_matches > 0) {
-            for (size_t i = 0; i < num_matches; ++i) {
-              request.AddCompletion(llvm::StringRef(
-                  process_infos.GetProcessNameAtIndex(i),
-                  process_infos.GetProcessNameLengthAtIndex(i)));
-            }
+          if (num_matches == 0)
+            return false;
+          for (size_t i = 0; i < num_matches; ++i) {
+            request.AddCompletion(
+                llvm::StringRef(process_infos.GetProcessNameAtIndex(i),
+                                process_infos.GetProcessNameLengthAtIndex(i)));
           }
-        }
-      }
 
       return false;
     }
diff --git a/lldb/source/Commands/CommandObjectSettings.cpp b/lldb/source/Commands/CommandObjectSettings.cpp
index 05e8ec9..5f6a4dc 100644
--- a/lldb/source/Commands/CommandObjectSettings.cpp
+++ b/lldb/source/Commands/CommandObjectSettings.cpp
@@ -142,26 +142,27 @@
       CommandCompletions::InvokeCommonCompletionCallbacks(
           GetCommandInterpreter(), CommandCompletions::eSettingsNameCompletion,
           request, nullptr);
-    } else {
+      return;
+    }
       arg =
           request.GetParsedLine().GetArgumentAtIndex(request.GetCursorIndex());
 
-      if (arg) {
-        if (arg[0] == '-') {
-          // Complete option name
-        } else {
-          // Complete setting value
-          const char *setting_var_name =
-              request.GetParsedLine().GetArgumentAtIndex(setting_var_idx);
-          Status error;
-          lldb::OptionValueSP value_sp(GetDebugger().GetPropertyValue(
-              &m_exe_ctx, setting_var_name, false, error));
-          if (value_sp) {
-            value_sp->AutoComplete(m_interpreter, request);
-          }
-        }
-      }
-    }
+      if (!arg)
+        return;
+
+      // Complete option name
+      if (arg[0] != '-')
+        return;
+
+      // Complete setting value
+      const char *setting_var_name =
+          request.GetParsedLine().GetArgumentAtIndex(setting_var_idx);
+      Status error;
+      lldb::OptionValueSP value_sp(GetDebugger().GetPropertyValue(
+          &m_exe_ctx, setting_var_name, false, error));
+      if (!value_sp)
+        return;
+      value_sp->AutoComplete(m_interpreter, request);
   }
 
 protected: