[Lldb-commits] [lldb] b7e667b - Revert "[lldb] Ignore libcxx std::ranges global variables in frame var"

Michael Buch via lldb-commits lldb-commits at lists.llvm.org
Tue Mar 7 03:26:46 PST 2023


Author: Michael Buch
Date: 2023-03-07T11:25:36Z
New Revision: b7e667bfd2a9bce0e3d5ca9fd6b97da553e03bd9

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

LOG: Revert "[lldb] Ignore libcxx std::ranges global variables in frame var"

Reverting because Xcode requires this to be handled elsewhere.
The global variable list gets constructed using the SBAPI

This reverts commit de10c1a824405833a0f49b22e7fa3f32a1393cc3.

Added: 
    

Modified: 
    lldb/include/lldb/Target/LanguageRuntime.h
    lldb/source/Core/ValueObject.cpp
    lldb/source/Plugins/LanguageRuntime/CPlusPlus/CPPLanguageRuntime.cpp
    lldb/source/Plugins/LanguageRuntime/CPlusPlus/CPPLanguageRuntime.h

Removed: 
    lldb/test/API/lang/cpp/hide_global_ranges_vars/Makefile
    lldb/test/API/lang/cpp/hide_global_ranges_vars/TestHideGlobalRangesVars.py
    lldb/test/API/lang/cpp/hide_global_ranges_vars/main.cpp


