From eab5c2f94f5aae17c3fc513ee347ee9bc1d2bcae Mon Sep 17 00:00:00 2001 From: Arthur Eubanks Date: Fri, 7 Oct 2022 10:08:25 -0700 Subject: [PATCH] [LLDB] Fix crash when printing a struct with a static wchar_t member Similar to D135170. Reviewed By: DavidSpickett Differential Revision: https://reviews.llvm.org/D135461 --- clang/lib/AST/StmtPrinter.cpp | 3 +++ .../TestConstStaticIntegralMember.py | 2 ++ lldb/test/API/lang/cpp/const_static_integral_member/main.cpp | 4 ++++ 3 files changed, 9 insertions(+) diff --git a/clang/lib/AST/StmtPrinter.cpp b/clang/lib/AST/StmtPrinter.cpp index fabffbd32364..a29f762e10c1 100644 --- a/clang/lib/AST/StmtPrinter.cpp +++ b/clang/lib/AST/StmtPrinter.cpp @@ -1293,6 +1293,9 @@ void StmtPrinter::VisitIntegerLiteral(IntegerLiteral *Node) { break; // no suffix. case BuiltinType::UInt128: break; // no suffix. + case BuiltinType::WChar_S: + case BuiltinType::WChar_U: + break; // no suffix } } diff --git a/lldb/test/API/lang/cpp/const_static_integral_member/TestConstStaticIntegralMember.py b/lldb/test/API/lang/cpp/const_static_integral_member/TestConstStaticIntegralMember.py index 91ed14ed48ab..ed7cd2514ae8 100644 --- a/lldb/test/API/lang/cpp/const_static_integral_member/TestConstStaticIntegralMember.py +++ b/lldb/test/API/lang/cpp/const_static_integral_member/TestConstStaticIntegralMember.py @@ -42,6 +42,7 @@ class TestCase(TestBase): self.expect_expr("A::ulong_max == ulong_max", result_value="true") self.expect_expr("A::longlong_max == longlong_max", result_value="true") self.expect_expr("A::ulonglong_max == ulonglong_max", result_value="true") + self.expect_expr("A::wchar_max == wchar_max", result_value="true") self.expect_expr("A::char_min == char_min", result_value="true") self.expect_expr("A::schar_min == schar_min", result_value="true") @@ -52,6 +53,7 @@ class TestCase(TestBase): self.expect_expr("A::ulong_min == ulong_min", result_value="true") self.expect_expr("A::longlong_min == longlong_min", result_value="true") self.expect_expr("A::ulonglong_min == ulonglong_min", result_value="true") + self.expect_expr("A::wchar_min == wchar_min", result_value="true") # Test an unscoped enum. self.expect_expr("A::enum_val", result_value="enum_case2") diff --git a/lldb/test/API/lang/cpp/const_static_integral_member/main.cpp b/lldb/test/API/lang/cpp/const_static_integral_member/main.cpp index 09ab9e669813..4cd4933275ae 100644 --- a/lldb/test/API/lang/cpp/const_static_integral_member/main.cpp +++ b/lldb/test/API/lang/cpp/const_static_integral_member/main.cpp @@ -36,6 +36,7 @@ struct A { const static auto longlong_max = std::numeric_limits::max(); const static auto ulonglong_max = std::numeric_limits::max(); + const static auto wchar_max = std::numeric_limits::max(); const static auto char_min = std::numeric_limits::min(); const static auto schar_min = std::numeric_limits::min(); @@ -47,6 +48,7 @@ struct A { const static auto longlong_min = std::numeric_limits::min(); const static auto ulonglong_min = std::numeric_limits::min(); + const static auto wchar_min = std::numeric_limits::min(); const static Enum enum_val = enum_case2; const static ScopedEnum scoped_enum_val = ScopedEnum::scoped_enum_case2; @@ -93,6 +95,7 @@ int main() { auto ulong_max = A::ulong_max; auto longlong_max = A::longlong_max; auto ulonglong_max = A::ulonglong_max; + auto wchar_max = A::wchar_max; auto char_min = A::char_min; auto schar_min = A::schar_min; @@ -103,6 +106,7 @@ int main() { auto ulong_min = A::ulong_min; auto longlong_min = A::longlong_min; auto ulonglong_min = A::ulonglong_min; + auto wchar_min = A::wchar_min; int member_copy = ClassWithOnlyConstStatic::member;