[Lldb-commits] [PATCH] D158788: [lldb-vscode] Use a switch to avoid else-after-return

Jonas Devlieghere via Phabricator via lldb-commits lldb-commits at lists.llvm.org
Thu Aug 24 15:51:00 PDT 2023


JDevlieghere created this revision.
JDevlieghere added a reviewer: wallace.
Herald added a project: All.
JDevlieghere requested review of this revision.

Use a switch to avoid else-after-return.


https://reviews.llvm.org/D158788

Files:
  lldb/tools/lldb-vscode/ProgressEvent.cpp


Index: lldb/tools/lldb-vscode/ProgressEvent.cpp
===================================================================
--- lldb/tools/lldb-vscode/ProgressEvent.cpp
+++ lldb/tools/lldb-vscode/ProgressEvent.cpp
@@ -9,6 +9,7 @@
 #include "ProgressEvent.h"
 
 #include "JSONUtils.h"
+#include "llvm/Support/ErrorHandling.h"
 #include <optional>
 
 using namespace lldb_vscode;
@@ -91,12 +92,15 @@
 ProgressEventType ProgressEvent::GetEventType() const { return m_event_type; }
 
 StringRef ProgressEvent::GetEventName() const {
-  if (m_event_type == progressStart)
+  switch (m_event_type) {
+  case progressStart:
     return "progressStart";
-  else if (m_event_type == progressEnd)
-    return "progressEnd";
-  else
+  case progressUpdate:
     return "progressUpdate";
+  case progressEnd:
+    return "progressEnd";
+  }
+  llvm_unreachable("All cases handled above!");
 }
 
 json::Value ProgressEvent::ToJSON() const {


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D158788.553287.patch
Type: text/x-patch
Size: 920 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/lldb-commits/attachments/20230824/54a86b24/attachment.bin>


More information about the lldb-commits mailing list