From 8a1cedddd88730d9fbe73c29da2a4c7690650f41 Mon Sep 17 00:00:00 2001 From: Enrico Granata Date: Fri, 17 Jul 2015 20:54:52 +0000 Subject: [PATCH] Teach the "extend char types" (char16_t, char32_t and wchar_t) formatters that a *single character* whose value is 0 is actually a valid thing to print out llvm-svn: 242572 --- lldb/source/DataFormatters/CXXFormatterFunctions.cpp | 3 +++ lldb/test/lang/cpp/char1632_t/TestChar1632T.py | 6 ++++++ lldb/test/lang/cpp/char1632_t/main.cpp | 2 ++ lldb/test/lang/cpp/wchar_t/TestCxxWCharT.py | 3 +++ lldb/test/lang/cpp/wchar_t/main.cpp | 1 + 5 files changed, 15 insertions(+) diff --git a/lldb/source/DataFormatters/CXXFormatterFunctions.cpp b/lldb/source/DataFormatters/CXXFormatterFunctions.cpp index d3c6f8e..54af44b 100644 --- a/lldb/source/DataFormatters/CXXFormatterFunctions.cpp +++ b/lldb/source/DataFormatters/CXXFormatterFunctions.cpp @@ -362,6 +362,7 @@ lldb_private::formatters::Char16SummaryProvider (ValueObject& valobj, Stream& st options.SetPrefixToken('u'); options.SetQuote('\''); options.SetSourceSize(1); + options.SetBinaryZeroIsTerminator(false); return ReadBufferAndDumpToStream(options); } @@ -387,6 +388,7 @@ lldb_private::formatters::Char32SummaryProvider (ValueObject& valobj, Stream& st options.SetPrefixToken('U'); options.SetQuote('\''); options.SetSourceSize(1); + options.SetBinaryZeroIsTerminator(false); return ReadBufferAndDumpToStream(options); } @@ -407,6 +409,7 @@ lldb_private::formatters::WCharSummaryProvider (ValueObject& valobj, Stream& str options.SetPrefixToken('L'); options.SetQuote('\''); options.SetSourceSize(1); + options.SetBinaryZeroIsTerminator(false); return ReadBufferAndDumpToStream(options); } diff --git a/lldb/test/lang/cpp/char1632_t/TestChar1632T.py b/lldb/test/lang/cpp/char1632_t/TestChar1632T.py index 7515695..d1ae510 100644 --- a/lldb/test/lang/cpp/char1632_t/TestChar1632T.py +++ b/lldb/test/lang/cpp/char1632_t/TestChar1632T.py @@ -76,6 +76,12 @@ class Char1632TestCase(TestBase): self.expect("frame variable s16 s32", substrs = ['(char16_t *) s16 = 0x','(char32_t *) s32 = ','"色ハ匂ヘト散リヌルヲ"','"෴"']) + # check that zero values are properly handles + self.expect('frame variable cs16_zero', substrs=["U+0000 u'\\0'"]) + self.expect('frame variable cs32_zero', substrs=["U+0x00000000 U'\\0'"]) + self.expect('expression cs16_zero', substrs=["U+0000 u'\\0'"]) + self.expect('expression cs32_zero', substrs=["U+0x00000000 U'\\0'"]) + # Check that we can run expressions that return charN_t self.expect("expression u'a'",substrs = ['(char16_t) $',"61 u'a'"]) self.expect("expression U'a'",substrs = ['(char32_t) $',"61 U'a'"]) diff --git a/lldb/test/lang/cpp/char1632_t/main.cpp b/lldb/test/lang/cpp/char1632_t/main.cpp index 1fc7f28..0b690de 100644 --- a/lldb/test/lang/cpp/char1632_t/main.cpp +++ b/lldb/test/lang/cpp/char1632_t/main.cpp @@ -10,6 +10,8 @@ int main (int argc, char const *argv[]) { + auto cs16_zero = (char16_t)0; + auto cs32_zero = (char32_t)0; auto cs16 = u"hello world ྒྙྐ"; auto cs32 = U"hello world ྒྙྐ"; char16_t *s16 = (char16_t *)u"ﺸﺵۻ"; diff --git a/lldb/test/lang/cpp/wchar_t/TestCxxWCharT.py b/lldb/test/lang/cpp/wchar_t/TestCxxWCharT.py index 84529c9..8b62c54 100644 --- a/lldb/test/lang/cpp/wchar_t/TestCxxWCharT.py +++ b/lldb/test/lang/cpp/wchar_t/TestCxxWCharT.py @@ -78,6 +78,9 @@ class CxxWCharTTestCase(TestBase): self.expect("frame variable array",substrs = ['L"Hey, I\'m a super wchar_t string']) self.expect("frame variable array",substrs = ['[0]'], matching=False) + + self.expect('frame variable wchar_zero', substrs=["L'\\0'"]) + self.expect('expression wchar_zero', substrs=["L'\\0'"]) if __name__ == '__main__': import atexit diff --git a/lldb/test/lang/cpp/wchar_t/main.cpp b/lldb/test/lang/cpp/wchar_t/main.cpp index 9a74d3e..e249c37b 100644 --- a/lldb/test/lang/cpp/wchar_t/main.cpp +++ b/lldb/test/lang/cpp/wchar_t/main.cpp @@ -29,6 +29,7 @@ int main (int argc, char const *argv[]) wchar_t *ws_NULL = nullptr; wchar_t *ws_empty = L""; wchar_t array[200], * array_source = L"Hey, I'm a super wchar_t string, éõñž"; + wchar_t wchar_zero = (wchar_t)0; memcpy(array, array_source, 39 * sizeof(wchar_t)); return 0; // Set break point at this line. } -- 2.7.4