From 4b58867d0688e7dc559a8bde0f3f987c311dd2b2 Mon Sep 17 00:00:00 2001 From: Davide Italiano Date: Wed, 25 Jul 2018 21:18:20 +0000 Subject: [PATCH] Revert "[DataFormatters] Add formatter for C++17 std::optional." I forgot to git add some files. I'm going to recommit the correct version at once soon. llvm-svn: 337963 --- .../data-formatter-stl/libcxx/optional/Makefile | 7 -- .../optional/TestDataFormatterLibcxxOptional.py | 59 --------------- .../data-formatter-stl/libcxx/optional/main.cpp | 27 ------- .../Plugins/Language/CPlusPlus/LibCxxOptional.cpp | 85 ---------------------- 4 files changed, 178 deletions(-) delete mode 100644 lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libcxx/optional/Makefile delete mode 100644 lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libcxx/optional/TestDataFormatterLibcxxOptional.py delete mode 100644 lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libcxx/optional/main.cpp delete mode 100644 lldb/source/Plugins/Language/CPlusPlus/LibCxxOptional.cpp diff --git a/lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libcxx/optional/Makefile b/lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libcxx/optional/Makefile deleted file mode 100644 index a6ea665..0000000 --- a/lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libcxx/optional/Makefile +++ /dev/null @@ -1,7 +0,0 @@ -LEVEL = ../../../../../make - -CXX_SOURCES := main.cpp - -USE_LIBCPP := 1 -include $(LEVEL)/Makefile.rules -CXXFLAGS += -std=c++17 diff --git a/lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libcxx/optional/TestDataFormatterLibcxxOptional.py b/lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libcxx/optional/TestDataFormatterLibcxxOptional.py deleted file mode 100644 index 630b496..0000000 --- a/lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libcxx/optional/TestDataFormatterLibcxxOptional.py +++ /dev/null @@ -1,59 +0,0 @@ -""" -Test lldb data formatter subsystem. -""" - -from __future__ import print_function - - -import os -import time -import lldb -from lldbsuite.test.decorators import * -from lldbsuite.test.lldbtest import * -from lldbsuite.test import lldbutil - - -class LibcxxOptionalDataFormatterTestCase(TestBase): - - mydir = TestBase.compute_mydir(__file__) - - @add_test_categories(["libc++"]) - - def test_with_run_command(self): - """Test that that file and class static variables display correctly.""" - self.build() - self.runCmd("file " + self.getBuildArtifact("a.out"), CURRENT_EXECUTABLE_SET) - - bkpt = self.target().FindBreakpointByID( - lldbutil.run_break_set_by_source_regexp( - self, "break here")) - - self.runCmd("run", RUN_SUCCEEDED) - - # The stop reason of the thread should be breakpoint. - self.expect("thread list", STOPPED_DUE_TO_BREAKPOINT, - substrs=['stopped', - 'stop reason = breakpoint']) - - self.expect("frame variable number_not_engaged", - substrs=['Has Value=false']) - - self.expect("frame variable number_engaged", - substrs=['Has Value=true', - 'Value = 42', - '}']) - - self.expect("frame var numbers", - substrs=['(optional_int_vect) numbers = Has Value=true {', - 'Value = size=4 {', - '[0] = 1', - '[1] = 2', - '[2] = 3', - '[3] = 4', - '}', - '}']) - - self.expect("frame var ostring", - substrs=['(optional_string) ostring = Has Value=true {', - 'Value = "hello"', - '}']) diff --git a/lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libcxx/optional/main.cpp b/lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libcxx/optional/main.cpp deleted file mode 100644 index 8ff54d1..0000000 --- a/lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libcxx/optional/main.cpp +++ /dev/null @@ -1,27 +0,0 @@ -#include -#include -#include -#include - -using int_vect = std::vector ; -using optional_int = std::optional ; -using optional_int_vect = std::optional ; -using optional_string = std::optional ; - -int main() -{ - optional_int number_not_engaged ; - optional_int number_engaged = 42 ; - - printf( "%d\n", *number_engaged) ; - - optional_int_vect numbers{{1,2,3,4}} ; - - printf( "%d %d\n", numbers.value()[0], numbers.value()[1] ) ; - - optional_string ostring = "hello" ; - - printf( "%s\n", ostring->c_str() ) ; - - return 0; // break here -} diff --git a/lldb/source/Plugins/Language/CPlusPlus/LibCxxOptional.cpp b/lldb/source/Plugins/Language/CPlusPlus/LibCxxOptional.cpp deleted file mode 100644 index 762b824..0000000 --- a/lldb/source/Plugins/Language/CPlusPlus/LibCxxOptional.cpp +++ /dev/null @@ -1,85 +0,0 @@ -//===-- LibCxxOptional.cpp --------------------------------------*- C++ -*-===// -// -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// - -#include "LibCxx.h" -#include "lldb/DataFormatters/FormattersHelpers.h" - -using namespace lldb; -using namespace lldb_private; - -namespace { - -class OptionalFrontEnd : public SyntheticChildrenFrontEnd { -public: - OptionalFrontEnd(ValueObject &valobj) : SyntheticChildrenFrontEnd(valobj) { - Update(); - } - - size_t GetIndexOfChildWithName(const ConstString &name) override { - return formatters::ExtractIndexFromString(name.GetCString()); - } - - bool MightHaveChildren() override { return true; } - bool Update() override; - size_t CalculateNumChildren() override { return m_size; } - ValueObjectSP GetChildAtIndex(size_t idx) override; - -private: - size_t m_size = 0; - ValueObjectSP m_base_sp; -}; -} // namespace - -bool OptionalFrontEnd::Update() { - ValueObjectSP engaged_sp( - m_backend.GetChildMemberWithName(ConstString("__engaged_"), true)); - - if (!engaged_sp) - return false; - - // __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); - - return false; -} - -ValueObjectSP OptionalFrontEnd::GetChildAtIndex(size_t idx) { - if (idx >= m_size) - return ValueObjectSP(); - - // __val_ contains the underlying value of an optional if it has one. - // Currently because it is part of an anonymous union GetChildMemberWithName() - // does not peer through and find it unless we are at the parent itself. - // We can obtain the parent through __engaged_. - ValueObjectSP val_sp( - m_backend.GetChildMemberWithName(ConstString("__engaged_"), true) - ->GetParent() - ->GetChildAtIndex(0, true) - ->GetChildMemberWithName(ConstString("__val_"), true)); - - if (!val_sp) - return ValueObjectSP(); - - CompilerType holder_type = val_sp->GetCompilerType(); - - if (!holder_type) - return ValueObjectSP(); - - return val_sp->Clone(ConstString(llvm::formatv("Value").str())); -} - -SyntheticChildrenFrontEnd * -formatters::LibcxxOptionalFrontEndCreator(CXXSyntheticChildren *, - lldb::ValueObjectSP valobj_sp) { - if (valobj_sp) - return new OptionalFrontEnd(*valobj_sp); - return nullptr; -} -- 2.7.4