################################################################################
diff  --git a/lldb/include/lldb/Target/LanguageRuntime.h b/lldb/include/lldb/Target/LanguageRuntime.h
index 34f0fdb9cfbc9..9cc79dc976c4d 100644
--- a/lldb/include/lldb/Target/LanguageRuntime.h
+++ b/lldb/include/lldb/Target/LanguageRuntime.h
@@ -151,11 +151,6 @@ class LanguageRuntime : public Runtime, public PluginInterface {
   /// from the user interface.
   virtual bool IsAllowedRuntimeValue(ConstString name) { return false; }
 
-  /// Returns 'true' if we the variable with the specified 'name'
-  /// should be hidden from variable views (e.g., when listing variables in
-  /// 'frame variable' or 'target variable')
-  virtual bool ShouldHideVariable(llvm::StringRef name) const { return false; }
-
   virtual std::optional<CompilerType> GetRuntimeType(CompilerType base_type) {
     return std::nullopt;
   }

diff  --git a/lldb/source/Core/ValueObject.cpp b/lldb/source/Core/ValueObject.cpp
index f3ca16781e9ad..6e79a04d024e5 100644
--- a/lldb/source/Core/ValueObject.cpp
+++ b/lldb/source/Core/ValueObject.cpp
@@ -1600,20 +1600,12 @@ bool ValueObject::IsRuntimeSupportValue() {
   if (!process)
     return false;
 
-  if (!GetVariable())
-    return false;
-
-  auto *runtime = process->GetLanguageRuntime(GetVariable()->GetLanguage());
-  if (runtime)
-    if (runtime->ShouldHideVariable(GetName().GetStringRef()))
-      return true;
-
   // We trust that the compiler did the right thing and marked runtime support
   // values as artificial.
-  if (!GetVariable()->IsArtificial())
+  if (!GetVariable() || !GetVariable()->IsArtificial())
     return false;
 
-  if (runtime)
+  if (auto *runtime = process->GetLanguageRuntime(GetVariable()->GetLanguage()))
     if (runtime->IsAllowedRuntimeValue(GetName()))
       return false;
 

diff  --git a/lldb/source/Plugins/LanguageRuntime/CPlusPlus/CPPLanguageRuntime.cpp b/lldb/source/Plugins/LanguageRuntime/CPlusPlus/CPPLanguageRuntime.cpp
index 5945c57e5aa74..0028a51412873 100644
--- a/lldb/source/Plugins/LanguageRuntime/CPlusPlus/CPPLanguageRuntime.cpp
+++ b/lldb/source/Plugins/LanguageRuntime/CPlusPlus/CPPLanguageRuntime.cpp
@@ -28,7 +28,6 @@
 #include "lldb/Target/StackFrame.h"
 #include "lldb/Target/ThreadPlanRunToAddress.h"
 #include "lldb/Target/ThreadPlanStepInRange.h"
-#include "lldb/Utility/RegularExpression.h"
 #include "lldb/Utility/Timer.h"
 
 using namespace lldb;
@@ -41,17 +40,6 @@ char CPPLanguageRuntime::ID = 0;
 CPPLanguageRuntime::CPPLanguageRuntime(Process *process)
     : LanguageRuntime(process) {}
 
-bool CPPLanguageRuntime::ShouldHideVariable(llvm::StringRef name) const {
-  // Matches the global function objects in std::ranges/std::ranges::views
-  // E.g.,
-  //   std::__1::ranges::views::__cpo::take
-  //   std::__1::ranges::__cpo::max_element
-  static RegularExpression ignore_global_ranges_pattern(
-      "std::__[[:alnum:]]+::ranges(::views)*::__cpo");
-
-  return ignore_globale_ranges_pattern.Execute(name);
-}
-
 bool CPPLanguageRuntime::IsAllowedRuntimeValue(ConstString name) {
   return name == g_this;
 }

diff  --git a/lldb/source/Plugins/LanguageRuntime/CPlusPlus/CPPLanguageRuntime.h b/lldb/source/Plugins/LanguageRuntime/CPlusPlus/CPPLanguageRuntime.h
index 097d1da6e909a..1be58b7bf9ea9 100644
--- a/lldb/source/Plugins/LanguageRuntime/CPlusPlus/CPPLanguageRuntime.h
+++ b/lldb/source/Plugins/LanguageRuntime/CPlusPlus/CPPLanguageRuntime.h
@@ -77,8 +77,6 @@ class CPPLanguageRuntime : public LanguageRuntime {
   lldb::ThreadPlanSP GetStepThroughTrampolinePlan(Thread &thread,
                                                   bool stop_others) override;
 
-  bool ShouldHideVariable(llvm::StringRef name) const override;
-
   bool IsAllowedRuntimeValue(ConstString name) override;
 protected:
   // Classes that inherit from CPPLanguageRuntime can see and modify these

diff  --git a/lldb/test/API/lang/cpp/hide_global_ranges_vars/Makefile b/lldb/test/API/lang/cpp/hide_global_ranges_vars/Makefile
deleted file mode 100644
index 4f79c0a900c3a..0000000000000
--- a/lldb/test/API/lang/cpp/hide_global_ranges_vars/Makefile
+++ /dev/null
@@ -1,4 +0,0 @@
-CXX_SOURCES := main.cpp
-CXXFLAGS_EXTRAS := -std=c++20
-
-include Makefile.rules

diff  --git a/lldb/test/API/lang/cpp/hide_global_ranges_vars/TestHideGlobalRangesVars.py b/lldb/test/API/lang/cpp/hide_global_ranges_vars/TestHideGlobalRangesVars.py
deleted file mode 100644
index f7b98a55341df..0000000000000
--- a/lldb/test/API/lang/cpp/hide_global_ranges_vars/TestHideGlobalRangesVars.py
+++ /dev/null
@@ -1,27 +0,0 @@
-"""Test that frame var and target var hide
-the global function objects in the libc++
-ranges implementation"""
-
-from lldbsuite.test.decorators import *
-from lldbsuite.test.lldbtest import *
-from lldbsuite.test import lldbutil
-
-class HideGlobalRangesVarsTestCase(TestBase):
-
-    @add_test_categories(["libc++"])
-    @skipIf(compiler=no_match("clang"))
-    @skipIf(compiler="clang", compiler_version=['<', '16.0'])
-    def test(self):
-        self.build()
-
-        lldbutil.run_to_source_breakpoint(self, "return", lldb.SBFileSpec('main.cpp', False))
-
-        self.expect("frame variable --show-globals",
-                    substrs=["::ranges::views::__cpo",
-                             "::ranges::__cpo"],
-                    matching=False)
-
-        self.expect("target variable",
-                    substrs=["::ranges::views::__cpo",
-                             "::ranges::__cpo"],
-                    matching=False)

diff  --git a/lldb/test/API/lang/cpp/hide_global_ranges_vars/main.cpp b/lldb/test/API/lang/cpp/hide_global_ranges_vars/main.cpp
deleted file mode 100644
index 96a05f846396a..0000000000000
--- a/lldb/test/API/lang/cpp/hide_global_ranges_vars/main.cpp
+++ /dev/null
@@ -1,9 +0,0 @@
-#include <ranges>
-
-int main(int argc, char const *argv[]) {
-  int arr[3] = {1, 2, 3};
-  auto arr_view = std::ranges::views::all(arr);
-  auto arr_max = std::ranges::max_element(arr);
-
-  return 0;
-}


        


More information about the lldb-commits mailing list