[ValueObjectSynthetic and ValueObjectDynamicValue] Override GetDeclaration
Summary:
Returns the declaration of the parent (non-synthetic or static) value.
Reviewers: granata.enrico, clayborg
Subscribers: lldb-commits
Differential Revision: http://reviews.llvm.org/D12092
llvm-svn: 245319
diff --git a/lldb/include/lldb/Core/ValueObjectDynamicValue.h b/lldb/include/lldb/Core/ValueObjectDynamicValue.h
index 1b43f98..ecc760e 100644
--- a/lldb/include/lldb/Core/ValueObjectDynamicValue.h
+++ b/lldb/include/lldb/Core/ValueObjectDynamicValue.h
@@ -85,7 +85,7 @@
{
return m_parent->GetSP();
}
-
+
void
SetOwningSP (lldb::ValueObjectSP &owning_sp)
{
@@ -105,6 +105,9 @@
virtual TypeImpl
GetTypeImpl ();
+ virtual bool
+ GetDeclaration (Declaration &decl);
+
protected:
virtual bool
UpdateValue ();
diff --git a/lldb/include/lldb/Core/ValueObjectSyntheticFilter.h b/lldb/include/lldb/Core/ValueObjectSyntheticFilter.h
index 40b0809..d6c2d2b 100644
--- a/lldb/include/lldb/Core/ValueObjectSyntheticFilter.h
+++ b/lldb/include/lldb/Core/ValueObjectSyntheticFilter.h
@@ -152,6 +152,9 @@
virtual void
SetFormat (lldb::Format format);
+ virtual bool
+ GetDeclaration (Declaration &decl);
+
protected:
virtual bool
UpdateValue ();
diff --git a/lldb/source/Core/ValueObjectDynamicValue.cpp b/lldb/source/Core/ValueObjectDynamicValue.cpp
index 80c16c8..0085a33 100644
--- a/lldb/source/Core/ValueObjectDynamicValue.cpp
+++ b/lldb/source/Core/ValueObjectDynamicValue.cpp
@@ -421,3 +421,12 @@
SetNeedsUpdate();
return ret_val;
}
+
+bool
+ValueObjectDynamicValue::GetDeclaration (Declaration &decl)
+{
+ if (m_parent)
+ return m_parent->GetDeclaration(decl);
+
+ return ValueObject::GetDeclaration(decl);
+}
diff --git a/lldb/source/Core/ValueObjectSyntheticFilter.cpp b/lldb/source/Core/ValueObjectSyntheticFilter.cpp
index 2a20ae3..ee8587c 100644
--- a/lldb/source/Core/ValueObjectSyntheticFilter.cpp
+++ b/lldb/source/Core/ValueObjectSyntheticFilter.cpp
@@ -314,3 +314,12 @@
this->ValueObject::SetFormat(format);
this->ClearUserVisibleData(eClearUserVisibleDataItemsAll);
}
+
+bool
+ValueObjectSynthetic::GetDeclaration (Declaration &decl)
+{
+ if (m_parent)
+ return m_parent->GetDeclaration(decl);
+
+ return ValueObject::GetDeclaration(decl);
+}
diff --git a/lldb/test/python_api/formatters/TestFormattersSBAPI.py b/lldb/test/python_api/formatters/TestFormattersSBAPI.py
index bd71ff3..39d123a 100644
--- a/lldb/test/python_api/formatters/TestFormattersSBAPI.py
+++ b/lldb/test/python_api/formatters/TestFormattersSBAPI.py
@@ -169,6 +169,7 @@
foo_var = self.dbg.GetSelectedTarget().GetProcess().GetSelectedThread().GetSelectedFrame().FindVariable('foo')
self.assertTrue(foo_var.IsValid(), 'could not find foo')
+ self.assertTrue(foo_var.GetDeclaration().IsValid(), 'foo declaration is invalid')
self.assertTrue(foo_var.GetNumChildren() == 2, 'synthetic value has wrong number of child items (synth)')
self.assertTrue(foo_var.GetChildMemberWithName('X').GetValueAsUnsigned() == 1, 'foo_synth.X has wrong value (synth)')