diff options
| author | Enrico Granata <egranata@apple.com> | 2015-01-22 03:07:34 +0000 |
|---|---|---|
| committer | Enrico Granata <egranata@apple.com> | 2015-01-22 03:07:34 +0000 |
| commit | de61ebafcfa3445869e223802bc2cd75b08aab60 (patch) | |
| tree | 35c9aefc6bce29d56f7b7ba0bcf9d78509acf5b9 /lldb/source | |
| parent | 2e4db3d00ce680801fa82ed19fc750e280cb372d (diff) | |
| download | bcm5719-llvm-de61ebafcfa3445869e223802bc2cd75b08aab60.tar.gz bcm5719-llvm-de61ebafcfa3445869e223802bc2cd75b08aab60.zip | |
Add an API to ValueObject that iterates over the entire parent chain via a callback, and rewrite GetRoot() in terms of this general iteration API. NFC
llvm-svn: 226771
Diffstat (limited to 'lldb/source')
| -rw-r--r-- | lldb/source/Core/ValueObject.cpp | 22 |
1 files changed, 14 insertions, 8 deletions
diff --git a/lldb/source/Core/ValueObject.cpp b/lldb/source/Core/ValueObject.cpp index 3b9a7ab049d..7231f0187ee 100644 --- a/lldb/source/Core/ValueObject.cpp +++ b/lldb/source/Core/ValueObject.cpp @@ -4130,16 +4130,22 @@ ValueObject::GetRoot () { if (m_root) return m_root; - ValueObject* parent = m_parent; - if (!parent) - return (m_root = this); - while (parent->m_parent) + return (m_root = FollowParentChain( [] (ValueObject* vo) -> bool { + return (vo->m_parent != nullptr); + })); +} + +ValueObject* +ValueObject::FollowParentChain (std::function<bool(ValueObject*)> f) +{ + ValueObject* vo = this; + while (vo) { - if (parent->m_root) - return (m_root = parent->m_root); - parent = parent->m_parent; + if (f(vo) == false) + break; + vo = vo->m_parent; } - return (m_root = parent); + return vo; } AddressType |

