[Lldb-commits] [PATCH] D155332: [lldb][NFC] Factor out CommandObject code filtering results based on scope

Felipe de Azevedo Piovezan via Phabricator via lldb-commits lldb-commits at lists.llvm.org
Wed Jul 19 06:14:45 PDT 2023


This revision was automatically updated to reflect the committed changes.
Closed by commit rG8bc97a3ee4f4: [lldb][NFC] Factor out CommandObject code filtering results based on scope (authored by fdeazeve).

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D155332/new/

https://reviews.llvm.org/D155332

Files:
  lldb/source/Commands/CommandObjectFrame.cpp


Index: lldb/source/Commands/CommandObjectFrame.cpp
===================================================================
--- lldb/source/Commands/CommandObjectFrame.cpp
+++ lldb/source/Commands/CommandObjectFrame.cpp
@@ -480,6 +480,25 @@
     return llvm::StringRef();
   }
 
+  /// Returns true if `scope` matches any of the options in `m_option_variable`.
+  bool ScopeRequested(lldb::ValueType scope) {
+    switch (scope) {
+    case eValueTypeVariableGlobal:
+    case eValueTypeVariableStatic:
+      return m_option_variable.show_globals;
+    case eValueTypeVariableArgument:
+      return m_option_variable.show_args;
+    case eValueTypeVariableLocal:
+      return m_option_variable.show_locals;
+    case eValueTypeInvalid:
+    case eValueTypeRegister:
+    case eValueTypeRegisterSet:
+    case eValueTypeConstResult:
+    case eValueTypeVariableThreadLocal:
+      return false;
+    }
+  }
+
   bool DoExecute(Args &command, CommandReturnObject &result) override {
     // No need to check "frame" for validity as eCommandRequiresFrame ensures
     // it is valid
@@ -630,27 +649,8 @@
         if (num_variables > 0) {
           for (size_t i = 0; i < num_variables; i++) {
             var_sp = variable_list->GetVariableAtIndex(i);
-            switch (var_sp->GetScope()) {
-            case eValueTypeVariableGlobal:
-              if (!m_option_variable.show_globals)
-                continue;
-              break;
-            case eValueTypeVariableStatic:
-              if (!m_option_variable.show_globals)
+            if (!ScopeRequested(var_sp->GetScope()))
                 continue;
-              break;
-            case eValueTypeVariableArgument:
-              if (!m_option_variable.show_args)
-                continue;
-              break;
-            case eValueTypeVariableLocal:
-              if (!m_option_variable.show_locals)
-                continue;
-              break;
-            default:
-              continue;
-              break;
-            }
             std::string scope_string;
             if (m_option_variable.show_scope)
               scope_string = GetScopeString(var_sp).str();


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D155332.541984.patch
Type: text/x-patch
Size: 2153 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/lldb-commits/attachments/20230719/50587142/attachment-0001.bin>


More information about the lldb-commits mailing list