Hide runtime support values such as clang's __vla_expr from frame variable
by respecting the "artificial" attribute on variables. Function
arguments that are artificial and useful to end-users are being
whitelisted by the language runtime.
<rdar://problem/45322477>
Differential Revision: https://reviews.llvm.org/D61451
llvm-svn: 359841
diff --git a/lldb/source/Target/CPPLanguageRuntime.cpp b/lldb/source/Target/CPPLanguageRuntime.cpp
index dfc7ff8..16387e8 100644
--- a/lldb/source/Target/CPPLanguageRuntime.cpp
+++ b/lldb/source/Target/CPPLanguageRuntime.cpp
@@ -7,6 +7,7 @@
//===----------------------------------------------------------------------===//
#include "lldb/Target/CPPLanguageRuntime.h"
+#include "lldb/Target/ObjCLanguageRuntime.h"
#include <string.h>
@@ -15,6 +16,7 @@
#include "llvm/ADT/StringRef.h"
#include "lldb/Symbol/Block.h"
+#include "lldb/Symbol/Variable.h"
#include "lldb/Symbol/VariableList.h"
#include "lldb/Core/PluginManager.h"
@@ -31,12 +33,30 @@
using namespace lldb;
using namespace lldb_private;
+static ConstString g_this = ConstString("this");
+
// Destructor
CPPLanguageRuntime::~CPPLanguageRuntime() {}
CPPLanguageRuntime::CPPLanguageRuntime(Process *process)
: LanguageRuntime(process) {}
+bool CPPLanguageRuntime::IsRuntimeSupportValue(ValueObject &valobj) {
+ // All runtime support values have to be marked as artificial by the
+ // compiler. But not all artificial variables should be hidden from
+ // the user.
+ if (!valobj.GetVariable())
+ return false;
+ if (!valobj.GetVariable()->IsArtificial())
+ return false;
+
+ // Whitelist "this" and since there is no ObjC++ runtime, any ObjC names.
+ ConstString name = valobj.GetName();
+ if (name == g_this)
+ return false;
+ return !ObjCLanguageRuntime::IsWhitelistedRuntimeValue(name);
+}
+
bool CPPLanguageRuntime::GetObjectDescription(Stream &str,
ValueObject &object) {
// C++ has no generic way to do this.
@@ -317,7 +337,7 @@
StackFrameSP frame = thread.GetStackFrameAtIndex(0);
if (frame) {
- ValueObjectSP value_sp = frame->FindVariable(ConstString("this"));
+ ValueObjectSP value_sp = frame->FindVariable(g_this);
CPPLanguageRuntime::LibCppStdFunctionCallableInfo callable_info =
FindLibCppStdFunctionCallableInfo(value_sp);