Skip to content

Commit

Permalink
Revert "[lldb] Ignore libcxx std::ranges global variables in frame var"
Browse files Browse the repository at this point in the history
Reverting because Xcode requires this to be handled elsewhere.
The global variable list gets constructed using the SBAPI

This reverts commit de10c1a.
  • Loading branch information
Michael137 committed Mar 7, 2023
1 parent a97bdba commit b7e667b
Show file tree
Hide file tree
Showing 7 changed files with 2 additions and 69 deletions.
5 changes: 0 additions & 5 deletions lldb/include/lldb/Target/LanguageRuntime.h
Expand Up @@ -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;
}
Expand Down
12 changes: 2 additions & 10 deletions lldb/source/Core/ValueObject.cpp
Expand Up @@ -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;

Expand Down
Expand Up @@ -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;
Expand All @@ -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;
}
Expand Down
Expand Up @@ -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
Expand Down
4 changes: 0 additions & 4 deletions lldb/test/API/lang/cpp/hide_global_ranges_vars/Makefile

This file was deleted.

This file was deleted.

9 changes: 0 additions & 9 deletions lldb/test/API/lang/cpp/hide_global_ranges_vars/main.cpp

This file was deleted.

0 comments on commit b7e667b

Please sign in to comment.