From c46d39b9e80e89d5b2200b884d79279a82793791 Mon Sep 17 00:00:00 2001 From: Jonas Devlieghere Date: Wed, 21 Aug 2019 21:30:55 +0000 Subject: Add char8_t support (C++20) This patch adds support for the char8_t type introduced in C++20 char8_t. The original patch was submitted by James Blachly on the LLDB mailing list [1]. I modified the patch a bit and added a test. [1] http://lists.llvm.org/pipermail/lldb-dev/2019-August/015393.html Differential revision: https://reviews.llvm.org/D66447 llvm-svn: 369582 --- .../lldbsuite/test/lang/cpp/char8_t/Makefile | 6 ++++ .../test/lang/cpp/char8_t/TestCxxChar8_t.py | 40 ++++++++++++++++++++++ .../lldbsuite/test/lang/cpp/char8_t/main.cpp | 7 ++++ 3 files changed, 53 insertions(+) create mode 100644 lldb/packages/Python/lldbsuite/test/lang/cpp/char8_t/Makefile create mode 100644 lldb/packages/Python/lldbsuite/test/lang/cpp/char8_t/TestCxxChar8_t.py create mode 100644 lldb/packages/Python/lldbsuite/test/lang/cpp/char8_t/main.cpp (limited to 'lldb/packages/Python/lldbsuite/test') diff --git a/lldb/packages/Python/lldbsuite/test/lang/cpp/char8_t/Makefile b/lldb/packages/Python/lldbsuite/test/lang/cpp/char8_t/Makefile new file mode 100644 index 00000000000..444da5fae9c --- /dev/null +++ b/lldb/packages/Python/lldbsuite/test/lang/cpp/char8_t/Makefile @@ -0,0 +1,6 @@ +LEVEL = ../../../make + +CXX_SOURCES := main.cpp +CFLAGS_EXTRAS := -std=c++2a -fchar8_t + +include $(LEVEL)/Makefile.rules diff --git a/lldb/packages/Python/lldbsuite/test/lang/cpp/char8_t/TestCxxChar8_t.py b/lldb/packages/Python/lldbsuite/test/lang/cpp/char8_t/TestCxxChar8_t.py new file mode 100644 index 00000000000..bca1d5a9797 --- /dev/null +++ b/lldb/packages/Python/lldbsuite/test/lang/cpp/char8_t/TestCxxChar8_t.py @@ -0,0 +1,40 @@ +# coding=utf8 +""" +Test that C++ supports char8_t correctly. +""" + +from __future__ import print_function + +import lldb +from lldbsuite.test.decorators import * +from lldbsuite.test.lldbtest import * +import lldbsuite.test.lldbutil as lldbutil + + +class CxxChar8_tTestCase(TestBase): + + mydir = TestBase.compute_mydir(__file__) + + @skipIf(compiler="clang", compiler_version=['<', '7.0']) + def test(self): + """Test that C++ supports char8_t correctly.""" + self.build() + exe = self.getBuildArtifact("a.out") + + # Create a target by the debugger. + target = self.dbg.CreateTarget(exe) + self.assertTrue(target, VALID_TARGET) + + # FIXME: We should be able to test this with target variable, but the + # data formatter output is broken. + lldbutil.run_break_set_by_symbol(self, 'main') + self.runCmd("run", RUN_SUCCEEDED) + + self.expect( + "frame variable a", substrs=["(char8_t) ::a = 0x61 u8'a'"]) + + self.expect( + "frame variable ab", substrs=['(const char8_t *) ::ab', 'u8"你好"']) + + self.expect( + "frame variable abc", substrs=['(char8_t [9]) ::abc = u8"你好"']) diff --git a/lldb/packages/Python/lldbsuite/test/lang/cpp/char8_t/main.cpp b/lldb/packages/Python/lldbsuite/test/lang/cpp/char8_t/main.cpp new file mode 100644 index 00000000000..b257ae2d794 --- /dev/null +++ b/lldb/packages/Python/lldbsuite/test/lang/cpp/char8_t/main.cpp @@ -0,0 +1,7 @@ +#include + +char8_t a = u8'a'; +const char8_t* ab = u8"你好"; +char8_t abc[9] = u8"你好"; + +int main (int argc, char const *argv[]) { return 0; } -- cgit v1.2.3