From cfca06d7963fa0909f90483b42a6d7d194d01e08 Mon Sep 17 00:00:00 2001 From: Dimitry Andric Date: Sun, 26 Jul 2020 19:36:28 +0000 Subject: Vendor import of llvm-project master 2e10b7a39b9, the last commit before the llvmorg-12-init tag, from which release/11.x was branched. --- lldb/source/Plugins/Language/CPlusPlus/LibCxxOptional.cpp | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) (limited to 'lldb/source/Plugins/Language/CPlusPlus/LibCxxOptional.cpp') diff --git a/lldb/source/Plugins/Language/CPlusPlus/LibCxxOptional.cpp b/lldb/source/Plugins/Language/CPlusPlus/LibCxxOptional.cpp index b1ad171d0b0c..c0c819632851 100644 --- a/lldb/source/Plugins/Language/CPlusPlus/LibCxxOptional.cpp +++ b/lldb/source/Plugins/Language/CPlusPlus/LibCxxOptional.cpp @@ -1,4 +1,4 @@ -//===-- LibCxxOptional.cpp --------------------------------------*- C++ -*-===// +//===-- LibCxxOptional.cpp ------------------------------------------------===// // // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. // See https://llvm.org/LICENSE.txt for license information. @@ -26,11 +26,12 @@ public: bool MightHaveChildren() override { return true; } bool Update() override; - size_t CalculateNumChildren() override { return m_size; } + size_t CalculateNumChildren() override { return m_has_value ? 1U : 0U; } ValueObjectSP GetChildAtIndex(size_t idx) override; private: - size_t m_size = 0; + /// True iff the option contains a value. + bool m_has_value = false; }; } // namespace @@ -44,13 +45,13 @@ bool OptionalFrontEnd::Update() { // __engaged_ is a bool flag and is true if the optional contains a value. // Converting it to unsigned gives us a size of 1 if it contains a value // and 0 if not. - m_size = engaged_sp->GetValueAsUnsigned(0); + m_has_value = engaged_sp->GetValueAsUnsigned(0) == 1; return false; } ValueObjectSP OptionalFrontEnd::GetChildAtIndex(size_t idx) { - if (idx >= m_size) + if (!m_has_value) return ValueObjectSP(); // __val_ contains the underlying value of an optional if it has one. @@ -71,7 +72,7 @@ ValueObjectSP OptionalFrontEnd::GetChildAtIndex(size_t idx) { if (!holder_type) return ValueObjectSP(); - return val_sp->Clone(ConstString(llvm::formatv("Value").str())); + return val_sp->Clone(ConstString("Value")); } SyntheticChildrenFrontEnd * -- cgit v1.2.3